diff --git a/README.rdoc b/README.rdoc deleted file mode 100644 index e69de29..0000000 diff --git a/docs/assets/images/site_logo.gif b/docs/assets/images/site_logo.gif deleted file mode 100644 index 2517fbe..0000000 Binary files a/docs/assets/images/site_logo.gif and /dev/null differ diff --git a/ext/planetstyles/flightdeck.zip b/ext/planetstyles/flightdeck.zip deleted file mode 100644 index 537cae0..0000000 Binary files a/ext/planetstyles/flightdeck.zip and /dev/null differ diff --git a/images/avatars/gallery/Civils_F/Civil_F_1.png b/images/avatars/gallery/Civils_F/Civil_F_1.png deleted file mode 100644 index f17f125..0000000 Binary files a/images/avatars/gallery/Civils_F/Civil_F_1.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_F/Civil_F_10.png b/images/avatars/gallery/Civils_F/Civil_F_10.png deleted file mode 100644 index d90af3b..0000000 Binary files a/images/avatars/gallery/Civils_F/Civil_F_10.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_F/Civil_F_11.png b/images/avatars/gallery/Civils_F/Civil_F_11.png deleted file mode 100644 index 70363de..0000000 Binary files a/images/avatars/gallery/Civils_F/Civil_F_11.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_F/Civil_F_12.png b/images/avatars/gallery/Civils_F/Civil_F_12.png deleted file mode 100644 index c525dfa..0000000 Binary files a/images/avatars/gallery/Civils_F/Civil_F_12.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_F/Civil_F_13.png b/images/avatars/gallery/Civils_F/Civil_F_13.png deleted file mode 100644 index f9dda67..0000000 Binary files a/images/avatars/gallery/Civils_F/Civil_F_13.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_F/Civil_F_14.png b/images/avatars/gallery/Civils_F/Civil_F_14.png deleted file mode 100644 index 92df834..0000000 Binary files a/images/avatars/gallery/Civils_F/Civil_F_14.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_F/Civil_F_15.png b/images/avatars/gallery/Civils_F/Civil_F_15.png deleted file mode 100644 index 5f3bc15..0000000 Binary files a/images/avatars/gallery/Civils_F/Civil_F_15.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_F/Civil_F_16.png b/images/avatars/gallery/Civils_F/Civil_F_16.png deleted file mode 100644 index ad82d03..0000000 Binary files a/images/avatars/gallery/Civils_F/Civil_F_16.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_F/Civil_F_17.png b/images/avatars/gallery/Civils_F/Civil_F_17.png deleted file mode 100644 index e534f6f..0000000 Binary files a/images/avatars/gallery/Civils_F/Civil_F_17.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_F/Civil_F_18.png b/images/avatars/gallery/Civils_F/Civil_F_18.png deleted file mode 100644 index 950204b..0000000 Binary files a/images/avatars/gallery/Civils_F/Civil_F_18.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_F/Civil_F_19.png b/images/avatars/gallery/Civils_F/Civil_F_19.png deleted file mode 100644 index 6cacaad..0000000 Binary files a/images/avatars/gallery/Civils_F/Civil_F_19.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_F/Civil_F_2.png b/images/avatars/gallery/Civils_F/Civil_F_2.png deleted file mode 100644 index acfeec6..0000000 Binary files a/images/avatars/gallery/Civils_F/Civil_F_2.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_F/Civil_F_20.png b/images/avatars/gallery/Civils_F/Civil_F_20.png deleted file mode 100644 index ea190da..0000000 Binary files a/images/avatars/gallery/Civils_F/Civil_F_20.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_F/Civil_F_21.png b/images/avatars/gallery/Civils_F/Civil_F_21.png deleted file mode 100644 index c9706ff..0000000 Binary files a/images/avatars/gallery/Civils_F/Civil_F_21.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_F/Civil_F_22.png b/images/avatars/gallery/Civils_F/Civil_F_22.png deleted file mode 100644 index 4cfab6e..0000000 Binary files a/images/avatars/gallery/Civils_F/Civil_F_22.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_F/Civil_F_23.png b/images/avatars/gallery/Civils_F/Civil_F_23.png deleted file mode 100644 index 866d602..0000000 Binary files a/images/avatars/gallery/Civils_F/Civil_F_23.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_F/Civil_F_24.png b/images/avatars/gallery/Civils_F/Civil_F_24.png deleted file mode 100644 index 030c2af..0000000 Binary files a/images/avatars/gallery/Civils_F/Civil_F_24.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_F/Civil_F_25.png b/images/avatars/gallery/Civils_F/Civil_F_25.png deleted file mode 100644 index 133b3b7..0000000 Binary files a/images/avatars/gallery/Civils_F/Civil_F_25.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_F/Civil_F_26.png b/images/avatars/gallery/Civils_F/Civil_F_26.png deleted file mode 100644 index 1276922..0000000 Binary files a/images/avatars/gallery/Civils_F/Civil_F_26.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_F/Civil_F_27.png b/images/avatars/gallery/Civils_F/Civil_F_27.png deleted file mode 100644 index 389537a..0000000 Binary files a/images/avatars/gallery/Civils_F/Civil_F_27.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_F/Civil_F_28.png b/images/avatars/gallery/Civils_F/Civil_F_28.png deleted file mode 100644 index bdc52c7..0000000 Binary files a/images/avatars/gallery/Civils_F/Civil_F_28.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_F/Civil_F_29.png b/images/avatars/gallery/Civils_F/Civil_F_29.png deleted file mode 100644 index fb483b1..0000000 Binary files a/images/avatars/gallery/Civils_F/Civil_F_29.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_F/Civil_F_3.png b/images/avatars/gallery/Civils_F/Civil_F_3.png deleted file mode 100644 index a6fa7ad..0000000 Binary files a/images/avatars/gallery/Civils_F/Civil_F_3.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_F/Civil_F_30.png b/images/avatars/gallery/Civils_F/Civil_F_30.png deleted file mode 100644 index 5337b64..0000000 Binary files a/images/avatars/gallery/Civils_F/Civil_F_30.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_F/Civil_F_4.png b/images/avatars/gallery/Civils_F/Civil_F_4.png deleted file mode 100644 index e0fd088..0000000 Binary files a/images/avatars/gallery/Civils_F/Civil_F_4.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_F/Civil_F_5.png b/images/avatars/gallery/Civils_F/Civil_F_5.png deleted file mode 100644 index a277367..0000000 Binary files a/images/avatars/gallery/Civils_F/Civil_F_5.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_F/Civil_F_6.png b/images/avatars/gallery/Civils_F/Civil_F_6.png deleted file mode 100644 index 3c6016b..0000000 Binary files a/images/avatars/gallery/Civils_F/Civil_F_6.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_F/Civil_F_7.png b/images/avatars/gallery/Civils_F/Civil_F_7.png deleted file mode 100644 index f12b85c..0000000 Binary files a/images/avatars/gallery/Civils_F/Civil_F_7.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_F/Civil_F_8.png b/images/avatars/gallery/Civils_F/Civil_F_8.png deleted file mode 100644 index b6a76d3..0000000 Binary files a/images/avatars/gallery/Civils_F/Civil_F_8.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_F/Civil_F_9.png b/images/avatars/gallery/Civils_F/Civil_F_9.png deleted file mode 100644 index 0f2a6c1..0000000 Binary files a/images/avatars/gallery/Civils_F/Civil_F_9.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_1.png b/images/avatars/gallery/Civils_H/Civil_H_1.png deleted file mode 100644 index 530ea9d..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_1.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_10.png b/images/avatars/gallery/Civils_H/Civil_H_10.png deleted file mode 100644 index be2d896..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_10.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_11.png b/images/avatars/gallery/Civils_H/Civil_H_11.png deleted file mode 100644 index ce324e3..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_11.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_12.png b/images/avatars/gallery/Civils_H/Civil_H_12.png deleted file mode 100644 index 7aca8bf..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_12.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_13.png b/images/avatars/gallery/Civils_H/Civil_H_13.png deleted file mode 100644 index 85b30df..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_13.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_14.png b/images/avatars/gallery/Civils_H/Civil_H_14.png deleted file mode 100644 index 6c4a669..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_14.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_15.png b/images/avatars/gallery/Civils_H/Civil_H_15.png deleted file mode 100644 index 3a6f922..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_15.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_16.png b/images/avatars/gallery/Civils_H/Civil_H_16.png deleted file mode 100644 index f6b17b1..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_16.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_17.png b/images/avatars/gallery/Civils_H/Civil_H_17.png deleted file mode 100644 index 5e9dcce..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_17.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_18.png b/images/avatars/gallery/Civils_H/Civil_H_18.png deleted file mode 100644 index d79d375..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_18.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_19.png b/images/avatars/gallery/Civils_H/Civil_H_19.png deleted file mode 100644 index d7c03a0..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_19.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_2.png b/images/avatars/gallery/Civils_H/Civil_H_2.png deleted file mode 100644 index fcdc734..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_2.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_20.png b/images/avatars/gallery/Civils_H/Civil_H_20.png deleted file mode 100644 index b46d55b..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_20.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_21.png b/images/avatars/gallery/Civils_H/Civil_H_21.png deleted file mode 100644 index c1fc92b..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_21.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_22.png b/images/avatars/gallery/Civils_H/Civil_H_22.png deleted file mode 100644 index 857fad5..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_22.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_23.png b/images/avatars/gallery/Civils_H/Civil_H_23.png deleted file mode 100644 index 18f1fae..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_23.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_24.png b/images/avatars/gallery/Civils_H/Civil_H_24.png deleted file mode 100644 index f8325c6..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_24.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_25.png b/images/avatars/gallery/Civils_H/Civil_H_25.png deleted file mode 100644 index eedb63d..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_25.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_26.png b/images/avatars/gallery/Civils_H/Civil_H_26.png deleted file mode 100644 index ca97ef3..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_26.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_27.png b/images/avatars/gallery/Civils_H/Civil_H_27.png deleted file mode 100644 index a736fea..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_27.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_28.png b/images/avatars/gallery/Civils_H/Civil_H_28.png deleted file mode 100644 index ac986d3..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_28.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_29.png b/images/avatars/gallery/Civils_H/Civil_H_29.png deleted file mode 100644 index 2e8a659..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_29.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_3.png b/images/avatars/gallery/Civils_H/Civil_H_3.png deleted file mode 100644 index c365d80..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_3.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_30.png b/images/avatars/gallery/Civils_H/Civil_H_30.png deleted file mode 100644 index a2f2d7d..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_30.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_31.png b/images/avatars/gallery/Civils_H/Civil_H_31.png deleted file mode 100644 index 661bf9b..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_31.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_32.png b/images/avatars/gallery/Civils_H/Civil_H_32.png deleted file mode 100644 index dda9cae..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_32.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_33.png b/images/avatars/gallery/Civils_H/Civil_H_33.png deleted file mode 100644 index dda9cae..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_33.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_34.png b/images/avatars/gallery/Civils_H/Civil_H_34.png deleted file mode 100644 index 26b3f87..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_34.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_35.png b/images/avatars/gallery/Civils_H/Civil_H_35.png deleted file mode 100644 index ca93153..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_35.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_36.png b/images/avatars/gallery/Civils_H/Civil_H_36.png deleted file mode 100644 index 1430e5a..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_36.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_37.png b/images/avatars/gallery/Civils_H/Civil_H_37.png deleted file mode 100644 index 3352d32..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_37.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_38.png b/images/avatars/gallery/Civils_H/Civil_H_38.png deleted file mode 100644 index ffb804c..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_38.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_39.png b/images/avatars/gallery/Civils_H/Civil_H_39.png deleted file mode 100644 index abe561e..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_39.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_4.png b/images/avatars/gallery/Civils_H/Civil_H_4.png deleted file mode 100644 index b636dde..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_4.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_40.png b/images/avatars/gallery/Civils_H/Civil_H_40.png deleted file mode 100644 index fdd08ea..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_40.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_41.png b/images/avatars/gallery/Civils_H/Civil_H_41.png deleted file mode 100644 index da66c0c..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_41.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_42.png b/images/avatars/gallery/Civils_H/Civil_H_42.png deleted file mode 100644 index d3d407f..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_42.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_43.png b/images/avatars/gallery/Civils_H/Civil_H_43.png deleted file mode 100644 index c81eece..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_43.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_44.png b/images/avatars/gallery/Civils_H/Civil_H_44.png deleted file mode 100644 index 6fb25fe..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_44.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_45.png b/images/avatars/gallery/Civils_H/Civil_H_45.png deleted file mode 100644 index 354674f..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_45.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_46.png b/images/avatars/gallery/Civils_H/Civil_H_46.png deleted file mode 100644 index 7164c9b..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_46.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_47.png b/images/avatars/gallery/Civils_H/Civil_H_47.png deleted file mode 100644 index 4ed7c92..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_47.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_48.png b/images/avatars/gallery/Civils_H/Civil_H_48.png deleted file mode 100644 index 14615e5..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_48.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_49.png b/images/avatars/gallery/Civils_H/Civil_H_49.png deleted file mode 100644 index 720df0b..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_49.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_5.png b/images/avatars/gallery/Civils_H/Civil_H_5.png deleted file mode 100644 index 0130105..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_5.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_50.png b/images/avatars/gallery/Civils_H/Civil_H_50.png deleted file mode 100644 index 123354f..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_50.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_51.png b/images/avatars/gallery/Civils_H/Civil_H_51.png deleted file mode 100644 index 029f30a..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_51.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_52.png b/images/avatars/gallery/Civils_H/Civil_H_52.png deleted file mode 100644 index e98b6a9..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_52.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_53.png b/images/avatars/gallery/Civils_H/Civil_H_53.png deleted file mode 100644 index bd08bfd..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_53.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_54.png b/images/avatars/gallery/Civils_H/Civil_H_54.png deleted file mode 100644 index 40d5c6a..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_54.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_55.png b/images/avatars/gallery/Civils_H/Civil_H_55.png deleted file mode 100644 index c87948d..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_55.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_56.png b/images/avatars/gallery/Civils_H/Civil_H_56.png deleted file mode 100644 index 21c6183..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_56.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_57.png b/images/avatars/gallery/Civils_H/Civil_H_57.png deleted file mode 100644 index 2172de1..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_57.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_58.png b/images/avatars/gallery/Civils_H/Civil_H_58.png deleted file mode 100644 index cde1758..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_58.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_59.png b/images/avatars/gallery/Civils_H/Civil_H_59.png deleted file mode 100644 index 4379604..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_59.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_6.png b/images/avatars/gallery/Civils_H/Civil_H_6.png deleted file mode 100644 index bd0d1eb..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_6.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_60.png b/images/avatars/gallery/Civils_H/Civil_H_60.png deleted file mode 100644 index 73f0202..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_60.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_61.png b/images/avatars/gallery/Civils_H/Civil_H_61.png deleted file mode 100644 index a92f14e..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_61.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_62.png b/images/avatars/gallery/Civils_H/Civil_H_62.png deleted file mode 100644 index 9dfa7fa..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_62.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_63.png b/images/avatars/gallery/Civils_H/Civil_H_63.png deleted file mode 100644 index b74ae5c..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_63.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_64.png b/images/avatars/gallery/Civils_H/Civil_H_64.png deleted file mode 100644 index ad4d91f..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_64.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_65.png b/images/avatars/gallery/Civils_H/Civil_H_65.png deleted file mode 100644 index cde1758..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_65.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_66.png b/images/avatars/gallery/Civils_H/Civil_H_66.png deleted file mode 100644 index 9dfaf11..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_66.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_67.png b/images/avatars/gallery/Civils_H/Civil_H_67.png deleted file mode 100644 index f904356..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_67.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_68.png b/images/avatars/gallery/Civils_H/Civil_H_68.png deleted file mode 100644 index c802234..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_68.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_7.png b/images/avatars/gallery/Civils_H/Civil_H_7.png deleted file mode 100644 index 44f7490..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_7.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_8.png b/images/avatars/gallery/Civils_H/Civil_H_8.png deleted file mode 100644 index 9ec74a6..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_8.png and /dev/null differ diff --git a/images/avatars/gallery/Civils_H/Civil_H_9.png b/images/avatars/gallery/Civils_H/Civil_H_9.png deleted file mode 100644 index 4a0a4d0..0000000 Binary files a/images/avatars/gallery/Civils_H/Civil_H_9.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_1.png b/images/avatars/gallery/Flics/Flic_1.png deleted file mode 100644 index fceb15d..0000000 Binary files a/images/avatars/gallery/Flics/Flic_1.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_10.png b/images/avatars/gallery/Flics/Flic_10.png deleted file mode 100644 index 87daed0..0000000 Binary files a/images/avatars/gallery/Flics/Flic_10.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_100.png b/images/avatars/gallery/Flics/Flic_100.png deleted file mode 100644 index 650c32d..0000000 Binary files a/images/avatars/gallery/Flics/Flic_100.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_101.png b/images/avatars/gallery/Flics/Flic_101.png deleted file mode 100644 index 9c76fd3..0000000 Binary files a/images/avatars/gallery/Flics/Flic_101.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_102.png b/images/avatars/gallery/Flics/Flic_102.png deleted file mode 100644 index 0b46809..0000000 Binary files a/images/avatars/gallery/Flics/Flic_102.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_103.png b/images/avatars/gallery/Flics/Flic_103.png deleted file mode 100644 index 1df04c6..0000000 Binary files a/images/avatars/gallery/Flics/Flic_103.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_104.png b/images/avatars/gallery/Flics/Flic_104.png deleted file mode 100644 index ee47e53..0000000 Binary files a/images/avatars/gallery/Flics/Flic_104.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_105.png b/images/avatars/gallery/Flics/Flic_105.png deleted file mode 100644 index b3b6538..0000000 Binary files a/images/avatars/gallery/Flics/Flic_105.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_106.png b/images/avatars/gallery/Flics/Flic_106.png deleted file mode 100644 index 6593d2a..0000000 Binary files a/images/avatars/gallery/Flics/Flic_106.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_107.png b/images/avatars/gallery/Flics/Flic_107.png deleted file mode 100644 index f14c07a..0000000 Binary files a/images/avatars/gallery/Flics/Flic_107.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_108.png b/images/avatars/gallery/Flics/Flic_108.png deleted file mode 100644 index 9ca09c2..0000000 Binary files a/images/avatars/gallery/Flics/Flic_108.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_109.png b/images/avatars/gallery/Flics/Flic_109.png deleted file mode 100644 index 08f74af..0000000 Binary files a/images/avatars/gallery/Flics/Flic_109.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_110.png b/images/avatars/gallery/Flics/Flic_110.png deleted file mode 100644 index fcab689..0000000 Binary files a/images/avatars/gallery/Flics/Flic_110.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_13.png b/images/avatars/gallery/Flics/Flic_13.png deleted file mode 100644 index 2f6213a..0000000 Binary files a/images/avatars/gallery/Flics/Flic_13.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_14.png b/images/avatars/gallery/Flics/Flic_14.png deleted file mode 100644 index 9879aab..0000000 Binary files a/images/avatars/gallery/Flics/Flic_14.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_15.png b/images/avatars/gallery/Flics/Flic_15.png deleted file mode 100644 index 1c4bf4b..0000000 Binary files a/images/avatars/gallery/Flics/Flic_15.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_16.png b/images/avatars/gallery/Flics/Flic_16.png deleted file mode 100644 index 6490a3e..0000000 Binary files a/images/avatars/gallery/Flics/Flic_16.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_19.png b/images/avatars/gallery/Flics/Flic_19.png deleted file mode 100644 index ee62835..0000000 Binary files a/images/avatars/gallery/Flics/Flic_19.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_2.png b/images/avatars/gallery/Flics/Flic_2.png deleted file mode 100644 index 3c11b70..0000000 Binary files a/images/avatars/gallery/Flics/Flic_2.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_20.png b/images/avatars/gallery/Flics/Flic_20.png deleted file mode 100644 index d566640..0000000 Binary files a/images/avatars/gallery/Flics/Flic_20.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_21.png b/images/avatars/gallery/Flics/Flic_21.png deleted file mode 100644 index 261356c..0000000 Binary files a/images/avatars/gallery/Flics/Flic_21.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_22.png b/images/avatars/gallery/Flics/Flic_22.png deleted file mode 100644 index 82be618..0000000 Binary files a/images/avatars/gallery/Flics/Flic_22.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_25.png b/images/avatars/gallery/Flics/Flic_25.png deleted file mode 100644 index 8301890..0000000 Binary files a/images/avatars/gallery/Flics/Flic_25.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_27.png b/images/avatars/gallery/Flics/Flic_27.png deleted file mode 100644 index 1b6694c..0000000 Binary files a/images/avatars/gallery/Flics/Flic_27.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_28.png b/images/avatars/gallery/Flics/Flic_28.png deleted file mode 100644 index 0f591fc..0000000 Binary files a/images/avatars/gallery/Flics/Flic_28.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_30.png b/images/avatars/gallery/Flics/Flic_30.png deleted file mode 100644 index ffc3aa2..0000000 Binary files a/images/avatars/gallery/Flics/Flic_30.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_31.png b/images/avatars/gallery/Flics/Flic_31.png deleted file mode 100644 index 9f1c51e..0000000 Binary files a/images/avatars/gallery/Flics/Flic_31.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_32.png b/images/avatars/gallery/Flics/Flic_32.png deleted file mode 100644 index dec4f91..0000000 Binary files a/images/avatars/gallery/Flics/Flic_32.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_33.png b/images/avatars/gallery/Flics/Flic_33.png deleted file mode 100644 index 6859ca7..0000000 Binary files a/images/avatars/gallery/Flics/Flic_33.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_34.png b/images/avatars/gallery/Flics/Flic_34.png deleted file mode 100644 index 30b6459..0000000 Binary files a/images/avatars/gallery/Flics/Flic_34.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_35.png b/images/avatars/gallery/Flics/Flic_35.png deleted file mode 100644 index b800d2f..0000000 Binary files a/images/avatars/gallery/Flics/Flic_35.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_36.png b/images/avatars/gallery/Flics/Flic_36.png deleted file mode 100644 index dcbfdf7..0000000 Binary files a/images/avatars/gallery/Flics/Flic_36.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_38.png b/images/avatars/gallery/Flics/Flic_38.png deleted file mode 100644 index 38b1dce..0000000 Binary files a/images/avatars/gallery/Flics/Flic_38.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_39.png b/images/avatars/gallery/Flics/Flic_39.png deleted file mode 100644 index d8c488a..0000000 Binary files a/images/avatars/gallery/Flics/Flic_39.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_4.png b/images/avatars/gallery/Flics/Flic_4.png deleted file mode 100644 index 6741716..0000000 Binary files a/images/avatars/gallery/Flics/Flic_4.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_40.png b/images/avatars/gallery/Flics/Flic_40.png deleted file mode 100644 index 3412bdf..0000000 Binary files a/images/avatars/gallery/Flics/Flic_40.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_41.png b/images/avatars/gallery/Flics/Flic_41.png deleted file mode 100644 index 77b7364..0000000 Binary files a/images/avatars/gallery/Flics/Flic_41.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_43.png b/images/avatars/gallery/Flics/Flic_43.png deleted file mode 100644 index d3064ee..0000000 Binary files a/images/avatars/gallery/Flics/Flic_43.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_44.png b/images/avatars/gallery/Flics/Flic_44.png deleted file mode 100644 index 2d461d4..0000000 Binary files a/images/avatars/gallery/Flics/Flic_44.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_45.png b/images/avatars/gallery/Flics/Flic_45.png deleted file mode 100644 index eac009c..0000000 Binary files a/images/avatars/gallery/Flics/Flic_45.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_46.png b/images/avatars/gallery/Flics/Flic_46.png deleted file mode 100644 index e039b5c..0000000 Binary files a/images/avatars/gallery/Flics/Flic_46.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_47.png b/images/avatars/gallery/Flics/Flic_47.png deleted file mode 100644 index 9497726..0000000 Binary files a/images/avatars/gallery/Flics/Flic_47.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_48.png b/images/avatars/gallery/Flics/Flic_48.png deleted file mode 100644 index ce7e0f9..0000000 Binary files a/images/avatars/gallery/Flics/Flic_48.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_49.png b/images/avatars/gallery/Flics/Flic_49.png deleted file mode 100644 index ff7f4f7..0000000 Binary files a/images/avatars/gallery/Flics/Flic_49.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_5.png b/images/avatars/gallery/Flics/Flic_5.png deleted file mode 100644 index ae5cad5..0000000 Binary files a/images/avatars/gallery/Flics/Flic_5.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_50.png b/images/avatars/gallery/Flics/Flic_50.png deleted file mode 100644 index 45bc993..0000000 Binary files a/images/avatars/gallery/Flics/Flic_50.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_51.png b/images/avatars/gallery/Flics/Flic_51.png deleted file mode 100644 index 7a625ce..0000000 Binary files a/images/avatars/gallery/Flics/Flic_51.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_52.png b/images/avatars/gallery/Flics/Flic_52.png deleted file mode 100644 index 1a427af..0000000 Binary files a/images/avatars/gallery/Flics/Flic_52.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_53.png b/images/avatars/gallery/Flics/Flic_53.png deleted file mode 100644 index 901a1c1..0000000 Binary files a/images/avatars/gallery/Flics/Flic_53.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_54.png b/images/avatars/gallery/Flics/Flic_54.png deleted file mode 100644 index 2b7ff30..0000000 Binary files a/images/avatars/gallery/Flics/Flic_54.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_55.png b/images/avatars/gallery/Flics/Flic_55.png deleted file mode 100644 index ea47c9b..0000000 Binary files a/images/avatars/gallery/Flics/Flic_55.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_56.png b/images/avatars/gallery/Flics/Flic_56.png deleted file mode 100644 index 2e7abe7..0000000 Binary files a/images/avatars/gallery/Flics/Flic_56.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_57.png b/images/avatars/gallery/Flics/Flic_57.png deleted file mode 100644 index 4ade0f7..0000000 Binary files a/images/avatars/gallery/Flics/Flic_57.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_58.png b/images/avatars/gallery/Flics/Flic_58.png deleted file mode 100644 index 14a2b66..0000000 Binary files a/images/avatars/gallery/Flics/Flic_58.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_59.png b/images/avatars/gallery/Flics/Flic_59.png deleted file mode 100644 index 9afb293..0000000 Binary files a/images/avatars/gallery/Flics/Flic_59.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_6.png b/images/avatars/gallery/Flics/Flic_6.png deleted file mode 100644 index ea03575..0000000 Binary files a/images/avatars/gallery/Flics/Flic_6.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_60.png b/images/avatars/gallery/Flics/Flic_60.png deleted file mode 100644 index 46f7c34..0000000 Binary files a/images/avatars/gallery/Flics/Flic_60.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_61.png b/images/avatars/gallery/Flics/Flic_61.png deleted file mode 100644 index af44776..0000000 Binary files a/images/avatars/gallery/Flics/Flic_61.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_62.png b/images/avatars/gallery/Flics/Flic_62.png deleted file mode 100644 index 354fac5..0000000 Binary files a/images/avatars/gallery/Flics/Flic_62.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_64.png b/images/avatars/gallery/Flics/Flic_64.png deleted file mode 100644 index 60b8c95..0000000 Binary files a/images/avatars/gallery/Flics/Flic_64.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_65.png b/images/avatars/gallery/Flics/Flic_65.png deleted file mode 100644 index 46d540d..0000000 Binary files a/images/avatars/gallery/Flics/Flic_65.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_66.png b/images/avatars/gallery/Flics/Flic_66.png deleted file mode 100644 index 34660be..0000000 Binary files a/images/avatars/gallery/Flics/Flic_66.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_67.png b/images/avatars/gallery/Flics/Flic_67.png deleted file mode 100644 index 91b2fbe..0000000 Binary files a/images/avatars/gallery/Flics/Flic_67.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_68.png b/images/avatars/gallery/Flics/Flic_68.png deleted file mode 100644 index 039150d..0000000 Binary files a/images/avatars/gallery/Flics/Flic_68.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_69.png b/images/avatars/gallery/Flics/Flic_69.png deleted file mode 100644 index d441301..0000000 Binary files a/images/avatars/gallery/Flics/Flic_69.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_7.png b/images/avatars/gallery/Flics/Flic_7.png deleted file mode 100644 index 8956181..0000000 Binary files a/images/avatars/gallery/Flics/Flic_7.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_70.png b/images/avatars/gallery/Flics/Flic_70.png deleted file mode 100644 index 955197c..0000000 Binary files a/images/avatars/gallery/Flics/Flic_70.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_71.png b/images/avatars/gallery/Flics/Flic_71.png deleted file mode 100644 index 9bbbe94..0000000 Binary files a/images/avatars/gallery/Flics/Flic_71.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_72.png b/images/avatars/gallery/Flics/Flic_72.png deleted file mode 100644 index ceb8b71..0000000 Binary files a/images/avatars/gallery/Flics/Flic_72.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_73.png b/images/avatars/gallery/Flics/Flic_73.png deleted file mode 100644 index bb7a4e1..0000000 Binary files a/images/avatars/gallery/Flics/Flic_73.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_74.png b/images/avatars/gallery/Flics/Flic_74.png deleted file mode 100644 index 3dc0709..0000000 Binary files a/images/avatars/gallery/Flics/Flic_74.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_75.png b/images/avatars/gallery/Flics/Flic_75.png deleted file mode 100644 index 64b1619..0000000 Binary files a/images/avatars/gallery/Flics/Flic_75.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_76.png b/images/avatars/gallery/Flics/Flic_76.png deleted file mode 100644 index 4287dde..0000000 Binary files a/images/avatars/gallery/Flics/Flic_76.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_77.png b/images/avatars/gallery/Flics/Flic_77.png deleted file mode 100644 index 0003b96..0000000 Binary files a/images/avatars/gallery/Flics/Flic_77.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_78.png b/images/avatars/gallery/Flics/Flic_78.png deleted file mode 100644 index ff0941d..0000000 Binary files a/images/avatars/gallery/Flics/Flic_78.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_79.png b/images/avatars/gallery/Flics/Flic_79.png deleted file mode 100644 index 6351c28..0000000 Binary files a/images/avatars/gallery/Flics/Flic_79.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_8.png b/images/avatars/gallery/Flics/Flic_8.png deleted file mode 100644 index d20d2ff..0000000 Binary files a/images/avatars/gallery/Flics/Flic_8.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_80.png b/images/avatars/gallery/Flics/Flic_80.png deleted file mode 100644 index 72b1984..0000000 Binary files a/images/avatars/gallery/Flics/Flic_80.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_81.png b/images/avatars/gallery/Flics/Flic_81.png deleted file mode 100644 index 997f3e5..0000000 Binary files a/images/avatars/gallery/Flics/Flic_81.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_82.png b/images/avatars/gallery/Flics/Flic_82.png deleted file mode 100644 index 78fad6d..0000000 Binary files a/images/avatars/gallery/Flics/Flic_82.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_83.png b/images/avatars/gallery/Flics/Flic_83.png deleted file mode 100644 index abb9229..0000000 Binary files a/images/avatars/gallery/Flics/Flic_83.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_84.png b/images/avatars/gallery/Flics/Flic_84.png deleted file mode 100644 index 0a3fc7b..0000000 Binary files a/images/avatars/gallery/Flics/Flic_84.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_85.png b/images/avatars/gallery/Flics/Flic_85.png deleted file mode 100644 index c8c52f8..0000000 Binary files a/images/avatars/gallery/Flics/Flic_85.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_86.png b/images/avatars/gallery/Flics/Flic_86.png deleted file mode 100644 index 8093039..0000000 Binary files a/images/avatars/gallery/Flics/Flic_86.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_87.png b/images/avatars/gallery/Flics/Flic_87.png deleted file mode 100644 index 0959643..0000000 Binary files a/images/avatars/gallery/Flics/Flic_87.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_88.png b/images/avatars/gallery/Flics/Flic_88.png deleted file mode 100644 index e0b62e0..0000000 Binary files a/images/avatars/gallery/Flics/Flic_88.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_89.png b/images/avatars/gallery/Flics/Flic_89.png deleted file mode 100644 index ebd3c10..0000000 Binary files a/images/avatars/gallery/Flics/Flic_89.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_9.png b/images/avatars/gallery/Flics/Flic_9.png deleted file mode 100644 index 23b2ec6..0000000 Binary files a/images/avatars/gallery/Flics/Flic_9.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_90.png b/images/avatars/gallery/Flics/Flic_90.png deleted file mode 100644 index 82d1e73..0000000 Binary files a/images/avatars/gallery/Flics/Flic_90.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_91.png b/images/avatars/gallery/Flics/Flic_91.png deleted file mode 100644 index 2d4d83d..0000000 Binary files a/images/avatars/gallery/Flics/Flic_91.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_92.png b/images/avatars/gallery/Flics/Flic_92.png deleted file mode 100644 index 4d2c19c..0000000 Binary files a/images/avatars/gallery/Flics/Flic_92.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_93.png b/images/avatars/gallery/Flics/Flic_93.png deleted file mode 100644 index 0f1fda2..0000000 Binary files a/images/avatars/gallery/Flics/Flic_93.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_94.png b/images/avatars/gallery/Flics/Flic_94.png deleted file mode 100644 index 8268452..0000000 Binary files a/images/avatars/gallery/Flics/Flic_94.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_95.png b/images/avatars/gallery/Flics/Flic_95.png deleted file mode 100644 index f6efce4..0000000 Binary files a/images/avatars/gallery/Flics/Flic_95.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_96.png b/images/avatars/gallery/Flics/Flic_96.png deleted file mode 100644 index e156470..0000000 Binary files a/images/avatars/gallery/Flics/Flic_96.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_97.png b/images/avatars/gallery/Flics/Flic_97.png deleted file mode 100644 index 944fbe8..0000000 Binary files a/images/avatars/gallery/Flics/Flic_97.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_98.png b/images/avatars/gallery/Flics/Flic_98.png deleted file mode 100644 index c3f17a0..0000000 Binary files a/images/avatars/gallery/Flics/Flic_98.png and /dev/null differ diff --git a/images/avatars/gallery/Flics/Flic_99.png b/images/avatars/gallery/Flics/Flic_99.png deleted file mode 100644 index 39f9a7e..0000000 Binary files a/images/avatars/gallery/Flics/Flic_99.png and /dev/null differ diff --git a/includes/functions.php b/includes/functions.php index c6ae59b..9759eab 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -2986,9 +2986,9 @@ function phpbb_ip_normalise(string $address) // If is ipv4 if (stripos($ip_normalised, '::ffff:') === 0) -{ + { $ip_normalised = substr($ip_normalised, 7); - } + } } return $ip_normalised; @@ -4129,9 +4129,6 @@ function page_header($page_title = '', $display_online_list = false, $item_id = $template->assign_var('S_FORM_TOKEN_LOGIN', ''); } - $current_hour = date('H'); - $day_state = $current_hour >= 6 && $current_hour <= 18 ? 'jour' : 'nuit'; - // The following assigns all _common_ variables that may be used at any point in a template. $template->assign_vars(array( 'SITENAME' => $config['sitename'], @@ -4246,8 +4243,8 @@ function page_header($page_title = '', $display_online_list = false, $item_id = 'T_ICONS_PATH' => "{$web_path}{$config['icons_path']}/", 'T_RANKS_PATH' => "{$web_path}{$config['ranks_path']}/", 'T_UPLOAD_PATH' => "{$web_path}{$config['upload_path']}/", - 'T_STYLESHEET_LINK' => "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme/stylesheet_' . $day_state . '.css?assets_version=' . $config['assets_version'], - 'T_STYLESHEET_LANG_LINK'=> "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme/' . $user->lang_name . '/stylesheet_' . $day_state . '.css?assets_version=' . $config['assets_version'], + 'T_STYLESHEET_LINK' => "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme/stylesheet.css?assets_version=' . $config['assets_version'], + 'T_STYLESHEET_LANG_LINK'=> "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme/' . $user->lang_name . '/stylesheet.css?assets_version=' . $config['assets_version'], 'T_FONT_AWESOME_LINK' => !empty($config['allow_cdn']) && !empty($config['load_font_awesome_url']) ? $config['load_font_awesome_url'] : "{$web_path}assets/css/font-awesome.min.css?assets_version=" . $config['assets_version'], 'T_JQUERY_LINK' => !empty($config['allow_cdn']) && !empty($config['load_jquery_url']) ? $config['load_jquery_url'] : "{$web_path}assets/javascript/jquery-3.4.1.min.js?assets_version=" . $config['assets_version'], 'S_ALLOW_CDN' => !empty($config['allow_cdn']), @@ -4353,7 +4350,7 @@ function phpbb_generate_debug_output(\phpbb\db\driver\driver_interface $db, \php $totaltime = microtime(true) - $GLOBALS['starttime']; $debug_info[] = sprintf('Time: %.3fs', $db->get_sql_time(), ($totaltime - $db->get_sql_time()), $totaltime); } - } + } if ($phpbb_container->getParameter('debug.memory')) { @@ -4363,7 +4360,7 @@ function phpbb_generate_debug_output(\phpbb\db\driver\driver_interface $db, \php $memory_usage = get_formatted_filesize($memory_usage); $debug_info[] = 'Peak Memory Usage: ' . $memory_usage; - } + } $debug_info[] = 'GZIP: ' . (($config['gzip_compress'] && @extension_loaded('zlib')) ? 'On' : 'Off'); diff --git a/install/update/index.php b/install/update/index.php deleted file mode 100644 index 250c0ab..0000000 --- a/install/update/index.php +++ /dev/null @@ -1,395 +0,0 @@ - array('from' => '3.2.7', 'to' => '3.3.0'), - 'files' => array( - '.htaccess', - 'adm/images/phpbb_logo.svg', - 'adm/index.php', - 'adm/style/acp_attachments.html', - 'adm/style/acp_avatar_options_upload.html', - 'adm/style/acp_ban.html', - 'adm/style/acp_contact.html', - 'adm/style/acp_database.html', - 'adm/style/acp_ext_actions.html', - 'adm/style/acp_ext_list.html', - 'adm/style/acp_forums.html', - 'adm/style/acp_groups.html', - 'adm/style/acp_help_phpbb.html', - 'adm/style/acp_icons.html', - 'adm/style/acp_language.html', - 'adm/style/acp_main.html', - 'adm/style/acp_modules.html', - 'adm/style/acp_permission_roles.html', - 'adm/style/acp_posting_buttons.html', - 'adm/style/acp_ranks.html', - 'adm/style/acp_search.html', - 'adm/style/acp_styles.html', - 'adm/style/acp_users_overview.html', - 'adm/style/acp_users_prefs.html', - 'adm/style/acp_users_signature.html', - 'adm/style/admin.css', - 'adm/style/admin.js', - 'adm/style/ajax.js', - 'adm/style/captcha_recaptcha.html', - 'adm/style/installer_footer.html', - 'adm/style/overall_footer.html', - 'adm/style/overall_header.html', - 'adm/style/permission_forum_copy.html', - 'adm/style/permission_mask.html', - 'adm/style/permissions.js', - 'adm/style/progress_bar.html', - 'adm/style/simple_footer.html', - 'adm/style/simple_header.html', - 'assets/cookieconsent/cookieconsent.min.css', - 'assets/cookieconsent/cookieconsent.min.js', - 'assets/javascript/core.js', - 'assets/javascript/editor.js', - 'assets/javascript/jquery-3.4.1.min.js', - 'assets/javascript/plupload.js', - 'common.php', - 'composer.json', - 'composer.lock', - 'config/default/container/parameters.yml', - 'config/default/container/services.yml', - 'config/default/container/services_auth.yml', - 'config/default/container/services_console.yml', - 'config/default/container/services_cron.yml', - 'config/default/container/services_password.yml', - 'config/default/container/services_routing.yml', - 'config/default/container/services_text_formatter.yml', - 'config/default/container/services_twig.yml', - 'config/default/container/services_ucp.yml', - 'config/default/routing/cron.yml', - 'config/default/routing/routing.yml', - 'config/default/routing/ucp.yml', - 'cron.php', - 'download/file.php', - 'ext/phpbb/viglink/acp/viglink_helper.php', - 'ext/phpbb/viglink/composer.json', - 'ext/phpbb/viglink/composer.lock', - 'ext/phpbb/viglink/styles/all/theme/viglink.css', - 'feed.php', - 'includes/acp/acp_attachments.php', - 'includes/acp/acp_bbcodes.php', - 'includes/acp/acp_board.php', - 'includes/acp/acp_database.php', - 'includes/acp/acp_extensions.php', - 'includes/acp/acp_forums.php', - 'includes/acp/acp_help_phpbb.php', - 'includes/acp/acp_main.php', - 'includes/acp/acp_permissions.php', - 'includes/acp/acp_prune.php', - 'includes/acp/acp_reasons.php', - 'includes/acp/acp_styles.php', - 'includes/acp/acp_update.php', - 'includes/acp/acp_users.php', - 'includes/acp/auth.php', - 'includes/bbcode.php', - 'includes/compatibility_globals.php', - 'includes/constants.php', - 'includes/diff/engine.php', - 'includes/functions.php', - 'includes/functions_acp.php', - 'includes/functions_admin.php', - 'includes/functions_compatibility.php', - 'includes/functions_compress.php', - 'includes/functions_content.php', - 'includes/functions_convert.php', - 'includes/functions_display.php', - 'includes/functions_download.php', - 'includes/functions_messenger.php', - 'includes/functions_module.php', - 'includes/functions_posting.php', - 'includes/functions_privmsgs.php', - 'includes/functions_transfer.php', - 'includes/functions_user.php', - 'includes/mcp/mcp_ban.php', - 'includes/mcp/mcp_logs.php', - 'includes/mcp/mcp_main.php', - 'includes/mcp/mcp_notes.php', - 'includes/mcp/mcp_topic.php', - 'includes/mcp/mcp_warn.php', - 'includes/message_parser.php', - 'includes/questionnaire/questionnaire.php', - 'includes/startup.php', - 'includes/ucp/ucp_attachments.php', - 'includes/ucp/ucp_groups.php', - 'includes/ucp/ucp_pm.php', - 'includes/ucp/ucp_pm_compose.php', - 'includes/ucp/ucp_pm_viewfolder.php', - 'includes/ucp/ucp_profile.php', - 'includes/ucp/ucp_register.php', - 'includes/ucp/ucp_resend.php', - 'includes/utf/utf_tools.php', - 'index.php', - 'language/en/acp/attachments.php', - 'language/en/acp/board.php', - 'language/en/acp/common.php', - 'language/en/acp/forums.php', - 'language/en/acp/permissions.php', - 'language/en/acp/permissions_phpbb.php', - 'language/en/acp/posting.php', - 'language/en/acp/profile.php', - 'language/en/acp/styles.php', - 'language/en/captcha_recaptcha.php', - 'language/en/cli.php', - 'language/en/common.php', - 'language/en/email/admin_activate.txt', - 'language/en/email/user_forgot_password.txt', - 'language/en/install.php', - 'language/en/migrator.php', - 'language/en/posting.php', - 'language/en/ucp.php', - 'mcp.php', - 'memberlist.php', - 'phpbb/auth/provider/apache.php', - 'phpbb/auth/provider/base.php', - 'phpbb/auth/provider/db.php', - 'phpbb/auth/provider/ldap.php', - 'phpbb/auth/provider/oauth/oauth.php', - 'phpbb/auth/provider/oauth/service/base.php', - 'phpbb/auth/provider/oauth/service/bitly.php', - 'phpbb/auth/provider/oauth/service/facebook.php', - 'phpbb/auth/provider/oauth/service/google.php', - 'phpbb/auth/provider/oauth/service/service_interface.php', - 'phpbb/auth/provider/oauth/service/twitter.php', - 'phpbb/auth/provider/oauth/token_storage.php', - 'phpbb/auth/provider/provider_interface.php', - 'phpbb/avatar/driver/remote.php', - 'phpbb/avatar/driver/upload.php', - 'phpbb/cache/driver/memcached.php', - 'phpbb/cache/driver/memory.php', - 'phpbb/captcha/non_gd.php', - 'phpbb/captcha/plugins/qa.php', - 'phpbb/class_loader.php', - 'phpbb/config/config.php', - 'phpbb/config_php_file.php', - 'phpbb/console/command/cron/run.php', - 'phpbb/console/command/extension/enable.php', - 'phpbb/console/command/update/check.php', - 'phpbb/console/command/user/add.php', - 'phpbb/content_visibility.php', - 'phpbb/controller/helper.php', - 'phpbb/cron/controller/cron.php', - 'phpbb/cron/event/cron_runner_listener.php', - 'phpbb/cron/manager.php', - 'phpbb/cron/task/core/update_hashes.php', - 'phpbb/cron/task/wrapper.php', - 'phpbb/db/driver/driver.php', - 'phpbb/db/driver/driver_interface.php', - 'phpbb/db/driver/factory.php', - 'phpbb/db/driver/mssql_odbc.php', - 'phpbb/db/driver/mssqlnative.php', - 'phpbb/db/driver/mysqli.php', - 'phpbb/db/driver/oracle.php', - 'phpbb/db/driver/postgres.php', - 'phpbb/db/driver/sqlite3.php', - 'phpbb/db/extractor/mysql_extractor.php', - 'phpbb/db/migration/data/v30x/release_3_0_4_rc1.php', - 'phpbb/db/migration/data/v310/softdelete_p1.php', - 'phpbb/db/migration/data/v32x/timezone_p3.php', - 'phpbb/db/migration/data/v32x/user_emoji_permission.php', - 'phpbb/db/migration/data/v32x/v328.php', - 'phpbb/db/migration/data/v32x/v328rc1.php', - 'phpbb/db/migration/data/v32x/v329.php', - 'phpbb/db/migration/data/v32x/v329rc1.php', - 'phpbb/db/migration/data/v330/add_display_unapproved_posts_config.php', - 'phpbb/db/migration/data/v330/dev.php', - 'phpbb/db/migration/data/v330/forums_legend_limit.php', - 'phpbb/db/migration/data/v330/jquery_update.php', - 'phpbb/db/migration/data/v330/remove_attachment_flash.php', - 'phpbb/db/migration/data/v330/remove_email_hash.php', - 'phpbb/db/migration/data/v330/remove_max_pass_chars.php', - 'phpbb/db/migration/data/v330/reset_password.php', - 'phpbb/db/migration/data/v330/v330.php', - 'phpbb/db/migration/data/v330/v330b1.php', - 'phpbb/db/migration/data/v330/v330b2.php', - 'phpbb/db/migration/data/v330/v330rc1.php', - 'phpbb/db/migration/tool/module.php', - 'phpbb/db/migrator.php', - 'phpbb/db/tools/mssql.php', - 'phpbb/db/tools/postgres.php', - 'phpbb/db/tools/tools.php', - 'phpbb/di/container_builder.php', - 'phpbb/di/extension/container_configuration.php', - 'phpbb/di/extension/core.php', - 'phpbb/di/extension/tables.php', - 'phpbb/di/service_collection.php', - 'phpbb/event/md_exporter.php', - 'phpbb/extension/extension_interface.php', - 'phpbb/extension/manager.php', - 'phpbb/feed/controller/feed.php', - 'phpbb/feed/topics_active.php', - 'phpbb/files/filespec.php', - 'phpbb/filesystem/filesystem.php', - 'phpbb/filesystem/filesystem_interface.php', - 'phpbb/filesystem.php', - 'phpbb/finder.php', - 'phpbb/group/helper.php', - 'phpbb/help/controller/bbcode.php', - 'phpbb/help/controller/faq.php', - 'phpbb/install/controller/helper.php', - 'phpbb/install/helper/container_factory.php', - 'phpbb/install/helper/database.php', - 'phpbb/install/helper/iohandler/iohandler_interface.php', - 'phpbb/install/installer_configuration.php', - 'phpbb/install/module/install_database/task/add_config_settings.php', - 'phpbb/install/module/install_database/task/create_schema.php', - 'phpbb/install/module/install_database/task/set_up_database.php', - 'phpbb/install/module/install_filesystem/task/create_config_file.php', - 'phpbb/install/module/requirements/task/check_server_environment.php', - 'phpbb/install/module_base.php', - 'phpbb/language/language_file_loader.php', - 'phpbb/lock/db.php', - 'phpbb/lock/flock.php', - 'phpbb/message/form.php', - 'phpbb/mimetype/guesser.php', - 'phpbb/notification/type/approve_post.php', - 'phpbb/notification/type/approve_topic.php', - 'phpbb/notification/type/base.php', - 'phpbb/notification/type/post.php', - 'phpbb/notification/type/topic.php', - 'phpbb/notification/type/type_interface.php', - 'phpbb/passwords/driver/argon2i.php', - 'phpbb/passwords/driver/argon2id.php', - 'phpbb/passwords/driver/base_native.php', - 'phpbb/passwords/manager.php', - 'phpbb/permissions.php', - 'phpbb/plupload/plupload.php', - 'phpbb/report/report_handler.php', - 'phpbb/request/request.php', - 'phpbb/request/request_interface.php', - 'phpbb/request/type_cast_helper.php', - 'phpbb/search/fulltext_mysql.php', - 'phpbb/search/fulltext_native.php', - 'phpbb/search/fulltext_postgres.php', - 'phpbb/search/fulltext_sphinx.php', - 'phpbb/session.php', - 'phpbb/template/asset.php', - 'phpbb/template/context.php', - 'phpbb/template/template.php', - 'phpbb/template/twig/extension/avatar.php', - 'phpbb/template/twig/extension/config.php', - 'phpbb/template/twig/extension/username.php', - 'phpbb/template/twig/extension.php', - 'phpbb/template/twig/lexer.php', - 'phpbb/template/twig/loader.php', - 'phpbb/template/twig/node/definenode.php', - 'phpbb/template/twig/node/includeasset.php', - 'phpbb/template/twig/node/includephp.php', - 'phpbb/template/twig/tokenparser/defineparser.php', - 'phpbb/template/twig/tokenparser/event.php', - 'phpbb/template/twig/tokenparser/includecss.php', - 'phpbb/template/twig/tokenparser/includejs.php', - 'phpbb/template/twig/tokenparser/includeparser.php', - 'phpbb/template/twig/tokenparser/includephp.php', - 'phpbb/template/twig/tokenparser/php.php', - 'phpbb/textformatter/acp_utils_interface.php', - 'phpbb/textformatter/s9e/acp_utils.php', - 'phpbb/textformatter/s9e/bbcode_merger.php', - 'phpbb/textformatter/s9e/factory.php', - 'phpbb/textformatter/s9e/link_helper.php', - 'phpbb/textformatter/s9e/parser.php', - 'phpbb/textformatter/s9e/quote_helper.php', - 'phpbb/ucp/controller/reset_password.php', - 'phpbb/user.php', - 'phpbb/user_loader.php', - 'posting.php', - 'report.php', - 'search.php', - 'styles/prosilver/style.cfg', - 'styles/prosilver/template/attachment.html', - 'styles/prosilver/template/bbcode.html', - 'styles/prosilver/template/captcha_recaptcha.html', - 'styles/prosilver/template/forum_fn.js', - 'styles/prosilver/template/forumlist_body.html', - 'styles/prosilver/template/mcp_forum.html', - 'styles/prosilver/template/mcp_move.html', - 'styles/prosilver/template/mcp_topic.html', - 'styles/prosilver/template/memberlist_body.html', - 'styles/prosilver/template/memberlist_search.html', - 'styles/prosilver/template/navbar_header.html', - 'styles/prosilver/template/overall_footer.html', - 'styles/prosilver/template/overall_header.html', - 'styles/prosilver/template/plupload.html', - 'styles/prosilver/template/posting_attach_body.html', - 'styles/prosilver/template/posting_buttons.html', - 'styles/prosilver/template/posting_layout.html', - 'styles/prosilver/template/posting_poll_body.html', - 'styles/prosilver/template/posting_review.html', - 'styles/prosilver/template/posting_topic_review.html', - 'styles/prosilver/template/search_results.html', - 'styles/prosilver/template/simple_footer.html', - 'styles/prosilver/template/ucp_agreement.html', - 'styles/prosilver/template/ucp_attachments.html', - 'styles/prosilver/template/ucp_avatar_options_upload.html', - 'styles/prosilver/template/ucp_groups_manage.html', - 'styles/prosilver/template/ucp_pm_history.html', - 'styles/prosilver/template/ucp_pm_viewmessage_print.html', - 'styles/prosilver/template/ucp_profile_profile_info.html', - 'styles/prosilver/template/ucp_register.html', - 'styles/prosilver/template/ucp_reset_password.html', - 'styles/prosilver/template/viewforum_body.html', - 'styles/prosilver/template/viewtopic_body.html', - 'styles/prosilver/template/viewtopic_print.html', - 'styles/prosilver/theme/colours.css', - 'styles/prosilver/theme/common.css', - 'styles/prosilver/theme/forms.css', - 'styles/prosilver/theme/icons.css', - 'styles/prosilver/theme/images/site_logo.svg', - 'styles/prosilver/theme/plupload.css', - 'styles/prosilver/theme/print.css', - 'styles/prosilver/theme/stylesheet.css', - 'ucp.php', - 'viewforum.php', - 'viewonline.php', - 'viewtopic.php', - ), - 'binary' => array( - 'images/upload_icons/flash.gif', - 'styles/prosilver/theme/images/bg_header.gif', - 'styles/prosilver/theme/images/bg_list.gif', - 'styles/prosilver/theme/images/icon_download.gif', - 'styles/prosilver/theme/images/icon_offline.gif', - 'styles/prosilver/theme/images/icon_online.gif', - 'styles/prosilver/theme/images/icon_rate_bad.gif', - 'styles/prosilver/theme/images/icon_rate_good.gif', - 'styles/prosilver/theme/images/quote.gif', - 'styles/prosilver/theme/images/quote_rtl.gif', - 'styles/prosilver/theme/images/site_logo.gif', - ), - 'deleted' => array( - 'adm/style/acp_ext_delete_data.html', - 'adm/style/acp_ext_disable.html', - 'adm/style/acp_ext_enable.html', - 'assets/javascript/jquery.min.js', - 'images/upload_icons/flash.gif', - 'includes/ucp/ucp_remind.php', - 'language/en/email/user_activate_passwd.txt', - 'phpbb/cache/driver/apc.php', - 'phpbb/cache/driver/eaccelerator.php', - 'phpbb/cache/driver/memcache.php', - 'phpbb/cache/driver/xcache.php', - 'phpbb/console/command/fixup/recalculate_email_hash.php', - 'phpbb/db/driver/mysql.php', - 'phpbb/db/tools.php', - 'styles/prosilver/template/ucp_remind.html', - 'styles/prosilver/theme/images/bg_header.gif', - 'styles/prosilver/theme/images/bg_list.gif', - 'styles/prosilver/theme/images/icon_download.gif', - 'styles/prosilver/theme/images/icon_offline.gif', - 'styles/prosilver/theme/images/icon_online.gif', - 'styles/prosilver/theme/images/icon_rate_bad.gif', - 'styles/prosilver/theme/images/icon_rate_good.gif', - 'styles/prosilver/theme/images/quote.gif', - 'styles/prosilver/theme/images/quote_rtl.gif', - 'styles/prosilver/theme/images/site_logo.gif', - ), -); diff --git a/install/update/new/.htaccess b/install/update/new/.htaccess deleted file mode 100644 index 0be28ab..0000000 --- a/install/update/new/.htaccess +++ /dev/null @@ -1,92 +0,0 @@ - -RewriteEngine on - -# -# Uncomment the statement below if URL rewriting doesn't -# work properly. If you installed phpBB in a subdirectory -# of your site, properly set the argument for the statement. -# e.g.: if your domain is test.com and you installed phpBB -# in http://www.test.com/phpBB/index.php you have to set -# the statement RewriteBase /phpBB/ -# -#RewriteBase / - -# -# Uncomment the statement below if you want to make use of -# HTTP authentication and it does not already work. -# This could be required if you are for example using PHP via Apache CGI. -# -#RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L] - -# -# The following 3 lines will rewrite URLs passed through the front controller -# to not require app.php in the actual URL. In other words, a controller is -# by default accessed at /app.php/my/controller, but can also be accessed at -# /my/controller -# -RewriteCond %{REQUEST_FILENAME} !-f -RewriteCond %{REQUEST_FILENAME} !-d -RewriteRule ^(.*)$ app.php [QSA,L] - -# -# If symbolic links are not already being followed, -# uncomment the line below. -# http://anothersysadmin.wordpress.com/2008/06/10/mod_rewrite-forbidden-403-with-apache-228/ -# -#Options +FollowSymLinks - - -# Apache content negotation tries to interpret non-existent paths as files if -# MultiViews is enabled. This will however cause issues with paths containg -# dots, e.g. for the cron tasks - - Options -MultiViews - - -# With Apache 2.4 the "Order, Deny" syntax has been deprecated and moved from -# module mod_authz_host to a new module called mod_access_compat (which may be -# disabled) and a new "Require" syntax has been introduced to mod_authz_host. -# We could just conditionally provide both versions, but unfortunately Apache -# does not explicitly tell us its version if the module mod_version is not -# available. In this case, we check for the availability of module -# mod_authz_core (which should be on 2.4 or higher only) as a best guess. - - - - Order Allow,Deny - Deny from All - - - Order Allow,Deny - Deny from All - - - = 2.4> - - Require all denied - - - Require all denied - - - - - - - Order Allow,Deny - Deny from All - - - Order Allow,Deny - Deny from All - - - - - Require all denied - - - Require all denied - - - diff --git a/install/update/new/adm/images/alert_close.png b/install/update/new/adm/images/alert_close.png deleted file mode 100644 index 79750a0..0000000 Binary files a/install/update/new/adm/images/alert_close.png and /dev/null differ diff --git a/install/update/new/adm/images/arrow_down.gif b/install/update/new/adm/images/arrow_down.gif deleted file mode 100644 index b7fbf7e..0000000 Binary files a/install/update/new/adm/images/arrow_down.gif and /dev/null differ diff --git a/install/update/new/adm/images/arrow_left.gif b/install/update/new/adm/images/arrow_left.gif deleted file mode 100644 index ac92cb4..0000000 Binary files a/install/update/new/adm/images/arrow_left.gif and /dev/null differ diff --git a/install/update/new/adm/images/arrow_right.gif b/install/update/new/adm/images/arrow_right.gif deleted file mode 100644 index 3a080ff..0000000 Binary files a/install/update/new/adm/images/arrow_right.gif and /dev/null differ diff --git a/install/update/new/adm/images/arrow_up.gif b/install/update/new/adm/images/arrow_up.gif deleted file mode 100644 index 0ff5872..0000000 Binary files a/install/update/new/adm/images/arrow_up.gif and /dev/null differ diff --git a/install/update/new/adm/images/bg_button.gif b/install/update/new/adm/images/bg_button.gif deleted file mode 100644 index 03172ff..0000000 Binary files a/install/update/new/adm/images/bg_button.gif and /dev/null differ diff --git a/install/update/new/adm/images/bg_hash1.gif b/install/update/new/adm/images/bg_hash1.gif deleted file mode 100644 index 6116367..0000000 Binary files a/install/update/new/adm/images/bg_hash1.gif and /dev/null differ diff --git a/install/update/new/adm/images/bg_hash2.gif b/install/update/new/adm/images/bg_hash2.gif deleted file mode 100644 index d318403..0000000 Binary files a/install/update/new/adm/images/bg_hash2.gif and /dev/null differ diff --git a/install/update/new/adm/images/bg_hash3.gif b/install/update/new/adm/images/bg_hash3.gif deleted file mode 100644 index 40bc7e1..0000000 Binary files a/install/update/new/adm/images/bg_hash3.gif and /dev/null differ diff --git a/install/update/new/adm/images/bg_hash4.gif b/install/update/new/adm/images/bg_hash4.gif deleted file mode 100644 index 54e7f00..0000000 Binary files a/install/update/new/adm/images/bg_hash4.gif and /dev/null differ diff --git a/install/update/new/adm/images/bg_header.gif b/install/update/new/adm/images/bg_header.gif deleted file mode 100644 index b95bf3b..0000000 Binary files a/install/update/new/adm/images/bg_header.gif and /dev/null differ diff --git a/install/update/new/adm/images/bg_header.jpg b/install/update/new/adm/images/bg_header.jpg deleted file mode 100644 index 5ecec53..0000000 Binary files a/install/update/new/adm/images/bg_header.jpg and /dev/null differ diff --git a/install/update/new/adm/images/bg_tabs_alt1.gif b/install/update/new/adm/images/bg_tabs_alt1.gif deleted file mode 100644 index 335a72c..0000000 Binary files a/install/update/new/adm/images/bg_tabs_alt1.gif and /dev/null differ diff --git a/install/update/new/adm/images/bg_tabs_alt2.gif b/install/update/new/adm/images/bg_tabs_alt2.gif deleted file mode 100644 index a2142d5..0000000 Binary files a/install/update/new/adm/images/bg_tabs_alt2.gif and /dev/null differ diff --git a/install/update/new/adm/images/cellpic3.gif b/install/update/new/adm/images/cellpic3.gif deleted file mode 100644 index be46fc6..0000000 Binary files a/install/update/new/adm/images/cellpic3.gif and /dev/null differ diff --git a/install/update/new/adm/images/file_conflict.gif b/install/update/new/adm/images/file_conflict.gif deleted file mode 100644 index 4458c4f..0000000 Binary files a/install/update/new/adm/images/file_conflict.gif and /dev/null differ diff --git a/install/update/new/adm/images/file_modified.gif b/install/update/new/adm/images/file_modified.gif deleted file mode 100644 index 17e8f97..0000000 Binary files a/install/update/new/adm/images/file_modified.gif and /dev/null differ diff --git a/install/update/new/adm/images/file_new.gif b/install/update/new/adm/images/file_new.gif deleted file mode 100644 index d0ec758..0000000 Binary files a/install/update/new/adm/images/file_new.gif and /dev/null differ diff --git a/install/update/new/adm/images/file_new_conflict.gif b/install/update/new/adm/images/file_new_conflict.gif deleted file mode 100644 index 84efde4..0000000 Binary files a/install/update/new/adm/images/file_new_conflict.gif and /dev/null differ diff --git a/install/update/new/adm/images/file_not_modified.gif b/install/update/new/adm/images/file_not_modified.gif deleted file mode 100644 index 8f9b3d3..0000000 Binary files a/install/update/new/adm/images/file_not_modified.gif and /dev/null differ diff --git a/install/update/new/adm/images/file_up_to_date.gif b/install/update/new/adm/images/file_up_to_date.gif deleted file mode 100644 index c372342..0000000 Binary files a/install/update/new/adm/images/file_up_to_date.gif and /dev/null differ diff --git a/install/update/new/adm/images/gradient2b.gif b/install/update/new/adm/images/gradient2b.gif deleted file mode 100644 index a810765..0000000 Binary files a/install/update/new/adm/images/gradient2b.gif and /dev/null differ diff --git a/install/update/new/adm/images/icon_delete.gif b/install/update/new/adm/images/icon_delete.gif deleted file mode 100644 index 57962d5..0000000 Binary files a/install/update/new/adm/images/icon_delete.gif and /dev/null differ diff --git a/install/update/new/adm/images/icon_delete_disabled.gif b/install/update/new/adm/images/icon_delete_disabled.gif deleted file mode 100644 index da55bbb..0000000 Binary files a/install/update/new/adm/images/icon_delete_disabled.gif and /dev/null differ diff --git a/install/update/new/adm/images/icon_down.gif b/install/update/new/adm/images/icon_down.gif deleted file mode 100644 index 793db26..0000000 Binary files a/install/update/new/adm/images/icon_down.gif and /dev/null differ diff --git a/install/update/new/adm/images/icon_down_disabled.gif b/install/update/new/adm/images/icon_down_disabled.gif deleted file mode 100644 index 3ba3697..0000000 Binary files a/install/update/new/adm/images/icon_down_disabled.gif and /dev/null differ diff --git a/install/update/new/adm/images/icon_edit.gif b/install/update/new/adm/images/icon_edit.gif deleted file mode 100644 index c95cf98..0000000 Binary files a/install/update/new/adm/images/icon_edit.gif and /dev/null differ diff --git a/install/update/new/adm/images/icon_edit_disabled.gif b/install/update/new/adm/images/icon_edit_disabled.gif deleted file mode 100644 index ac96b0e..0000000 Binary files a/install/update/new/adm/images/icon_edit_disabled.gif and /dev/null differ diff --git a/install/update/new/adm/images/icon_folder.gif b/install/update/new/adm/images/icon_folder.gif deleted file mode 100644 index 845618c..0000000 Binary files a/install/update/new/adm/images/icon_folder.gif and /dev/null differ diff --git a/install/update/new/adm/images/icon_folder_link.gif b/install/update/new/adm/images/icon_folder_link.gif deleted file mode 100644 index efeaf0a..0000000 Binary files a/install/update/new/adm/images/icon_folder_link.gif and /dev/null differ diff --git a/install/update/new/adm/images/icon_folder_lock.gif b/install/update/new/adm/images/icon_folder_lock.gif deleted file mode 100644 index 7afb092..0000000 Binary files a/install/update/new/adm/images/icon_folder_lock.gif and /dev/null differ diff --git a/install/update/new/adm/images/icon_subfolder.gif b/install/update/new/adm/images/icon_subfolder.gif deleted file mode 100644 index 7119486..0000000 Binary files a/install/update/new/adm/images/icon_subfolder.gif and /dev/null differ diff --git a/install/update/new/adm/images/icon_sync.gif b/install/update/new/adm/images/icon_sync.gif deleted file mode 100644 index 16223df..0000000 Binary files a/install/update/new/adm/images/icon_sync.gif and /dev/null differ diff --git a/install/update/new/adm/images/icon_sync_disabled.gif b/install/update/new/adm/images/icon_sync_disabled.gif deleted file mode 100644 index 3998504..0000000 Binary files a/install/update/new/adm/images/icon_sync_disabled.gif and /dev/null differ diff --git a/install/update/new/adm/images/icon_trace.gif b/install/update/new/adm/images/icon_trace.gif deleted file mode 100644 index 5c622e9..0000000 Binary files a/install/update/new/adm/images/icon_trace.gif and /dev/null differ diff --git a/install/update/new/adm/images/icon_up.gif b/install/update/new/adm/images/icon_up.gif deleted file mode 100644 index 7daa95c..0000000 Binary files a/install/update/new/adm/images/icon_up.gif and /dev/null differ diff --git a/install/update/new/adm/images/icon_up_disabled.gif b/install/update/new/adm/images/icon_up_disabled.gif deleted file mode 100644 index 2797192..0000000 Binary files a/install/update/new/adm/images/icon_up_disabled.gif and /dev/null differ diff --git a/install/update/new/adm/images/innerbox_bg.gif b/install/update/new/adm/images/innerbox_bg.gif deleted file mode 100644 index 460526f..0000000 Binary files a/install/update/new/adm/images/innerbox_bg.gif and /dev/null differ diff --git a/install/update/new/adm/images/loading.gif b/install/update/new/adm/images/loading.gif deleted file mode 100644 index e1ed088..0000000 Binary files a/install/update/new/adm/images/loading.gif and /dev/null differ diff --git a/install/update/new/adm/images/no_avatar.gif b/install/update/new/adm/images/no_avatar.gif deleted file mode 100644 index ad73330..0000000 Binary files a/install/update/new/adm/images/no_avatar.gif and /dev/null differ diff --git a/install/update/new/adm/images/no_image.png b/install/update/new/adm/images/no_image.png deleted file mode 100644 index 1061ee3..0000000 Binary files a/install/update/new/adm/images/no_image.png and /dev/null differ diff --git a/install/update/new/adm/images/phpbb_logo.png b/install/update/new/adm/images/phpbb_logo.png deleted file mode 100644 index 2d76ef1..0000000 Binary files a/install/update/new/adm/images/phpbb_logo.png and /dev/null differ diff --git a/install/update/new/adm/images/phpbb_logo.svg b/install/update/new/adm/images/phpbb_logo.svg deleted file mode 100644 index 2a24106..0000000 --- a/install/update/new/adm/images/phpbb_logo.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/install/update/new/adm/images/progress_bar.gif b/install/update/new/adm/images/progress_bar.gif deleted file mode 100644 index 1ae2651..0000000 Binary files a/install/update/new/adm/images/progress_bar.gif and /dev/null differ diff --git a/install/update/new/adm/images/spacer.gif b/install/update/new/adm/images/spacer.gif deleted file mode 100644 index cd29009..0000000 Binary files a/install/update/new/adm/images/spacer.gif and /dev/null differ diff --git a/install/update/new/adm/index.php b/install/update/new/adm/index.php deleted file mode 100644 index c648fdf..0000000 --- a/install/update/new/adm/index.php +++ /dev/null @@ -1,90 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -*/ -define('IN_PHPBB', true); -define('ADMIN_START', true); -define('NEED_SID', true); - -// Include files -$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); -require($phpbb_root_path . 'common.' . $phpEx); -require($phpbb_root_path . 'includes/functions_acp.' . $phpEx); -require($phpbb_root_path . 'includes/functions_admin.' . $phpEx); -require($phpbb_root_path . 'includes/functions_module.' . $phpEx); - -// Start session management -$user->session_begin(); -$auth->acl($user->data); -$user->setup('acp/common'); -// End session management - -// Have they authenticated (again) as an admin for this session? -if (!isset($user->data['session_admin']) || !$user->data['session_admin']) -{ - login_box('', $user->lang['LOGIN_ADMIN_CONFIRM'], $user->lang['LOGIN_ADMIN_SUCCESS'], true, false); -} - -// Is user any type of admin? No, then stop here, each script needs to -// check specific permissions but this is a catchall -if (!$auth->acl_get('a_')) -{ - send_status_line(403, 'Forbidden'); - trigger_error('NO_ADMIN'); -} - -// We define the admin variables now, because the user is now able to use the admin related features... -define('IN_ADMIN', true); - -// Some oft used variables -$file_uploads = (@ini_get('file_uploads') == '1' || strtolower(@ini_get('file_uploads')) === 'on') ? true : false; -$module_id = $request->variable('i', ''); -$mode = $request->variable('mode', ''); - -// Set custom style for admin area -$template->set_custom_style(array( - array( - 'name' => 'adm', - 'ext_path' => 'adm/style/', - ), -), $phpbb_admin_path . 'style'); - -$template->assign_var('T_ASSETS_PATH', $phpbb_root_path . 'assets'); -$template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style'); - -// Instantiate new module -$module = new p_master(); - -// Instantiate module system and generate list of available modules -$module->list_modules('acp'); - -// Select the active module -$module->set_active($module_id, $mode); - -// Assign data to the template engine for the list of modules -// We do this before loading the active module for correct menu display in trigger_error -$module->assign_tpl_vars(append_sid("{$phpbb_admin_path}index.$phpEx")); - -// Load and execute the relevant module -$module->load_active(); - -// Generate the page -adm_page_header($module->get_page_title()); - -$template->set_filenames(array( - 'body' => $module->get_tpl_name(), -)); - -adm_page_footer(); diff --git a/install/update/new/adm/style/acp_attachments.html b/install/update/new/adm/style/acp_attachments.html deleted file mode 100644 index 7a66f17..0000000 --- a/install/update/new/adm/style/acp_attachments.html +++ /dev/null @@ -1,495 +0,0 @@ - - - - - - « {L_BACK} - - -

{L_TITLE}

- -

{L_TITLE_EXPLAIN}

- - -
-

{L_WARNING}

-

{WARNING_MSG}

-
- - - -
-

{L_NOTIFY}

-

{NOTIFY_MSG}

-
- - - -

{L_UPLOADING_FILES}

- - - :: {upload.FILE_INFO}
- {upload.DENIED}{upload.ERROR_MSG}{L_SUCCESSFULLY_UPLOADED} -

- - - - - - -
- - - - - -
- {options.LEGEND} - - -
-

{options.TITLE_EXPLAIN}
-
{options.CONTENT}
-
- - - -
- -
- {L_SUBMIT} -   - -
- - -
-

{L_SECURE_DOWNLOAD_NOTICE}

-
- - -
- {L_SECURE_TITLE} -

{L_DOWNLOAD_ADD_IPS_EXPLAIN}

-
-
-
-
-
-

{L_EXCLUDE_ENTERED_IP}
-
-
-
- -

- -

-
- -
- {L_REMOVE_IPS} - -

{L_DOWNLOAD_REMOVE_IPS_EXPLAIN}

-
-
-
-
- -

- -

-
- - -

{L_NO_IPS_DEFINED}

- - {S_FORM_TOKEN} - -
- - - - - - -
-
- - - - {L_LEGEND} -
-
-
-
-
-

{L_SPECIAL_CATEGORY_EXPLAIN}
-
{S_CATEGORY_SELECT}
-
-
-
-
checked="checked" />
-
-
-
-
checked="checked" />
-
-
-
-
-
 src="{ROOT_PATH}images/spacer.gif"src="{UPLOAD_ICON_SRC}" id="image_upload_icon" alt="" title="" /> 
-
-
-
-
-
-
-
-
{ASSIGNED_EXTENSIONS}
[{L_GO_TO_EXTENSIONS} ]
-
-
-
-

{L_ALLOWED_FORUMS_EXPLAIN}
-
-
-
-
- -

-   - -

- {S_FORM_TOKEN} -
- -
- - -
-
- {L_TITLE} - - - - - - - - - - - - - - - - - - - - - - - - -
{L_EXTENSION_GROUP}{L_SPECIAL_CATEGORY}{L_OPTIONS}
 
{groups.GROUP_NAME} -
» {L_NOT_ALLOWED_IN_PM} -
» {L_ONLY_ALLOWED_IN_PM} -
» {L_NOT_ALLOWED_IN_PM_POST} -
» {L_ALLOWED_IN_PM_POST} -
{groups.CATEGORY} {ICON_EDIT}  {ICON_DELETE} 
-

- {L_CREATE_GROUP}{L_COLON} - -

- {S_FORM_TOKEN} -
-
- - - - - -
-
- {L_ADD_EXTENSION} -
-
-
-
-
-
-
{GROUP_SELECT_OPTIONS}
-
- -

- -

- {S_FORM_TOKEN} -
-
- -
- -
- {L_TITLE} - - - - - - - - - - - - - - - - - - - - - - - - -
{L_EXTENSION}{L_EXTENSION_GROUP}{L_DELETE}
 
{extensions.EXTENSION}{extensions.GROUP_OPTIONS}
- -

-   - -

- {S_FORM_TOKEN} -
-
- - - -
- -
- {L_TITLE} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{L_FILENAME}{L_FILEDATE}{L_FILESIZE}{L_ATTACH_POST_ID}{L_ATTACH_TO_POST}{L_DELETE}
{orphan.REAL_FILENAME}{orphan.FILETIME}{orphan.FILESIZE}{L_ATTACH_ID}{L_COLON}
 {L_MARK_ALL} :: {L_UNMARK_ALL}{L_MARK_ALL} :: {L_UNMARK_ALL}
- -
-

{L_NO_ATTACHMENTS}

-
- - - - - - - -

-   - -

- - - {S_FORM_TOKEN} -
-
- - - -
- -
- {L_TITLE} - - - - - - - - - - - - - - - {% for attachments in attachments %} - - - - - - - {% endfor %} - -
{L_FILENAME}{L_POSTED}{L_FILESIZE}{L_MARK}
- {{ lang('EXTENSION_GROUP') ~ lang('COLON') }} {{ attachments.EXT_GROUP_NAME }} - {% if attachments.S_IN_MESSAGE %} -
{{ attachments.L_DOWNLOAD_COUNT }} -
{{ lang('IN') }} {{ lang('PRIVATE_MESSAGE') }} - {% else %} -
{{ attachments.REAL_FILENAME }} - {% if attachments.COMMENT %}
{{ attachments.COMMENT }}{% endif %} -
{{ attachments.L_DOWNLOAD_COUNT }} -
{{ lang('TOPIC') ~ lang('COLON') }} {{ attachments.TOPIC_TITLE }} - {% endif %} -
{{ attachments.FILETIME }}
{{ lang('POST_BY_AUTHOR') }} {{ attachments.ATTACHMENT_POSTER }}
{{ attachments.FILESIZE }}
- -
-

{L_NO_ATTACHMENTS}

-
- - - - - - -
- {L_DISPLAY_LOG}{L_COLON}  {S_LIMIT_DAYS} {L_SORT_BY}{L_COLON} {S_SORT_KEY} {S_SORT_DIR} - -
- -
- - -
-
-

- {L_MARK_ALL} • - {L_UNMARK_ALL} -

-
- - {S_FORM_TOKEN} -
-
- - -
- {L_RESYNC_STATS} -
-
-

{L_RESYNC_FILES_STATS_EXPLAIN}
-
-
-
-
- - - - diff --git a/install/update/new/adm/style/acp_avatar_options_upload.html b/install/update/new/adm/style/acp_avatar_options_upload.html deleted file mode 100644 index 666950e..0000000 --- a/install/update/new/adm/style/acp_avatar_options_upload.html +++ /dev/null @@ -1,11 +0,0 @@ -
-
-
-
- - -
-

{L_UPLOAD_AVATAR_URL_EXPLAIN}
-
-
- diff --git a/install/update/new/adm/style/acp_ban.html b/install/update/new/adm/style/acp_ban.html deleted file mode 100644 index d0eab75..0000000 --- a/install/update/new/adm/style/acp_ban.html +++ /dev/null @@ -1,131 +0,0 @@ - - - - -

{L_ACP_BAN_EXPLAIN}

- -

{L_TITLE}

- -

{L_EXPLAIN}

- - - -
- -
- {L_TITLE} -
-
-
-
[ {L_FIND_USERNAME} ]
-
-
-
-
- -
-
-

{L_BAN_EXCLUDE_EXPLAIN}
-
-
-
-
-
-
-
-
-
-
-
- -

-   - -

-{S_FORM_TOKEN} -
-
- -

- -

{L_UNBAN_TITLE}

- -

{L_UNBAN_EXPLAIN}

- -
- -
- {L_UNBAN_TITLE} - - -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -

-   - -

- {S_FORM_TOKEN} -
- - - -

{L_NO_BAN_CELL}

- {S_FORM_TOKEN} - - - - -
- - diff --git a/install/update/new/adm/style/acp_contact.html b/install/update/new/adm/style/acp_contact.html deleted file mode 100644 index c46a2d7..0000000 --- a/install/update/new/adm/style/acp_contact.html +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - -

{L_ACP_CONTACT_SETTINGS}

- -

{L_ACP_CONTACT_SETTINGS_EXPLAIN}

- -
-
- {L_GENERAL_OPTIONS} -
-

{L_CONTACT_US_ENABLE_EXPLAIN}
-
- - -
-
-
- - -
- {L_CONTACT_US_INFO_PREVIEW} -

{CONTACT_US_INFO_PREVIEW}

-
- - -
- {L_CONTACT_US_INFO} -

{L_CONTACT_US_INFO_EXPLAIN}

- - - -
-
-
- -
- -
- -
- - - - - - - - - -
-
{L_OPTIONS}{L_COLON} {BBCODE_STATUS} :: {IMG_STATUS} :: {FLASH_STATUS} :: {URL_STATUS} :: {SMILIES_STATUS}
-
-
- -
-   - - {S_FORM_TOKEN} -
-
- - diff --git a/install/update/new/adm/style/acp_database.html b/install/update/new/adm/style/acp_database.html deleted file mode 100644 index d3433a8..0000000 --- a/install/update/new/adm/style/acp_database.html +++ /dev/null @@ -1,90 +0,0 @@ - - - - - -

{L_ACP_RESTORE}

- -

{L_ACP_RESTORE_EXPLAIN}

- - -
- -
- {L_RESTORE_OPTIONS} -
-
-
-
- -

-   -   -

- {S_FORM_TOKEN} -
-
- -
-

{L_ACP_NO_ITEMS}

-
- - - -

{L_ACP_BACKUP}

- -

{L_ACP_BACKUP_EXPLAIN}

- - - -
- -
- {L_BACKUP_OPTIONS} -
-
-
- -
-
-
-
-
- -
-
-
-
-
-
{L_SELECT_ALL} :: {L_DESELECT_ALL}
-
- -

-   - -

- {S_FORM_TOKEN} -
-
- - - - diff --git a/install/update/new/adm/style/acp_ext_actions.html b/install/update/new/adm/style/acp_ext_actions.html deleted file mode 100644 index 6b59ab7..0000000 --- a/install/update/new/adm/style/acp_ext_actions.html +++ /dev/null @@ -1,7 +0,0 @@ -{% for action in enabled.actions %} - {{ action.L_ACTION }}{% if not action.S_LAST_ROW %} | {% endif %} -{% endfor %} - -{% for action in disabled.actions %} - {{ action.L_ACTION }}{% if not action.S_LAST_ROW %} | {% endif %} -{% endfor %} diff --git a/install/update/new/adm/style/acp_ext_list.html b/install/update/new/adm/style/acp_ext_list.html deleted file mode 100644 index e578312..0000000 --- a/install/update/new/adm/style/acp_ext_list.html +++ /dev/null @@ -1,114 +0,0 @@ - - - - -

{L_EXTENSIONS_ADMIN}

- -

{L_EXTENSIONS_EXPLAIN}

- -
- {L_BROWSE_EXTENSIONS_DATABASE}{L_VERSIONCHECK_FORCE_UPDATE_ALL}{L_SETTINGS} -
- - - - - - - - - - - - - - - - class="hidden"> - - - - - - - - - - - - class="hidden"> - - - - - - - - - - - -
{L_EXTENSION_NAME}{L_CURRENT_VERSION}{L_EXTENSION_OPTIONS}{L_EXTENSION_ACTIONS}
{L_EXTENSIONS_ENABLED}
{enabled.META_DISPLAY_NAME} - - {enabled.META_VERSION} - - - {enabled.META_VERSION} - - {L_DETAILS} - -
{L_EXTENSIONS_DISABLED}
{disabled.META_DISPLAY_NAME} - - {disabled.META_VERSION} - - - {disabled.META_VERSION} - - - {L_DETAILS} - - -
- - - - - - - - - - - - - - - - - - - - - -
{L_EXTENSION_INSTALL_HEADLINE}
{L_EXTENSION_INSTALL_EXPLAIN}
{L_EXTENSION_UPDATE_HEADLINE}
{L_EXTENSION_UPDATE_EXPLAIN}
{L_EXTENSION_REMOVE_HEADLINE}
{L_EXTENSION_REMOVE_EXPLAIN}
- - diff --git a/install/update/new/adm/style/acp_forums.html b/install/update/new/adm/style/acp_forums.html deleted file mode 100644 index f51ce98..0000000 --- a/install/update/new/adm/style/acp_forums.html +++ /dev/null @@ -1,524 +0,0 @@ - - - - - - - - - « {L_BACK} - -

{L_TITLE} :: {FORUM_NAME}

- -

{L_FORUM_EDIT_EXPLAIN}

- - -
-

{L_WARNING}

-

{ERROR_MSG}

-
- - -
- -
- {L_FORUM_SETTINGS} - -
-
-
-
- -
-
-
-
-
-
-
- - - - -
-
-
-
- -
-

{L_COPY_PERMISSIONS_EXPLAIN}
-
-
- -
-
-
-
-
-

{L_FORUM_DESC_EXPLAIN}
-
-
- -
-
-
-

{L_FORUM_IMAGE_EXPLAIN}
-
- -
{L_FORUM_IMAGE}
- -
-
-

{L_FORUM_PASSWORD_EXPLAIN}
-
-
-
-

{L_FORUM_PASSWORD_CONFIRM_EXPLAIN}
-
-
- -
-

{L_FORUM_PASSWORD_UNSET_EXPLAIN}
-
-
- -
-
-
-
- -
- -
-
- {L_GENERAL_FORUM_SETTINGS} -
-

{L_DISPLAY_ACTIVE_TOPICS_EXPLAIN}
-
-
-
-
-
- -
-
- {L_GENERAL_FORUM_SETTINGS} - -
-
-
-
-
-

{L_LIST_SUBFORUMS_EXPLAIN}
-
-
-
-
-

{L_LIMIT_SUBFORUMS_EXPLAIN}
-
-
-
-
-

{L_LIST_INDEX_EXPLAIN}
-
-
-
-
-

{L_ENABLE_POST_REVIEW_EXPLAIN}
-
-
-
-
-

{L_ENABLE_QUICK_REPLY_EXPLAIN}
-
-
-
-
-

{L_ENABLE_INDEXING_EXPLAIN}
-
-
-
-
-
-
-
-
-
-

{L_ENABLE_RECENT_EXPLAIN}
-
-
-
-
-

{L_FORUM_TOPICS_PAGE_EXPLAIN}
-
-
- -
- -
- {L_FORUM_PRUNE_SETTINGS} - -
-

{L_FORUM_AUTO_PRUNE_EXPLAIN}
-
-
-
-
-

{L_AUTO_PRUNE_FREQ_EXPLAIN}
-
{L_DAYS}
-
-
-

{L_AUTO_PRUNE_DAYS_EXPLAIN}
-
{L_DAYS}
-
-
-

{L_AUTO_PRUNE_VIEWED_EXPLAIN}
-
{L_DAYS}
-
-
-

{L_PRUNE_OLD_POLLS_EXPLAIN}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

{L_FORUM_PRUNE_SHADOW_EXPLAIN}
-
-
-
-
-

{L_AUTO_PRUNE_SHADOW_FREQ_EXPLAIN}
-
{L_DAYS}
-
-
-

{L_AUTO_PRUNE_SHADOW_DAYS_EXPLAIN}
-
{L_DAYS}
-
- -
-
- - - -
-
- {L_FORUM_RULES} - -
-

{L_FORUM_RULES_LINK_EXPLAIN}
-
-
- -
-
-
{FORUM_RULES_PREVIEW}
-
- -
-

{L_FORUM_RULES_EXPLAIN}
-
-
- -
-
- -
-
- - - -
- {L_SUBMIT} -   - - {S_FORM_TOKEN} -
-
- - - - « {L_BACK} - -

{L_FORUM_DELETE}

- -

{L_FORUM_DELETE_EXPLAIN}

- - -
-

{L_WARNING}

-

{ERROR_MSG}

-
- - -
- -
- {L_FORUM_DELETE} -
-
-
{FORUM_NAME}
-
- -
-
-
- -
- -
- - -
-
-
- -
- -
- - -

- -

- {S_FORM_TOKEN} -
-
- - - - - -

{L_FORUM_ADMIN}

- -

{L_FORUM_ADMIN_EXPLAIN}

- -

{L_PROGRESS_EXPLAIN}

- - - - - -

{L_FORUM_ADMIN}

- -

{L_FORUM_ADMIN_EXPLAIN}

- - -
-

{L_WARNING}

-

{ERROR_MSG}

-
- - - - - -
-

{L_NOTIFY}

-

{L_FORUM_RESYNCED}

-
- - -

{NAVIGATION} [{L_EDIT} | {L_DELETE} | {L_RESYNC}]

- - - - - - - - - - - - - -
{forums.FOLDER_IMAGE} -
{forums.FORUM_IMAGE}
- {forums.FORUM_NAME}{forums.FORUM_NAME} -
{forums.FORUM_DESCRIPTION} -

{L_TOPICS}{L_COLON} {forums.FORUM_TOPICS} / {L_POSTS}{L_COLON} {forums.FORUM_POSTS} -
- - {ICON_MOVE_UP} - - {ICON_MOVE_DOWN} - {ICON_EDIT} - - {ICON_SYNC} - - {ICON_SYNC_DISABLED} - - {ICON_DELETE} -
- - -
- -
- {L_SELECT_FORUM}{L_COLON} - - - {S_FORM_TOKEN} -
-
- -
- -
- - - - - {S_FORM_TOKEN} -
-
- - - - diff --git a/install/update/new/adm/style/acp_groups.html b/install/update/new/adm/style/acp_groups.html deleted file mode 100644 index 8651b63..0000000 --- a/install/update/new/adm/style/acp_groups.html +++ /dev/null @@ -1,335 +0,0 @@ - - - - - - - « {L_BACK} - -

{L_ACP_GROUPS_MANAGE}

- -

{L_GROUP_EDIT_EXPLAIN}

- - -
-

{L_WARNING}

-

{ERROR_MSG}

-
- - -
- -
- {L_GROUP_DETAILS} -
-
for="group_name">{L_GROUP_NAME}{L_COLON}
-
{GROUP_NAME}
-
-
-
-
-
- -
-
- -
-

{L_GROUP_TYPE_EXPLAIN}
-
- {% EVENT acp_group_types_prepend %} - - - - - {% EVENT acp_group_types_append %} -
-
- - - - - -
-

{L_COPY_PERMISSIONS_EXPLAIN}
-
-
- -
- -
- {L_GROUP_OPTIONS_SAVE} - - -
-

{L_GROUP_FOUNDER_MANAGE_EXPLAIN}
-
-
- -
-

{L_GROUP_SKIP_AUTH_EXPLAIN}
-
-
-
-
-
-
-
-
-
-
-
-

{L_GROUP_RECEIVE_PM_EXPLAIN}
-
-
- -
- -
- {L_GROUP_SETTINGS_SAVE} -
-

{L_GROUP_MESSAGE_LIMIT_EXPLAIN}
-
-
-
-

{L_GROUP_MAX_RECIPIENTS_EXPLAIN}
-
-
-
-

{L_GROUP_COLOR_EXPLAIN}
-
- -        - [ {L_COLOUR_SWATCH} ] - -
-
-
-
-
-
-
- -
- {L_GROUP_AVATAR} -
-

{L_AVATAR_EXPLAIN}
-
{AVATAR}
-
-
-
-
-
-
-
- -
-

{avatar_drivers.L_EXPLAIN}

- {avatar_drivers.OUTPUT} -
- -
-
- -
- {L_SUBMIT} -   - - {S_FORM_TOKEN} -
-
- - - - « {L_BACK} - -

{L_GROUP_MEMBERS} :: {GROUP_NAME}

- -

{L_GROUP_MEMBERS_EXPLAIN}

- -
- -
- » {L_MAKE_DEFAULT_FOR_ALL} -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{L_USERNAME}{L_GROUP_DEFAULT}{L_JOINED}{L_POSTS}{L_MARK}
{L_GROUP_LEAD}
{leader.USERNAME}{leader.USERNAME}{L_YES}{L_NO}{leader.JOINED}{leader.USER_POSTS}
{L_GROUPS_NO_MODS}
{L_GROUP_APPROVED}
{L_GROUP_PENDING}
{member.USERNAME}{member.USERNAME}{L_YES}{L_NO}{member.JOINED}{member.USER_POSTS}
{L_GROUPS_NO_MEMBERS}
- - -
- - -

{L_MARK_ALL}{L_UNMARK_ALL}

-
- -

{L_ADD_USERS}

- -

{L_ADD_USERS_EXPLAIN}

- -
- {L_ADD_USERS} -
-
-
-
-
-
-

{L_USER_GROUP_DEFAULT_EXPLAIN}
-
-
-
-
-

{L_USERNAMES_EXPLAIN}
-
-
[ {L_FIND_USERNAME} ]
-
- -

- -

- {S_FORM_TOKEN} -
-
- - - -

{L_ACP_GROUPS_MANAGE}

- -

{L_ACP_GROUPS_MANAGE_EXPLAIN}

- - -
-

{L_WARNING}

-

{ERROR_MSG}

-
- - -

{L_USER_DEF_GROUPS}

- -

{L_USER_DEF_GROUPS_EXPLAIN}

- -
- - - - - - - - - - - - - - - - - - - - - - -
{L_GROUP}{L_TOTAL_MEMBERS}{L_PENDING_MEMBERS}{L_OPTIONS}{L_ACTION}
{L_NO_GROUPS_CREATED}
- - -
- - {L_CREATE_GROUP}{L_COLON} - - - {S_FORM_TOKEN} -
-
- -

{L_SPECIAL_GROUPS}

- -

{L_SPECIAL_GROUPS_EXPLAIN}

- - - - - - - - - - - - - - - - - - - - - - - - - -
{L_GROUP}{L_TOTAL_MEMBERS}{L_PENDING_MEMBERS}{L_OPTIONS}{L_ACTION}
style="color: #{groups.GROUP_COLOR}">{groups.GROUP_NAME}{groups.TOTAL_MEMBERS}{groups.PENDING_MEMBERS}{L_SETTINGS}{L_MEMBERS}{L_DELETE}{L_DELETE}
- - - - diff --git a/install/update/new/adm/style/acp_help_phpbb.html b/install/update/new/adm/style/acp_help_phpbb.html deleted file mode 100644 index 7d3c503..0000000 --- a/install/update/new/adm/style/acp_help_phpbb.html +++ /dev/null @@ -1,67 +0,0 @@ - - - - -

{L_ACP_HELP_PHPBB}

- -
-
- -
-

{L_SEND_STATISTICS}

-

{L_EXPLAIN_SEND_STATISTICS}

-
- -
-
- -
- {providers.NAME} - -
-
{providers.values.KEY}
-
{providers.values.VALUE}
-
- -
- -
-
-
-
-
- checked="checked" /> - -
-
{L_SEND_STATISTICS_LONG}
-
-
- - -
-

- - -

- {S_FORM_TOKEN} -
-
-
-
-
-

- {% for providers in providers %} - {% for values in providers.values %} - - {% endfor %} - {% endfor %} - -

-
-
- - diff --git a/install/update/new/adm/style/acp_icons.html b/install/update/new/adm/style/acp_icons.html deleted file mode 100644 index 45fe7f8..0000000 --- a/install/update/new/adm/style/acp_icons.html +++ /dev/null @@ -1,282 +0,0 @@ - - - - - - - - - « {L_BACK} - -

{L_TITLE}

- -

{L_EXPLAIN}

- -
- -
- {L_TITLE} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{L_CONFIG}
{L_URL}{L_LOCATION}{L_SMILIES_CODE}{L_SMILIES_EMOTION}{L_WIDTH}{L_HEIGHT}{L_ALT_TEXT}{L_DISPLAY_ON_POSTING}{L_ORDER}{L_ADD} ({L_MARK_ALL})
{items.TEXT_ALT}[{items.IMG}] - - - - -
{L_ADD_SMILEY_CODE}
{L_NO_ICONS}
- -

-   - -

- {S_FORM_TOKEN} -
-
- - - - « {L_BACK} - -

{L_TITLE}

- -

{L_EXPLAIN}

- -
- -
- {L_IMPORT} - - -

{L_NO_PAK_OPTIONS}

- - -
-
-
-
-

{L_CURRENT_EXPLAIN}
-
- -
- - -

- -

- - {S_FORM_TOKEN} -
-
- - - -

{L_TITLE}

- -

{L_EXPLAIN}

- - -
-

{L_NOTIFY}

-

{NOTICE}

-
- - -
- -
{L_IMPORT} | {L_EXPORT}
- -
- - {L_TITLE} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{L_TITLE}{L_CODE}{L_EMOTION}{L_OPTIONS}
{L_NOT_DISPLAYED}
{items.ALT_TEXT}{items.CODE}{items.EMOTION} - - {ICON_MOVE_UP} - - {ICON_MOVE_DOWN} - {ICON_EDIT} {ICON_DELETE} -
{L_ACP_NO_ITEMS}
- -

-     -

- {S_FORM_TOKEN} -
-
- - - - diff --git a/install/update/new/adm/style/acp_language.html b/install/update/new/adm/style/acp_language.html deleted file mode 100644 index 5e3ac95..0000000 --- a/install/update/new/adm/style/acp_language.html +++ /dev/null @@ -1,116 +0,0 @@ - - - - - - - « {L_BACK} - -

{L_LANGUAGE_PACK_DETAILS}

- -
- -
- {LANG_LOCAL_NAME} -
-
-
-
-
-
-
-
-
-
-
{LANG_ISO}
-
-
-
-
-
- -

- -

- {S_FORM_TOKEN} -
-
- - -

{L_MISSING_FILES}

- -
- {L_MISSING_LANG_FILES} - - » {missing_files.FILE_NAME}
- -
- - - -

{L_MISSING_VARS_EXPLAIN}

- -
- {L_MISSING_LANG_VARIABLES} - -
-
- -
{missing_varfile.variable.VAR_NAME}
- -
- -
- - - -

{L_ACP_LANGUAGE_PACKS}

- -

{L_ACP_LANGUAGE_PACKS_EXPLAIN}

- -
- {L_BROWSE_LANGUAGE_PACKS_DATABASE} -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{L_LANGUAGE_PACK_NAME}{L_LANGUAGE_PACK_LOCALNAME}{L_LANGUAGE_PACK_ISO}{L_LANGUAGE_PACK_USED_BY}{L_OPTIONS}
{L_INSTALLED_LANGUAGE_PACKS}
{lang.ENGLISH_NAME} {lang.TAG}{lang.LOCAL_NAME}{lang.ISO}{lang.USED_BY}{L_DELETE}
{L_UNINSTALLED_LANGUAGE_PACKS}
{notinst.NAME}{notinst.LOCAL_NAME}{notinst.ISO}{L_INSTALL}
- - - - diff --git a/install/update/new/adm/style/acp_main.html b/install/update/new/adm/style/acp_main.html deleted file mode 100644 index b8d337c..0000000 --- a/install/update/new/adm/style/acp_main.html +++ /dev/null @@ -1,339 +0,0 @@ - - - - - - -

{L_PERMISSIONS_TRANSFERRED}

- -

{L_PERMISSIONS_TRANSFERRED_EXPLAIN}

- - - -

{L_WELCOME_PHPBB}

- -

{L_ADMIN_INTRO}

- - -
-

{L_UPDATE_INCOMPLETE} {L_MORE_INFORMATION}

-
- -
-

{L_VERSIONCHECK_FAIL}

-

{VERSIONCHECK_FAIL_REASON}

-

{L_VERSIONCHECK_FORCE_UPDATE} · {L_MORE_INFORMATION}

-
- -
-

{L_VERSION_NOT_UP_TO_DATE_TITLE}

-

{L_VERSIONCHECK_FORCE_UPDATE} · {L_MORE_INFORMATION}

-
- - -
-

{UPGRADE_INSTRUCTIONS}

-
- - - -
-

{L_WARNING}

-

{L_NO_SEARCH_INDEX}

-
- - - -
-

{L_WARNING}

-

{L_REMOVE_INSTALL}

-
- - - - -
-

{L_ERROR_MBSTRING_FUNC_OVERLOAD}

-

{L_ERROR_MBSTRING_FUNC_OVERLOAD_EXPLAIN}

-
- - - -
-

{L_ERROR_MBSTRING_ENCODING_TRANSLATION}

-

{L_ERROR_MBSTRING_ENCODING_TRANSLATION_EXPLAIN}

-
- - - -
-

{L_ERROR_MBSTRING_HTTP_INPUT}

-

{L_ERROR_MBSTRING_HTTP_INPUT_EXPLAIN}

-
- - - -
-

{L_ERROR_MBSTRING_HTTP_OUTPUT}

-

{L_ERROR_MBSTRING_HTTP_OUTPUT_EXPLAIN}

-
- - - - -
-

{L_WRITABLE_CONFIG}

-
- - - -
-

{L_PHP_VERSION_OLD}

-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {% if S_TOTAL_ORPHAN %} - - - {% else %} - {% endif %} - - {% if S_VERSIONCHECK %} - - - - - {% endif %} - -
{{ lang('STATISTIC') }}{{ lang('VALUE') }}
{{ lang('BOARD_STARTED') ~ lang('COLON') }}{{ START_DATE }}
{{ lang('AVATAR_DIR_SIZE') ~ lang('COLON') }}{{ AVATAR_DIR_SIZE }}
{{ lang('DATABASE_SIZE') ~ lang('COLON') }}{{ DBSIZE }}
{{ lang('UPLOAD_DIR_SIZE') ~ lang('COLON') }}{{ UPLOAD_DIR_SIZE }}
{{ lang('DATABASE_SERVER_INFO') ~ lang('COLON') }}{{ DATABASE_INFO }}
{{ lang('GZIP_COMPRESSION') ~ lang('COLON') }}{{ GZIP_COMPRESSION }}
{{ lang('PHP_VERSION') ~ lang('COLON') }}{{ PHP_VERSION_INFO }}
{{ lang('NUMBER_ORPHAN') ~ lang('COLON') }} - {% if TOTAL_ORPHAN > 0 %} - {{ TOTAL_ORPHAN }} - {% else %} - {{ TOTAL_ORPHAN }} - {% endif %} -
{{ lang('BOARD_VERSION') ~ lang('COLON') }} - {{ BOARD_VERSION }}{{ lang('VERSIONCHECK_FORCE_UPDATE') }} ] -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{{ lang('STATISTIC') }}{{ lang('VALUE') }}
{{ lang('NUMBER_POSTS') ~ lang('COLON') }}{{ TOTAL_POSTS }}
{{ lang('POSTS_PER_DAY') ~ lang('COLON') }}{{ POSTS_PER_DAY }}
{{ lang('NUMBER_TOPICS') ~ lang('COLON') }}{{ TOTAL_TOPICS }}
{{ lang('TOPICS_PER_DAY') ~ lang('COLON') }}{{ TOPICS_PER_DAY }}
{{ lang('NUMBER_USERS') ~ lang('COLON') }}{{ TOTAL_USERS }}
{{ lang('USERS_PER_DAY') ~ lang('COLON') }}{{ USERS_PER_DAY }}
{{ lang('NUMBER_FILES') ~ lang('COLON') }}{{ TOTAL_FILES }}
{{ lang('FILES_PER_DAY') ~ lang('COLON') }}{{ FILES_PER_DAY }}
  
-
- - -
- {L_STATISTIC_RESYNC_OPTIONS} - -
-
-

 
-
-
-
- -
-
-

 
-
-
-
- -
-
-

{L_RESYNC_STATS_EXPLAIN}
-
-
-
- -
-
-

{L_RESYNC_POSTCOUNTS_EXPLAIN}
-
-
-
- -
-
-

{L_RESYNC_POST_MARKING_EXPLAIN}
-
-
-
- - -
-
-

{L_PURGE_SESSIONS_EXPLAIN}
-
-
-
- - -
-
-

{L_PURGE_CACHE_EXPLAIN}
-
-
-
- - -
- - - -

{L_ADMIN_LOG}

- -

{L_ADMIN_LOG_INDEX_EXPLAIN}

- -
» {L_VIEW_ADMIN_LOG}
- - - - - - - - - - - - - - - - - - - - -
{L_USERNAME}{L_IP}{L_TIME}{L_ACTION}
{log.USERNAME}{log.IP}{log.DATE}{log.ACTION}
- - - -

{L_INACTIVE_USERS}

- -

{L_INACTIVE_USERS_EXPLAIN_INDEX}

- -
» {L_VIEW_INACTIVE_USERS}
- - - - - - - - - - - - - - - - - - - - - - - - - - -
{L_USERNAME}{L_JOINED}{L_INACTIVE_DATE}{L_LAST_VISIT}{L_INACTIVE_REASON}
- {inactive.USERNAME_FULL} -
{L_POSTS}{L_COLON} {inactive.POSTS} [{L_SEARCH_USER_POSTS}] -
{inactive.JOINED}{inactive.INACTIVE_DATE}{inactive.LAST_VISIT} - {inactive.REASON} -
{inactive.REMINDED_EXPLAIN} -
{L_NO_INACTIVE_USERS}
- - - - - diff --git a/install/update/new/adm/style/acp_modules.html b/install/update/new/adm/style/acp_modules.html deleted file mode 100644 index f4040da..0000000 --- a/install/update/new/adm/style/acp_modules.html +++ /dev/null @@ -1,203 +0,0 @@ - - - - - - - - - « {L_BACK} - -

{L_TITLE} :: {MODULENAME}

- -

{L_EDIT_MODULE_EXPLAIN}

- - -
-

{L_WARNING}

-

{ERROR_MSG}

-
- - -
- -
- {L_GENERAL_OPTIONS} -
-

- {L_MODULE_LANGNAME_EXPLAIN}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
style="display: none;"> -
-

{L_MODULE_DISPLAYED_EXPLAIN}
-
-
-
-
-

- {L_CHOOSE_MODULE_EXPLAIN}
-
-
-
-

- {L_CHOOSE_MODE_EXPLAIN}
-
-
-
- -

- - - -   - -

- {S_FORM_TOKEN} -
-
- - - -

{L_ACP_MODULE_MANAGEMENT}

- -

{L_ACP_MODULE_MANAGEMENT_EXPLAIN}

- - -
-

{L_WARNING}

-

{ERROR_MSG}

-
- - - - - - - - -
{NAVIGATION} [{L_EDIT} | {L_DELETE} | {L_DISABLE}{L_ENABLE}]
- - - - - - - - - - - - - - -
{modules.MODULE_IMAGE}{modules.MODULE_TITLE} [{L_HIDDEN_MODULE}] {L_DISABLE}{L_ENABLE}  - - {ICON_MOVE_UP} - - {ICON_MOVE_DOWN} - {ICON_EDIT} - {ICON_DELETE} -
- - -
 
- -
- -
- - - - -
- -
- -
- -
- - - - - -
- -
- -
 

- -
-
- {L_SELECT_MODULE}{L_COLON} - - -
-
- - - - diff --git a/install/update/new/adm/style/acp_permission_roles.html b/install/update/new/adm/style/acp_permission_roles.html deleted file mode 100644 index 670d5e1..0000000 --- a/install/update/new/adm/style/acp_permission_roles.html +++ /dev/null @@ -1,191 +0,0 @@ - - - - - - - - - - - « {L_BACK} - -

{L_TITLE}

- -

{L_EXPLAIN}

- -
- » {L_SET_ROLE_PERMISSIONS} - -
- -
- {L_ROLE_DETAILS} -
-
-
-
-
-

{L_ROLE_DESCRIPTION_EXPLAIN}
-
-
- -

- - {S_FORM_TOKEN} -

-
- - - -

{L_ROLE_ASSIGNED_TO}

- - - - - -

- - - - » {L_BACK_TO_TOP}
-

- -

- -

{L_ACL_TYPE}

- -
- -
-
- -
- -
style="display: none;"> -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
{L_ACL_SETTING}{L_ACL_YES}{L_ACL_NO}{L_ACL_NEVER}
{auth.mask.PERMISSION}
-
-
- -
- -
- -
- - {S_FORM_TOKEN} -
-
- - » {L_BACK_TO_TOP}
-
- - - -

{L_TITLE}

- -

{L_EXPLAIN}

- -
- - - - - - - - - - - - - - - - - - -
{L_ROLE_NAME}{L_OPTIONS}
{roles.ROLE_NAME} -
{roles.ROLE_DESCRIPTION} -
{L_VIEW_ASSIGNED_ITEMS}{L_VIEW_ASSIGNED_ITEMS} - - {ICON_MOVE_UP} - - {ICON_MOVE_DOWN} - {ICON_EDIT} - {ICON_DELETE} -
- -
- {L_CREATE_ROLE}{L_COLON}
- {S_FORM_TOKEN} -
-
- - - - - -

{L_ROLE_ASSIGNED_TO}

- - - - - - - - diff --git a/install/update/new/adm/style/acp_posting_buttons.html b/install/update/new/adm/style/acp_posting_buttons.html deleted file mode 100644 index 614d6fa..0000000 --- a/install/update/new/adm/style/acp_posting_buttons.html +++ /dev/null @@ -1,50 +0,0 @@ - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
- diff --git a/install/update/new/adm/style/acp_ranks.html b/install/update/new/adm/style/acp_ranks.html deleted file mode 100644 index d373657..0000000 --- a/install/update/new/adm/style/acp_ranks.html +++ /dev/null @@ -1,107 +0,0 @@ - - - - - - - « {L_BACK} - - - -

{L_ACP_MANAGE_RANKS}

- -

{L_ACP_RANKS_EXPLAIN}

- -
- -
- {L_ACP_RANKS} - - - -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
style="display: none;"> -
-
-
-
-
- - - -

- - -   - - {S_FORM_TOKEN} -

-
-
- - - -

{L_ACP_MANAGE_RANKS}

- -

{L_ACP_RANKS_EXPLAIN}

- -
-
- {L_ACP_MANAGE_RANKS} - - - - - - - - - - - - - - - - - - - - - - - - -
{L_RANK_IMAGE}{L_RANK_TITLE}{L_RANK_MINIMUM}{L_ACTION}
{ranks.RANK_TITLE}  -  {ranks.RANK_TITLE}  -  {ranks.MIN_POSTS}{ICON_EDIT} {ICON_DELETE}
- -

- - {S_FORM_TOKEN} -

-
-
- - - - diff --git a/install/update/new/adm/style/acp_search.html b/install/update/new/adm/style/acp_search.html deleted file mode 100644 index 9962005..0000000 --- a/install/update/new/adm/style/acp_search.html +++ /dev/null @@ -1,159 +0,0 @@ - - - - - -

{L_ACP_SEARCH_SETTINGS}

- -

{L_ACP_SEARCH_SETTINGS_EXPLAIN}

- - - - - - - -

{L_ACP_SEARCH_INDEX}

- - -

{L_CONTINUE_EXPLAIN}

- -
-
- {L_SUBMIT} -   - - {S_FORM_TOKEN} -
-
- - -

{L_ACP_SEARCH_INDEX_EXPLAIN}

- - - - - -
- -
- - {backend.S_HIDDEN_FIELDS} - - {L_INDEX_STATS}{L_COLON} {backend.L_NAME} ({L_ACTIVE}) - - - - - - - - - - - - - - - - - - - - - - -
{backend.L_NAME} ({L_ACTIVE})
{L_STATISTIC}{L_VALUE}{L_STATISTIC}{L_VALUE}
{backend.data.STATISTIC_1}{L_COLON}{backend.data.VALUE_1}{backend.data.STATISTIC_2}{L_COLON}{backend.data.VALUE_2}
- - - -

- - - - - - - -

- {S_FORM_TOKEN} -
- -
- - - - - - - diff --git a/install/update/new/adm/style/acp_styles.html b/install/update/new/adm/style/acp_styles.html deleted file mode 100644 index c09294b..0000000 --- a/install/update/new/adm/style/acp_styles.html +++ /dev/null @@ -1,178 +0,0 @@ - - - - - - « {L_BACK} - - - -
- -
-

{MESSAGE_TITLE}

-

{MESSAGE_TEXT}

- - - - - {S_HIDDEN_FIELDS} - -
-   - -
- -
- -
- - -

{L_TITLE}

- -

{L_EXPLAIN}

- -
- {L_BROWSE_STYLES_DATABASE} -
- -
-{S_HIDDEN_FIELDS} -{S_FORM_TOKEN} - - - -
-
-
-
-
-
-
-
{STYLE_PATH}
-
-
-
-
{STYLE_VERSION}
-
-
-
-
{STYLE_COPYRIGHT}
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
- -
- -
- {L_SUBMIT} -   - - {S_FORM_TOKEN} -
- - - - - - - - - - - - {STYLES_LIST_EXTRA} - - - - - - - - - - - - - - - - - - {styles_list.EXTRA} - - - - -
{L_STYLE_NAME}{L_STYLE_PHPBB_VERSION}{L_STYLE_USED_BY}{L_ACTIONS} 
- - - - - {styles_list.STYLE_NAME} -
{styles_list.STYLE_COPYRIGHT}
- - {styles_list.STYLE_NAME} - - -
{styles_list.COMMENT}
- - -
{L_STYLE_PATH}{L_COLON} {styles_list.STYLE_PATH_FULL}
- -
{styles_list.STYLE_PHPBB_VERSION}{styles_list.USERS} - - | - - {styles_list.actions.L_ACTION} - - {styles_list.actions.HTML} - - - - {% if styles_list.STYLE_NAME !== 'prosilver' %} - - {% endif %} - - -   - - - - -
- - - -
- - - -
- - -
- - - - diff --git a/install/update/new/adm/style/acp_users_overview.html b/install/update/new/adm/style/acp_users_overview.html deleted file mode 100644 index 2af669a..0000000 --- a/install/update/new/adm/style/acp_users_overview.html +++ /dev/null @@ -1,169 +0,0 @@ -
- -
- {L_ACP_USER_OVERVIEW} -
-

{L_NAME_CHARS_EXPLAIN}
-
-
[ {L_USE_PERMISSIONS} ]
-
- -
-
-
{USER_INACTIVE_REASON}
-
- -
-
-
{USER_REGISTERED}
-
- -
-
-
{REGISTERED_IP}
-
[ {L_WHOIS} ]
-
- -
-
-
{USER_LASTACTIVE}
-
-
-
-
- - - {USER_POSTS} - - {USER_POSTS} - - - - ({L_POSTS_IN_QUEUE}) - - ({L_POSTS_IN_QUEUE}) - -
-
-
-
-
{USER_WARNINGS}
-
-
-

{L_FOUNDER_EXPLAIN}
-
-
-
-
-
-
-
-
-

{L_CHANGE_PASSWORD_EXPLAIN}
-
-
-
-

{L_CONFIRM_PASSWORD_EXPLAIN}
-
-
- - -

- - - {S_FORM_TOKEN} -

- -
-
- - - - - -
- -
- {L_USER_TOOLS} -
-
-
-
- - -

- - {S_FORM_TOKEN} -

- -
- -
- - -
-
- {L_DELETE_USER} -
-

{L_DELETE_USER_EXPLAIN}
-
- - - - {L_USER_NO_POSTS_TO_DELETE} - -
-
-

- - - {S_FORM_TOKEN} -

-
-
- - diff --git a/install/update/new/adm/style/acp_users_prefs.html b/install/update/new/adm/style/acp_users_prefs.html deleted file mode 100644 index 358f3d5..0000000 --- a/install/update/new/adm/style/acp_users_prefs.html +++ /dev/null @@ -1,151 +0,0 @@ - - -
- -
- {L_UCP_PREFS_PERSONAL} - -
-
-
-
-
-
-
-
-
-
-
-

{L_ALLOW_PM_EXPLAIN}
-
-
-
-
-
-
-
-
-
-

{L_NOTIFY_METHOD_EXPLAIN}
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-

{L_BOARD_DATE_FORMAT_EXPLAIN}
-
-
style="display:none;">
-
- -
- -
- {L_UCP_PREFS_POST} - -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
- -
- {L_UCP_PREFS_VIEW} - -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
{S_TOPIC_SORT_DAYS}
-
-
-
-
{S_TOPIC_SORT_KEY}
-
-
-
-
{S_TOPIC_SORT_DIR}
-
-
-
-
{S_POST_SORT_DAYS}
-
-
-
-
{S_POST_SORT_KEY}
-
-
-
-
{S_POST_SORT_DIR}
-
- -
- -
- - {S_FORM_TOKEN} -
- -
diff --git a/install/update/new/adm/style/acp_users_signature.html b/install/update/new/adm/style/acp_users_signature.html deleted file mode 100644 index 40f0fc2..0000000 --- a/install/update/new/adm/style/acp_users_signature.html +++ /dev/null @@ -1,52 +0,0 @@ - - -
- - -
- {L_ADMIN_SIG_PREVIEW} -

{SIGNATURE_PREVIEW}

-
- - -
- {L_SIGNATURE} -

{L_SIGNATURE_EXPLAIN}

- - - -
-
-
-
-
- - - - - - - - - -
-
{L_OPTIONS}{L_COLON} {BBCODE_STATUS} :: {IMG_STATUS} :: {FLASH_STATUS} :: {URL_STATUS} :: {SMILIES_STATUS}
-
-
- -
-   - - {S_FORM_TOKEN} -
-
diff --git a/install/update/new/adm/style/admin.css b/install/update/new/adm/style/admin.css deleted file mode 100644 index 3243d0e..0000000 --- a/install/update/new/adm/style/admin.css +++ /dev/null @@ -1,2736 +0,0 @@ -/* phpBB 3.3 Admin Style Sheet - ------------------------------------------------------------------------ - Original author: subBlue ( http://www.subblue.com/ ) - Copyright (c) phpBB Limited - - For full copyright and license information, please see - the docs/CREDITS.txt file. - ------------------------------------------------------------------------ -*/ - -/* General markup styles ----------------------------------------- */ -* { - /* Reset browsers default margin, padding and font sizes */ - margin: 0; - padding: 0; - font-size: 100%; -} - -abbr { - text-decoration: none; -} - -body, div, p, th, td, li, dd { - font-size: x-small; - voice-family: "\"}\""; - voice-family: inherit; - font-size: small; -} - -html>body, html>div, html>p, html>th, html>td, html>li, html>dd { - font-size: small; -} - -html { - color: #536482; - background: #DBD7D1; - /* Always show a scrollbar for short pages - stops the jump when the scrollbar appears. non-ie browsers */ - height: 100%; - margin-bottom: 1px; - word-wrap: break-word; -} - -body { - /* Text-Sizing with ems: http://www.clagnut.com/blog/348/ */ - font-family: "Lucida Grande", Verdana, Helvetica, Arial, sans-serif; - color: #536482; - background: #DBD7D1; - font-size: 62.5%; /* This sets the default font size to be equivalent to 10px */ - margin: 10px 15px; -} - -code, samp { - font-size: 1.2em; -} - -img { - border: 0; -} - -h1 { - font-family: "Trebuchet MS", Helvetica, sans-serif; - font-size: 1.70em; - font-weight: normal; - color: #333333; -} - -h2, caption { - font-family: "Trebuchet MS", Helvetica, sans-serif; - font-size: 1.40em; - font-weight: normal; - color: #115098; - text-align: left; - margin-top: 25px; -} - -.rtl h2, .rtl caption { - text-align: right; -} - -h3, h4 { - font-family: "Trebuchet MS", Helvetica, sans-serif; - font-size: 1.20em; - text-decoration: none; - line-height: 1.20em; - margin-top: 25px; -} - -p { - margin-bottom: 0.7em; - line-height: 1.40em; - font-size: 0.90em; -} - -ul { - list-style: disc; - margin: 0 0 1em 2em; -} - -.rtl ul { - margin: 0 2em 1em 0; -} - -hr { - border: 0 none; - border-top: 1px dashed #999999; - margin-bottom: 5px; - padding-bottom: 5px; - height: 1px; -} - -.centered-text { - text-align: center; -} - -.search-box { - float: left; -} - -.rtl .search-box { - float: right; -} - -.small { - font-size: 0.85em; -} - -.hidden { - display: none; -} - -@media only screen and (max-width: 800px), only screen and (max-device-width: 800px) -{ - body { - margin: 5px 5px 0; - } -} - -@media only screen and (max-width: 700px), only screen and (max-device-width: 700px) -{ - html, body { - height: auto; - margin: 0; - padding: 0; - } -} - - -/* General links */ -a:link, a:visited { - color: #105289; - text-decoration: none; -} - -a:hover { - color: #BC2A4D; - text-decoration: underline; -} - -a:active { - color: #368AD2; - text-decoration: none; -} - -.install-body p a { - font-weight: bold; -} - -a#maincontent, a#acl, a#assigned_to { - display: block; -} - -/* List items */ -ul, ol { - list-style-position: inside; - margin-left: 1em; -} - -li { - display: list-item; - list-style-type: inherit; -} - - -/* Main blocks ----------------------------------------- */ -#wrap { - padding: 0 0 15px 0; - min-width: 615px; -} - -#page-header { - text-align: right; - background: url("../images/phpbb_logo.svg") top left no-repeat; - height: 54px; - font-size: 0.85em; - margin-bottom: 10px; -} - -.rtl #page-header { - text-align: left; - background: url("../images/phpbb_logo.svg") top right no-repeat; -} - -#page-header h1 { - color: #767676; - font-family: "Trebuchet MS",Helvetica,sans-serif; - font-size: 1.70em; - padding-top: 10px; -} - -#page-header p { - font-size: 1.00em; -} - -#page-header p#skip { - display: none; -} - -#page-body { - min-width: 650px; -} - -.copyright { - font-size: 0.75em; - text-align: center; -} - -#content { - padding: 30px 10px 10px; - position: relative; -} - -#content h1 { - color: #115098; - line-height: 1.2em; - margin-bottom: 0; -} - -#main { - float: right; - width: 100%; - margin: 0 0 0 -210px; -} - -.rtl #main { - float: left; - margin: 0 -210px 0 0; -} - -.main { - margin-left: 210px; -} - -.rtl .main { - margin-left: 0; - margin-right: 210px; -} - -#page-body.simple-page-body { - padding: 0; - padding-right: 10px; - min-width: 0; -} - -@media only screen and (max-width: 700px), only screen and (max-device-width: 700px) -{ - #wrap, #page-body, #page-body.simple-page-body { - padding: 0; - min-width: 300px; - } - - #page-header { - margin: 5px; - padding-left: 160px; - height: auto; - min-height: 54px; - overflow: hidden; - } - - .rtl #page-header { - padding-right: 160px; - padding-left: 0; - } - - #page-header h1 { - font-size: 1.2em; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - } - - #page-header fieldset { - margin-top: 5px; - } - - #main, .rtl #main, .main, .rtl .main { - float: none; - width: auto; - margin: 0; - } - - #content { - background: #F3F3F3 url("../images/innerbox_bg.gif") repeat-x top; - padding: 5px; - } - - #page-footer { - padding: 0 5px 5px; - } -} - -@media only screen and (max-width: 400px), only screen and (max-device-width: 400px) -{ - #page-header { - background-size: 76px 26.5px; - padding-left: 80px; - min-height: 30px; - } - - .rtl #page-header { - padding-right: 80px; - } - - #page-header h1 { - padding-top: 0; - font-size: 1.1em; - } -} - - -/* Tabbed menu -----------------------------------------*/ -#tabs { - font-family: Arial, Helvetica, sans-serif; - line-height: normal; - margin: 0 7px; - position: relative; - z-index: 2; -} - -#tabs > ul { - list-style: none; - margin: 0; - padding: 0; -} - -#tabs .tab { - display: inline-block; - float: left; - font-size: 0.85em; - font-weight: bold; - line-height: 14px; -} - -.rtl #tabs .tab { - float: right; -} - -#tabs .tab > a { - background: #D4D6DA; - background: -moz-linear-gradient(top, #CACBCF 0%, #D4D6DA 100%); - background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #CACBCF), color-stop(100%, #D4D6DA)); - background: -webkit-linear-gradient(top, #CACBCF 0%, #D4D6DA 100%); - background: -o-linear-gradient(top, #CACBCF 0%, #D4D6DA 100%); - background: -ms-linear-gradient(top, #CACBCF 0%, #D4D6DA 100%); - background: linear-gradient(to bottom, #CACBCF 0%, #D4D6DA 100%); - border: 1px solid #BBB; - border-bottom-width: 0; - border-radius: 5px 5px 0 0; - color: #767676; - display: block; - font-weight: bold; - margin: 1px 1px 2px 0; - padding: 6px 9px 4px; - position: relative; - text-decoration: none; - text-transform: uppercase; - white-space: nowrap; - cursor: pointer; -} - -#tabs .tab > a:hover { - background: #F1F1EE; - border-color: #C0BFBB; - color: #BC2A4D; -} - -#tabs .activetab > a, -#tabs .activetab > a:hover { - background: #DCDEE2; - background: -moz-linear-gradient(top, #F2F2F2 0%, #DCDEE2 100%); - background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #F2F2F2), color-stop(100%, #DCDEE2)); - background: -webkit-linear-gradient(top, #F2F2F2 0%, #DCDEE2 100%); - background: -o-linear-gradient(top, #F2F2F2 0%, #DCDEE2 100%); - background: -ms-linear-gradient(top, #F2F2F2 0%, #DCDEE2 100%); - background: linear-gradient(to bottom, #F2F2F2 0%, #DCDEE2 100%); - border-color: #999; - border-bottom: 2px solid #DCDEE2; - box-shadow: 0 1px 1px #FFF inset; - color: #23649F; - margin: 0 1px 0 0; - padding: 7px 10px 4px; -} - -#tabs .activetab > a:hover { - color: #115098; -} - -/* Responsive tabs -----------------------------------------*/ -.responsive-tab { - position: relative; -} - -.responsive-tab > a.responsive-tab-link { - display: block; - font-size: 16px; - position: relative; - width: 16px; - line-height: 14px; - text-decoration: none; - padding-left: 9px !important; - padding-right: 9px !important; -} - -.responsive-tab .responsive-tab-link:before { - content: ''; - position: absolute; - left: 10px; - top: 7px; - height: .125em; - width: 14px; - border-bottom: 0.125em solid #767676; - border-top: 0.375em double #767676; -} - -.responsive-tab .responsive-tab-link:hover:before { - border-color: #BC2A4D; -} - -.responsive-tab.activetab .responsive-tab-link:before { - border-color: #23649F; -} - -.responsive-tab.activetab .responsive-tab-link:hover:before { - border-color: #115098; -} - -#tabs .dropdown, #minitabs .dropdown { - top: 20px; - margin-right: -2px; - font-weight: normal; -} - -#tabs .dropdown-right .dropdown { - margin-left: -2px; -} - -#tabs .dropdown-contents { - list-style: none; - margin: 0; -} - -#tabs .dropdown li { - border-bottom: 1px dotted #DCDCDC; -} - -#tabs .dropdown li:last-child { - border-bottom: none; -} - -#tabs .dropdown a { - display: block; - padding: 4px 8px; - text-align: right; -} - -/* Main Panel ----------------------------------------- */ -#acp { - position: relative; - top: -2px; - margin: 0 0 2px; - padding: 3px 1px; - min-width: 550px; - background: #F3F3F3 url("../images/innerbox_bg.gif") repeat-x top; - border: 1px #999999 solid; - border-radius: 5px; - box-shadow: #FFF 0 0 0 1px inset; -} - -#acp:first-child { - top: 0; -} - -.panel { - background: #F3F3F3 url("../images/innerbox_bg.gif") repeat-x top; - padding: 5px 0; - border-radius: 5px; - overflow: hidden; -} - -@media only screen and (max-width: 700px), only screen and (max-device-width: 700px) -{ - #acp { - min-width: 0; - min-height: 0; - border-radius: 0; - border-width: 1px 0; - background: #fff; - padding: 1px 0; - box-shadow: none; - } -} - -/* Sub-navigation Menu ----------------------------------------- */ - -/* Menu */ -#menu { - float: left; - width: 200px; - font-size: 1.00em; - padding: 0; - border-right: 1px solid #CCCFD3; - position: relative; -} - -.rtl #menu { - float: right; - border: none; - border-left: 1px solid #CCCFD3; -} - -#menu p { - font-size: 0.85em; -} - -#menu ul { - list-style: none; - margin: 0; - padding: 0; - word-wrap: normal; -} - -/* Default list state */ -#menu li, #menu .header { - padding: 0; - margin: 0; - font-size: 0.85em; - font-weight: bold; - display: block; -} - -/* Link styles for the sub-section links */ -#menu li span { - display: block; - padding: 3px 3px 3px 8px; - margin: 1px 0; - text-decoration: none; - font-weight: normal; - color: #138ECB; -} - -.rtl #menu li span { - padding: 3px 8px 3px 3px; -} - -#menu li a:hover, #menu li a:hover span { - text-decoration: none; - background-color: #FFFFFF; - color: #BC2A4D; -} - -#menu li a:active, #menu li a:active span { - color: #F632A0; -} - -#menu li#activemenu a span { - text-decoration: none; - font-weight: bold; - color: #1180B7; - background: transparent url("../images/arrow_right.gif") 0% 50% no-repeat; -} - -.rtl #menu li#activemenu a span { - background: transparent url("../images/arrow_left.gif") 100% 50% no-repeat; -} - -#menu li#activemenu a:hover span, #menu li#activemenu span { - text-decoration: none; - font-weight: bold; - color: #BC2A4D; - background: #FFFFFF url("../images/arrow_right.gif") 1% 50% no-repeat; -} - -.rtl #menu li#activemenu a:hover span, .rtl #menu li#activemenu span { - background: #FFFFFF url("../images/arrow_left.gif") 99% 50% no-repeat; -} - -#menu li a:active, #menu li a:active span, #menu li#activemenu a:active span { - color: #F632A0; -} - -#menu li span.completed { - text-decoration: none; - padding: 3px 3px 3px 12px; - background: url("../images/arrow_down.gif") 1% 50% no-repeat; -} - -.rtl #menu li span.completed { - text-decoration: none; - padding: 3px 12px 3px 3px; - background: url("../images/arrow_down.gif") 99% 50% no-repeat; -} - -#menu .header { - font-family: Tahoma, Helvetica, sans-serif; - display: block; - font-weight: bold; - color: #115098; - border-bottom: 1px solid #327AA5; - padding: 4px 0 2px; - margin-top: 15px; - text-transform: uppercase; - font-size: 0.75em; - text-decoration: none; - cursor: inherit; - outline-style: none; -} - -@media only screen and (max-width: 700px), only screen and (max-device-width: 700px) -{ - #menu, .rtl #menu { - float: none; - width: auto; - border-width: 0; - max-width: 200px; - margin: 0 auto 10px; - } - - #menu p { - text-align: center; - } - - #menu .menu-block.active { - margin: 0 -5px; - padding: 0 5px 3px; - background: rgba(255, 255, 255, .5); - border-radius: 5px; - } - - #menu .menu-block.no-header.active { - padding-top: 3px; - } - - #menu .menu-block .header { - margin-top: 5px; - cursor: pointer; - border-bottom-width: 0; - position: relative; - text-decoration: underline; - } - - #menu .menu-block .header:focus, #menu .menu-block.active .header { - color: #D31141; - text-decoration: none; - } - - #menu .menu-block ul { - display: none; - } - - .nojs #menu .menu-block:hover ul, #menu .menu-block.active ul, #menu .menu-block.no-header ul { - display: block; - } - - #menu .menu-block li:last-child { - border-bottom: 1px solid #327AA5; - } - - #menu .menu-block:last-child li:last-child, #menu .menu-block.active li:last-child { - border-bottom-width: 0; - } - - #menu .menu-block li a span { - border-radius: 2px; - } -} - - -/* Table styles ----------------------------------------- */ - -table { - width: 100%; - border: 1px solid #CCCFD3; - background-color: #FFFFFF; - padding: 1px; -} - -th { - padding: 3px 4px; - color: #FFFFFF; - background: #70AED3 url("../images/gradient2b.gif") bottom left repeat-x; - border-top: 1px solid #6DACD2; - border-bottom: 1px solid #327AA5; - text-align: left; - font-size: 0.75em; - text-transform: uppercase; -} - -td { - text-align: left; - font-size: 0.85em; - padding: 4px; - line-height: 1.20em; -} - -.rtl th, .rtl td { - text-align: right; -} - -.table1 { - clear: both; - border-spacing: 1px; - border-collapse: separate; -} - -.table2 { - display: inline-block; - border-spacing: 1px; - border-collapse: separate; -} - -.lside { - display: flex; - align-items: stretch; - width: 100%; -} - -.tabled { - width: 1%; -} - -dt#color_palette_placeholder table { - margin-right: 5px; - width: 80px; -} - -#color_palette_placeholder td { - padding: 0; -} - -table.type2 { - border: none; - background: none; - padding: 0; -} - -table.type2 th { - background: none; - border-top: none; - text-align: center; - color: #115098; - padding: 2px 0; -} - -table.type2 td { - padding: 0; - font-size: 1em; -} - -table.type2 td.name { - padding: 2px; - vertical-align: middle; -} - -table.type3 { - float: right; - width: 300px; - border: none; - background-color: transparent; - padding: 0; -} - -.rtl table.type3 { - float: left; -} - -table.type3 thead th { - background-color: transparent; - border-top: none; - text-align: center; - color: #115098; - padding: 0 3px; - font-size: 0.85em; - font-weight: normal; - text-transform: none; -} - -table.type3 tbody th { - border-top: none; - text-align: left; - text-transform: none; - padding: 0; - border: none; - font-size: 0.90em; - font-weight: normal; - width: 100%; -} - -.rtl table.type3 tbody th { - text-align: right; -} - -table.type3 td { - text-align: center; - padding: 1px; -} - -th.name { - text-align: left; - width: auto; -} - -.rtl th.name { - text-align: right; -} - -td.name { - text-align: left; - font-weight: bold; -} - -.rtl td.name { - text-align: right; -} - -.entry { - text-align: left; - font-weight: normal; -} - -.rtl .entry { - text-align: right; -} - -.row1 { - background-color: #F9F9F9; -} - -table.zebra-table tbody tr:nth-child(odd) { - background-color: #F9F9F9; -} - -.row2 { - word-break: break-all; - background-color: #DCEBFE; -} - -table.zebra-table tbody tr:nth-child(even) { - background-color: #DCEBFE; -} - -.row3 { background-color: #DBDFE2; } -.row4 { background-color: #E4E8EB; } -.col1 { background-color: #DCEBFE; } -.col2 { background-color: #F9F9F9; } - -/* 4 row background colours for trees */ -.row1a { background-color: #F9F9F9; } -.row1b { background-color: #F6F6F6; } -.row2a { background-color: #E7EEF4; } -.row2b { background-color: #E3EBF2; } - -tr.row-highlight:hover td { background-color: #DBDFE2; } - -.spacer { - background-color: #DBDFE2; - height: 1px; - line-height: 1px; -} - -/* Deactivated row */ -.row-inactive { - color: #999; -} -.row-inactive a, .row-inactive strong { - color: #888; -} -.row-inactive a:hover { - color: #BC2A4D; -} - -/* Specific tables */ -table.forums td.folder { - width: 27px; - text-align: center; -} - -table td.actions { - vertical-align: middle; - width: 100px; - text-align: center; - white-space: nowrap; -} - -table tr:first-child td.actions .up, table tr:last-child td.actions .down { - display: none; -} - -table tr:first-child td.actions .up-disabled, table tr:last-child td.actions .down-disabled { - display: inline !important; -} - -table.styles td.users, table td.mark { - text-align: center; -} - -table.fixed-width-table { - table-layout: fixed; - word-break: break-word; -} - -@media only screen and (max-width: 700px), only screen and (max-device-width: 700px) -{ - table.responsive, table.responsive tbody, table.responsive tr, table.responsive td { - display: block; - } - - table.responsive thead, table.responsive th, table.responsive colgroup { - display: none; - } - - table.responsive.show-header thead, table.responsive.show-header th:first-child, table.responsive caption { - display: block; - width: auto !important; - text-align: left !important; - margin: 0; - } - - table.responsive { - background: transparent none; - border-width: 0; - padding: 0; - } - - table.responsive caption { - padding: 3px 4px; - color: #FFFFFF; - background: #70AED3 url("../images/gradient2b.gif") bottom left repeat-x; - border-top: 1px solid #6DACD2; - border-bottom: 1px solid #327AA5; - text-align: left; - font-size: 0.75em; - font-weight: bold; - text-transform: uppercase; - } - - table.responsive.show-header th:first-child span.rank-img, table.responsive.no-caption caption, table.responsive.no-header thead { - display: none; - } - - table.responsive tr { - margin: 2px 0; - border: 1px solid #CCCFD3; - background-color: #FFFFFF; - padding: 1px 1px 0; - overflow: hidden; - } - - table.responsive tr.row1 td { background-color: #F9F9F9; } - table.responsive tr.row2 td { background-color: #DCEBFE; } - table.responsive tr.row3 td { background-color: #DBDFE2; } - table.responsive tr.row4 td { background-color: #E4E8EB; } - table.responsive tr.col1 td { background-color: #DCEBFE; } - table.responsive tr.col2 td { background-color: #F9F9F9; } - table.responsive tr.row1a td { background-color: #F9F9F9; } - table.responsive tr.row1b td { background-color: #F6F6F6; } - table.responsive tr.row2a td { background-color: #E7EEF4; } - table.responsive tr.row2b td { background-color: #E3EBF2; } - - table.responsive td { - width: auto !important; - text-align: left !important; - padding: 4px; - margin-bottom: 1px; - } - - .rtl table.responsive td { - text-align: right !important; - } - - table.responsive td.empty { - display: none !important; - } - - table.responsive td > dfn { - display: inline-block !important; - } - - table.responsive td > dfn:after { - content: ':'; - padding-right: 5px; - } - - table.responsive.two-columns td { - width: 50% !important; - float: left; - -moz-box-sizing: border-box; - box-sizing: border-box; - } - - .rtl table.responsive.two-columns td { - float: right; - } - - table.responsive.two-columns td:nth-child(2n+1) { - clear: left; - } - - table.responsive span.rank-img { - float: none; - padding-right: 5px; - } - - table.responsive#memberlist td:first-child input[type="checkbox"] { - float: right; - } - - /* Specific tables */ - table.responsive.forums td.folder { - float: left; - width: 27px; - background: transparent; - } - .rtl table.responsive.forums td.folder { - float: right; - } - - table.responsive.forums td.forum-desc { - margin-left: 35px; - min-height: 27px; - background: transparent; - } - - .rtl table.responsive.forums td.forum-desc { - margin-left: 0; - margin-right: 35px; - } - - table.responsive td.actions { - clear: both; - text-align: right !important; - } - - .rtl table.responsive td.actions { - text-align: left !important; - } - - table.responsive.styles tr.responsive-style-row td:first-child { - padding-left: 4px !important; - padding-right: 4px !important; - } - - table.responsive.styles td:first-child > dfn, table.responsive td.actions > dfn { - display: none !important; - } - - .horizontal-palette td:nth-child(2n), .vertical-palette tr:nth-child(2n) { - display: none; - } - - .colour-palette a { - display: inline-block !important; - } -} - -/* General form styles -----------------------------------------*/ -fieldset { - margin: 15px 0; - padding: 10px; - border-top: 1px solid #D7D7D7; - border-right: 1px solid #CCCCCC; - border-bottom: 1px solid #CCCCCC; - border-left: 1px solid #D7D7D7; - background-color: #FFFFFF; - position: relative; - border-radius: 3px; -} - -fieldset h2 { - margin-top: 0; -} - -.rtl fieldset { - border-top: 1px solid #D7D7D7; - border-right: 1px solid #D7D7D7; - border-bottom: 1px solid #CCCCCC; - border-left: 1px solid #CCCCCC; -} - -fieldset p { - font-size: 0.85em; -} - -legend { - padding: 1px 0; - font-family: Tahoma,arial,Verdana,Sans-serif; - font-size: .9em; - font-weight: bold; - color: #115098; - margin-top: -.4em; - position: relative; - text-transform: none; - line-height: 1.2em; - top: -.2em; - vertical-align: middle; -} - -input, textarea { - font-family: Verdana, Helvetica, Arial, sans-serif; - font-size: 0.90em; - font-weight: normal; - vertical-align: middle; - padding: 2px; - color: #111111; - border-left: 1px solid #AFAEAA; - border-top: 1px solid #AFAEAA; - border-right: 1px solid #D5D5C8; - border-bottom: 1px solid #D5D5C8; - background-color: #E3DFD8; -} - -.rtl input, .rtl textarea { - border-left: 1px solid #D5D5C8; - border-top: 1px solid #AFAEAA; - border-right: 1px solid #AFAEAA; - border-bottom: 1px solid #D5D5C8; -} - -input:hover, textarea:hover { - border-left: 1px solid #AFAEAA; - border-top: 1px solid #AFAEAA; - border-right: 1px solid #AFAEAA; - border-bottom: 1px solid #AFAEAA; - background-color: #E9E9E2; -} - -input.langvalue, textarea.langvalue { - width: 90%; -} - -input[type="number"] { - width: 60px; - -moz-padding-end: 0; -} - -optgroup, select { - background-color: #FAFAFA; - border: 1px solid #666666; - font-family: Verdana, Helvetica, Arial, sans-serif; - font-size: 0.85em; - font-weight: normal; - font-style: normal; - cursor: pointer; - padding: 1px; - vertical-align: middle; - width: auto; - color: #000; -} - -select:focus { - outline-style: none; -} - -optgroup { - font-size: 1.00em; - font-weight: bold; -} - -optgroup.disabled-options { - display: none; - background-color: gray; -} - -option { - padding: 0 1em 0 0; - color: #000; -} - -option.disabled-option { - color: graytext; -} - -.rtl option { - padding: 0 0 0 1em; -} - -.sep { - font-weight: bold; -} - -.username-coloured { - font-weight: bold; -} - -textarea { - font-family: Verdana, Helvetica, Arial, sans-serif; - font-size: 0.85em; - width: 60%; - padding: 2px; -} - -label { - cursor: pointer; - font-size: 0.85em; - padding: 0 5px 0 0; -} - -.rtl label { - padding: 0 0 0 5px; -} - -label input { - font-size: 1.00em; - vertical-align: middle; -} - -label img { - vertical-align: middle; -} - -fieldset.quick, p.quick { - margin: 0 0 5px; - padding: 5px 0 0; - border: none; - background-color: transparent; - text-align: right; -} - -.rtl fieldset.quick, .rtl p.quick { - text-align: left; -} - -fieldset.quick legend { - display: none; -} - -fieldset.tabulated { - background: none; - margin: 0; - margin-top: 5px; - padding: 0; - border: 0; -} - -fieldset.tabulated legend { - display: none; -} - -fieldset.nobg { - margin: 15px 0 0 0; - padding: 0; - border: none; - background-color: transparent; -} - -fieldset.display-options { - margin: 15px 0 2px 0; - padding: 0 0 4px 0; - border: none; - background-color: transparent; - text-align: center; - font-size: 0.85em; -} - -fieldset.display-options select, fieldset.display-options input, fieldset.display-options label { - font-size: 1.00em; - vertical-align: middle; -} - -select option.disabled { - background-color: #bbb; - color: #fff; -} - -/* Special case inputs */ -select#board_timezone, -select#full_folder_action { - width: 95%; -} - -@media only screen and (max-width: 700px), only screen and (max-device-width: 700px) -{ - fieldset { - padding: 5px; - } - - fieldset.quick, p.quick { - float: none !important; - text-align: center; - } - - fieldset.display-options { - clear: both; - } -} - -/* Definition list layout for forms - Other general def. list properties defined in prosilver_main.css ----------------------------------------- */ -dl { - font-family: Verdana, Helvetica, Arial, sans-serif; - font-size: 1.00em; -} - -dt { - float: left; - width: auto; -} - -.rtl dt { - float: right; -} - -dd { color: #666666;} -dd + dd { padding-top: 5px;} -dt span { padding: 0 5px 0 0;} -.rtl dt span { padding: 0 0 0 5px;} - -dt .explain { font-style: italic;} - -dt label { - font-size: 1.00em; - text-align: left; - font-weight: bold; - color: #4A5A73; -} - -.rtl dt label { - text-align: right; -} - -dd label { - font-size: 1.00em; - white-space: nowrap; - margin: 0 10px 0 0; - color: #4A5A73; -} - -.rtl dd label { - margin: 0 0 0 10px; -} - -html>body dd label input { vertical-align: text-bottom;} /* Tweak for Moz to align checkboxes/radio buttons nicely */ - -dd input { - font-size: 1.00em; - max-width: 100%; - margin: 2px 0; -} - -dd select { - font-size: 100%; - font-size: 1em; - width: auto; - max-width: 100%; - margin: 2px 0; -} - -dd textarea { - font-size: 0.90em; - width: 90%; -} - -fieldset dl { - margin-bottom: 10px; - font-size: 0.85em; -} - -fieldset dt { - width: 45%; - text-align: left; - border: none; - border-right: 1px solid #CCCCCC; - padding-top: 3px; -} - -.rtl fieldset dt { - text-align: right; - border: none; - border-left: 1px solid #CCCCCC; -} - -fieldset #color_palette_placeholder { - padding-top: 0; -} - -fieldset dd { - margin: 0 0 0 45%; - padding: 0 0 0 5px; - border: none; - border-left: 1px solid #CCCCCC; - vertical-align: top; - font-size: 1.00em; -} - -.rtl fieldset dd { - margin: 0 45% 0 0; - padding: 0 5px 0 0; - border: none; - border-right: 1px solid #CCCCCC; -} - -dd.full, .rtl dd.full { - margin: 0; - border: 0; - padding: 0; - padding-top: 3px; - text-align: center; - width: 95%; -} - -/* Hover highlights for form rows */ -fieldset dl:hover dt, fieldset dl:hover dd { - border-color: #666666; -} - -fieldset dl:hover dt label { - color: #000000; -} - -fieldset dl dd label:hover { - color: #BC2A4D; -} - -input:focus, textarea:focus { - border: 1px solid #BC2A4D; - background-color: #E9E9E2; - color: #BC2A4D; - outline-style: none; -} - -@media only screen and (max-width: 700px), only screen and (max-device-width: 700px) -{ - fieldset dl { - margin-bottom: 5px; - padding-bottom: 5px; - border-bottom: 1px solid #e8e8e8; - } - - fieldset > dl:last-child, fieldset > form:last-child > dl:last-child { - border-bottom-width: 0; - margin-bottom: 0; - } - - fieldset dt, .rtl fieldset dt, fieldset dd, .rtl fieldset dd { - border-width: 0; - margin-left: 0; - margin-right: 0; - float: none; - width: auto; - } - - fieldset .responsive-columns dt { - float: left; - } - - .ltr fieldset dd { - padding-left: 20px; - } - - .rtl fieldset dd { - padding-right: 20px; - } - - select, dd select, dd input { - max-width: 300px; - } - - input[type="number"], dd input[type="number"] { - max-width: 70px; - } -} - -@media only screen and (max-width: 400px), only screen and (max-device-width: 400px) -{ - select, dd select, dd input { - max-width: 240px; - } -} - -/* Submit button fieldset or paragraph ----------------------------------------- */ -fieldset.submit-buttons { - text-align: center; - border: none; - background-color: transparent; - margin: 0; - padding: 4px; - margin-top: -1px; -} - -p.submit-buttons { - text-align: center; - margin: 0; - padding: 4px; - margin-top: 10px; -} - -fieldset.submit-buttons input, p.submit-buttons input { - padding: 3px 2px; -} - -fieldset.submit-buttons legend { - display: none; -} - -@media only screen and (max-width: 700px), only screen and (max-device-width: 700px) -{ - p.submit-buttons { - margin-top: 0; - } -} - -/* Input field styles ----------------------------------------- */ - -input.radio, input.checkbox, input.permissions-checkbox { - width: auto !important; - background-color: transparent; - border: none; - cursor: pointer; -} - -input.full, -textarea.full { - width: 99%; -} - -input.medium { width: 50%;} -input.narrow { width: 25%;} -input.tiny { width: 10%;} -input.autowidth { width: auto !important;} -.box2 .inputbox { background-color: #E9E9E9;} - -/* Form button styles ----------------------------------------- */ -a.button1, input.button1, -a.button2, input.button2 { - width: auto !important; - padding: 1px 3px 0 3px; - font-family: "Lucida Grande", Verdana, Helvetica, Arial, sans-serif; - color: #000; - font-size: 0.85em; - background: #EFEFEF url("../images/bg_button.gif") repeat-x top; - cursor: pointer; -} - -a.button1, input.button1 { - font-weight: bold; - border: 1px solid #666666; -} - -/* Alternative button */ -a.button2, input.button2 { - border: 1px solid #666666; -} - -/* button in the style of the form buttons */ -a.button1, a.button1:link, a.button1:visited, a.button1:active, -a.button2, a.button2:link, a.button2:visited, a.button2:active { - text-decoration: none; - color: #000000; - padding: 4px 8px; -} - -/* Hover states */ -a.button1:hover, input.button1:hover, -a.button2:hover, input.button2:hover { - border: 1px solid #BC2A4D; - background: #EFEFEF url("../images/bg_button.gif") repeat bottom; - color: #BC2A4D; -} - -input.disabled { - font-weight: normal; - color: #666666; -} - -/* Focus states */ -input.button1:focus, input.button2:focus { - outline-style: none; -} - -/* jQuery popups ----------------------------------------- */ -.phpbb_alert { - background-color: #FFFFFF; - border: 1px solid #999999; - position: fixed; - display: none; - top: 150px; - left: 0; - right: 0; - width: 620px; - margin: 0 auto; - z-index: 50; - padding: 25px; - padding: 0 25px 20px 25px; -} - -.phpbb_alert .alert_close { - display: block; - float: right; - width: 16px; - height: 16px; - overflow: hidden; - text-decoration: none !important; - background: transparent url("../images/alert_close.png") 0 0 no-repeat; - margin-top: -7px; - margin-right: -31px; -} -.phpbb_alert .alert_close:hover { - background-position: 0 -16px; -} - - -.phpbb_alert p { - margin: 8px 0; - padding-bottom: 8px; -} - -.phpbb_alert label { - display: block; - margin: 8px 0; - padding-bottom: 8px; -} - -.phpbb_alert div.alert_text > p, -.phpbb_alert div.alert_text > label, -.phpbb_alert div.alert_text > select, -.phpbb_alert div.alert_text > textarea, -.phpbb_alert div.alert_text > input { - font-size: 0.9em; -} - -#darkenwrapper { - display: none; - position: relative; - z-index: 44; -} - -#darken { - position: fixed; - left: 0; - top: 0; - width: 100%; - height: 100%; - background-color: #000000; - opacity: 0.5; - z-index: 45; -} - -@media only screen and (max-height: 500px), only screen and (max-device-width: 500px) -{ - .phpbb_alert { - top: 25px; - } -} - -@media only screen and (max-width: 700px), only screen and (max-device-width: 700px) -{ - .phpbb_alert { - width: auto; - margin: 0 25px; - } -} - -#loading_indicator { - background: #000000 url("../images/loading.gif") center center no-repeat; - border-radius: 5px; - display: none; - opacity: 0.8; - margin-top: -50px; - margin-left: -50px; - height: 50px; - width: 50px; - position: fixed; - left: 50%; - top: 50%; - z-index: 51; -} - -/* Pagination ----------------------------------------- */ -.pagination { - font-size: .85em; - height: 1%; /* IE tweak (holly hack) */ - width: auto; - text-align: right; - margin: 5px 0; -} - -.top-pagination { - float: right; - margin: 15px 0 5px 0; -} - -.rtl .pagination { - text-align: left; - float: left; -} - -li.pagination { - margin-top: 0; -} - -.pagination img { - vertical-align: middle; -} - -.pagination ul { - display: inline-block; - *display: inline; /* IE7 inline-block hack */ - *zoom: 1; - margin-left: 0; - margin-bottom: 0; -} - -li.pagination ul { - margin-top: -2px; - vertical-align: middle; -} - -.pagination ul li, dl .pagination ul li, dl.icon .pagination ul li { - display: inline; - padding: 0; - font-size: 100%; - line-height: normal; -} - -.pagination li a, .pagnation li span, li .pagination li a, li .pagnation li span, .pagination li.active span, .pagination li.ellipsis span { - font-weight: normal; - text-decoration: none; - padding: 0 2px; - border: 1px solid transparent; - font-size: 0.9em; - line-height: 1.5em; -} - -.pagination li a, .pagination li a:link, .pagination li a:visited { - color: #5C758C; - background-color: #ECEDEE; - border-color: #B4BAC0; -} - -.pagination li.ellipsis span { - background-color: transparent; - color: #000000; -} - -.pagination li.active span { - color: #FFFFFF; - background-color: #4692BF; - border-color: #4692BF; -} - -.pagination li a:hover, .pagination .active a:hover { - color: #FFFFFF; - background-color: #368AD2; - border-color: #368AD2; -} - -.pagination li a:active, .pagination li.active a:active { - color: #5C758C; - background-color: #ECEDEE; - border-color: #B4BAC0; -} - -@media only screen and (max-width: 700px), only screen and (max-device-width: 700px) -{ - .pagination, .rtl .pagination { - float: none; - text-align: center; - margin: 5px 0; - } - - .pagination li a, .pagination li span { - display: inline-block; - min-width: 10px; - } -} - -/* Action Highlighting ----------------------------------------- */ -.successbox, .errorbox, .warningbox { - padding: 8px; - margin: 10px 0; - color: #FFFFFF; - text-align: center; - clear: both; -} - -.success { - color: #228822; -} - -.error { - color: #BC2A4D; -} - -.successbox { - background-color: #228822; -} - -.errorbox { - background-color: #BC2A4D; -} - -.warningbox { - background-color: #fca600; -} - -.successbox h3, .errorbox h3 { - color: #FFFFFF; - margin: 0 0 0.5em; - font-size: 1.10em; - font-family: "Lucida Grande",Verdana,Helvetica,Arial,sans-serif; -} - -.successbox p, .errorbox p { - color: #FFFFFF; - font-size: 0.85em; - margin-bottom: 0; -} - -.errorbox a:link, .errorbox a:active, .errorbox a:visited, -.successbox a:link, .successbox a:active, .successbox a:visited { - color: #DBD7D1; - text-decoration: underline; - font-weight: bold; -} - -.errorbox a:hover, .successbox a:hover { - color: #FFFFFF; - text-decoration: none; - font-weight: bold; -} - -#log-container { - display: none; - max-height: 300px; - padding: 8px; - margin: 10px 0; - clear: both; - overflow-y: auto; - background-color: #FFFFFF; -} - -#log-container.show_log_container { - display: block; - border: 1px solid #DBD7D1; -} - -.log { - font-size: 0.8em; -} - -.notice { - background-color: #62A5CC; -} - -.download-box { - margin: 10px 0 10px 0; -} - -/* Special cases for the error page */ -#errorpage #page-header a { - font-weight: bold; - line-height: 6em; -} - -#errorpage #content { - padding-top: 10px; -} - -#errorpage #content h1 { - color: #DF075C; -} - -#errorpage #content h2 { - margin-top: 20px; - margin-bottom: 5px; - border-bottom: 1px solid #CCCCCC; - padding-bottom: 5px; - color: #333333; -} - -/* Tooltip for permission roles */ -.tooltip { - width: 200px; - color: #000; - text-align: center; - border: 1px solid #AAA; -} - -.tooltip span.top { - background: #EFEFEF; - font-weight: bold; - padding: 2px; -} - -.tooltip span.bottom { - padding: 5px; - color: #000000; - background: #FFFFFF; -} - -/* - Format Buttons for signature editor -*/ -#format-buttons { - margin: 15px 0 2px 0; -} - -#format-buttons input, #format-buttons select { - vertical-align: middle; -} - -.row, fieldset dl { - overflow: hidden; -} - -/* Syntax Highlighting ----------------------------------------- */ -.sourcenum { - color: gray; - font-family: Monaco, 'Courier New', monospace; - font-size: 1.25em; - font-weight: bold; - line-height: 1.20em; - text-align: right; - padding: 0; -} - -.rtl .sourcenum { - text-align: left; -} - -.source { - font-family: Monaco, 'Courier New', monospace; - font-size: 1.25em; - line-height: 1.20em; - padding: 0; -} - -.syntaxbg { - color: #FFFFFF; -} - -.syntaxcomment { - color: #FF8000; -} - -.syntaxdefault { - color: #0000BB; -} - -.syntaxhtml { - color: #000000; -} - -.syntaxkeyword { - color: #007700; -} - -.syntaxstring { - color: #DD0000; -} - -/* Permission interface ----------------------------------------- */ - -.column1, .column2 { - width: 48%; - float: left; -} - -.ltr .column2, .rtl .column1 { - float: right; -} - -fieldset.permissions legend { - text-transform: none; -} - -fieldset.permissions legend input{ - height: 1.1em; -} - -/* Permission sections */ -fieldset.permissions .permissions-simple { - text-align: left; - padding-top: 3px; -} - -.rtl fieldset.permissions .permissions-simple { - text-align: right; -} - -fieldset.permissions .permissions-advanced { - padding: 10px 0 0 5px; - vertical-align: top; - clear: right; -} - -.rtl fieldset.permissions .permissions-advanced { - padding: 10px 5px 0 0; - clear: left; -} - -fieldset.permissions .permissions-switch { - float: right; -} - -.rtl fieldset.permissions .permissions-switch { - float: left; -} - -fieldset.permissions .padding { -} - -.permissions-switch { - margin-top: -6px; - font-size: .9em; -} - -.permissions-switch a { - text-decoration: underline; -} - -.permissions-reset { - padding-bottom: 10px; -} - -.permissions-reset a { - font-size: .85em; -} - -/* Tabbed menu */ -.permissions-category { - line-height: normal; - margin: 0 0 -1px 7px; - min-width: 570px; - font-size: 0.85em; -} - -.rtl .permissions-category { - margin: 0 7px -1px 0; -} - -.permissions-category ul { - margin: 0; - padding: 0; - list-style: none; -} - -.permissions-category li { - display: inline; - margin: 0; - padding: 0; - font-size: 1em; - font-weight: bold; -} - -.permissions-category a { - float: left; - background: url("../images/bg_tabs_alt1.gif") no-repeat 0% -35px; - margin: 0 1px 0 0; - padding: 0 0 0 6px; - text-decoration: none; - position: relative; -} - -.rtl .permissions-category a { - float: right; -} - -.permissions-category a span.tabbg { - float: left; - display: block; - background: url("../images/bg_tabs_alt2.gif") no-repeat 100% -35px; - padding: 7px 12px 6px 6px; - color: #536482; - white-space: nowrap; -} - -.rtl .permissions-category a span.tabbg { - float: right; -} - -/* Commented Backslash Hack hides rule from IE5-Mac \*/ -.permissions-category a span.tabbg, .rtl .permissions-category a span.tabbg { float: none;} -/* End hack */ - -.permissions-category a:hover span.tabbg { - color: #DD6900; -} - -.permissions-category .activetab a { - background-position: 0 0; -} - -.permissions-category .activetab a span.tabbg { - background-position: 100% 0; - padding-bottom: 7px; - color: #333333; -} - -.permissions-category a:hover { - background-position: 0 -70px; -} - -.permissions-category a:hover span.tabbg { - background-position: 100% -70px; -} - -.permissions-category .activetab a:hover span.tabbg { - color: #333333; - background-position: 100% 0; -} - -.permissions-category .activetab a:hover { - background-position: 0 0; -} - -.permissions-category a span.colour { - border: 1px solid #536482; - display: block; - float: left; - width: 10px; - height: 10px; - margin: 0 5px 0 0; -} - -/* Most browsers will have to live with a left aligned icon in RTL mode, as (currently) only Firefox 3.0 Alpha 3 renders it correctly without destroying it -.rtl .permissions-category a span.colour { - float: right; - margin: 0 0 0 5px; -} -*/ - -.permissions-category .activetab span.colour { - border-color: #333333; -} - -.permissions-category a:hover span.colour { - border-color: #DD6900; -} - -.permissions-category .activetab a:hover span.colour { - border-color: #333333; -} - -/* Permission preset colours */ -.permissions-preset-yes span.colour, -.yes { - background-color: #86F786; -} - -.permissions-preset-custom span.colour { - background-color: #B2BBDD; -} - -.permissions-preset-never span.colour { - background-color: #DD0000; -} - -.permissions-preset-no span.colour, -.never { - background-color: #EFB0B2; -} - -/* Permission panel ----------------------------------------- */ -.permissions-panel { - float: left; - background-color: #CADCEB; - width: 100%; - border-radius: 5px; - overflow: hidden; - padding: 5px 0; -} - -.rtl .permissions-panel { - float: right; -} - -/* Permission table ----------------------------------------- */ -.permissions-panel .tablewrap { - margin: 0 10px; -} - -.permissions-panel table { - width: 100%; -} - -.permissions-panel th { - text-transform: none; -} - -.permissions-panel th.value { - text-align: center; -} - -.permissions-panel th.name { - text-align: left; - width: auto; - text-transform: none; -} - -.rtl .permissions-panel th.name { - text-align: right; -} - -.permissions-panel th.permissions-name { - border: none; - color: #536482; - font-weight: normal; -} - -.permissions-panel th.permissions-name a.trace { - display: inline; -} - -.permissions-panel th.row3 { - background-image: none; - background-color: #D1D7DC; - color: #536482; - border: none; -} - -.permissions-panel th.row4 { - background-image: none; - background-color: #E4E8EB; - color: #536482; - border: none; -} - -.permissions-panel th a:link, .permissions-panel th a:hover, .permissions-panel th a:visited { - display: block; - color: #FFFFFF; - text-decoration: underline; -} - -.permissions-panel td.permissions-yes label:hover { - background-color: #86F786; -} - -.permissions-panel td.permissions-no label:hover { - background-color: #EFB0B2; -} - -.permissions-panel td.permissions-never label:hover { - background-color: #DD0000; -} - -.permissions-panel td { - padding: 0; - text-align: center; - width: 10%; -} - -.permissions-panel td label { - display: block; - margin: 0; - padding: 0; -} - -@media only screen and (max-width: 700px), only screen and (max-device-width: 700px) -{ - .column1, .column2 { - float: none !important; - width: auto; - } - - .permissions-simple { - clear: both; - } - - .permissions-simple td, .permissions-simple dd { - width: auto !important; - margin-left: 0 !important; - margin-right: 0 !important; - } - - .permissions-simple dd { - margin-top: 5px; - } - - .permissions-panel .tablewrap { - margin: 0 5px; - } - - .permissions-category { - min-width: 0; - margin: 0 !important; - } - - .permissions-category a, .permissions-category a span.tabbg { - display: block; - float: none !important; - background: transparent none; - } - - .permissions-category a { - background: #d9e5ee; - margin: 5px 0; - padding: 0 !important; - border-radius: 3px; - text-decoration: underline; - } - - .permissions-category .activetab a { - background-color: #dd6900; - color: #fff; - } - - .permissions-category a span.tabbg { - color: inherit !important; - padding-top: 6px !important; - padding-bottom: 6px !important; - } - - .permissions-category .activetab span.colour { - border-color: #fff; - } -} - -/* Avatars gallery ----------------------------------------- */ -#gallery { - display: block; - margin: 0 -5px; - padding: 0; - overflow: hidden; -} - -#gallery li { - display: block; - float: left; - border: 1px solid #ccc; - border-radius: 2px; - background: #fff; - padding: 5px; - margin: 5px; -} - -#gallery li:hover { - background-color: #eee; -} - -#gallery li label { - display: block; - text-align: center; - padding: 0; -} - -/* Dropdown menu -----------------------------------------*/ -.dropdown { - position: absolute; - left: 0; - top: 22px; - z-index: 2; - border: 1px solid transparent; - border-radius: 5px; - padding: 9px 0 0; -} - -.dropdown-up .dropdown { - top: auto; - bottom: 18px; - padding: 0 0 9px; -} - -.dropdown-left .dropdown { - left: auto; - right: 0; -} - -.dropdown .pointer, .dropdown .pointer-inner { - position: absolute; - width: 0; - height: 0; - border-top-width: 0; - border-bottom: 10px solid transparent; - border-left: 10px dashed transparent; - border-right: 10px dashed transparent; - -webkit-transform: rotate(360deg); /* better anti-aliasing in webkit */ - display: block; -} - -.dropdown-up .pointer, .dropdown-up .pointer-inner { - border-bottom-width: 0; - border-top: 10px solid transparent; -} - -.dropdown .pointer { - right: auto; - left: 10px; - top: 0; - z-index: 3; -} - -.dropdown-up .pointer { - bottom: 0; - top: auto; -} - -.dropdown-left .dropdown .pointer { - left: auto; - right: 10px; -} - -.dropdown .pointer-inner { - top: auto; - bottom: -11px; - left: -10px; -} - -.dropdown-up .pointer-inner { - bottom: auto; - top: -11px; -} - -.dropdown .pointer { - border-color: #B9B9B9 transparent; -} - -.dropdown .pointer-inner { - border-color: #FFF transparent; -} - -.dropdown .dropdown-contents { - z-index: 2; - overflow: hidden; - overflow-y: auto; - background: #fff; - border: 1px solid #b9b9b9; - border-radius: 5px; - padding: 5px; - position: relative; - min-width: 40px; - max-height: 200px; - box-shadow: 1px 3px 5px rgba(0, 0, 0, 0.2); - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; -} - -.dropdown-up .dropdown-contents { - box-shadow: 1px 0 5px rgba(0, 0, 0, 0.2); -} - -.dropdown li { - float: none; - margin: 0; - white-space: nowrap; - text-align: left; -} - -.rtl .dropdown li { - text-align: right; -} -.wrap .dropdown li, .dropdown.wrap li { - white-space: normal; -} - -.dropdown li:before, .dropdown li:after { - display: none !important; -} - -.roles-options > .dropdown { - left: auto; - top: 3.2em; - width: 250px; -} - -.rtl .roles-options > .dropdown { - right: auto; -} - -.roles-options { - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - -o-user-select: none; - user-select: none; - width: 250px; -} - -.roles-options > span { - border: 1px solid #DEDEDE; - border-radius: 3px; - padding: 4px; - width: 250px; - display: none; - background: url('../images/arrow_down.gif') no-repeat 245px .7em; -} - -.rtl .roles-options > span { - background: url('../images/arrow_down.gif') no-repeat 7px .7em; -} - -.roles-options li { - list-style: none; -} - -.roles-highlight { - background-color: #1e90ff; - color: #fff; -} - - -/* Classes for additional tasks ----------------------------------------- */ - -.current-ext { - color: #228822; -} - -.outdated-ext { - color: #BC2A4D; -} - -.phpinfo { - overflow: auto; - width: 99%; - direction: ltr; -} - -.phpinfo td, .phpinfo th, .phpinfo h2, .phpinfo h1 { - text-align: left; -} - -.requirements_not_met { - padding: 5px; - background-color: #BC2A4D; -} - -.requirements_not_met dt label, .requirements_not_met dd p { - color: #FFFFFF; - font-size: 1.4em; -} - -@media only screen and (max-width: 700px), only screen and (max-device-width: 700px) -{ - .responsive-hide { display: none !important; } - .responsive-show { display: block !important; } - .responsive-show-inline { display: inline !important; } - .responsive-show-inline-block { display: inline-block !important; } -} - -.clearfix { - overflow: hidden; -} - -.pagination:after, -#page-header:after, -#page-body:after, -#tabs:after, -#tabs > ul:after, -#tabs li:after, -#acp:after, -#content:after { - content: ''; - clear: both; - display: block; -} - -#progress-bar { - position: relative; - width: 90%; - text-align: center; - height: 25px; - margin: 20px auto; - border: 1px solid #cecece; -} - -#progress-bar #progress-bar-text { - position: absolute; - top: 0; - width: 100%; - color: #000; -} - -#progress-bar #progress-bar-filler { - display: block; - position: relative; - top: 0; - left: 0; - background-color: #3c84ad; - width: 0; - height: 25px; - overflow: hidden; - color: #fff; -} - -#progress-bar p { - line-height: 25px; - font-weight: bold; -} - -.send-stats-row { - margin: 15px 0; -} - -.send-stats-row:before { - display: table; - content: " "; -} - -.send-stats-tile { - position: relative; - padding: 14px; - margin-bottom: 20px; - background-color: #eff0f2; - border-radius: 6px; - box-shadow: rgba(0,0,0,0.3) 1px 1px 5px; -} - -.send-stats-tile h2 { - margin-top: 0; - text-align: center; - padding-bottom: 1em; -} - -.send-stats-tile i { - padding-right: 0.3em; -} - -.icon { - font-family: FontAwesome; - font-style: normal; -} - -.send-stats-data-row { - background: #f9f9f9; - border-radius: 6px; - border: #DEDEDE 1px solid; - padding: 10px; - border-top-width: 0; - border-top-right-radius: 0; - border-top-left-radius: 0; -} - -.send-stats-data-hidden .configlist { - display: none; -} - -.send-stats-data-only-row { - border-radius: 6px !important; - border-bottom-width: 1px !important; -} - -.send-stats-data-hidden { - padding: 0; - border: none; -} - -.send-stats-row > .send-stats-data-row:first-child { - background-color: #d9edf7; - border-bottom-width: 0; - border-top-right-radius: 6px; - border-top-left-radius: 6px; - border-top-width: 1px; - border-bottom-left-radius: 0; - border-bottom-right-radius: 0; -} - -.send-stats-settings dt, .send-stats-settings dd { - min-width: 25px; -} - -.send-stats-settings dd { - line-height: 1.5em; -} - -.send-stats-settings input { - display: none; -} - -.send-stats-settings input[type=checkbox] + label:before { - content: "\f096"; - font-family: FontAwesome; - font-size: 1.5em; -} - -.send-stats-settings input[type=checkbox]:checked + label:before { - content: "\f14a"; - color: #3c763d; -} - -.send-stats-data-row a:hover span { - text-decoration: underline; -} - -.send-stats-data-row a { - text-decoration: none; - cursor: default; -} - -.send-stats-data-row i { - padding-left: 6px; -} - -.configlist { - word-wrap: break-word; - word-break: break-all; -} - -/* stylelint-disable declaration-property-unit-whitelist */ -.emoji { - min-height: 18px; - min-width: 18px; - height: 1em; - width: 1em; -} -/* stylelint-enable declaration-property-unit-whitelist */ diff --git a/install/update/new/adm/style/admin.js b/install/update/new/adm/style/admin.js deleted file mode 100644 index 5fdd073..0000000 --- a/install/update/new/adm/style/admin.js +++ /dev/null @@ -1,316 +0,0 @@ -/** -* phpBB3 ACP functions -*/ - -/** -* Parse document block -*/ -function parse_document(container) -{ - var test = document.createElement('div'), - oldBrowser = (typeof test.style.borderRadius == 'undefined'); - - delete test; - - /** - * Navigation - */ - container.find('#menu').each(function() { - var menu = $(this), - blocks = menu.children('.menu-block'); - - if (!blocks.length) { - return; - } - - // Set onclick event - blocks.children('a.header').click(function() { - var parent = $(this).parent(); - if (!parent.hasClass('active')) { - parent.siblings().removeClass('active'); - } - parent.toggleClass('active'); - }); - - // Set active menu - menu.find('#activemenu').parents('.menu-block').addClass('active'); - - // Check if there is active menu - if (!blocks.filter('.active').length) { - blocks.filter(':first').addClass('active'); - } - }); - - /** - * Responsive tables - */ - container.find('table').not('.not-responsive').each(function() { - var $this = $(this), - th = $this.find('thead > tr > th'), - columns = th.length, - headers = [], - totalHeaders = 0, - i, headersLength; - - // Find columns - $this.find('colgroup:first').children().each(function(i) { - var column = $(this); - $this.find('td:nth-child(' + (i + 1) + ')').addClass(column.prop('className')); - }); - - // Styles table - if ($this.hasClass('styles')) { - $this.find('td:first-child[style]').each(function() { - var style = $(this).attr('style'); - if (style.length) { - $(this).parent('tr').attr('style', style.toLowerCase().replace('padding', 'margin')).addClass('responsive-style-row'); - } - }); - } - - // Find each header - if (!$this.data('no-responsive-header')) - { - th.each(function(column) { - var cell = $(this), - colspan = parseInt(cell.attr('colspan')), - dfn = cell.attr('data-dfn'), - text = dfn ? dfn : $.trim(cell.text()); - - if (text == ' ') text = ''; - colspan = isNaN(colspan) || colspan < 1 ? 1 : colspan; - - for (i=0; i - $this.addClass('responsive'); - - if (totalHeaders < 2) { - $this.addClass('show-header'); - return; - } - - $this.find('tbody > tr').each(function() { - var row = $(this), - cells = row.children('td'), - column = 0; - - if (cells.length == 1) { - row.addClass('big-column'); - return; - } - - cells.each(function() { - var cell = $(this), - colspan = parseInt(cell.attr('colspan')), - text = $.trim(cell.text()); - - if (headersLength <= column) { - return; - } - - if ((text.length && text !== '-') || cell.children().length) { - if (headers[column] != '') { - cell.prepend('' + headers[column] + ''); - } - } - else { - cell.addClass('empty'); - } - - colspan = isNaN(colspan) || colspan < 1 ? 1 : colspan; - column += colspan; - }); - }); - - // Remove in disabled extensions list - $this.find('tr.ext_disabled > .empty:nth-child(2) + .empty').siblings(':first-child').children('dfn').remove(); - }); - - /** - * Hide empty responsive tables - */ - container.find('table.responsive > tbody').each(function() { - var items = $(this).children('tr'); - if (items.length == 0) - { - $(this).parent('table:first').addClass('responsive-hide'); - } - }); - - /** - * Fieldsets with empty - */ - container.find('fieldset dt > span:last-child').each(function() { - var $this = $(this); - if ($this.html() == ' ') { - $this.addClass('responsive-hide'); - } - - }); - - /** - * Responsive tabs - */ - container.find('#tabs').not('[data-skip-responsive]').each(function() { - var $this = $(this), - $body = $('body'), - ul = $this.children(), - tabs = ul.children().not('[data-skip-responsive]'), - links = tabs.children('a'), - item = ul.append('').find('li.responsive-tab'), - menu = item.find('.dropdown-contents'), - maxHeight = 0, - lastWidth = false, - responsive = false; - - links.each(function() { - var link = $(this); - maxHeight = Math.max(maxHeight, Math.max(link.outerHeight(true), link.parent().outerHeight(true))); - }) - - function check() { - var width = $body.width(), - height = $this.height(); - - if (arguments.length == 0 && (!responsive || width <= lastWidth) && height <= maxHeight) { - return; - } - - tabs.show(); - item.hide(); - - lastWidth = width; - height = $this.height(); - if (height <= maxHeight) { - responsive = false; - if (item.hasClass('dropdown-visible')) { - phpbb.toggleDropdown.call(item.find('a.responsive-tab-link').get(0)); - } - return; - } - - responsive = true; - item.show(); - menu.html(''); - - var availableTabs = tabs.filter(':not(.activetab, .responsive-tab)'), - total = availableTabs.length, - i, tab; - - for (i = total - 1; i >= 0; i --) { - tab = availableTabs.eq(i); - menu.prepend(tab.clone(true).removeClass('tab')); - tab.hide(); - if ($this.height() <= maxHeight) { - menu.find('a').click(function() { check(true); }); - return; - } - } - menu.find('a').click(function() { check(true); }); - } - - phpbb.registerDropdown(item.find('a.responsive-tab-link'), item.find('.dropdown'), {visibleClass: 'activetab', verticalDirection: 'down'}); - - check(true); - $(window).resize(check); - }); -} - -/** - * Extension actions helper functions - */ -function move_to_enabled(element) -{ - var disabled_header = document.querySelector('#ext_disabled_header'); - disabled_header.parentNode.insertBefore(element, disabled_header); - element.classList.remove('ext_disabled'); - element.classList.add('ext_enabled'); -} -function move_to_disabled(element) -{ - var table_body = document.querySelector('#ext_disabled_header').parentNode; - table_body.appendChild(element); - element.classList.remove('ext_enabled'); - element.classList.add('ext_disabled'); -} -function set_actions(container, actions) { - container.innerHTML = ''; - for (var i = 0; i < actions.length; i++) { - var a = document.createElement('a'); - a.href = actions[i].U_ACTION.split('&').join('&'); // replace all occurances - a.title = actions[i].L_ACTION_EXPLAIN; - if (actions[i].COLOR) { - a.style = actions[i].COLOR; - } - a.innerHTML = actions[i].L_ACTION; - // ajaxify this action as well - phpbb.ajaxify({ - selector: a, - refresh: true, - callback: actions[i].ACTION_AJAX - }); - - container.appendChild(a); - - if (i < actions.length - 1) { - container.innerHTML += ' | '; - } - } -} -function show_enabled_header() { - document.querySelector('#ext_enabled_header').classList.remove('hidden'); -} -function show_disabled_header() { - document.querySelector('#ext_disabled_header').classList.remove('hidden'); -} -function hide_disabled_header_if_empty() { - if (!document.querySelector('.ext_disabled')) { - document.querySelector('#ext_disabled_header').classList.add('hidden'); - } -} -function hide_enabled_header_if_empty() { - if (!document.querySelector('.ext_enabled')) { - document.querySelector('#ext_enabled_header').classList.add('hidden'); - } -} - -/** -* Run onload functions -*/ -(function($) { - $(document).ready(function() { - // Swap .nojs and .hasjs - $('body.nojs').toggleClass('nojs hasjs'); - - // Focus forms - $('form[data-focus]:first').each(function() { - $('#' + this.getAttribute('data-focus')).focus(); - }); - - parse_document($('body')); - - $('#questionnaire-form').css('display', 'none'); - var $triggerConfiglist = $('#trigger-configlist'); - - $triggerConfiglist.on('click', function () { - var $configlist = $('#configlist'); - $configlist.closest('.send-stats-data-row').toggleClass('send-stats-data-hidden'); - $configlist.closest('.send-stats-row').find('.send-stats-data-row:first-child').toggleClass('send-stats-data-only-row'); - $(this).find('i').toggleClass('fa-angle-down fa-angle-up'); - }); - - $('#configlist').closest('.send-stats-data-row').addClass('send-stats-data-hidden'); - }); -})(jQuery); diff --git a/install/update/new/adm/style/ajax.js b/install/update/new/adm/style/ajax.js deleted file mode 100644 index 39b63e4..0000000 --- a/install/update/new/adm/style/ajax.js +++ /dev/null @@ -1,360 +0,0 @@ -/* global phpbb, statsData */ - -(function($) { // Avoid conflicts with other libraries - -'use strict'; - - -phpbb.prepareSendStats = function () { - var $form = $('#acp_help_phpbb'); - var $dark = $('#darkenwrapper'); - var $loadingIndicator; - - $form.on('submit', function (event) { - var $this = $(this), - currentTime = Math.floor(new Date().getTime() / 1000), - statsTime = parseInt($this.find('input[name=help_send_statistics_time]').val(), 10); - - event.preventDefault(); - $this.unbind('submit'); - - // Skip ajax request if form is submitted too early or send stats - // checkbox is not checked - if (!$this.find('input[name=help_send_statistics]').is(':checked') || - statsTime > currentTime) { - $form.find('input[type=submit]').click(); - setTimeout(function () { - $form.find('input[type=submit]').click(); - }, 300); - return; - } - - /** - * Handler for AJAX errors - */ - function errorHandler(jqXHR, textStatus, errorThrown) { - if (typeof console !== 'undefined' && console.log) { - console.log('AJAX error. status: ' + textStatus + ', message: ' + errorThrown); - } - phpbb.clearLoadingTimeout(); - var errorText = ''; - - if (typeof errorThrown === 'string' && errorThrown.length > 0) { - errorText = errorThrown; - } else { - errorText = $dark.attr('data-ajax-error-text-' + textStatus); - if (typeof errorText !== 'string' || !errorText.length) { - errorText = $dark.attr('data-ajax-error-text'); - } - } - phpbb.alert($dark.attr('data-ajax-error-title'), errorText); - } - - /** - * This is a private function used to handle the callbacks, refreshes - * and alert. It calls the callback, refreshes the page if necessary, and - * displays an alert to the user and removes it after an amount of time. - * - * It cannot be called from outside this function, and is purely here to - * avoid repetition of code. - * - * @param {object} res The object sent back by the server. - */ - function returnHandler(res) { - phpbb.clearLoadingTimeout(); - - // If a confirmation is not required, display an alert and call the - // callbacks. - $dark.fadeOut(phpbb.alertTime); - - if ($loadingIndicator) { - $loadingIndicator.fadeOut(phpbb.alertTime); - } - - var $sendStatisticsSuccess = $('', { - type: 'hidden', - name: 'send_statistics_response', - value: JSON.stringify(res) - }); - $sendStatisticsSuccess.appendTo('p.submit-buttons'); - - // Finish actual form submission - $form.find('input[type=submit]').click(); - } - - $loadingIndicator = phpbb.loadingIndicator(); - - $.ajax({ - url: $this.attr('data-ajax-action').replace('&', '&'), - type: 'POST', - data: statsData, - success: returnHandler, - error: errorHandler, - cache: false - }).always(function() { - if ($loadingIndicator && $loadingIndicator.is(':visible')) { - $loadingIndicator.fadeOut(phpbb.alertTime); - } - }); - }); -}; - -/** - * The following callbacks are for reording items. row_down - * is triggered when an item is moved down, and row_up is triggered when - * an item is moved up. It moves the row up or down, and deactivates / - * activates any up / down icons that require it (the ones at the top or bottom). - */ -phpbb.addAjaxCallback('row_down', function(res) { - if (typeof res.success === 'undefined' || !res.success) { - return; - } - - var $firstTr = $(this).parents('tr'), - $secondTr = $firstTr.next(); - - $firstTr.insertAfter($secondTr); -}); - -phpbb.addAjaxCallback('row_up', function(res) { - if (typeof res.success === 'undefined' || !res.success) { - return; - } - - var $secondTr = $(this).parents('tr'), - $firstTr = $secondTr.prev(); - - $secondTr.insertBefore($firstTr); -}); - -/** - * This callback replaces activate links with deactivate links and vice versa. - * It does this by replacing the text, and replacing all instances of "activate" - * in the href with "deactivate", and vice versa. - */ -phpbb.addAjaxCallback('activate_deactivate', function(res) { - var $this = $(this), - newHref = $this.attr('href'); - - $this.text(res.text); - - if (newHref.indexOf('deactivate') !== -1) { - newHref = newHref.replace('deactivate', 'activate'); - } else { - newHref = newHref.replace('activate', 'deactivate'); - } - - $this.attr('href', newHref); -}); - -/** - * The removes the parent row of the link or form that triggered the callback, - * and is good for stuff like the removal of forums. - */ -phpbb.addAjaxCallback('row_delete', function(res) { - if (res.SUCCESS !== false) { - $(this).parents('tr').remove(); - } -}); - -/** - * Callbacks for extension actions - */ -phpbb.addAjaxCallback('ext_enable', function(res) { - if (res.EXT_ENABLE_SUCCESS) { - move_to_enabled(this.parentNode.parentNode); - set_actions(this.parentNode, res.ACTIONS); - show_enabled_header(); - hide_disabled_header_if_empty(); - } -}); -phpbb.addAjaxCallback('ext_delete_data', function(res) { - if (res.EXT_DELETE_DATA_SUCCESS) { - move_to_disabled(this.parentNode.parentNode); - set_actions(this.parentNode, res.ACTIONS); - show_disabled_header(); - hide_enabled_header_if_empty(); - } -}); -phpbb.addAjaxCallback('ext_disable', function(res) { - if (res.EXT_DISABLE_SUCCESS) { - move_to_disabled(this.parentNode.parentNode); - set_actions(this.parentNode, res.ACTIONS); - show_disabled_header(); - hide_enabled_header_if_empty(); - } -}); - -/** - * Handler for submitting permissions form in chunks - * This call will submit permissions forms in chunks of 5 fieldsets. - */ -function submitPermissions() { - var $form = $('form#set-permissions'), - fieldsetList = $form.find('fieldset[id^=perm]'), - formDataSets = [], - dataSetIndex = 0, - $submitAllButton = $form.find('input[type=submit][name^=action]')[0], - $submitButton = $form.find('input[type=submit][data-clicked=true]')[0]; - - // Set proper start values for handling refresh of page - var permissionSubmitSize = 0, - permissionRequestCount = 0, - forumIds = [], - permissionSubmitFailed = false; - - if ($submitAllButton !== $submitButton) { - fieldsetList = $form.find('fieldset#' + $submitButton.closest('fieldset.permissions').id); - } - - $.each(fieldsetList, function (key, value) { - dataSetIndex = Math.floor(key / 5); - var $fieldset = $('fieldset#' + value.id); - if (key % 5 === 0) { - formDataSets[dataSetIndex] = $fieldset.find('select:visible, input:not([data-name])').serialize(); - } else { - formDataSets[dataSetIndex] += '&' + $fieldset.find('select:visible, input:not([data-name])').serialize(); - } - - // Find proper role value - var roleInput = $fieldset.find('input[name^=role][data-name]'); - if (roleInput.val()) { - formDataSets[dataSetIndex] += '&' + roleInput.attr('name') + '=' + roleInput.val(); - } else { - formDataSets[dataSetIndex] += '&' + roleInput.attr('name') + '=' + - $fieldset.find('select[name="' + roleInput.attr('name') + '"]').val(); - } - }); - - permissionSubmitSize = formDataSets.length; - - // Add each forum ID to forum ID list to preserve selected forums - $.each($form.find('input[type=hidden][name^=forum_id]'), function (key, value) { - if (value.name.match(/^forum_id\[([0-9]+)\]$/)) { - forumIds.push(value.value); - } - }); - - /** - * Handler for submitted permissions form chunk - * - * @param {object} res Object returned by AJAX call - */ - function handlePermissionReturn(res) { - permissionRequestCount++; - var $dark = $('#darkenwrapper'); - - if (res.S_USER_WARNING) { - phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); - permissionSubmitFailed = true; - } else if (!permissionSubmitFailed && res.S_USER_NOTICE) { - // Display success message at the end of submitting the form - if (permissionRequestCount >= permissionSubmitSize) { - var $alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); - var $alertBoxLink = $alert.find('p.alert_text > a'); - - // Create form to submit instead of normal "Back to previous page" link - if ($alertBoxLink) { - // Remove forum_id[] from URL - $alertBoxLink.attr('href', $alertBoxLink.attr('href').replace(/(&forum_id\[\]=[0-9]+)/g, '')); - var previousPageForm = '
'; - $.each(forumIds, function (key, value) { - previousPageForm += ''; - }); - previousPageForm += '
'; - - $alertBoxLink.on('click', function (e) { - var $previousPageForm = $(previousPageForm); - $('body').append($previousPageForm); - e.preventDefault(); - $previousPageForm.submit(); - }); - } - - // Do not allow closing alert - $dark.off('click'); - $alert.find('.alert_close').hide(); - - if (typeof res.REFRESH_DATA !== 'undefined') { - setTimeout(function () { - // Create forum to submit using POST. This will prevent - // exceeding the maximum length of URLs - var form = '
'; - $.each(forumIds, function (key, value) { - form += ''; - }); - form += '
'; - $form = $(form); - $('body').append($form); - - // Hide the alert even if we refresh the page, in case the user - // presses the back button. - $dark.fadeOut(phpbb.alertTime, function () { - if (typeof $alert !== 'undefined') { - $alert.hide(); - } - }); - - // Submit form - $form.submit(); - }, res.REFRESH_DATA.time * 1000); // Server specifies time in seconds - } - } - } - } - - // Create AJAX request for each form data set - $.each(formDataSets, function (key, formData) { - $.ajax({ - url: $form.action, - type: 'POST', - data: formData + '&' + $submitButton.name + '=' + encodeURIComponent($submitButton.value) + - '&creation_time=' + $form.find('input[type=hidden][name=creation_time]')[0].value + - '&form_token=' + $form.find('input[type=hidden][name=form_token]')[0].value + - '&' + $form.children('input[type=hidden]').serialize() + - '&' + $form.find('input[type=checkbox][name^=inherit]').serialize(), - success: handlePermissionReturn, - error: handlePermissionReturn - }); - }); -} - -$('[data-ajax]').each(function() { - var $this = $(this), - ajax = $this.attr('data-ajax'); - - if (ajax !== 'false') { - var fn = (ajax !== 'true') ? ajax : null; - phpbb.ajaxify({ - selector: this, - refresh: $this.attr('data-refresh') !== undefined, - callback: fn - }); - } -}); - -/** -* Automatically resize textarea -*/ -$(function() { - phpbb.resizeTextArea($('textarea:not(.no-auto-resize)'), {minHeight: 75}); - - var $setPermissionsForm = $('form#set-permissions'); - if ($setPermissionsForm.length) { - $setPermissionsForm.on('submit', function (e) { - submitPermissions(); - e.preventDefault(); - }); - $setPermissionsForm.find('input[type=submit]').click(function() { - $('input[type=submit]', $(this).parents($('form#set-permissions'))).removeAttr('data-clicked'); - $(this).attr('data-clicked', true); - }); - } - - if ($('#acp_help_phpbb')) { - phpbb.prepareSendStats(); - } -}); - - -})(jQuery); // Avoid conflicts with other libraries diff --git a/install/update/new/adm/style/captcha_recaptcha.html b/install/update/new/adm/style/captcha_recaptcha.html deleted file mode 100644 index 563bd98..0000000 --- a/install/update/new/adm/style/captcha_recaptcha.html +++ /dev/null @@ -1,15 +0,0 @@ - -
-
- - - {L_RECAPTCHA_INVISIBLE} - -
-
-
- -{L_RECAPTCHA_NOT_AVAILABLE} - diff --git a/install/update/new/adm/style/installer_convert.html b/install/update/new/adm/style/installer_convert.html deleted file mode 100644 index aa16542..0000000 --- a/install/update/new/adm/style/installer_convert.html +++ /dev/null @@ -1,87 +0,0 @@ - -

{TITLE}

- -
-

{ERROR_TITLE}

-

{ERROR_MSG}

-
- - -
- - {errors.TITLE} -

{errors.DESCRIPTION}

- -
- -

{BODY}

-{CONTENT} - -

onclick="return false;">{L_SUBMIT}

- - -
-

- {L_CONVERT_NEW_CONVERSION} - {L_CONTINUE_OLD_CONVERSION} -

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{L_AVAILABLE_CONVERTORS}
{L_SOFTWARE}{L_VERSION}{L_AUTHOR}{L_CONVERT_OPTIONS}
{convertors.SOFTWARE}{convertors.VERSION}{convertors.AUTHOR}{L_CONVERT}
{L_NO_CONVERTORS}---
- - -
- - - - -
- -
- - {checks.LEGEND} -

{checks.LEGEND_EXPLAIN}

- - -
-

{checks.TITLE_EXPLAIN}
-
{checks.RESULT}
-
- - - -
- - - diff --git a/install/update/new/adm/style/installer_footer.html b/install/update/new/adm/style/installer_footer.html deleted file mode 100644 index 81a85d1..0000000 --- a/install/update/new/adm/style/installer_footer.html +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - -{$SCRIPTS} - - - diff --git a/install/update/new/adm/style/installer_form.html b/install/update/new/adm/style/installer_form.html deleted file mode 100644 index 592d361..0000000 --- a/install/update/new/adm/style/installer_form.html +++ /dev/null @@ -1,57 +0,0 @@ -

{FORM_TITLE}

-
- - -
- - - - - -
- -
- - {options.LEGEND} - -
-

{options.TITLE_EXPLAIN}
-
- - - - - - - - - - - - - - - checked /> {options.OPTIONS.label} - - -
-
- - - -
- - - -
- {L_SUBMIT} - - disabled="disabled" /> - -
- -
diff --git a/install/update/new/adm/style/installer_header.html b/install/update/new/adm/style/installer_header.html deleted file mode 100644 index 704db9e..0000000 --- a/install/update/new/adm/style/installer_header.html +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - {META} - {PAGE_TITLE} - - - - - -
- - -
-
- -
- -
-
- - -
-
diff --git a/install/update/new/adm/style/installer_install.html b/install/update/new/adm/style/installer_install.html deleted file mode 100644 index 53a91f2..0000000 --- a/install/update/new/adm/style/installer_install.html +++ /dev/null @@ -1,13 +0,0 @@ - -

{TITLE}

-

{CONTENT}

- -
-
- {L_SUBMIT} - -
-
- - - diff --git a/install/update/new/adm/style/installer_main.html b/install/update/new/adm/style/installer_main.html deleted file mode 100644 index f14fe4d..0000000 --- a/install/update/new/adm/style/installer_main.html +++ /dev/null @@ -1,6 +0,0 @@ - - -

{TITLE}

-

{BODY}

- - diff --git a/install/update/new/adm/style/installer_update.html b/install/update/new/adm/style/installer_update.html deleted file mode 100644 index 48cc07f..0000000 --- a/install/update/new/adm/style/installer_update.html +++ /dev/null @@ -1,13 +0,0 @@ - -

{TITLE}

-

{CONTENT}

- -
-
- {L_SUBMIT} - -
-
- - - diff --git a/install/update/new/adm/style/installer_update_file_status.html b/install/update/new/adm/style/installer_update_file_status.html deleted file mode 100644 index a27bfa6..0000000 --- a/install/update/new/adm/style/installer_update_file_status.html +++ /dev/null @@ -1,80 +0,0 @@ - -

{L_FILES_DELETED}

- -

{L_FILES_DELETED_EXPLAIN}

- -
- {L_STATUS_DELETED} - -
-
{deleted.DIR_PART}{deleted.FILE_PART}
-
- -
- - - - -

{L_FILES_CONFLICT}

- -

{L_FILES_CONFLICT_EXPLAIN}

- -
- {L_STATUS_CONFLICT} - -
-
{conflict.DIR_PART}{conflict.FILE_PART}
-
- -
- - - - -

{L_FILES_MODIFIED}

- -

{L_FILES_MODIFIED_EXPLAIN}

- -
- {L_STATUS_MODIFIED} - -
-
{modified.DIR_PART}{modified.FILE_PART}
-
- -
- - - - -

{L_FILES_NEW}

- -

{L_FILES_NEW_EXPLAIN}

- - - - - - -

{L_FILES_NOT_MODIFIED}

- -

{L_FILES_NOT_MODIFIED_EXPLAIN}

- - - - diff --git a/install/update/new/adm/style/overall_footer.html b/install/update/new/adm/style/overall_footer.html deleted file mode 100644 index 7a5b620..0000000 --- a/install/update/new/adm/style/overall_footer.html +++ /dev/null @@ -1,46 +0,0 @@ -
-
-
-
-
- - -
- - - - - - - - -{$SCRIPTS} - - - diff --git a/install/update/new/adm/style/overall_header.html b/install/update/new/adm/style/overall_header.html deleted file mode 100644 index fa361d6..0000000 --- a/install/update/new/adm/style/overall_header.html +++ /dev/null @@ -1,157 +0,0 @@ - - - - - - -{META} -{PAGE_TITLE} - - - - - - - - -{$STYLESHEETS} - - - - - - - - - -
- - -
-
- -
- -
-
- - - -
- -
-
- {% if CONTAINER_EXCEPTION !== false %} -
-

{{ lang('CONTAINER_EXCEPTION') }}


-

{{ lang('EXCEPTION') }}{{ lang('COLON') }} {{ CONTAINER_EXCEPTION.getMessage() }}

-
{{ CONTAINER_EXCEPTION.getTraceAsString() }}
-
- {% endif %} diff --git a/install/update/new/adm/style/permission_forum_copy.html b/install/update/new/adm/style/permission_forum_copy.html deleted file mode 100644 index 0560648..0000000 --- a/install/update/new/adm/style/permission_forum_copy.html +++ /dev/null @@ -1,40 +0,0 @@ - - - - -

{L_ACP_FORUM_PERMISSIONS_COPY}

- -

{L_ACP_FORUM_PERMISSIONS_COPY_EXPLAIN}

- -
- -
- {L_LOOK_UP_FORUM} - -
-

{L_COPY_PERMISSIONS_FORUM_FROM_EXPLAIN}
-
-
-
- -
- {L_LOOK_UP_FORUM} -

{L_LOOK_UP_FORUMS_EXPLAIN}

- -
-

{L_COPY_PERMISSIONS_FORUM_TO_EXPLAIN}
-
-
-
- -
- {L_SUBMIT} -   - - {S_HIDDEN_FIELDS} - {S_FORM_TOKEN} -
- -
- - diff --git a/install/update/new/adm/style/permission_mask.html b/install/update/new/adm/style/permission_mask.html deleted file mode 100644 index 26aa5e0..0000000 --- a/install/update/new/adm/style/permission_mask.html +++ /dev/null @@ -1,152 +0,0 @@ - - - - - -
-

{p_mask.NAME} [{p_mask.L_ACL_TYPE}]

- - -
-
- - - - - - {p_mask.f_mask.PADDING}{p_mask.f_mask.PADDING}{p_mask.f_mask.NAME} - - - -
-
- {% if p_mask.f_mask.role_options %} -
- -
- {% else %} -
{L_NO_ROLE_AVAILABLE}
- {% endif %} -
- - - - - -
- - - diff --git a/install/update/new/adm/style/permissions.js b/install/update/new/adm/style/permissions.js deleted file mode 100644 index af8e21a..0000000 --- a/install/update/new/adm/style/permissions.js +++ /dev/null @@ -1,304 +0,0 @@ -/** -* Hide and show all checkboxes -* status = true (show boxes), false (hide boxes) -*/ -function display_checkboxes(status) { - var form = document.getElementById('set-permissions'); - var cb = document.getElementsByTagName('input'); - var display; - - //show - if (status) { - display = 'inline'; - } - //hide - else { - display = 'none'; - } - - for (var i = 0; i < cb.length; i++ ) { - if (cb[i].className === 'permissions-checkbox') { - cb[i].style.display = display; - } - } -} - -/** -* Change opacity of element -* e = element -* value = 0 (hidden) till 10 (fully visible) -*/ -function set_opacity(e, value) { - e.style.opacity = value/10; - - //IE opacity currently turned off, because of its astronomical stupidity - //e.style.filter = 'alpha(opacity=' + value*10 + ')'; -} - -/** -* Reset the opacity and checkboxes -* block_id = id of the element that needs to be toggled -*/ -function toggle_opacity(block_id) { - var cb = document.getElementById('checkbox' + block_id); - var fs = document.getElementById('perm' + block_id); - - if (cb.checked) { - set_opacity(fs, 5); - } else { - set_opacity(fs, 10); - } -} - -/** -* Reset the opacity and checkboxes -* value = 0 (checked) and 1 (unchecked) -* except_id = id of the element not to hide -*/ -function reset_opacity(status, except_id) { - var perm = document.getElementById('set-permissions'); - var fs = perm.getElementsByTagName('fieldset'); - var opacity = 5; - - if (status) { - opacity = 10; - } - - for (var i = 0; i < fs.length; i++ ) { - if (fs[i].className !== 'quick') { - set_opacity(fs[i], opacity); - } - } - - if (typeof(except_id) !== 'undefined') { - set_opacity(document.getElementById('perm' + except_id), 10); - } - - //reset checkboxes too - marklist('set-permissions', 'inherit', !status); -} - -/** -* Check whether we have a full radiobutton row of true -* index = offset for the row of inputs (0 == first row, 1 == second, 2 == third), -* rb = array of radiobuttons -*/ -function get_radio_status(index, rb) { - for (var i = index; i < rb.length; i = i + 3 ) { - if (rb[i].checked !== true) { - if (i > index) { - //at least one is true, but not all (custom) - return 2; - } - //first one is not true - return 0; - } - } - - // all radiobuttons true - return 1; -} - -/** -* Set tab colours -* id = panel the tab needs to be set for, -* init = initialising on open, -* quick = If no calculation needed, this contains the colour -*/ -function set_colours(id, init, quick) { - var table = document.getElementById('table' + id); - var tab = document.getElementById('tab' + id); - - if (typeof(quick) !== 'undefined') { - tab.className = 'permissions-preset-' + quick + ' activetab'; - return; - } - - var rb = table.getElementsByTagName('input'); - var colour = 'custom'; - - var status = get_radio_status(0, rb); - - if (status === 1) { - colour = 'yes'; - } else if (status === 0) { - // We move on to No - status = get_radio_status(1, rb); - - if (status === 1) { - colour = 'no'; - } else if (status === 0) { - // We move on to Never - status = get_radio_status(2, rb); - - if (status === 1) { - colour = 'never'; - } - } - } - - if (init) { - tab.className = 'permissions-preset-' + colour; - } else { - tab.className = 'permissions-preset-' + colour + ' activetab'; - } -} - -/** -* Initialise advanced tab colours on first load -* block_id = block that is opened -*/ -function init_colours(block_id) { - var block = document.getElementById('advanced' + block_id); - var panels = block.getElementsByTagName('div'); - var tab = document.getElementById('tab' + id); - - for (var i = 0; i < panels.length; i++) { - if (panels[i].className === 'permissions-panel') { - set_colours(panels[i].id.replace(/options/, ''), true); - } - } - - tab.className = tab.className + ' activetab'; -} - -/** -* Show/hide option panels -* value = suffix for ID to show -* adv = we are opening advanced permissions -* view = called from view permissions -*/ -function swap_options(pmask, fmask, cat, adv, view) { - id = pmask + fmask + cat; - active_option = active_pmask + active_fmask + active_cat; - - var old_tab = document.getElementById('tab' + active_option); - var new_tab = document.getElementById('tab' + id); - var adv_block = document.getElementById('advanced' + pmask + fmask); - - if (adv_block.style.display === 'block' && adv === true) { - phpbb.toggleDisplay('advanced' + pmask + fmask, -1); - reset_opacity(1); - display_checkboxes(false); - return; - } - - // no need to set anything if we are clicking on the same tab again - if (new_tab === old_tab && !adv) { - return; - } - - // init colours - if (adv && (pmask + fmask) !== (active_pmask + active_fmask)) { - init_colours(pmask + fmask); - display_checkboxes(true); - reset_opacity(1); - } else if (adv) { - //Checkbox might have been clicked, but we need full visibility - display_checkboxes(true); - reset_opacity(1); - } - - // set active tab - old_tab.className = old_tab.className.replace(/\ activetab/g, ''); - new_tab.className = new_tab.className + ' activetab'; - - if (id === active_option && adv !== true) { - return; - } - - phpbb.toggleDisplay('options' + active_option, -1); - - //hiding and showing the checkbox - if (document.getElementById('checkbox' + active_pmask + active_fmask)) { - phpbb.toggleDisplay('checkbox' + pmask + fmask, -1); - - if ((pmask + fmask) !== (active_pmask + active_fmask)) { - document.getElementById('checkbox' + active_pmask + active_fmask).style.display = 'inline'; - } - } - - if (!view) { - phpbb.toggleDisplay('advanced' + active_pmask + active_fmask, -1); - } - - if (!view) { - phpbb.toggleDisplay('advanced' + pmask + fmask, 1); - } - phpbb.toggleDisplay('options' + id, 1); - - active_pmask = pmask; - active_fmask = fmask; - active_cat = cat; -} - -/** -* Mark all radio buttons in one panel -* id = table ID container, s = status ['y'/'u'/'n'] -*/ -function mark_options(id, s) { - var t = document.getElementById(id); - - if (!t) { - return; - } - - var rb = t.getElementsByTagName('input'); - - for (var r = 0; r < rb.length; r++) { - if (rb[r].id.substr(rb[r].id.length-1) === s) { - rb[r].checked = true; - } - } -} - -function mark_one_option(id, field_name, s) { - var t = document.getElementById(id); - - if (!t) { - return; - } - - var rb = t.getElementsByTagName('input'); - - for (var r = 0; r < rb.length; r++) { - if (rb[r].id.substr(rb[r].id.length-field_name.length-3, field_name.length) === field_name && rb[r].id.substr(rb[r].id.length-1) === s) { - rb[r].checked = true; - } - } -} - -/** -* Reset role dropdown field to Select role... if an option gets changed -*/ -function reset_role(id) { - var t = document.getElementById(id); - - if (!t) { - return; - } - - t.options[0].selected = true; - - var parent = t.parentNode; - parent.querySelector('span.dropdown-trigger').innerText = no_role_assigned; - parent.querySelector('input[data-name^=role]').value = '0'; -} - -/** -* Load role and set options accordingly -*/ -function set_role_settings(role_id, target_id) { - settings = role_options[role_id]; - - if (!settings) { - return; - } - - // Mark all options to no (unset) first... - mark_options(target_id, 'u'); - - for (var r in settings) { - mark_one_option(target_id, r, (settings[r] === 1) ? 'y' : 'n'); - } -} diff --git a/install/update/new/adm/style/progress_bar.html b/install/update/new/adm/style/progress_bar.html deleted file mode 100644 index 1e58257..0000000 --- a/install/update/new/adm/style/progress_bar.html +++ /dev/null @@ -1,40 +0,0 @@ - - - - -
-

{L_PROGRESS}

- {L_PROGRESS} -

{L_PROGRESS_EXPLAIN}

-
- - - - diff --git a/install/update/new/adm/style/simple_footer.html b/install/update/new/adm/style/simple_footer.html deleted file mode 100644 index dd9dc90..0000000 --- a/install/update/new/adm/style/simple_footer.html +++ /dev/null @@ -1,27 +0,0 @@ - -

-
- - - - - - - - -{$SCRIPTS} - - - diff --git a/install/update/new/adm/style/simple_header.html b/install/update/new/adm/style/simple_header.html deleted file mode 100644 index a8a32bf..0000000 --- a/install/update/new/adm/style/simple_header.html +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - -{META} -{PAGE_TITLE} - - - - - -{$STYLESHEETS} - - - - - - - -
diff --git a/install/update/new/assets/cookieconsent/cookieconsent.min.css b/install/update/new/assets/cookieconsent/cookieconsent.min.css deleted file mode 100644 index d4d4390..0000000 --- a/install/update/new/assets/cookieconsent/cookieconsent.min.css +++ /dev/null @@ -1,6 +0,0 @@ -.cc-window{opacity:1;-webkit-transition:opacity 1s ease;transition:opacity 1s ease}.cc-window.cc-invisible{opacity:0}.cc-animate.cc-revoke{-webkit-transition:transform 1s ease;-webkit-transition:-webkit-transform 1s ease;transition:-webkit-transform 1s ease;transition:transform 1s ease;transition:transform 1s ease,-webkit-transform 1s ease}.cc-animate.cc-revoke.cc-top{-webkit-transform:translateY(-2em);transform:translateY(-2em)}.cc-animate.cc-revoke.cc-bottom{-webkit-transform:translateY(2em);transform:translateY(2em)}.cc-animate.cc-revoke.cc-active.cc-top{-webkit-transform:translateY(0);transform:translateY(0)}.cc-animate.cc-revoke.cc-active.cc-bottom{-webkit-transform:translateY(0);transform:translateY(0)}.cc-revoke:hover{-webkit-transform:translateY(0);transform:translateY(0)}.cc-grower{max-height:0;overflow:hidden;-webkit-transition:max-height 1s;transition:max-height 1s} -.cc-revoke,.cc-window{position:fixed;overflow:hidden;-webkit-box-sizing:border-box;box-sizing:border-box;font-family:Helvetica,Calibri,Arial,sans-serif;font-size:16px;line-height:1.5em;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:nowrap;flex-wrap:nowrap;z-index:9999}.cc-window.cc-static{position:static}.cc-window.cc-floating{padding:2em;max-width:24em;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column}.cc-window.cc-banner{padding:1em 1.8em;width:100%;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row}.cc-revoke{padding:.5em}.cc-revoke:hover{text-decoration:underline}.cc-header{font-size:18px;font-weight:700}.cc-btn,.cc-close,.cc-link,.cc-revoke{cursor:pointer}.cc-link{opacity:.8;display:inline-block;padding:.2em;text-decoration:underline}.cc-link:hover{opacity:1}.cc-link:active,.cc-link:visited{color:initial}.cc-btn{display:block;padding:.4em .8em;font-size:.9em;font-weight:700;border-width:2px;border-style:solid;text-align:center;white-space:nowrap}.cc-highlight .cc-btn:first-child{background-color:transparent;border-color:transparent}.cc-highlight .cc-btn:first-child:focus,.cc-highlight .cc-btn:first-child:hover{background-color:transparent;text-decoration:underline}.cc-close{display:block;position:absolute;top:.5em;right:.5em;font-size:1.6em;opacity:.9;line-height:.75}.cc-close:focus,.cc-close:hover{opacity:1} -.cc-revoke.cc-top{top:0;left:3em;border-bottom-left-radius:.5em;border-bottom-right-radius:.5em}.cc-revoke.cc-bottom{bottom:0;left:3em;border-top-left-radius:.5em;border-top-right-radius:.5em}.cc-revoke.cc-left{left:3em;right:unset}.cc-revoke.cc-right{right:3em;left:unset}.cc-top{top:1em}.cc-left{left:1em}.cc-right{right:1em}.cc-bottom{bottom:1em}.cc-floating>.cc-link{margin-bottom:1em}.cc-floating .cc-message{display:block;margin-bottom:1em}.cc-window.cc-floating .cc-compliance{-webkit-box-flex:1;-ms-flex:1 0 auto;flex:1 0 auto}.cc-window.cc-banner{-webkit-box-align:center;-ms-flex-align:center;align-items:center}.cc-banner.cc-top{left:0;right:0;top:0}.cc-banner.cc-bottom{left:0;right:0;bottom:0}.cc-banner .cc-message{display:block;-webkit-box-flex:1;-ms-flex:1 1 auto;flex:1 1 auto;max-width:100%;margin-right:1em}.cc-compliance{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-ms-flex-line-pack:justify;align-content:space-between}.cc-floating .cc-compliance>.cc-btn{-webkit-box-flex:1;-ms-flex:1;flex:1}.cc-btn+.cc-btn{margin-left:.5em} -@media print{.cc-revoke,.cc-window{display:none}}@media screen and (max-width:900px){.cc-btn{white-space:normal}}@media screen and (max-width:414px) and (orientation:portrait),screen and (max-width:736px) and (orientation:landscape){.cc-window.cc-top{top:0}.cc-window.cc-bottom{bottom:0}.cc-window.cc-banner,.cc-window.cc-floating,.cc-window.cc-left,.cc-window.cc-right{left:0;right:0}.cc-window.cc-banner{-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column}.cc-window.cc-banner .cc-compliance{-webkit-box-flex:1;-ms-flex:1 1 auto;flex:1 1 auto}.cc-window.cc-floating{max-width:none}.cc-window .cc-message{margin-bottom:1em}.cc-window.cc-banner{-webkit-box-align:unset;-ms-flex-align:unset;align-items:unset}.cc-window.cc-banner .cc-message{margin-right:0}} -.cc-floating.cc-theme-classic{padding:1.2em;border-radius:5px}.cc-floating.cc-type-info.cc-theme-classic .cc-compliance{text-align:center;display:inline;-webkit-box-flex:0;-ms-flex:none;flex:none}.cc-theme-classic .cc-btn{border-radius:5px}.cc-theme-classic .cc-btn:last-child{min-width:140px}.cc-floating.cc-type-info.cc-theme-classic .cc-btn{display:inline-block} -.cc-theme-edgeless.cc-window{padding:0}.cc-floating.cc-theme-edgeless .cc-message{margin:2em;margin-bottom:1.5em}.cc-banner.cc-theme-edgeless .cc-btn{margin:0;padding:.8em 1.8em;height:100%}.cc-banner.cc-theme-edgeless .cc-message{margin-left:1em}.cc-floating.cc-theme-edgeless .cc-btn+.cc-btn{margin-left:0} \ No newline at end of file diff --git a/install/update/new/assets/cookieconsent/cookieconsent.min.js b/install/update/new/assets/cookieconsent/cookieconsent.min.js deleted file mode 100644 index 1e3dccf..0000000 --- a/install/update/new/assets/cookieconsent/cookieconsent.min.js +++ /dev/null @@ -1 +0,0 @@ -!function(e){if(!e.hasInitialised){var t={escapeRegExp:function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},hasClass:function(e,t){var i=" ";return 1===e.nodeType&&(i+e.className+i).replace(/[\n\t]/g,i).indexOf(i+t+i)>=0},addClass:function(e,t){e.className+=" "+t},removeClass:function(e,t){var i=new RegExp("\\b"+this.escapeRegExp(t)+"\\b");e.className=e.className.replace(i,"")},interpolateString:function(e,t){return e.replace(/{{([a-z][a-z0-9\-_]*)}}/gi,function(e){return t(arguments[1])||""})},getCookie:function(e){var t=("; "+document.cookie).split("; "+e+"=");return t.length<2?void 0:t.pop().split(";").shift()},setCookie:function(e,t,i,n,o,s){var r=new Date;r.setHours(r.getHours()+24*(i||365));var a=[e+"="+t,"expires="+r.toUTCString(),"path="+(o||"/")];n&&a.push("domain="+n),s&&a.push("secure"),document.cookie=a.join(";")},deepExtend:function(e,t){for(var i in t)t.hasOwnProperty(i)&&(i in e&&this.isPlainObject(e[i])&&this.isPlainObject(t[i])?this.deepExtend(e[i],t[i]):e[i]=t[i]);return e},throttle:function(e,t){var i=!1;return function(){i||(e.apply(this,arguments),i=!0,setTimeout(function(){i=!1},t))}},hash:function(e){var t,i,n=0;if(0===e.length)return n;for(t=0,i=e.length;t=128?"#000":"#fff"},getLuminance:function(e){var t=parseInt(this.normaliseHex(e),16),i=38+(t>>16),n=38+(t>>8&255),o=38+(255&t);return"#"+(16777216+65536*(i<255?i<1?0:i:255)+256*(n<255?n<1?0:n:255)+(o<255?o<1?0:o:255)).toString(16).slice(1)},isMobile:function(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)},isPlainObject:function(e){return"object"==typeof e&&null!==e&&e.constructor==Object},traverseDOMPath:function(e,i){return e&&e.parentNode?t.hasClass(e,i)?e:this.traverseDOMPath(e.parentNode,i):null}};e.status={deny:"deny",allow:"allow",dismiss:"dismiss"},e.transitionEnd=function(){var e=document.createElement("div"),t={t:"transitionend",OT:"oTransitionEnd",msT:"MSTransitionEnd",MozT:"transitionend",WebkitT:"webkitTransitionEnd"};for(var i in t)if(t.hasOwnProperty(i)&&void 0!==e.style[i+"ransition"])return t[i];return""}(),e.hasTransition=!!e.transitionEnd;var i=Object.keys(e.status).map(t.escapeRegExp);e.customStyles={},e.Popup=function(){var n={enabled:!0,container:null,cookie:{name:"cookieconsent_status",path:"/",domain:"",expiryDays:365,secure:!1},onPopupOpen:function(){},onPopupClose:function(){},onInitialise:function(e){},onStatusChange:function(e,t){},onRevokeChoice:function(){},onNoCookieLaw:function(e,t){},content:{header:"Cookies used on the website!",message:"This website uses cookies to ensure you get the best experience on our website.",dismiss:"Got it!",allow:"Allow cookies",deny:"Decline",link:"Learn more",href:"https://www.cookiesandyou.com",close:"❌",target:"_blank",policy:"Cookie Policy"},elements:{header:'{{header}} ',message:'{{message}}',messagelink:'{{message}} {{link}}',dismiss:'{{dismiss}}',allow:'{{allow}}',deny:'{{deny}}',link:'{{link}}',close:'{{close}}'},window:'',revokeBtn:'
{{policy}}
',compliance:{info:'
{{dismiss}}
',"opt-in":'
{{deny}}{{allow}}
',"opt-out":'
{{deny}}{{allow}}
'},type:"info",layouts:{basic:"{{messagelink}}{{compliance}}","basic-close":"{{messagelink}}{{compliance}}{{close}}","basic-header":"{{header}}{{message}}{{link}}{{compliance}}"},layout:"basic",position:"bottom",theme:"block",static:!1,palette:null,revokable:!1,animateRevokable:!0,showLink:!0,dismissOnScroll:!1,dismissOnTimeout:!1,dismissOnWindowClick:!1,ignoreClicksFrom:["cc-revoke","cc-btn"],autoOpen:!0,autoAttach:!0,whitelistPage:[],blacklistPage:[],overrideHTML:null};function o(){this.initialise.apply(this,arguments)}function s(e){this.openingTimeout=null,t.removeClass(e,"cc-invisible")}function r(t){t.style.display="none",t.removeEventListener(e.transitionEnd,this.afterTransition),this.afterTransition=null}function a(){var e=this.options.position.split("-"),t=[];return e.forEach(function(e){t.push("cc-"+e)}),t}function c(n){var o=this.options,s=document.createElement("div"),r=o.container&&1===o.container.nodeType?o.container:document.body;s.innerHTML=n;var a=s.children[0];return a.style.display="none",t.hasClass(a,"cc-window")&&e.hasTransition&&t.addClass(a,"cc-invisible"),this.onButtonClick=function(n){var o=t.traverseDOMPath(n.target,"cc-btn")||n.target;if(t.hasClass(o,"cc-btn")){var s=o.className.match(new RegExp("\\bcc-("+i.join("|")+")\\b")),r=s&&s[1]||!1;r&&(this.setStatus(r),this.close(!0))}t.hasClass(o,"cc-close")&&(this.setStatus(e.status.dismiss),this.close(!0));t.hasClass(o,"cc-revoke")&&this.revokeChoice()}.bind(this),a.addEventListener("click",this.onButtonClick),o.autoAttach&&(r.firstChild?r.insertBefore(a,r.firstChild):r.appendChild(a)),a}function l(e){return"000000"==(e=t.normaliseHex(e))?"#222":t.getLuminance(e)}function u(e,t){for(var i=0,n=e.length;i=0;o&&t(n);return o}.call(this)&&(this.options.enabled=!1),u(this.options.blacklistPage,location.pathname)&&(this.options.enabled=!1),u(this.options.whitelistPage,location.pathname)&&(this.options.enabled=!0);var o=this.options.window.replace("{{classes}}",function(){var i=this.options,n="top"==i.position||"bottom"==i.position?"banner":"floating";t.isMobile()&&(n="floating");var o=["cc-"+n,"cc-type-"+i.type,"cc-theme-"+i.theme];i.static&&o.push("cc-static");o.push.apply(o,a.call(this));(function(i){var n=t.hash(JSON.stringify(i)),o="cc-color-override-"+n,s=t.isPlainObject(i);this.customStyleSelector=s?o:null,s&&function(i,n,o){if(e.customStyles[i])return void++e.customStyles[i].references;var s={},r=n.popup,a=n.button,c=n.highlight;r&&(r.text=r.text?r.text:t.getContrast(r.background),r.link=r.link?r.link:r.text,s[o+".cc-window"]=["color: "+r.text,"background-color: "+r.background],s[o+".cc-revoke"]=["color: "+r.text,"background-color: "+r.background],s[o+" .cc-link,"+o+" .cc-link:active,"+o+" .cc-link:visited"]=["color: "+r.link],a&&(a.text=a.text?a.text:t.getContrast(a.background),a.border=a.border?a.border:"transparent",s[o+" .cc-btn"]=["color: "+a.text,"border-color: "+a.border,"background-color: "+a.background],a.padding&&s[o+" .cc-btn"].push("padding: "+a.padding),"transparent"!=a.background&&(s[o+" .cc-btn:hover, "+o+" .cc-btn:focus"]=["background-color: "+(a.hover||l(a.background))]),c?(c.text=c.text?c.text:t.getContrast(c.background),c.border=c.border?c.border:"transparent",s[o+" .cc-highlight .cc-btn:first-child"]=["color: "+c.text,"border-color: "+c.border,"background-color: "+c.background]):s[o+" .cc-highlight .cc-btn:first-child"]=["color: "+r.text]));var u=document.createElement("style");document.head.appendChild(u),e.customStyles[i]={references:1,element:u.sheet};var h=-1;for(var p in s)s.hasOwnProperty(p)&&u.sheet.insertRule(p+"{"+s[p].join(";")+"}",++h)}(n,i,"."+o);return s}).call(this,this.options.palette);this.customStyleSelector&&o.push(this.customStyleSelector);return o}.call(this).join(" ")).replace("{{children}}",function(){var e={},i=this.options;i.showLink||(i.elements.link="",i.elements.messagelink=i.elements.message);Object.keys(i.elements).forEach(function(n){e[n]=t.interpolateString(i.elements[n],function(e){var t=i.content[e];return e&&"string"==typeof t&&t.length?t:""})});var n=i.compliance[i.type];n||(n=i.compliance.info);e.compliance=t.interpolateString(n,function(t){return e[t]});var o=i.layouts[i.layout];o||(o=i.layouts.basic);return t.interpolateString(o,function(t){return e[t]})}.call(this)),s=this.options.overrideHTML;if("string"==typeof s&&s.length&&(o=s),this.options.static){var r=c.call(this,'
'+o+"
");r.style.display="",this.element=r.firstChild,this.element.style.display="none",t.addClass(this.element,"cc-invisible")}else this.element=c.call(this,o);(function(){var i=this.setStatus.bind(this),n=this.close.bind(this),o=this.options.dismissOnTimeout;"number"==typeof o&&o>=0&&(this.dismissTimeout=window.setTimeout(function(){i(e.status.dismiss),n(!0)},Math.floor(o)));var s=this.options.dismissOnScroll;if("number"==typeof s&&s>=0){var r=function(t){window.pageYOffset>Math.floor(s)&&(i(e.status.dismiss),n(!0),window.removeEventListener("scroll",r),this.onWindowScroll=null)};this.options.enabled&&(this.onWindowScroll=r,window.addEventListener("scroll",r))}var a=this.options.dismissOnWindowClick,c=this.options.ignoreClicksFrom;if(a){var l=function(o){for(var s=!1,r=o.path.length,a=c.length,u=0;uo&&(i=!0),i?t.hasClass(n,"cc-active")||t.addClass(n,"cc-active"):t.hasClass(n,"cc-active")&&t.removeClass(n,"cc-active")},200);this.onMouseMove=o,window.addEventListener("mousemove",o)}}}.call(this),this.options.autoOpen&&this.autoOpen()},o.prototype.destroy=function(){this.onButtonClick&&this.element&&(this.element.removeEventListener("click",this.onButtonClick),this.onButtonClick=null),this.dismissTimeout&&(clearTimeout(this.dismissTimeout),this.dismissTimeout=null),this.onWindowScroll&&(window.removeEventListener("scroll",this.onWindowScroll),this.onWindowScroll=null),this.onWindowClick&&(window.removeEventListener("click",this.onWindowClick),this.onWindowClick=null),this.onMouseMove&&(window.removeEventListener("mousemove",this.onMouseMove),this.onMouseMove=null),this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.element=null,this.revokeBtn&&this.revokeBtn.parentNode&&this.revokeBtn.parentNode.removeChild(this.revokeBtn),this.revokeBtn=null,function(i){if(t.isPlainObject(i)){var n=t.hash(JSON.stringify(i)),o=e.customStyles[n];if(o&&!--o.references){var s=o.element.ownerNode;s&&s.parentNode&&s.parentNode.removeChild(s),e.customStyles[n]=null}}}(this.options.palette),this.options=null},o.prototype.open=function(t){if(this.element)return this.isOpen()||(e.hasTransition?this.fadeIn():this.element.style.display="",this.options.revokable&&this.toggleRevokeButton(),this.options.onPopupOpen.call(this)),this},o.prototype.close=function(t){if(this.element)return this.isOpen()&&(e.hasTransition?this.fadeOut():this.element.style.display="none",t&&this.options.revokable&&this.toggleRevokeButton(!0),this.options.onPopupClose.call(this)),this},o.prototype.fadeIn=function(){var i=this.element;if(e.hasTransition&&i&&(this.afterTransition&&r.call(this,i),t.hasClass(i,"cc-invisible"))){if(i.style.display="",this.options.static){var n=this.element.clientHeight;this.element.parentNode.style.maxHeight=n+"px"}this.openingTimeout=setTimeout(s.bind(this,i),20)}},o.prototype.fadeOut=function(){var i=this.element;e.hasTransition&&i&&(this.openingTimeout&&(clearTimeout(this.openingTimeout),s.bind(this,i)),t.hasClass(i,"cc-invisible")||(this.options.static&&(this.element.parentNode.style.maxHeight=""),this.afterTransition=r.bind(this,i),i.addEventListener(e.transitionEnd,this.afterTransition),t.addClass(i,"cc-invisible")))},o.prototype.isOpen=function(){return this.element&&""==this.element.style.display&&(!e.hasTransition||!t.hasClass(this.element,"cc-invisible"))},o.prototype.toggleRevokeButton=function(e){this.revokeBtn&&(this.revokeBtn.style.display=e?"":"none")},o.prototype.revokeChoice=function(e){this.options.enabled=!0,this.clearStatus(),this.options.onRevokeChoice.call(this),e||this.autoOpen()},o.prototype.hasAnswered=function(t){return Object.keys(e.status).indexOf(this.getStatus())>=0},o.prototype.hasConsented=function(t){var i=this.getStatus();return i==e.status.allow||i==e.status.dismiss},o.prototype.autoOpen=function(e){!this.hasAnswered()&&this.options.enabled?this.open():this.hasAnswered()&&this.options.revokable&&this.toggleRevokeButton(!0)},o.prototype.setStatus=function(i){var n=this.options.cookie,o=t.getCookie(n.name),s=Object.keys(e.status).indexOf(o)>=0;Object.keys(e.status).indexOf(i)>=0?(t.setCookie(n.name,i,n.expiryDays,n.domain,n.path,n.secure),this.options.onStatusChange.call(this,i,s)):this.clearStatus()},o.prototype.getStatus=function(){return t.getCookie(this.options.cookie.name)},o.prototype.clearStatus=function(){var e=this.options.cookie;t.setCookie(e.name,"",-1,e.domain,e.path)},o}(),e.Location=function(){var e={timeout:5e3,services:["ipinfo"],serviceDefinitions:{ipinfo:function(){return{url:"//ipinfo.io",headers:["Accept: application/json"],callback:function(e,t){try{var i=JSON.parse(t);return i.error?s(i):{code:i.country}}catch(e){return s({error:"Invalid response ("+e+")"})}}}},ipinfodb:function(e){return{url:"//api.ipinfodb.com/v3/ip-country/?key={api_key}&format=json&callback={callback}",isScript:!0,callback:function(e,t){try{var i=JSON.parse(t);return"ERROR"==i.statusCode?s({error:i.statusMessage}):{code:i.countryCode}}catch(e){return s({error:"Invalid response ("+e+")"})}}}},maxmind:function(){return{url:"//js.maxmind.com/js/apis/geoip2/v2.1/geoip2.js",isScript:!0,callback:function(e){window.geoip2?geoip2.country(function(t){try{e({code:t.country.iso_code})}catch(t){e(s(t))}},function(t){e(s(t))}):e(new Error("Unexpected response format. The downloaded script should have exported `geoip2` to the global scope"))}}}}};function i(i){t.deepExtend(this.options={},e),t.isPlainObject(i)&&t.deepExtend(this.options,i),this.currentServiceIndex=-1}function n(e,t,i){var n,o=document.createElement("script");o.type="text/"+(e.type||"javascript"),o.src=e.src||e,o.async=!1,o.onreadystatechange=o.onload=function(){var e=o.readyState;clearTimeout(n),t.done||e&&!/loaded|complete/.test(e)||(t.done=!0,t(),o.onreadystatechange=o.onload=null)},document.body.appendChild(o),n=setTimeout(function(){t.done=!0,t(),o.onreadystatechange=o.onload=null},i)}function o(e,t,i,n,o){var s=new(window.XMLHttpRequest||window.ActiveXObject)("MSXML2.XMLHTTP.3.0");if(s.open(n?"POST":"GET",e,1),s.setRequestHeader("Content-type","application/x-www-form-urlencoded"),Array.isArray(o))for(var r=0,a=o.length;r3&&t(s)}),s.send(n)}function s(e){return new Error("Error ["+(e.code||"UNKNOWN")+"]: "+e.error)}return i.prototype.getNextService=function(){var e;do{e=this.getServiceByIdx(++this.currentServiceIndex)}while(this.currentServiceIndex=0,revokable:t.revokable.indexOf(e)>=0,explicitAction:t.explicitAction.indexOf(e)>=0}},i.prototype.applyLaw=function(e,t){var i=this.get(t);return i.hasLaw||(e.enabled=!1,"function"==typeof e.onNoCookieLaw&&e.onNoCookieLaw(t,i)),this.options.regionalLaw&&(i.revokable&&(e.revokable=!0),i.explicitAction&&(e.dismissOnScroll=!1,e.dismissOnTimeout=!1)),e},i}(),e.initialise=function(i,n,o){var s=new e.Law(i.law);n||(n=function(){}),o||(o=function(){});var r=Object.keys(e.status),a=t.getCookie("cookieconsent_status");r.indexOf(a)>=0?n(new e.Popup(i)):e.getCountryCode(i,function(t){delete i.law,delete i.location,t.code&&(i=s.applyLaw(i,t.code)),n(new e.Popup(i))},function(t){delete i.law,delete i.location,o(t,new e.Popup(i))})},e.getCountryCode=function(t,i,n){t.law&&t.law.countryCode?i({code:t.law.countryCode}):t.location?new e.Location(t.location).locate(function(e){i(e||{})},n):i({})},e.utils=t,e.hasInitialised=!0,window.cookieconsent=e}}(window.cookieconsent||{}); \ No newline at end of file diff --git a/install/update/new/assets/javascript/core.js b/install/update/new/assets/javascript/core.js deleted file mode 100644 index bedbd23..0000000 --- a/install/update/new/assets/javascript/core.js +++ /dev/null @@ -1,1823 +0,0 @@ -/* global bbfontstyle */ - -var phpbb = {}; -phpbb.alertTime = 100; - -(function($) { // Avoid conflicts with other libraries - -'use strict'; - -// define a couple constants for keydown functions. -var keymap = { - TAB: 9, - ENTER: 13, - ESC: 27, - ARROW_UP: 38, - ARROW_DOWN: 40 -}; - -var $dark = $('#darkenwrapper'); -var $loadingIndicator; -var phpbbAlertTimer = null; - -phpbb.isTouch = (window && typeof window.ontouchstart !== 'undefined'); - -// Add ajax pre-filter to prevent cross-domain script execution -$.ajaxPrefilter(function(s) { - if (s.crossDomain) { - s.contents.script = false; - } -}); - -/** - * Display a loading screen - * - * @returns {object} Returns loadingIndicator. - */ -phpbb.loadingIndicator = function() { - if (!$loadingIndicator) { - $loadingIndicator = $('
', { - 'id': 'loading_indicator', - 'class': 'loading_indicator' - }); - $loadingIndicator.appendTo('#page-footer'); - } - - if (!$loadingIndicator.is(':visible')) { - $loadingIndicator.fadeIn(phpbb.alertTime); - // Wait 60 seconds and display an error if nothing has been returned by then. - phpbb.clearLoadingTimeout(); - phpbbAlertTimer = setTimeout(function() { - phpbb.showTimeoutMessage(); - }, 60000); - } - - return $loadingIndicator; -}; - -/** - * Show timeout message - */ -phpbb.showTimeoutMessage = function () { - var $alert = $('#phpbb_alert'); - - if ($loadingIndicator.is(':visible')) { - phpbb.alert($alert.attr('data-l-err'), $alert.attr('data-l-timeout-processing-req')); - } -}; - -/** - * Clear loading alert timeout -*/ -phpbb.clearLoadingTimeout = function() { - if (phpbbAlertTimer !== null) { - clearTimeout(phpbbAlertTimer); - phpbbAlertTimer = null; - } -}; - - -/** -* Close popup alert after a specified delay -* -* @param {int} delay Delay in ms until darkenwrapper's click event is triggered -*/ -phpbb.closeDarkenWrapper = function(delay) { - phpbbAlertTimer = setTimeout(function() { - $('#darkenwrapper').trigger('click'); - }, delay); -}; - -/** - * Display a simple alert similar to JSs native alert(). - * - * You can only call one alert or confirm box at any one time. - * - * @param {string} title Title of the message, eg "Information" (HTML). - * @param {string} msg Message to display (HTML). - * - * @returns {object} Returns the div created. - */ -phpbb.alert = function(title, msg) { - var $alert = $('#phpbb_alert'); - $alert.find('.alert_title').html(title); - $alert.find('.alert_text').html(msg); - - $(document).on('keydown.phpbb.alert', function(e) { - if (e.keyCode === keymap.ENTER || e.keyCode === keymap.ESC) { - phpbb.alert.close($alert, true); - e.preventDefault(); - e.stopPropagation(); - } - }); - phpbb.alert.open($alert); - - return $alert; -}; - -/** -* Handler for opening an alert box. -* -* @param {jQuery} $alert jQuery object. -*/ -phpbb.alert.open = function($alert) { - if (!$dark.is(':visible')) { - $dark.fadeIn(phpbb.alertTime); - } - - if ($loadingIndicator && $loadingIndicator.is(':visible')) { - $loadingIndicator.fadeOut(phpbb.alertTime, function() { - $dark.append($alert); - $alert.fadeIn(phpbb.alertTime); - }); - } else if ($dark.is(':visible')) { - $dark.append($alert); - $alert.fadeIn(phpbb.alertTime); - } else { - $dark.append($alert); - $alert.show(); - $dark.fadeIn(phpbb.alertTime); - } - - $alert.on('click', function(e) { - e.stopPropagation(); - }); - - $dark.one('click', function(e) { - phpbb.alert.close($alert, true); - e.preventDefault(); - e.stopPropagation(); - }); - - $alert.find('.alert_close').one('click', function(e) { - phpbb.alert.close($alert, true); - e.preventDefault(); - }); -}; - -/** -* Handler for closing an alert box. -* -* @param {jQuery} $alert jQuery object. -* @param {bool} fadedark Whether to remove dark background. -*/ -phpbb.alert.close = function($alert, fadedark) { - var $fade = (fadedark) ? $dark : $alert; - - $fade.fadeOut(phpbb.alertTime, function() { - $alert.hide(); - }); - - $alert.find('.alert_close').off('click'); - $(document).off('keydown.phpbb.alert'); -}; - -/** - * Display a simple yes / no box to the user. - * - * You can only call one alert or confirm box at any one time. - * - * @param {string} msg Message to display (HTML). - * @param {function} callback Callback. Bool param, whether the user pressed - * yes or no (or whatever their language is). - * @param {bool} fadedark Remove the dark background when done? Defaults - * to yes. - * - * @returns {object} Returns the div created. - */ -phpbb.confirm = function(msg, callback, fadedark) { - var $confirmDiv = $('#phpbb_confirm'); - $confirmDiv.find('.alert_text').html(msg); - fadedark = typeof fadedark !== 'undefined' ? fadedark : true; - - $(document).on('keydown.phpbb.alert', function(e) { - if (e.keyCode === keymap.ENTER || e.keyCode === keymap.ESC) { - var name = (e.keyCode === keymap.ENTER) ? 'confirm' : 'cancel'; - - $('input[name="' + name + '"]').trigger('click'); - e.preventDefault(); - e.stopPropagation(); - } - }); - - $confirmDiv.find('input[type="button"]').one('click.phpbb.confirmbox', function(e) { - var confirmed = this.name === 'confirm'; - - callback(confirmed); - $confirmDiv.find('input[type="button"]').off('click.phpbb.confirmbox'); - phpbb.alert.close($confirmDiv, fadedark || !confirmed); - - e.preventDefault(); - e.stopPropagation(); - }); - - phpbb.alert.open($confirmDiv); - - return $confirmDiv; -}; - -/** - * Turn a querystring into an array. - * - * @argument {string} string The querystring to parse. - * @returns {object} The object created. - */ -phpbb.parseQuerystring = function(string) { - var params = {}, i, split; - - string = string.split('&'); - for (i = 0; i < string.length; i++) { - split = string[i].split('='); - params[split[0]] = decodeURIComponent(split[1]); - } - return params; -}; - - -/** - * Makes a link use AJAX instead of loading an entire page. - * - * This function will work for links (both standard links and links which - * invoke confirm_box) and forms. It will be called automatically for links - * and forms with the data-ajax attribute set, and will call the necessary - * callback. - * - * For more info, view the following page on the phpBB wiki: - * http://wiki.phpbb.com/JavaScript_Function.phpbb.ajaxify - * - * @param {object} options Options. - */ -phpbb.ajaxify = function(options) { - var $elements = $(options.selector), - refresh = options.refresh, - callback = options.callback, - overlay = (typeof options.overlay !== 'undefined') ? options.overlay : true, - isForm = $elements.is('form'), - isText = $elements.is('input[type="text"], textarea'), - eventName; - - if (isForm) { - eventName = 'submit'; - } else if (isText) { - eventName = 'keyup'; - } else { - eventName = 'click'; - } - - $elements.on(eventName, function(event) { - var action, method, data, submit, that = this, $this = $(this); - - if ($this.find('input[type="submit"][data-clicked]').attr('data-ajax') === 'false') { - return; - } - - /** - * Handler for AJAX errors - */ - function errorHandler(jqXHR, textStatus, errorThrown) { - if (typeof console !== 'undefined' && console.log) { - console.log('AJAX error. status: ' + textStatus + ', message: ' + errorThrown); - } - phpbb.clearLoadingTimeout(); - var responseText, errorText = false; - try { - responseText = JSON.parse(jqXHR.responseText); - responseText = responseText.message; - } catch (e) {} - if (typeof responseText === 'string' && responseText.length > 0) { - errorText = responseText; - } else if (typeof errorThrown === 'string' && errorThrown.length > 0) { - errorText = errorThrown; - } else { - errorText = $dark.attr('data-ajax-error-text-' + textStatus); - if (typeof errorText !== 'string' || !errorText.length) { - errorText = $dark.attr('data-ajax-error-text'); - } - } - phpbb.alert($dark.attr('data-ajax-error-title'), errorText); - } - - /** - * This is a private function used to handle the callbacks, refreshes - * and alert. It calls the callback, refreshes the page if necessary, and - * displays an alert to the user and removes it after an amount of time. - * - * It cannot be called from outside this function, and is purely here to - * avoid repetition of code. - * - * @param {object} res The object sent back by the server. - */ - function returnHandler(res) { - var alert; - - phpbb.clearLoadingTimeout(); - - // Is a confirmation required? - if (typeof res.S_CONFIRM_ACTION === 'undefined') { - // If a confirmation is not required, display an alert and call the - // callbacks. - if (typeof res.MESSAGE_TITLE !== 'undefined') { - alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); - } else { - $dark.fadeOut(phpbb.alertTime); - - if ($loadingIndicator) { - $loadingIndicator.fadeOut(phpbb.alertTime); - } - } - - if (typeof phpbb.ajaxCallbacks[callback] === 'function') { - phpbb.ajaxCallbacks[callback].call(that, res); - } - - // If the server says to refresh the page, check whether the page should - // be refreshed and refresh page after specified time if required. - if (res.REFRESH_DATA) { - if (typeof refresh === 'function') { - refresh = refresh(res.REFRESH_DATA.url); - } else if (typeof refresh !== 'boolean') { - refresh = false; - } - - phpbbAlertTimer = setTimeout(function() { - if (refresh) { - window.location = res.REFRESH_DATA.url; - } - - // Hide the alert even if we refresh the page, in case the user - // presses the back button. - $dark.fadeOut(phpbb.alertTime, function() { - if (typeof alert !== 'undefined') { - alert.hide(); - } - }); - }, res.REFRESH_DATA.time * 1000); // Server specifies time in seconds - } - } else { - // If confirmation is required, display a dialog to the user. - phpbb.confirm(res.MESSAGE_BODY, function(del) { - if (!del) { - return; - } - - phpbb.loadingIndicator(); - data = $('
' + res.S_HIDDEN_FIELDS + '
').serialize(); - $.ajax({ - url: res.S_CONFIRM_ACTION, - type: 'POST', - data: data + '&confirm=' + res.YES_VALUE + '&' + $('form', '#phpbb_confirm').serialize(), - success: returnHandler, - error: errorHandler - }); - }, false); - } - } - - // If the element is a form, POST must be used and some extra data must - // be taken from the form. - var runFilter = (typeof options.filter === 'function'); - data = {}; - - if (isForm) { - action = $this.attr('action').replace('&', '&'); - data = $this.serializeArray(); - method = $this.attr('method') || 'GET'; - - if ($this.find('input[type="submit"][data-clicked]')) { - submit = $this.find('input[type="submit"][data-clicked]'); - data.push({ - name: submit.attr('name'), - value: submit.val() - }); - } - } else if (isText) { - var name = $this.attr('data-name') || this.name; - action = $this.attr('data-url').replace('&', '&'); - data[name] = this.value; - method = 'POST'; - } else { - action = this.href; - data = null; - method = 'GET'; - } - - var sendRequest = function() { - var dataOverlay = $this.attr('data-overlay'); - if (overlay && (typeof dataOverlay === 'undefined' || dataOverlay === 'true')) { - phpbb.loadingIndicator(); - } - - var request = $.ajax({ - url: action, - type: method, - data: data, - success: returnHandler, - error: errorHandler, - cache: false - }); - - request.always(function() { - if ($loadingIndicator && $loadingIndicator.is(':visible')) { - $loadingIndicator.fadeOut(phpbb.alertTime); - } - }); - }; - - // If filter function returns false, cancel the AJAX functionality, - // and return true (meaning that the HTTP request will be sent normally). - if (runFilter && !options.filter.call(this, data, event, sendRequest)) { - return; - } - - sendRequest(); - event.preventDefault(); - }); - - if (isForm) { - $elements.find('input:submit').click(function () { - var $this = $(this); - - // Remove data-clicked attribute from any submit button of form - $this.parents('form:first').find('input:submit[data-clicked]').removeAttr('data-clicked'); - - $this.attr('data-clicked', 'true'); - }); - } - - return this; -}; - -phpbb.search = { - cache: { - data: [] - }, - tpl: [], - container: [] -}; - -/** - * Get cached search data. - * - * @param {string} id Search ID. - * @returns {bool|object} Cached data object. Returns false if no data exists. - */ -phpbb.search.cache.get = function(id) { - if (this.data[id]) { - return this.data[id]; - } - return false; -}; - -/** - * Set search cache data value. - * - * @param {string} id Search ID. - * @param {string} key Data key. - * @param {string} value Data value. - */ -phpbb.search.cache.set = function(id, key, value) { - if (!this.data[id]) { - this.data[id] = { results: [] }; - } - this.data[id][key] = value; -}; - -/** - * Cache search result. - * - * @param {string} id Search ID. - * @param {string} keyword Keyword. - * @param {Array} results Search results. - */ -phpbb.search.cache.setResults = function(id, keyword, results) { - this.data[id].results[keyword] = results; -}; - -/** - * Trim spaces from keyword and lower its case. - * - * @param {string} keyword Search keyword to clean. - * @returns {string} Cleaned string. - */ -phpbb.search.cleanKeyword = function(keyword) { - return $.trim(keyword).toLowerCase(); -}; - -/** - * Get clean version of search keyword. If textarea supports several keywords - * (one per line), it fetches the current keyword based on the caret position. - * - * @param {jQuery} $input Search input|textarea. - * @param {string} keyword Input|textarea value. - * @param {bool} multiline Whether textarea supports multiple search keywords. - * - * @returns string Clean string. - */ -phpbb.search.getKeyword = function($input, keyword, multiline) { - if (multiline) { - var line = phpbb.search.getKeywordLine($input); - keyword = keyword.split('\n').splice(line, 1); - } - return phpbb.search.cleanKeyword(keyword); -}; - -/** - * Get the textarea line number on which the keyword resides - for textareas - * that support multiple keywords (one per line). - * - * @param {jQuery} $textarea Search textarea. - * @returns {int} The line number. - */ -phpbb.search.getKeywordLine = function ($textarea) { - var selectionStart = $textarea.get(0).selectionStart; - return $textarea.val().substr(0, selectionStart).split('\n').length - 1; -}; - -/** - * Set the value on the input|textarea. If textarea supports multiple - * keywords, only the active keyword is replaced. - * - * @param {jQuery} $input Search input|textarea. - * @param {string} value Value to set. - * @param {bool} multiline Whether textarea supports multiple search keywords. - */ -phpbb.search.setValue = function($input, value, multiline) { - if (multiline) { - var line = phpbb.search.getKeywordLine($input), - lines = $input.val().split('\n'); - lines[line] = value; - value = lines.join('\n'); - } - $input.val(value); -}; - -/** - * Sets the onclick event to set the value on the input|textarea to the - * selected search result. - * - * @param {jQuery} $input Search input|textarea. - * @param {object} value Result object. - * @param {jQuery} $row Result element. - * @param {jQuery} $container jQuery object for the search container. - */ -phpbb.search.setValueOnClick = function($input, value, $row, $container) { - $row.click(function() { - phpbb.search.setValue($input, value.result, $input.attr('data-multiline')); - phpbb.search.closeResults($input, $container); - }); -}; - -/** - * Runs before the AJAX search request is sent and determines whether - * there is a need to contact the server. If there are cached results - * already, those are displayed instead. Executes the AJAX request function - * itself due to the need to use a timeout to limit the number of requests. - * - * @param {Array} data Data to be sent to the server. - * @param {object} event Onkeyup event object. - * @param {function} sendRequest Function to execute AJAX request. - * - * @returns {boolean} Returns false. - */ -phpbb.search.filter = function(data, event, sendRequest) { - var $this = $(this), - dataName = ($this.attr('data-name') !== undefined) ? $this.attr('data-name') : $this.attr('name'), - minLength = parseInt($this.attr('data-min-length'), 10), - searchID = $this.attr('data-results'), - keyword = phpbb.search.getKeyword($this, data[dataName], $this.attr('data-multiline')), - cache = phpbb.search.cache.get(searchID), - key = event.keyCode || event.which, - proceed = true; - data[dataName] = keyword; - - // No need to search if enter was pressed - // for selecting a value from the results. - if (key === keymap.ENTER) { - return false; - } - - if (cache.timeout) { - clearTimeout(cache.timeout); - } - - var timeout = setTimeout(function() { - // Check min length and existence of cache. - if (minLength > keyword.length) { - proceed = false; - } else if (cache.lastSearch) { - // Has the keyword actually changed? - if (cache.lastSearch === keyword) { - proceed = false; - } else { - // Do we already have results for this? - if (cache.results[keyword]) { - var response = { - keyword: keyword, - results: cache.results[keyword] - }; - phpbb.search.handleResponse(response, $this, true); - proceed = false; - } - - // If the previous search didn't yield results and the string only had characters added to it, - // then we won't bother sending a request. - if (keyword.indexOf(cache.lastSearch) === 0 && cache.results[cache.lastSearch].length === 0) { - phpbb.search.cache.set(searchID, 'lastSearch', keyword); - phpbb.search.cache.setResults(searchID, keyword, []); - proceed = false; - } - } - } - - if (proceed) { - sendRequest.call(this); - } - }, 350); - phpbb.search.cache.set(searchID, 'timeout', timeout); - - return false; -}; - -/** - * Handle search result response. - * - * @param {object} res Data received from server. - * @param {jQuery} $input Search input|textarea. - * @param {bool} fromCache Whether the results are from the cache. - * @param {function} callback Optional callback to run when assigning each search result. - */ -phpbb.search.handleResponse = function(res, $input, fromCache, callback) { - if (typeof res !== 'object') { - return; - } - - var searchID = $input.attr('data-results'), - $container = $(searchID); - - if (this.cache.get(searchID).callback) { - callback = this.cache.get(searchID).callback; - } else if (typeof callback === 'function') { - this.cache.set(searchID, 'callback', callback); - } - - if (!fromCache) { - this.cache.setResults(searchID, res.keyword, res.results); - } - - this.cache.set(searchID, 'lastSearch', res.keyword); - this.showResults(res.results, $input, $container, callback); -}; - -/** - * Show search results. - * - * @param {Array} results Search results. - * @param {jQuery} $input Search input|textarea. - * @param {jQuery} $container Search results container element. - * @param {function} callback Optional callback to run when assigning each search result. - */ -phpbb.search.showResults = function(results, $input, $container, callback) { - var $resultContainer = $('.search-results', $container); - this.clearResults($resultContainer); - - if (!results.length) { - $container.hide(); - return; - } - - var searchID = $container.attr('id'), - tpl, - row; - - if (!this.tpl[searchID]) { - tpl = $('.search-result-tpl', $container); - this.tpl[searchID] = tpl.clone().removeClass('search-result-tpl'); - tpl.remove(); - } - tpl = this.tpl[searchID]; - - $.each(results, function(i, item) { - row = tpl.clone(); - row.find('.search-result').html(item.display); - - if (typeof callback === 'function') { - callback.call(this, $input, item, row, $container); - } - row.appendTo($resultContainer).show(); - }); - $container.show(); - - phpbb.search.navigateResults($input, $container, $resultContainer); -}; - -/** - * Clear search results. - * - * @param {jQuery} $container Search results container. - */ -phpbb.search.clearResults = function($container) { - $container.children(':not(.search-result-tpl)').remove(); -}; - -/** - * Close search results. - * - * @param {jQuery} $input Search input|textarea. - * @param {jQuery} $container Search results container. - */ -phpbb.search.closeResults = function($input, $container) { - $input.off('.phpbb.search'); - $container.hide(); -}; - -/** - * Navigate search results. - * - * @param {jQuery} $input Search input|textarea. - * @param {jQuery} $container Search results container. - * @param {jQuery} $resultContainer Search results list container. - */ -phpbb.search.navigateResults = function($input, $container, $resultContainer) { - // Add a namespace to the event (.phpbb.search), - // so it can be unbound specifically later on. - // Rebind it, to ensure the event is 'dynamic'. - $input.off('.phpbb.search'); - $input.on('keydown.phpbb.search', function(event) { - var key = event.keyCode || event.which, - $active = $resultContainer.children('.active'); - - switch (key) { - // Close the results - case keymap.ESC: - phpbb.search.closeResults($input, $container); - break; - - // Set the value for the selected result - case keymap.ENTER: - if ($active.length) { - var value = $active.find('.search-result > span').text(); - - phpbb.search.setValue($input, value, $input.attr('data-multiline')); - } - - phpbb.search.closeResults($input, $container); - - // Do not submit the form - event.preventDefault(); - break; - - // Navigate the results - case keymap.ARROW_DOWN: - case keymap.ARROW_UP: - var up = key === keymap.ARROW_UP, - $children = $resultContainer.children(); - - if (!$active.length) { - if (up) { - $children.last().addClass('active'); - } else { - $children.first().addClass('active'); - } - } else if ($children.length > 1) { - if (up) { - if ($active.is(':first-child')) { - $children.last().addClass('active'); - } else { - $active.prev().addClass('active'); - } - } else { - if ($active.is(':last-child')) { - $children.first().addClass('active'); - } else { - $active.next().addClass('active'); - } - } - - $active.removeClass('active'); - } - - // Do not change cursor position in the input element - event.preventDefault(); - break; - } - }); -}; - -$('#phpbb').click(function() { - var $this = $(this); - - if (!$this.is('.live-search') && !$this.parents().is('.live-search')) { - phpbb.search.closeResults($('input, textarea'), $('.live-search')); - } -}); - -phpbb.history = {}; - -/** -* Check whether a method in the native history object is supported. -* -* @param {string} fn Method name. -* @returns {bool} Returns true if the method is supported. -*/ -phpbb.history.isSupported = function(fn) { - return !(typeof history === 'undefined' || typeof history[fn] === 'undefined'); -}; - -/** -* Wrapper for the pushState and replaceState methods of the -* native history object. -* -* @param {string} mode Mode. Either push or replace. -* @param {string} url New URL. -* @param {string} [title] Optional page title. -* @param {object} [obj] Optional state object. -*/ -phpbb.history.alterUrl = function(mode, url, title, obj) { - var fn = mode + 'State'; - - if (!url || !phpbb.history.isSupported(fn)) { - return; - } - if (!title) { - title = document.title; - } - if (!obj) { - obj = null; - } - - history[fn](obj, title, url); -}; - -/** -* Wrapper for the native history.replaceState method. -* -* @param {string} url New URL. -* @param {string} [title] Optional page title. -* @param {object} [obj] Optional state object. -*/ -phpbb.history.replaceUrl = function(url, title, obj) { - phpbb.history.alterUrl('replace', url, title, obj); -}; - -/** -* Wrapper for the native history.pushState method. -* -* @param {string} url New URL. -* @param {string} [title] Optional page title. -* @param {object} [obj] Optional state object. -*/ -phpbb.history.pushUrl = function(url, title, obj) { - phpbb.history.alterUrl('push', url, title, obj); -}; - -/** -* Hide the optgroups that are not the selected timezone -* -* @param {bool} keepSelection Shall we keep the value selected, or shall the -* user be forced to repick one. -*/ -phpbb.timezoneSwitchDate = function(keepSelection) { - var $timezoneCopy = $('#timezone_copy'); - var $timezone = $('#timezone'); - var $tzDate = $('#tz_date'); - var $tzSelectDateSuggest = $('#tz_select_date_suggest'); - - if ($timezoneCopy.length === 0) { - // We make a backup of the original dropdown, so we can remove optgroups - // instead of setting display to none, because IE and chrome will not - // hide options inside of optgroups and selects via css - $timezone.clone() - .attr('id', 'timezone_copy') - .css('display', 'none') - .attr('name', 'tz_copy') - .insertAfter('#timezone'); - } else { - // Copy the content of our backup, so we can remove all unneeded options - $timezone.html($timezoneCopy.html()); - } - - if ($tzDate.val() !== '') { - $timezone.children('optgroup').remove(':not([data-tz-value="' + $tzDate.val() + '"])'); - } - - if ($tzDate.val() === $tzSelectDateSuggest.attr('data-suggested-tz')) { - $tzSelectDateSuggest.css('display', 'none'); - } else { - $tzSelectDateSuggest.css('display', 'inline'); - } - - var $tzOptions = $timezone.children('optgroup[data-tz-value="' + $tzDate.val() + '"]').children('option'); - - if ($tzOptions.length === 1) { - // If there is only one timezone for the selected date, we just select that automatically. - $tzOptions.prop('selected', true); - keepSelection = true; - } - - if (typeof keepSelection !== 'undefined' && !keepSelection) { - var $timezoneOptions = $timezone.find('optgroup option'); - if ($timezoneOptions.filter(':selected').length <= 0) { - $timezoneOptions.filter(':first').prop('selected', true); - } - } -}; - -/** -* Display the date/time select -*/ -phpbb.timezoneEnableDateSelection = function() { - $('#tz_select_date').css('display', 'block'); -}; - -/** -* Preselect a date/time or suggest one, if it is not picked. -* -* @param {bool} forceSelector Shall we select the suggestion? -*/ -phpbb.timezonePreselectSelect = function(forceSelector) { - - // The offset returned here is in minutes and negated. - var offset = (new Date()).getTimezoneOffset(); - var sign = '-'; - - if (offset < 0) { - sign = '+'; - offset = -offset; - } - - var minutes = offset % 60; - var hours = (offset - minutes) / 60; - - if (hours < 10) { - hours = '0' + hours.toString(); - } else { - hours = hours.toString(); - } - - if (minutes < 10) { - minutes = '0' + minutes.toString(); - } else { - minutes = minutes.toString(); - } - - var prefix = 'UTC' + sign + hours + ':' + minutes; - var prefixLength = prefix.length; - var selectorOptions = $('option', '#tz_date'); - var i; - - var $tzSelectDateSuggest = $('#tz_select_date_suggest'); - - for (i = 0; i < selectorOptions.length; ++i) { - var option = selectorOptions[i]; - - if (option.value.substring(0, prefixLength) === prefix) { - if ($('#tz_date').val() !== option.value && !forceSelector) { - // We do not select the option for the user, but notify him, - // that we would suggest a different setting. - phpbb.timezoneSwitchDate(true); - $tzSelectDateSuggest.css('display', 'inline'); - } else { - option.selected = true; - phpbb.timezoneSwitchDate(!forceSelector); - $tzSelectDateSuggest.css('display', 'none'); - } - - var suggestion = $tzSelectDateSuggest.attr('data-l-suggestion'); - - $tzSelectDateSuggest.attr('title', suggestion.replace('%s', option.innerHTML)); - $tzSelectDateSuggest.attr('value', suggestion.replace('%s', option.innerHTML.substring(0, 9))); - $tzSelectDateSuggest.attr('data-suggested-tz', option.innerHTML); - - // Found the suggestion, there cannot be more, so return from here. - return; - } - } -}; - -phpbb.ajaxCallbacks = {}; - -/** - * Adds an AJAX callback to be used by phpbb.ajaxify. - * - * See the phpbb.ajaxify comments for information on stuff like parameters. - * - * @param {string} id The name of the callback. - * @param {function} callback The callback to be called. - */ -phpbb.addAjaxCallback = function(id, callback) { - if (typeof callback === 'function') { - phpbb.ajaxCallbacks[id] = callback; - } - return this; -}; - -/** - * This callback handles live member searches. - */ -phpbb.addAjaxCallback('member_search', function(res) { - phpbb.search.handleResponse(res, $(this), false, phpbb.getFunctionByName('phpbb.search.setValueOnClick')); -}); - -/** - * This callback alternates text - it replaces the current text with the text in - * the alt-text data attribute, and replaces the text in the attribute with the - * current text so that the process can be repeated. - */ -phpbb.addAjaxCallback('alt_text', function() { - var $anchor, - updateAll = $(this).data('update-all'), - altText; - - if (updateAll !== undefined && updateAll.length) { - $anchor = $(updateAll); - } else { - $anchor = $(this); - } - - $anchor.each(function() { - var $this = $(this); - altText = $this.attr('data-alt-text'); - $this.attr('data-alt-text', $.trim($this.text())); - $this.attr('title', altText); - $this.children('span').text(altText); - }); -}); - -/** - * This callback is based on the alt_text callback. - * - * It replaces the current text with the text in the alt-text data attribute, - * and replaces the text in the attribute with the current text so that the - * process can be repeated. - * Additionally it replaces the class of the link's parent - * and changes the link itself. - */ -phpbb.addAjaxCallback('toggle_link', function() { - var $anchor, - updateAll = $(this).data('update-all') , - toggleText, - toggleUrl, - toggleClass; - - if (updateAll !== undefined && updateAll.length) { - $anchor = $(updateAll); - } else { - $anchor = $(this); - } - - $anchor.each(function() { - var $this = $(this); - - // Toggle link url - toggleUrl = $this.attr('data-toggle-url'); - $this.attr('data-toggle-url', $this.attr('href')); - $this.attr('href', toggleUrl); - - // Toggle class of link parent - toggleClass = $this.attr('data-toggle-class'); - $this.attr('data-toggle-class', $this.children().attr('class')); - $this.children('.icon').attr('class', toggleClass); - - // Toggle link text - toggleText = $this.attr('data-toggle-text'); - $this.attr('data-toggle-text', $this.children('span').text()); - $this.attr('title', $.trim(toggleText)); - $this.children('span').text(toggleText); - }); -}); - -/** -* Automatically resize textarea -* -* This function automatically resizes textarea elements when user -* types text. -* -* @param {jQuery} $items jQuery object(s) to resize -* @param {object} [options] Optional parameter that adjusts default -* configuration. See configuration variable -* -* Optional parameters: -* minWindowHeight {number} Minimum browser window height when textareas are resized. Default = 500 -* minHeight {number} Minimum height of textarea. Default = 200 -* maxHeight {number} Maximum height of textarea. Default = 500 -* heightDiff {number} Minimum difference between window and textarea height. Default = 200 -* resizeCallback {function} Function to call after resizing textarea -* resetCallback {function} Function to call when resize has been canceled - -* Callback function format: function(item) {} -* this points to DOM object -* item is a jQuery object, same as this -*/ -phpbb.resizeTextArea = function($items, options) { - // Configuration - var configuration = { - minWindowHeight: 500, - minHeight: 200, - maxHeight: 500, - heightDiff: 200, - resizeCallback: function() {}, - resetCallback: function() {} - }; - - if (phpbb.isTouch) { - return; - } - - if (arguments.length > 1) { - configuration = $.extend(configuration, options); - } - - function resetAutoResize(item) { - var $item = $(item); - if ($item.hasClass('auto-resized')) { - $(item) - .css({ height: '', resize: '' }) - .removeClass('auto-resized'); - configuration.resetCallback.call(item, $item); - } - } - - function autoResize(item) { - function setHeight(height) { - height += parseInt($item.css('height'), 10) - $item.innerHeight(); - $item - .css({ height: height + 'px', resize: 'none' }) - .addClass('auto-resized'); - configuration.resizeCallback.call(item, $item); - } - - var windowHeight = $(window).height(); - - if (windowHeight < configuration.minWindowHeight) { - resetAutoResize(item); - return; - } - - var maxHeight = Math.min( - Math.max(windowHeight - configuration.heightDiff, configuration.minHeight), - configuration.maxHeight - ), - $item = $(item), - height = parseInt($item.innerHeight(), 10), - scrollHeight = (item.scrollHeight) ? item.scrollHeight : 0; - - if (height < 0) { - return; - } - - if (height > maxHeight) { - setHeight(maxHeight); - } else if (scrollHeight > (height + 5)) { - setHeight(Math.min(maxHeight, scrollHeight)); - } - } - - $items.on('focus change keyup', function() { - $(this).each(function() { - autoResize(this); - }); - }).change(); - - $(window).resize(function() { - $items.each(function() { - if ($(this).hasClass('auto-resized')) { - autoResize(this); - } - }); - }); -}; - -/** -* Check if cursor in textarea is currently inside a bbcode tag -* -* @param {object} textarea Textarea DOM object -* @param {Array} startTags List of start tags to look for -* For example, Array('[code]', '[code=') -* @param {Array} endTags List of end tags to look for -* For example, Array('[/code]') -* -* @returns {boolean} True if cursor is in bbcode tag -*/ -phpbb.inBBCodeTag = function(textarea, startTags, endTags) { - var start = textarea.selectionStart, - lastEnd = -1, - lastStart = -1, - i, index, value; - - if (typeof start !== 'number') { - return false; - } - - value = textarea.value.toLowerCase(); - - for (i = 0; i < startTags.length; i++) { - var tagLength = startTags[i].length; - if (start >= tagLength) { - index = value.lastIndexOf(startTags[i], start - tagLength); - lastStart = Math.max(lastStart, index); - } - } - if (lastStart === -1) { - return false; - } - - if (start > 0) { - for (i = 0; i < endTags.length; i++) { - index = value.lastIndexOf(endTags[i], start - 1); - lastEnd = Math.max(lastEnd, index); - } - } - - return (lastEnd < lastStart); -}; - - -/** -* Adjust textarea to manage code bbcode -* -* This function allows to use tab characters when typing code -* and keeps indentation of previous line of code when adding new -* line while typing code. -* -* Editor's functionality is changed only when cursor is between -* [code] and [/code] bbcode tags. -* -* @param {object} textarea Textarea DOM object to apply editor to -*/ -phpbb.applyCodeEditor = function(textarea) { - // list of allowed start and end bbcode code tags, in lower case - var startTags = ['[code]', '[code='], - startTagsEnd = ']', - endTags = ['[/code]']; - - if (!textarea || typeof textarea.selectionStart !== 'number') { - return; - } - - if ($(textarea).data('code-editor') === true) { - return; - } - - function inTag() { - return phpbb.inBBCodeTag(textarea, startTags, endTags); - } - - /** - * Get line of text before cursor - * - * @param {boolean} stripCodeStart If true, only part of line - * after [code] tag will be returned. - * - * @returns {string} Line of text - */ - function getLastLine(stripCodeStart) { - var start = textarea.selectionStart, - value = textarea.value, - index = value.lastIndexOf('\n', start - 1); - - value = value.substring(index + 1, start); - - if (stripCodeStart) { - for (var i = 0; i < startTags.length; i++) { - index = value.lastIndexOf(startTags[i]); - if (index >= 0) { - var tagLength = startTags[i].length; - - value = value.substring(index + tagLength); - if (startTags[i].lastIndexOf(startTagsEnd) !== tagLength) { - index = value.indexOf(startTagsEnd); - - if (index >= 0) { - value = value.substr(index + 1); - } - } - } - } - } - - return value; - } - - /** - * Append text at cursor position - * - * @param {string} text Text to append - */ - function appendText(text) { - var start = textarea.selectionStart, - end = textarea.selectionEnd, - value = textarea.value; - - textarea.value = value.substr(0, start) + text + value.substr(end); - textarea.selectionStart = textarea.selectionEnd = start + text.length; - } - - $(textarea).data('code-editor', true).on('keydown', function(event) { - var key = event.keyCode || event.which; - - // intercept tabs - if (key === keymap.TAB && - !event.ctrlKey && - !event.shiftKey && - !event.altKey && - !event.metaKey) { - if (inTag()) { - appendText('\t'); - event.preventDefault(); - return; - } - } - - // intercept new line characters - if (key === keymap.ENTER) { - if (inTag()) { - var lastLine = getLastLine(true), - code = '' + /^\s*/g.exec(lastLine); - - if (code.length > 0) { - appendText('\n' + code); - event.preventDefault(); - } - } - } - }); -}; - -/** - * Show drag and drop animation when textarea is present - * - * This function will enable the drag and drop animation for a specified - * textarea. - * - * @param {HTMLElement} textarea Textarea DOM object to apply editor to - */ -phpbb.showDragNDrop = function(textarea) { - if (!textarea) { - return; - } - - $('body').on('dragenter dragover', function () { - $(textarea).addClass('drag-n-drop'); - }).on('dragleave dragout dragend drop', function() { - $(textarea).removeClass('drag-n-drop'); - }); - $(textarea).on('dragenter dragover', function () { - $(textarea).addClass('drag-n-drop-highlight'); - }).on('dragleave dragout dragend drop', function() { - $(textarea).removeClass('drag-n-drop-highlight'); - }); -}; - -/** -* List of classes that toggle dropdown menu, -* list of classes that contain visible dropdown menu -* -* Add your own classes to strings with comma (probably you -* will never need to do that) -*/ -phpbb.dropdownHandles = '.dropdown-container.dropdown-visible .dropdown-toggle'; -phpbb.dropdownVisibleContainers = '.dropdown-container.dropdown-visible'; - -/** -* Dropdown toggle event handler -* This handler is used by phpBB.registerDropdown() and other functions -*/ -phpbb.toggleDropdown = function() { - var $this = $(this), - options = $this.data('dropdown-options'), - parent = options.parent, - visible = parent.hasClass('dropdown-visible'), - direction; - - if (!visible) { - // Hide other dropdown menus - $(phpbb.dropdownHandles).each(phpbb.toggleDropdown); - - // Figure out direction of dropdown - direction = options.direction; - var verticalDirection = options.verticalDirection, - offset = $this.offset(); - - if (direction === 'auto') { - if (($(window).width() - $this.outerWidth(true)) / 2 > offset.left) { - direction = 'right'; - } else { - direction = 'left'; - } - } - parent.toggleClass(options.leftClass, direction === 'left') - .toggleClass(options.rightClass, direction === 'right'); - - if (verticalDirection === 'auto') { - var height = $(window).height(), - top = offset.top - $(window).scrollTop(); - - verticalDirection = (top < height * 0.7) ? 'down' : 'up'; - } - parent.toggleClass(options.upClass, verticalDirection === 'up') - .toggleClass(options.downClass, verticalDirection === 'down'); - } - - options.dropdown.toggle(); - parent.toggleClass(options.visibleClass, !visible) - .toggleClass('dropdown-visible', !visible); - - // Check dimensions when showing dropdown - // !visible because variable shows state of dropdown before it was toggled - if (!visible) { - var windowWidth = $(window).width(); - - options.dropdown.find('.dropdown-contents').each(function() { - var $this = $(this); - - $this.css({ - marginLeft: 0, - left: 0, - marginRight: 0, - maxWidth: (windowWidth - 4) + 'px' - }); - - var offset = $this.offset().left, - width = $this.outerWidth(true); - - if (offset < 2) { - $this.css('left', (2 - offset) + 'px'); - } else if ((offset + width + 2) > windowWidth) { - $this.css('margin-left', (windowWidth - offset - width - 2) + 'px'); - } - - // Check whether the vertical scrollbar is present. - $this.toggleClass('dropdown-nonscroll', this.scrollHeight === $this.innerHeight()); - - }); - var freeSpace = parent.offset().left - 4; - - if (direction === 'left') { - options.dropdown.css('margin-left', '-' + freeSpace + 'px'); - - // Try to position the notification dropdown correctly in RTL-responsive mode - if (options.dropdown.hasClass('dropdown-extended')) { - var contentWidth, - fullFreeSpace = freeSpace + parent.outerWidth(); - - options.dropdown.find('.dropdown-contents').each(function() { - contentWidth = parseInt($(this).outerWidth(), 10); - $(this).css({ marginLeft: 0, left: 0 }); - }); - - var maxOffset = Math.min(contentWidth, fullFreeSpace) + 'px'; - options.dropdown.css({ - width: maxOffset, - marginLeft: -maxOffset - }); - } - } else { - options.dropdown.css('margin-right', '-' + (windowWidth + freeSpace) + 'px'); - } - } - - // Prevent event propagation - if (arguments.length > 0) { - try { - var e = arguments[0]; - e.preventDefault(); - e.stopPropagation(); - } catch (error) { } - } - return false; -}; - -/** -* Toggle dropdown submenu -*/ -phpbb.toggleSubmenu = function(e) { - $(this).siblings('.dropdown-submenu').toggle(); - e.preventDefault(); -}; - -/** -* Register dropdown menu -* Shows/hides dropdown, decides which side to open to -* -* @param {jQuery} toggle Link that toggles dropdown. -* @param {jQuery} dropdown Dropdown menu. -* @param {Object} options List of options. Optional. -*/ -phpbb.registerDropdown = function(toggle, dropdown, options) { - var ops = { - parent: toggle.parent(), // Parent item to add classes to - direction: 'auto', // Direction of dropdown menu. Possible values: auto, left, right - verticalDirection: 'auto', // Vertical direction. Possible values: auto, up, down - visibleClass: 'visible', // Class to add to parent item when dropdown is visible - leftClass: 'dropdown-left', // Class to add to parent item when dropdown opens to left side - rightClass: 'dropdown-right', // Class to add to parent item when dropdown opens to right side - upClass: 'dropdown-up', // Class to add to parent item when dropdown opens above menu item - downClass: 'dropdown-down' // Class to add to parent item when dropdown opens below menu item - }; - if (options) { - ops = $.extend(ops, options); - } - ops.dropdown = dropdown; - - ops.parent.addClass('dropdown-container'); - toggle.addClass('dropdown-toggle'); - - toggle.data('dropdown-options', ops); - - toggle.click(phpbb.toggleDropdown); - $('.dropdown-toggle-submenu', ops.parent).click(phpbb.toggleSubmenu); -}; - -/** -* Get the HTML for a color palette table. -* -* @param {string} dir Palette direction - either v or h -* @param {int} width Palette cell width. -* @param {int} height Palette cell height. -*/ -phpbb.colorPalette = function(dir, width, height) { - var r, g, b, - numberList = new Array(6), - color = '', - html = ''; - - numberList[0] = '00'; - numberList[1] = '40'; - numberList[2] = '80'; - numberList[3] = 'BF'; - numberList[4] = 'FF'; - - var tableClass = (dir === 'h') ? 'horizontal-palette' : 'vertical-palette'; - html += ''; - - for (r = 0; r < 5; r++) { - if (dir === 'h') { - html += ''; - } - - for (g = 0; g < 5; g++) { - if (dir === 'v') { - html += ''; - } - - for (b = 0; b < 5; b++) { - color = '' + numberList[r] + numberList[g] + numberList[b]; - html += ''; - } - - if (dir === 'v') { - html += ''; - } - } - - if (dir === 'h') { - html += ''; - } - } - html += '
'; - html += '
'; - return html; -}; - -/** -* Register a color palette. -* -* @param {jQuery} el jQuery object for the palette container. -*/ -phpbb.registerPalette = function(el) { - var orientation = el.attr('data-color-palette') || el.attr('data-orientation'), // data-orientation kept for backwards compat. - height = el.attr('data-height'), - width = el.attr('data-width'), - target = el.attr('data-target'), - bbcode = el.attr('data-bbcode'); - - // Insert the palette HTML into the container. - el.html(phpbb.colorPalette(orientation, width, height)); - - // Add toggle control. - $('#color_palette_toggle').click(function(e) { - el.toggle(); - e.preventDefault(); - }); - - // Attach event handler when a palette cell is clicked. - $(el).on('click', 'a', function(e) { - var color = $(this).attr('data-color'); - - if (bbcode) { - bbfontstyle('[color=#' + color + ']', '[/color]'); - } else { - $(target).val(color); - } - e.preventDefault(); - }); -}; - -/** -* Set display of page element -* -* @param {string} id The ID of the element to change -* @param {int} action Set to 0 if element display should be toggled, -1 for -* hiding the element, and 1 for showing it. -* @param {string} type Display type that should be used, e.g. inline, block or -* other CSS "display" types -*/ -phpbb.toggleDisplay = function(id, action, type) { - if (!type) { - type = 'block'; - } - - var $element = $('#' + id); - - var display = $element.css('display'); - if (!action) { - action = (display === '' || display === type) ? -1 : 1; - } - $element.css('display', ((action === 1) ? type : 'none')); -}; - -/** -* Toggle additional settings based on the selected -* option of select element. -* -* @param {jQuery} el jQuery select element object. -*/ -phpbb.toggleSelectSettings = function(el) { - el.children().each(function() { - var $this = $(this), - $setting = $($this.data('toggle-setting')); - $setting.toggle($this.is(':selected')); - - // Disable any input elements that are not visible right now - if ($this.is(':selected')) { - $($this.data('toggle-setting') + ' input').prop('disabled', false); - } else { - $($this.data('toggle-setting') + ' input').prop('disabled', true); - } - }); -}; - -/** -* Get function from name. -* Based on http://stackoverflow.com/a/359910 -* -* @param {string} functionName Function to get. -* @returns function -*/ -phpbb.getFunctionByName = function (functionName) { - var namespaces = functionName.split('.'), - func = namespaces.pop(), - context = window; - - for (var i = 0; i < namespaces.length; i++) { - context = context[namespaces[i]]; - } - return context[func]; -}; - -/** -* Register page dropdowns. -*/ -phpbb.registerPageDropdowns = function() { - var $body = $('body'); - - $body.find('.dropdown-container').each(function() { - var $this = $(this), - $trigger = $this.find('.dropdown-trigger:first'), - $contents = $this.find('.dropdown'), - options = { - direction: 'auto', - verticalDirection: 'auto' - }, - data; - - if (!$trigger.length) { - data = $this.attr('data-dropdown-trigger'); - $trigger = data ? $this.children(data) : $this.children('a:first'); - } - - if (!$contents.length) { - data = $this.attr('data-dropdown-contents'); - $contents = data ? $this.children(data) : $this.children('div:first'); - } - - if (!$trigger.length || !$contents.length) { - return; - } - - if ($this.hasClass('dropdown-up')) { - options.verticalDirection = 'up'; - } - if ($this.hasClass('dropdown-down')) { - options.verticalDirection = 'down'; - } - if ($this.hasClass('dropdown-left')) { - options.direction = 'left'; - } - if ($this.hasClass('dropdown-right')) { - options.direction = 'right'; - } - - phpbb.registerDropdown($trigger, $contents, options); - }); - - // Hide active dropdowns when click event happens outside - $body.click(function(e) { - var $parents = $(e.target).parents(); - if (!$parents.is(phpbb.dropdownVisibleContainers)) { - $(phpbb.dropdownHandles).each(phpbb.toggleDropdown); - } - }); -}; - -/** - * Handle avatars to be lazy loaded. - */ -phpbb.lazyLoadAvatars = function loadAvatars() { - $('.avatar[data-src]').each(function () { - var $avatar = $(this); - - $avatar - .attr('src', $avatar.data('src')) - .removeAttr('data-src'); - }); -}; - -var recaptchaForm = $('.g-recaptcha').parents('form'); -var submitButton = null; -var programaticallySubmitted = false; - -phpbb.recaptchaOnLoad = function () { - // Listen to submit buttons in order to know which one was pressed - $('input[type="submit"]').each(function () { - $(this).on('click', function () { - submitButton = this; - }); - }); - - recaptchaForm.on('submit', function (e) { - if (!programaticallySubmitted) { - grecaptcha.execute(); - e.preventDefault(); - } - }); -} - -phpbb.recaptchaOnSubmit = function () { - programaticallySubmitted = true; - // If concrete button was clicked (e.g. preview instead of submit), - // let's trigger the same action - if (submitButton) { - submitButton.click(); - } else { - // Rename input[name="submit"] so that we can submit the form - if (typeof recaptchaForm.submit !== 'function') { - recaptchaForm.submit.name = 'submit_btn'; - } - recaptchaForm.submit(); - } -} - -// reCAPTCHA doesn't accept callback functions nested inside objects -// so we need to make this helper functions here -window.phpbbRecaptchaOnLoad = function() { - phpbb.recaptchaOnLoad(); -} -window.phpbbRecaptchaOnSubmit = function() { - phpbb.recaptchaOnSubmit(); -} - -$(window).on('load', phpbb.lazyLoadAvatars); - -/** -* Apply code editor to all textarea elements with data-bbcode attribute -*/ -$(function() { - $('textarea[data-bbcode]').each(function() { - phpbb.applyCodeEditor(this); - }); - - phpbb.registerPageDropdowns(); - - $('[data-color-palette], [data-orientation]').each(function() { - phpbb.registerPalette($(this)); - }); - - // Update browser history URL to point to specific post in viewtopic.php - // when using view=unread#unread link. - phpbb.history.replaceUrl($('#unread[data-url]').data('url')); - - // Hide settings that are not selected via select element. - $('select[data-togglable-settings]').each(function() { - var $this = $(this); - - $this.change(function() { - phpbb.toggleSelectSettings($this); - }); - phpbb.toggleSelectSettings($this); - }); -}); - -})(jQuery); // Avoid conflicts with other libraries diff --git a/install/update/new/assets/javascript/editor.js b/install/update/new/assets/javascript/editor.js deleted file mode 100644 index 24cbc09..0000000 --- a/install/update/new/assets/javascript/editor.js +++ /dev/null @@ -1,418 +0,0 @@ -/** -* bbCode control by subBlue design [ www.subBlue.com ] -* Includes unixsafe colour palette selector by SHS` -*/ - -// Startup variables -var imageTag = false; -var theSelection = false; -var bbcodeEnabled = true; - -// Check for Browser & Platform for PC & IE specific bits -// More details from: http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html -var clientPC = navigator.userAgent.toLowerCase(); // Get client info -var clientVer = parseInt(navigator.appVersion, 10); // Get browser version - -var is_ie = ((clientPC.indexOf('msie') !== -1) && (clientPC.indexOf('opera') === -1)); -var is_win = ((clientPC.indexOf('win') !== -1) || (clientPC.indexOf('16bit') !== -1)); -var baseHeight; - -/** -* Fix a bug involving the TextRange object. From -* http://www.frostjedi.com/terra/scripts/demo/caretBug.html -*/ -function initInsertions() { - var doc; - - if (document.forms[form_name]) { - doc = document; - } else { - doc = opener.document; - } - - var textarea = doc.forms[form_name].elements[text_name]; - - if (is_ie && typeof(baseHeight) !== 'number') { - textarea.focus(); - baseHeight = doc.selection.createRange().duplicate().boundingHeight; - - if (!document.forms[form_name]) { - document.body.focus(); - } - } -} - -/** -* bbstyle -*/ -function bbstyle(bbnumber) { - if (bbnumber !== -1) { - bbfontstyle(bbtags[bbnumber], bbtags[bbnumber+1]); - } else { - insert_text('[*]'); - document.forms[form_name].elements[text_name].focus(); - } -} - -/** -* Apply bbcodes -*/ -function bbfontstyle(bbopen, bbclose) { - theSelection = false; - - var textarea = document.forms[form_name].elements[text_name]; - - textarea.focus(); - - if ((clientVer >= 4) && is_ie && is_win) { - // Get text selection - theSelection = document.selection.createRange().text; - - if (theSelection) { - // Add tags around selection - document.selection.createRange().text = bbopen + theSelection + bbclose; - textarea.focus(); - theSelection = ''; - return; - } - } else if (textarea.selectionEnd && (textarea.selectionEnd - textarea.selectionStart > 0)) { - mozWrap(textarea, bbopen, bbclose); - textarea.focus(); - theSelection = ''; - return; - } - - //The new position for the cursor after adding the bbcode - var caret_pos = getCaretPosition(textarea).start; - var new_pos = caret_pos + bbopen.length; - - // Open tag - insert_text(bbopen + bbclose); - - // Center the cursor when we don't have a selection - // Gecko and proper browsers - if (!isNaN(textarea.selectionStart)) { - textarea.selectionStart = new_pos; - textarea.selectionEnd = new_pos; - } - // IE - else if (document.selection) { - var range = textarea.createTextRange(); - range.move("character", new_pos); - range.select(); - storeCaret(textarea); - } - - textarea.focus(); -} - -/** -* Insert text at position -*/ -function insert_text(text, spaces, popup) { - var textarea; - - if (!popup) { - textarea = document.forms[form_name].elements[text_name]; - } else { - textarea = opener.document.forms[form_name].elements[text_name]; - } - - if (spaces) { - text = ' ' + text + ' '; - } - - // Since IE9, IE also has textarea.selectionStart, but it still needs to be treated the old way. - // Therefore we simply add a !is_ie here until IE fixes the text-selection completely. - if (!isNaN(textarea.selectionStart) && !is_ie) { - var sel_start = textarea.selectionStart; - var sel_end = textarea.selectionEnd; - - mozWrap(textarea, text, ''); - textarea.selectionStart = sel_start + text.length; - textarea.selectionEnd = sel_end + text.length; - } else if (textarea.createTextRange && textarea.caretPos) { - if (baseHeight !== textarea.caretPos.boundingHeight) { - textarea.focus(); - storeCaret(textarea); - } - - var caret_pos = textarea.caretPos; - caret_pos.text = caret_pos.text.charAt(caret_pos.text.length - 1) === ' ' ? caret_pos.text + text + ' ' : caret_pos.text + text; - } else { - textarea.value = textarea.value + text; - } - - if (!popup) { - textarea.focus(); - } -} - -/** -* Add inline attachment at position -*/ -function attachInline(index, filename) { - insert_text('[attachment=' + index + ']' + filename + '[/attachment]'); - document.forms[form_name].elements[text_name].focus(); -} - -/** -* Add quote text to message -*/ -function addquote(post_id, username, l_wrote, attributes) { - var message_name = 'message_' + post_id; - var theSelection = ''; - var divarea = false; - var i; - - if (l_wrote === undefined) { - // Backwards compatibility - l_wrote = 'wrote'; - } - if (typeof attributes !== 'object') { - attributes = {}; - } - - if (document.all) { - divarea = document.all[message_name]; - } else { - divarea = document.getElementById(message_name); - } - - // Get text selection - not only the post content :( - // IE9 must use the document.selection method but has the *.getSelection so we just force no IE - if (window.getSelection && !is_ie && !window.opera) { - theSelection = window.getSelection().toString(); - } else if (document.getSelection && !is_ie) { - theSelection = document.getSelection(); - } else if (document.selection) { - theSelection = document.selection.createRange().text; - } - - if (theSelection === '' || typeof theSelection === 'undefined' || theSelection === null) { - if (divarea.innerHTML) { - theSelection = divarea.innerHTML.replace(/
/ig, '\n'); - theSelection = theSelection.replace(//ig, '\n'); - theSelection = theSelection.replace(/<\;/ig, '<'); - theSelection = theSelection.replace(/>\;/ig, '>'); - theSelection = theSelection.replace(/&\;/ig, '&'); - theSelection = theSelection.replace(/ \;/ig, ' '); - } else if (document.all) { - theSelection = divarea.innerText; - } else if (divarea.textContent) { - theSelection = divarea.textContent; - } else if (divarea.firstChild.nodeValue) { - theSelection = divarea.firstChild.nodeValue; - } - } - - if (theSelection) { - if (bbcodeEnabled) { - attributes.author = username; - insert_text(generateQuote(theSelection, attributes)); - } else { - insert_text(username + ' ' + l_wrote + ':' + '\n'); - var lines = split_lines(theSelection); - for (i = 0; i < lines.length; i++) { - insert_text('> ' + lines[i] + '\n'); - } - } - } -} - -/** -* Create a quote block for given text -* -* Possible attributes: -* - author: author's name (usually a username) -* - post_id: post_id of the post being quoted -* - user_id: user_id of the user being quoted -* - time: timestamp of the original message -* -* @param {!string} text Quote's text -* @param {!Object} attributes Quote's attributes -* @return {!string} Quote block to be used in a new post/text -*/ -function generateQuote(text, attributes) { - text = text.replace(/^\s+/, '').replace(/\s+$/, ''); - var quote = '[quote'; - if (attributes.author) { - // Add the author as the BBCode's default attribute - quote += '=' + formatAttributeValue(attributes.author); - delete attributes.author; - } - for (var name in attributes) { - if (attributes.hasOwnProperty(name)) { - var value = attributes[name]; - quote += ' ' + name + '=' + formatAttributeValue(value.toString()); - } - } - quote += ']'; - var newline = ((quote + text + '[/quote]').length > 80 || text.indexOf('\n') > -1) ? '\n' : ''; - quote += newline + text + newline + '[/quote]'; - - return quote; -} - -/** -* Format given string to be used as an attribute value -* -* Will return the string as-is if it can be used in a BBCode without quotes. Otherwise, -* it will use either single- or double- quotes depending on whichever requires less escaping. -* Quotes and backslashes are escaped with backslashes where necessary -* -* @param {!string} str Original string -* @return {!string} Same string if possible, escaped string within quotes otherwise -*/ -function formatAttributeValue(str) { - if (!/[ "'\\\]]/.test(str)) { - // Return as-is if it contains none of: space, ' " \ or ] - return str; - } - var singleQuoted = "'" + str.replace(/[\\']/g, '\\$&') + "'", - doubleQuoted = '"' + str.replace(/[\\"]/g, '\\$&') + '"'; - - return (singleQuoted.length < doubleQuoted.length) ? singleQuoted : doubleQuoted; -} - -function split_lines(text) { - var lines = text.split('\n'); - var splitLines = new Array(); - var j = 0; - var i; - - for(i = 0; i < lines.length; i++) { - if (lines[i].length <= 80) { - splitLines[j] = lines[i]; - j++; - } else { - var line = lines[i]; - var splitAt; - do { - splitAt = line.indexOf(' ', 80); - - if (splitAt === -1) { - splitLines[j] = line; - j++; - } else { - splitLines[j] = line.substring(0, splitAt); - line = line.substring(splitAt); - j++; - } - } - while(splitAt !== -1); - } - } - return splitLines; -} - -/** -* From http://www.massless.org/mozedit/ -*/ -function mozWrap(txtarea, open, close) { - var selLength = (typeof(txtarea.textLength) === 'undefined') ? txtarea.value.length : txtarea.textLength; - var selStart = txtarea.selectionStart; - var selEnd = txtarea.selectionEnd; - var scrollTop = txtarea.scrollTop; - - var s1 = (txtarea.value).substring(0,selStart); - var s2 = (txtarea.value).substring(selStart, selEnd); - var s3 = (txtarea.value).substring(selEnd, selLength); - - txtarea.value = s1 + open + s2 + close + s3; - txtarea.selectionStart = selStart + open.length; - txtarea.selectionEnd = selEnd + open.length; - txtarea.focus(); - txtarea.scrollTop = scrollTop; - - return; -} - -/** -* Insert at Caret position. Code from -* http://www.faqts.com/knowledge_base/view.phtml/aid/1052/fid/130 -*/ -function storeCaret(textEl) { - if (textEl.createTextRange && document.selection) { - textEl.caretPos = document.selection.createRange().duplicate(); - } -} - -/** -* Caret Position object -*/ -function caretPosition() { - var start = null; - var end = null; -} - -/** -* Get the caret position in an textarea -*/ -function getCaretPosition(txtarea) { - var caretPos = new caretPosition(); - - // simple Gecko/Opera way - if (txtarea.selectionStart || txtarea.selectionStart === 0) { - caretPos.start = txtarea.selectionStart; - caretPos.end = txtarea.selectionEnd; - } - // dirty and slow IE way - else if (document.selection) { - // get current selection - var range = document.selection.createRange(); - - // a new selection of the whole textarea - var range_all = document.body.createTextRange(); - range_all.moveToElementText(txtarea); - - // calculate selection start point by moving beginning of range_all to beginning of range - var sel_start; - for (sel_start = 0; range_all.compareEndPoints('StartToStart', range) < 0; sel_start++) { - range_all.moveStart('character', 1); - } - - txtarea.sel_start = sel_start; - - // we ignore the end value for IE, this is already dirty enough and we don't need it - caretPos.start = txtarea.sel_start; - caretPos.end = txtarea.sel_start; - } - - return caretPos; -} - -/** -* Allow to use tab character when typing code -* Keep indentation of last line of code when typing code -*/ -(function($) { - $(document).ready(function() { - var doc, textarea; - - // find textarea, make sure browser supports necessary functions - if (document.forms[form_name]) { - doc = document; - } else { - doc = opener.document; - } - - if (!doc.forms[form_name]) { - return; - } - - textarea = doc.forms[form_name].elements[text_name]; - - phpbb.applyCodeEditor(textarea); - if ($('#attach-panel').length) { - phpbb.showDragNDrop(textarea); - } - - $('textarea').on('keydown', function (e) { - if (e.which === 13 && (e.metaKey || e.ctrlKey)) { - $(this).closest('form').find(':submit').click(); - } - }); - }); -})(jQuery); - diff --git a/install/update/new/assets/javascript/installer.js b/install/update/new/assets/javascript/installer.js deleted file mode 100644 index a11b76b..0000000 --- a/install/update/new/assets/javascript/installer.js +++ /dev/null @@ -1,615 +0,0 @@ -/** - * Installer's AJAX frontend handler - */ - -(function($) { // Avoid conflicts with other libraries - 'use strict'; - - // Installer variables - var pollTimer = null; - var nextReadPosition = 0; - var progressBarTriggered = false; - var progressTimer = null; - var currentProgress = 0; - var refreshRequested = false; - var transmissionOver = false; - var statusCount = 0; - - // Template related variables - var $contentWrapper = $('.install-body').find('.main'); - - // Intercept form submits - interceptFormSubmit($('#install_install')); - - /** - * Creates an XHR object - * - * jQuery cannot be used as the response is streamed, and - * as of now, jQuery does not provide access to the response until - * the connection is not closed. - * - * @return XMLHttpRequest - */ - function createXhrObject() { - return new XMLHttpRequest(); - } - - /** - * Displays error, warning and log messages - * - * @param type - * @param messages - */ - function addMessage(type, messages) { - // Get message containers - var $errorContainer = $('#error-container'); - var $warningContainer = $('#warning-container'); - var $logContainer = $('#log-container'); - - var $title, $description, $msgElement, arraySize = messages.length; - for (var i = 0; i < arraySize; i++) { - $msgElement = $('
'); - $title = $(''); - $title.text(messages[i].title); - $msgElement.append($title); - - if (messages[i].hasOwnProperty('description')) { - $description = $('

'); - $description.html(messages[i].description); - $msgElement.append($description); - } - - switch (type) { - case 'error': - $msgElement.addClass('errorbox'); - $errorContainer.append($msgElement); - break; - case 'warning': - $msgElement.addClass('warningbox'); - $warningContainer.append($msgElement); - break; - case 'log': - $msgElement.addClass('log'); - $logContainer.prepend($msgElement); - $logContainer.addClass('show_log_container'); - break; - case 'success': - $msgElement.addClass('successbox'); - $errorContainer.prepend($msgElement); - break; - } - } - } - - /** - * Render a download box - */ - function addDownloadBox(downloadArray) - { - var $downloadContainer = $('#download-wrapper'); - var $downloadBox, $title, $content, $link; - - for (var i = 0; i < downloadArray.length; i++) { - $downloadBox = $('

'); - $downloadBox.addClass('download-box'); - - $title = $(''); - $title.text(downloadArray[i].title); - $downloadBox.append($title); - - if (downloadArray[i].hasOwnProperty('msg')) { - $content = $('

'); - $content.text(downloadArray[i].msg); - $downloadBox.append($content); - } - - $link = $(''); - $link.addClass('button1'); - $link.attr('href', downloadArray[i].href); - $link.text(downloadArray[i].download); - $downloadBox.append($link); - - $downloadContainer.append($downloadBox); - } - } - - /** - * Render update files' status - */ - function addUpdateFileStatus(fileStatus) - { - var $statusContainer = $('#file-status-wrapper'); - $statusContainer.html(fileStatus); - } - - /** - * Displays a form from the response - * - * @param formHtml - */ - function addForm(formHtml) { - var $formContainer = $('#form-wrapper'); - $formContainer.html(formHtml); - var $form = $('#install_install'); - interceptFormSubmit($form); - } - - /** - * Handles navigation status updates - * - * @param navObj - */ - function updateNavbarStatus(navObj) { - var navID, $stage, $stageListItem, $active; - $active = $('#activemenu'); - - if (navObj.hasOwnProperty('finished')) { - // This should be an Array - var navItems = navObj.finished; - - for (var i = 0; i < navItems.length; i++) { - navID = 'installer-stage-' + navItems[i]; - $stage = $('#' + navID); - $stageListItem = $stage.parent(); - - if ($active.length && $active.is($stageListItem)) { - $active.removeAttr('id'); - } - - $stage.addClass('completed'); - } - } - - if (navObj.hasOwnProperty('active')) { - navID = 'installer-stage-' + navObj.active; - $stage = $('#' + navID); - $stageListItem = $stage.parent(); - - if ($active.length && !$active.is($stageListItem)) { - $active.removeAttr('id'); - } - - $stageListItem.attr('id', 'activemenu'); - } - } - - /** - * Renders progress bar - * - * @param progressObject - */ - function setProgress(progressObject) { - var $statusText, $progressBar, $progressText, $progressFiller, $progressFillerText; - - if (progressObject.task_name.length) { - if (!progressBarTriggered) { - // Create progress bar - var $progressBarWrapper = $('#progress-bar-container'); - - // Create progress bar elements - $progressBar = $('

'); - $progressBar.attr('id', 'progress-bar'); - $progressText = $('

'); - $progressText.attr('id', 'progress-bar-text'); - $progressFiller = $('

'); - $progressFiller.attr('id', 'progress-bar-filler'); - $progressFillerText = $('

'); - $progressFillerText.attr('id', 'progress-bar-filler-text'); - - $statusText = $('

'); - $statusText.attr('id', 'progress-status-text'); - - $progressFiller.append($progressFillerText); - $progressBar.append($progressText); - $progressBar.append($progressFiller); - - $progressBarWrapper.append($statusText); - $progressBarWrapper.append($progressBar); - - $progressFillerText.css('width', $progressBar.width()); - - progressBarTriggered = true; - } else if (progressObject.hasOwnProperty('restart')) { - clearInterval(progressTimer); - - $progressFiller = $('#progress-bar-filler'); - $progressFillerText = $('#progress-bar-filler-text'); - $progressText = $('#progress-bar-text'); - $statusText = $('#progress-status-text'); - - $progressText.text('0%'); - $progressFillerText.text('0%'); - $progressFiller.css('width', '0%'); - - currentProgress = 0; - } else { - $statusText = $('#progress-status-text'); - } - - // Update progress bar - $statusText.text(progressObject.task_name + '…'); - incrementProgressBar(Math.round(progressObject.task_num / progressObject.task_count * 100)); - } - } - - // Set cookies - function setCookies(cookies) { - var cookie; - - for (var i = 0; i < cookies.length; i++) { - // Set cookie name and value - cookie = encodeURIComponent(cookies[i].name) + '=' + encodeURIComponent(cookies[i].value); - // Set path - cookie += '; path=/'; - document.cookie = cookie; - } - } - - // Redirects user - function redirect(url, use_ajax) { - if (use_ajax) { - resetPolling(); - - var xhReq = createXhrObject(); - xhReq.open('GET', url, true); - xhReq.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); - xhReq.send(); - - startPolling(xhReq); - } else { - window.location.href = url; - } - } - - /** - * Parse messages from the response object - * - * @param messageJSON - */ - function parseMessage(messageJSON) { - $('#loading_indicator').css('display', 'none'); - var responseObject; - - try { - responseObject = JSON.parse(messageJSON); - } catch (err) { - if (window.console) { - console.log('Failed to parse JSON object\n\nMessage: ' + err.message + '\n\nServer Response: ' + messageJSON); - } else { - alert('Failed to parse JSON object\n\nMessage: ' + err.message + '\n\nServer Response: ' + messageJSON); - } - - resetPolling(); - return; - } - - // Parse object - if (responseObject.hasOwnProperty('errors')) { - addMessage('error', responseObject.errors); - } - - if (responseObject.hasOwnProperty('warnings')) { - addMessage('warning', responseObject.warnings); - } - - if (responseObject.hasOwnProperty('logs')) { - addMessage('log', responseObject.logs); - } - - if (responseObject.hasOwnProperty('success')) { - addMessage('success', responseObject.success); - } - - if (responseObject.hasOwnProperty('form')) { - addForm(responseObject.form); - } - - if (responseObject.hasOwnProperty('progress')) { - setProgress(responseObject.progress); - } - - if (responseObject.hasOwnProperty('download')) { - addDownloadBox(responseObject.download); - } - - if (responseObject.hasOwnProperty('file_status')) { - addUpdateFileStatus(responseObject.file_status); - } - - if (responseObject.hasOwnProperty('nav')) { - updateNavbarStatus(responseObject.nav); - } - - if (responseObject.hasOwnProperty('cookies')) { - setCookies(responseObject.cookies); - } - - if (responseObject.hasOwnProperty('refresh')) { - refreshRequested = true; - } - - if (responseObject.hasOwnProperty('redirect')) { - redirect(responseObject.redirect.url, responseObject.redirect.use_ajax); - } - - if (responseObject.hasOwnProperty('over')) { - if (responseObject.over) { - transmissionOver = true; - } - } - } - - /** - * Processes status data - * - * @param status - */ - function processTimeoutResponse(status) { - if (statusCount === 12) { // 1 minute hard cap - status = 'fail'; - } - - if (status === 'continue') { - refreshRequested = false; - doRefresh(); - } else if (status === 'running') { - statusCount++; - $('#loading_indicator').css('display', 'block'); - setTimeout(queryInstallerStatus, 5000); - } else { - $('#loading_indicator').css('display', 'none'); - addMessage('error', - [{ - title: installLang.title, - description: installLang.msg - }] - ); - } - } - - /** - * Queries the installer's status - */ - function queryInstallerStatus() { - var url = $(location).attr('pathname'); - var lookUp = 'install/app.php'; - var position = url.indexOf(lookUp); - - if (position === -1) { - lookUp = 'install'; - position = url.indexOf(lookUp); - - if (position === -1) { - return false; - } - } - - url = url.substring(0, position) + lookUp + '/installer/status'; - $.getJSON(url, function(data) { - processTimeoutResponse(data.status); - }); - } - - /** - * Process updates in streamed response - * - * @param xhReq XHR object - */ - function pollContent(xhReq) { - var messages = xhReq.responseText; - var msgSeparator = '}\n\n'; - var unprocessed, messageEndIndex, endOfMessageIndex, message; - - do { - unprocessed = messages.substring(nextReadPosition); - messageEndIndex = unprocessed.indexOf(msgSeparator); - - if (messageEndIndex !== -1) { - endOfMessageIndex = messageEndIndex + msgSeparator.length; - message = unprocessed.substring(0, endOfMessageIndex); - parseMessage($.trim(message)); - nextReadPosition += endOfMessageIndex; - } - } while (messageEndIndex !== -1); - - if (xhReq.readyState === 4) { - $('#loading_indicator').css('display', 'none'); - resetPolling(); - - var timeoutDetected = !transmissionOver; - - if (refreshRequested) { - refreshRequested = false; - doRefresh(); - } - - if (timeoutDetected) { - statusCount = 0; - queryInstallerStatus(); - } - } - } - - /** - * Animates the progress bar - * - * @param $progressText - * @param $progressFiller - * @param $progressFillerText - * @param progressLimit - */ - function incrementFiller($progressText, $progressFiller, $progressFillerText, progressLimit) { - if (currentProgress >= progressLimit || currentProgress >= 100) { - clearInterval(progressTimer); - return; - } - - var $progressBar = $('#progress-bar'); - - currentProgress++; - $progressFillerText.css('width', $progressBar.width()); - $progressFillerText.text(currentProgress + '%'); - $progressText.text(currentProgress + '%'); - $progressFiller.css('width', currentProgress + '%'); - } - - /** - * Wrapper function for progress bar rendering and animating - * - * @param progressLimit - */ - function incrementProgressBar(progressLimit) { - var $progressFiller = $('#progress-bar-filler'); - var $progressFillerText = $('#progress-bar-filler-text'); - var $progressText = $('#progress-bar-text'); - var progressStart = $progressFiller.width() / $progressFiller.offsetParent().width() * 100; - currentProgress = Math.floor(progressStart); - - clearInterval(progressTimer); - progressTimer = setInterval(function() { - incrementFiller($progressText, $progressFiller, $progressFillerText, progressLimit); - }, 10); - } - - /** - * Resets the polling timer - */ - function resetPolling() { - clearInterval(pollTimer); - nextReadPosition = 0; - } - - /** - * Sets up timer for processing the streamed HTTP response - * - * @param xhReq - */ - function startPolling(xhReq) { - resetPolling(); - transmissionOver = false; - pollTimer = setInterval(function () { - pollContent(xhReq); - }, 250); - } - - /** - * Refresh page - */ - function doRefresh() { - resetPolling(); - - var xhReq = createXhrObject(); - xhReq.open('GET', $(location).attr('pathname'), true); - xhReq.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); - xhReq.send(); - - startPolling(xhReq); - } - - /** - * Renders the AJAX UI layout - */ - function setupAjaxLayout() { - progressBarTriggered = false; - - // Clear content - $contentWrapper.html(''); - - var $header = $('

'); - $header.attr('id', 'header-container'); - $contentWrapper.append($header); - - var $description = $('
'); - $description.attr('id', 'description-container'); - $contentWrapper.append($description); - - var $errorContainer = $('
'); - $errorContainer.attr('id', 'error-container'); - $contentWrapper.append($errorContainer); - - var $warningContainer = $('
'); - $warningContainer.attr('id', 'warning-container'); - $contentWrapper.append($warningContainer); - - var $progressContainer = $('
'); - $progressContainer.attr('id', 'progress-bar-container'); - $contentWrapper.append($progressContainer); - - var $logContainer = $('
'); - $logContainer.attr('id', 'log-container'); - $contentWrapper.append($logContainer); - - var $installerContentWrapper = $('
'); - $installerContentWrapper.attr('id', 'content-container'); - $contentWrapper.append($installerContentWrapper); - - var $installerDownloadWrapper = $('
'); - $installerDownloadWrapper.attr('id', 'download-wrapper'); - $installerContentWrapper.append($installerDownloadWrapper); - - var $updaterFileStatusWrapper = $('
'); - $updaterFileStatusWrapper.attr('id', 'file-status-wrapper'); - $installerContentWrapper.append($updaterFileStatusWrapper); - - var $formWrapper = $('
'); - $formWrapper.attr('id', 'form-wrapper'); - $installerContentWrapper.append($formWrapper); - - var $spinner = $('
'); - $spinner.attr('id', 'loading_indicator'); - $spinner.html(' '); - $contentWrapper.append($spinner); - } - - // Submits a form - function submitForm($form, $submitBtn) { - $form.css('display', 'none'); - - var xhReq = createXhrObject(); - xhReq.open('POST', $form.attr('action'), true); - xhReq.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); - xhReq.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); - xhReq.send(getFormFields($form, $submitBtn)); - - // Disable language selector - $('#language_selector :input, label').css('display', 'none'); - - // Clear content - setupAjaxLayout(); - $('#loading_indicator').css('display', 'block'); - - startPolling(xhReq); - } - - /** - * Add submit button to the POST information - * - * @param $form - * @param $submitBtn - * - * @returns {*} - */ - function getFormFields($form, $submitBtn) { - var formData = $form.serialize(); - formData += ((formData.length) ? '&' : '') + encodeURIComponent($submitBtn.attr('name')) + '='; - formData += encodeURIComponent($submitBtn.attr('value')); - - return formData; - } - - /** - * Intercept form submit events and determine the submit button used - * - * @param $form - */ - function interceptFormSubmit($form) { - if (!$form.length) { - return; - } - - $form.find(':submit').bind('click', function (event) { - event.preventDefault(); - submitForm($form, $(this)); - }); - } -})(jQuery); // Avoid conflicts with other libraries diff --git a/install/update/new/assets/javascript/jquery-3.4.1.min.js b/install/update/new/assets/javascript/jquery-3.4.1.min.js deleted file mode 100644 index a1c07fd..0000000 --- a/install/update/new/assets/javascript/jquery-3.4.1.min.js +++ /dev/null @@ -1,2 +0,0 @@ -/*! jQuery v3.4.1 | (c) JS Foundation and other contributors | jquery.org/license */ -!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(C,e){"use strict";var t=[],E=C.document,r=Object.getPrototypeOf,s=t.slice,g=t.concat,u=t.push,i=t.indexOf,n={},o=n.toString,v=n.hasOwnProperty,a=v.toString,l=a.call(Object),y={},m=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType},x=function(e){return null!=e&&e===e.window},c={type:!0,src:!0,nonce:!0,noModule:!0};function b(e,t,n){var r,i,o=(n=n||E).createElement("script");if(o.text=e,t)for(r in c)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function w(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[o.call(e)]||"object":typeof e}var f="3.4.1",k=function(e,t){return new k.fn.init(e,t)},p=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;function d(e){var t=!!e&&"length"in e&&e.length,n=w(e);return!m(e)&&!x(e)&&("array"===n||0===t||"number"==typeof t&&0+~]|"+M+")"+M+"*"),U=new RegExp(M+"|>"),X=new RegExp($),V=new RegExp("^"+I+"$"),G={ID:new RegExp("^#("+I+")"),CLASS:new RegExp("^\\.("+I+")"),TAG:new RegExp("^("+I+"|[*])"),ATTR:new RegExp("^"+W),PSEUDO:new RegExp("^"+$),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+R+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/HTML$/i,Q=/^(?:input|select|textarea|button)$/i,J=/^h\d$/i,K=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ee=/[+~]/,te=new RegExp("\\\\([\\da-f]{1,6}"+M+"?|("+M+")|.)","ig"),ne=function(e,t,n){var r="0x"+t-65536;return r!=r||n?t:r<0?String.fromCharCode(r+65536):String.fromCharCode(r>>10|55296,1023&r|56320)},re=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ie=function(e,t){return t?"\0"===e?"\ufffd":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},oe=function(){T()},ae=be(function(e){return!0===e.disabled&&"fieldset"===e.nodeName.toLowerCase()},{dir:"parentNode",next:"legend"});try{H.apply(t=O.call(m.childNodes),m.childNodes),t[m.childNodes.length].nodeType}catch(e){H={apply:t.length?function(e,t){L.apply(e,O.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function se(t,e,n,r){var i,o,a,s,u,l,c,f=e&&e.ownerDocument,p=e?e.nodeType:9;if(n=n||[],"string"!=typeof t||!t||1!==p&&9!==p&&11!==p)return n;if(!r&&((e?e.ownerDocument||e:m)!==C&&T(e),e=e||C,E)){if(11!==p&&(u=Z.exec(t)))if(i=u[1]){if(9===p){if(!(a=e.getElementById(i)))return n;if(a.id===i)return n.push(a),n}else if(f&&(a=f.getElementById(i))&&y(e,a)&&a.id===i)return n.push(a),n}else{if(u[2])return H.apply(n,e.getElementsByTagName(t)),n;if((i=u[3])&&d.getElementsByClassName&&e.getElementsByClassName)return H.apply(n,e.getElementsByClassName(i)),n}if(d.qsa&&!A[t+" "]&&(!v||!v.test(t))&&(1!==p||"object"!==e.nodeName.toLowerCase())){if(c=t,f=e,1===p&&U.test(t)){(s=e.getAttribute("id"))?s=s.replace(re,ie):e.setAttribute("id",s=k),o=(l=h(t)).length;while(o--)l[o]="#"+s+" "+xe(l[o]);c=l.join(","),f=ee.test(t)&&ye(e.parentNode)||e}try{return H.apply(n,f.querySelectorAll(c)),n}catch(e){A(t,!0)}finally{s===k&&e.removeAttribute("id")}}}return g(t.replace(B,"$1"),e,n,r)}function ue(){var r=[];return function e(t,n){return r.push(t+" ")>b.cacheLength&&delete e[r.shift()],e[t+" "]=n}}function le(e){return e[k]=!0,e}function ce(e){var t=C.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function fe(e,t){var n=e.split("|"),r=n.length;while(r--)b.attrHandle[n[r]]=t}function pe(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function de(t){return function(e){return"input"===e.nodeName.toLowerCase()&&e.type===t}}function he(n){return function(e){var t=e.nodeName.toLowerCase();return("input"===t||"button"===t)&&e.type===n}}function ge(t){return function(e){return"form"in e?e.parentNode&&!1===e.disabled?"label"in e?"label"in e.parentNode?e.parentNode.disabled===t:e.disabled===t:e.isDisabled===t||e.isDisabled!==!t&&ae(e)===t:e.disabled===t:"label"in e&&e.disabled===t}}function ve(a){return le(function(o){return o=+o,le(function(e,t){var n,r=a([],e.length,o),i=r.length;while(i--)e[n=r[i]]&&(e[n]=!(t[n]=e[n]))})})}function ye(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}for(e in d=se.support={},i=se.isXML=function(e){var t=e.namespaceURI,n=(e.ownerDocument||e).documentElement;return!Y.test(t||n&&n.nodeName||"HTML")},T=se.setDocument=function(e){var t,n,r=e?e.ownerDocument||e:m;return r!==C&&9===r.nodeType&&r.documentElement&&(a=(C=r).documentElement,E=!i(C),m!==C&&(n=C.defaultView)&&n.top!==n&&(n.addEventListener?n.addEventListener("unload",oe,!1):n.attachEvent&&n.attachEvent("onunload",oe)),d.attributes=ce(function(e){return e.className="i",!e.getAttribute("className")}),d.getElementsByTagName=ce(function(e){return e.appendChild(C.createComment("")),!e.getElementsByTagName("*").length}),d.getElementsByClassName=K.test(C.getElementsByClassName),d.getById=ce(function(e){return a.appendChild(e).id=k,!C.getElementsByName||!C.getElementsByName(k).length}),d.getById?(b.filter.ID=function(e){var t=e.replace(te,ne);return function(e){return e.getAttribute("id")===t}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n=t.getElementById(e);return n?[n]:[]}}):(b.filter.ID=function(e){var n=e.replace(te,ne);return function(e){var t="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return t&&t.value===n}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),b.find.TAG=d.getElementsByTagName?function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):d.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},b.find.CLASS=d.getElementsByClassName&&function(e,t){if("undefined"!=typeof t.getElementsByClassName&&E)return t.getElementsByClassName(e)},s=[],v=[],(d.qsa=K.test(C.querySelectorAll))&&(ce(function(e){a.appendChild(e).innerHTML="",e.querySelectorAll("[msallowcapture^='']").length&&v.push("[*^$]="+M+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||v.push("\\["+M+"*(?:value|"+R+")"),e.querySelectorAll("[id~="+k+"-]").length||v.push("~="),e.querySelectorAll(":checked").length||v.push(":checked"),e.querySelectorAll("a#"+k+"+*").length||v.push(".#.+[+~]")}),ce(function(e){e.innerHTML="";var t=C.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&v.push("name"+M+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&v.push(":enabled",":disabled"),a.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&v.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),v.push(",.*:")})),(d.matchesSelector=K.test(c=a.matches||a.webkitMatchesSelector||a.mozMatchesSelector||a.oMatchesSelector||a.msMatchesSelector))&&ce(function(e){d.disconnectedMatch=c.call(e,"*"),c.call(e,"[s!='']:x"),s.push("!=",$)}),v=v.length&&new RegExp(v.join("|")),s=s.length&&new RegExp(s.join("|")),t=K.test(a.compareDocumentPosition),y=t||K.test(a.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},D=t?function(e,t){if(e===t)return l=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)===(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!d.sortDetached&&t.compareDocumentPosition(e)===n?e===C||e.ownerDocument===m&&y(m,e)?-1:t===C||t.ownerDocument===m&&y(m,t)?1:u?P(u,e)-P(u,t):0:4&n?-1:1)}:function(e,t){if(e===t)return l=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,a=[e],s=[t];if(!i||!o)return e===C?-1:t===C?1:i?-1:o?1:u?P(u,e)-P(u,t):0;if(i===o)return pe(e,t);n=e;while(n=n.parentNode)a.unshift(n);n=t;while(n=n.parentNode)s.unshift(n);while(a[r]===s[r])r++;return r?pe(a[r],s[r]):a[r]===m?-1:s[r]===m?1:0}),C},se.matches=function(e,t){return se(e,null,null,t)},se.matchesSelector=function(e,t){if((e.ownerDocument||e)!==C&&T(e),d.matchesSelector&&E&&!A[t+" "]&&(!s||!s.test(t))&&(!v||!v.test(t)))try{var n=c.call(e,t);if(n||d.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){A(t,!0)}return 0":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(te,ne),e[3]=(e[3]||e[4]||e[5]||"").replace(te,ne),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||se.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&se.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return G.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&X.test(n)&&(t=h(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(te,ne).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=p[e+" "];return t||(t=new RegExp("(^|"+M+")"+e+"("+M+"|$)"))&&p(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(n,r,i){return function(e){var t=se.attr(e,n);return null==t?"!="===r:!r||(t+="","="===r?t===i:"!="===r?t!==i:"^="===r?i&&0===t.indexOf(i):"*="===r?i&&-1:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function j(e,n,r){return m(n)?k.grep(e,function(e,t){return!!n.call(e,t,e)!==r}):n.nodeType?k.grep(e,function(e){return e===n!==r}):"string"!=typeof n?k.grep(e,function(e){return-1)[^>]*|#([\w-]+))$/;(k.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||q,"string"==typeof e){if(!(r="<"===e[0]&&">"===e[e.length-1]&&3<=e.length?[null,e,null]:L.exec(e))||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof k?t[0]:t,k.merge(this,k.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:E,!0)),D.test(r[1])&&k.isPlainObject(t))for(r in t)m(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return(i=E.getElementById(r[2]))&&(this[0]=i,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):m(e)?void 0!==n.ready?n.ready(e):e(k):k.makeArray(e,this)}).prototype=k.fn,q=k(E);var H=/^(?:parents|prev(?:Until|All))/,O={children:!0,contents:!0,next:!0,prev:!0};function P(e,t){while((e=e[t])&&1!==e.nodeType);return e}k.fn.extend({has:function(e){var t=k(e,this),n=t.length;return this.filter(function(){for(var e=0;e\x20\t\r\n\f]*)/i,he=/^$|^module$|\/(?:java|ecma)script/i,ge={option:[1,""],thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};function ve(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&A(e,t)?k.merge([e],n):n}function ye(e,t){for(var n=0,r=e.length;nx",y.noCloneChecked=!!me.cloneNode(!0).lastChild.defaultValue;var Te=/^key/,Ce=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,Ee=/^([^.]*)(?:\.(.+)|)/;function ke(){return!0}function Se(){return!1}function Ne(e,t){return e===function(){try{return E.activeElement}catch(e){}}()==("focus"===t)}function Ae(e,t,n,r,i,o){var a,s;if("object"==typeof t){for(s in"string"!=typeof n&&(r=r||n,n=void 0),t)Ae(e,s,n,r,t[s],o);return e}if(null==r&&null==i?(i=n,r=n=void 0):null==i&&("string"==typeof n?(i=r,r=void 0):(i=r,r=n,n=void 0)),!1===i)i=Se;else if(!i)return e;return 1===o&&(a=i,(i=function(e){return k().off(e),a.apply(this,arguments)}).guid=a.guid||(a.guid=k.guid++)),e.each(function(){k.event.add(this,t,i,r,n)})}function De(e,i,o){o?(Q.set(e,i,!1),k.event.add(e,i,{namespace:!1,handler:function(e){var t,n,r=Q.get(this,i);if(1&e.isTrigger&&this[i]){if(r.length)(k.event.special[i]||{}).delegateType&&e.stopPropagation();else if(r=s.call(arguments),Q.set(this,i,r),t=o(this,i),this[i](),r!==(n=Q.get(this,i))||t?Q.set(this,i,!1):n={},r!==n)return e.stopImmediatePropagation(),e.preventDefault(),n.value}else r.length&&(Q.set(this,i,{value:k.event.trigger(k.extend(r[0],k.Event.prototype),r.slice(1),this)}),e.stopImmediatePropagation())}})):void 0===Q.get(e,i)&&k.event.add(e,i,ke)}k.event={global:{},add:function(t,e,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,v=Q.get(t);if(v){n.handler&&(n=(o=n).handler,i=o.selector),i&&k.find.matchesSelector(ie,i),n.guid||(n.guid=k.guid++),(u=v.events)||(u=v.events={}),(a=v.handle)||(a=v.handle=function(e){return"undefined"!=typeof k&&k.event.triggered!==e.type?k.event.dispatch.apply(t,arguments):void 0}),l=(e=(e||"").match(R)||[""]).length;while(l--)d=g=(s=Ee.exec(e[l])||[])[1],h=(s[2]||"").split(".").sort(),d&&(f=k.event.special[d]||{},d=(i?f.delegateType:f.bindType)||d,f=k.event.special[d]||{},c=k.extend({type:d,origType:g,data:r,handler:n,guid:n.guid,selector:i,needsContext:i&&k.expr.match.needsContext.test(i),namespace:h.join(".")},o),(p=u[d])||((p=u[d]=[]).delegateCount=0,f.setup&&!1!==f.setup.call(t,r,h,a)||t.addEventListener&&t.addEventListener(d,a)),f.add&&(f.add.call(t,c),c.handler.guid||(c.handler.guid=n.guid)),i?p.splice(p.delegateCount++,0,c):p.push(c),k.event.global[d]=!0)}},remove:function(e,t,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,v=Q.hasData(e)&&Q.get(e);if(v&&(u=v.events)){l=(t=(t||"").match(R)||[""]).length;while(l--)if(d=g=(s=Ee.exec(t[l])||[])[1],h=(s[2]||"").split(".").sort(),d){f=k.event.special[d]||{},p=u[d=(r?f.delegateType:f.bindType)||d]||[],s=s[2]&&new RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),a=o=p.length;while(o--)c=p[o],!i&&g!==c.origType||n&&n.guid!==c.guid||s&&!s.test(c.namespace)||r&&r!==c.selector&&("**"!==r||!c.selector)||(p.splice(o,1),c.selector&&p.delegateCount--,f.remove&&f.remove.call(e,c));a&&!p.length&&(f.teardown&&!1!==f.teardown.call(e,h,v.handle)||k.removeEvent(e,d,v.handle),delete u[d])}else for(d in u)k.event.remove(e,d+t[l],n,r,!0);k.isEmptyObject(u)&&Q.remove(e,"handle events")}},dispatch:function(e){var t,n,r,i,o,a,s=k.event.fix(e),u=new Array(arguments.length),l=(Q.get(this,"events")||{})[s.type]||[],c=k.event.special[s.type]||{};for(u[0]=s,t=1;t\x20\t\r\n\f]*)[^>]*)\/>/gi,qe=/\s*$/g;function Oe(e,t){return A(e,"table")&&A(11!==t.nodeType?t:t.firstChild,"tr")&&k(e).children("tbody")[0]||e}function Pe(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function Re(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Me(e,t){var n,r,i,o,a,s,u,l;if(1===t.nodeType){if(Q.hasData(e)&&(o=Q.access(e),a=Q.set(t,o),l=o.events))for(i in delete a.handle,a.events={},l)for(n=0,r=l[i].length;n")},clone:function(e,t,n){var r,i,o,a,s,u,l,c=e.cloneNode(!0),f=oe(e);if(!(y.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||k.isXMLDoc(e)))for(a=ve(c),r=0,i=(o=ve(e)).length;r").attr(n.scriptAttrs||{}).prop({charset:n.scriptCharset,src:n.url}).on("load error",i=function(e){r.remove(),i=null,e&&t("error"===e.type?404:200,e.type)}),E.head.appendChild(r[0])},abort:function(){i&&i()}}});var Vt,Gt=[],Yt=/(=)\?(?=&|$)|\?\?/;k.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Gt.pop()||k.expando+"_"+kt++;return this[e]=!0,e}}),k.ajaxPrefilter("json jsonp",function(e,t,n){var r,i,o,a=!1!==e.jsonp&&(Yt.test(e.url)?"url":"string"==typeof e.data&&0===(e.contentType||"").indexOf("application/x-www-form-urlencoded")&&Yt.test(e.data)&&"data");if(a||"jsonp"===e.dataTypes[0])return r=e.jsonpCallback=m(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,a?e[a]=e[a].replace(Yt,"$1"+r):!1!==e.jsonp&&(e.url+=(St.test(e.url)?"&":"?")+e.jsonp+"="+r),e.converters["script json"]=function(){return o||k.error(r+" was not called"),o[0]},e.dataTypes[0]="json",i=C[r],C[r]=function(){o=arguments},n.always(function(){void 0===i?k(C).removeProp(r):C[r]=i,e[r]&&(e.jsonpCallback=t.jsonpCallback,Gt.push(r)),o&&m(i)&&i(o[0]),o=i=void 0}),"script"}),y.createHTMLDocument=((Vt=E.implementation.createHTMLDocument("").body).innerHTML="
",2===Vt.childNodes.length),k.parseHTML=function(e,t,n){return"string"!=typeof e?[]:("boolean"==typeof t&&(n=t,t=!1),t||(y.createHTMLDocument?((r=(t=E.implementation.createHTMLDocument("")).createElement("base")).href=E.location.href,t.head.appendChild(r)):t=E),o=!n&&[],(i=D.exec(e))?[t.createElement(i[1])]:(i=we([e],t,o),o&&o.length&&k(o).remove(),k.merge([],i.childNodes)));var r,i,o},k.fn.load=function(e,t,n){var r,i,o,a=this,s=e.indexOf(" ");return-1").append(k.parseHTML(e)).find(r):e)}).always(n&&function(e,t){a.each(function(){n.apply(this,o||[e.responseText,t,e])})}),this},k.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){k.fn[t]=function(e){return this.on(t,e)}}),k.expr.pseudos.animated=function(t){return k.grep(k.timers,function(e){return t===e.elem}).length},k.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l=k.css(e,"position"),c=k(e),f={};"static"===l&&(e.style.position="relative"),s=c.offset(),o=k.css(e,"top"),u=k.css(e,"left"),("absolute"===l||"fixed"===l)&&-1<(o+u).indexOf("auto")?(a=(r=c.position()).top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),m(t)&&(t=t.call(e,n,k.extend({},s))),null!=t.top&&(f.top=t.top-s.top+a),null!=t.left&&(f.left=t.left-s.left+i),"using"in t?t.using.call(e,f):c.css(f)}},k.fn.extend({offset:function(t){if(arguments.length)return void 0===t?this:this.each(function(e){k.offset.setOffset(this,t,e)});var e,n,r=this[0];return r?r.getClientRects().length?(e=r.getBoundingClientRect(),n=r.ownerDocument.defaultView,{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,n,r=this[0],i={top:0,left:0};if("fixed"===k.css(r,"position"))t=r.getBoundingClientRect();else{t=this.offset(),n=r.ownerDocument,e=r.offsetParent||n.documentElement;while(e&&(e===n.body||e===n.documentElement)&&"static"===k.css(e,"position"))e=e.parentNode;e&&e!==r&&1===e.nodeType&&((i=k(e).offset()).top+=k.css(e,"borderTopWidth",!0),i.left+=k.css(e,"borderLeftWidth",!0))}return{top:t.top-i.top-k.css(r,"marginTop",!0),left:t.left-i.left-k.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent;while(e&&"static"===k.css(e,"position"))e=e.offsetParent;return e||ie})}}),k.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(t,i){var o="pageYOffset"===i;k.fn[t]=function(e){return _(this,function(e,t,n){var r;if(x(e)?r=e:9===e.nodeType&&(r=e.defaultView),void 0===n)return r?r[i]:e[t];r?r.scrollTo(o?r.pageXOffset:n,o?n:r.pageYOffset):e[t]=n},t,e,arguments.length)}}),k.each(["top","left"],function(e,n){k.cssHooks[n]=ze(y.pixelPosition,function(e,t){if(t)return t=_e(e,n),$e.test(t)?k(e).position()[n]+"px":t})}),k.each({Height:"height",Width:"width"},function(a,s){k.each({padding:"inner"+a,content:s,"":"outer"+a},function(r,o){k.fn[o]=function(e,t){var n=arguments.length&&(r||"boolean"!=typeof e),i=r||(!0===e||!0===t?"margin":"border");return _(this,function(e,t,n){var r;return x(e)?0===o.indexOf("outer")?e["inner"+a]:e.document.documentElement["client"+a]:9===e.nodeType?(r=e.documentElement,Math.max(e.body["scroll"+a],r["scroll"+a],e.body["offset"+a],r["offset"+a],r["client"+a])):void 0===n?k.css(e,t,i):k.style(e,t,n,i)},s,n?e:void 0,n)}})}),k.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,n){k.fn[n]=function(e,t){return 0 object(property: value). Requires attach_id to be one of the object properties. - */ -phpbb.plupload.setData = function(data) { - // Make sure that the array keys are reset. - phpbb.plupload.ids = phpbb.plupload.data = []; - phpbb.plupload.data = data; - - for (var i = 0; i < data.length; i++) { - phpbb.plupload.ids.push(Number(data[i].attach_id)); - } -}; - -/** - * Update the attachment data in the HTML and the phpbb & phpbb.plupload objects. - * - * @param {Array} data Array containing the new data to use. - * @param {string} action The action that required the update. Used to update the inline attachment bbcodes. - * @param {int} index The index from phpbb.plupload_ids that was affected by the action. - * @param {Array} downloadUrl Optional array of download urls to update. - */ -phpbb.plupload.update = function(data, action, index, downloadUrl) { - - phpbb.plupload.updateBbcode(action, index); - phpbb.plupload.setData(data); - phpbb.plupload.updateRows(downloadUrl); - phpbb.plupload.clearParams(); - phpbb.plupload.updateMultipartParams(phpbb.plupload.getSerializedData()); -}; - -/** - * Update the relevant elements and hidden data for all attachments. - * - * @param {Array} downloadUrl Optional array of download urls to update. - */ -phpbb.plupload.updateRows = function(downloadUrl) { - for (var i = 0; i < phpbb.plupload.ids.length; i++) { - phpbb.plupload.updateRow(i, downloadUrl); - } -}; - -/** - * Insert a row for a new attachment. This expects an HTML snippet in the HTML - * using the id "attach-row-tpl" to be present. This snippet is cloned and the - * data for the file inserted into it. The row is then appended or prepended to - * #file-list based on the attach_order setting. - * - * @param {object} file Plupload file object for the new attachment. - */ -phpbb.plupload.insertRow = function(file) { - var row = $(phpbb.plupload.rowTpl); - - row.attr('id', file.id); - row.find('.file-name').html(plupload.xmlEncode(file.name)); - row.find('.file-size').html(plupload.formatSize(file.size)); - - if (phpbb.plupload.order === 'desc') { - $('#file-list').prepend(row); - } else { - $('#file-list').append(row); - } -}; - -/** - * Update the relevant elements and hidden data for an attachment. - * - * @param {int} index The index from phpbb.plupload.ids of the attachment to edit. - * @param {Array} downloadUrl Optional array of download urls to update. - */ -phpbb.plupload.updateRow = function(index, downloadUrl) { - var attach = phpbb.plupload.data[index], - row = $('[data-attach-id="' + attach.attach_id + '"]'); - - // Add the link to the file - if (typeof downloadUrl !== 'undefined' && typeof downloadUrl[index] !== 'undefined') { - var url = downloadUrl[index].replace('&', '&'), - link = $(''); - - link.attr('href', url).html(attach.real_filename); - row.find('.file-name').html(link); - } - - row.find('textarea').attr('name', 'comment_list[' + index + ']'); - phpbb.plupload.updateHiddenData(row, attach, index); -}; - -/** - * Update hidden input data for an attachment. - * - * @param {object} row jQuery object for the attachment row. - * @param {object} attach Attachment data object from phpbb.plupload.data - * @param {int} index Attachment index from phpbb.plupload.ids - */ -phpbb.plupload.updateHiddenData = function(row, attach, index) { - row.find('input[type="hidden"]').remove(); - - for (var key in attach) { - if (!attach.hasOwnProperty(key)) { - return; - } - - var input = $('') - .attr('type', 'hidden') - .attr('name', 'attachment_data[' + index + '][' + key + ']') - .attr('value', attach[key]); - $(row).append(input); - } -}; - -/** - * Deleting a file removes it from the queue and fires an AJAX event to the - * server to tell it to remove the temporary attachment. The server - * responds with the updated attachment data list so that any future - * uploads can maintain state with the server - * - * @param {object} row jQuery object for the attachment row. - * @param {int} attachId Attachment id of the file to be removed. - */ -phpbb.plupload.deleteFile = function(row, attachId) { - // If there's no attach id, then the file hasn't been uploaded. Simply delete the row. - if (typeof attachId === 'undefined') { - var file = phpbb.plupload.uploader.getFile(row.attr('id')); - phpbb.plupload.uploader.removeFile(file); - - row.slideUp(100, function() { - row.remove(); - phpbb.plupload.hideEmptyList(); - }); - } - - var index = phpbb.plupload.getIndex(attachId); - row.find('.file-status').toggleClass('file-uploaded file-working'); - - if (index === false) { - return; - } - var fields = {}; - fields['delete_file[' + index + ']'] = 1; - - var always = function() { - row.find('.file-status').removeClass('file-working'); - }; - - var done = function(response) { - if (typeof response !== 'object') { - return; - } - - // trigger_error() was called which likely means a permission error was encountered. - if (typeof response.title !== 'undefined') { - phpbb.plupload.uploader.trigger('Error', { message: response.message }); - // We will have to assume that the deletion failed. So leave the file status as uploaded. - row.find('.file-status').toggleClass('file-uploaded'); - - return; - } - - // Handle errors while deleting file - if (typeof response.error !== 'undefined') { - phpbb.alert(phpbb.plupload.lang.ERROR, response.error.message); - - // We will have to assume that the deletion failed. So leave the file status as uploaded. - row.find('.file-status').toggleClass('file-uploaded'); - - return; - } - - phpbb.plupload.update(response, 'removal', index); - // Check if the user can upload files now if he had reached the max files limit. - phpbb.plupload.handleMaxFilesReached(); - - if (row.attr('id')) { - var file = phpbb.plupload.uploader.getFile(row.attr('id')); - phpbb.plupload.uploader.removeFile(file); - } - row.slideUp(100, function() { - row.remove(); - // Hide the file list if it's empty now. - phpbb.plupload.hideEmptyList(); - }); - phpbb.plupload.uploader.trigger('FilesRemoved'); - }; - - $.ajax(phpbb.plupload.config.url, { - type: 'POST', - data: $.extend(fields, phpbb.plupload.getSerializedData()), - headers: phpbb.plupload.config.headers - }) - .always(always) - .done(done); -}; - -/** - * Check the attachment list and hide its container if it's empty. - */ -phpbb.plupload.hideEmptyList = function() { - if (!$('#file-list').children().length) { - $('#file-list-container').slideUp(100); - } -}; - -/** - * Update the indices used in inline attachment bbcodes. This ensures that the - * bbcodes correspond to the correct file after a file is added or removed. - * This should be called before the phpbb.plupload,data and phpbb.plupload.ids - * arrays are updated, otherwise it will not work correctly. - * - * @param {string} action The action that occurred -- either "addition" or "removal" - * @param {int} index The index of the attachment from phpbb.plupload.ids that was affected. - */ -phpbb.plupload.updateBbcode = function(action, index) { - var textarea = $('#message', phpbb.plupload.form), - text = textarea.val(), - removal = (action === 'removal'); - - // Return if the bbcode isn't used at all. - if (text.indexOf('[attachment=') === -1) { - return; - } - - function runUpdate(i) { - var regex = new RegExp('\\[attachment=' + i + '\\](.*?)\\[\\/attachment\\]', 'g'); - text = text.replace(regex, function updateBbcode(_, fileName) { - // Remove the bbcode if the file was removed. - if (removal && index === i) { - return ''; - } - var newIndex = i + ((removal) ? -1 : 1); - return '[attachment=' + newIndex + ']' + fileName + '[/attachment]'; - }); - } - - // Loop forwards when removing and backwards when adding ensures we don't - // corrupt the bbcode index. - var i; - if (removal) { - for (i = index; i < phpbb.plupload.ids.length; i++) { - runUpdate(i); - } - } else { - for (i = phpbb.plupload.ids.length - 1; i >= index; i--) { - runUpdate(i); - } - } - - textarea.val(text); -}; - -/** - * Get Plupload file objects based on their upload status. - * - * @param {int} status Plupload status - plupload.DONE, plupload.FAILED, - * plupload.QUEUED, plupload.STARTED, plupload.STOPPED - * - * @returns {Array} The Plupload file objects matching the status. - */ -phpbb.plupload.getFilesByStatus = function(status) { - var files = []; - - $.each(phpbb.plupload.uploader.files, function(i, file) { - if (file.status === status) { - files.push(file); - } - }); - return files; -}; - -/** - * Check whether the user has reached the maximun number of files that he's allowed - * to upload. If so, disables the uploader and marks the queued files as failed. Otherwise - * makes sure that the uploader is enabled. - * - * @returns {bool} True if the limit has been reached. False if otherwise. - */ -phpbb.plupload.handleMaxFilesReached = function() { - // If there is no limit, the user is an admin or moderator. - if (!phpbb.plupload.maxFiles) { - return false; - } - - if (phpbb.plupload.maxFiles <= phpbb.plupload.ids.length) { - // Fail the rest of the queue. - phpbb.plupload.markQueuedFailed(phpbb.plupload.lang.TOO_MANY_ATTACHMENTS); - // Disable the uploader. - phpbb.plupload.disableUploader(); - phpbb.plupload.uploader.trigger('Error', { message: phpbb.plupload.lang.TOO_MANY_ATTACHMENTS }); - - return true; - } else if (phpbb.plupload.maxFiles > phpbb.plupload.ids.length) { - // Enable the uploader if the user is under the limit - phpbb.plupload.enableUploader(); - } - return false; -}; - -/** - * Disable the uploader - */ -phpbb.plupload.disableUploader = function() { - $('#add_files').addClass('disabled'); - phpbb.plupload.uploader.disableBrowse(); -}; - -/** - * Enable the uploader - */ -phpbb.plupload.enableUploader = function() { - $('#add_files').removeClass('disabled'); - phpbb.plupload.uploader.disableBrowse(false); -}; - -/** - * Mark all queued files as failed. - * - * @param {string} error Error message to present to the user. - */ -phpbb.plupload.markQueuedFailed = function(error) { - var files = phpbb.plupload.getFilesByStatus(plupload.QUEUED); - - $.each(files, function(i, file) { - $('#' + file.id).find('.file-progress').hide(); - phpbb.plupload.fileError(file, error); - }); -}; - -/** - * Marks a file as failed and sets the error message for it. - * - * @param {object} file Plupload file object that failed. - * @param {string} error Error message to present to the user. - */ -phpbb.plupload.fileError = function(file, error) { - file.status = plupload.FAILED; - file.error = error; - $('#' + file.id).find('.file-status') - .addClass('file-error') - .attr({ - 'data-error-title': phpbb.plupload.lang.ERROR, - 'data-error-message': error - }); -}; - - -/** - * Set up the Plupload object and get some basic data. - */ -phpbb.plupload.uploader = new plupload.Uploader(phpbb.plupload.config); -phpbb.plupload.initialize(); - -/** - * Add a file filter to check for max file sizes per mime type. - */ -plupload.addFileFilter('mime_types_max_file_size', function(types, file, callback) { - if (file.size !== 'undefined') { - $(types).each(function(i, type) { - let extensions = [], - extsArray = type.extensions.split(','); - - $(extsArray).each(function(i, extension) { - /^\s*\*\s*$/.test(extension) ? extensions.push("\\.*") : extensions.push("\\." + extension.replace(new RegExp("[" + "/^$.*+?|()[]{}\\".replace(/./g, "\\$&") + "]", "g"), "\\$&")); - }); - - let regex = new RegExp("(" + extensions.join("|") + ")$", "i"); - - if (regex.test(file.name)) { - if (type.max_file_size !== 'undefined' && type.max_file_size) { - if (file.size > type.max_file_size) { - phpbb.plupload.uploader.trigger('Error', { - code: plupload.FILE_SIZE_ERROR, - message: plupload.translate('File size error.'), - file: file - }); - - callback(false); - } else { - callback(true); - } - } else { - callback(true); - } - - return false; - } - }); - } -}); - -var $fileList = $('#file-list'); - -/** - * Insert inline attachment bbcode. - */ -$fileList.on('click', '.file-inline-bbcode', function(e) { - var attachId = $(this).parents('.attach-row').attr('data-attach-id'), - index = phpbb.plupload.getIndex(attachId); - - attachInline(index, phpbb.plupload.data[index].real_filename); - e.preventDefault(); -}); - -/** - * Delete a file. - */ -$fileList.on('click', '.file-delete', function(e) { - var row = $(this).parents('.attach-row'), - attachId = row.attr('data-attach-id'); - - phpbb.plupload.deleteFile(row, attachId); - e.preventDefault(); -}); - -/** - * Display the error message for a particular file when the error icon is clicked. - */ -$fileList.on('click', '.file-error', function(e) { - phpbb.alert($(this).attr('data-error-title'), $(this).attr('data-error-message')); - e.preventDefault(); -}); - -/** - * Fires when an error occurs. - */ -phpbb.plupload.uploader.bind('Error', function(up, error) { - error.file.name = plupload.xmlEncode(error.file.name); - - // The error message that Plupload provides for these is vague, so we'll be more specific. - if (error.code === plupload.FILE_EXTENSION_ERROR) { - error.message = plupload.translate('Invalid file extension:') + ' ' + error.file.name; - } else if (error.code === plupload.FILE_SIZE_ERROR) { - error.message = plupload.translate('File too large:') + ' ' + error.file.name; - } - phpbb.alert(phpbb.plupload.lang.ERROR, error.message); -}); - -/** - * Fires before a given file is about to be uploaded. This allows us to - * send the real filename along with the chunk. This is necessary because - * for some reason the filename is set to 'blob' whenever a file is chunked - * - * @param {object} up The plupload.Uploader object - * @param {object} file The plupload.File object that is about to be uploaded - */ -phpbb.plupload.uploader.bind('BeforeUpload', function(up, file) { - if (phpbb.plupload.handleMaxFilesReached()) { - return; - } - - phpbb.plupload.updateMultipartParams({ real_filename: file.name }); -}); - -/** - * Fired when a single chunk of any given file is uploaded. This parses the - * response from the server and checks for an error. If an error occurs it - * is reported to the user and the upload of this particular file is halted - * - * @param {object} up The plupload.Uploader object - * @param {object} file The plupload.File object whose chunk has just - * been uploaded - * @param {object} response The response object from the server - */ -phpbb.plupload.uploader.bind('ChunkUploaded', function(up, file, response) { - if (response.chunk >= response.chunks - 1) { - return; - } - - var json = {}; - try { - json = $.parseJSON(response.response); - } catch (e) { - file.status = plupload.FAILED; - up.trigger('FileUploaded', file, { - response: JSON.stringify({ - error: { - message: 'Error parsing server response.' - } - }) - }); - } - - // If trigger_error() was called, then a permission error likely occurred. - if (typeof json.title !== 'undefined') { - json.error = { message: json.message }; - } - - if (json.error) { - file.status = plupload.FAILED; - up.trigger('FileUploaded', file, { - response: JSON.stringify({ - error: { - message: json.error.message - } - }) - }); - } -}); - -/** - * Fires when files are added to the queue. - */ -phpbb.plupload.uploader.bind('FilesAdded', function(up, files) { - // Prevent unnecessary requests to the server if the user already uploaded - // the maximum number of files allowed. - if (phpbb.plupload.handleMaxFilesReached()) { - return; - } - - // Switch the active tab if the style supports it - if (typeof activateSubPanel === 'function') { - activateSubPanel('attach-panel'); // jshint ignore: line - } - - // Show the file list if there aren't any files currently. - var $fileListContainer = $('#file-list-container'); - if (!$fileListContainer.is(':visible')) { - $fileListContainer.show(100); - } - - $.each(files, function(i, file) { - phpbb.plupload.insertRow(file); - }); - - up.bind('UploadProgress', function(up, file) { - $('.file-progress-bar', '#' + file.id).css('width', file.percent + '%'); - $('#file-total-progress-bar').css('width', up.total.percent + '%'); - }); - - // Do not allow more files to be added to the running queue. - phpbb.plupload.disableUploader(); - - // Start uploading the files once the user has selected them. - up.start(); -}); - - -/** - * Fires when an entire file has been uploaded. It checks for errors - * returned by the server otherwise parses the list of attachment data and - * appends it to the next file upload so that the server can maintain state - * with regards to the attachments in a given post - * - * @param {object} up The plupload.Uploader object - * @param {object} file The plupload.File object that has just been - * uploaded - * @param {string} response The response string from the server - */ -phpbb.plupload.uploader.bind('FileUploaded', function(up, file, response) { - var json = {}, - row = $('#' + file.id), - error; - - // Hide the progress indicator. - row.find('.file-progress').hide(); - - try { - json = JSON.parse(response.response); - } catch (e) { - error = 'Error parsing server response.'; - } - - // If trigger_error() was called, then a permission error likely occurred. - if (typeof json.title !== 'undefined') { - error = json.message; - up.trigger('Error', { message: error }); - - // The rest of the queue will fail. - phpbb.plupload.markQueuedFailed(error); - } else if (json.error) { - error = json.error.message; - } - - if (typeof error !== 'undefined') { - phpbb.plupload.fileError(file, error); - } else if (file.status === plupload.DONE) { - file.attachment_data = json.data[0]; - - row.attr('data-attach-id', file.attachment_data.attach_id); - row.find('.file-inline-bbcode').show(); - row.find('.file-status').addClass('file-uploaded'); - phpbb.plupload.update(json.data, 'addition', 0, [json.download_url]); - } -}); - -/** - * Fires when the entire queue of files have been uploaded. - */ -phpbb.plupload.uploader.bind('UploadComplete', function() { - // Hide the progress bar - setTimeout(function() { - $('#file-total-progress-bar').fadeOut(500, function() { - $(this).css('width', 0).show(); - }); - }, 2000); - - // Re-enable the uploader - phpbb.plupload.enableUploader(); -}); - -})(jQuery); // Avoid conflicts with other libraries diff --git a/install/update/new/common.php b/install/update/new/common.php deleted file mode 100644 index e25274d..0000000 --- a/install/update/new/common.php +++ /dev/null @@ -1,166 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* Minimum Requirement: PHP 7.1.3 -*/ - -if (!defined('IN_PHPBB')) -{ - exit; -} - -require($phpbb_root_path . 'includes/startup.' . $phpEx); -require($phpbb_root_path . 'phpbb/class_loader.' . $phpEx); - -$phpbb_class_loader = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}phpbb/", $phpEx); -$phpbb_class_loader->register(); - -$phpbb_config_php_file = new \phpbb\config_php_file($phpbb_root_path, $phpEx); -extract($phpbb_config_php_file->get_all()); - -if (!defined('PHPBB_ENVIRONMENT')) -{ - @define('PHPBB_ENVIRONMENT', 'production'); -} - -if (!defined('PHPBB_INSTALLED')) -{ - // Redirect the user to the installer - require($phpbb_root_path . 'includes/functions.' . $phpEx); - - // We have to generate a full HTTP/1.1 header here since we can't guarantee to have any of the information - // available as used by the redirect function - $server_name = (!empty($_SERVER['HTTP_HOST'])) ? strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME')); - $server_port = (!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT'); - $secure = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 1 : 0; - - if (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') - { - $secure = 1; - $server_port = 443; - } - - $script_name = (!empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : getenv('PHP_SELF'); - if (!$script_name) - { - $script_name = (!empty($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : getenv('REQUEST_URI'); - } - - // $phpbb_root_path accounts for redirects from e.g. /adm - $script_path = trim(dirname($script_name)) . '/' . $phpbb_root_path . 'install/app.' . $phpEx; - // Replace any number of consecutive backslashes and/or slashes with a single slash - // (could happen on some proxy setups and/or Windows servers) - $script_path = preg_replace('#[\\\\/]{2,}#', '/', $script_path); - - // Eliminate . and .. from the path - require($phpbb_root_path . 'phpbb/filesystem.' . $phpEx); - $phpbb_filesystem = new phpbb\filesystem\filesystem(); - $script_path = $phpbb_filesystem->clean_path($script_path); - - $url = (($secure) ? 'https://' : 'http://') . $server_name; - - if ($server_port && (($secure && $server_port <> 443) || (!$secure && $server_port <> 80))) - { - // HTTP HOST can carry a port number... - if (strpos($server_name, ':') === false) - { - $url .= ':' . $server_port; - } - } - - $url .= $script_path; - header('Location: ' . $url); - exit; -} - -// In case $phpbb_adm_relative_path is not set (in case of an update), use the default. -$phpbb_adm_relative_path = (isset($phpbb_adm_relative_path)) ? $phpbb_adm_relative_path : 'adm/'; -$phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : $phpbb_root_path . $phpbb_adm_relative_path; - -// Include files -require($phpbb_root_path . 'includes/functions.' . $phpEx); -require($phpbb_root_path . 'includes/functions_content.' . $phpEx); -include($phpbb_root_path . 'includes/functions_compatibility.' . $phpEx); - -require($phpbb_root_path . 'includes/constants.' . $phpEx); -require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); - -if (PHPBB_ENVIRONMENT === 'development') -{ - \phpbb\debug\debug::enable(); -} -else -{ - set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); -} - -$phpbb_class_loader_ext = new \phpbb\class_loader('\\', "{$phpbb_root_path}ext/", $phpEx); -$phpbb_class_loader_ext->register(); - -// Set up container -try -{ - $phpbb_container_builder = new \phpbb\di\container_builder($phpbb_root_path, $phpEx); - $phpbb_container = $phpbb_container_builder->with_config($phpbb_config_php_file)->get_container(); -} -catch (InvalidArgumentException $e) -{ - if (PHPBB_ENVIRONMENT !== 'development') - { - trigger_error( - 'The requested environment ' . PHPBB_ENVIRONMENT . ' is not available.', - E_USER_ERROR - ); - } - else - { - throw $e; - } -} - -$phpbb_class_loader->set_cache($phpbb_container->get('cache.driver')); -$phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver')); - -$phpbb_container->get('dbal.conn')->set_debug_sql_explain($phpbb_container->getParameter('debug.sql_explain')); -$phpbb_container->get('dbal.conn')->set_debug_load_time($phpbb_container->getParameter('debug.load_time')); -require($phpbb_root_path . 'includes/compatibility_globals.' . $phpEx); - -register_compatibility_globals(); - -// Add own hook handler -require($phpbb_root_path . 'includes/hooks/index.' . $phpEx); -$phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display'))); - -/* @var $phpbb_hook_finder \phpbb\hook\finder */ -$phpbb_hook_finder = $phpbb_container->get('hook_finder'); - -foreach ($phpbb_hook_finder->find() as $hook) -{ - @include($phpbb_root_path . 'includes/hooks/' . $hook . '.' . $phpEx); -} - -/** -* Main event which is triggered on every page -* -* You can use this event to load function files and initiate objects -* -* NOTE: At this point the global session ($user) and permissions ($auth) -* do NOT exist yet. If you need to use the user object -* (f.e. to include language files) or need to check permissions, -* please use the core.user_setup event instead! -* -* @event core.common -* @since 3.1.0-a1 -*/ -$phpbb_dispatcher->dispatch('core.common'); diff --git a/install/update/new/composer.json b/install/update/new/composer.json deleted file mode 100644 index 57c7d74..0000000 --- a/install/update/new/composer.json +++ /dev/null @@ -1,76 +0,0 @@ -{ - "name": "phpbb/phpbb", - "description": "phpBB Forum Software application", - "type": "project", - "keywords": ["phpbb", "forum"], - "homepage": "https://www.phpbb.com", - "license": "GPL-2.0-only", - "authors": [ - { - "name": "phpBB Limited", - "email": "operations@phpbb.com", - "homepage": "https://www.phpbb.com/go/authors" - } - ], - "support": { - "issues": "https://tracker.phpbb.com", - "forum": "https://www.phpbb.com/community/", - "wiki": "https://wiki.phpbb.com", - "irc": "irc://irc.freenode.org/phpbb" - }, - "scripts": { - "post-update-cmd": "echo 'You MUST manually modify the clean-vendor-dir target in build/build.xml when adding or upgrading dependencies.'" - }, - "replace": { - "phpbb/phpbb-core": "self.version" - }, - "require": { - "php": "^7.1.3", - "ext-json": "*", - "bantu/ini-get-wrapper": "~1.0", - "google/recaptcha": "~1.1", - "guzzlehttp/guzzle": "~6.3", - "lusitanian/oauth": "^0.8.1", - "marc1706/fast-image-size": "^1.1", - "patchwork/utf8": "^1.1", - "s9e/text-formatter": "^2.0", - "symfony/config": "~3.4", - "symfony/console": "~3.4", - "symfony/debug": "~3.4", - "symfony/dependency-injection": "~3.4", - "symfony/event-dispatcher": "~3.4", - "symfony/filesystem": "~3.4", - "symfony/finder": "~3.4", - "symfony/http-foundation": "~3.4", - "symfony/http-kernel": "~3.4", - "symfony/process": "^3.4", - "symfony/proxy-manager-bridge": "~3.4", - "symfony/routing": "~3.4", - "symfony/twig-bridge": "~3.4", - "symfony/yaml": "~3.4", - "twig/twig": "^1.0 || ^2.0" - }, - "require-dev": { - "fabpot/goutte": "~3.2", - "facebook/webdriver": "~1.6", - "laravel/homestead": "~7.0", - "phing/phing": "~2.4", - "phpunit/dbunit": "~4.0", - "phpunit/phpunit": "^7.0", - "squizlabs/php_codesniffer": "~3.4", - "symfony/browser-kit": "~3.4", - "symfony/css-selector": "~3.4", - "symfony/dom-crawler": "~3.4", - "sami/sami": "^4.1" - }, - "extra": { - "branch-alias": { - "dev-master": "3.3.x-dev" - } - }, - "config": { - "platform": { - "php": "7.1.3" - } - } -} diff --git a/install/update/new/composer.lock b/install/update/new/composer.lock deleted file mode 100644 index 272c0fb..0000000 --- a/install/update/new/composer.lock +++ /dev/null @@ -1,4410 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", - "This file is @generated automatically" - ], - "content-hash": "bbbc187ca0c5d8f13e6358d529412446", - "packages": [ - { - "name": "bantu/ini-get-wrapper", - "version": "v1.0.1", - "source": { - "type": "git", - "url": "https://github.com/bantuXorg/php-ini-get-wrapper.git", - "reference": "4770c7feab370c62e23db4f31c112b7c6d90aee2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/bantuXorg/php-ini-get-wrapper/zipball/4770c7feab370c62e23db4f31c112b7c6d90aee2", - "reference": "4770c7feab370c62e23db4f31c112b7c6d90aee2", - "shasum": "" - }, - "require-dev": { - "phpunit/phpunit": "3.7.*" - }, - "type": "library", - "autoload": { - "psr-4": { - "bantu\\IniGetWrapper\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Convenience wrapper around ini_get()", - "time": "2014-09-15T13:12:35+00:00" - }, - { - "name": "google/recaptcha", - "version": "1.2.3", - "source": { - "type": "git", - "url": "https://github.com/google/recaptcha.git", - "reference": "98c4a6573b27e8b0990ea8789c74ea378795134c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/google/recaptcha/zipball/98c4a6573b27e8b0990ea8789c74ea378795134c", - "reference": "98c4a6573b27e8b0990ea8789c74ea378795134c", - "shasum": "" - }, - "require": { - "php": ">=5.5" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^2.2.20|^2.15", - "php-coveralls/php-coveralls": "^2.1", - "phpunit/phpunit": "^4.8.36|^5.7.27|^6.59|^7.5.11" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, - "autoload": { - "psr-4": { - "ReCaptcha\\": "src/ReCaptcha" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "description": "Client library for reCAPTCHA, a free service that protects websites from spam and abuse.", - "homepage": "https://www.google.com/recaptcha/", - "keywords": [ - "Abuse", - "captcha", - "recaptcha", - "spam" - ], - "time": "2019-08-16T15:48:25+00:00" - }, - { - "name": "guzzlehttp/guzzle", - "version": "6.5.2", - "source": { - "type": "git", - "url": "https://github.com/guzzle/guzzle.git", - "reference": "43ece0e75098b7ecd8d13918293029e555a50f82" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/43ece0e75098b7ecd8d13918293029e555a50f82", - "reference": "43ece0e75098b7ecd8d13918293029e555a50f82", - "shasum": "" - }, - "require": { - "ext-json": "*", - "guzzlehttp/promises": "^1.0", - "guzzlehttp/psr7": "^1.6.1", - "php": ">=5.5" - }, - "require-dev": { - "ext-curl": "*", - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0", - "psr/log": "^1.1" - }, - "suggest": { - "ext-intl": "Required for Internationalized Domain Name (IDN) support", - "psr/log": "Required for using the Log middleware" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "6.5-dev" - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\": "src/" - }, - "files": [ - "src/functions_include.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "description": "Guzzle is a PHP HTTP client library", - "homepage": "http://guzzlephp.org/", - "keywords": [ - "client", - "curl", - "framework", - "http", - "http client", - "rest", - "web service" - ], - "time": "2019-12-23T11:57:10+00:00" - }, - { - "name": "guzzlehttp/promises", - "version": "v1.3.1", - "source": { - "type": "git", - "url": "https://github.com/guzzle/promises.git", - "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/a59da6cf61d80060647ff4d3eb2c03a2bc694646", - "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646", - "shasum": "" - }, - "require": { - "php": ">=5.5.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4-dev" - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\Promise\\": "src/" - }, - "files": [ - "src/functions_include.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "description": "Guzzle promises library", - "keywords": [ - "promise" - ], - "time": "2016-12-20T10:07:11+00:00" - }, - { - "name": "guzzlehttp/psr7", - "version": "1.6.1", - "source": { - "type": "git", - "url": "https://github.com/guzzle/psr7.git", - "reference": "239400de7a173fe9901b9ac7c06497751f00727a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/239400de7a173fe9901b9ac7c06497751f00727a", - "reference": "239400de7a173fe9901b9ac7c06497751f00727a", - "shasum": "" - }, - "require": { - "php": ">=5.4.0", - "psr/http-message": "~1.0", - "ralouphie/getallheaders": "^2.0.5 || ^3.0.0" - }, - "provide": { - "psr/http-message-implementation": "1.0" - }, - "require-dev": { - "ext-zlib": "*", - "phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.8" - }, - "suggest": { - "zendframework/zend-httphandlerrunner": "Emit PSR-7 responses" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.6-dev" - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\Psr7\\": "src/" - }, - "files": [ - "src/functions_include.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - }, - { - "name": "Tobias Schultze", - "homepage": "https://github.com/Tobion" - } - ], - "description": "PSR-7 message implementation that also provides common utility methods", - "keywords": [ - "http", - "message", - "psr-7", - "request", - "response", - "stream", - "uri", - "url" - ], - "time": "2019-07-01T23:21:34+00:00" - }, - { - "name": "lusitanian/oauth", - "version": "v0.8.11", - "source": { - "type": "git", - "url": "https://github.com/Lusitanian/PHPoAuthLib.git", - "reference": "fc11a53db4b66da555a6a11fce294f574a8374f9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Lusitanian/PHPoAuthLib/zipball/fc11a53db4b66da555a6a11fce294f574a8374f9", - "reference": "fc11a53db4b66da555a6a11fce294f574a8374f9", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "require-dev": { - "phpunit/phpunit": "3.7.*", - "predis/predis": "0.8.*@dev", - "squizlabs/php_codesniffer": "2.*", - "symfony/http-foundation": "~2.1" - }, - "suggest": { - "ext-openssl": "Allows for usage of secure connections with the stream-based HTTP client.", - "predis/predis": "Allows using the Redis storage backend.", - "symfony/http-foundation": "Allows using the Symfony Session storage backend." - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "0.1-dev" - } - }, - "autoload": { - "psr-0": { - "OAuth": "src", - "OAuth\\Unit": "tests" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "David Desberg", - "email": "david@daviddesberg.com" - }, - { - "name": "Elliot Chance", - "email": "elliotchance@gmail.com" - }, - { - "name": "Pieter Hordijk", - "email": "info@pieterhordijk.com" - } - ], - "description": "PHP 5.3+ oAuth 1/2 Library", - "keywords": [ - "Authentication", - "authorization", - "oauth", - "security" - ], - "time": "2016-07-12T22:15:00+00:00" - }, - { - "name": "marc1706/fast-image-size", - "version": "v1.1.6", - "source": { - "type": "git", - "url": "https://github.com/marc1706/fast-image-size.git", - "reference": "3a3a2b036be20f43fa06ce00dfa754df503e6684" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/marc1706/fast-image-size/zipball/3a3a2b036be20f43fa06ce00dfa754df503e6684", - "reference": "3a3a2b036be20f43fa06ce00dfa754df503e6684", - "shasum": "" - }, - "require": { - "ext-mbstring": "*", - "php": ">=5.3.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.8" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1.x-dev" - } - }, - "autoload": { - "psr-4": { - "FastImageSize\\": "lib", - "FastImageSize\\tests\\": "tests" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Marc Alexander", - "email": "admin@m-a-styles.de", - "homepage": "https://www.m-a-styles.de", - "role": "Developer" - } - ], - "description": "fast-image-size is a PHP library that does almost everything PHP's getimagesize() does but without the large overhead of downloading the complete file.", - "homepage": "https://www.m-a-styles.de", - "keywords": [ - "fast", - "getimagesize", - "image", - "imagesize", - "php", - "size" - ], - "time": "2019-12-07T08:02:07+00:00" - }, - { - "name": "ocramius/package-versions", - "version": "1.4.2", - "source": { - "type": "git", - "url": "https://github.com/Ocramius/PackageVersions.git", - "reference": "44af6f3a2e2e04f2af46bcb302ad9600cba41c7d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Ocramius/PackageVersions/zipball/44af6f3a2e2e04f2af46bcb302ad9600cba41c7d", - "reference": "44af6f3a2e2e04f2af46bcb302ad9600cba41c7d", - "shasum": "" - }, - "require": { - "composer-plugin-api": "^1.0.0", - "php": "^7.1.0" - }, - "require-dev": { - "composer/composer": "^1.6.3", - "doctrine/coding-standard": "^5.0.1", - "ext-zip": "*", - "infection/infection": "^0.7.1", - "phpunit/phpunit": "^7.5.17" - }, - "type": "composer-plugin", - "extra": { - "class": "PackageVersions\\Installer", - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "PackageVersions\\": "src/PackageVersions" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com" - } - ], - "description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)", - "time": "2019-11-15T16:17:10+00:00" - }, - { - "name": "ocramius/proxy-manager", - "version": "2.1.1", - "source": { - "type": "git", - "url": "https://github.com/Ocramius/ProxyManager.git", - "reference": "e18ac876b2e4819c76349de8f78ccc8ef1554cd7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Ocramius/ProxyManager/zipball/e18ac876b2e4819c76349de8f78ccc8ef1554cd7", - "reference": "e18ac876b2e4819c76349de8f78ccc8ef1554cd7", - "shasum": "" - }, - "require": { - "ocramius/package-versions": "^1.1.1", - "php": "^7.1.0", - "zendframework/zend-code": "^3.1.0" - }, - "require-dev": { - "couscous/couscous": "^1.5.2", - "ext-phar": "*", - "humbug/humbug": "dev-master@DEV", - "nikic/php-parser": "^3.0.4", - "phpbench/phpbench": "^0.12.2", - "phpstan/phpstan": "^0.6.4", - "phpunit/phpunit": "^5.6.4", - "phpunit/phpunit-mock-objects": "^3.4.1", - "squizlabs/php_codesniffer": "^2.7.0" - }, - "suggest": { - "ocramius/generated-hydrator": "To have very fast object to array to object conversion for ghost objects", - "zendframework/zend-json": "To have the JsonRpc adapter (Remote Object feature)", - "zendframework/zend-soap": "To have the Soap adapter (Remote Object feature)", - "zendframework/zend-xmlrpc": "To have the XmlRpc adapter (Remote Object feature)" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0.x-dev" - } - }, - "autoload": { - "psr-0": { - "ProxyManager\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com", - "homepage": "http://ocramius.github.io/" - } - ], - "description": "A library providing utilities to generate, instantiate and generally operate with Object Proxies", - "homepage": "https://github.com/Ocramius/ProxyManager", - "keywords": [ - "aop", - "lazy loading", - "proxy", - "proxy pattern", - "service proxies" - ], - "time": "2017-05-04T11:12:50+00:00" - }, - { - "name": "paragonie/random_compat", - "version": "v9.99.99", - "source": { - "type": "git", - "url": "https://github.com/paragonie/random_compat.git", - "reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/paragonie/random_compat/zipball/84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95", - "reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95", - "shasum": "" - }, - "require": { - "php": "^7" - }, - "require-dev": { - "phpunit/phpunit": "4.*|5.*", - "vimeo/psalm": "^1" - }, - "suggest": { - "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." - }, - "type": "library", - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Paragon Initiative Enterprises", - "email": "security@paragonie.com", - "homepage": "https://paragonie.com" - } - ], - "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", - "keywords": [ - "csprng", - "polyfill", - "pseudorandom", - "random" - ], - "time": "2018-07-02T15:55:56+00:00" - }, - { - "name": "patchwork/utf8", - "version": "v1.3.2", - "source": { - "type": "git", - "url": "https://github.com/tchwork/utf8.git", - "reference": "d296e0026e7ce10b2a9fe594feca9628ef00e9e8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/tchwork/utf8/zipball/d296e0026e7ce10b2a9fe594feca9628ef00e9e8", - "reference": "d296e0026e7ce10b2a9fe594feca9628ef00e9e8", - "shasum": "" - }, - "require": { - "lib-pcre": ">=7.3", - "php": ">=5.3.0" - }, - "require-dev": { - "symfony/phpunit-bridge": "^3.4|^4.4" - }, - "suggest": { - "ext-iconv": "Use iconv for best performance", - "ext-intl": "Use Intl for best performance", - "ext-mbstring": "Use Mbstring for best performance", - "ext-wfio": "Use WFIO for UTF-8 filesystem access on Windows" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3-dev" - } - }, - "autoload": { - "psr-4": { - "Patchwork\\": "src/Patchwork/" - }, - "classmap": [ - "src/Normalizer.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "(Apache-2.0 or GPL-2.0)" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - } - ], - "description": "Portable and performant UTF-8, Unicode and Grapheme Clusters for PHP", - "homepage": "https://github.com/tchwork/utf8", - "keywords": [ - "grapheme", - "i18n", - "unicode", - "utf-8", - "utf8" - ], - "time": "2019-12-03T14:44:12+00:00" - }, - { - "name": "psr/container", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/container.git", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Container\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common Container Interface (PHP FIG PSR-11)", - "homepage": "https://github.com/php-fig/container", - "keywords": [ - "PSR-11", - "container", - "container-interface", - "container-interop", - "psr" - ], - "time": "2017-02-14T16:28:37+00:00" - }, - { - "name": "psr/http-message", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/php-fig/http-message.git", - "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", - "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Http\\Message\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for HTTP messages", - "homepage": "https://github.com/php-fig/http-message", - "keywords": [ - "http", - "http-message", - "psr", - "psr-7", - "request", - "response" - ], - "time": "2016-08-06T14:39:51+00:00" - }, - { - "name": "psr/log", - "version": "1.1.2", - "source": { - "type": "git", - "url": "https://github.com/php-fig/log.git", - "reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/446d54b4cb6bf489fc9d75f55843658e6f25d801", - "reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Log\\": "Psr/Log/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for logging libraries", - "homepage": "https://github.com/php-fig/log", - "keywords": [ - "log", - "psr", - "psr-3" - ], - "time": "2019-11-01T11:05:21+00:00" - }, - { - "name": "ralouphie/getallheaders", - "version": "3.0.3", - "source": { - "type": "git", - "url": "https://github.com/ralouphie/getallheaders.git", - "reference": "120b605dfeb996808c31b6477290a714d356e822" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", - "reference": "120b605dfeb996808c31b6477290a714d356e822", - "shasum": "" - }, - "require": { - "php": ">=5.6" - }, - "require-dev": { - "php-coveralls/php-coveralls": "^2.1", - "phpunit/phpunit": "^5 || ^6.5" - }, - "type": "library", - "autoload": { - "files": [ - "src/getallheaders.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ralph Khattar", - "email": "ralph.khattar@gmail.com" - } - ], - "description": "A polyfill for getallheaders.", - "time": "2019-03-08T08:55:37+00:00" - }, - { - "name": "s9e/regexp-builder", - "version": "1.4.3", - "source": { - "type": "git", - "url": "https://github.com/s9e/RegexpBuilder.git", - "reference": "59d0167a909659d718f53964f7653d2c83a5f8fe" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/s9e/RegexpBuilder/zipball/59d0167a909659d718f53964f7653d2c83a5f8fe", - "reference": "59d0167a909659d718f53964f7653d2c83a5f8fe", - "shasum": "" - }, - "require": { - "lib-pcre": ">=7.2", - "php": ">=5.5.1" - }, - "require-dev": { - "phpunit/phpunit": "<5.8" - }, - "type": "library", - "autoload": { - "psr-4": { - "s9e\\RegexpBuilder\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Single-purpose library that generates regular expressions that match a list of strings.", - "homepage": "https://github.com/s9e/RegexpBuilder/", - "keywords": [ - "regexp" - ], - "time": "2019-04-26T17:55:23+00:00" - }, - { - "name": "s9e/text-formatter", - "version": "2.3.1", - "source": { - "type": "git", - "url": "https://github.com/s9e/TextFormatter.git", - "reference": "65a0605f163b8ffcf7145357f167b153f31cd168" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/s9e/TextFormatter/zipball/65a0605f163b8ffcf7145357f167b153f31cd168", - "reference": "65a0605f163b8ffcf7145357f167b153f31cd168", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-filter": "*", - "lib-pcre": ">=8.13", - "php": ">=7.1", - "s9e/regexp-builder": "^1.4" - }, - "require-dev": { - "matthiasmullie/minify": "*", - "phpunit/phpunit": "^7 || 8.2.*" - }, - "suggest": { - "ext-curl": "Improves the performance of the MediaEmbed plugin and some JavaScript minifiers", - "ext-intl": "Allows international URLs to be accepted by the URL filter", - "ext-json": "Enables the generation of a JavaScript parser", - "ext-mbstring": "Improves the performance of the PHP renderer", - "ext-tokenizer": "Improves the performance of the PHP renderer", - "ext-xsl": "Enables the XSLT renderer", - "ext-zlib": "Enables gzip compression when scraping content via the MediaEmbed plugin" - }, - "type": "library", - "extra": { - "version": "2.3.1" - }, - "autoload": { - "psr-4": { - "s9e\\TextFormatter\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Multi-purpose text formatting and markup library. Plugins offer support for BBCodes, Markdown, emoticons, HTML, embedding media (YouTube, etc...), enhanced typography and more.", - "homepage": "https://github.com/s9e/TextFormatter/", - "keywords": [ - "bbcode", - "bbcodes", - "blog", - "censor", - "embed", - "emoji", - "emoticons", - "engine", - "forum", - "html", - "markdown", - "markup", - "media", - "parser", - "shortcodes" - ], - "time": "2019-12-26T19:14:01+00:00" - }, - { - "name": "symfony/config", - "version": "v3.4.36", - "source": { - "type": "git", - "url": "https://github.com/symfony/config.git", - "reference": "a599a867d0e4a07c342b5f1e656b3915a540ddbe" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/a599a867d0e4a07c342b5f1e656b3915a540ddbe", - "reference": "a599a867d0e4a07c342b5f1e656b3915a540ddbe", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8", - "symfony/filesystem": "~2.8|~3.0|~4.0", - "symfony/polyfill-ctype": "~1.8" - }, - "conflict": { - "symfony/dependency-injection": "<3.3", - "symfony/finder": "<3.3" - }, - "require-dev": { - "symfony/dependency-injection": "~3.3|~4.0", - "symfony/event-dispatcher": "~3.3|~4.0", - "symfony/finder": "~3.3|~4.0", - "symfony/yaml": "~3.0|~4.0" - }, - "suggest": { - "symfony/yaml": "To use the yaml reference dumper" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Config\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Config Component", - "homepage": "https://symfony.com", - "time": "2019-12-01T10:45:41+00:00" - }, - { - "name": "symfony/console", - "version": "v3.4.36", - "source": { - "type": "git", - "url": "https://github.com/symfony/console.git", - "reference": "1ee23b3b659b06c622f2bd2492a229e416eb4586" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/1ee23b3b659b06c622f2bd2492a229e416eb4586", - "reference": "1ee23b3b659b06c622f2bd2492a229e416eb4586", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8", - "symfony/debug": "~2.8|~3.0|~4.0", - "symfony/polyfill-mbstring": "~1.0" - }, - "conflict": { - "symfony/dependency-injection": "<3.4", - "symfony/process": "<3.3" - }, - "provide": { - "psr/log-implementation": "1.0" - }, - "require-dev": { - "psr/log": "~1.0", - "symfony/config": "~3.3|~4.0", - "symfony/dependency-injection": "~3.4|~4.0", - "symfony/event-dispatcher": "~2.8|~3.0|~4.0", - "symfony/lock": "~3.4|~4.0", - "symfony/process": "~3.3|~4.0" - }, - "suggest": { - "psr/log": "For using the console logger", - "symfony/event-dispatcher": "", - "symfony/lock": "", - "symfony/process": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Console\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Console Component", - "homepage": "https://symfony.com", - "time": "2019-12-01T10:04:45+00:00" - }, - { - "name": "symfony/debug", - "version": "v3.4.36", - "source": { - "type": "git", - "url": "https://github.com/symfony/debug.git", - "reference": "f72e33fdb1170b326e72c3157f0cd456351dd086" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/f72e33fdb1170b326e72c3157f0cd456351dd086", - "reference": "f72e33fdb1170b326e72c3157f0cd456351dd086", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8", - "psr/log": "~1.0" - }, - "conflict": { - "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" - }, - "require-dev": { - "symfony/http-kernel": "~2.8|~3.0|~4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Debug\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Debug Component", - "homepage": "https://symfony.com", - "time": "2019-10-24T15:33:53+00:00" - }, - { - "name": "symfony/dependency-injection", - "version": "v3.4.36", - "source": { - "type": "git", - "url": "https://github.com/symfony/dependency-injection.git", - "reference": "0d201916bfb3af939fec3c0c8815ea16c60ac1a2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/0d201916bfb3af939fec3c0c8815ea16c60ac1a2", - "reference": "0d201916bfb3af939fec3c0c8815ea16c60ac1a2", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8", - "psr/container": "^1.0" - }, - "conflict": { - "symfony/config": "<3.3.7", - "symfony/finder": "<3.3", - "symfony/proxy-manager-bridge": "<3.4", - "symfony/yaml": "<3.4" - }, - "provide": { - "psr/container-implementation": "1.0" - }, - "require-dev": { - "symfony/config": "~3.3|~4.0", - "symfony/expression-language": "~2.8|~3.0|~4.0", - "symfony/yaml": "~3.4|~4.0" - }, - "suggest": { - "symfony/config": "", - "symfony/expression-language": "For using expressions in service container configuration", - "symfony/finder": "For using double-star glob patterns or when GLOB_BRACE portability is required", - "symfony/proxy-manager-bridge": "Generate service proxies to lazy load them", - "symfony/yaml": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\DependencyInjection\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony DependencyInjection Component", - "homepage": "https://symfony.com", - "time": "2019-12-01T08:33:36+00:00" - }, - { - "name": "symfony/event-dispatcher", - "version": "v3.4.36", - "source": { - "type": "git", - "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "f9031c22ec127d4a2450760f81a8677fe8a10177" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/f9031c22ec127d4a2450760f81a8677fe8a10177", - "reference": "f9031c22ec127d4a2450760f81a8677fe8a10177", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8" - }, - "conflict": { - "symfony/dependency-injection": "<3.3" - }, - "require-dev": { - "psr/log": "~1.0", - "symfony/config": "~2.8|~3.0|~4.0", - "symfony/dependency-injection": "~3.3|~4.0", - "symfony/expression-language": "~2.8|~3.0|~4.0", - "symfony/stopwatch": "~2.8|~3.0|~4.0" - }, - "suggest": { - "symfony/dependency-injection": "", - "symfony/http-kernel": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\EventDispatcher\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony EventDispatcher Component", - "homepage": "https://symfony.com", - "time": "2019-10-24T15:33:53+00:00" - }, - { - "name": "symfony/filesystem", - "version": "v3.4.36", - "source": { - "type": "git", - "url": "https://github.com/symfony/filesystem.git", - "reference": "00cdad0936d06fab136944bc2342b762b1c3a4a2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/00cdad0936d06fab136944bc2342b762b1c3a4a2", - "reference": "00cdad0936d06fab136944bc2342b762b1c3a4a2", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8", - "symfony/polyfill-ctype": "~1.8" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Filesystem\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Filesystem Component", - "homepage": "https://symfony.com", - "time": "2019-11-25T16:36:22+00:00" - }, - { - "name": "symfony/finder", - "version": "v3.4.36", - "source": { - "type": "git", - "url": "https://github.com/symfony/finder.git", - "reference": "290ae21279b37bfd287cdcce640d51204e84afdf" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/290ae21279b37bfd287cdcce640d51204e84afdf", - "reference": "290ae21279b37bfd287cdcce640d51204e84afdf", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Finder\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Finder Component", - "homepage": "https://symfony.com", - "time": "2019-11-17T21:55:15+00:00" - }, - { - "name": "symfony/http-foundation", - "version": "v3.4.36", - "source": { - "type": "git", - "url": "https://github.com/symfony/http-foundation.git", - "reference": "d2d0cfe8e319d9df44c4cca570710fcf221d4593" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/d2d0cfe8e319d9df44c4cca570710fcf221d4593", - "reference": "d2d0cfe8e319d9df44c4cca570710fcf221d4593", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8", - "symfony/polyfill-mbstring": "~1.1", - "symfony/polyfill-php70": "~1.6" - }, - "require-dev": { - "symfony/expression-language": "~2.8|~3.0|~4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\HttpFoundation\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony HttpFoundation Component", - "homepage": "https://symfony.com", - "time": "2019-11-28T12:52:59+00:00" - }, - { - "name": "symfony/http-kernel", - "version": "v3.4.36", - "source": { - "type": "git", - "url": "https://github.com/symfony/http-kernel.git", - "reference": "c42c8339acb28cfff0fb1786948db4d23d609ff7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/c42c8339acb28cfff0fb1786948db4d23d609ff7", - "reference": "c42c8339acb28cfff0fb1786948db4d23d609ff7", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8", - "psr/log": "~1.0", - "symfony/debug": "^3.3.3|~4.0", - "symfony/event-dispatcher": "~2.8|~3.0|~4.0", - "symfony/http-foundation": "~3.4.12|~4.0.12|^4.1.1", - "symfony/polyfill-ctype": "~1.8", - "symfony/polyfill-php56": "~1.8" - }, - "conflict": { - "symfony/config": "<2.8", - "symfony/dependency-injection": "<3.4.10|<4.0.10,>=4", - "symfony/var-dumper": "<3.3", - "twig/twig": "<1.34|<2.4,>=2" - }, - "provide": { - "psr/log-implementation": "1.0" - }, - "require-dev": { - "psr/cache": "~1.0", - "symfony/browser-kit": "~2.8|~3.0|~4.0", - "symfony/class-loader": "~2.8|~3.0", - "symfony/config": "~2.8|~3.0|~4.0", - "symfony/console": "~2.8|~3.0|~4.0", - "symfony/css-selector": "~2.8|~3.0|~4.0", - "symfony/dependency-injection": "^3.4.10|^4.0.10", - "symfony/dom-crawler": "~2.8|~3.0|~4.0", - "symfony/expression-language": "~2.8|~3.0|~4.0", - "symfony/finder": "~2.8|~3.0|~4.0", - "symfony/process": "~2.8|~3.0|~4.0", - "symfony/routing": "~3.4|~4.0", - "symfony/stopwatch": "~2.8|~3.0|~4.0", - "symfony/templating": "~2.8|~3.0|~4.0", - "symfony/translation": "~2.8|~3.0|~4.0", - "symfony/var-dumper": "~3.3|~4.0" - }, - "suggest": { - "symfony/browser-kit": "", - "symfony/config": "", - "symfony/console": "", - "symfony/dependency-injection": "", - "symfony/finder": "", - "symfony/var-dumper": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\HttpKernel\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony HttpKernel Component", - "homepage": "https://symfony.com", - "time": "2019-12-01T13:50:37+00:00" - }, - { - "name": "symfony/polyfill-ctype", - "version": "v1.13.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/f8f0b461be3385e56d6de3dbb5a0df24c0c275e3", - "reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "suggest": { - "ext-ctype": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.13-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Ctype\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Gert de Pagter", - "email": "BackEndTea@gmail.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for ctype functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "ctype", - "polyfill", - "portable" - ], - "time": "2019-11-27T13:56:44+00:00" - }, - { - "name": "symfony/polyfill-mbstring", - "version": "v1.13.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "7b4aab9743c30be783b73de055d24a39cf4b954f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/7b4aab9743c30be783b73de055d24a39cf4b954f", - "reference": "7b4aab9743c30be783b73de055d24a39cf4b954f", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "suggest": { - "ext-mbstring": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.13-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Mbstring\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for the Mbstring extension", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "mbstring", - "polyfill", - "portable", - "shim" - ], - "time": "2019-11-27T14:18:11+00:00" - }, - { - "name": "symfony/polyfill-php56", - "version": "v1.13.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php56.git", - "reference": "53dd1cdf3cb986893ccf2b96665b25b3abb384f4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php56/zipball/53dd1cdf3cb986893ccf2b96665b25b3abb384f4", - "reference": "53dd1cdf3cb986893ccf2b96665b25b3abb384f4", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "symfony/polyfill-util": "~1.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.13-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php56\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "time": "2019-11-27T13:56:44+00:00" - }, - { - "name": "symfony/polyfill-php70", - "version": "v1.13.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php70.git", - "reference": "af23c7bb26a73b850840823662dda371484926c4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/af23c7bb26a73b850840823662dda371484926c4", - "reference": "af23c7bb26a73b850840823662dda371484926c4", - "shasum": "" - }, - "require": { - "paragonie/random_compat": "~1.0|~2.0|~9.99", - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.13-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php70\\": "" - }, - "files": [ - "bootstrap.php" - ], - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "time": "2019-11-27T13:56:44+00:00" - }, - { - "name": "symfony/polyfill-util", - "version": "v1.13.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-util.git", - "reference": "964a67f293b66b95883a5ed918a65354fcd2258f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-util/zipball/964a67f293b66b95883a5ed918a65354fcd2258f", - "reference": "964a67f293b66b95883a5ed918a65354fcd2258f", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.13-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Util\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony utilities for portability of PHP codes", - "homepage": "https://symfony.com", - "keywords": [ - "compat", - "compatibility", - "polyfill", - "shim" - ], - "time": "2019-11-27T13:56:44+00:00" - }, - { - "name": "symfony/process", - "version": "v3.4.36", - "source": { - "type": "git", - "url": "https://github.com/symfony/process.git", - "reference": "9a4545c01e1e4f473492bd52b71e574dcc401ca2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/9a4545c01e1e4f473492bd52b71e574dcc401ca2", - "reference": "9a4545c01e1e4f473492bd52b71e574dcc401ca2", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Process\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Process Component", - "homepage": "https://symfony.com", - "time": "2019-11-28T10:05:51+00:00" - }, - { - "name": "symfony/proxy-manager-bridge", - "version": "v3.4.36", - "source": { - "type": "git", - "url": "https://github.com/symfony/proxy-manager-bridge.git", - "reference": "3c185a0e45ea13334aaf7b0fa9726922816ebec6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/proxy-manager-bridge/zipball/3c185a0e45ea13334aaf7b0fa9726922816ebec6", - "reference": "3c185a0e45ea13334aaf7b0fa9726922816ebec6", - "shasum": "" - }, - "require": { - "ocramius/proxy-manager": "~0.4|~1.0|~2.0", - "php": "^5.5.9|>=7.0.8", - "symfony/dependency-injection": "~3.4|~4.0" - }, - "require-dev": { - "symfony/config": "~2.8|~3.0|~4.0" - }, - "type": "symfony-bridge", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Bridge\\ProxyManager\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony ProxyManager Bridge", - "homepage": "https://symfony.com", - "time": "2019-08-29T14:54:55+00:00" - }, - { - "name": "symfony/routing", - "version": "v3.4.36", - "source": { - "type": "git", - "url": "https://github.com/symfony/routing.git", - "reference": "b689ccd48e234ea404806d94b07eeb45f9f6f06a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/routing/zipball/b689ccd48e234ea404806d94b07eeb45f9f6f06a", - "reference": "b689ccd48e234ea404806d94b07eeb45f9f6f06a", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8" - }, - "conflict": { - "symfony/config": "<3.3.1", - "symfony/dependency-injection": "<3.3", - "symfony/yaml": "<3.4" - }, - "require-dev": { - "doctrine/annotations": "~1.0", - "psr/log": "~1.0", - "symfony/config": "^3.3.1|~4.0", - "symfony/dependency-injection": "~3.3|~4.0", - "symfony/expression-language": "~2.8|~3.0|~4.0", - "symfony/http-foundation": "~2.8|~3.0|~4.0", - "symfony/yaml": "~3.4|~4.0" - }, - "suggest": { - "doctrine/annotations": "For using the annotation loader", - "symfony/config": "For using the all-in-one router or any loader", - "symfony/expression-language": "For using expression matching", - "symfony/http-foundation": "For using a Symfony Request object", - "symfony/yaml": "For using the YAML loader" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Routing\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Routing Component", - "homepage": "https://symfony.com", - "keywords": [ - "router", - "routing", - "uri", - "url" - ], - "time": "2019-12-01T08:33:36+00:00" - }, - { - "name": "symfony/twig-bridge", - "version": "v3.4.36", - "source": { - "type": "git", - "url": "https://github.com/symfony/twig-bridge.git", - "reference": "49b824ddc7f2d250a1f172349cd9a111d63287c0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/twig-bridge/zipball/49b824ddc7f2d250a1f172349cd9a111d63287c0", - "reference": "49b824ddc7f2d250a1f172349cd9a111d63287c0", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8", - "twig/twig": "^1.41|^2.10" - }, - "conflict": { - "symfony/console": "<3.4", - "symfony/form": "<3.4.31|>=4.0,<4.3.4" - }, - "require-dev": { - "fig/link-util": "^1.0", - "symfony/asset": "~2.8|~3.0|~4.0", - "symfony/console": "~3.4|~4.0", - "symfony/dependency-injection": "~2.8|~3.0|~4.0", - "symfony/expression-language": "~2.8|~3.0|~4.0", - "symfony/finder": "~2.8|~3.0|~4.0", - "symfony/form": "^3.4.31|^4.3.4", - "symfony/http-foundation": "^3.3.11|~4.0", - "symfony/http-kernel": "~3.2|~4.0", - "symfony/polyfill-intl-icu": "~1.0", - "symfony/routing": "~2.8|~3.0|~4.0", - "symfony/security": "^2.8.31|^3.3.13|~4.0", - "symfony/security-acl": "~2.8|~3.0", - "symfony/stopwatch": "~2.8|~3.0|~4.0", - "symfony/templating": "~2.8|~3.0|~4.0", - "symfony/translation": "~2.8|~3.0|~4.0", - "symfony/var-dumper": "~2.8.10|~3.1.4|~3.2|~4.0", - "symfony/web-link": "~3.3|~4.0", - "symfony/workflow": "~3.3|~4.0", - "symfony/yaml": "~2.8|~3.0|~4.0" - }, - "suggest": { - "symfony/asset": "For using the AssetExtension", - "symfony/expression-language": "For using the ExpressionExtension", - "symfony/finder": "", - "symfony/form": "For using the FormExtension", - "symfony/http-kernel": "For using the HttpKernelExtension", - "symfony/routing": "For using the RoutingExtension", - "symfony/security": "For using the SecurityExtension", - "symfony/stopwatch": "For using the StopwatchExtension", - "symfony/templating": "For using the TwigEngine", - "symfony/translation": "For using the TranslationExtension", - "symfony/var-dumper": "For using the DumpExtension", - "symfony/web-link": "For using the WebLinkExtension", - "symfony/yaml": "For using the YamlExtension" - }, - "type": "symfony-bridge", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Bridge\\Twig\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Twig Bridge", - "homepage": "https://symfony.com", - "time": "2019-11-30T08:19:08+00:00" - }, - { - "name": "symfony/yaml", - "version": "v3.4.36", - "source": { - "type": "git", - "url": "https://github.com/symfony/yaml.git", - "reference": "dab657db15207879217fc81df4f875947bf68804" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/dab657db15207879217fc81df4f875947bf68804", - "reference": "dab657db15207879217fc81df4f875947bf68804", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8", - "symfony/polyfill-ctype": "~1.8" - }, - "conflict": { - "symfony/console": "<3.4" - }, - "require-dev": { - "symfony/console": "~3.4|~4.0" - }, - "suggest": { - "symfony/console": "For validating YAML files using the lint command" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Yaml\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Yaml Component", - "homepage": "https://symfony.com", - "time": "2019-10-24T15:33:53+00:00" - }, - { - "name": "twig/twig", - "version": "v2.12.2", - "source": { - "type": "git", - "url": "https://github.com/twigphp/Twig.git", - "reference": "d761fd1f1c6b867ae09a7d8119a6d95d06dc44ed" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/d761fd1f1c6b867ae09a7d8119a6d95d06dc44ed", - "reference": "d761fd1f1c6b867ae09a7d8119a6d95d06dc44ed", - "shasum": "" - }, - "require": { - "php": "^7.0", - "symfony/polyfill-ctype": "^1.8", - "symfony/polyfill-mbstring": "^1.3" - }, - "require-dev": { - "psr/container": "^1.0", - "symfony/debug": "^3.4|^4.2", - "symfony/phpunit-bridge": "^4.4@dev|^5.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.12-dev" - } - }, - "autoload": { - "psr-0": { - "Twig_": "lib/" - }, - "psr-4": { - "Twig\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, - { - "name": "Twig Team", - "homepage": "https://twig.symfony.com/contributors", - "role": "Contributors" - }, - { - "name": "Armin Ronacher", - "email": "armin.ronacher@active-4.com", - "role": "Project Founder" - } - ], - "description": "Twig, the flexible, fast, and secure template language for PHP", - "homepage": "https://twig.symfony.com", - "keywords": [ - "templating" - ], - "time": "2019-11-11T16:52:09+00:00" - }, - { - "name": "zendframework/zend-code", - "version": "3.4.1", - "source": { - "type": "git", - "url": "https://github.com/zendframework/zend-code.git", - "reference": "268040548f92c2bfcba164421c1add2ba43abaaa" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-code/zipball/268040548f92c2bfcba164421c1add2ba43abaaa", - "reference": "268040548f92c2bfcba164421c1add2ba43abaaa", - "shasum": "" - }, - "require": { - "php": "^7.1", - "zendframework/zend-eventmanager": "^2.6 || ^3.0" - }, - "conflict": { - "phpspec/prophecy": "<1.9.0" - }, - "require-dev": { - "doctrine/annotations": "^1.7", - "ext-phar": "*", - "phpunit/phpunit": "^7.5.16 || ^8.4", - "zendframework/zend-coding-standard": "^1.0", - "zendframework/zend-stdlib": "^2.7 || ^3.0" - }, - "suggest": { - "doctrine/annotations": "Doctrine\\Common\\Annotations >=1.0 for annotation features", - "zendframework/zend-stdlib": "Zend\\Stdlib component" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4.x-dev", - "dev-develop": "3.5.x-dev", - "dev-dev-4.0": "4.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Zend\\Code\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "description": "Extensions to the PHP Reflection API, static code scanning, and code generation", - "keywords": [ - "ZendFramework", - "code", - "zf" - ], - "time": "2019-12-10T19:21:15+00:00" - }, - { - "name": "zendframework/zend-eventmanager", - "version": "3.2.1", - "source": { - "type": "git", - "url": "https://github.com/zendframework/zend-eventmanager.git", - "reference": "a5e2583a211f73604691586b8406ff7296a946dd" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-eventmanager/zipball/a5e2583a211f73604691586b8406ff7296a946dd", - "reference": "a5e2583a211f73604691586b8406ff7296a946dd", - "shasum": "" - }, - "require": { - "php": "^5.6 || ^7.0" - }, - "require-dev": { - "athletic/athletic": "^0.1", - "container-interop/container-interop": "^1.1.0", - "phpunit/phpunit": "^5.7.27 || ^6.5.8 || ^7.1.2", - "zendframework/zend-coding-standard": "~1.0.0", - "zendframework/zend-stdlib": "^2.7.3 || ^3.0" - }, - "suggest": { - "container-interop/container-interop": "^1.1.0, to use the lazy listeners feature", - "zendframework/zend-stdlib": "^2.7.3 || ^3.0, to use the FilterChain feature" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.2-dev", - "dev-develop": "3.3-dev" - } - }, - "autoload": { - "psr-4": { - "Zend\\EventManager\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "description": "Trigger and listen to events within a PHP application", - "homepage": "https://github.com/zendframework/zend-eventmanager", - "keywords": [ - "event", - "eventmanager", - "events", - "zf2" - ], - "time": "2018-04-25T15:33:34+00:00" - } - ], - "packages-dev": [ - { - "name": "blackfire/php-sdk", - "version": "v1.21.0", - "source": { - "type": "git", - "url": "https://github.com/blackfireio/php-sdk.git", - "reference": "1aa41771641ac268c5a2a0fc520e0da0e1f6698a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/blackfireio/php-sdk/zipball/1aa41771641ac268c5a2a0fc520e0da0e1f6698a", - "reference": "1aa41771641ac268c5a2a0fc520e0da0e1f6698a", - "shasum": "" - }, - "require": { - "composer/ca-bundle": "^1.0", - "php": ">=5.2.0" - }, - "require-dev": { - "symfony/http-client": "^4.3" - }, - "suggest": { - "ext-blackfire": "The C version of the Blackfire probe", - "ext-zlib": "To push config to remote profiling targets" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.5.x-dev" - } - }, - "autoload": { - "files": [ - "src/autostart.php" - ], - "psr-4": { - "Blackfire\\": "src/Blackfire" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Blackfire.io", - "email": "support@blackfire.io" - } - ], - "description": "Blackfire.io PHP SDK", - "keywords": [ - "performance", - "profiler", - "uprofiler", - "xhprof" - ], - "time": "2019-12-05T12:48:12+00:00" - }, - { - "name": "composer/ca-bundle", - "version": "1.2.5", - "source": { - "type": "git", - "url": "https://github.com/composer/ca-bundle.git", - "reference": "62e8fc2dc550e5d6d8c9360c7721662670f58149" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/composer/ca-bundle/zipball/62e8fc2dc550e5d6d8c9360c7721662670f58149", - "reference": "62e8fc2dc550e5d6d8c9360c7721662670f58149", - "shasum": "" - }, - "require": { - "ext-openssl": "*", - "ext-pcre": "*", - "php": "^5.3.2 || ^7.0 || ^8.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || 6.5 - 8", - "psr/log": "^1.0", - "symfony/process": "^2.5 || ^3.0 || ^4.0 || ^5.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Composer\\CaBundle\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jordi Boggiano", - "email": "j.boggiano@seld.be", - "homepage": "http://seld.be" - } - ], - "description": "Lets you find a path to the system CA bundle, and includes a fallback to the Mozilla CA bundle.", - "keywords": [ - "cabundle", - "cacert", - "certificate", - "ssl", - "tls" - ], - "time": "2019-12-11T14:44:42+00:00" - }, - { - "name": "doctrine/instantiator", - "version": "1.3.0", - "source": { - "type": "git", - "url": "https://github.com/doctrine/instantiator.git", - "reference": "ae466f726242e637cebdd526a7d991b9433bacf1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/ae466f726242e637cebdd526a7d991b9433bacf1", - "reference": "ae466f726242e637cebdd526a7d991b9433bacf1", - "shasum": "" - }, - "require": { - "php": "^7.1" - }, - "require-dev": { - "doctrine/coding-standard": "^6.0", - "ext-pdo": "*", - "ext-phar": "*", - "phpbench/phpbench": "^0.13", - "phpstan/phpstan-phpunit": "^0.11", - "phpstan/phpstan-shim": "^0.11", - "phpunit/phpunit": "^7.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, - "autoload": { - "psr-4": { - "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com", - "homepage": "http://ocramius.github.com/" - } - ], - "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://www.doctrine-project.org/projects/instantiator.html", - "keywords": [ - "constructor", - "instantiate" - ], - "time": "2019-10-21T16:45:58+00:00" - }, - { - "name": "fabpot/goutte", - "version": "v3.2.3", - "source": { - "type": "git", - "url": "https://github.com/FriendsOfPHP/Goutte.git", - "reference": "3f0eaf0a40181359470651f1565b3e07e3dd31b8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/FriendsOfPHP/Goutte/zipball/3f0eaf0a40181359470651f1565b3e07e3dd31b8", - "reference": "3f0eaf0a40181359470651f1565b3e07e3dd31b8", - "shasum": "" - }, - "require": { - "guzzlehttp/guzzle": "^6.0", - "php": ">=5.5.0", - "symfony/browser-kit": "~2.1|~3.0|~4.0", - "symfony/css-selector": "~2.1|~3.0|~4.0", - "symfony/dom-crawler": "~2.1|~3.0|~4.0" - }, - "require-dev": { - "symfony/phpunit-bridge": "^3.3 || ^4" - }, - "type": "application", - "extra": { - "branch-alias": { - "dev-master": "3.2-dev" - } - }, - "autoload": { - "psr-4": { - "Goutte\\": "Goutte" - }, - "exclude-from-classmap": [ - "Goutte/Tests" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "A simple PHP Web Scraper", - "homepage": "https://github.com/FriendsOfPHP/Goutte", - "keywords": [ - "scraper" - ], - "time": "2018-06-29T15:13:57+00:00" - }, - { - "name": "facebook/webdriver", - "version": "1.7.1", - "source": { - "type": "git", - "url": "https://github.com/facebook/php-webdriver.git", - "reference": "e43de70f3c7166169d0f14a374505392734160e5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/facebook/php-webdriver/zipball/e43de70f3c7166169d0f14a374505392734160e5", - "reference": "e43de70f3c7166169d0f14a374505392734160e5", - "shasum": "" - }, - "require": { - "ext-curl": "*", - "ext-json": "*", - "ext-mbstring": "*", - "ext-zip": "*", - "php": "^5.6 || ~7.0", - "symfony/process": "^2.8 || ^3.1 || ^4.0" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^2.0", - "jakub-onderka/php-parallel-lint": "^0.9.2", - "php-coveralls/php-coveralls": "^2.0", - "php-mock/php-mock-phpunit": "^1.1", - "phpunit/phpunit": "^5.7", - "sebastian/environment": "^1.3.4 || ^2.0 || ^3.0", - "squizlabs/php_codesniffer": "^2.6", - "symfony/var-dumper": "^3.3 || ^4.0" - }, - "suggest": { - "ext-SimpleXML": "For Firefox profile creation" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-community": "1.5-dev" - } - }, - "autoload": { - "psr-4": { - "Facebook\\WebDriver\\": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "description": "A PHP client for Selenium WebDriver", - "homepage": "https://github.com/facebook/php-webdriver", - "keywords": [ - "facebook", - "php", - "selenium", - "webdriver" - ], - "time": "2019-06-13T08:02:18+00:00" - }, - { - "name": "laravel/homestead", - "version": "v7.20.0", - "source": { - "type": "git", - "url": "https://github.com/laravel/homestead.git", - "reference": "cae38adcfdde1de1c4581e7a33872adaf9fbf926" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/laravel/homestead/zipball/cae38adcfdde1de1c4581e7a33872adaf9fbf926", - "reference": "cae38adcfdde1de1c4581e7a33872adaf9fbf926", - "shasum": "" - }, - "require": { - "php": "^5.6 || ^7.0", - "symfony/console": "~3.3|~4.0", - "symfony/process": "~3.3|~4.0", - "symfony/yaml": "~3.3|~4.0" - }, - "require-dev": { - "phly/changelog-generator": "^2.2", - "phpunit/phpunit": "^5.7 || ^6.0" - }, - "bin": [ - "bin/homestead" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.0-dev" - } - }, - "autoload": { - "psr-4": { - "Laravel\\Homestead\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Taylor Otwell", - "email": "taylorotwell@gmail.com" - } - ], - "description": "A virtual machine for web artisans.", - "time": "2018-12-11T02:04:35+00:00" - }, - { - "name": "michelf/php-markdown", - "version": "1.9.0", - "source": { - "type": "git", - "url": "https://github.com/michelf/php-markdown.git", - "reference": "c83178d49e372ca967d1a8c77ae4e051b3a3c75c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/michelf/php-markdown/zipball/c83178d49e372ca967d1a8c77ae4e051b3a3c75c", - "reference": "c83178d49e372ca967d1a8c77ae4e051b3a3c75c", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "require-dev": { - "phpunit/phpunit": ">=4.3 <5.8" - }, - "type": "library", - "autoload": { - "psr-4": { - "Michelf\\": "Michelf/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Michel Fortin", - "email": "michel.fortin@michelf.ca", - "homepage": "https://michelf.ca/", - "role": "Developer" - }, - { - "name": "John Gruber", - "homepage": "https://daringfireball.net/" - } - ], - "description": "PHP Markdown", - "homepage": "https://michelf.ca/projects/php-markdown/", - "keywords": [ - "markdown" - ], - "time": "2019-12-02T02:32:27+00:00" - }, - { - "name": "myclabs/deep-copy", - "version": "1.9.4", - "source": { - "type": "git", - "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "579bb7356d91f9456ccd505f24ca8b667966a0a7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/579bb7356d91f9456ccd505f24ca8b667966a0a7", - "reference": "579bb7356d91f9456ccd505f24ca8b667966a0a7", - "shasum": "" - }, - "require": { - "php": "^7.1" - }, - "replace": { - "myclabs/deep-copy": "self.version" - }, - "require-dev": { - "doctrine/collections": "^1.0", - "doctrine/common": "^2.6", - "phpunit/phpunit": "^7.1" - }, - "type": "library", - "autoload": { - "psr-4": { - "DeepCopy\\": "src/DeepCopy/" - }, - "files": [ - "src/DeepCopy/deep_copy.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Create deep copies (clones) of your objects", - "keywords": [ - "clone", - "copy", - "duplicate", - "object", - "object graph" - ], - "time": "2019-12-15T19:12:40+00:00" - }, - { - "name": "nikic/php-parser", - "version": "v3.1.5", - "source": { - "type": "git", - "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "bb87e28e7d7b8d9a7fda231d37457c9210faf6ce" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/bb87e28e7d7b8d9a7fda231d37457c9210faf6ce", - "reference": "bb87e28e7d7b8d9a7fda231d37457c9210faf6ce", - "shasum": "" - }, - "require": { - "ext-tokenizer": "*", - "php": ">=5.5" - }, - "require-dev": { - "phpunit/phpunit": "~4.0|~5.0" - }, - "bin": [ - "bin/php-parse" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0-dev" - } - }, - "autoload": { - "psr-4": { - "PhpParser\\": "lib/PhpParser" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Nikita Popov" - } - ], - "description": "A PHP parser written in PHP", - "keywords": [ - "parser", - "php" - ], - "time": "2018-02-28T20:30:58+00:00" - }, - { - "name": "phar-io/manifest", - "version": "1.0.3", - "source": { - "type": "git", - "url": "https://github.com/phar-io/manifest.git", - "reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phar-io/manifest/zipball/7761fcacf03b4d4f16e7ccb606d4879ca431fcf4", - "reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-phar": "*", - "phar-io/version": "^2.0", - "php": "^5.6 || ^7.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Arne Blankerts", - "email": "arne@blankerts.de", - "role": "Developer" - }, - { - "name": "Sebastian Heuer", - "email": "sebastian@phpeople.de", - "role": "Developer" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "Developer" - } - ], - "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", - "time": "2018-07-08T19:23:20+00:00" - }, - { - "name": "phar-io/version", - "version": "2.0.1", - "source": { - "type": "git", - "url": "https://github.com/phar-io/version.git", - "reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phar-io/version/zipball/45a2ec53a73c70ce41d55cedef9063630abaf1b6", - "reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6", - "shasum": "" - }, - "require": { - "php": "^5.6 || ^7.0" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Arne Blankerts", - "email": "arne@blankerts.de", - "role": "Developer" - }, - { - "name": "Sebastian Heuer", - "email": "sebastian@phpeople.de", - "role": "Developer" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "Developer" - } - ], - "description": "Library for handling version information and constraints", - "time": "2018-07-08T19:19:57+00:00" - }, - { - "name": "phing/phing", - "version": "2.16.1", - "source": { - "type": "git", - "url": "https://github.com/phingofficial/phing.git", - "reference": "cbe0f969e434e269af91b4160b86fe899c6e07c7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phingofficial/phing/zipball/cbe0f969e434e269af91b4160b86fe899c6e07c7", - "reference": "cbe0f969e434e269af91b4160b86fe899c6e07c7", - "shasum": "" - }, - "require": { - "php": ">=5.2.0", - "symfony/yaml": "^3.1 || ^4.0" - }, - "require-dev": { - "ext-pdo_sqlite": "*", - "mikey179/vfsstream": "^1.6", - "pdepend/pdepend": "2.x", - "pear/archive_tar": "1.4.x", - "pear/http_request2": "dev-trunk", - "pear/net_growl": "dev-trunk", - "pear/pear-core-minimal": "1.10.1", - "pear/versioncontrol_git": "@dev", - "pear/versioncontrol_svn": "~0.5", - "phpdocumentor/phpdocumentor": "2.x", - "phploc/phploc": "~2.0.6", - "phpmd/phpmd": "~2.2", - "phpunit/phpunit": ">=3.7", - "sebastian/git": "~1.0", - "sebastian/phpcpd": "2.x", - "siad007/versioncontrol_hg": "^1.0", - "simpletest/simpletest": "^1.1", - "squizlabs/php_codesniffer": "~2.2" - }, - "suggest": { - "pdepend/pdepend": "PHP version of JDepend", - "pear/archive_tar": "Tar file management class", - "pear/versioncontrol_git": "A library that provides OO interface to handle Git repository", - "pear/versioncontrol_svn": "A simple OO-style interface for Subversion, the free/open-source version control system", - "phpdocumentor/phpdocumentor": "Documentation Generator for PHP", - "phploc/phploc": "A tool for quickly measuring the size of a PHP project", - "phpmd/phpmd": "PHP version of PMD tool", - "phpunit/php-code-coverage": "Library that provides collection, processing, and rendering functionality for PHP code coverage information", - "phpunit/phpunit": "The PHP Unit Testing Framework", - "sebastian/phpcpd": "Copy/Paste Detector (CPD) for PHP code", - "siad007/versioncontrol_hg": "A library for interfacing with Mercurial repositories.", - "tedivm/jshrink": "Javascript Minifier built in PHP" - }, - "bin": [ - "bin/phing" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.16.x-dev" - } - }, - "autoload": { - "classmap": [ - "classes/phing/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "classes" - ], - "license": [ - "LGPL-3.0" - ], - "authors": [ - { - "name": "Michiel Rook", - "email": "mrook@php.net" - }, - { - "name": "Phing Community", - "homepage": "https://www.phing.info/trac/wiki/Development/Contributors" - } - ], - "description": "PHing Is Not GNU make; it's a PHP project build system or build tool based on Apache Ant.", - "homepage": "https://www.phing.info/", - "keywords": [ - "build", - "phing", - "task", - "tool" - ], - "time": "2018-01-25T13:18:09+00:00" - }, - { - "name": "phpdocumentor/reflection-docblock", - "version": "2.0.5", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "e6a969a640b00d8daa3c66518b0405fb41ae0c4b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/e6a969a640b00d8daa3c66518b0405fb41ae0c4b", - "reference": "e6a969a640b00d8daa3c66518b0405fb41ae0c4b", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "suggest": { - "dflydev/markdown": "~1.0", - "erusev/parsedown": "~1.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "psr-0": { - "phpDocumentor": [ - "src/" - ] - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "mike.vanriel@naenius.com" - } - ], - "time": "2016-01-25T08:17:30+00:00" - }, - { - "name": "phpspec/prophecy", - "version": "1.10.1", - "source": { - "type": "git", - "url": "https://github.com/phpspec/prophecy.git", - "reference": "cbe1df668b3fe136bcc909126a0f529a78d4cbbc" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/cbe1df668b3fe136bcc909126a0f529a78d4cbbc", - "reference": "cbe1df668b3fe136bcc909126a0f529a78d4cbbc", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.0.2", - "php": "^5.3|^7.0", - "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0|^5.0", - "sebastian/comparator": "^1.2.3|^2.0|^3.0", - "sebastian/recursion-context": "^1.0|^2.0|^3.0" - }, - "require-dev": { - "phpspec/phpspec": "^2.5 || ^3.2", - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.10.x-dev" - } - }, - "autoload": { - "psr-4": { - "Prophecy\\": "src/Prophecy" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Konstantin Kudryashov", - "email": "ever.zet@gmail.com", - "homepage": "http://everzet.com" - }, - { - "name": "Marcello Duarte", - "email": "marcello.duarte@gmail.com" - } - ], - "description": "Highly opinionated mocking framework for PHP 5.3+", - "homepage": "https://github.com/phpspec/prophecy", - "keywords": [ - "Double", - "Dummy", - "fake", - "mock", - "spy", - "stub" - ], - "time": "2019-12-22T21:05:45+00:00" - }, - { - "name": "phpunit/dbunit", - "version": "4.0.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/dbunit.git", - "reference": "e77b469c3962b5a563f09a2a989f1c9bd38b8615" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/dbunit/zipball/e77b469c3962b5a563f09a2a989f1c9bd38b8615", - "reference": "e77b469c3962b5a563f09a2a989f1c9bd38b8615", - "shasum": "" - }, - "require": { - "ext-pdo": "*", - "ext-simplexml": "*", - "php": "^7.1", - "phpunit/phpunit": "^7.0", - "symfony/yaml": "^3.0 || ^4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "PHPUnit extension for database interaction testing", - "homepage": "https://github.com/sebastianbergmann/dbunit/", - "keywords": [ - "database", - "testing", - "xunit" - ], - "abandoned": true, - "time": "2018-02-07T06:47:59+00:00" - }, - { - "name": "phpunit/php-code-coverage", - "version": "6.1.4", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "807e6013b00af69b6c5d9ceb4282d0393dbb9d8d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/807e6013b00af69b6c5d9ceb4282d0393dbb9d8d", - "reference": "807e6013b00af69b6c5d9ceb4282d0393dbb9d8d", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-xmlwriter": "*", - "php": "^7.1", - "phpunit/php-file-iterator": "^2.0", - "phpunit/php-text-template": "^1.2.1", - "phpunit/php-token-stream": "^3.0", - "sebastian/code-unit-reverse-lookup": "^1.0.1", - "sebastian/environment": "^3.1 || ^4.0", - "sebastian/version": "^2.0.1", - "theseer/tokenizer": "^1.1" - }, - "require-dev": { - "phpunit/phpunit": "^7.0" - }, - "suggest": { - "ext-xdebug": "^2.6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "6.1-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", - "homepage": "https://github.com/sebastianbergmann/php-code-coverage", - "keywords": [ - "coverage", - "testing", - "xunit" - ], - "time": "2018-10-31T16:06:48+00:00" - }, - { - "name": "phpunit/php-file-iterator", - "version": "2.0.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "050bedf145a257b1ff02746c31894800e5122946" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/050bedf145a257b1ff02746c31894800e5122946", - "reference": "050bedf145a257b1ff02746c31894800e5122946", - "shasum": "" - }, - "require": { - "php": "^7.1" - }, - "require-dev": { - "phpunit/phpunit": "^7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "FilterIterator implementation that filters files based on a list of suffixes.", - "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", - "keywords": [ - "filesystem", - "iterator" - ], - "time": "2018-09-13T20:33:42+00:00" - }, - { - "name": "phpunit/php-text-template", - "version": "1.2.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Simple template engine.", - "homepage": "https://github.com/sebastianbergmann/php-text-template/", - "keywords": [ - "template" - ], - "time": "2015-06-21T13:50:34+00:00" - }, - { - "name": "phpunit/php-timer", - "version": "2.1.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "1038454804406b0b5f5f520358e78c1c2f71501e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/1038454804406b0b5f5f520358e78c1c2f71501e", - "reference": "1038454804406b0b5f5f520358e78c1c2f71501e", - "shasum": "" - }, - "require": { - "php": "^7.1" - }, - "require-dev": { - "phpunit/phpunit": "^7.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.1-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Utility class for timing", - "homepage": "https://github.com/sebastianbergmann/php-timer/", - "keywords": [ - "timer" - ], - "time": "2019-06-07T04:22:29+00:00" - }, - { - "name": "phpunit/php-token-stream", - "version": "3.1.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "995192df77f63a59e47f025390d2d1fdf8f425ff" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/995192df77f63a59e47f025390d2d1fdf8f425ff", - "reference": "995192df77f63a59e47f025390d2d1fdf8f425ff", - "shasum": "" - }, - "require": { - "ext-tokenizer": "*", - "php": "^7.1" - }, - "require-dev": { - "phpunit/phpunit": "^7.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.1-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Wrapper around PHP's tokenizer extension.", - "homepage": "https://github.com/sebastianbergmann/php-token-stream/", - "keywords": [ - "tokenizer" - ], - "time": "2019-09-17T06:23:10+00:00" - }, - { - "name": "phpunit/phpunit", - "version": "7.5.18", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "fcf6c4bfafaadc07785528b06385cce88935474d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/fcf6c4bfafaadc07785528b06385cce88935474d", - "reference": "fcf6c4bfafaadc07785528b06385cce88935474d", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.1", - "ext-dom": "*", - "ext-json": "*", - "ext-libxml": "*", - "ext-mbstring": "*", - "ext-xml": "*", - "myclabs/deep-copy": "^1.7", - "phar-io/manifest": "^1.0.2", - "phar-io/version": "^2.0", - "php": "^7.1", - "phpspec/prophecy": "^1.7", - "phpunit/php-code-coverage": "^6.0.7", - "phpunit/php-file-iterator": "^2.0.1", - "phpunit/php-text-template": "^1.2.1", - "phpunit/php-timer": "^2.1", - "sebastian/comparator": "^3.0", - "sebastian/diff": "^3.0", - "sebastian/environment": "^4.0", - "sebastian/exporter": "^3.1", - "sebastian/global-state": "^2.0", - "sebastian/object-enumerator": "^3.0.3", - "sebastian/resource-operations": "^2.0", - "sebastian/version": "^2.0.1" - }, - "conflict": { - "phpunit/phpunit-mock-objects": "*" - }, - "require-dev": { - "ext-pdo": "*" - }, - "suggest": { - "ext-soap": "*", - "ext-xdebug": "*", - "phpunit/php-invoker": "^2.0" - }, - "bin": [ - "phpunit" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "7.5-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "The PHP Unit Testing framework.", - "homepage": "https://phpunit.de/", - "keywords": [ - "phpunit", - "testing", - "xunit" - ], - "time": "2019-12-06T05:14:37+00:00" - }, - { - "name": "pimple/pimple", - "version": "v3.2.3", - "source": { - "type": "git", - "url": "https://github.com/silexphp/Pimple.git", - "reference": "9e403941ef9d65d20cba7d54e29fe906db42cf32" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/silexphp/Pimple/zipball/9e403941ef9d65d20cba7d54e29fe906db42cf32", - "reference": "9e403941ef9d65d20cba7d54e29fe906db42cf32", - "shasum": "" - }, - "require": { - "php": ">=5.3.0", - "psr/container": "^1.0" - }, - "require-dev": { - "symfony/phpunit-bridge": "^3.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.2.x-dev" - } - }, - "autoload": { - "psr-0": { - "Pimple": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "Pimple, a simple Dependency Injection Container", - "homepage": "http://pimple.sensiolabs.org", - "keywords": [ - "container", - "dependency injection" - ], - "time": "2018-01-21T07:42:36+00:00" - }, - { - "name": "sami/sami", - "version": "v4.1.2", - "source": { - "type": "git", - "url": "https://github.com/FriendsOfPHP/Sami.git", - "reference": "19b8a82b858bd31544c468317c8307188ccb4022" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/FriendsOfPHP/Sami/zipball/19b8a82b858bd31544c468317c8307188ccb4022", - "reference": "19b8a82b858bd31544c468317c8307188ccb4022", - "shasum": "" - }, - "require": { - "blackfire/php-sdk": "^1.5.18", - "michelf/php-markdown": "~1.3", - "nikic/php-parser": "~3.0", - "php": "^7.1.3", - "phpdocumentor/reflection-docblock": "~2.0", - "pimple/pimple": "~3.0", - "symfony/console": "~3.0|~4.0", - "symfony/filesystem": "~3.0|~4.0", - "symfony/finder": "~3.0|~4.0", - "symfony/process": "~3.0|~4.0", - "symfony/yaml": "~3.0|~4.0", - "twig/twig": "~2.0" - }, - "require-dev": { - "symfony/phpunit-bridge": "~4.0" - }, - "bin": [ - "sami.php" - ], - "type": "application", - "extra": { - "branch-alias": { - "dev-master": "4.1-dev" - } - }, - "autoload": { - "psr-4": { - "Sami\\": "Sami/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "Sami, an API documentation generator", - "homepage": "http://sami.sensiolabs.org", - "keywords": [ - "phpdoc" - ], - "abandoned": true, - "time": "2018-07-02T13:20:39+00:00" - }, - { - "name": "sebastian/code-unit-reverse-lookup", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", - "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", - "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", - "shasum": "" - }, - "require": { - "php": "^5.6 || ^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^5.7 || ^6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Looks up which function or method a line of code belongs to", - "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", - "time": "2017-03-04T06:30:41+00:00" - }, - { - "name": "sebastian/comparator", - "version": "3.0.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/5de4fc177adf9bce8df98d8d141a7559d7ccf6da", - "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da", - "shasum": "" - }, - "require": { - "php": "^7.1", - "sebastian/diff": "^3.0", - "sebastian/exporter": "^3.1" - }, - "require-dev": { - "phpunit/phpunit": "^7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides the functionality to compare PHP values for equality", - "homepage": "https://github.com/sebastianbergmann/comparator", - "keywords": [ - "comparator", - "compare", - "equality" - ], - "time": "2018-07-12T15:12:46+00:00" - }, - { - "name": "sebastian/diff", - "version": "3.0.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/720fcc7e9b5cf384ea68d9d930d480907a0c1a29", - "reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29", - "shasum": "" - }, - "require": { - "php": "^7.1" - }, - "require-dev": { - "phpunit/phpunit": "^7.5 || ^8.0", - "symfony/process": "^2 || ^3.3 || ^4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Kore Nordmann", - "email": "mail@kore-nordmann.de" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Diff implementation", - "homepage": "https://github.com/sebastianbergmann/diff", - "keywords": [ - "diff", - "udiff", - "unidiff", - "unified diff" - ], - "time": "2019-02-04T06:01:07+00:00" - }, - { - "name": "sebastian/environment", - "version": "4.2.3", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "464c90d7bdf5ad4e8a6aea15c091fec0603d4368" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/464c90d7bdf5ad4e8a6aea15c091fec0603d4368", - "reference": "464c90d7bdf5ad4e8a6aea15c091fec0603d4368", - "shasum": "" - }, - "require": { - "php": "^7.1" - }, - "require-dev": { - "phpunit/phpunit": "^7.5" - }, - "suggest": { - "ext-posix": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.2-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides functionality to handle HHVM/PHP environments", - "homepage": "http://www.github.com/sebastianbergmann/environment", - "keywords": [ - "Xdebug", - "environment", - "hhvm" - ], - "time": "2019-11-20T08:46:58+00:00" - }, - { - "name": "sebastian/exporter", - "version": "3.1.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "68609e1261d215ea5b21b7987539cbfbe156ec3e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/68609e1261d215ea5b21b7987539cbfbe156ec3e", - "reference": "68609e1261d215ea5b21b7987539cbfbe156ec3e", - "shasum": "" - }, - "require": { - "php": "^7.0", - "sebastian/recursion-context": "^3.0" - }, - "require-dev": { - "ext-mbstring": "*", - "phpunit/phpunit": "^6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.1.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@gmail.com" - } - ], - "description": "Provides the functionality to export PHP variables for visualization", - "homepage": "http://www.github.com/sebastianbergmann/exporter", - "keywords": [ - "export", - "exporter" - ], - "time": "2019-09-14T09:02:43+00:00" - }, - { - "name": "sebastian/global-state", - "version": "2.0.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", - "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", - "shasum": "" - }, - "require": { - "php": "^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^6.0" - }, - "suggest": { - "ext-uopz": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Snapshotting of global state", - "homepage": "http://www.github.com/sebastianbergmann/global-state", - "keywords": [ - "global state" - ], - "time": "2017-04-27T15:39:26+00:00" - }, - { - "name": "sebastian/object-enumerator", - "version": "3.0.3", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/7cfd9e65d11ffb5af41198476395774d4c8a84c5", - "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5", - "shasum": "" - }, - "require": { - "php": "^7.0", - "sebastian/object-reflector": "^1.1.1", - "sebastian/recursion-context": "^3.0" - }, - "require-dev": { - "phpunit/phpunit": "^6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Traverses array structures and object graphs to enumerate all referenced objects", - "homepage": "https://github.com/sebastianbergmann/object-enumerator/", - "time": "2017-08-03T12:35:26+00:00" - }, - { - "name": "sebastian/object-reflector", - "version": "1.1.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/object-reflector.git", - "reference": "773f97c67f28de00d397be301821b06708fca0be" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/773f97c67f28de00d397be301821b06708fca0be", - "reference": "773f97c67f28de00d397be301821b06708fca0be", - "shasum": "" - }, - "require": { - "php": "^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Allows reflection of object attributes, including inherited and non-public ones", - "homepage": "https://github.com/sebastianbergmann/object-reflector/", - "time": "2017-03-29T09:07:27+00:00" - }, - { - "name": "sebastian/recursion-context", - "version": "3.0.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", - "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", - "shasum": "" - }, - "require": { - "php": "^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - } - ], - "description": "Provides functionality to recursively process PHP variables", - "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2017-03-03T06:23:57+00:00" - }, - { - "name": "sebastian/resource-operations", - "version": "2.0.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "4d7a795d35b889bf80a0cc04e08d77cedfa917a9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/4d7a795d35b889bf80a0cc04e08d77cedfa917a9", - "reference": "4d7a795d35b889bf80a0cc04e08d77cedfa917a9", - "shasum": "" - }, - "require": { - "php": "^7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides a list of PHP built-in functions that operate on resources", - "homepage": "https://www.github.com/sebastianbergmann/resource-operations", - "time": "2018-10-04T04:07:39+00:00" - }, - { - "name": "sebastian/version", - "version": "2.0.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/version.git", - "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/99732be0ddb3361e16ad77b68ba41efc8e979019", - "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019", - "shasum": "" - }, - "require": { - "php": ">=5.6" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Library that helps with managing the version number of Git-hosted PHP projects", - "homepage": "https://github.com/sebastianbergmann/version", - "time": "2016-10-03T07:35:21+00:00" - }, - { - "name": "squizlabs/php_codesniffer", - "version": "3.5.3", - "source": { - "type": "git", - "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "557a1fc7ac702c66b0bbfe16ab3d55839ef724cb" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/557a1fc7ac702c66b0bbfe16ab3d55839ef724cb", - "reference": "557a1fc7ac702c66b0bbfe16ab3d55839ef724cb", - "shasum": "" - }, - "require": { - "ext-simplexml": "*", - "ext-tokenizer": "*", - "ext-xmlwriter": "*", - "php": ">=5.4.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" - }, - "bin": [ - "bin/phpcs", - "bin/phpcbf" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.x-dev" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Greg Sherwood", - "role": "lead" - } - ], - "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", - "keywords": [ - "phpcs", - "standards" - ], - "time": "2019-12-04T04:46:47+00:00" - }, - { - "name": "symfony/browser-kit", - "version": "v3.4.36", - "source": { - "type": "git", - "url": "https://github.com/symfony/browser-kit.git", - "reference": "2e4c991e27a97a8c27745720b030ff85a5cebdf6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/browser-kit/zipball/2e4c991e27a97a8c27745720b030ff85a5cebdf6", - "reference": "2e4c991e27a97a8c27745720b030ff85a5cebdf6", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8", - "symfony/dom-crawler": "~2.8|~3.0|~4.0" - }, - "require-dev": { - "symfony/css-selector": "~2.8|~3.0|~4.0", - "symfony/process": "~2.8|~3.0|~4.0" - }, - "suggest": { - "symfony/process": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\BrowserKit\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony BrowserKit Component", - "homepage": "https://symfony.com", - "time": "2019-10-24T15:33:53+00:00" - }, - { - "name": "symfony/css-selector", - "version": "v3.4.36", - "source": { - "type": "git", - "url": "https://github.com/symfony/css-selector.git", - "reference": "f819f71ae3ba6f396b4c015bd5895de7d2f1f85f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/css-selector/zipball/f819f71ae3ba6f396b4c015bd5895de7d2f1f85f", - "reference": "f819f71ae3ba6f396b4c015bd5895de7d2f1f85f", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\CssSelector\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Jean-François Simon", - "email": "jeanfrancois.simon@sensiolabs.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony CssSelector Component", - "homepage": "https://symfony.com", - "time": "2019-10-01T11:57:37+00:00" - }, - { - "name": "symfony/dom-crawler", - "version": "v3.4.36", - "source": { - "type": "git", - "url": "https://github.com/symfony/dom-crawler.git", - "reference": "6bcffd2eabc4ca087faaaf54e26c8ff3a40284f3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/6bcffd2eabc4ca087faaaf54e26c8ff3a40284f3", - "reference": "6bcffd2eabc4ca087faaaf54e26c8ff3a40284f3", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8", - "symfony/polyfill-ctype": "~1.8", - "symfony/polyfill-mbstring": "~1.0" - }, - "require-dev": { - "symfony/css-selector": "~2.8|~3.0|~4.0" - }, - "suggest": { - "symfony/css-selector": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\DomCrawler\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony DomCrawler Component", - "homepage": "https://symfony.com", - "time": "2019-10-24T15:33:53+00:00" - }, - { - "name": "theseer/tokenizer", - "version": "1.1.3", - "source": { - "type": "git", - "url": "https://github.com/theseer/tokenizer.git", - "reference": "11336f6f84e16a720dae9d8e6ed5019efa85a0f9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/theseer/tokenizer/zipball/11336f6f84e16a720dae9d8e6ed5019efa85a0f9", - "reference": "11336f6f84e16a720dae9d8e6ed5019efa85a0f9", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-tokenizer": "*", - "ext-xmlwriter": "*", - "php": "^7.0" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Arne Blankerts", - "email": "arne@blankerts.de", - "role": "Developer" - } - ], - "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", - "time": "2019-06-13T22:48:21+00:00" - } - ], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": [], - "prefer-stable": false, - "prefer-lowest": false, - "platform": { - "php": "^7.1.3", - "ext-json": "*" - }, - "platform-dev": [], - "platform-overrides": { - "php": "7.1.3" - } -} diff --git a/install/update/new/config/default/config.yml b/install/update/new/config/default/config.yml deleted file mode 100644 index e8d0536..0000000 --- a/install/update/new/config/default/config.yml +++ /dev/null @@ -1 +0,0 @@ -# phpBB's config file (This line is needed because of the packager) diff --git a/install/update/new/config/default/container/parameters.yml b/install/update/new/config/default/container/parameters.yml deleted file mode 100644 index 8fcb401..0000000 --- a/install/update/new/config/default/container/parameters.yml +++ /dev/null @@ -1,22 +0,0 @@ -parameters: - # Disable the usage of the super globals (_GET, _POST, _SERVER...) - core.disable_super_globals: true - - # Datetime class to use - datetime.class: \phpbb\datetime - - # Mimetype guesser priorities - mimetype.guesser.priority.lowest: -2 - mimetype.guesser.priority.low: -1 - mimetype.guesser.priority.default: 0 - mimetype.guesser.priority.high: 1 - mimetype.guesser.priority.highest: 2 - - # List of default password driver types - passwords.algorithms: - - passwords.driver.argon2id - - passwords.driver.argon2i - - passwords.driver.bcrypt_2y - - passwords.driver.bcrypt - - passwords.driver.salted_md5 - - passwords.driver.phpass diff --git a/install/update/new/config/default/container/services.yml b/install/update/new/config/default/container/services.yml deleted file mode 100644 index 2d47200..0000000 --- a/install/update/new/config/default/container/services.yml +++ /dev/null @@ -1,176 +0,0 @@ -imports: - - { resource: services_attachment.yml } - - { resource: services_auth.yml } - - { resource: services_avatar.yml } - - { resource: services_captcha.yml } - - { resource: services_console.yml } - - { resource: services_content.yml } - - { resource: services_cron.yml } - - { resource: services_db.yml } - - { resource: services_event.yml } - - { resource: services_feed.yml } - - { resource: services_files.yml } - - { resource: services_filesystem.yml } - - { resource: services_help.yml } - - { resource: services_hook.yml } - - { resource: services_http.yml } - - { resource: services_language.yml } - - { resource: services_migrator.yml } - - { resource: services_mimetype_guesser.yml } - - { resource: services_module.yml } - - { resource: services_notification.yml } - - { resource: services_password.yml } - - { resource: services_php.yml } - - { resource: services_profilefield.yml } - - { resource: services_report.yml } - - { resource: services_routing.yml } - - { resource: services_text_formatter.yml } - - { resource: services_text_reparser.yml } - - { resource: services_twig.yml } - - { resource: services_ucp.yml } - - { resource: services_user.yml } - - - { resource: tables.yml } - - { resource: parameters.yml } - -services: - cache: - class: phpbb\cache\service - arguments: - - '@cache.driver' - - '@config' - - '@dbal.conn' - - '%core.root_path%' - - '%core.php_ext%' - - cache.driver: - class: '%cache.driver.class%' - - class_loader: - class: phpbb\class_loader - arguments: - - phpbb\ - - '%core.root_path%includes/' - - '%core.php_ext%' - calls: - - [register, []] - - [set_cache, ['@cache.driver']] - - class_loader.ext: - class: phpbb\class_loader - arguments: - - \ - - '%core.root_path%ext/' - - '%core.php_ext%' - calls: - - [register, []] - - [set_cache, ['@cache.driver']] - - config: - class: phpbb\config\db - arguments: - - '@dbal.conn' - - '@cache.driver' - - '%tables.config%' - - config.php: - synthetic: true - - config_text: - class: phpbb\config\db_text - arguments: - - '@dbal.conn' - - '%tables.config_text%' - - controller.helper: - class: phpbb\controller\helper - arguments: - - '@template' - - '@user' - - '@config' - - '@symfony_request' - - '@request' - - '@routing.helper' - - controller.resolver: - class: phpbb\controller\resolver - arguments: - - '@service_container' - - '%core.root_path%' - - '@template' - - ext.manager: - class: phpbb\extension\manager - arguments: - - '@service_container' - - '@dbal.conn' - - '@config' - - '@filesystem' - - '%tables.ext%' - - '%core.root_path%' - - '%core.php_ext%' - - '@cache' - - file_downloader: - class: phpbb\file_downloader - - file_locator: - class: phpbb\routing\file_locator - arguments: - - '@filesystem' - - '%core.root_path%' - - group_helper: - class: phpbb\group\helper - arguments: - - '@auth' - - '@cache' - - '@config' - - '@language' - - '@dispatcher' - - '@path_helper' - - '@user' - - log: - class: phpbb\log\log - arguments: - - '@dbal.conn' - - '@user' - - '@auth' - - '@dispatcher' - - '%core.root_path%' - - '%core.adm_relative_path%' - - '%core.php_ext%' - - '%tables.log%' - - path_helper: - class: phpbb\path_helper - arguments: - - '@symfony_request' - - '@filesystem' - - '@request' - - '%core.root_path%' - - '%core.php_ext%' - - '%core.adm_relative_path%' - - plupload: - class: phpbb\plupload\plupload - arguments: - - '%core.root_path%' - - '@config' - - '@request' - - '@user' - - '@php_ini' - - '@mimetype.guesser' - - upload_imagesize: - class: FastImageSize\FastImageSize - - version_helper: - class: phpbb\version_helper - shared: false - arguments: - - '@cache' - - '@config' - - '@file_downloader' - - '@user' diff --git a/install/update/new/config/default/container/services_attachment.yml b/install/update/new/config/default/container/services_attachment.yml deleted file mode 100644 index c56ced2..0000000 --- a/install/update/new/config/default/container/services_attachment.yml +++ /dev/null @@ -1,40 +0,0 @@ -services: - attachment.delete: - class: phpbb\attachment\delete - shared: false - arguments: - - '@config' - - '@dbal.conn' - - '@dispatcher' - - '@filesystem' - - '@attachment.resync' - - '%core.root_path%' - - attachment.manager: - class: phpbb\attachment\manager - shared: false - arguments: - - '@attachment.delete' - - '@attachment.resync' - - '@attachment.upload' - - attachment.resync: - class: phpbb\attachment\resync - shared: false - arguments: - - '@dbal.conn' - - attachment.upload: - class: phpbb\attachment\upload - shared: false - arguments: - - '@auth' - - '@cache' - - '@config' - - '@files.upload' - - '@language' - - '@mimetype.guesser' - - '@dispatcher' - - '@plupload' - - '@user' - - '%core.root_path%' diff --git a/install/update/new/config/default/container/services_auth.yml b/install/update/new/config/default/container/services_auth.yml deleted file mode 100644 index 1540bea..0000000 --- a/install/update/new/config/default/container/services_auth.yml +++ /dev/null @@ -1,110 +0,0 @@ -services: -# ----- Auth management ----- - auth: - class: phpbb\auth\auth - -# ----- Auth providers ----- - auth.provider_collection: - class: phpbb\auth\provider_collection - arguments: - - '@service_container' - - '@config' - tags: - - { name: service_collection, tag: auth.provider } - - auth.provider.db: - class: phpbb\auth\provider\db - arguments: - - '@captcha.factory' - - '@config' - - '@dbal.conn' - - '@passwords.manager' - - '@request' - - '@user' - - '%core.root_path%' - - '%core.php_ext%' - tags: - - { name: auth.provider } - - auth.provider.apache: - class: phpbb\auth\provider\apache - arguments: - - '@config' - - '@dbal.conn' - - '@language' - - '@request' - - '@user' - - '%core.root_path%' - - '%core.php_ext%' - tags: - - { name: auth.provider } - - auth.provider.ldap: - class: phpbb\auth\provider\ldap - arguments: - - '@config' - - '@dbal.conn' - - '@language' - - '@user' - tags: - - { name: auth.provider } - - auth.provider.oauth: - class: phpbb\auth\provider\oauth\oauth - arguments: - - '@config' - - '@dbal.conn' - - '@auth.provider.db' - - '@dispatcher' - - '@language' - - '@request' - - '@auth.provider.oauth.service_collection' - - '@user' - - '%tables.auth_provider_oauth_token_storage%' - - '%tables.auth_provider_oauth_states%' - - '%tables.auth_provider_oauth_account_assoc%' - - '%tables.users%' - - '%core.root_path%' - - '%core.php_ext%' - tags: - - { name: auth.provider } - -# ----- OAuth services providers ----- - auth.provider.oauth.service_collection: - class: phpbb\di\service_collection - arguments: - - '@service_container' - tags: - - { name: service_collection, tag: auth.provider.oauth.service } - - auth.provider.oauth.service.bitly: - class: phpbb\auth\provider\oauth\service\bitly - arguments: - - '@config' - - '@request' - tags: - - { name: auth.provider.oauth.service } - - auth.provider.oauth.service.facebook: - class: phpbb\auth\provider\oauth\service\facebook - arguments: - - '@config' - - '@request' - tags: - - { name: auth.provider.oauth.service } - - auth.provider.oauth.service.google: - class: phpbb\auth\provider\oauth\service\google - arguments: - - '@config' - - '@request' - tags: - - { name: auth.provider.oauth.service } - - auth.provider.oauth.service.twitter: - class: phpbb\auth\provider\oauth\service\twitter - arguments: - - '@config' - - '@request' - tags: - - { name: auth.provider.oauth.service } diff --git a/install/update/new/config/default/container/services_avatar.yml b/install/update/new/config/default/container/services_avatar.yml deleted file mode 100644 index d96aa62..0000000 --- a/install/update/new/config/default/container/services_avatar.yml +++ /dev/null @@ -1,73 +0,0 @@ -services: - avatar.manager: - class: phpbb\avatar\manager - arguments: - - '@config' - - '@dispatcher' - - '@avatar.driver_collection' - -# ----- Avatar drivers ----- - avatar.driver_collection: - class: phpbb\di\service_collection - arguments: - - '@service_container' - tags: - - { name: service_collection, tag: avatar.driver } - - avatar.driver.gravatar: - class: phpbb\avatar\driver\gravatar - arguments: - - '@config' - - '@upload_imagesize' - - '%core.root_path%' - - '%core.php_ext%' - - '@path_helper' - - '@cache.driver' - calls: - - [set_name, [avatar.driver.gravatar]] - tags: - - { name: avatar.driver } - - avatar.driver.local: - class: phpbb\avatar\driver\local - arguments: - - '@config' - - '@upload_imagesize' - - '%core.root_path%' - - '%core.php_ext%' - - '@path_helper' - - '@cache.driver' - calls: - - [set_name, [avatar.driver.local]] - tags: - - { name: avatar.driver } - - avatar.driver.remote: - class: phpbb\avatar\driver\remote - arguments: - - '@config' - - '@upload_imagesize' - - '%core.root_path%' - - '%core.php_ext%' - - '@path_helper' - - '@cache.driver' - calls: - - [set_name, [avatar.driver.remote]] - tags: - - { name: avatar.driver } - - avatar.driver.upload: - class: phpbb\avatar\driver\upload - arguments: - - '@config' - - '%core.root_path%' - - '%core.php_ext%' - - '@filesystem' - - '@path_helper' - - '@dispatcher' - - '@files.factory' - - '@cache.driver' - calls: - - [set_name, [avatar.driver.upload]] - tags: - - { name: avatar.driver } diff --git a/install/update/new/config/default/container/services_captcha.yml b/install/update/new/config/default/container/services_captcha.yml deleted file mode 100644 index e462c43..0000000 --- a/install/update/new/config/default/container/services_captcha.yml +++ /dev/null @@ -1,59 +0,0 @@ -services: - captcha.factory: - class: phpbb\captcha\factory - arguments: - - '@service_container' - - '@captcha.plugins.service_collection' - -# ----- Captcha plugins ----- -# Service MUST NOT be shared for all the plugins to work. - captcha.plugins.service_collection: - class: phpbb\di\service_collection - arguments: - - '@service_container' - tags: - - { name: service_collection, tag: captcha.plugins } - - core.captcha.plugins.gd: - class: phpbb\captcha\plugins\gd - shared: false - calls: - - [set_name, [core.captcha.plugins.gd]] - tags: - - { name: captcha.plugins } - - core.captcha.plugins.gd_wave: - class: phpbb\captcha\plugins\gd_wave - shared: false - calls: - - [set_name, [core.captcha.plugins.gd_wave]] - tags: - - { name: captcha.plugins } - - core.captcha.plugins.nogd: - class: phpbb\captcha\plugins\nogd - shared: false - calls: - - [set_name, [core.captcha.plugins.nogd]] - tags: - - { name: captcha.plugins } - - core.captcha.plugins.qa: - class: phpbb\captcha\plugins\qa - shared: false - arguments: - - '%tables.captcha_qa_questions%' - - '%tables.captcha_qa_answers%' - - '%tables.captcha_qa_confirm%' - calls: - - [set_name, [core.captcha.plugins.qa]] - tags: - - { name: captcha.plugins } - - core.captcha.plugins.recaptcha: - class: phpbb\captcha\plugins\recaptcha - shared: false - calls: - - [set_name, [core.captcha.plugins.recaptcha]] - tags: - - { name: captcha.plugins } diff --git a/install/update/new/config/default/container/services_console.yml b/install/update/new/config/default/container/services_console.yml deleted file mode 100644 index b662102..0000000 --- a/install/update/new/config/default/container/services_console.yml +++ /dev/null @@ -1,287 +0,0 @@ -services: - console.exception_subscriber: - class: phpbb\console\exception_subscriber - arguments: - - '@language' - tags: - - { name: kernel.event_subscriber } - - console.command_collection: - class: phpbb\di\service_collection - arguments: - - '@service_container' - tags: - - { name: service_collection, tag: console.command } - - console.command.cache.purge: - class: phpbb\console\command\cache\purge - arguments: - - '@user' - - '@cache.driver' - - '@dbal.conn' - - '@auth' - - '@log' - - '@config' - tags: - - { name: console.command } - - console.command.config.delete: - class: phpbb\console\command\config\delete - arguments: - - '@user' - - '@config' - tags: - - { name: console.command } - - console.command.config.increment: - class: phpbb\console\command\config\increment - arguments: - - '@user' - - '@config' - tags: - - { name: console.command } - - console.command.config.get: - class: phpbb\console\command\config\get - arguments: - - '@user' - - '@config' - tags: - - { name: console.command } - - console.command.config.set: - class: phpbb\console\command\config\set - arguments: - - '@user' - - '@config' - tags: - - { name: console.command } - - console.command.config.set_atomic: - class: phpbb\console\command\config\set_atomic - arguments: - - '@user' - - '@config' - tags: - - { name: console.command } - - console.command.cron.list: - class: phpbb\console\command\cron\cron_list - arguments: - - '@user' - - '@cron.manager' - tags: - - { name: console.command } - - console.command.cron.run: - class: phpbb\console\command\cron\run - arguments: - - '@user' - - '@cron.manager' - - '@cron.lock_db' - tags: - - { name: console.command } - - console.command.db.list: - class: phpbb\console\command\db\list_command - arguments: - - '@user' - - '@migrator' - - '@ext.manager' - - '@config' - - '@cache' - tags: - - { name: console.command } - - console.command.db.migrate: - class: phpbb\console\command\db\migrate - arguments: - - '@user' - - '@language' - - '@migrator' - - '@ext.manager' - - '@config' - - '@cache' - - '@log' - - '@filesystem' - - '%core.root_path%' - tags: - - { name: console.command } - - console.command.db.revert: - class: phpbb\console\command\db\revert - parent: console.command.db.migrate - tags: - - { name: console.command } - - console.command.dev.migration_tips: - class: phpbb\console\command\dev\migration_tips - arguments: - - '@user' - - '@ext.manager' - tags: - - { name: console.command } - - console.command.extension.disable: - class: phpbb\console\command\extension\disable - arguments: - - '@user' - - '@ext.manager' - - '@log' - tags: - - { name: console.command } - - console.command.extension.enable: - class: phpbb\console\command\extension\enable - arguments: - - '@user' - - '@ext.manager' - - '@log' - tags: - - { name: console.command } - - console.command.extension.purge: - class: phpbb\console\command\extension\purge - arguments: - - '@user' - - '@ext.manager' - - '@log' - tags: - - { name: console.command } - - console.command.extension.show: - class: phpbb\console\command\extension\show - arguments: - - '@user' - - '@ext.manager' - - '@log' - tags: - - { name: console.command } - - console.command.fixup.update_hashes: - class: phpbb\console\command\fixup\update_hashes - arguments: - - '@config' - - '@user' - - '@dbal.conn' - - '@passwords.manager' - - '@passwords.driver_collection' - - '%passwords.algorithms%' - tags: - - { name: console.command } - - console.command.fixup.fix_left_right_ids: - class: phpbb\console\command\fixup\fix_left_right_ids - arguments: - - '@user' - - '@dbal.conn' - - '@cache.driver' - tags: - - { name: console.command } - - console.command.reparser.list: - class: phpbb\console\command\reparser\list_all - arguments: - - '@user' - - '@text_reparser_collection' - tags: - - { name: console.command } - - console.command.reparser.reparse: - class: phpbb\console\command\reparser\reparse - arguments: - - '@user' - - '@text_reparser.lock' - - '@text_reparser.manager' - - '@text_reparser_collection' - tags: - - { name: console.command } - - console.command.thumbnail.delete: - class: phpbb\console\command\thumbnail\delete - arguments: - - '@config' - - '@user' - - '@dbal.conn' - - '%core.root_path%' - tags: - - { name: console.command } - - console.command.thumbnail.generate: - class: phpbb\console\command\thumbnail\generate - arguments: - - '@config' - - '@user' - - '@dbal.conn' - - '@cache' - - '%core.root_path%' - - '%core.php_ext%' - tags: - - { name: console.command } - - console.command.thumbnail.recreate: - class: phpbb\console\command\thumbnail\recreate - arguments: - - '@user' - tags: - - { name: console.command } - - console.command.update.check: - class: phpbb\console\command\update\check - arguments: - - '@user' - - '@config' - - '@service_container' - - '@language' - tags: - - { name: console.command } - - console.command.user.activate: - class: phpbb\console\command\user\activate - arguments: - - '@user' - - '@dbal.conn' - - '@config' - - '@language' - - '@log' - - '@notification_manager' - - '@user_loader' - - '%core.root_path%' - - '%core.php_ext%' - tags: - - { name: console.command } - - console.command.user.add: - class: phpbb\console\command\user\add - arguments: - - '@user' - - '@dbal.conn' - - '@config' - - '@language' - - '@passwords.manager' - - '%core.root_path%' - - '%core.php_ext%' - tags: - - { name: console.command } - - console.command.user.delete: - class: phpbb\console\command\user\delete - arguments: - - '@user' - - '@dbal.conn' - - '@language' - - '@log' - - '@user_loader' - - '%core.root_path%' - - '%core.php_ext%' - tags: - - { name: console.command } - - console.command.user.reclean: - class: phpbb\console\command\user\reclean - arguments: - - '@user' - - '@dbal.conn' - - '@language' - tags: - - { name: console.command } diff --git a/install/update/new/config/default/container/services_content.yml b/install/update/new/config/default/container/services_content.yml deleted file mode 100644 index 6717c20..0000000 --- a/install/update/new/config/default/container/services_content.yml +++ /dev/null @@ -1,73 +0,0 @@ -services: - content.visibility: - class: phpbb\content_visibility - arguments: - - '@auth' - - '@config' - - '@dispatcher' - - '@dbal.conn' - - '@user' - - '%core.root_path%' - - '%core.php_ext%' - - '%tables.forums%' - - '%tables.posts%' - - '%tables.topics%' - - '%tables.users%' - - groupposition.legend: - class: phpbb\groupposition\legend - arguments: - - '@dbal.conn' - - '@user' - - groupposition.teampage: - class: phpbb\groupposition\teampage - arguments: - - '@dbal.conn' - - '@user' - - '@cache.driver' - - message.form.admin: - class: phpbb\message\admin_form - arguments: - - '@auth' - - '@config' - - '@config_text' - - '@dbal.conn' - - '@user' - - '@dispatcher' - - '%core.root_path%' - - '%core.php_ext%' - - message.form.topic: - class: phpbb\message\topic_form - arguments: - - '@auth' - - '@config' - - '@dbal.conn' - - '@user' - - '%core.root_path%' - - '%core.php_ext%' - - message.form.user: - class: phpbb\message\user_form - arguments: - - '@auth' - - '@config' - - '@dbal.conn' - - '@user' - - '%core.root_path%' - - '%core.php_ext%' - - pagination: - class: phpbb\pagination - arguments: - - '@template' - - '@user' - - '@controller.helper' - - '@dispatcher' - - viewonline_helper: - class: phpbb\viewonline_helper - arguments: - - '@filesystem' diff --git a/install/update/new/config/default/container/services_cron.yml b/install/update/new/config/default/container/services_cron.yml deleted file mode 100644 index 70f70e3..0000000 --- a/install/update/new/config/default/container/services_cron.yml +++ /dev/null @@ -1,248 +0,0 @@ -services: - cron.manager: - class: phpbb\cron\manager - arguments: - - '@cron.task_collection' - - '@routing.helper' - - '%core.root_path%' - - '%core.php_ext%' - - cron.lock_db: - class: phpbb\lock\db - arguments: - - cron_lock - - '@config' - - '@dbal.conn' - - cron.controller: - class: phpbb\cron\controller\cron - - cron.event_listener: - class: phpbb\cron\event\cron_runner_listener - arguments: - - '@cron.lock_db' - - '@cron.manager' - - '@request' - tags: - - { name: kernel.event_subscriber } - -# ----- Cron tasks ----- - cron.task_collection: - class: phpbb\di\service_collection - arguments: - - '@service_container' - tags: - - { name: service_collection, tag: cron.task } - - cron.task.core.prune_all_forums: - class: phpbb\cron\task\core\prune_all_forums - arguments: - - '%core.root_path%' - - '%core.php_ext%' - - '@config' - - '@dbal.conn' - calls: - - [set_name, [cron.task.core.prune_all_forums]] - tags: - - { name: cron.task } - - cron.task.core.prune_forum: - class: phpbb\cron\task\core\prune_forum - arguments: - - '%core.root_path%' - - '%core.php_ext%' - - '@config' - - '@dbal.conn' - calls: - - [set_name, [cron.task.core.prune_forum]] - tags: - - { name: cron.task } - - cron.task.core.prune_shadow_topics: - class: phpbb\cron\task\core\prune_shadow_topics - arguments: - - '%core.root_path%' - - '%core.php_ext%' - - '@config' - - '@dbal.conn' - - '@log' - - '@user' - calls: - - [set_name, [cron.task.core.prune_shadow_topics]] - tags: - - { name: cron.task } - - cron.task.core.prune_notifications: - class: phpbb\cron\task\core\prune_notifications - arguments: - - '@config' - - '@notification_manager' - calls: - - [set_name, [cron.task.core.prune_notifications]] - tags: - - { name: cron.task } - - cron.task.core.queue: - class: phpbb\cron\task\core\queue - arguments: - - '%core.root_path%' - - '%core.php_ext%' - - '@config' - - '%core.cache_dir%' - calls: - - [set_name, [cron.task.core.queue]] - tags: - - { name: cron.task } - - cron.task.core.tidy_cache: - class: phpbb\cron\task\core\tidy_cache - arguments: - - '@config' - - '@cache.driver' - calls: - - [set_name, [cron.task.core.tidy_cache]] - tags: - - { name: cron.task } - - cron.task.core.tidy_database: - class: phpbb\cron\task\core\tidy_database - arguments: - - '%core.root_path%' - - '%core.php_ext%' - - '@config' - calls: - - [set_name, [cron.task.core.tidy_database]] - tags: - - { name: cron.task } - - cron.task.core.tidy_plupload: - class: phpbb\cron\task\core\tidy_plupload - arguments: - - '%core.root_path%' - - '@config' - - '@log' - - '@user' - calls: - - [set_name, [cron.task.core.tidy_plupload]] - tags: - - { name: cron.task } - - cron.task.core.tidy_search: - class: phpbb\cron\task\core\tidy_search - arguments: - - '%core.root_path%' - - '%core.php_ext%' - - '@auth' - - '@config' - - '@dbal.conn' - - '@user' - - '@dispatcher' - calls: - - [set_name, [cron.task.core.tidy_search]] - tags: - - { name: cron.task } - - cron.task.core.tidy_sessions: - class: phpbb\cron\task\core\tidy_sessions - arguments: - - '@config' - - '@user' - calls: - - [set_name, [cron.task.core.tidy_sessions]] - tags: - - { name: cron.task } - - cron.task.core.tidy_warnings: - class: phpbb\cron\task\core\tidy_warnings - arguments: - - '%core.root_path%' - - '%core.php_ext%' - - '@config' - calls: - - [set_name, [cron.task.core.tidy_warnings]] - tags: - - { name: cron.task } - - cron.task.text_reparser.pm_text: - class: phpbb\cron\task\text_reparser\reparser - arguments: - - '@config' - - '@config_text' - - '@text_reparser.lock' - - '@text_reparser.manager' - - '@text_reparser_collection' - calls: - - [set_name, [cron.task.text_reparser.pm_text]] - - [set_reparser, [text_reparser.pm_text]] - tags: - - { name: cron.task } - - cron.task.text_reparser.poll_option: - class: phpbb\cron\task\text_reparser\reparser - arguments: - - '@config' - - '@config_text' - - '@text_reparser.lock' - - '@text_reparser.manager' - - '@text_reparser_collection' - calls: - - [set_name, [cron.task.text_reparser.poll_option]] - - [set_reparser, [text_reparser.poll_option]] - tags: - - { name: cron.task } - - cron.task.text_reparser.poll_title: - class: phpbb\cron\task\text_reparser\reparser - arguments: - - '@config' - - '@config_text' - - '@text_reparser.lock' - - '@text_reparser.manager' - - '@text_reparser_collection' - calls: - - [set_name, [cron.task.text_reparser.poll_title]] - - [set_reparser, [text_reparser.poll_title]] - tags: - - { name: cron.task } - - cron.task.text_reparser.post_text: - class: phpbb\cron\task\text_reparser\reparser - arguments: - - '@config' - - '@config_text' - - '@text_reparser.lock' - - '@text_reparser.manager' - - '@text_reparser_collection' - calls: - - [set_name, [cron.task.text_reparser.post_text]] - - [set_reparser, [text_reparser.post_text]] - tags: - - { name: cron.task } - - cron.task.text_reparser.user_signature: - class: phpbb\cron\task\text_reparser\reparser - arguments: - - '@config' - - '@config_text' - - '@text_reparser.lock' - - '@text_reparser.manager' - - '@text_reparser_collection' - calls: - - [set_name, [cron.task.text_reparser.user_signature]] - - [set_reparser, [text_reparser.user_signature]] - tags: - - { name: cron.task } - - cron.task.core.update_hashes: - class: phpbb\cron\task\core\update_hashes - arguments: - - '@config' - - '@dbal.conn' - - '@passwords.update.lock' - - '@passwords.manager' - - '@passwords.driver_collection' - - '%passwords.algorithms%' - calls: - - [set_name, [cron.task.core.update_hashes]] - tags: - - { name: cron.task } diff --git a/install/update/new/config/default/container/services_db.yml b/install/update/new/config/default/container/services_db.yml deleted file mode 100644 index d538177..0000000 --- a/install/update/new/config/default/container/services_db.yml +++ /dev/null @@ -1,71 +0,0 @@ -services: - dbal.conn: - class: phpbb\db\driver\factory - arguments: - - '@service_container' - - dbal.conn.driver: - synthetic: true - -# ----- DB Tools ----- - dbal.tools.factory: - class: phpbb\db\tools\factory - - dbal.tools: - class: phpbb\db\tools\tools_interface - factory: ['@dbal.tools.factory', get] - arguments: - - '@dbal.conn.driver' - -# ----- DB Extractor ----- - dbal.extractor.factory: - class: phpbb\db\extractor\factory - arguments: - - '@dbal.conn.driver' - - '@service_container' - - dbal.extractor: - class: phpbb\db\extractor\extractor_interface - factory: ['@dbal.extractor.factory', get] - -# ----- DB Extractors for different drivers ----- -# Service MUST NOT be shared for all the handlers to work correctly. - dbal.extractor.extractors.mssql_extractor: - class: phpbb\db\extractor\mssql_extractor - shared: false - arguments: - - '%core.root_path%' - - '@request' - - '@dbal.conn.driver' - - dbal.extractor.extractors.mysql_extractor: - class: phpbb\db\extractor\mysql_extractor - shared: false - arguments: - - '%core.root_path%' - - '@request' - - '@dbal.conn.driver' - - dbal.extractor.extractors.oracle_extractor: - class: phpbb\db\extractor\oracle_extractor - shared: false - arguments: - - '%core.root_path%' - - '@request' - - '@dbal.conn.driver' - - dbal.extractor.extractors.postgres_extractor: - class: phpbb\db\extractor\postgres_extractor - shared: false - arguments: - - '%core.root_path%' - - '@request' - - '@dbal.conn.driver' - - dbal.extractor.extractors.sqlite3_extractor: - class: phpbb\db\extractor\sqlite3_extractor - shared: false - arguments: - - '%core.root_path%' - - '@request' - - '@dbal.conn.driver' diff --git a/install/update/new/config/default/container/services_event.yml b/install/update/new/config/default/container/services_event.yml deleted file mode 100644 index 5696275..0000000 --- a/install/update/new/config/default/container/services_event.yml +++ /dev/null @@ -1,26 +0,0 @@ -services: - dispatcher: - class: phpbb\event\dispatcher - arguments: - - '@service_container' - - kernel_exception_subscriber: - class: phpbb\event\kernel_exception_subscriber - arguments: - - '@template' - - '@language' - - '%debug.exceptions%' - tags: - - { name: kernel.event_subscriber } - - kernel_terminate_subscriber: - class: phpbb\event\kernel_terminate_subscriber - tags: - - { name: kernel.event_subscriber } - - symfony_response_listener: - class: Symfony\Component\HttpKernel\EventListener\ResponseListener - arguments: - - UTF-8 - tags: - - { name: kernel.event_subscriber } diff --git a/install/update/new/config/default/container/services_feed.yml b/install/update/new/config/default/container/services_feed.yml deleted file mode 100644 index e8bac4b..0000000 --- a/install/update/new/config/default/container/services_feed.yml +++ /dev/null @@ -1,126 +0,0 @@ -services: - phpbb.feed.controller: - class: phpbb\feed\controller\feed - arguments: - - '@template.twig.environment' - - '@symfony_request' - - '@controller.helper' - - '@config' - - '@dbal.conn' - - '@service_container' - - '@feed.helper' - - '@user' - - '@auth' - - '@dispatcher' - - '%core.php_ext%' - - feed.helper: - class: phpbb\feed\helper - arguments: - - '@config' - - '@service_container' - - '@path_helper' - - '@text_formatter.renderer' - - '@user' - - feed.forum: - class: phpbb\feed\forum - shared: false - arguments: - - '@feed.helper' - - '@config' - - '@dbal.conn' - - '@cache.driver' - - '@user' - - '@auth' - - '@content.visibility' - - '@dispatcher' - - '%core.php_ext%' - - feed.forums: - class: phpbb\feed\forums - shared: false - arguments: - - '@feed.helper' - - '@config' - - '@dbal.conn' - - '@cache.driver' - - '@user' - - '@auth' - - '@content.visibility' - - '@dispatcher' - - '%core.php_ext%' - - feed.news: - class: phpbb\feed\news - shared: false - arguments: - - '@feed.helper' - - '@config' - - '@dbal.conn' - - '@cache.driver' - - '@user' - - '@auth' - - '@content.visibility' - - '@dispatcher' - - '%core.php_ext%' - - feed.overall: - class: phpbb\feed\overall - shared: false - arguments: - - '@feed.helper' - - '@config' - - '@dbal.conn' - - '@cache.driver' - - '@user' - - '@auth' - - '@content.visibility' - - '@dispatcher' - - '%core.php_ext%' - - feed.quote_helper: - class: phpbb\feed\quote_helper - parent: text_formatter.s9e.quote_helper - - feed.topic: - class: phpbb\feed\topic - shared: false - arguments: - - '@feed.helper' - - '@config' - - '@dbal.conn' - - '@cache.driver' - - '@user' - - '@auth' - - '@content.visibility' - - '@dispatcher' - - '%core.php_ext%' - - feed.topics: - class: phpbb\feed\topics - shared: false - arguments: - - '@feed.helper' - - '@config' - - '@dbal.conn' - - '@cache.driver' - - '@user' - - '@auth' - - '@content.visibility' - - '@dispatcher' - - '%core.php_ext%' - - feed.topics_active: - class: phpbb\feed\topics_active - shared: false - arguments: - - '@feed.helper' - - '@config' - - '@dbal.conn' - - '@cache.driver' - - '@user' - - '@auth' - - '@content.visibility' - - '@dispatcher' - - '%core.php_ext%' diff --git a/install/update/new/config/default/container/services_files.yml b/install/update/new/config/default/container/services_files.yml deleted file mode 100644 index ba1fdb4..0000000 --- a/install/update/new/config/default/container/services_files.yml +++ /dev/null @@ -1,57 +0,0 @@ -services: - files.factory: - class: phpbb\files\factory - arguments: - - '@service_container' - - files.filespec: - class: phpbb\files\filespec - shared: false - arguments: - - '@filesystem' - - '@language' - - '@php_ini' - - '@upload_imagesize' - - '%core.root_path%' - - '@mimetype.guesser' - - '@plupload' - - files.upload: - class: phpbb\files\upload - shared: false - arguments: - - '@filesystem' - - '@files.factory' - - '@language' - - '@php_ini' - - '@request' - - files.types.form: - class: phpbb\files\types\form - shared: false - arguments: - - '@files.factory' - - '@language' - - '@php_ini' - - '@plupload' - - '@request' - - files.types.local: - class: phpbb\files\types\local - shared: false - arguments: - - '@files.factory' - - '@language' - - '@php_ini' - - '@request' - - files.types.remote: - class: phpbb\files\types\remote - shared: false - arguments: - - '@config' - - '@files.factory' - - '@language' - - '@php_ini' - - '@request' - - '%core.root_path%' diff --git a/install/update/new/config/default/container/services_filesystem.yml b/install/update/new/config/default/container/services_filesystem.yml deleted file mode 100644 index 828f907..0000000 --- a/install/update/new/config/default/container/services_filesystem.yml +++ /dev/null @@ -1,3 +0,0 @@ -services: - filesystem: - class: phpbb\filesystem\filesystem diff --git a/install/update/new/config/default/container/services_help.yml b/install/update/new/config/default/container/services_help.yml deleted file mode 100644 index 1bff001..0000000 --- a/install/update/new/config/default/container/services_help.yml +++ /dev/null @@ -1,27 +0,0 @@ -services: - phpbb.help.manager: - class: phpbb\help\manager - arguments: - - '@dispatcher' - - '@language' - - '@template' - - phpbb.help.controller.bbcode: - class: phpbb\help\controller\bbcode - arguments: - - '@controller.helper' - - '@phpbb.help.manager' - - '@template' - - '@language' - - '%core.root_path%' - - '%core.php_ext%' - - phpbb.help.controller.faq: - class: phpbb\help\controller\faq - arguments: - - '@controller.helper' - - '@phpbb.help.manager' - - '@template' - - '@language' - - '%core.root_path%' - - '%core.php_ext%' diff --git a/install/update/new/config/default/container/services_hook.yml b/install/update/new/config/default/container/services_hook.yml deleted file mode 100644 index 10a8418..0000000 --- a/install/update/new/config/default/container/services_hook.yml +++ /dev/null @@ -1,7 +0,0 @@ -services: - hook_finder: - class: phpbb\hook\finder - arguments: - - '%core.root_path%' - - '%core.php_ext%' - - '@cache.driver' diff --git a/install/update/new/config/default/container/services_http.yml b/install/update/new/config/default/container/services_http.yml deleted file mode 100644 index 49cfbf5..0000000 --- a/install/update/new/config/default/container/services_http.yml +++ /dev/null @@ -1,23 +0,0 @@ -services: - http_kernel: - class: Symfony\Component\HttpKernel\HttpKernel - arguments: - - '@dispatcher' - - '@controller.resolver' - - '@request_stack' - - # WARNING: The Symfony request does not escape the input and should be used very carefully - # prefer the phpbb request (service @request) as possible - symfony_request: - class: phpbb\symfony_request - arguments: - - '@request' - - request_stack: - class: Symfony\Component\HttpFoundation\RequestStack - - request: - class: phpbb\request\request - arguments: - - null - - '%core.disable_super_globals%' diff --git a/install/update/new/config/default/container/services_language.yml b/install/update/new/config/default/container/services_language.yml deleted file mode 100644 index 8201fbf..0000000 --- a/install/update/new/config/default/container/services_language.yml +++ /dev/null @@ -1,22 +0,0 @@ -services: - language.helper.language_file: - class: phpbb\language\language_file_helper - arguments: - - '%core.root_path%' - - language: - class: phpbb\language\language - arguments: - - '@language.loader' - - language.loader_abstract: - abstract: true - class: phpbb\language\language_file_loader - arguments: - - '%core.root_path%' - - '%core.php_ext%' - - language.loader: - parent: language.loader_abstract - calls: - - [set_extension_manager, ['@ext.manager']] diff --git a/install/update/new/config/default/container/services_migrator.yml b/install/update/new/config/default/container/services_migrator.yml deleted file mode 100644 index c63b087..0000000 --- a/install/update/new/config/default/container/services_migrator.yml +++ /dev/null @@ -1,64 +0,0 @@ -services: -# ----- Migrator ----- - migrator: - class: phpbb\db\migrator - arguments: - - '@service_container' - - '@config' - - '@dbal.conn' - - '@dbal.tools' - - '%tables.migrations%' - - '%core.root_path%' - - '%core.php_ext%' - - '%core.table_prefix%' - - '@migrator.tool_collection' - - '@migrator.helper' - - migrator.helper: - class: phpbb\db\migration\helper - -# ----- Migrator's tools ----- - migrator.tool_collection: - class: phpbb\di\service_collection - arguments: - - '@service_container' - tags: - - { name: service_collection, tag: migrator.tool } - - migrator.tool.config: - class: phpbb\db\migration\tool\config - arguments: - - '@config' - tags: - - { name: migrator.tool } - - migrator.tool.config_text: - class: phpbb\db\migration\tool\config_text - arguments: - - '@config_text' - tags: - - { name: migrator.tool } - - migrator.tool.module: - class: phpbb\db\migration\tool\module - arguments: - - '@dbal.conn' - - '@cache' - - '@user' - - '@module.manager' - - '%core.root_path%' - - '%core.php_ext%' - - '%tables.modules%' - tags: - - { name: migrator.tool } - - migrator.tool.permission: - class: phpbb\db\migration\tool\permission - arguments: - - '@dbal.conn' - - '@cache' - - '@auth' - - '%core.root_path%' - - '%core.php_ext%' - tags: - - { name: migrator.tool } diff --git a/install/update/new/config/default/container/services_mimetype_guesser.yml b/install/update/new/config/default/container/services_mimetype_guesser.yml deleted file mode 100644 index 432470d..0000000 --- a/install/update/new/config/default/container/services_mimetype_guesser.yml +++ /dev/null @@ -1,36 +0,0 @@ -services: - mimetype.guesser_collection: - class: phpbb\di\service_collection - arguments: - - '@service_container' - tags: - - { name: service_collection, tag: mimetype.guessers } - - mimetype.fileinfo_mimetype_guesser: - class: Symfony\Component\HttpFoundation\File\MimeType\FileinfoMimeTypeGuesser - tags: - - { name: mimetype.guessers } - - mimetype.filebinary_mimetype_guesser: - class: Symfony\Component\HttpFoundation\File\MimeType\FileBinaryMimeTypeGuesser - tags: - - { name: mimetype.guessers } - - mimetype.content_guesser: - class: phpbb\mimetype\content_guesser - calls: - - [set_priority, ['%mimetype.guesser.priority.low%']] - tags: - - { name: mimetype.guessers } - - mimetype.extension_guesser: - class: phpbb\mimetype\extension_guesser - calls: - - [set_priority, ['%mimetype.guesser.priority.lowest%']] - tags: - - { name: mimetype.guessers } - - mimetype.guesser: - class: phpbb\mimetype\guesser - arguments: - - '@mimetype.guesser_collection' diff --git a/install/update/new/config/default/container/services_module.yml b/install/update/new/config/default/container/services_module.yml deleted file mode 100644 index a057e55..0000000 --- a/install/update/new/config/default/container/services_module.yml +++ /dev/null @@ -1,10 +0,0 @@ -services: - module.manager: - class: phpbb\module\module_manager - arguments: - - '@cache.driver' - - '@dbal.conn' - - '@ext.manager' - - '%tables.modules%' - - '%core.root_path%' - - '%core.php_ext%' diff --git a/install/update/new/config/default/container/services_notification.yml b/install/update/new/config/default/container/services_notification.yml deleted file mode 100644 index 6c3cea3..0000000 --- a/install/update/new/config/default/container/services_notification.yml +++ /dev/null @@ -1,224 +0,0 @@ -services: - notification_manager: - class: phpbb\notification\manager - arguments: - - '@notification.type_collection' - - '@notification.method_collection' - - '@service_container' - - '@user_loader' - - '@dispatcher' - - '@dbal.conn' - - '@cache' - - '@language' - - '@user' - - '%tables.notification_types%' - - '%tables.user_notifications%' - -# ----- Notification's types ----- -# Service MUST NOT be shared for all the plugins to work. - notification.type_collection: - class: phpbb\di\service_collection - arguments: - - '@service_container' - tags: - - { name: service_collection, tag: notification.type } - - notification.type.base: - abstract: true - arguments: - - '@dbal.conn' - - '@language' - - '@user' - - '@auth' - - '%core.root_path%' - - '%core.php_ext%' - - '%tables.user_notifications%' - - notification.type.admin_activate_user: - class: phpbb\notification\type\admin_activate_user - shared: false - parent: notification.type.base - calls: - - [set_user_loader, ['@user_loader']] - - [set_config, ['@config']] - tags: - - { name: notification.type } - - notification.type.approve_post: - class: phpbb\notification\type\approve_post - shared: false - parent: notification.type.post - tags: - - { name: notification.type } - - notification.type.approve_topic: - class: phpbb\notification\type\approve_topic - shared: false - parent: notification.type.topic - tags: - - { name: notification.type } - - notification.type.bookmark: - class: phpbb\notification\type\bookmark - shared: false - parent: notification.type.post - tags: - - { name: notification.type } - - notification.type.disapprove_post: - class: phpbb\notification\type\disapprove_post - shared: false - parent: notification.type.post - tags: - - { name: notification.type } - - notification.type.disapprove_topic: - class: phpbb\notification\type\disapprove_topic - shared: false - parent: notification.type.topic - tags: - - { name: notification.type } - - notification.type.group_request: - class: phpbb\notification\type\group_request - shared: false - parent: notification.type.base - calls: - - [set_user_loader, ['@user_loader']] - tags: - - { name: notification.type } - - notification.type.group_request_approved: - class: phpbb\notification\type\group_request_approved - shared: false - parent: notification.type.base - tags: - - { name: notification.type } - - notification.type.pm: - class: phpbb\notification\type\pm - shared: false - parent: notification.type.base - calls: - - [set_user_loader, ['@user_loader']] - - [set_config, ['@config']] - tags: - - { name: notification.type } - - notification.type.post: - class: phpbb\notification\type\post - shared: false - parent: notification.type.base - calls: - - [set_user_loader, ['@user_loader']] - - [set_config, ['@config']] - tags: - - { name: notification.type } - - notification.type.post_in_queue: - class: phpbb\notification\type\post_in_queue - shared: false - parent: notification.type.post - tags: - - { name: notification.type } - - notification.type.quote: - class: phpbb\notification\type\quote - shared: false - parent: notification.type.post - calls: - - [set_utils, ['@text_formatter.utils']] - tags: - - { name: notification.type } - - notification.type.report_pm: - class: phpbb\notification\type\report_pm - shared: false - parent: notification.type.pm - tags: - - { name: notification.type } - - notification.type.report_pm_closed: - class: phpbb\notification\type\report_pm_closed - shared: false - parent: notification.type.pm - tags: - - { name: notification.type } - - notification.type.report_post: - class: phpbb\notification\type\report_post - shared: false - parent: notification.type.post - tags: - - { name: notification.type } - - notification.type.report_post_closed: - class: phpbb\notification\type\report_post_closed - shared: false - parent: notification.type.post - tags: - - { name: notification.type } - - notification.type.topic: - class: phpbb\notification\type\topic - shared: false - parent: notification.type.base - calls: - - [set_user_loader, ['@user_loader']] - - [set_config, ['@config']] - tags: - - { name: notification.type } - - notification.type.topic_in_queue: - class: phpbb\notification\type\topic_in_queue - shared: false - parent: notification.type.topic - tags: - - { name: notification.type } - -# ----- Notification's methods ----- -# Service MUST NOT be shared for all the plugins to work. - notification.method_collection: - class: phpbb\di\service_collection - arguments: - - '@service_container' - tags: - - { name: service_collection, tag: notification.method } - - notification.method.board: - class: phpbb\notification\method\board - shared: false - arguments: - - '@user_loader' - - '@dbal.conn' - - '@cache.driver' - - '@user' - - '@config' - - '%tables.notification_types%' - - '%tables.notifications%' - tags: - - { name: notification.method } - - notification.method.email: - class: phpbb\notification\method\email - shared: false - arguments: - - '@user_loader' - - '@user' - - '@config' - - '%core.root_path%' - - '%core.php_ext%' - tags: - - { name: notification.method } - - notification.method.jabber: - class: phpbb\notification\method\jabber - shared: false - arguments: - - '@user_loader' - - '@user' - - '@config' - - '%core.root_path%' - - '%core.php_ext%' - tags: - - { name: notification.method } diff --git a/install/update/new/config/default/container/services_password.yml b/install/update/new/config/default/container/services_password.yml deleted file mode 100644 index a9adbeb..0000000 --- a/install/update/new/config/default/container/services_password.yml +++ /dev/null @@ -1,156 +0,0 @@ -parameters: - passwords.driver.argon2_memory_cost: 1024 - passwords.driver.argon2_threads: 2 - passwords.driver.argon2_time_cost: 2 - passwords.driver.bcrypt_cost: 10 - -services: -# ----- Password management ----- - passwords.manager: - class: phpbb\passwords\manager - arguments: - - '@config' - - '@passwords.driver_collection' - - '@passwords.helper' - - '%passwords.algorithms%' - - passwords.helper: - class: phpbb\passwords\helper - - passwords.driver_helper: - class: phpbb\passwords\driver\helper - arguments: - - '@config' - -# ----- Password's drivers ----- - passwords.driver_collection: - class: phpbb\di\service_collection - arguments: - - '@service_container' - tags: - - { name: service_collection, tag: passwords.driver } - - passwords.driver.argon2i: - class: phpbb\passwords\driver\argon2i - arguments: - - '@config' - - '@passwords.driver_helper' - - '%passwords.driver.argon2_memory_cost%' - - '%passwords.driver.argon2_threads%' - - '%passwords.driver.argon2_time_cost%' - tags: - - { name: passwords.driver } - - passwords.driver.argon2id: - class: phpbb\passwords\driver\argon2id - parent: passwords.driver.argon2i - tags: - - { name: passwords.driver } - - passwords.driver.bcrypt: - class: phpbb\passwords\driver\bcrypt - arguments: - - '@config' - - '@passwords.driver_helper' - - '%passwords.driver.bcrypt_cost%' - tags: - - { name: passwords.driver } - - passwords.driver.bcrypt_2y: - class: phpbb\passwords\driver\bcrypt_2y - arguments: - - '@config' - - '@passwords.driver_helper' - - '%passwords.driver.bcrypt_cost%' - tags: - - { name: passwords.driver } - - passwords.driver.bcrypt_wcf2: - class: phpbb\passwords\driver\bcrypt_wcf2 - arguments: - - '@passwords.driver.bcrypt' - - '@passwords.driver_helper' - tags: - - { name: passwords.driver } - - passwords.driver.salted_md5: - class: phpbb\passwords\driver\salted_md5 - arguments: - - '@config' - - '@passwords.driver_helper' - tags: - - { name: passwords.driver } - - passwords.driver.phpass: - class: phpbb\passwords\driver\phpass - arguments: - - '@config' - - '@passwords.driver_helper' - tags: - - { name: passwords.driver } - - passwords.driver.convert_password: - class: phpbb\passwords\driver\convert_password - arguments: - - '@config' - - '@passwords.driver_helper' - tags: - - { name: passwords.driver } - - passwords.driver.sha1_smf: - class: phpbb\passwords\driver\sha1_smf - arguments: - - '@config' - - '@passwords.driver_helper' - tags: - - { name: passwords.driver } - - passwords.driver.sha1_wcf1: - class: phpbb\passwords\driver\sha1_wcf1 - arguments: - - '@config' - - '@passwords.driver_helper' - tags: - - { name: passwords.driver } - - passwords.driver.sha1: - class: phpbb\passwords\driver\sha1 - arguments: - - '@config' - - '@passwords.driver_helper' - tags: - - { name: passwords.driver } - - passwords.driver.md5_phpbb2: - class: phpbb\passwords\driver\md5_phpbb2 - arguments: - - '@request' - - '@passwords.driver.salted_md5' - - '@passwords.driver_helper' - - '%core.root_path%' - - '%core.php_ext%' - tags: - - { name: passwords.driver } - - passwords.driver.md5_mybb: - class: phpbb\passwords\driver\md5_mybb - arguments: - - '@config' - - '@passwords.driver_helper' - tags: - - { name: passwords.driver } - - passwords.driver.md5_vb: - class: phpbb\passwords\driver\md5_vb - arguments: - - '@config' - - '@passwords.driver_helper' - tags: - - { name: passwords.driver } - - passwords.update.lock: - class: phpbb\lock\db - arguments: - - update_hashes_lock - - '@config' - - '@dbal.conn' diff --git a/install/update/new/config/default/container/services_php.yml b/install/update/new/config/default/container/services_php.yml deleted file mode 100644 index 2934996..0000000 --- a/install/update/new/config/default/container/services_php.yml +++ /dev/null @@ -1,3 +0,0 @@ -services: - php_ini: - class: bantu\IniGetWrapper\IniGetWrapper diff --git a/install/update/new/config/default/container/services_profilefield.yml b/install/update/new/config/default/container/services_profilefield.yml deleted file mode 100644 index 90b2283..0000000 --- a/install/update/new/config/default/container/services_profilefield.yml +++ /dev/null @@ -1,102 +0,0 @@ -services: - profilefields.manager: - class: phpbb\profilefields\manager - arguments: - - '@auth' - - '@dbal.conn' - - '@dispatcher' - - '@request' - - '@template' - - '@profilefields.type_collection' - - '@user' - - '%tables.profile_fields%' - - '%tables.profile_fields_language%' - - '%tables.profile_fields_data%' - - profilefields.lang_helper: - class: phpbb\profilefields\lang_helper - arguments: - - '@dbal.conn' - - '%tables.profile_fields_options_language%' - -# ----- Profile fields types ----- - profilefields.type_collection: - class: phpbb\di\service_collection - arguments: - - '@service_container' - tags: - - { name: service_collection, tag: profilefield.type } - - profilefields.type.bool: - class: phpbb\profilefields\type\type_bool - arguments: - - '@profilefields.lang_helper' - - '@request' - - '@template' - - '@user' - tags: - - { name: profilefield.type } - - profilefields.type.date: - class: phpbb\profilefields\type\type_date - arguments: - - '@request' - - '@template' - - '@user' - tags: - - { name: profilefield.type } - - profilefields.type.dropdown: - class: phpbb\profilefields\type\type_dropdown - arguments: - - '@profilefields.lang_helper' - - '@request' - - '@template' - - '@user' - tags: - - { name: profilefield.type } - - profilefields.type.googleplus: - class: phpbb\profilefields\type\type_googleplus - arguments: - - '@request' - - '@template' - - '@user' - tags: - - { name: profilefield.type } - - profilefields.type.int: - class: phpbb\profilefields\type\type_int - arguments: - - '@request' - - '@template' - - '@user' - tags: - - { name: profilefield.type } - - profilefields.type.string: - class: phpbb\profilefields\type\type_string - arguments: - - '@request' - - '@template' - - '@user' - tags: - - { name: profilefield.type } - - profilefields.type.text: - class: phpbb\profilefields\type\type_text - arguments: - - '@request' - - '@template' - - '@user' - tags: - - { name: profilefield.type } - - profilefields.type.url: - class: phpbb\profilefields\type\type_url - arguments: - - '@request' - - '@template' - - '@user' - tags: - - { name: profilefield.type } diff --git a/install/update/new/config/default/container/services_report.yml b/install/update/new/config/default/container/services_report.yml deleted file mode 100644 index 2c5b3bf..0000000 --- a/install/update/new/config/default/container/services_report.yml +++ /dev/null @@ -1,53 +0,0 @@ -services: -# ----- Report controller ----- - phpbb.report.controller: - class: phpbb\report\controller\report - arguments: - - '@config' - - '@user' - - '@template' - - '@controller.helper' - - '@request' - - '@captcha.factory' - - '@phpbb.report.handler_factory' - - '@phpbb.report.report_reason_list_provider' - - '%core.root_path%' - - '%core.php_ext%' - -# ----- Report handler factory ----- - phpbb.report.handler_factory: - class: phpbb\report\handler_factory - arguments: - - '@service_container' - -# ----- Report UI provider ----- - phpbb.report.report_reason_list_provider: - class: phpbb\report\report_reason_list_provider - arguments: - - '@dbal.conn.driver' - - '@template' - - '@user' - -# ----- Report handlers ----- -# Service MUST NOT be shared for all the handlers to work correctly. - phpbb.report.handlers.report_handler_pm: - class: phpbb\report\report_handler_pm - shared: false - arguments: - - '@dbal.conn.driver' - - '@dispatcher' - - '@config' - - '@auth' - - '@user' - - '@notification_manager' - - phpbb.report.handlers.report_handler_post: - class: phpbb\report\report_handler_post - shared: false - arguments: - - '@dbal.conn.driver' - - '@dispatcher' - - '@config' - - '@auth' - - '@user' - - '@notification_manager' diff --git a/install/update/new/config/default/container/services_routing.yml b/install/update/new/config/default/container/services_routing.yml deleted file mode 100644 index 0bf0a33..0000000 --- a/install/update/new/config/default/container/services_routing.yml +++ /dev/null @@ -1,77 +0,0 @@ -services: - router: - class: phpbb\routing\router - arguments: - - '@service_container' - - '@routing.chained_resources_locator' - - '@routing.delegated_loader' - - '%core.php_ext%' - - '%core.cache_dir%' - - router.listener: - class: Symfony\Component\HttpKernel\EventListener\RouterListener - arguments: - - '@router' - - '@request_stack' - tags: - - { name: kernel.event_subscriber } - - routing.helper: - class: phpbb\routing\helper - arguments: - - '@config' - - '@router' - - '@symfony_request' - - '@request' - - '@filesystem' - - '%core.root_path%' - - '%core.php_ext%' - -# ---- Route loaders ---- - - routing.delegated_loader: - class: Symfony\Component\Config\Loader\DelegatingLoader - arguments: - - '@routing.resolver' - - routing.resolver: - class: phpbb\routing\loader_resolver - arguments: - - '@routing.loader.collection' - - routing.loader.collection: - class: phpbb\di\service_collection - arguments: - - '@service_container' - tags: - - { name: service_collection, tag: routing.loader } - - routing.loader.yaml: - class: Symfony\Component\Routing\Loader\YamlFileLoader - arguments: - - '@file_locator' - tags: - - { name: routing.loader } - -# ---- Resources Locators ---- - - routing.chained_resources_locator: - class: phpbb\routing\resources_locator\chained_resources_locator - arguments: - - '@routing.resources_locator.collection' - - routing.resources_locator.collection: - class: phpbb\di\service_collection - arguments: - - '@service_container' - tags: - - { name: service_collection, tag: routing.resources_locator } - - routing.resources_locator.default: - class: phpbb\routing\resources_locator\default_resources_locator - arguments: - - '%core.root_path%' - - '%core.environment%' - - '@ext.manager' - tags: - - { name: routing.resources_locator } diff --git a/install/update/new/config/default/container/services_text_formatter.yml b/install/update/new/config/default/container/services_text_formatter.yml deleted file mode 100644 index 4e4abf6..0000000 --- a/install/update/new/config/default/container/services_text_formatter.yml +++ /dev/null @@ -1,84 +0,0 @@ -parameters: - text_formatter.cache.dir: '%core.cache_dir%' - text_formatter.cache.parser.key: _text_formatter_parser - text_formatter.cache.renderer.key: _text_formatter_renderer - -services: - text_formatter.acp_utils: - class: phpbb\textformatter\s9e\acp_utils - arguments: - - '@text_formatter.s9e.factory' - - text_formatter.cache: - alias: text_formatter.s9e.factory - - text_formatter.data_access: - class: phpbb\textformatter\data_access - arguments: - - '@dbal.conn' - - '%tables.bbcodes%' - - '%tables.smilies%' - - '%tables.styles%' - - '%tables.words%' - - '%core.root_path%styles/' - - text_formatter.parser: - alias: text_formatter.s9e.parser - - text_formatter.renderer: - alias: text_formatter.s9e.renderer - - text_formatter.utils: - alias: text_formatter.s9e.utils - - text_formatter.s9e.bbcode_merger: - class: phpbb\textformatter\s9e\bbcode_merger - arguments: - - '@text_formatter.s9e.factory' - - text_formatter.s9e.factory: - class: phpbb\textformatter\s9e\factory - arguments: - - '@text_formatter.data_access' - - '@cache.driver' - - '@dispatcher' - - '@config' - - '@text_formatter.s9e.link_helper' - - '@log' - - '%text_formatter.cache.dir%' - - '%text_formatter.cache.parser.key%' - - '%text_formatter.cache.renderer.key%' - - text_formatter.s9e.link_helper: - class: phpbb\textformatter\s9e\link_helper - - text_formatter.s9e.parser: - class: phpbb\textformatter\s9e\parser - arguments: - - '@cache.driver' - - '%text_formatter.cache.parser.key%' - - '@text_formatter.s9e.factory' - - '@dispatcher' - - text_formatter.s9e.quote_helper: - class: phpbb\textformatter\s9e\quote_helper - arguments: - - '@user' - - '%core.root_path%' - - '%core.php_ext%' - - text_formatter.s9e.renderer: - class: phpbb\textformatter\s9e\renderer - arguments: - - '@cache.driver' - - '%text_formatter.cache.dir%' - - '%text_formatter.cache.renderer.key%' - - '@text_formatter.s9e.factory' - - '@dispatcher' - calls: - - [configure_quote_helper, ['@text_formatter.s9e.quote_helper']] - - [configure_smilies_path, ['@config', '@path_helper']] - - [configure_user, ['@user', '@config', '@auth']] - - text_formatter.s9e.utils: - class: phpbb\textformatter\s9e\utils diff --git a/install/update/new/config/default/container/services_text_reparser.yml b/install/update/new/config/default/container/services_text_reparser.yml deleted file mode 100644 index 4bc49f5..0000000 --- a/install/update/new/config/default/container/services_text_reparser.yml +++ /dev/null @@ -1,109 +0,0 @@ -services: - text_reparser.manager: - class: phpbb\textreparser\manager - arguments: - - '@config' - - '@config_text' - - '@text_reparser_collection' - - text_reparser.lock: - class: phpbb\lock\db - arguments: - - reparse_lock - - '@config' - - '@dbal.conn' - - text_reparser_collection: - class: phpbb\di\service_collection - arguments: - - '@service_container' - tags: - - { name: service_collection, tag: text_reparser.plugin } - - text_reparser.contact_admin_info: - class: phpbb\textreparser\plugins\contact_admin_info - arguments: - - '@config_text' - calls: - - [set_name, [contact_admin_info]] - tags: - - { name: text_reparser.plugin } - - text_reparser.forum_description: - class: phpbb\textreparser\plugins\forum_description - arguments: - - '@dbal.conn' - - '%tables.forums%' - calls: - - [set_name, [forum_description]] - tags: - - { name: text_reparser.plugin } - - text_reparser.forum_rules: - class: phpbb\textreparser\plugins\forum_rules - arguments: - - '@dbal.conn' - - '%tables.forums%' - calls: - - [set_name, [forum_rules]] - tags: - - { name: text_reparser.plugin } - - text_reparser.group_description: - class: phpbb\textreparser\plugins\group_description - arguments: - - '@dbal.conn' - - '%tables.groups%' - calls: - - [set_name, [group_description]] - tags: - - { name: text_reparser.plugin } - - text_reparser.pm_text: - class: phpbb\textreparser\plugins\pm_text - arguments: - - '@dbal.conn' - - '%tables.privmsgs%' - calls: - - [set_name, [pm_text]] - tags: - - { name: text_reparser.plugin } - - text_reparser.poll_option: - class: phpbb\textreparser\plugins\poll_option - arguments: - - '@dbal.conn' - calls: - - [set_name, [poll_option]] - tags: - - { name: text_reparser.plugin } - - text_reparser.poll_title: - class: phpbb\textreparser\plugins\poll_title - arguments: - - '@dbal.conn' - - '%tables.topics%' - calls: - - [set_name, [poll_title]] - tags: - - { name: text_reparser.plugin } - - text_reparser.post_text: - class: phpbb\textreparser\plugins\post_text - arguments: - - '@dbal.conn' - - '%tables.posts%' - calls: - - [set_name, [post_text]] - tags: - - { name: text_reparser.plugin } - - text_reparser.user_signature: - class: phpbb\textreparser\plugins\user_signature - arguments: - - '@dbal.conn' - - '%tables.users%' - calls: - - [set_name, [user_signature]] - tags: - - { name: text_reparser.plugin } diff --git a/install/update/new/config/default/container/services_twig.yml b/install/update/new/config/default/container/services_twig.yml deleted file mode 100644 index 6f70155..0000000 --- a/install/update/new/config/default/container/services_twig.yml +++ /dev/null @@ -1,86 +0,0 @@ -parameters: - core.template.cache_path: '%core.cache_dir%twig/' - -services: - template.twig.environment: - class: phpbb\template\twig\environment - arguments: - - '@config' - - '@filesystem' - - '@path_helper' - - '%core.template.cache_path%' - - '@ext.manager' - - '@template.twig.loader' - - '@dispatcher' - - [] - calls: - - [setLexer, ['@template.twig.lexer']] - - template.twig.lexer: - class: phpbb\template\twig\lexer - lazy: true - arguments: - - '@template.twig.environment' - - template.twig.loader: - class: phpbb\template\twig\loader - arguments: - - '@filesystem' - - template.twig.extensions.collection: - class: phpbb\di\service_collection - arguments: - - '@service_container' - tags: - - { name: service_collection, tag: twig.extension } - - template.twig.extensions.phpbb: - class: phpbb\template\twig\extension - arguments: - - '@template_context' - - '@template.twig.environment' - - '@language' - tags: - - { name: twig.extension } - - template.twig.extensions.avatar: - class: phpbb\template\twig\extension\avatar - tags: - - { name: twig.extension } - - template.twig.extensions.config: - class: phpbb\template\twig\extension\config - arguments: - - '@config' - tags: - - { name: twig.extension } - - template.twig.extensions.routing: - class: phpbb\template\twig\extension\routing - arguments: - - '@routing.helper' - tags: - - { name: twig.extension } - - template.twig.extensions.username: - class: phpbb\template\twig\extension\username - tags: - - { name: twig.extension } - - template.twig.extensions.debug: - class: Twig_Extension_Debug - - template: - class: phpbb\template\twig\twig - arguments: - - '@path_helper' - - '@config' - - '@template_context' - - '@template.twig.environment' - - '%core.template.cache_path%' - - '@user' - - '@template.twig.extensions.collection' - - '@ext.manager' - - template_context: - class: phpbb\template\context diff --git a/install/update/new/config/default/container/services_ucp.yml b/install/update/new/config/default/container/services_ucp.yml deleted file mode 100644 index 861fa4a..0000000 --- a/install/update/new/config/default/container/services_ucp.yml +++ /dev/null @@ -1,17 +0,0 @@ -services: - phpbb.ucp.controller.reset_password: - class: phpbb\ucp\controller\reset_password - arguments: - - '@config' - - '@dbal.conn' - - '@dispatcher' - - '@controller.helper' - - '@language' - - '@log' - - '@passwords.manager' - - '@request' - - '@template' - - '@user' - - '%tables.users%' - - '%core.root_path%' - - '%core.php_ext%' diff --git a/install/update/new/config/default/container/services_user.yml b/install/update/new/config/default/container/services_user.yml deleted file mode 100644 index 7e634c6..0000000 --- a/install/update/new/config/default/container/services_user.yml +++ /dev/null @@ -1,20 +0,0 @@ -services: - acl.permissions: - class: phpbb\permissions - arguments: - - '@dispatcher' - - '@user' - - user: - class: phpbb\user - arguments: - - '@language' - - '%datetime.class%' - - user_loader: - class: phpbb\user_loader - arguments: - - '@dbal.conn' - - '%core.root_path%' - - '%core.php_ext%' - - '%tables.users%' diff --git a/install/update/new/config/default/container/tables.yml b/install/update/new/config/default/container/tables.yml deleted file mode 100644 index 4aed357..0000000 --- a/install/update/new/config/default/container/tables.yml +++ /dev/null @@ -1,78 +0,0 @@ -parameters: - tables.acl_groups: '%core.table_prefix%acl_groups' - tables.acl_options: '%core.table_prefix%acl_options' - tables.acl_roles: '%core.table_prefix%acl_roles' - tables.acl_roles_data: '%core.table_prefix%acl_roles_data' - tables.acl_users: '%core.table_prefix%acl_users' - tables.attachments: '%core.table_prefix%attachments' - tables.auth_provider_oauth_token_storage: '%core.table_prefix%oauth_tokens' - tables.auth_provider_oauth_states: '%core.table_prefix%oauth_states' - tables.auth_provider_oauth_account_assoc: '%core.table_prefix%oauth_accounts' - tables.banlist: '%core.table_prefix%banlist' - tables.bbcodes: '%core.table_prefix%bbcodes' - tables.bookmarks: '%core.table_prefix%bookmarks' - tables.bots: '%core.table_prefix%bots' - tables.captcha_qa_questions: '%core.table_prefix%captcha_questions' - tables.captcha_qa_answers: '%core.table_prefix%captcha_answers' - tables.captcha_qa_confirm: '%core.table_prefix%qa_confirm' - tables.config: '%core.table_prefix%config' - tables.config_text: '%core.table_prefix%config_text' - tables.confirm: '%core.table_prefix%confirm' - tables.disallow: '%core.table_prefix%disallow' - tables.drafts: '%core.table_prefix%drafts' - tables.ext: '%core.table_prefix%ext' - tables.extensions: '%core.table_prefix%extensions' - tables.extension_groups: '%core.table_prefix%extension_groups' - tables.forums: '%core.table_prefix%forums' - tables.forums_access: '%core.table_prefix%forums_access' - tables.forums_track: '%core.table_prefix%forums_track' - tables.forums_watch: '%core.table_prefix%forums_watch' - tables.groups: '%core.table_prefix%groups' - tables.icons: '%core.table_prefix%icons' - tables.lang: '%core.table_prefix%lang' - tables.log: '%core.table_prefix%log' - tables.login_attempts: '%core.table_prefix%login_attempts' - tables.migrations: '%core.table_prefix%migrations' - tables.moderator_cache: '%core.table_prefix%moderator_cache' - tables.modules: '%core.table_prefix%modules' - tables.notification_types: '%core.table_prefix%notification_types' - tables.notifications: '%core.table_prefix%notifications' - tables.poll_options: '%core.table_prefix%poll_options' - tables.poll_votes: '%core.table_prefix%poll_votes' - tables.posts: '%core.table_prefix%posts' - tables.privmsgs: '%core.table_prefix%privmsgs' - tables.privmsgs_folder: '%core.table_prefix%privmsgs_folder' - tables.privmsgs_rules: '%core.table_prefix%privmsgs_rules' - tables.privmsgs_to: '%core.table_prefix%privmsgs_to' - tables.profile_fields: '%core.table_prefix%profile_fields' - tables.profile_fields_data: '%core.table_prefix%profile_fields_data' - tables.profile_fields_options_language: '%core.table_prefix%profile_fields_lang' - tables.profile_fields_language: '%core.table_prefix%profile_lang' - tables.ranks: '%core.table_prefix%ranks' - tables.reports: '%core.table_prefix%reports' - tables.reports_reasons: '%core.table_prefix%reports_reasons' - tables.search_results: '%core.table_prefix%search_results' - tables.search_wordlist: '%core.table_prefix%search_wordlist' - tables.search_wordmatch: '%core.table_prefix%search_wordmatch' - tables.sessions: '%core.table_prefix%sessions' - tables.sessions_keys: '%core.table_prefix%sessions_keys' - tables.sitelist: '%core.table_prefix%sitelist' - tables.smilies: '%core.table_prefix%smilies' - tables.sphinx: '%core.table_prefix%sphinx' - tables.styles: '%core.table_prefix%styles' - tables.styles_template: '%core.table_prefix%styles_template' - tables.styles_template_data: '%core.table_prefix%styles_template_data' - tables.styles_theme: '%core.table_prefix%styles_theme' - tables.styles_imageset: '%core.table_prefix%styles_imageset' - tables.styles_imageset_data: '%core.table_prefix%styles_imageset_data' - tables.teampage: '%core.table_prefix%teampage' - tables.topics: '%core.table_prefix%topics' - tables.topics_posted: '%core.table_prefix%topics_posted' - tables.topics_track: '%core.table_prefix%topics_track' - tables.topics_watch: '%core.table_prefix%topics_watch' - tables.user_group: '%core.table_prefix%user_group' - tables.user_notifications: '%core.table_prefix%user_notifications' - tables.users: '%core.table_prefix%users' - tables.warnings: '%core.table_prefix%warnings' - tables.words: '%core.table_prefix%words' - tables.zebra: '%core.table_prefix%zebra' diff --git a/install/update/new/config/default/routing/cron.yml b/install/update/new/config/default/routing/cron.yml deleted file mode 100644 index 5a63416..0000000 --- a/install/update/new/config/default/routing/cron.yml +++ /dev/null @@ -1,3 +0,0 @@ -phpbb_cron_run: - path: /{cron_type} - defaults: { _controller: cron.controller:handle } diff --git a/install/update/new/config/default/routing/feed.yml b/install/update/new/config/default/routing/feed.yml deleted file mode 100644 index 22c9ea5..0000000 --- a/install/update/new/config/default/routing/feed.yml +++ /dev/null @@ -1,35 +0,0 @@ -phpbb_feed_forums: - path: /forums - defaults: { _controller: phpbb.feed.controller:forums } - -phpbb_feed_news: - path: /news - defaults: { _controller: phpbb.feed.controller:news } - -phpbb_feed_topics: - path: /topics - defaults: { _controller: phpbb.feed.controller:topics } - -phpbb_feed_topics_active: - path: /topics_active - defaults: { _controller: phpbb.feed.controller:topics_active } - -phpbb_feed_topics_new: - path: /topics_new - defaults: { _controller: phpbb.feed.controller:topics_new } - -phpbb_feed_forum: - path: /forum/{forum_id} - defaults: { _controller: phpbb.feed.controller:forum } - requirements: - forum_id: \d+ - -phpbb_feed_topic: - path: /topic/{topic_id} - defaults: { _controller: phpbb.feed.controller:topic } - requirements: - topic_id: \d+ - -phpbb_feed_overall: - path: /{mode} - defaults: { _controller: phpbb.feed.controller:overall } diff --git a/install/update/new/config/default/routing/help.yml b/install/update/new/config/default/routing/help.yml deleted file mode 100644 index 8d43839..0000000 --- a/install/update/new/config/default/routing/help.yml +++ /dev/null @@ -1,7 +0,0 @@ -phpbb_help_bbcode_controller: - path: /bbcode - defaults: { _controller: phpbb.help.controller.bbcode:handle } - -phpbb_help_faq_controller: - path: /faq - defaults: { _controller: phpbb.help.controller.faq:handle } diff --git a/install/update/new/config/default/routing/report.yml b/install/update/new/config/default/routing/report.yml deleted file mode 100644 index c386770..0000000 --- a/install/update/new/config/default/routing/report.yml +++ /dev/null @@ -1,17 +0,0 @@ -phpbb_report_pm_controller: - path: /pm/{id}/report - methods: [GET, POST] - defaults: - _controller: phpbb.report.controller:handle - mode: 'pm' - requirements: - id: \d+ - -phpbb_report_post_controller: - path: /post/{id}/report - methods: [GET, POST] - defaults: - _controller: phpbb.report.controller:handle - mode: 'post' - requirements: - id: \d+ diff --git a/install/update/new/config/default/routing/routing.yml b/install/update/new/config/default/routing/routing.yml deleted file mode 100644 index a5e9265..0000000 --- a/install/update/new/config/default/routing/routing.yml +++ /dev/null @@ -1,32 +0,0 @@ -# Structure: -# -# foo_controller: -# path: /foo -# defaults: { _controller: foo_sevice:method } -# -# The above will be accessed via app.php?controller=foo and it will -# instantiate the 'foo_service' service and call the 'method' method. -# - -phpbb_cron_routing: - resource: cron.yml - prefix: /cron - -phpbb_feed_routing: - resource: feed.yml - prefix: /feed - -phpbb_feed_index: - path: /feed - defaults: { _controller: phpbb.feed.controller:overall } - -phpbb_help_routing: - resource: help.yml - prefix: /help - -phpbb_report_routing: - resource: report.yml - -phpbb_ucp_routing: - resource: ucp.yml - prefix: /user diff --git a/install/update/new/config/default/routing/ucp.yml b/install/update/new/config/default/routing/ucp.yml deleted file mode 100644 index 06bd7c3..0000000 --- a/install/update/new/config/default/routing/ucp.yml +++ /dev/null @@ -1,7 +0,0 @@ -phpbb_ucp_reset_password_controller: - path: /reset_password - defaults: { _controller: phpbb.ucp.controller.reset_password:reset } - -phpbb_ucp_forgot_password_controller: - path: /forgot_password - defaults: { _controller: phpbb.ucp.controller.reset_password:request } diff --git a/install/update/new/config/installer/config.yml b/install/update/new/config/installer/config.yml deleted file mode 100644 index 979dbbc..0000000 --- a/install/update/new/config/installer/config.yml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - - { resource: ../default/config.yml } diff --git a/install/update/new/config/installer/container/environment.yml b/install/update/new/config/installer/container/environment.yml deleted file mode 100644 index 40a3c7a..0000000 --- a/install/update/new/config/installer/container/environment.yml +++ /dev/null @@ -1,3 +0,0 @@ -imports: - - { resource: services.yml } - - { resource: parameters.yml } diff --git a/install/update/new/config/installer/container/parameters.yml b/install/update/new/config/installer/container/parameters.yml deleted file mode 100644 index f11f7e2..0000000 --- a/install/update/new/config/installer/container/parameters.yml +++ /dev/null @@ -1,5 +0,0 @@ -imports: - - { resource: ../../default/container/parameters.yml } - -parameters: - installer.create_config_file.options: [] diff --git a/install/update/new/config/installer/container/services.yml b/install/update/new/config/installer/container/services.yml deleted file mode 100644 index 7203c0a..0000000 --- a/install/update/new/config/installer/container/services.yml +++ /dev/null @@ -1,104 +0,0 @@ -imports: - - { resource: services_installer.yml } - - { resource: ../../default/container/services_event.yml } - - { resource: ../../default/container/services_filesystem.yml } - - { resource: ../../default/container/services_http.yml } - - { resource: ../../default/container/services_language.yml } - - { resource: ../../default/container/services_php.yml } - - { resource: ../../default/container/services_routing.yml } - - { resource: ../../default/container/services_twig.yml } - -services: - cache.driver: - class: '%cache.driver.class%' - arguments: - - '%core.cache_dir%' - - config: - class: phpbb\config\config - arguments: - - - rand_seed: 'installer_seed' - rand_seed_last_update: 0 - - controller.resolver: - class: phpbb\controller\resolver - arguments: - - '@service_container' - - '%core.root_path%' - - '@template' - - file_locator: - class: phpbb\routing\file_locator - arguments: - - '@filesystem' - - '%core.root_path%' - - kernel_exception_subscriber: - class: phpbb\install\event\kernel_exception_subscriber - arguments: - - '@phpbb.installer.controller.helper' - - '@language' - - '@template' - tags: - - { name: kernel.event_subscriber } - - language.loader: - parent: language.loader_abstract - - path_helper: - class: phpbb\path_helper - arguments: - - '@symfony_request' - - '@filesystem' - - '@request' - - '%core.root_path%' - - '%core.php_ext%' - - routing.resources_locator.default: - class: phpbb\routing\resources_locator\installer_resources_locator - arguments: - - '@filesystem' - - '%core.root_path%' - - '%core.environment%' - tags: - - { name: routing.resources_locator } - - template: - class: phpbb\template\twig\twig - arguments: - - '@path_helper' - - '@config' - - '@template_context' - - '@template.twig.environment' - - '%core.template.cache_path%' - - null - - '@template.twig.extensions.collection' - - template.twig.environment: - class: phpbb\template\twig\environment - arguments: - - '@config' - - '@filesystem' - - '@path_helper' - - '%core.template.cache_path%' - - null - - '@template.twig.loader' - - null - - [] - calls: - - [setLexer, ['@template.twig.lexer']] - - user: - class: phpbb\user - arguments: - - '@language' - - '%datetime.class%' - - console.exception_subscriber: - class: phpbb\console\exception_subscriber - arguments: - - '@language' - - '%debug.exceptions%' - tags: - - { name: kernel.event_subscriber } diff --git a/install/update/new/config/installer/container/services_file_updater.yml b/install/update/new/config/installer/container/services_file_updater.yml deleted file mode 100644 index 9d39bb8..0000000 --- a/install/update/new/config/installer/container/services_file_updater.yml +++ /dev/null @@ -1,38 +0,0 @@ -services: - installer.file_updater.factory: - class: phpbb\install\helper\file_updater\factory - arguments: - - '@installer.file_updater.collection' - - installer.file_updater.collection: - class: phpbb\di\service_collection - arguments: - - '@service_container' - tags: - - { name: service_collection, tag: file_updater } - - installer.file_updater.compress: - class: phpbb\install\helper\file_updater\compression_file_updater - arguments: - - '@installer.helper.update_helper' - - '%core.root_path%' - - '%core.php_ext%' - tags: - - { name: file_updater } - - installer.file_updater.ftp: - class: phpbb\install\helper\file_updater\ftp_file_updater - arguments: - - '@installer.helper.update_helper' - - '%core.root_path%' - - '%core.php_ext%' - tags: - - { name: file_updater } - - installer.file_updater.file: - class: phpbb\install\helper\file_updater\file_updater - arguments: - - '@filesystem' - - '%core.root_path%' - tags: - - { name: file_updater } diff --git a/install/update/new/config/installer/container/services_install_console.yml b/install/update/new/config/installer/container/services_install_console.yml deleted file mode 100644 index 41d3aa4..0000000 --- a/install/update/new/config/installer/container/services_install_console.yml +++ /dev/null @@ -1,61 +0,0 @@ -services: - console.installer.command_collection: - class: phpbb\di\service_collection - arguments: - - '@service_container' - tags: - - { name: service_collection, tag: console.installer.command } - - console.installer.command.install: - class: phpbb\install\console\command\install\install - arguments: - - '@language' - - '@installer.helper.iohandler_factory' - - '@installer.installer.install' - - '@installer.helper.install_helper' - tags: - - { name: console.installer.command } - - console.installer.command.config.show: - class: phpbb\install\console\command\install\config\show - arguments: - - '@language' - - '@installer.helper.iohandler_factory' - tags: - - { name: console.installer.command } - - - console.installer.command.config.validate: - class: phpbb\install\console\command\install\config\validate - arguments: - - '@language' - - '@installer.helper.iohandler_factory' - tags: - - { name: console.installer.command } - - console.updater.command.update: - class: phpbb\install\console\command\update\update - arguments: - - '@language' - - '@installer.helper.iohandler_factory' - - '@installer.installer.update' - - '@installer.helper.install_helper' - tags: - - { name: console.installer.command } - - console.updater.command.config.show: - class: phpbb\install\console\command\update\config\show - arguments: - - '@language' - - '@installer.helper.iohandler_factory' - tags: - - { name: console.installer.command } - - - console.updater.command.config.validate: - class: phpbb\install\console\command\update\config\validate - arguments: - - '@language' - - '@installer.helper.iohandler_factory' - tags: - - { name: console.installer.command } diff --git a/install/update/new/config/installer/container/services_install_controller.yml b/install/update/new/config/installer/container/services_install_controller.yml deleted file mode 100644 index 5aaba0f..0000000 --- a/install/update/new/config/installer/container/services_install_controller.yml +++ /dev/null @@ -1,73 +0,0 @@ -services: - phpbb.installer.controller.welcome: - class: phpbb\install\controller\installer_index - arguments: - - '@phpbb.installer.controller.helper' - - '@language' - - '@template' - - '%core.root_path%' - - phpbb.installer.controller.helper: - class: phpbb\install\controller\helper - arguments: - - '@installer.helper.config' - - '@language' - - '@language.helper.language_file' - - '@installer.navigation.provider' - - '@template' - - '@path_helper' - - '@request' - - '@symfony_request' - - '@router' - - '%core.root_path%' - - phpbb.installer.controller.install: - class: phpbb\install\controller\install - arguments: - - '@phpbb.installer.controller.helper' - - '@installer.helper.iohandler_factory' - - '@installer.navigation.provider' - - '@language' - - '@template' - - '@request' - - '@installer.installer.install' - - '@installer.helper.install_helper' - - phpbb.installer.controller.update: - class: phpbb\install\controller\update - arguments: - - '@phpbb.installer.controller.helper' - - '@installer.installer.update' - - '@installer.helper.install_helper' - - '@installer.helper.iohandler_factory' - - '@language' - - '@installer.navigation.provider' - - '@request' - - '@template' - - phpbb.installer.controller.file_downloader: - class: phpbb\install\controller\archive_download - arguments: - - '@installer.helper.config' - - phpbb.installer.controller.convert: - class: phpbb\convert\controller\convertor - arguments: - - '@cache.driver' - - '@installer.helper.container_factory' - - '@installer.helper.database' - - '@phpbb.installer.controller.helper' - - '@installer.helper.install_helper' - - '@installer.helper.iohandler_factory' - - '@language' - - '@installer.navigation.provider' - - '@request' - - '@template' - - '%core.root_path%' - - '%core.php_ext%' - - phpbb.installer.controller.status: - class: phpbb\install\controller\timeout_check - arguments: - - '@phpbb.installer.controller.helper' - - '%core.root_path%' diff --git a/install/update/new/config/installer/container/services_install_data.yml b/install/update/new/config/installer/container/services_install_data.yml deleted file mode 100644 index 5de0017..0000000 --- a/install/update/new/config/installer/container/services_install_data.yml +++ /dev/null @@ -1,55 +0,0 @@ -services: - installer.install_data.add_bots: - class: phpbb\install\module\install_data\task\add_bots - arguments: - - '@installer.helper.config' - - '@installer.helper.iohandler' - - '@installer.helper.container_factory' - - '@language' - - '%core.root_path%' - - '%core.php_ext%' - tags: - - { name: install_data_install, order: 20 } - - installer.install_data.add_languages: - class: phpbb\install\module\install_data\task\add_languages - arguments: - - '@installer.helper.iohandler' - - '@installer.helper.container_factory' - - '@language.helper.language_file' - tags: - - { name: install_data_install, order: 10 } - - installer.install_data.add_modules: - class: phpbb\install\module\install_data\task\add_modules - arguments: - - '@installer.helper.config' - - '@installer.helper.iohandler' - - '@installer.helper.container_factory' - tags: - - { name: install_data_install, order: 30 } - - installer.install_data.create_search_index: - class: phpbb\install\module\install_data\task\create_search_index - arguments: - - '@config' - - '@installer.helper.container_factory' - - '%core.root_path%' - - '%core.php_ext%' - tags: - - { name: install_data_install, order: 40 } - - installer.module.data_install_collection: - class: phpbb\di\ordered_service_collection - arguments: - - '@service_container' - tags: - - { name: service_collection, tag: install_data_install, class_name_aware: true } - - installer.module.data_install: - class: phpbb\install\module\install_data\module - parent: installer.module_base - arguments: - - '@installer.module.data_install_collection' - tags: - - { name: installer_install_module, order: 50 } diff --git a/install/update/new/config/installer/container/services_install_database.yml b/install/update/new/config/installer/container/services_install_database.yml deleted file mode 100644 index 33f5965..0000000 --- a/install/update/new/config/installer/container/services_install_database.yml +++ /dev/null @@ -1,71 +0,0 @@ -services: - installer.install_database.create_schema_file: - class: phpbb\install\module\install_database\task\create_schema_file - arguments: - - '@installer.helper.config' - - '@installer.helper.database' - - '@filesystem' - - '%core.root_path%' - - '%core.php_ext%' - tags: - - { name: install_database_install, order: 10 } - - installer.install_database.set_up_database: - class: phpbb\install\module\install_database\task\set_up_database - arguments: - - '@installer.helper.config' - - '@installer.helper.database' - - '@filesystem' - - '@installer.helper.iohandler' - - '%core.root_path%' - tags: - - { name: install_database_install, order: 20 } - - installer.install_database.add_tables: - class: phpbb\install\module\install_database\task\add_tables - arguments: - - '@installer.helper.config' - - '@installer.helper.database' - - '@filesystem' - - '%core.root_path%' - tags: - - { name: install_database_install, order: 30 } - - installer.install_database.add_default_data: - class: phpbb\install\module\install_database\task\add_default_data - arguments: - - '@installer.helper.database' - - '@installer.helper.config' - - '@installer.helper.iohandler' - - '@installer.helper.container_factory' - - '@language' - - '%core.root_path%' - tags: - - { name: install_database_install, order: 40 } - - installer.install_database.add_config_settings: - class: phpbb\install\module\install_database\task\add_config_settings - arguments: - - '@filesystem' - - '@installer.helper.config' - - '@installer.helper.iohandler' - - '@installer.helper.container_factory' - - '@language' - - '%core.root_path%' - tags: - - { name: install_database_install, order: 50 } - - installer.module.install_database_collection: - class: phpbb\di\ordered_service_collection - arguments: - - '@service_container' - tags: - - { name: service_collection, tag: install_database_install, class_name_aware: true } - - installer.module.database_install: - class: phpbb\install\module\install_database\module - parent: installer.module_base - arguments: - - '@installer.module.install_database_collection' - tags: - - { name: installer_install_module, order: 40 } diff --git a/install/update/new/config/installer/container/services_install_filesystem.yml b/install/update/new/config/installer/container/services_install_filesystem.yml deleted file mode 100644 index 65b2a6e..0000000 --- a/install/update/new/config/installer/container/services_install_filesystem.yml +++ /dev/null @@ -1,28 +0,0 @@ -services: - installer.install_filesystem.create_config_file: - class: phpbb\install\module\install_filesystem\task\create_config_file - arguments: - - '@filesystem' - - '@installer.helper.config' - - '@installer.helper.database' - - '@installer.helper.iohandler' - - '%core.root_path%' - - '%core.php_ext%' - - '%installer.create_config_file.options%' - tags: - - { name: install_filesystem_install, order: 10 } - - installer.module.install_filesystem_collection: - class: phpbb\di\ordered_service_collection - arguments: - - '@service_container' - tags: - - { name: service_collection, tag: install_filesystem_install, class_name_aware: true } - - installer.module.filesystem_install: - class: phpbb\install\module\install_filesystem\module - parent: installer.module_base - arguments: - - '@installer.module.install_filesystem_collection' - tags: - - { name: installer_install_module, order: 30 } diff --git a/install/update/new/config/installer/container/services_install_finish.yml b/install/update/new/config/installer/container/services_install_finish.yml deleted file mode 100644 index 6a46d8f..0000000 --- a/install/update/new/config/installer/container/services_install_finish.yml +++ /dev/null @@ -1,44 +0,0 @@ -services: - installer.install_finish.populate_migrations: - class: phpbb\install\module\install_finish\task\populate_migrations - arguments: - - '@installer.helper.config' - - '@installer.helper.container_factory' - tags: - - { name: install_finish, order: 10 } - - installer.install_finish.install_extensions: - class: phpbb\install\module\install_finish\task\install_extensions - arguments: - - '@installer.helper.container_factory' - - '@installer.helper.config' - - '@installer.helper.iohandler' - - '%core.root_path%' - tags: - - { name: install_finish, order: 20 } - - installer.install_finish.notify_user: - class: phpbb\install\module\install_finish\task\notify_user - arguments: - - '@installer.helper.container_factory' - - '@installer.helper.config' - - '@installer.helper.iohandler' - - '%core.root_path%' - - '%core.php_ext%' - tags: - - { name: install_finish, order: 30 } - - installer.module.install_finish_collection: - class: phpbb\di\ordered_service_collection - arguments: - - '@service_container' - tags: - - { name: service_collection, tag: install_finish, class_name_aware: true } - - installer.module.finish_install: - class: phpbb\install\module\install_finish\module - parent: installer.module_base - arguments: - - '@installer.module.install_finish_collection' - tags: - - { name: installer_install_module, order: 60 } diff --git a/install/update/new/config/installer/container/services_install_navigation.yml b/install/update/new/config/installer/container/services_install_navigation.yml deleted file mode 100644 index d7151eb..0000000 --- a/install/update/new/config/installer/container/services_install_navigation.yml +++ /dev/null @@ -1,42 +0,0 @@ -services: - installer.navigation.provider: - class: phpbb\install\helper\navigation\navigation_provider - arguments: - - '@installer.navigation.service_collection' - - installer.navigation.service_collection: - class: phpbb\di\service_collection - arguments: - - '@service_container' - tags: - - { name: service_collection, tag: installer.navigation } - - installer.navigation.main_navigation: - class: phpbb\install\helper\navigation\main_navigation - shared: false - tags: - - { name: installer.navigation } - - installer.navigation.install_navigation: - class: phpbb\install\helper\navigation\install_navigation - arguments: - - '@installer.helper.install_helper' - shared: false - tags: - - { name: installer.navigation } - - installer.navigation.update_navigation: - class: phpbb\install\helper\navigation\update_navigation - arguments: - - '@installer.helper.install_helper' - shared: false - tags: - - { name: installer.navigation } - - installer.navigation.convertor_navigation: - class: phpbb\install\helper\navigation\convertor_navigation - arguments: - - '@installer.helper.install_helper' - shared: false - tags: - - { name: installer.navigation } diff --git a/install/update/new/config/installer/container/services_install_obtain_data.yml b/install/update/new/config/installer/container/services_install_obtain_data.yml deleted file mode 100644 index 010aba8..0000000 --- a/install/update/new/config/installer/container/services_install_obtain_data.yml +++ /dev/null @@ -1,59 +0,0 @@ -services: - installer.obtain_data.obtain_admin_data: - class: phpbb\install\module\obtain_data\task\obtain_admin_data - arguments: - - '@installer.helper.config' - - '@installer.helper.iohandler' - tags: - - { name: install_obtain_data, order: 10 } - - installer.obtain_data.obtain_board_data: - class: phpbb\install\module\obtain_data\task\obtain_board_data - arguments: - - '@installer.helper.config' - - '@installer.helper.iohandler' - - '@language.helper.language_file' - tags: - - { name: install_obtain_data, order: 50 } - - installer.obtain_data.obtain_database_data: - class: phpbb\install\module\obtain_data\task\obtain_database_data - arguments: - - '@installer.helper.database' - - '@installer.helper.config' - - '@installer.helper.iohandler' - tags: - - { name: install_obtain_data, order: 20 } - - installer.obtain_data.obtain_email_data: - class: phpbb\install\module\obtain_data\task\obtain_email_data - arguments: - - '@installer.helper.config' - - '@installer.helper.iohandler' - tags: - - { name: install_obtain_data, order: 40 } - - installer.obtain_data.obtain_server_data: - class: phpbb\install\module\obtain_data\task\obtain_server_data - arguments: - - '@installer.helper.config' - - '@installer.helper.iohandler' - tags: - - { name: install_obtain_data, order: 30 } - - installer.module.install_obtain_data_collection: - class: phpbb\di\ordered_service_collection - arguments: - - '@service_container' - tags: - - { name: service_collection, tag: install_obtain_data, class_name_aware: true } - - installer.module.obtain_data_install: - class: phpbb\install\module\obtain_data\install_module - parent: installer.module_base - arguments: - - '@installer.module.install_obtain_data_collection' - - true - - false - tags: - - { name: installer_install_module, order: 20 } diff --git a/install/update/new/config/installer/container/services_install_requirements.yml b/install/update/new/config/installer/container/services_install_requirements.yml deleted file mode 100644 index c03eb1f..0000000 --- a/install/update/new/config/installer/container/services_install_requirements.yml +++ /dev/null @@ -1,37 +0,0 @@ -services: - installer.requirements.check_filesystem: - class: phpbb\install\module\requirements\task\check_filesystem - arguments: - - '@filesystem' - - '@installer.helper.iohandler' - - '%core.root_path%' - - '%core.php_ext%' - tags: - - { name: installer_requirements, order: 10 } - - installer.requirements.check_server_environment: - class: phpbb\install\module\requirements\task\check_server_environment - arguments: - - '@installer.helper.database' - - '@installer.helper.iohandler' - tags: - - { name: installer_requirements, order: 20 } - - { name: update_requirements, order: 20 } - - installer.module.install_requirements_collection: - class: phpbb\di\ordered_service_collection - arguments: - - '@service_container' - tags: - - { name: service_collection, tag: installer_requirements, class_name_aware: true } - -# Please note, that the name of this module is hard coded in the installer service - installer.module.requirements_install: - class: phpbb\install\module\requirements\install_module - parent: installer.module_base - arguments: - - '@installer.module.install_requirements_collection' - - true - - false - tags: - - { name: installer_install_module, order: 10 } diff --git a/install/update/new/config/installer/container/services_installer.yml b/install/update/new/config/installer/container/services_installer.yml deleted file mode 100644 index 57181b2..0000000 --- a/install/update/new/config/installer/container/services_installer.yml +++ /dev/null @@ -1,119 +0,0 @@ -imports: - - { resource: services_file_updater.yml } - - { resource: services_install_console.yml } - - { resource: services_install_controller.yml } - - { resource: services_install_data.yml } - - { resource: services_install_database.yml } - - { resource: services_install_filesystem.yml } - - { resource: services_install_finish.yml } - - { resource: services_install_navigation.yml } - - { resource: services_install_obtain_data.yml } - - { resource: services_install_requirements.yml } - - { resource: services_update_database.yml } - - { resource: services_update_filesystem.yml } - - { resource: services_update_obtain_data.yml } - - { resource: services_update_requirements.yml } - -services: -# -------- Installer helpers ------------------------ - installer.helper.config: - class: phpbb\install\helper\config - arguments: - - '@filesystem' - - '@php_ini' - - '%core.root_path%' - - installer.helper.database: - class: phpbb\install\helper\database - arguments: - - '@filesystem' - - '%core.root_path%' - - installer.helper.iohandler_factory: - class: phpbb\install\helper\iohandler\factory - arguments: - - '@service_container' - - installer.helper.iohandler_abstract: - abstract: true - calls: - - [set_language, ['@language']] - - installer.helper.iohandler_ajax: - class: phpbb\install\helper\iohandler\ajax_iohandler - parent: installer.helper.iohandler_abstract - arguments: - - '@path_helper' - - '@request' - - '@template' - - '@router' - - '%core.root_path%' - - installer.helper.iohandler_cli: - class: phpbb\install\helper\iohandler\cli_iohandler - parent: installer.helper.iohandler_abstract - - installer.helper.iohandler: - class: phpbb\install\helper\iohandler\iohandler_interface - factory: ['@installer.helper.iohandler_factory', get] - - installer.helper.container_factory: - class: phpbb\install\helper\container_factory - arguments: - - '@language' - - '@request' - - '@installer.helper.update_helper' - - '%core.root_path%' - - '%core.php_ext%' - - installer.helper.install_helper: - class: phpbb\install\helper\install_helper - arguments: - - '%core.root_path%' - - '%core.php_ext%' - - installer.helper.update_helper: - class: phpbb\install\helper\update_helper - arguments: - - '%core.root_path%' - -# -------- Installer -------------------------------- - installer.module_base: - abstract: true - calls: - - [setup, ['@installer.helper.config', '@installer.helper.iohandler']] - - installer.installer.abstract: - class: phpbb\install\installer - abstract: true - arguments: - - '@cache.driver' - - '@installer.helper.config' - - '@path_helper' - - '@installer.helper.container_factory' - - installer.install.module_collection: - class: phpbb\di\ordered_service_collection - arguments: - - '@service_container' - tags: - - { name: service_collection, tag: installer_install_module } - - installer.update.module_collection: - class: phpbb\di\ordered_service_collection - arguments: - - '@service_container' - tags: - - { name: service_collection, tag: installer_update_module } - - installer.installer.install: - parent: installer.installer.abstract - calls: - - [set_modules, ['@installer.install.module_collection']] - - [set_purge_cache_before, [false]] - - installer.installer.update: - parent: installer.installer.abstract - calls: - - [set_modules, ['@installer.update.module_collection']] - - [set_purge_cache_before, [true]] diff --git a/install/update/new/config/installer/container/services_update_database.yml b/install/update/new/config/installer/container/services_update_database.yml deleted file mode 100644 index bb97cff..0000000 --- a/install/update/new/config/installer/container/services_update_database.yml +++ /dev/null @@ -1,40 +0,0 @@ -services: - installer.update_database.update_task: - class: phpbb\install\module\update_database\task\update - arguments: - - '@installer.helper.container_factory' - - '@filesystem' - - '@installer.helper.config' - - '@installer.helper.iohandler' - - '@language' - - '%core.root_path%' - tags: - - { name: update_database_task, order: 10 } - - installer.update_database.update_extensions: - class: phpbb\install\module\update_database\task\update_extensions - arguments: - - '@installer.helper.container_factory' - - '@installer.helper.config' - - '@installer.helper.iohandler' - - '@installer.helper.update_helper' - - '%core.root_path%' - tags: - - { name: update_database_task, order: 20 } - - installer.module.update_database_collection: - class: phpbb\di\ordered_service_collection - arguments: - - '@service_container' - tags: - - { name: service_collection, tag: update_database_task, class_name_aware: true } - - installer.module.update_database: - class: phpbb\install\module\update_database\module - parent: installer.module_base - arguments: - - '@installer.module.update_database_collection' - - true - - false - tags: - - { name: installer_update_module, order: 40 } diff --git a/install/update/new/config/installer/container/services_update_filesystem.yml b/install/update/new/config/installer/container/services_update_filesystem.yml deleted file mode 100644 index c0a0467..0000000 --- a/install/update/new/config/installer/container/services_update_filesystem.yml +++ /dev/null @@ -1,72 +0,0 @@ -services: - installer.update_filesystem.check_task: - class: phpbb\install\module\update_filesystem\task\file_check - arguments: - - '@filesystem' - - '@installer.helper.config' - - '@installer.helper.iohandler' - - '@installer.helper.update_helper' - - '%core.root_path%' - tags: - - { name: update_filesystem, order: 10 } - - installer.update_filesystem.diff_files: - class: phpbb\install\module\update_filesystem\task\diff_files - arguments: - - '@installer.helper.container_factory' - - '@installer.helper.config' - - '@installer.helper.iohandler' - - '@installer.helper.update_helper' - - '%core.root_path%' - - '%core.php_ext%' - tags: - - { name: update_filesystem, order: 20 } - - installer.update_filesystem.show_file_status: - class: phpbb\install\module\update_filesystem\task\show_file_status - arguments: - - '@installer.helper.container_factory' - - '@installer.helper.config' - - '@installer.helper.iohandler' - - '@filesystem' - - '@installer.file_updater.factory' - tags: - - { name: update_filesystem, order: 30 } - - installer.update_filesystem.update_files: - class: phpbb\install\module\update_filesystem\task\update_files - arguments: - - '@installer.helper.container_factory' - - '@installer.helper.config' - - '@installer.helper.iohandler' - - '@installer.file_updater.factory' - - '@installer.helper.update_helper' - - '%core.root_path%' - tags: - - { name: update_filesystem, order: 40 } - - installer.update_filesystem.download_updated_files: - class: phpbb\install\module\update_filesystem\task\download_updated_files - arguments: - - '@installer.helper.config' - - '@installer.helper.iohandler' - - '@filesystem' - tags: - - { name: update_filesystem, order: 50 } - - installer.module.update_filesystem_collection: - class: phpbb\di\ordered_service_collection - arguments: - - '@service_container' - tags: - - { name: service_collection, tag: update_filesystem, class_name_aware: true } - - installer.module.filesystem_update: - class: phpbb\install\module\update_filesystem\module - parent: installer.module_base - arguments: - - '@installer.module.update_filesystem_collection' - - true - - false - tags: - - { name: installer_update_module, order: 30 } diff --git a/install/update/new/config/installer/container/services_update_obtain_data.yml b/install/update/new/config/installer/container/services_update_obtain_data.yml deleted file mode 100644 index 999976a..0000000 --- a/install/update/new/config/installer/container/services_update_obtain_data.yml +++ /dev/null @@ -1,53 +0,0 @@ -services: - installer.obtain_data.update_options: - class: phpbb\install\module\obtain_data\task\obtain_update_settings - arguments: - - '@installer.helper.config' - - '@installer.helper.iohandler' - tags: - - { name: update_obtain_data, order: 10 } - - installer.obtain_data.file_updater_method: - class: phpbb\install\module\obtain_data\task\obtain_file_updater_method - arguments: - - '@installer.helper.config' - - '@installer.helper.iohandler' - tags: - - { name: update_obtain_data, order: 20 } - - installer.obtain_data.update_files: - class: phpbb\install\module\obtain_data\task\obtain_update_files - arguments: - - '@installer.helper.config' - - '@installer.helper.iohandler' - - '%core.root_path%' - - '%core.php_ext%' - tags: - - { name: update_obtain_data, order: 30 } - - installer.obtain_data.update_ftp_settings: - class: phpbb\install\module\obtain_data\task\obtain_update_ftp_data - arguments: - - '@installer.helper.config' - - '@installer.helper.iohandler' - - '@installer.helper.update_helper' - - '%core.php_ext%' - tags: - - { name: update_obtain_data, order: 40 } - - installer.module.update_obtain_data_collection: - class: phpbb\di\ordered_service_collection - arguments: - - '@service_container' - tags: - - { name: service_collection, tag: update_obtain_data, class_name_aware: true } - - installer.module.obtain_data_update: - class: phpbb\install\module\obtain_data\update_module - parent: installer.module_base - arguments: - - '@installer.module.update_obtain_data_collection' - - true - - false - tags: - - { name: installer_update_module, order: 20 } diff --git a/install/update/new/config/installer/container/services_update_requirements.yml b/install/update/new/config/installer/container/services_update_requirements.yml deleted file mode 100644 index 6b851de..0000000 --- a/install/update/new/config/installer/container/services_update_requirements.yml +++ /dev/null @@ -1,41 +0,0 @@ -services: - installer.requirements.check_filesystem_update: - class: phpbb\install\module\requirements\task\check_filesystem - arguments: - - '@filesystem' - - '@installer.helper.iohandler' - - '%core.root_path%' - - '%core.php_ext%' - - false - tags: - - { name: update_requirements, order: 10 } - - installer.requirements.update_requirements: - class: phpbb\install\module\requirements\task\check_update - arguments: - - '@installer.helper.container_factory' - - '@filesystem' - - '@installer.helper.config' - - '@installer.helper.iohandler' - - '@installer.helper.update_helper' - - '%core.root_path%' - - '%core.php_ext%' - tags: - - { name: update_requirements, order: 30 } - - installer.module.update_requirements_collection: - class: phpbb\di\ordered_service_collection - arguments: - - '@service_container' - tags: - - { name: service_collection, tag: update_requirements, class_name_aware: true } - - installer.module.requirements_update: - class: phpbb\install\module\requirements\update_module - parent: installer.module_base - arguments: - - '@installer.module.update_requirements_collection' - - true - - false - tags: - - { name: installer_update_module, order: 10 } diff --git a/install/update/new/config/installer/routing/environment.yml b/install/update/new/config/installer/routing/environment.yml deleted file mode 100644 index 7a1f588..0000000 --- a/install/update/new/config/installer/routing/environment.yml +++ /dev/null @@ -1,2 +0,0 @@ -core.default: - resource: installer.yml diff --git a/install/update/new/config/installer/routing/installer.yml b/install/update/new/config/installer/routing/installer.yml deleted file mode 100644 index 66b8893..0000000 --- a/install/update/new/config/installer/routing/installer.yml +++ /dev/null @@ -1,67 +0,0 @@ -phpbb_installer_index: - path: / - defaults: - _controller: phpbb.installer.controller.welcome:handle - mode: 'intro' - -phpbb_installer_license: - path: /license - defaults: - _controller: phpbb.installer.controller.welcome:handle - mode: 'license' - -phpbb_installer_support: - path: /support - defaults: - _controller: phpbb.installer.controller.welcome:handle - mode: 'support' - -phpbb_installer_install: - path: /install - defaults: - _controller: phpbb.installer.controller.install:handle - -phpbb_installer_update: - path: /update - defaults: - _controller: phpbb.installer.controller.update:handle - -phpbb_installer_update_file_download: - path: /download/updated - defaults: - _controller: phpbb.installer.controller.file_downloader:update_archive - -phpbb_installer_update_conflict_download: - path: /download/conflict - defaults: - _controller: phpbb.installer.controller.file_downloader:conflict_archive - -phpbb_convert_intro: - path: /convert/{start_new} - defaults: - _controller: phpbb.installer.controller.convert:intro - start_new: 0 - -phpbb_convert_settings: - path: /convert/settings/{converter} - defaults: - _controller: phpbb.installer.controller.convert:settings - requirements: - converter: "[a-zA-Z0-9_]+" - -phpbb_convert_convert: - path: /convert/in_progress/{converter} - defaults: - _controller: phpbb.installer.controller.convert:convert - requirements: - converter: "[a-zA-Z0-9_]+" - -phpbb_convert_finish: - path: /convert/finished - defaults: - _controller: phpbb.installer.controller.convert:finish - -phpbb_installer_status: - path: /installer/status - defaults: - _controller: phpbb.installer.controller.status:status diff --git a/install/update/new/config/production/config.yml b/install/update/new/config/production/config.yml deleted file mode 100644 index 979dbbc..0000000 --- a/install/update/new/config/production/config.yml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - - { resource: ../default/config.yml } diff --git a/install/update/new/config/production/container/environment.yml b/install/update/new/config/production/container/environment.yml deleted file mode 100644 index 40a3c7a..0000000 --- a/install/update/new/config/production/container/environment.yml +++ /dev/null @@ -1,3 +0,0 @@ -imports: - - { resource: services.yml } - - { resource: parameters.yml } diff --git a/install/update/new/config/production/container/parameters.yml b/install/update/new/config/production/container/parameters.yml deleted file mode 100644 index 0447646..0000000 --- a/install/update/new/config/production/container/parameters.yml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - - { resource: ../../default/container/parameters.yml } diff --git a/install/update/new/config/production/container/services.yml b/install/update/new/config/production/container/services.yml deleted file mode 100644 index b302f0f..0000000 --- a/install/update/new/config/production/container/services.yml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - - { resource: ../../default/container/services.yml } diff --git a/install/update/new/config/production/routing/environment.yml b/install/update/new/config/production/routing/environment.yml deleted file mode 100644 index 301183b..0000000 --- a/install/update/new/config/production/routing/environment.yml +++ /dev/null @@ -1,2 +0,0 @@ -core.default: - resource: ../../default/routing/routing.yml diff --git a/install/update/new/cron.php b/install/update/new/cron.php deleted file mode 100644 index c99b772..0000000 --- a/install/update/new/cron.php +++ /dev/null @@ -1,37 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -use Symfony\Component\HttpFoundation\RedirectResponse; - -/** -*/ -define('IN_PHPBB', true); -$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); -include($phpbb_root_path . 'common.' . $phpEx); - -// Do not update users last page entry -$user->session_begin(false); -$auth->acl($user->data); - -$cron_type = $request->variable('cron_type', ''); - -$get_params_array = $request->get_super_global(\phpbb\request\request_interface::GET); - -/** @var \phpbb\controller\helper $controller_helper */ -$controller_helper = $phpbb_container->get('controller.helper'); -$response = new RedirectResponse( - $controller_helper->route('phpbb_cron_run', $get_params_array, false), - 301 -); -$response->send(); diff --git a/install/update/new/download/file.php b/install/update/new/download/file.php deleted file mode 100644 index 6d0796d..0000000 --- a/install/update/new/download/file.php +++ /dev/null @@ -1,321 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -define('IN_PHPBB', true); -$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); - -// Thank you sun. -if (isset($_SERVER['CONTENT_TYPE'])) -{ - if ($_SERVER['CONTENT_TYPE'] === 'application/x-java-archive') - { - exit; - } -} -else if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'Java') !== false) -{ - exit; -} - -if (isset($_GET['avatar'])) -{ - require($phpbb_root_path . 'includes/startup.' . $phpEx); - - require($phpbb_root_path . 'phpbb/class_loader.' . $phpEx); - $phpbb_class_loader = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}phpbb/", $phpEx); - $phpbb_class_loader->register(); - - $phpbb_config_php_file = new \phpbb\config_php_file($phpbb_root_path, $phpEx); - extract($phpbb_config_php_file->get_all()); - - if (!defined('PHPBB_ENVIRONMENT')) - { - @define('PHPBB_ENVIRONMENT', 'production'); - } - - if (!defined('PHPBB_INSTALLED') || empty($dbms) || empty($acm_type)) - { - exit; - } - - require($phpbb_root_path . 'includes/constants.' . $phpEx); - require($phpbb_root_path . 'includes/functions.' . $phpEx); - require($phpbb_root_path . 'includes/functions_download' . '.' . $phpEx); - require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); - - // Setup class loader first - $phpbb_class_loader_ext = new \phpbb\class_loader('\\', "{$phpbb_root_path}ext/", $phpEx); - $phpbb_class_loader_ext->register(); - - // Set up container - $phpbb_container_builder = new \phpbb\di\container_builder($phpbb_root_path, $phpEx); - $phpbb_container = $phpbb_container_builder->with_config($phpbb_config_php_file)->get_container(); - - $phpbb_class_loader->set_cache($phpbb_container->get('cache.driver')); - $phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver')); - - // set up caching - /* @var $cache \phpbb\cache\service */ - $cache = $phpbb_container->get('cache'); - - /* @var $phpbb_dispatcher \phpbb\event\dispatcher */ - $phpbb_dispatcher = $phpbb_container->get('dispatcher'); - - /* @var $request \phpbb\request\request_interface */ - $request = $phpbb_container->get('request'); - - /* @var $db \phpbb\db\driver\driver_interface */ - $db = $phpbb_container->get('dbal.conn'); - - /* @var $phpbb_log \phpbb\log\log_interface */ - $phpbb_log = $phpbb_container->get('log'); - - unset($dbpasswd); - - /* @var $config \phpbb\config\config */ - $config = $phpbb_container->get('config'); - - // load extensions - /* @var $phpbb_extension_manager \phpbb\extension\manager */ - $phpbb_extension_manager = $phpbb_container->get('ext.manager'); - - // worst-case default - $browser = strtolower($request->header('User-Agent', 'msie 6.0')); - - /* @var $phpbb_avatar_manager \phpbb\avatar\manager */ - $phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); - - $filename = $request->variable('avatar', ''); - $avatar_group = false; - $exit = false; - - if (isset($filename[0]) && $filename[0] === 'g') - { - $avatar_group = true; - $filename = substr($filename, 1); - } - - // '==' is not a bug - . as the first char is as bad as no dot at all - if (strpos($filename, '.') == false) - { - send_status_line(403, 'Forbidden'); - $exit = true; - } - - if (!$exit) - { - $ext = substr(strrchr($filename, '.'), 1); - $stamp = (int) substr(stristr($filename, '_'), 1); - $filename = (int) $filename; - $exit = set_modified_headers($stamp, $browser); - } - if (!$exit && !in_array($ext, array('png', 'gif', 'jpg', 'jpeg'))) - { - // no way such an avatar could exist. They are not following the rules, stop the show. - send_status_line(403, 'Forbidden'); - $exit = true; - } - - - if (!$exit) - { - if (!$filename) - { - // no way such an avatar could exist. They are not following the rules, stop the show. - send_status_line(403, 'Forbidden'); - } - else - { - send_avatar_to_browser(($avatar_group ? 'g' : '') . $filename . '.' . $ext, $browser); - } - } - file_gc(); -} - -// implicit else: we are not in avatar mode -include($phpbb_root_path . 'common.' . $phpEx); -require($phpbb_root_path . 'includes/functions_download' . '.' . $phpEx); - -$attach_id = $request->variable('id', 0); -$mode = $request->variable('mode', ''); -$thumbnail = $request->variable('t', false); - -// Start session management, do not update session page. -$user->session_begin(false); -$auth->acl($user->data); -$user->setup('viewtopic'); - -$phpbb_content_visibility = $phpbb_container->get('content.visibility'); - -if (!$config['allow_attachments'] && !$config['allow_pm_attach']) -{ - send_status_line(404, 'Not Found'); - trigger_error('ATTACHMENT_FUNCTIONALITY_DISABLED'); -} - -if (!$attach_id) -{ - send_status_line(404, 'Not Found'); - trigger_error('NO_ATTACHMENT_SELECTED'); -} - -$sql = 'SELECT attach_id, post_msg_id, topic_id, in_message, poster_id, is_orphan, physical_filename, real_filename, extension, mimetype, filesize, filetime - FROM ' . ATTACHMENTS_TABLE . " - WHERE attach_id = $attach_id"; -$result = $db->sql_query($sql); -$attachment = $db->sql_fetchrow($result); -$db->sql_freeresult($result); - -if (!$attachment) -{ - send_status_line(404, 'Not Found'); - trigger_error('ERROR_NO_ATTACHMENT'); -} -else if (!download_allowed()) -{ - send_status_line(403, 'Forbidden'); - trigger_error($user->lang['LINKAGE_FORBIDDEN']); -} -else -{ - $attachment['physical_filename'] = utf8_basename($attachment['physical_filename']); - - if (!$attachment['in_message'] && !$config['allow_attachments'] || $attachment['in_message'] && !$config['allow_pm_attach']) - { - send_status_line(404, 'Not Found'); - trigger_error('ATTACHMENT_FUNCTIONALITY_DISABLED'); - } - - if ($attachment['is_orphan']) - { - // We allow admins having attachment permissions to see orphan attachments... - $own_attachment = ($auth->acl_get('a_attach') || $attachment['poster_id'] == $user->data['user_id']) ? true : false; - - if (!$own_attachment || ($attachment['in_message'] && !$auth->acl_get('u_pm_download')) || (!$attachment['in_message'] && !$auth->acl_get('u_download'))) - { - send_status_line(404, 'Not Found'); - trigger_error('ERROR_NO_ATTACHMENT'); - } - - // Obtain all extensions... - $extensions = $cache->obtain_attach_extensions(true); - } - else - { - if (!$attachment['in_message']) - { - phpbb_download_handle_forum_auth($db, $auth, $attachment['topic_id']); - - $sql = 'SELECT forum_id, post_visibility - FROM ' . POSTS_TABLE . ' - WHERE post_id = ' . (int) $attachment['post_msg_id']; - $result = $db->sql_query($sql); - $post_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$post_row || !$phpbb_content_visibility->is_visible('post', $post_row['forum_id'], $post_row)) - { - // Attachment of a soft deleted post and the user is not allowed to see the post - send_status_line(404, 'Not Found'); - trigger_error('ERROR_NO_ATTACHMENT'); - } - } - else - { - // Attachment is in a private message. - $post_row = array('forum_id' => false); - phpbb_download_handle_pm_auth($db, $auth, $user->data['user_id'], $attachment['post_msg_id']); - } - - $extensions = array(); - if (!extension_allowed($post_row['forum_id'], $attachment['extension'], $extensions)) - { - send_status_line(403, 'Forbidden'); - trigger_error(sprintf($user->lang['EXTENSION_DISABLED_AFTER_POSTING'], $attachment['extension'])); - } - } - - $download_mode = (int) $extensions[$attachment['extension']]['download_mode']; - $display_cat = $extensions[$attachment['extension']]['display_cat']; - - if (($display_cat == ATTACHMENT_CATEGORY_IMAGE || $display_cat == ATTACHMENT_CATEGORY_THUMB) && !$user->optionget('viewimg')) - { - $display_cat = ATTACHMENT_CATEGORY_NONE; - } - - /** - * Event to modify data before sending file to browser - * - * @event core.download_file_send_to_browser_before - * @var int attach_id The attachment ID - * @var array attachment Array with attachment data - * @var int display_cat Attachment category - * @var int download_mode File extension specific download mode - * @var array extensions Array with file extensions data - * @var string mode Download mode - * @var bool thumbnail Flag indicating if the file is a thumbnail - * @since 3.1.6-RC1 - * @changed 3.1.7-RC1 Fixing wrong name of a variable (replacing "extension" by "extensions") - */ - $vars = array( - 'attach_id', - 'attachment', - 'display_cat', - 'download_mode', - 'extensions', - 'mode', - 'thumbnail', - ); - extract($phpbb_dispatcher->trigger_event('core.download_file_send_to_browser_before', compact($vars))); - - if ($thumbnail) - { - $attachment['physical_filename'] = 'thumb_' . $attachment['physical_filename']; - } - else if ($display_cat == ATTACHMENT_CATEGORY_NONE && !$attachment['is_orphan'] && !phpbb_http_byte_range($attachment['filesize'])) - { - // Update download count - phpbb_increment_downloads($db, $attachment['attach_id']); - } - - if ($display_cat == ATTACHMENT_CATEGORY_IMAGE && $mode === 'view' && (strpos($attachment['mimetype'], 'image') === 0) && (strpos(strtolower($user->browser), 'msie') !== false) && !phpbb_is_greater_ie_version($user->browser, 7)) - { - wrap_img_in_html(append_sid($phpbb_root_path . 'download/file.' . $phpEx, 'id=' . $attachment['attach_id']), $attachment['real_filename']); - file_gc(); - } - else - { - // Determine the 'presenting'-method - if ($download_mode == PHYSICAL_LINK) - { - // This presenting method should no longer be used - if (!@is_dir($phpbb_root_path . $config['upload_path'])) - { - send_status_line(500, 'Internal Server Error'); - trigger_error($user->lang['PHYSICAL_DOWNLOAD_NOT_POSSIBLE']); - } - - redirect($phpbb_root_path . $config['upload_path'] . '/' . $attachment['physical_filename']); - file_gc(); - } - else - { - send_file_to_browser($attachment, $config['upload_path'], $display_cat); - file_gc(); - } - } -} diff --git a/install/update/new/ext/phpbb/viglink/acp/viglink_helper.php b/install/update/new/ext/phpbb/viglink/acp/viglink_helper.php deleted file mode 100644 index 36bf313..0000000 --- a/install/update/new/ext/phpbb/viglink/acp/viglink_helper.php +++ /dev/null @@ -1,147 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - */ - -namespace phpbb\viglink\acp; - -/** - * Class to handle allowing or disallowing VigLink services - */ -class viglink_helper -{ - /** @var \phpbb\cache\driver\driver_interface $cache */ - protected $cache; - - /** @var \phpbb\config\config $config */ - protected $config; - - /** @var \phpbb\file_downloader $file_downloader */ - protected $file_downloader; - - /** @var \phpbb\language\language $language */ - protected $language; - - /** @var \phpbb\log\log $log */ - protected $log; - - /** @var \phpbb\user $user */ - protected $user; - - /** @var bool Use SSL or not */ - protected $use_ssl = false; - - /** - * Constructor - * - * @param \phpbb\cache\driver\driver_interface $cache - * @param \phpbb\config\config $config - * @param \phpbb\file_downloader $file_downloader - * @param \phpbb\language\language $language - * @param \phpbb\log\log $log - * @param \phpbb\user $user - */ - public function __construct(\phpbb\cache\driver\driver_interface $cache, \phpbb\config\config $config, \phpbb\file_downloader $file_downloader, \phpbb\language\language $language, \phpbb\log\log $log, \phpbb\user $user) - { - $this->cache = $cache; - $this->config = $config; - $this->file_downloader = $file_downloader; - $this->language = $language; - $this->log = $log; - $this->user = $user; - } - - /** - * Obtains the latest VigLink services information from phpBB - * - * @param bool $force_update Ignores cached data. Defaults to false. - * @param bool $force_cache Force the use of the cache. Override $force_update. - * - * @throws \RuntimeException - * - * @return void - */ - public function set_viglink_services($force_update = false, $force_cache = false) - { - $cache_key = '_versioncheck_viglink_' . $this->use_ssl; - - $info = $this->cache->get($cache_key); - - if ($info === false && $force_cache) - { - throw new \RuntimeException($this->language->lang('VERSIONCHECK_FAIL')); - } - - if ($info === false || $force_update) - { - try - { - $info = $this->file_downloader->get('www.phpbb.com', '/viglink', 'enabled', 443); - } - catch (\phpbb\exception\runtime_exception $exception) - { - $prepare_parameters = array_merge(array($exception->getMessage()), $exception->get_parameters()); - throw new \RuntimeException(call_user_func_array(array($this->language, 'lang'), $prepare_parameters)); - } - - if ($info === '0') - { - $this->set_viglink_configs(array( - 'allow_viglink_phpbb' => false, - )); - } - else - { - $info = '1'; - $this->set_viglink_configs(array( - 'allow_viglink_phpbb' => true, - )); - } - - $this->cache->put($cache_key, $info, 86400); // 24 hours - } - } - - /** - * Sets VigLink service configs as determined by phpBB - * - * @param array $data Array of VigLink file data. - * - * @return void - */ - protected function set_viglink_configs($data) - { - $viglink_configs = array( - 'allow_viglink_phpbb', - 'phpbb_viglink_api_key', - ); - - foreach ($viglink_configs as $cfg_name) - { - if (array_key_exists($cfg_name, $data) && ($data[$cfg_name] != $this->config[$cfg_name] || !isset($this->config[$cfg_name]))) - { - $this->config->set($cfg_name, $data[$cfg_name]); - } - } - - $this->config->set('viglink_last_gc', time(), false); - } - - /** - * Log a VigLink error message to the error log - * - * @param string $message The error message - */ - public function log_viglink_error($message) - { - $user_id = empty($this->user->data) ? ANONYMOUS : $this->user->data['user_id']; - $user_ip = empty($this->user->ip) ? '' : $this->user->ip; - - $this->log->add('critical', $user_id, $user_ip, 'LOG_VIGLINK_CHECK_FAIL', false, array($message)); - } -} diff --git a/install/update/new/ext/phpbb/viglink/composer.json b/install/update/new/ext/phpbb/viglink/composer.json deleted file mode 100644 index e1e73f3..0000000 --- a/install/update/new/ext/phpbb/viglink/composer.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "phpbb/viglink", - "type": "phpbb-extension", - "description": "The VigLink extension for phpBB makes it possible to earn revenue, without any change to the user experience, when users post and follow links to commercial sites.", - "homepage": "https://www.phpbb.com", - "version": "1.0.5", - "keywords": ["phpbb", "extension", "viglink"], - "license": "GPL-2.0-only", - "authors": [ - { - "name": "phpBB Limited", - "email": "operations@phpbb.com", - "homepage": "https://www.phpbb.com/go/authors" - } - ], - "require": { - "php": ">=5.4", - "phpbb/phpbb": ">=3.2.0", - "composer/installers": "~1.0" - }, - "extra": { - "display-name": "VigLink", - "soft-require": { - "phpbb/phpbb": ">=3.2.0-b1,<4.0.0@dev" - } - } -} diff --git a/install/update/new/ext/phpbb/viglink/composer.lock b/install/update/new/ext/phpbb/viglink/composer.lock deleted file mode 100644 index 1f8e919..0000000 --- a/install/update/new/ext/phpbb/viglink/composer.lock +++ /dev/null @@ -1,2443 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", - "This file is @generated automatically" - ], - "content-hash": "b80efb4b6261de83a1e263bb46ddfa8b", - "packages": [ - { - "name": "bantu/ini-get-wrapper", - "version": "v1.0.1", - "source": { - "type": "git", - "url": "https://github.com/bantuXorg/php-ini-get-wrapper.git", - "reference": "4770c7feab370c62e23db4f31c112b7c6d90aee2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/bantuXorg/php-ini-get-wrapper/zipball/4770c7feab370c62e23db4f31c112b7c6d90aee2", - "reference": "4770c7feab370c62e23db4f31c112b7c6d90aee2", - "shasum": "" - }, - "require-dev": { - "phpunit/phpunit": "3.7.*" - }, - "type": "library", - "autoload": { - "psr-4": { - "bantu\\IniGetWrapper\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Convenience wrapper around ini_get()", - "time": "2014-09-15T13:12:35+00:00" - }, - { - "name": "composer/installers", - "version": "v1.7.0", - "source": { - "type": "git", - "url": "https://github.com/composer/installers.git", - "reference": "141b272484481432cda342727a427dc1e206bfa0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/composer/installers/zipball/141b272484481432cda342727a427dc1e206bfa0", - "reference": "141b272484481432cda342727a427dc1e206bfa0", - "shasum": "" - }, - "require": { - "composer-plugin-api": "^1.0" - }, - "replace": { - "roundcube/plugin-installer": "*", - "shama/baton": "*" - }, - "require-dev": { - "composer/composer": "1.0.*@dev", - "phpunit/phpunit": "^4.8.36" - }, - "type": "composer-plugin", - "extra": { - "class": "Composer\\Installers\\Plugin", - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "psr-4": { - "Composer\\Installers\\": "src/Composer/Installers" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Kyle Robinson Young", - "email": "kyle@dontkry.com", - "homepage": "https://github.com/shama" - } - ], - "description": "A multi-framework Composer library installer", - "homepage": "https://composer.github.io/installers/", - "keywords": [ - "Craft", - "Dolibarr", - "Eliasis", - "Hurad", - "ImageCMS", - "Kanboard", - "Lan Management System", - "MODX Evo", - "Mautic", - "Maya", - "OXID", - "Plentymarkets", - "Porto", - "RadPHP", - "SMF", - "Thelia", - "Whmcs", - "WolfCMS", - "agl", - "aimeos", - "annotatecms", - "attogram", - "bitrix", - "cakephp", - "chef", - "cockpit", - "codeigniter", - "concrete5", - "croogo", - "dokuwiki", - "drupal", - "eZ Platform", - "elgg", - "expressionengine", - "fuelphp", - "grav", - "installer", - "itop", - "joomla", - "known", - "kohana", - "laravel", - "lavalite", - "lithium", - "magento", - "majima", - "mako", - "mediawiki", - "modulework", - "modx", - "moodle", - "osclass", - "phpbb", - "piwik", - "ppi", - "puppet", - "pxcms", - "reindex", - "roundcube", - "shopware", - "silverstripe", - "sydes", - "symfony", - "typo3", - "wordpress", - "yawik", - "zend", - "zikula" - ], - "time": "2019-08-12T15:00:31+00:00" - }, - { - "name": "google/recaptcha", - "version": "1.2.3", - "source": { - "type": "git", - "url": "https://github.com/google/recaptcha.git", - "reference": "98c4a6573b27e8b0990ea8789c74ea378795134c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/google/recaptcha/zipball/98c4a6573b27e8b0990ea8789c74ea378795134c", - "reference": "98c4a6573b27e8b0990ea8789c74ea378795134c", - "shasum": "" - }, - "require": { - "php": ">=5.5" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^2.2.20|^2.15", - "php-coveralls/php-coveralls": "^2.1", - "phpunit/phpunit": "^4.8.36|^5.7.27|^6.59|^7.5.11" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, - "autoload": { - "psr-4": { - "ReCaptcha\\": "src/ReCaptcha" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "description": "Client library for reCAPTCHA, a free service that protects websites from spam and abuse.", - "homepage": "https://www.google.com/recaptcha/", - "keywords": [ - "Abuse", - "captcha", - "recaptcha", - "spam" - ], - "time": "2019-08-16T15:48:25+00:00" - }, - { - "name": "guzzlehttp/guzzle", - "version": "6.5.2", - "source": { - "type": "git", - "url": "https://github.com/guzzle/guzzle.git", - "reference": "43ece0e75098b7ecd8d13918293029e555a50f82" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/43ece0e75098b7ecd8d13918293029e555a50f82", - "reference": "43ece0e75098b7ecd8d13918293029e555a50f82", - "shasum": "" - }, - "require": { - "ext-json": "*", - "guzzlehttp/promises": "^1.0", - "guzzlehttp/psr7": "^1.6.1", - "php": ">=5.5" - }, - "require-dev": { - "ext-curl": "*", - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0", - "psr/log": "^1.1" - }, - "suggest": { - "ext-intl": "Required for Internationalized Domain Name (IDN) support", - "psr/log": "Required for using the Log middleware" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "6.5-dev" - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\": "src/" - }, - "files": [ - "src/functions_include.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "description": "Guzzle is a PHP HTTP client library", - "homepage": "http://guzzlephp.org/", - "keywords": [ - "client", - "curl", - "framework", - "http", - "http client", - "rest", - "web service" - ], - "time": "2019-12-23T11:57:10+00:00" - }, - { - "name": "guzzlehttp/promises", - "version": "v1.3.1", - "source": { - "type": "git", - "url": "https://github.com/guzzle/promises.git", - "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/a59da6cf61d80060647ff4d3eb2c03a2bc694646", - "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646", - "shasum": "" - }, - "require": { - "php": ">=5.5.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4-dev" - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\Promise\\": "src/" - }, - "files": [ - "src/functions_include.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "description": "Guzzle promises library", - "keywords": [ - "promise" - ], - "time": "2016-12-20T10:07:11+00:00" - }, - { - "name": "guzzlehttp/psr7", - "version": "1.6.1", - "source": { - "type": "git", - "url": "https://github.com/guzzle/psr7.git", - "reference": "239400de7a173fe9901b9ac7c06497751f00727a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/239400de7a173fe9901b9ac7c06497751f00727a", - "reference": "239400de7a173fe9901b9ac7c06497751f00727a", - "shasum": "" - }, - "require": { - "php": ">=5.4.0", - "psr/http-message": "~1.0", - "ralouphie/getallheaders": "^2.0.5 || ^3.0.0" - }, - "provide": { - "psr/http-message-implementation": "1.0" - }, - "require-dev": { - "ext-zlib": "*", - "phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.8" - }, - "suggest": { - "zendframework/zend-httphandlerrunner": "Emit PSR-7 responses" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.6-dev" - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\Psr7\\": "src/" - }, - "files": [ - "src/functions_include.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - }, - { - "name": "Tobias Schultze", - "homepage": "https://github.com/Tobion" - } - ], - "description": "PSR-7 message implementation that also provides common utility methods", - "keywords": [ - "http", - "message", - "psr-7", - "request", - "response", - "stream", - "uri", - "url" - ], - "time": "2019-07-01T23:21:34+00:00" - }, - { - "name": "lusitanian/oauth", - "version": "v0.8.11", - "source": { - "type": "git", - "url": "https://github.com/Lusitanian/PHPoAuthLib.git", - "reference": "fc11a53db4b66da555a6a11fce294f574a8374f9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Lusitanian/PHPoAuthLib/zipball/fc11a53db4b66da555a6a11fce294f574a8374f9", - "reference": "fc11a53db4b66da555a6a11fce294f574a8374f9", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "require-dev": { - "phpunit/phpunit": "3.7.*", - "predis/predis": "0.8.*@dev", - "squizlabs/php_codesniffer": "2.*", - "symfony/http-foundation": "~2.1" - }, - "suggest": { - "ext-openssl": "Allows for usage of secure connections with the stream-based HTTP client.", - "predis/predis": "Allows using the Redis storage backend.", - "symfony/http-foundation": "Allows using the Symfony Session storage backend." - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "0.1-dev" - } - }, - "autoload": { - "psr-0": { - "OAuth": "src", - "OAuth\\Unit": "tests" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "David Desberg", - "email": "david@daviddesberg.com" - }, - { - "name": "Elliot Chance", - "email": "elliotchance@gmail.com" - }, - { - "name": "Pieter Hordijk", - "email": "info@pieterhordijk.com" - } - ], - "description": "PHP 5.3+ oAuth 1/2 Library", - "keywords": [ - "Authentication", - "authorization", - "oauth", - "security" - ], - "time": "2018-02-14T22:37:14+00:00" - }, - { - "name": "marc1706/fast-image-size", - "version": "v1.1.6", - "source": { - "type": "git", - "url": "https://github.com/marc1706/fast-image-size.git", - "reference": "3a3a2b036be20f43fa06ce00dfa754df503e6684" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/marc1706/fast-image-size/zipball/3a3a2b036be20f43fa06ce00dfa754df503e6684", - "reference": "3a3a2b036be20f43fa06ce00dfa754df503e6684", - "shasum": "" - }, - "require": { - "ext-mbstring": "*", - "php": ">=5.3.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.8" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1.x-dev" - } - }, - "autoload": { - "psr-4": { - "FastImageSize\\": "lib", - "FastImageSize\\tests\\": "tests" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Marc Alexander", - "email": "admin@m-a-styles.de", - "homepage": "https://www.m-a-styles.de", - "role": "Developer" - } - ], - "description": "fast-image-size is a PHP library that does almost everything PHP's getimagesize() does but without the large overhead of downloading the complete file.", - "homepage": "https://www.m-a-styles.de", - "keywords": [ - "fast", - "getimagesize", - "image", - "imagesize", - "php", - "size" - ], - "time": "2019-12-07T08:02:07+00:00" - }, - { - "name": "ocramius/package-versions", - "version": "1.4.2", - "source": { - "type": "git", - "url": "https://github.com/Ocramius/PackageVersions.git", - "reference": "44af6f3a2e2e04f2af46bcb302ad9600cba41c7d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Ocramius/PackageVersions/zipball/44af6f3a2e2e04f2af46bcb302ad9600cba41c7d", - "reference": "44af6f3a2e2e04f2af46bcb302ad9600cba41c7d", - "shasum": "" - }, - "require": { - "composer-plugin-api": "^1.0.0", - "php": "^7.1.0" - }, - "require-dev": { - "composer/composer": "^1.6.3", - "doctrine/coding-standard": "^5.0.1", - "ext-zip": "*", - "infection/infection": "^0.7.1", - "phpunit/phpunit": "^7.5.17" - }, - "type": "composer-plugin", - "extra": { - "class": "PackageVersions\\Installer", - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "PackageVersions\\": "src/PackageVersions" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com" - } - ], - "description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)", - "time": "2019-11-15T16:17:10+00:00" - }, - { - "name": "ocramius/proxy-manager", - "version": "2.2.3", - "source": { - "type": "git", - "url": "https://github.com/Ocramius/ProxyManager.git", - "reference": "4d154742e31c35137d5374c998e8f86b54db2e2f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Ocramius/ProxyManager/zipball/4d154742e31c35137d5374c998e8f86b54db2e2f", - "reference": "4d154742e31c35137d5374c998e8f86b54db2e2f", - "shasum": "" - }, - "require": { - "ocramius/package-versions": "^1.1.3", - "php": "^7.2.0", - "zendframework/zend-code": "^3.3.0" - }, - "require-dev": { - "couscous/couscous": "^1.6.1", - "ext-phar": "*", - "humbug/humbug": "1.0.0-RC.0@RC", - "nikic/php-parser": "^3.1.1", - "padraic/phpunit-accelerator": "dev-master@DEV", - "phpbench/phpbench": "^0.12.2", - "phpstan/phpstan": "dev-master#856eb10a81c1d27c701a83f167dc870fd8f4236a as 0.9.999", - "phpstan/phpstan-phpunit": "dev-master#5629c0a1f4a9c417cb1077cf6693ad9753895761", - "phpunit/phpunit": "^6.4.3", - "squizlabs/php_codesniffer": "^2.9.1" - }, - "suggest": { - "ocramius/generated-hydrator": "To have very fast object to array to object conversion for ghost objects", - "zendframework/zend-json": "To have the JsonRpc adapter (Remote Object feature)", - "zendframework/zend-soap": "To have the Soap adapter (Remote Object feature)", - "zendframework/zend-xmlrpc": "To have the XmlRpc adapter (Remote Object feature)" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0.x-dev" - } - }, - "autoload": { - "psr-0": { - "ProxyManager\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com", - "homepage": "http://ocramius.github.io/" - } - ], - "description": "A library providing utilities to generate, instantiate and generally operate with Object Proxies", - "homepage": "https://github.com/Ocramius/ProxyManager", - "keywords": [ - "aop", - "lazy loading", - "proxy", - "proxy pattern", - "service proxies" - ], - "time": "2019-08-10T08:37:15+00:00" - }, - { - "name": "paragonie/random_compat", - "version": "v9.99.99", - "source": { - "type": "git", - "url": "https://github.com/paragonie/random_compat.git", - "reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/paragonie/random_compat/zipball/84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95", - "reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95", - "shasum": "" - }, - "require": { - "php": "^7" - }, - "require-dev": { - "phpunit/phpunit": "4.*|5.*", - "vimeo/psalm": "^1" - }, - "suggest": { - "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." - }, - "type": "library", - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Paragon Initiative Enterprises", - "email": "security@paragonie.com", - "homepage": "https://paragonie.com" - } - ], - "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", - "keywords": [ - "csprng", - "polyfill", - "pseudorandom", - "random" - ], - "time": "2018-07-02T15:55:56+00:00" - }, - { - "name": "patchwork/utf8", - "version": "v1.3.2", - "source": { - "type": "git", - "url": "https://github.com/tchwork/utf8.git", - "reference": "d296e0026e7ce10b2a9fe594feca9628ef00e9e8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/tchwork/utf8/zipball/d296e0026e7ce10b2a9fe594feca9628ef00e9e8", - "reference": "d296e0026e7ce10b2a9fe594feca9628ef00e9e8", - "shasum": "" - }, - "require": { - "lib-pcre": ">=7.3", - "php": ">=5.3.0" - }, - "require-dev": { - "symfony/phpunit-bridge": "^3.4|^4.4" - }, - "suggest": { - "ext-iconv": "Use iconv for best performance", - "ext-intl": "Use Intl for best performance", - "ext-mbstring": "Use Mbstring for best performance", - "ext-wfio": "Use WFIO for UTF-8 filesystem access on Windows" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3-dev" - } - }, - "autoload": { - "psr-4": { - "Patchwork\\": "src/Patchwork/" - }, - "classmap": [ - "src/Normalizer.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "(Apache-2.0 or GPL-2.0)" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - } - ], - "description": "Portable and performant UTF-8, Unicode and Grapheme Clusters for PHP", - "homepage": "https://github.com/tchwork/utf8", - "keywords": [ - "grapheme", - "i18n", - "unicode", - "utf-8", - "utf8" - ], - "time": "2019-12-03T14:44:12+00:00" - }, - { - "name": "phpbb/phpbb", - "version": "3.3.0-RC1", - "source": { - "type": "git", - "url": "https://github.com/phpbb/phpbb-app.git", - "reference": "664db37d53bb5490e701d4e016f7df2434e2418e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpbb/phpbb-app/zipball/664db37d53bb5490e701d4e016f7df2434e2418e", - "reference": "664db37d53bb5490e701d4e016f7df2434e2418e", - "shasum": "" - }, - "require": { - "bantu/ini-get-wrapper": "~1.0", - "ext-json": "*", - "google/recaptcha": "~1.1", - "guzzlehttp/guzzle": "~6.3", - "lusitanian/oauth": "^0.8.1", - "marc1706/fast-image-size": "^1.1", - "patchwork/utf8": "^1.1", - "php": ">=7.1", - "s9e/text-formatter": "^2.0", - "symfony/config": "~3.4", - "symfony/console": "~3.4", - "symfony/debug": "~3.4", - "symfony/dependency-injection": "~3.4", - "symfony/event-dispatcher": "~3.4", - "symfony/filesystem": "~3.4", - "symfony/finder": "~3.4", - "symfony/http-foundation": "~3.4", - "symfony/http-kernel": "~3.4", - "symfony/proxy-manager-bridge": "~3.4", - "symfony/routing": "~3.4", - "symfony/twig-bridge": "~3.4", - "symfony/yaml": "~3.4", - "twig/twig": "^1.0 || ^2.0" - }, - "replace": { - "phpbb/phpbb-core": "self.version" - }, - "require-dev": { - "fabpot/goutte": "~3.2", - "facebook/webdriver": "~1.6", - "laravel/homestead": "~7.0", - "phing/phing": "~2.4", - "phpunit/dbunit": "~4.0", - "phpunit/phpunit": "^7.0", - "squizlabs/php_codesniffer": "~3.4", - "symfony/browser-kit": "~3.4", - "symfony/css-selector": "~3.4", - "symfony/dom-crawler": "~3.4" - }, - "type": "project", - "extra": { - "branch-alias": { - "dev-master": "3.3.x-dev" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "GPL-2.0-only" - ], - "authors": [ - { - "name": "phpBB Limited", - "email": "operations@phpbb.com", - "homepage": "https://www.phpbb.com/go/authors" - } - ], - "description": "phpBB Forum Software application", - "homepage": "https://www.phpbb.com", - "keywords": [ - "forum", - "phpbb" - ], - "time": "2019-12-21T09:51:05+00:00" - }, - { - "name": "psr/container", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/container.git", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Container\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common Container Interface (PHP FIG PSR-11)", - "homepage": "https://github.com/php-fig/container", - "keywords": [ - "PSR-11", - "container", - "container-interface", - "container-interop", - "psr" - ], - "time": "2017-02-14T16:28:37+00:00" - }, - { - "name": "psr/http-message", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/php-fig/http-message.git", - "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", - "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Http\\Message\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for HTTP messages", - "homepage": "https://github.com/php-fig/http-message", - "keywords": [ - "http", - "http-message", - "psr", - "psr-7", - "request", - "response" - ], - "time": "2016-08-06T14:39:51+00:00" - }, - { - "name": "psr/log", - "version": "1.1.2", - "source": { - "type": "git", - "url": "https://github.com/php-fig/log.git", - "reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/446d54b4cb6bf489fc9d75f55843658e6f25d801", - "reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Log\\": "Psr/Log/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for logging libraries", - "homepage": "https://github.com/php-fig/log", - "keywords": [ - "log", - "psr", - "psr-3" - ], - "time": "2019-11-01T11:05:21+00:00" - }, - { - "name": "ralouphie/getallheaders", - "version": "3.0.3", - "source": { - "type": "git", - "url": "https://github.com/ralouphie/getallheaders.git", - "reference": "120b605dfeb996808c31b6477290a714d356e822" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", - "reference": "120b605dfeb996808c31b6477290a714d356e822", - "shasum": "" - }, - "require": { - "php": ">=5.6" - }, - "require-dev": { - "php-coveralls/php-coveralls": "^2.1", - "phpunit/phpunit": "^5 || ^6.5" - }, - "type": "library", - "autoload": { - "files": [ - "src/getallheaders.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ralph Khattar", - "email": "ralph.khattar@gmail.com" - } - ], - "description": "A polyfill for getallheaders.", - "time": "2019-03-08T08:55:37+00:00" - }, - { - "name": "s9e/regexp-builder", - "version": "1.4.3", - "source": { - "type": "git", - "url": "https://github.com/s9e/RegexpBuilder.git", - "reference": "59d0167a909659d718f53964f7653d2c83a5f8fe" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/s9e/RegexpBuilder/zipball/59d0167a909659d718f53964f7653d2c83a5f8fe", - "reference": "59d0167a909659d718f53964f7653d2c83a5f8fe", - "shasum": "" - }, - "require": { - "lib-pcre": ">=7.2", - "php": ">=5.5.1" - }, - "require-dev": { - "phpunit/phpunit": "<5.8" - }, - "type": "library", - "autoload": { - "psr-4": { - "s9e\\RegexpBuilder\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Single-purpose library that generates regular expressions that match a list of strings.", - "homepage": "https://github.com/s9e/RegexpBuilder/", - "keywords": [ - "regexp" - ], - "time": "2019-04-26T17:55:23+00:00" - }, - { - "name": "s9e/text-formatter", - "version": "2.3.0", - "source": { - "type": "git", - "url": "https://github.com/s9e/TextFormatter.git", - "reference": "26d6ee3a931a25acfea3096f62f0cc42172f3859" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/s9e/TextFormatter/zipball/26d6ee3a931a25acfea3096f62f0cc42172f3859", - "reference": "26d6ee3a931a25acfea3096f62f0cc42172f3859", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-filter": "*", - "lib-pcre": ">=8.13", - "php": ">=7.1", - "s9e/regexp-builder": "^1.4" - }, - "require-dev": { - "matthiasmullie/minify": "*", - "phpunit/phpunit": "^7 || 8.2.*" - }, - "suggest": { - "ext-curl": "Improves the performance of the MediaEmbed plugin and some JavaScript minifiers", - "ext-intl": "Allows international URLs to be accepted by the URL filter", - "ext-json": "Enables the generation of a JavaScript parser", - "ext-mbstring": "Improves the performance of the PHP renderer", - "ext-tokenizer": "Improves the performance of the PHP renderer", - "ext-xsl": "Enables the XSLT renderer", - "ext-zlib": "Enables gzip compression when scraping content via the MediaEmbed plugin" - }, - "type": "library", - "extra": { - "version": "2.3.0" - }, - "autoload": { - "psr-4": { - "s9e\\TextFormatter\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Multi-purpose text formatting and markup library. Plugins offer support for BBCodes, Markdown, emoticons, HTML, embedding media (YouTube, etc...), enhanced typography and more.", - "homepage": "https://github.com/s9e/TextFormatter/", - "keywords": [ - "bbcode", - "bbcodes", - "blog", - "censor", - "embed", - "emoji", - "emoticons", - "engine", - "forum", - "html", - "markdown", - "markup", - "media", - "parser", - "shortcodes" - ], - "time": "2019-11-17T16:03:56+00:00" - }, - { - "name": "symfony/config", - "version": "v3.4.36", - "source": { - "type": "git", - "url": "https://github.com/symfony/config.git", - "reference": "a599a867d0e4a07c342b5f1e656b3915a540ddbe" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/a599a867d0e4a07c342b5f1e656b3915a540ddbe", - "reference": "a599a867d0e4a07c342b5f1e656b3915a540ddbe", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8", - "symfony/filesystem": "~2.8|~3.0|~4.0", - "symfony/polyfill-ctype": "~1.8" - }, - "conflict": { - "symfony/dependency-injection": "<3.3", - "symfony/finder": "<3.3" - }, - "require-dev": { - "symfony/dependency-injection": "~3.3|~4.0", - "symfony/event-dispatcher": "~3.3|~4.0", - "symfony/finder": "~3.3|~4.0", - "symfony/yaml": "~3.0|~4.0" - }, - "suggest": { - "symfony/yaml": "To use the yaml reference dumper" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Config\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Config Component", - "homepage": "https://symfony.com", - "time": "2019-12-01T10:45:41+00:00" - }, - { - "name": "symfony/console", - "version": "v3.4.36", - "source": { - "type": "git", - "url": "https://github.com/symfony/console.git", - "reference": "1ee23b3b659b06c622f2bd2492a229e416eb4586" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/1ee23b3b659b06c622f2bd2492a229e416eb4586", - "reference": "1ee23b3b659b06c622f2bd2492a229e416eb4586", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8", - "symfony/debug": "~2.8|~3.0|~4.0", - "symfony/polyfill-mbstring": "~1.0" - }, - "conflict": { - "symfony/dependency-injection": "<3.4", - "symfony/process": "<3.3" - }, - "provide": { - "psr/log-implementation": "1.0" - }, - "require-dev": { - "psr/log": "~1.0", - "symfony/config": "~3.3|~4.0", - "symfony/dependency-injection": "~3.4|~4.0", - "symfony/event-dispatcher": "~2.8|~3.0|~4.0", - "symfony/lock": "~3.4|~4.0", - "symfony/process": "~3.3|~4.0" - }, - "suggest": { - "psr/log": "For using the console logger", - "symfony/event-dispatcher": "", - "symfony/lock": "", - "symfony/process": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Console\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Console Component", - "homepage": "https://symfony.com", - "time": "2019-12-01T10:04:45+00:00" - }, - { - "name": "symfony/debug", - "version": "v3.4.36", - "source": { - "type": "git", - "url": "https://github.com/symfony/debug.git", - "reference": "f72e33fdb1170b326e72c3157f0cd456351dd086" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/f72e33fdb1170b326e72c3157f0cd456351dd086", - "reference": "f72e33fdb1170b326e72c3157f0cd456351dd086", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8", - "psr/log": "~1.0" - }, - "conflict": { - "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" - }, - "require-dev": { - "symfony/http-kernel": "~2.8|~3.0|~4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Debug\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Debug Component", - "homepage": "https://symfony.com", - "time": "2019-10-24T15:33:53+00:00" - }, - { - "name": "symfony/dependency-injection", - "version": "v3.4.36", - "source": { - "type": "git", - "url": "https://github.com/symfony/dependency-injection.git", - "reference": "0d201916bfb3af939fec3c0c8815ea16c60ac1a2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/0d201916bfb3af939fec3c0c8815ea16c60ac1a2", - "reference": "0d201916bfb3af939fec3c0c8815ea16c60ac1a2", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8", - "psr/container": "^1.0" - }, - "conflict": { - "symfony/config": "<3.3.7", - "symfony/finder": "<3.3", - "symfony/proxy-manager-bridge": "<3.4", - "symfony/yaml": "<3.4" - }, - "provide": { - "psr/container-implementation": "1.0" - }, - "require-dev": { - "symfony/config": "~3.3|~4.0", - "symfony/expression-language": "~2.8|~3.0|~4.0", - "symfony/yaml": "~3.4|~4.0" - }, - "suggest": { - "symfony/config": "", - "symfony/expression-language": "For using expressions in service container configuration", - "symfony/finder": "For using double-star glob patterns or when GLOB_BRACE portability is required", - "symfony/proxy-manager-bridge": "Generate service proxies to lazy load them", - "symfony/yaml": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\DependencyInjection\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony DependencyInjection Component", - "homepage": "https://symfony.com", - "time": "2019-12-01T08:33:36+00:00" - }, - { - "name": "symfony/event-dispatcher", - "version": "v3.4.36", - "source": { - "type": "git", - "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "f9031c22ec127d4a2450760f81a8677fe8a10177" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/f9031c22ec127d4a2450760f81a8677fe8a10177", - "reference": "f9031c22ec127d4a2450760f81a8677fe8a10177", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8" - }, - "conflict": { - "symfony/dependency-injection": "<3.3" - }, - "require-dev": { - "psr/log": "~1.0", - "symfony/config": "~2.8|~3.0|~4.0", - "symfony/dependency-injection": "~3.3|~4.0", - "symfony/expression-language": "~2.8|~3.0|~4.0", - "symfony/stopwatch": "~2.8|~3.0|~4.0" - }, - "suggest": { - "symfony/dependency-injection": "", - "symfony/http-kernel": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\EventDispatcher\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony EventDispatcher Component", - "homepage": "https://symfony.com", - "time": "2019-10-24T15:33:53+00:00" - }, - { - "name": "symfony/filesystem", - "version": "v3.4.36", - "source": { - "type": "git", - "url": "https://github.com/symfony/filesystem.git", - "reference": "00cdad0936d06fab136944bc2342b762b1c3a4a2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/00cdad0936d06fab136944bc2342b762b1c3a4a2", - "reference": "00cdad0936d06fab136944bc2342b762b1c3a4a2", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8", - "symfony/polyfill-ctype": "~1.8" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Filesystem\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Filesystem Component", - "homepage": "https://symfony.com", - "time": "2019-11-25T16:36:22+00:00" - }, - { - "name": "symfony/finder", - "version": "v3.4.36", - "source": { - "type": "git", - "url": "https://github.com/symfony/finder.git", - "reference": "290ae21279b37bfd287cdcce640d51204e84afdf" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/290ae21279b37bfd287cdcce640d51204e84afdf", - "reference": "290ae21279b37bfd287cdcce640d51204e84afdf", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Finder\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Finder Component", - "homepage": "https://symfony.com", - "time": "2019-11-17T21:55:15+00:00" - }, - { - "name": "symfony/http-foundation", - "version": "v3.4.36", - "source": { - "type": "git", - "url": "https://github.com/symfony/http-foundation.git", - "reference": "d2d0cfe8e319d9df44c4cca570710fcf221d4593" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/d2d0cfe8e319d9df44c4cca570710fcf221d4593", - "reference": "d2d0cfe8e319d9df44c4cca570710fcf221d4593", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8", - "symfony/polyfill-mbstring": "~1.1", - "symfony/polyfill-php70": "~1.6" - }, - "require-dev": { - "symfony/expression-language": "~2.8|~3.0|~4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\HttpFoundation\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony HttpFoundation Component", - "homepage": "https://symfony.com", - "time": "2019-11-28T12:52:59+00:00" - }, - { - "name": "symfony/http-kernel", - "version": "v3.4.36", - "source": { - "type": "git", - "url": "https://github.com/symfony/http-kernel.git", - "reference": "c42c8339acb28cfff0fb1786948db4d23d609ff7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/c42c8339acb28cfff0fb1786948db4d23d609ff7", - "reference": "c42c8339acb28cfff0fb1786948db4d23d609ff7", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8", - "psr/log": "~1.0", - "symfony/debug": "^3.3.3|~4.0", - "symfony/event-dispatcher": "~2.8|~3.0|~4.0", - "symfony/http-foundation": "~3.4.12|~4.0.12|^4.1.1", - "symfony/polyfill-ctype": "~1.8", - "symfony/polyfill-php56": "~1.8" - }, - "conflict": { - "symfony/config": "<2.8", - "symfony/dependency-injection": "<3.4.10|<4.0.10,>=4", - "symfony/var-dumper": "<3.3", - "twig/twig": "<1.34|<2.4,>=2" - }, - "provide": { - "psr/log-implementation": "1.0" - }, - "require-dev": { - "psr/cache": "~1.0", - "symfony/browser-kit": "~2.8|~3.0|~4.0", - "symfony/class-loader": "~2.8|~3.0", - "symfony/config": "~2.8|~3.0|~4.0", - "symfony/console": "~2.8|~3.0|~4.0", - "symfony/css-selector": "~2.8|~3.0|~4.0", - "symfony/dependency-injection": "^3.4.10|^4.0.10", - "symfony/dom-crawler": "~2.8|~3.0|~4.0", - "symfony/expression-language": "~2.8|~3.0|~4.0", - "symfony/finder": "~2.8|~3.0|~4.0", - "symfony/process": "~2.8|~3.0|~4.0", - "symfony/routing": "~3.4|~4.0", - "symfony/stopwatch": "~2.8|~3.0|~4.0", - "symfony/templating": "~2.8|~3.0|~4.0", - "symfony/translation": "~2.8|~3.0|~4.0", - "symfony/var-dumper": "~3.3|~4.0" - }, - "suggest": { - "symfony/browser-kit": "", - "symfony/config": "", - "symfony/console": "", - "symfony/dependency-injection": "", - "symfony/finder": "", - "symfony/var-dumper": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\HttpKernel\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony HttpKernel Component", - "homepage": "https://symfony.com", - "time": "2019-12-01T13:50:37+00:00" - }, - { - "name": "symfony/polyfill-ctype", - "version": "v1.13.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/f8f0b461be3385e56d6de3dbb5a0df24c0c275e3", - "reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "suggest": { - "ext-ctype": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.13-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Ctype\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Gert de Pagter", - "email": "BackEndTea@gmail.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for ctype functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "ctype", - "polyfill", - "portable" - ], - "time": "2019-11-27T13:56:44+00:00" - }, - { - "name": "symfony/polyfill-mbstring", - "version": "v1.13.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "7b4aab9743c30be783b73de055d24a39cf4b954f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/7b4aab9743c30be783b73de055d24a39cf4b954f", - "reference": "7b4aab9743c30be783b73de055d24a39cf4b954f", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "suggest": { - "ext-mbstring": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.13-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Mbstring\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for the Mbstring extension", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "mbstring", - "polyfill", - "portable", - "shim" - ], - "time": "2019-11-27T14:18:11+00:00" - }, - { - "name": "symfony/polyfill-php56", - "version": "v1.13.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php56.git", - "reference": "53dd1cdf3cb986893ccf2b96665b25b3abb384f4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php56/zipball/53dd1cdf3cb986893ccf2b96665b25b3abb384f4", - "reference": "53dd1cdf3cb986893ccf2b96665b25b3abb384f4", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "symfony/polyfill-util": "~1.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.13-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php56\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "time": "2019-11-27T13:56:44+00:00" - }, - { - "name": "symfony/polyfill-php70", - "version": "v1.13.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php70.git", - "reference": "af23c7bb26a73b850840823662dda371484926c4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/af23c7bb26a73b850840823662dda371484926c4", - "reference": "af23c7bb26a73b850840823662dda371484926c4", - "shasum": "" - }, - "require": { - "paragonie/random_compat": "~1.0|~2.0|~9.99", - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.13-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php70\\": "" - }, - "files": [ - "bootstrap.php" - ], - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "time": "2019-11-27T13:56:44+00:00" - }, - { - "name": "symfony/polyfill-util", - "version": "v1.13.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-util.git", - "reference": "964a67f293b66b95883a5ed918a65354fcd2258f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-util/zipball/964a67f293b66b95883a5ed918a65354fcd2258f", - "reference": "964a67f293b66b95883a5ed918a65354fcd2258f", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.13-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Util\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony utilities for portability of PHP codes", - "homepage": "https://symfony.com", - "keywords": [ - "compat", - "compatibility", - "polyfill", - "shim" - ], - "time": "2019-11-27T13:56:44+00:00" - }, - { - "name": "symfony/proxy-manager-bridge", - "version": "v3.4.36", - "source": { - "type": "git", - "url": "https://github.com/symfony/proxy-manager-bridge.git", - "reference": "3c185a0e45ea13334aaf7b0fa9726922816ebec6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/proxy-manager-bridge/zipball/3c185a0e45ea13334aaf7b0fa9726922816ebec6", - "reference": "3c185a0e45ea13334aaf7b0fa9726922816ebec6", - "shasum": "" - }, - "require": { - "ocramius/proxy-manager": "~0.4|~1.0|~2.0", - "php": "^5.5.9|>=7.0.8", - "symfony/dependency-injection": "~3.4|~4.0" - }, - "require-dev": { - "symfony/config": "~2.8|~3.0|~4.0" - }, - "type": "symfony-bridge", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Bridge\\ProxyManager\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony ProxyManager Bridge", - "homepage": "https://symfony.com", - "time": "2019-08-29T14:54:55+00:00" - }, - { - "name": "symfony/routing", - "version": "v3.4.36", - "source": { - "type": "git", - "url": "https://github.com/symfony/routing.git", - "reference": "b689ccd48e234ea404806d94b07eeb45f9f6f06a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/routing/zipball/b689ccd48e234ea404806d94b07eeb45f9f6f06a", - "reference": "b689ccd48e234ea404806d94b07eeb45f9f6f06a", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8" - }, - "conflict": { - "symfony/config": "<3.3.1", - "symfony/dependency-injection": "<3.3", - "symfony/yaml": "<3.4" - }, - "require-dev": { - "doctrine/annotations": "~1.0", - "psr/log": "~1.0", - "symfony/config": "^3.3.1|~4.0", - "symfony/dependency-injection": "~3.3|~4.0", - "symfony/expression-language": "~2.8|~3.0|~4.0", - "symfony/http-foundation": "~2.8|~3.0|~4.0", - "symfony/yaml": "~3.4|~4.0" - }, - "suggest": { - "doctrine/annotations": "For using the annotation loader", - "symfony/config": "For using the all-in-one router or any loader", - "symfony/expression-language": "For using expression matching", - "symfony/http-foundation": "For using a Symfony Request object", - "symfony/yaml": "For using the YAML loader" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Routing\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Routing Component", - "homepage": "https://symfony.com", - "keywords": [ - "router", - "routing", - "uri", - "url" - ], - "time": "2019-12-01T08:33:36+00:00" - }, - { - "name": "symfony/twig-bridge", - "version": "v3.4.36", - "source": { - "type": "git", - "url": "https://github.com/symfony/twig-bridge.git", - "reference": "49b824ddc7f2d250a1f172349cd9a111d63287c0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/twig-bridge/zipball/49b824ddc7f2d250a1f172349cd9a111d63287c0", - "reference": "49b824ddc7f2d250a1f172349cd9a111d63287c0", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8", - "twig/twig": "^1.41|^2.10" - }, - "conflict": { - "symfony/console": "<3.4", - "symfony/form": "<3.4.31|>=4.0,<4.3.4" - }, - "require-dev": { - "fig/link-util": "^1.0", - "symfony/asset": "~2.8|~3.0|~4.0", - "symfony/console": "~3.4|~4.0", - "symfony/dependency-injection": "~2.8|~3.0|~4.0", - "symfony/expression-language": "~2.8|~3.0|~4.0", - "symfony/finder": "~2.8|~3.0|~4.0", - "symfony/form": "^3.4.31|^4.3.4", - "symfony/http-foundation": "^3.3.11|~4.0", - "symfony/http-kernel": "~3.2|~4.0", - "symfony/polyfill-intl-icu": "~1.0", - "symfony/routing": "~2.8|~3.0|~4.0", - "symfony/security": "^2.8.31|^3.3.13|~4.0", - "symfony/security-acl": "~2.8|~3.0", - "symfony/stopwatch": "~2.8|~3.0|~4.0", - "symfony/templating": "~2.8|~3.0|~4.0", - "symfony/translation": "~2.8|~3.0|~4.0", - "symfony/var-dumper": "~2.8.10|~3.1.4|~3.2|~4.0", - "symfony/web-link": "~3.3|~4.0", - "symfony/workflow": "~3.3|~4.0", - "symfony/yaml": "~2.8|~3.0|~4.0" - }, - "suggest": { - "symfony/asset": "For using the AssetExtension", - "symfony/expression-language": "For using the ExpressionExtension", - "symfony/finder": "", - "symfony/form": "For using the FormExtension", - "symfony/http-kernel": "For using the HttpKernelExtension", - "symfony/routing": "For using the RoutingExtension", - "symfony/security": "For using the SecurityExtension", - "symfony/stopwatch": "For using the StopwatchExtension", - "symfony/templating": "For using the TwigEngine", - "symfony/translation": "For using the TranslationExtension", - "symfony/var-dumper": "For using the DumpExtension", - "symfony/web-link": "For using the WebLinkExtension", - "symfony/yaml": "For using the YamlExtension" - }, - "type": "symfony-bridge", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Bridge\\Twig\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Twig Bridge", - "homepage": "https://symfony.com", - "time": "2019-11-30T08:19:08+00:00" - }, - { - "name": "symfony/yaml", - "version": "v3.4.36", - "source": { - "type": "git", - "url": "https://github.com/symfony/yaml.git", - "reference": "dab657db15207879217fc81df4f875947bf68804" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/dab657db15207879217fc81df4f875947bf68804", - "reference": "dab657db15207879217fc81df4f875947bf68804", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8", - "symfony/polyfill-ctype": "~1.8" - }, - "conflict": { - "symfony/console": "<3.4" - }, - "require-dev": { - "symfony/console": "~3.4|~4.0" - }, - "suggest": { - "symfony/console": "For validating YAML files using the lint command" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Yaml\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Yaml Component", - "homepage": "https://symfony.com", - "time": "2019-10-24T15:33:53+00:00" - }, - { - "name": "twig/twig", - "version": "v2.12.2", - "source": { - "type": "git", - "url": "https://github.com/twigphp/Twig.git", - "reference": "d761fd1f1c6b867ae09a7d8119a6d95d06dc44ed" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/d761fd1f1c6b867ae09a7d8119a6d95d06dc44ed", - "reference": "d761fd1f1c6b867ae09a7d8119a6d95d06dc44ed", - "shasum": "" - }, - "require": { - "php": "^7.0", - "symfony/polyfill-ctype": "^1.8", - "symfony/polyfill-mbstring": "^1.3" - }, - "require-dev": { - "psr/container": "^1.0", - "symfony/debug": "^3.4|^4.2", - "symfony/phpunit-bridge": "^4.4@dev|^5.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.12-dev" - } - }, - "autoload": { - "psr-0": { - "Twig_": "lib/" - }, - "psr-4": { - "Twig\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, - { - "name": "Twig Team", - "homepage": "https://twig.symfony.com/contributors", - "role": "Contributors" - }, - { - "name": "Armin Ronacher", - "email": "armin.ronacher@active-4.com", - "role": "Project Founder" - } - ], - "description": "Twig, the flexible, fast, and secure template language for PHP", - "homepage": "https://twig.symfony.com", - "keywords": [ - "templating" - ], - "time": "2019-11-11T16:52:09+00:00" - }, - { - "name": "zendframework/zend-code", - "version": "3.4.1", - "source": { - "type": "git", - "url": "https://github.com/zendframework/zend-code.git", - "reference": "268040548f92c2bfcba164421c1add2ba43abaaa" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-code/zipball/268040548f92c2bfcba164421c1add2ba43abaaa", - "reference": "268040548f92c2bfcba164421c1add2ba43abaaa", - "shasum": "" - }, - "require": { - "php": "^7.1", - "zendframework/zend-eventmanager": "^2.6 || ^3.0" - }, - "conflict": { - "phpspec/prophecy": "<1.9.0" - }, - "require-dev": { - "doctrine/annotations": "^1.7", - "ext-phar": "*", - "phpunit/phpunit": "^7.5.16 || ^8.4", - "zendframework/zend-coding-standard": "^1.0", - "zendframework/zend-stdlib": "^2.7 || ^3.0" - }, - "suggest": { - "doctrine/annotations": "Doctrine\\Common\\Annotations >=1.0 for annotation features", - "zendframework/zend-stdlib": "Zend\\Stdlib component" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4.x-dev", - "dev-develop": "3.5.x-dev", - "dev-dev-4.0": "4.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Zend\\Code\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "description": "Extensions to the PHP Reflection API, static code scanning, and code generation", - "keywords": [ - "ZendFramework", - "code", - "zf" - ], - "time": "2019-12-10T19:21:15+00:00" - }, - { - "name": "zendframework/zend-eventmanager", - "version": "3.2.1", - "source": { - "type": "git", - "url": "https://github.com/zendframework/zend-eventmanager.git", - "reference": "a5e2583a211f73604691586b8406ff7296a946dd" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-eventmanager/zipball/a5e2583a211f73604691586b8406ff7296a946dd", - "reference": "a5e2583a211f73604691586b8406ff7296a946dd", - "shasum": "" - }, - "require": { - "php": "^5.6 || ^7.0" - }, - "require-dev": { - "athletic/athletic": "^0.1", - "container-interop/container-interop": "^1.1.0", - "phpunit/phpunit": "^5.7.27 || ^6.5.8 || ^7.1.2", - "zendframework/zend-coding-standard": "~1.0.0", - "zendframework/zend-stdlib": "^2.7.3 || ^3.0" - }, - "suggest": { - "container-interop/container-interop": "^1.1.0, to use the lazy listeners feature", - "zendframework/zend-stdlib": "^2.7.3 || ^3.0, to use the FilterChain feature" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.2-dev", - "dev-develop": "3.3-dev" - } - }, - "autoload": { - "psr-4": { - "Zend\\EventManager\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "description": "Trigger and listen to events within a PHP application", - "homepage": "https://github.com/zendframework/zend-eventmanager", - "keywords": [ - "event", - "eventmanager", - "events", - "zf2" - ], - "time": "2018-04-25T15:33:34+00:00" - } - ], - "packages-dev": [], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": { - "phpbb/phpbb": 10 - }, - "prefer-stable": false, - "prefer-lowest": false, - "platform": { - "php": ">=5.4" - }, - "platform-dev": [] -} diff --git a/install/update/new/ext/phpbb/viglink/styles/all/theme/viglink.css b/install/update/new/ext/phpbb/viglink/styles/all/theme/viglink.css deleted file mode 100644 index 96c5137..0000000 --- a/install/update/new/ext/phpbb/viglink/styles/all/theme/viglink.css +++ /dev/null @@ -1,18 +0,0 @@ -/* phpBB VigLink Extension Style Sheet - ------------------------------------------------------------------------ - Copyright (c) phpBB Limited - - For full copyright and license information, please see - the docs/CREDITS.txt file. - ------------------------------------------------------------------------ -*/ - -.viglink-header { - background: url("images/VigLink_logo.png") no-repeat 0 0; - padding-bottom: 18px; - padding-left: 142px; -} - -.send-stats-tile > .viglink-header-h2 { - margin-bottom: 10px; -} diff --git a/install/update/new/feed.php b/install/update/new/feed.php deleted file mode 100644 index e384489..0000000 --- a/install/update/new/feed.php +++ /dev/null @@ -1,58 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -* Idea and original RSS Feed 2.0 MOD (Version 1.0.8/9) by leviatan21 -* Original MOD: http://www.phpbb.com/community/viewtopic.php?f=69&t=1214645 -* MOD Author Profile: http://www.phpbb.com/community/memberlist.php?mode=viewprofile&u=345763 -* MOD Author Homepage: http://www.mssti.com/phpbb3/ -* -**/ - -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\Routing\Exception\InvalidParameterException; - -/** -* @ignore -**/ -define('IN_PHPBB', true); -$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); -include($phpbb_root_path . 'common.' . $phpEx); - -/** @var \phpbb\controller\helper $controller_helper */ -$controller_helper = $phpbb_container->get('controller.helper'); - -$forum_id = $request->variable('f', 0); -$topic_id = $request->variable('t', 0); -$mode = $request->variable('mode', ''); - -if ($forum_id !== 0) -{ - $url = $controller_helper->route('phpbb_feed_forum', array('forum_id' => $forum_id), false); -} -else if ($topic_id !== 0) -{ - $url = $controller_helper->route('phpbb_feed_topic', array('topic_id' => $topic_id), false); -} -else -{ - try - { - $url = $controller_helper->route('phpbb_feed_overall', array('mode' => $mode), false); - } - catch (InvalidParameterException $e) - { - $url = $controller_helper->route('phpbb_feed_index'); - } -} - -$response = new RedirectResponse($url, 301); -$response->send(); diff --git a/install/update/new/includes/acp/acp_attachments.php b/install/update/new/includes/acp/acp_attachments.php deleted file mode 100644 index feeccbe..0000000 --- a/install/update/new/includes/acp/acp_attachments.php +++ /dev/null @@ -1,1730 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -class acp_attachments -{ - /** @var \phpbb\db\driver\driver_interface */ - protected $db; - - /** @var \phpbb\config\config */ - protected $config; - - /** @var \phpbb\language\language */ - protected $language; - - /** @var ContainerBuilder */ - protected $phpbb_container; - - /** @var \phpbb\template\template */ - protected $template; - - /** @var \phpbb\user */ - protected $user; - - /** @var \phpbb\filesystem\filesystem_interface */ - protected $filesystem; - - /** @var \phpbb\attachment\manager */ - protected $attachment_manager; - - public $id; - public $u_action; - protected $new_config; - - function main($id, $mode) - { - global $db, $user, $auth, $template, $cache, $phpbb_container, $phpbb_filesystem, $phpbb_dispatcher; - global $config, $phpbb_admin_path, $phpbb_root_path, $phpEx, $phpbb_log, $request; - - $this->id = $id; - $this->db = $db; - $this->config = $config; - $this->language = $phpbb_container->get('language'); - $this->template = $template; - $this->user = $user; - $this->phpbb_container = $phpbb_container; - $this->filesystem = $phpbb_filesystem; - $this->attachment_manager = $phpbb_container->get('attachment.manager'); - - $user->add_lang(array('posting', 'viewtopic', 'acp/attachments')); - - $error = $notify = array(); - $submit = (isset($_POST['submit'])) ? true : false; - $action = $request->variable('action', ''); - - $form_key = 'acp_attach'; - add_form_key($form_key); - - if ($submit && !check_form_key($form_key)) - { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - switch ($mode) - { - case 'attach': - $l_title = 'ACP_ATTACHMENT_SETTINGS'; - break; - - case 'extensions': - $l_title = 'ACP_MANAGE_EXTENSIONS'; - break; - - case 'ext_groups': - $l_title = 'ACP_EXTENSION_GROUPS'; - break; - - case 'orphan': - $l_title = 'ACP_ORPHAN_ATTACHMENTS'; - break; - - case 'manage': - $l_title = 'ACP_MANAGE_ATTACHMENTS'; - break; - - default: - trigger_error('NO_MODE', E_USER_ERROR); - break; - } - - $this->tpl_name = 'acp_attachments'; - $this->page_title = $l_title; - - $template->assign_vars(array( - 'L_TITLE' => $user->lang[$l_title], - 'L_TITLE_EXPLAIN' => $user->lang[$l_title . '_EXPLAIN'], - 'U_ACTION' => $this->u_action) - ); - - switch ($mode) - { - case 'attach': - - if (!function_exists('get_supported_image_types')) - { - include($phpbb_root_path . 'includes/functions_posting.' . $phpEx); - } - - $sql = 'SELECT group_name, cat_id - FROM ' . EXTENSION_GROUPS_TABLE . ' - WHERE cat_id > 0 - ORDER BY cat_id'; - $result = $db->sql_query($sql); - - $s_assigned_groups = array(); - while ($row = $db->sql_fetchrow($result)) - { - $row['group_name'] = $this->language->is_set('EXT_GROUP_' . utf8_strtoupper($row['group_name'])) ? $this->language->lang('EXT_GROUP_' . utf8_strtoupper($row['group_name'])) : $row['group_name']; - $s_assigned_groups[$row['cat_id']][] = $row['group_name']; - } - $db->sql_freeresult($result); - - $l_legend_cat_images = $user->lang['SETTINGS_CAT_IMAGES'] . ' [' . $user->lang['ASSIGNED_GROUP'] . ': ' . ((!empty($s_assigned_groups[ATTACHMENT_CATEGORY_IMAGE])) ? implode($user->lang['COMMA_SEPARATOR'], $s_assigned_groups[ATTACHMENT_CATEGORY_IMAGE]) : $user->lang['NO_EXT_GROUP']) . ']'; - - $display_vars = array( - 'title' => 'ACP_ATTACHMENT_SETTINGS', - 'vars' => array( - 'legend1' => 'ACP_ATTACHMENT_SETTINGS', - - 'img_max_width' => array('lang' => 'MAX_IMAGE_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false,), - 'img_max_height' => array('lang' => 'MAX_IMAGE_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false,), - 'img_link_width' => array('lang' => 'IMAGE_LINK_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false,), - 'img_link_height' => array('lang' => 'IMAGE_LINK_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false,), - - 'allow_attachments' => array('lang' => 'ALLOW_ATTACHMENTS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_pm_attach' => array('lang' => 'ALLOW_PM_ATTACHMENTS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'upload_path' => array('lang' => 'UPLOAD_DIR', 'validate' => 'wpath', 'type' => 'text:25:100', 'explain' => true), - 'display_order' => array('lang' => 'DISPLAY_ORDER', 'validate' => 'bool', 'type' => 'custom', 'method' => 'display_order', 'explain' => true), - 'attachment_quota' => array('lang' => 'ATTACH_QUOTA', 'validate' => 'string', 'type' => 'custom', 'method' => 'max_filesize', 'explain' => true), - 'max_filesize' => array('lang' => 'ATTACH_MAX_FILESIZE', 'validate' => 'string', 'type' => 'custom', 'method' => 'max_filesize', 'explain' => true), - 'max_filesize_pm' => array('lang' => 'ATTACH_MAX_PM_FILESIZE','validate' => 'string', 'type' => 'custom', 'method' => 'max_filesize', 'explain' => true), - 'max_attachments' => array('lang' => 'MAX_ATTACHMENTS', 'validate' => 'int:0:999', 'type' => 'number:0:999', 'explain' => false), - 'max_attachments_pm' => array('lang' => 'MAX_ATTACHMENTS_PM', 'validate' => 'int:0:999', 'type' => 'number:0:999', 'explain' => false), - 'secure_downloads' => array('lang' => 'SECURE_DOWNLOADS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'secure_allow_deny' => array('lang' => 'SECURE_ALLOW_DENY', 'validate' => 'int', 'type' => 'custom', 'method' => 'select_allow_deny', 'explain' => true), - 'secure_allow_empty_referer' => array('lang' => 'SECURE_EMPTY_REFERRER', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'check_attachment_content' => array('lang' => 'CHECK_CONTENT', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - - 'legend2' => $l_legend_cat_images, - 'img_display_inlined' => array('lang' => 'DISPLAY_INLINED', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'img_create_thumbnail' => array('lang' => 'CREATE_THUMBNAIL', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'img_max_thumb_width' => array('lang' => 'MAX_THUMB_WIDTH', 'validate' => 'int:0:999999999999999', 'type' => 'number:0:999999999999999', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), - 'img_min_thumb_filesize' => array('lang' => 'MIN_THUMB_FILESIZE', 'validate' => 'int:0:999999999999999', 'type' => 'number:0:999999999999999', 'explain' => true, 'append' => ' ' . $user->lang['BYTES']), - 'img_max' => array('lang' => 'MAX_IMAGE_SIZE', 'validate' => 'int:0:9999', 'type' => 'dimension:0:9999', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), - 'img_link' => array('lang' => 'IMAGE_LINK_SIZE', 'validate' => 'int:0:9999', 'type' => 'dimension:0:9999', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), - ) - ); - - /** - * Event to add and/or modify acp_attachement configurations - * - * @event core.acp_attachments_config_edit_add - * @var array display_vars Array of config values to display and process - * @var string mode Mode of the config page we are displaying - * @var boolean submit Do we display the form or process the submission - * @since 3.1.11-RC1 - */ - $vars = array('display_vars', 'mode', 'submit'); - extract($phpbb_dispatcher->trigger_event('core.acp_attachments_config_edit_add', compact($vars))); - - $this->new_config = $config; - $cfg_array = (isset($_REQUEST['config'])) ? $request->variable('config', array('' => '')) : $this->new_config; - $error = array(); - - // We validate the complete config if whished - validate_config_vars($display_vars['vars'], $cfg_array, $error); - - // Do not write values if there is an error - if (count($error)) - { - $submit = false; - } - - // We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to... - foreach ($display_vars['vars'] as $config_name => $null) - { - if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false) - { - continue; - } - - $this->new_config[$config_name] = $config_value = $cfg_array[$config_name]; - - if (in_array($config_name, array('attachment_quota', 'max_filesize', 'max_filesize_pm'))) - { - $size_var = $request->variable($config_name, ''); - $this->new_config[$config_name] = $config_value = ($size_var == 'kb') ? round($config_value * 1024) : (($size_var == 'mb') ? round($config_value * 1048576) : $config_value); - } - - if ($submit) - { - $config->set($config_name, $config_value); - } - } - - $this->perform_site_list(); - - if ($submit) - { - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_CONFIG_ATTACH'); - - // Check Settings - $this->test_upload($error, $this->new_config['upload_path'], false); - - if (!count($error)) - { - trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action)); - } - } - - $template->assign_var('S_ATTACHMENT_SETTINGS', true); - - // Secure Download Options - Same procedure as with banning - $allow_deny = ($this->new_config['secure_allow_deny']) ? 'ALLOWED' : 'DISALLOWED'; - - $sql = 'SELECT * - FROM ' . SITELIST_TABLE; - $result = $db->sql_query($sql); - - $defined_ips = ''; - $ips = array(); - - while ($row = $db->sql_fetchrow($result)) - { - $value = ($row['site_ip']) ? $row['site_ip'] : $row['site_hostname']; - if ($value) - { - $defined_ips .= '' . $value . ''; - $ips[$row['site_id']] = $value; - } - } - $db->sql_freeresult($result); - - $template->assign_vars(array( - 'S_SECURE_DOWNLOADS' => $this->new_config['secure_downloads'], - 'S_DEFINED_IPS' => ($defined_ips != '') ? true : false, - 'S_WARNING' => (count($error)) ? true : false, - - 'WARNING_MSG' => implode('
', $error), - 'DEFINED_IPS' => $defined_ips, - - 'L_SECURE_TITLE' => $user->lang['DEFINE_' . $allow_deny . '_IPS'], - 'L_IP_EXCLUDE' => $user->lang['EXCLUDE_FROM_' . $allow_deny . '_IP'], - 'L_REMOVE_IPS' => $user->lang['REMOVE_' . $allow_deny . '_IPS']) - ); - - // Output relevant options - foreach ($display_vars['vars'] as $config_key => $vars) - { - if (!is_array($vars) && strpos($config_key, 'legend') === false) - { - continue; - } - - if (strpos($config_key, 'legend') !== false) - { - $template->assign_block_vars('options', array( - 'S_LEGEND' => true, - 'LEGEND' => (isset($user->lang[$vars])) ? $user->lang[$vars] : $vars) - ); - - continue; - } - - $type = explode(':', $vars['type']); - - $l_explain = ''; - if ($vars['explain'] && isset($vars['lang_explain'])) - { - $l_explain = (isset($user->lang[$vars['lang_explain']])) ? $user->lang[$vars['lang_explain']] : $vars['lang_explain']; - } - else if ($vars['explain']) - { - $l_explain = (isset($user->lang[$vars['lang'] . '_EXPLAIN'])) ? $user->lang[$vars['lang'] . '_EXPLAIN'] : ''; - } - - $content = build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars); - if (empty($content)) - { - continue; - } - - $template->assign_block_vars('options', array( - 'KEY' => $config_key, - 'TITLE' => $user->lang[$vars['lang']], - 'S_EXPLAIN' => $vars['explain'], - 'TITLE_EXPLAIN' => $l_explain, - 'CONTENT' => $content, - ) - ); - - unset($display_vars['vars'][$config_key]); - } - - break; - - case 'extensions': - - if ($submit || isset($_POST['add_extension_check'])) - { - if ($submit) - { - // Change Extensions ? - $extension_change_list = $request->variable('extension_change_list', array(0)); - $group_select_list = $request->variable('group_select', array(0)); - - // Generate correct Change List - $extensions = array(); - - for ($i = 0, $size = count($extension_change_list); $i < $size; $i++) - { - $extensions[$extension_change_list[$i]]['group_id'] = $group_select_list[$i]; - } - - $sql = 'SELECT * - FROM ' . EXTENSIONS_TABLE . ' - ORDER BY extension_id'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if ($row['group_id'] != $extensions[$row['extension_id']]['group_id']) - { - $sql = 'UPDATE ' . EXTENSIONS_TABLE . ' - SET group_id = ' . (int) $extensions[$row['extension_id']]['group_id'] . ' - WHERE extension_id = ' . $row['extension_id']; - $db->sql_query($sql); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ATTACH_EXT_UPDATE', false, array($row['extension'])); - } - } - $db->sql_freeresult($result); - - // Delete Extension? - $extension_id_list = $request->variable('extension_id_list', array(0)); - - if (count($extension_id_list)) - { - $sql = 'SELECT extension - FROM ' . EXTENSIONS_TABLE . ' - WHERE ' . $db->sql_in_set('extension_id', $extension_id_list); - $result = $db->sql_query($sql); - - $extension_list = ''; - while ($row = $db->sql_fetchrow($result)) - { - $extension_list .= ($extension_list == '') ? $row['extension'] : ', ' . $row['extension']; - } - $db->sql_freeresult($result); - - $sql = 'DELETE - FROM ' . EXTENSIONS_TABLE . ' - WHERE ' . $db->sql_in_set('extension_id', $extension_id_list); - $db->sql_query($sql); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ATTACH_EXT_DEL', false, array($extension_list)); - } - } - - // Add Extension? - $add_extension = strtolower($request->variable('add_extension', '')); - $add_extension_group = $request->variable('add_group_select', 0); - $add = (isset($_POST['add_extension_check'])) ? true : false; - - if ($add_extension && $add) - { - if (!count($error)) - { - $sql = 'SELECT extension_id - FROM ' . EXTENSIONS_TABLE . " - WHERE extension = '" . $db->sql_escape($add_extension) . "'"; - $result = $db->sql_query($sql); - - if ($row = $db->sql_fetchrow($result)) - { - $error[] = sprintf($user->lang['EXTENSION_EXIST'], $add_extension); - } - $db->sql_freeresult($result); - - if (!count($error)) - { - $sql_ary = array( - 'group_id' => $add_extension_group, - 'extension' => $add_extension - ); - - $db->sql_query('INSERT INTO ' . EXTENSIONS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ATTACH_EXT_ADD', false, array($add_extension)); - } - } - } - - if (!count($error)) - { - $notify[] = $user->lang['EXTENSIONS_UPDATED']; - } - - $cache->destroy('_extensions'); - } - - $template->assign_vars(array( - 'S_EXTENSIONS' => true, - 'ADD_EXTENSION' => (isset($add_extension)) ? $add_extension : '', - 'GROUP_SELECT_OPTIONS' => (isset($_POST['add_extension_check'])) ? $this->group_select('add_group_select', $add_extension_group, 'extension_group') : $this->group_select('add_group_select', false, 'extension_group')) - ); - - $sql = 'SELECT * - FROM ' . EXTENSIONS_TABLE . ' - ORDER BY group_id, extension'; - $result = $db->sql_query($sql); - - if ($row = $db->sql_fetchrow($result)) - { - $old_group_id = $row['group_id']; - do - { - $s_spacer = false; - - $current_group_id = $row['group_id']; - if ($old_group_id != $current_group_id) - { - $s_spacer = true; - $old_group_id = $current_group_id; - } - - $template->assign_block_vars('extensions', array( - 'S_SPACER' => $s_spacer, - 'EXTENSION_ID' => $row['extension_id'], - 'EXTENSION' => $row['extension'], - 'GROUP_OPTIONS' => $this->group_select('group_select[]', $row['group_id'])) - ); - } - while ($row = $db->sql_fetchrow($result)); - } - $db->sql_freeresult($result); - - break; - - case 'ext_groups': - - $template->assign_var('S_EXTENSION_GROUPS', true); - - if ($submit) - { - $action = $request->variable('action', ''); - $group_id = $request->variable('g', 0); - - if ($action != 'add' && $action != 'edit') - { - trigger_error('NO_MODE', E_USER_ERROR); - } - - if (!$group_id && $action == 'edit') - { - trigger_error($user->lang['NO_EXT_GROUP_SPECIFIED'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - if ($group_id) - { - $sql = 'SELECT * - FROM ' . EXTENSION_GROUPS_TABLE . " - WHERE group_id = $group_id"; - $result = $db->sql_query($sql); - $ext_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$ext_row) - { - trigger_error($user->lang['NO_EXT_GROUP_SPECIFIED'] . adm_back_link($this->u_action), E_USER_WARNING); - } - } - else - { - $ext_row = array(); - } - - $group_name = $request->variable('group_name', '', true); - $new_group_name = ($action == 'add') ? $group_name : (($ext_row['group_name'] != $group_name) ? $group_name : ''); - - if (!$group_name) - { - $error[] = $user->lang['NO_EXT_GROUP_NAME']; - } - - // Check New Group Name - if ($new_group_name) - { - $sql = 'SELECT group_id - FROM ' . EXTENSION_GROUPS_TABLE . " - WHERE LOWER(group_name) = '" . $db->sql_escape(utf8_strtolower($new_group_name)) . "'"; - if ($group_id) - { - $sql .= ' AND group_id <> ' . $group_id; - } - $result = $db->sql_query($sql); - - if ($db->sql_fetchrow($result)) - { - $error[] = sprintf($user->lang['EXTENSION_GROUP_EXIST'], $new_group_name); - } - $db->sql_freeresult($result); - } - - if (!count($error)) - { - // Ok, build the update/insert array - $upload_icon = $request->variable('upload_icon', 'no_image'); - $size_select = $request->variable('size_select', 'b'); - $forum_select = $request->variable('forum_select', false); - $allowed_forums = $request->variable('allowed_forums', array(0)); - $allow_in_pm = (isset($_POST['allow_in_pm'])) ? true : false; - $max_filesize = $request->variable('max_filesize', 0); - $max_filesize = ($size_select == 'kb') ? round($max_filesize * 1024) : (($size_select == 'mb') ? round($max_filesize * 1048576) : $max_filesize); - $allow_group = (isset($_POST['allow_group'])) ? true : false; - - if ($max_filesize == $config['max_filesize']) - { - $max_filesize = 0; - } - - if (!count($allowed_forums)) - { - $forum_select = false; - } - - $group_ary = array( - 'group_name' => $group_name, - 'cat_id' => $request->variable('special_category', ATTACHMENT_CATEGORY_NONE), - 'allow_group' => ($allow_group) ? 1 : 0, - 'upload_icon' => ($upload_icon == 'no_image') ? '' : $upload_icon, - 'max_filesize' => $max_filesize, - 'allowed_forums'=> ($forum_select) ? serialize($allowed_forums) : '', - 'allow_in_pm' => ($allow_in_pm) ? 1 : 0, - ); - - if ($action == 'add') - { - $group_ary['download_mode'] = INLINE_LINK; - } - - $sql = ($action == 'add') ? 'INSERT INTO ' . EXTENSION_GROUPS_TABLE . ' ' : 'UPDATE ' . EXTENSION_GROUPS_TABLE . ' SET '; - $sql .= $db->sql_build_array((($action == 'add') ? 'INSERT' : 'UPDATE'), $group_ary); - $sql .= ($action == 'edit') ? " WHERE group_id = $group_id" : ''; - - $db->sql_query($sql); - - if ($action == 'add') - { - $group_id = $db->sql_nextid(); - } - - $group_name = $this->language->is_set('EXT_GROUP_' . utf8_strtoupper($group_name)) ? $this->language->lang('EXT_GROUP_' . utf8_strtoupper($group_name)) : $group_name; - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ATTACH_EXTGROUP_' . strtoupper($action), false, array($group_name)); - } - - $extension_list = $request->variable('extensions', array(0)); - - if ($action == 'edit' && count($extension_list)) - { - $sql = 'UPDATE ' . EXTENSIONS_TABLE . " - SET group_id = 0 - WHERE group_id = $group_id"; - $db->sql_query($sql); - } - - if (count($extension_list)) - { - $sql = 'UPDATE ' . EXTENSIONS_TABLE . " - SET group_id = $group_id - WHERE " . $db->sql_in_set('extension_id', $extension_list); - $db->sql_query($sql); - } - - $cache->destroy('_extensions'); - - if (!count($error)) - { - $notify[] = $user->lang['SUCCESS_EXTENSION_GROUP_' . strtoupper($action)]; - } - } - - $cat_lang = array( - ATTACHMENT_CATEGORY_NONE => $user->lang['NO_FILE_CAT'], - ATTACHMENT_CATEGORY_IMAGE => $user->lang['CAT_IMAGES'], - ); - - $group_id = $request->variable('g', 0); - $action = (isset($_POST['add'])) ? 'add' : $action; - - switch ($action) - { - case 'delete': - - if (confirm_box(true)) - { - $sql = 'SELECT group_name - FROM ' . EXTENSION_GROUPS_TABLE . " - WHERE group_id = $group_id"; - $result = $db->sql_query($sql); - $group_name = (string) $db->sql_fetchfield('group_name'); - $db->sql_freeresult($result); - - $sql = 'DELETE - FROM ' . EXTENSION_GROUPS_TABLE . " - WHERE group_id = $group_id"; - $db->sql_query($sql); - - // Set corresponding Extensions to a pending Group - $sql = 'UPDATE ' . EXTENSIONS_TABLE . " - SET group_id = 0 - WHERE group_id = $group_id"; - $db->sql_query($sql); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ATTACH_EXTGROUP_DEL', false, array($group_name)); - - $cache->destroy('_extensions'); - - trigger_error($user->lang['EXTENSION_GROUP_DELETED'] . adm_back_link($this->u_action)); - } - else - { - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( - 'i' => $id, - 'mode' => $mode, - 'group_id' => $group_id, - 'action' => 'delete', - ))); - } - - break; - - case 'edit': - - if (!$group_id) - { - trigger_error($user->lang['NO_EXT_GROUP_SPECIFIED'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - $sql = 'SELECT * - FROM ' . EXTENSION_GROUPS_TABLE . " - WHERE group_id = $group_id"; - $result = $db->sql_query($sql); - $ext_group_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $forum_ids = (!$ext_group_row['allowed_forums']) ? array() : unserialize(trim($ext_group_row['allowed_forums'])); - - // no break; - - case 'add': - - if ($action == 'add') - { - $ext_group_row = array( - 'group_name' => $request->variable('group_name', '', true), - 'cat_id' => 0, - 'allow_group' => 1, - 'allow_in_pm' => 1, - 'upload_icon' => '', - 'max_filesize' => 0, - ); - - $forum_ids = array(); - } - - $sql = 'SELECT * - FROM ' . EXTENSIONS_TABLE . " - WHERE group_id = $group_id - OR group_id = 0 - ORDER BY extension"; - $result = $db->sql_query($sql); - $extensions = $db->sql_fetchrowset($result); - $db->sql_freeresult($result); - - if ($ext_group_row['max_filesize'] == 0) - { - $ext_group_row['max_filesize'] = (int) $config['max_filesize']; - } - - $max_filesize = get_formatted_filesize($ext_group_row['max_filesize'], false, array('mb', 'kb', 'b')); - $size_format = $max_filesize['si_identifier']; - $ext_group_row['max_filesize'] = $max_filesize['value']; - - $img_path = $config['upload_icons_path']; - - $filename_list = ''; - $no_image_select = false; - - $imglist = filelist($phpbb_root_path . $img_path); - - if (!empty($imglist[''])) - { - $imglist = array_values($imglist); - $imglist = $imglist[0]; - - foreach ($imglist as $key => $img) - { - if (!$ext_group_row['upload_icon']) - { - $no_image_select = true; - $selected = ''; - } - else - { - $selected = ($ext_group_row['upload_icon'] == $img) ? ' selected="selected"' : ''; - } - - if (strlen($img) > 255) - { - continue; - } - - $filename_list .= ''; - } - } - - $i = 0; - $assigned_extensions = ''; - foreach ($extensions as $num => $row) - { - if ($row['group_id'] == $group_id && $group_id) - { - $assigned_extensions .= ($i) ? ', ' . $row['extension'] : $row['extension']; - $i++; - } - } - - $s_extension_options = ''; - foreach ($extensions as $row) - { - $s_extension_options .= '' . $row['extension'] . ''; - } - - $template->assign_vars(array( - 'IMG_PATH' => $img_path, - 'ACTION' => $action, - 'GROUP_ID' => $group_id, - 'GROUP_NAME' => $ext_group_row['group_name'], - 'ALLOW_GROUP' => $ext_group_row['allow_group'], - 'ALLOW_IN_PM' => $ext_group_row['allow_in_pm'], - 'UPLOAD_ICON_SRC' => $phpbb_root_path . $img_path . '/' . $ext_group_row['upload_icon'], - 'EXTGROUP_FILESIZE' => $ext_group_row['max_filesize'], - 'ASSIGNED_EXTENSIONS' => $assigned_extensions, - - 'S_CATEGORY_SELECT' => $this->category_select('special_category', $group_id, 'category'), - 'S_EXT_GROUP_SIZE_OPTIONS' => size_select_options($size_format), - 'S_EXTENSION_OPTIONS' => $s_extension_options, - 'S_FILENAME_LIST' => $filename_list, - 'S_EDIT_GROUP' => true, - 'S_NO_IMAGE' => $no_image_select, - 'S_FORUM_IDS' => (count($forum_ids)) ? true : false, - - 'U_EXTENSIONS' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=$id&mode=extensions"), - 'U_BACK' => $this->u_action, - - 'L_LEGEND' => $user->lang[strtoupper($action) . '_EXTENSION_GROUP']) - ); - - $s_forum_id_options = ''; - - /** @todo use in-built function **/ - - $sql = 'SELECT forum_id, forum_name, parent_id, forum_type, left_id, right_id - FROM ' . FORUMS_TABLE . ' - ORDER BY left_id ASC'; - $result = $db->sql_query($sql, 600); - - $right = $cat_right = $padding_inc = 0; - $padding = $forum_list = $holding = ''; - $padding_store = array('0' => ''); - - while ($row = $db->sql_fetchrow($result)) - { - if ($row['forum_type'] == FORUM_CAT && ($row['left_id'] + 1 == $row['right_id'])) - { - // Non-postable forum with no subforums, don't display - continue; - } - - if (!$auth->acl_get('f_list', $row['forum_id'])) - { - // if the user does not have permissions to list this forum skip - continue; - } - - if ($row['left_id'] < $right) - { - $padding .= '   '; - $padding_store[$row['parent_id']] = $padding; - } - else if ($row['left_id'] > $right + 1) - { - $padding = empty($padding_store[$row['parent_id']]) ? '' : $padding_store[$row['parent_id']]; - } - - $right = $row['right_id']; - - $selected = (in_array($row['forum_id'], $forum_ids)) ? ' selected="selected"' : ''; - - if ($row['left_id'] > $cat_right) - { - // make sure we don't forget anything - $s_forum_id_options .= $holding; - $holding = ''; - } - - if ($row['right_id'] - $row['left_id'] > 1) - { - $cat_right = max($cat_right, $row['right_id']); - - $holding .= ''; - } - else - { - $s_forum_id_options .= $holding . ''; - $holding = ''; - } - } - - if ($holding) - { - $s_forum_id_options .= $holding; - } - - $db->sql_freeresult($result); - unset($padding_store); - - $template->assign_vars(array( - 'S_FORUM_ID_OPTIONS' => $s_forum_id_options) - ); - - break; - } - - $sql = 'SELECT * - FROM ' . EXTENSION_GROUPS_TABLE . ' - ORDER BY allow_group DESC, allow_in_pm DESC, group_name'; - $result = $db->sql_query($sql); - - $old_allow_group = $old_allow_pm = 1; - while ($row = $db->sql_fetchrow($result)) - { - $s_add_spacer = ($old_allow_group != $row['allow_group'] || $old_allow_pm != $row['allow_in_pm']) ? true : false; - - $template->assign_block_vars('groups', array( - 'S_ADD_SPACER' => $s_add_spacer, - 'S_ALLOWED_IN_PM' => ($row['allow_in_pm']) ? true : false, - 'S_GROUP_ALLOWED' => ($row['allow_group']) ? true : false, - - 'U_EDIT' => $this->u_action . "&action=edit&g={$row['group_id']}", - 'U_DELETE' => $this->u_action . "&action=delete&g={$row['group_id']}", - - 'GROUP_NAME' => $this->language->is_set('EXT_GROUP_' . utf8_strtoupper($row['group_name'])) ? $this->language->lang('EXT_GROUP_' . utf8_strtoupper($row['group_name'])) : $row['group_name'], - 'CATEGORY' => $cat_lang[$row['cat_id']], - ) - ); - - $old_allow_group = $row['allow_group']; - $old_allow_pm = $row['allow_in_pm']; - } - $db->sql_freeresult($result); - - break; - - case 'orphan': - - /* @var $pagination \phpbb\pagination */ - $pagination = $this->phpbb_container->get('pagination'); - - if ($submit) - { - $delete_files = (isset($_POST['delete'])) ? array_keys($request->variable('delete', array('' => 0))) : array(); - $add_files = (isset($_POST['add'])) ? array_keys($request->variable('add', array('' => 0))) : array(); - $post_ids = $request->variable('post_id', array('' => 0)); - - if (count($delete_files)) - { - $sql = 'SELECT * - FROM ' . ATTACHMENTS_TABLE . ' - WHERE ' . $db->sql_in_set('attach_id', $delete_files) . ' - AND is_orphan = 1'; - $result = $db->sql_query($sql); - - $delete_files = array(); - while ($row = $db->sql_fetchrow($result)) - { - $this->attachment_manager->unlink($row['physical_filename'], 'file'); - - if ($row['thumbnail']) - { - $this->attachment_manager->unlink($row['physical_filename'], 'thumbnail'); - } - - $delete_files[$row['attach_id']] = $row['real_filename']; - } - $db->sql_freeresult($result); - } - - if (count($delete_files)) - { - $sql = 'DELETE FROM ' . ATTACHMENTS_TABLE . ' - WHERE ' . $db->sql_in_set('attach_id', array_keys($delete_files)); - $db->sql_query($sql); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ATTACH_ORPHAN_DEL', false, array(implode(', ', $delete_files))); - $notify[] = sprintf($user->lang['LOG_ATTACH_ORPHAN_DEL'], implode($user->lang['COMMA_SEPARATOR'], $delete_files)); - } - - $upload_list = array(); - foreach ($add_files as $attach_id) - { - if (!isset($delete_files[$attach_id]) && !empty($post_ids[$attach_id])) - { - $upload_list[$attach_id] = $post_ids[$attach_id]; - } - } - unset($add_files); - - if (count($upload_list)) - { - $template->assign_var('S_UPLOADING_FILES', true); - - $sql = 'SELECT forum_id, forum_name - FROM ' . FORUMS_TABLE; - $result = $db->sql_query($sql); - - $forum_names = array(); - while ($row = $db->sql_fetchrow($result)) - { - $forum_names[$row['forum_id']] = $row['forum_name']; - } - $db->sql_freeresult($result); - - $sql = 'SELECT forum_id, topic_id, post_id, poster_id - FROM ' . POSTS_TABLE . ' - WHERE ' . $db->sql_in_set('post_id', $upload_list); - $result = $db->sql_query($sql); - - $post_info = array(); - while ($row = $db->sql_fetchrow($result)) - { - $post_info[$row['post_id']] = $row; - } - $db->sql_freeresult($result); - - // Select those attachments we want to change... - $sql = 'SELECT * - FROM ' . ATTACHMENTS_TABLE . ' - WHERE ' . $db->sql_in_set('attach_id', array_keys($upload_list)) . ' - AND is_orphan = 1'; - $result = $db->sql_query($sql); - - $files_added = $space_taken = 0; - while ($row = $db->sql_fetchrow($result)) - { - $post_row = $post_info[$upload_list[$row['attach_id']]]; - - $template->assign_block_vars('upload', array( - 'FILE_INFO' => sprintf($user->lang['UPLOADING_FILE_TO'], $row['real_filename'], $post_row['post_id']), - 'S_DENIED' => (!$auth->acl_get('f_attach', $post_row['forum_id'])) ? true : false, - 'L_DENIED' => (!$auth->acl_get('f_attach', $post_row['forum_id'])) ? sprintf($user->lang['UPLOAD_DENIED_FORUM'], $forum_names[$row['forum_id']]) : '') - ); - - if (!$auth->acl_get('f_attach', $post_row['forum_id'])) - { - continue; - } - - // Adjust attachment entry - $sql_ary = array( - 'in_message' => 0, - 'is_orphan' => 0, - 'poster_id' => $post_row['poster_id'], - 'post_msg_id' => $post_row['post_id'], - 'topic_id' => $post_row['topic_id'], - ); - - $sql = 'UPDATE ' . ATTACHMENTS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE attach_id = ' . $row['attach_id']; - $db->sql_query($sql); - - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET post_attachment = 1 - WHERE post_id = ' . $post_row['post_id']; - $db->sql_query($sql); - - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_attachment = 1 - WHERE topic_id = ' . $post_row['topic_id']; - $db->sql_query($sql); - - $space_taken += $row['filesize']; - $files_added++; - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ATTACH_FILEUPLOAD', false, array($post_row['post_id'], $row['real_filename'])); - } - $db->sql_freeresult($result); - - if ($files_added) - { - $config->increment('upload_dir_size', $space_taken, false); - $config->increment('num_files', $files_added, false); - } - } - } - - $template->assign_vars(array( - 'S_ORPHAN' => true) - ); - - $attachments_per_page = (int) $config['topics_per_page']; - - // Get total number or orphans older than 3 hours - $sql = 'SELECT COUNT(attach_id) as num_files, SUM(filesize) as total_size - FROM ' . ATTACHMENTS_TABLE . ' - WHERE is_orphan = 1 - AND filetime < ' . (time() - 3*60*60); - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $num_files = (int) $row['num_files']; - $total_size = (int) $row['total_size']; - $this->db->sql_freeresult($result); - - $start = $request->variable('start', 0); - $start = $pagination->validate_start($start, $attachments_per_page, $num_files); - - // Just get the files with is_orphan set and older than 3 hours - $sql = 'SELECT * - FROM ' . ATTACHMENTS_TABLE . ' - WHERE is_orphan = 1 - AND filetime < ' . (time() - 3*60*60) . ' - ORDER BY filetime DESC'; - $result = $db->sql_query_limit($sql, $attachments_per_page, $start); - - while ($row = $db->sql_fetchrow($result)) - { - $template->assign_block_vars('orphan', array( - 'FILESIZE' => get_formatted_filesize($row['filesize']), - 'FILETIME' => $user->format_date($row['filetime']), - 'REAL_FILENAME' => utf8_basename($row['real_filename']), - 'PHYSICAL_FILENAME' => utf8_basename($row['physical_filename']), - 'ATTACH_ID' => $row['attach_id'], - 'POST_IDS' => (!empty($post_ids[$row['attach_id']])) ? $post_ids[$row['attach_id']] : '', - 'U_FILE' => append_sid($phpbb_root_path . 'download/file.' . $phpEx, 'mode=view&id=' . $row['attach_id'])) - ); - } - $db->sql_freeresult($result); - - $pagination->generate_template_pagination( - $this->u_action, - 'pagination', - 'start', - $num_files, - $attachments_per_page, - $start - ); - - $template->assign_vars(array( - 'TOTAL_FILES' => $num_files, - 'TOTAL_SIZE' => get_formatted_filesize($total_size), - )); - - break; - - case 'manage': - - if ($submit) - { - $delete_files = (isset($_POST['delete'])) ? array_keys($request->variable('delete', array('' => 0))) : array(); - - if (count($delete_files)) - { - // Select those attachments we want to delete... - $sql = 'SELECT real_filename - FROM ' . ATTACHMENTS_TABLE . ' - WHERE ' . $db->sql_in_set('attach_id', $delete_files) . ' - AND is_orphan = 0'; - $result = $db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) - { - $deleted_filenames[] = $row['real_filename']; - } - $db->sql_freeresult($result); - - if ($num_deleted = $this->attachment_manager->delete('attach', $delete_files)) - { - if (count($delete_files) != $num_deleted) - { - $error[] = $user->lang['FILES_GONE']; - } - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ATTACHMENTS_DELETED', false, array(implode(', ', $deleted_filenames))); - $notify[] = sprintf($user->lang['LOG_ATTACHMENTS_DELETED'], implode($user->lang['COMMA_SEPARATOR'], $deleted_filenames)); - } - else - { - $error[] = $user->lang['NO_FILES_TO_DELETE']; - } - } - } - - if ($action == 'stats') - { - $this->handle_stats_resync(); - } - - $stats_error = $this->check_stats_accuracy(); - - if ($stats_error) - { - $error[] = $stats_error; - } - - $template->assign_vars(array( - 'S_MANAGE' => true, - )); - - $start = $request->variable('start', 0); - - // Sort keys - $sort_days = $request->variable('st', 0); - $sort_key = $request->variable('sk', 't'); - $sort_dir = $request->variable('sd', 'd'); - - // Sorting - $limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); - $sort_by_text = array('f' => $user->lang['FILENAME'], 't' => $user->lang['FILEDATE'], 's' => $user->lang['FILESIZE'], 'x' => $user->lang['EXTENSION'], 'd' => $user->lang['DOWNLOADS'],'p' => $user->lang['ATTACH_POST_TYPE'], 'u' => $user->lang['AUTHOR']); - $sort_by_sql = array('f' => 'a.real_filename', 't' => 'a.filetime', 's' => 'a.filesize', 'x' => 'a.extension', 'd' => 'a.download_count', 'p' => 'a.in_message', 'u' => 'u.username'); - - $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; - gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); - - $min_filetime = ($sort_days) ? (time() - ($sort_days * 86400)) : ''; - $limit_filetime = ($min_filetime) ? " AND a.filetime >= $min_filetime " : ''; - $start = ($sort_days && isset($_POST['sort'])) ? 0 : $start; - - $attachments_per_page = (int) $config['topics_per_page']; - - $stats = $this->get_attachment_stats($limit_filetime); - $num_files = $stats['num_files']; - $total_size = $stats['upload_dir_size']; - - // Make sure $start is set to the last page if it exceeds the amount - /* @var $pagination \phpbb\pagination */ - $pagination = $phpbb_container->get('pagination'); - $start = $pagination->validate_start($start, $attachments_per_page, $num_files); - - // If the user is trying to reach the second half of the attachments list, fetch it starting from the end - $store_reverse = false; - $sql_limit = $attachments_per_page; - - if ($start > $num_files / 2) - { - $store_reverse = true; - - // Select the sort order. Add time sort anchor for non-time sorting cases - $sql_sort_anchor = ($sort_key != 't') ? ', a.filetime ' . (($sort_dir == 'd') ? 'ASC' : 'DESC') : ''; - $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'ASC' : 'DESC') . $sql_sort_anchor; - $sql_limit = $pagination->reverse_limit($start, $sql_limit, $num_files); - $sql_start = $pagination->reverse_start($start, $sql_limit, $num_files); - } - else - { - // Select the sort order. Add time sort anchor for non-time sorting cases - $sql_sort_anchor = ($sort_key != 't') ? ', a.filetime ' . (($sort_dir == 'd') ? 'DESC' : 'ASC') : ''; - $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC') . $sql_sort_anchor; - $sql_start = $start; - } - - $attachments_list = array(); - - // Just get the files - $sql = 'SELECT a.*, u.username, u.user_colour, t.topic_title - FROM ' . ATTACHMENTS_TABLE . ' a - LEFT JOIN ' . USERS_TABLE . ' u ON (u.user_id = a.poster_id) - LEFT JOIN ' . TOPICS_TABLE . " t ON (a.topic_id = t.topic_id) - WHERE a.is_orphan = 0 - $limit_filetime - ORDER BY $sql_sort_order"; - $result = $db->sql_query_limit($sql, $sql_limit, $sql_start); - - $i = ($store_reverse) ? $sql_limit - 1 : 0; - - // Store increment value in a variable to save some conditional calls - $i_increment = ($store_reverse) ? -1 : 1; - while ($attachment_row = $db->sql_fetchrow($result)) - { - $attachments_list[$i] = $attachment_row; - $i = $i + $i_increment; - } - $db->sql_freeresult($result); - - $base_url = $this->u_action . "&$u_sort_param"; - $pagination->generate_template_pagination($base_url, 'pagination', 'start', $num_files, $attachments_per_page, $start); - - $template->assign_vars(array( - 'TOTAL_FILES' => $num_files, - 'TOTAL_SIZE' => get_formatted_filesize($total_size), - - 'S_LIMIT_DAYS' => $s_limit_days, - 'S_SORT_KEY' => $s_sort_key, - 'S_SORT_DIR' => $s_sort_dir) - ); - - // Grab extensions - $extensions = $cache->obtain_attach_extensions(true); - - for ($i = 0, $end = count($attachments_list); $i < $end; ++$i) - { - $row = $attachments_list[$i]; - - $row['extension'] = strtolower(trim((string) $row['extension'])); - $comment = ($row['attach_comment'] && !$row['in_message']) ? str_replace(array("\n", "\r"), array('
', "\n"), $row['attach_comment']) : ''; - $display_cat = isset($extensions[$row['extension']]['display_cat']) ? $extensions[$row['extension']]['display_cat'] : ATTACHMENT_CATEGORY_NONE; - $l_downloaded_viewed = ($display_cat == ATTACHMENT_CATEGORY_NONE) ? 'DOWNLOAD_COUNTS' : 'VIEWED_COUNTS'; - - $template->assign_block_vars('attachments', array( - 'ATTACHMENT_POSTER' => get_username_string('full', (int) $row['poster_id'], (string) $row['username'], (string) $row['user_colour'], (string) $row['username']), - 'FILESIZE' => get_formatted_filesize((int) $row['filesize']), - 'FILETIME' => $user->format_date((int) $row['filetime']), - 'REAL_FILENAME' => utf8_basename((string) $row['real_filename']), - 'EXT_GROUP_NAME' => $this->language->is_set('EXT_GROUP_' . utf8_strtoupper($extensions[$row['extension']]['group_name'])) ? $this->language->lang('EXT_GROUP_' . utf8_strtoupper($extensions[$row['extension']]['group_name'])) : $extensions[$row['extension']]['group_name'], - 'COMMENT' => $comment, - 'TOPIC_TITLE' => (!$row['in_message']) ? (string) $row['topic_title'] : '', - 'ATTACH_ID' => (int) $row['attach_id'], - - 'L_DOWNLOAD_COUNT' => $user->lang($l_downloaded_viewed, (int) $row['download_count']), - - 'S_IN_MESSAGE' => (bool) $row['in_message'], - - 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t={$row['topic_id']}&p={$row['post_msg_id']}") . "#p{$row['post_msg_id']}", - 'U_FILE' => append_sid($phpbb_root_path . 'download/file.' . $phpEx, 'mode=view&id=' . $row['attach_id'])) - ); - } - - break; - } - - if (count($error)) - { - $template->assign_vars(array( - 'S_WARNING' => true, - 'WARNING_MSG' => implode('
', $error)) - ); - } - - if (count($notify)) - { - $template->assign_vars(array( - 'S_NOTIFY' => true, - 'NOTIFY_MSG' => implode('
', $notify)) - ); - } - } - - /** - * Get attachment file count and size of upload directory - * - * @param $limit string Additional limit for WHERE clause to filter stats by. - * @return array Returns array with stats: num_files and upload_dir_size - */ - public function get_attachment_stats($limit = '') - { - $sql = 'SELECT COUNT(a.attach_id) AS num_files, SUM(a.filesize) AS upload_dir_size - FROM ' . ATTACHMENTS_TABLE . " a - WHERE a.is_orphan = 0 - $limit"; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - return array( - 'num_files' => (int) $row['num_files'], - 'upload_dir_size' => (float) $row['upload_dir_size'], - ); - } - - /** - * Set config attachment stat values - * - * @param $stats array Array of config key => value pairs to set. - * @return null - */ - public function set_attachment_stats($stats) - { - foreach ($stats as $key => $value) - { - $this->config->set($key, $value, true); - } - } - - /** - * Check accuracy of attachment statistics. - * - * @return bool|string Returns false if stats are correct or error message - * otherwise. - */ - public function check_stats_accuracy() - { - // Get fresh stats. - $stats = $this->get_attachment_stats(); - - // Get current files stats - $num_files = (int) $this->config['num_files']; - $total_size = (float) $this->config['upload_dir_size']; - - if (($num_files != $stats['num_files']) || ($total_size != $stats['upload_dir_size'])) - { - $u_resync = $this->u_action . '&action=stats'; - - return $this->user->lang( - 'FILES_STATS_WRONG', - (int) $stats['num_files'], - get_formatted_filesize($stats['upload_dir_size']), - '', - '' - ); - } - return false; - } - - /** - * Handle stats resync. - * - * @return null - */ - public function handle_stats_resync() - { - if (!confirm_box(true)) - { - confirm_box(false, $this->user->lang['RESYNC_FILES_STATS_CONFIRM'], build_hidden_fields(array( - 'i' => $this->id, - 'mode' => 'manage', - 'action' => 'stats', - ))); - } - else - { - $this->set_attachment_stats($this->get_attachment_stats()); - - /* @var $log \phpbb\log\log_interface */ - $log = $this->phpbb_container->get('log'); - $log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_RESYNC_FILES_STATS'); - } - - } - - /** - * Build Select for category items - */ - function category_select($select_name, $group_id = false, $key = '') - { - global $db, $user; - - $types = array( - ATTACHMENT_CATEGORY_NONE => $user->lang['NO_FILE_CAT'], - ATTACHMENT_CATEGORY_IMAGE => $user->lang['CAT_IMAGES'], - ); - - if ($group_id) - { - $sql = 'SELECT cat_id - FROM ' . EXTENSION_GROUPS_TABLE . ' - WHERE group_id = ' . (int) $group_id; - $result = $db->sql_query($sql); - - $cat_type = (!($row = $db->sql_fetchrow($result))) ? ATTACHMENT_CATEGORY_NONE : $row['cat_id']; - - $db->sql_freeresult($result); - } - else - { - $cat_type = ATTACHMENT_CATEGORY_NONE; - } - - $group_select = ''; - - return $group_select; - } - - /** - * Extension group select - */ - function group_select($select_name, $default_group = false, $key = '') - { - global $db, $user; - - $group_select = ''; - - return $group_select; - } - - /** - * Test Settings - */ - function test_upload(&$error, $upload_dir, $create_directory = false) - { - global $user, $phpbb_root_path; - - // Does the target directory exist, is it a directory and writable. - if ($create_directory) - { - if (!file_exists($phpbb_root_path . $upload_dir)) - { - @mkdir($phpbb_root_path . $upload_dir, 0777); - - try - { - $this->filesystem->phpbb_chmod($phpbb_root_path . $upload_dir, CHMOD_READ | CHMOD_WRITE); - } - catch (\phpbb\filesystem\exception\filesystem_exception $e) - { - // Do nothing - } - } - } - - if (!file_exists($phpbb_root_path . $upload_dir)) - { - $error[] = sprintf($user->lang['NO_UPLOAD_DIR'], $upload_dir); - return; - } - - if (!is_dir($phpbb_root_path . $upload_dir)) - { - $error[] = sprintf($user->lang['UPLOAD_NOT_DIR'], $upload_dir); - return; - } - - if (!$this->filesystem->is_writable($phpbb_root_path . $upload_dir)) - { - $error[] = sprintf($user->lang['NO_WRITE_UPLOAD'], $upload_dir); - return; - } - } - - /** - * Perform operations on sites for external linking - */ - function perform_site_list() - { - global $db, $user, $request, $phpbb_log; - - if (isset($_REQUEST['securesubmit'])) - { - // Grab the list of entries - $ips = $request->variable('ips', ''); - $ip_list = array_unique(explode("\n", $ips)); - $ip_list_log = implode(', ', $ip_list); - - $ip_exclude = (int) $request->variable('ipexclude', false, false, \phpbb\request\request_interface::POST); - - $iplist = array(); - $hostlist = array(); - - foreach ($ip_list as $item) - { - if (preg_match('#^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})[ ]*\-[ ]*([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$#', trim($item), $ip_range_explode)) - { - // Don't ask about all this, just don't ask ... ! - $ip_1_counter = $ip_range_explode[1]; - $ip_1_end = $ip_range_explode[5]; - - while ($ip_1_counter <= $ip_1_end) - { - $ip_2_counter = ($ip_1_counter == $ip_range_explode[1]) ? $ip_range_explode[2] : 0; - $ip_2_end = ($ip_1_counter < $ip_1_end) ? 254 : $ip_range_explode[6]; - - if ($ip_2_counter == 0 && $ip_2_end == 254) - { - $ip_2_counter = 256; - - $iplist[] = "'$ip_1_counter.*'"; - } - - while ($ip_2_counter <= $ip_2_end) - { - $ip_3_counter = ($ip_2_counter == $ip_range_explode[2] && $ip_1_counter == $ip_range_explode[1]) ? $ip_range_explode[3] : 0; - $ip_3_end = ($ip_2_counter < $ip_2_end || $ip_1_counter < $ip_1_end) ? 254 : $ip_range_explode[7]; - - if ($ip_3_counter == 0 && $ip_3_end == 254) - { - $ip_3_counter = 256; - - $iplist[] = "'$ip_1_counter.$ip_2_counter.*'"; - } - - while ($ip_3_counter <= $ip_3_end) - { - $ip_4_counter = ($ip_3_counter == $ip_range_explode[3] && $ip_2_counter == $ip_range_explode[2] && $ip_1_counter == $ip_range_explode[1]) ? $ip_range_explode[4] : 0; - $ip_4_end = ($ip_3_counter < $ip_3_end || $ip_2_counter < $ip_2_end) ? 254 : $ip_range_explode[8]; - - if ($ip_4_counter == 0 && $ip_4_end == 254) - { - $ip_4_counter = 256; - - $iplist[] = "'$ip_1_counter.$ip_2_counter.$ip_3_counter.*'"; - } - - while ($ip_4_counter <= $ip_4_end) - { - $iplist[] = "'$ip_1_counter.$ip_2_counter.$ip_3_counter.$ip_4_counter'"; - $ip_4_counter++; - } - $ip_3_counter++; - } - $ip_2_counter++; - } - $ip_1_counter++; - } - } - else if (preg_match('#^([0-9]{1,3})\.([0-9\*]{1,3})\.([0-9\*]{1,3})\.([0-9\*]{1,3})$#', trim($item)) || preg_match('#^[a-f0-9:]+\*?$#i', trim($item))) - { - $iplist[] = "'" . trim($item) . "'"; - } - else if (preg_match('#^([\w\-_]\.?){2,}$#is', trim($item))) - { - $hostlist[] = "'" . trim($item) . "'"; - } - else if (preg_match("#^([a-z0-9\-\*\._/]+?)$#is", trim($item))) - { - $hostlist[] = "'" . trim($item) . "'"; - } - } - - $sql = 'SELECT site_ip, site_hostname - FROM ' . SITELIST_TABLE . " - WHERE ip_exclude = $ip_exclude"; - $result = $db->sql_query($sql); - - if ($row = $db->sql_fetchrow($result)) - { - $iplist_tmp = array(); - $hostlist_tmp = array(); - do - { - if ($row['site_ip']) - { - if (strlen($row['site_ip']) > 40) - { - continue; - } - - $iplist_tmp[] = "'" . $row['site_ip'] . "'"; - } - else if ($row['site_hostname']) - { - if (strlen($row['site_hostname']) > 255) - { - continue; - } - - $hostlist_tmp[] = "'" . $row['site_hostname'] . "'"; - } - // break; - } - while ($row = $db->sql_fetchrow($result)); - - $iplist = array_unique(array_diff($iplist, $iplist_tmp)); - $hostlist = array_unique(array_diff($hostlist, $hostlist_tmp)); - unset($iplist_tmp); - unset($hostlist_tmp); - } - $db->sql_freeresult($result); - - if (count($iplist)) - { - foreach ($iplist as $ip_entry) - { - $sql = 'INSERT INTO ' . SITELIST_TABLE . " (site_ip, ip_exclude) - VALUES ($ip_entry, $ip_exclude)"; - $db->sql_query($sql); - } - } - - if (count($hostlist)) - { - foreach ($hostlist as $host_entry) - { - $sql = 'INSERT INTO ' . SITELIST_TABLE . " (site_hostname, ip_exclude) - VALUES ($host_entry, $ip_exclude)"; - $db->sql_query($sql); - } - } - - if (!empty($ip_list_log)) - { - // Update log - $log_entry = ($ip_exclude) ? 'LOG_DOWNLOAD_EXCLUDE_IP' : 'LOG_DOWNLOAD_IP'; - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, $log_entry, false, array($ip_list_log)); - } - - trigger_error($user->lang['SECURE_DOWNLOAD_UPDATE_SUCCESS'] . adm_back_link($this->u_action)); - } - else if (isset($_POST['unsecuresubmit'])) - { - $unip_sql = $request->variable('unip', array(0)); - - if (count($unip_sql)) - { - $l_unip_list = ''; - - // Grab details of ips for logging information later - $sql = 'SELECT site_ip, site_hostname - FROM ' . SITELIST_TABLE . ' - WHERE ' . $db->sql_in_set('site_id', $unip_sql); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $l_unip_list .= (($l_unip_list != '') ? ', ' : '') . (($row['site_ip']) ? $row['site_ip'] : $row['site_hostname']); - } - $db->sql_freeresult($result); - - $sql = 'DELETE FROM ' . SITELIST_TABLE . ' - WHERE ' . $db->sql_in_set('site_id', $unip_sql); - $db->sql_query($sql); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_DOWNLOAD_REMOVE_IP', false, array($l_unip_list)); - } - - trigger_error($user->lang['SECURE_DOWNLOAD_UPDATE_SUCCESS'] . adm_back_link($this->u_action)); - } - } - - /** - * Write display_order config field - */ - function display_order($value, $key = '') - { - $radio_ary = array(0 => 'DESCENDING', 1 => 'ASCENDING'); - - return h_radio('config[display_order]', $radio_ary, $value, $key); - } - - /** - * Adjust all three max_filesize config vars for display - */ - function max_filesize($value, $key = '') - { - // Determine size var and adjust the value accordingly - $filesize = get_formatted_filesize($value, false, array('mb', 'kb', 'b')); - $size_var = $filesize['si_identifier']; - $value = $filesize['value']; - - // size and maxlength must not be specified for input of type number - return ' '; - } - - /** - * Write secure_allow_deny config field - */ - function select_allow_deny($value, $key = '') - { - $radio_ary = array(1 => 'ORDER_ALLOW_DENY', 0 => 'ORDER_DENY_ALLOW'); - - return h_radio('config[' . $key . ']', $radio_ary, $value, $key); - } - -} diff --git a/install/update/new/includes/acp/acp_bbcodes.php b/install/update/new/includes/acp/acp_bbcodes.php deleted file mode 100644 index 5e39055..0000000 --- a/install/update/new/includes/acp/acp_bbcodes.php +++ /dev/null @@ -1,480 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -class acp_bbcodes -{ - var $u_action; - - function main($id, $mode) - { - global $db, $user, $template, $cache, $request, $phpbb_dispatcher, $phpbb_container; - global $phpbb_log; - - $user->add_lang('acp/posting'); - - // Set up general vars - $action = $request->variable('action', ''); - $bbcode_id = $request->variable('bbcode', 0); - - $this->tpl_name = 'acp_bbcodes'; - $this->page_title = 'ACP_BBCODES'; - $form_key = 'acp_bbcodes'; - - add_form_key($form_key); - - // Set up mode-specific vars - switch ($action) - { - case 'add': - $bbcode_match = $bbcode_tpl = $bbcode_helpline = ''; - $display_on_posting = 0; - break; - - case 'edit': - $sql = 'SELECT bbcode_match, bbcode_tpl, display_on_posting, bbcode_helpline - FROM ' . BBCODES_TABLE . ' - WHERE bbcode_id = ' . $bbcode_id; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - trigger_error($user->lang['BBCODE_NOT_EXIST'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - $bbcode_match = $row['bbcode_match']; - $bbcode_tpl = htmlspecialchars($row['bbcode_tpl']); - $display_on_posting = $row['display_on_posting']; - $bbcode_helpline = $row['bbcode_helpline']; - break; - - case 'modify': - $sql = 'SELECT bbcode_id, bbcode_tag - FROM ' . BBCODES_TABLE . ' - WHERE bbcode_id = ' . $bbcode_id; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - trigger_error($user->lang['BBCODE_NOT_EXIST'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - // No break here - - case 'create': - $display_on_posting = $request->variable('display_on_posting', 0); - - $bbcode_match = $request->variable('bbcode_match', ''); - $bbcode_tpl = htmlspecialchars_decode($request->variable('bbcode_tpl', '', true)); - $bbcode_helpline = $request->variable('bbcode_helpline', '', true); - break; - } - - // Do major work - switch ($action) - { - case 'edit': - case 'add': - - $tpl_ary = array( - 'S_EDIT_BBCODE' => true, - 'U_BACK' => $this->u_action, - 'U_ACTION' => $this->u_action . '&action=' . (($action == 'add') ? 'create' : 'modify') . (($bbcode_id) ? "&bbcode=$bbcode_id" : ''), - - 'L_BBCODE_USAGE_EXPLAIN'=> sprintf($user->lang['BBCODE_USAGE_EXPLAIN'], '', ''), - 'BBCODE_MATCH' => $bbcode_match, - 'BBCODE_TPL' => $bbcode_tpl, - 'BBCODE_HELPLINE' => $bbcode_helpline, - 'DISPLAY_ON_POSTING' => $display_on_posting, - ); - - $bbcode_tokens = array('TEXT', 'SIMPLETEXT', 'INTTEXT', 'IDENTIFIER', 'NUMBER', 'EMAIL', 'URL', 'LOCAL_URL', 'RELATIVE_URL', 'COLOR'); - - /** - * Modify custom bbcode template data before we display the add/edit form - * - * @event core.acp_bbcodes_edit_add - * @var string action Type of the action: add|edit - * @var array tpl_ary Array with custom bbcode add/edit data - * @var int bbcode_id When editing: the bbcode id, - * when creating: 0 - * @var array bbcode_tokens Array of bbcode tokens - * @since 3.1.0-a3 - */ - $vars = array('action', 'tpl_ary', 'bbcode_id', 'bbcode_tokens'); - extract($phpbb_dispatcher->trigger_event('core.acp_bbcodes_edit_add', compact($vars))); - - $template->assign_vars($tpl_ary); - - foreach ($bbcode_tokens as $token) - { - $template->assign_block_vars('token', array( - 'TOKEN' => '{' . $token . '}', - 'EXPLAIN' => ($token === 'LOCAL_URL') ? $user->lang(array('tokens', $token), generate_board_url() . '/') : $user->lang(array('tokens', $token)), - )); - } - - return; - - break; - - case 'modify': - case 'create': - - $sql_ary = $hidden_fields = array(); - - /** - * Modify custom bbcode data before the modify/create action - * - * @event core.acp_bbcodes_modify_create - * @var string action Type of the action: modify|create - * @var array sql_ary Array with new bbcode data - * @var int bbcode_id When editing: the bbcode id, - * when creating: 0 - * @var bool display_on_posting Display bbcode on posting form - * @var string bbcode_match The bbcode usage string to match - * @var string bbcode_tpl The bbcode HTML replacement string - * @var string bbcode_helpline The bbcode help line string - * @var array hidden_fields Array of hidden fields for use when - * submitting form when $warn_unsafe is true - * @since 3.1.0-a3 - */ - $vars = array( - 'action', - 'sql_ary', - 'bbcode_id', - 'display_on_posting', - 'bbcode_match', - 'bbcode_tpl', - 'bbcode_helpline', - 'hidden_fields', - ); - extract($phpbb_dispatcher->trigger_event('core.acp_bbcodes_modify_create', compact($vars))); - - $acp_utils = $phpbb_container->get('text_formatter.acp_utils'); - $bbcode_info = $acp_utils->analyse_bbcode($bbcode_match, $bbcode_tpl); - $warn_unsafe = ($bbcode_info['status'] === $acp_utils::BBCODE_STATUS_UNSAFE); - - if ($bbcode_info['status'] === $acp_utils::BBCODE_STATUS_INVALID_TEMPLATE) - { - trigger_error($user->lang['BBCODE_INVALID_TEMPLATE'] . adm_back_link($this->u_action), E_USER_WARNING); - } - if ($bbcode_info['status'] === $acp_utils::BBCODE_STATUS_INVALID_DEFINITION) - { - trigger_error($user->lang['BBCODE_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - if (!$warn_unsafe && !check_form_key($form_key)) - { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - if (!$warn_unsafe || confirm_box(true)) - { - $data = $this->build_regexp($bbcode_match, $bbcode_tpl); - - // Make sure the user didn't pick a "bad" name for the BBCode tag. - $hard_coded = array('code', 'quote', 'quote=', 'attachment', 'attachment=', 'b', 'i', 'url', 'url=', 'img', 'size', 'size=', 'color', 'color=', 'u', 'list', 'list=', 'email', 'email=', 'flash', 'flash='); - - if (($action == 'modify' && strtolower($data['bbcode_tag']) !== strtolower($row['bbcode_tag'])) || ($action == 'create')) - { - $sql = 'SELECT 1 as test - FROM ' . BBCODES_TABLE . " - WHERE LOWER(bbcode_tag) = '" . $db->sql_escape(strtolower($data['bbcode_tag'])) . "'"; - $result = $db->sql_query($sql); - $info = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - // Grab the end, interrogate the last closing tag - if (isset($info['test']) && $info['test'] === '1' - || in_array(strtolower($data['bbcode_tag']), $hard_coded) - || (preg_match('#\[/([^[]*)]$#', $bbcode_match, $regs) && in_array(strtolower($regs[1]), $hard_coded)) - ) - { - trigger_error($user->lang['BBCODE_INVALID_TAG_NAME'] . adm_back_link($this->u_action), E_USER_WARNING); - } - } - - if (substr($data['bbcode_tag'], -1) === '=') - { - $test = substr($data['bbcode_tag'], 0, -1); - } - else - { - $test = $data['bbcode_tag']; - } - - if (strlen($data['bbcode_tag']) > 16) - { - trigger_error($user->lang['BBCODE_TAG_TOO_LONG'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - if (strlen($bbcode_match) > 4000) - { - trigger_error($user->lang['BBCODE_TAG_DEF_TOO_LONG'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - if (strlen($bbcode_helpline) > 255) - { - trigger_error($user->lang['BBCODE_HELPLINE_TOO_LONG'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - $sql_ary = array_merge($sql_ary, array( - 'bbcode_tag' => $data['bbcode_tag'], - 'bbcode_match' => $bbcode_match, - 'bbcode_tpl' => $bbcode_tpl, - 'display_on_posting' => $display_on_posting, - 'bbcode_helpline' => $bbcode_helpline, - 'first_pass_match' => $data['first_pass_match'], - 'first_pass_replace' => $data['first_pass_replace'], - 'second_pass_match' => $data['second_pass_match'], - 'second_pass_replace' => $data['second_pass_replace'] - )); - - if ($action == 'create') - { - $sql = 'SELECT MAX(bbcode_id) as max_bbcode_id - FROM ' . BBCODES_TABLE; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - $bbcode_id = (int) $row['max_bbcode_id'] + 1; - - // Make sure it is greater than the core bbcode ids... - if ($bbcode_id <= NUM_CORE_BBCODES) - { - $bbcode_id = NUM_CORE_BBCODES + 1; - } - } - else - { - $bbcode_id = NUM_CORE_BBCODES + 1; - } - - if ($bbcode_id > BBCODE_LIMIT) - { - trigger_error($user->lang['TOO_MANY_BBCODES'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - $sql_ary['bbcode_id'] = (int) $bbcode_id; - - $db->sql_query('INSERT INTO ' . BBCODES_TABLE . $db->sql_build_array('INSERT', $sql_ary)); - $cache->destroy('sql', BBCODES_TABLE); - $phpbb_container->get('text_formatter.cache')->invalidate(); - - $lang = 'BBCODE_ADDED'; - $log_action = 'LOG_BBCODE_ADD'; - } - else - { - $sql = 'UPDATE ' . BBCODES_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE bbcode_id = ' . $bbcode_id; - $db->sql_query($sql); - $cache->destroy('sql', BBCODES_TABLE); - $phpbb_container->get('text_formatter.cache')->invalidate(); - - $lang = 'BBCODE_EDITED'; - $log_action = 'LOG_BBCODE_EDIT'; - } - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, $log_action, false, array($data['bbcode_tag'])); - - /** - * Event after a BBCode has been added or updated - * - * @event core.acp_bbcodes_modify_create_after - * @var string action Type of the action: modify|create - * @var int bbcode_id The id of the added or updated bbcode - * @var array sql_ary Array with bbcode data (read only) - * @since 3.2.4-RC1 - */ - $vars = array( - 'action', - 'bbcode_id', - 'sql_ary', - ); - extract($phpbb_dispatcher->trigger_event('core.acp_bbcodes_modify_create_after', compact($vars))); - - trigger_error($user->lang[$lang] . adm_back_link($this->u_action)); - } - else - { - confirm_box(false, $user->lang['BBCODE_DANGER'], build_hidden_fields(array_merge($hidden_fields, array( - 'action' => $action, - 'bbcode' => $bbcode_id, - 'bbcode_match' => $bbcode_match, - 'bbcode_tpl' => htmlspecialchars($bbcode_tpl), - 'bbcode_helpline' => $bbcode_helpline, - 'display_on_posting' => $display_on_posting, - ))) - , 'confirm_bbcode.html'); - } - - break; - - case 'delete': - - $sql = 'SELECT bbcode_tag - FROM ' . BBCODES_TABLE . " - WHERE bbcode_id = $bbcode_id"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - if (confirm_box(true)) - { - $bbcode_tag = $row['bbcode_tag']; - - $db->sql_query('DELETE FROM ' . BBCODES_TABLE . " WHERE bbcode_id = $bbcode_id"); - $cache->destroy('sql', BBCODES_TABLE); - $phpbb_container->get('text_formatter.cache')->invalidate(); - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_BBCODE_DELETE', false, array($bbcode_tag)); - - /** - * Event after a BBCode has been deleted - * - * @event core.acp_bbcodes_delete_after - * @var string action Type of the action: delete - * @var int bbcode_id The id of the deleted bbcode - * @var string bbcode_tag The tag of the deleted bbcode - * @since 3.2.4-RC1 - */ - $vars = array( - 'action', - 'bbcode_id', - 'bbcode_tag', - ); - extract($phpbb_dispatcher->trigger_event('core.acp_bbcodes_delete_after', compact($vars))); - - if ($request->is_ajax()) - { - $json_response = new \phpbb\json_response; - $json_response->send(array( - 'MESSAGE_TITLE' => $user->lang['INFORMATION'], - 'MESSAGE_TEXT' => $user->lang['BBCODE_DELETED'], - 'REFRESH_DATA' => array( - 'time' => 3 - ) - )); - } - } - else - { - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( - 'bbcode' => $bbcode_id, - 'i' => $id, - 'mode' => $mode, - 'action' => $action)) - ); - } - } - - break; - } - - $u_action = $this->u_action; - - $template_data = array( - 'U_ACTION' => $this->u_action . '&action=add', - ); - - $sql_ary = array( - 'SELECT' => 'b.*', - 'FROM' => array(BBCODES_TABLE => 'b'), - 'ORDER_BY' => 'b.bbcode_tag', - ); - - /** - * Modify custom bbcode template data before we display the form - * - * @event core.acp_bbcodes_display_form - * @var string action Type of the action: modify|create - * @var array sql_ary The SQL array to get custom bbcode data - * @var array template_data Array with form template data - * @var string u_action The u_action link - * @since 3.1.0-a3 - */ - $vars = array('action', 'sql_ary', 'template_data', 'u_action'); - extract($phpbb_dispatcher->trigger_event('core.acp_bbcodes_display_form', compact($vars))); - - $result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary)); - - $template->assign_vars($template_data); - - while ($row = $db->sql_fetchrow($result)) - { - $bbcodes_array = array( - 'BBCODE_TAG' => $row['bbcode_tag'], - 'U_EDIT' => $u_action . '&action=edit&bbcode=' . $row['bbcode_id'], - 'U_DELETE' => $u_action . '&action=delete&bbcode=' . $row['bbcode_id'], - ); - - /** - * Modify display of custom bbcodes in the form - * - * @event core.acp_bbcodes_display_bbcodes - * @var array row Array with current bbcode data - * @var array bbcodes_array Array of bbcodes template data - * @var string u_action The u_action link - * @since 3.1.0-a3 - */ - $vars = array('bbcodes_array', 'row', 'u_action'); - extract($phpbb_dispatcher->trigger_event('core.acp_bbcodes_display_bbcodes', compact($vars))); - - $template->assign_block_vars('bbcodes', $bbcodes_array); - - } - $db->sql_freeresult($result); - } - - /* - * Build regular expression for custom bbcode - */ - function build_regexp(&$bbcode_match, &$bbcode_tpl) - { - $bbcode_match = trim($bbcode_match); - $bbcode_tag = preg_replace('/.*?\[([a-z0-9_-]+).*/i', '$1', $bbcode_match); - - if (!preg_match('/^[a-zA-Z0-9_-]+$/', $bbcode_tag)) - { - global $user; - trigger_error($user->lang['BBCODE_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - return array( - 'bbcode_tag' => $bbcode_tag, - 'first_pass_match' => '/(?!)/', - 'first_pass_replace' => '', - // Use a non-matching, valid regexp to effectively disable this BBCode - 'second_pass_match' => '/(?!)/', - 'second_pass_replace' => '' - ); - } -} diff --git a/install/update/new/includes/acp/acp_board.php b/install/update/new/includes/acp/acp_board.php deleted file mode 100644 index cd72a87..0000000 --- a/install/update/new/includes/acp/acp_board.php +++ /dev/null @@ -1,1172 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @todo add cron intervals to server settings? (database_gc, queue_interval, session_gc, search_gc, cache_gc, warnings_gc) -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -class acp_board -{ - var $u_action; - var $new_config; - - function main($id, $mode) - { - global $user, $template, $request, $language; - global $config, $phpbb_root_path, $phpEx; - global $cache, $phpbb_container, $phpbb_dispatcher, $phpbb_log; - - /** @var \phpbb\language\language $language Language object */ - $language = $phpbb_container->get('language'); - - $user->add_lang('acp/board'); - - $submit = (isset($_POST['submit']) || isset($_POST['allow_quick_reply_enable'])) ? true : false; - - $form_key = 'acp_board'; - add_form_key($form_key); - - /** - * Validation types are: - * string, int, bool, - * script_path (absolute path in url - beginning with / and no trailing slash), - * rpath (relative), rwpath (realtive, writable), path (relative path, but able to escape the root), wpath (writable) - */ - switch ($mode) - { - case 'settings': - $display_vars = array( - 'title' => 'ACP_BOARD_SETTINGS', - 'vars' => array( - 'legend1' => 'ACP_BOARD_SETTINGS', - 'sitename' => array('lang' => 'SITE_NAME', 'validate' => 'string', 'type' => 'text:40:255', 'explain' => false), - 'site_desc' => array('lang' => 'SITE_DESC', 'validate' => 'string', 'type' => 'text:40:255', 'explain' => false), - 'site_home_url' => array('lang' => 'SITE_HOME_URL', 'validate' => 'url', 'type' => 'url:40:255', 'explain' => true), - 'site_home_text' => array('lang' => 'SITE_HOME_TEXT', 'validate' => 'string', 'type' => 'text:40:255', 'explain' => true), - 'board_index_text' => array('lang' => 'BOARD_INDEX_TEXT', 'validate' => 'string', 'type' => 'text:40:255', 'explain' => true), - 'board_disable' => array('lang' => 'DISABLE_BOARD', 'validate' => 'bool', 'type' => 'custom', 'method' => 'board_disable', 'explain' => true), - 'board_disable_msg' => false, - 'default_lang' => array('lang' => 'DEFAULT_LANGUAGE', 'validate' => 'lang', 'type' => 'select', 'function' => 'language_select', 'params' => array('{CONFIG_VALUE}'), 'explain' => false), - 'default_dateformat' => array('lang' => 'DEFAULT_DATE_FORMAT', 'validate' => 'string', 'type' => 'custom', 'method' => 'dateformat_select', 'explain' => true), - 'board_timezone' => array('lang' => 'SYSTEM_TIMEZONE', 'validate' => 'timezone', 'type' => 'custom', 'method' => 'timezone_select', 'explain' => true), - - 'legend2' => 'BOARD_STYLE', - 'default_style' => array('lang' => 'DEFAULT_STYLE', 'validate' => 'int', 'type' => 'select', 'function' => 'style_select', 'params' => array('{CONFIG_VALUE}', false), 'explain' => true), - 'guest_style' => array('lang' => 'GUEST_STYLE', 'validate' => 'int', 'type' => 'select', 'function' => 'style_select', 'params' => array($this->guest_style_get(), false), 'explain' => true), - 'override_user_style' => array('lang' => 'OVERRIDE_STYLE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - - 'legend3' => 'WARNINGS', - 'warnings_expire_days' => array('lang' => 'WARNINGS_EXPIRE', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']), - - 'legend4' => 'ACP_SUBMIT_CHANGES', - ) - ); - break; - - case 'features': - $display_vars = array( - 'title' => 'ACP_BOARD_FEATURES', - 'vars' => array( - 'legend1' => 'ACP_BOARD_FEATURES', - 'allow_privmsg' => array('lang' => 'BOARD_PM', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'allow_topic_notify' => array('lang' => 'ALLOW_TOPIC_NOTIFY', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_forum_notify' => array('lang' => 'ALLOW_FORUM_NOTIFY', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_namechange' => array('lang' => 'ALLOW_NAME_CHANGE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_attachments' => array('lang' => 'ALLOW_ATTACHMENTS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_pm_attach' => array('lang' => 'ALLOW_PM_ATTACHMENTS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_pm_report' => array('lang' => 'ALLOW_PM_REPORT', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'allow_bbcode' => array('lang' => 'ALLOW_BBCODE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_smilies' => array('lang' => 'ALLOW_SMILIES', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_sig' => array('lang' => 'ALLOW_SIG', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_board_notifications' => array('lang' => 'ALLOW_BOARD_NOTIFICATIONS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_nocensors' => array('lang' => 'ALLOW_NO_CENSORS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'allow_bookmarks' => array('lang' => 'ALLOW_BOOKMARKS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'allow_birthdays' => array('lang' => 'ALLOW_BIRTHDAYS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'display_last_subject' => array('lang' => 'DISPLAY_LAST_SUBJECT', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'display_unapproved_posts' => array('lang' => 'DISPLAY_UNAPPROVED_POSTS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'allow_quick_reply' => array('lang' => 'ALLOW_QUICK_REPLY', 'validate' => 'bool', 'type' => 'custom', 'method' => 'quick_reply', 'explain' => true), - - 'legend2' => 'ACP_SUBMIT_CHANGES', - ) - ); - break; - - case 'avatar': - /* @var $phpbb_avatar_manager \phpbb\avatar\manager */ - $phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); - $avatar_drivers = $phpbb_avatar_manager->get_all_drivers(); - - $avatar_vars = array(); - foreach ($avatar_drivers as $current_driver) - { - /** @var \phpbb\avatar\driver\driver_interface $driver */ - $driver = $phpbb_avatar_manager->get_driver($current_driver, false); - - /* - * First grab the settings for enabling/disabling the avatar - * driver and afterwards grab additional settings the driver - * might have. - */ - $avatar_vars += $phpbb_avatar_manager->get_avatar_settings($driver); - $avatar_vars += $driver->prepare_form_acp($user); - } - - $display_vars = array( - 'title' => 'ACP_AVATAR_SETTINGS', - 'vars' => array( - 'legend1' => 'ACP_AVATAR_SETTINGS', - - 'avatar_min_width' => array('lang' => 'MIN_AVATAR_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false), - 'avatar_min_height' => array('lang' => 'MIN_AVATAR_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false), - 'avatar_max_width' => array('lang' => 'MAX_AVATAR_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false), - 'avatar_max_height' => array('lang' => 'MAX_AVATAR_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false), - - 'allow_avatar' => array('lang' => 'ALLOW_AVATARS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'avatar_min' => array('lang' => 'MIN_AVATAR_SIZE', 'validate' => 'int:0', 'type' => 'dimension:0', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), - 'avatar_max' => array('lang' => 'MAX_AVATAR_SIZE', 'validate' => 'int:0', 'type' => 'dimension:0', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), - ) - ); - - if (!empty($avatar_vars)) - { - $display_vars['vars'] += $avatar_vars; - } - break; - - case 'message': - $display_vars = array( - 'title' => 'ACP_MESSAGE_SETTINGS', - 'lang' => 'ucp', - 'vars' => array( - 'legend1' => 'GENERAL_SETTINGS', - 'allow_privmsg' => array('lang' => 'BOARD_PM', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'pm_max_boxes' => array('lang' => 'BOXES_MAX', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true), - 'pm_max_msgs' => array('lang' => 'BOXES_LIMIT', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true), - 'full_folder_action' => array('lang' => 'FULL_FOLDER_ACTION', 'validate' => 'int', 'type' => 'select', 'method' => 'full_folder_select', 'explain' => true), - 'pm_edit_time' => array('lang' => 'PM_EDIT_TIME', 'validate' => 'int:0:99999', 'type' => 'number:0:99999', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']), - 'pm_max_recipients' => array('lang' => 'PM_MAX_RECIPIENTS', 'validate' => 'int:0:99999', 'type' => 'number:0:99999', 'explain' => true), - - 'legend2' => 'GENERAL_OPTIONS', - 'allow_mass_pm' => array('lang' => 'ALLOW_MASS_PM', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'auth_bbcode_pm' => array('lang' => 'ALLOW_BBCODE_PM', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'auth_smilies_pm' => array('lang' => 'ALLOW_SMILIES_PM', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_pm_attach' => array('lang' => 'ALLOW_PM_ATTACHMENTS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_sig_pm' => array('lang' => 'ALLOW_SIG_PM', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'print_pm' => array('lang' => 'ALLOW_PRINT_PM', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'forward_pm' => array('lang' => 'ALLOW_FORWARD_PM', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'auth_img_pm' => array('lang' => 'ALLOW_IMG_PM', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'auth_flash_pm' => array('lang' => 'ALLOW_FLASH_PM', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'enable_pm_icons' => array('lang' => 'ENABLE_PM_ICONS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - - 'legend3' => 'ACP_SUBMIT_CHANGES', - ) - ); - break; - - case 'post': - $display_vars = array( - 'title' => 'ACP_POST_SETTINGS', - 'vars' => array( - 'legend1' => 'GENERAL_OPTIONS', - 'allow_topic_notify' => array('lang' => 'ALLOW_TOPIC_NOTIFY', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_forum_notify' => array('lang' => 'ALLOW_FORUM_NOTIFY', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_bbcode' => array('lang' => 'ALLOW_BBCODE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_post_flash' => array('lang' => 'ALLOW_POST_FLASH', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'allow_smilies' => array('lang' => 'ALLOW_SMILIES', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_post_links' => array('lang' => 'ALLOW_POST_LINKS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'allowed_schemes_links' => array('lang' => 'ALLOWED_SCHEMES_LINKS', 'validate' => 'string', 'type' => 'text:0:255', 'explain' => true), - 'allow_nocensors' => array('lang' => 'ALLOW_NO_CENSORS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'allow_bookmarks' => array('lang' => 'ALLOW_BOOKMARKS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'enable_post_confirm' => array('lang' => 'VISUAL_CONFIRM_POST', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'allow_quick_reply' => array('lang' => 'ALLOW_QUICK_REPLY', 'validate' => 'bool', 'type' => 'custom', 'method' => 'quick_reply', 'explain' => true), - - 'legend2' => 'POSTING', - 'bump_type' => false, - 'edit_time' => array('lang' => 'EDIT_TIME', 'validate' => 'int:0:99999', 'type' => 'number:0:99999', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']), - 'delete_time' => array('lang' => 'DELETE_TIME', 'validate' => 'int:0:99999', 'type' => 'number:0:99999', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']), - 'display_last_edited' => array('lang' => 'DISPLAY_LAST_EDITED', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'flood_interval' => array('lang' => 'FLOOD_INTERVAL', 'validate' => 'int:0:9999999999', 'type' => 'number:0:9999999999', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']), - 'bump_interval' => array('lang' => 'BUMP_INTERVAL', 'validate' => 'int:0', 'type' => 'custom', 'method' => 'bump_interval', 'explain' => true), - 'topics_per_page' => array('lang' => 'TOPICS_PER_PAGE', 'validate' => 'int:1:9999', 'type' => 'number:1:9999', 'explain' => false), - 'posts_per_page' => array('lang' => 'POSTS_PER_PAGE', 'validate' => 'int:1:9999', 'type' => 'number:1:9999', 'explain' => false), - 'smilies_per_page' => array('lang' => 'SMILIES_PER_PAGE', 'validate' => 'int:1:9999', 'type' => 'number:1:9999', 'explain' => false), - 'hot_threshold' => array('lang' => 'HOT_THRESHOLD', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true), - 'max_poll_options' => array('lang' => 'MAX_POLL_OPTIONS', 'validate' => 'int:2:127', 'type' => 'number:2:127', 'explain' => false), - 'max_post_chars' => array('lang' => 'CHAR_LIMIT', 'validate' => 'int:0:999999', 'type' => 'number:0:999999', 'explain' => true), - 'min_post_chars' => array('lang' => 'MIN_CHAR_LIMIT', 'validate' => 'int:1:999999', 'type' => 'number:1:999999', 'explain' => true), - 'max_post_smilies' => array('lang' => 'SMILIES_LIMIT', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true), - 'max_post_urls' => array('lang' => 'MAX_POST_URLS', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true), - 'max_post_font_size' => array('lang' => 'MAX_POST_FONT_SIZE', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true, 'append' => ' %'), - 'max_quote_depth' => array('lang' => 'QUOTE_DEPTH_LIMIT', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true), - 'max_post_img_width' => array('lang' => 'MAX_POST_IMG_WIDTH', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), - 'max_post_img_height' => array('lang' => 'MAX_POST_IMG_HEIGHT', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), - - 'legend3' => 'ACP_SUBMIT_CHANGES', - ) - ); - break; - - case 'signature': - $display_vars = array( - 'title' => 'ACP_SIGNATURE_SETTINGS', - 'vars' => array( - 'legend1' => 'GENERAL_OPTIONS', - 'allow_sig' => array('lang' => 'ALLOW_SIG', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_sig_bbcode' => array('lang' => 'ALLOW_SIG_BBCODE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_sig_img' => array('lang' => 'ALLOW_SIG_IMG', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_sig_flash' => array('lang' => 'ALLOW_SIG_FLASH', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_sig_smilies' => array('lang' => 'ALLOW_SIG_SMILIES', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_sig_links' => array('lang' => 'ALLOW_SIG_LINKS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - - 'legend2' => 'GENERAL_SETTINGS', - 'max_sig_chars' => array('lang' => 'MAX_SIG_LENGTH', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true), - 'max_sig_urls' => array('lang' => 'MAX_SIG_URLS', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true), - 'max_sig_font_size' => array('lang' => 'MAX_SIG_FONT_SIZE', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true, 'append' => ' %'), - 'max_sig_smilies' => array('lang' => 'MAX_SIG_SMILIES', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true), - 'max_sig_img_width' => array('lang' => 'MAX_SIG_IMG_WIDTH', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), - 'max_sig_img_height' => array('lang' => 'MAX_SIG_IMG_HEIGHT', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), - - 'legend3' => 'ACP_SUBMIT_CHANGES', - ) - ); - break; - - case 'registration': - $display_vars = array( - 'title' => 'ACP_REGISTER_SETTINGS', - 'vars' => array( - 'legend1' => 'GENERAL_SETTINGS', - 'max_name_chars' => array('lang' => 'USERNAME_LENGTH', 'validate' => 'int:8:180', 'type' => false, 'method' => false, 'explain' => false,), - - 'require_activation' => array('lang' => 'ACC_ACTIVATION', 'validate' => 'int', 'type' => 'select', 'method' => 'select_acc_activation', 'explain' => true), - 'new_member_post_limit' => array('lang' => 'NEW_MEMBER_POST_LIMIT', 'validate' => 'int:0:255', 'type' => 'number:0:255', 'explain' => true, 'append' => ' ' . $user->lang['POSTS']), - 'new_member_group_default'=> array('lang' => 'NEW_MEMBER_GROUP_DEFAULT', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'min_name_chars' => array('lang' => 'USERNAME_LENGTH', 'validate' => 'int:1', 'type' => 'custom:5:180', 'method' => 'username_length', 'explain' => true), - 'min_pass_chars' => array('lang' => 'PASSWORD_LENGTH', 'validate' => 'int:1', 'type' => 'custom', 'method' => 'password_length', 'explain' => true), - 'allow_name_chars' => array('lang' => 'USERNAME_CHARS', 'validate' => 'string', 'type' => 'select', 'method' => 'select_username_chars', 'explain' => true), - 'pass_complex' => array('lang' => 'PASSWORD_TYPE', 'validate' => 'string', 'type' => 'select', 'method' => 'select_password_chars', 'explain' => true), - 'chg_passforce' => array('lang' => 'FORCE_PASS_CHANGE', 'validate' => 'int:0:999', 'type' => 'number:0:999', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']), - - 'legend2' => 'GENERAL_OPTIONS', - 'allow_namechange' => array('lang' => 'ALLOW_NAME_CHANGE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_emailreuse' => array('lang' => 'ALLOW_EMAIL_REUSE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'enable_confirm' => array('lang' => 'VISUAL_CONFIRM_REG', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'max_login_attempts' => array('lang' => 'MAX_LOGIN_ATTEMPTS', 'validate' => 'int:0:999', 'type' => 'number:0:999', 'explain' => true), - 'max_reg_attempts' => array('lang' => 'REG_LIMIT', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true), - - 'legend3' => 'COPPA', - 'coppa_enable' => array('lang' => 'ENABLE_COPPA', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'coppa_mail' => array('lang' => 'COPPA_MAIL', 'validate' => 'string', 'type' => 'textarea:5:40', 'explain' => true), - 'coppa_fax' => array('lang' => 'COPPA_FAX', 'validate' => 'string', 'type' => 'text:25:100', 'explain' => false), - - 'legend4' => 'ACP_SUBMIT_CHANGES', - ) - ); - break; - - case 'feed': - $display_vars = array( - 'title' => 'ACP_FEED_MANAGEMENT', - 'vars' => array( - 'legend1' => 'ACP_FEED_GENERAL', - 'feed_enable' => array('lang' => 'ACP_FEED_ENABLE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true ), - 'feed_item_statistics' => array('lang' => 'ACP_FEED_ITEM_STATISTICS', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), - 'feed_http_auth' => array('lang' => 'ACP_FEED_HTTP_AUTH', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), - - 'legend2' => 'ACP_FEED_POST_BASED', - 'feed_limit_post' => array('lang' => 'ACP_FEED_LIMIT', 'validate' => 'int:5:9999', 'type' => 'number:5:9999', 'explain' => true), - 'feed_overall' => array('lang' => 'ACP_FEED_OVERALL', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true ), - 'feed_forum' => array('lang' => 'ACP_FEED_FORUM', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true ), - 'feed_topic' => array('lang' => 'ACP_FEED_TOPIC', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true ), - - 'legend3' => 'ACP_FEED_TOPIC_BASED', - 'feed_limit_topic' => array('lang' => 'ACP_FEED_LIMIT', 'validate' => 'int:5:9999', 'type' => 'number:5:9999', 'explain' => true), - 'feed_topics_new' => array('lang' => 'ACP_FEED_TOPICS_NEW', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true ), - 'feed_topics_active' => array('lang' => 'ACP_FEED_TOPICS_ACTIVE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true ), - 'feed_news_id' => array('lang' => 'ACP_FEED_NEWS', 'validate' => 'string', 'type' => 'custom', 'method' => 'select_news_forums', 'explain' => true), - - 'legend4' => 'ACP_FEED_SETTINGS_OTHER', - 'feed_overall_forums' => array('lang' => 'ACP_FEED_OVERALL_FORUMS', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true ), - 'feed_exclude_id' => array('lang' => 'ACP_FEED_EXCLUDE_ID', 'validate' => 'string', 'type' => 'custom', 'method' => 'select_exclude_forums', 'explain' => true), - ) - ); - break; - - case 'cookie': - $display_vars = array( - 'title' => 'ACP_COOKIE_SETTINGS', - 'vars' => array( - 'legend1' => 'ACP_COOKIE_SETTINGS', - 'cookie_domain' => array('lang' => 'COOKIE_DOMAIN', 'validate' => 'string', 'type' => 'text::255', 'explain' => true), - 'cookie_name' => array('lang' => 'COOKIE_NAME', 'validate' => 'string', 'type' => 'text::16', 'explain' => true), - 'cookie_path' => array('lang' => 'COOKIE_PATH', 'validate' => 'string', 'type' => 'text::255', 'explain' => true), - 'cookie_secure' => array('lang' => 'COOKIE_SECURE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), - 'cookie_notice' => array('lang' => 'COOKIE_NOTICE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), - ) - ); - break; - - case 'load': - $display_vars = array( - 'title' => 'ACP_LOAD_SETTINGS', - 'vars' => array( - 'legend1' => 'GENERAL_SETTINGS', - 'limit_load' => array('lang' => 'LIMIT_LOAD', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true), - 'session_length' => array('lang' => 'SESSION_LENGTH', 'validate' => 'int:60:9999999999', 'type' => 'number:60:9999999999', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']), - 'active_sessions' => array('lang' => 'LIMIT_SESSIONS', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true), - 'load_online_time' => array('lang' => 'ONLINE_LENGTH', 'validate' => 'int:0:999', 'type' => 'number:0:999', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']), - 'read_notification_expire_days' => array('lang' => 'READ_NOTIFICATION_EXPIRE_DAYS', 'validate' => 'int:0', 'type' => 'number:0', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']), - - 'legend2' => 'GENERAL_OPTIONS', - 'load_notifications' => array('lang' => 'LOAD_NOTIFICATIONS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'load_db_track' => array('lang' => 'YES_POST_MARKING', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'load_db_lastread' => array('lang' => 'YES_READ_MARKING', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'load_anon_lastread' => array('lang' => 'YES_ANON_READ_MARKING', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'load_online' => array('lang' => 'YES_ONLINE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'load_online_guests' => array('lang' => 'YES_ONLINE_GUESTS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'load_onlinetrack' => array('lang' => 'YES_ONLINE_TRACK', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'load_birthdays' => array('lang' => 'YES_BIRTHDAYS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'load_unreads_search' => array('lang' => 'YES_UNREAD_SEARCH', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'load_moderators' => array('lang' => 'YES_MODERATORS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'load_jumpbox' => array('lang' => 'YES_JUMPBOX', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'load_user_activity' => array('lang' => 'LOAD_USER_ACTIVITY', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'load_user_activity_limit' => array('lang' => 'LOAD_USER_ACTIVITY_LIMIT', 'validate' => 'int:0:99999999', 'type' => 'number:0:99999999', 'explain' => true), - 'load_tplcompile' => array('lang' => 'RECOMPILE_STYLES', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'allow_cdn' => array('lang' => 'ALLOW_CDN', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'enable_accurate_pm_button' => array('lang' => 'YES_ACCURATE_PM_BUTTON', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'allow_live_searches' => array('lang' => 'ALLOW_LIVE_SEARCHES', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - - 'legend3' => 'CUSTOM_PROFILE_FIELDS', - 'load_cpf_memberlist' => array('lang' => 'LOAD_CPF_MEMBERLIST', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'load_cpf_pm' => array('lang' => 'LOAD_CPF_PM', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'load_cpf_viewprofile' => array('lang' => 'LOAD_CPF_VIEWPROFILE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'load_cpf_viewtopic' => array('lang' => 'LOAD_CPF_VIEWTOPIC', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - - 'legend4' => 'ACP_SUBMIT_CHANGES', - ) - ); - break; - - case 'auth': - $display_vars = array( - 'title' => 'ACP_AUTH_SETTINGS', - 'vars' => array( - 'legend1' => 'ACP_AUTH_SETTINGS', - 'auth_method' => array('lang' => 'AUTH_METHOD', 'validate' => 'string', 'type' => 'select:1:toggable', 'method' => 'select_auth_method', 'explain' => false), - ) - ); - break; - - case 'server': - $display_vars = array( - 'title' => 'ACP_SERVER_SETTINGS', - 'vars' => array( - 'legend1' => 'ACP_SERVER_SETTINGS', - 'gzip_compress' => array('lang' => 'ENABLE_GZIP', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'use_system_cron' => array('lang' => 'USE_SYSTEM_CRON', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - - 'legend2' => 'PATH_SETTINGS', - 'enable_mod_rewrite' => array('lang' => 'MOD_REWRITE_ENABLE', 'validate' => 'bool', 'type' => 'custom', 'method' => 'enable_mod_rewrite', 'explain' => true), - 'smilies_path' => array('lang' => 'SMILIES_PATH', 'validate' => 'rpath', 'type' => 'text:20:255', 'explain' => true), - 'icons_path' => array('lang' => 'ICONS_PATH', 'validate' => 'rpath', 'type' => 'text:20:255', 'explain' => true), - 'upload_icons_path' => array('lang' => 'UPLOAD_ICONS_PATH', 'validate' => 'rpath', 'type' => 'text:20:255', 'explain' => true), - 'ranks_path' => array('lang' => 'RANKS_PATH', 'validate' => 'rpath', 'type' => 'text:20:255', 'explain' => true), - - 'legend3' => 'SERVER_URL_SETTINGS', - 'force_server_vars' => array('lang' => 'FORCE_SERVER_VARS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'server_protocol' => array('lang' => 'SERVER_PROTOCOL', 'validate' => 'string', 'type' => 'text:10:10', 'explain' => true), - 'server_name' => array('lang' => 'SERVER_NAME', 'validate' => 'string', 'type' => 'text:40:255', 'explain' => true), - 'server_port' => array('lang' => 'SERVER_PORT', 'validate' => 'int:0:99999', 'type' => 'number:0:99999', 'explain' => true), - 'script_path' => array('lang' => 'SCRIPT_PATH', 'validate' => 'script_path', 'type' => 'text::255', 'explain' => true), - - 'legend4' => 'ACP_SUBMIT_CHANGES', - ) - ); - break; - - case 'security': - $display_vars = array( - 'title' => 'ACP_SECURITY_SETTINGS', - 'vars' => array( - 'legend1' => 'ACP_SECURITY_SETTINGS', - 'allow_autologin' => array('lang' => 'ALLOW_AUTOLOGIN', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'allow_password_reset' => array('lang' => 'ALLOW_PASSWORD_RESET', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'max_autologin_time' => array('lang' => 'AUTOLOGIN_LENGTH', 'validate' => 'int:0:99999', 'type' => 'number:0:99999', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']), - 'ip_check' => array('lang' => 'IP_VALID', 'validate' => 'int', 'type' => 'custom', 'method' => 'select_ip_check', 'explain' => true), - 'browser_check' => array('lang' => 'BROWSER_VALID', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'forwarded_for_check' => array('lang' => 'FORWARDED_FOR_VALID', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'referer_validation' => array('lang' => 'REFERRER_VALID', 'validate' => 'int:0:3','type' => 'custom', 'method' => 'select_ref_check', 'explain' => true), - 'remote_upload_verify' => array('lang' => 'UPLOAD_CERT_VALID', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'check_dnsbl' => array('lang' => 'CHECK_DNSBL', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'email_check_mx' => array('lang' => 'EMAIL_CHECK_MX', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'min_pass_chars' => array('lang' => 'PASSWORD_LENGTH', 'validate' => 'int:1', 'type' => 'custom', 'method' => 'password_length', 'explain' => true), - 'pass_complex' => array('lang' => 'PASSWORD_TYPE', 'validate' => 'string', 'type' => 'select', 'method' => 'select_password_chars', 'explain' => true), - 'chg_passforce' => array('lang' => 'FORCE_PASS_CHANGE', 'validate' => 'int:0:999', 'type' => 'number:0:999', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']), - 'max_login_attempts' => array('lang' => 'MAX_LOGIN_ATTEMPTS', 'validate' => 'int:0:999', 'type' => 'number:0:999', 'explain' => true), - 'ip_login_limit_max' => array('lang' => 'IP_LOGIN_LIMIT_MAX', 'validate' => 'int:0:999', 'type' => 'number:0:999', 'explain' => true), - 'ip_login_limit_time' => array('lang' => 'IP_LOGIN_LIMIT_TIME', 'validate' => 'int:0:99999', 'type' => 'number:0:99999', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']), - 'ip_login_limit_use_forwarded' => array('lang' => 'IP_LOGIN_LIMIT_USE_FORWARDED', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'tpl_allow_php' => array('lang' => 'TPL_ALLOW_PHP', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'form_token_lifetime' => array('lang' => 'FORM_TIME_MAX', 'validate' => 'int:-1:99999', 'type' => 'number:-1:99999', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']), - 'form_token_sid_guests' => array('lang' => 'FORM_SID_GUESTS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - - ) - ); - break; - - case 'email': - $display_vars = array( - 'title' => 'ACP_EMAIL_SETTINGS', - 'vars' => array( - 'legend1' => 'GENERAL_SETTINGS', - 'email_enable' => array('lang' => 'ENABLE_EMAIL', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), - 'board_email_form' => array('lang' => 'BOARD_EMAIL_FORM', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), - 'email_package_size' => array('lang' => 'EMAIL_PACKAGE_SIZE', 'validate' => 'int:0', 'type' => 'number:0:99999', 'explain' => true), - 'email_max_chunk_size' => array('lang' => 'EMAIL_MAX_CHUNK_SIZE', 'validate' => 'int:1:99999', 'type' => 'number:1:99999', 'explain' => true), - 'board_contact' => array('lang' => 'CONTACT_EMAIL', 'validate' => 'email', 'type' => 'email:25:100', 'explain' => true), - 'board_contact_name' => array('lang' => 'CONTACT_EMAIL_NAME', 'validate' => 'string', 'type' => 'text:25:50', 'explain' => true), - 'board_email' => array('lang' => 'ADMIN_EMAIL', 'validate' => 'email', 'type' => 'email:25:100', 'explain' => true), - 'email_force_sender' => array('lang' => 'EMAIL_FORCE_SENDER', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'board_email_sig' => array('lang' => 'EMAIL_SIG', 'validate' => 'string', 'type' => 'textarea:5:30', 'explain' => true), - 'board_hide_emails' => array('lang' => 'BOARD_HIDE_EMAILS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'send_test_email' => array('lang' => 'SEND_TEST_EMAIL', 'validate' => 'bool', 'type' => 'custom', 'method' => 'send_test_email', 'explain' => true), - - 'legend2' => 'SMTP_SETTINGS', - 'smtp_delivery' => array('lang' => 'USE_SMTP', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'smtp_host' => array('lang' => 'SMTP_SERVER', 'validate' => 'string', 'type' => 'text:25:50', 'explain' => true), - 'smtp_port' => array('lang' => 'SMTP_PORT', 'validate' => 'int:0:99999', 'type' => 'number:0:99999', 'explain' => true), - 'smtp_auth_method' => array('lang' => 'SMTP_AUTH_METHOD', 'validate' => 'string', 'type' => 'select', 'method' => 'mail_auth_select', 'explain' => true), - 'smtp_username' => array('lang' => 'SMTP_USERNAME', 'validate' => 'string', 'type' => 'text:25:255', 'explain' => true), - 'smtp_password' => array('lang' => 'SMTP_PASSWORD', 'validate' => 'string', 'type' => 'password:25:255', 'explain' => true), - 'smtp_verify_peer' => array('lang' => 'SMTP_VERIFY_PEER', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'smtp_verify_peer_name' => array('lang' => 'SMTP_VERIFY_PEER_NAME', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'smtp_allow_self_signed'=> array('lang' => 'SMTP_ALLOW_SELF_SIGNED','validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - - 'legend3' => 'ACP_SUBMIT_CHANGES', - ) - ); - break; - - default: - trigger_error('NO_MODE', E_USER_ERROR); - break; - } - - /** - * Event to add and/or modify acp_board configurations - * - * @event core.acp_board_config_edit_add - * @var array display_vars Array of config values to display and process - * @var string mode Mode of the config page we are displaying - * @var boolean submit Do we display the form or process the submission - * @since 3.1.0-a4 - */ - $vars = array('display_vars', 'mode', 'submit'); - extract($phpbb_dispatcher->trigger_event('core.acp_board_config_edit_add', compact($vars))); - - if (isset($display_vars['lang'])) - { - $user->add_lang($display_vars['lang']); - } - - $this->new_config = clone $config; - $cfg_array = (isset($_REQUEST['config'])) ? $request->variable('config', array('' => ''), true) : $this->new_config; - $error = array(); - - // We validate the complete config if wished - validate_config_vars($display_vars['vars'], $cfg_array, $error); - - if ($submit && !check_form_key($form_key)) - { - $error[] = $user->lang['FORM_INVALID']; - } - // Do not write values if there is an error - if (count($error)) - { - $submit = false; - } - - // We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to... - foreach ($display_vars['vars'] as $config_name => $data) - { - if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false) - { - continue; - } - - if ($config_name == 'auth_method' || $config_name == 'feed_news_id' || $config_name == 'feed_exclude_id') - { - continue; - } - - if ($config_name == 'guest_style') - { - if (isset($cfg_array[$config_name])) - { - $this->guest_style_set($cfg_array[$config_name]); - } - continue; - } - - $this->new_config[$config_name] = $config_value = $cfg_array[$config_name]; - - if ($submit) - { - if (isset($data['type']) && strpos($data['type'], 'password') === 0 && $config_value === '********') - { - /** - * Do not update password fields if the content is ********, - * because that is the password replacement we use to not - * send the password to the output - */ - continue; - } - - $config->set($config_name, $config_value); - - if ($config_name == 'allow_quick_reply' && isset($_POST['allow_quick_reply_enable'])) - { - enable_bitfield_column_flag(FORUMS_TABLE, 'forum_flags', round(log(FORUM_FLAG_QUICK_REPLY, 2))); - } - } - } - - // Invalidate the text_formatter cache when posting options are changed - if ($mode == 'post' && $submit) - { - $phpbb_container->get('text_formatter.cache')->invalidate(); - } - - // Store news and exclude ids - if ($mode == 'feed' && $submit) - { - $cache->destroy('_feed_news_forum_ids'); - $cache->destroy('_feed_excluded_forum_ids'); - - $this->store_feed_forums(FORUM_OPTION_FEED_NEWS, 'feed_news_id'); - $this->store_feed_forums(FORUM_OPTION_FEED_EXCLUDE, 'feed_exclude_id'); - } - - if ($mode == 'auth') - { - // Retrieve a list of auth plugins and check their config values - /* @var $auth_providers \phpbb\auth\provider_collection */ - $auth_providers = $phpbb_container->get('auth.provider_collection'); - - $updated_auth_settings = false; - $old_auth_config = array(); - foreach ($auth_providers as $provider) - { - /** @var \phpbb\auth\provider\provider_interface $provider */ - if ($fields = $provider->acp()) - { - // Check if we need to create config fields for this plugin and save config when submit was pressed - foreach ($fields as $field) - { - if (!isset($config[$field])) - { - $config->set($field, ''); - } - - if (!isset($cfg_array[$field]) || strpos($field, 'legend') !== false) - { - continue; - } - - if (substr($field, -9) === '_password' && $cfg_array[$field] === '********') - { - // Do not update password fields if the content is ********, - // because that is the password replacement we use to not - // send the password to the output - continue; - } - - $old_auth_config[$field] = $this->new_config[$field]; - $config_value = $cfg_array[$field]; - $this->new_config[$field] = $config_value; - - if ($submit) - { - $updated_auth_settings = true; - $config->set($field, $config_value); - } - } - } - unset($fields); - } - - if ($submit && (($cfg_array['auth_method'] != $this->new_config['auth_method']) || $updated_auth_settings)) - { - $method = basename($cfg_array['auth_method']); - if (array_key_exists('auth.provider.' . $method, $auth_providers)) - { - $provider = $auth_providers['auth.provider.' . $method]; - if ($error = $provider->init()) - { - foreach ($old_auth_config as $config_name => $config_value) - { - $config->set($config_name, $config_value); - } - trigger_error($error . adm_back_link($this->u_action), E_USER_WARNING); - } - $config->set('auth_method', basename($cfg_array['auth_method'])); - } - else - { - trigger_error('NO_AUTH_PLUGIN', E_USER_ERROR); - } - } - } - - if ($mode == 'email' && $request->is_set_post('send_test_email')) - { - if ($config['email_enable']) - { - include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); - - $messenger = new messenger(false); - $messenger->template('test'); - $messenger->set_addresses($user->data); - $messenger->anti_abuse_headers($config, $user); - $messenger->assign_vars(array( - 'USERNAME' => htmlspecialchars_decode($user->data['username']), - )); - $messenger->send(NOTIFY_EMAIL); - - trigger_error($user->lang('TEST_EMAIL_SENT') . adm_back_link($this->u_action)); - } - else - { - $user->add_lang('memberlist'); - trigger_error($user->lang('EMAIL_DISABLED') . adm_back_link($this->u_action), E_USER_WARNING); - } - } - - if ($submit) - { - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_CONFIG_' . strtoupper($mode)); - - $message = $user->lang('CONFIG_UPDATED'); - $message_type = E_USER_NOTICE; - if (!$config['email_enable'] && in_array($mode, array('email', 'registration')) && - in_array($config['require_activation'], array(USER_ACTIVATION_SELF, USER_ACTIVATION_ADMIN))) - { - $message .= '

' . $user->lang('ACC_ACTIVATION_WARNING'); - $message_type = E_USER_WARNING; - } - trigger_error($message . adm_back_link($this->u_action), $message_type); - } - - $this->tpl_name = 'acp_board'; - $this->page_title = $display_vars['title']; - - $template->assign_vars(array( - 'L_TITLE' => $user->lang[$display_vars['title']], - 'L_TITLE_EXPLAIN' => $user->lang[$display_vars['title'] . '_EXPLAIN'], - - 'S_ERROR' => (count($error)) ? true : false, - 'ERROR_MSG' => implode('
', $error), - - 'U_ACTION' => $this->u_action) - ); - - // Output relevant page - foreach ($display_vars['vars'] as $config_key => $vars) - { - if (!is_array($vars) && strpos($config_key, 'legend') === false) - { - continue; - } - - if (strpos($config_key, 'legend') !== false) - { - $template->assign_block_vars('options', array( - 'S_LEGEND' => true, - 'LEGEND' => (isset($user->lang[$vars])) ? $user->lang[$vars] : $vars) - ); - - continue; - } - - $type = explode(':', $vars['type']); - - $l_explain = ''; - if ($vars['explain'] && isset($vars['lang_explain'])) - { - $l_explain = (isset($user->lang[$vars['lang_explain']])) ? $user->lang[$vars['lang_explain']] : $vars['lang_explain']; - } - else if ($vars['explain']) - { - $l_explain = (isset($user->lang[$vars['lang'] . '_EXPLAIN'])) ? $user->lang[$vars['lang'] . '_EXPLAIN'] : ''; - } - - $content = build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars); - - if (empty($content)) - { - continue; - } - - $template->assign_block_vars('options', array( - 'KEY' => $config_key, - 'TITLE' => (isset($user->lang[$vars['lang']])) ? $user->lang[$vars['lang']] : $vars['lang'], - 'S_EXPLAIN' => $vars['explain'] && !empty($l_explain), - 'TITLE_EXPLAIN' => $l_explain, - 'CONTENT' => $content, - ) - ); - - unset($display_vars['vars'][$config_key]); - } - - if ($mode == 'auth') - { - $template->assign_var('S_AUTH', true); - - foreach ($auth_providers as $provider) - { - $auth_tpl = $provider->get_acp_template($this->new_config); - if ($auth_tpl) - { - if (array_key_exists('BLOCK_VAR_NAME', $auth_tpl)) - { - foreach ($auth_tpl['BLOCK_VARS'] as $block_vars) - { - $template->assign_block_vars($auth_tpl['BLOCK_VAR_NAME'], $block_vars); - } - } - $template->assign_vars($auth_tpl['TEMPLATE_VARS']); - $template->assign_block_vars('auth_tpl', array( - 'TEMPLATE_FILE' => $auth_tpl['TEMPLATE_FILE'], - )); - } - } - } - } - - /** - * Select auth method - */ - function select_auth_method($selected_method, $key = '') - { - global $phpbb_container; - - /* @var $auth_providers \phpbb\auth\provider_collection */ - $auth_providers = $phpbb_container->get('auth.provider_collection'); - $auth_plugins = array(); - - foreach ($auth_providers as $key => $value) - { - if (!($value instanceof \phpbb\auth\provider\provider_interface)) - { - continue; - } - $auth_plugins[] = str_replace('auth.provider.', '', $key); - } - - sort($auth_plugins); - - $auth_select = ''; - foreach ($auth_plugins as $method) - { - $selected = ($selected_method == $method) ? ' selected="selected"' : ''; - $auth_select .= "'; - } - - return $auth_select; - } - - /** - * Select mail authentication method - */ - function mail_auth_select($selected_method, $key = '') - { - global $user; - - $auth_methods = array('PLAIN', 'LOGIN', 'CRAM-MD5', 'DIGEST-MD5', 'POP-BEFORE-SMTP'); - $s_smtp_auth_options = ''; - - foreach ($auth_methods as $method) - { - $s_smtp_auth_options .= ''; - } - - return $s_smtp_auth_options; - } - - /** - * Select full folder action - */ - function full_folder_select($value, $key = '') - { - global $user; - - return ''; - } - - /** - * Select ip validation - */ - function select_ip_check($value, $key = '') - { - $radio_ary = array(4 => 'ALL', 3 => 'CLASS_C', 2 => 'CLASS_B', 0 => 'NO_IP_VALIDATION'); - - return h_radio('config[ip_check]', $radio_ary, $value, $key); - } - - /** - * Select referer validation - */ - function select_ref_check($value, $key = '') - { - $radio_ary = array(REFERER_VALIDATE_PATH => 'REF_PATH', REFERER_VALIDATE_HOST => 'REF_HOST', REFERER_VALIDATE_NONE => 'NO_REF_VALIDATION'); - - return h_radio('config[referer_validation]', $radio_ary, $value, $key); - } - - /** - * Select account activation method - */ - function select_acc_activation($selected_value, $value) - { - global $user, $config; - - $act_ary = array( - 'ACC_DISABLE' => array(true, USER_ACTIVATION_DISABLE), - 'ACC_NONE' => array(true, USER_ACTIVATION_NONE), - 'ACC_USER' => array($config['email_enable'], USER_ACTIVATION_SELF), - 'ACC_ADMIN' => array($config['email_enable'], USER_ACTIVATION_ADMIN), - ); - - $act_options = ''; - foreach ($act_ary as $key => $data) - { - list($available, $value) = $data; - $selected = ($selected_value == $value) ? ' selected="selected"' : ''; - $class = (!$available) ? ' class="disabled-option"' : ''; - $act_options .= ''; - } - - return $act_options; - } - - /** - * Maximum/Minimum username length - */ - function username_length($value, $key = '') - { - global $user; - - return ' ' . $user->lang['MIN_CHARS'] . '   ' . $user->lang['MAX_CHARS']; - } - - /** - * Allowed chars in usernames - */ - function select_username_chars($selected_value, $key) - { - global $user; - - $user_char_ary = array('USERNAME_CHARS_ANY', 'USERNAME_ALPHA_ONLY', 'USERNAME_ALPHA_SPACERS', 'USERNAME_LETTER_NUM', 'USERNAME_LETTER_NUM_SPACERS', 'USERNAME_ASCII'); - $user_char_options = ''; - foreach ($user_char_ary as $user_type) - { - $selected = ($selected_value == $user_type) ? ' selected="selected"' : ''; - $user_char_options .= ''; - } - - return $user_char_options; - } - - /** - * Minimum password length - */ - function password_length($value, $key) - { - global $user; - - return ' ' . $user->lang['MIN_CHARS']; - } - - /** - * Required chars in passwords - */ - function select_password_chars($selected_value, $key) - { - global $user; - - $pass_type_ary = array('PASS_TYPE_ANY', 'PASS_TYPE_CASE', 'PASS_TYPE_ALPHA', 'PASS_TYPE_SYMBOL'); - $pass_char_options = ''; - foreach ($pass_type_ary as $pass_type) - { - $selected = ($selected_value == $pass_type) ? ' selected="selected"' : ''; - $pass_char_options .= ''; - } - - return $pass_char_options; - } - - /** - * Select bump interval - */ - function bump_interval($value, $key) - { - global $user; - - $s_bump_type = ''; - $types = array('m' => 'MINUTES', 'h' => 'HOURS', 'd' => 'DAYS'); - foreach ($types as $type => $lang) - { - $selected = ($this->new_config['bump_type'] == $type) ? ' selected="selected"' : ''; - $s_bump_type .= ''; - } - - return ' '; - } - - /** - * Board disable option and message - */ - function board_disable($value, $key) - { - $radio_ary = array(1 => 'YES', 0 => 'NO'); - - return h_radio('config[board_disable]', $radio_ary, $value) . '
'; - } - - /** - * Global quick reply enable/disable setting and button to enable in all forums - */ - function quick_reply($value, $key) - { - global $user; - - $radio_ary = array(1 => 'YES', 0 => 'NO'); - - return h_radio('config[allow_quick_reply]', $radio_ary, $value) . - '

'; - } - - /** - * Select guest timezone - */ - function timezone_select($value, $key) - { - global $template, $user; - - $timezone_select = phpbb_timezone_select($template, $user, $value, true); - - return ''; - } - - /** - * Get guest style - */ - public function guest_style_get() - { - global $db; - - $sql = 'SELECT user_style - FROM ' . USERS_TABLE . ' - WHERE user_id = ' . ANONYMOUS; - $result = $db->sql_query($sql); - - $style = (int) $db->sql_fetchfield('user_style'); - $db->sql_freeresult($result); - - return $style; - } - - /** - * Set guest style - * - * @param int $style_id The style ID - */ - public function guest_style_set($style_id) - { - global $db; - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_style = ' . (int) $style_id . ' - WHERE user_id = ' . ANONYMOUS; - $db->sql_query($sql); - } - - /** - * Select default dateformat - */ - function dateformat_select($value, $key) - { - global $user, $config; - - // Let the format_date function operate with the acp values - $old_tz = $user->timezone; - try - { - $user->timezone = new DateTimeZone($config['board_timezone']); - } - catch (\Exception $e) - { - // If the board timezone is invalid, we just use the users timezone. - } - - $dateformat_options = ''; - - foreach ($user->lang['dateformats'] as $format => $null) - { - $dateformat_options .= ''; - } - - $dateformat_options .= ''; - - // Reset users date options - $user->timezone = $old_tz; - - return " - "; - } - - /** - * Select multiple forums - */ - function select_news_forums($value, $key) - { - $forum_list = make_forum_select(false, false, true, true, true, false, true); - - // Build forum options - $s_forum_options = ''; - - return $s_forum_options; - } - - function select_exclude_forums($value, $key) - { - $forum_list = make_forum_select(false, false, true, true, true, false, true); - - // Build forum options - $s_forum_options = ''; - - return $s_forum_options; - } - - function store_feed_forums($option, $key) - { - global $db, $cache, $request; - - // Get key - $values = $request->variable($key, array(0 => 0)); - - // Empty option bit for all forums - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET forum_options = forum_options - ' . (1 << $option) . ' - WHERE ' . $db->sql_bit_and('forum_options', $option, '<> 0'); - $db->sql_query($sql); - - // Already emptied for all... - if (count($values)) - { - // Set for selected forums - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET forum_options = forum_options + ' . (1 << $option) . ' - WHERE ' . $db->sql_in_set('forum_id', $values); - $db->sql_query($sql); - } - - // Empty sql cache for forums table because options changed - $cache->destroy('sql', FORUMS_TABLE); - } - - /** - * Option to enable/disable removal of 'app.php' from URLs - * - * Note that if mod_rewrite is on, URLs without app.php will still work, - * but any paths generated by the controller helper url() method will not - * contain app.php. - * - * @param int $value The current config value - * @param string $key The config key - * @return string The HTML for the form field - */ - function enable_mod_rewrite($value, $key) - { - global $user; - - // Determine whether mod_rewrite is enabled on the server - // NOTE: This only works on Apache servers on which PHP is NOT - // installed as CGI. In that case, there is no way for PHP to - // determine whether or not the Apache module is enabled. - // - // To be clear on the value of $mod_rewite: - // null = Cannot determine whether or not the server has mod_rewrite - // enabled - // false = Can determine that the server does NOT have mod_rewrite - // enabled - // true = Can determine that the server DOES have mod_rewrite_enabled - $mod_rewrite = null; - if (function_exists('apache_get_modules')) - { - $mod_rewrite = (bool) in_array('mod_rewrite', apache_get_modules()); - } - - // If $message is false, mod_rewrite is enabled. - // Otherwise, it is not and we need to: - // 1) disable the form field - // 2) make sure the config value is set to 0 - // 3) append the message to the return - $value = ($mod_rewrite === false) ? 0 : $value; - $message = $mod_rewrite === null ? 'MOD_REWRITE_INFORMATION_UNAVAILABLE' : ($mod_rewrite === false ? 'MOD_REWRITE_DISABLED' : false); - - // Let's do some friendly HTML injection if we want to disable the - // form field because h_radio() has no pretty way of doing so - $field_name = 'config[enable_mod_rewrite]' . ($message === 'MOD_REWRITE_DISABLED' ? '" disabled="disabled' : ''); - - return h_radio($field_name, array(1 => 'YES', 0 => 'NO'), $value) . - ($message !== false ? '
' . $user->lang($message) . '' : ''); - } - - function send_test_email($value, $key) - { - global $user; - - return ''; - } -} diff --git a/install/update/new/includes/acp/acp_database.php b/install/update/new/includes/acp/acp_database.php deleted file mode 100644 index c1c7488..0000000 --- a/install/update/new/includes/acp/acp_database.php +++ /dev/null @@ -1,616 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -class acp_database -{ - var $db_tools; - var $u_action; - public $page_title; - - function main($id, $mode) - { - global $cache, $db, $user, $template, $table_prefix, $request; - global $phpbb_root_path, $phpbb_container, $phpbb_log; - - $this->db_tools = $phpbb_container->get('dbal.tools'); - - $user->add_lang('acp/database'); - - $this->tpl_name = 'acp_database'; - $this->page_title = 'ACP_DATABASE'; - - $action = $request->variable('action', ''); - - $form_key = 'acp_database'; - add_form_key($form_key); - - $template->assign_vars(array( - 'MODE' => $mode - )); - - switch ($mode) - { - case 'backup': - - $this->page_title = 'ACP_BACKUP'; - - switch ($action) - { - case 'download': - $type = $request->variable('type', ''); - $table = array_intersect($this->db_tools->sql_list_tables(), $request->variable('table', array(''))); - $format = $request->variable('method', ''); - - if (!count($table)) - { - trigger_error($user->lang['TABLE_SELECT_ERROR'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - if (!check_form_key($form_key)) - { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - $store = true; - $structure = false; - $schema_data = false; - - if ($type == 'full' || $type == 'structure') - { - $structure = true; - } - - if ($type == 'full' || $type == 'data') - { - $schema_data = true; - } - - @set_time_limit(1200); - @set_time_limit(0); - - $time = time(); - - $filename = 'backup_' . $time . '_' . unique_id(); - - /** @var phpbb\db\extractor\extractor_interface $extractor Database extractor */ - $extractor = $phpbb_container->get('dbal.extractor'); - $extractor->init_extractor($format, $filename, $time, false, $store); - - $extractor->write_start($table_prefix); - - foreach ($table as $table_name) - { - // Get the table structure - if ($structure) - { - $extractor->write_table($table_name); - } - else - { - // We might wanna empty out all that junk :D - switch ($db->get_sql_layer()) - { - case 'sqlite3': - $extractor->flush('DELETE FROM ' . $table_name . ";\n"); - break; - - case 'mssql_odbc': - case 'mssqlnative': - $extractor->flush('TRUNCATE TABLE ' . $table_name . "GO\n"); - break; - - case 'oracle': - $extractor->flush('TRUNCATE TABLE ' . $table_name . "/\n"); - break; - - default: - $extractor->flush('TRUNCATE TABLE ' . $table_name . ";\n"); - break; - } - } - - // Data - if ($schema_data) - { - $extractor->write_data($table_name); - } - } - - $extractor->write_end(); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_DB_BACKUP'); - - trigger_error($user->lang['BACKUP_SUCCESS'] . adm_back_link($this->u_action)); - break; - - default: - $tables = $this->db_tools->sql_list_tables(); - asort($tables); - foreach ($tables as $table_name) - { - if (strlen($table_prefix) === 0 || stripos($table_name, $table_prefix) === 0) - { - $template->assign_block_vars('tables', array( - 'TABLE' => $table_name - )); - } - } - unset($tables); - - $template->assign_vars(array( - 'U_ACTION' => $this->u_action . '&action=download' - )); - - $available_methods = array('gzip' => 'zlib', 'bzip2' => 'bz2'); - - foreach ($available_methods as $type => $module) - { - if (!@extension_loaded($module)) - { - continue; - } - - $template->assign_block_vars('methods', array( - 'TYPE' => $type - )); - } - - $template->assign_block_vars('methods', array( - 'TYPE' => 'text' - )); - break; - } - break; - - case 'restore': - - $this->page_title = 'ACP_RESTORE'; - - switch ($action) - { - case 'submit': - $delete = $request->variable('delete', ''); - $file = $request->variable('file', ''); - - $backup_info = $this->get_backup_file($phpbb_root_path . 'store/', $file); - - if (empty($backup_info) || !is_readable($backup_info['file_name'])) - { - trigger_error($user->lang['BACKUP_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - if ($delete) - { - if (confirm_box(true)) - { - unlink($backup_info['file_name']); - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_DB_DELETE'); - trigger_error($user->lang['BACKUP_DELETE'] . adm_back_link($this->u_action)); - } - else - { - confirm_box(false, $user->lang['DELETE_SELECTED_BACKUP'], build_hidden_fields(array('delete' => $delete, 'file' => $file))); - } - } - else if (confirm_box(true)) - { - switch ($backup_info['extension']) - { - case 'sql': - $fp = fopen($backup_info['file_name'], 'rb'); - $read = 'fread'; - $seek = 'fseek'; - $eof = 'feof'; - $close = 'fclose'; - $fgetd = 'fgetd'; - break; - - case 'sql.bz2': - $fp = bzopen($backup_info['file_name'], 'r'); - $read = 'bzread'; - $seek = ''; - $eof = 'feof'; - $close = 'bzclose'; - $fgetd = 'fgetd_seekless'; - break; - - case 'sql.gz': - $fp = gzopen($backup_info['file_name'], 'rb'); - $read = 'gzread'; - $seek = 'gzseek'; - $eof = 'gzeof'; - $close = 'gzclose'; - $fgetd = 'fgetd'; - break; - - default: - trigger_error($user->lang['BACKUP_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); - return; - } - - switch ($db->get_sql_layer()) - { - case 'mysqli': - case 'sqlite3': - while (($sql = $fgetd($fp, ";\n", $read, $seek, $eof)) !== false) - { - $db->sql_query($sql); - } - break; - - case 'postgres': - $delim = ";\n"; - while (($sql = $fgetd($fp, $delim, $read, $seek, $eof)) !== false) - { - $query = trim($sql); - - if (substr($query, 0, 13) == 'CREATE DOMAIN') - { - list(, , $domain) = explode(' ', $query); - $sql = "SELECT domain_name - FROM information_schema.domains - WHERE domain_name = '$domain';"; - $result = $db->sql_query($sql); - if (!$db->sql_fetchrow($result)) - { - $db->sql_query($query); - } - $db->sql_freeresult($result); - } - else - { - $db->sql_query($query); - } - - if (substr($query, 0, 4) == 'COPY') - { - while (($sub = $fgetd($fp, "\n", $read, $seek, $eof)) !== '\.') - { - if ($sub === false) - { - trigger_error($user->lang['RESTORE_FAILURE'] . adm_back_link($this->u_action), E_USER_WARNING); - } - pg_put_line($db->get_db_connect_id(), $sub . "\n"); - } - pg_put_line($db->get_db_connect_id(), "\\.\n"); - pg_end_copy($db->get_db_connect_id()); - } - } - break; - - case 'oracle': - while (($sql = $fgetd($fp, "/\n", $read, $seek, $eof)) !== false) - { - $db->sql_query($sql); - } - break; - - case 'mssql_odbc': - case 'mssqlnative': - while (($sql = $fgetd($fp, "GO\n", $read, $seek, $eof)) !== false) - { - $db->sql_query($sql); - } - break; - } - - $close($fp); - - // Purge the cache due to updated data - $cache->purge(); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_DB_RESTORE'); - trigger_error($user->lang['RESTORE_SUCCESS'] . adm_back_link($this->u_action)); - break; - } - else - { - confirm_box(false, $user->lang['RESTORE_SELECTED_BACKUP'], build_hidden_fields(array('file' => $file))); - } - - default: - $backup_files = $this->get_file_list($phpbb_root_path . 'store/'); - - if (!empty($backup_files)) - { - krsort($backup_files); - - foreach ($backup_files as $name => $file) - { - $template->assign_block_vars('files', array( - 'FILE' => sha1($file), - 'NAME' => $user->format_date($name, 'd-m-Y H:i', true), - 'SUPPORTED' => true, - )); - } - } - - $template->assign_vars(array( - 'U_ACTION' => $this->u_action . '&action=submit' - )); - break; - } - break; - } - } - - /** - * Get backup file from file hash - * - * @param string $directory Relative path to directory - * @param string $file_hash Hash of selected file - * - * @return array Backup file data or empty array if unable to find file - */ - protected function get_backup_file($directory, $file_hash) - { - $backup_data = []; - - $file_list = $this->get_file_list($directory); - $supported_extensions = $this->get_supported_extensions(); - - foreach ($file_list as $file) - { - preg_match('#^backup_(\d{10,})_(?:[a-z\d]{16}|[a-z\d]{32})\.(sql(?:\.(?:gz|bz2))?)$#i', $file, $matches); - if (sha1($file) === $file_hash && in_array($matches[2], $supported_extensions)) - { - $backup_data = [ - 'file_name' => $directory . $file, - 'extension' => $matches[2], - ]; - break; - } - } - - return $backup_data; - } - - /** - * Get backup file list for directory - * - * @param string $directory Relative path to backup directory - * - * @return array List of backup files in specified directory - */ - protected function get_file_list($directory) - { - $supported_extensions = $this->get_supported_extensions(); - - $dh = @opendir($directory); - - $backup_files = []; - - if ($dh) - { - while (($file = readdir($dh)) !== false) - { - if (preg_match('#^backup_(\d{10,})_(?:[a-z\d]{16}|[a-z\d]{32})\.(sql(?:\.(?:gz|bz2))?)$#i', $file, $matches)) - { - if (in_array($matches[2], $supported_extensions)) - { - $backup_files[(int) $matches[1]] = $file; - } - } - } - closedir($dh); - } - - return $backup_files; - } - - /** - * Get supported extensions for backup - * - * @return array List of supported extensions - */ - protected function get_supported_extensions() - { - $extensions = ['sql']; - $available_methods = ['sql.gz' => 'zlib', 'sql.bz2' => 'bz2']; - - foreach ($available_methods as $type => $module) - { - if (!@extension_loaded($module)) - { - continue; - } - $extensions[] = $type; - } - - return $extensions; - } -} - -// get how much space we allow for a chunk of data, very similar to phpMyAdmin's way of doing things ;-) (hey, we only do this for MySQL anyway :P) -function get_usable_memory() -{ - $val = trim(@ini_get('memory_limit')); - - if (preg_match('/(\\d+)([mkg]?)/i', $val, $regs)) - { - $memory_limit = (int) $regs[1]; - switch ($regs[2]) - { - - case 'k': - case 'K': - $memory_limit *= 1024; - break; - - case 'm': - case 'M': - $memory_limit *= 1048576; - break; - - case 'g': - case 'G': - $memory_limit *= 1073741824; - break; - } - - // how much memory PHP requires at the start of export (it is really a little less) - if ($memory_limit > 6100000) - { - $memory_limit -= 6100000; - } - - // allow us to consume half of the total memory available - $memory_limit /= 2; - } - else - { - // set the buffer to 1M if we have no clue how much memory PHP will give us :P - $memory_limit = 1048576; - } - - return $memory_limit; -} - -function sanitize_data_mssql($text) -{ - $data = preg_split('/[\n\t\r\b\f]/', $text); - preg_match_all('/[\n\t\r\b\f]/', $text, $matches); - - $val = array(); - - foreach ($data as $value) - { - if (strlen($value)) - { - $val[] = "'" . $value . "'"; - } - if (count($matches[0])) - { - $val[] = 'char(' . ord(array_shift($matches[0])) . ')'; - } - } - - return implode('+', $val); -} - -function sanitize_data_oracle($text) -{ -// $data = preg_split('/[\0\n\t\r\b\f\'"\/\\\]/', $text); -// preg_match_all('/[\0\n\t\r\b\f\'"\/\\\]/', $text, $matches); - $data = preg_split('/[\0\b\f\'\/]/', $text); - preg_match_all('/[\0\r\b\f\'\/]/', $text, $matches); - - $val = array(); - - foreach ($data as $value) - { - if (strlen($value)) - { - $val[] = "'" . $value . "'"; - } - if (count($matches[0])) - { - $val[] = 'chr(' . ord(array_shift($matches[0])) . ')'; - } - } - - return implode('||', $val); -} - -function sanitize_data_generic($text) -{ - $data = preg_split('/[\n\t\r\b\f]/', $text); - preg_match_all('/[\n\t\r\b\f]/', $text, $matches); - - $val = array(); - - foreach ($data as $value) - { - if (strlen($value)) - { - $val[] = "'" . $value . "'"; - } - if (count($matches[0])) - { - $val[] = "'" . array_shift($matches[0]) . "'"; - } - } - - return implode('||', $val); -} - -// modified from PHP.net -function fgetd(&$fp, $delim, $read, $seek, $eof, $buffer = 8192) -{ - $record = ''; - $delim_len = strlen($delim); - - while (!$eof($fp)) - { - $pos = strpos($record, $delim); - if ($pos === false) - { - $record .= $read($fp, $buffer); - if ($eof($fp) && ($pos = strpos($record, $delim)) !== false) - { - $seek($fp, $pos + $delim_len - strlen($record), SEEK_CUR); - return substr($record, 0, $pos); - } - } - else - { - $seek($fp, $pos + $delim_len - strlen($record), SEEK_CUR); - return substr($record, 0, $pos); - } - } - - return false; -} - -function fgetd_seekless(&$fp, $delim, $read, $seek, $eof, $buffer = 8192) -{ - static $array = array(); - static $record = ''; - - if (!count($array)) - { - while (!$eof($fp)) - { - if (strpos($record, $delim) !== false) - { - $array = explode($delim, $record); - $record = array_pop($array); - break; - } - else - { - $record .= $read($fp, $buffer); - } - } - if ($eof($fp) && strpos($record, $delim) !== false) - { - $array = explode($delim, $record); - $record = array_pop($array); - } - } - - if (count($array)) - { - return array_shift($array); - } - - return false; -} diff --git a/install/update/new/includes/acp/acp_extensions.php b/install/update/new/includes/acp/acp_extensions.php deleted file mode 100644 index 8696654..0000000 --- a/install/update/new/includes/acp/acp_extensions.php +++ /dev/null @@ -1,771 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -use phpbb\exception\exception_interface; -use phpbb\exception\version_check_exception; - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -class acp_extensions -{ - var $u_action; - var $tpl_name; - var $page_title; - - private $config; - private $template; - private $user; - private $log; - private $request; - private $phpbb_dispatcher; - private $ext_manager; - private $phpbb_container; - private $php_ini; - - function main($id, $mode) - { - // Start the page - global $config, $user, $template, $request, $phpbb_extension_manager, $phpbb_root_path, $phpbb_log, $phpbb_dispatcher, $phpbb_container; - - $this->config = $config; - $this->template = $template; - $this->user = $user; - $this->request = $request; - $this->log = $phpbb_log; - $this->phpbb_dispatcher = $phpbb_dispatcher; - $this->ext_manager = $phpbb_extension_manager; - $this->phpbb_container = $phpbb_container; - $this->php_ini = $this->phpbb_container->get('php_ini'); - - $this->user->add_lang(array('install', 'acp/extensions', 'migrator')); - - $this->page_title = 'ACP_EXTENSIONS'; - - $action = $this->request->variable('action', 'list'); - $ext_name = $this->request->variable('ext_name', ''); - - // What is a safe limit of execution time? Half the max execution time should be safe. - $safe_time_limit = ($this->php_ini->getNumeric('max_execution_time') / 2); - $start_time = time(); - - // Cancel action - if ($this->request->is_set_post('cancel')) - { - $action = 'list'; - $ext_name = ''; - } - - if (in_array($action, array('enable', 'disable', 'delete_data')) && !check_link_hash($this->request->variable('hash', ''), $action . '.' . $ext_name)) - { - trigger_error('FORM_INVALID', E_USER_WARNING); - } - - /** - * Event to run a specific action on extension - * - * @event core.acp_extensions_run_action_before - * @var string action Action to run; if the event completes execution of the action, should be set to 'none' - * @var string u_action Url we are at - * @var string ext_name Extension name from request - * @var int safe_time_limit Safe limit of execution time - * @var int start_time Start time - * @var string tpl_name Template file to load - * @since 3.1.11-RC1 - * @changed 3.2.1-RC1 Renamed to core.acp_extensions_run_action_before, added tpl_name, added action 'none' - */ - $u_action = $this->u_action; - $tpl_name = ''; - $vars = array('action', 'u_action', 'ext_name', 'safe_time_limit', 'start_time', 'tpl_name'); - extract($this->phpbb_dispatcher->trigger_event('core.acp_extensions_run_action_before', compact($vars))); - - // In case they have been updated by the event - $this->u_action = $u_action; - $this->tpl_name = $tpl_name; - - // If they've specified an extension, let's load the metadata manager and validate it. - if ($ext_name) - { - $md_manager = $this->ext_manager->create_extension_metadata_manager($ext_name); - - try - { - $md_manager->get_metadata('all'); - } - catch (exception_interface $e) - { - $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters())); - trigger_error($message . adm_back_link($this->u_action), E_USER_WARNING); - } - } - - // What are we doing? - switch ($action) - { - case 'none': - // Intentionally empty, used by extensions that execute additional actions in the prior event - break; - - case 'set_config_version_check_force_unstable': - $force_unstable = $this->request->variable('force_unstable', false); - - if ($force_unstable) - { - $s_hidden_fields = build_hidden_fields(array( - 'force_unstable' => $force_unstable, - )); - - confirm_box(false, $this->user->lang('EXTENSION_FORCE_UNSTABLE_CONFIRM'), $s_hidden_fields); - } - else - { - $this->config->set('extension_force_unstable', false); - trigger_error($this->user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action)); - } - break; - - case 'list': - default: - if (confirm_box(true)) - { - $this->config->set('extension_force_unstable', true); - trigger_error($this->user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action)); - } - - $this->list_enabled_exts(); - $this->list_disabled_exts(); - $this->list_available_exts(); - - $this->template->assign_vars(array( - 'U_VERSIONCHECK_FORCE' => $this->u_action . '&action=list&versioncheck_force=1', - 'FORCE_UNSTABLE' => $this->config['extension_force_unstable'], - 'U_ACTION' => $this->u_action, - )); - - $this->tpl_name = 'acp_ext_list'; - break; - - case 'enable_pre': - try - { - $md_manager->validate_enable(); - } - catch (exception_interface $e) - { - $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters())); - trigger_error($message . adm_back_link($this->u_action), E_USER_WARNING); - } - - $extension = $this->ext_manager->get_extension($ext_name); - - $this->check_is_enableable($extension); - - if ($this->ext_manager->is_enabled($ext_name)) - { - redirect($this->u_action); - } - - if (confirm_box(true)) - { - redirect($this->u_action . '&action=enable&ext_name=' . urlencode($ext_name) . '&hash=' . generate_link_hash('enable.' . $ext_name)); - } - else - { - confirm_box(false, $this->user->lang('EXTENSION_ENABLE_CONFIRM', $md_manager->get_metadata('display-name')), build_hidden_fields(array( - 'i' => $id, - 'mode' => $mode, - 'action' => 'enable_pre', - 'ext_name' => $ext_name, - ))); - } - break; - - case 'enable': - try - { - $md_manager->validate_enable(); - } - catch (exception_interface $e) - { - $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters())); - trigger_error($message . adm_back_link($this->u_action), E_USER_WARNING); - } - - $extension = $this->ext_manager->get_extension($ext_name); - - $this->check_is_enableable($extension); - - try - { - while ($this->ext_manager->enable_step($ext_name)) - { - // Are we approaching the time limit? If so we want to pause the update and continue after refreshing - if ((time() - $start_time) >= $safe_time_limit) - { - meta_refresh(0, $this->u_action . '&action=enable&ext_name=' . urlencode($ext_name) . '&hash=' . generate_link_hash('enable.' . $ext_name)); - trigger_error('EXTENSION_ENABLE_IN_PROGRESS', E_USER_NOTICE); - } - } - - // Update custom style for admin area - $this->template->set_custom_style(array( - array( - 'name' => 'adm', - 'ext_path' => 'adm/style/', - ), - ), array($phpbb_root_path . 'adm/style')); - - $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_EXT_ENABLE', time(), array($ext_name)); - } - catch (\phpbb\db\migration\exception $e) - { - trigger_error($this->user->lang('MIGRATION_EXCEPTION_ERROR', $e->getLocalisedMessage($this->user)), E_USER_WARNING); - } - - if ($this->request->is_ajax()) - { - $actions = $this->output_actions('enabled', [ - 'DISABLE' => $this->u_action . '&action=disable_pre&ext_name=' . urlencode($ext_name), - ]); - - $data = [ - 'EXT_ENABLE_SUCCESS' => true, - 'ACTIONS' => $actions, - 'REFRESH_DATA' => [ - 'url' => '', - 'time' => 0, - ], - ]; - - $json_response = new \phpbb\json_response; - $json_response->send($data); - } - - trigger_error($this->user->lang('EXTENSION_ENABLE_SUCCESS') . adm_back_link($this->u_action), E_USER_NOTICE); - break; - - case 'disable_pre': - if (!$this->ext_manager->is_enabled($ext_name)) - { - redirect($this->u_action); - } - - if (confirm_box(true)) - { - redirect($this->u_action . '&action=disable&ext_name=' . urlencode($ext_name) . '&hash=' . generate_link_hash('disable.' . $ext_name)); - } - else - { - confirm_box(false, $this->user->lang('EXTENSION_DISABLE_CONFIRM', $md_manager->get_metadata('display-name')), build_hidden_fields(array( - 'i' => $id, - 'mode' => $mode, - 'action' => 'disable_pre', - 'ext_name' => $ext_name, - ))); - } - break; - - case 'disable': - if (!$this->ext_manager->is_enabled($ext_name)) - { - redirect($this->u_action); - } - - while ($this->ext_manager->disable_step($ext_name)) - { - // Are we approaching the time limit? If so we want to pause the update and continue after refreshing - if ((time() - $start_time) >= $safe_time_limit) - { - $this->template->assign_var('S_NEXT_STEP', true); - - meta_refresh(0, $this->u_action . '&action=disable&ext_name=' . urlencode($ext_name) . '&hash=' . generate_link_hash('disable.' . $ext_name)); - trigger_error('EXTENSION_DISABLE_IN_PROGRESS', E_USER_NOTICE); - } - } - $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_EXT_DISABLE', time(), array($ext_name)); - - if ($this->request->is_ajax()) - { - $actions = $this->output_actions('disabled', [ - 'ENABLE' => $this->u_action . '&action=enable_pre&ext_name=' . urlencode($ext_name), - 'DELETE_DATA' => $this->u_action . '&action=delete_data_pre&ext_name=' . urlencode($ext_name), - ]); - - $data = [ - 'EXT_DISABLE_SUCCESS' => true, - 'ACTIONS' => $actions, - 'REFRESH_DATA' => [ - 'url' => '', - 'time' => 0, - ], - ]; - - $json_response = new \phpbb\json_response; - $json_response->send($data); - } - - trigger_error($this->user->lang('EXTENSION_DISABLE_SUCCESS') . adm_back_link($this->u_action), E_USER_NOTICE); - break; - - case 'delete_data_pre': - if ($this->ext_manager->is_enabled($ext_name)) - { - redirect($this->u_action); - } - - if (confirm_box(true)) - { - redirect($this->u_action . '&action=delete_data&ext_name=' . urlencode($ext_name) . '&hash=' . generate_link_hash('delete_data.' . $ext_name)); - } - else - { - confirm_box(false, $this->user->lang('EXTENSION_DELETE_DATA_CONFIRM', $md_manager->get_metadata('display-name')), build_hidden_fields(array( - 'i' => $id, - 'mode' => $mode, - 'action' => 'delete_data_pre', - 'ext_name' => $ext_name, - ))); - } - break; - - case 'delete_data': - if ($this->ext_manager->is_enabled($ext_name)) - { - redirect($this->u_action); - } - - try - { - while ($this->ext_manager->purge_step($ext_name)) - { - // Are we approaching the time limit? If so we want to pause the update and continue after refreshing - if ((time() - $start_time) >= $safe_time_limit) - { - $this->template->assign_var('S_NEXT_STEP', true); - - meta_refresh(0, $this->u_action . '&action=delete_data&ext_name=' . urlencode($ext_name) . '&hash=' . generate_link_hash('delete_data.' . $ext_name)); - trigger_error('EXTENSION_DELETE_DATA_IN_PROGRESS', E_USER_NOTICE); - } - } - $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_EXT_PURGE', time(), array($ext_name)); - } - catch (\phpbb\db\migration\exception $e) - { - trigger_error($this->user->lang('MIGRATION_EXCEPTION_ERROR', $e->getLocalisedMessage($this->user)), E_USER_WARNING); - } - - if ($this->request->is_ajax()) - { - $actions = $this->output_actions('disabled', [ - 'ENABLE' => $this->u_action . '&action=enable_pre&ext_name=' . urlencode($ext_name), - ]); - - $data = [ - 'EXT_DELETE_DATA_SUCCESS' => true, - 'ACTIONS' => $actions, - 'REFRESH_DATA' => [ - 'url' => '', - 'time' => 0, - ], - ]; - - $json_response = new \phpbb\json_response; - $json_response->send($data); - } - - trigger_error($this->user->lang('EXTENSION_DELETE_DATA_SUCCESS') . adm_back_link($this->u_action), E_USER_NOTICE); - break; - - case 'details': - // Output it to the template - $meta = $md_manager->get_metadata('all'); - $this->output_metadata_to_template($meta); - - if (isset($meta['extra']['version-check'])) - { - try - { - $updates_available = $this->ext_manager->version_check($md_manager, $this->request->variable('versioncheck_force', false), false, $this->config['extension_force_unstable'] ? 'unstable' : null); - - $this->template->assign_vars(array( - 'S_UP_TO_DATE' => empty($updates_available), - 'UP_TO_DATE_MSG' => $this->user->lang(empty($updates_available) ? 'UP_TO_DATE' : 'NOT_UP_TO_DATE', $md_manager->get_metadata('display-name')), - )); - - $this->template->assign_block_vars('updates_available', $updates_available); - } - catch (exception_interface $e) - { - $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters())); - - $this->template->assign_vars(array( - 'S_VERSIONCHECK_FAIL' => true, - 'VERSIONCHECK_FAIL_REASON' => ($e->getMessage() !== 'VERSIONCHECK_FAIL') ? $message : '', - )); - } - $this->template->assign_var('S_VERSIONCHECK', true); - } - else - { - $this->template->assign_var('S_VERSIONCHECK', false); - } - - $this->template->assign_vars(array( - 'U_BACK' => $this->u_action . '&action=list', - 'U_VERSIONCHECK_FORCE' => $this->u_action . '&action=details&versioncheck_force=1&ext_name=' . urlencode($md_manager->get_metadata('name')), - )); - - $this->tpl_name = 'acp_ext_details'; - break; - } - - /** - * Event to run after a specific action on extension has completed - * - * @event core.acp_extensions_run_action_after - * @var string action Action that has run - * @var string u_action Url we are at - * @var string ext_name Extension name from request - * @var int safe_time_limit Safe limit of execution time - * @var int start_time Start time - * @var string tpl_name Template file to load - * @since 3.1.11-RC1 - */ - $u_action = $this->u_action; - $tpl_name = $this->tpl_name; - $vars = array('action', 'u_action', 'ext_name', 'safe_time_limit', 'start_time', 'tpl_name'); - extract($this->phpbb_dispatcher->trigger_event('core.acp_extensions_run_action_after', compact($vars))); - - // In case they have been updated by the event - $this->u_action = $u_action; - $this->tpl_name = $tpl_name; - } - - /** - * Lists all the enabled extensions and dumps to the template - * - * @return null - */ - public function list_enabled_exts() - { - $enabled_extension_meta_data = array(); - - foreach ($this->ext_manager->all_enabled() as $name => $location) - { - $md_manager = $this->ext_manager->create_extension_metadata_manager($name); - - try - { - $meta = $md_manager->get_metadata('all'); - $enabled_extension_meta_data[$name] = array( - 'META_DISPLAY_NAME' => $md_manager->get_metadata('display-name'), - 'META_VERSION' => $meta['version'], - ); - - if (isset($meta['extra']['version-check'])) - { - try - { - $force_update = $this->request->variable('versioncheck_force', false); - $updates = $this->ext_manager->version_check($md_manager, $force_update, !$force_update); - - $enabled_extension_meta_data[$name]['S_UP_TO_DATE'] = empty($updates); - $enabled_extension_meta_data[$name]['S_VERSIONCHECK'] = true; - $enabled_extension_meta_data[$name]['U_VERSIONCHECK_FORCE'] = $this->u_action . '&action=details&versioncheck_force=1&ext_name=' . urlencode($md_manager->get_metadata('name')); - } - catch (exception_interface $e) - { - // Ignore exceptions due to the version check - } - } - else - { - $enabled_extension_meta_data[$name]['S_VERSIONCHECK'] = false; - } - } - catch (exception_interface $e) - { - $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters())); - $this->template->assign_block_vars('disabled', array( - 'META_DISPLAY_NAME' => $this->user->lang('EXTENSION_INVALID_LIST', $name, $message), - 'S_VERSIONCHECK' => false, - )); - } - catch (\RuntimeException $e) - { - $enabled_extension_meta_data[$name]['S_VERSIONCHECK'] = false; - } - } - - uasort($enabled_extension_meta_data, array($this, 'sort_extension_meta_data_table')); - - foreach ($enabled_extension_meta_data as $name => $block_vars) - { - $block_vars['NAME'] = $name; - $block_vars['U_DETAILS'] = $this->u_action . '&action=details&ext_name=' . urlencode($name); - - $this->template->assign_block_vars('enabled', $block_vars); - - $this->output_actions('enabled', array( - 'DISABLE' => $this->u_action . '&action=disable_pre&ext_name=' . urlencode($name), - )); - } - } - - /** - * Lists all the disabled extensions and dumps to the template - * - * @return null - */ - public function list_disabled_exts() - { - $disabled_extension_meta_data = array(); - - foreach ($this->ext_manager->all_disabled() as $name => $location) - { - $md_manager = $this->ext_manager->create_extension_metadata_manager($name); - - try - { - $meta = $md_manager->get_metadata('all'); - $disabled_extension_meta_data[$name] = array( - 'META_DISPLAY_NAME' => $md_manager->get_metadata('display-name'), - 'META_VERSION' => $meta['version'], - ); - - if (isset($meta['extra']['version-check'])) - { - $force_update = $this->request->variable('versioncheck_force', false); - $updates = $this->ext_manager->version_check($md_manager, $force_update, !$force_update); - - $disabled_extension_meta_data[$name]['S_UP_TO_DATE'] = empty($updates); - $disabled_extension_meta_data[$name]['S_VERSIONCHECK'] = true; - $disabled_extension_meta_data[$name]['U_VERSIONCHECK_FORCE'] = $this->u_action . '&action=details&versioncheck_force=1&ext_name=' . urlencode($md_manager->get_metadata('name')); - } - else - { - $disabled_extension_meta_data[$name]['S_VERSIONCHECK'] = false; - } - } - catch (version_check_exception $e) - { - $disabled_extension_meta_data[$name]['S_VERSIONCHECK'] = false; - } - catch (exception_interface $e) - { - $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters())); - $this->template->assign_block_vars('disabled', array( - 'META_DISPLAY_NAME' => $this->user->lang('EXTENSION_INVALID_LIST', $name, $message), - 'S_VERSIONCHECK' => false, - )); - } - catch (\RuntimeException $e) - { - $disabled_extension_meta_data[$name]['S_VERSIONCHECK'] = false; - } - } - - uasort($disabled_extension_meta_data, array($this, 'sort_extension_meta_data_table')); - - foreach ($disabled_extension_meta_data as $name => $block_vars) - { - $block_vars['NAME'] = $name; - $block_vars['U_DETAILS'] = $this->u_action . '&action=details&ext_name=' . urlencode($name); - - $this->template->assign_block_vars('disabled', $block_vars); - - $this->output_actions('disabled', array( - 'ENABLE' => $this->u_action . '&action=enable_pre&ext_name=' . urlencode($name), - 'DELETE_DATA' => $this->u_action . '&action=delete_data_pre&ext_name=' . urlencode($name), - )); - } - } - - /** - * Lists all the available extensions and dumps to the template - * - * @return null - */ - public function list_available_exts() - { - $uninstalled = array_diff_key($this->ext_manager->all_available(), $this->ext_manager->all_configured()); - - $available_extension_meta_data = array(); - - foreach ($uninstalled as $name => $location) - { - $md_manager = $this->ext_manager->create_extension_metadata_manager($name); - - try - { - $meta = $md_manager->get_metadata('all'); - $available_extension_meta_data[$name] = array( - 'META_DISPLAY_NAME' => $md_manager->get_metadata('display-name'), - 'META_VERSION' => $meta['version'], - ); - - if (isset($meta['extra']['version-check'])) - { - $force_update = $this->request->variable('versioncheck_force', false); - $updates = $this->ext_manager->version_check($md_manager, $force_update, !$force_update); - - $available_extension_meta_data[$name]['S_UP_TO_DATE'] = empty($updates); - $available_extension_meta_data[$name]['S_VERSIONCHECK'] = true; - $available_extension_meta_data[$name]['U_VERSIONCHECK_FORCE'] = $this->u_action . '&action=details&versioncheck_force=1&ext_name=' . urlencode($md_manager->get_metadata('name')); - } - else - { - $available_extension_meta_data[$name]['S_VERSIONCHECK'] = false; - } - } - catch (version_check_exception $e) - { - $available_extension_meta_data[$name]['S_VERSIONCHECK'] = false; - } - catch (exception_interface $e) - { - $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters())); - $this->template->assign_block_vars('disabled', array( - 'META_DISPLAY_NAME' => $this->user->lang('EXTENSION_INVALID_LIST', $name, $message), - 'S_VERSIONCHECK' => false, - )); - } - } - - uasort($available_extension_meta_data, array($this, 'sort_extension_meta_data_table')); - - foreach ($available_extension_meta_data as $name => $block_vars) - { - $block_vars['NAME'] = $name; - $block_vars['U_DETAILS'] = $this->u_action . '&action=details&ext_name=' . urlencode($name); - - $this->template->assign_block_vars('disabled', $block_vars); - - $this->output_actions('disabled', array( - 'ENABLE' => $this->u_action . '&action=enable_pre&ext_name=' . urlencode($name), - )); - } - } - - /** - * Output actions to a block - * - * @param string $block - * @param array $actions - * @return array List of actions to be performed on the extension - */ - private function output_actions($block, $actions) - { - $vars_ary = array(); - foreach ($actions as $lang => $options) - { - $url = $options; - if (is_array($options)) - { - $url = $options['url']; - } - - $vars = array( - 'L_ACTION' => $this->user->lang('EXTENSION_' . $lang), - 'L_ACTION_EXPLAIN' => (isset($this->user->lang['EXTENSION_' . $lang . '_EXPLAIN'])) ? $this->user->lang('EXTENSION_' . $lang . '_EXPLAIN') : '', - 'U_ACTION' => $url, - 'ACTION_AJAX' => 'ext_' . strtolower($lang), - ); - - if (isset($options['color'])) - { - $vars['COLOR'] = $options['color']; - } - - $this->template->assign_block_vars($block . '.actions', $vars); - - $vars_ary[] = $vars; - } - - return $vars_ary; - } - - /** - * Sort helper for the table containing the metadata about the extensions. - */ - protected function sort_extension_meta_data_table($val1, $val2) - { - return strnatcasecmp($val1['META_DISPLAY_NAME'], $val2['META_DISPLAY_NAME']); - } - - /** - * Outputs extension metadata into the template - * - * @param array $metadata Array with all metadata for the extension - * @return null - */ - public function output_metadata_to_template($metadata) - { - $this->template->assign_vars(array( - 'META_NAME' => $metadata['name'], - 'META_TYPE' => $metadata['type'], - 'META_DESCRIPTION' => (isset($metadata['description'])) ? $metadata['description'] : '', - 'META_HOMEPAGE' => (isset($metadata['homepage'])) ? $metadata['homepage'] : '', - 'META_VERSION' => $metadata['version'], - 'META_TIME' => (isset($metadata['time'])) ? $metadata['time'] : '', - 'META_LICENSE' => $metadata['license'], - - 'META_REQUIRE_PHP' => (isset($metadata['require']['php'])) ? $metadata['require']['php'] : '', - 'META_REQUIRE_PHP_FAIL' => (isset($metadata['require']['php'])) ? false : true, - - 'META_REQUIRE_PHPBB' => (isset($metadata['extra']['soft-require']['phpbb/phpbb'])) ? $metadata['extra']['soft-require']['phpbb/phpbb'] : '', - 'META_REQUIRE_PHPBB_FAIL' => (isset($metadata['extra']['soft-require']['phpbb/phpbb'])) ? false : true, - - 'META_DISPLAY_NAME' => (isset($metadata['extra']['display-name'])) ? $metadata['extra']['display-name'] : '', - )); - - foreach ($metadata['authors'] as $author) - { - $this->template->assign_block_vars('meta_authors', array( - 'AUTHOR_NAME' => $author['name'], - 'AUTHOR_EMAIL' => (isset($author['email'])) ? $author['email'] : '', - 'AUTHOR_HOMEPAGE' => (isset($author['homepage'])) ? $author['homepage'] : '', - 'AUTHOR_ROLE' => (isset($author['role'])) ? $author['role'] : '', - )); - } - } - - /** - * Checks whether the extension can be enabled. Triggers error if not. - * Error message can be set by the extension. - * - * @param \phpbb\extension\extension_interface $extension Extension to check - */ - protected function check_is_enableable(\phpbb\extension\extension_interface $extension) - { - $message = $extension->is_enableable(); - if ($message !== true) - { - if (empty($message)) - { - $message = $this->user->lang('EXTENSION_NOT_ENABLEABLE'); - } - else if (is_array($message)) - { - $message = implode('
', $message); - } - - trigger_error($message . adm_back_link($this->u_action), E_USER_WARNING); - } - } -} diff --git a/install/update/new/includes/acp/acp_forums.php b/install/update/new/includes/acp/acp_forums.php deleted file mode 100644 index ba3901f..0000000 --- a/install/update/new/includes/acp/acp_forums.php +++ /dev/null @@ -1,2211 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -class acp_forums -{ - var $u_action; - var $parent_id = 0; - - function main($id, $mode) - { - global $db, $user, $auth, $template, $cache, $request, $phpbb_dispatcher; - global $phpbb_admin_path, $phpbb_root_path, $phpEx, $phpbb_log; - - $user->add_lang('acp/forums'); - $this->tpl_name = 'acp_forums'; - $this->page_title = 'ACP_MANAGE_FORUMS'; - - $form_key = 'acp_forums'; - add_form_key($form_key); - - $action = $request->variable('action', ''); - $update = (isset($_POST['update'])) ? true : false; - $forum_id = $request->variable('f', 0); - - $this->parent_id = $request->variable('parent_id', 0); - $forum_data = $errors = array(); - if ($update && !check_form_key($form_key)) - { - $update = false; - $errors[] = $user->lang['FORM_INVALID']; - } - - // Check additional permissions - switch ($action) - { - case 'progress_bar': - $start = $request->variable('start', 0); - $total = $request->variable('total', 0); - - $this->display_progress_bar($start, $total); - break; - - case 'delete': - - if (!$auth->acl_get('a_forumdel')) - { - trigger_error($user->lang['NO_PERMISSION_FORUM_DELETE'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); - } - - break; - - case 'add': - - if (!$auth->acl_get('a_forumadd')) - { - trigger_error($user->lang['NO_PERMISSION_FORUM_ADD'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); - } - - break; - } - - // Major routines - if ($update) - { - switch ($action) - { - case 'delete': - $action_subforums = $request->variable('action_subforums', ''); - $subforums_to_id = $request->variable('subforums_to_id', 0); - $action_posts = $request->variable('action_posts', ''); - $posts_to_id = $request->variable('posts_to_id', 0); - - $errors = $this->delete_forum($forum_id, $action_posts, $action_subforums, $posts_to_id, $subforums_to_id); - - if (count($errors)) - { - break; - } - - $auth->acl_clear_prefetch(); - $cache->destroy('sql', FORUMS_TABLE); - - trigger_error($user->lang['FORUM_DELETED'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id)); - - break; - - case 'edit': - $forum_data = array( - 'forum_id' => $forum_id - ); - - // No break here - - case 'add': - - $forum_data += array( - 'parent_id' => $request->variable('forum_parent_id', $this->parent_id), - 'forum_type' => $request->variable('forum_type', FORUM_POST), - 'type_action' => $request->variable('type_action', ''), - 'forum_status' => $request->variable('forum_status', ITEM_UNLOCKED), - 'forum_parents' => '', - 'forum_name' => $request->variable('forum_name', '', true), - 'forum_link' => $request->variable('forum_link', ''), - 'forum_link_track' => $request->variable('forum_link_track', false), - 'forum_desc' => $request->variable('forum_desc', '', true), - 'forum_desc_uid' => '', - 'forum_desc_options' => 7, - 'forum_desc_bitfield' => '', - 'forum_rules' => $request->variable('forum_rules', '', true), - 'forum_rules_uid' => '', - 'forum_rules_options' => 7, - 'forum_rules_bitfield' => '', - 'forum_rules_link' => $request->variable('forum_rules_link', ''), - 'forum_image' => $request->variable('forum_image', ''), - 'forum_style' => $request->variable('forum_style', 0), - 'display_subforum_list' => $request->variable('display_subforum_list', true), - 'display_subforum_limit'=> $request->variable('display_subforum_limit', false), - 'display_on_index' => $request->variable('display_on_index', true), - 'forum_topics_per_page' => $request->variable('topics_per_page', 0), - 'enable_indexing' => $request->variable('enable_indexing', true), - 'enable_icons' => $request->variable('enable_icons', true), - 'enable_prune' => $request->variable('enable_prune', false), - 'enable_post_review' => $request->variable('enable_post_review', true), - 'enable_quick_reply' => $request->variable('enable_quick_reply', false), - 'enable_shadow_prune' => $request->variable('enable_shadow_prune', false), - 'prune_days' => $request->variable('prune_days', 7), - 'prune_viewed' => $request->variable('prune_viewed', 7), - 'prune_freq' => $request->variable('prune_freq', 1), - 'prune_old_polls' => $request->variable('prune_old_polls', false), - 'prune_announce' => $request->variable('prune_announce', false), - 'prune_sticky' => $request->variable('prune_sticky', false), - 'prune_shadow_days' => $request->variable('prune_shadow_days', 7), - 'prune_shadow_freq' => $request->variable('prune_shadow_freq', 1), - 'forum_password' => $request->variable('forum_password', '', true), - 'forum_password_confirm'=> $request->variable('forum_password_confirm', '', true), - 'forum_password_unset' => $request->variable('forum_password_unset', false), - ); - - /** - * Request forum data and operate on it (parse texts, etc.) - * - * @event core.acp_manage_forums_request_data - * @var string action Type of the action: add|edit - * @var array forum_data Array with new forum data - * @since 3.1.0-a1 - */ - $vars = array('action', 'forum_data'); - extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_request_data', compact($vars))); - - // On add, add empty forum_options... else do not consider it (not updating it) - if ($action == 'add') - { - $forum_data['forum_options'] = 0; - } - - // Use link_display_on_index setting if forum type is link - if ($forum_data['forum_type'] == FORUM_LINK) - { - $forum_data['display_on_index'] = $request->variable('link_display_on_index', false); - } - - // Linked forums and categories are not able to be locked... - if ($forum_data['forum_type'] == FORUM_LINK || $forum_data['forum_type'] == FORUM_CAT) - { - $forum_data['forum_status'] = ITEM_UNLOCKED; - } - - $forum_data['show_active'] = ($forum_data['forum_type'] == FORUM_POST) ? $request->variable('display_recent', true) : $request->variable('display_active', false); - - // Get data for forum rules if specified... - if ($forum_data['forum_rules']) - { - generate_text_for_storage($forum_data['forum_rules'], $forum_data['forum_rules_uid'], $forum_data['forum_rules_bitfield'], $forum_data['forum_rules_options'], $request->variable('rules_parse_bbcode', false), $request->variable('rules_parse_urls', false), $request->variable('rules_parse_smilies', false)); - } - - // Get data for forum description if specified - if ($forum_data['forum_desc']) - { - generate_text_for_storage($forum_data['forum_desc'], $forum_data['forum_desc_uid'], $forum_data['forum_desc_bitfield'], $forum_data['forum_desc_options'], $request->variable('desc_parse_bbcode', false), $request->variable('desc_parse_urls', false), $request->variable('desc_parse_smilies', false)); - } - - $errors = $this->update_forum_data($forum_data); - - if (!count($errors)) - { - $forum_perm_from = $request->variable('forum_perm_from', 0); - $cache->destroy('sql', FORUMS_TABLE); - - $copied_permissions = false; - // Copy permissions? - if ($forum_perm_from && $forum_perm_from != $forum_data['forum_id'] && - ($action != 'edit' || empty($forum_id) || ($auth->acl_get('a_fauth') && $auth->acl_get('a_authusers') && $auth->acl_get('a_authgroups') && $auth->acl_get('a_mauth')))) - { - copy_forum_permissions($forum_perm_from, $forum_data['forum_id'], ($action == 'edit') ? true : false); - phpbb_cache_moderators($db, $cache, $auth); - $copied_permissions = true; - } -/* Commented out because of questionable UI workflow - re-visit for 3.0.7 - else if (!$this->parent_id && $action != 'edit' && $auth->acl_get('a_fauth') && $auth->acl_get('a_authusers') && $auth->acl_get('a_authgroups') && $auth->acl_get('a_mauth')) - { - $this->copy_permission_page($forum_data); - return; - } -*/ - $auth->acl_clear_prefetch(); - - $acl_url = '&mode=setting_forum_local&forum_id[]=' . $forum_data['forum_id']; - - $message = ($action == 'add') ? $user->lang['FORUM_CREATED'] : $user->lang['FORUM_UPDATED']; - - // redirect directly to permission settings screen if authed - if ($action == 'add' && !$copied_permissions && $auth->acl_get('a_fauth')) - { - $message .= '

' . sprintf($user->lang['REDIRECT_ACL'], '', ''); - - meta_refresh(4, append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions' . $acl_url)); - } - - trigger_error($message . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id)); - } - - break; - } - } - - switch ($action) - { - case 'move_up': - case 'move_down': - - if (!$forum_id) - { - trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); - } - - $sql = 'SELECT * - FROM ' . FORUMS_TABLE . " - WHERE forum_id = $forum_id"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); - } - - $move_forum_name = $this->move_forum_by($row, $action, 1); - - if ($move_forum_name !== false) - { - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_' . strtoupper($action), false, array($row['forum_name'], $move_forum_name)); - $cache->destroy('sql', FORUMS_TABLE); - } - - if ($request->is_ajax()) - { - $json_response = new \phpbb\json_response; - $json_response->send(array('success' => ($move_forum_name !== false))); - } - - break; - - case 'sync': - if (!$forum_id) - { - trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); - } - - @set_time_limit(0); - - $sql = 'SELECT forum_name, (forum_topics_approved + forum_topics_unapproved + forum_topics_softdeleted) AS total_topics - FROM ' . FORUMS_TABLE . " - WHERE forum_id = $forum_id"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); - } - - if ($row['total_topics']) - { - $sql = 'SELECT MIN(topic_id) as min_topic_id, MAX(topic_id) as max_topic_id - FROM ' . TOPICS_TABLE . ' - WHERE forum_id = ' . $forum_id; - $result = $db->sql_query($sql); - $row2 = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - // Typecast to int if there is no data available - $row2['min_topic_id'] = (int) $row2['min_topic_id']; - $row2['max_topic_id'] = (int) $row2['max_topic_id']; - - $start = $request->variable('start', $row2['min_topic_id']); - - $batch_size = 2000; - $end = $start + $batch_size; - - // Sync all topics in batch mode... - sync('topic', 'range', 'topic_id BETWEEN ' . $start . ' AND ' . $end, true, true); - - if ($end < $row2['max_topic_id']) - { - // We really need to find a way of showing statistics... no progress here - $sql = 'SELECT COUNT(topic_id) as num_topics - FROM ' . TOPICS_TABLE . ' - WHERE forum_id = ' . $forum_id . ' - AND topic_id BETWEEN ' . $start . ' AND ' . $end; - $result = $db->sql_query($sql); - $topics_done = $request->variable('topics_done', 0) + (int) $db->sql_fetchfield('num_topics'); - $db->sql_freeresult($result); - - $start += $batch_size; - - $url = $this->u_action . "&parent_id={$this->parent_id}&f=$forum_id&action=sync&start=$start&topics_done=$topics_done&total={$row['total_topics']}"; - - meta_refresh(0, $url); - - $template->assign_vars(array( - 'U_PROGRESS_BAR' => $this->u_action . "&action=progress_bar&start=$topics_done&total={$row['total_topics']}", - 'UA_PROGRESS_BAR' => addslashes($this->u_action . "&action=progress_bar&start=$topics_done&total={$row['total_topics']}"), - 'S_CONTINUE_SYNC' => true, - 'L_PROGRESS_EXPLAIN' => sprintf($user->lang['SYNC_IN_PROGRESS_EXPLAIN'], $topics_done, $row['total_topics'])) - ); - - return; - } - } - - $url = $this->u_action . "&parent_id={$this->parent_id}&f=$forum_id&action=sync_forum"; - meta_refresh(0, $url); - - $template->assign_vars(array( - 'U_PROGRESS_BAR' => $this->u_action . '&action=progress_bar', - 'UA_PROGRESS_BAR' => addslashes($this->u_action . '&action=progress_bar'), - 'S_CONTINUE_SYNC' => true, - 'L_PROGRESS_EXPLAIN' => sprintf($user->lang['SYNC_IN_PROGRESS_EXPLAIN'], 0, $row['total_topics'])) - ); - - return; - - break; - - case 'sync_forum': - - $sql = 'SELECT forum_name, forum_type - FROM ' . FORUMS_TABLE . " - WHERE forum_id = $forum_id"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); - } - - sync('forum', 'forum_id', $forum_id, false, true); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_SYNC', false, array($row['forum_name'])); - - $cache->destroy('sql', FORUMS_TABLE); - - $template->assign_var('L_FORUM_RESYNCED', sprintf($user->lang['FORUM_RESYNCED'], $row['forum_name'])); - - break; - - case 'add': - case 'edit': - - if ($update) - { - $forum_data['forum_flags'] = 0; - $forum_data['forum_flags'] += ($request->variable('forum_link_track', false)) ? FORUM_FLAG_LINK_TRACK : 0; - $forum_data['forum_flags'] += ($request->variable('prune_old_polls', false)) ? FORUM_FLAG_PRUNE_POLL : 0; - $forum_data['forum_flags'] += ($request->variable('prune_announce', false)) ? FORUM_FLAG_PRUNE_ANNOUNCE : 0; - $forum_data['forum_flags'] += ($request->variable('prune_sticky', false)) ? FORUM_FLAG_PRUNE_STICKY : 0; - $forum_data['forum_flags'] += ($forum_data['show_active']) ? FORUM_FLAG_ACTIVE_TOPICS : 0; - $forum_data['forum_flags'] += ($request->variable('enable_post_review', true)) ? FORUM_FLAG_POST_REVIEW : 0; - $forum_data['forum_flags'] += ($request->variable('enable_quick_reply', false)) ? FORUM_FLAG_QUICK_REPLY : 0; - } - - // Initialise $row, so we always have it in the event - $row = array(); - - // Show form to create/modify a forum - if ($action == 'edit') - { - $this->page_title = 'EDIT_FORUM'; - $row = $this->get_forum_info($forum_id); - $old_forum_type = $row['forum_type']; - - if (!$update) - { - $forum_data = $row; - } - else - { - $forum_data['left_id'] = $row['left_id']; - $forum_data['right_id'] = $row['right_id']; - } - - // Make sure no direct child forums are able to be selected as parents. - $exclude_forums = array(); - foreach (get_forum_branch($forum_id, 'children') as $row) - { - $exclude_forums[] = $row['forum_id']; - } - - $parents_list = make_forum_select($forum_data['parent_id'], $exclude_forums, false, false, false); - - $forum_data['forum_password_confirm'] = $forum_data['forum_password']; - } - else - { - $this->page_title = 'CREATE_FORUM'; - - $forum_id = $this->parent_id; - $parents_list = make_forum_select($this->parent_id, false, false, false, false); - - // Fill forum data with default values - if (!$update) - { - $forum_data = array( - 'parent_id' => $this->parent_id, - 'forum_type' => FORUM_POST, - 'forum_status' => ITEM_UNLOCKED, - 'forum_name' => $request->variable('forum_name', '', true), - 'forum_link' => '', - 'forum_link_track' => false, - 'forum_desc' => '', - 'forum_rules' => '', - 'forum_rules_link' => '', - 'forum_image' => '', - 'forum_style' => 0, - 'display_subforum_list' => true, - 'display_subforum_limit' => false, - 'display_on_index' => true, - 'forum_topics_per_page' => 0, - 'enable_indexing' => true, - 'enable_icons' => true, - 'enable_prune' => false, - 'prune_days' => 7, - 'prune_viewed' => 7, - 'prune_freq' => 1, - 'enable_shadow_prune' => false, - 'prune_shadow_days' => 7, - 'prune_shadow_freq' => 1, - 'forum_flags' => FORUM_FLAG_POST_REVIEW + FORUM_FLAG_ACTIVE_TOPICS, - 'forum_options' => 0, - 'forum_password' => '', - 'forum_password_confirm'=> '', - ); - } - } - - /** - * Initialise data before we display the add/edit form - * - * @event core.acp_manage_forums_initialise_data - * @var string action Type of the action: add|edit - * @var bool update Do we display the form only - * or did the user press submit - * @var int forum_id When editing: the forum id, - * when creating: the parent forum id - * @var array row Array with current forum data - * empty when creating new forum - * @var array forum_data Array with new forum data - * @var string parents_list List of parent options - * @since 3.1.0-a1 - */ - $vars = array('action', 'update', 'forum_id', 'row', 'forum_data', 'parents_list'); - extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_initialise_data', compact($vars))); - - $forum_rules_data = array( - 'text' => $forum_data['forum_rules'], - 'allow_bbcode' => true, - 'allow_smilies' => true, - 'allow_urls' => true - ); - - $forum_desc_data = array( - 'text' => $forum_data['forum_desc'], - 'allow_bbcode' => true, - 'allow_smilies' => true, - 'allow_urls' => true - ); - - $forum_rules_preview = ''; - - // Parse rules if specified - if ($forum_data['forum_rules']) - { - if (!isset($forum_data['forum_rules_uid'])) - { - // Before we are able to display the preview and plane text, we need to parse our $request->variable()'d value... - $forum_data['forum_rules_uid'] = ''; - $forum_data['forum_rules_bitfield'] = ''; - $forum_data['forum_rules_options'] = 0; - - generate_text_for_storage($forum_data['forum_rules'], $forum_data['forum_rules_uid'], $forum_data['forum_rules_bitfield'], $forum_data['forum_rules_options'], $request->variable('rules_allow_bbcode', false), $request->variable('rules_allow_urls', false), $request->variable('rules_allow_smilies', false)); - } - - // Generate preview content - $forum_rules_preview = generate_text_for_display($forum_data['forum_rules'], $forum_data['forum_rules_uid'], $forum_data['forum_rules_bitfield'], $forum_data['forum_rules_options']); - - // decode... - $forum_rules_data = generate_text_for_edit($forum_data['forum_rules'], $forum_data['forum_rules_uid'], $forum_data['forum_rules_options']); - } - - // Parse desciption if specified - if ($forum_data['forum_desc']) - { - if (!isset($forum_data['forum_desc_uid'])) - { - // Before we are able to display the preview and plane text, we need to parse our $request->variable()'d value... - $forum_data['forum_desc_uid'] = ''; - $forum_data['forum_desc_bitfield'] = ''; - $forum_data['forum_desc_options'] = 0; - - generate_text_for_storage($forum_data['forum_desc'], $forum_data['forum_desc_uid'], $forum_data['forum_desc_bitfield'], $forum_data['forum_desc_options'], $request->variable('desc_allow_bbcode', false), $request->variable('desc_allow_urls', false), $request->variable('desc_allow_smilies', false)); - } - - // decode... - $forum_desc_data = generate_text_for_edit($forum_data['forum_desc'], $forum_data['forum_desc_uid'], $forum_data['forum_desc_options']); - } - - $forum_type_options = ''; - $forum_type_ary = array(FORUM_CAT => 'CAT', FORUM_POST => 'FORUM', FORUM_LINK => 'LINK'); - - foreach ($forum_type_ary as $value => $lang) - { - $forum_type_options .= ''; - } - - $styles_list = style_select($forum_data['forum_style'], true); - - $statuslist = ''; - - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE . ' - WHERE forum_type = ' . FORUM_POST . " - AND forum_id <> $forum_id"; - $result = $db->sql_query_limit($sql, 1); - - $postable_forum_exists = false; - if ($db->sql_fetchrow($result)) - { - $postable_forum_exists = true; - } - $db->sql_freeresult($result); - - // Subforum move options - if ($action == 'edit' && $forum_data['forum_type'] == FORUM_CAT) - { - $subforums_id = array(); - $subforums = get_forum_branch($forum_id, 'children'); - - foreach ($subforums as $row) - { - $subforums_id[] = $row['forum_id']; - } - - $forums_list = make_forum_select($forum_data['parent_id'], $subforums_id); - - if ($postable_forum_exists) - { - $template->assign_vars(array( - 'S_MOVE_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $subforums_id)) // , false, true, false??? - ); - } - - $template->assign_vars(array( - 'S_HAS_SUBFORUMS' => ($forum_data['right_id'] - $forum_data['left_id'] > 1) ? true : false, - 'S_FORUMS_LIST' => $forums_list) - ); - } - else if ($postable_forum_exists) - { - $template->assign_vars(array( - 'S_MOVE_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $forum_id, false, true, false)) - ); - } - - $s_show_display_on_index = false; - - if ($forum_data['parent_id'] > 0) - { - // if this forum is a subforum put the "display on index" checkbox - if ($parent_info = $this->get_forum_info($forum_data['parent_id'])) - { - if ($parent_info['parent_id'] > 0 || $parent_info['forum_type'] == FORUM_CAT) - { - $s_show_display_on_index = true; - } - } - } - - if (strlen($forum_data['forum_password']) == 32) - { - $errors[] = $user->lang['FORUM_PASSWORD_OLD']; - } - - $template_data = array( - 'S_EDIT_FORUM' => true, - 'S_ERROR' => (count($errors)) ? true : false, - 'S_PARENT_ID' => $this->parent_id, - 'S_FORUM_PARENT_ID' => $forum_data['parent_id'], - 'S_ADD_ACTION' => ($action == 'add') ? true : false, - - 'U_BACK' => $this->u_action . '&parent_id=' . $this->parent_id, - 'U_EDIT_ACTION' => $this->u_action . "&parent_id={$this->parent_id}&action=$action&f=$forum_id", - - 'L_COPY_PERMISSIONS_EXPLAIN' => $user->lang['COPY_PERMISSIONS_' . strtoupper($action) . '_EXPLAIN'], - 'L_TITLE' => $user->lang[$this->page_title], - 'ERROR_MSG' => (count($errors)) ? implode('
', $errors) : '', - - 'FORUM_NAME' => $forum_data['forum_name'], - 'FORUM_DATA_LINK' => $forum_data['forum_link'], - 'FORUM_IMAGE' => $forum_data['forum_image'], - 'FORUM_IMAGE_SRC' => ($forum_data['forum_image']) ? $phpbb_root_path . $forum_data['forum_image'] : '', - 'FORUM_POST' => FORUM_POST, - 'FORUM_LINK' => FORUM_LINK, - 'FORUM_CAT' => FORUM_CAT, - 'PRUNE_FREQ' => $forum_data['prune_freq'], - 'PRUNE_DAYS' => $forum_data['prune_days'], - 'PRUNE_VIEWED' => $forum_data['prune_viewed'], - 'PRUNE_SHADOW_FREQ' => $forum_data['prune_shadow_freq'], - 'PRUNE_SHADOW_DAYS' => $forum_data['prune_shadow_days'], - 'TOPICS_PER_PAGE' => $forum_data['forum_topics_per_page'], - 'FORUM_RULES_LINK' => $forum_data['forum_rules_link'], - 'FORUM_RULES' => $forum_data['forum_rules'], - 'FORUM_RULES_PREVIEW' => $forum_rules_preview, - 'FORUM_RULES_PLAIN' => $forum_rules_data['text'], - 'S_BBCODE_CHECKED' => ($forum_rules_data['allow_bbcode']) ? true : false, - 'S_SMILIES_CHECKED' => ($forum_rules_data['allow_smilies']) ? true : false, - 'S_URLS_CHECKED' => ($forum_rules_data['allow_urls']) ? true : false, - 'S_FORUM_PASSWORD_SET' => (empty($forum_data['forum_password'])) ? false : true, - - 'FORUM_DESC' => $forum_desc_data['text'], - 'S_DESC_BBCODE_CHECKED' => ($forum_desc_data['allow_bbcode']) ? true : false, - 'S_DESC_SMILIES_CHECKED' => ($forum_desc_data['allow_smilies']) ? true : false, - 'S_DESC_URLS_CHECKED' => ($forum_desc_data['allow_urls']) ? true : false, - - 'S_FORUM_TYPE_OPTIONS' => $forum_type_options, - 'S_STATUS_OPTIONS' => $statuslist, - 'S_PARENT_OPTIONS' => $parents_list, - 'S_STYLES_OPTIONS' => $styles_list, - 'S_FORUM_OPTIONS' => make_forum_select(($action == 'add') ? $forum_data['parent_id'] : false, ($action == 'edit') ? $forum_data['forum_id'] : false, false, false, false), - 'S_SHOW_DISPLAY_ON_INDEX' => $s_show_display_on_index, - 'S_FORUM_POST' => ($forum_data['forum_type'] == FORUM_POST) ? true : false, - 'S_FORUM_ORIG_POST' => (isset($old_forum_type) && $old_forum_type == FORUM_POST) ? true : false, - 'S_FORUM_ORIG_CAT' => (isset($old_forum_type) && $old_forum_type == FORUM_CAT) ? true : false, - 'S_FORUM_ORIG_LINK' => (isset($old_forum_type) && $old_forum_type == FORUM_LINK) ? true : false, - 'S_FORUM_LINK' => ($forum_data['forum_type'] == FORUM_LINK) ? true : false, - 'S_FORUM_CAT' => ($forum_data['forum_type'] == FORUM_CAT) ? true : false, - 'S_ENABLE_INDEXING' => ($forum_data['enable_indexing']) ? true : false, - 'S_TOPIC_ICONS' => ($forum_data['enable_icons']) ? true : false, - 'S_DISPLAY_SUBFORUM_LIST' => ($forum_data['display_subforum_list']) ? true : false, - 'S_DISPLAY_SUBFORUM_LIMIT' => ($forum_data['display_subforum_limit']) ? true : false, - 'S_DISPLAY_ON_INDEX' => ($forum_data['display_on_index']) ? true : false, - 'S_PRUNE_ENABLE' => ($forum_data['enable_prune']) ? true : false, - 'S_PRUNE_SHADOW_ENABLE' => ($forum_data['enable_shadow_prune']) ? true : false, - 'S_FORUM_LINK_TRACK' => ($forum_data['forum_flags'] & FORUM_FLAG_LINK_TRACK) ? true : false, - 'S_PRUNE_OLD_POLLS' => ($forum_data['forum_flags'] & FORUM_FLAG_PRUNE_POLL) ? true : false, - 'S_PRUNE_ANNOUNCE' => ($forum_data['forum_flags'] & FORUM_FLAG_PRUNE_ANNOUNCE) ? true : false, - 'S_PRUNE_STICKY' => ($forum_data['forum_flags'] & FORUM_FLAG_PRUNE_STICKY) ? true : false, - 'S_DISPLAY_ACTIVE_TOPICS' => ($forum_data['forum_type'] == FORUM_POST) ? ($forum_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS) : true, - 'S_ENABLE_ACTIVE_TOPICS' => ($forum_data['forum_type'] == FORUM_CAT) ? ($forum_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS) : false, - 'S_ENABLE_POST_REVIEW' => ($forum_data['forum_flags'] & FORUM_FLAG_POST_REVIEW) ? true : false, - 'S_ENABLE_QUICK_REPLY' => ($forum_data['forum_flags'] & FORUM_FLAG_QUICK_REPLY) ? true : false, - 'S_CAN_COPY_PERMISSIONS' => ($action != 'edit' || empty($forum_id) || ($auth->acl_get('a_fauth') && $auth->acl_get('a_authusers') && $auth->acl_get('a_authgroups') && $auth->acl_get('a_mauth'))) ? true : false, - ); - - /** - * Modify forum template data before we display the form - * - * @event core.acp_manage_forums_display_form - * @var string action Type of the action: add|edit - * @var bool update Do we display the form only - * or did the user press submit - * @var int forum_id When editing: the forum id, - * when creating: the parent forum id - * @var array row Array with current forum data - * empty when creating new forum - * @var array forum_data Array with new forum data - * @var string parents_list List of parent options - * @var array errors Array of errors, if you add errors - * ensure to update the template variables - * S_ERROR and ERROR_MSG to display it - * @var array template_data Array with new forum data - * @since 3.1.0-a1 - */ - $vars = array( - 'action', - 'update', - 'forum_id', - 'row', - 'forum_data', - 'parents_list', - 'errors', - 'template_data', - ); - extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_display_form', compact($vars))); - - $template->assign_vars($template_data); - - return; - - break; - - case 'delete': - - if (!$forum_id) - { - trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); - } - - $forum_data = $this->get_forum_info($forum_id); - - $subforums_id = array(); - $subforums = get_forum_branch($forum_id, 'children'); - - foreach ($subforums as $row) - { - $subforums_id[] = $row['forum_id']; - } - - $forums_list = make_forum_select($forum_data['parent_id'], $subforums_id); - - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE . ' - WHERE forum_type = ' . FORUM_POST . " - AND forum_id <> $forum_id"; - $result = $db->sql_query_limit($sql, 1); - - if ($db->sql_fetchrow($result)) - { - $template->assign_vars(array( - 'S_MOVE_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $subforums_id, false, true)) // , false, true, false??? - ); - } - $db->sql_freeresult($result); - - $parent_id = ($this->parent_id == $forum_id) ? 0 : $this->parent_id; - - $template->assign_vars(array( - 'S_DELETE_FORUM' => true, - 'U_ACTION' => $this->u_action . "&parent_id={$parent_id}&action=delete&f=$forum_id", - 'U_BACK' => $this->u_action . '&parent_id=' . $this->parent_id, - - 'FORUM_NAME' => $forum_data['forum_name'], - 'S_FORUM_POST' => ($forum_data['forum_type'] == FORUM_POST) ? true : false, - 'S_FORUM_LINK' => ($forum_data['forum_type'] == FORUM_LINK) ? true : false, - 'S_HAS_SUBFORUMS' => ($forum_data['right_id'] - $forum_data['left_id'] > 1) ? true : false, - 'S_FORUMS_LIST' => $forums_list, - 'S_ERROR' => (count($errors)) ? true : false, - 'ERROR_MSG' => (count($errors)) ? implode('
', $errors) : '') - ); - - return; - break; - - case 'copy_perm': - $forum_perm_from = $request->variable('forum_perm_from', 0); - - // Copy permissions? - if (!empty($forum_perm_from) && $forum_perm_from != $forum_id) - { - copy_forum_permissions($forum_perm_from, $forum_id, true); - phpbb_cache_moderators($db, $cache, $auth); - $auth->acl_clear_prefetch(); - $cache->destroy('sql', FORUMS_TABLE); - - $acl_url = '&mode=setting_forum_local&forum_id[]=' . $forum_id; - - $message = $user->lang['FORUM_UPDATED']; - - // Redirect to permissions - if ($auth->acl_get('a_fauth')) - { - $message .= '

' . sprintf($user->lang['REDIRECT_ACL'], '', ''); - } - - trigger_error($message . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id)); - } - - break; - } - - // Default management page - if (!$this->parent_id) - { - $navigation = $user->lang['FORUM_INDEX']; - } - else - { - $navigation = '' . $user->lang['FORUM_INDEX'] . ''; - - $forums_nav = get_forum_branch($this->parent_id, 'parents', 'descending'); - foreach ($forums_nav as $row) - { - if ($row['forum_id'] == $this->parent_id) - { - $navigation .= ' -> ' . $row['forum_name']; - } - else - { - $navigation .= ' -> ' . $row['forum_name'] . ''; - } - } - } - - // Jumpbox - $forum_box = make_forum_select($this->parent_id, false, false, false, false); //make_forum_select($this->parent_id); - - if ($action == 'sync' || $action == 'sync_forum') - { - $template->assign_var('S_RESYNCED', true); - } - - $sql = 'SELECT * - FROM ' . FORUMS_TABLE . " - WHERE parent_id = $this->parent_id - ORDER BY left_id"; - $result = $db->sql_query($sql); - - $rowset = array(); - while ($row = $db->sql_fetchrow($result)) - { - $rowset[(int) $row['forum_id']] = $row; - } - $db->sql_freeresult($result); - - /** - * Modify the forum list data - * - * @event core.acp_manage_forums_modify_forum_list - * @var array rowset Array with the forums list data - * @since 3.1.10-RC1 - */ - $vars = array('rowset'); - extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_modify_forum_list', compact($vars))); - - if (!empty($rowset)) - { - foreach ($rowset as $row) - { - $forum_type = $row['forum_type']; - - if ($row['forum_status'] == ITEM_LOCKED) - { - $folder_image = '' . $user->lang['LOCKED'] . ''; - } - else - { - switch ($forum_type) - { - case FORUM_LINK: - $folder_image = '' . $user->lang['LINK'] . ''; - break; - - default: - $folder_image = ($row['left_id'] + 1 != $row['right_id']) ? '' . $user->lang['SUBFORUM'] . '' : '' . $user->lang['FOLDER'] . ''; - break; - } - } - - $url = $this->u_action . "&parent_id=$this->parent_id&f={$row['forum_id']}"; - - $template->assign_block_vars('forums', array( - 'FOLDER_IMAGE' => $folder_image, - 'FORUM_IMAGE' => ($row['forum_image']) ? '' : '', - 'FORUM_IMAGE_SRC' => ($row['forum_image']) ? $phpbb_root_path . $row['forum_image'] : '', - 'FORUM_NAME' => $row['forum_name'], - 'FORUM_DESCRIPTION' => generate_text_for_display($row['forum_desc'], $row['forum_desc_uid'], $row['forum_desc_bitfield'], $row['forum_desc_options']), - 'FORUM_TOPICS' => $row['forum_topics_approved'], - 'FORUM_POSTS' => $row['forum_posts_approved'], - - 'S_FORUM_LINK' => ($forum_type == FORUM_LINK) ? true : false, - 'S_FORUM_POST' => ($forum_type == FORUM_POST) ? true : false, - - 'U_FORUM' => $this->u_action . '&parent_id=' . $row['forum_id'], - 'U_MOVE_UP' => $url . '&action=move_up', - 'U_MOVE_DOWN' => $url . '&action=move_down', - 'U_EDIT' => $url . '&action=edit', - 'U_DELETE' => $url . '&action=delete', - 'U_SYNC' => $url . '&action=sync') - ); - } - } - else if ($this->parent_id) - { - $row = $this->get_forum_info($this->parent_id); - - $url = $this->u_action . '&parent_id=' . $this->parent_id . '&f=' . $row['forum_id']; - - $template->assign_vars(array( - 'S_NO_FORUMS' => true, - - 'U_EDIT' => $url . '&action=edit', - 'U_DELETE' => $url . '&action=delete', - 'U_SYNC' => $url . '&action=sync') - ); - } - unset($rowset); - - $template->assign_vars(array( - 'ERROR_MSG' => (count($errors)) ? implode('
', $errors) : '', - 'NAVIGATION' => $navigation, - 'FORUM_BOX' => $forum_box, - 'U_SEL_ACTION' => $this->u_action, - 'U_ACTION' => $this->u_action . '&parent_id=' . $this->parent_id, - - 'U_PROGRESS_BAR' => $this->u_action . '&action=progress_bar', - 'UA_PROGRESS_BAR' => addslashes($this->u_action . '&action=progress_bar'), - )); - } - - /** - * Get forum details - */ - function get_forum_info($forum_id) - { - global $db; - - $sql = 'SELECT * - FROM ' . FORUMS_TABLE . " - WHERE forum_id = $forum_id"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - trigger_error("Forum #$forum_id does not exist", E_USER_ERROR); - } - - return $row; - } - - /** - * Update forum data - */ - function update_forum_data(&$forum_data_ary) - { - global $db, $user, $cache, $phpbb_root_path, $phpbb_container, $phpbb_dispatcher, $phpbb_log, $request; - - $errors = array(); - - $forum_data = $forum_data_ary; - /** - * Validate the forum data before we create/update the forum - * - * @event core.acp_manage_forums_validate_data - * @var array forum_data Array with new forum data - * @var array errors Array of errors, should be strings and not - * language key. - * @since 3.1.0-a1 - */ - $vars = array('forum_data', 'errors'); - extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_validate_data', compact($vars))); - $forum_data_ary = $forum_data; - unset($forum_data); - - if ($forum_data_ary['forum_name'] == '') - { - $errors[] = $user->lang['FORUM_NAME_EMPTY']; - } - - /** - * Replace Emojis and other 4bit UTF-8 chars not allowed by MySql to UCR / NCR. - * Using their Numeric Character Reference's Hexadecimal notation. - */ - $forum_data_ary['forum_name'] = utf8_encode_ucr($forum_data_ary['forum_name']); - - /** - * This should never happen again. - * Leaving the fallback here just in case there will be the need of it. - */ - if (preg_match_all('/[\x{10000}-\x{10FFFF}]/u', $forum_data_ary['forum_name'], $matches)) - { - $character_list = implode('
', $matches[0]); - - $errors[] = $user->lang('FORUM_NAME_EMOJI', $character_list); - } - - if (utf8_strlen($forum_data_ary['forum_desc']) > 4000) - { - $errors[] = $user->lang['FORUM_DESC_TOO_LONG']; - } - - if (utf8_strlen($forum_data_ary['forum_rules']) > 4000) - { - $errors[] = $user->lang['FORUM_RULES_TOO_LONG']; - } - - if ($forum_data_ary['forum_password'] || $forum_data_ary['forum_password_confirm']) - { - if ($forum_data_ary['forum_password'] != $forum_data_ary['forum_password_confirm']) - { - $forum_data_ary['forum_password'] = $forum_data_ary['forum_password_confirm'] = ''; - $errors[] = $user->lang['FORUM_PASSWORD_MISMATCH']; - } - } - - if ($forum_data_ary['prune_days'] < 0 || $forum_data_ary['prune_viewed'] < 0 || $forum_data_ary['prune_freq'] < 0) - { - $forum_data_ary['prune_days'] = $forum_data_ary['prune_viewed'] = $forum_data_ary['prune_freq'] = 0; - $errors[] = $user->lang['FORUM_DATA_NEGATIVE']; - } - - $range_test_ary = array( - array('lang' => 'FORUM_TOPICS_PAGE', 'value' => $forum_data_ary['forum_topics_per_page'], 'column_type' => 'USINT:0'), - ); - - if (!empty($forum_data_ary['forum_image']) && !file_exists($phpbb_root_path . $forum_data_ary['forum_image'])) - { - $errors[] = $user->lang['FORUM_IMAGE_NO_EXIST']; - } - - validate_range($range_test_ary, $errors); - - // Set forum flags - // 1 = link tracking - // 2 = prune old polls - // 4 = prune announcements - // 8 = prune stickies - // 16 = show active topics - // 32 = enable post review - $forum_data_ary['forum_flags'] = 0; - $forum_data_ary['forum_flags'] += ($forum_data_ary['forum_link_track']) ? FORUM_FLAG_LINK_TRACK : 0; - $forum_data_ary['forum_flags'] += ($forum_data_ary['prune_old_polls']) ? FORUM_FLAG_PRUNE_POLL : 0; - $forum_data_ary['forum_flags'] += ($forum_data_ary['prune_announce']) ? FORUM_FLAG_PRUNE_ANNOUNCE : 0; - $forum_data_ary['forum_flags'] += ($forum_data_ary['prune_sticky']) ? FORUM_FLAG_PRUNE_STICKY : 0; - $forum_data_ary['forum_flags'] += ($forum_data_ary['show_active']) ? FORUM_FLAG_ACTIVE_TOPICS : 0; - $forum_data_ary['forum_flags'] += ($forum_data_ary['enable_post_review']) ? FORUM_FLAG_POST_REVIEW : 0; - $forum_data_ary['forum_flags'] += ($forum_data_ary['enable_quick_reply']) ? FORUM_FLAG_QUICK_REPLY : 0; - - // Unset data that are not database fields - $forum_data_sql = $forum_data_ary; - - unset($forum_data_sql['forum_link_track']); - unset($forum_data_sql['prune_old_polls']); - unset($forum_data_sql['prune_announce']); - unset($forum_data_sql['prune_sticky']); - unset($forum_data_sql['show_active']); - unset($forum_data_sql['enable_post_review']); - unset($forum_data_sql['enable_quick_reply']); - unset($forum_data_sql['forum_password_confirm']); - - // What are we going to do tonight Brain? The same thing we do everynight, - // try to take over the world ... or decide whether to continue update - // and if so, whether it's a new forum/cat/link or an existing one - if (count($errors)) - { - return $errors; - } - - // As we don't know the old password, it's kinda tricky to detect changes - if ($forum_data_sql['forum_password_unset']) - { - $forum_data_sql['forum_password'] = ''; - } - else if (empty($forum_data_sql['forum_password'])) - { - unset($forum_data_sql['forum_password']); - } - else - { - // Instantiate passwords manager - /* @var $passwords_manager \phpbb\passwords\manager */ - $passwords_manager = $phpbb_container->get('passwords.manager'); - - $forum_data_sql['forum_password'] = $passwords_manager->hash($forum_data_sql['forum_password']); - } - unset($forum_data_sql['forum_password_unset']); - - $forum_data = $forum_data_ary; - /** - * Remove invalid values from forum_data_sql that should not be updated - * - * @event core.acp_manage_forums_update_data_before - * @var array forum_data Array with forum data - * @var array forum_data_sql Array with data we are going to update - * If forum_data_sql[forum_id] is set, we update - * that forum, otherwise a new one is created. - * @since 3.1.0-a1 - */ - $vars = array('forum_data', 'forum_data_sql'); - extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_update_data_before', compact($vars))); - $forum_data_ary = $forum_data; - unset($forum_data); - - $is_new_forum = !isset($forum_data_sql['forum_id']); - - if ($is_new_forum) - { - // no forum_id means we're creating a new forum - unset($forum_data_sql['type_action']); - - if ($forum_data_sql['parent_id']) - { - $sql = 'SELECT left_id, right_id, forum_type - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . $forum_data_sql['parent_id']; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - trigger_error($user->lang['PARENT_NOT_EXIST'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); - } - - if ($row['forum_type'] == FORUM_LINK) - { - $errors[] = $user->lang['PARENT_IS_LINK_FORUM']; - return $errors; - } - - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET left_id = left_id + 2, right_id = right_id + 2 - WHERE left_id > ' . $row['right_id']; - $db->sql_query($sql); - - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET right_id = right_id + 2 - WHERE ' . $row['left_id'] . ' BETWEEN left_id AND right_id'; - $db->sql_query($sql); - - $forum_data_sql['left_id'] = $row['right_id']; - $forum_data_sql['right_id'] = $row['right_id'] + 1; - } - else - { - $sql = 'SELECT MAX(right_id) AS right_id - FROM ' . FORUMS_TABLE; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $forum_data_sql['left_id'] = $row['right_id'] + 1; - $forum_data_sql['right_id'] = $row['right_id'] + 2; - } - - $sql = 'INSERT INTO ' . FORUMS_TABLE . ' ' . $db->sql_build_array('INSERT', $forum_data_sql); - $db->sql_query($sql); - - $forum_data_ary['forum_id'] = $db->sql_nextid(); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_ADD', false, array($forum_data_ary['forum_name'])); - } - else - { - $row = $this->get_forum_info($forum_data_sql['forum_id']); - - if ($row['forum_type'] == FORUM_POST && $row['forum_type'] != $forum_data_sql['forum_type']) - { - // Has subforums and want to change into a link? - if ($row['right_id'] - $row['left_id'] > 1 && $forum_data_sql['forum_type'] == FORUM_LINK) - { - $errors[] = $user->lang['FORUM_WITH_SUBFORUMS_NOT_TO_LINK']; - return $errors; - } - - // we're turning a postable forum into a non-postable forum - if ($forum_data_sql['type_action'] == 'move') - { - $to_forum_id = $request->variable('to_forum_id', 0); - - if ($to_forum_id) - { - $errors = $this->move_forum_content($forum_data_sql['forum_id'], $to_forum_id); - } - else - { - return array($user->lang['NO_DESTINATION_FORUM']); - } - } - else if ($forum_data_sql['type_action'] == 'delete') - { - $errors = $this->delete_forum_content($forum_data_sql['forum_id']); - } - else - { - return array($user->lang['NO_FORUM_ACTION']); - } - - $forum_data_sql['forum_posts_approved'] = $forum_data_sql['forum_posts_unapproved'] = $forum_data_sql['forum_posts_softdeleted'] = $forum_data_sql['forum_topics_approved'] = $forum_data_sql['forum_topics_unapproved'] = $forum_data_sql['forum_topics_softdeleted'] = 0; - $forum_data_sql['forum_last_post_id'] = $forum_data_sql['forum_last_poster_id'] = $forum_data_sql['forum_last_post_time'] = 0; - $forum_data_sql['forum_last_poster_name'] = $forum_data_sql['forum_last_poster_colour'] = ''; - } - else if ($row['forum_type'] == FORUM_CAT && $forum_data_sql['forum_type'] == FORUM_LINK) - { - // Has subforums? - if ($row['right_id'] - $row['left_id'] > 1) - { - // We are turning a category into a link - but need to decide what to do with the subforums. - $action_subforums = $request->variable('action_subforums', ''); - $subforums_to_id = $request->variable('subforums_to_id', 0); - - if ($action_subforums == 'delete') - { - $rows = get_forum_branch($row['forum_id'], 'children', 'descending', false); - - foreach ($rows as $_row) - { - // Do not remove the forum id we are about to change. ;) - if ($_row['forum_id'] == $row['forum_id']) - { - continue; - } - - $forum_ids[] = $_row['forum_id']; - $errors = array_merge($errors, $this->delete_forum_content($_row['forum_id'])); - } - - if (count($errors)) - { - return $errors; - } - - if (count($forum_ids)) - { - $sql = 'DELETE FROM ' . FORUMS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $forum_ids); - $db->sql_query($sql); - - $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $forum_ids); - $db->sql_query($sql); - - $sql = 'DELETE FROM ' . ACL_USERS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $forum_ids); - $db->sql_query($sql); - - // Delete forum ids from extension groups table - $sql = 'SELECT group_id, allowed_forums - FROM ' . EXTENSION_GROUPS_TABLE; - $result = $db->sql_query($sql); - - while ($_row = $db->sql_fetchrow($result)) - { - if (!$_row['allowed_forums']) - { - continue; - } - - $allowed_forums = unserialize(trim($_row['allowed_forums'])); - $allowed_forums = array_diff($allowed_forums, $forum_ids); - - $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . " - SET allowed_forums = '" . ((count($allowed_forums)) ? serialize($allowed_forums) : '') . "' - WHERE group_id = {$_row['group_id']}"; - $db->sql_query($sql); - } - $db->sql_freeresult($result); - - $cache->destroy('_extensions'); - } - } - else if ($action_subforums == 'move') - { - if (!$subforums_to_id) - { - return array($user->lang['NO_DESTINATION_FORUM']); - } - - $sql = 'SELECT forum_name - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . $subforums_to_id; - $result = $db->sql_query($sql); - $_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$_row) - { - return array($user->lang['NO_FORUM']); - } - - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE . " - WHERE parent_id = {$row['forum_id']}"; - $result = $db->sql_query($sql); - - while ($_row = $db->sql_fetchrow($result)) - { - $this->move_forum($_row['forum_id'], $subforums_to_id); - } - $db->sql_freeresult($result); - - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET parent_id = $subforums_to_id - WHERE parent_id = {$row['forum_id']}"; - $db->sql_query($sql); - } - - // Adjust the left/right id - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET right_id = left_id + 1 - WHERE forum_id = ' . $row['forum_id']; - $db->sql_query($sql); - } - } - else if ($row['forum_type'] == FORUM_CAT && $forum_data_sql['forum_type'] == FORUM_POST) - { - // Changing a category to a forum? Reset the data (you can't post directly in a cat, you must use a forum) - $forum_data_sql['forum_posts_approved'] = 0; - $forum_data_sql['forum_posts_unapproved'] = 0; - $forum_data_sql['forum_posts_softdeleted'] = 0; - $forum_data_sql['forum_topics_approved'] = 0; - $forum_data_sql['forum_topics_unapproved'] = 0; - $forum_data_sql['forum_topics_softdeleted'] = 0; - $forum_data_sql['forum_last_post_id'] = 0; - $forum_data_sql['forum_last_post_subject'] = ''; - $forum_data_sql['forum_last_post_time'] = 0; - $forum_data_sql['forum_last_poster_id'] = 0; - $forum_data_sql['forum_last_poster_name'] = ''; - $forum_data_sql['forum_last_poster_colour'] = ''; - } - - if (count($errors)) - { - return $errors; - } - - if ($row['parent_id'] != $forum_data_sql['parent_id']) - { - if ($row['forum_id'] != $forum_data_sql['parent_id']) - { - $errors = $this->move_forum($forum_data_sql['forum_id'], $forum_data_sql['parent_id']); - } - else - { - $forum_data_sql['parent_id'] = $row['parent_id']; - } - } - - if (count($errors)) - { - return $errors; - } - - unset($forum_data_sql['type_action']); - - if ($row['forum_name'] != $forum_data_sql['forum_name']) - { - // the forum name has changed, clear the parents list of all forums (for safety) - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET forum_parents = ''"; - $db->sql_query($sql); - } - - // Setting the forum id to the forum id is not really received well by some dbs. ;) - $forum_id = $forum_data_sql['forum_id']; - unset($forum_data_sql['forum_id']); - - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $forum_data_sql) . ' - WHERE forum_id = ' . $forum_id; - $db->sql_query($sql); - - // Add it back - $forum_data_ary['forum_id'] = $forum_id; - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_EDIT', false, array($forum_data_ary['forum_name'])); - } - - $forum_data = $forum_data_ary; - /** - * Event after a forum was updated or created - * - * @event core.acp_manage_forums_update_data_after - * @var array forum_data Array with forum data - * @var array forum_data_sql Array with data we updated - * @var bool is_new_forum Did we create a forum or update one - * If you want to overwrite this value, - * ensure to set forum_data_sql[forum_id] - * @var array errors Array of errors, should be strings and not - * language key. - * @since 3.1.0-a1 - */ - $vars = array('forum_data', 'forum_data_sql', 'is_new_forum', 'errors'); - extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_update_data_after', compact($vars))); - $forum_data_ary = $forum_data; - unset($forum_data); - - return $errors; - } - - /** - * Move forum - */ - function move_forum($from_id, $to_id) - { - global $db, $user, $phpbb_dispatcher; - - $errors = array(); - - // Check if we want to move to a parent with link type - if ($to_id > 0) - { - $to_data = $this->get_forum_info($to_id); - - if ($to_data['forum_type'] == FORUM_LINK) - { - $errors[] = $user->lang['PARENT_IS_LINK_FORUM']; - } - } - - /** - * Event when we move all children of one forum to another - * - * This event may be triggered, when a forum is deleted - * - * @event core.acp_manage_forums_move_children - * @var int from_id Id of the current parent forum - * @var int to_id Id of the new parent forum - * @var array errors Array of errors, should be strings and not - * language key. - * @since 3.1.0-a1 - */ - $vars = array('from_id', 'to_id', 'errors'); - extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_move_children', compact($vars))); - - // Return if there were errors - if (!empty($errors)) - { - return $errors; - } - - $db->sql_transaction('begin'); - - $moved_forums = get_forum_branch($from_id, 'children', 'descending'); - $from_data = $moved_forums[0]; - $diff = count($moved_forums) * 2; - - $moved_ids = array(); - for ($i = 0, $size = count($moved_forums); $i < $size; ++$i) - { - $moved_ids[] = $moved_forums[$i]['forum_id']; - } - - // Resync parents - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET right_id = right_id - $diff, forum_parents = '' - WHERE left_id < " . $from_data['right_id'] . " - AND right_id > " . $from_data['right_id']; - $db->sql_query($sql); - - // Resync righthand side of tree - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET left_id = left_id - $diff, right_id = right_id - $diff, forum_parents = '' - WHERE left_id > " . $from_data['right_id']; - $db->sql_query($sql); - - if ($to_id > 0) - { - // Retrieve $to_data again, it may have been changed... - $to_data = $this->get_forum_info($to_id); - - // Resync new parents - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET right_id = right_id + $diff, forum_parents = '' - WHERE " . $to_data['right_id'] . ' BETWEEN left_id AND right_id - AND ' . $db->sql_in_set('forum_id', $moved_ids, true); - $db->sql_query($sql); - - // Resync the righthand side of the tree - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET left_id = left_id + $diff, right_id = right_id + $diff, forum_parents = '' - WHERE left_id > " . $to_data['right_id'] . ' - AND ' . $db->sql_in_set('forum_id', $moved_ids, true); - $db->sql_query($sql); - - // Resync moved branch - $to_data['right_id'] += $diff; - - if ($to_data['right_id'] > $from_data['right_id']) - { - $diff = '+ ' . ($to_data['right_id'] - $from_data['right_id'] - 1); - } - else - { - $diff = '- ' . abs($to_data['right_id'] - $from_data['right_id'] - 1); - } - } - else - { - $sql = 'SELECT MAX(right_id) AS right_id - FROM ' . FORUMS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $moved_ids, true); - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $diff = '+ ' . ($row['right_id'] - $from_data['left_id'] + 1); - } - - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET left_id = left_id $diff, right_id = right_id $diff, forum_parents = '' - WHERE " . $db->sql_in_set('forum_id', $moved_ids); - $db->sql_query($sql); - - $db->sql_transaction('commit'); - - return $errors; - } - - /** - * Move forum content from one to another forum - */ - function move_forum_content($from_id, $to_id, $sync = true) - { - global $db, $phpbb_dispatcher; - - $errors = array(); - - /** - * Event when we move content from one forum to another - * - * @event core.acp_manage_forums_move_content - * @var int from_id Id of the current parent forum - * @var int to_id Id of the new parent forum - * @var bool sync Shall we sync the "to"-forum's data - * @var array errors Array of errors, should be strings and not - * language key. If this array is not empty, - * The content will not be moved. - * @since 3.1.0-a1 - */ - $vars = array('from_id', 'to_id', 'sync', 'errors'); - extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_move_content', compact($vars))); - - // Return if there were errors - if (!empty($errors)) - { - return $errors; - } - - $table_ary = array(LOG_TABLE, POSTS_TABLE, TOPICS_TABLE, DRAFTS_TABLE, TOPICS_TRACK_TABLE); - - /** - * Perform additional actions before move forum content - * - * @event core.acp_manage_forums_move_content_sql_before - * @var array table_ary Array of tables from which forum_id will be updated - * @since 3.2.4-RC1 - */ - $vars = array('table_ary'); - extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_move_content_sql_before', compact($vars))); - - foreach ($table_ary as $table) - { - $sql = "UPDATE $table - SET forum_id = $to_id - WHERE forum_id = $from_id"; - $db->sql_query($sql); - } - unset($table_ary); - - $table_ary = array(FORUMS_ACCESS_TABLE, FORUMS_TRACK_TABLE, FORUMS_WATCH_TABLE, MODERATOR_CACHE_TABLE); - - foreach ($table_ary as $table) - { - $sql = "DELETE FROM $table - WHERE forum_id = $from_id"; - $db->sql_query($sql); - } - - /** - * Event when content has been moved from one forum to another - * - * @event core.acp_manage_forums_move_content_after - * @var int from_id Id of the current parent forum - * @var int to_id Id of the new parent forum - * @var bool sync Shall we sync the "to"-forum's data - * - * @since 3.2.9-RC1 - */ - $vars = array('from_id', 'to_id', 'sync'); - extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_move_content_after', compact($vars))); - - if ($sync) - { - // Delete ghost topics that link back to the same forum then resync counters - sync('topic_moved'); - sync('forum', 'forum_id', $to_id, false, true); - } - - return array(); - } - - /** - * Remove complete forum - */ - function delete_forum($forum_id, $action_posts = 'delete', $action_subforums = 'delete', $posts_to_id = 0, $subforums_to_id = 0) - { - global $db, $user, $cache, $phpbb_log; - - $forum_data = $this->get_forum_info($forum_id); - - $errors = array(); - $log_action_posts = $log_action_forums = $posts_to_name = $subforums_to_name = ''; - $forum_ids = array($forum_id); - - if ($action_posts == 'delete') - { - $log_action_posts = 'POSTS'; - $errors = array_merge($errors, $this->delete_forum_content($forum_id)); - } - else if ($action_posts == 'move') - { - if (!$posts_to_id) - { - $errors[] = $user->lang['NO_DESTINATION_FORUM']; - } - else - { - $log_action_posts = 'MOVE_POSTS'; - - $sql = 'SELECT forum_name - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . $posts_to_id; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - $errors[] = $user->lang['NO_FORUM']; - } - else - { - $posts_to_name = $row['forum_name']; - $errors = array_merge($errors, $this->move_forum_content($forum_id, $posts_to_id)); - } - } - } - - if (count($errors)) - { - return $errors; - } - - if ($action_subforums == 'delete') - { - $log_action_forums = 'FORUMS'; - $rows = get_forum_branch($forum_id, 'children', 'descending', false); - - foreach ($rows as $row) - { - $forum_ids[] = $row['forum_id']; - $errors = array_merge($errors, $this->delete_forum_content($row['forum_id'])); - } - - if (count($errors)) - { - return $errors; - } - - $diff = count($forum_ids) * 2; - - $sql = 'DELETE FROM ' . FORUMS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $forum_ids); - $db->sql_query($sql); - - $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $forum_ids); - $db->sql_query($sql); - - $sql = 'DELETE FROM ' . ACL_USERS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $forum_ids); - $db->sql_query($sql); - } - else if ($action_subforums == 'move') - { - if (!$subforums_to_id) - { - $errors[] = $user->lang['NO_DESTINATION_FORUM']; - } - else - { - $log_action_forums = 'MOVE_FORUMS'; - - $sql = 'SELECT forum_name - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . $subforums_to_id; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - $errors[] = $user->lang['NO_FORUM']; - } - else - { - $subforums_to_name = $row['forum_name']; - - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE . " - WHERE parent_id = $forum_id"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $this->move_forum($row['forum_id'], $subforums_to_id); - } - $db->sql_freeresult($result); - - // Grab new forum data for correct tree updating later - $forum_data = $this->get_forum_info($forum_id); - - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET parent_id = $subforums_to_id - WHERE parent_id = $forum_id"; - $db->sql_query($sql); - - $diff = 2; - $sql = 'DELETE FROM ' . FORUMS_TABLE . " - WHERE forum_id = $forum_id"; - $db->sql_query($sql); - - $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . " - WHERE forum_id = $forum_id"; - $db->sql_query($sql); - - $sql = 'DELETE FROM ' . ACL_USERS_TABLE . " - WHERE forum_id = $forum_id"; - $db->sql_query($sql); - } - } - - if (count($errors)) - { - return $errors; - } - } - else - { - $diff = 2; - $sql = 'DELETE FROM ' . FORUMS_TABLE . " - WHERE forum_id = $forum_id"; - $db->sql_query($sql); - - $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . " - WHERE forum_id = $forum_id"; - $db->sql_query($sql); - - $sql = 'DELETE FROM ' . ACL_USERS_TABLE . " - WHERE forum_id = $forum_id"; - $db->sql_query($sql); - } - - // Resync tree - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET right_id = right_id - $diff - WHERE left_id < {$forum_data['right_id']} AND right_id > {$forum_data['right_id']}"; - $db->sql_query($sql); - - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET left_id = left_id - $diff, right_id = right_id - $diff - WHERE left_id > {$forum_data['right_id']}"; - $db->sql_query($sql); - - // Delete forum ids from extension groups table - $sql = 'SELECT group_id, allowed_forums - FROM ' . EXTENSION_GROUPS_TABLE; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if (!$row['allowed_forums']) - { - continue; - } - - $allowed_forums = unserialize(trim($row['allowed_forums'])); - $allowed_forums = array_diff($allowed_forums, $forum_ids); - - $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . " - SET allowed_forums = '" . ((count($allowed_forums)) ? serialize($allowed_forums) : '') . "' - WHERE group_id = {$row['group_id']}"; - $db->sql_query($sql); - } - $db->sql_freeresult($result); - - $cache->destroy('_extensions'); - - $log_action = implode('_', array($log_action_posts, $log_action_forums)); - - switch ($log_action) - { - case 'MOVE_POSTS_MOVE_FORUMS': - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_DEL_MOVE_POSTS_MOVE_FORUMS', false, array($posts_to_name, $subforums_to_name, $forum_data['forum_name'])); - break; - - case 'MOVE_POSTS_FORUMS': - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_DEL_MOVE_POSTS_FORUMS', false, array($posts_to_name, $forum_data['forum_name'])); - break; - - case 'POSTS_MOVE_FORUMS': - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_DEL_POSTS_MOVE_FORUMS', false, array($subforums_to_name, $forum_data['forum_name'])); - break; - - case '_MOVE_FORUMS': - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_DEL_MOVE_FORUMS', false, array($subforums_to_name, $forum_data['forum_name'])); - break; - - case 'MOVE_POSTS_': - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_DEL_MOVE_POSTS', false, array($posts_to_name, $forum_data['forum_name'])); - break; - - case 'POSTS_FORUMS': - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_DEL_POSTS_FORUMS', false, array($forum_data['forum_name'])); - break; - - case '_FORUMS': - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_DEL_FORUMS', false, array($forum_data['forum_name'])); - break; - - case 'POSTS_': - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_DEL_POSTS', false, array($forum_data['forum_name'])); - break; - - default: - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_DEL_FORUM', false, array($forum_data['forum_name'])); - break; - } - - return $errors; - } - - /** - * Delete forum content - */ - function delete_forum_content($forum_id) - { - global $db, $config, $phpbb_root_path, $phpEx, $phpbb_container, $phpbb_dispatcher; - - include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx); - - $db->sql_transaction('begin'); - - // Select then delete all attachments - $sql = 'SELECT a.topic_id - FROM ' . POSTS_TABLE . ' p, ' . ATTACHMENTS_TABLE . " a - WHERE p.forum_id = $forum_id - AND a.in_message = 0 - AND a.topic_id = p.topic_id"; - $result = $db->sql_query($sql); - - $topic_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $topic_ids[] = $row['topic_id']; - } - $db->sql_freeresult($result); - - /** @var \phpbb\attachment\manager $attachment_manager */ - $attachment_manager = $phpbb_container->get('attachment.manager'); - $attachment_manager->delete('topic', $topic_ids, false); - unset($attachment_manager); - - // Delete shadow topics pointing to topics in this forum - delete_topic_shadows($forum_id); - - // Before we remove anything we make sure we are able to adjust the post counts later. ;) - $sql = 'SELECT poster_id - FROM ' . POSTS_TABLE . ' - WHERE forum_id = ' . $forum_id . ' - AND post_postcount = 1 - AND post_visibility = ' . ITEM_APPROVED; - $result = $db->sql_query($sql); - - $post_counts = array(); - while ($row = $db->sql_fetchrow($result)) - { - $post_counts[$row['poster_id']] = (!empty($post_counts[$row['poster_id']])) ? $post_counts[$row['poster_id']] + 1 : 1; - } - $db->sql_freeresult($result); - - switch ($db->get_sql_layer()) - { - case 'mysqli': - - // Delete everything else and thank MySQL for offering multi-table deletion - $tables_ary = array( - SEARCH_WORDMATCH_TABLE => 'post_id', - REPORTS_TABLE => 'post_id', - WARNINGS_TABLE => 'post_id', - BOOKMARKS_TABLE => 'topic_id', - TOPICS_WATCH_TABLE => 'topic_id', - TOPICS_POSTED_TABLE => 'topic_id', - POLL_OPTIONS_TABLE => 'topic_id', - POLL_VOTES_TABLE => 'topic_id', - ); - - $sql = 'DELETE ' . POSTS_TABLE; - $sql_using = "\nFROM " . POSTS_TABLE; - $sql_where = "\nWHERE " . POSTS_TABLE . ".forum_id = $forum_id\n"; - - foreach ($tables_ary as $table => $field) - { - $sql .= ", $table "; - $sql_using .= ", $table "; - $sql_where .= "\nAND $table.$field = " . POSTS_TABLE . ".$field"; - } - - $db->sql_query($sql . $sql_using . $sql_where); - - break; - - default: - - // Delete everything else and curse your DB for not offering multi-table deletion - $tables_ary = array( - 'post_id' => array( - SEARCH_WORDMATCH_TABLE, - REPORTS_TABLE, - WARNINGS_TABLE, - ), - - 'topic_id' => array( - BOOKMARKS_TABLE, - TOPICS_WATCH_TABLE, - TOPICS_POSTED_TABLE, - POLL_OPTIONS_TABLE, - POLL_VOTES_TABLE, - ) - ); - - // Amount of rows we select and delete in one iteration. - $batch_size = 500; - - foreach ($tables_ary as $field => $tables) - { - $start = 0; - - do - { - $sql = "SELECT $field - FROM " . POSTS_TABLE . ' - WHERE forum_id = ' . $forum_id; - $result = $db->sql_query_limit($sql, $batch_size, $start); - - $ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $ids[] = $row[$field]; - } - $db->sql_freeresult($result); - - if (count($ids)) - { - $start += count($ids); - - foreach ($tables as $table) - { - $db->sql_query("DELETE FROM $table WHERE " . $db->sql_in_set($field, $ids)); - } - } - } - while (count($ids) == $batch_size); - } - unset($ids); - - break; - } - - $table_ary = array(FORUMS_ACCESS_TABLE, FORUMS_TRACK_TABLE, FORUMS_WATCH_TABLE, LOG_TABLE, MODERATOR_CACHE_TABLE, POSTS_TABLE, TOPICS_TABLE, TOPICS_TRACK_TABLE); - - /** - * Perform additional actions before forum content deletion - * - * @event core.delete_forum_content_before_query - * @var array table_ary Array of tables from which all rows will be deleted that hold the forum_id - * @var int forum_id the forum id - * @var array topic_ids Array of the topic ids from the forum to be deleted - * @var array post_counts Array of counts of posts in the forum, by poster_id - * @since 3.1.6-RC1 - */ - $vars = array( - 'table_ary', - 'forum_id', - 'topic_ids', - 'post_counts', - ); - extract($phpbb_dispatcher->trigger_event('core.delete_forum_content_before_query', compact($vars))); - - foreach ($table_ary as $table) - { - $db->sql_query("DELETE FROM $table WHERE forum_id = $forum_id"); - } - - // Set forum ids to 0 - $table_ary = array(DRAFTS_TABLE); - - foreach ($table_ary as $table) - { - $db->sql_query("UPDATE $table SET forum_id = 0 WHERE forum_id = $forum_id"); - } - - // Adjust users post counts - if (count($post_counts)) - { - foreach ($post_counts as $poster_id => $substract) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_posts = 0 - WHERE user_id = ' . $poster_id . ' - AND user_posts < ' . $substract; - $db->sql_query($sql); - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_posts = user_posts - ' . $substract . ' - WHERE user_id = ' . $poster_id . ' - AND user_posts >= ' . $substract; - $db->sql_query($sql); - } - } - - $db->sql_transaction('commit'); - - // Make sure the overall post/topic count is correct... - $sql = 'SELECT COUNT(post_id) AS stat - FROM ' . POSTS_TABLE . ' - WHERE post_visibility = ' . ITEM_APPROVED; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $config->set('num_posts', (int) $row['stat'], false); - - $sql = 'SELECT COUNT(topic_id) AS stat - FROM ' . TOPICS_TABLE . ' - WHERE topic_visibility = ' . ITEM_APPROVED; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $config->set('num_topics', (int) $row['stat'], false); - - $sql = 'SELECT COUNT(attach_id) as stat - FROM ' . ATTACHMENTS_TABLE; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $config->set('num_files', (int) $row['stat'], false); - - $sql = 'SELECT SUM(filesize) as stat - FROM ' . ATTACHMENTS_TABLE; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $config->set('upload_dir_size', (float) $row['stat'], false); - - return array(); - } - - /** - * Move forum position by $steps up/down - */ - function move_forum_by($forum_row, $action = 'move_up', $steps = 1) - { - global $db; - - /** - * Fetch all the siblings between the module's current spot - * and where we want to move it to. If there are less than $steps - * siblings between the current spot and the target then the - * module will move as far as possible - */ - $sql = 'SELECT forum_id, forum_name, left_id, right_id - FROM ' . FORUMS_TABLE . " - WHERE parent_id = {$forum_row['parent_id']} - AND " . (($action == 'move_up') ? "right_id < {$forum_row['right_id']} ORDER BY right_id DESC" : "left_id > {$forum_row['left_id']} ORDER BY left_id ASC"); - $result = $db->sql_query_limit($sql, $steps); - - $target = array(); - while ($row = $db->sql_fetchrow($result)) - { - $target = $row; - } - $db->sql_freeresult($result); - - if (!count($target)) - { - // The forum is already on top or bottom - return false; - } - - /** - * $left_id and $right_id define the scope of the nodes that are affected by the move. - * $diff_up and $diff_down are the values to substract or add to each node's left_id - * and right_id in order to move them up or down. - * $move_up_left and $move_up_right define the scope of the nodes that are moving - * up. Other nodes in the scope of ($left_id, $right_id) are considered to move down. - */ - if ($action == 'move_up') - { - $left_id = $target['left_id']; - $right_id = $forum_row['right_id']; - - $diff_up = $forum_row['left_id'] - $target['left_id']; - $diff_down = $forum_row['right_id'] + 1 - $forum_row['left_id']; - - $move_up_left = $forum_row['left_id']; - $move_up_right = $forum_row['right_id']; - } - else - { - $left_id = $forum_row['left_id']; - $right_id = $target['right_id']; - - $diff_up = $forum_row['right_id'] + 1 - $forum_row['left_id']; - $diff_down = $target['right_id'] - $forum_row['right_id']; - - $move_up_left = $forum_row['right_id'] + 1; - $move_up_right = $target['right_id']; - } - - // Now do the dirty job - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET left_id = left_id + CASE - WHEN left_id BETWEEN {$move_up_left} AND {$move_up_right} THEN -{$diff_up} - ELSE {$diff_down} - END, - right_id = right_id + CASE - WHEN right_id BETWEEN {$move_up_left} AND {$move_up_right} THEN -{$diff_up} - ELSE {$diff_down} - END, - forum_parents = '' - WHERE - left_id BETWEEN {$left_id} AND {$right_id} - AND right_id BETWEEN {$left_id} AND {$right_id}"; - $db->sql_query($sql); - - return $target['forum_name']; - } - - /** - * Display progress bar for syncinc forums - */ - function display_progress_bar($start, $total) - { - global $template, $user; - - adm_page_header($user->lang['SYNC_IN_PROGRESS']); - - $template->set_filenames(array( - 'body' => 'progress_bar.html') - ); - - $template->assign_vars(array( - 'L_PROGRESS' => $user->lang['SYNC_IN_PROGRESS'], - 'L_PROGRESS_EXPLAIN' => ($start && $total) ? sprintf($user->lang['SYNC_IN_PROGRESS_EXPLAIN'], $start, $total) : $user->lang['SYNC_IN_PROGRESS']) - ); - - adm_page_footer(); - } - - /** - * Display copy permission page - * Not used at the moment - we will have a look at it for 3.0.7 - */ - function copy_permission_page($forum_data) - { - global $phpEx, $phpbb_admin_path, $template, $user; - - $acl_url = '&mode=setting_forum_local&forum_id[]=' . $forum_data['forum_id']; - $action = append_sid($this->u_action . "&parent_id={$this->parent_id}&f={$forum_data['forum_id']}&action=copy_perm"); - - $l_acl = sprintf($user->lang['COPY_TO_ACL'], '', ''); - - $this->tpl_name = 'acp_forums_copy_perm'; - - $template->assign_vars(array( - 'U_ACL' => append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions' . $acl_url), - 'L_ACL_LINK' => $l_acl, - 'L_BACK_LINK' => adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), - 'S_COPY_ACTION' => $action, - 'S_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $forum_data['forum_id'], false, false, false), - )); - } - -} diff --git a/install/update/new/includes/acp/acp_help_phpbb.php b/install/update/new/includes/acp/acp_help_phpbb.php deleted file mode 100644 index 798cff5..0000000 --- a/install/update/new/includes/acp/acp_help_phpbb.php +++ /dev/null @@ -1,146 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -class acp_help_phpbb -{ - var $u_action; - - function main($id, $mode) - { - global $config, $request, $template, $user, $phpbb_dispatcher, $phpbb_admin_path, $phpbb_root_path, $phpEx; - - if (!class_exists('phpbb_questionnaire_data_collector')) - { - include($phpbb_root_path . 'includes/questionnaire/questionnaire.' . $phpEx); - } - - $collect_url = "https://www.phpbb.com/statistics/send"; - - $this->tpl_name = 'acp_help_phpbb'; - $this->page_title = 'ACP_HELP_PHPBB'; - - $submit = ($request->is_set_post('submit')) ? true : false; - - $form_key = 'acp_help_phpbb'; - add_form_key($form_key); - $error = array(); - - if ($submit && !check_form_key($form_key)) - { - $error[] = $user->lang['FORM_INVALID']; - } - // Do not write values if there is an error - if (count($error)) - { - $submit = false; - } - - // generate a unique id if necessary - if (!isset($config['questionnaire_unique_id'])) - { - $install_id = unique_id(); - $config->set('questionnaire_unique_id', $install_id); - } - else - { - $install_id = $config['questionnaire_unique_id']; - } - - $collector = new phpbb_questionnaire_data_collector($install_id); - - // Add data provider - $collector->add_data_provider(new phpbb_questionnaire_php_data_provider()); - $collector->add_data_provider(new phpbb_questionnaire_system_data_provider()); - $collector->add_data_provider(new phpbb_questionnaire_phpbb_data_provider($config)); - - /** - * Event to modify ACP help phpBB page and/or listen to submit - * - * @event core.acp_help_phpbb_submit_before - * @var boolean submit Do we display the form or process the submission - * @since 3.2.0-RC2 - */ - $vars = array('submit'); - extract($phpbb_dispatcher->trigger_event('core.acp_help_phpbb_submit_before', compact($vars))); - - if ($submit) - { - $config->set('help_send_statistics', $request->variable('help_send_statistics', false)); - $response = $request->variable('send_statistics_response', ''); - - $config->set('help_send_statistics_time', time()); - - if (!empty($response)) - { - $decoded_response = json_decode(htmlspecialchars_decode($response), true); - - if ($decoded_response && isset($decoded_response['status']) && $decoded_response['status'] == 'ok') - { - trigger_error($user->lang('THANKS_SEND_STATISTICS') . adm_back_link($this->u_action)); - } - else - { - trigger_error($user->lang('FAIL_SEND_STATISTICS') . adm_back_link($this->u_action), E_USER_WARNING); - } - } - - trigger_error($user->lang('CONFIG_UPDATED') . adm_back_link($this->u_action)); - } - - $template->assign_vars(array( - 'U_COLLECT_STATS' => $collect_url, - 'S_COLLECT_STATS' => (!empty($config['help_send_statistics'])) ? true : false, - 'S_STATS' => $collector->get_data_raw(), - 'S_STATS_DATA' => json_encode($collector->get_data_raw()), - 'U_ACP_MAIN' => append_sid("{$phpbb_admin_path}index.$phpEx"), - 'U_ACTION' => $this->u_action, - // Pass earliest time we should try to send stats again - 'COLLECT_STATS_TIME' => intval($config['help_send_statistics_time']) + 86400, - )); - - $raw = $collector->get_data_raw(); - - foreach ($raw as $provider => $data) - { - if ($provider == 'install_id') - { - $data = array($provider => $data); - } - - $template->assign_block_vars('providers', array( - 'NAME' => htmlspecialchars($provider), - )); - - foreach ($data as $key => $value) - { - if (is_array($value)) - { - $value = utf8_wordwrap(serialize($value), 75, "\n", true); - } - - $template->assign_block_vars('providers.values', array( - 'KEY' => utf8_htmlspecialchars($key), - 'VALUE' => utf8_htmlspecialchars($value), - )); - } - } - } -} diff --git a/install/update/new/includes/acp/acp_main.php b/install/update/new/includes/acp/acp_main.php deleted file mode 100644 index 27fac54..0000000 --- a/install/update/new/includes/acp/acp_main.php +++ /dev/null @@ -1,707 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -class acp_main -{ - var $u_action; - - function main($id, $mode) - { - global $config, $db, $cache, $user, $auth, $template, $request, $phpbb_log; - global $phpbb_root_path, $phpbb_admin_path, $phpEx, $phpbb_container, $phpbb_dispatcher, $phpbb_filesystem; - - // Show restore permissions notice - if ($user->data['user_perm_from'] && $auth->acl_get('a_switchperm')) - { - $this->tpl_name = 'acp_main'; - $this->page_title = 'ACP_MAIN'; - - $sql = 'SELECT user_id, username, user_colour - FROM ' . USERS_TABLE . ' - WHERE user_id = ' . $user->data['user_perm_from']; - $result = $db->sql_query($sql); - $user_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $perm_from = get_username_string('full', $user_row['user_id'], $user_row['username'], $user_row['user_colour']); - - $template->assign_vars(array( - 'S_RESTORE_PERMISSIONS' => true, - 'U_RESTORE_PERMISSIONS' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=restore_perm'), - 'PERM_FROM' => $perm_from, - 'L_PERMISSIONS_TRANSFERRED_EXPLAIN' => sprintf($user->lang['PERMISSIONS_TRANSFERRED_EXPLAIN'], $perm_from, append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=restore_perm')), - )); - - return; - } - - $action = $request->variable('action', ''); - - if ($action) - { - if ($action === 'admlogout') - { - $user->unset_admin(); - redirect(append_sid("{$phpbb_root_path}index.$phpEx")); - } - - if (!confirm_box(true)) - { - switch ($action) - { - case 'online': - $confirm = true; - $confirm_lang = 'RESET_ONLINE_CONFIRM'; - break; - case 'stats': - $confirm = true; - $confirm_lang = 'RESYNC_STATS_CONFIRM'; - break; - case 'user': - $confirm = true; - $confirm_lang = 'RESYNC_POSTCOUNTS_CONFIRM'; - break; - case 'date': - $confirm = true; - $confirm_lang = 'RESET_DATE_CONFIRM'; - break; - case 'db_track': - $confirm = true; - $confirm_lang = 'RESYNC_POST_MARKING_CONFIRM'; - break; - case 'purge_cache': - $confirm = true; - $confirm_lang = 'PURGE_CACHE_CONFIRM'; - break; - case 'purge_sessions': - $confirm = true; - $confirm_lang = 'PURGE_SESSIONS_CONFIRM'; - break; - - default: - $confirm = true; - $confirm_lang = 'CONFIRM_OPERATION'; - } - - if ($confirm) - { - confirm_box(false, $user->lang[$confirm_lang], build_hidden_fields(array( - 'i' => $id, - 'mode' => $mode, - 'action' => $action, - ))); - } - } - else - { - switch ($action) - { - - case 'online': - if (!$auth->acl_get('a_board')) - { - send_status_line(403, 'Forbidden'); - trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - $config->set('record_online_users', 1, false); - $config->set('record_online_date', time(), false); - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_RESET_ONLINE'); - - if ($request->is_ajax()) - { - trigger_error('RESET_ONLINE_SUCCESS'); - } - break; - - case 'stats': - if (!$auth->acl_get('a_board')) - { - send_status_line(403, 'Forbidden'); - trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - $sql = 'SELECT COUNT(post_id) AS stat - FROM ' . POSTS_TABLE . ' - WHERE post_visibility = ' . ITEM_APPROVED; - $result = $db->sql_query($sql); - $config->set('num_posts', (int) $db->sql_fetchfield('stat'), false); - $db->sql_freeresult($result); - - $sql = 'SELECT COUNT(topic_id) AS stat - FROM ' . TOPICS_TABLE . ' - WHERE topic_visibility = ' . ITEM_APPROVED; - $result = $db->sql_query($sql); - $config->set('num_topics', (int) $db->sql_fetchfield('stat'), false); - $db->sql_freeresult($result); - - $sql = 'SELECT COUNT(user_id) AS stat - FROM ' . USERS_TABLE . ' - WHERE user_type IN (' . USER_NORMAL . ',' . USER_FOUNDER . ')'; - $result = $db->sql_query($sql); - $config->set('num_users', (int) $db->sql_fetchfield('stat'), false); - $db->sql_freeresult($result); - - $sql = 'SELECT COUNT(attach_id) as stat - FROM ' . ATTACHMENTS_TABLE . ' - WHERE is_orphan = 0'; - $result = $db->sql_query($sql); - $config->set('num_files', (int) $db->sql_fetchfield('stat'), false); - $db->sql_freeresult($result); - - $sql = 'SELECT SUM(filesize) as stat - FROM ' . ATTACHMENTS_TABLE . ' - WHERE is_orphan = 0'; - $result = $db->sql_query($sql); - $config->set('upload_dir_size', (float) $db->sql_fetchfield('stat'), false); - $db->sql_freeresult($result); - - if (!function_exists('update_last_username')) - { - include($phpbb_root_path . "includes/functions_user.$phpEx"); - } - update_last_username(); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_RESYNC_STATS'); - - if ($request->is_ajax()) - { - trigger_error('RESYNC_STATS_SUCCESS'); - } - break; - - case 'user': - if (!$auth->acl_get('a_board')) - { - send_status_line(403, 'Forbidden'); - trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - // Resync post counts - $start = $max_post_id = 0; - - // Find the maximum post ID, we can only stop the cycle when we've reached it - $sql = 'SELECT MAX(forum_last_post_id) as max_post_id - FROM ' . FORUMS_TABLE; - $result = $db->sql_query($sql); - $max_post_id = (int) $db->sql_fetchfield('max_post_id'); - $db->sql_freeresult($result); - - // No maximum post id? :o - if (!$max_post_id) - { - $sql = 'SELECT MAX(post_id) as max_post_id - FROM ' . POSTS_TABLE; - $result = $db->sql_query($sql); - $max_post_id = (int) $db->sql_fetchfield('max_post_id'); - $db->sql_freeresult($result); - } - - // Still no maximum post id? Then we are finished - if (!$max_post_id) - { - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_RESYNC_POSTCOUNTS'); - break; - } - - $step = ($config['num_posts']) ? (max((int) ($config['num_posts'] / 5), 20000)) : 20000; - $db->sql_query('UPDATE ' . USERS_TABLE . ' SET user_posts = 0'); - - while ($start < $max_post_id) - { - $sql = 'SELECT COUNT(post_id) AS num_posts, poster_id - FROM ' . POSTS_TABLE . ' - WHERE post_id BETWEEN ' . ($start + 1) . ' AND ' . ($start + $step) . ' - AND post_postcount = 1 AND post_visibility = ' . ITEM_APPROVED . ' - GROUP BY poster_id'; - $result = $db->sql_query($sql); - - if ($row = $db->sql_fetchrow($result)) - { - do - { - $sql = 'UPDATE ' . USERS_TABLE . " SET user_posts = user_posts + {$row['num_posts']} WHERE user_id = {$row['poster_id']}"; - $db->sql_query($sql); - } - while ($row = $db->sql_fetchrow($result)); - } - $db->sql_freeresult($result); - - $start += $step; - } - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_RESYNC_POSTCOUNTS'); - - if ($request->is_ajax()) - { - trigger_error('RESYNC_POSTCOUNTS_SUCCESS'); - } - break; - - case 'date': - if (!$auth->acl_get('a_board')) - { - send_status_line(403, 'Forbidden'); - trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - $config->set('board_startdate', time() - 1); - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_RESET_DATE'); - - if ($request->is_ajax()) - { - trigger_error('RESET_DATE_SUCCESS'); - } - break; - - case 'db_track': - switch ($db->get_sql_layer()) - { - case 'sqlite3': - $db->sql_query('DELETE FROM ' . TOPICS_POSTED_TABLE); - break; - - default: - $db->sql_query('TRUNCATE TABLE ' . TOPICS_POSTED_TABLE); - break; - } - - // This can get really nasty... therefore we only do the last six months - $get_from_time = time() - (6 * 4 * 7 * 24 * 60 * 60); - - // Select forum ids, do not include categories - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE . ' - WHERE forum_type <> ' . FORUM_CAT; - $result = $db->sql_query($sql); - - $forum_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $forum_ids[] = $row['forum_id']; - } - $db->sql_freeresult($result); - - // Any global announcements? ;) - $forum_ids[] = 0; - - // Now go through the forums and get us some topics... - foreach ($forum_ids as $forum_id) - { - $sql = 'SELECT p.poster_id, p.topic_id - FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t - WHERE t.forum_id = ' . $forum_id . ' - AND t.topic_moved_id = 0 - AND t.topic_last_post_time > ' . $get_from_time . ' - AND t.topic_id = p.topic_id - AND p.poster_id <> ' . ANONYMOUS . ' - GROUP BY p.poster_id, p.topic_id'; - $result = $db->sql_query($sql); - - $posted = array(); - while ($row = $db->sql_fetchrow($result)) - { - $posted[$row['poster_id']][] = $row['topic_id']; - } - $db->sql_freeresult($result); - - $sql_ary = array(); - foreach ($posted as $user_id => $topic_row) - { - foreach ($topic_row as $topic_id) - { - $sql_ary[] = array( - 'user_id' => (int) $user_id, - 'topic_id' => (int) $topic_id, - 'topic_posted' => 1, - ); - } - } - unset($posted); - - if (count($sql_ary)) - { - $db->sql_multi_insert(TOPICS_POSTED_TABLE, $sql_ary); - } - } - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_RESYNC_POST_MARKING'); - - if ($request->is_ajax()) - { - trigger_error('RESYNC_POST_MARKING_SUCCESS'); - } - break; - - case 'purge_cache': - $config->increment('assets_version', 1); - $cache->purge(); - - // Remove old renderers from the text_formatter service. Since this - // operation is performed after the cache is purged, there is not "current" - // renderer and in effect all renderers will be purged - $phpbb_container->get('text_formatter.cache')->tidy(); - - // Clear permissions - $auth->acl_clear_prefetch(); - phpbb_cache_moderators($db, $cache, $auth); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_PURGE_CACHE'); - - if ($request->is_ajax()) - { - trigger_error('PURGE_CACHE_SUCCESS'); - } - break; - - case 'purge_sessions': - if ((int) $user->data['user_type'] !== USER_FOUNDER) - { - send_status_line(403, 'Forbidden'); - trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - $tables = array(CONFIRM_TABLE, SESSIONS_TABLE); - - foreach ($tables as $table) - { - switch ($db->get_sql_layer()) - { - case 'sqlite3': - $db->sql_query("DELETE FROM $table"); - break; - - default: - $db->sql_query("TRUNCATE TABLE $table"); - break; - } - } - - // let's restore the admin session - $reinsert_ary = array( - 'session_id' => (string) $user->session_id, - 'session_page' => (string) substr($user->page['page'], 0, 199), - 'session_forum_id' => $user->page['forum'], - 'session_user_id' => (int) $user->data['user_id'], - 'session_start' => (int) $user->data['session_start'], - 'session_last_visit' => (int) $user->data['session_last_visit'], - 'session_time' => (int) $user->time_now, - 'session_browser' => (string) trim(substr($user->browser, 0, 149)), - 'session_forwarded_for' => (string) $user->forwarded_for, - 'session_ip' => (string) $user->ip, - 'session_autologin' => (int) $user->data['session_autologin'], - 'session_admin' => 1, - 'session_viewonline' => (int) $user->data['session_viewonline'], - ); - - $sql = 'INSERT INTO ' . SESSIONS_TABLE . ' ' . $db->sql_build_array('INSERT', $reinsert_ary); - $db->sql_query($sql); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_PURGE_SESSIONS'); - - if ($request->is_ajax()) - { - trigger_error('PURGE_SESSIONS_SUCCESS'); - } - break; - } - } - } - - // Version check - $user->add_lang('install'); - - if ($auth->acl_get('a_server') && version_compare(PHP_VERSION, '5.4.0', '<')) - { - $template->assign_vars(array( - 'S_PHP_VERSION_OLD' => true, - 'L_PHP_VERSION_OLD' => sprintf($user->lang['PHP_VERSION_OLD'], PHP_VERSION, '5.4.0', '', ''), - )); - } - - if ($auth->acl_get('a_board')) - { - $version_helper = $phpbb_container->get('version_helper'); - try - { - $recheck = $request->variable('versioncheck_force', false); - $updates_available = $version_helper->get_update_on_branch($recheck); - $upgrades_available = $version_helper->get_suggested_updates(); - if (!empty($upgrades_available)) - { - $upgrades_available = array_pop($upgrades_available); - } - - $template->assign_vars(array( - 'S_VERSION_UP_TO_DATE' => empty($updates_available), - 'S_VERSION_UPGRADEABLE' => !empty($upgrades_available), - 'UPGRADE_INSTRUCTIONS' => !empty($upgrades_available) ? $user->lang('UPGRADE_INSTRUCTIONS', $upgrades_available['current'], $upgrades_available['announcement']) : false, - )); - } - catch (\RuntimeException $e) - { - $message = call_user_func_array(array($user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters())); - $template->assign_vars(array( - 'S_VERSIONCHECK_FAIL' => true, - 'VERSIONCHECK_FAIL_REASON' => ($e->getMessage() !== 'VERSIONCHECK_FAIL') ? $message : '', - )); - } - } - else - { - // We set this template var to true, to not display an outdated version notice. - $template->assign_var('S_VERSION_UP_TO_DATE', true); - } - - // Incomplete update? - if (phpbb_version_compare($config['version'], PHPBB_VERSION, '<')) - { - $template->assign_var('S_UPDATE_INCOMPLETE', true); - } - - /** - * Notice admin - * - * @event core.acp_main_notice - * @since 3.1.0-RC3 - */ - $phpbb_dispatcher->dispatch('core.acp_main_notice'); - - // Get forum statistics - $total_posts = $config['num_posts']; - $total_topics = $config['num_topics']; - $total_users = $config['num_users']; - $total_files = $config['num_files']; - - $start_date = $user->format_date($config['board_startdate']); - - $boarddays = (time() - $config['board_startdate']) / 86400; - - $posts_per_day = sprintf('%.2f', $total_posts / $boarddays); - $topics_per_day = sprintf('%.2f', $total_topics / $boarddays); - $users_per_day = sprintf('%.2f', $total_users / $boarddays); - $files_per_day = sprintf('%.2f', $total_files / $boarddays); - - $upload_dir_size = get_formatted_filesize($config['upload_dir_size']); - - $avatar_dir_size = 0; - - if ($avatar_dir = @opendir($phpbb_root_path . $config['avatar_path'])) - { - while (($file = readdir($avatar_dir)) !== false) - { - if ($file[0] != '.' && $file != 'CVS' && strpos($file, 'index.') === false) - { - $avatar_dir_size += filesize($phpbb_root_path . $config['avatar_path'] . '/' . $file); - } - } - closedir($avatar_dir); - - $avatar_dir_size = get_formatted_filesize($avatar_dir_size); - } - else - { - // Couldn't open Avatar dir. - $avatar_dir_size = $user->lang['NOT_AVAILABLE']; - } - - if ($posts_per_day > $total_posts) - { - $posts_per_day = $total_posts; - } - - if ($topics_per_day > $total_topics) - { - $topics_per_day = $total_topics; - } - - if ($users_per_day > $total_users) - { - $users_per_day = $total_users; - } - - if ($files_per_day > $total_files) - { - $files_per_day = $total_files; - } - - if ($config['allow_attachments'] || $config['allow_pm_attach']) - { - $sql = 'SELECT COUNT(attach_id) AS total_orphan - FROM ' . ATTACHMENTS_TABLE . ' - WHERE is_orphan = 1 - AND filetime < ' . (time() - 3*60*60); - $result = $db->sql_query($sql); - $total_orphan = (int) $db->sql_fetchfield('total_orphan'); - $db->sql_freeresult($result); - } - else - { - $total_orphan = false; - } - - $dbsize = get_database_size(); - - $template->assign_vars(array( - 'TOTAL_POSTS' => $total_posts, - 'POSTS_PER_DAY' => $posts_per_day, - 'TOTAL_TOPICS' => $total_topics, - 'TOPICS_PER_DAY' => $topics_per_day, - 'TOTAL_USERS' => $total_users, - 'USERS_PER_DAY' => $users_per_day, - 'TOTAL_FILES' => $total_files, - 'FILES_PER_DAY' => $files_per_day, - 'START_DATE' => $start_date, - 'AVATAR_DIR_SIZE' => $avatar_dir_size, - 'DBSIZE' => $dbsize, - 'UPLOAD_DIR_SIZE' => $upload_dir_size, - 'TOTAL_ORPHAN' => $total_orphan, - 'S_TOTAL_ORPHAN' => ($total_orphan === false) ? false : true, - 'GZIP_COMPRESSION' => ($config['gzip_compress'] && @extension_loaded('zlib')) ? $user->lang['ON'] : $user->lang['OFF'], - 'DATABASE_INFO' => $db->sql_server_info(), - 'PHP_VERSION_INFO' => PHP_VERSION, - 'BOARD_VERSION' => $config['version'], - - 'U_ACTION' => $this->u_action, - 'U_ADMIN_LOG' => append_sid("{$phpbb_admin_path}index.$phpEx", 'i=logs&mode=admin'), - 'U_INACTIVE_USERS' => append_sid("{$phpbb_admin_path}index.$phpEx", 'i=inactive&mode=list'), - 'U_VERSIONCHECK' => append_sid("{$phpbb_admin_path}index.$phpEx", 'i=update&mode=version_check'), - 'U_VERSIONCHECK_FORCE' => append_sid("{$phpbb_admin_path}index.$phpEx", 'versioncheck_force=1'), - 'U_ATTACH_ORPHAN' => append_sid("{$phpbb_admin_path}index.$phpEx", 'i=acp_attachments&mode=orphan'), - - 'S_VERSIONCHECK' => ($auth->acl_get('a_board')) ? true : false, - 'S_ACTION_OPTIONS' => ($auth->acl_get('a_board')) ? true : false, - 'S_FOUNDER' => ($user->data['user_type'] == USER_FOUNDER) ? true : false, - ) - ); - - $log_data = array(); - $log_count = false; - - if ($auth->acl_get('a_viewlogs')) - { - view_log('admin', $log_data, $log_count, 5); - - foreach ($log_data as $row) - { - $template->assign_block_vars('log', array( - 'USERNAME' => $row['username_full'], - 'IP' => $row['ip'], - 'DATE' => $user->format_date($row['time']), - 'ACTION' => $row['action']) - ); - } - } - - if ($auth->acl_get('a_user')) - { - $user->add_lang('memberlist'); - - $inactive = array(); - $inactive_count = 0; - - view_inactive_users($inactive, $inactive_count, 10); - - foreach ($inactive as $row) - { - $template->assign_block_vars('inactive', array( - 'INACTIVE_DATE' => $user->format_date($row['user_inactive_time']), - 'REMINDED_DATE' => $user->format_date($row['user_reminded_time']), - 'JOINED' => $user->format_date($row['user_regdate']), - 'LAST_VISIT' => (!$row['user_lastvisit']) ? ' - ' : $user->format_date($row['user_lastvisit']), - - 'REASON' => $row['inactive_reason'], - 'USER_ID' => $row['user_id'], - 'POSTS' => ($row['user_posts']) ? $row['user_posts'] : 0, - 'REMINDED' => $row['user_reminded'], - - 'REMINDED_EXPLAIN' => $user->lang('USER_LAST_REMINDED', (int) $row['user_reminded'], $user->format_date($row['user_reminded_time'])), - - 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], false, append_sid("{$phpbb_admin_path}index.$phpEx", 'i=users&mode=overview')), - 'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), - 'USER_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), - - 'U_USER_ADMIN' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=users&mode=overview&u={$row['user_id']}"), - 'U_SEARCH_USER' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id={$row['user_id']}&sr=posts") : '', - )); - } - - $option_ary = array('activate' => 'ACTIVATE', 'delete' => 'DELETE'); - if ($config['email_enable']) - { - $option_ary += array('remind' => 'REMIND'); - } - - $template->assign_vars(array( - 'S_INACTIVE_USERS' => true, - 'S_INACTIVE_OPTIONS' => build_select($option_ary)) - ); - } - - // Warn if install is still present - if (!defined('IN_INSTALL') && !$phpbb_container->getParameter('allow_install_dir') && file_exists($phpbb_root_path . 'install') && !is_file($phpbb_root_path . 'install')) - { - $template->assign_var('S_REMOVE_INSTALL', true); - } - - // Warn if no search index is created - if ($config['num_posts'] && class_exists($config['search_type'])) - { - $error = false; - $search_type = $config['search_type']; - $search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher); - - if (!$search->index_created()) - { - $template->assign_vars(array( - 'S_SEARCH_INDEX_MISSING' => true, - 'L_NO_SEARCH_INDEX' => $user->lang('NO_SEARCH_INDEX', $search->get_name(), '', ''), - )); - } - } - - if (!defined('PHPBB_DISABLE_CONFIG_CHECK') && file_exists($phpbb_root_path . 'config.' . $phpEx) && $phpbb_filesystem->is_writable($phpbb_root_path . 'config.' . $phpEx)) - { - // World-Writable? (000x) - $template->assign_var('S_WRITABLE_CONFIG', (bool) (@fileperms($phpbb_root_path . 'config.' . $phpEx) & 0x0002)); - } - - if (extension_loaded('mbstring')) - { - $template->assign_vars(array( - 'S_MBSTRING_LOADED' => true, - 'S_MBSTRING_FUNC_OVERLOAD_FAIL' => (intval(@ini_get('mbstring.func_overload')) & (MB_OVERLOAD_MAIL | MB_OVERLOAD_STRING)), - 'S_MBSTRING_ENCODING_TRANSLATION_FAIL' => (@ini_get('mbstring.encoding_translation') != 0), - 'S_MBSTRING_HTTP_INPUT_FAIL' => !in_array(@ini_get('mbstring.http_input'), array('pass', '')), - 'S_MBSTRING_HTTP_OUTPUT_FAIL' => !in_array(@ini_get('mbstring.http_output'), array('pass', '')), - )); - } - - // Fill dbms version if not yet filled - if (empty($config['dbms_version'])) - { - $config->set('dbms_version', $db->sql_server_info(true)); - } - - $this->tpl_name = 'acp_main'; - $this->page_title = 'ACP_MAIN'; - } -} diff --git a/install/update/new/includes/acp/acp_permissions.php b/install/update/new/includes/acp/acp_permissions.php deleted file mode 100644 index 59bf366..0000000 --- a/install/update/new/includes/acp/acp_permissions.php +++ /dev/null @@ -1,1346 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -class acp_permissions -{ - var $u_action; - var $permission_dropdown; - - /** - * @var $phpbb_permissions \phpbb\permissions - */ - protected $permissions; - - function main($id, $mode) - { - global $db, $user, $auth, $template, $phpbb_container, $request; - global $config, $phpbb_root_path, $phpEx; - - if (!function_exists('user_get_id_name')) - { - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - } - - if (!class_exists('auth_admin')) - { - include($phpbb_root_path . 'includes/acp/auth.' . $phpEx); - } - - $this->permissions = $phpbb_container->get('acl.permissions'); - - $auth_admin = new auth_admin(); - - $user->add_lang('acp/permissions'); - add_permission_language(); - - $this->tpl_name = 'acp_permissions'; - - // Trace has other vars - if ($mode == 'trace') - { - $user_id = $request->variable('u', 0); - $forum_id = $request->variable('f', 0); - $permission = $request->variable('auth', ''); - - $this->tpl_name = 'permission_trace'; - - if ($user_id && isset($auth_admin->acl_options['id'][$permission]) && $auth->acl_get('a_viewauth')) - { - $this->page_title = sprintf($user->lang['TRACE_PERMISSION'], $this->permissions->get_permission_lang($permission)); - $this->permission_trace($user_id, $forum_id, $permission); - return; - } - trigger_error('NO_MODE', E_USER_ERROR); - } - - // Copy forum permissions - if ($mode == 'setting_forum_copy') - { - $this->tpl_name = 'permission_forum_copy'; - - if ($auth->acl_get('a_fauth') && $auth->acl_get('a_authusers') && $auth->acl_get('a_authgroups') && $auth->acl_get('a_mauth')) - { - $this->page_title = 'ACP_FORUM_PERMISSIONS_COPY'; - $this->copy_forum_permissions(); - return; - } - - trigger_error('NO_MODE', E_USER_ERROR); - } - - // Set some vars - $action = $request->variable('action', array('' => 0)); - $action = key($action); - $action = (isset($_POST['psubmit'])) ? 'apply_permissions' : $action; - - $all_forums = $request->variable('all_forums', 0); - $subforum_id = $request->variable('subforum_id', 0); - $forum_id = $request->variable('forum_id', array(0)); - - $username = $request->variable('username', array(''), true); - $usernames = $request->variable('usernames', '', true); - $user_id = $request->variable('user_id', array(0)); - - $group_id = $request->variable('group_id', array(0)); - $select_all_groups = $request->variable('select_all_groups', 0); - - $form_name = 'acp_permissions'; - add_form_key($form_name); - - // If select all groups is set, we pre-build the group id array (this option is used for other screens to link to the permission settings screen) - if ($select_all_groups) - { - // Add default groups to selection - $sql_and = (!$config['coppa_enable']) ? " AND group_name <> 'REGISTERED_COPPA'" : ''; - - $sql = 'SELECT group_id - FROM ' . GROUPS_TABLE . ' - WHERE group_type = ' . GROUP_SPECIAL . " - $sql_and"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $group_id[] = $row['group_id']; - } - $db->sql_freeresult($result); - } - - // Map usernames to ids and vice versa - if ($usernames) - { - $username = explode("\n", $usernames); - } - unset($usernames); - - if (count($username) && !count($user_id)) - { - user_get_id_name($user_id, $username); - - if (!count($user_id)) - { - trigger_error($user->lang['SELECTED_USER_NOT_EXIST'] . adm_back_link($this->u_action), E_USER_WARNING); - } - } - unset($username); - - // Build forum ids (of all forums are checked or subforum listing used) - if ($all_forums) - { - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE . ' - ORDER BY left_id'; - $result = $db->sql_query($sql); - - $forum_id = array(); - while ($row = $db->sql_fetchrow($result)) - { - $forum_id[] = (int) $row['forum_id']; - } - $db->sql_freeresult($result); - } - else if ($subforum_id) - { - $forum_id = array(); - foreach (get_forum_branch($subforum_id, 'children') as $row) - { - $forum_id[] = (int) $row['forum_id']; - } - } - - // Define some common variables for every mode - $permission_scope = (strpos($mode, '_global') !== false) ? 'global' : 'local'; - - // Showing introductionary page? - if ($mode == 'intro') - { - $this->page_title = 'ACP_PERMISSIONS'; - - $template->assign_vars(array( - 'S_INTRO' => true) - ); - - return; - } - - switch ($mode) - { - case 'setting_user_global': - case 'setting_group_global': - $this->permission_dropdown = array('u_', 'm_', 'a_'); - $permission_victim = ($mode == 'setting_user_global') ? array('user') : array('group'); - $this->page_title = ($mode == 'setting_user_global') ? 'ACP_USERS_PERMISSIONS' : 'ACP_GROUPS_PERMISSIONS'; - break; - - case 'setting_user_local': - case 'setting_group_local': - $this->permission_dropdown = array('f_', 'm_'); - $permission_victim = ($mode == 'setting_user_local') ? array('user', 'forums') : array('group', 'forums'); - $this->page_title = ($mode == 'setting_user_local') ? 'ACP_USERS_FORUM_PERMISSIONS' : 'ACP_GROUPS_FORUM_PERMISSIONS'; - break; - - case 'setting_admin_global': - case 'setting_mod_global': - $this->permission_dropdown = (strpos($mode, '_admin_') !== false) ? array('a_') : array('m_'); - $permission_victim = array('usergroup'); - $this->page_title = ($mode == 'setting_admin_global') ? 'ACP_ADMINISTRATORS' : 'ACP_GLOBAL_MODERATORS'; - break; - - case 'setting_mod_local': - case 'setting_forum_local': - $this->permission_dropdown = ($mode == 'setting_mod_local') ? array('m_') : array('f_'); - $permission_victim = array('forums', 'usergroup'); - $this->page_title = ($mode == 'setting_mod_local') ? 'ACP_FORUM_MODERATORS' : 'ACP_FORUM_PERMISSIONS'; - break; - - case 'view_admin_global': - case 'view_user_global': - case 'view_mod_global': - $this->permission_dropdown = ($mode == 'view_admin_global') ? array('a_') : (($mode == 'view_user_global') ? array('u_') : array('m_')); - $permission_victim = array('usergroup_view'); - $this->page_title = ($mode == 'view_admin_global') ? 'ACP_VIEW_ADMIN_PERMISSIONS' : (($mode == 'view_user_global') ? 'ACP_VIEW_USER_PERMISSIONS' : 'ACP_VIEW_GLOBAL_MOD_PERMISSIONS'); - break; - - case 'view_mod_local': - case 'view_forum_local': - $this->permission_dropdown = ($mode == 'view_mod_local') ? array('m_') : array('f_'); - $permission_victim = array('forums', 'usergroup_view'); - $this->page_title = ($mode == 'view_mod_local') ? 'ACP_VIEW_FORUM_MOD_PERMISSIONS' : 'ACP_VIEW_FORUM_PERMISSIONS'; - break; - - default: - trigger_error('NO_MODE', E_USER_ERROR); - break; - } - - $template->assign_vars(array( - 'L_TITLE' => $user->lang[$this->page_title], - 'L_EXPLAIN' => $user->lang[$this->page_title . '_EXPLAIN']) - ); - - // Get permission type - $permission_type = $request->variable('type', $this->permission_dropdown[0]); - - if (!in_array($permission_type, $this->permission_dropdown)) - { - trigger_error($user->lang['WRONG_PERMISSION_TYPE'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - // Handle actions - if (strpos($mode, 'setting_') === 0 && $action) - { - switch ($action) - { - case 'delete': - if (confirm_box(true)) - { - // All users/groups selected? - $all_users = (isset($_POST['all_users'])) ? true : false; - $all_groups = (isset($_POST['all_groups'])) ? true : false; - - if ($all_users || $all_groups) - { - $items = $this->retrieve_defined_user_groups($permission_scope, $forum_id, $permission_type); - - if ($all_users && count($items['user_ids'])) - { - $user_id = $items['user_ids']; - } - else if ($all_groups && count($items['group_ids'])) - { - $group_id = $items['group_ids']; - } - } - - if (count($user_id) || count($group_id)) - { - $this->remove_permissions($mode, $permission_type, $auth_admin, $user_id, $group_id, $forum_id); - } - else - { - trigger_error($user->lang['NO_USER_GROUP_SELECTED'] . adm_back_link($this->u_action), E_USER_WARNING); - } - } - else - { - if (isset($_POST['cancel'])) - { - $u_redirect = $this->u_action . '&type=' . $permission_type; - foreach ($forum_id as $fid) - { - $u_redirect .= '&forum_id[]=' . $fid; - } - redirect($u_redirect); - } - - $s_hidden_fields = array( - 'i' => $id, - 'mode' => $mode, - 'action' => array($action => 1), - 'user_id' => $user_id, - 'group_id' => $group_id, - 'forum_id' => $forum_id, - 'type' => $permission_type, - ); - if (isset($_POST['all_users'])) - { - $s_hidden_fields['all_users'] = 1; - } - if (isset($_POST['all_groups'])) - { - $s_hidden_fields['all_groups'] = 1; - } - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields($s_hidden_fields)); - } - break; - - case 'apply_permissions': - if (!isset($_POST['setting'])) - { - send_status_line(403, 'Forbidden'); - trigger_error($user->lang['NO_AUTH_SETTING_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); - } - if (!check_form_key($form_name)) - { - trigger_error($user->lang['FORM_INVALID']. adm_back_link($this->u_action), E_USER_WARNING); - } - - $this->set_permissions($mode, $permission_type, $auth_admin, $user_id, $group_id); - break; - - case 'apply_all_permissions': - if (!isset($_POST['setting'])) - { - send_status_line(403, 'Forbidden'); - trigger_error($user->lang['NO_AUTH_SETTING_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); - } - if (!check_form_key($form_name)) - { - trigger_error($user->lang['FORM_INVALID']. adm_back_link($this->u_action), E_USER_WARNING); - } - - $this->set_all_permissions($mode, $permission_type, $auth_admin, $user_id, $group_id); - break; - } - } - - // Go through the screens/options needed and present them in correct order - foreach ($permission_victim as $victim) - { - switch ($victim) - { - case 'forum_dropdown': - - if (count($forum_id)) - { - $this->check_existence('forum', $forum_id); - continue 2; - } - - $template->assign_vars(array( - 'S_SELECT_FORUM' => true, - 'S_FORUM_OPTIONS' => make_forum_select(false, false, true, false, false)) - ); - - break; - - case 'forums': - - if (count($forum_id)) - { - $this->check_existence('forum', $forum_id); - continue 2; - } - - $forum_list = make_forum_select(false, false, true, false, false, false, true); - - // Build forum options - $s_forum_options = ''; - foreach ($forum_list as $f_id => $f_row) - { - $s_forum_options .= ''; - } - - // Build subforum options - $s_subforum_options = $this->build_subforum_options($forum_list); - - $template->assign_vars(array( - 'S_SELECT_FORUM' => true, - 'S_FORUM_OPTIONS' => $s_forum_options, - 'S_SUBFORUM_OPTIONS' => $s_subforum_options, - 'S_FORUM_ALL' => true, - 'S_FORUM_MULTIPLE' => true) - ); - - break; - - case 'user': - - if (count($user_id)) - { - $this->check_existence('user', $user_id); - continue 2; - } - - $template->assign_vars(array( - 'S_SELECT_USER' => true, - 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=select_victim&field=username&select_single=true'), - )); - - break; - - case 'group': - - if (count($group_id)) - { - $this->check_existence('group', $group_id); - continue 2; - } - - $template->assign_vars(array( - 'S_SELECT_GROUP' => true, - 'S_GROUP_OPTIONS' => group_select_options(false, false, false), // Show all groups - )); - - break; - - case 'usergroup': - case 'usergroup_view': - - $all_users = (isset($_POST['all_users'])) ? true : false; - $all_groups = (isset($_POST['all_groups'])) ? true : false; - - if ((count($user_id) && !$all_users) || (count($group_id) && !$all_groups)) - { - if (count($user_id)) - { - $this->check_existence('user', $user_id); - } - - if (count($group_id)) - { - $this->check_existence('group', $group_id); - } - - continue 2; - } - - // Now we check the users... because the "all"-selection is different here (all defined users/groups) - $items = $this->retrieve_defined_user_groups($permission_scope, $forum_id, $permission_type); - - if ($all_users && count($items['user_ids'])) - { - $user_id = $items['user_ids']; - continue 2; - } - - if ($all_groups && count($items['group_ids'])) - { - $group_id = $items['group_ids']; - continue 2; - } - - $template->assign_vars(array( - 'S_SELECT_USERGROUP' => ($victim == 'usergroup') ? true : false, - 'S_SELECT_USERGROUP_VIEW' => ($victim == 'usergroup_view') ? true : false, - 'S_DEFINED_USER_OPTIONS' => $items['user_ids_options'], - 'S_DEFINED_GROUP_OPTIONS' => $items['group_ids_options'], - 'S_ADD_GROUP_OPTIONS' => group_select_options(false, $items['group_ids'], false), // Show all groups - 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=add_user&field=username&select_single=true'), - )); - - break; - } - - // The S_ALLOW_SELECT parameter below is a measure to lower memory usage. - // If there are more than 5 forums selected the admin is not able to select all users/groups too. - // We need to see if the number of forums can be increased or need to be decreased. - - // Setting permissions screen - $s_hidden_fields = build_hidden_fields(array( - 'user_id' => $user_id, - 'group_id' => $group_id, - 'forum_id' => $forum_id, - 'type' => $permission_type, - )); - - $template->assign_vars(array( - 'U_ACTION' => $this->u_action, - 'ANONYMOUS_USER_ID' => ANONYMOUS, - - 'S_SELECT_VICTIM' => true, - 'S_ALLOW_ALL_SELECT' => (count($forum_id) > 5) ? false : true, - 'S_CAN_SELECT_USER' => ($auth->acl_get('a_authusers')) ? true : false, - 'S_CAN_SELECT_GROUP' => ($auth->acl_get('a_authgroups')) ? true : false, - 'S_HIDDEN_FIELDS' => $s_hidden_fields) - ); - - // Let the forum names being displayed - if (count($forum_id)) - { - $sql = 'SELECT forum_name - FROM ' . FORUMS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $forum_id) . ' - ORDER BY left_id ASC'; - $result = $db->sql_query($sql); - - $forum_names = array(); - while ($row = $db->sql_fetchrow($result)) - { - $forum_names[] = $row['forum_name']; - } - $db->sql_freeresult($result); - - $template->assign_vars(array( - 'S_FORUM_NAMES' => (count($forum_names)) ? true : false, - 'FORUM_NAMES' => implode($user->lang['COMMA_SEPARATOR'], $forum_names)) - ); - } - - return; - } - - // Setting permissions screen - $s_hidden_fields = build_hidden_fields(array( - 'user_id' => $user_id, - 'group_id' => $group_id, - 'forum_id' => $forum_id, - 'type' => $permission_type, - )); - - // Do not allow forum_ids being set and no other setting defined (will bog down the server too much) - if (count($forum_id) && !count($user_id) && !count($group_id)) - { - trigger_error($user->lang['ONLY_FORUM_DEFINED'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - $template->assign_vars(array( - 'S_PERMISSION_DROPDOWN' => (count($this->permission_dropdown) > 1) ? $this->build_permission_dropdown($this->permission_dropdown, $permission_type, $permission_scope) : false, - 'L_PERMISSION_TYPE' => $this->permissions->get_type_lang($permission_type), - - 'U_ACTION' => $this->u_action, - 'S_HIDDEN_FIELDS' => $s_hidden_fields) - ); - - if (strpos($mode, 'setting_') === 0) - { - $template->assign_vars(array( - 'S_SETTING_PERMISSIONS' => true) - ); - - $hold_ary = $auth_admin->get_mask('set', (count($user_id)) ? $user_id : false, (count($group_id)) ? $group_id : false, (count($forum_id)) ? $forum_id : false, $permission_type, $permission_scope, ACL_NO); - $auth_admin->display_mask('set', $permission_type, $hold_ary, ((count($user_id)) ? 'user' : 'group'), (($permission_scope == 'local') ? true : false)); - } - else - { - $template->assign_vars(array( - 'S_VIEWING_PERMISSIONS' => true) - ); - - $hold_ary = $auth_admin->get_mask('view', (count($user_id)) ? $user_id : false, (count($group_id)) ? $group_id : false, (count($forum_id)) ? $forum_id : false, $permission_type, $permission_scope, ACL_NEVER); - $auth_admin->display_mask('view', $permission_type, $hold_ary, ((count($user_id)) ? 'user' : 'group'), (($permission_scope == 'local') ? true : false)); - } - } - - /** - * Build +subforum options - */ - function build_subforum_options($forum_list) - { - global $user; - - $s_options = ''; - - $forum_list = array_merge($forum_list); - - foreach ($forum_list as $key => $row) - { - if ($row['disabled']) - { - continue; - } - - $s_options .= ''; - } - - return $s_options; - } - - /** - * Build dropdown field for changing permission types - */ - function build_permission_dropdown($options, $default_option, $permission_scope) - { - global $auth; - - $s_dropdown_options = ''; - foreach ($options as $setting) - { - if (!$auth->acl_get('a_' . str_replace('_', '', $setting) . 'auth')) - { - continue; - } - - $selected = ($setting == $default_option) ? ' selected="selected"' : ''; - $l_setting = $this->permissions->get_type_lang($setting, $permission_scope); - $s_dropdown_options .= ''; - } - - return $s_dropdown_options; - } - - /** - * Check if selected items exist. Remove not found ids and if empty return error. - */ - function check_existence($mode, &$ids) - { - global $db, $user; - - switch ($mode) - { - case 'user': - $table = USERS_TABLE; - $sql_id = 'user_id'; - break; - - case 'group': - $table = GROUPS_TABLE; - $sql_id = 'group_id'; - break; - - case 'forum': - $table = FORUMS_TABLE; - $sql_id = 'forum_id'; - break; - } - - if (count($ids)) - { - $sql = "SELECT $sql_id - FROM $table - WHERE " . $db->sql_in_set($sql_id, $ids); - $result = $db->sql_query($sql); - - $ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $ids[] = (int) $row[$sql_id]; - } - $db->sql_freeresult($result); - } - - if (!count($ids)) - { - trigger_error($user->lang['SELECTED_' . strtoupper($mode) . '_NOT_EXIST'] . adm_back_link($this->u_action), E_USER_WARNING); - } - } - - /** - * Apply permissions - */ - function set_permissions($mode, $permission_type, $auth_admin, &$user_id, &$group_id) - { - global $db, $cache, $user, $auth; - global $request; - - $psubmit = $request->variable('psubmit', array(0 => array(0 => 0))); - - // User or group to be set? - $ug_type = (count($user_id)) ? 'user' : 'group'; - - // Check the permission setting again - if (!$auth->acl_get('a_' . str_replace('_', '', $permission_type) . 'auth') || !$auth->acl_get('a_auth' . $ug_type . 's')) - { - send_status_line(403, 'Forbidden'); - trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - // We loop through the auth settings defined in our submit - $ug_id = key($psubmit); - $forum_id = key($psubmit[$ug_id]); - - $settings = $request->variable('setting', array(0 => array(0 => array('' => 0))), false, \phpbb\request\request_interface::POST); - if (empty($settings) || empty($settings[$ug_id]) || empty($settings[$ug_id][$forum_id])) - { - trigger_error('WRONG_PERMISSION_SETTING_FORMAT', E_USER_WARNING); - } - - $auth_settings = $settings[$ug_id][$forum_id]; - - // Do we have a role we want to set? - $roles = $request->variable('role', array(0 => array(0 => 0)), false, \phpbb\request\request_interface::POST); - $assigned_role = (isset($roles[$ug_id][$forum_id])) ? (int) $roles[$ug_id][$forum_id] : 0; - - // Do the admin want to set these permissions to other items too? - $inherit = $request->variable('inherit', array(0 => array(0))); - - $ug_id = array($ug_id); - $forum_id = array($forum_id); - - if (count($inherit)) - { - foreach ($inherit as $_ug_id => $forum_id_ary) - { - // Inherit users/groups? - if (!in_array($_ug_id, $ug_id)) - { - $ug_id[] = $_ug_id; - } - - // Inherit forums? - $forum_id = array_merge($forum_id, array_keys($forum_id_ary)); - } - } - - $forum_id = array_unique($forum_id); - - // If the auth settings differ from the assigned role, then do not set a role... - if ($assigned_role) - { - if (!$this->check_assigned_role($assigned_role, $auth_settings)) - { - $assigned_role = 0; - } - } - - // Update the permission set... - $auth_admin->acl_set($ug_type, $forum_id, $ug_id, $auth_settings, $assigned_role); - - // Do we need to recache the moderator lists? - if ($permission_type == 'm_') - { - phpbb_cache_moderators($db, $cache, $auth); - } - - // Remove users who are now moderators or admins from everyones foes list - if ($permission_type == 'm_' || $permission_type == 'a_') - { - phpbb_update_foes($db, $auth, $group_id, $user_id); - } - - $this->log_action($mode, 'add', $permission_type, $ug_type, $ug_id, $forum_id); - - meta_refresh(5, $this->u_action); - trigger_error($user->lang['AUTH_UPDATED'] . adm_back_link($this->u_action)); - } - - /** - * Apply all permissions - */ - function set_all_permissions($mode, $permission_type, $auth_admin, &$user_id, &$group_id) - { - global $db, $cache, $user, $auth; - global $request; - - // User or group to be set? - $ug_type = (count($user_id)) ? 'user' : 'group'; - - // Check the permission setting again - if (!$auth->acl_get('a_' . str_replace('_', '', $permission_type) . 'auth') || !$auth->acl_get('a_auth' . $ug_type . 's')) - { - send_status_line(403, 'Forbidden'); - trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - $auth_settings = $request->variable('setting', array(0 => array(0 => array('' => 0))), false, \phpbb\request\request_interface::POST); - $auth_roles = $request->variable('role', array(0 => array(0 => 0)), false, \phpbb\request\request_interface::POST); - $ug_ids = $forum_ids = array(); - - // We need to go through the auth settings - foreach ($auth_settings as $ug_id => $forum_auth_row) - { - $ug_id = (int) $ug_id; - $ug_ids[] = $ug_id; - - foreach ($forum_auth_row as $forum_id => $auth_options) - { - $forum_id = (int) $forum_id; - $forum_ids[] = $forum_id; - - // Check role... - $assigned_role = (isset($auth_roles[$ug_id][$forum_id])) ? (int) $auth_roles[$ug_id][$forum_id] : 0; - - // If the auth settings differ from the assigned role, then do not set a role... - if ($assigned_role) - { - if (!$this->check_assigned_role($assigned_role, $auth_options)) - { - $assigned_role = 0; - } - } - - // Update the permission set... - $auth_admin->acl_set($ug_type, $forum_id, $ug_id, $auth_options, $assigned_role, false); - } - } - - $auth_admin->acl_clear_prefetch(); - - // Do we need to recache the moderator lists? - if ($permission_type == 'm_') - { - phpbb_cache_moderators($db, $cache, $auth); - } - - // Remove users who are now moderators or admins from everyones foes list - if ($permission_type == 'm_' || $permission_type == 'a_') - { - phpbb_update_foes($db, $auth, $group_id, $user_id); - } - - $this->log_action($mode, 'add', $permission_type, $ug_type, $ug_ids, $forum_ids); - - if ($mode == 'setting_forum_local' || $mode == 'setting_mod_local') - { - meta_refresh(5, $this->u_action . '&forum_id[]=' . implode('&forum_id[]=', $forum_ids)); - trigger_error($user->lang['AUTH_UPDATED'] . adm_back_link($this->u_action . '&forum_id[]=' . implode('&forum_id[]=', $forum_ids))); - } - else - { - meta_refresh(5, $this->u_action); - trigger_error($user->lang['AUTH_UPDATED'] . adm_back_link($this->u_action)); - } - } - - /** - * Compare auth settings with auth settings from role - * returns false if they differ, true if they are equal - */ - function check_assigned_role($role_id, &$auth_settings) - { - global $db; - - $sql = 'SELECT o.auth_option, r.auth_setting - FROM ' . ACL_OPTIONS_TABLE . ' o, ' . ACL_ROLES_DATA_TABLE . ' r - WHERE o.auth_option_id = r.auth_option_id - AND r.role_id = ' . $role_id; - $result = $db->sql_query($sql); - - $test_auth_settings = array(); - while ($row = $db->sql_fetchrow($result)) - { - $test_auth_settings[$row['auth_option']] = $row['auth_setting']; - } - $db->sql_freeresult($result); - - // We need to add any ACL_NO setting from auth_settings to compare correctly - foreach ($auth_settings as $option => $setting) - { - if ($setting == ACL_NO) - { - $test_auth_settings[$option] = $setting; - } - } - - if (count(array_diff_assoc($auth_settings, $test_auth_settings))) - { - return false; - } - - return true; - } - - /** - * Remove permissions - */ - function remove_permissions($mode, $permission_type, $auth_admin, &$user_id, &$group_id, &$forum_id) - { - global $user, $db, $cache, $auth; - - // User or group to be set? - $ug_type = (count($user_id)) ? 'user' : 'group'; - - // Check the permission setting again - if (!$auth->acl_get('a_' . str_replace('_', '', $permission_type) . 'auth') || !$auth->acl_get('a_auth' . $ug_type . 's')) - { - send_status_line(403, 'Forbidden'); - trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - $auth_admin->acl_delete($ug_type, (($ug_type == 'user') ? $user_id : $group_id), (count($forum_id) ? $forum_id : false), $permission_type); - - // Do we need to recache the moderator lists? - if ($permission_type == 'm_') - { - phpbb_cache_moderators($db, $cache, $auth); - } - - $this->log_action($mode, 'del', $permission_type, $ug_type, (($ug_type == 'user') ? $user_id : $group_id), (count($forum_id) ? $forum_id : array(0 => 0))); - - if ($mode == 'setting_forum_local' || $mode == 'setting_mod_local') - { - meta_refresh(5, $this->u_action . '&forum_id[]=' . implode('&forum_id[]=', $forum_id)); - trigger_error($user->lang['AUTH_UPDATED'] . adm_back_link($this->u_action . '&forum_id[]=' . implode('&forum_id[]=', $forum_id))); - } - else - { - meta_refresh(5, $this->u_action); - trigger_error($user->lang['AUTH_UPDATED'] . adm_back_link($this->u_action)); - } - } - - /** - * Log permission changes - */ - function log_action($mode, $action, $permission_type, $ug_type, $ug_id, $forum_id) - { - global $db, $user, $phpbb_log, $phpbb_container; - - if (!is_array($ug_id)) - { - $ug_id = array($ug_id); - } - - if (!is_array($forum_id)) - { - $forum_id = array($forum_id); - } - - // Logging ... first grab user or groupnames ... - $sql = ($ug_type == 'group') ? 'SELECT group_name as name, group_type FROM ' . GROUPS_TABLE . ' WHERE ' : 'SELECT username as name FROM ' . USERS_TABLE . ' WHERE '; - $sql .= $db->sql_in_set(($ug_type == 'group') ? 'group_id' : 'user_id', array_map('intval', $ug_id)); - $result = $db->sql_query($sql); - - /** @var \phpbb\group\helper $group_helper */ - $group_helper = $phpbb_container->get('group_helper'); - - $l_ug_list = ''; - while ($row = $db->sql_fetchrow($result)) - { - $group_name = $group_helper->get_name($row['name']); - $l_ug_list .= (($l_ug_list != '') ? ', ' : '') . ((isset($row['group_type']) && $row['group_type'] == GROUP_SPECIAL) ? '' . $group_name . '' : $group_name); - } - $db->sql_freeresult($result); - - $mode = str_replace('setting_', '', $mode); - - if ($forum_id[0] == 0) - { - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ACL_' . strtoupper($action) . '_' . strtoupper($mode) . '_' . strtoupper($permission_type), false, array($l_ug_list)); - } - else - { - // Grab the forum details if non-zero forum_id - $sql = 'SELECT forum_name - FROM ' . FORUMS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $forum_id); - $result = $db->sql_query($sql); - - $l_forum_list = ''; - while ($row = $db->sql_fetchrow($result)) - { - $l_forum_list .= (($l_forum_list != '') ? ', ' : '') . $row['forum_name']; - } - $db->sql_freeresult($result); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ACL_' . strtoupper($action) . '_' . strtoupper($mode) . '_' . strtoupper($permission_type), false, array($l_forum_list, $l_ug_list)); - } - } - - /** - * Display a complete trace tree for the selected permission to determine where settings are set/unset - */ - function permission_trace($user_id, $forum_id, $permission) - { - global $db, $template, $user, $auth, $request, $phpbb_container; - - if ($user_id != $user->data['user_id']) - { - $userdata = $auth->obtain_user_data($user_id); - } - else - { - $userdata = $user->data; - } - - if (!$userdata) - { - trigger_error('NO_USERS', E_USER_ERROR); - } - - /** @var \phpbb\group\helper $group_helper */ - $group_helper = $phpbb_container->get('group_helper'); - - $forum_name = false; - - if ($forum_id) - { - $sql = 'SELECT forum_name - FROM ' . FORUMS_TABLE . " - WHERE forum_id = $forum_id"; - $result = $db->sql_query($sql, 3600); - $forum_name = $db->sql_fetchfield('forum_name'); - $db->sql_freeresult($result); - } - - $back = $request->variable('back', 0); - - $template->assign_vars(array( - 'PERMISSION' => $this->permissions->get_permission_lang($permission), - 'PERMISSION_USERNAME' => $userdata['username'], - 'FORUM_NAME' => $forum_name, - - 'S_GLOBAL_TRACE' => ($forum_id) ? false : true, - - 'U_BACK' => ($back) ? build_url(array('f', 'back')) . "&f=$back" : '') - ); - - $template->assign_block_vars('trace', array( - 'WHO' => $user->lang['DEFAULT'], - 'INFORMATION' => $user->lang['TRACE_DEFAULT'], - - 'S_SETTING_NO' => true, - 'S_TOTAL_NO' => true) - ); - - $sql = 'SELECT DISTINCT g.group_name, g.group_id, g.group_type - FROM ' . GROUPS_TABLE . ' g - LEFT JOIN ' . USER_GROUP_TABLE . ' ug ON (ug.group_id = g.group_id) - WHERE ug.user_id = ' . $user_id . ' - AND ug.user_pending = 0 - AND NOT (ug.group_leader = 1 AND g.group_skip_auth = 1) - ORDER BY g.group_type DESC, g.group_id DESC'; - $result = $db->sql_query($sql); - - $groups = array(); - while ($row = $db->sql_fetchrow($result)) - { - $groups[$row['group_id']] = array( - 'auth_setting' => ACL_NO, - 'group_name' => $group_helper->get_name($row['group_name']), - ); - } - $db->sql_freeresult($result); - - $total = ACL_NO; - $add_key = (($forum_id) ? '_LOCAL' : ''); - - if (count($groups)) - { - // Get group auth settings - $hold_ary = $auth->acl_group_raw_data(array_keys($groups), $permission, $forum_id); - - foreach ($hold_ary as $group_id => $forum_ary) - { - $groups[$group_id]['auth_setting'] = $hold_ary[$group_id][$forum_id][$permission]; - } - unset($hold_ary); - - foreach ($groups as $id => $row) - { - switch ($row['auth_setting']) - { - case ACL_NO: - $information = $user->lang['TRACE_GROUP_NO' . $add_key]; - break; - - case ACL_YES: - $information = ($total == ACL_YES) ? $user->lang['TRACE_GROUP_YES_TOTAL_YES' . $add_key] : (($total == ACL_NEVER) ? $user->lang['TRACE_GROUP_YES_TOTAL_NEVER' . $add_key] : $user->lang['TRACE_GROUP_YES_TOTAL_NO' . $add_key]); - $total = ($total == ACL_NO) ? ACL_YES : $total; - break; - - case ACL_NEVER: - $information = ($total == ACL_YES) ? $user->lang['TRACE_GROUP_NEVER_TOTAL_YES' . $add_key] : (($total == ACL_NEVER) ? $user->lang['TRACE_GROUP_NEVER_TOTAL_NEVER' . $add_key] : $user->lang['TRACE_GROUP_NEVER_TOTAL_NO' . $add_key]); - $total = ACL_NEVER; - break; - } - - $template->assign_block_vars('trace', array( - 'WHO' => $row['group_name'], - 'INFORMATION' => $information, - - 'S_SETTING_NO' => ($row['auth_setting'] == ACL_NO) ? true : false, - 'S_SETTING_YES' => ($row['auth_setting'] == ACL_YES) ? true : false, - 'S_SETTING_NEVER' => ($row['auth_setting'] == ACL_NEVER) ? true : false, - 'S_TOTAL_NO' => ($total == ACL_NO) ? true : false, - 'S_TOTAL_YES' => ($total == ACL_YES) ? true : false, - 'S_TOTAL_NEVER' => ($total == ACL_NEVER) ? true : false) - ); - } - } - - // Get user specific permission... globally or for this forum - $hold_ary = $auth->acl_user_raw_data($user_id, $permission, $forum_id); - $auth_setting = (!count($hold_ary)) ? ACL_NO : $hold_ary[$user_id][$forum_id][$permission]; - - switch ($auth_setting) - { - case ACL_NO: - $information = ($total == ACL_NO) ? $user->lang['TRACE_USER_NO_TOTAL_NO' . $add_key] : $user->lang['TRACE_USER_KEPT' . $add_key]; - $total = ($total == ACL_NO) ? ACL_NEVER : $total; - break; - - case ACL_YES: - $information = ($total == ACL_YES) ? $user->lang['TRACE_USER_YES_TOTAL_YES' . $add_key] : (($total == ACL_NEVER) ? $user->lang['TRACE_USER_YES_TOTAL_NEVER' . $add_key] : $user->lang['TRACE_USER_YES_TOTAL_NO' . $add_key]); - $total = ($total == ACL_NO) ? ACL_YES : $total; - break; - - case ACL_NEVER: - $information = ($total == ACL_YES) ? $user->lang['TRACE_USER_NEVER_TOTAL_YES' . $add_key] : (($total == ACL_NEVER) ? $user->lang['TRACE_USER_NEVER_TOTAL_NEVER' . $add_key] : $user->lang['TRACE_USER_NEVER_TOTAL_NO' . $add_key]); - $total = ACL_NEVER; - break; - } - - $template->assign_block_vars('trace', array( - 'WHO' => $userdata['username'], - 'INFORMATION' => $information, - - 'S_SETTING_NO' => ($auth_setting == ACL_NO) ? true : false, - 'S_SETTING_YES' => ($auth_setting == ACL_YES) ? true : false, - 'S_SETTING_NEVER' => ($auth_setting == ACL_NEVER) ? true : false, - 'S_TOTAL_NO' => false, - 'S_TOTAL_YES' => ($total == ACL_YES) ? true : false, - 'S_TOTAL_NEVER' => ($total == ACL_NEVER) ? true : false) - ); - - if ($forum_id != 0 && isset($auth->acl_options['global'][$permission])) - { - if ($user_id != $user->data['user_id']) - { - $auth2 = new \phpbb\auth\auth(); - $auth2->acl($userdata); - $auth_setting = $auth2->acl_get($permission); - } - else - { - $auth_setting = $auth->acl_get($permission); - } - - if ($auth_setting) - { - $information = ($total == ACL_YES) ? $user->lang['TRACE_USER_GLOBAL_YES_TOTAL_YES'] : $user->lang['TRACE_USER_GLOBAL_YES_TOTAL_NEVER']; - $total = ACL_YES; - } - else - { - $information = $user->lang['TRACE_USER_GLOBAL_NEVER_TOTAL_KEPT']; - } - - // If there is no auth information we do not need to worry the user by showing non-relevant data. - if ($auth_setting) - { - $template->assign_block_vars('trace', array( - 'WHO' => sprintf($user->lang['TRACE_GLOBAL_SETTING'], $userdata['username']), - 'INFORMATION' => sprintf($information, '", ''), - - 'S_SETTING_NO' => false, - 'S_SETTING_YES' => $auth_setting, - 'S_SETTING_NEVER' => !$auth_setting, - 'S_TOTAL_NO' => false, - 'S_TOTAL_YES' => ($total == ACL_YES) ? true : false, - 'S_TOTAL_NEVER' => ($total == ACL_NEVER) ? true : false) - ); - } - } - - // Take founder status into account, overwriting the default values - if ($userdata['user_type'] == USER_FOUNDER && strpos($permission, 'a_') === 0) - { - $template->assign_block_vars('trace', array( - 'WHO' => $userdata['username'], - 'INFORMATION' => $user->lang['TRACE_USER_FOUNDER'], - - 'S_SETTING_NO' => ($auth_setting == ACL_NO) ? true : false, - 'S_SETTING_YES' => ($auth_setting == ACL_YES) ? true : false, - 'S_SETTING_NEVER' => ($auth_setting == ACL_NEVER) ? true : false, - 'S_TOTAL_NO' => false, - 'S_TOTAL_YES' => true, - 'S_TOTAL_NEVER' => false) - ); - - $total = ACL_YES; - } - - // Total value... - $template->assign_vars(array( - 'S_RESULT_NO' => ($total == ACL_NO) ? true : false, - 'S_RESULT_YES' => ($total == ACL_YES) ? true : false, - 'S_RESULT_NEVER' => ($total == ACL_NEVER) ? true : false, - )); - } - - /** - * Handles copying permissions from one forum to others - */ - function copy_forum_permissions() - { - global $db, $auth, $cache, $template, $user, $request; - - $user->add_lang('acp/forums'); - - $submit = isset($_POST['submit']) ? true : false; - - if ($submit) - { - $src = $request->variable('src_forum_id', 0); - $dest = $request->variable('dest_forum_ids', array(0)); - - if (confirm_box(true)) - { - if (copy_forum_permissions($src, $dest)) - { - phpbb_cache_moderators($db, $cache, $auth); - - $auth->acl_clear_prefetch(); - $cache->destroy('sql', FORUMS_TABLE); - - trigger_error($user->lang['AUTH_UPDATED'] . adm_back_link($this->u_action)); - } - else - { - trigger_error($user->lang['SELECTED_FORUM_NOT_EXIST'] . adm_back_link($this->u_action), E_USER_WARNING); - } - } - else - { - $s_hidden_fields = array( - 'submit' => $submit, - 'src_forum_id' => $src, - 'dest_forum_ids' => $dest, - ); - - $s_hidden_fields = build_hidden_fields($s_hidden_fields); - - confirm_box(false, $user->lang['COPY_PERMISSIONS_CONFIRM'], $s_hidden_fields); - } - } - - $template->assign_vars(array( - 'S_FORUM_OPTIONS' => make_forum_select(false, false, false, false, false), - )); - } - - /** - * Get already assigned users/groups - */ - function retrieve_defined_user_groups($permission_scope, $forum_id, $permission_type) - { - global $db, $phpbb_container; - - /** @var \phpbb\group\helper $group_helper */ - $group_helper = $phpbb_container->get('group_helper'); - - $sql_forum_id = ($permission_scope == 'global') ? 'AND a.forum_id = 0' : ((count($forum_id)) ? 'AND ' . $db->sql_in_set('a.forum_id', $forum_id) : 'AND a.forum_id <> 0'); - - // Permission options are only able to be a permission set... therefore we will pre-fetch the possible options and also the possible roles - $option_ids = $role_ids = array(); - - $sql = 'SELECT auth_option_id - FROM ' . ACL_OPTIONS_TABLE . ' - WHERE auth_option ' . $db->sql_like_expression($permission_type . $db->get_any_char()); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $option_ids[] = (int) $row['auth_option_id']; - } - $db->sql_freeresult($result); - - if (count($option_ids)) - { - $sql = 'SELECT DISTINCT role_id - FROM ' . ACL_ROLES_DATA_TABLE . ' - WHERE ' . $db->sql_in_set('auth_option_id', $option_ids); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $role_ids[] = (int) $row['role_id']; - } - $db->sql_freeresult($result); - } - - if (count($option_ids) && count($role_ids)) - { - $sql_where = 'AND (' . $db->sql_in_set('a.auth_option_id', $option_ids) . ' OR ' . $db->sql_in_set('a.auth_role_id', $role_ids) . ')'; - } - else if (count($role_ids)) - { - $sql_where = 'AND ' . $db->sql_in_set('a.auth_role_id', $role_ids); - } - else if (count($option_ids)) - { - $sql_where = 'AND ' . $db->sql_in_set('a.auth_option_id', $option_ids); - } - - // Not ideal, due to the filesort, non-use of indexes, etc. - $sql = 'SELECT DISTINCT u.user_id, u.username, u.username_clean, u.user_regdate - FROM ' . USERS_TABLE . ' u, ' . ACL_USERS_TABLE . " a - WHERE u.user_id = a.user_id - $sql_forum_id - $sql_where - ORDER BY u.username_clean, u.user_regdate ASC"; - $result = $db->sql_query($sql); - - $s_defined_user_options = ''; - $defined_user_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $s_defined_user_options .= ''; - $defined_user_ids[] = $row['user_id']; - } - $db->sql_freeresult($result); - - $sql = 'SELECT DISTINCT g.group_type, g.group_name, g.group_id - FROM ' . GROUPS_TABLE . ' g, ' . ACL_GROUPS_TABLE . " a - WHERE g.group_id = a.group_id - $sql_forum_id - $sql_where - ORDER BY g.group_type DESC, g.group_name ASC"; - $result = $db->sql_query($sql); - - $s_defined_group_options = ''; - $defined_group_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $s_defined_group_options .= '' . $group_helper->get_name($row['group_name']) . ''; - $defined_group_ids[] = $row['group_id']; - } - $db->sql_freeresult($result); - - return array( - 'group_ids' => $defined_group_ids, - 'group_ids_options' => $s_defined_group_options, - 'user_ids' => $defined_user_ids, - 'user_ids_options' => $s_defined_user_options - ); - } -} diff --git a/install/update/new/includes/acp/acp_prune.php b/install/update/new/includes/acp/acp_prune.php deleted file mode 100644 index c5f7789..0000000 --- a/install/update/new/includes/acp/acp_prune.php +++ /dev/null @@ -1,588 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -class acp_prune -{ - var $u_action; - - function main($id, $mode) - { - global $user, $phpEx, $phpbb_root_path; - - $user->add_lang('acp/prune'); - - if (!function_exists('user_active_flip')) - { - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - } - - switch ($mode) - { - case 'forums': - $this->tpl_name = 'acp_prune_forums'; - $this->page_title = 'ACP_PRUNE_FORUMS'; - $this->prune_forums($id, $mode); - break; - - case 'users': - $this->tpl_name = 'acp_prune_users'; - $this->page_title = 'ACP_PRUNE_USERS'; - $this->prune_users($id, $mode); - break; - } - } - - /** - * Prune forums - */ - function prune_forums($id, $mode) - { - global $db, $user, $auth, $template, $phpbb_log, $request, $phpbb_dispatcher; - - $all_forums = $request->variable('all_forums', 0); - $forum_id = $request->variable('f', array(0)); - $submit = (isset($_POST['submit'])) ? true : false; - - if ($all_forums) - { - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE . ' - ORDER BY left_id'; - $result = $db->sql_query($sql); - - $forum_id = array(); - while ($row = $db->sql_fetchrow($result)) - { - $forum_id[] = $row['forum_id']; - } - $db->sql_freeresult($result); - } - - if ($submit) - { - if (confirm_box(true)) - { - $prune_posted = $request->variable('prune_days', 0); - $prune_viewed = $request->variable('prune_vieweddays', 0); - $prune_all = (!$prune_posted && !$prune_viewed) ? true : false; - - $prune_flags = 0; - $prune_flags += ($request->variable('prune_old_polls', 0)) ? 2 : 0; - $prune_flags += ($request->variable('prune_announce', 0)) ? 4 : 0; - $prune_flags += ($request->variable('prune_sticky', 0)) ? 8 : 0; - - // Convert days to seconds for timestamp functions... - $prunedate_posted = time() - ($prune_posted * 86400); - $prunedate_viewed = time() - ($prune_viewed * 86400); - - $template->assign_vars(array( - 'S_PRUNED' => true) - ); - - $sql_forum = (count($forum_id)) ? ' AND ' . $db->sql_in_set('forum_id', $forum_id) : ''; - - // Get a list of forum's or the data for the forum that we are pruning. - $sql = 'SELECT forum_id, forum_name - FROM ' . FORUMS_TABLE . ' - WHERE forum_type = ' . FORUM_POST . " - $sql_forum - ORDER BY left_id ASC"; - $result = $db->sql_query($sql); - - if ($row = $db->sql_fetchrow($result)) - { - $prune_ids = array(); - $p_result['topics'] = 0; - $p_result['posts'] = 0; - $log_data = ''; - - do - { - if (!$auth->acl_get('f_list', $row['forum_id'])) - { - continue; - } - - if ($prune_all) - { - $p_result = prune($row['forum_id'], 'posted', time(), $prune_flags, false); - } - else - { - if ($prune_posted) - { - $return = prune($row['forum_id'], 'posted', $prunedate_posted, $prune_flags, false); - $p_result['topics'] += $return['topics']; - $p_result['posts'] += $return['posts']; - } - - if ($prune_viewed) - { - $return = prune($row['forum_id'], 'viewed', $prunedate_viewed, $prune_flags, false); - $p_result['topics'] += $return['topics']; - $p_result['posts'] += $return['posts']; - } - } - - $prune_ids[] = $row['forum_id']; - - $template->assign_block_vars('pruned', array( - 'FORUM_NAME' => $row['forum_name'], - 'NUM_TOPICS' => $p_result['topics'], - 'NUM_POSTS' => $p_result['posts']) - ); - - $log_data .= (($log_data != '') ? ', ' : '') . $row['forum_name']; - } - while ($row = $db->sql_fetchrow($result)); - - // Sync all pruned forums at once - sync('forum', 'forum_id', $prune_ids, true, true); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_PRUNE', false, array($log_data)); - } - $db->sql_freeresult($result); - - return; - } - else - { - $hidden_fields = array( - 'i' => $id, - 'mode' => $mode, - 'submit' => 1, - 'all_forums' => $all_forums, - 'f' => $forum_id, - - 'prune_days' => $request->variable('prune_days', 0), - 'prune_vieweddays' => $request->variable('prune_vieweddays', 0), - 'prune_old_polls' => $request->variable('prune_old_polls', 0), - 'prune_announce' => $request->variable('prune_announce', 0), - 'prune_sticky' => $request->variable('prune_sticky', 0), - ); - - /** - * Use this event to pass data from the prune form to the confirmation screen - * - * @event core.prune_forums_settings_confirm - * @var array hidden_fields Hidden fields that are passed through the confirm screen - * @since 3.2.2-RC1 - */ - $vars = array('hidden_fields'); - extract($phpbb_dispatcher->trigger_event('core.prune_forums_settings_confirm', compact($vars))); - - confirm_box(false, $user->lang['PRUNE_FORUM_CONFIRM'], build_hidden_fields($hidden_fields)); - } - } - - // If they haven't selected a forum for pruning yet then - // display a select box to use for pruning. - if (!count($forum_id)) - { - $template->assign_vars(array( - 'U_ACTION' => $this->u_action, - 'S_SELECT_FORUM' => true, - 'S_FORUM_OPTIONS' => make_forum_select(false, false, false)) - ); - } - else - { - $sql = 'SELECT forum_id, forum_name - FROM ' . FORUMS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $forum_id); - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - - if (!$row) - { - $db->sql_freeresult($result); - trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - $forum_list = $s_hidden_fields = ''; - do - { - $forum_list .= (($forum_list != '') ? ', ' : '') . '' . $row['forum_name'] . ''; - $s_hidden_fields .= ''; - } - while ($row = $db->sql_fetchrow($result)); - - $db->sql_freeresult($result); - - $l_selected_forums = (count($forum_id) == 1) ? 'SELECTED_FORUM' : 'SELECTED_FORUMS'; - - $template_data = array( - 'L_SELECTED_FORUMS' => $user->lang[$l_selected_forums], - 'U_ACTION' => $this->u_action, - 'U_BACK' => $this->u_action, - 'FORUM_LIST' => $forum_list, - 'S_HIDDEN_FIELDS' => $s_hidden_fields, - ); - - /** - * Event to add/modify prune forums settings template data - * - * @event core.prune_forums_settings_template_data - * @var array template_data Array with form template data - * @since 3.2.2-RC1 - */ - $vars = array('template_data'); - extract($phpbb_dispatcher->trigger_event('core.prune_forums_settings_template_data', compact($vars))); - - $template->assign_vars($template_data); - } - } - - /** - * Prune users - */ - function prune_users($id, $mode) - { - global $db, $user, $auth, $template, $phpbb_log, $request; - global $phpbb_root_path, $phpbb_admin_path, $phpEx, $phpbb_container; - - /** @var \phpbb\group\helper $group_helper */ - $group_helper = $phpbb_container->get('group_helper'); - - $user->add_lang('memberlist'); - - $prune = (isset($_POST['prune'])) ? true : false; - - if ($prune) - { - $action = $request->variable('action', 'deactivate'); - $deleteposts = $request->variable('deleteposts', 0); - - if (confirm_box(true)) - { - $user_ids = $usernames = array(); - - $this->get_prune_users($user_ids, $usernames); - if (count($user_ids)) - { - if ($action == 'deactivate') - { - user_active_flip('deactivate', $user_ids); - $l_log = 'LOG_PRUNE_USER_DEAC'; - } - else if ($action == 'delete') - { - if ($deleteposts) - { - user_delete('remove', $user_ids); - - $l_log = 'LOG_PRUNE_USER_DEL_DEL'; - } - else - { - user_delete('retain', $user_ids, true); - - $l_log = 'LOG_PRUNE_USER_DEL_ANON'; - } - } - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, $l_log, false, array(implode(', ', $usernames))); - $msg = $user->lang['USER_' . strtoupper($action) . '_SUCCESS']; - } - else - { - $msg = $user->lang['USER_PRUNE_FAILURE']; - } - - trigger_error($msg . adm_back_link($this->u_action)); - } - else - { - // We list the users which will be pruned... - $user_ids = $usernames = array(); - $this->get_prune_users($user_ids, $usernames); - - if (!count($user_ids)) - { - trigger_error($user->lang['USER_PRUNE_FAILURE'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - // Assign to template - foreach ($user_ids as $user_id) - { - $template->assign_block_vars('users', array( - 'USERNAME' => $usernames[$user_id], - 'USER_ID' => $user_id, - 'U_PROFILE' => get_username_string('profile', $user_id, $usernames[$user_id]), - 'U_USER_ADMIN' => ($auth->acl_get('a_user')) ? append_sid("{$phpbb_admin_path}index.$phpEx", 'i=users&mode=overview&u=' . $user_id, true, $user->session_id) : '', - )); - } - - $template->assign_vars(array( - 'S_DEACTIVATE' => ($action == 'deactivate') ? true : false, - 'S_DELETE' => ($action == 'delete') ? true : false, - )); - - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( - 'i' => $id, - 'mode' => $mode, - 'prune' => 1, - - 'deleteposts' => $request->variable('deleteposts', 0), - 'action' => $request->variable('action', ''), - )), 'confirm_body_prune.html'); - } - } - - $find_count = array('lt' => $user->lang['LESS_THAN'], 'eq' => $user->lang['EQUAL_TO'], 'gt' => $user->lang['MORE_THAN']); - $s_find_count = ''; - - foreach ($find_count as $key => $value) - { - $selected = ($key == 'eq') ? ' selected="selected"' : ''; - $s_find_count .= ''; - } - - $find_time = array('lt' => $user->lang['BEFORE'], 'gt' => $user->lang['AFTER']); - $s_find_active_time = ''; - foreach ($find_time as $key => $value) - { - $s_find_active_time .= ''; - } - - $sql = 'SELECT group_id, group_name - FROM ' . GROUPS_TABLE . ' - WHERE group_type <> ' . GROUP_SPECIAL . ' - ORDER BY group_name ASC'; - $result = $db->sql_query($sql); - - $s_group_list = ''; - while ($row = $db->sql_fetchrow($result)) - { - $s_group_list .= ''; - } - $db->sql_freeresult($result); - - if ($s_group_list) - { - // Only prepend the "All groups" option if there are groups, - // otherwise we don't want to display this option at all. - $s_group_list = '' . $s_group_list; - } - - $template->assign_vars(array( - 'U_ACTION' => $this->u_action, - 'S_ACTIVE_OPTIONS' => $s_find_active_time, - 'S_GROUP_LIST' => $s_group_list, - 'S_COUNT_OPTIONS' => $s_find_count, - 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=acp_prune&field=users'), - )); - } - - /** - * Get user_ids/usernames from those being pruned - */ - function get_prune_users(&$user_ids, &$usernames) - { - global $user, $db, $request; - - $users_by_name = $request->variable('users', '', true); - $users_by_id = $request->variable('user_ids', array(0)); - $group_id = $request->variable('group_id', 0); - $posts_on_queue = (trim($request->variable('posts_on_queue', '')) === '') ? false : $request->variable('posts_on_queue', 0); - - if ($users_by_name) - { - $users = explode("\n", $users_by_name); - $where_sql = ' AND ' . $db->sql_in_set('username_clean', array_map('utf8_clean_string', $users)); - } - else if (!empty($users_by_id)) - { - $user_ids = $users_by_id; - user_get_id_name($user_ids, $usernames); - - $where_sql = ' AND ' . $db->sql_in_set('user_id', $user_ids); - } - else - { - $username = $request->variable('username', '', true); - $email = $request->variable('email', ''); - - $active_select = $request->variable('active_select', 'lt'); - $count_select = $request->variable('count_select', 'eq'); - $queue_select = $request->variable('queue_select', 'gt'); - $joined_before = $request->variable('joined_before', ''); - $joined_after = $request->variable('joined_after', ''); - $active = $request->variable('active', ''); - - $count = ($request->variable('count', '') === '') ? false : $request->variable('count', 0); - - $active = ($active) ? explode('-', $active) : array(); - $joined_before = ($joined_before) ? explode('-', $joined_before) : array(); - $joined_after = ($joined_after) ? explode('-', $joined_after) : array(); - - // calculate the conditions required by the join time criteria - $joined_sql = ''; - if (!empty($joined_before) && !empty($joined_after)) - { - // if the two entered dates are equal, we need to adjust - // so that our time range is a full day instead of 1 second - if ($joined_after == $joined_before) - { - $joined_after[2] += 1; - } - - $joined_sql = ' AND user_regdate BETWEEN ' . gmmktime(0, 0, 0, (int) $joined_after[1], (int) $joined_after[2], (int) $joined_after[0]) . - ' AND ' . gmmktime(0, 0, 0, (int) $joined_before[1], (int) $joined_before[2], (int) $joined_before[0]); - } - else if (empty($joined_before) && !empty($joined_after)) - { - $joined_sql = ' AND user_regdate > ' . gmmktime(0, 0, 0, (int) $joined_after[1], (int) $joined_after[2], (int) $joined_after[0]); - } - else if (empty($joined_after) && !empty($joined_before)) - { - $joined_sql = ' AND user_regdate < ' . gmmktime(0, 0, 0, (int) $joined_before[1], (int) $joined_before[2], (int) $joined_before[0]); - } - // implicit else when both arrays are empty do nothing - - if ((count($active) && count($active) != 3) || (count($joined_before) && count($joined_before) != 3) || (count($joined_after) && count($joined_after) != 3)) - { - trigger_error($user->lang['WRONG_ACTIVE_JOINED_DATE'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - $key_match = array('lt' => '<', 'gt' => '>', 'eq' => '='); - - $where_sql = ''; - $where_sql .= ($username) ? ' AND username_clean ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), utf8_clean_string($username))) : ''; - $where_sql .= ($email) ? ' AND user_email ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), $email)) . ' ' : ''; - $where_sql .= $joined_sql; - $where_sql .= ($count !== false) ? " AND user_posts " . $key_match[$count_select] . ' ' . (int) $count . ' ' : ''; - - // First handle pruning of users who never logged in, last active date is 0000-00-00 - if (count($active) && (int) $active[0] == 0 && (int) $active[1] == 0 && (int) $active[2] == 0) - { - $where_sql .= ' AND user_lastvisit = 0'; - } - else if (count($active) && $active_select != 'lt') - { - $where_sql .= ' AND user_lastvisit ' . $key_match[$active_select] . ' ' . gmmktime(0, 0, 0, (int) $active[1], (int) $active[2], (int) $active[0]); - } - else if (count($active)) - { - $where_sql .= ' AND (user_lastvisit > 0 AND user_lastvisit < ' . gmmktime(0, 0, 0, (int) $active[1], (int) $active[2], (int) $active[0]) . ')'; - } - } - - // If no search criteria were provided, go no further. - if (!$where_sql && !$group_id && $posts_on_queue === false) - { - return; - } - - // Get bot ids - $sql = 'SELECT user_id - FROM ' . BOTS_TABLE; - $result = $db->sql_query($sql); - - $bot_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $bot_ids[] = $row['user_id']; - } - $db->sql_freeresult($result); - - // Protect the admin, do not prune if no options are given... - if ($where_sql) - { - // Do not prune founder members - $sql = 'SELECT user_id, username - FROM ' . USERS_TABLE . ' - WHERE user_id <> ' . ANONYMOUS . ' - AND user_type <> ' . USER_FOUNDER . " - $where_sql"; - $result = $db->sql_query($sql); - - $user_ids = $usernames = array(); - - while ($row = $db->sql_fetchrow($result)) - { - // Do not prune bots and the user currently pruning. - if ($row['user_id'] != $user->data['user_id'] && !in_array($row['user_id'], $bot_ids)) - { - $user_ids[] = $row['user_id']; - $usernames[$row['user_id']] = $row['username']; - } - } - $db->sql_freeresult($result); - } - - if ($group_id) - { - $sql = 'SELECT u.user_id, u.username - FROM ' . USER_GROUP_TABLE . ' ug, ' . USERS_TABLE . ' u - WHERE ug.group_id = ' . (int) $group_id . ' - AND ug.user_id <> ' . ANONYMOUS . ' - AND u.user_type <> ' . USER_FOUNDER . ' - AND ug.user_pending = 0 - AND ug.group_leader = 0 - AND u.user_id = ug.user_id - ' . (!empty($user_ids) ? ' AND ' . $db->sql_in_set('ug.user_id', $user_ids) : ''); - $result = $db->sql_query($sql); - - // we're performing an intersection operation, so all the relevant users - // come from this most recent query (which was limited to the results of the - // previous query) - $user_ids = $usernames = array(); - while ($row = $db->sql_fetchrow($result)) - { - // Do not prune bots and the user currently pruning. - if ($row['user_id'] != $user->data['user_id'] && !in_array($row['user_id'], $bot_ids)) - { - $user_ids[] = $row['user_id']; - $usernames[$row['user_id']] = $row['username']; - } - } - $db->sql_freeresult($result); - } - - if ($posts_on_queue !== false) - { - $sql = 'SELECT u.user_id, u.username, COUNT(p.post_id) AS queue_posts - FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u - WHERE u.user_id <> ' . ANONYMOUS . ' - AND u.user_type <> ' . USER_FOUNDER . ' - AND ' . $db->sql_in_set('p.post_visibility', array(ITEM_UNAPPROVED, ITEM_REAPPROVE)) . ' - AND u.user_id = p.poster_id - ' . (!empty($user_ids) ? ' AND ' . $db->sql_in_set('p.poster_id', $user_ids) : '') . ' - GROUP BY p.poster_id - HAVING queue_posts ' . $key_match[$queue_select] . ' ' . $posts_on_queue; - $result = $db->sql_query($sql); - - // same intersection logic as the above group ID portion - $user_ids = $usernames = array(); - while ($row = $db->sql_fetchrow($result)) - { - // Do not prune bots and the user currently pruning. - if ($row['user_id'] != $user->data['user_id'] && !in_array($row['user_id'], $bot_ids)) - { - $user_ids[] = $row['user_id']; - $usernames[$row['user_id']] = $row['username']; - } - } - $db->sql_freeresult($result); - } - } -} diff --git a/install/update/new/includes/acp/acp_reasons.php b/install/update/new/includes/acp/acp_reasons.php deleted file mode 100644 index f3f82bd..0000000 --- a/install/update/new/includes/acp/acp_reasons.php +++ /dev/null @@ -1,392 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -class acp_reasons -{ - var $u_action; - - function main($id, $mode) - { - global $db, $user, $template; - global $request, $phpbb_log; - - $user->add_lang(array('mcp', 'acp/posting')); - - // Set up general vars - $action = $request->variable('action', ''); - $submit = (isset($_POST['submit'])) ? true : false; - $reason_id = $request->variable('id', 0); - - $this->tpl_name = 'acp_reasons'; - $this->page_title = 'ACP_REASONS'; - - $form_name = 'acp_reason'; - add_form_key('acp_reason'); - - $error = array(); - - switch ($action) - { - case 'add': - case 'edit': - - $reason_row = array( - 'reason_title' => $request->variable('reason_title', '', true), - 'reason_description' => $request->variable('reason_description', '', true), - ); - - if ($submit) - { - if (!check_form_key($form_name)) - { - $error[] = $user->lang['FORM_INVALID']; - } - // Reason specified? - if (!$reason_row['reason_title'] || !$reason_row['reason_description']) - { - $error[] = $user->lang['NO_REASON_INFO']; - } - - $check_double = ($action == 'add') ? true : false; - - if ($action == 'edit') - { - $sql = 'SELECT reason_title - FROM ' . REPORTS_REASONS_TABLE . " - WHERE reason_id = $reason_id"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (strtolower($row['reason_title']) == 'other' || strtolower($reason_row['reason_title']) == 'other') - { - $reason_row['reason_title'] = 'other'; - } - - if ($row['reason_title'] != $reason_row['reason_title']) - { - $check_double = true; - } - } - - // Check for same reason if adding it... - if ($check_double) - { - $sql = 'SELECT reason_id - FROM ' . REPORTS_REASONS_TABLE . " - WHERE reason_title = '" . $db->sql_escape($reason_row['reason_title']) . "'"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row || ($action == 'add' && strtolower($reason_row['reason_title']) == 'other')) - { - $error[] = $user->lang['REASON_ALREADY_EXIST']; - } - } - - if (!count($error)) - { - // New reason? - if ($action == 'add') - { - // Get new order... - $sql = 'SELECT MAX(reason_order) as max_reason_order - FROM ' . REPORTS_REASONS_TABLE; - $result = $db->sql_query($sql); - $max_order = (int) $db->sql_fetchfield('max_reason_order'); - $db->sql_freeresult($result); - - $sql_ary = array( - 'reason_title' => (string) $reason_row['reason_title'], - 'reason_description' => (string) $reason_row['reason_description'], - 'reason_order' => $max_order + 1 - ); - - $db->sql_query('INSERT INTO ' . REPORTS_REASONS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); - - $log = 'ADDED'; - } - else if ($reason_id) - { - $sql_ary = array( - 'reason_title' => (string) $reason_row['reason_title'], - 'reason_description' => (string) $reason_row['reason_description'], - ); - - $db->sql_query('UPDATE ' . REPORTS_REASONS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE reason_id = ' . $reason_id); - - $log = 'UPDATED'; - } - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_REASON_' . $log, false, array($reason_row['reason_title'])); - trigger_error($user->lang['REASON_' . $log] . adm_back_link($this->u_action)); - } - } - else if ($reason_id) - { - $sql = 'SELECT * - FROM ' . REPORTS_REASONS_TABLE . ' - WHERE reason_id = ' . $reason_id; - $result = $db->sql_query($sql); - $reason_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$reason_row) - { - trigger_error($user->lang['NO_REASON'] . adm_back_link($this->u_action), E_USER_WARNING); - } - } - - $l_title = ($action == 'edit') ? 'EDIT' : 'ADD'; - - $translated = false; - - // If the reason is defined within the language file, we will use the localized version, else just use the database entry... - if (isset($user->lang['report_reasons']['TITLE'][strtoupper($reason_row['reason_title'])]) && isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($reason_row['reason_title'])])) - { - $translated = true; - } - - $template->assign_vars(array( - 'L_TITLE' => $user->lang['REASON_' . $l_title], - 'U_ACTION' => $this->u_action . "&id=$reason_id&action=$action", - 'U_BACK' => $this->u_action, - 'ERROR_MSG' => (count($error)) ? implode('
', $error) : '', - - 'REASON_TITLE' => $reason_row['reason_title'], - 'REASON_DESCRIPTION' => $reason_row['reason_description'], - - 'TRANSLATED_TITLE' => ($translated) ? $user->lang['report_reasons']['TITLE'][strtoupper($reason_row['reason_title'])] : '', - 'TRANSLATED_DESCRIPTION'=> ($translated) ? $user->lang['report_reasons']['DESCRIPTION'][strtoupper($reason_row['reason_title'])] : '', - - 'S_AVAILABLE_TITLES' => implode($user->lang['COMMA_SEPARATOR'], array_map('htmlspecialchars', array_keys($user->lang['report_reasons']['TITLE']))), - 'S_EDIT_REASON' => true, - 'S_TRANSLATED' => $translated, - 'S_ERROR' => (count($error)) ? true : false, - ) - ); - - return; - break; - - case 'delete': - - $sql = 'SELECT * - FROM ' . REPORTS_REASONS_TABLE . ' - WHERE reason_id = ' . $reason_id; - $result = $db->sql_query($sql); - $reason_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$reason_row) - { - trigger_error($user->lang['NO_REASON'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - if (strtolower($reason_row['reason_title']) == 'other') - { - trigger_error($user->lang['NO_REMOVE_DEFAULT_REASON'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - // Let the deletion be confirmed... - if (confirm_box(true)) - { - $sql = 'SELECT reason_id - FROM ' . REPORTS_REASONS_TABLE . " - WHERE LOWER(reason_title) = 'other'"; - $result = $db->sql_query($sql); - $other_reason_id = (int) $db->sql_fetchfield('reason_id'); - $db->sql_freeresult($result); - - switch ($db->get_sql_layer()) - { - // The ugly one! - case 'mysqli': - // Change the reports using this reason to 'other' - $sql = 'UPDATE ' . REPORTS_TABLE . ' - SET reason_id = ' . $other_reason_id . ", report_text = CONCAT('" . $db->sql_escape($reason_row['reason_description']) . "\n\n', report_text) - WHERE reason_id = $reason_id"; - break; - - // Standard? What's that? - case 'mssql_odbc': - case 'mssqlnative': - // Change the reports using this reason to 'other' - $sql = "DECLARE @ptrval binary(16) - - SELECT @ptrval = TEXTPTR(report_text) - FROM " . REPORTS_TABLE . " - WHERE reason_id = " . $reason_id . " - - UPDATETEXT " . REPORTS_TABLE . ".report_text @ptrval 0 0 '" . $db->sql_escape($reason_row['reason_description']) . "\n\n' - - UPDATE " . REPORTS_TABLE . ' - SET reason_id = ' . $other_reason_id . " - WHERE reason_id = $reason_id"; - break; - - // Teh standard - case 'postgres': - case 'oracle': - case 'sqlite3': - // Change the reports using this reason to 'other' - $sql = 'UPDATE ' . REPORTS_TABLE . ' - SET reason_id = ' . $other_reason_id . ", report_text = '" . $db->sql_escape($reason_row['reason_description']) . "\n\n' || report_text - WHERE reason_id = $reason_id"; - break; - } - $db->sql_query($sql); - - $db->sql_query('DELETE FROM ' . REPORTS_REASONS_TABLE . ' WHERE reason_id = ' . $reason_id); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_REASON_REMOVED', false, array($reason_row['reason_title'])); - trigger_error($user->lang['REASON_REMOVED'] . adm_back_link($this->u_action)); - } - else - { - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( - 'i' => $id, - 'mode' => $mode, - 'action' => $action, - 'id' => $reason_id)) - ); - } - - break; - - case 'move_up': - case 'move_down': - - if (!check_link_hash($request->variable('hash', ''), 'acp_reasons')) - { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - $sql = 'SELECT reason_order - FROM ' . REPORTS_REASONS_TABLE . " - WHERE reason_id = $reason_id"; - $result = $db->sql_query($sql); - $order = $db->sql_fetchfield('reason_order'); - $db->sql_freeresult($result); - - if ($order === false || ($order == 0 && $action == 'move_up')) - { - break; - } - $order = (int) $order; - $order_total = $order * 2 + (($action == 'move_up') ? -1 : 1); - - $sql = 'UPDATE ' . REPORTS_REASONS_TABLE . ' - SET reason_order = ' . $order_total . ' - reason_order - WHERE reason_order IN (' . $order . ', ' . (($action == 'move_up') ? $order - 1 : $order + 1) . ')'; - $db->sql_query($sql); - - if ($request->is_ajax()) - { - $json_response = new \phpbb\json_response; - $json_response->send(array( - 'success' => (bool) $db->sql_affectedrows(), - )); - } - break; - } - - // By default, check that order is valid and fix it if necessary - $sql = 'SELECT reason_id, reason_order - FROM ' . REPORTS_REASONS_TABLE . ' - ORDER BY reason_order'; - $result = $db->sql_query($sql); - - if ($row = $db->sql_fetchrow($result)) - { - $order = 0; - do - { - ++$order; - - if ($row['reason_order'] != $order) - { - $sql = 'UPDATE ' . REPORTS_REASONS_TABLE . " - SET reason_order = $order - WHERE reason_id = {$row['reason_id']}"; - $db->sql_query($sql); - } - } - while ($row = $db->sql_fetchrow($result)); - } - $db->sql_freeresult($result); - - $template->assign_vars(array( - 'U_ACTION' => $this->u_action, - ) - ); - - // Reason count - $sql = 'SELECT reason_id, COUNT(reason_id) AS reason_count - FROM ' . REPORTS_TABLE . ' - GROUP BY reason_id'; - $result = $db->sql_query($sql); - - $reason_count = array(); - while ($row = $db->sql_fetchrow($result)) - { - $reason_count[$row['reason_id']] = $row['reason_count']; - } - $db->sql_freeresult($result); - - $sql = 'SELECT * - FROM ' . REPORTS_REASONS_TABLE . ' - ORDER BY reason_order ASC'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $translated = false; - $other_reason = ($row['reason_title'] == 'other') ? true : false; - - // If the reason is defined within the language file, we will use the localized version, else just use the database entry... - if (isset($user->lang['report_reasons']['TITLE'][strtoupper($row['reason_title'])]) && isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])])) - { - $row['reason_description'] = $user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])]; - $row['reason_title'] = $user->lang['report_reasons']['TITLE'][strtoupper($row['reason_title'])]; - - $translated = true; - } - - $template->assign_block_vars('reasons', array( - 'REASON_TITLE' => $row['reason_title'], - 'REASON_DESCRIPTION' => $row['reason_description'], - 'REASON_COUNT' => (isset($reason_count[$row['reason_id']])) ? $reason_count[$row['reason_id']] : 0, - - 'S_TRANSLATED' => $translated, - 'S_OTHER_REASON' => $other_reason, - - 'U_EDIT' => $this->u_action . '&action=edit&id=' . $row['reason_id'], - 'U_DELETE' => (!$other_reason) ? $this->u_action . '&action=delete&id=' . $row['reason_id'] : '', - 'U_MOVE_UP' => $this->u_action . '&action=move_up&id=' . $row['reason_id'] . '&hash=' . generate_link_hash('acp_reasons'), - 'U_MOVE_DOWN' => $this->u_action . '&action=move_down&id=' . $row['reason_id'] . '&hash=' . generate_link_hash('acp_reasons')) - ); - } - $db->sql_freeresult($result); - } -} diff --git a/install/update/new/includes/acp/acp_styles.php b/install/update/new/includes/acp/acp_styles.php deleted file mode 100644 index 87c8d88..0000000 --- a/install/update/new/includes/acp/acp_styles.php +++ /dev/null @@ -1,1396 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -class acp_styles -{ - public $u_action; - - protected $u_base_action; - protected $s_hidden_fields; - protected $mode; - protected $styles_path; - protected $styles_path_absolute = 'styles'; - protected $default_style = 0; - protected $styles_list_cols = 0; - protected $reserved_style_names = array('adm', 'admin', 'all'); - - /** @var \phpbb\config\config */ - protected $config; - - /** @var \phpbb\db\driver\driver_interface */ - protected $db; - - /** @var \phpbb\user */ - protected $user; - - /** @var \phpbb\template\template */ - protected $template; - - /** @var \phpbb\request\request_interface */ - protected $request; - - /** @var \phpbb\cache\driver\driver_interface */ - protected $cache; - - /** @var \phpbb\auth\auth */ - protected $auth; - - /** @var \phpbb\textformatter\cache_interface */ - protected $text_formatter_cache; - - /** @var string */ - protected $phpbb_root_path; - - /** @var string */ - protected $php_ext; - - /** @var \phpbb\event\dispatcher_interface */ - protected $dispatcher; - - public function main($id, $mode) - { - global $db, $user, $phpbb_admin_path, $phpbb_root_path, $phpEx, $template, $request, $cache, $auth, $config, $phpbb_dispatcher, $phpbb_container; - - $this->db = $db; - $this->user = $user; - $this->template = $template; - $this->request = $request; - $this->cache = $cache; - $this->auth = $auth; - $this->text_formatter_cache = $phpbb_container->get('text_formatter.cache'); - $this->config = $config; - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $phpEx; - $this->dispatcher = $phpbb_dispatcher; - - $this->default_style = $config['default_style']; - $this->styles_path = $this->phpbb_root_path . $this->styles_path_absolute . '/'; - - $this->u_base_action = append_sid("{$phpbb_admin_path}index.{$this->php_ext}", "i={$id}"); - $this->s_hidden_fields = array( - 'mode' => $mode, - ); - - $this->user->add_lang('acp/styles'); - - $this->tpl_name = 'acp_styles'; - $this->page_title = 'ACP_CAT_STYLES'; - $this->mode = $mode; - - $action = $this->request->variable('action', ''); - $post_actions = array('install', 'activate', 'deactivate', 'uninstall'); - - foreach ($post_actions as $key) - { - if ($this->request->is_set_post($key)) - { - $action = $key; - } - } - - // The uninstall action uses confirm_box() to verify the validity of the request, - // so there is no need to check for a valid token here. - if (in_array($action, $post_actions) && $action != 'uninstall') - { - $is_valid_request = check_link_hash($request->variable('hash', ''), $action) || check_form_key('styles_management'); - - if (!$is_valid_request) - { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); - } - } - - if ($action != '') - { - $this->s_hidden_fields['action'] = $action; - } - - $this->template->assign_vars(array( - 'U_ACTION' => $this->u_base_action, - 'S_HIDDEN_FIELDS' => build_hidden_fields($this->s_hidden_fields) - ) - ); - - /** - * Run code before ACP styles action execution - * - * @event core.acp_styles_action_before - * @var int id Module ID - * @var string mode Active module - * @var string action Module that should be run - * @since 3.1.7-RC1 - */ - $vars = array('id', 'mode', 'action'); - extract($this->dispatcher->trigger_event('core.acp_styles_action_before', compact($vars))); - - // Execute actions - switch ($action) - { - case 'install': - $this->action_install(); - return; - case 'uninstall': - $this->action_uninstall(); - return; - case 'activate': - $this->action_activate(); - return; - case 'deactivate': - $this->action_deactivate(); - return; - case 'details': - $this->action_details(); - return; - default: - $this->frontend(); - } - } - - /** - * Main page - */ - protected function frontend() - { - add_form_key('styles_management'); - - // Check mode - switch ($this->mode) - { - case 'style': - $this->welcome_message('ACP_STYLES', 'ACP_STYLES_EXPLAIN'); - $this->show_installed(); - return; - case 'install': - $this->welcome_message('INSTALL_STYLES', 'INSTALL_STYLES_EXPLAIN'); - $this->show_available(); - return; - } - trigger_error($this->user->lang['NO_MODE'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - /** - * Install style(s) - */ - protected function action_install() - { - // Get list of styles to install - $dirs = $this->request_vars('dir', '', true); - - // Get list of styles that can be installed - $styles = $this->find_available(false); - - // Install each style - $messages = array(); - $installed_names = array(); - $installed_dirs = array(); - foreach ($dirs as $dir) - { - if (in_array($dir, $this->reserved_style_names)) - { - $messages[] = $this->user->lang('STYLE_NAME_RESERVED', htmlspecialchars($dir)); - continue; - } - - $found = false; - foreach ($styles as &$style) - { - // Check if: - // 1. Directory matches directory we are looking for - // 2. Style is not installed yet - // 3. Style with same name or directory hasn't been installed already within this function - if ($style['style_path'] == $dir && empty($style['_installed']) && !in_array($style['style_path'], $installed_dirs) && !in_array($style['style_name'], $installed_names)) - { - // Install style - $style['style_active'] = 1; - $style['style_id'] = $this->install_style($style); - $style['_installed'] = true; - $found = true; - $installed_names[] = $style['style_name']; - $installed_dirs[] = $style['style_path']; - $messages[] = sprintf($this->user->lang['STYLE_INSTALLED'], htmlspecialchars($style['style_name'])); - } - } - if (!$found) - { - $messages[] = sprintf($this->user->lang['STYLE_NOT_INSTALLED'], htmlspecialchars($dir)); - } - } - - // Invalidate the text formatter's cache for the new styles to take effect - if (!empty($installed_names)) - { - $this->text_formatter_cache->invalidate(); - } - - // Show message - if (!count($messages)) - { - trigger_error($this->user->lang['NO_MATCHING_STYLES_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); - } - $message = implode('
', $messages); - $message .= '

« ' . $this->user->lang('STYLE_INSTALLED_RETURN_INSTALLED_STYLES') . ''; - $message .= '

» ' . $this->user->lang('STYLE_INSTALLED_RETURN_UNINSTALLED_STYLES') . ''; - trigger_error($message, E_USER_NOTICE); - } - - /** - * Confirm styles removal - */ - protected function action_uninstall() - { - // Get list of styles to uninstall - $ids = $this->request_vars('id', 0, true); - - // Don't remove prosilver, you can still deactivate it. - $sql = 'SELECT style_id - FROM ' . STYLES_TABLE . " - WHERE style_name = '" . $this->db->sql_escape('prosilver') . "'"; - $result = $this->db->sql_query($sql); - $prosilver_id = (int) $this->db->sql_fetchfield('style_id'); - $this->db->sql_freeresult($result); - - if ($prosilver_id && in_array($prosilver_id, $ids)) - { - trigger_error($this->user->lang('UNINSTALL_PROSILVER') . adm_back_link($this->u_action), E_USER_WARNING); - } - - // Check if confirmation box was submitted - if (confirm_box(true)) - { - // Uninstall - $this->action_uninstall_confirmed($ids, $this->request->variable('confirm_delete_files', false)); - return; - } - - // Confirm box - $s_hidden = build_hidden_fields(array( - 'action' => 'uninstall', - 'ids' => $ids - )); - $this->template->assign_var('S_CONFIRM_DELETE', true); - confirm_box(false, $this->user->lang['CONFIRM_UNINSTALL_STYLES'], $s_hidden, 'acp_styles.html'); - - // Canceled - show styles list - $this->frontend(); - } - - /** - * Uninstall styles(s) - * - * @param array $ids List of style IDs - * @param bool $delete_files If true, script will attempt to remove files for selected styles - */ - protected function action_uninstall_confirmed($ids, $delete_files) - { - global $user, $phpbb_log; - - $default = $this->default_style; - $uninstalled = array(); - $messages = array(); - - // Check styles list - foreach ($ids as $id) - { - if (!$id) - { - trigger_error($this->user->lang['INVALID_STYLE_ID'] . adm_back_link($this->u_action), E_USER_WARNING); - } - if ($id == $default) - { - trigger_error($this->user->lang['UNINSTALL_DEFAULT'] . adm_back_link($this->u_action), E_USER_WARNING); - } - $uninstalled[$id] = false; - } - - // Order by reversed style_id, so parent styles would be removed after child styles - // This way parent and child styles can be removed in same function call - $sql = 'SELECT * - FROM ' . STYLES_TABLE . ' - WHERE style_id IN (' . implode(', ', $ids) . ') - ORDER BY style_id DESC'; - $result = $this->db->sql_query($sql); - - $rows = $this->db->sql_fetchrowset($result); - $this->db->sql_freeresult($result); - - // Uinstall each style - $uninstalled = array(); - foreach ($rows as $style) - { - $result = $this->uninstall_style($style, $delete_files); - - if (is_string($result)) - { - $messages[] = $result; - continue; - } - $messages[] = sprintf($this->user->lang['STYLE_UNINSTALLED'], $style['style_name']); - $uninstalled[] = $style['style_name']; - - // Attempt to delete files - if ($delete_files) - { - $messages[] = sprintf($this->user->lang[$this->delete_style_files($style['style_path']) ? 'DELETE_STYLE_FILES_SUCCESS' : 'DELETE_STYLE_FILES_FAILED'], $style['style_name']); - } - } - - if (empty($messages)) - { - // Nothing to uninstall? - trigger_error($this->user->lang['NO_MATCHING_STYLES_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - // Log action - if (count($uninstalled)) - { - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_STYLE_DELETE', false, array(implode(', ', $uninstalled))); - } - - // Clear cache - $this->cache->purge(); - - // Show message - trigger_error(implode('
', $messages) . adm_back_link($this->u_action), E_USER_NOTICE); - } - - /** - * Activate styles - */ - protected function action_activate() - { - // Get list of styles to activate - $ids = $this->request_vars('id', 0, true); - - // Activate styles - $sql = 'UPDATE ' . STYLES_TABLE . ' - SET style_active = 1 - WHERE style_id IN (' . implode(', ', $ids) . ')'; - $this->db->sql_query($sql); - - // Purge cache - $this->cache->destroy('sql', STYLES_TABLE); - - // Show styles list - $this->frontend(); - } - - /** - * Deactivate styles - */ - protected function action_deactivate() - { - // Get list of styles to deactivate - $ids = $this->request_vars('id', 0, true); - - // Check for default style - foreach ($ids as $id) - { - if ($id == $this->default_style) - { - trigger_error($this->user->lang['DEACTIVATE_DEFAULT'] . adm_back_link($this->u_action), E_USER_WARNING); - } - } - - // Reset default style for users who use selected styles - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_style = ' . (int) $this->default_style . ' - WHERE user_style IN (' . implode(', ', $ids) . ')'; - $this->db->sql_query($sql); - - // Deactivate styles - $sql = 'UPDATE ' . STYLES_TABLE . ' - SET style_active = 0 - WHERE style_id IN (' . implode(', ', $ids) . ')'; - $this->db->sql_query($sql); - - // Purge cache - $this->cache->destroy('sql', STYLES_TABLE); - - // Show styles list - $this->frontend(); - } - - /** - * Show style details - */ - protected function action_details() - { - global $user, $phpbb_log; - - $id = $this->request->variable('id', 0); - if (!$id) - { - trigger_error($this->user->lang['NO_MATCHING_STYLES_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - // Get all styles - $styles = $this->get_styles(); - usort($styles, array($this, 'sort_styles')); - - // Find current style - $style = false; - foreach ($styles as $row) - { - if ($row['style_id'] == $id) - { - $style = $row; - break; - } - } - - if ($style === false) - { - trigger_error($this->user->lang['NO_MATCHING_STYLES_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - // Read style configuration file - $style_cfg = $this->read_style_cfg($style['style_path']); - - // Find all available parent styles - $list = $this->find_possible_parents($styles, $id); - - // Add form key - $form_key = 'acp_styles'; - add_form_key($form_key); - - // Change data - if ($this->request->variable('update', false)) - { - if (!check_form_key($form_key)) - { - trigger_error($this->user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - $update = array( - 'style_name' => trim($this->request->variable('style_name', $style['style_name'])), - 'style_parent_id' => $this->request->variable('style_parent', (int) $style['style_parent_id']), - 'style_active' => $this->request->variable('style_active', (int) $style['style_active']), - ); - $update_action = $this->u_action . '&action=details&id=' . $id; - - // Check style name - if ($update['style_name'] != $style['style_name']) - { - if (!strlen($update['style_name'])) - { - trigger_error($this->user->lang['STYLE_ERR_STYLE_NAME'] . adm_back_link($update_action), E_USER_WARNING); - } - foreach ($styles as $row) - { - if ($row['style_name'] == $update['style_name']) - { - trigger_error($this->user->lang['STYLE_ERR_NAME_EXIST'] . adm_back_link($update_action), E_USER_WARNING); - } - } - } - else - { - unset($update['style_name']); - } - - // Check parent style id - if ($update['style_parent_id'] != $style['style_parent_id']) - { - if ($update['style_parent_id'] != 0) - { - $found = false; - foreach ($list as $row) - { - if ($row['style_id'] == $update['style_parent_id']) - { - $found = true; - $update['style_parent_tree'] = ($row['style_parent_tree'] != '' ? $row['style_parent_tree'] . '/' : '') . $row['style_path']; - break; - } - } - if (!$found) - { - trigger_error($this->user->lang['STYLE_ERR_INVALID_PARENT'] . adm_back_link($update_action), E_USER_WARNING); - } - } - else - { - $update['style_parent_tree'] = ''; - } - } - else - { - unset($update['style_parent_id']); - } - - // Check style_active - if ($update['style_active'] != $style['style_active']) - { - if (!$update['style_active'] && $this->default_style == $style['style_id']) - { - trigger_error($this->user->lang['DEACTIVATE_DEFAULT'] . adm_back_link($update_action), E_USER_WARNING); - } - } - else - { - unset($update['style_active']); - } - - // Update data - if (count($update)) - { - $sql = 'UPDATE ' . STYLES_TABLE . ' - SET ' . $this->db->sql_build_array('UPDATE', $update) . " - WHERE style_id = $id"; - $this->db->sql_query($sql); - - $style = array_merge($style, $update); - - if (isset($update['style_parent_id'])) - { - // Update styles tree - $styles = $this->get_styles(); - if ($this->update_styles_tree($styles, $style)) - { - // Something was changed in styles tree, purge all cache - $this->cache->purge(); - } - } - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_STYLE_EDIT_DETAILS', false, array($style['style_name'])); - } - - // Update default style - $default = $this->request->variable('style_default', 0); - if ($default) - { - if (!$style['style_active']) - { - trigger_error($this->user->lang['STYLE_DEFAULT_CHANGE_INACTIVE'] . adm_back_link($update_action), E_USER_WARNING); - } - $this->config->set('default_style', $id); - $this->cache->purge(); - } - - // Show styles list - $this->frontend(); - return; - } - - // Show page title - $this->welcome_message('ACP_STYLES', null); - - // Show parent styles - foreach ($list as $row) - { - $this->template->assign_block_vars('parent_styles', array( - 'STYLE_ID' => $row['style_id'], - 'STYLE_NAME' => htmlspecialchars($row['style_name']), - 'LEVEL' => $row['level'], - 'SPACER' => str_repeat('  ', $row['level']), - ) - ); - } - - // Show style details - $this->template->assign_vars(array( - 'S_STYLE_DETAILS' => true, - 'STYLE_ID' => $style['style_id'], - 'STYLE_NAME' => htmlspecialchars($style['style_name']), - 'STYLE_PATH' => htmlspecialchars($style['style_path']), - 'STYLE_VERSION' => htmlspecialchars($style_cfg['style_version']), - 'STYLE_COPYRIGHT' => strip_tags($style['style_copyright']), - 'STYLE_PARENT' => $style['style_parent_id'], - 'S_STYLE_ACTIVE' => $style['style_active'], - 'S_STYLE_DEFAULT' => ($style['style_id'] == $this->default_style) - ) - ); - } - - /** - * List installed styles - */ - protected function show_installed() - { - // Get all installed styles - $styles = $this->get_styles(); - - if (!count($styles)) - { - trigger_error($this->user->lang['NO_MATCHING_STYLES_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - usort($styles, array($this, 'sort_styles')); - - // Get users - $users = $this->get_users(); - - // Add users counter to rows - foreach ($styles as &$style) - { - $style['_users'] = isset($users[$style['style_id']]) ? $users[$style['style_id']] : 0; - } - - // Set up styles list variables - // Addons should increase this number and update template variable - $this->styles_list_cols = 4; - $this->template->assign_var('STYLES_LIST_COLS', $this->styles_list_cols); - - // Show styles list - $this->show_styles_list($styles, 0, 0); - - // Show styles with invalid inherits_id - foreach ($styles as $style) - { - if (empty($style['_shown'])) - { - $style['_note'] = sprintf($this->user->lang['REQUIRES_STYLE'], htmlspecialchars($style['style_parent_tree'])); - $this->list_style($style, 0); - } - } - - // Add buttons - $this->template->assign_block_vars('extra_actions', array( - 'ACTION_NAME' => 'activate', - 'L_ACTION' => $this->user->lang['STYLE_ACTIVATE'], - ) - ); - - $this->template->assign_block_vars('extra_actions', array( - 'ACTION_NAME' => 'deactivate', - 'L_ACTION' => $this->user->lang['STYLE_DEACTIVATE'], - ) - ); - - if (isset($this->style_counters) && $this->style_counters['total'] > 1) - { - $this->template->assign_block_vars('extra_actions', array( - 'ACTION_NAME' => 'uninstall', - 'L_ACTION' => $this->user->lang['STYLE_UNINSTALL'], - ) - ); - } - } - - /** - * Show list of styles that can be installed - */ - protected function show_available() - { - // Get list of styles - $styles = $this->find_available(true); - - // Show styles - if (empty($styles)) - { - trigger_error($this->user->lang['NO_UNINSTALLED_STYLE'] . adm_back_link($this->u_base_action), E_USER_NOTICE); - } - - usort($styles, array($this, 'sort_styles')); - - $this->styles_list_cols = 3; - $this->template->assign_vars(array( - 'STYLES_LIST_COLS' => $this->styles_list_cols, - 'STYLES_LIST_HIDE_COUNT' => true - ) - ); - - // Show styles - foreach ($styles as &$style) - { - // Check if style has a parent style in styles list - $has_parent = false; - if ($style['_inherit_name'] != '') - { - foreach ($styles as $parent_style) - { - if ($parent_style['style_name'] == $style['_inherit_name'] && empty($parent_style['_shown'])) - { - // Show parent style first - $has_parent = true; - } - } - } - if (!$has_parent) - { - $this->list_style($style, 0); - $this->show_available_child_styles($styles, $style['style_name'], 1); - } - } - - // Show styles that do not have parent style in styles list - foreach ($styles as $style) - { - if (empty($style['_shown'])) - { - $this->list_style($style, 0); - } - } - - // Add button - if (isset($this->style_counters) && $this->style_counters['caninstall'] > 0) - { - $this->template->assign_block_vars('extra_actions', array( - 'ACTION_NAME' => 'install', - 'L_ACTION' => $this->user->lang['INSTALL_STYLES'], - ) - ); - } - } - - /** - * Find styles available for installation - * - * @param bool $all if true, function will return all installable styles. if false, function will return only styles that can be installed - * @return array List of styles - */ - protected function find_available($all) - { - // Get list of installed styles - $installed = $this->get_styles(); - - $installed_dirs = array(); - $installed_names = array(); - foreach ($installed as $style) - { - $installed_dirs[] = $style['style_path']; - $installed_names[$style['style_name']] = array( - 'path' => $style['style_path'], - 'id' => $style['style_id'], - 'parent' => $style['style_parent_id'], - 'tree' => (strlen($style['style_parent_tree']) ? $style['style_parent_tree'] . '/' : '') . $style['style_path'], - ); - } - - // Get list of directories - $dirs = $this->find_style_dirs(); - - // Find styles that can be installed - $styles = array(); - foreach ($dirs as $dir) - { - if (in_array($dir, $installed_dirs)) - { - // Style is already installed - continue; - } - $cfg = $this->read_style_cfg($dir); - if ($cfg === false) - { - // Invalid style.cfg - continue; - } - - // Style should be available for installation - $parent = $cfg['parent']; - $style = array( - 'style_id' => 0, - 'style_name' => $cfg['name'], - 'style_copyright' => $cfg['copyright'], - 'style_active' => 0, - 'style_path' => $dir, - 'bbcode_bitfield' => $cfg['template_bitfield'], - 'style_parent_id' => 0, - 'style_parent_tree' => '', - // Extra values for styles list - // All extra variable start with _ so they won't be confused with data that can be added to styles table - '_inherit_name' => $parent, - '_available' => true, - '_note' => '', - ); - - // Check style inheritance - if ($parent != '') - { - if (isset($installed_names[$parent])) - { - // Parent style is installed - $row = $installed_names[$parent]; - $style['style_parent_id'] = $row['id']; - $style['style_parent_tree'] = $row['tree']; - } - else - { - // Parent style is not installed yet - $style['_available'] = false; - $style['_note'] = sprintf($this->user->lang['REQUIRES_STYLE'], htmlspecialchars($parent)); - } - } - - if ($all || $style['_available']) - { - $styles[] = $style; - } - } - - return $styles; - } - - /** - * Show styles list - * - * @param array $styles styles list - * @param int $parent parent style id - * @param int $level style inheritance level - */ - protected function show_styles_list(&$styles, $parent, $level) - { - foreach ($styles as &$style) - { - if (empty($style['_shown']) && $style['style_parent_id'] == $parent) - { - $this->list_style($style, $level); - $this->show_styles_list($styles, $style['style_id'], $level + 1); - } - } - } - - /** - * Show available styles tree - * - * @param array $styles Styles list, passed as reference - * @param string $name Name of parent style - * @param int $level Styles tree level - */ - protected function show_available_child_styles(&$styles, $name, $level) - { - foreach ($styles as &$style) - { - if (empty($style['_shown']) && $style['_inherit_name'] == $name) - { - $this->list_style($style, $level); - $this->show_available_child_styles($styles, $style['style_name'], $level + 1); - } - } - } - - /** - * Update styles tree - * - * @param array $styles Styles list, passed as reference - * @param array|false $style Current style, false if root - * @return bool True if something was updated, false if not - */ - protected function update_styles_tree(&$styles, $style = false) - { - $parent_id = ($style === false) ? 0 : $style['style_id']; - $parent_tree = ($style === false) ? '' : ($style['style_parent_tree'] == '' ? '' : $style['style_parent_tree']) . $style['style_path']; - $update = false; - $updated = false; - foreach ($styles as &$row) - { - if ($row['style_parent_id'] == $parent_id) - { - if ($row['style_parent_tree'] != $parent_tree) - { - $row['style_parent_tree'] = $parent_tree; - $update = true; - } - $updated |= $this->update_styles_tree($styles, $row); - } - } - if ($update) - { - $sql = 'UPDATE ' . STYLES_TABLE . " - SET style_parent_tree = '" . $this->db->sql_escape($parent_tree) . "' - WHERE style_parent_id = {$parent_id}"; - $this->db->sql_query($sql); - $updated = true; - } - return $updated; - } - - /** - * Find all possible parent styles for style - * - * @param array $styles list of styles - * @param int $id id of style - * @param int $parent current parent style id - * @param int $level current tree level - * @return array Style ids, names and levels - */ - protected function find_possible_parents($styles, $id = -1, $parent = 0, $level = 0) - { - $results = array(); - foreach ($styles as $style) - { - if ($style['style_id'] != $id && $style['style_parent_id'] == $parent) - { - $results[] = array( - 'style_id' => $style['style_id'], - 'style_name' => $style['style_name'], - 'style_path' => $style['style_path'], - 'style_parent_id' => $style['style_parent_id'], - 'style_parent_tree' => $style['style_parent_tree'], - 'level' => $level - ); - $results = array_merge($results, $this->find_possible_parents($styles, $id, $style['style_id'], $level + 1)); - } - } - return $results; - } - - /** - * Show item in styles list - * - * @param array $style style row - * @param int $level style inheritance level - */ - protected function list_style(&$style, $level) - { - // Mark row as shown - if (!empty($style['_shown'])) - { - return; - } - - $style['_shown'] = true; - - // Generate template variables - $actions = array(); - $row = array( - // Style data - 'STYLE_ID' => $style['style_id'], - 'STYLE_NAME' => htmlspecialchars($style['style_name']), - 'STYLE_PHPBB_VERSION' => $this->read_style_cfg($style['style_path'])['phpbb_version'], - 'STYLE_PATH' => htmlspecialchars($style['style_path']), - 'STYLE_COPYRIGHT' => strip_tags($style['style_copyright']), - 'STYLE_ACTIVE' => $style['style_active'], - - // Additional data - 'DEFAULT' => ($style['style_id'] && $style['style_id'] == $this->default_style), - 'USERS' => (isset($style['_users'])) ? $style['_users'] : '', - 'LEVEL' => $level, - 'PADDING' => (4 + 16 * $level), - 'SHOW_COPYRIGHT' => ($style['style_id']) ? false : true, - 'STYLE_PATH_FULL' => htmlspecialchars($this->styles_path_absolute . '/' . $style['style_path']) . '/', - - // Comment to show below style - 'COMMENT' => (isset($style['_note'])) ? $style['_note'] : '', - - // The following variables should be used by hooks to add custom HTML code - 'EXTRA' => '', - 'EXTRA_OPTIONS' => '' - ); - - // Status specific data - if ($style['style_id']) - { - // Style is installed - - // Details - $actions[] = array( - 'U_ACTION' => $this->u_action . '&action=details&id=' . $style['style_id'], - 'L_ACTION' => $this->user->lang['DETAILS'] - ); - - // Activate/Deactive - $action_name = ($style['style_active'] ? 'de' : '') . 'activate'; - - $actions[] = array( - 'U_ACTION' => $this->u_action . '&action=' . $action_name . '&hash=' . generate_link_hash($action_name) . '&id=' . $style['style_id'], - 'L_ACTION' => $this->user->lang['STYLE_' . ($style['style_active'] ? 'DE' : '') . 'ACTIVATE'] - ); - -/* // Export - $actions[] = array( - 'U_ACTION' => $this->u_action . '&action=export&hash=' . generate_link_hash('export') . '&id=' . $style['style_id'], - 'L_ACTION' => $this->user->lang['EXPORT'] - ); */ - - if ($style['style_name'] !== 'prosilver') - { - // Uninstall - $actions[] = array( - 'U_ACTION' => $this->u_action . '&action=uninstall&hash=' . generate_link_hash('uninstall') . '&id=' . $style['style_id'], - 'L_ACTION' => $this->user->lang['STYLE_UNINSTALL'] - ); - } - - // Preview - $actions[] = array( - 'U_ACTION' => append_sid($this->phpbb_root_path . 'index.' . $this->php_ext, 'style=' . $style['style_id']), - 'L_ACTION' => $this->user->lang['PREVIEW'] - ); - } - else - { - // Style is not installed - if (empty($style['_available'])) - { - $actions[] = array( - 'HTML' => $this->user->lang['CANNOT_BE_INSTALLED'] - ); - } - else - { - $actions[] = array( - 'U_ACTION' => $this->u_action . '&action=install&hash=' . generate_link_hash('install') . '&dir=' . urlencode($style['style_path']), - 'L_ACTION' => $this->user->lang['INSTALL_STYLE'] - ); - } - } - - // todo: add hook - - // Assign template variables - $this->template->assign_block_vars('styles_list', $row); - foreach ($actions as $action) - { - $this->template->assign_block_vars('styles_list.actions', $action); - } - - // Increase counters - $counter = ($style['style_id']) ? ($style['style_active'] ? 'active' : 'inactive') : (empty($style['_available']) ? 'cannotinstall' : 'caninstall'); - if (!isset($this->style_counters)) - { - $this->style_counters = array( - 'total' => 0, - 'active' => 0, - 'inactive' => 0, - 'caninstall' => 0, - 'cannotinstall' => 0 - ); - } - $this->style_counters[$counter]++; - $this->style_counters['total']++; - } - - /** - * Show welcome message - * - * @param string $title main title - * @param string $description page description - */ - protected function welcome_message($title, $description) - { - $this->template->assign_vars(array( - 'L_TITLE' => $this->user->lang[$title], - 'L_EXPLAIN' => (isset($this->user->lang[$description])) ? $this->user->lang[$description] : '' - ) - ); - } - - /** - * Find all directories that have styles - * - * @return array Directory names - */ - protected function find_style_dirs() - { - $styles = array(); - - $dp = @opendir($this->styles_path); - if ($dp) - { - while (($file = readdir($dp)) !== false) - { - $dir = $this->styles_path . $file; - if ($file[0] == '.' || !is_dir($dir)) - { - continue; - } - - if (file_exists("{$dir}/style.cfg")) - { - $styles[] = $file; - } - } - closedir($dp); - } - - return $styles; - } - - /** - * Sort styles - */ - public function sort_styles($style1, $style2) - { - if ($style1['style_active'] != $style2['style_active']) - { - return ($style1['style_active']) ? -1 : 1; - } - if (isset($style1['_available']) && $style1['_available'] != $style2['_available']) - { - return ($style1['_available']) ? -1 : 1; - } - return strcasecmp(isset($style1['style_name']) ? $style1['style_name'] : $style1['name'], isset($style2['style_name']) ? $style2['style_name'] : $style2['name']); - } - - /** - * Read style configuration file - * - * @param string $dir style directory - * @return array|bool Style data, false on error - */ - protected function read_style_cfg($dir) - { - // This should never happen, we give them a red warning because of its relevance. - if (!file_exists($this->styles_path . $dir . '/style.cfg')) - { - trigger_error($this->user->lang('NO_STYLE_CFG', $dir), E_USER_WARNING); - } - - static $required = array('name', 'phpbb_version', 'copyright'); - - $cfg = parse_cfg_file($this->styles_path . $dir . '/style.cfg'); - - // Check if it is a valid file - foreach ($required as $key) - { - if (!isset($cfg[$key])) - { - return false; - } - } - - // Check data - if (!isset($cfg['parent']) || !is_string($cfg['parent']) || $cfg['parent'] == $cfg['name']) - { - $cfg['parent'] = ''; - } - if (!isset($cfg['template_bitfield'])) - { - $cfg['template_bitfield'] = $this->default_bitfield(); - } - - return $cfg; - } - - /** - * Install style - * - * @param array $style style data - * @return int Style id - */ - protected function install_style($style) - { - global $user, $phpbb_log; - - // Generate row - $sql_ary = array(); - foreach ($style as $key => $value) - { - if ($key != 'style_id' && substr($key, 0, 1) != '_') - { - $sql_ary[$key] = $value; - } - } - - // Add to database - $this->db->sql_transaction('begin'); - - $sql = 'INSERT INTO ' . STYLES_TABLE . ' - ' . $this->db->sql_build_array('INSERT', $sql_ary); - $this->db->sql_query($sql); - - $id = $this->db->sql_nextid(); - - $this->db->sql_transaction('commit'); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_STYLE_ADD', false, array($sql_ary['style_name'])); - - return $id; - } - - /** - * Lists all styles - * - * @return array Rows with styles data - */ - protected function get_styles() - { - $sql = 'SELECT * - FROM ' . STYLES_TABLE; - $result = $this->db->sql_query($sql); - - $rows = $this->db->sql_fetchrowset($result); - $this->db->sql_freeresult($result); - - return $rows; - } - - /** - * Count users for each style - * - * @return array Styles in following format: [style_id] = number of users - */ - protected function get_users() - { - $sql = 'SELECT user_style, COUNT(user_style) AS style_count - FROM ' . USERS_TABLE . ' - GROUP BY user_style'; - $result = $this->db->sql_query($sql); - - $style_count = array(); - while ($row = $this->db->sql_fetchrow($result)) - { - $style_count[$row['user_style']] = $row['style_count']; - } - $this->db->sql_freeresult($result); - - return $style_count; - } - - /** - * Uninstall style - * - * @param array $style Style data - * @return bool|string True on success, error message on error - */ - protected function uninstall_style($style) - { - $id = $style['style_id']; - $path = $style['style_path']; - - // Check if style has child styles - $sql = 'SELECT style_id - FROM ' . STYLES_TABLE . ' - WHERE style_parent_id = ' . (int) $id . " OR style_parent_tree = '" . $this->db->sql_escape($path) . "'"; - $result = $this->db->sql_query($sql); - - $conflict = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if ($conflict !== false) - { - return sprintf($this->user->lang['STYLE_UNINSTALL_DEPENDENT'], $style['style_name']); - } - - // Change default style for users - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_style = ' . (int) $this->default_style . ' - WHERE user_style = ' . $id; - $this->db->sql_query($sql); - - // Uninstall style - $sql = 'DELETE FROM ' . STYLES_TABLE . ' - WHERE style_id = ' . $id; - $this->db->sql_query($sql); - return true; - } - - /** - * Delete all files in style directory - * - * @param string $path Style directory - * @param string $dir Directory to remove inside style's directory - * @return bool True on success, false on error - */ - protected function delete_style_files($path, $dir = '') - { - $dirname = $this->styles_path . $path . $dir; - $result = true; - - $dp = @opendir($dirname); - - if ($dp) - { - while (($file = readdir($dp)) !== false) - { - if ($file == '.' || $file == '..') - { - continue; - } - $filename = $dirname . '/' . $file; - if (is_dir($filename)) - { - if (!$this->delete_style_files($path, $dir . '/' . $file)) - { - $result = false; - } - } - else - { - if (!@unlink($filename)) - { - $result = false; - } - } - } - closedir($dp); - } - if (!@rmdir($dirname)) - { - return false; - } - - return $result; - } - - /** - * Get list of items from posted data - * - * @param string $name Variable name - * @param string|int $default Default value for array - * @param bool $error If true, error will be triggered if list is empty - * @return array Items - */ - protected function request_vars($name, $default, $error = false) - { - $item = $this->request->variable($name, $default); - $items = $this->request->variable($name . 's', array($default)); - - if (count($items) == 1 && $items[0] == $default) - { - $items = array(); - } - - if ($item != $default && !count($items)) - { - $items[] = $item; - } - - if ($error && !count($items)) - { - trigger_error($this->user->lang['NO_MATCHING_STYLES_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - return $items; - } - - /** - * Generates default bitfield - * - * This bitfield decides which bbcodes are defined in a template. - * - * @return string Bitfield - */ - protected function default_bitfield() - { - static $value; - if (isset($value)) - { - return $value; - } - - // Hardcoded template bitfield to add for new templates - $default_bitfield = '1111111111111'; - - $bitfield = new bitfield(); - for ($i = 0; $i < strlen($default_bitfield); $i++) - { - if ($default_bitfield[$i] == '1') - { - $bitfield->set($i); - } - } - - return $bitfield->get_base64(); - } - -} diff --git a/install/update/new/includes/acp/acp_update.php b/install/update/new/includes/acp/acp_update.php deleted file mode 100644 index fa3afa6..0000000 --- a/install/update/new/includes/acp/acp_update.php +++ /dev/null @@ -1,88 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -class acp_update -{ - var $u_action; - - function main($id, $mode) - { - global $config, $user, $template, $request; - global $phpbb_root_path, $phpEx, $phpbb_container; - - $user->add_lang('install'); - - $this->tpl_name = 'acp_update'; - $this->page_title = 'ACP_VERSION_CHECK'; - - /* @var $version_helper \phpbb\version_helper */ - $version_helper = $phpbb_container->get('version_helper'); - try - { - $recheck = $request->variable('versioncheck_force', false); - $updates_available = $version_helper->get_update_on_branch($recheck); - $upgrades_available = $version_helper->get_suggested_updates(); - if (!empty($upgrades_available)) - { - $upgrades_available = array_pop($upgrades_available); - } - } - catch (\RuntimeException $e) - { - $template->assign_var('S_VERSIONCHECK_FAIL', true); - - $updates_available = array(); - } - - if (!empty($updates_available)) - { - $template->assign_block_vars('updates_available', $updates_available); - } - - $update_link = $phpbb_root_path . 'install/app.' . $phpEx; - - $template_ary = [ - 'S_UP_TO_DATE' => empty($updates_available), - 'U_ACTION' => $this->u_action, - 'U_VERSIONCHECK_FORCE' => append_sid($this->u_action . '&versioncheck_force=1'), - - 'CURRENT_VERSION' => $config['version'], - - 'UPDATE_INSTRUCTIONS' => $user->lang('UPDATE_INSTRUCTIONS', $update_link), - 'S_VERSION_UPGRADEABLE' => !empty($upgrades_available), - 'UPGRADE_INSTRUCTIONS' => !empty($upgrades_available) ? $user->lang('UPGRADE_INSTRUCTIONS', $upgrades_available['current'], $upgrades_available['announcement']) : false, - ]; - - $template->assign_vars($template_ary); - - // Incomplete update? - if (phpbb_version_compare($config['version'], PHPBB_VERSION, '<')) - { - $database_update_link = $phpbb_root_path . 'install/app.php/update'; - - $template->assign_vars(array( - 'S_UPDATE_INCOMPLETE' => true, - 'FILES_VERSION' => PHPBB_VERSION, - 'INCOMPLETE_INSTRUCTIONS' => $user->lang('UPDATE_INCOMPLETE_EXPLAIN', $database_update_link), - )); - } - } -} diff --git a/install/update/new/includes/acp/acp_users.php b/install/update/new/includes/acp/acp_users.php deleted file mode 100644 index 6993c86..0000000 --- a/install/update/new/includes/acp/acp_users.php +++ /dev/null @@ -1,2689 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -class acp_users -{ - var $u_action; - var $p_master; - - function __construct($p_master) - { - $this->p_master = $p_master; - } - - function main($id, $mode) - { - global $config, $db, $user, $auth, $template; - global $phpbb_root_path, $phpbb_admin_path, $phpEx; - global $phpbb_dispatcher, $request; - global $phpbb_container, $phpbb_log; - - $user->add_lang(array('posting', 'ucp', 'acp/users')); - $this->tpl_name = 'acp_users'; - - $error = array(); - $username = $request->variable('username', '', true); - $user_id = $request->variable('u', 0); - $action = $request->variable('action', ''); - - // Get referer to redirect user to the appropriate page after delete action - $redirect = $request->variable('redirect', ''); - $redirect_tag = "redirect=$redirect"; - $redirect_url = append_sid("{$phpbb_admin_path}index.$phpEx", "i=$redirect"); - - $submit = (isset($_POST['update']) && !isset($_POST['cancel'])) ? true : false; - - $form_name = 'acp_users'; - add_form_key($form_name); - - // Whois (special case) - if ($action == 'whois') - { - if (!function_exists('user_get_id_name')) - { - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - } - - $this->page_title = 'WHOIS'; - $this->tpl_name = 'simple_body'; - - $user_ip = phpbb_ip_normalise($request->variable('user_ip', '')); - $domain = gethostbyaddr($user_ip); - $ipwhois = user_ipwhois($user_ip); - - $template->assign_vars(array( - 'MESSAGE_TITLE' => sprintf($user->lang['IP_WHOIS_FOR'], $domain), - 'MESSAGE_TEXT' => nl2br($ipwhois)) - ); - - return; - } - - // Show user selection mask - if (!$username && !$user_id) - { - $this->page_title = 'SELECT_USER'; - - $template->assign_vars(array( - 'U_ACTION' => $this->u_action, - 'ANONYMOUS_USER_ID' => ANONYMOUS, - - 'S_SELECT_USER' => true, - 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=select_user&field=username&select_single=true'), - )); - - return; - } - - if (!$user_id) - { - $sql = 'SELECT user_id - FROM ' . USERS_TABLE . " - WHERE username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'"; - $result = $db->sql_query($sql); - $user_id = (int) $db->sql_fetchfield('user_id'); - $db->sql_freeresult($result); - - if (!$user_id) - { - trigger_error($user->lang['NO_USER'] . adm_back_link($this->u_action), E_USER_WARNING); - } - } - - // Generate content for all modes - $sql = 'SELECT u.*, s.* - FROM ' . USERS_TABLE . ' u - LEFT JOIN ' . SESSIONS_TABLE . ' s ON (s.session_user_id = u.user_id) - WHERE u.user_id = ' . $user_id . ' - ORDER BY s.session_time DESC'; - $result = $db->sql_query_limit($sql, 1); - $user_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$user_row) - { - trigger_error($user->lang['NO_USER'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - // Generate overall "header" for user admin - $s_form_options = ''; - - // Build modes dropdown list - $sql = 'SELECT module_mode, module_auth - FROM ' . MODULES_TABLE . " - WHERE module_basename = 'acp_users' - AND module_enabled = 1 - AND module_class = 'acp' - ORDER BY left_id, module_mode"; - $result = $db->sql_query($sql); - - $dropdown_modes = array(); - while ($row = $db->sql_fetchrow($result)) - { - if (!$this->p_master->module_auth_self($row['module_auth'])) - { - continue; - } - - $dropdown_modes[$row['module_mode']] = true; - } - $db->sql_freeresult($result); - - foreach ($dropdown_modes as $module_mode => $null) - { - $selected = ($mode == $module_mode) ? ' selected="selected"' : ''; - $s_form_options .= ''; - } - - $template->assign_vars(array( - 'U_BACK' => (empty($redirect)) ? $this->u_action : $redirect_url, - 'U_MODE_SELECT' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=$id&u=$user_id"), - 'U_ACTION' => $this->u_action . '&u=' . $user_id . ((empty($redirect)) ? '' : '&' . $redirect_tag), - 'S_FORM_OPTIONS' => $s_form_options, - 'MANAGED_USERNAME' => $user_row['username']) - ); - - // Prevent normal users/admins change/view founders if they are not a founder by themselves - if ($user->data['user_type'] != USER_FOUNDER && $user_row['user_type'] == USER_FOUNDER) - { - trigger_error($user->lang['NOT_MANAGE_FOUNDER'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - $this->page_title = $user_row['username'] . ' :: ' . $user->lang('ACP_USER_' . strtoupper($mode)); - - switch ($mode) - { - case 'overview': - - if (!function_exists('user_get_id_name')) - { - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - } - - $user->add_lang('acp/ban'); - - $delete = $request->variable('delete', 0); - $delete_type = $request->variable('delete_type', ''); - $ip = $request->variable('ip', 'ip'); - - /** - * Run code at beginning of ACP users overview - * - * @event core.acp_users_overview_before - * @var array user_row Current user data - * @var string mode Active module - * @var string action Module that should be run - * @var bool submit Do we display the form only - * or did the user press submit - * @var array error Array holding error messages - * @since 3.1.3-RC1 - */ - $vars = array('user_row', 'mode', 'action', 'submit', 'error'); - extract($phpbb_dispatcher->trigger_event('core.acp_users_overview_before', compact($vars))); - - if ($submit) - { - if ($delete) - { - if (!$auth->acl_get('a_userdel')) - { - send_status_line(403, 'Forbidden'); - trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - // Check if the user wants to remove himself or the guest user account - if ($user_id == ANONYMOUS) - { - trigger_error($user->lang['CANNOT_REMOVE_ANONYMOUS'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - // Founders can not be deleted. - if ($user_row['user_type'] == USER_FOUNDER) - { - trigger_error($user->lang['CANNOT_REMOVE_FOUNDER'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - if ($user_id == $user->data['user_id']) - { - trigger_error($user->lang['CANNOT_REMOVE_YOURSELF'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - if ($delete_type) - { - if (confirm_box(true)) - { - user_delete($delete_type, $user_id, $user_row['username']); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_DELETED', false, array($user_row['username'])); - trigger_error($user->lang['USER_DELETED'] . adm_back_link( - (empty($redirect)) ? $this->u_action : $redirect_url - ) - ); - } - else - { - $delete_confirm_hidden_fields = array( - 'u' => $user_id, - 'i' => $id, - 'mode' => $mode, - 'action' => $action, - 'update' => true, - 'delete' => 1, - 'delete_type' => $delete_type, - ); - - // Checks if the redirection page is specified - if (!empty($redirect)) - { - $delete_confirm_hidden_fields['redirect'] = $redirect; - } - - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields($delete_confirm_hidden_fields)); - } - } - else - { - trigger_error($user->lang['NO_MODE'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - } - - // Handle quicktool actions - switch ($action) - { - case 'banuser': - case 'banemail': - case 'banip': - - if ($user_id == $user->data['user_id']) - { - trigger_error($user->lang['CANNOT_BAN_YOURSELF'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - if ($user_id == ANONYMOUS) - { - trigger_error($user->lang['CANNOT_BAN_ANONYMOUS'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - if ($user_row['user_type'] == USER_FOUNDER) - { - trigger_error($user->lang['CANNOT_BAN_FOUNDER'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - if (!check_form_key($form_name)) - { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - $ban = array(); - - switch ($action) - { - case 'banuser': - $ban[] = $user_row['username']; - $reason = 'USER_ADMIN_BAN_NAME_REASON'; - break; - - case 'banemail': - $ban[] = $user_row['user_email']; - $reason = 'USER_ADMIN_BAN_EMAIL_REASON'; - break; - - case 'banip': - $ban[] = $user_row['user_ip']; - - $sql = 'SELECT DISTINCT poster_ip - FROM ' . POSTS_TABLE . " - WHERE poster_id = $user_id"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $ban[] = $row['poster_ip']; - } - $db->sql_freeresult($result); - - $reason = 'USER_ADMIN_BAN_IP_REASON'; - break; - } - - $ban_reason = $request->variable('ban_reason', $user->lang[$reason], true); - $ban_give_reason = $request->variable('ban_give_reason', '', true); - - // Log not used at the moment, we simply utilize the ban function. - $result = user_ban(substr($action, 3), $ban, 0, 0, 0, $ban_reason, $ban_give_reason); - - trigger_error((($result === false) ? $user->lang['BAN_ALREADY_ENTERED'] : $user->lang['BAN_SUCCESSFUL']) . adm_back_link($this->u_action . '&u=' . $user_id)); - - break; - - case 'reactivate': - - if ($user_id == $user->data['user_id']) - { - trigger_error($user->lang['CANNOT_FORCE_REACT_YOURSELF'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - if (!check_form_key($form_name)) - { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - if ($user_row['user_type'] == USER_FOUNDER) - { - trigger_error($user->lang['CANNOT_FORCE_REACT_FOUNDER'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - if ($user_row['user_type'] == USER_IGNORE) - { - trigger_error($user->lang['CANNOT_FORCE_REACT_BOT'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - if ($config['email_enable']) - { - if (!class_exists('messenger')) - { - include($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); - } - - $server_url = generate_board_url(); - - $user_actkey = gen_rand_string(mt_rand(6, 10)); - $email_template = ($user_row['user_type'] == USER_NORMAL) ? 'user_reactivate_account' : 'user_resend_inactive'; - - if ($user_row['user_type'] == USER_NORMAL) - { - user_active_flip('deactivate', $user_id, INACTIVE_REMIND); - } - else - { - // Grabbing the last confirm key - we only send a reminder - $sql = 'SELECT user_actkey - FROM ' . USERS_TABLE . ' - WHERE user_id = ' . $user_id; - $result = $db->sql_query($sql); - $user_activation_key = (string) $db->sql_fetchfield('user_actkey'); - $db->sql_freeresult($result); - - $user_actkey = empty($user_activation_key) ? $user_actkey : $user_activation_key; - } - - if ($user_row['user_type'] == USER_NORMAL || empty($user_activation_key)) - { - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_actkey = '" . $db->sql_escape($user_actkey) . "' - WHERE user_id = $user_id"; - $db->sql_query($sql); - } - - $messenger = new messenger(false); - - $messenger->template($email_template, $user_row['user_lang']); - - $messenger->set_addresses($user_row); - - $messenger->anti_abuse_headers($config, $user); - - $messenger->assign_vars(array( - 'WELCOME_MSG' => htmlspecialchars_decode(sprintf($user->lang['WELCOME_SUBJECT'], $config['sitename'])), - 'USERNAME' => htmlspecialchars_decode($user_row['username']), - 'U_ACTIVATE' => "$server_url/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k=$user_actkey") - ); - - $messenger->send(NOTIFY_EMAIL); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_REACTIVATE', false, array($user_row['username'])); - $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_REACTIVATE_USER', false, array( - 'reportee_id' => $user_id - )); - - trigger_error($user->lang['FORCE_REACTIVATION_SUCCESS'] . adm_back_link($this->u_action . '&u=' . $user_id)); - } - - break; - - case 'active': - - if ($user_id == $user->data['user_id']) - { - // It is only deactivation since the user is already activated (else he would not have reached this page) - trigger_error($user->lang['CANNOT_DEACTIVATE_YOURSELF'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - if (!check_form_key($form_name)) - { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - if ($user_row['user_type'] == USER_FOUNDER) - { - trigger_error($user->lang['CANNOT_DEACTIVATE_FOUNDER'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - if ($user_row['user_type'] == USER_IGNORE) - { - trigger_error($user->lang['CANNOT_DEACTIVATE_BOT'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - user_active_flip('flip', $user_id); - - if ($user_row['user_type'] == USER_INACTIVE) - { - if ($config['require_activation'] == USER_ACTIVATION_ADMIN) - { - /* @var $phpbb_notifications \phpbb\notification\manager */ - $phpbb_notifications = $phpbb_container->get('notification_manager'); - $phpbb_notifications->delete_notifications('notification.type.admin_activate_user', $user_row['user_id']); - - if (!class_exists('messenger')) - { - include($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); - } - - $messenger = new messenger(false); - - $messenger->template('admin_welcome_activated', $user_row['user_lang']); - - $messenger->set_addresses($user_row); - - $messenger->anti_abuse_headers($config, $user); - - $messenger->assign_vars(array( - 'USERNAME' => htmlspecialchars_decode($user_row['username'])) - ); - - $messenger->send(NOTIFY_EMAIL); - } - } - - $message = ($user_row['user_type'] == USER_INACTIVE) ? 'USER_ADMIN_ACTIVATED' : 'USER_ADMIN_DEACTIVED'; - $log = ($user_row['user_type'] == USER_INACTIVE) ? 'LOG_USER_ACTIVE' : 'LOG_USER_INACTIVE'; - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, $log, false, array($user_row['username'])); - $phpbb_log->add('user', $user->data['user_id'], $user->ip, $log . '_USER', false, array( - 'reportee_id' => $user_id - )); - - trigger_error($user->lang[$message] . adm_back_link($this->u_action . '&u=' . $user_id)); - - break; - - case 'delsig': - - if (!check_form_key($form_name)) - { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - $sql_ary = array( - 'user_sig' => '', - 'user_sig_bbcode_uid' => '', - 'user_sig_bbcode_bitfield' => '' - ); - - $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " - WHERE user_id = $user_id"; - $db->sql_query($sql); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_DEL_SIG', false, array($user_row['username'])); - $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_DEL_SIG_USER', false, array( - 'reportee_id' => $user_id - )); - - trigger_error($user->lang['USER_ADMIN_SIG_REMOVED'] . adm_back_link($this->u_action . '&u=' . $user_id)); - - break; - - case 'delavatar': - - if (!check_form_key($form_name)) - { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - // Delete old avatar if present - /* @var $phpbb_avatar_manager \phpbb\avatar\manager */ - $phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); - $phpbb_avatar_manager->handle_avatar_delete($db, $user, $phpbb_avatar_manager->clean_row($user_row, 'user'), USERS_TABLE, 'user_'); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_DEL_AVATAR', false, array($user_row['username'])); - $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_DEL_AVATAR_USER', false, array( - 'reportee_id' => $user_id - )); - - trigger_error($user->lang['USER_ADMIN_AVATAR_REMOVED'] . adm_back_link($this->u_action . '&u=' . $user_id)); - break; - - case 'delposts': - - if (confirm_box(true)) - { - // Delete posts, attachments, etc. - delete_posts('poster_id', $user_id); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_DEL_POSTS', false, array($user_row['username'])); - trigger_error($user->lang['USER_POSTS_DELETED'] . adm_back_link($this->u_action . '&u=' . $user_id)); - } - else - { - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( - 'u' => $user_id, - 'i' => $id, - 'mode' => $mode, - 'action' => $action, - 'update' => true)) - ); - } - - break; - - case 'delattach': - - if (confirm_box(true)) - { - /** @var \phpbb\attachment\manager $attachment_manager */ - $attachment_manager = $phpbb_container->get('attachment.manager'); - $attachment_manager->delete('user', $user_id); - unset($attachment_manager); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_DEL_ATTACH', false, array($user_row['username'])); - trigger_error($user->lang['USER_ATTACHMENTS_REMOVED'] . adm_back_link($this->u_action . '&u=' . $user_id)); - } - else - { - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( - 'u' => $user_id, - 'i' => $id, - 'mode' => $mode, - 'action' => $action, - 'update' => true)) - ); - } - - break; - - case 'deloutbox': - - if (confirm_box(true)) - { - $msg_ids = array(); - $lang = 'EMPTY'; - - $sql = 'SELECT msg_id - FROM ' . PRIVMSGS_TO_TABLE . " - WHERE author_id = $user_id - AND folder_id = " . PRIVMSGS_OUTBOX; - $result = $db->sql_query($sql); - - if ($row = $db->sql_fetchrow($result)) - { - if (!function_exists('delete_pm')) - { - include($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx); - } - - do - { - $msg_ids[] = (int) $row['msg_id']; - } - while ($row = $db->sql_fetchrow($result)); - - $db->sql_freeresult($result); - - delete_pm($user_id, $msg_ids, PRIVMSGS_OUTBOX); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_DEL_OUTBOX', false, array($user_row['username'])); - - $lang = 'EMPTIED'; - } - $db->sql_freeresult($result); - - trigger_error($user->lang['USER_OUTBOX_' . $lang] . adm_back_link($this->u_action . '&u=' . $user_id)); - } - else - { - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( - 'u' => $user_id, - 'i' => $id, - 'mode' => $mode, - 'action' => $action, - 'update' => true)) - ); - } - break; - - case 'moveposts': - - if (!check_form_key($form_name)) - { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - $user->add_lang('acp/forums'); - - $new_forum_id = $request->variable('new_f', 0); - - if (!$new_forum_id) - { - $this->page_title = 'USER_ADMIN_MOVE_POSTS'; - - $template->assign_vars(array( - 'S_SELECT_FORUM' => true, - 'U_ACTION' => $this->u_action . "&action=$action&u=$user_id", - 'U_BACK' => $this->u_action . "&u=$user_id", - 'S_FORUM_OPTIONS' => make_forum_select(false, false, false, true)) - ); - - return; - } - - // Is the new forum postable to? - $sql = 'SELECT forum_name, forum_type - FROM ' . FORUMS_TABLE . " - WHERE forum_id = $new_forum_id"; - $result = $db->sql_query($sql); - $forum_info = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$forum_info) - { - trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - if ($forum_info['forum_type'] != FORUM_POST) - { - trigger_error($user->lang['MOVE_POSTS_NO_POSTABLE_FORUM'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - // Two stage? - // Move topics comprising only posts from this user - $topic_id_ary = $move_topic_ary = $move_post_ary = $new_topic_id_ary = array(); - $forum_id_ary = array($new_forum_id); - - $sql = 'SELECT topic_id, post_visibility, COUNT(post_id) AS total_posts - FROM ' . POSTS_TABLE . " - WHERE poster_id = $user_id - AND forum_id <> $new_forum_id - GROUP BY topic_id, post_visibility"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $topic_id_ary[$row['topic_id']][$row['post_visibility']] = $row['total_posts']; - } - $db->sql_freeresult($result); - - if (count($topic_id_ary)) - { - $sql = 'SELECT topic_id, forum_id, topic_title, topic_posts_approved, topic_posts_unapproved, topic_posts_softdeleted, topic_attachment - FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', array_keys($topic_id_ary)); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if ($topic_id_ary[$row['topic_id']][ITEM_APPROVED] == $row['topic_posts_approved'] - && $topic_id_ary[$row['topic_id']][ITEM_UNAPPROVED] == $row['topic_posts_unapproved'] - && $topic_id_ary[$row['topic_id']][ITEM_REAPPROVE] == $row['topic_posts_unapproved'] - && $topic_id_ary[$row['topic_id']][ITEM_DELETED] == $row['topic_posts_softdeleted']) - { - $move_topic_ary[] = $row['topic_id']; - } - else - { - $move_post_ary[$row['topic_id']]['title'] = $row['topic_title']; - $move_post_ary[$row['topic_id']]['attach'] = ($row['topic_attachment']) ? 1 : 0; - } - - $forum_id_ary[] = $row['forum_id']; - } - $db->sql_freeresult($result); - } - - // Entire topic comprises posts by this user, move these topics - if (count($move_topic_ary)) - { - move_topics($move_topic_ary, $new_forum_id, false); - } - - if (count($move_post_ary)) - { - // Create new topic - // Update post_ids, report_ids, attachment_ids - foreach ($move_post_ary as $topic_id => $post_ary) - { - // Create new topic - $sql = 'INSERT INTO ' . TOPICS_TABLE . ' ' . $db->sql_build_array('INSERT', array( - 'topic_poster' => $user_id, - 'topic_time' => time(), - 'forum_id' => $new_forum_id, - 'icon_id' => 0, - 'topic_visibility' => ITEM_APPROVED, - 'topic_title' => $post_ary['title'], - 'topic_first_poster_name' => $user_row['username'], - 'topic_type' => POST_NORMAL, - 'topic_time_limit' => 0, - 'topic_attachment' => $post_ary['attach']) - ); - $db->sql_query($sql); - - $new_topic_id = $db->sql_nextid(); - - // Move posts - $sql = 'UPDATE ' . POSTS_TABLE . " - SET forum_id = $new_forum_id, topic_id = $new_topic_id - WHERE topic_id = $topic_id - AND poster_id = $user_id"; - $db->sql_query($sql); - - if ($post_ary['attach']) - { - $sql = 'UPDATE ' . ATTACHMENTS_TABLE . " - SET topic_id = $new_topic_id - WHERE topic_id = $topic_id - AND poster_id = $user_id"; - $db->sql_query($sql); - } - - $new_topic_id_ary[] = $new_topic_id; - } - } - - $forum_id_ary = array_unique($forum_id_ary); - $topic_id_ary = array_unique(array_merge(array_keys($topic_id_ary), $new_topic_id_ary)); - - if (count($topic_id_ary)) - { - sync('topic_reported', 'topic_id', $topic_id_ary); - sync('topic', 'topic_id', $topic_id_ary); - } - - if (count($forum_id_ary)) - { - sync('forum', 'forum_id', $forum_id_ary, false, true); - } - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_MOVE_POSTS', false, array($user_row['username'], $forum_info['forum_name'])); - $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_MOVE_POSTS_USER', false, array( - 'reportee_id' => $user_id, - $forum_info['forum_name'] - )); - - trigger_error($user->lang['USER_POSTS_MOVED'] . adm_back_link($this->u_action . '&u=' . $user_id)); - - break; - - case 'leave_nr': - - if (confirm_box(true)) - { - remove_newly_registered($user_id, $user_row); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_REMOVED_NR', false, array($user_row['username'])); - trigger_error($user->lang['USER_LIFTED_NR'] . adm_back_link($this->u_action . '&u=' . $user_id)); - } - else - { - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( - 'u' => $user_id, - 'i' => $id, - 'mode' => $mode, - 'action' => $action, - 'update' => true)) - ); - } - - break; - - default: - $u_action = $this->u_action; - - /** - * Run custom quicktool code - * - * @event core.acp_users_overview_run_quicktool - * @var string action Quick tool that should be run - * @var array user_row Current user data - * @var string u_action The u_action link - * @since 3.1.0-a1 - * @changed 3.2.2-RC1 Added u_action - */ - $vars = array('action', 'user_row', 'u_action'); - extract($phpbb_dispatcher->trigger_event('core.acp_users_overview_run_quicktool', compact($vars))); - - unset($u_action); - break; - } - - // Handle registration info updates - $data = array( - 'username' => $request->variable('user', $user_row['username'], true), - 'user_founder' => $request->variable('user_founder', ($user_row['user_type'] == USER_FOUNDER) ? 1 : 0), - 'email' => strtolower($request->variable('user_email', $user_row['user_email'])), - 'new_password' => $request->variable('new_password', '', true), - 'password_confirm' => $request->variable('password_confirm', '', true), - ); - - // Validation data - we do not check the password complexity setting here - $check_ary = array( - 'new_password' => array( - array('string', true, $config['min_pass_chars'], 0), - array('password')), - 'password_confirm' => array('string', true, $config['min_pass_chars'], 0), - ); - - // Check username if altered - if ($data['username'] != $user_row['username']) - { - $check_ary += array( - 'username' => array( - array('string', false, $config['min_name_chars'], $config['max_name_chars']), - array('username', $user_row['username'], true) - ), - ); - } - - // Check email if altered - if ($data['email'] != $user_row['user_email']) - { - $check_ary += array( - 'email' => array( - array('string', false, 6, 60), - array('user_email', $user_row['user_email']), - ), - ); - } - - $error = validate_data($data, $check_ary); - - if ($data['new_password'] && $data['password_confirm'] != $data['new_password']) - { - $error[] = 'NEW_PASSWORD_ERROR'; - } - - if (!check_form_key($form_name)) - { - $error[] = 'FORM_INVALID'; - } - - // Instantiate passwords manager - /* @var $passwords_manager \phpbb\passwords\manager */ - $passwords_manager = $phpbb_container->get('passwords.manager'); - - // Which updates do we need to do? - $update_username = ($user_row['username'] != $data['username']) ? $data['username'] : false; - $update_password = $data['new_password'] && !$passwords_manager->check($data['new_password'], $user_row['user_password']); - $update_email = ($data['email'] != $user_row['user_email']) ? $data['email'] : false; - - if (!count($error)) - { - $sql_ary = array(); - - if ($user_row['user_type'] != USER_FOUNDER || $user->data['user_type'] == USER_FOUNDER) - { - // Only allow founders updating the founder status... - if ($user->data['user_type'] == USER_FOUNDER) - { - // Setting a normal member to be a founder - if ($data['user_founder'] && $user_row['user_type'] != USER_FOUNDER) - { - // Make sure the user is not setting an Inactive or ignored user to be a founder - if ($user_row['user_type'] == USER_IGNORE) - { - trigger_error($user->lang['CANNOT_SET_FOUNDER_IGNORED'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - if ($user_row['user_type'] == USER_INACTIVE) - { - trigger_error($user->lang['CANNOT_SET_FOUNDER_INACTIVE'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - $sql_ary['user_type'] = USER_FOUNDER; - } - else if (!$data['user_founder'] && $user_row['user_type'] == USER_FOUNDER) - { - // Check if at least one founder is present - $sql = 'SELECT user_id - FROM ' . USERS_TABLE . ' - WHERE user_type = ' . USER_FOUNDER . ' - AND user_id <> ' . $user_id; - $result = $db->sql_query_limit($sql, 1); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - $sql_ary['user_type'] = USER_NORMAL; - } - else - { - trigger_error($user->lang['AT_LEAST_ONE_FOUNDER'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - } - } - } - - /** - * Modify user data before we update it - * - * @event core.acp_users_overview_modify_data - * @var array user_row Current user data - * @var array data Submitted user data - * @var array sql_ary User data we udpate - * @since 3.1.0-a1 - */ - $vars = array('user_row', 'data', 'sql_ary'); - extract($phpbb_dispatcher->trigger_event('core.acp_users_overview_modify_data', compact($vars))); - - if ($update_username !== false) - { - $sql_ary['username'] = $update_username; - $sql_ary['username_clean'] = utf8_clean_string($update_username); - - $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_UPDATE_NAME', false, array( - 'reportee_id' => $user_id, - $user_row['username'], - $update_username - )); - } - - if ($update_email !== false) - { - $sql_ary += ['user_email' => $update_email]; - - $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_UPDATE_EMAIL', false, array( - 'reportee_id' => $user_id, - $user_row['username'], - $user_row['user_email'], - $update_email - )); - } - - if ($update_password) - { - $sql_ary += array( - 'user_password' => $passwords_manager->hash($data['new_password']), - 'user_passchg' => time(), - ); - - $user->reset_login_keys($user_id); - - $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_NEW_PASSWORD', false, array( - 'reportee_id' => $user_id, - $user_row['username'] - )); - } - - if (count($sql_ary)) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE user_id = ' . $user_id; - $db->sql_query($sql); - } - - if ($update_username) - { - user_update_name($user_row['username'], $update_username); - } - - // Let the users permissions being updated - $auth->acl_clear_prefetch($user_id); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_USER_UPDATE', false, array($data['username'])); - - trigger_error($user->lang['USER_OVERVIEW_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); - } - - // Replace "error" strings with their real, localised form - $error = array_map(array($user, 'lang'), $error); - } - - if ($user_id == $user->data['user_id']) - { - $quick_tool_ary = array('delsig' => 'DEL_SIG', 'delavatar' => 'DEL_AVATAR', 'moveposts' => 'MOVE_POSTS', 'delposts' => 'DEL_POSTS', 'delattach' => 'DEL_ATTACH', 'deloutbox' => 'DEL_OUTBOX'); - if ($user_row['user_new']) - { - $quick_tool_ary['leave_nr'] = 'LEAVE_NR'; - } - } - else - { - $quick_tool_ary = array(); - - if ($user_row['user_type'] != USER_FOUNDER) - { - $quick_tool_ary += array('banuser' => 'BAN_USER', 'banemail' => 'BAN_EMAIL', 'banip' => 'BAN_IP'); - } - - if ($user_row['user_type'] != USER_FOUNDER && $user_row['user_type'] != USER_IGNORE) - { - $quick_tool_ary += array('active' => (($user_row['user_type'] == USER_INACTIVE) ? 'ACTIVATE' : 'DEACTIVATE')); - } - - $quick_tool_ary += array('delsig' => 'DEL_SIG', 'delavatar' => 'DEL_AVATAR', 'moveposts' => 'MOVE_POSTS', 'delposts' => 'DEL_POSTS', 'delattach' => 'DEL_ATTACH', 'deloutbox' => 'DEL_OUTBOX'); - - if ($config['email_enable'] && ($user_row['user_type'] == USER_NORMAL || $user_row['user_type'] == USER_INACTIVE)) - { - $quick_tool_ary['reactivate'] = 'FORCE'; - } - - if ($user_row['user_new']) - { - $quick_tool_ary['leave_nr'] = 'LEAVE_NR'; - } - } - - if ($config['load_onlinetrack']) - { - $sql = 'SELECT MAX(session_time) AS session_time, MIN(session_viewonline) AS session_viewonline - FROM ' . SESSIONS_TABLE . " - WHERE session_user_id = $user_id"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $user_row['session_time'] = (isset($row['session_time'])) ? $row['session_time'] : 0; - $user_row['session_viewonline'] = (isset($row['session_viewonline'])) ? $row['session_viewonline'] : 0; - unset($row); - } - - /** - * Add additional quick tool options and overwrite user data - * - * @event core.acp_users_display_overview - * @var array user_row Array with user data - * @var array quick_tool_ary Ouick tool options - * @since 3.1.0-a1 - */ - $vars = array('user_row', 'quick_tool_ary'); - extract($phpbb_dispatcher->trigger_event('core.acp_users_display_overview', compact($vars))); - - $s_action_options = ''; - foreach ($quick_tool_ary as $value => $lang) - { - $s_action_options .= ''; - } - - $last_active = (!empty($user_row['session_time'])) ? $user_row['session_time'] : $user_row['user_lastvisit']; - - $inactive_reason = ''; - if ($user_row['user_type'] == USER_INACTIVE) - { - $inactive_reason = $user->lang['INACTIVE_REASON_UNKNOWN']; - - switch ($user_row['user_inactive_reason']) - { - case INACTIVE_REGISTER: - $inactive_reason = $user->lang['INACTIVE_REASON_REGISTER']; - break; - - case INACTIVE_PROFILE: - $inactive_reason = $user->lang['INACTIVE_REASON_PROFILE']; - break; - - case INACTIVE_MANUAL: - $inactive_reason = $user->lang['INACTIVE_REASON_MANUAL']; - break; - - case INACTIVE_REMIND: - $inactive_reason = $user->lang['INACTIVE_REASON_REMIND']; - break; - } - } - - // Posts in Queue - $sql = 'SELECT COUNT(post_id) as posts_in_queue - FROM ' . POSTS_TABLE . ' - WHERE poster_id = ' . $user_id . ' - AND ' . $db->sql_in_set('post_visibility', array(ITEM_UNAPPROVED, ITEM_REAPPROVE)); - $result = $db->sql_query($sql); - $user_row['posts_in_queue'] = (int) $db->sql_fetchfield('posts_in_queue'); - $db->sql_freeresult($result); - - $sql = 'SELECT post_id - FROM ' . POSTS_TABLE . ' - WHERE poster_id = '. $user_id; - $result = $db->sql_query_limit($sql, 1); - $user_row['user_has_posts'] = (bool) $db->sql_fetchfield('post_id'); - $db->sql_freeresult($result); - - $template->assign_vars(array( - 'L_NAME_CHARS_EXPLAIN' => $user->lang($config['allow_name_chars'] . '_EXPLAIN', $user->lang('CHARACTERS', (int) $config['min_name_chars']), $user->lang('CHARACTERS', (int) $config['max_name_chars'])), - 'L_CHANGE_PASSWORD_EXPLAIN' => $user->lang($config['pass_complex'] . '_EXPLAIN', $user->lang('CHARACTERS', (int) $config['min_pass_chars'])), - 'L_POSTS_IN_QUEUE' => $user->lang('NUM_POSTS_IN_QUEUE', $user_row['posts_in_queue']), - 'S_FOUNDER' => ($user->data['user_type'] == USER_FOUNDER) ? true : false, - - 'S_OVERVIEW' => true, - 'S_USER_IP' => ($user_row['user_ip']) ? true : false, - 'S_USER_FOUNDER' => ($user_row['user_type'] == USER_FOUNDER) ? true : false, - 'S_ACTION_OPTIONS' => $s_action_options, - 'S_OWN_ACCOUNT' => ($user_id == $user->data['user_id']) ? true : false, - 'S_USER_INACTIVE' => ($user_row['user_type'] == USER_INACTIVE) ? true : false, - - 'U_SHOW_IP' => $this->u_action . "&u=$user_id&ip=" . (($ip == 'ip') ? 'hostname' : 'ip'), - 'U_WHOIS' => $this->u_action . "&action=whois&user_ip={$user_row['user_ip']}", - 'U_MCP_QUEUE' => ($auth->acl_getf_global('m_approve')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue', true, $user->session_id) : '', - 'U_SEARCH_USER' => ($config['load_search'] && $auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id={$user_row['user_id']}&sr=posts") : '', - - 'U_SWITCH_PERMISSIONS' => ($auth->acl_get('a_switchperm') && $user->data['user_id'] != $user_row['user_id']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", "mode=switch_perm&u={$user_row['user_id']}&hash=" . generate_link_hash('switchperm')) : '', - - 'POSTS_IN_QUEUE' => $user_row['posts_in_queue'], - 'USER' => $user_row['username'], - 'USER_REGISTERED' => $user->format_date($user_row['user_regdate']), - 'REGISTERED_IP' => ($ip == 'hostname') ? gethostbyaddr($user_row['user_ip']) : $user_row['user_ip'], - 'USER_LASTACTIVE' => ($last_active) ? $user->format_date($last_active) : ' - ', - 'USER_EMAIL' => $user_row['user_email'], - 'USER_WARNINGS' => $user_row['user_warnings'], - 'USER_POSTS' => $user_row['user_posts'], - 'USER_HAS_POSTS' => $user_row['user_has_posts'], - 'USER_INACTIVE_REASON' => $inactive_reason, - )); - - break; - - case 'feedback': - - $user->add_lang('mcp'); - - // Set up general vars - $start = $request->variable('start', 0); - $deletemark = (isset($_POST['delmarked'])) ? true : false; - $deleteall = (isset($_POST['delall'])) ? true : false; - $marked = $request->variable('mark', array(0)); - $message = $request->variable('message', '', true); - - /* @var $pagination \phpbb\pagination */ - $pagination = $phpbb_container->get('pagination'); - - // Sort keys - $sort_days = $request->variable('st', 0); - $sort_key = $request->variable('sk', 't'); - $sort_dir = $request->variable('sd', 'd'); - - // Delete entries if requested and able - if (($deletemark || $deleteall) && $auth->acl_get('a_clearlogs')) - { - if (!check_form_key($form_name)) - { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - $where_sql = ''; - if ($deletemark && $marked) - { - $sql_in = array(); - foreach ($marked as $mark) - { - $sql_in[] = $mark; - } - $where_sql = ' AND ' . $db->sql_in_set('log_id', $sql_in); - unset($sql_in); - } - - if ($where_sql || $deleteall) - { - $sql = 'DELETE FROM ' . LOG_TABLE . ' - WHERE log_type = ' . LOG_USERS . " - AND reportee_id = $user_id - $where_sql"; - $db->sql_query($sql); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_CLEAR_USER', false, array($user_row['username'])); - } - } - - if ($submit && $message) - { - if (!check_form_key($form_name)) - { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_FEEDBACK', false, array($user_row['username'])); - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_USER_FEEDBACK', false, array( - 'forum_id' => 0, - 'topic_id' => 0, - $user_row['username'] - )); - $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_GENERAL', false, array( - 'reportee_id' => $user_id, - $message - )); - - trigger_error($user->lang['USER_FEEDBACK_ADDED'] . adm_back_link($this->u_action . '&u=' . $user_id)); - } - - // Sorting - $limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); - $sort_by_text = array('u' => $user->lang['SORT_USERNAME'], 't' => $user->lang['SORT_DATE'], 'i' => $user->lang['SORT_IP'], 'o' => $user->lang['SORT_ACTION']); - $sort_by_sql = array('u' => 'u.username_clean', 't' => 'l.log_time', 'i' => 'l.log_ip', 'o' => 'l.log_operation'); - - $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; - gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); - - // Define where and sort sql for use in displaying logs - $sql_where = ($sort_days) ? (time() - ($sort_days * 86400)) : 0; - $sql_sort = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'); - - // Grab log data - $log_data = array(); - $log_count = 0; - $start = view_log('user', $log_data, $log_count, $config['topics_per_page'], $start, 0, 0, $user_id, $sql_where, $sql_sort); - - $base_url = $this->u_action . "&u=$user_id&$u_sort_param"; - $pagination->generate_template_pagination($base_url, 'pagination', 'start', $log_count, $config['topics_per_page'], $start); - - $template->assign_vars(array( - 'S_FEEDBACK' => true, - - 'S_LIMIT_DAYS' => $s_limit_days, - 'S_SORT_KEY' => $s_sort_key, - 'S_SORT_DIR' => $s_sort_dir, - 'S_CLEARLOGS' => $auth->acl_get('a_clearlogs')) - ); - - foreach ($log_data as $row) - { - $template->assign_block_vars('log', array( - 'USERNAME' => $row['username_full'], - 'IP' => $row['ip'], - 'DATE' => $user->format_date($row['time']), - 'ACTION' => nl2br($row['action']), - 'ID' => $row['id']) - ); - } - - break; - - case 'warnings': - $user->add_lang('mcp'); - - // Set up general vars - $deletemark = (isset($_POST['delmarked'])) ? true : false; - $deleteall = (isset($_POST['delall'])) ? true : false; - $confirm = (isset($_POST['confirm'])) ? true : false; - $marked = $request->variable('mark', array(0)); - - // Delete entries if requested and able - if ($deletemark || $deleteall || $confirm) - { - if (confirm_box(true)) - { - $where_sql = ''; - $deletemark = $request->variable('delmarked', 0); - $deleteall = $request->variable('delall', 0); - if ($deletemark && $marked) - { - $where_sql = ' AND ' . $db->sql_in_set('warning_id', array_values($marked)); - } - - if ($where_sql || $deleteall) - { - $sql = 'DELETE FROM ' . WARNINGS_TABLE . " - WHERE user_id = $user_id - $where_sql"; - $db->sql_query($sql); - - if ($deleteall) - { - $log_warnings = $deleted_warnings = 0; - } - else - { - $num_warnings = (int) $db->sql_affectedrows(); - $deleted_warnings = ' user_warnings - ' . $num_warnings; - $log_warnings = ($num_warnings > 2) ? 2 : $num_warnings; - } - - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_warnings = $deleted_warnings - WHERE user_id = $user_id"; - $db->sql_query($sql); - - if ($log_warnings) - { - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_WARNINGS_DELETED', false, array($user_row['username'], $num_warnings)); - } - else - { - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_WARNINGS_DELETED_ALL', false, array($user_row['username'])); - } - } - } - else - { - $s_hidden_fields = array( - 'i' => $id, - 'mode' => $mode, - 'u' => $user_id, - 'mark' => $marked, - ); - if (isset($_POST['delmarked'])) - { - $s_hidden_fields['delmarked'] = 1; - } - if (isset($_POST['delall'])) - { - $s_hidden_fields['delall'] = 1; - } - if (isset($_POST['delall']) || (isset($_POST['delmarked']) && count($marked))) - { - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields($s_hidden_fields)); - } - } - } - - $sql = 'SELECT w.warning_id, w.warning_time, w.post_id, l.log_operation, l.log_data, l.user_id AS mod_user_id, m.username AS mod_username, m.user_colour AS mod_user_colour - FROM ' . WARNINGS_TABLE . ' w - LEFT JOIN ' . LOG_TABLE . ' l - ON (w.log_id = l.log_id) - LEFT JOIN ' . USERS_TABLE . ' m - ON (l.user_id = m.user_id) - WHERE w.user_id = ' . $user_id . ' - ORDER BY w.warning_time DESC'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if (!$row['log_operation']) - { - // We do not have a log-entry anymore, so there is no data available - $row['action'] = $user->lang['USER_WARNING_LOG_DELETED']; - } - else - { - $row['action'] = (isset($user->lang[$row['log_operation']])) ? $user->lang[$row['log_operation']] : '{' . ucfirst(str_replace('_', ' ', $row['log_operation'])) . '}'; - if (!empty($row['log_data'])) - { - $log_data_ary = @unserialize($row['log_data']); - $log_data_ary = ($log_data_ary === false) ? array() : $log_data_ary; - - if (isset($user->lang[$row['log_operation']])) - { - // Check if there are more occurrences of % than arguments, if there are we fill out the arguments array - // It doesn't matter if we add more arguments than placeholders - if ((substr_count($row['action'], '%') - count($log_data_ary)) > 0) - { - $log_data_ary = array_merge($log_data_ary, array_fill(0, substr_count($row['action'], '%') - count($log_data_ary), '')); - } - $row['action'] = vsprintf($row['action'], $log_data_ary); - $row['action'] = bbcode_nl2br(censor_text($row['action'])); - } - else if (!empty($log_data_ary)) - { - $row['action'] .= '
' . implode('', $log_data_ary); - } - } - } - - $template->assign_block_vars('warn', array( - 'ID' => $row['warning_id'], - 'USERNAME' => ($row['log_operation']) ? get_username_string('full', $row['mod_user_id'], $row['mod_username'], $row['mod_user_colour']) : '-', - 'ACTION' => make_clickable($row['action']), - 'DATE' => $user->format_date($row['warning_time']), - )); - } - $db->sql_freeresult($result); - - $template->assign_vars(array( - 'S_WARNINGS' => true, - )); - - break; - - case 'profile': - - if (!function_exists('user_get_id_name')) - { - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - } - - /* @var $cp \phpbb\profilefields\manager */ - $cp = $phpbb_container->get('profilefields.manager'); - - $cp_data = $cp_error = array(); - - $sql = 'SELECT lang_id - FROM ' . LANG_TABLE . " - WHERE lang_iso = '" . $db->sql_escape($user->data['user_lang']) . "'"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $user_row['iso_lang_id'] = $row['lang_id']; - - $data = array( - 'jabber' => $request->variable('jabber', $user_row['user_jabber'], true), - 'bday_day' => 0, - 'bday_month' => 0, - 'bday_year' => 0, - ); - - if ($user_row['user_birthday']) - { - list($data['bday_day'], $data['bday_month'], $data['bday_year']) = explode('-', $user_row['user_birthday']); - } - - $data['bday_day'] = $request->variable('bday_day', $data['bday_day']); - $data['bday_month'] = $request->variable('bday_month', $data['bday_month']); - $data['bday_year'] = $request->variable('bday_year', $data['bday_year']); - $data['user_birthday'] = sprintf('%2d-%2d-%4d', $data['bday_day'], $data['bday_month'], $data['bday_year']); - - /** - * Modify user data on editing profile in ACP - * - * @event core.acp_users_modify_profile - * @var array data Array with user profile data - * @var bool submit Flag indicating if submit button has been pressed - * @var int user_id The user id - * @var array user_row Array with the full user data - * @since 3.1.4-RC1 - */ - $vars = array('data', 'submit', 'user_id', 'user_row'); - extract($phpbb_dispatcher->trigger_event('core.acp_users_modify_profile', compact($vars))); - - if ($submit) - { - $error = validate_data($data, array( - 'jabber' => array( - array('string', true, 5, 255), - array('jabber')), - 'bday_day' => array('num', true, 1, 31), - 'bday_month' => array('num', true, 1, 12), - 'bday_year' => array('num', true, 1901, gmdate('Y', time())), - 'user_birthday' => array('date', true), - )); - - // validate custom profile fields - $cp->submit_cp_field('profile', $user_row['iso_lang_id'], $cp_data, $cp_error); - - if (count($cp_error)) - { - $error = array_merge($error, $cp_error); - } - if (!check_form_key($form_name)) - { - $error[] = 'FORM_INVALID'; - } - - /** - * Validate profile data in ACP before submitting to the database - * - * @event core.acp_users_profile_validate - * @var array data Array with user profile data - * @var int user_id The user id - * @var array user_row Array with the full user data - * @var array error Array with the form errors - * @since 3.1.4-RC1 - * @changed 3.1.12-RC1 Removed submit, added user_id, user_row - */ - $vars = array('data', 'user_id', 'user_row', 'error'); - extract($phpbb_dispatcher->trigger_event('core.acp_users_profile_validate', compact($vars))); - - if (!count($error)) - { - $sql_ary = array( - 'user_jabber' => $data['jabber'], - 'user_birthday' => $data['user_birthday'], - ); - - /** - * Modify profile data in ACP before submitting to the database - * - * @event core.acp_users_profile_modify_sql_ary - * @var array cp_data Array with the user custom profile fields data - * @var array data Array with user profile data - * @var int user_id The user id - * @var array user_row Array with the full user data - * @var array sql_ary Array with sql data - * @since 3.1.4-RC1 - */ - $vars = array('cp_data', 'data', 'user_id', 'user_row', 'sql_ary'); - extract($phpbb_dispatcher->trigger_event('core.acp_users_profile_modify_sql_ary', compact($vars))); - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " - WHERE user_id = $user_id"; - $db->sql_query($sql); - - // Update Custom Fields - $cp->update_profile_field_data($user_id, $cp_data); - - trigger_error($user->lang['USER_PROFILE_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); - } - - // Replace "error" strings with their real, localised form - $error = array_map(array($user, 'lang'), $error); - } - - $s_birthday_day_options = ''; - for ($i = 1; $i < 32; $i++) - { - $selected = ($i == $data['bday_day']) ? ' selected="selected"' : ''; - $s_birthday_day_options .= ""; - } - - $s_birthday_month_options = ''; - for ($i = 1; $i < 13; $i++) - { - $selected = ($i == $data['bday_month']) ? ' selected="selected"' : ''; - $s_birthday_month_options .= ""; - } - - $now = getdate(); - $s_birthday_year_options = ''; - for ($i = $now['year'] - 100; $i <= $now['year']; $i++) - { - $selected = ($i == $data['bday_year']) ? ' selected="selected"' : ''; - $s_birthday_year_options .= ""; - } - unset($now); - - $template->assign_vars(array( - 'JABBER' => $data['jabber'], - 'S_BIRTHDAY_DAY_OPTIONS' => $s_birthday_day_options, - 'S_BIRTHDAY_MONTH_OPTIONS' => $s_birthday_month_options, - 'S_BIRTHDAY_YEAR_OPTIONS' => $s_birthday_year_options, - - 'S_PROFILE' => true) - ); - - // Get additional profile fields and assign them to the template block var 'profile_fields' - $user->get_profile_fields($user_id); - - $cp->generate_profile_fields('profile', $user_row['iso_lang_id']); - - break; - - case 'prefs': - - if (!function_exists('user_get_id_name')) - { - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - } - - $data = array( - 'dateformat' => $request->variable('dateformat', $user_row['user_dateformat'], true), - 'lang' => basename($request->variable('lang', $user_row['user_lang'])), - 'tz' => $request->variable('tz', $user_row['user_timezone']), - 'style' => $request->variable('style', $user_row['user_style']), - 'viewemail' => $request->variable('viewemail', $user_row['user_allow_viewemail']), - 'massemail' => $request->variable('massemail', $user_row['user_allow_massemail']), - 'hideonline' => $request->variable('hideonline', !$user_row['user_allow_viewonline']), - 'notifymethod' => $request->variable('notifymethod', $user_row['user_notify_type']), - 'notifypm' => $request->variable('notifypm', $user_row['user_notify_pm']), - 'allowpm' => $request->variable('allowpm', $user_row['user_allow_pm']), - - 'topic_sk' => $request->variable('topic_sk', ($user_row['user_topic_sortby_type']) ? $user_row['user_topic_sortby_type'] : 't'), - 'topic_sd' => $request->variable('topic_sd', ($user_row['user_topic_sortby_dir']) ? $user_row['user_topic_sortby_dir'] : 'd'), - 'topic_st' => $request->variable('topic_st', ($user_row['user_topic_show_days']) ? $user_row['user_topic_show_days'] : 0), - - 'post_sk' => $request->variable('post_sk', ($user_row['user_post_sortby_type']) ? $user_row['user_post_sortby_type'] : 't'), - 'post_sd' => $request->variable('post_sd', ($user_row['user_post_sortby_dir']) ? $user_row['user_post_sortby_dir'] : 'a'), - 'post_st' => $request->variable('post_st', ($user_row['user_post_show_days']) ? $user_row['user_post_show_days'] : 0), - - 'view_images' => $request->variable('view_images', $this->optionget($user_row, 'viewimg')), - 'view_flash' => $request->variable('view_flash', $this->optionget($user_row, 'viewflash')), - 'view_smilies' => $request->variable('view_smilies', $this->optionget($user_row, 'viewsmilies')), - 'view_sigs' => $request->variable('view_sigs', $this->optionget($user_row, 'viewsigs')), - 'view_avatars' => $request->variable('view_avatars', $this->optionget($user_row, 'viewavatars')), - 'view_wordcensor' => $request->variable('view_wordcensor', $this->optionget($user_row, 'viewcensors')), - - 'bbcode' => $request->variable('bbcode', $this->optionget($user_row, 'bbcode')), - 'smilies' => $request->variable('smilies', $this->optionget($user_row, 'smilies')), - 'sig' => $request->variable('sig', $this->optionget($user_row, 'attachsig')), - 'notify' => $request->variable('notify', $user_row['user_notify']), - ); - - /** - * Modify users preferences data - * - * @event core.acp_users_prefs_modify_data - * @var array data Array with users preferences data - * @var array user_row Array with user data - * @since 3.1.0-b3 - */ - $vars = array('data', 'user_row'); - extract($phpbb_dispatcher->trigger_event('core.acp_users_prefs_modify_data', compact($vars))); - - if ($submit) - { - $error = validate_data($data, array( - 'dateformat' => array('string', false, 1, 64), - 'lang' => array('match', false, '#^[a-z_\-]{2,}$#i'), - 'tz' => array('timezone'), - - 'topic_sk' => array('string', false, 1, 1), - 'topic_sd' => array('string', false, 1, 1), - 'post_sk' => array('string', false, 1, 1), - 'post_sd' => array('string', false, 1, 1), - )); - - if (!check_form_key($form_name)) - { - $error[] = 'FORM_INVALID'; - } - - if (!count($error)) - { - $this->optionset($user_row, 'viewimg', $data['view_images']); - $this->optionset($user_row, 'viewflash', $data['view_flash']); - $this->optionset($user_row, 'viewsmilies', $data['view_smilies']); - $this->optionset($user_row, 'viewsigs', $data['view_sigs']); - $this->optionset($user_row, 'viewavatars', $data['view_avatars']); - $this->optionset($user_row, 'viewcensors', $data['view_wordcensor']); - $this->optionset($user_row, 'bbcode', $data['bbcode']); - $this->optionset($user_row, 'smilies', $data['smilies']); - $this->optionset($user_row, 'attachsig', $data['sig']); - - $sql_ary = array( - 'user_options' => $user_row['user_options'], - - 'user_allow_pm' => $data['allowpm'], - 'user_allow_viewemail' => $data['viewemail'], - 'user_allow_massemail' => $data['massemail'], - 'user_allow_viewonline' => !$data['hideonline'], - 'user_notify_type' => $data['notifymethod'], - 'user_notify_pm' => $data['notifypm'], - - 'user_dateformat' => $data['dateformat'], - 'user_lang' => $data['lang'], - 'user_timezone' => $data['tz'], - 'user_style' => $data['style'], - - 'user_topic_sortby_type' => $data['topic_sk'], - 'user_post_sortby_type' => $data['post_sk'], - 'user_topic_sortby_dir' => $data['topic_sd'], - 'user_post_sortby_dir' => $data['post_sd'], - - 'user_topic_show_days' => $data['topic_st'], - 'user_post_show_days' => $data['post_st'], - - 'user_notify' => $data['notify'], - ); - - /** - * Modify SQL query before users preferences are updated - * - * @event core.acp_users_prefs_modify_sql - * @var array data Array with users preferences data - * @var array user_row Array with user data - * @var array sql_ary SQL array with users preferences data to update - * @var array error Array with errors data - * @since 3.1.0-b3 - */ - $vars = array('data', 'user_row', 'sql_ary', 'error'); - extract($phpbb_dispatcher->trigger_event('core.acp_users_prefs_modify_sql', compact($vars))); - - if (!count($error)) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " - WHERE user_id = $user_id"; - $db->sql_query($sql); - - // Check if user has an active session - if ($user_row['session_id']) - { - // We'll update the session if user_allow_viewonline has changed and the user is a bot - // Or if it's a regular user and the admin set it to hide the session - if ($user_row['user_allow_viewonline'] != $sql_ary['user_allow_viewonline'] && $user_row['user_type'] == USER_IGNORE - || $user_row['user_allow_viewonline'] && !$sql_ary['user_allow_viewonline']) - { - // We also need to check if the user has the permission to cloak. - $user_auth = new \phpbb\auth\auth(); - $user_auth->acl($user_row); - - $session_sql_ary = array( - 'session_viewonline' => ($user_auth->acl_get('u_hideonline')) ? $sql_ary['user_allow_viewonline'] : true, - ); - - $sql = 'UPDATE ' . SESSIONS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $session_sql_ary) . " - WHERE session_user_id = $user_id"; - $db->sql_query($sql); - - unset($user_auth); - } - } - - trigger_error($user->lang['USER_PREFS_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); - } - } - - // Replace "error" strings with their real, localised form - $error = array_map(array($user, 'lang'), $error); - } - - $dateformat_options = ''; - foreach ($user->lang['dateformats'] as $format => $null) - { - $dateformat_options .= ''; - } - - $s_custom = false; - - $dateformat_options .= ''; - - $sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']); - - // Topic ordering options - $limit_topic_days = array(0 => $user->lang['ALL_TOPICS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); - $sort_by_topic_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 'r' => $user->lang['REPLIES'], 's' => $user->lang['SUBJECT'], 'v' => $user->lang['VIEWS']); - - // Post ordering options - $limit_post_days = array(0 => $user->lang['ALL_POSTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); - $sort_by_post_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']); - - $_options = array('topic', 'post'); - foreach ($_options as $sort_option) - { - ${'s_limit_' . $sort_option . '_days'} = ''; - - ${'s_sort_' . $sort_option . '_key'} = ''; - - ${'s_sort_' . $sort_option . '_dir'} = ''; - } - - phpbb_timezone_select($template, $user, $data['tz'], true); - $user_prefs_data = array( - 'S_PREFS' => true, - 'S_JABBER_DISABLED' => ($config['jab_enable'] && $user_row['user_jabber'] && @extension_loaded('xml')) ? false : true, - - 'VIEW_EMAIL' => $data['viewemail'], - 'MASS_EMAIL' => $data['massemail'], - 'ALLOW_PM' => $data['allowpm'], - 'HIDE_ONLINE' => $data['hideonline'], - 'NOTIFY_EMAIL' => ($data['notifymethod'] == NOTIFY_EMAIL) ? true : false, - 'NOTIFY_IM' => ($data['notifymethod'] == NOTIFY_IM) ? true : false, - 'NOTIFY_BOTH' => ($data['notifymethod'] == NOTIFY_BOTH) ? true : false, - 'NOTIFY_PM' => $data['notifypm'], - 'BBCODE' => $data['bbcode'], - 'SMILIES' => $data['smilies'], - 'ATTACH_SIG' => $data['sig'], - 'NOTIFY' => $data['notify'], - 'VIEW_IMAGES' => $data['view_images'], - 'VIEW_FLASH' => $data['view_flash'], - 'VIEW_SMILIES' => $data['view_smilies'], - 'VIEW_SIGS' => $data['view_sigs'], - 'VIEW_AVATARS' => $data['view_avatars'], - 'VIEW_WORDCENSOR' => $data['view_wordcensor'], - - 'S_TOPIC_SORT_DAYS' => $s_limit_topic_days, - 'S_TOPIC_SORT_KEY' => $s_sort_topic_key, - 'S_TOPIC_SORT_DIR' => $s_sort_topic_dir, - 'S_POST_SORT_DAYS' => $s_limit_post_days, - 'S_POST_SORT_KEY' => $s_sort_post_key, - 'S_POST_SORT_DIR' => $s_sort_post_dir, - - 'DATE_FORMAT' => $data['dateformat'], - 'S_DATEFORMAT_OPTIONS' => $dateformat_options, - 'S_CUSTOM_DATEFORMAT' => $s_custom, - 'DEFAULT_DATEFORMAT' => $config['default_dateformat'], - 'A_DEFAULT_DATEFORMAT' => addslashes($config['default_dateformat']), - - 'S_LANG_OPTIONS' => language_select($data['lang']), - 'S_STYLE_OPTIONS' => style_select($data['style']), - ); - - /** - * Modify users preferences data before assigning it to the template - * - * @event core.acp_users_prefs_modify_template_data - * @var array data Array with users preferences data - * @var array user_row Array with user data - * @var array user_prefs_data Array with users preferences data to be assigned to the template - * @since 3.1.0-b3 - */ - $vars = array('data', 'user_row', 'user_prefs_data'); - extract($phpbb_dispatcher->trigger_event('core.acp_users_prefs_modify_template_data', compact($vars))); - - $template->assign_vars($user_prefs_data); - - break; - - case 'avatar': - - $avatars_enabled = false; - /** @var \phpbb\avatar\manager $phpbb_avatar_manager */ - $phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); - - if ($config['allow_avatar']) - { - $avatar_drivers = $phpbb_avatar_manager->get_enabled_drivers(); - - // This is normalised data, without the user_ prefix - $avatar_data = \phpbb\avatar\manager::clean_row($user_row, 'user'); - - if ($submit) - { - if (check_form_key($form_name)) - { - $driver_name = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', '')); - - if (in_array($driver_name, $avatar_drivers) && !$request->is_set_post('avatar_delete')) - { - $driver = $phpbb_avatar_manager->get_driver($driver_name); - $result = $driver->process_form($request, $template, $user, $avatar_data, $error); - - if ($result && empty($error)) - { - // Success! Lets save the result in the database - $result = array( - 'user_avatar_type' => $driver_name, - 'user_avatar' => $result['avatar'], - 'user_avatar_width' => $result['avatar_width'], - 'user_avatar_height' => $result['avatar_height'], - ); - - /** - * Modify users preferences data before assigning it to the template - * - * @event core.acp_users_avatar_sql - * @var array user_row Array with user data - * @var array result Array with user avatar data to be updated in the DB - * @since 3.2.4-RC1 - */ - $vars = array('user_row', 'result'); - extract($phpbb_dispatcher->trigger_event('core.acp_users_avatar_sql', compact($vars))); - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $result) . ' - WHERE user_id = ' . (int) $user_id; - - $db->sql_query($sql); - trigger_error($user->lang['USER_AVATAR_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); - } - } - } - else - { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - } - - // Handle deletion of avatars - if ($request->is_set_post('avatar_delete')) - { - if (!confirm_box(true)) - { - confirm_box(false, $user->lang('CONFIRM_AVATAR_DELETE'), build_hidden_fields(array( - 'avatar_delete' => true)) - ); - } - else - { - $phpbb_avatar_manager->handle_avatar_delete($db, $user, $avatar_data, USERS_TABLE, 'user_'); - - trigger_error($user->lang['USER_AVATAR_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); - } - } - - $selected_driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', $user_row['user_avatar_type'])); - - // Assign min and max values before generating avatar driver html - $template->assign_vars(array( - 'AVATAR_MIN_WIDTH' => $config['avatar_min_width'], - 'AVATAR_MAX_WIDTH' => $config['avatar_max_width'], - 'AVATAR_MIN_HEIGHT' => $config['avatar_min_height'], - 'AVATAR_MAX_HEIGHT' => $config['avatar_max_height'], - )); - - foreach ($avatar_drivers as $current_driver) - { - $driver = $phpbb_avatar_manager->get_driver($current_driver); - - $avatars_enabled = true; - $template->set_filenames(array( - 'avatar' => $driver->get_acp_template_name(), - )); - - if ($driver->prepare_form($request, $template, $user, $avatar_data, $error)) - { - $driver_name = $phpbb_avatar_manager->prepare_driver_name($current_driver); - $driver_upper = strtoupper($driver_name); - - $template->assign_block_vars('avatar_drivers', array( - 'L_TITLE' => $user->lang($driver_upper . '_TITLE'), - 'L_EXPLAIN' => $user->lang($driver_upper . '_EXPLAIN'), - - 'DRIVER' => $driver_name, - 'SELECTED' => $current_driver == $selected_driver, - 'OUTPUT' => $template->assign_display('avatar'), - )); - } - } - } - - // Avatar manager is not initialized if avatars are disabled - if (isset($phpbb_avatar_manager)) - { - // Replace "error" strings with their real, localised form - $error = $phpbb_avatar_manager->localize_errors($user, $error); - } - - $avatar = phpbb_get_user_avatar($user_row, 'USER_AVATAR', true); - - $template->assign_vars(array( - 'S_AVATAR' => true, - 'ERROR' => (!empty($error)) ? implode('
', $error) : '', - 'AVATAR' => (empty($avatar) ? '' : $avatar), - - 'S_FORM_ENCTYPE' => ' enctype="multipart/form-data"', - - 'L_AVATAR_EXPLAIN' => $user->lang(($config['avatar_filesize'] == 0) ? 'AVATAR_EXPLAIN_NO_FILESIZE' : 'AVATAR_EXPLAIN', $config['avatar_max_width'], $config['avatar_max_height'], $config['avatar_filesize'] / 1024), - - 'S_AVATARS_ENABLED' => ($config['allow_avatar'] && $avatars_enabled), - )); - - break; - - case 'rank': - - if ($submit) - { - if (!check_form_key($form_name)) - { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - $rank_id = $request->variable('user_rank', 0); - - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_rank = $rank_id - WHERE user_id = $user_id"; - $db->sql_query($sql); - - trigger_error($user->lang['USER_RANK_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); - } - - $sql = 'SELECT * - FROM ' . RANKS_TABLE . ' - WHERE rank_special = 1 - ORDER BY rank_title'; - $result = $db->sql_query($sql); - - $s_rank_options = ''; - - while ($row = $db->sql_fetchrow($result)) - { - $selected = ($user_row['user_rank'] && $row['rank_id'] == $user_row['user_rank']) ? ' selected="selected"' : ''; - $s_rank_options .= ''; - } - $db->sql_freeresult($result); - - $template->assign_vars(array( - 'S_RANK' => true, - 'S_RANK_OPTIONS' => $s_rank_options) - ); - - break; - - case 'sig': - - if (!function_exists('display_custom_bbcodes')) - { - include($phpbb_root_path . 'includes/functions_display.' . $phpEx); - } - - $enable_bbcode = ($config['allow_sig_bbcode']) ? $this->optionget($user_row, 'sig_bbcode') : false; - $enable_smilies = ($config['allow_sig_smilies']) ? $this->optionget($user_row, 'sig_smilies') : false; - $enable_urls = ($config['allow_sig_links']) ? $this->optionget($user_row, 'sig_links') : false; - - $bbcode_flags = ($enable_bbcode ? OPTION_FLAG_BBCODE : 0) + ($enable_smilies ? OPTION_FLAG_SMILIES : 0) + ($enable_urls ? OPTION_FLAG_LINKS : 0); - - $decoded_message = generate_text_for_edit($user_row['user_sig'], $user_row['user_sig_bbcode_uid'], $bbcode_flags); - $signature = $request->variable('signature', $decoded_message['text'], true); - $signature_preview = ''; - - if ($submit || $request->is_set_post('preview')) - { - $enable_bbcode = ($config['allow_sig_bbcode']) ? !$request->variable('disable_bbcode', false) : false; - $enable_smilies = ($config['allow_sig_smilies']) ? !$request->variable('disable_smilies', false) : false; - $enable_urls = ($config['allow_sig_links']) ? !$request->variable('disable_magic_url', false) : false; - - if (!check_form_key($form_name)) - { - $error[] = 'FORM_INVALID'; - } - } - - $bbcode_uid = $bbcode_bitfield = $bbcode_flags = ''; - $warn_msg = generate_text_for_storage( - $signature, - $bbcode_uid, - $bbcode_bitfield, - $bbcode_flags, - $enable_bbcode, - $enable_urls, - $enable_smilies, - $config['allow_sig_img'], - $config['allow_sig_flash'], - true, - $config['allow_sig_links'], - 'sig' - ); - - if (count($warn_msg)) - { - $error += $warn_msg; - } - - if (!$submit) - { - // Parse it for displaying - $signature_preview = generate_text_for_display($signature, $bbcode_uid, $bbcode_bitfield, $bbcode_flags); - } - else - { - if (!count($error)) - { - $this->optionset($user_row, 'sig_bbcode', $enable_bbcode); - $this->optionset($user_row, 'sig_smilies', $enable_smilies); - $this->optionset($user_row, 'sig_links', $enable_urls); - - $sql_ary = array( - 'user_sig' => $signature, - 'user_options' => $user_row['user_options'], - 'user_sig_bbcode_uid' => $bbcode_uid, - 'user_sig_bbcode_bitfield' => $bbcode_bitfield, - ); - - /** - * Modify user signature before it is stored in the DB - * - * @event core.acp_users_modify_signature_sql_ary - * @var array user_row Array with user data - * @var array sql_ary Array with user signature data to be updated in the DB - * @since 3.2.4-RC1 - */ - $vars = array('user_row', 'sql_ary'); - extract($phpbb_dispatcher->trigger_event('core.acp_users_modify_signature_sql_ary', compact($vars))); - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE user_id = ' . $user_id; - $db->sql_query($sql); - - trigger_error($user->lang['USER_SIG_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); - } - } - - // Replace "error" strings with their real, localised form - $error = array_map(array($user, 'lang'), $error); - - if ($request->is_set_post('preview')) - { - $decoded_message = generate_text_for_edit($signature, $bbcode_uid, $bbcode_flags); - } - - /** @var \phpbb\controller\helper $controller_helper */ - $controller_helper = $phpbb_container->get('controller.helper'); - - $template->assign_vars(array( - 'S_SIGNATURE' => true, - - 'SIGNATURE' => $decoded_message['text'], - 'SIGNATURE_PREVIEW' => $signature_preview, - - 'S_BBCODE_CHECKED' => (!$enable_bbcode) ? ' checked="checked"' : '', - 'S_SMILIES_CHECKED' => (!$enable_smilies) ? ' checked="checked"' : '', - 'S_MAGIC_URL_CHECKED' => (!$enable_urls) ? ' checked="checked"' : '', - - 'BBCODE_STATUS' => $user->lang(($config['allow_sig_bbcode'] ? 'BBCODE_IS_ON' : 'BBCODE_IS_OFF'), '', ''), - 'SMILIES_STATUS' => ($config['allow_sig_smilies']) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'], - 'IMG_STATUS' => ($config['allow_sig_img']) ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'], - 'FLASH_STATUS' => ($config['allow_sig_flash']) ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'], - 'URL_STATUS' => ($config['allow_sig_links']) ? $user->lang['URL_IS_ON'] : $user->lang['URL_IS_OFF'], - - 'L_SIGNATURE_EXPLAIN' => $user->lang('SIGNATURE_EXPLAIN', (int) $config['max_sig_chars']), - - 'S_BBCODE_ALLOWED' => $config['allow_sig_bbcode'], - 'S_SMILIES_ALLOWED' => $config['allow_sig_smilies'], - 'S_BBCODE_IMG' => ($config['allow_sig_img']) ? true : false, - 'S_BBCODE_FLASH' => ($config['allow_sig_flash']) ? true : false, - 'S_LINKS_ALLOWED' => ($config['allow_sig_links']) ? true : false) - ); - - // Assigning custom bbcodes - display_custom_bbcodes(); - - break; - - case 'attach': - /* @var $pagination \phpbb\pagination */ - $pagination = $phpbb_container->get('pagination'); - - $start = $request->variable('start', 0); - $deletemark = (isset($_POST['delmarked'])) ? true : false; - $marked = $request->variable('mark', array(0)); - - // Sort keys - $sort_key = $request->variable('sk', 'a'); - $sort_dir = $request->variable('sd', 'd'); - - if ($deletemark && count($marked)) - { - $sql = 'SELECT attach_id - FROM ' . ATTACHMENTS_TABLE . ' - WHERE poster_id = ' . $user_id . ' - AND is_orphan = 0 - AND ' . $db->sql_in_set('attach_id', $marked); - $result = $db->sql_query($sql); - - $marked = array(); - while ($row = $db->sql_fetchrow($result)) - { - $marked[] = $row['attach_id']; - } - $db->sql_freeresult($result); - } - - if ($deletemark && count($marked)) - { - if (confirm_box(true)) - { - $sql = 'SELECT real_filename - FROM ' . ATTACHMENTS_TABLE . ' - WHERE ' . $db->sql_in_set('attach_id', $marked); - $result = $db->sql_query($sql); - - $log_attachments = array(); - while ($row = $db->sql_fetchrow($result)) - { - $log_attachments[] = $row['real_filename']; - } - $db->sql_freeresult($result); - - /** @var \phpbb\attachment\manager $attachment_manager */ - $attachment_manager = $phpbb_container->get('attachment.manager'); - $attachment_manager->delete('attach', $marked); - unset($attachment_manager); - - $message = (count($log_attachments) == 1) ? $user->lang['ATTACHMENT_DELETED'] : $user->lang['ATTACHMENTS_DELETED']; - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ATTACHMENTS_DELETED', false, array(implode($user->lang['COMMA_SEPARATOR'], $log_attachments))); - trigger_error($message . adm_back_link($this->u_action . '&u=' . $user_id)); - } - else - { - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( - 'u' => $user_id, - 'i' => $id, - 'mode' => $mode, - 'action' => $action, - 'delmarked' => true, - 'mark' => $marked)) - ); - } - } - - $sk_text = array('a' => $user->lang['SORT_FILENAME'], 'c' => $user->lang['SORT_EXTENSION'], 'd' => $user->lang['SORT_SIZE'], 'e' => $user->lang['SORT_DOWNLOADS'], 'f' => $user->lang['SORT_POST_TIME'], 'g' => $user->lang['SORT_TOPIC_TITLE']); - $sk_sql = array('a' => 'a.real_filename', 'c' => 'a.extension', 'd' => 'a.filesize', 'e' => 'a.download_count', 'f' => 'a.filetime', 'g' => 't.topic_title'); - - $sd_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']); - - $s_sort_key = ''; - foreach ($sk_text as $key => $value) - { - $selected = ($sort_key == $key) ? ' selected="selected"' : ''; - $s_sort_key .= ''; - } - - $s_sort_dir = ''; - foreach ($sd_text as $key => $value) - { - $selected = ($sort_dir == $key) ? ' selected="selected"' : ''; - $s_sort_dir .= ''; - } - - if (!isset($sk_sql[$sort_key])) - { - $sort_key = 'a'; - } - - $order_by = $sk_sql[$sort_key] . ' ' . (($sort_dir == 'a') ? 'ASC' : 'DESC'); - - $sql = 'SELECT COUNT(attach_id) as num_attachments - FROM ' . ATTACHMENTS_TABLE . " - WHERE poster_id = $user_id - AND is_orphan = 0"; - $result = $db->sql_query_limit($sql, 1); - $num_attachments = (int) $db->sql_fetchfield('num_attachments'); - $db->sql_freeresult($result); - - $sql = 'SELECT a.*, t.topic_title, p.message_subject as message_title - FROM ' . ATTACHMENTS_TABLE . ' a - LEFT JOIN ' . TOPICS_TABLE . ' t ON (a.topic_id = t.topic_id - AND a.in_message = 0) - LEFT JOIN ' . PRIVMSGS_TABLE . ' p ON (a.post_msg_id = p.msg_id - AND a.in_message = 1) - WHERE a.poster_id = ' . $user_id . " - AND a.is_orphan = 0 - ORDER BY $order_by"; - $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); - - while ($row = $db->sql_fetchrow($result)) - { - if ($row['in_message']) - { - $view_topic = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=pm&p={$row['post_msg_id']}"); - } - else - { - $view_topic = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t={$row['topic_id']}&p={$row['post_msg_id']}") . '#p' . $row['post_msg_id']; - } - - $template->assign_block_vars('attach', array( - 'REAL_FILENAME' => $row['real_filename'], - 'COMMENT' => nl2br($row['attach_comment']), - 'EXTENSION' => $row['extension'], - 'SIZE' => get_formatted_filesize($row['filesize']), - 'DOWNLOAD_COUNT' => $row['download_count'], - 'POST_TIME' => $user->format_date($row['filetime']), - 'TOPIC_TITLE' => ($row['in_message']) ? $row['message_title'] : $row['topic_title'], - - 'ATTACH_ID' => $row['attach_id'], - 'POST_ID' => $row['post_msg_id'], - 'TOPIC_ID' => $row['topic_id'], - - 'S_IN_MESSAGE' => $row['in_message'], - - 'U_DOWNLOAD' => append_sid("{$phpbb_root_path}download/file.$phpEx", 'mode=view&id=' . $row['attach_id']), - 'U_VIEW_TOPIC' => $view_topic) - ); - } - $db->sql_freeresult($result); - - $base_url = $this->u_action . "&u=$user_id&sk=$sort_key&sd=$sort_dir"; - $pagination->generate_template_pagination($base_url, 'pagination', 'start', $num_attachments, $config['topics_per_page'], $start); - - $template->assign_vars(array( - 'S_ATTACHMENTS' => true, - 'S_SORT_KEY' => $s_sort_key, - 'S_SORT_DIR' => $s_sort_dir, - )); - - break; - - case 'groups': - - if (!function_exists('group_user_attributes')) - { - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - } - - $user->add_lang(array('groups', 'acp/groups')); - $group_id = $request->variable('g', 0); - - if ($group_id) - { - // Check the founder only entry for this group to make sure everything is well - $sql = 'SELECT group_founder_manage - FROM ' . GROUPS_TABLE . ' - WHERE group_id = ' . $group_id; - $result = $db->sql_query($sql); - $founder_manage = (int) $db->sql_fetchfield('group_founder_manage'); - $db->sql_freeresult($result); - - if ($user->data['user_type'] != USER_FOUNDER && $founder_manage) - { - trigger_error($user->lang['NOT_ALLOWED_MANAGE_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - } - - switch ($action) - { - case 'demote': - case 'promote': - case 'default': - if (!$group_id) - { - trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - if (!check_link_hash($request->variable('hash', ''), 'acp_users')) - { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - group_user_attributes($action, $group_id, $user_id); - - if ($action == 'default') - { - $user_row['group_id'] = $group_id; - } - break; - - case 'delete': - - if (confirm_box(true)) - { - if (!$group_id) - { - trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - if ($error = group_user_del($group_id, $user_id)) - { - trigger_error($user->lang[$error] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - $error = array(); - - // The delete action was successful - therefore update the user row... - $sql = 'SELECT u.*, s.* - FROM ' . USERS_TABLE . ' u - LEFT JOIN ' . SESSIONS_TABLE . ' s ON (s.session_user_id = u.user_id) - WHERE u.user_id = ' . $user_id . ' - ORDER BY s.session_time DESC'; - $result = $db->sql_query_limit($sql, 1); - $user_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - } - else - { - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( - 'u' => $user_id, - 'i' => $id, - 'mode' => $mode, - 'action' => $action, - 'g' => $group_id)) - ); - } - - break; - - case 'approve': - - if (confirm_box(true)) - { - if (!$group_id) - { - trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - group_user_attributes($action, $group_id, $user_id); - } - else - { - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( - 'u' => $user_id, - 'i' => $id, - 'mode' => $mode, - 'action' => $action, - 'g' => $group_id)) - ); - } - - break; - } - - // Add user to group? - if ($submit) - { - - if (!check_form_key($form_name)) - { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - if (!$group_id) - { - trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - // Add user/s to group - if ($error = group_user_add($group_id, $user_id)) - { - trigger_error($user->lang[$error] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - $error = array(); - } - - /** @var \phpbb\group\helper $group_helper */ - $group_helper = $phpbb_container->get('group_helper'); - - $sql = 'SELECT ug.*, g.* - FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . " ug - WHERE ug.user_id = $user_id - AND g.group_id = ug.group_id - ORDER BY g.group_type DESC, ug.user_pending ASC, g.group_name"; - $result = $db->sql_query($sql); - - $i = 0; - $group_data = $id_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - $type = ($row['group_type'] == GROUP_SPECIAL) ? 'special' : (($row['user_pending']) ? 'pending' : 'normal'); - - $group_data[$type][$i]['group_id'] = $row['group_id']; - $group_data[$type][$i]['group_name'] = $row['group_name']; - $group_data[$type][$i]['group_leader'] = ($row['group_leader']) ? 1 : 0; - - $id_ary[] = $row['group_id']; - - $i++; - } - $db->sql_freeresult($result); - - // Select box for other groups - $sql = 'SELECT group_id, group_name, group_type, group_founder_manage - FROM ' . GROUPS_TABLE . ' - ' . ((count($id_ary)) ? 'WHERE ' . $db->sql_in_set('group_id', $id_ary, true) : '') . ' - ORDER BY group_type DESC, group_name ASC'; - $result = $db->sql_query($sql); - - $s_group_options = ''; - while ($row = $db->sql_fetchrow($result)) - { - if (!$config['coppa_enable'] && $row['group_name'] == 'REGISTERED_COPPA') - { - continue; - } - - // Do not display those groups not allowed to be managed - if ($user->data['user_type'] != USER_FOUNDER && $row['group_founder_manage']) - { - continue; - } - - $s_group_options .= '' . $group_helper->get_name($row['group_name']) . ''; - } - $db->sql_freeresult($result); - - $current_type = ''; - foreach ($group_data as $group_type => $data_ary) - { - if ($current_type != $group_type) - { - $template->assign_block_vars('group', array( - 'S_NEW_GROUP_TYPE' => true, - 'GROUP_TYPE' => $user->lang['USER_GROUP_' . strtoupper($group_type)]) - ); - } - - foreach ($data_ary as $data) - { - $template->assign_block_vars('group', array( - 'U_EDIT_GROUP' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=groups&mode=manage&action=edit&u=$user_id&g={$data['group_id']}&back_link=acp_users_groups"), - 'U_DEFAULT' => $this->u_action . "&action=default&u=$user_id&g=" . $data['group_id'] . '&hash=' . generate_link_hash('acp_users'), - 'U_DEMOTE_PROMOTE' => $this->u_action . '&action=' . (($data['group_leader']) ? 'demote' : 'promote') . "&u=$user_id&g=" . $data['group_id'] . '&hash=' . generate_link_hash('acp_users'), - 'U_DELETE' => $this->u_action . "&action=delete&u=$user_id&g=" . $data['group_id'], - 'U_APPROVE' => ($group_type == 'pending') ? $this->u_action . "&action=approve&u=$user_id&g=" . $data['group_id'] : '', - - 'GROUP_NAME' => $group_helper->get_name($data['group_name']), - 'L_DEMOTE_PROMOTE' => ($data['group_leader']) ? $user->lang['GROUP_DEMOTE'] : $user->lang['GROUP_PROMOTE'], - - 'S_IS_MEMBER' => ($group_type != 'pending') ? true : false, - 'S_NO_DEFAULT' => ($user_row['group_id'] != $data['group_id']) ? true : false, - 'S_SPECIAL_GROUP' => ($group_type == 'special') ? true : false, - ) - ); - } - } - - $template->assign_vars(array( - 'S_GROUPS' => true, - 'S_GROUP_OPTIONS' => $s_group_options) - ); - - break; - - case 'perm': - - if (!class_exists('auth_admin')) - { - include($phpbb_root_path . 'includes/acp/auth.' . $phpEx); - } - - $auth_admin = new auth_admin(); - - $user->add_lang('acp/permissions'); - add_permission_language(); - - $forum_id = $request->variable('f', 0); - - // Global Permissions - if (!$forum_id) - { - // Select auth options - $sql = 'SELECT auth_option, is_local, is_global - FROM ' . ACL_OPTIONS_TABLE . ' - WHERE auth_option ' . $db->sql_like_expression($db->get_any_char() . '_') . ' - AND is_global = 1 - ORDER BY auth_option'; - $result = $db->sql_query($sql); - - $hold_ary = array(); - - while ($row = $db->sql_fetchrow($result)) - { - $hold_ary = $auth_admin->get_mask('view', $user_id, false, false, $row['auth_option'], 'global', ACL_NEVER); - $auth_admin->display_mask('view', $row['auth_option'], $hold_ary, 'user', false, false); - } - $db->sql_freeresult($result); - - unset($hold_ary); - } - else - { - $sql = 'SELECT auth_option, is_local, is_global - FROM ' . ACL_OPTIONS_TABLE . " - WHERE auth_option " . $db->sql_like_expression($db->get_any_char() . '_') . " - AND is_local = 1 - ORDER BY is_global DESC, auth_option"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $hold_ary = $auth_admin->get_mask('view', $user_id, false, $forum_id, $row['auth_option'], 'local', ACL_NEVER); - $auth_admin->display_mask('view', $row['auth_option'], $hold_ary, 'user', true, false); - } - $db->sql_freeresult($result); - } - - $s_forum_options = ''; - $s_forum_options .= make_forum_select($forum_id, false, true, false, false, false); - - $template->assign_vars(array( - 'S_PERMISSIONS' => true, - - 'S_GLOBAL' => (!$forum_id) ? true : false, - 'S_FORUM_OPTIONS' => $s_forum_options, - - 'U_ACTION' => $this->u_action . '&u=' . $user_id, - 'U_USER_PERMISSIONS' => append_sid("{$phpbb_admin_path}index.$phpEx" ,'i=permissions&mode=setting_user_global&user_id[]=' . $user_id), - 'U_USER_FORUM_PERMISSIONS' => append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions&mode=setting_user_local&user_id[]=' . $user_id)) - ); - - break; - - default: - - /** - * Additional modes provided by extensions - * - * @event core.acp_users_mode_add - * @var string mode New mode - * @var int user_id User id of the user to manage - * @var array user_row Array with user data - * @var array error Array with errors data - * @since 3.2.2-RC1 - */ - $vars = array('mode', 'user_id', 'user_row', 'error'); - extract($phpbb_dispatcher->trigger_event('core.acp_users_mode_add', compact($vars))); - - break; - } - - // Assign general variables - $template->assign_vars(array( - 'S_ERROR' => (count($error)) ? true : false, - 'ERROR_MSG' => (count($error)) ? implode('
', $error) : '') - ); - } - - /** - * Set option bit field for user options in a user row array. - * - * Optionset replacement for this module based on $user->optionset. - * - * @param array $user_row Row from the users table. - * @param int $key Option key, as defined in $user->keyoptions property. - * @param bool $value True to set the option, false to clear the option. - * @param int $data Current bit field value, or false to use $user_row['user_options'] - * @return int|bool If $data is false, the bit field is modified and - * written back to $user_row['user_options'], and - * return value is true if the bit field changed and - * false otherwise. If $data is not false, the new - * bitfield value is returned. - */ - function optionset(&$user_row, $key, $value, $data = false) - { - global $user; - - $var = ($data !== false) ? $data : $user_row['user_options']; - - $new_var = phpbb_optionset($user->keyoptions[$key], $value, $var); - - if ($data === false) - { - if ($new_var != $var) - { - $user_row['user_options'] = $new_var; - return true; - } - else - { - return false; - } - } - else - { - return $new_var; - } - } - - /** - * Get option bit field from user options in a user row array. - * - * Optionget replacement for this module based on $user->optionget. - * - * @param array $user_row Row from the users table. - * @param int $key option key, as defined in $user->keyoptions property. - * @param int $data bit field value to use, or false to use $user_row['user_options'] - * @return bool true if the option is set in the bit field, false otherwise - */ - function optionget(&$user_row, $key, $data = false) - { - global $user; - - $var = ($data !== false) ? $data : $user_row['user_options']; - return phpbb_optionget($user->keyoptions[$key], $var); - } -} diff --git a/install/update/new/includes/acp/auth.php b/install/update/new/includes/acp/auth.php deleted file mode 100644 index f203f9d..0000000 --- a/install/update/new/includes/acp/auth.php +++ /dev/null @@ -1,1316 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* ACP Permission/Auth class -*/ -class auth_admin extends \phpbb\auth\auth -{ - /** - * Init auth settings - */ - function __construct() - { - global $db, $cache; - - if (($this->acl_options = $cache->get('_acl_options')) === false) - { - $sql = 'SELECT auth_option_id, auth_option, is_global, is_local - FROM ' . ACL_OPTIONS_TABLE . ' - ORDER BY auth_option_id'; - $result = $db->sql_query($sql); - - $global = $local = 0; - $this->acl_options = array(); - while ($row = $db->sql_fetchrow($result)) - { - if ($row['is_global']) - { - $this->acl_options['global'][$row['auth_option']] = $global++; - } - - if ($row['is_local']) - { - $this->acl_options['local'][$row['auth_option']] = $local++; - } - - $this->acl_options['id'][$row['auth_option']] = (int) $row['auth_option_id']; - $this->acl_options['option'][(int) $row['auth_option_id']] = $row['auth_option']; - } - $db->sql_freeresult($result); - - $cache->put('_acl_options', $this->acl_options); - } - } - - /** - * Get permission mask - * This function only supports getting permissions of one type (for example a_) - * - * @param set|view $mode defines the permissions we get, view gets effective permissions (checking user AND group permissions), set only gets the user or group permission set alone - * @param mixed $user_id user ids to search for (a user_id or a group_id has to be specified at least) - * @param mixed $group_id group ids to search for, return group related settings (a user_id or a group_id has to be specified at least) - * @param mixed $forum_id forum_ids to search for. Defining a forum id also means getting local settings - * @param string $auth_option the auth_option defines the permission setting to look for (a_ for example) - * @param local|global $scope the scope defines the permission scope. If local, a forum_id is additionally required - * @param ACL_NEVER|ACL_NO|ACL_YES $acl_fill defines the mode those permissions not set are getting filled with - */ - function get_mask($mode, $user_id = false, $group_id = false, $forum_id = false, $auth_option = false, $scope = false, $acl_fill = ACL_NEVER) - { - global $db, $user; - - $hold_ary = array(); - $view_user_mask = ($mode == 'view' && $group_id === false) ? true : false; - - if ($auth_option === false || $scope === false) - { - return array(); - } - - $acl_user_function = ($mode == 'set') ? 'acl_user_raw_data' : 'acl_raw_data'; - - if (!$view_user_mask) - { - if ($forum_id !== false) - { - $hold_ary = ($group_id !== false) ? $this->acl_group_raw_data($group_id, $auth_option . '%', $forum_id) : $this->$acl_user_function($user_id, $auth_option . '%', $forum_id); - } - else - { - $hold_ary = ($group_id !== false) ? $this->acl_group_raw_data($group_id, $auth_option . '%', ($scope == 'global') ? 0 : false) : $this->$acl_user_function($user_id, $auth_option . '%', ($scope == 'global') ? 0 : false); - } - } - - // Make sure hold_ary is filled with every setting (prevents missing forums/users/groups) - $ug_id = ($group_id !== false) ? ((!is_array($group_id)) ? array($group_id) : $group_id) : ((!is_array($user_id)) ? array($user_id) : $user_id); - $forum_ids = ($forum_id !== false) ? ((!is_array($forum_id)) ? array($forum_id) : $forum_id) : (($scope == 'global') ? array(0) : array()); - - // Only those options we need - $compare_options = array_diff(preg_replace('/^((?!' . $auth_option . ').+)|(' . $auth_option . ')$/', '', array_keys($this->acl_options[$scope])), array('')); - - // If forum_ids is false and the scope is local we actually want to have all forums within the array - if ($scope == 'local' && !count($forum_ids)) - { - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE; - $result = $db->sql_query($sql, 120); - - while ($row = $db->sql_fetchrow($result)) - { - $forum_ids[] = (int) $row['forum_id']; - } - $db->sql_freeresult($result); - } - - if ($view_user_mask) - { - $auth2 = null; - - $sql = 'SELECT user_id, user_permissions, user_type - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('user_id', $ug_id); - $result = $db->sql_query($sql); - - while ($userdata = $db->sql_fetchrow($result)) - { - if ($user->data['user_id'] != $userdata['user_id']) - { - $auth2 = new \phpbb\auth\auth(); - $auth2->acl($userdata); - } - else - { - global $auth; - $auth2 = &$auth; - } - - $hold_ary[$userdata['user_id']] = array(); - foreach ($forum_ids as $f_id) - { - $hold_ary[$userdata['user_id']][$f_id] = array(); - foreach ($compare_options as $option) - { - $hold_ary[$userdata['user_id']][$f_id][$option] = $auth2->acl_get($option, $f_id); - } - } - } - $db->sql_freeresult($result); - - unset($userdata); - unset($auth2); - } - - foreach ($ug_id as $_id) - { - if (!isset($hold_ary[$_id])) - { - $hold_ary[$_id] = array(); - } - - foreach ($forum_ids as $f_id) - { - if (!isset($hold_ary[$_id][$f_id])) - { - $hold_ary[$_id][$f_id] = array(); - } - } - } - - // Now, we need to fill the gaps with $acl_fill. ;) - - // Now switch back to keys - if (count($compare_options)) - { - $compare_options = array_combine($compare_options, array_fill(1, count($compare_options), $acl_fill)); - } - - // Defining the user-function here to save some memory - $return_acl_fill = function () use ($acl_fill) - { - return $acl_fill; - }; - - // Actually fill the gaps - if (count($hold_ary)) - { - foreach ($hold_ary as $ug_id => $row) - { - foreach ($row as $id => $options) - { - // Do not include the global auth_option - unset($options[$auth_option]); - - // Not a "fine" solution, but at all it's a 1-dimensional - // array_diff_key function filling the resulting array values with zeros - // The differences get merged into $hold_ary (all permissions having $acl_fill set) - $hold_ary[$ug_id][$id] = array_merge($options, - - array_map($return_acl_fill, - array_flip( - array_diff( - array_keys($compare_options), array_keys($options) - ) - ) - ) - ); - } - } - } - else - { - $hold_ary[($group_id !== false) ? $group_id : $user_id][(int) $forum_id] = $compare_options; - } - - return $hold_ary; - } - - /** - * Get permission mask for roles - * This function only supports getting masks for one role - */ - function get_role_mask($role_id) - { - global $db; - - $hold_ary = array(); - - // Get users having this role set... - $sql = 'SELECT user_id, forum_id - FROM ' . ACL_USERS_TABLE . ' - WHERE auth_role_id = ' . $role_id . ' - ORDER BY forum_id'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $hold_ary[$row['forum_id']]['users'][] = $row['user_id']; - } - $db->sql_freeresult($result); - - // Now grab groups... - $sql = 'SELECT group_id, forum_id - FROM ' . ACL_GROUPS_TABLE . ' - WHERE auth_role_id = ' . $role_id . ' - ORDER BY forum_id'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $hold_ary[$row['forum_id']]['groups'][] = $row['group_id']; - } - $db->sql_freeresult($result); - - return $hold_ary; - } - - /** - * Display permission mask (assign to template) - */ - function display_mask($mode, $permission_type, &$hold_ary, $user_mode = 'user', $local = false, $group_display = true) - { - global $template, $user, $db, $phpbb_container; - - /* @var $phpbb_permissions \phpbb\permissions */ - $phpbb_permissions = $phpbb_container->get('acl.permissions'); - - /** @var \phpbb\group\helper $group_helper */ - $group_helper = $phpbb_container->get('group_helper'); - - // Define names for template loops, might be able to be set - $tpl_pmask = 'p_mask'; - $tpl_fmask = 'f_mask'; - $tpl_category = 'category'; - $tpl_mask = 'mask'; - - $l_acl_type = $phpbb_permissions->get_type_lang($permission_type, (($local) ? 'local' : 'global')); - - // Allow trace for viewing permissions and in user mode - $show_trace = ($mode == 'view' && $user_mode == 'user') ? true : false; - - // Get names - if ($user_mode == 'user') - { - $sql = 'SELECT user_id as ug_id, username as ug_name - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('user_id', array_keys($hold_ary)) . ' - ORDER BY username_clean ASC'; - } - else - { - $sql = 'SELECT group_id as ug_id, group_name as ug_name, group_type - FROM ' . GROUPS_TABLE . ' - WHERE ' . $db->sql_in_set('group_id', array_keys($hold_ary)) . ' - ORDER BY group_type DESC, group_name ASC'; - } - $result = $db->sql_query($sql); - - $ug_names_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - $ug_names_ary[$row['ug_id']] = ($user_mode == 'user') ? $row['ug_name'] : $group_helper->get_name($row['ug_name']); - } - $db->sql_freeresult($result); - - // Get used forums - $forum_ids = array(); - foreach ($hold_ary as $ug_id => $row) - { - $forum_ids = array_merge($forum_ids, array_keys($row)); - } - $forum_ids = array_unique($forum_ids); - - $forum_names_ary = array(); - if ($local) - { - $forum_names_ary = make_forum_select(false, false, true, false, false, false, true); - - // Remove the disabled ones, since we do not create an option field here... - foreach ($forum_names_ary as $key => $value) - { - if (!$value['disabled']) - { - continue; - } - unset($forum_names_ary[$key]); - } - } - else - { - $forum_names_ary[0] = $l_acl_type; - } - - // Get available roles - $sql = 'SELECT * - FROM ' . ACL_ROLES_TABLE . " - WHERE role_type = '" . $db->sql_escape($permission_type) . "' - ORDER BY role_order ASC"; - $result = $db->sql_query($sql); - - $roles = array(); - while ($row = $db->sql_fetchrow($result)) - { - $roles[$row['role_id']] = $row; - } - $db->sql_freeresult($result); - - $cur_roles = $this->acl_role_data($user_mode, $permission_type, array_keys($hold_ary)); - - // Build js roles array (role data assignments) - $s_role_js_array = ''; - - if (count($roles)) - { - $s_role_js_array = array(); - - // Make sure every role (even if empty) has its array defined - foreach ($roles as $_role_id => $null) - { - $s_role_js_array[$_role_id] = "\n" . 'role_options[' . $_role_id . '] = new Array();' . "\n"; - } - - $sql = 'SELECT r.role_id, o.auth_option, r.auth_setting - FROM ' . ACL_ROLES_DATA_TABLE . ' r, ' . ACL_OPTIONS_TABLE . ' o - WHERE o.auth_option_id = r.auth_option_id - AND ' . $db->sql_in_set('r.role_id', array_keys($roles)); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $flag = substr($row['auth_option'], 0, strpos($row['auth_option'], '_') + 1); - if ($flag == $row['auth_option']) - { - continue; - } - - $s_role_js_array[$row['role_id']] .= 'role_options[' . $row['role_id'] . '][\'' . addslashes($row['auth_option']) . '\'] = ' . $row['auth_setting'] . '; '; - } - $db->sql_freeresult($result); - - $s_role_js_array = implode('', $s_role_js_array); - } - - $template->assign_var('S_ROLE_JS_ARRAY', $s_role_js_array); - unset($s_role_js_array); - - // Now obtain memberships - $user_groups_default = $user_groups_custom = array(); - if ($user_mode == 'user' && $group_display) - { - $sql = 'SELECT group_id, group_name, group_type - FROM ' . GROUPS_TABLE . ' - ORDER BY group_type DESC, group_name ASC'; - $result = $db->sql_query($sql); - - $groups = array(); - while ($row = $db->sql_fetchrow($result)) - { - $groups[$row['group_id']] = $row; - } - $db->sql_freeresult($result); - - $memberships = group_memberships(false, array_keys($hold_ary), false); - - // User is not a member of any group? Bad admin, bad bad admin... - if ($memberships) - { - foreach ($memberships as $row) - { - $user_groups_default[$row['user_id']][] = $group_helper->get_name($groups[$row['group_id']]['group_name']); - } - } - unset($memberships, $groups); - } - - // If we only have one forum id to display or being in local mode and more than one user/group to display, - // we switch the complete interface to group by user/usergroup instead of grouping by forum - // To achieve this, we need to switch the array a bit - if (count($forum_ids) == 1 || ($local && count($ug_names_ary) > 1)) - { - $hold_ary_temp = $hold_ary; - $hold_ary = array(); - foreach ($hold_ary_temp as $ug_id => $row) - { - foreach ($forum_names_ary as $forum_id => $forum_row) - { - if (isset($row[$forum_id])) - { - $hold_ary[$forum_id][$ug_id] = $row[$forum_id]; - } - } - } - unset($hold_ary_temp); - - foreach ($hold_ary as $forum_id => $forum_array) - { - $content_array = $categories = array(); - $this->build_permission_array($hold_ary[$forum_id], $content_array, $categories, array_keys($ug_names_ary)); - - $template->assign_block_vars($tpl_pmask, array( - 'NAME' => ($forum_id == 0) ? $forum_names_ary[0] : $forum_names_ary[$forum_id]['forum_name'], - 'PADDING' => ($forum_id == 0) ? '' : $forum_names_ary[$forum_id]['padding'], - - 'CATEGORIES' => implode('', $categories), - - 'L_ACL_TYPE' => $l_acl_type, - - 'S_LOCAL' => ($local) ? true : false, - 'S_GLOBAL' => (!$local) ? true : false, - 'S_NUM_CATS' => count($categories), - 'S_VIEW' => ($mode == 'view') ? true : false, - 'S_NUM_OBJECTS' => count($content_array), - 'S_USER_MODE' => ($user_mode == 'user') ? true : false, - 'S_GROUP_MODE' => ($user_mode == 'group') ? true : false) - ); - - foreach ($content_array as $ug_id => $ug_array) - { - // Build role dropdown options - $current_role_id = (isset($cur_roles[$ug_id][$forum_id])) ? $cur_roles[$ug_id][$forum_id] : 0; - - $role_options = array(); - - $s_role_options = ''; - $current_role_id = (isset($cur_roles[$ug_id][$forum_id])) ? $cur_roles[$ug_id][$forum_id] : 0; - - foreach ($roles as $role_id => $role_row) - { - $role_description = (!empty($user->lang[$role_row['role_description']])) ? $user->lang[$role_row['role_description']] : nl2br($role_row['role_description']); - $role_name = (!empty($user->lang[$role_row['role_name']])) ? $user->lang[$role_row['role_name']] : $role_row['role_name']; - - $title = ($role_description) ? ' title="' . $role_description . '"' : ''; - $s_role_options .= ''; - - $role_options[] = array( - 'ID' => $role_id, - 'ROLE_NAME' => $role_name, - 'TITLE' => $role_description, - 'SELECTED' => $role_id == $current_role_id, - ); - } - - if ($s_role_options) - { - $s_role_options = '' . $s_role_options; - } - - if (!$current_role_id && $mode != 'view') - { - $s_custom_permissions = false; - - foreach ($ug_array as $key => $value) - { - if ($value['S_NEVER'] || $value['S_YES']) - { - $s_custom_permissions = true; - break; - } - } - } - else - { - $s_custom_permissions = false; - } - - $template->assign_block_vars($tpl_pmask . '.' . $tpl_fmask, array( - 'NAME' => $ug_names_ary[$ug_id], - 'UG_ID' => $ug_id, - 'S_ROLE_OPTIONS' => $s_role_options, - 'S_CUSTOM' => $s_custom_permissions, - 'FORUM_ID' => $forum_id, - 'S_ROLE_ID' => $current_role_id, - )); - - $template->assign_block_vars_array($tpl_pmask . '.' . $tpl_fmask . '.role_options', $role_options); - - $this->assign_cat_array($ug_array, $tpl_pmask . '.' . $tpl_fmask . '.' . $tpl_category, $tpl_mask, $ug_id, $forum_id, ($mode == 'view'), $show_trace); - - unset($content_array[$ug_id]); - } - - unset($hold_ary[$forum_id]); - } - } - else - { - foreach ($ug_names_ary as $ug_id => $ug_name) - { - if (!isset($hold_ary[$ug_id])) - { - continue; - } - - $content_array = $categories = array(); - $this->build_permission_array($hold_ary[$ug_id], $content_array, $categories, array_keys($forum_names_ary)); - - $template->assign_block_vars($tpl_pmask, array( - 'NAME' => $ug_name, - 'CATEGORIES' => implode('', $categories), - - 'USER_GROUPS_DEFAULT' => ($user_mode == 'user' && isset($user_groups_default[$ug_id]) && count($user_groups_default[$ug_id])) ? implode($user->lang['COMMA_SEPARATOR'], $user_groups_default[$ug_id]) : '', - 'USER_GROUPS_CUSTOM' => ($user_mode == 'user' && isset($user_groups_custom[$ug_id]) && count($user_groups_custom[$ug_id])) ? implode($user->lang['COMMA_SEPARATOR'], $user_groups_custom[$ug_id]) : '', - 'L_ACL_TYPE' => $l_acl_type, - - 'S_LOCAL' => ($local) ? true : false, - 'S_GLOBAL' => (!$local) ? true : false, - 'S_NUM_CATS' => count($categories), - 'S_VIEW' => ($mode == 'view') ? true : false, - 'S_NUM_OBJECTS' => count($content_array), - 'S_USER_MODE' => ($user_mode == 'user') ? true : false, - 'S_GROUP_MODE' => ($user_mode == 'group') ? true : false) - ); - - foreach ($content_array as $forum_id => $forum_array) - { - // Build role dropdown options - $current_role_id = (isset($cur_roles[$ug_id][$forum_id])) ? $cur_roles[$ug_id][$forum_id] : 0; - - $role_options = array(); - - $current_role_id = (isset($cur_roles[$ug_id][$forum_id])) ? $cur_roles[$ug_id][$forum_id] : 0; - $s_role_options = ''; - - foreach ($roles as $role_id => $role_row) - { - $role_description = (!empty($user->lang[$role_row['role_description']])) ? $user->lang[$role_row['role_description']] : nl2br($role_row['role_description']); - $role_name = (!empty($user->lang[$role_row['role_name']])) ? $user->lang[$role_row['role_name']] : $role_row['role_name']; - - $title = ($role_description) ? ' title="' . $role_description . '"' : ''; - $s_role_options .= ''; - - $role_options[] = array( - 'ID' => $role_id, - 'ROLE_NAME' => $role_name, - 'TITLE' => $role_description, - 'SELECTED' => $role_id == $current_role_id, - ); - } - - if ($s_role_options) - { - $s_role_options = '' . $s_role_options; - } - - if (!$current_role_id && $mode != 'view') - { - $s_custom_permissions = false; - - foreach ($forum_array as $key => $value) - { - if ($value['S_NEVER'] || $value['S_YES']) - { - $s_custom_permissions = true; - break; - } - } - } - else - { - $s_custom_permissions = false; - } - - $template->assign_block_vars($tpl_pmask . '.' . $tpl_fmask, array( - 'NAME' => ($forum_id == 0) ? $forum_names_ary[0] : $forum_names_ary[$forum_id]['forum_name'], - 'PADDING' => ($forum_id == 0) ? '' : $forum_names_ary[$forum_id]['padding'], - 'S_CUSTOM' => $s_custom_permissions, - 'UG_ID' => $ug_id, - 'S_ROLE_OPTIONS' => $s_role_options, - 'FORUM_ID' => $forum_id) - ); - - $template->assign_block_vars_array($tpl_pmask . '.' . $tpl_fmask . '.role_options', $role_options); - - $this->assign_cat_array($forum_array, $tpl_pmask . '.' . $tpl_fmask . '.' . $tpl_category, $tpl_mask, $ug_id, $forum_id, ($mode == 'view'), $show_trace); - } - - unset($hold_ary[$ug_id], $ug_names_ary[$ug_id]); - } - } - } - - /** - * Display permission mask for roles - */ - function display_role_mask(&$hold_ary) - { - global $db, $template, $user, $phpbb_root_path, $phpEx; - global $phpbb_container; - - if (!count($hold_ary)) - { - return; - } - - /** @var \phpbb\group\helper $group_helper */ - $group_helper = $phpbb_container->get('group_helper'); - - // Get forum names - $sql = 'SELECT forum_id, forum_name - FROM ' . FORUMS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', array_keys($hold_ary)) . ' - ORDER BY left_id'; - $result = $db->sql_query($sql); - - // If the role is used globally, then reflect that - $forum_names = (isset($hold_ary[0])) ? array(0 => '') : array(); - while ($row = $db->sql_fetchrow($result)) - { - $forum_names[$row['forum_id']] = $row['forum_name']; - } - $db->sql_freeresult($result); - - foreach ($forum_names as $forum_id => $forum_name) - { - $auth_ary = $hold_ary[$forum_id]; - - $template->assign_block_vars('role_mask', array( - 'NAME' => ($forum_id == 0) ? $user->lang['GLOBAL_MASK'] : $forum_name, - 'FORUM_ID' => $forum_id) - ); - - if (isset($auth_ary['users']) && count($auth_ary['users'])) - { - $sql = 'SELECT user_id, username - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('user_id', $auth_ary['users']) . ' - ORDER BY username_clean ASC'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $template->assign_block_vars('role_mask.users', array( - 'USER_ID' => $row['user_id'], - 'USERNAME' => get_username_string('username', $row['user_id'], $row['username']), - 'U_PROFILE' => get_username_string('profile', $row['user_id'], $row['username']), - )); - } - $db->sql_freeresult($result); - } - - if (isset($auth_ary['groups']) && count($auth_ary['groups'])) - { - $sql = 'SELECT group_id, group_name, group_type - FROM ' . GROUPS_TABLE . ' - WHERE ' . $db->sql_in_set('group_id', $auth_ary['groups']) . ' - ORDER BY group_type ASC, group_name'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $template->assign_block_vars('role_mask.groups', array( - 'GROUP_ID' => $row['group_id'], - 'GROUP_NAME' => $group_helper->get_name($row['group_name']), - 'U_PROFILE' => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=group&g={$row['group_id']}")) - ); - } - $db->sql_freeresult($result); - } - } - } - - /** - * NOTE: this function is not in use atm - * Add a new option to the list ... $options is a hash of form -> - * $options = array( - * 'local' => array('option1', 'option2', ...), - * 'global' => array('optionA', 'optionB', ...) - * ); - */ - function acl_add_option($options) - { - global $db, $cache; - - if (!is_array($options)) - { - return false; - } - - $cur_options = array(); - - // Determine current options - $sql = 'SELECT auth_option, is_global, is_local - FROM ' . ACL_OPTIONS_TABLE . ' - ORDER BY auth_option_id'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $cur_options[$row['auth_option']] = ($row['is_global'] && $row['is_local']) ? 'both' : (($row['is_global']) ? 'global' : 'local'); - } - $db->sql_freeresult($result); - - // Here we need to insert new options ... this requires discovering whether - // an options is global, local or both and whether we need to add an permission - // set flag (x_) - $new_options = array('local' => array(), 'global' => array()); - - foreach ($options as $type => $option_ary) - { - $option_ary = array_unique($option_ary); - - foreach ($option_ary as $option_value) - { - $new_options[$type][] = $option_value; - - $flag = substr($option_value, 0, strpos($option_value, '_') + 1); - - if (!in_array($flag, $new_options[$type])) - { - $new_options[$type][] = $flag; - } - } - } - unset($options); - - $options = array(); - $options['local'] = array_diff($new_options['local'], $new_options['global']); - $options['global'] = array_diff($new_options['global'], $new_options['local']); - $options['both'] = array_intersect($new_options['local'], $new_options['global']); - - // Now check which options to add/update - $add_options = $update_options = array(); - - // First local ones... - foreach ($options as $type => $option_ary) - { - foreach ($option_ary as $option) - { - if (!isset($cur_options[$option])) - { - $add_options[] = array( - 'auth_option' => (string) $option, - 'is_global' => ($type == 'global' || $type == 'both') ? 1 : 0, - 'is_local' => ($type == 'local' || $type == 'both') ? 1 : 0 - ); - - continue; - } - - // Else, update existing entry if it is changed... - if ($type === $cur_options[$option]) - { - continue; - } - - // New type is always both: - // If is now both, we set both. - // If it was global the new one is local and we need to set it to both - // If it was local the new one is global and we need to set it to both - $update_options[] = $option; - } - } - - if (!empty($add_options)) - { - $db->sql_multi_insert(ACL_OPTIONS_TABLE, $add_options); - } - - if (!empty($update_options)) - { - $sql = 'UPDATE ' . ACL_OPTIONS_TABLE . ' - SET is_global = 1, is_local = 1 - WHERE ' . $db->sql_in_set('auth_option', $update_options); - $db->sql_query($sql); - } - - $cache->destroy('_acl_options'); - $this->acl_clear_prefetch(); - - // Because we just changed the options and also purged the options cache, we instantly update/regenerate it for later calls to succeed. - $this->acl_options = array(); - $this->__construct(); - - return true; - } - - /** - * Set a user or group ACL record - */ - function acl_set($ug_type, $forum_id, $ug_id, $auth, $role_id = 0, $clear_prefetch = true) - { - global $db; - - // One or more forums - if (!is_array($forum_id)) - { - $forum_id = array($forum_id); - } - - // One or more users - if (!is_array($ug_id)) - { - $ug_id = array($ug_id); - } - - $ug_id_sql = $db->sql_in_set($ug_type . '_id', array_map('intval', $ug_id)); - $forum_sql = $db->sql_in_set('forum_id', array_map('intval', $forum_id)); - - // Instead of updating, inserting, removing we just remove all current settings and re-set everything... - $table = ($ug_type == 'user') ? ACL_USERS_TABLE : ACL_GROUPS_TABLE; - $id_field = $ug_type . '_id'; - - // Get any flags as required - reset($auth); - $flag = key($auth); - $flag = substr($flag, 0, strpos($flag, '_') + 1); - - // This ID (the any-flag) is set if one or more permissions are true... - $any_option_id = (int) $this->acl_options['id'][$flag]; - - // Remove any-flag from auth ary - if (isset($auth[$flag])) - { - unset($auth[$flag]); - } - - // Remove current auth options... - $auth_option_ids = array((int) $any_option_id); - foreach ($auth as $auth_option => $auth_setting) - { - $auth_option_ids[] = (int) $this->acl_options['id'][$auth_option]; - } - - $sql = "DELETE FROM $table - WHERE $forum_sql - AND $ug_id_sql - AND " . $db->sql_in_set('auth_option_id', $auth_option_ids); - $db->sql_query($sql); - - // Remove those having a role assigned... the correct type of course... - $sql = 'SELECT role_id - FROM ' . ACL_ROLES_TABLE . " - WHERE role_type = '" . $db->sql_escape($flag) . "'"; - $result = $db->sql_query($sql); - - $role_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $role_ids[] = $row['role_id']; - } - $db->sql_freeresult($result); - - if (count($role_ids)) - { - $sql = "DELETE FROM $table - WHERE $forum_sql - AND $ug_id_sql - AND auth_option_id = 0 - AND " . $db->sql_in_set('auth_role_id', $role_ids); - $db->sql_query($sql); - } - - // Ok, include the any-flag if one or more auth options are set to yes... - foreach ($auth as $auth_option => $setting) - { - if ($setting == ACL_YES && (!isset($auth[$flag]) || $auth[$flag] == ACL_NEVER)) - { - $auth[$flag] = ACL_YES; - } - } - - $sql_ary = array(); - foreach ($forum_id as $forum) - { - $forum = (int) $forum; - - if ($role_id) - { - foreach ($ug_id as $id) - { - $sql_ary[] = array( - $id_field => (int) $id, - 'forum_id' => (int) $forum, - 'auth_option_id' => 0, - 'auth_setting' => 0, - 'auth_role_id' => (int) $role_id, - ); - } - } - else - { - foreach ($auth as $auth_option => $setting) - { - $auth_option_id = (int) $this->acl_options['id'][$auth_option]; - - if ($setting != ACL_NO) - { - foreach ($ug_id as $id) - { - $sql_ary[] = array( - $id_field => (int) $id, - 'forum_id' => (int) $forum, - 'auth_option_id' => (int) $auth_option_id, - 'auth_setting' => (int) $setting - ); - } - } - } - } - } - - $db->sql_multi_insert($table, $sql_ary); - - if ($clear_prefetch) - { - $this->acl_clear_prefetch(); - } - } - - /** - * Set a role-specific ACL record - */ - function acl_set_role($role_id, $auth) - { - global $db; - - // Get any-flag as required - reset($auth); - $flag = key($auth); - $flag = substr($flag, 0, strpos($flag, '_') + 1); - - // Remove any-flag from auth ary - if (isset($auth[$flag])) - { - unset($auth[$flag]); - } - - // Re-set any flag... - foreach ($auth as $auth_option => $setting) - { - if ($setting == ACL_YES && (!isset($auth[$flag]) || $auth[$flag] == ACL_NEVER)) - { - $auth[$flag] = ACL_YES; - } - } - - $sql_ary = array(); - foreach ($auth as $auth_option => $setting) - { - $auth_option_id = (int) $this->acl_options['id'][$auth_option]; - - if ($setting != ACL_NO) - { - $sql_ary[] = array( - 'role_id' => (int) $role_id, - 'auth_option_id' => (int) $auth_option_id, - 'auth_setting' => (int) $setting - ); - } - } - - // If no data is there, we set the any-flag to ACL_NEVER... - if (!count($sql_ary)) - { - $sql_ary[] = array( - 'role_id' => (int) $role_id, - 'auth_option_id' => (int) $this->acl_options['id'][$flag], - 'auth_setting' => ACL_NEVER - ); - } - - // Remove current auth options... - $sql = 'DELETE FROM ' . ACL_ROLES_DATA_TABLE . ' - WHERE role_id = ' . $role_id; - $db->sql_query($sql); - - // Now insert the new values - $db->sql_multi_insert(ACL_ROLES_DATA_TABLE, $sql_ary); - - $this->acl_clear_prefetch(); - } - - /** - * Remove local permission - */ - function acl_delete($mode, $ug_id = false, $forum_id = false, $permission_type = false) - { - global $db; - - if ($ug_id === false && $forum_id === false) - { - return; - } - - $option_id_ary = array(); - $table = ($mode == 'user') ? ACL_USERS_TABLE : ACL_GROUPS_TABLE; - $id_field = $mode . '_id'; - - $where_sql = array(); - - if ($forum_id !== false) - { - $where_sql[] = (!is_array($forum_id)) ? 'forum_id = ' . (int) $forum_id : $db->sql_in_set('forum_id', array_map('intval', $forum_id)); - } - - if ($ug_id !== false) - { - $where_sql[] = (!is_array($ug_id)) ? $id_field . ' = ' . (int) $ug_id : $db->sql_in_set($id_field, array_map('intval', $ug_id)); - } - - // There seem to be auth options involved, therefore we need to go through the list and make sure we capture roles correctly - if ($permission_type !== false) - { - // Get permission type - $sql = 'SELECT auth_option, auth_option_id - FROM ' . ACL_OPTIONS_TABLE . " - WHERE auth_option " . $db->sql_like_expression($permission_type . $db->get_any_char()); - $result = $db->sql_query($sql); - - $auth_id_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - $option_id_ary[] = $row['auth_option_id']; - $auth_id_ary[$row['auth_option']] = ACL_NO; - } - $db->sql_freeresult($result); - - // First of all, lets grab the items having roles with the specified auth options assigned - $sql = "SELECT auth_role_id, $id_field, forum_id - FROM $table, " . ACL_ROLES_TABLE . " r - WHERE auth_role_id <> 0 - AND auth_role_id = r.role_id - AND r.role_type = '{$permission_type}' - AND " . implode(' AND ', $where_sql) . ' - ORDER BY auth_role_id'; - $result = $db->sql_query($sql); - - $cur_role_auth = array(); - while ($row = $db->sql_fetchrow($result)) - { - $cur_role_auth[$row['auth_role_id']][$row['forum_id']][] = $row[$id_field]; - } - $db->sql_freeresult($result); - - // Get role data for resetting data - if (count($cur_role_auth)) - { - $sql = 'SELECT ao.auth_option, rd.role_id, rd.auth_setting - FROM ' . ACL_OPTIONS_TABLE . ' ao, ' . ACL_ROLES_DATA_TABLE . ' rd - WHERE ao.auth_option_id = rd.auth_option_id - AND ' . $db->sql_in_set('rd.role_id', array_keys($cur_role_auth)); - $result = $db->sql_query($sql); - - $auth_settings = array(); - while ($row = $db->sql_fetchrow($result)) - { - // We need to fill all auth_options, else setting it will fail... - if (!isset($auth_settings[$row['role_id']])) - { - $auth_settings[$row['role_id']] = $auth_id_ary; - } - $auth_settings[$row['role_id']][$row['auth_option']] = $row['auth_setting']; - } - $db->sql_freeresult($result); - - // Set the options - foreach ($cur_role_auth as $role_id => $auth_row) - { - foreach ($auth_row as $f_id => $ug_row) - { - $this->acl_set($mode, $f_id, $ug_row, $auth_settings[$role_id], 0, false); - } - } - } - } - - // Now, normally remove permissions... - if ($permission_type !== false) - { - $where_sql[] = $db->sql_in_set('auth_option_id', array_map('intval', $option_id_ary)); - } - - $sql = "DELETE FROM $table - WHERE " . implode(' AND ', $where_sql); - $db->sql_query($sql); - - $this->acl_clear_prefetch(); - } - - /** - * Assign category to template - * used by display_mask() - */ - function assign_cat_array(&$category_array, $tpl_cat, $tpl_mask, $ug_id, $forum_id, $s_view, $show_trace = false) - { - global $template, $phpbb_admin_path, $phpEx, $phpbb_container; - - /* @var $phpbb_permissions \phpbb\permissions */ - $phpbb_permissions = $phpbb_container->get('acl.permissions'); - - foreach ($category_array as $cat => $cat_array) - { - if (!$phpbb_permissions->category_defined($cat)) - { - continue; - } - - $template->assign_block_vars($tpl_cat, array( - 'S_YES' => ($cat_array['S_YES'] && !$cat_array['S_NEVER'] && !$cat_array['S_NO']) ? true : false, - 'S_NEVER' => ($cat_array['S_NEVER'] && !$cat_array['S_YES'] && !$cat_array['S_NO']) ? true : false, - 'S_NO' => ($cat_array['S_NO'] && !$cat_array['S_NEVER'] && !$cat_array['S_YES']) ? true : false, - - 'CAT_NAME' => $phpbb_permissions->get_category_lang($cat), - )); - - /* Sort permissions by name (more naturaly and user friendly than sorting by a primary key) - * Commented out due to it's memory consumption and time needed - * - $key_array = array_intersect(array_keys($user->lang), array_map(create_function('$a', 'return "acl_" . $a;'), array_keys($cat_array['permissions']))); - $values_array = $cat_array['permissions']; - - $cat_array['permissions'] = array(); - - foreach ($key_array as $key) - { - $key = str_replace('acl_', '', $key); - $cat_array['permissions'][$key] = $values_array[$key]; - } - unset($key_array, $values_array); -*/ - foreach ($cat_array['permissions'] as $permission => $allowed) - { - if (!$phpbb_permissions->permission_defined($permission)) - { - continue; - } - - if ($s_view) - { - $template->assign_block_vars($tpl_cat . '.' . $tpl_mask, array( - 'S_YES' => ($allowed == ACL_YES) ? true : false, - 'S_NEVER' => ($allowed == ACL_NEVER) ? true : false, - - 'UG_ID' => $ug_id, - 'FORUM_ID' => $forum_id, - 'FIELD_NAME' => $permission, - 'S_FIELD_NAME' => 'setting[' . $ug_id . '][' . $forum_id . '][' . $permission . ']', - - 'U_TRACE' => ($show_trace) ? append_sid("{$phpbb_admin_path}index.$phpEx", "i=permissions&mode=trace&u=$ug_id&f=$forum_id&auth=$permission") : '', - 'UA_TRACE' => ($show_trace) ? append_sid("{$phpbb_admin_path}index.$phpEx", "i=permissions&mode=trace&u=$ug_id&f=$forum_id&auth=$permission", false) : '', - - 'PERMISSION' => $phpbb_permissions->get_permission_lang($permission), - )); - } - else - { - $template->assign_block_vars($tpl_cat . '.' . $tpl_mask, array( - 'S_YES' => ($allowed == ACL_YES) ? true : false, - 'S_NEVER' => ($allowed == ACL_NEVER) ? true : false, - 'S_NO' => ($allowed == ACL_NO) ? true : false, - - 'UG_ID' => $ug_id, - 'FORUM_ID' => $forum_id, - 'FIELD_NAME' => $permission, - 'S_FIELD_NAME' => 'setting[' . $ug_id . '][' . $forum_id . '][' . $permission . ']', - - 'U_TRACE' => ($show_trace) ? append_sid("{$phpbb_admin_path}index.$phpEx", "i=permissions&mode=trace&u=$ug_id&f=$forum_id&auth=$permission") : '', - 'UA_TRACE' => ($show_trace) ? append_sid("{$phpbb_admin_path}index.$phpEx", "i=permissions&mode=trace&u=$ug_id&f=$forum_id&auth=$permission", false) : '', - - 'PERMISSION' => $phpbb_permissions->get_permission_lang($permission), - )); - } - } - } - } - - /** - * Building content array from permission rows with explicit key ordering - * used by display_mask() - */ - function build_permission_array(&$permission_row, &$content_array, &$categories, $key_sort_array) - { - global $phpbb_container; - - /* @var $phpbb_permissions \phpbb\permissions */ - $phpbb_permissions = $phpbb_container->get('acl.permissions'); - - foreach ($key_sort_array as $forum_id) - { - if (!isset($permission_row[$forum_id])) - { - continue; - } - - $permissions = $permission_row[$forum_id]; - ksort($permissions); - - foreach ($permissions as $permission => $auth_setting) - { - $cat = $phpbb_permissions->get_permission_category($permission); - - // Build our categories array - if (!isset($categories[$cat])) - { - $categories[$cat] = $phpbb_permissions->get_category_lang($cat); - } - - // Build our content array - if (!isset($content_array[$forum_id])) - { - $content_array[$forum_id] = array(); - } - - if (!isset($content_array[$forum_id][$cat])) - { - $content_array[$forum_id][$cat] = array( - 'S_YES' => false, - 'S_NEVER' => false, - 'S_NO' => false, - 'permissions' => array(), - ); - } - - $content_array[$forum_id][$cat]['S_YES'] |= ($auth_setting == ACL_YES) ? true : false; - $content_array[$forum_id][$cat]['S_NEVER'] |= ($auth_setting == ACL_NEVER) ? true : false; - $content_array[$forum_id][$cat]['S_NO'] |= ($auth_setting == ACL_NO) ? true : false; - - $content_array[$forum_id][$cat]['permissions'][$permission] = $auth_setting; - } - } - } - - /** - * Use permissions from another user. This transferes a permission set from one user to another. - * The other user is always able to revert back to his permission set. - * This function does not check for lower/higher permissions, it is possible for the user to gain - * "more" permissions by this. - * Admin permissions will not be copied. - */ - function ghost_permissions($from_user_id, $to_user_id) - { - global $db; - - if ($to_user_id == ANONYMOUS) - { - return false; - } - - $hold_ary = $this->acl_raw_data_single_user($from_user_id); - - // Key 0 in $hold_ary are global options, all others are forum_ids - - // We disallow copying admin permissions - foreach ($this->acl_options['global'] as $opt => $id) - { - if (strpos($opt, 'a_') === 0) - { - $hold_ary[0][$this->acl_options['id'][$opt]] = ACL_NEVER; - } - } - - // Force a_switchperm to be allowed - $hold_ary[0][$this->acl_options['id']['a_switchperm']] = ACL_YES; - - $user_permissions = $this->build_bitstring($hold_ary); - - if (!$user_permissions) - { - return false; - } - - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_permissions = '" . $db->sql_escape($user_permissions) . "', - user_perm_from = $from_user_id - WHERE user_id = " . $to_user_id; - $db->sql_query($sql); - - return true; - } -} diff --git a/install/update/new/includes/bbcode.php b/install/update/new/includes/bbcode.php deleted file mode 100644 index 21c630d..0000000 --- a/install/update/new/includes/bbcode.php +++ /dev/null @@ -1,707 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* BBCode class -*/ -class bbcode -{ - var $bbcode_uid = ''; - var $bbcode_bitfield = ''; - var $bbcode_cache = array(); - var $bbcode_template = array(); - - var $bbcodes = array(); - - var $template_bitfield; - - /** - * Constructor - */ - function __construct($bitfield = '') - { - $this->bbcode_set_bitfield($bitfield); - } - - /** - * Init bbcode cache entries if bitfield is specified - * - * @param string $bitfield The bbcode bitfield - */ - function bbcode_set_bitfield($bitfield = '') - { - if ($bitfield) - { - $this->bbcode_bitfield = $bitfield; - $this->bbcode_cache_init(); - } - } - - /** - * Second pass bbcodes - */ - function bbcode_second_pass(&$message, $bbcode_uid = '', $bbcode_bitfield = false) - { - if ($bbcode_uid) - { - $this->bbcode_uid = $bbcode_uid; - } - - if ($bbcode_bitfield !== false) - { - $this->bbcode_bitfield = $bbcode_bitfield; - - // Init those added with a new bbcode_bitfield (already stored codes will not get parsed again) - $this->bbcode_cache_init(); - } - - if (!$this->bbcode_bitfield) - { - // Remove the uid from tags that have not been transformed into HTML - if ($this->bbcode_uid) - { - $message = str_replace(':' . $this->bbcode_uid, '', $message); - } - - return; - } - - $str = array('search' => array(), 'replace' => array()); - $preg = array('search' => array(), 'replace' => array()); - - $bitfield = new bitfield($this->bbcode_bitfield); - $bbcodes_set = $bitfield->get_all_set(); - - $undid_bbcode_specialchars = false; - foreach ($bbcodes_set as $bbcode_id) - { - if (!empty($this->bbcode_cache[$bbcode_id])) - { - foreach ($this->bbcode_cache[$bbcode_id] as $type => $array) - { - foreach ($array as $search => $replace) - { - ${$type}['search'][] = str_replace('$uid', $this->bbcode_uid, $search); - ${$type}['replace'][] = $replace; - } - - if (count($str['search'])) - { - $message = str_replace($str['search'], $str['replace'], $message); - $str = array('search' => array(), 'replace' => array()); - } - - if (count($preg['search'])) - { - // we need to turn the entities back into their original form to allow the - // search patterns to work properly - if (!$undid_bbcode_specialchars) - { - $message = str_replace(array(':', '.'), array(':', '.'), $message); - $undid_bbcode_specialchars = true; - } - - foreach ($preg['search'] as $key => $search) - { - if (is_callable($preg['replace'][$key])) - { - $message = preg_replace_callback($search, $preg['replace'][$key], $message); - } - else - { - $message = preg_replace($search, $preg['replace'][$key], $message); - } - } - - $preg = array('search' => array(), 'replace' => array()); - } - } - } - } - - // Remove the uid from tags that have not been transformed into HTML - $message = str_replace(':' . $this->bbcode_uid, '', $message); - } - - /** - * Init bbcode cache - * - * requires: $this->bbcode_bitfield - * sets: $this->bbcode_cache with bbcode templates needed for bbcode_bitfield - */ - function bbcode_cache_init() - { - global $user, $phpbb_dispatcher, $phpbb_extension_manager, $phpbb_container, $phpbb_filesystem; - - if (empty($this->template_filename)) - { - $this->template_bitfield = new bitfield($user->style['bbcode_bitfield']); - - $template = new \phpbb\template\twig\twig( - $phpbb_container->get('path_helper'), - $phpbb_container->get('config'), - new \phpbb\template\context(), - new \phpbb\template\twig\environment( - $phpbb_container->get('config'), - $phpbb_container->get('filesystem'), - $phpbb_container->get('path_helper'), - $phpbb_container->getParameter('core.cache_dir'), - $phpbb_container->get('ext.manager'), - new \phpbb\template\twig\loader( - $phpbb_filesystem - ) - ), - $phpbb_container->getParameter('core.cache_dir'), - $phpbb_container->get('user'), - $phpbb_container->get('template.twig.extensions.collection'), - $phpbb_extension_manager - ); - - $template->set_style(); - $template->set_filenames(array('bbcode.html' => 'bbcode.html')); - $this->template_filename = $template->get_source_file_for_handle('bbcode.html'); - } - - $bbcode_ids = $rowset = $sql = array(); - - $bitfield = new bitfield($this->bbcode_bitfield); - $bbcodes_set = $bitfield->get_all_set(); - - foreach ($bbcodes_set as $bbcode_id) - { - if (isset($this->bbcode_cache[$bbcode_id])) - { - // do not try to re-cache it if it's already in - continue; - } - $bbcode_ids[] = $bbcode_id; - - if ($bbcode_id > NUM_CORE_BBCODES) - { - $sql[] = $bbcode_id; - } - } - - if (count($sql)) - { - global $db; - - $sql = 'SELECT * - FROM ' . BBCODES_TABLE . ' - WHERE ' . $db->sql_in_set('bbcode_id', $sql); - $result = $db->sql_query($sql, 3600); - - while ($row = $db->sql_fetchrow($result)) - { - // To circumvent replacing newlines with
for the generated html, - // we use carriage returns here. They are later changed back to newlines - $row['bbcode_tpl'] = str_replace("\n", "\r", $row['bbcode_tpl']); - $row['second_pass_replace'] = str_replace("\n", "\r", $row['second_pass_replace']); - - $rowset[$row['bbcode_id']] = $row; - } - $db->sql_freeresult($result); - } - - // To perform custom second pass in extension, use $this->bbcode_second_pass_by_extension() - // method which accepts variable number of parameters - foreach ($bbcode_ids as $bbcode_id) - { - switch ($bbcode_id) - { - case BBCODE_ID_QUOTE: - $this->bbcode_cache[$bbcode_id] = array( - 'str' => array( - '[/quote:$uid]' => $this->bbcode_tpl('quote_close', $bbcode_id) - ), - 'preg' => array( - '#\[quote(?:="(.*?)")?:$uid\]((?!\[quote(?:=".*?")?:$uid\]).)?#is' => function ($match) { - if (!isset($match[2])) - { - $match[2] = ''; - } - - return $this->bbcode_second_pass_quote($match[1], $match[2]); - }, - ) - ); - break; - - case BBCODE_ID_B: - $this->bbcode_cache[$bbcode_id] = array( - 'str' => array( - '[b:$uid]' => $this->bbcode_tpl('b_open', $bbcode_id), - '[/b:$uid]' => $this->bbcode_tpl('b_close', $bbcode_id), - ) - ); - break; - - case BBCODE_ID_I: - $this->bbcode_cache[$bbcode_id] = array( - 'str' => array( - '[i:$uid]' => $this->bbcode_tpl('i_open', $bbcode_id), - '[/i:$uid]' => $this->bbcode_tpl('i_close', $bbcode_id), - ) - ); - break; - - case BBCODE_ID_URL: - $this->bbcode_cache[$bbcode_id] = array( - 'preg' => array( - '#\[url:$uid\]((.*?))\[/url:$uid\]#s' => $this->bbcode_tpl('url', $bbcode_id), - '#\[url=([^\[]+?):$uid\](.*?)\[/url:$uid\]#s' => $this->bbcode_tpl('url', $bbcode_id), - ) - ); - break; - - case BBCODE_ID_IMG: - if ($user->optionget('viewimg')) - { - $this->bbcode_cache[$bbcode_id] = array( - 'preg' => array( - '#\[img:$uid\](.*?)\[/img:$uid\]#s' => $this->bbcode_tpl('img', $bbcode_id), - ) - ); - } - else - { - $this->bbcode_cache[$bbcode_id] = array( - 'preg' => array( - '#\[img:$uid\](.*?)\[/img:$uid\]#s' => str_replace('$2', '[ img ]', $this->bbcode_tpl('url', $bbcode_id, true)), - ) - ); - } - break; - - case BBCODE_ID_SIZE: - $this->bbcode_cache[$bbcode_id] = array( - 'preg' => array( - '#\[size=([\-\+]?\d+):$uid\](.*?)\[/size:$uid\]#s' => $this->bbcode_tpl('size', $bbcode_id), - ) - ); - break; - - case BBCODE_ID_COLOR: - $this->bbcode_cache[$bbcode_id] = array( - 'preg' => array( - '!\[color=(#[0-9a-f]{3}|#[0-9a-f]{6}|[a-z\-]+):$uid\](.*?)\[/color:$uid\]!is' => $this->bbcode_tpl('color', $bbcode_id), - ) - ); - break; - - case BBCODE_ID_U: - $this->bbcode_cache[$bbcode_id] = array( - 'str' => array( - '[u:$uid]' => $this->bbcode_tpl('u_open', $bbcode_id), - '[/u:$uid]' => $this->bbcode_tpl('u_close', $bbcode_id), - ) - ); - break; - - case BBCODE_ID_CODE: - $this->bbcode_cache[$bbcode_id] = array( - 'preg' => array( - '#\[code(?:=([a-z]+))?:$uid\](.*?)\[/code:$uid\]#is' => function ($match) { - return $this->bbcode_second_pass_code($match[1], $match[2]); - }, - ) - ); - break; - - case BBCODE_ID_LIST: - $this->bbcode_cache[$bbcode_id] = array( - 'preg' => array( - '#(\[\/?(list|\*):[mou]?:?$uid\])[\n]{1}#' => "\$1", - '#(\[list=([^\[]+):$uid\])[\n]{1}#' => "\$1", - '#\[list=([^\[]+):$uid\]#' => function ($match) { - return $this->bbcode_list($match[1]); - }, - ), - 'str' => array( - '[list:$uid]' => $this->bbcode_tpl('ulist_open_default', $bbcode_id), - '[/list:u:$uid]' => $this->bbcode_tpl('ulist_close', $bbcode_id), - '[/list:o:$uid]' => $this->bbcode_tpl('olist_close', $bbcode_id), - '[*:$uid]' => $this->bbcode_tpl('listitem', $bbcode_id), - '[/*:$uid]' => $this->bbcode_tpl('listitem_close', $bbcode_id), - '[/*:m:$uid]' => $this->bbcode_tpl('listitem_close', $bbcode_id) - ), - ); - break; - - case BBCODE_ID_EMAIL: - $this->bbcode_cache[$bbcode_id] = array( - 'preg' => array( - '#\[email:$uid\]((.*?))\[/email:$uid\]#is' => $this->bbcode_tpl('email', $bbcode_id), - '#\[email=([^\[]+):$uid\](.*?)\[/email:$uid\]#is' => $this->bbcode_tpl('email', $bbcode_id) - ) - ); - break; - - case BBCODE_ID_FLASH: - if ($user->optionget('viewflash')) - { - $this->bbcode_cache[$bbcode_id] = array( - 'preg' => array( - '#\[flash=([0-9]+),([0-9]+):$uid\](.*?)\[/flash:$uid\]#' => $this->bbcode_tpl('flash', $bbcode_id), - ) - ); - } - else - { - $this->bbcode_cache[$bbcode_id] = array( - 'preg' => array( - '#\[flash=([0-9]+),([0-9]+):$uid\](.*?)\[/flash:$uid\]#' => str_replace('$1', '$3', str_replace('$2', '[ flash ]', $this->bbcode_tpl('url', $bbcode_id, true))) - ) - ); - } - break; - - case BBCODE_ID_ATTACH: - $this->bbcode_cache[$bbcode_id] = array( - 'str' => array( - '[/attachment:$uid]' => $this->bbcode_tpl('inline_attachment_close', $bbcode_id) - ), - 'preg' => array( - '#\[attachment=([0-9]+):$uid\]#' => $this->bbcode_tpl('inline_attachment_open', $bbcode_id) - ) - ); - break; - - default: - if (isset($rowset[$bbcode_id])) - { - if ($this->template_bitfield->get($bbcode_id)) - { - // The bbcode requires a custom template to be loaded - if (!$bbcode_tpl = $this->bbcode_tpl($rowset[$bbcode_id]['bbcode_tag'], $bbcode_id)) - { - // For some reason, the required template seems not to be available, use the default template - $bbcode_tpl = (!empty($rowset[$bbcode_id]['second_pass_replace'])) ? $rowset[$bbcode_id]['second_pass_replace'] : $rowset[$bbcode_id]['bbcode_tpl']; - } - else - { - // In order to use templates with custom bbcodes we need - // to replace all {VARS} to corresponding backreferences - // Note that backreferences are numbered from bbcode_match - if (preg_match_all('/\{(URL|LOCAL_URL|EMAIL|TEXT|SIMPLETEXT|INTTEXT|IDENTIFIER|COLOR|NUMBER)[0-9]*\}/', $rowset[$bbcode_id]['bbcode_match'], $m)) - { - foreach ($m[0] as $i => $tok) - { - $bbcode_tpl = str_replace($tok, '$' . ($i + 1), $bbcode_tpl); - } - } - } - } - else - { - // Default template - $bbcode_tpl = (!empty($rowset[$bbcode_id]['second_pass_replace'])) ? $rowset[$bbcode_id]['second_pass_replace'] : $rowset[$bbcode_id]['bbcode_tpl']; - } - - // Replace {L_*} lang strings - $bbcode_tpl = preg_replace_callback('/{L_([A-Z0-9_]+)}/', function ($match) use ($user) { - return (!empty($user->lang[$match[1]])) ? $user->lang($match[1]) : ucwords(strtolower(str_replace('_', ' ', $match[1]))); - }, $bbcode_tpl); - - if (!empty($rowset[$bbcode_id]['second_pass_replace'])) - { - // The custom BBCode requires second-pass pattern replacements - $this->bbcode_cache[$bbcode_id] = array( - 'preg' => array($rowset[$bbcode_id]['second_pass_match'] => $bbcode_tpl) - ); - } - else - { - $this->bbcode_cache[$bbcode_id] = array( - 'str' => array($rowset[$bbcode_id]['second_pass_match'] => $bbcode_tpl) - ); - } - } - else - { - $this->bbcode_cache[$bbcode_id] = false; - } - break; - } - } - - $bbcode_cache = $this->bbcode_cache; - $bbcode_bitfield = $this->bbcode_bitfield; - $bbcode_uid = $this->bbcode_uid; - - /** - * Use this event to modify the bbcode_cache - * - * @event core.bbcode_cache_init_end - * @var array bbcode_cache The array of cached search and replace patterns of bbcodes - * @var string bbcode_bitfield The bbcode bitfield - * @var string bbcode_uid The bbcode uid - * @since 3.1.3-RC1 - */ - $vars = array('bbcode_cache', 'bbcode_bitfield', 'bbcode_uid'); - extract($phpbb_dispatcher->trigger_event('core.bbcode_cache_init_end', compact($vars))); - - $this->bbcode_cache = $bbcode_cache; - $this->bbcode_bitfield = $bbcode_bitfield; - $this->bbcode_uid = $bbcode_uid; - } - - /** - * Return bbcode template - */ - function bbcode_tpl($tpl_name, $bbcode_id = -1, $skip_bitfield_check = false) - { - static $bbcode_hardtpl = array(); - if (empty($bbcode_hardtpl)) - { - global $user; - - $bbcode_hardtpl = array( - 'b_open' => '', - 'b_close' => '', - 'i_open' => '', - 'i_close' => '', - 'u_open' => '', - 'u_close' => '', - 'img' => '' . $user->lang['IMAGE'] . '', - 'size' => '$2', - 'color' => '$2', - 'email' => '$2' - ); - } - - if ($bbcode_id != -1 && !$skip_bitfield_check && !$this->template_bitfield->get($bbcode_id)) - { - return (isset($bbcode_hardtpl[$tpl_name])) ? $bbcode_hardtpl[$tpl_name] : false; - } - - if (empty($this->bbcode_template)) - { - if (($tpl = file_get_contents($this->template_filename)) === false) - { - trigger_error('Could not load bbcode template', E_USER_ERROR); - } - - // replace \ with \\ and then ' with \'. - $tpl = str_replace('\\', '\\\\', $tpl); - $tpl = str_replace("'", "\'", $tpl); - - // strip newlines and indent - $tpl = preg_replace("/\n[\n\r\s\t]*/", '', $tpl); - - // Turn template blocks into PHP assignment statements for the values of $bbcode_tpl.. - $this->bbcode_template = array(); - - // Capture the BBCode template matches - // Allow phpBB template or the Twig syntax - $matches = (preg_match_all('#(.*?)#', $tpl, $match)) ?: - preg_match_all('#{% for (.*?) in .*? %}(.*?){% endfor %}#s', $tpl, $match); - - for ($i = 0; $i < $matches; $i++) - { - if (empty($match[1][$i])) - { - continue; - } - - $this->bbcode_template[$match[1][$i]] = $this->bbcode_tpl_replace($match[1][$i], $match[2][$i]); - } - } - - return (isset($this->bbcode_template[$tpl_name])) ? $this->bbcode_template[$tpl_name] : ((isset($bbcode_hardtpl[$tpl_name])) ? $bbcode_hardtpl[$tpl_name] : false); - } - - /** - * Return bbcode template replacement - */ - function bbcode_tpl_replace($tpl_name, $tpl) - { - global $user; - - static $replacements = array( - 'quote_username_open' => array('{USERNAME}' => '$1'), - 'color' => array('{COLOR}' => '$1', '{TEXT}' => '$2'), - 'size' => array('{SIZE}' => '$1', '{TEXT}' => '$2'), - 'img' => array('{URL}' => '$1'), - 'flash' => array('{WIDTH}' => '$1', '{HEIGHT}' => '$2', '{URL}' => '$3'), - 'url' => array('{URL}' => '$1', '{DESCRIPTION}' => '$2'), - 'email' => array('{EMAIL}' => '$1', '{DESCRIPTION}' => '$2') - ); - - $tpl = preg_replace_callback('/{L_([A-Z0-9_]+)}/', function ($match) use ($user) { - return (!empty($user->lang[$match[1]])) ? $user->lang($match[1]) : ucwords(strtolower(str_replace('_', ' ', $match[1]))); - }, $tpl); - - if (!empty($replacements[$tpl_name])) - { - $tpl = strtr($tpl, $replacements[$tpl_name]); - } - - return trim($tpl); - } - - /** - * Second parse list bbcode - */ - function bbcode_list($type) - { - if ($type == '') - { - $tpl = 'ulist_open_default'; - $type = 'default'; - } - else if ($type == 'i') - { - $tpl = 'olist_open'; - $type = 'lower-roman'; - } - else if ($type == 'I') - { - $tpl = 'olist_open'; - $type = 'upper-roman'; - } - else if (preg_match('#^(disc|circle|square)$#i', $type)) - { - $tpl = 'ulist_open'; - $type = strtolower($type); - } - else if (preg_match('#^[a-z]$#', $type)) - { - $tpl = 'olist_open'; - $type = 'lower-alpha'; - } - else if (preg_match('#[A-Z]#', $type)) - { - $tpl = 'olist_open'; - $type = 'upper-alpha'; - } - else if (is_numeric($type)) - { - $tpl = 'olist_open'; - $type = 'decimal'; - } - else - { - $tpl = 'olist_open'; - $type = 'decimal'; - } - - return str_replace('{LIST_TYPE}', $type, $this->bbcode_tpl($tpl)); - } - - /** - * Second parse quote tag - */ - function bbcode_second_pass_quote($username, $quote) - { - // when using the /e modifier, preg_replace slashes double-quotes but does not - // seem to slash anything else - $quote = str_replace('\"', '"', $quote); - $username = str_replace('\"', '"', $username); - - // remove newline at the beginning - if ($quote == "\n") - { - $quote = ''; - } - - $quote = (($username) ? str_replace('$1', $username, $this->bbcode_tpl('quote_username_open')) : $this->bbcode_tpl('quote_open')) . $quote; - - return $quote; - } - - /** - * Second parse code tag - */ - function bbcode_second_pass_code($type, $code) - { - // when using the /e modifier, preg_replace slashes double-quotes but does not - // seem to slash anything else - $code = str_replace('\"', '"', $code); - - switch ($type) - { - case 'php': - // Not the english way, but valid because of hardcoded syntax highlighting - if (strpos($code, '
') === 0) - { - $code = substr($code, 41); - } - - // no break; - - default: - $code = str_replace("\t", '   ', $code); - $code = str_replace(' ', '  ', $code); - $code = str_replace(' ', '  ', $code); - $code = str_replace("\n ", "\n ", $code); - - // keep space at the beginning - if (!empty($code) && $code[0] == ' ') - { - $code = ' ' . substr($code, 1); - } - - // remove newline at the beginning - if (!empty($code) && $code[0] == "\n") - { - $code = substr($code, 1); - } - break; - } - - $code = $this->bbcode_tpl('code_open') . $code . $this->bbcode_tpl('code_close'); - - return $code; - } - - /** - * Function to perform custom bbcode second pass by extensions - * can be used to assign bbcode pattern replacement - * Example: '#\[list=([^\[]+):$uid\]#e' => "\$this->bbcode_second_pass_by_extension('\$1')" - * - * Accepts variable number of parameters - * - * @return mixed Second pass result - */ - function bbcode_second_pass_by_extension() - { - global $phpbb_dispatcher; - - $return = false; - $params_array = func_get_args(); - - /** - * Event to perform bbcode second pass with - * the custom validating methods provided by extensions - * - * @event core.bbcode_second_pass_by_extension - * @var array params_array Array with the function parameters - * @var mixed return Second pass result to return - * - * @since 3.1.5-RC1 - */ - $vars = array('params_array', 'return'); - extract($phpbb_dispatcher->trigger_event('core.bbcode_second_pass_by_extension', compact($vars))); - - return $return; - } -} diff --git a/install/update/new/includes/compatibility_globals.php b/install/update/new/includes/compatibility_globals.php deleted file mode 100644 index 15880d4..0000000 --- a/install/update/new/includes/compatibility_globals.php +++ /dev/null @@ -1,92 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -// -// Deprecated globals -// -define('ATTACHMENT_CATEGORY_WM', 2); // Windows Media Files - Streaming - @deprecated 3.2 -define('ATTACHMENT_CATEGORY_RM', 3); // Real Media Files - Streaming - @deprecated 3.2 -define('ATTACHMENT_CATEGORY_QUICKTIME', 6); // Quicktime/Mov files - @deprecated 3.2 -define('ATTACHMENT_CATEGORY_FLASH', 5); // Flash/SWF files - @deprecated 3.3 - -/** - * Sets compatibility globals in the global scope - * - * This function registers compatibility variables to the global - * variable scope. This is required to make it possible to include this file - * in a service. - */ -function register_compatibility_globals() -{ - global $phpbb_container; - - global $cache, $phpbb_dispatcher, $request, $user, $auth, $db, $config, $language, $phpbb_log; - global $symfony_request, $phpbb_filesystem, $phpbb_path_helper, $phpbb_extension_manager, $template; - - // set up caching - /* @var $cache \phpbb\cache\service */ - $cache = $phpbb_container->get('cache'); - - // Instantiate some basic classes - /* @var $phpbb_dispatcher \phpbb\event\dispatcher */ - $phpbb_dispatcher = $phpbb_container->get('dispatcher'); - - /* @var $request \phpbb\request\request_interface */ - $request = $phpbb_container->get('request'); - // Inject request instance, so only this instance is used with request_var - request_var('', 0, false, false, $request); - - /* @var $user \phpbb\user */ - $user = $phpbb_container->get('user'); - - /* @var \phpbb\language\language $language */ - $language = $phpbb_container->get('language'); - - /* @var $auth \phpbb\auth\auth */ - $auth = $phpbb_container->get('auth'); - - /* @var $db \phpbb\db\driver\driver_interface */ - $db = $phpbb_container->get('dbal.conn'); - - // Grab global variables, re-cache if necessary - /* @var $config phpbb\config\db */ - $config = $phpbb_container->get('config'); - set_config('', '', false, $config); - set_config_count('', 0, false, $config); - - /* @var $phpbb_log \phpbb\log\log_interface */ - $phpbb_log = $phpbb_container->get('log'); - - /* @var $symfony_request \phpbb\symfony_request */ - $symfony_request = $phpbb_container->get('symfony_request'); - - /* @var $phpbb_filesystem \phpbb\filesystem\filesystem_interface */ - $phpbb_filesystem = $phpbb_container->get('filesystem'); - - /* @var $phpbb_path_helper \phpbb\path_helper */ - $phpbb_path_helper = $phpbb_container->get('path_helper'); - - // load extensions - /* @var $phpbb_extension_manager \phpbb\extension\manager */ - $phpbb_extension_manager = $phpbb_container->get('ext.manager'); - - /* @var $template \phpbb\template\template */ - $template = $phpbb_container->get('template'); -} diff --git a/install/update/new/includes/constants.php b/install/update/new/includes/constants.php deleted file mode 100644 index 9508ce5..0000000 --- a/install/update/new/includes/constants.php +++ /dev/null @@ -1,312 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* valid external constants: -* PHPBB_MSG_HANDLER -* PHPBB_DB_NEW_LINK -* PHPBB_ROOT_PATH -* PHPBB_ADMIN_PATH -*/ - -// phpBB Version -@define('PHPBB_VERSION', '3.3.0'); - -// QA-related -// define('PHPBB_QA', 1); - -// User related -define('ANONYMOUS', 1); - -define('USER_ACTIVATION_NONE', 0); -define('USER_ACTIVATION_SELF', 1); -define('USER_ACTIVATION_ADMIN', 2); -define('USER_ACTIVATION_DISABLE', 3); - -define('AVATAR_UPLOAD', 1); -define('AVATAR_REMOTE', 2); -define('AVATAR_GALLERY', 3); - -define('USER_NORMAL', 0); -define('USER_INACTIVE', 1); -define('USER_IGNORE', 2); -define('USER_FOUNDER', 3); - -define('INACTIVE_REGISTER', 1); // Newly registered account -define('INACTIVE_PROFILE', 2); // Profile details changed -define('INACTIVE_MANUAL', 3); // Account deactivated by administrator -define('INACTIVE_REMIND', 4); // Forced user account reactivation - -// ACL -define('ACL_NEVER', 0); -define('ACL_YES', 1); -define('ACL_NO', -1); - -// Login error codes -define('LOGIN_CONTINUE', 1); -define('LOGIN_BREAK', 2); -define('LOGIN_SUCCESS', 3); -define('LOGIN_SUCCESS_CREATE_PROFILE', 20); -define('LOGIN_SUCCESS_LINK_PROFILE', 21); -define('LOGIN_ERROR_USERNAME', 10); -define('LOGIN_ERROR_PASSWORD', 11); -define('LOGIN_ERROR_ACTIVE', 12); -define('LOGIN_ERROR_ATTEMPTS', 13); -define('LOGIN_ERROR_EXTERNAL_AUTH', 14); -define('LOGIN_ERROR_PASSWORD_CONVERT', 15); - -// Maximum login attempts -// The value is arbitrary, but it has to fit into the user_login_attempts field. -define('LOGIN_ATTEMPTS_MAX', 100); - -// Group settings -define('GROUP_OPEN', 0); -define('GROUP_CLOSED', 1); -define('GROUP_HIDDEN', 2); -define('GROUP_SPECIAL', 3); -define('GROUP_FREE', 4); - -// Forum/Topic states -define('FORUM_CAT', 0); -define('FORUM_POST', 1); -define('FORUM_LINK', 2); -define('ITEM_UNLOCKED', 0); -define('ITEM_LOCKED', 1); -define('ITEM_MOVED', 2); - -define('ITEM_UNAPPROVED', 0); // => has not yet been approved -define('ITEM_APPROVED', 1); // => has been approved, and has not been soft deleted -define('ITEM_DELETED', 2); // => has been soft deleted -define('ITEM_REAPPROVE', 3); // => has been edited and needs to be re-approved - -// Forum Flags -define('FORUM_FLAG_LINK_TRACK', 1); -define('FORUM_FLAG_PRUNE_POLL', 2); -define('FORUM_FLAG_PRUNE_ANNOUNCE', 4); -define('FORUM_FLAG_PRUNE_STICKY', 8); -define('FORUM_FLAG_ACTIVE_TOPICS', 16); -define('FORUM_FLAG_POST_REVIEW', 32); -define('FORUM_FLAG_QUICK_REPLY', 64); - -// Forum Options... sequential order. Modifications should begin at number 10 (number 29 is maximum) -define('FORUM_OPTION_FEED_NEWS', 1); -define('FORUM_OPTION_FEED_EXCLUDE', 2); - -// Optional text flags -define('OPTION_FLAG_BBCODE', 1); -define('OPTION_FLAG_SMILIES', 2); -define('OPTION_FLAG_LINKS', 4); - -// Topic types -define('POST_NORMAL', 0); -define('POST_STICKY', 1); -define('POST_ANNOUNCE', 2); -define('POST_GLOBAL', 3); - -// Lastread types -define('TRACK_NORMAL', 0); -define('TRACK_POSTED', 1); - -// Notify methods -define('NOTIFY_EMAIL', 0); -define('NOTIFY_IM', 1); -define('NOTIFY_BOTH', 2); - -// Notify status -define('NOTIFY_YES', 0); -define('NOTIFY_NO', 1); - -// Email Priority Settings -define('MAIL_LOW_PRIORITY', 4); -define('MAIL_NORMAL_PRIORITY', 3); -define('MAIL_HIGH_PRIORITY', 2); - -// Log types -define('LOG_ADMIN', 0); -define('LOG_MOD', 1); -define('LOG_CRITICAL', 2); -define('LOG_USERS', 3); - -// Private messaging - Do NOT change these values -define('PRIVMSGS_HOLD_BOX', -4); -define('PRIVMSGS_NO_BOX', -3); -define('PRIVMSGS_OUTBOX', -2); -define('PRIVMSGS_SENTBOX', -1); -define('PRIVMSGS_INBOX', 0); - -// Full Folder Actions -define('FULL_FOLDER_NONE', -3); -define('FULL_FOLDER_DELETE', -2); -define('FULL_FOLDER_HOLD', -1); - -// Download Modes - Attachments -define('INLINE_LINK', 1); -// This mode is only used internally to allow modders extending the attachment functionality -define('PHYSICAL_LINK', 2); - -// Confirm types -define('CONFIRM_REG', 1); -define('CONFIRM_LOGIN', 2); -define('CONFIRM_POST', 3); -define('CONFIRM_REPORT', 4); - -// Categories - Attachments -define('ATTACHMENT_CATEGORY_NONE', 0); -define('ATTACHMENT_CATEGORY_IMAGE', 1); // Inline Images -define('ATTACHMENT_CATEGORY_THUMB', 4); // Not used within the database, only while displaying posts - -// BBCode UID length -define('BBCODE_UID_LEN', 8); - -// Number of core BBCodes -define('NUM_CORE_BBCODES', 12); -define('NUM_PREDEFINED_BBCODES', 22); - -// BBCode IDs -define('BBCODE_ID_QUOTE', 0); -define('BBCODE_ID_B', 1); -define('BBCODE_ID_I', 2); -define('BBCODE_ID_URL', 3); -define('BBCODE_ID_IMG', 4); -define('BBCODE_ID_SIZE', 5); -define('BBCODE_ID_COLOR', 6); -define('BBCODE_ID_U', 7); -define('BBCODE_ID_CODE', 8); -define('BBCODE_ID_LIST', 9); -define('BBCODE_ID_EMAIL', 10); -define('BBCODE_ID_FLASH', 11); -define('BBCODE_ID_ATTACH', 12); - -// BBCode hard limit -define('BBCODE_LIMIT', 1511); - -// Smiley hard limit -define('SMILEY_LIMIT', 1000); - -// Magic url types -define('MAGIC_URL_EMAIL', 1); -define('MAGIC_URL_FULL', 2); -define('MAGIC_URL_LOCAL', 3); -define('MAGIC_URL_WWW', 4); - -// Profile Field Types -define('FIELD_INT', 1); -define('FIELD_STRING', 2); -define('FIELD_TEXT', 3); -define('FIELD_BOOL', 4); -define('FIELD_DROPDOWN', 5); -define('FIELD_DATE', 6); - -// referer validation -define('REFERER_VALIDATE_NONE', 0); -define('REFERER_VALIDATE_HOST', 1); -define('REFERER_VALIDATE_PATH', 2); - -// phpbb_chmod() permissions -@define('CHMOD_ALL', 7); -@define('CHMOD_READ', 4); -@define('CHMOD_WRITE', 2); -@define('CHMOD_EXECUTE', 1); - -// Captcha code length -define('CAPTCHA_MIN_CHARS', 4); -define('CAPTCHA_MAX_CHARS', 7); - -// Additional constants -define('VOTE_CONVERTED', 127); - -// BC global FTW -global $table_prefix; - -// Table names -define('ACL_GROUPS_TABLE', $table_prefix . 'acl_groups'); -define('ACL_OPTIONS_TABLE', $table_prefix . 'acl_options'); -define('ACL_ROLES_DATA_TABLE', $table_prefix . 'acl_roles_data'); -define('ACL_ROLES_TABLE', $table_prefix . 'acl_roles'); -define('ACL_USERS_TABLE', $table_prefix . 'acl_users'); -define('ATTACHMENTS_TABLE', $table_prefix . 'attachments'); -define('BANLIST_TABLE', $table_prefix . 'banlist'); -define('BBCODES_TABLE', $table_prefix . 'bbcodes'); -define('BOOKMARKS_TABLE', $table_prefix . 'bookmarks'); -define('BOTS_TABLE', $table_prefix . 'bots'); -@define('CONFIG_TABLE', $table_prefix . 'config'); -define('CONFIG_TEXT_TABLE', $table_prefix . 'config_text'); -define('CONFIRM_TABLE', $table_prefix . 'confirm'); -define('DISALLOW_TABLE', $table_prefix . 'disallow'); -define('DRAFTS_TABLE', $table_prefix . 'drafts'); -define('EXT_TABLE', $table_prefix . 'ext'); -define('EXTENSIONS_TABLE', $table_prefix . 'extensions'); -define('EXTENSION_GROUPS_TABLE', $table_prefix . 'extension_groups'); -define('FORUMS_TABLE', $table_prefix . 'forums'); -define('FORUMS_ACCESS_TABLE', $table_prefix . 'forums_access'); -define('FORUMS_TRACK_TABLE', $table_prefix . 'forums_track'); -define('FORUMS_WATCH_TABLE', $table_prefix . 'forums_watch'); -define('GROUPS_TABLE', $table_prefix . 'groups'); -define('ICONS_TABLE', $table_prefix . 'icons'); -define('LANG_TABLE', $table_prefix . 'lang'); -define('LOG_TABLE', $table_prefix . 'log'); -define('LOGIN_ATTEMPT_TABLE', $table_prefix . 'login_attempts'); -define('MIGRATIONS_TABLE', $table_prefix . 'migrations'); -define('MODERATOR_CACHE_TABLE', $table_prefix . 'moderator_cache'); -define('MODULES_TABLE', $table_prefix . 'modules'); -define('NOTIFICATION_TYPES_TABLE', $table_prefix . 'notification_types'); -define('NOTIFICATIONS_TABLE', $table_prefix . 'notifications'); -define('POLL_OPTIONS_TABLE', $table_prefix . 'poll_options'); -define('POLL_VOTES_TABLE', $table_prefix . 'poll_votes'); -define('POSTS_TABLE', $table_prefix . 'posts'); -define('PRIVMSGS_TABLE', $table_prefix . 'privmsgs'); -define('PRIVMSGS_FOLDER_TABLE', $table_prefix . 'privmsgs_folder'); -define('PRIVMSGS_RULES_TABLE', $table_prefix . 'privmsgs_rules'); -define('PRIVMSGS_TO_TABLE', $table_prefix . 'privmsgs_to'); -define('PROFILE_FIELDS_TABLE', $table_prefix . 'profile_fields'); -define('PROFILE_FIELDS_DATA_TABLE', $table_prefix . 'profile_fields_data'); -define('PROFILE_FIELDS_LANG_TABLE', $table_prefix . 'profile_fields_lang'); -define('PROFILE_LANG_TABLE', $table_prefix . 'profile_lang'); -define('RANKS_TABLE', $table_prefix . 'ranks'); -define('REPORTS_TABLE', $table_prefix . 'reports'); -define('REPORTS_REASONS_TABLE', $table_prefix . 'reports_reasons'); -define('SEARCH_RESULTS_TABLE', $table_prefix . 'search_results'); -define('SEARCH_WORDLIST_TABLE', $table_prefix . 'search_wordlist'); -define('SEARCH_WORDMATCH_TABLE', $table_prefix . 'search_wordmatch'); -define('SESSIONS_TABLE', $table_prefix . 'sessions'); -define('SESSIONS_KEYS_TABLE', $table_prefix . 'sessions_keys'); -define('SITELIST_TABLE', $table_prefix . 'sitelist'); -define('SMILIES_TABLE', $table_prefix . 'smilies'); -define('SPHINX_TABLE', $table_prefix . 'sphinx'); -define('STYLES_TABLE', $table_prefix . 'styles'); -define('STYLES_TEMPLATE_TABLE', $table_prefix . 'styles_template'); -define('STYLES_TEMPLATE_DATA_TABLE',$table_prefix . 'styles_template_data'); -define('STYLES_THEME_TABLE', $table_prefix . 'styles_theme'); -define('STYLES_IMAGESET_TABLE', $table_prefix . 'styles_imageset'); -define('STYLES_IMAGESET_DATA_TABLE',$table_prefix . 'styles_imageset_data'); -define('TEAMPAGE_TABLE', $table_prefix . 'teampage'); -define('TOPICS_TABLE', $table_prefix . 'topics'); -define('TOPICS_POSTED_TABLE', $table_prefix . 'topics_posted'); -define('TOPICS_TRACK_TABLE', $table_prefix . 'topics_track'); -define('TOPICS_WATCH_TABLE', $table_prefix . 'topics_watch'); -define('USER_GROUP_TABLE', $table_prefix . 'user_group'); -define('USER_NOTIFICATIONS_TABLE', $table_prefix . 'user_notifications'); -define('USERS_TABLE', $table_prefix . 'users'); -define('WARNINGS_TABLE', $table_prefix . 'warnings'); -define('WORDS_TABLE', $table_prefix . 'words'); -define('ZEBRA_TABLE', $table_prefix . 'zebra'); - -// Additional tables diff --git a/install/update/new/includes/diff/engine.php b/install/update/new/includes/diff/engine.php deleted file mode 100644 index 0d73db0..0000000 --- a/install/update/new/includes/diff/engine.php +++ /dev/null @@ -1,557 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* Code from pear.php.net, Text_Diff-1.1.0 package -* http://pear.php.net/package/Text_Diff/ (native engine) -* -* Modified by phpBB Limited to meet our coding standards -* and being able to integrate into phpBB -* -* Class used internally by Text_Diff to actually compute the diffs. This -* class is implemented using native PHP code. -* -* The algorithm used here is mostly lifted from the perl module -* Algorithm::Diff (version 1.06) by Ned Konz, which is available at: -* http://www.perl.com/CPAN/authors/id/N/NE/NEDKONZ/Algorithm-Diff-1.06.zip -* -* More ideas are taken from: http://www.ics.uci.edu/~eppstein/161/960229.html -* -* Some ideas (and a bit of code) are taken from analyze.c, of GNU -* diffutils-2.7, which can be found at: -* ftp://gnudist.gnu.org/pub/gnu/diffutils/diffutils-2.7.tar.gz -* -* Some ideas (subdivision by NCHUNKS > 2, and some optimizations) are from -* Geoffrey T. Dairiki . The original PHP version of this -* code was written by him, and is used/adapted with his permission. -* -* Copyright 2004-2008 The Horde Project (http://www.horde.org/) -* -* @author Geoffrey T. Dairiki -* @package diff -* -* @access private -*/ -class diff_engine -{ - /** - * If set to true we trim all lines before we compare them. This ensures that sole space/tab changes do not trigger diffs. - */ - var $skip_whitespace_changes = true; - - function diff(&$from_lines, &$to_lines, $preserve_cr = true) - { - // Remove empty lines... - // If preserve_cr is true, we basically only change \r\n and bare \r to \n to get the same carriage returns for both files - // If it is false, we try to only use \n once per line and ommit all empty lines to be able to get a proper data diff - - if (is_array($from_lines)) - { - $from_lines = implode("\n", $from_lines); - } - - if (is_array($to_lines)) - { - $to_lines = implode("\n", $to_lines); - } - - if ($preserve_cr) - { - $from_lines = explode("\n", str_replace("\r", "\n", str_replace("\r\n", "\n", $from_lines))); - $to_lines = explode("\n", str_replace("\r", "\n", str_replace("\r\n", "\n", $to_lines))); - } - else - { - $from_lines = explode("\n", preg_replace('#[\n\r]+#', "\n", $from_lines)); - $to_lines = explode("\n", preg_replace('#[\n\r]+#', "\n", $to_lines)); - } - - $n_from = count($from_lines); - $n_to = count($to_lines); - - $this->xchanged = $this->ychanged = $this->xv = $this->yv = $this->xind = $this->yind = array(); - unset($this->seq, $this->in_seq, $this->lcs); - - // Skip leading common lines. - for ($skip = 0; $skip < $n_from && $skip < $n_to; $skip++) - { - if (trim($from_lines[$skip]) !== trim($to_lines[$skip])) - { - break; - } - $this->xchanged[$skip] = $this->ychanged[$skip] = false; - } - - // Skip trailing common lines. - $xi = $n_from; - $yi = $n_to; - - for ($endskip = 0; --$xi > $skip && --$yi > $skip; $endskip++) - { - if (trim($from_lines[$xi]) !== trim($to_lines[$yi])) - { - break; - } - $this->xchanged[$xi] = $this->ychanged[$yi] = false; - } - - // Ignore lines which do not exist in both files. - for ($xi = $skip; $xi < $n_from - $endskip; $xi++) - { - if ($this->skip_whitespace_changes) $xhash[trim($from_lines[$xi])] = 1; else $xhash[$from_lines[$xi]] = 1; - } - - for ($yi = $skip; $yi < $n_to - $endskip; $yi++) - { - $line = ($this->skip_whitespace_changes) ? trim($to_lines[$yi]) : $to_lines[$yi]; - - if (($this->ychanged[$yi] = empty($xhash[$line]))) - { - continue; - } - $yhash[$line] = 1; - $this->yv[] = $line; - $this->yind[] = $yi; - } - - for ($xi = $skip; $xi < $n_from - $endskip; $xi++) - { - $line = ($this->skip_whitespace_changes) ? trim($from_lines[$xi]) : $from_lines[$xi]; - - if (($this->xchanged[$xi] = empty($yhash[$line]))) - { - continue; - } - $this->xv[] = $line; - $this->xind[] = $xi; - } - - // Find the LCS. - $this->_compareseq(0, count($this->xv), 0, count($this->yv)); - - // Merge edits when possible. - if ($this->skip_whitespace_changes) - { - $from_lines_clean = array_map('trim', $from_lines); - $to_lines_clean = array_map('trim', $to_lines); - - $this->_shift_boundaries($from_lines_clean, $this->xchanged, $this->ychanged); - $this->_shift_boundaries($to_lines_clean, $this->ychanged, $this->xchanged); - - unset($from_lines_clean, $to_lines_clean); - } - else - { - $this->_shift_boundaries($from_lines, $this->xchanged, $this->ychanged); - $this->_shift_boundaries($to_lines, $this->ychanged, $this->xchanged); - } - - // Compute the edit operations. - $edits = array(); - $xi = $yi = 0; - - while ($xi < $n_from || $yi < $n_to) - { - // Skip matching "snake". - $copy = array(); - - while ($xi < $n_from && $yi < $n_to && !$this->xchanged[$xi] && !$this->ychanged[$yi]) - { - $copy[] = $from_lines[$xi++]; - $yi++; - } - - if ($copy) - { - $edits[] = new diff_op_copy($copy); - } - - // Find deletes & adds. - $delete = array(); - while ($xi < $n_from && $this->xchanged[$xi]) - { - $delete[] = $from_lines[$xi++]; - } - - $add = array(); - while ($yi < $n_to && $this->ychanged[$yi]) - { - $add[] = $to_lines[$yi++]; - } - - if ($delete && $add) - { - $edits[] = new diff_op_change($delete, $add); - } - else if ($delete) - { - $edits[] = new diff_op_delete($delete); - } - else if ($add) - { - $edits[] = new diff_op_add($add); - } - } - - return $edits; - } - - /** - * Divides the Largest Common Subsequence (LCS) of the sequences (XOFF, - * XLIM) and (YOFF, YLIM) into NCHUNKS approximately equally sized segments. - * - * Returns (LCS, PTS). LCS is the length of the LCS. PTS is an array of - * NCHUNKS+1 (X, Y) indexes giving the diving points between sub - * sequences. The first sub-sequence is contained in (X0, X1), (Y0, Y1), - * the second in (X1, X2), (Y1, Y2) and so on. Note that (X0, Y0) == - * (XOFF, YOFF) and (X[NCHUNKS], Y[NCHUNKS]) == (XLIM, YLIM). - * - * This function assumes that the first lines of the specified portions of - * the two files do not match, and likewise that the last lines do not - * match. The caller must trim matching lines from the beginning and end - * of the portions it is going to specify. - */ - function _diag($xoff, $xlim, $yoff, $ylim, $nchunks) - { - $flip = false; - - if ($xlim - $xoff > $ylim - $yoff) - { - // Things seems faster (I'm not sure I understand why) when the shortest sequence is in X. - $flip = true; - list($xoff, $xlim, $yoff, $ylim) = array($yoff, $ylim, $xoff, $xlim); - } - - if ($flip) - { - for ($i = $ylim - 1; $i >= $yoff; $i--) - { - $ymatches[$this->xv[$i]][] = $i; - } - } - else - { - for ($i = $ylim - 1; $i >= $yoff; $i--) - { - $ymatches[$this->yv[$i]][] = $i; - } - } - - $this->lcs = 0; - $this->seq[0]= $yoff - 1; - $this->in_seq = array(); - $ymids[0] = array(); - - $numer = $xlim - $xoff + $nchunks - 1; - $x = $xoff; - - for ($chunk = 0; $chunk < $nchunks; $chunk++) - { - if ($chunk > 0) - { - for ($i = 0; $i <= $this->lcs; $i++) - { - $ymids[$i][$chunk - 1] = $this->seq[$i]; - } - } - - $x1 = $xoff + (int)(($numer + ($xlim - $xoff) * $chunk) / $nchunks); - - for (; $x < $x1; $x++) - { - $line = $flip ? $this->yv[$x] : $this->xv[$x]; - if (empty($ymatches[$line])) - { - continue; - } - $matches = $ymatches[$line]; - - reset($matches); - while ($y = current($matches)) - { - next($matches); - if (empty($this->in_seq[$y])) - { - $k = $this->_lcs_pos($y); - $ymids[$k] = $ymids[$k - 1]; - break; - } - } - - // no reset() here - while ($y = current($matches)) - { - next($matches); - if ($y > $this->seq[$k - 1]) - { - // Optimization: this is a common case: next match is just replacing previous match. - $this->in_seq[$this->seq[$k]] = false; - $this->seq[$k] = $y; - $this->in_seq[$y] = 1; - } - else if (empty($this->in_seq[$y])) - { - $k = $this->_lcs_pos($y); - $ymids[$k] = $ymids[$k - 1]; - } - } - } - } - - $seps[] = $flip ? array($yoff, $xoff) : array($xoff, $yoff); - $ymid = $ymids[$this->lcs]; - - for ($n = 0; $n < $nchunks - 1; $n++) - { - $x1 = $xoff + (int)(($numer + ($xlim - $xoff) * $n) / $nchunks); - $y1 = $ymid[$n] + 1; - $seps[] = $flip ? array($y1, $x1) : array($x1, $y1); - } - $seps[] = $flip ? array($ylim, $xlim) : array($xlim, $ylim); - - return array($this->lcs, $seps); - } - - function _lcs_pos($ypos) - { - $end = $this->lcs; - - if ($end == 0 || $ypos > $this->seq[$end]) - { - $this->seq[++$this->lcs] = $ypos; - $this->in_seq[$ypos] = 1; - return $this->lcs; - } - - $beg = 1; - while ($beg < $end) - { - $mid = (int)(($beg + $end) / 2); - if ($ypos > $this->seq[$mid]) - { - $beg = $mid + 1; - } - else - { - $end = $mid; - } - } - - $this->in_seq[$this->seq[$end]] = false; - $this->seq[$end] = $ypos; - $this->in_seq[$ypos] = 1; - - return $end; - } - - /** - * Finds LCS of two sequences. - * - * The results are recorded in the vectors $this->{x,y}changed[], by - * storing a 1 in the element for each line that is an insertion or - * deletion (ie. is not in the LCS). - * - * The subsequence of file 0 is (XOFF, XLIM) and likewise for file 1. - * - * Note that XLIM, YLIM are exclusive bounds. All line numbers are - * origin-0 and discarded lines are not counted. - */ - function _compareseq($xoff, $xlim, $yoff, $ylim) - { - // Slide down the bottom initial diagonal. - while ($xoff < $xlim && $yoff < $ylim && $this->xv[$xoff] == $this->yv[$yoff]) - { - ++$xoff; - ++$yoff; - } - - // Slide up the top initial diagonal. - while ($xlim > $xoff && $ylim > $yoff && $this->xv[$xlim - 1] == $this->yv[$ylim - 1]) - { - --$xlim; - --$ylim; - } - - if ($xoff == $xlim || $yoff == $ylim) - { - $lcs = 0; - } - else - { - // This is ad hoc but seems to work well. - // $nchunks = sqrt(min($xlim - $xoff, $ylim - $yoff) / 2.5); - // $nchunks = max(2,min(8,(int)$nchunks)); - $nchunks = min(7, $xlim - $xoff, $ylim - $yoff) + 1; - list($lcs, $seps) = $this->_diag($xoff, $xlim, $yoff, $ylim, $nchunks); - } - - if ($lcs == 0) - { - // X and Y sequences have no common subsequence: mark all changed. - while ($yoff < $ylim) - { - $this->ychanged[$this->yind[$yoff++]] = 1; - } - - while ($xoff < $xlim) - { - $this->xchanged[$this->xind[$xoff++]] = 1; - } - } - else - { - // Use the partitions to split this problem into subproblems. - reset($seps); - $pt1 = $seps[0]; - - while ($pt2 = next($seps)) - { - $this->_compareseq($pt1[0], $pt2[0], $pt1[1], $pt2[1]); - $pt1 = $pt2; - } - } - } - - /** - * Adjusts inserts/deletes of identical lines to join changes as much as possible. - * - * We do something when a run of changed lines include a line at one end - * and has an excluded, identical line at the other. We are free to - * choose which identical line is included. 'compareseq' usually chooses - * the one at the beginning, but usually it is cleaner to consider the - * following identical line to be the "change". - * - * This is extracted verbatim from analyze.c (GNU diffutils-2.7). - */ - function _shift_boundaries($lines, &$changed, $other_changed) - { - $i = 0; - $j = 0; - - $len = count($lines); - $other_len = count($other_changed); - - while (1) - { - // Scan forward to find the beginning of another run of - // changes. Also keep track of the corresponding point in the other file. - // - // Throughout this code, $i and $j are adjusted together so that - // the first $i elements of $changed and the first $j elements of - // $other_changed both contain the same number of zeros (unchanged lines). - // - // Furthermore, $j is always kept so that $j == $other_len or $other_changed[$j] == false. - while ($j < $other_len && $other_changed[$j]) - { - $j++; - } - - while ($i < $len && ! $changed[$i]) - { - $i++; - $j++; - - while ($j < $other_len && $other_changed[$j]) - { - $j++; - } - } - - if ($i == $len) - { - break; - } - - $start = $i; - - // Find the end of this run of changes. - while (++$i < $len && $changed[$i]) - { - continue; - } - - do - { - // Record the length of this run of changes, so that we can later determine whether the run has grown. - $runlength = $i - $start; - - // Move the changed region back, so long as the previous unchanged line matches the last changed one. - // This merges with previous changed regions. - while ($start > 0 && $lines[$start - 1] == $lines[$i - 1]) - { - $changed[--$start] = 1; - $changed[--$i] = false; - - while ($start > 0 && $changed[$start - 1]) - { - $start--; - } - - while ($other_changed[--$j]) - { - continue; - } - } - - // Set CORRESPONDING to the end of the changed run, at the last point where it corresponds to a changed run in the - // other file. CORRESPONDING == LEN means no such point has been found. - $corresponding = $j < $other_len ? $i : $len; - - // Move the changed region forward, so long as the first changed line matches the following unchanged one. - // This merges with following changed regions. - // Do this second, so that if there are no merges, the changed region is moved forward as far as possible. - while ($i < $len && $lines[$start] == $lines[$i]) - { - $changed[$start++] = false; - $changed[$i++] = 1; - - while ($i < $len && $changed[$i]) - { - $i++; - } - - $j++; - if ($j < $other_len && $other_changed[$j]) - { - $corresponding = $i; - while ($j < $other_len && $other_changed[$j]) - { - $j++; - } - } - } - } - while ($runlength != $i - $start); - - // If possible, move the fully-merged run of changes back to a corresponding run in the other file. - while ($corresponding < $i) - { - $changed[--$start] = 1; - $changed[--$i] = 0; - - while ($other_changed[--$j]) - { - continue; - } - } - } - } -} diff --git a/install/update/new/includes/functions.php b/install/update/new/includes/functions.php deleted file mode 100644 index 9759eab..0000000 --- a/install/update/new/includes/functions.php +++ /dev/null @@ -1,4630 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -// Common global functions -/** -* Load the autoloaders added by the extensions. -* -* @param string $phpbb_root_path Path to the phpbb root directory. -*/ -function phpbb_load_extensions_autoloaders($phpbb_root_path) -{ - $iterator = new \RecursiveIteratorIterator( - new \phpbb\recursive_dot_prefix_filter_iterator( - new \RecursiveDirectoryIterator( - $phpbb_root_path . 'ext/', - \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS - ) - ), - \RecursiveIteratorIterator::SELF_FIRST - ); - $iterator->setMaxDepth(2); - - foreach ($iterator as $file_info) - { - if ($file_info->getFilename() === 'vendor' && $iterator->getDepth() === 2) - { - $filename = $file_info->getRealPath() . '/autoload.php'; - if (file_exists($filename)) - { - require $filename; - } - } - } -} - -/** -* Generates an alphanumeric random string of given length -* -* @param int $num_chars Length of random string, defaults to 8. -* This number should be less or equal than 64. -* -* @return string -*/ -function gen_rand_string($num_chars = 8) -{ - $range = array_merge(range('A', 'Z'), range(0, 9)); - $size = count($range); - - $output = ''; - for ($i = 0; $i < $num_chars; $i++) - { - $rand = random_int(0, $size-1); - $output .= $range[$rand]; - } - - return $output; -} - -/** -* Generates a user-friendly alphanumeric random string of given length -* We remove 0 and O so users cannot confuse those in passwords etc. -* -* @param int $num_chars Length of random string, defaults to 8. -* This number should be less or equal than 64. -* -* @return string -*/ -function gen_rand_string_friendly($num_chars = 8) -{ - $range = array_merge(range('A', 'N'), range('P', 'Z'), range(1, 9)); - $size = count($range); - - $output = ''; - for ($i = 0; $i < $num_chars; $i++) - { - $rand = random_int(0, $size-1); - $output .= $range[$rand]; - } - - return $output; -} - -/** -* Return unique id -*/ -function unique_id() -{ - return strtolower(gen_rand_string(16)); -} - -/** -* Wrapper for mt_rand() which allows swapping $min and $max parameters. -* -* PHP does not allow us to swap the order of the arguments for mt_rand() anymore. -* (since PHP 5.3.4, see http://bugs.php.net/46587) -* -* @param int $min Lowest value to be returned -* @param int $max Highest value to be returned -* -* @return int Random integer between $min and $max (or $max and $min) -*/ -function phpbb_mt_rand($min, $max) -{ - return ($min > $max) ? mt_rand($max, $min) : mt_rand($min, $max); -} - -/** -* Wrapper for getdate() which returns the equivalent array for UTC timestamps. -* -* @param int $time Unix timestamp (optional) -* -* @return array Returns an associative array of information related to the timestamp. -* See http://www.php.net/manual/en/function.getdate.php -*/ -function phpbb_gmgetdate($time = false) -{ - if ($time === false) - { - $time = time(); - } - - // getdate() interprets timestamps in local time. - // What follows uses the fact that getdate() and - // date('Z') balance each other out. - return getdate($time - date('Z')); -} - -/** -* Return formatted string for filesizes -* -* @param mixed $value filesize in bytes -* (non-negative number; int, float or string) -* @param bool $string_only true if language string should be returned -* @param array $allowed_units only allow these units (data array indexes) -* -* @return mixed data array if $string_only is false -*/ -function get_formatted_filesize($value, $string_only = true, $allowed_units = false) -{ - global $user; - - $available_units = array( - 'tb' => array( - 'min' => 1099511627776, // pow(2, 40) - 'index' => 4, - 'si_unit' => 'TB', - 'iec_unit' => 'TIB', - ), - 'gb' => array( - 'min' => 1073741824, // pow(2, 30) - 'index' => 3, - 'si_unit' => 'GB', - 'iec_unit' => 'GIB', - ), - 'mb' => array( - 'min' => 1048576, // pow(2, 20) - 'index' => 2, - 'si_unit' => 'MB', - 'iec_unit' => 'MIB', - ), - 'kb' => array( - 'min' => 1024, // pow(2, 10) - 'index' => 1, - 'si_unit' => 'KB', - 'iec_unit' => 'KIB', - ), - 'b' => array( - 'min' => 0, - 'index' => 0, - 'si_unit' => 'BYTES', // Language index - 'iec_unit' => 'BYTES', // Language index - ), - ); - - foreach ($available_units as $si_identifier => $unit_info) - { - if (!empty($allowed_units) && $si_identifier != 'b' && !in_array($si_identifier, $allowed_units)) - { - continue; - } - - if ($value >= $unit_info['min']) - { - $unit_info['si_identifier'] = $si_identifier; - - break; - } - } - unset($available_units); - - for ($i = 0; $i < $unit_info['index']; $i++) - { - $value /= 1024; - } - $value = round($value, 2); - - // Lookup units in language dictionary - $unit_info['si_unit'] = (isset($user->lang[$unit_info['si_unit']])) ? $user->lang[$unit_info['si_unit']] : $unit_info['si_unit']; - $unit_info['iec_unit'] = (isset($user->lang[$unit_info['iec_unit']])) ? $user->lang[$unit_info['iec_unit']] : $unit_info['iec_unit']; - - // Default to IEC - $unit_info['unit'] = $unit_info['iec_unit']; - - if (!$string_only) - { - $unit_info['value'] = $value; - - return $unit_info; - } - - return $value . ' ' . $unit_info['unit']; -} - -/** -* Determine whether we are approaching the maximum execution time. Should be called once -* at the beginning of the script in which it's used. -* @return bool Either true if the maximum execution time is nearly reached, or false -* if some time is still left. -*/ -function still_on_time($extra_time = 15) -{ - static $max_execution_time, $start_time; - - $current_time = microtime(true); - - if (empty($max_execution_time)) - { - $max_execution_time = (function_exists('ini_get')) ? (int) @ini_get('max_execution_time') : (int) @get_cfg_var('max_execution_time'); - - // If zero, then set to something higher to not let the user catch the ten seconds barrier. - if ($max_execution_time === 0) - { - $max_execution_time = 50 + $extra_time; - } - - $max_execution_time = min(max(10, ($max_execution_time - $extra_time)), 50); - - // For debugging purposes - // $max_execution_time = 10; - - global $starttime; - $start_time = (empty($starttime)) ? $current_time : $starttime; - } - - return (ceil($current_time - $start_time) < $max_execution_time) ? true : false; -} - -/** -* Wrapper for version_compare() that allows using uppercase A and B -* for alpha and beta releases. -* -* See http://www.php.net/manual/en/function.version-compare.php -* -* @param string $version1 First version number -* @param string $version2 Second version number -* @param string $operator Comparison operator (optional) -* -* @return mixed Boolean (true, false) if comparison operator is specified. -* Integer (-1, 0, 1) otherwise. -*/ -function phpbb_version_compare($version1, $version2, $operator = null) -{ - $version1 = strtolower($version1); - $version2 = strtolower($version2); - - if (is_null($operator)) - { - return version_compare($version1, $version2); - } - else - { - return version_compare($version1, $version2, $operator); - } -} - -// functions used for building option fields - -/** -* Pick a language, any language ... -*/ -function language_select($default = '') -{ - global $db; - - $sql = 'SELECT lang_iso, lang_local_name - FROM ' . LANG_TABLE . ' - ORDER BY lang_english_name'; - $result = $db->sql_query($sql); - - $lang_options = ''; - while ($row = $db->sql_fetchrow($result)) - { - $selected = ($row['lang_iso'] == $default) ? ' selected="selected"' : ''; - $lang_options .= ''; - } - $db->sql_freeresult($result); - - return $lang_options; -} - -/** -* Pick a template/theme combo, -*/ -function style_select($default = '', $all = false) -{ - global $db; - - $sql_where = (!$all) ? 'WHERE style_active = 1 ' : ''; - $sql = 'SELECT style_id, style_name - FROM ' . STYLES_TABLE . " - $sql_where - ORDER BY style_name"; - $result = $db->sql_query($sql); - - $style_options = ''; - while ($row = $db->sql_fetchrow($result)) - { - $selected = ($row['style_id'] == $default) ? ' selected="selected"' : ''; - $style_options .= ''; - } - $db->sql_freeresult($result); - - return $style_options; -} - -/** -* Format the timezone offset with hours and minutes -* -* @param int $tz_offset Timezone offset in seconds -* @param bool $show_null Whether null offsets should be shown -* @return string Normalized offset string: -7200 => -02:00 -* 16200 => +04:30 -*/ -function phpbb_format_timezone_offset($tz_offset, $show_null = false) -{ - $sign = ($tz_offset < 0) ? '-' : '+'; - $time_offset = abs($tz_offset); - - if ($time_offset == 0 && $show_null == false) - { - return ''; - } - - $offset_seconds = $time_offset % 3600; - $offset_minutes = $offset_seconds / 60; - $offset_hours = ($time_offset - $offset_seconds) / 3600; - - $offset_string = sprintf("%s%02d:%02d", $sign, $offset_hours, $offset_minutes); - return $offset_string; -} - -/** -* Compares two time zone labels. -* Arranges them in increasing order by timezone offset. -* Places UTC before other timezones in the same offset. -*/ -function phpbb_tz_select_compare($a, $b) -{ - $a_sign = $a[3]; - $b_sign = $b[3]; - if ($a_sign != $b_sign) - { - return $a_sign == '-' ? -1 : 1; - } - - $a_offset = substr($a, 4, 5); - $b_offset = substr($b, 4, 5); - if ($a_offset == $b_offset) - { - $a_name = substr($a, 12); - $b_name = substr($b, 12); - if ($a_name == $b_name) - { - return 0; - } - else if ($a_name == 'UTC') - { - return -1; - } - else if ($b_name == 'UTC') - { - return 1; - } - else - { - return $a_name < $b_name ? -1 : 1; - } - } - else - { - if ($a_sign == '-') - { - return $a_offset > $b_offset ? -1 : 1; - } - else - { - return $a_offset < $b_offset ? -1 : 1; - } - } -} - -/** -* Return list of timezone identifiers -* We also add the selected timezone if we can create an object with it. -* DateTimeZone::listIdentifiers seems to not add all identifiers to the list, -* because some are only kept for backward compatible reasons. If the user has -* a deprecated value, we add it here, so it can still be kept. Once the user -* changed his value, there is no way back to deprecated values. -* -* @param string $selected_timezone Additional timezone that shall -* be added to the list of identiers -* @return array DateTimeZone::listIdentifiers and additional -* selected_timezone if it is a valid timezone. -*/ -function phpbb_get_timezone_identifiers($selected_timezone) -{ - $timezones = DateTimeZone::listIdentifiers(); - - if (!in_array($selected_timezone, $timezones)) - { - try - { - // Add valid timezones that are currently selected but not returned - // by DateTimeZone::listIdentifiers - $validate_timezone = new DateTimeZone($selected_timezone); - $timezones[] = $selected_timezone; - } - catch (\Exception $e) - { - } - } - - return $timezones; -} - -/** -* Options to pick a timezone and date/time -* -* @param \phpbb\template\template $template phpBB template object -* @param \phpbb\user $user Object of the current user -* @param string $default A timezone to select -* @param boolean $truncate Shall we truncate the options text -* -* @return array Returns an array containing the options for the time selector. -*/ -function phpbb_timezone_select($template, $user, $default = '', $truncate = false) -{ - static $timezones; - - $default_offset = ''; - if (!isset($timezones)) - { - $unsorted_timezones = phpbb_get_timezone_identifiers($default); - - $timezones = array(); - foreach ($unsorted_timezones as $timezone) - { - $tz = new DateTimeZone($timezone); - $dt = $user->create_datetime('now', $tz); - $offset = $dt->getOffset(); - $current_time = $dt->format($user->lang['DATETIME_FORMAT'], true); - $offset_string = phpbb_format_timezone_offset($offset, true); - $timezones['UTC' . $offset_string . ' - ' . $timezone] = array( - 'tz' => $timezone, - 'offset' => $offset_string, - 'current' => $current_time, - ); - if ($timezone === $default) - { - $default_offset = 'UTC' . $offset_string; - } - } - unset($unsorted_timezones); - - uksort($timezones, 'phpbb_tz_select_compare'); - } - - $tz_select = $opt_group = ''; - - foreach ($timezones as $key => $timezone) - { - if ($opt_group != $timezone['offset']) - { - // Generate tz_select for backwards compatibility - $tz_select .= ($opt_group) ? '' : ''; - $tz_select .= ''; - $opt_group = $timezone['offset']; - $template->assign_block_vars('timezone_select', array( - 'LABEL' => $user->lang(array('timezones', 'UTC_OFFSET_CURRENT'), $timezone['offset'], $timezone['current']), - 'VALUE' => $key . ' - ' . $timezone['current'], - )); - - $selected = (!empty($default_offset) && strpos($key, $default_offset) !== false) ? ' selected="selected"' : ''; - $template->assign_block_vars('timezone_date', array( - 'VALUE' => $key . ' - ' . $timezone['current'], - 'SELECTED' => !empty($selected), - 'TITLE' => $user->lang(array('timezones', 'UTC_OFFSET_CURRENT'), $timezone['offset'], $timezone['current']), - )); - } - - $label = $timezone['tz']; - if (isset($user->lang['timezones'][$label])) - { - $label = $user->lang['timezones'][$label]; - } - $title = $user->lang(array('timezones', 'UTC_OFFSET_CURRENT'), $timezone['offset'], $label); - - if ($truncate) - { - $label = truncate_string($label, 50, 255, false, '...'); - } - - // Also generate timezone_select for backwards compatibility - $selected = ($timezone['tz'] === $default) ? ' selected="selected"' : ''; - $tz_select .= ''; - $template->assign_block_vars('timezone_select.timezone_options', array( - 'TITLE' => $title, - 'VALUE' => $timezone['tz'], - 'SELECTED' => !empty($selected), - 'LABEL' => $label, - )); - } - $tz_select .= ''; - - return $tz_select; -} - -// Functions handling topic/post tracking/marking - -/** -* Marks a topic/forum as read -* Marks a topic as posted to -* -* @param string $mode (all, topics, topic, post) -* @param int|bool $forum_id Used in all, topics, and topic mode -* @param int|bool $topic_id Used in topic and post mode -* @param int $post_time 0 means current time(), otherwise to set a specific mark time -* @param int $user_id can only be used with $mode == 'post' -*/ -function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $user_id = 0) -{ - global $db, $user, $config; - global $request, $phpbb_container, $phpbb_dispatcher; - - $post_time = ($post_time === 0 || $post_time > time()) ? time() : (int) $post_time; - - $should_markread = true; - - /** - * This event is used for performing actions directly before marking forums, - * topics or posts as read. - * - * It is also possible to prevent the marking. For that, the $should_markread parameter - * should be set to FALSE. - * - * @event core.markread_before - * @var string mode Variable containing marking mode value - * @var mixed forum_id Variable containing forum id, or false - * @var mixed topic_id Variable containing topic id, or false - * @var int post_time Variable containing post time - * @var int user_id Variable containing the user id - * @var bool should_markread Flag indicating if the markread should be done or not. - * @since 3.1.4-RC1 - */ - $vars = array( - 'mode', - 'forum_id', - 'topic_id', - 'post_time', - 'user_id', - 'should_markread', - ); - extract($phpbb_dispatcher->trigger_event('core.markread_before', compact($vars))); - - if (!$should_markread) - { - return; - } - - if ($mode == 'all') - { - if (empty($forum_id)) - { - // Mark all forums read (index page) - /* @var $phpbb_notifications \phpbb\notification\manager */ - $phpbb_notifications = $phpbb_container->get('notification_manager'); - - // Mark all topic notifications read for this user - $phpbb_notifications->mark_notifications(array( - 'notification.type.topic', - 'notification.type.quote', - 'notification.type.bookmark', - 'notification.type.post', - 'notification.type.approve_topic', - 'notification.type.approve_post', - ), false, $user->data['user_id'], $post_time); - - if ($config['load_db_lastread'] && $user->data['is_registered']) - { - // Mark all forums read (index page) - $tables = array(TOPICS_TRACK_TABLE, FORUMS_TRACK_TABLE); - foreach ($tables as $table) - { - $sql = 'DELETE FROM ' . $table . " - WHERE user_id = {$user->data['user_id']} - AND mark_time < $post_time"; - $db->sql_query($sql); - } - - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_lastmark = $post_time - WHERE user_id = {$user->data['user_id']} - AND user_lastmark < $post_time"; - $db->sql_query($sql); - } - else if ($config['load_anon_lastread'] || $user->data['is_registered']) - { - $tracking_topics = $request->variable($config['cookie_name'] . '_track', '', true, \phpbb\request\request_interface::COOKIE); - $tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array(); - - unset($tracking_topics['tf']); - unset($tracking_topics['t']); - unset($tracking_topics['f']); - $tracking_topics['l'] = base_convert($post_time - $config['board_startdate'], 10, 36); - - $user->set_cookie('track', tracking_serialize($tracking_topics), $post_time + 31536000); - $request->overwrite($config['cookie_name'] . '_track', tracking_serialize($tracking_topics), \phpbb\request\request_interface::COOKIE); - - unset($tracking_topics); - - if ($user->data['is_registered']) - { - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_lastmark = $post_time - WHERE user_id = {$user->data['user_id']} - AND user_lastmark < $post_time"; - $db->sql_query($sql); - } - } - } - } - else if ($mode == 'topics') - { - // Mark all topics in forums read - if (!is_array($forum_id)) - { - $forum_id = array($forum_id); - } - else - { - $forum_id = array_unique($forum_id); - } - - /* @var $phpbb_notifications \phpbb\notification\manager */ - $phpbb_notifications = $phpbb_container->get('notification_manager'); - - $phpbb_notifications->mark_notifications_by_parent(array( - 'notification.type.topic', - 'notification.type.approve_topic', - ), $forum_id, $user->data['user_id'], $post_time); - - // Mark all post/quote notifications read for this user in this forum - $topic_ids = array(); - $sql = 'SELECT topic_id - FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $forum_id); - $result = $db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) - { - $topic_ids[] = $row['topic_id']; - } - $db->sql_freeresult($result); - - $phpbb_notifications->mark_notifications_by_parent(array( - 'notification.type.quote', - 'notification.type.bookmark', - 'notification.type.post', - 'notification.type.approve_post', - ), $topic_ids, $user->data['user_id'], $post_time); - - // Add 0 to forums array to mark global announcements correctly - // $forum_id[] = 0; - - if ($config['load_db_lastread'] && $user->data['is_registered']) - { - $sql = 'DELETE FROM ' . TOPICS_TRACK_TABLE . " - WHERE user_id = {$user->data['user_id']} - AND mark_time < $post_time - AND " . $db->sql_in_set('forum_id', $forum_id); - $db->sql_query($sql); - - $sql = 'SELECT forum_id - FROM ' . FORUMS_TRACK_TABLE . " - WHERE user_id = {$user->data['user_id']} - AND " . $db->sql_in_set('forum_id', $forum_id); - $result = $db->sql_query($sql); - - $sql_update = array(); - while ($row = $db->sql_fetchrow($result)) - { - $sql_update[] = (int) $row['forum_id']; - } - $db->sql_freeresult($result); - - if (count($sql_update)) - { - $sql = 'UPDATE ' . FORUMS_TRACK_TABLE . " - SET mark_time = $post_time - WHERE user_id = {$user->data['user_id']} - AND mark_time < $post_time - AND " . $db->sql_in_set('forum_id', $sql_update); - $db->sql_query($sql); - } - - if ($sql_insert = array_diff($forum_id, $sql_update)) - { - $sql_ary = array(); - foreach ($sql_insert as $f_id) - { - $sql_ary[] = array( - 'user_id' => (int) $user->data['user_id'], - 'forum_id' => (int) $f_id, - 'mark_time' => $post_time, - ); - } - - $db->sql_multi_insert(FORUMS_TRACK_TABLE, $sql_ary); - } - } - else if ($config['load_anon_lastread'] || $user->data['is_registered']) - { - $tracking = $request->variable($config['cookie_name'] . '_track', '', true, \phpbb\request\request_interface::COOKIE); - $tracking = ($tracking) ? tracking_unserialize($tracking) : array(); - - foreach ($forum_id as $f_id) - { - $topic_ids36 = (isset($tracking['tf'][$f_id])) ? $tracking['tf'][$f_id] : array(); - - if (isset($tracking['tf'][$f_id])) - { - unset($tracking['tf'][$f_id]); - } - - foreach ($topic_ids36 as $topic_id36) - { - unset($tracking['t'][$topic_id36]); - } - - if (isset($tracking['f'][$f_id])) - { - unset($tracking['f'][$f_id]); - } - - $tracking['f'][$f_id] = base_convert($post_time - $config['board_startdate'], 10, 36); - } - - if (isset($tracking['tf']) && empty($tracking['tf'])) - { - unset($tracking['tf']); - } - - $user->set_cookie('track', tracking_serialize($tracking), $post_time + 31536000); - $request->overwrite($config['cookie_name'] . '_track', tracking_serialize($tracking), \phpbb\request\request_interface::COOKIE); - - unset($tracking); - } - } - else if ($mode == 'topic') - { - if ($topic_id === false || $forum_id === false) - { - return; - } - - /* @var $phpbb_notifications \phpbb\notification\manager */ - $phpbb_notifications = $phpbb_container->get('notification_manager'); - - // Mark post notifications read for this user in this topic - $phpbb_notifications->mark_notifications(array( - 'notification.type.topic', - 'notification.type.approve_topic', - ), $topic_id, $user->data['user_id'], $post_time); - - $phpbb_notifications->mark_notifications_by_parent(array( - 'notification.type.quote', - 'notification.type.bookmark', - 'notification.type.post', - 'notification.type.approve_post', - ), $topic_id, $user->data['user_id'], $post_time); - - if ($config['load_db_lastread'] && $user->data['is_registered']) - { - $sql = 'UPDATE ' . TOPICS_TRACK_TABLE . " - SET mark_time = $post_time - WHERE user_id = {$user->data['user_id']} - AND mark_time < $post_time - AND topic_id = $topic_id"; - $db->sql_query($sql); - - // insert row - if (!$db->sql_affectedrows()) - { - $db->sql_return_on_error(true); - - $sql_ary = array( - 'user_id' => (int) $user->data['user_id'], - 'topic_id' => (int) $topic_id, - 'forum_id' => (int) $forum_id, - 'mark_time' => $post_time, - ); - - $db->sql_query('INSERT INTO ' . TOPICS_TRACK_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); - - $db->sql_return_on_error(false); - } - } - else if ($config['load_anon_lastread'] || $user->data['is_registered']) - { - $tracking = $request->variable($config['cookie_name'] . '_track', '', true, \phpbb\request\request_interface::COOKIE); - $tracking = ($tracking) ? tracking_unserialize($tracking) : array(); - - $topic_id36 = base_convert($topic_id, 10, 36); - - if (!isset($tracking['t'][$topic_id36])) - { - $tracking['tf'][$forum_id][$topic_id36] = true; - } - - $tracking['t'][$topic_id36] = base_convert($post_time - (int) $config['board_startdate'], 10, 36); - - // If the cookie grows larger than 10000 characters we will remove the smallest value - // This can result in old topics being unread - but most of the time it should be accurate... - if (strlen($request->variable($config['cookie_name'] . '_track', '', true, \phpbb\request\request_interface::COOKIE)) > 10000) - { - //echo 'Cookie grown too large' . print_r($tracking, true); - - // We get the ten most minimum stored time offsets and its associated topic ids - $time_keys = array(); - for ($i = 0; $i < 10 && count($tracking['t']); $i++) - { - $min_value = min($tracking['t']); - $m_tkey = array_search($min_value, $tracking['t']); - unset($tracking['t'][$m_tkey]); - - $time_keys[$m_tkey] = $min_value; - } - - // Now remove the topic ids from the array... - foreach ($tracking['tf'] as $f_id => $topic_id_ary) - { - foreach ($time_keys as $m_tkey => $min_value) - { - if (isset($topic_id_ary[$m_tkey])) - { - $tracking['f'][$f_id] = $min_value; - unset($tracking['tf'][$f_id][$m_tkey]); - } - } - } - - if ($user->data['is_registered']) - { - $user->data['user_lastmark'] = intval(base_convert(max($time_keys) + $config['board_startdate'], 36, 10)); - - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_lastmark = $post_time - WHERE user_id = {$user->data['user_id']} - AND mark_time < $post_time"; - $db->sql_query($sql); - } - else - { - $tracking['l'] = max($time_keys); - } - } - - $user->set_cookie('track', tracking_serialize($tracking), $post_time + 31536000); - $request->overwrite($config['cookie_name'] . '_track', tracking_serialize($tracking), \phpbb\request\request_interface::COOKIE); - } - } - else if ($mode == 'post') - { - if ($topic_id === false) - { - return; - } - - $use_user_id = (!$user_id) ? $user->data['user_id'] : $user_id; - - if ($config['load_db_track'] && $use_user_id != ANONYMOUS) - { - $db->sql_return_on_error(true); - - $sql_ary = array( - 'user_id' => (int) $use_user_id, - 'topic_id' => (int) $topic_id, - 'topic_posted' => 1, - ); - - $db->sql_query('INSERT INTO ' . TOPICS_POSTED_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); - - $db->sql_return_on_error(false); - } - } - - /** - * This event is used for performing actions directly after forums, - * topics or posts have been marked as read. - * - * @event core.markread_after - * @var string mode Variable containing marking mode value - * @var mixed forum_id Variable containing forum id, or false - * @var mixed topic_id Variable containing topic id, or false - * @var int post_time Variable containing post time - * @var int user_id Variable containing the user id - * @since 3.2.6-RC1 - */ - $vars = array( - 'mode', - 'forum_id', - 'topic_id', - 'post_time', - 'user_id', - ); - extract($phpbb_dispatcher->trigger_event('core.markread_after', compact($vars))); -} - -/** -* Get topic tracking info by using already fetched info -*/ -function get_topic_tracking($forum_id, $topic_ids, &$rowset, $forum_mark_time, $global_announce_list = false) -{ - global $user; - - $last_read = array(); - - if (!is_array($topic_ids)) - { - $topic_ids = array($topic_ids); - } - - foreach ($topic_ids as $topic_id) - { - if (!empty($rowset[$topic_id]['mark_time'])) - { - $last_read[$topic_id] = $rowset[$topic_id]['mark_time']; - } - } - - $topic_ids = array_diff($topic_ids, array_keys($last_read)); - - if (count($topic_ids)) - { - $mark_time = array(); - - if (!empty($forum_mark_time[$forum_id]) && $forum_mark_time[$forum_id] !== false) - { - $mark_time[$forum_id] = $forum_mark_time[$forum_id]; - } - - $user_lastmark = (isset($mark_time[$forum_id])) ? $mark_time[$forum_id] : $user->data['user_lastmark']; - - foreach ($topic_ids as $topic_id) - { - $last_read[$topic_id] = $user_lastmark; - } - } - - return $last_read; -} - -/** -* Get topic tracking info from db (for cookie based tracking only this function is used) -*/ -function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_list = false) -{ - global $config, $user, $request; - - $last_read = array(); - - if (!is_array($topic_ids)) - { - $topic_ids = array($topic_ids); - } - - if ($config['load_db_lastread'] && $user->data['is_registered']) - { - global $db; - - $sql = 'SELECT topic_id, mark_time - FROM ' . TOPICS_TRACK_TABLE . " - WHERE user_id = {$user->data['user_id']} - AND " . $db->sql_in_set('topic_id', $topic_ids); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $last_read[$row['topic_id']] = $row['mark_time']; - } - $db->sql_freeresult($result); - - $topic_ids = array_diff($topic_ids, array_keys($last_read)); - - if (count($topic_ids)) - { - $sql = 'SELECT forum_id, mark_time - FROM ' . FORUMS_TRACK_TABLE . " - WHERE user_id = {$user->data['user_id']} - AND forum_id = $forum_id"; - $result = $db->sql_query($sql); - - $mark_time = array(); - while ($row = $db->sql_fetchrow($result)) - { - $mark_time[$row['forum_id']] = $row['mark_time']; - } - $db->sql_freeresult($result); - - $user_lastmark = (isset($mark_time[$forum_id])) ? $mark_time[$forum_id] : $user->data['user_lastmark']; - - foreach ($topic_ids as $topic_id) - { - $last_read[$topic_id] = $user_lastmark; - } - } - } - else if ($config['load_anon_lastread'] || $user->data['is_registered']) - { - global $tracking_topics; - - if (!isset($tracking_topics) || !count($tracking_topics)) - { - $tracking_topics = $request->variable($config['cookie_name'] . '_track', '', true, \phpbb\request\request_interface::COOKIE); - $tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array(); - } - - if (!$user->data['is_registered']) - { - $user_lastmark = (isset($tracking_topics['l'])) ? base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate'] : 0; - } - else - { - $user_lastmark = $user->data['user_lastmark']; - } - - foreach ($topic_ids as $topic_id) - { - $topic_id36 = base_convert($topic_id, 10, 36); - - if (isset($tracking_topics['t'][$topic_id36])) - { - $last_read[$topic_id] = base_convert($tracking_topics['t'][$topic_id36], 36, 10) + $config['board_startdate']; - } - } - - $topic_ids = array_diff($topic_ids, array_keys($last_read)); - - if (count($topic_ids)) - { - $mark_time = array(); - - if (isset($tracking_topics['f'][$forum_id])) - { - $mark_time[$forum_id] = base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate']; - } - - $user_lastmark = (isset($mark_time[$forum_id])) ? $mark_time[$forum_id] : $user_lastmark; - - foreach ($topic_ids as $topic_id) - { - $last_read[$topic_id] = $user_lastmark; - } - } - } - - return $last_read; -} - -/** -* Get list of unread topics -* -* @param int $user_id User ID (or false for current user) -* @param string $sql_extra Extra WHERE SQL statement -* @param string $sql_sort ORDER BY SQL sorting statement -* @param string $sql_limit Limits the size of unread topics list, 0 for unlimited query -* @param string $sql_limit_offset Sets the offset of the first row to search, 0 to search from the start -* -* @return array[int][int] Topic ids as keys, mark_time of topic as value -*/ -function get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $sql_limit = 1001, $sql_limit_offset = 0) -{ - global $config, $db, $user, $request; - global $phpbb_dispatcher; - - $user_id = ($user_id === false) ? (int) $user->data['user_id'] : (int) $user_id; - - // Data array we're going to return - $unread_topics = array(); - - if (empty($sql_sort)) - { - $sql_sort = 'ORDER BY t.topic_last_post_time DESC, t.topic_last_post_id DESC'; - } - - if ($config['load_db_lastread'] && $user->data['is_registered']) - { - // Get list of the unread topics - $last_mark = (int) $user->data['user_lastmark']; - - $sql_array = array( - 'SELECT' => 't.topic_id, t.topic_last_post_time, tt.mark_time as topic_mark_time, ft.mark_time as forum_mark_time', - - 'FROM' => array(TOPICS_TABLE => 't'), - - 'LEFT_JOIN' => array( - array( - 'FROM' => array(TOPICS_TRACK_TABLE => 'tt'), - 'ON' => "tt.user_id = $user_id AND t.topic_id = tt.topic_id", - ), - array( - 'FROM' => array(FORUMS_TRACK_TABLE => 'ft'), - 'ON' => "ft.user_id = $user_id AND t.forum_id = ft.forum_id", - ), - ), - - 'WHERE' => " - t.topic_last_post_time > $last_mark AND - ( - (tt.mark_time IS NOT NULL AND t.topic_last_post_time > tt.mark_time) OR - (tt.mark_time IS NULL AND ft.mark_time IS NOT NULL AND t.topic_last_post_time > ft.mark_time) OR - (tt.mark_time IS NULL AND ft.mark_time IS NULL) - ) - $sql_extra - $sql_sort", - ); - - /** - * Change SQL query for fetching unread topics data - * - * @event core.get_unread_topics_modify_sql - * @var array sql_array Fully assembled SQL query with keys SELECT, FROM, LEFT_JOIN, WHERE - * @var int last_mark User's last_mark time - * @var string sql_extra Extra WHERE SQL statement - * @var string sql_sort ORDER BY SQL sorting statement - * @since 3.1.4-RC1 - */ - $vars = array( - 'sql_array', - 'last_mark', - 'sql_extra', - 'sql_sort', - ); - extract($phpbb_dispatcher->trigger_event('core.get_unread_topics_modify_sql', compact($vars))); - - $sql = $db->sql_build_query('SELECT', $sql_array); - $result = $db->sql_query_limit($sql, $sql_limit, $sql_limit_offset); - - while ($row = $db->sql_fetchrow($result)) - { - $topic_id = (int) $row['topic_id']; - $unread_topics[$topic_id] = ($row['topic_mark_time']) ? (int) $row['topic_mark_time'] : (($row['forum_mark_time']) ? (int) $row['forum_mark_time'] : $last_mark); - } - $db->sql_freeresult($result); - } - else if ($config['load_anon_lastread'] || $user->data['is_registered']) - { - global $tracking_topics; - - if (empty($tracking_topics)) - { - $tracking_topics = $request->variable($config['cookie_name'] . '_track', '', false, \phpbb\request\request_interface::COOKIE); - $tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array(); - } - - if (!$user->data['is_registered']) - { - $user_lastmark = (isset($tracking_topics['l'])) ? base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate'] : 0; - } - else - { - $user_lastmark = (int) $user->data['user_lastmark']; - } - - $sql = 'SELECT t.topic_id, t.forum_id, t.topic_last_post_time - FROM ' . TOPICS_TABLE . ' t - WHERE t.topic_last_post_time > ' . $user_lastmark . " - $sql_extra - $sql_sort"; - $result = $db->sql_query_limit($sql, $sql_limit, $sql_limit_offset); - - while ($row = $db->sql_fetchrow($result)) - { - $forum_id = (int) $row['forum_id']; - $topic_id = (int) $row['topic_id']; - $topic_id36 = base_convert($topic_id, 10, 36); - - if (isset($tracking_topics['t'][$topic_id36])) - { - $last_read = base_convert($tracking_topics['t'][$topic_id36], 36, 10) + $config['board_startdate']; - - if ($row['topic_last_post_time'] > $last_read) - { - $unread_topics[$topic_id] = $last_read; - } - } - else if (isset($tracking_topics['f'][$forum_id])) - { - $mark_time = base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate']; - - if ($row['topic_last_post_time'] > $mark_time) - { - $unread_topics[$topic_id] = $mark_time; - } - } - else - { - $unread_topics[$topic_id] = $user_lastmark; - } - } - $db->sql_freeresult($result); - } - - return $unread_topics; -} - -/** -* Check for read forums and update topic tracking info accordingly -* -* @param int $forum_id the forum id to check -* @param int $forum_last_post_time the forums last post time -* @param int $f_mark_time the forums last mark time if user is registered and load_db_lastread enabled -* @param int $mark_time_forum false if the mark time needs to be obtained, else the last users forum mark time -* -* @return true if complete forum got marked read, else false. -*/ -function update_forum_tracking_info($forum_id, $forum_last_post_time, $f_mark_time = false, $mark_time_forum = false) -{ - global $db, $tracking_topics, $user, $config, $request, $phpbb_container; - - // Determine the users last forum mark time if not given. - if ($mark_time_forum === false) - { - if ($config['load_db_lastread'] && $user->data['is_registered']) - { - $mark_time_forum = (!empty($f_mark_time)) ? $f_mark_time : $user->data['user_lastmark']; - } - else if ($config['load_anon_lastread'] || $user->data['is_registered']) - { - $tracking_topics = $request->variable($config['cookie_name'] . '_track', '', true, \phpbb\request\request_interface::COOKIE); - $tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array(); - - if (!$user->data['is_registered']) - { - $user->data['user_lastmark'] = (isset($tracking_topics['l'])) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0; - } - - $mark_time_forum = (isset($tracking_topics['f'][$forum_id])) ? (int) (base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate']) : $user->data['user_lastmark']; - } - } - - // Handle update of unapproved topics info. - // Only update for moderators having m_approve permission for the forum. - /* @var $phpbb_content_visibility \phpbb\content_visibility */ - $phpbb_content_visibility = $phpbb_container->get('content.visibility'); - - // Check the forum for any left unread topics. - // If there are none, we mark the forum as read. - if ($config['load_db_lastread'] && $user->data['is_registered']) - { - if ($mark_time_forum >= $forum_last_post_time) - { - // We do not need to mark read, this happened before. Therefore setting this to true - $row = true; - } - else - { - $sql = 'SELECT t.forum_id - FROM ' . TOPICS_TABLE . ' t - LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt - ON (tt.topic_id = t.topic_id - AND tt.user_id = ' . $user->data['user_id'] . ') - WHERE t.forum_id = ' . $forum_id . ' - AND t.topic_last_post_time > ' . $mark_time_forum . ' - AND t.topic_moved_id = 0 - AND ' . $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.') . ' - AND (tt.topic_id IS NULL - OR tt.mark_time < t.topic_last_post_time)'; - $result = $db->sql_query_limit($sql, 1); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - } - } - else if ($config['load_anon_lastread'] || $user->data['is_registered']) - { - // Get information from cookie - if (!isset($tracking_topics['tf'][$forum_id])) - { - // We do not need to mark read, this happened before. Therefore setting this to true - $row = true; - } - else - { - $sql = 'SELECT t.topic_id - FROM ' . TOPICS_TABLE . ' t - WHERE t.forum_id = ' . $forum_id . ' - AND t.topic_last_post_time > ' . $mark_time_forum . ' - AND t.topic_moved_id = 0 - AND ' . $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.'); - $result = $db->sql_query($sql); - - $check_forum = $tracking_topics['tf'][$forum_id]; - $unread = false; - - while ($row = $db->sql_fetchrow($result)) - { - if (!isset($check_forum[base_convert($row['topic_id'], 10, 36)])) - { - $unread = true; - break; - } - } - $db->sql_freeresult($result); - - $row = $unread; - } - } - else - { - $row = true; - } - - if (!$row) - { - markread('topics', $forum_id); - return true; - } - - return false; -} - -/** -* Transform an array into a serialized format -*/ -function tracking_serialize($input) -{ - $out = ''; - foreach ($input as $key => $value) - { - if (is_array($value)) - { - $out .= $key . ':(' . tracking_serialize($value) . ');'; - } - else - { - $out .= $key . ':' . $value . ';'; - } - } - return $out; -} - -/** -* Transform a serialized array into an actual array -*/ -function tracking_unserialize($string, $max_depth = 3) -{ - $n = strlen($string); - if ($n > 10010) - { - die('Invalid data supplied'); - } - $data = $stack = array(); - $key = ''; - $mode = 0; - $level = &$data; - for ($i = 0; $i < $n; ++$i) - { - switch ($mode) - { - case 0: - switch ($string[$i]) - { - case ':': - $level[$key] = 0; - $mode = 1; - break; - case ')': - unset($level); - $level = array_pop($stack); - $mode = 3; - break; - default: - $key .= $string[$i]; - } - break; - - case 1: - switch ($string[$i]) - { - case '(': - if (count($stack) >= $max_depth) - { - die('Invalid data supplied'); - } - $stack[] = &$level; - $level[$key] = array(); - $level = &$level[$key]; - $key = ''; - $mode = 0; - break; - default: - $level[$key] = $string[$i]; - $mode = 2; - break; - } - break; - - case 2: - switch ($string[$i]) - { - case ')': - unset($level); - $level = array_pop($stack); - $mode = 3; - break; - case ';': - $key = ''; - $mode = 0; - break; - default: - $level[$key] .= $string[$i]; - break; - } - break; - - case 3: - switch ($string[$i]) - { - case ')': - unset($level); - $level = array_pop($stack); - break; - case ';': - $key = ''; - $mode = 0; - break; - default: - die('Invalid data supplied'); - break; - } - break; - } - } - - if (count($stack) != 0 || ($mode != 0 && $mode != 3)) - { - die('Invalid data supplied'); - } - - return $level; -} - -// Server functions (building urls, redirecting...) - -/** -* Append session id to url. -* This function supports hooks. -* -* @param string $url The url the session id needs to be appended to (can have params) -* @param mixed $params String or array of additional url parameters -* @param bool $is_amp Is url using & (true) or & (false) -* @param string $session_id Possibility to use a custom session id instead of the global one -* @param bool $is_route Is url generated by a route. -* -* @return string The corrected url. -* -* Examples: -* -* append_sid("{$phpbb_root_path}viewtopic.$phpEx?t=1&f=2"); -* append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=1&f=2'); -* append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=1&f=2', false); -* append_sid("{$phpbb_root_path}viewtopic.$phpEx", array('t' => 1, 'f' => 2)); -* -* -*/ -function append_sid($url, $params = false, $is_amp = true, $session_id = false, $is_route = false) -{ - global $_SID, $_EXTRA_URL, $phpbb_hook, $phpbb_path_helper; - global $phpbb_dispatcher; - - if ($params === '' || (is_array($params) && empty($params))) - { - // Do not append the ? if the param-list is empty anyway. - $params = false; - } - - // Update the root path with the correct relative web path - if (!$is_route && $phpbb_path_helper instanceof \phpbb\path_helper) - { - $url = $phpbb_path_helper->update_web_root_path($url); - } - - $append_sid_overwrite = false; - - /** - * This event can either supplement or override the append_sid() function - * - * To override this function, the event must set $append_sid_overwrite to - * the new URL value, which will be returned following the event - * - * @event core.append_sid - * @var string url The url the session id needs - * to be appended to (can have - * params) - * @var mixed params String or array of additional - * url parameters - * @var bool is_amp Is url using & (true) or - * & (false) - * @var bool|string session_id Possibility to use a custom - * session id (string) instead of - * the global one (false) - * @var bool|string append_sid_overwrite Overwrite function (string - * URL) or not (false) - * @var bool is_route Is url generated by a route. - * @since 3.1.0-a1 - */ - $vars = array('url', 'params', 'is_amp', 'session_id', 'append_sid_overwrite', 'is_route'); - extract($phpbb_dispatcher->trigger_event('core.append_sid', compact($vars))); - - if ($append_sid_overwrite) - { - return $append_sid_overwrite; - } - - // The following hook remains for backwards compatibility, though use of - // the event above is preferred. - // Developers using the hook function need to globalise the $_SID and $_EXTRA_URL on their own and also handle it appropriately. - // They could mimic most of what is within this function - if (!empty($phpbb_hook) && $phpbb_hook->call_hook(__FUNCTION__, $url, $params, $is_amp, $session_id)) - { - if ($phpbb_hook->hook_return(__FUNCTION__)) - { - return $phpbb_hook->hook_return_result(__FUNCTION__); - } - } - - $params_is_array = is_array($params); - - // Get anchor - $anchor = ''; - if (strpos($url, '#') !== false) - { - list($url, $anchor) = explode('#', $url, 2); - $anchor = '#' . $anchor; - } - else if (!$params_is_array && strpos($params, '#') !== false) - { - list($params, $anchor) = explode('#', $params, 2); - $anchor = '#' . $anchor; - } - - // Handle really simple cases quickly - if ($_SID == '' && $session_id === false && empty($_EXTRA_URL) && !$params_is_array && !$anchor) - { - if ($params === false) - { - return $url; - } - - $url_delim = (strpos($url, '?') === false) ? '?' : (($is_amp) ? '&' : '&'); - return $url . ($params !== false ? $url_delim. $params : ''); - } - - // Assign sid if session id is not specified - if ($session_id === false) - { - $session_id = $_SID; - } - - $amp_delim = ($is_amp) ? '&' : '&'; - $url_delim = (strpos($url, '?') === false) ? '?' : $amp_delim; - - // Appending custom url parameter? - $append_url = (!empty($_EXTRA_URL)) ? implode($amp_delim, $_EXTRA_URL) : ''; - - // Use the short variant if possible ;) - if ($params === false) - { - // Append session id - if (!$session_id) - { - return $url . (($append_url) ? $url_delim . $append_url : '') . $anchor; - } - else - { - return $url . (($append_url) ? $url_delim . $append_url . $amp_delim : $url_delim) . 'sid=' . $session_id . $anchor; - } - } - - // Build string if parameters are specified as array - if (is_array($params)) - { - $output = array(); - - foreach ($params as $key => $item) - { - if ($item === NULL) - { - continue; - } - - if ($key == '#') - { - $anchor = '#' . $item; - continue; - } - - $output[] = $key . '=' . $item; - } - - $params = implode($amp_delim, $output); - } - - // Append session id and parameters (even if they are empty) - // If parameters are empty, the developer can still append his/her parameters without caring about the delimiter - return $url . (($append_url) ? $url_delim . $append_url . $amp_delim : $url_delim) . $params . ((!$session_id) ? '' : $amp_delim . 'sid=' . $session_id) . $anchor; -} - -/** -* Generate board url (example: http://www.example.com/phpBB) -* -* @param bool $without_script_path if set to true the script path gets not appended (example: http://www.example.com) -* -* @return string the generated board url -*/ -function generate_board_url($without_script_path = false) -{ - global $config, $user, $request, $symfony_request; - - $server_name = $user->host; - - // Forcing server vars is the only way to specify/override the protocol - if ($config['force_server_vars'] || !$server_name) - { - $server_protocol = ($config['server_protocol']) ? $config['server_protocol'] : (($config['cookie_secure']) ? 'https://' : 'http://'); - $server_name = $config['server_name']; - $server_port = (int) $config['server_port']; - $script_path = $config['script_path']; - - $url = $server_protocol . $server_name; - $cookie_secure = $config['cookie_secure']; - } - else - { - $server_port = (int) $symfony_request->getPort(); - - $forwarded_proto = $request->server('HTTP_X_FORWARDED_PROTO'); - - if (!empty($forwarded_proto) && $forwarded_proto === 'https') - { - $server_port = 443; - } - // Do not rely on cookie_secure, users seem to think that it means a secured cookie instead of an encrypted connection - $cookie_secure = $request->is_secure() ? 1 : 0; - $url = (($cookie_secure) ? 'https://' : 'http://') . $server_name; - - $script_path = $user->page['root_script_path']; - } - - if ($server_port && (($cookie_secure && $server_port <> 443) || (!$cookie_secure && $server_port <> 80))) - { - // HTTP HOST can carry a port number (we fetch $user->host, but for old versions this may be true) - if (strpos($server_name, ':') === false) - { - $url .= ':' . $server_port; - } - } - - if (!$without_script_path) - { - $url .= $script_path; - } - - // Strip / from the end - if (substr($url, -1, 1) == '/') - { - $url = substr($url, 0, -1); - } - - return $url; -} - -/** -* Redirects the user to another page then exits the script nicely -* This function is intended for urls within the board. It's not meant to redirect to cross-domains. -* -* @param string $url The url to redirect to -* @param bool $return If true, do not redirect but return the sanitized URL. Default is no return. -* @param bool $disable_cd_check If true, redirect() will redirect to an external domain. If false, the redirect point to the boards url if it does not match the current domain. Default is false. -*/ -function redirect($url, $return = false, $disable_cd_check = false) -{ - global $user, $phpbb_path_helper, $phpbb_dispatcher; - - if (!$user->is_setup()) - { - $user->add_lang('common'); - } - - // Make sure no &'s are in, this will break the redirect - $url = str_replace('&', '&', $url); - - // Determine which type of redirect we need to handle... - $url_parts = @parse_url($url); - - if ($url_parts === false) - { - // Malformed url - trigger_error('INSECURE_REDIRECT', E_USER_WARNING); - } - else if (!empty($url_parts['scheme']) && !empty($url_parts['host'])) - { - // Attention: only able to redirect within the same domain if $disable_cd_check is false (yourdomain.com -> www.yourdomain.com will not work) - if (!$disable_cd_check && $url_parts['host'] !== $user->host) - { - trigger_error('INSECURE_REDIRECT', E_USER_WARNING); - } - } - else if ($url[0] == '/') - { - // Absolute uri, prepend direct url... - $url = generate_board_url(true) . $url; - } - else - { - // Relative uri - $pathinfo = pathinfo($url); - - // Is the uri pointing to the current directory? - if ($pathinfo['dirname'] == '.') - { - $url = str_replace('./', '', $url); - - // Strip / from the beginning - if ($url && substr($url, 0, 1) == '/') - { - $url = substr($url, 1); - } - } - - $url = $phpbb_path_helper->remove_web_root_path($url); - - if ($user->page['page_dir']) - { - $url = $user->page['page_dir'] . '/' . $url; - } - - $url = generate_board_url() . '/' . $url; - } - - // Clean URL and check if we go outside the forum directory - $url = $phpbb_path_helper->clean_url($url); - - if (!$disable_cd_check && strpos($url, generate_board_url(true) . '/') !== 0) - { - trigger_error('INSECURE_REDIRECT', E_USER_WARNING); - } - - // Make sure no linebreaks are there... to prevent http response splitting for PHP < 4.4.2 - if (strpos(urldecode($url), "\n") !== false || strpos(urldecode($url), "\r") !== false || strpos($url, ';') !== false) - { - trigger_error('INSECURE_REDIRECT', E_USER_WARNING); - } - - // Now, also check the protocol and for a valid url the last time... - $allowed_protocols = array('http', 'https', 'ftp', 'ftps'); - $url_parts = parse_url($url); - - if ($url_parts === false || empty($url_parts['scheme']) || !in_array($url_parts['scheme'], $allowed_protocols)) - { - trigger_error('INSECURE_REDIRECT', E_USER_WARNING); - } - - /** - * Execute code and/or overwrite redirect() - * - * @event core.functions.redirect - * @var string url The url - * @var bool return If true, do not redirect but return the sanitized URL. - * @var bool disable_cd_check If true, redirect() will redirect to an external domain. If false, the redirect point to the boards url if it does not match the current domain. - * @since 3.1.0-RC3 - */ - $vars = array('url', 'return', 'disable_cd_check'); - extract($phpbb_dispatcher->trigger_event('core.functions.redirect', compact($vars))); - - if ($return) - { - return $url; - } - else - { - garbage_collection(); - } - - // Behave as per HTTP/1.1 spec for others - header('Location: ' . $url); - exit; -} - -/** -* Re-Apply session id after page reloads -*/ -function reapply_sid($url, $is_route = false) -{ - global $phpEx, $phpbb_root_path; - - if ($url === "index.$phpEx") - { - return append_sid("index.$phpEx"); - } - else if ($url === "{$phpbb_root_path}index.$phpEx") - { - return append_sid("{$phpbb_root_path}index.$phpEx"); - } - - // Remove previously added sid - if (strpos($url, 'sid=') !== false) - { - // All kind of links - $url = preg_replace('/(\?)?(&|&)?sid=[a-z0-9]+/', '', $url); - // if the sid was the first param, make the old second as first ones - $url = preg_replace("/$phpEx(&|&)+?/", "$phpEx?", $url); - } - - return append_sid($url, false, true, false, $is_route); -} - -/** -* Returns url from the session/current page with an re-appended SID with optionally stripping vars from the url -*/ -function build_url($strip_vars = false) -{ - global $config, $user, $phpbb_path_helper; - - $page = $phpbb_path_helper->get_valid_page($user->page['page'], $config['enable_mod_rewrite']); - - // Append SID - $redirect = append_sid($page, false, false); - - if ($strip_vars !== false) - { - $redirect = $phpbb_path_helper->strip_url_params($redirect, $strip_vars, false); - } - else - { - $redirect = str_replace('&', '&', $redirect); - } - - return $redirect . ((strpos($redirect, '?') === false) ? '?' : ''); -} - -/** -* Meta refresh assignment -* Adds META template variable with meta http tag. -* -* @param int $time Time in seconds for meta refresh tag -* @param string $url URL to redirect to. The url will go through redirect() first before the template variable is assigned -* @param bool $disable_cd_check If true, meta_refresh() will redirect to an external domain. If false, the redirect point to the boards url if it does not match the current domain. Default is false. -*/ -function meta_refresh($time, $url, $disable_cd_check = false) -{ - global $template, $refresh_data, $request; - - $url = redirect($url, true, $disable_cd_check); - if ($request->is_ajax()) - { - $refresh_data = array( - 'time' => $time, - 'url' => $url, - ); - } - else - { - // For XHTML compatibility we change back & to & - $url = str_replace('&', '&', $url); - - $template->assign_vars(array( - 'META' => '') - ); - } - - return $url; -} - -/** -* Outputs correct status line header. -* -* Depending on php sapi one of the two following forms is used: -* -* Status: 404 Not Found -* -* HTTP/1.x 404 Not Found -* -* HTTP version is taken from HTTP_VERSION environment variable, -* and defaults to 1.0. -* -* Sample usage: -* -* send_status_line(404, 'Not Found'); -* -* @param int $code HTTP status code -* @param string $message Message for the status code -* @return null -*/ -function send_status_line($code, $message) -{ - if (substr(strtolower(@php_sapi_name()), 0, 3) === 'cgi') - { - // in theory, we shouldn't need that due to php doing it. Reality offers a differing opinion, though - header("Status: $code $message", true, $code); - } - else - { - $version = phpbb_request_http_version(); - header("$version $code $message", true, $code); - } -} - -/** -* Returns the HTTP version used in the current request. -* -* Handles the case of being called before $request is present, -* in which case it falls back to the $_SERVER superglobal. -* -* @return string HTTP version -*/ -function phpbb_request_http_version() -{ - global $request; - - $version = ''; - if ($request && $request->server('SERVER_PROTOCOL')) - { - $version = $request->server('SERVER_PROTOCOL'); - } - else if (isset($_SERVER['SERVER_PROTOCOL'])) - { - $version = $_SERVER['SERVER_PROTOCOL']; - } - - if (!empty($version) && is_string($version) && preg_match('#^HTTP/[0-9]\.[0-9]$#', $version)) - { - return $version; - } - - return 'HTTP/1.0'; -} - -//Form validation - - -/** -* Add a secret hash for use in links/GET requests -* @param string $link_name The name of the link; has to match the name used in check_link_hash, otherwise no restrictions apply -* @return string the hash - -*/ -function generate_link_hash($link_name) -{ - global $user; - - if (!isset($user->data["hash_$link_name"])) - { - $user->data["hash_$link_name"] = substr(sha1($user->data['user_form_salt'] . $link_name), 0, 8); - } - - return $user->data["hash_$link_name"]; -} - - -/** -* checks a link hash - for GET requests -* @param string $token the submitted token -* @param string $link_name The name of the link -* @return boolean true if all is fine -*/ -function check_link_hash($token, $link_name) -{ - return $token === generate_link_hash($link_name); -} - -/** -* Add a secret token to the form (requires the S_FORM_TOKEN template variable) -* @param string $form_name The name of the form; has to match the name used in check_form_key, otherwise no restrictions apply -* @param string $template_variable_suffix A string that is appended to the name of the template variable to which the form elements are assigned -*/ -function add_form_key($form_name, $template_variable_suffix = '') -{ - global $config, $template, $user, $phpbb_dispatcher; - - $now = time(); - $token_sid = ($user->data['user_id'] == ANONYMOUS && !empty($config['form_token_sid_guests'])) ? $user->session_id : ''; - $token = sha1($now . $user->data['user_form_salt'] . $form_name . $token_sid); - - $s_fields = build_hidden_fields(array( - 'creation_time' => $now, - 'form_token' => $token, - )); - - /** - * Perform additional actions on creation of the form token - * - * @event core.add_form_key - * @var string form_name The form name - * @var int now Current time timestamp - * @var string s_fields Generated hidden fields - * @var string token Form token - * @var string token_sid User session ID - * @var string template_variable_suffix The string that is appended to template variable name - * - * @since 3.1.0-RC3 - * @changed 3.1.11-RC1 Added template_variable_suffix - */ - $vars = array( - 'form_name', - 'now', - 's_fields', - 'token', - 'token_sid', - 'template_variable_suffix', - ); - extract($phpbb_dispatcher->trigger_event('core.add_form_key', compact($vars))); - - $template->assign_var('S_FORM_TOKEN' . $template_variable_suffix, $s_fields); -} - -/** - * Check the form key. Required for all altering actions not secured by confirm_box - * - * @param string $form_name The name of the form; has to match the name used - * in add_form_key, otherwise no restrictions apply - * @param int $timespan The maximum acceptable age for a submitted form - * in seconds. Defaults to the config setting. - * @return bool True, if the form key was valid, false otherwise - */ -function check_form_key($form_name, $timespan = false) -{ - global $config, $request, $user; - - if ($timespan === false) - { - // we enforce a minimum value of half a minute here. - $timespan = ($config['form_token_lifetime'] == -1) ? -1 : max(30, $config['form_token_lifetime']); - } - - if ($request->is_set_post('creation_time') && $request->is_set_post('form_token')) - { - $creation_time = abs($request->variable('creation_time', 0)); - $token = $request->variable('form_token', ''); - - $diff = time() - $creation_time; - - // If creation_time and the time() now is zero we can assume it was not a human doing this (the check for if ($diff)... - if (defined('DEBUG_TEST') || $diff && ($diff <= $timespan || $timespan === -1)) - { - $token_sid = ($user->data['user_id'] == ANONYMOUS && !empty($config['form_token_sid_guests'])) ? $user->session_id : ''; - $key = sha1($creation_time . $user->data['user_form_salt'] . $form_name . $token_sid); - - if ($key === $token) - { - return true; - } - } - } - - return false; -} - -// Message/Login boxes - -/** -* Build Confirm box -* @param boolean $check True for checking if confirmed (without any additional parameters) and false for displaying the confirm box -* @param string|array $title Title/Message used for confirm box. -* message text is _CONFIRM appended to title. -* If title cannot be found in user->lang a default one is displayed -* If title_CONFIRM cannot be found in user->lang the text given is used. -* If title is an array, the first array value is used as explained per above, -* all other array values are sent as parameters to the language function. -* @param string $hidden Hidden variables -* @param string $html_body Template used for confirm box -* @param string $u_action Custom form action -* -* @return bool True if confirmation was successful, false if not -*/ -function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_body.html', $u_action = '') -{ - global $user, $template, $db, $request; - global $config, $language, $phpbb_path_helper, $phpbb_dispatcher; - - if (isset($_POST['cancel'])) - { - return false; - } - - $confirm = ($language->lang('YES') === $request->variable('confirm', '', true, \phpbb\request\request_interface::POST)); - - if ($check && $confirm) - { - $user_id = $request->variable('confirm_uid', 0); - $session_id = $request->variable('sess', ''); - $confirm_key = $request->variable('confirm_key', ''); - - if ($user_id != $user->data['user_id'] || $session_id != $user->session_id || !$confirm_key || !$user->data['user_last_confirm_key'] || $confirm_key != $user->data['user_last_confirm_key']) - { - return false; - } - - // Reset user_last_confirm_key - $sql = 'UPDATE ' . USERS_TABLE . " SET user_last_confirm_key = '' - WHERE user_id = " . $user->data['user_id']; - $db->sql_query($sql); - - return true; - } - else if ($check) - { - return false; - } - - $s_hidden_fields = build_hidden_fields(array( - 'confirm_uid' => $user->data['user_id'], - 'sess' => $user->session_id, - 'sid' => $user->session_id, - )); - - // generate activation key - $confirm_key = gen_rand_string(10); - - // generate language strings - if (is_array($title)) - { - $key = array_shift($title); - $count = array_shift($title); - $confirm_title = $language->is_set($key) ? $language->lang($key, $count, $title) : $language->lang('CONFIRM'); - $confirm_text = $language->is_set($key . '_CONFIRM') ? $language->lang($key . '_CONFIRM', $count, $title) : $key; - } - else - { - $confirm_title = $language->is_set($title) ? $language->lang($title) : $language->lang('CONFIRM'); - $confirm_text = $language->is_set($title . '_CONFIRM') ? $language->lang($title . '_CONFIRM') : $title; - } - - if (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin']) - { - adm_page_header($confirm_title); - } - else - { - page_header($confirm_title); - } - - $template->set_filenames(array( - 'body' => $html_body) - ); - - // If activation key already exist, we better do not re-use the key (something very strange is going on...) - if ($request->variable('confirm_key', '')) - { - // This should not occur, therefore we cancel the operation to safe the user - return false; - } - - // re-add sid / transform & to & for user->page (user->page is always using &) - $use_page = ($u_action) ? $u_action : str_replace('&', '&', $user->page['page']); - $u_action = reapply_sid($phpbb_path_helper->get_valid_page($use_page, $config['enable_mod_rewrite'])); - $u_action .= ((strpos($u_action, '?') === false) ? '?' : '&') . 'confirm_key=' . $confirm_key; - - $template->assign_vars(array( - 'MESSAGE_TITLE' => $confirm_title, - 'MESSAGE_TEXT' => $confirm_text, - - 'YES_VALUE' => $language->lang('YES'), - 'S_CONFIRM_ACTION' => $u_action, - 'S_HIDDEN_FIELDS' => $hidden . $s_hidden_fields, - 'S_AJAX_REQUEST' => $request->is_ajax(), - )); - - $sql = 'UPDATE ' . USERS_TABLE . " SET user_last_confirm_key = '" . $db->sql_escape($confirm_key) . "' - WHERE user_id = " . $user->data['user_id']; - $db->sql_query($sql); - - if ($request->is_ajax()) - { - $u_action .= '&confirm_uid=' . $user->data['user_id'] . '&sess=' . $user->session_id . '&sid=' . $user->session_id; - $data = array( - 'MESSAGE_BODY' => $template->assign_display('body'), - 'MESSAGE_TITLE' => $confirm_title, - 'MESSAGE_TEXT' => $confirm_text, - - 'YES_VALUE' => $language->lang('YES'), - 'S_CONFIRM_ACTION' => str_replace('&', '&', $u_action), //inefficient, rewrite whole function - 'S_HIDDEN_FIELDS' => $hidden . $s_hidden_fields - ); - - /** - * This event allows an extension to modify the ajax output of confirm box. - * - * @event core.confirm_box_ajax_before - * @var string u_action Action of the form - * @var array data Data to be sent - * @var string hidden Hidden fields generated by caller - * @var string s_hidden_fields Hidden fields generated by this function - * @since 3.2.8-RC1 - */ - $vars = array( - 'u_action', - 'data', - 'hidden', - 's_hidden_fields', - ); - extract($phpbb_dispatcher->trigger_event('core.confirm_box_ajax_before', compact($vars))); - - $json_response = new \phpbb\json_response; - $json_response->send($data); - } - - if (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin']) - { - adm_page_footer(); - } - else - { - page_footer(); - } - - exit; // unreachable, page_footer() above will call exit() -} - -/** -* Generate login box or verify password -*/ -function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = false, $s_display = true) -{ - global $user, $template, $auth, $phpEx, $phpbb_root_path, $config; - global $request, $phpbb_container, $phpbb_dispatcher, $phpbb_log; - - $err = ''; - $form_name = 'login'; - $username = $autologin = false; - - // Make sure user->setup() has been called - if (!$user->is_setup()) - { - $user->setup(); - } - - /** - * This event allows an extension to modify the login process - * - * @event core.login_box_before - * @var string redirect Redirect string - * @var string l_explain Explain language string - * @var string l_success Success language string - * @var bool admin Is admin? - * @var bool s_display Display full login form? - * @var string err Error string - * @since 3.1.9-RC1 - */ - $vars = array('redirect', 'l_explain', 'l_success', 'admin', 's_display', 'err'); - extract($phpbb_dispatcher->trigger_event('core.login_box_before', compact($vars))); - - // Print out error if user tries to authenticate as an administrator without having the privileges... - if ($admin && !$auth->acl_get('a_')) - { - // Not authd - // anonymous/inactive users are never able to go to the ACP even if they have the relevant permissions - if ($user->data['is_registered']) - { - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ADMIN_AUTH_FAIL'); - } - send_status_line(403, 'Forbidden'); - trigger_error('NO_AUTH_ADMIN'); - } - - if (empty($err) && ($request->is_set_post('login') || ($request->is_set('login') && $request->variable('login', '') == 'external'))) - { - // Get credential - if ($admin) - { - $credential = $request->variable('credential', ''); - - if (strspn($credential, 'abcdef0123456789') !== strlen($credential) || strlen($credential) != 32) - { - if ($user->data['is_registered']) - { - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ADMIN_AUTH_FAIL'); - } - send_status_line(403, 'Forbidden'); - trigger_error('NO_AUTH_ADMIN'); - } - - $password = $request->untrimmed_variable('password_' . $credential, '', true); - } - else - { - $password = $request->untrimmed_variable('password', '', true); - } - - $username = $request->variable('username', '', true); - $autologin = $request->is_set_post('autologin'); - $viewonline = (int) !$request->is_set_post('viewonline'); - $admin = ($admin) ? 1 : 0; - $viewonline = ($admin) ? $user->data['session_viewonline'] : $viewonline; - - // Check if the supplied username is equal to the one stored within the database if re-authenticating - if ($admin && utf8_clean_string($username) != utf8_clean_string($user->data['username'])) - { - // We log the attempt to use a different username... - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ADMIN_AUTH_FAIL'); - - send_status_line(403, 'Forbidden'); - trigger_error('NO_AUTH_ADMIN_USER_DIFFER'); - } - - // Check form key - if ($password && !defined('IN_CHECK_BAN') && !check_form_key($form_name)) - { - $result = array( - 'status' => false, - 'error_msg' => 'FORM_INVALID', - ); - } - else - { - // If authentication is successful we redirect user to previous page - $result = $auth->login($username, $password, $autologin, $viewonline, $admin); - } - - // If admin authentication and login, we will log if it was a success or not... - // We also break the operation on the first non-success login - it could be argued that the user already knows - if ($admin) - { - if ($result['status'] == LOGIN_SUCCESS) - { - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ADMIN_AUTH_SUCCESS'); - } - else - { - // Only log the failed attempt if a real user tried to. - // anonymous/inactive users are never able to go to the ACP even if they have the relevant permissions - if ($user->data['is_registered']) - { - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ADMIN_AUTH_FAIL'); - } - } - } - - // The result parameter is always an array, holding the relevant information... - if ($result['status'] == LOGIN_SUCCESS) - { - $redirect = $request->variable('redirect', "{$phpbb_root_path}index.$phpEx"); - - /** - * This event allows an extension to modify the redirection when a user successfully logs in - * - * @event core.login_box_redirect - * @var string redirect Redirect string - * @var bool admin Is admin? - * @var array result Result from auth provider - * @since 3.1.0-RC5 - * @changed 3.1.9-RC1 Removed undefined return variable - * @changed 3.2.4-RC1 Added result - */ - $vars = array('redirect', 'admin', 'result'); - extract($phpbb_dispatcher->trigger_event('core.login_box_redirect', compact($vars))); - - // append/replace SID (may change during the session for AOL users) - $redirect = reapply_sid($redirect); - - // Special case... the user is effectively banned, but we allow founders to login - if (defined('IN_CHECK_BAN') && $result['user_row']['user_type'] != USER_FOUNDER) - { - return; - } - - redirect($redirect); - } - - // Something failed, determine what... - if ($result['status'] == LOGIN_BREAK) - { - trigger_error($result['error_msg']); - } - - // Special cases... determine - switch ($result['status']) - { - case LOGIN_ERROR_PASSWORD_CONVERT: - $err = sprintf( - $user->lang[$result['error_msg']], - ($config['email_enable']) ? '' : '', - ($config['email_enable']) ? '' : '', - '', - '' - ); - break; - - case LOGIN_ERROR_ATTEMPTS: - - $captcha = $phpbb_container->get('captcha.factory')->get_instance($config['captcha_plugin']); - $captcha->init(CONFIRM_LOGIN); - // $captcha->reset(); - - $template->assign_vars(array( - 'CAPTCHA_TEMPLATE' => $captcha->get_template(), - )); - // no break; - - // Username, password, etc... - default: - $err = $user->lang[$result['error_msg']]; - - // Assign admin contact to some error messages - if ($result['error_msg'] == 'LOGIN_ERROR_USERNAME' || $result['error_msg'] == 'LOGIN_ERROR_PASSWORD') - { - $err = sprintf($user->lang[$result['error_msg']], '', ''); - } - - break; - } - - /** - * This event allows an extension to process when a user fails a login attempt - * - * @event core.login_box_failed - * @var array result Login result data - * @var string username User name used to login - * @var string password Password used to login - * @var string err Error message - * @since 3.1.3-RC1 - */ - $vars = array('result', 'username', 'password', 'err'); - extract($phpbb_dispatcher->trigger_event('core.login_box_failed', compact($vars))); - } - - // Assign credential for username/password pair - $credential = ($admin) ? md5(unique_id()) : false; - - $s_hidden_fields = array( - 'sid' => $user->session_id, - ); - - if ($redirect) - { - $s_hidden_fields['redirect'] = $redirect; - } - - if ($admin) - { - $s_hidden_fields['credential'] = $credential; - } - - /* @var $provider_collection \phpbb\auth\provider_collection */ - $provider_collection = $phpbb_container->get('auth.provider_collection'); - $auth_provider = $provider_collection->get_provider(); - - $auth_provider_data = $auth_provider->get_login_data(); - if ($auth_provider_data) - { - if (isset($auth_provider_data['VARS'])) - { - $template->assign_vars($auth_provider_data['VARS']); - } - - if (isset($auth_provider_data['BLOCK_VAR_NAME'])) - { - foreach ($auth_provider_data['BLOCK_VARS'] as $block_vars) - { - $template->assign_block_vars($auth_provider_data['BLOCK_VAR_NAME'], $block_vars); - } - } - - $template->assign_vars(array( - 'PROVIDER_TEMPLATE_FILE' => $auth_provider_data['TEMPLATE_FILE'], - )); - } - - $s_hidden_fields = build_hidden_fields($s_hidden_fields); - - /** @var \phpbb\controller\helper $controller_helper */ - $controller_helper = $phpbb_container->get('controller.helper'); - - $login_box_template_data = array( - 'LOGIN_ERROR' => $err, - 'LOGIN_EXPLAIN' => $l_explain, - - 'U_SEND_PASSWORD' => ($config['email_enable']) ? $controller_helper->route('phpbb_ucp_forgot_password_controller') : '', - 'U_RESEND_ACTIVATION' => ($config['require_activation'] == USER_ACTIVATION_SELF && $config['email_enable']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=resend_act') : '', - 'U_TERMS_USE' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=terms'), - 'U_PRIVACY' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=privacy'), - 'UA_PRIVACY' => addslashes(append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=privacy')), - - 'S_DISPLAY_FULL_LOGIN' => ($s_display) ? true : false, - 'S_HIDDEN_FIELDS' => $s_hidden_fields, - - 'S_ADMIN_AUTH' => $admin, - 'USERNAME' => ($admin) ? $user->data['username'] : '', - - 'USERNAME_CREDENTIAL' => 'username', - 'PASSWORD_CREDENTIAL' => ($admin) ? 'password_' . $credential : 'password', - ); - - /** - * Event to add/modify login box template data - * - * @event core.login_box_modify_template_data - * @var int admin Flag whether user is admin - * @var string username User name - * @var int autologin Flag whether autologin is enabled - * @var string redirect Redirect URL - * @var array login_box_template_data Array with the login box template data - * @since 3.2.3-RC2 - */ - $vars = array( - 'admin', - 'username', - 'autologin', - 'redirect', - 'login_box_template_data', - ); - extract($phpbb_dispatcher->trigger_event('core.login_box_modify_template_data', compact($vars))); - - $template->assign_vars($login_box_template_data); - - page_header($user->lang['LOGIN']); - - $template->set_filenames(array( - 'body' => 'login_body.html') - ); - make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx")); - - page_footer(); -} - -/** -* Generate forum login box -*/ -function login_forum_box($forum_data) -{ - global $db, $phpbb_container, $request, $template, $user, $phpbb_dispatcher, $phpbb_root_path, $phpEx; - - $password = $request->variable('password', '', true); - - $sql = 'SELECT forum_id - FROM ' . FORUMS_ACCESS_TABLE . ' - WHERE forum_id = ' . $forum_data['forum_id'] . ' - AND user_id = ' . $user->data['user_id'] . " - AND session_id = '" . $db->sql_escape($user->session_id) . "'"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - return true; - } - - if ($password) - { - // Remove expired authorised sessions - $sql = 'SELECT f.session_id - FROM ' . FORUMS_ACCESS_TABLE . ' f - LEFT JOIN ' . SESSIONS_TABLE . ' s ON (f.session_id = s.session_id) - WHERE s.session_id IS NULL'; - $result = $db->sql_query($sql); - - if ($row = $db->sql_fetchrow($result)) - { - $sql_in = array(); - do - { - $sql_in[] = (string) $row['session_id']; - } - while ($row = $db->sql_fetchrow($result)); - - // Remove expired sessions - $sql = 'DELETE FROM ' . FORUMS_ACCESS_TABLE . ' - WHERE ' . $db->sql_in_set('session_id', $sql_in); - $db->sql_query($sql); - } - $db->sql_freeresult($result); - - /* @var $passwords_manager \phpbb\passwords\manager */ - $passwords_manager = $phpbb_container->get('passwords.manager'); - - if ($passwords_manager->check($password, $forum_data['forum_password'])) - { - $sql_ary = array( - 'forum_id' => (int) $forum_data['forum_id'], - 'user_id' => (int) $user->data['user_id'], - 'session_id' => (string) $user->session_id, - ); - - $db->sql_query('INSERT INTO ' . FORUMS_ACCESS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); - - return true; - } - - $template->assign_var('LOGIN_ERROR', $user->lang['WRONG_PASSWORD']); - } - - /** - * Performing additional actions, load additional data on forum login - * - * @event core.login_forum_box - * @var array forum_data Array with forum data - * @var string password Password entered - * @since 3.1.0-RC3 - */ - $vars = array('forum_data', 'password'); - extract($phpbb_dispatcher->trigger_event('core.login_forum_box', compact($vars))); - - page_header($user->lang['LOGIN']); - - $template->assign_vars(array( - 'FORUM_NAME' => isset($forum_data['forum_name']) ? $forum_data['forum_name'] : '', - 'S_LOGIN_ACTION' => build_url(array('f')), - 'S_HIDDEN_FIELDS' => build_hidden_fields(array('f' => $forum_data['forum_id']))) - ); - - $template->set_filenames(array( - 'body' => 'login_forum.html') - ); - - make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"), $forum_data['forum_id']); - - page_footer(); -} - -// Little helpers - -/** -* Little helper for the build_hidden_fields function -*/ -function _build_hidden_fields($key, $value, $specialchar, $stripslashes) -{ - $hidden_fields = ''; - - if (!is_array($value)) - { - $value = ($stripslashes) ? stripslashes($value) : $value; - $value = ($specialchar) ? htmlspecialchars($value, ENT_COMPAT, 'UTF-8') : $value; - - $hidden_fields .= '' . "\n"; - } - else - { - foreach ($value as $_key => $_value) - { - $_key = ($stripslashes) ? stripslashes($_key) : $_key; - $_key = ($specialchar) ? htmlspecialchars($_key, ENT_COMPAT, 'UTF-8') : $_key; - - $hidden_fields .= _build_hidden_fields($key . '[' . $_key . ']', $_value, $specialchar, $stripslashes); - } - } - - return $hidden_fields; -} - -/** -* Build simple hidden fields from array -* -* @param array $field_ary an array of values to build the hidden field from -* @param bool $specialchar if true, keys and values get specialchared -* @param bool $stripslashes if true, keys and values get stripslashed -* -* @return string the hidden fields -*/ -function build_hidden_fields($field_ary, $specialchar = false, $stripslashes = false) -{ - $s_hidden_fields = ''; - - foreach ($field_ary as $name => $vars) - { - $name = ($stripslashes) ? stripslashes($name) : $name; - $name = ($specialchar) ? htmlspecialchars($name, ENT_COMPAT, 'UTF-8') : $name; - - $s_hidden_fields .= _build_hidden_fields($name, $vars, $specialchar, $stripslashes); - } - - return $s_hidden_fields; -} - -/** -* Parse cfg file -*/ -function parse_cfg_file($filename, $lines = false) -{ - $parsed_items = array(); - - if ($lines === false) - { - $lines = file($filename); - } - - foreach ($lines as $line) - { - $line = trim($line); - - if (!$line || $line[0] == '#' || ($delim_pos = strpos($line, '=')) === false) - { - continue; - } - - // Determine first occurrence, since in values the equal sign is allowed - $key = htmlspecialchars(strtolower(trim(substr($line, 0, $delim_pos)))); - $value = trim(substr($line, $delim_pos + 1)); - - if (in_array($value, array('off', 'false', '0'))) - { - $value = false; - } - else if (in_array($value, array('on', 'true', '1'))) - { - $value = true; - } - else if (!trim($value)) - { - $value = ''; - } - else if (($value[0] == "'" && $value[strlen($value) - 1] == "'") || ($value[0] == '"' && $value[strlen($value) - 1] == '"')) - { - $value = htmlspecialchars(substr($value, 1, strlen($value)-2)); - } - else - { - $value = htmlspecialchars($value); - } - - $parsed_items[$key] = $value; - } - - if (isset($parsed_items['parent']) && isset($parsed_items['name']) && $parsed_items['parent'] == $parsed_items['name']) - { - unset($parsed_items['parent']); - } - - return $parsed_items; -} - -/** -* Return a nicely formatted backtrace. -* -* Turns the array returned by debug_backtrace() into HTML markup. -* Also filters out absolute paths to phpBB root. -* -* @return string HTML markup -*/ -function get_backtrace() -{ - $output = '
'; - $backtrace = debug_backtrace(); - - // We skip the first one, because it only shows this file/function - unset($backtrace[0]); - - foreach ($backtrace as $trace) - { - // Strip the current directory from path - $trace['file'] = (empty($trace['file'])) ? '(not given by php)' : htmlspecialchars(phpbb_filter_root_path($trace['file'])); - $trace['line'] = (empty($trace['line'])) ? '(not given by php)' : $trace['line']; - - // Only show function arguments for include etc. - // Other parameters may contain sensible information - $argument = ''; - if (!empty($trace['args'][0]) && in_array($trace['function'], array('include', 'require', 'include_once', 'require_once'))) - { - $argument = htmlspecialchars(phpbb_filter_root_path($trace['args'][0])); - } - - $trace['class'] = (!isset($trace['class'])) ? '' : $trace['class']; - $trace['type'] = (!isset($trace['type'])) ? '' : $trace['type']; - - $output .= '
'; - $output .= 'FILE: ' . $trace['file'] . '
'; - $output .= 'LINE: ' . ((!empty($trace['line'])) ? $trace['line'] : '') . '
'; - - $output .= 'CALL: ' . htmlspecialchars($trace['class'] . $trace['type'] . $trace['function']); - $output .= '(' . (($argument !== '') ? "'$argument'" : '') . ')
'; - } - $output .= '
'; - return $output; -} - -/** -* This function returns a regular expression pattern for commonly used expressions -* Use with / as delimiter for email mode and # for url modes -* mode can be: email|bbcode_htm|url|url_inline|www_url|www_url_inline|relative_url|relative_url_inline|ipv4|ipv6 -*/ -function get_preg_expression($mode) -{ - switch ($mode) - { - case 'email': - // Regex written by James Watts and Francisco Jose Martin Moreno - // http://fightingforalostcause.net/misc/2006/compare-email-regex.php - return '((?:[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*(?:[\w\!\#$\%\'\*\+\-\/\=\?\^\`{\|\}\~]|&)+)@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,63})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)'; - break; - - case 'bbcode_htm': - return array( - '#.*?#', - '#.*?#', - '#\2#', - '#.*?#', - '#(?:0|[1-9](?:(?:0|[1-9])+)*))[.](?(?:0|[1-9](?:(?:0|[1-9])+)*))[.](?(?:0|[1-9](?:(?:0|[1-9])+)*))(?:-(?(?:(?:(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?|(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?)|(?:0|[1-9](?:(?:0|[1-9])+)*))(?:[.](?:(?:(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?|(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?)|(?:0|[1-9](?:(?:0|[1-9])+)*)))*))?(?:[+](?(?:(?:(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?|(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?)|(?:(?:0|[1-9])+))(?:[.](?:(?:(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?|(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?)|(?:(?:0|[1-9])+)))*))?)$/'; - break; - } - - return ''; -} - -/** -* Generate regexp for naughty words censoring -* Depends on whether installed PHP version supports unicode properties -* -* @param string $word word template to be replaced -* -* @return string $preg_expr regex to use with word censor -*/ -function get_censor_preg_expression($word) -{ - // Unescape the asterisk to simplify further conversions - $word = str_replace('\*', '*', preg_quote($word, '#')); - - // Replace asterisk(s) inside the pattern, at the start and at the end of it with regexes - $word = preg_replace(array('#(?<=[\p{Nd}\p{L}_])\*+(?=[\p{Nd}\p{L}_])#iu', '#^\*+#', '#\*+$#'), array('([\x20]*?|[\p{Nd}\p{L}_-]*?)', '[\p{Nd}\p{L}_-]*?', '[\p{Nd}\p{L}_-]*?'), $word); - - // Generate the final substitution - $preg_expr = '#(?getParameter('debug.show_errors') ? E_ALL : error_reporting())) == 0) - { - return; - } - - if (strpos($errfile, 'cache') === false && strpos($errfile, 'template.') === false) - { - $errfile = phpbb_filter_root_path($errfile); - $msg_text = phpbb_filter_root_path($msg_text); - $error_name = ($errno === E_WARNING) ? 'PHP Warning' : 'PHP Notice'; - echo '[phpBB Debug] ' . $error_name . ': in file ' . $errfile . ' on line ' . $errline . ': ' . $msg_text . '
' . "\n"; - - // we are writing an image - the user won't see the debug, so let's place it in the log - if (defined('IMAGE_OUTPUT') || defined('IN_CRON')) - { - $phpbb_log->add('critical', $user->data['user_id'], $user->ip, 'LOG_IMAGE_GENERATION_ERROR', false, array($errfile, $errline, $msg_text)); - } - // echo '

BACKTRACE
' . get_backtrace() . '
' . "\n"; - } - - return; - - break; - - case E_USER_ERROR: - - if (!empty($user) && $user->is_setup()) - { - $msg_text = (!empty($user->lang[$msg_text])) ? $user->lang[$msg_text] : $msg_text; - $msg_title = (!isset($msg_title)) ? $user->lang['GENERAL_ERROR'] : ((!empty($user->lang[$msg_title])) ? $user->lang[$msg_title] : $msg_title); - - $l_return_index = sprintf($user->lang['RETURN_INDEX'], '', ''); - $l_notify = ''; - - if (!empty($config['board_contact'])) - { - $l_notify = '

' . sprintf($user->lang['NOTIFY_ADMIN_EMAIL'], $config['board_contact']) . '

'; - } - } - else - { - $msg_title = 'General Error'; - $l_return_index = 'Return to index page'; - $l_notify = ''; - - if (!empty($config['board_contact'])) - { - $l_notify = '

Please notify the board administrator or webmaster: ' . $config['board_contact'] . '

'; - } - } - - $log_text = $msg_text; - $backtrace = get_backtrace(); - if ($backtrace) - { - $log_text .= '

BACKTRACE
' . $backtrace; - } - - if (defined('IN_INSTALL') || ($phpbb_container != null && $phpbb_container->getParameter('debug.show_errors')) || isset($auth) && $auth->acl_get('a_')) - { - $msg_text = $log_text; - - // If this is defined there already was some output - // So let's not break it - if (defined('IN_DB_UPDATE')) - { - echo '
' . $msg_text . '
'; - - $db->sql_return_on_error(true); - phpbb_end_update($cache, $config); - } - } - - if ((defined('IN_CRON') || defined('IMAGE_OUTPUT')) && isset($db)) - { - // let's avoid loops - $db->sql_return_on_error(true); - $phpbb_log->add('critical', $user->data['user_id'], $user->ip, 'LOG_GENERAL_ERROR', false, array($msg_title, $log_text)); - $db->sql_return_on_error(false); - } - - // Do not send 200 OK, but service unavailable on errors - send_status_line(503, 'Service Unavailable'); - - garbage_collection(); - - // Try to not call the adm page data... - - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo '' . $msg_title . ''; - echo ''; - echo ''; - echo ''; - echo '
'; - echo ' '; - echo '
'; - echo '
'; - echo '
'; - echo '

' . $msg_title . '

'; - - echo '
' . $msg_text . '
'; - - echo $l_notify; - - echo '
'; - echo '
'; - echo '
'; - echo ' '; - echo '
'; - echo ''; - echo ''; - - exit_handler(); - - // On a fatal error (and E_USER_ERROR *is* fatal) we never want other scripts to continue and force an exit here. - exit; - break; - - case E_USER_WARNING: - case E_USER_NOTICE: - - define('IN_ERROR_HANDLER', true); - - if (empty($user->data)) - { - $user->session_begin(); - } - - // We re-init the auth array to get correct results on login/logout - $auth->acl($user->data); - - if (!$user->is_setup()) - { - $user->setup(); - } - - if ($msg_text == 'ERROR_NO_ATTACHMENT' || $msg_text == 'NO_FORUM' || $msg_text == 'NO_TOPIC' || $msg_text == 'NO_USER') - { - send_status_line(404, 'Not Found'); - } - - $msg_text = (!empty($user->lang[$msg_text])) ? $user->lang[$msg_text] : $msg_text; - $msg_title = (!isset($msg_title)) ? $user->lang['INFORMATION'] : ((!empty($user->lang[$msg_title])) ? $user->lang[$msg_title] : $msg_title); - - if (!defined('HEADER_INC')) - { - if (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin']) - { - adm_page_header($msg_title); - } - else - { - page_header($msg_title); - } - } - - $template->set_filenames(array( - 'body' => 'message_body.html') - ); - - $template->assign_vars(array( - 'MESSAGE_TITLE' => $msg_title, - 'MESSAGE_TEXT' => $msg_text, - 'S_USER_WARNING' => ($errno == E_USER_WARNING) ? true : false, - 'S_USER_NOTICE' => ($errno == E_USER_NOTICE) ? true : false) - ); - - if ($request->is_ajax()) - { - global $refresh_data; - - $json_response = new \phpbb\json_response; - $json_response->send(array( - 'MESSAGE_TITLE' => $msg_title, - 'MESSAGE_TEXT' => $msg_text, - 'S_USER_WARNING' => ($errno == E_USER_WARNING) ? true : false, - 'S_USER_NOTICE' => ($errno == E_USER_NOTICE) ? true : false, - 'REFRESH_DATA' => (!empty($refresh_data)) ? $refresh_data : null - )); - } - - // We do not want the cron script to be called on error messages - define('IN_CRON', true); - - if (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin']) - { - adm_page_footer(); - } - else - { - page_footer(); - } - - exit_handler(); - break; - - // PHP4 compatibility - case E_DEPRECATED: - return true; - break; - } - - // If we notice an error not handled here we pass this back to PHP by returning false - // This may not work for all php versions - return false; -} - -/** -* Removes absolute path to phpBB root directory from error messages -* and converts backslashes to forward slashes. -* -* @param string $errfile Absolute file path -* (e.g. /var/www/phpbb3/phpBB/includes/functions.php) -* Please note that if $errfile is outside of the phpBB root, -* the root path will not be found and can not be filtered. -* @return string Relative file path -* (e.g. /includes/functions.php) -*/ -function phpbb_filter_root_path($errfile) -{ - global $phpbb_filesystem; - - static $root_path; - - if (empty($root_path)) - { - if ($phpbb_filesystem) - { - $root_path = $phpbb_filesystem->realpath(dirname(__FILE__) . '/../'); - } - else - { - $filesystem = new \phpbb\filesystem\filesystem(); - $root_path = $filesystem->realpath(dirname(__FILE__) . '/../'); - } - } - - return str_replace(array($root_path, '\\'), array('[ROOT]', '/'), $errfile); -} - -/** -* Queries the session table to get information about online guests -* @param int $item_id Limits the search to the item with this id -* @param string $item The name of the item which is stored in the session table as session_{$item}_id -* @return int The number of active distinct guest sessions -*/ -function obtain_guest_count($item_id = 0, $item = 'forum') -{ - global $db, $config; - - if ($item_id) - { - $reading_sql = ' AND s.session_' . $item . '_id = ' . (int) $item_id; - } - else - { - $reading_sql = ''; - } - $time = (time() - (intval($config['load_online_time']) * 60)); - - // Get number of online guests - - if ($db->get_sql_layer() === 'sqlite3') - { - $sql = 'SELECT COUNT(session_ip) as num_guests - FROM ( - SELECT DISTINCT s.session_ip - FROM ' . SESSIONS_TABLE . ' s - WHERE s.session_user_id = ' . ANONYMOUS . ' - AND s.session_time >= ' . ($time - ((int) ($time % 60))) . - $reading_sql . - ')'; - } - else - { - $sql = 'SELECT COUNT(DISTINCT s.session_ip) as num_guests - FROM ' . SESSIONS_TABLE . ' s - WHERE s.session_user_id = ' . ANONYMOUS . ' - AND s.session_time >= ' . ($time - ((int) ($time % 60))) . - $reading_sql; - } - $result = $db->sql_query($sql); - $guests_online = (int) $db->sql_fetchfield('num_guests'); - $db->sql_freeresult($result); - - return $guests_online; -} - -/** -* Queries the session table to get information about online users -* @param int $item_id Limits the search to the item with this id -* @param string $item The name of the item which is stored in the session table as session_{$item}_id -* @return array An array containing the ids of online, hidden and visible users, as well as statistical info -*/ -function obtain_users_online($item_id = 0, $item = 'forum') -{ - global $db, $config; - - $reading_sql = ''; - if ($item_id !== 0) - { - $reading_sql = ' AND s.session_' . $item . '_id = ' . (int) $item_id; - } - - $online_users = array( - 'online_users' => array(), - 'hidden_users' => array(), - 'total_online' => 0, - 'visible_online' => 0, - 'hidden_online' => 0, - 'guests_online' => 0, - ); - - if ($config['load_online_guests']) - { - $online_users['guests_online'] = obtain_guest_count($item_id, $item); - } - - // a little discrete magic to cache this for 30 seconds - $time = (time() - (intval($config['load_online_time']) * 60)); - - $sql = 'SELECT s.session_user_id, s.session_ip, s.session_viewonline - FROM ' . SESSIONS_TABLE . ' s - WHERE s.session_time >= ' . ($time - ((int) ($time % 30))) . - $reading_sql . - ' AND s.session_user_id <> ' . ANONYMOUS; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - // Skip multiple sessions for one user - if (!isset($online_users['online_users'][$row['session_user_id']])) - { - $online_users['online_users'][$row['session_user_id']] = (int) $row['session_user_id']; - if ($row['session_viewonline']) - { - $online_users['visible_online']++; - } - else - { - $online_users['hidden_users'][$row['session_user_id']] = (int) $row['session_user_id']; - $online_users['hidden_online']++; - } - } - } - $online_users['total_online'] = $online_users['guests_online'] + $online_users['visible_online'] + $online_users['hidden_online']; - $db->sql_freeresult($result); - - return $online_users; -} - -/** -* Uses the result of obtain_users_online to generate a localized, readable representation. -* @param mixed $online_users result of obtain_users_online - array with user_id lists for total, hidden and visible users, and statistics -* @param int $item_id Indicate that the data is limited to one item and not global -* @param string $item The name of the item which is stored in the session table as session_{$item}_id -* @return array An array containing the string for output to the template -*/ -function obtain_users_online_string($online_users, $item_id = 0, $item = 'forum') -{ - global $config, $db, $user, $auth, $phpbb_dispatcher; - - $user_online_link = $rowset = array(); - // Need caps version of $item for language-strings - $item_caps = strtoupper($item); - - if (count($online_users['online_users'])) - { - $sql_ary = array( - 'SELECT' => 'u.username, u.username_clean, u.user_id, u.user_type, u.user_allow_viewonline, u.user_colour', - 'FROM' => array( - USERS_TABLE => 'u', - ), - 'WHERE' => $db->sql_in_set('u.user_id', $online_users['online_users']), - 'ORDER_BY' => 'u.username_clean ASC', - ); - - /** - * Modify SQL query to obtain online users data - * - * @event core.obtain_users_online_string_sql - * @var array online_users Array with online users data - * from obtain_users_online() - * @var int item_id Restrict online users to item id - * @var string item Restrict online users to a certain - * session item, e.g. forum for - * session_forum_id - * @var array sql_ary SQL query array to obtain users online data - * @since 3.1.4-RC1 - * @changed 3.1.7-RC1 Change sql query into array and adjust var accordingly. Allows extension authors the ability to adjust the sql_ary. - */ - $vars = array('online_users', 'item_id', 'item', 'sql_ary'); - extract($phpbb_dispatcher->trigger_event('core.obtain_users_online_string_sql', compact($vars))); - - $result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary)); - $rowset = $db->sql_fetchrowset($result); - $db->sql_freeresult($result); - - foreach ($rowset as $row) - { - // User is logged in and therefore not a guest - if ($row['user_id'] != ANONYMOUS) - { - if (isset($online_users['hidden_users'][$row['user_id']])) - { - $row['username'] = '' . $row['username'] . ''; - } - - if (!isset($online_users['hidden_users'][$row['user_id']]) || $auth->acl_get('u_viewonline') || $row['user_id'] === $user->data['user_id']) - { - $user_online_link[$row['user_id']] = get_username_string(($row['user_type'] <> USER_IGNORE) ? 'full' : 'no_profile', $row['user_id'], $row['username'], $row['user_colour']); - } - } - } - } - - /** - * Modify online userlist data - * - * @event core.obtain_users_online_string_before_modify - * @var array online_users Array with online users data - * from obtain_users_online() - * @var int item_id Restrict online users to item id - * @var string item Restrict online users to a certain - * session item, e.g. forum for - * session_forum_id - * @var array rowset Array with online users data - * @var array user_online_link Array with online users items (usernames) - * @since 3.1.10-RC1 - */ - $vars = array( - 'online_users', - 'item_id', - 'item', - 'rowset', - 'user_online_link', - ); - extract($phpbb_dispatcher->trigger_event('core.obtain_users_online_string_before_modify', compact($vars))); - - $online_userlist = implode(', ', $user_online_link); - - if (!$online_userlist) - { - $online_userlist = $user->lang['NO_ONLINE_USERS']; - } - - if ($item_id === 0) - { - $online_userlist = $user->lang['REGISTERED_USERS'] . ' ' . $online_userlist; - } - else if ($config['load_online_guests']) - { - $online_userlist = $user->lang('BROWSING_' . $item_caps . '_GUESTS', $online_users['guests_online'], $online_userlist); - } - else - { - $online_userlist = sprintf($user->lang['BROWSING_' . $item_caps], $online_userlist); - } - // Build online listing - $visible_online = $user->lang('REG_USERS_TOTAL', (int) $online_users['visible_online']); - $hidden_online = $user->lang('HIDDEN_USERS_TOTAL', (int) $online_users['hidden_online']); - - if ($config['load_online_guests']) - { - $guests_online = $user->lang('GUEST_USERS_TOTAL', (int) $online_users['guests_online']); - $l_online_users = $user->lang('ONLINE_USERS_TOTAL_GUESTS', (int) $online_users['total_online'], $visible_online, $hidden_online, $guests_online); - } - else - { - $l_online_users = $user->lang('ONLINE_USERS_TOTAL', (int) $online_users['total_online'], $visible_online, $hidden_online); - } - - /** - * Modify online userlist data - * - * @event core.obtain_users_online_string_modify - * @var array online_users Array with online users data - * from obtain_users_online() - * @var int item_id Restrict online users to item id - * @var string item Restrict online users to a certain - * session item, e.g. forum for - * session_forum_id - * @var array rowset Array with online users data - * @var array user_online_link Array with online users items (usernames) - * @var string online_userlist String containing users online list - * @var string l_online_users String with total online users count info - * @since 3.1.4-RC1 - */ - $vars = array( - 'online_users', - 'item_id', - 'item', - 'rowset', - 'user_online_link', - 'online_userlist', - 'l_online_users', - ); - extract($phpbb_dispatcher->trigger_event('core.obtain_users_online_string_modify', compact($vars))); - - return array( - 'online_userlist' => $online_userlist, - 'l_online_users' => $l_online_users, - ); -} - -/** -* Get option bitfield from custom data -* -* @param int $bit The bit/value to get -* @param int $data Current bitfield to check -* @return bool Returns true if value of constant is set in bitfield, else false -*/ -function phpbb_optionget($bit, $data) -{ - return ($data & 1 << (int) $bit) ? true : false; -} - -/** -* Set option bitfield -* -* @param int $bit The bit/value to set/unset -* @param bool $set True if option should be set, false if option should be unset. -* @param int $data Current bitfield to change -* -* @return int The new bitfield -*/ -function phpbb_optionset($bit, $set, $data) -{ - if ($set && !($data & 1 << $bit)) - { - $data += 1 << $bit; - } - else if (!$set && ($data & 1 << $bit)) - { - $data -= 1 << $bit; - } - - return $data; -} - -/** -* Login using http authenticate. -* -* @param array $param Parameter array, see $param_defaults array. -* -* @return null -*/ -function phpbb_http_login($param) -{ - global $auth, $user, $request; - global $config; - - $param_defaults = array( - 'auth_message' => '', - - 'autologin' => false, - 'viewonline' => true, - 'admin' => false, - ); - - // Overwrite default values with passed values - $param = array_merge($param_defaults, $param); - - // User is already logged in - // We will not overwrite his session - if (!empty($user->data['is_registered'])) - { - return; - } - - // $_SERVER keys to check - $username_keys = array( - 'PHP_AUTH_USER', - 'Authorization', - 'REMOTE_USER', 'REDIRECT_REMOTE_USER', - 'HTTP_AUTHORIZATION', 'REDIRECT_HTTP_AUTHORIZATION', - 'REMOTE_AUTHORIZATION', 'REDIRECT_REMOTE_AUTHORIZATION', - 'AUTH_USER', - ); - - $password_keys = array( - 'PHP_AUTH_PW', - 'REMOTE_PASSWORD', - 'AUTH_PASSWORD', - ); - - $username = null; - foreach ($username_keys as $k) - { - if ($request->is_set($k, \phpbb\request\request_interface::SERVER)) - { - $username = htmlspecialchars_decode($request->server($k)); - break; - } - } - - $password = null; - foreach ($password_keys as $k) - { - if ($request->is_set($k, \phpbb\request\request_interface::SERVER)) - { - $password = htmlspecialchars_decode($request->server($k)); - break; - } - } - - // Decode encoded information (IIS, CGI, FastCGI etc.) - if (!is_null($username) && is_null($password) && strpos($username, 'Basic ') === 0) - { - list($username, $password) = explode(':', base64_decode(substr($username, 6)), 2); - } - - if (!is_null($username) && !is_null($password)) - { - set_var($username, $username, 'string', true); - set_var($password, $password, 'string', true); - - $auth_result = $auth->login($username, $password, $param['autologin'], $param['viewonline'], $param['admin']); - - if ($auth_result['status'] == LOGIN_SUCCESS) - { - return; - } - else if ($auth_result['status'] == LOGIN_ERROR_ATTEMPTS) - { - send_status_line(401, 'Unauthorized'); - - trigger_error('NOT_AUTHORISED'); - } - } - - // Prepend sitename to auth_message - $param['auth_message'] = ($param['auth_message'] === '') ? $config['sitename'] : $config['sitename'] . ' - ' . $param['auth_message']; - - // We should probably filter out non-ASCII characters - RFC2616 - $param['auth_message'] = preg_replace('/[\x80-\xFF]/', '?', $param['auth_message']); - - header('WWW-Authenticate: Basic realm="' . $param['auth_message'] . '"'); - send_status_line(401, 'Unauthorized'); - - trigger_error('NOT_AUTHORISED'); -} - -/** -* Escapes and quotes a string for use as an HTML/XML attribute value. -* -* This is a port of Python xml.sax.saxutils quoteattr. -* -* The function will attempt to choose a quote character in such a way as to -* avoid escaping quotes in the string. If this is not possible the string will -* be wrapped in double quotes and double quotes will be escaped. -* -* @param string $data The string to be escaped -* @param array $entities Associative array of additional entities to be escaped -* @return string Escaped and quoted string -*/ -function phpbb_quoteattr($data, $entities = null) -{ - $data = str_replace('&', '&', $data); - $data = str_replace('>', '>', $data); - $data = str_replace('<', '<', $data); - - $data = str_replace("\n", ' ', $data); - $data = str_replace("\r", ' ', $data); - $data = str_replace("\t", ' ', $data); - - if (!empty($entities)) - { - $data = str_replace(array_keys($entities), array_values($entities), $data); - } - - if (strpos($data, '"') !== false) - { - if (strpos($data, "'") !== false) - { - $data = '"' . str_replace('"', '"', $data) . '"'; - } - else - { - $data = "'" . $data . "'"; - } - } - else - { - $data = '"' . $data . '"'; - } - - return $data; -} - -/** -* Converts query string (GET) parameters in request into hidden fields. -* -* Useful for forwarding GET parameters when submitting forms with GET method. -* -* It is possible to omit some of the GET parameters, which is useful if -* they are specified in the form being submitted. -* -* sid is always omitted. -* -* @param \phpbb\request\request $request Request object -* @param array $exclude A list of variable names that should not be forwarded -* @return string HTML with hidden fields -*/ -function phpbb_build_hidden_fields_for_query_params($request, $exclude = null) -{ - $names = $request->variable_names(\phpbb\request\request_interface::GET); - $hidden = ''; - foreach ($names as $name) - { - // Sessions are dealt with elsewhere, omit sid always - if ($name == 'sid') - { - continue; - } - - // Omit any additional parameters requested - if (!empty($exclude) && in_array($name, $exclude)) - { - continue; - } - - $escaped_name = phpbb_quoteattr($name); - - // Note: we might retrieve the variable from POST or cookies - // here. To avoid exposing cookies, skip variables that are - // overwritten somewhere other than GET entirely. - $value = $request->variable($name, '', true); - $get_value = $request->variable($name, '', true, \phpbb\request\request_interface::GET); - if ($value === $get_value) - { - $escaped_value = phpbb_quoteattr($value); - $hidden .= ""; - } - } - return $hidden; -} - -/** -* Get user avatar -* -* @param array $user_row Row from the users table -* @param string $alt Optional language string for alt tag within image, can be a language key or text -* @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP -* @param bool $lazy If true, will be lazy loaded (requires JS) -* -* @return string Avatar html -*/ -function phpbb_get_user_avatar($user_row, $alt = 'USER_AVATAR', $ignore_config = false, $lazy = false) -{ - $row = \phpbb\avatar\manager::clean_row($user_row, 'user'); - return phpbb_get_avatar($row, $alt, $ignore_config, $lazy); -} - -/** -* Get group avatar -* -* @param array $group_row Row from the groups table -* @param string $alt Optional language string for alt tag within image, can be a language key or text -* @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP -* @param bool $lazy If true, will be lazy loaded (requires JS) -* -* @return string Avatar html -*/ -function phpbb_get_group_avatar($group_row, $alt = 'GROUP_AVATAR', $ignore_config = false, $lazy = false) -{ - $row = \phpbb\avatar\manager::clean_row($group_row, 'group'); - return phpbb_get_avatar($row, $alt, $ignore_config, $lazy); -} - -/** -* Get avatar -* -* @param array $row Row cleaned by \phpbb\avatar\manager::clean_row -* @param string $alt Optional language string for alt tag within image, can be a language key or text -* @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP -* @param bool $lazy If true, will be lazy loaded (requires JS) -* -* @return string Avatar html -*/ -function phpbb_get_avatar($row, $alt, $ignore_config = false, $lazy = false) -{ - global $user, $config; - global $phpbb_container, $phpbb_dispatcher; - - if (!$config['allow_avatar'] && !$ignore_config) - { - return ''; - } - - $avatar_data = array( - 'src' => $row['avatar'], - 'width' => $row['avatar_width'], - 'height' => $row['avatar_height'], - ); - - /* @var $phpbb_avatar_manager \phpbb\avatar\manager */ - $phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); - $driver = $phpbb_avatar_manager->get_driver($row['avatar_type'], !$ignore_config); - $html = ''; - - if ($driver) - { - $html = $driver->get_custom_html($user, $row, $alt); - $avatar_data = $driver->get_data($row); - } - else - { - $avatar_data['src'] = ''; - } - - if (empty($html) && !empty($avatar_data['src'])) - { - if ($lazy) - { - // Determine board url - we may need it later - $board_url = generate_board_url() . '/'; - // This path is sent with the base template paths in the assign_vars() - // call below. We need to correct it in case we are accessing from a - // controller because the web paths will be incorrect otherwise. - $phpbb_path_helper = $phpbb_container->get('path_helper'); - $corrected_path = $phpbb_path_helper->get_web_root_path(); - - $web_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? $board_url : $corrected_path; - - $theme = "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme'; - - $src = 'src="' . $theme . '/images/no_avatar.gif" data-src="' . $avatar_data['src'] . '"'; - } - else - { - $src = 'src="' . $avatar_data['src'] . '"'; - } - - $html = ''; - } - - /** - * Event to modify HTML tag of avatar - * - * @event core.get_avatar_after - * @var array row Row cleaned by \phpbb\avatar\manager::clean_row - * @var string alt Optional language string for alt tag within image, can be a language key or text - * @var bool ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP - * @var array avatar_data The HTML attributes for avatar tag - * @var string html The HTML tag of generated avatar - * @since 3.1.6-RC1 - */ - $vars = array('row', 'alt', 'ignore_config', 'avatar_data', 'html'); - extract($phpbb_dispatcher->trigger_event('core.get_avatar_after', compact($vars))); - - return $html; -} - -/** -* Generate page header -*/ -function page_header($page_title = '', $display_online_list = false, $item_id = 0, $item = 'forum', $send_headers = true) -{ - global $db, $config, $template, $SID, $_SID, $_EXTRA_URL, $user, $auth, $phpEx, $phpbb_root_path; - global $phpbb_dispatcher, $request, $phpbb_container, $phpbb_admin_path; - - if (defined('HEADER_INC')) - { - return; - } - - define('HEADER_INC', true); - - // A listener can set this variable to `true` when it overrides this function - $page_header_override = false; - - /** - * Execute code and/or overwrite page_header() - * - * @event core.page_header - * @var string page_title Page title - * @var bool display_online_list Do we display online users list - * @var string item Restrict online users to a certain - * session item, e.g. forum for - * session_forum_id - * @var int item_id Restrict online users to item id - * @var bool page_header_override Shall we return instead of running - * the rest of page_header() - * @since 3.1.0-a1 - */ - $vars = array('page_title', 'display_online_list', 'item_id', 'item', 'page_header_override'); - extract($phpbb_dispatcher->trigger_event('core.page_header', compact($vars))); - - if ($page_header_override) - { - return; - } - - // gzip_compression - if ($config['gzip_compress']) - { - // to avoid partially compressed output resulting in blank pages in - // the browser or error messages, compression is disabled in a few cases: - // - // 1) if headers have already been sent, this indicates plaintext output - // has been started so further content must not be compressed - // 2) the length of the current output buffer is non-zero. This means - // there is already some uncompressed content in this output buffer - // so further output must not be compressed - // 3) if more than one level of output buffering is used because we - // cannot test all output buffer level content lengths. One level - // could be caused by php.ini output_buffering. Anything - // beyond that is manual, so the code wrapping phpBB in output buffering - // can easily compress the output itself. - // - if (@extension_loaded('zlib') && !headers_sent() && ob_get_level() <= 1 && ob_get_length() == 0) - { - ob_start('ob_gzhandler'); - } - } - - $user->update_session_infos(); - - // Generate logged in/logged out status - if ($user->data['user_id'] != ANONYMOUS) - { - $u_login_logout = append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=logout', true, $user->session_id); - $l_login_logout = $user->lang['LOGOUT']; - } - else - { - $redirect = $request->variable('redirect', rawurlencode($user->page['page'])); - $u_login_logout = append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login&redirect=' . $redirect); - $l_login_logout = $user->lang['LOGIN']; - } - - // Last visit date/time - $s_last_visit = ($user->data['user_id'] != ANONYMOUS) ? $user->format_date($user->data['session_last_visit']) : ''; - - // Get users online list ... if required - $l_online_users = $online_userlist = $l_online_record = $l_online_time = ''; - - if ($config['load_online'] && $config['load_online_time'] && $display_online_list) - { - /** - * Load online data: - * For obtaining another session column use $item and $item_id in the function-parameter, whereby the column is session_{$item}_id. - */ - $item_id = max($item_id, 0); - - $online_users = obtain_users_online($item_id, $item); - $user_online_strings = obtain_users_online_string($online_users, $item_id, $item); - - $l_online_users = $user_online_strings['l_online_users']; - $online_userlist = $user_online_strings['online_userlist']; - $total_online_users = $online_users['total_online']; - - if ($total_online_users > $config['record_online_users']) - { - $config->set('record_online_users', $total_online_users, false); - $config->set('record_online_date', time(), false); - } - - $l_online_record = $user->lang('RECORD_ONLINE_USERS', (int) $config['record_online_users'], $user->format_date($config['record_online_date'], false, true)); - - $l_online_time = $user->lang('VIEW_ONLINE_TIMES', (int) $config['load_online_time']); - } - - $s_privmsg_new = false; - - // Check for new private messages if user is logged in - if (!empty($user->data['is_registered'])) - { - if ($user->data['user_new_privmsg']) - { - if (!$user->data['user_last_privmsg'] || $user->data['user_last_privmsg'] > $user->data['session_last_visit']) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_last_privmsg = ' . $user->data['session_last_visit'] . ' - WHERE user_id = ' . $user->data['user_id']; - $db->sql_query($sql); - - $s_privmsg_new = true; - } - else - { - $s_privmsg_new = false; - } - } - else - { - $s_privmsg_new = false; - } - } - - $forum_id = $request->variable('f', 0); - $topic_id = $request->variable('t', 0); - - $s_feed_news = false; - - // Get option for news - if ($config['feed_enable']) - { - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE . ' - WHERE ' . $db->sql_bit_and('forum_options', FORUM_OPTION_FEED_NEWS, '<> 0'); - $result = $db->sql_query_limit($sql, 1, 0, 600); - $s_feed_news = (int) $db->sql_fetchfield('forum_id'); - $db->sql_freeresult($result); - } - - // Determine board url - we may need it later - $board_url = generate_board_url() . '/'; - // This path is sent with the base template paths in the assign_vars() - // call below. We need to correct it in case we are accessing from a - // controller because the web paths will be incorrect otherwise. - /* @var $phpbb_path_helper \phpbb\path_helper */ - $phpbb_path_helper = $phpbb_container->get('path_helper'); - $corrected_path = $phpbb_path_helper->get_web_root_path(); - $web_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? $board_url : $corrected_path; - - // Send a proper content-language to the output - $user_lang = $user->lang['USER_LANG']; - if (strpos($user_lang, '-x-') !== false) - { - $user_lang = substr($user_lang, 0, strpos($user_lang, '-x-')); - } - - $s_search_hidden_fields = array(); - if ($_SID) - { - $s_search_hidden_fields['sid'] = $_SID; - } - - if (!empty($_EXTRA_URL)) - { - foreach ($_EXTRA_URL as $url_param) - { - $url_param = explode('=', $url_param, 2); - $s_search_hidden_fields[$url_param[0]] = $url_param[1]; - } - } - - $dt = $user->create_datetime(); - $timezone_offset = $user->lang(array('timezones', 'UTC_OFFSET'), phpbb_format_timezone_offset($dt->getOffset())); - $timezone_name = $user->timezone->getName(); - if (isset($user->lang['timezones'][$timezone_name])) - { - $timezone_name = $user->lang['timezones'][$timezone_name]; - } - - // Output the notifications - $notifications = false; - if ($config['load_notifications'] && $config['allow_board_notifications'] && $user->data['user_id'] != ANONYMOUS && $user->data['user_type'] != USER_IGNORE) - { - /* @var $phpbb_notifications \phpbb\notification\manager */ - $phpbb_notifications = $phpbb_container->get('notification_manager'); - - $notifications = $phpbb_notifications->load_notifications('notification.method.board', array( - 'all_unread' => true, - 'limit' => 5, - )); - - foreach ($notifications['notifications'] as $notification) - { - $template->assign_block_vars('notifications', $notification->prepare_for_display()); - } - } - - /** @var \phpbb\controller\helper $controller_helper */ - $controller_helper = $phpbb_container->get('controller.helper'); - $notification_mark_hash = generate_link_hash('mark_all_notifications_read'); - - $s_login_redirect = build_hidden_fields(array('redirect' => $phpbb_path_helper->remove_web_root_path(build_url()))); - - // Add form token for login box, in case page is presenting a login form. - add_form_key('login', '_LOGIN'); - - /** - * Workaround for missing template variable in pre phpBB 3.2.6 styles. - * @deprecated 3.2.7 (To be removed: 4.0.0-a1) - */ - $form_token_login = $template->retrieve_var('S_FORM_TOKEN_LOGIN'); - if (!empty($form_token_login)) - { - $s_login_redirect .= $form_token_login; - // Remove S_FORM_TOKEN_LOGIN as it's already appended to S_LOGIN_REDIRECT - $template->assign_var('S_FORM_TOKEN_LOGIN', ''); - } - - // The following assigns all _common_ variables that may be used at any point in a template. - $template->assign_vars(array( - 'SITENAME' => $config['sitename'], - 'SITE_DESCRIPTION' => $config['site_desc'], - 'PAGE_TITLE' => $page_title, - 'SCRIPT_NAME' => str_replace('.' . $phpEx, '', $user->page['page_name']), - 'LAST_VISIT_DATE' => sprintf($user->lang['YOU_LAST_VISIT'], $s_last_visit), - 'LAST_VISIT_YOU' => $s_last_visit, - 'CURRENT_TIME' => sprintf($user->lang['CURRENT_TIME'], $user->format_date(time(), false, true)), - 'TOTAL_USERS_ONLINE' => $l_online_users, - 'LOGGED_IN_USER_LIST' => $online_userlist, - 'RECORD_USERS' => $l_online_record, - - 'PRIVATE_MESSAGE_COUNT' => (!empty($user->data['user_unread_privmsg'])) ? $user->data['user_unread_privmsg'] : 0, - 'CURRENT_USER_AVATAR' => phpbb_get_user_avatar($user->data), - 'CURRENT_USERNAME_SIMPLE' => get_username_string('no_profile', $user->data['user_id'], $user->data['username'], $user->data['user_colour']), - 'CURRENT_USERNAME_FULL' => get_username_string('full', $user->data['user_id'], $user->data['username'], $user->data['user_colour']), - 'UNREAD_NOTIFICATIONS_COUNT' => ($notifications !== false) ? $notifications['unread_count'] : '', - 'NOTIFICATIONS_COUNT' => ($notifications !== false) ? $notifications['unread_count'] : '', - 'U_VIEW_ALL_NOTIFICATIONS' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=ucp_notifications'), - 'U_MARK_ALL_NOTIFICATIONS' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=ucp_notifications&mode=notification_list&mark=all&token=' . $notification_mark_hash), - 'U_NOTIFICATION_SETTINGS' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=ucp_notifications&mode=notification_options'), - 'S_NOTIFICATIONS_DISPLAY' => $config['load_notifications'] && $config['allow_board_notifications'], - - 'S_USER_NEW_PRIVMSG' => $user->data['user_new_privmsg'], - 'S_USER_UNREAD_PRIVMSG' => $user->data['user_unread_privmsg'], - 'S_USER_NEW' => $user->data['user_new'], - - 'SID' => $SID, - '_SID' => $_SID, - 'SESSION_ID' => $user->session_id, - 'ROOT_PATH' => $web_path, - 'BOARD_URL' => $board_url, - - 'L_LOGIN_LOGOUT' => $l_login_logout, - 'L_INDEX' => ($config['board_index_text'] !== '') ? $config['board_index_text'] : $user->lang['FORUM_INDEX'], - 'L_SITE_HOME' => ($config['site_home_text'] !== '') ? $config['site_home_text'] : $user->lang['HOME'], - 'L_ONLINE_EXPLAIN' => $l_online_time, - - 'U_PRIVATEMSGS' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&folder=inbox'), - 'U_RETURN_INBOX' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&folder=inbox'), - 'U_MEMBERLIST' => append_sid("{$phpbb_root_path}memberlist.$phpEx"), - 'U_VIEWONLINE' => ($auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel')) ? append_sid("{$phpbb_root_path}viewonline.$phpEx") : '', - 'U_LOGIN_LOGOUT' => $u_login_logout, - 'U_INDEX' => append_sid("{$phpbb_root_path}index.$phpEx"), - 'U_SEARCH' => append_sid("{$phpbb_root_path}search.$phpEx"), - 'U_SITE_HOME' => $config['site_home_url'], - 'U_REGISTER' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register'), - 'U_PROFILE' => append_sid("{$phpbb_root_path}ucp.$phpEx"), - 'U_USER_PROFILE' => get_username_string('profile', $user->data['user_id'], $user->data['username'], $user->data['user_colour']), - 'U_MODCP' => append_sid("{$phpbb_root_path}mcp.$phpEx", false, true, $user->session_id), - 'U_FAQ' => $controller_helper->route('phpbb_help_faq_controller'), - 'U_SEARCH_SELF' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=egosearch'), - 'U_SEARCH_NEW' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=newposts'), - 'U_SEARCH_UNANSWERED' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=unanswered'), - 'U_SEARCH_UNREAD' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=unreadposts'), - 'U_SEARCH_ACTIVE_TOPICS'=> append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=active_topics'), - 'U_DELETE_COOKIES' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=delete_cookies'), - 'U_CONTACT_US' => ($config['contact_admin_form_enable'] && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contactadmin') : '', - 'U_TEAM' => (!$auth->acl_get('u_viewprofile')) ? '' : append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=team'), - 'U_TERMS_USE' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=terms'), - 'U_PRIVACY' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=privacy'), - 'UA_PRIVACY' => addslashes(append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=privacy')), - 'U_RESTORE_PERMISSIONS' => ($user->data['user_perm_from'] && $auth->acl_get('a_switchperm')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=restore_perm') : '', - 'U_FEED' => $controller_helper->route('phpbb_feed_index'), - - 'S_USER_LOGGED_IN' => ($user->data['user_id'] != ANONYMOUS) ? true : false, - 'S_AUTOLOGIN_ENABLED' => ($config['allow_autologin']) ? true : false, - 'S_BOARD_DISABLED' => ($config['board_disable']) ? true : false, - 'S_REGISTERED_USER' => (!empty($user->data['is_registered'])) ? true : false, - 'S_IS_BOT' => (!empty($user->data['is_bot'])) ? true : false, - 'S_USER_LANG' => $user_lang, - 'S_USER_BROWSER' => (isset($user->data['session_browser'])) ? $user->data['session_browser'] : $user->lang['UNKNOWN_BROWSER'], - 'S_USERNAME' => $user->data['username'], - 'S_CONTENT_DIRECTION' => $user->lang['DIRECTION'], - 'S_CONTENT_FLOW_BEGIN' => ($user->lang['DIRECTION'] == 'ltr') ? 'left' : 'right', - 'S_CONTENT_FLOW_END' => ($user->lang['DIRECTION'] == 'ltr') ? 'right' : 'left', - 'S_CONTENT_ENCODING' => 'UTF-8', - 'S_TIMEZONE' => sprintf($user->lang['ALL_TIMES'], $timezone_offset, $timezone_name), - 'S_DISPLAY_ONLINE_LIST' => ($l_online_time) ? 1 : 0, - 'S_DISPLAY_SEARCH' => (!$config['load_search']) ? 0 : (isset($auth) ? ($auth->acl_get('u_search') && $auth->acl_getf_global('f_search')) : 1), - 'S_DISPLAY_PM' => ($config['allow_privmsg'] && !empty($user->data['is_registered']) && ($auth->acl_get('u_readpm') || $auth->acl_get('u_sendpm'))) ? true : false, - 'S_DISPLAY_MEMBERLIST' => (isset($auth)) ? $auth->acl_get('u_viewprofile') : 0, - 'S_NEW_PM' => ($s_privmsg_new) ? 1 : 0, - 'S_REGISTER_ENABLED' => ($config['require_activation'] != USER_ACTIVATION_DISABLE) ? true : false, - 'S_FORUM_ID' => $forum_id, - 'S_TOPIC_ID' => $topic_id, - - 'S_LOGIN_ACTION' => ((!defined('ADMIN_START')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login') : append_sid("{$phpbb_admin_path}index.$phpEx", false, true, $user->session_id)), - 'S_LOGIN_REDIRECT' => $s_login_redirect, - - 'S_ENABLE_FEEDS' => ($config['feed_enable']) ? true : false, - 'S_ENABLE_FEEDS_OVERALL' => ($config['feed_overall']) ? true : false, - 'S_ENABLE_FEEDS_FORUMS' => ($config['feed_overall_forums']) ? true : false, - 'S_ENABLE_FEEDS_TOPICS' => ($config['feed_topics_new']) ? true : false, - 'S_ENABLE_FEEDS_TOPICS_ACTIVE' => ($config['feed_topics_active']) ? true : false, - 'S_ENABLE_FEEDS_NEWS' => ($s_feed_news) ? true : false, - - 'S_LOAD_UNREADS' => ($config['load_unreads_search'] && ($config['load_anon_lastread'] || $user->data['is_registered'])) ? true : false, - - 'S_SEARCH_HIDDEN_FIELDS' => build_hidden_fields($s_search_hidden_fields), - - 'T_ASSETS_VERSION' => $config['assets_version'], - 'T_ASSETS_PATH' => "{$web_path}assets", - 'T_THEME_PATH' => "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme', - 'T_TEMPLATE_PATH' => "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/template', - 'T_SUPER_TEMPLATE_PATH' => "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/template', - 'T_IMAGES_PATH' => "{$web_path}images/", - 'T_SMILIES_PATH' => "{$web_path}{$config['smilies_path']}/", - 'T_AVATAR_PATH' => "{$web_path}{$config['avatar_path']}/", - 'T_AVATAR_GALLERY_PATH' => "{$web_path}{$config['avatar_gallery_path']}/", - 'T_ICONS_PATH' => "{$web_path}{$config['icons_path']}/", - 'T_RANKS_PATH' => "{$web_path}{$config['ranks_path']}/", - 'T_UPLOAD_PATH' => "{$web_path}{$config['upload_path']}/", - 'T_STYLESHEET_LINK' => "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme/stylesheet.css?assets_version=' . $config['assets_version'], - 'T_STYLESHEET_LANG_LINK'=> "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme/' . $user->lang_name . '/stylesheet.css?assets_version=' . $config['assets_version'], - 'T_FONT_AWESOME_LINK' => !empty($config['allow_cdn']) && !empty($config['load_font_awesome_url']) ? $config['load_font_awesome_url'] : "{$web_path}assets/css/font-awesome.min.css?assets_version=" . $config['assets_version'], - 'T_JQUERY_LINK' => !empty($config['allow_cdn']) && !empty($config['load_jquery_url']) ? $config['load_jquery_url'] : "{$web_path}assets/javascript/jquery-3.4.1.min.js?assets_version=" . $config['assets_version'], - 'S_ALLOW_CDN' => !empty($config['allow_cdn']), - 'S_COOKIE_NOTICE' => !empty($config['cookie_notice']), - - 'T_THEME_NAME' => rawurlencode($user->style['style_path']), - 'T_THEME_LANG_NAME' => $user->lang_name, - 'T_TEMPLATE_NAME' => $user->style['style_path'], - 'T_SUPER_TEMPLATE_NAME' => rawurlencode((isset($user->style['style_parent_tree']) && $user->style['style_parent_tree']) ? $user->style['style_parent_tree'] : $user->style['style_path']), - 'T_IMAGES' => 'images', - 'T_SMILIES' => $config['smilies_path'], - 'T_AVATAR' => $config['avatar_path'], - 'T_AVATAR_GALLERY' => $config['avatar_gallery_path'], - 'T_ICONS' => $config['icons_path'], - 'T_RANKS' => $config['ranks_path'], - 'T_UPLOAD' => $config['upload_path'], - - 'SITE_LOGO_IMG' => $user->img('site_logo'), - )); - - $http_headers = array(); - - if ($send_headers) - { - // An array of http headers that phpBB will set. The following event may override these. - $http_headers += array( - // application/xhtml+xml not used because of IE - 'Content-type' => 'text/html; charset=UTF-8', - 'Cache-Control' => 'private, no-cache="set-cookie"', - 'Expires' => gmdate('D, d M Y H:i:s', time()) . ' GMT', - 'Referrer-Policy' => 'strict-origin-when-cross-origin', - ); - if (!empty($user->data['is_bot'])) - { - // Let reverse proxies know we detected a bot. - $http_headers['X-PHPBB-IS-BOT'] = 'yes'; - } - } - - /** - * Execute code and/or overwrite _common_ template variables after they have been assigned. - * - * @event core.page_header_after - * @var string page_title Page title - * @var bool display_online_list Do we display online users list - * @var string item Restrict online users to a certain - * session item, e.g. forum for - * session_forum_id - * @var int item_id Restrict online users to item id - * @var array http_headers HTTP headers that should be set by phpbb - * - * @since 3.1.0-b3 - */ - $vars = array('page_title', 'display_online_list', 'item_id', 'item', 'http_headers'); - extract($phpbb_dispatcher->trigger_event('core.page_header_after', compact($vars))); - - foreach ($http_headers as $hname => $hval) - { - header((string) $hname . ': ' . (string) $hval); - } - - return; -} - -/** -* Check and display the SQL report if requested. -* -* @param \phpbb\request\request_interface $request Request object -* @param \phpbb\auth\auth $auth Auth object -* @param \phpbb\db\driver\driver_interface $db Database connection -*/ -function phpbb_check_and_display_sql_report(\phpbb\request\request_interface $request, \phpbb\auth\auth $auth, \phpbb\db\driver\driver_interface $db) -{ - global $phpbb_container; - - if ($phpbb_container->getParameter('debug.sql_explain') && $request->variable('explain', false) && $auth->acl_get('a_')) - { - $db->sql_report('display'); - } -} - -/** -* Generate the debug output string -* -* @param \phpbb\db\driver\driver_interface $db Database connection -* @param \phpbb\config\config $config Config object -* @param \phpbb\auth\auth $auth Auth object -* @param \phpbb\user $user User object -* @param \phpbb\event\dispatcher_interface $phpbb_dispatcher Event dispatcher -* @return string -*/ -function phpbb_generate_debug_output(\phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\auth\auth $auth, \phpbb\user $user, \phpbb\event\dispatcher_interface $phpbb_dispatcher) -{ - global $phpbb_container; - - $debug_info = array(); - - // Output page creation time - if ($phpbb_container->getParameter('debug.load_time')) - { - if (isset($GLOBALS['starttime'])) - { - $totaltime = microtime(true) - $GLOBALS['starttime']; - $debug_info[] = sprintf('Time: %.3fs', $db->get_sql_time(), ($totaltime - $db->get_sql_time()), $totaltime); - } - } - - if ($phpbb_container->getParameter('debug.memory')) - { - $memory_usage = memory_get_peak_usage(); - if ($memory_usage) - { - $memory_usage = get_formatted_filesize($memory_usage); - - $debug_info[] = 'Peak Memory Usage: ' . $memory_usage; - } - - $debug_info[] = 'GZIP: ' . (($config['gzip_compress'] && @extension_loaded('zlib')) ? 'On' : 'Off'); - - if ($user->load) - { - $debug_info[] = 'Load: ' . $user->load; - } - } - - if ($phpbb_container->getParameter('debug.sql_explain')) - { - $debug_info[] = sprintf('Queries: %d', $db->sql_num_queries(true), $db->sql_num_queries()); - - if ($auth->acl_get('a_')) - { - $debug_info[] = 'SQL Explain'; - } - } - - /** - * Modify debug output information - * - * @event core.phpbb_generate_debug_output - * @var array debug_info Array of strings with debug information - * - * @since 3.1.0-RC3 - */ - $vars = array('debug_info'); - extract($phpbb_dispatcher->trigger_event('core.phpbb_generate_debug_output', compact($vars))); - - return implode(' | ', $debug_info); -} - -/** -* Generate page footer -* -* @param bool $run_cron Whether or not to run the cron -* @param bool $display_template Whether or not to display the template -* @param bool $exit_handler Whether or not to run the exit_handler() -*/ -function page_footer($run_cron = true, $display_template = true, $exit_handler = true) -{ - global $db, $config, $template, $user, $auth, $cache, $phpEx; - global $request, $phpbb_dispatcher, $phpbb_admin_path; - - // A listener can set this variable to `true` when it overrides this function - $page_footer_override = false; - - /** - * Execute code and/or overwrite page_footer() - * - * @event core.page_footer - * @var bool run_cron Shall we run cron tasks - * @var bool page_footer_override Shall we return instead of running - * the rest of page_footer() - * @since 3.1.0-a1 - */ - $vars = array('run_cron', 'page_footer_override'); - extract($phpbb_dispatcher->trigger_event('core.page_footer', compact($vars))); - - if ($page_footer_override) - { - return; - } - - phpbb_check_and_display_sql_report($request, $auth, $db); - - $template->assign_vars(array( - 'DEBUG_OUTPUT' => phpbb_generate_debug_output($db, $config, $auth, $user, $phpbb_dispatcher), - 'TRANSLATION_INFO' => (!empty($user->lang['TRANSLATION_INFO'])) ? $user->lang['TRANSLATION_INFO'] : '', - 'CREDIT_LINE' => $user->lang('POWERED_BY', 'phpBB® Forum Software © phpBB Limited'), - - 'U_ACP' => ($auth->acl_get('a_') && !empty($user->data['is_registered'])) ? append_sid("{$phpbb_admin_path}index.$phpEx", false, true, $user->session_id) : '') - ); - - // Call cron-type script - $call_cron = false; - if (!defined('IN_CRON') && !$config['use_system_cron'] && $run_cron && !$config['board_disable'] && !$user->data['is_bot'] && !$cache->get('_cron.lock_check')) - { - $call_cron = true; - $time_now = (!empty($user->time_now) && is_int($user->time_now)) ? $user->time_now : time(); - - // Any old lock present? - if (!empty($config['cron_lock'])) - { - $cron_time = explode(' ', $config['cron_lock']); - - // If 1 hour lock is present we do not call cron.php - if ($cron_time[0] + 3600 >= $time_now) - { - $call_cron = false; - } - } - } - - // Call cron job? - if ($call_cron) - { - global $phpbb_container; - - /* @var $cron \phpbb\cron\manager */ - $cron = $phpbb_container->get('cron.manager'); - $task = $cron->find_one_ready_task(); - - if ($task) - { - $url = $task->get_url(); - $template->assign_var('RUN_CRON_TASK', 'cron'); - } - else - { - $cache->put('_cron.lock_check', true, 60); - } - } - - /** - * Execute code and/or modify output before displaying the template. - * - * @event core.page_footer_after - * @var bool display_template Whether or not to display the template - * @var bool exit_handler Whether or not to run the exit_handler() - * - * @since 3.1.0-RC5 - */ - $vars = array('display_template', 'exit_handler'); - extract($phpbb_dispatcher->trigger_event('core.page_footer_after', compact($vars))); - - if ($display_template) - { - $template->display('body'); - } - - garbage_collection(); - - if ($exit_handler) - { - exit_handler(); - } -} - -/** -* Closing the cache object and the database -* Cool function name, eh? We might want to add operations to it later -*/ -function garbage_collection() -{ - global $cache, $db; - global $phpbb_dispatcher; - - if (!empty($phpbb_dispatcher)) - { - /** - * Unload some objects, to free some memory, before we finish our task - * - * @event core.garbage_collection - * @since 3.1.0-a1 - */ - $phpbb_dispatcher->dispatch('core.garbage_collection'); - } - - // Unload cache, must be done before the DB connection if closed - if (!empty($cache)) - { - $cache->unload(); - } - - // Close our DB connection. - if (!empty($db)) - { - $db->sql_close(); - } -} - -/** -* Handler for exit calls in phpBB. -* This function supports hooks. -* -* Note: This function is called after the template has been outputted. -*/ -function exit_handler() -{ - global $phpbb_hook; - - if (!empty($phpbb_hook) && $phpbb_hook->call_hook(__FUNCTION__)) - { - if ($phpbb_hook->hook_return(__FUNCTION__)) - { - return $phpbb_hook->hook_return_result(__FUNCTION__); - } - } - - // As a pre-caution... some setups display a blank page if the flush() is not there. - (ob_get_level() > 0) ? @ob_flush() : @flush(); - - exit; -} - -/** -* Handler for init calls in phpBB. This function is called in \phpbb\user::setup(); -* This function supports hooks. -*/ -function phpbb_user_session_handler() -{ - global $phpbb_hook; - - if (!empty($phpbb_hook) && $phpbb_hook->call_hook(__FUNCTION__)) - { - if ($phpbb_hook->hook_return(__FUNCTION__)) - { - return $phpbb_hook->hook_return_result(__FUNCTION__); - } - } - - return; -} - -/** -* Casts a numeric string $input to an appropriate numeric type (i.e. integer or float) -* -* @param string $input A numeric string. -* -* @return int|float Integer $input if $input fits integer, -* float $input otherwise. -*/ -function phpbb_to_numeric($input) -{ - return ($input > PHP_INT_MAX) ? (float) $input : (int) $input; -} - -/** -* Get the board contact details (e.g. for emails) -* -* @param \phpbb\config\config $config -* @param string $phpEx -* @return string -*/ -function phpbb_get_board_contact(\phpbb\config\config $config, $phpEx) -{ - if ($config['contact_admin_form_enable']) - { - return generate_board_url() . '/memberlist.' . $phpEx . '?mode=contactadmin'; - } - else - { - return $config['board_contact']; - } -} - -/** -* Get a clickable board contact details link -* -* @param \phpbb\config\config $config -* @param string $phpbb_root_path -* @param string $phpEx -* @return string -*/ -function phpbb_get_board_contact_link(\phpbb\config\config $config, $phpbb_root_path, $phpEx) -{ - if ($config['contact_admin_form_enable'] && $config['email_enable']) - { - return append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contactadmin'); - } - else - { - return 'mailto:' . htmlspecialchars($config['board_contact']); - } -} diff --git a/install/update/new/includes/functions_acp.php b/install/update/new/includes/functions_acp.php deleted file mode 100644 index 4926351..0000000 --- a/install/update/new/includes/functions_acp.php +++ /dev/null @@ -1,727 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* Header for acp pages -*/ -function adm_page_header($page_title) -{ - global $config, $user, $template; - global $phpbb_root_path, $phpbb_admin_path, $phpEx, $SID, $_SID; - global $phpbb_dispatcher, $phpbb_container; - - if (defined('HEADER_INC')) - { - return; - } - - define('HEADER_INC', true); - - // A listener can set this variable to `true` when it overrides this function - $adm_page_header_override = false; - - /** - * Execute code and/or overwrite adm_page_header() - * - * @event core.adm_page_header - * @var string page_title Page title - * @var bool adm_page_header_override Shall we return instead of - * running the rest of adm_page_header() - * @since 3.1.0-a1 - */ - $vars = array('page_title', 'adm_page_header_override'); - extract($phpbb_dispatcher->trigger_event('core.adm_page_header', compact($vars))); - - if ($adm_page_header_override) - { - return; - } - - $user->update_session_infos(); - - // gzip_compression - if ($config['gzip_compress']) - { - if (@extension_loaded('zlib') && !headers_sent()) - { - ob_start('ob_gzhandler'); - } - } - - $template->assign_vars(array( - 'PAGE_TITLE' => $page_title, - 'USERNAME' => $user->data['username'], - - 'SID' => $SID, - '_SID' => $_SID, - 'SESSION_ID' => $user->session_id, - 'ROOT_PATH' => $phpbb_root_path, - 'ADMIN_ROOT_PATH' => $phpbb_admin_path, - - 'U_LOGOUT' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=logout'), - 'U_ADM_LOGOUT' => append_sid("{$phpbb_admin_path}index.$phpEx", 'action=admlogout'), - 'U_ADM_INDEX' => append_sid("{$phpbb_admin_path}index.$phpEx"), - 'U_INDEX' => append_sid("{$phpbb_root_path}index.$phpEx"), - - 'T_IMAGES_PATH' => "{$phpbb_root_path}images/", - 'T_SMILIES_PATH' => "{$phpbb_root_path}{$config['smilies_path']}/", - 'T_AVATAR_PATH' => "{$phpbb_root_path}{$config['avatar_path']}/", - 'T_AVATAR_GALLERY_PATH' => "{$phpbb_root_path}{$config['avatar_gallery_path']}/", - 'T_ICONS_PATH' => "{$phpbb_root_path}{$config['icons_path']}/", - 'T_RANKS_PATH' => "{$phpbb_root_path}{$config['ranks_path']}/", - 'T_UPLOAD_PATH' => "{$phpbb_root_path}{$config['upload_path']}/", - 'T_FONT_AWESOME_LINK' => !empty($config['allow_cdn']) && !empty($config['load_font_awesome_url']) ? $config['load_font_awesome_url'] : "{$phpbb_root_path}assets/css/font-awesome.min.css?assets_version=" . $config['assets_version'], - - 'T_ASSETS_VERSION' => $config['assets_version'], - - 'ICON_MOVE_UP' => '' . $user->lang['MOVE_UP'] . '', - 'ICON_MOVE_UP_DISABLED' => '' . $user->lang['MOVE_UP'] . '', - 'ICON_MOVE_DOWN' => '' . $user->lang['MOVE_DOWN'] . '', - 'ICON_MOVE_DOWN_DISABLED' => '' . $user->lang['MOVE_DOWN'] . '', - 'ICON_EDIT' => '' . $user->lang['EDIT'] . '', - 'ICON_EDIT_DISABLED' => '' . $user->lang['EDIT'] . '', - 'ICON_DELETE' => '' . $user->lang['DELETE'] . '', - 'ICON_DELETE_DISABLED' => '' . $user->lang['DELETE'] . '', - 'ICON_SYNC' => '' . $user->lang['RESYNC'] . '', - 'ICON_SYNC_DISABLED' => '' . $user->lang['RESYNC'] . '', - - 'S_USER_LANG' => $user->lang['USER_LANG'], - 'S_CONTENT_DIRECTION' => $user->lang['DIRECTION'], - 'S_CONTENT_ENCODING' => 'UTF-8', - 'S_CONTENT_FLOW_BEGIN' => ($user->lang['DIRECTION'] == 'ltr') ? 'left' : 'right', - 'S_CONTENT_FLOW_END' => ($user->lang['DIRECTION'] == 'ltr') ? 'right' : 'left', - - 'CONTAINER_EXCEPTION' => $phpbb_container->hasParameter('container_exception') ? $phpbb_container->getParameter('container_exception') : false, - )); - - // An array of http headers that phpBB will set. The following event may override these. - $http_headers = array( - // application/xhtml+xml not used because of IE - 'Content-type' => 'text/html; charset=UTF-8', - 'Cache-Control' => 'private, no-cache="set-cookie"', - 'Expires' => gmdate('D, d M Y H:i:s', time()) . ' GMT', - 'Referrer-Policy' => 'strict-origin-when-cross-origin', - ); - - /** - * Execute code and/or overwrite _common_ template variables after they have been assigned. - * - * @event core.adm_page_header_after - * @var string page_title Page title - * @var array http_headers HTTP headers that should be set by phpbb - * - * @since 3.1.0-RC3 - */ - $vars = array('page_title', 'http_headers'); - extract($phpbb_dispatcher->trigger_event('core.adm_page_header_after', compact($vars))); - - foreach ($http_headers as $hname => $hval) - { - header((string) $hname . ': ' . (string) $hval); - } - - return; -} - -/** -* Page footer for acp pages -*/ -function adm_page_footer($copyright_html = true) -{ - global $db, $config, $template, $user, $auth; - global $phpbb_root_path; - global $request, $phpbb_dispatcher; - - // A listener can set this variable to `true` when it overrides this function - $adm_page_footer_override = false; - - /** - * Execute code and/or overwrite adm_page_footer() - * - * @event core.adm_page_footer - * @var bool copyright_html Shall we display the copyright? - * @var bool adm_page_footer_override Shall we return instead of - * running the rest of adm_page_footer() - * @since 3.1.0-a1 - */ - $vars = array('copyright_html', 'adm_page_footer_override'); - extract($phpbb_dispatcher->trigger_event('core.adm_page_footer', compact($vars))); - - if ($adm_page_footer_override) - { - return; - } - - phpbb_check_and_display_sql_report($request, $auth, $db); - - $template->assign_vars(array( - 'DEBUG_OUTPUT' => phpbb_generate_debug_output($db, $config, $auth, $user, $phpbb_dispatcher), - 'TRANSLATION_INFO' => (!empty($user->lang['TRANSLATION_INFO'])) ? $user->lang['TRANSLATION_INFO'] : '', - 'S_COPYRIGHT_HTML' => $copyright_html, - 'CREDIT_LINE' => $user->lang('POWERED_BY', 'phpBB® Forum Software © phpBB Limited'), - 'T_JQUERY_LINK' => !empty($config['allow_cdn']) && !empty($config['load_jquery_url']) ? $config['load_jquery_url'] : "{$phpbb_root_path}assets/javascript/jquery-3.4.1.min.js", - 'S_ALLOW_CDN' => !empty($config['allow_cdn']), - 'VERSION' => $config['version']) - ); - - $template->display('body'); - - garbage_collection(); - exit_handler(); -} - -/** -* Generate back link for acp pages -*/ -function adm_back_link($u_action) -{ - global $user; - return '

« ' . $user->lang['BACK_TO_PREV'] . ''; -} - -/** -* Build select field options in acp pages -*/ -function build_select($option_ary, $option_default = false) -{ - global $user; - - $html = ''; - foreach ($option_ary as $value => $title) - { - $selected = ($option_default !== false && $value == $option_default) ? ' selected="selected"' : ''; - $html .= ''; - } - - return $html; -} - -/** -* Build radio fields in acp pages -*/ -function h_radio($name, $input_ary, $input_default = false, $id = false, $key = false, $separator = '') -{ - global $user; - - $html = ''; - $id_assigned = false; - foreach ($input_ary as $value => $title) - { - $selected = ($input_default !== false && $value == $input_default) ? ' checked="checked"' : ''; - $html .= '' . $separator; - $id_assigned = true; - } - - return $html; -} - -/** -* Build configuration template for acp configuration pages -*/ -function build_cfg_template($tpl_type, $key, &$new_ary, $config_key, $vars) -{ - global $user, $module, $phpbb_dispatcher; - - $tpl = ''; - $name = 'config[' . $config_key . ']'; - - // Make sure there is no notice printed out for non-existent config options (we simply set them) - if (!isset($new_ary[$config_key])) - { - $new_ary[$config_key] = ''; - } - - switch ($tpl_type[0]) - { - case 'password': - if ($new_ary[$config_key] !== '') - { - // replace passwords with asterixes - $new_ary[$config_key] = '********'; - } - case 'text': - case 'url': - case 'email': - case 'tel': - case 'search': - // maxlength and size are only valid for these types and will be - // ignored for other input types. - $size = (int) $tpl_type[1]; - $maxlength = (int) $tpl_type[2]; - - $tpl = ''; - break; - - case 'color': - case 'datetime': - case 'datetime-local': - case 'month': - case 'week': - $tpl = ''; - break; - - case 'date': - case 'time': - case 'number': - case 'range': - $max = ''; - $min = ( isset($tpl_type[1]) ) ? (int) $tpl_type[1] : false; - if ( isset($tpl_type[2]) ) - { - $max = (int) $tpl_type[2]; - } - - $tpl = ''; - break; - - case 'dimension': - $max = ''; - - $min = (int) $tpl_type[1]; - - if ( isset($tpl_type[2]) ) - { - $max = (int) $tpl_type[2]; - } - - $tpl = ' x '; - break; - - case 'textarea': - $rows = (int) $tpl_type[1]; - $cols = (int) $tpl_type[2]; - - $tpl = ''; - break; - - case 'radio': - $key_yes = ($new_ary[$config_key]) ? ' checked="checked"' : ''; - $key_no = (!$new_ary[$config_key]) ? ' checked="checked"' : ''; - - $tpl_type_cond = explode('_', $tpl_type[1]); - $type_no = ($tpl_type_cond[0] == 'disabled' || $tpl_type_cond[0] == 'enabled') ? false : true; - - $tpl_no = ''; - $tpl_yes = ''; - - $tpl = ($tpl_type_cond[0] == 'yes' || $tpl_type_cond[0] == 'enabled') ? $tpl_yes . $tpl_no : $tpl_no . $tpl_yes; - break; - - case 'select': - case 'custom': - - if (isset($vars['method'])) - { - $call = array($module->module, $vars['method']); - } - else if (isset($vars['function'])) - { - $call = $vars['function']; - } - else - { - break; - } - - if (isset($vars['params'])) - { - $args = array(); - foreach ($vars['params'] as $value) - { - switch ($value) - { - case '{CONFIG_VALUE}': - $value = $new_ary[$config_key]; - break; - - case '{KEY}': - $value = $key; - break; - } - - $args[] = $value; - } - } - else - { - $args = array($new_ary[$config_key], $key); - } - - $return = call_user_func_array($call, $args); - - if ($tpl_type[0] == 'select') - { - $size = (isset($tpl_type[1])) ? (int) $tpl_type[1] : 1; - $data_toggle = (!empty($tpl_type[2])) ? ' data-togglable-settings="true"' : ''; - - $tpl = ''; - } - else - { - $tpl = $return; - } - - break; - - default: - break; - } - - if (isset($vars['append'])) - { - $tpl .= $vars['append']; - } - - $new = $new_ary; - /** - * Overwrite the html code we display for the config value - * - * @event core.build_config_template - * @var array tpl_type Config type array: - * 0 => data type - * 1 [optional] => string: size, int: minimum - * 2 [optional] => string: max. length, int: maximum - * @var string key Should be used for the id attribute in html - * @var array new Array with the config values we display - * @var string name Should be used for the name attribute - * @var array vars Array with the options for the config - * @var string tpl The resulting html code we display - * @since 3.1.0-a1 - */ - $vars = array('tpl_type', 'key', 'new', 'name', 'vars', 'tpl'); - extract($phpbb_dispatcher->trigger_event('core.build_config_template', compact($vars))); - $new_ary = $new; - unset($new); - - return $tpl; -} - -/** -* Going through a config array and validate values, writing errors to $error. The validation method accepts parameters separated by ':' for string and int. -* The first parameter defines the type to be used, the second the lower bound and the third the upper bound. Only the type is required. -*/ -function validate_config_vars($config_vars, &$cfg_array, &$error) -{ - global $phpbb_root_path, $user, $phpbb_dispatcher, $phpbb_filesystem, $language; - - $type = 0; - $min = 1; - $max = 2; - - foreach ($config_vars as $config_name => $config_definition) - { - if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false) - { - continue; - } - - if (!isset($config_definition['validate'])) - { - continue; - } - - $validator = explode(':', $config_definition['validate']); - - // Validate a bit. ;) (0 = type, 1 = min, 2= max) - switch ($validator[$type]) - { - case 'url': - $cfg_array[$config_name] = trim($cfg_array[$config_name]); - - if (!empty($cfg_array[$config_name]) && !preg_match('#^' . get_preg_expression('url') . '$#iu', $cfg_array[$config_name])) - { - $error[] = $language->lang('URL_INVALID', $language->lang($config_definition['lang'])); - } - - // no break here - - case 'string': - $length = utf8_strlen($cfg_array[$config_name]); - - // the column is a VARCHAR - $validator[$max] = (isset($validator[$max])) ? min(255, $validator[$max]) : 255; - - if (isset($validator[$min]) && $length < $validator[$min]) - { - $error[] = sprintf($user->lang['SETTING_TOO_SHORT'], $user->lang[$config_definition['lang']], $validator[$min]); - } - else if (isset($validator[$max]) && $length > $validator[2]) - { - $error[] = sprintf($user->lang['SETTING_TOO_LONG'], $user->lang[$config_definition['lang']], $validator[$max]); - } - break; - - case 'bool': - $cfg_array[$config_name] = ($cfg_array[$config_name]) ? 1 : 0; - break; - - case 'int': - $cfg_array[$config_name] = (int) $cfg_array[$config_name]; - - if (isset($validator[$min]) && $cfg_array[$config_name] < $validator[$min]) - { - $error[] = sprintf($user->lang['SETTING_TOO_LOW'], $user->lang[$config_definition['lang']], $validator[$min]); - } - else if (isset($validator[$max]) && $cfg_array[$config_name] > $validator[$max]) - { - $error[] = sprintf($user->lang['SETTING_TOO_BIG'], $user->lang[$config_definition['lang']], $validator[$max]); - } - - if (strpos($config_name, '_max') !== false) - { - // Min/max pairs of settings should ensure that min <= max - // Replace _max with _min to find the name of the minimum - // corresponding configuration variable - $min_name = str_replace('_max', '_min', $config_name); - - if (isset($cfg_array[$min_name]) && is_numeric($cfg_array[$min_name]) && $cfg_array[$config_name] < $cfg_array[$min_name]) - { - // A minimum value exists and the maximum value is less than it - $error[] = sprintf($user->lang['SETTING_TOO_LOW'], $user->lang[$config_definition['lang']], (int) $cfg_array[$min_name]); - } - } - break; - - case 'email': - if (!preg_match('/^' . get_preg_expression('email') . '$/i', $cfg_array[$config_name])) - { - $error[] = $user->lang['EMAIL_INVALID_EMAIL']; - } - break; - - // Absolute path - case 'script_path': - if (!$cfg_array[$config_name]) - { - break; - } - - $destination = str_replace('\\', '/', $cfg_array[$config_name]); - - if ($destination !== '/') - { - // Adjust destination path (no trailing slash) - if (substr($destination, -1, 1) == '/') - { - $destination = substr($destination, 0, -1); - } - - $destination = str_replace(array('../', './'), '', $destination); - - if ($destination[0] != '/') - { - $destination = '/' . $destination; - } - } - - $cfg_array[$config_name] = trim($destination); - - break; - - // Absolute path - case 'lang': - if (!$cfg_array[$config_name]) - { - break; - } - - $cfg_array[$config_name] = basename($cfg_array[$config_name]); - - if (!file_exists($phpbb_root_path . 'language/' . $cfg_array[$config_name] . '/')) - { - $error[] = $user->lang['WRONG_DATA_LANG']; - } - break; - - // Relative path (appended $phpbb_root_path) - case 'rpath': - case 'rwpath': - if (!$cfg_array[$config_name]) - { - break; - } - - $destination = $cfg_array[$config_name]; - - // Adjust destination path (no trailing slash) - if (substr($destination, -1, 1) == '/' || substr($destination, -1, 1) == '\\') - { - $destination = substr($destination, 0, -1); - } - - $destination = str_replace(array('../', '..\\', './', '.\\'), '', $destination); - if ($destination && ($destination[0] == '/' || $destination[0] == "\\")) - { - $destination = ''; - } - - $cfg_array[$config_name] = trim($destination); - - // Path being relative (still prefixed by phpbb_root_path), but with the ability to escape the root dir... - case 'path': - case 'wpath': - - if (!$cfg_array[$config_name]) - { - break; - } - - $cfg_array[$config_name] = trim($cfg_array[$config_name]); - - // Make sure no NUL byte is present... - if (strpos($cfg_array[$config_name], "\0") !== false || strpos($cfg_array[$config_name], '%00') !== false) - { - $cfg_array[$config_name] = ''; - break; - } - - $path = $phpbb_root_path . $cfg_array[$config_name]; - - if (!file_exists($path)) - { - $error[] = sprintf($user->lang['DIRECTORY_DOES_NOT_EXIST'], $cfg_array[$config_name]); - } - - if (file_exists($path) && !is_dir($path)) - { - $error[] = sprintf($user->lang['DIRECTORY_NOT_DIR'], $cfg_array[$config_name]); - } - - // Check if the path is writable - if ($config_definition['validate'] == 'wpath' || $config_definition['validate'] == 'rwpath') - { - if (file_exists($path) && !$phpbb_filesystem->is_writable($path)) - { - $error[] = sprintf($user->lang['DIRECTORY_NOT_WRITABLE'], $cfg_array[$config_name]); - } - } - - break; - - default: - /** - * Validate a config value - * - * @event core.validate_config_variable - * @var array cfg_array Array with config values - * @var string config_name Name of the config we validate - * @var array config_definition Array with the options for - * this config - * @var array error Array of errors, the errors should - * be strings only, language keys are - * not replaced afterwards - * @since 3.1.0-a1 - */ - $vars = array('cfg_array', 'config_name', 'config_definition', 'error'); - extract($phpbb_dispatcher->trigger_event('core.validate_config_variable', compact($vars))); - break; - } - } - - return; -} - -/** -* Checks whatever or not a variable is OK for use in the Database -* param mixed $value_ary An array of the form array(array('lang' => ..., 'value' => ..., 'column_type' =>))' -* param mixed $error The error array -*/ -function validate_range($value_ary, &$error) -{ - global $user; - - $column_types = array( - 'BOOL' => array('php_type' => 'int', 'min' => 0, 'max' => 1), - 'USINT' => array('php_type' => 'int', 'min' => 0, 'max' => 65535), - 'UINT' => array('php_type' => 'int', 'min' => 0, 'max' => (int) 0x7fffffff), - // Do not use (int) 0x80000000 - it evaluates to different - // values on 32-bit and 64-bit systems. - // Apparently -2147483648 is a float on 32-bit systems, - // despite fitting in an int, thus explicit cast is needed. - 'INT' => array('php_type' => 'int', 'min' => (int) -2147483648, 'max' => (int) 0x7fffffff), - 'TINT' => array('php_type' => 'int', 'min' => -128, 'max' => 127), - - 'VCHAR' => array('php_type' => 'string', 'min' => 0, 'max' => 255), - ); - foreach ($value_ary as $value) - { - $column = explode(':', $value['column_type']); - if (!isset($column_types[$column[0]])) - { - continue; - } - else - { - $type = $column_types[$column[0]]; - } - - switch ($type['php_type']) - { - case 'string' : - $max = (isset($column[1])) ? min($column[1],$type['max']) : $type['max']; - if (utf8_strlen($value['value']) > $max) - { - $error[] = sprintf($user->lang['SETTING_TOO_LONG'], $user->lang[$value['lang']], $max); - } - break; - - case 'int': - $min = (isset($column[1])) ? max($column[1],$type['min']) : $type['min']; - $max = (isset($column[2])) ? min($column[2],$type['max']) : $type['max']; - if ($value['value'] < $min) - { - $error[] = sprintf($user->lang['SETTING_TOO_LOW'], $user->lang[$value['lang']], $min); - } - else if ($value['value'] > $max) - { - $error[] = sprintf($user->lang['SETTING_TOO_BIG'], $user->lang[$value['lang']], $max); - } - break; - } - } -} - -/** -* Inserts new config display_vars into an exisiting display_vars array -* at the given position. -* -* @param array $display_vars An array of existing config display vars -* @param array $add_config_vars An array of new config display vars -* @param array $where Where to place the new config vars, -* before or after an exisiting config, as an array -* of the form: array('after' => 'config_name') or -* array('before' => 'config_name'). -* @return array The array of config display vars -*/ -function phpbb_insert_config_array($display_vars, $add_config_vars, $where) -{ - if (is_array($where) && array_key_exists(current($where), $display_vars)) - { - $position = array_search(current($where), array_keys($display_vars)) + ((key($where) == 'before') ? 0 : 1); - $display_vars = array_merge( - array_slice($display_vars, 0, $position), - $add_config_vars, - array_slice($display_vars, $position) - ); - } - - return $display_vars; -} diff --git a/install/update/new/includes/functions_admin.php b/install/update/new/includes/functions_admin.php deleted file mode 100644 index 4629706..0000000 --- a/install/update/new/includes/functions_admin.php +++ /dev/null @@ -1,3096 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* Recalculate Nested Sets -* -* @param int $new_id first left_id (should start with 1) -* @param string $pkey primary key-column (containing the id for the parent_id of the children) -* @param string $table constant or fullname of the table -* @param int $parent_id parent_id of the current set (default = 0) -* @param array $where contains strings to compare closer on the where statement (additional) -*/ -function recalc_nested_sets(&$new_id, $pkey, $table, $parent_id = 0, $where = array()) -{ - global $db; - - $sql = 'SELECT * - FROM ' . $table . ' - WHERE parent_id = ' . (int) $parent_id . - ((!empty($where)) ? ' AND ' . implode(' AND ', $where) : '') . ' - ORDER BY left_id ASC'; - $result = $db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) - { - // First we update the left_id for this module - if ($row['left_id'] != $new_id) - { - $db->sql_query('UPDATE ' . $table . ' SET ' . $db->sql_build_array('UPDATE', array('left_id' => $new_id)) . " WHERE $pkey = {$row[$pkey]}"); - } - $new_id++; - - // Then we go through any children and update their left/right id's - recalc_nested_sets($new_id, $pkey, $table, $row[$pkey], $where); - - // Then we come back and update the right_id for this module - if ($row['right_id'] != $new_id) - { - $db->sql_query('UPDATE ' . $table . ' SET ' . $db->sql_build_array('UPDATE', array('right_id' => $new_id)) . " WHERE $pkey = {$row[$pkey]}"); - } - $new_id++; - } - $db->sql_freeresult($result); -} - -/** -* Simple version of jumpbox, just lists authed forums -*/ -function make_forum_select($select_id = false, $ignore_id = false, $ignore_acl = false, $ignore_nonpost = false, $ignore_emptycat = true, $only_acl_post = false, $return_array = false) -{ - global $db, $auth, $phpbb_dispatcher; - - // This query is identical to the jumpbox one - $sql = 'SELECT forum_id, forum_name, parent_id, forum_type, forum_flags, forum_options, left_id, right_id - FROM ' . FORUMS_TABLE . ' - ORDER BY left_id ASC'; - $result = $db->sql_query($sql, 600); - - $rowset = array(); - while ($row = $db->sql_fetchrow($result)) - { - $rowset[(int) $row['forum_id']] = $row; - } - $db->sql_freeresult($result); - - $right = 0; - $padding_store = array('0' => ''); - $padding = ''; - $forum_list = ($return_array) ? array() : ''; - - /** - * Modify the forum list data - * - * @event core.make_forum_select_modify_forum_list - * @var array rowset Array with the forums list data - * @since 3.1.10-RC1 - */ - $vars = array('rowset'); - extract($phpbb_dispatcher->trigger_event('core.make_forum_select_modify_forum_list', compact($vars))); - - // Sometimes it could happen that forums will be displayed here not be displayed within the index page - // This is the result of forums not displayed at index, having list permissions and a parent of a forum with no permissions. - // If this happens, the padding could be "broken" - - foreach ($rowset as $row) - { - if ($row['left_id'] < $right) - { - $padding .= '   '; - $padding_store[$row['parent_id']] = $padding; - } - else if ($row['left_id'] > $right + 1) - { - $padding = (isset($padding_store[$row['parent_id']])) ? $padding_store[$row['parent_id']] : ''; - } - - $right = $row['right_id']; - $disabled = false; - - if (!$ignore_acl && $auth->acl_gets(array('f_list', 'a_forum', 'a_forumadd', 'a_forumdel'), $row['forum_id'])) - { - if ($only_acl_post && !$auth->acl_get('f_post', $row['forum_id']) || (!$auth->acl_get('m_approve', $row['forum_id']) && !$auth->acl_get('f_noapprove', $row['forum_id']))) - { - $disabled = true; - } - } - else if (!$ignore_acl) - { - continue; - } - - if ( - ((is_array($ignore_id) && in_array($row['forum_id'], $ignore_id)) || $row['forum_id'] == $ignore_id) - || - // Non-postable forum with no subforums, don't display - ($row['forum_type'] == FORUM_CAT && ($row['left_id'] + 1 == $row['right_id']) && $ignore_emptycat) - || - ($row['forum_type'] != FORUM_POST && $ignore_nonpost) - ) - { - $disabled = true; - } - - if ($return_array) - { - // Include some more information... - $selected = (is_array($select_id)) ? ((in_array($row['forum_id'], $select_id)) ? true : false) : (($row['forum_id'] == $select_id) ? true : false); - $forum_list[$row['forum_id']] = array_merge(array('padding' => $padding, 'selected' => ($selected && !$disabled), 'disabled' => $disabled), $row); - } - else - { - $selected = (is_array($select_id)) ? ((in_array($row['forum_id'], $select_id)) ? ' selected="selected"' : '') : (($row['forum_id'] == $select_id) ? ' selected="selected"' : ''); - $forum_list .= ''; - } - } - unset($padding_store, $rowset); - - return $forum_list; -} - -/** -* Generate size select options -*/ -function size_select_options($size_compare) -{ - global $user; - - $size_types_text = array($user->lang['BYTES'], $user->lang['KIB'], $user->lang['MIB']); - $size_types = array('b', 'kb', 'mb'); - - $s_size_options = ''; - - for ($i = 0, $size = count($size_types_text); $i < $size; $i++) - { - $selected = ($size_compare == $size_types[$i]) ? ' selected="selected"' : ''; - $s_size_options .= ''; - } - - return $s_size_options; -} - -/** -* Generate list of groups (option fields without select) -* -* @param int $group_id The default group id to mark as selected -* @param array $exclude_ids The group ids to exclude from the list, false (default) if you whish to exclude no id -* @param int $manage_founder If set to false (default) all groups are returned, if 0 only those groups returned not being managed by founders only, if 1 only those groups returned managed by founders only. -* -* @return string The list of options. -*/ -function group_select_options($group_id, $exclude_ids = false, $manage_founder = false) -{ - global $db, $config, $phpbb_container; - - /** @var \phpbb\group\helper $group_helper */ - $group_helper = $phpbb_container->get('group_helper'); - - $exclude_sql = ($exclude_ids !== false && count($exclude_ids)) ? 'WHERE ' . $db->sql_in_set('group_id', array_map('intval', $exclude_ids), true) : ''; - $sql_and = (!$config['coppa_enable']) ? (($exclude_sql) ? ' AND ' : ' WHERE ') . "group_name <> 'REGISTERED_COPPA'" : ''; - $sql_founder = ($manage_founder !== false) ? (($exclude_sql || $sql_and) ? ' AND ' : ' WHERE ') . 'group_founder_manage = ' . (int) $manage_founder : ''; - - $sql = 'SELECT group_id, group_name, group_type - FROM ' . GROUPS_TABLE . " - $exclude_sql - $sql_and - $sql_founder - ORDER BY group_type DESC, group_name ASC"; - $result = $db->sql_query($sql); - - $s_group_options = ''; - while ($row = $db->sql_fetchrow($result)) - { - $selected = ($row['group_id'] == $group_id) ? ' selected="selected"' : ''; - $s_group_options .= '' . $group_helper->get_name($row['group_name']) . ''; - } - $db->sql_freeresult($result); - - return $s_group_options; -} - -/** -* Obtain authed forums list -*/ -function get_forum_list($acl_list = 'f_list', $id_only = true, $postable_only = false, $no_cache = false) -{ - global $db, $auth, $phpbb_dispatcher; - static $forum_rows; - - if (!isset($forum_rows)) - { - // This query is identical to the jumpbox one - $expire_time = ($no_cache) ? 0 : 600; - - $sql = 'SELECT forum_id, forum_name, parent_id, forum_type, left_id, right_id - FROM ' . FORUMS_TABLE . ' - ORDER BY left_id ASC'; - $result = $db->sql_query($sql, $expire_time); - - $forum_rows = array(); - - $right = $padding = 0; - $padding_store = array('0' => 0); - - while ($row = $db->sql_fetchrow($result)) - { - if ($row['left_id'] < $right) - { - $padding++; - $padding_store[$row['parent_id']] = $padding; - } - else if ($row['left_id'] > $right + 1) - { - // Ok, if the $padding_store for this parent is empty there is something wrong. For now we will skip over it. - // @todo digging deep to find out "how" this can happen. - $padding = (isset($padding_store[$row['parent_id']])) ? $padding_store[$row['parent_id']] : $padding; - } - - $right = $row['right_id']; - $row['padding'] = $padding; - - $forum_rows[] = $row; - } - $db->sql_freeresult($result); - unset($padding_store); - } - - $rowset = array(); - foreach ($forum_rows as $row) - { - if ($postable_only && $row['forum_type'] != FORUM_POST) - { - continue; - } - - if ($acl_list == '' || ($acl_list != '' && $auth->acl_gets($acl_list, $row['forum_id']))) - { - $rowset[] = ($id_only) ? (int) $row['forum_id'] : $row; - } - } - - /** - * Modify the forum list data - * - * @event core.get_forum_list_modify_data - * @var array rowset Array with the forum list data - * @since 3.1.10-RC1 - */ - $vars = array('rowset'); - extract($phpbb_dispatcher->trigger_event('core.get_forum_list_modify_data', compact($vars))); - - return $rowset; -} - -/** -* Get forum branch -*/ -function get_forum_branch($forum_id, $type = 'all', $order = 'descending', $include_forum = true) -{ - global $db; - - switch ($type) - { - case 'parents': - $condition = 'f1.left_id BETWEEN f2.left_id AND f2.right_id'; - break; - - case 'children': - $condition = 'f2.left_id BETWEEN f1.left_id AND f1.right_id'; - break; - - default: - $condition = 'f2.left_id BETWEEN f1.left_id AND f1.right_id OR f1.left_id BETWEEN f2.left_id AND f2.right_id'; - break; - } - - $rows = array(); - - $sql = 'SELECT f2.* - FROM ' . FORUMS_TABLE . ' f1 - LEFT JOIN ' . FORUMS_TABLE . " f2 ON ($condition) - WHERE f1.forum_id = $forum_id - ORDER BY f2.left_id " . (($order == 'descending') ? 'ASC' : 'DESC'); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if (!$include_forum && $row['forum_id'] == $forum_id) - { - continue; - } - - $rows[] = $row; - } - $db->sql_freeresult($result); - - return $rows; -} - -/** -* Copies permissions from one forum to others -* -* @param int $src_forum_id The source forum we want to copy permissions from -* @param array $dest_forum_ids The destination forum(s) we want to copy to -* @param bool $clear_dest_perms True if destination permissions should be deleted -* @param bool $add_log True if log entry should be added -* -* @return bool False on error -*/ -function copy_forum_permissions($src_forum_id, $dest_forum_ids, $clear_dest_perms = true, $add_log = true) -{ - global $db, $user, $phpbb_log; - - // Only one forum id specified - if (!is_array($dest_forum_ids)) - { - $dest_forum_ids = array($dest_forum_ids); - } - - // Make sure forum ids are integers - $src_forum_id = (int) $src_forum_id; - $dest_forum_ids = array_map('intval', $dest_forum_ids); - - // No source forum or no destination forums specified - if (empty($src_forum_id) || empty($dest_forum_ids)) - { - return false; - } - - // Check if source forum exists - $sql = 'SELECT forum_name - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . $src_forum_id; - $result = $db->sql_query($sql); - $src_forum_name = $db->sql_fetchfield('forum_name'); - $db->sql_freeresult($result); - - // Source forum doesn't exist - if (empty($src_forum_name)) - { - return false; - } - - // Check if destination forums exists - $sql = 'SELECT forum_id, forum_name - FROM ' . FORUMS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $dest_forum_ids); - $result = $db->sql_query($sql); - - $dest_forum_ids = $dest_forum_names = array(); - while ($row = $db->sql_fetchrow($result)) - { - $dest_forum_ids[] = (int) $row['forum_id']; - $dest_forum_names[] = $row['forum_name']; - } - $db->sql_freeresult($result); - - // No destination forum exists - if (empty($dest_forum_ids)) - { - return false; - } - - // From the mysql documentation: - // Prior to MySQL 4.0.14, the target table of the INSERT statement cannot appear - // in the FROM clause of the SELECT part of the query. This limitation is lifted in 4.0.14. - // Due to this we stay on the safe side if we do the insertion "the manual way" - - // Rowsets we're going to insert - $users_sql_ary = $groups_sql_ary = array(); - - // Query acl users table for source forum data - $sql = 'SELECT user_id, auth_option_id, auth_role_id, auth_setting - FROM ' . ACL_USERS_TABLE . ' - WHERE forum_id = ' . $src_forum_id; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $row = array( - 'user_id' => (int) $row['user_id'], - 'auth_option_id' => (int) $row['auth_option_id'], - 'auth_role_id' => (int) $row['auth_role_id'], - 'auth_setting' => (int) $row['auth_setting'], - ); - - foreach ($dest_forum_ids as $dest_forum_id) - { - $users_sql_ary[] = $row + array('forum_id' => $dest_forum_id); - } - } - $db->sql_freeresult($result); - - // Query acl groups table for source forum data - $sql = 'SELECT group_id, auth_option_id, auth_role_id, auth_setting - FROM ' . ACL_GROUPS_TABLE . ' - WHERE forum_id = ' . $src_forum_id; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $row = array( - 'group_id' => (int) $row['group_id'], - 'auth_option_id' => (int) $row['auth_option_id'], - 'auth_role_id' => (int) $row['auth_role_id'], - 'auth_setting' => (int) $row['auth_setting'], - ); - - foreach ($dest_forum_ids as $dest_forum_id) - { - $groups_sql_ary[] = $row + array('forum_id' => $dest_forum_id); - } - } - $db->sql_freeresult($result); - - $db->sql_transaction('begin'); - - // Clear current permissions of destination forums - if ($clear_dest_perms) - { - $sql = 'DELETE FROM ' . ACL_USERS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $dest_forum_ids); - $db->sql_query($sql); - - $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $dest_forum_ids); - $db->sql_query($sql); - } - - $db->sql_multi_insert(ACL_USERS_TABLE, $users_sql_ary); - $db->sql_multi_insert(ACL_GROUPS_TABLE, $groups_sql_ary); - - if ($add_log) - { - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_COPIED_PERMISSIONS', false, array($src_forum_name, implode(', ', $dest_forum_names))); - } - - $db->sql_transaction('commit'); - - return true; -} - -/** -* Get physical file listing -*/ -function filelist($rootdir, $dir = '', $type = 'gif|jpg|jpeg|png') -{ - $matches = array($dir => array()); - - // Remove initial / if present - $rootdir = (substr($rootdir, 0, 1) == '/') ? substr($rootdir, 1) : $rootdir; - // Add closing / if not present - $rootdir = ($rootdir && substr($rootdir, -1) != '/') ? $rootdir . '/' : $rootdir; - - // Remove initial / if present - $dir = (substr($dir, 0, 1) == '/') ? substr($dir, 1) : $dir; - // Add closing / if not present - $dir = ($dir && substr($dir, -1) != '/') ? $dir . '/' : $dir; - - if (!is_dir($rootdir . $dir)) - { - return $matches; - } - - $dh = @opendir($rootdir . $dir); - - if (!$dh) - { - return $matches; - } - - while (($fname = readdir($dh)) !== false) - { - if (is_file("$rootdir$dir$fname")) - { - if (filesize("$rootdir$dir$fname") && preg_match('#\.' . $type . '$#i', $fname)) - { - $matches[$dir][] = $fname; - } - } - else if ($fname[0] != '.' && is_dir("$rootdir$dir$fname")) - { - $matches += filelist($rootdir, "$dir$fname", $type); - } - } - closedir($dh); - - return $matches; -} - -/** -* Move topic(s) -*/ -function move_topics($topic_ids, $forum_id, $auto_sync = true) -{ - global $db, $phpbb_dispatcher; - - if (empty($topic_ids)) - { - return; - } - - $forum_ids = array($forum_id); - - if (!is_array($topic_ids)) - { - $topic_ids = array($topic_ids); - } - - /** - * Perform additional actions before topics move - * - * @event core.move_topics_before - * @var array topic_ids Array of the moved topic ids - * @var string forum_id The forum id from where the topics are moved - * @since 3.2.9-RC1 - */ - $vars = array( - 'topic_ids', - 'forum_id', - ); - extract($phpbb_dispatcher->trigger_event('core.move_topics_before', compact($vars))); - - $sql = 'DELETE FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_moved_id', $topic_ids) . ' - AND forum_id = ' . $forum_id; - $db->sql_query($sql); - - if ($auto_sync) - { - $sql = 'SELECT DISTINCT forum_id - FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', $topic_ids); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $forum_ids[] = $row['forum_id']; - } - $db->sql_freeresult($result); - } - - $table_ary = array(TOPICS_TABLE, POSTS_TABLE, LOG_TABLE, DRAFTS_TABLE, TOPICS_TRACK_TABLE); - - /** - * Perform additional actions before topics move - * - * @event core.move_topics_before_query - * @var array table_ary Array of tables from which forum_id will be updated for all rows that hold the moved topics - * @var array topic_ids Array of the moved topic ids - * @var string forum_id The forum id from where the topics are moved - * @var array forum_ids Array of the forums where the topics are moving (includes also forum_id) - * @var bool auto_sync Whether or not to perform auto sync - * @since 3.1.5-RC1 - */ - $vars = array( - 'table_ary', - 'topic_ids', - 'forum_id', - 'forum_ids', - 'auto_sync', - ); - extract($phpbb_dispatcher->trigger_event('core.move_topics_before_query', compact($vars))); - - foreach ($table_ary as $table) - { - $sql = "UPDATE $table - SET forum_id = $forum_id - WHERE " . $db->sql_in_set('topic_id', $topic_ids); - $db->sql_query($sql); - } - unset($table_ary); - - /** - * Perform additional actions after topics move - * - * @event core.move_topics_after - * @var array topic_ids Array of the moved topic ids - * @var string forum_id The forum id from where the topics were moved - * @var array forum_ids Array of the forums where the topics were moved (includes also forum_id) - * @since 3.2.9-RC1 - */ - $vars = array( - 'topic_ids', - 'forum_id', - 'forum_ids', - ); - extract($phpbb_dispatcher->trigger_event('core.move_topics_after', compact($vars))); - - if ($auto_sync) - { - sync('forum', 'forum_id', $forum_ids, true, true); - unset($forum_ids); - } -} - -/** -* Move post(s) -*/ -function move_posts($post_ids, $topic_id, $auto_sync = true) -{ - global $db, $phpbb_dispatcher; - - if (!is_array($post_ids)) - { - $post_ids = array($post_ids); - } - - $forum_ids = array(); - $topic_ids = array($topic_id); - - $sql = 'SELECT DISTINCT topic_id, forum_id - FROM ' . POSTS_TABLE . ' - WHERE ' . $db->sql_in_set('post_id', $post_ids); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $forum_ids[] = (int) $row['forum_id']; - $topic_ids[] = (int) $row['topic_id']; - } - $db->sql_freeresult($result); - - $sql = 'SELECT forum_id - FROM ' . TOPICS_TABLE . ' - WHERE topic_id = ' . $topic_id; - $result = $db->sql_query($sql); - $forum_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$forum_row) - { - trigger_error('NO_TOPIC'); - } - - /** - * Perform additional actions before moving posts - * - * @event core.move_posts_before - * @var array post_ids Array of post ids to move - * @var int topic_id The topic id the posts are moved to - * @var bool auto_sync Whether or not to perform auto sync - * @var array forum_ids Array of the forum ids the posts are moved from - * @var array topic_ids Array of the topic ids the posts are moved from - * @var array forum_row Array with the forum id of the topic the posts are moved to - * @since 3.1.7-RC1 - */ - $vars = array( - 'post_ids', - 'topic_id', - 'auto_sync', - 'forum_ids', - 'topic_ids', - 'forum_row', - ); - extract($phpbb_dispatcher->trigger_event('core.move_posts_before', compact($vars))); - - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET forum_id = ' . (int) $forum_row['forum_id'] . ", topic_id = $topic_id - WHERE " . $db->sql_in_set('post_id', $post_ids); - $db->sql_query($sql); - - $sql = 'UPDATE ' . ATTACHMENTS_TABLE . " - SET topic_id = $topic_id, in_message = 0 - WHERE " . $db->sql_in_set('post_msg_id', $post_ids); - $db->sql_query($sql); - - /** - * Perform additional actions after moving posts - * - * @event core.move_posts_after - * @var array post_ids Array of the moved post ids - * @var int topic_id The topic id the posts are moved to - * @var bool auto_sync Whether or not to perform auto sync - * @var array forum_ids Array of the forum ids the posts are moved from - * @var array topic_ids Array of the topic ids the posts are moved from - * @var array forum_row Array with the forum id of the topic the posts are moved to - * @since 3.1.7-RC1 - */ - $vars = array( - 'post_ids', - 'topic_id', - 'auto_sync', - 'forum_ids', - 'topic_ids', - 'forum_row', - ); - extract($phpbb_dispatcher->trigger_event('core.move_posts_after', compact($vars))); - - if ($auto_sync) - { - $forum_ids[] = (int) $forum_row['forum_id']; - - sync('topic_reported', 'topic_id', $topic_ids); - sync('topic_attachment', 'topic_id', $topic_ids); - sync('topic', 'topic_id', $topic_ids, true); - sync('forum', 'forum_id', $forum_ids, true, true); - - /** - * Perform additional actions after move post sync - * - * @event core.move_posts_sync_after - * @var array post_ids Array of the moved post ids - * @var int topic_id The topic id the posts are moved to - * @var bool auto_sync Whether or not to perform auto sync - * @var array forum_ids Array of the forum ids the posts are moved from - * @var array topic_ids Array of the topic ids the posts are moved from - * @var array forum_row Array with the forum id of the topic the posts are moved to - * @since 3.1.11-RC1 - */ - $vars = array( - 'post_ids', - 'topic_id', - 'auto_sync', - 'forum_ids', - 'topic_ids', - 'forum_row', - ); - extract($phpbb_dispatcher->trigger_event('core.move_posts_sync_after', compact($vars))); - } - - // Update posted information - update_posted_info($topic_ids); -} - -/** -* Remove topic(s) -*/ -function delete_topics($where_type, $where_ids, $auto_sync = true, $post_count_sync = true, $call_delete_posts = true) -{ - global $db, $config, $phpbb_container, $phpbb_dispatcher; - - $approved_topics = 0; - $forum_ids = $topic_ids = array(); - - if ($where_type === 'range') - { - $where_clause = $where_ids; - } - else - { - $where_ids = (is_array($where_ids)) ? array_unique($where_ids) : array($where_ids); - - if (!count($where_ids)) - { - return array('topics' => 0, 'posts' => 0); - } - - $where_clause = $db->sql_in_set($where_type, $where_ids); - } - - // Making sure that delete_posts does not call delete_topics again... - $return = array( - 'posts' => ($call_delete_posts) ? delete_posts($where_type, $where_ids, false, true, $post_count_sync, false) : 0, - ); - - $sql = 'SELECT topic_id, forum_id, topic_visibility, topic_moved_id - FROM ' . TOPICS_TABLE . ' - WHERE ' . $where_clause; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $forum_ids[] = $row['forum_id']; - $topic_ids[] = $row['topic_id']; - - if ($row['topic_visibility'] == ITEM_APPROVED && !$row['topic_moved_id']) - { - $approved_topics++; - } - } - $db->sql_freeresult($result); - - $return['topics'] = count($topic_ids); - - if (!count($topic_ids)) - { - return $return; - } - - $db->sql_transaction('begin'); - - $table_ary = array(BOOKMARKS_TABLE, TOPICS_TRACK_TABLE, TOPICS_POSTED_TABLE, POLL_VOTES_TABLE, POLL_OPTIONS_TABLE, TOPICS_WATCH_TABLE, TOPICS_TABLE); - - /** - * Perform additional actions before topic(s) deletion - * - * @event core.delete_topics_before_query - * @var array table_ary Array of tables from which all rows will be deleted that hold a topic_id occuring in topic_ids - * @var array topic_ids Array of topic ids to delete - * @since 3.1.4-RC1 - */ - $vars = array( - 'table_ary', - 'topic_ids', - ); - extract($phpbb_dispatcher->trigger_event('core.delete_topics_before_query', compact($vars))); - - foreach ($table_ary as $table) - { - $sql = "DELETE FROM $table - WHERE " . $db->sql_in_set('topic_id', $topic_ids); - $db->sql_query($sql); - } - unset($table_ary); - - /** - * Perform additional actions after topic(s) deletion - * - * @event core.delete_topics_after_query - * @var array topic_ids Array of topic ids that were deleted - * @since 3.1.4-RC1 - */ - $vars = array( - 'topic_ids', - ); - extract($phpbb_dispatcher->trigger_event('core.delete_topics_after_query', compact($vars))); - - $moved_topic_ids = array(); - - // update the other forums - $sql = 'SELECT topic_id, forum_id - FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_moved_id', $topic_ids); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $forum_ids[] = $row['forum_id']; - $moved_topic_ids[] = $row['topic_id']; - } - $db->sql_freeresult($result); - - if (count($moved_topic_ids)) - { - $sql = 'DELETE FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', $moved_topic_ids); - $db->sql_query($sql); - } - - $db->sql_transaction('commit'); - - if ($auto_sync) - { - sync('forum', 'forum_id', array_unique($forum_ids), true, true); - sync('topic_reported', $where_type, $where_ids); - } - - if ($approved_topics) - { - $config->increment('num_topics', $approved_topics * (-1), false); - } - - /* @var $phpbb_notifications \phpbb\notification\manager */ - $phpbb_notifications = $phpbb_container->get('notification_manager'); - - $phpbb_notifications->delete_notifications(array( - 'notification.type.topic', - 'notification.type.approve_topic', - 'notification.type.topic_in_queue', - ), $topic_ids); - - return $return; -} - -/** -* Remove post(s) -*/ -function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync = true, $post_count_sync = true, $call_delete_topics = true) -{ - global $db, $config, $phpbb_root_path, $phpEx, $auth, $user, $phpbb_container, $phpbb_dispatcher; - - // Notifications types to delete - $delete_notifications_types = array( - 'notification.type.quote', - 'notification.type.approve_post', - 'notification.type.post_in_queue', - 'notification.type.report_post', - ); - - /** - * Perform additional actions before post(s) deletion - * - * @event core.delete_posts_before - * @var string where_type Variable containing posts deletion mode - * @var mixed where_ids Array or comma separated list of posts ids to delete - * @var bool auto_sync Flag indicating if topics/forums should be synchronized - * @var bool posted_sync Flag indicating if topics_posted table should be resynchronized - * @var bool post_count_sync Flag indicating if posts count should be resynchronized - * @var bool call_delete_topics Flag indicating if topics having no posts should be deleted - * @var array delete_notifications_types Array with notifications types to delete - * @since 3.1.0-a4 - */ - $vars = array( - 'where_type', - 'where_ids', - 'auto_sync', - 'posted_sync', - 'post_count_sync', - 'call_delete_topics', - 'delete_notifications_types', - ); - extract($phpbb_dispatcher->trigger_event('core.delete_posts_before', compact($vars))); - - if ($where_type === 'range') - { - $where_clause = $where_ids; - } - else - { - if (is_array($where_ids)) - { - $where_ids = array_unique($where_ids); - } - else - { - $where_ids = array($where_ids); - } - - if (!count($where_ids)) - { - return false; - } - - $where_ids = array_map('intval', $where_ids); - -/* Possible code for splitting post deletion - if (count($where_ids) >= 1001) - { - // Split into chunks of 1000 - $chunks = array_chunk($where_ids, 1000); - - foreach ($chunks as $_where_ids) - { - delete_posts($where_type, $_where_ids, $auto_sync, $posted_sync, $post_count_sync, $call_delete_topics); - } - - return; - }*/ - - $where_clause = $db->sql_in_set($where_type, $where_ids); - } - - $approved_posts = 0; - $post_ids = $topic_ids = $forum_ids = $post_counts = $remove_topics = array(); - - $sql = 'SELECT post_id, poster_id, post_visibility, post_postcount, topic_id, forum_id - FROM ' . POSTS_TABLE . ' - WHERE ' . $where_clause; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $post_ids[] = (int) $row['post_id']; - $poster_ids[] = (int) $row['poster_id']; - $topic_ids[] = (int) $row['topic_id']; - $forum_ids[] = (int) $row['forum_id']; - - if ($row['post_postcount'] && $post_count_sync && $row['post_visibility'] == ITEM_APPROVED) - { - $post_counts[$row['poster_id']] = (!empty($post_counts[$row['poster_id']])) ? $post_counts[$row['poster_id']] + 1 : 1; - } - - if ($row['post_visibility'] == ITEM_APPROVED) - { - $approved_posts++; - } - } - $db->sql_freeresult($result); - - if (!count($post_ids)) - { - return false; - } - - $db->sql_transaction('begin'); - - $table_ary = array(POSTS_TABLE, REPORTS_TABLE); - - /** - * Perform additional actions during post(s) deletion before running the queries - * - * @event core.delete_posts_in_transaction_before - * @var array post_ids Array with deleted posts' ids - * @var array poster_ids Array with deleted posts' author ids - * @var array topic_ids Array with deleted posts' topic ids - * @var array forum_ids Array with deleted posts' forum ids - * @var string where_type Variable containing posts deletion mode - * @var mixed where_ids Array or comma separated list of post ids to delete - * @var array delete_notifications_types Array with notifications types to delete - * @var array table_ary Array with table names to delete data from - * @since 3.1.7-RC1 - */ - $vars = array( - 'post_ids', - 'poster_ids', - 'topic_ids', - 'forum_ids', - 'where_type', - 'where_ids', - 'delete_notifications_types', - 'table_ary', - ); - extract($phpbb_dispatcher->trigger_event('core.delete_posts_in_transaction_before', compact($vars))); - - foreach ($table_ary as $table) - { - $sql = "DELETE FROM $table - WHERE " . $db->sql_in_set('post_id', $post_ids); - $db->sql_query($sql); - } - unset($table_ary); - - // Adjust users post counts - if (count($post_counts) && $post_count_sync) - { - foreach ($post_counts as $poster_id => $substract) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_posts = 0 - WHERE user_id = ' . $poster_id . ' - AND user_posts < ' . $substract; - $db->sql_query($sql); - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_posts = user_posts - ' . $substract . ' - WHERE user_id = ' . $poster_id . ' - AND user_posts >= ' . $substract; - $db->sql_query($sql); - } - } - - // Remove topics now having no posts? - if (count($topic_ids)) - { - $sql = 'SELECT topic_id - FROM ' . POSTS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', $topic_ids) . ' - GROUP BY topic_id'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $remove_topics[] = $row['topic_id']; - } - $db->sql_freeresult($result); - - // Actually, those not within remove_topics should be removed. ;) - $remove_topics = array_diff($topic_ids, $remove_topics); - } - - // Remove the message from the search index - $search_type = $config['search_type']; - - if (!class_exists($search_type)) - { - trigger_error('NO_SUCH_SEARCH_MODULE'); - } - - $error = false; - $search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher); - - if ($error) - { - trigger_error($error); - } - - $search->index_remove($post_ids, $poster_ids, $forum_ids); - - /** @var \phpbb\attachment\manager $attachment_manager */ - $attachment_manager = $phpbb_container->get('attachment.manager'); - $attachment_manager->delete('post', $post_ids, false); - unset($attachment_manager); - - /** - * Perform additional actions during post(s) deletion - * - * @event core.delete_posts_in_transaction - * @var array post_ids Array with deleted posts' ids - * @var array poster_ids Array with deleted posts' author ids - * @var array topic_ids Array with deleted posts' topic ids - * @var array forum_ids Array with deleted posts' forum ids - * @var string where_type Variable containing posts deletion mode - * @var mixed where_ids Array or comma separated list of posts ids to delete - * @var array delete_notifications_types Array with notifications types to delete - * @since 3.1.0-a4 - */ - $vars = array( - 'post_ids', - 'poster_ids', - 'topic_ids', - 'forum_ids', - 'where_type', - 'where_ids', - 'delete_notifications_types', - ); - extract($phpbb_dispatcher->trigger_event('core.delete_posts_in_transaction', compact($vars))); - - $db->sql_transaction('commit'); - - /** - * Perform additional actions after post(s) deletion - * - * @event core.delete_posts_after - * @var array post_ids Array with deleted posts' ids - * @var array poster_ids Array with deleted posts' author ids - * @var array topic_ids Array with deleted posts' topic ids - * @var array forum_ids Array with deleted posts' forum ids - * @var string where_type Variable containing posts deletion mode - * @var mixed where_ids Array or comma separated list of posts ids to delete - * @var array delete_notifications_types Array with notifications types to delete - * @since 3.1.0-a4 - */ - $vars = array( - 'post_ids', - 'poster_ids', - 'topic_ids', - 'forum_ids', - 'where_type', - 'where_ids', - 'delete_notifications_types', - ); - extract($phpbb_dispatcher->trigger_event('core.delete_posts_after', compact($vars))); - - // Resync topics_posted table - if ($posted_sync) - { - update_posted_info($topic_ids); - } - - if ($auto_sync) - { - sync('topic_reported', 'topic_id', $topic_ids); - sync('topic', 'topic_id', $topic_ids, true); - sync('forum', 'forum_id', $forum_ids, true, true); - } - - if ($approved_posts && $post_count_sync) - { - $config->increment('num_posts', $approved_posts * (-1), false); - } - - // We actually remove topics now to not be inconsistent (the delete_topics function calls this function too) - if (count($remove_topics) && $call_delete_topics) - { - delete_topics('topic_id', $remove_topics, $auto_sync, $post_count_sync, false); - } - - /* @var $phpbb_notifications \phpbb\notification\manager */ - $phpbb_notifications = $phpbb_container->get('notification_manager'); - - $phpbb_notifications->delete_notifications($delete_notifications_types, $post_ids); - - return count($post_ids); -} - -/** -* Deletes shadow topics pointing to a specified forum. -* -* @param int $forum_id The forum id -* @param string $sql_more Additional WHERE statement, e.g. t.topic_time < (time() - 1234) -* @param bool $auto_sync Will call sync() if this is true -* -* @return array Array with affected forums -*/ -function delete_topic_shadows($forum_id, $sql_more = '', $auto_sync = true) -{ - global $db; - - if (!$forum_id) - { - // Nothing to do. - return; - } - - // Set of affected forums we have to resync - $sync_forum_ids = array(); - - // Amount of topics we select and delete at once. - $batch_size = 500; - - do - { - $sql = 'SELECT t2.forum_id, t2.topic_id - FROM ' . TOPICS_TABLE . ' t2, ' . TOPICS_TABLE . ' t - WHERE t2.topic_moved_id = t.topic_id - AND t.forum_id = ' . (int) $forum_id . ' - ' . (($sql_more) ? 'AND ' . $sql_more : ''); - $result = $db->sql_query_limit($sql, $batch_size); - - $topic_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $topic_ids[] = (int) $row['topic_id']; - - $sync_forum_ids[(int) $row['forum_id']] = (int) $row['forum_id']; - } - $db->sql_freeresult($result); - - if (!empty($topic_ids)) - { - $sql = 'DELETE FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', $topic_ids); - $db->sql_query($sql); - } - } - while (count($topic_ids) == $batch_size); - - if ($auto_sync) - { - sync('forum', 'forum_id', $sync_forum_ids, true, true); - } - - return $sync_forum_ids; -} - -/** -* Update/Sync posted information for topics -*/ -function update_posted_info(&$topic_ids) -{ - global $db, $config; - - if (empty($topic_ids) || !$config['load_db_track']) - { - return; - } - - // First of all, let us remove any posted information for these topics - $sql = 'DELETE FROM ' . TOPICS_POSTED_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', $topic_ids); - $db->sql_query($sql); - - // Now, let us collect the user/topic combos for rebuilding the information - $sql = 'SELECT poster_id, topic_id - FROM ' . POSTS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', $topic_ids) . ' - AND poster_id <> ' . ANONYMOUS . ' - GROUP BY poster_id, topic_id'; - $result = $db->sql_query($sql); - - $posted = array(); - while ($row = $db->sql_fetchrow($result)) - { - // Add as key to make them unique (grouping by) and circumvent empty keys on array_unique - $posted[$row['poster_id']][] = $row['topic_id']; - } - $db->sql_freeresult($result); - - // Now add the information... - $sql_ary = array(); - foreach ($posted as $user_id => $topic_row) - { - foreach ($topic_row as $topic_id) - { - $sql_ary[] = array( - 'user_id' => (int) $user_id, - 'topic_id' => (int) $topic_id, - 'topic_posted' => 1, - ); - } - } - unset($posted); - - $db->sql_multi_insert(TOPICS_POSTED_TABLE, $sql_ary); -} - -/** -* All-encompasing sync function -* -* Exaples: -* -* sync('topic', 'topic_id', 123); // resync topic #123 -* sync('topic', 'forum_id', array(2, 3)); // resync topics from forum #2 and #3 -* sync('topic'); // resync all topics -* sync('topic', 'range', 'topic_id BETWEEN 1 AND 60'); // resync a range of topics/forums (only available for 'topic' and 'forum' modes) -* -* -* Modes: -* - forum Resync complete forum -* - topic Resync topics -* - topic_moved Removes topic shadows that would be in the same forum as the topic they link to -* - topic_visibility Resyncs the topic_visibility flag according to the status of the first post -* - post_reported Resyncs the post_reported flag, relying on actual reports -* - topic_reported Resyncs the topic_reported flag, relying on post_reported flags -* - post_attachement Same as post_reported, but with attachment flags -* - topic_attachement Same as topic_reported, but with attachment flags -*/ -function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $sync_extra = false) -{ - global $db; - - if (is_array($where_ids)) - { - $where_ids = array_unique($where_ids); - $where_ids = array_map('intval', $where_ids); - } - else if ($where_type != 'range') - { - $where_ids = ($where_ids) ? array((int) $where_ids) : array(); - } - - if ($mode == 'forum' || $mode == 'topic' || $mode == 'topic_visibility' || $mode == 'topic_reported' || $mode == 'post_reported') - { - if (!$where_type) - { - $where_sql = ''; - $where_sql_and = 'WHERE'; - } - else if ($where_type == 'range') - { - // Only check a range of topics/forums. For instance: 'topic_id BETWEEN 1 AND 60' - $where_sql = 'WHERE (' . $mode[0] . ".$where_ids)"; - $where_sql_and = $where_sql . "\n\tAND"; - } - else - { - // Do not sync the "global forum" - $where_ids = array_diff($where_ids, array(0)); - - if (!count($where_ids)) - { - // Empty array with IDs. This means that we don't have any work to do. Just return. - return; - } - - // Limit the topics/forums we are syncing, use specific topic/forum IDs. - // $where_type contains the field for the where clause (forum_id, topic_id) - $where_sql = 'WHERE ' . $db->sql_in_set($mode[0] . '.' . $where_type, $where_ids); - $where_sql_and = $where_sql . "\n\tAND"; - } - } - else - { - if (!count($where_ids)) - { - return; - } - - // $where_type contains the field for the where clause (forum_id, topic_id) - $where_sql = 'WHERE ' . $db->sql_in_set($mode[0] . '.' . $where_type, $where_ids); - $where_sql_and = $where_sql . "\n\tAND"; - } - - switch ($mode) - { - case 'topic_moved': - $db->sql_transaction('begin'); - switch ($db->get_sql_layer()) - { - case 'mysqli': - $sql = 'DELETE FROM ' . TOPICS_TABLE . ' - USING ' . TOPICS_TABLE . ' t1, ' . TOPICS_TABLE . " t2 - WHERE t1.topic_moved_id = t2.topic_id - AND t1.forum_id = t2.forum_id"; - $db->sql_query($sql); - break; - - default: - $sql = 'SELECT t1.topic_id - FROM ' .TOPICS_TABLE . ' t1, ' . TOPICS_TABLE . " t2 - WHERE t1.topic_moved_id = t2.topic_id - AND t1.forum_id = t2.forum_id"; - $result = $db->sql_query($sql); - - $topic_id_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - $topic_id_ary[] = $row['topic_id']; - } - $db->sql_freeresult($result); - - if (!count($topic_id_ary)) - { - return; - } - - $sql = 'DELETE FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', $topic_id_ary); - $db->sql_query($sql); - - break; - } - - $db->sql_transaction('commit'); - break; - - case 'topic_visibility': - - $db->sql_transaction('begin'); - - $sql = 'SELECT t.topic_id, p.post_visibility - FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p - $where_sql_and p.topic_id = t.topic_id - AND p.post_visibility = " . ITEM_APPROVED; - $result = $db->sql_query($sql); - - $topics_approved = array(); - while ($row = $db->sql_fetchrow($result)) - { - $topics_approved[] = (int) $row['topic_id']; - } - $db->sql_freeresult($result); - - $sql = 'SELECT t.topic_id, p.post_visibility - FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p - $where_sql_and " . $db->sql_in_set('t.topic_id', $topics_approved, true, true) . ' - AND p.topic_id = t.topic_id - AND p.post_visibility = ' . ITEM_DELETED; - $result = $db->sql_query($sql); - - $topics_softdeleted = array(); - while ($row = $db->sql_fetchrow($result)) - { - $topics_softdeleted[] = (int) $row['topic_id']; - } - $db->sql_freeresult($result); - - $topics_softdeleted = array_diff($topics_softdeleted, $topics_approved); - $topics_not_unapproved = array_merge($topics_softdeleted, $topics_approved); - - $update_ary = array( - ITEM_UNAPPROVED => (!empty($topics_not_unapproved)) ? $where_sql_and . ' ' . $db->sql_in_set('topic_id', $topics_not_unapproved, true) : '', - ITEM_APPROVED => (!empty($topics_approved)) ? ' WHERE ' . $db->sql_in_set('topic_id', $topics_approved) : '', - ITEM_DELETED => (!empty($topics_softdeleted)) ? ' WHERE ' . $db->sql_in_set('topic_id', $topics_softdeleted) : '', - ); - - foreach ($update_ary as $visibility => $sql_where) - { - if ($sql_where) - { - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_visibility = ' . $visibility . ' - ' . $sql_where; - $db->sql_query($sql); - } - } - - $db->sql_transaction('commit'); - break; - - case 'post_reported': - $post_ids = $post_reported = array(); - - $db->sql_transaction('begin'); - - $sql = 'SELECT p.post_id, p.post_reported - FROM ' . POSTS_TABLE . " p - $where_sql - GROUP BY p.post_id, p.post_reported"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $post_ids[$row['post_id']] = $row['post_id']; - if ($row['post_reported']) - { - $post_reported[$row['post_id']] = 1; - } - } - $db->sql_freeresult($result); - - $sql = 'SELECT DISTINCT(post_id) - FROM ' . REPORTS_TABLE . ' - WHERE ' . $db->sql_in_set('post_id', $post_ids) . ' - AND report_closed = 0'; - $result = $db->sql_query($sql); - - $post_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - if (!isset($post_reported[$row['post_id']])) - { - $post_ids[] = $row['post_id']; - } - else - { - unset($post_reported[$row['post_id']]); - } - } - $db->sql_freeresult($result); - - // $post_reported should be empty by now, if it's not it contains - // posts that are falsely flagged as reported - foreach ($post_reported as $post_id => $void) - { - $post_ids[] = $post_id; - } - - if (count($post_ids)) - { - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET post_reported = 1 - post_reported - WHERE ' . $db->sql_in_set('post_id', $post_ids); - $db->sql_query($sql); - } - - $db->sql_transaction('commit'); - break; - - case 'topic_reported': - if ($sync_extra) - { - sync('post_reported', $where_type, $where_ids); - } - - $topic_ids = $topic_reported = array(); - - $db->sql_transaction('begin'); - - $sql = 'SELECT DISTINCT(t.topic_id) - FROM ' . POSTS_TABLE . " t - $where_sql_and t.post_reported = 1"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $topic_reported[$row['topic_id']] = 1; - } - $db->sql_freeresult($result); - - $sql = 'SELECT t.topic_id, t.topic_reported - FROM ' . TOPICS_TABLE . " t - $where_sql"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if ($row['topic_reported'] ^ isset($topic_reported[$row['topic_id']])) - { - $topic_ids[] = $row['topic_id']; - } - } - $db->sql_freeresult($result); - - if (count($topic_ids)) - { - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_reported = 1 - topic_reported - WHERE ' . $db->sql_in_set('topic_id', $topic_ids); - $db->sql_query($sql); - } - - $db->sql_transaction('commit'); - break; - - case 'post_attachment': - $post_ids = $post_attachment = array(); - - $db->sql_transaction('begin'); - - $sql = 'SELECT p.post_id, p.post_attachment - FROM ' . POSTS_TABLE . " p - $where_sql - GROUP BY p.post_id, p.post_attachment"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $post_ids[$row['post_id']] = $row['post_id']; - if ($row['post_attachment']) - { - $post_attachment[$row['post_id']] = 1; - } - } - $db->sql_freeresult($result); - - $sql = 'SELECT DISTINCT(post_msg_id) - FROM ' . ATTACHMENTS_TABLE . ' - WHERE ' . $db->sql_in_set('post_msg_id', $post_ids) . ' - AND in_message = 0'; - $result = $db->sql_query($sql); - - $post_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - if (!isset($post_attachment[$row['post_msg_id']])) - { - $post_ids[] = $row['post_msg_id']; - } - else - { - unset($post_attachment[$row['post_msg_id']]); - } - } - $db->sql_freeresult($result); - - // $post_attachment should be empty by now, if it's not it contains - // posts that are falsely flagged as having attachments - foreach ($post_attachment as $post_id => $void) - { - $post_ids[] = $post_id; - } - - if (count($post_ids)) - { - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET post_attachment = 1 - post_attachment - WHERE ' . $db->sql_in_set('post_id', $post_ids); - $db->sql_query($sql); - } - - $db->sql_transaction('commit'); - break; - - case 'topic_attachment': - if ($sync_extra) - { - sync('post_attachment', $where_type, $where_ids); - } - - $topic_ids = $topic_attachment = array(); - - $db->sql_transaction('begin'); - - $sql = 'SELECT DISTINCT(t.topic_id) - FROM ' . POSTS_TABLE . " t - $where_sql_and t.post_attachment = 1"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $topic_attachment[$row['topic_id']] = 1; - } - $db->sql_freeresult($result); - - $sql = 'SELECT t.topic_id, t.topic_attachment - FROM ' . TOPICS_TABLE . " t - $where_sql"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if ($row['topic_attachment'] ^ isset($topic_attachment[$row['topic_id']])) - { - $topic_ids[] = $row['topic_id']; - } - } - $db->sql_freeresult($result); - - if (count($topic_ids)) - { - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_attachment = 1 - topic_attachment - WHERE ' . $db->sql_in_set('topic_id', $topic_ids); - $db->sql_query($sql); - } - - $db->sql_transaction('commit'); - - break; - - case 'forum': - - $db->sql_transaction('begin'); - - // 1: Get the list of all forums - $sql = 'SELECT f.* - FROM ' . FORUMS_TABLE . " f - $where_sql"; - $result = $db->sql_query($sql); - - $forum_data = $forum_ids = $post_ids = $last_post_id = $post_info = array(); - while ($row = $db->sql_fetchrow($result)) - { - if ($row['forum_type'] == FORUM_LINK) - { - continue; - } - - $forum_id = (int) $row['forum_id']; - $forum_ids[$forum_id] = $forum_id; - - $forum_data[$forum_id] = $row; - if ($sync_extra) - { - $forum_data[$forum_id]['posts_approved'] = 0; - $forum_data[$forum_id]['posts_unapproved'] = 0; - $forum_data[$forum_id]['posts_softdeleted'] = 0; - $forum_data[$forum_id]['topics_approved'] = 0; - $forum_data[$forum_id]['topics_unapproved'] = 0; - $forum_data[$forum_id]['topics_softdeleted'] = 0; - } - $forum_data[$forum_id]['last_post_id'] = 0; - $forum_data[$forum_id]['last_post_subject'] = ''; - $forum_data[$forum_id]['last_post_time'] = 0; - $forum_data[$forum_id]['last_poster_id'] = 0; - $forum_data[$forum_id]['last_poster_name'] = ''; - $forum_data[$forum_id]['last_poster_colour'] = ''; - } - $db->sql_freeresult($result); - - if (!count($forum_ids)) - { - break; - } - - $forum_ids = array_values($forum_ids); - - // 2: Get topic counts for each forum (optional) - if ($sync_extra) - { - $sql = 'SELECT forum_id, topic_visibility, COUNT(topic_id) AS total_topics - FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $forum_ids) . ' - GROUP BY forum_id, topic_visibility'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $forum_id = (int) $row['forum_id']; - - if ($row['topic_visibility'] == ITEM_APPROVED) - { - $forum_data[$forum_id]['topics_approved'] = $row['total_topics']; - } - else if ($row['topic_visibility'] == ITEM_UNAPPROVED || $row['topic_visibility'] == ITEM_REAPPROVE) - { - $forum_data[$forum_id]['topics_unapproved'] = $row['total_topics']; - } - else if ($row['topic_visibility'] == ITEM_DELETED) - { - $forum_data[$forum_id]['topics_softdeleted'] = $row['total_topics']; - } - } - $db->sql_freeresult($result); - } - - // 3: Get post count for each forum (optional) - if ($sync_extra) - { - if (count($forum_ids) == 1) - { - $sql = 'SELECT SUM(t.topic_posts_approved) AS forum_posts_approved, SUM(t.topic_posts_unapproved) AS forum_posts_unapproved, SUM(t.topic_posts_softdeleted) AS forum_posts_softdeleted - FROM ' . TOPICS_TABLE . ' t - WHERE ' . $db->sql_in_set('t.forum_id', $forum_ids) . ' - AND t.topic_status <> ' . ITEM_MOVED; - } - else - { - $sql = 'SELECT t.forum_id, SUM(t.topic_posts_approved) AS forum_posts_approved, SUM(t.topic_posts_unapproved) AS forum_posts_unapproved, SUM(t.topic_posts_softdeleted) AS forum_posts_softdeleted - FROM ' . TOPICS_TABLE . ' t - WHERE ' . $db->sql_in_set('t.forum_id', $forum_ids) . ' - AND t.topic_status <> ' . ITEM_MOVED . ' - GROUP BY t.forum_id'; - } - - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $forum_id = (count($forum_ids) == 1) ? (int) $forum_ids[0] : (int) $row['forum_id']; - - $forum_data[$forum_id]['posts_approved'] = (int) $row['forum_posts_approved']; - $forum_data[$forum_id]['posts_unapproved'] = (int) $row['forum_posts_unapproved']; - $forum_data[$forum_id]['posts_softdeleted'] = (int) $row['forum_posts_softdeleted']; - } - $db->sql_freeresult($result); - } - - // 4: Get last_post_id for each forum - if (count($forum_ids) == 1) - { - $sql = 'SELECT MAX(t.topic_last_post_id) as last_post_id - FROM ' . TOPICS_TABLE . ' t - WHERE ' . $db->sql_in_set('t.forum_id', $forum_ids) . ' - AND t.topic_visibility = ' . ITEM_APPROVED; - } - else - { - $sql = 'SELECT t.forum_id, MAX(t.topic_last_post_id) as last_post_id - FROM ' . TOPICS_TABLE . ' t - WHERE ' . $db->sql_in_set('t.forum_id', $forum_ids) . ' - AND t.topic_visibility = ' . ITEM_APPROVED . ' - GROUP BY t.forum_id'; - } - - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $forum_id = (count($forum_ids) == 1) ? (int) $forum_ids[0] : (int) $row['forum_id']; - - $forum_data[$forum_id]['last_post_id'] = (int) $row['last_post_id']; - - $post_ids[] = $row['last_post_id']; - } - $db->sql_freeresult($result); - - // 5: Retrieve last_post infos - if (count($post_ids)) - { - $sql = 'SELECT p.post_id, p.poster_id, p.post_subject, p.post_time, p.post_username, u.username, u.user_colour - FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u - WHERE ' . $db->sql_in_set('p.post_id', $post_ids) . ' - AND p.poster_id = u.user_id'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $post_info[$row['post_id']] = $row; - } - $db->sql_freeresult($result); - - foreach ($forum_data as $forum_id => $data) - { - if ($data['last_post_id']) - { - if (isset($post_info[$data['last_post_id']])) - { - $forum_data[$forum_id]['last_post_subject'] = $post_info[$data['last_post_id']]['post_subject']; - $forum_data[$forum_id]['last_post_time'] = $post_info[$data['last_post_id']]['post_time']; - $forum_data[$forum_id]['last_poster_id'] = $post_info[$data['last_post_id']]['poster_id']; - $forum_data[$forum_id]['last_poster_name'] = ($post_info[$data['last_post_id']]['poster_id'] != ANONYMOUS) ? $post_info[$data['last_post_id']]['username'] : $post_info[$data['last_post_id']]['post_username']; - $forum_data[$forum_id]['last_poster_colour'] = $post_info[$data['last_post_id']]['user_colour']; - } - else - { - // For some reason we did not find the post in the db - $forum_data[$forum_id]['last_post_id'] = 0; - $forum_data[$forum_id]['last_post_subject'] = ''; - $forum_data[$forum_id]['last_post_time'] = 0; - $forum_data[$forum_id]['last_poster_id'] = 0; - $forum_data[$forum_id]['last_poster_name'] = ''; - $forum_data[$forum_id]['last_poster_colour'] = ''; - } - } - } - unset($post_info); - } - - // 6: Now do that thing - $fieldnames = array('last_post_id', 'last_post_subject', 'last_post_time', 'last_poster_id', 'last_poster_name', 'last_poster_colour'); - - if ($sync_extra) - { - array_push($fieldnames, 'posts_approved', 'posts_unapproved', 'posts_softdeleted', 'topics_approved', 'topics_unapproved', 'topics_softdeleted'); - } - - foreach ($forum_data as $forum_id => $row) - { - $sql_ary = array(); - - foreach ($fieldnames as $fieldname) - { - if ($row['forum_' . $fieldname] != $row[$fieldname]) - { - if (preg_match('#(name|colour|subject)$#', $fieldname)) - { - $sql_ary['forum_' . $fieldname] = (string) $row[$fieldname]; - } - else - { - $sql_ary['forum_' . $fieldname] = (int) $row[$fieldname]; - } - } - } - - if (count($sql_ary)) - { - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE forum_id = ' . $forum_id; - $db->sql_query($sql); - } - } - - $db->sql_transaction('commit'); - break; - - case 'topic': - $topic_data = $post_ids = $resync_forums = $delete_topics = $delete_posts = $moved_topics = array(); - - $db->sql_transaction('begin'); - - $sql = 'SELECT t.topic_id, t.forum_id, t.topic_moved_id, t.topic_visibility, ' . (($sync_extra) ? 't.topic_attachment, t.topic_reported, ' : '') . 't.topic_poster, t.topic_time, t.topic_posts_approved, t.topic_posts_unapproved, t.topic_posts_softdeleted, t.topic_first_post_id, t.topic_first_poster_name, t.topic_first_poster_colour, t.topic_last_post_id, t.topic_last_post_subject, t.topic_last_poster_id, t.topic_last_poster_name, t.topic_last_poster_colour, t.topic_last_post_time - FROM ' . TOPICS_TABLE . " t - $where_sql"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if ($row['topic_moved_id']) - { - $moved_topics[] = $row['topic_id']; - continue; - } - - $topic_id = (int) $row['topic_id']; - $topic_data[$topic_id] = $row; - $topic_data[$topic_id]['visibility'] = ITEM_UNAPPROVED; - $topic_data[$topic_id]['posts_approved'] = 0; - $topic_data[$topic_id]['posts_unapproved'] = 0; - $topic_data[$topic_id]['posts_softdeleted'] = 0; - $topic_data[$topic_id]['first_post_id'] = 0; - $topic_data[$topic_id]['last_post_id'] = 0; - unset($topic_data[$topic_id]['topic_id']); - - // This array holds all topic_ids - $delete_topics[$topic_id] = ''; - - if ($sync_extra) - { - $topic_data[$topic_id]['reported'] = 0; - $topic_data[$topic_id]['attachment'] = 0; - } - } - $db->sql_freeresult($result); - - // Use "t" as table alias because of the $where_sql clause - // NOTE: 't.post_visibility' in the GROUP BY is causing a major slowdown. - $sql = 'SELECT t.topic_id, t.post_visibility, COUNT(t.post_id) AS total_posts, MIN(t.post_id) AS first_post_id, MAX(t.post_id) AS last_post_id - FROM ' . POSTS_TABLE . " t - $where_sql - GROUP BY t.topic_id, t.post_visibility"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $topic_id = (int) $row['topic_id']; - - $row['first_post_id'] = (int) $row['first_post_id']; - $row['last_post_id'] = (int) $row['last_post_id']; - - if (!isset($topic_data[$topic_id])) - { - // Hey, these posts come from a topic that does not exist - $delete_posts[$topic_id] = ''; - } - else - { - // Unset the corresponding entry in $delete_topics - // When we'll be done, only topics with no posts will remain - unset($delete_topics[$topic_id]); - - if ($row['post_visibility'] == ITEM_APPROVED) - { - $topic_data[$topic_id]['posts_approved'] = $row['total_posts']; - } - else if ($row['post_visibility'] == ITEM_UNAPPROVED || $row['post_visibility'] == ITEM_REAPPROVE) - { - $topic_data[$topic_id]['posts_unapproved'] = $row['total_posts']; - } - else if ($row['post_visibility'] == ITEM_DELETED) - { - $topic_data[$topic_id]['posts_softdeleted'] = $row['total_posts']; - } - - if ($row['post_visibility'] == ITEM_APPROVED) - { - $topic_data[$topic_id]['visibility'] = ITEM_APPROVED; - $topic_data[$topic_id]['first_post_id'] = $row['first_post_id']; - $topic_data[$topic_id]['last_post_id'] = $row['last_post_id']; - } - else if ($topic_data[$topic_id]['visibility'] != ITEM_APPROVED) - { - // If there is no approved post, we take the min/max of the other visibilities - // for the last and first post info, because it is only visible to moderators anyway - $topic_data[$topic_id]['first_post_id'] = (!empty($topic_data[$topic_id]['first_post_id'])) ? min($topic_data[$topic_id]['first_post_id'], $row['first_post_id']) : $row['first_post_id']; - $topic_data[$topic_id]['last_post_id'] = max($topic_data[$topic_id]['last_post_id'], $row['last_post_id']); - - if ($topic_data[$topic_id]['visibility'] == ITEM_UNAPPROVED || $topic_data[$topic_id]['visibility'] == ITEM_REAPPROVE) - { - // Soft delete status is stronger than unapproved. - $topic_data[$topic_id]['visibility'] = $row['post_visibility']; - } - } - } - } - $db->sql_freeresult($result); - - foreach ($topic_data as $topic_id => $row) - { - $post_ids[] = $row['first_post_id']; - if ($row['first_post_id'] != $row['last_post_id']) - { - $post_ids[] = $row['last_post_id']; - } - } - - // Now we delete empty topics and orphan posts - if (count($delete_posts)) - { - delete_posts('topic_id', array_keys($delete_posts), false); - unset($delete_posts); - } - - if (!count($topic_data)) - { - // If we get there, topic ids were invalid or topics did not contain any posts - delete_topics($where_type, $where_ids, true); - return; - } - - if (count($delete_topics)) - { - $delete_topic_ids = array(); - foreach ($delete_topics as $topic_id => $void) - { - unset($topic_data[$topic_id]); - $delete_topic_ids[] = $topic_id; - } - - delete_topics('topic_id', $delete_topic_ids, false); - unset($delete_topics, $delete_topic_ids); - } - - $sql = 'SELECT p.post_id, p.topic_id, p.post_visibility, p.poster_id, p.post_subject, p.post_username, p.post_time, u.username, u.user_colour - FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u - WHERE ' . $db->sql_in_set('p.post_id', $post_ids) . ' - AND u.user_id = p.poster_id'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $topic_id = intval($row['topic_id']); - - if ($row['post_id'] == $topic_data[$topic_id]['first_post_id']) - { - $topic_data[$topic_id]['time'] = $row['post_time']; - $topic_data[$topic_id]['poster'] = $row['poster_id']; - $topic_data[$topic_id]['first_poster_name'] = ($row['poster_id'] == ANONYMOUS) ? $row['post_username'] : $row['username']; - $topic_data[$topic_id]['first_poster_colour'] = $row['user_colour']; - } - - if ($row['post_id'] == $topic_data[$topic_id]['last_post_id']) - { - $topic_data[$topic_id]['last_poster_id'] = $row['poster_id']; - $topic_data[$topic_id]['last_post_subject'] = $row['post_subject']; - $topic_data[$topic_id]['last_post_time'] = $row['post_time']; - $topic_data[$topic_id]['last_poster_name'] = ($row['poster_id'] == ANONYMOUS) ? $row['post_username'] : $row['username']; - $topic_data[$topic_id]['last_poster_colour'] = $row['user_colour']; - } - } - $db->sql_freeresult($result); - - // Make sure shadow topics do link to existing topics - if (count($moved_topics)) - { - $delete_topics = array(); - - $sql = 'SELECT t1.topic_id, t1.topic_moved_id - FROM ' . TOPICS_TABLE . ' t1 - LEFT JOIN ' . TOPICS_TABLE . ' t2 ON (t2.topic_id = t1.topic_moved_id) - WHERE ' . $db->sql_in_set('t1.topic_id', $moved_topics) . ' - AND t2.topic_id IS NULL'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $delete_topics[] = $row['topic_id']; - } - $db->sql_freeresult($result); - - if (count($delete_topics)) - { - delete_topics('topic_id', $delete_topics, false); - } - unset($delete_topics); - - // Make sure shadow topics having no last post data being updated (this only rarely happens...) - $sql = 'SELECT topic_id, topic_moved_id, topic_last_post_id, topic_first_post_id - FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', $moved_topics) . ' - AND topic_last_post_time = 0'; - $result = $db->sql_query($sql); - - $shadow_topic_data = $post_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $shadow_topic_data[$row['topic_moved_id']] = $row; - $post_ids[] = $row['topic_last_post_id']; - $post_ids[] = $row['topic_first_post_id']; - } - $db->sql_freeresult($result); - - $sync_shadow_topics = array(); - if (count($post_ids)) - { - $sql = 'SELECT p.post_id, p.topic_id, p.post_visibility, p.poster_id, p.post_subject, p.post_username, p.post_time, u.username, u.user_colour - FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u - WHERE ' . $db->sql_in_set('p.post_id', $post_ids) . ' - AND u.user_id = p.poster_id'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $topic_id = (int) $row['topic_id']; - - // Ok, there should be a shadow topic. If there isn't, then there's something wrong with the db. - // However, there's not much we can do about it. - if (!empty($shadow_topic_data[$topic_id])) - { - if ($row['post_id'] == $shadow_topic_data[$topic_id]['topic_first_post_id']) - { - $orig_topic_id = $shadow_topic_data[$topic_id]['topic_id']; - - if (!isset($sync_shadow_topics[$orig_topic_id])) - { - $sync_shadow_topics[$orig_topic_id] = array(); - } - - $sync_shadow_topics[$orig_topic_id]['topic_time'] = $row['post_time']; - $sync_shadow_topics[$orig_topic_id]['topic_poster'] = $row['poster_id']; - $sync_shadow_topics[$orig_topic_id]['topic_first_poster_name'] = ($row['poster_id'] == ANONYMOUS) ? $row['post_username'] : $row['username']; - $sync_shadow_topics[$orig_topic_id]['topic_first_poster_colour'] = $row['user_colour']; - } - - if ($row['post_id'] == $shadow_topic_data[$topic_id]['topic_last_post_id']) - { - $orig_topic_id = $shadow_topic_data[$topic_id]['topic_id']; - - if (!isset($sync_shadow_topics[$orig_topic_id])) - { - $sync_shadow_topics[$orig_topic_id] = array(); - } - - $sync_shadow_topics[$orig_topic_id]['topic_last_poster_id'] = $row['poster_id']; - $sync_shadow_topics[$orig_topic_id]['topic_last_post_subject'] = $row['post_subject']; - $sync_shadow_topics[$orig_topic_id]['topic_last_post_time'] = $row['post_time']; - $sync_shadow_topics[$orig_topic_id]['topic_last_poster_name'] = ($row['poster_id'] == ANONYMOUS) ? $row['post_username'] : $row['username']; - $sync_shadow_topics[$orig_topic_id]['topic_last_poster_colour'] = $row['user_colour']; - } - } - } - $db->sql_freeresult($result); - - $shadow_topic_data = array(); - - // Update the information we collected - if (count($sync_shadow_topics)) - { - foreach ($sync_shadow_topics as $sync_topic_id => $sql_ary) - { - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE topic_id = ' . $sync_topic_id; - $db->sql_query($sql); - } - } - } - - unset($sync_shadow_topics, $shadow_topic_data); - } - - // These are fields that will be synchronised - $fieldnames = array('time', 'visibility', 'posts_approved', 'posts_unapproved', 'posts_softdeleted', 'poster', 'first_post_id', 'first_poster_name', 'first_poster_colour', 'last_post_id', 'last_post_subject', 'last_post_time', 'last_poster_id', 'last_poster_name', 'last_poster_colour'); - - if ($sync_extra) - { - // This routine assumes that post_reported values are correct - // if they are not, use sync('post_reported') first - $sql = 'SELECT t.topic_id, p.post_id - FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p - $where_sql_and p.topic_id = t.topic_id - AND p.post_reported = 1 - GROUP BY t.topic_id, p.post_id"; - $result = $db->sql_query($sql); - - $fieldnames[] = 'reported'; - while ($row = $db->sql_fetchrow($result)) - { - $topic_data[intval($row['topic_id'])]['reported'] = 1; - } - $db->sql_freeresult($result); - - // This routine assumes that post_attachment values are correct - // if they are not, use sync('post_attachment') first - $sql = 'SELECT t.topic_id, p.post_id - FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p - $where_sql_and p.topic_id = t.topic_id - AND p.post_attachment = 1 - GROUP BY t.topic_id, p.post_id"; - $result = $db->sql_query($sql); - - $fieldnames[] = 'attachment'; - while ($row = $db->sql_fetchrow($result)) - { - $topic_data[intval($row['topic_id'])]['attachment'] = 1; - } - $db->sql_freeresult($result); - } - - foreach ($topic_data as $topic_id => $row) - { - $sql_ary = array(); - - foreach ($fieldnames as $fieldname) - { - if (isset($row[$fieldname]) && isset($row['topic_' . $fieldname]) && $row['topic_' . $fieldname] != $row[$fieldname]) - { - $sql_ary['topic_' . $fieldname] = $row[$fieldname]; - } - } - - if (count($sql_ary)) - { - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE topic_id = ' . $topic_id; - $db->sql_query($sql); - - $resync_forums[$row['forum_id']] = $row['forum_id']; - } - } - unset($topic_data); - - $db->sql_transaction('commit'); - - // if some topics have been resync'ed then resync parent forums - // except when we're only syncing a range, we don't want to sync forums during - // batch processing. - if ($resync_parents && count($resync_forums) && $where_type != 'range') - { - sync('forum', 'forum_id', array_values($resync_forums), true, true); - } - break; - } - - return; -} - -/** -* Prune function -*/ -function prune($forum_id, $prune_mode, $prune_date, $prune_flags = 0, $auto_sync = true, $prune_limit = 0) -{ - global $db, $phpbb_dispatcher; - - if (!is_array($forum_id)) - { - $forum_id = array($forum_id); - } - - if (!count($forum_id)) - { - return; - } - - $sql_and = ''; - - if (!($prune_flags & FORUM_FLAG_PRUNE_ANNOUNCE)) - { - $sql_and .= ' AND topic_type <> ' . POST_ANNOUNCE; - $sql_and .= ' AND topic_type <> ' . POST_GLOBAL; - } - - if (!($prune_flags & FORUM_FLAG_PRUNE_STICKY)) - { - $sql_and .= ' AND topic_type <> ' . POST_STICKY; - } - - if ($prune_mode == 'posted') - { - $sql_and .= " AND topic_last_post_time < $prune_date"; - } - - if ($prune_mode == 'viewed') - { - $sql_and .= " AND topic_last_view_time < $prune_date"; - } - - if ($prune_mode == 'shadow') - { - $sql_and .= ' AND topic_status = ' . ITEM_MOVED . " AND topic_last_post_time < $prune_date"; - } - - /** - * Use this event to modify the SQL that selects topics to be pruned - * - * @event core.prune_sql - * @var string forum_id The forum id - * @var string prune_mode The prune mode - * @var string prune_date The prune date - * @var int prune_flags The prune flags - * @var bool auto_sync Whether or not to perform auto sync - * @var string sql_and SQL text appended to where clause - * @var int prune_limit The prune limit - * @since 3.1.3-RC1 - * @changed 3.1.10-RC1 Added prune_limit - */ - $vars = array( - 'forum_id', - 'prune_mode', - 'prune_date', - 'prune_flags', - 'auto_sync', - 'sql_and', - 'prune_limit', - ); - extract($phpbb_dispatcher->trigger_event('core.prune_sql', compact($vars))); - - $sql = 'SELECT topic_id - FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $forum_id) . " - AND poll_start = 0 - $sql_and"; - $result = $db->sql_query_limit($sql, $prune_limit); - - $topic_list = array(); - while ($row = $db->sql_fetchrow($result)) - { - $topic_list[] = $row['topic_id']; - } - $db->sql_freeresult($result); - - if ($prune_flags & FORUM_FLAG_PRUNE_POLL) - { - $sql = 'SELECT topic_id - FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $forum_id) . " - AND poll_start > 0 - AND poll_last_vote < $prune_date - $sql_and"; - $result = $db->sql_query_limit($sql, $prune_limit); - - while ($row = $db->sql_fetchrow($result)) - { - $topic_list[] = $row['topic_id']; - } - $db->sql_freeresult($result); - - $topic_list = array_unique($topic_list); - } - - /** - * Perform additional actions before topic deletion via pruning - * - * @event core.prune_delete_before - * @var int[] topic_list The IDs of the topics to be deleted - * @since 3.2.2-RC1 - */ - $vars = array('topic_list'); - extract($phpbb_dispatcher->trigger_event('core.prune_delete_before', compact($vars))); - - return delete_topics('topic_id', $topic_list, $auto_sync, false); -} - -/** -* Function auto_prune(), this function now relies on passed vars -*/ -function auto_prune($forum_id, $prune_mode, $prune_flags, $prune_days, $prune_freq) -{ - global $db, $user, $phpbb_log; - - $sql = 'SELECT forum_name - FROM ' . FORUMS_TABLE . " - WHERE forum_id = $forum_id"; - $result = $db->sql_query($sql, 3600); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - $prune_date = time() - ($prune_days * 86400); - $next_prune = time() + ($prune_freq * 86400); - - $result = prune($forum_id, $prune_mode, $prune_date, $prune_flags, true, 300); - - if ($result['topics'] == 0 && $result['posts'] == 0) - { - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET prune_next = $next_prune - WHERE forum_id = $forum_id"; - $db->sql_query($sql); - } - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_AUTO_PRUNE', false, array($row['forum_name'])); - } - - return; -} - -/** -* Cache moderators. Called whenever permissions are changed -* via admin_permissions. Changes of usernames and group names -* must be carried through for the moderators table. -* -* @param \phpbb\db\driver\driver_interface $db Database connection -* @param \phpbb\cache\driver\driver_interface Cache driver -* @param \phpbb\auth\auth $auth Authentication object -* @return null -*/ -function phpbb_cache_moderators($db, $cache, $auth) -{ - // Remove cached sql results - $cache->destroy('sql', MODERATOR_CACHE_TABLE); - - // Clear table - switch ($db->get_sql_layer()) - { - case 'sqlite3': - $db->sql_query('DELETE FROM ' . MODERATOR_CACHE_TABLE); - break; - - default: - $db->sql_query('TRUNCATE TABLE ' . MODERATOR_CACHE_TABLE); - break; - } - - // We add moderators who have forum moderator permissions without an explicit ACL_NEVER setting - $sql_ary = array(); - - // Grab all users having moderative options... - $hold_ary = $auth->acl_user_raw_data(false, 'm_%', false); - - // Add users? - if (!empty($hold_ary)) - { - // At least one moderative option warrants a display - $ug_id_ary = array_keys($hold_ary); - - // Remove users who have group memberships with DENY moderator permissions - $sql_ary_deny = array( - 'SELECT' => 'a.forum_id, ug.user_id, g.group_id', - - 'FROM' => array( - ACL_OPTIONS_TABLE => 'o', - USER_GROUP_TABLE => 'ug', - GROUPS_TABLE => 'g', - ACL_GROUPS_TABLE => 'a', - ), - - 'LEFT_JOIN' => array( - array( - 'FROM' => array(ACL_ROLES_DATA_TABLE => 'r'), - 'ON' => 'a.auth_role_id = r.role_id', - ), - ), - - 'WHERE' => '(o.auth_option_id = a.auth_option_id OR o.auth_option_id = r.auth_option_id) - AND ((a.auth_setting = ' . ACL_NEVER . ' AND r.auth_setting IS NULL) - OR r.auth_setting = ' . ACL_NEVER . ') - AND a.group_id = ug.group_id - AND g.group_id = ug.group_id - AND NOT (ug.group_leader = 1 AND g.group_skip_auth = 1) - AND ' . $db->sql_in_set('ug.user_id', $ug_id_ary) . " - AND ug.user_pending = 0 - AND o.auth_option " . $db->sql_like_expression('m_' . $db->get_any_char()), - ); - $sql = $db->sql_build_query('SELECT', $sql_ary_deny); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if (isset($hold_ary[$row['user_id']][$row['forum_id']])) - { - unset($hold_ary[$row['user_id']][$row['forum_id']]); - } - } - $db->sql_freeresult($result); - - if (count($hold_ary)) - { - // Get usernames... - $sql = 'SELECT user_id, username - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('user_id', array_keys($hold_ary)); - $result = $db->sql_query($sql); - - $usernames_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - $usernames_ary[$row['user_id']] = $row['username']; - } - $db->sql_freeresult($result); - - foreach ($hold_ary as $user_id => $forum_id_ary) - { - // Do not continue if user does not exist - if (!isset($usernames_ary[$user_id])) - { - continue; - } - - foreach ($forum_id_ary as $forum_id => $auth_ary) - { - $sql_ary[] = array( - 'forum_id' => (int) $forum_id, - 'user_id' => (int) $user_id, - 'username' => (string) $usernames_ary[$user_id], - 'group_id' => 0, - 'group_name' => '' - ); - } - } - } - } - - // Now to the groups... - $hold_ary = $auth->acl_group_raw_data(false, 'm_%', false); - - if (!empty($hold_ary)) - { - $ug_id_ary = array_keys($hold_ary); - - // Make sure not hidden or special groups are involved... - $sql = 'SELECT group_name, group_id, group_type - FROM ' . GROUPS_TABLE . ' - WHERE ' . $db->sql_in_set('group_id', $ug_id_ary); - $result = $db->sql_query($sql); - - $groupnames_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - if ($row['group_type'] == GROUP_HIDDEN || $row['group_type'] == GROUP_SPECIAL) - { - unset($hold_ary[$row['group_id']]); - } - - $groupnames_ary[$row['group_id']] = $row['group_name']; - } - $db->sql_freeresult($result); - - foreach ($hold_ary as $group_id => $forum_id_ary) - { - // If there is no group, we do not assign it... - if (!isset($groupnames_ary[$group_id])) - { - continue; - } - - foreach ($forum_id_ary as $forum_id => $auth_ary) - { - $flag = false; - foreach ($auth_ary as $auth_option => $setting) - { - // Make sure at least one ACL_YES option is set... - if ($setting == ACL_YES) - { - $flag = true; - break; - } - } - - if (!$flag) - { - continue; - } - - $sql_ary[] = array( - 'forum_id' => (int) $forum_id, - 'user_id' => 0, - 'username' => '', - 'group_id' => (int) $group_id, - 'group_name' => (string) $groupnames_ary[$group_id] - ); - } - } - } - - $db->sql_multi_insert(MODERATOR_CACHE_TABLE, $sql_ary); -} - -/** -* View log -* -* @param string $mode The mode defines which log_type is used and from which log the entry is retrieved -* @param array &$log The result array with the logs -* @param mixed &$log_count If $log_count is set to false, we will skip counting all entries in the database. -* Otherwise an integer with the number of total matching entries is returned. -* @param int $limit Limit the number of entries that are returned -* @param int $offset Offset when fetching the log entries, f.e. when paginating -* @param mixed $forum_id Restrict the log entries to the given forum_id (can also be an array of forum_ids) -* @param int $topic_id Restrict the log entries to the given topic_id -* @param int $user_id Restrict the log entries to the given user_id -* @param int $log_time Only get log entries newer than the given timestamp -* @param string $sort_by SQL order option, e.g. 'l.log_time DESC' -* @param string $keywords Will only return log entries that have the keywords in log_operation or log_data -* -* @return int Returns the offset of the last valid page, if the specified offset was invalid (too high) -*/ -function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $limit_days = 0, $sort_by = 'l.log_time DESC', $keywords = '') -{ - global $phpbb_log; - - $count_logs = ($log_count !== false); - - $log = $phpbb_log->get_logs($mode, $count_logs, $limit, $offset, $forum_id, $topic_id, $user_id, $limit_days, $sort_by, $keywords); - $log_count = $phpbb_log->get_log_count(); - - return $phpbb_log->get_valid_offset(); -} - -/** -* Removes moderators and administrators from foe lists. -* -* @param \phpbb\db\driver\driver_interface $db Database connection -* @param \phpbb\auth\auth $auth Authentication object -* @param array|bool $group_id If an array, remove all members of this group from foe lists, or false to ignore -* @param array|bool $user_id If an array, remove this user from foe lists, or false to ignore -* @return null -*/ -function phpbb_update_foes($db, $auth, $group_id = false, $user_id = false) -{ - // update foes for some user - if (is_array($user_id) && count($user_id)) - { - $sql = 'DELETE FROM ' . ZEBRA_TABLE . ' - WHERE ' . $db->sql_in_set('zebra_id', $user_id) . ' - AND foe = 1'; - $db->sql_query($sql); - return; - } - - // update foes for some group - if (is_array($group_id) && count($group_id)) - { - // Grab group settings... - $sql_ary = array( - 'SELECT' => 'a.group_id', - - 'FROM' => array( - ACL_OPTIONS_TABLE => 'ao', - ACL_GROUPS_TABLE => 'a', - ), - - 'LEFT_JOIN' => array( - array( - 'FROM' => array(ACL_ROLES_DATA_TABLE => 'r'), - 'ON' => 'a.auth_role_id = r.role_id', - ), - ), - - 'WHERE' => '(ao.auth_option_id = a.auth_option_id OR ao.auth_option_id = r.auth_option_id) - AND ' . $db->sql_in_set('a.group_id', $group_id) . " - AND ao.auth_option IN ('a_', 'm_')", - - 'GROUP_BY' => 'a.group_id', - ); - $sql = $db->sql_build_query('SELECT', $sql_ary); - $result = $db->sql_query($sql); - - $groups = array(); - while ($row = $db->sql_fetchrow($result)) - { - $groups[] = (int) $row['group_id']; - } - $db->sql_freeresult($result); - - if (!count($groups)) - { - return; - } - - switch ($db->get_sql_layer()) - { - case 'mysqli': - $sql = 'DELETE z.* - FROM ' . ZEBRA_TABLE . ' z, ' . USER_GROUP_TABLE . ' ug - WHERE z.zebra_id = ug.user_id - AND z.foe = 1 - AND ' . $db->sql_in_set('ug.group_id', $groups); - $db->sql_query($sql); - break; - - default: - $sql = 'SELECT user_id - FROM ' . USER_GROUP_TABLE . ' - WHERE ' . $db->sql_in_set('group_id', $groups); - $result = $db->sql_query($sql); - - $users = array(); - while ($row = $db->sql_fetchrow($result)) - { - $users[] = (int) $row['user_id']; - } - $db->sql_freeresult($result); - - if (count($users)) - { - $sql = 'DELETE FROM ' . ZEBRA_TABLE . ' - WHERE ' . $db->sql_in_set('zebra_id', $users) . ' - AND foe = 1'; - $db->sql_query($sql); - } - break; - } - - return; - } - - // update foes for everyone - $perms = array(); - foreach ($auth->acl_get_list(false, array('a_', 'm_'), false) as $forum_id => $forum_ary) - { - foreach ($forum_ary as $auth_option => $user_ary) - { - $perms = array_merge($perms, $user_ary); - } - } - - if (count($perms)) - { - $sql = 'DELETE FROM ' . ZEBRA_TABLE . ' - WHERE ' . $db->sql_in_set('zebra_id', array_unique($perms)) . ' - AND foe = 1'; - $db->sql_query($sql); - } - unset($perms); -} - -/** -* Lists inactive users -*/ -function view_inactive_users(&$users, &$user_count, $limit = 0, $offset = 0, $limit_days = 0, $sort_by = 'user_inactive_time DESC') -{ - global $db, $user; - - $sql = 'SELECT COUNT(user_id) AS user_count - FROM ' . USERS_TABLE . ' - WHERE user_type = ' . USER_INACTIVE . - (($limit_days) ? " AND user_inactive_time >= $limit_days" : ''); - $result = $db->sql_query($sql); - $user_count = (int) $db->sql_fetchfield('user_count'); - $db->sql_freeresult($result); - - if ($user_count == 0) - { - // Save the queries, because there are no users to display - return 0; - } - - if ($offset >= $user_count) - { - $offset = ($offset - $limit < 0) ? 0 : $offset - $limit; - } - - $sql = 'SELECT * - FROM ' . USERS_TABLE . ' - WHERE user_type = ' . USER_INACTIVE . - (($limit_days) ? " AND user_inactive_time >= $limit_days" : '') . " - ORDER BY $sort_by"; - $result = $db->sql_query_limit($sql, $limit, $offset); - - while ($row = $db->sql_fetchrow($result)) - { - $row['inactive_reason'] = $user->lang['INACTIVE_REASON_UNKNOWN']; - switch ($row['user_inactive_reason']) - { - case INACTIVE_REGISTER: - $row['inactive_reason'] = $user->lang['INACTIVE_REASON_REGISTER']; - break; - - case INACTIVE_PROFILE: - $row['inactive_reason'] = $user->lang['INACTIVE_REASON_PROFILE']; - break; - - case INACTIVE_MANUAL: - $row['inactive_reason'] = $user->lang['INACTIVE_REASON_MANUAL']; - break; - - case INACTIVE_REMIND: - $row['inactive_reason'] = $user->lang['INACTIVE_REASON_REMIND']; - break; - } - - $users[] = $row; - } - $db->sql_freeresult($result); - - return $offset; -} - -/** -* Lists warned users -*/ -function view_warned_users(&$users, &$user_count, $limit = 0, $offset = 0, $limit_days = 0, $sort_by = 'user_warnings DESC') -{ - global $db; - - $sql = 'SELECT user_id, username, user_colour, user_warnings, user_last_warning - FROM ' . USERS_TABLE . ' - WHERE user_warnings > 0 - ' . (($limit_days) ? "AND user_last_warning >= $limit_days" : '') . " - ORDER BY $sort_by"; - $result = $db->sql_query_limit($sql, $limit, $offset); - $users = $db->sql_fetchrowset($result); - $db->sql_freeresult($result); - - $sql = 'SELECT count(user_id) AS user_count - FROM ' . USERS_TABLE . ' - WHERE user_warnings > 0 - ' . (($limit_days) ? "AND user_last_warning >= $limit_days" : ''); - $result = $db->sql_query($sql); - $user_count = (int) $db->sql_fetchfield('user_count'); - $db->sql_freeresult($result); - - return; -} - -/** -* Get database size -* Currently only mysql and mssql are supported -*/ -function get_database_size() -{ - global $db, $user, $table_prefix; - - $database_size = false; - - // This code is heavily influenced by a similar routine in phpMyAdmin 2.2.0 - switch ($db->get_sql_layer()) - { - case 'mysqli': - $sql = 'SELECT VERSION() AS mysql_version'; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - $version = $row['mysql_version']; - - if (preg_match('#(3\.23|[45]\.|10\.[0-9]\.[0-9]{1,2}-+Maria)#', $version)) - { - $db_name = (preg_match('#^(?:3\.23\.(?:[6-9]|[1-9]{2}))|[45]\.|10\.[0-9]\.[0-9]{1,2}-+Maria#', $version)) ? "`{$db->get_db_name()}`" : $db->get_db_name(); - - $sql = 'SHOW TABLE STATUS - FROM ' . $db_name; - $result = $db->sql_query($sql, 7200); - - $database_size = 0; - while ($row = $db->sql_fetchrow($result)) - { - if ((isset($row['Type']) && $row['Type'] != 'MRG_MyISAM') || (isset($row['Engine']) && ($row['Engine'] == 'MyISAM' || $row['Engine'] == 'InnoDB' || $row['Engine'] == 'Aria'))) - { - if ($table_prefix != '') - { - if (strpos($row['Name'], $table_prefix) !== false) - { - $database_size += $row['Data_length'] + $row['Index_length']; - } - } - else - { - $database_size += $row['Data_length'] + $row['Index_length']; - } - } - } - $db->sql_freeresult($result); - } - } - break; - - case 'sqlite3': - global $dbhost; - - if (file_exists($dbhost)) - { - $database_size = filesize($dbhost); - } - - break; - - case 'mssql_odbc': - case 'mssqlnative': - $sql = 'SELECT @@VERSION AS mssql_version'; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $sql = 'SELECT ((SUM(size) * 8.0) * 1024.0) as dbsize - FROM sysfiles'; - - if ($row) - { - // Azure stats are stored elsewhere - if (strpos($row['mssql_version'], 'SQL Azure') !== false) - { - $sql = 'SELECT ((SUM(reserved_page_count) * 8.0) * 1024.0) as dbsize - FROM sys.dm_db_partition_stats'; - } - } - - $result = $db->sql_query($sql, 7200); - $database_size = ($row = $db->sql_fetchrow($result)) ? $row['dbsize'] : false; - $db->sql_freeresult($result); - break; - - case 'postgres': - $sql = "SELECT proname - FROM pg_proc - WHERE proname = 'pg_database_size'"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row['proname'] == 'pg_database_size') - { - $database = $db->get_db_name(); - if (strpos($database, '.') !== false) - { - list($database, ) = explode('.', $database); - } - - $sql = "SELECT oid - FROM pg_database - WHERE datname = '$database'"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $oid = $row['oid']; - - $sql = 'SELECT pg_database_size(' . $oid . ') as size'; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $database_size = $row['size']; - } - break; - - case 'oracle': - $sql = 'SELECT SUM(bytes) as dbsize - FROM user_segments'; - $result = $db->sql_query($sql, 7200); - $database_size = ($row = $db->sql_fetchrow($result)) ? $row['dbsize'] : false; - $db->sql_freeresult($result); - break; - } - - $database_size = ($database_size !== false) ? get_formatted_filesize($database_size) : $user->lang['NOT_AVAILABLE']; - - return $database_size; -} - -/* -* Tidy Warnings -* Remove all warnings which have now expired from the database -* The duration of a warning can be defined by the administrator -* This only removes the warning and reduces the associated count, -* it does not remove the user note recording the contents of the warning -*/ -function tidy_warnings() -{ - global $db, $config; - - $expire_date = time() - ($config['warnings_expire_days'] * 86400); - $warning_list = $user_list = array(); - - $sql = 'SELECT * FROM ' . WARNINGS_TABLE . " - WHERE warning_time < $expire_date"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $warning_list[] = $row['warning_id']; - $user_list[$row['user_id']] = isset($user_list[$row['user_id']]) ? ++$user_list[$row['user_id']] : 1; - } - $db->sql_freeresult($result); - - if (count($warning_list)) - { - $db->sql_transaction('begin'); - - $sql = 'DELETE FROM ' . WARNINGS_TABLE . ' - WHERE ' . $db->sql_in_set('warning_id', $warning_list); - $db->sql_query($sql); - - foreach ($user_list as $user_id => $value) - { - $sql = 'UPDATE ' . USERS_TABLE . " SET user_warnings = user_warnings - $value - WHERE user_id = $user_id"; - $db->sql_query($sql); - } - - $db->sql_transaction('commit'); - } - - $config->set('warnings_last_gc', time(), false); -} - -/** -* Tidy database, doing some maintanance tasks -*/ -function tidy_database() -{ - global $config, $db; - - // Here we check permission consistency - - // Sometimes, it can happen permission tables having forums listed which do not exist - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE; - $result = $db->sql_query($sql); - - $forum_ids = array(0); - while ($row = $db->sql_fetchrow($result)) - { - $forum_ids[] = $row['forum_id']; - } - $db->sql_freeresult($result); - - $db->sql_transaction('begin'); - - // Delete those rows from the acl tables not having listed the forums above - $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $forum_ids, true); - $db->sql_query($sql); - - $sql = 'DELETE FROM ' . ACL_USERS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $forum_ids, true); - $db->sql_query($sql); - - $db->sql_transaction('commit'); - - $config->set('database_last_gc', time(), false); -} - -/** -* Add permission language - this will make sure custom files will be included -*/ -function add_permission_language() -{ - global $user, $phpEx, $phpbb_extension_manager; - - // add permission language files from extensions - $finder = $phpbb_extension_manager->get_finder(); - - $lang_files = $finder - ->prefix('permissions_') - ->suffix(".$phpEx") - ->core_path('language/') - ->extension_directory('/language') - ->find(); - - foreach ($lang_files as $lang_file => $ext_name) - { - if ($ext_name === '/') - { - $user->add_lang($lang_file); - } - else - { - $user->add_lang_ext($ext_name, $lang_file); - } - } -} - -/** - * Enables a particular flag in a bitfield column of a given table. - * - * @param string $table_name The table to update - * @param string $column_name The column containing a bitfield to update - * @param int $flag The binary flag which is OR-ed with the current column value - * @param string $sql_more This string is attached to the sql query generated to update the table. - * - * @return null - */ -function enable_bitfield_column_flag($table_name, $column_name, $flag, $sql_more = '') -{ - global $db; - - $sql = 'UPDATE ' . $table_name . ' - SET ' . $column_name . ' = ' . $db->sql_bit_or($column_name, $flag) . ' - ' . $sql_more; - $db->sql_query($sql); -} diff --git a/install/update/new/includes/functions_compatibility.php b/install/update/new/includes/functions_compatibility.php deleted file mode 100644 index 92e24c0..0000000 --- a/install/update/new/includes/functions_compatibility.php +++ /dev/null @@ -1,675 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* Get user avatar -* -* @deprecated 3.1.0-a1 (To be removed: 4.0.0) -* -* @param string $avatar Users assigned avatar name -* @param int $avatar_type Type of avatar -* @param string $avatar_width Width of users avatar -* @param string $avatar_height Height of users avatar -* @param string $alt Optional language string for alt tag within image, can be a language key or text -* @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP -* @param bool $lazy If true, will be lazy loaded (requires JS) -* -* @return string Avatar image -*/ -function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $alt = 'USER_AVATAR', $ignore_config = false, $lazy = false) -{ - // map arguments to new function phpbb_get_avatar() - $row = array( - 'avatar' => $avatar, - 'avatar_type' => $avatar_type, - 'avatar_width' => $avatar_width, - 'avatar_height' => $avatar_height, - ); - - return phpbb_get_avatar($row, $alt, $ignore_config, $lazy); -} - -/** -* Hash the password -* -* @deprecated 3.1.0-a2 (To be removed: 4.0.0) -* -* @param string $password Password to be hashed -* -* @return string|bool Password hash or false if something went wrong during hashing -*/ -function phpbb_hash($password) -{ - global $phpbb_container; - - /* @var $passwords_manager \phpbb\passwords\manager */ - $passwords_manager = $phpbb_container->get('passwords.manager'); - return $passwords_manager->hash($password); -} - -/** -* Check for correct password -* -* @deprecated 3.1.0-a2 (To be removed: 4.0.0) -* -* @param string $password The password in plain text -* @param string $hash The stored password hash -* -* @return bool Returns true if the password is correct, false if not. -*/ -function phpbb_check_hash($password, $hash) -{ - global $phpbb_container; - - /* @var $passwords_manager \phpbb\passwords\manager */ - $passwords_manager = $phpbb_container->get('passwords.manager'); - return $passwords_manager->check($password, $hash); -} - -/** -* Eliminates useless . and .. components from specified path. -* -* Deprecated, use filesystem class instead -* -* @param string $path Path to clean -* @return string Cleaned path -* -* @deprecated 3.1.0 (To be removed: 4.0.0) -*/ -function phpbb_clean_path($path) -{ - global $phpbb_path_helper, $phpbb_container; - - if (!$phpbb_path_helper && $phpbb_container) - { - /* @var $phpbb_path_helper \phpbb\path_helper */ - $phpbb_path_helper = $phpbb_container->get('path_helper'); - } - else if (!$phpbb_path_helper) - { - global $phpbb_root_path, $phpEx; - - // The container is not yet loaded, use a new instance - if (!class_exists('\phpbb\path_helper')) - { - require($phpbb_root_path . 'phpbb/path_helper.' . $phpEx); - } - - $request = new phpbb\request\request(); - $phpbb_path_helper = new phpbb\path_helper( - new phpbb\symfony_request( - $request - ), - new phpbb\filesystem\filesystem(), - $request, - $phpbb_root_path, - $phpEx - ); - } - - return $phpbb_path_helper->clean_path($path); -} - -/** -* Pick a timezone -* -* @param string $default A timezone to select -* @param boolean $truncate Shall we truncate the options text -* -* @return string Returns the options for timezone selector only -* -* @deprecated 3.1.0 (To be removed: 4.0.0) -*/ -function tz_select($default = '', $truncate = false) -{ - global $template, $user; - - return phpbb_timezone_select($template, $user, $default, $truncate); -} - -/** -* Cache moderators. Called whenever permissions are changed -* via admin_permissions. Changes of usernames and group names -* must be carried through for the moderators table. -* -* @deprecated 3.1.0 (To be removed: 4.0.0) -* @return null -*/ -function cache_moderators() -{ - global $db, $cache, $auth; - return phpbb_cache_moderators($db, $cache, $auth); -} - -/** -* Removes moderators and administrators from foe lists. -* -* @deprecated 3.1.0 (To be removed: 4.0.0) -* @param array|bool $group_id If an array, remove all members of this group from foe lists, or false to ignore -* @param array|bool $user_id If an array, remove this user from foe lists, or false to ignore -* @return null -*/ -function update_foes($group_id = false, $user_id = false) -{ - global $db, $auth; - return phpbb_update_foes($db, $auth, $group_id, $user_id); -} - -/** -* Get user rank title and image -* -* @param int $user_rank the current stored users rank id -* @param int $user_posts the users number of posts -* @param string &$rank_title the rank title will be stored here after execution -* @param string &$rank_img the rank image as full img tag is stored here after execution -* @param string &$rank_img_src the rank image source is stored here after execution -* -* @deprecated 3.1.0-RC5 (To be removed: 4.0.0) -* -* Note: since we do not want to break backwards-compatibility, this function will only properly assign ranks to guests if you call it for them with user_posts == false -*/ -function get_user_rank($user_rank, $user_posts, &$rank_title, &$rank_img, &$rank_img_src) -{ - global $phpbb_root_path, $phpEx; - if (!function_exists('phpbb_get_user_rank')) - { - include($phpbb_root_path . 'includes/functions_display.' . $phpEx); - } - - $rank_data = phpbb_get_user_rank(array('user_rank' => $user_rank), $user_posts); - $rank_title = $rank_data['title']; - $rank_img = $rank_data['img']; - $rank_img_src = $rank_data['img_src']; -} - -/** - * Retrieve contents from remotely stored file - * - * @deprecated 3.1.2 Use file_downloader instead - */ -function get_remote_file($host, $directory, $filename, &$errstr, &$errno, $port = 80, $timeout = 6) -{ - global $phpbb_container; - - // Get file downloader and assign $errstr and $errno - /* @var $file_downloader \phpbb\file_downloader */ - $file_downloader = $phpbb_container->get('file_downloader'); - - $file_data = $file_downloader->get($host, $directory, $filename, $port, $timeout); - $errstr = $file_downloader->get_error_string(); - $errno = $file_downloader->get_error_number(); - - return $file_data; -} - -/** - * Add log entry - * - * @param string $mode The mode defines which log_type is used and from which log the entry is retrieved - * @param int $forum_id Mode 'mod' ONLY: forum id of the related item, NOT INCLUDED otherwise - * @param int $topic_id Mode 'mod' ONLY: topic id of the related item, NOT INCLUDED otherwise - * @param int $reportee_id Mode 'user' ONLY: user id of the reportee, NOT INCLUDED otherwise - * @param string $log_operation Name of the operation - * @param array $additional_data More arguments can be added, depending on the log_type - * - * @return int|bool Returns the log_id, if the entry was added to the database, false otherwise. - * - * @deprecated 3.1.0 (To be removed: 4.0.0) - */ -function add_log() -{ - global $phpbb_log, $user; - - $args = func_get_args(); - $mode = array_shift($args); - - // This looks kind of dirty, but add_log has some additional data before the log_operation - $additional_data = array(); - switch ($mode) - { - case 'admin': - case 'critical': - break; - case 'mod': - $additional_data['forum_id'] = array_shift($args); - $additional_data['topic_id'] = array_shift($args); - break; - case 'user': - $additional_data['reportee_id'] = array_shift($args); - break; - } - - $log_operation = array_shift($args); - $additional_data = array_merge($additional_data, $args); - - $user_id = (empty($user->data)) ? ANONYMOUS : $user->data['user_id']; - $user_ip = (empty($user->ip)) ? '' : $user->ip; - - return $phpbb_log->add($mode, $user_id, $user_ip, $log_operation, time(), $additional_data); -} - -/** - * Sets a configuration option's value. - * - * Please note that this function does not update the is_dynamic value for - * an already existing config option. - * - * @param string $config_name The configuration option's name - * @param string $config_value New configuration value - * @param bool $is_dynamic Whether this variable should be cached (false) or - * if it changes too frequently (true) to be - * efficiently cached. - * - * @return null - * - * @deprecated 3.1.0 (To be removed: 4.0.0) - */ -function set_config($config_name, $config_value, $is_dynamic = false, \phpbb\config\config $set_config = null) -{ - static $config = null; - - if ($set_config !== null) - { - $config = $set_config; - - if (empty($config_name)) - { - return; - } - } - - $config->set($config_name, $config_value, !$is_dynamic); -} - -/** - * Increments an integer config value directly in the database. - * - * @param string $config_name The configuration option's name - * @param int $increment Amount to increment by - * @param bool $is_dynamic Whether this variable should be cached (false) or - * if it changes too frequently (true) to be - * efficiently cached. - * - * @return null - * - * @deprecated 3.1.0 (To be removed: 4.0.0) - */ -function set_config_count($config_name, $increment, $is_dynamic = false, \phpbb\config\config $set_config = null) -{ - static $config = null; - if ($set_config !== null) - { - $config = $set_config; - if (empty($config_name)) - { - return; - } - } - $config->increment($config_name, $increment, !$is_dynamic); -} - -/** - * Wrapper function of \phpbb\request\request::variable which exists for backwards compatability. - * See {@link \phpbb\request\request_interface::variable \phpbb\request\request_interface::variable} for - * documentation of this function's use. - * - * @deprecated 3.1.0 (To be removed: 4.0.0) - * @param mixed $var_name The form variable's name from which data shall be retrieved. - * If the value is an array this may be an array of indizes which will give - * direct access to a value at any depth. E.g. if the value of "var" is array(1 => "a") - * then specifying array("var", 1) as the name will return "a". - * If you pass an instance of {@link \phpbb\request\request_interface phpbb_request_interface} - * as this parameter it will overwrite the current request class instance. If you do - * not do so, it will create its own instance (but leave superglobals enabled). - * @param mixed $default A default value that is returned if the variable was not set. - * This function will always return a value of the same type as the default. - * @param bool $multibyte If $default is a string this paramater has to be true if the variable may contain any UTF-8 characters - * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks - * @param bool $cookie This param is mapped to \phpbb\request\request_interface::COOKIE as the last param for - * \phpbb\request\request_interface::variable for backwards compatability reasons. - * @param \phpbb\request\request_interface|null|false If an instance of \phpbb\request\request_interface is given the instance is stored in - * a static variable and used for all further calls where this parameters is null. Until - * the function is called with an instance it automatically creates a new \phpbb\request\request - * instance on every call. By passing false this per-call instantiation can be restored - * after having passed in a \phpbb\request\request_interface instance. - * - * @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the - * the same as that of $default. If the variable is not set $default is returned. - */ -function request_var($var_name, $default, $multibyte = false, $cookie = false, $request = null) -{ - // This is all just an ugly hack to add "Dependency Injection" to a function - // the only real code is the function call which maps this function to a method. - static $static_request = null; - if ($request instanceof \phpbb\request\request_interface) - { - $static_request = $request; - if (empty($var_name)) - { - return; - } - } - else if ($request === false) - { - $static_request = null; - if (empty($var_name)) - { - return; - } - } - $tmp_request = $static_request; - // no request class set, create a temporary one ourselves to keep backwards compatibility - if ($tmp_request === null) - { - // false param: enable super globals, so the created request class does not - // make super globals inaccessible everywhere outside this function. - $tmp_request = new \phpbb\request\request(new \phpbb\request\type_cast_helper(), false); - } - return $tmp_request->variable($var_name, $default, $multibyte, ($cookie) ? \phpbb\request\request_interface::COOKIE : \phpbb\request\request_interface::REQUEST); -} - -/** - * Get tables of a database - * - * @deprecated 3.1.0 (To be removed: 4.0.0) - */ -function get_tables($db) -{ - $db_tools_factory = new \phpbb\db\tools\factory(); - $db_tools = $db_tools_factory->get($db); - - return $db_tools->sql_list_tables(); -} - -/** - * Global function for chmodding directories and files for internal use - * - * This function determines owner and group whom the file belongs to and user and group of PHP and then set safest possible file permissions. - * The function determines owner and group from common.php file and sets the same to the provided file. - * The function uses bit fields to build the permissions. - * The function sets the appropiate execute bit on directories. - * - * Supported constants representing bit fields are: - * - * CHMOD_ALL - all permissions (7) - * CHMOD_READ - read permission (4) - * CHMOD_WRITE - write permission (2) - * CHMOD_EXECUTE - execute permission (1) - * - * NOTE: The function uses POSIX extension and fileowner()/filegroup() functions. If any of them is disabled, this function tries to build proper permissions, by calling is_readable() and is_writable() functions. - * - * @param string $filename The file/directory to be chmodded - * @param int $perms Permissions to set - * - * @return bool true on success, otherwise false - * - * @deprecated 3.2.0-dev use \phpbb\filesystem\filesystem::phpbb_chmod() instead - */ -function phpbb_chmod($filename, $perms = CHMOD_READ) -{ - global $phpbb_filesystem; - - try - { - $phpbb_filesystem->phpbb_chmod($filename, $perms); - } - catch (\phpbb\filesystem\exception\filesystem_exception $e) - { - return false; - } - - return true; -} - -/** - * Test if a file/directory is writable - * - * This function calls the native is_writable() when not running under - * Windows and it is not disabled. - * - * @param string $file Path to perform write test on - * @return bool True when the path is writable, otherwise false. - * - * @deprecated 3.2.0-dev use \phpbb\filesystem\filesystem::is_writable() instead - */ -function phpbb_is_writable($file) -{ - global $phpbb_filesystem; - - return $phpbb_filesystem->is_writable($file); -} - -/** - * Checks if a path ($path) is absolute or relative - * - * @param string $path Path to check absoluteness of - * @return boolean - * - * @deprecated 3.2.0-dev use \phpbb\filesystem\filesystem::is_absolute_path() instead - */ -function phpbb_is_absolute($path) -{ - global $phpbb_filesystem; - - return $phpbb_filesystem->is_absolute_path($path); -} - -/** - * A wrapper for realpath - * - * @deprecated 3.2.0-dev use \phpbb\filesystem\filesystem::realpath() instead - */ -function phpbb_realpath($path) -{ - global $phpbb_filesystem; - - return $phpbb_filesystem->realpath($path); -} - -/** - * Determine which plural form we should use. - * For some languages this is not as simple as for English. - * - * @param $rule int ID of the plural rule we want to use, see https://area51.phpbb.com/docs/dev/32x/language/plurals.html - * @param $number int|float The number we want to get the plural case for. Float numbers are floored. - * @return int The plural-case we need to use for the number plural-rule combination - * - * @deprecated 3.2.0-dev (To be removed: 4.0.0) - */ -function phpbb_get_plural_form($rule, $number) -{ - global $phpbb_container; - - /** @var \phpbb\language\language $language */ - $language = $phpbb_container->get('language'); - return $language->get_plural_form($number, $rule); -} - -/** -* @return bool Always true -* @deprecated 3.2.0-dev -*/ -function phpbb_pcre_utf8_support() -{ - return true; -} - -/** - * Casts a variable to the given type. - * - * @deprecated 3.1 (To be removed 4.0.0) - */ -function set_var(&$result, $var, $type, $multibyte = false) -{ - // no need for dependency injection here, if you have the object, call the method yourself! - $type_cast_helper = new \phpbb\request\type_cast_helper(); - $type_cast_helper->set_var($result, $var, $type, $multibyte); -} - -/** - * Delete Attachments - * - * @deprecated 3.2.0-a1 (To be removed: 4.0.0) - * - * @param string $mode can be: post|message|topic|attach|user - * @param mixed $ids can be: post_ids, message_ids, topic_ids, attach_ids, user_ids - * @param bool $resync set this to false if you are deleting posts or topics - */ -function delete_attachments($mode, $ids, $resync = true) -{ - global $phpbb_container; - - /** @var \phpbb\attachment\manager $attachment_manager */ - $attachment_manager = $phpbb_container->get('attachment.manager'); - $num_deleted = $attachment_manager->delete($mode, $ids, $resync); - - unset($attachment_manager); - - return $num_deleted; -} - -/** - * Delete attached file - * - * @deprecated 3.2.0-a1 (To be removed: 4.0.0) - */ -function phpbb_unlink($filename, $mode = 'file', $entry_removed = false) -{ - global $phpbb_container; - - /** @var \phpbb\attachment\manager $attachment_manager */ - $attachment_manager = $phpbb_container->get('attachment.manager'); - $unlink = $attachment_manager->unlink($filename, $mode, $entry_removed); - unset($attachment_manager); - - return $unlink; -} - -/** - * Display reasons - * - * @deprecated 3.2.0-dev (To be removed: 4.0.0) - */ -function display_reasons($reason_id = 0) -{ - global $phpbb_container; - - $phpbb_container->get('phpbb.report.report_reason_list_provider')->display_reasons($reason_id); -} - -/** - * Upload Attachment - filedata is generated here - * Uses upload class - * - * @deprecated 3.2.0-a1 (To be removed: 4.0.0) - * - * @param string $form_name The form name of the file upload input - * @param int $forum_id The id of the forum - * @param bool $local Whether the file is local or not - * @param string $local_storage The path to the local file - * @param bool $is_message Whether it is a PM or not - * @param array $local_filedata A filespec object created for the local file - * - * @return array File data array - */ -function upload_attachment($form_name, $forum_id, $local = false, $local_storage = '', $is_message = false, $local_filedata = false) -{ - global $phpbb_container; - - /** @var \phpbb\attachment\manager $attachment_manager */ - $attachment_manager = $phpbb_container->get('attachment.manager'); - $file = $attachment_manager->upload($form_name, $forum_id, $local, $local_storage, $is_message, $local_filedata); - unset($attachment_manager); - - return $file; -} - -/** -* Wrapper for php's checkdnsrr function. -* -* @param string $host Fully-Qualified Domain Name -* @param string $type Resource record type to lookup -* Supported types are: MX (default), A, AAAA, NS, TXT, CNAME -* Other types may work or may not work -* -* @return mixed true if entry found, -* false if entry not found, -* null if this function is not supported by this environment -* -* Since null can also be returned, you probably want to compare the result -* with === true or === false, -* -* @deprecated 3.3.0-b2 (To be removed: 4.0.0) -*/ -function phpbb_checkdnsrr($host, $type = 'MX') -{ - return checkdnsrr($host, $type); -} - -/* - * Wrapper for inet_ntop() - * - * Converts a packed internet address to a human readable representation - * inet_ntop() is supported by PHP since 5.1.0, since 5.3.0 also on Windows. - * - * @param string $in_addr A 32bit IPv4, or 128bit IPv6 address. - * - * @return mixed false on failure, - * string otherwise - * - * @deprecated 3.3.0-b2 (To be removed: 4.0.0) - */ -function phpbb_inet_ntop($in_addr) -{ - return inet_ntop($in_addr); -} - -/** - * Wrapper for inet_pton() - * - * Converts a human readable IP address to its packed in_addr representation - * inet_pton() is supported by PHP since 5.1.0, since 5.3.0 also on Windows. - * - * @param string $address A human readable IPv4 or IPv6 address. - * - * @return mixed false if address is invalid, - * in_addr representation of the given address otherwise (string) - * - * @deprecated 3.3.0-b2 (To be removed: 4.0.0) - */ -function phpbb_inet_pton($address) -{ - return inet_pton($address); -} - -/** - * Hashes an email address to a big integer - * - * @param string $email Email address - * - * @return string Unsigned Big Integer - * - * @deprecated 3.3.0-b2 (To be removed: 4.0.0) - */ -function phpbb_email_hash($email) -{ - return sprintf('%u', crc32(strtolower($email))) . strlen($email); -} diff --git a/install/update/new/includes/functions_compress.php b/install/update/new/includes/functions_compress.php deleted file mode 100644 index 56d64d3..0000000 --- a/install/update/new/includes/functions_compress.php +++ /dev/null @@ -1,830 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* Class for handling archives (compression/decompression) -*/ -class compress -{ - var $fp = 0; - - /** - * @var array - */ - protected $filelist = array(); - - /** - * Add file to archive - */ - function add_file($src, $src_rm_prefix = '', $src_add_prefix = '', $skip_files = '') - { - global $phpbb_root_path; - - $skip_files = explode(',', $skip_files); - - // Remove rm prefix from src path - $src_path = ($src_rm_prefix) ? preg_replace('#^(' . preg_quote($src_rm_prefix, '#') . ')#', '', $src) : $src; - // Add src prefix - $src_path = ($src_add_prefix) ? ($src_add_prefix . ((substr($src_add_prefix, -1) != '/') ? '/' : '') . $src_path) : $src_path; - // Remove initial "/" if present - $src_path = (substr($src_path, 0, 1) == '/') ? substr($src_path, 1) : $src_path; - - if (is_file($phpbb_root_path . $src)) - { - $this->data($src_path, file_get_contents("$phpbb_root_path$src"), stat("$phpbb_root_path$src"), false); - } - else if (is_dir($phpbb_root_path . $src)) - { - // Clean up path, add closing / if not present - $src_path = ($src_path && substr($src_path, -1) != '/') ? $src_path . '/' : $src_path; - - $filelist = filelist("$phpbb_root_path$src", '', '*'); - krsort($filelist); - - /** - * Commented out, as adding the folders produces corrupted archives - if ($src_path) - { - $this->data($src_path, '', true, stat("$phpbb_root_path$src")); - } - */ - - foreach ($filelist as $path => $file_ary) - { - /** - * Commented out, as adding the folders produces corrupted archives - if ($path) - { - // Same as for src_path - $path = (substr($path, 0, 1) == '/') ? substr($path, 1) : $path; - $path = ($path && substr($path, -1) != '/') ? $path . '/' : $path; - - $this->data("$src_path$path", '', true, stat("$phpbb_root_path$src$path")); - } - */ - - foreach ($file_ary as $file) - { - if (in_array($path . $file, $skip_files)) - { - continue; - } - - $this->data("$src_path$path$file", file_get_contents("$phpbb_root_path$src$path$file"), stat("$phpbb_root_path$src$path$file"), false); - } - } - } - else - { - // $src does not exist - return false; - } - - return true; - } - - /** - * Add custom file (the filepath will not be adjusted) - */ - function add_custom_file($src, $filename) - { - if (!file_exists($src)) - { - return false; - } - - $this->data($filename, file_get_contents($src), stat($src), false); - return true; - } - - /** - * Add file data - */ - function add_data($src, $name) - { - $stat = array(); - $stat[2] = 436; //384 - $stat[4] = $stat[5] = 0; - $stat[7] = strlen($src); - $stat[9] = time(); - $this->data($name, $src, $stat, false); - return true; - } - - /** - * Checks if a file by that name as already been added and, if it has, - * returns a new, unique name. - * - * @param string $name The filename - * @return string A unique filename - */ - protected function unique_filename($name) - { - if (isset($this->filelist[$name])) - { - $start = $name; - $ext = ''; - $this->filelist[$name]++; - - // Separate the extension off the end of the filename to preserve it - $pos = strrpos($name, '.'); - if ($pos !== false) - { - $start = substr($name, 0, $pos); - $ext = substr($name, $pos); - } - - return $start . '_' . $this->filelist[$name] . $ext; - } - - $this->filelist[$name] = 0; - return $name; - } - - /** - * Return available methods - * - * @return array Array of strings of available compression methods (.tar, .tar.gz, .zip, etc.) - */ - static public function methods() - { - $methods = array('.tar'); - $available_methods = array('.tar.gz' => 'zlib', '.tar.bz2' => 'bz2', '.zip' => 'zlib'); - - foreach ($available_methods as $type => $module) - { - if (!@extension_loaded($module)) - { - continue; - } - $methods[] = $type; - } - - return $methods; - } -} - -/** -* Zip creation class from phpMyAdmin 2.3.0 (c) Tobias Ratschiller, Olivier Müller, Loïc Chapeaux, -* Marc Delisle, http://www.phpmyadmin.net/ -* -* Zip extraction function by Alexandre Tedeschi, alexandrebr at gmail dot com -* -* Modified extensively by psoTFX and DavidMJ, (c) phpBB Limited, 2003 -* -* Based on work by Eric Mueller and Denis125 -* Official ZIP file format: http://www.pkware.com/appnote.txt -*/ -class compress_zip extends compress -{ - var $datasec = array(); - var $ctrl_dir = array(); - var $eof_cdh = "\x50\x4b\x05\x06\x00\x00\x00\x00"; - - var $old_offset = 0; - var $datasec_len = 0; - - /** - * @var \phpbb\filesystem\filesystem_interface - */ - protected $filesystem; - - /** - * Constructor - */ - function __construct($mode, $file) - { - global $phpbb_filesystem; - - $this->fp = @fopen($file, $mode . 'b'); - $this->filesystem = ($phpbb_filesystem instanceof \phpbb\filesystem\filesystem_interface) ? $phpbb_filesystem : new \phpbb\filesystem\filesystem(); - - if (!$this->fp) - { - trigger_error('Unable to open file ' . $file . ' [' . $mode . 'b]'); - } - } - - /** - * Convert unix to dos time - */ - function unix_to_dos_time($time) - { - $timearray = (!$time) ? getdate() : getdate($time); - - if ($timearray['year'] < 1980) - { - $timearray['year'] = 1980; - $timearray['mon'] = $timearray['mday'] = 1; - $timearray['hours'] = $timearray['minutes'] = $timearray['seconds'] = 0; - } - - return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) | ($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1); - } - - /** - * Extract archive - */ - function extract($dst) - { - // Loop the file, looking for files and folders - $dd_try = false; - rewind($this->fp); - - while (!feof($this->fp)) - { - // Check if the signature is valid... - $signature = fread($this->fp, 4); - - switch ($signature) - { - // 'Local File Header' - case "\x50\x4b\x03\x04": - // Lets get everything we need. - // We don't store the version needed to extract, the general purpose bit flag or the date and time fields - $data = unpack("@4/vc_method/@10/Vcrc/Vc_size/Vuc_size/vname_len/vextra_field", fread($this->fp, 26)); - $file_name = fread($this->fp, $data['name_len']); // filename - - if ($data['extra_field']) - { - fread($this->fp, $data['extra_field']); // extra field - } - - $target_filename = "$dst$file_name"; - - if (!$data['uc_size'] && !$data['crc'] && substr($file_name, -1, 1) == '/') - { - if (!is_dir($target_filename)) - { - $str = ''; - $folders = explode('/', $target_filename); - - // Create and folders and subfolders if they do not exist - foreach ($folders as $folder) - { - $folder = trim($folder); - if (!$folder) - { - continue; - } - - $str = (!empty($str)) ? $str . '/' . $folder : $folder; - if (!is_dir($str)) - { - if (!@mkdir($str, 0777)) - { - trigger_error("Could not create directory $folder"); - } - - try - { - $this->filesystem->phpbb_chmod($str, CHMOD_READ | CHMOD_WRITE); - } - catch (\phpbb\filesystem\exception\filesystem_exception $e) - { - // Do nothing - } - } - } - } - // This is a directory, we are not writing files - continue 2; - } - else - { - // Some archivers are punks, they don't include folders in their archives! - $str = ''; - $folders = explode('/', pathinfo($target_filename, PATHINFO_DIRNAME)); - - // Create and folders and subfolders if they do not exist - foreach ($folders as $folder) - { - $folder = trim($folder); - if (!$folder) - { - continue; - } - - $str = (!empty($str)) ? $str . '/' . $folder : $folder; - if (!is_dir($str)) - { - if (!@mkdir($str, 0777)) - { - trigger_error("Could not create directory $folder"); - } - - try - { - $this->filesystem->phpbb_chmod($str, CHMOD_READ | CHMOD_WRITE); - } - catch (\phpbb\filesystem\exception\filesystem_exception $e) - { - // Do nothing - } - } - } - } - - if (!$data['uc_size']) - { - $content = ''; - } - else - { - $content = fread($this->fp, $data['c_size']); - } - - $fp = fopen($target_filename, "w"); - - switch ($data['c_method']) - { - case 0: - // Not compressed - fwrite($fp, $content); - break; - - case 8: - // Deflate - fwrite($fp, gzinflate($content, $data['uc_size'])); - break; - - case 12: - // Bzip2 - fwrite($fp, bzdecompress($content)); - break; - } - - fclose($fp); - break; - - // We hit the 'Central Directory Header', we can stop because nothing else in here requires our attention - // or we hit the end of the central directory record, we can safely end the loop as we are totally finished with looking for files and folders - case "\x50\x4b\x01\x02": - // This case should simply never happen.. but it does exist.. - case "\x50\x4b\x05\x06": - break 2; - - // 'Packed to Removable Disk', ignore it and look for the next signature... - case 'PK00': - continue 2; - - // We have encountered a header that is weird. Lets look for better data... - default: - if (!$dd_try) - { - // Unexpected header. Trying to detect wrong placed 'Data Descriptor'; - $dd_try = true; - fseek($this->fp, 8, SEEK_CUR); // Jump over 'crc-32'(4) 'compressed-size'(4), 'uncompressed-size'(4) - continue 2; - } - trigger_error("Unexpected header, ending loop"); - break 2; - } - - $dd_try = false; - } - } - - /** - * Close archive - */ - function close() - { - // Write out central file directory and footer ... if it exists - if (count($this->ctrl_dir)) - { - fwrite($this->fp, $this->file()); - } - fclose($this->fp); - } - - /** - * Create the structures ... note we assume version made by is MSDOS - */ - function data($name, $data, $stat, $is_dir = false) - { - $name = str_replace('\\', '/', $name); - $name = $this->unique_filename($name); - - $hexdtime = pack('V', $this->unix_to_dos_time($stat[9])); - - if ($is_dir) - { - $unc_len = $c_len = $crc = 0; - $zdata = ''; - $var_ext = 10; - } - else - { - $unc_len = strlen($data); - $crc = crc32($data); - $zdata = gzdeflate($data); - $c_len = strlen($zdata); - $var_ext = 20; - - // Did we compress? No, then use data as is - if ($c_len >= $unc_len) - { - $zdata = $data; - $c_len = $unc_len; - $var_ext = 10; - } - } - unset($data); - - // If we didn't compress set method to store, else deflate - $c_method = ($c_len == $unc_len) ? "\x00\x00" : "\x08\x00"; - - // Are we a file or a directory? Set archive for file - $attrib = ($is_dir) ? 16 : 32; - - // File Record Header - $fr = "\x50\x4b\x03\x04"; // Local file header 4bytes - $fr .= pack('v', $var_ext); // ver needed to extract 2bytes - $fr .= "\x00\x00"; // gen purpose bit flag 2bytes - $fr .= $c_method; // compression method 2bytes - $fr .= $hexdtime; // last mod time and date 2+2bytes - $fr .= pack('V', $crc); // crc32 4bytes - $fr .= pack('V', $c_len); // compressed filesize 4bytes - $fr .= pack('V', $unc_len); // uncompressed filesize 4bytes - $fr .= pack('v', strlen($name));// length of filename 2bytes - - $fr .= pack('v', 0); // extra field length 2bytes - $fr .= $name; - $fr .= $zdata; - unset($zdata); - - $this->datasec_len += strlen($fr); - - // Add data to file ... by writing data out incrementally we save some memory - fwrite($this->fp, $fr); - unset($fr); - - // Central Directory Header - $cdrec = "\x50\x4b\x01\x02"; // header 4bytes - $cdrec .= "\x00\x00"; // version made by - $cdrec .= pack('v', $var_ext); // version needed to extract - $cdrec .= "\x00\x00"; // gen purpose bit flag - $cdrec .= $c_method; // compression method - $cdrec .= $hexdtime; // last mod time & date - $cdrec .= pack('V', $crc); // crc32 - $cdrec .= pack('V', $c_len); // compressed filesize - $cdrec .= pack('V', $unc_len); // uncompressed filesize - $cdrec .= pack('v', strlen($name)); // length of filename - $cdrec .= pack('v', 0); // extra field length - $cdrec .= pack('v', 0); // file comment length - $cdrec .= pack('v', 0); // disk number start - $cdrec .= pack('v', 0); // internal file attributes - $cdrec .= pack('V', $attrib); // external file attributes - $cdrec .= pack('V', $this->old_offset); // relative offset of local header - $cdrec .= $name; - - // Save to central directory - $this->ctrl_dir[] = $cdrec; - - $this->old_offset = $this->datasec_len; - } - - /** - * file - */ - function file() - { - $ctrldir = implode('', $this->ctrl_dir); - - return $ctrldir . $this->eof_cdh . - pack('v', count($this->ctrl_dir)) . // total # of entries "on this disk" - pack('v', count($this->ctrl_dir)) . // total # of entries overall - pack('V', strlen($ctrldir)) . // size of central dir - pack('V', $this->datasec_len) . // offset to start of central dir - "\x00\x00"; // .zip file comment length - } - - /** - * Download archive - */ - function download($filename, $download_name = false) - { - global $phpbb_root_path; - - if ($download_name === false) - { - $download_name = $filename; - } - - $mimetype = 'application/zip'; - - header('Cache-Control: private, no-cache'); - header("Content-Type: $mimetype; name=\"$download_name.zip\""); - header("Content-disposition: attachment; filename=$download_name.zip"); - - $fp = @fopen("{$phpbb_root_path}store/$filename.zip", 'rb'); - if ($fp) - { - while ($buffer = fread($fp, 1024)) - { - echo $buffer; - } - fclose($fp); - } - } -} - -/** -* Tar/tar.gz compression routine -* Header/checksum creation derived from tarfile.pl, (c) Tom Horsley, 1994 -*/ -class compress_tar extends compress -{ - var $isgz = false; - var $isbz = false; - var $filename = ''; - var $mode = ''; - var $type = ''; - var $wrote = false; - - /** - * @var \phpbb\filesystem\filesystem_interface - */ - protected $filesystem; - - /** - * Constructor - */ - function __construct($mode, $file, $type = '') - { - global $phpbb_filesystem; - - $type = (!$type) ? $file : $type; - $this->isgz = preg_match('#(\.tar\.gz|\.tgz)$#', $type); - $this->isbz = preg_match('#\.tar\.bz2$#', $type); - - $this->mode = &$mode; - $this->file = &$file; - $this->type = &$type; - $this->open(); - - $this->filesystem = ($phpbb_filesystem instanceof \phpbb\filesystem\filesystem_interface) ? $phpbb_filesystem : new \phpbb\filesystem\filesystem(); - } - - /** - * Extract archive - */ - function extract($dst) - { - $fzread = ($this->isbz && function_exists('bzread')) ? 'bzread' : (($this->isgz && @extension_loaded('zlib')) ? 'gzread' : 'fread'); - - // Run through the file and grab directory entries - while ($buffer = $fzread($this->fp, 512)) - { - $tmp = unpack('A6magic', substr($buffer, 257, 6)); - - if (trim($tmp['magic']) == 'ustar') - { - $tmp = unpack('A100name', $buffer); - $filename = trim($tmp['name']); - - $tmp = unpack('Atype', substr($buffer, 156, 1)); - $filetype = (int) trim($tmp['type']); - - $tmp = unpack('A12size', substr($buffer, 124, 12)); - $filesize = octdec((int) trim($tmp['size'])); - - $target_filename = "$dst$filename"; - - if ($filetype == 5) - { - if (!is_dir($target_filename)) - { - $str = ''; - $folders = explode('/', $target_filename); - - // Create and folders and subfolders if they do not exist - foreach ($folders as $folder) - { - $folder = trim($folder); - if (!$folder) - { - continue; - } - - $str = (!empty($str)) ? $str . '/' . $folder : $folder; - if (!is_dir($str)) - { - if (!@mkdir($str, 0777)) - { - trigger_error("Could not create directory $folder"); - } - - try - { - $this->filesystem->phpbb_chmod($str, CHMOD_READ | CHMOD_WRITE); - } - catch (\phpbb\filesystem\exception\filesystem_exception $e) - { - // Do nothing - } - } - } - } - } - else if ($filesize >= 0 && ($filetype == 0 || $filetype == "\0")) - { - // Some archivers are punks, they don't properly order the folders in their archives! - $str = ''; - $folders = explode('/', pathinfo($target_filename, PATHINFO_DIRNAME)); - - // Create and folders and subfolders if they do not exist - foreach ($folders as $folder) - { - $folder = trim($folder); - if (!$folder) - { - continue; - } - - $str = (!empty($str)) ? $str . '/' . $folder : $folder; - if (!is_dir($str)) - { - if (!@mkdir($str, 0777)) - { - trigger_error("Could not create directory $folder"); - } - - try - { - $this->filesystem->phpbb_chmod($str, CHMOD_READ | CHMOD_WRITE); - } - catch (\phpbb\filesystem\exception\filesystem_exception $e) - { - // Do nothing - } - } - } - - // Write out the files - if (!($fp = fopen($target_filename, 'wb'))) - { - trigger_error("Couldn't create file $filename"); - } - - try - { - $this->filesystem->phpbb_chmod($target_filename, CHMOD_READ); - } - catch (\phpbb\filesystem\exception\filesystem_exception $e) - { - // Do nothing - } - - // Grab the file contents - fwrite($fp, ($filesize) ? $fzread($this->fp, ($filesize + 511) &~ 511) : '', $filesize); - fclose($fp); - } - } - } - } - - /** - * Close archive - */ - function close() - { - $fzclose = ($this->isbz && function_exists('bzclose')) ? 'bzclose' : (($this->isgz && @extension_loaded('zlib')) ? 'gzclose' : 'fclose'); - - if ($this->wrote) - { - $fzwrite = ($this->isbz && function_exists('bzwrite')) ? 'bzwrite' : (($this->isgz && @extension_loaded('zlib')) ? 'gzwrite' : 'fwrite'); - - // The end of a tar archive ends in two records of all NULLs (1024 bytes of \0) - $fzwrite($this->fp, str_repeat("\0", 1024)); - } - - $fzclose($this->fp); - } - - /** - * Create the structures - */ - function data($name, $data, $stat, $is_dir = false) - { - $name = $this->unique_filename($name); - $this->wrote = true; - $fzwrite = ($this->isbz && function_exists('bzwrite')) ? 'bzwrite' : (($this->isgz && @extension_loaded('zlib')) ? 'gzwrite' : 'fwrite'); - - $typeflag = ($is_dir) ? '5' : ''; - - // This is the header data, it contains all the info we know about the file or folder that we are about to archive - $header = ''; - $header .= pack('a100', $name); // file name - $header .= pack('a8', sprintf("%07o", $stat[2])); // file mode - $header .= pack('a8', sprintf("%07o", $stat[4])); // owner id - $header .= pack('a8', sprintf("%07o", $stat[5])); // group id - $header .= pack('a12', sprintf("%011o", $stat[7])); // file size - $header .= pack('a12', sprintf("%011o", $stat[9])); // last mod time - - // Checksum - $checksum = 0; - for ($i = 0; $i < 148; $i++) - { - $checksum += ord($header[$i]); - } - - // We precompute the rest of the hash, this saves us time in the loop and allows us to insert our hash without resorting to string functions - $checksum += 2415 + (($is_dir) ? 53 : 0); - - $header .= pack('a8', sprintf("%07o", $checksum)); // checksum - $header .= pack('a1', $typeflag); // link indicator - $header .= pack('a100', ''); // name of linked file - $header .= pack('a6', 'ustar'); // ustar indicator - $header .= pack('a2', '00'); // ustar version - $header .= pack('a32', 'Unknown'); // owner name - $header .= pack('a32', 'Unknown'); // group name - $header .= pack('a8', ''); // device major number - $header .= pack('a8', ''); // device minor number - $header .= pack('a155', ''); // filename prefix - $header .= pack('a12', ''); // end - - // This writes the entire file in one shot. Header, followed by data and then null padded to a multiple of 512 - $fzwrite($this->fp, $header . (($stat[7] !== 0 && !$is_dir) ? $data . str_repeat("\0", (($stat[7] + 511) &~ 511) - $stat[7]) : '')); - unset($data); - } - - /** - * Open archive - */ - function open() - { - $fzopen = ($this->isbz && function_exists('bzopen')) ? 'bzopen' : (($this->isgz && @extension_loaded('zlib')) ? 'gzopen' : 'fopen'); - $this->fp = @$fzopen($this->file, $this->mode . (($fzopen == 'bzopen') ? '' : 'b') . (($fzopen == 'gzopen') ? '9' : '')); - - if (!$this->fp) - { - trigger_error('Unable to open file ' . $this->file . ' [' . $fzopen . ' - ' . $this->mode . 'b]'); - } - } - - /** - * Download archive - */ - function download($filename, $download_name = false) - { - global $phpbb_root_path; - - if ($download_name === false) - { - $download_name = $filename; - } - - switch ($this->type) - { - case '.tar': - $mimetype = 'application/x-tar'; - break; - - case '.tar.gz': - $mimetype = 'application/x-gzip'; - break; - - case '.tar.bz2': - $mimetype = 'application/x-bzip2'; - break; - - default: - $mimetype = 'application/octet-stream'; - break; - } - - header('Cache-Control: private, no-cache'); - header("Content-Type: $mimetype; name=\"$download_name$this->type\""); - header("Content-disposition: attachment; filename=$download_name$this->type"); - - $fp = @fopen("{$phpbb_root_path}store/$filename$this->type", 'rb'); - if ($fp) - { - while ($buffer = fread($fp, 1024)) - { - echo $buffer; - } - fclose($fp); - } - } -} diff --git a/install/update/new/includes/functions_content.php b/install/update/new/includes/functions_content.php deleted file mode 100644 index fd014c7..0000000 --- a/install/update/new/includes/functions_content.php +++ /dev/null @@ -1,1788 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* gen_sort_selects() -* make_jumpbox() -* bump_topic_allowed() -* get_context() -* phpbb_clean_search_string() -* decode_message() -* strip_bbcode() -* generate_text_for_display() -* generate_text_for_storage() -* generate_text_for_edit() -* make_clickable_callback() -* make_clickable() -* censor_text() -* bbcode_nl2br() -* smiley_text() -* parse_attachments() -* extension_allowed() -* truncate_string() -* get_username_string() -* class bitfield -*/ - -/** -* Generate sort selection fields -*/ -function gen_sort_selects(&$limit_days, &$sort_by_text, &$sort_days, &$sort_key, &$sort_dir, &$s_limit_days, &$s_sort_key, &$s_sort_dir, &$u_sort_param, $def_st = false, $def_sk = false, $def_sd = false) -{ - global $user, $phpbb_dispatcher; - - $sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']); - - $sorts = array( - 'st' => array( - 'key' => 'sort_days', - 'default' => $def_st, - 'options' => $limit_days, - 'output' => &$s_limit_days, - ), - - 'sk' => array( - 'key' => 'sort_key', - 'default' => $def_sk, - 'options' => $sort_by_text, - 'output' => &$s_sort_key, - ), - - 'sd' => array( - 'key' => 'sort_dir', - 'default' => $def_sd, - 'options' => $sort_dir_text, - 'output' => &$s_sort_dir, - ), - ); - $u_sort_param = ''; - - foreach ($sorts as $name => $sort_ary) - { - $key = $sort_ary['key']; - $selected = ${$sort_ary['key']}; - - // Check if the key is selectable. If not, we reset to the default or first key found. - // This ensures the values are always valid. We also set $sort_dir/sort_key/etc. to the - // correct value, else the protection is void. ;) - if (!isset($sort_ary['options'][$selected])) - { - if ($sort_ary['default'] !== false) - { - $selected = ${$key} = $sort_ary['default']; - } - else - { - @reset($sort_ary['options']); - $selected = ${$key} = key($sort_ary['options']); - } - } - - $sort_ary['output'] = ''; - - $u_sort_param .= ($selected !== $sort_ary['default']) ? ((strlen($u_sort_param)) ? '&' : '') . "{$name}={$selected}" : ''; - } - - /** - * Run code before generated sort selects are returned - * - * @event core.gen_sort_selects_after - * @var int limit_days Days limit - * @var array sort_by_text Sort by text options - * @var int sort_days Sort by days flag - * @var string sort_key Sort key - * @var string sort_dir Sort dir - * @var string s_limit_days String of days limit - * @var string s_sort_key String of sort key - * @var string s_sort_dir String of sort dir - * @var string u_sort_param Sort URL params - * @var bool def_st Default sort days - * @var bool def_sk Default sort key - * @var bool def_sd Default sort dir - * @var array sorts Sorts - * @since 3.1.9-RC1 - */ - $vars = array( - 'limit_days', - 'sort_by_text', - 'sort_days', - 'sort_key', - 'sort_dir', - 's_limit_days', - 's_sort_key', - 's_sort_dir', - 'u_sort_param', - 'def_st', - 'def_sk', - 'def_sd', - 'sorts', - ); - extract($phpbb_dispatcher->trigger_event('core.gen_sort_selects_after', compact($vars))); - - return; -} - -/** -* Generate Jumpbox -*/ -function make_jumpbox($action, $forum_id = false, $select_all = false, $acl_list = false, $force_display = false) -{ - global $config, $auth, $template, $user, $db, $phpbb_path_helper, $phpbb_dispatcher; - - // We only return if the jumpbox is not forced to be displayed (in case it is needed for functionality) - if (!$config['load_jumpbox'] && $force_display === false) - { - return; - } - - $sql = 'SELECT forum_id, forum_name, parent_id, forum_type, left_id, right_id - FROM ' . FORUMS_TABLE . ' - ORDER BY left_id ASC'; - $result = $db->sql_query($sql, 600); - - $rowset = array(); - while ($row = $db->sql_fetchrow($result)) - { - $rowset[(int) $row['forum_id']] = $row; - } - $db->sql_freeresult($result); - - $right = $padding = 0; - $padding_store = array('0' => 0); - $display_jumpbox = false; - $iteration = 0; - - /** - * Modify the jumpbox forum list data - * - * @event core.make_jumpbox_modify_forum_list - * @var array rowset Array with the forums list data - * @since 3.1.10-RC1 - */ - $vars = array('rowset'); - extract($phpbb_dispatcher->trigger_event('core.make_jumpbox_modify_forum_list', compact($vars))); - - // Sometimes it could happen that forums will be displayed here not be displayed within the index page - // This is the result of forums not displayed at index, having list permissions and a parent of a forum with no permissions. - // If this happens, the padding could be "broken" - - foreach ($rowset as $row) - { - if ($row['left_id'] < $right) - { - $padding++; - $padding_store[$row['parent_id']] = $padding; - } - else if ($row['left_id'] > $right + 1) - { - // Ok, if the $padding_store for this parent is empty there is something wrong. For now we will skip over it. - // @todo digging deep to find out "how" this can happen. - $padding = (isset($padding_store[$row['parent_id']])) ? $padding_store[$row['parent_id']] : $padding; - } - - $right = $row['right_id']; - - if ($row['forum_type'] == FORUM_CAT && ($row['left_id'] + 1 == $row['right_id'])) - { - // Non-postable forum with no subforums, don't display - continue; - } - - if (!$auth->acl_get('f_list', $row['forum_id'])) - { - // if the user does not have permissions to list this forum skip - continue; - } - - if ($acl_list && !$auth->acl_gets($acl_list, $row['forum_id'])) - { - continue; - } - - $tpl_ary = array(); - if (!$display_jumpbox) - { - $tpl_ary[] = array( - 'FORUM_ID' => ($select_all) ? 0 : -1, - 'FORUM_NAME' => ($select_all) ? $user->lang['ALL_FORUMS'] : $user->lang['SELECT_FORUM'], - 'S_FORUM_COUNT' => $iteration, - 'LINK' => $phpbb_path_helper->append_url_params($action, array('f' => $forum_id)), - ); - - $iteration++; - $display_jumpbox = true; - } - - $tpl_ary[] = array( - 'FORUM_ID' => $row['forum_id'], - 'FORUM_NAME' => $row['forum_name'], - 'SELECTED' => ($row['forum_id'] == $forum_id) ? ' selected="selected"' : '', - 'S_FORUM_COUNT' => $iteration, - 'S_IS_CAT' => ($row['forum_type'] == FORUM_CAT) ? true : false, - 'S_IS_LINK' => ($row['forum_type'] == FORUM_LINK) ? true : false, - 'S_IS_POST' => ($row['forum_type'] == FORUM_POST) ? true : false, - 'LINK' => $phpbb_path_helper->append_url_params($action, array('f' => $row['forum_id'])), - ); - - /** - * Modify the jumpbox before it is assigned to the template - * - * @event core.make_jumpbox_modify_tpl_ary - * @var array row The data of the forum - * @var array tpl_ary Template data of the forum - * @since 3.1.10-RC1 - */ - $vars = array( - 'row', - 'tpl_ary', - ); - extract($phpbb_dispatcher->trigger_event('core.make_jumpbox_modify_tpl_ary', compact($vars))); - - $template->assign_block_vars_array('jumpbox_forums', $tpl_ary); - - unset($tpl_ary); - - for ($i = 0; $i < $padding; $i++) - { - $template->assign_block_vars('jumpbox_forums.level', array()); - } - $iteration++; - } - unset($padding_store, $rowset); - - $url_parts = $phpbb_path_helper->get_url_parts($action); - - $template->assign_vars(array( - 'S_DISPLAY_JUMPBOX' => $display_jumpbox, - 'S_JUMPBOX_ACTION' => $action, - 'HIDDEN_FIELDS_FOR_JUMPBOX' => build_hidden_fields($url_parts['params']), - )); - - return; -} - -/** -* Bump Topic Check - used by posting and viewtopic -*/ -function bump_topic_allowed($forum_id, $topic_bumped, $last_post_time, $topic_poster, $last_topic_poster) -{ - global $config, $auth, $user; - - // Check permission and make sure the last post was not already bumped - if (!$auth->acl_get('f_bump', $forum_id) || $topic_bumped) - { - return false; - } - - // Check bump time range, is the user really allowed to bump the topic at this time? - $bump_time = ($config['bump_type'] == 'm') ? $config['bump_interval'] * 60 : (($config['bump_type'] == 'h') ? $config['bump_interval'] * 3600 : $config['bump_interval'] * 86400); - - // Check bump time - if ($last_post_time + $bump_time > time()) - { - return false; - } - - // Check bumper, only topic poster and last poster are allowed to bump - if ($topic_poster != $user->data['user_id'] && $last_topic_poster != $user->data['user_id']) - { - return false; - } - - // A bump time of 0 will completely disable the bump feature... not intended but might be useful. - return $bump_time; -} - -/** -* Generates a text with approx. the specified length which contains the specified words and their context -* -* @param string $text The full text from which context shall be extracted -* @param string $words An array of words which should be contained in the result, has to be a valid part of a PCRE pattern (escape with preg_quote!) -* @param int $length The desired length of the resulting text, however the result might be shorter or longer than this value -* -* @return string Context of the specified words separated by "..." -*/ -function get_context($text, $words, $length = 400) -{ - // first replace all whitespaces with single spaces - $text = preg_replace('/ +/', ' ', strtr($text, "\t\n\r\x0C ", ' ')); - - // we need to turn the entities back into their original form, to not cut the message in between them - $entities = array('<', '>', '[', ']', '.', ':', ':'); - $characters = array('<', '>', '[', ']', '.', ':', ':'); - $text = str_replace($entities, $characters, $text); - - $word_indizes = array(); - if (count($words)) - { - $match = ''; - // find the starting indizes of all words - foreach ($words as $word) - { - if ($word) - { - if (preg_match('#(?:[^\w]|^)(' . $word . ')(?:[^\w]|$)#i', $text, $match)) - { - if (empty($match[1])) - { - continue; - } - - $pos = utf8_strpos($text, $match[1]); - if ($pos !== false) - { - $word_indizes[] = $pos; - } - } - } - } - unset($match); - - if (count($word_indizes)) - { - $word_indizes = array_unique($word_indizes); - sort($word_indizes); - - $wordnum = count($word_indizes); - // number of characters on the right and left side of each word - $sequence_length = (int) ($length / (2 * $wordnum)) - 2; - $final_text = ''; - $word = $j = 0; - $final_text_index = -1; - - // cycle through every character in the original text - for ($i = $word_indizes[$word], $n = utf8_strlen($text); $i < $n; $i++) - { - // if the current position is the start of one of the words then append $sequence_length characters to the final text - if (isset($word_indizes[$word]) && ($i == $word_indizes[$word])) - { - if ($final_text_index < $i - $sequence_length - 1) - { - $final_text .= '... ' . preg_replace('#^([^ ]*)#', '', utf8_substr($text, $i - $sequence_length, $sequence_length)); - } - else - { - // if the final text is already nearer to the current word than $sequence_length we only append the text - // from its current index on and distribute the unused length to all other sequenes - $sequence_length += (int) (($final_text_index - $i + $sequence_length + 1) / (2 * $wordnum)); - $final_text .= utf8_substr($text, $final_text_index + 1, $i - $final_text_index - 1); - } - $final_text_index = $i - 1; - - // add the following characters to the final text (see below) - $word++; - $j = 1; - } - - if ($j > 0) - { - // add the character to the final text and increment the sequence counter - $final_text .= utf8_substr($text, $i, 1); - $final_text_index++; - $j++; - - // if this is a whitespace then check whether we are done with this sequence - if (utf8_substr($text, $i, 1) == ' ') - { - // only check whether we have to exit the context generation completely if we haven't already reached the end anyway - if ($i + 4 < $n) - { - if (($j > $sequence_length && $word >= $wordnum) || utf8_strlen($final_text) > $length) - { - $final_text .= ' ...'; - break; - } - } - else - { - // make sure the text really reaches the end - $j -= 4; - } - - // stop context generation and wait for the next word - if ($j > $sequence_length) - { - $j = 0; - } - } - } - } - return str_replace($characters, $entities, $final_text); - } - } - - if (!count($words) || !count($word_indizes)) - { - return str_replace($characters, $entities, ((utf8_strlen($text) >= $length + 3) ? utf8_substr($text, 0, $length) . '...' : $text)); - } -} - -/** -* Cleans a search string by removing single wildcards from it and replacing multiple spaces with a single one. -* -* @param string $search_string The full search string which should be cleaned. -* -* @return string The cleaned search string without any wildcards and multiple spaces. -*/ -function phpbb_clean_search_string($search_string) -{ - // This regular expressions matches every single wildcard. - // That means one after a whitespace or the beginning of the string or one before a whitespace or the end of the string. - $search_string = preg_replace('#(?<=^|\s)\*+(?=\s|$)#', '', $search_string); - $search_string = trim($search_string); - $search_string = preg_replace(array('#\s+#u', '#\*+#u'), array(' ', '*'), $search_string); - return $search_string; -} - -/** -* Decode text whereby text is coming from the db and expected to be pre-parsed content -* We are placing this outside of the message parser because we are often in need of it... -* -* NOTE: special chars are kept encoded -* -* @param string &$message Original message, passed by reference -* @param string $bbcode_uid BBCode UID -* @return null -*/ -function decode_message(&$message, $bbcode_uid = '') -{ - global $phpbb_container, $phpbb_dispatcher; - - /** - * Use this event to modify the message before it is decoded - * - * @event core.decode_message_before - * @var string message_text The message content - * @var string bbcode_uid The message BBCode UID - * @since 3.1.9-RC1 - */ - $message_text = $message; - $vars = array('message_text', 'bbcode_uid'); - extract($phpbb_dispatcher->trigger_event('core.decode_message_before', compact($vars))); - $message = $message_text; - - if (preg_match('#^<[rt][ >]#', $message)) - { - $message = htmlspecialchars($phpbb_container->get('text_formatter.utils')->unparse($message), ENT_COMPAT); - } - else - { - if ($bbcode_uid) - { - $match = array('
', "[/*:m:$bbcode_uid]", ":u:$bbcode_uid", ":o:$bbcode_uid", ":$bbcode_uid"); - $replace = array("\n", '', '', '', ''); - } - else - { - $match = array('
'); - $replace = array("\n"); - } - - $message = str_replace($match, $replace, $message); - - $match = get_preg_expression('bbcode_htm'); - $replace = array('\1', '\1', '\2', '\2', '\1', '', ''); - - $message = preg_replace($match, $replace, $message); - } - - /** - * Use this event to modify the message after it is decoded - * - * @event core.decode_message_after - * @var string message_text The message content - * @var string bbcode_uid The message BBCode UID - * @since 3.1.9-RC1 - */ - $message_text = $message; - $vars = array('message_text', 'bbcode_uid'); - extract($phpbb_dispatcher->trigger_event('core.decode_message_after', compact($vars))); - $message = $message_text; -} - -/** -* Strips all bbcode from a text in place -*/ -function strip_bbcode(&$text, $uid = '') -{ - global $phpbb_container; - - if (preg_match('#^<[rt][ >]#', $text)) - { - $text = $phpbb_container->get('text_formatter.utils')->clean_formatting($text); - } - else - { - if (!$uid) - { - $uid = '[0-9a-z]{5,}'; - } - - $text = preg_replace("#\[\/?[a-z0-9\*\+\-]+(?:=(?:".*"|[^\]]*))?(?::[a-z])?(\:$uid)\]#", ' ', $text); - - $match = get_preg_expression('bbcode_htm'); - $replace = array('\1', '\1', '\2', '\1', '', ''); - - $text = preg_replace($match, $replace, $text); - } -} - -/** -* For display of custom parsed text on user-facing pages -* Expects $text to be the value directly from the database (stored value) -*/ -function generate_text_for_display($text, $uid, $bitfield, $flags, $censor_text = true) -{ - static $bbcode; - global $auth, $config, $user; - global $phpbb_dispatcher, $phpbb_container; - - if ($text === '') - { - return ''; - } - - /** - * Use this event to modify the text before it is parsed - * - * @event core.modify_text_for_display_before - * @var string text The text to parse - * @var string uid The BBCode UID - * @var string bitfield The BBCode Bitfield - * @var int flags The BBCode Flags - * @var bool censor_text Whether or not to apply word censors - * @since 3.1.0-a1 - */ - $vars = array('text', 'uid', 'bitfield', 'flags', 'censor_text'); - extract($phpbb_dispatcher->trigger_event('core.modify_text_for_display_before', compact($vars))); - - if (preg_match('#^<[rt][ >]#', $text)) - { - $renderer = $phpbb_container->get('text_formatter.renderer'); - - // Temporarily switch off viewcensors if applicable - $old_censor = $renderer->get_viewcensors(); - - // Check here if the user is having viewing censors disabled (and also allowed to do so). - if (!$user->optionget('viewcensors') && $config['allow_nocensors'] && $auth->acl_get('u_chgcensors')) - { - $censor_text = false; - } - - if ($old_censor !== $censor_text) - { - $renderer->set_viewcensors($censor_text); - } - - $text = $renderer->render($text); - - // Restore the previous value - if ($old_censor !== $censor_text) - { - $renderer->set_viewcensors($old_censor); - } - } - else - { - if ($censor_text) - { - $text = censor_text($text); - } - - // Parse bbcode if bbcode uid stored and bbcode enabled - if ($uid && ($flags & OPTION_FLAG_BBCODE)) - { - if (!class_exists('bbcode')) - { - global $phpbb_root_path, $phpEx; - include($phpbb_root_path . 'includes/bbcode.' . $phpEx); - } - - if (empty($bbcode)) - { - $bbcode = new bbcode($bitfield); - } - else - { - $bbcode->bbcode_set_bitfield($bitfield); - } - - $bbcode->bbcode_second_pass($text, $uid); - } - - $text = bbcode_nl2br($text); - $text = smiley_text($text, !($flags & OPTION_FLAG_SMILIES)); - } - - /** - * Use this event to modify the text after it is parsed - * - * @event core.modify_text_for_display_after - * @var string text The text to parse - * @var string uid The BBCode UID - * @var string bitfield The BBCode Bitfield - * @var int flags The BBCode Flags - * @since 3.1.0-a1 - */ - $vars = array('text', 'uid', 'bitfield', 'flags'); - extract($phpbb_dispatcher->trigger_event('core.modify_text_for_display_after', compact($vars))); - - return $text; -} - -/** -* For parsing custom parsed text to be stored within the database. -* This function additionally returns the uid and bitfield that needs to be stored. -* Expects $text to be the value directly from $request->variable() and in it's non-parsed form -* -* @param string $text The text to be replaced with the parsed one -* @param string $uid The BBCode uid for this parse -* @param string $bitfield The BBCode bitfield for this parse -* @param int $flags The allow_bbcode, allow_urls and allow_smilies compiled into a single integer. -* @param bool $allow_bbcode If BBCode is allowed (i.e. if BBCode is parsed) -* @param bool $allow_urls If urls is allowed -* @param bool $allow_smilies If smilies are allowed -* @param bool $allow_img_bbcode -* @param bool $allow_flash_bbcode -* @param bool $allow_quote_bbcode -* @param bool $allow_url_bbcode -* @param string $mode Mode to parse text as, e.g. post or sig -* -* @return array An array of string with the errors that occurred while parsing -*/ -function generate_text_for_storage(&$text, &$uid, &$bitfield, &$flags, $allow_bbcode = false, $allow_urls = false, $allow_smilies = false, $allow_img_bbcode = true, $allow_flash_bbcode = true, $allow_quote_bbcode = true, $allow_url_bbcode = true, $mode = 'post') -{ - global $phpbb_root_path, $phpEx, $phpbb_dispatcher; - - /** - * Use this event to modify the text before it is prepared for storage - * - * @event core.modify_text_for_storage_before - * @var string text The text to parse - * @var string uid The BBCode UID - * @var string bitfield The BBCode Bitfield - * @var int flags The BBCode Flags - * @var bool allow_bbcode Whether or not to parse BBCode - * @var bool allow_urls Whether or not to parse URLs - * @var bool allow_smilies Whether or not to parse Smilies - * @var bool allow_img_bbcode Whether or not to parse the [img] BBCode - * @var bool allow_flash_bbcode Whether or not to parse the [flash] BBCode - * @var bool allow_quote_bbcode Whether or not to parse the [quote] BBCode - * @var bool allow_url_bbcode Whether or not to parse the [url] BBCode - * @var string mode Mode to parse text as, e.g. post or sig - * @since 3.1.0-a1 - * @changed 3.2.0-a1 Added mode - */ - $vars = array( - 'text', - 'uid', - 'bitfield', - 'flags', - 'allow_bbcode', - 'allow_urls', - 'allow_smilies', - 'allow_img_bbcode', - 'allow_flash_bbcode', - 'allow_quote_bbcode', - 'allow_url_bbcode', - 'mode', - ); - extract($phpbb_dispatcher->trigger_event('core.modify_text_for_storage_before', compact($vars))); - - $uid = $bitfield = ''; - $flags = (($allow_bbcode) ? OPTION_FLAG_BBCODE : 0) + (($allow_smilies) ? OPTION_FLAG_SMILIES : 0) + (($allow_urls) ? OPTION_FLAG_LINKS : 0); - - if (!class_exists('parse_message')) - { - include($phpbb_root_path . 'includes/message_parser.' . $phpEx); - } - - $message_parser = new parse_message($text); - $message_parser->parse($allow_bbcode, $allow_urls, $allow_smilies, $allow_img_bbcode, $allow_flash_bbcode, $allow_quote_bbcode, $allow_url_bbcode, true, $mode); - - $text = $message_parser->message; - $uid = $message_parser->bbcode_uid; - - // If the bbcode_bitfield is empty, there is no need for the uid to be stored. - if (!$message_parser->bbcode_bitfield) - { - $uid = ''; - } - - $bitfield = $message_parser->bbcode_bitfield; - - /** - * Use this event to modify the text after it is prepared for storage - * - * @event core.modify_text_for_storage_after - * @var string text The text to parse - * @var string uid The BBCode UID - * @var string bitfield The BBCode Bitfield - * @var int flags The BBCode Flags - * @var string message_parser The message_parser object - * @since 3.1.0-a1 - * @changed 3.1.11-RC1 Added message_parser to vars - */ - $vars = array('text', 'uid', 'bitfield', 'flags', 'message_parser'); - extract($phpbb_dispatcher->trigger_event('core.modify_text_for_storage_after', compact($vars))); - - return $message_parser->warn_msg; -} - -/** -* For decoding custom parsed text for edits as well as extracting the flags -* Expects $text to be the value directly from the database (pre-parsed content) -*/ -function generate_text_for_edit($text, $uid, $flags) -{ - global $phpbb_dispatcher; - - /** - * Use this event to modify the text before it is decoded for editing - * - * @event core.modify_text_for_edit_before - * @var string text The text to parse - * @var string uid The BBCode UID - * @var int flags The BBCode Flags - * @since 3.1.0-a1 - */ - $vars = array('text', 'uid', 'flags'); - extract($phpbb_dispatcher->trigger_event('core.modify_text_for_edit_before', compact($vars))); - - decode_message($text, $uid); - - /** - * Use this event to modify the text after it is decoded for editing - * - * @event core.modify_text_for_edit_after - * @var string text The text to parse - * @var int flags The BBCode Flags - * @since 3.1.0-a1 - */ - $vars = array('text', 'flags'); - extract($phpbb_dispatcher->trigger_event('core.modify_text_for_edit_after', compact($vars))); - - return array( - 'allow_bbcode' => ($flags & OPTION_FLAG_BBCODE) ? 1 : 0, - 'allow_smilies' => ($flags & OPTION_FLAG_SMILIES) ? 1 : 0, - 'allow_urls' => ($flags & OPTION_FLAG_LINKS) ? 1 : 0, - 'text' => $text - ); -} - -/** -* A subroutine of make_clickable used with preg_replace -* It places correct HTML around an url, shortens the displayed text -* and makes sure no entities are inside URLs -*/ -function make_clickable_callback($type, $whitespace, $url, $relative_url, $class) -{ - $orig_url = $url; - $orig_relative = $relative_url; - $append = ''; - $url = htmlspecialchars_decode($url); - $relative_url = htmlspecialchars_decode($relative_url); - - // make sure no HTML entities were matched - $chars = array('<', '>', '"'); - $split = false; - - foreach ($chars as $char) - { - $next_split = strpos($url, $char); - if ($next_split !== false) - { - $split = ($split !== false) ? min($split, $next_split) : $next_split; - } - } - - if ($split !== false) - { - // an HTML entity was found, so the URL has to end before it - $append = substr($url, $split) . $relative_url; - $url = substr($url, 0, $split); - $relative_url = ''; - } - else if ($relative_url) - { - // same for $relative_url - $split = false; - foreach ($chars as $char) - { - $next_split = strpos($relative_url, $char); - if ($next_split !== false) - { - $split = ($split !== false) ? min($split, $next_split) : $next_split; - } - } - - if ($split !== false) - { - $append = substr($relative_url, $split); - $relative_url = substr($relative_url, 0, $split); - } - } - - // if the last character of the url is a punctuation mark, exclude it from the url - $last_char = ($relative_url) ? $relative_url[strlen($relative_url) - 1] : $url[strlen($url) - 1]; - - switch ($last_char) - { - case '.': - case '?': - case '!': - case ':': - case ',': - $append = $last_char; - if ($relative_url) - { - $relative_url = substr($relative_url, 0, -1); - } - else - { - $url = substr($url, 0, -1); - } - break; - - // set last_char to empty here, so the variable can be used later to - // check whether a character was removed - default: - $last_char = ''; - break; - } - - $short_url = (utf8_strlen($url) > 55) ? utf8_substr($url, 0, 39) . ' ... ' . utf8_substr($url, -10) : $url; - - switch ($type) - { - case MAGIC_URL_LOCAL: - $tag = 'l'; - $relative_url = preg_replace('/[&?]sid=[0-9a-f]{32}$/', '', preg_replace('/([&?])sid=[0-9a-f]{32}&/', '$1', $relative_url)); - $url = $url . '/' . $relative_url; - $text = $relative_url; - - // this url goes to http://domain.tld/path/to/board/ which - // would result in an empty link if treated as local so - // don't touch it and let MAGIC_URL_FULL take care of it. - if (!$relative_url) - { - return $whitespace . $orig_url . '/' . $orig_relative; // slash is taken away by relative url pattern - } - break; - - case MAGIC_URL_FULL: - $tag = 'm'; - $text = $short_url; - break; - - case MAGIC_URL_WWW: - $tag = 'w'; - $url = 'http://' . $url; - $text = $short_url; - break; - - case MAGIC_URL_EMAIL: - $tag = 'e'; - $text = $short_url; - $url = 'mailto:' . $url; - break; - } - - $url = htmlspecialchars($url); - $text = htmlspecialchars($text); - $append = htmlspecialchars($append); - - $html = "$whitespace$text$append"; - - return $html; -} - -/** -* make_clickable function -* -* Replace magic urls of form http://xxx.xxx., www.xxx. and xxx@xxx.xxx. -* Cuts down displayed size of link if over 50 chars, turns absolute links -* into relative versions when the server/script path matches the link -*/ -function make_clickable($text, $server_url = false, $class = 'postlink') -{ - if ($server_url === false) - { - $server_url = generate_board_url(); - } - - static $static_class; - static $magic_url_match_args; - - if (!isset($magic_url_match_args[$server_url]) || $static_class != $class) - { - $static_class = $class; - $class = ($static_class) ? ' class="' . $static_class . '"' : ''; - $local_class = ($static_class) ? ' class="' . $static_class . '-local"' : ''; - - if (!is_array($magic_url_match_args)) - { - $magic_url_match_args = array(); - } - - // relative urls for this board - $magic_url_match_args[$server_url][] = array( - '#(^|[\n\t (>.])(' . preg_quote($server_url, '#') . ')/(' . get_preg_expression('relative_url_inline') . ')#iu', - MAGIC_URL_LOCAL, - $local_class, - ); - - // matches a xxxx://aaaaa.bbb.cccc. ... - $magic_url_match_args[$server_url][] = array( - '#(^|[\n\t (>.])(' . get_preg_expression('url_inline') . ')#iu', - MAGIC_URL_FULL, - $class, - ); - - // matches a "www.xxxx.yyyy[/zzzz]" kinda lazy URL thing - $magic_url_match_args[$server_url][] = array( - '#(^|[\n\t (>])(' . get_preg_expression('www_url_inline') . ')#iu', - MAGIC_URL_WWW, - $class, - ); - - // matches an email@domain type address at the start of a line, or after a space or after what might be a BBCode. - $magic_url_match_args[$server_url][] = array( - '/(^|[\n\t (>])(' . get_preg_expression('email') . ')/iu', - MAGIC_URL_EMAIL, - '', - ); - } - - foreach ($magic_url_match_args[$server_url] as $magic_args) - { - if (preg_match($magic_args[0], $text, $matches)) - { - $text = preg_replace_callback($magic_args[0], function($matches) use ($magic_args) - { - $relative_url = isset($matches[3]) ? $matches[3] : ''; - return make_clickable_callback($magic_args[1], $matches[1], $matches[2], $relative_url, $magic_args[2]); - }, $text); - } - } - - return $text; -} - -/** -* Censoring -*/ -function censor_text($text) -{ - static $censors; - - // Nothing to do? - if ($text === '') - { - return ''; - } - - // We moved the word censor checks in here because we call this function quite often - and then only need to do the check once - if (!isset($censors) || !is_array($censors)) - { - global $config, $user, $auth, $cache; - - // We check here if the user is having viewing censors disabled (and also allowed to do so). - if (!$user->optionget('viewcensors') && $config['allow_nocensors'] && $auth->acl_get('u_chgcensors')) - { - $censors = array(); - } - else - { - $censors = $cache->obtain_word_list(); - } - } - - if (count($censors)) - { - return preg_replace($censors['match'], $censors['replace'], $text); - } - - return $text; -} - -/** -* custom version of nl2br which takes custom BBCodes into account -*/ -function bbcode_nl2br($text) -{ - // custom BBCodes might contain carriage returns so they - // are not converted into
so now revert that - $text = str_replace(array("\n", "\r"), array('
', "\n"), $text); - return $text; -} - -/** -* Smiley processing -*/ -function smiley_text($text, $force_option = false) -{ - global $config, $user, $phpbb_path_helper, $phpbb_dispatcher; - - if ($force_option || !$config['allow_smilies'] || !$user->optionget('viewsmilies')) - { - return preg_replace('##', ''; - } - } - - $filesize = get_formatted_filesize($attachment['filesize'], false); - - $comment = bbcode_nl2br(censor_text($attachment['attach_comment'])); - - $block_array += array( - 'UPLOAD_ICON' => $upload_icon, - 'FILESIZE' => $filesize['value'], - 'SIZE_LANG' => $filesize['unit'], - 'DOWNLOAD_NAME' => utf8_basename($attachment['real_filename']), - 'COMMENT' => $comment, - ); - - $denied = false; - - if (!extension_allowed($forum_id, $attachment['extension'], $extensions)) - { - $denied = true; - - $block_array += array( - 'S_DENIED' => true, - 'DENIED_MESSAGE' => sprintf($user->lang['EXTENSION_DISABLED_AFTER_POSTING'], $attachment['extension']) - ); - } - - if (!$denied) - { - $display_cat = $extensions[$attachment['extension']]['display_cat']; - - if ($display_cat == ATTACHMENT_CATEGORY_IMAGE) - { - if ($attachment['thumbnail']) - { - $display_cat = ATTACHMENT_CATEGORY_THUMB; - } - else - { - if ($config['img_display_inlined']) - { - if ($config['img_link_width'] || $config['img_link_height']) - { - $dimension = @getimagesize($filename); - - // If the dimensions could not be determined or the image being 0x0 we display it as a link for safety purposes - if ($dimension === false || empty($dimension[0]) || empty($dimension[1])) - { - $display_cat = ATTACHMENT_CATEGORY_NONE; - } - else - { - $display_cat = ($dimension[0] <= $config['img_link_width'] && $dimension[1] <= $config['img_link_height']) ? ATTACHMENT_CATEGORY_IMAGE : ATTACHMENT_CATEGORY_NONE; - } - } - } - else - { - $display_cat = ATTACHMENT_CATEGORY_NONE; - } - } - } - - // Make some descisions based on user options being set. - if (($display_cat == ATTACHMENT_CATEGORY_IMAGE || $display_cat == ATTACHMENT_CATEGORY_THUMB) && !$user->optionget('viewimg')) - { - $display_cat = ATTACHMENT_CATEGORY_NONE; - } - - $download_link = append_sid("{$phpbb_root_path}download/file.$phpEx", 'id=' . $attachment['attach_id']); - $l_downloaded_viewed = 'VIEWED_COUNTS'; - - switch ($display_cat) - { - // Images - case ATTACHMENT_CATEGORY_IMAGE: - $inline_link = append_sid("{$phpbb_root_path}download/file.$phpEx", 'id=' . $attachment['attach_id']); - $download_link .= '&mode=view'; - - $block_array += array( - 'S_IMAGE' => true, - 'U_INLINE_LINK' => $inline_link, - ); - - $update_count_ary[] = $attachment['attach_id']; - break; - - // Images, but display Thumbnail - case ATTACHMENT_CATEGORY_THUMB: - $thumbnail_link = append_sid("{$phpbb_root_path}download/file.$phpEx", 'id=' . $attachment['attach_id'] . '&t=1'); - $download_link .= '&mode=view'; - - $block_array += array( - 'S_THUMBNAIL' => true, - 'THUMB_IMAGE' => $thumbnail_link, - ); - - $update_count_ary[] = $attachment['attach_id']; - break; - - default: - $l_downloaded_viewed = 'DOWNLOAD_COUNTS'; - - $block_array += array( - 'S_FILE' => true, - ); - break; - } - - if (!isset($attachment['download_count'])) - { - $attachment['download_count'] = 0; - } - - $block_array += array( - 'U_DOWNLOAD_LINK' => $download_link, - 'L_DOWNLOAD_COUNT' => $user->lang($l_downloaded_viewed, (int) $attachment['download_count']), - ); - } - - $update_count = $update_count_ary; - /** - * Use this event to modify the attachment template data. - * - * This event is triggered once per attachment. - * - * @event core.parse_attachments_modify_template_data - * @var array attachment Array with attachment data - * @var array block_array Template data of the attachment - * @var int display_cat Attachment category data - * @var string download_link Attachment download link - * @var array extensions Array with attachment extensions data - * @var mixed forum_id The forum id the attachments are displayed in (false if in private message) - * @var bool preview Flag indicating if we are in post preview mode - * @var array update_count Array with attachment ids to update download count - * @since 3.1.0-RC5 - */ - $vars = array( - 'attachment', - 'block_array', - 'display_cat', - 'download_link', - 'extensions', - 'forum_id', - 'preview', - 'update_count', - ); - extract($phpbb_dispatcher->trigger_event('core.parse_attachments_modify_template_data', compact($vars))); - $update_count_ary = $update_count; - unset($update_count); - - $template->assign_block_vars('_file', $block_array); - - $compiled_attachments[] = $template->assign_display('attachment_tpl'); - } - - $attachments = $compiled_attachments; - unset($compiled_attachments); - - $unset_tpl = array(); - - preg_match_all('#(.*?)#', $message, $matches, PREG_PATTERN_ORDER); - - $replace = array(); - foreach ($matches[0] as $num => $capture) - { - $index = $matches[1][$num]; - - $replace['from'][] = $matches[0][$num]; - $replace['to'][] = (isset($attachments[$index])) ? $attachments[$index] : sprintf($user->lang['MISSING_INLINE_ATTACHMENT'], $matches[2][array_search($index, $matches[1])]); - - $unset_tpl[] = $index; - } - - if (isset($replace['from'])) - { - $message = str_replace($replace['from'], $replace['to'], $message); - } - - $unset_tpl = array_unique($unset_tpl); - - // Sort correctly - if ($config['display_order']) - { - // Ascending sort - krsort($attachments); - } - else - { - // Descending sort - ksort($attachments); - } - - // Needed to let not display the inlined attachments at the end of the post again - foreach ($unset_tpl as $index) - { - unset($attachments[$index]); - } -} - -/** -* Check if extension is allowed to be posted. -* -* @param mixed $forum_id The forum id to check or false if private message -* @param string $extension The extension to check, for example zip. -* @param array &$extensions The extension array holding the information from the cache (will be obtained if empty) -* -* @return bool False if the extension is not allowed to be posted, else true. -*/ -function extension_allowed($forum_id, $extension, &$extensions) -{ - if (empty($extensions)) - { - global $cache; - $extensions = $cache->obtain_attach_extensions($forum_id); - } - - return (!isset($extensions['_allowed_'][$extension])) ? false : true; -} - -/** -* Truncates string while retaining special characters if going over the max length -* The default max length is 60 at the moment -* The maximum storage length is there to fit the string within the given length. The string may be further truncated due to html entities. -* For example: string given is 'a "quote"' (length: 9), would be a stored as 'a "quote"' (length: 19) -* -* @param string $string The text to truncate to the given length. String is specialchared. -* @param int $max_length Maximum length of string (multibyte character count as 1 char / Html entity count as 1 char) -* @param int $max_store_length Maximum character length of string (multibyte character count as 1 char / Html entity count as entity chars). -* @param bool $allow_reply Allow Re: in front of string -* NOTE: This parameter can cause undesired behavior (returning strings longer than $max_store_length) and is deprecated. -* @param string $append String to be appended -*/ -function truncate_string($string, $max_length = 60, $max_store_length = 255, $allow_reply = false, $append = '') -{ - $strip_reply = false; - $stripped = false; - if ($allow_reply && strpos($string, 'Re: ') === 0) - { - $strip_reply = true; - $string = substr($string, 4); - } - - $_chars = utf8_str_split(htmlspecialchars_decode($string)); - $chars = array_map('utf8_htmlspecialchars', $_chars); - - // Now check the length ;) - if (count($chars) > $max_length) - { - // Cut off the last elements from the array - $string = implode('', array_slice($chars, 0, $max_length - utf8_strlen($append))); - $stripped = true; - } - - // Due to specialchars, we may not be able to store the string... - if (utf8_strlen($string) > $max_store_length) - { - // let's split again, we do not want half-baked strings where entities are split - $_chars = utf8_str_split(htmlspecialchars_decode($string)); - $chars = array_map('utf8_htmlspecialchars', $_chars); - - do - { - array_pop($chars); - $string = implode('', $chars); - } - while (!empty($chars) && utf8_strlen($string) > $max_store_length); - } - - if ($strip_reply) - { - $string = 'Re: ' . $string; - } - - if ($append != '' && $stripped) - { - $string = $string . $append; - } - - return $string; -} - -/** -* Get username details for placing into templates. -* This function caches all modes on first call, except for no_profile and anonymous user - determined by $user_id. -* -* @html Username spans and links -* -* @param string $mode Can be profile (for getting an url to the profile), username (for obtaining the username), colour (for obtaining the user colour), full (for obtaining a html string representing a coloured link to the users profile) or no_profile (the same as full but forcing no profile link) -* @param int $user_id The users id -* @param string $username The users name -* @param string $username_colour The users colour -* @param string $guest_username optional parameter to specify the guest username. It will be used in favor of the GUEST language variable then. -* @param string $custom_profile_url optional parameter to specify a profile url. The user id get appended to this url as &u={user_id} -* -* @return string A string consisting of what is wanted based on $mode. -*/ -function get_username_string($mode, $user_id, $username, $username_colour = '', $guest_username = false, $custom_profile_url = false) -{ - static $_profile_cache; - global $phpbb_dispatcher; - - // We cache some common variables we need within this function - if (empty($_profile_cache)) - { - global $phpbb_root_path, $phpEx; - - /** @html Username spans and links for usage in the template */ - $_profile_cache['base_url'] = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u={USER_ID}'); - $_profile_cache['tpl_noprofile'] = '{USERNAME}'; - $_profile_cache['tpl_noprofile_colour'] = '{USERNAME}'; - $_profile_cache['tpl_profile'] = '{USERNAME}'; - $_profile_cache['tpl_profile_colour'] = '{USERNAME}'; - } - - global $user, $auth; - - // This switch makes sure we only run code required for the mode - switch ($mode) - { - case 'full': - case 'no_profile': - case 'colour': - - // Build correct username colour - $username_colour = ($username_colour) ? '#' . $username_colour : ''; - - // Return colour - if ($mode == 'colour') - { - $username_string = $username_colour; - break; - } - - // no break; - - case 'username': - - // Build correct username - if ($guest_username === false) - { - $username = ($username) ? $username : $user->lang['GUEST']; - } - else - { - $username = ($user_id && $user_id != ANONYMOUS) ? $username : ((!empty($guest_username)) ? $guest_username : $user->lang['GUEST']); - } - - // Return username - if ($mode == 'username') - { - $username_string = $username; - break; - } - - // no break; - - case 'profile': - - // Build correct profile url - only show if not anonymous and permission to view profile if registered user - // For anonymous the link leads to a login page. - if ($user_id && $user_id != ANONYMOUS && ($user->data['user_id'] == ANONYMOUS || $auth->acl_get('u_viewprofile'))) - { - $profile_url = ($custom_profile_url !== false) ? $custom_profile_url . '&u=' . (int) $user_id : str_replace(array('={USER_ID}', '=%7BUSER_ID%7D'), '=' . (int) $user_id, $_profile_cache['base_url']); - } - else - { - $profile_url = ''; - } - - // Return profile - if ($mode == 'profile') - { - $username_string = $profile_url; - break; - } - - // no break; - } - - if (!isset($username_string)) - { - if (($mode == 'full' && !$profile_url) || $mode == 'no_profile') - { - $username_string = str_replace(array('{USERNAME_COLOUR}', '{USERNAME}'), array($username_colour, $username), (!$username_colour) ? $_profile_cache['tpl_noprofile'] : $_profile_cache['tpl_noprofile_colour']); - } - else - { - $username_string = str_replace(array('{PROFILE_URL}', '{USERNAME_COLOUR}', '{USERNAME}'), array($profile_url, $username_colour, $username), (!$username_colour) ? $_profile_cache['tpl_profile'] : $_profile_cache['tpl_profile_colour']); - } - } - - /** - * Use this event to change the output of get_username_string() - * - * @event core.modify_username_string - * @var string mode profile|username|colour|full|no_profile - * @var int user_id String or array of additional url - * parameters - * @var string username The user's username - * @var string username_colour The user's colour - * @var string guest_username Optional parameter to specify the - * guest username. - * @var string custom_profile_url Optional parameter to specify a - * profile url. - * @var string username_string The string that has been generated - * @var array _profile_cache Array of original return templates - * @since 3.1.0-a1 - */ - $vars = array( - 'mode', - 'user_id', - 'username', - 'username_colour', - 'guest_username', - 'custom_profile_url', - 'username_string', - '_profile_cache', - ); - extract($phpbb_dispatcher->trigger_event('core.modify_username_string', compact($vars))); - - return $username_string; -} - -/** - * Add an option to the quick-mod tools. - * - * @param string $url The recepting URL for the quickmod actions. - * @param string $option The language key for the value of the option. - * @param string $lang_string The language string to use. - */ -function phpbb_add_quickmod_option($url, $option, $lang_string) -{ - global $template, $user, $phpbb_path_helper; - - $lang_string = $user->lang($lang_string); - $template->assign_block_vars('quickmod', array( - 'VALUE' => $option, - 'TITLE' => $lang_string, - 'LINK' => $phpbb_path_helper->append_url_params($url, array('action' => $option)), - )); -} - -/** -* Concatenate an array into a string list. -* -* @param array $items Array of items to concatenate -* @param object $user The phpBB $user object. -* -* @return string String list. Examples: "A"; "A and B"; "A, B, and C" -*/ -function phpbb_generate_string_list($items, $user) -{ - if (empty($items)) - { - return ''; - } - - $count = count($items); - $last_item = array_pop($items); - $lang_key = 'STRING_LIST_MULTI'; - - if ($count == 1) - { - return $last_item; - } - else if ($count == 2) - { - $lang_key = 'STRING_LIST_SIMPLE'; - } - $list = implode($user->lang['COMMA_SEPARATOR'], $items); - - return $user->lang($lang_key, $list, $last_item); -} - -class bitfield -{ - var $data; - - function __construct($bitfield = '') - { - $this->data = base64_decode($bitfield); - } - - /** - */ - function get($n) - { - // Get the ($n / 8)th char - $byte = $n >> 3; - - if (strlen($this->data) >= $byte + 1) - { - $c = $this->data[$byte]; - - // Lookup the ($n % 8)th bit of the byte - $bit = 7 - ($n & 7); - return (bool) (ord($c) & (1 << $bit)); - } - else - { - return false; - } - } - - function set($n) - { - $byte = $n >> 3; - $bit = 7 - ($n & 7); - - if (strlen($this->data) >= $byte + 1) - { - $this->data[$byte] = $this->data[$byte] | chr(1 << $bit); - } - else - { - $this->data .= str_repeat("\0", $byte - strlen($this->data)); - $this->data .= chr(1 << $bit); - } - } - - function clear($n) - { - $byte = $n >> 3; - - if (strlen($this->data) >= $byte + 1) - { - $bit = 7 - ($n & 7); - $this->data[$byte] = $this->data[$byte] &~ chr(1 << $bit); - } - } - - function get_blob() - { - return $this->data; - } - - function get_base64() - { - return base64_encode($this->data); - } - - function get_bin() - { - $bin = ''; - $len = strlen($this->data); - - for ($i = 0; $i < $len; ++$i) - { - $bin .= str_pad(decbin(ord($this->data[$i])), 8, '0', STR_PAD_LEFT); - } - - return $bin; - } - - function get_all_set() - { - return array_keys(array_filter(str_split($this->get_bin()))); - } - - function merge($bitfield) - { - $this->data = $this->data | $bitfield->get_blob(); - } -} - -/** - * Formats the quote according to the given BBCode status setting - * - * @param phpbb\language\language $language Language class - * @param parse_message $message_parser Message parser class - * @param phpbb\textformatter\utils_interface $text_formatter_utils Text formatter utilities - * @param bool $bbcode_status The status of the BBCode setting - * @param array $quote_attributes The attributes of the quoted post - * @param string $message_link Link of the original quoted post - */ -function phpbb_format_quote($language, $message_parser, $text_formatter_utils, $bbcode_status, $quote_attributes, $message_link = '') -{ - if ($bbcode_status) - { - $quote_text = $text_formatter_utils->generate_quote( - censor_text($message_parser->message), - $quote_attributes - ); - - $message_parser->message = $quote_text . "\n\n"; - } - else - { - $offset = 0; - $quote_string = "> "; - $message = censor_text(trim($message_parser->message)); - // see if we are nesting. It's easily tricked but should work for one level of nesting - if (strpos($message, ">") !== false) - { - $offset = 10; - } - $message = utf8_wordwrap($message, 75 + $offset, "\n"); - - $message = $quote_string . $message; - $message = str_replace("\n", "\n" . $quote_string, $message); - - $message_parser->message = $quote_attributes['author'] . " " . $language->lang('WROTE') . ":\n" . $message . "\n"; - } - - if ($message_link) - { - $message_parser->message = $message_link . $message_parser->message; - } -} diff --git a/install/update/new/includes/functions_convert.php b/install/update/new/includes/functions_convert.php deleted file mode 100644 index 96e1087..0000000 --- a/install/update/new/includes/functions_convert.php +++ /dev/null @@ -1,2500 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* Default avatar width/height -* @ignore -*/ -define('DEFAULT_AVATAR_X', 80); -define('DEFAULT_AVATAR_Y', 80); - -// Global functions - all functions can be used by convertors - -// SIMPLE FUNCTIONS - -/** -* Return the preceding value -*/ -function dec($var) -{ - return --$var; -} - -/** -* Return the next value -*/ -function inc($var) -{ - return ++$var; -} - -/** -* Return whether the value is positive -*/ -function is_positive($n) -{ - return ($n > 0) ? 1 : 0; -} - -/** -* Boolean inverse of the value -*/ -function not($var) -{ - return ($var) ? 0 : 1; -} - -/** -* Convert a textual value to it's equivalent boolean value -* -* @param string $str String to convert (converts yes, on, y, 1 and true to boolean true) -* @return boolean The equivalent value -*/ -function str_to_bool($str) -{ - $str = strtolower($str); - return ($str == 'yes' || $str == 'on' || $str == 'y' || $str == 'true' || $str == '1') ? true : false; -} - -/** -* Function to mimic php's empty() function (it is the same) -*/ -function is_empty($mixed) -{ - return empty($mixed); -} - -/** -* Convert the name of a user's primary group to the appropriate equivalent phpBB group id -* -* @param string $status The name of the group -* @return int The group_id corresponding to the equivalent group -*/ -function str_to_primary_group($status) -{ - switch (ucfirst(strtolower($status))) - { - case 'Administrator': - return get_group_id('administrators'); - break; - - case 'Super moderator': - case 'Global moderator': - case 'Moderator': - return get_group_id('global_moderators'); - break; - - case 'Guest': - case 'Anonymous': - return get_group_id('guests'); - break; - - default: - return get_group_id('registered'); - break; - } -} - -/** -* Convert a boolean into the appropriate phpBB constant indicating whether the item is locked -*/ -function is_item_locked($bool) -{ - return ($bool) ? ITEM_LOCKED : ITEM_UNLOCKED; -} - -/** -* Convert a value from days to seconds -*/ -function days_to_seconds($days) -{ - return ($days * 86400); -} - -/** -* Determine whether a user is anonymous and return the appropriate new user_id -*/ -function is_user_anonymous($user_id) -{ - return ($user_id > ANONYMOUS) ? $user_id : ANONYMOUS; -} - -/** -* Generate a key value based on existing values -* -* @param int $pad Amount to add to the maximum value -* @return int Key value -*/ -function auto_id($pad = 0) -{ - global $auto_id, $convert_row; - - if (!empty($convert_row['max_id'])) - { - return $convert_row['max_id'] + $pad; - } - - return $auto_id + $pad; -} - -/** -* Convert a boolean into the appropriate phpBB constant indicating whether the user is active -*/ -function set_user_type($user_active) -{ - return ($user_active) ? USER_NORMAL : USER_INACTIVE; -} - -/** -* Convert a value from minutes to hours -*/ -function minutes_to_hours($minutes) -{ - return ($minutes / 3600); -} - -/** -* Return the group_id for a given group name -*/ -function get_group_id($group_name) -{ - global $db, $group_mapping; - - if (empty($group_mapping)) - { - $sql = 'SELECT group_name, group_id - FROM ' . GROUPS_TABLE; - $result = $db->sql_query($sql); - - $group_mapping = array(); - while ($row = $db->sql_fetchrow($result)) - { - $group_mapping[strtoupper($row['group_name'])] = (int) $row['group_id']; - } - $db->sql_freeresult($result); - } - - if (!count($group_mapping)) - { - add_default_groups(); - return get_group_id($group_name); - } - - if (isset($group_mapping[strtoupper($group_name)])) - { - return $group_mapping[strtoupper($group_name)]; - } - - return $group_mapping['REGISTERED']; -} - -/** -* Convert a boolean into the appropriate phpBB constant indicating whether the topic is locked -*/ -function is_topic_locked($bool) -{ - return (!empty($bool)) ? ITEM_LOCKED : ITEM_UNLOCKED; -} - -/** -* Generate a bbcode_uid value -*/ -function make_uid($timestamp) -{ - static $last_timestamp, $last_uid; - - if (empty($last_timestamp) || $timestamp != $last_timestamp) - { - $last_uid = substr(base_convert(unique_id(), 16, 36), 0, BBCODE_UID_LEN); - } - $last_timestamp = $timestamp; - return $last_uid; -} - - -/** -* Validate a website address -*/ -function validate_website($url) -{ - if ($url === 'http://') - { - return ''; - } - else if (!preg_match('#^http[s]?://#i', $url) && strlen($url) > 0) - { - return 'http://' . $url; - } - return $url; -} - -/** -* Convert nulls to zeros for fields which allowed a NULL value in the source but not the destination -*/ -function null_to_zero($value) -{ - return ($value === NULL) ? 0 : $value; -} - -/** -* Convert nulls to empty strings for fields which allowed a NULL value in the source but not the destination -*/ -function null_to_str($value) -{ - return ($value === NULL) ? '' : $value; -} - -// EXTENDED FUNCTIONS - -/** -* Get old config value -*/ -function get_config_value($config_name) -{ - static $convert_config; - - if (!isset($convert_config)) - { - $convert_config = get_config(); - } - - if (!isset($convert_config[$config_name])) - { - return false; - } - - return (empty($convert_config[$config_name])) ? '' : $convert_config[$config_name]; -} - -/** -* Convert an IP address from the hexadecimal notation to normal dotted-quad notation -*/ -function decode_ip($int_ip) -{ - if (!$int_ip) - { - return $int_ip; - } - - $hexipbang = explode('.', chunk_split($int_ip, 2, '.')); - - // Any mod changing the way ips are stored? Then we are not able to convert and enter the ip "as is" to not "destroy" anything... - if (count($hexipbang) < 4) - { - return $int_ip; - } - - return hexdec($hexipbang[0]) . '.' . hexdec($hexipbang[1]) . '.' . hexdec($hexipbang[2]) . '.' . hexdec($hexipbang[3]); -} - -/** -* Reverse the encoding of wild-carded bans -*/ -function decode_ban_ip($int_ip) -{ - return str_replace('255', '*', decode_ip($int_ip)); -} - -/** -* Determine the MIME-type of a specified filename -* This does not actually inspect the file, but simply uses the file extension -*/ -function mimetype($filename) -{ - if (!preg_match('/\.([a-z0-9]+)$/i', $filename, $m)) - { - return 'application/octet-stream'; - } - - switch (strtolower($m[1])) - { - case 'zip': return 'application/zip'; - case 'jpeg': return 'image/jpeg'; - case 'jpg': return 'image/jpeg'; - case 'jpe': return 'image/jpeg'; - case 'png': return 'image/png'; - case 'gif': return 'image/gif'; - case 'htm': - case 'html': return 'text/html'; - case 'tif': return 'image/tiff'; - case 'tiff': return 'image/tiff'; - case 'ras': return 'image/x-cmu-raster'; - case 'pnm': return 'image/x-portable-anymap'; - case 'pbm': return 'image/x-portable-bitmap'; - case 'pgm': return 'image/x-portable-graymap'; - case 'ppm': return 'image/x-portable-pixmap'; - case 'rgb': return 'image/x-rgb'; - case 'xbm': return 'image/x-xbitmap'; - case 'xpm': return 'image/x-xpixmap'; - case 'xwd': return 'image/x-xwindowdump'; - case 'z': return 'application/x-compress'; - case 'gtar': return 'application/x-gtar'; - case 'tgz': return 'application/x-gtar'; - case 'gz': return 'application/x-gzip'; - case 'tar': return 'application/x-tar'; - case 'xls': return 'application/excel'; - case 'pdf': return 'application/pdf'; - case 'ppt': return 'application/powerpoint'; - case 'rm': return 'application/vnd.rn-realmedia'; - case 'wma': return 'audio/x-ms-wma'; - case 'swf': return 'application/x-shockwave-flash'; - case 'ief': return 'image/ief'; - case 'doc': - case 'dot': - case 'wrd': return 'application/msword'; - case 'ai': - case 'eps': - case 'ps': return 'application/postscript'; - case 'asc': - case 'txt': - case 'c': - case 'cc': - case 'h': - case 'hh': - case 'cpp': - case 'hpp': - case 'php': - case 'php3': return 'text/plain'; - default: return 'application/octet-stream'; - } -} - -/** -* Obtain the dimensions of all remotely hosted avatars -* This should only be called from execute_last -* There can be significant network overhead if there are a large number of remote avatars -* @todo Look at the option of allowing the user to decide whether this is called or to force the dimensions -*/ -function remote_avatar_dims() -{ - global $db; - - $sql = 'SELECT user_id, user_avatar - FROM ' . USERS_TABLE . ' - WHERE user_avatar_type = ' . AVATAR_REMOTE; - $result = $db->sql_query($sql); - - $remote_avatars = array(); - while ($row = $db->sql_fetchrow($result)) - { - $remote_avatars[(int) $row['user_id']] = $row['user_avatar']; - } - $db->sql_freeresult($result); - - foreach ($remote_avatars as $user_id => $avatar) - { - $width = (int) get_remote_avatar_dim($avatar, 0); - $height = (int) get_remote_avatar_dim($avatar, 1); - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_avatar_width = ' . (int) $width . ', user_avatar_height = ' . (int) $height . ' - WHERE user_id = ' . $user_id; - $db->sql_query($sql); - } -} - -function import_avatar_gallery($gallery_name = '', $subdirs_as_galleries = false) -{ - global $config, $convert, $user; - - $relative_path = empty($convert->convertor['source_path_absolute']); - - // check for trailing slash - if (rtrim($convert->convertor['avatar_gallery_path'], '/') === '') - { - $convert->p_master->error(sprintf($user->lang['CONV_ERROR_NO_GALLERY_PATH'], 'import_avatar_gallery()'), __LINE__, __FILE__); - } - - $src_path = relative_base(path($convert->convertor['avatar_gallery_path'], $relative_path), $relative_path); - - if (is_dir($src_path)) - { - // Do not die on failure... safe mode restrictions may be in effect. - copy_dir($convert->convertor['avatar_gallery_path'], path($config['avatar_gallery_path']) . $gallery_name, !$subdirs_as_galleries, false, false, $relative_path); - - // only doing 1 level deep. (ibf 1.x) - // notes: ibf has 2 tiers: directly in the avatar directory for base gallery (handled in the above statement), plus subdirs(handled below). - // recursive subdirs ignored. -- i don't know if other forums support recursive galleries. if they do, this following code could be upgraded to be recursive. - if ($subdirs_as_galleries) - { - $dirlist = array(); - if ($handle = @opendir($src_path)) - { - while ($entry = readdir($handle)) - { - if ($entry[0] == '.' || $entry == 'CVS' || $entry == 'index.htm') - { - continue; - } - - if (is_dir($src_path . $entry)) - { - $dirlist[] = $entry; - } - } - closedir($handle); - } - else if ($dir = @dir($src_path)) - { - while ($entry = $dir->read()) - { - if ($entry[0] == '.' || $entry == 'CVS' || $entry == 'index.htm') - { - continue; - } - - if (is_dir($src_path . $entry)) - { - $dirlist[] = $entry; - } - } - $dir->close(); - } - - for ($i = 0, $end = count($dirlist); $i < $end; ++$i) - { - $dir = $dirlist[$i]; - - // Do not die on failure... safe mode restrictions may be in effect. - copy_dir(path($convert->convertor['avatar_gallery_path'], $relative_path) . $dir, path($config['avatar_gallery_path']) . $dir, true, false, false, $relative_path); - } - } - } -} - -function import_attachment_files($category_name = '') -{ - global $config, $convert, $db, $user; - - $sql = 'SELECT config_value AS upload_path - FROM ' . CONFIG_TABLE . " - WHERE config_name = 'upload_path'"; - $result = $db->sql_query($sql); - $config['upload_path'] = $db->sql_fetchfield('upload_path'); - $db->sql_freeresult($result); - - $relative_path = empty($convert->convertor['source_path_absolute']); - - if (empty($convert->convertor['upload_path'])) - { - $convert->p_master->error(sprintf($user->lang['CONV_ERROR_NO_UPLOAD_DIR'], 'import_attachment_files()'), __LINE__, __FILE__); - } - - if (is_dir(relative_base(path($convert->convertor['upload_path'], $relative_path), $relative_path))) - { - copy_dir($convert->convertor['upload_path'], path($config['upload_path']) . $category_name, true, false, true, $relative_path); - } -} - -function attachment_forum_perms($forum_id) -{ - if (!is_array($forum_id)) - { - $forum_id = array($forum_id); - } - - return serialize($forum_id); -} - -// base64todec function -// -> from php manual? -function base64_unpack($string) -{ - $chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+-'; - $base = strlen($chars); - - $length = strlen($string); - $number = 0; - - for ($i = 1; $i <= $length; $i++) - { - $pos = $length - $i; - $operand = strpos($chars, substr($string, $pos, 1)); - $exponent = pow($base, $i-1); - $dec_value = $operand * $exponent; - $number += $dec_value; - } - - return $number; -} - -function _import_check($config_var, $source, $use_target) -{ - global $convert, $config; - - $result = array( - 'orig_source' => $source, - 'copied' => false, - 'relative_path' => (empty($convert->convertor['source_path_absolute'])) ? true : false, - ); - - // copy file will prepend $phpBB_root_path - $target = $config[$config_var] . '/' . utf8_basename(($use_target === false) ? $source : $use_target); - - if (!empty($convert->convertor[$config_var]) && strpos($source, $convert->convertor[$config_var]) !== 0) - { - $source = $convert->convertor[$config_var] . $source; - } - - $result['source'] = $source; - - if (file_exists(relative_base($source, $result['relative_path'], __LINE__, __FILE__))) - { - $result['copied'] = copy_file($source, $target, false, false, $result['relative_path']); - } - - if ($result['copied']) - { - $result['target'] = utf8_basename($target); - } - else - { - $result['target'] = ($use_target !== false) ? $result['orig_source'] : utf8_basename($target); - } - - return $result; -} - -function import_attachment($source, $use_target = false) -{ - if (empty($source)) - { - return ''; - } - - global $convert, $config, $user; - - // check for trailing slash - if (rtrim($convert->convertor['upload_path'], '/') === '') - { - $convert->p_master->error(sprintf($user->lang['CONV_ERROR_NO_UPLOAD_DIR'], 'import_attachment()'), __LINE__, __FILE__); - } - - $result = _import_check('upload_path', $source, $use_target); - - if ($result['copied']) - { - // Thumbnails? - if (is_array($convert->convertor['thumbnails'])) - { - $thumb_dir = $convert->convertor['thumbnails'][0]; - $thumb_prefix = $convert->convertor['thumbnails'][1]; - $thumb_source = $thumb_dir . $thumb_prefix . utf8_basename($result['source']); - - if (strpos($thumb_source, $convert->convertor['upload_path']) !== 0) - { - $thumb_source = $convert->convertor['upload_path'] . $thumb_source; - } - $thumb_target = $config['upload_path'] . '/thumb_' . $result['target']; - - if (file_exists(relative_base($thumb_source, $result['relative_path'], __LINE__, __FILE__))) - { - copy_file($thumb_source, $thumb_target, false, false, $result['relative_path']); - } - } - } - - return $result['target']; -} - -function import_rank($source, $use_target = false) -{ - if (empty($source)) - { - return ''; - } - - global $convert, $user; - - if (!isset($convert->convertor['ranks_path'])) - { - $convert->p_master->error(sprintf($user->lang['CONV_ERROR_NO_RANKS_PATH'], 'import_rank()'), __LINE__, __FILE__); - } - - $result = _import_check('ranks_path', $source, $use_target); - return $result['target']; -} - -function import_smiley($source, $use_target = false) -{ - if (empty($source)) - { - return ''; - } - - global $convert, $user; - - // check for trailing slash - if (rtrim($convert->convertor['smilies_path'], '/') === '') - { - $convert->p_master->error(sprintf($user->lang['CONV_ERROR_NO_SMILIES_PATH'], 'import_smiley()'), __LINE__, __FILE__); - } - - $result = _import_check('smilies_path', $source, $use_target); - return $result['target']; -} - -/* -*/ -function import_avatar($source, $use_target = false, $user_id = false) -{ - if (empty($source) || preg_match('#^https?:#i', $source) || preg_match('#blank\.(gif|png)$#i', $source)) - { - return; - } - - global $convert, $config, $user; - - // check for trailing slash - if (rtrim($convert->convertor['avatar_path'], '/') === '') - { - $convert->p_master->error(sprintf($user->lang['CONV_ERROR_NO_AVATAR_PATH'], 'import_avatar()'), __LINE__, __FILE__); - } - - if ($use_target === false && $user_id !== false) - { - $use_target = $config['avatar_salt'] . '_' . $user_id . '.' . substr(strrchr($source, '.'), 1); - } - - _import_check('avatar_path', $source, $use_target); - - return ((!empty($user_id)) ? $user_id : $use_target) . '.' . substr(strrchr($source, '.'), 1); -} - -/** -* @todo all image dimension functions below (there are a *lot*) should get revisited and converted to one or two functions (no more needed, really). -*/ - -/** -* Calculate the size of the specified image -* Called from the following functions for calculating the size of specific image types -*/ -function get_image_dim($source) -{ - if (empty($source)) - { - return array(0, 0); - } - - global $convert; - - $relative_path = empty($convert->convertor['source_path_absolute']); - - if (file_exists(relative_base($source, $relative_path))) - { - $image = relative_base($source, $relative_path); - return @getimagesize($image); - } - - return false; -} - -/** -* Obtain the width of the specified smilie -*/ -function get_smiley_width($src) -{ - return get_smiley_dim($src, 0); -} - -/** -* Obtain the height of the specified smilie -*/ -function get_smiley_height($src) -{ - return get_smiley_dim($src, 1); -} - -/** -* Obtain the size of the specified smilie (using the cache if possible) and cache the value -*/ -function get_smiley_dim($source, $axis) -{ - if (empty($source)) - { - return 15; - } - - static $smiley_cache = array(); - - if (isset($smiley_cache[$source])) - { - return $smiley_cache[$source][$axis]; - } - - global $convert, $user; - - $orig_source = $source; - - if (!isset($convert->convertor['smilies_path'])) - { - $convert->p_master->error(sprintf($user->lang['CONV_ERROR_NO_SMILIES_PATH'], 'get_smiley_dim()'), __LINE__, __FILE__); - } - - if (!empty($convert->convertor['smilies_path']) && strpos($source, $convert->convertor['smilies_path']) !== 0) - { - $source = $convert->convertor['smilies_path'] . $source; - } - - $smiley_cache[$orig_source] = get_image_dim($source); - - if (empty($smiley_cache[$orig_source]) || empty($smiley_cache[$orig_source][0]) || empty($smiley_cache[$orig_source][1])) - { - $smiley_cache[$orig_source] = array(15, 15); - return 15; - } - - return $smiley_cache[$orig_source][$axis]; -} - -/** -* Obtain the width of the specified avatar -*/ -function get_avatar_width($src, $func = false, $arg1 = false, $arg2 = false) -{ - return get_avatar_dim($src, 0, $func, $arg1, $arg2); -} - -/** -* Obtain the height of the specified avatar -*/ -function get_avatar_height($src, $func = false, $arg1 = false, $arg2 = false) -{ - return get_avatar_dim($src, 1, $func, $arg1, $arg2); -} - -/** -*/ -function get_avatar_dim($src, $axis, $func = false, $arg1 = false, $arg2 = false) -{ - $avatar_type = AVATAR_UPLOAD; - - if ($func) - { - if ($arg1 || $arg2) - { - $ary = array($arg1); - - if ($arg2) - { - $ary[] = $arg2; - } - - $avatar_type = call_user_func_array($func, $ary); - } - else - { - $avatar_type = call_user_func($func); - } - } - - switch ($avatar_type) - { - case AVATAR_UPLOAD: - return get_upload_avatar_dim($src, $axis); - break; - - case AVATAR_GALLERY: - return get_gallery_avatar_dim($src, $axis); - break; - - case AVATAR_REMOTE: - // see notes on this functions usage and (hopefully) model $func to avoid this accordingly - return get_remote_avatar_dim($src, $axis); - break; - - default: - $default_x = (defined('DEFAULT_AVATAR_X_CUSTOM')) ? DEFAULT_AVATAR_X_CUSTOM : DEFAULT_AVATAR_X; - $default_y = (defined('DEFAULT_AVATAR_Y_CUSTOM')) ? DEFAULT_AVATAR_Y_CUSTOM : DEFAULT_AVATAR_Y; - - return $axis ? $default_y : $default_x; - break; - } -} - -/** -* Obtain the size of the specified uploaded avatar (using the cache if possible) and cache the value -*/ -function get_upload_avatar_dim($source, $axis) -{ - static $cachedims = false; - static $cachekey = false; - - if (empty($source)) - { - return 0; - } - - if ($cachekey == $source) - { - return $cachedims[$axis]; - } - - if (substr($source, 0, 7) == 'upload:') - { - $source = substr($source, 7); - } - - global $convert, $user; - - if (!isset($convert->convertor['avatar_path'])) - { - $convert->p_master->error(sprintf($user->lang['CONV_ERROR_NO_AVATAR_PATH'], 'get_upload_avatar_dim()'), __LINE__, __FILE__); - } - - if (!empty($convert->convertor['avatar_path']) && strpos($source, $convert->convertor['avatar_path']) !== 0) - { - $source = path($convert->convertor['avatar_path'], empty($convert->convertor['source_path_absolute'])) . $source; - } - - $cachedims = get_image_dim($source); - - if (empty($cachedims) || empty($cachedims[0]) || empty($cachedims[1])) - { - $default_x = (defined('DEFAULT_AVATAR_X_CUSTOM')) ? DEFAULT_AVATAR_X_CUSTOM : DEFAULT_AVATAR_X; - $default_y = (defined('DEFAULT_AVATAR_Y_CUSTOM')) ? DEFAULT_AVATAR_Y_CUSTOM : DEFAULT_AVATAR_Y; - - $cachedims = array($default_x, $default_y); - } - - return $cachedims[$axis]; -} - -/** -* Obtain the size of the specified gallery avatar (using the cache if possible) and cache the value -*/ -function get_gallery_avatar_dim($source, $axis) -{ - if (empty($source)) - { - return 0; - } - - static $avatar_cache = array(); - - if (isset($avatar_cache[$source])) - { - return $avatar_cache[$source][$axis]; - } - - global $convert, $user; - - $orig_source = $source; - - if (!isset($convert->convertor['avatar_gallery_path'])) - { - $convert->p_master->error(sprintf($user->lang['CONV_ERROR_NO_GALLERY_PATH'], 'get_gallery_avatar_dim()'), __LINE__, __FILE__); - } - - if (!empty($convert->convertor['avatar_gallery_path']) && strpos($source, $convert->convertor['avatar_gallery_path']) !== 0) - { - $source = path($convert->convertor['avatar_gallery_path'], empty($convert->convertor['source_path_absolute'])) . $source; - } - - $avatar_cache[$orig_source] = get_image_dim($source); - - if (empty($avatar_cache[$orig_source]) || empty($avatar_cache[$orig_source][0]) || empty($avatar_cache[$orig_source][1])) - { - $default_x = (defined('DEFAULT_AVATAR_X_CUSTOM')) ? DEFAULT_AVATAR_X_CUSTOM : DEFAULT_AVATAR_X; - $default_y = (defined('DEFAULT_AVATAR_Y_CUSTOM')) ? DEFAULT_AVATAR_Y_CUSTOM : DEFAULT_AVATAR_Y; - - $avatar_cache[$orig_source] = array($default_x, $default_y); - } - - return $avatar_cache[$orig_source][$axis]; -} - -/** -* Obtain the size of the specified remote avatar (using the cache if possible) and cache the value -* Whilst it's unlikely that remote avatars will be duplicated, it is possible so caching seems the best option -* This should only be called from a post processing step due to the possibility of network timeouts -*/ -function get_remote_avatar_dim($src, $axis) -{ - if (empty($src)) - { - return 0; - } - - static $remote_avatar_cache = array(); - - // an ugly hack: we assume that the dimensions of each remote avatar are accessed exactly twice (x and y) - if (isset($remote_avatar_cache[$src])) - { - $retval = $remote_avatar_cache[$src][$axis]; - unset($remote_avatar_cache); - return $retval; - } - - $url_info = @parse_url($src); - if (empty($url_info['host'])) - { - return 0; - } - $host = $url_info['host']; - $port = (isset($url_info['port'])) ? $url_info['port'] : 0; - $protocol = (isset($url_info['scheme'])) ? $url_info['scheme'] : 'http'; - if (empty($port)) - { - switch (strtolower($protocol)) - { - case 'ftp': - $port = 21; - break; - - case 'https': - $port = 443; - break; - - default: - $port = 80; - } - } - - $timeout = @ini_get('default_socket_timeout'); - @ini_set('default_socket_timeout', 2); - - // We're just trying to reach the server to avoid timeouts - $fp = @fsockopen($host, $port, $errno, $errstr, 1); - if ($fp) - { - $remote_avatar_cache[$src] = @getimagesize($src); - fclose($fp); - } - - $default_x = (defined('DEFAULT_AVATAR_X_CUSTOM')) ? DEFAULT_AVATAR_X_CUSTOM : DEFAULT_AVATAR_X; - $default_y = (defined('DEFAULT_AVATAR_Y_CUSTOM')) ? DEFAULT_AVATAR_Y_CUSTOM : DEFAULT_AVATAR_Y; - $default = array($default_x, $default_y); - - if (empty($remote_avatar_cache[$src]) || empty($remote_avatar_cache[$src][0]) || empty($remote_avatar_cache[$src][1])) - { - $remote_avatar_cache[$src] = $default; - } - else - { - // We trust gallery and uploaded avatars to conform to the size settings; we might have to adjust here - if ($remote_avatar_cache[$src][0] > $default_x || $remote_avatar_cache[$src][1] > $default_y) - { - $bigger = ($remote_avatar_cache[$src][0] > $remote_avatar_cache[$src][1]) ? 0 : 1; - $ratio = $default[$bigger] / $remote_avatar_cache[$src][$bigger]; - $remote_avatar_cache[$src][0] = (int) ($remote_avatar_cache[$src][0] * $ratio); - $remote_avatar_cache[$src][1] = (int) ($remote_avatar_cache[$src][1] * $ratio); - } - } - - @ini_set('default_socket_timeout', $timeout); - return $remote_avatar_cache[$src][$axis]; -} - -function set_user_options() -{ - global $convert_row; - - // Key need to be set in row, else default value is chosen - $keyoptions = array( - 'viewimg' => array('bit' => 0, 'default' => 1), - 'viewflash' => array('bit' => 1, 'default' => 1), - 'viewsmilies' => array('bit' => 2, 'default' => 1), - 'viewsigs' => array('bit' => 3, 'default' => 1), - 'viewavatars' => array('bit' => 4, 'default' => 1), - 'viewcensors' => array('bit' => 5, 'default' => 1), - 'attachsig' => array('bit' => 6, 'default' => 0), - 'bbcode' => array('bit' => 8, 'default' => 1), - 'smilies' => array('bit' => 9, 'default' => 1), - 'sig_bbcode' => array('bit' => 15, 'default' => 1), - 'sig_smilies' => array('bit' => 16, 'default' => 1), - 'sig_links' => array('bit' => 17, 'default' => 1), - ); - - $option_field = 0; - - foreach ($keyoptions as $key => $key_ary) - { - $value = (isset($convert_row[$key])) ? (int) $convert_row[$key] : $key_ary['default']; - - if ($value && !($option_field & 1 << $key_ary['bit'])) - { - $option_field += 1 << $key_ary['bit']; - } - } - - return $option_field; -} - -/** -* Index messages on the fly as we convert them -* @todo naderman, can you check that this works with the new search plugins as it's use is currently disabled (and thus untested) -function search_indexing($message = '') -{ - global $fulltext_search, $convert_row; - - if (!isset($convert_row['post_id'])) - { - return; - } - - if (!$message) - { - if (!isset($convert_row['message'])) - { - return; - } - - $message = $convert_row['message']; - } - - $title = (isset($convert_row['title'])) ? $convert_row['title'] : ''; - - $fulltext_search->index('post', $convert_row['post_id'], $message, $title, $convert_row['poster_id'], $convert_row['forum_id']); -} -*/ - -function make_unique_filename($filename) -{ - if (!strlen($filename)) - { - $filename = md5(unique_id()) . '.dat'; - } - else if ($filename[0] == '.') - { - $filename = md5(unique_id()) . $filename; - } - else if (preg_match('/\.([a-z]+)$/i', $filename, $m)) - { - $filename = preg_replace('/\.([a-z]+)$/i', '_' . md5(unique_id()) . '.\1', $filename); - } - else - { - $filename .= '_' . md5(unique_id()) . '.dat'; - } - - return $filename; -} - -function words_unique(&$words) -{ - reset($words); - $return_array = array(); - - $word = current($words); - do - { - $return_array[$word] = $word; - } - while ($word = next($words)); - - return $return_array; -} - -/** -* Adds a user to the specified group and optionally makes them a group leader -* This function does not create the group if it does not exist and so should only be called after the groups have been created -*/ -function add_user_group($group_id, $user_id, $group_leader = false) -{ - global $db; - - $sql = 'INSERT INTO ' . USER_GROUP_TABLE . ' ' . $db->sql_build_array('INSERT', array( - 'group_id' => $group_id, - 'user_id' => $user_id, - 'group_leader' => ($group_leader) ? 1 : 0, - 'user_pending' => 0)); - $db->sql_query($sql); -} - -// STANDALONE FUNCTIONS - -/** -* Add users to the pre-defined "special" groups -* -* @param string $group The name of the special group to add to -* @param string $select_query An SQL query to retrieve the user(s) to add to the group -*/ -function user_group_auth($group, $select_query, $use_src_db) -{ - global $convert, $user, $db, $src_db, $same_db; - - if (!in_array($group, array('guests', 'registered', 'registered_coppa', 'global_moderators', 'administrators', 'bots'))) - { - $convert->p_master->error(sprintf($user->lang['CONV_ERROR_WRONG_GROUP'], $group, 'user_group_auth()'), __LINE__, __FILE__, true); - return; - } - - $sql = 'SELECT group_id - FROM ' . GROUPS_TABLE . " - WHERE group_name = '" . $db->sql_escape(strtoupper($group)) . "'"; - $result = $db->sql_query($sql); - $group_id = (int) $db->sql_fetchfield('group_id'); - $db->sql_freeresult($result); - - if (!$group_id) - { - $convert->p_master->error(sprintf($user->lang['CONV_ERROR_NO_GROUP'], $group, 'user_group_auth()'), __LINE__, __FILE__, true); - return; - } - - if ($same_db || !$use_src_db) - { - $sql = 'INSERT INTO ' . USER_GROUP_TABLE . ' (user_id, group_id, user_pending) - ' . str_replace('{' . strtoupper($group) . '}', $group_id . ', 0', $select_query); - $db->sql_query($sql); - } - else - { - $result = $src_db->sql_query(str_replace('{' . strtoupper($group) . '}', $group_id . ' ', $select_query)); - while ($row = $src_db->sql_fetchrow($result)) - { - // this might become quite a lot of INSERTS unfortunately - $sql = 'INSERT INTO ' . USER_GROUP_TABLE . " (user_id, group_id, user_pending) - VALUES ({$row['user_id']}, $group_id, 0)"; - $db->sql_query($sql); - } - $src_db->sql_freeresult($result); - } -} - -/** -* Retrieves configuration information from the source forum and caches it as an array -* Both database and file driven configuration formats can be handled -* (the type used is specified in $config_schema, see convert_phpbb20.php for more details) -*/ -function get_config() -{ - static $convert_config; - global $user; - - if (isset($convert_config)) - { - return $convert_config; - } - - global $src_db, $same_db; - global $convert; - - if ($convert->config_schema['table_format'] != 'file') - { - if ($convert->mysql_convert && $same_db) - { - $src_db->sql_query("SET NAMES 'binary'"); - } - - $sql = 'SELECT * FROM ' . $convert->src_table_prefix . $convert->config_schema['table_name']; - $result = $src_db->sql_query($sql); - $row = $src_db->sql_fetchrow($result); - - if (!$row) - { - $convert->p_master->error($user->lang['CONV_ERROR_GET_CONFIG'], __LINE__, __FILE__); - } - } - - if (is_array($convert->config_schema['table_format'])) - { - $convert_config = array(); - $key = key($convert->config_schema['table_format']); - $val = current($convert->config_schema['table_format']); - - do - { - $convert_config[$row[$key]] = $row[$val]; - } - while ($row = $src_db->sql_fetchrow($result)); - $src_db->sql_freeresult($result); - - if ($convert->mysql_convert && $same_db) - { - $src_db->sql_query("SET NAMES 'utf8'"); - } - } - else if ($convert->config_schema['table_format'] == 'file') - { - $filename = $convert->options['forum_path'] . '/' . $convert->config_schema['filename']; - if (!file_exists($filename)) - { - $convert->p_master->error($user->lang('FILE_NOT_FOUND', $filename), __LINE__, __FILE__); - } - - if (isset($convert->config_schema['array_name'])) - { - unset($convert->config_schema['array_name']); - } - - $convert_config = extract_variables_from_file($filename); - if (!empty($convert->config_schema['array_name'])) - { - $convert_config = $convert_config[$convert->config_schema['array_name']]; - } - } - else - { - $convert_config = $row; - if ($convert->mysql_convert && $same_db) - { - $src_db->sql_query("SET NAMES 'utf8'"); - } - } - - if (!count($convert_config)) - { - $convert->p_master->error($user->lang['CONV_ERROR_CONFIG_EMPTY'], __LINE__, __FILE__); - } - - return $convert_config; -} - -/** -* Transfers the relevant configuration information from the source forum -* The mapping of fields is specified in $config_schema, see convert_phpbb20.php for more details -*/ -function restore_config($schema) -{ - global $config; - - $convert_config = get_config(); - - foreach ($schema['settings'] as $config_name => $src) - { - if (preg_match('/(.*)\((.*)\)/', $src, $m)) - { - $var = (empty($m[2]) || empty($convert_config[$m[2]])) ? "''" : "'" . addslashes($convert_config[$m[2]]) . "'"; - $exec = '$config_value = ' . $m[1] . '(' . $var . ');'; - // @codingStandardsIgnoreStart - eval($exec); - // @codingStandardsIgnoreEnd - } - else - { - if ($schema['table_format'] != 'file' || empty($schema['array_name'])) - { - $config_value = (isset($convert_config[$src])) ? $convert_config[$src] : ''; - } - else if (!empty($schema['array_name'])) - { - $src_ary = $schema['array_name']; - $config_value = (isset($convert_config[$src_ary][$src])) ? $convert_config[$src_ary][$src] : ''; - } - } - - if ($config_value !== '') - { - // Most are... - if (is_string($config_value)) - { - $config_value = truncate_string(utf8_htmlspecialchars($config_value), 255, 255, false); - } - - $config->set($config_name, $config_value); - } - } -} - -/** -* Update the count of PM's in custom folders for all users -*/ -function update_folder_pm_count() -{ - global $db; - - $sql = 'SELECT user_id, folder_id, COUNT(msg_id) as num_messages - FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE folder_id NOT IN (' . PRIVMSGS_NO_BOX . ', ' . PRIVMSGS_HOLD_BOX . ', ' . PRIVMSGS_INBOX . ', ' . PRIVMSGS_OUTBOX . ', ' . PRIVMSGS_SENTBOX . ') - GROUP BY folder_id, user_id'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $db->sql_query('UPDATE ' . PRIVMSGS_FOLDER_TABLE . ' SET pm_count = ' . $row['num_messages'] . ' - WHERE user_id = ' . $row['user_id'] . ' AND folder_id = ' . $row['folder_id']); - } - $db->sql_freeresult($result); -} - -// Functions mainly used by the main convertor script - -function path($path, $path_relative = true) -{ - if ($path === false) - { - return ''; - } - - if (substr($path, -1) != '/') - { - $path .= '/'; - } - - if (!$path_relative) - { - return $path; - } - - if (substr($path, 0, 1) == '/') - { - $path = substr($path, 1); - } - - return $path; -} - -/** -* Extract the variables defined in a configuration file -* @todo As noted by Xore we need to look at this from a security perspective -*/ -function extract_variables_from_file($_filename) -{ - include($_filename); - - $vars = get_defined_vars(); - unset($vars['_filename']); - - return $vars; -} - -function get_path($src_path, $src_url, $test_file) -{ - global $phpbb_root_path, $phpEx; - - $board_config = get_config(); - - $test_file = preg_replace('/\.php$/i', ".$phpEx", $test_file); - $src_path = path($src_path); - - if (@file_exists($phpbb_root_path . $src_path . $test_file)) - { - return $src_path; - } - - if (!empty($src_url) && !empty($board_config['server_name'])) - { - if (!preg_match('#https?://([^/]+)(.*)#i', $src_url, $m)) - { - return false; - } - - if ($m[1] != $board_config['server_name']) - { - return false; - } - - $url_parts = explode('/', $m[2]); - if (substr($src_url, -1) != '/') - { - if (preg_match('/.*\.([a-z0-9]{3,4})$/i', $url_parts[count($url_parts) - 1])) - { - $url_parts[count($url_parts) - 1] = ''; - } - else - { - $url_parts[] = ''; - } - } - - $script_path = $board_config['script_path']; - if (substr($script_path, -1) == '/') - { - $script_path = substr($script_path, 0, -1); - } - - $path_array = array(); - - $phpbb_parts = explode('/', $script_path); - for ($i = 0, $end = count($url_parts); $i < $end; ++$i) - { - if ($i < count($phpbb_parts[$i]) && $url_parts[$i] == $phpbb_parts[$i]) - { - $path_array[] = $url_parts[$i]; - unset($url_parts[$i]); - } - else - { - $path = ''; - for ($j = $i, $end2 = count($phpbb_parts); $j < $end2; ++$j) - { - $path .= '../'; - } - $path .= implode('/', $url_parts); - break; - } - } - - if (!empty($path)) - { - if (@file_exists($phpbb_root_path . $path . $test_file)) - { - return $path; - } - } - } - - return false; -} - -function compare_table($tables, $tablename, &$prefixes) -{ - for ($i = 0, $table_size = count($tables); $i < $table_size; ++$i) - { - if (preg_match('/(.*)' . $tables[$i] . '$/', $tablename, $m)) - { - if (empty($m[1])) - { - $m[1] = '*'; - } - - if (isset($prefixes[$m[1]])) - { - $prefixes[$m[1]]++; - } - else - { - $prefixes[$m[1]] = 1; - } - } - } -} - -/** -* Grant permissions to a specified user or group -* -* @param string $ug_type user|group|user_role|group_role -* @param mixed $forum_id forum ids (array|int|0) -> 0 == all forums -* @param mixed $ug_id [int] user_id|group_id : [string] usergroup name -* @param mixed $acl_list [string] acl entry : [array] acl entries : [string] role entry -* @param int $setting ACL_YES|ACL_NO|ACL_NEVER -*/ -function mass_auth($ug_type, $forum_id, $ug_id, $acl_list, $setting = ACL_NO) -{ - global $db; - static $acl_option_ids, $group_ids; - - if (($ug_type == 'group' || $ug_type == 'group_role') && is_string($ug_id)) - { - if (!isset($group_ids[$ug_id])) - { - $sql = 'SELECT group_id - FROM ' . GROUPS_TABLE . " - WHERE group_name = '" . $db->sql_escape(strtoupper($ug_id)) . "'"; - $result = $db->sql_query_limit($sql, 1); - $id = (int) $db->sql_fetchfield('group_id'); - $db->sql_freeresult($result); - - if (!$id) - { - return; - } - - $group_ids[$ug_id] = $id; - } - - $ug_id = (int) $group_ids[$ug_id]; - } - - $table = ($ug_type == 'user' || $ug_type == 'user_role') ? ACL_USERS_TABLE : ACL_GROUPS_TABLE; - $id_field = ($ug_type == 'user' || $ug_type == 'user_role') ? 'user_id' : 'group_id'; - - // Role based permissions are the simplest to handle so check for them first - if ($ug_type == 'user_role' || $ug_type == 'group_role') - { - if (is_numeric($forum_id)) - { - $sql = 'SELECT role_id - FROM ' . ACL_ROLES_TABLE . " - WHERE role_name = 'ROLE_" . $db->sql_escape($acl_list) . "'"; - $result = $db->sql_query_limit($sql, 1); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - // If we have no role id there is something wrong here - if ($row) - { - $sql = "INSERT INTO $table ($id_field, forum_id, auth_role_id) VALUES ($ug_id, $forum_id, " . $row['role_id'] . ')'; - $db->sql_query($sql); - } - } - - return; - } - - // Build correct parameters - $auth = array(); - - if (!is_array($acl_list)) - { - $auth = array($acl_list => $setting); - } - else - { - foreach ($acl_list as $auth_option) - { - $auth[$auth_option] = $setting; - } - } - unset($acl_list); - - if (!is_array($forum_id)) - { - $forum_id = array($forum_id); - } - - // Set any flags as required - foreach ($auth as $auth_option => $acl_setting) - { - $flag = substr($auth_option, 0, strpos($auth_option, '_') + 1); - if (empty($auth[$flag])) - { - $auth[$flag] = $acl_setting; - } - } - - if (!is_array($acl_option_ids) || empty($acl_option_ids)) - { - $sql = 'SELECT auth_option_id, auth_option - FROM ' . ACL_OPTIONS_TABLE; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $acl_option_ids[$row['auth_option']] = $row['auth_option_id']; - } - $db->sql_freeresult($result); - } - - $sql_forum = 'AND ' . $db->sql_in_set('a.forum_id', array_map('intval', $forum_id), false, true); - - $sql = ($ug_type == 'user') ? 'SELECT o.auth_option_id, o.auth_option, a.forum_id, a.auth_setting FROM ' . ACL_USERS_TABLE . ' a, ' . ACL_OPTIONS_TABLE . " o WHERE a.auth_option_id = o.auth_option_id $sql_forum AND a.user_id = $ug_id" : 'SELECT o.auth_option_id, o.auth_option, a.forum_id, a.auth_setting FROM ' . ACL_GROUPS_TABLE . ' a, ' . ACL_OPTIONS_TABLE . " o WHERE a.auth_option_id = o.auth_option_id $sql_forum AND a.group_id = $ug_id"; - $result = $db->sql_query($sql); - - $cur_auth = array(); - while ($row = $db->sql_fetchrow($result)) - { - $cur_auth[$row['forum_id']][$row['auth_option_id']] = $row['auth_setting']; - } - $db->sql_freeresult($result); - - $sql_ary = array(); - foreach ($forum_id as $forum) - { - foreach ($auth as $auth_option => $setting) - { - $auth_option_id = $acl_option_ids[$auth_option]; - - if (!$auth_option_id) - { - continue; - } - - switch ($setting) - { - case ACL_NO: - if (isset($cur_auth[$forum][$auth_option_id])) - { - $sql_ary['delete'][] = "DELETE FROM $table - WHERE forum_id = $forum - AND auth_option_id = $auth_option_id - AND $id_field = $ug_id"; - } - break; - - default: - if (!isset($cur_auth[$forum][$auth_option_id])) - { - $sql_ary['insert'][] = "$ug_id, $forum, $auth_option_id, $setting"; - } - else if ($cur_auth[$forum][$auth_option_id] != $setting) - { - $sql_ary['update'][] = "UPDATE " . $table . " - SET auth_setting = $setting - WHERE $id_field = $ug_id - AND forum_id = $forum - AND auth_option_id = $auth_option_id"; - } - } - } - } - unset($cur_auth); - - $sql = ''; - foreach ($sql_ary as $sql_type => $sql_subary) - { - switch ($sql_type) - { - case 'insert': - switch ($db->get_sql_layer()) - { - case 'sqlite3': - case 'mssqlnative': - $sql = implode(' UNION ALL ', preg_replace('#^(.*?)$#', 'SELECT \1', $sql_subary)); - break; - - default: - foreach ($sql_subary as $sql) - { - $sql = "INSERT INTO $table ($id_field, forum_id, auth_option_id, auth_setting) VALUES ($sql)"; - $db->sql_query($sql); - $sql = ''; - } - } - - if ($sql != '') - { - $sql = "INSERT INTO $table ($id_field, forum_id, auth_option_id, auth_setting) $sql"; - $db->sql_query($sql); - } - break; - - case 'update': - case 'delete': - foreach ($sql_subary as $sql) - { - $db->sql_query($sql); - $sql = ''; - } - break; - } - unset($sql_ary[$sql_type]); - } - unset($sql_ary); - -} - -/** -* Update the count of unread private messages for all users -*/ -function update_unread_count() -{ - global $db; - - $sql = 'SELECT user_id, COUNT(msg_id) as num_messages - FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE pm_unread = 1 - AND folder_id <> ' . PRIVMSGS_OUTBOX . ' - GROUP BY user_id'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $db->sql_query('UPDATE ' . USERS_TABLE . ' SET user_unread_privmsg = ' . $row['num_messages'] . ' - WHERE user_id = ' . $row['user_id']); - } - $db->sql_freeresult($result); -} - -/** -* Add any of the pre-defined "special" groups which are missing from the database -*/ -function add_default_groups() -{ - global $db; - - $default_groups = array( - 'GUESTS' => array('', 0, 0), - 'REGISTERED' => array('', 0, 0), - 'REGISTERED_COPPA' => array('', 0, 0), - 'GLOBAL_MODERATORS' => array('00AA00', 2, 0), - 'ADMINISTRATORS' => array('AA0000', 1, 1), - 'BOTS' => array('9E8DA7', 0, 0), - 'NEWLY_REGISTERED' => array('', 0, 0), - ); - - $sql = 'SELECT * - FROM ' . GROUPS_TABLE . ' - WHERE ' . $db->sql_in_set('group_name', array_keys($default_groups)); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - unset($default_groups[strtoupper($row['group_name'])]); - } - $db->sql_freeresult($result); - - $sql_ary = array(); - - foreach ($default_groups as $name => $data) - { - $sql_ary[] = array( - 'group_name' => (string) $name, - 'group_desc' => '', - 'group_desc_uid' => '', - 'group_desc_bitfield' => '', - 'group_type' => GROUP_SPECIAL, - 'group_colour' => (string) $data[0], - 'group_legend' => (int) $data[1], - 'group_founder_manage' => (int) $data[2], - ); - } - - if (count($sql_ary)) - { - $db->sql_multi_insert(GROUPS_TABLE, $sql_ary); - } -} - -function add_groups_to_teampage() -{ - global $db; - - $teampage_groups = array( - 'ADMINISTRATORS' => 1, - 'GLOBAL_MODERATORS' => 2, - ); - - $sql = 'SELECT * - FROM ' . GROUPS_TABLE . ' - WHERE ' . $db->sql_in_set('group_name', array_keys($teampage_groups)); - $result = $db->sql_query($sql); - - $teampage_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - $teampage_ary[] = array( - 'group_id' => (int) $row['group_id'], - 'teampage_name' => '', - 'teampage_position' => (int) $teampage_groups[$row['group_name']], - 'teampage_parent' => 0, - ); - } - $db->sql_freeresult($result); - - if (count($teampage_ary)) - { - $db->sql_multi_insert(TEAMPAGE_TABLE, $teampage_ary); - } -} - - -/** -* Sync post count. We might need to do this in batches. -*/ -function sync_post_count($offset, $limit) -{ - global $db; - $sql = 'SELECT COUNT(post_id) AS num_posts, poster_id - FROM ' . POSTS_TABLE . ' - WHERE post_postcount = 1 - AND post_visibility = ' . ITEM_APPROVED . ' - GROUP BY poster_id - ORDER BY poster_id'; - $result = $db->sql_query_limit($sql, $limit, $offset); - - while ($row = $db->sql_fetchrow($result)) - { - $db->sql_query('UPDATE ' . USERS_TABLE . " SET user_posts = {$row['num_posts']} WHERE user_id = {$row['poster_id']}"); - } - $db->sql_freeresult($result); -} - -/** -* Add the search bots into the database -* This code should be used in execute_last if the source database did not have bots -* If you are converting bots this function should not be called -* @todo We might want to look at sharing the bot list between the install code and this code for consistancy -*/ -function add_bots() -{ - global $db, $convert, $user, $config, $phpbb_root_path, $phpEx; - - $db->sql_query($convert->truncate_statement . BOTS_TABLE); - - $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . " WHERE group_name = 'BOTS'"; - $result = $db->sql_query($sql); - $group_id = (int) $db->sql_fetchfield('group_id', false, $result); - $db->sql_freeresult($result); - - if (!$group_id) - { - add_default_groups(); - - $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . " WHERE group_name = 'BOTS'"; - $result = $db->sql_query($sql); - $group_id = (int) $db->sql_fetchfield('group_id', false, $result); - $db->sql_freeresult($result); - - if (!$group_id) - { - global $install; - $install->error($user->lang['CONV_ERROR_INCONSISTENT_GROUPS'], __LINE__, __FILE__); - } - } - - $bots = array( - 'AdsBot [Google]' => array('AdsBot-Google', ''), - 'Alexa [Bot]' => array('ia_archiver', ''), - 'Alta Vista [Bot]' => array('Scooter/', ''), - 'Ask Jeeves [Bot]' => array('Ask Jeeves', ''), - 'Baidu [Spider]' => array('Baiduspider+(', ''), - 'Bing [Bot]' => array('bingbot/', ''), - 'Exabot [Bot]' => array('Exabot/', ''), - 'FAST Enterprise [Crawler]' => array('FAST Enterprise Crawler', ''), - 'FAST WebCrawler [Crawler]' => array('FAST-WebCrawler/', ''), - 'Francis [Bot]' => array('http://www.neomo.de/', ''), - 'Gigabot [Bot]' => array('Gigabot/', ''), - 'Google Adsense [Bot]' => array('Mediapartners-Google', ''), - 'Google Desktop' => array('Google Desktop', ''), - 'Google Feedfetcher' => array('Feedfetcher-Google', ''), - 'Google [Bot]' => array('Googlebot', ''), - 'Heise IT-Markt [Crawler]' => array('heise-IT-Markt-Crawler', ''), - 'Heritrix [Crawler]' => array('heritrix/1.', ''), - 'IBM Research [Bot]' => array('ibm.com/cs/crawler', ''), - 'ICCrawler - ICjobs' => array('ICCrawler - ICjobs', ''), - 'ichiro [Crawler]' => array('ichiro/2', ''), - 'Majestic-12 [Bot]' => array('MJ12bot/', ''), - 'Metager [Bot]' => array('MetagerBot/', ''), - 'MSN NewsBlogs' => array('msnbot-NewsBlogs/', ''), - 'MSN [Bot]' => array('msnbot/', ''), - 'MSNbot Media' => array('msnbot-media/', ''), - 'NG-Search [Bot]' => array('NG-Search/', ''), - 'Nutch [Bot]' => array('http://lucene.apache.org/nutch/', ''), - 'Nutch/CVS [Bot]' => array('NutchCVS/', ''), - 'OmniExplorer [Bot]' => array('OmniExplorer_Bot/', ''), - 'Online link [Validator]' => array('online link validator', ''), - 'psbot [Picsearch]' => array('psbot/0', ''), - 'Seekport [Bot]' => array('Seekbot/', ''), - 'Sensis [Crawler]' => array('Sensis Web Crawler', ''), - 'SEO Crawler' => array('SEO search Crawler/', ''), - 'Seoma [Crawler]' => array('Seoma [SEO Crawler]', ''), - 'SEOSearch [Crawler]' => array('SEOsearch/', ''), - 'Snappy [Bot]' => array('Snappy/1.1 ( http://www.urltrends.com/ )', ''), - 'Steeler [Crawler]' => array('http://www.tkl.iis.u-tokyo.ac.jp/~crawler/', ''), - 'Synoo [Bot]' => array('SynooBot/', ''), - 'Telekom [Bot]' => array('crawleradmin.t-info@telekom.de', ''), - 'TurnitinBot [Bot]' => array('TurnitinBot/', ''), - 'Voyager [Bot]' => array('voyager/1.0', ''), - 'W3 [Sitesearch]' => array('W3 SiteSearch Crawler', ''), - 'W3C [Linkcheck]' => array('W3C-checklink/', ''), - 'W3C [Validator]' => array('W3C_*Validator', ''), - 'WiseNut [Bot]' => array('http://www.WISEnutbot.com', ''), - 'YaCy [Bot]' => array('yacybot', ''), - 'Yahoo MMCrawler [Bot]' => array('Yahoo-MMCrawler/', ''), - 'Yahoo Slurp [Bot]' => array('Yahoo! DE Slurp', ''), - 'Yahoo [Bot]' => array('Yahoo! Slurp', ''), - 'YahooSeeker [Bot]' => array('YahooSeeker/', ''), - ); - - if (!function_exists('user_add')) - { - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - } - - foreach ($bots as $bot_name => $bot_ary) - { - $user_row = array( - 'user_type' => USER_IGNORE, - 'group_id' => $group_id, - 'username' => $bot_name, - 'user_regdate' => time(), - 'user_password' => '', - 'user_colour' => '9E8DA7', - 'user_email' => '', - 'user_lang' => $config['default_lang'], - 'user_style' => 1, - 'user_timezone' => 'UTC', - 'user_allow_massemail' => 0, - ); - - $user_id = user_add($user_row); - - if ($user_id) - { - $sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $db->sql_build_array('INSERT', array( - 'bot_active' => 1, - 'bot_name' => $bot_name, - 'user_id' => $user_id, - 'bot_agent' => $bot_ary[0], - 'bot_ip' => $bot_ary[1]) - ); - $db->sql_query($sql); - } - } -} - -/** -* Update any dynamic configuration variables after the conversion is finished -* @todo Confirm that this updates all relevant values since it has not necessarily been kept in sync with all changes -*/ -function update_dynamic_config() -{ - global $db, $config; - - // Get latest username - $sql = 'SELECT user_id, username, user_colour - FROM ' . USERS_TABLE . ' - WHERE user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')'; - - if (!empty($config['increment_user_id'])) - { - $sql .= ' AND user_id <> ' . $config['increment_user_id']; - } - - $sql .= ' ORDER BY user_id DESC'; - - $result = $db->sql_query_limit($sql, 1); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - $config->set('newest_user_id', $row['user_id'], false); - $config->set('newest_username', $row['username'], false); - $config->set('newest_user_colour', $row['user_colour'], false); - } - -// Also do not reset record online user/date. There will be old data or the fresh data from the schema. -// set_config('record_online_users', 1, true); -// set_config('record_online_date', time(), true); - - $sql = 'SELECT COUNT(post_id) AS stat - FROM ' . POSTS_TABLE . ' - WHERE post_visibility = ' . ITEM_APPROVED; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $config->set('num_posts', (int) $row['stat'], false); - - $sql = 'SELECT COUNT(topic_id) AS stat - FROM ' . TOPICS_TABLE . ' - WHERE topic_visibility = ' . ITEM_APPROVED; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $config->set('num_topics', (int) $row['stat'], false); - - $sql = 'SELECT COUNT(user_id) AS stat - FROM ' . USERS_TABLE . ' - WHERE user_type IN (' . USER_NORMAL . ',' . USER_FOUNDER . ')'; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $config->set('num_users', (int) $row['stat'], false); - - $sql = 'SELECT COUNT(attach_id) as stat - FROM ' . ATTACHMENTS_TABLE . ' - WHERE is_orphan = 0'; - $result = $db->sql_query($sql); - $config->set('num_files', (int) $db->sql_fetchfield('stat'), false); - $db->sql_freeresult($result); - - $sql = 'SELECT SUM(filesize) as stat - FROM ' . ATTACHMENTS_TABLE . ' - WHERE is_orphan = 0'; - $result = $db->sql_query($sql); - $config->set('upload_dir_size', (float) $db->sql_fetchfield('stat'), false); - $db->sql_freeresult($result); - - /** - * We do not resync users post counts - this can be done by the admin after conversion if wanted. - $sql = 'SELECT COUNT(post_id) AS num_posts, poster_id - FROM ' . POSTS_TABLE . ' - WHERE post_postcount = 1 - GROUP BY poster_id'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $db->sql_query('UPDATE ' . USERS_TABLE . " SET user_posts = {$row['num_posts']} WHERE user_id = {$row['poster_id']}"); - } - $db->sql_freeresult($result); - */ -} - -/** -* Updates topics_posted entries -*/ -function update_topics_posted() -{ - global $db; - - switch ($db->get_sql_layer()) - { - case 'sqlite3': - $db->sql_query('DELETE FROM ' . TOPICS_POSTED_TABLE); - break; - - default: - $db->sql_query('TRUNCATE TABLE ' . TOPICS_POSTED_TABLE); - break; - } - - // This can get really nasty... therefore we only do the last six months - $get_from_time = time() - (6 * 4 * 7 * 24 * 60 * 60); - - // Select forum ids, do not include categories - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE . ' - WHERE forum_type <> ' . FORUM_CAT; - $result = $db->sql_query($sql); - - $forum_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $forum_ids[] = $row['forum_id']; - } - $db->sql_freeresult($result); - - // Any global announcements? ;) - $forum_ids[] = 0; - - // Now go through the forums and get us some topics... - foreach ($forum_ids as $forum_id) - { - $sql = 'SELECT p.poster_id, p.topic_id - FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t - WHERE t.forum_id = ' . $forum_id . ' - AND t.topic_moved_id = 0 - AND t.topic_last_post_time > ' . $get_from_time . ' - AND t.topic_id = p.topic_id - AND p.poster_id <> ' . ANONYMOUS . ' - GROUP BY p.poster_id, p.topic_id'; - $result = $db->sql_query($sql); - - $posted = array(); - while ($row = $db->sql_fetchrow($result)) - { - $posted[$row['poster_id']][] = $row['topic_id']; - } - $db->sql_freeresult($result); - - $sql_ary = array(); - foreach ($posted as $user_id => $topic_row) - { - foreach ($topic_row as $topic_id) - { - $sql_ary[] = array( - 'user_id' => (int) $user_id, - 'topic_id' => (int) $topic_id, - 'topic_posted' => 1, - ); - } - } - unset($posted); - - if (count($sql_ary)) - { - $db->sql_multi_insert(TOPICS_POSTED_TABLE, $sql_ary); - } - } -} - -/** -* Ensure that all users have a default group specified and update related information such as their colour -*/ -function fix_empty_primary_groups() -{ - global $db; - - // Set group ids for users not already having it - $sql = 'UPDATE ' . USERS_TABLE . ' SET group_id = ' . get_group_id('registered') . ' - WHERE group_id = 0 AND user_type = ' . USER_INACTIVE; - $db->sql_query($sql); - - $sql = 'UPDATE ' . USERS_TABLE . ' SET group_id = ' . get_group_id('registered') . ' - WHERE group_id = 0 AND user_type = ' . USER_NORMAL; - $db->sql_query($sql); - - $db->sql_query('UPDATE ' . USERS_TABLE . ' SET group_id = ' . get_group_id('guests') . ' WHERE user_id = ' . ANONYMOUS); - - $sql = 'SELECT user_id FROM ' . USER_GROUP_TABLE . ' WHERE group_id = ' . get_group_id('administrators'); - $result = $db->sql_query($sql); - - $user_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $user_ids[] = $row['user_id']; - } - $db->sql_freeresult($result); - - if (count($user_ids)) - { - $db->sql_query('UPDATE ' . USERS_TABLE . ' SET group_id = ' . get_group_id('administrators') . ' - WHERE group_id = 0 AND ' . $db->sql_in_set('user_id', $user_ids)); - } - - $sql = 'SELECT user_id FROM ' . USER_GROUP_TABLE . ' WHERE group_id = ' . get_group_id('global_moderators'); - $result = $db->sql_query($sql); - - $user_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $user_ids[] = $row['user_id']; - } - $db->sql_freeresult($result); - - if (count($user_ids)) - { - $db->sql_query('UPDATE ' . USERS_TABLE . ' SET group_id = ' . get_group_id('global_moderators') . ' - WHERE group_id = 0 AND ' . $db->sql_in_set('user_id', $user_ids)); - } - - // Set user colour - $sql = 'SELECT group_id, group_colour FROM ' . GROUPS_TABLE . " - WHERE group_colour <> ''"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $db->sql_query('UPDATE ' . USERS_TABLE . " SET user_colour = '{$row['group_colour']}' WHERE group_id = {$row['group_id']}"); - } - $db->sql_freeresult($result); -} - -/** -* Cleanly remove invalid user entries after converting the users table... -*/ -function remove_invalid_users() -{ - global $db, $phpEx, $phpbb_root_path; - - // username_clean is UNIQUE - $sql = 'SELECT user_id - FROM ' . USERS_TABLE . " - WHERE username_clean = ''"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - if (!function_exists('user_delete')) - { - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - } - - user_delete('remove', $row['user_id']); - } -} - -function convert_bbcode($message, $convert_size = true, $extended_bbcodes = false) -{ - static $orig, $repl, $origx, $replx, $str_from, $str_to; - - if (empty($orig)) - { - $orig = $repl = array(); - - $orig[] = '#\[(php|sql)\](.*?)\[/(php|sql)\]#is'; - $repl[] = '[code]\2[/code]'; - - $orig[] = '#\[font=[^\]]+\](.*?)\[/font\]#is'; - $repl[] = '\1'; - - $orig[] = '#\[align=[a-z]+\](.*?)\[/align\]#is'; - $repl[] = '\1'; - - $orig[] = '#\[/list=.*?\]#is'; - $repl[] = '[/list]'; - - $origx = array( - '#\[glow[^\]]+\](.*?)\[/glow\]#is', - '#\[shadow[^\]]+\](.*?)\[/shadow\]#is', - '#\[flash[^\]]+\](.*?)\[/flash\]#is' - ); - - $replx = array( - '\1', - '\1', - '[url=\1]Flash[/url]' - ); - - $str_from = array( - '[ftp]', '[/ftp]', - '[ftp=', '[/ftp]', - '[pre]', '[/pre]', - '[table]', '[/table]', - '[td]', '[/td]', - '[tr]', '[/tr]', - '[s]', '[/s]', - '[left]', '[/left]', - '[right]', '[/right]', - '[center]', '[/center]', - '[sub]', '[/sub]', - '[sup]', '[/sup]', - '[tt]', '[/tt]', - '[move]', '[/move]', - '[hr]' - ); - - $str_to = array( - '[url]', '[/url]', - '[url=', '[/url]', - '[code]', '[/code]', - "\n", '', - '', '', - "\n", '', - '', '', - '', '', - '', '', - '', '', - '', '', - '', '', - '', '', - '', '', - "\n\n" - ); - - for ($i = 0, $end = count($str_from); $i < $end; ++$i) - { - $origx[] = '#\\' . str_replace(']', '\\]', $str_from[$i]) . '#is'; - $replx[] = $str_to[$i]; - } - } - - if (preg_match_all('#\[email=([^\]]+)\](.*?)\[/email\]#i', $message, $m)) - { - for ($i = 0, $end = count($m[1]); $i < $end; ++$i) - { - if ($m[1][$i] == $m[2][$i]) - { - $message = str_replace($m[0][$i], '[email]' . $m[1][$i] . '[/email]', $message); - } - else - { - $message = str_replace($m[0][$i], $m[2][$i] . ' ([email]' . $m[1][$i] . '[/email])', $message); - } - } - } - - if ($convert_size && preg_match('#\[size=[0-9]+\].*?\[/size\]#i', $message)) - { - $size = array(9, 9, 12, 15, 18, 24, 29, 29, 29, 29); - $message = preg_replace('#\[size=([0-9]+)\](.*?)\[/size\]#i', '[size=\1]\2[/size]', $message); - $message = preg_replace('#\[size=[0-9]{2,}\](.*?)\[/size\]#i', '[size=29]\1[/size]', $message); - - for ($i = count($size); $i;) - { - $i--; - $message = str_replace('[size=' . $i . ']', '[size=' . $size[$i] . ']', $message); - } - } - - if ($extended_bbcodes) - { - $message = preg_replace($origx, $replx, $message); - } - - $message = preg_replace($orig, $repl, $message); - return $message; -} - - -function copy_file($src, $trg, $overwrite = false, $die_on_failure = true, $source_relative_path = true) -{ - global $convert, $phpbb_root_path, $user, $phpbb_filesystem; - - /** @var \phpbb\filesystem\filesystem_interface $filesystem */ - $filesystem = $phpbb_filesystem; - - if (substr($trg, -1) == '/') - { - $trg .= utf8_basename($src); - } - $src_path = relative_base($src, $source_relative_path, __LINE__, __FILE__); - $trg_path = $trg; - - if (!$overwrite && @file_exists($trg_path)) - { - return true; - } - - if (!@file_exists($src_path)) - { - return; - } - - $path = $phpbb_root_path; - $parts = explode('/', $trg); - unset($parts[count($parts) - 1]); - - for ($i = 0, $end = count($parts); $i < $end; ++$i) - { - $path .= $parts[$i] . '/'; - - if (!is_dir($path)) - { - @mkdir($path, 0777); - } - } - - if (!$filesystem->is_writable($path)) - { - @chmod($path, 0777); - } - - if (!@copy($src_path, $phpbb_root_path . $trg_path)) - { - $convert->p_master->error(sprintf($user->lang['COULD_NOT_COPY'], $src_path, $phpbb_root_path . $trg_path), __LINE__, __FILE__, !$die_on_failure); - return; - } - - if ($perm = @fileperms($src_path)) - { - @chmod($phpbb_root_path . $trg_path, $perm); - } - - return true; -} - -function copy_dir($src, $trg, $copy_subdirs = true, $overwrite = false, $die_on_failure = true, $source_relative_path = true) -{ - global $convert, $phpbb_root_path, $config, $user, $phpbb_filesystem; - - /** @var \phpbb\filesystem\filesystem_interface $filesystem */ - $filesystem = $phpbb_filesystem; - - $dirlist = $filelist = $bad_dirs = array(); - $src = path($src, $source_relative_path); - $trg = path($trg); - $src_path = relative_base($src, $source_relative_path, __LINE__, __FILE__); - $trg_path = $phpbb_root_path . $trg; - - if (!is_dir($trg_path)) - { - @mkdir($trg_path, 0777); - @chmod($trg_path, 0777); - } - - if (!$filesystem->is_writable($trg_path)) - { - $bad_dirs[] = path($config['script_path']) . $trg; - } - - if ($handle = @opendir($src_path)) - { - while ($entry = readdir($handle)) - { - if ($entry[0] == '.' || $entry == 'CVS' || $entry == 'index.htm') - { - continue; - } - - if (is_dir($src_path . $entry)) - { - $dirlist[] = $entry; - } - else - { - $filelist[] = $entry; - } - } - closedir($handle); - } - else if ($dir = @dir($src_path)) - { - while ($entry = $dir->read()) - { - if ($entry[0] == '.' || $entry == 'CVS' || $entry == 'index.htm') - { - continue; - } - - if (is_dir($src_path . $entry)) - { - $dirlist[] = $entry; - } - else - { - $filelist[] = $entry; - } - } - $dir->close(); - } - else - { - $convert->p_master->error(sprintf($user->lang['CONV_ERROR_COULD_NOT_READ'], relative_base($src, $source_relative_path)), __LINE__, __FILE__); - } - - if ($copy_subdirs) - { - for ($i = 0, $end = count($dirlist); $i < $end; ++$i) - { - $dir = $dirlist[$i]; - - if ($dir == 'CVS') - { - continue; - } - - if (!is_dir($trg_path . $dir)) - { - @mkdir($trg_path . $dir, 0777); - @chmod($trg_path . $dir, 0777); - } - - if (!$filesystem->is_writable($trg_path . $dir)) - { - $bad_dirs[] = $trg . $dir; - $bad_dirs[] = $trg_path . $dir; - } - - if (!count($bad_dirs)) - { - copy_dir($src . $dir, $trg . $dir, true, $overwrite, $die_on_failure, $source_relative_path); - } - } - } - - if (count($bad_dirs)) - { - $str = (count($bad_dirs) == 1) ? $user->lang['MAKE_FOLDER_WRITABLE'] : $user->lang['MAKE_FOLDERS_WRITABLE']; - sort($bad_dirs); - $convert->p_master->error(sprintf($str, implode('
', $bad_dirs)), __LINE__, __FILE__); - } - - for ($i = 0, $end = count($filelist); $i < $end; ++$i) - { - copy_file($src . $filelist[$i], $trg . $filelist[$i], $overwrite, $die_on_failure, $source_relative_path); - } -} - -function relative_base($path, $is_relative = true, $line = false, $file = false) -{ - global $convert, $user; - - if (!$is_relative) - { - return $path; - } - - if (empty($convert->options['forum_path']) && $is_relative) - { - $line = $line ? $line : __LINE__; - $file = $file ? $file : __FILE__; - - $convert->p_master->error($user->lang['CONV_ERROR_NO_FORUM_PATH'], $line, $file); - } - - return $convert->options['forum_path'] . '/' . $path; -} - -function get_smiley_display() -{ - static $smiley_count = 0; - $smiley_count++; - return ($smiley_count < 50) ? 1 : 0; -} - - -function fill_dateformat($user_dateformat) -{ - global $config; - - return ((empty($user_dateformat)) ? $config['default_dateformat'] : $user_dateformat); -} diff --git a/install/update/new/includes/functions_display.php b/install/update/new/includes/functions_display.php deleted file mode 100644 index 44478db..0000000 --- a/install/update/new/includes/functions_display.php +++ /dev/null @@ -1,1725 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* Display Forums -*/ -function display_forums($root_data = '', $display_moderators = true, $return_moderators = false) -{ - global $db, $auth, $user, $template; - global $phpbb_root_path, $phpEx, $config; - global $request, $phpbb_dispatcher, $phpbb_container; - - $forum_rows = $subforums = $forum_ids = $forum_ids_moderator = $forum_moderators = $active_forum_ary = array(); - $parent_id = $visible_forums = 0; - $parent_subforum_limit = false; - - // Mark forums read? - $mark_read = $request->variable('mark', ''); - - if ($mark_read == 'all') - { - $mark_read = ''; - } - - if (!$root_data) - { - if ($mark_read == 'forums') - { - $mark_read = 'all'; - } - - $root_data = array('forum_id' => 0); - $sql_where = ''; - } - else - { - $sql_where = 'left_id > ' . $root_data['left_id'] . ' AND left_id < ' . $root_data['right_id']; - } - - // Handle marking everything read - if ($mark_read == 'all') - { - $redirect = build_url(array('mark', 'hash', 'mark_time')); - meta_refresh(3, $redirect); - - if (check_link_hash($request->variable('hash', ''), 'global')) - { - markread('all', false, false, $request->variable('mark_time', 0)); - - if ($request->is_ajax()) - { - // Tell the ajax script what language vars and URL need to be replaced - $data = array( - 'NO_UNREAD_POSTS' => $user->lang['NO_UNREAD_POSTS'], - 'UNREAD_POSTS' => $user->lang['UNREAD_POSTS'], - 'U_MARK_FORUMS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}index.$phpEx", 'hash=' . generate_link_hash('global') . '&mark=forums&mark_time=' . time(), false) : '', - 'MESSAGE_TITLE' => $user->lang['INFORMATION'], - 'MESSAGE_TEXT' => $user->lang['FORUMS_MARKED'] - ); - $json_response = new \phpbb\json_response(); - $json_response->send($data); - } - - trigger_error( - $user->lang['FORUMS_MARKED'] . '

' . - sprintf($user->lang['RETURN_INDEX'], '', '') - ); - } - else - { - trigger_error(sprintf($user->lang['RETURN_PAGE'], '', '')); - } - } - - // Display list of active topics for this category? - $show_active = (isset($root_data['forum_flags']) && ($root_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS)) ? true : false; - - $sql_array = array( - 'SELECT' => 'f.*', - 'FROM' => array( - FORUMS_TABLE => 'f' - ), - 'LEFT_JOIN' => array(), - ); - - if ($config['load_db_lastread'] && $user->data['is_registered']) - { - $sql_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TRACK_TABLE => 'ft'), 'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND ft.forum_id = f.forum_id'); - $sql_array['SELECT'] .= ', ft.mark_time'; - } - else if ($config['load_anon_lastread'] || $user->data['is_registered']) - { - $tracking_topics = $request->variable($config['cookie_name'] . '_track', '', true, \phpbb\request\request_interface::COOKIE); - $tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array(); - - if (!$user->data['is_registered']) - { - $user->data['user_lastmark'] = (isset($tracking_topics['l'])) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0; - } - } - - if ($show_active) - { - $sql_array['LEFT_JOIN'][] = array( - 'FROM' => array(FORUMS_ACCESS_TABLE => 'fa'), - 'ON' => "fa.forum_id = f.forum_id AND fa.session_id = '" . $db->sql_escape($user->session_id) . "'" - ); - - $sql_array['SELECT'] .= ', fa.user_id'; - } - - $sql_ary = array( - 'SELECT' => $sql_array['SELECT'], - 'FROM' => $sql_array['FROM'], - 'LEFT_JOIN' => $sql_array['LEFT_JOIN'], - - 'WHERE' => $sql_where, - - 'ORDER_BY' => 'f.left_id', - ); - - /** - * Event to modify the SQL query before the forum data is queried - * - * @event core.display_forums_modify_sql - * @var array sql_ary The SQL array to get the data of the forums - * @since 3.1.0-a1 - */ - $vars = array('sql_ary'); - extract($phpbb_dispatcher->trigger_event('core.display_forums_modify_sql', compact($vars))); - - $sql = $db->sql_build_query('SELECT', $sql_ary); - $result = $db->sql_query($sql); - - $forum_tracking_info = $valid_categories = array(); - $branch_root_id = $root_data['forum_id']; - - /* @var $phpbb_content_visibility \phpbb\content_visibility */ - $phpbb_content_visibility = $phpbb_container->get('content.visibility'); - - while ($row = $db->sql_fetchrow($result)) - { - /** - * Event to modify the data set of a forum - * - * This event is triggered once per forum - * - * @event core.display_forums_modify_row - * @var int branch_root_id Last top-level forum - * @var array row The data of the forum - * @since 3.1.0-a1 - */ - $vars = array('branch_root_id', 'row'); - extract($phpbb_dispatcher->trigger_event('core.display_forums_modify_row', compact($vars))); - - $forum_id = $row['forum_id']; - - // Mark forums read? - if ($mark_read == 'forums') - { - if ($auth->acl_get('f_list', $forum_id)) - { - $forum_ids[] = $forum_id; - } - - continue; - } - - // Category with no members - if ($row['forum_type'] == FORUM_CAT && ($row['left_id'] + 1 == $row['right_id'])) - { - continue; - } - - // Skip branch - if (isset($right_id)) - { - if ($row['left_id'] < $right_id) - { - continue; - } - unset($right_id); - } - - if (!$auth->acl_get('f_list', $forum_id)) - { - // if the user does not have permissions to list this forum, skip everything until next branch - $right_id = $row['right_id']; - continue; - } - - if ($config['load_db_lastread'] && $user->data['is_registered']) - { - $forum_tracking_info[$forum_id] = (!empty($row['mark_time'])) ? $row['mark_time'] : $user->data['user_lastmark']; - } - else if ($config['load_anon_lastread'] || $user->data['is_registered']) - { - if (!$user->data['is_registered']) - { - $user->data['user_lastmark'] = (isset($tracking_topics['l'])) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0; - } - $forum_tracking_info[$forum_id] = (isset($tracking_topics['f'][$forum_id])) ? (int) (base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate']) : $user->data['user_lastmark']; - } - - // Lets check whether there are unapproved topics/posts, so we can display an information to moderators - $row['forum_id_unapproved_topics'] = ($auth->acl_get('m_approve', $forum_id) && $row['forum_topics_unapproved']) ? $forum_id : 0; - $row['forum_id_unapproved_posts'] = ($auth->acl_get('m_approve', $forum_id) && $row['forum_posts_unapproved']) ? $forum_id : 0; - $row['forum_posts'] = $phpbb_content_visibility->get_count('forum_posts', $row, $forum_id); - $row['forum_topics'] = $phpbb_content_visibility->get_count('forum_topics', $row, $forum_id); - - // Display active topics from this forum? - if ($show_active && $row['forum_type'] == FORUM_POST && $auth->acl_get('f_read', $forum_id) && ($row['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS)) - { - if (!isset($active_forum_ary['forum_topics'])) - { - $active_forum_ary['forum_topics'] = 0; - } - - if (!isset($active_forum_ary['forum_posts'])) - { - $active_forum_ary['forum_posts'] = 0; - } - - $active_forum_ary['forum_id'][] = $forum_id; - $active_forum_ary['enable_icons'][] = $row['enable_icons']; - $active_forum_ary['forum_topics'] += $row['forum_topics']; - $active_forum_ary['forum_posts'] += $row['forum_posts']; - - // If this is a passworded forum we do not show active topics from it if the user is not authorised to view it... - if ($row['forum_password'] && $row['user_id'] != $user->data['user_id']) - { - $active_forum_ary['exclude_forum_id'][] = $forum_id; - } - } - - // Fill list of categories with forums - if (isset($forum_rows[$row['parent_id']])) - { - $valid_categories[$row['parent_id']] = true; - } - - // - if ($row['parent_id'] == $root_data['forum_id'] || $row['parent_id'] == $branch_root_id) - { - if ($row['forum_type'] != FORUM_CAT) - { - $forum_ids_moderator[] = (int) $forum_id; - } - - // Direct child of current branch - $parent_id = $forum_id; - $parent_subforum_limit = $row['display_subforum_limit']; - $forum_rows[$forum_id] = $row; - - if ($row['forum_type'] == FORUM_CAT && $row['parent_id'] == $root_data['forum_id']) - { - $branch_root_id = $forum_id; - } - $forum_rows[$parent_id]['forum_id_last_post'] = $row['forum_id']; - $forum_rows[$parent_id]['forum_password_last_post'] = $row['forum_password']; - $forum_rows[$parent_id]['orig_forum_last_post_time'] = $row['forum_last_post_time']; - } - else if ($row['forum_type'] != FORUM_CAT) - { - $subforums[$parent_id][$forum_id]['display'] = ($row['display_on_index'] && (!$parent_subforum_limit || $parent_id == $row['parent_id'])); - $subforums[$parent_id][$forum_id]['name'] = $row['forum_name']; - $subforums[$parent_id][$forum_id]['orig_forum_last_post_time'] = $row['forum_last_post_time']; - $subforums[$parent_id][$forum_id]['children'] = array(); - $subforums[$parent_id][$forum_id]['type'] = $row['forum_type']; - - if (isset($subforums[$parent_id][$row['parent_id']]) && !$row['display_on_index']) - { - $subforums[$parent_id][$row['parent_id']]['children'][] = $forum_id; - } - - if (!$forum_rows[$parent_id]['forum_id_unapproved_topics'] && $row['forum_id_unapproved_topics']) - { - $forum_rows[$parent_id]['forum_id_unapproved_topics'] = $forum_id; - } - - if (!$forum_rows[$parent_id]['forum_id_unapproved_posts'] && $row['forum_id_unapproved_posts']) - { - $forum_rows[$parent_id]['forum_id_unapproved_posts'] = $forum_id; - } - - $forum_rows[$parent_id]['forum_topics'] += $row['forum_topics']; - - // Do not list redirects in LINK Forums as Posts. - if ($row['forum_type'] != FORUM_LINK) - { - $forum_rows[$parent_id]['forum_posts'] += $row['forum_posts']; - } - - if ($row['forum_last_post_time'] > $forum_rows[$parent_id]['forum_last_post_time']) - { - $forum_rows[$parent_id]['forum_last_post_id'] = $row['forum_last_post_id']; - $forum_rows[$parent_id]['forum_last_post_subject'] = $row['forum_last_post_subject']; - $forum_rows[$parent_id]['forum_last_post_time'] = $row['forum_last_post_time']; - $forum_rows[$parent_id]['forum_last_poster_id'] = $row['forum_last_poster_id']; - $forum_rows[$parent_id]['forum_last_poster_name'] = $row['forum_last_poster_name']; - $forum_rows[$parent_id]['forum_last_poster_colour'] = $row['forum_last_poster_colour']; - $forum_rows[$parent_id]['forum_id_last_post'] = $forum_id; - $forum_rows[$parent_id]['forum_password_last_post'] = $row['forum_password']; - } - } - - /** - * Event to modify the forum rows data set - * - * This event is triggered once per forum - * - * @event core.display_forums_modify_forum_rows - * @var array forum_rows Data array of all forums we display - * @var array subforums Data array of all subforums we display - * @var int branch_root_id Current top-level forum - * @var int parent_id Current parent forum - * @var array row The data of the forum - * @since 3.1.0-a1 - */ - $vars = array('forum_rows', 'subforums', 'branch_root_id', 'parent_id', 'row'); - extract($phpbb_dispatcher->trigger_event('core.display_forums_modify_forum_rows', compact($vars))); - } - $db->sql_freeresult($result); - - // Handle marking posts - if ($mark_read == 'forums') - { - $redirect = build_url(array('mark', 'hash', 'mark_time')); - $token = $request->variable('hash', ''); - if (check_link_hash($token, 'global')) - { - markread('topics', $forum_ids, false, $request->variable('mark_time', 0)); - $message = sprintf($user->lang['RETURN_FORUM'], '', ''); - meta_refresh(3, $redirect); - - if ($request->is_ajax()) - { - // Tell the ajax script what language vars and URL need to be replaced - $data = array( - 'NO_UNREAD_POSTS' => $user->lang['NO_UNREAD_POSTS'], - 'UNREAD_POSTS' => $user->lang['UNREAD_POSTS'], - 'U_MARK_FORUMS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'hash=' . generate_link_hash('global') . '&f=' . $root_data['forum_id'] . '&mark=forums&mark_time=' . time(), false) : '', - 'MESSAGE_TITLE' => $user->lang['INFORMATION'], - 'MESSAGE_TEXT' => $user->lang['FORUMS_MARKED'] - ); - $json_response = new \phpbb\json_response(); - $json_response->send($data); - } - - trigger_error($user->lang['FORUMS_MARKED'] . '

' . $message); - } - else - { - $message = sprintf($user->lang['RETURN_PAGE'], '', ''); - meta_refresh(3, $redirect); - trigger_error($message); - } - - } - - // Grab moderators ... if necessary - if ($display_moderators) - { - if ($return_moderators) - { - $forum_ids_moderator[] = $root_data['forum_id']; - } - get_moderators($forum_moderators, $forum_ids_moderator); - } - - /** - * Event to perform additional actions before the forum list is being generated - * - * @event core.display_forums_before - * @var array active_forum_ary Array with forum data to display active topics - * @var bool display_moderators Flag indicating if we display forum moderators - * @var array forum_moderators Array with forum moderators list - * @var array forum_rows Data array of all forums we display - * @var bool return_moderators Flag indicating if moderators list should be returned - * @var array root_data Array with the root forum data - * @since 3.1.4-RC1 - */ - $vars = array( - 'active_forum_ary', - 'display_moderators', - 'forum_moderators', - 'forum_rows', - 'return_moderators', - 'root_data', - ); - extract($phpbb_dispatcher->trigger_event('core.display_forums_before', compact($vars))); - - // Used to tell whatever we have to create a dummy category or not. - $last_catless = true; - foreach ($forum_rows as $row) - { - // Category - if ($row['parent_id'] == $root_data['forum_id'] && $row['forum_type'] == FORUM_CAT) - { - // Do not display categories without any forums to display - if (!isset($valid_categories[$row['forum_id']])) - { - continue; - } - - $cat_row = array( - 'S_IS_CAT' => true, - 'FORUM_ID' => $row['forum_id'], - 'FORUM_NAME' => $row['forum_name'], - 'FORUM_DESC' => generate_text_for_display($row['forum_desc'], $row['forum_desc_uid'], $row['forum_desc_bitfield'], $row['forum_desc_options']), - 'FORUM_FOLDER_IMG' => '', - 'FORUM_FOLDER_IMG_SRC' => '', - 'FORUM_IMAGE' => ($row['forum_image']) ? '' . $user->lang['FORUM_CAT'] . '' : '', - 'FORUM_IMAGE_SRC' => ($row['forum_image']) ? $phpbb_root_path . $row['forum_image'] : '', - 'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']), - ); - - /** - * Modify the template data block of the 'category' - * - * This event is triggered once per 'category' - * - * @event core.display_forums_modify_category_template_vars - * @var array cat_row Template data of the 'category' - * @var bool last_catless The flag indicating whether the last forum had a parent category - * @var array root_data Array with the root forum data - * @var array row The data of the 'category' - * @since 3.1.0-RC4 - * @changed 3.1.7-RC1 Removed undefined catless variable - */ - $vars = array( - 'cat_row', - 'last_catless', - 'root_data', - 'row', - ); - extract($phpbb_dispatcher->trigger_event('core.display_forums_modify_category_template_vars', compact($vars))); - - $template->assign_block_vars('forumrow', $cat_row); - - continue; - } - - $visible_forums++; - $forum_id = $row['forum_id']; - - $forum_unread = (isset($forum_tracking_info[$forum_id]) && $row['orig_forum_last_post_time'] > $forum_tracking_info[$forum_id]) ? true : false; - - $folder_image = $folder_alt = $l_subforums = ''; - $subforums_list = array(); - - // Generate list of subforums if we need to - if (isset($subforums[$forum_id])) - { - foreach ($subforums[$forum_id] as $subforum_id => $subforum_row) - { - $subforum_unread = (isset($forum_tracking_info[$subforum_id]) && $subforum_row['orig_forum_last_post_time'] > $forum_tracking_info[$subforum_id]) ? true : false; - - if (!$subforum_unread && !empty($subforum_row['children'])) - { - foreach ($subforum_row['children'] as $child_id) - { - if (isset($forum_tracking_info[$child_id]) && $subforums[$forum_id][$child_id]['orig_forum_last_post_time'] > $forum_tracking_info[$child_id]) - { - // Once we found an unread child forum, we can drop out of this loop - $subforum_unread = true; - break; - } - } - } - - if ($subforum_row['display'] && $subforum_row['name']) - { - $subforums_list[] = array( - 'link' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $subforum_id), - 'name' => $subforum_row['name'], - 'unread' => $subforum_unread, - 'type' => $subforum_row['type'], - ); - } - else - { - unset($subforums[$forum_id][$subforum_id]); - } - - // If one subforum is unread the forum gets unread too... - if ($subforum_unread) - { - $forum_unread = true; - } - } - - $l_subforums = (count($subforums[$forum_id]) == 1) ? $user->lang['SUBFORUM'] : $user->lang['SUBFORUMS']; - $folder_image = ($forum_unread) ? 'forum_unread_subforum' : 'forum_read_subforum'; - } - else - { - switch ($row['forum_type']) - { - case FORUM_POST: - $folder_image = ($forum_unread) ? 'forum_unread' : 'forum_read'; - break; - - case FORUM_LINK: - $folder_image = 'forum_link'; - break; - } - } - - // Which folder should we display? - if ($row['forum_status'] == ITEM_LOCKED) - { - $folder_image = ($forum_unread) ? 'forum_unread_locked' : 'forum_read_locked'; - $folder_alt = 'FORUM_LOCKED'; - } - else - { - $folder_alt = ($forum_unread) ? 'UNREAD_POSTS' : 'NO_UNREAD_POSTS'; - } - - // Create last post link information, if appropriate - if ($row['forum_last_post_id']) - { - if ($row['forum_password_last_post'] === '' && $auth->acl_gets('f_read', 'f_list_topics', $row['forum_id_last_post'])) - { - $last_post_subject = utf8_decode_ncr(censor_text($row['forum_last_post_subject'])); - - $last_post_subject_truncated = truncate_string($last_post_subject, 30, 255, false, $user->lang['ELLIPSIS']); - } - else - { - $last_post_subject = $last_post_subject_truncated = ''; - } - $last_post_time = $user->format_date($row['forum_last_post_time']); - $last_post_time_rfc3339 = gmdate(DATE_RFC3339, $row['forum_last_post_time']); - $last_post_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id_last_post'] . '&p=' . $row['forum_last_post_id']) . '#p' . $row['forum_last_post_id']; - } - else - { - $last_post_subject = $last_post_time = $last_post_time_rfc3339 = $last_post_url = $last_post_subject_truncated = ''; - } - - // Output moderator listing ... if applicable - $l_moderator = $moderators_list = ''; - if ($display_moderators && !empty($forum_moderators[$forum_id])) - { - $l_moderator = (count($forum_moderators[$forum_id]) == 1) ? $user->lang['MODERATOR'] : $user->lang['MODERATORS']; - $moderators_list = implode($user->lang['COMMA_SEPARATOR'], $forum_moderators[$forum_id]); - } - - $l_post_click_count = ($row['forum_type'] == FORUM_LINK) ? 'CLICKS' : 'POSTS'; - $post_click_count = ($row['forum_type'] != FORUM_LINK || $row['forum_flags'] & FORUM_FLAG_LINK_TRACK) ? $row['forum_posts'] : ''; - - $s_subforums_list = $subforums_row = array(); - foreach ($subforums_list as $subforum) - { - $s_subforums_list[] = '' . $subforum['name'] . ''; - $subforums_row[] = array( - 'U_SUBFORUM' => $subforum['link'], - 'SUBFORUM_NAME' => $subforum['name'], - 'S_UNREAD' => $subforum['unread'], - 'IS_LINK' => $subforum['type'] == FORUM_LINK, - ); - } - $s_subforums_list = (string) implode($user->lang['COMMA_SEPARATOR'], $s_subforums_list); - $catless = ($row['parent_id'] == $root_data['forum_id']) ? true : false; - - if ($row['forum_type'] != FORUM_LINK) - { - $u_viewforum = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']); - } - else - { - // If the forum is a link and we count redirects we need to visit it - // If the forum is having a password or no read access we do not expose the link, but instead handle it in viewforum - if (($row['forum_flags'] & FORUM_FLAG_LINK_TRACK) || $row['forum_password'] || !$auth->acl_get('f_read', $forum_id)) - { - $u_viewforum = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']); - } - else - { - $u_viewforum = $row['forum_link']; - } - } - - $forum_row = array( - 'S_IS_CAT' => false, - 'S_NO_CAT' => $catless && !$last_catless, - 'S_IS_LINK' => ($row['forum_type'] == FORUM_LINK) ? true : false, - 'S_UNREAD_FORUM' => $forum_unread, - 'S_AUTH_READ' => $auth->acl_get('f_read', $row['forum_id']), - 'S_LOCKED_FORUM' => ($row['forum_status'] == ITEM_LOCKED) ? true : false, - 'S_LIST_SUBFORUMS' => ($row['display_subforum_list']) ? true : false, - 'S_SUBFORUMS' => (count($subforums_list)) ? true : false, - 'S_DISPLAY_SUBJECT' => ($last_post_subject !== '' && $config['display_last_subject']) ? true : false, - 'S_FEED_ENABLED' => ($config['feed_forum'] && !phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $row['forum_options']) && $row['forum_type'] == FORUM_POST) ? true : false, - - 'FORUM_ID' => $row['forum_id'], - 'FORUM_NAME' => $row['forum_name'], - 'FORUM_DESC' => generate_text_for_display($row['forum_desc'], $row['forum_desc_uid'], $row['forum_desc_bitfield'], $row['forum_desc_options']), - 'TOPICS' => $row['forum_topics'], - $l_post_click_count => $post_click_count, - 'FORUM_IMG_STYLE' => $folder_image, - 'FORUM_FOLDER_IMG' => $user->img($folder_image, $folder_alt), - 'FORUM_FOLDER_IMG_ALT' => isset($user->lang[$folder_alt]) ? $user->lang[$folder_alt] : '', - 'FORUM_IMAGE' => ($row['forum_image']) ? '' . $user->lang[$folder_alt] . '' : '', - 'FORUM_IMAGE_SRC' => ($row['forum_image']) ? $phpbb_root_path . $row['forum_image'] : '', - 'LAST_POST_SUBJECT' => $last_post_subject, - 'LAST_POST_SUBJECT_TRUNCATED' => $last_post_subject_truncated, - 'LAST_POST_TIME' => $last_post_time, - 'LAST_POST_TIME_RFC3339'=> $last_post_time_rfc3339, - 'LAST_POSTER' => get_username_string('username', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']), - 'LAST_POSTER_COLOUR' => get_username_string('colour', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']), - 'LAST_POSTER_FULL' => get_username_string('full', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']), - 'MODERATORS' => $moderators_list, - 'SUBFORUMS' => $s_subforums_list, - - 'L_SUBFORUM_STR' => $l_subforums, - 'L_MODERATOR_STR' => $l_moderator, - - 'U_UNAPPROVED_TOPICS' => ($row['forum_id_unapproved_topics']) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=unapproved_topics&f=' . $row['forum_id_unapproved_topics']) : '', - 'U_UNAPPROVED_POSTS' => ($row['forum_id_unapproved_posts']) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=unapproved_posts&f=' . $row['forum_id_unapproved_posts']) : '', - 'U_VIEWFORUM' => $u_viewforum, - 'U_LAST_POSTER' => get_username_string('profile', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']), - 'U_LAST_POST' => $last_post_url, - ); - - /** - * Modify the template data block of the forum - * - * This event is triggered once per forum - * - * @event core.display_forums_modify_template_vars - * @var array forum_row Template data of the forum - * @var array row The data of the forum - * @var array subforums_row Template data of subforums - * @since 3.1.0-a1 - * @changed 3.1.0-b5 Added var subforums_row - */ - $vars = array('forum_row', 'row', 'subforums_row'); - extract($phpbb_dispatcher->trigger_event('core.display_forums_modify_template_vars', compact($vars))); - - $template->assign_block_vars('forumrow', $forum_row); - - // Assign subforums loop for style authors - $template->assign_block_vars_array('forumrow.subforum', $subforums_row); - - /** - * Modify and/or assign additional template data for the forum - * after forumrow loop has been assigned. This can be used - * to create additional forumrow subloops in extensions. - * - * This event is triggered once per forum - * - * @event core.display_forums_add_template_data - * @var array forum_row Template data of the forum - * @var array row The data of the forum - * @var array subforums_list The data of subforums - * @var array subforums_row Template data of subforums - * @var bool catless The flag indicating whether a forum has a parent category - * @since 3.1.0-b5 - */ - $vars = array( - 'forum_row', - 'row', - 'subforums_list', - 'subforums_row', - 'catless', - ); - extract($phpbb_dispatcher->trigger_event('core.display_forums_add_template_data', compact($vars))); - - $last_catless = $catless; - } - - $template->assign_vars(array( - 'U_MARK_FORUMS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'hash=' . generate_link_hash('global') . '&f=' . $root_data['forum_id'] . '&mark=forums&mark_time=' . time()) : '', - 'S_HAS_SUBFORUM' => ($visible_forums) ? true : false, - 'L_SUBFORUM' => ($visible_forums == 1) ? $user->lang['SUBFORUM'] : $user->lang['SUBFORUMS'], - 'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'), - 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'TOPICS_UNAPPROVED'), - 'UNAPPROVED_POST_IMG' => $user->img('icon_topic_unapproved', 'POSTS_UNAPPROVED_FORUM'), - )); - - /** - * Event to perform additional actions after the forum list has been generated - * - * @event core.display_forums_after - * @var array active_forum_ary Array with forum data to display active topics - * @var bool display_moderators Flag indicating if we display forum moderators - * @var array forum_moderators Array with forum moderators list - * @var array forum_rows Data array of all forums we display - * @var bool return_moderators Flag indicating if moderators list should be returned - * @var array root_data Array with the root forum data - * @since 3.1.0-RC5 - */ - $vars = array( - 'active_forum_ary', - 'display_moderators', - 'forum_moderators', - 'forum_rows', - 'return_moderators', - 'root_data', - ); - extract($phpbb_dispatcher->trigger_event('core.display_forums_after', compact($vars))); - - if ($return_moderators) - { - return array($active_forum_ary, $forum_moderators); - } - - return array($active_forum_ary, array()); -} - -/** -* Create forum rules for given forum -*/ -function generate_forum_rules(&$forum_data) -{ - if ($forum_data['forum_rules']) - { - $forum_data['forum_rules'] = generate_text_for_display($forum_data['forum_rules'], $forum_data['forum_rules_uid'], $forum_data['forum_rules_bitfield'], $forum_data['forum_rules_options']); - } - - if (!$forum_data['forum_rules'] && !$forum_data['forum_rules_link']) - { - return; - } - - global $template; - - $template->assign_vars(array( - 'S_FORUM_RULES' => true, - 'U_FORUM_RULES' => $forum_data['forum_rules_link'], - 'FORUM_RULES' => $forum_data['forum_rules']) - ); -} - -/** -* Create forum navigation links for given forum, create parent -* list if currently null, assign basic forum info to template -*/ -function generate_forum_nav(&$forum_data_ary) -{ - global $template, $auth, $config; - global $phpEx, $phpbb_root_path, $phpbb_dispatcher; - - if (!$auth->acl_get('f_list', $forum_data_ary['forum_id'])) - { - return; - } - - $navlinks_parents = $forum_template_data = array(); - - // Get forum parents - $forum_parents = get_forum_parents($forum_data_ary); - - $microdata_attr = 'data-forum-id'; - - // Build navigation links - if (!empty($forum_parents)) - { - foreach ($forum_parents as $parent_forum_id => $parent_data) - { - list($parent_name, $parent_type) = array_values($parent_data); - - // Skip this parent if the user does not have the permission to view it - if (!$auth->acl_get('f_list', $parent_forum_id)) - { - continue; - } - - $navlinks_parents[] = array( - 'S_IS_CAT' => ($parent_type == FORUM_CAT) ? true : false, - 'S_IS_LINK' => ($parent_type == FORUM_LINK) ? true : false, - 'S_IS_POST' => ($parent_type == FORUM_POST) ? true : false, - 'BREADCRUMB_NAME' => $parent_name, - 'FORUM_ID' => $parent_forum_id, - 'MICRODATA' => $microdata_attr . '="' . $parent_forum_id . '"', - 'U_BREADCRUMB' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $parent_forum_id), - ); - } - } - - $navlinks = array( - 'S_IS_CAT' => ($forum_data_ary['forum_type'] == FORUM_CAT) ? true : false, - 'S_IS_LINK' => ($forum_data_ary['forum_type'] == FORUM_LINK) ? true : false, - 'S_IS_POST' => ($forum_data_ary['forum_type'] == FORUM_POST) ? true : false, - 'BREADCRUMB_NAME' => $forum_data_ary['forum_name'], - 'FORUM_ID' => $forum_data_ary['forum_id'], - 'MICRODATA' => $microdata_attr . '="' . $forum_data_ary['forum_id'] . '"', - 'U_BREADCRUMB' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_data_ary['forum_id']), - ); - - $forum_template_data = array( - 'FORUM_ID' => $forum_data_ary['forum_id'], - 'FORUM_NAME' => $forum_data_ary['forum_name'], - 'FORUM_DESC' => generate_text_for_display($forum_data_ary['forum_desc'], $forum_data_ary['forum_desc_uid'], $forum_data_ary['forum_desc_bitfield'], $forum_data_ary['forum_desc_options']), - - 'S_ENABLE_FEEDS_FORUM' => ($config['feed_forum'] && $forum_data_ary['forum_type'] == FORUM_POST && !phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $forum_data_ary['forum_options'])) ? true : false, - ); - - $forum_data = $forum_data_ary; - /** - * Event to modify the navlinks text - * - * @event core.generate_forum_nav - * @var array forum_data Array with the forum data - * @var array forum_template_data Array with generic forum template data - * @var string microdata_attr The microdata attribute - * @var array navlinks_parents Array with the forum parents navlinks data - * @var array navlinks Array with the forum navlinks data - * @since 3.1.5-RC1 - */ - $vars = array( - 'forum_data', - 'forum_template_data', - 'microdata_attr', - 'navlinks_parents', - 'navlinks', - ); - extract($phpbb_dispatcher->trigger_event('core.generate_forum_nav', compact($vars))); - $forum_data_ary = $forum_data; - unset($forum_data); - - $template->assign_block_vars_array('navlinks', $navlinks_parents); - $template->assign_block_vars('navlinks', $navlinks); - $template->assign_vars($forum_template_data); - - return; -} - -/** -* Returns forum parents as an array. Get them from forum_data if available, or update the database otherwise -*/ -function get_forum_parents(&$forum_data) -{ - global $db; - - $forum_parents = array(); - - if ($forum_data['parent_id'] > 0) - { - if ($forum_data['forum_parents'] == '') - { - $sql = 'SELECT forum_id, forum_name, forum_type - FROM ' . FORUMS_TABLE . ' - WHERE left_id < ' . $forum_data['left_id'] . ' - AND right_id > ' . $forum_data['right_id'] . ' - ORDER BY left_id ASC'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $forum_parents[$row['forum_id']] = array($row['forum_name'], (int) $row['forum_type']); - } - $db->sql_freeresult($result); - - $forum_data['forum_parents'] = serialize($forum_parents); - - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET forum_parents = '" . $db->sql_escape($forum_data['forum_parents']) . "' - WHERE parent_id = " . $forum_data['parent_id']; - $db->sql_query($sql); - } - else - { - $forum_parents = unserialize($forum_data['forum_parents']); - } - } - - return $forum_parents; -} - -/** -* Obtain list of moderators of each forum -*/ -function get_moderators(&$forum_moderators, $forum_id = false) -{ - global $db, $phpbb_root_path, $phpEx, $user, $auth; - global $phpbb_container; - - $forum_id_ary = array(); - - if ($forum_id !== false) - { - if (!is_array($forum_id)) - { - $forum_id = array($forum_id); - } - - // Exchange key/value pair to be able to faster check for the forum id existence - $forum_id_ary = array_flip($forum_id); - } - - $sql_array = array( - 'SELECT' => 'm.*, u.user_colour, g.group_colour, g.group_type', - - 'FROM' => array( - MODERATOR_CACHE_TABLE => 'm', - ), - - 'LEFT_JOIN' => array( - array( - 'FROM' => array(USERS_TABLE => 'u'), - 'ON' => 'm.user_id = u.user_id', - ), - array( - 'FROM' => array(GROUPS_TABLE => 'g'), - 'ON' => 'm.group_id = g.group_id', - ), - ), - - 'WHERE' => 'm.display_on_index = 1', - ); - - /** @var \phpbb\group\helper $group_helper */ - $group_helper = $phpbb_container->get('group_helper'); - - // We query every forum here because for caching we should not have any parameter. - $sql = $db->sql_build_query('SELECT', $sql_array); - $result = $db->sql_query($sql, 3600); - - while ($row = $db->sql_fetchrow($result)) - { - $f_id = (int) $row['forum_id']; - - if (!isset($forum_id_ary[$f_id])) - { - continue; - } - - if (!empty($row['user_id'])) - { - $forum_moderators[$f_id][] = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']); - } - else - { - $group_name = $group_helper->get_name($row['group_name']); - - if ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')) - { - $forum_moderators[$f_id][] = '' . $group_name . ''; - } - else - { - $forum_moderators[$f_id][] = '' . $group_name . ''; - } - } - } - $db->sql_freeresult($result); - - return; -} - -/** -* User authorisation levels output -* -* @param string $mode Can be forum or topic. Not in use at the moment. -* @param int $forum_id The current forum the user is in. -* @param int $forum_status The forums status bit. -*/ -function gen_forum_auth_level($mode, $forum_id, $forum_status) -{ - global $template, $auth, $user, $config; - - $locked = ($forum_status == ITEM_LOCKED && !$auth->acl_get('m_edit', $forum_id)) ? true : false; - - $rules = array( - ($auth->acl_get('f_post', $forum_id) && !$locked) ? $user->lang['RULES_POST_CAN'] : $user->lang['RULES_POST_CANNOT'], - ($auth->acl_get('f_reply', $forum_id) && !$locked) ? $user->lang['RULES_REPLY_CAN'] : $user->lang['RULES_REPLY_CANNOT'], - ($user->data['is_registered'] && $auth->acl_gets('f_edit', 'm_edit', $forum_id) && !$locked) ? $user->lang['RULES_EDIT_CAN'] : $user->lang['RULES_EDIT_CANNOT'], - ($user->data['is_registered'] && ($auth->acl_gets('f_delete', 'm_delete', $forum_id) || $auth->acl_gets('f_softdelete', 'm_softdelete', $forum_id)) && !$locked) ? $user->lang['RULES_DELETE_CAN'] : $user->lang['RULES_DELETE_CANNOT'], - ); - - if ($config['allow_attachments']) - { - $rules[] = ($auth->acl_get('f_attach', $forum_id) && $auth->acl_get('u_attach') && !$locked) ? $user->lang['RULES_ATTACH_CAN'] : $user->lang['RULES_ATTACH_CANNOT']; - } - - foreach ($rules as $rule) - { - $template->assign_block_vars('rules', array('RULE' => $rule)); - } - - return; -} - -/** -* Generate topic status -*/ -function topic_status(&$topic_row, $replies, $unread_topic, &$folder_img, &$folder_alt, &$topic_type) -{ - global $user, $config; - - if ($topic_row['topic_status'] == ITEM_MOVED) - { - $topic_type = $user->lang['VIEW_TOPIC_MOVED']; - $folder_img = 'topic_moved'; - $folder_alt = 'TOPIC_MOVED'; - } - else - { - switch ($topic_row['topic_type']) - { - case POST_GLOBAL: - $topic_type = $user->lang['VIEW_TOPIC_GLOBAL']; - $folder = 'global_read'; - $folder_new = 'global_unread'; - break; - - case POST_ANNOUNCE: - $topic_type = $user->lang['VIEW_TOPIC_ANNOUNCEMENT']; - $folder = 'announce_read'; - $folder_new = 'announce_unread'; - break; - - case POST_STICKY: - $topic_type = $user->lang['VIEW_TOPIC_STICKY']; - $folder = 'sticky_read'; - $folder_new = 'sticky_unread'; - break; - - default: - $topic_type = ''; - $folder = 'topic_read'; - $folder_new = 'topic_unread'; - - // Hot topic threshold is for posts in a topic, which is replies + the first post. ;) - if ($config['hot_threshold'] && ($replies + 1) >= $config['hot_threshold'] && $topic_row['topic_status'] != ITEM_LOCKED) - { - $folder .= '_hot'; - $folder_new .= '_hot'; - } - break; - } - - if ($topic_row['topic_status'] == ITEM_LOCKED) - { - $topic_type = $user->lang['VIEW_TOPIC_LOCKED']; - $folder .= '_locked'; - $folder_new .= '_locked'; - } - - $folder_img = ($unread_topic) ? $folder_new : $folder; - $folder_alt = ($unread_topic) ? 'UNREAD_POSTS' : (($topic_row['topic_status'] == ITEM_LOCKED) ? 'TOPIC_LOCKED' : 'NO_UNREAD_POSTS'); - - // Posted image? - if (!empty($topic_row['topic_posted']) && $topic_row['topic_posted']) - { - $folder_img .= '_mine'; - } - } - - if ($topic_row['poll_start'] && $topic_row['topic_status'] != ITEM_MOVED) - { - $topic_type = $user->lang['VIEW_TOPIC_POLL']; - } -} - -/** -* Assign/Build custom bbcodes for display in screens supporting using of bbcodes -* The custom bbcodes buttons will be placed within the template block 'custom_tags' -*/ -function display_custom_bbcodes() -{ - global $db, $template, $user, $phpbb_dispatcher; - - // Start counting from 22 for the bbcode ids (every bbcode takes two ids - opening/closing) - $num_predefined_bbcodes = NUM_PREDEFINED_BBCODES; - - $sql_ary = array( - 'SELECT' => 'b.bbcode_id, b.bbcode_tag, b.bbcode_helpline', - 'FROM' => array(BBCODES_TABLE => 'b'), - 'WHERE' => 'b.display_on_posting = 1', - 'ORDER_BY' => 'b.bbcode_tag', - ); - - /** - * Event to modify the SQL query before custom bbcode data is queried - * - * @event core.display_custom_bbcodes_modify_sql - * @var array sql_ary The SQL array to get the bbcode data - * @var int num_predefined_bbcodes The number of predefined core bbcodes - * (multiplied by factor of 2) - * @since 3.1.0-a3 - */ - $vars = array('sql_ary', 'num_predefined_bbcodes'); - extract($phpbb_dispatcher->trigger_event('core.display_custom_bbcodes_modify_sql', compact($vars))); - - $result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary)); - - $i = 0; - while ($row = $db->sql_fetchrow($result)) - { - // If the helpline is defined within the language file, we will use the localised version, else just use the database entry... - if (isset($user->lang[strtoupper($row['bbcode_helpline'])])) - { - $row['bbcode_helpline'] = $user->lang[strtoupper($row['bbcode_helpline'])]; - } - - $custom_tags = array( - 'BBCODE_NAME' => "'[{$row['bbcode_tag']}]', '[/" . str_replace('=', '', $row['bbcode_tag']) . "]'", - 'BBCODE_ID' => $num_predefined_bbcodes + ($i * 2), - 'BBCODE_TAG' => $row['bbcode_tag'], - 'BBCODE_TAG_CLEAN' => str_replace('=', '-', $row['bbcode_tag']), - 'BBCODE_HELPLINE' => $row['bbcode_helpline'], - ); - - /** - * Event to modify the template data block of a custom bbcode - * - * This event is triggered once per bbcode - * - * @event core.display_custom_bbcodes_modify_row - * @var array custom_tags Template data of the bbcode - * @var array row The data of the bbcode - * @since 3.1.0-a1 - */ - $vars = array('custom_tags', 'row'); - extract($phpbb_dispatcher->trigger_event('core.display_custom_bbcodes_modify_row', compact($vars))); - - $template->assign_block_vars('custom_tags', $custom_tags); - - $i++; - } - $db->sql_freeresult($result); - - /** - * Display custom bbcodes - * - * @event core.display_custom_bbcodes - * @since 3.1.0-a1 - */ - $phpbb_dispatcher->dispatch('core.display_custom_bbcodes'); -} - -/** -* Display user activity (action forum/topic) -*/ -function display_user_activity(&$userdata_ary) -{ - global $auth, $template, $db, $user, $config; - global $phpbb_root_path, $phpEx; - global $phpbb_container, $phpbb_dispatcher; - - // Do not display user activity for users having too many posts... - $limit = $config['load_user_activity_limit']; - if ($userdata_ary['user_posts'] > $limit && $limit != 0) - { - return; - } - - $forum_ary = array(); - - $forum_read_ary = $auth->acl_getf('f_read'); - foreach ($forum_read_ary as $forum_id => $allowed) - { - if ($allowed['f_read']) - { - $forum_ary[] = (int) $forum_id; - } - } - - $forum_ary = array_diff($forum_ary, $user->get_passworded_forums()); - - $active_f_row = $active_t_row = array(); - if (!empty($forum_ary)) - { - /* @var $phpbb_content_visibility \phpbb\content_visibility */ - $phpbb_content_visibility = $phpbb_container->get('content.visibility'); - - // Obtain active forum - $sql = 'SELECT forum_id, COUNT(post_id) AS num_posts - FROM ' . POSTS_TABLE . ' - WHERE poster_id = ' . $userdata_ary['user_id'] . ' - AND post_postcount = 1 - AND ' . $phpbb_content_visibility->get_forums_visibility_sql('post', $forum_ary) . ' - GROUP BY forum_id - ORDER BY num_posts DESC'; - $result = $db->sql_query_limit($sql, 1); - $active_f_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!empty($active_f_row)) - { - $sql = 'SELECT forum_name - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . $active_f_row['forum_id']; - $result = $db->sql_query($sql, 3600); - $active_f_row['forum_name'] = (string) $db->sql_fetchfield('forum_name'); - $db->sql_freeresult($result); - } - - // Obtain active topic - $sql = 'SELECT topic_id, COUNT(post_id) AS num_posts - FROM ' . POSTS_TABLE . ' - WHERE poster_id = ' . $userdata_ary['user_id'] . ' - AND post_postcount = 1 - AND ' . $phpbb_content_visibility->get_forums_visibility_sql('post', $forum_ary) . ' - GROUP BY topic_id - ORDER BY num_posts DESC'; - $result = $db->sql_query_limit($sql, 1); - $active_t_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!empty($active_t_row)) - { - $sql = 'SELECT topic_title - FROM ' . TOPICS_TABLE . ' - WHERE topic_id = ' . $active_t_row['topic_id']; - $result = $db->sql_query($sql); - $active_t_row['topic_title'] = (string) $db->sql_fetchfield('topic_title'); - $db->sql_freeresult($result); - } - } - - $userdata = $userdata_ary; - $show_user_activity = true; - /** - * Alter list of forums and topics to display as active - * - * @event core.display_user_activity_modify_actives - * @var array userdata User's data - * @var array active_f_row List of active forums - * @var array active_t_row List of active posts - * @var bool show_user_activity Show user forum and topic activity - * @since 3.1.0-RC3 - * @changed 3.2.5-RC1 Added show_user_activity into event - */ - $vars = array('userdata', 'active_f_row', 'active_t_row', 'show_user_activity'); - extract($phpbb_dispatcher->trigger_event('core.display_user_activity_modify_actives', compact($vars))); - $userdata_ary = $userdata; - unset($userdata); - - $userdata_ary['active_t_row'] = $active_t_row; - $userdata_ary['active_f_row'] = $active_f_row; - - $active_f_name = $active_f_id = $active_f_count = $active_f_pct = ''; - if (!empty($active_f_row['num_posts'])) - { - $active_f_name = $active_f_row['forum_name']; - $active_f_id = $active_f_row['forum_id']; - $active_f_count = $active_f_row['num_posts']; - $active_f_pct = ($userdata_ary['user_posts']) ? ($active_f_count / $userdata_ary['user_posts']) * 100 : 0; - } - - $active_t_name = $active_t_id = $active_t_count = $active_t_pct = ''; - if (!empty($active_t_row['num_posts'])) - { - $active_t_name = $active_t_row['topic_title']; - $active_t_id = $active_t_row['topic_id']; - $active_t_count = $active_t_row['num_posts']; - $active_t_pct = ($userdata_ary['user_posts']) ? ($active_t_count / $userdata_ary['user_posts']) * 100 : 0; - } - - $l_active_pct = ($userdata_ary['user_id'] != ANONYMOUS && $userdata_ary['user_id'] == $user->data['user_id']) ? $user->lang['POST_PCT_ACTIVE_OWN'] : $user->lang['POST_PCT_ACTIVE']; - - $template->assign_vars(array( - 'ACTIVE_FORUM' => $active_f_name, - 'ACTIVE_FORUM_POSTS' => $user->lang('USER_POSTS', (int) $active_f_count), - 'ACTIVE_FORUM_PCT' => sprintf($l_active_pct, $active_f_pct), - 'ACTIVE_TOPIC' => censor_text($active_t_name), - 'ACTIVE_TOPIC_POSTS' => $user->lang('USER_POSTS', (int) $active_t_count), - 'ACTIVE_TOPIC_PCT' => sprintf($l_active_pct, $active_t_pct), - 'U_ACTIVE_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $active_f_id), - 'U_ACTIVE_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=' . $active_t_id), - 'S_SHOW_ACTIVITY' => $show_user_activity) - ); -} - -/** -* Topic and forum watching common code -*/ -function watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id, $notify_status = 'unset', $start = 0, $item_title = '') -{ - global $db, $user, $phpEx, $start, $phpbb_root_path; - global $request; - - $table_sql = ($mode == 'forum') ? FORUMS_WATCH_TABLE : TOPICS_WATCH_TABLE; - $where_sql = ($mode == 'forum') ? 'forum_id' : 'topic_id'; - $match_id = ($mode == 'forum') ? $forum_id : $topic_id; - $u_url = "uid={$user->data['user_id']}"; - $u_url .= ($mode == 'forum') ? '&f' : '&f=' . $forum_id . '&t'; - $is_watching = 0; - - // Is user watching this topic? - if ($user_id != ANONYMOUS) - { - $can_watch = true; - - if ($notify_status == 'unset') - { - $sql = "SELECT notify_status - FROM $table_sql - WHERE $where_sql = $match_id - AND user_id = $user_id"; - $result = $db->sql_query($sql); - - $notify_status = ($row = $db->sql_fetchrow($result)) ? $row['notify_status'] : NULL; - $db->sql_freeresult($result); - } - - if (!is_null($notify_status) && $notify_status !== '') - { - if (isset($_GET['unwatch'])) - { - $uid = $request->variable('uid', 0); - $token = $request->variable('hash', ''); - - if ($token && check_link_hash($token, "{$mode}_$match_id") || confirm_box(true)) - { - if ($uid != $user_id || $request->variable('unwatch', '', false, \phpbb\request\request_interface::GET) != $mode) - { - $redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&start=$start"); - $message = $user->lang['ERR_UNWATCHING']; - - if (!$request->is_ajax()) - { - $message .= '

' . $user->lang('RETURN_' . strtoupper($mode), '', ''); - } - trigger_error($message); - } - - $sql = 'DELETE FROM ' . $table_sql . " - WHERE $where_sql = $match_id - AND user_id = $user_id"; - $db->sql_query($sql); - - $redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&start=$start"); - $message = $user->lang['NOT_WATCHING_' . strtoupper($mode)]; - - if (!$request->is_ajax()) - { - $message .= '

' . $user->lang('RETURN_' . strtoupper($mode), '', ''); - } - meta_refresh(3, $redirect_url); - trigger_error($message); - } - else - { - $s_hidden_fields = array( - 'uid' => $user->data['user_id'], - 'unwatch' => $mode, - 'start' => $start, - 'f' => $forum_id, - ); - if ($mode != 'forum') - { - $s_hidden_fields['t'] = $topic_id; - } - - if ($item_title == '') - { - $confirm_box_message = 'UNWATCH_' . strtoupper($mode); - } - else - { - $confirm_box_message = $user->lang('UNWATCH_' . strtoupper($mode) . '_DETAILED', $item_title); - } - confirm_box(false, $confirm_box_message, build_hidden_fields($s_hidden_fields)); - } - } - else - { - $is_watching = true; - - if ($notify_status != NOTIFY_YES) - { - $sql = 'UPDATE ' . $table_sql . " - SET notify_status = " . NOTIFY_YES . " - WHERE $where_sql = $match_id - AND user_id = $user_id"; - $db->sql_query($sql); - } - } - } - else - { - if (isset($_GET['watch'])) - { - $uid = $request->variable('uid', 0); - $token = $request->variable('hash', ''); - - if ($token && check_link_hash($token, "{$mode}_$match_id") || confirm_box(true)) - { - if ($uid != $user_id || $request->variable('watch', '', false, \phpbb\request\request_interface::GET) != $mode) - { - $redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&start=$start"); - $message = $user->lang['ERR_WATCHING']; - - if (!$request->is_ajax()) - { - $message .= '

' . $user->lang('RETURN_' . strtoupper($mode), '', ''); - } - trigger_error($message); - } - - $is_watching = true; - - $sql = 'INSERT INTO ' . $table_sql . " (user_id, $where_sql, notify_status) - VALUES ($user_id, $match_id, " . NOTIFY_YES . ')'; - $db->sql_query($sql); - - $redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&start=$start"); - $message = $user->lang['ARE_WATCHING_' . strtoupper($mode)]; - - if (!$request->is_ajax()) - { - $message .= '

' . $user->lang('RETURN_' . strtoupper($mode), '', ''); - } - meta_refresh(3, $redirect_url); - trigger_error($message); - } - else - { - $s_hidden_fields = array( - 'uid' => $user->data['user_id'], - 'watch' => $mode, - 'start' => $start, - 'f' => $forum_id, - ); - if ($mode != 'forum') - { - $s_hidden_fields['t'] = $topic_id; - } - - $confirm_box_message = (($item_title == '') ? 'WATCH_' . strtoupper($mode) : $user->lang('WATCH_' . strtoupper($mode) . '_DETAILED', $item_title)); - confirm_box(false, $confirm_box_message, build_hidden_fields($s_hidden_fields)); - } - } - else - { - $is_watching = 0; - } - } - } - else - { - if ((isset($_GET['unwatch']) && $request->variable('unwatch', '', false, \phpbb\request\request_interface::GET) == $mode) || - (isset($_GET['watch']) && $request->variable('watch', '', false, \phpbb\request\request_interface::GET) == $mode)) - { - login_box(); - } - else - { - $can_watch = 0; - $is_watching = 0; - } - } - - if ($can_watch) - { - $s_watching['link'] = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&" . (($is_watching) ? 'unwatch' : 'watch') . "=$mode&start=$start&hash=" . generate_link_hash("{$mode}_$match_id")); - $s_watching['link_toggle'] = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&" . ((!$is_watching) ? 'unwatch' : 'watch') . "=$mode&start=$start&hash=" . generate_link_hash("{$mode}_$match_id")); - $s_watching['title'] = $user->lang[(($is_watching) ? 'STOP' : 'START') . '_WATCHING_' . strtoupper($mode)]; - $s_watching['title_toggle'] = $user->lang[((!$is_watching) ? 'STOP' : 'START') . '_WATCHING_' . strtoupper($mode)]; - $s_watching['is_watching'] = $is_watching; - } - - return; -} - -/** -* Get user rank title and image -* -* @param array $user_data the current stored users data -* @param int $user_posts the users number of posts -* -* @return array An associative array containing the rank title (title), the rank image as full img tag (img) and the rank image source (img_src) -* -* Note: since we do not want to break backwards-compatibility, this function will only properly assign ranks to guests if you call it for them with user_posts == false -*/ -function phpbb_get_user_rank($user_data, $user_posts) -{ - global $ranks, $config, $phpbb_root_path, $phpbb_path_helper, $phpbb_dispatcher; - - $user_rank_data = array( - 'title' => null, - 'img' => null, - 'img_src' => null, - ); - - /** - * Preparing a user's rank before displaying - * - * @event core.modify_user_rank - * @var array user_data Array with user's data - * @var int user_posts User_posts to change - * @since 3.1.0-RC4 - */ - - $vars = array('user_data', 'user_posts'); - extract($phpbb_dispatcher->trigger_event('core.modify_user_rank', compact($vars))); - - if (empty($ranks)) - { - global $cache; - $ranks = $cache->obtain_ranks(); - } - - if (!empty($user_data['user_rank'])) - { - - $user_rank_data['title'] = (isset($ranks['special'][$user_data['user_rank']]['rank_title'])) ? $ranks['special'][$user_data['user_rank']]['rank_title'] : ''; - - $user_rank_data['img_src'] = (!empty($ranks['special'][$user_data['user_rank']]['rank_image'])) ? $phpbb_path_helper->update_web_root_path($phpbb_root_path . $config['ranks_path'] . '/' . $ranks['special'][$user_data['user_rank']]['rank_image']) : ''; - - $user_rank_data['img'] = (!empty($ranks['special'][$user_data['user_rank']]['rank_image'])) ? '' . $ranks['special'][$user_data['user_rank']]['rank_title'] . '' : ''; - } - else if ($user_posts !== false) - { - if (!empty($ranks['normal'])) - { - foreach ($ranks['normal'] as $rank) - { - if ($user_posts >= $rank['rank_min']) - { - $user_rank_data['title'] = $rank['rank_title']; - $user_rank_data['img_src'] = (!empty($rank['rank_image'])) ? $phpbb_path_helper->update_web_root_path($phpbb_root_path . $config['ranks_path'] . '/' . $rank['rank_image']) : ''; - $user_rank_data['img'] = (!empty($rank['rank_image'])) ? '' . $rank['rank_title'] . '' : ''; - break; - } - } - } - } - - /** - * Modify a user's rank before displaying - * - * @event core.get_user_rank_after - * @var array user_data Array with user's data - * @var int user_posts User_posts to change - * @var array user_rank_data User rank data - * @since 3.1.11-RC1 - */ - - $vars = array( - 'user_data', - 'user_posts', - 'user_rank_data', - ); - extract($phpbb_dispatcher->trigger_event('core.get_user_rank_after', compact($vars))); - - return $user_rank_data; -} - -/** -* Prepare profile data -*/ -function phpbb_show_profile($data, $user_notes_enabled = false, $warn_user_enabled = false, $check_can_receive_pm = true) -{ - global $config, $auth, $user, $phpEx, $phpbb_root_path, $phpbb_dispatcher; - - $username = $data['username']; - $user_id = $data['user_id']; - - $user_rank_data = phpbb_get_user_rank($data, (($user_id == ANONYMOUS) ? false : $data['user_posts'])); - - if ((!empty($data['user_allow_viewemail']) && $auth->acl_get('u_sendemail')) || $auth->acl_get('a_user')) - { - $email = ($config['board_email_form'] && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=email&u=' . $user_id) : (($config['board_hide_emails'] && !$auth->acl_get('a_user')) ? '' : 'mailto:' . $data['user_email']); - } - else - { - $email = ''; - } - - if ($config['load_onlinetrack']) - { - $update_time = $config['load_online_time'] * 60; - $online = (time() - $update_time < $data['session_time'] && ((isset($data['session_viewonline']) && $data['session_viewonline']) || $auth->acl_get('u_viewonline'))) ? true : false; - } - else - { - $online = false; - } - - if ($data['user_allow_viewonline'] || $auth->acl_get('u_viewonline')) - { - $last_active = (!empty($data['session_time'])) ? $data['session_time'] : $data['user_lastvisit']; - } - else - { - $last_active = ''; - } - - $age = ''; - - if ($config['allow_birthdays'] && $data['user_birthday']) - { - list($bday_day, $bday_month, $bday_year) = array_map('intval', explode('-', $data['user_birthday'])); - - if ($bday_year) - { - $now = $user->create_datetime(); - $now = phpbb_gmgetdate($now->getTimestamp() + $now->getOffset()); - - $diff = $now['mon'] - $bday_month; - if ($diff == 0) - { - $diff = ($now['mday'] - $bday_day < 0) ? 1 : 0; - } - else - { - $diff = ($diff < 0) ? 1 : 0; - } - - $age = max(0, (int) ($now['year'] - $bday_year - $diff)); - } - } - - if (!function_exists('phpbb_get_banned_user_ids')) - { - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - } - - // Can this user receive a Private Message? - $can_receive_pm = $check_can_receive_pm && ( - // They must be a "normal" user - $data['user_type'] != USER_IGNORE && - - // They must not be deactivated by the administrator - ($data['user_type'] != USER_INACTIVE || $data['user_inactive_reason'] != INACTIVE_MANUAL) && - - // They must be able to read PMs - count($auth->acl_get_list($user_id, 'u_readpm')) && - - // They must not be permanently banned - !count(phpbb_get_banned_user_ids($user_id, false)) && - - // They must allow users to contact via PM - (($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) || $data['user_allow_pm']) - ); - - // Dump it out to the template - $template_data = array( - 'AGE' => $age, - 'RANK_TITLE' => $user_rank_data['title'], - 'JOINED' => $user->format_date($data['user_regdate']), - 'LAST_ACTIVE' => (empty($last_active)) ? ' - ' : $user->format_date($last_active), - 'POSTS' => ($data['user_posts']) ? $data['user_posts'] : 0, - 'WARNINGS' => isset($data['user_warnings']) ? $data['user_warnings'] : 0, - - 'USERNAME_FULL' => get_username_string('full', $user_id, $username, $data['user_colour']), - 'USERNAME' => get_username_string('username', $user_id, $username, $data['user_colour']), - 'USER_COLOR' => get_username_string('colour', $user_id, $username, $data['user_colour']), - 'U_VIEW_PROFILE' => get_username_string('profile', $user_id, $username, $data['user_colour']), - - 'A_USERNAME' => addslashes(get_username_string('username', $user_id, $username, $data['user_colour'])), - - 'AVATAR_IMG' => phpbb_get_user_avatar($data), - 'ONLINE_IMG' => (!$config['load_onlinetrack']) ? '' : (($online) ? $user->img('icon_user_online', 'ONLINE') : $user->img('icon_user_offline', 'OFFLINE')), - 'S_ONLINE' => ($config['load_onlinetrack'] && $online) ? true : false, - 'RANK_IMG' => $user_rank_data['img'], - 'RANK_IMG_SRC' => $user_rank_data['img_src'], - 'S_JABBER_ENABLED' => ($config['jab_enable']) ? true : false, - - 'S_WARNINGS' => ($auth->acl_getf_global('m_') || $auth->acl_get('m_warn')) ? true : false, - - 'U_SEARCH_USER' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id=$user_id&sr=posts") : '', - 'U_NOTES' => ($user_notes_enabled && $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $user_id, true, $user->session_id) : '', - 'U_WARN' => ($warn_user_enabled && $auth->acl_get('m_warn')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_user&u=' . $user_id, true, $user->session_id) : '', - 'U_PM' => ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && $can_receive_pm) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&u=' . $user_id) : '', - 'U_EMAIL' => $email, - 'U_JABBER' => ($data['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=jabber&u=' . $user_id) : '', - - 'USER_JABBER' => ($config['jab_enable']) ? $data['user_jabber'] : '', - 'USER_JABBER_IMG' => ($config['jab_enable'] && $data['user_jabber']) ? $user->img('icon_contact_jabber', $data['user_jabber']) : '', - - 'L_SEND_EMAIL_USER' => $user->lang('SEND_EMAIL_USER', $username), - 'L_CONTACT_USER' => $user->lang('CONTACT_USER', $username), - 'L_VIEWING_PROFILE' => $user->lang('VIEWING_PROFILE', $username), - ); - - /** - * Preparing a user's data before displaying it in profile and memberlist - * - * @event core.memberlist_prepare_profile_data - * @var array data Array with user's data - * @var array template_data Template array with user's data - * @since 3.1.0-a1 - */ - $vars = array('data', 'template_data'); - extract($phpbb_dispatcher->trigger_event('core.memberlist_prepare_profile_data', compact($vars))); - - return $template_data; -} - -function phpbb_sort_last_active($first, $second) -{ - global $id_cache, $sort_dir; - - $lesser_than = ($sort_dir === 'd') ? -1 : 1; - - if (isset($id_cache[$first]['group_leader']) && $id_cache[$first]['group_leader'] && (!isset($id_cache[$second]['group_leader']) || !$id_cache[$second]['group_leader'])) - { - return -1; - } - else if (isset($id_cache[$second]['group_leader']) && (!isset($id_cache[$first]['group_leader']) || !$id_cache[$first]['group_leader']) && $id_cache[$second]['group_leader']) - { - return 1; - } - else - { - return $lesser_than * (int) ($id_cache[$first]['last_visit'] - $id_cache[$second]['last_visit']); - } -} diff --git a/install/update/new/includes/functions_download.php b/install/update/new/includes/functions_download.php deleted file mode 100644 index d2d3924..0000000 --- a/install/update/new/includes/functions_download.php +++ /dev/null @@ -1,782 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* A simplified function to deliver avatars -* The argument needs to be checked before calling this function. -*/ -function send_avatar_to_browser($file, $browser) -{ - global $config, $phpbb_root_path; - - $prefix = $config['avatar_salt'] . '_'; - $image_dir = $config['avatar_path']; - - // Adjust image_dir path (no trailing slash) - if (substr($image_dir, -1, 1) == '/' || substr($image_dir, -1, 1) == '\\') - { - $image_dir = substr($image_dir, 0, -1) . '/'; - } - $image_dir = str_replace(array('../', '..\\', './', '.\\'), '', $image_dir); - - if ($image_dir && ($image_dir[0] == '/' || $image_dir[0] == '\\')) - { - $image_dir = ''; - } - $file_path = $phpbb_root_path . $image_dir . '/' . $prefix . $file; - - if ((@file_exists($file_path) && @is_readable($file_path)) && !headers_sent()) - { - header('Cache-Control: public'); - - $image_data = @getimagesize($file_path); - header('Content-Type: ' . image_type_to_mime_type($image_data[2])); - - if ((strpos(strtolower($browser), 'msie') !== false) && !phpbb_is_greater_ie_version($browser, 7)) - { - header('Content-Disposition: attachment; ' . header_filename($file)); - - if (strpos(strtolower($browser), 'msie 6.0') !== false) - { - header('Expires: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT'); - } - else - { - header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 31536000) . ' GMT'); - } - } - else - { - header('Content-Disposition: inline; ' . header_filename($file)); - header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 31536000) . ' GMT'); - } - - $size = @filesize($file_path); - if ($size) - { - header("Content-Length: $size"); - } - - if (@readfile($file_path) == false) - { - $fp = @fopen($file_path, 'rb'); - - if ($fp !== false) - { - while (!feof($fp)) - { - echo fread($fp, 8192); - } - fclose($fp); - } - } - - flush(); - } - else - { - header('HTTP/1.0 404 Not Found'); - } -} - -/** -* Wraps an url into a simple html page. Used to display attachments in IE. -* this is a workaround for now; might be moved to template system later -* direct any complaints to 1 Microsoft Way, Redmond -*/ -function wrap_img_in_html($src, $title) -{ - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo '' . $title . ''; - echo ''; - echo ''; - echo '
'; - echo '' . $title . ''; - echo '
'; - echo ''; - echo ''; -} - -/** -* Send file to browser -*/ -function send_file_to_browser($attachment, $upload_dir, $category) -{ - global $user, $db, $phpbb_dispatcher, $phpbb_root_path, $request; - - $filename = $phpbb_root_path . $upload_dir . '/' . $attachment['physical_filename']; - - if (!@file_exists($filename)) - { - send_status_line(404, 'Not Found'); - trigger_error('ERROR_NO_ATTACHMENT'); - } - - // Correct the mime type - we force application/octetstream for all files, except images - // Please do not change this, it is a security precaution - if ($category != ATTACHMENT_CATEGORY_IMAGE || strpos($attachment['mimetype'], 'image') !== 0) - { - $attachment['mimetype'] = (strpos(strtolower($user->browser), 'msie') !== false || strpos(strtolower($user->browser), 'opera') !== false) ? 'application/octetstream' : 'application/octet-stream'; - } - - if (@ob_get_length()) - { - @ob_end_clean(); - } - - // Now send the File Contents to the Browser - $size = @filesize($filename); - - /** - * Event to alter attachment before it is sent to browser. - * - * @event core.send_file_to_browser_before - * @var array attachment Attachment data - * @var string upload_dir Relative path of upload directory - * @var int category Attachment category - * @var string filename Path to file, including filename - * @var int size File size - * @since 3.1.11-RC1 - */ - $vars = array( - 'attachment', - 'upload_dir', - 'category', - 'filename', - 'size', - ); - extract($phpbb_dispatcher->trigger_event('core.send_file_to_browser_before', compact($vars))); - - // To correctly display further errors we need to make sure we are using the correct headers for both (unsetting content-length may not work) - - // Check if headers already sent or not able to get the file contents. - if (headers_sent() || !@file_exists($filename) || !@is_readable($filename)) - { - // PHP track_errors setting On? - if (!empty($php_errormsg)) - { - send_status_line(500, 'Internal Server Error'); - trigger_error($user->lang['UNABLE_TO_DELIVER_FILE'] . '
' . sprintf($user->lang['TRACKED_PHP_ERROR'], $php_errormsg)); - } - - send_status_line(500, 'Internal Server Error'); - trigger_error('UNABLE_TO_DELIVER_FILE'); - } - - // Make sure the database record for the filesize is correct - if ($size > 0 && $size != $attachment['filesize'] && strpos($attachment['physical_filename'], 'thumb_') === false) - { - // Update database record - $sql = 'UPDATE ' . ATTACHMENTS_TABLE . ' - SET filesize = ' . (int) $size . ' - WHERE attach_id = ' . (int) $attachment['attach_id']; - $db->sql_query($sql); - } - - // Now the tricky part... let's dance - header('Cache-Control: private'); - - // Send out the Headers. Do not set Content-Disposition to inline please, it is a security measure for users using the Internet Explorer. - header('Content-Type: ' . $attachment['mimetype']); - - if (phpbb_is_greater_ie_version($user->browser, 7)) - { - header('X-Content-Type-Options: nosniff'); - } - - if (empty($user->browser) || ((strpos(strtolower($user->browser), 'msie') !== false) && !phpbb_is_greater_ie_version($user->browser, 7))) - { - header('Content-Disposition: attachment; ' . header_filename(htmlspecialchars_decode($attachment['real_filename']))); - if (empty($user->browser) || (strpos(strtolower($user->browser), 'msie 6.0') !== false)) - { - header('Expires: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT'); - } - } - else - { - header('Content-Disposition: ' . ((strpos($attachment['mimetype'], 'image') === 0) ? 'inline' : 'attachment') . '; ' . header_filename(htmlspecialchars_decode($attachment['real_filename']))); - if (phpbb_is_greater_ie_version($user->browser, 7) && (strpos($attachment['mimetype'], 'image') !== 0)) - { - header('X-Download-Options: noopen'); - } - } - - // Close the db connection before sending the file etc. - file_gc(false); - - if (!set_modified_headers($attachment['filetime'], $user->browser)) - { - // We make sure those have to be enabled manually by defining a constant - // because of the potential disclosure of full attachment path - // in case support for features is absent in the webserver software. - if (defined('PHPBB_ENABLE_X_ACCEL_REDIRECT') && PHPBB_ENABLE_X_ACCEL_REDIRECT) - { - // X-Accel-Redirect - http://wiki.nginx.org/XSendfile - header('X-Accel-Redirect: ' . $user->page['root_script_path'] . $upload_dir . '/' . $attachment['physical_filename']); - exit; - } - else if (defined('PHPBB_ENABLE_X_SENDFILE') && PHPBB_ENABLE_X_SENDFILE && !phpbb_http_byte_range($size)) - { - // X-Sendfile - http://blog.lighttpd.net/articles/2006/07/02/x-sendfile - // Lighttpd's X-Sendfile does not support range requests as of 1.4.26 - // and always requires an absolute path. - header('X-Sendfile: ' . dirname(__FILE__) . "/../$upload_dir/{$attachment['physical_filename']}"); - exit; - } - - if ($size) - { - header("Content-Length: $size"); - } - - // Try to deliver in chunks - @set_time_limit(0); - - $fp = @fopen($filename, 'rb'); - - if ($fp !== false) - { - // Deliver file partially if requested - if ($range = phpbb_http_byte_range($size)) - { - fseek($fp, $range['byte_pos_start']); - - send_status_line(206, 'Partial Content'); - header('Content-Range: bytes ' . $range['byte_pos_start'] . '-' . $range['byte_pos_end'] . '/' . $range['bytes_total']); - header('Content-Length: ' . $range['bytes_requested']); - - // First read chunks - while (!feof($fp) && ftell($fp) < $range['byte_pos_end'] - 8192) - { - echo fread($fp, 8192); - } - // Then, read the remainder - echo fread($fp, $range['bytes_requested'] % 8192); - } - else - { - while (!feof($fp)) - { - echo fread($fp, 8192); - } - } - fclose($fp); - } - else - { - @readfile($filename); - } - - flush(); - } - - exit; -} - -/** -* Get a browser friendly UTF-8 encoded filename -*/ -function header_filename($file) -{ - global $request; - - $user_agent = $request->header('User-Agent'); - - // There be dragons here. - // Not many follows the RFC... - if (strpos($user_agent, 'MSIE') !== false || strpos($user_agent, 'Konqueror') !== false) - { - return "filename=" . rawurlencode($file); - } - - // follow the RFC for extended filename for the rest - return "filename*=UTF-8''" . rawurlencode($file); -} - -/** -* Check if downloading item is allowed -*/ -function download_allowed() -{ - global $config, $user, $db, $request; - - if (!$config['secure_downloads']) - { - return true; - } - - $url = htmlspecialchars_decode($request->header('Referer')); - - if (!$url) - { - return ($config['secure_allow_empty_referer']) ? true : false; - } - - // Split URL into domain and script part - $url = @parse_url($url); - - if ($url === false) - { - return ($config['secure_allow_empty_referer']) ? true : false; - } - - $hostname = $url['host']; - unset($url); - - $allowed = ($config['secure_allow_deny']) ? false : true; - $iplist = array(); - - if (($ip_ary = @gethostbynamel($hostname)) !== false) - { - foreach ($ip_ary as $ip) - { - if ($ip) - { - $iplist[] = $ip; - } - } - } - - // Check for own server... - $server_name = $user->host; - - // Forcing server vars is the only way to specify/override the protocol - if ($config['force_server_vars'] || !$server_name) - { - $server_name = $config['server_name']; - } - - if (preg_match('#^.*?' . preg_quote($server_name, '#') . '.*?$#i', $hostname)) - { - $allowed = true; - } - - // Get IP's and Hostnames - if (!$allowed) - { - $sql = 'SELECT site_ip, site_hostname, ip_exclude - FROM ' . SITELIST_TABLE; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $site_ip = trim($row['site_ip']); - $site_hostname = trim($row['site_hostname']); - - if ($site_ip) - { - foreach ($iplist as $ip) - { - if (preg_match('#^' . str_replace('\*', '.*?', preg_quote($site_ip, '#')) . '$#i', $ip)) - { - if ($row['ip_exclude']) - { - $allowed = ($config['secure_allow_deny']) ? false : true; - break 2; - } - else - { - $allowed = ($config['secure_allow_deny']) ? true : false; - } - } - } - } - - if ($site_hostname) - { - if (preg_match('#^' . str_replace('\*', '.*?', preg_quote($site_hostname, '#')) . '$#i', $hostname)) - { - if ($row['ip_exclude']) - { - $allowed = ($config['secure_allow_deny']) ? false : true; - break; - } - else - { - $allowed = ($config['secure_allow_deny']) ? true : false; - } - } - } - } - $db->sql_freeresult($result); - } - - return $allowed; -} - -/** -* Check if the browser has the file already and set the appropriate headers- -* @returns false if a resend is in order. -*/ -function set_modified_headers($stamp, $browser) -{ - global $request; - - // let's see if we have to send the file at all - $last_load = $request->header('If-Modified-Since') ? strtotime(trim($request->header('If-Modified-Since'))) : false; - - if (strpos(strtolower($browser), 'msie 6.0') === false && !phpbb_is_greater_ie_version($browser, 7)) - { - if ($last_load !== false && $last_load >= $stamp) - { - send_status_line(304, 'Not Modified'); - // seems that we need those too ... browsers - header('Cache-Control: private'); - header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 31536000) . ' GMT'); - return true; - } - else - { - header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $stamp) . ' GMT'); - } - } - return false; -} - -/** -* Garbage Collection -* -* @param bool $exit Whether to die or not. -* -* @return null -*/ -function file_gc($exit = true) -{ - global $cache, $db; - - if (!empty($cache)) - { - $cache->unload(); - } - - $db->sql_close(); - - if ($exit) - { - exit; - } -} - -/** -* HTTP range support (RFC 2616 Section 14.35) -* -* Allows browsers to request partial file content -* in case a download has been interrupted. -* -* @param int $filesize the size of the file in bytes we are about to deliver -* -* @return mixed false if the whole file has to be delivered -* associative array on success -*/ -function phpbb_http_byte_range($filesize) -{ - // Only call find_range_request() once. - static $request_array; - - if (!$filesize) - { - return false; - } - - if (!isset($request_array)) - { - $request_array = phpbb_find_range_request(); - } - - return (empty($request_array)) ? false : phpbb_parse_range_request($request_array, $filesize); -} - -/** -* Searches for HTTP range request in request headers. -* -* @return mixed false if no request found -* array of strings containing the requested ranges otherwise -* e.g. array(0 => '0-0', 1 => '123-125') -*/ -function phpbb_find_range_request() -{ - global $request; - - $value = $request->header('Range'); - - // Make sure range request starts with "bytes=" - if (strpos($value, 'bytes=') === 0) - { - // Strip leading 'bytes=' - // Multiple ranges can be separated by a comma - return explode(',', substr($value, 6)); - } - - return false; -} - -/** -* Analyses a range request array. -* -* A range request can contain multiple ranges, -* we however only handle the first request and -* only support requests from a given byte to the end of the file. -* -* @param array $request_array array of strings containing the requested ranges -* @param int $filesize the full size of the file in bytes that has been requested -* -* @return mixed false if the whole file has to be delivered -* associative array on success -* byte_pos_start the first byte position, can be passed to fseek() -* byte_pos_end the last byte position -* bytes_requested the number of bytes requested -* bytes_total the full size of the file -*/ -function phpbb_parse_range_request($request_array, $filesize) -{ - $first_byte_pos = -1; - $last_byte_pos = -1; - - // Go through all ranges - foreach ($request_array as $range_string) - { - $range = explode('-', trim($range_string)); - - // "-" is invalid, "0-0" however is valid and means the very first byte. - if (count($range) != 2 || $range[0] === '' && $range[1] === '') - { - continue; - } - - // Substitute defaults - if ($range[0] === '') - { - $range[0] = 0; - } - - if ($range[1] === '') - { - $range[1] = $filesize - 1; - } - - if ($last_byte_pos >= 0 && $last_byte_pos + 1 != $range[0]) - { - // We only support contiguous ranges, no multipart stuff :( - return false; - } - - if ($range[1] && $range[1] < $range[0]) - { - // The requested range contains 0 bytes. - continue; - } - - // Return bytes from $range[0] to $range[1] - if ($first_byte_pos < 0) - { - $first_byte_pos = (int) $range[0]; - } - - $last_byte_pos = (int) $range[1]; - - if ($first_byte_pos >= $filesize) - { - // Requested range not satisfiable - return false; - } - - // Adjust last-byte-pos if it is absent or greater than the content. - if ($range[1] === '' || $last_byte_pos >= $filesize) - { - $last_byte_pos = $filesize - 1; - } - } - - if ($first_byte_pos < 0 || $last_byte_pos < 0) - { - return false; - } - - return array( - 'byte_pos_start' => $first_byte_pos, - 'byte_pos_end' => $last_byte_pos, - 'bytes_requested' => $last_byte_pos - $first_byte_pos + 1, - 'bytes_total' => $filesize, - ); -} - -/** -* Increments the download count of all provided attachments -* -* @param \phpbb\db\driver\driver_interface $db The database object -* @param array|int $ids The attach_id of each attachment -* -* @return null -*/ -function phpbb_increment_downloads($db, $ids) -{ - if (!is_array($ids)) - { - $ids = array($ids); - } - - $sql = 'UPDATE ' . ATTACHMENTS_TABLE . ' - SET download_count = download_count + 1 - WHERE ' . $db->sql_in_set('attach_id', $ids); - $db->sql_query($sql); -} - -/** -* Handles authentication when downloading attachments from a post or topic -* -* @param \phpbb\db\driver\driver_interface $db The database object -* @param \phpbb\auth\auth $auth The authentication object -* @param int $topic_id The id of the topic that we are downloading from -* -* @return null -*/ -function phpbb_download_handle_forum_auth($db, $auth, $topic_id) -{ - global $phpbb_container; - - $sql_array = array( - 'SELECT' => 't.topic_visibility, t.forum_id, f.forum_name, f.forum_password, f.parent_id', - 'FROM' => array( - TOPICS_TABLE => 't', - FORUMS_TABLE => 'f', - ), - 'WHERE' => 't.topic_id = ' . (int) $topic_id . ' - AND t.forum_id = f.forum_id', - ); - - $sql = $db->sql_build_query('SELECT', $sql_array); - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $phpbb_content_visibility = $phpbb_container->get('content.visibility'); - - if ($row && !$phpbb_content_visibility->is_visible('topic', $row['forum_id'], $row)) - { - send_status_line(404, 'Not Found'); - trigger_error('ERROR_NO_ATTACHMENT'); - } - else if ($row && $auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id'])) - { - if ($row['forum_password']) - { - // Do something else ... ? - login_forum_box($row); - } - } - else - { - send_status_line(403, 'Forbidden'); - trigger_error('SORRY_AUTH_VIEW_ATTACH'); - } -} - -/** -* Handles authentication when downloading attachments from PMs -* -* @param \phpbb\db\driver\driver_interface $db The database object -* @param \phpbb\auth\auth $auth The authentication object -* @param int $user_id The user id -* @param int $msg_id The id of the PM that we are downloading from -* -* @return null -*/ -function phpbb_download_handle_pm_auth($db, $auth, $user_id, $msg_id) -{ - global $phpbb_dispatcher; - - if (!$auth->acl_get('u_pm_download')) - { - send_status_line(403, 'Forbidden'); - trigger_error('SORRY_AUTH_VIEW_ATTACH'); - } - - $allowed = phpbb_download_check_pm_auth($db, $user_id, $msg_id); - - /** - * Event to modify PM attachments download auth - * - * @event core.modify_pm_attach_download_auth - * @var bool allowed Whether the user is allowed to download from that PM or not - * @var int msg_id The id of the PM to download from - * @var int user_id The user id for auth check - * @since 3.1.11-RC1 - */ - $vars = array('allowed', 'msg_id', 'user_id'); - extract($phpbb_dispatcher->trigger_event('core.modify_pm_attach_download_auth', compact($vars))); - - if (!$allowed) - { - send_status_line(403, 'Forbidden'); - trigger_error('ERROR_NO_ATTACHMENT'); - } -} - -/** -* Checks whether a user can download from a particular PM -* -* @param \phpbb\db\driver\driver_interface $db The database object -* @param int $user_id The user id -* @param int $msg_id The id of the PM that we are downloading from -* -* @return bool Whether the user is allowed to download from that PM or not -*/ -function phpbb_download_check_pm_auth($db, $user_id, $msg_id) -{ - // Check if the attachment is within the users scope... - $sql = 'SELECT msg_id - FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE msg_id = ' . (int) $msg_id . ' - AND ( - user_id = ' . (int) $user_id . ' - OR author_id = ' . (int) $user_id . ' - )'; - $result = $db->sql_query_limit($sql, 1); - $allowed = (bool) $db->sql_fetchfield('msg_id'); - $db->sql_freeresult($result); - - return $allowed; -} - -/** -* Check if the browser is internet explorer version 7+ -* -* @param string $user_agent User agent HTTP header -* @param int $version IE version to check against -* -* @return bool true if internet explorer version is greater than $version -*/ -function phpbb_is_greater_ie_version($user_agent, $version) -{ - if (preg_match('/msie (\d+)/', strtolower($user_agent), $matches)) - { - $ie_version = (int) $matches[1]; - return ($ie_version > $version); - } - else - { - return false; - } -} diff --git a/install/update/new/includes/functions_messenger.php b/install/update/new/includes/functions_messenger.php deleted file mode 100644 index ec297b5..0000000 --- a/install/update/new/includes/functions_messenger.php +++ /dev/null @@ -1,1935 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* Messenger -*/ -class messenger -{ - var $msg, $replyto, $from, $subject; - var $addresses = array(); - var $extra_headers = array(); - - var $mail_priority = MAIL_NORMAL_PRIORITY; - var $use_queue = true; - - /** @var \phpbb\template\template */ - protected $template; - - /** - * Constructor - */ - function __construct($use_queue = true) - { - global $config; - - $this->use_queue = (!$config['email_package_size']) ? false : $use_queue; - $this->subject = ''; - } - - /** - * Resets all the data (address, template file, etc etc) to default - */ - function reset() - { - $this->addresses = $this->extra_headers = array(); - $this->msg = $this->replyto = $this->from = ''; - $this->mail_priority = MAIL_NORMAL_PRIORITY; - } - - /** - * Set addresses for to/im as available - * - * @param array $user User row - */ - function set_addresses($user) - { - if (isset($user['user_email']) && $user['user_email']) - { - $this->to($user['user_email'], (isset($user['username']) ? $user['username'] : '')); - } - - if (isset($user['user_jabber']) && $user['user_jabber']) - { - $this->im($user['user_jabber'], (isset($user['username']) ? $user['username'] : '')); - } - } - - /** - * Sets an email address to send to - */ - function to($address, $realname = '') - { - global $config; - - if (!trim($address)) - { - return; - } - - $pos = isset($this->addresses['to']) ? count($this->addresses['to']) : 0; - - $this->addresses['to'][$pos]['email'] = trim($address); - - // If empty sendmail_path on windows, PHP changes the to line - if (!$config['smtp_delivery'] && DIRECTORY_SEPARATOR == '\\') - { - $this->addresses['to'][$pos]['name'] = ''; - } - else - { - $this->addresses['to'][$pos]['name'] = trim($realname); - } - } - - /** - * Sets an cc address to send to - */ - function cc($address, $realname = '') - { - if (!trim($address)) - { - return; - } - - $pos = isset($this->addresses['cc']) ? count($this->addresses['cc']) : 0; - $this->addresses['cc'][$pos]['email'] = trim($address); - $this->addresses['cc'][$pos]['name'] = trim($realname); - } - - /** - * Sets an bcc address to send to - */ - function bcc($address, $realname = '') - { - if (!trim($address)) - { - return; - } - - $pos = isset($this->addresses['bcc']) ? count($this->addresses['bcc']) : 0; - $this->addresses['bcc'][$pos]['email'] = trim($address); - $this->addresses['bcc'][$pos]['name'] = trim($realname); - } - - /** - * Sets a im contact to send to - */ - function im($address, $realname = '') - { - // IM-Addresses could be empty - if (!trim($address)) - { - return; - } - - $pos = isset($this->addresses['im']) ? count($this->addresses['im']) : 0; - $this->addresses['im'][$pos]['uid'] = trim($address); - $this->addresses['im'][$pos]['name'] = trim($realname); - } - - /** - * Set the reply to address - */ - function replyto($address) - { - $this->replyto = trim($address); - } - - /** - * Set the from address - */ - function from($address) - { - $this->from = trim($address); - } - - /** - * set up subject for mail - */ - function subject($subject = '') - { - $this->subject = trim($subject); - } - - /** - * set up extra mail headers - */ - function headers($headers) - { - $this->extra_headers[] = trim($headers); - } - - /** - * Adds X-AntiAbuse headers - * - * @param \phpbb\config\config $config Config object - * @param \phpbb\user $user User object - * @return void - */ - function anti_abuse_headers($config, $user) - { - $this->headers('X-AntiAbuse: Board servername - ' . mail_encode($config['server_name'])); - $this->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']); - $this->headers('X-AntiAbuse: Username - ' . mail_encode($user->data['username'])); - $this->headers('X-AntiAbuse: User IP - ' . $user->ip); - } - - /** - * Set the email priority - */ - function set_mail_priority($priority = MAIL_NORMAL_PRIORITY) - { - $this->mail_priority = $priority; - } - - /** - * Set email template to use - */ - function template($template_file, $template_lang = '', $template_path = '', $template_dir_prefix = '') - { - global $config, $phpbb_root_path, $user; - - $template_dir_prefix = (!$template_dir_prefix || $template_dir_prefix[0] === '/') ? $template_dir_prefix : '/' . $template_dir_prefix; - - $this->setup_template(); - - if (!trim($template_file)) - { - trigger_error('No template file for emailing set.', E_USER_ERROR); - } - - if (!trim($template_lang)) - { - // fall back to board default language if the user's language is - // missing $template_file. If this does not exist either, - // $this->template->set_filenames will do a trigger_error - $template_lang = basename($config['default_lang']); - } - - $ext_template_paths = array( - array( - 'name' => $template_lang . '_email', - 'ext_path' => 'language/' . $template_lang . '/email' . $template_dir_prefix, - ), - ); - - if ($template_path) - { - $template_paths = array( - $template_path . $template_dir_prefix, - ); - } - else - { - $template_path = (!empty($user->lang_path)) ? $user->lang_path : $phpbb_root_path . 'language/'; - $template_path .= $template_lang . '/email'; - - $template_paths = array( - $template_path . $template_dir_prefix, - ); - - $board_language = basename($config['default_lang']); - - // we can only specify default language fallback when the path is not a custom one for which we - // do not know the default language alternative - if ($template_lang !== $board_language) - { - $fallback_template_path = (!empty($user->lang_path)) ? $user->lang_path : $phpbb_root_path . 'language/'; - $fallback_template_path .= $board_language . '/email'; - - $template_paths[] = $fallback_template_path . $template_dir_prefix; - - $ext_template_paths[] = array( - 'name' => $board_language . '_email', - 'ext_path' => 'language/' . $board_language . '/email' . $template_dir_prefix, - ); - } - // If everything fails just fall back to en template - if ($template_lang !== 'en' && $board_language !== 'en') - { - $fallback_template_path = (!empty($user->lang_path)) ? $user->lang_path : $phpbb_root_path . 'language/'; - $fallback_template_path .= 'en/email'; - - $template_paths[] = $fallback_template_path . $template_dir_prefix; - - $ext_template_paths[] = array( - 'name' => 'en_email', - 'ext_path' => 'language/en/email' . $template_dir_prefix, - ); - } - } - - $this->set_template_paths($ext_template_paths, $template_paths); - - $this->template->set_filenames(array( - 'body' => $template_file . '.txt', - )); - - return true; - } - - /** - * assign variables to email template - */ - function assign_vars($vars) - { - $this->setup_template(); - - $this->template->assign_vars($vars); - } - - function assign_block_vars($blockname, $vars) - { - $this->setup_template(); - - $this->template->assign_block_vars($blockname, $vars); - } - - /** - * Send the mail out to the recipients set previously in var $this->addresses - * - * @param int $method User notification method NOTIFY_EMAIL|NOTIFY_IM|NOTIFY_BOTH - * @param bool $break Flag indicating if the function only formats the subject - * and the message without sending it - * - * @return bool - */ - function send($method = NOTIFY_EMAIL, $break = false) - { - global $config, $user, $phpbb_dispatcher; - - // We add some standard variables we always use, no need to specify them always - $this->assign_vars(array( - 'U_BOARD' => generate_board_url(), - 'EMAIL_SIG' => str_replace('
', "\n", "-- \n" . htmlspecialchars_decode($config['board_email_sig'])), - 'SITENAME' => htmlspecialchars_decode($config['sitename']), - )); - - $subject = $this->subject; - $template = $this->template; - /** - * Event to modify the template before parsing - * - * @event core.modify_notification_template - * @var int method User notification method NOTIFY_EMAIL|NOTIFY_IM|NOTIFY_BOTH - * @var bool break Flag indicating if the function only formats the subject - * and the message without sending it - * @var string subject The message subject - * @var \phpbb\template\template template The (readonly) template object - * @since 3.2.4-RC1 - */ - $vars = array('method', 'break', 'subject', 'template'); - extract($phpbb_dispatcher->trigger_event('core.modify_notification_template', compact($vars))); - - // Parse message through template - $message = trim($this->template->assign_display('body')); - - /** - * Event to modify notification message text after parsing - * - * @event core.modify_notification_message - * @var int method User notification method NOTIFY_EMAIL|NOTIFY_IM|NOTIFY_BOTH - * @var bool break Flag indicating if the function only formats the subject - * and the message without sending it - * @var string subject The message subject - * @var string message The message text - * @since 3.1.11-RC1 - */ - $vars = array('method', 'break', 'subject', 'message'); - extract($phpbb_dispatcher->trigger_event('core.modify_notification_message', compact($vars))); - - $this->subject = $subject; - $this->msg = $message; - unset($subject, $message, $template); - - // Because we use \n for newlines in the body message we need to fix line encoding errors for those admins who uploaded email template files in the wrong encoding - $this->msg = str_replace("\r\n", "\n", $this->msg); - - // We now try and pull a subject from the email body ... if it exists, - // do this here because the subject may contain a variable - $drop_header = ''; - $match = array(); - if (preg_match('#^(Subject:(.*?))$#m', $this->msg, $match)) - { - $this->subject = (trim($match[2]) != '') ? trim($match[2]) : (($this->subject != '') ? $this->subject : $user->lang['NO_EMAIL_SUBJECT']); - $drop_header .= '[\r\n]*?' . preg_quote($match[1], '#'); - } - else - { - $this->subject = (($this->subject != '') ? $this->subject : $user->lang['NO_EMAIL_SUBJECT']); - } - - if (preg_match('#^(List-Unsubscribe:(.*?))$#m', $this->msg, $match)) - { - $this->extra_headers[] = $match[1]; - $drop_header .= '[\r\n]*?' . preg_quote($match[1], '#'); - } - - if ($drop_header) - { - $this->msg = trim(preg_replace('#' . $drop_header . '#s', '', $this->msg)); - } - - if ($break) - { - return true; - } - - switch ($method) - { - case NOTIFY_EMAIL: - $result = $this->msg_email(); - break; - - case NOTIFY_IM: - $result = $this->msg_jabber(); - break; - - case NOTIFY_BOTH: - $result = $this->msg_email(); - $this->msg_jabber(); - break; - } - - $this->reset(); - return $result; - } - - /** - * Add error message to log - */ - function error($type, $msg) - { - global $user, $config, $request, $phpbb_log; - - // Session doesn't exist, create it - if (!isset($user->session_id) || $user->session_id === '') - { - $user->session_begin(); - } - - $calling_page = htmlspecialchars_decode($request->server('PHP_SELF')); - - switch ($type) - { - case 'EMAIL': - $message = 'EMAIL/' . (($config['smtp_delivery']) ? 'SMTP' : 'PHP/mail()') . ''; - break; - - default: - $message = "$type"; - break; - } - - $message .= '
' . htmlspecialchars($calling_page) . '

' . $msg . '
'; - $phpbb_log->add('critical', $user->data['user_id'], $user->ip, 'LOG_ERROR_' . $type, false, array($message)); - } - - /** - * Save to queue - */ - function save_queue() - { - global $config; - - if ($config['email_package_size'] && $this->use_queue && !empty($this->queue)) - { - $this->queue->save(); - return; - } - } - - /** - * Generates a valid message id to be used in emails - * - * @return string message id - */ - function generate_message_id() - { - global $config, $request; - - $domain = ($config['server_name']) ?: $request->server('SERVER_NAME', 'phpbb.generated'); - - return md5(unique_id(time())) . '@' . $domain; - } - - /** - * Return email header - */ - function build_header($to, $cc, $bcc) - { - global $config, $phpbb_dispatcher; - - // We could use keys here, but we won't do this for 3.0.x to retain backwards compatibility - $headers = array(); - - $headers[] = 'From: ' . $this->from; - - if ($cc) - { - $headers[] = 'Cc: ' . $cc; - } - - if ($bcc) - { - $headers[] = 'Bcc: ' . $bcc; - } - - $headers[] = 'Reply-To: ' . $this->replyto; - $headers[] = 'Return-Path: <' . $config['board_email'] . '>'; - $headers[] = 'Sender: <' . $config['board_email'] . '>'; - $headers[] = 'MIME-Version: 1.0'; - $headers[] = 'Message-ID: <' . $this->generate_message_id() . '>'; - $headers[] = 'Date: ' . date('r', time()); - $headers[] = 'Content-Type: text/plain; charset=UTF-8'; // format=flowed - $headers[] = 'Content-Transfer-Encoding: 8bit'; // 7bit - - $headers[] = 'X-Priority: ' . $this->mail_priority; - $headers[] = 'X-MSMail-Priority: ' . (($this->mail_priority == MAIL_LOW_PRIORITY) ? 'Low' : (($this->mail_priority == MAIL_NORMAL_PRIORITY) ? 'Normal' : 'High')); - $headers[] = 'X-Mailer: phpBB3'; - $headers[] = 'X-MimeOLE: phpBB3'; - $headers[] = 'X-phpBB-Origin: phpbb://' . str_replace(array('http://', 'https://'), array('', ''), generate_board_url()); - - /** - * Event to modify email header entries - * - * @event core.modify_email_headers - * @var array headers Array containing email header entries - * @since 3.1.11-RC1 - */ - $vars = array('headers'); - extract($phpbb_dispatcher->trigger_event('core.modify_email_headers', compact($vars))); - - if (count($this->extra_headers)) - { - $headers = array_merge($headers, $this->extra_headers); - } - - return $headers; - } - - /** - * Send out emails - */ - function msg_email() - { - global $config, $phpbb_dispatcher; - - if (empty($config['email_enable'])) - { - return false; - } - - // Addresses to send to? - if (empty($this->addresses) || (empty($this->addresses['to']) && empty($this->addresses['cc']) && empty($this->addresses['bcc']))) - { - // Send was successful. ;) - return true; - } - - $use_queue = false; - if ($config['email_package_size'] && $this->use_queue) - { - if (empty($this->queue)) - { - $this->queue = new queue(); - $this->queue->init('email', $config['email_package_size']); - } - $use_queue = true; - } - - $contact_name = htmlspecialchars_decode($config['board_contact_name']); - $board_contact = (($contact_name !== '') ? '"' . mail_encode($contact_name) . '" ' : '') . '<' . $config['board_contact'] . '>'; - - $break = false; - $addresses = $this->addresses; - $subject = $this->subject; - $msg = $this->msg; - /** - * Event to send message via external transport - * - * @event core.notification_message_email - * @var bool break Flag indicating if the function return after hook - * @var array addresses The message recipients - * @var string subject The message subject - * @var string msg The message text - * @since 3.2.4-RC1 - */ - $vars = array( - 'break', - 'addresses', - 'subject', - 'msg', - ); - extract($phpbb_dispatcher->trigger_event('core.notification_message_email', compact($vars))); - - if ($break) - { - return true; - } - - if (empty($this->replyto)) - { - $this->replyto = $board_contact; - } - - if (empty($this->from)) - { - $this->from = $board_contact; - } - - $encode_eol = ($config['smtp_delivery']) ? "\r\n" : PHP_EOL; - - // Build to, cc and bcc strings - $to = $cc = $bcc = ''; - foreach ($this->addresses as $type => $address_ary) - { - if ($type == 'im') - { - continue; - } - - foreach ($address_ary as $which_ary) - { - ${$type} .= ((${$type} != '') ? ', ' : '') . (($which_ary['name'] != '') ? mail_encode($which_ary['name'], $encode_eol) . ' <' . $which_ary['email'] . '>' : $which_ary['email']); - } - } - - // Build header - $headers = $this->build_header($to, $cc, $bcc); - - // Send message ... - if (!$use_queue) - { - $mail_to = ($to == '') ? 'undisclosed-recipients:;' : $to; - $err_msg = ''; - - if ($config['smtp_delivery']) - { - $result = smtpmail($this->addresses, mail_encode($this->subject), wordwrap(utf8_wordwrap($this->msg), 997, "\n", true), $err_msg, $headers); - } - else - { - $result = phpbb_mail($mail_to, $this->subject, $this->msg, $headers, PHP_EOL, $err_msg); - } - - if (!$result) - { - $this->error('EMAIL', $err_msg); - return false; - } - } - else - { - $this->queue->put('email', array( - 'to' => $to, - 'addresses' => $this->addresses, - 'subject' => $this->subject, - 'msg' => $this->msg, - 'headers' => $headers) - ); - } - - return true; - } - - /** - * Send jabber message out - */ - function msg_jabber() - { - global $config, $user, $phpbb_root_path, $phpEx; - - if (empty($config['jab_enable']) || empty($config['jab_host']) || empty($config['jab_username']) || empty($config['jab_password'])) - { - return false; - } - - if (empty($this->addresses['im'])) - { - // Send was successful. ;) - return true; - } - - $use_queue = false; - if ($config['jab_package_size'] && $this->use_queue) - { - if (empty($this->queue)) - { - $this->queue = new queue(); - $this->queue->init('jabber', $config['jab_package_size']); - } - $use_queue = true; - } - - $addresses = array(); - foreach ($this->addresses['im'] as $type => $uid_ary) - { - $addresses[] = $uid_ary['uid']; - } - $addresses = array_unique($addresses); - - if (!$use_queue) - { - include_once($phpbb_root_path . 'includes/functions_jabber.' . $phpEx); - $this->jabber = new jabber($config['jab_host'], $config['jab_port'], $config['jab_username'], htmlspecialchars_decode($config['jab_password']), $config['jab_use_ssl'], $config['jab_verify_peer'], $config['jab_verify_peer_name'], $config['jab_allow_self_signed']); - - if (!$this->jabber->connect()) - { - $this->error('JABBER', $user->lang['ERR_JAB_CONNECT'] . '
' . $this->jabber->get_log()); - return false; - } - - if (!$this->jabber->login()) - { - $this->error('JABBER', $user->lang['ERR_JAB_AUTH'] . '
' . $this->jabber->get_log()); - return false; - } - - foreach ($addresses as $address) - { - $this->jabber->send_message($address, $this->msg, $this->subject); - } - - $this->jabber->disconnect(); - } - else - { - $this->queue->put('jabber', array( - 'addresses' => $addresses, - 'subject' => $this->subject, - 'msg' => $this->msg) - ); - } - unset($addresses); - return true; - } - - /** - * Setup template engine - */ - protected function setup_template() - { - global $phpbb_container, $phpbb_dispatcher; - - if ($this->template instanceof \phpbb\template\template) - { - return; - } - - $template_environment = new \phpbb\template\twig\environment( - $phpbb_container->get('config'), - $phpbb_container->get('filesystem'), - $phpbb_container->get('path_helper'), - $phpbb_container->getParameter('core.template.cache_path'), - $phpbb_container->get('ext.manager'), - new \phpbb\template\twig\loader( - $phpbb_container->get('filesystem') - ), - $phpbb_dispatcher, - array() - ); - $template_environment->setLexer($phpbb_container->get('template.twig.lexer')); - - $this->template = new \phpbb\template\twig\twig( - $phpbb_container->get('path_helper'), - $phpbb_container->get('config'), - new \phpbb\template\context(), - $template_environment, - $phpbb_container->getParameter('core.template.cache_path'), - $phpbb_container->get('user'), - $phpbb_container->get('template.twig.extensions.collection'), - $phpbb_container->get('ext.manager') - ); - } - - /** - * Set template paths to load - */ - protected function set_template_paths($path_name, $paths) - { - $this->setup_template(); - - $this->template->set_custom_style($path_name, $paths); - } -} - -/** -* handling email and jabber queue -*/ -class queue -{ - var $data = array(); - var $queue_data = array(); - var $package_size = 0; - var $cache_file = ''; - var $eol = "\n"; - - /** - * @var \phpbb\filesystem\filesystem_interface - */ - protected $filesystem; - - /** - * constructor - */ - function __construct() - { - global $phpEx, $phpbb_root_path, $phpbb_filesystem, $phpbb_container; - - $this->data = array(); - $this->cache_file = $phpbb_container->getParameter('core.cache_dir') . "queue.$phpEx"; - $this->filesystem = $phpbb_filesystem; - } - - /** - * Init a queue object - */ - function init($object, $package_size) - { - $this->data[$object] = array(); - $this->data[$object]['package_size'] = $package_size; - $this->data[$object]['data'] = array(); - } - - /** - * Put object in queue - */ - function put($object, $scope) - { - $this->data[$object]['data'][] = $scope; - } - - /** - * Process queue - * Using lock file - */ - function process() - { - global $config, $phpEx, $phpbb_root_path, $user, $phpbb_dispatcher; - - $lock = new \phpbb\lock\flock($this->cache_file); - $lock->acquire(); - - // avoid races, check file existence once - $have_cache_file = file_exists($this->cache_file); - if (!$have_cache_file || $config['last_queue_run'] > time() - $config['queue_interval']) - { - if (!$have_cache_file) - { - $config->set('last_queue_run', time(), false); - } - - $lock->release(); - return; - } - - $config->set('last_queue_run', time(), false); - - include($this->cache_file); - - foreach ($this->queue_data as $object => $data_ary) - { - @set_time_limit(0); - - if (!isset($data_ary['package_size'])) - { - $data_ary['package_size'] = 0; - } - - $package_size = $data_ary['package_size']; - $num_items = (!$package_size || count($data_ary['data']) < $package_size) ? count($data_ary['data']) : $package_size; - - /* - * This code is commented out because it causes problems on some web hosts. - * The core problem is rather restrictive email sending limits. - * This code is nly useful if you have no such restrictions from the - * web host and the package size setting is wrong. - - // If the amount of emails to be sent is way more than package_size than we need to increase it to prevent backlogs... - if (count($data_ary['data']) > $package_size * 2.5) - { - $num_items = count($data_ary['data']); - } - */ - - switch ($object) - { - case 'email': - // Delete the email queued objects if mailing is disabled - if (!$config['email_enable']) - { - unset($this->queue_data['email']); - continue 2; - } - break; - - case 'jabber': - if (!$config['jab_enable']) - { - unset($this->queue_data['jabber']); - continue 2; - } - - include_once($phpbb_root_path . 'includes/functions_jabber.' . $phpEx); - $this->jabber = new jabber($config['jab_host'], $config['jab_port'], $config['jab_username'], htmlspecialchars_decode($config['jab_password']), $config['jab_use_ssl'], $config['jab_verify_peer'], $config['jab_verify_peer_name'], $config['jab_allow_self_signed']); - - if (!$this->jabber->connect()) - { - $messenger = new messenger(); - $messenger->error('JABBER', $user->lang['ERR_JAB_CONNECT']); - continue 2; - } - - if (!$this->jabber->login()) - { - $messenger = new messenger(); - $messenger->error('JABBER', $user->lang['ERR_JAB_AUTH']); - continue 2; - } - - break; - - default: - $lock->release(); - return; - } - - for ($i = 0; $i < $num_items; $i++) - { - // Make variables available... - extract(array_shift($this->queue_data[$object]['data'])); - - switch ($object) - { - case 'email': - $break = false; - /** - * Event to send message via external transport - * - * @event core.notification_message_process - * @var bool break Flag indicating if the function return after hook - * @var array addresses The message recipients - * @var string subject The message subject - * @var string msg The message text - * @since 3.2.4-RC1 - */ - $vars = array( - 'break', - 'addresses', - 'subject', - 'msg', - ); - extract($phpbb_dispatcher->trigger_event('core.notification_message_process', compact($vars))); - - if (!$break) - { - $err_msg = ''; - $to = (!$to) ? 'undisclosed-recipients:;' : $to; - - if ($config['smtp_delivery']) - { - $result = smtpmail($addresses, mail_encode($subject), wordwrap(utf8_wordwrap($msg), 997, "\n", true), $err_msg, $headers); - } - else - { - $result = phpbb_mail($to, $subject, $msg, $headers, PHP_EOL, $err_msg); - } - - if (!$result) - { - $messenger = new messenger(); - $messenger->error('EMAIL', $err_msg); - continue 2; - } - } - break; - - case 'jabber': - foreach ($addresses as $address) - { - if ($this->jabber->send_message($address, $msg, $subject) === false) - { - $messenger = new messenger(); - $messenger->error('JABBER', $this->jabber->get_log()); - continue 3; - } - } - break; - } - } - - // No more data for this object? Unset it - if (!count($this->queue_data[$object]['data'])) - { - unset($this->queue_data[$object]); - } - - // Post-object processing - switch ($object) - { - case 'jabber': - // Hang about a couple of secs to ensure the messages are - // handled, then disconnect - $this->jabber->disconnect(); - break; - } - } - - if (!count($this->queue_data)) - { - @unlink($this->cache_file); - } - else - { - if ($fp = @fopen($this->cache_file, 'wb')) - { - fwrite($fp, "queue_data = unserialize(" . var_export(serialize($this->queue_data), true) . ");\n\n?>"); - fclose($fp); - - if (function_exists('opcache_invalidate')) - { - @opcache_invalidate($this->cache_file); - } - - try - { - $this->filesystem->phpbb_chmod($this->cache_file, CHMOD_READ | CHMOD_WRITE); - } - catch (\phpbb\filesystem\exception\filesystem_exception $e) - { - // Do nothing - } - } - } - - $lock->release(); - } - - /** - * Save queue - */ - function save() - { - if (!count($this->data)) - { - return; - } - - $lock = new \phpbb\lock\flock($this->cache_file); - $lock->acquire(); - - if (file_exists($this->cache_file)) - { - include($this->cache_file); - - foreach ($this->queue_data as $object => $data_ary) - { - if (isset($this->data[$object]) && count($this->data[$object])) - { - $this->data[$object]['data'] = array_merge($data_ary['data'], $this->data[$object]['data']); - } - else - { - $this->data[$object]['data'] = $data_ary['data']; - } - } - } - - if ($fp = @fopen($this->cache_file, 'w')) - { - fwrite($fp, "queue_data = unserialize(" . var_export(serialize($this->data), true) . ");\n\n?>"); - fclose($fp); - - if (function_exists('opcache_invalidate')) - { - @opcache_invalidate($this->cache_file); - } - - try - { - $this->filesystem->phpbb_chmod($this->cache_file, CHMOD_READ | CHMOD_WRITE); - } - catch (\phpbb\filesystem\exception\filesystem_exception $e) - { - // Do nothing - } - - $this->data = array(); - } - - $lock->release(); - } -} - -/** -* Replacement or substitute for PHP's mail command -*/ -function smtpmail($addresses, $subject, $message, &$err_msg, $headers = false) -{ - global $config, $user; - - // Fix any bare linefeeds in the message to make it RFC821 Compliant. - $message = preg_replace("#(?lang['NO_EMAIL_SUBJECT'])) ? $user->lang['NO_EMAIL_SUBJECT'] : 'No email subject specified'; - return false; - } - - if (trim($message) == '') - { - $err_msg = (isset($user->lang['NO_EMAIL_MESSAGE'])) ? $user->lang['NO_EMAIL_MESSAGE'] : 'Email message was blank'; - return false; - } - - $mail_rcpt = $mail_to = $mail_cc = array(); - - // Build correct addresses for RCPT TO command and the client side display (TO, CC) - if (isset($addresses['to']) && count($addresses['to'])) - { - foreach ($addresses['to'] as $which_ary) - { - $mail_to[] = ($which_ary['name'] != '') ? mail_encode(trim($which_ary['name'])) . ' <' . trim($which_ary['email']) . '>' : '<' . trim($which_ary['email']) . '>'; - $mail_rcpt['to'][] = '<' . trim($which_ary['email']) . '>'; - } - } - - if (isset($addresses['bcc']) && count($addresses['bcc'])) - { - foreach ($addresses['bcc'] as $which_ary) - { - $mail_rcpt['bcc'][] = '<' . trim($which_ary['email']) . '>'; - } - } - - if (isset($addresses['cc']) && count($addresses['cc'])) - { - foreach ($addresses['cc'] as $which_ary) - { - $mail_cc[] = ($which_ary['name'] != '') ? mail_encode(trim($which_ary['name'])) . ' <' . trim($which_ary['email']) . '>' : '<' . trim($which_ary['email']) . '>'; - $mail_rcpt['cc'][] = '<' . trim($which_ary['email']) . '>'; - } - } - - $smtp = new smtp_class(); - - $errno = 0; - $errstr = ''; - - $smtp->add_backtrace('Connecting to ' . $config['smtp_host'] . ':' . $config['smtp_port']); - - // Ok we have error checked as much as we can to this point let's get on it already. - if (!class_exists('\phpbb\error_collector')) - { - global $phpbb_root_path, $phpEx; - include($phpbb_root_path . 'includes/error_collector.' . $phpEx); - } - $collector = new \phpbb\error_collector; - $collector->install(); - - $options = array(); - $verify_peer = (bool) $config['smtp_verify_peer']; - $verify_peer_name = (bool) $config['smtp_verify_peer_name']; - $allow_self_signed = (bool) $config['smtp_allow_self_signed']; - $remote_socket = $config['smtp_host'] . ':' . $config['smtp_port']; - - // Set ssl context options, see http://php.net/manual/en/context.ssl.php - $options['ssl'] = array('verify_peer' => $verify_peer, 'verify_peer_name' => $verify_peer_name, 'allow_self_signed' => $allow_self_signed); - $socket_context = stream_context_create($options); - - $smtp->socket = @stream_socket_client($remote_socket, $errno, $errstr, 20, STREAM_CLIENT_CONNECT, $socket_context); - $collector->uninstall(); - $error_contents = $collector->format_errors(); - - if (!$smtp->socket) - { - if ($errstr) - { - $errstr = utf8_convert_message($errstr); - } - - $err_msg = (isset($user->lang['NO_CONNECT_TO_SMTP_HOST'])) ? sprintf($user->lang['NO_CONNECT_TO_SMTP_HOST'], $errno, $errstr) : "Could not connect to smtp host : $errno : $errstr"; - $err_msg .= ($error_contents) ? '

' . htmlspecialchars($error_contents) : ''; - return false; - } - - // Wait for reply - if ($err_msg = $smtp->server_parse('220', __LINE__)) - { - $smtp->close_session($err_msg); - return false; - } - - // Let me in. This function handles the complete authentication process - if ($err_msg = $smtp->log_into_server($config['smtp_host'], $config['smtp_username'], htmlspecialchars_decode($config['smtp_password']), $config['smtp_auth_method'])) - { - $smtp->close_session($err_msg); - return false; - } - - // From this point onward most server response codes should be 250 - // Specify who the mail is from.... - $smtp->server_send('MAIL FROM:<' . $config['board_email'] . '>'); - if ($err_msg = $smtp->server_parse('250', __LINE__)) - { - $smtp->close_session($err_msg); - return false; - } - - // Specify each user to send to and build to header. - $to_header = implode(', ', $mail_to); - $cc_header = implode(', ', $mail_cc); - - // Now tell the MTA to send the Message to the following people... [TO, BCC, CC] - $rcpt = false; - foreach ($mail_rcpt as $type => $mail_to_addresses) - { - foreach ($mail_to_addresses as $mail_to_address) - { - // Add an additional bit of error checking to the To field. - if (preg_match('#[^ ]+\@[^ ]+#', $mail_to_address)) - { - $smtp->server_send("RCPT TO:$mail_to_address"); - if ($err_msg = $smtp->server_parse('250', __LINE__)) - { - // We continue... if users are not resolved we do not care - if ($smtp->numeric_response_code != 550) - { - $smtp->close_session($err_msg); - return false; - } - } - else - { - $rcpt = true; - } - } - } - } - - // We try to send messages even if a few people do not seem to have valid email addresses, but if no one has, we have to exit here. - if (!$rcpt) - { - $user->session_begin(); - $err_msg .= '

'; - $err_msg .= (isset($user->lang['INVALID_EMAIL_LOG'])) ? sprintf($user->lang['INVALID_EMAIL_LOG'], htmlspecialchars($mail_to_address)) : '' . htmlspecialchars($mail_to_address) . ' possibly an invalid email address?'; - $smtp->close_session($err_msg); - return false; - } - - // Ok now we tell the server we are ready to start sending data - $smtp->server_send('DATA'); - - // This is the last response code we look for until the end of the message. - if ($err_msg = $smtp->server_parse('354', __LINE__)) - { - $smtp->close_session($err_msg); - return false; - } - - // Send the Subject Line... - $smtp->server_send("Subject: $subject"); - - // Now the To Header. - $to_header = ($to_header == '') ? 'undisclosed-recipients:;' : $to_header; - $smtp->server_send("To: $to_header"); - - // Now the CC Header. - if ($cc_header != '') - { - $smtp->server_send("CC: $cc_header"); - } - - // Now any custom headers.... - if ($headers !== false) - { - $smtp->server_send("$headers\r\n"); - } - - // Ok now we are ready for the message... - $smtp->server_send($message); - - // Ok the all the ingredients are mixed in let's cook this puppy... - $smtp->server_send('.'); - if ($err_msg = $smtp->server_parse('250', __LINE__)) - { - $smtp->close_session($err_msg); - return false; - } - - // Now tell the server we are done and close the socket... - $smtp->server_send('QUIT'); - $smtp->close_session($err_msg); - - return true; -} - -/** -* SMTP Class -* Auth Mechanisms originally taken from the AUTH Modules found within the PHP Extension and Application Repository (PEAR) -* See docs/AUTHORS for more details -*/ -class smtp_class -{ - var $server_response = ''; - var $socket = 0; - protected $socket_tls = false; - var $responses = array(); - var $commands = array(); - var $numeric_response_code = 0; - - var $backtrace = false; - var $backtrace_log = array(); - - function __construct() - { - // Always create a backtrace for admins to identify SMTP problems - $this->backtrace = true; - $this->backtrace_log = array(); - } - - /** - * Add backtrace message for debugging - */ - function add_backtrace($message) - { - if ($this->backtrace) - { - $this->backtrace_log[] = utf8_htmlspecialchars($message); - } - } - - /** - * Send command to smtp server - */ - function server_send($command, $private_info = false) - { - fputs($this->socket, $command . "\r\n"); - - (!$private_info) ? $this->add_backtrace("# $command") : $this->add_backtrace('# Omitting sensitive information'); - - // We could put additional code here - } - - /** - * We use the line to give the support people an indication at which command the error occurred - */ - function server_parse($response, $line) - { - global $user; - - $this->server_response = ''; - $this->responses = array(); - $this->numeric_response_code = 0; - - while (substr($this->server_response, 3, 1) != ' ') - { - if (!($this->server_response = fgets($this->socket, 256))) - { - return (isset($user->lang['NO_EMAIL_RESPONSE_CODE'])) ? $user->lang['NO_EMAIL_RESPONSE_CODE'] : 'Could not get mail server response codes'; - } - $this->responses[] = substr(rtrim($this->server_response), 4); - $this->numeric_response_code = (int) substr($this->server_response, 0, 3); - - $this->add_backtrace("LINE: $line <- {$this->server_response}"); - } - - if (!(substr($this->server_response, 0, 3) == $response)) - { - $this->numeric_response_code = (int) substr($this->server_response, 0, 3); - return (isset($user->lang['EMAIL_SMTP_ERROR_RESPONSE'])) ? sprintf($user->lang['EMAIL_SMTP_ERROR_RESPONSE'], $line, $this->server_response) : "Ran into problems sending Mail at Line $line. Response: $this->server_response"; - } - - return 0; - } - - /** - * Close session - */ - function close_session(&$err_msg) - { - fclose($this->socket); - - if ($this->backtrace) - { - $message = '

Backtrace

' . implode('
', $this->backtrace_log) . '

'; - $err_msg .= $message; - } - } - - /** - * Log into server and get possible auth codes if neccessary - */ - function log_into_server($hostname, $username, $password, $default_auth_method) - { - global $user; - - // Here we try to determine the *real* hostname (reverse DNS entry preferrably) - $local_host = $user->host; - - if (function_exists('php_uname')) - { - $local_host = php_uname('n'); - - // Able to resolve name to IP - if (($addr = @gethostbyname($local_host)) !== $local_host) - { - // Able to resolve IP back to name - if (($name = @gethostbyaddr($addr)) !== $addr) - { - $local_host = $name; - } - } - } - - // If we are authenticating through pop-before-smtp, we - // have to login ones before we get authenticated - // NOTE: on some configurations the time between an update of the auth database takes so - // long that the first email send does not work. This is not a biggie on a live board (only - // the install mail will most likely fail) - but on a dynamic ip connection this might produce - // severe problems and is not fixable! - if ($default_auth_method == 'POP-BEFORE-SMTP' && $username && $password) - { - global $config; - - $errno = 0; - $errstr = ''; - - $this->server_send("QUIT"); - fclose($this->socket); - - $this->pop_before_smtp($hostname, $username, $password); - $username = $password = $default_auth_method = ''; - - // We need to close the previous session, else the server is not - // able to get our ip for matching... - if (!$this->socket = @fsockopen($config['smtp_host'], $config['smtp_port'], $errno, $errstr, 10)) - { - if ($errstr) - { - $errstr = utf8_convert_message($errstr); - } - - $err_msg = (isset($user->lang['NO_CONNECT_TO_SMTP_HOST'])) ? sprintf($user->lang['NO_CONNECT_TO_SMTP_HOST'], $errno, $errstr) : "Could not connect to smtp host : $errno : $errstr"; - return $err_msg; - } - - // Wait for reply - if ($err_msg = $this->server_parse('220', __LINE__)) - { - $this->close_session($err_msg); - return $err_msg; - } - } - - $hello_result = $this->hello($local_host); - if (!is_null($hello_result)) - { - return $hello_result; - } - - // SMTP STARTTLS (RFC 3207) - if (!$this->socket_tls) - { - $this->socket_tls = $this->starttls(); - - if ($this->socket_tls) - { - // Switched to TLS - // RFC 3207: "The client MUST discard any knowledge obtained from the server, [...]" - // So say hello again - $hello_result = $this->hello($local_host); - - if (!is_null($hello_result)) - { - return $hello_result; - } - } - } - - // If we are not authenticated yet, something might be wrong if no username and passwd passed - if (!$username || !$password) - { - return false; - } - - if (!isset($this->commands['AUTH'])) - { - return (isset($user->lang['SMTP_NO_AUTH_SUPPORT'])) ? $user->lang['SMTP_NO_AUTH_SUPPORT'] : 'SMTP server does not support authentication'; - } - - // Get best authentication method - $available_methods = explode(' ', $this->commands['AUTH']); - - // Define the auth ordering if the default auth method was not found - $auth_methods = array('PLAIN', 'LOGIN', 'CRAM-MD5', 'DIGEST-MD5'); - $method = ''; - - if (in_array($default_auth_method, $available_methods)) - { - $method = $default_auth_method; - } - else - { - foreach ($auth_methods as $_method) - { - if (in_array($_method, $available_methods)) - { - $method = $_method; - break; - } - } - } - - if (!$method) - { - return (isset($user->lang['NO_SUPPORTED_AUTH_METHODS'])) ? $user->lang['NO_SUPPORTED_AUTH_METHODS'] : 'No supported authentication methods'; - } - - $method = strtolower(str_replace('-', '_', $method)); - return $this->$method($username, $password); - } - - /** - * SMTP EHLO/HELO - * - * @return mixed Null if the authentication process is supposed to continue - * False if already authenticated - * Error message (string) otherwise - */ - protected function hello($hostname) - { - // Try EHLO first - $this->server_send("EHLO $hostname"); - if ($err_msg = $this->server_parse('250', __LINE__)) - { - // a 503 response code means that we're already authenticated - if ($this->numeric_response_code == 503) - { - return false; - } - - // If EHLO fails, we try HELO - $this->server_send("HELO $hostname"); - if ($err_msg = $this->server_parse('250', __LINE__)) - { - return ($this->numeric_response_code == 503) ? false : $err_msg; - } - } - - foreach ($this->responses as $response) - { - $response = explode(' ', $response); - $response_code = $response[0]; - unset($response[0]); - $this->commands[$response_code] = implode(' ', $response); - } - } - - /** - * SMTP STARTTLS (RFC 3207) - * - * @return bool Returns true if TLS was started - * Otherwise false - */ - protected function starttls() - { - global $config; - - // allow SMTPS (what was used by phpBB 3.0) if hostname is prefixed with tls:// or ssl:// - if (strpos($config['smtp_host'], 'tls://') === 0 || strpos($config['smtp_host'], 'ssl://') === 0) - { - return true; - } - - if (!function_exists('stream_socket_enable_crypto')) - { - return false; - } - - if (!isset($this->commands['STARTTLS'])) - { - return false; - } - - $this->server_send('STARTTLS'); - - if ($err_msg = $this->server_parse('220', __LINE__)) - { - return false; - } - - $result = false; - $stream_meta = stream_get_meta_data($this->socket); - - if (socket_set_blocking($this->socket, 1)) - { - // https://secure.php.net/manual/en/function.stream-socket-enable-crypto.php#119122 - $crypto = (phpbb_version_compare(PHP_VERSION, '5.6.7', '<')) ? STREAM_CRYPTO_METHOD_TLS_CLIENT : STREAM_CRYPTO_METHOD_SSLv23_CLIENT; - $result = stream_socket_enable_crypto($this->socket, true, $crypto); - socket_set_blocking($this->socket, (int) $stream_meta['blocked']); - } - - return $result; - } - - /** - * Pop before smtp authentication - */ - function pop_before_smtp($hostname, $username, $password) - { - global $user; - - if (!$this->socket = @fsockopen($hostname, 110, $errno, $errstr, 10)) - { - if ($errstr) - { - $errstr = utf8_convert_message($errstr); - } - - return (isset($user->lang['NO_CONNECT_TO_SMTP_HOST'])) ? sprintf($user->lang['NO_CONNECT_TO_SMTP_HOST'], $errno, $errstr) : "Could not connect to smtp host : $errno : $errstr"; - } - - $this->server_send("USER $username", true); - if ($err_msg = $this->server_parse('+OK', __LINE__)) - { - return $err_msg; - } - - $this->server_send("PASS $password", true); - if ($err_msg = $this->server_parse('+OK', __LINE__)) - { - return $err_msg; - } - - $this->server_send('QUIT'); - fclose($this->socket); - - return false; - } - - /** - * Plain authentication method - */ - function plain($username, $password) - { - $this->server_send('AUTH PLAIN'); - if ($err_msg = $this->server_parse('334', __LINE__)) - { - return ($this->numeric_response_code == 503) ? false : $err_msg; - } - - $base64_method_plain = base64_encode("\0" . $username . "\0" . $password); - $this->server_send($base64_method_plain, true); - if ($err_msg = $this->server_parse('235', __LINE__)) - { - return $err_msg; - } - - return false; - } - - /** - * Login authentication method - */ - function login($username, $password) - { - $this->server_send('AUTH LOGIN'); - if ($err_msg = $this->server_parse('334', __LINE__)) - { - return ($this->numeric_response_code == 503) ? false : $err_msg; - } - - $this->server_send(base64_encode($username), true); - if ($err_msg = $this->server_parse('334', __LINE__)) - { - return $err_msg; - } - - $this->server_send(base64_encode($password), true); - if ($err_msg = $this->server_parse('235', __LINE__)) - { - return $err_msg; - } - - return false; - } - - /** - * cram_md5 authentication method - */ - function cram_md5($username, $password) - { - $this->server_send('AUTH CRAM-MD5'); - if ($err_msg = $this->server_parse('334', __LINE__)) - { - return ($this->numeric_response_code == 503) ? false : $err_msg; - } - - $md5_challenge = base64_decode($this->responses[0]); - $password = (strlen($password) > 64) ? pack('H32', md5($password)) : ((strlen($password) < 64) ? str_pad($password, 64, chr(0)) : $password); - $md5_digest = md5((substr($password, 0, 64) ^ str_repeat(chr(0x5C), 64)) . (pack('H32', md5((substr($password, 0, 64) ^ str_repeat(chr(0x36), 64)) . $md5_challenge)))); - - $base64_method_cram_md5 = base64_encode($username . ' ' . $md5_digest); - - $this->server_send($base64_method_cram_md5, true); - if ($err_msg = $this->server_parse('235', __LINE__)) - { - return $err_msg; - } - - return false; - } - - /** - * digest_md5 authentication method - * A real pain in the *** - */ - function digest_md5($username, $password) - { - global $config, $user; - - $this->server_send('AUTH DIGEST-MD5'); - if ($err_msg = $this->server_parse('334', __LINE__)) - { - return ($this->numeric_response_code == 503) ? false : $err_msg; - } - - $md5_challenge = base64_decode($this->responses[0]); - - // Parse the md5 challenge - from AUTH_SASL (PEAR) - $tokens = array(); - while (preg_match('/^([a-z-]+)=("[^"]+(?host; - } - - // Maxbuf - if (empty($tokens['maxbuf'])) - { - $tokens['maxbuf'] = 65536; - } - - // Required: nonce, algorithm - if (empty($tokens['nonce']) || empty($tokens['algorithm'])) - { - $tokens = array(); - } - $md5_challenge = $tokens; - - if (!empty($md5_challenge)) - { - $str = ''; - for ($i = 0; $i < 32; $i++) - { - $str .= chr(mt_rand(0, 255)); - } - $cnonce = base64_encode($str); - - $digest_uri = 'smtp/' . $config['smtp_host']; - - $auth_1 = sprintf('%s:%s:%s', pack('H32', md5(sprintf('%s:%s:%s', $username, $md5_challenge['realm'], $password))), $md5_challenge['nonce'], $cnonce); - $auth_2 = 'AUTHENTICATE:' . $digest_uri; - $response_value = md5(sprintf('%s:%s:00000001:%s:auth:%s', md5($auth_1), $md5_challenge['nonce'], $cnonce, md5($auth_2))); - - $input_string = sprintf('username="%s",realm="%s",nonce="%s",cnonce="%s",nc="00000001",qop=auth,digest-uri="%s",response=%s,%d', $username, $md5_challenge['realm'], $md5_challenge['nonce'], $cnonce, $digest_uri, $response_value, $md5_challenge['maxbuf']); - } - else - { - return (isset($user->lang['INVALID_DIGEST_CHALLENGE'])) ? $user->lang['INVALID_DIGEST_CHALLENGE'] : 'Invalid digest challenge'; - } - - $base64_method_digest_md5 = base64_encode($input_string); - $this->server_send($base64_method_digest_md5, true); - if ($err_msg = $this->server_parse('334', __LINE__)) - { - return $err_msg; - } - - $this->server_send(' '); - if ($err_msg = $this->server_parse('235', __LINE__)) - { - return $err_msg; - } - - return false; - } -} - -/** -* Encodes the given string for proper display in UTF-8. -* -* This version is using base64 encoded data. The downside of this -* is if the mail client does not understand this encoding the user -* is basically doomed with an unreadable subject. -* -* Please note that this version fully supports RFC 2045 section 6.8. -* -* @param string $eol End of line we are using (optional to be backwards compatible) -*/ -function mail_encode($str, $eol = "\r\n") -{ - // define start delimimter, end delimiter and spacer - $start = "=?UTF-8?B?"; - $end = "?="; - $delimiter = "$eol "; - - // Maximum length is 75. $split_length *must* be a multiple of 4, but <= 75 - strlen($start . $delimiter . $end)!!! - $split_length = 60; - $encoded_str = base64_encode($str); - - // If encoded string meets the limits, we just return with the correct data. - if (strlen($encoded_str) <= $split_length) - { - return $start . $encoded_str . $end; - } - - // If there is only ASCII data, we just return what we want, correctly splitting the lines. - if (strlen($str) === utf8_strlen($str)) - { - return $start . implode($end . $delimiter . $start, str_split($encoded_str, $split_length)) . $end; - } - - // UTF-8 data, compose encoded lines - $array = utf8_str_split($str); - $str = ''; - - while (count($array)) - { - $text = ''; - - while (count($array) && intval((strlen($text . $array[0]) + 2) / 3) << 2 <= $split_length) - { - $text .= array_shift($array); - } - - $str .= $start . base64_encode($text) . $end . $delimiter; - } - - return substr($str, 0, -strlen($delimiter)); -} - -/** - * Wrapper for sending out emails with the PHP's mail function - */ -function phpbb_mail($to, $subject, $msg, $headers, $eol, &$err_msg) -{ - global $config, $phpbb_root_path, $phpEx; - - // Convert Numeric Character References to UTF-8 chars (ie. Emojis) - $subject = utf8_decode_ncr($subject); - $msg = utf8_decode_ncr($msg); - - /** - * We use the EOL character for the OS here because the PHP mail function does not correctly transform line endings. - * On Windows SMTP is used (SMTP is \r\n), on UNIX a command is used... - * Reference: http://bugs.php.net/bug.php?id=15841 - */ - $headers = implode($eol, $headers); - - if (!class_exists('\phpbb\error_collector')) - { - include($phpbb_root_path . 'includes/error_collector.' . $phpEx); - } - - $collector = new \phpbb\error_collector; - $collector->install(); - - /** - * On some PHP Versions mail() *may* fail if there are newlines within the subject. - * Newlines are used as a delimiter for lines in mail_encode() according to RFC 2045 section 6.8. - * Because PHP can't decide what is wanted we revert back to the non-RFC-compliant way of separating by one space - * (Use '' as parameter to mail_encode() results in SPACE used) - */ - $additional_parameters = $config['email_force_sender'] ? '-f' . $config['board_email'] : ''; - - $result = mail($to, mail_encode($subject, ''), wordwrap(utf8_wordwrap($msg), 997, "\n", true), $headers, $additional_parameters); - - $collector->uninstall(); - $err_msg = $collector->format_errors(); - - return $result; -} diff --git a/install/update/new/includes/functions_module.php b/install/update/new/includes/functions_module.php deleted file mode 100644 index e90c11f..0000000 --- a/install/update/new/includes/functions_module.php +++ /dev/null @@ -1,1153 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* Class handling all types of 'plugins' (a future term) -*/ -class p_master -{ - var $p_id; - var $p_class; - var $p_name; - var $p_mode; - var $p_parent; - - var $include_path = false; - var $active_module = false; - var $active_module_row_id = false; - var $acl_forum_id = false; - var $module_ary = array(); - - /** - * Constuctor - * Set module include path - */ - function __construct($include_path = false) - { - global $phpbb_root_path; - - $this->include_path = ($include_path !== false) ? $include_path : $phpbb_root_path . 'includes/'; - - // Make sure the path ends with / - if (substr($this->include_path, -1) !== '/') - { - $this->include_path .= '/'; - } - } - - /** - * Set custom include path for modules - * Schema for inclusion is include_path . modulebase - * - * @param string $include_path include path to be used. - * @access public - */ - function set_custom_include_path($include_path) - { - $this->include_path = $include_path; - - // Make sure the path ends with / - if (substr($this->include_path, -1) !== '/') - { - $this->include_path .= '/'; - } - } - - /** - * List modules - * - * This creates a list, stored in $this->module_ary of all available - * modules for the given class (ucp, mcp and acp). Additionally - * $this->module_y_ary is created with indentation information for - * displaying the module list appropriately. Only modules for which - * the user has access rights are included in these lists. - */ - function list_modules($p_class) - { - global $db, $user, $cache; - global $phpbb_dispatcher; - - // Sanitise for future path use, it's escaped as appropriate for queries - $this->p_class = str_replace(array('.', '/', '\\'), '', basename($p_class)); - - // Get cached modules - if (($this->module_cache = $cache->get('_modules_' . $this->p_class)) === false) - { - // Get modules - $sql = 'SELECT * - FROM ' . MODULES_TABLE . " - WHERE module_class = '" . $db->sql_escape($this->p_class) . "' - ORDER BY left_id ASC"; - $result = $db->sql_query($sql); - - $rows = array(); - while ($row = $db->sql_fetchrow($result)) - { - $rows[$row['module_id']] = $row; - } - $db->sql_freeresult($result); - - $this->module_cache = array(); - foreach ($rows as $module_id => $row) - { - $this->module_cache['modules'][] = $row; - $this->module_cache['parents'][$row['module_id']] = $this->get_parents($row['parent_id'], $row['left_id'], $row['right_id'], $rows); - } - unset($rows); - - $cache->put('_modules_' . $this->p_class, $this->module_cache); - } - - if (empty($this->module_cache)) - { - $this->module_cache = array('modules' => array(), 'parents' => array()); - } - - // We "could" build a true tree with this function - maybe mod authors want to use this... - // Functions for traversing and manipulating the tree are not available though - // We might re-structure the module system to use true trees in 4.0 - // $tree = $this->build_tree($this->module_cache['modules'], $this->module_cache['parents']); - - // Clean up module cache array to only let survive modules the user can access - $right_id = false; - - $hide_categories = array(); - foreach ($this->module_cache['modules'] as $key => $row) - { - // When the module has no mode (category) we check whether it has visible children - // before listing it as well. - if (!$row['module_mode']) - { - $hide_categories[(int) $row['module_id']] = $key; - } - - // Not allowed to view module? - if (!$this->module_auth_self($row['module_auth'])) - { - unset($this->module_cache['modules'][$key]); - continue; - } - - // Category with no members, ignore - if (!$row['module_basename'] && ($row['left_id'] + 1 == $row['right_id'])) - { - unset($this->module_cache['modules'][$key]); - continue; - } - - // Skip branch - if ($right_id !== false) - { - if ($row['left_id'] < $right_id) - { - unset($this->module_cache['modules'][$key]); - continue; - } - - $right_id = false; - } - - // Not enabled? - if (!$row['module_enabled']) - { - // If category is disabled then disable every child too - unset($this->module_cache['modules'][$key]); - $right_id = $row['right_id']; - continue; - } - - if ($row['module_mode']) - { - // The parent category has a visible child - // So remove it and all its parents from the hide array - unset($hide_categories[(int) $row['parent_id']]); - foreach ($this->module_cache['parents'][$row['module_id']] as $module_id => $row_id) - { - unset($hide_categories[$module_id]); - } - } - } - - foreach ($hide_categories as $module_id => $row_id) - { - unset($this->module_cache['modules'][$row_id]); - } - - // Re-index (this is needed, else we are not able to array_slice later) - $this->module_cache['modules'] = array_merge($this->module_cache['modules']); - - // Include MOD _info files for populating language entries within the menus - $this->add_mod_info($this->p_class); - - // Now build the module array, but exclude completely empty categories... - $right_id = false; - $names = array(); - - foreach ($this->module_cache['modules'] as $key => $row) - { - // Skip branch - if ($right_id !== false) - { - if ($row['left_id'] < $right_id) - { - continue; - } - - $right_id = false; - } - - // Category with no members on their way down (we have to check every level) - if (!$row['module_basename']) - { - $empty_category = true; - - // We go through the branch and look for an activated module - foreach (array_slice($this->module_cache['modules'], $key + 1) as $temp_row) - { - if ($temp_row['left_id'] > $row['left_id'] && $temp_row['left_id'] < $row['right_id']) - { - // Module there - if ($temp_row['module_basename'] && $temp_row['module_enabled']) - { - $empty_category = false; - break; - } - continue; - } - break; - } - - // Skip the branch - if ($empty_category) - { - $right_id = $row['right_id']; - continue; - } - } - - $depth = count($this->module_cache['parents'][$row['module_id']]); - - // We need to prefix the functions to not create a naming conflict - - // Function for building 'url_extra' - $short_name = $this->get_short_name($row['module_basename']); - - $url_func = 'phpbb_module_' . $short_name . '_url'; - if (!function_exists($url_func)) - { - $url_func = '_module_' . $short_name . '_url'; - } - - // Function for building the language name - $lang_func = 'phpbb_module_' . $short_name . '_lang'; - if (!function_exists($lang_func)) - { - $lang_func = '_module_' . $short_name . '_lang'; - } - - // Custom function for calling parameters on module init (for example assigning template variables) - $custom_func = 'phpbb_module_' . $short_name; - if (!function_exists($custom_func)) - { - $custom_func = '_module_' . $short_name; - } - - $names[$row['module_basename'] . '_' . $row['module_mode']][] = true; - - $module_row = array( - 'depth' => $depth, - - 'id' => (int) $row['module_id'], - 'parent' => (int) $row['parent_id'], - 'cat' => ($row['right_id'] > $row['left_id'] + 1) ? true : false, - - 'is_duplicate' => ($row['module_basename'] && count($names[$row['module_basename'] . '_' . $row['module_mode']]) > 1) ? true : false, - - 'name' => (string) $row['module_basename'], - 'mode' => (string) $row['module_mode'], - 'display' => (int) $row['module_display'], - - 'url_extra' => (function_exists($url_func)) ? $url_func($row['module_mode'], $row) : '', - - 'lang' => ($row['module_basename'] && function_exists($lang_func)) ? $lang_func($row['module_mode'], $row['module_langname']) : ((!empty($user->lang[$row['module_langname']])) ? $user->lang[$row['module_langname']] : $row['module_langname']), - 'langname' => $row['module_langname'], - - 'left' => $row['left_id'], - 'right' => $row['right_id'], - ); - - if (function_exists($custom_func)) - { - $custom_func($row['module_mode'], $module_row); - } - - /** - * This event allows to modify parameters for building modules list - * - * @event core.modify_module_row - * @var string url_func Function for building 'url_extra' - * @var string lang_func Function for building the language name - * @var string custom_func Custom function for calling parameters on module init - * @var array row Array holding the basic module data - * @var array module_row Array holding the module display parameters - * @since 3.1.0-b3 - */ - $vars = array('url_func', 'lang_func', 'custom_func', 'row', 'module_row'); - extract($phpbb_dispatcher->trigger_event('core.modify_module_row', compact($vars))); - - $this->module_ary[] = $module_row; - } - - unset($this->module_cache['modules'], $names); - } - - /** - * Check if a certain main module is accessible/loaded - * By giving the module mode you are able to additionally check for only one mode within the main module - * - * @param string $module_basename The module base name, for example logs, reports, main (for the mcp). - * @param mixed $module_mode The module mode to check. If provided the mode will be checked in addition for presence. - * - * @return bool Returns true if module is loaded and accessible, else returns false - */ - function loaded($module_basename, $module_mode = false) - { - if (!$this->is_full_class($module_basename)) - { - $module_basename = $this->p_class . '_' . $module_basename; - } - - if (empty($this->loaded_cache)) - { - $this->loaded_cache = array(); - - foreach ($this->module_ary as $row) - { - if (!$row['name']) - { - continue; - } - - if (!isset($this->loaded_cache[$row['name']])) - { - $this->loaded_cache[$row['name']] = array(); - } - - if (!$row['mode']) - { - continue; - } - - $this->loaded_cache[$row['name']][$row['mode']] = true; - } - } - - if ($module_mode === false) - { - return (isset($this->loaded_cache[$module_basename])) ? true : false; - } - - return (!empty($this->loaded_cache[$module_basename][$module_mode])) ? true : false; - } - - /** - * Check module authorisation. - * - * This is a non-static version that uses $this->acl_forum_id - * for the forum id. - */ - function module_auth_self($module_auth) - { - return self::module_auth($module_auth, $this->acl_forum_id); - } - - /** - * Check module authorisation. - * - * This is a static version, it must be given $forum_id. - * See also module_auth_self. - */ - static function module_auth($module_auth, $forum_id) - { - global $auth, $config; - global $request, $phpbb_extension_manager, $phpbb_dispatcher; - - $module_auth = trim($module_auth); - - // Generally allowed to access module if module_auth is empty - if (!$module_auth) - { - return true; - } - - // With the code below we make sure only those elements get eval'd we really want to be checked - preg_match_all('/(?: - "[^"\\\\]*(?:\\\\.[^"\\\\]*)*" | - \'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\' | - [(),] | - [^\s(),]+)/x', $module_auth, $match); - - // Valid tokens for auth and their replacements - $valid_tokens = array( - 'acl_([a-z0-9_]+)(,\$id)?' => '(int) $auth->acl_get(\'\\1\'\\2)', - '\$id' => '(int) $forum_id', - 'aclf_([a-z0-9_]+)' => '(int) $auth->acl_getf_global(\'\\1\')', - 'cfg_([a-z0-9_]+)' => '(int) $config[\'\\1\']', - 'request_([a-zA-Z0-9_]+)' => '$request->variable(\'\\1\', false)', - 'ext_([a-zA-Z0-9_/]+)' => 'array_key_exists(\'\\1\', $phpbb_extension_manager->all_enabled())', - 'authmethod_([a-z0-9_\\\\]+)' => '($config[\'auth_method\'] === \'\\1\')', - ); - - /** - * Alter tokens for module authorisation check - * - * @event core.module_auth - * @var array valid_tokens Valid tokens and their auth check - * replacements - * @var string module_auth The module_auth of the current - * module - * @var int forum_id The current forum_id - * @since 3.1.0-a3 - */ - $vars = array('valid_tokens', 'module_auth', 'forum_id'); - extract($phpbb_dispatcher->trigger_event('core.module_auth', compact($vars))); - - $tokens = $match[0]; - for ($i = 0, $size = count($tokens); $i < $size; $i++) - { - $token = &$tokens[$i]; - - switch ($token) - { - case ')': - case '(': - case '&&': - case '||': - case ',': - break; - - default: - if (!preg_match('#(?:' . implode(')|(?:', array_keys($valid_tokens)) . ')#', $token)) - { - $token = ''; - } - break; - } - } - - $module_auth = implode(' ', $tokens); - - // Make sure $id separation is working fine - $module_auth = str_replace(' , ', ',', $module_auth); - - $module_auth = preg_replace( - // Array keys with # prepended/appended - array_map(function($value) { - return '#' . $value . '#'; - }, array_keys($valid_tokens)), - array_values($valid_tokens), - $module_auth - ); - - $is_auth = false; - // @codingStandardsIgnoreStart - eval('$is_auth = (int) (' . $module_auth . ');'); - // @codingStandardsIgnoreEnd - - return $is_auth; - } - - /** - * Set active module - */ - function set_active($id = false, $mode = false) - { - global $request; - - $icat = false; - $this->active_module = false; - - if ($request->variable('icat', '')) - { - $icat = $id; - $id = $request->variable('icat', ''); - } - - // Restore the backslashes in class names - if (strpos($id, '-') !== false) - { - $id = str_replace('-', '\\', $id); - } - - if ($id && !is_numeric($id) && !$this->is_full_class($id)) - { - $id = $this->p_class . '_' . $id; - } - - $category = false; - foreach ($this->module_ary as $row_id => $item_ary) - { - // If this is a module and it's selected, active - // If this is a category and the module is the first within it, active - // If this is a module and no mode selected, select first mode - // If no category or module selected, go active for first module in first category - if ( - (($item_ary['name'] === $id || $item_ary['name'] === $this->p_class . '_' . $id || $item_ary['id'] === (int) $id) && (($item_ary['mode'] == $mode && !$item_ary['cat']) || ($icat && $item_ary['cat']))) || - ($item_ary['parent'] === $category && !$item_ary['cat'] && !$icat && $item_ary['display']) || - (($item_ary['name'] === $id || $item_ary['name'] === $this->p_class . '_' . $id || $item_ary['id'] === (int) $id) && !$mode && !$item_ary['cat']) || - (!$id && !$mode && !$item_ary['cat'] && $item_ary['display']) - ) - { - if ($item_ary['cat']) - { - $id = $icat; - $icat = false; - - continue; - } - - $this->p_id = $item_ary['id']; - $this->p_parent = $item_ary['parent']; - $this->p_name = $item_ary['name']; - $this->p_mode = $item_ary['mode']; - $this->p_left = $item_ary['left']; - $this->p_right = $item_ary['right']; - - $this->module_cache['parents'] = $this->module_cache['parents'][$this->p_id]; - $this->active_module = $item_ary['id']; - $this->active_module_row_id = $row_id; - - break; - } - else if (($item_ary['cat'] && $item_ary['id'] === (int) $id) || ($item_ary['parent'] === $category && $item_ary['cat'])) - { - $category = $item_ary['id']; - } - } - } - - /** - * Loads currently active module - * - * This method loads a given module, passing it the relevant id and mode. - * - * @param string|false $mode mode, as passed through to the module - * @param string|false $module_url If supplied, we use this module url - * @param bool $execute_module If true, at the end we execute the main method for the new instance - */ - function load_active($mode = false, $module_url = false, $execute_module = true) - { - global $phpbb_root_path, $phpbb_admin_path, $phpEx, $user, $template, $request; - - $module_path = $this->include_path . $this->p_class; - $icat = $request->variable('icat', ''); - - if ($this->active_module === false) - { - trigger_error('MODULE_NOT_ACCESS', E_USER_ERROR); - } - - // new modules use the full class names, old ones are always called _, e.g. acp_board - if (!class_exists($this->p_name)) - { - if (!file_exists("$module_path/{$this->p_name}.$phpEx")) - { - trigger_error($user->lang('MODULE_NOT_FIND', "$module_path/{$this->p_name}.$phpEx"), E_USER_ERROR); - } - - include("$module_path/{$this->p_name}.$phpEx"); - - if (!class_exists($this->p_name)) - { - trigger_error($user->lang('MODULE_FILE_INCORRECT_CLASS', "$module_path/{$this->p_name}.$phpEx", $this->p_name), E_USER_ERROR); - } - } - - if (!empty($mode)) - { - $this->p_mode = $mode; - } - - // Create a new instance of the desired module ... - $class_name = $this->p_name; - - $this->module = new $class_name($this); - - // We pre-define the action parameter we are using all over the place - if (defined('IN_ADMIN')) - { - /* - * If this is an extension module, we'll try to automatically set - * the style paths for the extension (the ext author can change them - * if necessary). - */ - $module_dir = explode('\\', get_class($this->module)); - - // 0 vendor, 1 extension name, ... - if (isset($module_dir[1])) - { - $module_style_dir = $phpbb_root_path . 'ext/' . $module_dir[0] . '/' . $module_dir[1] . '/adm/style'; - - if (is_dir($module_style_dir)) - { - $template->set_custom_style(array( - array( - 'name' => 'adm', - 'ext_path' => 'adm/style/', - ), - ), array($module_style_dir, $phpbb_admin_path . 'style')); - } - } - - // Is first module automatically enabled a duplicate and the category not passed yet? - if (!$icat && $this->module_ary[$this->active_module_row_id]['is_duplicate']) - { - $icat = $this->module_ary[$this->active_module_row_id]['parent']; - } - - // Not being able to overwrite ;) - $this->module->u_action = append_sid("{$phpbb_admin_path}index.$phpEx", 'i=' . $this->get_module_identifier($this->p_name)) . (($icat) ? '&icat=' . $icat : '') . "&mode={$this->p_mode}"; - } - else - { - /* - * If this is an extension module, we'll try to automatically set - * the style paths for the extension (the ext author can change them - * if necessary). - */ - $module_dir = explode('\\', get_class($this->module)); - - // 0 vendor, 1 extension name, ... - if (isset($module_dir[1])) - { - $module_style_dir = 'ext/' . $module_dir[0] . '/' . $module_dir[1] . '/styles'; - - if (is_dir($phpbb_root_path . $module_style_dir)) - { - $template->set_style(array($module_style_dir, 'styles')); - } - } - - // If user specified the module url we will use it... - if ($module_url !== false) - { - $this->module->u_action = $module_url; - } - else - { - $this->module->u_action = $phpbb_root_path . (($user->page['page_dir']) ? $user->page['page_dir'] . '/' : '') . $user->page['page_name']; - } - - $this->module->u_action = append_sid($this->module->u_action, 'i=' . $this->get_module_identifier($this->p_name)) . (($icat) ? '&icat=' . $icat : '') . "&mode={$this->p_mode}"; - } - - // Add url_extra parameter to u_action url - if (!empty($this->module_ary) && $this->active_module !== false && $this->module_ary[$this->active_module_row_id]['url_extra']) - { - $this->module->u_action .= $this->module_ary[$this->active_module_row_id]['url_extra']; - } - - // Assign the module path for re-usage - $this->module->module_path = $module_path . '/'; - - // Execute the main method for the new instance, we send the module id and mode as parameters - // Users are able to call the main method after this function to be able to assign additional parameters manually - if ($execute_module) - { - $short_name = preg_replace("#^{$this->p_class}_#", '', $this->p_name); - $this->module->main($short_name, $this->p_mode); - } - } - - /** - * Appending url parameter to the currently active module. - * - * This function is called for adding specific url parameters while executing the current module. - * It is doing the same as the _module_{name}_url() function, apart from being able to be called after - * having dynamically parsed specific parameters. This allows more freedom in choosing additional parameters. - * One example can be seen in /includes/mcp/mcp_notes.php - $this->p_master->adjust_url() call. - * - * @param string $url_extra Extra url parameters, e.g.: &u=$user_id - * - */ - function adjust_url($url_extra) - { - if (empty($this->module_ary[$this->active_module_row_id])) - { - return; - } - - $row = &$this->module_ary[$this->active_module_row_id]; - - // We check for the same url_extra in $row['url_extra'] to overcome doubled additions... - if (strpos($row['url_extra'], $url_extra) === false) - { - $row['url_extra'] .= $url_extra; - } - } - - /** - * Check if a module is active - */ - function is_active($id, $mode = false) - { - // If we find a name by this id and being enabled we have our active one... - foreach ($this->module_ary as $row_id => $item_ary) - { - if (($item_ary['name'] === $id || $item_ary['id'] === (int) $id) && $item_ary['display'] || $item_ary['name'] === $this->p_class . '_' . $id) - { - if ($mode === false || $mode === $item_ary['mode']) - { - return true; - } - } - } - - return false; - } - - /** - * Get parents - */ - function get_parents($parent_id, $left_id, $right_id, &$all_parents) - { - $parents = array(); - - if ($parent_id > 0) - { - foreach ($all_parents as $module_id => $row) - { - if ($row['left_id'] < $left_id && $row['right_id'] > $right_id) - { - $parents[$module_id] = $row['parent_id']; - } - - if ($row['left_id'] > $left_id) - { - break; - } - } - } - - return $parents; - } - - /** - * Get tree branch - */ - function get_branch($left_id, $right_id, $remaining) - { - $branch = array(); - - foreach ($remaining as $key => $row) - { - if ($row['left_id'] > $left_id && $row['left_id'] < $right_id) - { - $branch[] = $row; - continue; - } - break; - } - - return $branch; - } - - /** - * Build true binary tree from given array - * Not in use - */ - function build_tree(&$modules, &$parents) - { - $tree = array(); - - foreach ($modules as $row) - { - $branch = &$tree; - - if ($row['parent_id']) - { - // Go through the tree to find our branch - $parent_tree = $parents[$row['module_id']]; - - foreach ($parent_tree as $id => $value) - { - if (!isset($branch[$id]) && isset($branch['child'])) - { - $branch = &$branch['child']; - } - $branch = &$branch[$id]; - } - $branch = &$branch['child']; - } - - $branch[$row['module_id']] = $row; - if (!isset($branch[$row['module_id']]['child'])) - { - $branch[$row['module_id']]['child'] = array(); - } - } - - return $tree; - } - - /** - * Build navigation structure - */ - function assign_tpl_vars($module_url) - { - global $template; - - $current_id = $right_id = false; - - // Make sure the module_url has a question mark set, effectively determining the delimiter to use - $delim = (strpos($module_url, '?') === false) ? '?' : '&'; - - $current_depth = 0; - $linear_offset = 'l_block1'; - $tabular_offset = 't_block2'; - - // Generate the list of modules, we'll do this in two ways ... - // 1) In a linear fashion - // 2) In a combined tabbed + linear fashion ... tabs for the categories - // and a linear list for subcategories/items - foreach ($this->module_ary as $row_id => $item_ary) - { - // Skip hidden modules - if (!$item_ary['display']) - { - continue; - } - - // Skip branch - if ($right_id !== false) - { - if ($item_ary['left'] < $right_id) - { - continue; - } - - $right_id = false; - } - - // Category with no members on their way down (we have to check every level) - if (!$item_ary['name']) - { - $empty_category = true; - - // We go through the branch and look for an activated module - foreach (array_slice($this->module_ary, $row_id + 1) as $temp_row) - { - if ($temp_row['left'] > $item_ary['left'] && $temp_row['left'] < $item_ary['right']) - { - // Module there and displayed? - if ($temp_row['name'] && $temp_row['display']) - { - $empty_category = false; - break; - } - continue; - } - break; - } - - // Skip the branch - if ($empty_category) - { - $right_id = $item_ary['right']; - continue; - } - } - - // Select first id we can get - if (!$current_id && (isset($this->module_cache['parents'][$item_ary['id']]) || $item_ary['id'] == $this->p_id)) - { - $current_id = $item_ary['id']; - } - - $depth = $item_ary['depth']; - - if ($depth > $current_depth) - { - $linear_offset = $linear_offset . '.l_block' . ($depth + 1); - $tabular_offset = ($depth + 1 > 2) ? $tabular_offset . '.t_block' . ($depth + 1) : $tabular_offset; - } - else if ($depth < $current_depth) - { - for ($i = $current_depth - $depth; $i > 0; $i--) - { - $linear_offset = substr($linear_offset, 0, strrpos($linear_offset, '.')); - $tabular_offset = ($i + $depth > 1) ? substr($tabular_offset, 0, strrpos($tabular_offset, '.')) : $tabular_offset; - } - } - - $u_title = $module_url . $delim . 'i='; - // if the item has a name use it, else use its id - if (empty($item_ary['name'])) - { - $u_title .= $item_ary['id']; - } - else - { - // if the category has a name, then use it. - $u_title .= $this->get_module_identifier($item_ary['name']); - } - // If the item is not a category append the mode - if (!$item_ary['cat']) - { - if ($item_ary['is_duplicate']) - { - $u_title .= '&icat=' . $current_id; - } - $u_title .= '&mode=' . $item_ary['mode']; - } - - // Was not allowed in categories before - /*!$item_ary['cat'] && */ - $u_title .= (isset($item_ary['url_extra'])) ? $item_ary['url_extra'] : ''; - - // Only output a categories items if it's currently selected - if (!$depth || ($depth && (in_array($item_ary['parent'], array_values($this->module_cache['parents'])) || $item_ary['parent'] == $this->p_parent))) - { - $use_tabular_offset = (!$depth) ? 't_block1' : $tabular_offset; - - $tpl_ary = array( - 'L_TITLE' => $item_ary['lang'], - 'S_SELECTED' => (isset($this->module_cache['parents'][$item_ary['id']]) || $item_ary['id'] == $this->p_id) ? true : false, - 'U_TITLE' => $u_title - ); - - if (isset($this->module_cache['parents'][$item_ary['id']]) || $item_ary['id'] == $this->p_id) - { - $template->assign_block_vars('navlinks', array( - 'BREADCRUMB_NAME' => $item_ary['lang'], - 'U_BREADCRUMB' => $u_title, - )); - } - - $template->assign_block_vars($use_tabular_offset, array_merge($tpl_ary, array_change_key_case($item_ary, CASE_UPPER))); - } - - $tpl_ary = array( - 'L_TITLE' => $item_ary['lang'], - 'S_SELECTED' => (isset($this->module_cache['parents'][$item_ary['id']]) || $item_ary['id'] == $this->p_id) ? true : false, - 'U_TITLE' => $u_title - ); - - $template->assign_block_vars($linear_offset, array_merge($tpl_ary, array_change_key_case($item_ary, CASE_UPPER))); - - $current_depth = $depth; - } - } - - /** - * Returns desired template name - */ - function get_tpl_name() - { - return $this->module->tpl_name . '.html'; - } - - /** - * Returns the desired page title - */ - function get_page_title() - { - global $user; - - if (!isset($this->module->page_title)) - { - return ''; - } - - return (isset($user->lang[$this->module->page_title])) ? $user->lang[$this->module->page_title] : $this->module->page_title; - } - - /** - * Load module as the current active one without the need for registering it - * - * @param string $class module class (acp/mcp/ucp) - * @param string $name module name (class name of the module, or its basename - * phpbb_ext_foo_acp_bar_module, ucp_zebra or zebra) - * @param string $mode mode, as passed through to the module - * - */ - function load($class, $name, $mode = false) - { - // new modules use the full class names, old ones are always called _, e.g. acp_board - // in the latter case this function may be called as load('acp', 'board') - if (!class_exists($name) && substr($name, 0, strlen($class) + 1) !== $class . '_') - { - $name = $class . '_' . $name; - } - - $this->p_class = $class; - $this->p_name = $name; - - // Set active module to true instead of using the id - $this->active_module = true; - - $this->load_active($mode); - } - - /** - * Display module - */ - function display($page_title, $display_online_list = false) - { - global $template, $user; - - // Generate the page - if (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin']) - { - adm_page_header($page_title); - } - else - { - page_header($page_title, $display_online_list); - } - - $template->set_filenames(array( - 'body' => $this->get_tpl_name()) - ); - - if (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin']) - { - adm_page_footer(); - } - else - { - page_footer(); - } - } - - /** - * Toggle whether this module will be displayed or not - */ - function set_display($id, $mode = false, $display = true) - { - foreach ($this->module_ary as $row_id => $item_ary) - { - if (($item_ary['name'] === $id || $item_ary['name'] === $this->p_class . '_' . $id || $item_ary['id'] === (int) $id) && (!$mode || $item_ary['mode'] === $mode)) - { - $this->module_ary[$row_id]['display'] = (int) $display; - } - } - } - - /** - * Add custom MOD info language file - */ - function add_mod_info($module_class) - { - global $config, $user, $phpEx, $phpbb_extension_manager; - - $finder = $phpbb_extension_manager->get_finder(); - - // We grab the language files from the default, English and user's language. - // So we can fall back to the other files like we do when using add_lang() - $default_lang_files = $english_lang_files = $user_lang_files = array(); - - // Search for board default language if it's not the user language - if ($config['default_lang'] != $user->lang_name) - { - $default_lang_files = $finder - ->prefix('info_' . strtolower($module_class) . '_') - ->suffix(".$phpEx") - ->extension_directory('/language/' . basename($config['default_lang'])) - ->core_path('language/' . basename($config['default_lang']) . '/mods/') - ->find(); - } - - // Search for english, if its not the default or user language - if ($config['default_lang'] != 'en' && $user->lang_name != 'en') - { - $english_lang_files = $finder - ->prefix('info_' . strtolower($module_class) . '_') - ->suffix(".$phpEx") - ->extension_directory('/language/en') - ->core_path('language/en/mods/') - ->find(); - } - - // Find files in the user's language - $user_lang_files = $finder - ->prefix('info_' . strtolower($module_class) . '_') - ->suffix(".$phpEx") - ->extension_directory('/language/' . $user->lang_name) - ->core_path('language/' . $user->lang_name . '/mods/') - ->find(); - - $lang_files = array_merge($english_lang_files, $default_lang_files, $user_lang_files); - foreach ($lang_files as $lang_file => $ext_name) - { - $user->add_lang_ext($ext_name, $lang_file); - } - } - - /** - * Retrieve shortened module basename for legacy basenames (with xcp_ prefix) - * - * @param string $basename A module basename - * @return string The basename if it starts with phpbb_ or the basename with - * the current p_class (e.g. acp_) stripped. - */ - protected function get_short_name($basename) - { - if (substr($basename, 0, 6) === 'phpbb\\' || strpos($basename, '\\') !== false) - { - return $basename; - } - - // strip xcp_ prefix from old classes - return substr($basename, strlen($this->p_class) + 1); - } - - /** - * If the basename contains a \ we don't use that for the URL. - * - * Firefox is currently unable to correctly copy a urlencoded \ - * so users will be unable to post links to modules. - * However we can replace them with dashes and re-replace them later - * - * @param string $basename Basename of the module - * @return string Identifier that should be used for - * module link creation - */ - protected function get_module_identifier($basename) - { - if (strpos($basename, '\\') === false) - { - return $basename; - } - - return str_replace('\\', '-', $basename); - } - - /** - * Checks whether the given module basename is a correct class name - * - * @param string $basename A module basename - * @return bool True if the basename starts with phpbb_ or (x)cp_, false otherwise - */ - protected function is_full_class($basename) - { - return (strpos($basename, '\\') !== false || preg_match('/^(ucp|mcp|acp)_/', $basename)); - } -} diff --git a/install/update/new/includes/functions_posting.php b/install/update/new/includes/functions_posting.php deleted file mode 100644 index 45eda4b..0000000 --- a/install/update/new/includes/functions_posting.php +++ /dev/null @@ -1,2804 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* Fill smiley templates (or just the variables) with smilies, either in a window or inline -*/ -function generate_smilies($mode, $forum_id) -{ - global $db, $user, $config, $template, $phpbb_dispatcher, $request; - global $phpEx, $phpbb_root_path, $phpbb_container, $phpbb_path_helper; - - /* @var $pagination \phpbb\pagination */ - $pagination = $phpbb_container->get('pagination'); - $base_url = append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=smilies&f=' . $forum_id); - $start = $request->variable('start', 0); - - if ($mode == 'window') - { - if ($forum_id) - { - $sql = 'SELECT forum_style - FROM ' . FORUMS_TABLE . " - WHERE forum_id = $forum_id"; - $result = $db->sql_query_limit($sql, 1); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $user->setup('posting', (int) $row['forum_style']); - } - else - { - $user->setup('posting'); - } - - page_header($user->lang['SMILIES']); - - $sql_ary = [ - 'SELECT' => 'COUNT(s.smiley_id) AS item_count', - 'FROM' => [ - SMILIES_TABLE => 's', - ], - 'GROUP_BY' => 's.smiley_url', - ]; - - /** - * Modify SQL query that fetches the total number of smilies in window mode - * - * @event core.generate_smilies_count_sql_before - * @var int forum_id Forum where smilies are generated - * @var array sql_ary Array with the SQL query - * @since 3.2.9-RC1 - */ - $vars = [ - 'forum_id', - 'sql_ary', - ]; - extract($phpbb_dispatcher->trigger_event('core.generate_smilies_count_sql_before', compact($vars))); - - $sql = $db->sql_build_query('SELECT', $sql_ary); - $result = $db->sql_query($sql, 3600); - - $smiley_count = 0; - while ($row = $db->sql_fetchrow($result)) - { - ++$smiley_count; - } - $db->sql_freeresult($result); - - $template->set_filenames(array( - 'body' => 'posting_smilies.html') - ); - - $start = $pagination->validate_start($start, $config['smilies_per_page'], $smiley_count); - $pagination->generate_template_pagination($base_url, 'pagination', 'start', $smiley_count, $config['smilies_per_page'], $start); - } - - $display_link = false; - if ($mode == 'inline') - { - $sql = 'SELECT smiley_id - FROM ' . SMILIES_TABLE . ' - WHERE display_on_posting = 0'; - $result = $db->sql_query_limit($sql, 1, 0, 3600); - - if ($row = $db->sql_fetchrow($result)) - { - $display_link = true; - } - $db->sql_freeresult($result); - } - - if ($mode == 'window') - { - $sql = 'SELECT smiley_url, MIN(emotion) as emotion, MIN(code) AS code, smiley_width, smiley_height, MIN(smiley_order) AS min_smiley_order - FROM ' . SMILIES_TABLE . ' - GROUP BY smiley_url, smiley_width, smiley_height - ORDER BY min_smiley_order'; - $result = $db->sql_query_limit($sql, $config['smilies_per_page'], $start, 3600); - } - else - { - $sql = 'SELECT * - FROM ' . SMILIES_TABLE . ' - WHERE display_on_posting = 1 - ORDER BY smiley_order'; - $result = $db->sql_query($sql, 3600); - } - - $smilies = array(); - while ($row = $db->sql_fetchrow($result)) - { - if (empty($smilies[$row['smiley_url']])) - { - $smilies[$row['smiley_url']] = $row; - } - } - $db->sql_freeresult($result); - - /** - * Modify smilies before they are assigned to the template - * - * @event core.generate_smilies_modify_rowset - * @var string mode Smiley mode, either window or inline - * @var int forum_id Forum where smilies are generated - * @var array smilies Smiley rows fetched from the database - * @since 3.2.9-RC1 - */ - $vars = [ - 'mode', - 'forum_id', - 'smilies', - ]; - extract($phpbb_dispatcher->trigger_event('core.generate_smilies_modify_rowset', compact($vars))); - - if (count($smilies)) - { - $root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_path_helper->get_web_root_path(); - - foreach ($smilies as $row) - { - /** - * Modify smiley root path before populating smiley list - * - * @event core.generate_smilies_before - * @var string root_path root_path for smilies - * @since 3.1.11-RC1 - */ - $vars = array('root_path'); - extract($phpbb_dispatcher->trigger_event('core.generate_smilies_before', compact($vars))); - $template->assign_block_vars('smiley', array( - 'SMILEY_CODE' => $row['code'], - 'A_SMILEY_CODE' => addslashes($row['code']), - 'SMILEY_IMG' => $root_path . $config['smilies_path'] . '/' . $row['smiley_url'], - 'SMILEY_WIDTH' => $row['smiley_width'], - 'SMILEY_HEIGHT' => $row['smiley_height'], - 'SMILEY_DESC' => $row['emotion']) - ); - } - } - - /** - * This event is called after the smilies are populated - * - * @event core.generate_smilies_after - * @var string mode Mode of the smilies: window|inline - * @var int forum_id The forum ID we are currently in - * @var bool display_link Shall we display the "more smilies" link? - * @since 3.1.0-a1 - */ - $vars = array('mode', 'forum_id', 'display_link'); - extract($phpbb_dispatcher->trigger_event('core.generate_smilies_after', compact($vars))); - - if ($mode == 'inline' && $display_link) - { - $template->assign_vars(array( - 'S_SHOW_SMILEY_LINK' => true, - 'U_MORE_SMILIES' => $base_url, - )); - } - - if ($mode == 'window') - { - page_footer(); - } -} - -/** -* Update last post information -* Should be used instead of sync() if only the last post information are out of sync... faster -* -* @param string $type Can be forum|topic -* @param mixed $ids topic/forum ids -* @param bool $return_update_sql true: SQL query shall be returned, false: execute SQL -*/ -function update_post_information($type, $ids, $return_update_sql = false) -{ - global $db; - - if (empty($ids)) - { - return; - } - if (!is_array($ids)) - { - $ids = array($ids); - } - - $update_sql = $empty_forums = $not_empty_forums = array(); - - if ($type != 'topic') - { - $topic_join = ', ' . TOPICS_TABLE . ' t'; - $topic_condition = 'AND t.topic_id = p.topic_id AND t.topic_visibility = ' . ITEM_APPROVED; - } - else - { - $topic_join = ''; - $topic_condition = ''; - } - - if (count($ids) == 1) - { - $sql = 'SELECT p.post_id as last_post_id - FROM ' . POSTS_TABLE . " p $topic_join - WHERE " . $db->sql_in_set('p.' . $type . '_id', $ids) . " - $topic_condition - AND p.post_visibility = " . ITEM_APPROVED . " - ORDER BY p.post_id DESC"; - $result = $db->sql_query_limit($sql, 1); - } - else - { - $sql = 'SELECT p.' . $type . '_id, MAX(p.post_id) as last_post_id - FROM ' . POSTS_TABLE . " p $topic_join - WHERE " . $db->sql_in_set('p.' . $type . '_id', $ids) . " - $topic_condition - AND p.post_visibility = " . ITEM_APPROVED . " - GROUP BY p.{$type}_id"; - $result = $db->sql_query($sql); - } - - $last_post_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - if (count($ids) == 1) - { - $row[$type . '_id'] = $ids[0]; - } - - if ($type == 'forum') - { - $not_empty_forums[] = $row['forum_id']; - - if (empty($row['last_post_id'])) - { - $empty_forums[] = $row['forum_id']; - } - } - - $last_post_ids[] = $row['last_post_id']; - } - $db->sql_freeresult($result); - - if ($type == 'forum') - { - $empty_forums = array_merge($empty_forums, array_diff($ids, $not_empty_forums)); - - foreach ($empty_forums as $void => $forum_id) - { - $update_sql[$forum_id][] = 'forum_last_post_id = 0'; - $update_sql[$forum_id][] = "forum_last_post_subject = ''"; - $update_sql[$forum_id][] = 'forum_last_post_time = 0'; - $update_sql[$forum_id][] = 'forum_last_poster_id = 0'; - $update_sql[$forum_id][] = "forum_last_poster_name = ''"; - $update_sql[$forum_id][] = "forum_last_poster_colour = ''"; - } - } - - if (count($last_post_ids)) - { - $sql = 'SELECT p.' . $type . '_id, p.post_id, p.post_subject, p.post_time, p.poster_id, p.post_username, u.user_id, u.username, u.user_colour - FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u - WHERE p.poster_id = u.user_id - AND ' . $db->sql_in_set('p.post_id', $last_post_ids); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $update_sql[$row["{$type}_id"]][] = $type . '_last_post_id = ' . (int) $row['post_id']; - $update_sql[$row["{$type}_id"]][] = "{$type}_last_post_subject = '" . $db->sql_escape($row['post_subject']) . "'"; - $update_sql[$row["{$type}_id"]][] = $type . '_last_post_time = ' . (int) $row['post_time']; - $update_sql[$row["{$type}_id"]][] = $type . '_last_poster_id = ' . (int) $row['poster_id']; - $update_sql[$row["{$type}_id"]][] = "{$type}_last_poster_colour = '" . $db->sql_escape($row['user_colour']) . "'"; - $update_sql[$row["{$type}_id"]][] = "{$type}_last_poster_name = '" . (($row['poster_id'] == ANONYMOUS) ? $db->sql_escape($row['post_username']) : $db->sql_escape($row['username'])) . "'"; - } - $db->sql_freeresult($result); - } - unset($empty_forums, $ids, $last_post_ids); - - if ($return_update_sql || !count($update_sql)) - { - return $update_sql; - } - - $table = ($type == 'forum') ? FORUMS_TABLE : TOPICS_TABLE; - - foreach ($update_sql as $update_id => $update_sql_ary) - { - $sql = "UPDATE $table - SET " . implode(', ', $update_sql_ary) . " - WHERE {$type}_id = $update_id"; - $db->sql_query($sql); - } - - return; -} - -/** -* Generate Topic Icons for display -*/ -function posting_gen_topic_icons($mode, $icon_id) -{ - global $phpbb_root_path, $config, $template, $cache; - - // Grab icons - $icons = $cache->obtain_icons(); - - if (!$icon_id) - { - $template->assign_var('S_NO_ICON_CHECKED', ' checked="checked"'); - } - - if (count($icons)) - { - $root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_root_path; - - foreach ($icons as $id => $data) - { - if ($data['display']) - { - $template->assign_block_vars('topic_icon', array( - 'ICON_ID' => $id, - 'ICON_IMG' => $root_path . $config['icons_path'] . '/' . $data['img'], - 'ICON_WIDTH' => $data['width'], - 'ICON_HEIGHT' => $data['height'], - 'ICON_ALT' => $data['alt'], - - 'S_CHECKED' => ($id == $icon_id) ? true : false, - 'S_ICON_CHECKED' => ($id == $icon_id) ? ' checked="checked"' : '') - ); - } - } - - return true; - } - - return false; -} - -/** -* Build topic types able to be selected -*/ -function posting_gen_topic_types($forum_id, $cur_topic_type = POST_NORMAL) -{ - global $auth, $user, $template; - - $toggle = false; - - $topic_types = array( - 'sticky' => array('const' => POST_STICKY, 'lang' => 'POST_STICKY'), - 'announce' => array('const' => POST_ANNOUNCE, 'lang' => 'POST_ANNOUNCEMENT'), - 'announce_global' => array('const' => POST_GLOBAL, 'lang' => 'POST_GLOBAL') - ); - - $topic_type_array = array(); - - foreach ($topic_types as $auth_key => $topic_value) - { - if ($auth->acl_get('f_' . $auth_key, $forum_id)) - { - $toggle = true; - - $topic_type_array[] = array( - 'VALUE' => $topic_value['const'], - 'S_CHECKED' => ($cur_topic_type == $topic_value['const']) ? ' checked="checked"' : '', - 'L_TOPIC_TYPE' => $user->lang[$topic_value['lang']] - ); - } - } - - if ($toggle) - { - $topic_type_array = array_merge(array(0 => array( - 'VALUE' => POST_NORMAL, - 'S_CHECKED' => ($cur_topic_type == POST_NORMAL) ? ' checked="checked"' : '', - 'L_TOPIC_TYPE' => $user->lang['POST_NORMAL'])), - - $topic_type_array - ); - - foreach ($topic_type_array as $array) - { - $template->assign_block_vars('topic_type', $array); - } - - $template->assign_vars(array( - 'S_TOPIC_TYPE_STICKY' => ($auth->acl_get('f_sticky', $forum_id)), - 'S_TOPIC_TYPE_ANNOUNCE' => ($auth->acl_gets('f_announce', 'f_announce_global', $forum_id)), - )); - } - - return $toggle; -} - -// -// Attachment related functions -// -/** -* Calculate the needed size for Thumbnail -*/ -function get_img_size_format($width, $height) -{ - global $config; - - // Maximum Width the Image can take - $max_width = ($config['img_max_thumb_width']) ? $config['img_max_thumb_width'] : 400; - - if ($width > $height) - { - return array( - round($width * ($max_width / $width)), - round($height * ($max_width / $width)) - ); - } - else - { - return array( - round($width * ($max_width / $height)), - round($height * ($max_width / $height)) - ); - } -} - -/** -* Return supported image types -*/ -function get_supported_image_types($type = false) -{ - if (@extension_loaded('gd')) - { - $format = imagetypes(); - $new_type = 0; - - if ($type !== false) - { - // Type is one of the IMAGETYPE constants - it is fetched from getimagesize() - switch ($type) - { - // GIF - case IMAGETYPE_GIF: - $new_type = ($format & IMG_GIF) ? IMG_GIF : false; - break; - - // JPG, JPC, JP2 - case IMAGETYPE_JPEG: - case IMAGETYPE_JPC: - case IMAGETYPE_JPEG2000: - case IMAGETYPE_JP2: - case IMAGETYPE_JPX: - case IMAGETYPE_JB2: - $new_type = ($format & IMG_JPG) ? IMG_JPG : false; - break; - - // PNG - case IMAGETYPE_PNG: - $new_type = ($format & IMG_PNG) ? IMG_PNG : false; - break; - - // WBMP - case IMAGETYPE_WBMP: - $new_type = ($format & IMG_WBMP) ? IMG_WBMP : false; - break; - } - } - else - { - $new_type = array(); - $go_through_types = array(IMG_GIF, IMG_JPG, IMG_PNG, IMG_WBMP); - - foreach ($go_through_types as $check_type) - { - if ($format & $check_type) - { - $new_type[] = $check_type; - } - } - } - - return array( - 'gd' => ($new_type) ? true : false, - 'format' => $new_type, - 'version' => (function_exists('imagecreatetruecolor')) ? 2 : 1 - ); - } - - return array('gd' => false); -} - -/** -* Create Thumbnail -*/ -function create_thumbnail($source, $destination, $mimetype) -{ - global $config, $phpbb_filesystem, $phpbb_dispatcher; - - $min_filesize = (int) $config['img_min_thumb_filesize']; - $img_filesize = (file_exists($source)) ? @filesize($source) : false; - - if (!$img_filesize || $img_filesize <= $min_filesize) - { - return false; - } - - $dimension = @getimagesize($source); - - if ($dimension === false) - { - return false; - } - - list($width, $height, $type, ) = $dimension; - - if (empty($width) || empty($height)) - { - return false; - } - - list($new_width, $new_height) = get_img_size_format($width, $height); - - // Do not create a thumbnail if the resulting width/height is bigger than the original one - if ($new_width >= $width && $new_height >= $height) - { - return false; - } - - $thumbnail_created = false; - - /** - * Create thumbnail event to replace GD thumbnail creation with for example ImageMagick - * - * @event core.thumbnail_create_before - * @var string source Image source path - * @var string destination Thumbnail destination path - * @var string mimetype Image mime type - * @var float new_width Calculated thumbnail width - * @var float new_height Calculated thumbnail height - * @var bool thumbnail_created Set to true to skip default GD thumbnail creation - * @since 3.2.4 - */ - $vars = array( - 'source', - 'destination', - 'mimetype', - 'new_width', - 'new_height', - 'thumbnail_created', - ); - extract($phpbb_dispatcher->trigger_event('core.thumbnail_create_before', compact($vars))); - - if (!$thumbnail_created) - { - $type = get_supported_image_types($type); - - if ($type['gd']) - { - // If the type is not supported, we are not able to create a thumbnail - if ($type['format'] === false) - { - return false; - } - - switch ($type['format']) - { - case IMG_GIF: - $image = @imagecreatefromgif($source); - break; - - case IMG_JPG: - @ini_set('gd.jpeg_ignore_warning', 1); - $image = @imagecreatefromjpeg($source); - break; - - case IMG_PNG: - $image = @imagecreatefrompng($source); - break; - - case IMG_WBMP: - $image = @imagecreatefromwbmp($source); - break; - } - - if (empty($image)) - { - return false; - } - - if ($type['version'] == 1) - { - $new_image = imagecreate($new_width, $new_height); - - if ($new_image === false) - { - return false; - } - - imagecopyresized($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); - } - else - { - $new_image = imagecreatetruecolor($new_width, $new_height); - - if ($new_image === false) - { - return false; - } - - // Preserve alpha transparency (png for example) - @imagealphablending($new_image, false); - @imagesavealpha($new_image, true); - - imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); - } - - switch ($type['format']) - { - case IMG_GIF: - imagegif($new_image, $destination); - break; - - case IMG_JPG: - imagejpeg($new_image, $destination, 90); - break; - - case IMG_PNG: - imagepng($new_image, $destination); - break; - - case IMG_WBMP: - imagewbmp($new_image, $destination); - break; - } - - imagedestroy($new_image); - } - else - { - return false; - } - } - - if (!file_exists($destination)) - { - return false; - } - - try - { - $phpbb_filesystem->phpbb_chmod($destination, CHMOD_READ | CHMOD_WRITE); - } - catch (\phpbb\filesystem\exception\filesystem_exception $e) - { - // Do nothing - } - - return true; -} - -/** -* Assign Inline attachments (build option fields) -*/ -function posting_gen_inline_attachments(&$attachment_data) -{ - global $template; - - if (count($attachment_data)) - { - $s_inline_attachment_options = ''; - - foreach ($attachment_data as $i => $attachment) - { - $s_inline_attachment_options .= ''; - } - - $template->assign_var('S_INLINE_ATTACHMENT_OPTIONS', $s_inline_attachment_options); - - return true; - } - - return false; -} - -/** -* Generate inline attachment entry -*/ -function posting_gen_attachment_entry($attachment_data, &$filename_data, $show_attach_box = true) -{ - global $template, $config, $phpbb_root_path, $phpEx, $user, $phpbb_dispatcher; - - // Some default template variables - $template->assign_vars(array( - 'S_SHOW_ATTACH_BOX' => $show_attach_box, - 'S_HAS_ATTACHMENTS' => count($attachment_data), - 'FILESIZE' => $config['max_filesize'], - 'FILE_COMMENT' => (isset($filename_data['filecomment'])) ? $filename_data['filecomment'] : '', - )); - - if (count($attachment_data)) - { - // We display the posted attachments within the desired order. - ($config['display_order']) ? krsort($attachment_data) : ksort($attachment_data); - - $attachrow_template_vars = []; - - foreach ($attachment_data as $count => $attach_row) - { - $hidden = ''; - $attach_row['real_filename'] = utf8_basename($attach_row['real_filename']); - - foreach ($attach_row as $key => $value) - { - $hidden .= ''; - } - - $download_link = append_sid("{$phpbb_root_path}download/file.$phpEx", 'mode=view&id=' . (int) $attach_row['attach_id'], true, ($attach_row['is_orphan']) ? $user->session_id : false); - - $attachrow_template_vars[(int) $attach_row['attach_id']] = array( - 'FILENAME' => utf8_basename($attach_row['real_filename']), - 'A_FILENAME' => addslashes(utf8_basename($attach_row['real_filename'])), - 'FILE_COMMENT' => $attach_row['attach_comment'], - 'ATTACH_ID' => $attach_row['attach_id'], - 'S_IS_ORPHAN' => $attach_row['is_orphan'], - 'ASSOC_INDEX' => $count, - 'FILESIZE' => get_formatted_filesize($attach_row['filesize']), - - 'U_VIEW_ATTACHMENT' => $download_link, - 'S_HIDDEN' => $hidden, - ); - } - - /** - * Modify inline attachments template vars - * - * @event core.modify_inline_attachments_template_vars - * @var array attachment_data Array containing attachments data - * @var array attachrow_template_vars Array containing attachments template vars - * @since 3.2.2-RC1 - */ - $vars = array('attachment_data', 'attachrow_template_vars'); - extract($phpbb_dispatcher->trigger_event('core.modify_inline_attachments_template_vars', compact($vars))); - - $template->assign_block_vars_array('attach_row', $attachrow_template_vars); - } - - return count($attachment_data); -} - -// -// General Post functions -// - -/** -* Load Drafts -*/ -function load_drafts($topic_id = 0, $forum_id = 0, $id = 0, $pm_action = '', $msg_id = 0) -{ - global $user, $db, $template, $auth; - global $phpbb_root_path, $phpbb_dispatcher, $phpEx; - - $topic_ids = $forum_ids = $draft_rows = array(); - - // Load those drafts not connected to forums/topics - // If forum_id == 0 AND topic_id == 0 then this is a PM draft - if (!$topic_id && !$forum_id) - { - $sql_and = ' AND d.forum_id = 0 AND d.topic_id = 0'; - } - else - { - $sql_and = ''; - $sql_and .= ($forum_id) ? ' AND d.forum_id = ' . (int) $forum_id : ''; - $sql_and .= ($topic_id) ? ' AND d.topic_id = ' . (int) $topic_id : ''; - } - - $sql = 'SELECT d.*, f.forum_id, f.forum_name - FROM ' . DRAFTS_TABLE . ' d - LEFT JOIN ' . FORUMS_TABLE . ' f ON (f.forum_id = d.forum_id) - WHERE d.user_id = ' . $user->data['user_id'] . " - $sql_and - ORDER BY d.save_time DESC"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if ($row['topic_id']) - { - $topic_ids[] = (int) $row['topic_id']; - } - $draft_rows[] = $row; - } - $db->sql_freeresult($result); - - if (!count($draft_rows)) - { - return; - } - - $topic_rows = array(); - if (count($topic_ids)) - { - $sql = 'SELECT topic_id, forum_id, topic_title, topic_poster - FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', array_unique($topic_ids)); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $topic_rows[$row['topic_id']] = $row; - } - $db->sql_freeresult($result); - } - - /** - * Drafts found and their topics - * Edit $draft_rows in order to add or remove drafts loaded - * - * @event core.load_drafts_draft_list_result - * @var array draft_rows The drafts query result. Includes its forum id and everything about the draft - * @var array topic_ids The list of topics got from the topics table - * @var array topic_rows The topics that draft_rows references - * @since 3.1.0-RC3 - */ - $vars = array('draft_rows', 'topic_ids', 'topic_rows'); - extract($phpbb_dispatcher->trigger_event('core.load_drafts_draft_list_result', compact($vars))); - - unset($topic_ids); - - $template->assign_var('S_SHOW_DRAFTS', true); - - foreach ($draft_rows as $draft) - { - $link_topic = $link_forum = $link_pm = false; - $view_url = $title = ''; - - if (isset($topic_rows[$draft['topic_id']]) - && ( - ($topic_rows[$draft['topic_id']]['forum_id'] && $auth->acl_get('f_read', $topic_rows[$draft['topic_id']]['forum_id'])) - || - (!$topic_rows[$draft['topic_id']]['forum_id'] && $auth->acl_getf_global('f_read')) - )) - { - $topic_forum_id = ($topic_rows[$draft['topic_id']]['forum_id']) ? $topic_rows[$draft['topic_id']]['forum_id'] : $forum_id; - - $link_topic = true; - $view_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $topic_forum_id . '&t=' . $draft['topic_id']); - $title = $topic_rows[$draft['topic_id']]['topic_title']; - - $insert_url = append_sid("{$phpbb_root_path}posting.$phpEx", 'f=' . $topic_forum_id . '&t=' . $draft['topic_id'] . '&mode=reply&d=' . $draft['draft_id']); - } - else if ($draft['forum_id'] && $auth->acl_get('f_read', $draft['forum_id'])) - { - $link_forum = true; - $view_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $draft['forum_id']); - $title = $draft['forum_name']; - - $insert_url = append_sid("{$phpbb_root_path}posting.$phpEx", 'f=' . $draft['forum_id'] . '&mode=post&d=' . $draft['draft_id']); - } - else - { - // Either display as PM draft if forum_id and topic_id are empty or if access to the forums has been denied afterwards... - $link_pm = true; - $insert_url = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=$id&mode=compose&d={$draft['draft_id']}" . (($pm_action) ? "&action=$pm_action" : '') . (($msg_id) ? "&p=$msg_id" : '')); - } - - $template->assign_block_vars('draftrow', array( - 'DRAFT_ID' => $draft['draft_id'], - 'DATE' => $user->format_date($draft['save_time']), - 'DRAFT_SUBJECT' => $draft['draft_subject'], - - 'TITLE' => $title, - 'U_VIEW' => $view_url, - 'U_INSERT' => $insert_url, - - 'S_LINK_PM' => $link_pm, - 'S_LINK_TOPIC' => $link_topic, - 'S_LINK_FORUM' => $link_forum) - ); - } -} - -/** -* Topic Review -*/ -function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id = 0, $show_quote_button = true) -{ - global $user, $auth, $db, $template; - global $config, $phpbb_root_path, $phpEx, $phpbb_container, $phpbb_dispatcher; - - /* @var $phpbb_content_visibility \phpbb\content_visibility */ - $phpbb_content_visibility = $phpbb_container->get('content.visibility'); - $sql_sort = ($mode == 'post_review') ? 'ASC' : 'DESC'; - - // Go ahead and pull all data for this topic - $sql = 'SELECT p.post_id - FROM ' . POSTS_TABLE . ' p' . " - WHERE p.topic_id = $topic_id - AND " . $phpbb_content_visibility->get_visibility_sql('post', $forum_id, 'p.') . ' - ' . (($mode == 'post_review') ? " AND p.post_id > $cur_post_id" : '') . ' - ' . (($mode == 'post_review_edit') ? " AND p.post_id = $cur_post_id" : '') . ' - ORDER BY p.post_time ' . $sql_sort . ', p.post_id ' . $sql_sort; - $result = $db->sql_query_limit($sql, $config['posts_per_page']); - - $post_list = array(); - - while ($row = $db->sql_fetchrow($result)) - { - $post_list[] = $row['post_id']; - } - - $db->sql_freeresult($result); - - if (!count($post_list)) - { - return false; - } - - // Handle 'post_review_edit' like 'post_review' from now on - if ($mode == 'post_review_edit') - { - $mode = 'post_review'; - } - - $sql_ary = array( - 'SELECT' => 'u.username, u.user_id, u.user_colour, p.*, z.friend, z.foe, uu.username as post_delete_username, uu.user_colour as post_delete_user_colour', - - 'FROM' => array( - USERS_TABLE => 'u', - POSTS_TABLE => 'p', - ), - - 'LEFT_JOIN' => array( - array( - 'FROM' => array(ZEBRA_TABLE => 'z'), - 'ON' => 'z.user_id = ' . $user->data['user_id'] . ' AND z.zebra_id = p.poster_id', - ), - array( - 'FROM' => array(USERS_TABLE => 'uu'), - 'ON' => 'uu.user_id = p.post_delete_user', - ), - ), - - 'WHERE' => $db->sql_in_set('p.post_id', $post_list) . ' - AND u.user_id = p.poster_id', - ); - - /** - * Event to modify the SQL query for topic reviews - * - * @event core.topic_review_modify_sql_ary - * @var int topic_id The topic ID that is being reviewed - * @var int forum_id The topic's forum ID - * @var string mode The topic review mode - * @var int cur_post_id Post offset ID - * @var bool show_quote_button Flag indicating if the quote button should be displayed - * @var array post_list Array with the post IDs - * @var array sql_ary Array with the SQL query - * @since 3.2.8-RC1 - */ - $vars = array( - 'topic_id', - 'forum_id', - 'mode', - 'cur_post_id', - 'show_quote_button', - 'post_list', - 'sql_ary', - ); - extract($phpbb_dispatcher->trigger_event('core.topic_review_modify_sql_ary', compact($vars))); - - $sql = $db->sql_build_query('SELECT', $sql_ary); - $result = $db->sql_query($sql); - - $rowset = array(); - $has_attachments = false; - while ($row = $db->sql_fetchrow($result)) - { - $rowset[$row['post_id']] = $row; - - if ($row['post_attachment']) - { - $has_attachments = true; - } - } - $db->sql_freeresult($result); - - // Grab extensions - $attachments = array(); - if ($has_attachments && $auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id)) - { - // Get attachments... - $sql = 'SELECT * - FROM ' . ATTACHMENTS_TABLE . ' - WHERE ' . $db->sql_in_set('post_msg_id', $post_list) . ' - AND in_message = 0 - ORDER BY filetime DESC, post_msg_id ASC'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $attachments[$row['post_msg_id']][] = $row; - } - $db->sql_freeresult($result); - } - - /** - * Event to modify the posts list for topic reviews - * - * @event core.topic_review_modify_post_list - * @var array attachments Array with the post attachments data - * @var int cur_post_id Post offset ID - * @var int forum_id The topic's forum ID - * @var string mode The topic review mode - * @var array post_list Array with the post IDs - * @var array rowset Array with the posts data - * @var bool show_quote_button Flag indicating if the quote button should be displayed - * @var int topic_id The topic ID that is being reviewed - * @since 3.1.9-RC1 - */ - $vars = array( - 'attachments', - 'cur_post_id', - 'forum_id', - 'mode', - 'post_list', - 'rowset', - 'show_quote_button', - 'topic_id', - ); - extract($phpbb_dispatcher->trigger_event('core.topic_review_modify_post_list', compact($vars))); - - for ($i = 0, $end = count($post_list); $i < $end; ++$i) - { - // A non-existing rowset only happens if there was no user present for the entered poster_id - // This could be a broken posts table. - if (!isset($rowset[$post_list[$i]])) - { - continue; - } - - $row = $rowset[$post_list[$i]]; - - $poster_id = $row['user_id']; - $post_subject = $row['post_subject']; - - $decoded_message = false; - - if ($show_quote_button && $auth->acl_get('f_reply', $forum_id)) - { - $decoded_message = censor_text($row['post_text']); - decode_message($decoded_message, $row['bbcode_uid']); - - $decoded_message = bbcode_nl2br($decoded_message); - } - - $parse_flags = ($row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0); - $parse_flags |= ($row['enable_smilies'] ? OPTION_FLAG_SMILIES : 0); - $message = generate_text_for_display($row['post_text'], $row['bbcode_uid'], $row['bbcode_bitfield'], $parse_flags, true); - - if (!empty($attachments[$row['post_id']])) - { - $update_count = array(); - parse_attachments($forum_id, $message, $attachments[$row['post_id']], $update_count); - } - - $post_subject = censor_text($post_subject); - - $post_anchor = ($mode == 'post_review') ? 'ppr' . $row['post_id'] : 'pr' . $row['post_id']; - $u_show_post = append_sid($phpbb_root_path . 'viewtopic.' . $phpEx, "f=$forum_id&t=$topic_id&p={$row['post_id']}&view=show#p{$row['post_id']}"); - - $l_deleted_message = ''; - if ($row['post_visibility'] == ITEM_DELETED) - { - $display_postername = get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']); - - // User having deleted the post also being the post author? - if (!$row['post_delete_user'] || $row['post_delete_user'] == $poster_id) - { - $display_username = $display_postername; - } - else - { - $display_username = get_username_string('full', $row['post_delete_user'], $row['post_delete_username'], $row['post_delete_user_colour']); - } - - if ($row['post_delete_reason']) - { - $l_deleted_message = $user->lang('POST_DELETED_BY_REASON', $display_postername, $display_username, $user->format_date($row['post_delete_time'], false, true), $row['post_delete_reason']); - } - else - { - $l_deleted_message = $user->lang('POST_DELETED_BY', $display_postername, $display_username, $user->format_date($row['post_delete_time'], false, true)); - } - } - - $post_row = array( - 'POST_AUTHOR_FULL' => get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), - 'POST_AUTHOR_COLOUR' => get_username_string('colour', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), - 'POST_AUTHOR' => get_username_string('username', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), - 'U_POST_AUTHOR' => get_username_string('profile', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), - - 'S_HAS_ATTACHMENTS' => (!empty($attachments[$row['post_id']])) ? true : false, - 'S_FRIEND' => ($row['friend']) ? true : false, - 'S_IGNORE_POST' => ($row['foe']) ? true : false, - 'L_IGNORE_POST' => ($row['foe']) ? sprintf($user->lang['POST_BY_FOE'], get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), "", '') : '', - 'S_POST_DELETED' => ($row['post_visibility'] == ITEM_DELETED) ? true : false, - 'L_DELETE_POST' => $l_deleted_message, - - 'POST_SUBJECT' => $post_subject, - 'MINI_POST_IMG' => $user->img('icon_post_target', $user->lang['POST']), - 'POST_DATE' => $user->format_date($row['post_time']), - 'MESSAGE' => $message, - 'DECODED_MESSAGE' => $decoded_message, - 'POST_ID' => $row['post_id'], - 'POST_TIME' => $row['post_time'], - 'USER_ID' => $row['user_id'], - 'U_MINI_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $row['post_id']) . '#p' . $row['post_id'], - 'U_MCP_DETAILS' => ($auth->acl_get('m_info', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=post_details&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '', - 'POSTER_QUOTE' => ($show_quote_button && $auth->acl_get('f_reply', $forum_id)) ? addslashes(get_username_string('username', $poster_id, $row['username'], $row['user_colour'], $row['post_username'])) : '', - ); - - $current_row_number = $i; - - /** - * Event to modify the template data block for topic reviews - * - * @event core.topic_review_modify_row - * @var string mode The review mode - * @var int topic_id The topic that is being reviewed - * @var int forum_id The topic's forum - * @var int cur_post_id Post offset id - * @var int current_row_number Number of the current row being iterated - * @var array post_row Template block array of the current post - * @var array row Array with original post and user data - * @since 3.1.4-RC1 - */ - $vars = array( - 'mode', - 'topic_id', - 'forum_id', - 'cur_post_id', - 'current_row_number', - 'post_row', - 'row', - ); - extract($phpbb_dispatcher->trigger_event('core.topic_review_modify_row', compact($vars))); - - $template->assign_block_vars($mode . '_row', $post_row); - - // Display not already displayed Attachments for this post, we already parsed them. ;) - if (!empty($attachments[$row['post_id']])) - { - foreach ($attachments[$row['post_id']] as $attachment) - { - $template->assign_block_vars($mode . '_row.attachment', array( - 'DISPLAY_ATTACHMENT' => $attachment) - ); - } - } - - unset($rowset[$post_list[$i]]); - } - - if ($mode == 'topic_review') - { - $template->assign_var('QUOTE_IMG', $user->img('icon_post_quote', $user->lang['REPLY_WITH_QUOTE'])); - } - - return true; -} - -// -// Post handling functions -// - -/** -* Delete Post -*/ -function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false, $softdelete_reason = '') -{ - global $db, $user, $phpbb_container, $phpbb_dispatcher; - global $config, $phpEx, $phpbb_root_path; - - // Specify our post mode - $post_mode = 'delete'; - if (($data['topic_first_post_id'] === $data['topic_last_post_id']) && ($data['topic_posts_approved'] + $data['topic_posts_unapproved'] + $data['topic_posts_softdeleted'] == 1)) - { - $post_mode = 'delete_topic'; - } - else if ($data['topic_first_post_id'] == $post_id) - { - $post_mode = 'delete_first_post'; - } - else if ($data['topic_last_post_id'] == $post_id) - { - $post_mode = 'delete_last_post'; - } - $sql_data = array(); - $next_post_id = false; - - include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx); - - $db->sql_transaction('begin'); - - // we must make sure to update forums that contain the shadow'd topic - if ($post_mode == 'delete_topic') - { - $shadow_forum_ids = array(); - - $sql = 'SELECT forum_id - FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_moved_id', $topic_id); - $result = $db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) - { - if (!isset($shadow_forum_ids[(int) $row['forum_id']])) - { - $shadow_forum_ids[(int) $row['forum_id']] = 1; - } - else - { - $shadow_forum_ids[(int) $row['forum_id']]++; - } - } - $db->sql_freeresult($result); - } - - /* @var $phpbb_content_visibility \phpbb\content_visibility */ - $phpbb_content_visibility = $phpbb_container->get('content.visibility'); - - // (Soft) delete the post - if ($is_soft && ($post_mode != 'delete_topic')) - { - $phpbb_content_visibility->set_post_visibility(ITEM_DELETED, $post_id, $topic_id, $forum_id, $user->data['user_id'], time(), $softdelete_reason, ($data['topic_first_post_id'] == $post_id), ($data['topic_last_post_id'] == $post_id)); - } - else if (!$is_soft) - { - if (!delete_posts('post_id', array($post_id), false, false, false)) - { - // Try to delete topic, we may had an previous error causing inconsistency - if ($post_mode == 'delete_topic') - { - delete_topics('topic_id', array($topic_id), false); - } - trigger_error('ALREADY_DELETED'); - } - } - - $db->sql_transaction('commit'); - - // Collect the necessary information for updating the tables - $sql_data[FORUMS_TABLE] = $sql_data[TOPICS_TABLE] = ''; - switch ($post_mode) - { - case 'delete_topic': - - foreach ($shadow_forum_ids as $updated_forum => $topic_count) - { - // counting is fun! we only have to do count($forum_ids) number of queries, - // even if the topic is moved back to where its shadow lives (we count how many times it is in a forum) - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET forum_topics_approved = forum_topics_approved - ' . $topic_count . ' - WHERE forum_id = ' . $updated_forum; - $db->sql_query($sql); - update_post_information('forum', $updated_forum); - } - - if ($is_soft) - { - $phpbb_content_visibility->set_topic_visibility(ITEM_DELETED, $topic_id, $forum_id, $user->data['user_id'], time(), $softdelete_reason); - } - else - { - delete_topics('topic_id', array($topic_id), false); - - $phpbb_content_visibility->remove_topic_from_statistic($data, $sql_data); - $config->increment('num_posts', -1, false); - - $update_sql = update_post_information('forum', $forum_id, true); - if (count($update_sql)) - { - $sql_data[FORUMS_TABLE] .= ($sql_data[FORUMS_TABLE]) ? ', ' : ''; - $sql_data[FORUMS_TABLE] .= implode(', ', $update_sql[$forum_id]); - } - } - - break; - - case 'delete_first_post': - $sql = 'SELECT p.post_id, p.poster_id, p.post_time, p.post_username, u.username, u.user_colour - FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . " u - WHERE p.topic_id = $topic_id - AND p.poster_id = u.user_id - AND p.post_visibility = " . ITEM_APPROVED . ' - ORDER BY p.post_time ASC, p.post_id ASC'; - $result = $db->sql_query_limit($sql, 1); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - // No approved post, so the first is a not-approved post (unapproved or soft deleted) - $sql = 'SELECT p.post_id, p.poster_id, p.post_time, p.post_username, u.username, u.user_colour - FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . " u - WHERE p.topic_id = $topic_id - AND p.poster_id = u.user_id - ORDER BY p.post_time ASC, p.post_id ASC"; - $result = $db->sql_query_limit($sql, 1); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - } - - $next_post_id = (int) $row['post_id']; - - $sql_data[TOPICS_TABLE] = $db->sql_build_array('UPDATE', array( - 'topic_poster' => (int) $row['poster_id'], - 'topic_first_post_id' => (int) $row['post_id'], - 'topic_first_poster_colour' => $row['user_colour'], - 'topic_first_poster_name' => ($row['poster_id'] == ANONYMOUS) ? $row['post_username'] : $row['username'], - 'topic_time' => (int) $row['post_time'], - )); - break; - - case 'delete_last_post': - if (!$is_soft) - { - // Update last post information when hard deleting. Soft delete already did that by itself. - $update_sql = update_post_information('forum', $forum_id, true); - if (count($update_sql)) - { - $sql_data[FORUMS_TABLE] = (($sql_data[FORUMS_TABLE]) ? $sql_data[FORUMS_TABLE] . ', ' : '') . implode(', ', $update_sql[$forum_id]); - } - - $sql_data[TOPICS_TABLE] = (($sql_data[TOPICS_TABLE]) ? $sql_data[TOPICS_TABLE] . ', ' : '') . 'topic_bumped = 0, topic_bumper = 0'; - - $update_sql = update_post_information('topic', $topic_id, true); - if (!empty($update_sql)) - { - $sql_data[TOPICS_TABLE] .= ', ' . implode(', ', $update_sql[$topic_id]); - $next_post_id = (int) str_replace('topic_last_post_id = ', '', $update_sql[$topic_id][0]); - } - } - - if (!$next_post_id) - { - $sql = 'SELECT MAX(post_id) as last_post_id - FROM ' . POSTS_TABLE . " - WHERE topic_id = $topic_id - AND " . $phpbb_content_visibility->get_visibility_sql('post', $forum_id); - $result = $db->sql_query($sql); - $next_post_id = (int) $db->sql_fetchfield('last_post_id'); - $db->sql_freeresult($result); - } - break; - - case 'delete': - $sql = 'SELECT post_id - FROM ' . POSTS_TABLE . " - WHERE topic_id = $topic_id - AND " . $phpbb_content_visibility->get_visibility_sql('post', $forum_id) . ' - AND post_time > ' . $data['post_time'] . ' - ORDER BY post_time ASC, post_id ASC'; - $result = $db->sql_query_limit($sql, 1); - $next_post_id = (int) $db->sql_fetchfield('post_id'); - $db->sql_freeresult($result); - break; - } - - if (($post_mode == 'delete') || ($post_mode == 'delete_last_post') || ($post_mode == 'delete_first_post')) - { - if (!$is_soft) - { - $phpbb_content_visibility->remove_post_from_statistic($data, $sql_data); - } - - $sql = 'SELECT 1 AS has_attachments - FROM ' . ATTACHMENTS_TABLE . ' - WHERE topic_id = ' . $topic_id; - $result = $db->sql_query_limit($sql, 1); - $has_attachments = (int) $db->sql_fetchfield('has_attachments'); - $db->sql_freeresult($result); - - if (!$has_attachments) - { - $sql_data[TOPICS_TABLE] = (($sql_data[TOPICS_TABLE]) ? $sql_data[TOPICS_TABLE] . ', ' : '') . 'topic_attachment = 0'; - } - } - - $db->sql_transaction('begin'); - - $where_sql = array( - FORUMS_TABLE => "forum_id = $forum_id", - TOPICS_TABLE => "topic_id = $topic_id", - USERS_TABLE => 'user_id = ' . $data['poster_id'], - ); - - foreach ($sql_data as $table => $update_sql) - { - if ($update_sql) - { - $db->sql_query("UPDATE $table SET $update_sql WHERE " . $where_sql[$table]); - } - } - - // Adjust posted info for this user by looking for a post by him/her within this topic... - if ($post_mode != 'delete_topic' && $config['load_db_track'] && $data['poster_id'] != ANONYMOUS) - { - $sql = 'SELECT poster_id - FROM ' . POSTS_TABLE . ' - WHERE topic_id = ' . $topic_id . ' - AND poster_id = ' . $data['poster_id']; - $result = $db->sql_query_limit($sql, 1); - $poster_id = (int) $db->sql_fetchfield('poster_id'); - $db->sql_freeresult($result); - - // The user is not having any more posts within this topic - if (!$poster_id) - { - $sql = 'DELETE FROM ' . TOPICS_POSTED_TABLE . ' - WHERE topic_id = ' . $topic_id . ' - AND user_id = ' . $data['poster_id']; - $db->sql_query($sql); - } - } - - $db->sql_transaction('commit'); - - if ($data['post_reported'] && ($post_mode != 'delete_topic')) - { - sync('topic_reported', 'topic_id', array($topic_id)); - } - - /** - * This event is used for performing actions directly after a post or topic - * has been deleted. - * - * @event core.delete_post_after - * @var int forum_id Post forum ID - * @var int topic_id Post topic ID - * @var int post_id Post ID - * @var array data Post data - * @var bool is_soft Soft delete flag - * @var string softdelete_reason Soft delete reason - * @var string post_mode delete_topic, delete_first_post, delete_last_post or delete - * @var mixed next_post_id Next post ID in the topic (post ID or false) - * - * @since 3.1.11-RC1 - */ - $vars = array( - 'forum_id', - 'topic_id', - 'post_id', - 'data', - 'is_soft', - 'softdelete_reason', - 'post_mode', - 'next_post_id', - ); - extract($phpbb_dispatcher->trigger_event('core.delete_post_after', compact($vars))); - - return $next_post_id; -} - -/** -* Submit Post -* @todo Split up and create lightweight, simple API for this. -*/ -function submit_post($mode, $subject, $username, $topic_type, &$poll_ary, &$data_ary, $update_message = true, $update_search_index = true) -{ - global $db, $auth, $user, $config, $phpEx, $phpbb_root_path, $phpbb_container, $phpbb_dispatcher, $phpbb_log, $request; - - $poll = $poll_ary; - $data = $data_ary; - /** - * Modify the data for post submitting - * - * @event core.modify_submit_post_data - * @var string mode Variable containing posting mode value - * @var string subject Variable containing post subject value - * @var string username Variable containing post author name - * @var int topic_type Variable containing topic type value - * @var array poll Array with the poll data for the post - * @var array data Array with the data for the post - * @var bool update_message Flag indicating if the post will be updated - * @var bool update_search_index Flag indicating if the search index will be updated - * @since 3.1.0-a4 - */ - $vars = array( - 'mode', - 'subject', - 'username', - 'topic_type', - 'poll', - 'data', - 'update_message', - 'update_search_index', - ); - extract($phpbb_dispatcher->trigger_event('core.modify_submit_post_data', compact($vars))); - $poll_ary = $poll; - $data_ary = $data; - unset($poll); - unset($data); - - // We do not handle erasing posts here - if ($mode == 'delete') - { - return false; - } - - if (!empty($data_ary['post_time'])) - { - $current_time = $data_ary['post_time']; - } - else - { - $current_time = time(); - } - - if ($mode == 'post') - { - $post_mode = 'post'; - $update_message = true; - } - else if ($mode != 'edit') - { - $post_mode = 'reply'; - $update_message = true; - } - else if ($mode == 'edit') - { - $post_mode = ($data_ary['topic_posts_approved'] + $data_ary['topic_posts_unapproved'] + $data_ary['topic_posts_softdeleted'] == 1) ? 'edit_topic' : (($data_ary['topic_first_post_id'] == $data_ary['post_id']) ? 'edit_first_post' : (($data_ary['topic_last_post_id'] == $data_ary['post_id']) ? 'edit_last_post' : 'edit')); - } - - // First of all make sure the subject and topic title are having the correct length. - // To achieve this without cutting off between special chars we convert to an array and then count the elements. - $subject = truncate_string($subject, 120); - $data_ary['topic_title'] = truncate_string($data_ary['topic_title'], 120); - - // Collect some basic information about which tables and which rows to update/insert - $sql_data = $topic_row = array(); - $poster_id = ($mode == 'edit') ? $data_ary['poster_id'] : (int) $user->data['user_id']; - - // Retrieve some additional information if not present - if ($mode == 'edit' && (!isset($data_ary['post_visibility']) || !isset($data_ary['topic_visibility']) || $data_ary['post_visibility'] === false || $data_ary['topic_visibility'] === false)) - { - $sql = 'SELECT p.post_visibility, t.topic_type, t.topic_posts_approved, t.topic_posts_unapproved, t.topic_posts_softdeleted, t.topic_visibility - FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p - WHERE t.topic_id = p.topic_id - AND p.post_id = ' . $data_ary['post_id']; - $result = $db->sql_query($sql); - $topic_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $data_ary['topic_visibility'] = $topic_row['topic_visibility']; - $data_ary['post_visibility'] = $topic_row['post_visibility']; - } - - // This variable indicates if the user is able to post or put into the queue - $post_visibility = ITEM_APPROVED; - - // Check the permissions for post approval. - // Moderators must go through post approval like ordinary users. - if (!$auth->acl_get('f_noapprove', $data_ary['forum_id'])) - { - // Post not approved, but in queue - $post_visibility = ITEM_UNAPPROVED; - switch ($post_mode) - { - case 'edit_first_post': - case 'edit': - case 'edit_last_post': - case 'edit_topic': - $post_visibility = ITEM_REAPPROVE; - break; - } - } - else if (isset($data_ary['post_visibility']) && $data_ary['post_visibility'] !== false) - { - $post_visibility = $data_ary['post_visibility']; - } - - // MODs/Extensions are able to force any visibility on posts - if (isset($data_ary['force_approved_state'])) - { - $post_visibility = (in_array((int) $data_ary['force_approved_state'], array(ITEM_APPROVED, ITEM_UNAPPROVED, ITEM_DELETED, ITEM_REAPPROVE))) ? (int) $data_ary['force_approved_state'] : $post_visibility; - } - if (isset($data_ary['force_visibility'])) - { - $post_visibility = (in_array((int) $data_ary['force_visibility'], array(ITEM_APPROVED, ITEM_UNAPPROVED, ITEM_DELETED, ITEM_REAPPROVE))) ? (int) $data_ary['force_visibility'] : $post_visibility; - } - - // Start the transaction here - $db->sql_transaction('begin'); - - // Collect Information - switch ($post_mode) - { - case 'post': - case 'reply': - $sql_data[POSTS_TABLE]['sql'] = array( - 'forum_id' => $data_ary['forum_id'], - 'poster_id' => (int) $user->data['user_id'], - 'icon_id' => $data_ary['icon_id'], - 'poster_ip' => $user->ip, - 'post_time' => $current_time, - 'post_visibility' => $post_visibility, - 'enable_bbcode' => $data_ary['enable_bbcode'], - 'enable_smilies' => $data_ary['enable_smilies'], - 'enable_magic_url' => $data_ary['enable_urls'], - 'enable_sig' => $data_ary['enable_sig'], - 'post_username' => (!$user->data['is_registered']) ? $username : '', - 'post_subject' => $subject, - 'post_text' => $data_ary['message'], - 'post_checksum' => $data_ary['message_md5'], - 'post_attachment' => (!empty($data_ary['attachment_data'])) ? 1 : 0, - 'bbcode_bitfield' => $data_ary['bbcode_bitfield'], - 'bbcode_uid' => $data_ary['bbcode_uid'], - 'post_postcount' => ($auth->acl_get('f_postcount', $data_ary['forum_id'])) ? 1 : 0, - 'post_edit_locked' => $data_ary['post_edit_locked'] - ); - break; - - case 'edit_first_post': - case 'edit': - - case 'edit_last_post': - case 'edit_topic': - - // If edit reason is given always display edit info - - // If editing last post then display no edit info - // If m_edit permission then display no edit info - // If normal edit display edit info - - // Display edit info if edit reason given or user is editing his post, which is not the last within the topic. - if ($data_ary['post_edit_reason'] || (!$auth->acl_get('m_edit', $data_ary['forum_id']) && ($post_mode == 'edit' || $post_mode == 'edit_first_post'))) - { - $data_ary['post_edit_reason'] = truncate_string($data_ary['post_edit_reason'], 255, 255, false); - - $sql_data[POSTS_TABLE]['sql'] = array( - 'post_edit_time' => $current_time, - 'post_edit_reason' => $data_ary['post_edit_reason'], - 'post_edit_user' => (int) $data_ary['post_edit_user'], - ); - - $sql_data[POSTS_TABLE]['stat'][] = 'post_edit_count = post_edit_count + 1'; - } - else if (!$data_ary['post_edit_reason'] && $mode == 'edit' && $auth->acl_get('m_edit', $data_ary['forum_id'])) - { - $sql_data[POSTS_TABLE]['sql'] = array( - 'post_edit_reason' => '', - ); - } - - // If the person editing this post is different to the one having posted then we will add a log entry stating the edit - // Could be simplified by only adding to the log if the edit is not tracked - but this may confuse admins/mods - if ($user->data['user_id'] != $poster_id) - { - $log_subject = ($subject) ? $subject : $data_ary['topic_title']; - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_POST_EDITED', false, array( - 'forum_id' => $data_ary['forum_id'], - 'topic_id' => $data_ary['topic_id'], - 'post_id' => $data_ary['post_id'], - $log_subject, - (!empty($username)) ? $username : $user->lang['GUEST'], - $data_ary['post_edit_reason'] - )); - } - - if (!isset($sql_data[POSTS_TABLE]['sql'])) - { - $sql_data[POSTS_TABLE]['sql'] = array(); - } - - $sql_data[POSTS_TABLE]['sql'] = array_merge($sql_data[POSTS_TABLE]['sql'], array( - 'forum_id' => $data_ary['forum_id'], - 'poster_id' => $data_ary['poster_id'], - 'icon_id' => $data_ary['icon_id'], - // We will change the visibility later - //'post_visibility' => $post_visibility, - 'enable_bbcode' => $data_ary['enable_bbcode'], - 'enable_smilies' => $data_ary['enable_smilies'], - 'enable_magic_url' => $data_ary['enable_urls'], - 'enable_sig' => $data_ary['enable_sig'], - 'post_username' => ($username && $data_ary['poster_id'] == ANONYMOUS) ? $username : '', - 'post_subject' => $subject, - 'post_checksum' => $data_ary['message_md5'], - 'post_attachment' => (!empty($data_ary['attachment_data'])) ? 1 : 0, - 'bbcode_bitfield' => $data_ary['bbcode_bitfield'], - 'bbcode_uid' => $data_ary['bbcode_uid'], - 'post_edit_locked' => $data_ary['post_edit_locked']) - ); - - if ($update_message) - { - $sql_data[POSTS_TABLE]['sql']['post_text'] = $data_ary['message']; - } - - break; - } - - // And the topic ladies and gentlemen - switch ($post_mode) - { - case 'post': - $sql_data[TOPICS_TABLE]['sql'] = array( - 'topic_poster' => (int) $user->data['user_id'], - 'topic_time' => $current_time, - 'topic_last_view_time' => $current_time, - 'forum_id' => $data_ary['forum_id'], - 'icon_id' => $data_ary['icon_id'], - 'topic_posts_approved' => ($post_visibility == ITEM_APPROVED) ? 1 : 0, - 'topic_posts_softdeleted' => ($post_visibility == ITEM_DELETED) ? 1 : 0, - 'topic_posts_unapproved' => ($post_visibility == ITEM_UNAPPROVED) ? 1 : 0, - 'topic_visibility' => $post_visibility, - 'topic_delete_user' => ($post_visibility != ITEM_APPROVED) ? (int) $user->data['user_id'] : 0, - 'topic_title' => $subject, - 'topic_first_poster_name' => (!$user->data['is_registered'] && $username) ? $username : (($user->data['user_id'] != ANONYMOUS) ? $user->data['username'] : ''), - 'topic_first_poster_colour' => $user->data['user_colour'], - 'topic_type' => $topic_type, - 'topic_time_limit' => $topic_type != POST_NORMAL ? ($data_ary['topic_time_limit'] * 86400) : 0, - 'topic_attachment' => (!empty($data_ary['attachment_data'])) ? 1 : 0, - 'topic_status' => (isset($data_ary['topic_status'])) ? $data_ary['topic_status'] : ITEM_UNLOCKED, - ); - - if (isset($poll_ary['poll_options']) && !empty($poll_ary['poll_options'])) - { - $poll_start = ($poll_ary['poll_start']) ? $poll_ary['poll_start'] : $current_time; - $poll_length = $poll_ary['poll_length'] * 86400; - if ($poll_length < 0) - { - $poll_start = $poll_start + $poll_length; - if ($poll_start < 0) - { - $poll_start = 0; - } - $poll_length = 1; - } - - $sql_data[TOPICS_TABLE]['sql'] = array_merge($sql_data[TOPICS_TABLE]['sql'], array( - 'poll_title' => $poll_ary['poll_title'], - 'poll_start' => $poll_start, - 'poll_max_options' => $poll_ary['poll_max_options'], - 'poll_length' => $poll_length, - 'poll_vote_change' => $poll_ary['poll_vote_change']) - ); - } - - $sql_data[USERS_TABLE]['stat'][] = "user_lastpost_time = $current_time" . (($auth->acl_get('f_postcount', $data_ary['forum_id']) && $post_visibility == ITEM_APPROVED) ? ', user_posts = user_posts + 1' : ''); - - if ($post_visibility == ITEM_APPROVED) - { - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_topics_approved = forum_topics_approved + 1'; - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts_approved = forum_posts_approved + 1'; - } - else if ($post_visibility == ITEM_UNAPPROVED) - { - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_topics_unapproved = forum_topics_unapproved + 1'; - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts_unapproved = forum_posts_unapproved + 1'; - } - else if ($post_visibility == ITEM_DELETED) - { - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_topics_softdeleted = forum_topics_softdeleted + 1'; - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts_softdeleted = forum_posts_softdeleted + 1'; - } - break; - - case 'reply': - $sql_data[TOPICS_TABLE]['stat'][] = 'topic_last_view_time = ' . $current_time . ', - topic_bumped = 0, - topic_bumper = 0' . - (($post_visibility == ITEM_APPROVED) ? ', topic_posts_approved = topic_posts_approved + 1' : '') . - (($post_visibility == ITEM_UNAPPROVED) ? ', topic_posts_unapproved = topic_posts_unapproved + 1' : '') . - (($post_visibility == ITEM_DELETED) ? ', topic_posts_softdeleted = topic_posts_softdeleted + 1' : '') . - ((!empty($data_ary['attachment_data']) || (isset($data_ary['topic_attachment']) && $data_ary['topic_attachment'])) ? ', topic_attachment = 1' : ''); - - $sql_data[USERS_TABLE]['stat'][] = "user_lastpost_time = $current_time" . (($auth->acl_get('f_postcount', $data_ary['forum_id']) && $post_visibility == ITEM_APPROVED) ? ', user_posts = user_posts + 1' : ''); - - if ($post_visibility == ITEM_APPROVED) - { - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts_approved = forum_posts_approved + 1'; - } - else if ($post_visibility == ITEM_UNAPPROVED) - { - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts_unapproved = forum_posts_unapproved + 1'; - } - else if ($post_visibility == ITEM_DELETED) - { - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts_softdeleted = forum_posts_softdeleted + 1'; - } - break; - - case 'edit_topic': - case 'edit_first_post': - if (isset($poll_ary['poll_options'])) - { - $poll_start = ($poll_ary['poll_start'] || empty($poll_ary['poll_options'])) ? $poll_ary['poll_start'] : $current_time; - $poll_length = $poll_ary['poll_length'] * 86400; - if ($poll_length < 0) - { - $poll_start = $poll_start + $poll_length; - if ($poll_start < 0) - { - $poll_start = 0; - } - $poll_length = 1; - } - } - - $sql_data[TOPICS_TABLE]['sql'] = array( - 'forum_id' => $data_ary['forum_id'], - 'icon_id' => $data_ary['icon_id'], - 'topic_title' => $subject, - 'topic_first_poster_name' => $username, - 'topic_type' => $topic_type, - 'topic_time_limit' => $topic_type != POST_NORMAL ? ($data_ary['topic_time_limit'] * 86400) : 0, - 'poll_title' => (isset($poll_ary['poll_options'])) ? $poll_ary['poll_title'] : '', - 'poll_start' => (isset($poll_ary['poll_options'])) ? $poll_start : 0, - 'poll_max_options' => (isset($poll_ary['poll_options'])) ? $poll_ary['poll_max_options'] : 1, - 'poll_length' => (isset($poll_ary['poll_options'])) ? $poll_length : 0, - 'poll_vote_change' => (isset($poll_ary['poll_vote_change'])) ? $poll_ary['poll_vote_change'] : 0, - 'topic_last_view_time' => $current_time, - - 'topic_attachment' => (!empty($data_ary['attachment_data'])) ? 1 : (isset($data_ary['topic_attachment']) ? $data_ary['topic_attachment'] : 0), - ); - - break; - } - - $poll = $poll_ary; - $data = $data_ary; - /** - * Modify sql query data for post submitting - * - * @event core.submit_post_modify_sql_data - * @var array data Array with the data for the post - * @var array poll Array with the poll data for the post - * @var string post_mode Variable containing posting mode value - * @var bool sql_data Array with the data for the posting SQL query - * @var string subject Variable containing post subject value - * @var int topic_type Variable containing topic type value - * @var string username Variable containing post author name - * @since 3.1.3-RC1 - */ - $vars = array( - 'data', - 'poll', - 'post_mode', - 'sql_data', - 'subject', - 'topic_type', - 'username', - ); - extract($phpbb_dispatcher->trigger_event('core.submit_post_modify_sql_data', compact($vars))); - $poll_ary = $poll; - $data_ary = $data; - unset($poll); - unset($data); - - // Submit new topic - if ($post_mode == 'post') - { - $sql = 'INSERT INTO ' . TOPICS_TABLE . ' ' . - $db->sql_build_array('INSERT', $sql_data[TOPICS_TABLE]['sql']); - $db->sql_query($sql); - - $data_ary['topic_id'] = $db->sql_nextid(); - - $sql_data[POSTS_TABLE]['sql'] = array_merge($sql_data[POSTS_TABLE]['sql'], array( - 'topic_id' => $data_ary['topic_id']) - ); - unset($sql_data[TOPICS_TABLE]['sql']); - } - - // Submit new post - if ($post_mode == 'post' || $post_mode == 'reply') - { - if ($post_mode == 'reply') - { - $sql_data[POSTS_TABLE]['sql'] = array_merge($sql_data[POSTS_TABLE]['sql'], array( - 'topic_id' => $data_ary['topic_id'], - )); - } - - $sql = 'INSERT INTO ' . POSTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_data[POSTS_TABLE]['sql']); - $db->sql_query($sql); - $data_ary['post_id'] = $db->sql_nextid(); - - if ($post_mode == 'post' || $post_visibility == ITEM_APPROVED) - { - $sql_data[TOPICS_TABLE]['sql'] = array( - 'topic_last_post_id' => $data_ary['post_id'], - 'topic_last_post_time' => $current_time, - 'topic_last_poster_id' => $sql_data[POSTS_TABLE]['sql']['poster_id'], - 'topic_last_poster_name' => ($user->data['user_id'] == ANONYMOUS) ? $sql_data[POSTS_TABLE]['sql']['post_username'] : $user->data['username'], - 'topic_last_poster_colour' => $user->data['user_colour'], - 'topic_last_post_subject' => (string) $subject, - ); - } - - if ($post_mode == 'post') - { - $sql_data[TOPICS_TABLE]['sql']['topic_first_post_id'] = $data_ary['post_id']; - } - - // Update total post count and forum information - if ($post_visibility == ITEM_APPROVED) - { - if ($post_mode == 'post') - { - $config->increment('num_topics', 1, false); - } - $config->increment('num_posts', 1, false); - - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_id = ' . $data_ary['post_id']; - $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_post_subject = '" . $db->sql_escape($subject) . "'"; - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_time = ' . $current_time; - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_id = ' . (int) $user->data['user_id']; - $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_name = '" . $db->sql_escape((!$user->data['is_registered'] && $username) ? $username : (($user->data['user_id'] != ANONYMOUS) ? $user->data['username'] : '')) . "'"; - $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_colour = '" . $db->sql_escape($user->data['user_colour']) . "'"; - } - - unset($sql_data[POSTS_TABLE]['sql']); - } - - // Update the topics table - if (isset($sql_data[TOPICS_TABLE]['sql'])) - { - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_data[TOPICS_TABLE]['sql']) . ' - WHERE topic_id = ' . $data_ary['topic_id']; - $db->sql_query($sql); - - unset($sql_data[TOPICS_TABLE]['sql']); - } - - // Update the posts table - if (isset($sql_data[POSTS_TABLE]['sql'])) - { - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_data[POSTS_TABLE]['sql']) . ' - WHERE post_id = ' . $data_ary['post_id']; - $db->sql_query($sql); - - unset($sql_data[POSTS_TABLE]['sql']); - } - - // Update Poll Tables - if (isset($poll_ary['poll_options'])) - { - $cur_poll_options = array(); - - if ($mode == 'edit') - { - $sql = 'SELECT * - FROM ' . POLL_OPTIONS_TABLE . ' - WHERE topic_id = ' . $data_ary['topic_id'] . ' - ORDER BY poll_option_id'; - $result = $db->sql_query($sql); - - $cur_poll_options = array(); - while ($row = $db->sql_fetchrow($result)) - { - $cur_poll_options[] = $row; - } - $db->sql_freeresult($result); - } - - $sql_insert_ary = array(); - - for ($i = 0, $size = count($poll_ary['poll_options']); $i < $size; $i++) - { - if (strlen(trim($poll_ary['poll_options'][$i]))) - { - if (empty($cur_poll_options[$i])) - { - // If we add options we need to put them to the end to be able to preserve votes... - $sql_insert_ary[] = array( - 'poll_option_id' => (int) count($cur_poll_options) + 1 + count($sql_insert_ary), - 'topic_id' => (int) $data_ary['topic_id'], - 'poll_option_text' => (string) $poll_ary['poll_options'][$i] - ); - } - else if ($poll_ary['poll_options'][$i] != $cur_poll_options[$i]) - { - $sql = 'UPDATE ' . POLL_OPTIONS_TABLE . " - SET poll_option_text = '" . $db->sql_escape($poll_ary['poll_options'][$i]) . "' - WHERE poll_option_id = " . $cur_poll_options[$i]['poll_option_id'] . ' - AND topic_id = ' . $data_ary['topic_id']; - $db->sql_query($sql); - } - } - } - - $db->sql_multi_insert(POLL_OPTIONS_TABLE, $sql_insert_ary); - - if (count($poll_ary['poll_options']) < count($cur_poll_options)) - { - $sql = 'DELETE FROM ' . POLL_OPTIONS_TABLE . ' - WHERE poll_option_id > ' . count($poll_ary['poll_options']) . ' - AND topic_id = ' . $data_ary['topic_id']; - $db->sql_query($sql); - } - - // If edited, we would need to reset votes (since options can be re-ordered above, you can't be sure if the change is for changing the text or adding an option - if ($mode == 'edit' && count($poll_ary['poll_options']) != count($cur_poll_options)) - { - $db->sql_query('DELETE FROM ' . POLL_VOTES_TABLE . ' WHERE topic_id = ' . $data_ary['topic_id']); - $db->sql_query('UPDATE ' . POLL_OPTIONS_TABLE . ' SET poll_option_total = 0 WHERE topic_id = ' . $data_ary['topic_id']); - } - } - - // Submit Attachments - if (!empty($data_ary['attachment_data']) && $data_ary['post_id'] && in_array($mode, array('post', 'reply', 'quote', 'edit'))) - { - $space_taken = $files_added = 0; - $orphan_rows = array(); - - foreach ($data_ary['attachment_data'] as $pos => $attach_row) - { - $orphan_rows[(int) $attach_row['attach_id']] = array(); - } - - if (count($orphan_rows)) - { - $sql = 'SELECT attach_id, filesize, physical_filename - FROM ' . ATTACHMENTS_TABLE . ' - WHERE ' . $db->sql_in_set('attach_id', array_keys($orphan_rows)) . ' - AND is_orphan = 1 - AND poster_id = ' . $user->data['user_id']; - $result = $db->sql_query($sql); - - $orphan_rows = array(); - while ($row = $db->sql_fetchrow($result)) - { - $orphan_rows[$row['attach_id']] = $row; - } - $db->sql_freeresult($result); - } - - foreach ($data_ary['attachment_data'] as $pos => $attach_row) - { - if ($attach_row['is_orphan'] && !isset($orphan_rows[$attach_row['attach_id']])) - { - continue; - } - - if (preg_match('/[\x{10000}-\x{10FFFF}]/u', $attach_row['attach_comment'])) - { - trigger_error('ATTACH_COMMENT_NO_EMOJIS'); - } - - if (!$attach_row['is_orphan']) - { - // update entry in db if attachment already stored in db and filespace - $sql = 'UPDATE ' . ATTACHMENTS_TABLE . " - SET attach_comment = '" . $db->sql_escape($attach_row['attach_comment']) . "' - WHERE attach_id = " . (int) $attach_row['attach_id'] . ' - AND is_orphan = 0'; - $db->sql_query($sql); - } - else - { - // insert attachment into db - if (!@file_exists($phpbb_root_path . $config['upload_path'] . '/' . utf8_basename($orphan_rows[$attach_row['attach_id']]['physical_filename']))) - { - continue; - } - - $space_taken += $orphan_rows[$attach_row['attach_id']]['filesize']; - $files_added++; - - $attach_sql = array( - 'post_msg_id' => $data_ary['post_id'], - 'topic_id' => $data_ary['topic_id'], - 'is_orphan' => 0, - 'poster_id' => $poster_id, - 'attach_comment' => $attach_row['attach_comment'], - ); - - $sql = 'UPDATE ' . ATTACHMENTS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $attach_sql) . ' - WHERE attach_id = ' . $attach_row['attach_id'] . ' - AND is_orphan = 1 - AND poster_id = ' . $user->data['user_id']; - $db->sql_query($sql); - } - } - - if ($space_taken && $files_added) - { - $config->increment('upload_dir_size', $space_taken, false); - $config->increment('num_files', $files_added, false); - } - } - - $first_post_has_topic_info = ($post_mode == 'edit_first_post' && - (($post_visibility == ITEM_DELETED && $data_ary['topic_posts_softdeleted'] == 1) || - ($post_visibility == ITEM_UNAPPROVED && $data_ary['topic_posts_unapproved'] == 1) || - ($post_visibility == ITEM_REAPPROVE && $data_ary['topic_posts_unapproved'] == 1) || - ($post_visibility == ITEM_APPROVED && $data_ary['topic_posts_approved'] == 1))); - // Fix the post's and topic's visibility and first/last post information, when the post is edited - if (($post_mode != 'post' && $post_mode != 'reply') && $data_ary['post_visibility'] != $post_visibility) - { - // If the post was not approved, it could also be the starter, - // so we sync the starter after approving/restoring, to ensure that the stats are correct - // Same applies for the last post - $is_starter = ($post_mode == 'edit_first_post' || $post_mode == 'edit_topic' || $data_ary['post_visibility'] != ITEM_APPROVED); - $is_latest = ($post_mode == 'edit_last_post' || $post_mode == 'edit_topic' || $data_ary['post_visibility'] != ITEM_APPROVED); - - /* @var $phpbb_content_visibility \phpbb\content_visibility */ - $phpbb_content_visibility = $phpbb_container->get('content.visibility'); - $phpbb_content_visibility->set_post_visibility($post_visibility, $data_ary['post_id'], $data_ary['topic_id'], $data_ary['forum_id'], $user->data['user_id'], time(), '', $is_starter, $is_latest); - } - else if ($post_mode == 'edit_last_post' || $post_mode == 'edit_topic' || $first_post_has_topic_info) - { - if ($post_visibility == ITEM_APPROVED || $data_ary['topic_visibility'] == $post_visibility) - { - // only the subject can be changed from edit - $sql_data[TOPICS_TABLE]['stat'][] = "topic_last_post_subject = '" . $db->sql_escape($subject) . "'"; - - // Maybe not only the subject, but also changing anonymous usernames. ;) - if ($data_ary['poster_id'] == ANONYMOUS) - { - $sql_data[TOPICS_TABLE]['stat'][] = "topic_last_poster_name = '" . $db->sql_escape($username) . "'"; - } - - if ($post_visibility == ITEM_APPROVED) - { - // this does not _necessarily_ mean that we must update the info again, - // it just means that we might have to - $sql = 'SELECT forum_last_post_id, forum_last_post_subject - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . (int) $data_ary['forum_id']; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - // this post is the latest post in the forum, better update - if ($row['forum_last_post_id'] == $data_ary['post_id'] && ($row['forum_last_post_subject'] !== $subject || $data_ary['poster_id'] == ANONYMOUS)) - { - // the post's subject changed - if ($row['forum_last_post_subject'] !== $subject) - { - $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_post_subject = '" . $db->sql_escape($subject) . "'"; - } - - // Update the user name if poster is anonymous... just in case a moderator changed it - if ($data_ary['poster_id'] == ANONYMOUS) - { - $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_name = '" . $db->sql_escape($username) . "'"; - } - } - } - } - } - - // Update forum stats - $where_sql = array( - POSTS_TABLE => 'post_id = ' . $data_ary['post_id'], - TOPICS_TABLE => 'topic_id = ' . $data_ary['topic_id'], - FORUMS_TABLE => 'forum_id = ' . $data_ary['forum_id'], - USERS_TABLE => 'user_id = ' . $poster_id - ); - - foreach ($sql_data as $table => $update_ary) - { - if (isset($update_ary['stat']) && implode('', $update_ary['stat'])) - { - $sql = "UPDATE $table SET " . implode(', ', $update_ary['stat']) . ' WHERE ' . $where_sql[$table]; - $db->sql_query($sql); - } - } - - // Delete topic shadows (if any exist). We do not need a shadow topic for an global announcement - if ($topic_type == POST_GLOBAL) - { - $sql = 'DELETE FROM ' . TOPICS_TABLE . ' - WHERE topic_moved_id = ' . $data_ary['topic_id']; - $db->sql_query($sql); - } - - // Committing the transaction before updating search index - $db->sql_transaction('commit'); - - // Delete draft if post was loaded... - $draft_id = $request->variable('draft_loaded', 0); - if ($draft_id) - { - $sql = 'DELETE FROM ' . DRAFTS_TABLE . " - WHERE draft_id = $draft_id - AND user_id = {$user->data['user_id']}"; - $db->sql_query($sql); - } - - // Index message contents - if ($update_search_index && $data_ary['enable_indexing']) - { - // Select the search method and do some additional checks to ensure it can actually be utilised - $search_type = $config['search_type']; - - if (!class_exists($search_type)) - { - trigger_error('NO_SUCH_SEARCH_MODULE'); - } - - $error = false; - $search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher); - - if ($error) - { - trigger_error($error); - } - - $search->index($mode, $data_ary['post_id'], $data_ary['message'], $subject, $poster_id, $data_ary['forum_id']); - } - - // Topic Notification, do not change if moderator is changing other users posts... - if ($user->data['user_id'] == $poster_id) - { - if (!$data_ary['notify_set'] && $data_ary['notify']) - { - $sql = 'INSERT INTO ' . TOPICS_WATCH_TABLE . ' (user_id, topic_id) - VALUES (' . $user->data['user_id'] . ', ' . $data_ary['topic_id'] . ')'; - $db->sql_query($sql); - } - else if (($config['email_enable'] || $config['jab_enable']) && $data_ary['notify_set'] && !$data_ary['notify']) - { - $sql = 'DELETE FROM ' . TOPICS_WATCH_TABLE . ' - WHERE user_id = ' . $user->data['user_id'] . ' - AND topic_id = ' . $data_ary['topic_id']; - $db->sql_query($sql); - } - } - - if ($mode == 'post' || $mode == 'reply' || $mode == 'quote') - { - // Mark this topic as posted to - markread('post', $data_ary['forum_id'], $data_ary['topic_id']); - } - - // Mark this topic as read - // We do not use post_time here, this is intended (post_time can have a date in the past if editing a message) - markread('topic', $data_ary['forum_id'], $data_ary['topic_id'], time()); - - // - if ($config['load_db_lastread'] && $user->data['is_registered']) - { - $sql = 'SELECT mark_time - FROM ' . FORUMS_TRACK_TABLE . ' - WHERE user_id = ' . $user->data['user_id'] . ' - AND forum_id = ' . $data_ary['forum_id']; - $result = $db->sql_query($sql); - $f_mark_time = (int) $db->sql_fetchfield('mark_time'); - $db->sql_freeresult($result); - } - else if ($config['load_anon_lastread'] || $user->data['is_registered']) - { - $f_mark_time = false; - } - - if (($config['load_db_lastread'] && $user->data['is_registered']) || $config['load_anon_lastread'] || $user->data['is_registered']) - { - // Update forum info - $sql = 'SELECT forum_last_post_time - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . $data_ary['forum_id']; - $result = $db->sql_query($sql); - $forum_last_post_time = (int) $db->sql_fetchfield('forum_last_post_time'); - $db->sql_freeresult($result); - - update_forum_tracking_info($data_ary['forum_id'], $forum_last_post_time, $f_mark_time, false); - } - - // If a username was supplied or the poster is a guest, we will use the supplied username. - // Doing it this way we can use "...post by guest-username..." in notifications when - // "guest-username" is supplied or ommit the username if it is not. - $username = ($username !== '' || !$user->data['is_registered']) ? $username : $user->data['username']; - - // Send Notifications - $notification_data = array_merge($data_ary, array( - 'topic_title' => (isset($data_ary['topic_title'])) ? $data_ary['topic_title'] : $subject, - 'post_username' => $username, - 'poster_id' => $poster_id, - 'post_text' => $data_ary['message'], - 'post_time' => $current_time, - 'post_subject' => $subject, - )); - - /** - * This event allows you to modify the notification data upon submission - * - * @event core.modify_submit_notification_data - * @var array notification_data The notification data to be inserted in to the database - * @var array data_ary The data array with a lot of the post submission data - * @var string mode The posting mode - * @var int poster_id The poster id - * @since 3.2.4-RC1 - */ - $vars = array('notification_data', 'data_ary', 'mode', 'poster_id'); - extract($phpbb_dispatcher->trigger_event('core.modify_submit_notification_data', compact($vars))); - - /* @var $phpbb_notifications \phpbb\notification\manager */ - $phpbb_notifications = $phpbb_container->get('notification_manager'); - - if ($post_visibility == ITEM_APPROVED) - { - switch ($mode) - { - case 'post': - $phpbb_notifications->add_notifications(array( - 'notification.type.quote', - 'notification.type.topic', - ), $notification_data); - break; - - case 'reply': - case 'quote': - $phpbb_notifications->add_notifications(array( - 'notification.type.quote', - 'notification.type.bookmark', - 'notification.type.post', - ), $notification_data); - break; - - case 'edit_topic': - case 'edit_first_post': - case 'edit': - case 'edit_last_post': - if ($user->data['user_id'] == $poster_id) - { - $phpbb_notifications->update_notifications(array( - 'notification.type.quote', - ), $notification_data); - } - - $phpbb_notifications->update_notifications(array( - 'notification.type.bookmark', - 'notification.type.topic', - 'notification.type.post', - ), $notification_data); - break; - } - } - else if ($post_visibility == ITEM_UNAPPROVED) - { - switch ($mode) - { - case 'post': - $phpbb_notifications->add_notifications('notification.type.topic_in_queue', $notification_data); - break; - - case 'reply': - case 'quote': - $phpbb_notifications->add_notifications('notification.type.post_in_queue', $notification_data); - break; - - case 'edit_topic': - case 'edit_first_post': - case 'edit': - case 'edit_last_post': - // Nothing to do here - break; - } - } - else if ($post_visibility == ITEM_REAPPROVE) - { - switch ($mode) - { - case 'edit_topic': - case 'edit_first_post': - $phpbb_notifications->add_notifications('notification.type.topic_in_queue', $notification_data); - - // Delete the approve_post notification so we can notify the user again, - // when his post got reapproved - $phpbb_notifications->delete_notifications('notification.type.approve_post', $notification_data['post_id']); - break; - - case 'edit': - case 'edit_last_post': - $phpbb_notifications->add_notifications('notification.type.post_in_queue', $notification_data); - - // Delete the approve_post notification so we can notify the user again, - // when his post got reapproved - $phpbb_notifications->delete_notifications('notification.type.approve_post', $notification_data['post_id']); - break; - - case 'post': - case 'reply': - case 'quote': - // Nothing to do here - break; - } - } - else if ($post_visibility == ITEM_DELETED) - { - switch ($mode) - { - case 'post': - case 'reply': - case 'quote': - case 'edit_topic': - case 'edit_first_post': - case 'edit': - case 'edit_last_post': - // Nothing to do here - break; - } - } - - $params = $add_anchor = ''; - - if ($post_visibility == ITEM_APPROVED || - ($auth->acl_get('m_softdelete', $data_ary['forum_id']) && $post_visibility == ITEM_DELETED) || - ($auth->acl_get('m_approve', $data_ary['forum_id']) && in_array($post_visibility, array(ITEM_UNAPPROVED, ITEM_REAPPROVE)))) - { - $params .= '&t=' . $data_ary['topic_id']; - - if ($mode != 'post') - { - $params .= '&p=' . $data_ary['post_id']; - $add_anchor = '#p' . $data_ary['post_id']; - } - } - else if ($mode != 'post' && $post_mode != 'edit_first_post' && $post_mode != 'edit_topic') - { - $params .= '&t=' . $data_ary['topic_id']; - } - - $url = (!$params) ? "{$phpbb_root_path}viewforum.$phpEx" : "{$phpbb_root_path}viewtopic.$phpEx"; - $url = append_sid($url, 'f=' . $data_ary['forum_id'] . $params) . $add_anchor; - - $poll = $poll_ary; - $data = $data_ary; - /** - * This event is used for performing actions directly after a post or topic - * has been submitted. When a new topic is posted, the topic ID is - * available in the $data array. - * - * The only action that can be done by altering data made available to this - * event is to modify the return URL ($url). - * - * @event core.submit_post_end - * @var string mode Variable containing posting mode value - * @var string subject Variable containing post subject value - * @var string username Variable containing post author name - * @var int topic_type Variable containing topic type value - * @var array poll Array with the poll data for the post - * @var array data Array with the data for the post - * @var int post_visibility Variable containing up to date post visibility - * @var bool update_message Flag indicating if the post will be updated - * @var bool update_search_index Flag indicating if the search index will be updated - * @var string url The "Return to topic" URL - * - * @since 3.1.0-a3 - * @changed 3.1.0-RC3 Added vars mode, subject, username, topic_type, - * poll, update_message, update_search_index - */ - $vars = array( - 'mode', - 'subject', - 'username', - 'topic_type', - 'poll', - 'data', - 'post_visibility', - 'update_message', - 'update_search_index', - 'url', - ); - extract($phpbb_dispatcher->trigger_event('core.submit_post_end', compact($vars))); - $data_ary = $data; - $poll_ary = $poll; - unset($data); - unset($poll); - - return $url; -} - -/** -* Handle topic bumping -* @param int $forum_id The ID of the forum the topic is being bumped belongs to -* @param int $topic_id The ID of the topic is being bumping -* @param array $post_data Passes some topic parameters: -* - 'topic_title' -* - 'topic_last_post_id' -* - 'topic_last_poster_id' -* - 'topic_last_post_subject' -* - 'topic_last_poster_name' -* - 'topic_last_poster_colour' -* @param int $bump_time The time at which topic was bumped, usually it is a current time as obtained via time(). -* @return string An URL to the bumped topic, example: ./viewtopic.php?forum_id=1&topic_id=2&p=3#p3 -*/ -function phpbb_bump_topic($forum_id, $topic_id, $post_data, $bump_time = false) -{ - global $config, $db, $user, $phpEx, $phpbb_root_path, $phpbb_log; - - if ($bump_time === false) - { - $bump_time = time(); - } - - // Begin bumping - $db->sql_transaction('begin'); - - // Update the topic's last post post_time - $sql = 'UPDATE ' . POSTS_TABLE . " - SET post_time = $bump_time - WHERE post_id = {$post_data['topic_last_post_id']} - AND topic_id = $topic_id"; - $db->sql_query($sql); - - // Sync the topic's last post time, the rest of the topic's last post data isn't changed - $sql = 'UPDATE ' . TOPICS_TABLE . " - SET topic_last_post_time = $bump_time, - topic_bumped = 1, - topic_bumper = " . $user->data['user_id'] . " - WHERE topic_id = $topic_id"; - $db->sql_query($sql); - - // Update the forum's last post info - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET forum_last_post_id = " . $post_data['topic_last_post_id'] . ", - forum_last_poster_id = " . $post_data['topic_last_poster_id'] . ", - forum_last_post_subject = '" . $db->sql_escape($post_data['topic_last_post_subject']) . "', - forum_last_post_time = $bump_time, - forum_last_poster_name = '" . $db->sql_escape($post_data['topic_last_poster_name']) . "', - forum_last_poster_colour = '" . $db->sql_escape($post_data['topic_last_poster_colour']) . "' - WHERE forum_id = $forum_id"; - $db->sql_query($sql); - - // Update bumper's time of the last posting to prevent flood - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_lastpost_time = $bump_time - WHERE user_id = " . $user->data['user_id']; - $db->sql_query($sql); - - $db->sql_transaction('commit'); - - // Mark this topic as posted to - markread('post', $forum_id, $topic_id, $bump_time); - - // Mark this topic as read - markread('topic', $forum_id, $topic_id, $bump_time); - - // Update forum tracking info - if ($config['load_db_lastread'] && $user->data['is_registered']) - { - $sql = 'SELECT mark_time - FROM ' . FORUMS_TRACK_TABLE . ' - WHERE user_id = ' . $user->data['user_id'] . ' - AND forum_id = ' . $forum_id; - $result = $db->sql_query($sql); - $f_mark_time = (int) $db->sql_fetchfield('mark_time'); - $db->sql_freeresult($result); - } - else if ($config['load_anon_lastread'] || $user->data['is_registered']) - { - $f_mark_time = false; - } - - if (($config['load_db_lastread'] && $user->data['is_registered']) || $config['load_anon_lastread'] || $user->data['is_registered']) - { - // Update forum info - $sql = 'SELECT forum_last_post_time - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . $forum_id; - $result = $db->sql_query($sql); - $forum_last_post_time = (int) $db->sql_fetchfield('forum_last_post_time'); - $db->sql_freeresult($result); - - update_forum_tracking_info($forum_id, $forum_last_post_time, $f_mark_time, false); - } - - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_BUMP_TOPIC', false, array( - 'forum_id' => $forum_id, - 'topic_id' => $topic_id, - $post_data['topic_title'] - )); - - $url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&p={$post_data['topic_last_post_id']}") . "#p{$post_data['topic_last_post_id']}"; - - return $url; -} - -/** -* Show upload popup (progress bar) -*/ -function phpbb_upload_popup($forum_style = 0) -{ - global $template, $user; - - ($forum_style) ? $user->setup('posting', $forum_style) : $user->setup('posting'); - - page_header($user->lang['PROGRESS_BAR']); - - $template->set_filenames(array( - 'popup' => 'posting_progress_bar.html') - ); - - $template->assign_vars(array( - 'PROGRESS_BAR' => $user->img('upload_bar', $user->lang['UPLOAD_IN_PROGRESS'])) - ); - - $template->display('popup'); - - garbage_collection(); - exit_handler(); -} - -/** -* Do the various checks required for removing posts as well as removing it -* -* @param int $forum_id The id of the forum -* @param int $topic_id The id of the topic -* @param int $post_id The id of the post -* @param array $post_data Array with the post data -* @param bool $is_soft The flag indicating whether it is the soft delete mode -* @param string $delete_reason Description for the post deletion reason -* -* @return null -*/ -function phpbb_handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_soft = false, $delete_reason = '') -{ - global $user, $auth, $config, $request; - global $phpbb_root_path, $phpEx, $phpbb_log, $phpbb_dispatcher; - - $force_delete_allowed = $force_softdelete_allowed = false; - $perm_check = ($is_soft) ? 'softdelete' : 'delete'; - - /** - * This event allows to modify the conditions for the post deletion - * - * @event core.handle_post_delete_conditions - * @var int forum_id The id of the forum - * @var int topic_id The id of the topic - * @var int post_id The id of the post - * @var array post_data Array with the post data - * @var bool is_soft The flag indicating whether it is the soft delete mode - * @var string delete_reason Description for the post deletion reason - * @var bool force_delete_allowed Allow the user to delete the post (all permissions and conditions are ignored) - * @var bool force_softdelete_allowed Allow the user to softdelete the post (all permissions and conditions are ignored) - * @var string perm_check The deletion mode softdelete|delete - * @since 3.1.11-RC1 - */ - $vars = array( - 'forum_id', - 'topic_id', - 'post_id', - 'post_data', - 'is_soft', - 'delete_reason', - 'force_delete_allowed', - 'force_softdelete_allowed', - 'perm_check', - ); - extract($phpbb_dispatcher->trigger_event('core.handle_post_delete_conditions', compact($vars))); - - // If moderator removing post or user itself removing post, present a confirmation screen - if ($force_delete_allowed || ($is_soft && $force_softdelete_allowed) || $auth->acl_get("m_$perm_check", $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get("f_$perm_check", $forum_id) && $post_id == $post_data['topic_last_post_id'] && !$post_data['post_edit_locked'] && ($post_data['post_time'] > time() - ($config['delete_time'] * 60) || !$config['delete_time']))) - { - $s_hidden_fields = array( - 'p' => $post_id, - 'f' => $forum_id, - 'mode' => ($is_soft) ? 'soft_delete' : 'delete', - ); - - if (confirm_box(true)) - { - $data = array( - 'topic_first_post_id' => $post_data['topic_first_post_id'], - 'topic_last_post_id' => $post_data['topic_last_post_id'], - 'topic_posts_approved' => $post_data['topic_posts_approved'], - 'topic_posts_unapproved' => $post_data['topic_posts_unapproved'], - 'topic_posts_softdeleted' => $post_data['topic_posts_softdeleted'], - 'topic_visibility' => $post_data['topic_visibility'], - 'topic_type' => $post_data['topic_type'], - 'post_visibility' => $post_data['post_visibility'], - 'post_reported' => $post_data['post_reported'], - 'post_time' => $post_data['post_time'], - 'poster_id' => $post_data['poster_id'], - 'post_postcount' => $post_data['post_postcount'], - ); - - $next_post_id = delete_post($forum_id, $topic_id, $post_id, $data, $is_soft, $delete_reason); - $post_username = ($post_data['poster_id'] == ANONYMOUS && !empty($post_data['post_username'])) ? $post_data['post_username'] : $post_data['username']; - - if ($next_post_id === false) - { - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, (($is_soft) ? 'LOG_SOFTDELETE_TOPIC' : 'LOG_DELETE_TOPIC'), false, array( - 'forum_id' => $forum_id, - 'topic_id' => $topic_id, - $post_data['topic_title'], - $post_username, - $delete_reason - )); - - $meta_info = append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id"); - $message = $user->lang['POST_DELETED']; - } - else - { - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, (($is_soft) ? 'LOG_SOFTDELETE_POST' : 'LOG_DELETE_POST'), false, array( - 'forum_id' => $forum_id, - 'topic_id' => $topic_id, - 'post_id' => $post_id, - $post_data['post_subject'], - $post_username, - $delete_reason - )); - - $meta_info = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&p=$next_post_id") . "#p$next_post_id"; - $message = $user->lang['POST_DELETED']; - - if (!$request->is_ajax()) - { - $message .= '

' . $user->lang('RETURN_TOPIC', '', ''); - } - } - - meta_refresh(3, $meta_info); - if (!$request->is_ajax()) - { - $message .= '

' . $user->lang('RETURN_FORUM', '', ''); - } - trigger_error($message); - } - else - { - global $template; - - $can_delete = $force_delete_allowed || ($auth->acl_get('m_delete', $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get('f_delete', $forum_id))); - $can_softdelete = $force_softdelete_allowed || ($auth->acl_get('m_softdelete', $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get('f_softdelete', $forum_id))); - - $template->assign_vars(array( - 'S_SOFTDELETED' => $post_data['post_visibility'] == ITEM_DELETED, - 'S_CHECKED_PERMANENT' => $request->is_set_post('delete_permanent') ? ' checked="checked"' : '', - 'S_ALLOWED_DELETE' => $can_delete, - 'S_ALLOWED_SOFTDELETE' => $can_softdelete, - )); - - $l_confirm = 'DELETE_POST'; - if ($post_data['post_visibility'] == ITEM_DELETED) - { - $l_confirm .= '_PERMANENTLY'; - $s_hidden_fields['delete_permanent'] = '1'; - } - else if (!$can_softdelete) - { - $s_hidden_fields['delete_permanent'] = '1'; - } - - confirm_box(false, $l_confirm, build_hidden_fields($s_hidden_fields), 'confirm_delete_body.html'); - } - } - - // If we are here the user is not able to delete - present the correct error message - if ($post_data['poster_id'] != $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) - { - trigger_error('DELETE_OWN_POSTS'); - } - - if ($post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id) && $post_id != $post_data['topic_last_post_id']) - { - trigger_error('CANNOT_DELETE_REPLIED'); - } - - trigger_error('USER_CANNOT_DELETE'); -} diff --git a/install/update/new/includes/functions_privmsgs.php b/install/update/new/includes/functions_privmsgs.php deleted file mode 100644 index f07512d..0000000 --- a/install/update/new/includes/functions_privmsgs.php +++ /dev/null @@ -1,2303 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/* - Ability to simply add own rules by doing three things: - 1) Add an appropriate constant - 2) Add a new check array to the global_privmsgs_rules variable and the condition array (if one is required) - 3) Implement the rule logic in the check_rule() function - 4) Add a new language variable to ucp.php - - The user is then able to select the new rule. It will be checked against and handled as specified. - To add new actions (yes, checks can be added here too) to the rule management, the core code has to be modified. -*/ - -define('RULE_IS_LIKE', 1); // Is Like -define('RULE_IS_NOT_LIKE', 2); // Is Not Like -define('RULE_IS', 3); // Is -define('RULE_IS_NOT', 4); // Is Not -define('RULE_BEGINS_WITH', 5); // Begins with -define('RULE_ENDS_WITH', 6); // Ends with -define('RULE_IS_FRIEND', 7); // Is Friend -define('RULE_IS_FOE', 8); // Is Foe -define('RULE_IS_USER', 9); // Is User -define('RULE_IS_GROUP', 10); // Is In Usergroup -define('RULE_ANSWERED', 11); // Answered -define('RULE_FORWARDED', 12); // Forwarded -define('RULE_TO_GROUP', 14); // Usergroup -define('RULE_TO_ME', 15); // Me - -define('ACTION_PLACE_INTO_FOLDER', 1); -define('ACTION_MARK_AS_READ', 2); -define('ACTION_MARK_AS_IMPORTANT', 3); -define('ACTION_DELETE_MESSAGE', 4); - -define('CHECK_SUBJECT', 1); -define('CHECK_SENDER', 2); -define('CHECK_MESSAGE', 3); -define('CHECK_STATUS', 4); -define('CHECK_TO', 5); - -/** -* Global private message rules -* These rules define what to do if a rule is hit -*/ -$global_privmsgs_rules = array( - CHECK_SUBJECT => array( - RULE_IS_LIKE => array('check0' => 'message_subject'), - RULE_IS_NOT_LIKE => array('check0' => 'message_subject'), - RULE_IS => array('check0' => 'message_subject'), - RULE_IS_NOT => array('check0' => 'message_subject'), - RULE_BEGINS_WITH => array('check0' => 'message_subject'), - RULE_ENDS_WITH => array('check0' => 'message_subject'), - ), - - CHECK_SENDER => array( - RULE_IS_LIKE => array('check0' => 'username'), - RULE_IS_NOT_LIKE => array('check0' => 'username'), - RULE_IS => array('check0' => 'username'), - RULE_IS_NOT => array('check0' => 'username'), - RULE_BEGINS_WITH => array('check0' => 'username'), - RULE_ENDS_WITH => array('check0' => 'username'), - RULE_IS_FRIEND => array('check0' => 'friend'), - RULE_IS_FOE => array('check0' => 'foe'), - RULE_IS_USER => array('check0' => 'author_id'), - RULE_IS_GROUP => array('check0' => 'author_in_group'), - ), - - CHECK_MESSAGE => array( - RULE_IS_LIKE => array('check0' => 'message_text'), - RULE_IS_NOT_LIKE => array('check0' => 'message_text'), - RULE_IS => array('check0' => 'message_text'), - RULE_IS_NOT => array('check0' => 'message_text'), - ), - - CHECK_STATUS => array( - RULE_ANSWERED => array('check0' => 'pm_replied'), - RULE_FORWARDED => array('check0' => 'pm_forwarded'), - ), - - CHECK_TO => array( - RULE_TO_GROUP => array('check0' => 'to', 'check1' => 'bcc', 'check2' => 'user_in_group'), - RULE_TO_ME => array('check0' => 'to', 'check1' => 'bcc'), - ) -); - -/** -* This is for defining which condition fields to show for which Rule -*/ -$global_rule_conditions = array( - RULE_IS_LIKE => 'text', - RULE_IS_NOT_LIKE => 'text', - RULE_IS => 'text', - RULE_IS_NOT => 'text', - RULE_BEGINS_WITH => 'text', - RULE_ENDS_WITH => 'text', - RULE_IS_USER => 'user', - RULE_IS_GROUP => 'group' -); - -/** -* Get all folder -*/ -function get_folder($user_id, $folder_id = false) -{ - global $db, $user, $template; - global $phpbb_root_path, $phpEx; - - $folder = array(); - - // Get folder information - $sql = 'SELECT folder_id, COUNT(msg_id) as num_messages, SUM(pm_unread) as num_unread - FROM ' . PRIVMSGS_TO_TABLE . " - WHERE user_id = $user_id - AND folder_id <> " . PRIVMSGS_NO_BOX . ' - GROUP BY folder_id'; - $result = $db->sql_query($sql); - - $num_messages = $num_unread = array(); - while ($row = $db->sql_fetchrow($result)) - { - $num_messages[(int) $row['folder_id']] = $row['num_messages']; - $num_unread[(int) $row['folder_id']] = $row['num_unread']; - } - $db->sql_freeresult($result); - - // Make sure the default boxes are defined - $available_folder = array(PRIVMSGS_INBOX, PRIVMSGS_OUTBOX, PRIVMSGS_SENTBOX); - - foreach ($available_folder as $default_folder) - { - if (!isset($num_messages[$default_folder])) - { - $num_messages[$default_folder] = 0; - } - - if (!isset($num_unread[$default_folder])) - { - $num_unread[$default_folder] = 0; - } - } - - // Adjust unread status for outbox - $num_unread[PRIVMSGS_OUTBOX] = $num_messages[PRIVMSGS_OUTBOX]; - - $folder[PRIVMSGS_INBOX] = array( - 'folder_name' => $user->lang['PM_INBOX'], - 'num_messages' => $num_messages[PRIVMSGS_INBOX], - 'unread_messages' => $num_unread[PRIVMSGS_INBOX] - ); - - // Custom Folder - $sql = 'SELECT folder_id, folder_name, pm_count - FROM ' . PRIVMSGS_FOLDER_TABLE . " - WHERE user_id = $user_id"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $folder[$row['folder_id']] = array( - 'folder_name' => $row['folder_name'], - 'num_messages' => $row['pm_count'], - 'unread_messages' => ((isset($num_unread[$row['folder_id']])) ? $num_unread[$row['folder_id']] : 0) - ); - } - $db->sql_freeresult($result); - - $folder[PRIVMSGS_OUTBOX] = array( - 'folder_name' => $user->lang['PM_OUTBOX'], - 'num_messages' => $num_messages[PRIVMSGS_OUTBOX], - 'unread_messages' => $num_unread[PRIVMSGS_OUTBOX] - ); - - $folder[PRIVMSGS_SENTBOX] = array( - 'folder_name' => $user->lang['PM_SENTBOX'], - 'num_messages' => $num_messages[PRIVMSGS_SENTBOX], - 'unread_messages' => $num_unread[PRIVMSGS_SENTBOX] - ); - - // Define Folder Array for template designers (and for making custom folders usable by the template too) - foreach ($folder as $f_id => $folder_ary) - { - $folder_id_name = ($f_id == PRIVMSGS_INBOX) ? 'inbox' : (($f_id == PRIVMSGS_OUTBOX) ? 'outbox' : 'sentbox'); - - $template->assign_block_vars('folder', array( - 'FOLDER_ID' => $f_id, - 'FOLDER_NAME' => $folder_ary['folder_name'], - 'NUM_MESSAGES' => $folder_ary['num_messages'], - 'UNREAD_MESSAGES' => $folder_ary['unread_messages'], - - 'U_FOLDER' => ($f_id > 0) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&folder=' . $f_id) : append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&folder=' . $folder_id_name), - - 'S_CUR_FOLDER' => ($f_id === $folder_id) ? true : false, - 'S_UNREAD_MESSAGES' => ($folder_ary['unread_messages']) ? true : false, - 'S_CUSTOM_FOLDER' => ($f_id > 0) ? true : false) - ); - } - - if ($folder_id !== false && $folder_id !== PRIVMSGS_HOLD_BOX && !isset($folder[$folder_id])) - { - trigger_error('UNKNOWN_FOLDER'); - } - - return $folder; -} - -/** -* Delete Messages From Sentbox -* we are doing this here because this saves us a bunch of checks and queries -*/ -function clean_sentbox($num_sentbox_messages) -{ - global $db, $user; - - // Check Message Limit - if ($user->data['message_limit'] && $num_sentbox_messages > $user->data['message_limit']) - { - // Delete old messages - $sql = 'SELECT t.msg_id - FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p - WHERE t.msg_id = p.msg_id - AND t.user_id = ' . $user->data['user_id'] . ' - AND t.folder_id = ' . PRIVMSGS_SENTBOX . ' - ORDER BY p.message_time ASC'; - $result = $db->sql_query_limit($sql, ($num_sentbox_messages - $user->data['message_limit'])); - - $delete_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $delete_ids[] = $row['msg_id']; - } - $db->sql_freeresult($result); - delete_pm($user->data['user_id'], $delete_ids, PRIVMSGS_SENTBOX); - } -} - -/** -* Check Rule against Message Information -*/ -function check_rule(&$rules, &$rule_row, &$message_row, $user_id) -{ - if (!isset($rules[$rule_row['rule_check']][$rule_row['rule_connection']])) - { - return false; - } - - $check_ary = $rules[$rule_row['rule_check']][$rule_row['rule_connection']]; - - $result = false; - - $check0 = $message_row[$check_ary['check0']]; - - switch ($rule_row['rule_connection']) - { - case RULE_IS_LIKE: - $result = preg_match("/" . preg_quote($rule_row['rule_string'], '/') . '/i', $check0); - break; - - case RULE_IS_NOT_LIKE: - $result = !preg_match("/" . preg_quote($rule_row['rule_string'], '/') . '/i', $check0); - break; - - case RULE_IS: - $result = ($check0 == $rule_row['rule_string']); - break; - - case RULE_IS_NOT: - $result = ($check0 != $rule_row['rule_string']); - break; - - case RULE_BEGINS_WITH: - $result = preg_match("/^" . preg_quote($rule_row['rule_string'], '/') . '/i', $check0); - break; - - case RULE_ENDS_WITH: - $result = preg_match("/" . preg_quote($rule_row['rule_string'], '/') . '$/i', $check0); - break; - - case RULE_IS_FRIEND: - case RULE_IS_FOE: - case RULE_ANSWERED: - case RULE_FORWARDED: - $result = ($check0 == 1); - break; - - case RULE_IS_USER: - $result = ($check0 == $rule_row['rule_user_id']); - break; - - case RULE_IS_GROUP: - $result = in_array($rule_row['rule_group_id'], $check0); - break; - - case RULE_TO_GROUP: - $result = (in_array('g_' . $message_row[$check_ary['check2']], $check0) || in_array('g_' . $message_row[$check_ary['check2']], $message_row[$check_ary['check1']])); - break; - - case RULE_TO_ME: - $result = (in_array('u_' . $user_id, $check0) || in_array('u_' . $user_id, $message_row[$check_ary['check1']])); - break; - } - - if (!$result) - { - return false; - } - - switch ($rule_row['rule_action']) - { - case ACTION_PLACE_INTO_FOLDER: - return array('action' => $rule_row['rule_action'], 'folder_id' => $rule_row['rule_folder_id']); - break; - - case ACTION_MARK_AS_READ: - case ACTION_MARK_AS_IMPORTANT: - return array('action' => $rule_row['rule_action'], 'pm_unread' => $message_row['pm_unread'], 'pm_marked' => $message_row['pm_marked']); - break; - - case ACTION_DELETE_MESSAGE: - global $db; - - // Check for admins/mods - users are not allowed to remove those messages... - // We do the check here to make sure the data we use is consistent - $sql = 'SELECT user_id, user_type, user_permissions - FROM ' . USERS_TABLE . ' - WHERE user_id = ' . (int) $message_row['author_id']; - $result = $db->sql_query($sql); - $userdata = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $auth2 = new \phpbb\auth\auth(); - $auth2->acl($userdata); - - if (!$auth2->acl_get('a_') && !$auth2->acl_get('m_') && !$auth2->acl_getf_global('m_')) - { - return array('action' => $rule_row['rule_action'], 'pm_unread' => $message_row['pm_unread'], 'pm_marked' => $message_row['pm_marked']); - } - - return false; - break; - - default: - return false; - } - - return false; -} - -/** -* Update user PM count -*/ -function update_pm_counts() -{ - global $user, $db; - - // Update unread count - $sql = 'SELECT COUNT(msg_id) as num_messages - FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE pm_unread = 1 - AND folder_id <> ' . PRIVMSGS_OUTBOX . ' - AND user_id = ' . $user->data['user_id']; - $result = $db->sql_query($sql); - $user->data['user_unread_privmsg'] = (int) $db->sql_fetchfield('num_messages'); - $db->sql_freeresult($result); - - // Update new pm count - $sql = 'SELECT COUNT(msg_id) as num_messages - FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE pm_new = 1 - AND folder_id IN (' . PRIVMSGS_NO_BOX . ', ' . PRIVMSGS_HOLD_BOX . ') - AND user_id = ' . $user->data['user_id']; - $result = $db->sql_query($sql); - $user->data['user_new_privmsg'] = (int) $db->sql_fetchfield('num_messages'); - $db->sql_freeresult($result); - - $db->sql_query('UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', array( - 'user_unread_privmsg' => (int) $user->data['user_unread_privmsg'], - 'user_new_privmsg' => (int) $user->data['user_new_privmsg'], - )) . ' WHERE user_id = ' . $user->data['user_id']); - - // Ok, here we need to repair something, other boxes than privmsgs_no_box and privmsgs_hold_box should not carry the pm_new flag. - if (!$user->data['user_new_privmsg']) - { - $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . ' - SET pm_new = 0 - WHERE pm_new = 1 - AND folder_id NOT IN (' . PRIVMSGS_NO_BOX . ', ' . PRIVMSGS_HOLD_BOX . ') - AND user_id = ' . $user->data['user_id']; - $db->sql_query($sql); - } -} - -/** -* Place new messages into appropriate folder -*/ -function place_pm_into_folder(&$global_privmsgs_rules, $release = false) -{ - global $db, $user, $config; - - if (!$user->data['user_new_privmsg']) - { - return array('not_moved' => 0, 'removed' => 0); - } - - $user_message_rules = (int) $user->data['user_message_rules']; - $user_id = (int) $user->data['user_id']; - - $action_ary = $move_into_folder = array(); - $num_removed = 0; - - // Newly processing on-hold messages - if ($release) - { - $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . ' - SET folder_id = ' . PRIVMSGS_NO_BOX . ' - WHERE folder_id = ' . PRIVMSGS_HOLD_BOX . " - AND user_id = $user_id"; - $db->sql_query($sql); - } - - // Get those messages not yet placed into any box - $retrieve_sql = 'SELECT t.*, p.*, u.username, u.user_id, u.group_id - FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p, ' . USERS_TABLE . " u - WHERE t.user_id = $user_id - AND p.author_id = u.user_id - AND t.folder_id = " . PRIVMSGS_NO_BOX . ' - AND t.msg_id = p.msg_id'; - - // Just place into the appropriate arrays if no rules need to be checked - if (!$user_message_rules) - { - $result = $db->sql_query($retrieve_sql); - - while ($row = $db->sql_fetchrow($result)) - { - $action_ary[$row['msg_id']][] = array('action' => false); - } - $db->sql_freeresult($result); - } - else - { - $user_rules = $zebra = $check_rows = array(); - $user_ids = $memberships = array(); - - // First of all, grab all rules and retrieve friends/foes - $sql = 'SELECT * - FROM ' . PRIVMSGS_RULES_TABLE . " - WHERE user_id = $user_id"; - $result = $db->sql_query($sql); - $user_rules = $db->sql_fetchrowset($result); - $db->sql_freeresult($result); - - if (count($user_rules)) - { - $sql = 'SELECT zebra_id, friend, foe - FROM ' . ZEBRA_TABLE . " - WHERE user_id = $user_id"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $zebra[$row['zebra_id']] = $row; - } - $db->sql_freeresult($result); - } - - // Now build a bare-bone check_row array - $result = $db->sql_query($retrieve_sql); - - while ($row = $db->sql_fetchrow($result)) - { - $check_rows[] = array_merge($row, array( - 'to' => explode(':', $row['to_address']), - 'bcc' => explode(':', $row['bcc_address']), - 'friend' => (isset($zebra[$row['author_id']])) ? $zebra[$row['author_id']]['friend'] : 0, - 'foe' => (isset($zebra[$row['author_id']])) ? $zebra[$row['author_id']]['foe'] : 0, - 'user_in_group' => $user->data['group_id'], - 'author_in_group' => array()) - ); - - $user_ids[] = $row['user_id']; - } - $db->sql_freeresult($result); - - // Retrieve user memberships - if (count($user_ids)) - { - $sql = 'SELECT * - FROM ' . USER_GROUP_TABLE . ' - WHERE ' . $db->sql_in_set('user_id', $user_ids) . ' - AND user_pending = 0'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $memberships[$row['user_id']][] = $row['group_id']; - } - $db->sql_freeresult($result); - } - - // Now place into the appropriate folder - foreach ($check_rows as $row) - { - // Add membership if set - if (isset($memberships[$row['author_id']])) - { - $row['author_in_group'] = $memberships[$row['user_id']]; - } - - // Check Rule - this should be very quick since we have all information we need - $is_match = false; - foreach ($user_rules as $rule_row) - { - if (($action = check_rule($global_privmsgs_rules, $rule_row, $row, $user_id)) !== false) - { - $is_match = true; - $action_ary[$row['msg_id']][] = $action; - } - } - - if (!$is_match) - { - $action_ary[$row['msg_id']][] = array('action' => false); - } - } - - unset($user_rules, $zebra, $check_rows, $user_ids, $memberships); - } - - // We place actions into arrays, to save queries. - $unread_ids = $delete_ids = $important_ids = array(); - - foreach ($action_ary as $msg_id => $msg_ary) - { - // It is allowed to execute actions more than once, except placing messages into folder - $folder_action = $message_removed = false; - - foreach ($msg_ary as $pos => $rule_ary) - { - if ($folder_action && $rule_ary['action'] == ACTION_PLACE_INTO_FOLDER) - { - continue; - } - - switch ($rule_ary['action']) - { - case ACTION_PLACE_INTO_FOLDER: - // Folder actions have precedence, so we will remove any other ones - $folder_action = true; - $move_into_folder[(int) $rule_ary['folder_id']][] = $msg_id; - break; - - case ACTION_MARK_AS_READ: - if ($rule_ary['pm_unread']) - { - $unread_ids[] = $msg_id; - } - break; - - case ACTION_DELETE_MESSAGE: - $delete_ids[] = $msg_id; - $message_removed = true; - break; - - case ACTION_MARK_AS_IMPORTANT: - if (!$rule_ary['pm_marked']) - { - $important_ids[] = $msg_id; - } - break; - } - } - - // We place this here because it could happen that the messages are doubled if a rule marks a message and then moves it into a specific - // folder. Here we simply move the message into the INBOX if it gets not removed and also not put into a custom folder. - if (!$folder_action && !$message_removed) - { - $move_into_folder[PRIVMSGS_INBOX][] = $msg_id; - } - } - - // Do not change the order of processing - // The number of queries needed to be executed here highly depends on the defined rules and are - // only gone through if new messages arrive. - - // Delete messages - if (count($delete_ids)) - { - $num_removed += count($delete_ids); - delete_pm($user_id, $delete_ids, PRIVMSGS_NO_BOX); - } - - // Set messages to Unread - if (count($unread_ids)) - { - $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . ' - SET pm_unread = 0 - WHERE ' . $db->sql_in_set('msg_id', $unread_ids) . " - AND user_id = $user_id - AND folder_id = " . PRIVMSGS_NO_BOX; - $db->sql_query($sql); - } - - // mark messages as important - if (count($important_ids)) - { - $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . ' - SET pm_marked = 1 - pm_marked - WHERE folder_id = ' . PRIVMSGS_NO_BOX . " - AND user_id = $user_id - AND " . $db->sql_in_set('msg_id', $important_ids); - $db->sql_query($sql); - } - - // Move into folder - $folder = array(); - - if (count($move_into_folder)) - { - // Determine Full Folder Action - we need the move to folder id later eventually - $full_folder_action = ($user->data['user_full_folder'] == FULL_FOLDER_NONE) ? ($config['full_folder_action'] - (FULL_FOLDER_NONE*(-1))) : $user->data['user_full_folder']; - - $sql_folder = array_keys($move_into_folder); - if ($full_folder_action >= 0) - { - $sql_folder[] = $full_folder_action; - } - - $sql = 'SELECT folder_id, pm_count - FROM ' . PRIVMSGS_FOLDER_TABLE . ' - WHERE ' . $db->sql_in_set('folder_id', $sql_folder) . " - AND user_id = $user_id"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $folder[(int) $row['folder_id']] = (int) $row['pm_count']; - } - $db->sql_freeresult($result); - - unset($sql_folder); - - if (isset($move_into_folder[PRIVMSGS_INBOX])) - { - $sql = 'SELECT COUNT(msg_id) as num_messages - FROM ' . PRIVMSGS_TO_TABLE . " - WHERE user_id = $user_id - AND folder_id = " . PRIVMSGS_INBOX; - $result = $db->sql_query($sql); - $folder[PRIVMSGS_INBOX] = (int) $db->sql_fetchfield('num_messages'); - $db->sql_freeresult($result); - } - } - - // Here we have ideally only one folder to move into - foreach ($move_into_folder as $folder_id => $msg_ary) - { - $dest_folder = $folder_id; - $full_folder_action = FULL_FOLDER_NONE; - - // Check Message Limit - we calculate with the complete array, most of the time it is one message - // But we are making sure that the other way around works too (more messages in queue than allowed to be stored) - if ($user->data['message_limit'] && $folder[$folder_id] && ($folder[$folder_id] + count($msg_ary)) > $user->data['message_limit']) - { - $full_folder_action = ($user->data['user_full_folder'] == FULL_FOLDER_NONE) ? ($config['full_folder_action'] - (FULL_FOLDER_NONE*(-1))) : $user->data['user_full_folder']; - - // If destination folder itself is full... - if ($full_folder_action >= 0 && ($folder[$full_folder_action] + count($msg_ary)) > $user->data['message_limit']) - { - $full_folder_action = $config['full_folder_action'] - (FULL_FOLDER_NONE*(-1)); - } - - // If Full Folder Action is to move to another folder, we simply adjust the destination folder - if ($full_folder_action >= 0) - { - $dest_folder = $full_folder_action; - } - else if ($full_folder_action == FULL_FOLDER_DELETE) - { - // Delete some messages. NOTE: Ordered by msg_id here instead of message_time! - $sql = 'SELECT msg_id - FROM ' . PRIVMSGS_TO_TABLE . " - WHERE user_id = $user_id - AND folder_id = $dest_folder - ORDER BY msg_id ASC"; - $result = $db->sql_query_limit($sql, (($folder[$dest_folder] + count($msg_ary)) - $user->data['message_limit'])); - - $delete_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $delete_ids[] = $row['msg_id']; - } - $db->sql_freeresult($result); - - $num_removed += count($delete_ids); - delete_pm($user_id, $delete_ids, $dest_folder); - } - } - - // - if ($full_folder_action == FULL_FOLDER_HOLD) - { - $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . ' - SET folder_id = ' . PRIVMSGS_HOLD_BOX . ' - WHERE folder_id = ' . PRIVMSGS_NO_BOX . " - AND user_id = $user_id - AND " . $db->sql_in_set('msg_id', $msg_ary); - $db->sql_query($sql); - } - else - { - $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . " - SET folder_id = $dest_folder, pm_new = 0 - WHERE folder_id = " . PRIVMSGS_NO_BOX . " - AND user_id = $user_id - AND pm_new = 1 - AND " . $db->sql_in_set('msg_id', $msg_ary); - $db->sql_query($sql); - - if ($dest_folder != PRIVMSGS_INBOX) - { - $sql = 'UPDATE ' . PRIVMSGS_FOLDER_TABLE . ' - SET pm_count = pm_count + ' . (int) $db->sql_affectedrows() . " - WHERE folder_id = $dest_folder - AND user_id = $user_id"; - $db->sql_query($sql); - } - } - } - - if (count($action_ary)) - { - // Move from OUTBOX to SENTBOX - // We are not checking any full folder status here... SENTBOX is a special treatment (old messages get deleted) - $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . ' - SET folder_id = ' . PRIVMSGS_SENTBOX . ' - WHERE folder_id = ' . PRIVMSGS_OUTBOX . ' - AND ' . $db->sql_in_set('msg_id', array_keys($action_ary)); - $db->sql_query($sql); - } - - // Update new/unread count - update_pm_counts(); - - // Now check how many messages got not moved... - $sql = 'SELECT COUNT(msg_id) as num_messages - FROM ' . PRIVMSGS_TO_TABLE . " - WHERE user_id = $user_id - AND folder_id = " . PRIVMSGS_HOLD_BOX; - $result = $db->sql_query($sql); - $num_not_moved = (int) $db->sql_fetchfield('num_messages'); - $db->sql_freeresult($result); - - return array('not_moved' => $num_not_moved, 'removed' => $num_removed); -} - -/** -* Move PM from one to another folder -*/ -function move_pm($user_id, $message_limit, $move_msg_ids, $dest_folder, $cur_folder_id) -{ - global $db, $user; - global $phpbb_root_path, $phpEx; - - $num_moved = 0; - - if (!is_array($move_msg_ids)) - { - $move_msg_ids = array($move_msg_ids); - } - - if (count($move_msg_ids) && !in_array($dest_folder, array(PRIVMSGS_NO_BOX, PRIVMSGS_OUTBOX, PRIVMSGS_SENTBOX)) && - !in_array($cur_folder_id, array(PRIVMSGS_NO_BOX, PRIVMSGS_OUTBOX)) && $cur_folder_id != $dest_folder) - { - // We have to check the destination folder ;) - if ($dest_folder != PRIVMSGS_INBOX) - { - $sql = 'SELECT folder_id, folder_name, pm_count - FROM ' . PRIVMSGS_FOLDER_TABLE . " - WHERE folder_id = $dest_folder - AND user_id = $user_id"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - send_status_line(403, 'Forbidden'); - trigger_error('NOT_AUTHORISED'); - } - - if ($message_limit && $row['pm_count'] + count($move_msg_ids) > $message_limit) - { - $message = sprintf($user->lang['NOT_ENOUGH_SPACE_FOLDER'], $row['folder_name']) . '

'; - $message .= sprintf($user->lang['CLICK_RETURN_FOLDER'], '', '', $row['folder_name']); - trigger_error($message); - } - } - else - { - $sql = 'SELECT COUNT(msg_id) as num_messages - FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE folder_id = ' . PRIVMSGS_INBOX . " - AND user_id = $user_id"; - $result = $db->sql_query($sql); - $num_messages = (int) $db->sql_fetchfield('num_messages'); - $db->sql_freeresult($result); - - if ($message_limit && $num_messages + count($move_msg_ids) > $message_limit) - { - $message = sprintf($user->lang['NOT_ENOUGH_SPACE_FOLDER'], $user->lang['PM_INBOX']) . '

'; - $message .= sprintf($user->lang['CLICK_RETURN_FOLDER'], '', '', $user->lang['PM_INBOX']); - trigger_error($message); - } - } - - $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . " - SET folder_id = $dest_folder - WHERE folder_id = $cur_folder_id - AND user_id = $user_id - AND " . $db->sql_in_set('msg_id', $move_msg_ids); - $db->sql_query($sql); - $num_moved = $db->sql_affectedrows(); - - // Update pm counts - if ($num_moved) - { - if (!in_array($cur_folder_id, array(PRIVMSGS_INBOX, PRIVMSGS_OUTBOX, PRIVMSGS_SENTBOX))) - { - $sql = 'UPDATE ' . PRIVMSGS_FOLDER_TABLE . " - SET pm_count = pm_count - $num_moved - WHERE folder_id = $cur_folder_id - AND user_id = $user_id"; - $db->sql_query($sql); - } - - if ($dest_folder != PRIVMSGS_INBOX) - { - $sql = 'UPDATE ' . PRIVMSGS_FOLDER_TABLE . " - SET pm_count = pm_count + $num_moved - WHERE folder_id = $dest_folder - AND user_id = $user_id"; - $db->sql_query($sql); - } - } - } - else if (in_array($cur_folder_id, array(PRIVMSGS_NO_BOX, PRIVMSGS_OUTBOX))) - { - trigger_error('CANNOT_MOVE_SPECIAL'); - } - - return $num_moved; -} - -/** -* Update unread message status -*/ -function update_unread_status($unread, $msg_id, $user_id, $folder_id) -{ - if (!$unread) - { - return; - } - - global $db, $user, $phpbb_container; - - /* @var $phpbb_notifications \phpbb\notification\manager */ - $phpbb_notifications = $phpbb_container->get('notification_manager'); - - $phpbb_notifications->mark_notifications('notification.type.pm', $msg_id, $user_id); - - $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . " - SET pm_unread = 0 - WHERE msg_id = $msg_id - AND user_id = $user_id - AND folder_id = $folder_id - AND pm_unread = 1"; - $db->sql_query($sql); - - // If the message is already marked as read, we just skip the rest to avoid negative PM count - if (!$db->sql_affectedrows()) - { - return; - } - - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_unread_privmsg = user_unread_privmsg - 1 - WHERE user_id = $user_id"; - $db->sql_query($sql); - - if ($user->data['user_id'] == $user_id) - { - $user->data['user_unread_privmsg']--; - - // Try to cope with previous wrong conversions... - if ($user->data['user_unread_privmsg'] < 0) - { - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_unread_privmsg = 0 - WHERE user_id = $user_id"; - $db->sql_query($sql); - - $user->data['user_unread_privmsg'] = 0; - } - } -} - -function mark_folder_read($user_id, $folder_id) -{ - global $db; - - $sql = 'SELECT msg_id - FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE folder_id = ' . ((int) $folder_id) . ' - AND user_id = ' . ((int) $user_id) . ' - AND pm_unread = 1'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - update_unread_status(true, $row['msg_id'], $user_id, $folder_id); - } - $db->sql_freeresult($result); -} - -/** -* Handle all actions possible with marked messages -*/ -function handle_mark_actions($user_id, $mark_action) -{ - global $db, $user, $phpbb_root_path, $phpEx, $request; - - $msg_ids = $request->variable('marked_msg_id', array(0)); - $cur_folder_id = $request->variable('cur_folder_id', PRIVMSGS_NO_BOX); - - if (!count($msg_ids)) - { - return false; - } - - switch ($mark_action) - { - case 'mark_important': - - $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . " - SET pm_marked = 1 - pm_marked - WHERE folder_id = $cur_folder_id - AND user_id = $user_id - AND " . $db->sql_in_set('msg_id', $msg_ids); - $db->sql_query($sql); - - break; - - case 'delete_marked': - - global $auth; - - if (!$auth->acl_get('u_pm_delete')) - { - send_status_line(403, 'Forbidden'); - trigger_error('NO_AUTH_DELETE_MESSAGE'); - } - - if (confirm_box(true)) - { - delete_pm($user_id, $msg_ids, $cur_folder_id); - - $success_msg = (count($msg_ids) == 1) ? 'MESSAGE_DELETED' : 'MESSAGES_DELETED'; - $redirect = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&folder=' . $cur_folder_id); - - meta_refresh(3, $redirect); - trigger_error($user->lang[$success_msg] . '

' . sprintf($user->lang['RETURN_FOLDER'], '', '')); - } - else - { - $s_hidden_fields = array( - 'cur_folder_id' => $cur_folder_id, - 'mark_option' => 'delete_marked', - 'submit_mark' => true, - 'marked_msg_id' => $msg_ids - ); - - confirm_box(false, 'DELETE_MARKED_PM', build_hidden_fields($s_hidden_fields)); - } - - break; - - default: - return false; - } - - return true; -} - -/** -* Delete PM(s) -*/ -function delete_pm($user_id, $msg_ids, $folder_id) -{ - global $db, $user, $phpbb_container, $phpbb_dispatcher; - - $user_id = (int) $user_id; - $folder_id = (int) $folder_id; - - if (!$user_id) - { - return false; - } - - if (!is_array($msg_ids)) - { - if (!$msg_ids) - { - return false; - } - $msg_ids = array($msg_ids); - } - - if (!count($msg_ids)) - { - return false; - } - - /** - * Get all info for PM(s) before they are deleted - * - * @event core.delete_pm_before - * @var int user_id ID of the user requested the message delete - * @var array msg_ids array of all messages to be deleted - * @var int folder_id ID of the user folder where the messages are stored - * @since 3.1.0-b5 - */ - $vars = array('user_id', 'msg_ids', 'folder_id'); - extract($phpbb_dispatcher->trigger_event('core.delete_pm_before', compact($vars))); - - // Get PM Information for later deleting - $sql = 'SELECT msg_id, pm_unread, pm_new - FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE ' . $db->sql_in_set('msg_id', array_map('intval', $msg_ids)) . " - AND folder_id = $folder_id - AND user_id = $user_id"; - $result = $db->sql_query($sql); - - $delete_rows = array(); - $num_unread = $num_new = $num_deleted = 0; - while ($row = $db->sql_fetchrow($result)) - { - $num_unread += (int) $row['pm_unread']; - $num_new += (int) $row['pm_new']; - - $delete_rows[$row['msg_id']] = 1; - } - $db->sql_freeresult($result); - unset($msg_ids); - - if (!count($delete_rows)) - { - return false; - } - - $db->sql_transaction('begin'); - - // if no one has read the message yet (meaning it is in users outbox) - // then mark the message as deleted... - if ($folder_id == PRIVMSGS_OUTBOX) - { - // Remove PM from Outbox - $sql = 'DELETE FROM ' . PRIVMSGS_TO_TABLE . " - WHERE user_id = $user_id AND folder_id = " . PRIVMSGS_OUTBOX . ' - AND ' . $db->sql_in_set('msg_id', array_keys($delete_rows)); - $db->sql_query($sql); - - // Update PM Information for safety - $sql = 'UPDATE ' . PRIVMSGS_TABLE . " SET message_text = '' - WHERE " . $db->sql_in_set('msg_id', array_keys($delete_rows)); - $db->sql_query($sql); - - // Set delete flag for those intended to receive the PM - // We do not remove the message actually, to retain some basic information (sent time for example) - $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . ' - SET pm_deleted = 1 - WHERE ' . $db->sql_in_set('msg_id', array_keys($delete_rows)); - $db->sql_query($sql); - - $num_deleted = $db->sql_affectedrows(); - } - else - { - // Delete private message data - $sql = 'DELETE FROM ' . PRIVMSGS_TO_TABLE . " - WHERE user_id = $user_id - AND folder_id = $folder_id - AND " . $db->sql_in_set('msg_id', array_keys($delete_rows)); - $db->sql_query($sql); - $num_deleted = $db->sql_affectedrows(); - } - - // if folder id is user defined folder then decrease pm_count - if (!in_array($folder_id, array(PRIVMSGS_INBOX, PRIVMSGS_OUTBOX, PRIVMSGS_SENTBOX, PRIVMSGS_NO_BOX))) - { - $sql = 'UPDATE ' . PRIVMSGS_FOLDER_TABLE . " - SET pm_count = pm_count - $num_deleted - WHERE folder_id = $folder_id"; - $db->sql_query($sql); - } - - // Update unread and new status field - if ($num_unread || $num_new) - { - $set_sql = ($num_unread) ? 'user_unread_privmsg = user_unread_privmsg - ' . $num_unread : ''; - - if ($num_new) - { - $set_sql .= ($set_sql != '') ? ', ' : ''; - $set_sql .= 'user_new_privmsg = user_new_privmsg - ' . $num_new; - } - - $db->sql_query('UPDATE ' . USERS_TABLE . " SET $set_sql WHERE user_id = $user_id"); - - $user->data['user_new_privmsg'] -= $num_new; - $user->data['user_unread_privmsg'] -= $num_unread; - } - - /* @var $phpbb_notifications \phpbb\notification\manager */ - $phpbb_notifications = $phpbb_container->get('notification_manager'); - - $phpbb_notifications->delete_notifications('notification.type.pm', array_keys($delete_rows)); - - // Now we have to check which messages we can delete completely - $sql = 'SELECT msg_id - FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE ' . $db->sql_in_set('msg_id', array_keys($delete_rows)); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - unset($delete_rows[$row['msg_id']]); - } - $db->sql_freeresult($result); - - $delete_ids = array_keys($delete_rows); - - if (count($delete_ids)) - { - // Check if there are any attachments we need to remove - /** @var \phpbb\attachment\manager $attachment_manager */ - $attachment_manager = $phpbb_container->get('attachment.manager'); - $attachment_manager->delete('message', $delete_ids, false); - unset($attachment_manager); - - $sql = 'DELETE FROM ' . PRIVMSGS_TABLE . ' - WHERE ' . $db->sql_in_set('msg_id', $delete_ids); - $db->sql_query($sql); - } - - $db->sql_transaction('commit'); - - return true; -} - -/** -* Delete all PM(s) for a given user and delete the ones without references -* -* @param int $user_id ID of the user whose private messages we want to delete -* -* @return boolean False if there were no pms found, true otherwise. -*/ -function phpbb_delete_user_pms($user_id) -{ - $user_id = (int) $user_id; - - if (!$user_id) - { - return false; - } - - return phpbb_delete_users_pms(array($user_id)); -} - -/** -* Delete all PM(s) for given users and delete the ones without references -* -* @param array $user_ids IDs of the users whose private messages we want to delete -* -* @return boolean False if there were no pms found, true otherwise. -*/ -function phpbb_delete_users_pms($user_ids) -{ - global $db, $phpbb_container; - - $user_id_sql = $db->sql_in_set('user_id', $user_ids); - $author_id_sql = $db->sql_in_set('author_id', $user_ids); - - // Get PM Information for later deleting - // The two queries where split, so we can use our indexes - $undelivered_msg = $delete_ids = array(); - - // Part 1: get PMs the user received - $sql = 'SELECT msg_id - FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE ' . $user_id_sql; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $msg_id = (int) $row['msg_id']; - $delete_ids[$msg_id] = $msg_id; - } - $db->sql_freeresult($result); - - // Part 2: get PMs the users sent, but are yet to be received. - // We cannot simply delete them. First we have to check - // whether another user already received and read the message. - $sql = 'SELECT msg_id - FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE ' . $author_id_sql . ' - AND folder_id = ' . PRIVMSGS_NO_BOX; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $msg_id = (int) $row['msg_id']; - $undelivered_msg[$msg_id] = $msg_id; - } - $db->sql_freeresult($result); - - if (empty($delete_ids) && empty($undelivered_msg)) - { - return false; - } - - $db->sql_transaction('begin'); - - /* @var $phpbb_notifications \phpbb\notification\manager */ - $phpbb_notifications = $phpbb_container->get('notification_manager'); - - if (!empty($undelivered_msg)) - { - // A pm is delivered, if for any recipient the message was moved - // from their NO_BOX to another folder. We do not delete such - // messages, but only delete them for users, who have not yet - // received them. - $sql = 'SELECT msg_id - FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE ' . $author_id_sql . ' - AND folder_id <> ' . PRIVMSGS_NO_BOX . ' - AND folder_id <> ' . PRIVMSGS_OUTBOX . ' - AND folder_id <> ' . PRIVMSGS_SENTBOX; - $result = $db->sql_query($sql); - - $delivered_msg = array(); - while ($row = $db->sql_fetchrow($result)) - { - $msg_id = (int) $row['msg_id']; - $delivered_msg[$msg_id] = $msg_id; - unset($undelivered_msg[$msg_id]); - } - $db->sql_freeresult($result); - - $undelivered_user = array(); - - // Count the messages we delete, so we can correct the user pm data - $sql = 'SELECT user_id, COUNT(msg_id) as num_undelivered_privmsgs - FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE ' . $author_id_sql . ' - AND folder_id = ' . PRIVMSGS_NO_BOX . ' - AND ' . $db->sql_in_set('msg_id', array_merge($undelivered_msg, $delivered_msg)) . ' - GROUP BY user_id'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $num_pms = (int) $row['num_undelivered_privmsgs']; - $undelivered_user[$num_pms][] = (int) $row['user_id']; - - if (count($undelivered_user[$num_pms]) > 50) - { - // If there are too many users affected the query might get - // too long, so we update the value for the first bunch here. - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_new_privmsg = user_new_privmsg - ' . $num_pms . ', - user_unread_privmsg = user_unread_privmsg - ' . $num_pms . ' - WHERE ' . $db->sql_in_set('user_id', $undelivered_user[$num_pms]); - $db->sql_query($sql); - unset($undelivered_user[$num_pms]); - } - } - $db->sql_freeresult($result); - - foreach ($undelivered_user as $num_pms => $undelivered_user_set) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_new_privmsg = user_new_privmsg - ' . $num_pms . ', - user_unread_privmsg = user_unread_privmsg - ' . $num_pms . ' - WHERE ' . $db->sql_in_set('user_id', $undelivered_user_set); - $db->sql_query($sql); - } - - if (!empty($delivered_msg)) - { - $sql = 'DELETE FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE folder_id = ' . PRIVMSGS_NO_BOX . ' - AND ' . $db->sql_in_set('msg_id', $delivered_msg); - $db->sql_query($sql); - - $phpbb_notifications->delete_notifications('notification.type.pm', $delivered_msg); - } - - if (!empty($undelivered_msg)) - { - $sql = 'DELETE FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE ' . $db->sql_in_set('msg_id', $undelivered_msg); - $db->sql_query($sql); - - $sql = 'DELETE FROM ' . PRIVMSGS_TABLE . ' - WHERE ' . $db->sql_in_set('msg_id', $undelivered_msg); - $db->sql_query($sql); - - $phpbb_notifications->delete_notifications('notification.type.pm', $undelivered_msg); - } - } - - // Reset the user's pm count to 0 - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_new_privmsg = 0, - user_unread_privmsg = 0 - WHERE ' . $user_id_sql; - $db->sql_query($sql); - - // Delete private message data of the user - $sql = 'DELETE FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE ' . $user_id_sql; - $db->sql_query($sql); - - if (!empty($delete_ids)) - { - // Now we have to check which messages we can delete completely - $sql = 'SELECT msg_id - FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE ' . $db->sql_in_set('msg_id', $delete_ids); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - unset($delete_ids[$row['msg_id']]); - } - $db->sql_freeresult($result); - - if (!empty($delete_ids)) - { - // Check if there are any attachments we need to remove - /** @var \phpbb\attachment\manager $attachment_manager */ - $attachment_manager = $phpbb_container->get('attachment.manager'); - $attachment_manager->delete('message', $delete_ids, false); - unset($attachment_manager); - - $sql = 'DELETE FROM ' . PRIVMSGS_TABLE . ' - WHERE ' . $db->sql_in_set('msg_id', $delete_ids); - $db->sql_query($sql); - - $phpbb_notifications->delete_notifications('notification.type.pm', $delete_ids); - } - } - - // Set the remaining author id to anonymous - // This way users are still able to read messages from users being removed - $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . ' - SET author_id = ' . ANONYMOUS . ' - WHERE ' . $author_id_sql; - $db->sql_query($sql); - - $sql = 'UPDATE ' . PRIVMSGS_TABLE . ' - SET author_id = ' . ANONYMOUS . ' - WHERE ' . $author_id_sql; - $db->sql_query($sql); - - $db->sql_transaction('commit'); - - return true; -} - -/** -* Rebuild message header -*/ -function rebuild_header($check_ary) -{ - $address = array(); - - foreach ($check_ary as $check_type => $address_field) - { - // Split Addresses into users and groups - preg_match_all('/:?(u|g)_([0-9]+):?/', $address_field, $match); - - $u = $g = array(); - foreach ($match[1] as $id => $type) - { - ${$type}[] = (int) $match[2][$id]; - } - - $_types = array('u', 'g'); - foreach ($_types as $type) - { - if (count(${$type})) - { - foreach (${$type} as $id) - { - $address[$type][$id] = $check_type; - } - } - } - } - - return $address; -} - -/** -* Print out/assign recipient information -*/ -function write_pm_addresses($check_ary, $author_id, $plaintext = false) -{ - global $db, $user, $template, $phpbb_root_path, $phpEx, $phpbb_container; - - /** @var \phpbb\group\helper $group_helper */ - $group_helper = $phpbb_container->get('group_helper'); - - $addresses = array(); - - foreach ($check_ary as $check_type => $address_field) - { - if (!is_array($address_field)) - { - // Split Addresses into users and groups - preg_match_all('/:?(u|g)_([0-9]+):?/', $address_field, $match); - - $u = $g = array(); - foreach ($match[1] as $id => $type) - { - ${$type}[] = (int) $match[2][$id]; - } - } - else - { - $u = $address_field['u']; - $g = $address_field['g']; - } - - $address = array(); - if (count($u)) - { - $sql = 'SELECT user_id, username, user_colour - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('user_id', $u); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if ($check_type == 'to' || $author_id == $user->data['user_id'] || $row['user_id'] == $user->data['user_id']) - { - if ($plaintext) - { - $address[] = $row['username']; - } - else - { - $address['user'][$row['user_id']] = array('name' => $row['username'], 'colour' => $row['user_colour']); - } - } - } - $db->sql_freeresult($result); - } - - if (count($g)) - { - if ($plaintext) - { - $sql = 'SELECT group_name, group_type - FROM ' . GROUPS_TABLE . ' - WHERE ' . $db->sql_in_set('group_id', $g); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if ($check_type == 'to' || $author_id == $user->data['user_id'] || $row['user_id'] == $user->data['user_id']) - { - $address[] = $group_helper->get_name($row['group_name']); - } - } - $db->sql_freeresult($result); - } - else - { - $sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type, ug.user_id - FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . ' ug - WHERE ' . $db->sql_in_set('g.group_id', $g) . ' - AND g.group_id = ug.group_id - AND ug.user_pending = 0'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if (!isset($address['group'][$row['group_id']])) - { - if ($check_type == 'to' || $author_id == $user->data['user_id'] || $row['user_id'] == $user->data['user_id']) - { - $row['group_name'] = $group_helper->get_name($row['group_name']); - $address['group'][$row['group_id']] = array('name' => $row['group_name'], 'colour' => $row['group_colour']); - } - } - - if (isset($address['user'][$row['user_id']])) - { - $address['user'][$row['user_id']]['in_group'] = $row['group_id']; - } - } - $db->sql_freeresult($result); - } - } - - if (count($address) && !$plaintext) - { - $template->assign_var('S_' . strtoupper($check_type) . '_RECIPIENT', true); - - foreach ($address as $type => $adr_ary) - { - foreach ($adr_ary as $id => $row) - { - $tpl_ary = array( - 'IS_GROUP' => ($type == 'group') ? true : false, - 'IS_USER' => ($type == 'user') ? true : false, - 'UG_ID' => $id, - 'NAME' => $row['name'], - 'COLOUR' => ($row['colour']) ? '#' . $row['colour'] : '', - 'TYPE' => $type, - ); - - if ($type == 'user') - { - $tpl_ary = array_merge($tpl_ary, array( - 'U_VIEW' => get_username_string('profile', $id, $row['name'], $row['colour']), - 'NAME_FULL' => get_username_string('full', $id, $row['name'], $row['colour']), - )); - } - else - { - $tpl_ary = array_merge($tpl_ary, array( - 'U_VIEW' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&g=' . $id), - )); - } - - $template->assign_block_vars($check_type . '_recipient', $tpl_ary); - } - } - } - - $addresses[$check_type] = $address; - } - - return $addresses; -} - -/** -* Get folder status -*/ -function get_folder_status($folder_id, $folder) -{ - global $user; - - if (isset($folder[$folder_id])) - { - $folder = $folder[$folder_id]; - } - else - { - return false; - } - - $return = array( - 'folder_name' => $folder['folder_name'], - 'cur' => $folder['num_messages'], - 'remaining' => ($user->data['message_limit']) ? $user->data['message_limit'] - $folder['num_messages'] : 0, - 'max' => $user->data['message_limit'], - 'percent' => ($user->data['message_limit']) ? (($user->data['message_limit'] > 0) ? floor(($folder['num_messages'] / $user->data['message_limit']) * 100) : 100) : 0, - ); - - $return['message'] = $user->lang('FOLDER_STATUS_MSG', $user->lang('MESSAGES_COUNT', (int) $return['max']), (int) $return['cur'], $return['percent']); - - return $return; -} - -// -// COMPOSE MESSAGES -// - -/** -* Submit PM -*/ -function submit_pm($mode, $subject, &$data_ary, $put_in_outbox = true) -{ - global $db, $auth, $config, $user, $phpbb_root_path, $phpbb_container, $phpbb_dispatcher, $request; - - // We do not handle erasing pms here - if ($mode == 'delete') - { - return false; - } - - $current_time = time(); - - $data = $data_ary; - /** - * Get all parts of the PM that are to be submited to the DB. - * - * @event core.submit_pm_before - * @var string mode PM Post mode - post|reply|quote|quotepost|forward|edit - * @var string subject Subject of the private message - * @var array data The whole row data of the PM. - * @since 3.1.0-b3 - */ - $vars = array('mode', 'subject', 'data'); - extract($phpbb_dispatcher->trigger_event('core.submit_pm_before', compact($vars))); - $data_ary = $data; - unset($data); - - // Collect some basic information about which tables and which rows to update/insert - $sql_data = array(); - $root_level = 0; - - // Recipient Information - $recipients = $to = $bcc = array(); - - if ($mode != 'edit') - { - // Build Recipient List - // u|g => array($user_id => 'to'|'bcc') - $_types = array('u', 'g'); - foreach ($_types as $ug_type) - { - if (isset($data_ary['address_list'][$ug_type]) && count($data_ary['address_list'][$ug_type])) - { - foreach ($data_ary['address_list'][$ug_type] as $id => $field) - { - $id = (int) $id; - - // Do not rely on the address list being "valid" - if (!$id || ($ug_type == 'u' && $id == ANONYMOUS)) - { - continue; - } - - $field = ($field == 'to') ? 'to' : 'bcc'; - if ($ug_type == 'u') - { - $recipients[$id] = $field; - } - ${$field}[] = $ug_type . '_' . $id; - } - } - } - - if (isset($data_ary['address_list']['g']) && count($data_ary['address_list']['g'])) - { - // We need to check the PM status of group members (do they want to receive PM's?) - // Only check if not a moderator or admin, since they are allowed to override this user setting - $sql_allow_pm = (!$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_')) ? ' AND u.user_allow_pm = 1' : ''; - - $sql = 'SELECT u.user_type, ug.group_id, ug.user_id - FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . ' ug - WHERE ' . $db->sql_in_set('ug.group_id', array_keys($data_ary['address_list']['g'])) . ' - AND ug.user_pending = 0 - AND u.user_id = ug.user_id - AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')' . - $sql_allow_pm; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $field = ($data_ary['address_list']['g'][$row['group_id']] == 'to') ? 'to' : 'bcc'; - $recipients[$row['user_id']] = $field; - } - $db->sql_freeresult($result); - } - - if (!count($recipients)) - { - trigger_error('NO_RECIPIENT'); - } - } - - // First of all make sure the subject are having the correct length. - $subject = truncate_string($subject); - - $db->sql_transaction('begin'); - - $sql = ''; - - switch ($mode) - { - case 'reply': - case 'quote': - $root_level = ($data_ary['reply_from_root_level']) ? $data_ary['reply_from_root_level'] : $data_ary['reply_from_msg_id']; - - // Set message_replied switch for this user - $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . ' - SET pm_replied = 1 - WHERE user_id = ' . $data_ary['from_user_id'] . ' - AND msg_id = ' . $data_ary['reply_from_msg_id']; - - // no break - - case 'forward': - case 'post': - case 'quotepost': - $sql_data = array( - 'root_level' => $root_level, - 'author_id' => $data_ary['from_user_id'], - 'icon_id' => $data_ary['icon_id'], - 'author_ip' => $data_ary['from_user_ip'], - 'message_time' => $current_time, - 'enable_bbcode' => $data_ary['enable_bbcode'], - 'enable_smilies' => $data_ary['enable_smilies'], - 'enable_magic_url' => $data_ary['enable_urls'], - 'enable_sig' => $data_ary['enable_sig'], - 'message_subject' => $subject, - 'message_text' => $data_ary['message'], - 'message_attachment'=> (!empty($data_ary['attachment_data'])) ? 1 : 0, - 'bbcode_bitfield' => $data_ary['bbcode_bitfield'], - 'bbcode_uid' => $data_ary['bbcode_uid'], - 'to_address' => implode(':', $to), - 'bcc_address' => implode(':', $bcc), - 'message_reported' => 0, - ); - break; - - case 'edit': - $sql_data = array( - 'icon_id' => $data_ary['icon_id'], - 'message_edit_time' => $current_time, - 'enable_bbcode' => $data_ary['enable_bbcode'], - 'enable_smilies' => $data_ary['enable_smilies'], - 'enable_magic_url' => $data_ary['enable_urls'], - 'enable_sig' => $data_ary['enable_sig'], - 'message_subject' => $subject, - 'message_text' => $data_ary['message'], - 'message_attachment'=> (!empty($data_ary['attachment_data'])) ? 1 : 0, - 'bbcode_bitfield' => $data_ary['bbcode_bitfield'], - 'bbcode_uid' => $data_ary['bbcode_uid'] - ); - break; - } - - if (count($sql_data)) - { - if ($mode == 'post' || $mode == 'reply' || $mode == 'quote' || $mode == 'quotepost' || $mode == 'forward') - { - $db->sql_query('INSERT INTO ' . PRIVMSGS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_data)); - $data_ary['msg_id'] = $db->sql_nextid(); - } - else if ($mode == 'edit') - { - $sql = 'UPDATE ' . PRIVMSGS_TABLE . ' - SET message_edit_count = message_edit_count + 1, ' . $db->sql_build_array('UPDATE', $sql_data) . ' - WHERE msg_id = ' . $data_ary['msg_id']; - $db->sql_query($sql); - } - } - - if ($mode != 'edit') - { - if ($sql) - { - $db->sql_query($sql); - } - unset($sql); - - $sql_ary = array(); - foreach ($recipients as $user_id => $type) - { - $sql_ary[] = array( - 'msg_id' => (int) $data_ary['msg_id'], - 'user_id' => (int) $user_id, - 'author_id' => (int) $data_ary['from_user_id'], - 'folder_id' => PRIVMSGS_NO_BOX, - 'pm_new' => 1, - 'pm_unread' => 1, - 'pm_forwarded' => ($mode == 'forward') ? 1 : 0 - ); - } - - $db->sql_multi_insert(PRIVMSGS_TO_TABLE, $sql_ary); - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_new_privmsg = user_new_privmsg + 1, user_unread_privmsg = user_unread_privmsg + 1, user_last_privmsg = ' . time() . ' - WHERE ' . $db->sql_in_set('user_id', array_keys($recipients)); - $db->sql_query($sql); - - // Put PM into outbox - if ($put_in_outbox) - { - $db->sql_query('INSERT INTO ' . PRIVMSGS_TO_TABLE . ' ' . $db->sql_build_array('INSERT', array( - 'msg_id' => (int) $data_ary['msg_id'], - 'user_id' => (int) $data_ary['from_user_id'], - 'author_id' => (int) $data_ary['from_user_id'], - 'folder_id' => PRIVMSGS_OUTBOX, - 'pm_new' => 0, - 'pm_unread' => 0, - 'pm_forwarded' => ($mode == 'forward') ? 1 : 0)) - ); - } - } - - // Set user last post time - if ($mode == 'reply' || $mode == 'quote' || $mode == 'quotepost' || $mode == 'forward' || $mode == 'post') - { - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_lastpost_time = $current_time - WHERE user_id = " . $data_ary['from_user_id']; - $db->sql_query($sql); - } - - // Submit Attachments - if (!empty($data_ary['attachment_data']) && $data_ary['msg_id'] && in_array($mode, array('post', 'reply', 'quote', 'quotepost', 'edit', 'forward'))) - { - $space_taken = $files_added = 0; - $orphan_rows = array(); - - foreach ($data_ary['attachment_data'] as $pos => $attach_row) - { - $orphan_rows[(int) $attach_row['attach_id']] = array(); - } - - if (count($orphan_rows)) - { - $sql = 'SELECT attach_id, filesize, physical_filename - FROM ' . ATTACHMENTS_TABLE . ' - WHERE ' . $db->sql_in_set('attach_id', array_keys($orphan_rows)) . ' - AND in_message = 1 - AND is_orphan = 1 - AND poster_id = ' . $user->data['user_id']; - $result = $db->sql_query($sql); - - $orphan_rows = array(); - while ($row = $db->sql_fetchrow($result)) - { - $orphan_rows[$row['attach_id']] = $row; - } - $db->sql_freeresult($result); - } - - foreach ($data_ary['attachment_data'] as $pos => $attach_row) - { - if ($attach_row['is_orphan'] && !isset($orphan_rows[$attach_row['attach_id']])) - { - continue; - } - - if (!$attach_row['is_orphan']) - { - // update entry in db if attachment already stored in db and filespace - $sql = 'UPDATE ' . ATTACHMENTS_TABLE . " - SET attach_comment = '" . $db->sql_escape($attach_row['attach_comment']) . "' - WHERE attach_id = " . (int) $attach_row['attach_id'] . ' - AND is_orphan = 0'; - $db->sql_query($sql); - } - else - { - // insert attachment into db - if (!@file_exists($phpbb_root_path . $config['upload_path'] . '/' . utf8_basename($orphan_rows[$attach_row['attach_id']]['physical_filename']))) - { - continue; - } - - $space_taken += $orphan_rows[$attach_row['attach_id']]['filesize']; - $files_added++; - - $attach_sql = array( - 'post_msg_id' => $data_ary['msg_id'], - 'topic_id' => 0, - 'is_orphan' => 0, - 'poster_id' => $data_ary['from_user_id'], - 'attach_comment' => $attach_row['attach_comment'], - ); - - $sql = 'UPDATE ' . ATTACHMENTS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $attach_sql) . ' - WHERE attach_id = ' . $attach_row['attach_id'] . ' - AND is_orphan = 1 - AND poster_id = ' . $user->data['user_id']; - $db->sql_query($sql); - } - } - - if ($space_taken && $files_added) - { - $config->increment('upload_dir_size', $space_taken, false); - $config->increment('num_files', $files_added, false); - } - } - - // Delete draft if post was loaded... - $draft_id = $request->variable('draft_loaded', 0); - if ($draft_id) - { - $sql = 'DELETE FROM ' . DRAFTS_TABLE . " - WHERE draft_id = $draft_id - AND user_id = " . $data_ary['from_user_id']; - $db->sql_query($sql); - } - - $db->sql_transaction('commit'); - - // Send Notifications - $pm_data = array_merge($data_ary, array( - 'message_subject' => $subject, - 'recipients' => $recipients, - )); - - /* @var $phpbb_notifications \phpbb\notification\manager */ - $phpbb_notifications = $phpbb_container->get('notification_manager'); - - if ($mode == 'edit') - { - $phpbb_notifications->update_notifications('notification.type.pm', $pm_data); - } - else - { - $phpbb_notifications->add_notifications('notification.type.pm', $pm_data); - } - - $data = $data_ary; - /** - * Get PM message ID after submission to DB - * - * @event core.submit_pm_after - * @var string mode PM Post mode - post|reply|quote|quotepost|forward|edit - * @var string subject Subject of the private message - * @var array data The whole row data of the PM. - * @var array pm_data The data sent to notification class - * @since 3.1.0-b5 - */ - $vars = array('mode', 'subject', 'data', 'pm_data'); - extract($phpbb_dispatcher->trigger_event('core.submit_pm_after', compact($vars))); - $data_ary = $data; - unset($data); - - return $data_ary['msg_id']; -} - -/** -* Display Message History -*/ -function message_history($msg_id, $user_id, $message_row, $folder, $in_post_mode = false) -{ - global $db, $user, $template, $phpbb_root_path, $phpEx, $auth, $phpbb_dispatcher; - - // Select all receipts and the author from the pm we currently view, to only display their pm-history - $sql = 'SELECT author_id, user_id - FROM ' . PRIVMSGS_TO_TABLE . " - WHERE msg_id = $msg_id - AND folder_id <> " . PRIVMSGS_HOLD_BOX; - $result = $db->sql_query($sql); - - $recipients = array(); - while ($row = $db->sql_fetchrow($result)) - { - $recipients[] = (int) $row['user_id']; - $recipients[] = (int) $row['author_id']; - } - $db->sql_freeresult($result); - $recipients = array_unique($recipients); - - // Get History Messages (could be newer) - $sql_where = 't.msg_id = p.msg_id - AND p.author_id = u.user_id - AND t.folder_id NOT IN (' . PRIVMSGS_NO_BOX . ', ' . PRIVMSGS_HOLD_BOX . ') - AND ' . $db->sql_in_set('t.author_id', $recipients, false, true) . " - AND t.user_id = $user_id"; - - // We no longer need those. - unset($recipients); - - if (!$message_row['root_level']) - { - $sql_where .= " AND (p.root_level = $msg_id OR (p.root_level = 0 AND p.msg_id = $msg_id))"; - } - else - { - $sql_where .= " AND (p.root_level = " . $message_row['root_level'] . ' OR p.msg_id = ' . $message_row['root_level'] . ')'; - } - - $sql_ary = array( - 'SELECT' => 't.*, p.*, u.*', - 'FROM' => array( - PRIVMSGS_TABLE => 'p', - PRIVMSGS_TO_TABLE => 't', - USERS_TABLE => 'u' - ), - 'LEFT_JOIN' => array(), - 'WHERE' => $sql_where, - 'ORDER_BY' => 'p.message_time DESC', - ); - - /** - * Event to modify the SQL query before the message history in private message is queried - * - * @event core.message_history_modify_sql_ary - * @var array sql_ary The SQL array to get the data of the message history in private message - * @since 3.2.8-RC1 - */ - $vars = array('sql_ary'); - extract($phpbb_dispatcher->trigger_event('core.message_history_modify_sql_ary', compact($vars))); - - $sql = $db->sql_build_query('SELECT', $sql_ary); - unset($sql_ary); - - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - - if (!$row) - { - $db->sql_freeresult($result); - return false; - } - - $title = $row['message_subject']; - - $rowset = array(); - $folder_url = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm') . '&folder='; - - do - { - $folder_id = (int) $row['folder_id']; - - $row['folder'][] = (isset($folder[$folder_id])) ? '' . $folder[$folder_id]['folder_name'] . '' : $user->lang['UNKNOWN_FOLDER']; - - if (isset($rowset[$row['msg_id']])) - { - $rowset[$row['msg_id']]['folder'][] = (isset($folder[$folder_id])) ? '' . $folder[$folder_id]['folder_name'] . '' : $user->lang['UNKNOWN_FOLDER']; - } - else - { - $rowset[$row['msg_id']] = $row; - } - } - while ($row = $db->sql_fetchrow($result)); - $db->sql_freeresult($result); - - if (count($rowset) == 1 && !$in_post_mode) - { - return false; - } - - $title = censor_text($title); - - $url = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm'); - $next_history_pm = $previous_history_pm = $prev_id = 0; - - // Re-order rowset to be able to get the next/prev message rows... - $rowset = array_values($rowset); - - for ($i = 0, $size = count($rowset); $i < $size; $i++) - { - $row = &$rowset[$i]; - $id = (int) $row['msg_id']; - - $author_id = $row['author_id']; - $folder_id = (int) $row['folder_id']; - - $subject = $row['message_subject']; - $message = $row['message_text']; - - $message = censor_text($message); - - $decoded_message = false; - - if ($in_post_mode && $auth->acl_get('u_sendpm') && $author_id != ANONYMOUS) - { - $decoded_message = $message; - decode_message($decoded_message, $row['bbcode_uid']); - - $decoded_message = bbcode_nl2br($decoded_message); - } - - $parse_flags = ($row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0); - $parse_flags |= ($row['enable_smilies'] ? OPTION_FLAG_SMILIES : 0); - - $message = generate_text_for_display($message, $row['bbcode_uid'], $row['bbcode_bitfield'], $parse_flags, false); - - $subject = censor_text($subject); - - if ($id == $msg_id) - { - $next_history_pm = (isset($rowset[$i + 1])) ? (int) $rowset[$i + 1]['msg_id'] : 0; - $previous_history_pm = $prev_id; - } - - $template_vars = array( - 'MESSAGE_AUTHOR_QUOTE' => (($decoded_message) ? addslashes(get_username_string('username', $author_id, $row['username'], $row['user_colour'], $row['username'])) : ''), - 'MESSAGE_AUTHOR_FULL' => get_username_string('full', $author_id, $row['username'], $row['user_colour'], $row['username']), - 'MESSAGE_AUTHOR_COLOUR' => get_username_string('colour', $author_id, $row['username'], $row['user_colour'], $row['username']), - 'MESSAGE_AUTHOR' => get_username_string('username', $author_id, $row['username'], $row['user_colour'], $row['username']), - 'U_MESSAGE_AUTHOR' => get_username_string('profile', $author_id, $row['username'], $row['user_colour'], $row['username']), - - 'SUBJECT' => $subject, - 'SENT_DATE' => $user->format_date($row['message_time']), - 'MESSAGE' => $message, - 'FOLDER' => implode($user->lang['COMMA_SEPARATOR'], $row['folder']), - 'DECODED_MESSAGE' => $decoded_message, - - 'S_CURRENT_MSG' => ($row['msg_id'] == $msg_id), - 'S_AUTHOR_DELETED' => ($author_id == ANONYMOUS) ? true : false, - 'S_IN_POST_MODE' => $in_post_mode, - - 'MSG_ID' => $row['msg_id'], - 'MESSAGE_TIME' => $row['message_time'], - 'USER_ID' => $row['user_id'], - 'U_VIEW_MESSAGE' => "$url&f=$folder_id&p=" . $row['msg_id'], - 'U_QUOTE' => (!$in_post_mode && $auth->acl_get('u_sendpm') && $author_id != ANONYMOUS) ? "$url&mode=compose&action=quote&f=" . $folder_id . "&p=" . $row['msg_id'] : '', - 'U_POST_REPLY_PM' => ($author_id != $user->data['user_id'] && $author_id != ANONYMOUS && $auth->acl_get('u_sendpm')) ? "$url&mode=compose&action=reply&f=$folder_id&p=" . $row['msg_id'] : '' - ); - - /** - * Modify the template vars for displaying the message history in private message - * - * @event core.message_history_modify_template_vars - * @var array template_vars Array containing the query - * @var array row Array containing the action user row - * @since 3.2.8-RC1 - */ - $vars = array( - 'template_vars', - 'row', - ); - extract($phpbb_dispatcher->trigger_event('core.message_history_modify_template_vars', compact($vars))); - - $template->assign_block_vars('history_row', $template_vars); - - unset($rowset[$i]); - $prev_id = $id; - } - - $template->assign_vars(array( - 'QUOTE_IMG' => $user->img('icon_post_quote', $user->lang['REPLY_WITH_QUOTE']), - 'HISTORY_TITLE' => $title, - - 'U_VIEW_NEXT_HISTORY' => ($next_history_pm) ? "$url&p=" . $next_history_pm : '', - 'U_VIEW_PREVIOUS_HISTORY' => ($previous_history_pm) ? "$url&p=" . $previous_history_pm : '', - )); - - return true; -} - -/** -* Set correct users max messages in PM folder. -* If several group memberships define different amount of messages, the highest will be chosen. -*/ -function set_user_message_limit() -{ - global $user, $db, $config; - - // Get maximum about from user memberships - $message_limit = phpbb_get_max_setting_from_group($db, $user->data['user_id'], 'message_limit'); - - // If it is 0, there is no limit set and we use the maximum value within the config. - $user->data['message_limit'] = (!$message_limit) ? $config['pm_max_msgs'] : $message_limit; -} - -/** - * Get the maximum PM setting for the groups of the user - * - * @param \phpbb\db\driver\driver_interface $db - * @param int $user_id - * @param string $setting Only 'max_recipients' and 'message_limit' are supported - * @return int The maximum setting for all groups of the user, unless one group has '0' - * @throws \InvalidArgumentException If selected group setting is not supported - */ -function phpbb_get_max_setting_from_group(\phpbb\db\driver\driver_interface $db, $user_id, $setting) -{ - if ($setting !== 'max_recipients' && $setting !== 'message_limit') - { - throw new InvalidArgumentException('Setting "' . $setting . '" is not supported'); - } - - // Get maximum number of allowed recipients - $sql = 'SELECT MAX(g.group_' . $setting . ') as max_setting - FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . ' ug - WHERE ug.user_id = ' . (int) $user_id . ' - AND ug.user_pending = 0 - AND ug.group_id = g.group_id'; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - $max_setting = (int) $row['max_setting']; - - return $max_setting; -} - -/** -* Generates an array of coloured recipient names from a list of PMs - (groups & users) -* -* @param array $pm_by_id An array of rows from PRIVMSGS_TABLE, keys are the msg_ids. -* -* @return array 2D Array: array(msg_id => array('username or group string', ...), ...) -* Usernames are generated with {@link get_username_string get_username_string} -* Groups are coloured and have a link to the membership page -*/ -function get_recipient_strings($pm_by_id) -{ - global $db, $phpbb_root_path, $phpEx, $user, $phpbb_container; - - /** @var \phpbb\group\helper $group_helper */ - $group_helper = $phpbb_container->get('group_helper'); - - $address_list = $recipient_list = $address = array(); - - $_types = array('u', 'g'); - - foreach ($pm_by_id as $message_id => $row) - { - $address[$message_id] = rebuild_header(array('to' => $row['to_address'], 'bcc' => $row['bcc_address'])); - - foreach ($_types as $ug_type) - { - if (isset($address[$message_id][$ug_type]) && count($address[$message_id][$ug_type])) - { - foreach ($address[$message_id][$ug_type] as $ug_id => $in_to) - { - $recipient_list[$ug_type][$ug_id] = array('name' => $user->lang['NA'], 'colour' => ''); - } - } - } - } - - foreach ($_types as $ug_type) - { - if (!empty($recipient_list[$ug_type])) - { - if ($ug_type == 'u') - { - $sql = 'SELECT user_id as id, username as name, user_colour as colour - FROM ' . USERS_TABLE . ' - WHERE '; - } - else - { - $sql = 'SELECT group_id as id, group_name as name, group_colour as colour, group_type - FROM ' . GROUPS_TABLE . ' - WHERE '; - } - $sql .= $db->sql_in_set(($ug_type == 'u') ? 'user_id' : 'group_id', array_map('intval', array_keys($recipient_list[$ug_type]))); - - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if ($ug_type == 'g') - { - $row['name'] = $group_helper->get_name($row['name']); - } - - $recipient_list[$ug_type][$row['id']] = array('name' => $row['name'], 'colour' => $row['colour']); - } - $db->sql_freeresult($result); - } - } - - foreach ($address as $message_id => $adr_ary) - { - foreach ($adr_ary as $type => $id_ary) - { - foreach ($id_ary as $ug_id => $_id) - { - if ($type == 'u') - { - $address_list[$message_id][] = get_username_string('full', $ug_id, $recipient_list[$type][$ug_id]['name'], $recipient_list[$type][$ug_id]['colour']); - } - else - { - $user_colour = ($recipient_list[$type][$ug_id]['colour']) ? ' style="font-weight: bold; color:#' . $recipient_list[$type][$ug_id]['colour'] . '"' : ''; - $link = ''; - $address_list[$message_id][] = $link . $recipient_list[$type][$ug_id]['name'] . (($link) ? '' : ''); - } - } - } - } - - return $address_list; -} diff --git a/install/update/new/includes/functions_transfer.php b/install/update/new/includes/functions_transfer.php deleted file mode 100644 index f0070b4..0000000 --- a/install/update/new/includes/functions_transfer.php +++ /dev/null @@ -1,899 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* Transfer class, wrapper for ftp/sftp/ssh -*/ -class transfer -{ - var $connection; - var $host; - var $port; - var $username; - var $password; - var $timeout; - var $root_path; - var $tmp_path; - var $file_perms; - var $dir_perms; - - /** - * Constructor - init some basic values - */ - function __construct() - { - global $phpbb_root_path; - - $this->file_perms = 0644; - $this->dir_perms = 0777; - - // We use the store directory as temporary path to circumvent open basedir restrictions - $this->tmp_path = $phpbb_root_path . 'store/'; - } - - /** - * Write file to location - */ - function write_file($destination_file = '', $contents = '') - { - global $phpbb_root_path; - - $destination_file = $this->root_path . str_replace($phpbb_root_path, '', $destination_file); - - // need to create a temp file and then move that temp file. - // ftp functions can only move files around and can't create. - // This means that the users will need to have access to write - // temporary files or have write access on a folder within phpBB - // like the cache folder. If the user can't do either, then - // he/she needs to use the fsock ftp method - $temp_name = tempnam($this->tmp_path, 'transfer_'); - @unlink($temp_name); - - $fp = @fopen($temp_name, 'w'); - - if (!$fp) - { - trigger_error('Unable to create temporary file ' . $temp_name, E_USER_ERROR); - } - - @fwrite($fp, $contents); - @fclose($fp); - - $result = $this->overwrite_file($temp_name, $destination_file); - - // remove temporary file now - @unlink($temp_name); - - return $result; - } - - /** - * Moving file into location. If the destination file already exists it gets overwritten - */ - function overwrite_file($source_file, $destination_file) - { - /** - * @todo generally think about overwriting files in another way, by creating a temporary file and then renaming it - * @todo check for the destination file existance too - */ - $this->_delete($destination_file); - $result = $this->_put($source_file, $destination_file); - $this->_chmod($destination_file, $this->file_perms); - - return $result; - } - - /** - * Create directory structure - */ - function make_dir($dir) - { - global $phpbb_root_path; - - $dir = str_replace($phpbb_root_path, '', $dir); - $dir = explode('/', $dir); - $dirs = ''; - - for ($i = 0, $total = count($dir); $i < $total; $i++) - { - $result = true; - - if (strpos($dir[$i], '.') === 0) - { - continue; - } - $cur_dir = $dir[$i] . '/'; - - if (!file_exists($phpbb_root_path . $dirs . $cur_dir)) - { - // create the directory - $result = $this->_mkdir($dir[$i]); - $this->_chmod($dir[$i], $this->dir_perms); - } - - $this->_chdir($this->root_path . $dirs . $dir[$i]); - $dirs .= $cur_dir; - } - - $this->_chdir($this->root_path); - - /** - * @todo stack result into array to make sure every path creation has been taken care of - */ - return $result; - } - - /** - * Copy file from source location to destination location - */ - function copy_file($from_loc, $to_loc) - { - global $phpbb_root_path; - - $from_loc = ((strpos($from_loc, $phpbb_root_path) !== 0) ? $phpbb_root_path : '') . $from_loc; - $to_loc = $this->root_path . str_replace($phpbb_root_path, '', $to_loc); - - if (!file_exists($from_loc)) - { - return false; - } - - $result = $this->overwrite_file($from_loc, $to_loc); - - return $result; - } - - /** - * Remove file - */ - function delete_file($file) - { - global $phpbb_root_path; - - $file = $this->root_path . str_replace($phpbb_root_path, '', $file); - - return $this->_delete($file); - } - - /** - * Remove directory - * @todo remove child directories? - */ - function remove_dir($dir) - { - global $phpbb_root_path; - - $dir = $this->root_path . str_replace($phpbb_root_path, '', $dir); - - return $this->_rmdir($dir); - } - - /** - * Rename a file or folder - */ - function rename($old_handle, $new_handle) - { - global $phpbb_root_path; - - $old_handle = $this->root_path . str_replace($phpbb_root_path, '', $old_handle); - - return $this->_rename($old_handle, $new_handle); - } - - /** - * Check if a specified file exist... - */ - function file_exists($directory, $filename) - { - global $phpbb_root_path; - - $directory = $this->root_path . str_replace($phpbb_root_path, '', $directory); - - $this->_chdir($directory); - $result = $this->_ls(); - - if ($result !== false && is_array($result)) - { - return (in_array($filename, $result)) ? true : false; - } - - return false; - } - - /** - * Open session - */ - function open_session() - { - return $this->_init(); - } - - /** - * Close current session - */ - function close_session() - { - return $this->_close(); - } - - /** - * Determine methods able to be used - */ - static public function methods() - { - $methods = array(); - $disabled_functions = explode(',', @ini_get('disable_functions')); - - if (@extension_loaded('ftp')) - { - $methods[] = 'ftp'; - } - - if (!in_array('fsockopen', $disabled_functions)) - { - $methods[] = 'ftp_fsock'; - } - - return $methods; - } -} - -/** -* FTP transfer class -*/ -class ftp extends transfer -{ - /** - * Standard parameters for FTP session - */ - function __construct($host, $username, $password, $root_path, $port = 21, $timeout = 10) - { - $this->host = $host; - $this->port = $port; - $this->username = $username; - $this->password = $password; - $this->timeout = $timeout; - - // Make sure $this->root_path is layed out the same way as the $user->page['root_script_path'] value (/ at the end) - $this->root_path = str_replace('\\', '/', $this->root_path); - - if (!empty($root_path)) - { - $this->root_path = (($root_path[0] != '/' ) ? '/' : '') . $root_path . ((substr($root_path, -1, 1) == '/') ? '' : '/'); - } - - // Init some needed values - $this->transfer(); - - return; - } - - /** - * Requests data - */ - static public function data() - { - global $user; - - return array( - 'host' => 'localhost', - 'username' => 'anonymous', - 'password' => '', - 'root_path' => $user->page['root_script_path'], - 'port' => 21, - 'timeout' => 10 - ); - } - - /** - * Init FTP Session - * @access private - */ - function _init() - { - // connect to the server - $this->connection = @ftp_connect($this->host, $this->port, $this->timeout); - - if (!$this->connection) - { - return 'ERR_CONNECTING_SERVER'; - } - - // login to the server - if (!@ftp_login($this->connection, $this->username, $this->password)) - { - return 'ERR_UNABLE_TO_LOGIN'; - } - - // attempt to turn pasv mode on - @ftp_pasv($this->connection, true); - - // change to the root directory - if (!$this->_chdir($this->root_path)) - { - return 'ERR_CHANGING_DIRECTORY'; - } - - return true; - } - - /** - * Create Directory (MKDIR) - * @access private - */ - function _mkdir($dir) - { - return @ftp_mkdir($this->connection, $dir); - } - - /** - * Remove directory (RMDIR) - * @access private - */ - function _rmdir($dir) - { - return @ftp_rmdir($this->connection, $dir); - } - - /** - * Rename file - * @access private - */ - function _rename($old_handle, $new_handle) - { - return @ftp_rename($this->connection, $old_handle, $new_handle); - } - - /** - * Change current working directory (CHDIR) - * @access private - */ - function _chdir($dir = '') - { - if ($dir && $dir !== '/') - { - if (substr($dir, -1, 1) == '/') - { - $dir = substr($dir, 0, -1); - } - } - - return @ftp_chdir($this->connection, $dir); - } - - /** - * change file permissions (CHMOD) - * @access private - */ - function _chmod($file, $perms) - { - if (function_exists('ftp_chmod')) - { - $err = @ftp_chmod($this->connection, $perms, $file); - } - else - { - // Unfortunatly CHMOD is not expecting an octal value... - // We need to transform the integer (which was an octal) to an octal representation (to get the int) and then pass as is. ;) - $chmod_cmd = 'CHMOD ' . base_convert($perms, 10, 8) . ' ' . $file; - $err = $this->_site($chmod_cmd); - } - - return $err; - } - - /** - * Upload file to location (PUT) - * @access private - */ - function _put($from_file, $to_file) - { - // We only use the BINARY file mode to cicumvent rewrite actions from ftp server (mostly linefeeds being replaced) - $mode = FTP_BINARY; - - $to_dir = dirname($to_file); - $to_file = basename($to_file); - $this->_chdir($to_dir); - - $result = @ftp_put($this->connection, $to_file, $from_file, $mode); - $this->_chdir($this->root_path); - - return $result; - } - - /** - * Delete file (DELETE) - * @access private - */ - function _delete($file) - { - return @ftp_delete($this->connection, $file); - } - - /** - * Close ftp session (CLOSE) - * @access private - */ - function _close() - { - if (!$this->connection) - { - return false; - } - - return @ftp_quit($this->connection); - } - - /** - * Return current working directory (CWD) - * At the moment not used by parent class - * @access private - */ - function _cwd() - { - return @ftp_pwd($this->connection); - } - - /** - * Return list of files in a given directory (LS) - * @access private - */ - function _ls($dir = './') - { - $list = @ftp_nlist($this->connection, $dir); - - // See bug #46295 - Some FTP daemons don't like './' - if ($dir === './') - { - // Let's try some alternatives - $list = (empty($list)) ? @ftp_nlist($this->connection, '.') : $list; - $list = (empty($list)) ? @ftp_nlist($this->connection, '') : $list; - } - - // Return on error - if ($list === false) - { - return false; - } - - // Remove path if prepended - foreach ($list as $key => $item) - { - // Use same separator for item and dir - $item = str_replace('\\', '/', $item); - $dir = str_replace('\\', '/', $dir); - - if (!empty($dir) && strpos($item, $dir) === 0) - { - $item = substr($item, strlen($dir)); - } - - $list[$key] = $item; - } - - return $list; - } - - /** - * FTP SITE command (ftp-only function) - * @access private - */ - function _site($command) - { - return @ftp_site($this->connection, $command); - } -} - -/** -* FTP fsock transfer class -*/ -class ftp_fsock extends transfer -{ - var $data_connection; - - /** - * Standard parameters for FTP session - */ - function __construct($host, $username, $password, $root_path, $port = 21, $timeout = 10) - { - $this->host = $host; - $this->port = $port; - $this->username = $username; - $this->password = $password; - $this->timeout = $timeout; - - // Make sure $this->root_path is layed out the same way as the $user->page['root_script_path'] value (/ at the end) - $this->root_path = str_replace('\\', '/', $this->root_path); - - if (!empty($root_path)) - { - $this->root_path = (($root_path[0] != '/' ) ? '/' : '') . $root_path . ((substr($root_path, -1, 1) == '/') ? '' : '/'); - } - - // Init some needed values - parent::__construct(); - - return; - } - - /** - * Requests data - */ - static public function data() - { - global $user; - - return array( - 'host' => 'localhost', - 'username' => 'anonymous', - 'password' => '', - 'root_path' => $user->page['root_script_path'], - 'port' => 21, - 'timeout' => 10 - ); - } - - /** - * Init FTP Session - * @access private - */ - function _init() - { - $errno = 0; - $errstr = ''; - - // connect to the server - $this->connection = @fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout); - - if (!$this->connection || !$this->_check_command()) - { - return 'ERR_CONNECTING_SERVER'; - } - - @stream_set_timeout($this->connection, $this->timeout); - - // login - if (!$this->_send_command('USER', $this->username)) - { - return 'ERR_UNABLE_TO_LOGIN'; - } - - if (!$this->_send_command('PASS', $this->password)) - { - return 'ERR_UNABLE_TO_LOGIN'; - } - - // change to the root directory - if (!$this->_chdir($this->root_path)) - { - return 'ERR_CHANGING_DIRECTORY'; - } - - return true; - } - - /** - * Create Directory (MKDIR) - * @access private - */ - function _mkdir($dir) - { - return $this->_send_command('MKD', $dir); - } - - /** - * Remove directory (RMDIR) - * @access private - */ - function _rmdir($dir) - { - return $this->_send_command('RMD', $dir); - } - - /** - * Rename File - * @access private - */ - function _rename($old_handle, $new_handle) - { - $this->_send_command('RNFR', $old_handle); - return $this->_send_command('RNTO', $new_handle); - } - - /** - * Change current working directory (CHDIR) - * @access private - */ - function _chdir($dir = '') - { - if ($dir && $dir !== '/') - { - if (substr($dir, -1, 1) == '/') - { - $dir = substr($dir, 0, -1); - } - } - - return $this->_send_command('CWD', $dir); - } - - /** - * change file permissions (CHMOD) - * @access private - */ - function _chmod($file, $perms) - { - // Unfortunatly CHMOD is not expecting an octal value... - // We need to transform the integer (which was an octal) to an octal representation (to get the int) and then pass as is. ;) - return $this->_send_command('SITE CHMOD', base_convert($perms, 10, 8) . ' ' . $file); - } - - /** - * Upload file to location (PUT) - * @access private - */ - function _put($from_file, $to_file) - { - // We only use the BINARY file mode to cicumvent rewrite actions from ftp server (mostly linefeeds being replaced) - // 'I' == BINARY - // 'A' == ASCII - if (!$this->_send_command('TYPE', 'I')) - { - return false; - } - - // open the connection to send file over - if (!$this->_open_data_connection()) - { - return false; - } - - $this->_send_command('STOR', $to_file, false); - - // send the file - $fp = @fopen($from_file, 'rb'); - while (!@feof($fp)) - { - @fwrite($this->data_connection, @fread($fp, 4096)); - } - @fclose($fp); - - // close connection - $this->_close_data_connection(); - - return $this->_check_command(); - } - - /** - * Delete file (DELETE) - * @access private - */ - function _delete($file) - { - return $this->_send_command('DELE', $file); - } - - /** - * Close ftp session (CLOSE) - * @access private - */ - function _close() - { - if (!$this->connection) - { - return false; - } - - return $this->_send_command('QUIT'); - } - - /** - * Return current working directory (CWD) - * At the moment not used by parent class - * @access private - */ - function _cwd() - { - $this->_send_command('PWD', '', false); - return preg_replace('#^[0-9]{3} "(.+)" .+\r\n#', '\\1', $this->_check_command(true)); - } - - /** - * Return list of files in a given directory (LS) - * @access private - */ - function _ls($dir = './') - { - if (!$this->_open_data_connection()) - { - return false; - } - - $this->_send_command('NLST', $dir); - - $list = array(); - while (!@feof($this->data_connection)) - { - $filename = preg_replace('#[\r\n]#', '', @fgets($this->data_connection, 512)); - - if ($filename !== '') - { - $list[] = $filename; - } - } - $this->_close_data_connection(); - - // Clear buffer - $this->_check_command(); - - // See bug #46295 - Some FTP daemons don't like './' - if ($dir === './' && empty($list)) - { - // Let's try some alternatives - $list = $this->_ls('.'); - - if (empty($list)) - { - $list = $this->_ls(''); - } - - return $list; - } - - // Remove path if prepended - foreach ($list as $key => $item) - { - // Use same separator for item and dir - $item = str_replace('\\', '/', $item); - $dir = str_replace('\\', '/', $dir); - - if (!empty($dir) && strpos($item, $dir) === 0) - { - $item = substr($item, strlen($dir)); - } - - $list[$key] = $item; - } - - return $list; - } - - /** - * Send a command to server (FTP fsock only function) - * @access private - */ - function _send_command($command, $args = '', $check = true) - { - if (!empty($args)) - { - $command = "$command $args"; - } - - fwrite($this->connection, $command . "\r\n"); - - if ($check === true && !$this->_check_command()) - { - return false; - } - - return true; - } - - /** - * Opens a connection to send data (FTP fosck only function) - * @access private - */ - function _open_data_connection() - { - // Try to find out whether we have a IPv4 or IPv6 (control) connection - if (function_exists('stream_socket_get_name')) - { - $socket_name = stream_socket_get_name($this->connection, true); - $server_ip = substr($socket_name, 0, strrpos($socket_name, ':')); - } - - if (isset($server_ip) && filter_var($server_ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) // ipv4 - { - // Passive mode - $this->_send_command('PASV', '', false); - - if (!$ip_port = $this->_check_command(true)) - { - return false; - } - - // open the connection to start sending the file - if (!preg_match('#[0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]+,[0-9]+#', $ip_port, $temp)) - { - // bad ip and port - return false; - } - - $temp = explode(',', $temp[0]); - $server_ip = $temp[0] . '.' . $temp[1] . '.' . $temp[2] . '.' . $temp[3]; - $server_port = $temp[4] * 256 + $temp[5]; - } - else // ipv6 - { - // Extended Passive Mode - RFC2428 - $this->_send_command('EPSV', '', false); - - if (!$epsv_response = $this->_check_command(true)) - { - return false; - } - - // Response looks like "229 Entering Extended Passive Mode (|||12345|)" - // where 12345 is the tcp port for the data connection - if (!preg_match('#\(\|\|\|([0-9]+)\|\)#', $epsv_response, $match)) - { - return false; - } - $server_port = (int) $match[1]; - - // fsockopen expects IPv6 address in square brackets - $server_ip = "[$server_ip]"; - } - - $errno = 0; - $errstr = ''; - - if (!$this->data_connection = @fsockopen($server_ip, $server_port, $errno, $errstr, $this->timeout)) - { - return false; - } - @stream_set_timeout($this->data_connection, $this->timeout); - - return true; - } - - /** - * Closes a connection used to send data - * @access private - */ - function _close_data_connection() - { - return @fclose($this->data_connection); - } - - /** - * Check to make sure command was successful (FTP fsock only function) - * @access private - */ - function _check_command($return = false) - { - $response = ''; - - do - { - $result = @fgets($this->connection, 512); - $response .= $result; - } - while (substr($result, 3, 1) !== ' '); - - if (!preg_match('#^[123]#', $response)) - { - return false; - } - - return ($return) ? $response : true; - } -} diff --git a/install/update/new/includes/functions_user.php b/install/update/new/includes/functions_user.php deleted file mode 100644 index dc6e092..0000000 --- a/install/update/new/includes/functions_user.php +++ /dev/null @@ -1,3757 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* Obtain user_ids from usernames or vice versa. Returns false on -* success else the error string -* -* @param array &$user_id_ary The user ids to check or empty if usernames used -* @param array &$username_ary The usernames to check or empty if user ids used -* @param mixed $user_type Array of user types to check, false if not restricting by user type -* @param boolean $update_references If false, the supplied array is unset and appears unchanged from where it was called -* @return boolean|string Returns false on success, error string on failure -*/ -function user_get_id_name(&$user_id_ary, &$username_ary, $user_type = false, $update_references = false) -{ - global $db; - - // Are both arrays already filled? Yep, return else - // are neither array filled? - if ($user_id_ary && $username_ary) - { - return false; - } - else if (!$user_id_ary && !$username_ary) - { - return 'NO_USERS'; - } - - $which_ary = ($user_id_ary) ? 'user_id_ary' : 'username_ary'; - - if (${$which_ary} && !is_array(${$which_ary})) - { - ${$which_ary} = array(${$which_ary}); - } - - $sql_in = ($which_ary == 'user_id_ary') ? array_map('intval', ${$which_ary}) : array_map('utf8_clean_string', ${$which_ary}); - - // By unsetting the array here, the values passed in at the point user_get_id_name() was called will be retained. - // Otherwise, if we don't unset (as the array was passed by reference) the original array will be updated below. - if ($update_references === false) - { - unset(${$which_ary}); - } - - $user_id_ary = $username_ary = array(); - - // Grab the user id/username records - $sql_where = ($which_ary == 'user_id_ary') ? 'user_id' : 'username_clean'; - $sql = 'SELECT user_id, username - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set($sql_where, $sql_in); - - if ($user_type !== false && !empty($user_type)) - { - $sql .= ' AND ' . $db->sql_in_set('user_type', $user_type); - } - - $result = $db->sql_query($sql); - - if (!($row = $db->sql_fetchrow($result))) - { - $db->sql_freeresult($result); - return 'NO_USERS'; - } - - do - { - $username_ary[$row['user_id']] = $row['username']; - $user_id_ary[] = $row['user_id']; - } - while ($row = $db->sql_fetchrow($result)); - $db->sql_freeresult($result); - - return false; -} - -/** -* Get latest registered username and update database to reflect it -*/ -function update_last_username() -{ - global $config, $db; - - // Get latest username - $sql = 'SELECT user_id, username, user_colour - FROM ' . USERS_TABLE . ' - WHERE user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ') - ORDER BY user_id DESC'; - $result = $db->sql_query_limit($sql, 1); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - $config->set('newest_user_id', $row['user_id'], false); - $config->set('newest_username', $row['username'], false); - $config->set('newest_user_colour', $row['user_colour'], false); - } -} - -/** -* Updates a username across all relevant tables/fields -* -* @param string $old_name the old/current username -* @param string $new_name the new username -*/ -function user_update_name($old_name, $new_name) -{ - global $config, $db, $cache, $phpbb_dispatcher; - - $update_ary = array( - FORUMS_TABLE => array( - 'forum_last_poster_id' => 'forum_last_poster_name', - ), - MODERATOR_CACHE_TABLE => array( - 'user_id' => 'username', - ), - POSTS_TABLE => array( - 'poster_id' => 'post_username', - ), - TOPICS_TABLE => array( - 'topic_poster' => 'topic_first_poster_name', - 'topic_last_poster_id' => 'topic_last_poster_name', - ), - ); - - foreach ($update_ary as $table => $field_ary) - { - foreach ($field_ary as $id_field => $name_field) - { - $sql = "UPDATE $table - SET $name_field = '" . $db->sql_escape($new_name) . "' - WHERE $name_field = '" . $db->sql_escape($old_name) . "' - AND $id_field <> " . ANONYMOUS; - $db->sql_query($sql); - } - } - - if ($config['newest_username'] == $old_name) - { - $config->set('newest_username', $new_name, false); - } - - /** - * Update a username when it is changed - * - * @event core.update_username - * @var string old_name The old username that is replaced - * @var string new_name The new username - * @since 3.1.0-a1 - */ - $vars = array('old_name', 'new_name'); - extract($phpbb_dispatcher->trigger_event('core.update_username', compact($vars))); - - // Because some tables/caches use username-specific data we need to purge this here. - $cache->destroy('sql', MODERATOR_CACHE_TABLE); -} - -/** -* Adds an user -* -* @param mixed $user_row An array containing the following keys (and the appropriate values): username, group_id (the group to place the user in), user_email and the user_type(usually 0). Additional entries not overridden by defaults will be forwarded. -* @param array $cp_data custom profile fields, see custom_profile::build_insert_sql_array -* @param array $notifications_data The notifications settings for the new user -* @return the new user's ID. -*/ -function user_add($user_row, $cp_data = false, $notifications_data = null) -{ - global $db, $config; - global $phpbb_dispatcher, $phpbb_container; - - if (empty($user_row['username']) || !isset($user_row['group_id']) || !isset($user_row['user_email']) || !isset($user_row['user_type'])) - { - return false; - } - - $username_clean = utf8_clean_string($user_row['username']); - - if (empty($username_clean)) - { - return false; - } - - $sql_ary = array( - 'username' => $user_row['username'], - 'username_clean' => $username_clean, - 'user_password' => (isset($user_row['user_password'])) ? $user_row['user_password'] : '', - 'user_email' => strtolower($user_row['user_email']), - 'group_id' => $user_row['group_id'], - 'user_type' => $user_row['user_type'], - ); - - // These are the additional vars able to be specified - $additional_vars = array( - 'user_permissions' => '', - 'user_timezone' => $config['board_timezone'], - 'user_dateformat' => $config['default_dateformat'], - 'user_lang' => $config['default_lang'], - 'user_style' => (int) $config['default_style'], - 'user_actkey' => '', - 'user_ip' => '', - 'user_regdate' => time(), - 'user_passchg' => time(), - 'user_options' => 230271, - // We do not set the new flag here - registration scripts need to specify it - 'user_new' => 0, - - 'user_inactive_reason' => 0, - 'user_inactive_time' => 0, - 'user_lastmark' => time(), - 'user_lastvisit' => 0, - 'user_lastpost_time' => 0, - 'user_lastpage' => '', - 'user_posts' => 0, - 'user_colour' => '', - 'user_avatar' => '', - 'user_avatar_type' => '', - 'user_avatar_width' => 0, - 'user_avatar_height' => 0, - 'user_new_privmsg' => 0, - 'user_unread_privmsg' => 0, - 'user_last_privmsg' => 0, - 'user_message_rules' => 0, - 'user_full_folder' => PRIVMSGS_NO_BOX, - 'user_emailtime' => 0, - - 'user_notify' => 0, - 'user_notify_pm' => 1, - 'user_notify_type' => NOTIFY_EMAIL, - 'user_allow_pm' => 1, - 'user_allow_viewonline' => 1, - 'user_allow_viewemail' => 1, - 'user_allow_massemail' => 1, - - 'user_sig' => '', - 'user_sig_bbcode_uid' => '', - 'user_sig_bbcode_bitfield' => '', - - 'user_form_salt' => unique_id(), - ); - - // Now fill the sql array with not required variables - foreach ($additional_vars as $key => $default_value) - { - $sql_ary[$key] = (isset($user_row[$key])) ? $user_row[$key] : $default_value; - } - - // Any additional variables in $user_row not covered above? - $remaining_vars = array_diff(array_keys($user_row), array_keys($sql_ary)); - - // Now fill our sql array with the remaining vars - if (count($remaining_vars)) - { - foreach ($remaining_vars as $key) - { - $sql_ary[$key] = $user_row[$key]; - } - } - - /** - * Use this event to modify the values to be inserted when a user is added - * - * @event core.user_add_modify_data - * @var array user_row Array of user details submitted to user_add - * @var array cp_data Array of Custom profile fields submitted to user_add - * @var array sql_ary Array of data to be inserted when a user is added - * @var array notifications_data Array of notification data to be inserted when a user is added - * @since 3.1.0-a1 - * @changed 3.1.0-b5 Added user_row and cp_data - * @changed 3.1.11-RC1 Added notifications_data - */ - $vars = array('user_row', 'cp_data', 'sql_ary', 'notifications_data'); - extract($phpbb_dispatcher->trigger_event('core.user_add_modify_data', compact($vars))); - - $sql = 'INSERT INTO ' . USERS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); - $db->sql_query($sql); - - $user_id = $db->sql_nextid(); - - // Insert Custom Profile Fields - if ($cp_data !== false && count($cp_data)) - { - $cp_data['user_id'] = (int) $user_id; - - /* @var $cp \phpbb\profilefields\manager */ - $cp = $phpbb_container->get('profilefields.manager'); - $sql = 'INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' ' . - $db->sql_build_array('INSERT', $cp->build_insert_sql_array($cp_data)); - $db->sql_query($sql); - } - - // Place into appropriate group... - $sql = 'INSERT INTO ' . USER_GROUP_TABLE . ' ' . $db->sql_build_array('INSERT', array( - 'user_id' => (int) $user_id, - 'group_id' => (int) $user_row['group_id'], - 'user_pending' => 0) - ); - $db->sql_query($sql); - - // Now make it the users default group... - group_set_user_default($user_row['group_id'], array($user_id), false); - - // Add to newly registered users group if user_new is 1 - if ($config['new_member_post_limit'] && $sql_ary['user_new']) - { - $sql = 'SELECT group_id - FROM ' . GROUPS_TABLE . " - WHERE group_name = 'NEWLY_REGISTERED' - AND group_type = " . GROUP_SPECIAL; - $result = $db->sql_query($sql); - $add_group_id = (int) $db->sql_fetchfield('group_id'); - $db->sql_freeresult($result); - - if ($add_group_id) - { - global $phpbb_log; - - // Because these actions only fill the log unnecessarily, we disable it - $phpbb_log->disable('admin'); - - // Add user to "newly registered users" group and set to default group if admin specified so. - if ($config['new_member_group_default']) - { - group_user_add($add_group_id, $user_id, false, false, true); - $user_row['group_id'] = $add_group_id; - } - else - { - group_user_add($add_group_id, $user_id); - } - - $phpbb_log->enable('admin'); - } - } - - // set the newest user and adjust the user count if the user is a normal user and no activation mail is sent - if ($user_row['user_type'] == USER_NORMAL || $user_row['user_type'] == USER_FOUNDER) - { - $config->set('newest_user_id', $user_id, false); - $config->set('newest_username', $user_row['username'], false); - $config->increment('num_users', 1, false); - - $sql = 'SELECT group_colour - FROM ' . GROUPS_TABLE . ' - WHERE group_id = ' . (int) $user_row['group_id']; - $result = $db->sql_query_limit($sql, 1); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $config->set('newest_user_colour', $row['group_colour'], false); - } - - // Use default notifications settings if notifications_data is not set - if ($notifications_data === null) - { - $notifications_data = array( - array( - 'item_type' => 'notification.type.post', - 'method' => 'notification.method.email', - ), - array( - 'item_type' => 'notification.type.topic', - 'method' => 'notification.method.email', - ), - ); - } - - /** - * Modify the notifications data to be inserted in the database when a user is added - * - * @event core.user_add_modify_notifications_data - * @var array user_row Array of user details submitted to user_add - * @var array cp_data Array of Custom profile fields submitted to user_add - * @var array sql_ary Array of data to be inserted when a user is added - * @var array notifications_data Array of notification data to be inserted when a user is added - * @since 3.2.2-RC1 - */ - $vars = array('user_row', 'cp_data', 'sql_ary', 'notifications_data'); - extract($phpbb_dispatcher->trigger_event('core.user_add_modify_notifications_data', compact($vars))); - - // Subscribe user to notifications if necessary - if (!empty($notifications_data)) - { - /* @var $phpbb_notifications \phpbb\notification\manager */ - $phpbb_notifications = $phpbb_container->get('notification_manager'); - foreach ($notifications_data as $subscription) - { - $phpbb_notifications->add_subscription($subscription['item_type'], 0, $subscription['method'], $user_id); - } - } - - /** - * Event that returns user id, user details and user CPF of newly registered user - * - * @event core.user_add_after - * @var int user_id User id of newly registered user - * @var array user_row Array of user details submitted to user_add - * @var array cp_data Array of Custom profile fields submitted to user_add - * @since 3.1.0-b5 - */ - $vars = array('user_id', 'user_row', 'cp_data'); - extract($phpbb_dispatcher->trigger_event('core.user_add_after', compact($vars))); - - return $user_id; -} - -/** - * Remove User - * - * @param string $mode Either 'retain' or 'remove' - * @param mixed $user_ids Either an array of integers or an integer - * @param bool $retain_username - * @return bool - */ -function user_delete($mode, $user_ids, $retain_username = true) -{ - global $cache, $config, $db, $user, $phpbb_dispatcher, $phpbb_container; - global $phpbb_root_path, $phpEx; - - $db->sql_transaction('begin'); - - $user_rows = array(); - if (!is_array($user_ids)) - { - $user_ids = array($user_ids); - } - - $user_id_sql = $db->sql_in_set('user_id', $user_ids); - - $sql = 'SELECT * - FROM ' . USERS_TABLE . ' - WHERE ' . $user_id_sql; - $result = $db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) - { - $user_rows[(int) $row['user_id']] = $row; - } - $db->sql_freeresult($result); - - if (empty($user_rows)) - { - return false; - } - - /** - * Event before a user is deleted - * - * @event core.delete_user_before - * @var string mode Mode of deletion (retain/delete posts) - * @var array user_ids IDs of the deleted user - * @var mixed retain_username True if username should be retained - * or false if not - * @var array user_rows Array containing data of the deleted users - * @since 3.1.0-a1 - * @changed 3.2.4-RC1 Added user_rows - */ - $vars = array('mode', 'user_ids', 'retain_username', 'user_rows'); - extract($phpbb_dispatcher->trigger_event('core.delete_user_before', compact($vars))); - - // Before we begin, we will remove the reports the user issued. - $sql = 'SELECT r.post_id, p.topic_id - FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . ' p - WHERE ' . $db->sql_in_set('r.user_id', $user_ids) . ' - AND p.post_id = r.post_id'; - $result = $db->sql_query($sql); - - $report_posts = $report_topics = array(); - while ($row = $db->sql_fetchrow($result)) - { - $report_posts[] = $row['post_id']; - $report_topics[] = $row['topic_id']; - } - $db->sql_freeresult($result); - - if (count($report_posts)) - { - $report_posts = array_unique($report_posts); - $report_topics = array_unique($report_topics); - - // Get a list of topics that still contain reported posts - $sql = 'SELECT DISTINCT topic_id - FROM ' . POSTS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', $report_topics) . ' - AND post_reported = 1 - AND ' . $db->sql_in_set('post_id', $report_posts, true); - $result = $db->sql_query($sql); - - $keep_report_topics = array(); - while ($row = $db->sql_fetchrow($result)) - { - $keep_report_topics[] = $row['topic_id']; - } - $db->sql_freeresult($result); - - if (count($keep_report_topics)) - { - $report_topics = array_diff($report_topics, $keep_report_topics); - } - unset($keep_report_topics); - - // Now set the flags back - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET post_reported = 0 - WHERE ' . $db->sql_in_set('post_id', $report_posts); - $db->sql_query($sql); - - if (count($report_topics)) - { - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_reported = 0 - WHERE ' . $db->sql_in_set('topic_id', $report_topics); - $db->sql_query($sql); - } - } - - // Remove reports - $db->sql_query('DELETE FROM ' . REPORTS_TABLE . ' WHERE ' . $user_id_sql); - - $num_users_delta = 0; - - // Get auth provider collection in case accounts might need to be unlinked - $provider_collection = $phpbb_container->get('auth.provider_collection'); - - // Some things need to be done in the loop (if the query changes based - // on which user is currently being deleted) - $added_guest_posts = 0; - foreach ($user_rows as $user_id => $user_row) - { - if ($user_row['user_avatar'] && $user_row['user_avatar_type'] == 'avatar.driver.upload') - { - avatar_delete('user', $user_row); - } - - // Unlink accounts - foreach ($provider_collection as $provider_name => $auth_provider) - { - $provider_data = $auth_provider->get_auth_link_data($user_id); - - if ($provider_data !== null) - { - $link_data = array( - 'user_id' => $user_id, - 'link_method' => 'user_delete', - ); - - // BLOCK_VARS might contain hidden fields necessary for unlinking accounts - if (isset($provider_data['BLOCK_VARS']) && is_array($provider_data['BLOCK_VARS'])) - { - foreach ($provider_data['BLOCK_VARS'] as $provider_service) - { - if (!array_key_exists('HIDDEN_FIELDS', $provider_service)) - { - $provider_service['HIDDEN_FIELDS'] = array(); - } - - $auth_provider->unlink_account(array_merge($link_data, $provider_service['HIDDEN_FIELDS'])); - } - } - else - { - $auth_provider->unlink_account($link_data); - } - } - } - - // Decrement number of users if this user is active - if ($user_row['user_type'] != USER_INACTIVE && $user_row['user_type'] != USER_IGNORE) - { - --$num_users_delta; - } - - switch ($mode) - { - case 'retain': - if ($retain_username === false) - { - $post_username = $user->lang['GUEST']; - } - else - { - $post_username = $user_row['username']; - } - - // If the user is inactive and newly registered - // we assume no posts from the user, and save - // the queries - if ($user_row['user_type'] != USER_INACTIVE || $user_row['user_inactive_reason'] != INACTIVE_REGISTER || $user_row['user_posts']) - { - // When we delete these users and retain the posts, we must assign all the data to the guest user - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET forum_last_poster_id = ' . ANONYMOUS . ", forum_last_poster_name = '" . $db->sql_escape($post_username) . "', forum_last_poster_colour = '' - WHERE forum_last_poster_id = $user_id"; - $db->sql_query($sql); - - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET poster_id = ' . ANONYMOUS . ", post_username = '" . $db->sql_escape($post_username) . "' - WHERE poster_id = $user_id"; - $db->sql_query($sql); - - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_poster = ' . ANONYMOUS . ", topic_first_poster_name = '" . $db->sql_escape($post_username) . "', topic_first_poster_colour = '' - WHERE topic_poster = $user_id"; - $db->sql_query($sql); - - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_last_poster_id = ' . ANONYMOUS . ", topic_last_poster_name = '" . $db->sql_escape($post_username) . "', topic_last_poster_colour = '' - WHERE topic_last_poster_id = $user_id"; - $db->sql_query($sql); - - // Since we change every post by this author, we need to count this amount towards the anonymous user - - if ($user_row['user_posts']) - { - $added_guest_posts += $user_row['user_posts']; - } - } - break; - - case 'remove': - // there is nothing variant specific to deleting posts - break; - } - } - - if ($num_users_delta != 0) - { - $config->increment('num_users', $num_users_delta, false); - } - - // Now do the invariant tasks - // all queries performed in one call of this function are in a single transaction - // so this is kosher - if ($mode == 'retain') - { - // Assign more data to the Anonymous user - $sql = 'UPDATE ' . ATTACHMENTS_TABLE . ' - SET poster_id = ' . ANONYMOUS . ' - WHERE ' . $db->sql_in_set('poster_id', $user_ids); - $db->sql_query($sql); - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_posts = user_posts + ' . $added_guest_posts . ' - WHERE user_id = ' . ANONYMOUS; - $db->sql_query($sql); - } - else if ($mode == 'remove') - { - if (!function_exists('delete_posts')) - { - include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); - } - - // Delete posts, attachments, etc. - // delete_posts can handle any number of IDs in its second argument - delete_posts('poster_id', $user_ids); - } - - $table_ary = [ - USERS_TABLE, - USER_GROUP_TABLE, - TOPICS_WATCH_TABLE, - FORUMS_WATCH_TABLE, - ACL_USERS_TABLE, - TOPICS_TRACK_TABLE, - TOPICS_POSTED_TABLE, - FORUMS_TRACK_TABLE, - PROFILE_FIELDS_DATA_TABLE, - MODERATOR_CACHE_TABLE, - DRAFTS_TABLE, - BOOKMARKS_TABLE, - SESSIONS_KEYS_TABLE, - PRIVMSGS_FOLDER_TABLE, - PRIVMSGS_RULES_TABLE, - $phpbb_container->getParameter('tables.auth_provider_oauth_token_storage'), - $phpbb_container->getParameter('tables.auth_provider_oauth_states'), - $phpbb_container->getParameter('tables.auth_provider_oauth_account_assoc'), - $phpbb_container->getParameter('tables.user_notifications') - ]; - - // Ignore errors on deleting from non-existent tables, e.g. when migrating - $db->sql_return_on_error(true); - // Delete the miscellaneous (non-post) data for the user - foreach ($table_ary as $table) - { - $sql = "DELETE FROM $table - WHERE " . $user_id_sql; - $db->sql_query($sql); - } - $db->sql_return_on_error(); - - $cache->destroy('sql', MODERATOR_CACHE_TABLE); - - // Change user_id to anonymous for posts edited by this user - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET post_edit_user = ' . ANONYMOUS . ' - WHERE ' . $db->sql_in_set('post_edit_user', $user_ids); - $db->sql_query($sql); - - // Change user_id to anonymous for pms edited by this user - $sql = 'UPDATE ' . PRIVMSGS_TABLE . ' - SET message_edit_user = ' . ANONYMOUS . ' - WHERE ' . $db->sql_in_set('message_edit_user', $user_ids); - $db->sql_query($sql); - - // Change user_id to anonymous for posts deleted by this user - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET post_delete_user = ' . ANONYMOUS . ' - WHERE ' . $db->sql_in_set('post_delete_user', $user_ids); - $db->sql_query($sql); - - // Change user_id to anonymous for topics deleted by this user - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_delete_user = ' . ANONYMOUS . ' - WHERE ' . $db->sql_in_set('topic_delete_user', $user_ids); - $db->sql_query($sql); - - // Delete user log entries about this user - $sql = 'DELETE FROM ' . LOG_TABLE . ' - WHERE ' . $db->sql_in_set('reportee_id', $user_ids); - $db->sql_query($sql); - - // Change user_id to anonymous for this users triggered events - $sql = 'UPDATE ' . LOG_TABLE . ' - SET user_id = ' . ANONYMOUS . ' - WHERE ' . $user_id_sql; - $db->sql_query($sql); - - // Delete the user_id from the zebra table - $sql = 'DELETE FROM ' . ZEBRA_TABLE . ' - WHERE ' . $user_id_sql . ' - OR ' . $db->sql_in_set('zebra_id', $user_ids); - $db->sql_query($sql); - - // Delete the user_id from the banlist - $sql = 'DELETE FROM ' . BANLIST_TABLE . ' - WHERE ' . $db->sql_in_set('ban_userid', $user_ids); - $db->sql_query($sql); - - // Delete the user_id from the session table - $sql = 'DELETE FROM ' . SESSIONS_TABLE . ' - WHERE ' . $db->sql_in_set('session_user_id', $user_ids); - $db->sql_query($sql); - - // Clean the private messages tables from the user - if (!function_exists('phpbb_delete_user_pms')) - { - include($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx); - } - phpbb_delete_users_pms($user_ids); - - $phpbb_notifications = $phpbb_container->get('notification_manager'); - $phpbb_notifications->delete_notifications('notification.type.admin_activate_user', $user_ids); - - $db->sql_transaction('commit'); - - /** - * Event after a user is deleted - * - * @event core.delete_user_after - * @var string mode Mode of deletion (retain/delete posts) - * @var array user_ids IDs of the deleted user - * @var mixed retain_username True if username should be retained - * or false if not - * @var array user_rows Array containing data of the deleted users - * @since 3.1.0-a1 - * @changed 3.2.2-RC1 Added user_rows - */ - $vars = array('mode', 'user_ids', 'retain_username', 'user_rows'); - extract($phpbb_dispatcher->trigger_event('core.delete_user_after', compact($vars))); - - // Reset newest user info if appropriate - if (in_array($config['newest_user_id'], $user_ids)) - { - update_last_username(); - } - - return false; -} - -/** -* Flips user_type from active to inactive and vice versa, handles group membership updates -* -* @param string $mode can be flip for flipping from active/inactive, activate or deactivate -*/ -function user_active_flip($mode, $user_id_ary, $reason = INACTIVE_MANUAL) -{ - global $config, $db, $user, $auth, $phpbb_dispatcher; - - $deactivated = $activated = 0; - $sql_statements = array(); - - if (!is_array($user_id_ary)) - { - $user_id_ary = array($user_id_ary); - } - - if (!count($user_id_ary)) - { - return; - } - - $sql = 'SELECT user_id, group_id, user_type, user_inactive_reason - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('user_id', $user_id_ary); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $sql_ary = array(); - - if ($row['user_type'] == USER_IGNORE || $row['user_type'] == USER_FOUNDER || - ($mode == 'activate' && $row['user_type'] != USER_INACTIVE) || - ($mode == 'deactivate' && $row['user_type'] == USER_INACTIVE)) - { - continue; - } - - if ($row['user_type'] == USER_INACTIVE) - { - $activated++; - } - else - { - $deactivated++; - - // Remove the users session key... - $user->reset_login_keys($row['user_id']); - } - - $sql_ary += array( - 'user_type' => ($row['user_type'] == USER_NORMAL) ? USER_INACTIVE : USER_NORMAL, - 'user_inactive_time' => ($row['user_type'] == USER_NORMAL) ? time() : 0, - 'user_inactive_reason' => ($row['user_type'] == USER_NORMAL) ? $reason : 0, - ); - - $sql_statements[$row['user_id']] = $sql_ary; - } - $db->sql_freeresult($result); - - /** - * Check or modify activated/deactivated users data before submitting it to the database - * - * @event core.user_active_flip_before - * @var string mode User type changing mode, can be: flip|activate|deactivate - * @var int reason Reason for changing user type, can be: INACTIVE_REGISTER|INACTIVE_PROFILE|INACTIVE_MANUAL|INACTIVE_REMIND - * @var int activated The number of users to be activated - * @var int deactivated The number of users to be deactivated - * @var array user_id_ary Array with user ids to change user type - * @var array sql_statements Array with users data to submit to the database, keys: user ids, values: arrays with user data - * @since 3.1.4-RC1 - */ - $vars = array('mode', 'reason', 'activated', 'deactivated', 'user_id_ary', 'sql_statements'); - extract($phpbb_dispatcher->trigger_event('core.user_active_flip_before', compact($vars))); - - if (count($sql_statements)) - { - foreach ($sql_statements as $user_id => $sql_ary) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE user_id = ' . $user_id; - $db->sql_query($sql); - } - - $auth->acl_clear_prefetch(array_keys($sql_statements)); - } - - /** - * Perform additional actions after the users have been activated/deactivated - * - * @event core.user_active_flip_after - * @var string mode User type changing mode, can be: flip|activate|deactivate - * @var int reason Reason for changing user type, can be: INACTIVE_REGISTER|INACTIVE_PROFILE|INACTIVE_MANUAL|INACTIVE_REMIND - * @var int activated The number of users to be activated - * @var int deactivated The number of users to be deactivated - * @var array user_id_ary Array with user ids to change user type - * @var array sql_statements Array with users data to submit to the database, keys: user ids, values: arrays with user data - * @since 3.1.4-RC1 - */ - $vars = array('mode', 'reason', 'activated', 'deactivated', 'user_id_ary', 'sql_statements'); - extract($phpbb_dispatcher->trigger_event('core.user_active_flip_after', compact($vars))); - - if ($deactivated) - { - $config->increment('num_users', $deactivated * (-1), false); - } - - if ($activated) - { - $config->increment('num_users', $activated, false); - } - - // Update latest username - update_last_username(); -} - -/** -* Add a ban or ban exclusion to the banlist. Bans either a user, an IP or an email address -* -* @param string $mode Type of ban. One of the following: user, ip, email -* @param mixed $ban Banned entity. Either string or array with usernames, ips or email addresses -* @param int $ban_len Ban length in minutes -* @param string $ban_len_other Ban length as a date (YYYY-MM-DD) -* @param boolean $ban_exclude Exclude these entities from banning? -* @param string $ban_reason String describing the reason for this ban -* @return boolean -*/ -function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reason, $ban_give_reason = '') -{ - global $db, $user, $cache, $phpbb_log; - - // Delete stale bans - $sql = 'DELETE FROM ' . BANLIST_TABLE . ' - WHERE ban_end < ' . time() . ' - AND ban_end <> 0'; - $db->sql_query($sql); - - $ban_list = (!is_array($ban)) ? array_unique(explode("\n", $ban)) : $ban; - $ban_list_log = implode(', ', $ban_list); - - $current_time = time(); - - // Set $ban_end to the unix time when the ban should end. 0 is a permanent ban. - if ($ban_len) - { - if ($ban_len != -1 || !$ban_len_other) - { - $ban_end = max($current_time, $current_time + ($ban_len) * 60); - } - else - { - $ban_other = explode('-', $ban_len_other); - if (count($ban_other) == 3 && ((int) $ban_other[0] < 9999) && - (strlen($ban_other[0]) == 4) && (strlen($ban_other[1]) == 2) && (strlen($ban_other[2]) == 2)) - { - $ban_end = max($current_time, $user->create_datetime() - ->setDate((int) $ban_other[0], (int) $ban_other[1], (int) $ban_other[2]) - ->setTime(0, 0, 0) - ->getTimestamp() + $user->timezone->getOffset(new DateTime('UTC'))); - } - else - { - trigger_error('LENGTH_BAN_INVALID', E_USER_WARNING); - } - } - } - else - { - $ban_end = 0; - } - - $founder = $founder_names = array(); - - if (!$ban_exclude) - { - // Create a list of founder... - $sql = 'SELECT user_id, user_email, username_clean - FROM ' . USERS_TABLE . ' - WHERE user_type = ' . USER_FOUNDER; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $founder[$row['user_id']] = $row['user_email']; - $founder_names[$row['user_id']] = $row['username_clean']; - } - $db->sql_freeresult($result); - } - - $banlist_ary = array(); - - switch ($mode) - { - case 'user': - $type = 'ban_userid'; - - // At the moment we do not support wildcard username banning - - // Select the relevant user_ids. - $sql_usernames = array(); - - foreach ($ban_list as $username) - { - $username = trim($username); - if ($username != '') - { - $clean_name = utf8_clean_string($username); - if ($clean_name == $user->data['username_clean']) - { - trigger_error('CANNOT_BAN_YOURSELF', E_USER_WARNING); - } - if (in_array($clean_name, $founder_names)) - { - trigger_error('CANNOT_BAN_FOUNDER', E_USER_WARNING); - } - $sql_usernames[] = $clean_name; - } - } - - // Make sure we have been given someone to ban - if (!count($sql_usernames)) - { - trigger_error('NO_USER_SPECIFIED', E_USER_WARNING); - } - - $sql = 'SELECT user_id - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('username_clean', $sql_usernames); - - // Do not allow banning yourself, the guest account, or founders. - $non_bannable = array($user->data['user_id'], ANONYMOUS); - if (count($founder)) - { - $sql .= ' AND ' . $db->sql_in_set('user_id', array_merge(array_keys($founder), $non_bannable), true); - } - else - { - $sql .= ' AND ' . $db->sql_in_set('user_id', $non_bannable, true); - } - - $result = $db->sql_query($sql); - - if ($row = $db->sql_fetchrow($result)) - { - do - { - $banlist_ary[] = (int) $row['user_id']; - } - while ($row = $db->sql_fetchrow($result)); - } - else - { - $db->sql_freeresult($result); - trigger_error('NO_USERS', E_USER_WARNING); - } - $db->sql_freeresult($result); - break; - - case 'ip': - $type = 'ban_ip'; - - foreach ($ban_list as $ban_item) - { - if (preg_match('#^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})[ ]*\-[ ]*([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$#', trim($ban_item), $ip_range_explode)) - { - // This is an IP range - // Don't ask about all this, just don't ask ... ! - $ip_1_counter = $ip_range_explode[1]; - $ip_1_end = $ip_range_explode[5]; - - while ($ip_1_counter <= $ip_1_end) - { - $ip_2_counter = ($ip_1_counter == $ip_range_explode[1]) ? $ip_range_explode[2] : 0; - $ip_2_end = ($ip_1_counter < $ip_1_end) ? 254 : $ip_range_explode[6]; - - if ($ip_2_counter == 0 && $ip_2_end == 254) - { - $ip_2_counter = 256; - - $banlist_ary[] = "$ip_1_counter.*"; - } - - while ($ip_2_counter <= $ip_2_end) - { - $ip_3_counter = ($ip_2_counter == $ip_range_explode[2] && $ip_1_counter == $ip_range_explode[1]) ? $ip_range_explode[3] : 0; - $ip_3_end = ($ip_2_counter < $ip_2_end || $ip_1_counter < $ip_1_end) ? 254 : $ip_range_explode[7]; - - if ($ip_3_counter == 0 && $ip_3_end == 254) - { - $ip_3_counter = 256; - - $banlist_ary[] = "$ip_1_counter.$ip_2_counter.*"; - } - - while ($ip_3_counter <= $ip_3_end) - { - $ip_4_counter = ($ip_3_counter == $ip_range_explode[3] && $ip_2_counter == $ip_range_explode[2] && $ip_1_counter == $ip_range_explode[1]) ? $ip_range_explode[4] : 0; - $ip_4_end = ($ip_3_counter < $ip_3_end || $ip_2_counter < $ip_2_end) ? 254 : $ip_range_explode[8]; - - if ($ip_4_counter == 0 && $ip_4_end == 254) - { - $ip_4_counter = 256; - - $banlist_ary[] = "$ip_1_counter.$ip_2_counter.$ip_3_counter.*"; - } - - while ($ip_4_counter <= $ip_4_end) - { - $banlist_ary[] = "$ip_1_counter.$ip_2_counter.$ip_3_counter.$ip_4_counter"; - $ip_4_counter++; - } - $ip_3_counter++; - } - $ip_2_counter++; - } - $ip_1_counter++; - } - } - else if (preg_match('#^([0-9]{1,3})\.([0-9\*]{1,3})\.([0-9\*]{1,3})\.([0-9\*]{1,3})$#', trim($ban_item)) || preg_match('#^[a-f0-9:]+\*?$#i', trim($ban_item))) - { - // Normal IP address - $banlist_ary[] = trim($ban_item); - } - else if (preg_match('#^\*$#', trim($ban_item))) - { - // Ban all IPs - $banlist_ary[] = '*'; - } - else if (preg_match('#^([\w\-_]\.?){2,}$#is', trim($ban_item))) - { - // hostname - $ip_ary = gethostbynamel(trim($ban_item)); - - if (!empty($ip_ary)) - { - foreach ($ip_ary as $ip) - { - if ($ip) - { - if (strlen($ip) > 40) - { - continue; - } - - $banlist_ary[] = $ip; - } - } - } - } - - if (empty($banlist_ary)) - { - trigger_error('NO_IPS_DEFINED', E_USER_WARNING); - } - } - break; - - case 'email': - $type = 'ban_email'; - - foreach ($ban_list as $ban_item) - { - $ban_item = trim($ban_item); - - if (preg_match('#^.*?@*|(([a-z0-9\-]+\.)+([a-z]{2,3}))$#i', $ban_item)) - { - if (strlen($ban_item) > 100) - { - continue; - } - - if (!count($founder) || !in_array($ban_item, $founder)) - { - $banlist_ary[] = $ban_item; - } - } - } - - if (count($ban_list) == 0) - { - trigger_error('NO_EMAILS_DEFINED', E_USER_WARNING); - } - break; - - default: - trigger_error('NO_MODE', E_USER_WARNING); - break; - } - - // Fetch currently set bans of the specified type and exclude state. Prevent duplicate bans. - $sql_where = ($type == 'ban_userid') ? 'ban_userid <> 0' : "$type <> ''"; - - $sql = "SELECT $type - FROM " . BANLIST_TABLE . " - WHERE $sql_where - AND ban_exclude = " . (int) $ban_exclude; - $result = $db->sql_query($sql); - - // Reset $sql_where, because we use it later... - $sql_where = ''; - - if ($row = $db->sql_fetchrow($result)) - { - $banlist_ary_tmp = array(); - do - { - switch ($mode) - { - case 'user': - $banlist_ary_tmp[] = $row['ban_userid']; - break; - - case 'ip': - $banlist_ary_tmp[] = $row['ban_ip']; - break; - - case 'email': - $banlist_ary_tmp[] = $row['ban_email']; - break; - } - } - while ($row = $db->sql_fetchrow($result)); - - $banlist_ary_tmp = array_intersect($banlist_ary, $banlist_ary_tmp); - - if (count($banlist_ary_tmp)) - { - // One or more entities are already banned/excluded, delete the existing bans, so they can be re-inserted with the given new length - $sql = 'DELETE FROM ' . BANLIST_TABLE . ' - WHERE ' . $db->sql_in_set($type, $banlist_ary_tmp) . ' - AND ban_exclude = ' . (int) $ban_exclude; - $db->sql_query($sql); - } - - unset($banlist_ary_tmp); - } - $db->sql_freeresult($result); - - // We have some entities to ban - if (count($banlist_ary)) - { - $sql_ary = array(); - - foreach ($banlist_ary as $ban_entry) - { - $sql_ary[] = array( - $type => $ban_entry, - 'ban_start' => (int) $current_time, - 'ban_end' => (int) $ban_end, - 'ban_exclude' => (int) $ban_exclude, - 'ban_reason' => (string) $ban_reason, - 'ban_give_reason' => (string) $ban_give_reason, - ); - } - - $db->sql_multi_insert(BANLIST_TABLE, $sql_ary); - - // If we are banning we want to logout anyone matching the ban - if (!$ban_exclude) - { - switch ($mode) - { - case 'user': - $sql_where = 'WHERE ' . $db->sql_in_set('session_user_id', $banlist_ary); - break; - - case 'ip': - $sql_where = 'WHERE ' . $db->sql_in_set('session_ip', $banlist_ary); - break; - - case 'email': - $banlist_ary_sql = array(); - - foreach ($banlist_ary as $ban_entry) - { - $banlist_ary_sql[] = (string) str_replace('*', '%', $ban_entry); - } - - $sql = 'SELECT user_id - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('user_email', $banlist_ary_sql); - $result = $db->sql_query($sql); - - $sql_in = array(); - - if ($row = $db->sql_fetchrow($result)) - { - do - { - $sql_in[] = $row['user_id']; - } - while ($row = $db->sql_fetchrow($result)); - - $sql_where = 'WHERE ' . $db->sql_in_set('session_user_id', $sql_in); - } - $db->sql_freeresult($result); - break; - } - - if (isset($sql_where) && $sql_where) - { - $sql = 'DELETE FROM ' . SESSIONS_TABLE . " - $sql_where"; - $db->sql_query($sql); - - if ($mode == 'user') - { - $sql = 'DELETE FROM ' . SESSIONS_KEYS_TABLE . ' ' . ((in_array('*', $banlist_ary)) ? '' : 'WHERE ' . $db->sql_in_set('user_id', $banlist_ary)); - $db->sql_query($sql); - } - } - } - - // Update log - $log_entry = ($ban_exclude) ? 'LOG_BAN_EXCLUDE_' : 'LOG_BAN_'; - - // Add to admin log, moderator log and user notes - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, $log_entry . strtoupper($mode), false, array($ban_reason, $ban_list_log)); - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, $log_entry . strtoupper($mode), false, array( - 'forum_id' => 0, - 'topic_id' => 0, - $ban_reason, - $ban_list_log - )); - if ($mode == 'user') - { - foreach ($banlist_ary as $user_id) - { - $phpbb_log->add('user', $user->data['user_id'], $user->ip, $log_entry . strtoupper($mode), false, array( - 'reportee_id' => $user_id, - $ban_reason, - $ban_list_log - )); - } - } - - $cache->destroy('sql', BANLIST_TABLE); - - return true; - } - - // There was nothing to ban/exclude. But destroying the cache because of the removal of stale bans. - $cache->destroy('sql', BANLIST_TABLE); - - return false; -} - -/** -* Unban User -*/ -function user_unban($mode, $ban) -{ - global $db, $user, $cache, $phpbb_log, $phpbb_dispatcher; - - // Delete stale bans - $sql = 'DELETE FROM ' . BANLIST_TABLE . ' - WHERE ban_end < ' . time() . ' - AND ban_end <> 0'; - $db->sql_query($sql); - - if (!is_array($ban)) - { - $ban = array($ban); - } - - $unban_sql = array_map('intval', $ban); - - if (count($unban_sql)) - { - // Grab details of bans for logging information later - switch ($mode) - { - case 'user': - $sql = 'SELECT u.username AS unban_info, u.user_id - FROM ' . USERS_TABLE . ' u, ' . BANLIST_TABLE . ' b - WHERE ' . $db->sql_in_set('b.ban_id', $unban_sql) . ' - AND u.user_id = b.ban_userid'; - break; - - case 'email': - $sql = 'SELECT ban_email AS unban_info - FROM ' . BANLIST_TABLE . ' - WHERE ' . $db->sql_in_set('ban_id', $unban_sql); - break; - - case 'ip': - $sql = 'SELECT ban_ip AS unban_info - FROM ' . BANLIST_TABLE . ' - WHERE ' . $db->sql_in_set('ban_id', $unban_sql); - break; - } - $result = $db->sql_query($sql); - - $l_unban_list = ''; - $user_ids_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - $l_unban_list .= (($l_unban_list != '') ? ', ' : '') . $row['unban_info']; - if ($mode == 'user') - { - $user_ids_ary[] = $row['user_id']; - } - } - $db->sql_freeresult($result); - - $sql = 'DELETE FROM ' . BANLIST_TABLE . ' - WHERE ' . $db->sql_in_set('ban_id', $unban_sql); - $db->sql_query($sql); - - // Add to moderator log, admin log and user notes - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_UNBAN_' . strtoupper($mode), false, array($l_unban_list)); - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_UNBAN_' . strtoupper($mode), false, array( - 'forum_id' => 0, - 'topic_id' => 0, - $l_unban_list - )); - if ($mode == 'user') - { - foreach ($user_ids_ary as $user_id) - { - $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_UNBAN_' . strtoupper($mode), false, array( - 'reportee_id' => $user_id, - $l_unban_list - )); - } - } - - /** - * Use this event to perform actions after the unban has been performed - * - * @event core.user_unban - * @var string mode One of the following: user, ip, email - * @var array user_ids_ary Array with user_ids - * @since 3.1.11-RC1 - */ - $vars = array( - 'mode', - 'user_ids_ary', - ); - extract($phpbb_dispatcher->trigger_event('core.user_unban', compact($vars))); - } - - $cache->destroy('sql', BANLIST_TABLE); - - return false; -} - -/** -* Internet Protocol Address Whois -* RFC3912: WHOIS Protocol Specification -* -* @param string $ip Ip address, either IPv4 or IPv6. -* -* @return string Empty string if not a valid ip address. -* Otherwise make_clickable()'ed whois result. -*/ -function user_ipwhois($ip) -{ - if (!filter_var($ip, FILTER_VALIDATE_IP)) - { - return ''; - } - - // IPv4 & IPv6 addresses - $whois_host = 'whois.arin.net.'; - - $ipwhois = ''; - - if (($fsk = @fsockopen($whois_host, 43))) - { - // CRLF as per RFC3912 - fputs($fsk, "$ip\r\n"); - while (!feof($fsk)) - { - $ipwhois .= fgets($fsk, 1024); - } - @fclose($fsk); - } - - $match = array(); - - // Test for referrals from $whois_host to other whois databases, roll on rwhois - if (preg_match('#ReferralServer:[\x20]*whois://(.+)#im', $ipwhois, $match)) - { - if (strpos($match[1], ':') !== false) - { - $pos = strrpos($match[1], ':'); - $server = substr($match[1], 0, $pos); - $port = (int) substr($match[1], $pos + 1); - unset($pos); - } - else - { - $server = $match[1]; - $port = 43; - } - - $buffer = ''; - - if (($fsk = @fsockopen($server, $port))) - { - fputs($fsk, "$ip\r\n"); - while (!feof($fsk)) - { - $buffer .= fgets($fsk, 1024); - } - @fclose($fsk); - } - - // Use the result from $whois_host if we don't get any result here - $ipwhois = (empty($buffer)) ? $ipwhois : $buffer; - } - - $ipwhois = htmlspecialchars($ipwhois); - - // Magic URL ;) - return trim(make_clickable($ipwhois, false, '')); -} - -/** -* Data validation ... used primarily but not exclusively by ucp modules -* -* "Master" function for validating a range of data types -*/ -function validate_data($data, $val_ary) -{ - global $user; - - $error = array(); - - foreach ($val_ary as $var => $val_seq) - { - if (!is_array($val_seq[0])) - { - $val_seq = array($val_seq); - } - - foreach ($val_seq as $validate) - { - $function = array_shift($validate); - array_unshift($validate, $data[$var]); - - if (is_array($function)) - { - $result = call_user_func_array(array($function[0], 'validate_' . $function[1]), $validate); - } - else - { - $function_prefix = (function_exists('phpbb_validate_' . $function)) ? 'phpbb_validate_' : 'validate_'; - $result = call_user_func_array($function_prefix . $function, $validate); - } - - if ($result) - { - // Since errors are checked later for their language file existence, we need to make sure custom errors are not adjusted. - $error[] = (empty($user->lang[$result . '_' . strtoupper($var)])) ? $result : $result . '_' . strtoupper($var); - } - } - } - - return $error; -} - -/** -* Validate String -* -* @return boolean|string Either false if validation succeeded or a string which will be used as the error message (with the variable name appended) -*/ -function validate_string($string, $optional = false, $min = 0, $max = 0) -{ - if (empty($string) && $optional) - { - return false; - } - - if ($min && utf8_strlen(htmlspecialchars_decode($string)) < $min) - { - return 'TOO_SHORT'; - } - else if ($max && utf8_strlen(htmlspecialchars_decode($string)) > $max) - { - return 'TOO_LONG'; - } - - return false; -} - -/** -* Validate Number -* -* @return boolean|string Either false if validation succeeded or a string which will be used as the error message (with the variable name appended) -*/ -function validate_num($num, $optional = false, $min = 0, $max = 1E99) -{ - if (empty($num) && $optional) - { - return false; - } - - if ($num < $min) - { - return 'TOO_SMALL'; - } - else if ($num > $max) - { - return 'TOO_LARGE'; - } - - return false; -} - -/** -* Validate Date -* @param String $string a date in the dd-mm-yyyy format -* @return boolean -*/ -function validate_date($date_string, $optional = false) -{ - $date = explode('-', $date_string); - if ((empty($date) || count($date) != 3) && $optional) - { - return false; - } - else if ($optional) - { - for ($field = 0; $field <= 1; $field++) - { - $date[$field] = (int) $date[$field]; - if (empty($date[$field])) - { - $date[$field] = 1; - } - } - $date[2] = (int) $date[2]; - // assume an arbitrary leap year - if (empty($date[2])) - { - $date[2] = 1980; - } - } - - if (count($date) != 3 || !checkdate($date[1], $date[0], $date[2])) - { - return 'INVALID'; - } - - return false; -} - - -/** -* Validate Match -* -* @return boolean|string Either false if validation succeeded or a string which will be used as the error message (with the variable name appended) -*/ -function validate_match($string, $optional = false, $match = '') -{ - if (empty($string) && $optional) - { - return false; - } - - if (empty($match)) - { - return false; - } - - if (!preg_match($match, $string)) - { - return 'WRONG_DATA'; - } - - return false; -} - -/** -* Validate Language Pack ISO Name -* -* Tests whether a language name is valid and installed -* -* @param string $lang_iso The language string to test -* -* @return bool|string Either false if validation succeeded or -* a string which will be used as the error message -* (with the variable name appended) -*/ -function validate_language_iso_name($lang_iso) -{ - global $db; - - $sql = 'SELECT lang_id - FROM ' . LANG_TABLE . " - WHERE lang_iso = '" . $db->sql_escape($lang_iso) . "'"; - $result = $db->sql_query($sql); - $lang_id = (int) $db->sql_fetchfield('lang_id'); - $db->sql_freeresult($result); - - return ($lang_id) ? false : 'WRONG_DATA'; -} - -/** -* Validate Timezone Name -* -* Tests whether a timezone name is valid -* -* @param string $timezone The timezone string to test -* -* @return bool|string Either false if validation succeeded or -* a string which will be used as the error message -* (with the variable name appended) -*/ -function phpbb_validate_timezone($timezone) -{ - return (in_array($timezone, phpbb_get_timezone_identifiers($timezone))) ? false : 'TIMEZONE_INVALID'; -} - -/*** - * Validate Username - * - * Check to see if the username has been taken, or if it is disallowed. - * Also checks if it includes the " character or the 4-bytes Unicode ones - * (aka emojis) which we don't allow in usernames. - * Used for registering, changing names, and posting anonymously with a username - * - * @param string $username The username to check - * @param string $allowed_username An allowed username, default being $user->data['username'] - * - * @return mixed Either false if validation succeeded or a string which will be - * used as the error message (with the variable name appended) - */ -function validate_username($username, $allowed_username = false, $allow_all_names = false) -{ - global $config, $db, $user, $cache; - - $clean_username = utf8_clean_string($username); - $allowed_username = ($allowed_username === false) ? $user->data['username_clean'] : utf8_clean_string($allowed_username); - - if ($allowed_username == $clean_username) - { - return false; - } - - // The very first check is for - // out-of-bounds characters that are currently - // not supported by utf8_bin in MySQL - if (preg_match('/[\x{10000}-\x{10FFFF}]/u', $username)) - { - return 'INVALID_EMOJIS'; - } - - // ... fast checks first. - if (strpos($username, '"') !== false || strpos($username, '"') !== false || empty($clean_username)) - { - return 'INVALID_CHARS'; - } - - switch ($config['allow_name_chars']) - { - case 'USERNAME_CHARS_ANY': - $regex = '.+'; - break; - - case 'USERNAME_ALPHA_ONLY': - $regex = '[A-Za-z0-9]+'; - break; - - case 'USERNAME_ALPHA_SPACERS': - $regex = '[A-Za-z0-9-[\]_+ ]+'; - break; - - case 'USERNAME_LETTER_NUM': - $regex = '[\p{Lu}\p{Ll}\p{N}]+'; - break; - - case 'USERNAME_LETTER_NUM_SPACERS': - $regex = '[-\]_+ [\p{Lu}\p{Ll}\p{N}]+'; - break; - - case 'USERNAME_ASCII': - default: - $regex = '[\x01-\x7F]+'; - break; - } - - if (!preg_match('#^' . $regex . '$#u', $username)) - { - return 'INVALID_CHARS'; - } - - $sql = 'SELECT username - FROM ' . USERS_TABLE . " - WHERE username_clean = '" . $db->sql_escape($clean_username) . "'"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - return 'USERNAME_TAKEN'; - } - - $sql = 'SELECT group_name - FROM ' . GROUPS_TABLE . " - WHERE LOWER(group_name) = '" . $db->sql_escape(utf8_strtolower($username)) . "'"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - return 'USERNAME_TAKEN'; - } - - if (!$allow_all_names) - { - $bad_usernames = $cache->obtain_disallowed_usernames(); - - foreach ($bad_usernames as $bad_username) - { - if (preg_match('#^' . $bad_username . '$#', $clean_username)) - { - return 'USERNAME_DISALLOWED'; - } - } - } - - return false; -} - -/** -* Check to see if the password meets the complexity settings -* -* @return boolean|string Either false if validation succeeded or a string which will be used as the error message (with the variable name appended) -*/ -function validate_password($password) -{ - global $config; - - if ($password === '' || $config['pass_complex'] === 'PASS_TYPE_ANY') - { - // Password empty or no password complexity required. - return false; - } - - $upp = '\p{Lu}'; - $low = '\p{Ll}'; - $num = '\p{N}'; - $sym = '[^\p{Lu}\p{Ll}\p{N}]'; - $chars = array(); - - switch ($config['pass_complex']) - { - // No break statements below ... - // We require strong passwords in case pass_complex is not set or is invalid - default: - - // Require mixed case letters, numbers and symbols - case 'PASS_TYPE_SYMBOL': - $chars[] = $sym; - - // Require mixed case letters and numbers - case 'PASS_TYPE_ALPHA': - $chars[] = $num; - - // Require mixed case letters - case 'PASS_TYPE_CASE': - $chars[] = $low; - $chars[] = $upp; - } - - foreach ($chars as $char) - { - if (!preg_match('#' . $char . '#u', $password)) - { - return 'INVALID_CHARS'; - } - } - - return false; -} - -/** -* Check to see if email address is a valid address and contains a MX record -* -* @param string $email The email to check -* -* @return mixed Either false if validation succeeded or a string which will be used as the error message (with the variable name appended) -*/ -function phpbb_validate_email($email, $config = null) -{ - if ($config === null) - { - global $config; - } - - $email = strtolower($email); - - if (!preg_match('/^' . get_preg_expression('email') . '$/i', $email)) - { - return 'EMAIL_INVALID'; - } - - // Check MX record. - // The idea for this is from reading the UseBB blog/announcement. :) - if ($config['email_check_mx']) - { - list(, $domain) = explode('@', $email); - - if (checkdnsrr($domain, 'A') === false && checkdnsrr($domain, 'MX') === false) - { - return 'DOMAIN_NO_MX_RECORD'; - } - } - - return false; -} - -/** -* Check to see if email address is banned or already present in the DB -* -* @param string $email The email to check -* @param string $allowed_email An allowed email, default being $user->data['user_email'] -* -* @return mixed Either false if validation succeeded or a string which will be used as the error message (with the variable name appended) -*/ -function validate_user_email($email, $allowed_email = false) -{ - global $config, $db, $user; - - $email = strtolower($email); - $allowed_email = ($allowed_email === false) ? strtolower($user->data['user_email']) : strtolower($allowed_email); - - if ($allowed_email == $email) - { - return false; - } - - $validate_email = phpbb_validate_email($email, $config); - if ($validate_email) - { - return $validate_email; - } - - $ban = $user->check_ban(false, false, $email, true); - if (!empty($ban)) - { - return !empty($ban['ban_give_reason']) ? $ban['ban_give_reason'] : 'EMAIL_BANNED'; - } - - if (!$config['allow_emailreuse']) - { - $sql = 'SELECT user_email - FROM ' . USERS_TABLE . " - WHERE user_email = '" . $db->sql_escape($email) . "'"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - return 'EMAIL_TAKEN'; - } - } - - return false; -} - -/** -* Validate jabber address -* Taken from the jabber class within flyspray (see author notes) -* -* @author flyspray.org -*/ -function validate_jabber($jid) -{ - if (!$jid) - { - return false; - } - - $separator_pos = strpos($jid, '@'); - - if ($separator_pos === false) - { - return 'WRONG_DATA'; - } - - $username = substr($jid, 0, $separator_pos); - $realm = substr($jid, $separator_pos + 1); - - if (strlen($username) == 0 || strlen($realm) < 3) - { - return 'WRONG_DATA'; - } - - $arr = explode('.', $realm); - - if (count($arr) == 0) - { - return 'WRONG_DATA'; - } - - foreach ($arr as $part) - { - if (substr($part, 0, 1) == '-' || substr($part, -1, 1) == '-') - { - return 'WRONG_DATA'; - } - - if (!preg_match("@^[a-zA-Z0-9-.]+$@", $part)) - { - return 'WRONG_DATA'; - } - } - - $boundary = array(array(0, 127), array(192, 223), array(224, 239), array(240, 247), array(248, 251), array(252, 253)); - - // Prohibited Characters RFC3454 + RFC3920 - $prohibited = array( - // Table C.1.1 - array(0x0020, 0x0020), // SPACE - // Table C.1.2 - array(0x00A0, 0x00A0), // NO-BREAK SPACE - array(0x1680, 0x1680), // OGHAM SPACE MARK - array(0x2000, 0x2001), // EN QUAD - array(0x2001, 0x2001), // EM QUAD - array(0x2002, 0x2002), // EN SPACE - array(0x2003, 0x2003), // EM SPACE - array(0x2004, 0x2004), // THREE-PER-EM SPACE - array(0x2005, 0x2005), // FOUR-PER-EM SPACE - array(0x2006, 0x2006), // SIX-PER-EM SPACE - array(0x2007, 0x2007), // FIGURE SPACE - array(0x2008, 0x2008), // PUNCTUATION SPACE - array(0x2009, 0x2009), // THIN SPACE - array(0x200A, 0x200A), // HAIR SPACE - array(0x200B, 0x200B), // ZERO WIDTH SPACE - array(0x202F, 0x202F), // NARROW NO-BREAK SPACE - array(0x205F, 0x205F), // MEDIUM MATHEMATICAL SPACE - array(0x3000, 0x3000), // IDEOGRAPHIC SPACE - // Table C.2.1 - array(0x0000, 0x001F), // [CONTROL CHARACTERS] - array(0x007F, 0x007F), // DELETE - // Table C.2.2 - array(0x0080, 0x009F), // [CONTROL CHARACTERS] - array(0x06DD, 0x06DD), // ARABIC END OF AYAH - array(0x070F, 0x070F), // SYRIAC ABBREVIATION MARK - array(0x180E, 0x180E), // MONGOLIAN VOWEL SEPARATOR - array(0x200C, 0x200C), // ZERO WIDTH NON-JOINER - array(0x200D, 0x200D), // ZERO WIDTH JOINER - array(0x2028, 0x2028), // LINE SEPARATOR - array(0x2029, 0x2029), // PARAGRAPH SEPARATOR - array(0x2060, 0x2060), // WORD JOINER - array(0x2061, 0x2061), // FUNCTION APPLICATION - array(0x2062, 0x2062), // INVISIBLE TIMES - array(0x2063, 0x2063), // INVISIBLE SEPARATOR - array(0x206A, 0x206F), // [CONTROL CHARACTERS] - array(0xFEFF, 0xFEFF), // ZERO WIDTH NO-BREAK SPACE - array(0xFFF9, 0xFFFC), // [CONTROL CHARACTERS] - array(0x1D173, 0x1D17A), // [MUSICAL CONTROL CHARACTERS] - // Table C.3 - array(0xE000, 0xF8FF), // [PRIVATE USE, PLANE 0] - array(0xF0000, 0xFFFFD), // [PRIVATE USE, PLANE 15] - array(0x100000, 0x10FFFD), // [PRIVATE USE, PLANE 16] - // Table C.4 - array(0xFDD0, 0xFDEF), // [NONCHARACTER CODE POINTS] - array(0xFFFE, 0xFFFF), // [NONCHARACTER CODE POINTS] - array(0x1FFFE, 0x1FFFF), // [NONCHARACTER CODE POINTS] - array(0x2FFFE, 0x2FFFF), // [NONCHARACTER CODE POINTS] - array(0x3FFFE, 0x3FFFF), // [NONCHARACTER CODE POINTS] - array(0x4FFFE, 0x4FFFF), // [NONCHARACTER CODE POINTS] - array(0x5FFFE, 0x5FFFF), // [NONCHARACTER CODE POINTS] - array(0x6FFFE, 0x6FFFF), // [NONCHARACTER CODE POINTS] - array(0x7FFFE, 0x7FFFF), // [NONCHARACTER CODE POINTS] - array(0x8FFFE, 0x8FFFF), // [NONCHARACTER CODE POINTS] - array(0x9FFFE, 0x9FFFF), // [NONCHARACTER CODE POINTS] - array(0xAFFFE, 0xAFFFF), // [NONCHARACTER CODE POINTS] - array(0xBFFFE, 0xBFFFF), // [NONCHARACTER CODE POINTS] - array(0xCFFFE, 0xCFFFF), // [NONCHARACTER CODE POINTS] - array(0xDFFFE, 0xDFFFF), // [NONCHARACTER CODE POINTS] - array(0xEFFFE, 0xEFFFF), // [NONCHARACTER CODE POINTS] - array(0xFFFFE, 0xFFFFF), // [NONCHARACTER CODE POINTS] - array(0x10FFFE, 0x10FFFF), // [NONCHARACTER CODE POINTS] - // Table C.5 - array(0xD800, 0xDFFF), // [SURROGATE CODES] - // Table C.6 - array(0xFFF9, 0xFFF9), // INTERLINEAR ANNOTATION ANCHOR - array(0xFFFA, 0xFFFA), // INTERLINEAR ANNOTATION SEPARATOR - array(0xFFFB, 0xFFFB), // INTERLINEAR ANNOTATION TERMINATOR - array(0xFFFC, 0xFFFC), // OBJECT REPLACEMENT CHARACTER - array(0xFFFD, 0xFFFD), // REPLACEMENT CHARACTER - // Table C.7 - array(0x2FF0, 0x2FFB), // [IDEOGRAPHIC DESCRIPTION CHARACTERS] - // Table C.8 - array(0x0340, 0x0340), // COMBINING GRAVE TONE MARK - array(0x0341, 0x0341), // COMBINING ACUTE TONE MARK - array(0x200E, 0x200E), // LEFT-TO-RIGHT MARK - array(0x200F, 0x200F), // RIGHT-TO-LEFT MARK - array(0x202A, 0x202A), // LEFT-TO-RIGHT EMBEDDING - array(0x202B, 0x202B), // RIGHT-TO-LEFT EMBEDDING - array(0x202C, 0x202C), // POP DIRECTIONAL FORMATTING - array(0x202D, 0x202D), // LEFT-TO-RIGHT OVERRIDE - array(0x202E, 0x202E), // RIGHT-TO-LEFT OVERRIDE - array(0x206A, 0x206A), // INHIBIT SYMMETRIC SWAPPING - array(0x206B, 0x206B), // ACTIVATE SYMMETRIC SWAPPING - array(0x206C, 0x206C), // INHIBIT ARABIC FORM SHAPING - array(0x206D, 0x206D), // ACTIVATE ARABIC FORM SHAPING - array(0x206E, 0x206E), // NATIONAL DIGIT SHAPES - array(0x206F, 0x206F), // NOMINAL DIGIT SHAPES - // Table C.9 - array(0xE0001, 0xE0001), // LANGUAGE TAG - array(0xE0020, 0xE007F), // [TAGGING CHARACTERS] - // RFC3920 - array(0x22, 0x22), // " - array(0x26, 0x26), // & - array(0x27, 0x27), // ' - array(0x2F, 0x2F), // / - array(0x3A, 0x3A), // : - array(0x3C, 0x3C), // < - array(0x3E, 0x3E), // > - array(0x40, 0x40) // @ - ); - - $pos = 0; - $result = true; - - while ($pos < strlen($username)) - { - $len = $uni = 0; - for ($i = 0; $i <= 5; $i++) - { - if (ord($username[$pos]) >= $boundary[$i][0] && ord($username[$pos]) <= $boundary[$i][1]) - { - $len = $i + 1; - $uni = (ord($username[$pos]) - $boundary[$i][0]) * pow(2, $i * 6); - - for ($k = 1; $k < $len; $k++) - { - $uni += (ord($username[$pos + $k]) - 128) * pow(2, ($i - $k) * 6); - } - - break; - } - } - - if ($len == 0) - { - return 'WRONG_DATA'; - } - - foreach ($prohibited as $pval) - { - if ($uni >= $pval[0] && $uni <= $pval[1]) - { - $result = false; - break 2; - } - } - - $pos = $pos + $len; - } - - if (!$result) - { - return 'WRONG_DATA'; - } - - return false; -} - -/** -* Validate hex colour value -* -* @param string $colour The hex colour value -* @param bool $optional Whether the colour value is optional. True if an empty -* string will be accepted as correct input, false if not. -* @return bool|string Error message if colour value is incorrect, false if it -* fits the hex colour code -*/ -function phpbb_validate_hex_colour($colour, $optional = false) -{ - if ($colour === '') - { - return (($optional) ? false : 'WRONG_DATA'); - } - - if (!preg_match('/^([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/', $colour)) - { - return 'WRONG_DATA'; - } - - return false; -} - -/** -* Verifies whether a style ID corresponds to an active style. -* -* @param int $style_id The style_id of a style which should be checked if activated or not. -* @return boolean -*/ -function phpbb_style_is_active($style_id) -{ - global $db; - - $sql = 'SELECT style_active - FROM ' . STYLES_TABLE . ' - WHERE style_id = '. (int) $style_id; - $result = $db->sql_query($sql); - - $style_is_active = (bool) $db->sql_fetchfield('style_active'); - $db->sql_freeresult($result); - - return $style_is_active; -} - -/** -* Remove avatar -*/ -function avatar_delete($mode, $row, $clean_db = false) -{ - global $phpbb_root_path, $config; - - // Check if the users avatar is actually *not* a group avatar - if ($mode == 'user') - { - if (strpos($row['user_avatar'], 'g') === 0 || (((int) $row['user_avatar'] !== 0) && ((int) $row['user_avatar'] !== (int) $row['user_id']))) - { - return false; - } - } - - if ($clean_db) - { - avatar_remove_db($row[$mode . '_avatar']); - } - $filename = get_avatar_filename($row[$mode . '_avatar']); - - if (file_exists($phpbb_root_path . $config['avatar_path'] . '/' . $filename)) - { - @unlink($phpbb_root_path . $config['avatar_path'] . '/' . $filename); - return true; - } - - return false; -} - -/** -* Generates avatar filename from the database entry -*/ -function get_avatar_filename($avatar_entry) -{ - global $config; - - if ($avatar_entry[0] === 'g') - { - $avatar_group = true; - $avatar_entry = substr($avatar_entry, 1); - } - else - { - $avatar_group = false; - } - $ext = substr(strrchr($avatar_entry, '.'), 1); - $avatar_entry = intval($avatar_entry); - return $config['avatar_salt'] . '_' . (($avatar_group) ? 'g' : '') . $avatar_entry . '.' . $ext; -} - -/** -* Returns an explanation string with maximum avatar settings -* -* @return string -*/ -function phpbb_avatar_explanation_string() -{ - global $config, $user; - - return $user->lang(($config['avatar_filesize'] == 0) ? 'AVATAR_EXPLAIN_NO_FILESIZE' : 'AVATAR_EXPLAIN', - $user->lang('PIXELS', (int) $config['avatar_max_width']), - $user->lang('PIXELS', (int) $config['avatar_max_height']), - round($config['avatar_filesize'] / 1024)); -} - -// -// Usergroup functions -// - -/** -* Add or edit a group. If we're editing a group we only update user -* parameters such as rank, etc. if they are changed -*/ -function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow_desc_bbcode = false, $allow_desc_urls = false, $allow_desc_smilies = false) -{ - global $db, $user, $phpbb_container, $phpbb_log; - - /** @var \phpbb\group\helper $group_helper */ - $group_helper = $phpbb_container->get('group_helper'); - - $error = array(); - - // Attributes which also affect the users table - $user_attribute_ary = array('group_colour', 'group_rank', 'group_avatar', 'group_avatar_type', 'group_avatar_width', 'group_avatar_height'); - - // Check data. Limit group name length. - if (!utf8_strlen($name) || utf8_strlen($name) > 60) - { - $error[] = (!utf8_strlen($name)) ? $user->lang['GROUP_ERR_USERNAME'] : $user->lang['GROUP_ERR_USER_LONG']; - } - - $err = group_validate_groupname($group_id, $name); - if (!empty($err)) - { - $error[] = $user->lang[$err]; - } - - if (!in_array($type, array(GROUP_OPEN, GROUP_CLOSED, GROUP_HIDDEN, GROUP_SPECIAL, GROUP_FREE))) - { - $error[] = $user->lang['GROUP_ERR_TYPE']; - } - - $group_teampage = !empty($group_attributes['group_teampage']); - unset($group_attributes['group_teampage']); - - if (!count($error)) - { - $current_legend = \phpbb\groupposition\legend::GROUP_DISABLED; - $current_teampage = \phpbb\groupposition\teampage::GROUP_DISABLED; - - /* @var $legend \phpbb\groupposition\legend */ - $legend = $phpbb_container->get('groupposition.legend'); - - /* @var $teampage \phpbb\groupposition\teampage */ - $teampage = $phpbb_container->get('groupposition.teampage'); - - if ($group_id) - { - try - { - $current_legend = $legend->get_group_value($group_id); - $current_teampage = $teampage->get_group_value($group_id); - } - catch (\phpbb\groupposition\exception $exception) - { - trigger_error($user->lang($exception->getMessage())); - } - } - - if (!empty($group_attributes['group_legend'])) - { - if (($group_id && ($current_legend == \phpbb\groupposition\legend::GROUP_DISABLED)) || !$group_id) - { - // Old group currently not in the legend or new group, add at the end. - $group_attributes['group_legend'] = 1 + $legend->get_group_count(); - } - else - { - // Group stayes in the legend - $group_attributes['group_legend'] = $current_legend; - } - } - else if ($group_id && ($current_legend != \phpbb\groupposition\legend::GROUP_DISABLED)) - { - // Group is removed from the legend - try - { - $legend->delete_group($group_id, true); - } - catch (\phpbb\groupposition\exception $exception) - { - trigger_error($user->lang($exception->getMessage())); - } - $group_attributes['group_legend'] = \phpbb\groupposition\legend::GROUP_DISABLED; - } - else - { - $group_attributes['group_legend'] = \phpbb\groupposition\legend::GROUP_DISABLED; - } - - // Unset the objects, we don't need them anymore. - unset($legend); - - $user_ary = array(); - $sql_ary = array( - 'group_name' => (string) $name, - 'group_desc' => (string) $desc, - 'group_desc_uid' => '', - 'group_desc_bitfield' => '', - 'group_type' => (int) $type, - ); - - // Parse description - if ($desc) - { - generate_text_for_storage($sql_ary['group_desc'], $sql_ary['group_desc_uid'], $sql_ary['group_desc_bitfield'], $sql_ary['group_desc_options'], $allow_desc_bbcode, $allow_desc_urls, $allow_desc_smilies); - } - - if (count($group_attributes)) - { - // Merge them with $sql_ary to properly update the group - $sql_ary = array_merge($sql_ary, $group_attributes); - } - - // Setting the log message before we set the group id (if group gets added) - $log = ($group_id) ? 'LOG_GROUP_UPDATED' : 'LOG_GROUP_CREATED'; - - if ($group_id) - { - $sql = 'SELECT user_id - FROM ' . USERS_TABLE . ' - WHERE group_id = ' . $group_id; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $user_ary[] = $row['user_id']; - } - $db->sql_freeresult($result); - - if (isset($sql_ary['group_avatar'])) - { - remove_default_avatar($group_id, $user_ary); - } - - if (isset($sql_ary['group_rank'])) - { - remove_default_rank($group_id, $user_ary); - } - - $sql = 'UPDATE ' . GROUPS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " - WHERE group_id = $group_id"; - $db->sql_query($sql); - - // Since we may update the name too, we need to do this on other tables too... - $sql = 'UPDATE ' . MODERATOR_CACHE_TABLE . " - SET group_name = '" . $db->sql_escape($sql_ary['group_name']) . "' - WHERE group_id = $group_id"; - $db->sql_query($sql); - - // One special case is the group skip auth setting. If this was changed we need to purge permissions for this group - if (isset($group_attributes['group_skip_auth'])) - { - // Get users within this group... - $sql = 'SELECT user_id - FROM ' . USER_GROUP_TABLE . ' - WHERE group_id = ' . $group_id . ' - AND user_pending = 0'; - $result = $db->sql_query($sql); - - $user_id_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - $user_id_ary[] = $row['user_id']; - } - $db->sql_freeresult($result); - - if (!empty($user_id_ary)) - { - global $auth; - - // Clear permissions cache of relevant users - $auth->acl_clear_prefetch($user_id_ary); - } - } - } - else - { - $sql = 'INSERT INTO ' . GROUPS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); - $db->sql_query($sql); - } - - // Remove the group from the teampage, only if unselected and we are editing a group, - // which is currently displayed. - if (!$group_teampage && $group_id && $current_teampage != \phpbb\groupposition\teampage::GROUP_DISABLED) - { - try - { - $teampage->delete_group($group_id); - } - catch (\phpbb\groupposition\exception $exception) - { - trigger_error($user->lang($exception->getMessage())); - } - } - - if (!$group_id) - { - $group_id = $db->sql_nextid(); - - if (isset($sql_ary['group_avatar_type']) && $sql_ary['group_avatar_type'] == 'avatar.driver.upload') - { - group_correct_avatar($group_id, $sql_ary['group_avatar']); - } - } - - try - { - if ($group_teampage && $current_teampage == \phpbb\groupposition\teampage::GROUP_DISABLED) - { - $teampage->add_group($group_id); - } - - if ($group_teampage) - { - if ($current_teampage == \phpbb\groupposition\teampage::GROUP_DISABLED) - { - $teampage->add_group($group_id); - } - } - else if ($group_id && ($current_teampage != \phpbb\groupposition\teampage::GROUP_DISABLED)) - { - $teampage->delete_group($group_id); - } - } - catch (\phpbb\groupposition\exception $exception) - { - trigger_error($user->lang($exception->getMessage())); - } - unset($teampage); - - // Set user attributes - $sql_ary = array(); - if (count($group_attributes)) - { - // Go through the user attributes array, check if a group attribute matches it and then set it. ;) - foreach ($user_attribute_ary as $attribute) - { - if (!isset($group_attributes[$attribute])) - { - continue; - } - - // If we are about to set an avatar, we will not overwrite user avatars if no group avatar is set... - if (strpos($attribute, 'group_avatar') === 0 && !$group_attributes[$attribute]) - { - continue; - } - - $sql_ary[$attribute] = $group_attributes[$attribute]; - } - } - - if (count($sql_ary) && count($user_ary)) - { - group_set_user_default($group_id, $user_ary, $sql_ary); - } - - $name = $group_helper->get_name($name); - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, $log, false, array($name)); - - group_update_listings($group_id); - } - - return (count($error)) ? $error : false; -} - - -/** -* Changes a group avatar's filename to conform to the naming scheme -*/ -function group_correct_avatar($group_id, $old_entry) -{ - global $config, $db, $phpbb_root_path; - - $group_id = (int) $group_id; - $ext = substr(strrchr($old_entry, '.'), 1); - $old_filename = get_avatar_filename($old_entry); - $new_filename = $config['avatar_salt'] . "_g$group_id.$ext"; - $new_entry = 'g' . $group_id . '_' . substr(time(), -5) . ".$ext"; - - $avatar_path = $phpbb_root_path . $config['avatar_path']; - if (@rename($avatar_path . '/'. $old_filename, $avatar_path . '/' . $new_filename)) - { - $sql = 'UPDATE ' . GROUPS_TABLE . ' - SET group_avatar = \'' . $db->sql_escape($new_entry) . "' - WHERE group_id = $group_id"; - $db->sql_query($sql); - } -} - - -/** -* Remove avatar also for users not having the group as default -*/ -function avatar_remove_db($avatar_name) -{ - global $db; - - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_avatar = '', - user_avatar_type = '' - WHERE user_avatar = '" . $db->sql_escape($avatar_name) . '\''; - $db->sql_query($sql); -} - - -/** -* Group Delete -*/ -function group_delete($group_id, $group_name = false) -{ - global $db, $cache, $auth, $user, $phpbb_root_path, $phpEx, $phpbb_dispatcher, $phpbb_container, $phpbb_log; - - if (!$group_name) - { - $group_name = get_group_name($group_id); - } - - $start = 0; - - do - { - $user_id_ary = $username_ary = array(); - - // Batch query for group members, call group_user_del - $sql = 'SELECT u.user_id, u.username - FROM ' . USER_GROUP_TABLE . ' ug, ' . USERS_TABLE . " u - WHERE ug.group_id = $group_id - AND u.user_id = ug.user_id"; - $result = $db->sql_query_limit($sql, 200, $start); - - if ($row = $db->sql_fetchrow($result)) - { - do - { - $user_id_ary[] = $row['user_id']; - $username_ary[] = $row['username']; - - $start++; - } - while ($row = $db->sql_fetchrow($result)); - - group_user_del($group_id, $user_id_ary, $username_ary, $group_name); - } - else - { - $start = 0; - } - $db->sql_freeresult($result); - } - while ($start); - - // Delete group from legend and teampage - try - { - /* @var $legend \phpbb\groupposition\legend */ - $legend = $phpbb_container->get('groupposition.legend'); - $legend->delete_group($group_id); - unset($legend); - } - catch (\phpbb\groupposition\exception $exception) - { - // The group we want to delete does not exist. - // No reason to worry, we just continue the deleting process. - //trigger_error($user->lang($exception->getMessage())); - } - - try - { - /* @var $teampage \phpbb\groupposition\teampage */ - $teampage = $phpbb_container->get('groupposition.teampage'); - $teampage->delete_group($group_id); - unset($teampage); - } - catch (\phpbb\groupposition\exception $exception) - { - // The group we want to delete does not exist. - // No reason to worry, we just continue the deleting process. - //trigger_error($user->lang($exception->getMessage())); - } - - // Delete group - $sql = 'DELETE FROM ' . GROUPS_TABLE . " - WHERE group_id = $group_id"; - $db->sql_query($sql); - - // Delete auth entries from the groups table - $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . " - WHERE group_id = $group_id"; - $db->sql_query($sql); - - /** - * Event after a group is deleted - * - * @event core.delete_group_after - * @var int group_id ID of the deleted group - * @var string group_name Name of the deleted group - * @since 3.1.0-a1 - */ - $vars = array('group_id', 'group_name'); - extract($phpbb_dispatcher->trigger_event('core.delete_group_after', compact($vars))); - - // Re-cache moderators - if (!function_exists('phpbb_cache_moderators')) - { - include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); - } - - phpbb_cache_moderators($db, $cache, $auth); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_GROUP_DELETE', false, array($group_name)); - - // Return false - no error - return false; -} - -/** -* Add user(s) to group -* -* @return mixed false if no errors occurred, else the user lang string for the relevant error, for example 'NO_USER' -*/ -function group_user_add($group_id, $user_id_ary = false, $username_ary = false, $group_name = false, $default = false, $leader = 0, $pending = 0, $group_attributes = false) -{ - global $db, $auth, $user, $phpbb_container, $phpbb_log, $phpbb_dispatcher; - - // We need both username and user_id info - $result = user_get_id_name($user_id_ary, $username_ary); - - if (empty($user_id_ary) || $result !== false) - { - return 'NO_USER'; - } - - // Because the item that gets passed into the previous function is unset, the reference is lost and our original - // array is retained - so we know there's a problem if there's a different number of ids to usernames now. - if (count($user_id_ary) != count($username_ary)) - { - return 'GROUP_USERS_INVALID'; - } - - // Remove users who are already members of this group - $sql = 'SELECT user_id, group_leader - FROM ' . USER_GROUP_TABLE . ' - WHERE ' . $db->sql_in_set('user_id', $user_id_ary) . " - AND group_id = $group_id"; - $result = $db->sql_query($sql); - - $add_id_ary = $update_id_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - $add_id_ary[] = (int) $row['user_id']; - - if ($leader && !$row['group_leader']) - { - $update_id_ary[] = (int) $row['user_id']; - } - } - $db->sql_freeresult($result); - - // Do all the users exist in this group? - $add_id_ary = array_diff($user_id_ary, $add_id_ary); - - // If we have no users - if (!count($add_id_ary) && !count($update_id_ary)) - { - return 'GROUP_USERS_EXIST'; - } - - $db->sql_transaction('begin'); - - // Insert the new users - if (count($add_id_ary)) - { - $sql_ary = array(); - - foreach ($add_id_ary as $user_id) - { - $sql_ary[] = array( - 'user_id' => (int) $user_id, - 'group_id' => (int) $group_id, - 'group_leader' => (int) $leader, - 'user_pending' => (int) $pending, - ); - } - - $db->sql_multi_insert(USER_GROUP_TABLE, $sql_ary); - } - - if (count($update_id_ary)) - { - $sql = 'UPDATE ' . USER_GROUP_TABLE . ' - SET group_leader = 1 - WHERE ' . $db->sql_in_set('user_id', $update_id_ary) . " - AND group_id = $group_id"; - $db->sql_query($sql); - } - - if ($default) - { - group_user_attributes('default', $group_id, $user_id_ary, false, $group_name, $group_attributes); - } - - $db->sql_transaction('commit'); - - // Clear permissions cache of relevant users - $auth->acl_clear_prefetch($user_id_ary); - - /** - * Event after users are added to a group - * - * @event core.group_add_user_after - * @var int group_id ID of the group to which users are added - * @var string group_name Name of the group - * @var array user_id_ary IDs of the users which are added - * @var array username_ary names of the users which are added - * @var int pending Pending setting, 1 if user(s) added are pending - * @since 3.1.7-RC1 - */ - $vars = array( - 'group_id', - 'group_name', - 'user_id_ary', - 'username_ary', - 'pending', - ); - extract($phpbb_dispatcher->trigger_event('core.group_add_user_after', compact($vars))); - - if (!$group_name) - { - $group_name = get_group_name($group_id); - } - - $log = ($leader) ? 'LOG_MODS_ADDED' : (($pending) ? 'LOG_USERS_PENDING' : 'LOG_USERS_ADDED'); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, $log, false, array($group_name, implode(', ', $username_ary))); - - group_update_listings($group_id); - - if ($pending) - { - /* @var $phpbb_notifications \phpbb\notification\manager */ - $phpbb_notifications = $phpbb_container->get('notification_manager'); - - foreach ($add_id_ary as $user_id) - { - $phpbb_notifications->add_notifications('notification.type.group_request', array( - 'group_id' => $group_id, - 'user_id' => $user_id, - 'group_name' => $group_name, - )); - } - } - - // Return false - no error - return false; -} - -/** -* Remove a user/s from a given group. When we remove users we update their -* default group_id. We do this by examining which "special" groups they belong -* to. The selection is made based on a reasonable priority system -* -* @return false if no errors occurred, else the user lang string for the relevant error, for example 'NO_USER' -*/ -function group_user_del($group_id, $user_id_ary = false, $username_ary = false, $group_name = false, $log_action = true) -{ - global $db, $auth, $config, $user, $phpbb_dispatcher, $phpbb_container, $phpbb_log; - - if ($config['coppa_enable']) - { - $group_order = array('ADMINISTRATORS', 'GLOBAL_MODERATORS', 'NEWLY_REGISTERED', 'REGISTERED_COPPA', 'REGISTERED', 'BOTS', 'GUESTS'); - } - else - { - $group_order = array('ADMINISTRATORS', 'GLOBAL_MODERATORS', 'NEWLY_REGISTERED', 'REGISTERED', 'BOTS', 'GUESTS'); - } - - // We need both username and user_id info - $result = user_get_id_name($user_id_ary, $username_ary); - - if (empty($user_id_ary) || $result !== false) - { - return 'NO_USER'; - } - - $sql = 'SELECT * - FROM ' . GROUPS_TABLE . ' - WHERE ' . $db->sql_in_set('group_name', $group_order); - $result = $db->sql_query($sql); - - $group_order_id = $special_group_data = array(); - while ($row = $db->sql_fetchrow($result)) - { - $group_order_id[$row['group_name']] = $row['group_id']; - - $special_group_data[$row['group_id']] = array( - 'group_colour' => $row['group_colour'], - 'group_rank' => $row['group_rank'], - ); - - // Only set the group avatar if one is defined... - if ($row['group_avatar']) - { - $special_group_data[$row['group_id']] = array_merge($special_group_data[$row['group_id']], array( - 'group_avatar' => $row['group_avatar'], - 'group_avatar_type' => $row['group_avatar_type'], - 'group_avatar_width' => $row['group_avatar_width'], - 'group_avatar_height' => $row['group_avatar_height']) - ); - } - } - $db->sql_freeresult($result); - - // Get users default groups - we only need to reset default group membership if the group from which the user gets removed is set as default - $sql = 'SELECT user_id, group_id - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('user_id', $user_id_ary); - $result = $db->sql_query($sql); - - $default_groups = array(); - while ($row = $db->sql_fetchrow($result)) - { - $default_groups[$row['user_id']] = $row['group_id']; - } - $db->sql_freeresult($result); - - // What special group memberships exist for these users? - $sql = 'SELECT g.group_id, g.group_name, ug.user_id - FROM ' . USER_GROUP_TABLE . ' ug, ' . GROUPS_TABLE . ' g - WHERE ' . $db->sql_in_set('ug.user_id', $user_id_ary) . " - AND g.group_id = ug.group_id - AND g.group_id <> $group_id - AND g.group_type = " . GROUP_SPECIAL . ' - ORDER BY ug.user_id, g.group_id'; - $result = $db->sql_query($sql); - - $temp_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - if ($default_groups[$row['user_id']] == $group_id && (!isset($temp_ary[$row['user_id']]) || $group_order_id[$row['group_name']] < $temp_ary[$row['user_id']])) - { - $temp_ary[$row['user_id']] = $row['group_id']; - } - } - $db->sql_freeresult($result); - - // sql_where_ary holds the new default groups and their users - $sql_where_ary = array(); - foreach ($temp_ary as $uid => $gid) - { - $sql_where_ary[$gid][] = $uid; - } - unset($temp_ary); - - foreach ($special_group_data as $gid => $default_data_ary) - { - if (isset($sql_where_ary[$gid]) && count($sql_where_ary[$gid])) - { - remove_default_rank($group_id, $sql_where_ary[$gid]); - remove_default_avatar($group_id, $sql_where_ary[$gid]); - group_set_user_default($gid, $sql_where_ary[$gid], $default_data_ary); - } - } - unset($special_group_data); - - /** - * Event before users are removed from a group - * - * @event core.group_delete_user_before - * @var int group_id ID of the group from which users are deleted - * @var string group_name Name of the group - * @var array user_id_ary IDs of the users which are removed - * @var array username_ary names of the users which are removed - * @since 3.1.0-a1 - */ - $vars = array('group_id', 'group_name', 'user_id_ary', 'username_ary'); - extract($phpbb_dispatcher->trigger_event('core.group_delete_user_before', compact($vars))); - - $sql = 'DELETE FROM ' . USER_GROUP_TABLE . " - WHERE group_id = $group_id - AND " . $db->sql_in_set('user_id', $user_id_ary); - $db->sql_query($sql); - - // Clear permissions cache of relevant users - $auth->acl_clear_prefetch($user_id_ary); - - /** - * Event after users are removed from a group - * - * @event core.group_delete_user_after - * @var int group_id ID of the group from which users are deleted - * @var string group_name Name of the group - * @var array user_id_ary IDs of the users which are removed - * @var array username_ary names of the users which are removed - * @since 3.1.7-RC1 - */ - $vars = array('group_id', 'group_name', 'user_id_ary', 'username_ary'); - extract($phpbb_dispatcher->trigger_event('core.group_delete_user_after', compact($vars))); - - if ($log_action) - { - if (!$group_name) - { - $group_name = get_group_name($group_id); - } - - $log = 'LOG_GROUP_REMOVE'; - - if ($group_name) - { - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, $log, false, array($group_name, implode(', ', $username_ary))); - } - } - - group_update_listings($group_id); - - /* @var $phpbb_notifications \phpbb\notification\manager */ - $phpbb_notifications = $phpbb_container->get('notification_manager'); - - $phpbb_notifications->delete_notifications('notification.type.group_request', $user_id_ary, $group_id); - - // Return false - no error - return false; -} - - -/** -* Removes the group avatar of the default group from the users in user_ids who have that group as default. -*/ -function remove_default_avatar($group_id, $user_ids) -{ - global $db; - - if (!is_array($user_ids)) - { - $user_ids = array($user_ids); - } - if (empty($user_ids)) - { - return false; - } - - $user_ids = array_map('intval', $user_ids); - - $sql = 'SELECT * - FROM ' . GROUPS_TABLE . ' - WHERE group_id = ' . (int) $group_id; - $result = $db->sql_query($sql); - if (!$row = $db->sql_fetchrow($result)) - { - $db->sql_freeresult($result); - return false; - } - $db->sql_freeresult($result); - - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_avatar = '', - user_avatar_type = '', - user_avatar_width = 0, - user_avatar_height = 0 - WHERE group_id = " . (int) $group_id . " - AND user_avatar = '" . $db->sql_escape($row['group_avatar']) . "' - AND " . $db->sql_in_set('user_id', $user_ids); - - $db->sql_query($sql); -} - -/** -* Removes the group rank of the default group from the users in user_ids who have that group as default. -*/ -function remove_default_rank($group_id, $user_ids) -{ - global $db; - - if (!is_array($user_ids)) - { - $user_ids = array($user_ids); - } - if (empty($user_ids)) - { - return false; - } - - $user_ids = array_map('intval', $user_ids); - - $sql = 'SELECT * - FROM ' . GROUPS_TABLE . ' - WHERE group_id = ' . (int) $group_id; - $result = $db->sql_query($sql); - if (!$row = $db->sql_fetchrow($result)) - { - $db->sql_freeresult($result); - return false; - } - $db->sql_freeresult($result); - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_rank = 0 - WHERE group_id = ' . (int) $group_id . ' - AND user_rank <> 0 - AND user_rank = ' . (int) $row['group_rank'] . ' - AND ' . $db->sql_in_set('user_id', $user_ids); - $db->sql_query($sql); -} - -/** -* This is used to promote (to leader), demote or set as default a member/s -*/ -function group_user_attributes($action, $group_id, $user_id_ary = false, $username_ary = false, $group_name = false, $group_attributes = false) -{ - global $db, $auth, $user, $phpbb_container, $phpbb_log, $phpbb_dispatcher; - - // We need both username and user_id info - $result = user_get_id_name($user_id_ary, $username_ary); - - if (empty($user_id_ary) || $result !== false) - { - return 'NO_USERS'; - } - - if (!$group_name) - { - $group_name = get_group_name($group_id); - } - - switch ($action) - { - case 'demote': - case 'promote': - - $sql = 'SELECT user_id - FROM ' . USER_GROUP_TABLE . " - WHERE group_id = $group_id - AND user_pending = 1 - AND " . $db->sql_in_set('user_id', $user_id_ary); - $result = $db->sql_query_limit($sql, 1); - $not_empty = ($db->sql_fetchrow($result)); - $db->sql_freeresult($result); - if ($not_empty) - { - return 'NO_VALID_USERS'; - } - - $sql = 'UPDATE ' . USER_GROUP_TABLE . ' - SET group_leader = ' . (($action == 'promote') ? 1 : 0) . " - WHERE group_id = $group_id - AND user_pending = 0 - AND " . $db->sql_in_set('user_id', $user_id_ary); - $db->sql_query($sql); - - $log = ($action == 'promote') ? 'LOG_GROUP_PROMOTED' : 'LOG_GROUP_DEMOTED'; - break; - - case 'approve': - // Make sure we only approve those which are pending ;) - $sql = 'SELECT u.user_id, u.user_email, u.username, u.username_clean, u.user_notify_type, u.user_jabber, u.user_lang - FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . ' ug - WHERE ug.group_id = ' . $group_id . ' - AND ug.user_pending = 1 - AND ug.user_id = u.user_id - AND ' . $db->sql_in_set('ug.user_id', $user_id_ary); - $result = $db->sql_query($sql); - - $user_id_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - $user_id_ary[] = $row['user_id']; - } - $db->sql_freeresult($result); - - if (!count($user_id_ary)) - { - return false; - } - - $sql = 'UPDATE ' . USER_GROUP_TABLE . " - SET user_pending = 0 - WHERE group_id = $group_id - AND " . $db->sql_in_set('user_id', $user_id_ary); - $db->sql_query($sql); - - /* @var $phpbb_notifications \phpbb\notification\manager */ - $phpbb_notifications = $phpbb_container->get('notification_manager'); - - $phpbb_notifications->add_notifications('notification.type.group_request_approved', array( - 'user_ids' => $user_id_ary, - 'group_id' => $group_id, - 'group_name' => $group_name, - )); - $phpbb_notifications->delete_notifications('notification.type.group_request', $user_id_ary, $group_id); - - $log = 'LOG_USERS_APPROVED'; - break; - - case 'default': - // We only set default group for approved members of the group - $sql = 'SELECT user_id - FROM ' . USER_GROUP_TABLE . " - WHERE group_id = $group_id - AND user_pending = 0 - AND " . $db->sql_in_set('user_id', $user_id_ary); - $result = $db->sql_query($sql); - - $user_id_ary = $username_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - $user_id_ary[] = $row['user_id']; - } - $db->sql_freeresult($result); - - $result = user_get_id_name($user_id_ary, $username_ary); - if (!count($user_id_ary) || $result !== false) - { - return 'NO_USERS'; - } - - $sql = 'SELECT user_id, group_id - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('user_id', $user_id_ary, false, true); - $result = $db->sql_query($sql); - - $groups = array(); - while ($row = $db->sql_fetchrow($result)) - { - if (!isset($groups[$row['group_id']])) - { - $groups[$row['group_id']] = array(); - } - $groups[$row['group_id']][] = $row['user_id']; - } - $db->sql_freeresult($result); - - foreach ($groups as $gid => $uids) - { - remove_default_rank($gid, $uids); - remove_default_avatar($gid, $uids); - } - group_set_user_default($group_id, $user_id_ary, $group_attributes); - $log = 'LOG_GROUP_DEFAULTS'; - break; - } - - /** - * Event to perform additional actions on setting user group attributes - * - * @event core.user_set_group_attributes - * @var int group_id ID of the group - * @var string group_name Name of the group - * @var array user_id_ary IDs of the users to set group attributes - * @var array username_ary Names of the users to set group attributes - * @var array group_attributes Group attributes which were changed - * @var string action Action to perform over the group members - * @since 3.1.10-RC1 - */ - $vars = array( - 'group_id', - 'group_name', - 'user_id_ary', - 'username_ary', - 'group_attributes', - 'action', - ); - extract($phpbb_dispatcher->trigger_event('core.user_set_group_attributes', compact($vars))); - - // Clear permissions cache of relevant users - $auth->acl_clear_prefetch($user_id_ary); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, $log, false, array($group_name, implode(', ', $username_ary))); - - group_update_listings($group_id); - - return false; -} - -/** -* A small version of validate_username to check for a group name's existence. To be called directly. -*/ -function group_validate_groupname($group_id, $group_name) -{ - global $db; - - $group_name = utf8_clean_string($group_name); - - if (!empty($group_id)) - { - $sql = 'SELECT group_name - FROM ' . GROUPS_TABLE . ' - WHERE group_id = ' . (int) $group_id; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - return false; - } - - $allowed_groupname = utf8_clean_string($row['group_name']); - - if ($allowed_groupname == $group_name) - { - return false; - } - } - - $sql = 'SELECT group_name - FROM ' . GROUPS_TABLE . " - WHERE LOWER(group_name) = '" . $db->sql_escape(utf8_strtolower($group_name)) . "'"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - return 'GROUP_NAME_TAKEN'; - } - - return false; -} - -/** -* Set users default group -* -* @access private -*/ -function group_set_user_default($group_id, $user_id_ary, $group_attributes = false, $update_listing = false) -{ - global $config, $phpbb_container, $db, $phpbb_dispatcher; - - if (empty($user_id_ary)) - { - return; - } - - $attribute_ary = array( - 'group_colour' => 'string', - 'group_rank' => 'int', - 'group_avatar' => 'string', - 'group_avatar_type' => 'string', - 'group_avatar_width' => 'int', - 'group_avatar_height' => 'int', - ); - - $sql_ary = array( - 'group_id' => $group_id - ); - - // Were group attributes passed to the function? If not we need to obtain them - if ($group_attributes === false) - { - $sql = 'SELECT ' . implode(', ', array_keys($attribute_ary)) . ' - FROM ' . GROUPS_TABLE . " - WHERE group_id = $group_id"; - $result = $db->sql_query($sql); - $group_attributes = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - } - - foreach ($attribute_ary as $attribute => $type) - { - if (isset($group_attributes[$attribute])) - { - // If we are about to set an avatar or rank, we will not overwrite with empty, unless we are not actually changing the default group - if ((strpos($attribute, 'group_avatar') === 0 || strpos($attribute, 'group_rank') === 0) && !$group_attributes[$attribute]) - { - continue; - } - - settype($group_attributes[$attribute], $type); - $sql_ary[str_replace('group_', 'user_', $attribute)] = $group_attributes[$attribute]; - } - } - - $updated_sql_ary = $sql_ary; - - // Before we update the user attributes, we will update the rank for users that don't have a custom rank - if (isset($sql_ary['user_rank'])) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', array('user_rank' => $sql_ary['user_rank'])) . ' - WHERE user_rank = 0 - AND ' . $db->sql_in_set('user_id', $user_id_ary); - $db->sql_query($sql); - unset($sql_ary['user_rank']); - } - - // Before we update the user attributes, we will update the avatar for users that don't have a custom avatar - $avatar_options = array('user_avatar', 'user_avatar_type', 'user_avatar_height', 'user_avatar_width'); - - if (isset($sql_ary['user_avatar'])) - { - $avatar_sql_ary = array(); - foreach ($avatar_options as $avatar_option) - { - if (isset($sql_ary[$avatar_option])) - { - $avatar_sql_ary[$avatar_option] = $sql_ary[$avatar_option]; - } - } - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $avatar_sql_ary) . " - WHERE user_avatar = '' - AND " . $db->sql_in_set('user_id', $user_id_ary); - $db->sql_query($sql); - } - - // Remove the avatar options, as we already updated them - foreach ($avatar_options as $avatar_option) - { - unset($sql_ary[$avatar_option]); - } - - if (!empty($sql_ary)) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE ' . $db->sql_in_set('user_id', $user_id_ary); - $db->sql_query($sql); - } - - if (isset($sql_ary['user_colour'])) - { - // Update any cached colour information for these users - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET forum_last_poster_colour = '" . $db->sql_escape($sql_ary['user_colour']) . "' - WHERE " . $db->sql_in_set('forum_last_poster_id', $user_id_ary); - $db->sql_query($sql); - - $sql = 'UPDATE ' . TOPICS_TABLE . " - SET topic_first_poster_colour = '" . $db->sql_escape($sql_ary['user_colour']) . "' - WHERE " . $db->sql_in_set('topic_poster', $user_id_ary); - $db->sql_query($sql); - - $sql = 'UPDATE ' . TOPICS_TABLE . " - SET topic_last_poster_colour = '" . $db->sql_escape($sql_ary['user_colour']) . "' - WHERE " . $db->sql_in_set('topic_last_poster_id', $user_id_ary); - $db->sql_query($sql); - - if (in_array($config['newest_user_id'], $user_id_ary)) - { - $config->set('newest_user_colour', $sql_ary['user_colour'], false); - } - } - - // Make all values available for the event - $sql_ary = $updated_sql_ary; - - /** - * Event when the default group is set for an array of users - * - * @event core.user_set_default_group - * @var int group_id ID of the group - * @var array user_id_ary IDs of the users - * @var array group_attributes Group attributes which were changed - * @var array update_listing Update the list of moderators and foes - * @var array sql_ary User attributes which were changed - * @since 3.1.0-a1 - */ - $vars = array('group_id', 'user_id_ary', 'group_attributes', 'update_listing', 'sql_ary'); - extract($phpbb_dispatcher->trigger_event('core.user_set_default_group', compact($vars))); - - if ($update_listing) - { - group_update_listings($group_id); - } - - // Because some tables/caches use usercolour-specific data we need to purge this here. - $phpbb_container->get('cache.driver')->destroy('sql', MODERATOR_CACHE_TABLE); -} - -/** -* Get group name -*/ -function get_group_name($group_id) -{ - global $db, $phpbb_container; - - $sql = 'SELECT group_name, group_type - FROM ' . GROUPS_TABLE . ' - WHERE group_id = ' . (int) $group_id; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - return ''; - } - - /** @var \phpbb\group\helper $group_helper */ - $group_helper = $phpbb_container->get('group_helper'); - - return $group_helper->get_name($row['group_name']); -} - -/** -* Obtain either the members of a specified group, the groups the specified user is subscribed to -* or checking if a specified user is in a specified group. This function does not return pending memberships. -* -* Note: Never use this more than once... first group your users/groups -*/ -function group_memberships($group_id_ary = false, $user_id_ary = false, $return_bool = false) -{ - global $db; - - if (!$group_id_ary && !$user_id_ary) - { - return true; - } - - if ($user_id_ary) - { - $user_id_ary = (!is_array($user_id_ary)) ? array($user_id_ary) : $user_id_ary; - } - - if ($group_id_ary) - { - $group_id_ary = (!is_array($group_id_ary)) ? array($group_id_ary) : $group_id_ary; - } - - $sql = 'SELECT ug.*, u.username, u.username_clean, u.user_email - FROM ' . USER_GROUP_TABLE . ' ug, ' . USERS_TABLE . ' u - WHERE ug.user_id = u.user_id - AND ug.user_pending = 0 AND '; - - if ($group_id_ary) - { - $sql .= ' ' . $db->sql_in_set('ug.group_id', $group_id_ary); - } - - if ($user_id_ary) - { - $sql .= ($group_id_ary) ? ' AND ' : ' '; - $sql .= $db->sql_in_set('ug.user_id', $user_id_ary); - } - - $result = ($return_bool) ? $db->sql_query_limit($sql, 1) : $db->sql_query($sql); - - $row = $db->sql_fetchrow($result); - - if ($return_bool) - { - $db->sql_freeresult($result); - return ($row) ? true : false; - } - - if (!$row) - { - return false; - } - - $return = array(); - - do - { - $return[] = $row; - } - while ($row = $db->sql_fetchrow($result)); - - $db->sql_freeresult($result); - - return $return; -} - -/** -* Re-cache moderators and foes if group has a_ or m_ permissions -*/ -function group_update_listings($group_id) -{ - global $db, $cache, $auth; - - $hold_ary = $auth->acl_group_raw_data($group_id, array('a_', 'm_')); - - if (empty($hold_ary)) - { - return; - } - - $mod_permissions = $admin_permissions = false; - - foreach ($hold_ary as $g_id => $forum_ary) - { - foreach ($forum_ary as $forum_id => $auth_ary) - { - foreach ($auth_ary as $auth_option => $setting) - { - if ($mod_permissions && $admin_permissions) - { - break 3; - } - - if ($setting != ACL_YES) - { - continue; - } - - if ($auth_option == 'm_') - { - $mod_permissions = true; - } - - if ($auth_option == 'a_') - { - $admin_permissions = true; - } - } - } - } - - if ($mod_permissions) - { - if (!function_exists('phpbb_cache_moderators')) - { - global $phpbb_root_path, $phpEx; - include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); - } - phpbb_cache_moderators($db, $cache, $auth); - } - - if ($mod_permissions || $admin_permissions) - { - if (!function_exists('phpbb_update_foes')) - { - global $phpbb_root_path, $phpEx; - include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); - } - phpbb_update_foes($db, $auth, array($group_id)); - } -} - - - -/** -* Funtion to make a user leave the NEWLY_REGISTERED system group. -* @access public -* @param $user_id The id of the user to remove from the group -*/ -function remove_newly_registered($user_id, $user_data = false) -{ - global $db; - - if ($user_data === false) - { - $sql = 'SELECT * - FROM ' . USERS_TABLE . ' - WHERE user_id = ' . $user_id; - $result = $db->sql_query($sql); - $user_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$user_row) - { - return false; - } - else - { - $user_data = $user_row; - } - } - - $sql = 'SELECT group_id - FROM ' . GROUPS_TABLE . " - WHERE group_name = 'NEWLY_REGISTERED' - AND group_type = " . GROUP_SPECIAL; - $result = $db->sql_query($sql); - $group_id = (int) $db->sql_fetchfield('group_id'); - $db->sql_freeresult($result); - - if (!$group_id) - { - return false; - } - - // We need to call group_user_del here, because this function makes sure everything is correctly changed. - // Force function to not log the removal of users from newly registered users group - group_user_del($group_id, $user_id, false, false, false); - - // Set user_new to 0 to let this not be triggered again - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_new = 0 - WHERE user_id = ' . $user_id; - $db->sql_query($sql); - - // The new users group was the users default group? - if ($user_data['group_id'] == $group_id) - { - // Which group is now the users default one? - $sql = 'SELECT group_id - FROM ' . USERS_TABLE . ' - WHERE user_id = ' . $user_id; - $result = $db->sql_query($sql); - $user_data['group_id'] = $db->sql_fetchfield('group_id'); - $db->sql_freeresult($result); - } - - return $user_data['group_id']; -} - -/** -* Gets user ids of currently banned registered users. -* -* @param array $user_ids Array of users' ids to check for banning, -* leave empty to get complete list of banned ids -* @param bool|int $ban_end Bool True to get users currently banned -* Bool False to only get permanently banned users -* Int Unix timestamp to get users banned until that time -* @return array Array of banned users' ids if any, empty array otherwise -*/ -function phpbb_get_banned_user_ids($user_ids = array(), $ban_end = true) -{ - global $db; - - $sql_user_ids = (!empty($user_ids)) ? $db->sql_in_set('ban_userid', $user_ids) : 'ban_userid <> 0'; - - // Get banned User ID's - // Ignore stale bans which were not wiped yet - $banned_ids_list = array(); - $sql = 'SELECT ban_userid - FROM ' . BANLIST_TABLE . " - WHERE $sql_user_ids - AND ban_exclude <> 1"; - - if ($ban_end === true) - { - // Banned currently - $sql .= " AND (ban_end > " . time() . ' - OR ban_end = 0)'; - } - else if ($ban_end === false) - { - // Permanently banned - $sql .= " AND ban_end = 0"; - } - else - { - // Banned until a specified time - $sql .= " AND (ban_end > " . (int) $ban_end . ' - OR ban_end = 0)'; - } - - $result = $db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) - { - $user_id = (int) $row['ban_userid']; - $banned_ids_list[$user_id] = $user_id; - } - $db->sql_freeresult($result); - - return $banned_ids_list; -} - -/** -* Function for assigning a template var if the zebra module got included -*/ -function phpbb_module_zebra($mode, &$module_row) -{ - global $template; - - $template->assign_var('S_ZEBRA_ENABLED', true); - - if ($mode == 'friends') - { - $template->assign_var('S_ZEBRA_FRIENDS_ENABLED', true); - } - - if ($mode == 'foes') - { - $template->assign_var('S_ZEBRA_FOES_ENABLED', true); - } -} diff --git a/install/update/new/includes/mcp/mcp_ban.php b/install/update/new/includes/mcp/mcp_ban.php deleted file mode 100644 index 6f748f5..0000000 --- a/install/update/new/includes/mcp/mcp_ban.php +++ /dev/null @@ -1,301 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -class mcp_ban -{ - var $u_action; - - function main($id, $mode) - { - global $db, $user, $auth, $template, $request, $phpbb_dispatcher; - global $phpbb_root_path, $phpEx; - - if (!function_exists('user_ban')) - { - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - } - - // Include the admin banning interface... - if (!class_exists('acp_ban')) - { - include($phpbb_root_path . 'includes/acp/acp_ban.' . $phpEx); - } - - $bansubmit = $request->is_set_post('bansubmit'); - $unbansubmit = $request->is_set_post('unbansubmit'); - - $user->add_lang(array('acp/ban', 'acp/users')); - $this->tpl_name = 'mcp_ban'; - - /** - * Use this event to pass perform actions when a ban is issued or revoked - * - * @event core.mcp_ban_main - * @var bool bansubmit True if a ban is issued - * @var bool unbansubmit True if a ban is removed - * @var string mode Mode of the ban that is being worked on - * @since 3.1.0-RC5 - */ - $vars = array( - 'bansubmit', - 'unbansubmit', - 'mode', - ); - extract($phpbb_dispatcher->trigger_event('core.mcp_ban_main', compact($vars))); - - // Ban submitted? - if ($bansubmit) - { - // Grab the list of entries - $ban = $request->variable('ban', '', $mode === 'user'); - $ban_length = $request->variable('banlength', 0); - $ban_length_other = $request->variable('banlengthother', ''); - $ban_exclude = $request->variable('banexclude', 0); - $ban_reason = $request->variable('banreason', '', true); - $ban_give_reason = $request->variable('bangivereason', '', true); - - if ($ban) - { - if (confirm_box(true)) - { - $abort_ban = false; - /** - * Use this event to modify the ban details before the ban is performed - * - * @event core.mcp_ban_before - * @var string mode One of the following: user, ip, email - * @var string ban Either string or array with usernames, ips or email addresses - * @var int ban_length Ban length in minutes - * @var string ban_length_other Ban length as a date (YYYY-MM-DD) - * @var bool ban_exclude Are we banning or excluding from another ban - * @var string ban_reason Ban reason displayed to moderators - * @var string ban_give_reason Ban reason displayed to the banned user - * @var mixed abort_ban Either false, or an error message that is displayed to the user. - * If a string is given the bans are not issued. - * @since 3.1.0-RC5 - */ - $vars = array( - 'mode', - 'ban', - 'ban_length', - 'ban_length_other', - 'ban_exclude', - 'ban_reason', - 'ban_give_reason', - 'abort_ban', - ); - extract($phpbb_dispatcher->trigger_event('core.mcp_ban_before', compact($vars))); - - if ($abort_ban) - { - trigger_error($abort_ban); - } - user_ban($mode, $ban, $ban_length, $ban_length_other, $ban_exclude, $ban_reason, $ban_give_reason); - - /** - * Use this event to perform actions after the ban has been performed - * - * @event core.mcp_ban_after - * @var string mode One of the following: user, ip, email - * @var string ban Either string or array with usernames, ips or email addresses - * @var int ban_length Ban length in minutes - * @var string ban_length_other Ban length as a date (YYYY-MM-DD) - * @var bool ban_exclude Are we banning or excluding from another ban - * @var string ban_reason Ban reason displayed to moderators - * @var string ban_give_reason Ban reason displayed to the banned user - * @since 3.1.0-RC5 - */ - $vars = array( - 'mode', - 'ban', - 'ban_length', - 'ban_length_other', - 'ban_exclude', - 'ban_reason', - 'ban_give_reason', - ); - extract($phpbb_dispatcher->trigger_event('core.mcp_ban_after', compact($vars))); - - trigger_error($user->lang['BAN_UPDATE_SUCCESSFUL'] . '

« ' . $user->lang['BACK_TO_PREV'] . ''); - } - else - { - $hidden_fields = array( - 'mode' => $mode, - 'ban' => $ban, - 'bansubmit' => true, - 'banlength' => $ban_length, - 'banlengthother' => $ban_length_other, - 'banexclude' => $ban_exclude, - 'banreason' => $ban_reason, - 'bangivereason' => $ban_give_reason, - ); - - /** - * Use this event to pass data from the ban form to the confirmation screen - * - * @event core.mcp_ban_confirm - * @var array hidden_fields Hidden fields that are passed through the confirm screen - * @since 3.1.0-RC5 - */ - $vars = array('hidden_fields'); - extract($phpbb_dispatcher->trigger_event('core.mcp_ban_confirm', compact($vars))); - - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields($hidden_fields)); - } - } - } - else if ($unbansubmit) - { - $ban = $request->variable('unban', array('')); - - if ($ban) - { - if (confirm_box(true)) - { - user_unban($mode, $ban); - - trigger_error($user->lang['BAN_UPDATE_SUCCESSFUL'] . '

« ' . $user->lang['BACK_TO_PREV'] . ''); - } - else - { - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( - 'mode' => $mode, - 'unbansubmit' => true, - 'unban' => $ban))); - } - } - } - - // Ban length options - $ban_end_text = array(0 => $user->lang['PERMANENT'], 30 => $user->lang['30_MINS'], 60 => $user->lang['1_HOUR'], 360 => $user->lang['6_HOURS'], 1440 => $user->lang['1_DAY'], 10080 => $user->lang['7_DAYS'], 20160 => $user->lang['2_WEEKS'], 40320 => $user->lang['1_MONTH'], -1 => $user->lang['UNTIL'] . ' -> '); - - $ban_end_options = ''; - foreach ($ban_end_text as $length => $text) - { - $ban_end_options .= ''; - } - - // Define language vars - $this->page_title = $user->lang[strtoupper($mode) . '_BAN']; - - $l_ban_explain = $user->lang[strtoupper($mode) . '_BAN_EXPLAIN']; - $l_ban_exclude_explain = $user->lang[strtoupper($mode) . '_BAN_EXCLUDE_EXPLAIN']; - $l_unban_title = $user->lang[strtoupper($mode) . '_UNBAN']; - $l_unban_explain = $user->lang[strtoupper($mode) . '_UNBAN_EXPLAIN']; - $l_no_ban_cell = $user->lang[strtoupper($mode) . '_NO_BANNED']; - - switch ($mode) - { - case 'user': - $l_ban_cell = $user->lang['USERNAME']; - break; - - case 'ip': - $l_ban_cell = $user->lang['IP_HOSTNAME']; - break; - - case 'email': - $l_ban_cell = $user->lang['EMAIL_ADDRESS']; - break; - } - - acp_ban::display_ban_options($mode); - - $template->assign_vars(array( - 'L_TITLE' => $this->page_title, - 'L_EXPLAIN' => $l_ban_explain, - 'L_UNBAN_TITLE' => $l_unban_title, - 'L_UNBAN_EXPLAIN' => $l_unban_explain, - 'L_BAN_CELL' => $l_ban_cell, - 'L_BAN_EXCLUDE_EXPLAIN' => $l_ban_exclude_explain, - 'L_NO_BAN_CELL' => $l_no_ban_cell, - - 'S_USERNAME_BAN' => ($mode == 'user') ? true : false, - - 'U_ACTION' => $this->u_action, - 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=mcp_ban&field=ban'), - )); - - if ($mode === 'email' && !$auth->acl_get('a_user')) - { - return; - } - - // As a "service" we will check if any post id is specified and populate the username of the poster id if given - $post_id = $request->variable('p', 0); - $user_id = $request->variable('u', 0); - $pre_fill = false; - - if ($user_id && $user_id <> ANONYMOUS) - { - $sql = 'SELECT username, user_email, user_ip - FROM ' . USERS_TABLE . ' - WHERE user_id = ' . $user_id; - $result = $db->sql_query($sql); - switch ($mode) - { - case 'user': - $pre_fill = (string) $db->sql_fetchfield('username'); - break; - - case 'ip': - $pre_fill = (string) $db->sql_fetchfield('user_ip'); - break; - - case 'email': - $pre_fill = (string) $db->sql_fetchfield('user_email'); - break; - } - $db->sql_freeresult($result); - } - else if ($post_id) - { - $post_info = phpbb_get_post_data(array($post_id), 'm_ban'); - - if (count($post_info) && !empty($post_info[$post_id])) - { - switch ($mode) - { - case 'user': - $pre_fill = $post_info[$post_id]['username']; - break; - - case 'ip': - $pre_fill = $post_info[$post_id]['poster_ip']; - break; - - case 'email': - $pre_fill = $post_info[$post_id]['user_email']; - break; - } - - } - } - - if ($pre_fill) - { - // left for legacy template compatibility - $template->assign_var('USERNAMES', $pre_fill); - $template->assign_var('BAN_QUANTIFIER', $pre_fill); - } - } -} diff --git a/install/update/new/includes/mcp/mcp_logs.php b/install/update/new/includes/mcp/mcp_logs.php deleted file mode 100644 index dc098fc..0000000 --- a/install/update/new/includes/mcp/mcp_logs.php +++ /dev/null @@ -1,230 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* mcp_logs -* Handling warning the users -*/ -class mcp_logs -{ - var $u_action; - var $p_master; - - function __construct($p_master) - { - $this->p_master = $p_master; - } - - function main($id, $mode) - { - global $auth, $db, $user, $template, $request; - global $config, $phpbb_container, $phpbb_log; - - $user->add_lang('acp/common'); - - $action = $request->variable('action', array('' => '')); - - if (is_array($action)) - { - $action = key($action); - } - else - { - $action = $request->variable('action', ''); - } - - // Set up general vars - $start = $request->variable('start', 0); - $deletemark = ($action == 'del_marked') ? true : false; - $deleteall = ($action == 'del_all') ? true : false; - $marked = $request->variable('mark', array(0)); - - // Sort keys - $sort_days = $request->variable('st', 0); - $sort_key = $request->variable('sk', 't'); - $sort_dir = $request->variable('sd', 'd'); - - $this->tpl_name = 'mcp_logs'; - $this->page_title = 'MCP_LOGS'; - - /* @var $pagination \phpbb\pagination */ - $pagination = $phpbb_container->get('pagination'); - - $forum_list = array_values(array_intersect(get_forum_list('f_read'), get_forum_list('m_'))); - $forum_list[] = 0; - - $forum_id = $topic_id = 0; - - switch ($mode) - { - case 'front': - break; - - case 'forum_logs': - $forum_id = $request->variable('f', 0); - - if (!in_array($forum_id, $forum_list)) - { - send_status_line(403, 'Forbidden'); - trigger_error('NOT_AUTHORISED'); - } - - $forum_list = array($forum_id); - break; - - case 'topic_logs': - $topic_id = $request->variable('t', 0); - - $sql = 'SELECT forum_id - FROM ' . TOPICS_TABLE . ' - WHERE topic_id = ' . $topic_id; - $result = $db->sql_query($sql); - $forum_id = (int) $db->sql_fetchfield('forum_id'); - $db->sql_freeresult($result); - - if (!in_array($forum_id, $forum_list)) - { - send_status_line(403, 'Forbidden'); - trigger_error('NOT_AUTHORISED'); - } - - $forum_list = array($forum_id); - break; - } - - // Delete entries if requested and able - if (($deletemark || $deleteall) && $auth->acl_get('a_clearlogs')) - { - if (confirm_box(true)) - { - if ($deletemark && count($marked)) - { - $conditions = array( - 'forum_id' => array('IN' => $forum_list), - 'log_id' => array('IN' => $marked), - ); - - $phpbb_log->delete('mod', $conditions); - } - else if ($deleteall) - { - $keywords = $request->variable('keywords', '', true); - - $conditions = array( - 'forum_id' => array('IN' => $forum_list), - 'keywords' => $keywords, - ); - - if ($sort_days) - { - $conditions['log_time'] = array('>=', time() - ($sort_days * 86400)); - } - - if ($mode == 'topic_logs') - { - $conditions['topic_id'] = $topic_id; - } - - $phpbb_log->delete('mod', $conditions); - } - } - else - { - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( - 'f' => $forum_id, - 't' => $topic_id, - 'start' => $start, - 'delmarked' => $deletemark, - 'delall' => $deleteall, - 'mark' => $marked, - 'st' => $sort_days, - 'sk' => $sort_key, - 'sd' => $sort_dir, - 'i' => $id, - 'mode' => $mode, - 'action' => $request->variable('action', array('' => '')))) - ); - } - } - - // Sorting - $limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); - $sort_by_text = array('u' => $user->lang['SORT_USERNAME'], 't' => $user->lang['SORT_DATE'], 'i' => $user->lang['SORT_IP'], 'o' => $user->lang['SORT_ACTION']); - $sort_by_sql = array('u' => 'u.username_clean', 't' => 'l.log_time', 'i' => 'l.log_ip', 'o' => 'l.log_operation'); - - $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; - gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); - - // Define where and sort sql for use in displaying logs - $sql_where = ($sort_days) ? (time() - ($sort_days * 86400)) : 0; - $sql_sort = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'); - - $keywords = $request->variable('keywords', '', true); - $keywords_param = !empty($keywords) ? '&keywords=' . urlencode(htmlspecialchars_decode($keywords)) : ''; - - // Grab log data - $log_data = array(); - $log_count = 0; - $start = view_log('mod', $log_data, $log_count, $config['topics_per_page'], $start, $forum_list, $topic_id, 0, $sql_where, $sql_sort, $keywords); - - $base_url = $this->u_action . "&$u_sort_param$keywords_param"; - $pagination->generate_template_pagination($base_url, 'pagination', 'start', $log_count, $config['topics_per_page'], $start); - - $template->assign_vars(array( - 'TOTAL' => $user->lang('TOTAL_LOGS', (int) $log_count), - - 'L_TITLE' => $user->lang['MCP_LOGS'], - - 'U_POST_ACTION' => $this->u_action . "&$u_sort_param$keywords_param&start=$start", - 'S_CLEAR_ALLOWED' => ($auth->acl_get('a_clearlogs')) ? true : false, - 'S_SELECT_SORT_DIR' => $s_sort_dir, - 'S_SELECT_SORT_KEY' => $s_sort_key, - 'S_SELECT_SORT_DAYS' => $s_limit_days, - 'S_LOGS' => ($log_count > 0), - 'S_KEYWORDS' => $keywords, - ) - ); - - foreach ($log_data as $row) - { - $data = array(); - - $checks = array('viewpost', 'viewtopic', 'viewforum'); - foreach ($checks as $check) - { - if (isset($row[$check]) && $row[$check]) - { - $data[] = '' . $user->lang['LOGVIEW_' . strtoupper($check)] . ''; - } - } - - $template->assign_block_vars('log', array( - 'USERNAME' => $row['username_full'], - 'IP' => $row['ip'], - 'DATE' => $user->format_date($row['time']), - 'ACTION' => $row['action'], - 'DATA' => (count($data)) ? implode(' | ', $data) : '', - 'ID' => $row['id'], - ) - ); - } - } -} diff --git a/install/update/new/includes/mcp/mcp_main.php b/install/update/new/includes/mcp/mcp_main.php deleted file mode 100644 index 744eaeb..0000000 --- a/install/update/new/includes/mcp/mcp_main.php +++ /dev/null @@ -1,1717 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* mcp_main -* Handling mcp actions -*/ -class mcp_main -{ - var $p_master; - var $u_action; - - function __construct($p_master) - { - $this->p_master = $p_master; - } - - function main($id, $mode) - { - global $auth, $user, $action; - global $phpbb_root_path, $phpEx, $request; - global $phpbb_dispatcher; - - $quickmod = ($mode == 'quickmod') ? true : false; - - /** - * Event to perform additional actions before an MCP action is executed. - * - * @event core.mcp_main_before - * @var string action The action that is about to be performed - * @var string mode The mode in which the MCP is accessed, e.g. front, forum_view, topic_view, post_details, quickmod - * @var boolean quickmod Whether or not the action is performed via QuickMod - * @since 3.2.8-RC1 - */ - $vars = [ - 'action', - 'mode', - 'quickmod', - ]; - extract($phpbb_dispatcher->trigger_event('core.mcp_main_before', compact($vars))); - - switch ($action) - { - case 'lock': - case 'unlock': - $topic_ids = (!$quickmod) ? $request->variable('topic_id_list', array(0)) : array($request->variable('t', 0)); - - if (!count($topic_ids)) - { - trigger_error('NO_TOPIC_SELECTED'); - } - - lock_unlock($action, $topic_ids); - break; - - case 'lock_post': - case 'unlock_post': - - $post_ids = (!$quickmod) ? $request->variable('post_id_list', array(0)) : array($request->variable('p', 0)); - - if (!count($post_ids)) - { - trigger_error('NO_POST_SELECTED'); - } - - lock_unlock($action, $post_ids); - break; - - case 'make_announce': - case 'make_sticky': - case 'make_global': - case 'make_normal': - - $topic_ids = (!$quickmod) ? $request->variable('topic_id_list', array(0)) : array($request->variable('t', 0)); - - if (!count($topic_ids)) - { - trigger_error('NO_TOPIC_SELECTED'); - } - - change_topic_type($action, $topic_ids); - break; - - case 'move': - $user->add_lang('viewtopic'); - - $topic_ids = (!$quickmod) ? $request->variable('topic_id_list', array(0)) : array($request->variable('t', 0)); - - if (!count($topic_ids)) - { - trigger_error('NO_TOPIC_SELECTED'); - } - - mcp_move_topic($topic_ids); - break; - - case 'fork': - $user->add_lang('viewtopic'); - - $topic_ids = (!$quickmod) ? $request->variable('topic_id_list', array(0)) : array($request->variable('t', 0)); - - if (!count($topic_ids)) - { - trigger_error('NO_TOPIC_SELECTED'); - } - - mcp_fork_topic($topic_ids); - break; - - case 'delete_topic': - $user->add_lang('viewtopic'); - - // f parameter is not reliable for permission usage, however we just use it to decide - // which permission we will check later on. So if it is manipulated, we will still catch it later on. - $forum_id = $request->variable('f', 0); - $topic_ids = (!$quickmod) ? $request->variable('topic_id_list', array(0)) : array($request->variable('t', 0)); - $soft_delete = (($request->is_set_post('confirm') && !$request->is_set_post('delete_permanent')) || !$auth->acl_get('m_delete', $forum_id)) ? true : false; - - if (!count($topic_ids)) - { - trigger_error('NO_TOPIC_SELECTED'); - } - - mcp_delete_topic($topic_ids, $soft_delete, $request->variable('delete_reason', '', true)); - break; - - case 'delete_post': - $user->add_lang('posting'); - - // f parameter is not reliable for permission usage, however we just use it to decide - // which permission we will check later on. So if it is manipulated, we will still catch it later on. - $forum_id = $request->variable('f', 0); - $post_ids = (!$quickmod) ? $request->variable('post_id_list', array(0)) : array($request->variable('p', 0)); - $soft_delete = (($request->is_set_post('confirm') && !$request->is_set_post('delete_permanent')) || !$auth->acl_get('m_delete', $forum_id)) ? true : false; - - if (!count($post_ids)) - { - trigger_error('NO_POST_SELECTED'); - } - - mcp_delete_post($post_ids, $soft_delete, $request->variable('delete_reason', '', true)); - break; - - case 'restore_topic': - $user->add_lang('posting'); - - $topic_ids = (!$quickmod) ? $request->variable('topic_id_list', array(0)) : array($request->variable('t', 0)); - - if (!count($topic_ids)) - { - trigger_error('NO_TOPIC_SELECTED'); - } - - mcp_restore_topic($topic_ids); - break; - - default: - /** - * This event allows you to handle custom quickmod options - * - * @event core.modify_quickmod_actions - * @var string action Topic quick moderation action name - * @var bool quickmod Flag indicating whether MCP is in quick moderation mode - * @since 3.1.0-a4 - * @changed 3.1.0-RC4 Added variables: action, quickmod - */ - $vars = array('action', 'quickmod'); - extract($phpbb_dispatcher->trigger_event('core.modify_quickmod_actions', compact($vars))); - break; - } - - switch ($mode) - { - case 'front': - if (!function_exists('mcp_front_view')) - { - include($phpbb_root_path . 'includes/mcp/mcp_front.' . $phpEx); - } - - $user->add_lang('acp/common'); - - mcp_front_view($id, $mode, $action); - - $this->tpl_name = 'mcp_front'; - $this->page_title = 'MCP_MAIN'; - break; - - case 'forum_view': - if (!function_exists('mcp_forum_view')) - { - include($phpbb_root_path . 'includes/mcp/mcp_forum.' . $phpEx); - } - - $user->add_lang('viewforum'); - - $forum_id = $request->variable('f', 0); - - $forum_info = phpbb_get_forum_data($forum_id, 'm_', true); - - if (!count($forum_info)) - { - $this->main('main', 'front'); - return; - } - - $forum_info = $forum_info[$forum_id]; - - mcp_forum_view($id, $mode, $action, $forum_info); - - $this->tpl_name = 'mcp_forum'; - $this->page_title = 'MCP_MAIN_FORUM_VIEW'; - break; - - case 'topic_view': - if (!function_exists('mcp_topic_view')) - { - include($phpbb_root_path . 'includes/mcp/mcp_topic.' . $phpEx); - } - - mcp_topic_view($id, $mode, $action); - - $this->tpl_name = 'mcp_topic'; - $this->page_title = 'MCP_MAIN_TOPIC_VIEW'; - break; - - case 'post_details': - if (!function_exists('mcp_post_details')) - { - include($phpbb_root_path . 'includes/mcp/mcp_post.' . $phpEx); - } - - mcp_post_details($id, $mode, $action); - - $this->tpl_name = ($action == 'whois') ? 'mcp_whois' : 'mcp_post'; - $this->page_title = 'MCP_MAIN_POST_DETAILS'; - break; - - default: - if ($quickmod) - { - switch ($action) - { - case 'lock': - case 'unlock': - case 'make_announce': - case 'make_sticky': - case 'make_global': - case 'make_normal': - case 'make_onindex': - case 'move': - case 'fork': - case 'delete_topic': - trigger_error('TOPIC_NOT_EXIST'); - break; - - case 'lock_post': - case 'unlock_post': - case 'delete_post': - trigger_error('POST_NOT_EXIST'); - break; - } - } - - trigger_error('NO_MODE', E_USER_ERROR); - break; - } - } -} - -/** -* Lock/Unlock Topic/Post -*/ -function lock_unlock($action, $ids) -{ - global $user, $db, $request, $phpbb_log, $phpbb_dispatcher; - - if ($action == 'lock' || $action == 'unlock') - { - $table = TOPICS_TABLE; - $sql_id = 'topic_id'; - $set_id = 'topic_status'; - $l_prefix = 'TOPIC'; - } - else - { - $table = POSTS_TABLE; - $sql_id = 'post_id'; - $set_id = 'post_edit_locked'; - $l_prefix = 'POST'; - } - - $orig_ids = $ids; - - if (!phpbb_check_ids($ids, $table, $sql_id, array('m_lock'))) - { - // Make sure that for f_user_lock only the lock action is triggered. - if ($action != 'lock') - { - return; - } - - $ids = $orig_ids; - - if (!phpbb_check_ids($ids, $table, $sql_id, array('f_user_lock'))) - { - return; - } - } - unset($orig_ids); - - $redirect = $request->variable('redirect', build_url(array('action', 'quickmod'))); - $redirect = reapply_sid($redirect); - - $s_hidden_fields = build_hidden_fields(array( - $sql_id . '_list' => $ids, - 'action' => $action, - 'redirect' => $redirect) - ); - - if (confirm_box(true)) - { - $sql = "UPDATE $table - SET $set_id = " . (($action == 'lock' || $action == 'lock_post') ? ITEM_LOCKED : ITEM_UNLOCKED) . ' - WHERE ' . $db->sql_in_set($sql_id, $ids); - $db->sql_query($sql); - - $data = ($action == 'lock' || $action == 'unlock') ? phpbb_get_topic_data($ids) : phpbb_get_post_data($ids); - - foreach ($data as $id => $row) - { - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_' . strtoupper($action), false, array( - 'forum_id' => $row['forum_id'], - 'topic_id' => $row['topic_id'], - 'post_id' => isset($row['post_id']) ? $row['post_id'] : 0, - $row['topic_title'] - )); - } - - /** - * Perform additional actions after locking/unlocking posts/topics - * - * @event core.mcp_lock_unlock_after - * @var string action Variable containing the action we perform on the posts/topics ('lock', 'unlock', 'lock_post' or 'unlock_post') - * @var array ids Array containing the post/topic IDs that have been locked/unlocked - * @var array data Array containing posts/topics data - * @since 3.1.7-RC1 - */ - $vars = array( - 'action', - 'ids', - 'data', - ); - extract($phpbb_dispatcher->trigger_event('core.mcp_lock_unlock_after', compact($vars))); - - $success_msg = $l_prefix . ((count($ids) == 1) ? '' : 'S') . '_' . (($action == 'lock' || $action == 'lock_post') ? 'LOCKED' : 'UNLOCKED') . '_SUCCESS'; - - meta_refresh(2, $redirect); - $message = $user->lang[$success_msg]; - - if (!$request->is_ajax()) - { - $message .= '

' . $user->lang('RETURN_PAGE', '', ''); - } - trigger_error($message); - } - else - { - confirm_box(false, strtoupper($action) . '_' . $l_prefix . ((count($ids) == 1) ? '' : 'S'), $s_hidden_fields); - } - - redirect($redirect); -} - -/** -* Change Topic Type -*/ -function change_topic_type($action, $topic_ids) -{ - global $user, $db, $request, $phpbb_log, $phpbb_dispatcher; - - switch ($action) - { - case 'make_announce': - $new_topic_type = POST_ANNOUNCE; - $check_acl = 'f_announce'; - $l_new_type = (count($topic_ids) == 1) ? 'MCP_MAKE_ANNOUNCEMENT' : 'MCP_MAKE_ANNOUNCEMENTS'; - break; - - case 'make_global': - $new_topic_type = POST_GLOBAL; - $check_acl = 'f_announce_global'; - $l_new_type = (count($topic_ids) == 1) ? 'MCP_MAKE_GLOBAL' : 'MCP_MAKE_GLOBALS'; - break; - - case 'make_sticky': - $new_topic_type = POST_STICKY; - $check_acl = 'f_sticky'; - $l_new_type = (count($topic_ids) == 1) ? 'MCP_MAKE_STICKY' : 'MCP_MAKE_STICKIES'; - break; - - default: - $new_topic_type = POST_NORMAL; - $check_acl = false; - $l_new_type = (count($topic_ids) == 1) ? 'MCP_MAKE_NORMAL' : 'MCP_MAKE_NORMALS'; - break; - } - - $forum_id = phpbb_check_ids($topic_ids, TOPICS_TABLE, 'topic_id', $check_acl, true); - - if ($forum_id === false) - { - return; - } - - $redirect = $request->variable('redirect', build_url(array('action', 'quickmod'))); - $redirect = reapply_sid($redirect); - - $s_hidden_fields = array( - 'topic_id_list' => $topic_ids, - 'f' => $forum_id, - 'action' => $action, - 'redirect' => $redirect, - ); - - if (confirm_box(true)) - { - - /** - * Perform additional actions before changing topic(s) type - * - * @event core.mcp_change_topic_type_before - * @var int new_topic_type The candidated topic type. - * @var int forum_id The forum ID for the topic ID(s). - * @var array topic_ids Array containing the topic ID(s) that will be changed - * @since 3.2.6-RC1 - */ - $vars = array( - 'new_topic_type', - 'forum_id', - 'topic_ids', - ); - extract($phpbb_dispatcher->trigger_event('core.mcp_change_topic_type_before', compact($vars))); - - $db->sql_transaction('begin'); - - $sql = 'UPDATE ' . TOPICS_TABLE . " - SET topic_type = $new_topic_type - WHERE " . $db->sql_in_set('topic_id', $topic_ids); - $db->sql_query($sql); - - if (($new_topic_type == POST_GLOBAL) && count($topic_ids)) - { - // Delete topic shadows for global announcements - $sql = 'DELETE FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_moved_id', $topic_ids); - $db->sql_query($sql); - } - - $db->sql_transaction('commit'); - - $success_msg = (count($topic_ids) == 1) ? 'TOPIC_TYPE_CHANGED' : 'TOPICS_TYPE_CHANGED'; - - if (count($topic_ids)) - { - $data = phpbb_get_topic_data($topic_ids); - - foreach ($data as $topic_id => $row) - { - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_TOPIC_TYPE_CHANGED', false, array( - 'forum_id' => $forum_id, - 'topic_id' => $topic_id, - $row['topic_title'] - )); - } - } - - /** - * Perform additional actions after changing topic types - * - * @event core.mcp_change_topic_type_after - * @var int new_topic_type The newly changed topic type. - * @var int forum_id The forum ID where the newly changed topic type belongs to. - * @var array topic_ids Array containing the topic IDs that have been changed - * @since 3.2.6-RC1 - */ - $vars = array( - 'new_topic_type', - 'forum_id', - 'topic_ids', - ); - extract($phpbb_dispatcher->trigger_event('core.mcp_change_topic_type_after', compact($vars))); - - meta_refresh(2, $redirect); - $message = $user->lang[$success_msg]; - - if (!$request->is_ajax()) - { - $message .= '

' . $user->lang('RETURN_PAGE', '', ''); - } - trigger_error($message); - } - else - { - confirm_box(false, $l_new_type, build_hidden_fields($s_hidden_fields)); - } - - redirect($redirect); -} - -/** -* Move Topic -*/ -function mcp_move_topic($topic_ids) -{ - global $auth, $user, $db, $template, $phpbb_log, $request, $phpbb_dispatcher; - global $phpEx, $phpbb_root_path; - - // Here we limit the operation to one forum only - $forum_id = phpbb_check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array('m_move'), true); - - if ($forum_id === false) - { - return; - } - - $to_forum_id = $request->variable('to_forum_id', 0); - $redirect = $request->variable('redirect', build_url(array('action', 'quickmod'))); - $additional_msg = $success_msg = ''; - - $s_hidden_fields = build_hidden_fields(array( - 'topic_id_list' => $topic_ids, - 'f' => $forum_id, - 'action' => 'move', - 'redirect' => $redirect) - ); - - if ($to_forum_id) - { - $forum_data = phpbb_get_forum_data($to_forum_id, 'f_post'); - - if (!count($forum_data)) - { - $additional_msg = $user->lang['FORUM_NOT_EXIST']; - } - else - { - $forum_data = $forum_data[$to_forum_id]; - - if ($forum_data['forum_type'] != FORUM_POST) - { - $additional_msg = $user->lang['FORUM_NOT_POSTABLE']; - } - else if (!$auth->acl_get('f_post', $to_forum_id) || (!$auth->acl_get('m_approve', $to_forum_id) && !$auth->acl_get('f_noapprove', $to_forum_id))) - { - $additional_msg = $user->lang['USER_CANNOT_POST']; - } - else if ($forum_id == $to_forum_id) - { - $additional_msg = $user->lang['CANNOT_MOVE_SAME_FORUM']; - } - } - } - else if (isset($_POST['confirm'])) - { - $additional_msg = $user->lang['FORUM_NOT_EXIST']; - } - - if (!$to_forum_id || $additional_msg) - { - $request->overwrite('confirm', null, \phpbb\request\request_interface::POST); - $request->overwrite('confirm_key', null); - } - - if (confirm_box(true)) - { - $topic_data = phpbb_get_topic_data($topic_ids); - $leave_shadow = (isset($_POST['move_leave_shadow'])) ? true : false; - - $forum_sync_data = array(); - - $forum_sync_data[$forum_id] = current($topic_data); - $forum_sync_data[$to_forum_id] = $forum_data; - - $topics_moved = $topics_moved_unapproved = $topics_moved_softdeleted = 0; - $posts_moved = $posts_moved_unapproved = $posts_moved_softdeleted = 0; - - foreach ($topic_data as $topic_id => $topic_info) - { - if ($topic_info['topic_visibility'] == ITEM_APPROVED) - { - $topics_moved++; - } - else if ($topic_info['topic_visibility'] == ITEM_UNAPPROVED || $topic_info['topic_visibility'] == ITEM_REAPPROVE) - { - $topics_moved_unapproved++; - } - else if ($topic_info['topic_visibility'] == ITEM_DELETED) - { - $topics_moved_softdeleted++; - } - - $posts_moved += $topic_info['topic_posts_approved']; - $posts_moved_unapproved += $topic_info['topic_posts_unapproved']; - $posts_moved_softdeleted += $topic_info['topic_posts_softdeleted']; - } - - $db->sql_transaction('begin'); - - // Move topics, but do not resync yet - move_topics($topic_ids, $to_forum_id, false); - - if ($request->is_set_post('move_lock_topics') && $auth->acl_get('m_lock', $to_forum_id)) - { - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_status = ' . ITEM_LOCKED . ' - WHERE ' . $db->sql_in_set('topic_id', $topic_ids); - $db->sql_query($sql); - } - - $shadow_topics = 0; - $forum_ids = array($to_forum_id); - foreach ($topic_data as $topic_id => $row) - { - // Get the list of forums to resync - $forum_ids[] = $row['forum_id']; - - // We add the $to_forum_id twice, because 'forum_id' is updated - // when the topic is moved again later. - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_MOVE', false, array( - 'forum_id' => (int) $to_forum_id, - 'topic_id' => (int) $topic_id, - $row['forum_name'], - $forum_data['forum_name'], - (int) $row['forum_id'], - (int) $forum_data['forum_id'], - )); - - // Leave a redirection if required and only if the topic is visible to users - if ($leave_shadow && $row['topic_visibility'] == ITEM_APPROVED && $row['topic_type'] != POST_GLOBAL) - { - $shadow = array( - 'forum_id' => (int) $row['forum_id'], - 'icon_id' => (int) $row['icon_id'], - 'topic_attachment' => (int) $row['topic_attachment'], - 'topic_visibility' => ITEM_APPROVED, // a shadow topic is always approved - 'topic_reported' => 0, // a shadow topic is never reported - 'topic_title' => (string) $row['topic_title'], - 'topic_poster' => (int) $row['topic_poster'], - 'topic_time' => (int) $row['topic_time'], - 'topic_time_limit' => (int) $row['topic_time_limit'], - 'topic_views' => (int) $row['topic_views'], - 'topic_posts_approved' => (int) $row['topic_posts_approved'], - 'topic_posts_unapproved'=> (int) $row['topic_posts_unapproved'], - 'topic_posts_softdeleted'=> (int) $row['topic_posts_softdeleted'], - 'topic_status' => ITEM_MOVED, - 'topic_type' => POST_NORMAL, - 'topic_first_post_id' => (int) $row['topic_first_post_id'], - 'topic_first_poster_colour'=>(string) $row['topic_first_poster_colour'], - 'topic_first_poster_name'=> (string) $row['topic_first_poster_name'], - 'topic_last_post_id' => (int) $row['topic_last_post_id'], - 'topic_last_poster_id' => (int) $row['topic_last_poster_id'], - 'topic_last_poster_colour'=>(string) $row['topic_last_poster_colour'], - 'topic_last_poster_name'=> (string) $row['topic_last_poster_name'], - 'topic_last_post_subject'=> (string) $row['topic_last_post_subject'], - 'topic_last_post_time' => (int) $row['topic_last_post_time'], - 'topic_last_view_time' => (int) $row['topic_last_view_time'], - 'topic_moved_id' => (int) $row['topic_id'], - 'topic_bumped' => (int) $row['topic_bumped'], - 'topic_bumper' => (int) $row['topic_bumper'], - 'poll_title' => (string) $row['poll_title'], - 'poll_start' => (int) $row['poll_start'], - 'poll_length' => (int) $row['poll_length'], - 'poll_max_options' => (int) $row['poll_max_options'], - 'poll_last_vote' => (int) $row['poll_last_vote'] - ); - - /** - * Perform actions before shadow topic is created. - * - * @event core.mcp_main_modify_shadow_sql - * @var array shadow SQL array to be used by $db->sql_build_array - * @var array row Topic data - * @since 3.1.11-RC1 - * @changed 3.1.11-RC1 Added variable: row - */ - $vars = array( - 'shadow', - 'row', - ); - extract($phpbb_dispatcher->trigger_event('core.mcp_main_modify_shadow_sql', compact($vars))); - - $db->sql_query('INSERT INTO ' . TOPICS_TABLE . $db->sql_build_array('INSERT', $shadow)); - - // Shadow topics only count on new "topics" and not posts... a shadow topic alone has 0 posts - $shadow_topics++; - } - } - unset($topic_data); - - $sync_sql = array(); - if ($posts_moved) - { - $sync_sql[$to_forum_id][] = 'forum_posts_approved = forum_posts_approved + ' . (int) $posts_moved; - $sync_sql[$forum_id][] = 'forum_posts_approved = forum_posts_approved - ' . (int) $posts_moved; - } - if ($posts_moved_unapproved) - { - $sync_sql[$to_forum_id][] = 'forum_posts_unapproved = forum_posts_unapproved + ' . (int) $posts_moved_unapproved; - $sync_sql[$forum_id][] = 'forum_posts_unapproved = forum_posts_unapproved - ' . (int) $posts_moved_unapproved; - } - if ($posts_moved_softdeleted) - { - $sync_sql[$to_forum_id][] = 'forum_posts_softdeleted = forum_posts_softdeleted + ' . (int) $posts_moved_softdeleted; - $sync_sql[$forum_id][] = 'forum_posts_softdeleted = forum_posts_softdeleted - ' . (int) $posts_moved_softdeleted; - } - - if ($topics_moved) - { - $sync_sql[$to_forum_id][] = 'forum_topics_approved = forum_topics_approved + ' . (int) $topics_moved; - if ($topics_moved - $shadow_topics > 0) - { - $sync_sql[$forum_id][] = 'forum_topics_approved = forum_topics_approved - ' . (int) ($topics_moved - $shadow_topics); - } - } - if ($topics_moved_unapproved) - { - $sync_sql[$to_forum_id][] = 'forum_topics_unapproved = forum_topics_unapproved + ' . (int) $topics_moved_unapproved; - $sync_sql[$forum_id][] = 'forum_topics_unapproved = forum_topics_unapproved - ' . (int) $topics_moved_unapproved; - } - if ($topics_moved_softdeleted) - { - $sync_sql[$to_forum_id][] = 'forum_topics_softdeleted = forum_topics_softdeleted + ' . (int) $topics_moved_softdeleted; - $sync_sql[$forum_id][] = 'forum_topics_softdeleted = forum_topics_softdeleted - ' . (int) $topics_moved_softdeleted; - } - - $success_msg = (count($topic_ids) == 1) ? 'TOPIC_MOVED_SUCCESS' : 'TOPICS_MOVED_SUCCESS'; - - foreach ($sync_sql as $forum_id_key => $array) - { - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET ' . implode(', ', $array) . ' - WHERE forum_id = ' . $forum_id_key; - $db->sql_query($sql); - } - - $db->sql_transaction('commit'); - - sync('forum', 'forum_id', array($forum_id, $to_forum_id)); - } - else - { - $template->assign_vars(array( - 'S_FORUM_SELECT' => make_forum_select($to_forum_id, $forum_id, false, true, true, true), - 'S_CAN_LEAVE_SHADOW' => true, - 'S_CAN_LOCK_TOPIC' => ($auth->acl_get('m_lock', $to_forum_id)) ? true : false, - 'ADDITIONAL_MSG' => $additional_msg) - ); - - confirm_box(false, 'MOVE_TOPIC' . ((count($topic_ids) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_move.html'); - } - - $redirect = $request->variable('redirect', "index.$phpEx"); - $redirect = reapply_sid($redirect); - - if (!$success_msg) - { - redirect($redirect); - } - else - { - meta_refresh(3, $redirect); - - $message = $user->lang[$success_msg]; - $message .= '

' . sprintf($user->lang['RETURN_PAGE'], '', ''); - $message .= '

' . sprintf($user->lang['RETURN_FORUM'], '', ''); - $message .= '

' . sprintf($user->lang['RETURN_NEW_FORUM'], '', ''); - - trigger_error($message); - } -} - -/** -* Restore Topics -*/ -function mcp_restore_topic($topic_ids) -{ - global $user, $phpEx, $phpbb_root_path, $request, $phpbb_container, $phpbb_log; - - if (!phpbb_check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array('m_approve'))) - { - return; - } - - $redirect = $request->variable('redirect', build_url(array('action', 'quickmod'))); - $forum_id = $request->variable('f', 0); - - $s_hidden_fields = build_hidden_fields(array( - 'topic_id_list' => $topic_ids, - 'f' => $forum_id, - 'action' => 'restore_topic', - 'redirect' => $redirect, - )); - $success_msg = ''; - - if (confirm_box(true)) - { - $success_msg = (count($topic_ids) == 1) ? 'TOPIC_RESTORED_SUCCESS' : 'TOPICS_RESTORED_SUCCESS'; - - $data = phpbb_get_topic_data($topic_ids); - - /* @var $phpbb_content_visibility \phpbb\content_visibility */ - $phpbb_content_visibility = $phpbb_container->get('content.visibility'); - foreach ($data as $topic_id => $row) - { - $return = $phpbb_content_visibility->set_topic_visibility(ITEM_APPROVED, $topic_id, $row['forum_id'], $user->data['user_id'], time(), ''); - if (!empty($return)) - { - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_RESTORE_TOPIC', false, array( - 'forum_id' => $row['forum_id'], - 'topic_id' => $topic_id, - $row['topic_title'], - $row['topic_first_poster_name'] - )); - } - } - } - else - { - confirm_box(false, (count($topic_ids) == 1) ? 'RESTORE_TOPIC' : 'RESTORE_TOPICS', $s_hidden_fields); - } - - $topic_id = $request->variable('t', 0); - if (!$request->is_set('quickmod', \phpbb\request\request_interface::REQUEST)) - { - $redirect = $request->variable('redirect', "index.$phpEx"); - $redirect = reapply_sid($redirect); - $redirect_message = 'PAGE'; - } - else if ($topic_id) - { - $redirect = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=' . $topic_id); - $redirect_message = 'TOPIC'; - } - else - { - $redirect = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id); - $redirect_message = 'FORUM'; - } - - if (!$success_msg) - { - redirect($redirect); - } - else - { - meta_refresh(3, $redirect); - trigger_error($user->lang[$success_msg] . '

' . sprintf($user->lang['RETURN_' . $redirect_message], '', '')); - } -} - -/** -* Delete Topics -*/ -function mcp_delete_topic($topic_ids, $is_soft = false, $soft_delete_reason = '', $action = 'delete_topic') -{ - global $auth, $user, $db, $phpEx, $phpbb_root_path, $request, $phpbb_container, $phpbb_log; - - $check_permission = ($is_soft) ? 'm_softdelete' : 'm_delete'; - if (!phpbb_check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array($check_permission))) - { - return; - } - - $redirect = $request->variable('redirect', build_url(array('action', 'quickmod'))); - $forum_id = $request->variable('f', 0); - - $s_hidden_fields = array( - 'topic_id_list' => $topic_ids, - 'f' => $forum_id, - 'action' => $action, - 'redirect' => $redirect, - ); - $success_msg = ''; - - if (confirm_box(true)) - { - $success_msg = (count($topic_ids) == 1) ? 'TOPIC_DELETED_SUCCESS' : 'TOPICS_DELETED_SUCCESS'; - - $data = phpbb_get_topic_data($topic_ids); - - foreach ($data as $topic_id => $row) - { - if ($row['topic_moved_id']) - { - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_DELETE_SHADOW_TOPIC', false, array( - 'forum_id' => $row['forum_id'], - 'topic_id' => $topic_id, - $row['topic_title'] - )); - } - else - { - // Only soft delete non-shadow topics - if ($is_soft) - { - /* @var $phpbb_content_visibility \phpbb\content_visibility */ - $phpbb_content_visibility = $phpbb_container->get('content.visibility'); - $return = $phpbb_content_visibility->set_topic_visibility(ITEM_DELETED, $topic_id, $row['forum_id'], $user->data['user_id'], time(), $soft_delete_reason); - if (!empty($return)) - { - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_SOFTDELETE_TOPIC', false, array( - 'forum_id' => $row['forum_id'], - 'topic_id' => $topic_id, - $row['topic_title'], - $row['topic_first_poster_name'], - $soft_delete_reason - )); - } - } - else - { - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_DELETE_TOPIC', false, array( - 'forum_id' => $row['forum_id'], - 'topic_id' => $topic_id, - $row['topic_title'], - $row['topic_first_poster_name'], - $soft_delete_reason - )); - } - } - } - - if (!$is_soft) - { - delete_topics('topic_id', $topic_ids); - } - } - else - { - global $template; - - $user->add_lang('posting'); - - // If there are only shadow topics, we neither need a reason nor softdelete - $sql = 'SELECT topic_id - FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', $topic_ids) . ' - AND topic_moved_id = 0'; - $result = $db->sql_query_limit($sql, 1); - $only_shadow = !$db->sql_fetchfield('topic_id'); - $db->sql_freeresult($result); - - $only_softdeleted = false; - if (!$only_shadow && $auth->acl_get('m_delete', $forum_id) && $auth->acl_get('m_softdelete', $forum_id)) - { - // If there are only soft deleted topics, we display a message why the option is not available - $sql = 'SELECT topic_id - FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', $topic_ids) . ' - AND topic_visibility <> ' . ITEM_DELETED; - $result = $db->sql_query_limit($sql, 1); - $only_softdeleted = !$db->sql_fetchfield('topic_id'); - $db->sql_freeresult($result); - } - - $template->assign_vars(array( - 'S_SHADOW_TOPICS' => $only_shadow, - 'S_SOFTDELETED' => $only_softdeleted, - 'S_TOPIC_MODE' => true, - 'S_ALLOWED_DELETE' => $auth->acl_get('m_delete', $forum_id), - 'S_ALLOWED_SOFTDELETE' => $auth->acl_get('m_softdelete', $forum_id), - 'DELETE_TOPIC_PERMANENTLY_EXPLAIN' => $user->lang('DELETE_TOPIC_PERMANENTLY', count($topic_ids)), - )); - - $count = count($topic_ids); - $l_confirm = $count === 1 ? 'DELETE_TOPIC' : 'DELETE_TOPICS'; - if ($only_softdeleted) - { - $l_confirm = array($l_confirm . '_PERMANENTLY', $count); - $s_hidden_fields['delete_permanent'] = '1'; - } - else if ($only_shadow || !$auth->acl_get('m_softdelete', $forum_id)) - { - $s_hidden_fields['delete_permanent'] = '1'; - } - - confirm_box(false, $l_confirm, build_hidden_fields($s_hidden_fields), 'confirm_delete_body.html'); - } - - $topic_id = $request->variable('t', 0); - if (!$request->is_set('quickmod', \phpbb\request\request_interface::REQUEST)) - { - $redirect = $request->variable('redirect', "index.$phpEx"); - $redirect = reapply_sid($redirect); - $redirect_message = 'PAGE'; - } - else if ($is_soft && $topic_id) - { - $redirect = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=' . $topic_id); - $redirect_message = 'TOPIC'; - } - else - { - $redirect = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id); - $redirect_message = 'FORUM'; - } - - if (!$success_msg) - { - redirect($redirect); - } - else - { - meta_refresh(3, $redirect); - trigger_error($user->lang[$success_msg] . '

' . sprintf($user->lang['RETURN_' . $redirect_message], '', '')); - } -} - -/** -* Delete Posts -*/ -function mcp_delete_post($post_ids, $is_soft = false, $soft_delete_reason = '', $action = 'delete_post') -{ - global $auth, $user, $db, $phpEx, $phpbb_root_path, $request, $phpbb_container, $phpbb_log; - - $check_permission = ($is_soft) ? 'm_softdelete' : 'm_delete'; - if (!phpbb_check_ids($post_ids, POSTS_TABLE, 'post_id', array($check_permission))) - { - return; - } - - $redirect = $request->variable('redirect', build_url(array('action', 'quickmod'))); - $forum_id = $request->variable('f', 0); - - $s_hidden_fields = array( - 'post_id_list' => $post_ids, - 'f' => $forum_id, - 'action' => $action, - 'redirect' => $redirect, - ); - $success_msg = ''; - - if (confirm_box(true) && $is_soft) - { - $post_info = phpbb_get_post_data($post_ids); - - $topic_info = $approve_log = array(); - - // Group the posts by topic_id - foreach ($post_info as $post_id => $post_data) - { - if ($post_data['post_visibility'] != ITEM_APPROVED) - { - continue; - } - $topic_id = (int) $post_data['topic_id']; - - $topic_info[$topic_id]['posts'][] = (int) $post_id; - $topic_info[$topic_id]['forum_id'] = (int) $post_data['forum_id']; - - if ($post_id == $post_data['topic_first_post_id']) - { - $topic_info[$topic_id]['first_post'] = true; - } - - if ($post_id == $post_data['topic_last_post_id']) - { - $topic_info[$topic_id]['last_post'] = true; - } - - $approve_log[] = array( - 'forum_id' => $post_data['forum_id'], - 'topic_id' => $post_data['topic_id'], - 'post_id' => $post_id, - 'post_subject' => $post_data['post_subject'], - 'poster_id' => $post_data['poster_id'], - 'post_username' => $post_data['post_username'], - 'username' => $post_data['username'], - ); - } - - /* @var $phpbb_content_visibility \phpbb\content_visibility */ - $phpbb_content_visibility = $phpbb_container->get('content.visibility'); - foreach ($topic_info as $topic_id => $topic_data) - { - $phpbb_content_visibility->set_post_visibility(ITEM_DELETED, $topic_data['posts'], $topic_id, $topic_data['forum_id'], $user->data['user_id'], time(), $soft_delete_reason, isset($topic_data['first_post']), isset($topic_data['last_post'])); - } - $affected_topics = count($topic_info); - // None of the topics is really deleted, so a redirect won't hurt much. - $deleted_topics = 0; - - $success_msg = (count($post_info) == 1) ? $user->lang['POST_DELETED_SUCCESS'] : $user->lang['POSTS_DELETED_SUCCESS']; - - foreach ($approve_log as $row) - { - $post_username = ($row['poster_id'] == ANONYMOUS && !empty($row['post_username'])) ? $row['post_username'] : $row['username']; - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_SOFTDELETE_POST', false, array( - 'forum_id' => $row['forum_id'], - 'topic_id' => $row['topic_id'], - 'post_id' => $row['post_id'], - $row['post_subject'], - $post_username, - $soft_delete_reason - )); - } - - $topic_id = $request->variable('t', 0); - - // Return links - $return_link = array(); - if ($affected_topics == 1 && $topic_id) - { - $return_link[] = sprintf($user->lang['RETURN_TOPIC'], '', ''); - } - $return_link[] = sprintf($user->lang['RETURN_FORUM'], '', ''); - - } - else if (confirm_box(true)) - { - if (!function_exists('delete_posts')) - { - include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); - } - - // Count the number of topics that are affected - // I did not use COUNT(DISTINCT ...) because I remember having problems - // with it on older versions of MySQL -- Ashe - - $sql = 'SELECT DISTINCT topic_id - FROM ' . POSTS_TABLE . ' - WHERE ' . $db->sql_in_set('post_id', $post_ids); - $result = $db->sql_query($sql); - - $topic_id_list = array(); - while ($row = $db->sql_fetchrow($result)) - { - $topic_id_list[] = $row['topic_id']; - } - $affected_topics = count($topic_id_list); - $db->sql_freeresult($result); - - $post_data = phpbb_get_post_data($post_ids); - - foreach ($post_data as $id => $row) - { - $post_username = ($row['poster_id'] == ANONYMOUS && !empty($row['post_username'])) ? $row['post_username'] : $row['username']; - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_DELETE_POST', false, array( - 'forum_id' => $row['forum_id'], - 'topic_id' => $row['topic_id'], - 'post_id' => $row['post_id'], - $row['post_subject'], - $post_username, - $soft_delete_reason - )); - } - - // Now delete the posts, topics and forums are automatically resync'ed - delete_posts('post_id', $post_ids); - - $sql = 'SELECT COUNT(topic_id) AS topics_left - FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', $topic_id_list); - $result = $db->sql_query_limit($sql, 1); - - $deleted_topics = ($row = $db->sql_fetchrow($result)) ? ($affected_topics - $row['topics_left']) : $affected_topics; - $db->sql_freeresult($result); - - $topic_id = $request->variable('t', 0); - - // Return links - $return_link = array(); - if ($affected_topics == 1 && !$deleted_topics && $topic_id) - { - $return_link[] = sprintf($user->lang['RETURN_TOPIC'], '', ''); - } - $return_link[] = sprintf($user->lang['RETURN_FORUM'], '', ''); - - if (count($post_ids) == 1) - { - if ($deleted_topics) - { - // We deleted the only post of a topic, which in turn has - // been removed from the database - $success_msg = $user->lang['TOPIC_DELETED_SUCCESS']; - } - else - { - $success_msg = $user->lang['POST_DELETED_SUCCESS']; - } - } - else - { - if ($deleted_topics) - { - // Some of topics disappeared - $success_msg = $user->lang['POSTS_DELETED_SUCCESS'] . '

' . $user->lang['EMPTY_TOPICS_REMOVED_WARNING']; - } - else - { - $success_msg = $user->lang['POSTS_DELETED_SUCCESS']; - } - } - } - else - { - global $template; - - $user->add_lang('posting'); - - $only_softdeleted = false; - if ($auth->acl_get('m_delete', $forum_id) && $auth->acl_get('m_softdelete', $forum_id)) - { - // If there are only soft deleted posts, we display a message why the option is not available - $sql = 'SELECT post_id - FROM ' . POSTS_TABLE . ' - WHERE ' . $db->sql_in_set('post_id', $post_ids) . ' - AND post_visibility <> ' . ITEM_DELETED; - $result = $db->sql_query_limit($sql, 1); - $only_softdeleted = !$db->sql_fetchfield('post_id'); - $db->sql_freeresult($result); - } - - $template->assign_vars(array( - 'S_SOFTDELETED' => $only_softdeleted, - 'S_ALLOWED_DELETE' => $auth->acl_get('m_delete', $forum_id), - 'S_ALLOWED_SOFTDELETE' => $auth->acl_get('m_softdelete', $forum_id), - 'DELETE_POST_PERMANENTLY_EXPLAIN' => $user->lang('DELETE_POST_PERMANENTLY', count($post_ids)), - )); - - $count = count($post_ids); - $l_confirm = $count === 1 ? 'DELETE_POST' : 'DELETE_POSTS'; - if ($only_softdeleted) - { - $l_confirm = array($l_confirm . '_PERMANENTLY', $count); - $s_hidden_fields['delete_permanent'] = '1'; - } - else if (!$auth->acl_get('m_softdelete', $forum_id)) - { - $s_hidden_fields['delete_permanent'] = '1'; - } - - confirm_box(false, $l_confirm, build_hidden_fields($s_hidden_fields), 'confirm_delete_body.html'); - } - - $redirect = $request->variable('redirect', "index.$phpEx"); - $redirect = reapply_sid($redirect); - - if (!$success_msg) - { - redirect($redirect); - } - else - { - if ($affected_topics != 1 || $deleted_topics || !$topic_id) - { - $redirect = append_sid("{$phpbb_root_path}mcp.$phpEx", "f=$forum_id&i=main&mode=forum_view", false); - } - - meta_refresh(3, $redirect); - trigger_error($success_msg . '

' . sprintf($user->lang['RETURN_PAGE'], '', '') . '

' . implode('

', $return_link)); - } -} - -/** -* Fork Topic -*/ -function mcp_fork_topic($topic_ids) -{ - global $auth, $user, $db, $template, $config; - global $phpEx, $phpbb_root_path, $phpbb_log, $request, $phpbb_dispatcher; - - if (!phpbb_check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array('m_'))) - { - return; - } - - $to_forum_id = $request->variable('to_forum_id', 0); - $forum_id = $request->variable('f', 0); - $redirect = $request->variable('redirect', build_url(array('action', 'quickmod'))); - $additional_msg = $success_msg = ''; - $counter = array(); - - $s_hidden_fields = build_hidden_fields(array( - 'topic_id_list' => $topic_ids, - 'f' => $forum_id, - 'action' => 'fork', - 'redirect' => $redirect) - ); - - if ($to_forum_id) - { - $forum_data = phpbb_get_forum_data($to_forum_id, 'f_post'); - - if (!count($topic_ids)) - { - $additional_msg = $user->lang['NO_TOPIC_SELECTED']; - } - else if (!count($forum_data)) - { - $additional_msg = $user->lang['FORUM_NOT_EXIST']; - } - else - { - $forum_data = $forum_data[$to_forum_id]; - - if ($forum_data['forum_type'] != FORUM_POST) - { - $additional_msg = $user->lang['FORUM_NOT_POSTABLE']; - } - else if (!$auth->acl_get('f_post', $to_forum_id)) - { - $additional_msg = $user->lang['USER_CANNOT_POST']; - } - } - } - else if (isset($_POST['confirm'])) - { - $additional_msg = $user->lang['FORUM_NOT_EXIST']; - } - - if ($additional_msg) - { - $request->overwrite('confirm', null, \phpbb\request\request_interface::POST); - $request->overwrite('confirm_key', null); - } - - if (confirm_box(true)) - { - $topic_data = phpbb_get_topic_data($topic_ids, 'f_post'); - - $total_topics = $total_topics_unapproved = $total_topics_softdeleted = 0; - $total_posts = $total_posts_unapproved = $total_posts_softdeleted = 0; - $new_topic_id_list = array(); - - foreach ($topic_data as $topic_id => $topic_row) - { - if (!isset($search_type) && $topic_row['enable_indexing']) - { - // Select the search method and do some additional checks to ensure it can actually be utilised - $search_type = $config['search_type']; - - if (!class_exists($search_type)) - { - trigger_error('NO_SUCH_SEARCH_MODULE'); - } - - $error = false; - $search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher); - $search_mode = 'post'; - - if ($error) - { - trigger_error($error); - } - } - else if (!isset($search_type) && !$topic_row['enable_indexing']) - { - $search_type = false; - } - - $sql_ary = array( - 'forum_id' => (int) $to_forum_id, - 'icon_id' => (int) $topic_row['icon_id'], - 'topic_attachment' => (int) $topic_row['topic_attachment'], - 'topic_visibility' => (int) $topic_row['topic_visibility'], - 'topic_reported' => 0, - 'topic_title' => (string) $topic_row['topic_title'], - 'topic_poster' => (int) $topic_row['topic_poster'], - 'topic_time' => (int) $topic_row['topic_time'], - 'topic_posts_approved' => (int) $topic_row['topic_posts_approved'], - 'topic_posts_unapproved' => (int) $topic_row['topic_posts_unapproved'], - 'topic_posts_softdeleted' => (int) $topic_row['topic_posts_softdeleted'], - 'topic_status' => (int) $topic_row['topic_status'], - 'topic_type' => (int) $topic_row['topic_type'], - 'topic_first_poster_name' => (string) $topic_row['topic_first_poster_name'], - 'topic_last_poster_id' => (int) $topic_row['topic_last_poster_id'], - 'topic_last_poster_name' => (string) $topic_row['topic_last_poster_name'], - 'topic_last_post_time' => (int) $topic_row['topic_last_post_time'], - 'topic_last_view_time' => (int) $topic_row['topic_last_view_time'], - 'topic_bumped' => (int) $topic_row['topic_bumped'], - 'topic_bumper' => (int) $topic_row['topic_bumper'], - 'poll_title' => (string) $topic_row['poll_title'], - 'poll_start' => (int) $topic_row['poll_start'], - 'poll_length' => (int) $topic_row['poll_length'], - 'poll_max_options' => (int) $topic_row['poll_max_options'], - 'poll_vote_change' => (int) $topic_row['poll_vote_change'], - ); - - /** - * Perform actions before forked topic is created. - * - * @event core.mcp_main_modify_fork_sql - * @var array sql_ary SQL array to be used by $db->sql_build_array - * @var array topic_row Topic data - * @since 3.1.11-RC1 - * @changed 3.1.11-RC1 Added variable: topic_row - */ - $vars = array( - 'sql_ary', - 'topic_row', - ); - extract($phpbb_dispatcher->trigger_event('core.mcp_main_modify_fork_sql', compact($vars))); - - $db->sql_query('INSERT INTO ' . TOPICS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); - $new_topic_id = $db->sql_nextid(); - $new_topic_id_list[$topic_id] = $new_topic_id; - - switch ($topic_row['topic_visibility']) - { - case ITEM_APPROVED: - $total_topics++; - break; - case ITEM_UNAPPROVED: - case ITEM_REAPPROVE: - $total_topics_unapproved++; - break; - case ITEM_DELETED: - $total_topics_softdeleted++; - break; - } - - if ($topic_row['poll_start']) - { - $sql = 'SELECT * - FROM ' . POLL_OPTIONS_TABLE . " - WHERE topic_id = $topic_id"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $sql_ary = array( - 'poll_option_id' => (int) $row['poll_option_id'], - 'topic_id' => (int) $new_topic_id, - 'poll_option_text' => (string) $row['poll_option_text'], - 'poll_option_total' => 0 - ); - - $db->sql_query('INSERT INTO ' . POLL_OPTIONS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); - } - $db->sql_freeresult($result); - } - - $sql = 'SELECT * - FROM ' . POSTS_TABLE . " - WHERE topic_id = $topic_id - ORDER BY post_time ASC, post_id ASC"; - $result = $db->sql_query($sql); - - $post_rows = array(); - while ($row = $db->sql_fetchrow($result)) - { - $post_rows[] = $row; - } - $db->sql_freeresult($result); - - if (!count($post_rows)) - { - continue; - } - - foreach ($post_rows as $row) - { - $sql_ary = array( - 'topic_id' => (int) $new_topic_id, - 'forum_id' => (int) $to_forum_id, - 'poster_id' => (int) $row['poster_id'], - 'icon_id' => (int) $row['icon_id'], - 'poster_ip' => (string) $row['poster_ip'], - 'post_time' => (int) $row['post_time'], - 'post_visibility' => (int) $row['post_visibility'], - 'post_reported' => 0, - 'enable_bbcode' => (int) $row['enable_bbcode'], - 'enable_smilies' => (int) $row['enable_smilies'], - 'enable_magic_url' => (int) $row['enable_magic_url'], - 'enable_sig' => (int) $row['enable_sig'], - 'post_username' => (string) $row['post_username'], - 'post_subject' => (string) $row['post_subject'], - 'post_text' => (string) $row['post_text'], - 'post_edit_reason' => (string) $row['post_edit_reason'], - 'post_edit_user' => (int) $row['post_edit_user'], - 'post_checksum' => (string) $row['post_checksum'], - 'post_attachment' => (int) $row['post_attachment'], - 'bbcode_bitfield' => $row['bbcode_bitfield'], - 'bbcode_uid' => (string) $row['bbcode_uid'], - 'post_edit_time' => (int) $row['post_edit_time'], - 'post_edit_count' => (int) $row['post_edit_count'], - 'post_edit_locked' => (int) $row['post_edit_locked'], - 'post_postcount' => $row['post_postcount'], - ); - // Adjust post count only if the post can be incremented to the user counter - if ($row['post_postcount']) - { - if (isset($counter[$row['poster_id']])) - { - ++$counter[$row['poster_id']]; - } - else - { - $counter[$row['poster_id']] = 1; - } - } - $db->sql_query('INSERT INTO ' . POSTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); - $new_post_id = $db->sql_nextid(); - - /** - * Perform actions after forked topic is created. - * - * @event core.mcp_main_fork_sql_after - * @var int new_topic_id The newly created topic ID - * @var int to_forum_id The forum ID where the forked topic has been moved to - * @var int new_post_id The newly created post ID - * @var array row Post data - * @since 3.2.4-RC1 - */ - $vars = array( - 'new_topic_id', - 'to_forum_id', - 'new_post_id', - 'row', - ); - extract($phpbb_dispatcher->trigger_event('core.mcp_main_fork_sql_after', compact($vars))); - - switch ($row['post_visibility']) - { - case ITEM_APPROVED: - $total_posts++; - break; - case ITEM_UNAPPROVED: - case ITEM_REAPPROVE: - $total_posts_unapproved++; - break; - case ITEM_DELETED: - $total_posts_softdeleted++; - break; - } - - // Copy whether the topic is dotted - markread('post', $to_forum_id, $new_topic_id, 0, $row['poster_id']); - - if (!empty($search_type)) - { - $search->index($search_mode, $new_post_id, $sql_ary['post_text'], $sql_ary['post_subject'], $sql_ary['poster_id'], ($topic_row['topic_type'] == POST_GLOBAL) ? 0 : $to_forum_id); - $search_mode = 'reply'; // After one we index replies - } - - // Copy Attachments - if ($row['post_attachment']) - { - $sql = 'SELECT * FROM ' . ATTACHMENTS_TABLE . " - WHERE post_msg_id = {$row['post_id']} - AND topic_id = $topic_id - AND in_message = 0"; - $result = $db->sql_query($sql); - - $sql_ary = array(); - while ($attach_row = $db->sql_fetchrow($result)) - { - $sql_ary[] = array( - 'post_msg_id' => (int) $new_post_id, - 'topic_id' => (int) $new_topic_id, - 'in_message' => 0, - 'is_orphan' => (int) $attach_row['is_orphan'], - 'poster_id' => (int) $attach_row['poster_id'], - 'physical_filename' => (string) utf8_basename($attach_row['physical_filename']), - 'real_filename' => (string) utf8_basename($attach_row['real_filename']), - 'download_count' => (int) $attach_row['download_count'], - 'attach_comment' => (string) $attach_row['attach_comment'], - 'extension' => (string) $attach_row['extension'], - 'mimetype' => (string) $attach_row['mimetype'], - 'filesize' => (int) $attach_row['filesize'], - 'filetime' => (int) $attach_row['filetime'], - 'thumbnail' => (int) $attach_row['thumbnail'] - ); - } - $db->sql_freeresult($result); - - if (count($sql_ary)) - { - $db->sql_multi_insert(ATTACHMENTS_TABLE, $sql_ary); - } - } - } - - // Copy topic subscriptions to new topic - $sql = 'SELECT user_id, notify_status - FROM ' . TOPICS_WATCH_TABLE . ' - WHERE topic_id = ' . $topic_id; - $result = $db->sql_query($sql); - - $sql_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - $sql_ary[] = array( - 'topic_id' => (int) $new_topic_id, - 'user_id' => (int) $row['user_id'], - 'notify_status' => (int) $row['notify_status'], - ); - } - $db->sql_freeresult($result); - - if (count($sql_ary)) - { - $db->sql_multi_insert(TOPICS_WATCH_TABLE, $sql_ary); - } - - // Copy bookmarks to new topic - $sql = 'SELECT user_id - FROM ' . BOOKMARKS_TABLE . ' - WHERE topic_id = ' . $topic_id; - $result = $db->sql_query($sql); - - $sql_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - $sql_ary[] = array( - 'topic_id' => (int) $new_topic_id, - 'user_id' => (int) $row['user_id'], - ); - } - $db->sql_freeresult($result); - - if (count($sql_ary)) - { - $db->sql_multi_insert(BOOKMARKS_TABLE, $sql_ary); - } - } - - // Sync new topics, parent forums and board stats - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET forum_posts_approved = forum_posts_approved + ' . $total_posts . ', - forum_posts_unapproved = forum_posts_unapproved + ' . $total_posts_unapproved . ', - forum_posts_softdeleted = forum_posts_softdeleted + ' . $total_posts_softdeleted . ', - forum_topics_approved = forum_topics_approved + ' . $total_topics . ', - forum_topics_unapproved = forum_topics_unapproved + ' . $total_topics_unapproved . ', - forum_topics_softdeleted = forum_topics_softdeleted + ' . $total_topics_softdeleted . ' - WHERE forum_id = ' . $to_forum_id; - $db->sql_query($sql); - - if (!empty($counter)) - { - // Do only one query per user and not a query per post. - foreach ($counter as $user_id => $count) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_posts = user_posts + ' . (int) $count . ' - WHERE user_id = ' . (int) $user_id; - $db->sql_query($sql); - } - } - - sync('topic', 'topic_id', $new_topic_id_list); - sync('forum', 'forum_id', $to_forum_id); - - $config->increment('num_topics', count($new_topic_id_list), false); - $config->increment('num_posts', $total_posts, false); - - foreach ($new_topic_id_list as $topic_id => $new_topic_id) - { - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_FORK', false, array( - 'forum_id' => $to_forum_id, - 'topic_id' => $new_topic_id, - $topic_row['forum_name'] - )); - } - - $success_msg = (count($topic_ids) == 1) ? 'TOPIC_FORKED_SUCCESS' : 'TOPICS_FORKED_SUCCESS'; - } - else - { - $template->assign_vars(array( - 'S_FORUM_SELECT' => make_forum_select($to_forum_id, false, false, true, true, true), - 'S_CAN_LEAVE_SHADOW' => false, - 'ADDITIONAL_MSG' => $additional_msg) - ); - - confirm_box(false, 'FORK_TOPIC' . ((count($topic_ids) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_move.html'); - } - - $redirect = $request->variable('redirect', "index.$phpEx"); - $redirect = reapply_sid($redirect); - - if (!$success_msg) - { - redirect($redirect); - } - else - { - $redirect_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id); - meta_refresh(3, $redirect_url); - $return_link = sprintf($user->lang['RETURN_FORUM'], '', ''); - - if ($forum_id != $to_forum_id) - { - $return_link .= '

' . sprintf($user->lang['RETURN_NEW_FORUM'], '', ''); - } - - trigger_error($user->lang[$success_msg] . '

' . $return_link); - } -} diff --git a/install/update/new/includes/mcp/mcp_notes.php b/install/update/new/includes/mcp/mcp_notes.php deleted file mode 100644 index 74bd1f1..0000000 --- a/install/update/new/includes/mcp/mcp_notes.php +++ /dev/null @@ -1,258 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* mcp_notes -* Displays notes about a user -*/ -class mcp_notes -{ - var $p_master; - var $u_action; - - function __construct($p_master) - { - $this->p_master = $p_master; - } - - function main($id, $mode) - { - global $user, $template, $request; - global $phpbb_root_path, $phpEx; - - $action = $request->variable('action', array('' => '')); - - if (is_array($action)) - { - $action = key($action); - } - - $this->page_title = 'MCP_NOTES'; - - switch ($mode) - { - case 'front': - $template->assign_vars(array( - 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=mcp&field=username&select_single=true'), - 'U_POST_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes'), - - 'L_TITLE' => $user->lang['MCP_NOTES'], - )); - - $this->tpl_name = 'mcp_notes_front'; - break; - - case 'user_notes': - $user->add_lang('acp/common'); - - $this->mcp_notes_user_view($action); - $this->tpl_name = 'mcp_notes_user'; - break; - } - } - - /** - * Display user notes - */ - function mcp_notes_user_view($action) - { - global $config, $phpbb_log, $request; - global $template, $db, $user, $auth, $phpbb_container; - - $user_id = $request->variable('u', 0); - $username = $request->variable('username', '', true); - $start = $request->variable('start', 0); - $st = $request->variable('st', 0); - $sk = $request->variable('sk', 'b'); - $sd = $request->variable('sd', 'd'); - - /* @var $pagination \phpbb\pagination */ - $pagination = $phpbb_container->get('pagination'); - - add_form_key('mcp_notes'); - - $sql_where = ($user_id) ? "user_id = $user_id" : "username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'"; - - $sql = 'SELECT * - FROM ' . USERS_TABLE . " - WHERE $sql_where"; - $result = $db->sql_query($sql); - $userrow = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$userrow) - { - trigger_error('NO_USER'); - } - - $user_id = $userrow['user_id']; - - // Populate user id to the currently active module (this module) - // The following method is another way of adjusting module urls. It is the easy variant if we want - // to directly adjust the current module url based on data retrieved within the same module. - if (strpos($this->u_action, "&u=$user_id") === false) - { - $this->p_master->adjust_url('&u=' . $user_id); - $this->u_action .= "&u=$user_id"; - } - - $deletemark = ($action == 'del_marked') ? true : false; - $deleteall = ($action == 'del_all') ? true : false; - $marked = $request->variable('marknote', array(0)); - $usernote = $request->variable('usernote', '', true); - - // Handle any actions - if (($deletemark || $deleteall) && $auth->acl_get('a_clearlogs')) - { - $where_sql = ''; - if ($deletemark && $marked) - { - $sql_in = array(); - foreach ($marked as $mark) - { - $sql_in[] = $mark; - } - $where_sql = ' AND ' . $db->sql_in_set('log_id', $sql_in); - unset($sql_in); - } - - if ($where_sql || $deleteall) - { - if (check_form_key('mcp_notes')) - { - $sql = 'DELETE FROM ' . LOG_TABLE . ' - WHERE log_type = ' . LOG_USERS . " - AND reportee_id = $user_id - $where_sql"; - $db->sql_query($sql); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_CLEAR_USER', false, array($userrow['username'])); - - $msg = ($deletemark) ? 'MARKED_NOTES_DELETED' : 'ALL_NOTES_DELETED'; - } - else - { - $msg = 'FORM_INVALID'; - } - $redirect = $this->u_action . '&u=' . $user_id; - meta_refresh(3, $redirect); - trigger_error($user->lang[$msg] . '

' . sprintf($user->lang['RETURN_PAGE'], '', '')); - } - } - - if ($usernote && $action == 'add_feedback') - { - if (check_form_key('mcp_notes')) - { - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_FEEDBACK', false, array($userrow['username'])); - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_USER_FEEDBACK', false, array( - 'forum_id' => 0, - 'topic_id' => 0, - $userrow['username'] - )); - $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_GENERAL', false, array( - 'reportee_id' => $user_id, - $usernote - )); - - $msg = $user->lang['USER_FEEDBACK_ADDED']; - } - else - { - $msg = $user->lang['FORM_INVALID']; - } - $redirect = $this->u_action; - meta_refresh(3, $redirect); - - trigger_error($msg . '

' . sprintf($user->lang['RETURN_PAGE'], '', '')); - } - - // Generate the appropriate user information for the user we are looking at - - $rank_title = $rank_img = ''; - $avatar_img = phpbb_get_user_avatar($userrow); - - $limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); - $sort_by_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_DATE'], 'c' => $user->lang['SORT_IP'], 'd' => $user->lang['SORT_ACTION']); - $sort_by_sql = array('a' => 'u.username_clean', 'b' => 'l.log_time', 'c' => 'l.log_ip', 'd' => 'l.log_operation'); - - $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; - gen_sort_selects($limit_days, $sort_by_text, $st, $sk, $sd, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); - - // Define where and sort sql for use in displaying logs - $sql_where = ($st) ? (time() - ($st * 86400)) : 0; - $sql_sort = $sort_by_sql[$sk] . ' ' . (($sd == 'd') ? 'DESC' : 'ASC'); - - $keywords = $request->variable('keywords', '', true); - $keywords_param = !empty($keywords) ? '&keywords=' . urlencode(htmlspecialchars_decode($keywords)) : ''; - - $log_data = array(); - $log_count = 0; - $start = view_log('user', $log_data, $log_count, $config['topics_per_page'], $start, 0, 0, $user_id, $sql_where, $sql_sort, $keywords); - - if ($log_count) - { - $template->assign_var('S_USER_NOTES', true); - - foreach ($log_data as $row) - { - $template->assign_block_vars('usernotes', array( - 'REPORT_BY' => $row['username_full'], - 'REPORT_AT' => $user->format_date($row['time']), - 'ACTION' => $row['action'], - 'IP' => $row['ip'], - 'ID' => $row['id']) - ); - } - } - - $base_url = $this->u_action . "&$u_sort_param$keywords_param"; - $pagination->generate_template_pagination($base_url, 'pagination', 'start', $log_count, $config['topics_per_page'], $start); - - $template->assign_vars(array( - 'U_POST_ACTION' => $this->u_action, - 'S_CLEAR_ALLOWED' => ($auth->acl_get('a_clearlogs')) ? true : false, - 'S_SELECT_SORT_DIR' => $s_sort_dir, - 'S_SELECT_SORT_KEY' => $s_sort_key, - 'S_SELECT_SORT_DAYS' => $s_limit_days, - 'S_KEYWORDS' => $keywords, - - 'L_TITLE' => $user->lang['MCP_NOTES_USER'], - - 'TOTAL_REPORTS' => $user->lang('LIST_REPORTS', (int) $log_count), - - 'RANK_TITLE' => $rank_title, - 'JOINED' => $user->format_date($userrow['user_regdate']), - 'POSTS' => ($userrow['user_posts']) ? $userrow['user_posts'] : 0, - 'WARNINGS' => ($userrow['user_warnings']) ? $userrow['user_warnings'] : 0, - - 'USERNAME_FULL' => get_username_string('full', $userrow['user_id'], $userrow['username'], $userrow['user_colour']), - 'USERNAME_COLOUR' => get_username_string('colour', $userrow['user_id'], $userrow['username'], $userrow['user_colour']), - 'USERNAME' => get_username_string('username', $userrow['user_id'], $userrow['username'], $userrow['user_colour']), - 'U_PROFILE' => get_username_string('profile', $userrow['user_id'], $userrow['username'], $userrow['user_colour']), - - 'AVATAR_IMG' => $avatar_img, - 'RANK_IMG' => $rank_img, - ) - ); - } - -} diff --git a/install/update/new/includes/mcp/mcp_topic.php b/install/update/new/includes/mcp/mcp_topic.php deleted file mode 100644 index 77db5f3..0000000 --- a/install/update/new/includes/mcp/mcp_topic.php +++ /dev/null @@ -1,834 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* View topic in MCP -*/ -function mcp_topic_view($id, $mode, $action) -{ - global $phpEx, $phpbb_root_path, $config, $request; - global $template, $db, $user, $auth, $phpbb_container, $phpbb_dispatcher; - - $url = append_sid("{$phpbb_root_path}mcp.$phpEx?" . phpbb_extra_url()); - - /* @var $pagination \phpbb\pagination */ - $pagination = $phpbb_container->get('pagination'); - $user->add_lang('viewtopic'); - - $topic_id = $request->variable('t', 0); - $topic_info = phpbb_get_topic_data(array($topic_id), false, true); - - if (!count($topic_info)) - { - trigger_error('TOPIC_NOT_EXIST'); - } - - $topic_info = $topic_info[$topic_id]; - - // Set up some vars - $icon_id = $request->variable('icon', 0); - $subject = $request->variable('subject', '', true); - $start = $request->variable('start', 0); - $sort_days_old = $request->variable('st_old', 0); - $forum_id = $request->variable('f', 0); - $to_topic_id = $request->variable('to_topic_id', 0); - $to_forum_id = $request->variable('to_forum_id', 0); - $sort = isset($_POST['sort']) ? true : false; - $submitted_id_list = $request->variable('post_ids', array(0)); - $checked_ids = $post_id_list = $request->variable('post_id_list', array(0)); - - // Resync Topic? - if ($action == 'resync') - { - if (!function_exists('mcp_resync_topics')) - { - include($phpbb_root_path . 'includes/mcp/mcp_forum.' . $phpEx); - } - mcp_resync_topics(array($topic_id)); - } - - // Split Topic? - if ($action == 'split_all' || $action == 'split_beyond') - { - if (!$sort) - { - split_topic($action, $topic_id, $to_forum_id, $subject); - } - $action = 'split'; - } - - // Merge Posts? - if ($action == 'merge_posts') - { - if (!$sort) - { - merge_posts($topic_id, $to_topic_id); - } - $action = 'merge'; - } - - if ($action == 'split' && !$subject) - { - $subject = $topic_info['topic_title']; - } - - // Restore or pprove posts? - if (($action == 'restore' || $action == 'approve') && $auth->acl_get('m_approve', $topic_info['forum_id'])) - { - if (!class_exists('mcp_queue')) - { - include($phpbb_root_path . 'includes/mcp/mcp_queue.' . $phpEx); - } - - include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx); - include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); - - if (!count($post_id_list)) - { - trigger_error('NO_POST_SELECTED'); - } - - if (!$sort) - { - mcp_queue::approve_posts($action, $post_id_list, $id, $mode); - } - } - - // Jumpbox, sort selects and that kind of things - make_jumpbox($url . "&i=$id&mode=forum_view", $topic_info['forum_id'], false, 'm_', true); - $where_sql = ($action == 'reports') ? 'WHERE post_reported = 1 AND ' : 'WHERE'; - - $sort_days = $total = 0; - $sort_key = $sort_dir = ''; - $sort_by_sql = $sort_order_sql = array(); - phpbb_mcp_sorting('viewtopic', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $topic_info['forum_id'], $topic_id, $where_sql); - - /* @var $phpbb_content_visibility \phpbb\content_visibility */ - $phpbb_content_visibility = $phpbb_container->get('content.visibility'); - $limit_time_sql = ($sort_days) ? 'AND p.post_time >= ' . (time() - ($sort_days * 86400)) : ''; - - if ($total == -1) - { - $total = $phpbb_content_visibility->get_count('topic_posts', $topic_info, $topic_info['forum_id']); - } - - $posts_per_page = max(0, $request->variable('posts_per_page', intval($config['posts_per_page']))); - if ($posts_per_page == 0) - { - $posts_per_page = $total; - } - - if ((!empty($sort_days_old) && $sort_days_old != $sort_days) || $total <= $posts_per_page) - { - $start = 0; - } - $start = $pagination->validate_start($start, $posts_per_page, $total); - - $sql_where = (($action == 'reports') ? 'p.post_reported = 1 AND ' : '') . ' - p.topic_id = ' . $topic_id . ' - AND ' . $phpbb_content_visibility->get_visibility_sql('post', $topic_info['forum_id'], 'p.') . ' - AND p.poster_id = u.user_id ' . - $limit_time_sql; - - $sql_ary = array( - 'SELECT' => 'u.username, u.username_clean, u.user_colour, p.*', - 'FROM' => array( - POSTS_TABLE => 'p', - USERS_TABLE => 'u' - ), - 'LEFT_JOIN' => array(), - 'WHERE' => $sql_where, - 'ORDER_BY' => $sort_order_sql, - ); - - /** - * Event to modify the SQL query before the MCP topic review posts is queried - * - * @event core.mcp_topic_modify_sql_ary - * @var array sql_ary The SQL array to get the data of the MCP topic review posts - * @since 3.2.8-RC1 - */ - $vars = array('sql_ary'); - extract($phpbb_dispatcher->trigger_event('core.mcp_topic_modify_sql_ary', compact($vars))); - - $sql = $db->sql_build_query('SELECT', $sql_ary); - unset($sql_ary); - - $result = $db->sql_query_limit($sql, $posts_per_page, $start); - - $rowset = $post_id_list = array(); - while ($row = $db->sql_fetchrow($result)) - { - $rowset[] = $row; - $post_id_list[] = $row['post_id']; - } - $db->sql_freeresult($result); - - // Get topic tracking info - if ($config['load_db_lastread']) - { - $tmp_topic_data = array($topic_id => $topic_info); - $topic_tracking_info = get_topic_tracking($topic_info['forum_id'], $topic_id, $tmp_topic_data, array($topic_info['forum_id'] => $topic_info['forum_mark_time'])); - unset($tmp_topic_data); - } - else - { - $topic_tracking_info = get_complete_topic_tracking($topic_info['forum_id'], $topic_id); - } - - $has_unapproved_posts = $has_deleted_posts = false; - - // Grab extensions - $attachments = array(); - if ($topic_info['topic_attachment'] && count($post_id_list)) - { - // Get attachments... - if ($auth->acl_get('u_download') && $auth->acl_get('f_download', $topic_info['forum_id'])) - { - $sql = 'SELECT * - FROM ' . ATTACHMENTS_TABLE . ' - WHERE ' . $db->sql_in_set('post_msg_id', $post_id_list) . ' - AND in_message = 0 - ORDER BY filetime DESC, post_msg_id ASC'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $attachments[$row['post_msg_id']][] = $row; - } - $db->sql_freeresult($result); - } - } - - /** - * Event to modify the post data for the MCP topic review before assigning the posts - * - * @event core.mcp_topic_modify_post_data - * @var array attachments List of attachments post_id => array of attachments - * @var int forum_id The forum ID we are currently in - * @var int id ID of the tab we are displaying - * @var string mode Mode of the MCP page we are displaying - * @var array post_id_list Array with post ids we are going to display - * @var array rowset Array with the posts data - * @var int topic_id The topic ID we are currently reviewing - * @since 3.1.7-RC1 - */ - $vars = array( - 'attachments', - 'forum_id', - 'id', - 'mode', - 'post_id_list', - 'rowset', - 'topic_id', - ); - extract($phpbb_dispatcher->trigger_event('core.mcp_topic_modify_post_data', compact($vars))); - - foreach ($rowset as $current_row_number => $row) - { - $message = $row['post_text']; - $post_subject = ($row['post_subject'] != '') ? $row['post_subject'] : $topic_info['topic_title']; - - $parse_flags = ($row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES; - $message = generate_text_for_display($message, $row['bbcode_uid'], $row['bbcode_bitfield'], $parse_flags, false); - - if (!empty($attachments[$row['post_id']])) - { - $update_count = array(); - parse_attachments($topic_info['forum_id'], $message, $attachments[$row['post_id']], $update_count); - } - - if ($row['post_visibility'] == ITEM_UNAPPROVED || $row['post_visibility'] == ITEM_REAPPROVE) - { - $has_unapproved_posts = true; - } - - if ($row['post_visibility'] == ITEM_DELETED) - { - $has_deleted_posts = true; - } - - $post_unread = (isset($topic_tracking_info[$topic_id]) && $row['post_time'] > $topic_tracking_info[$topic_id]) ? true : false; - - $post_row = array( - 'POST_AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), - 'POST_AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), - 'POST_AUTHOR' => get_username_string('username', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), - 'U_POST_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), - - 'POST_DATE' => $user->format_date($row['post_time']), - 'POST_SUBJECT' => $post_subject, - 'MESSAGE' => $message, - 'POST_ID' => $row['post_id'], - 'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], '', ''), - - 'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'), - - 'S_POST_REPORTED' => ($row['post_reported'] && $auth->acl_get('m_report', $topic_info['forum_id'])), - 'S_POST_UNAPPROVED' => (($row['post_visibility'] == ITEM_UNAPPROVED || $row['post_visibility'] == ITEM_REAPPROVE) && $auth->acl_get('m_approve', $topic_info['forum_id'])), - 'S_POST_DELETED' => ($row['post_visibility'] == ITEM_DELETED && $auth->acl_get('m_approve', $topic_info['forum_id'])), - 'S_CHECKED' => (($submitted_id_list && !in_array(intval($row['post_id']), $submitted_id_list)) || in_array(intval($row['post_id']), $checked_ids)) ? true : false, - 'S_HAS_ATTACHMENTS' => (!empty($attachments[$row['post_id']])) ? true : false, - - 'U_POST_DETAILS' => "$url&i=$id&p={$row['post_id']}&mode=post_details" . (($forum_id) ? "&f=$forum_id" : ''), - 'U_MCP_APPROVE' => ($auth->acl_get('m_approve', $topic_info['forum_id'])) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=approve_details&f=' . $topic_info['forum_id'] . '&p=' . $row['post_id']) : '', - 'U_MCP_REPORT' => ($auth->acl_get('m_report', $topic_info['forum_id'])) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=report_details&f=' . $topic_info['forum_id'] . '&p=' . $row['post_id']) : '', - ); - - /** - * Event to modify the template data block for topic reviews in the MCP - * - * @event core.mcp_topic_review_modify_row - * @var int id ID of the tab we are displaying - * @var string mode Mode of the MCP page we are displaying - * @var int topic_id The topic ID we are currently reviewing - * @var int forum_id The forum ID we are currently in - * @var int start Start item of this page - * @var int current_row_number Number of the post on this page - * @var array post_row Template block array of the current post - * @var array row Array with original post and user data - * @var array topic_info Array with topic data - * @var int total Total posts count - * @since 3.1.4-RC1 - */ - $vars = array( - 'id', - 'mode', - 'topic_id', - 'forum_id', - 'start', - 'current_row_number', - 'post_row', - 'row', - 'topic_info', - 'total', - ); - extract($phpbb_dispatcher->trigger_event('core.mcp_topic_review_modify_row', compact($vars))); - - $template->assign_block_vars('postrow', $post_row); - - // Display not already displayed Attachments for this post, we already parsed them. ;) - if (!empty($attachments[$row['post_id']])) - { - foreach ($attachments[$row['post_id']] as $attachment) - { - $template->assign_block_vars('postrow.attachment', array( - 'DISPLAY_ATTACHMENT' => $attachment) - ); - } - } - - unset($rowset[$current_row_number]); - } - - // Display topic icons for split topic - $s_topic_icons = false; - - if ($auth->acl_gets('m_split', 'm_merge', (int) $topic_info['forum_id'])) - { - include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx); - $s_topic_icons = posting_gen_topic_icons('', $icon_id); - - // Has the user selected a topic for merge? - if ($to_topic_id) - { - $to_topic_info = phpbb_get_topic_data(array($to_topic_id), 'm_merge'); - - if (!count($to_topic_info)) - { - $to_topic_id = 0; - } - else - { - $to_topic_info = $to_topic_info[$to_topic_id]; - - if (!$to_topic_info['enable_icons'] || $auth->acl_get('!f_icons', $topic_info['forum_id'])) - { - $s_topic_icons = false; - } - } - } - } - - $s_hidden_fields = build_hidden_fields(array( - 'st_old' => $sort_days, - 'post_ids' => $post_id_list, - )); - - $base_url = append_sid("{$phpbb_root_path}mcp.$phpEx", "i=$id&t={$topic_info['topic_id']}&mode=$mode&action=$action&to_topic_id=$to_topic_id&posts_per_page=$posts_per_page&st=$sort_days&sk=$sort_key&sd=$sort_dir"); - if ($posts_per_page) - { - $pagination->generate_template_pagination($base_url, 'pagination', 'start', $total, $posts_per_page, $start); - } - - $template->assign_vars(array( - 'TOPIC_TITLE' => $topic_info['topic_title'], - 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $topic_info['forum_id'] . '&t=' . $topic_info['topic_id']), - - 'TO_TOPIC_ID' => $to_topic_id, - 'TO_TOPIC_INFO' => ($to_topic_id) ? sprintf($user->lang['YOU_SELECTED_TOPIC'], $to_topic_id, '' . $to_topic_info['topic_title'] . '') : '', - - 'SPLIT_SUBJECT' => $subject, - 'POSTS_PER_PAGE' => $posts_per_page, - 'ACTION' => $action, - - 'REPORTED_IMG' => $user->img('icon_topic_reported', 'POST_REPORTED'), - 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'POST_UNAPPROVED'), - 'DELETED_IMG' => $user->img('icon_topic_deleted', 'POST_DELETED_RESTORE'), - 'INFO_IMG' => $user->img('icon_post_info', 'VIEW_INFO'), - - 'S_MCP_ACTION' => "$url&i=$id&mode=$mode&action=$action&start=$start", - 'S_FORUM_SELECT' => ($to_forum_id) ? make_forum_select($to_forum_id, false, false, true, true, true) : make_forum_select($topic_info['forum_id'], false, false, true, true, true), - 'S_CAN_SPLIT' => ($auth->acl_get('m_split', $topic_info['forum_id'])) ? true : false, - 'S_CAN_MERGE' => ($auth->acl_get('m_merge', $topic_info['forum_id'])) ? true : false, - 'S_CAN_DELETE' => ($auth->acl_get('m_delete', $topic_info['forum_id'])) ? true : false, - 'S_CAN_APPROVE' => ($has_unapproved_posts && $auth->acl_get('m_approve', $topic_info['forum_id'])) ? true : false, - 'S_CAN_RESTORE' => ($has_deleted_posts && $auth->acl_get('m_approve', $topic_info['forum_id'])) ? true : false, - 'S_CAN_LOCK' => ($auth->acl_get('m_lock', $topic_info['forum_id'])) ? true : false, - 'S_CAN_REPORT' => ($auth->acl_get('m_report', $topic_info['forum_id'])) ? true : false, - 'S_CAN_SYNC' => $auth->acl_get('m_', $topic_info['forum_id']), - 'S_REPORT_VIEW' => ($action == 'reports') ? true : false, - 'S_MERGE_VIEW' => ($action == 'merge') ? true : false, - 'S_SPLIT_VIEW' => ($action == 'split') ? true : false, - - 'S_HIDDEN_FIELDS' => $s_hidden_fields, - - 'S_SHOW_TOPIC_ICONS' => $s_topic_icons, - 'S_TOPIC_ICON' => $icon_id, - - 'U_SELECT_TOPIC' => "$url&i=$id&mode=forum_view&action=merge_select" . (($forum_id) ? "&f=$forum_id" : ''), - - 'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], '', ''), - 'RETURN_FORUM' => sprintf($user->lang['RETURN_FORUM'], '', ''), - - 'TOTAL_POSTS' => $user->lang('VIEW_TOPIC_POSTS', (int) $total), - )); -} - -/** -* Split topic -*/ -function split_topic($action, $topic_id, $to_forum_id, $subject) -{ - global $db, $template, $user, $phpEx, $phpbb_root_path, $auth, $config, $phpbb_log, $request, $phpbb_dispatcher; - - $post_id_list = $request->variable('post_id_list', array(0)); - $forum_id = $request->variable('forum_id', 0); - $start = $request->variable('start', 0); - - if (!count($post_id_list)) - { - $template->assign_var('MESSAGE', $user->lang['NO_POST_SELECTED']); - return; - } - - if (!phpbb_check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_split'))) - { - return; - } - - $post_id = $post_id_list[0]; - $post_info = phpbb_get_post_data(array($post_id)); - - if (!count($post_info)) - { - $template->assign_var('MESSAGE', $user->lang['NO_POST_SELECTED']); - return; - } - - $post_info = $post_info[$post_id]; - $subject = trim($subject); - - // Make some tests - if (!$subject) - { - $template->assign_var('MESSAGE', $user->lang['EMPTY_SUBJECT']); - return; - } - - if ($to_forum_id <= 0) - { - $template->assign_var('MESSAGE', $user->lang['NO_DESTINATION_FORUM']); - return; - } - - $forum_info = phpbb_get_forum_data(array($to_forum_id), 'f_post'); - - if (!count($forum_info)) - { - $template->assign_var('MESSAGE', $user->lang['USER_CANNOT_POST']); - return; - } - - $forum_info = $forum_info[$to_forum_id]; - - if ($forum_info['forum_type'] != FORUM_POST) - { - $template->assign_var('MESSAGE', $user->lang['FORUM_NOT_POSTABLE']); - return; - } - - $redirect = $request->variable('redirect', build_url(array('quickmod'))); - - $s_hidden_fields = build_hidden_fields(array( - 'i' => 'main', - 'post_id_list' => $post_id_list, - 'f' => $forum_id, - 'mode' => 'topic_view', - 'start' => $start, - 'action' => $action, - 't' => $topic_id, - 'redirect' => $redirect, - 'subject' => $subject, - 'to_forum_id' => $to_forum_id, - 'icon' => $request->variable('icon', 0)) - ); - - if (confirm_box(true)) - { - if ($action == 'split_beyond') - { - $sort_days = $total = 0; - $sort_key = $sort_dir = ''; - $sort_by_sql = $sort_order_sql = array(); - phpbb_mcp_sorting('viewtopic', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id, $topic_id); - - $limit_time_sql = ($sort_days) ? 'AND t.topic_last_post_time >= ' . (time() - ($sort_days * 86400)) : ''; - - if ($sort_order_sql[0] == 'u') - { - $sql = 'SELECT p.post_id, p.forum_id, p.post_visibility - FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . " u - WHERE p.topic_id = $topic_id - AND p.poster_id = u.user_id - $limit_time_sql - ORDER BY $sort_order_sql"; - } - else - { - $sql = 'SELECT p.post_id, p.forum_id, p.post_visibility - FROM ' . POSTS_TABLE . " p - WHERE p.topic_id = $topic_id - $limit_time_sql - ORDER BY $sort_order_sql"; - } - $result = $db->sql_query_limit($sql, 0, $start); - - $store = false; - $post_id_list = array(); - while ($row = $db->sql_fetchrow($result)) - { - // If split from selected post (split_beyond), we split the unapproved items too. - if (($row['post_visibility'] == ITEM_UNAPPROVED || $row['post_visibility'] == ITEM_REAPPROVE) && !$auth->acl_get('m_approve', $row['forum_id'])) - { -// continue; - } - - // Start to store post_ids as soon as we see the first post that was selected - if ($row['post_id'] == $post_id) - { - $store = true; - } - - if ($store) - { - $post_id_list[] = $row['post_id']; - } - } - $db->sql_freeresult($result); - } - - if (!count($post_id_list)) - { - trigger_error('NO_POST_SELECTED'); - } - - $icon_id = $request->variable('icon', 0); - - $sql_ary = array( - 'forum_id' => $to_forum_id, - 'topic_title' => $subject, - 'icon_id' => $icon_id, - 'topic_visibility' => 1 - ); - - $sql = 'INSERT INTO ' . TOPICS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); - $db->sql_query($sql); - - $to_topic_id = $db->sql_nextid(); - move_posts($post_id_list, $to_topic_id); - - $topic_info = phpbb_get_topic_data(array($topic_id)); - $topic_info = $topic_info[$topic_id]; - - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_SPLIT_DESTINATION', false, array( - 'forum_id' => $to_forum_id, - 'topic_id' => $to_topic_id, - $subject - )); - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_SPLIT_SOURCE', false, array( - 'forum_id' => $forum_id, - 'topic_id' => $topic_id, - $topic_info['topic_title'] - )); - - // Change topic title of first post - $sql = 'UPDATE ' . POSTS_TABLE . " - SET post_subject = '" . $db->sql_escape($subject) . "' - WHERE post_id = {$post_id_list[0]}"; - $db->sql_query($sql); - - // Grab data for first post in split topic - $sql_array = array( - 'SELECT' => 'p.post_id, p.forum_id, p.poster_id, p.post_text, f.enable_indexing', - 'FROM' => array( - POSTS_TABLE => 'p', - ), - 'LEFT_JOIN' => array( - array( - 'FROM' => array(FORUMS_TABLE => 'f'), - 'ON' => 'p.forum_id = f.forum_id', - ) - ), - 'WHERE' => "post_id = {$post_id_list[0]}", - ); - $sql = $db->sql_build_query('SELECT', $sql_array); - $result = $db->sql_query($sql); - $first_post_data = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - // Index first post as if it were edited - if ($first_post_data['enable_indexing']) - { - // Select the search method and do some additional checks to ensure it can actually be utilised - $search_type = $config['search_type']; - - if (!class_exists($search_type)) - { - trigger_error('NO_SUCH_SEARCH_MODULE'); - } - - $error = false; - $search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher); - - if ($error) - { - trigger_error($error); - } - - $search->index('edit', $first_post_data['post_id'], $first_post_data['post_text'], $subject, $first_post_data['poster_id'], $first_post_data['forum_id']); - } - - // Copy topic subscriptions to new topic - $sql = 'SELECT user_id, notify_status - FROM ' . TOPICS_WATCH_TABLE . ' - WHERE topic_id = ' . $topic_id; - $result = $db->sql_query($sql); - - $sql_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - $sql_ary[] = array( - 'topic_id' => (int) $to_topic_id, - 'user_id' => (int) $row['user_id'], - 'notify_status' => (int) $row['notify_status'], - ); - } - $db->sql_freeresult($result); - - if (count($sql_ary)) - { - $db->sql_multi_insert(TOPICS_WATCH_TABLE, $sql_ary); - } - - // Copy bookmarks to new topic - $sql = 'SELECT user_id - FROM ' . BOOKMARKS_TABLE . ' - WHERE topic_id = ' . $topic_id; - $result = $db->sql_query($sql); - - $sql_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - $sql_ary[] = array( - 'topic_id' => (int) $to_topic_id, - 'user_id' => (int) $row['user_id'], - ); - } - $db->sql_freeresult($result); - - if (count($sql_ary)) - { - $db->sql_multi_insert(BOOKMARKS_TABLE, $sql_ary); - } - - $success_msg = 'TOPIC_SPLIT_SUCCESS'; - - // Update forum statistics - $config->increment('num_topics', 1, false); - - // Link back to both topics - $return_link = sprintf($user->lang['RETURN_TOPIC'], '', '') . '

' . sprintf($user->lang['RETURN_NEW_TOPIC'], '', ''); - $redirect = $request->variable('redirect', "{$phpbb_root_path}viewtopic.$phpEx?f=$to_forum_id&t=$to_topic_id"); - $redirect = reapply_sid($redirect); - - meta_refresh(3, $redirect); - trigger_error($user->lang[$success_msg] . '

' . $return_link); - } - else - { - confirm_box(false, ($action == 'split_all') ? 'SPLIT_TOPIC_ALL' : 'SPLIT_TOPIC_BEYOND', $s_hidden_fields); - } -} - -/** -* Merge selected posts into selected topic -*/ -function merge_posts($topic_id, $to_topic_id) -{ - global $db, $template, $user, $phpEx, $phpbb_root_path, $phpbb_log, $request, $phpbb_dispatcher; - - if (!$to_topic_id) - { - $template->assign_var('MESSAGE', $user->lang['NO_FINAL_TOPIC_SELECTED']); - return; - } - - $sync_topics = array($topic_id, $to_topic_id); - - $topic_data = phpbb_get_topic_data($sync_topics, 'm_merge'); - - if (!count($topic_data) || empty($topic_data[$to_topic_id])) - { - $template->assign_var('MESSAGE', $user->lang['NO_FINAL_TOPIC_SELECTED']); - return; - } - - $sync_forums = array(); - foreach ($topic_data as $data) - { - $sync_forums[$data['forum_id']] = $data['forum_id']; - } - - $topic_data = $topic_data[$to_topic_id]; - - $post_id_list = $request->variable('post_id_list', array(0)); - $start = $request->variable('start', 0); - - if (!count($post_id_list)) - { - $template->assign_var('MESSAGE', $user->lang['NO_POST_SELECTED']); - return; - } - - if (!phpbb_check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_merge'))) - { - return; - } - - $redirect = $request->variable('redirect', build_url(array('quickmod'))); - - $s_hidden_fields = build_hidden_fields(array( - 'i' => 'main', - 'post_id_list' => $post_id_list, - 'to_topic_id' => $to_topic_id, - 'mode' => 'topic_view', - 'action' => 'merge_posts', - 'start' => $start, - 'redirect' => $redirect, - 't' => $topic_id) - ); - $return_link = ''; - - if (confirm_box(true)) - { - $to_forum_id = $topic_data['forum_id']; - - move_posts($post_id_list, $to_topic_id, false); - - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_MERGE', false, array( - 'forum_id' => $to_forum_id, - 'topic_id' => $to_topic_id, - $topic_data['topic_title'] - )); - - // Message and return links - $success_msg = 'POSTS_MERGED_SUCCESS'; - - // Does the original topic still exist? If yes, link back to it - $sql = 'SELECT forum_id - FROM ' . POSTS_TABLE . ' - WHERE topic_id = ' . $topic_id; - $result = $db->sql_query_limit($sql, 1); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - $return_link .= sprintf($user->lang['RETURN_TOPIC'], '', ''); - } - else - { - if (!function_exists('phpbb_update_rows_avoiding_duplicates_notify_status')) - { - include($phpbb_root_path . 'includes/functions_database_helper.' . $phpEx); - } - - // If the topic no longer exist, we will update the topic watch table. - phpbb_update_rows_avoiding_duplicates_notify_status($db, TOPICS_WATCH_TABLE, 'topic_id', array($topic_id), $to_topic_id); - - // If the topic no longer exist, we will update the bookmarks table. - phpbb_update_rows_avoiding_duplicates($db, BOOKMARKS_TABLE, 'topic_id', array($topic_id), $to_topic_id); - } - - // Re-sync the topics and forums because the auto-sync was deactivated in the call of move_posts() - sync('topic_reported', 'topic_id', $sync_topics); - sync('topic_attachment', 'topic_id', $sync_topics); - sync('topic', 'topic_id', $sync_topics, true); - sync('forum', 'forum_id', $sync_forums, true, true); - - // Link to the new topic - $return_link .= (($return_link) ? '

' : '') . sprintf($user->lang['RETURN_NEW_TOPIC'], '', ''); - $redirect = $request->variable('redirect', "{$phpbb_root_path}viewtopic.$phpEx?f=$to_forum_id&t=$to_topic_id"); - $redirect = reapply_sid($redirect); - - /** - * Perform additional actions after merging posts. - * - * @event core.mcp_topics_merge_posts_after - * @var int topic_id The topic ID from which posts are being moved - * @var int to_topic_id The topic ID to which posts are being moved - * @since 3.1.11-RC1 - */ - $vars = array( - 'topic_id', - 'to_topic_id', - ); - extract($phpbb_dispatcher->trigger_event('core.mcp_topics_merge_posts_after', compact($vars))); - - meta_refresh(3, $redirect); - trigger_error($user->lang[$success_msg] . '

' . $return_link); - } - else - { - confirm_box(false, 'MERGE_POSTS', $s_hidden_fields); - } -} diff --git a/install/update/new/includes/mcp/mcp_warn.php b/install/update/new/includes/mcp/mcp_warn.php deleted file mode 100644 index 7a8599f..0000000 --- a/install/update/new/includes/mcp/mcp_warn.php +++ /dev/null @@ -1,610 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* mcp_warn -* Handling warning the users -*/ -class mcp_warn -{ - var $p_master; - var $u_action; - - function __construct($p_master) - { - $this->p_master = $p_master; - } - - function main($id, $mode) - { - global $request; - - $action = $request->variable('action', array('' => '')); - - if (is_array($action)) - { - $action = key($action); - } - - $this->page_title = 'MCP_WARN'; - - add_form_key('mcp_warn'); - - switch ($mode) - { - case 'front': - $this->mcp_warn_front_view(); - $this->tpl_name = 'mcp_warn_front'; - break; - - case 'list': - $this->mcp_warn_list_view($action); - $this->tpl_name = 'mcp_warn_list'; - break; - - case 'warn_post': - $this->mcp_warn_post_view($action); - $this->tpl_name = 'mcp_warn_post'; - break; - - case 'warn_user': - $this->mcp_warn_user_view($action); - $this->tpl_name = 'mcp_warn_user'; - break; - } - } - - /** - * Generates the summary on the main page of the warning module - */ - function mcp_warn_front_view() - { - global $phpEx, $phpbb_root_path; - global $template, $db, $user; - - $template->assign_vars(array( - 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=mcp&field=username&select_single=true'), - 'U_POST_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_user'), - )); - - // Obtain a list of the 5 naughtiest users.... - // These are the 5 users with the highest warning count - $highest = array(); - $count = 0; - - view_warned_users($highest, $count, 5); - - foreach ($highest as $row) - { - $template->assign_block_vars('highest', array( - 'U_NOTES' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $row['user_id']), - - 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), - - 'WARNING_TIME' => $user->format_date($row['user_last_warning']), - 'WARNINGS' => $row['user_warnings'], - )); - } - - // And now the 5 most recent users to get in trouble - $sql = 'SELECT u.user_id, u.username, u.username_clean, u.user_colour, u.user_warnings, w.warning_time - FROM ' . USERS_TABLE . ' u, ' . WARNINGS_TABLE . ' w - WHERE u.user_id = w.user_id - ORDER BY w.warning_time DESC'; - $result = $db->sql_query_limit($sql, 5); - - while ($row = $db->sql_fetchrow($result)) - { - $template->assign_block_vars('latest', array( - 'U_NOTES' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $row['user_id']), - - 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), - - 'WARNING_TIME' => $user->format_date($row['warning_time']), - 'WARNINGS' => $row['user_warnings'], - )); - } - $db->sql_freeresult($result); - } - - /** - * Lists all users with warnings - */ - function mcp_warn_list_view($action) - { - global $phpEx, $phpbb_root_path, $config, $phpbb_container; - global $template, $user, $auth, $request; - - /* @var $pagination \phpbb\pagination */ - $pagination = $phpbb_container->get('pagination'); - $user->add_lang('memberlist'); - - $start = $request->variable('start', 0); - $st = $request->variable('st', 0); - $sk = $request->variable('sk', 'b'); - $sd = $request->variable('sd', 'd'); - - $limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); - $sort_by_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_DATE'], 'c' => $user->lang['SORT_WARNINGS']); - $sort_by_sql = array('a' => 'username_clean', 'b' => 'user_last_warning', 'c' => 'user_warnings'); - - $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; - gen_sort_selects($limit_days, $sort_by_text, $st, $sk, $sd, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); - - // Define where and sort sql for use in displaying logs - $sql_where = ($st) ? (time() - ($st * 86400)) : 0; - $sql_sort = $sort_by_sql[$sk] . ' ' . (($sd == 'd') ? 'DESC' : 'ASC'); - - $users = array(); - $user_count = 0; - - view_warned_users($users, $user_count, $config['topics_per_page'], $start, $sql_where, $sql_sort); - - foreach ($users as $row) - { - $template->assign_block_vars('user', array( - 'U_NOTES' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $row['user_id']), - - 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), - - 'WARNING_TIME' => $user->format_date($row['user_last_warning']), - 'WARNINGS' => $row['user_warnings'], - )); - } - - $base_url = append_sid("{$phpbb_root_path}mcp.$phpEx", "i=warn&mode=list&st=$st&sk=$sk&sd=$sd"); - $pagination->generate_template_pagination($base_url, 'pagination', 'start', $user_count, $config['topics_per_page'], $start); - - $template->assign_vars(array( - 'U_POST_ACTION' => $this->u_action, - 'S_CLEAR_ALLOWED' => ($auth->acl_get('a_clearlogs')) ? true : false, - 'S_SELECT_SORT_DIR' => $s_sort_dir, - 'S_SELECT_SORT_KEY' => $s_sort_key, - 'S_SELECT_SORT_DAYS' => $s_limit_days, - - 'TOTAL_USERS' => $user->lang('LIST_USERS', (int) $user_count), - )); - } - - /** - * Handles warning the user when the warning is for a specific post - */ - function mcp_warn_post_view($action) - { - global $phpEx, $phpbb_root_path, $config, $request; - global $template, $db, $user, $phpbb_dispatcher; - - $post_id = $request->variable('p', 0); - $forum_id = $request->variable('f', 0); - $notify = (isset($_REQUEST['notify_user'])) ? true : false; - $warning = $request->variable('warning', '', true); - - $sql = 'SELECT u.*, p.* - FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . " u - WHERE p.post_id = $post_id - AND u.user_id = p.poster_id"; - $result = $db->sql_query($sql); - $user_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$user_row) - { - trigger_error('NO_POST'); - } - - // There is no point issuing a warning to ignored users (ie anonymous and bots) - if ($user_row['user_type'] == USER_IGNORE) - { - trigger_error('CANNOT_WARN_ANONYMOUS'); - } - - // Prevent someone from warning themselves - if ($user_row['user_id'] == $user->data['user_id']) - { - trigger_error('CANNOT_WARN_SELF'); - } - - // Check if there is already a warning for this post to prevent multiple - // warnings for the same offence - $sql = 'SELECT post_id - FROM ' . WARNINGS_TABLE . " - WHERE post_id = $post_id"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - trigger_error('ALREADY_WARNED'); - } - - $user_id = $user_row['user_id']; - - if (strpos($this->u_action, "&f=$forum_id&p=$post_id") === false) - { - $this->p_master->adjust_url("&f=$forum_id&p=$post_id"); - $this->u_action .= "&f=$forum_id&p=$post_id"; - } - - // Check if can send a notification - if ($config['allow_privmsg']) - { - $auth2 = new \phpbb\auth\auth(); - $auth2->acl($user_row); - $s_can_notify = ($auth2->acl_get('u_readpm')) ? true : false; - unset($auth2); - } - else - { - $s_can_notify = false; - } - - // Prevent against clever people - if ($notify && !$s_can_notify) - { - $notify = false; - } - - if ($warning && $action == 'add_warning') - { - if (check_form_key('mcp_warn')) - { - $s_mcp_warn_post = true; - - /** - * Event for before warning a user for a post. - * - * @event core.mcp_warn_post_before - * @var array user_row The entire user row - * @var string warning The warning message - * @var bool notify If true, we notify the user for the warning - * @var int post_id The post id for which the warning is added - * @var bool s_mcp_warn_post If true, we add the warning else we omit it - * @since 3.1.0-b4 - */ - $vars = array( - 'user_row', - 'warning', - 'notify', - 'post_id', - 's_mcp_warn_post', - ); - extract($phpbb_dispatcher->trigger_event('core.mcp_warn_post_before', compact($vars))); - - if ($s_mcp_warn_post) - { - add_warning($user_row, $warning, $notify, $post_id); - $message = $user->lang['USER_WARNING_ADDED']; - - /** - * Event for after warning a user for a post. - * - * @event core.mcp_warn_post_after - * @var array user_row The entire user row - * @var string warning The warning message - * @var bool notify If true, the user was notified for the warning - * @var int post_id The post id for which the warning is added - * @var string message Message displayed to the moderator - * @since 3.1.0-b4 - */ - $vars = array( - 'user_row', - 'warning', - 'notify', - 'post_id', - 'message', - ); - extract($phpbb_dispatcher->trigger_event('core.mcp_warn_post_after', compact($vars))); - } - } - else - { - $message = $user->lang['FORM_INVALID']; - } - - if (!empty($message)) - { - $redirect = append_sid("{$phpbb_root_path}mcp.$phpEx", "i=notes&mode=user_notes&u=$user_id"); - meta_refresh(2, $redirect); - trigger_error($message . '

' . sprintf($user->lang['RETURN_PAGE'], '', '')); - } - } - - // OK, they didn't submit a warning so lets build the page for them to do so - - // We want to make the message available here as a reminder - // Parse the message and subject - $parse_flags = OPTION_FLAG_SMILIES | ($user_row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0); - $message = generate_text_for_display($user_row['post_text'], $user_row['bbcode_uid'], $user_row['bbcode_bitfield'], $parse_flags, true); - - // Generate the appropriate user information for the user we are looking at - if (!function_exists('phpbb_get_user_rank')) - { - include($phpbb_root_path . 'includes/functions_display.' . $phpEx); - } - - $user_rank_data = phpbb_get_user_rank($user_row, $user_row['user_posts']); - $avatar_img = phpbb_get_user_avatar($user_row); - - $template->assign_vars(array( - 'U_POST_ACTION' => $this->u_action, - - 'POST' => $message, - 'USERNAME' => $user_row['username'], - 'USER_COLOR' => (!empty($user_row['user_colour'])) ? $user_row['user_colour'] : '', - 'RANK_TITLE' => $user_rank_data['title'], - 'JOINED' => $user->format_date($user_row['user_regdate']), - 'POSTS' => ($user_row['user_posts']) ? $user_row['user_posts'] : 0, - 'WARNINGS' => ($user_row['user_warnings']) ? $user_row['user_warnings'] : 0, - - 'AVATAR_IMG' => $avatar_img, - 'RANK_IMG' => $user_rank_data['img'], - - 'L_WARNING_POST_DEFAULT' => sprintf($user->lang['WARNING_POST_DEFAULT'], generate_board_url() . "/viewtopic.$phpEx?f=$forum_id&p=$post_id#p$post_id"), - - 'S_CAN_NOTIFY' => $s_can_notify, - )); - } - - /** - * Handles warning the user - */ - function mcp_warn_user_view($action) - { - global $phpEx, $phpbb_root_path, $config, $request; - global $template, $db, $user, $phpbb_dispatcher; - - $user_id = $request->variable('u', 0); - $username = $request->variable('username', '', true); - $notify = (isset($_REQUEST['notify_user'])) ? true : false; - $warning = $request->variable('warning', '', true); - - $sql_where = ($user_id) ? "user_id = $user_id" : "username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'"; - - $sql = 'SELECT * - FROM ' . USERS_TABLE . ' - WHERE ' . $sql_where; - $result = $db->sql_query($sql); - $user_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$user_row) - { - trigger_error('NO_USER'); - } - - // Prevent someone from warning themselves - if ($user_row['user_id'] == $user->data['user_id']) - { - trigger_error('CANNOT_WARN_SELF'); - } - - $user_id = $user_row['user_id']; - - if (strpos($this->u_action, "&u=$user_id") === false) - { - $this->p_master->adjust_url('&u=' . $user_id); - $this->u_action .= "&u=$user_id"; - } - - // Check if can send a notification - if ($config['allow_privmsg']) - { - $auth2 = new \phpbb\auth\auth(); - $auth2->acl($user_row); - $s_can_notify = ($auth2->acl_get('u_readpm')) ? true : false; - unset($auth2); - } - else - { - $s_can_notify = false; - } - - // Prevent against clever people - if ($notify && !$s_can_notify) - { - $notify = false; - } - - if ($warning && $action == 'add_warning') - { - if (check_form_key('mcp_warn')) - { - $s_mcp_warn_user = true; - - /** - * Event for before warning a user from MCP. - * - * @event core.mcp_warn_user_before - * @var array user_row The entire user row - * @var string warning The warning message - * @var bool notify If true, we notify the user for the warning - * @var bool s_mcp_warn_user If true, we add the warning else we omit it - * @since 3.1.0-b4 - */ - $vars = array( - 'user_row', - 'warning', - 'notify', - 's_mcp_warn_user', - ); - extract($phpbb_dispatcher->trigger_event('core.mcp_warn_user_before', compact($vars))); - - if ($s_mcp_warn_user) - { - add_warning($user_row, $warning, $notify); - $message = $user->lang['USER_WARNING_ADDED']; - - /** - * Event for after warning a user from MCP. - * - * @event core.mcp_warn_user_after - * @var array user_row The entire user row - * @var string warning The warning message - * @var bool notify If true, the user was notified for the warning - * @var string message Message displayed to the moderator - * @since 3.1.0-b4 - */ - $vars = array( - 'user_row', - 'warning', - 'notify', - 'message', - ); - extract($phpbb_dispatcher->trigger_event('core.mcp_warn_user_after', compact($vars))); - } - } - else - { - $message = $user->lang['FORM_INVALID']; - } - - if (!empty($message)) - { - $redirect = append_sid("{$phpbb_root_path}mcp.$phpEx", "i=notes&mode=user_notes&u=$user_id"); - meta_refresh(2, $redirect); - trigger_error($message . '

' . sprintf($user->lang['RETURN_PAGE'], '', '')); - } - } - - // Generate the appropriate user information for the user we are looking at - if (!function_exists('phpbb_get_user_rank')) - { - include($phpbb_root_path . 'includes/functions_display.' . $phpEx); - } - $user_rank_data = phpbb_get_user_rank($user_row, $user_row['user_posts']); - $avatar_img = phpbb_get_user_avatar($user_row); - - // OK, they didn't submit a warning so lets build the page for them to do so - $template->assign_vars(array( - 'U_POST_ACTION' => $this->u_action, - - 'RANK_TITLE' => $user_rank_data['title'], - 'JOINED' => $user->format_date($user_row['user_regdate']), - 'POSTS' => ($user_row['user_posts']) ? $user_row['user_posts'] : 0, - 'WARNINGS' => ($user_row['user_warnings']) ? $user_row['user_warnings'] : 0, - - 'USERNAME_FULL' => get_username_string('full', $user_row['user_id'], $user_row['username'], $user_row['user_colour']), - 'USERNAME_COLOUR' => get_username_string('colour', $user_row['user_id'], $user_row['username'], $user_row['user_colour']), - 'USERNAME' => get_username_string('username', $user_row['user_id'], $user_row['username'], $user_row['user_colour']), - 'U_PROFILE' => get_username_string('profile', $user_row['user_id'], $user_row['username'], $user_row['user_colour']), - - 'AVATAR_IMG' => $avatar_img, - 'RANK_IMG' => $user_rank_data['img'], - - 'S_CAN_NOTIFY' => $s_can_notify, - )); - - return $user_id; - } -} - -/** -* Insert the warning into the database -*/ -function add_warning($user_row, $warning, $send_pm = true, $post_id = 0) -{ - global $phpEx, $phpbb_root_path, $config, $phpbb_log; - global $db, $user; - - if ($send_pm) - { - include_once($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx); - include_once($phpbb_root_path . 'includes/message_parser.' . $phpEx); - - // Attempt to translate warning to language of user being warned if user's language differs from issuer's language - if ($user_row['user_lang'] != $user->lang_name) - { - $lang = array(); - - $user_row['user_lang'] = (file_exists($phpbb_root_path . 'language/' . basename($user_row['user_lang']) . "/mcp." . $phpEx)) ? $user_row['user_lang'] : $config['default_lang']; - include($phpbb_root_path . 'language/' . basename($user_row['user_lang']) . "/mcp." . $phpEx); - - $warn_pm_subject = $lang['WARNING_PM_SUBJECT']; - $warn_pm_body = sprintf($lang['WARNING_PM_BODY'], $warning); - - unset($lang); - } - else - { - $warn_pm_subject = $user->lang('WARNING_PM_SUBJECT'); - $warn_pm_body = $user->lang('WARNING_PM_BODY', $warning); - } - - $message_parser = new parse_message(); - - $message_parser->message = $warn_pm_body; - $message_parser->parse(true, true, true, false, false, true, true); - - $pm_data = array( - 'from_user_id' => $user->data['user_id'], - 'from_user_ip' => $user->ip, - 'from_username' => $user->data['username'], - 'enable_sig' => false, - 'enable_bbcode' => true, - 'enable_smilies' => true, - 'enable_urls' => false, - 'icon_id' => 0, - 'bbcode_bitfield' => $message_parser->bbcode_bitfield, - 'bbcode_uid' => $message_parser->bbcode_uid, - 'message' => $message_parser->message, - 'address_list' => array('u' => array($user_row['user_id'] => 'to')), - ); - - submit_pm('post', $warn_pm_subject, $pm_data, false); - } - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_WARNING', false, array($user_row['username'])); - $log_id = $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_WARNING_BODY', false, array( - 'reportee_id' => $user_row['user_id'], - $warning - )); - - $sql_ary = array( - 'user_id' => $user_row['user_id'], - 'post_id' => $post_id, - 'log_id' => $log_id, - 'warning_time' => time(), - ); - - $db->sql_query('INSERT INTO ' . WARNINGS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_warnings = user_warnings + 1, - user_last_warning = ' . time() . ' - WHERE user_id = ' . $user_row['user_id']; - $db->sql_query($sql); - - // We add this to the mod log too for moderators to see that a specific user got warned. - $sql = 'SELECT forum_id, topic_id - FROM ' . POSTS_TABLE . ' - WHERE post_id = ' . $post_id; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_USER_WARNING', false, array( - 'forum_id' => $row['forum_id'], - 'topic_id' => $row['topic_id'], - 'post_id' => $post_id, - $user_row['username'] - )); -} diff --git a/install/update/new/includes/message_parser.php b/install/update/new/includes/message_parser.php deleted file mode 100644 index d6214c4..0000000 --- a/install/update/new/includes/message_parser.php +++ /dev/null @@ -1,2087 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -if (!class_exists('bbcode')) -{ - // The following lines are for extensions which include message_parser.php - // while $phpbb_root_path and $phpEx are out of the script scope - // which may lead to the 'Undefined variable' and 'failed to open stream' errors - if (!isset($phpbb_root_path)) - { - global $phpbb_root_path; - } - - if (!isset($phpEx)) - { - global $phpEx; - } - - include($phpbb_root_path . 'includes/bbcode.' . $phpEx); -} - -/** -* BBCODE FIRSTPASS -* BBCODE first pass class (functions for parsing messages for db storage) -*/ -class bbcode_firstpass extends bbcode -{ - var $message = ''; - var $warn_msg = array(); - var $parsed_items = array(); - var $mode; - - /** - * Parse BBCode - */ - function parse_bbcode() - { - if (!$this->bbcodes) - { - $this->bbcode_init(); - } - - global $user; - - $this->bbcode_bitfield = ''; - $bitfield = new bitfield(); - - foreach ($this->bbcodes as $bbcode_name => $bbcode_data) - { - if (isset($bbcode_data['disabled']) && $bbcode_data['disabled']) - { - foreach ($bbcode_data['regexp'] as $regexp => $replacement) - { - if (preg_match($regexp, $this->message)) - { - $this->warn_msg[] = sprintf($user->lang['UNAUTHORISED_BBCODE'] , '[' . $bbcode_name . ']'); - continue; - } - } - } - else - { - foreach ($bbcode_data['regexp'] as $regexp => $replacement) - { - // The pattern gets compiled and cached by the PCRE extension, - // it should not demand recompilation - if (preg_match($regexp, $this->message)) - { - if (is_callable($replacement)) - { - $this->message = preg_replace_callback($regexp, $replacement, $this->message); - } - else - { - $this->message = preg_replace($regexp, $replacement, $this->message); - } - $bitfield->set($bbcode_data['bbcode_id']); - } - } - } - } - - $this->bbcode_bitfield = $bitfield->get_base64(); - } - - /** - * Prepare some bbcodes for better parsing - */ - function prepare_bbcodes() - { - // Ok, seems like users instead want the no-parsing of urls, smilies, etc. after and before and within quote tags being tagged as "not a bug". - // Fine by me ;) Will ease our live... but do not come back and cry at us, we won't hear you. - - /* Add newline at the end and in front of each quote block to prevent parsing errors (urls, smilies, etc.) - if (strpos($this->message, '[quote') !== false && strpos($this->message, '[/quote]') !== false) - { - $this->message = str_replace("\r\n", "\n", $this->message); - - // We strip newlines and spaces after and before quotes in quotes (trimming) and then add exactly one newline - $this->message = preg_replace('#\[quote(=".*?")?\]\s*(.*?)\s*\[/quote\]#siu', '[quote\1]' . "\n" . '\2' ."\n[/quote]", $this->message); - } - */ - - // Add other checks which needs to be placed before actually parsing anything (be it bbcodes, smilies, urls...) - } - - /** - * Init bbcode data for later parsing - */ - function bbcode_init($allow_custom_bbcode = true) - { - global $phpbb_dispatcher; - - static $rowset; - - $bbcode_class = $this; - - // This array holds all bbcode data. BBCodes will be processed in this - // order, so it is important to keep [code] in first position and - // [quote] in second position. - // To parse multiline URL we enable dotall option setting only for URL text - // but not for link itself, thus [url][/url] is not affected. - // - // To perform custom validation in extension, use $this->validate_bbcode_by_extension() - // method which accepts variable number of parameters - $this->bbcodes = array( - 'code' => array('bbcode_id' => BBCODE_ID_CODE, 'regexp' => array('#\[code(?:=([a-z]+))?\](.+\[/code\])#uis' => function ($match) use($bbcode_class) - { - return $bbcode_class->bbcode_code($match[1], $match[2]); - } - )), - 'quote' => array('bbcode_id' => BBCODE_ID_QUOTE, 'regexp' => array('#\[quote(?:="(.*?)")?\](.+)\[/quote\]#uis' => function ($match) use($bbcode_class) - { - return $bbcode_class->bbcode_quote($match[0]); - } - )), - 'attachment' => array('bbcode_id' => BBCODE_ID_ATTACH, 'regexp' => array('#\[attachment=([0-9]+)\](.*?)\[/attachment\]#uis' => function ($match) use($bbcode_class) - { - return $bbcode_class->bbcode_attachment($match[1], $match[2]); - } - )), - 'b' => array('bbcode_id' => BBCODE_ID_B, 'regexp' => array('#\[b\](.*?)\[/b\]#uis' => function ($match) use($bbcode_class) - { - return $bbcode_class->bbcode_strong($match[1]); - } - )), - 'i' => array('bbcode_id' => BBCODE_ID_I, 'regexp' => array('#\[i\](.*?)\[/i\]#uis' => function ($match) use($bbcode_class) - { - return $bbcode_class->bbcode_italic($match[1]); - } - )), - 'url' => array('bbcode_id' => BBCODE_ID_URL, 'regexp' => array('#\[url(=(.*))?\](?(1)((?s).*(?-s))|(.*))\[/url\]#uiU' => function ($match) use($bbcode_class) - { - return $bbcode_class->validate_url($match[2], ($match[3]) ? $match[3] : $match[4]); - } - )), - 'img' => array('bbcode_id' => BBCODE_ID_IMG, 'regexp' => array('#\[img\](.*)\[/img\]#uiU' => function ($match) use($bbcode_class) - { - return $bbcode_class->bbcode_img($match[1]); - } - )), - 'size' => array('bbcode_id' => BBCODE_ID_SIZE, 'regexp' => array('#\[size=([\-\+]?\d+)\](.*?)\[/size\]#uis' => function ($match) use($bbcode_class) - { - return $bbcode_class->bbcode_size($match[1], $match[2]); - } - )), - 'color' => array('bbcode_id' => BBCODE_ID_COLOR, 'regexp' => array('!\[color=(#[0-9a-f]{3}|#[0-9a-f]{6}|[a-z\-]+)\](.*?)\[/color\]!uis' => function ($match) use($bbcode_class) - { - return $bbcode_class->bbcode_color($match[1], $match[2]); - } - )), - 'u' => array('bbcode_id' => BBCODE_ID_U, 'regexp' => array('#\[u\](.*?)\[/u\]#uis' => function ($match) use($bbcode_class) - { - return $bbcode_class->bbcode_underline($match[1]); - } - )), - 'list' => array('bbcode_id' => BBCODE_ID_LIST, 'regexp' => array('#\[list(?:=(?:[a-z0-9]|disc|circle|square))?].*\[/list]#uis' => function ($match) use($bbcode_class) - { - return $bbcode_class->bbcode_parse_list($match[0]); - } - )), - 'email' => array('bbcode_id' => BBCODE_ID_EMAIL, 'regexp' => array('#\[email=?(.*?)?\](.*?)\[/email\]#uis' => function ($match) use($bbcode_class) - { - return $bbcode_class->validate_email($match[1], $match[2]); - } - )), - 'flash' => array('bbcode_id' => BBCODE_ID_FLASH, 'regexp' => array('#\[flash=([0-9]+),([0-9]+)\](.*?)\[/flash\]#ui' => function ($match) use($bbcode_class) - { - return $bbcode_class->bbcode_flash($match[1], $match[2], $match[3]); - } - )) - ); - - // Zero the parsed items array - $this->parsed_items = array(); - - foreach ($this->bbcodes as $tag => $bbcode_data) - { - $this->parsed_items[$tag] = 0; - } - - if (!$allow_custom_bbcode) - { - return; - } - - if (!is_array($rowset)) - { - global $db; - $rowset = array(); - - $sql = 'SELECT * - FROM ' . BBCODES_TABLE; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $rowset[] = $row; - } - $db->sql_freeresult($result); - } - - foreach ($rowset as $row) - { - $this->bbcodes[$row['bbcode_tag']] = array( - 'bbcode_id' => (int) $row['bbcode_id'], - 'regexp' => array($row['first_pass_match'] => str_replace('$uid', $this->bbcode_uid, $row['first_pass_replace'])) - ); - } - - $bbcodes = $this->bbcodes; - - /** - * Event to modify the bbcode data for later parsing - * - * @event core.modify_bbcode_init - * @var array bbcodes Array of bbcode data for use in parsing - * @var array rowset Array of bbcode data from the database - * @since 3.1.0-a3 - */ - $vars = array('bbcodes', 'rowset'); - extract($phpbb_dispatcher->trigger_event('core.modify_bbcode_init', compact($vars))); - - $this->bbcodes = $bbcodes; - } - - /** - * Making some pre-checks for bbcodes as well as increasing the number of parsed items - */ - function check_bbcode($bbcode, &$in) - { - // when using the /e modifier, preg_replace slashes double-quotes but does not - // seem to slash anything else - $in = str_replace("\r\n", "\n", str_replace('\"', '"', $in)); - - // Trimming here to make sure no empty bbcodes are parsed accidently - if (trim($in) == '') - { - return false; - } - - $this->parsed_items[$bbcode]++; - - return true; - } - - /** - * Transform some characters in valid bbcodes - */ - function bbcode_specialchars($text) - { - $str_from = array('<', '>', '[', ']', '.', ':'); - $str_to = array('<', '>', '[', ']', '.', ':'); - - return str_replace($str_from, $str_to, $text); - } - - /** - * Parse size tag - */ - function bbcode_size($stx, $in) - { - global $user, $config; - - if (!$this->check_bbcode('size', $in)) - { - return $in; - } - - if ($config['max_' . $this->mode . '_font_size'] && $config['max_' . $this->mode . '_font_size'] < $stx) - { - $this->warn_msg[] = $user->lang('MAX_FONT_SIZE_EXCEEDED', (int) $config['max_' . $this->mode . '_font_size']); - - return '[size=' . $stx . ']' . $in . '[/size]'; - } - - // Do not allow size=0 - if ($stx <= 0) - { - return '[size=' . $stx . ']' . $in . '[/size]'; - } - - return '[size=' . $stx . ':' . $this->bbcode_uid . ']' . $in . '[/size:' . $this->bbcode_uid . ']'; - } - - /** - * Parse color tag - */ - function bbcode_color($stx, $in) - { - if (!$this->check_bbcode('color', $in)) - { - return $in; - } - - return '[color=' . $stx . ':' . $this->bbcode_uid . ']' . $in . '[/color:' . $this->bbcode_uid . ']'; - } - - /** - * Parse u tag - */ - function bbcode_underline($in) - { - if (!$this->check_bbcode('u', $in)) - { - return $in; - } - - return '[u:' . $this->bbcode_uid . ']' . $in . '[/u:' . $this->bbcode_uid . ']'; - } - - /** - * Parse b tag - */ - function bbcode_strong($in) - { - if (!$this->check_bbcode('b', $in)) - { - return $in; - } - - return '[b:' . $this->bbcode_uid . ']' . $in . '[/b:' . $this->bbcode_uid . ']'; - } - - /** - * Parse i tag - */ - function bbcode_italic($in) - { - if (!$this->check_bbcode('i', $in)) - { - return $in; - } - - return '[i:' . $this->bbcode_uid . ']' . $in . '[/i:' . $this->bbcode_uid . ']'; - } - - /** - * Parse img tag - */ - function bbcode_img($in) - { - global $user, $config; - - if (!$this->check_bbcode('img', $in)) - { - return $in; - } - - $in = trim($in); - $error = false; - - $in = str_replace(' ', '%20', $in); - - // Checking urls - if (!preg_match('#^' . get_preg_expression('url') . '$#iu', $in) && !preg_match('#^' . get_preg_expression('www_url') . '$#iu', $in)) - { - return '[img]' . $in . '[/img]'; - } - - // Try to cope with a common user error... not specifying a protocol but only a subdomain - if (!preg_match('#^[a-z0-9]+://#i', $in)) - { - $in = 'http://' . $in; - } - - if ($config['max_' . $this->mode . '_img_height'] || $config['max_' . $this->mode . '_img_width']) - { - $imagesize = new \FastImageSize\FastImageSize(); - $size_info = $imagesize->getImageSize(htmlspecialchars_decode($in)); - - if ($size_info === false) - { - $error = true; - $this->warn_msg[] = $user->lang['UNABLE_GET_IMAGE_SIZE']; - } - else - { - if ($config['max_' . $this->mode . '_img_height'] && $config['max_' . $this->mode . '_img_height'] < $size_info['height']) - { - $error = true; - $this->warn_msg[] = $user->lang('MAX_IMG_HEIGHT_EXCEEDED', (int) $config['max_' . $this->mode . '_img_height']); - } - - if ($config['max_' . $this->mode . '_img_width'] && $config['max_' . $this->mode . '_img_width'] < $size_info['width']) - { - $error = true; - $this->warn_msg[] = $user->lang('MAX_IMG_WIDTH_EXCEEDED', (int) $config['max_' . $this->mode . '_img_width']); - } - } - } - - if ($error || $this->path_in_domain($in)) - { - return '[img]' . $in . '[/img]'; - } - - return '[img:' . $this->bbcode_uid . ']' . $this->bbcode_specialchars($in) . '[/img:' . $this->bbcode_uid . ']'; - } - - /** - * Parse flash tag - */ - function bbcode_flash($width, $height, $in) - { - global $user, $config; - - if (!$this->check_bbcode('flash', $in)) - { - return $in; - } - - $in = trim($in); - $error = false; - - // Do not allow 0-sizes generally being entered - if ($width <= 0 || $height <= 0) - { - return '[flash=' . $width . ',' . $height . ']' . $in . '[/flash]'; - } - - $in = str_replace(' ', '%20', $in); - - // Make sure $in is a URL. - if (!preg_match('#^' . get_preg_expression('url') . '$#iu', $in) && - !preg_match('#^' . get_preg_expression('www_url') . '$#iu', $in)) - { - return '[flash=' . $width . ',' . $height . ']' . $in . '[/flash]'; - } - - // Apply the same size checks on flash files as on images - if ($config['max_' . $this->mode . '_img_height'] || $config['max_' . $this->mode . '_img_width']) - { - if ($config['max_' . $this->mode . '_img_height'] && $config['max_' . $this->mode . '_img_height'] < $height) - { - $error = true; - $this->warn_msg[] = $user->lang('MAX_FLASH_HEIGHT_EXCEEDED', (int) $config['max_' . $this->mode . '_img_height']); - } - - if ($config['max_' . $this->mode . '_img_width'] && $config['max_' . $this->mode . '_img_width'] < $width) - { - $error = true; - $this->warn_msg[] = $user->lang('MAX_FLASH_WIDTH_EXCEEDED', (int) $config['max_' . $this->mode . '_img_width']); - } - } - - if ($error || $this->path_in_domain($in)) - { - return '[flash=' . $width . ',' . $height . ']' . $in . '[/flash]'; - } - - return '[flash=' . $width . ',' . $height . ':' . $this->bbcode_uid . ']' . $this->bbcode_specialchars($in) . '[/flash:' . $this->bbcode_uid . ']'; - } - - /** - * Parse inline attachments [ia] - */ - function bbcode_attachment($stx, $in) - { - if (!$this->check_bbcode('attachment', $in)) - { - return $in; - } - - return '[attachment=' . $stx . ':' . $this->bbcode_uid . ']' . trim($in) . '[/attachment:' . $this->bbcode_uid . ']'; - } - - /** - * Parse code text from code tag - * @access private - */ - function bbcode_parse_code($stx, &$code) - { - switch (strtolower($stx)) - { - case 'php': - - $remove_tags = false; - - $str_from = array('<', '>', '[', ']', '.', ':', ':'); - $str_to = array('<', '>', '[', ']', '.', ':', ':'); - $code = str_replace($str_from, $str_to, $code); - - if (!preg_match('/\<\?.*?\?\>/is', $code)) - { - $remove_tags = true; - $code = ""; - } - - $conf = array('highlight.bg', 'highlight.comment', 'highlight.default', 'highlight.html', 'highlight.keyword', 'highlight.string'); - foreach ($conf as $ini_var) - { - @ini_set($ini_var, str_replace('highlight.', 'syntax', $ini_var)); - } - - // Because highlight_string is specialcharing the text (but we already did this before), we have to reverse this in order to get correct results - $code = htmlspecialchars_decode($code); - $code = highlight_string($code, true); - - $str_from = array('', '', '','[', ']', '.', ':'); - $str_to = array('', '', '', '[', ']', '.', ':'); - - if ($remove_tags) - { - $str_from[] = '<?php '; - $str_to[] = ''; - $str_from[] = '<?php '; - $str_to[] = ''; - } - - $code = str_replace($str_from, $str_to, $code); - $code = preg_replace('#^()\n?(.*?)\n?()$#is', '$1$2$3', $code); - - if ($remove_tags) - { - $code = preg_replace('#()?\?>()#', '$1 $2', $code); - } - - $code = preg_replace('#^(.*)#s', '$2', $code); - $code = preg_replace('#(?:\s++| )*+$#u', '', $code); - - // remove newline at the end - if (!empty($code) && substr($code, -1) == "\n") - { - $code = substr($code, 0, -1); - } - - return "[code=$stx:" . $this->bbcode_uid . ']' . $code . '[/code:' . $this->bbcode_uid . ']'; - break; - - default: - return '[code:' . $this->bbcode_uid . ']' . $this->bbcode_specialchars($code) . '[/code:' . $this->bbcode_uid . ']'; - break; - } - } - - /** - * Parse code tag - * Expects the argument to start right after the opening [code] tag and to end with [/code] - */ - function bbcode_code($stx, $in) - { - if (!$this->check_bbcode('code', $in)) - { - return $in; - } - - // We remove the hardcoded elements from the code block here because it is not used in code blocks - // Having it here saves us one preg_replace per message containing [code] blocks - // Additionally, magic url parsing should go after parsing bbcodes, but for safety those are stripped out too... - $htm_match = get_preg_expression('bbcode_htm'); - unset($htm_match[4], $htm_match[5]); - $htm_replace = array('\1', '\1', '\2', '\1'); - - $out = $code_block = ''; - $open = 1; - - while ($in) - { - // Determine position and tag length of next code block - preg_match('#(.*?)(\[code(?:=([a-z]+))?\])(.+)#is', $in, $buffer); - $pos = (isset($buffer[1])) ? strlen($buffer[1]) : false; - $tag_length = (isset($buffer[2])) ? strlen($buffer[2]) : false; - - // Determine position of ending code tag - $pos2 = stripos($in, '[/code]'); - - // Which is the next block, ending code or code block - if ($pos !== false && $pos < $pos2) - { - // Open new block - if (!$open) - { - $out .= substr($in, 0, $pos); - $in = substr($in, $pos); - $stx = (isset($buffer[3])) ? $buffer[3] : ''; - $code_block = ''; - } - else - { - // Already opened block, just append to the current block - $code_block .= substr($in, 0, $pos) . ((isset($buffer[2])) ? $buffer[2] : ''); - $in = substr($in, $pos); - } - - $in = substr($in, $tag_length); - $open++; - } - else - { - // Close the block - if ($open == 1) - { - $code_block .= substr($in, 0, $pos2); - $code_block = preg_replace($htm_match, $htm_replace, $code_block); - - // Parse this code block - $out .= $this->bbcode_parse_code($stx, $code_block); - $code_block = ''; - $open--; - } - else if ($open) - { - // Close one open tag... add to the current code block - $code_block .= substr($in, 0, $pos2 + 7); - $open--; - } - else - { - // end code without opening code... will be always outside code block - $out .= substr($in, 0, $pos2 + 7); - } - - $in = substr($in, $pos2 + 7); - } - } - - // if now $code_block has contents we need to parse the remaining code while removing the last closing tag to match up. - if ($code_block) - { - $code_block = substr($code_block, 0, -7); - $code_block = preg_replace($htm_match, $htm_replace, $code_block); - - $out .= $this->bbcode_parse_code($stx, $code_block); - } - - return $out; - } - - /** - * Parse list bbcode - * Expects the argument to start with a tag - */ - function bbcode_parse_list($in) - { - if (!$this->check_bbcode('list', $in)) - { - return $in; - } - - // $tok holds characters to stop at. Since the string starts with a '[' we'll get everything up to the first ']' which should be the opening [list] tag - $tok = ']'; - $out = '['; - - // First character is [ - $in = substr($in, 1); - $list_end_tags = $item_end_tags = array(); - - do - { - $pos = strlen($in); - - for ($i = 0, $tok_len = strlen($tok); $i < $tok_len; ++$i) - { - $tmp_pos = strpos($in, $tok[$i]); - - if ($tmp_pos !== false && $tmp_pos < $pos) - { - $pos = $tmp_pos; - } - } - - $buffer = substr($in, 0, $pos); - $tok = $in[$pos]; - - $in = substr($in, $pos + 1); - - if ($tok == ']') - { - // if $tok is ']' the buffer holds a tag - if (strtolower($buffer) == '/list' && count($list_end_tags)) - { - // valid [/list] tag, check nesting so that we don't hit false positives - if (count($item_end_tags) && count($item_end_tags) >= count($list_end_tags)) - { - // current li tag has not been closed - $out = preg_replace('/\n?\[$/', '[', $out) . array_pop($item_end_tags) . ']['; - } - - $out .= array_pop($list_end_tags) . ']'; - $tok = '['; - } - else if (preg_match('#^list(=[0-9a-z]+)?$#i', $buffer, $m)) - { - // sub-list, add a closing tag - if (empty($m[1]) || preg_match('/^=(?:disc|square|circle)$/i', $m[1])) - { - array_push($list_end_tags, '/list:u:' . $this->bbcode_uid); - } - else - { - array_push($list_end_tags, '/list:o:' . $this->bbcode_uid); - } - $out .= 'list' . substr($buffer, 4) . ':' . $this->bbcode_uid . ']'; - $tok = '['; - } - else - { - if (($buffer == '*' || substr($buffer, -2) == '[*') && count($list_end_tags)) - { - // the buffer holds a bullet tag and we have a [list] tag open - if (count($item_end_tags) >= count($list_end_tags)) - { - if (substr($buffer, -2) == '[*') - { - $out .= substr($buffer, 0, -2) . '['; - } - // current li tag has not been closed - if (preg_match('/\n\[$/', $out, $m)) - { - $out = preg_replace('/\n\[$/', '[', $out); - $buffer = array_pop($item_end_tags) . "]\n[*:" . $this->bbcode_uid; - } - else - { - $buffer = array_pop($item_end_tags) . '][*:' . $this->bbcode_uid; - } - } - else - { - $buffer = '*:' . $this->bbcode_uid; - } - - $item_end_tags[] = '/*:m:' . $this->bbcode_uid; - } - else if ($buffer == '/*') - { - array_pop($item_end_tags); - $buffer = '/*:' . $this->bbcode_uid; - } - - $out .= $buffer . $tok; - $tok = '[]'; - } - } - else - { - // Not within a tag, just add buffer to the return string - $out .= $buffer . $tok; - $tok = ($tok == '[') ? ']' : '[]'; - } - } - while ($in); - - // do we have some tags open? close them now - if (count($item_end_tags)) - { - $out .= '[' . implode('][', $item_end_tags) . ']'; - } - if (count($list_end_tags)) - { - $out .= '[' . implode('][', $list_end_tags) . ']'; - } - - return $out; - } - - /** - * Parse quote bbcode - * Expects the argument to start with a tag - */ - function bbcode_quote($in) - { - $in = str_replace("\r\n", "\n", str_replace('\"', '"', trim($in))); - - if (!$in) - { - return ''; - } - - // To let the parser not catch tokens within quote_username quotes we encode them before we start this... - $in = preg_replace_callback('#quote="(.*?)"\]#i', function ($match) { - return 'quote="' . str_replace(array('[', ']', '\\\"'), array('[', ']', '\"'), $match[1]) . '"]'; - }, $in); - - $tok = ']'; - $out = '['; - - $in = substr($in, 1); - $close_tags = $error_ary = array(); - $buffer = ''; - - do - { - $pos = strlen($in); - for ($i = 0, $tok_len = strlen($tok); $i < $tok_len; ++$i) - { - $tmp_pos = strpos($in, $tok[$i]); - if ($tmp_pos !== false && $tmp_pos < $pos) - { - $pos = $tmp_pos; - } - } - - $buffer .= substr($in, 0, $pos); - $tok = $in[$pos]; - $in = substr($in, $pos + 1); - - if ($tok == ']') - { - if (strtolower($buffer) == '/quote' && count($close_tags) && substr($out, -1, 1) == '[') - { - // we have found a closing tag - $out .= array_pop($close_tags) . ']'; - $tok = '['; - $buffer = ''; - - /* Add space at the end of the closing tag if not happened before to allow following urls/smilies to be parsed correctly - * Do not try to think for the user. :/ Do not parse urls/smilies if there is no space - is the same as with other bbcodes too. - * Also, we won't have any spaces within $in anyway, only adding up spaces -> #10982 - if (!$in || $in[0] !== ' ') - { - $out .= ' '; - }*/ - } - else if (preg_match('#^quote(?:="(.*?)")?$#is', $buffer, $m) && substr($out, -1, 1) == '[') - { - $this->parsed_items['quote']++; - array_push($close_tags, '/quote:' . $this->bbcode_uid); - - if (isset($m[1]) && $m[1]) - { - $username = str_replace(array('[', ']'), array('[', ']'), $m[1]); - $username = preg_replace('#\[(?!b|i|u|color|url|email|/b|/i|/u|/color|/url|/email)#iU', '[$1', $username); - - $end_tags = array(); - $error = false; - - preg_match_all('#\[((?:/)?(?:[a-z]+))#i', $username, $tags); - foreach ($tags[1] as $tag) - { - if ($tag[0] != '/') - { - $end_tags[] = '/' . $tag; - } - else - { - $end_tag = array_pop($end_tags); - $error = ($end_tag != $tag) ? true : false; - } - } - - if ($error) - { - $username = $m[1]; - } - - $out .= 'quote="' . $username . '":' . $this->bbcode_uid . ']'; - } - else - { - $out .= 'quote:' . $this->bbcode_uid . ']'; - } - - $tok = '['; - $buffer = ''; - } - else if (preg_match('#^quote="(.*?)#is', $buffer, $m)) - { - // the buffer holds an invalid opening tag - $buffer .= ']'; - } - else - { - $out .= $buffer . $tok; - $tok = '[]'; - $buffer = ''; - } - } - else - { -/** -* Old quote code working fine, but having errors listed in bug #3572 -* -* $out .= $buffer . $tok; -* $tok = ($tok == '[') ? ']' : '[]'; -* $buffer = ''; -*/ - - $out .= $buffer . $tok; - - if ($tok == '[') - { - // Search the text for the next tok... if an ending quote comes first, then change tok to [] - $pos1 = stripos($in, '[/quote'); - // If the token ] comes first, we change it to ] - $pos2 = strpos($in, ']'); - // If the token [ comes first, we change it to [ - $pos3 = strpos($in, '['); - - if ($pos1 !== false && ($pos2 === false || $pos1 < $pos2) && ($pos3 === false || $pos1 < $pos3)) - { - $tok = '[]'; - } - else if ($pos3 !== false && ($pos2 === false || $pos3 < $pos2)) - { - $tok = '['; - } - else - { - $tok = ']'; - } - } - else - { - $tok = '[]'; - } - $buffer = ''; - } - } - while ($in); - - $out .= $buffer; - - if (count($close_tags)) - { - $out .= '[' . implode('][', $close_tags) . ']'; - } - - foreach ($error_ary as $error_msg) - { - $this->warn_msg[] = $error_msg; - } - - return $out; - } - - /** - * Validate email - */ - function validate_email($var1, $var2) - { - $var1 = str_replace("\r\n", "\n", str_replace('\"', '"', trim($var1))); - $var2 = str_replace("\r\n", "\n", str_replace('\"', '"', trim($var2))); - - $txt = $var2; - $email = ($var1) ? $var1 : $var2; - - $validated = true; - - if (!preg_match('/^' . get_preg_expression('email') . '$/i', $email)) - { - $validated = false; - } - - if (!$validated) - { - return '[email' . (($var1) ? "=$var1" : '') . ']' . $var2 . '[/email]'; - } - - $this->parsed_items['email']++; - - if ($var1) - { - $retval = '[email=' . $this->bbcode_specialchars($email) . ':' . $this->bbcode_uid . ']' . $txt . '[/email:' . $this->bbcode_uid . ']'; - } - else - { - $retval = '[email:' . $this->bbcode_uid . ']' . $this->bbcode_specialchars($email) . '[/email:' . $this->bbcode_uid . ']'; - } - - return $retval; - } - - /** - * Validate url - * - * @param string $var1 optional url parameter for url bbcode: [url(=$var1)]$var2[/url] - * @param string $var2 url bbcode content: [url(=$var1)]$var2[/url] - */ - function validate_url($var1, $var2) - { - $var1 = str_replace("\r\n", "\n", str_replace('\"', '"', trim($var1))); - $var2 = str_replace("\r\n", "\n", str_replace('\"', '"', trim($var2))); - - $url = ($var1) ? $var1 : $var2; - - if ($var1 && !$var2) - { - $var2 = $var1; - } - - if (!$url) - { - return '[url' . (($var1) ? '=' . $var1 : '') . ']' . $var2 . '[/url]'; - } - - $valid = false; - - $url = str_replace(' ', '%20', $url); - - // Checking urls - if (preg_match('#^' . get_preg_expression('url') . '$#iu', $url) || - preg_match('#^' . get_preg_expression('www_url') . '$#iu', $url) || - preg_match('#^' . preg_quote(generate_board_url(), '#') . get_preg_expression('relative_url') . '$#iu', $url)) - { - $valid = true; - } - - if ($valid) - { - $this->parsed_items['url']++; - - // if there is no scheme, then add http schema - if (!preg_match('#^[a-z][a-z\d+\-.]*:/{2}#i', $url)) - { - $url = 'http://' . $url; - } - - // Is this a link to somewhere inside this board? If so then remove the session id from the url - if (strpos($url, generate_board_url()) !== false && strpos($url, 'sid=') !== false) - { - $url = preg_replace('/(&|\?)sid=[0-9a-f]{32}&/', '\1', $url); - $url = preg_replace('/(&|\?)sid=[0-9a-f]{32}$/', '', $url); - $url = append_sid($url); - } - - return ($var1) ? '[url=' . $this->bbcode_specialchars($url) . ':' . $this->bbcode_uid . ']' . $var2 . '[/url:' . $this->bbcode_uid . ']' : '[url:' . $this->bbcode_uid . ']' . $this->bbcode_specialchars($url) . '[/url:' . $this->bbcode_uid . ']'; - } - - return '[url' . (($var1) ? '=' . $var1 : '') . ']' . $var2 . '[/url]'; - } - - /** - * Check if url is pointing to this domain/script_path/php-file - * - * @param string $url the url to check - * @return true if the url is pointing to this domain/script_path/php-file, false if not - * - * @access private - */ - function path_in_domain($url) - { - global $config, $phpEx, $user; - - if ($config['force_server_vars']) - { - $check_path = !empty($config['script_path']) ? $config['script_path'] : '/'; - } - else - { - $check_path = ($user->page['root_script_path'] != '/') ? substr($user->page['root_script_path'], 0, -1) : '/'; - } - - // Is the user trying to link to a php file in this domain and script path? - if (strpos($url, ".{$phpEx}") !== false && strpos($url, $check_path) !== false) - { - $server_name = $user->host; - - // Forcing server vars is the only way to specify/override the protocol - if ($config['force_server_vars'] || !$server_name) - { - $server_name = $config['server_name']; - } - - // Check again in correct order... - $pos_ext = strpos($url, ".{$phpEx}"); - $pos_path = strpos($url, $check_path); - $pos_domain = strpos($url, $server_name); - - if ($pos_domain !== false && $pos_path >= $pos_domain && $pos_ext >= $pos_path) - { - // Ok, actually we allow linking to some files (this may be able to be extended in some way later...) - if (strpos($url, '/' . $check_path . '/download/file.' . $phpEx) !== 0) - { - return false; - } - - return true; - } - } - - return false; - } -} - -/** -* Main message parser for posting, pm, etc. takes raw message -* and parses it for attachments, bbcode and smilies -*/ -class parse_message extends bbcode_firstpass -{ - var $attachment_data = array(); - var $filename_data = array(); - - // Helps ironing out user error - var $message_status = ''; - - var $allow_img_bbcode = true; - var $allow_flash_bbcode = true; - var $allow_quote_bbcode = true; - var $allow_url_bbcode = true; - - /** - * The plupload object used for dealing with attachments - * @var \phpbb\plupload\plupload - */ - protected $plupload; - - /** - * Init - give message here or manually - */ - function __construct($message = '') - { - // Init BBCode UID - $this->bbcode_uid = substr(base_convert(unique_id(), 16, 36), 0, BBCODE_UID_LEN); - $this->message = $message; - } - - /** - * Parse Message - */ - function parse($allow_bbcode, $allow_magic_url, $allow_smilies, $allow_img_bbcode = true, $allow_flash_bbcode = true, $allow_quote_bbcode = true, $allow_url_bbcode = true, $update_this_message = true, $mode = 'post') - { - global $config, $user, $phpbb_dispatcher, $phpbb_container; - - $this->mode = $mode; - - foreach (array('chars', 'smilies', 'urls', 'font_size', 'img_height', 'img_width') as $key) - { - if (!isset($config['max_' . $mode . '_' . $key])) - { - $config['max_' . $mode . '_' . $key] = 0; - } - } - - $this->allow_img_bbcode = $allow_img_bbcode; - $this->allow_flash_bbcode = $allow_flash_bbcode; - $this->allow_quote_bbcode = $allow_quote_bbcode; - $this->allow_url_bbcode = $allow_url_bbcode; - - // If false, then $this->message won't be altered, the text will be returned instead. - if (!$update_this_message) - { - $tmp_message = $this->message; - $return_message = &$this->message; - } - - if ($this->message_status == 'display') - { - $this->decode_message(); - } - - // Store message length... - $message_length = ($mode == 'post') ? utf8_strlen($this->message) : utf8_strlen(preg_replace('#\[\/?[a-z\*\+\-]+(=[\S]+)?\]#ius', ' ', $this->message)); - - // Maximum message length check. 0 disables this check completely. - if ((int) $config['max_' . $mode . '_chars'] > 0 && $message_length > (int) $config['max_' . $mode . '_chars']) - { - $this->warn_msg[] = $user->lang('CHARS_' . strtoupper($mode) . '_CONTAINS', $message_length) . '
' . $user->lang('TOO_MANY_CHARS_LIMIT', (int) $config['max_' . $mode . '_chars']); - return (!$update_this_message) ? $return_message : $this->warn_msg; - } - - // Minimum message length check for post only - if ($mode === 'post') - { - if (!$message_length || $message_length < (int) $config['min_post_chars']) - { - $this->warn_msg[] = (!$message_length) ? $user->lang['TOO_FEW_CHARS'] : ($user->lang('CHARS_POST_CONTAINS', $message_length) . '
' . $user->lang('TOO_FEW_CHARS_LIMIT', (int) $config['min_post_chars'])); - return (!$update_this_message) ? $return_message : $this->warn_msg; - } - } - - /** - * This event can be used for additional message checks/cleanup before parsing - * - * @event core.message_parser_check_message - * @var bool allow_bbcode Do we allow BBCodes - * @var bool allow_magic_url Do we allow magic urls - * @var bool allow_smilies Do we allow smilies - * @var bool allow_img_bbcode Do we allow image BBCode - * @var bool allow_flash_bbcode Do we allow flash BBCode - * @var bool allow_quote_bbcode Do we allow quote BBCode - * @var bool allow_url_bbcode Do we allow url BBCode - * @var bool update_this_message Do we alter the parsed message - * @var string mode Posting mode - * @var string message The message text to parse - * @var string bbcode_bitfield The bbcode_bitfield before parsing - * @var string bbcode_uid The bbcode_uid before parsing - * @var bool return Do we return after the event is triggered if $warn_msg is not empty - * @var array warn_msg Array of the warning messages - * @since 3.1.2-RC1 - * @changed 3.1.3-RC1 Added vars $bbcode_bitfield and $bbcode_uid - */ - $message = $this->message; - $warn_msg = $this->warn_msg; - $return = false; - $bbcode_bitfield = $this->bbcode_bitfield; - $bbcode_uid = $this->bbcode_uid; - $vars = array( - 'allow_bbcode', - 'allow_magic_url', - 'allow_smilies', - 'allow_img_bbcode', - 'allow_flash_bbcode', - 'allow_quote_bbcode', - 'allow_url_bbcode', - 'update_this_message', - 'mode', - 'message', - 'bbcode_bitfield', - 'bbcode_uid', - 'return', - 'warn_msg', - ); - extract($phpbb_dispatcher->trigger_event('core.message_parser_check_message', compact($vars))); - $this->message = $message; - $this->warn_msg = $warn_msg; - $this->bbcode_bitfield = $bbcode_bitfield; - $this->bbcode_uid = $bbcode_uid; - if ($return && !empty($this->warn_msg)) - { - return (!$update_this_message) ? $return_message : $this->warn_msg; - } - - // Get the parser - $parser = $phpbb_container->get('text_formatter.parser'); - - // Set the parser's options - ($allow_bbcode) ? $parser->enable_bbcodes() : $parser->disable_bbcodes(); - ($allow_magic_url) ? $parser->enable_magic_url() : $parser->disable_magic_url(); - ($allow_smilies) ? $parser->enable_smilies() : $parser->disable_smilies(); - ($allow_img_bbcode) ? $parser->enable_bbcode('img') : $parser->disable_bbcode('img'); - ($allow_flash_bbcode) ? $parser->enable_bbcode('flash') : $parser->disable_bbcode('flash'); - ($allow_quote_bbcode) ? $parser->enable_bbcode('quote') : $parser->disable_bbcode('quote'); - ($allow_url_bbcode) ? $parser->enable_bbcode('url') : $parser->disable_bbcode('url'); - - // Set some config values - $parser->set_vars(array( - 'max_font_size' => $config['max_' . $this->mode . '_font_size'], - 'max_img_height' => $config['max_' . $this->mode . '_img_height'], - 'max_img_width' => $config['max_' . $this->mode . '_img_width'], - 'max_smilies' => $config['max_' . $this->mode . '_smilies'], - 'max_urls' => $config['max_' . $this->mode . '_urls'] - )); - - // Parse this message - $this->message = $parser->parse(htmlspecialchars_decode($this->message, ENT_QUOTES)); - - // Remove quotes that are nested too deep - if ($config['max_quote_depth'] > 0) - { - $this->remove_nested_quotes($config['max_quote_depth']); - } - - // Check for "empty" message. We do not check here for maximum length, because bbcode, smilies, etc. can add to the length. - // The maximum length check happened before any parsings. - if ($mode === 'post' && utf8_clean_string($this->message) === '') - { - $this->warn_msg[] = $user->lang['TOO_FEW_CHARS']; - return (!$update_this_message) ? $return_message : $this->warn_msg; - } - - // Remove quotes that are nested too deep - if ($config['max_quote_depth'] > 0) - { - $this->message = $phpbb_container->get('text_formatter.utils')->remove_bbcode( - $this->message, - 'quote', - $config['max_quote_depth'] - ); - } - - // Check for errors - $errors = $parser->get_errors(); - if ($errors) - { - foreach ($errors as $i => $args) - { - // Translate each error with $user->lang() - $errors[$i] = call_user_func_array(array($user, 'lang'), $args); - } - $this->warn_msg = array_merge($this->warn_msg, $errors); - - return (!$update_this_message) ? $return_message : $this->warn_msg; - } - - if (!$update_this_message) - { - unset($this->message); - $this->message = $tmp_message; - return $return_message; - } - - $this->message_status = 'parsed'; - return false; - } - - /** - * Formatting text for display - */ - function format_display($allow_bbcode, $allow_magic_url, $allow_smilies, $update_this_message = true) - { - global $phpbb_container, $phpbb_dispatcher; - - // If false, then the parsed message get returned but internal message not processed. - if (!$update_this_message) - { - $tmp_message = $this->message; - $return_message = &$this->message; - } - - $text = $this->message; - $uid = $this->bbcode_uid; - - /** - * Event to modify the text before it is parsed - * - * @event core.modify_format_display_text_before - * @var string text The message text to parse - * @var string uid The bbcode uid - * @var bool allow_bbcode Do we allow bbcodes - * @var bool allow_magic_url Do we allow magic urls - * @var bool allow_smilies Do we allow smilies - * @var bool update_this_message Do we update the internal message - * with the parsed result - * @since 3.1.6-RC1 - */ - $vars = array('text', 'uid', 'allow_bbcode', 'allow_magic_url', 'allow_smilies', 'update_this_message'); - extract($phpbb_dispatcher->trigger_event('core.modify_format_display_text_before', compact($vars))); - - $this->message = $text; - $this->bbcode_uid = $uid; - unset($text, $uid); - - // NOTE: message_status is unreliable for detecting unparsed text because some callers - // change $this->message without resetting $this->message_status to 'plain' so we - // inspect the message instead - //if ($this->message_status == 'plain') - if (!preg_match('/^<[rt][ >]/', $this->message)) - { - // Force updating message - of course. - $this->parse($allow_bbcode, $allow_magic_url, $allow_smilies, $this->allow_img_bbcode, $this->allow_flash_bbcode, $this->allow_quote_bbcode, $this->allow_url_bbcode, true); - } - - // There's a bug when previewing a topic with no poll, because the empty title of the poll - // gets parsed but $this->message still ends up empty. This fixes it, until a proper fix is - // devised - if ($this->message === '') - { - $this->message = $phpbb_container->get('text_formatter.parser')->parse($this->message); - } - - $this->message = $phpbb_container->get('text_formatter.renderer')->render($this->message); - - $text = $this->message; - $uid = $this->bbcode_uid; - - /** - * Event to modify the text after it is parsed - * - * @event core.modify_format_display_text_after - * @var string text The message text to parse - * @var string uid The bbcode uid - * @var bool allow_bbcode Do we allow bbcodes - * @var bool allow_magic_url Do we allow magic urls - * @var bool allow_smilies Do we allow smilies - * @var bool update_this_message Do we update the internal message - * with the parsed result - * @since 3.1.0-a3 - */ - $vars = array('text', 'uid', 'allow_bbcode', 'allow_magic_url', 'allow_smilies', 'update_this_message'); - extract($phpbb_dispatcher->trigger_event('core.modify_format_display_text_after', compact($vars))); - - $this->message = $text; - $this->bbcode_uid = $uid; - - if (!$update_this_message) - { - unset($this->message); - $this->message = $tmp_message; - return $return_message; - } - - $this->message_status = 'display'; - return false; - } - - /** - * Decode message to be placed back into form box - */ - function decode_message($custom_bbcode_uid = '', $update_this_message = true) - { - // If false, then the parsed message get returned but internal message not processed. - if (!$update_this_message) - { - $tmp_message = $this->message; - $return_message = &$this->message; - } - - ($custom_bbcode_uid) ? decode_message($this->message, $custom_bbcode_uid) : decode_message($this->message, $this->bbcode_uid); - - if (!$update_this_message) - { - unset($this->message); - $this->message = $tmp_message; - return $return_message; - } - - $this->message_status = 'plain'; - return false; - } - - /** - * Replace magic urls of form http://xxx.xxx., www.xxx. and xxx@xxx.xxx. - * Cuts down displayed size of link if over 50 chars, turns absolute links - * into relative versions when the server/script path matches the link - */ - function magic_url($server_url) - { - // We use the global make_clickable function - $this->message = make_clickable($this->message, $server_url); - } - - /** - * Parse Smilies - */ - function smilies($max_smilies = 0) - { - global $db, $user; - static $match; - static $replace; - - // See if the static arrays have already been filled on an earlier invocation - if (!is_array($match)) - { - $match = $replace = array(); - - // NOTE: obtain_* function? chaching the table contents? - - // For now setting the ttl to 10 minutes - switch ($db->get_sql_layer()) - { - case 'mssql_odbc': - case 'mssqlnative': - $sql = 'SELECT * - FROM ' . SMILIES_TABLE . ' - ORDER BY LEN(code) DESC'; - break; - - // LENGTH supported by MySQL, IBM DB2, Oracle and Access for sure... - default: - $sql = 'SELECT * - FROM ' . SMILIES_TABLE . ' - ORDER BY LENGTH(code) DESC'; - break; - } - $result = $db->sql_query($sql, 600); - - while ($row = $db->sql_fetchrow($result)) - { - if (empty($row['code'])) - { - continue; - } - - // (assertion) - $match[] = preg_quote($row['code'], '#'); - $replace[] = '' . $row['code'] . ''; - } - $db->sql_freeresult($result); - } - - if (count($match)) - { - if ($max_smilies) - { - // 'u' modifier has been added to correctly parse smilies within unicode strings - // For details: http://tracker.phpbb.com/browse/PHPBB3-10117 - $num_matches = preg_match_all('#(?<=^|[\n .])(?:' . implode('|', $match) . ')(?![^<>]*>)#u', $this->message, $matches); - unset($matches); - - if ($num_matches !== false && $num_matches > $max_smilies) - { - $this->warn_msg[] = sprintf($user->lang['TOO_MANY_SMILIES'], $max_smilies); - return; - } - } - - // Make sure the delimiter # is added in front and at the end of every element within $match - // 'u' modifier has been added to correctly parse smilies within unicode strings - // For details: http://tracker.phpbb.com/browse/PHPBB3-10117 - - $this->message = trim(preg_replace(explode(chr(0), '#(?<=^|[\n .])' . implode('(?![^<>]*>)#u' . chr(0) . '#(?<=^|[\n .])', $match) . '(?![^<>]*>)#u'), $replace, $this->message)); - } - } - - /** - * Check attachment form token depending on submit type - * - * @param \phpbb\language\language $language Language - * @param \phpbb\request\request_interface $request Request - * @param string $form_name Form name for checking form key - * - * @return bool True if form token is not needed or valid, false if needed and invalid - */ - function check_attachment_form_token(\phpbb\language\language $language, \phpbb\request\request_interface $request, $form_name) - { - $add_file = $request->is_set_post('add_file'); - $delete_file = $request->is_set_post('delete_file'); - - if (($add_file || $delete_file) && !check_form_key($form_name)) - { - $this->warn_msg[] = $language->lang('FORM_INVALID'); - - if ($request->is_ajax() && $this->plupload) - { - $this->plupload->emit_error(-400, 'FORM_INVALID'); - } - - return false; - } - - return true; - } - - /** - * Parse Attachments - */ - function parse_attachments($form_name, $mode, $forum_id, $submit, $preview, $refresh, $is_message = false) - { - global $config, $auth, $user, $phpbb_root_path, $phpEx, $db, $request; - global $phpbb_container, $phpbb_dispatcher; - - $error = array(); - - $num_attachments = count($this->attachment_data); - $this->filename_data['filecomment'] = $request->variable('filecomment', '', true); - $upload = $request->file($form_name); - $upload_file = (!empty($upload) && $upload['name'] !== 'none' && trim($upload['name'])); - - $add_file = (isset($_POST['add_file'])) ? true : false; - $delete_file = (isset($_POST['delete_file'])) ? true : false; - - // First of all adjust comments if changed - $actual_comment_list = $request->variable('comment_list', array(''), true); - - foreach ($actual_comment_list as $comment_key => $comment) - { - if (!isset($this->attachment_data[$comment_key])) - { - continue; - } - - if ($this->attachment_data[$comment_key]['attach_comment'] != $actual_comment_list[$comment_key]) - { - $this->attachment_data[$comment_key]['attach_comment'] = $actual_comment_list[$comment_key]; - } - } - - $cfg = array(); - $cfg['max_attachments'] = ($is_message) ? $config['max_attachments_pm'] : $config['max_attachments']; - $forum_id = ($is_message) ? 0 : $forum_id; - - if ($submit && in_array($mode, array('post', 'reply', 'quote', 'edit')) && $upload_file) - { - if ($num_attachments < $cfg['max_attachments'] || $auth->acl_get('a_') || $auth->acl_get('m_', $forum_id)) - { - /** @var \phpbb\attachment\manager $attachment_manager */ - $attachment_manager = $phpbb_container->get('attachment.manager'); - $filedata = $attachment_manager->upload($form_name, $forum_id, false, '', $is_message); - $error = $filedata['error']; - - if ($filedata['post_attach'] && !count($error)) - { - $sql_ary = array( - 'physical_filename' => $filedata['physical_filename'], - 'attach_comment' => $this->filename_data['filecomment'], - 'real_filename' => $filedata['real_filename'], - 'extension' => $filedata['extension'], - 'mimetype' => $filedata['mimetype'], - 'filesize' => $filedata['filesize'], - 'filetime' => $filedata['filetime'], - 'thumbnail' => $filedata['thumbnail'], - 'is_orphan' => 1, - 'in_message' => ($is_message) ? 1 : 0, - 'poster_id' => $user->data['user_id'], - ); - - /** - * Modify attachment sql array on submit - * - * @event core.modify_attachment_sql_ary_on_submit - * @var array sql_ary Array containing SQL data - * @since 3.2.6-RC1 - */ - $vars = array('sql_ary'); - extract($phpbb_dispatcher->trigger_event('core.modify_attachment_sql_ary_on_submit', compact($vars))); - - $db->sql_query('INSERT INTO ' . ATTACHMENTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); - - $new_entry = array( - 'attach_id' => $db->sql_nextid(), - 'is_orphan' => 1, - 'real_filename' => $filedata['real_filename'], - 'attach_comment'=> $this->filename_data['filecomment'], - 'filesize' => $filedata['filesize'], - ); - - $this->attachment_data = array_merge(array(0 => $new_entry), $this->attachment_data); - - /** - * Modify attachment data on submit - * - * @event core.modify_attachment_data_on_submit - * @var array attachment_data Array containing attachment data - * @since 3.2.2-RC1 - */ - $attachment_data = $this->attachment_data; - $vars = array('attachment_data'); - extract($phpbb_dispatcher->trigger_event('core.modify_attachment_data_on_submit', compact($vars))); - $this->attachment_data = $attachment_data; - unset($attachment_data); - - $this->message = preg_replace_callback('#\[attachment=([0-9]+)\](.*?)\[\/attachment\]#', function ($match) { - return '[attachment='.($match[1] + 1).']' . $match[2] . '[/attachment]'; - }, $this->message); - - $this->filename_data['filecomment'] = ''; - - // This Variable is set to false here, because Attachments are entered into the - // Database in two modes, one if the id_list is 0 and the second one if post_attach is true - // Since post_attach is automatically switched to true if an Attachment got added to the filesystem, - // but we are assigning an id of 0 here, we have to reset the post_attach variable to false. - // - // This is very relevant, because it could happen that the post got not submitted, but we do not - // know this circumstance here. We could be at the posting page or we could be redirected to the entered - // post. :) - $filedata['post_attach'] = false; - } - } - else - { - $error[] = $user->lang('TOO_MANY_ATTACHMENTS', (int) $cfg['max_attachments']); - } - } - - if ($preview || $refresh || count($error)) - { - if (isset($this->plupload) && $this->plupload->is_active()) - { - $json_response = new \phpbb\json_response(); - } - - // Perform actions on temporary attachments - if ($delete_file) - { - include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx); - - $index = array_keys($request->variable('delete_file', array(0 => 0))); - $index = (!empty($index)) ? $index[0] : false; - - if ($index !== false && !empty($this->attachment_data[$index])) - { - /** @var \phpbb\attachment\manager $attachment_manager */ - $attachment_manager = $phpbb_container->get('attachment.manager'); - - // delete selected attachment - if ($this->attachment_data[$index]['is_orphan']) - { - $sql = 'SELECT attach_id, physical_filename, thumbnail - FROM ' . ATTACHMENTS_TABLE . ' - WHERE attach_id = ' . (int) $this->attachment_data[$index]['attach_id'] . ' - AND is_orphan = 1 - AND poster_id = ' . $user->data['user_id']; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - $attachment_manager->unlink($row['physical_filename'], 'file'); - - if ($row['thumbnail']) - { - $attachment_manager->unlink($row['physical_filename'], 'thumbnail'); - } - - $db->sql_query('DELETE FROM ' . ATTACHMENTS_TABLE . ' WHERE attach_id = ' . (int) $this->attachment_data[$index]['attach_id']); - } - } - else - { - $attachment_manager->delete('attach', $this->attachment_data[$index]['attach_id']); - } - - unset($this->attachment_data[$index]); - $this->message = preg_replace_callback('#\[attachment=([0-9]+)\](.*?)\[\/attachment\]#', function ($match) use($index) { - return ($match[1] == $index) ? '' : (($match[1] > $index) ? '[attachment=' . ($match[1] - 1) . ']' . $match[2] . '[/attachment]' : $match[0]); - }, $this->message); - - // Reindex Array - $this->attachment_data = array_values($this->attachment_data); - if (isset($this->plupload) && $this->plupload->is_active()) - { - $json_response->send($this->attachment_data); - } - } - } - else if (($add_file || $preview) && $upload_file) - { - if ($num_attachments < $cfg['max_attachments'] || $auth->acl_gets('m_', 'a_', $forum_id)) - { - /** @var \phpbb\attachment\manager $attachment_manager */ - $attachment_manager = $phpbb_container->get('attachment.manager'); - $filedata = $attachment_manager->upload($form_name, $forum_id, false, '', $is_message); - $error = array_merge($error, $filedata['error']); - - if (!count($error)) - { - $sql_ary = array( - 'physical_filename' => $filedata['physical_filename'], - 'attach_comment' => $this->filename_data['filecomment'], - 'real_filename' => $filedata['real_filename'], - 'extension' => $filedata['extension'], - 'mimetype' => $filedata['mimetype'], - 'filesize' => $filedata['filesize'], - 'filetime' => $filedata['filetime'], - 'thumbnail' => $filedata['thumbnail'], - 'is_orphan' => 1, - 'in_message' => ($is_message) ? 1 : 0, - 'poster_id' => $user->data['user_id'], - ); - - /** - * Modify attachment sql array on upload - * - * @event core.modify_attachment_sql_ary_on_upload - * @var array sql_ary Array containing SQL data - * @since 3.2.6-RC1 - */ - $vars = array('sql_ary'); - extract($phpbb_dispatcher->trigger_event('core.modify_attachment_sql_ary_on_upload', compact($vars))); - - $db->sql_query('INSERT INTO ' . ATTACHMENTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); - - $new_entry = array( - 'attach_id' => $db->sql_nextid(), - 'is_orphan' => 1, - 'real_filename' => $filedata['real_filename'], - 'attach_comment'=> $this->filename_data['filecomment'], - 'filesize' => $filedata['filesize'], - ); - - $this->attachment_data = array_merge(array(0 => $new_entry), $this->attachment_data); - - /** - * Modify attachment data on upload - * - * @event core.modify_attachment_data_on_upload - * @var array attachment_data Array containing attachment data - * @since 3.2.2-RC1 - */ - $attachment_data = $this->attachment_data; - $vars = array('attachment_data'); - extract($phpbb_dispatcher->trigger_event('core.modify_attachment_data_on_upload', compact($vars))); - $this->attachment_data = $attachment_data; - unset($attachment_data); - - $this->message = preg_replace_callback('#\[attachment=([0-9]+)\](.*?)\[\/attachment\]#', function ($match) { - return '[attachment=' . ($match[1] + 1) . ']' . $match[2] . '[/attachment]'; - }, $this->message); - $this->filename_data['filecomment'] = ''; - - if (isset($this->plupload) && $this->plupload->is_active()) - { - $download_url = append_sid("{$phpbb_root_path}download/file.{$phpEx}", 'mode=view&id=' . $new_entry['attach_id']); - - // Send the client the attachment data to maintain state - $json_response->send(array('data' => $this->attachment_data, 'download_url' => $download_url)); - } - } - } - else - { - $error[] = $user->lang('TOO_MANY_ATTACHMENTS', (int) $cfg['max_attachments']); - } - - if (!empty($error) && isset($this->plupload) && $this->plupload->is_active()) - { - // If this is a plupload (and thus ajax) request, give the - // client the first error we have - $json_response->send(array( - 'jsonrpc' => '2.0', - 'id' => 'id', - 'error' => array( - 'code' => 105, - 'message' => current($error), - ), - )); - } - } - } - - foreach ($error as $error_msg) - { - $this->warn_msg[] = $error_msg; - } - } - - /** - * Get Attachment Data - */ - function get_submitted_attachment_data($check_user_id = false) - { - global $user, $db; - global $request; - - $this->filename_data['filecomment'] = $request->variable('filecomment', '', true); - $attachment_data = $request->variable('attachment_data', array(0 => array('' => '')), true, \phpbb\request\request_interface::POST); - $this->attachment_data = array(); - - $check_user_id = ($check_user_id === false) ? $user->data['user_id'] : $check_user_id; - - if (!count($attachment_data)) - { - return; - } - - $not_orphan = $orphan = array(); - - foreach ($attachment_data as $pos => $var_ary) - { - if ($var_ary['is_orphan']) - { - $orphan[(int) $var_ary['attach_id']] = $pos; - } - else - { - $not_orphan[(int) $var_ary['attach_id']] = $pos; - } - } - - // Regenerate already posted attachments - if (count($not_orphan)) - { - // Get the attachment data, based on the poster id... - $sql = 'SELECT attach_id, is_orphan, real_filename, attach_comment, filesize - FROM ' . ATTACHMENTS_TABLE . ' - WHERE ' . $db->sql_in_set('attach_id', array_keys($not_orphan)) . ' - AND poster_id = ' . $check_user_id; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $pos = $not_orphan[$row['attach_id']]; - $this->attachment_data[$pos] = $row; - $this->attachment_data[$pos]['attach_comment'] = $attachment_data[$pos]['attach_comment']; - - unset($not_orphan[$row['attach_id']]); - } - $db->sql_freeresult($result); - } - - if (count($not_orphan)) - { - trigger_error('NO_ACCESS_ATTACHMENT', E_USER_ERROR); - } - - // Regenerate newly uploaded attachments - if (count($orphan)) - { - $sql = 'SELECT attach_id, is_orphan, real_filename, attach_comment, filesize - FROM ' . ATTACHMENTS_TABLE . ' - WHERE ' . $db->sql_in_set('attach_id', array_keys($orphan)) . ' - AND poster_id = ' . $user->data['user_id'] . ' - AND is_orphan = 1'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $pos = $orphan[$row['attach_id']]; - $this->attachment_data[$pos] = $row; - $this->attachment_data[$pos]['attach_comment'] = $attachment_data[$pos]['attach_comment']; - - unset($orphan[$row['attach_id']]); - } - $db->sql_freeresult($result); - } - - if (count($orphan)) - { - trigger_error('NO_ACCESS_ATTACHMENT', E_USER_ERROR); - } - - ksort($this->attachment_data); - } - - /** - * Parse Poll - */ - function parse_poll(&$poll) - { - global $user, $config; - - $poll_max_options = $poll['poll_max_options']; - - // Parse Poll Option text - $tmp_message = $this->message; - - $poll['poll_options'] = preg_split('/\s*?\n\s*/', trim($poll['poll_option_text'])); - $poll['poll_options_size'] = count($poll['poll_options']); - - foreach ($poll['poll_options'] as &$poll_option) - { - $this->message = $poll_option; - $poll_option = $this->parse($poll['enable_bbcode'], ($config['allow_post_links']) ? $poll['enable_urls'] : false, $poll['enable_smilies'], $poll['img_status'], false, false, $config['allow_post_links'], false, 'poll'); - } - unset($poll_option); - $poll['poll_option_text'] = implode("\n", $poll['poll_options']); - - // Parse Poll Title - $this->message = $poll['poll_title']; - if (!$poll['poll_title'] && $poll['poll_options_size']) - { - $this->warn_msg[] = $user->lang['NO_POLL_TITLE']; - } - else - { - if (utf8_strlen(preg_replace('#\[\/?[a-z\*\+\-]+(=[\S]+)?\]#ius', ' ', $this->message)) > 100) - { - $this->warn_msg[] = $user->lang['POLL_TITLE_TOO_LONG']; - } - $poll['poll_title'] = $this->parse($poll['enable_bbcode'], ($config['allow_post_links']) ? $poll['enable_urls'] : false, $poll['enable_smilies'], $poll['img_status'], false, false, $config['allow_post_links'], false, 'poll'); - if (strlen($poll['poll_title']) > 255) - { - $this->warn_msg[] = $user->lang['POLL_TITLE_COMP_TOO_LONG']; - } - } - - if (count($poll['poll_options']) == 1) - { - $this->warn_msg[] = $user->lang['TOO_FEW_POLL_OPTIONS']; - } - else if ($poll['poll_options_size'] > (int) $config['max_poll_options']) - { - $this->warn_msg[] = $user->lang['TOO_MANY_POLL_OPTIONS']; - } - else if ($poll_max_options > $poll['poll_options_size']) - { - $this->warn_msg[] = $user->lang['TOO_MANY_USER_OPTIONS']; - } - - $poll['poll_max_options'] = ($poll['poll_max_options'] < 1) ? 1 : (($poll['poll_max_options'] > $config['max_poll_options']) ? $config['max_poll_options'] : $poll['poll_max_options']); - - $this->message = $tmp_message; - } - - /** - * Remove nested quotes at given depth in current parsed message - * - * @param integer $max_depth Depth limit - * @return null - */ - public function remove_nested_quotes($max_depth) - { - global $phpbb_container; - - if (preg_match('#^<[rt][ >]#', $this->message)) - { - $this->message = $phpbb_container->get('text_formatter.utils')->remove_bbcode( - $this->message, - 'quote', - $max_depth - ); - - return; - } - - // Capture all [quote] and [/quote] tags - preg_match_all('(\\[/?quote(?:="(.*?)")?:' . $this->bbcode_uid . '\\])', $this->message, $matches, PREG_OFFSET_CAPTURE); - - // Iterate over the quote tags to mark the ranges that must be removed - $depth = 0; - $ranges = array(); - $start_pos = 0; - foreach ($matches[0] as $match) - { - if ($match[0][1] === '/') - { - --$depth; - if ($depth == $max_depth) - { - $end_pos = $match[1] + strlen($match[0]); - $length = $end_pos - $start_pos; - $ranges[] = array($start_pos, $length); - } - } - else - { - ++$depth; - if ($depth == $max_depth + 1) - { - $start_pos = $match[1]; - } - } - } - - foreach (array_reverse($ranges) as $range) - { - list($start_pos, $length) = $range; - $this->message = substr_replace($this->message, '', $start_pos, $length); - } - } - - /** - * Setter function for passing the plupload object - * - * @param \phpbb\plupload\plupload $plupload The plupload object - * - * @return null - */ - public function set_plupload(\phpbb\plupload\plupload $plupload) - { - $this->plupload = $plupload; - } - - /** - * Function to perform custom bbcode validation by extensions - * can be used in bbcode_init() to assign regexp replacement - * Example: 'regexp' => array('#\[b\](.*?)\[/b\]#uise' => "\$this->validate_bbcode_by_extension('\$1')") - * - * Accepts variable number of parameters - * - * @return mixed Validation result - */ - public function validate_bbcode_by_extension() - { - global $phpbb_dispatcher; - - $return = false; - $params_array = func_get_args(); - - /** - * Event to validate bbcode with the custom validating methods - * provided by extensions - * - * @event core.validate_bbcode_by_extension - * @var array params_array Array with the function parameters - * @var mixed return Validation result to return - * - * @since 3.1.5-RC1 - */ - $vars = array('params_array', 'return'); - extract($phpbb_dispatcher->trigger_event('core.validate_bbcode_by_extension', compact($vars))); - - return $return; - } -} diff --git a/install/update/new/includes/questionnaire/questionnaire.php b/install/update/new/includes/questionnaire/questionnaire.php deleted file mode 100644 index ec2e6fe..0000000 --- a/install/update/new/includes/questionnaire/questionnaire.php +++ /dev/null @@ -1,497 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* This class collects data which is used to create some usage statistics. -* -* The collected data is - after authorization of the administrator - submitted -* to a central server. For privacy reasons we try to collect only data which aren't private -* or don't give any information which might help to identify the user. -* -* @author Johannes Schlueter -* @copyright (c) 2007-2008 Johannes Schlueter -*/ -class phpbb_questionnaire_data_collector -{ - var $providers; - var $data = null; - var $install_id = ''; - - /** - * Constructor. - * - * @param string - */ - function __construct($install_id) - { - $this->install_id = $install_id; - $this->providers = array(); - } - - function add_data_provider($provider) - { - $this->providers[] = $provider; - } - - /** - * Get data as an array. - * - * @return array All Data - */ - function get_data_raw() - { - if (!$this->data) - { - $this->collect(); - } - - return $this->data; - } - - function get_data_for_form() - { - return base64_encode(json_encode($this->get_data_raw())); - } - - /** - * Collect info into the data property. - * - * @return null - */ - function collect() - { - foreach (array_keys($this->providers) as $key) - { - $provider = $this->providers[$key]; - $this->data[$provider->get_identifier()] = $provider->get_data(); - } - $this->data['install_id'] = $this->install_id; - } -} - -/** interface: get_indentifier(), get_data() */ - -/** -* Questionnaire PHP data provider -*/ -class phpbb_questionnaire_php_data_provider -{ - function get_identifier() - { - return 'PHP'; - } - - /** - * Get data about the PHP runtime setup. - * - * @return array - */ - function get_data() - { - return array( - 'version' => PHP_VERSION, - 'sapi' => PHP_SAPI, - 'int_size' => defined('PHP_INT_SIZE') ? PHP_INT_SIZE : '', - 'open_basedir' => (int) @ini_get('open_basedir'), - 'memory_limit' => @ini_get('memory_limit'), - 'allow_url_fopen' => (int) @ini_get('allow_url_fopen'), - 'allow_url_include' => (int) @ini_get('allow_url_include'), - 'file_uploads' => (int) @ini_get('file_uploads'), - 'upload_max_filesize' => @ini_get('upload_max_filesize'), - 'post_max_size' => @ini_get('post_max_size'), - 'disable_functions' => @ini_get('disable_functions'), - 'disable_classes' => @ini_get('disable_classes'), - 'enable_dl' => (int) @ini_get('enable_dl'), - 'filter.default' => @ini_get('filter.default'), - 'zend.ze1_compatibility_mode' => (int) @ini_get('zend.ze1_compatibility_mode'), - 'unicode.semantics' => (int) @ini_get('unicode.semantics'), - 'zend_thread_safty' => (int) function_exists('zend_thread_id'), - 'extensions' => implode(',', get_loaded_extensions()), - ); - } -} - -/** -* Questionnaire System data provider -*/ -class phpbb_questionnaire_system_data_provider -{ - function get_identifier() - { - return 'System'; - } - - /** - * Get data about the general system information, like OS or IP (shortened). - * - * @return array - */ - function get_data() - { - global $request; - - // Start discovering the IPV4 server address, if available - // Try apache, IIS, fall back to 0.0.0.0 - $server_address = htmlspecialchars_decode($request->server('SERVER_ADDR', $request->server('LOCAL_ADDR', '0.0.0.0'))); - - return array( - 'os' => PHP_OS, - 'httpd' => htmlspecialchars_decode($request->server('SERVER_SOFTWARE')), - // we don't want the real IP address (for privacy policy reasons) but only - // a network address to see whether your installation is running on a private or public network. - 'private_ip' => $this->is_private_ip($server_address), - 'ipv6' => strpos($server_address, ':') !== false, - ); - } - - /** - * Checks whether the given IP is in a private network. - * - * @param string $ip IP in v4 dot-decimal or v6 hex format - * @return bool true if the IP is from a private network, else false - */ - function is_private_ip($ip) - { - // IPv4 - if (strpos($ip, ':') === false) - { - $ip_address_ary = explode('.', $ip); - - // build ip - if (!isset($ip_address_ary[0]) || !isset($ip_address_ary[1])) - { - $ip_address_ary = explode('.', '0.0.0.0'); - } - - // IANA reserved addresses for private networks (RFC 1918) are: - // - 10.0.0.0/8 - // - 172.16.0.0/12 - // - 192.168.0.0/16 - if ($ip_address_ary[0] == '10' || - ($ip_address_ary[0] == '172' && intval($ip_address_ary[1]) > 15 && intval($ip_address_ary[1]) < 32) || - ($ip_address_ary[0] == '192' && $ip_address_ary[1] == '168')) - { - return true; - } - } - // IPv6 - else - { - // unique local unicast - $prefix = substr($ip, 0, 2); - if ($prefix == 'fc' || $prefix == 'fd') - { - return true; - } - } - - return false; - } -} - -/** -* Questionnaire phpBB data provider -*/ -class phpbb_questionnaire_phpbb_data_provider -{ - var $config; - var $unique_id; - - /** - * Constructor. - * - * @param array $config - */ - function __construct($config) - { - // generate a unique id if necessary - if (empty($config['questionnaire_unique_id'])) - { - $this->unique_id = unique_id(); - $config->set('questionnaire_unique_id', $this->unique_id); - } - else - { - $this->unique_id = $config['questionnaire_unique_id']; - } - - $this->config = $config; - } - - /** - * Returns a string identifier for this data provider - * - * @return string "phpBB" - */ - function get_identifier() - { - return 'phpBB'; - } - - /** - * Get data about this phpBB installation. - * - * @return array Relevant anonymous config options - */ - function get_data() - { - global $phpbb_config_php_file; - - extract($phpbb_config_php_file->get_all()); - unset($dbhost, $dbport, $dbname, $dbuser, $dbpasswd); // Just a precaution - - $dbms = $phpbb_config_php_file->convert_30_dbms_to_31($dbms); - - // Only send certain config vars - $config_vars = array( - 'active_sessions' => true, - 'allow_attachments' => true, - 'allow_autologin' => true, - 'allow_avatar' => true, - 'allow_avatar_local' => true, - 'allow_avatar_remote' => true, - 'allow_avatar_upload' => true, - 'allow_bbcode' => true, - 'allow_birthdays' => true, - 'allow_bookmarks' => true, - 'allow_emailreuse' => true, - 'allow_forum_notify' => true, - 'allow_mass_pm' => true, - 'allow_name_chars' => true, - 'allow_namechange' => true, - 'allow_nocensors' => true, - 'allow_pm_attach' => true, - 'allow_pm_report' => true, - 'allow_post_flash' => true, - 'allow_post_links' => true, - 'allow_privmsg' => true, - 'allow_quick_reply' => true, - 'allow_sig' => true, - 'allow_sig_bbcode' => true, - 'allow_sig_flash' => true, - 'allow_sig_img' => true, - 'allow_sig_links' => true, - 'allow_sig_pm' => true, - 'allow_sig_smilies' => true, - 'allow_smilies' => true, - 'allow_topic_notify' => true, - 'attachment_quota' => true, - 'auth_bbcode_pm' => true, - 'auth_flash_pm' => true, - 'auth_img_pm' => true, - 'auth_method' => true, - 'auth_smilies_pm' => true, - 'avatar_filesize' => true, - 'avatar_max_height' => true, - 'avatar_max_width' => true, - 'avatar_min_height' => true, - 'avatar_min_width' => true, - 'board_email_form' => true, - 'board_hide_emails' => true, - 'board_timezone' => true, - 'browser_check' => true, - 'bump_interval' => true, - 'bump_type' => true, - 'cache_gc' => true, - 'captcha_plugin' => true, - 'captcha_gd' => true, - 'captcha_gd_foreground_noise' => true, - 'captcha_gd_x_grid' => true, - 'captcha_gd_y_grid' => true, - 'captcha_gd_wave' => true, - 'captcha_gd_3d_noise' => true, - 'captcha_gd_fonts' => true, - 'confirm_refresh' => true, - 'check_attachment_content' => true, - 'check_dnsbl' => true, - 'chg_passforce' => true, - 'cookie_secure' => true, - 'coppa_enable' => true, - 'database_gc' => true, - 'dbms_version' => true, - 'default_dateformat' => true, - 'default_lang' => true, - 'display_last_edited' => true, - 'display_order' => true, - 'edit_time' => true, - 'email_check_mx' => true, - 'email_enable' => true, - 'email_force_sender' => true, - 'email_package_size' => true, - 'enable_confirm' => true, - 'enable_pm_icons' => true, - 'enable_post_confirm' => true, - 'feed_enable' => true, - 'feed_http_auth' => true, - 'feed_limit_post' => true, - 'feed_limit_topic' => true, - 'feed_overall' => true, - 'feed_overall_forums' => true, - 'feed_forum' => true, - 'feed_topic' => true, - 'feed_topics_new' => true, - 'feed_topics_active' => true, - 'feed_item_statistics' => true, - 'flood_interval' => true, - 'force_server_vars' => true, - 'form_token_lifetime' => true, - 'form_token_mintime' => true, - 'form_token_sid_guests' => true, - 'forward_pm' => true, - 'forwarded_for_check' => true, - 'full_folder_action' => true, - 'fulltext_native_common_thres' => true, - 'fulltext_native_load_upd' => true, - 'fulltext_native_max_chars' => true, - 'fulltext_native_min_chars' => true, - 'gzip_compress' => true, - 'hot_threshold' => true, - 'img_create_thumbnail' => true, - 'img_display_inlined' => true, - 'img_link_height' => true, - 'img_link_width' => true, - 'img_max_height' => true, - 'img_max_thumb_width' => true, - 'img_max_width' => true, - 'img_min_thumb_filesize' => true, - 'ip_check' => true, - 'jab_enable' => true, - 'jab_package_size' => true, - 'jab_use_ssl' => true, - 'limit_load' => true, - 'limit_search_load' => true, - 'load_anon_lastread' => true, - 'load_birthdays' => true, - 'load_cpf_memberlist' => true, - 'load_cpf_viewprofile' => true, - 'load_cpf_viewtopic' => true, - 'load_db_lastread' => true, - 'load_db_track' => true, - 'load_jumpbox' => true, - 'load_moderators' => true, - 'load_online' => true, - 'load_online_guests' => true, - 'load_online_time' => true, - 'load_onlinetrack' => true, - 'load_search' => true, - 'load_tplcompile' => true, - 'load_user_activity' => true, - 'max_attachments' => true, - 'max_attachments_pm' => true, - 'max_autologin_time' => true, - 'max_filesize' => true, - 'max_filesize_pm' => true, - 'max_login_attempts' => true, - 'max_name_chars' => true, - 'max_num_search_keywords' => true, - 'max_poll_options' => true, - 'max_post_chars' => true, - 'max_post_font_size' => true, - 'max_post_img_height' => true, - 'max_post_img_width' => true, - 'max_post_smilies' => true, - 'max_post_urls' => true, - 'max_quote_depth' => true, - 'max_reg_attempts' => true, - 'max_sig_chars' => true, - 'max_sig_font_size' => true, - 'max_sig_img_height' => true, - 'max_sig_img_width' => true, - 'max_sig_smilies' => true, - 'max_sig_urls' => true, - 'min_name_chars' => true, - 'min_pass_chars' => true, - 'min_post_chars' => true, - 'min_search_author_chars' => true, - 'mime_triggers' => true, - 'new_member_post_limit' => true, - 'new_member_group_default' => true, - 'override_user_style' => true, - 'pass_complex' => true, - 'pm_edit_time' => true, - 'pm_max_boxes' => true, - 'pm_max_msgs' => true, - 'pm_max_recipients' => true, - 'posts_per_page' => true, - 'print_pm' => true, - 'queue_interval' => true, - 'require_activation' => true, - 'referer_validation' => true, - 'search_block_size' => true, - 'search_gc' => true, - 'search_interval' => true, - 'search_anonymous_interval' => true, - 'search_type' => true, - 'search_store_results' => true, - 'secure_allow_deny' => true, - 'secure_allow_empty_referer' => true, - 'secure_downloads' => true, - 'session_gc' => true, - 'session_length' => true, - 'smtp_auth_method' => true, - 'smtp_delivery' => true, - 'topics_per_page' => true, - 'tpl_allow_php' => true, - 'version' => true, - 'warnings_expire_days' => true, - 'warnings_gc' => true, - - 'num_files' => true, - 'num_posts' => true, - 'num_topics' => true, - 'num_users' => true, - 'record_online_users' => true, - ); - - $result = array(); - foreach ($config_vars as $name => $void) - { - if (isset($this->config[$name])) - { - $result['config_' . $name] = $this->config[$name]; - } - } - - global $db, $request; - - $result['dbms'] = $dbms; - $result['acm_type'] = $acm_type; - $result['user_agent'] = 'Unknown'; - $result['dbms_version'] = $db->sql_server_info(true); - - // Try to get user agent vendor and version - $match = array(); - $user_agent = $request->header('User-Agent'); - $agents = array('firefox', 'msie', 'opera', 'chrome', 'safari', 'mozilla', 'seamonkey', 'konqueror', 'netscape', 'gecko', 'navigator', 'mosaic', 'lynx', 'amaya', 'omniweb', 'avant', 'camino', 'flock', 'aol'); - - // We check here 1 by 1 because some strings occur after others (for example Mozilla [...] Firefox/) - foreach ($agents as $agent) - { - if (preg_match('#(' . $agent . ')[/ ]?([0-9.]*)#i', $user_agent, $match)) - { - $result['user_agent'] = $match[1] . ' ' . $match[2]; - break; - } - } - - return $result; - } -} diff --git a/install/update/new/includes/startup.php b/install/update/new/includes/startup.php deleted file mode 100644 index 5ead3b7..0000000 --- a/install/update/new/includes/startup.php +++ /dev/null @@ -1,86 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -// Report all errors, except notices and deprecation messages -$level = E_ALL & ~E_NOTICE & ~E_DEPRECATED; -error_reporting($level); - -/** -* Minimum Requirement: PHP 7.1.3 -*/ -if (version_compare(PHP_VERSION, '7.1.3', '<')) -{ - die('You are running an unsupported PHP version. Please upgrade to PHP 7.1.3 or higher before trying to install or update to phpBB 3.3'); -} -// Register globals and magic quotes have been dropped in PHP 5.4 so no need for extra checks - - -// In PHP 5.3.0 the error level has been raised to E_WARNING which causes problems -// because we show E_WARNING errors and do not set a default timezone. -// This is because we have our own timezone handling and work in UTC only anyway. - -// So what we basically want to do is set our timezone to UTC, -// but we don't know what other scripts (such as bridges) are involved, -// so we check whether a timezone is already set by calling date_default_timezone_get(). - -// Unfortunately, date_default_timezone_get() itself might throw E_WARNING -// if no timezone has been set, so we have to keep it quiet with @. - -// date_default_timezone_get() tries to guess the correct timezone first -// and then falls back to UTC when everything fails. -// We just set the timezone to whatever date_default_timezone_get() returns. -date_default_timezone_set(@date_default_timezone_get()); - -// Autoloading of dependencies. -// Three options are supported: -// 1. If dependencies are installed with Composer, Composer will create a -// vendor/autoload.php. If this file exists it will be -// automatically used by phpBB. This is the default mode that phpBB -// will use when shipped. -// 2. To disable composer autoloading, PHPBB_NO_COMPOSER_AUTOLOAD can be specified. -// Additionally specify PHPBB_AUTOLOAD=/path/to/autoload.php in the -// environment. This is useful for running CLI scripts and tests. -// /path/to/autoload.php should define and register class loaders -// for all of phpBB's dependencies. -// 3. You can also set PHPBB_NO_COMPOSER_AUTOLOAD without setting PHPBB_AUTOLOAD. -// In this case autoloading needs to be defined before running any phpBB -// script. This might be useful in cases when phpBB is integrated into a -// larger program. -if (getenv('PHPBB_NO_COMPOSER_AUTOLOAD')) -{ - if (getenv('PHPBB_AUTOLOAD')) - { - require(getenv('PHPBB_AUTOLOAD')); - } -} -else -{ - if (!file_exists($phpbb_root_path . 'vendor/autoload.php')) - { - trigger_error( - 'Composer dependencies have not been set up yet, run ' . - "'php ../composer.phar install' from the phpBB directory to do so.", - E_USER_ERROR - ); - } - require($phpbb_root_path . 'vendor/autoload.php'); -} - -$starttime = microtime(true); diff --git a/install/update/new/includes/ucp/ucp_attachments.php b/install/update/new/includes/ucp/ucp_attachments.php deleted file mode 100644 index 7808fed..0000000 --- a/install/update/new/includes/ucp/ucp_attachments.php +++ /dev/null @@ -1,219 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* ucp_attachments -* User attachments -*/ -class ucp_attachments -{ - var $u_action; - - function main($id, $mode) - { - global $template, $user, $db, $config, $phpEx, $phpbb_root_path, $phpbb_container, $request, $auth; - - $start = $request->variable('start', 0); - $sort_key = $request->variable('sk', 'a'); - $sort_dir = $request->variable('sd', 'a'); - - $delete = (isset($_POST['delete'])) ? true : false; - $delete_ids = array_keys($request->variable('attachment', array(0))); - - if ($delete && count($delete_ids)) - { - // Validate $delete_ids... - $sql = 'SELECT a.attach_id, p.post_edit_locked, t.topic_status, f.forum_id, f.forum_status - FROM ' . ATTACHMENTS_TABLE . ' a - LEFT JOIN ' . POSTS_TABLE . ' p - ON (a.post_msg_id = p.post_id AND a.in_message = 0) - LEFT JOIN ' . TOPICS_TABLE . ' t - ON (t.topic_id = p.topic_id AND a.in_message = 0) - LEFT JOIN ' . FORUMS_TABLE . ' f - ON (f.forum_id = t.forum_id AND a.in_message = 0) - WHERE a.poster_id = ' . $user->data['user_id'] . ' - AND a.is_orphan = 0 - AND ' . $db->sql_in_set('a.attach_id', $delete_ids); - $result = $db->sql_query($sql); - - $delete_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - if (!$auth->acl_get('m_edit', $row['forum_id']) && ($row['forum_status'] == ITEM_LOCKED || $row['topic_status'] == ITEM_LOCKED || $row['post_edit_locked'])) - { - continue; - } - - $delete_ids[] = $row['attach_id']; - } - $db->sql_freeresult($result); - } - - if ($delete && count($delete_ids)) - { - $s_hidden_fields = array( - 'delete' => 1 - ); - - foreach ($delete_ids as $attachment_id) - { - $s_hidden_fields['attachment'][$attachment_id] = 1; - } - - if (confirm_box(true)) - { - /** @var \phpbb\attachment\manager $attachment_manager */ - $attachment_manager = $phpbb_container->get('attachment.manager'); - $attachment_manager->delete('attach', $delete_ids); - unset($attachment_manager); - - meta_refresh(3, $this->u_action); - $message = ((count($delete_ids) == 1) ? $user->lang['ATTACHMENT_DELETED'] : $user->lang['ATTACHMENTS_DELETED']) . '

' . sprintf($user->lang['RETURN_UCP'], '', ''); - trigger_error($message); - } - else - { - confirm_box(false, (count($delete_ids) == 1) ? 'DELETE_ATTACHMENT' : 'DELETE_ATTACHMENTS', build_hidden_fields($s_hidden_fields)); - } - } - - // Select box eventually - $sort_key_text = array('a' => $user->lang['SORT_FILENAME'], 'b' => $user->lang['SORT_COMMENT'], 'c' => $user->lang['SORT_EXTENSION'], 'd' => $user->lang['SORT_SIZE'], 'e' => $user->lang['SORT_DOWNLOADS'], 'f' => $user->lang['SORT_POST_TIME'], 'g' => $user->lang['SORT_TOPIC_TITLE']); - $sort_key_sql = array('a' => 'a.real_filename', 'b' => 'a.attach_comment', 'c' => 'a.extension', 'd' => 'a.filesize', 'e' => 'a.download_count', 'f' => 'a.filetime', 'g' => 't.topic_title'); - - $sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']); - - $s_sort_key = ''; - foreach ($sort_key_text as $key => $value) - { - $selected = ($sort_key == $key) ? ' selected="selected"' : ''; - $s_sort_key .= ''; - } - - $s_sort_dir = ''; - foreach ($sort_dir_text as $key => $value) - { - $selected = ($sort_dir == $key) ? ' selected="selected"' : ''; - $s_sort_dir .= ''; - } - - if (!isset($sort_key_sql[$sort_key])) - { - $sort_key = 'a'; - } - - $order_by = $sort_key_sql[$sort_key] . ' ' . (($sort_dir == 'a') ? 'ASC' : 'DESC'); - - $sql = 'SELECT COUNT(attach_id) as num_attachments - FROM ' . ATTACHMENTS_TABLE . ' - WHERE poster_id = ' . $user->data['user_id'] . ' - AND is_orphan = 0'; - $result = $db->sql_query($sql); - $num_attachments = $db->sql_fetchfield('num_attachments'); - $db->sql_freeresult($result); - - // Ensure start is a valid value - /* @var $pagination \phpbb\pagination */ - $pagination = $phpbb_container->get('pagination'); - $start = $pagination->validate_start($start, $config['topics_per_page'], $num_attachments); - - $sql = 'SELECT a.*, t.topic_title, pr.message_subject as message_title, p.post_edit_locked, t.topic_status, f.forum_id, f.forum_status - FROM ' . ATTACHMENTS_TABLE . ' a - LEFT JOIN ' . POSTS_TABLE . ' p ON (a.post_msg_id = p.post_id AND a.in_message = 0) - LEFT JOIN ' . TOPICS_TABLE . ' t ON (a.topic_id = t.topic_id AND a.in_message = 0) - LEFT JOIN ' . FORUMS_TABLE . ' f ON (f.forum_id = t.forum_id AND a.in_message = 0) - LEFT JOIN ' . PRIVMSGS_TABLE . ' pr ON (a.post_msg_id = pr.msg_id AND a.in_message = 1) - WHERE a.poster_id = ' . $user->data['user_id'] . " - AND a.is_orphan = 0 - ORDER BY $order_by"; - $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); - - $row_count = 0; - if ($row = $db->sql_fetchrow($result)) - { - $template->assign_var('S_ATTACHMENT_ROWS', true); - - do - { - if ($row['in_message']) - { - $view_topic = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=pm&p={$row['post_msg_id']}"); - } - else - { - $view_topic = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t={$row['topic_id']}&p={$row['post_msg_id']}") . "#p{$row['post_msg_id']}"; - } - - $template->assign_block_vars('attachrow', array( - 'ROW_NUMBER' => $row_count + ($start + 1), - 'FILENAME' => $row['real_filename'], - 'COMMENT' => bbcode_nl2br($row['attach_comment']), - 'EXTENSION' => $row['extension'], - 'SIZE' => get_formatted_filesize($row['filesize']), - 'DOWNLOAD_COUNT' => $row['download_count'], - 'POST_TIME' => $user->format_date($row['filetime']), - 'TOPIC_TITLE' => ($row['in_message']) ? $row['message_title'] : $row['topic_title'], - - 'ATTACH_ID' => $row['attach_id'], - 'POST_ID' => $row['post_msg_id'], - 'TOPIC_ID' => $row['topic_id'], - - 'S_IN_MESSAGE' => $row['in_message'], - 'S_LOCKED' => !$row['in_message'] && !$auth->acl_get('m_edit', $row['forum_id']) && ($row['forum_status'] == ITEM_LOCKED || $row['topic_status'] == ITEM_LOCKED || $row['post_edit_locked']), - - 'U_VIEW_ATTACHMENT' => append_sid("{$phpbb_root_path}download/file.$phpEx", 'id=' . $row['attach_id']), - 'U_VIEW_TOPIC' => $view_topic) - ); - - $row_count++; - } - while ($row = $db->sql_fetchrow($result)); - } - $db->sql_freeresult($result); - - $base_url = $this->u_action . "&sk=$sort_key&sd=$sort_dir"; - $pagination->generate_template_pagination($base_url, 'pagination', 'start', $num_attachments, $config['topics_per_page'], $start); - - $template->assign_vars(array( - 'TOTAL_ATTACHMENTS' => $num_attachments, - 'NUM_ATTACHMENTS' => $user->lang('NUM_ATTACHMENTS', $num_attachments), - - 'L_TITLE' => $user->lang['UCP_ATTACHMENTS'], - - 'U_SORT_FILENAME' => $this->u_action . "&sk=a&sd=" . (($sort_key == 'a' && $sort_dir == 'a') ? 'd' : 'a'), - 'U_SORT_FILE_COMMENT' => $this->u_action . "&sk=b&sd=" . (($sort_key == 'b' && $sort_dir == 'a') ? 'd' : 'a'), - 'U_SORT_EXTENSION' => $this->u_action . "&sk=c&sd=" . (($sort_key == 'c' && $sort_dir == 'a') ? 'd' : 'a'), - 'U_SORT_FILESIZE' => $this->u_action . "&sk=d&sd=" . (($sort_key == 'd' && $sort_dir == 'a') ? 'd' : 'a'), - 'U_SORT_DOWNLOADS' => $this->u_action . "&sk=e&sd=" . (($sort_key == 'e' && $sort_dir == 'a') ? 'd' : 'a'), - 'U_SORT_POST_TIME' => $this->u_action . "&sk=f&sd=" . (($sort_key == 'f' && $sort_dir == 'a') ? 'd' : 'a'), - 'U_SORT_TOPIC_TITLE' => $this->u_action . "&sk=g&sd=" . (($sort_key == 'g' && $sort_dir == 'a') ? 'd' : 'a'), - - 'S_DISPLAY_MARK_ALL' => ($num_attachments) ? true : false, - 'S_DISPLAY_PAGINATION' => ($num_attachments) ? true : false, - 'S_UCP_ACTION' => $this->u_action, - 'S_SORT_OPTIONS' => $s_sort_key, - 'S_ORDER_SELECT' => $s_sort_dir) - ); - - $this->tpl_name = 'ucp_attachments'; - $this->page_title = 'UCP_ATTACHMENTS'; - } -} diff --git a/install/update/new/includes/ucp/ucp_groups.php b/install/update/new/includes/ucp/ucp_groups.php deleted file mode 100644 index 6eba3a0..0000000 --- a/install/update/new/includes/ucp/ucp_groups.php +++ /dev/null @@ -1,1142 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* ucp_groups -*/ -class ucp_groups -{ - var $u_action; - - function main($id, $mode) - { - global $config, $phpbb_root_path, $phpEx, $phpbb_admin_path; - global $db, $user, $auth, $cache, $template; - global $request, $phpbb_container, $phpbb_log; - - /** @var \phpbb\language\language $language Language object */ - $language = $phpbb_container->get('language'); - - $user->add_lang('groups'); - - $return_page = '

' . sprintf($user->lang['RETURN_PAGE'], '', ''); - - $mark_ary = $request->variable('mark', array(0)); - $submit = $request->variable('submit', false, false, \phpbb\request\request_interface::POST); - - /** @var \phpbb\group\helper $group_helper */ - $group_helper = $phpbb_container->get('group_helper'); - - switch ($mode) - { - case 'membership': - - $this->page_title = 'UCP_USERGROUPS_MEMBER'; - - if ($submit || isset($_POST['change_default'])) - { - $action = (isset($_POST['change_default'])) ? 'change_default' : $request->variable('action', ''); - $group_id = ($action == 'change_default') ? $request->variable('default', 0) : $request->variable('selected', 0); - - if (!$group_id) - { - trigger_error('NO_GROUP_SELECTED'); - } - - $sql = 'SELECT group_id, group_name, group_type - FROM ' . GROUPS_TABLE . " - WHERE group_id IN ($group_id, {$user->data['group_id']})"; - $result = $db->sql_query($sql); - - $group_row = array(); - while ($row = $db->sql_fetchrow($result)) - { - $row['group_name'] = $group_helper->get_name($row['group_name']); - $group_row[$row['group_id']] = $row; - } - $db->sql_freeresult($result); - - if (!count($group_row)) - { - trigger_error('GROUP_NOT_EXIST'); - } - - switch ($action) - { - case 'change_default': - // User already having this group set as default? - if ($group_id == $user->data['group_id']) - { - trigger_error($user->lang['ALREADY_DEFAULT_GROUP'] . $return_page); - } - - if (!$auth->acl_get('u_chggrp')) - { - send_status_line(403, 'Forbidden'); - trigger_error($user->lang['NOT_AUTHORISED'] . $return_page); - } - - // User needs to be member of the group in order to make it default - if (!group_memberships($group_id, $user->data['user_id'], true)) - { - trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page); - } - - if (confirm_box(true)) - { - group_user_attributes('default', $group_id, $user->data['user_id']); - - $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_GROUP_CHANGE', false, array( - 'reportee_id' => $user->data['user_id'], - sprintf($user->lang['USER_GROUP_CHANGE'], $group_row[$user->data['group_id']]['group_name'], $group_row[$group_id]['group_name']) - )); - - meta_refresh(3, $this->u_action); - trigger_error($user->lang['CHANGED_DEFAULT_GROUP'] . $return_page); - } - else - { - $s_hidden_fields = array( - 'default' => $group_id, - 'change_default'=> true - ); - - confirm_box(false, sprintf($user->lang['GROUP_CHANGE_DEFAULT'], $group_row[$group_id]['group_name']), build_hidden_fields($s_hidden_fields)); - } - - break; - - case 'resign': - - // User tries to resign from default group but is not allowed to change it? - if ($group_id == $user->data['group_id'] && !$auth->acl_get('u_chggrp')) - { - trigger_error($user->lang['NOT_RESIGN_FROM_DEFAULT_GROUP'] . $return_page); - } - - if (!($row = group_memberships($group_id, $user->data['user_id']))) - { - trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page); - } - $row = current($row); - - $sql = 'SELECT group_type - FROM ' . GROUPS_TABLE . ' - WHERE group_id = ' . $group_id; - $result = $db->sql_query($sql); - $group_type = (int) $db->sql_fetchfield('group_type'); - $db->sql_freeresult($result); - - if ($group_type != GROUP_OPEN && $group_type != GROUP_FREE) - { - trigger_error($user->lang['CANNOT_RESIGN_GROUP'] . $return_page); - } - - if (confirm_box(true)) - { - group_user_del($group_id, $user->data['user_id']); - - $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_GROUP_RESIGN', false, array( - 'reportee_id' => $user->data['user_id'], - $group_row[$group_id]['group_name'] - )); - - meta_refresh(3, $this->u_action); - trigger_error($user->lang[($row['user_pending']) ? 'GROUP_RESIGNED_PENDING' : 'GROUP_RESIGNED_MEMBERSHIP'] . $return_page); - } - else - { - $s_hidden_fields = array( - 'selected' => $group_id, - 'action' => 'resign', - 'submit' => true - ); - - confirm_box(false, ($row['user_pending']) ? 'GROUP_RESIGN_PENDING' : 'GROUP_RESIGN_MEMBERSHIP', build_hidden_fields($s_hidden_fields)); - } - - break; - - case 'join': - - $sql = 'SELECT ug.*, u.username, u.username_clean, u.user_email - FROM ' . USER_GROUP_TABLE . ' ug, ' . USERS_TABLE . ' u - WHERE ug.user_id = u.user_id - AND ug.group_id = ' . $group_id . ' - AND ug.user_id = ' . $user->data['user_id']; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - if ($row['user_pending']) - { - trigger_error($user->lang['ALREADY_IN_GROUP_PENDING'] . $return_page); - } - - trigger_error($user->lang['ALREADY_IN_GROUP'] . $return_page); - } - - // Check permission to join (open group or request) - if ($group_row[$group_id]['group_type'] != GROUP_OPEN && $group_row[$group_id]['group_type'] != GROUP_FREE) - { - trigger_error($user->lang['CANNOT_JOIN_GROUP'] . $return_page); - } - - if (confirm_box(true)) - { - if ($group_row[$group_id]['group_type'] == GROUP_FREE) - { - group_user_add($group_id, $user->data['user_id']); - } - else - { - group_user_add($group_id, $user->data['user_id'], false, false, false, 0, 1); - } - - $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_GROUP_JOIN' . (($group_row[$group_id]['group_type'] == GROUP_FREE) ? '' : '_PENDING'), false, array( - 'reportee_id' => $user->data['user_id'], - $group_row[$group_id]['group_name'] - )); - - meta_refresh(3, $this->u_action); - trigger_error($user->lang[($group_row[$group_id]['group_type'] == GROUP_FREE) ? 'GROUP_JOINED' : 'GROUP_JOINED_PENDING'] . $return_page); - } - else - { - $s_hidden_fields = array( - 'selected' => $group_id, - 'action' => 'join', - 'submit' => true - ); - - confirm_box(false, ($group_row[$group_id]['group_type'] == GROUP_FREE) ? 'GROUP_JOIN' : 'GROUP_JOIN_PENDING', build_hidden_fields($s_hidden_fields)); - } - - break; - - case 'demote': - - if (!($row = group_memberships($group_id, $user->data['user_id']))) - { - trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page); - } - $row = current($row); - - if (!$row['group_leader']) - { - trigger_error($user->lang['NOT_LEADER_OF_GROUP'] . $return_page); - } - - if (confirm_box(true)) - { - group_user_attributes('demote', $group_id, $user->data['user_id']); - - $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_GROUP_DEMOTE', false, array( - 'reportee_id' => $user->data['user_id'], - $group_row[$group_id]['group_name'] - )); - - meta_refresh(3, $this->u_action); - trigger_error($user->lang['USER_GROUP_DEMOTED'] . $return_page); - } - else - { - $s_hidden_fields = array( - 'selected' => $group_id, - 'action' => 'demote', - 'submit' => true - ); - - confirm_box(false, 'USER_GROUP_DEMOTE', build_hidden_fields($s_hidden_fields)); - } - - break; - } - } - - $sql = 'SELECT g.*, ug.group_leader, ug.user_pending - FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . ' ug - WHERE ug.user_id = ' . $user->data['user_id'] . ' - AND g.group_id = ug.group_id - ORDER BY g.group_type DESC, g.group_name'; - $result = $db->sql_query($sql); - - $group_id_ary = array(); - $leader_count = $member_count = $pending_count = 0; - while ($row = $db->sql_fetchrow($result)) - { - $block = ($row['group_leader']) ? 'leader' : (($row['user_pending']) ? 'pending' : 'member'); - - switch ($row['group_type']) - { - case GROUP_OPEN: - $group_status = 'OPEN'; - break; - - case GROUP_CLOSED: - $group_status = 'CLOSED'; - break; - - case GROUP_HIDDEN: - $group_status = 'HIDDEN'; - break; - - case GROUP_SPECIAL: - $group_status = 'SPECIAL'; - break; - - case GROUP_FREE: - $group_status = 'FREE'; - break; - } - - $template->assign_block_vars($block, array( - 'GROUP_ID' => $row['group_id'], - 'GROUP_NAME' => $group_helper->get_name($row['group_name']), - 'GROUP_DESC' => ($row['group_type'] <> GROUP_SPECIAL) ? generate_text_for_display($row['group_desc'], $row['group_desc_uid'], $row['group_desc_bitfield'], $row['group_desc_options']) : $user->lang['GROUP_IS_SPECIAL'], - 'GROUP_SPECIAL' => ($row['group_type'] <> GROUP_SPECIAL) ? false : true, - 'GROUP_STATUS' => $user->lang['GROUP_IS_' . $group_status], - 'GROUP_COLOUR' => $row['group_colour'], - - 'U_VIEW_GROUP' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&g=' . $row['group_id']), - - 'S_GROUP_DEFAULT' => ($row['group_id'] == $user->data['group_id']) ? true : false, - 'S_ROW_COUNT' => ${$block . '_count'}++) - ); - - $group_id_ary[] = (int) $row['group_id']; - } - $db->sql_freeresult($result); - - // Hide hidden groups unless user is an admin with group privileges - $sql_and = ($auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) ? '<> ' . GROUP_SPECIAL : 'NOT IN (' . GROUP_SPECIAL . ', ' . GROUP_HIDDEN . ')'; - - $sql = 'SELECT group_id, group_name, group_colour, group_desc, group_desc_uid, group_desc_bitfield, group_desc_options, group_type, group_founder_manage - FROM ' . GROUPS_TABLE . ' - WHERE ' . ((count($group_id_ary)) ? $db->sql_in_set('group_id', $group_id_ary, true) . ' AND ' : '') . " - group_type $sql_and - ORDER BY group_type DESC, group_name"; - $result = $db->sql_query($sql); - - $nonmember_count = 0; - while ($row = $db->sql_fetchrow($result)) - { - switch ($row['group_type']) - { - case GROUP_OPEN: - $group_status = 'OPEN'; - break; - - case GROUP_CLOSED: - $group_status = 'CLOSED'; - break; - - case GROUP_HIDDEN: - $group_status = 'HIDDEN'; - break; - - case GROUP_SPECIAL: - $group_status = 'SPECIAL'; - break; - - case GROUP_FREE: - $group_status = 'FREE'; - break; - } - - $template->assign_block_vars('nonmember', array( - 'GROUP_ID' => $row['group_id'], - 'GROUP_NAME' => $group_helper->get_name($row['group_name']), - 'GROUP_DESC' => ($row['group_type'] <> GROUP_SPECIAL) ? generate_text_for_display($row['group_desc'], $row['group_desc_uid'], $row['group_desc_bitfield'], $row['group_desc_options']) : $user->lang['GROUP_IS_SPECIAL'], - 'GROUP_SPECIAL' => ($row['group_type'] <> GROUP_SPECIAL) ? false : true, - 'GROUP_CLOSED' => ($row['group_type'] <> GROUP_CLOSED || $auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) ? false : true, - 'GROUP_STATUS' => $user->lang['GROUP_IS_' . $group_status], - 'S_CAN_JOIN' => ($row['group_type'] == GROUP_OPEN || $row['group_type'] == GROUP_FREE) ? true : false, - 'GROUP_COLOUR' => $row['group_colour'], - - 'U_VIEW_GROUP' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&g=' . $row['group_id']), - - 'S_ROW_COUNT' => $nonmember_count++) - ); - } - $db->sql_freeresult($result); - - $template->assign_vars(array( - 'S_CHANGE_DEFAULT' => ($auth->acl_get('u_chggrp')) ? true : false, - 'S_LEADER_COUNT' => $leader_count, - 'S_MEMBER_COUNT' => $member_count, - 'S_PENDING_COUNT' => $pending_count, - 'S_NONMEMBER_COUNT' => $nonmember_count, - - 'S_UCP_ACTION' => $this->u_action) - ); - - break; - - case 'manage': - - $this->page_title = 'UCP_USERGROUPS_MANAGE'; - $action = (isset($_POST['addusers'])) ? 'addusers' : $request->variable('action', ''); - $group_id = $request->variable('g', 0); - - if (!function_exists('phpbb_get_user_rank')) - { - include($phpbb_root_path . 'includes/functions_display.' . $phpEx); - } - - add_form_key('ucp_groups'); - - if ($group_id) - { - $sql = 'SELECT g.*, t.teampage_position AS group_teampage - FROM ' . GROUPS_TABLE . ' g - LEFT JOIN ' . TEAMPAGE_TABLE . ' t - ON (t.group_id = g.group_id) - WHERE g.group_id = ' . $group_id; - $result = $db->sql_query($sql); - $group_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$group_row) - { - trigger_error($user->lang['NO_GROUP'] . $return_page); - } - - // Check if the user is allowed to manage this group if set to founder only. - if ($user->data['user_type'] != USER_FOUNDER && $group_row['group_founder_manage']) - { - trigger_error($user->lang['NOT_ALLOWED_MANAGE_GROUP'] . $return_page, E_USER_WARNING); - } - - $group_name = $group_row['group_name']; - $group_type = $group_row['group_type']; - - $avatar = phpbb_get_group_avatar($group_row, 'GROUP_AVATAR', true); - - $template->assign_vars(array( - 'GROUP_NAME' => $group_helper->get_name($group_name), - 'GROUP_INTERNAL_NAME' => $group_name, - 'GROUP_COLOUR' => (isset($group_row['group_colour'])) ? $group_row['group_colour'] : '', - 'GROUP_DESC_DISP' => generate_text_for_display($group_row['group_desc'], $group_row['group_desc_uid'], $group_row['group_desc_bitfield'], $group_row['group_desc_options']), - 'GROUP_TYPE' => $group_row['group_type'], - - 'AVATAR' => (empty($avatar) ? '' : $avatar), - 'AVATAR_IMAGE' => (empty($avatar) ? '' : $avatar), - 'AVATAR_WIDTH' => (isset($group_row['group_avatar_width'])) ? $group_row['group_avatar_width'] : '', - 'AVATAR_HEIGHT' => (isset($group_row['group_avatar_height'])) ? $group_row['group_avatar_height'] : '', - )); - } - - switch ($action) - { - case 'edit': - - if (!$group_id) - { - trigger_error($user->lang['NO_GROUP'] . $return_page); - } - - if (!($row = group_memberships($group_id, $user->data['user_id']))) - { - trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page); - } - $row = current($row); - - if (!$row['group_leader']) - { - trigger_error($user->lang['NOT_LEADER_OF_GROUP'] . $return_page); - } - - $user->add_lang(array('acp/groups', 'acp/common')); - - $update = (isset($_POST['update'])) ? true : false; - - $error = array(); - - // Setup avatar data for later - $avatars_enabled = false; - $avatar_drivers = null; - $avatar_data = null; - $avatar_error = array(); - - /** @var \phpbb\avatar\manager $phpbb_avatar_manager */ - $phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); - - if ($config['allow_avatar']) - { - $avatar_drivers = $phpbb_avatar_manager->get_enabled_drivers(); - - // This is normalised data, without the group_ prefix - $avatar_data = \phpbb\avatar\manager::clean_row($group_row, 'group'); - } - - // Handle deletion of avatars - if ($request->is_set_post('avatar_delete')) - { - if (confirm_box(true)) - { - $phpbb_avatar_manager->handle_avatar_delete($db, $user, $avatar_data, GROUPS_TABLE, 'group_'); - $cache->destroy('sql', GROUPS_TABLE); - - $message = ($action == 'edit') ? 'GROUP_UPDATED' : 'GROUP_CREATED'; - trigger_error($user->lang[$message] . $return_page); - } - else - { - confirm_box(false, $user->lang('CONFIRM_AVATAR_DELETE'), build_hidden_fields(array( - 'avatar_delete' => true, - 'i' => $id, - 'mode' => $mode, - 'g' => $group_id, - 'action' => $action)) - ); - } - } - - // Did we submit? - if ($update) - { - $group_name = $request->variable('group_name', '', true); - $group_desc = $request->variable('group_desc', '', true); - $group_type = $request->variable('group_type', GROUP_FREE); - - $allow_desc_bbcode = $request->variable('desc_parse_bbcode', false); - $allow_desc_urls = $request->variable('desc_parse_urls', false); - $allow_desc_smilies = $request->variable('desc_parse_smilies', false); - - $submit_ary = array( - 'colour' => $request->variable('group_colour', ''), - 'rank' => $request->variable('group_rank', 0), - 'receive_pm' => isset($_REQUEST['group_receive_pm']) ? 1 : 0, - 'message_limit' => $request->variable('group_message_limit', 0), - 'max_recipients'=> $request->variable('group_max_recipients', 0), - 'legend' => $group_row['group_legend'], - 'teampage' => $group_row['group_teampage'], - ); - - if (!check_form_key('ucp_groups')) - { - $error[] = $user->lang['FORM_INVALID']; - } - - if (!count($error) && $config['allow_avatar']) - { - // Handle avatar - $driver_name = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', '')); - - if (in_array($driver_name, $avatar_drivers) && !$request->is_set_post('avatar_delete')) - { - $driver = $phpbb_avatar_manager->get_driver($driver_name); - $result = $driver->process_form($request, $template, $user, $avatar_data, $avatar_error); - - if ($result && empty($avatar_error)) - { - $result['avatar_type'] = $driver_name; - - $submit_ary = array_merge($submit_ary, $result); - } - } - - // Merge any avatars errors into the primary error array - $error = array_merge($error, $phpbb_avatar_manager->localize_errors($user, $avatar_error)); - } - - // Validate submitted colour value - if ($colour_error = validate_data($submit_ary, array('colour' => array('hex_colour', true)))) - { - // Replace "error" string with its real, localised form - $error = array_merge($error, $colour_error); - } - - if (!count($error)) - { - // Only set the rank, colour, etc. if it's changed or if we're adding a new - // group. This prevents existing group members being updated if no changes - // were made. - // However there are some attributes that need to be set everytime, - // otherwise the group gets removed from the feature. - $set_attributes = array('legend', 'teampage'); - - $group_attributes = array(); - $test_variables = array( - 'rank' => 'int', - 'colour' => 'string', - 'avatar' => 'string', - 'avatar_type' => 'string', - 'avatar_width' => 'int', - 'avatar_height' => 'int', - 'receive_pm' => 'int', - 'legend' => 'int', - 'teampage' => 'int', - 'message_limit' => 'int', - 'max_recipients'=> 'int', - ); - - foreach ($test_variables as $test => $type) - { - if (isset($submit_ary[$test]) && ($action == 'add' || $group_row['group_' . $test] != $submit_ary[$test] || isset($group_attributes['group_avatar']) && strpos($test, 'avatar') === 0 || in_array($test, $set_attributes))) - { - settype($submit_ary[$test], $type); - $group_attributes['group_' . $test] = $group_row['group_' . $test] = $submit_ary[$test]; - } - } - - if (!($error = group_create($group_id, $group_type, $group_name, $group_desc, $group_attributes, $allow_desc_bbcode, $allow_desc_urls, $allow_desc_smilies))) - { - $cache->destroy('sql', GROUPS_TABLE); - $cache->destroy('sql', TEAMPAGE_TABLE); - - $message = ($action == 'edit') ? 'GROUP_UPDATED' : 'GROUP_CREATED'; - trigger_error($user->lang[$message] . $return_page); - } - } - - if (count($error)) - { - $error = array_map(array(&$user, 'lang'), $error); - $group_rank = $submit_ary['rank']; - - $group_desc_data = array( - 'text' => $group_desc, - 'allow_bbcode' => $allow_desc_bbcode, - 'allow_smilies' => $allow_desc_smilies, - 'allow_urls' => $allow_desc_urls - ); - } - } - else if (!$group_id) - { - $group_desc_data = array( - 'text' => '', - 'allow_bbcode' => true, - 'allow_smilies' => true, - 'allow_urls' => true - ); - $group_rank = 0; - $group_type = GROUP_OPEN; - } - else - { - $group_desc_data = generate_text_for_edit($group_row['group_desc'], $group_row['group_desc_uid'], $group_row['group_desc_options']); - $group_rank = $group_row['group_rank']; - } - - $sql = 'SELECT * - FROM ' . RANKS_TABLE . ' - WHERE rank_special = 1 - ORDER BY rank_title'; - $result = $db->sql_query($sql); - - $rank_options = ''; - while ($row = $db->sql_fetchrow($result)) - { - $selected = ($group_rank && $row['rank_id'] == $group_rank) ? ' selected="selected"' : ''; - $rank_options .= ''; - } - $db->sql_freeresult($result); - - $type_free = ($group_type == GROUP_FREE) ? ' checked="checked"' : ''; - $type_open = ($group_type == GROUP_OPEN) ? ' checked="checked"' : ''; - $type_closed = ($group_type == GROUP_CLOSED) ? ' checked="checked"' : ''; - $type_hidden = ($group_type == GROUP_HIDDEN) ? ' checked="checked"' : ''; - - // Load up stuff for avatars - if ($config['allow_avatar']) - { - $avatars_enabled = false; - $selected_driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', $avatar_data['avatar_type'])); - - // Assign min and max values before generating avatar driver html - $template->assign_vars(array( - 'AVATAR_MIN_WIDTH' => $config['avatar_min_width'], - 'AVATAR_MAX_WIDTH' => $config['avatar_max_width'], - 'AVATAR_MIN_HEIGHT' => $config['avatar_min_height'], - 'AVATAR_MAX_HEIGHT' => $config['avatar_max_height'], - )); - - foreach ($avatar_drivers as $current_driver) - { - $driver = $phpbb_avatar_manager->get_driver($current_driver); - - $avatars_enabled = true; - $template->set_filenames(array( - 'avatar' => $driver->get_template_name(), - )); - - if ($driver->prepare_form($request, $template, $user, $avatar_data, $avatar_error)) - { - $driver_name = $phpbb_avatar_manager->prepare_driver_name($current_driver); - $driver_upper = strtoupper($driver_name); - $template->assign_block_vars('avatar_drivers', array( - 'L_TITLE' => $user->lang($driver_upper . '_TITLE'), - 'L_EXPLAIN' => $user->lang($driver_upper . '_EXPLAIN'), - - 'DRIVER' => $driver_name, - 'SELECTED' => $current_driver == $selected_driver, - 'OUTPUT' => $template->assign_display('avatar'), - )); - } - } - } - - if (isset($phpbb_avatar_manager) && !$update) - { - // Merge any avatars errors into the primary error array - $error = array_merge($error, $phpbb_avatar_manager->localize_errors($user, $avatar_error)); - } - - $template->assign_vars(array( - 'S_EDIT' => true, - 'S_INCLUDE_SWATCH' => true, - 'S_FORM_ENCTYPE' => ' enctype="multipart/form-data"', - 'S_ERROR' => (count($error)) ? true : false, - 'S_SPECIAL_GROUP' => ($group_type == GROUP_SPECIAL) ? true : false, - 'S_AVATARS_ENABLED' => ($config['allow_avatar'] && $avatars_enabled), - 'S_GROUP_MANAGE' => true, - - 'ERROR_MSG' => (count($error)) ? implode('
', $error) : '', - 'GROUP_RECEIVE_PM' => (isset($group_row['group_receive_pm']) && $group_row['group_receive_pm']) ? ' checked="checked"' : '', - 'GROUP_MESSAGE_LIMIT' => (isset($group_row['group_message_limit'])) ? $group_row['group_message_limit'] : 0, - 'GROUP_MAX_RECIPIENTS' => (isset($group_row['group_max_recipients'])) ? $group_row['group_max_recipients'] : 0, - - 'GROUP_DESC' => $group_desc_data['text'], - 'S_DESC_BBCODE_CHECKED' => $group_desc_data['allow_bbcode'], - 'S_DESC_URLS_CHECKED' => $group_desc_data['allow_urls'], - 'S_DESC_SMILIES_CHECKED'=> $group_desc_data['allow_smilies'], - - 'S_RANK_OPTIONS' => $rank_options, - - 'GROUP_TYPE_FREE' => GROUP_FREE, - 'GROUP_TYPE_OPEN' => GROUP_OPEN, - 'GROUP_TYPE_CLOSED' => GROUP_CLOSED, - 'GROUP_TYPE_HIDDEN' => GROUP_HIDDEN, - 'GROUP_TYPE_SPECIAL' => GROUP_SPECIAL, - - 'GROUP_FREE' => $type_free, - 'GROUP_OPEN' => $type_open, - 'GROUP_CLOSED' => $type_closed, - 'GROUP_HIDDEN' => $type_hidden, - - 'S_UCP_ACTION' => $this->u_action . "&action=$action&g=$group_id", - 'L_AVATAR_EXPLAIN' => phpbb_avatar_explanation_string(), - )); - - break; - - case 'list': - - if (!$group_id) - { - trigger_error($user->lang['NO_GROUP'] . $return_page); - } - - if (!($row = group_memberships($group_id, $user->data['user_id']))) - { - trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page); - } - $row = current($row); - - if (!$row['group_leader']) - { - trigger_error($user->lang['NOT_LEADER_OF_GROUP'] . $return_page); - } - - $user->add_lang(array('acp/groups', 'acp/common')); - $start = $request->variable('start', 0); - - // Grab the leaders - always, on every page... - $sql = 'SELECT u.user_id, u.username, u.username_clean, u.user_colour, u.user_regdate, u.user_posts, u.group_id, ug.group_leader, ug.user_pending - FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . " ug - WHERE ug.group_id = $group_id - AND u.user_id = ug.user_id - AND ug.group_leader = 1 - ORDER BY ug.user_pending DESC, u.username_clean"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $template->assign_block_vars('leader', array( - 'USERNAME' => $row['username'], - 'USERNAME_COLOUR' => $row['user_colour'], - 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), - 'U_USER_VIEW' => get_username_string('profile', $row['user_id'], $row['username']), - 'S_GROUP_DEFAULT' => ($row['group_id'] == $group_id) ? true : false, - 'JOINED' => ($row['user_regdate']) ? $user->format_date($row['user_regdate']) : ' - ', - 'USER_POSTS' => $row['user_posts'], - 'USER_ID' => $row['user_id']) - ); - } - $db->sql_freeresult($result); - - // Total number of group members (non-leaders) - $sql = 'SELECT COUNT(user_id) AS total_members - FROM ' . USER_GROUP_TABLE . " - WHERE group_id = $group_id - AND group_leader = 0"; - $result = $db->sql_query($sql); - $total_members = (int) $db->sql_fetchfield('total_members'); - $db->sql_freeresult($result); - - // Grab the members - $sql = 'SELECT u.user_id, u.username, u.username_clean, u.user_colour, u.user_regdate, u.user_posts, u.group_id, ug.group_leader, ug.user_pending - FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . " ug - WHERE ug.group_id = $group_id - AND u.user_id = ug.user_id - AND ug.group_leader = 0 - ORDER BY ug.user_pending DESC, u.username_clean"; - $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); - - $pending = false; - $approved = false; - - while ($row = $db->sql_fetchrow($result)) - { - if ($row['user_pending'] && !$pending) - { - $template->assign_block_vars('member', array( - 'S_PENDING' => true) - ); - $template->assign_var('S_PENDING_SET', true); - - $pending = true; - } - else if (!$row['user_pending'] && !$approved) - { - $template->assign_block_vars('member', array( - 'S_APPROVED' => true) - ); - $template->assign_var('S_APPROVED_SET', true); - - $approved = true; - } - - $template->assign_block_vars('member', array( - 'USERNAME' => $row['username'], - 'USERNAME_COLOUR' => $row['user_colour'], - 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), - 'U_USER_VIEW' => get_username_string('profile', $row['user_id'], $row['username']), - 'S_GROUP_DEFAULT' => ($row['group_id'] == $group_id) ? true : false, - 'JOINED' => ($row['user_regdate']) ? $user->format_date($row['user_regdate']) : ' - ', - 'USER_POSTS' => $row['user_posts'], - 'USER_ID' => $row['user_id']) - ); - } - $db->sql_freeresult($result); - - $s_action_options = ''; - $options = array('default' => 'DEFAULT', 'approve' => 'APPROVE', 'deleteusers' => 'DELETE'); - - foreach ($options as $option => $lang) - { - $s_action_options .= ''; - } - - /* @var $pagination \phpbb\pagination */ - $pagination = $phpbb_container->get('pagination'); - $base_url = $this->u_action . "&action=$action&g=$group_id"; - $start = $pagination->validate_start($start, $config['topics_per_page'], $total_members); - $pagination->generate_template_pagination($base_url, 'pagination', 'start', $total_members, $config['topics_per_page'], $start); - - $template->assign_vars(array( - 'S_LIST' => true, - 'S_ACTION_OPTIONS' => $s_action_options, - - 'U_ACTION' => $this->u_action . "&g=$group_id", - 'S_UCP_ACTION' => $this->u_action . "&g=$group_id", - 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=ucp&field=usernames'), - )); - - break; - - case 'approve': - - if (!$group_id) - { - trigger_error($user->lang['NO_GROUP'] . $return_page); - } - - if (!check_form_key('ucp_groups')) - { - trigger_error($user->lang('FORM_INVALID') . $return_page); - } - - if (!($row = group_memberships($group_id, $user->data['user_id']))) - { - trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page); - } - $row = current($row); - - if (!$row['group_leader']) - { - trigger_error($user->lang['NOT_LEADER_OF_GROUP'] . $return_page); - } - - $user->add_lang('acp/groups'); - - // Approve, demote or promote - group_user_attributes('approve', $group_id, $mark_ary, false, false); - - trigger_error($user->lang['USERS_APPROVED'] . '

' . sprintf($user->lang['RETURN_PAGE'], '', '')); - - break; - - case 'default': - - if (!$group_id) - { - trigger_error($user->lang['NO_GROUP'] . $return_page); - } - - if (!($row = group_memberships($group_id, $user->data['user_id']))) - { - trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page); - } - $row = current($row); - - if (!$row['group_leader']) - { - trigger_error($user->lang['NOT_LEADER_OF_GROUP'] . $return_page); - } - - $group_row['group_name'] = $group_helper->get_name($group_row['group_name']); - - if (confirm_box(true)) - { - if (!count($mark_ary)) - { - $start = 0; - - do - { - $sql = 'SELECT user_id - FROM ' . USER_GROUP_TABLE . " - WHERE group_id = $group_id - ORDER BY user_id"; - $result = $db->sql_query_limit($sql, 200, $start); - - $mark_ary = array(); - if ($row = $db->sql_fetchrow($result)) - { - do - { - $mark_ary[] = $row['user_id']; - } - while ($row = $db->sql_fetchrow($result)); - - group_user_attributes('default', $group_id, $mark_ary, false, $group_row['group_name'], $group_row); - - $start = (count($mark_ary) < 200) ? 0 : $start + 200; - } - else - { - $start = 0; - } - $db->sql_freeresult($result); - } - while ($start); - } - else - { - group_user_attributes('default', $group_id, $mark_ary, false, $group_row['group_name'], $group_row); - } - - $user->add_lang('acp/groups'); - - trigger_error($user->lang['GROUP_DEFS_UPDATED'] . '

' . sprintf($user->lang['RETURN_PAGE'], '', '')); - } - else - { - $user->add_lang('acp/common'); - - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( - 'mark' => $mark_ary, - 'g' => $group_id, - 'i' => $id, - 'mode' => $mode, - 'action' => $action)) - ); - } - - // redirect to last screen - redirect($this->u_action . '&action=list&g=' . $group_id); - - break; - - case 'deleteusers': - - $user->add_lang(array('acp/groups', 'acp/common')); - - if (!($row = group_memberships($group_id, $user->data['user_id']))) - { - trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page); - } - $row = current($row); - - if (!$row['group_leader']) - { - trigger_error($user->lang['NOT_LEADER_OF_GROUP'] . $return_page); - } - - $group_row['group_name'] = $group_helper->get_name($group_row['group_name']); - - if (confirm_box(true)) - { - if (!$group_id) - { - trigger_error($user->lang['NO_GROUP'] . $return_page); - } - - $error = group_user_del($group_id, $mark_ary, false, $group_row['group_name']); - - if ($error) - { - trigger_error($user->lang[$error] . '

' . sprintf($user->lang['RETURN_PAGE'], '', '')); - } - - trigger_error($user->lang['GROUP_USERS_REMOVE'] . '

' . sprintf($user->lang['RETURN_PAGE'], '', '')); - } - else - { - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( - 'mark' => $mark_ary, - 'g' => $group_id, - 'i' => $id, - 'mode' => $mode, - 'action' => $action)) - ); - } - - // redirect to last screen - redirect($this->u_action . '&action=list&g=' . $group_id); - - break; - - case 'addusers': - - $user->add_lang(array('acp/groups', 'acp/common')); - - $names = $request->variable('usernames', '', true); - - if (!$group_id) - { - trigger_error($user->lang['NO_GROUP'] . $return_page); - } - - if (!$names) - { - trigger_error($user->lang['NO_USERS'] . $return_page); - } - - if (!($row = group_memberships($group_id, $user->data['user_id']))) - { - trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page); - } - $row = current($row); - - if (!$row['group_leader']) - { - trigger_error($user->lang['NOT_LEADER_OF_GROUP'] . $return_page); - } - - $name_ary = array_unique(explode("\n", $names)); - $group_name = $group_helper->get_name($group_row['group_name']); - - $default = $request->variable('default', 0); - - if (confirm_box(true)) - { - $return_manage_page = '

' . $language->lang('RETURN_PAGE', '', ''); - - // Add user/s to group - if ($error = group_user_add($group_id, false, $name_ary, $group_name, $default, 0, 0, $group_row)) - { - $display_message = $language->lang($error); - - if ($error == 'GROUP_USERS_INVALID') - { - // Find which users don't exist - $actual_name_ary = $name_ary; - $actual_user_id_ary = []; - user_get_id_name($actual_user_id_ary, $actual_name_ary, false, true); - - $display_message = $language->lang('GROUP_USERS_INVALID', implode($language->lang('COMMA_SEPARATOR'), array_udiff($name_ary, $actual_name_ary, 'strcasecmp'))); - } - - trigger_error($display_message . $return_manage_page); - } - - trigger_error($language->lang('GROUP_USERS_ADDED') . $return_manage_page); - } - else - { - $s_hidden_fields = array( - 'default' => $default, - 'usernames' => $names, - 'g' => $group_id, - 'i' => $id, - 'mode' => $mode, - 'action' => $action - ); - - confirm_box(false, $user->lang('GROUP_CONFIRM_ADD_USERS', count($name_ary), implode($user->lang['COMMA_SEPARATOR'], $name_ary)), build_hidden_fields($s_hidden_fields)); - } - - trigger_error($user->lang['NO_USERS_ADDED'] . '

' . sprintf($user->lang['RETURN_PAGE'], '', '')); - - break; - - default: - $user->add_lang('acp/common'); - - $sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_desc, g.group_desc_uid, g.group_desc_bitfield, g.group_desc_options, g.group_type, ug.group_leader - FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . ' ug - WHERE ug.user_id = ' . $user->data['user_id'] . ' - AND g.group_id = ug.group_id - AND ug.group_leader = 1 - ORDER BY g.group_type DESC, g.group_name'; - $result = $db->sql_query($sql); - - while ($value = $db->sql_fetchrow($result)) - { - $template->assign_block_vars('leader', array( - 'GROUP_NAME' => $group_helper->get_name($value['group_name']), - 'GROUP_DESC' => generate_text_for_display($value['group_desc'], $value['group_desc_uid'], $value['group_desc_bitfield'], $value['group_desc_options']), - 'GROUP_TYPE' => $value['group_type'], - 'GROUP_ID' => $value['group_id'], - 'GROUP_COLOUR' => $value['group_colour'], - - 'U_LIST' => $this->u_action . "&action=list&g={$value['group_id']}", - 'U_EDIT' => $this->u_action . "&action=edit&g={$value['group_id']}") - ); - } - $db->sql_freeresult($result); - - break; - } - - break; - } - - $this->tpl_name = 'ucp_groups_' . $mode; - } -} diff --git a/install/update/new/includes/ucp/ucp_pm.php b/install/update/new/includes/ucp/ucp_pm.php deleted file mode 100644 index 00d1ce7..0000000 --- a/install/update/new/includes/ucp/ucp_pm.php +++ /dev/null @@ -1,442 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* Private Message Class -* -* $_REQUEST['folder'] display folder with the id used -* $_REQUEST['folder'] inbox|outbox|sentbox display folder with the associated name -* -* Display Messages (default to inbox) - mode=view -* Display single message - mode=view&p=[msg_id] or &p=[msg_id] (short linkage) -* -* if the folder id with (&f=[folder_id]) is used when displaying messages, one query will be saved. If it is not used, phpBB needs to grab -* the folder id first in order to display the input boxes and folder names and such things. ;) phpBB always checks this against the database to make -* sure the user is able to view the message. -* -* Composing Messages (mode=compose): -* To specific user (u=[user_id]) -* To specific group (g=[group_id]) -* Quoting a post (action=quotepost&p=[post_id]) -* Quoting a PM (action=quote&p=[msg_id]) -* Forwarding a PM (action=forward&p=[msg_id]) -*/ -class ucp_pm -{ - var $u_action; - - function main($id, $mode) - { - global $user, $template, $phpbb_root_path, $auth, $phpEx, $db, $config, $request; - - if (!$user->data['is_registered']) - { - trigger_error('NO_MESSAGE'); - } - - // Is PM disabled? - if (!$config['allow_privmsg']) - { - trigger_error('PM_DISABLED'); - } - - $user->add_lang('posting'); - $template->assign_var('S_PRIVMSGS', true); - - // Folder directly specified? - $folder_specified = $request->variable('folder', ''); - - if (!in_array($folder_specified, array('inbox', 'outbox', 'sentbox'))) - { - $folder_specified = (int) $folder_specified; - } - else - { - $folder_specified = ($folder_specified == 'inbox') ? PRIVMSGS_INBOX : (($folder_specified == 'outbox') ? PRIVMSGS_OUTBOX : PRIVMSGS_SENTBOX); - } - - if (!$folder_specified) - { - $mode = (!$mode) ? $request->variable('mode', 'view') : $mode; - } - else - { - $mode = 'view'; - } - - if (!function_exists('get_folder')) - { - include($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx); - } - - switch ($mode) - { - // Compose message - case 'compose': - $action = $request->variable('action', 'post'); - - $user_folders = get_folder($user->data['user_id']); - - if ($action != 'delete' && !$auth->acl_get('u_sendpm')) - { - // trigger_error('NO_AUTH_SEND_MESSAGE'); - $template->assign_vars(array( - 'S_NO_AUTH_SEND_MESSAGE' => true, - 'S_COMPOSE_PM_VIEW' => true, - )); - - $tpl_file = 'ucp_pm_viewfolder'; - break; - } - - if (!function_exists('compose_pm')) - { - include($phpbb_root_path . 'includes/ucp/ucp_pm_compose.' . $phpEx); - } - compose_pm($id, $mode, $action, $user_folders); - - $tpl_file = 'posting_body'; - break; - - case 'options': - set_user_message_limit(); - get_folder($user->data['user_id']); - - if (!function_exists('message_options')) - { - include($phpbb_root_path . 'includes/ucp/ucp_pm_options.' . $phpEx); - } - message_options($id, $mode, $global_privmsgs_rules, $global_rule_conditions); - - $tpl_file = 'ucp_pm_options'; - break; - - case 'drafts': - - get_folder($user->data['user_id']); - $this->p_name = 'pm'; - - if (!class_exists('ucp_main')) - { - include($phpbb_root_path . 'includes/ucp/ucp_main.' . $phpEx); - } - - $module = new ucp_main($this); - $module->u_action = $this->u_action; - $module->main($id, $mode); - - $this->tpl_name = $module->tpl_name; - $this->page_title = 'UCP_PM_DRAFTS'; - - unset($module); - return; - - break; - - case 'view': - - set_user_message_limit(); - - if ($folder_specified) - { - $folder_id = $folder_specified; - $action = 'view_folder'; - } - else - { - $folder_id = $request->variable('f', PRIVMSGS_NO_BOX); - $action = $request->variable('action', 'view_folder'); - } - - $msg_id = $request->variable('p', 0); - $view = $request->variable('view', ''); - - // View message if specified - if ($msg_id) - { - $action = 'view_message'; - } - - if (!$auth->acl_get('u_readpm')) - { - send_status_line(403, 'Forbidden'); - trigger_error('NO_AUTH_READ_MESSAGE'); - } - - if ($view == 'print' && (!$config['print_pm'] || !$auth->acl_get('u_pm_printpm'))) - { - send_status_line(403, 'Forbidden'); - trigger_error('NO_AUTH_PRINT_MESSAGE'); - } - - // Do not allow hold messages to be seen - if ($folder_id == PRIVMSGS_HOLD_BOX) - { - trigger_error('NO_AUTH_READ_HOLD_MESSAGE'); - } - - add_form_key('ucp_pm_view'); - - // First Handle Mark actions and moving messages - $submit_mark = (isset($_POST['submit_mark'])) ? true : false; - $move_pm = (isset($_POST['move_pm'])) ? true : false; - $mark_option = $request->variable('mark_option', ''); - $dest_folder = $request->variable('dest_folder', PRIVMSGS_NO_BOX); - - // Is moving PM triggered through mark options? - if (!in_array($mark_option, array('mark_important', 'delete_marked')) && $submit_mark) - { - $move_pm = true; - $dest_folder = (int) $mark_option; - $submit_mark = false; - } - - if (($move_pm || $submit_mark) && !check_form_key('ucp_pm_view')) - { - trigger_error('FORM_INVALID'); - } - - // Move PM - if ($move_pm) - { - $move_msg_ids = (isset($_POST['marked_msg_id'])) ? $request->variable('marked_msg_id', array(0)) : array(); - $cur_folder_id = $request->variable('cur_folder_id', PRIVMSGS_NO_BOX); - - if (move_pm($user->data['user_id'], $user->data['message_limit'], $move_msg_ids, $dest_folder, $cur_folder_id)) - { - // Return to folder view if single message moved - if ($action == 'view_message') - { - $msg_id = 0; - $folder_id = $request->variable('cur_folder_id', PRIVMSGS_NO_BOX); - $action = 'view_folder'; - } - } - } - - // Message Mark Options - if ($submit_mark) - { - handle_mark_actions($user->data['user_id'], $mark_option); - } - - // If new messages arrived, place them into the appropriate folder - $num_not_moved = $num_removed = 0; - $release = $request->variable('release', 0); - - if ($user->data['user_new_privmsg'] && ($action == 'view_folder' || $action == 'view_message')) - { - $return = place_pm_into_folder($global_privmsgs_rules, $release); - $num_not_moved = $return['not_moved']; - $num_removed = $return['removed']; - } - - if (!$msg_id && $folder_id == PRIVMSGS_NO_BOX) - { - $folder_id = PRIVMSGS_INBOX; - } - else if ($msg_id && $folder_id == PRIVMSGS_NO_BOX) - { - $sql = 'SELECT folder_id - FROM ' . PRIVMSGS_TO_TABLE . " - WHERE msg_id = $msg_id - AND folder_id <> " . PRIVMSGS_NO_BOX . ' - AND user_id = ' . $user->data['user_id']; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - trigger_error('NO_MESSAGE'); - } - $folder_id = (int) $row['folder_id']; - } - - if ($request->variable('mark', '') == 'all' && check_link_hash($request->variable('token', ''), 'mark_all_pms_read')) - { - mark_folder_read($user->data['user_id'], $folder_id); - - meta_refresh(3, $this->u_action); - $message = $user->lang['PM_MARK_ALL_READ_SUCCESS']; - - if ($request->is_ajax()) - { - $json_response = new \phpbb\json_response(); - $json_response->send(array( - 'MESSAGE_TITLE' => $user->lang['INFORMATION'], - 'MESSAGE_TEXT' => $message, - 'success' => true, - )); - } - $message .= '

' . $user->lang('RETURN_UCP', '', ''); - - trigger_error($message); - } - - $message_row = array(); - if ($action == 'view_message' && $msg_id) - { - // Get Message user want to see - if ($view == 'next' || $view == 'previous') - { - $sql_condition = ($view == 'next') ? '>' : '<'; - $sql_ordering = ($view == 'next') ? 'ASC' : 'DESC'; - - $sql = 'SELECT t.msg_id - FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p, ' . PRIVMSGS_TABLE . " p2 - WHERE p2.msg_id = $msg_id - AND t.folder_id = $folder_id - AND t.user_id = " . $user->data['user_id'] . " - AND t.msg_id = p.msg_id - AND p.message_time $sql_condition p2.message_time - ORDER BY p.message_time $sql_ordering"; - $result = $db->sql_query_limit($sql, 1); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - $message = ($view == 'next') ? 'NO_NEWER_PM' : 'NO_OLDER_PM'; - trigger_error($message); - } - else - { - $msg_id = $row['msg_id']; - } - } - - $sql = 'SELECT t.*, p.*, u.* - FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p, ' . USERS_TABLE . ' u - WHERE t.user_id = ' . $user->data['user_id'] . " - AND p.author_id = u.user_id - AND t.folder_id = $folder_id - AND t.msg_id = p.msg_id - AND p.msg_id = $msg_id"; - $result = $db->sql_query($sql); - $message_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$message_row) - { - trigger_error('NO_MESSAGE'); - } - - // Update unread status - update_unread_status($message_row['pm_unread'], $message_row['msg_id'], $user->data['user_id'], $folder_id); - } - - $folder = get_folder($user->data['user_id'], $folder_id); - - $s_folder_options = $s_to_folder_options = ''; - foreach ($folder as $f_id => $folder_ary) - { - $option = '' . $folder_ary['folder_name'] . (($folder_ary['unread_messages']) ? ' [' . $folder_ary['unread_messages'] . '] ' : '') . ''; - - $s_to_folder_options .= ($f_id != PRIVMSGS_OUTBOX && $f_id != PRIVMSGS_SENTBOX) ? $option : ''; - $s_folder_options .= $option; - } - clean_sentbox($folder[PRIVMSGS_SENTBOX]['num_messages']); - - // Header for message view - folder and so on - $folder_status = get_folder_status($folder_id, $folder); - - $template->assign_vars(array( - 'CUR_FOLDER_ID' => $folder_id, - 'CUR_FOLDER_NAME' => $folder_status['folder_name'], - 'NUM_NOT_MOVED' => $num_not_moved, - 'NUM_REMOVED' => $num_removed, - 'RELEASE_MESSAGE_INFO' => sprintf($user->lang['RELEASE_MESSAGES'], '', ''), - 'NOT_MOVED_MESSAGES' => $user->lang('NOT_MOVED_MESSAGES', (int) $num_not_moved), - 'RULE_REMOVED_MESSAGES' => $user->lang('RULE_REMOVED_MESSAGES', (int) $num_removed), - - 'S_FOLDER_OPTIONS' => $s_folder_options, - 'S_TO_FOLDER_OPTIONS' => $s_to_folder_options, - 'S_FOLDER_ACTION' => $this->u_action . '&action=view_folder', - 'S_PM_ACTION' => $this->u_action . '&action=' . $action, - - 'U_INBOX' => $this->u_action . '&folder=inbox', - 'U_OUTBOX' => $this->u_action . '&folder=outbox', - 'U_SENTBOX' => $this->u_action . '&folder=sentbox', - 'U_CREATE_FOLDER' => $this->u_action . '&mode=options', - 'U_CURRENT_FOLDER' => $this->u_action . '&folder=' . $folder_id, - 'U_MARK_ALL' => $this->u_action . '&folder=' . $folder_id . '&mark=all&token=' . generate_link_hash('mark_all_pms_read'), - - 'S_IN_INBOX' => ($folder_id == PRIVMSGS_INBOX) ? true : false, - 'S_IN_OUTBOX' => ($folder_id == PRIVMSGS_OUTBOX) ? true : false, - 'S_IN_SENTBOX' => ($folder_id == PRIVMSGS_SENTBOX) ? true : false, - - 'FOLDER_STATUS' => $folder_status['message'], - 'FOLDER_MAX_MESSAGES' => $folder_status['max'], - 'FOLDER_CUR_MESSAGES' => $folder_status['cur'], - 'FOLDER_REMAINING_MESSAGES' => $folder_status['remaining'], - 'FOLDER_PERCENT' => $folder_status['percent']) - ); - - if ($action == 'view_folder') - { - if (!function_exists('view_folder')) - { - include($phpbb_root_path . 'includes/ucp/ucp_pm_viewfolder.' . $phpEx); - } - view_folder($id, $mode, $folder_id, $folder); - - $tpl_file = 'ucp_pm_viewfolder'; - } - else if ($action == 'view_message') - { - $template->assign_vars(array( - 'S_VIEW_MESSAGE' => true, - 'L_RETURN_TO_FOLDER' => $user->lang('RETURN_TO', $folder_status['folder_name']), - 'MSG_ID' => $msg_id, - )); - - if (!$msg_id) - { - trigger_error('NO_MESSAGE'); - } - - if (!function_exists('view_message')) - { - include($phpbb_root_path . 'includes/ucp/ucp_pm_viewmessage.' . $phpEx); - } - view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row); - - $tpl_file = ($view == 'print') ? 'ucp_pm_viewmessage_print' : 'ucp_pm_viewmessage'; - } - - break; - - default: - trigger_error('NO_ACTION_MODE', E_USER_ERROR); - break; - } - - $template->assign_vars(array( - 'L_TITLE' => $user->lang['UCP_PM_' . strtoupper($mode)], - 'S_UCP_ACTION' => $this->u_action . ((isset($action)) ? "&action=$action" : '')) - ); - - // Set desired template - $this->tpl_name = $tpl_file; - $this->page_title = 'UCP_PM_' . strtoupper($mode); - } -} diff --git a/install/update/new/includes/ucp/ucp_pm_compose.php b/install/update/new/includes/ucp/ucp_pm_compose.php deleted file mode 100644 index 87a8c91..0000000 --- a/install/update/new/includes/ucp/ucp_pm_compose.php +++ /dev/null @@ -1,1562 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* Compose private message -* Called from ucp_pm with mode == 'compose' -*/ -function compose_pm($id, $mode, $action, $user_folders = array()) -{ - global $template, $db, $auth, $user, $cache; - global $phpbb_root_path, $phpEx, $config, $language; - global $request, $phpbb_dispatcher, $phpbb_container; - - // Damn php and globals - i know, this is horrible - // Needed for handle_message_list_actions() - global $refresh, $submit, $preview; - - if (!function_exists('generate_smilies')) - { - include($phpbb_root_path . 'includes/functions_posting.' . $phpEx); - } - - if (!function_exists('display_custom_bbcodes')) - { - include($phpbb_root_path . 'includes/functions_display.' . $phpEx); - } - - if (!class_exists('parse_message')) - { - include($phpbb_root_path . 'includes/message_parser.' . $phpEx); - } - - if (!$action) - { - $action = 'post'; - } - add_form_key('ucp_pm_compose'); - - // Grab only parameters needed here - $to_user_id = $request->variable('u', 0); - $to_group_id = $request->variable('g', 0); - $msg_id = $request->variable('p', 0); - $draft_id = $request->variable('d', 0); - - // Reply to all triggered (quote/reply) - $reply_to_all = $request->variable('reply_to_all', 0); - - $address_list = $request->variable('address_list', array('' => array(0 => ''))); - - $preview = (isset($_POST['preview'])) ? true : false; - $save = (isset($_POST['save'])) ? true : false; - $load = (isset($_POST['load'])) ? true : false; - $cancel = (isset($_POST['cancel']) && !isset($_POST['save'])) ? true : false; - $delete = (isset($_POST['delete'])) ? true : false; - - $remove_u = (isset($_REQUEST['remove_u'])) ? true : false; - $remove_g = (isset($_REQUEST['remove_g'])) ? true : false; - $add_to = (isset($_REQUEST['add_to'])) ? true : false; - $add_bcc = (isset($_REQUEST['add_bcc'])) ? true : false; - - $refresh = isset($_POST['add_file']) || isset($_POST['delete_file']) || $save || $load - || $remove_u || $remove_g || $add_to || $add_bcc; - $submit = $request->is_set_post('post') && !$refresh && !$preview; - - $action = ($delete && !$preview && !$refresh && $submit) ? 'delete' : $action; - $select_single = ($config['allow_mass_pm'] && $auth->acl_get('u_masspm')) ? false : true; - - $error = array(); - $current_time = time(); - - /** @var \phpbb\group\helper $group_helper */ - $group_helper = $phpbb_container->get('group_helper'); - - // Was cancel pressed? If so then redirect to the appropriate page - if ($cancel) - { - if ($msg_id) - { - redirect(append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=view&action=view_message&p=' . $msg_id)); - } - redirect(append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm')); - } - - // Since viewtopic.php language entries are used in several modes, - // we include the language file here - $user->add_lang('viewtopic'); - - /** - * Modify the default vars before composing a PM - * - * @event core.ucp_pm_compose_modify_data - * @var int msg_id post_id in the page request - * @var int to_user_id The id of whom the message is to - * @var int to_group_id The id of the group the message is to - * @var bool submit Whether the form has been submitted - * @var bool preview Whether the user is previewing the PM or not - * @var string action One of: post, reply, quote, forward, quotepost, edit, delete, smilies - * @var bool delete Whether the user is deleting the PM - * @var int reply_to_all Value of reply_to_all request variable. - * @since 3.1.4-RC1 - */ - $vars = array( - 'msg_id', - 'to_user_id', - 'to_group_id', - 'submit', - 'preview', - 'action', - 'delete', - 'reply_to_all', - ); - extract($phpbb_dispatcher->trigger_event('core.ucp_pm_compose_modify_data', compact($vars))); - - // Output PM_TO box if message composing - if ($action != 'edit') - { - // Add groups to PM box - if ($config['allow_mass_pm'] && $auth->acl_get('u_masspm_group')) - { - $sql = 'SELECT g.group_id, g.group_name, g.group_type, g.group_colour - FROM ' . GROUPS_TABLE . ' g'; - - if (!$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) - { - $sql .= ' LEFT JOIN ' . USER_GROUP_TABLE . ' ug - ON ( - g.group_id = ug.group_id - AND ug.user_id = ' . $user->data['user_id'] . ' - AND ug.user_pending = 0 - ) - WHERE (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $user->data['user_id'] . ')'; - } - - $sql .= ($auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) ? ' WHERE ' : ' AND '; - - $sql .= 'g.group_receive_pm = 1 - ORDER BY g.group_type DESC, g.group_name ASC'; - $result = $db->sql_query($sql); - - $group_options = ''; - while ($row = $db->sql_fetchrow($result)) - { - $group_options .= '' . $group_helper->get_name($row['group_name']) . ''; - } - $db->sql_freeresult($result); - } - - $template->assign_vars(array( - 'S_SHOW_PM_BOX' => true, - 'S_ALLOW_MASS_PM' => ($config['allow_mass_pm'] && $auth->acl_get('u_masspm')) ? true : false, - 'S_GROUP_OPTIONS' => ($config['allow_mass_pm'] && $auth->acl_get('u_masspm_group')) ? $group_options : '', - 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=searchuser&form=postform&field=username_list&select_single=" . (int) $select_single), - )); - } - - $sql = ''; - $folder_id = 0; - - // What is all this following SQL for? Well, we need to know - // some basic information in all cases before we do anything. - switch ($action) - { - case 'post': - if (!$auth->acl_get('u_sendpm')) - { - send_status_line(403, 'Forbidden'); - trigger_error('NO_AUTH_SEND_MESSAGE'); - } - break; - - case 'reply': - case 'quote': - case 'forward': - case 'quotepost': - if (!$msg_id) - { - trigger_error('NO_MESSAGE'); - } - - if (!$auth->acl_get('u_sendpm')) - { - send_status_line(403, 'Forbidden'); - trigger_error('NO_AUTH_SEND_MESSAGE'); - } - - if ($action == 'quotepost') - { - $sql = 'SELECT p.post_id as msg_id, p.forum_id, p.post_text as message_text, p.poster_id as author_id, p.post_time as message_time, p.bbcode_bitfield, p.bbcode_uid, p.enable_sig, p.enable_smilies, p.enable_magic_url, t.topic_title as message_subject, u.username as quote_username - FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . " u - WHERE p.post_id = $msg_id - AND t.topic_id = p.topic_id - AND u.user_id = p.poster_id"; - } - else - { - $sql = 'SELECT t.folder_id, p.*, u.username as quote_username - FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p, ' . USERS_TABLE . ' u - WHERE t.user_id = ' . $user->data['user_id'] . " - AND p.author_id = u.user_id - AND t.msg_id = p.msg_id - AND p.msg_id = $msg_id"; - } - break; - - case 'edit': - if (!$msg_id) - { - trigger_error('NO_MESSAGE'); - } - - // check for outbox (not read) status, we do not allow editing if one user already having the message - $sql = 'SELECT p.*, t.folder_id - FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p - WHERE t.user_id = ' . $user->data['user_id'] . ' - AND t.folder_id = ' . PRIVMSGS_OUTBOX . " - AND t.msg_id = $msg_id - AND t.msg_id = p.msg_id"; - break; - - case 'delete': - if (!$auth->acl_get('u_pm_delete')) - { - send_status_line(403, 'Forbidden'); - trigger_error('NO_AUTH_DELETE_MESSAGE'); - } - - if (!$msg_id) - { - trigger_error('NO_MESSAGE'); - } - - $sql = 'SELECT msg_id, pm_unread, pm_new, author_id, folder_id - FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE user_id = ' . $user->data['user_id'] . " - AND msg_id = $msg_id"; - break; - - case 'smilies': - generate_smilies('window', 0); - break; - - default: - trigger_error('NO_ACTION_MODE', E_USER_ERROR); - break; - } - - if ($action == 'forward' && (!$config['forward_pm'] || !$auth->acl_get('u_pm_forward'))) - { - send_status_line(403, 'Forbidden'); - trigger_error('NO_AUTH_FORWARD_MESSAGE'); - } - - if ($action == 'edit' && !$auth->acl_get('u_pm_edit')) - { - send_status_line(403, 'Forbidden'); - trigger_error('NO_AUTH_EDIT_MESSAGE'); - } - - if ($sql) - { - /** - * Alter sql query to get message for user to write the PM - * - * @event core.ucp_pm_compose_compose_pm_basic_info_query_before - * @var string sql String with the query to be executed - * @var int msg_id topic_id in the page request - * @var int to_user_id The id of whom the message is to - * @var int to_group_id The id of the group whom the message is to - * @var bool submit Whether the user is sending the PM or not - * @var bool preview Whether the user is previewing the PM or not - * @var string action One of: post, reply, quote, forward, quotepost, edit, delete, smilies - * @var bool delete Whether the user is deleting the PM - * @var int reply_to_all Value of reply_to_all request variable. - * @since 3.1.0-RC5 - * @changed 3.2.0-a1 Removed undefined variables - */ - $vars = array( - 'sql', - 'msg_id', - 'to_user_id', - 'to_group_id', - 'submit', - 'preview', - 'action', - 'delete', - 'reply_to_all', - ); - extract($phpbb_dispatcher->trigger_event('core.ucp_pm_compose_compose_pm_basic_info_query_before', compact($vars))); - - $result = $db->sql_query($sql); - $post = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$post) - { - // If editing it could be the recipient already read the message... - if ($action == 'edit') - { - $sql = 'SELECT p.*, t.folder_id - FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p - WHERE t.user_id = ' . $user->data['user_id'] . " - AND t.msg_id = $msg_id - AND t.msg_id = p.msg_id"; - $result = $db->sql_query($sql); - $post = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($post) - { - trigger_error('NO_EDIT_READ_MESSAGE'); - } - } - - trigger_error('NO_MESSAGE'); - } - - if ($action == 'quotepost') - { - if (($post['forum_id'] && !$auth->acl_get('f_read', $post['forum_id'])) || (!$post['forum_id'] && !$auth->acl_getf_global('f_read'))) - { - send_status_line(403, 'Forbidden'); - trigger_error('NOT_AUTHORISED'); - } - - /** - * Get the result of querying for the post to be quoted in the pm message - * - * @event core.ucp_pm_compose_quotepost_query_after - * @var string sql The original SQL used in the query - * @var array post Associative array with the data of the quoted post - * @var array msg_id The post_id that was searched to get the message for quoting - * @var int to_user_id Users the message is sent to - * @var int to_group_id Groups the message is sent to - * @var bool submit Whether the user is sending the PM or not - * @var bool preview Whether the user is previewing the PM or not - * @var string action One of: post, reply, quote, forward, quotepost, edit, delete, smilies - * @var bool delete If deleting message - * @var int reply_to_all Value of reply_to_all request variable. - * @since 3.1.0-RC5 - * @changed 3.2.0-a1 Removed undefined variables - */ - $vars = array( - 'sql', - 'post', - 'msg_id', - 'to_user_id', - 'to_group_id', - 'submit', - 'preview', - 'action', - 'delete', - 'reply_to_all', - ); - extract($phpbb_dispatcher->trigger_event('core.ucp_pm_compose_quotepost_query_after', compact($vars))); - - // Passworded forum? - if ($post['forum_id']) - { - $sql = 'SELECT forum_id, forum_name, forum_password - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . (int) $post['forum_id']; - $result = $db->sql_query($sql); - $forum_data = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!empty($forum_data['forum_password'])) - { - login_forum_box($forum_data); - } - } - } - - $msg_id = (int) $post['msg_id']; - $folder_id = (isset($post['folder_id'])) ? $post['folder_id'] : 0; - $message_text = (isset($post['message_text'])) ? $post['message_text'] : ''; - - if ((!$post['author_id'] || ($post['author_id'] == ANONYMOUS && $action != 'delete')) && $msg_id) - { - trigger_error('NO_AUTHOR'); - } - - if ($action == 'quotepost') - { - // Decode text for message display - decode_message($message_text, $post['bbcode_uid']); - } - - if ($action != 'delete') - { - $enable_urls = $post['enable_magic_url']; - $enable_sig = (isset($post['enable_sig'])) ? $post['enable_sig'] : 0; - - $message_attachment = (isset($post['message_attachment'])) ? $post['message_attachment'] : 0; - $message_subject = $post['message_subject']; - $message_time = $post['message_time']; - $bbcode_uid = $post['bbcode_uid']; - - $quote_username = (isset($post['quote_username'])) ? $post['quote_username'] : ''; - $icon_id = (isset($post['icon_id'])) ? $post['icon_id'] : 0; - - if (($action == 'reply' || $action == 'quote' || $action == 'quotepost') && !count($address_list) && !$refresh && !$submit && !$preview) - { - // Add the original author as the recipient if quoting a post or only replying and not having checked "reply to all" - if ($action == 'quotepost' || !$reply_to_all) - { - $address_list = array('u' => array($post['author_id'] => 'to')); - } - else - { - // We try to include every previously listed member from the TO Header - Reply to all - $address_list = rebuild_header(array('to' => $post['to_address'])); - - // Add the author (if he is already listed then this is no shame (it will be overwritten)) - $address_list['u'][$post['author_id']] = 'to'; - - // Now, make sure the user itself is not listed. ;) - if (isset($address_list['u'][$user->data['user_id']])) - { - unset($address_list['u'][$user->data['user_id']]); - } - } - } - else if ($action == 'edit' && !count($address_list) && !$refresh && !$submit && !$preview) - { - // Rebuild TO and BCC Header - $address_list = rebuild_header(array('to' => $post['to_address'], 'bcc' => $post['bcc_address'])); - } - - if ($action == 'quotepost') - { - $check_value = 0; - } - else - { - $check_value = (($post['enable_bbcode']+1) << 8) + (($post['enable_smilies']+1) << 4) + (($enable_urls+1) << 2) + (($post['enable_sig']+1) << 1); - } - } - } - else - { - $message_attachment = 0; - $message_text = $message_subject = ''; - - /** - * Predefine message text and subject - * - * @event core.ucp_pm_compose_predefined_message - * @var string message_text Message text - * @var string message_subject Messate subject - * @since 3.1.11-RC1 - */ - $vars = array('message_text', 'message_subject'); - extract($phpbb_dispatcher->trigger_event('core.ucp_pm_compose_predefined_message', compact($vars))); - - if ($to_user_id && $to_user_id != ANONYMOUS && $action == 'post') - { - $address_list['u'][$to_user_id] = 'to'; - } - else if ($to_group_id && $action == 'post') - { - $address_list['g'][$to_group_id] = 'to'; - } - $check_value = 0; - } - - if (($to_group_id || isset($address_list['g'])) && (!$config['allow_mass_pm'] || !$auth->acl_get('u_masspm_group'))) - { - send_status_line(403, 'Forbidden'); - trigger_error('NO_AUTH_GROUP_MESSAGE'); - } - - if ($action == 'edit' && !$refresh && !$preview && !$submit) - { - if (!($message_time > time() - ($config['pm_edit_time'] * 60) || !$config['pm_edit_time'])) - { - trigger_error('CANNOT_EDIT_MESSAGE_TIME'); - } - } - - if ($action == 'post') - { - $template->assign_var('S_NEW_MESSAGE', true); - } - - if (!isset($icon_id)) - { - $icon_id = 0; - } - - /* @var $plupload \phpbb\plupload\plupload */ - $plupload = $phpbb_container->get('plupload'); - $message_parser = new parse_message(); - $message_parser->set_plupload($plupload); - - $message_parser->message = ($action == 'reply') ? '' : $message_text; - unset($message_text); - - $s_action = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=$id&mode=$mode&action=$action", true, $user->session_id); - $s_action .= (($folder_id) ? "&f=$folder_id" : '') . (($msg_id) ? "&p=$msg_id" : ''); - - // Delete triggered ? - if ($action == 'delete') - { - // Folder id has been determined by the SQL Statement - // $folder_id = $request->variable('f', PRIVMSGS_NO_BOX); - - // Do we need to confirm ? - if (confirm_box(true)) - { - delete_pm($user->data['user_id'], $msg_id, $folder_id); - - // jump to next message in "history"? nope, not for the moment. But able to be included later. - $meta_info = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=pm&folder=$folder_id"); - $message = $user->lang['MESSAGE_DELETED']; - - meta_refresh(3, $meta_info); - $message .= '

' . sprintf($user->lang['RETURN_FOLDER'], '', ''); - trigger_error($message); - } - else - { - $s_hidden_fields = array( - 'p' => $msg_id, - 'f' => $folder_id, - 'action' => 'delete' - ); - - // "{$phpbb_root_path}ucp.$phpEx?i=pm&mode=compose" - confirm_box(false, 'DELETE_MESSAGE', build_hidden_fields($s_hidden_fields)); - } - - redirect(append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=view&action=view_message&p=' . $msg_id)); - } - - // Get maximum number of allowed recipients - $max_recipients = phpbb_get_max_setting_from_group($db, $user->data['user_id'], 'max_recipients'); - - // If it is 0, there is no limit set and we use the maximum value within the config. - $max_recipients = (!$max_recipients) ? $config['pm_max_recipients'] : $max_recipients; - - // If this is a quote/reply "to all"... we may increase the max_recpients to the number of original recipients - if (($action == 'reply' || $action == 'quote') && $max_recipients && $reply_to_all) - { - // We try to include every previously listed member from the TO Header - $list = rebuild_header(array('to' => $post['to_address'])); - - // Can be an empty array too ;) - $list = (!empty($list['u'])) ? $list['u'] : array(); - $list[$post['author_id']] = 'to'; - - if (isset($list[$user->data['user_id']])) - { - unset($list[$user->data['user_id']]); - } - - $max_recipients = ($max_recipients < count($list)) ? count($list) : $max_recipients; - - unset($list); - } - - // Handle User/Group adding/removing - handle_message_list_actions($address_list, $error, $remove_u, $remove_g, $add_to, $add_bcc); - - // Check mass pm to group permission - if ((!$config['allow_mass_pm'] || !$auth->acl_get('u_masspm_group')) && !empty($address_list['g'])) - { - $address_list = array(); - $error[] = $user->lang['NO_AUTH_GROUP_MESSAGE']; - } - - // Check mass pm to users permission - if ((!$config['allow_mass_pm'] || !$auth->acl_get('u_masspm')) && num_recipients($address_list) > 1) - { - $address_list = get_recipients($address_list, 1); - $error[] = $user->lang('TOO_MANY_RECIPIENTS', 1); - } - - // Check for too many recipients - if (!empty($address_list['u']) && $max_recipients && count($address_list['u']) > $max_recipients) - { - $address_list = get_recipients($address_list, $max_recipients); - $error[] = $user->lang('TOO_MANY_RECIPIENTS', $max_recipients); - } - - // Always check if the submitted attachment data is valid and belongs to the user. - // Further down (especially in submit_post()) we do not check this again. - $message_parser->get_submitted_attachment_data(); - - if ($message_attachment && !$submit && !$refresh && !$preview && $action == 'edit') - { - // Do not change to SELECT * - $sql = 'SELECT attach_id, is_orphan, attach_comment, real_filename, filesize - FROM ' . ATTACHMENTS_TABLE . " - WHERE post_msg_id = $msg_id - AND in_message = 1 - AND is_orphan = 0 - ORDER BY filetime DESC"; - $result = $db->sql_query($sql); - $message_parser->attachment_data = array_merge($message_parser->attachment_data, $db->sql_fetchrowset($result)); - $db->sql_freeresult($result); - } - - if (!in_array($action, array('quote', 'edit', 'delete', 'forward'))) - { - $enable_sig = ($config['allow_sig'] && $config['allow_sig_pm'] && $auth->acl_get('u_sig') && $user->optionget('attachsig')); - $enable_smilies = ($config['allow_smilies'] && $auth->acl_get('u_pm_smilies') && $user->optionget('smilies')); - $enable_bbcode = ($config['allow_bbcode'] && $auth->acl_get('u_pm_bbcode') && $user->optionget('bbcode')); - $enable_urls = true; - } - - $drafts = false; - - // User own some drafts? - if ($auth->acl_get('u_savedrafts') && $action != 'delete') - { - $sql = 'SELECT draft_id - FROM ' . DRAFTS_TABLE . ' - WHERE forum_id = 0 - AND topic_id = 0 - AND user_id = ' . $user->data['user_id'] . - (($draft_id) ? " AND draft_id <> $draft_id" : ''); - $result = $db->sql_query_limit($sql, 1); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - $drafts = true; - } - } - - if ($action == 'edit') - { - $message_parser->bbcode_uid = $bbcode_uid; - } - - $bbcode_status = ($config['allow_bbcode'] && $config['auth_bbcode_pm'] && $auth->acl_get('u_pm_bbcode')) ? true : false; - $smilies_status = ($config['allow_smilies'] && $config['auth_smilies_pm'] && $auth->acl_get('u_pm_smilies')) ? true : false; - $img_status = ($config['auth_img_pm'] && $auth->acl_get('u_pm_img')) ? true : false; - $flash_status = ($config['auth_flash_pm'] && $auth->acl_get('u_pm_flash')) ? true : false; - $url_status = ($config['allow_post_links']) ? true : false; - - // Save Draft - if ($save && $auth->acl_get('u_savedrafts')) - { - $subject = $request->variable('subject', '', true); - $subject = (!$subject && $action != 'post') ? $user->lang['NEW_MESSAGE'] : $subject; - $message = $request->variable('message', '', true); - - if ($subject && $message) - { - if (confirm_box(true)) - { - $message_parser->message = $message; - $message_parser->parse($bbcode_status, $url_status, $smilies_status, $img_status, $flash_status, true, $url_status); - - $sql = 'INSERT INTO ' . DRAFTS_TABLE . ' ' . $db->sql_build_array('INSERT', array( - 'user_id' => $user->data['user_id'], - 'topic_id' => 0, - 'forum_id' => 0, - 'save_time' => $current_time, - 'draft_subject' => $subject, - 'draft_message' => $message_parser->message, - ) - ); - $db->sql_query($sql); - - $redirect_url = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=pm&mode=$mode"); - - meta_refresh(3, $redirect_url); - $message = $user->lang['DRAFT_SAVED'] . '

' . sprintf($user->lang['RETURN_UCP'], '', ''); - - trigger_error($message); - } - else - { - $s_hidden_fields = build_hidden_fields(array( - 'mode' => $mode, - 'action' => $action, - 'save' => true, - 'subject' => $subject, - 'message' => $message, - 'u' => $to_user_id, - 'g' => $to_group_id, - 'p' => $msg_id) - ); - $s_hidden_fields .= build_address_field($address_list); - - confirm_box(false, 'SAVE_DRAFT', $s_hidden_fields); - } - } - else - { - if (utf8_clean_string($subject) === '') - { - $error[] = $user->lang['EMPTY_MESSAGE_SUBJECT']; - } - - if (utf8_clean_string($message) === '') - { - $error[] = $user->lang['TOO_FEW_CHARS']; - } - } - - unset($subject, $message); - } - - // Load Draft - if ($draft_id && $auth->acl_get('u_savedrafts')) - { - $sql = 'SELECT draft_subject, draft_message - FROM ' . DRAFTS_TABLE . " - WHERE draft_id = $draft_id - AND topic_id = 0 - AND forum_id = 0 - AND user_id = " . $user->data['user_id']; - $result = $db->sql_query_limit($sql, 1); - - if ($row = $db->sql_fetchrow($result)) - { - $message_parser->message = $row['draft_message']; - $message_subject = $row['draft_subject']; - - $template->assign_var('S_DRAFT_LOADED', true); - } - else - { - $draft_id = 0; - } - $db->sql_freeresult($result); - } - - // Load Drafts - if ($load && $drafts) - { - load_drafts(0, 0, $id, $action, $msg_id); - } - - if ($submit || $preview || $refresh) - { - if (($submit || $preview) && !check_form_key('ucp_pm_compose')) - { - $error[] = $user->lang['FORM_INVALID']; - } - $subject = $request->variable('subject', '', true); - $message_parser->message = $request->variable('message', '', true); - - $icon_id = $request->variable('icon', 0); - - $enable_bbcode = (!$bbcode_status || isset($_POST['disable_bbcode'])) ? false : true; - $enable_smilies = (!$smilies_status || isset($_POST['disable_smilies'])) ? false : true; - $enable_urls = (isset($_POST['disable_magic_url'])) ? 0 : 1; - $enable_sig = (!$config['allow_sig'] ||!$config['allow_sig_pm']) ? false : ((isset($_POST['attach_sig'])) ? true : false); - - /** - * Modify private message - * - * @event core.ucp_pm_compose_modify_parse_before - * @var bool enable_bbcode Whether or not bbcode is enabled - * @var bool enable_smilies Whether or not smilies are enabled - * @var bool enable_urls Whether or not urls are enabled - * @var bool enable_sig Whether or not signature is enabled - * @var string subject PM subject text - * @var object message_parser The message parser object - * @var bool submit Whether or not the form has been sumitted - * @var bool preview Whether or not the signature is being previewed - * @var array error Any error strings - * @since 3.1.10-RC1 - */ - $vars = array( - 'enable_bbcode', - 'enable_smilies', - 'enable_urls', - 'enable_sig', - 'subject', - 'message_parser', - 'submit', - 'preview', - 'error', - ); - extract($phpbb_dispatcher->trigger_event('core.ucp_pm_compose_modify_parse_before', compact($vars))); - - // Parse Attachments - before checksum is calculated - if ($message_parser->check_attachment_form_token($language, $request, 'ucp_pm_compose')) - { - $message_parser->parse_attachments('fileupload', $action, 0, $submit, $preview, $refresh, true); - } - - if (count($message_parser->warn_msg) && !($remove_u || $remove_g || $add_to || $add_bcc)) - { - $error[] = implode('
', $message_parser->warn_msg); - $message_parser->warn_msg = array(); - } - - // Parse message - $message_parser->parse($enable_bbcode, ($config['allow_post_links']) ? $enable_urls : false, $enable_smilies, $img_status, $flash_status, true, $config['allow_post_links']); - - // On a refresh we do not care about message parsing errors - if (count($message_parser->warn_msg) && !$refresh) - { - $error[] = implode('
', $message_parser->warn_msg); - } - - if ($action != 'edit' && !$preview && !$refresh && $config['flood_interval'] && !$auth->acl_get('u_ignoreflood')) - { - // Flood check - $last_post_time = $user->data['user_lastpost_time']; - - if ($last_post_time) - { - if ($last_post_time && ($current_time - $last_post_time) < intval($config['flood_interval'])) - { - $error[] = $user->lang['FLOOD_ERROR']; - } - } - } - - // Subject defined - if ($submit) - { - if (utf8_clean_string($subject) === '') - { - $error[] = $user->lang['EMPTY_MESSAGE_SUBJECT']; - } - - if (!count($address_list)) - { - $error[] = $user->lang['NO_RECIPIENT']; - } - } - - // Store message, sync counters - if (!count($error) && $submit) - { - $pm_data = array( - 'msg_id' => (int) $msg_id, - 'from_user_id' => $user->data['user_id'], - 'from_user_ip' => $user->ip, - 'from_username' => $user->data['username'], - 'reply_from_root_level' => (isset($post['root_level'])) ? (int) $post['root_level'] : 0, - 'reply_from_msg_id' => (int) $msg_id, - 'icon_id' => (int) $icon_id, - 'enable_sig' => (bool) $enable_sig, - 'enable_bbcode' => (bool) $enable_bbcode, - 'enable_smilies' => (bool) $enable_smilies, - 'enable_urls' => (bool) $enable_urls, - 'bbcode_bitfield' => $message_parser->bbcode_bitfield, - 'bbcode_uid' => $message_parser->bbcode_uid, - 'message' => $message_parser->message, - 'attachment_data' => $message_parser->attachment_data, - 'filename_data' => $message_parser->filename_data, - 'address_list' => $address_list - ); - - // ((!$message_subject) ? $subject : $message_subject) - $msg_id = submit_pm($action, $subject, $pm_data); - - $return_message_url = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=view&p=' . $msg_id); - $inbox_folder_url = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&folder=inbox'); - $outbox_folder_url = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&folder=outbox'); - - $folder_url = ''; - if (($folder_id > 0) && isset($user_folders[$folder_id])) - { - $folder_url = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&folder=' . $folder_id); - } - - $return_box_url = ($action === 'post' || $action === 'edit') ? $outbox_folder_url : $inbox_folder_url; - $return_box_lang = ($action === 'post' || $action === 'edit') ? 'PM_OUTBOX' : 'PM_INBOX'; - - $save_message = ($action === 'edit') ? $user->lang['MESSAGE_EDITED'] : $user->lang['MESSAGE_STORED']; - $message = $save_message . '

' . $user->lang('VIEW_PRIVATE_MESSAGE', '', ''); - - $last_click_type = 'CLICK_RETURN_FOLDER'; - if ($folder_url) - { - $message .= '

' . sprintf($user->lang['CLICK_RETURN_FOLDER'], '', '', $user_folders[$folder_id]['folder_name']); - $last_click_type = 'CLICK_GOTO_FOLDER'; - } - $message .= '

' . sprintf($user->lang[$last_click_type], '', '', $user->lang[$return_box_lang]); - - meta_refresh(3, $return_message_url); - trigger_error($message); - } - - $message_subject = $subject; - } - - // Preview - if (!count($error) && $preview) - { - $preview_message = $message_parser->format_display($enable_bbcode, $enable_urls, $enable_smilies, false); - - $preview_signature = $user->data['user_sig']; - $preview_signature_uid = $user->data['user_sig_bbcode_uid']; - $preview_signature_bitfield = $user->data['user_sig_bbcode_bitfield']; - - // Signature - if ($enable_sig && $config['allow_sig'] && $preview_signature) - { - $bbcode_flags = ($enable_bbcode ? OPTION_FLAG_BBCODE : 0) + ($enable_smilies ? OPTION_FLAG_SMILIES : 0) + ($enable_urls ? OPTION_FLAG_LINKS : 0); - $preview_signature = generate_text_for_display($preview_signature, $preview_signature_uid, $preview_signature_bitfield, $bbcode_flags); - } - else - { - $preview_signature = ''; - } - - // Attachment Preview - if (count($message_parser->attachment_data)) - { - $template->assign_var('S_HAS_ATTACHMENTS', true); - - $update_count = array(); - $attachment_data = $message_parser->attachment_data; - - parse_attachments(false, $preview_message, $attachment_data, $update_count, true); - - foreach ($attachment_data as $i => $attachment) - { - $template->assign_block_vars('attachment', array( - 'DISPLAY_ATTACHMENT' => $attachment) - ); - } - unset($attachment_data); - } - - $preview_subject = censor_text($subject); - - if (!count($error)) - { - $template->assign_vars(array( - 'PREVIEW_SUBJECT' => $preview_subject, - 'PREVIEW_MESSAGE' => $preview_message, - 'PREVIEW_SIGNATURE' => $preview_signature, - - 'S_DISPLAY_PREVIEW' => true) - ); - } - unset($message_text); - } - - // Decode text for message display - $bbcode_uid = (($action == 'quote' || $action == 'forward') && !$preview && !$refresh && (!count($error) || (count($error) && !$submit))) ? $bbcode_uid : $message_parser->bbcode_uid; - - $message_parser->decode_message($bbcode_uid); - - if (($action == 'quote' || $action == 'quotepost') && !$preview && !$refresh && !$submit) - { - if ($action == 'quotepost') - { - $post_id = $request->variable('p', 0); - if ($config['allow_post_links']) - { - $message_link = generate_board_url() . "/viewtopic.$phpEx?p={$post_id}#p{$post_id}"; - $message_link_subject = "{$user->lang['SUBJECT']}{$user->lang['COLON']} {$message_subject}"; - if ($bbcode_status) - { - $message_link = "[url=" . $message_link . "]" . $message_link_subject . "[/url]\n\n"; - } - else - { - $message_link = $message_link . " - " . $message_link_subject . "\n\n"; - } - } - else - { - $message_link = $user->lang['SUBJECT'] . $user->lang['COLON'] . ' ' . $message_subject . " (" . generate_board_url() . "/viewtopic.$phpEx?p={$post_id}#p{$post_id})\n\n"; - } - } - else - { - $message_link = ''; - } - $quote_attributes = array( - 'author' => $quote_username, - 'time' => $post['message_time'], - 'user_id' => $post['author_id'], - ); - if ($action === 'quotepost') - { - $quote_attributes['post_id'] = $post['msg_id']; - } - if ($action === 'quote') - { - $quote_attributes['msg_id'] = $post['msg_id']; - } - /** @var \phpbb\language\language $language */ - $language = $phpbb_container->get('language'); - /** @var \phpbb\textformatter\utils_interface $text_formatter_utils */ - $text_formatter_utils = $phpbb_container->get('text_formatter.utils'); - phpbb_format_quote($language, $message_parser, $text_formatter_utils, $bbcode_status, $quote_attributes, $message_link); - } - - if (($action == 'reply' || $action == 'quote' || $action == 'quotepost') && !$preview && !$refresh) - { - $message_subject = ((!preg_match('/^Re:/', $message_subject)) ? 'Re: ' : '') . censor_text($message_subject); - - /** - * This event allows you to modify the PM subject of the PM being quoted - * - * @event core.pm_modify_message_subject - * @var string message_subject String with the PM subject already censored. - * @since 3.2.8-RC1 - */ - $vars = array('message_subject'); - extract($phpbb_dispatcher->trigger_event('core.pm_modify_message_subject', compact($vars))); - } - - if ($action == 'forward' && !$preview && !$refresh && !$submit) - { - $fwd_to_field = write_pm_addresses(array('to' => $post['to_address']), 0, true); - - if ($config['allow_post_links']) - { - $quote_username_text = '[url=' . generate_board_url() . "/memberlist.$phpEx?mode=viewprofile&u={$post['author_id']}]{$quote_username}[/url]"; - } - else - { - $quote_username_text = $quote_username . ' (' . generate_board_url() . "/memberlist.$phpEx?mode=viewprofile&u={$post['author_id']})"; - } - - $forward_text = array(); - $forward_text[] = $user->lang['FWD_ORIGINAL_MESSAGE']; - $forward_text[] = sprintf($user->lang['FWD_SUBJECT'], censor_text($message_subject)); - $forward_text[] = sprintf($user->lang['FWD_DATE'], $user->format_date($message_time, false, true)); - $forward_text[] = sprintf($user->lang['FWD_FROM'], $quote_username_text); - $forward_text[] = sprintf($user->lang['FWD_TO'], implode($user->lang['COMMA_SEPARATOR'], $fwd_to_field['to'])); - - $quote_text = $phpbb_container->get('text_formatter.utils')->generate_quote( - censor_text($message_parser->message), - array('author' => $quote_username) - ); - $message_parser->message = implode("\n", $forward_text) . "\n\n" . $quote_text; - $message_subject = ((!preg_match('/^Fwd:/', $message_subject)) ? 'Fwd: ' : '') . censor_text($message_subject); - } - - $attachment_data = $message_parser->attachment_data; - $filename_data = $message_parser->filename_data; - $message_text = $message_parser->message; - - // MAIN PM PAGE BEGINS HERE - - // Generate smiley listing - generate_smilies('inline', 0); - - // Generate PM Icons - $s_pm_icons = false; - if ($config['enable_pm_icons']) - { - $s_pm_icons = posting_gen_topic_icons($action, $icon_id); - } - - // Generate inline attachment select box - posting_gen_inline_attachments($attachment_data); - - // Build address list for display - // array('u' => array($author_id => 'to')); - if (count($address_list)) - { - // Get Usernames and Group Names - $result = array(); - if (!empty($address_list['u'])) - { - $sql = 'SELECT user_id as id, username as name, user_colour as colour - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('user_id', array_map('intval', array_keys($address_list['u']))) . ' - ORDER BY username_clean ASC'; - $result['u'] = $db->sql_query($sql); - } - - if (!empty($address_list['g'])) - { - $sql = 'SELECT g.group_id AS id, g.group_name AS name, g.group_colour AS colour, g.group_type - FROM ' . GROUPS_TABLE . ' g'; - - if (!$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) - { - $sql .= ' LEFT JOIN ' . USER_GROUP_TABLE . ' ug - ON ( - g.group_id = ug.group_id - AND ug.user_id = ' . $user->data['user_id'] . ' - AND ug.user_pending = 0 - ) - WHERE (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $user->data['user_id'] . ')'; - } - - $sql .= ($auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) ? ' WHERE ' : ' AND '; - - $sql .= 'g.group_receive_pm = 1 - AND ' . $db->sql_in_set('g.group_id', array_map('intval', array_keys($address_list['g']))) . ' - ORDER BY g.group_name ASC'; - - $result['g'] = $db->sql_query($sql); - } - - $u = $g = array(); - $_types = array('u', 'g'); - foreach ($_types as $type) - { - if (isset($result[$type]) && $result[$type]) - { - while ($row = $db->sql_fetchrow($result[$type])) - { - if ($type == 'g') - { - $row['name'] = $group_helper->get_name($row['name']); - } - - ${$type}[$row['id']] = array('name' => $row['name'], 'colour' => $row['colour']); - } - $db->sql_freeresult($result[$type]); - } - } - - // Now Build the address list - foreach ($address_list as $type => $adr_ary) - { - foreach ($adr_ary as $id => $field) - { - if (!isset(${$type}[$id])) - { - unset($address_list[$type][$id]); - continue; - } - - $field = ($field == 'to') ? 'to' : 'bcc'; - $type = ($type == 'u') ? 'u' : 'g'; - $id = (int) $id; - - $tpl_ary = array( - 'IS_GROUP' => ($type == 'g') ? true : false, - 'IS_USER' => ($type == 'u') ? true : false, - 'UG_ID' => $id, - 'NAME' => ${$type}[$id]['name'], - 'COLOUR' => (${$type}[$id]['colour']) ? '#' . ${$type}[$id]['colour'] : '', - 'TYPE' => $type, - ); - - if ($type == 'u') - { - $tpl_ary = array_merge($tpl_ary, array( - 'U_VIEW' => get_username_string('profile', $id, ${$type}[$id]['name'], ${$type}[$id]['colour']), - 'NAME_FULL' => get_username_string('full', $id, ${$type}[$id]['name'], ${$type}[$id]['colour']), - )); - } - else - { - $tpl_ary = array_merge($tpl_ary, array( - 'U_VIEW' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&g=' . $id), - )); - } - - $template->assign_block_vars($field . '_recipient', $tpl_ary); - } - } - } - - // Build hidden address list - $s_hidden_address_field = build_address_field($address_list); - - $bbcode_checked = (isset($enable_bbcode)) ? !$enable_bbcode : (($config['allow_bbcode'] && $auth->acl_get('u_pm_bbcode')) ? !$user->optionget('bbcode') : 1); - $smilies_checked = (isset($enable_smilies)) ? !$enable_smilies : (($config['allow_smilies'] && $auth->acl_get('u_pm_smilies')) ? !$user->optionget('smilies') : 1); - $urls_checked = (isset($enable_urls)) ? !$enable_urls : 0; - $sig_checked = $enable_sig; - - switch ($action) - { - case 'post': - $page_title = $user->lang['POST_NEW_PM']; - break; - - case 'quote': - $page_title = $user->lang['POST_QUOTE_PM']; - break; - - case 'quotepost': - $page_title = $user->lang['POST_PM_POST']; - break; - - case 'reply': - $page_title = $user->lang['POST_REPLY_PM']; - break; - - case 'edit': - $page_title = $user->lang['POST_EDIT_PM']; - break; - - case 'forward': - $page_title = $user->lang['POST_FORWARD_PM']; - break; - - default: - trigger_error('NO_ACTION_MODE', E_USER_ERROR); - break; - } - - $s_hidden_fields = (isset($check_value)) ? '' : ''; - $s_hidden_fields .= ($draft_id || isset($_REQUEST['draft_loaded'])) ? '' : ''; - - $form_enctype = (@ini_get('file_uploads') == '0' || strtolower(@ini_get('file_uploads')) == 'off' || !$config['allow_pm_attach'] || !$auth->acl_get('u_pm_attach')) ? '' : ' enctype="multipart/form-data"'; - - /** @var \phpbb\controller\helper $controller_helper */ - $controller_helper = $phpbb_container->get('controller.helper'); - - // Start assigning vars for main posting page ... - $template_ary = array( - 'L_POST_A' => $page_title, - 'L_ICON' => $user->lang['PM_ICON'], - 'L_MESSAGE_BODY_EXPLAIN' => $user->lang('MESSAGE_BODY_EXPLAIN', (int) $config['max_post_chars']), - - 'SUBJECT' => (isset($message_subject)) ? $message_subject : '', - 'MESSAGE' => $message_text, - 'BBCODE_STATUS' => $user->lang(($bbcode_status ? 'BBCODE_IS_ON' : 'BBCODE_IS_OFF'), '', ''), - 'IMG_STATUS' => ($img_status) ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'], - 'FLASH_STATUS' => ($flash_status) ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'], - 'SMILIES_STATUS' => ($smilies_status) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'], - 'URL_STATUS' => ($url_status) ? $user->lang['URL_IS_ON'] : $user->lang['URL_IS_OFF'], - 'MAX_FONT_SIZE' => (int) $config['max_post_font_size'], - 'MINI_POST_IMG' => $user->img('icon_post_target', $user->lang['PM']), - 'ERROR' => (count($error)) ? implode('
', $error) : '', - 'MAX_RECIPIENTS' => ($config['allow_mass_pm'] && ($auth->acl_get('u_masspm') || $auth->acl_get('u_masspm_group'))) ? $max_recipients : 0, - - 'S_COMPOSE_PM' => true, - 'S_EDIT_POST' => ($action == 'edit'), - 'S_SHOW_PM_ICONS' => $s_pm_icons, - 'S_BBCODE_ALLOWED' => ($bbcode_status) ? 1 : 0, - 'S_BBCODE_CHECKED' => ($bbcode_checked) ? ' checked="checked"' : '', - 'S_SMILIES_ALLOWED' => $smilies_status, - 'S_SMILIES_CHECKED' => ($smilies_checked) ? ' checked="checked"' : '', - 'S_SIG_ALLOWED' => ($config['allow_sig'] && $config['allow_sig_pm'] && $auth->acl_get('u_sig')), - 'S_SIGNATURE_CHECKED' => ($sig_checked) ? ' checked="checked"' : '', - 'S_LINKS_ALLOWED' => $url_status, - 'S_MAGIC_URL_CHECKED' => ($urls_checked) ? ' checked="checked"' : '', - 'S_SAVE_ALLOWED' => ($auth->acl_get('u_savedrafts') && $action != 'edit') ? true : false, - 'S_HAS_DRAFTS' => ($auth->acl_get('u_savedrafts') && $drafts), - 'S_FORM_ENCTYPE' => $form_enctype, - 'S_ATTACH_DATA' => json_encode($message_parser->attachment_data), - - 'S_BBCODE_IMG' => $img_status, - 'S_BBCODE_FLASH' => $flash_status, - 'S_BBCODE_QUOTE' => true, - 'S_BBCODE_URL' => $url_status, - - 'S_POST_ACTION' => $s_action, - 'S_HIDDEN_ADDRESS_FIELD' => $s_hidden_address_field, - 'S_HIDDEN_FIELDS' => $s_hidden_fields, - - 'S_CLOSE_PROGRESS_WINDOW' => isset($_POST['add_file']), - 'U_PROGRESS_BAR' => append_sid("{$phpbb_root_path}posting.$phpEx", 'f=0&mode=popup'), - 'UA_PROGRESS_BAR' => addslashes(append_sid("{$phpbb_root_path}posting.$phpEx", 'f=0&mode=popup')), - ); - - /** - * Modify the default template vars - * - * @event core.ucp_pm_compose_template - * @var array template_ary Template variables - * @since 3.2.6-RC1 - */ - $vars = array('template_ary'); - extract($phpbb_dispatcher->trigger_event('core.ucp_pm_compose_template', compact($vars))); - - $template->assign_vars($template_ary); - - // Build custom bbcodes array - display_custom_bbcodes(); - - // Show attachment box for adding attachments if true - $allowed = ($auth->acl_get('u_pm_attach') && $config['allow_pm_attach'] && $form_enctype); - - if ($allowed) - { - $max_files = ($auth->acl_gets('a_', 'm_')) ? 0 : (int) $config['max_attachments_pm']; - $plupload->configure($cache, $template, $s_action, false, $max_files); - } - - // Attachment entry - posting_gen_attachment_entry($attachment_data, $filename_data, $allowed); - - // Message History - if ($action == 'reply' || $action == 'quote' || $action == 'forward') - { - if (message_history($msg_id, $user->data['user_id'], $post, array(), true)) - { - $template->assign_var('S_DISPLAY_HISTORY', true); - } - } -} - -/** -* For composing messages, handle list actions -*/ -function handle_message_list_actions(&$address_list, &$error, $remove_u, $remove_g, $add_to, $add_bcc) -{ - global $auth, $db, $user; - global $request, $phpbb_dispatcher; - - // Delete User [TO/BCC] - if ($remove_u && $request->variable('remove_u', array(0 => ''))) - { - $remove_user_id = array_keys($request->variable('remove_u', array(0 => ''))); - - if (isset($remove_user_id[0])) - { - unset($address_list['u'][(int) $remove_user_id[0]]); - } - } - - // Delete Group [TO/BCC] - if ($remove_g && $request->variable('remove_g', array(0 => ''))) - { - $remove_group_id = array_keys($request->variable('remove_g', array(0 => ''))); - - if (isset($remove_group_id[0])) - { - unset($address_list['g'][(int) $remove_group_id[0]]); - } - } - - // Add Selected Groups - $group_list = $request->variable('group_list', array(0)); - - // Build usernames to add - $usernames = $request->variable('username', '', true); - $usernames = (empty($usernames)) ? array() : array($usernames); - - $username_list = $request->variable('username_list', '', true); - if ($username_list) - { - $usernames = array_merge($usernames, explode("\n", $username_list)); - } - - // If add to or add bcc not pressed, users could still have usernames listed they want to add... - if (!$add_to && !$add_bcc && (count($group_list) || count($usernames))) - { - $add_to = true; - - global $refresh, $submit, $preview; - - $refresh = true; - $submit = false; - - // Preview is only true if there was also a message entered - if ($request->variable('message', '')) - { - $preview = true; - } - } - - // Add User/Group [TO] - if ($add_to || $add_bcc) - { - $type = ($add_to) ? 'to' : 'bcc'; - - if (count($group_list)) - { - foreach ($group_list as $group_id) - { - $address_list['g'][$group_id] = $type; - } - } - - // User ID's to add... - $user_id_ary = array(); - - // Reveal the correct user_ids - if (count($usernames)) - { - $user_id_ary = array(); - user_get_id_name($user_id_ary, $usernames, array(USER_NORMAL, USER_FOUNDER, USER_INACTIVE)); - - // If there are users not existing, we will at least print a notice... - if (!count($user_id_ary)) - { - $error[] = $user->lang['PM_NO_USERS']; - } - } - - // Add Friends if specified - $friend_list = array_keys($request->variable('add_' . $type, array(0))); - $user_id_ary = array_merge($user_id_ary, $friend_list); - - foreach ($user_id_ary as $user_id) - { - if ($user_id == ANONYMOUS) - { - continue; - } - - $address_list['u'][$user_id] = $type; - } - } - - // Check for disallowed recipients - if (!empty($address_list['u'])) - { - $can_ignore_allow_pm = $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'); - - // Administrator deactivated users check and we need to check their - // PM status (do they want to receive PM's?) - // Only check PM status if not a moderator or admin, since they - // are allowed to override this user setting - $sql = 'SELECT user_id, user_allow_pm - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('user_id', array_keys($address_list['u'])) . ' - AND ( - (user_type = ' . USER_INACTIVE . ' - AND user_inactive_reason = ' . INACTIVE_MANUAL . ') - ' . ($can_ignore_allow_pm ? '' : ' OR user_allow_pm = 0') . ' - )'; - - $result = $db->sql_query($sql); - - $removed_no_pm = $removed_no_permission = false; - while ($row = $db->sql_fetchrow($result)) - { - if (!$can_ignore_allow_pm && !$row['user_allow_pm']) - { - $removed_no_pm = true; - } - else - { - $removed_no_permission = true; - } - - unset($address_list['u'][$row['user_id']]); - } - $db->sql_freeresult($result); - - // print a notice about users not being added who do not want to receive pms - if ($removed_no_pm) - { - $error[] = $user->lang['PM_USERS_REMOVED_NO_PM']; - } - - // print a notice about users not being added who do not have permission to receive PMs - if ($removed_no_permission) - { - $error[] = $user->lang['PM_USERS_REMOVED_NO_PERMISSION']; - } - - if (!count(array_keys($address_list['u']))) - { - return; - } - - // Check if users have permission to read PMs - $can_read = $auth->acl_get_list(array_keys($address_list['u']), 'u_readpm'); - $can_read = (empty($can_read) || !isset($can_read[0]['u_readpm'])) ? array() : $can_read[0]['u_readpm']; - $cannot_read_list = array_diff(array_keys($address_list['u']), $can_read); - if (!empty($cannot_read_list)) - { - foreach ($cannot_read_list as $cannot_read) - { - unset($address_list['u'][$cannot_read]); - } - - $error[] = $user->lang['PM_USERS_REMOVED_NO_PERMISSION']; - } - - // Check if users are banned - $banned_user_list = phpbb_get_banned_user_ids(array_keys($address_list['u']), false); - if (!empty($banned_user_list)) - { - foreach ($banned_user_list as $banned_user) - { - unset($address_list['u'][$banned_user]); - } - - $error[] = $user->lang['PM_USERS_REMOVED_NO_PERMISSION']; - } - } - - /** - * Event for additional message list actions - * - * @event core.message_list_actions - * @var array address_list The assoc array with the recipient user/group ids - * @var array error The array containing error data - * @var bool remove_u The variable for removing a user - * @var bool remove_g The variable for removing a group - * @var bool add_to The variable for adding a user to the [TO] field - * @var bool add_bcc The variable for adding a user to the [BCC] field - * @since 3.2.4-RC1 - */ - $vars = array('address_list', 'error', 'remove_u', 'remove_g', 'add_to', 'add_bcc'); - extract($phpbb_dispatcher->trigger_event('core.message_list_actions', compact($vars))); -} - -/** -* Build the hidden field for the recipients. Needed, as the variable is not read via $request->variable(). -*/ -function build_address_field($address_list) -{ - $s_hidden_address_field = ''; - foreach ($address_list as $type => $adr_ary) - { - foreach ($adr_ary as $id => $field) - { - $s_hidden_address_field .= ''; - } - } - return $s_hidden_address_field; -} - -/** -* Return number of private message recipients -*/ -function num_recipients($address_list) -{ - $num_recipients = 0; - - foreach ($address_list as $field => $adr_ary) - { - $num_recipients += count($adr_ary); - } - - return $num_recipients; -} - -/** -* Get number of 'num_recipients' recipients from first position -*/ -function get_recipients($address_list, $num_recipients = 1) -{ - $recipient = array(); - - $count = 0; - foreach ($address_list as $field => $adr_ary) - { - foreach ($adr_ary as $id => $type) - { - if ($count >= $num_recipients) - { - break 2; - } - $recipient[$field][$id] = $type; - $count++; - } - } - - return $recipient; -} diff --git a/install/update/new/includes/ucp/ucp_pm_viewfolder.php b/install/update/new/includes/ucp/ucp_pm_viewfolder.php deleted file mode 100644 index ce40a25..0000000 --- a/install/update/new/includes/ucp/ucp_pm_viewfolder.php +++ /dev/null @@ -1,611 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* View message folder -* Called from ucp_pm with mode == 'view' && action == 'view_folder' -*/ -function view_folder($id, $mode, $folder_id, $folder) -{ - global $user, $template, $auth, $db, $cache, $request; - global $phpbb_root_path, $config, $phpEx; - - $submit_export = (isset($_POST['submit_export'])) ? true : false; - - $folder_info = get_pm_from($folder_id, $folder, $user->data['user_id']); - - add_form_key('ucp_pm_view_folder'); - - if (!$submit_export) - { - $user->add_lang('viewforum'); - - // Grab icons - $icons = $cache->obtain_icons(); - - $color_rows = array('message_reported', 'marked', 'replied'); - - $_module = new p_master(); - $_module->list_modules('ucp'); - $_module->set_active('zebra'); - - $zebra_enabled = ($_module->active_module === false) ? false : true; - - unset($_module); - - if ($zebra_enabled) - { - $color_rows = array_merge($color_rows, array('friend', 'foe')); - } - - foreach ($color_rows as $var) - { - $template->assign_block_vars('pm_colour_info', array( - 'IMG' => $user->img("pm_{$var}", ''), - 'CLASS' => "pm_{$var}_colour", - 'LANG' => $user->lang[strtoupper($var) . '_MESSAGE']) - ); - } - - $mark_options = array('mark_important', 'delete_marked'); - - // Minimise edits - if (!$auth->acl_get('u_pm_delete') && $key = array_search('delete_marked', $mark_options)) - { - unset($mark_options[$key]); - } - - $s_mark_options = ''; - foreach ($mark_options as $mark_option) - { - $s_mark_options .= ''; - } - - // We do the folder moving options here too, for template authors to use... - $s_folder_move_options = ''; - if ($folder_id != PRIVMSGS_NO_BOX && $folder_id != PRIVMSGS_OUTBOX) - { - foreach ($folder as $f_id => $folder_ary) - { - if ($f_id == PRIVMSGS_OUTBOX || $f_id == PRIVMSGS_SENTBOX || $f_id == $folder_id) - { - continue; - } - - $s_folder_move_options .= ''; - $s_folder_move_options .= sprintf($user->lang['MOVE_MARKED_TO_FOLDER'], $folder_ary['folder_name']); - $s_folder_move_options .= (($folder_ary['unread_messages']) ? ' [' . $folder_ary['unread_messages'] . '] ' : '') . ''; - } - } - $friend = $foe = array(); - - // Get friends and foes - $sql = 'SELECT * - FROM ' . ZEBRA_TABLE . ' - WHERE user_id = ' . $user->data['user_id']; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $friend[$row['zebra_id']] = $row['friend']; - $foe[$row['zebra_id']] = $row['foe']; - } - $db->sql_freeresult($result); - - $template->assign_vars(array( - 'S_MARK_OPTIONS' => $s_mark_options, - 'S_MOVE_MARKED_OPTIONS' => $s_folder_move_options) - ); - - // Okay, lets dump out the page ... - if (count($folder_info['pm_list'])) - { - $address_list = array(); - - // Build Recipient List if in outbox/sentbox - max two additional queries - if ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) - { - $address_list = get_recipient_strings($folder_info['rowset']); - } - - foreach ($folder_info['pm_list'] as $message_id) - { - $row = &$folder_info['rowset'][$message_id]; - - $folder_img = ($row['pm_unread']) ? 'pm_unread' : 'pm_read'; - $folder_alt = ($row['pm_unread']) ? 'NEW_MESSAGES' : 'NO_NEW_MESSAGES'; - - // Generate all URIs ... - $view_message_url = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=$id&mode=view&f=$folder_id&p=$message_id"); - $remove_message_url = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=$id&mode=compose&action=delete&p=$message_id"); - - $row_indicator = ''; - foreach ($color_rows as $var) - { - if (($var !== 'friend' && $var !== 'foe' && $row[($var === 'message_reported') ? $var : "pm_{$var}"]) - || - (($var === 'friend' || $var === 'foe') && isset(${$var}[$row['author_id']]) && ${$var}[$row['author_id']])) - { - $row_indicator = $var; - break; - } - } - - // Send vars to template - $template->assign_block_vars('messagerow', array( - 'PM_CLASS' => ($row_indicator) ? 'pm_' . $row_indicator . '_colour' : '', - - 'MESSAGE_AUTHOR_FULL' => get_username_string('full', $row['author_id'], $row['username'], $row['user_colour'], $row['username']), - 'MESSAGE_AUTHOR_COLOUR' => get_username_string('colour', $row['author_id'], $row['username'], $row['user_colour'], $row['username']), - 'MESSAGE_AUTHOR' => get_username_string('username', $row['author_id'], $row['username'], $row['user_colour'], $row['username']), - 'U_MESSAGE_AUTHOR' => get_username_string('profile', $row['author_id'], $row['username'], $row['user_colour'], $row['username']), - - 'FOLDER_ID' => $folder_id, - 'MESSAGE_ID' => $message_id, - 'SENT_TIME' => $user->format_date($row['message_time']), - 'SUBJECT' => censor_text($row['message_subject']), - 'FOLDER' => (isset($folder[$row['folder_id']])) ? $folder[$row['folder_id']]['folder_name'] : '', - 'U_FOLDER' => (isset($folder[$row['folder_id']])) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'folder=' . $row['folder_id']) : '', - 'PM_ICON_IMG' => (!empty($icons[$row['icon_id']])) ? '' : '', - 'PM_ICON_URL' => (!empty($icons[$row['icon_id']])) ? $config['icons_path'] . '/' . $icons[$row['icon_id']]['img'] : '', - 'FOLDER_IMG' => $user->img($folder_img, $folder_alt), - 'FOLDER_IMG_STYLE' => $folder_img, - 'PM_IMG' => ($row_indicator) ? $user->img('pm_' . $row_indicator, '') : '', - 'ATTACH_ICON_IMG' => ($auth->acl_get('u_pm_download') && $row['message_attachment'] && $config['allow_pm_attach']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', - - 'S_PM_UNREAD' => ($row['pm_unread']) ? true : false, - 'S_PM_DELETED' => ($row['pm_deleted']) ? true : false, - 'S_PM_REPORTED' => (isset($row['report_id'])) ? true : false, - 'S_AUTHOR_DELETED' => ($row['author_id'] == ANONYMOUS) ? true : false, - - 'U_VIEW_PM' => ($row['pm_deleted']) ? '' : $view_message_url, - 'U_REMOVE_PM' => ($row['pm_deleted']) ? $remove_message_url : '', - 'U_MCP_REPORT' => (isset($row['report_id'])) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=pm_reports&mode=pm_report_details&r=' . $row['report_id']) : '', - 'RECIPIENTS' => ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) ? implode($user->lang['COMMA_SEPARATOR'], $address_list[$message_id]) : '') - ); - } - unset($folder_info['rowset']); - - $template->assign_vars(array( - 'S_SHOW_RECIPIENTS' => ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) ? true : false, - 'S_SHOW_COLOUR_LEGEND' => true, - - 'REPORTED_IMG' => $user->img('icon_topic_reported', 'PM_REPORTED'), - 'S_PM_ICONS' => ($config['enable_pm_icons']) ? true : false) - ); - } - } - else - { - $export_type = $request->variable('export_option', ''); - $enclosure = $request->variable('enclosure', ''); - $delimiter = $request->variable('delimiter', ''); - - if (!check_form_key('ucp_pm_view_folder')) - { - trigger_error('FORM_INVALID'); - } - - if ($export_type == 'CSV' && ($delimiter === '' || $enclosure === '')) - { - $template->assign_var('PROMPT', true); - } - else - { - // Build Recipient List if in outbox/sentbox - - $address_temp = $address = $data = array(); - - if ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) - { - foreach ($folder_info['rowset'] as $message_id => $row) - { - $address_temp[$message_id] = rebuild_header(array('to' => $row['to_address'], 'bcc' => $row['bcc_address'])); - $address[$message_id] = array(); - } - } - - foreach ($folder_info['pm_list'] as $message_id) - { - $row = &$folder_info['rowset'][$message_id]; - - include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx); - - $sql = 'SELECT p.message_text, p.bbcode_uid - FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p, ' . USERS_TABLE . ' u - WHERE t.user_id = ' . $user->data['user_id'] . " - AND p.author_id = u.user_id - AND t.folder_id = $folder_id - AND t.msg_id = p.msg_id - AND p.msg_id = $message_id"; - $result = $db->sql_query_limit($sql, 1); - $message_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $_types = array('u', 'g'); - foreach ($_types as $ug_type) - { - if (isset($address_temp[$message_id][$ug_type]) && count($address_temp[$message_id][$ug_type])) - { - if (!isset($address[$message_id][$ug_type])) - { - $address[$message_id][$ug_type] = array(); - } - if ($ug_type == 'u') - { - $sql = 'SELECT user_id as id, username as name - FROM ' . USERS_TABLE . ' - WHERE '; - } - else - { - $sql = 'SELECT group_id as id, group_name as name - FROM ' . GROUPS_TABLE . ' - WHERE '; - } - $sql .= $db->sql_in_set(($ug_type == 'u') ? 'user_id' : 'group_id', array_map('intval', array_keys($address_temp[$message_id][$ug_type]))); - - $result = $db->sql_query($sql); - - while ($info_row = $db->sql_fetchrow($result)) - { - $address[$message_id][$ug_type][$address_temp[$message_id][$ug_type][$info_row['id']]][] = $info_row['name']; - unset($address_temp[$message_id][$ug_type][$info_row['id']]); - } - $db->sql_freeresult($result); - } - } - - // There is the chance that all recipients of the message got deleted. To avoid creating - // exports without recipients, we add a bogus "undisclosed recipient". - if (!(isset($address[$message_id]['g']) && count($address[$message_id]['g'])) && - !(isset($address[$message_id]['u']) && count($address[$message_id]['u']))) - { - $address[$message_id]['u'] = array(); - $address[$message_id]['u']['to'] = array(); - $address[$message_id]['u']['to'][] = $user->lang['UNDISCLOSED_RECIPIENT']; - } - - decode_message($message_row['message_text'], $message_row['bbcode_uid']); - - $data[] = array( - 'subject' => censor_text($row['message_subject']), - 'sender' => $row['username'], - // ISO 8601 date. For PHP4 we are able to hardcode the timezone because $user->format_date() does not set it. - 'date' => $user->format_date($row['message_time'], 'c', true), - 'to' => ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) ? $address[$message_id] : '', - 'message' => $message_row['message_text'] - ); - } - - switch ($export_type) - { - case 'CSV': - case 'CSV_EXCEL': - $mimetype = 'text/csv'; - $filetype = 'csv'; - - if ($export_type == 'CSV_EXCEL') - { - $enclosure = '"'; - $delimiter = ','; - $newline = "\r\n"; - } - else - { - $newline = "\n"; - } - - $string = ''; - foreach ($data as $value) - { - $recipients = $value['to']; - $value['to'] = $value['bcc'] = ''; - - if (is_array($recipients)) - { - foreach ($recipients as $values) - { - $value['bcc'] .= (isset($values['bcc']) && is_array($values['bcc'])) ? ',' . implode(',', $values['bcc']) : ''; - $value['to'] .= (isset($values['to']) && is_array($values['to'])) ? ',' . implode(',', $values['to']) : ''; - } - - // Remove the commas which will appear before the first entry. - $value['to'] = substr($value['to'], 1); - $value['bcc'] = substr($value['bcc'], 1); - } - - foreach ($value as $tag => $text) - { - $cell = str_replace($enclosure, $enclosure . $enclosure, $text); - - if (strpos($cell, $enclosure) !== false || strpos($cell, $delimiter) !== false || strpos($cell, $newline) !== false) - { - $string .= $enclosure . $text . $enclosure . $delimiter; - } - else - { - $string .= $cell . $delimiter; - } - } - $string = substr($string, 0, -1) . $newline; - } - break; - - case 'XML': - $mimetype = 'application/xml'; - $filetype = 'xml'; - $string = '' . "\n"; - $string .= "\n"; - - foreach ($data as $value) - { - $string .= "\t\n"; - - if (is_array($value['to'])) - { - foreach ($value['to'] as $key => $values) - { - foreach ($values as $type => $types) - { - foreach ($types as $name) - { - $string .= "\t\t$name\n"; - } - } - } - } - - unset($value['to']); - - foreach ($value as $tag => $text) - { - $string .= "\t\t<$tag>$text\n"; - } - - $string .= "\t\n"; - } - $string .= ''; - break; - } - - header('Cache-Control: private, no-cache'); - header("Content-Type: $mimetype; name=\"data.$filetype\""); - header("Content-disposition: attachment; filename=data.$filetype"); - echo $string; - exit; - } - } -} - -/** -* Get Messages from folder/user -*/ -function get_pm_from($folder_id, $folder, $user_id) -{ - global $user, $db, $template, $config, $auth, $phpbb_container, $phpbb_root_path, $phpEx, $request, $phpbb_dispatcher; - - $start = $request->variable('start', 0); - - // Additional vars later, pm ordering is mostly different from post ordering. :/ - $sort_days = $request->variable('st', 0); - $sort_key = $request->variable('sk', 't'); - $sort_dir = $request->variable('sd', 'd'); - - /* @var $pagination \phpbb\pagination */ - $pagination = $phpbb_container->get('pagination'); - - // PM ordering options - $limit_days = array(0 => $user->lang['ALL_MESSAGES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); - - // No sort by Author for sentbox/outbox (already only author available) - // Also, sort by msg_id for the time - private messages are not as prone to errors as posts are. - if ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) - { - $sort_by_text = array('t' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']); - $sort_by_sql = array('t' => 'p.message_time', 's' => array('p.message_subject', 'p.message_time')); - } - else - { - $sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']); - $sort_by_sql = array('a' => array('u.username_clean', 'p.message_time'), 't' => 'p.message_time', 's' => array('p.message_subject', 'p.message_time')); - } - - $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; - gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); - - $folder_sql = 't.folder_id = ' . (int) $folder_id; - - // Limit pms to certain time frame, obtain correct pm count - if ($sort_days) - { - $min_post_time = time() - ($sort_days * 86400); - - if (isset($_POST['sort'])) - { - $start = 0; - } - - $sql = 'SELECT COUNT(t.msg_id) AS pm_count - FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . " p - WHERE $folder_sql - AND t.user_id = $user_id - AND t.msg_id = p.msg_id - AND p.message_time >= $min_post_time"; - $result = $db->sql_query_limit($sql, 1); - $pm_count = (int) $db->sql_fetchfield('pm_count'); - $db->sql_freeresult($result); - - $sql_limit_time = "AND p.message_time >= $min_post_time"; - } - else - { - $pm_count = (!empty($folder[$folder_id]['num_messages'])) ? $folder[$folder_id]['num_messages'] : 0; - $sql_limit_time = ''; - } - - $base_url = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=pm&mode=view&action=view_folder&f=$folder_id&$u_sort_param"); - $start = $pagination->validate_start($start, $config['topics_per_page'], $pm_count); - $pagination->generate_template_pagination($base_url, 'pagination', 'start', $pm_count, $config['topics_per_page'], $start); - - $template_vars = array( - 'TOTAL_MESSAGES' => $user->lang('VIEW_PM_MESSAGES', (int) $pm_count), - - 'POST_IMG' => (!$auth->acl_get('u_sendpm')) ? $user->img('button_topic_locked', 'POST_PM_LOCKED') : $user->img('button_pm_new', 'POST_NEW_PM'), - - 'S_NO_AUTH_SEND_MESSAGE' => !$auth->acl_get('u_sendpm'), - - 'S_SELECT_SORT_DIR' => $s_sort_dir, - 'S_SELECT_SORT_KEY' => $s_sort_key, - 'S_SELECT_SORT_DAYS' => $s_limit_days, - 'S_TOPIC_ICONS' => ($config['enable_pm_icons']) ? true : false, - - 'U_POST_NEW_TOPIC' => ($auth->acl_get('u_sendpm')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose') : '', - 'S_PM_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", "i=pm&mode=view&action=view_folder&f=$folder_id" . (($start !== 0) ? "&start=$start" : '')), - ); - - /** - * Modify template variables before they are assigned - * - * @event core.ucp_pm_view_folder_get_pm_from_template - * @var int folder_id Folder ID - * @var array folder Folder data - * @var int user_id User ID - * @var string base_url Pagination base URL - * @var int start Pagination start - * @var int pm_count Count of PMs - * @var array template_vars Template variables to be assigned - * @since 3.1.11-RC1 - */ - $vars = array( - 'folder_id', - 'folder', - 'user_id', - 'base_url', - 'start', - 'pm_count', - 'template_vars', - ); - extract($phpbb_dispatcher->trigger_event('core.ucp_pm_view_folder_get_pm_from_template', compact($vars))); - - $template->assign_vars($template_vars); - - // Grab all pm data - $rowset = $pm_list = array(); - - // If the user is trying to reach late pages, start searching from the end - $store_reverse = false; - $sql_limit = $config['topics_per_page']; - if ($start > $pm_count / 2) - { - $store_reverse = true; - - // Select the sort order - $direction = ($sort_dir == 'd') ? 'ASC' : 'DESC'; - $sql_limit = $pagination->reverse_limit($start, $sql_limit, $pm_count); - $sql_start = $pagination->reverse_start($start, $sql_limit, $pm_count); - } - else - { - // Select the sort order - $direction = ($sort_dir == 'd') ? 'DESC' : 'ASC'; - $sql_start = $start; - } - - // Sql sort order - if (is_array($sort_by_sql[$sort_key])) - { - $sql_sort_order = implode(' ' . $direction . ', ', $sort_by_sql[$sort_key]) . ' ' . $direction; - } - else - { - $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . $direction; - } - - $sql_ary = array( - 'SELECT' => 't.*, p.root_level, p.message_time, p.message_subject, p.icon_id, p.to_address, p.message_attachment, p.bcc_address, u.username, u.username_clean, u.user_colour, p.message_reported', - 'FROM' => array( - PRIVMSGS_TO_TABLE => 't', - PRIVMSGS_TABLE => 'p', - USERS_TABLE => 'u', - ), - 'WHERE' => "t.user_id = $user_id - AND p.author_id = u.user_id - AND $folder_sql - AND t.msg_id = p.msg_id - $sql_limit_time", - 'ORDER_BY' => $sql_sort_order, - ); - - /** - * Modify SQL before it is executed - * - * @event core.ucp_pm_view_folder_get_pm_from_sql - * @var array sql_ary SQL array - * @var int sql_limit SQL limit - * @var int sql_start SQL start - * @since 3.1.11-RC1 - */ - $vars = array( - 'sql_ary', - 'sql_limit', - 'sql_start', - ); - extract($phpbb_dispatcher->trigger_event('core.ucp_pm_view_folder_get_pm_from_sql', compact($vars))); - - $result = $db->sql_query_limit($db->sql_build_query('SELECT', $sql_ary), $sql_limit, $sql_start); - - $pm_reported = array(); - while ($row = $db->sql_fetchrow($result)) - { - $rowset[$row['msg_id']] = $row; - $pm_list[] = $row['msg_id']; - if ($row['message_reported']) - { - $pm_reported[] = $row['msg_id']; - } - } - $db->sql_freeresult($result); - - // Fetch the report_ids, if there are any reported pms. - if (!empty($pm_reported) && $auth->acl_getf_global('m_report')) - { - $sql = 'SELECT pm_id, report_id - FROM ' . REPORTS_TABLE . ' - WHERE report_closed = 0 - AND ' . $db->sql_in_set('pm_id', $pm_reported); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $rowset[$row['pm_id']]['report_id'] = $row['report_id']; - } - $db->sql_freeresult($result); - } - - $pm_list = ($store_reverse) ? array_reverse($pm_list) : $pm_list; - - return array( - 'pm_count' => $pm_count, - 'pm_list' => $pm_list, - 'rowset' => $rowset - ); -} diff --git a/install/update/new/includes/ucp/ucp_profile.php b/install/update/new/includes/ucp/ucp_profile.php deleted file mode 100644 index dca7e7e..0000000 --- a/install/update/new/includes/ucp/ucp_profile.php +++ /dev/null @@ -1,847 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* ucp_profile -* Changing profile settings -* -* @todo what about pertaining user_sig_options? -*/ -class ucp_profile -{ - var $u_action; - - function main($id, $mode) - { - global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx; - global $request, $phpbb_container, $phpbb_log, $phpbb_dispatcher; - - $user->add_lang('posting'); - - $submit = $request->variable('submit', false, false, \phpbb\request\request_interface::POST); - $error = $data = array(); - $s_hidden_fields = ''; - - switch ($mode) - { - case 'reg_details': - - $data = array( - 'username' => $request->variable('username', $user->data['username'], true), - 'email' => strtolower($request->variable('email', $user->data['user_email'])), - 'new_password' => $request->variable('new_password', '', true), - 'cur_password' => $request->variable('cur_password', '', true), - 'password_confirm' => $request->variable('password_confirm', '', true), - ); - - /** - * Modify user registration data on editing account settings in UCP - * - * @event core.ucp_profile_reg_details_data - * @var array data Array with current or updated user registration data - * @var bool submit Flag indicating if submit button has been pressed - * @since 3.1.4-RC1 - */ - $vars = array('data', 'submit'); - extract($phpbb_dispatcher->trigger_event('core.ucp_profile_reg_details_data', compact($vars))); - - add_form_key('ucp_reg_details'); - - if ($submit) - { - // Do not check cur_password, it is the old one. - $check_ary = array( - 'new_password' => array( - array('string', true, $config['min_pass_chars'], 0), - array('password')), - 'password_confirm' => array('string', true, $config['min_pass_chars'], 0), - 'email' => array( - array('string', false, 6, 60), - array('user_email')), - ); - - if ($auth->acl_get('u_chgname') && $config['allow_namechange']) - { - $check_ary['username'] = array( - array('string', false, $config['min_name_chars'], $config['max_name_chars']), - array('username'), - ); - } - - $error = validate_data($data, $check_ary); - - if ($auth->acl_get('u_chgpasswd') && $data['new_password'] && $data['password_confirm'] != $data['new_password']) - { - $error[] = ($data['password_confirm']) ? 'NEW_PASSWORD_ERROR' : 'NEW_PASSWORD_CONFIRM_EMPTY'; - } - - // Instantiate passwords manager - /* @var $passwords_manager \phpbb\passwords\manager */ - $passwords_manager = $phpbb_container->get('passwords.manager'); - - // Only check the new password against the previous password if there have been no errors - if (!count($error) && $auth->acl_get('u_chgpasswd') && $data['new_password'] && $passwords_manager->check($data['new_password'], $user->data['user_password'])) - { - $error[] = 'SAME_PASSWORD_ERROR'; - } - - if (!$passwords_manager->check($data['cur_password'], $user->data['user_password'])) - { - $error[] = ($data['cur_password']) ? 'CUR_PASSWORD_ERROR' : 'CUR_PASSWORD_EMPTY'; - } - - if (!check_form_key('ucp_reg_details')) - { - $error[] = 'FORM_INVALID'; - } - - /** - * Validate user data on editing registration data in UCP - * - * @event core.ucp_profile_reg_details_validate - * @var array data Array with user profile data - * @var bool submit Flag indicating if submit button has been pressed - * @var array error Array of any generated errors - * @since 3.1.4-RC1 - */ - $vars = array('data', 'submit', 'error'); - extract($phpbb_dispatcher->trigger_event('core.ucp_profile_reg_details_validate', compact($vars))); - - if (!count($error)) - { - $sql_ary = array( - 'username' => ($auth->acl_get('u_chgname') && $config['allow_namechange']) ? $data['username'] : $user->data['username'], - 'username_clean' => ($auth->acl_get('u_chgname') && $config['allow_namechange']) ? utf8_clean_string($data['username']) : $user->data['username_clean'], - 'user_email' => ($auth->acl_get('u_chgemail')) ? $data['email'] : $user->data['user_email'], - 'user_password' => ($auth->acl_get('u_chgpasswd') && $data['new_password']) ? $passwords_manager->hash($data['new_password']) : $user->data['user_password'], - ); - - if ($auth->acl_get('u_chgname') && $config['allow_namechange'] && $data['username'] != $user->data['username']) - { - $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_UPDATE_NAME', false, array( - 'reportee_id' => $user->data['user_id'], - $user->data['username'], - $data['username'] - )); - } - - if ($auth->acl_get('u_chgpasswd') && $data['new_password'] && !$passwords_manager->check($data['new_password'], $user->data['user_password'])) - { - $sql_ary['user_passchg'] = time(); - - $user->reset_login_keys(); - $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_NEW_PASSWORD', false, array( - 'reportee_id' => $user->data['user_id'], - $user->data['username'] - )); - } - - if ($auth->acl_get('u_chgemail') && $data['email'] != $user->data['user_email']) - { - $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_UPDATE_EMAIL', false, array( - 'reportee_id' => $user->data['user_id'], - $user->data['username'], - $user->data['user_email'], - $data['email'] - )); - } - - $message = 'PROFILE_UPDATED'; - - if ($auth->acl_get('u_chgemail') && $config['email_enable'] && $data['email'] != $user->data['user_email'] && $user->data['user_type'] != USER_FOUNDER && ($config['require_activation'] == USER_ACTIVATION_SELF || $config['require_activation'] == USER_ACTIVATION_ADMIN)) - { - $message = ($config['require_activation'] == USER_ACTIVATION_SELF) ? 'ACCOUNT_EMAIL_CHANGED' : 'ACCOUNT_EMAIL_CHANGED_ADMIN'; - - include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); - - $server_url = generate_board_url(); - - $user_actkey = gen_rand_string(mt_rand(6, 10)); - - $messenger = new messenger(false); - - $template_file = ($config['require_activation'] == USER_ACTIVATION_ADMIN) ? 'user_activate_inactive' : 'user_activate'; - $messenger->template($template_file, $user->data['user_lang']); - - $messenger->to($data['email'], $data['username']); - - $messenger->anti_abuse_headers($config, $user); - - $messenger->assign_vars(array( - 'USERNAME' => htmlspecialchars_decode($data['username']), - 'U_ACTIVATE' => "$server_url/ucp.$phpEx?mode=activate&u={$user->data['user_id']}&k=$user_actkey") - ); - - $messenger->send(NOTIFY_EMAIL); - - if ($config['require_activation'] == USER_ACTIVATION_ADMIN) - { - $notifications_manager = $phpbb_container->get('notification_manager'); - $notifications_manager->add_notifications('notification.type.admin_activate_user', array( - 'user_id' => $user->data['user_id'], - 'user_actkey' => $user_actkey, - 'user_regdate' => time(), // Notification time - )); - } - - user_active_flip('deactivate', $user->data['user_id'], INACTIVE_PROFILE); - - // Because we want the profile to be reactivated we set user_newpasswd to empty (else the reactivation will fail) - $sql_ary['user_actkey'] = $user_actkey; - $sql_ary['user_newpasswd'] = ''; - } - - /** - * Modify user registration data before submitting it to the database - * - * @event core.ucp_profile_reg_details_sql_ary - * @var array data Array with current or updated user registration data - * @var array sql_ary Array with user registration data to submit to the database - * @since 3.1.4-RC1 - */ - $vars = array('data', 'sql_ary'); - extract($phpbb_dispatcher->trigger_event('core.ucp_profile_reg_details_sql_ary', compact($vars))); - - if (count($sql_ary)) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE user_id = ' . $user->data['user_id']; - $db->sql_query($sql); - } - - // Need to update config, forum, topic, posting, messages, etc. - if ($data['username'] != $user->data['username'] && $auth->acl_get('u_chgname') && $config['allow_namechange']) - { - user_update_name($user->data['username'], $data['username']); - } - - // Now, we can remove the user completely (kill the session) - NOT BEFORE!!! - if (!empty($sql_ary['user_actkey'])) - { - meta_refresh(5, append_sid($phpbb_root_path . 'index.' . $phpEx)); - $message = $user->lang[$message] . '

' . sprintf($user->lang['RETURN_INDEX'], '', ''); - - // Because the user gets deactivated we log him out too, killing his session - $user->session_kill(); - } - else - { - meta_refresh(3, $this->u_action); - $message = $user->lang[$message] . '

' . sprintf($user->lang['RETURN_UCP'], '', ''); - } - - trigger_error($message); - } - - // Replace "error" strings with their real, localised form - $error = array_map(array($user, 'lang'), $error); - } - - $template->assign_vars(array( - 'ERROR' => (count($error)) ? implode('
', $error) : '', - - 'USERNAME' => $data['username'], - 'EMAIL' => $data['email'], - 'PASSWORD_CONFIRM' => $data['password_confirm'], - 'NEW_PASSWORD' => $data['new_password'], - 'CUR_PASSWORD' => '', - - 'L_USERNAME_EXPLAIN' => $user->lang($config['allow_name_chars'] . '_EXPLAIN', $user->lang('CHARACTERS', (int) $config['min_name_chars']), $user->lang('CHARACTERS', (int) $config['max_name_chars'])), - 'L_CHANGE_PASSWORD_EXPLAIN' => $user->lang($config['pass_complex'] . '_EXPLAIN', $user->lang('CHARACTERS', (int) $config['min_pass_chars'])), - - 'S_FORCE_PASSWORD' => ($auth->acl_get('u_chgpasswd') && $config['chg_passforce'] && $user->data['user_passchg'] < time() - ($config['chg_passforce'] * 86400)) ? true : false, - 'S_CHANGE_USERNAME' => ($config['allow_namechange'] && $auth->acl_get('u_chgname')) ? true : false, - 'S_CHANGE_EMAIL' => ($auth->acl_get('u_chgemail')) ? true : false, - 'S_CHANGE_PASSWORD' => ($auth->acl_get('u_chgpasswd')) ? true : false) - ); - break; - - case 'profile_info': - // Do not display profile information panel if not authed to do so - if (!$auth->acl_get('u_chgprofileinfo')) - { - send_status_line(403, 'Forbidden'); - trigger_error('NO_AUTH_PROFILEINFO'); - } - - /* @var $cp \phpbb\profilefields\manager */ - $cp = $phpbb_container->get('profilefields.manager'); - - $cp_data = $cp_error = array(); - - $data = array( - 'jabber' => $request->variable('jabber', $user->data['user_jabber'], true), - ); - - if ($config['allow_birthdays']) - { - $data['bday_day'] = $data['bday_month'] = $data['bday_year'] = 0; - - if ($user->data['user_birthday']) - { - list($data['bday_day'], $data['bday_month'], $data['bday_year']) = explode('-', $user->data['user_birthday']); - } - - $data['bday_day'] = $request->variable('bday_day', $data['bday_day']); - $data['bday_month'] = $request->variable('bday_month', $data['bday_month']); - $data['bday_year'] = $request->variable('bday_year', $data['bday_year']); - $data['user_birthday'] = sprintf('%2d-%2d-%4d', $data['bday_day'], $data['bday_month'], $data['bday_year']); - } - - /** - * Modify user data on editing profile in UCP - * - * @event core.ucp_profile_modify_profile_info - * @var array data Array with user profile data - * @var bool submit Flag indicating if submit button has been pressed - * @since 3.1.4-RC1 - */ - $vars = array('data', 'submit'); - extract($phpbb_dispatcher->trigger_event('core.ucp_profile_modify_profile_info', compact($vars))); - - add_form_key('ucp_profile_info'); - - if ($submit) - { - $validate_array = array( - 'jabber' => array( - array('string', true, 5, 255), - array('jabber')), - ); - - if ($config['allow_birthdays']) - { - $validate_array = array_merge($validate_array, array( - 'bday_day' => array('num', true, 1, 31), - 'bday_month' => array('num', true, 1, 12), - 'bday_year' => array('num', true, 1901, gmdate('Y', time()) + 50), - 'user_birthday' => array('date', true), - )); - } - - $error = validate_data($data, $validate_array); - - // validate custom profile fields - $cp->submit_cp_field('profile', $user->get_iso_lang_id(), $cp_data, $cp_error); - - if (count($cp_error)) - { - $error = array_merge($error, $cp_error); - } - - if (!check_form_key('ucp_profile_info')) - { - $error[] = 'FORM_INVALID'; - } - - /** - * Validate user data on editing profile in UCP - * - * @event core.ucp_profile_validate_profile_info - * @var array data Array with user profile data - * @var bool submit Flag indicating if submit button has been pressed - * @var array error Array of any generated errors - * @since 3.1.4-RC1 - */ - $vars = array('data', 'submit', 'error'); - extract($phpbb_dispatcher->trigger_event('core.ucp_profile_validate_profile_info', compact($vars))); - - if (!count($error)) - { - $data['notify'] = $user->data['user_notify_type']; - - if ($data['notify'] == NOTIFY_IM && (!$config['jab_enable'] || !$data['jabber'] || !@extension_loaded('xml'))) - { - // User has not filled in a jabber address (Or one of the modules is disabled or jabber is disabled) - // Disable notify by Jabber now for this user. - $data['notify'] = NOTIFY_EMAIL; - } - - $sql_ary = array( - 'user_jabber' => $data['jabber'], - 'user_notify_type' => $data['notify'], - ); - - if ($config['allow_birthdays']) - { - $sql_ary['user_birthday'] = $data['user_birthday']; - } - - /** - * Modify profile data in UCP before submitting to the database - * - * @event core.ucp_profile_info_modify_sql_ary - * @var array cp_data Array with the user custom profile fields data - * @var array data Array with user profile data - * @var array sql_ary user options data we update - * @since 3.1.4-RC1 - */ - $vars = array('cp_data', 'data', 'sql_ary'); - extract($phpbb_dispatcher->trigger_event('core.ucp_profile_info_modify_sql_ary', compact($vars))); - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE user_id = ' . $user->data['user_id']; - $db->sql_query($sql); - - // Update Custom Fields - $cp->update_profile_field_data($user->data['user_id'], $cp_data); - - meta_refresh(3, $this->u_action); - $message = $user->lang['PROFILE_UPDATED'] . '

' . sprintf($user->lang['RETURN_UCP'], '', ''); - trigger_error($message); - } - - // Replace "error" strings with their real, localised form - $error = array_map(array($user, 'lang'), $error); - } - - if ($config['allow_birthdays']) - { - $s_birthday_day_options = ''; - for ($i = 1; $i < 32; $i++) - { - $selected = ($i == $data['bday_day']) ? ' selected="selected"' : ''; - $s_birthday_day_options .= ""; - } - - $s_birthday_month_options = ''; - for ($i = 1; $i < 13; $i++) - { - $selected = ($i == $data['bday_month']) ? ' selected="selected"' : ''; - $s_birthday_month_options .= ""; - } - - $now = getdate(); - $s_birthday_year_options = ''; - for ($i = $now['year'] - 100; $i <= $now['year']; $i++) - { - $selected = ($i == $data['bday_year']) ? ' selected="selected"' : ''; - $s_birthday_year_options .= ""; - } - unset($now); - - $template->assign_vars(array( - 'S_BIRTHDAY_DAY_OPTIONS' => $s_birthday_day_options, - 'S_BIRTHDAY_MONTH_OPTIONS' => $s_birthday_month_options, - 'S_BIRTHDAY_YEAR_OPTIONS' => $s_birthday_year_options, - 'S_BIRTHDAYS_ENABLED' => true, - )); - } - - $template->assign_vars(array( - 'ERROR' => (count($error)) ? implode('
', $error) : '', - 'S_JABBER_ENABLED' => $config['jab_enable'], - 'JABBER' => $data['jabber'], - )); - - // Get additional profile fields and assign them to the template block var 'profile_fields' - $user->get_profile_fields($user->data['user_id']); - - $cp->generate_profile_fields('profile', $user->get_iso_lang_id()); - - break; - - case 'signature': - - if (!$auth->acl_get('u_sig')) - { - send_status_line(403, 'Forbidden'); - trigger_error('NO_AUTH_SIGNATURE'); - } - - if (!function_exists('generate_smilies')) - { - include($phpbb_root_path . 'includes/functions_posting.' . $phpEx); - } - - if (!function_exists('display_custom_bbcodes')) - { - include($phpbb_root_path . 'includes/functions_display.' . $phpEx); - } - - $preview = $request->is_set_post('preview'); - - $enable_bbcode = ($config['allow_sig_bbcode']) ? $user->optionget('sig_bbcode') : false; - $enable_smilies = ($config['allow_sig_smilies']) ? $user->optionget('sig_smilies') : false; - $enable_urls = ($config['allow_sig_links']) ? $user->optionget('sig_links') : false; - - $bbcode_flags = ($enable_bbcode ? OPTION_FLAG_BBCODE : 0) + ($enable_smilies ? OPTION_FLAG_SMILIES : 0) + ($enable_urls ? OPTION_FLAG_LINKS : 0); - - $decoded_message = generate_text_for_edit($user->data['user_sig'], $user->data['user_sig_bbcode_uid'], $bbcode_flags); - $signature = $request->variable('signature', $decoded_message['text'], true); - $signature_preview = ''; - - if ($submit || $preview) - { - $enable_bbcode = ($config['allow_sig_bbcode']) ? !$request->variable('disable_bbcode', false) : false; - $enable_smilies = ($config['allow_sig_smilies']) ? !$request->variable('disable_smilies', false) : false; - $enable_urls = ($config['allow_sig_links']) ? !$request->variable('disable_magic_url', false) : false; - - if (!check_form_key('ucp_sig')) - { - $error[] = 'FORM_INVALID'; - } - } - - /** - * Modify user signature on editing profile in UCP - * - * @event core.ucp_profile_modify_signature - * @var bool enable_bbcode Whether or not bbcode is enabled - * @var bool enable_smilies Whether or not smilies are enabled - * @var bool enable_urls Whether or not urls are enabled - * @var string signature Users signature text - * @var array error Any error strings - * @var bool submit Whether or not the form has been sumitted - * @var bool preview Whether or not the signature is being previewed - * @since 3.1.10-RC1 - * @changed 3.2.0-RC2 Removed message parser - */ - $vars = array( - 'enable_bbcode', - 'enable_smilies', - 'enable_urls', - 'signature', - 'error', - 'submit', - 'preview', - ); - extract($phpbb_dispatcher->trigger_event('core.ucp_profile_modify_signature', compact($vars))); - - $bbcode_uid = $bbcode_bitfield = $bbcode_flags = ''; - $warn_msg = generate_text_for_storage( - $signature, - $bbcode_uid, - $bbcode_bitfield, - $bbcode_flags, - $enable_bbcode, - $enable_urls, - $enable_smilies, - $config['allow_sig_img'], - $config['allow_sig_flash'], - true, - $config['allow_sig_links'], - 'sig' - ); - - if (count($warn_msg)) - { - $error += $warn_msg; - } - - if (!$submit) - { - // Parse it for displaying - $signature_preview = generate_text_for_display($signature, $bbcode_uid, $bbcode_bitfield, $bbcode_flags); - } - else - { - if (!count($error)) - { - $user->optionset('sig_bbcode', $enable_bbcode); - $user->optionset('sig_smilies', $enable_smilies); - $user->optionset('sig_links', $enable_urls); - - $sql_ary = array( - 'user_sig' => $signature, - 'user_options' => $user->data['user_options'], - 'user_sig_bbcode_uid' => $bbcode_uid, - 'user_sig_bbcode_bitfield' => $bbcode_bitfield - ); - - /** - * Modify user registration data before submitting it to the database - * - * @event core.ucp_profile_modify_signature_sql_ary - * @var array sql_ary Array with user signature data to submit to the database - * @since 3.1.10-RC1 - */ - $vars = array('sql_ary'); - extract($phpbb_dispatcher->trigger_event('core.ucp_profile_modify_signature_sql_ary', compact($vars))); - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE user_id = ' . $user->data['user_id']; - $db->sql_query($sql); - - $message = $user->lang['PROFILE_UPDATED'] . '

' . sprintf($user->lang['RETURN_UCP'], '', ''); - trigger_error($message); - } - } - - // Replace "error" strings with their real, localised form - $error = array_map(array($user, 'lang'), $error); - - if ($request->is_set_post('preview')) - { - $decoded_message = generate_text_for_edit($signature, $bbcode_uid, $bbcode_flags); - } - - /** @var \phpbb\controller\helper $controller_helper */ - $controller_helper = $phpbb_container->get('controller.helper'); - - $template->assign_vars(array( - 'ERROR' => (count($error)) ? implode('
', $error) : '', - 'SIGNATURE' => $decoded_message['text'], - 'SIGNATURE_PREVIEW' => $signature_preview, - - 'S_BBCODE_CHECKED' => (!$enable_bbcode) ? ' checked="checked"' : '', - 'S_SMILIES_CHECKED' => (!$enable_smilies) ? ' checked="checked"' : '', - 'S_MAGIC_URL_CHECKED' => (!$enable_urls) ? ' checked="checked"' : '', - - 'BBCODE_STATUS' => $user->lang(($config['allow_sig_bbcode'] ? 'BBCODE_IS_ON' : 'BBCODE_IS_OFF'), '', ''), - 'SMILIES_STATUS' => ($config['allow_sig_smilies']) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'], - 'IMG_STATUS' => ($config['allow_sig_img']) ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'], - 'FLASH_STATUS' => ($config['allow_sig_flash']) ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'], - 'URL_STATUS' => ($config['allow_sig_links']) ? $user->lang['URL_IS_ON'] : $user->lang['URL_IS_OFF'], - 'MAX_FONT_SIZE' => (int) $config['max_sig_font_size'], - - 'L_SIGNATURE_EXPLAIN' => $user->lang('SIGNATURE_EXPLAIN', (int) $config['max_sig_chars']), - - 'S_BBCODE_ALLOWED' => $config['allow_sig_bbcode'], - 'S_SMILIES_ALLOWED' => $config['allow_sig_smilies'], - 'S_BBCODE_IMG' => ($config['allow_sig_img']) ? true : false, - 'S_BBCODE_FLASH' => ($config['allow_sig_flash']) ? true : false, - 'S_LINKS_ALLOWED' => ($config['allow_sig_links']) ? true : false) - ); - - add_form_key('ucp_sig'); - - // Build custom bbcodes array - display_custom_bbcodes(); - - // Generate smiley listing - generate_smilies('inline', 0); - - break; - - case 'avatar': - - add_form_key('ucp_avatar'); - - $avatars_enabled = false; - - if ($config['allow_avatar'] && $auth->acl_get('u_chgavatar')) - { - /* @var $phpbb_avatar_manager \phpbb\avatar\manager */ - $phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); - $avatar_drivers = $phpbb_avatar_manager->get_enabled_drivers(); - - // This is normalised data, without the user_ prefix - $avatar_data = \phpbb\avatar\manager::clean_row($user->data, 'user'); - - if ($submit) - { - if (check_form_key('ucp_avatar')) - { - $driver_name = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', '')); - - if (in_array($driver_name, $avatar_drivers) && !$request->is_set_post('avatar_delete')) - { - $driver = $phpbb_avatar_manager->get_driver($driver_name); - $result = $driver->process_form($request, $template, $user, $avatar_data, $error); - - if ($result && empty($error)) - { - // Success! Lets save the result in the database - $result = array( - 'user_avatar_type' => $driver_name, - 'user_avatar' => $result['avatar'], - 'user_avatar_width' => $result['avatar_width'], - 'user_avatar_height' => $result['avatar_height'], - ); - - /** - * Trigger events on successfull avatar change - * - * @event core.ucp_profile_avatar_sql - * @var array result Array with data to be stored in DB - * @since 3.1.11-RC1 - */ - $vars = array('result'); - extract($phpbb_dispatcher->trigger_event('core.ucp_profile_avatar_sql', compact($vars))); - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $result) . ' - WHERE user_id = ' . (int) $user->data['user_id']; - $db->sql_query($sql); - - meta_refresh(3, $this->u_action); - $message = $user->lang['PROFILE_UPDATED'] . '

' . sprintf($user->lang['RETURN_UCP'], '', ''); - trigger_error($message); - } - } - } - else - { - $error[] = 'FORM_INVALID'; - } - } - - // Handle deletion of avatars - if ($request->is_set_post('avatar_delete')) - { - if (!confirm_box(true)) - { - confirm_box(false, $user->lang('CONFIRM_AVATAR_DELETE'), build_hidden_fields(array( - 'avatar_delete' => true, - 'i' => $id, - 'mode' => $mode)) - ); - } - else - { - $phpbb_avatar_manager->handle_avatar_delete($db, $user, $avatar_data, USERS_TABLE, 'user_'); - - meta_refresh(3, $this->u_action); - $message = $user->lang['PROFILE_UPDATED'] . '

' . sprintf($user->lang['RETURN_UCP'], '', ''); - trigger_error($message); - } - } - - $selected_driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', $user->data['user_avatar_type'])); - - $template->assign_vars(array( - 'AVATAR_MIN_WIDTH' => $config['avatar_min_width'], - 'AVATAR_MAX_WIDTH' => $config['avatar_max_width'], - 'AVATAR_MIN_HEIGHT' => $config['avatar_min_height'], - 'AVATAR_MAX_HEIGHT' => $config['avatar_max_height'], - )); - - foreach ($avatar_drivers as $current_driver) - { - $driver = $phpbb_avatar_manager->get_driver($current_driver); - - $avatars_enabled = true; - $template->set_filenames(array( - 'avatar' => $driver->get_template_name(), - )); - - if ($driver->prepare_form($request, $template, $user, $avatar_data, $error)) - { - $driver_name = $phpbb_avatar_manager->prepare_driver_name($current_driver); - $driver_upper = strtoupper($driver_name); - - $template->assign_block_vars('avatar_drivers', array( - 'L_TITLE' => $user->lang($driver_upper . '_TITLE'), - 'L_EXPLAIN' => $user->lang($driver_upper . '_EXPLAIN'), - - 'DRIVER' => $driver_name, - 'SELECTED' => $current_driver == $selected_driver, - 'OUTPUT' => $template->assign_display('avatar'), - )); - } - } - - // Replace "error" strings with their real, localised form - $error = $phpbb_avatar_manager->localize_errors($user, $error); - } - - $avatar = phpbb_get_user_avatar($user->data, 'USER_AVATAR', true); - - $template->assign_vars(array( - 'ERROR' => (count($error)) ? implode('
', $error) : '', - 'AVATAR' => $avatar, - - 'S_FORM_ENCTYPE' => ' enctype="multipart/form-data"', - - 'L_AVATAR_EXPLAIN' => phpbb_avatar_explanation_string(), - - 'S_AVATARS_ENABLED' => ($config['allow_avatar'] && $avatars_enabled), - )); - - break; - - case 'autologin_keys': - - add_form_key('ucp_autologin_keys'); - - if ($submit) - { - $keys = $request->variable('keys', array('')); - - if (!check_form_key('ucp_autologin_keys')) - { - $error[] = 'FORM_INVALID'; - } - - if (!count($error)) - { - if (!empty($keys)) - { - foreach ($keys as $key => $id) - { - $keys[$key] = $db->sql_like_expression($id . $db->get_any_char()); - } - $sql_where = '(key_id ' . implode(' OR key_id ', $keys) . ')'; - $sql = 'DELETE FROM ' . SESSIONS_KEYS_TABLE . ' - WHERE user_id = ' . (int) $user->data['user_id'] . ' - AND ' . $sql_where ; - - $db->sql_query($sql); - - meta_refresh(3, $this->u_action); - $message = $user->lang['AUTOLOGIN_SESSION_KEYS_DELETED'] . '

' . sprintf($user->lang['RETURN_UCP'], '', ''); - trigger_error($message); - } - } - - // Replace "error" strings with their real, localised form - $error = array_map(array($user, 'lang'), $error); - } - - $sql = 'SELECT key_id, last_ip, last_login - FROM ' . SESSIONS_KEYS_TABLE . ' - WHERE user_id = ' . (int) $user->data['user_id'] . ' - ORDER BY last_login ASC'; - - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $template->assign_block_vars('sessions', array( - 'KEY' => substr($row['key_id'], 0, 8), - 'IP' => $row['last_ip'], - 'LOGIN_TIME' => $user->format_date($row['last_login']), - )); - } - - $db->sql_freeresult($result); - - break; - } - - $template->assign_vars(array( - 'ERROR' => (count($error)) ? implode('
', $error) : '', - - 'L_TITLE' => $user->lang['UCP_PROFILE_' . strtoupper($mode)], - - 'S_HIDDEN_FIELDS' => $s_hidden_fields, - 'S_UCP_ACTION' => $this->u_action) - ); - - // Set desired template - $this->tpl_name = 'ucp_profile_' . $mode; - $this->page_title = 'UCP_PROFILE_' . strtoupper($mode); - } -} diff --git a/install/update/new/includes/ucp/ucp_register.php b/install/update/new/includes/ucp/ucp_register.php deleted file mode 100644 index 00fa803..0000000 --- a/install/update/new/includes/ucp/ucp_register.php +++ /dev/null @@ -1,738 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* ucp_register -* Board registration -*/ -class ucp_register -{ - var $u_action; - - function main($id, $mode) - { - global $config, $db, $user, $template, $phpbb_root_path, $phpEx; - global $request, $phpbb_container, $phpbb_dispatcher; - - // - if ($config['require_activation'] == USER_ACTIVATION_DISABLE || - (in_array($config['require_activation'], array(USER_ACTIVATION_SELF, USER_ACTIVATION_ADMIN)) && !$config['email_enable'])) - { - trigger_error('UCP_REGISTER_DISABLE'); - } - - $coppa = $request->is_set('coppa_yes') ? 1 : ($request->is_set('coppa_no') ? 0 : false); - $coppa = $request->is_set('coppa') ? $request->variable('coppa', 0) : $coppa; - $agreed = $request->variable('agreed', false); - $submit = $request->is_set_post('submit'); - $change_lang = $request->variable('change_lang', ''); - $user_lang = $request->variable('lang', $user->lang_name); - - if ($agreed && !check_form_key('ucp_register')) - { - $agreed = false; - } - - if ($coppa !== false && !check_form_key('ucp_register')) - { - $coppa = false; - } - - /** - * Add UCP register data before they are assigned to the template or submitted - * - * To assign data to the template, use $template->assign_vars() - * - * @event core.ucp_register_requests_after - * @var bool coppa Is set coppa - * @var bool agreed Did user agree to coppa? - * @var bool submit Is set post submit? - * @var string change_lang Change language request - * @var string user_lang User language request - * @since 3.1.11-RC1 - */ - $vars = array( - 'coppa', - 'agreed', - 'submit', - 'change_lang', - 'user_lang', - ); - extract($phpbb_dispatcher->trigger_event('core.ucp_register_requests_after', compact($vars))); - - add_form_key('ucp_register'); - - if ($change_lang || $user_lang != $config['default_lang']) - { - $use_lang = ($change_lang) ? basename($change_lang) : basename($user_lang); - - if (!validate_language_iso_name($use_lang)) - { - if ($change_lang) - { - $submit = false; - - // Setting back agreed to let the user view the agreement in his/her language - $agreed = false; - } - - $user_lang = $use_lang; - } - else - { - $change_lang = ''; - $user_lang = $user->lang_name; - } - } - - /* @var $cp \phpbb\profilefields\manager */ - $cp = $phpbb_container->get('profilefields.manager'); - - $error = $cp_data = $cp_error = array(); - $s_hidden_fields = array(); - - // Handle login_link data added to $_hidden_fields - $login_link_data = $this->get_login_link_data_array(); - - if (!empty($login_link_data)) - { - // Confirm that we have all necessary data - /* @var $provider_collection \phpbb\auth\provider_collection */ - $provider_collection = $phpbb_container->get('auth.provider_collection'); - $auth_provider = $provider_collection->get_provider($request->variable('auth_provider', '')); - - $result = $auth_provider->login_link_has_necessary_data($login_link_data); - if ($result !== null) - { - $error[] = $user->lang[$result]; - } - - $s_hidden_fields = array_merge($s_hidden_fields, $this->get_login_link_data_for_hidden_fields($login_link_data)); - } - - if (!$agreed || ($coppa === false && $config['coppa_enable']) || ($coppa && !$config['coppa_enable'])) - { - $add_coppa = ($coppa !== false) ? '&coppa=' . $coppa : ''; - - $s_hidden_fields = array_merge($s_hidden_fields, array( - 'change_lang' => '', - )); - - // If we change the language, we want to pass on some more possible parameter. - if ($change_lang) - { - // We do not include the password - $s_hidden_fields = array_merge($s_hidden_fields, array( - 'username' => $request->variable('username', '', true), - 'email' => strtolower($request->variable('email', '')), - 'lang' => $user->lang_name, - 'tz' => $request->variable('tz', $config['board_timezone']), - )); - - } - - // Checking amount of available languages - $sql = 'SELECT lang_id - FROM ' . LANG_TABLE; - $result = $db->sql_query($sql); - - $lang_row = array(); - while ($row = $db->sql_fetchrow($result)) - { - $lang_row[] = $row; - } - $db->sql_freeresult($result); - - if ($coppa === false && $config['coppa_enable']) - { - $now = getdate(); - $coppa_birthday = $user->create_datetime() - ->setDate($now['year'] - 13, $now['mon'], $now['mday'] - 1) - ->setTime(0, 0, 0) - ->format($user->lang['DATE_FORMAT'], true); - unset($now); - - $template_vars = array( - 'S_LANG_OPTIONS' => (count($lang_row) > 1) ? language_select($user_lang) : '', - 'L_COPPA_NO' => $user->lang('UCP_COPPA_BEFORE', $coppa_birthday), - 'L_COPPA_YES' => $user->lang('UCP_COPPA_ON_AFTER', $coppa_birthday), - - 'S_SHOW_COPPA' => true, - 'S_HIDDEN_FIELDS' => build_hidden_fields($s_hidden_fields), - 'S_UCP_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register'), - - 'COOKIE_NAME' => $config['cookie_name'], - 'COOKIE_PATH' => $config['cookie_path'], - ); - } - else - { - $template_vars = array( - 'S_LANG_OPTIONS' => (count($lang_row) > 1) ? language_select($user_lang) : '', - 'L_TERMS_OF_USE' => sprintf($user->lang['TERMS_OF_USE_CONTENT'], $config['sitename'], generate_board_url()), - - 'S_SHOW_COPPA' => false, - 'S_REGISTRATION' => true, - 'S_HIDDEN_FIELDS' => build_hidden_fields($s_hidden_fields), - 'S_UCP_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register' . $add_coppa), - - 'COOKIE_NAME' => $config['cookie_name'], - 'COOKIE_PATH' => $config['cookie_path'], - ); - } - - $tpl_name = 'ucp_agreement'; - - /** - * Allows to modify the agreements. - * - * @event core.ucp_register_agreement_modify_template_data - * @var string tpl_name Template file - * @var array template_vars Array with data about to be assigned to the template - * @var array s_hidden_fields Array with hidden form elements - * @var array lang_row Array with available languages, read only - * @since 3.2.2-RC1 - */ - $vars = array('tpl_name', 'template_vars', 's_hidden_fields', 'lang_row'); - extract($phpbb_dispatcher->trigger_event('core.ucp_register_agreement_modify_template_data', compact($vars))); - - unset($lang_row); - - $template_vars = array_merge($template_vars, array( - 'S_HIDDEN_FIELDS' => build_hidden_fields($s_hidden_fields), - )); - - $template->assign_vars($template_vars); - - /** - * Allows to modify the agreements. - * - * To assign data to the template, use $template->assign_vars() - * - * @event core.ucp_register_agreement - * @since 3.1.6-RC1 - * @deprecated 3.2.2-RC1 Replaced by core.ucp_register_agreement_modify_template_data and to be removed in 3.3.0-RC1 - */ - $phpbb_dispatcher->dispatch('core.ucp_register_agreement'); - - $this->tpl_name = $tpl_name; - return; - } - - // The CAPTCHA kicks in here. We can't help that the information gets lost on language change. - if ($config['enable_confirm']) - { - $captcha = $phpbb_container->get('captcha.factory')->get_instance($config['captcha_plugin']); - $captcha->init(CONFIRM_REG); - } - - $timezone = $config['board_timezone']; - - $data = array( - 'username' => $request->variable('username', '', true), - 'new_password' => $request->variable('new_password', '', true), - 'password_confirm' => $request->variable('password_confirm', '', true), - 'email' => strtolower($request->variable('email', '')), - 'lang' => basename($request->variable('lang', $user->lang_name)), - 'tz' => $request->variable('tz', $timezone), - ); - /** - * Add UCP register data before they are assigned to the template or submitted - * - * To assign data to the template, use $template->assign_vars() - * - * @event core.ucp_register_data_before - * @var bool submit Do we display the form only - * or did the user press submit - * @var array data Array with current ucp registration data - * @since 3.1.4-RC1 - */ - $vars = array('submit', 'data'); - extract($phpbb_dispatcher->trigger_event('core.ucp_register_data_before', compact($vars))); - - // Check and initialize some variables if needed - if ($submit) - { - $error = validate_data($data, array( - 'username' => array( - array('string', false, $config['min_name_chars'], $config['max_name_chars']), - array('username', '')), - 'new_password' => array( - array('string', false, $config['min_pass_chars'], 0), - array('password')), - 'password_confirm' => array('string', false, $config['min_pass_chars'], 0), - 'email' => array( - array('string', false, 6, 60), - array('user_email')), - 'tz' => array('timezone'), - 'lang' => array('language_iso_name'), - )); - - if (!check_form_key('ucp_register')) - { - $error[] = $user->lang['FORM_INVALID']; - } - - // Replace "error" strings with their real, localised form - $error = array_map(array($user, 'lang'), $error); - - if ($config['enable_confirm']) - { - $vc_response = $captcha->validate($data); - if ($vc_response !== false) - { - $error[] = $vc_response; - } - - if ($config['max_reg_attempts'] && $captcha->get_attempt_count() > $config['max_reg_attempts']) - { - $error[] = $user->lang['TOO_MANY_REGISTERS']; - } - } - - // DNSBL check - if ($config['check_dnsbl']) - { - if (($dnsbl = $user->check_dnsbl('register')) !== false) - { - $error[] = sprintf($user->lang['IP_BLACKLISTED'], $user->ip, $dnsbl[1]); - } - } - - // validate custom profile fields - $cp->submit_cp_field('register', $user->get_iso_lang_id(), $cp_data, $error); - - if (!count($error)) - { - if ($data['new_password'] != $data['password_confirm']) - { - $error[] = $user->lang['NEW_PASSWORD_ERROR']; - } - } - /** - * Check UCP registration data after they are submitted - * - * @event core.ucp_register_data_after - * @var bool submit Do we display the form only - * or did the user press submit - * @var array data Array with current ucp registration data - * @var array cp_data Array with custom profile fields data - * @var array error Array with list of errors - * @since 3.1.4-RC1 - */ - $vars = array('submit', 'data', 'cp_data', 'error'); - extract($phpbb_dispatcher->trigger_event('core.ucp_register_data_after', compact($vars))); - - if (!count($error)) - { - $server_url = generate_board_url(); - - // Which group by default? - $group_name = ($coppa) ? 'REGISTERED_COPPA' : 'REGISTERED'; - - $sql = 'SELECT group_id - FROM ' . GROUPS_TABLE . " - WHERE group_name = '" . $db->sql_escape($group_name) . "' - AND group_type = " . GROUP_SPECIAL; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - trigger_error('NO_GROUP'); - } - - $group_id = $row['group_id']; - - if (($coppa || - $config['require_activation'] == USER_ACTIVATION_SELF || - $config['require_activation'] == USER_ACTIVATION_ADMIN) && $config['email_enable']) - { - $user_actkey = gen_rand_string(mt_rand(6, 10)); - $user_type = USER_INACTIVE; - $user_inactive_reason = INACTIVE_REGISTER; - $user_inactive_time = time(); - } - else - { - $user_type = USER_NORMAL; - $user_actkey = ''; - $user_inactive_reason = 0; - $user_inactive_time = 0; - } - - // Instantiate passwords manager - /* @var $passwords_manager \phpbb\passwords\manager */ - $passwords_manager = $phpbb_container->get('passwords.manager'); - - $user_row = array( - 'username' => $data['username'], - 'user_password' => $passwords_manager->hash($data['new_password']), - 'user_email' => $data['email'], - 'group_id' => (int) $group_id, - 'user_timezone' => $data['tz'], - 'user_lang' => $data['lang'], - 'user_type' => $user_type, - 'user_actkey' => $user_actkey, - 'user_ip' => $user->ip, - 'user_regdate' => time(), - 'user_inactive_reason' => $user_inactive_reason, - 'user_inactive_time' => $user_inactive_time, - ); - - if ($config['new_member_post_limit']) - { - $user_row['user_new'] = 1; - } - /** - * Add into $user_row before user_add - * - * user_add allows adding more data into the users table - * - * @event core.ucp_register_user_row_after - * @var bool submit Do we display the form only - * or did the user press submit - * @var array cp_data Array with custom profile fields data - * @var array user_row Array with current ucp registration data - * @since 3.1.4-RC1 - */ - $vars = array('submit', 'cp_data', 'user_row'); - extract($phpbb_dispatcher->trigger_event('core.ucp_register_user_row_after', compact($vars))); - - // Register user... - $user_id = user_add($user_row, $cp_data); - - // This should not happen, because the required variables are listed above... - if ($user_id === false) - { - trigger_error('NO_USER', E_USER_ERROR); - } - - // Okay, captcha, your job is done. - if ($config['enable_confirm'] && isset($captcha)) - { - $captcha->reset(); - } - - if ($coppa && $config['email_enable']) - { - $message = $user->lang['ACCOUNT_COPPA']; - $email_template = 'coppa_welcome_inactive'; - } - else if ($config['require_activation'] == USER_ACTIVATION_SELF && $config['email_enable']) - { - $message = $user->lang['ACCOUNT_INACTIVE']; - $email_template = 'user_welcome_inactive'; - } - else if ($config['require_activation'] == USER_ACTIVATION_ADMIN && $config['email_enable']) - { - $message = $user->lang['ACCOUNT_INACTIVE_ADMIN']; - $email_template = 'admin_welcome_inactive'; - } - else - { - $message = $user->lang['ACCOUNT_ADDED']; - $email_template = 'user_welcome'; - - // Autologin after registration - $user->session_create($user_id, 0, false, 1); - } - - if ($config['email_enable']) - { - include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); - - $messenger = new messenger(false); - - $messenger->template($email_template, $data['lang']); - - $messenger->to($data['email'], $data['username']); - - $messenger->anti_abuse_headers($config, $user); - - $messenger->assign_vars(array( - 'WELCOME_MSG' => htmlspecialchars_decode(sprintf($user->lang['WELCOME_SUBJECT'], $config['sitename'])), - 'USERNAME' => htmlspecialchars_decode($data['username']), - 'PASSWORD' => htmlspecialchars_decode($data['new_password']), - 'U_ACTIVATE' => "$server_url/ucp.$phpEx?mode=activate&u=$user_id&k=$user_actkey") - ); - - if ($coppa) - { - $messenger->assign_vars(array( - 'FAX_INFO' => $config['coppa_fax'], - 'MAIL_INFO' => $config['coppa_mail'], - 'EMAIL_ADDRESS' => $data['email']) - ); - } - - /** - * Modify messenger data before welcome mail is sent - * - * @event core.ucp_register_welcome_email_before - * @var array user_row Array with user registration data - * @var array cp_data Array with custom profile fields data - * @var array data Array with current ucp registration data - * @var string message Message to be displayed to the user after registration - * @var string server_url Server URL - * @var int user_id New user ID - * @var string user_actkey User activation key - * @var messenger messenger phpBB Messenger - * @since 3.2.4-RC1 - */ - $vars = array( - 'user_row', - 'cp_data', - 'data', - 'message', - 'server_url', - 'user_id', - 'user_actkey', - 'messenger', - ); - extract($phpbb_dispatcher->trigger_event('core.ucp_register_welcome_email_before', compact($vars))); - - $messenger->send(NOTIFY_EMAIL); - } - - if ($config['require_activation'] == USER_ACTIVATION_ADMIN) - { - /* @var $phpbb_notifications \phpbb\notification\manager */ - $phpbb_notifications = $phpbb_container->get('notification_manager'); - $phpbb_notifications->add_notifications('notification.type.admin_activate_user', array( - 'user_id' => $user_id, - 'user_actkey' => $user_row['user_actkey'], - 'user_regdate' => $user_row['user_regdate'], - )); - } - - // Perform account linking if necessary - if (!empty($login_link_data)) - { - $login_link_data['user_id'] = $user_id; - - $result = $auth_provider->link_account($login_link_data); - - if ($result) - { - $message = $message . '

' . $user->lang[$result]; - } - } - - /** - * Perform additional actions after user registration - * - * @event core.ucp_register_register_after - * @var array user_row Array with user registration data - * @var array cp_data Array with custom profile fields data - * @var array data Array with current ucp registration data - * @var string message Message to be displayed to the user after registration - * @var string server_url Server URL - * @var int user_id New user ID - * @var string user_actkey User activation key - * @since 3.2.4-RC1 - */ - $vars = array( - 'user_row', - 'cp_data', - 'data', - 'message', - 'server_url', - 'user_id', - 'user_actkey', - ); - extract($phpbb_dispatcher->trigger_event('core.ucp_register_register_after', compact($vars))); - - $message = $message . '

' . sprintf($user->lang['RETURN_INDEX'], '', ''); - trigger_error($message); - } - } - - $s_hidden_fields = array_merge($s_hidden_fields, array( - 'agreed' => 'true', - 'change_lang' => 0, - )); - - if ($config['coppa_enable']) - { - $s_hidden_fields['coppa'] = $coppa; - } - - if ($config['enable_confirm']) - { - $s_hidden_fields = array_merge($s_hidden_fields, $captcha->get_hidden_fields()); - } - - // Visual Confirmation - Show images - if ($config['enable_confirm']) - { - $template->assign_vars(array( - 'CAPTCHA_TEMPLATE' => $captcha->get_template(), - )); - } - - // - $l_reg_cond = ''; - switch ($config['require_activation']) - { - case USER_ACTIVATION_SELF: - $l_reg_cond = $user->lang['UCP_EMAIL_ACTIVATE']; - break; - - case USER_ACTIVATION_ADMIN: - $l_reg_cond = $user->lang['UCP_ADMIN_ACTIVATE']; - break; - } - - /* @var $provider_collection \phpbb\auth\provider_collection */ - $provider_collection = $phpbb_container->get('auth.provider_collection'); - $auth_provider = $provider_collection->get_provider(); - - $auth_provider_data = $auth_provider->get_login_data(); - if ($auth_provider_data) - { - if (isset($auth_provider_data['VARS'])) - { - $template->assign_vars($auth_provider_data['VARS']); - } - - if (isset($auth_provider_data['BLOCK_VAR_NAME'])) - { - foreach ($auth_provider_data['BLOCK_VARS'] as $block_vars) - { - $template->assign_block_vars($auth_provider_data['BLOCK_VAR_NAME'], $block_vars); - } - } - - $template->assign_vars(array( - 'PROVIDER_TEMPLATE_FILE' => $auth_provider_data['TEMPLATE_FILE'], - )); - } - - // Assign template vars for timezone select - phpbb_timezone_select($template, $user, $data['tz'], true); - - $template_vars = array( - 'USERNAME' => $data['username'], - 'PASSWORD' => $data['new_password'], - 'PASSWORD_CONFIRM' => $data['password_confirm'], - 'EMAIL' => $data['email'], - - 'L_REG_COND' => $l_reg_cond, - 'L_USERNAME_EXPLAIN' => $user->lang($config['allow_name_chars'] . '_EXPLAIN', $user->lang('CHARACTERS', (int) $config['min_name_chars']), $user->lang('CHARACTERS', (int) $config['max_name_chars'])), - 'L_PASSWORD_EXPLAIN' => $user->lang($config['pass_complex'] . '_EXPLAIN', $user->lang('CHARACTERS', (int) $config['min_pass_chars'])), - - 'S_LANG_OPTIONS' => language_select($data['lang']), - 'S_TZ_PRESELECT' => !$submit, - 'S_CONFIRM_REFRESH' => ($config['enable_confirm'] && $config['confirm_refresh']) ? true : false, - 'S_REGISTRATION' => true, - 'S_COPPA' => $coppa, - 'S_UCP_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register'), - - 'COOKIE_NAME' => $config['cookie_name'], - 'COOKIE_PATH' => $config['cookie_path'], - ); - - $tpl_name = 'ucp_register'; - - /** - * Modify template data on the registration page - * - * @event core.ucp_register_modify_template_data - * @var array template_vars Array with template data - * @var array data Array with user data, read only - * @var array error Array with errors - * @var array s_hidden_fields Array with hidden field elements - * @var string tpl_name Template name - * @since 3.2.2-RC1 - */ - $vars = array( - 'template_vars', - 'data', - 'error', - 's_hidden_fields', - 'tpl_name', - ); - extract($phpbb_dispatcher->trigger_event('core.ucp_register_modify_template_data', compact($vars))); - - $template_vars = array_merge($template_vars, array( - 'ERROR' => (count($error)) ? implode('
', $error) : '', - 'S_HIDDEN_FIELDS' => build_hidden_fields($s_hidden_fields), - )); - - $template->assign_vars($template_vars); - - // - $user->profile_fields = array(); - - // Generate profile fields -> Template Block Variable profile_fields - $cp->generate_profile_fields('register', $user->get_iso_lang_id()); - - // - $this->tpl_name = $tpl_name; - } - - /** - * Creates the login_link data array - * - * @return array Returns an array of all POST paramaters whose names - * begin with 'login_link_' - */ - protected function get_login_link_data_array() - { - global $request; - - $var_names = $request->variable_names(\phpbb\request\request_interface::POST); - $login_link_data = array(); - $string_start_length = strlen('login_link_'); - - foreach ($var_names as $var_name) - { - if (strpos($var_name, 'login_link_') === 0) - { - $key_name = substr($var_name, $string_start_length); - $login_link_data[$key_name] = $request->variable($var_name, '', false, \phpbb\request\request_interface::POST); - } - } - - return $login_link_data; - } - - /** - * Prepends they key names of an associative array with 'login_link_' for - * inclusion on the page as hidden fields. - * - * @param array $data The array to be modified - * @return array The modified array - */ - protected function get_login_link_data_for_hidden_fields($data) - { - $new_data = array(); - - foreach ($data as $key => $value) - { - $new_data['login_link_' . $key] = $value; - } - - return $new_data; - } -} diff --git a/install/update/new/includes/ucp/ucp_resend.php b/install/update/new/includes/ucp/ucp_resend.php deleted file mode 100644 index 5592366..0000000 --- a/install/update/new/includes/ucp/ucp_resend.php +++ /dev/null @@ -1,163 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* ucp_resend -* Resending activation emails -*/ -class ucp_resend -{ - var $u_action; - - function main($id, $mode) - { - global $config, $phpbb_root_path, $phpEx; - global $db, $user, $auth, $template, $request; - - $username = $request->variable('username', '', true); - $email = strtolower($request->variable('email', '')); - $submit = (isset($_POST['submit'])) ? true : false; - - add_form_key('ucp_resend'); - - if ($submit) - { - if (!check_form_key('ucp_resend')) - { - trigger_error('FORM_INVALID'); - } - - $sql = 'SELECT user_id, group_id, username, user_email, user_type, user_lang, user_actkey, user_inactive_reason - FROM ' . USERS_TABLE . " - WHERE user_email = '" . $db->sql_escape($email) . "' - AND username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'"; - $result = $db->sql_query($sql); - $user_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$user_row) - { - trigger_error('NO_EMAIL_USER'); - } - - if ($user_row['user_type'] == USER_IGNORE) - { - trigger_error('NO_USER'); - } - - if (!$user_row['user_actkey'] && $user_row['user_type'] != USER_INACTIVE) - { - trigger_error('ACCOUNT_ALREADY_ACTIVATED'); - } - - if (!$user_row['user_actkey'] || ($user_row['user_type'] == USER_INACTIVE && $user_row['user_inactive_reason'] == INACTIVE_MANUAL)) - { - trigger_error('ACCOUNT_DEACTIVATED'); - } - - // Determine coppa status on group (REGISTERED(_COPPA)) - $sql = 'SELECT group_name, group_type - FROM ' . GROUPS_TABLE . ' - WHERE group_id = ' . $user_row['group_id']; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - trigger_error('NO_GROUP'); - } - - $coppa = ($row['group_name'] == 'REGISTERED_COPPA' && $row['group_type'] == GROUP_SPECIAL) ? true : false; - - include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); - $messenger = new messenger(false); - - if ($config['require_activation'] == USER_ACTIVATION_SELF || $coppa) - { - $messenger->template(($coppa) ? 'coppa_resend_inactive' : 'user_resend_inactive', $user_row['user_lang']); - $messenger->set_addresses($user_row); - - $messenger->anti_abuse_headers($config, $user); - - $messenger->assign_vars(array( - 'WELCOME_MSG' => htmlspecialchars_decode(sprintf($user->lang['WELCOME_SUBJECT'], $config['sitename'])), - 'USERNAME' => htmlspecialchars_decode($user_row['username']), - 'U_ACTIVATE' => generate_board_url() . "/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k={$user_row['user_actkey']}") - ); - - if ($coppa) - { - $messenger->assign_vars(array( - 'FAX_INFO' => $config['coppa_fax'], - 'MAIL_INFO' => $config['coppa_mail'], - 'EMAIL_ADDRESS' => $user_row['user_email']) - ); - } - - $messenger->send(NOTIFY_EMAIL); - } - - if ($config['require_activation'] == USER_ACTIVATION_ADMIN) - { - // Grab an array of user_id's with a_user permissions ... these users can activate a user - $admin_ary = $auth->acl_get_list(false, 'a_user', false); - - $sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('user_id', $admin_ary[0]['a_user']); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $messenger->template('admin_activate', $row['user_lang']); - $messenger->set_addresses($row); - - $messenger->anti_abuse_headers($config, $user); - - $messenger->assign_vars(array( - 'USERNAME' => htmlspecialchars_decode($user_row['username']), - 'U_USER_DETAILS' => generate_board_url() . "/memberlist.$phpEx?mode=viewprofile&u={$user_row['user_id']}", - 'U_ACTIVATE' => generate_board_url() . "/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k={$user_row['user_actkey']}") - ); - - $messenger->send($row['user_notify_type']); - } - $db->sql_freeresult($result); - } - - meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx")); - - $message = ($config['require_activation'] == USER_ACTIVATION_ADMIN) ? $user->lang['ACTIVATION_EMAIL_SENT_ADMIN'] : $user->lang['ACTIVATION_EMAIL_SENT']; - $message .= '

' . sprintf($user->lang['RETURN_INDEX'], '', ''); - trigger_error($message); - } - - $template->assign_vars(array( - 'USERNAME' => $username, - 'EMAIL' => $email, - 'S_PROFILE_ACTION' => append_sid($phpbb_root_path . 'ucp.' . $phpEx, 'mode=resend_act')) - ); - - $this->tpl_name = 'ucp_resend'; - $this->page_title = 'UCP_RESEND'; - } -} diff --git a/install/update/new/includes/utf/utf_tools.php b/install/update/new/includes/utf/utf_tools.php deleted file mode 100644 index bb155ae..0000000 --- a/install/update/new/includes/utf/utf_tools.php +++ /dev/null @@ -1,1469 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -// Enforce ASCII only string handling -setlocale(LC_CTYPE, 'C'); - -/** -* Setup the UTF-8 portability layer -*/ -Patchwork\Utf8\Bootup::initUtf8Encode(); -Patchwork\Utf8\Bootup::initMbstring(); -Patchwork\Utf8\Bootup::initIntl(); - -/** -* UTF-8 tools -* -* Whenever possible, these functions will try to use PHP's built-in functions or -* extensions, otherwise they will default to custom routines. -* -*/ - -/** -* UTF-8 aware alternative to strrpos -* @ignore -*/ -function utf8_strrpos($str, $needle, $offset = null) -{ - // Emulate behaviour of strrpos rather than raising warning - if (empty($str)) - { - return false; - } - - if (is_null($offset)) - { - return mb_strrpos($str, $needle); - } - else - { - return mb_strrpos($str, $needle, $offset); - } -} - -/** -* UTF-8 aware alternative to strpos -* @ignore -*/ -function utf8_strpos($str, $needle, $offset = null) -{ - if (is_null($offset)) - { - return mb_strpos($str, $needle); - } - else - { - return mb_strpos($str, $needle, $offset); - } -} - -/** -* UTF-8 aware alternative to strtolower -* @ignore -*/ -function utf8_strtolower($str) -{ - return mb_strtolower($str); -} - -/** -* UTF-8 aware alternative to strtoupper -* @ignore -*/ -function utf8_strtoupper($str) -{ - return mb_strtoupper($str); -} - -/** -* UTF-8 aware alternative to substr -* @ignore -*/ -function utf8_substr($str, $offset, $length = null) -{ - if (is_null($length)) - { - return mb_substr($str, $offset); - } - else - { - return mb_substr($str, $offset, $length); - } -} - -/** -* Return the length (in characters) of a UTF-8 string -* @ignore -*/ -function utf8_strlen($text) -{ - return mb_strlen($text, 'utf-8'); -} - -/** -* UTF-8 aware alternative to str_split -* Convert a string to an array -* -* @author Harry Fuecks -* @param string $str UTF-8 encoded -* @param int $split_len number to characters to split string by -* @return array characters in string reverses -*/ -function utf8_str_split($str, $split_len = 1) -{ - if (!is_int($split_len) || $split_len < 1) - { - return false; - } - - $len = utf8_strlen($str); - if ($len <= $split_len) - { - return array($str); - } - - preg_match_all('/.{' . $split_len . '}|[^\x00]{1,' . $split_len . '}$/us', $str, $ar); - return $ar[0]; -} - -/** -* UTF-8 aware alternative to strspn -* Find length of initial segment matching the mask -* -* @author Harry Fuecks -*/ -function utf8_strspn($str, $mask, $start = null, $length = null) -{ - if ($start !== null || $length !== null) - { - $str = utf8_substr($str, $start, $length); - } - - preg_match('/^[' . $mask . ']+/u', $str, $matches); - - if (isset($matches[0])) - { - return utf8_strlen($matches[0]); - } - - return 0; -} - -/** -* UTF-8 aware alternative to ucfirst -* Make a string's first character uppercase -* -* @author Harry Fuecks -* @param string -* @return string with first character as upper case (if applicable) -*/ -function utf8_ucfirst($str) -{ - switch (utf8_strlen($str)) - { - case 0: - return ''; - break; - - case 1: - return utf8_strtoupper($str); - break; - - default: - preg_match('/^(.{1})(.*)$/us', $str, $matches); - return utf8_strtoupper($matches[1]) . $matches[2]; - break; - } -} - -/** -* Recode a string to UTF-8 -* -* If the encoding is not supported, the string is returned as-is -* -* @param string $string Original string -* @param string $encoding Original encoding (lowered) -* @return string The string, encoded in UTF-8 -*/ -function utf8_recode($string, $encoding) -{ - $encoding = strtolower($encoding); - - if ($encoding == 'utf-8' || !is_string($string) || empty($string)) - { - return $string; - } - - // we force iso-8859-1 to be cp1252 - if ($encoding == 'iso-8859-1') - { - $encoding = 'cp1252'; - } - // convert iso-8859-8-i to iso-8859-8 - else if ($encoding == 'iso-8859-8-i') - { - $encoding = 'iso-8859-8'; - $string = hebrev($string); - } - - // First, try iconv() - if (function_exists('iconv')) - { - $ret = @iconv($encoding, 'utf-8', $string); - - if (!empty($ret)) - { - return $ret; - } - } - - // Try the mb_string extension - if (function_exists('mb_convert_encoding')) - { - // mbstring is nasty on PHP4, we must make *sure* that we send a good encoding - switch ($encoding) - { - case 'iso-8859-1': - case 'iso-8859-2': - case 'iso-8859-4': - case 'iso-8859-7': - case 'iso-8859-9': - case 'iso-8859-15': - case 'windows-1251': - case 'windows-1252': - case 'cp1252': - case 'shift_jis': - case 'euc-kr': - case 'big5': - case 'gb2312': - $ret = @mb_convert_encoding($string, 'utf-8', $encoding); - - if (!empty($ret)) - { - return $ret; - } - } - } - - // Try the recode extension - if (function_exists('recode_string')) - { - $ret = @recode_string($encoding . '..utf-8', $string); - - if (!empty($ret)) - { - return $ret; - } - } - - // If nothing works, check if we have a custom transcoder available - if (!preg_match('#^[a-z0-9_ \\-]+$#', $encoding)) - { - // Make sure the encoding name is alphanumeric, we don't want it to be abused into loading arbitrary files - trigger_error('Unknown encoding: ' . $encoding, E_USER_ERROR); - } - - global $phpbb_root_path, $phpEx; - - // iso-8859-* character encoding - if (preg_match('/iso[_ -]?8859[_ -]?(\\d+)/', $encoding, $array)) - { - switch ($array[1]) - { - case '1': - case '2': - case '4': - case '7': - case '8': - case '9': - case '15': - if (!function_exists('iso_8859_' . $array[1])) - { - if (!file_exists($phpbb_root_path . 'includes/utf/data/recode_basic.' . $phpEx)) - { - trigger_error('Basic reencoder file is missing', E_USER_ERROR); - } - include($phpbb_root_path . 'includes/utf/data/recode_basic.' . $phpEx); - } - return call_user_func('iso_8859_' . $array[1], $string); - break; - - default: - trigger_error('Unknown encoding: ' . $encoding, E_USER_ERROR); - break; - } - } - - // CP/WIN character encoding - if (preg_match('/(?:cp|windows)[_\- ]?(\\d+)/', $encoding, $array)) - { - switch ($array[1]) - { - case '932': - break; - case '1250': - case '1251': - case '1252': - case '1254': - case '1255': - case '1256': - case '1257': - case '874': - if (!function_exists('cp' . $array[1])) - { - if (!file_exists($phpbb_root_path . 'includes/utf/data/recode_basic.' . $phpEx)) - { - trigger_error('Basic reencoder file is missing', E_USER_ERROR); - } - include($phpbb_root_path . 'includes/utf/data/recode_basic.' . $phpEx); - } - return call_user_func('cp' . $array[1], $string); - break; - - default: - trigger_error('Unknown encoding: ' . $encoding, E_USER_ERROR); - break; - } - } - - // TIS-620 - if (preg_match('/tis[_ -]?620/', $encoding)) - { - if (!function_exists('tis_620')) - { - if (!file_exists($phpbb_root_path . 'includes/utf/data/recode_basic.' . $phpEx)) - { - trigger_error('Basic reencoder file is missing', E_USER_ERROR); - } - include($phpbb_root_path . 'includes/utf/data/recode_basic.' . $phpEx); - } - return tis_620($string); - } - - // SJIS - if (preg_match('/sjis(?:[_ -]?win)?|(?:cp|ibm)[_ -]?932|shift[_ -]?jis/', $encoding)) - { - if (!function_exists('sjis')) - { - if (!file_exists($phpbb_root_path . 'includes/utf/data/recode_cjk.' . $phpEx)) - { - trigger_error('CJK reencoder file is missing', E_USER_ERROR); - } - include($phpbb_root_path . 'includes/utf/data/recode_cjk.' . $phpEx); - } - return sjis($string); - } - - // EUC_KR - if (preg_match('/euc[_ -]?kr/', $encoding)) - { - if (!function_exists('euc_kr')) - { - if (!file_exists($phpbb_root_path . 'includes/utf/data/recode_cjk.' . $phpEx)) - { - trigger_error('CJK reencoder file is missing', E_USER_ERROR); - } - include($phpbb_root_path . 'includes/utf/data/recode_cjk.' . $phpEx); - } - return euc_kr($string); - } - - // BIG-5 - if (preg_match('/big[_ -]?5/', $encoding)) - { - if (!function_exists('big5')) - { - if (!file_exists($phpbb_root_path . 'includes/utf/data/recode_cjk.' . $phpEx)) - { - trigger_error('CJK reencoder file is missing', E_USER_ERROR); - } - include($phpbb_root_path . 'includes/utf/data/recode_cjk.' . $phpEx); - } - return big5($string); - } - - // GB2312 - if (preg_match('/gb[_ -]?2312/', $encoding)) - { - if (!function_exists('gb2312')) - { - if (!file_exists($phpbb_root_path . 'includes/utf/data/recode_cjk.' . $phpEx)) - { - trigger_error('CJK reencoder file is missing', E_USER_ERROR); - } - include($phpbb_root_path . 'includes/utf/data/recode_cjk.' . $phpEx); - } - return gb2312($string); - } - - // Trigger an error?! Fow now just give bad data :-( - trigger_error('Unknown encoding: ' . $encoding, E_USER_ERROR); -} - -/** - * Replace some special UTF-8 chars that are not in ASCII with their UCR. - * using their Numeric Character Reference's Hexadecimal notation. - * - * Doesn't interfere with Japanese or Cyrillic etc. - * Unicode character visualization will depend on the character support - * of your web browser and the fonts installed on your system. - * - * @see https://en.wikibooks.org/wiki/Unicode/Character_reference/1F000-1FFFF - * - * @param string $text UTF-8 string in NFC - * @return string ASCII string using NCR for non-ASCII chars - */ -function utf8_encode_ucr($text) -{ - return preg_replace_callback('/[\\xF0-\\xF4].../', 'utf8_encode_ncr_callback', $text); -} - -/** - * Replace all UTF-8 chars that are not in ASCII with their NCR - * using their Numeric Character Reference's Hexadecimal notation. - * - * @param string $text UTF-8 string in NFC - * @return string ASCII string using NCRs for non-ASCII chars - */ -function utf8_encode_ncr($text) -{ - return preg_replace_callback('#[\\xC2-\\xF4][\\x80-\\xBF]{1,3}#', 'utf8_encode_ncr_callback', $text); -} - -/** - * Callback used in utf8_encode_ncr() and utf8_encode_ucr() - * - * Takes a UTF-8 char and replaces it with its NCR. Attention, $m is an array - * - * @param array $m 0-based numerically indexed array passed by preg_replace_callback() - * @return string A HTML NCR if the character is valid, or the original string otherwise - */ -function utf8_encode_ncr_callback($m) -{ - return '&#' . utf8_ord($m[0]) . ';'; -} - -/** -* Converts a UTF-8 char to an NCR -* -* @param string $chr UTF-8 char -* @return integer UNICODE code point -*/ -function utf8_ord($chr) -{ - switch (strlen($chr)) - { - case 1: - return ord($chr); - break; - - case 2: - return ((ord($chr[0]) & 0x1F) << 6) | (ord($chr[1]) & 0x3F); - break; - - case 3: - return ((ord($chr[0]) & 0x0F) << 12) | ((ord($chr[1]) & 0x3F) << 6) | (ord($chr[2]) & 0x3F); - break; - - case 4: - return ((ord($chr[0]) & 0x07) << 18) | ((ord($chr[1]) & 0x3F) << 12) | ((ord($chr[2]) & 0x3F) << 6) | (ord($chr[3]) & 0x3F); - break; - - default: - return $chr; - } -} - -/** -* Converts an NCR to a UTF-8 char -* -* @param int $cp UNICODE code point -* @return string UTF-8 char -*/ -function utf8_chr($cp) -{ - if ($cp > 0xFFFF) - { - return chr(0xF0 | ($cp >> 18)) . chr(0x80 | (($cp >> 12) & 0x3F)) . chr(0x80 | (($cp >> 6) & 0x3F)) . chr(0x80 | ($cp & 0x3F)); - } - else if ($cp > 0x7FF) - { - return chr(0xE0 | ($cp >> 12)) . chr(0x80 | (($cp >> 6) & 0x3F)) . chr(0x80 | ($cp & 0x3F)); - } - else if ($cp > 0x7F) - { - return chr(0xC0 | ($cp >> 6)) . chr(0x80 | ($cp & 0x3F)); - } - else - { - return chr($cp); - } -} - -/** -* Convert Numeric Character References to UTF-8 chars -* -* Notes: -* - we do not convert NCRs recursively, if you pass &#38; it will return & -* - we DO NOT check for the existence of the Unicode characters, therefore an entity may be converted to an inexistent codepoint -* -* @param string $text String to convert, encoded in UTF-8 (no normal form required) -* @return string UTF-8 string where NCRs have been replaced with the actual chars -*/ -function utf8_decode_ncr($text) -{ - return preg_replace_callback('/&#([0-9]{1,6}|x[0-9A-F]{1,5});/i', 'utf8_decode_ncr_callback', $text); -} - -/** -* Callback used in decode_ncr() -* -* Takes a NCR (in decimal or hexadecimal) and returns a UTF-8 char. Attention, $m is an array. -* It will ignore most of invalid NCRs, but not all! -* -* @param array $m 0-based numerically indexed array passed by preg_replace_callback() -* @return string UTF-8 char -*/ -function utf8_decode_ncr_callback($m) -{ - $cp = (strncasecmp($m[1], 'x', 1)) ? $m[1] : hexdec(substr($m[1], 1)); - - return utf8_chr($cp); -} - -/** -* Case folds a unicode string as per Unicode 5.0, section 3.13 -* -* @param string $text text to be case folded -* @param string $option determines how we will fold the cases -* @return string case folded text -*/ -function utf8_case_fold($text, $option = 'full') -{ - static $uniarray = array(); - global $phpbb_root_path, $phpEx; - - // common is always set - if (!isset($uniarray['c'])) - { - $uniarray['c'] = include($phpbb_root_path . 'includes/utf/data/case_fold_c.' . $phpEx); - } - - // only set full if we need to - if ($option === 'full' && !isset($uniarray['f'])) - { - $uniarray['f'] = include($phpbb_root_path . 'includes/utf/data/case_fold_f.' . $phpEx); - } - - // only set simple if we need to - if ($option !== 'full' && !isset($uniarray['s'])) - { - $uniarray['s'] = include($phpbb_root_path . 'includes/utf/data/case_fold_s.' . $phpEx); - } - - // common is always replaced - $text = strtr($text, $uniarray['c']); - - if ($option === 'full') - { - // full replaces a character with multiple characters - $text = strtr($text, $uniarray['f']); - } - else - { - // simple replaces a character with another character - $text = strtr($text, $uniarray['s']); - } - - return $text; -} - -/** -* Takes the input and does a "special" case fold. It does minor normalization -* and returns NFKC compatable text -* -* @param string $text text to be case folded -* @param string $option determines how we will fold the cases -* @return string case folded text -*/ -function utf8_case_fold_nfkc($text, $option = 'full') -{ - static $fc_nfkc_closure = array( - "\xCD\xBA" => "\x20\xCE\xB9", - "\xCF\x92" => "\xCF\x85", - "\xCF\x93" => "\xCF\x8D", - "\xCF\x94" => "\xCF\x8B", - "\xCF\xB2" => "\xCF\x83", - "\xCF\xB9" => "\xCF\x83", - "\xE1\xB4\xAC" => "\x61", - "\xE1\xB4\xAD" => "\xC3\xA6", - "\xE1\xB4\xAE" => "\x62", - "\xE1\xB4\xB0" => "\x64", - "\xE1\xB4\xB1" => "\x65", - "\xE1\xB4\xB2" => "\xC7\x9D", - "\xE1\xB4\xB3" => "\x67", - "\xE1\xB4\xB4" => "\x68", - "\xE1\xB4\xB5" => "\x69", - "\xE1\xB4\xB6" => "\x6A", - "\xE1\xB4\xB7" => "\x6B", - "\xE1\xB4\xB8" => "\x6C", - "\xE1\xB4\xB9" => "\x6D", - "\xE1\xB4\xBA" => "\x6E", - "\xE1\xB4\xBC" => "\x6F", - "\xE1\xB4\xBD" => "\xC8\xA3", - "\xE1\xB4\xBE" => "\x70", - "\xE1\xB4\xBF" => "\x72", - "\xE1\xB5\x80" => "\x74", - "\xE1\xB5\x81" => "\x75", - "\xE1\xB5\x82" => "\x77", - "\xE2\x82\xA8" => "\x72\x73", - "\xE2\x84\x82" => "\x63", - "\xE2\x84\x83" => "\xC2\xB0\x63", - "\xE2\x84\x87" => "\xC9\x9B", - "\xE2\x84\x89" => "\xC2\xB0\x66", - "\xE2\x84\x8B" => "\x68", - "\xE2\x84\x8C" => "\x68", - "\xE2\x84\x8D" => "\x68", - "\xE2\x84\x90" => "\x69", - "\xE2\x84\x91" => "\x69", - "\xE2\x84\x92" => "\x6C", - "\xE2\x84\x95" => "\x6E", - "\xE2\x84\x96" => "\x6E\x6F", - "\xE2\x84\x99" => "\x70", - "\xE2\x84\x9A" => "\x71", - "\xE2\x84\x9B" => "\x72", - "\xE2\x84\x9C" => "\x72", - "\xE2\x84\x9D" => "\x72", - "\xE2\x84\xA0" => "\x73\x6D", - "\xE2\x84\xA1" => "\x74\x65\x6C", - "\xE2\x84\xA2" => "\x74\x6D", - "\xE2\x84\xA4" => "\x7A", - "\xE2\x84\xA8" => "\x7A", - "\xE2\x84\xAC" => "\x62", - "\xE2\x84\xAD" => "\x63", - "\xE2\x84\xB0" => "\x65", - "\xE2\x84\xB1" => "\x66", - "\xE2\x84\xB3" => "\x6D", - "\xE2\x84\xBB" => "\x66\x61\x78", - "\xE2\x84\xBE" => "\xCE\xB3", - "\xE2\x84\xBF" => "\xCF\x80", - "\xE2\x85\x85" => "\x64", - "\xE3\x89\x90" => "\x70\x74\x65", - "\xE3\x8B\x8C" => "\x68\x67", - "\xE3\x8B\x8E" => "\x65\x76", - "\xE3\x8B\x8F" => "\x6C\x74\x64", - "\xE3\x8D\xB1" => "\x68\x70\x61", - "\xE3\x8D\xB3" => "\x61\x75", - "\xE3\x8D\xB5" => "\x6F\x76", - "\xE3\x8D\xBA" => "\x69\x75", - "\xE3\x8E\x80" => "\x70\x61", - "\xE3\x8E\x81" => "\x6E\x61", - "\xE3\x8E\x82" => "\xCE\xBC\x61", - "\xE3\x8E\x83" => "\x6D\x61", - "\xE3\x8E\x84" => "\x6B\x61", - "\xE3\x8E\x85" => "\x6B\x62", - "\xE3\x8E\x86" => "\x6D\x62", - "\xE3\x8E\x87" => "\x67\x62", - "\xE3\x8E\x8A" => "\x70\x66", - "\xE3\x8E\x8B" => "\x6E\x66", - "\xE3\x8E\x8C" => "\xCE\xBC\x66", - "\xE3\x8E\x90" => "\x68\x7A", - "\xE3\x8E\x91" => "\x6B\x68\x7A", - "\xE3\x8E\x92" => "\x6D\x68\x7A", - "\xE3\x8E\x93" => "\x67\x68\x7A", - "\xE3\x8E\x94" => "\x74\x68\x7A", - "\xE3\x8E\xA9" => "\x70\x61", - "\xE3\x8E\xAA" => "\x6B\x70\x61", - "\xE3\x8E\xAB" => "\x6D\x70\x61", - "\xE3\x8E\xAC" => "\x67\x70\x61", - "\xE3\x8E\xB4" => "\x70\x76", - "\xE3\x8E\xB5" => "\x6E\x76", - "\xE3\x8E\xB6" => "\xCE\xBC\x76", - "\xE3\x8E\xB7" => "\x6D\x76", - "\xE3\x8E\xB8" => "\x6B\x76", - "\xE3\x8E\xB9" => "\x6D\x76", - "\xE3\x8E\xBA" => "\x70\x77", - "\xE3\x8E\xBB" => "\x6E\x77", - "\xE3\x8E\xBC" => "\xCE\xBC\x77", - "\xE3\x8E\xBD" => "\x6D\x77", - "\xE3\x8E\xBE" => "\x6B\x77", - "\xE3\x8E\xBF" => "\x6D\x77", - "\xE3\x8F\x80" => "\x6B\xCF\x89", - "\xE3\x8F\x81" => "\x6D\xCF\x89", - "\xE3\x8F\x83" => "\x62\x71", - "\xE3\x8F\x86" => "\x63\xE2\x88\x95\x6B\x67", - "\xE3\x8F\x87" => "\x63\x6F\x2E", - "\xE3\x8F\x88" => "\x64\x62", - "\xE3\x8F\x89" => "\x67\x79", - "\xE3\x8F\x8B" => "\x68\x70", - "\xE3\x8F\x8D" => "\x6B\x6B", - "\xE3\x8F\x8E" => "\x6B\x6D", - "\xE3\x8F\x97" => "\x70\x68", - "\xE3\x8F\x99" => "\x70\x70\x6D", - "\xE3\x8F\x9A" => "\x70\x72", - "\xE3\x8F\x9C" => "\x73\x76", - "\xE3\x8F\x9D" => "\x77\x62", - "\xE3\x8F\x9E" => "\x76\xE2\x88\x95\x6D", - "\xE3\x8F\x9F" => "\x61\xE2\x88\x95\x6D", - "\xF0\x9D\x90\x80" => "\x61", - "\xF0\x9D\x90\x81" => "\x62", - "\xF0\x9D\x90\x82" => "\x63", - "\xF0\x9D\x90\x83" => "\x64", - "\xF0\x9D\x90\x84" => "\x65", - "\xF0\x9D\x90\x85" => "\x66", - "\xF0\x9D\x90\x86" => "\x67", - "\xF0\x9D\x90\x87" => "\x68", - "\xF0\x9D\x90\x88" => "\x69", - "\xF0\x9D\x90\x89" => "\x6A", - "\xF0\x9D\x90\x8A" => "\x6B", - "\xF0\x9D\x90\x8B" => "\x6C", - "\xF0\x9D\x90\x8C" => "\x6D", - "\xF0\x9D\x90\x8D" => "\x6E", - "\xF0\x9D\x90\x8E" => "\x6F", - "\xF0\x9D\x90\x8F" => "\x70", - "\xF0\x9D\x90\x90" => "\x71", - "\xF0\x9D\x90\x91" => "\x72", - "\xF0\x9D\x90\x92" => "\x73", - "\xF0\x9D\x90\x93" => "\x74", - "\xF0\x9D\x90\x94" => "\x75", - "\xF0\x9D\x90\x95" => "\x76", - "\xF0\x9D\x90\x96" => "\x77", - "\xF0\x9D\x90\x97" => "\x78", - "\xF0\x9D\x90\x98" => "\x79", - "\xF0\x9D\x90\x99" => "\x7A", - "\xF0\x9D\x90\xB4" => "\x61", - "\xF0\x9D\x90\xB5" => "\x62", - "\xF0\x9D\x90\xB6" => "\x63", - "\xF0\x9D\x90\xB7" => "\x64", - "\xF0\x9D\x90\xB8" => "\x65", - "\xF0\x9D\x90\xB9" => "\x66", - "\xF0\x9D\x90\xBA" => "\x67", - "\xF0\x9D\x90\xBB" => "\x68", - "\xF0\x9D\x90\xBC" => "\x69", - "\xF0\x9D\x90\xBD" => "\x6A", - "\xF0\x9D\x90\xBE" => "\x6B", - "\xF0\x9D\x90\xBF" => "\x6C", - "\xF0\x9D\x91\x80" => "\x6D", - "\xF0\x9D\x91\x81" => "\x6E", - "\xF0\x9D\x91\x82" => "\x6F", - "\xF0\x9D\x91\x83" => "\x70", - "\xF0\x9D\x91\x84" => "\x71", - "\xF0\x9D\x91\x85" => "\x72", - "\xF0\x9D\x91\x86" => "\x73", - "\xF0\x9D\x91\x87" => "\x74", - "\xF0\x9D\x91\x88" => "\x75", - "\xF0\x9D\x91\x89" => "\x76", - "\xF0\x9D\x91\x8A" => "\x77", - "\xF0\x9D\x91\x8B" => "\x78", - "\xF0\x9D\x91\x8C" => "\x79", - "\xF0\x9D\x91\x8D" => "\x7A", - "\xF0\x9D\x91\xA8" => "\x61", - "\xF0\x9D\x91\xA9" => "\x62", - "\xF0\x9D\x91\xAA" => "\x63", - "\xF0\x9D\x91\xAB" => "\x64", - "\xF0\x9D\x91\xAC" => "\x65", - "\xF0\x9D\x91\xAD" => "\x66", - "\xF0\x9D\x91\xAE" => "\x67", - "\xF0\x9D\x91\xAF" => "\x68", - "\xF0\x9D\x91\xB0" => "\x69", - "\xF0\x9D\x91\xB1" => "\x6A", - "\xF0\x9D\x91\xB2" => "\x6B", - "\xF0\x9D\x91\xB3" => "\x6C", - "\xF0\x9D\x91\xB4" => "\x6D", - "\xF0\x9D\x91\xB5" => "\x6E", - "\xF0\x9D\x91\xB6" => "\x6F", - "\xF0\x9D\x91\xB7" => "\x70", - "\xF0\x9D\x91\xB8" => "\x71", - "\xF0\x9D\x91\xB9" => "\x72", - "\xF0\x9D\x91\xBA" => "\x73", - "\xF0\x9D\x91\xBB" => "\x74", - "\xF0\x9D\x91\xBC" => "\x75", - "\xF0\x9D\x91\xBD" => "\x76", - "\xF0\x9D\x91\xBE" => "\x77", - "\xF0\x9D\x91\xBF" => "\x78", - "\xF0\x9D\x92\x80" => "\x79", - "\xF0\x9D\x92\x81" => "\x7A", - "\xF0\x9D\x92\x9C" => "\x61", - "\xF0\x9D\x92\x9E" => "\x63", - "\xF0\x9D\x92\x9F" => "\x64", - "\xF0\x9D\x92\xA2" => "\x67", - "\xF0\x9D\x92\xA5" => "\x6A", - "\xF0\x9D\x92\xA6" => "\x6B", - "\xF0\x9D\x92\xA9" => "\x6E", - "\xF0\x9D\x92\xAA" => "\x6F", - "\xF0\x9D\x92\xAB" => "\x70", - "\xF0\x9D\x92\xAC" => "\x71", - "\xF0\x9D\x92\xAE" => "\x73", - "\xF0\x9D\x92\xAF" => "\x74", - "\xF0\x9D\x92\xB0" => "\x75", - "\xF0\x9D\x92\xB1" => "\x76", - "\xF0\x9D\x92\xB2" => "\x77", - "\xF0\x9D\x92\xB3" => "\x78", - "\xF0\x9D\x92\xB4" => "\x79", - "\xF0\x9D\x92\xB5" => "\x7A", - "\xF0\x9D\x93\x90" => "\x61", - "\xF0\x9D\x93\x91" => "\x62", - "\xF0\x9D\x93\x92" => "\x63", - "\xF0\x9D\x93\x93" => "\x64", - "\xF0\x9D\x93\x94" => "\x65", - "\xF0\x9D\x93\x95" => "\x66", - "\xF0\x9D\x93\x96" => "\x67", - "\xF0\x9D\x93\x97" => "\x68", - "\xF0\x9D\x93\x98" => "\x69", - "\xF0\x9D\x93\x99" => "\x6A", - "\xF0\x9D\x93\x9A" => "\x6B", - "\xF0\x9D\x93\x9B" => "\x6C", - "\xF0\x9D\x93\x9C" => "\x6D", - "\xF0\x9D\x93\x9D" => "\x6E", - "\xF0\x9D\x93\x9E" => "\x6F", - "\xF0\x9D\x93\x9F" => "\x70", - "\xF0\x9D\x93\xA0" => "\x71", - "\xF0\x9D\x93\xA1" => "\x72", - "\xF0\x9D\x93\xA2" => "\x73", - "\xF0\x9D\x93\xA3" => "\x74", - "\xF0\x9D\x93\xA4" => "\x75", - "\xF0\x9D\x93\xA5" => "\x76", - "\xF0\x9D\x93\xA6" => "\x77", - "\xF0\x9D\x93\xA7" => "\x78", - "\xF0\x9D\x93\xA8" => "\x79", - "\xF0\x9D\x93\xA9" => "\x7A", - "\xF0\x9D\x94\x84" => "\x61", - "\xF0\x9D\x94\x85" => "\x62", - "\xF0\x9D\x94\x87" => "\x64", - "\xF0\x9D\x94\x88" => "\x65", - "\xF0\x9D\x94\x89" => "\x66", - "\xF0\x9D\x94\x8A" => "\x67", - "\xF0\x9D\x94\x8D" => "\x6A", - "\xF0\x9D\x94\x8E" => "\x6B", - "\xF0\x9D\x94\x8F" => "\x6C", - "\xF0\x9D\x94\x90" => "\x6D", - "\xF0\x9D\x94\x91" => "\x6E", - "\xF0\x9D\x94\x92" => "\x6F", - "\xF0\x9D\x94\x93" => "\x70", - "\xF0\x9D\x94\x94" => "\x71", - "\xF0\x9D\x94\x96" => "\x73", - "\xF0\x9D\x94\x97" => "\x74", - "\xF0\x9D\x94\x98" => "\x75", - "\xF0\x9D\x94\x99" => "\x76", - "\xF0\x9D\x94\x9A" => "\x77", - "\xF0\x9D\x94\x9B" => "\x78", - "\xF0\x9D\x94\x9C" => "\x79", - "\xF0\x9D\x94\xB8" => "\x61", - "\xF0\x9D\x94\xB9" => "\x62", - "\xF0\x9D\x94\xBB" => "\x64", - "\xF0\x9D\x94\xBC" => "\x65", - "\xF0\x9D\x94\xBD" => "\x66", - "\xF0\x9D\x94\xBE" => "\x67", - "\xF0\x9D\x95\x80" => "\x69", - "\xF0\x9D\x95\x81" => "\x6A", - "\xF0\x9D\x95\x82" => "\x6B", - "\xF0\x9D\x95\x83" => "\x6C", - "\xF0\x9D\x95\x84" => "\x6D", - "\xF0\x9D\x95\x86" => "\x6F", - "\xF0\x9D\x95\x8A" => "\x73", - "\xF0\x9D\x95\x8B" => "\x74", - "\xF0\x9D\x95\x8C" => "\x75", - "\xF0\x9D\x95\x8D" => "\x76", - "\xF0\x9D\x95\x8E" => "\x77", - "\xF0\x9D\x95\x8F" => "\x78", - "\xF0\x9D\x95\x90" => "\x79", - "\xF0\x9D\x95\xAC" => "\x61", - "\xF0\x9D\x95\xAD" => "\x62", - "\xF0\x9D\x95\xAE" => "\x63", - "\xF0\x9D\x95\xAF" => "\x64", - "\xF0\x9D\x95\xB0" => "\x65", - "\xF0\x9D\x95\xB1" => "\x66", - "\xF0\x9D\x95\xB2" => "\x67", - "\xF0\x9D\x95\xB3" => "\x68", - "\xF0\x9D\x95\xB4" => "\x69", - "\xF0\x9D\x95\xB5" => "\x6A", - "\xF0\x9D\x95\xB6" => "\x6B", - "\xF0\x9D\x95\xB7" => "\x6C", - "\xF0\x9D\x95\xB8" => "\x6D", - "\xF0\x9D\x95\xB9" => "\x6E", - "\xF0\x9D\x95\xBA" => "\x6F", - "\xF0\x9D\x95\xBB" => "\x70", - "\xF0\x9D\x95\xBC" => "\x71", - "\xF0\x9D\x95\xBD" => "\x72", - "\xF0\x9D\x95\xBE" => "\x73", - "\xF0\x9D\x95\xBF" => "\x74", - "\xF0\x9D\x96\x80" => "\x75", - "\xF0\x9D\x96\x81" => "\x76", - "\xF0\x9D\x96\x82" => "\x77", - "\xF0\x9D\x96\x83" => "\x78", - "\xF0\x9D\x96\x84" => "\x79", - "\xF0\x9D\x96\x85" => "\x7A", - "\xF0\x9D\x96\xA0" => "\x61", - "\xF0\x9D\x96\xA1" => "\x62", - "\xF0\x9D\x96\xA2" => "\x63", - "\xF0\x9D\x96\xA3" => "\x64", - "\xF0\x9D\x96\xA4" => "\x65", - "\xF0\x9D\x96\xA5" => "\x66", - "\xF0\x9D\x96\xA6" => "\x67", - "\xF0\x9D\x96\xA7" => "\x68", - "\xF0\x9D\x96\xA8" => "\x69", - "\xF0\x9D\x96\xA9" => "\x6A", - "\xF0\x9D\x96\xAA" => "\x6B", - "\xF0\x9D\x96\xAB" => "\x6C", - "\xF0\x9D\x96\xAC" => "\x6D", - "\xF0\x9D\x96\xAD" => "\x6E", - "\xF0\x9D\x96\xAE" => "\x6F", - "\xF0\x9D\x96\xAF" => "\x70", - "\xF0\x9D\x96\xB0" => "\x71", - "\xF0\x9D\x96\xB1" => "\x72", - "\xF0\x9D\x96\xB2" => "\x73", - "\xF0\x9D\x96\xB3" => "\x74", - "\xF0\x9D\x96\xB4" => "\x75", - "\xF0\x9D\x96\xB5" => "\x76", - "\xF0\x9D\x96\xB6" => "\x77", - "\xF0\x9D\x96\xB7" => "\x78", - "\xF0\x9D\x96\xB8" => "\x79", - "\xF0\x9D\x96\xB9" => "\x7A", - "\xF0\x9D\x97\x94" => "\x61", - "\xF0\x9D\x97\x95" => "\x62", - "\xF0\x9D\x97\x96" => "\x63", - "\xF0\x9D\x97\x97" => "\x64", - "\xF0\x9D\x97\x98" => "\x65", - "\xF0\x9D\x97\x99" => "\x66", - "\xF0\x9D\x97\x9A" => "\x67", - "\xF0\x9D\x97\x9B" => "\x68", - "\xF0\x9D\x97\x9C" => "\x69", - "\xF0\x9D\x97\x9D" => "\x6A", - "\xF0\x9D\x97\x9E" => "\x6B", - "\xF0\x9D\x97\x9F" => "\x6C", - "\xF0\x9D\x97\xA0" => "\x6D", - "\xF0\x9D\x97\xA1" => "\x6E", - "\xF0\x9D\x97\xA2" => "\x6F", - "\xF0\x9D\x97\xA3" => "\x70", - "\xF0\x9D\x97\xA4" => "\x71", - "\xF0\x9D\x97\xA5" => "\x72", - "\xF0\x9D\x97\xA6" => "\x73", - "\xF0\x9D\x97\xA7" => "\x74", - "\xF0\x9D\x97\xA8" => "\x75", - "\xF0\x9D\x97\xA9" => "\x76", - "\xF0\x9D\x97\xAA" => "\x77", - "\xF0\x9D\x97\xAB" => "\x78", - "\xF0\x9D\x97\xAC" => "\x79", - "\xF0\x9D\x97\xAD" => "\x7A", - "\xF0\x9D\x98\x88" => "\x61", - "\xF0\x9D\x98\x89" => "\x62", - "\xF0\x9D\x98\x8A" => "\x63", - "\xF0\x9D\x98\x8B" => "\x64", - "\xF0\x9D\x98\x8C" => "\x65", - "\xF0\x9D\x98\x8D" => "\x66", - "\xF0\x9D\x98\x8E" => "\x67", - "\xF0\x9D\x98\x8F" => "\x68", - "\xF0\x9D\x98\x90" => "\x69", - "\xF0\x9D\x98\x91" => "\x6A", - "\xF0\x9D\x98\x92" => "\x6B", - "\xF0\x9D\x98\x93" => "\x6C", - "\xF0\x9D\x98\x94" => "\x6D", - "\xF0\x9D\x98\x95" => "\x6E", - "\xF0\x9D\x98\x96" => "\x6F", - "\xF0\x9D\x98\x97" => "\x70", - "\xF0\x9D\x98\x98" => "\x71", - "\xF0\x9D\x98\x99" => "\x72", - "\xF0\x9D\x98\x9A" => "\x73", - "\xF0\x9D\x98\x9B" => "\x74", - "\xF0\x9D\x98\x9C" => "\x75", - "\xF0\x9D\x98\x9D" => "\x76", - "\xF0\x9D\x98\x9E" => "\x77", - "\xF0\x9D\x98\x9F" => "\x78", - "\xF0\x9D\x98\xA0" => "\x79", - "\xF0\x9D\x98\xA1" => "\x7A", - "\xF0\x9D\x98\xBC" => "\x61", - "\xF0\x9D\x98\xBD" => "\x62", - "\xF0\x9D\x98\xBE" => "\x63", - "\xF0\x9D\x98\xBF" => "\x64", - "\xF0\x9D\x99\x80" => "\x65", - "\xF0\x9D\x99\x81" => "\x66", - "\xF0\x9D\x99\x82" => "\x67", - "\xF0\x9D\x99\x83" => "\x68", - "\xF0\x9D\x99\x84" => "\x69", - "\xF0\x9D\x99\x85" => "\x6A", - "\xF0\x9D\x99\x86" => "\x6B", - "\xF0\x9D\x99\x87" => "\x6C", - "\xF0\x9D\x99\x88" => "\x6D", - "\xF0\x9D\x99\x89" => "\x6E", - "\xF0\x9D\x99\x8A" => "\x6F", - "\xF0\x9D\x99\x8B" => "\x70", - "\xF0\x9D\x99\x8C" => "\x71", - "\xF0\x9D\x99\x8D" => "\x72", - "\xF0\x9D\x99\x8E" => "\x73", - "\xF0\x9D\x99\x8F" => "\x74", - "\xF0\x9D\x99\x90" => "\x75", - "\xF0\x9D\x99\x91" => "\x76", - "\xF0\x9D\x99\x92" => "\x77", - "\xF0\x9D\x99\x93" => "\x78", - "\xF0\x9D\x99\x94" => "\x79", - "\xF0\x9D\x99\x95" => "\x7A", - "\xF0\x9D\x99\xB0" => "\x61", - "\xF0\x9D\x99\xB1" => "\x62", - "\xF0\x9D\x99\xB2" => "\x63", - "\xF0\x9D\x99\xB3" => "\x64", - "\xF0\x9D\x99\xB4" => "\x65", - "\xF0\x9D\x99\xB5" => "\x66", - "\xF0\x9D\x99\xB6" => "\x67", - "\xF0\x9D\x99\xB7" => "\x68", - "\xF0\x9D\x99\xB8" => "\x69", - "\xF0\x9D\x99\xB9" => "\x6A", - "\xF0\x9D\x99\xBA" => "\x6B", - "\xF0\x9D\x99\xBB" => "\x6C", - "\xF0\x9D\x99\xBC" => "\x6D", - "\xF0\x9D\x99\xBD" => "\x6E", - "\xF0\x9D\x99\xBE" => "\x6F", - "\xF0\x9D\x99\xBF" => "\x70", - "\xF0\x9D\x9A\x80" => "\x71", - "\xF0\x9D\x9A\x81" => "\x72", - "\xF0\x9D\x9A\x82" => "\x73", - "\xF0\x9D\x9A\x83" => "\x74", - "\xF0\x9D\x9A\x84" => "\x75", - "\xF0\x9D\x9A\x85" => "\x76", - "\xF0\x9D\x9A\x86" => "\x77", - "\xF0\x9D\x9A\x87" => "\x78", - "\xF0\x9D\x9A\x88" => "\x79", - "\xF0\x9D\x9A\x89" => "\x7A", - "\xF0\x9D\x9A\xA8" => "\xCE\xB1", - "\xF0\x9D\x9A\xA9" => "\xCE\xB2", - "\xF0\x9D\x9A\xAA" => "\xCE\xB3", - "\xF0\x9D\x9A\xAB" => "\xCE\xB4", - "\xF0\x9D\x9A\xAC" => "\xCE\xB5", - "\xF0\x9D\x9A\xAD" => "\xCE\xB6", - "\xF0\x9D\x9A\xAE" => "\xCE\xB7", - "\xF0\x9D\x9A\xAF" => "\xCE\xB8", - "\xF0\x9D\x9A\xB0" => "\xCE\xB9", - "\xF0\x9D\x9A\xB1" => "\xCE\xBA", - "\xF0\x9D\x9A\xB2" => "\xCE\xBB", - "\xF0\x9D\x9A\xB3" => "\xCE\xBC", - "\xF0\x9D\x9A\xB4" => "\xCE\xBD", - "\xF0\x9D\x9A\xB5" => "\xCE\xBE", - "\xF0\x9D\x9A\xB6" => "\xCE\xBF", - "\xF0\x9D\x9A\xB7" => "\xCF\x80", - "\xF0\x9D\x9A\xB8" => "\xCF\x81", - "\xF0\x9D\x9A\xB9" => "\xCE\xB8", - "\xF0\x9D\x9A\xBA" => "\xCF\x83", - "\xF0\x9D\x9A\xBB" => "\xCF\x84", - "\xF0\x9D\x9A\xBC" => "\xCF\x85", - "\xF0\x9D\x9A\xBD" => "\xCF\x86", - "\xF0\x9D\x9A\xBE" => "\xCF\x87", - "\xF0\x9D\x9A\xBF" => "\xCF\x88", - "\xF0\x9D\x9B\x80" => "\xCF\x89", - "\xF0\x9D\x9B\x93" => "\xCF\x83", - "\xF0\x9D\x9B\xA2" => "\xCE\xB1", - "\xF0\x9D\x9B\xA3" => "\xCE\xB2", - "\xF0\x9D\x9B\xA4" => "\xCE\xB3", - "\xF0\x9D\x9B\xA5" => "\xCE\xB4", - "\xF0\x9D\x9B\xA6" => "\xCE\xB5", - "\xF0\x9D\x9B\xA7" => "\xCE\xB6", - "\xF0\x9D\x9B\xA8" => "\xCE\xB7", - "\xF0\x9D\x9B\xA9" => "\xCE\xB8", - "\xF0\x9D\x9B\xAA" => "\xCE\xB9", - "\xF0\x9D\x9B\xAB" => "\xCE\xBA", - "\xF0\x9D\x9B\xAC" => "\xCE\xBB", - "\xF0\x9D\x9B\xAD" => "\xCE\xBC", - "\xF0\x9D\x9B\xAE" => "\xCE\xBD", - "\xF0\x9D\x9B\xAF" => "\xCE\xBE", - "\xF0\x9D\x9B\xB0" => "\xCE\xBF", - "\xF0\x9D\x9B\xB1" => "\xCF\x80", - "\xF0\x9D\x9B\xB2" => "\xCF\x81", - "\xF0\x9D\x9B\xB3" => "\xCE\xB8", - "\xF0\x9D\x9B\xB4" => "\xCF\x83", - "\xF0\x9D\x9B\xB5" => "\xCF\x84", - "\xF0\x9D\x9B\xB6" => "\xCF\x85", - "\xF0\x9D\x9B\xB7" => "\xCF\x86", - "\xF0\x9D\x9B\xB8" => "\xCF\x87", - "\xF0\x9D\x9B\xB9" => "\xCF\x88", - "\xF0\x9D\x9B\xBA" => "\xCF\x89", - "\xF0\x9D\x9C\x8D" => "\xCF\x83", - "\xF0\x9D\x9C\x9C" => "\xCE\xB1", - "\xF0\x9D\x9C\x9D" => "\xCE\xB2", - "\xF0\x9D\x9C\x9E" => "\xCE\xB3", - "\xF0\x9D\x9C\x9F" => "\xCE\xB4", - "\xF0\x9D\x9C\xA0" => "\xCE\xB5", - "\xF0\x9D\x9C\xA1" => "\xCE\xB6", - "\xF0\x9D\x9C\xA2" => "\xCE\xB7", - "\xF0\x9D\x9C\xA3" => "\xCE\xB8", - "\xF0\x9D\x9C\xA4" => "\xCE\xB9", - "\xF0\x9D\x9C\xA5" => "\xCE\xBA", - "\xF0\x9D\x9C\xA6" => "\xCE\xBB", - "\xF0\x9D\x9C\xA7" => "\xCE\xBC", - "\xF0\x9D\x9C\xA8" => "\xCE\xBD", - "\xF0\x9D\x9C\xA9" => "\xCE\xBE", - "\xF0\x9D\x9C\xAA" => "\xCE\xBF", - "\xF0\x9D\x9C\xAB" => "\xCF\x80", - "\xF0\x9D\x9C\xAC" => "\xCF\x81", - "\xF0\x9D\x9C\xAD" => "\xCE\xB8", - "\xF0\x9D\x9C\xAE" => "\xCF\x83", - "\xF0\x9D\x9C\xAF" => "\xCF\x84", - "\xF0\x9D\x9C\xB0" => "\xCF\x85", - "\xF0\x9D\x9C\xB1" => "\xCF\x86", - "\xF0\x9D\x9C\xB2" => "\xCF\x87", - "\xF0\x9D\x9C\xB3" => "\xCF\x88", - "\xF0\x9D\x9C\xB4" => "\xCF\x89", - "\xF0\x9D\x9D\x87" => "\xCF\x83", - "\xF0\x9D\x9D\x96" => "\xCE\xB1", - "\xF0\x9D\x9D\x97" => "\xCE\xB2", - "\xF0\x9D\x9D\x98" => "\xCE\xB3", - "\xF0\x9D\x9D\x99" => "\xCE\xB4", - "\xF0\x9D\x9D\x9A" => "\xCE\xB5", - "\xF0\x9D\x9D\x9B" => "\xCE\xB6", - "\xF0\x9D\x9D\x9C" => "\xCE\xB7", - "\xF0\x9D\x9D\x9D" => "\xCE\xB8", - "\xF0\x9D\x9D\x9E" => "\xCE\xB9", - "\xF0\x9D\x9D\x9F" => "\xCE\xBA", - "\xF0\x9D\x9D\xA0" => "\xCE\xBB", - "\xF0\x9D\x9D\xA1" => "\xCE\xBC", - "\xF0\x9D\x9D\xA2" => "\xCE\xBD", - "\xF0\x9D\x9D\xA3" => "\xCE\xBE", - "\xF0\x9D\x9D\xA4" => "\xCE\xBF", - "\xF0\x9D\x9D\xA5" => "\xCF\x80", - "\xF0\x9D\x9D\xA6" => "\xCF\x81", - "\xF0\x9D\x9D\xA7" => "\xCE\xB8", - "\xF0\x9D\x9D\xA8" => "\xCF\x83", - "\xF0\x9D\x9D\xA9" => "\xCF\x84", - "\xF0\x9D\x9D\xAA" => "\xCF\x85", - "\xF0\x9D\x9D\xAB" => "\xCF\x86", - "\xF0\x9D\x9D\xAC" => "\xCF\x87", - "\xF0\x9D\x9D\xAD" => "\xCF\x88", - "\xF0\x9D\x9D\xAE" => "\xCF\x89", - "\xF0\x9D\x9E\x81" => "\xCF\x83", - "\xF0\x9D\x9E\x90" => "\xCE\xB1", - "\xF0\x9D\x9E\x91" => "\xCE\xB2", - "\xF0\x9D\x9E\x92" => "\xCE\xB3", - "\xF0\x9D\x9E\x93" => "\xCE\xB4", - "\xF0\x9D\x9E\x94" => "\xCE\xB5", - "\xF0\x9D\x9E\x95" => "\xCE\xB6", - "\xF0\x9D\x9E\x96" => "\xCE\xB7", - "\xF0\x9D\x9E\x97" => "\xCE\xB8", - "\xF0\x9D\x9E\x98" => "\xCE\xB9", - "\xF0\x9D\x9E\x99" => "\xCE\xBA", - "\xF0\x9D\x9E\x9A" => "\xCE\xBB", - "\xF0\x9D\x9E\x9B" => "\xCE\xBC", - "\xF0\x9D\x9E\x9C" => "\xCE\xBD", - "\xF0\x9D\x9E\x9D" => "\xCE\xBE", - "\xF0\x9D\x9E\x9E" => "\xCE\xBF", - "\xF0\x9D\x9E\x9F" => "\xCF\x80", - "\xF0\x9D\x9E\xA0" => "\xCF\x81", - "\xF0\x9D\x9E\xA1" => "\xCE\xB8", - "\xF0\x9D\x9E\xA2" => "\xCF\x83", - "\xF0\x9D\x9E\xA3" => "\xCF\x84", - "\xF0\x9D\x9E\xA4" => "\xCF\x85", - "\xF0\x9D\x9E\xA5" => "\xCF\x86", - "\xF0\x9D\x9E\xA6" => "\xCF\x87", - "\xF0\x9D\x9E\xA7" => "\xCF\x88", - "\xF0\x9D\x9E\xA8" => "\xCF\x89", - "\xF0\x9D\x9E\xBB" => "\xCF\x83", - "\xF0\x9D\x9F\x8A" => "\xCF\x9D", - ); - - // do the case fold - $text = utf8_case_fold($text, $option); - - // convert to NFKC - Normalizer::normalize($text, Normalizer::NFKC); - - // FC_NFKC_Closure, http://www.unicode.org/Public/5.0.0/ucd/DerivedNormalizationProps.txt - $text = strtr($text, $fc_nfkc_closure); - - return $text; -} - -/** -* Assume the input is NFC: -* Takes the input and does a "special" case fold. It does minor normalization as well. -* -* @param string $text text to be case folded -* @param string $option determines how we will fold the cases -* @return string case folded text -*/ -function utf8_case_fold_nfc($text, $option = 'full') -{ - static $uniarray = array(); - static $ypogegrammeni = array( - "\xCD\xBA" => "\x20\xCD\x85", - "\xE1\xBE\x80" => "\xE1\xBC\x80\xCD\x85", - "\xE1\xBE\x81" => "\xE1\xBC\x81\xCD\x85", - "\xE1\xBE\x82" => "\xE1\xBC\x82\xCD\x85", - "\xE1\xBE\x83" => "\xE1\xBC\x83\xCD\x85", - "\xE1\xBE\x84" => "\xE1\xBC\x84\xCD\x85", - "\xE1\xBE\x85" => "\xE1\xBC\x85\xCD\x85", - "\xE1\xBE\x86" => "\xE1\xBC\x86\xCD\x85", - "\xE1\xBE\x87" => "\xE1\xBC\x87\xCD\x85", - "\xE1\xBE\x88" => "\xE1\xBC\x88\xCD\x85", - "\xE1\xBE\x89" => "\xE1\xBC\x89\xCD\x85", - "\xE1\xBE\x8A" => "\xE1\xBC\x8A\xCD\x85", - "\xE1\xBE\x8B" => "\xE1\xBC\x8B\xCD\x85", - "\xE1\xBE\x8C" => "\xE1\xBC\x8C\xCD\x85", - "\xE1\xBE\x8D" => "\xE1\xBC\x8D\xCD\x85", - "\xE1\xBE\x8E" => "\xE1\xBC\x8E\xCD\x85", - "\xE1\xBE\x8F" => "\xE1\xBC\x8F\xCD\x85", - "\xE1\xBE\x90" => "\xE1\xBC\xA0\xCD\x85", - "\xE1\xBE\x91" => "\xE1\xBC\xA1\xCD\x85", - "\xE1\xBE\x92" => "\xE1\xBC\xA2\xCD\x85", - "\xE1\xBE\x93" => "\xE1\xBC\xA3\xCD\x85", - "\xE1\xBE\x94" => "\xE1\xBC\xA4\xCD\x85", - "\xE1\xBE\x95" => "\xE1\xBC\xA5\xCD\x85", - "\xE1\xBE\x96" => "\xE1\xBC\xA6\xCD\x85", - "\xE1\xBE\x97" => "\xE1\xBC\xA7\xCD\x85", - "\xE1\xBE\x98" => "\xE1\xBC\xA8\xCD\x85", - "\xE1\xBE\x99" => "\xE1\xBC\xA9\xCD\x85", - "\xE1\xBE\x9A" => "\xE1\xBC\xAA\xCD\x85", - "\xE1\xBE\x9B" => "\xE1\xBC\xAB\xCD\x85", - "\xE1\xBE\x9C" => "\xE1\xBC\xAC\xCD\x85", - "\xE1\xBE\x9D" => "\xE1\xBC\xAD\xCD\x85", - "\xE1\xBE\x9E" => "\xE1\xBC\xAE\xCD\x85", - "\xE1\xBE\x9F" => "\xE1\xBC\xAF\xCD\x85", - "\xE1\xBE\xA0" => "\xE1\xBD\xA0\xCD\x85", - "\xE1\xBE\xA1" => "\xE1\xBD\xA1\xCD\x85", - "\xE1\xBE\xA2" => "\xE1\xBD\xA2\xCD\x85", - "\xE1\xBE\xA3" => "\xE1\xBD\xA3\xCD\x85", - "\xE1\xBE\xA4" => "\xE1\xBD\xA4\xCD\x85", - "\xE1\xBE\xA5" => "\xE1\xBD\xA5\xCD\x85", - "\xE1\xBE\xA6" => "\xE1\xBD\xA6\xCD\x85", - "\xE1\xBE\xA7" => "\xE1\xBD\xA7\xCD\x85", - "\xE1\xBE\xA8" => "\xE1\xBD\xA8\xCD\x85", - "\xE1\xBE\xA9" => "\xE1\xBD\xA9\xCD\x85", - "\xE1\xBE\xAA" => "\xE1\xBD\xAA\xCD\x85", - "\xE1\xBE\xAB" => "\xE1\xBD\xAB\xCD\x85", - "\xE1\xBE\xAC" => "\xE1\xBD\xAC\xCD\x85", - "\xE1\xBE\xAD" => "\xE1\xBD\xAD\xCD\x85", - "\xE1\xBE\xAE" => "\xE1\xBD\xAE\xCD\x85", - "\xE1\xBE\xAF" => "\xE1\xBD\xAF\xCD\x85", - "\xE1\xBE\xB2" => "\xE1\xBD\xB0\xCD\x85", - "\xE1\xBE\xB3" => "\xCE\xB1\xCD\x85", - "\xE1\xBE\xB4" => "\xCE\xAC\xCD\x85", - "\xE1\xBE\xB7" => "\xE1\xBE\xB6\xCD\x85", - "\xE1\xBE\xBC" => "\xCE\x91\xCD\x85", - "\xE1\xBF\x82" => "\xE1\xBD\xB4\xCD\x85", - "\xE1\xBF\x83" => "\xCE\xB7\xCD\x85", - "\xE1\xBF\x84" => "\xCE\xAE\xCD\x85", - "\xE1\xBF\x87" => "\xE1\xBF\x86\xCD\x85", - "\xE1\xBF\x8C" => "\xCE\x97\xCD\x85", - "\xE1\xBF\xB2" => "\xE1\xBD\xBC\xCD\x85", - "\xE1\xBF\xB3" => "\xCF\x89\xCD\x85", - "\xE1\xBF\xB4" => "\xCF\x8E\xCD\x85", - "\xE1\xBF\xB7" => "\xE1\xBF\xB6\xCD\x85", - "\xE1\xBF\xBC" => "\xCE\xA9\xCD\x85", - ); - - // perform a small trick, avoid further normalization on composed points that contain U+0345 in their decomposition - $text = strtr($text, $ypogegrammeni); - - // do the case fold - $text = utf8_case_fold($text, $option); - - return $text; -} - -/** -* wrapper around PHP's native normalizer from intl -* previously a PECL extension, included in the core since PHP 5.3.0 -* http://php.net/manual/en/normalizer.normalize.php -* -* @param mixed $strings a string or an array of strings to normalize -* @return mixed the normalized content, preserving array keys if array given. -*/ -function utf8_normalize_nfc($strings) -{ - if (empty($strings)) - { - return $strings; - } - - if (!is_array($strings)) - { - if (Normalizer::isNormalized($strings)) - { - return $strings; - } - return (string) Normalizer::normalize($strings); - } - else - { - foreach ($strings as $key => $string) - { - if (is_array($string)) - { - foreach ($string as $_key => $_string) - { - if (Normalizer::isNormalized($strings[$key][$_key])) - { - continue; - } - $strings[$key][$_key] = (string) Normalizer::normalize($strings[$key][$_key]); - } - } - else - { - if (Normalizer::isNormalized($strings[$key])) - { - continue; - } - $strings[$key] = (string) Normalizer::normalize($strings[$key]); - } - } - } - - return $strings; -} - -/** -* This function is used to generate a "clean" version of a string. -* Clean means that it is a case insensitive form (case folding) and that it is normalized (NFC). -* Additionally a homographs of one character are transformed into one specific character (preferably ASCII -* if it is an ASCII character). -* -* Please be aware that if you change something within this function or within -* functions used here you need to rebuild/update the username_clean column in the users table. And all other -* columns that store a clean string otherwise you will break this functionality. -* -* @param string $text An unclean string, mabye user input (has to be valid UTF-8!) -* @return string Cleaned up version of the input string -*/ -function utf8_clean_string($text) -{ - global $phpbb_root_path, $phpEx; - - static $homographs = array(); - if (empty($homographs)) - { - $homographs = include($phpbb_root_path . 'includes/utf/data/confusables.' . $phpEx); - } - - $text = utf8_case_fold_nfkc($text); - $text = strtr($text, $homographs); - // Other control characters - $text = preg_replace('#(?:[\x00-\x1F\x7F]+|(?:\xC2[\x80-\x9F])+)#', '', $text); - - // we need to reduce multiple spaces to a single one - $text = preg_replace('# {2,}#', ' ', $text); - - // we can use trim here as all the other space characters should have been turned - // into normal ASCII spaces by now - return trim($text); -} - -/** -* A wrapper for htmlspecialchars($value, ENT_COMPAT, 'UTF-8') -*/ -function utf8_htmlspecialchars($value) -{ - return htmlspecialchars($value, ENT_COMPAT, 'UTF-8'); -} - -/** -* Trying to convert returned system message to utf8 -* -* PHP assumes such messages are ISO-8859-1 so we'll do that too -* and if it breaks messages we'll blame it on them ;-) -*/ -function utf8_convert_message($message) -{ - // First of all check if conversion is neded at all, as there is no point - // in converting ASCII messages from ISO-8859-1 to UTF-8 - if (!preg_match('/[\x80-\xFF]/', $message)) - { - return utf8_htmlspecialchars($message); - } - - // else we need to convert some part of the message - return utf8_htmlspecialchars(utf8_recode($message, 'ISO-8859-1')); -} - -/** -* UTF8-compatible wordwrap replacement -* -* @param string $string The input string -* @param int $width The column width. Defaults to 75. -* @param string $break The line is broken using the optional break parameter. Defaults to '\n'. -* @param bool $cut If the cut is set to TRUE, the string is always wrapped at the specified width. So if you have a word that is larger than the given width, it is broken apart. -* -* @return string the given string wrapped at the specified column. -* -*/ -function utf8_wordwrap($string, $width = 75, $break = "\n", $cut = false) -{ - // We first need to explode on $break, not destroying existing (intended) breaks - $lines = explode($break, $string); - $new_lines = array(0 => ''); - $index = 0; - - foreach ($lines as $line) - { - $words = explode(' ', $line); - - for ($i = 0, $size = count($words); $i < $size; $i++) - { - $word = $words[$i]; - - // If cut is true we need to cut the word if it is > width chars - if ($cut && utf8_strlen($word) > $width) - { - $words[$i] = utf8_substr($word, $width); - $word = utf8_substr($word, 0, $width); - $i--; - } - - if (utf8_strlen($new_lines[$index] . $word) > $width) - { - $new_lines[$index] = substr($new_lines[$index], 0, -1); - $index++; - $new_lines[$index] = ''; - } - - $new_lines[$index] .= $word . ' '; - } - - $new_lines[$index] = substr($new_lines[$index], 0, -1); - $index++; - $new_lines[$index] = ''; - } - - unset($new_lines[$index]); - return implode($break, $new_lines); -} - -/** -* UTF8-safe basename() function -* -* basename() has some limitations and is dependent on the locale setting -* according to the PHP manual. Therefore we provide our own locale independent -* basename function. -* -* @param string $filename The filename basename() should be applied to -* @return string The basenamed filename -*/ -function utf8_basename($filename) -{ - // We always check for forward slash AND backward slash - // because they could be mixed or "sneaked" in. ;) - // You know, never trust user input... - if (strpos($filename, '/') !== false) - { - $filename = utf8_substr($filename, utf8_strrpos($filename, '/') + 1); - } - - if (strpos($filename, '\\') !== false) - { - $filename = utf8_substr($filename, utf8_strrpos($filename, '\\') + 1); - } - - return $filename; -} diff --git a/install/update/new/index.php b/install/update/new/index.php deleted file mode 100644 index 5622bc3..0000000 --- a/install/update/new/index.php +++ /dev/null @@ -1,252 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -*/ - -/** -* @ignore -*/ -define('IN_PHPBB', true); -$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); -include($phpbb_root_path . 'common.' . $phpEx); -include($phpbb_root_path . 'includes/functions_display.' . $phpEx); - -// Start session management -$user->session_begin(); -$auth->acl($user->data); -$user->setup('viewforum'); - -// Mark notifications read -if (($mark_notification = $request->variable('mark_notification', 0))) -{ - if ($user->data['user_id'] == ANONYMOUS) - { - if ($request->is_ajax()) - { - trigger_error('LOGIN_REQUIRED'); - } - login_box('', $user->lang['LOGIN_REQUIRED']); - } - - if (check_link_hash($request->variable('hash', ''), 'mark_notification_read')) - { - /* @var $phpbb_notifications \phpbb\notification\manager */ - $phpbb_notifications = $phpbb_container->get('notification_manager'); - - $notification = $phpbb_notifications->load_notifications('notification.method.board', array( - 'notification_id' => $mark_notification, - )); - - if (isset($notification['notifications'][$mark_notification])) - { - $notification = $notification['notifications'][$mark_notification]; - - $notification->mark_read(); - - /** - * You can use this event to perform additional tasks or redirect user elsewhere. - * - * @event core.index_mark_notification_after - * @var int mark_notification Notification ID - * @var \phpbb\notification\type\type_interface notification Notification instance - * @since 3.2.6-RC1 - */ - $vars = array('mark_notification', 'notification'); - extract($phpbb_dispatcher->trigger_event('core.index_mark_notification_after', compact($vars))); - - if ($request->is_ajax()) - { - $json_response = new \phpbb\json_response(); - $json_response->send(array( - 'success' => true, - )); - } - - if (($redirect = $request->variable('redirect', ''))) - { - redirect(append_sid($phpbb_root_path . $redirect)); - } - - redirect($notification->get_redirect_url()); - } - } -} - -display_forums('', $config['load_moderators']); - -$order_legend = ($config['legend_sort_groupname']) ? 'group_name' : 'group_legend'; -// Grab group details for legend display -if ($auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) -{ - $sql = 'SELECT group_id, group_name, group_colour, group_type, group_legend - FROM ' . GROUPS_TABLE . ' - WHERE group_legend > 0 - ORDER BY ' . $order_legend . ' ASC'; -} -else -{ - $sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type, g.group_legend - FROM ' . GROUPS_TABLE . ' g - LEFT JOIN ' . USER_GROUP_TABLE . ' ug - ON ( - g.group_id = ug.group_id - AND ug.user_id = ' . $user->data['user_id'] . ' - AND ug.user_pending = 0 - ) - WHERE g.group_legend > 0 - AND (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $user->data['user_id'] . ') - ORDER BY g.' . $order_legend . ' ASC'; -} -$result = $db->sql_query($sql); - -/** @var \phpbb\group\helper $group_helper */ -$group_helper = $phpbb_container->get('group_helper'); - -$legend = array(); -while ($row = $db->sql_fetchrow($result)) -{ - $colour_text = ($row['group_colour']) ? ' style="color:#' . $row['group_colour'] . '"' : ''; - $group_name = $group_helper->get_name($row['group_name']); - - if ($row['group_name'] == 'BOTS' || ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile'))) - { - $legend[] = '' . $group_name . '
'; - } - else - { - $legend[] = '' . $group_name . ''; - } -} -$db->sql_freeresult($result); - -$legend = implode($user->lang['COMMA_SEPARATOR'], $legend); - -// Generate birthday list if required ... -$show_birthdays = ($config['load_birthdays'] && $config['allow_birthdays'] && $auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel')); - -$birthdays = $birthday_list = array(); -if ($show_birthdays) -{ - $time = $user->create_datetime(); - $now = phpbb_gmgetdate($time->getTimestamp() + $time->getOffset()); - - // Display birthdays of 29th february on 28th february in non-leap-years - $leap_year_birthdays = ''; - if ($now['mday'] == 28 && $now['mon'] == 2 && !$time->format('L')) - { - $leap_year_birthdays = " OR u.user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', 29, 2)) . "%'"; - } - - $sql_ary = array( - 'SELECT' => 'u.user_id, u.username, u.user_colour, u.user_birthday', - 'FROM' => array( - USERS_TABLE => 'u', - ), - 'LEFT_JOIN' => array( - array( - 'FROM' => array(BANLIST_TABLE => 'b'), - 'ON' => 'u.user_id = b.ban_userid', - ), - ), - 'WHERE' => "(b.ban_id IS NULL OR b.ban_exclude = 1) - AND (u.user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', $now['mday'], $now['mon'])) . "%' $leap_year_birthdays) - AND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')', - ); - - /** - * Event to modify the SQL query to get birthdays data - * - * @event core.index_modify_birthdays_sql - * @var array now The assoc array with the 'now' local timestamp data - * @var array sql_ary The SQL array to get the birthdays data - * @var object time The user related Datetime object - * @since 3.1.7-RC1 - */ - $vars = array('now', 'sql_ary', 'time'); - extract($phpbb_dispatcher->trigger_event('core.index_modify_birthdays_sql', compact($vars))); - - $sql = $db->sql_build_query('SELECT', $sql_ary); - $result = $db->sql_query($sql); - $rows = $db->sql_fetchrowset($result); - $db->sql_freeresult($result); - - foreach ($rows as $row) - { - $birthday_username = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']); - $birthday_year = (int) substr($row['user_birthday'], -4); - $birthday_age = ($birthday_year) ? max(0, $now['year'] - $birthday_year) : ''; - - $birthdays[] = array( - 'USERNAME' => $birthday_username, - 'AGE' => $birthday_age, - ); - - // For 3.0 compatibility - $birthday_list[] = $birthday_username . (($birthday_age) ? " ({$birthday_age})" : ''); - } - - /** - * Event to modify the birthdays list - * - * @event core.index_modify_birthdays_list - * @var array birthdays Array with the users birthdays data - * @var array rows Array with the birthdays SQL query result - * @since 3.1.7-RC1 - */ - $vars = array('birthdays', 'rows'); - extract($phpbb_dispatcher->trigger_event('core.index_modify_birthdays_list', compact($vars))); - - $template->assign_block_vars_array('birthdays', $birthdays); -} - -// Assign index specific vars -$template->assign_vars(array( - 'TOTAL_POSTS' => $user->lang('TOTAL_POSTS_COUNT', (int) $config['num_posts']), - 'TOTAL_TOPICS' => $user->lang('TOTAL_TOPICS', (int) $config['num_topics']), - 'TOTAL_USERS' => $user->lang('TOTAL_USERS', (int) $config['num_users']), - 'NEWEST_USER' => $user->lang('NEWEST_USER', get_username_string('full', $config['newest_user_id'], $config['newest_username'], $config['newest_user_colour'])), - - 'LEGEND' => $legend, - 'BIRTHDAY_LIST' => (empty($birthday_list)) ? '' : implode($user->lang['COMMA_SEPARATOR'], $birthday_list), - - 'S_LOGIN_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'), - 'U_SEND_PASSWORD' => ($config['email_enable']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=sendpassword') : '', - 'S_DISPLAY_BIRTHDAY_LIST' => $show_birthdays, - 'S_INDEX' => true, - - 'U_MARK_FORUMS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}index.$phpEx", 'hash=' . generate_link_hash('global') . '&mark=forums&mark_time=' . time()) : '', - 'U_MCP' => ($auth->acl_get('m_') || $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=front', true, $user->session_id) : '') -); - -$page_title = ($config['board_index_text'] !== '') ? $config['board_index_text'] : $user->lang['INDEX']; - -/** -* You can use this event to modify the page title and load data for the index -* -* @event core.index_modify_page_title -* @var string page_title Title of the index page -* @since 3.1.0-a1 -*/ -$vars = array('page_title'); -extract($phpbb_dispatcher->trigger_event('core.index_modify_page_title', compact($vars))); - -// Output page -page_header($page_title, true); - -$template->set_filenames(array( - 'body' => 'index_body.html') -); - -page_footer(); diff --git a/install/update/new/language/en/acp/attachments.php b/install/update/new/language/en/acp/attachments.php deleted file mode 100644 index 67454f8..0000000 --- a/install/update/new/language/en/acp/attachments.php +++ /dev/null @@ -1,167 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* DO NOT CHANGE -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -if (empty($lang) || !is_array($lang)) -{ - $lang = array(); -} - -// DEVELOPERS PLEASE NOTE -// -// All language files should use UTF-8 as their encoding and the files must not contain a BOM. -// -// Placeholders can now contain order information, e.g. instead of -// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows -// translators to re-order the output of data while ensuring it remains correct -// -// You do not need this where single placeholders are used, e.g. 'Message %d' is fine -// equally where a string contains only two placeholders which are used to wrap text -// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine - -$lang = array_merge($lang, array( - 'ACP_ATTACHMENT_SETTINGS_EXPLAIN' => 'Here you can configure the main settings for attachments and the associated special categories.', - 'ACP_EXTENSION_GROUPS_EXPLAIN' => 'Here you can add, delete, modify or disable your extension groups. Further options include the assignment of a special category to them, changing the download mechanism and defining an upload icon which will be displayed in front of the attachment which belongs to the group.', - 'ACP_MANAGE_EXTENSIONS_EXPLAIN' => 'Here you can manage your allowed extensions. To activate your extensions, please refer to the extension groups management panel. We strongly recommend not to allow scripting extensions (such as php, php3, php4, phtml, pl, cgi, py, rb, asp, aspx, and so forth…).', - 'ACP_ORPHAN_ATTACHMENTS_EXPLAIN' => 'Here you are able to see orphaned files. This happens mostly if users are attaching files but not submitting the post. You are able to delete the files or attach them to existing posts. Attaching to posts requires a valid post ID, you have to determine this ID by yourself. This will assign the already uploaded attachment to the post you entered.', - 'ADD_EXTENSION' => 'Add extension', - 'ADD_EXTENSION_GROUP' => 'Add extension group', - 'ADMIN_UPLOAD_ERROR' => 'Errors while trying to attach file: “%s”.', - 'ALLOWED_FORUMS' => 'Allowed forums', - 'ALLOWED_FORUMS_EXPLAIN' => 'Able to post the assigned extensions at the selected (or all if selected) forums.', - 'ALLOWED_IN_PM_POST' => 'Allowed', - 'ALLOW_ATTACHMENTS' => 'Allow attachments', - 'ALLOW_ALL_FORUMS' => 'Allow all forums', - 'ALLOW_IN_PM' => 'Allowed in private messaging', - 'ALLOW_PM_ATTACHMENTS' => 'Allow attachments in private messages', - 'ALLOW_SELECTED_FORUMS' => 'Only forums selected below', - 'ASSIGNED_EXTENSIONS' => 'Assigned extensions', - 'ASSIGNED_GROUP' => 'Assigned extension group', - 'ATTACH_EXTENSIONS_URL' => 'Extensions', - 'ATTACH_EXT_GROUPS_URL' => 'Extension groups', - 'ATTACH_ID' => 'ID', - 'ATTACH_MAX_FILESIZE' => 'Maximum file size', - 'ATTACH_MAX_FILESIZE_EXPLAIN' => 'Maximum size of each file. If this value is 0, the uploadable filesize is only limited by your PHP configuration.', - 'ATTACH_MAX_PM_FILESIZE' => 'Maximum file size messaging', - 'ATTACH_MAX_PM_FILESIZE_EXPLAIN' => 'Maximum size of each file, with 0 being unlimited, attached to a private message.', - 'ATTACH_ORPHAN_URL' => 'Orphan attachments', - 'ATTACH_POST_ID' => 'Post ID', - 'ATTACH_POST_TYPE' => 'Post type', - 'ATTACH_QUOTA' => 'Total attachment quota', - 'ATTACH_QUOTA_EXPLAIN' => 'Maximum drive space available for attachments for the whole board, with 0 being unlimited.', - 'ATTACH_TO_POST' => 'Attach file to post', - - 'CAT_IMAGES' => 'Images', - 'CHECK_CONTENT' => 'Check attachment files', - 'CHECK_CONTENT_EXPLAIN' => 'Some browsers can be tricked to assume an incorrect mimetype for uploaded files. This option ensures that such files likely to cause this are rejected.', - 'CREATE_GROUP' => 'Create new group', - 'CREATE_THUMBNAIL' => 'Create thumbnail', - 'CREATE_THUMBNAIL_EXPLAIN' => 'Create a thumbnail in all possible situations.', - - 'DEFINE_ALLOWED_IPS' => 'Define allowed IPs/hostnames', - 'DEFINE_DISALLOWED_IPS' => 'Define disallowed IPs/hostnames', - 'DOWNLOAD_ADD_IPS_EXPLAIN' => 'To specify several different IPs or hostnames enter each on a new line. To specify a range of IP addresses separate the start and end with a hyphen (-), to specify a wildcard use “*”.', - 'DOWNLOAD_REMOVE_IPS_EXPLAIN' => 'You can remove (or un-exclude) multiple IP addresses in one go using the appropriate combination of mouse and keyboard for your computer and browser. Excluded IPs have a blue background.', - 'DISPLAY_INLINED' => 'Display images inline', - 'DISPLAY_INLINED_EXPLAIN' => 'If set to No image attachments will show as a link.', - 'DISPLAY_ORDER' => 'Attachment display order', - 'DISPLAY_ORDER_EXPLAIN' => 'Display attachments ordered by time.', - - 'EDIT_EXTENSION_GROUP' => 'Edit extension group', - 'EXCLUDE_ENTERED_IP' => 'Enable this to exclude the entered IP/hostname.', - 'EXCLUDE_FROM_ALLOWED_IP' => 'Exclude IP from allowed IPs/hostnames', - 'EXCLUDE_FROM_DISALLOWED_IP' => 'Exclude IP from disallowed IPs/hostnames', - 'EXTENSIONS_UPDATED' => 'Extensions successfully updated.', - 'EXTENSION_EXIST' => 'The extension %s already exists.', - 'EXTENSION_GROUP' => 'Extension group', - 'EXTENSION_GROUPS' => 'Extension groups', - 'EXTENSION_GROUP_DELETED' => 'Extension group successfully deleted.', - 'EXTENSION_GROUP_EXIST' => 'The extension group %s already exists.', - - 'EXT_GROUP_ARCHIVES' => 'Archives', - 'EXT_GROUP_DOCUMENTS' => 'Documents', - 'EXT_GROUP_DOWNLOADABLE_FILES' => 'Downloadable Files', - 'EXT_GROUP_IMAGES' => 'Images', - 'EXT_GROUP_PLAIN_TEXT' => 'Plain Text', - - 'FILES_GONE' => 'Some of the attachments you selected for deletion do not exist. They may have been already deleted. Attachments that did exist were deleted.', - 'FILES_STATS_WRONG' => 'Your file statistics are likely inaccurate and need to be resynchronised. Actual values: number of attachments = %1$d, total size of attachments = %2$s.
Click %3$shere%4$s to resynchronise them.', - - 'GO_TO_EXTENSIONS' => 'Go to extension management screen', - 'GROUP_NAME' => 'Group name', - - 'IMAGE_LINK_SIZE' => 'Image link dimensions', - 'IMAGE_LINK_SIZE_EXPLAIN' => 'Display image attachment as an inline text link if image is larger than this. To disable this behaviour, set the values to 0px by 0px.', - - 'MAX_ATTACHMENTS' => 'Maximum number of attachments per post', - 'MAX_ATTACHMENTS_PM' => 'Maximum number of attachments per private message', - 'MAX_EXTGROUP_FILESIZE' => 'Maximum file size', - 'MAX_IMAGE_SIZE' => 'Maximum image dimensions', - 'MAX_IMAGE_SIZE_EXPLAIN' => 'Maximum size of image attachments. Set both values to 0px by 0px to disable dimension checking.', - 'MAX_THUMB_WIDTH' => 'Maximum thumbnail width/height in pixel', - 'MAX_THUMB_WIDTH_EXPLAIN' => 'A generated thumbnail will not exceed the width set here.', - 'MIN_THUMB_FILESIZE' => 'Minimum thumbnail file size', - 'MIN_THUMB_FILESIZE_EXPLAIN' => 'Do not create a thumbnail for images smaller than this.', - 'MODE_INLINE' => 'Inline', - 'MODE_PHYSICAL' => 'Physical', - - 'NOT_ALLOWED_IN_PM' => 'Only allowed in posts', - 'NOT_ALLOWED_IN_PM_POST' => 'Not allowed', - 'NOT_ASSIGNED' => 'Not assigned', - 'NO_ATTACHMENTS' => 'No attachments found for this period.', - 'NO_EXT_GROUP' => 'None', - 'NO_EXT_GROUP_NAME' => 'No group name entered', - 'NO_EXT_GROUP_SPECIFIED' => 'No extension group specified.', - 'NO_FILE_CAT' => 'None', - 'NO_IMAGE' => 'No image', - 'NO_UPLOAD_DIR' => 'The upload directory you specified does not exist.', - 'NO_WRITE_UPLOAD' => 'The upload directory you specified cannot be written to. Please alter the permissions to allow the webserver to write to it.', - - 'ONLY_ALLOWED_IN_PM' => 'Only allowed in private messages', - 'ORDER_ALLOW_DENY' => 'Allow', - 'ORDER_DENY_ALLOW' => 'Deny', - - 'REMOVE_ALLOWED_IPS' => 'Remove or un-exclude allowed IPs/hostnames', - 'REMOVE_DISALLOWED_IPS' => 'Remove or un-exclude disallowed IPs/hostnames', - 'RESYNC_FILES_STATS_CONFIRM' => 'Are you sure you wish to resynchronise file statistics?', - - 'SECURE_ALLOW_DENY' => 'Allow/Deny list', - 'SECURE_ALLOW_DENY_EXPLAIN' => 'Change the default behaviour when secure downloads are enabled of the Allow/Deny list to that of a whitelist (Allow) or a blacklist (Deny).', - 'SECURE_DOWNLOADS' => 'Enable secure downloads', - 'SECURE_DOWNLOADS_EXPLAIN' => 'With this option enabled, downloads are limited to IP’s/hostnames you define.', - 'SECURE_DOWNLOAD_NOTICE' => 'Secure Downloads are not enabled. The settings below will be applied after enabling secure downloads.', - 'SECURE_DOWNLOAD_UPDATE_SUCCESS'=> 'The IP list has been updated successfully.', - 'SECURE_EMPTY_REFERRER' => 'Allow empty referrer', - 'SECURE_EMPTY_REFERRER_EXPLAIN' => 'Secure downloads are based on referrers. Do you want to allow downloads for those omitting the referrer?', - 'SETTINGS_CAT_IMAGES' => 'Image category settings', - 'SPECIAL_CATEGORY' => 'Special category', - 'SPECIAL_CATEGORY_EXPLAIN' => 'Special categories differ between the way presented within posts.', - 'SUCCESSFULLY_UPLOADED' => 'Successfully uploaded.', - 'SUCCESS_EXTENSION_GROUP_ADD' => 'Extension group successfully added.', - 'SUCCESS_EXTENSION_GROUP_EDIT' => 'Extension group successfully updated.', - - 'UPLOADING_FILES' => 'Uploading files', - 'UPLOADING_FILE_TO' => 'Uploading file “%1$s” to post number %2$d…', - 'UPLOAD_DENIED_FORUM' => 'You do not have the permission to upload files to forum “%s”.', - 'UPLOAD_DIR' => 'Upload directory', - 'UPLOAD_DIR_EXPLAIN' => 'Storage path for attachments. Please note that if you change this directory while already having uploaded attachments you need to manually copy the files to their new location.', - 'UPLOAD_ICON' => 'Upload icon', - 'UPLOAD_NOT_DIR' => 'The upload location you specified does not appear to be a directory.', -)); diff --git a/install/update/new/language/en/acp/board.php b/install/update/new/language/en/acp/board.php deleted file mode 100644 index a01a4f1..0000000 --- a/install/update/new/language/en/acp/board.php +++ /dev/null @@ -1,635 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* DO NOT CHANGE -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -if (empty($lang) || !is_array($lang)) -{ - $lang = array(); -} - -// DEVELOPERS PLEASE NOTE -// -// All language files should use UTF-8 as their encoding and the files must not contain a BOM. -// -// Placeholders can now contain order information, e.g. instead of -// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows -// translators to re-order the output of data while ensuring it remains correct -// -// You do not need this where single placeholders are used, e.g. 'Message %d' is fine -// equally where a string contains only two placeholders which are used to wrap text -// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine - -// Board Settings -$lang = array_merge($lang, array( - 'ACP_BOARD_SETTINGS_EXPLAIN' => 'Here you can determine the basic operation of your board, give it a fitting name and description, and among other settings adjust the default values for timezone and language.', - 'BOARD_INDEX_TEXT' => 'Board index text', - 'BOARD_INDEX_TEXT_EXPLAIN' => 'This text is displayed as the board index in the board’s breadcrumbs. If not specified, it will default to “Board index”.', - 'BOARD_STYLE' => 'Board style', - 'CUSTOM_DATEFORMAT' => 'Custom…', - 'DEFAULT_DATE_FORMAT' => 'Date format', - 'DEFAULT_DATE_FORMAT_EXPLAIN' => 'The date format is the same as the PHP date() function.', - 'DEFAULT_LANGUAGE' => 'Default language', - 'DEFAULT_STYLE' => 'Default style', - 'DEFAULT_STYLE_EXPLAIN' => 'The default style for new users.', - 'DISABLE_BOARD' => 'Disable board', - 'DISABLE_BOARD_EXPLAIN' => 'This will make the board unavailable to users who are neither administrators nor moderators. You can also enter a short (255 character) message to display if you wish.', - 'DISPLAY_LAST_SUBJECT' => 'Display subject of last added post on forum list', - 'DISPLAY_LAST_SUBJECT_EXPLAIN' => 'The subject of the last added post will be displayed in the forum list with a hyperlink to the post. Subjects from password protected forums and forums in which user doesn’t have read access are not shown.', - 'DISPLAY_UNAPPROVED_POSTS' => 'Display unapproved posts to the author', - 'DISPLAY_UNAPPROVED_POSTS_EXPLAIN' => 'Unapproved posts can be viewed by the author. Does not apply to Guest posts.', - 'GUEST_STYLE' => 'Guest style', - 'GUEST_STYLE_EXPLAIN' => 'The board style for guests.', - 'OVERRIDE_STYLE' => 'Override user style', - 'OVERRIDE_STYLE_EXPLAIN' => 'Replaces user’s (and guest’s) style with the style as defined under "Default style".', - 'SITE_DESC' => 'Site description', - 'SITE_HOME_TEXT' => 'Main website text', - 'SITE_HOME_TEXT_EXPLAIN' => 'This text will be displayed as a link to your website homepage in the board’s breadcrumbs. If not specified, it will default to “Home”.', - 'SITE_HOME_URL' => 'Main website URL', - 'SITE_HOME_URL_EXPLAIN' => 'If specified, a link to this URL will be prepended to your board’s breadcrumbs and the board logo will link to this URL instead of the forum index. An absolute URL is required, e.g. http://www.phpbb.com.', - 'SITE_NAME' => 'Site name', - 'SYSTEM_TIMEZONE' => 'Guest timezone', - 'SYSTEM_TIMEZONE_EXPLAIN' => 'Timezone to use for displaying times to users who are not logged in (guests, bots). Logged in users set their timezone during registration and can change it in their user control panel.', - 'WARNINGS_EXPIRE' => 'Warning duration', - 'WARNINGS_EXPIRE_EXPLAIN' => 'Number of days that will elapse before a warning will automatically expire from a user’s record. Set this value to 0 to make warnings permanent.', -)); - -// Board Features -$lang = array_merge($lang, array( - 'ACP_BOARD_FEATURES_EXPLAIN' => 'Here you can enable/disable several board features.', - - 'ALLOW_ATTACHMENTS' => 'Allow attachments', - 'ALLOW_BIRTHDAYS' => 'Allow birthdays', - 'ALLOW_BIRTHDAYS_EXPLAIN' => 'Allow birthdays to be entered and age being displayed in profiles. Please note the birthday list within the board index is controlled by a separate load setting.', - 'ALLOW_BOOKMARKS' => 'Allow bookmarking topics', - 'ALLOW_BOOKMARKS_EXPLAIN' => 'User is able to store personal bookmarks.', - 'ALLOW_BBCODE' => 'Allow BBCode', - 'ALLOW_FORUM_NOTIFY' => 'Allow subscribing to forums', - 'ALLOW_NAME_CHANGE' => 'Allow username changes', - 'ALLOW_NO_CENSORS' => 'Allow disabling of word censoring', - 'ALLOW_NO_CENSORS_EXPLAIN' => 'Users can choose to disable the automatic word censoring of posts and private messages.', - 'ALLOW_PM_ATTACHMENTS' => 'Allow attachments in private messages', - 'ALLOW_PM_REPORT' => 'Allow users to report private messages', - 'ALLOW_PM_REPORT_EXPLAIN' => 'If this setting is enabled, users have the option of reporting a private message they have received or sent to the board’s moderators. These private messages will then be visible in the Moderator Control Panel.', - 'ALLOW_QUICK_REPLY' => 'Allow quick reply', - 'ALLOW_QUICK_REPLY_EXPLAIN' => 'This switch allows for the quick reply to be disabled board-wide. When enabled, forum specific settings will be used to determine whether the quick reply is displayed in individual forums.', - 'ALLOW_QUICK_REPLY_BUTTON' => 'Submit and enable quick reply in all forums', - 'ALLOW_SIG' => 'Allow signatures', - 'ALLOW_SIG_BBCODE' => 'Allow BBCode in user signatures', - 'ALLOW_SIG_FLASH' => 'Allow use of [FLASH] BBCode tag in user signatures', - 'ALLOW_SIG_IMG' => 'Allow use of [IMG] BBCode tag in user signatures', - 'ALLOW_SIG_LINKS' => 'Allow use of links in user signatures', - 'ALLOW_SIG_LINKS_EXPLAIN' => 'If disallowed the [URL] BBCode tag and automatic/magic URLs are disabled.', - 'ALLOW_SIG_SMILIES' => 'Allow use of smilies in user signatures', - 'ALLOW_SMILIES' => 'Allow smilies', - 'ALLOW_TOPIC_NOTIFY' => 'Allow subscribing to topics', - 'BOARD_PM' => 'Private messaging', - 'BOARD_PM_EXPLAIN' => 'Enable private messaging for all users.', - 'ALLOW_BOARD_NOTIFICATIONS' => 'Allow board notifications', -)); - -// Avatar Settings -$lang = array_merge($lang, array( - 'ACP_AVATAR_SETTINGS_EXPLAIN' => 'Avatars are generally small, unique images a user can associate with themselves. Depending on the style they are usually displayed below the username when viewing topics. Here you can determine how users can define their avatars. Please note that in order to upload avatars you need to have created the directory you name below and ensure it can be written to by the web server. Please also note that file size limits are only imposed on uploaded avatars, they do not apply to remotely linked images.', - - 'ALLOW_AVATARS' => 'Enable avatars', - 'ALLOW_AVATARS_EXPLAIN' => 'Allow general usage of avatars;
If you disable avatars in general or avatars of a certain mode, the disabled avatars will no longer be shown on the board, but users will still be able to download their own avatars in the User Control Panel.', - 'ALLOW_GRAVATAR' => 'Enable gravatar avatars', - 'ALLOW_LOCAL' => 'Enable gallery avatars', - 'ALLOW_REMOTE' => 'Enable remote avatars', - 'ALLOW_REMOTE_EXPLAIN' => 'Avatars linked to from another website.
Warning: Enabling this feature might allow users to check for the existence of files and services that are only accessible on the local network.', - 'ALLOW_REMOTE_UPLOAD' => 'Enable remote avatar uploading', - 'ALLOW_REMOTE_UPLOAD_EXPLAIN' => 'Allow uploading of avatars from another website.
Warning: Enabling this feature might allow users to check for the existence of files and services that are only accessible on the local network.', - 'ALLOW_UPLOAD' => 'Enable avatar uploading', - 'AVATAR_GALLERY_PATH' => 'Avatar gallery path', - 'AVATAR_GALLERY_PATH_EXPLAIN' => 'Path under your phpBB root directory for pre-loaded images, e.g. images/avatars/gallery.
Double dots like ../ will be stripped from the path for security reasons.', - 'AVATAR_STORAGE_PATH' => 'Avatar storage path', - 'AVATAR_STORAGE_PATH_EXPLAIN' => 'Path under your phpBB root directory, e.g. images/avatars/upload.
Avatar uploading will not be available if this path is not writable.
Double dots like ../ will be stripped from the path for security reasons.', - 'MAX_AVATAR_SIZE' => 'Maximum avatar dimensions', - 'MAX_AVATAR_SIZE_EXPLAIN' => 'Width x Height in pixels.', - 'MAX_FILESIZE' => 'Maximum avatar file size', - 'MAX_FILESIZE_EXPLAIN' => 'For uploaded avatar files. If this value is 0, the uploaded filesize is only limited by your PHP configuration.', - 'MIN_AVATAR_SIZE' => 'Minimum avatar dimensions', - 'MIN_AVATAR_SIZE_EXPLAIN' => 'Width x Height in pixels.', -)); - -// Message Settings -$lang = array_merge($lang, array( - 'ACP_MESSAGE_SETTINGS_EXPLAIN' => 'Here you can set all default settings for private messaging.', - - 'ALLOW_BBCODE_PM' => 'Allow BBCode in private messages', - 'ALLOW_FLASH_PM' => 'Allow use of [FLASH] BBCode tag', - 'ALLOW_FLASH_PM_EXPLAIN' => 'Note that the ability to use flash in private messages, if enabled here, also depends on the permissions.', - 'ALLOW_FORWARD_PM' => 'Allow forwarding of private messages', - 'ALLOW_IMG_PM' => 'Allow use of [IMG] BBCode tag', - 'ALLOW_MASS_PM' => 'Allow sending of private messages to multiple users and groups', - 'ALLOW_MASS_PM_EXPLAIN' => 'Sending to groups can be adjusted per group within the group settings page.', - 'ALLOW_PRINT_PM' => 'Allow print view in private messaging', - 'ALLOW_QUOTE_PM' => 'Allow quotes in private messages', - 'ALLOW_SIG_PM' => 'Allow signature in private messages', - 'ALLOW_SMILIES_PM' => 'Allow smilies in private messages', - 'BOXES_LIMIT' => 'Maximum private messages per box', - 'BOXES_LIMIT_EXPLAIN' => 'Users may receive no more than this many messages in each of their private message boxes. Set this value to 0 to allow unlimited messages.', - 'BOXES_MAX' => 'Maximum private message folders', - 'BOXES_MAX_EXPLAIN' => 'By default users may create this many personal folders for private messages.', - 'ENABLE_PM_ICONS' => 'Enable use of topic icons in private messages', - 'FULL_FOLDER_ACTION' => 'Full folder default action', - 'FULL_FOLDER_ACTION_EXPLAIN'=> 'Default action to take if a user’s folder is full assuming the user’s folder action, if set at all, is not applicable. The only exception is for the “Sent messages” folder where the default action is always to delete old messages.', - 'HOLD_NEW_MESSAGES' => 'Hold new messages', - 'PM_EDIT_TIME' => 'Limit editing time', - 'PM_EDIT_TIME_EXPLAIN' => 'Limits the time available to edit a private message not already delivered. Setting the value to 0 disables this behaviour.', - 'PM_MAX_RECIPIENTS' => 'Maximum number of allowed recipients', - 'PM_MAX_RECIPIENTS_EXPLAIN' => 'The maximum number of allowed recipients in a private message. If 0 is entered, an unlimited number is allowed. This setting can be adjusted for every group within the group settings page.', -)); - -// Post Settings -$lang = array_merge($lang, array( - 'ACP_POST_SETTINGS_EXPLAIN' => 'Here you can set all default settings for posting.', - 'ALLOW_POST_LINKS' => 'Allow links in posts/private messages', - 'ALLOW_POST_LINKS_EXPLAIN' => 'If disallowed the [URL] BBCode tag and automatic/magic URLs are disabled.', - 'ALLOWED_SCHEMES_LINKS' => 'Allowed schemes in links', - 'ALLOWED_SCHEMES_LINKS_EXPLAIN' => 'Users can only post schemeless URLs or one of the comma-separated list of allowed schemes.', - 'ALLOW_POST_FLASH' => 'Allow use of [FLASH] BBCode tag in posts', - 'ALLOW_POST_FLASH_EXPLAIN' => 'If disallowed the [FLASH] BBCode tag is disabled in posts. Otherwise the permission system controls which users can use the [FLASH] BBCode tag.', - - 'BUMP_INTERVAL' => 'Bump interval', - 'BUMP_INTERVAL_EXPLAIN' => 'Number of minutes, hours or days between the last post to a topic and the ability to bump that topic. Setting the value to 0 disables bumping entirely.', - 'CHAR_LIMIT' => 'Maximum characters per post/message', - 'CHAR_LIMIT_EXPLAIN' => 'The number of characters allowed within a post/private message. Set to 0 for unlimited characters.', - 'DELETE_TIME' => 'Limit deleting time', - 'DELETE_TIME_EXPLAIN' => 'Limits the time available to delete a new post. Setting the value to 0 disables this behaviour.', - 'DISPLAY_LAST_EDITED' => 'Display last edited time information', - 'DISPLAY_LAST_EDITED_EXPLAIN' => 'Choose if the last edited by information to be displayed on posts.', - 'EDIT_TIME' => 'Limit editing time', - 'EDIT_TIME_EXPLAIN' => 'Limits the time available to edit a new post. Setting the value to 0 disables this behaviour.', - 'FLOOD_INTERVAL' => 'Flood interval', - 'FLOOD_INTERVAL_EXPLAIN' => 'Number of seconds a user must wait between posting new messages. To enable users to ignore this alter their permissions.', - 'HOT_THRESHOLD' => 'Popular topic threshold', - 'HOT_THRESHOLD_EXPLAIN' => 'Posts per topic threshold required for the popular topic annotation. Set to 0 to disable popular topics.', - 'MAX_POLL_OPTIONS' => 'Maximum number of poll options', - 'MAX_POST_FONT_SIZE' => 'Maximum font size per post', - 'MAX_POST_FONT_SIZE_EXPLAIN' => 'Maximum font size allowed in a post. Set to 0 for unlimited font size.', - 'MAX_POST_IMG_HEIGHT' => 'Maximum image height per post', - 'MAX_POST_IMG_HEIGHT_EXPLAIN' => 'Maximum height of an image/flash file in postings. Set to 0 for unlimited size.', - 'MAX_POST_IMG_WIDTH' => 'Maximum image width per post', - 'MAX_POST_IMG_WIDTH_EXPLAIN' => 'Maximum width of an image/flash file in postings. Set to 0 for unlimited size.', - 'MAX_POST_URLS' => 'Maximum links per post', - 'MAX_POST_URLS_EXPLAIN' => 'Maximum number of URLs in a post. Set to 0 for unlimited links.', - 'MIN_CHAR_LIMIT' => 'Minimum characters per post/message', - 'MIN_CHAR_LIMIT_EXPLAIN' => 'The minimum number of characters the user need to enter within a post/private message. The minimum for this setting is 1.', - 'POSTING' => 'Posting', - 'POSTS_PER_PAGE' => 'Posts per page', - 'QUOTE_DEPTH_LIMIT' => 'Maximum nesting depth for quotes', - 'QUOTE_DEPTH_LIMIT_EXPLAIN' => 'Maximum quote nesting depth in a post. Set to 0 for unlimited depth.', - 'SMILIES_LIMIT' => 'Maximum smilies per post', - 'SMILIES_LIMIT_EXPLAIN' => 'Maximum number of smilies in a post. Set to 0 for unlimited smilies.', - 'SMILIES_PER_PAGE' => 'Smilies per page', - 'TOPICS_PER_PAGE' => 'Topics per page', -)); - -// Signature Settings -$lang = array_merge($lang, array( - 'ACP_SIGNATURE_SETTINGS_EXPLAIN' => 'Here you can set all default settings for signatures.', - - 'MAX_SIG_FONT_SIZE' => 'Maximum signature font size', - 'MAX_SIG_FONT_SIZE_EXPLAIN' => 'Maximum font size allowed in user signatures. Set to 0 for unlimited size.', - 'MAX_SIG_IMG_HEIGHT' => 'Maximum signature image height', - 'MAX_SIG_IMG_HEIGHT_EXPLAIN' => 'Maximum height of an image/flash file in user signatures. Set to 0 for unlimited height.', - 'MAX_SIG_IMG_WIDTH' => 'Maximum signature image width', - 'MAX_SIG_IMG_WIDTH_EXPLAIN' => 'Maximum width of an image/flash file in user signatures. Set to 0 for unlimited width.', - 'MAX_SIG_LENGTH' => 'Maximum signature length', - 'MAX_SIG_LENGTH_EXPLAIN' => 'Maximum number of characters in user signatures.', - 'MAX_SIG_SMILIES' => 'Maximum smilies per signature', - 'MAX_SIG_SMILIES_EXPLAIN' => 'Maximum smilies allowed in user signatures. Set to 0 for unlimited smilies.', - 'MAX_SIG_URLS' => 'Maximum signature links', - 'MAX_SIG_URLS_EXPLAIN' => 'Maximum number of links in user signatures. Set to 0 for unlimited links.', -)); - -// Registration Settings -$lang = array_merge($lang, array( - 'ACP_REGISTER_SETTINGS_EXPLAIN' => 'Here you are able to define registration and profile related settings.', - - 'ACC_ACTIVATION' => 'Account activation', - 'ACC_ACTIVATION_EXPLAIN' => 'This determines whether users have immediate access to the board or if confirmation is required. You can also completely disable new registrations. “Board-wide email” must be enabled in order to use user or admin activation.', - 'ACC_ACTIVATION_WARNING' => 'Please note that the currently selected activation method requires emails to be enabled, otherwise registration will be disabled. We recommend to either select a different activation method or reenable emails.', - 'NEW_MEMBER_POST_LIMIT' => 'New member post limit', - 'NEW_MEMBER_POST_LIMIT_EXPLAIN' => 'New members are within the Newly Registered Users group until they reach this number of posts. You can use this group to keep them from using the PM system or to review their posts. A value of 0 disables this feature.', - 'NEW_MEMBER_GROUP_DEFAULT' => 'Set Newly Registered Users group to default', - 'NEW_MEMBER_GROUP_DEFAULT_EXPLAIN' => 'If set to yes, and a new member post limit is specified, newly registered users will not only be put into the Newly Registered Users group, but this group will also be their default one. This may come in handy if you want to assign a group default rank and/or avatar the user then inherits.', - - 'ACC_ADMIN' => 'By admin', - 'ACC_DISABLE' => 'Disable registration', - 'ACC_NONE' => 'No activation (immediate access)', - 'ACC_USER' => 'By user (email verification)', -// 'ACC_USER_ADMIN' => 'User + Admin', - 'ALLOW_EMAIL_REUSE' => 'Allow email address re-use', - 'ALLOW_EMAIL_REUSE_EXPLAIN' => 'Different users can register with the same email address.', - 'COPPA' => 'COPPA', - 'COPPA_FAX' => 'COPPA fax number', - 'COPPA_MAIL' => 'COPPA mailing address', - 'COPPA_MAIL_EXPLAIN' => 'This is the mailing address where parents will send COPPA registration forms.', - 'ENABLE_COPPA' => 'Enable COPPA', - 'ENABLE_COPPA_EXPLAIN' => 'This requires users to declare whether they are 13 or over for compliance with the U.S. COPPA. If this is disabled the COPPA specific groups will no longer be displayed.', - 'MAX_CHARS' => 'Max', - 'MIN_CHARS' => 'Min', - 'NO_AUTH_PLUGIN' => 'No suitable auth plugin found.', - 'PASSWORD_LENGTH' => 'Password length', - 'PASSWORD_LENGTH_EXPLAIN' => 'Minimum and maximum number of characters in passwords.', - 'REG_LIMIT' => 'Registration attempts', - 'REG_LIMIT_EXPLAIN' => 'Number of attempts users can make at solving the anti-spambot task before being locked out of that session.', - 'USERNAME_ALPHA_ONLY' => 'Alphanumeric only', - 'USERNAME_ALPHA_SPACERS' => 'Alphanumeric and spacers', - 'USERNAME_ASCII' => 'ASCII (no international unicode)', - 'USERNAME_LETTER_NUM' => 'Any letter and number', - 'USERNAME_LETTER_NUM_SPACERS' => 'Any letter, number, and spacer', - 'USERNAME_CHARS' => 'Limit username chars', - 'USERNAME_CHARS_ANY' => 'Any character', - 'USERNAME_CHARS_EXPLAIN' => 'Restrict type of characters that may be used in usernames, spacers are: space, -, +, _, [ and ].', - 'USERNAME_LENGTH' => 'Username length', - 'USERNAME_LENGTH_EXPLAIN' => 'Minimum and maximum number of characters in usernames.', -)); - -// Feeds -$lang = array_merge($lang, array( - 'ACP_FEED_MANAGEMENT' => 'General syndication feeds settings', - 'ACP_FEED_MANAGEMENT_EXPLAIN' => 'This module makes available various ATOM feeds, parsing any BBCode in posts to make them readable in external feeds.', - - 'ACP_FEED_GENERAL' => 'General feed settings', - 'ACP_FEED_POST_BASED' => 'Post-based feed settings', - 'ACP_FEED_TOPIC_BASED' => 'Topic-based feed settings', - 'ACP_FEED_SETTINGS_OTHER' => 'Other feeds and settings', - - 'ACP_FEED_ENABLE' => 'Enable feeds', - 'ACP_FEED_ENABLE_EXPLAIN' => 'Turns on or off ATOM feeds for the entire board.
Disabling this switches off all feeds, no matter how the options below are set.', - 'ACP_FEED_LIMIT' => 'Number of items', - 'ACP_FEED_LIMIT_EXPLAIN' => 'The maximum number of feed items to display.', - - 'ACP_FEED_OVERALL' => 'Enable board-wide feed', - 'ACP_FEED_OVERALL_EXPLAIN' => 'Board-wide new posts.', - 'ACP_FEED_FORUM' => 'Enable per-forum feeds', - 'ACP_FEED_FORUM_EXPLAIN' => 'Single forum and subforums new posts.', - 'ACP_FEED_TOPIC' => 'Enable per-topic feeds', - 'ACP_FEED_TOPIC_EXPLAIN' => 'Single topics new posts.', - - 'ACP_FEED_TOPICS_NEW' => 'Enable new topics feed', - 'ACP_FEED_TOPICS_NEW_EXPLAIN' => 'Enables the “New Topics” feed, which displays the last created topics including the first post.', - 'ACP_FEED_TOPICS_ACTIVE' => 'Enable active topics feed', - 'ACP_FEED_TOPICS_ACTIVE_EXPLAIN' => 'Enables the “Active Topics” feed, which displays the last active topics including the last post.', - 'ACP_FEED_NEWS' => 'News feed', - 'ACP_FEED_NEWS_EXPLAIN' => 'Pull the first post from these forums. Select no forums to disable news feed.
Select multiple forums by holding CTRL and clicking.', - - 'ACP_FEED_OVERALL_FORUMS' => 'Enable forums feed', - 'ACP_FEED_OVERALL_FORUMS_EXPLAIN' => 'Enables the “All forums” feed, which displays a list of forums.', - - 'ACP_FEED_HTTP_AUTH' => 'Allow HTTP Authentication', - 'ACP_FEED_HTTP_AUTH_EXPLAIN' => 'Enables HTTP authentication, which allows users to receive content that is hidden to guest users by adding the auth=http parameter to the feed URL. Please note that some PHP setups require additional changes to the .htaccess file. Instructions can be found in that file.', - 'ACP_FEED_ITEM_STATISTICS' => 'Item statistics', - 'ACP_FEED_ITEM_STATISTICS_EXPLAIN' => 'Display individual statistics underneath feed items
(e.g. posted by, date and time, replies, views)', - 'ACP_FEED_EXCLUDE_ID' => 'Exclude these forums', - 'ACP_FEED_EXCLUDE_ID_EXPLAIN' => 'Content from these will be not included in feeds. Select no forum to pull data from all forums.
Select/Deselect multiple forums by holding CTRL and clicking.', -)); - -// Visual Confirmation Settings -$lang = array_merge($lang, array( - 'ACP_VC_SETTINGS_EXPLAIN' => 'Here you can select and configure plugins, which are designed to block automated form submissions by spambots. These plugins typically work by challenging the user with a CAPTCHA, a test which is designed to be difficult for computers to solve.', - 'ACP_VC_EXT_GET_MORE' => 'For additional (and possibly better) anti-spam plugins, visit the phpBB.com Extensions Database. For more information on preventing spam on your board, visit the phpBB.com Knowledge Base.', - 'AVAILABLE_CAPTCHAS' => 'Available plugins', - 'CAPTCHA_UNAVAILABLE' => 'The plugin cannot be selected as its requirements are not met.', - 'CAPTCHA_GD' => 'GD image', - 'CAPTCHA_GD_3D' => 'GD 3D image', - 'CAPTCHA_GD_FOREGROUND_NOISE' => 'Foreground noise', - 'CAPTCHA_GD_EXPLAIN' => 'Uses GD to make a more advanced anti-spambot image.', - 'CAPTCHA_GD_FOREGROUND_NOISE_EXPLAIN' => 'Use foreground noise to make the image harder to read.', - 'CAPTCHA_GD_X_GRID' => 'Background noise x-axis', - 'CAPTCHA_GD_X_GRID_EXPLAIN' => 'Use lower settings of this to make the image harder to read. 0 will disable x-axis background noise.', - 'CAPTCHA_GD_Y_GRID' => 'Background noise y-axis', - 'CAPTCHA_GD_Y_GRID_EXPLAIN' => 'Use lower settings of this to make the image harder to read. 0 will disable y-axis background noise.', - 'CAPTCHA_GD_WAVE' => 'Wave distortion', - 'CAPTCHA_GD_WAVE_EXPLAIN' => 'This applies a wave distortion to the image.', - 'CAPTCHA_GD_3D_NOISE' => 'Add 3D-noise objects', - 'CAPTCHA_GD_3D_NOISE_EXPLAIN' => 'This adds additional objects to the image, over the letters.', - 'CAPTCHA_GD_FONTS' => 'Use different fonts', - 'CAPTCHA_GD_FONTS_EXPLAIN' => 'This setting controls how many different letter shapes are used. You can just use the default shapes or introduce altered letters. Adding lowercase letters is also possible.', - 'CAPTCHA_FONT_DEFAULT' => 'Default', - 'CAPTCHA_FONT_NEW' => 'New Shapes', - 'CAPTCHA_FONT_LOWER' => 'Also use lowercase', - 'CAPTCHA_NO_GD' => 'Simple image', - 'CAPTCHA_PREVIEW_MSG' => 'Your changes have not been saved, this is just a preview.', - 'CAPTCHA_PREVIEW_EXPLAIN' => 'The plugin as it would look like using the current selection.', - - 'CAPTCHA_SELECT' => 'Installed plugins', - 'CAPTCHA_SELECT_EXPLAIN' => 'The dropdown holds the plugins recognised by the board. Grey entries are not available right now and might need configuration prior to use.', - 'CAPTCHA_CONFIGURE' => 'Configure plugins', - 'CAPTCHA_CONFIGURE_EXPLAIN' => 'Change the settings for the selected plugin.', - 'CONFIGURE' => 'Configure', - 'CAPTCHA_NO_OPTIONS' => 'This plugin has no configuration options.', - - 'VISUAL_CONFIRM_POST' => 'Enable spambot countermeasures for guest postings', - 'VISUAL_CONFIRM_POST_EXPLAIN' => 'Requires guest users to pass the anti-spambot task to help prevent automated postings.', - 'VISUAL_CONFIRM_REG' => 'Enable spambot countermeasures for registrations', - 'VISUAL_CONFIRM_REG_EXPLAIN' => 'Requires new users to pass the anti-spambot task to help prevent automated registrations.', - 'VISUAL_CONFIRM_REFRESH' => 'Allow users to refresh the anti-spambot task', - 'VISUAL_CONFIRM_REFRESH_EXPLAIN' => 'Allows users to request a new anti-spambot task if they are unable to solve the current task during registration. Some plugins might not support this option.', -)); - -// Cookie Settings -$lang = array_merge($lang, array( - 'ACP_COOKIE_SETTINGS_EXPLAIN' => 'These details define the data used to send cookies to your users browsers. In most cases the default values for the cookie settings should be sufficient. If you do need to change any do so with care, incorrect settings can prevent users logging in. If you have problems with users staying logging in to your board, visit the phpBB.com Knowledge Base - Fixing incorrect cookie settings.', - - 'COOKIE_DOMAIN' => 'Cookie domain', - 'COOKIE_DOMAIN_EXPLAIN' => 'In most cases the cookie domain is optional. Leave it blank if you are unsure.

In the case where you have a board integrated with other software or have multiple domains, then to determine the cookie domain you need to do the following. If you have something like example.com and forums.example.com, or perhaps forums.example.com and blog.example.com. Remove the subdomains until you find the common domain, example.com. Now add a dot in front of the common domain and you would enter .example.com (note the dot at the beginning).', - 'COOKIE_NAME' => 'Cookie name', - 'COOKIE_NAME_EXPLAIN' => 'This can be anything what you want, make it original. Whenever the cookie settings are changed the name of the cookie should be changed.', - 'COOKIE_NOTICE' => 'Cookie notice', - 'COOKIE_NOTICE_EXPLAIN' => 'If enabled a cookie notice will be displayed to users when visiting your board. This might be required by law depending on the content of your board and enabled extensions.', - 'COOKIE_PATH' => 'Cookie path', - 'COOKIE_PATH_EXPLAIN' => 'This will usually be the same as your script path or simply a slash to make the cookie accessible across the site domain.', - 'COOKIE_SECURE' => 'Cookie secure', - 'COOKIE_SECURE_EXPLAIN' => 'If your server is running via SSL set this to enabled else leave as disabled. Having this enabled and not running via SSL will result in server errors during redirects.', - 'ONLINE_LENGTH' => 'View online time span', - 'ONLINE_LENGTH_EXPLAIN' => 'Number of minutes after which inactive users will not appear in “Who is online” listings. The higher this value the greater is the processing required to generate the listing.', - 'SESSION_LENGTH' => 'Session length', - 'SESSION_LENGTH_EXPLAIN' => 'Sessions will expire after this time, in seconds.', -)); - -// Contact Settings -$lang = array_merge($lang, array( - 'ACP_CONTACT_SETTINGS_EXPLAIN' => 'Here you can enable and disable the contact page and also add a text that is displayed on the page.', - - 'CONTACT_US_ENABLE' => 'Enable contact page', - 'CONTACT_US_ENABLE_EXPLAIN' => 'This page allows users to send emails to board administrators. Please note that board-wide emails option must be enabled as well. You can find this option in General > Client Communication > Email settings.', - - 'CONTACT_US_INFO' => 'Contact information', - 'CONTACT_US_INFO_EXPLAIN' => 'The message is displayed on the contact page', - 'CONTACT_US_INFO_PREVIEW' => 'Contact page information - Preview', - 'CONTACT_US_INFO_UPDATED' => 'Contact page information has been updated.', -)); - -// Load Settings -$lang = array_merge($lang, array( - 'ACP_LOAD_SETTINGS_EXPLAIN' => 'Here you can enable and disable certain board functions to reduce the amount of processing required. On most servers there is no need to disable any functions. However on certain systems or in shared hosting environments it may be beneficial to disable capabilities you do not really need. You can also specify limits for system load and active sessions beyond which the board will go offline.', - - 'ALLOW_CDN' => 'Allow usage of third party content delivery networks', - 'ALLOW_CDN_EXPLAIN' => 'If this setting is enabled, some files will be served from external third party servers instead of your server. This reduces the network bandwidth required by your server, but may present a privacy issue for some board administrators. In a default phpBB installation, this includes loading “jQuery” and the font “Open Sans” from Google’s content delivery network.', - 'ALLOW_LIVE_SEARCHES' => 'Allow live searches', - 'ALLOW_LIVE_SEARCHES_EXPLAIN' => 'If this setting is enabled, users are provided with keyword suggestions as they type in certain fields throughout the board.', - 'CUSTOM_PROFILE_FIELDS' => 'Custom profile fields', - 'LIMIT_LOAD' => 'Limit system load', - 'LIMIT_LOAD_EXPLAIN' => 'If the system’s 1-minute load average exceeds this value the board will automatically go offline. A value of 1.0 equals ~100% utilisation of one processor. This only functions on UNIX based servers and where this information is accessible. The value here resets itself to 0 if phpBB was unable to get the load limit.', - 'LIMIT_SESSIONS' => 'Limit sessions', - 'LIMIT_SESSIONS_EXPLAIN' => 'If the number of sessions exceeds this value within a one minute period the board will go offline. Set to 0 for unlimited sessions.', - 'LOAD_CPF_MEMBERLIST' => 'Allow styles to display custom profile fields in memberlist', - 'LOAD_CPF_PM' => 'Display custom profile fields in private messages', - 'LOAD_CPF_VIEWPROFILE' => 'Display custom profile fields in user profiles', - 'LOAD_CPF_VIEWTOPIC' => 'Display custom profile fields on topic pages', - 'LOAD_USER_ACTIVITY' => 'Show user’s activity', - 'LOAD_USER_ACTIVITY_EXPLAIN' => 'Displays active topic/forum in user profiles and user control panel. It is recommended to disable this on boards with more than one million posts.', - 'LOAD_USER_ACTIVITY_LIMIT' => 'User’s activity post limit', - 'LOAD_USER_ACTIVITY_LIMIT_EXPLAIN' => 'The active topic/forum won’t be shown for users having more than this number of posts. Set to 0 to disable the limit.', - 'READ_NOTIFICATION_EXPIRE_DAYS' => 'Read Notification Expiration', - 'READ_NOTIFICATION_EXPIRE_DAYS_EXPLAIN' => 'Number of days that will elapse before a read notification will automatically be deleted. Set this value to 0 to make notifications permanent.', - 'RECOMPILE_STYLES' => 'Recompile stale style components', - 'RECOMPILE_STYLES_EXPLAIN' => 'Check for updated style components on filesystem and recompile.', - 'YES_ACCURATE_PM_BUTTON' => 'Enable permission specific PM button in topic pages', - 'YES_ACCURATE_PM_BUTTON_EXPLAIN' => 'If this setting is enabled, only post profiles of users who are permitted to read private messages will have a private message button.', - 'YES_ANON_READ_MARKING' => 'Enable topic marking for guests', - 'YES_ANON_READ_MARKING_EXPLAIN' => 'Stores read/unread status information for guests. If disabled, posts are always marked read for guests.', - 'YES_BIRTHDAYS' => 'Enable birthday listing', - 'YES_BIRTHDAYS_EXPLAIN' => 'If disabled the birthday listing is no longer displayed. To let this setting take effect the birthday feature needs to be enabled too.', - 'YES_JUMPBOX' => 'Enable display of jumpbox', - 'YES_MODERATORS' => 'Enable display of moderators', - 'YES_ONLINE' => 'Enable online user listings', - 'YES_ONLINE_EXPLAIN' => 'Display online user information on index, forum and topic pages.', - 'YES_ONLINE_GUESTS' => 'Enable online guest listings in viewonline', - 'YES_ONLINE_GUESTS_EXPLAIN' => 'Allow display of guest user information in viewonline.', - 'YES_ONLINE_TRACK' => 'Enable display of user online/offline information', - 'YES_ONLINE_TRACK_EXPLAIN' => 'Display online information for user in profiles and topic pages.', - 'YES_POST_MARKING' => 'Enable dotted topics', - 'YES_POST_MARKING_EXPLAIN' => 'Indicates whether user has posted to a topic.', - 'YES_READ_MARKING' => 'Enable server-side topic marking', - 'YES_READ_MARKING_EXPLAIN' => 'Stores read/unread status information in the database rather than a cookie.', - 'YES_UNREAD_SEARCH' => 'Enable search for unread posts', -)); - -// Auth settings -$lang = array_merge($lang, array( - 'ACP_AUTH_SETTINGS_EXPLAIN' => 'phpBB supports authentication plug-ins, or modules. These allow you determine how users are authenticated when they log into the board. By default four plug-ins are provided: DB, LDAP, Apache, and OAuth. Not all methods require additional information so only fill out fields if they are relevant to the selected method.', - - 'AUTH_METHOD' => 'Select an authentication method', - - 'AUTH_PROVIDER_OAUTH_ERROR_ELEMENT_MISSING' => 'Both the key and secret of each enabled OAuth service provider must be provided. Only one was provided for an OAuth service provider.', - 'AUTH_PROVIDER_OAUTH_EXPLAIN' => 'Each OAuth provider requires a unique secret and key in order to authenticate with the external server. These should be supplied by the OAuth service when you register your website with them and should be entered exactly as provided to you.
Any service that does not have both a key and a secret entered here will not be available for use by the forum users. Also note, that user can still register and login using the DB authentication plug-in.', - 'AUTH_PROVIDER_OAUTH_KEY' => 'Key', - 'AUTH_PROVIDER_OAUTH_TITLE' => 'OAuth', - 'AUTH_PROVIDER_OAUTH_SECRET' => 'Secret', - - 'APACHE_SETUP_BEFORE_USE' => 'You have to setup apache authentication before you switch phpBB to this authentication method. Keep in mind that the username you use for apache authentication has to be the same as your phpBB username. Apache authentication can only be used with mod_php (not with a CGI version).', - - 'LDAP' => 'LDAP', - 'LDAP_DN' => 'LDAP base dn', - 'LDAP_DN_EXPLAIN' => 'This is the Distinguished Name, locating the user information, e.g. o=My Company,c=US.', - 'LDAP_EMAIL' => 'LDAP email attribute', - 'LDAP_EMAIL_EXPLAIN' => 'Set this to the name of your user entry email attribute (if one exists) in order to automatically set the email address for new users. Leaving this empty results in empty email address for users who log in for the first time.', - 'LDAP_INCORRECT_USER_PASSWORD' => 'Binding to LDAP server failed with specified user/password.', - 'LDAP_NO_EMAIL' => 'The specified email attribute does not exist.', - 'LDAP_NO_IDENTITY' => 'Could not find a login identity for %s.', - 'LDAP_PASSWORD' => 'LDAP password', - 'LDAP_PASSWORD_EXPLAIN' => 'Leave blank to use anonymous binding, otherwise fill in the password for the above user. Required for Active Directory Servers.
Warning: This password will be stored as plain text in the database, visible to everybody who can access your database or who can view this configuration page.', - 'LDAP_PORT' => 'LDAP server port', - 'LDAP_PORT_EXPLAIN' => 'Optionally you can specify a port which should be used to connect to the LDAP server instead of the default port 389.', - 'LDAP_SERVER' => 'LDAP server name', - 'LDAP_SERVER_EXPLAIN' => 'If using LDAP this is the hostname or IP address of the LDAP server. Alternatively you can specify an URL like ldap://hostname:port/', - 'LDAP_UID' => 'LDAP uid', - 'LDAP_UID_EXPLAIN' => 'This is the key under which to search for a given login identity, e.g. uid, sn, etc.', - 'LDAP_USER' => 'LDAP user dn', - 'LDAP_USER_EXPLAIN' => 'Leave blank to use anonymous binding. If filled in phpBB uses the specified distinguished name on login attempts to find the correct user, e.g. uid=Username,ou=MyUnit,o=MyCompany,c=US. Required for Active Directory Servers.', - 'LDAP_USER_FILTER' => 'LDAP user filter', - 'LDAP_USER_FILTER_EXPLAIN' => 'Optionally you can further limit the searched objects with additional filters. For example objectClass=posixGroup would result in the use of (&(uid=$username)(objectClass=posixGroup))', -)); - -// Server Settings -$lang = array_merge($lang, array( - 'ACP_SERVER_SETTINGS_EXPLAIN' => 'Here you define server and domain dependent settings. Please ensure the data you enter is accurate, errors will result in emails containing incorrect information. When entering the domain name remember it does include http:// or other protocol term. Only alter the port number if you know your server uses a different value, port 80 is correct in most cases.', - - 'ENABLE_GZIP' => 'Enable GZip compression', - 'ENABLE_GZIP_EXPLAIN' => 'Generated content will be compressed prior to sending it to the user. This can reduce network traffic but will also increase CPU usage on both server and client side. Requires zlib PHP extension to be loaded.', - 'FORCE_SERVER_VARS' => 'Force server URL settings', - 'FORCE_SERVER_VARS_EXPLAIN' => 'If set to yes the server settings defined here will be used in favour of the automatically determined values.', - 'ICONS_PATH' => 'Post icons storage path', - 'ICONS_PATH_EXPLAIN' => 'Path under your phpBB root directory, e.g. images/icons.', - 'MOD_REWRITE_ENABLE' => 'Enable URL Rewriting', - 'MOD_REWRITE_ENABLE_EXPLAIN' => 'When enabled, URLs containing ’app.php’ will be rewritten to remove the filename (i.e. app.php/foo will become /foo). Apache server’s mod_rewrite module is required for this functionality to work; if this option is enabled without mod_rewrite support, URLs on your board may be broken.', - 'MOD_REWRITE_DISABLED' => 'The mod_rewrite module on your Apache web server is disabled. Enable the module or contact your web hosting provider if you wish to enable this feature.', - 'MOD_REWRITE_INFORMATION_UNAVAILABLE' => 'We are unable to determine whether or not this server supports URL rewriting. This setting may be enabled but if URL rewriting is not available, paths generated by this board (such as for use in links) may be broken. Contact your web hosting provider if you are unsure whether or not you can safely enable this feature.', - 'PATH_SETTINGS' => 'Path settings', - 'RANKS_PATH' => 'Rank image storage path', - 'RANKS_PATH_EXPLAIN' => 'Path under your phpBB root directory, e.g. images/ranks.', - 'SCRIPT_PATH' => 'Script path', - 'SCRIPT_PATH_EXPLAIN' => 'The path where phpBB is located relative to the domain name, e.g. /phpBB3.', - 'SERVER_NAME' => 'Domain name', - 'SERVER_NAME_EXPLAIN' => 'The domain name this board runs from (for example: www.example.com).', - 'SERVER_PORT' => 'Server port', - 'SERVER_PORT_EXPLAIN' => 'The port your server is running on, usually 80, only change if different.', - 'SERVER_PROTOCOL' => 'Server protocol', - 'SERVER_PROTOCOL_EXPLAIN' => 'This is used as the server protocol if these settings are forced. If empty or not forced the protocol is determined by the cookie secure settings (http:// or https://).', - 'SERVER_URL_SETTINGS' => 'Server URL settings', - 'SMILIES_PATH' => 'Smilies storage path', - 'SMILIES_PATH_EXPLAIN' => 'Path under your phpBB root directory, e.g. images/smilies.', - 'UPLOAD_ICONS_PATH' => 'Extension group icons storage path', - 'UPLOAD_ICONS_PATH_EXPLAIN' => 'Path under your phpBB root directory, e.g. images/upload_icons.', - 'USE_SYSTEM_CRON' => 'Run periodic tasks from system cron', - 'USE_SYSTEM_CRON_EXPLAIN' => 'When off, phpBB will arrange for periodic tasks to be run automatically. When on, phpBB will not schedule any periodic tasks by itself; a system administrator must arrange for bin/phpbbcli.php cron:run to be run by the system cron facility at regular intervals (e.g. every 5 minutes).', -)); - -// Security Settings -$lang = array_merge($lang, array( - 'ACP_SECURITY_SETTINGS_EXPLAIN' => 'Here you are able to define session and login related settings.', - - 'ALL' => 'All', - 'ALLOW_AUTOLOGIN' => 'Allow "Remember Me" logins', - 'ALLOW_AUTOLOGIN_EXPLAIN' => 'Determines whether users are given "Remember Me" option when they visit the board.', - 'ALLOW_PASSWORD_RESET' => 'Allow password reset ("Forgot Password")', - 'ALLOW_PASSWORD_RESET_EXPLAIN' => 'Determines whether or not users are able to use the "I forgot my password" link on the login page to recover their account. If you use an external authentication mechanism you may wish to disable this feature.', - 'AUTOLOGIN_LENGTH' => '"Remember Me" login key expiration length (in days)', - 'AUTOLOGIN_LENGTH_EXPLAIN' => 'Number of days after which "Remember Me" login keys are removed or zero to disable.', - 'BROWSER_VALID' => 'Validate browser', - 'BROWSER_VALID_EXPLAIN' => 'Enables browser validation for each session improving security.', - 'CHECK_DNSBL' => 'Check IP against DNS Blackhole List', - 'CHECK_DNSBL_EXPLAIN' => 'If enabled the user’s IP address is checked against the following DNSBL services on registration and posting: spamcop.net and www.spamhaus.org. This lookup may take a while, depending on the server’s configuration. If slowdowns are experienced or too many false positives reported it is recommended to disable this check.', - 'CLASS_B' => 'A.B', - 'CLASS_C' => 'A.B.C', - 'EMAIL_CHECK_MX' => 'Check email domain for valid MX record', - 'EMAIL_CHECK_MX_EXPLAIN' => 'If enabled, the email domain provided on registration and profile changes is checked for a valid MX record.', - 'FORCE_PASS_CHANGE' => 'Force password change', - 'FORCE_PASS_CHANGE_EXPLAIN' => 'Require user to change their password after a set number of days. Setting this value to 0 disables this behaviour.', - 'FORM_TIME_MAX' => 'Maximum time to submit forms', - 'FORM_TIME_MAX_EXPLAIN' => 'The time a user has to submit a form. Use -1 to disable. Note that a form might become invalid if the session expires, regardless of this setting.', - 'FORM_SID_GUESTS' => 'Tie forms to guest sessions', - 'FORM_SID_GUESTS_EXPLAIN' => 'If enabled, the form token issued to guests will be session-exclusive. This can cause problems with some ISPs.', - 'FORWARDED_FOR_VALID' => 'Validate X_FORWARDED_FOR header', - 'FORWARDED_FOR_VALID_EXPLAIN' => 'Sessions will only be continued if the sent X_FORWARDED_FOR header equals the one sent with the previous request. Bans will be checked against IPs in X_FORWARDED_FOR too.', - 'IP_VALID' => 'Session IP validation', - 'IP_VALID_EXPLAIN' => 'Determines how much of the users IP is used to validate a session; All compares the complete address, A.B.C the first x.x.x, A.B the first x.x, None disables checking. On IPv6 addresses A.B.C compares the first 4 blocks and A.B the first 3 blocks.', - 'IP_LOGIN_LIMIT_MAX' => 'Maximum number of login attempts per IP address', - 'IP_LOGIN_LIMIT_MAX_EXPLAIN' => 'The threshold of login attempts allowed from a single IP address before an anti-spambot task is triggered. Enter 0 to prevent the anti-spambot task from being triggered by IP addresses.', - 'IP_LOGIN_LIMIT_TIME' => 'IP address login attempt expiration time', - 'IP_LOGIN_LIMIT_TIME_EXPLAIN' => 'Login attempts expire after this period.', - 'IP_LOGIN_LIMIT_USE_FORWARDED' => 'Limit login attempts by X_FORWARDED_FOR header', - 'IP_LOGIN_LIMIT_USE_FORWARDED_EXPLAIN' => 'Instead of limiting login attempts by IP address they are limited by X_FORWARDED_FOR values.
Warning: Only enable this if you are operating a proxy server that sets X_FORWARDED_FOR to trustworthy values.', - 'MAX_LOGIN_ATTEMPTS' => 'Maximum number of login attempts per username', - 'MAX_LOGIN_ATTEMPTS_EXPLAIN' => 'The number of login attempts allowed for a single account before the anti-spambot task is triggered. Enter 0 to prevent the anti-spambot task from being triggered for distinct user accounts.', - 'NO_IP_VALIDATION' => 'None', - 'NO_REF_VALIDATION' => 'None', - 'PASSWORD_TYPE' => 'Password complexity', - 'PASSWORD_TYPE_EXPLAIN' => 'Determines how complex a password needs to be when set or altered, subsequent options include the previous ones.', - 'PASS_TYPE_ALPHA' => 'Must contain letters and numbers', - 'PASS_TYPE_ANY' => 'No requirements', - 'PASS_TYPE_CASE' => 'Must be mixed case', - 'PASS_TYPE_SYMBOL' => 'Must contain symbols', - 'REF_HOST' => 'Only validate host', - 'REF_PATH' => 'Also validate path', - 'REFERRER_VALID' => 'Validate Referrer', - 'REFERRER_VALID_EXPLAIN' => 'If enabled, the referrer of POST requests will be checked against the host/script path settings. This may cause issues with boards using several domains and or external logins.', - 'TPL_ALLOW_PHP' => 'Allow php in templates', - 'TPL_ALLOW_PHP_EXPLAIN' => 'If this option is enabled, PHP and INCLUDEPHP statements will be recognised and parsed in templates.', - 'UPLOAD_CERT_VALID' => 'Validate upload certificate', - 'UPLOAD_CERT_VALID_EXPLAIN' => 'If enabled, certificates of remote uploads will be validated. This requires the CA bundle to be defined by the openssl.cafile or curl.cainfo setting in your php.ini.', -)); - -// Email Settings -$lang = array_merge($lang, array( - 'ACP_EMAIL_SETTINGS_EXPLAIN' => 'This information is used when the board sends emails to your users. Please ensure the email address you specify is valid, any bounced or undeliverable messages will likely be sent to that address. If your host does not provide a native (PHP based) email service you can instead send messages directly using SMTP. This requires the address of an appropriate server (ask your provider if necessary). If the server requires authentication (and only if it does) enter the necessary username, password and authentication method.', - - 'ADMIN_EMAIL' => 'From email address', - 'ADMIN_EMAIL_EXPLAIN' => 'This will be used as the from address on all emails, the technical contact email address. It will always be used as the Sender address in emails.', - 'BOARD_EMAIL_FORM' => 'Users send email via board', - 'BOARD_EMAIL_FORM_EXPLAIN' => 'Instead of showing the users email address users are able to send emails via the board.', - 'BOARD_HIDE_EMAILS' => 'Hide email addresses', - 'BOARD_HIDE_EMAILS_EXPLAIN' => 'This function keeps email addresses completely private.', - 'CONTACT_EMAIL' => 'Contact email address', - 'CONTACT_EMAIL_EXPLAIN' => 'This address will be used whenever a specific contact point is needed, e.g. spam, error output, etc. It will always be used as the From and Reply-To address in emails.', - 'CONTACT_EMAIL_NAME' => 'Contact name', - 'CONTACT_EMAIL_NAME_EXPLAIN' => 'This is the contact name that e-mail recipients will see. If you don’t want to have a contact name, leave this field empty.', - 'EMAIL_FORCE_SENDER' => 'Force from email address', - 'EMAIL_FORCE_SENDER_EXPLAIN' => 'This will set the Return-Path to the from email address instead of using the local user and hostname of the server. This setting does not apply when using SMTP.
Warning: Requires the user that the webserver runs as to be added as trusted user to the sendmail configuration.', - 'EMAIL_PACKAGE_SIZE' => 'Email package size', - 'EMAIL_PACKAGE_SIZE_EXPLAIN' => 'This is the number of maximum emails sent out in one package. This setting is applied to the internal message queue; set this value to 0 if you have problems with non-delivered notification emails.', - 'EMAIL_MAX_CHUNK_SIZE' => 'Maximum allowed email recipients', - 'EMAIL_MAX_CHUNK_SIZE_EXPLAIN' => 'If necessary, set this to not exceed the maximum number of recipients that your email server will allow in one email message.', - 'EMAIL_SIG' => 'Email signature', - 'EMAIL_SIG_EXPLAIN' => 'This text will be attached to all emails the board sends.', - 'ENABLE_EMAIL' => 'Enable board-wide emails', - 'ENABLE_EMAIL_EXPLAIN' => 'If this is set to disabled no emails will be sent by the board at all. Note the user and admin account activation settings require this setting to be enabled. If currently using “user” or “admin” activation in the activation settings, disabling this setting will disable registration.', - 'SEND_TEST_EMAIL' => 'Send a test email', - 'SEND_TEST_EMAIL_EXPLAIN' => 'This will send a test email to the address defined in your account.', - 'SMTP_ALLOW_SELF_SIGNED' => 'Allow self-signed SSL certificates', - 'SMTP_ALLOW_SELF_SIGNED_EXPLAIN'=> 'Allow connections to SMTP server with self-signed SSL certificate.
Warning: Allowing self-signed SSL certificates may cause security implications.', - 'SMTP_AUTH_METHOD' => 'Authentication method for SMTP', - 'SMTP_AUTH_METHOD_EXPLAIN' => 'Only used if a username/password is set, ask your provider if you are unsure which method to use.', - 'SMTP_CRAM_MD5' => 'CRAM-MD5', - 'SMTP_DIGEST_MD5' => 'DIGEST-MD5', - 'SMTP_LOGIN' => 'LOGIN', - 'SMTP_PASSWORD' => 'SMTP password', - 'SMTP_PASSWORD_EXPLAIN' => 'Only enter a password if your SMTP server requires it.
Warning: This password will be stored as plain text in the database, visible to everybody who can access your database or who can view this configuration page.', - 'SMTP_PLAIN' => 'PLAIN', - 'SMTP_POP_BEFORE_SMTP' => 'POP-BEFORE-SMTP', - 'SMTP_PORT' => 'SMTP server port', - 'SMTP_PORT_EXPLAIN' => 'Only change this if you know your SMTP server is on a different port.', - 'SMTP_SERVER' => 'SMTP server address', - 'SMTP_SERVER_EXPLAIN' => 'Do not provide a protocol (ssl:// or tls://) unless your mail host tells you to do so.', - 'SMTP_SETTINGS' => 'SMTP settings', - 'SMTP_USERNAME' => 'SMTP username', - 'SMTP_USERNAME_EXPLAIN' => 'Only enter a username if your SMTP server requires it.', - 'SMTP_VERIFY_PEER' => 'Verify SSL certificate', - 'SMTP_VERIFY_PEER_EXPLAIN' => 'Require verification of SSL certificate used by SMTP server.
Warning: Connecting peers with unverified SSL certificates may cause security implications.', - 'SMTP_VERIFY_PEER_NAME' => 'Verify SMTP peer name', - 'SMTP_VERIFY_PEER_NAME_EXPLAIN' => 'Require verification of peer name for SMTP servers using SSL / TLS connections.
Warning: Connecting to unverified peers may cause security implications.', - 'TEST_EMAIL_SENT' => 'The test email has been sent.
If you don’t receive it, please check your emails configuration.

If you require assistance, please visit the phpBB support forums.', - - 'USE_SMTP' => 'Use SMTP server for email', - 'USE_SMTP_EXPLAIN' => 'Select “Yes” if you want or have to send email via a named server instead of the local mail function.', -)); - -// Jabber settings -$lang = array_merge($lang, array( - 'ACP_JABBER_SETTINGS_EXPLAIN' => 'Here you can enable and control the use of Jabber for instant messaging and board notifications. Jabber is an open source protocol and therefore available for use by anyone. Some Jabber servers include gateways or transports which allow you to contact users on other networks. Not all servers offer all transports and changes in protocols can prevent transports from operating. Please be sure to enter already registered account details - phpBB will use the details you enter here as is.', - - 'JAB_ALLOW_SELF_SIGNED' => 'Allow self-signed SSL certificates', - 'JAB_ALLOW_SELF_SIGNED_EXPLAIN' => 'Allow connections to Jabber server with self-signed SSL certificate.
Warning: Allowing self-signed SSL certificates may cause security implications.', - 'JAB_ENABLE' => 'Enable Jabber', - 'JAB_ENABLE_EXPLAIN' => 'Enables use of Jabber messaging and notifications.', - 'JAB_GTALK_NOTE' => 'Please note that GTalk will not work because the dns_get_record function could not be found. This function is not available in PHP4, and is not implemented on Windows platforms. It currently does not work on BSD-based systems, including Mac OS.', - 'JAB_PACKAGE_SIZE' => 'Jabber package size', - 'JAB_PACKAGE_SIZE_EXPLAIN' => 'This is the number of messages sent in one package. If set to 0 the message is sent immediately and will not be queued for later sending.', - 'JAB_PASSWORD' => 'Jabber password', - 'JAB_PASSWORD_EXPLAIN' => 'Warning: This password will be stored as plain text in the database, visible to everybody who can access your database or who can view this configuration page.', - 'JAB_PORT' => 'Jabber port', - 'JAB_PORT_EXPLAIN' => 'Leave blank unless you know it is not port 5222.', - 'JAB_SERVER' => 'Jabber server', - 'JAB_SERVER_EXPLAIN' => 'See %sjabber.org%s for a list of servers.', - 'JAB_SETTINGS_CHANGED' => 'Jabber settings changed successfully.', - 'JAB_USE_SSL' => 'Use SSL to connect', - 'JAB_USE_SSL_EXPLAIN' => 'If enabled a secure connection is tried to be established. The Jabber port will be modified to 5223 if port 5222 is specified.', - 'JAB_USERNAME' => 'Jabber username or JID', - 'JAB_USERNAME_EXPLAIN' => 'Specify a registered username or a valid JID. The username will not be checked for validity. If you only specify a username, then your JID will be the username and the server you specified above. Else, specify a valid JID, for example user@jabber.org.', - 'JAB_VERIFY_PEER' => 'Verify SSL certificate', - 'JAB_VERIFY_PEER_EXPLAIN' => 'Require verification of SSL certificate used by Jabber server.
Warning: Connecting peers with unverified SSL certificates may cause security implications.', - 'JAB_VERIFY_PEER_NAME' => 'Verify Jabber peer name', - 'JAB_VERIFY_PEER_NAME_EXPLAIN' => 'Require verification of peer name for Jabber servers using SSL / TLS connections.
Warning: Connecting to unverified peers may cause security implications.', -)); diff --git a/install/update/new/language/en/acp/common.php b/install/update/new/language/en/acp/common.php deleted file mode 100644 index 5ac4b44..0000000 --- a/install/update/new/language/en/acp/common.php +++ /dev/null @@ -1,823 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* DO NOT CHANGE -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -if (empty($lang) || !is_array($lang)) -{ - $lang = array(); -} - -// DEVELOPERS PLEASE NOTE -// -// All language files should use UTF-8 as their encoding and the files must not contain a BOM. -// -// Placeholders can now contain order information, e.g. instead of -// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows -// translators to re-order the output of data while ensuring it remains correct -// -// You do not need this where single placeholders are used, e.g. 'Message %d' is fine -// equally where a string contains only two placeholders which are used to wrap text -// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine - -// Common -$lang = array_merge($lang, array( - 'ACP_ADMINISTRATORS' => 'Administrators', - 'ACP_ADMIN_LOGS' => 'Admin log', - 'ACP_ADMIN_ROLES' => 'Admin roles', - 'ACP_ATTACHMENTS' => 'Attachments', - 'ACP_ATTACHMENT_SETTINGS' => 'Attachment settings', - 'ACP_AUTH_SETTINGS' => 'Authentication', - 'ACP_AUTOMATION' => 'Automation', - 'ACP_AVATAR_SETTINGS' => 'Avatar settings', - - 'ACP_BACKUP' => 'Backup', - 'ACP_BAN' => 'Banning', - 'ACP_BAN_EMAILS' => 'Ban emails', - 'ACP_BAN_IPS' => 'Ban IPs', - 'ACP_BAN_USERNAMES' => 'Ban users', - 'ACP_BBCODES' => 'BBCodes', - 'ACP_BOARD_CONFIGURATION' => 'Board configuration', - 'ACP_BOARD_FEATURES' => 'Board features', - 'ACP_BOARD_MANAGEMENT' => 'Board management', - 'ACP_BOARD_SETTINGS' => 'Board settings', - 'ACP_BOTS' => 'Spiders/Robots', - - 'ACP_CAPTCHA' => 'CAPTCHA', - - 'ACP_CAT_CUSTOMISE' => 'Customise', - 'ACP_CAT_DATABASE' => 'Database', - 'ACP_CAT_DOT_MODS' => 'Extensions', - 'ACP_CAT_FORUMS' => 'Forums', - 'ACP_CAT_GENERAL' => 'General', - 'ACP_CAT_MAINTENANCE' => 'Maintenance', - 'ACP_CAT_PERMISSIONS' => 'Permissions', - 'ACP_CAT_POSTING' => 'Posting', - 'ACP_CAT_STYLES' => 'Styles', - 'ACP_CAT_SYSTEM' => 'System', - 'ACP_CAT_USERGROUP' => 'Users and Groups', - 'ACP_CAT_USERS' => 'Users', - 'ACP_CLIENT_COMMUNICATION' => 'Client communication', - 'ACP_COOKIE_SETTINGS' => 'Cookie settings', - 'ACP_CONTACT' => 'Contact page', - 'ACP_CONTACT_SETTINGS' => 'Contact page settings', - 'ACP_CRITICAL_LOGS' => 'Error log', - 'ACP_CUSTOM_PROFILE_FIELDS' => 'Custom profile fields', - - 'ACP_DATABASE' => 'Database management', - 'ACP_DISALLOW' => 'Disallow', - 'ACP_DISALLOW_USERNAMES' => 'Disallow usernames', - - 'ACP_EMAIL_SETTINGS' => 'Email settings', - 'ACP_EXTENSION_GROUPS' => 'Manage attachment extension groups', - 'ACP_EXTENSION_MANAGEMENT' => 'Extension management', - 'ACP_EXTENSIONS' => 'Manage extensions', - - 'ACP_FORUM_BASED_PERMISSIONS' => 'Forum based permissions', - 'ACP_FORUM_LOGS' => 'Forum logs', - 'ACP_FORUM_MANAGEMENT' => 'Forum management', - 'ACP_FORUM_MODERATORS' => 'Forum moderators', - 'ACP_FORUM_PERMISSIONS' => 'Forum permissions', - 'ACP_FORUM_PERMISSIONS_COPY' => 'Copy forum permissions', - 'ACP_FORUM_ROLES' => 'Forum roles', - - 'ACP_GENERAL_CONFIGURATION' => 'General configuration', - 'ACP_GENERAL_TASKS' => 'General tasks', - 'ACP_GLOBAL_MODERATORS' => 'Global moderators', - 'ACP_GLOBAL_PERMISSIONS' => 'Global permissions', - 'ACP_GROUPS' => 'Groups', - 'ACP_GROUPS_FORUM_PERMISSIONS' => 'Group forum permissions', - 'ACP_GROUPS_MANAGE' => 'Manage groups', - 'ACP_GROUPS_MANAGEMENT' => 'Group management', - 'ACP_GROUPS_PERMISSIONS' => 'Group permissions', - 'ACP_GROUPS_POSITION' => 'Manage group positions', - - 'ACP_HELP_PHPBB' => 'Help support phpBB', - - 'ACP_ICONS' => 'Topic icons', - 'ACP_ICONS_SMILIES' => 'Topic icons/smilies', - 'ACP_INACTIVE_USERS' => 'Inactive users', - 'ACP_INDEX' => 'ACP index', - - 'ACP_JABBER_SETTINGS' => 'Jabber settings', - - 'ACP_LANGUAGE' => 'Language management', - 'ACP_LANGUAGE_PACKS' => 'Language packs', - 'ACP_LOAD_SETTINGS' => 'Load settings', - 'ACP_LOGGING' => 'Logging', - - 'ACP_MAIN' => 'ACP index', - - 'ACP_MANAGE_ATTACHMENTS' => 'Manage attachments', - 'ACP_MANAGE_ATTACHMENTS_EXPLAIN' => 'Here you can list and delete files attached to posts and private messages.', - - 'ACP_MANAGE_EXTENSIONS' => 'Manage attachment extensions', - 'ACP_MANAGE_FORUMS' => 'Manage forums', - 'ACP_MANAGE_RANKS' => 'Manage ranks', - 'ACP_MANAGE_REASONS' => 'Manage report/denial reasons', - 'ACP_MANAGE_USERS' => 'Manage users', - 'ACP_MASS_EMAIL' => 'Mass email', - 'ACP_MESSAGES' => 'Messages', - 'ACP_MESSAGE_SETTINGS' => 'Private message settings', - 'ACP_MODULE_MANAGEMENT' => 'Module management', - 'ACP_MOD_LOGS' => 'Moderator log', - 'ACP_MOD_ROLES' => 'Moderator roles', - - 'ACP_NO_ITEMS' => 'There are no items yet.', - - 'ACP_ORPHAN_ATTACHMENTS' => 'Orphaned attachments', - - 'ACP_PERMISSIONS' => 'Permissions', - 'ACP_PERMISSION_MASKS' => 'Permission masks', - 'ACP_PERMISSION_ROLES' => 'Permission roles', - 'ACP_PERMISSION_TRACE' => 'Permission trace', - 'ACP_PHP_INFO' => 'PHP information', - 'ACP_POST_SETTINGS' => 'Post settings', - 'ACP_PRUNE_FORUMS' => 'Prune forums', - 'ACP_PRUNE_USERS' => 'Prune users', - 'ACP_PRUNING' => 'Pruning', - - 'ACP_QUICK_ACCESS' => 'Quick access', - - 'ACP_RANKS' => 'Ranks', - 'ACP_REASONS' => 'Report/denial reasons', - 'ACP_REGISTER_SETTINGS' => 'User registration settings', - - 'ACP_RESTORE' => 'Restore', - - 'ACP_FEED' => 'Feed management', - 'ACP_FEED_SETTINGS' => 'Feed settings', - - 'ACP_SEARCH' => 'Search configuration', - 'ACP_SEARCH_INDEX' => 'Search index', - 'ACP_SEARCH_SETTINGS' => 'Search settings', - - 'ACP_SECURITY_SETTINGS' => 'Security settings', - 'ACP_SERVER_CONFIGURATION' => 'Server configuration', - 'ACP_SERVER_SETTINGS' => 'Server settings', - 'ACP_SIGNATURE_SETTINGS' => 'Signature settings', - 'ACP_SMILIES' => 'Smilies', - 'ACP_STYLE_MANAGEMENT' => 'Style management', - 'ACP_STYLES' => 'Styles', - 'ACP_STYLES_CACHE' => 'Purge Cache', - 'ACP_STYLES_INSTALL' => 'Install Styles', - - 'ACP_SUBMIT_CHANGES' => 'Submit changes', - - 'ACP_TEMPLATES' => 'Templates', - 'ACP_THEMES' => 'Themes', - - 'ACP_UPDATE' => 'Updating', - 'ACP_USERS_FORUM_PERMISSIONS' => 'User forum permissions', - 'ACP_USERS_LOGS' => 'User logs', - 'ACP_USERS_PERMISSIONS' => 'User permissions', - 'ACP_USER_ATTACH' => 'Attachments', - 'ACP_USER_AVATAR' => 'Avatar', - 'ACP_USER_FEEDBACK' => 'Feedback', - 'ACP_USER_GROUPS' => 'Groups', - 'ACP_USER_MANAGEMENT' => 'User management', - 'ACP_USER_OVERVIEW' => 'Overview', - 'ACP_USER_PERM' => 'Permissions', - 'ACP_USER_PREFS' => 'Preferences', - 'ACP_USER_PROFILE' => 'Profile', - 'ACP_USER_RANK' => 'Rank', - 'ACP_USER_ROLES' => 'User roles', - 'ACP_USER_SECURITY' => 'User security', - 'ACP_USER_SIG' => 'Signature', - 'ACP_USER_WARNINGS' => 'Warnings', - - 'ACP_VC_SETTINGS' => 'Spambot countermeasures', - 'ACP_VC_CAPTCHA_DISPLAY' => 'CAPTCHA image preview', - 'ACP_VERSION_CHECK' => 'Check for updates', - 'ACP_VIEW_ADMIN_PERMISSIONS' => 'View administrative permissions', - 'ACP_VIEW_FORUM_MOD_PERMISSIONS' => 'View forum moderation permissions', - 'ACP_VIEW_FORUM_PERMISSIONS' => 'View forum-based permissions', - 'ACP_VIEW_GLOBAL_MOD_PERMISSIONS' => 'View global moderation permissions', - 'ACP_VIEW_USER_PERMISSIONS' => 'View user-based permissions', - - 'ACP_WORDS' => 'Word censoring', - - 'ACTION' => 'Action', - 'ACTIONS' => 'Actions', - 'ACTIVATE' => 'Activate', - 'ADD' => 'Add', - 'ADMIN' => 'Administration', - 'ADMIN_INDEX' => 'Admin index', - 'ADMIN_PANEL' => 'Administration Control Panel', - - 'ADM_LOGOUT' => 'ACP Logout', - 'ADM_LOGGED_OUT' => 'Successfully logged out from Administration Control Panel', - - 'BACK' => 'Back', - - 'CONTAINER_EXCEPTION' => 'phpBB encountered an error building the container due to an installed extension. For this reason, all extensions have been temporarily disabled. Please try purging your forum cache. All extensions will automatically be re-enabled once the container error is resolved. If this error continues, please visit phpBB.com for support.', - 'EXCEPTION' => 'Exception', - - 'COLOUR_SWATCH' => 'Web-safe colour swatch', - 'CONFIG_UPDATED' => 'Configuration updated successfully.', - 'CRON_LOCK_ERROR' => 'Could not obtain cron lock.', - 'CRON_NO_SUCH_TASK' => 'Could not find cron task “%s”.', - 'CRON_NO_TASK' => 'No cron tasks need to be run right now.', - 'CRON_NO_TASKS' => 'No cron tasks could be found.', - 'CURRENT_VERSION' => 'Current version', - - 'DEACTIVATE' => 'Deactivate', - 'DIRECTORY_DOES_NOT_EXIST' => 'The entered path “%s” does not exist.', - 'DIRECTORY_NOT_DIR' => 'The entered path “%s” is not a directory.', - 'DIRECTORY_NOT_WRITABLE' => 'The entered path “%s” is not writable.', - 'DISABLE' => 'Disable', - 'DOWNLOAD' => 'Download', - 'DOWNLOAD_AS' => 'Download as', - 'DOWNLOAD_STORE' => 'Download or store file', - 'DOWNLOAD_STORE_EXPLAIN' => 'You may directly download the file or save it in your store/ folder.', - 'DOWNLOADS' => 'Downloads', - - 'EDIT' => 'Edit', - 'ENABLE' => 'Enable', - 'EXPORT_DOWNLOAD' => 'Download', - 'EXPORT_STORE' => 'Store', - - 'GENERAL_OPTIONS' => 'General options', - 'GENERAL_SETTINGS' => 'General settings', - 'GLOBAL_MASK' => 'Global permission mask', - - 'INSTALL' => 'Install', - 'IP' => 'User IP', - 'IP_HOSTNAME' => 'IP addresses or hostnames', - - 'LATEST_VERSION' => 'Latest version', - 'LOAD_NOTIFICATIONS' => 'Display Notifications', - 'LOAD_NOTIFICATIONS_EXPLAIN' => 'Display the notifications list on every page (typically in the header).', - 'LOGGED_IN_AS' => 'You are logged in as:', - 'LOGIN_ADMIN' => 'To administer the board you must be an authenticated user.', - 'LOGIN_ADMIN_CONFIRM' => 'To administer the board you must re-authenticate yourself.', - 'LOGIN_ADMIN_SUCCESS' => 'You have successfully authenticated and will now be redirected to the Administration Control Panel.', - 'LOOK_UP_FORUM' => 'Select a forum', - 'LOOK_UP_FORUMS_EXPLAIN'=> 'You are able to select more than one forum.', - - 'MANAGE' => 'Manage', - 'MENU_TOGGLE' => 'Hide or display the side menu', - 'MORE' => 'More', // Not used at the moment - 'MORE_INFORMATION' => 'More information »', - 'MOVE_DOWN' => 'Move down', - 'MOVE_UP' => 'Move up', - - 'NOTIFY' => 'Notification', - 'NO_ADMIN' => 'You are not authorised to administer this board.', - 'NO_EMAILS_DEFINED' => 'No valid email addresses found.', - 'NO_FILES_TO_DELETE' => 'Attachments you selected for deletion do not exist.', - 'NO_PASSWORD_SUPPLIED' => 'You need to enter your password to access the Administration Control Panel.', - - 'OFF' => 'Off', - 'ON' => 'On', - - 'PARSE_BBCODE' => 'Parse BBCode', - 'PARSE_SMILIES' => 'Parse smilies', - 'PARSE_URLS' => 'Parse links', - 'PERMISSIONS_TRANSFERRED' => 'Permissions transferred', - 'PERMISSIONS_TRANSFERRED_EXPLAIN' => 'You currently have the permissions from %1$s. You are able to browse the board with this user’s permissions, but not access the administration control panel since admin permissions were not transferred. You can revert to your permission set at any time.', - 'PROCEED_TO_ACP' => '%sProceed to the ACP%s', - - 'RELEASE_ANNOUNCEMENT' => 'Announcement', - 'REMIND' => 'Remind', - 'REPARSE_LOCK_ERROR' => 'Reparsing is already in progress by another process.', - 'RESYNC' => 'Resynchronise', - - 'RUNNING_TASK' => 'Running task: %s.', - 'SELECT_ANONYMOUS' => 'Select anonymous user', - 'SELECT_OPTION' => 'Select option', - - 'SETTING_TOO_LOW' => 'The provided value for the setting “%1$s” is too low. The minimum acceptable value is %2$d.', - 'SETTING_TOO_BIG' => 'The provided value for the setting “%1$s” is too high. The maximum acceptable value is %2$d.', - 'SETTING_TOO_LONG' => 'The provided value for the setting “%1$s” is too long. The maximum acceptable length is %2$d.', - 'SETTING_TOO_SHORT' => 'The provided value for the setting “%1$s” is too short. The minimum acceptable length is %2$d.', - - 'SHOW_ALL_OPERATIONS' => 'Show all operations', - - 'TASKS_NOT_READY' => 'Not ready tasks:', - 'TASKS_READY' => 'Ready tasks:', - 'TOTAL_SIZE' => 'Total size', - - 'UCP' => 'User Control Panel', - 'URL_INVALID' => 'The provided URL for the setting “%1$s” is invalid.', - 'USERNAMES_EXPLAIN' => 'Place each username on a separate line.', - 'USER_CONTROL_PANEL' => 'User Control Panel', - - 'UPDATE_NEEDED' => 'The board is not up to date.', - 'UPDATE_NOT_NEEDED' => 'The board is up to date.', - 'UPDATES_AVAILABLE' => 'Updates available:', - - 'WARNING' => 'Warning', -)); - -// PHP info -$lang = array_merge($lang, array( - 'ACP_PHP_INFO_EXPLAIN' => 'This page lists information on the version of PHP installed on this server. It includes details of loaded modules, available variables and default settings. This information may be useful when diagnosing problems. Please be aware that some hosting companies will limit what information is displayed here for security reasons. You are advised to not give out any details on this page except when asked by official team members on the support forums.', - - 'NO_PHPINFO_AVAILABLE' => 'Information about your PHP configuration is unable to be determined. Phpinfo() has been disabled for security reasons.', -)); - -// Logs -$lang = array_merge($lang, array( - 'ACP_ADMIN_LOGS_EXPLAIN' => 'This lists all the actions carried out by board administrators. You can sort by username, date, IP or action. If you have appropriate permissions you can also clear individual operations or the log as a whole.', - 'ACP_CRITICAL_LOGS_EXPLAIN' => 'This lists the actions carried out by the board itself. This log provides you with information you are able to use for solving specific problems, for example non-delivery of emails. You can sort by username, date, IP or action. If you have appropriate permissions you can also clear individual operations or the log as a whole.', - 'ACP_MOD_LOGS_EXPLAIN' => 'This lists all actions done on forums, topics and posts as well as actions carried out on users by moderators, including banning. You can sort by username, date, IP or action. If you have appropriate permissions you can also clear individual operations or the log as a whole.', - 'ACP_USERS_LOGS_EXPLAIN' => 'This lists all actions carried out by users or on users (reports, warnings and user notes).', - 'ALL_ENTRIES' => 'All entries', - - 'DISPLAY_LOG' => 'Display entries from previous', - - 'NO_ENTRIES' => 'No log entries for this period.', - - 'SORT_IP' => 'IP address', - 'SORT_DATE' => 'Date', - 'SORT_ACTION' => 'Log action', -)); - -// Index page -$lang = array_merge($lang, array( - 'ADMIN_INTRO' => 'Thank you for choosing phpBB as your board solution. This screen will give you a quick overview of all the various statistics of your board. The links on the left hand side of this screen allow you to control every aspect of your board experience. Each page will have instructions on how to use the tools.', - 'ADMIN_LOG' => 'Logged administrator actions', - 'ADMIN_LOG_INDEX_EXPLAIN' => 'This gives an overview of the last five actions carried out by board administrators. A full copy of the log can be viewed from the appropriate menu item or following the link below.', - 'AVATAR_DIR_SIZE' => 'Avatar directory size', - - 'BOARD_STARTED' => 'Board started', - 'BOARD_VERSION' => 'Board version', - - 'DATABASE_SERVER_INFO' => 'Database server', - 'DATABASE_SIZE' => 'Database size', - - // Environment configuration checks, mbstring related - 'ERROR_MBSTRING_FUNC_OVERLOAD' => 'Function overloading is improperly configured', - 'ERROR_MBSTRING_FUNC_OVERLOAD_EXPLAIN' => 'mbstring.func_overload must be set to either 0 or 4. You can check the current value on the PHP information page.', - 'ERROR_MBSTRING_ENCODING_TRANSLATION' => 'Transparent character encoding is improperly configured', - 'ERROR_MBSTRING_ENCODING_TRANSLATION_EXPLAIN' => 'mbstring.encoding_translation must be set to 0. You can check the current value on the PHP information page.', - 'ERROR_MBSTRING_HTTP_INPUT' => 'HTTP input character conversion is improperly configured', - 'ERROR_MBSTRING_HTTP_INPUT_EXPLAIN' => 'mbstring.http_input must be set to pass. You can check the current value on the PHP information page.', - 'ERROR_MBSTRING_HTTP_OUTPUT' => 'HTTP output character conversion is improperly configured', - 'ERROR_MBSTRING_HTTP_OUTPUT_EXPLAIN' => 'mbstring.http_output must be set to pass. You can check the current value on the PHP information page.', - - 'FILES_PER_DAY' => 'Attachments per day', - 'FORUM_STATS' => 'Board statistics', - - 'GZIP_COMPRESSION' => 'GZip compression', - - 'NO_SEARCH_INDEX' => 'The selected search backend does not have a search index.
Please create the index for “%1$s” in the %2$ssearch index%3$s section.', - 'NOT_AVAILABLE' => 'Not available', - 'NUMBER_FILES' => 'Number of attachments', - 'NUMBER_POSTS' => 'Number of posts', - 'NUMBER_TOPICS' => 'Number of topics', - 'NUMBER_USERS' => 'Number of users', - 'NUMBER_ORPHAN' => 'Orphan attachments', - - 'PHP_VERSION' => 'PHP version', - 'PHP_VERSION_OLD' => 'The version of PHP on this server (%1$s) will no longer be supported by future versions of phpBB. The minimum required version will be PHP %2$s. %3$sDetails%4$s', - - 'POSTS_PER_DAY' => 'Posts per day', - - 'PURGE_CACHE' => 'Purge the cache', - 'PURGE_CACHE_CONFIRM' => 'Are you sure you wish to purge the cache?', - 'PURGE_CACHE_EXPLAIN' => 'Purge all cache related items, this includes any cached template files or queries.', - 'PURGE_CACHE_SUCCESS' => 'Cache successfully purged.', - - 'PURGE_SESSIONS' => 'Purge all sessions', - 'PURGE_SESSIONS_CONFIRM' => 'Are you sure you wish to purge all sessions? This will log out all users.', - 'PURGE_SESSIONS_EXPLAIN' => 'Purge all sessions. This will log out all users by truncating the session table.', - 'PURGE_SESSIONS_SUCCESS' => 'Sessions successfully purged.', - - 'RESET_DATE' => 'Reset board’s start date', - 'RESET_DATE_CONFIRM' => 'Are you sure you wish to reset the board’s start date?', - 'RESET_DATE_SUCCESS' => 'Board’s start date reset', - 'RESET_ONLINE' => 'Reset most users ever online', - 'RESET_ONLINE_CONFIRM' => 'Are you sure you wish to reset the most users ever online counter?', - 'RESET_ONLINE_SUCCESS' => 'Most users ever online reset', - 'RESYNC_POSTCOUNTS' => 'Resynchronise post counts', - 'RESYNC_POSTCOUNTS_EXPLAIN' => 'Only existing posts will be taken into consideration. Pruned posts will not be counted.', - 'RESYNC_POSTCOUNTS_CONFIRM' => 'Are you sure you wish to resynchronise post counts?', - 'RESYNC_POSTCOUNTS_SUCCESS' => 'Resynchronised post counts', - 'RESYNC_POST_MARKING' => 'Resynchronise dotted topics', - 'RESYNC_POST_MARKING_CONFIRM' => 'Are you sure you wish to resynchronise dotted topics?', - 'RESYNC_POST_MARKING_EXPLAIN' => 'First unmarks all topics and then correctly marks topics that have seen any activity during the past six months.', - 'RESYNC_POST_MARKING_SUCCESS' => 'Resynchronised dotted topics', - 'RESYNC_STATS' => 'Resynchronise statistics', - 'RESYNC_STATS_CONFIRM' => 'Are you sure you wish to resynchronise statistics?', - 'RESYNC_STATS_EXPLAIN' => 'Recalculates the total number of posts, topics, users and files.', - 'RESYNC_STATS_SUCCESS' => 'Resynchronised statistics', - 'RUN' => 'Run now', - - 'STATISTIC' => 'Statistic', - 'STATISTIC_RESYNC_OPTIONS' => 'Resynchronise or reset statistics', - - 'TIMEZONE_INVALID' => 'The timezone you selected is invalid.', - 'TIMEZONE_SELECTED' => '(currently selected)', - 'TOPICS_PER_DAY' => 'Topics per day', - - 'UPLOAD_DIR_SIZE' => 'Size of posted attachments', - 'USERS_PER_DAY' => 'Users per day', - - 'VALUE' => 'Value', - 'VERSIONCHECK_FAIL' => 'Failed to obtain latest version information.', - 'VERSIONCHECK_FORCE_UPDATE' => 'Re-Check version', - 'VERSION_CHECK' => 'Version check', - 'VERSION_CHECK_EXPLAIN' => 'Checks to see if your phpBB installation is up to date.', - 'VERSIONCHECK_INVALID_ENTRY' => 'Latest version information contains an unsupported entry.', - 'VERSIONCHECK_INVALID_URL' => 'Latest version information contains invalid URL.', - 'VERSIONCHECK_INVALID_VERSION' => 'Latest version information contains an invalid version.', - 'VERSION_NOT_UP_TO_DATE_ACP' => 'Your phpBB installation is not up to date.
Below is a link to the release announcement, which contains more information as well as instructions on updating.', - 'VERSION_NOT_UP_TO_DATE_TITLE' => 'Your phpBB installation is not up to date.', - 'VERSION_UP_TO_DATE_ACP' => 'Your phpBB installation is up to date. There are no updates available at this time.', - 'VIEW_ADMIN_LOG' => 'View administrator log', - 'VIEW_INACTIVE_USERS' => 'View inactive users', - - 'WELCOME_PHPBB' => 'Welcome to phpBB', - 'WRITABLE_CONFIG' => 'Your config file (config.php) is currently world-writable. We strongly encourage you to change the permissions to 640 or at least to 644 (for example: chmod 640 config.php).', -)); - -// Inactive Users -$lang = array_merge($lang, array( - 'INACTIVE_DATE' => 'Inactive date', - 'INACTIVE_REASON' => 'Reason', - 'INACTIVE_REASON_MANUAL' => 'Account deactivated by administrator', - 'INACTIVE_REASON_PROFILE' => 'Profile details changed', - 'INACTIVE_REASON_REGISTER' => 'Newly registered account', - 'INACTIVE_REASON_REMIND' => 'Forced user account reactivation', - 'INACTIVE_REASON_UNKNOWN' => 'Unknown', - 'INACTIVE_USERS' => 'Inactive users', - 'INACTIVE_USERS_EXPLAIN' => 'This is a list of users who have registered but whose accounts are inactive. You can activate, delete or remind (by sending an email) these users if you wish.', - 'INACTIVE_USERS_EXPLAIN_INDEX' => 'This is a list of the last 10 registered users who have inactive accounts. Accounts are inactive either because account activation was enabled in user registration settings and these users’ accounts have not yet been activated, or because these accounts have been deactivated. A full list is available by following the link below from where you can activate, delete or remind (by sending an email) these users if you wish.', - - 'NO_INACTIVE_USERS' => 'No inactive users', - - 'SORT_INACTIVE' => 'Inactive date', - 'SORT_LAST_VISIT' => 'Last visit', - 'SORT_REASON' => 'Reason', - 'SORT_REG_DATE' => 'Registration date', - 'SORT_LAST_REMINDER'=> 'Last reminded', - 'SORT_REMINDER' => 'Reminder sent', - - 'USER_IS_INACTIVE' => 'User is inactive', -)); - -// Help support phpBB page -$lang = array_merge($lang, array( - 'EXPLAIN_SEND_STATISTICS' => 'Please send information about your server and board configurations to phpBB for statistical analysis. All information that could identify you or your website has been removed - the data is entirely anonymous. We base decisions about future phpBB versions on this information. The statistics are made available publically. We also share this data with the PHP project, the programming language phpBB is made with.', - 'EXPLAIN_SHOW_STATISTICS' => 'Using the button below you can preview all variables that will be transmitted.', - 'DONT_SEND_STATISTICS' => 'Return to the ACP if you do not wish to send statistical information to phpBB.', - 'GO_ACP_MAIN' => 'Go to the ACP start page', - 'HIDE_STATISTICS' => 'Hide details', - 'SEND_STATISTICS' => 'Send statistics', - 'SEND_STATISTICS_LONG' => 'Send statistical information', - 'SHOW_STATISTICS' => 'Show details', - 'THANKS_SEND_STATISTICS' => 'Thank you for submitting your information.', - 'FAIL_SEND_STATISTICS' => 'phpBB was unable to send statistics', -)); - -// Log Entries -$lang = array_merge($lang, array( - 'LOG_ACL_ADD_USER_GLOBAL_U_' => 'Added or edited users’ user permissions
» %s', - 'LOG_ACL_ADD_GROUP_GLOBAL_U_' => 'Added or edited groups’ user permissions
» %s', - 'LOG_ACL_ADD_USER_GLOBAL_M_' => 'Added or edited users’ global moderator permissions
» %s', - 'LOG_ACL_ADD_GROUP_GLOBAL_M_' => 'Added or edited groups’ global moderator permissions
» %s', - 'LOG_ACL_ADD_USER_GLOBAL_A_' => 'Added or edited users’ administrator permissions
» %s', - 'LOG_ACL_ADD_GROUP_GLOBAL_A_' => 'Added or edited groups’ administrator permissions
» %s', - - 'LOG_ACL_ADD_ADMIN_GLOBAL_A_' => 'Added or edited Administrators
» %s', - 'LOG_ACL_ADD_MOD_GLOBAL_M_' => 'Added or edited Global Moderators
» %s', - - 'LOG_ACL_ADD_USER_LOCAL_F_' => 'Added or edited users’ forum access from %1$s
» %2$s', - 'LOG_ACL_ADD_USER_LOCAL_M_' => 'Added or edited users’ forum moderator access from %1$s
» %2$s', - 'LOG_ACL_ADD_GROUP_LOCAL_F_' => 'Added or edited groups’ forum access from %1$s
» %2$s', - 'LOG_ACL_ADD_GROUP_LOCAL_M_' => 'Added or edited groups’ forum moderator access from %1$s
» %2$s', - - 'LOG_ACL_ADD_MOD_LOCAL_M_' => 'Added or edited Moderators from %1$s
» %2$s', - 'LOG_ACL_ADD_FORUM_LOCAL_F_' => 'Added or edited forum permissions from %1$s
» %2$s', - - 'LOG_ACL_DEL_ADMIN_GLOBAL_A_' => 'Removed Administrators
» %s', - 'LOG_ACL_DEL_MOD_GLOBAL_M_' => 'Removed Global Moderators
» %s', - 'LOG_ACL_DEL_MOD_LOCAL_M_' => 'Removed Moderators from %1$s
» %2$s', - 'LOG_ACL_DEL_FORUM_LOCAL_F_' => 'Removed User/Group forum permissions from %1$s
» %2$s', - - 'LOG_ACL_TRANSFER_PERMISSIONS' => 'Permissions transferred from
» %s', - 'LOG_ACL_RESTORE_PERMISSIONS' => 'Own permissions restored after using permissions from
» %s', - - 'LOG_ADMIN_AUTH_FAIL' => 'Failed administration login attempt', - 'LOG_ADMIN_AUTH_SUCCESS' => 'Successful administration login', - - 'LOG_ATTACHMENTS_DELETED' => 'Removed user attachments
» %s', - - 'LOG_ATTACH_EXT_ADD' => 'Added or edited attachment extension
» %s', - 'LOG_ATTACH_EXT_DEL' => 'Removed attachment extension
» %s', - 'LOG_ATTACH_EXT_UPDATE' => 'Updated attachment extension
» %s', - 'LOG_ATTACH_EXTGROUP_ADD' => 'Added extension group
» %s', - 'LOG_ATTACH_EXTGROUP_EDIT' => 'Edited extension group
» %s', - 'LOG_ATTACH_EXTGROUP_DEL' => 'Removed extension group
» %s', - 'LOG_ATTACH_FILEUPLOAD' => 'Orphan File uploaded to Post
» ID %1$d - %2$s', - 'LOG_ATTACH_ORPHAN_DEL' => 'Orphan Files deleted
» %s', - - 'LOG_BAN_EXCLUDE_USER' => 'Excluded user from ban for reason “%1$s
» %2$s', - 'LOG_BAN_EXCLUDE_IP' => 'Excluded IP from ban for reason “%1$s
» %2$s', - 'LOG_BAN_EXCLUDE_EMAIL' => 'Excluded email from ban for reason “%1$s
» %2$s', - 'LOG_BAN_USER' => 'Banned user for reason “%1$s
» %2$s', - 'LOG_BAN_IP' => 'Banned IP for reason “%1$s
» %2$s', - 'LOG_BAN_EMAIL' => 'Banned email for reason “%1$s
» %2$s', - 'LOG_UNBAN_USER' => 'Unbanned user
» %s', - 'LOG_UNBAN_IP' => 'Unbanned IP
» %s', - 'LOG_UNBAN_EMAIL' => 'Unbanned email
» %s', - - 'LOG_BBCODE_ADD' => 'Added new BBCode
» %s', - 'LOG_BBCODE_EDIT' => 'Edited BBCode
» %s', - 'LOG_BBCODE_DELETE' => 'Deleted BBCode
» %s', - 'LOG_BBCODE_CONFIGURATION_ERROR' => 'Error while configuring BBCode: %1$s
» %2$s', - - 'LOG_BOT_ADDED' => 'New bot added
» %s', - 'LOG_BOT_DELETE' => 'Deleted bot
» %s', - 'LOG_BOT_UPDATED' => 'Existing bot updated
» %s', - - 'LOG_CLEAR_ADMIN' => 'Cleared admin log', - 'LOG_CLEAR_CRITICAL' => 'Cleared error log', - 'LOG_CLEAR_MOD' => 'Cleared moderator log', - 'LOG_CLEAR_USER' => 'Cleared user log
» %s', - 'LOG_CLEAR_USERS' => 'Cleared user logs', - - 'LOG_CONFIG_ATTACH' => 'Altered attachment settings', - 'LOG_CONFIG_AUTH' => 'Altered authentication settings', - 'LOG_CONFIG_AVATAR' => 'Altered avatar settings', - 'LOG_CONFIG_COOKIE' => 'Altered cookie settings', - 'LOG_CONFIG_EMAIL' => 'Altered email settings', - 'LOG_CONFIG_FEATURES' => 'Altered board features', - 'LOG_CONFIG_LOAD' => 'Altered load settings', - 'LOG_CONFIG_MESSAGE' => 'Altered private message settings', - 'LOG_CONFIG_POST' => 'Altered post settings', - 'LOG_CONFIG_REGISTRATION' => 'Altered user registration settings', - 'LOG_CONFIG_FEED' => 'Altered syndication feeds settings', - 'LOG_CONFIG_SEARCH' => 'Altered search settings', - 'LOG_CONFIG_SECURITY' => 'Altered security settings', - 'LOG_CONFIG_SERVER' => 'Altered server settings', - 'LOG_CONFIG_SETTINGS' => 'Altered board settings', - 'LOG_CONFIG_SIGNATURE' => 'Altered signature settings', - 'LOG_CONFIG_VISUAL' => 'Altered anti-spambot settings', - - 'LOG_APPROVE_TOPIC' => 'Approved topic
» %s', - 'LOG_BUMP_TOPIC' => 'User bumped topic
» %s', - 'LOG_DELETE_POST' => 'Deleted post “%1$s” written by “%2$s” for the following reason
» %3$s', - 'LOG_DELETE_SHADOW_TOPIC' => 'Deleted shadow topic
» %s', - 'LOG_DELETE_TOPIC' => 'Deleted topic “%1$s” written by “%2$s” for the following reason
» %3$s', - 'LOG_FORK' => 'Copied topic
» from %s', - 'LOG_LOCK' => 'Locked topic
» %s', - 'LOG_LOCK_POST' => 'Locked post
» %s', - 'LOG_MERGE' => 'Merged posts into topic
» %s', - 'LOG_MOVE' => 'Moved topic
» from %1$s to %2$s', - 'LOG_MOVED_TOPIC' => 'Moved topic
» %s', - 'LOG_PM_REPORT_CLOSED' => 'Closed PM report
» %s', - 'LOG_PM_REPORT_DELETED' => 'Deleted PM report
» %s', - 'LOG_POST_APPROVED' => 'Approved post
» %s', - 'LOG_POST_DISAPPROVED' => 'Disapproved post “%1$s” written by “%3$s” for the following reason
» %2$s', - 'LOG_POST_EDITED' => 'Edited post “%1$s” written by “%2$s” for the following reason
» %3$s', - 'LOG_POST_RESTORED' => 'Restored post
» %s', - 'LOG_REPORT_CLOSED' => 'Closed report
» %s', - 'LOG_REPORT_DELETED' => 'Deleted report
» %s', - 'LOG_RESTORE_TOPIC' => 'Restored topic “%1$s” written by
» %2$s', - 'LOG_SOFTDELETE_POST' => 'Soft deleted post “%1$s” written by “%2$s” for the following reason
» %3$s', - 'LOG_SOFTDELETE_TOPIC' => 'Soft deleted topic “%1$s” written by “%2$s” for the following reason
» %3$s', - 'LOG_SPLIT_DESTINATION' => 'Moved split posts
» to %s', - 'LOG_SPLIT_SOURCE' => 'Split posts
» from %s', - - 'LOG_TOPIC_APPROVED' => 'Approved topic
» %s', - 'LOG_TOPIC_RESTORED' => 'Restored topic
» %s', - 'LOG_TOPIC_DISAPPROVED' => 'Disapproved topic “%1$s” written by “%3$s” for the following reason
» %2$s', - 'LOG_TOPIC_RESYNC' => 'Resynchronised topic counters
» %s', - 'LOG_TOPIC_TYPE_CHANGED' => 'Changed topic type
» %s', - 'LOG_UNLOCK' => 'Unlocked topic
» %s', - 'LOG_UNLOCK_POST' => 'Unlocked post
» %s', - - 'LOG_DISALLOW_ADD' => 'Added disallowed username
» %s', - 'LOG_DISALLOW_DELETE' => 'Deleted disallowed username', - - 'LOG_DB_BACKUP' => 'Database backup', - 'LOG_DB_DELETE' => 'Deleted database backup', - 'LOG_DB_RESTORE' => 'Restored database backup', - - 'LOG_DOWNLOAD_EXCLUDE_IP' => 'Excluded IP/hostname from download list
» %s', - 'LOG_DOWNLOAD_IP' => 'Added IP/hostname to download list
» %s', - 'LOG_DOWNLOAD_REMOVE_IP' => 'Removed IP/hostname from download list
» %s', - - 'LOG_ERROR_JABBER' => 'Jabber error
» %s', - 'LOG_ERROR_EMAIL' => 'Email error
» %s', - 'LOG_ERROR_CAPTCHA' => 'CAPTCHA error
» %s', - - 'LOG_FORUM_ADD' => 'Created new forum
» %s', - 'LOG_FORUM_COPIED_PERMISSIONS' => 'Copied forum permissions from %1$s
» %2$s', - 'LOG_FORUM_DEL_FORUM' => 'Deleted forum
» %s', - 'LOG_FORUM_DEL_FORUMS' => 'Deleted forum and its subforums
» %s', - 'LOG_FORUM_DEL_MOVE_FORUMS' => 'Deleted forum and moved subforums to %1$s
» %2$s', - 'LOG_FORUM_DEL_MOVE_POSTS' => 'Deleted forum and moved posts to %1$s
» %2$s', - 'LOG_FORUM_DEL_MOVE_POSTS_FORUMS' => 'Deleted forum and its subforums, moved posts to %1$s
» %2$s', - 'LOG_FORUM_DEL_MOVE_POSTS_MOVE_FORUMS' => 'Deleted forum, moved posts to %1$s and subforums to %2$s
» %3$s', - 'LOG_FORUM_DEL_POSTS' => 'Deleted forum and its posts
» %s', - 'LOG_FORUM_DEL_POSTS_FORUMS' => 'Deleted forum, its posts and subforums
» %s', - 'LOG_FORUM_DEL_POSTS_MOVE_FORUMS' => 'Deleted forum and its posts, moved subforums to %1$s
» %2$s', - 'LOG_FORUM_EDIT' => 'Edited forum details
» %s', - 'LOG_FORUM_MOVE_DOWN' => 'Moved forum %1$s below %2$s', - 'LOG_FORUM_MOVE_UP' => 'Moved forum %1$s above %2$s', - 'LOG_FORUM_SYNC' => 'Re-synchronised forum
» %s', - - 'LOG_GENERAL_ERROR' => 'A general error occurred: %1$s
» %2$s', - - 'LOG_GROUP_CREATED' => 'New usergroup created
» %s', - 'LOG_GROUP_DEFAULTS' => 'Group “%1$s” made default for members
» %2$s', - 'LOG_GROUP_DELETE' => 'Usergroup deleted
» %s', - 'LOG_GROUP_DEMOTED' => 'Leaders demoted in usergroup %1$s
» %2$s', - 'LOG_GROUP_PROMOTED' => 'Members promoted to leader in usergroup %1$s
» %2$s', - 'LOG_GROUP_REMOVE' => 'Members removed from usergroup %1$s
» %2$s', - 'LOG_GROUP_UPDATED' => 'Usergroup details updated
» %s', - 'LOG_MODS_ADDED' => 'Added new leaders to usergroup %1$s
» %2$s', - 'LOG_USERS_ADDED' => 'Added new members to usergroup %1$s
» %2$s', - 'LOG_USERS_APPROVED' => 'Users approved in usergroup %1$s
» %2$s', - 'LOG_USERS_PENDING' => 'Users requested to join group “%1$s” and need to be approved
» %2$s', - - 'LOG_IMAGE_GENERATION_ERROR' => 'Error while creating image
» Error in %1$s on line %2$s: %3$s', - - 'LOG_INACTIVE_ACTIVATE' => 'Activated inactive users
» %s', - 'LOG_INACTIVE_DELETE' => 'Deleted inactive users
» %s', - 'LOG_INACTIVE_REMIND' => 'Sent reminder emails to inactive users
» %s', - 'LOG_INSTALL_CONVERTED' => 'Converted from %1$s to phpBB %2$s', - 'LOG_INSTALL_INSTALLED' => 'Installed phpBB %s', - - 'LOG_IP_BROWSER_FORWARDED_CHECK' => 'Session IP/browser/X_FORWARDED_FOR check failed
»User IP “%1$s” checked against session IP “%2$s”, user browser string “%3$s” checked against session browser string “%4$s” and user X_FORWARDED_FOR string “%5$s” checked against session X_FORWARDED_FOR string “%6$s”.', - - 'LOG_JAB_CHANGED' => 'Jabber account changed', - 'LOG_JAB_PASSCHG' => 'Jabber password changed', - 'LOG_JAB_REGISTER' => 'Jabber account registered', - 'LOG_JAB_SETTINGS_CHANGED' => 'Jabber settings changed', - - 'LOG_LANGUAGE_PACK_DELETED' => 'Deleted language pack
» %s', - 'LOG_LANGUAGE_PACK_INSTALLED' => 'Installed language pack
» %s', - 'LOG_LANGUAGE_PACK_UPDATED' => 'Updated language pack details
» %s', - 'LOG_LANGUAGE_FILE_REPLACED' => 'Replaced language file
» %s', - 'LOG_LANGUAGE_FILE_SUBMITTED' => 'Submitted language file and placed in store folder
» %s', - - 'LOG_MASS_EMAIL' => 'Sent mass email
» %s', - - 'LOG_MCP_CHANGE_POSTER' => 'Changed poster in topic “%1$s”
» from %2$s to %3$s', - - 'LOG_MODULE_DISABLE' => 'Module disabled
» %s', - 'LOG_MODULE_ENABLE' => 'Module enabled
» %s', - 'LOG_MODULE_MOVE_DOWN' => 'Module moved down
» %1$s below %2$s', - 'LOG_MODULE_MOVE_UP' => 'Module moved up
» %1$s above %2$s', - 'LOG_MODULE_REMOVED' => 'Module removed
» %s', - 'LOG_MODULE_ADD' => 'Module added
» %s', - 'LOG_MODULE_EDIT' => 'Module edited
» %s', - - 'LOG_A_ROLE_ADD' => 'Admin role added
» %s', - 'LOG_A_ROLE_EDIT' => 'Admin role edited
» %s', - 'LOG_A_ROLE_REMOVED' => 'Admin role removed
» %s', - 'LOG_F_ROLE_ADD' => 'Forum role added
» %s', - 'LOG_F_ROLE_EDIT' => 'Forum role edited
» %s', - 'LOG_F_ROLE_REMOVED' => 'Forum role removed
» %s', - 'LOG_M_ROLE_ADD' => 'Moderator role added
» %s', - 'LOG_M_ROLE_EDIT' => 'Moderator role edited
» %s', - 'LOG_M_ROLE_REMOVED' => 'Moderator role removed
» %s', - 'LOG_U_ROLE_ADD' => 'User role added
» %s', - 'LOG_U_ROLE_EDIT' => 'User role edited
» %s', - 'LOG_U_ROLE_REMOVED' => 'User role removed
» %s', - - 'LOG_PLUPLOAD_TIDY_FAILED' => 'Unable to open %1$s for tidying, check permissions.
Exception: %2$s
Trace: %3$s', - - 'LOG_PROFILE_FIELD_ACTIVATE' => 'Profile field activated
» %s', - 'LOG_PROFILE_FIELD_CREATE' => 'Profile field added
» %s', - 'LOG_PROFILE_FIELD_DEACTIVATE' => 'Profile field deactivated
» %s', - 'LOG_PROFILE_FIELD_EDIT' => 'Profile field changed
» %s', - 'LOG_PROFILE_FIELD_REMOVED' => 'Profile field removed
» %s', - - 'LOG_PRUNE' => 'Pruned forums
» %s', - 'LOG_AUTO_PRUNE' => 'Auto-pruned forums
» %s', - 'LOG_PRUNE_SHADOW' => 'Auto-pruned shadow topics
» %s', - 'LOG_PRUNE_USER_DEAC' => 'Users deactivated
» %s', - 'LOG_PRUNE_USER_DEL_DEL' => 'Users pruned and posts deleted
» %s', - 'LOG_PRUNE_USER_DEL_ANON' => 'Users pruned and posts retained
» %s', - - 'LOG_PURGE_CACHE' => 'Purged cache', - 'LOG_PURGE_SESSIONS' => 'Purged sessions', - - 'LOG_RANK_ADDED' => 'Added new rank
» %s', - 'LOG_RANK_REMOVED' => 'Removed rank
» %s', - 'LOG_RANK_UPDATED' => 'Updated rank
» %s', - - 'LOG_REASON_ADDED' => 'Added report/denial reason
» %s', - 'LOG_REASON_REMOVED' => 'Removed report/denial reason
» %s', - 'LOG_REASON_UPDATED' => 'Updated report/denial reason
» %s', - - 'LOG_REFERER_INVALID' => 'Referrer validation failed
»Referrer was “%1$s”. The request was rejected and the session killed.', - 'LOG_RESET_DATE' => 'Board start date reset', - 'LOG_RESET_ONLINE' => 'Most users online reset', - 'LOG_RESYNC_FILES_STATS' => 'File statistics resynchronised', - 'LOG_RESYNC_POSTCOUNTS' => 'User post counts resynchronised', - 'LOG_RESYNC_POST_MARKING' => 'Dotted topics resynchronised', - 'LOG_RESYNC_STATS' => 'Post, topic and user statistics resynchronised', - - 'LOG_SEARCH_INDEX_CREATED' => 'Created search index for
» %s', - 'LOG_SEARCH_INDEX_REMOVED' => 'Removed search index for
» %s', - 'LOG_SPHINX_ERROR' => 'Sphinx Error
» %s', - 'LOG_STYLE_ADD' => 'Added new style
» %s', - 'LOG_STYLE_DELETE' => 'Deleted style
» %s', - 'LOG_STYLE_EDIT_DETAILS' => 'Edited style
» %s', - 'LOG_STYLE_EXPORT' => 'Exported style
» %s', - - // @deprecated 3.1 - 'LOG_TEMPLATE_ADD_DB' => 'Added new template set to database
» %s', - // @deprecated 3.1 - 'LOG_TEMPLATE_ADD_FS' => 'Add new template set on filesystem
» %s', - 'LOG_TEMPLATE_CACHE_CLEARED' => 'Deleted cached versions of template files in template set %1$s
» %2$s', - 'LOG_TEMPLATE_DELETE' => 'Deleted template set
» %s', - 'LOG_TEMPLATE_EDIT' => 'Edited template set %1$s
» %2$s', - 'LOG_TEMPLATE_EDIT_DETAILS' => 'Edited template details
» %s', - 'LOG_TEMPLATE_EXPORT' => 'Exported template set
» %s', - // @deprecated 3.1 - 'LOG_TEMPLATE_REFRESHED' => 'Refreshed template set
» %s', - - // @deprecated 3.1 - 'LOG_THEME_ADD_DB' => 'Added new theme to database
» %s', - // @deprecated 3.1 - 'LOG_THEME_ADD_FS' => 'Add new theme on filesystem
» %s', - 'LOG_THEME_DELETE' => 'Theme deleted
» %s', - 'LOG_THEME_EDIT_DETAILS' => 'Edited theme details
» %s', - 'LOG_THEME_EDIT' => 'Edited theme %1$s', - 'LOG_THEME_EDIT_FILE' => 'Edited theme %1$s
» Modified file %2$s', - 'LOG_THEME_EXPORT' => 'Exported theme
» %s', - // @deprecated 3.1 - 'LOG_THEME_REFRESHED' => 'Refreshed theme
» %s', - - 'LOG_UPDATE_DATABASE' => 'Updated Database from version %1$s to version %2$s', - 'LOG_UPDATE_PHPBB' => 'Updated phpBB from version %1$s to version %2$s', - - 'LOG_USER_ACTIVE' => 'User activated
» %s', - 'LOG_USER_BAN_USER' => 'Banned User via user management for reason “%1$s
» %2$s', - 'LOG_USER_BAN_IP' => 'Banned IP via user management for reason “%1$s
» %2$s', - 'LOG_USER_BAN_EMAIL' => 'Banned email via user management for reason “%1$s
» %2$s', - 'LOG_USER_DELETED' => 'Deleted user
» %s', - 'LOG_USER_DEL_ATTACH' => 'Removed all attachments made by the user
» %s', - 'LOG_USER_DEL_AVATAR' => 'Removed user avatar
» %s', - 'LOG_USER_DEL_OUTBOX' => 'Emptied user outbox
» %s', - 'LOG_USER_DEL_POSTS' => 'Removed all posts made by the user
» %s', - 'LOG_USER_DEL_SIG' => 'Removed user signature
» %s', - 'LOG_USER_INACTIVE' => 'User deactivated
» %s', - 'LOG_USER_MOVE_POSTS' => 'Moved user posts
» posts by “%1$s” to forum “%2$s”', - 'LOG_USER_NEW_PASSWORD' => 'Changed user password
» %s', - 'LOG_USER_REACTIVATE' => 'Forced user account reactivation
» %s', - 'LOG_USER_REMOVED_NR' => 'Removed newly registered flag from user
» %s', - - 'LOG_USER_UPDATE_EMAIL' => 'User “%1$s” changed email
» from “%2$s” to “%3$s”', - 'LOG_USER_UPDATE_NAME' => 'Changed username
» from “%1$s” to “%2$s”', - 'LOG_USER_USER_UPDATE' => 'Updated user details
» %s', - - 'LOG_USER_ACTIVE_USER' => 'User account activated', - 'LOG_USER_DEL_AVATAR_USER' => 'User avatar removed', - 'LOG_USER_DEL_SIG_USER' => 'User signature removed', - 'LOG_USER_FEEDBACK' => 'Added user feedback
» %s', - 'LOG_USER_GENERAL' => 'Entry added:
» %s', - 'LOG_USER_INACTIVE_USER' => 'User account de-activated', - 'LOG_USER_LOCK' => 'User locked own topic
» %s', - 'LOG_USER_MOVE_POSTS_USER' => 'Moved all posts to forum» %s', - 'LOG_USER_REACTIVATE_USER' => 'Forced user account reactivation', - 'LOG_USER_UNLOCK' => 'User unlocked own topic
» %s', - 'LOG_USER_WARNING' => 'Added user warning
» %s', - 'LOG_USER_WARNING_BODY' => 'The following warning was issued to this user
» %s', - - 'LOG_USER_GROUP_CHANGE' => 'User changed default group
» %s', - 'LOG_USER_GROUP_DEMOTE' => 'User demoted as leaders from usergroup
» %s', - 'LOG_USER_GROUP_JOIN' => 'User joined group
» %s', - 'LOG_USER_GROUP_JOIN_PENDING' => 'User joined group and needs to be approved
» %s', - 'LOG_USER_GROUP_RESIGN' => 'User resigned membership from group
» %s', - - 'LOG_WARNING_DELETED' => 'Deleted user warning
» %s', - 'LOG_WARNINGS_DELETED' => array( - 1 => 'Deleted user warning
» %1$s', - 2 => 'Deleted %2$d user warnings
» %1$s', // Example: 'Deleted 2 user warnings
» username' - ), - 'LOG_WARNINGS_DELETED_ALL' => 'Deleted all user warnings
» %s', - - 'LOG_WORD_ADD' => 'Added word censor
» %s', - 'LOG_WORD_DELETE' => 'Deleted word censor
» %s', - 'LOG_WORD_EDIT' => 'Edited word censor
» %s', - - 'LOG_EXT_ENABLE' => 'Extension enabled
» %s', - 'LOG_EXT_DISABLE' => 'Extension disabled
» %s', - 'LOG_EXT_PURGE' => 'Extension’s data deleted
» %s', - 'LOG_EXT_UPDATE' => 'Extension updated
» %s', -)); diff --git a/install/update/new/language/en/acp/forums.php b/install/update/new/language/en/acp/forums.php deleted file mode 100644 index 3ab1523..0000000 --- a/install/update/new/language/en/acp/forums.php +++ /dev/null @@ -1,168 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* DO NOT CHANGE -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -if (empty($lang) || !is_array($lang)) -{ - $lang = array(); -} - -// DEVELOPERS PLEASE NOTE -// -// All language files should use UTF-8 as their encoding and the files must not contain a BOM. -// -// Placeholders can now contain order information, e.g. instead of -// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows -// translators to re-order the output of data while ensuring it remains correct -// -// You do not need this where single placeholders are used, e.g. 'Message %d' is fine -// equally where a string contains only two placeholders which are used to wrap text -// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine - -// Forum Admin -$lang = array_merge($lang, array( - 'AUTO_PRUNE_DAYS' => 'Auto-prune post age', - 'AUTO_PRUNE_DAYS_EXPLAIN' => 'Number of days since last post after which topic is removed.', - 'AUTO_PRUNE_FREQ' => 'Auto-prune frequency', - 'AUTO_PRUNE_FREQ_EXPLAIN' => 'Time in days between pruning events.', - 'AUTO_PRUNE_VIEWED' => 'Auto-prune post viewed age', - 'AUTO_PRUNE_VIEWED_EXPLAIN' => 'Number of days since topic was viewed after which topic is removed.', - 'AUTO_PRUNE_SHADOW_FREQ' => 'Auto-prune shadow topics frequency', - 'AUTO_PRUNE_SHADOW_DAYS' => 'Auto-prune shadow topics age', - 'AUTO_PRUNE_SHADOW_DAYS_EXPLAIN' => 'Number of days after which shadow topic is removed.', - 'AUTO_PRUNE_SHADOW_FREQ_EXPLAIN' => 'Time in days between pruning events.', - - 'CONTINUE' => 'Continue', - 'COPY_PERMISSIONS' => 'Copy permissions from', - 'COPY_PERMISSIONS_EXPLAIN' => 'To ease up the permission setup for your new forum, you can copy the permissions of an existing forum.', - 'COPY_PERMISSIONS_ADD_EXPLAIN' => 'Once created, the forum will have the same permissions as the one you select here. If no forum is selected the newly created forum will not be visible until permissions had been set.', - 'COPY_PERMISSIONS_EDIT_EXPLAIN' => 'If you select to copy permissions, the forum will have the same permissions as the one you select here. This will overwrite any permissions you have previously set for this forum with the permissions of the forum you select here. If no forum is selected the current permissions will be kept.', - 'COPY_TO_ACL' => 'Alternatively, you are also able to %sset up new permissions%s for this forum.', - 'CREATE_FORUM' => 'Create new forum', - - 'DECIDE_MOVE_DELETE_CONTENT' => 'Delete content or move to forum', - 'DECIDE_MOVE_DELETE_SUBFORUMS' => 'Delete subforums or move to forum', - 'DEFAULT_STYLE' => 'Default style', - 'DELETE_ALL_POSTS' => 'Delete posts', - 'DELETE_SUBFORUMS' => 'Delete subforums and posts', - 'DISPLAY_ACTIVE_TOPICS' => 'Enable active topics', - 'DISPLAY_ACTIVE_TOPICS_EXPLAIN' => 'If set to yes active topics in selected subforums will be displayed under this category.', - - 'EDIT_FORUM' => 'Edit forum', - 'ENABLE_INDEXING' => 'Enable search indexing', - 'ENABLE_INDEXING_EXPLAIN' => 'If set to yes posts made to this forum will be indexed for searching.', - 'ENABLE_POST_REVIEW' => 'Enable post review', - 'ENABLE_POST_REVIEW_EXPLAIN' => 'If set to yes users are able to review their post if new posts were made to the topic while users wrote theirs. This should be disabled for chat forums.', - 'ENABLE_QUICK_REPLY' => 'Enable quick reply', - 'ENABLE_QUICK_REPLY_EXPLAIN' => 'Enables the quick reply in this forum. This setting is not considered if the quick reply is disabled board wide. The quick reply will only be displayed for users who have permission to post in this forum.', - 'ENABLE_RECENT' => 'Display active topics', - 'ENABLE_RECENT_EXPLAIN' => 'If set to yes topics made to this forum will be shown in the active topics list.', - 'ENABLE_TOPIC_ICONS' => 'Enable topic icons', - - 'FORUM_ADMIN' => 'Forum administration', - 'FORUM_ADMIN_EXPLAIN' => 'In phpBB3 everything is forum based. A category is just a special type of forum. Each forum can have an unlimited number of sub-forums and you can determine whether each may be posted to or not (i.e. whether it acts like an old category). Here you can add, edit, delete, lock, unlock individual forums as well as set certain additional controls. If your posts and topics have got out of sync you can also resynchronise a forum. You need to copy or set appropriate permissions for newly created forums to have them displayed.', - 'FORUM_AUTO_PRUNE' => 'Enable auto-pruning', - 'FORUM_AUTO_PRUNE_EXPLAIN' => 'Prunes the forum of topics, set the frequency/age parameters below.', - 'FORUM_CREATED' => 'Forum created successfully.', - 'FORUM_DATA_NEGATIVE' => 'Pruning parameters cannot be negative.', - 'FORUM_DESC_TOO_LONG' => 'The forum description is too long, it must be less than 4000 characters.', - 'FORUM_DELETE' => 'Delete forum', - 'FORUM_DELETE_EXPLAIN' => 'The form below will allow you to delete a forum. If the forum is postable you are able to decide where you want to put all topics (or forums) it contained.', - 'FORUM_DELETED' => 'Forum successfully deleted.', - 'FORUM_DESC' => 'Description', - 'FORUM_DESC_EXPLAIN' => 'Any HTML markup entered here will be displayed as is. If the selected forum type is a category the description is not used.', - 'FORUM_EDIT_EXPLAIN' => 'The form below will allow you to customise this forum. Please note that moderation and post count controls are set via forum permissions for each user or usergroup.', - 'FORUM_IMAGE' => 'Forum image', - 'FORUM_IMAGE_EXPLAIN' => 'Location, relative to the phpBB root directory, of an additional image to associate with this forum.', - 'FORUM_IMAGE_NO_EXIST' => 'The specified forum image does not exist', - 'FORUM_LINK_EXPLAIN' => 'Full URL (including the protocol, i.e.: http://) to the destination location that clicking this forum will take the user, e.g.: http://www.phpbb.com/.', - 'FORUM_LINK_TRACK' => 'Track link redirects', - 'FORUM_LINK_TRACK_EXPLAIN' => 'Records the number of times a forum link was clicked.', - 'FORUM_NAME' => 'Forum name', - 'FORUM_NAME_EMPTY' => 'You must enter a name for this forum.', - 'FORUM_NAME_EMOJI' => 'The forum name you entered is invalid.
It contains the following unsupported characters:
%s', - 'FORUM_PARENT' => 'Parent forum', - 'FORUM_PASSWORD' => 'Forum password', - 'FORUM_PASSWORD_CONFIRM' => 'Confirm forum password', - 'FORUM_PASSWORD_CONFIRM_EXPLAIN' => 'Only needs to be set if a forum password is entered.', - 'FORUM_PASSWORD_EXPLAIN' => 'Defines a password for this forum, use the permission system in preference.', - 'FORUM_PASSWORD_UNSET' => 'Remove forum password', - 'FORUM_PASSWORD_UNSET_EXPLAIN' => 'Check here if you want to remove the forum password.', - 'FORUM_PASSWORD_OLD' => 'The forum password is using an old hashing method and should be changed.', - 'FORUM_PASSWORD_MISMATCH' => 'The passwords you entered did not match.', - 'FORUM_PRUNE_SETTINGS' => 'Forum prune settings', - 'FORUM_PRUNE_SHADOW' => 'Enable auto-pruning of shadow topics', - 'FORUM_PRUNE_SHADOW_EXPLAIN' => 'Prunes the forum of shadow topics, set the frequency/age parameters below.', - 'FORUM_RESYNCED' => 'Forum “%s” successfully resynced', - 'FORUM_RULES_EXPLAIN' => 'Forum rules are displayed at any page within the given forum.', - 'FORUM_RULES_LINK' => 'Link to forum rules', - 'FORUM_RULES_LINK_EXPLAIN' => 'You are able to enter the URL of the page/post containing your forum rules here. This setting will override the forum rules text you specified.', - 'FORUM_RULES_PREVIEW' => 'Forum rules preview', - 'FORUM_RULES_TOO_LONG' => 'The forum rules must be less than 4000 characters.', - 'FORUM_SETTINGS' => 'Forum settings', - 'FORUM_STATUS' => 'Forum status', - 'FORUM_STYLE' => 'Forum style', - 'FORUM_TOPICS_PAGE' => 'Topics per page', - 'FORUM_TOPICS_PAGE_EXPLAIN' => 'If non-zero this value will override the default topics per page setting.', - 'FORUM_TYPE' => 'Forum type', - 'FORUM_UPDATED' => 'Forum information updated successfully.', - - 'FORUM_WITH_SUBFORUMS_NOT_TO_LINK' => 'You want to change a postable forum having subforums to a link. Please move all subforums out of this forum before you proceed, because after changing to a link you are no longer able to see the subforums currently connected to this forum.', - - 'GENERAL_FORUM_SETTINGS' => 'General forum settings', - - 'LINK' => 'Link', - 'LIMIT_SUBFORUMS' => 'Limit legend to direct child-subforums', - 'LIMIT_SUBFORUMS_EXPLAIN' => 'Limits the subforums to be displayed to subforums that are direct descendants (children) of the current forum. Disabling this will display all subforums with the “List subforums in legend” option enabled, regardless of depth.', - 'LIST_INDEX' => 'List subforum in parent-forum’s legend', - 'LIST_INDEX_EXPLAIN' => 'Displays this forum on the index and elsewhere as a link within the legend of its parent-forum if the parent-forum’s “List subforums in legend” option is enabled.', - 'LIST_SUBFORUMS' => 'List subforums in legend', - 'LIST_SUBFORUMS_EXPLAIN' => 'Displays this forum’s subforums on the index and elsewhere as a link within the legend if their “List subforum in parent-forum’s legend” option is enabled.', - 'LOCKED' => 'Locked', - - 'MOVE_POSTS_NO_POSTABLE_FORUM' => 'The forum you selected for moving the posts to is not postable. Please select a postable forum.', - 'MOVE_POSTS_TO' => 'Move posts to', - 'MOVE_SUBFORUMS_TO' => 'Move subforums to', - - 'NO_DESTINATION_FORUM' => 'You have not specified a forum to move content to.', - 'NO_FORUM_ACTION' => 'No action defined for what happens with the forum content.', - 'NO_PARENT' => 'No parent', - 'NO_PERMISSIONS' => 'Do not copy permissions', - 'NO_PERMISSION_FORUM_ADD' => 'You do not have the necessary permissions to add forums.', - 'NO_PERMISSION_FORUM_DELETE' => 'You do not have the necessary permissions to delete forums.', - - 'PARENT_IS_LINK_FORUM' => 'The parent you specified is a forum link. Link forums are not able to hold other forums, please specify a category or forum as the parent forum.', - 'PARENT_NOT_EXIST' => 'Parent does not exist.', - 'PRUNE_ANNOUNCEMENTS' => 'Prune announcements', - 'PRUNE_STICKY' => 'Prune stickies', - 'PRUNE_OLD_POLLS' => 'Prune old polls', - 'PRUNE_OLD_POLLS_EXPLAIN' => 'Removes topics with polls not voted in for post age days.', - - 'REDIRECT_ACL' => 'Now you are able to %sset permissions%s for this forum.', - - 'SYNC_IN_PROGRESS' => 'Synchronizing forum', - 'SYNC_IN_PROGRESS_EXPLAIN' => 'Currently resyncing topic range %1$d/%2$d.', - - 'TYPE_CAT' => 'Category', - 'TYPE_FORUM' => 'Forum', - 'TYPE_LINK' => 'Link', - - 'UNLOCKED' => 'Unlocked', -)); diff --git a/install/update/new/language/en/acp/permissions.php b/install/update/new/language/en/acp/permissions.php deleted file mode 100644 index 875e424..0000000 --- a/install/update/new/language/en/acp/permissions.php +++ /dev/null @@ -1,287 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* DO NOT CHANGE -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -if (empty($lang) || !is_array($lang)) -{ - $lang = array(); -} - -// DEVELOPERS PLEASE NOTE -// -// All language files should use UTF-8 as their encoding and the files must not contain a BOM. -// -// Placeholders can now contain order information, e.g. instead of -// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows -// translators to re-order the output of data while ensuring it remains correct -// -// You do not need this where single placeholders are used, e.g. 'Message %d' is fine -// equally where a string contains only two placeholders which are used to wrap text -// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine - -$lang = array_merge($lang, array( - 'ACP_PERMISSIONS_EXPLAIN' => ' -

Permissions are highly granular and grouped into four major sections, which are:

- -

Global Permissions

-

These are used to control access on a global level and apply to the entire bulletin board. They are further divided into User Permissions, Group Permissions, Administrators and Global Moderators.

- -

Forum Based Permissions

-

These are used to control access on a per forum basis. They are further divided into Forum Permissions, Forum Moderators, User Forum Permissions and Group Forum Permissions.

- -

Permission Roles

-

These are used to create different sets of permissions for the different permission types later being able to be assigned on a role-based basis. The default roles should cover the administration of bulletin boards large and small, though within each of the four divisions, you can add/edit/delete roles as you see fit.

- -

Permission Masks

-

These are used to view the effective permissions assigned to Users, Moderators (Local and Global), Administrators or Forums.

- -
- -

For further information on setting up and managing permissions on your phpBB3 board, please see the section on Setting permissions of our Quick Start Guide.

- ', - - 'ACL_NEVER' => 'Never', - 'ACL_SET' => 'Setting permissions', - 'ACL_SET_EXPLAIN' => 'Permissions are based on a simple YES/NO system. Setting an option to NEVER for a user or usergroup overrides any other value assigned to it. If you do not wish to assign a value for an option for this user or group select NO. If values are assigned for this option elsewhere they will be used in preference, else NEVER is assumed. All objects marked (with the checkbox in front of them) will copy the permission set you defined.', - 'ACL_SETTING' => 'Setting', - - 'ACL_TYPE_A_' => 'Administrative permissions', - 'ACL_TYPE_F_' => 'Forum permissions', - 'ACL_TYPE_M_' => 'Moderative permissions', - 'ACL_TYPE_U_' => 'User permissions', - - 'ACL_TYPE_GLOBAL_A_' => 'Administrative permissions', - 'ACL_TYPE_GLOBAL_U_' => 'User permissions', - 'ACL_TYPE_GLOBAL_M_' => 'Global Moderator permissions', - 'ACL_TYPE_LOCAL_M_' => 'Forum Moderator permissions', - 'ACL_TYPE_LOCAL_F_' => 'Forum permissions', - - 'ACL_NO' => 'No', - 'ACL_VIEW' => 'Viewing permissions', - 'ACL_VIEW_EXPLAIN' => 'Here you can see the effective permissions the user/group is having. A red square indicates that the user/group does not have the permission, a green square indicates that the user/group does have the permission.', - 'ACL_YES' => 'Yes', - - 'ACP_ADMINISTRATORS_EXPLAIN' => 'Here you can assign administrator permissions to users or groups. All users with administrator permissions can view the administration control panel.', - 'ACP_FORUM_MODERATORS_EXPLAIN' => 'Here you can assign users and groups as forum moderators. To assign users access to forums, to define global moderative permissions or administrators please use the appropriate page.', - 'ACP_FORUM_PERMISSIONS_EXPLAIN' => 'Here you can alter which users and groups can access which forums. To assign moderators or define administrators please use the appropriate page.', - 'ACP_FORUM_PERMISSIONS_COPY_EXPLAIN' => 'Here you can copy forum permissions from one forum to one or more other forums.', - 'ACP_GLOBAL_MODERATORS_EXPLAIN' => 'Here you can assign global moderator permissions to users or groups. These moderators are like ordinary moderators except they have access to every forum on your board.', - 'ACP_GROUPS_FORUM_PERMISSIONS_EXPLAIN' => 'Here you can assign forum permissions to groups.', - 'ACP_GROUPS_PERMISSIONS_EXPLAIN' => 'Here you can assign global permissions to groups - user permissions, global moderator permissions and administrator permissions. User permissions include capabilities such as the use of avatars, sending private messages, et cetera; global moderator permissions such as approving posts, manage topics, manage bans, et cetera and lastly administrator permissions such as altering permissions, define custom BBCodes, manage forums, et cetera. Individual user permissions should only be changed in rare occasions, the preferred method is putting users in groups and assigning the group permissions.', - 'ACP_ADMIN_ROLES_EXPLAIN' => 'Here you are able to manage the roles for administrative permissions. Roles are effective permissions, if you change a role the items having this role assigned will change its permissions too.', - 'ACP_FORUM_ROLES_EXPLAIN' => 'Here you are able to manage the roles for forum permissions. Roles are effective permissions, if you change a role the items having this role assigned will change its permissions too.', - 'ACP_MOD_ROLES_EXPLAIN' => 'Here you are able to manage the roles for moderative permissions. Roles are effective permissions, if you change a role the items having this role assigned will change its permissions too.', - 'ACP_USER_ROLES_EXPLAIN' => 'Here you are able to manage the roles for user permissions. Roles are effective permissions, if you change a role the items having this role assigned will change its permissions too.', - 'ACP_USERS_FORUM_PERMISSIONS_EXPLAIN' => 'Here you can assign forum permissions to users.', - 'ACP_USERS_PERMISSIONS_EXPLAIN' => 'Here you can assign global permissions to users - user permissions, global moderator permissions and administrator permissions. User permissions include capabilities such as the use of avatars, sending private messages, et cetera; global moderator permissions such as approving posts, manage topics, manage bans, et cetera and lastly administrator permissions such as altering permissions, define custom BBCodes, manage forums, et cetera. To alter these settings for large numbers of users the Group permissions system is the preferred method. User permissions should only be changed in rare occasions, the preferred method is putting users in groups and assigning the group permissions.', - 'ACP_VIEW_ADMIN_PERMISSIONS_EXPLAIN' => 'Here you can view the effective administrative permissions assigned to the selected users/groups.', - 'ACP_VIEW_GLOBAL_MOD_PERMISSIONS_EXPLAIN' => 'Here you can view the global moderative permissions assigned to the selected users/groups.', - 'ACP_VIEW_FORUM_PERMISSIONS_EXPLAIN' => 'Here you can view the forum permissions assigned to the selected users/groups and forums.', - 'ACP_VIEW_FORUM_MOD_PERMISSIONS_EXPLAIN' => 'Here you can view the forum moderator permissions assigned to the selected users/groups and forums.', - 'ACP_VIEW_USER_PERMISSIONS_EXPLAIN' => 'Here you can view the effective user permissions assigned to the selected users/groups.', - - 'ADD_GROUPS' => 'Add groups', - 'ADD_PERMISSIONS' => 'Add permissions', - 'ADD_USERS' => 'Add users', - 'ADVANCED_PERMISSIONS' => 'Advanced Permissions', - 'ALL_GROUPS' => 'Select all groups', - 'ALL_NEVER' => 'All NEVER', - 'ALL_NO' => 'All NO', - 'ALL_USERS' => 'Select all users', - 'ALL_YES' => 'All YES', - 'APPLY_ALL_PERMISSIONS' => 'Apply all permissions', - 'APPLY_PERMISSIONS' => 'Apply permissions', - 'APPLY_PERMISSIONS_EXPLAIN' => 'The permissions and role defined for this item will only be applied to this item and all checked items.', - 'AUTH_UPDATED' => 'Permissions have been updated.', - - 'COPY_PERMISSIONS_CONFIRM' => 'Are you sure you wish to carry out this operation? Please be aware that this will overwrite any existing permissions on the selected targets.', - 'COPY_PERMISSIONS_FORUM_FROM_EXPLAIN' => 'The source forum you want to copy permissions from.', - 'COPY_PERMISSIONS_FORUM_TO_EXPLAIN' => 'The destination forums you want the copied permissions applied to.', - 'COPY_PERMISSIONS_FROM' => 'Copy permissions from', - 'COPY_PERMISSIONS_TO' => 'Apply permissions to', - - 'CREATE_ROLE' => 'Create role', - 'CREATE_ROLE_FROM' => 'Use settings from…', - 'CUSTOM' => 'Custom…', - - 'DEFAULT' => 'Default', - 'DELETE_ROLE' => 'Delete role', - 'DELETE_ROLE_CONFIRM' => 'Are you sure you want to remove this role? Items having this role assigned will not lose their permission settings.', - 'DISPLAY_ROLE_ITEMS' => 'View items using this role', - - 'EDIT_PERMISSIONS' => 'Edit permissions', - 'EDIT_ROLE' => 'Edit role', - - 'GROUPS_NOT_ASSIGNED' => 'No group assigned to this role', - - 'LOOK_UP_GROUP' => 'Look up usergroup', - 'LOOK_UP_USER' => 'Look up user', - - 'MANAGE_GROUPS' => 'Manage groups', - 'MANAGE_USERS' => 'Manage users', - - 'NO_AUTH_SETTING_FOUND' => 'Permission settings not defined.', - 'NO_ROLE_ASSIGNED' => 'No role assigned…', - 'NO_ROLE_ASSIGNED_EXPLAIN' => 'Setting to this role does not change permissions on the right. If you want to unset/remove all permissions you should use the “All NO” link.', - 'NO_ROLE_AVAILABLE' => 'No role available', - 'NO_ROLE_NAME_SPECIFIED' => 'Please give the role a name.', - 'NO_ROLE_SELECTED' => 'Role could not be found.', - 'NO_USER_GROUP_SELECTED' => 'You haven’t selected any user or group.', - - 'ONLY_FORUM_DEFINED' => 'You only defined forums in your selection. Please also select at least one user or one group.', - - 'PERMISSION_APPLIED_TO_ALL' => 'Permissions and role will also be applied to all checked objects', - 'PLUS_SUBFORUMS' => '+Subforums', - - 'REMOVE_PERMISSIONS' => 'Remove permissions', - 'REMOVE_ROLE' => 'Remove role', - 'RESULTING_PERMISSION' => 'Resulting permission', - 'ROLE' => 'Role', - 'ROLE_ADD_SUCCESS' => 'Role successfully added.', - 'ROLE_ASSIGNED_TO' => 'Users/Groups assigned to %s', - 'ROLE_DELETED' => 'Role successfully removed.', - 'ROLE_DESCRIPTION' => 'Role description', - - 'ROLE_ADMIN_FORUM' => 'Forum Admin', - 'ROLE_ADMIN_FULL' => 'Full Admin', - 'ROLE_ADMIN_STANDARD' => 'Standard Admin', - 'ROLE_ADMIN_USERGROUP' => 'User and Groups Admin', - 'ROLE_FORUM_BOT' => 'Bot Access', - 'ROLE_FORUM_FULL' => 'Full Access', - 'ROLE_FORUM_LIMITED' => 'Limited Access', - 'ROLE_FORUM_LIMITED_POLLS' => 'Limited Access + Polls', - 'ROLE_FORUM_NOACCESS' => 'No Access', - 'ROLE_FORUM_ONQUEUE' => 'On Moderation Queue', - 'ROLE_FORUM_POLLS' => 'Standard Access + Polls', - 'ROLE_FORUM_READONLY' => 'Read Only Access', - 'ROLE_FORUM_STANDARD' => 'Standard Access', - 'ROLE_FORUM_NEW_MEMBER' => 'Newly Registered User Access', - 'ROLE_MOD_FULL' => 'Full Moderator', - 'ROLE_MOD_QUEUE' => 'Queue Moderator', - 'ROLE_MOD_SIMPLE' => 'Simple Moderator', - 'ROLE_MOD_STANDARD' => 'Standard Moderator', - 'ROLE_USER_FULL' => 'All Features', - 'ROLE_USER_LIMITED' => 'Limited Features', - 'ROLE_USER_NOAVATAR' => 'No Avatar', - 'ROLE_USER_NOPM' => 'No Private Messages', - 'ROLE_USER_STANDARD' => 'Standard Features', - 'ROLE_USER_NEW_MEMBER' => 'Newly Registered User Features', - - 'ROLE_DESCRIPTION_ADMIN_FORUM' => 'Can access the forum management and forum permission settings.', - 'ROLE_DESCRIPTION_ADMIN_FULL' => 'Has access to all administrative functions of this board.
Not recommended.', - 'ROLE_DESCRIPTION_ADMIN_STANDARD' => 'Has access to most administrative features but is not allowed to use server or system related tools.', - 'ROLE_DESCRIPTION_ADMIN_USERGROUP' => 'Can manage groups and users: Able to change permissions, settings, manage bans, and manage ranks.', - 'ROLE_DESCRIPTION_FORUM_BOT' => 'This role is recommended for bots and search spiders.', - 'ROLE_DESCRIPTION_FORUM_FULL' => 'Can use all forum features, including posting of announcements and stickies. Can also ignore the flood limit.
Not recommended for normal users.', - 'ROLE_DESCRIPTION_FORUM_LIMITED' => 'Can use some forum features, but cannot attach files or use post icons.', - 'ROLE_DESCRIPTION_FORUM_LIMITED_POLLS' => 'As per Limited Access but can also create polls.', - 'ROLE_DESCRIPTION_FORUM_NOACCESS' => 'Can neither see nor access the forum.', - 'ROLE_DESCRIPTION_FORUM_ONQUEUE' => 'Can use most forum features including attachments, but posts and topics need to be approved by a moderator.', - 'ROLE_DESCRIPTION_FORUM_POLLS' => 'Like Standard Access but can also create polls.', - 'ROLE_DESCRIPTION_FORUM_READONLY' => 'Can read the forum, but cannot create new topics or reply to posts.', - 'ROLE_DESCRIPTION_FORUM_STANDARD' => 'Can use most forum features including attachments and deleting own topics, but cannot lock own topics, and cannot create polls.', - 'ROLE_DESCRIPTION_FORUM_NEW_MEMBER' => 'A role for members of the special newly registered users group; contains NEVER permissions to lock features for new users.', - 'ROLE_DESCRIPTION_MOD_FULL' => 'Can use all moderating features, including banning.', - 'ROLE_DESCRIPTION_MOD_QUEUE' => 'Can use the Moderation Queue to validate and edit posts, but nothing else.', - 'ROLE_DESCRIPTION_MOD_SIMPLE' => 'Can only use basic topic actions. Cannot send warnings or use moderation queue.', - 'ROLE_DESCRIPTION_MOD_STANDARD' => 'Can use most moderating tools, but cannot ban users or change the post author.', - 'ROLE_DESCRIPTION_USER_FULL' => 'Can use all available forum features for users, including changing the user name or ignoring the flood limit.
Not recommended.', - 'ROLE_DESCRIPTION_USER_LIMITED' => 'Can access some of the user features. Attachments, emails, or instant messages are not allowed.', - 'ROLE_DESCRIPTION_USER_NOAVATAR' => 'Has a limited feature set and is not allowed to use the Avatar feature.', - 'ROLE_DESCRIPTION_USER_NOPM' => 'Has a limited feature set, and is not allowed to use Private Messages.', - 'ROLE_DESCRIPTION_USER_STANDARD' => 'Can access most but not all user features. Cannot change user name or ignore the flood limit, for instance.', - 'ROLE_DESCRIPTION_USER_NEW_MEMBER' => 'A role for members of the special newly registered users group; contains NEVER permissions to lock features for new users.', - - 'ROLE_DESCRIPTION_EXPLAIN' => 'You are able to enter a short explanation of what the role is doing or for what it is meant for. The text you enter here will be displayed within the permissions screens too.', - 'ROLE_DESCRIPTION_LONG' => 'The role description is too long, please limit it to 4000 characters.', - 'ROLE_DETAILS' => 'Role details', - 'ROLE_EDIT_SUCCESS' => 'Role successfully edited.', - 'ROLE_NAME' => 'Role name', - 'ROLE_NAME_ALREADY_EXIST' => 'A role named %s already exist for the specified permission type.', - 'ROLE_NOT_ASSIGNED' => 'Role has not been assigned yet.', - - 'SELECTED_FORUM_NOT_EXIST' => 'The selected forum(s) do not exist.', - 'SELECTED_GROUP_NOT_EXIST' => 'The selected group(s) do not exist.', - 'SELECTED_USER_NOT_EXIST' => 'The selected user(s) do not exist.', - 'SELECT_FORUM_SUBFORUM_EXPLAIN' => 'The forum you select here will include all subforums into the selection.', - 'SELECT_ROLE' => 'Select role…', - 'SELECT_TYPE' => 'Select type', - 'SET_PERMISSIONS' => 'Set permissions', - 'SET_ROLE_PERMISSIONS' => 'Set role permissions', - 'SET_USERS_PERMISSIONS' => 'Set user permissions', - 'SET_USERS_FORUM_PERMISSIONS' => 'Set user forum permissions', - - 'TRACE_DEFAULT' => 'By default every permission is NO (unset). So the permission can be overwritten by other settings.', - 'TRACE_FOR' => 'Trace for', - 'TRACE_GLOBAL_SETTING' => '%s (global)', - 'TRACE_GROUP_NEVER_TOTAL_NEVER' => 'This group’s permission is set to NEVER like the total result so the old result is kept.', - 'TRACE_GROUP_NEVER_TOTAL_NEVER_LOCAL' => 'This group’s permission for this forum is set to NEVER like the total result so the old result is kept.', - 'TRACE_GROUP_NEVER_TOTAL_NO' => 'This group’s permission is set to NEVER which becomes the new total value because it wasn’t set yet (set to NO).', - 'TRACE_GROUP_NEVER_TOTAL_NO_LOCAL' => 'This group’s permission for this forum is set to NEVER which becomes the new total value because it wasn’t set yet (set to NO).', - 'TRACE_GROUP_NEVER_TOTAL_YES' => 'This group’s permission is set to NEVER which overwrites the total YES to a NEVER for this user.', - 'TRACE_GROUP_NEVER_TOTAL_YES_LOCAL' => 'This group’s permission for this forum is set to NEVER which overwrites the total YES to a NEVER for this user.', - 'TRACE_GROUP_NO' => 'The permission is NO for this group so the old total value is kept.', - 'TRACE_GROUP_NO_LOCAL' => 'The permission is NO for this group within this forum so the old total value is kept.', - 'TRACE_GROUP_YES_TOTAL_NEVER' => 'This group’s permission is set to YES but the total NEVER cannot be overwritten.', - 'TRACE_GROUP_YES_TOTAL_NEVER_LOCAL' => 'This group’s permission for this forum is set to YES but the total NEVER cannot be overwritten.', - 'TRACE_GROUP_YES_TOTAL_NO' => 'This group’s permission is set to YES which becomes the new total value because it wasn’t set yet (set to NO).', - 'TRACE_GROUP_YES_TOTAL_NO_LOCAL' => 'This group’s permission for this forum is set to YES which becomes the new total value because it wasn’t set yet (set to NO).', - 'TRACE_GROUP_YES_TOTAL_YES' => 'This group’s permission is set to YES and the total permission is already set to YES, so the total result is kept.', - 'TRACE_GROUP_YES_TOTAL_YES_LOCAL' => 'This group’s permission for this forum is set to YES and the total permission is already set to YES, so the total result is kept.', - 'TRACE_PERMISSION' => 'Trace permission - %s', - 'TRACE_RESULT' => 'Trace result', - 'TRACE_SETTING' => 'Trace setting', - - 'TRACE_USER_GLOBAL_YES_TOTAL_YES' => 'The forum independent user permission evaluates to YES but the total permission is already set to YES, so the total result is kept. %sTrace global permission%s', - 'TRACE_USER_GLOBAL_YES_TOTAL_NEVER' => 'The forum independent user permission evaluates to YES which overwrites the current local result NEVER. %sTrace global permission%s', - 'TRACE_USER_GLOBAL_NEVER_TOTAL_KEPT' => 'The forum independent user permission evaluates to NEVER which doesn’t influence the local permission. %sTrace global permission%s', - - 'TRACE_USER_FOUNDER' => 'The user is a founder, therefore admin permissions are always set to YES.', - 'TRACE_USER_KEPT' => 'The user’s permission is NO so the old total value is kept.', - 'TRACE_USER_KEPT_LOCAL' => 'The user’s permission for this forum is NO so the old total value is kept.', - 'TRACE_USER_NEVER_TOTAL_NEVER' => 'The user’s permission is set to NEVER and the total value is set to NEVER, so nothing is changed.', - 'TRACE_USER_NEVER_TOTAL_NEVER_LOCAL' => 'The user’s permission for this forum is set to NEVER and the total value is set to NEVER, so nothing is changed.', - 'TRACE_USER_NEVER_TOTAL_NO' => 'The user’s permission is set to NEVER which becomes the total value because it was set to NO.', - 'TRACE_USER_NEVER_TOTAL_NO_LOCAL' => 'The user’s permission for this forum is set to NEVER which becomes the total value because it was set to NO.', - 'TRACE_USER_NEVER_TOTAL_YES' => 'The user’s permission is set to NEVER and overwrites the previous YES.', - 'TRACE_USER_NEVER_TOTAL_YES_LOCAL' => 'The user’s permission for this forum is set to NEVER and overwrites the previous YES.', - 'TRACE_USER_NO_TOTAL_NO' => 'The user’s permission is NO and the total value was set to NO so it defaults to NEVER.', - 'TRACE_USER_NO_TOTAL_NO_LOCAL' => 'The user’s permission for this forum is NO and the total value was set to NO so it defaults to NEVER.', - 'TRACE_USER_YES_TOTAL_NEVER' => 'The user’s permission is set to YES but the total NEVER cannot be overwritten.', - 'TRACE_USER_YES_TOTAL_NEVER_LOCAL' => 'The user’s permission for this forum is set to YES but the total NEVER cannot be overwritten.', - 'TRACE_USER_YES_TOTAL_NO' => 'The user’s permission is set to YES which becomes the total value because it was set to NO.', - 'TRACE_USER_YES_TOTAL_NO_LOCAL' => 'The user’s permission for this forum is set to YES which becomes the total value because it was set to NO.', - 'TRACE_USER_YES_TOTAL_YES' => 'The user’s permission is set to YES and the total value is set to YES, so nothing is changed.', - 'TRACE_USER_YES_TOTAL_YES_LOCAL' => 'The user’s permission for this forum is set to YES and the total value is set to YES, so nothing is changed.', - 'TRACE_WHO' => 'Who', - 'TRACE_TOTAL' => 'Total', - - 'USERS_NOT_ASSIGNED' => 'No users are assigned to this role', - 'USER_IS_MEMBER_OF_DEFAULT' => 'is a member of the following pre-defined groups', - 'USER_IS_MEMBER_OF_CUSTOM' => 'is a member of the following user defined groups', - - 'VIEW_ASSIGNED_ITEMS' => 'View assigned items', - 'VIEW_LOCAL_PERMS' => 'Local permissions', - 'VIEW_GLOBAL_PERMS' => 'Global permissions', - 'VIEW_PERMISSIONS' => 'View permissions', - - 'WRONG_PERMISSION_TYPE' => 'Wrong permission type selected.', - 'WRONG_PERMISSION_SETTING_FORMAT' => 'The permission settings are in a wrong format, phpBB is not able to process them correctly.', -)); diff --git a/install/update/new/language/en/acp/permissions_phpbb.php b/install/update/new/language/en/acp/permissions_phpbb.php deleted file mode 100644 index ab89399..0000000 --- a/install/update/new/language/en/acp/permissions_phpbb.php +++ /dev/null @@ -1,215 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* DO NOT CHANGE -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -if (empty($lang) || !is_array($lang)) -{ - $lang = array(); -} - -// DEVELOPERS PLEASE NOTE -// -// All language files should use UTF-8 as their encoding and the files must not contain a BOM. -// -// Placeholders can now contain order information, e.g. instead of -// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows -// translators to re-order the output of data while ensuring it remains correct -// -// You do not need this where single placeholders are used, e.g. 'Message %d' is fine -// equally where a string contains only two placeholders which are used to wrap text -// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine - -/** -* EXTENSION-DEVELOPERS PLEASE NOTE -* -* You are able to put your permission sets into your extension. -* The permissions logic should be added via the 'core.permissions' event. -* You can easily add new permission categories, types and permissions, by -* simply merging them into the respective arrays. -* The respective language strings should be added into a language file, that -* start with 'permissions_', so they are automatically loaded within the ACP. -*/ - -$lang = array_merge($lang, array( - 'ACL_CAT_ACTIONS' => 'Actions', - 'ACL_CAT_CONTENT' => 'Content', - 'ACL_CAT_FORUMS' => 'Forums', - 'ACL_CAT_MISC' => 'Misc', - 'ACL_CAT_PERMISSIONS' => 'Permissions', - 'ACL_CAT_PM' => 'Private messages', - 'ACL_CAT_POLLS' => 'Polls', - 'ACL_CAT_POST' => 'Post', - 'ACL_CAT_POST_ACTIONS' => 'Post actions', - 'ACL_CAT_POSTING' => 'Posting', - 'ACL_CAT_PROFILE' => 'Profile', - 'ACL_CAT_SETTINGS' => 'Settings', - 'ACL_CAT_TOPIC_ACTIONS' => 'Topic actions', - 'ACL_CAT_USER_GROUP' => 'Users & Groups', -)); - -// User Permissions -$lang = array_merge($lang, array( - 'ACL_U_VIEWPROFILE' => 'Can view profiles, memberlist and online list', - 'ACL_U_CHGNAME' => 'Can change username', - 'ACL_U_CHGPASSWD' => 'Can change password', - 'ACL_U_CHGEMAIL' => 'Can change email address', - 'ACL_U_CHGAVATAR' => 'Can change avatar', - 'ACL_U_CHGGRP' => 'Can change default usergroup', - 'ACL_U_CHGPROFILEINFO' => 'Can change profile field information', - - 'ACL_U_ATTACH' => 'Can attach files', - 'ACL_U_DOWNLOAD' => 'Can download files', - 'ACL_U_SAVEDRAFTS' => 'Can save drafts', - 'ACL_U_CHGCENSORS' => 'Can disable word censors', - 'ACL_U_SIG' => 'Can use signature', - 'ACL_U_EMOJI' => 'Can use emoji and rich text characters in topic title', - - 'ACL_U_SENDPM' => 'Can send private messages', - 'ACL_U_MASSPM' => 'Can send private messages to multiple users', - 'ACL_U_MASSPM_GROUP'=> 'Can send private messages to groups', - 'ACL_U_READPM' => 'Can read private messages', - 'ACL_U_PM_EDIT' => 'Can edit own private messages', - 'ACL_U_PM_DELETE' => 'Can remove private messages from own folder', - 'ACL_U_PM_FORWARD' => 'Can forward private messages', - 'ACL_U_PM_EMAILPM' => 'Can email private messages', - 'ACL_U_PM_PRINTPM' => 'Can print private messages', - 'ACL_U_PM_ATTACH' => 'Can attach files in private messages', - 'ACL_U_PM_DOWNLOAD' => 'Can download files in private messages', - 'ACL_U_PM_BBCODE' => 'Can use BBCode in private messages', - 'ACL_U_PM_SMILIES' => 'Can use smilies in private messages', - 'ACL_U_PM_IMG' => 'Can use [img] BBCode tag in private messages', - 'ACL_U_PM_FLASH' => 'Can use [flash] BBCode tag in private messages', - - 'ACL_U_SENDEMAIL' => 'Can send emails', - 'ACL_U_SENDIM' => 'Can send instant messages', - 'ACL_U_IGNOREFLOOD' => 'Can ignore flood limit', - 'ACL_U_HIDEONLINE' => 'Can hide online status', - 'ACL_U_VIEWONLINE' => 'Can view hidden online users', - 'ACL_U_SEARCH' => 'Can search board', -)); - -// Forum Permissions -$lang = array_merge($lang, array( - 'ACL_F_LIST' => 'Can see forum', - 'ACL_F_LIST_TOPICS' => 'Can see topics', - 'ACL_F_READ' => 'Can read forum', - 'ACL_F_SEARCH' => 'Can search the forum', - 'ACL_F_SUBSCRIBE' => 'Can subscribe forum', - 'ACL_F_PRINT' => 'Can print topics', - 'ACL_F_EMAIL' => 'Can email topics', - 'ACL_F_BUMP' => 'Can bump topics', - 'ACL_F_USER_LOCK' => 'Can lock own topics', - 'ACL_F_DOWNLOAD' => 'Can download files', - 'ACL_F_REPORT' => 'Can report posts', - - 'ACL_F_POST' => 'Can start new topics', - 'ACL_F_STICKY' => 'Can post stickies', - 'ACL_F_ANNOUNCE' => 'Can post announcements', - 'ACL_F_ANNOUNCE_GLOBAL' => 'Can post global announcements', - 'ACL_F_REPLY' => 'Can reply to topics', - 'ACL_F_EDIT' => 'Can edit own posts', - 'ACL_F_DELETE' => 'Can permanently delete own posts', - 'ACL_F_SOFTDELETE' => 'Can soft delete own posts
Moderators, who have the approve posts permission, can restore soft deleted posts.', - 'ACL_F_IGNOREFLOOD' => 'Can ignore flood limit', - 'ACL_F_POSTCOUNT' => 'Increment post counter
Please note that this setting only affects new posts.', - 'ACL_F_NOAPPROVE' => 'Can post without approval', - - 'ACL_F_ATTACH' => 'Can attach files', - 'ACL_F_ICONS' => 'Can use topic/post icons', - 'ACL_F_BBCODE' => 'Can use BBCode', - 'ACL_F_FLASH' => 'Can use [flash] BBCode tag', - 'ACL_F_IMG' => 'Can use [img] BBCode tag', - 'ACL_F_SIGS' => 'Can use signatures', - 'ACL_F_SMILIES' => 'Can use smilies', - - 'ACL_F_POLL' => 'Can create polls', - 'ACL_F_VOTE' => 'Can vote in polls', - 'ACL_F_VOTECHG' => 'Can change existing vote', -)); - -// Moderator Permissions -$lang = array_merge($lang, array( - 'ACL_M_EDIT' => 'Can edit posts', - 'ACL_M_DELETE' => 'Can permanently delete posts', - 'ACL_M_SOFTDELETE' => 'Can soft delete posts
Moderators, who have the approve posts permission, can restore soft deleted posts.', - 'ACL_M_APPROVE' => 'Can approve and restore posts', - 'ACL_M_REPORT' => 'Can close and delete reports', - 'ACL_M_CHGPOSTER' => 'Can change post author', - - 'ACL_M_MOVE' => 'Can move topics', - 'ACL_M_LOCK' => 'Can lock topics', - 'ACL_M_SPLIT' => 'Can split topics', - 'ACL_M_MERGE' => 'Can merge topics', - - 'ACL_M_INFO' => 'Can view post details', - 'ACL_M_WARN' => 'Can issue warnings
This setting is only assigned globally. It is not forum based.', // This moderator setting is only global (and not local) - 'ACL_M_PM_REPORT' => 'Can close and delete reports of private messages
This setting is only assigned globally. It is not forum based.', // This moderator setting is only global (and not local) - 'ACL_M_BAN' => 'Can manage bans
This setting is only assigned globally. It is not forum based.', // This moderator setting is only global (and not local) -)); - -// Admin Permissions -$lang = array_merge($lang, array( - 'ACL_A_BOARD' => 'Can alter board settings/check for updates', - 'ACL_A_SERVER' => 'Can alter server/communication settings', - 'ACL_A_JABBER' => 'Can alter Jabber settings', - 'ACL_A_PHPINFO' => 'Can view php settings', - - 'ACL_A_FORUM' => 'Can manage forums', - 'ACL_A_FORUMADD' => 'Can add new forums', - 'ACL_A_FORUMDEL' => 'Can delete forums', - 'ACL_A_PRUNE' => 'Can prune forums', - - 'ACL_A_ICONS' => 'Can alter topic/post icons and smilies', - 'ACL_A_WORDS' => 'Can alter word censors', - 'ACL_A_BBCODE' => 'Can define BBCode tags', - 'ACL_A_ATTACH' => 'Can alter attachment related settings', - - 'ACL_A_USER' => 'Can manage users
This also includes seeing the users browser agent within the viewonline list.', - 'ACL_A_USERDEL' => 'Can delete/prune users', - 'ACL_A_GROUP' => 'Can manage groups', - 'ACL_A_GROUPADD' => 'Can add new groups', - 'ACL_A_GROUPDEL' => 'Can delete groups', - 'ACL_A_RANKS' => 'Can manage ranks', - 'ACL_A_PROFILE' => 'Can manage custom profile fields', - 'ACL_A_NAMES' => 'Can manage disallowed names', - 'ACL_A_BAN' => 'Can manage bans', - - 'ACL_A_VIEWAUTH' => 'Can view permission masks', - 'ACL_A_AUTHGROUPS' => 'Can alter permissions for individual groups', - 'ACL_A_AUTHUSERS' => 'Can alter permissions for individual users', - 'ACL_A_FAUTH' => 'Can alter forum permission class', - 'ACL_A_MAUTH' => 'Can alter moderator permission class', - 'ACL_A_AAUTH' => 'Can alter admin permission class', - 'ACL_A_UAUTH' => 'Can alter user permission class', - 'ACL_A_ROLES' => 'Can manage roles', - 'ACL_A_SWITCHPERM' => 'Can use others permissions', - - 'ACL_A_STYLES' => 'Can manage styles', - 'ACL_A_EXTENSIONS' => 'Can manage extensions', - 'ACL_A_VIEWLOGS' => 'Can view logs', - 'ACL_A_CLEARLOGS' => 'Can clear logs', - 'ACL_A_MODULES' => 'Can manage modules', - 'ACL_A_LANGUAGE' => 'Can manage language packs', - 'ACL_A_EMAIL' => 'Can send mass email', - 'ACL_A_BOTS' => 'Can manage bots', - 'ACL_A_REASONS' => 'Can manage report/denial reasons', - 'ACL_A_BACKUP' => 'Can backup/restore database', - 'ACL_A_SEARCH' => 'Can manage search backends and settings', -)); diff --git a/install/update/new/language/en/acp/posting.php b/install/update/new/language/en/acp/posting.php deleted file mode 100644 index 3bff6b9..0000000 --- a/install/update/new/language/en/acp/posting.php +++ /dev/null @@ -1,291 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* DO NOT CHANGE -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -if (empty($lang) || !is_array($lang)) -{ - $lang = array(); -} - -// DEVELOPERS PLEASE NOTE -// -// All language files should use UTF-8 as their encoding and the files must not contain a BOM. -// -// Placeholders can now contain order information, e.g. instead of -// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows -// translators to re-order the output of data while ensuring it remains correct -// -// You do not need this where single placeholders are used, e.g. 'Message %d' is fine -// equally where a string contains only two placeholders which are used to wrap text -// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine - -// BBCodes -// Note to translators: you can translate everything but what's between { and } -$lang = array_merge($lang, array( - 'ACP_BBCODES_EXPLAIN' => 'BBCode is a special implementation of HTML offering greater control over what and how something is displayed. From this page you can add, remove and edit custom BBCodes.', - 'ADD_BBCODE' => 'Add a new BBCode', - - 'BBCODE_DANGER' => 'The BBCode you are trying to add seems unsafe. If the BBCode uses a {TEXT} token in a sensitive context, try using a more restrictive type instead. Only proceed if you understand the risks involved.', - 'BBCODE_DANGER_PROCEED' => 'Proceed', //'I understand the risk', - - 'BBCODE_ADDED' => 'BBCode added successfully.', - 'BBCODE_EDITED' => 'BBCode edited successfully.', - 'BBCODE_DELETED' => 'The BBCode has been removed successfully.', - 'BBCODE_NOT_EXIST' => 'The BBCode you selected does not exist.', - 'BBCODE_HELPLINE' => 'Help line', - 'BBCODE_HELPLINE_EXPLAIN' => 'This field contains the mouse over text of the BBCode.', - 'BBCODE_HELPLINE_TEXT' => 'Help line text', - 'BBCODE_HELPLINE_TOO_LONG' => 'The help line you entered is too long.', - - 'BBCODE_INVALID_TAG_NAME' => 'The BBCode tag name that you selected already exists.', - 'BBCODE_INVALID' => 'Your BBCode is constructed in an invalid form.', - 'BBCODE_INVALID_TEMPLATE' => 'Your BBCode’s template is invalid.', - 'BBCODE_TAG' => 'Tag', - 'BBCODE_TAG_TOO_LONG' => 'The tag name you selected is too long.', - 'BBCODE_TAG_DEF_TOO_LONG' => 'The tag definition that you have entered is too long, please shorten your tag definition.', - 'BBCODE_USAGE' => 'BBCode usage', - 'BBCODE_USAGE_EXAMPLE' => '[highlight={COLOR}]{TEXT}[/highlight]

[font={SIMPLETEXT1}]{SIMPLETEXT2}[/font]', - 'BBCODE_USAGE_EXPLAIN' => 'Here you define how to use the BBCode. Replace any variable input by the corresponding token (%ssee below%s).', - - 'EXAMPLE' => 'Example:', - 'EXAMPLES' => 'Examples:', - - 'HTML_REPLACEMENT' => 'HTML replacement', - 'HTML_REPLACEMENT_EXAMPLE' => '<span style="background-color: {COLOR};">{TEXT}</span>

<span style="font-family: {SIMPLETEXT1};">{SIMPLETEXT2}</span>', - 'HTML_REPLACEMENT_EXPLAIN' => 'Here you define the default HTML replacement. Do not forget to put back tokens you used above!', - - 'TOKEN' => 'Token', - 'TOKENS' => 'Tokens', - 'TOKENS_EXPLAIN' => 'Tokens are placeholders for user input. The input will be validated only if it matches the corresponding definition. If needed, you can number them by adding a number as the last character between the braces, e.g. {TEXT1}, {TEXT2}.

Within the HTML replacement you can also use any language string present in your language/ directory like this: {L_<STRINGNAME>} where <STRINGNAME> is the name of the translated string you want to add. For example, {L_WROTE} will be displayed as “wrote” or its translation according to user’s locale.

Please note that only tokens listed below are able to be used within custom BBCodes.', - 'TOKEN_DEFINITION' => 'What can it be?', - 'TOO_MANY_BBCODES' => 'You cannot create any more BBCodes. Please remove one or more BBCodes then try again.', - - 'tokens' => array( - 'TEXT' => 'Any text, including foreign characters, numbers, etc…', - 'SIMPLETEXT' => 'Characters from the latin alphabet (A-Z), numbers, spaces, commas, dots, minus, plus, hyphen and underscore', - 'INTTEXT' => 'Unicode letter characters, numbers, spaces, commas, dots, minus, plus, hyphen, underscore and whitespaces.', - 'IDENTIFIER' => 'Characters from the latin alphabet (A-Z), numbers, hyphen and underscore', - 'NUMBER' => 'Any series of digits', - 'EMAIL' => 'A valid email address', - 'URL' => 'A valid URL using any allowed protocol (http, ftp, etc… cannot be used for javascript exploits). If none is given, “http://” is prefixed to the string.', - 'LOCAL_URL' => 'A local URL. The URL must be relative to the topic page and cannot contain a server name or protocol, as links are prefixed with “%s”', - 'RELATIVE_URL' => 'A relative URL. You can use this to match parts of a URL, but be careful: a full URL is a valid relative URL. When you want to use relative URLs of your board, use the LOCAL_URL token.', - 'COLOR' => 'A HTML colour, can be either in the numeric form #FF1234 or a CSS colour keyword such as fuchsia or InactiveBorder', - ), -)); - -// Smilies and topic icons -$lang = array_merge($lang, array( - 'ACP_ICONS_EXPLAIN' => 'From this page you can add, remove and edit the icons users may add to their topics or posts. These icons are generally displayed next to topic titles on the forum listing, or the post subjects in topic listings. You can also install and create new packages of icons.', - 'ACP_SMILIES_EXPLAIN' => 'Smilies or emoticons are typically small, sometimes animated images used to convey an emotion or feeling. From this page you can add, remove and edit the emoticons users can use in their posts and private messages. You can also install and create new packages of smilies.', - 'ADD_SMILIES' => 'Add multiple smilies', - 'ADD_SMILEY_CODE' => 'Add additional smiley code', - 'ADD_ICONS' => 'Add multiple icons', - 'AFTER_ICONS' => 'After %s', - 'AFTER_SMILIES' => 'After %s', - - 'CODE' => 'Code', - 'CURRENT_ICONS' => 'Current icons', - 'CURRENT_ICONS_EXPLAIN' => 'Choose what to do with the currently installed icons.', - 'CURRENT_SMILIES' => 'Current smilies', - 'CURRENT_SMILIES_EXPLAIN' => 'Choose what to do with the currently installed smilies.', - - 'DISPLAY_ON_POSTING' => 'Display on posting page', - 'DISPLAY_POSTING' => 'On posting page', - 'DISPLAY_POSTING_NO' => 'Not on posting page', - - 'EDIT_ICONS' => 'Edit icons', - 'EDIT_SMILIES' => 'Edit smilies', - 'EMOTION' => 'Emotion', - 'EXPORT_ICONS' => 'Export and download icons.pak', - 'EXPORT_ICONS_EXPLAIN' => '%sOn clicking this link, the configuration for your installed icons will be packaged into icons.pak which once downloaded can be used to create a .zip or .tgz file containing all of your icons plus this icons.pak configuration file%s.', - 'EXPORT_SMILIES' => 'Export and download smilies.pak', - 'EXPORT_SMILIES_EXPLAIN' => '%sOn clicking this link, the configuration for your installed smilies will be packaged into smilies.pak which once downloaded can be used to create a .zip or .tgz file containing all of your smilies plus this smilies.pak configuration file%s.', - - 'FIRST' => 'First', - - 'ICONS_ADD' => 'Add a new icon', - 'ICONS_ADDED' => array( - 0 => 'No icons were added.', - 1 => 'The icon has been added successfully.', - 2 => 'The icons have been added successfully.', - ), - 'ICONS_CONFIG' => 'Icon configuration', - 'ICONS_DELETED' => 'The icon has been removed successfully.', - 'ICONS_EDIT' => 'Edit icon', - 'ICONS_EDITED' => array( - 0 => 'No icons were updated.', - 1 => 'The icon has been updated successfully.', - 2 => 'The icons have been updated successfully.', - ), - 'ICONS_HEIGHT' => 'Icon height', - 'ICONS_IMAGE' => 'Icon image', - 'ICONS_IMPORTED' => 'The icons pack has been installed successfully.', - 'ICONS_IMPORT_SUCCESS' => 'The icons pack was imported successfully.', - 'ICONS_LOCATION' => 'Icon location', - 'ICONS_NOT_DISPLAYED' => 'The following icons are not displayed on the posting page', - 'ICONS_ORDER' => 'Icon order', - 'ICONS_URL' => 'Icon image file', - 'ICONS_WIDTH' => 'Icon width', - 'IMPORT_ICONS' => 'Install icons package', - 'IMPORT_SMILIES' => 'Install smilies package', - - 'KEEP_ALL' => 'Keep all', - - 'MASS_ADD_SMILIES' => 'Add multiple smilies', - - 'NO_ICONS_ADD' => 'There are no icons available for adding.', - 'NO_ICONS_EDIT' => 'There are no icons available for modifying.', - 'NO_ICONS_EXPORT' => 'You have no icons with which to create a package.', - 'NO_ICONS_PAK' => 'No icon packages found.', - 'NO_SMILIES_ADD' => 'There are no smilies available for adding.', - 'NO_SMILIES_EDIT' => 'There are no smilies available for modifying.', - 'NO_SMILIES_EXPORT' => 'You have no smilies with which to create a package.', - 'NO_SMILIES_PAK' => 'No smiley packages found.', - - 'PAK_FILE_NOT_READABLE' => 'Could not read .pak file.', - - 'REPLACE_MATCHES' => 'Replace matches', - - 'SELECT_PACKAGE' => 'Select a package file', - 'SMILIES_ADD' => 'Add a new smiley', - 'SMILIES_ADDED' => array( - 0 => 'No smilies were added.', - 1 => 'The smiley has been added successfully.', - 2 => 'The smilies have been added successfully.', - ), - 'SMILIES_CODE' => 'Smiley code', - 'SMILIES_CONFIG' => 'Smiley configuration', - 'SMILIES_DELETED' => 'The smiley has been removed successfully.', - 'SMILIES_EDIT' => 'Edit smiley', - 'SMILIE_NO_CODE' => 'The smiley “%s” was ignored, as there was no code entered.', - 'SMILIE_NO_EMOTION' => 'The smiley “%s” was ignored, as there was no emotion entered.', - 'SMILIE_NO_FILE' => 'The smiley “%s” was ignored, as the file is missing.', - 'SMILIES_EDITED' => array( - 0 => 'No smilies were updated.', - 1 => 'The smiley has been updated successfully.', - 2 => 'The smilies have been updated successfully.', - ), - 'SMILIES_EMOTION' => 'Emotion', - 'SMILIES_HEIGHT' => 'Smiley height', - 'SMILIES_IMAGE' => 'Smiley image', - 'SMILIES_IMPORTED' => 'The smilies pack has been installed successfully.', - 'SMILIES_IMPORT_SUCCESS' => 'The smilies pack was imported successfully.', - 'SMILIES_LOCATION' => 'Smiley location', - 'SMILIES_NOT_DISPLAYED' => 'The following smilies are not displayed on the posting page', - 'SMILIES_ORDER' => 'Smiley order', - 'SMILIES_URL' => 'Smiley image file', - 'SMILIES_WIDTH' => 'Smiley width', - - 'TOO_MANY_SMILIES' => array( - 1 => 'Limit of %d smiley reached.', - 2 => 'Limit of %d smilies reached.', - ), - - 'WRONG_PAK_TYPE' => 'The specified package does not contain the appropriate data.', -)); - -// Word censors -$lang = array_merge($lang, array( - 'ACP_WORDS_EXPLAIN' => 'From this control panel you can add, edit, and remove words that will be automatically censored on your forums. People are still allowed to register with usernames containing these words. Wildcards (*) are accepted in the word field, e.g. *test* will match detestable, test* would match testing, *test would match detest.', - 'ADD_WORD' => 'Add new word', - - 'EDIT_WORD' => 'Edit word censor', - 'ENTER_WORD' => 'You must enter a word and its replacement.', - - 'NO_WORD' => 'No word selected for editing.', - - 'REPLACEMENT' => 'Replacement', - - 'UPDATE_WORD' => 'Update word censor', - - 'WORD' => 'Word', - 'WORD_ADDED' => 'The word censor has been successfully added.', - 'WORD_REMOVED' => 'The selected word censor has been successfully removed.', - 'WORD_UPDATED' => 'The selected word censor has been successfully updated.', -)); - -// Ranks -$lang = array_merge($lang, array( - 'ACP_RANKS_EXPLAIN' => 'Using this form you can add, edit, view and delete ranks. You can also create special ranks which can be applied to a user via the user management facility.', - 'ADD_RANK' => 'Add new rank', - - 'MUST_SELECT_RANK' => 'You must select a rank.', - - 'NO_ASSIGNED_RANK' => 'No special rank assigned.', - 'NO_RANK_TITLE' => 'You haven’t specified a title for the rank.', - 'NO_UPDATE_RANKS' => 'The rank was successfully deleted. However user accounts using this rank were not updated. You will need to manually reset the rank on these accounts.', - - 'RANK_ADDED' => 'The rank was successfully added.', - 'RANK_IMAGE' => 'Rank image', - 'RANK_IMAGE_EXPLAIN' => 'Use this to define a small image associated with the rank. The path is relative to the root phpBB directory.', - 'RANK_IMAGE_IN_USE' => '(In use)', - 'RANK_MINIMUM' => 'Minimum posts', - 'RANK_REMOVED' => 'The rank was successfully deleted.', - 'RANK_SPECIAL' => 'Set as special rank', - 'RANK_TITLE' => 'Rank title', - 'RANK_UPDATED' => 'The rank was successfully updated.', -)); - -// Disallow Usernames -$lang = array_merge($lang, array( - 'ACP_DISALLOW_EXPLAIN' => 'Here you can control usernames which will not be allowed to be used. Disallowed usernames are allowed to contain a wildcard character of *.', - 'ADD_DISALLOW_EXPLAIN' => 'You can disallow a username using the wildcard character * to match any character.', - 'ADD_DISALLOW_TITLE' => 'Add a disallowed username', - - 'DELETE_DISALLOW_EXPLAIN' => 'You can remove a disallowed username by selecting the username from this list and clicking submit.', - 'DELETE_DISALLOW_TITLE' => 'Remove a disallowed username', - 'DISALLOWED_ALREADY' => 'The name you entered is already disallowed.', - 'DISALLOWED_DELETED' => 'The disallowed username has been successfully removed.', - 'DISALLOW_SUCCESSFUL' => 'The disallowed username has been successfully added.', - - 'NO_DISALLOWED' => 'No disallowed usernames', - 'NO_USERNAME_SPECIFIED' => 'You haven’t selected or entered a username to operate with.', -)); - -// Reasons -$lang = array_merge($lang, array( - 'ACP_REASONS_EXPLAIN' => 'Here you can manage the reasons used in reports and denial messages when disapproving posts. There is one default reason (marked with a *) you are not able to remove, this reason is normally used for custom messages if no reason fits.', - 'ADD_NEW_REASON' => 'Add new reason', - 'AVAILABLE_TITLES' => 'Available localised reason titles', - - 'IS_NOT_TRANSLATED' => 'Reason has not been localised.', - 'IS_NOT_TRANSLATED_EXPLAIN' => 'Reason has not been localised. If you want to provide the localised form, specify the correct key from the language files report reasons section.', - 'IS_TRANSLATED' => 'Reason has been localised.', - 'IS_TRANSLATED_EXPLAIN' => 'Reason has been localised. If the title you enter here is specified within the language files report reasons section, the localised form of the title and description will be used.', - - 'NO_REASON' => 'Reason could not be found.', - 'NO_REASON_INFO' => 'You have to specify a title and a description for this reason.', - 'NO_REMOVE_DEFAULT_REASON' => 'You are not able to remove the default reason “Other”.', - - 'REASON_ADD' => 'Add report/denial reason', - 'REASON_ADDED' => 'Report/denial reason successfully added.', - 'REASON_ALREADY_EXIST' => 'A reason with this title already exist, please enter another title for this reason.', - 'REASON_DESCRIPTION' => 'Reason description', - 'REASON_DESC_TRANSLATED' => 'Displayed reason description', - 'REASON_EDIT' => 'Edit report/denial reason', - 'REASON_EDIT_EXPLAIN' => 'Here you are able to add or edit a reason. If the reason is translated the localised version is used instead of the description entered here.', - 'REASON_REMOVED' => 'Report/denial reason successfully removed.', - 'REASON_TITLE' => 'Reason title', - 'REASON_TITLE_TRANSLATED' => 'Displayed reason title', - 'REASON_UPDATED' => 'Report/denial reason successfully updated.', - - 'USED_IN_REPORTS' => 'Used in reports', -)); diff --git a/install/update/new/language/en/acp/profile.php b/install/update/new/language/en/acp/profile.php deleted file mode 100644 index 87c9505..0000000 --- a/install/update/new/language/en/acp/profile.php +++ /dev/null @@ -1,176 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* DO NOT CHANGE -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -if (empty($lang) || !is_array($lang)) -{ - $lang = array(); -} - -// DEVELOPERS PLEASE NOTE -// -// All language files should use UTF-8 as their encoding and the files must not contain a BOM. -// -// Placeholders can now contain order information, e.g. instead of -// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows -// translators to re-order the output of data while ensuring it remains correct -// -// You do not need this where single placeholders are used, e.g. 'Message %d' is fine -// equally where a string contains only two placeholders which are used to wrap text -// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine - -// Custom profile fields -$lang = array_merge($lang, array( - 'ADDED_PROFILE_FIELD' => 'Successfully added custom profile field.', - 'ALPHA_DOTS' => 'Alphanumeric and dots (periods)', - 'ALPHA_ONLY' => 'Alphanumeric only', - 'ALPHA_SPACERS' => 'Alphanumeric and spacers', - 'ALPHA_UNDERSCORE' => 'Alphanumeric and underscores', - 'ALPHA_PUNCTUATION' => 'Alphanumeric with comma, dots, underscore and dashes beginning with a letter', - 'ALWAYS_TODAY' => 'Always the current date', - - 'BOOL_ENTRIES_EXPLAIN' => 'Enter your options now', - 'BOOL_TYPE_EXPLAIN' => 'Define the type, either a checkbox or radio buttons. A checkbox will only be displayed if it is checked for a given user. In that case the second language option will be used. Radio buttons will display regardless of their value.', - - 'CHANGED_PROFILE_FIELD' => 'Successfully changed profile field.', - 'CHARS_ANY' => 'Any character', - 'CHECKBOX' => 'Checkbox', - 'COLUMNS' => 'Columns', - 'CP_LANG_DEFAULT_VALUE' => 'Default value', - 'CP_LANG_EXPLAIN' => 'Field description', - 'CP_LANG_EXPLAIN_EXPLAIN' => 'The explanation for this field presented to the user.', - 'CP_LANG_NAME' => 'Field name/title presented to the user', - 'CP_LANG_OPTIONS' => 'Options', - 'CREATE_NEW_FIELD' => 'Create new field', - 'CUSTOM_FIELDS_NOT_TRANSLATED' => 'At least one custom profile field has not yet been translated. Please enter the required information by clicking on the “Translate” link.', - - 'DEFAULT_ISO_LANGUAGE' => 'Default language [%s]', - 'DEFAULT_LANGUAGE_NOT_FILLED' => 'The language entries for the default language are not filled for this profile field.', - 'DEFAULT_VALUE' => 'Default value', - 'DELETE_PROFILE_FIELD' => 'Remove profile field', - 'DELETE_PROFILE_FIELD_CONFIRM' => 'Are you sure you want to delete this profile field?', - 'DISPLAY_AT_PROFILE' => 'Display in user control panel', - 'DISPLAY_AT_PROFILE_EXPLAIN' => 'The user is able to change this profile field within the user control panel.', - 'DISPLAY_AT_REGISTER' => 'Display on registration screen', - 'DISPLAY_AT_REGISTER_EXPLAIN' => 'If this option is enabled, the field will be displayed on registration.', - 'DISPLAY_ON_MEMBERLIST' => 'Display on memberlist screen', - 'DISPLAY_ON_MEMBERLIST_EXPLAIN' => 'If this option is enabled, the field will be displayed in the user rows on the memberlist screen.', - 'DISPLAY_ON_PM' => 'Display on view private message screen', - 'DISPLAY_ON_PM_EXPLAIN' => 'If this option is enabled, the field will be displayed in the mini-profile on the private message screen.', - 'DISPLAY_ON_VT' => 'Display on viewtopic screen', - 'DISPLAY_ON_VT_EXPLAIN' => 'If this option is enabled, the field will be displayed in the mini-profile on the topic screen.', - 'DISPLAY_PROFILE_FIELD' => 'Publicly display profile field', - 'DISPLAY_PROFILE_FIELD_EXPLAIN' => 'The profile field will be shown in all locations allowed within the load settings. Setting this to “no” will hide the field from topic pages, profiles and the memberlist.', - 'DROPDOWN_ENTRIES_EXPLAIN' => 'Enter your options now, every option in one line.', - - 'EDIT_DROPDOWN_LANG_EXPLAIN' => 'Please note that you are able to change your options text and also able to add new options to the end. It is not advised to add new options between existing options - this could result in wrong options assigned to your users. This can also happen if you remove options in-between. Removing options from the end result in users having assigned this item now reverting back to the default one.', - 'EMPTY_FIELD_IDENT' => 'Empty field identification', - 'EMPTY_USER_FIELD_NAME' => 'Please enter a field name/title', - 'ENTRIES' => 'Entries', - 'EVERYTHING_OK' => 'Everything OK', - - 'FIELD_BOOL' => 'Boolean (Yes/No)', - 'FIELD_CONTACT_DESC' => 'Contact description', - 'FIELD_CONTACT_URL' => 'Contact link', - 'FIELD_DATE' => 'Date', - 'FIELD_DESCRIPTION' => 'Field description', - 'FIELD_DESCRIPTION_EXPLAIN' => 'The explanation for this field presented to the user.', - 'FIELD_DROPDOWN' => 'Dropdown box', - 'FIELD_GOOGLEPLUS' => 'Google+', - 'FIELD_IDENT' => 'Field identification', - 'FIELD_IDENT_ALREADY_EXIST' => 'The chosen field identification already exist. Please choose another name.', - 'FIELD_IDENT_EXPLAIN' => 'The field identification is a name to identify the profile field within the database and the templates.', - 'FIELD_INT' => 'Numbers', - 'FIELD_IS_CONTACT' => 'Display field as a contact field', - 'FIELD_IS_CONTACT_EXPLAIN' => 'Contact fields are displayed within the contact section of the user profile and are displayed differently in the mini profile next to posts and private messages. You can use %s as a placeholder variable which will be replaced by a value provided by the user.', - 'FIELD_LENGTH' => 'Length of input box', - 'FIELD_NOT_FOUND' => 'Profile field not found.', - 'FIELD_STRING' => 'Single text field', - 'FIELD_TEXT' => 'Textarea', - 'FIELD_TYPE' => 'Field type', - 'FIELD_TYPE_EXPLAIN' => 'You are not able to change the field type later.', - 'FIELD_URL' => 'URL (Link)', - 'FIELD_VALIDATION' => 'Field validation', - 'FIRST_OPTION' => 'First option', - - 'HIDE_PROFILE_FIELD' => 'Hide profile field', - 'HIDE_PROFILE_FIELD_EXPLAIN' => 'Hide the profile field from all users except administrators and moderators, who are still able to see this field. If the Display in user control panel option is disabled, the user will not be able to see or change this field and the field can only be changed by administrators.', - - 'INVALID_CHARS_FIELD_IDENT' => 'Field identification can only contain lowercase a-z and _', - 'INVALID_FIELD_IDENT_LEN' => 'Field identification can only be 17 characters long', - 'ISO_LANGUAGE' => 'Language [%s]', - - 'LANG_SPECIFIC_OPTIONS' => 'Language specific options [%s]', - - 'LETTER_NUM_DOTS' => 'Any letters, numbers and dots (periods)', - 'LETTER_NUM_ONLY' => 'Any letters and numbers', - 'LETTER_NUM_PUNCTUATION' => 'Any letters, numbers, comma, dots, underscores and dashes beginning with any letter', - 'LETTER_NUM_SPACERS' => 'Any letters, numbers and spacers', - 'LETTER_NUM_UNDERSCORE' => 'Any letters, numbers and underscores', - - 'MAX_FIELD_CHARS' => 'Maximum number of characters', - 'MAX_FIELD_NUMBER' => 'Highest allowed number', - 'MIN_FIELD_CHARS' => 'Minimum number of characters', - 'MIN_FIELD_NUMBER' => 'Lowest allowed number', - - 'NO_FIELD_ENTRIES' => 'No entries defined', - 'NO_FIELD_ID' => 'No field id specified.', - 'NO_FIELD_TYPE' => 'No Field type specified.', - 'NO_VALUE_OPTION' => 'Option equal to non entered value', - 'NO_VALUE_OPTION_EXPLAIN' => 'Value for a non-entry. If the field is required, the user gets an error if he choose the option selected here.', - 'NUMBERS_ONLY' => 'Only numbers (0-9)', - - 'PROFILE_BASIC_OPTIONS' => 'Basic options', - 'PROFILE_FIELD_ACTIVATED' => 'Profile field successfully activated.', - 'PROFILE_FIELD_DEACTIVATED' => 'Profile field successfully deactivated.', - 'PROFILE_LANG_OPTIONS' => 'Language specific options', - 'PROFILE_TYPE_OPTIONS' => 'Profile type specific options', - - 'RADIO_BUTTONS' => 'Radio buttons', - 'REMOVED_PROFILE_FIELD' => 'Successfully removed profile field.', - 'REQUIRED_FIELD' => 'Required field', - 'REQUIRED_FIELD_EXPLAIN' => 'Force profile field to be filled out or specified by user or administrator. If display at registration screen option is disabled, the field will only be required when the user edits their profile.', - 'ROWS' => 'Rows', - - 'SAVE' => 'Save', - 'SECOND_OPTION' => 'Second option', - 'SHOW_NOVALUE_FIELD' => 'Show field if no value was selected', - 'SHOW_NOVALUE_FIELD_EXPLAIN' => 'Determines if the profile field should be displayed if no value was selected for optional fields or if no value has been selected yet for required fields.', - 'STEP_1_EXPLAIN_CREATE' => 'Here you can enter the first basic parameters of your new profile field. This information is needed for the second step where you’ll be able to set remaining options and tweak your profile field further.', - 'STEP_1_EXPLAIN_EDIT' => 'Here you can change the basic parameters of your profile field. The relevant options are re-calculated within the second step.', - 'STEP_1_TITLE_CREATE' => 'Add profile field', - 'STEP_1_TITLE_EDIT' => 'Edit profile field', - 'STEP_2_EXPLAIN_CREATE' => 'Here you are able to define some common options you may want to adjust.', - 'STEP_2_EXPLAIN_EDIT' => 'Here you are able to change some common options.
Please note that changes to profile fields will not affect existing profile fields entered by your users.', - 'STEP_2_TITLE_CREATE' => 'Profile type specific options', - 'STEP_2_TITLE_EDIT' => 'Profile type specific options', - 'STEP_3_EXPLAIN_CREATE' => 'Since you have more than one board language installed, you have to fill out the remaining language items too. If you don’t, then default language setting for this custom profile field will be used, you are able to fill out the remaining language items later too.', - 'STEP_3_EXPLAIN_EDIT' => 'Since you have more than one board language installed, you now can change or add the remaining language items too. If you don’t, then default language setting for this custom profile field will be used.', - 'STEP_3_TITLE_CREATE' => 'Remaining language definitions', - 'STEP_3_TITLE_EDIT' => 'Language definitions', - 'STRING_DEFAULT_VALUE_EXPLAIN' => 'Enter a default phrase to be displayed, a default value. Leave empty if you want to show it empty at the first place.', - - 'TEXT_DEFAULT_VALUE_EXPLAIN' => 'Enter a default text to be displayed, a default value. Leave empty if you want to show it empty at the first place.', - 'TRANSLATE' => 'Translate', - - 'USER_FIELD_NAME' => 'Field name/title presented to the user', - - 'VISIBILITY_OPTION' => 'Visibility options', -)); diff --git a/install/update/new/language/en/acp/styles.php b/install/update/new/language/en/acp/styles.php deleted file mode 100644 index 44be3c1..0000000 --- a/install/update/new/language/en/acp/styles.php +++ /dev/null @@ -1,91 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* DO NOT CHANGE -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -if (empty($lang) || !is_array($lang)) -{ - $lang = []; -} - -// DEVELOPERS PLEASE NOTE -// -// All language files should use UTF-8 as their encoding and the files must not contain a BOM. -// -// Placeholders can now contain order information, e.g. instead of -// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows -// translators to re-order the output of data while ensuring it remains correct -// -// You do not need this where single placeholders are used, e.g. 'Message %d' is fine -// equally where a string contains only two placeholders which are used to wrap text -// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine - -$lang = array_merge($lang, [ - 'ACP_STYLES_EXPLAIN' => 'Here you can manage the styles available on your board.
Please note you cannot uninstall the “prosilver” style as it is phpBB’s default and primary parent style.', - - 'CANNOT_BE_INSTALLED' => 'Cannot be installed', - 'CONFIRM_UNINSTALL_STYLES' => 'Are you sure you wish to uninstall selected styles?', - 'COPYRIGHT' => 'Copyright', - - 'DEACTIVATE_DEFAULT' => 'You cannot deactivate the default style.', - 'DELETE_FROM_FS' => 'Delete from filesystem', - 'DELETE_STYLE_FILES_FAILED' => 'Error deleting files for style "%s".', - 'DELETE_STYLE_FILES_SUCCESS' => 'Files for style "%s" have been deleted.', - 'DETAILS' => 'Details', - - 'INHERITING_FROM' => 'Inherits from', - 'INSTALL_STYLE' => 'Install style', - 'INSTALL_STYLES' => 'Install styles', - 'INSTALL_STYLES_EXPLAIN' => 'Here you can install new styles.
If you cannot find a specific style in list below, check to make sure style is already installed. If it is not installed, check if it was uploaded correctly.', - 'INVALID_STYLE_ID' => 'Invalid style ID.', - - 'NO_MATCHING_STYLES_FOUND' => 'No styles match your query.', - 'NO_UNINSTALLED_STYLE' => 'No uninstalled styles detected.', - - 'PURGED_CACHE' => 'Cache was purged.', - - 'REQUIRES_STYLE' => 'This style requires the style "%s" to be installed.', - - 'STYLE_ACTIVATE' => 'Activate', - 'STYLE_ACTIVE' => 'Active', - 'STYLE_DEACTIVATE' => 'Deactivate', - 'STYLE_DEFAULT' => 'Make default style', - 'STYLE_DEFAULT_CHANGE_INACTIVE' => 'You must activate style before making it default style.', - 'STYLE_ERR_INVALID_PARENT' => 'Invalid parent style.', - 'STYLE_ERR_NAME_EXIST' => 'A style with that name already exists.', - 'STYLE_ERR_STYLE_NAME' => 'You must supply a name for this style.', - 'STYLE_INSTALLED' => 'Style "%s" has been installed.', - 'STYLE_INSTALLED_RETURN_INSTALLED_STYLES' => 'Return to installed styles list', - 'STYLE_INSTALLED_RETURN_UNINSTALLED_STYLES' => 'Install more styles', - 'STYLE_NAME' => 'Style name', - 'STYLE_NAME_RESERVED' => 'Style "%s" can not be installed, because the name is reserved.', - 'STYLE_NOT_INSTALLED' => 'Style "%s" was not installed.', - 'STYLE_PATH' => 'Style path', - 'STYLE_UNINSTALL' => 'Uninstall', - 'STYLE_UNINSTALL_DEPENDENT' => 'Style "%s" cannot be uninstalled because it has one or more child styles.', - 'STYLE_UNINSTALLED' => 'Style "%s" uninstalled successfully.', - 'STYLE_PHPBB_VERSION' => 'phpBB Version', - 'STYLE_USED_BY' => 'Used by (including robots)', - 'STYLE_VERSION' => 'Style version', - - 'UNINSTALL_PROSILVER' => 'You cannot uninstall the style “prosilver”.', - 'UNINSTALL_DEFAULT' => 'You cannot uninstall the default style.', - - 'BROWSE_STYLES_DATABASE' => 'Browse styles database', -]); diff --git a/install/update/new/language/en/captcha_recaptcha.php b/install/update/new/language/en/captcha_recaptcha.php deleted file mode 100644 index 68546ae..0000000 --- a/install/update/new/language/en/captcha_recaptcha.php +++ /dev/null @@ -1,52 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* DO NOT CHANGE -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -if (empty($lang) || !is_array($lang)) -{ - $lang = array(); -} - -// DEVELOPERS PLEASE NOTE -// -// All language files should use UTF-8 as their encoding and the files must not contain a BOM. -// -// Placeholders can now contain order information, e.g. instead of -// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows -// translators to re-order the output of data while ensuring it remains correct -// -// You do not need this where single placeholders are used, e.g. 'Message %d' is fine -// equally where a string contains only two placeholders which are used to wrap text -// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine - -$lang = array_merge($lang, array( - 'RECAPTCHA_LANG' => 'en-GB', // Find the language/country code on https://developers.google.com/recaptcha/docs/language - If no code exists for your language you can use "en" or leave the string empty - 'RECAPTCHA_NOT_AVAILABLE' => 'In order to use reCaptcha, you must create an account on www.google.com/recaptcha.', - 'CAPTCHA_RECAPTCHA' => 'reCaptcha', - 'RECAPTCHA_INCORRECT' => 'The solution you provided was incorrect', - 'RECAPTCHA_NOSCRIPT' => 'Please enable JavaScript in your browser to load the challenge.', - - 'RECAPTCHA_PUBLIC' => 'Site key', - 'RECAPTCHA_PUBLIC_EXPLAIN' => 'Your site reCAPTCHA key. Keys can be obtained on www.google.com/recaptcha. Please, use reCAPTCHA v2 > Invisible reCAPTCHA badge type.', - 'RECAPTCHA_PRIVATE' => 'Secret key', - 'RECAPTCHA_PRIVATE_EXPLAIN' => 'Your secret reCAPTCHA key. Keys can be obtained on www.google.com/recaptcha. Please, use reCAPTCHA v2 > Invisible reCAPTCHA badge type.', - - 'RECAPTCHA_INVISIBLE' => 'This CAPTCHA is actually invisible. To verify that it works, a small icon should appear in right bottom corner of this page.', -)); diff --git a/install/update/new/language/en/cli.php b/install/update/new/language/en/cli.php deleted file mode 100644 index 122010d..0000000 --- a/install/update/new/language/en/cli.php +++ /dev/null @@ -1,175 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* DO NOT CHANGE -*/ -if (empty($lang) || !is_array($lang)) -{ - $lang = array(); -} - -// DEVELOPERS PLEASE NOTE -// -// Placeholders can now contain order information, e.g. instead of -// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows -// translators to re-order the output of data while ensuring it remains correct -// -// You do not need this where single placeholders are used, e.g. 'Message %d' is fine -// equally where a string contains only two placeholders which are used to wrap text -// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine - -$lang = array_merge($lang, array( - 'CLI_CONFIG_CANNOT_CACHED' => 'Set this option if the configuration option changes too frequently to be efficiently cached.', - 'CLI_CONFIG_CURRENT' => 'Current configuration value, use 0 and 1 to specify boolean values', - 'CLI_CONFIG_DELETE_SUCCESS' => 'Successfully deleted config %s.', - 'CLI_CONFIG_NEW' => 'New configuration value, use 0 and 1 to specify boolean values', - 'CLI_CONFIG_NOT_EXISTS' => 'Config %s does not exist', - 'CLI_CONFIG_OPTION_NAME' => 'The configuration option’s name', - 'CLI_CONFIG_PRINT_WITHOUT_NEWLINE' => 'Set this option if the value should be printed without a new line at the end.', - 'CLI_CONFIG_INCREMENT_BY' => 'Amount to increment by', - 'CLI_CONFIG_INCREMENT_SUCCESS' => 'Successfully incremented config %s', - 'CLI_CONFIG_SET_FAILURE' => 'Could not set config %s', - 'CLI_CONFIG_SET_SUCCESS' => 'Successfully set config %s', - - 'CLI_DESCRIPTION_CRON_LIST' => 'Prints a list of ready and unready cron jobs.', - 'CLI_DESCRIPTION_CRON_RUN' => 'Runs all ready cron tasks.', - 'CLI_DESCRIPTION_CRON_RUN_ARGUMENT_1' => 'Name of the task to be run', - 'CLI_DESCRIPTION_DB_LIST' => 'List all installed and available migrations.', - 'CLI_DESCRIPTION_DB_MIGRATE' => 'Updates the database by applying migrations.', - 'CLI_DESCRIPTION_DB_REVERT' => 'Revert a migration.', - 'CLI_DESCRIPTION_DELETE_CONFIG' => 'Deletes a configuration option', - 'CLI_DESCRIPTION_DISABLE_EXTENSION' => 'Disables the specified extension.', - 'CLI_DESCRIPTION_ENABLE_EXTENSION' => 'Enables the specified extension.', - 'CLI_DESCRIPTION_FIND_MIGRATIONS' => 'Finds migrations that are not depended upon.', - 'CLI_DESCRIPTION_FIX_LEFT_RIGHT_IDS' => 'Repairs the tree structure of the forums and modules.', - 'CLI_DESCRIPTION_GET_CONFIG' => 'Gets a configuration option’s value', - 'CLI_DESCRIPTION_INCREMENT_CONFIG' => 'Increments a configuration option’s integer value', - 'CLI_DESCRIPTION_LIST_EXTENSIONS' => 'Lists all extensions in the database and on the filesystem.', - - 'CLI_DESCRIPTION_OPTION_ENV' => 'The Environment name.', - 'CLI_DESCRIPTION_OPTION_SAFE_MODE' => 'Run in Safe Mode (without extensions).', - 'CLI_DESCRIPTION_OPTION_SHELL' => 'Launch the shell.', - - 'CLI_DESCRIPTION_PURGE_EXTENSION' => 'Purges the specified extension.', - - 'CLI_DESCRIPTION_REPARSER_LIST' => 'Lists the types of text that can be reparsed.', - 'CLI_DESCRIPTION_REPARSER_AVAILABLE' => 'Available reparsers:', - 'CLI_DESCRIPTION_REPARSER_REPARSE' => 'Reparses stored text with the current text_formatter services.', - 'CLI_DESCRIPTION_REPARSER_REPARSE_ARG_1' => 'Type of text to reparse. Leave blank to reparse everything.', - 'CLI_DESCRIPTION_REPARSER_REPARSE_OPT_DRY_RUN' => 'Do not save any changes; just print what would happen', - 'CLI_DESCRIPTION_REPARSER_REPARSE_OPT_RANGE_MIN' => 'Lowest record ID to process', - 'CLI_DESCRIPTION_REPARSER_REPARSE_OPT_RANGE_MAX' => 'Highest record ID to process', - 'CLI_DESCRIPTION_REPARSER_REPARSE_OPT_RANGE_SIZE' => 'Approximate number of records to process at a time', - 'CLI_DESCRIPTION_REPARSER_REPARSE_OPT_RESUME' => 'Start reparsing where the last execution stopped', - - 'CLI_DESCRIPTION_SET_ATOMIC_CONFIG' => 'Sets a configuration option’s value only if the old matches the current value', - 'CLI_DESCRIPTION_SET_CONFIG' => 'Sets a configuration option’s value', - - 'CLI_DESCRIPTION_THUMBNAIL_DELETE' => 'Delete all existing thumbnails.', - 'CLI_DESCRIPTION_THUMBNAIL_GENERATE' => 'Generate all missing thumbnails.', - 'CLI_DESCRIPTION_THUMBNAIL_RECREATE' => 'Recreate all thumbnails.', - - 'CLI_DESCRIPTION_UPDATE_CHECK' => 'Check if the board is up to date.', - 'CLI_DESCRIPTION_UPDATE_CHECK_ARGUMENT_1' => 'Name of the extension to check (if all, checks all the extensions)', - 'CLI_DESCRIPTION_UPDATE_CHECK_OPTION_CACHE' => 'Run check command with cache.', - 'CLI_DESCRIPTION_UPDATE_CHECK_OPTION_STABILITY' => 'Run command choosing to check only stable or unstable versions.', - - 'CLI_DESCRIPTION_UPDATE_HASH_BCRYPT' => 'Updates outdated password hashes to be hashed with bcrypt.', - - 'CLI_ERROR_INVALID_STABILITY' => '"%s" needs to be set to "stable" or "unstable".', - - 'CLI_DESCRIPTION_USER_ACTIVATE' => 'Activate (or deactivate) a user account.', - 'CLI_DESCRIPTION_USER_ACTIVATE_USERNAME' => 'Username of the account to activate.', - 'CLI_DESCRIPTION_USER_ACTIVATE_DEACTIVATE' => 'Deactivate the user’s account', - 'CLI_DESCRIPTION_USER_ACTIVATE_ACTIVE' => 'The user is already active.', - 'CLI_DESCRIPTION_USER_ACTIVATE_INACTIVE' => 'The user is already inactive.', - 'CLI_DESCRIPTION_USER_ADD' => 'Add a new user.', - 'CLI_DESCRIPTION_USER_ADD_OPTION_USERNAME' => 'Username of the new user', - 'CLI_DESCRIPTION_USER_ADD_OPTION_PASSWORD' => 'Password of the new user', - 'CLI_DESCRIPTION_USER_ADD_OPTION_EMAIL' => 'E-mail address of the new user', - 'CLI_DESCRIPTION_USER_ADD_OPTION_NOTIFY' => 'Send account activation email to the new user (not sent by default)', - 'CLI_DESCRIPTION_USER_DELETE' => 'Delete a user account.', - 'CLI_DESCRIPTION_USER_DELETE_USERNAME' => 'Username of the user to delete', - 'CLI_DESCRIPTION_USER_DELETE_OPTION_POSTS' => 'Delete all posts by the user. Without this option, the user’s posts will be retained.', - 'CLI_DESCRIPTION_USER_RECLEAN' => 'Re-clean usernames.', - - 'CLI_EXTENSION_DISABLE_FAILURE' => 'Could not disable extension %s', - 'CLI_EXTENSION_DISABLE_SUCCESS' => 'Successfully disabled extension %s', - 'CLI_EXTENSION_DISABLED' => 'Extension %s is not enabled', - 'CLI_EXTENSION_ENABLE_FAILURE' => 'Could not enable extension %s', - 'CLI_EXTENSION_ENABLE_SUCCESS' => 'Successfully enabled extension %s', - 'CLI_EXTENSION_ENABLED' => 'Extension %s is already enabled', - 'CLI_EXTENSION_NOT_EXIST' => 'Extension %s does not exist', - 'CLI_EXTENSION_NAME' => 'Name of the extension', - 'CLI_EXTENSION_PURGE_FAILURE' => 'Could not purge extension %s', - 'CLI_EXTENSION_PURGE_SUCCESS' => 'Successfully purged extension %s', - 'CLI_EXTENSION_UPDATE_FAILURE' => 'Could not update extension %s', - 'CLI_EXTENSION_UPDATE_SUCCESS' => 'Successfully updated extension %s', - 'CLI_EXTENSION_NOT_FOUND' => 'No extensions were found.', - 'CLI_EXTENSION_NOT_ENABLEABLE' => 'Extension %s is not enableable.', - 'CLI_EXTENSIONS_AVAILABLE' => 'Available', - 'CLI_EXTENSIONS_DISABLED' => 'Disabled', - 'CLI_EXTENSIONS_ENABLED' => 'Enabled', - - 'CLI_FIXUP_FIX_LEFT_RIGHT_IDS_SUCCESS' => 'Successfully repaired the tree structure of the forums and modules.', - 'CLI_FIXUP_UPDATE_HASH_BCRYPT_SUCCESS' => 'Successfully updated outdated password hashes to bcrypt.', - - 'CLI_MIGRATION_NAME' => 'Migration name, including the namespace (use forward slashes instead of backslashes to avoid problems).', - 'CLI_MIGRATIONS_AVAILABLE' => 'Available migrations', - 'CLI_MIGRATIONS_INSTALLED' => 'Installed migrations', - 'CLI_MIGRATIONS_ONLY_AVAILABLE' => 'Show only available migrations', - 'CLI_MIGRATIONS_EMPTY' => 'No migrations.', - - 'CLI_REPARSER_REPARSE_REPARSING' => 'Reparsing %1$s (range %2$d..%3$d)', - 'CLI_REPARSER_REPARSE_REPARSING_START' => 'Reparsing %s...', - 'CLI_REPARSER_REPARSE_SUCCESS' => 'Reparsing ended with success', - - // In all the case %1$s is the logical name of the file and %2$s the real name on the filesystem - // eg: big_image.png (2_a51529ae7932008cf8454a95af84cacd) generated. - 'CLI_THUMBNAIL_DELETED' => '%1$s (%2$s) deleted.', - 'CLI_THUMBNAIL_DELETING' => 'Deleting thumbnails', - 'CLI_THUMBNAIL_SKIPPED' => '%1$s (%2$s) skipped.', - 'CLI_THUMBNAIL_GENERATED' => '%1$s (%2$s) generated.', - 'CLI_THUMBNAIL_GENERATING' => 'Generating thumbnails', - 'CLI_THUMBNAIL_GENERATING_DONE' => 'All thumbnails have been regenerated.', - 'CLI_THUMBNAIL_DELETING_DONE' => 'All thumbnails have been deleted.', - - 'CLI_THUMBNAIL_NOTHING_TO_GENERATE' => 'No thumbnails to generate.', - 'CLI_THUMBNAIL_NOTHING_TO_DELETE' => 'No thumbnails to delete.', - - 'CLI_USER_ADD_SUCCESS' => 'Successfully added user %s.', - 'CLI_USER_DELETE_CONFIRM' => 'Are you sure you want to delete ‘%s’? [y/N]', - 'CLI_USER_RECLEAN_START' => 'Re-cleaning usernames', - 'CLI_USER_RECLEAN_DONE' => [ - 0 => 'Re-cleaning complete. No usernames needed to be cleaned.', - 1 => 'Re-cleaning complete. %d username was cleaned.', - 2 => 'Re-cleaning complete. %d usernames were cleaned.', - ], -)); - -// Additional help for commands. -$lang = array_merge($lang, array( - 'CLI_HELP_CRON_RUN' => $lang['CLI_DESCRIPTION_CRON_RUN'] . ' Optionally you can specify a cron task name to run only the specified cron task.', - 'CLI_HELP_USER_ACTIVATE' => 'Activate a user account, or deactivate an account using the --deactivate option. -To optionally send an activation email to the user, use the --send-email option.', - 'CLI_HELP_USER_ADD' => 'The %command.name% command adds a new user: -If this command is run without options, you will be prompted to enter them. -To optionally send an email to the new user, use the --send-email option.', - 'CLI_HELP_USER_RECLEAN' => 'Re-clean usernames will check all stored usernames and ensure clean versions are also stored. Cleaned usernames are a case insensitive form, NFC normalized and transformed to ASCII.', -)); diff --git a/install/update/new/language/en/common.php b/install/update/new/language/en/common.php deleted file mode 100644 index 31914cf..0000000 --- a/install/update/new/language/en/common.php +++ /dev/null @@ -1,1453 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* DO NOT CHANGE -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -if (empty($lang) || !is_array($lang)) -{ - $lang = array(); -} - -// DEVELOPERS PLEASE NOTE -// -// All language files should use UTF-8 as their encoding and the files must not contain a BOM. -// -// Placeholders can now contain order information, e.g. instead of -// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows -// translators to re-order the output of data while ensuring it remains correct -// -// You do not need this where single placeholders are used, e.g. 'Message %d' is fine -// equally where a string contains only two placeholders which are used to wrap text -// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine -// -// Some characters you may want to copy&paste: -// ’ » “ ” … -// - -$lang = array_merge($lang, array( - 'TRANSLATION_INFO' => '', - 'DIRECTION' => 'ltr', - 'DATE_FORMAT' => '|d M Y|', // 01 Jan 2007 (with Relative days enabled) - 'DATETIME_FORMAT' => '|d M Y, H:i|', // 01 Jan 2007, 13:37 (with Relative days enabled) - 'USER_LANG' => 'en-gb', - - // You can define different rules for the determination of plural forms here. - // See https://area51.phpbb.com/docs/dev/32x/language/plurals.html for more information - // or ask the translation manager for help. - 'PLURAL_RULE' => 1, - - '1_DAY' => '1 day', - '1_MONTH' => '1 month', - '1_YEAR' => '1 year', - '2_WEEKS' => '2 weeks', - '3_MONTHS' => '3 months', - '6_MONTHS' => '6 months', - '7_DAYS' => '7 days', - - 'ACCOUNT_ALREADY_ACTIVATED' => 'Your account has already been activated.', - 'ACCOUNT_DEACTIVATED' => 'Your account has been manually deactivated and is only able to be reactivated by an administrator.', - 'ACP' => 'Administration Control Panel', - 'ACP_SHORT' => 'ACP', - 'ACTIVE' => 'active', - 'ACTIVE_ERROR' => 'The specified username is currently inactive. If you have problems activating your account, please contact a board administrator.', - 'ADMINISTRATOR' => 'Administrator', - 'ADMINISTRATORS' => 'Administrators', - 'AGE' => 'Age', - 'AIM' => 'AIM', - 'AJAX_ERROR_TITLE' => 'AJAX error', - 'AJAX_ERROR_TEXT' => 'Something went wrong when processing your request.', - 'AJAX_ERROR_TEXT_ABORT' => 'User aborted request.', - 'AJAX_ERROR_TEXT_TIMEOUT' => 'Your request timed out; please try again.', - 'AJAX_ERROR_TEXT_PARSERERROR' => 'Something went wrong with the request and the server returned an invalid reply.', - 'ALLOWED' => 'Allowed', - 'ALL_FILES' => 'All files', - 'ALL_FORUMS' => 'All forums', - 'ALL_MESSAGES' => 'All messages', - 'ALL_POSTS' => 'All posts', - 'ALL_TIMES' => 'All times are %1$s', - 'ALL_TOPICS' => 'All Topics', - 'ALT_TEXT' => 'Alternative text', - 'AND' => 'And', - 'ARE_WATCHING_FORUM' => 'You have subscribed to be notified of new posts in this forum.', - 'ARE_WATCHING_TOPIC' => 'You have subscribed to be notified of new posts in this topic.', - 'ASCENDING' => 'Ascending', - 'ATTACHMENTS' => 'Attachments', - 'ATTACHED_IMAGE_NOT_IMAGE' => 'The image file you tried to attach is invalid.', - 'AUTHOR' => 'Author', - 'AUTH_NO_PROFILE_CREATED' => 'The creation of a user profile was unsuccessful.', - 'AUTH_PROVIDER_OAUTH_ERROR_ALREADY_LINKED' => 'This external service is already associated with another board account.', - 'AUTH_PROVIDER_OAUTH_ERROR_INVALID_ENTRY' => 'Invalid database entry.', - 'AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE' => 'Invalid service type provided to OAuth service handler.', - 'AUTH_PROVIDER_OAUTH_ERROR_REQUEST' => 'Something went wrong when processing your OAuth request.', - 'AUTH_PROVIDER_OAUTH_ERROR_SERVICE_NOT_CREATED' => 'OAuth service not created', - 'AUTH_PROVIDER_OAUTH_SERVICE_BITLY' => 'Bitly', - 'AUTH_PROVIDER_OAUTH_SERVICE_FACEBOOK' => 'Facebook', - 'AUTH_PROVIDER_OAUTH_SERVICE_GOOGLE' => 'Google', - 'AUTH_PROVIDER_OAUTH_SERVICE_TWITTER' => 'Twitter', - 'AUTH_PROVIDER_OAUTH_TOKEN_ERROR_NOT_STORED' => 'OAuth token not stored.', - 'AUTH_PROVIDER_OAUTH_TOKEN_ERROR_INCORRECTLY_STORED' => 'OAuth token incorrectly stored.', - 'AVATAR_DISALLOWED_CONTENT' => 'The upload was rejected because the uploaded file was identified as a possible attack vector.', - 'AVATAR_DISALLOWED_EXTENSION' => 'This file cannot be displayed because the extension %s is not allowed.', - 'AVATAR_EMPTY_REMOTE_DATA' => 'The specified avatar could not be uploaded because the remote data appears to be invalid or corrupted.', - 'AVATAR_EMPTY_FILEUPLOAD' => 'The uploaded avatar file is empty.', - 'AVATAR_INVALID_FILENAME' => '%s is an invalid filename.', - 'AVATAR_NOT_UPLOADED' => 'Avatar could not be uploaded.', - 'AVATAR_NO_TEMP_DIR' => 'Temporary folder could not be found or is not writable.', - 'AVATAR_NO_SIZE' => 'The width or height of the linked avatar could not be determined. Please enter them manually.', - 'AVATAR_PARTIAL_UPLOAD' => 'The specified file was only partially uploaded.', - 'AVATAR_PHP_SIZE_NA' => 'The avatar’s filesize is too large.
The maximum allowed filesize set in php.ini could not be determined.', - 'AVATAR_PHP_SIZE_OVERRUN' => 'The avatar’s filesize is too large. The maximum allowed upload size is %1$d %2$s.
Please note this is set in php.ini and cannot be overridden.', - 'AVATAR_REMOTE_UPLOAD_TIMEOUT' => 'The specified avatar could not be uploaded because the request timed out.', - 'AVATAR_PHP_UPLOAD_STOPPED' => 'A PHP extension has stopped the file upload.', - 'AVATAR_URL_INVALID' => 'The URL you specified is invalid.', - 'AVATAR_URL_NOT_FOUND' => 'The file specified could not be found.', - 'AVATAR_WRONG_FILESIZE' => 'The avatar’s filesize must be between 0 and %1$d %2$s.', - 'AVATAR_WRONG_SIZE' => 'The submitted avatar is %5$s wide and %6$s high. Avatars must be at least %1$s wide and %2$s high, but no larger than %3$s wide and %4$s high.', - - 'BACK_TO_TOP' => 'Top', - 'BACK_TO_PREV' => 'Back to previous page', - 'BAN_TRIGGERED_BY_EMAIL'=> 'A ban has been issued on your email address.', - 'BAN_TRIGGERED_BY_IP' => 'A ban has been issued on your IP address.', - 'BAN_TRIGGERED_BY_USER' => 'A ban has been issued on your username.', - 'BBCODE_GUIDE' => 'BBCode guide', - 'BCC' => 'BCC', - 'BIRTHDAYS' => 'Birthdays', - 'BOARD_BAN_PERM' => 'You have been permanently banned from this board.

Please contact the %2$sBoard Administrator%3$s for more information.', - 'BOARD_BAN_REASON' => 'Reason given for ban: %s', - 'BOARD_BAN_TIME' => 'You have been banned from this board until %1$s.

Please contact the %2$sBoard Administrator%3$s for more information.', - 'BOARD_DISABLE' => 'Sorry but this board is currently unavailable.', - 'BOARD_DISABLED' => 'This board is currently disabled.', - 'BOARD_UNAVAILABLE' => 'Sorry but the board is temporarily unavailable, please try again in a few minutes.', - 'BROWSING_FORUM' => 'Users browsing this forum: %1$s', - 'BROWSING_FORUM_GUESTS' => array( - 1 => 'Users browsing this forum: %2$s and %1$d guest', - 2 => 'Users browsing this forum: %2$s and %1$d guests', - ), - 'BUTTON_DELETE' => 'Delete', - 'BUTTON_EDIT' => 'Edit', - 'BUTTON_FORUM_LOCKED' => 'Locked', - 'BUTTON_INFORMATION' => 'Information', - 'BUTTON_NEW_TOPIC' => 'New Topic', - 'BUTTON_PM' => 'PM', - 'BUTTON_PM_FORWARD' => 'Forward', - 'BUTTON_PM_NEW' => 'New PM', - 'BUTTON_PM_REPLY' => 'Send Reply', - 'BUTTON_PM_REPLY_ALL' => 'Reply All', - 'BUTTON_POST_REPLY' => 'Post Reply', - 'BUTTON_QUOTE' => 'Quote', - 'BUTTON_REPORT' => 'Report', - 'BUTTON_TOPIC_LOCKED' => 'Locked', - 'BUTTON_WARN' => 'Warn', - 'BYTES' => 'Bytes', - 'BYTES_SHORT' => 'B', - - 'CANCEL' => 'Cancel', - 'CHANGE' => 'Change', - 'CHANGE_FONT_SIZE' => 'Change font size', - 'CHANGING_PREFERENCES' => 'Changing board preferences', - 'CHANGING_PROFILE' => 'Changing profile settings', - 'CHARACTERS' => array( - 1 => '%d character', - 2 => '%d characters', - ), - 'COLLAPSE_VIEW' => 'Collapse view', - 'CLOSE_WINDOW' => 'Close window', - 'COLOUR_SWATCH' => 'Colour swatch', - 'COLON' => ':', - 'COMMA_SEPARATOR' => ', ', // Comma used to join lists into a single string, use localised comma if appropriate, eg: Ideographic or Arabic - 'CONFIRM' => 'Confirm', - 'CONFIRM_CODE' => 'Confirmation code', - 'CONFIRM_CODE_EXPLAIN' => 'Enter the code exactly as it appears. All letters are case insensitive.', - 'CONFIRM_CODE_WRONG' => 'The confirmation code you entered was incorrect.', - 'CONFIRM_OPERATION' => 'Are you sure you wish to carry out this operation?', - 'CONFIRM_AVATAR_DELETE' => 'Are you sure you wish to delete this avatar?', - 'CONGRATULATIONS' => 'Congratulations to', - 'CONNECTION_FAILED' => 'Connection failed.', - 'CONNECTION_SUCCESS' => 'Connection was successful!', - 'CONTACT' => 'Contact', - 'CONTACT_USER' => 'Contact %s', - 'CONTACT_US' => 'Contact us', - 'COOKIE_CONSENT_INFO' => 'Learn more', - 'COOKIE_CONSENT_MSG' => 'This website uses cookies to ensure you get the best experience on our website.', - 'COOKIE_CONSENT_OK' => 'Got it!', - 'COOKIE_CONSENT_HREF' => 'http://cookiesandyou.com', - 'COOKIES_DELETED' => 'All board cookies successfully deleted.', - 'CURRENT_TIME' => 'It is currently %s', - - 'DAY' => 'Day', - 'DAYS' => 'Days', - 'DELETE' => 'Delete', - 'DELETE_ALL' => 'Delete all', - 'DELETE_COOKIES' => 'Delete cookies', - 'DELETE_MARKED' => 'Delete marked', - 'DELETE_POST' => 'Delete post', - 'DELIMITER' => 'Delimiter', - 'DESCENDING' => 'Descending', - 'DISABLED' => 'Disabled', - 'DISPLAY' => 'Display', - 'DISPLAY_GUESTS' => 'Display guests', - 'DISPLAY_MESSAGES' => 'Display messages from previous', - 'DISPLAY_POSTS' => 'Display posts from previous', - 'DISPLAY_TOPICS' => 'Display topics from previous', - 'DOWNLOADED' => 'Downloaded', - 'DOWNLOADING_FILE' => 'Downloading file', - 'DOWNLOAD_COUNTS' => array( - 0 => 'Not downloaded yet', - 1 => 'Downloaded %d time', - 2 => 'Downloaded %d times', - ), - - 'EDIT_POST' => 'Edit post', - 'ELLIPSIS' => '…', - 'EMAIL' => 'Email', // Short form for EMAIL_ADDRESS - 'EMAIL_ADDRESS' => 'Email address', - 'EMAIL_INVALID_EMAIL' => 'The email address you entered is invalid.', - 'EMAIL_SMTP_ERROR_RESPONSE' => 'Ran into problems sending email at Line %1$s. Response: %2$s.', - 'EMPTY_SUBJECT' => 'You must specify a subject when posting a new topic.', - 'EMPTY_MESSAGE_SUBJECT' => 'You must specify a subject when composing a new message.', - 'ENABLED' => 'Enabled', - 'ENCLOSURE' => 'Enclosure', - 'ENTER_USERNAME' => 'Enter username', - 'ERR_CHANGING_DIRECTORY' => 'Unable to change directory.', - 'ERR_CONNECTING_SERVER' => 'Error connecting to the server.', - 'ERR_JAB_AUTH' => 'Could not authorise on Jabber server.', - 'ERR_JAB_CONNECT' => 'Could not connect to Jabber server.', - 'ERR_UNABLE_TO_LOGIN' => 'The specified username or password is incorrect.', - 'ERR_UNWATCHING' => 'An error occurred while trying to unsubscribe.', - 'ERR_WATCHING' => 'An error occurred while trying to subscribe.', - 'ERR_WRONG_PATH_TO_PHPBB' => 'The phpBB path specified appears to be invalid.', - 'ERROR' => 'Error', - 'EXPAND_VIEW' => 'Expand view', - 'EXTENSION' => 'Extension', - 'EXTENSION_DISABLED' => 'The extension %s is not enabled.', - 'EXTENSION_DISABLED_AFTER_POSTING' => 'The extension %s has been deactivated and can no longer be displayed.', - 'EXTENSION_DOES_NOT_EXIST' => 'The extension %s does not exist.', - - 'FACEBOOK' => 'Facebook', - 'FAQ' => 'FAQ', - 'FAQ_EXPLAIN' => 'Frequently Asked Questions', - 'FEATURE_NOT_AVAILABLE' => 'The requested feature is not available on this board.', - 'FILENAME' => 'Filename', - 'FILESIZE' => 'File size', - 'FILEDATE' => 'File date', - 'FILE_COMMENT' => 'File comment', - 'FILE_CONTENT_ERR' => 'Could not read the contents of file: %s', - 'FILE_JSON_DECODE_ERR' => 'Failed to decode json file: %s', - 'FILE_NOT_FOUND' => 'The requested file could not be found: %s', - 'FIND_USERNAME' => 'Find a member', - 'FOLDER' => 'Folder', - 'FORGOT_PASS' => 'I forgot my password', - 'FORM_INVALID' => 'The submitted form was invalid. Try submitting again.', - 'FORUM' => 'Forum', - 'FORUMS' => 'Forums', - 'FORUMS_MARKED' => 'Forums have been marked read.', - 'FORUM_CAT' => 'Forum category', - 'FORUM_INDEX' => 'Board index', - 'FORUM_LINK' => 'Forum link', - 'FORUM_LOCATION' => 'Forum location', - 'FORUM_LOCKED' => 'Forum locked', - 'FORUM_RULES' => 'Forum rules', - 'FORUM_RULES_LINK' => 'Please click here to view the forum rules', - 'FROM' => 'from', - 'FSOCK_DISABLED' => 'The operation could not be completed because the fsockopen function has been disabled or the server being queried could not be found.', - 'FSOCK_TIMEOUT' => 'A timeout occurred while reading from the network stream.', - - 'FILESYSTEM_CANNOT_CHANGE_FILE_GROUP' => 'Unable to change file group', - 'FILESYSTEM_CANNOT_CHANGE_FILE_PERMISSIONS' => 'Unable to change file permissions', - 'FILESYSTEM_CANNOT_COPY_FILES' => 'Unable to copy files', - 'FILESYSTEM_CANNOT_CREATE_SYMLINK' => 'Unable to create a symlink', - 'FILESYSTEM_CANNOT_CREATE_DIRECTORY' => 'Unable to create directory', - 'FILESYSTEM_CANNOT_DELETE_FILES' => 'Unable to delete files from the system', - 'FILESYSTEM_CANNOT_DUMP_FILE' => 'Unable to dump into file', - 'FILESYSTEM_CANNOT_MIRROR_DIRECTORY' => 'Unable to mirror directory', - 'FILESYSTEM_CANNOT_RENAME_FILE' => 'Unable to rename a file from the system', - 'FILESYSTEM_CANNOT_TOUCH_FILES' => 'Unable to create file or change file timestamps', - - 'FTP_FSOCK_HOST' => 'FTP host', - 'FTP_FSOCK_HOST_EXPLAIN' => 'FTP server used to connect your site.', - 'FTP_FSOCK_PASSWORD' => 'FTP password', - 'FTP_FSOCK_PASSWORD_EXPLAIN' => 'Password for your FTP username.', - 'FTP_FSOCK_PORT' => 'FTP port', - 'FTP_FSOCK_PORT_EXPLAIN' => 'Port used to connect to your server.', - 'FTP_FSOCK_ROOT_PATH' => 'Path to phpBB', - 'FTP_FSOCK_ROOT_PATH_EXPLAIN' => 'Path from the root to your phpBB board.', - 'FTP_FSOCK_TIMEOUT' => 'FTP timeout', - 'FTP_FSOCK_TIMEOUT_EXPLAIN' => 'The amount of time, in seconds, that the system will wait for a reply from your server.', - 'FTP_FSOCK_USERNAME' => 'FTP username', - 'FTP_FSOCK_USERNAME_EXPLAIN' => 'Username used to connect to your server.', - - 'FTP_HOST' => 'FTP host', - 'FTP_HOST_EXPLAIN' => 'FTP server used to connect your site.', - 'FTP_PASSWORD' => 'FTP password', - 'FTP_PASSWORD_EXPLAIN' => 'Password for your FTP username.', - 'FTP_PORT' => 'FTP port', - 'FTP_PORT_EXPLAIN' => 'Port used to connect to your server.', - 'FTP_ROOT_PATH' => 'Path to phpBB', - 'FTP_ROOT_PATH_EXPLAIN' => 'Path from the root to your phpBB board.', - 'FTP_TIMEOUT' => 'FTP timeout', - 'FTP_TIMEOUT_EXPLAIN' => 'The amount of time, in seconds, that the system will wait for a reply from your server.', - 'FTP_USERNAME' => 'FTP username', - 'FTP_USERNAME_EXPLAIN' => 'Username used to connect to your server.', - - 'GENERAL_ERROR' => 'General Error', - 'GB' => 'GB', - 'GIB' => 'GiB', - 'GO' => 'Go', - 'GOOGLEPLUS' => 'Google+', - 'GOTO_FIRST_POST' => 'Go to first post', - 'GOTO_LAST_POST' => 'Go to last post', - 'GOTO_PAGE' => 'Go to page', - 'GROUP' => 'Group', - 'GROUPS' => 'Groups', - 'GROUP_ERR_TYPE' => 'Inappropriate group type specified.', - 'GROUP_ERR_USERNAME' => 'No group name specified.', - 'GROUP_ERR_USER_LONG' => 'Group names cannot exceed 60 characters. The specified group name is too long.', - 'GUEST' => 'Guest', - 'GUEST_USERS_ONLINE' => array( - 1 => 'There is %d guest user online', - 2 => 'There are %d guest users online', - ), - 'GUEST_USERS_TOTAL' => array( - 1 => '%d guest', - 2 => '%d guests', - ), - 'G_ADMINISTRATORS' => 'Administrators', - 'G_BOTS' => 'Bots', - 'G_GUESTS' => 'Guests', - 'G_REGISTERED' => 'Registered users', - 'G_REGISTERED_COPPA' => 'Registered COPPA users', - 'G_GLOBAL_MODERATORS' => 'Global moderators', - 'G_NEWLY_REGISTERED' => 'Newly registered users', - - 'HIDDEN_USERS_ONLINE' => array( - 1 => '%d hidden user', - 2 => '%d hidden users', - ), - 'HIDDEN_USERS_TOTAL' => array( - 1 => '%d hidden', - 2 => '%d hidden', - ), - 'HIDE_GUESTS' => 'Hide guests', - 'HIDE_ME' => 'Hide my online status this session', - 'HOURS' => 'Hours', - 'HOME' => 'Home', - - 'ICQ' => 'ICQ', - 'IF' => 'If', - 'IMAGE' => 'Image', - 'IMAGE_FILETYPE_INVALID' => 'Image file type %d for mimetype %s not supported.', - 'IMAGE_FILETYPE_MISMATCH' => 'Image file type mismatch: expected extension %1$s but extension %2$s given.', - 'IN' => 'in', - 'INACTIVE' => 'Inactive', - 'INDEX' => 'Index page', - 'INFORMATION' => 'Information', - 'INSECURE_REDIRECT' => 'Tried to redirect to potentially insecure url.', - 'INTERESTS' => 'Interests', - 'INVALID_DIGEST_CHALLENGE' => 'Invalid digest challenge.', - 'INVALID_EMAIL_LOG' => '%s possibly an invalid email address?', - 'INVALID_FEED_ATTACHMENTS' => 'The selected feed tried fetching attachments with invalid constraints.', - 'INVALID_PLURAL_RULE' => 'The chosen plural rule is invalid. Valid values are integers between 0 and 15.', - 'IP' => 'IP', - 'IP_BLACKLISTED' => 'Your IP %1$s has been blocked because it is blacklisted. For details please see %2$s.', - - 'JABBER' => 'Jabber', - 'JOINED' => 'Joined', - 'JUMP_PAGE' => 'Enter the page number you wish to go to', - 'JUMP_TO' => 'Jump to', - 'JUMP_TO_PAGE' => 'Jump to page', - 'JUMP_TO_PAGE_CLICK' => 'Click to jump to page…', - - 'KB' => 'KB', - 'KIB' => 'KiB', - - 'LAST_POST' => 'Last post', - 'LAST_UPDATED' => 'Last updated', - 'LAST_VISIT' => 'Last visit', - 'LDAP_NO_LDAP_EXTENSION' => 'LDAP extension not available.', - 'LDAP_NO_SERVER_CONNECTION' => 'Could not connect to LDAP server.', - 'LDAP_SEARCH_FAILED' => 'An error occurred while searching the LDAP directory.', - 'LEGEND' => 'Legend', - 'LIVE_SEARCHES_NOT_ALLOWED' => 'Live searches are not allowed.', - 'LOADING' => 'Loading', - 'LOCATION' => 'Location', - 'LOCK_POST' => 'Lock post', - 'LOCK_POST_EXPLAIN' => 'Prevent editing', - 'LOCK_TOPIC' => 'Lock topic', - 'LOGIN' => 'Login', - 'LOGIN_CHECK_PM' => 'Log in to check your private messages.', - 'LOGIN_CONFIRMATION' => 'Confirmation of login', - 'LOGIN_CONFIRM_EXPLAIN' => 'To prevent brute forcing accounts the board requires you to enter a confirmation code after a maximum amount of failed logins. The code is displayed in the image you should see below. If you are visually impaired or cannot otherwise read this code please contact the %sBoard Administrator%s.', // unused - 'LOGIN_ERROR_ATTEMPTS' => 'You exceeded the maximum allowed number of login attempts. In addition to your username and password you now also have to pass the CAPTCHA test.', - 'LOGIN_ERROR_EXTERNAL_AUTH_APACHE' => 'You have not been authenticated by Apache.', - 'LOGIN_ERROR_OAUTH_SERVICE_DOES_NOT_EXIST' => 'A non-existant OAuth service has been requested.', - 'LOGIN_ERROR_PASSWORD' => 'You have specified an incorrect password. Please check your password and try again. If you continue to have problems please contact the %sBoard Administrator%s.', - 'LOGIN_ERROR_PASSWORD_CONVERT' => 'It was not possible to convert your password when updating this bulletin board’s software. Please %srequest a new password%s. If you continue to have problems please contact the %sBoard Administrator%s.', - 'LOGIN_ERROR_USERNAME' => 'You have specified an incorrect username. Please check your username and try again. If you continue to have problems please contact the %sBoard Administrator%s.', - 'LOGIN_FORUM' => 'To view or post in this forum you must enter its password.', - 'LOGIN_INFO' => 'In order to login you must be registered. Registering takes only a few moments but gives you increased capabilities. The board administrator may also grant additional permissions to registered users. Before you register please ensure you are familiar with our terms of use and related policies. Please ensure you read any forum rules as you navigate around the board.', - 'LOGIN_VIEWFORUM' => 'The board requires you to be registered and logged in to view this forum.', - 'LOGIN_EXPLAIN_EDIT' => 'In order to edit posts in this forum you have to be registered and logged in.', - 'LOGIN_EXPLAIN_VIEWONLINE' => 'In order to view the online list you have to be registered and logged in.', - 'LOGIN_REQUIRED' => 'You need to login to perform this action.', - 'LOGOUT' => 'Logout', - 'LOGOUT_USER' => 'Logout [ %s ]', - 'LOG_ME_IN' => 'Remember me', - - 'MAIN' => 'Main', - 'MARK' => 'Mark', - 'MARK_ALL' => 'Mark all', - 'MARK_ALL_READ' => 'Mark all read', - 'MARK_FORUMS_READ' => 'Mark forums read', - 'MARK_READ' => 'Mark read', - 'MARK_SUBFORUMS_READ' => 'Mark subforums read', - 'MB' => 'MB', - 'MIB' => 'MiB', - 'MCP' => 'Moderator Control Panel', - 'MCP_SHORT' => 'MCP', - 'MEMBERLIST' => 'Members', - 'MEMBERLIST_EXPLAIN' => 'View complete list of members', - 'MERGE' => 'Merge', - 'MERGE_POSTS' => 'Move posts', - 'MERGE_TOPIC' => 'Merge topic', - 'MESSAGE' => 'Message', - 'MESSAGES' => 'Messages', - 'MESSAGES_COUNT' => array( - 1 => '%d message', - 2 => '%d messages', - ), - 'MESSAGE_BODY' => 'Message body', - 'MINUTES' => 'Minutes', - 'MODERATE' => 'Moderate', - 'MODERATOR' => 'Moderator', - 'MODERATORS' => 'Moderators', - 'MODULE_NOT_ACCESS' => 'Module not accessible', - 'MODULE_NOT_FIND' => 'Cannot find module %s', - 'MODULE_FILE_INCORRECT_CLASS' => 'Module file %s does not contain correct class [%s]', - 'MONTH' => 'Month', - 'MOVE' => 'Move', - - 'NA' => 'N/A', - 'NEWEST_USER' => 'Our newest member %s', - 'NEW_MESSAGE' => 'New message', - 'NEW_MESSAGES' => 'New messages', - 'NEW_POST' => 'New post', // Not used anymore - 'NEW_POSTS' => 'New posts', // Not used anymore - 'NEXT' => 'Next', // Used in pagination - 'NEXT_STEP' => 'Next', - 'NEVER' => 'Never', - 'NO' => 'No', - 'NO_NOTIFICATIONS' => 'You have no notifications', - 'NOT_ALLOWED_MANAGE_GROUP' => 'You are not allowed to manage this group.', - 'NOT_AUTHORISED' => 'You are not authorised to access this area.', - 'NOT_WATCHING_FORUM' => 'You are no longer subscribed to updates on this forum.', - 'NOT_WATCHING_TOPIC' => 'You are no longer subscribed to this topic.', - 'NOTIFICATIONS' => 'Notifications', - // This applies for NOTIFICATION_BOOKMARK and NOTIFICATION_POST. - // %1$s will return a list of users that's concatenated using "," and "and" - see STRING_LIST - // Once the user count reaches 5 users or more, the list is trimmed using NOTIFICATION_X_OTHERS - // Once the user count reaches 20 users or more, the list is trimmed using NOTIFICATION_MANY_OTHERS - // Examples: - // A replied... - // A and B replied... - // A, B and C replied... - // A, B, C and 2 others replied... - // A, B, C and others replied... - 'NOTIFICATION_BOOKMARK' => array( - 1 => 'Reply from %1$s in bookmarked topic:', - ), - 'NOTIFICATION_FORUM' => 'Forum: %1$s', - 'NOTIFICATION_GROUP_REQUEST' => 'Group request from %1$s to join the group %2$s.', - 'NOTIFICATION_GROUP_REQUEST_APPROVED' => 'Group request approved to join the group %1$s.', - 'NOTIFICATION_METHOD_INVALID' => 'The method "%s" does not refer to a valid notification method.', - 'NOTIFICATION_PM' => 'Private Message from %1$s:', - 'NOTIFICATION_POST' => array( - 1 => 'Reply from %1$s in topic:', - ), - 'NOTIFICATION_POST_APPROVED' => 'Post approved:', - 'NOTIFICATION_POST_DISAPPROVED' => 'Post disapproved:', - 'NOTIFICATION_POST_IN_QUEUE' => 'Post approval request by %1$s:', - 'NOTIFICATION_QUOTE' => array( - 1 => 'Quoted by %1$s in:', - ), - 'NOTIFICATION_REFERENCE' => '"%1$s"', - 'NOTIFICATION_REASON' => 'Reason: %1$s.', - 'NOTIFICATION_REPORT_PM' => 'Private Message reported by %1$s:', - 'NOTIFICATION_REPORT_POST' => 'Post reported by %1$s:', - 'NOTIFICATION_REPORT_CLOSED' => 'Report closed by %1$s for:', - 'NOTIFICATION_TOPIC' => 'New topic by %1$s:', - 'NOTIFICATION_TOPIC_APPROVED' => 'Topic approved:', - 'NOTIFICATION_TOPIC_DISAPPROVED' => 'Topic disapproved:', - 'NOTIFICATION_TOPIC_IN_QUEUE' => 'Topic approval request by %1$s:', - 'NOTIFICATION_TYPE_NOT_EXIST' => 'The notification type "%s" is missing from the file system.', - 'NOTIFICATION_ADMIN_ACTIVATE_USER' => 'Activation required for deactivated or newly registered user: “%1$s”', - // Used in conjunction with NOTIFICATION_BOOKMARK and NOTIFICATION_POST. - 'NOTIFICATION_MANY_OTHERS' => 'others', - 'NOTIFICATION_X_OTHERS' => array( - 2 => '%d others', - ), - 'NOTIFY_ADMIN' => 'Please notify the board administrator or webmaster.', - 'NOTIFY_ADMIN_EMAIL' => 'Please notify the board administrator or webmaster: %1$s', - 'NO_ACCESS_ATTACHMENT' => 'You are not allowed to access this file.', - 'NO_ACTION' => 'No action specified.', - 'NO_ADMINISTRATORS' => 'There are no administrators.', - 'NO_AUTH_ADMIN' => 'Access to the Administration Control Panel is not allowed as you do not have administrative permissions.', - 'NO_AUTH_ADMIN_USER_DIFFER' => 'You are not able to re-authenticate as a different user.', - 'NO_AUTH_OPERATION' => 'You do not have the necessary permissions to complete this operation.', - 'NO_AVATARS' => 'No avatars currently available', - 'NO_CONNECT_TO_SMTP_HOST' => 'Could not connect to smtp host : %1$s : %2$s', - 'NO_BIRTHDAYS' => 'No birthdays today', - 'NO_EMAIL_MESSAGE' => 'Email message was blank.', - 'NO_EMAIL_RESPONSE_CODE' => 'Could not get mail server response codes.', - 'NO_EMAIL_SUBJECT' => 'No email subject specified.', - 'NO_FORUM' => 'The forum you selected does not exist.', - 'NO_FORUMS' => 'This board has no forums.', - 'NO_GROUP' => 'The requested usergroup does not exist.', - 'NO_GROUP_MEMBERS' => 'This group currently has no members.', - 'NO_IPS_DEFINED' => 'No IP addresses or hostnames defined', - 'NO_MEMBERS' => 'No members found for this search criterion.', - 'NO_MESSAGES' => 'No messages', - 'NO_MODE' => 'No mode specified.', - 'NO_MODERATORS' => 'There are no moderators.', - 'NO_NEW_MESSAGES' => 'No new messages', - 'NO_NEW_POSTS' => 'No new posts', // Not used anymore - 'NO_ONLINE_USERS' => 'No registered users', - 'NO_POSTS' => 'No posts', - 'NO_POSTS_TIME_FRAME' => 'No posts exist inside this topic for the selected time frame.', - 'NO_FEED_ENABLED' => 'Feeds are not available on this board.', - 'NO_FEED' => 'The requested feed is not available.', - 'NO_STYLE_DATA' => 'Could not get style data for user_style %s and set for user_id %s', - 'NO_STYLE_CFG' => 'Could not get the style configuration file for: %s', - 'NO_SUBJECT' => 'No subject specified', // Used for posts having no subject defined but displayed within management pages. - 'NO_SUCH_SEARCH_MODULE' => 'The specified search backend doesn’t exist.', - 'NO_SUPPORTED_AUTH_METHODS' => 'No supported authentication methods.', - 'NO_TOPIC' => 'The requested topic does not exist.', - 'NO_TOPIC_FORUM' => 'The topic or forum no longer exists.', - 'NO_TOPICS' => 'There are no topics or posts in this forum.', - 'NO_TOPICS_TIME_FRAME' => 'No topics exist inside this forum for the selected time frame.', - 'NO_UNREAD_POSTS' => 'No unread posts', - 'NO_UPLOAD_FORM_FOUND' => 'Upload initiated but no valid file upload form found.', - 'NO_USER' => 'The requested user does not exist.', - 'NO_USERS' => 'The requested users do not exist.', - 'NO_USER_SPECIFIED' => 'No username was specified.', - - // Nullar/Singular/Plural language entry. The key numbers define the number range in which a certain grammatical expression is valid. - 'NUM_ATTACHMENTS' => array( - 1 => '%d attachment', - 2 => '%d attachments', - ), - 'NUM_POSTS_IN_QUEUE' => array( - 0 => 'No posts in queue', // 0 - 1 => '1 post in queue', // 1 - 2 => '%d posts in queue', // 2+ - ), - - 'OCCUPATION' => 'Occupation', - 'OFFLINE' => 'Offline', - 'ONLINE' => 'Online', - 'ONLINE_BUDDIES' => 'Online friends', - // "... :: x registered and y hidden" - 'ONLINE_USERS_TOTAL' => array( - 1 => 'In total there is %1$d user online :: %2$s and %3$s', - 2 => 'In total there are %1$d users online :: %2$s and %3$s', - ), - // "... :: x registered, y hidden and z guests" - 'ONLINE_USERS_TOTAL_GUESTS' => array( - 1 => 'In total there is %1$d user online :: %2$s, %3$s and %4$s', - 2 => 'In total there are %1$d users online :: %2$s, %3$s and %4$s', - ), - 'OPTIONS' => 'Options', - - 'PAGE_NOT_FOUND' => 'The requested page could not be found.', - 'PAGE_OF' => 'Page %1$d of %2$d', - 'PAGE_TITLE_NUMBER' => 'Page %s', - 'PASSWORD' => 'Password', - 'PIXEL' => 'px', - 'PIXELS' => array( - 1 => '%d pixel', - 2 => '%d pixels', - ), - 'PLEASE_WAIT' => 'Please wait.', - 'PM' => 'PM', - 'PM_REPORTED' => 'Click to view report', - 'POSTING_MESSAGE' => 'Posting message in %s', - 'POSTING_PRIVATE_MESSAGE' => 'Composing private message', - 'POST' => 'Post', - 'POST_ANNOUNCEMENT' => 'Announce', - 'POST_STICKY' => 'Sticky', - 'POSTED' => 'Posted', - 'POSTED_IN_FORUM' => 'in', - 'POSTED_ON_DATE' => 'on', - 'POSTS' => 'Posts', - 'POSTS_UNAPPROVED' => 'At least one post in this topic has not been approved.', - 'POSTS_UNAPPROVED_FORUM'=> 'At least one post in this forum has not been approved.', - 'POST_BY_AUTHOR' => 'by', - 'POST_BY_FOE' => '%1$s, who is currently on your ignore list, made this post.', - 'POST_DISPLAY' => '%1$sDisplay this post%2$s.', - 'POST_DAY' => '%.2f posts per day', - 'POST_DELETED_ACTION' => 'Deleted post:', - 'POST_DELETED' => 'This post has been deleted.', - 'POST_DELETED_BY' => '%2$s deleted the post by %1$s on %3$s.', - 'POST_DELETED_BY_REASON'=> '%2$s deleted the post by %1$s on %3$s for the following reason: %4$s', - 'POST_DETAILS' => 'Post details', - 'POST_NEW_TOPIC' => 'Post new topic', - 'POST_PCT' => '%.2f%% of all posts', - 'POST_PCT_ACTIVE' => '%.2f%% of user’s posts', - 'POST_PCT_ACTIVE_OWN' => '%.2f%% of your posts', - 'POST_REPLY' => 'Post a reply', - 'POST_REPORTED' => 'Click to view report', - 'POST_SUBJECT' => 'Post subject', - 'POST_TIME' => 'Post time', - 'POST_TOPIC' => 'Post a new topic', - 'POST_UNAPPROVED_ACTION' => 'Post awaiting approval:', - 'POST_UNAPPROVED' => 'This post has not been approved.', - 'POST_UNAPPROVED_EXPLAIN' => 'This post is not visible to other users until it has been approved by a moderator.', - 'POWERED_BY' => 'Powered by %s', - 'PREVIEW' => 'Preview', - 'PREVIOUS' => 'Previous', // Used in pagination - 'PREVIOUS_STEP' => 'Previous', - 'PRIVACY' => 'Privacy policy', - 'PRIVACY_LINK' => 'Privacy', - 'PRIVATE_MESSAGE' => 'Private message', - 'PRIVATE_MESSAGES' => 'Private messages', - 'PRIVATE_MESSAGING' => 'Private messaging', - 'PROFILE' => 'User Control Panel', - - 'QUICK_LINKS' => 'Quick links', - - 'RANK' => 'Rank', - 'READING_FORUM' => 'Viewing topics in %s', - 'READING_GLOBAL_ANNOUNCE' => 'Reading global announcement', - 'READING_LINK' => 'Following forum link %s', - 'READING_TOPIC' => 'Reading topic in %s', - 'READ_PROFILE' => 'Profile', - 'REASON' => 'Reason', - 'RECORD_ONLINE_USERS' => 'Most users ever online was %1$s on %2$s', - 'REDIRECT' => 'Redirect', - 'REDIRECTS' => 'Total redirects', - 'REGISTER' => 'Register', - 'REGISTERED_USERS' => 'Registered users:', - // "... and 2 hidden users online" - 'REG_USERS_ONLINE' => array( - 1 => 'There is %1$d registered user and %2$s online', - 2 => 'There are %1$d registered users and %2$s online', - ), - 'REG_USERS_TOTAL' => array( - 1 => '%d registered', - 2 => '%d registered', - ), - 'REMOVE' => 'Remove', - 'REMOVE_INSTALL' => 'Please delete, move or rename the install directory before you use your board. If this directory is still present, only the Administration Control Panel (ACP) will be accessible.', - 'REPLIES' => 'Replies', - 'REPLY_WITH_QUOTE' => 'Reply with quote', - 'REPLYING_GLOBAL_ANNOUNCE' => 'Replying to global announcement', - 'REPLYING_MESSAGE' => 'Replying to message in %s', - 'REPORT_BY' => 'Report by', - 'REPORT_POST' => 'Report this post', - 'REPORTING_POST' => 'Reporting post', - 'RESEND_ACTIVATION' => 'Resend activation email', - 'RESET' => 'Reset', - 'RESTORE_PERMISSIONS' => 'Restore permissions', - 'RETURN_INDEX' => '%sReturn to the index page%s', - 'RETURN_FORUM' => '%sReturn to the forum last visited%s', - 'RETURN_PAGE' => '%sReturn to the previous page%s', - 'RETURN_TOPIC' => '%sReturn to the topic last visited%s', - 'RETURN_TO' => 'Return to “%s”', - 'RETURN_TO_INDEX' => 'Return to Board Index', - 'FEED' => 'Feed', - 'FEED_NEWS' => 'News', - 'FEED_TOPICS_ACTIVE' => 'Active Topics', - 'FEED_TOPICS_NEW' => 'New Topics', - 'RULES_ATTACH_CAN' => 'You can post attachments in this forum', - 'RULES_ATTACH_CANNOT' => 'You cannot post attachments in this forum', - 'RULES_DELETE_CAN' => 'You can delete your posts in this forum', - 'RULES_DELETE_CANNOT' => 'You cannot delete your posts in this forum', - 'RULES_DOWNLOAD_CAN' => 'You can download attachments in this forum', - 'RULES_DOWNLOAD_CANNOT' => 'You cannot download attachments in this forum', - 'RULES_EDIT_CAN' => 'You can edit your posts in this forum', - 'RULES_EDIT_CANNOT' => 'You cannot edit your posts in this forum', - 'RULES_LOCK_CAN' => 'You can lock your topics in this forum', - 'RULES_LOCK_CANNOT' => 'You cannot lock your topics in this forum', - 'RULES_POST_CAN' => 'You can post new topics in this forum', - 'RULES_POST_CANNOT' => 'You cannot post new topics in this forum', - 'RULES_REPLY_CAN' => 'You can reply to topics in this forum', - 'RULES_REPLY_CANNOT' => 'You cannot reply to topics in this forum', - 'RULES_VOTE_CAN' => 'You can vote in polls in this forum', - 'RULES_VOTE_CANNOT' => 'You cannot vote in polls in this forum', - - 'SEARCH' => 'Search', - 'SEARCH_MINI' => 'Search…', - 'SEARCH_ADV' => 'Advanced search', - 'SEARCH_ADV_EXPLAIN' => 'View the advanced search options', - 'SEARCH_KEYWORDS' => 'Search for keywords', - 'SEARCHING_FORUMS' => 'Searching forums', - 'SEARCH_ACTIVE_TOPICS' => 'Active topics', - 'SEARCH_FOR' => 'Search for', - 'SEARCH_FORUM' => 'Search this forum…', - 'SEARCH_NEW' => 'New posts', - 'SEARCH_POSTS_BY' => 'Search posts by', - 'SEARCH_SELF' => 'Your posts', - 'SEARCH_TOPIC' => 'Search this topic…', - 'SEARCH_UNANSWERED' => 'Unanswered topics', - 'SEARCH_UNREAD' => 'Unread posts', - 'SEARCH_USER_POSTS' => 'Search user’s posts', - 'SECONDS' => 'Seconds', - 'SEE_ALL' => 'See All', - 'SELECT' => 'Select', - 'SELECT_ALL_CODE' => 'Select all', - 'SELECT_DESTINATION_FORUM' => 'Please select a destination forum', - 'SELECT_FORUM' => 'Select a forum', - 'SEND_EMAIL' => 'Send email', // Used for submit buttons - 'SEND_EMAIL_USER' => 'Send email to %s', - 'SEND_PRIVATE_MESSAGE' => 'Send private message', - 'SETTINGS' => 'Settings', - 'SIGNATURE' => 'Signature', - 'SKIP' => 'Skip to content', - 'SKYPE' => 'Skype', - 'SMTP_NO_AUTH_SUPPORT' => 'SMTP server does not support authentication.', - 'SORRY_AUTH_READ' => 'You are not authorised to read this forum.', - 'SORRY_AUTH_READ_TOPIC' => 'You are not authorised to read this topic.', - 'SORRY_AUTH_VIEW_ATTACH' => 'You are not authorised to download this attachment.', - 'SORT_BY' => 'Sort by', - 'SORT_DIRECTION' => 'Direction', - 'SORT_JOINED' => 'Joined date', - 'SORT_LOCATION' => 'Location', - 'SORT_OPTIONS' => 'Display and sorting options', - 'SORT_RANK' => 'Rank', - 'SORT_POSTS' => 'Posts', - 'SORT_TOPIC_TITLE' => 'Topic title', - 'SORT_USERNAME' => 'Username', - 'SPLIT_TOPIC' => 'Split topic', - 'SQL_ERROR_OCCURRED' => 'An SQL error occurred while fetching this page. Please contact the %sBoard Administrator%s if this problem persists.', - 'STATISTICS' => 'Statistics', - 'START_WATCHING_FORUM' => 'Subscribe forum', - 'START_WATCHING_TOPIC' => 'Subscribe topic', - 'STOP_WATCHING_FORUM' => 'Unsubscribe forum', - 'STOP_WATCHING_TOPIC' => 'Unsubscribe topic', - 'STRING_LIST_MULTI' => '%1$s, and %2$s', - 'STRING_LIST_SIMPLE' => '%1$s and %2$s', - 'SUBFORUM' => 'Subforum', - 'SUBFORUMS' => 'Subforums', - 'SUBJECT' => 'Subject', - 'SUBMIT' => 'Submit', - - 'TB' => 'TB', - 'TERMS_LINK' => 'Terms', - 'TERMS_USE' => 'Terms of use', - 'TEST_CONNECTION' => 'Test connection', - 'THE_TEAM' => 'The team', - 'TIB' => 'TiB', - 'TIME' => 'Time', - 'TIMEOUT_PROCESSING_REQ' => 'Request timed out.', - - 'TOO_LARGE' => 'The value you entered is too large.', - 'TOO_LARGE_MAX_RECIPIENTS' => 'The value of Maximum number of allowed recipients per private message setting you entered is too large.', - - 'TOO_LONG' => 'The value you entered is too long.', - - 'TOO_LONG_CONFIRM_CODE' => 'The confirm code you entered is too long.', - 'TOO_LONG_DATEFORMAT' => 'The date format you entered is too long.', - 'TOO_LONG_JABBER' => 'The Jabber account name you entered is too long.', - 'TOO_LONG_NEW_PASSWORD' => 'The password you entered is too long.', - 'TOO_LONG_PASSWORD_CONFIRM' => 'The password confirmation you entered is too long.', - 'TOO_LONG_USER_PASSWORD' => 'The password you entered is too long.', - 'TOO_LONG_USERNAME' => 'The username you entered is too long.', - 'TOO_LONG_EMAIL' => 'The email address you entered is too long.', - - 'TOO_MANY_VOTE_OPTIONS' => 'You have tried to vote for too many options.', - - 'TOO_SHORT' => 'The value you entered is too short.', - - 'TOO_SHORT_CONFIRM_CODE' => 'The confirm code you entered is too short.', - 'TOO_SHORT_DATEFORMAT' => 'The date format you entered is too short.', - 'TOO_SHORT_JABBER' => 'The Jabber account name you entered is too short.', - 'TOO_SHORT_NEW_PASSWORD' => 'The password you entered is too short.', - 'TOO_SHORT_PASSWORD_CONFIRM' => 'The password confirmation you entered is too short.', - 'TOO_SHORT_USER_PASSWORD' => 'The password you entered is too short.', - 'TOO_SHORT_USERNAME' => 'The username you entered is too short.', - 'TOO_SHORT_EMAIL' => 'The email address you entered is too short.', - 'TOO_SHORT_EMAIL_CONFIRM' => 'The email address confirmation you entered is too short.', - 'TOO_SMALL' => 'The value you entered is too small.', - 'TOO_SMALL_MAX_RECIPIENTS' => 'The value of Maximum number of allowed recipients per private message setting you entered is too small.', - - 'TOPIC' => 'Topic', - 'TOPICS' => 'Topics', - 'TOPICS_UNAPPROVED' => 'At least one topic in this forum has not been approved.', - 'TOPIC_ICON' => 'Topic icon', - 'TOPIC_LOCKED' => 'This topic is locked, you cannot edit posts or make further replies.', - 'TOPIC_LOCKED_SHORT'=> 'Topic locked', - 'TOPIC_MOVED' => 'Moved topic', - 'TOPIC_REVIEW' => 'Topic review', - 'TOPIC_TITLE' => 'Topic title', - 'TOPIC_UNAPPROVED' => 'This topic has not been approved.', - 'TOPIC_UNAPPROVED_FORUM' => array( - 1 => 'Topic awaiting approval', - 2 => 'Topics awaiting approval', - ), - 'TOPIC_DELETED' => 'This topic has been deleted.', - 'TOTAL_ATTACHMENTS' => 'Attachment(s)', - 'TOTAL_LOGS' => array( - 1 => '%d log', - 2 => '%d logs', - ), - 'TOTAL_PMS' => array( - 1 => '%d private message in total', - 2 => '%d private messages in total', - ), - 'TOPIC_POLL' => 'This topic has a poll.', - 'TOTAL_POSTS' => 'Total posts', - 'TOTAL_POSTS_COUNT' => array( - 2 => 'Total posts %d', - ), - 'TOPIC_REPORTED' => 'This topic has been reported', - 'TOTAL_TOPICS' => array( - 2 => 'Total topics %d', - ), - 'TOTAL_USERS' => array( - 2 => 'Total members %d', - ), - 'TRACKED_PHP_ERROR' => 'Tracked PHP errors: %s', - 'TWITTER' => 'Twitter', - - 'UNABLE_GET_IMAGE_SIZE' => 'It was not possible to determine the dimensions of the image. Please verify that the URL you entered is correct.', - 'UNABLE_TO_DELIVER_FILE'=> 'Unable to deliver file.', - 'UNKNOWN_BROWSER' => 'Unknown browser', - 'UNMARK_ALL' => 'Unmark all', - 'UNREAD_MESSAGES' => 'Unread messages', - 'UNREAD_POST' => 'Unread post', - 'UNREAD_POSTS' => 'Unread posts', - 'UNWATCH_FORUM_CONFIRM' => 'Are you sure you wish to unsubscribe from this forum?', - 'UNWATCH_FORUM_DETAILED' => 'Are you sure you wish to unsubscribe from the forum “%s”?', - 'UNWATCH_TOPIC_CONFIRM' => 'Are you sure you wish to unsubscribe from this topic?', - 'UNWATCH_TOPIC_DETAILED' => 'Are you sure you wish to unsubscribe from the topic “%s”?', - 'UNWATCHED_FORUMS' => 'You are no longer subscribed to the selected forums.', - 'UNWATCHED_TOPICS' => 'You are no longer subscribed to the selected topics.', - 'UNWATCHED_FORUMS_TOPICS' => 'You are no longer subscribed to the selected entries.', - 'UPDATE' => 'Update', - 'UPLOAD_IN_PROGRESS' => 'The upload is currently in progress.', - 'URL_REDIRECT' => 'If your browser does not support meta redirection %splease click HERE to be redirected%s.', - 'USERGROUPS' => 'Groups', - 'USERNAME' => 'Username', - 'USERNAMES' => 'Usernames', - 'USER_AVATAR' => 'User avatar', - 'USER_CANNOT_READ' => 'You cannot read posts in this forum.', - 'USER_POSTS' => array( - 1 => '%d Post', - 2 => '%d Posts', - ), - 'USERS' => 'Users', - 'USE_PERMISSIONS' => 'Test out user’s permissions', - - 'USER_NEW_PERMISSION_DISALLOWED' => 'We are sorry, but you are not authorised to use this feature. You may have just registered here and may need to participate more in discussions to be able to use this feature.', - - 'VARIANT_DATE_SEPARATOR' => ' / ', // Used in date format dropdown, eg: "Today, 13:37 / 01 Jan 2007, 13:37" ... to join a relative date with calendar date - 'VIEWED' => 'Viewed', - 'VIEWED_COUNTS' => array( - 0 => 'Not viewed yet', - 1 => 'Viewed %d time', - 2 => 'Viewed %d times', - ), - 'VIEWING_CONTACT_ADMIN' => 'Viewing contact page', - 'VIEWING_FAQ' => 'Viewing FAQ', - 'VIEWING_MEMBERS' => 'Viewing member details', - 'VIEWING_ONLINE' => 'Viewing who is online', - 'VIEWING_MCP' => 'Viewing moderator control panel', - 'VIEWING_MEMBER_PROFILE' => 'Viewing member profile', - 'VIEWING_PRIVATE_MESSAGES' => 'Viewing private messages', - 'VIEWING_REGISTER' => 'Registering account', - 'VIEWING_UCP' => 'Viewing user control panel', - 'VIEWS' => 'Views', - 'VIEW_BOOKMARKS' => 'View bookmarks', - 'VIEW_FORUM_LOGS' => 'View Logs', - 'VIEW_LATEST_POST' => 'View the latest post', - 'VIEW_NEWEST_POST' => 'View first unread post', - 'VIEW_NOTES' => 'View user notes', - 'VIEW_ONLINE_TIMES' => array( - 1 => 'based on users active over the past %d minute', - 2 => 'based on users active over the past %d minutes', - ), - 'VIEW_TOPIC' => 'View topic', - 'VIEW_TOPIC_ANNOUNCEMENT' => 'Announcement: ', - 'VIEW_TOPIC_GLOBAL' => 'Global Announcement: ', - 'VIEW_TOPIC_LOCKED' => 'Locked: ', - 'VIEW_TOPIC_LOGS' => 'View logs', - 'VIEW_TOPIC_MOVED' => 'Moved: ', - 'VIEW_TOPIC_POLL' => 'Poll: ', - 'VIEW_TOPIC_STICKY' => 'Sticky: ', - 'VISIT_WEBSITE' => 'Visit website', - - 'WARNINGS' => 'Warnings', - 'WARN_USER' => 'Warn user', - 'WATCH_FORUM_CONFIRM' => 'Are you sure you wish to subscribe to this forum?', - 'WATCH_FORUM_DETAILED' => 'Are you sure you wish to subscribe to the forum “%s”?', - 'WATCH_TOPIC_CONFIRM' => 'Are you sure you wish to subscribe to this topic?', - 'WATCH_TOPIC_DETAILED' => 'Are you sure you wish to subscribe to the topic “%s”?', - 'WELCOME_SUBJECT' => 'Welcome to %s forums', - 'WEBSITE' => 'Website', - 'WHOIS' => 'Whois', - 'WHO_IS_ONLINE' => 'Who is online', - 'WRONG_PASSWORD' => 'You entered an incorrect password.', - - 'WRONG_DATA_COLOUR' => 'The colour value you entered is invalid.', - 'WRONG_DATA_JABBER' => 'The name you entered is not a valid Jabber account name.', - 'WRONG_DATA_LANG' => 'The language you specified is not valid.', - 'WRONG_DATA_POST_SD' => 'The post sort direction you specified is not valid.', - 'WRONG_DATA_POST_SK' => 'The post sort option you specified is not valid.', - 'WRONG_DATA_TOPIC_SD' => 'The topic sort direction you specified is not valid.', - 'WRONG_DATA_TOPIC_SK' => 'The topic sort option you specified is not valid.', - 'WROTE' => 'wrote', - - 'YAHOO' => 'Yahoo Messenger', - 'YOUTUBE' => 'YouTube', - 'YEAR' => 'Year', - 'YEAR_MONTH_DAY' => '(YYYY-MM-DD)', - 'YES' => 'Yes', - 'YOU_LAST_VISIT' => 'Last visit was: %s', - - 'datetime' => array( - 'TODAY' => 'Today', - 'TOMORROW' => 'Tomorrow', - 'YESTERDAY' => 'Yesterday', - 'AGO' => array( - 0 => 'less than a minute ago', - 1 => '%d minute ago', - 2 => '%d minutes ago', - ), - - 'Sunday' => 'Sunday', - 'Monday' => 'Monday', - 'Tuesday' => 'Tuesday', - 'Wednesday' => 'Wednesday', - 'Thursday' => 'Thursday', - 'Friday' => 'Friday', - 'Saturday' => 'Saturday', - - 'Sun' => 'Sun', - 'Mon' => 'Mon', - 'Tue' => 'Tue', - 'Wed' => 'Wed', - 'Thu' => 'Thu', - 'Fri' => 'Fri', - 'Sat' => 'Sat', - - 'January' => 'January', - 'February' => 'February', - 'March' => 'March', - 'April' => 'April', - 'May' => 'May', - 'June' => 'June', - 'July' => 'July', - 'August' => 'August', - 'September' => 'September', - 'October' => 'October', - 'November' => 'November', - 'December' => 'December', - - 'Jan' => 'Jan', - 'Feb' => 'Feb', - 'Mar' => 'Mar', - 'Apr' => 'Apr', - 'May_short' => 'May', // Short representation of "May". May_short used because in English the short and long date are the same for May. - 'Jun' => 'Jun', - 'Jul' => 'Jul', - 'Aug' => 'Aug', - 'Sep' => 'Sep', - 'Oct' => 'Oct', - 'Nov' => 'Nov', - 'Dec' => 'Dec', - ), - - // Timezones can be translated. We use this for the Etc/GMT timezones here, - // because they are named invers to their offset. - 'timezones' => array( - 'UTC' => 'UTC', - 'UTC_OFFSET' => 'UTC%1$s', - 'UTC_OFFSET_CURRENT' => 'UTC%1$s - %2$s', - - 'Etc/GMT-12' => 'UTC+12', - 'Etc/GMT-11' => 'UTC+11', - 'Etc/GMT-10' => 'UTC+10', - 'Etc/GMT-9' => 'UTC+9', - 'Etc/GMT-8' => 'UTC+8', - 'Etc/GMT-7' => 'UTC+7', - 'Etc/GMT-6' => 'UTC+6', - 'Etc/GMT-5' => 'UTC+5', - 'Etc/GMT-4' => 'UTC+4', - 'Etc/GMT-3' => 'UTC+3', - 'Etc/GMT-2' => 'UTC+2', - 'Etc/GMT-1' => 'UTC+1', - 'Etc/GMT+1' => 'UTC-1', - 'Etc/GMT+2' => 'UTC-2', - 'Etc/GMT+3' => 'UTC-3', - 'Etc/GMT+4' => 'UTC-4', - 'Etc/GMT+5' => 'UTC-5', - 'Etc/GMT+6' => 'UTC-6', - 'Etc/GMT+7' => 'UTC-7', - 'Etc/GMT+8' => 'UTC-8', - 'Etc/GMT+9' => 'UTC-9', - 'Etc/GMT+10' => 'UTC-10', - 'Etc/GMT+11' => 'UTC-11', - 'Etc/GMT+12' => 'UTC-12', - - 'Africa/Abidjan' => 'Africa/Abidjan', - 'Africa/Accra' => 'Africa/Accra', - 'Africa/Addis_Ababa' => 'Africa/Addis Ababa', - 'Africa/Algiers' => 'Africa/Algiers', - 'Africa/Asmara' => 'Africa/Asmara', - 'Africa/Bamako' => 'Africa/Bamako', - 'Africa/Bangui' => 'Africa/Bangui', - 'Africa/Banjul' => 'Africa/Banjul', - 'Africa/Bissau' => 'Africa/Bissau', - 'Africa/Blantyre' => 'Africa/Blantyre', - 'Africa/Brazzaville' => 'Africa/Brazzaville', - 'Africa/Bujumbura' => 'Africa/Bujumbura', - 'Africa/Cairo' => 'Africa/Cairo', - 'Africa/Casablanca' => 'Africa/Casablanca', - 'Africa/Ceuta' => 'Africa/Ceuta', - 'Africa/Conakry' => 'Africa/Conakry', - 'Africa/Dakar' => 'Africa/Dakar', - 'Africa/Dar_es_Salaam' => 'Africa/Dar es Salaam', - 'Africa/Djibouti' => 'Africa/Djibouti', - 'Africa/Douala' => 'Africa/Douala', - 'Africa/El_Aaiun' => 'Africa/El Aaiun', - 'Africa/Freetown' => 'Africa/Freetown', - 'Africa/Gaborone' => 'Africa/Gaborone', - 'Africa/Harare' => 'Africa/Harare', - 'Africa/Johannesburg' => 'Africa/Johannesburg', - 'Africa/Juba' => 'Africa/Juba', - 'Africa/Kampala' => 'Africa/Kampala', - 'Africa/Khartoum' => 'Africa/Khartoum', - 'Africa/Kigali' => 'Africa/Kigali', - 'Africa/Kinshasa' => 'Africa/Kinshasa', - 'Africa/Lagos' => 'Africa/Lagos', - 'Africa/Libreville' => 'Africa/Libreville', - 'Africa/Lome' => 'Africa/Lome', - 'Africa/Luanda' => 'Africa/Luanda', - 'Africa/Lubumbashi' => 'Africa/Lubumbashi', - 'Africa/Lusaka' => 'Africa/Lusaka', - 'Africa/Malabo' => 'Africa/Malabo', - 'Africa/Maputo' => 'Africa/Maputo', - 'Africa/Maseru' => 'Africa/Maseru', - 'Africa/Mbabane' => 'Africa/Mbabane', - 'Africa/Mogadishu' => 'Africa/Mogadishu', - 'Africa/Monrovia' => 'Africa/Monrovia', - 'Africa/Nairobi' => 'Africa/Nairobi', - 'Africa/Ndjamena' => 'Africa/Ndjamena', - 'Africa/Niamey' => 'Africa/Niamey', - 'Africa/Nouakchott' => 'Africa/Nouakchott', - 'Africa/Ouagadougou' => 'Africa/Ouagadougou', - 'Africa/Porto-Novo' => 'Africa/Porto-Novo', - 'Africa/Sao_Tome' => 'Africa/Sao Tome', - 'Africa/Tripoli' => 'Africa/Tripoli', - 'Africa/Tunis' => 'Africa/Tunis', - 'Africa/Windhoek' => 'Africa/Windhoek', - - 'America/Adak' => 'America/Adak', - 'America/Anchorage' => 'America/Anchorage', - 'America/Anguilla' => 'America/Anguilla', - 'America/Antigua' => 'America/Antigua', - 'America/Araguaina' => 'America/Araguaina', - - 'America/Argentina/Buenos_Aires' => 'America/Argentina/Buenos Aires', - 'America/Argentina/Catamarca' => 'America/Argentina/Catamarca', - 'America/Argentina/Cordoba' => 'America/Argentina/Cordoba', - 'America/Argentina/Jujuy' => 'America/Argentina/Jujuy', - 'America/Argentina/La_Rioja' => 'America/Argentina/La Rioja', - 'America/Argentina/Mendoza' => 'America/Argentina/Mendoza', - 'America/Argentina/Rio_Gallegos' => 'America/Argentina/Rio Gallegos', - 'America/Argentina/Salta' => 'America/Argentina/Salta', - 'America/Argentina/San_Juan' => 'America/Argentina/San Juan', - 'America/Argentina/San_Luis' => 'America/Argentina/San Luis', - 'America/Argentina/Tucuman' => 'America/Argentina/Tucuman', - 'America/Argentina/Ushuaia' => 'America/Argentina/Ushuaia', - - 'America/Aruba' => 'America/Aruba', - 'America/Asuncion' => 'America/Asuncion', - 'America/Atikokan' => 'America/Atikokan', - 'America/Bahia' => 'America/Bahia', - 'America/Bahia_Banderas' => 'America/Bahia Banderas', - 'America/Barbados' => 'America/Barbados', - 'America/Belem' => 'America/Belem', - 'America/Belize' => 'America/Belize', - 'America/Blanc-Sablon' => 'America/Blanc-Sablon', - 'America/Boa_Vista' => 'America/Boa Vista', - 'America/Bogota' => 'America/Bogota', - 'America/Boise' => 'America/Boise', - 'America/Cambridge_Bay' => 'America/Cambridge Bay', - 'America/Campo_Grande' => 'America/Campo Grande', - 'America/Cancun' => 'America/Cancun', - 'America/Caracas' => 'America/Caracas', - 'America/Cayenne' => 'America/Cayenne', - 'America/Cayman' => 'America/Cayman', - 'America/Chicago' => 'America/Chicago', - 'America/Chihuahua' => 'America/Chihuahua', - 'America/Costa_Rica' => 'America/Costa Rica', - 'America/Creston' => 'America/Creston', - 'America/Cuiaba' => 'America/Cuiaba', - 'America/Curacao' => 'America/Curacao', - 'America/Danmarkshavn' => 'America/Danmarkshavn', - 'America/Dawson' => 'America/Dawson', - 'America/Dawson_Creek' => 'America/Dawson Creek', - 'America/Denver' => 'America/Denver', - 'America/Detroit' => 'America/Detroit', - 'America/Dominica' => 'America/Dominica', - 'America/Edmonton' => 'America/Edmonton', - 'America/Eirunepe' => 'America/Eirunepe', - 'America/El_Salvador' => 'America/El Salvador', - 'America/Fortaleza' => 'America/Fortaleza', - 'America/Glace_Bay' => 'America/Glace Bay', - 'America/Godthab' => 'America/Godthab', - 'America/Goose_Bay' => 'America/Goose Bay', - 'America/Grand_Turk' => 'America/Grand Turk', - 'America/Grenada' => 'America/Grenada', - 'America/Guadeloupe' => 'America/Guadeloupe', - 'America/Guatemala' => 'America/Guatemala', - 'America/Guayaquil' => 'America/Guayaquil', - 'America/Guyana' => 'America/Guyana', - 'America/Halifax' => 'America/Halifax', - 'America/Havana' => 'America/Havana', - 'America/Hermosillo' => 'America/Hermosillo', - 'America/Indiana/Indianapolis' => 'America/Indiana/Indianapolis', - 'America/Indiana/Knox' => 'America/Indiana/Knox', - 'America/Indiana/Marengo' => 'America/Indiana/Marengo', - 'America/Indiana/Petersburg' => 'America/Indiana/Petersburg', - 'America/Indiana/Tell_City' => 'America/Indiana/Tell City', - 'America/Indiana/Vevay' => 'America/Indiana/Vevay', - 'America/Indiana/Vincennes' => 'America/Indiana/Vincennes', - 'America/Indiana/Winamac' => 'America/Indiana/Winamac', - 'America/Inuvik' => 'America/Inuvik', - 'America/Iqaluit' => 'America/Iqaluit', - 'America/Jamaica' => 'America/Jamaica', - 'America/Juneau' => 'America/Juneau', - 'America/Kentucky/Louisville' => 'America/Kentucky/Louisville', - 'America/Kentucky/Monticello' => 'America/Kentucky/Monticello', - 'America/Kralendijk' => 'America/Kralendijk', - 'America/La_Paz' => 'America/La Paz', - 'America/Lima' => 'America/Lima', - 'America/Los_Angeles' => 'America/Los Angeles', - 'America/Lower_Princes' => 'America/Lower Princes', - 'America/Maceio' => 'America/Maceio', - 'America/Managua' => 'America/Managua', - 'America/Manaus' => 'America/Manaus', - 'America/Marigot' => 'America/Marigot', - 'America/Martinique' => 'America/Martinique', - 'America/Matamoros' => 'America/Matamoros', - 'America/Mazatlan' => 'America/Mazatlan', - 'America/Menominee' => 'America/Menominee', - 'America/Merida' => 'America/Merida', - 'America/Metlakatla' => 'America/Metlakatla', - 'America/Mexico_City' => 'America/Mexico City', - 'America/Miquelon' => 'America/Miquelon', - 'America/Moncton' => 'America/Moncton', - 'America/Monterrey' => 'America/Monterrey', - 'America/Montevideo' => 'America/Montevideo', - 'America/Montreal' => 'America/Montreal', - 'America/Montserrat' => 'America/Montserrat', - 'America/Nassau' => 'America/Nassau', - 'America/New_York' => 'America/New York', - 'America/Nipigon' => 'America/Nipigon', - 'America/Nome' => 'America/Nome', - 'America/Noronha' => 'America/Noronha', - 'America/North_Dakota/Beulah' => 'America/North Dakota/Beulah', - 'America/North_Dakota/Center' => 'America/North Dakota/Center', - 'America/North_Dakota/New_Salem' => 'America/North Dakota/New Salem', - 'America/Ojinaga' => 'America/Ojinaga', - 'America/Panama' => 'America/Panama', - 'America/Pangnirtung' => 'America/Pangnirtung', - 'America/Paramaribo' => 'America/Paramaribo', - 'America/Phoenix' => 'America/Phoenix', - 'America/Port-au-Prince' => 'America/Port-au-Prince', - 'America/Port_of_Spain' => 'America/Port of Spain', - 'America/Porto_Velho' => 'America/Porto Velho', - 'America/Puerto_Rico' => 'America/Puerto Rico', - 'America/Rainy_River' => 'America/Rainy River', - 'America/Rankin_Inlet' => 'America/Rankin Inlet', - 'America/Recife' => 'America/Recife', - 'America/Regina' => 'America/Regina', - 'America/Resolute' => 'America/Resolute', - 'America/Rio_Branco' => 'America/Rio Branco', - 'America/Santa_Isabel' => 'America/Santa Isabel', - 'America/Santarem' => 'America/Santarem', - 'America/Santiago' => 'America/Santiago', - 'America/Santo_Domingo' => 'America/Santo Domingo', - 'America/Sao_Paulo' => 'America/Sao Paulo', - 'America/Scoresbysund' => 'America/Scoresbysund', - 'America/Shiprock' => 'America/Shiprock', - 'America/Sitka' => 'America/Sitka', - 'America/St_Barthelemy' => 'America/St. Barthelemy', - 'America/St_Johns' => 'America/St. Johns', - 'America/St_Kitts' => 'America/St. Kitts', - 'America/St_Lucia' => 'America/St. Lucia', - 'America/St_Thomas' => 'America/St. Thomas', - 'America/St_Vincent' => 'America/St. Vincent', - 'America/Swift_Current' => 'America/Swift Current', - 'America/Tegucigalpa' => 'America/Tegucigalpa', - 'America/Thule' => 'America/Thule', - 'America/Thunder_Bay' => 'America/Thunder Bay', - 'America/Tijuana' => 'America/Tijuana', - 'America/Toronto' => 'America/Toronto', - 'America/Tortola' => 'America/Tortola', - 'America/Vancouver' => 'America/Vancouver', - 'America/Whitehorse' => 'America/Whitehorse', - 'America/Winnipeg' => 'America/Winnipeg', - 'America/Yakutat' => 'America/Yakutat', - 'America/Yellowknife' => 'America/Yellowknife', - - 'Antarctica/Casey' => 'Antarctica/Casey', - 'Antarctica/Davis' => 'Antarctica/Davis', - 'Antarctica/DumontDUrville' => 'Antarctica/DumontDUrville', - 'Antarctica/Macquarie' => 'Antarctica/Macquarie', - 'Antarctica/Mawson' => 'Antarctica/Mawson', - 'Antarctica/McMurdo' => 'Antarctica/McMurdo', - 'Antarctica/Palmer' => 'Antarctica/Palmer', - 'Antarctica/Rothera' => 'Antarctica/Rothera', - 'Antarctica/South_Pole' => 'Antarctica/South Pole', - 'Antarctica/Syowa' => 'Antarctica/Syowa', - 'Antarctica/Vostok' => 'Antarctica/Vostok', - - 'Arctic/Longyearbyen' => 'Arctic/Longyearbyen', - - 'Asia/Aden' => 'Asia/Aden', - 'Asia/Almaty' => 'Asia/Almaty', - 'Asia/Amman' => 'Asia/Amman', - 'Asia/Anadyr' => 'Asia/Anadyr', - 'Asia/Aqtau' => 'Asia/Aqtau', - 'Asia/Aqtobe' => 'Asia/Aqtobe', - 'Asia/Ashgabat' => 'Asia/Ashgabat', - 'Asia/Baghdad' => 'Asia/Baghdad', - 'Asia/Bahrain' => 'Asia/Bahrain', - 'Asia/Baku' => 'Asia/Baku', - 'Asia/Bangkok' => 'Asia/Bangkok', - 'Asia/Beirut' => 'Asia/Beirut', - 'Asia/Bishkek' => 'Asia/Bishkek', - 'Asia/Brunei' => 'Asia/Brunei', - 'Asia/Choibalsan' => 'Asia/Choibalsan', - 'Asia/Chongqing' => 'Asia/Chongqing', - 'Asia/Colombo' => 'Asia/Colombo', - 'Asia/Damascus' => 'Asia/Damascus', - 'Asia/Dhaka' => 'Asia/Dhaka', - 'Asia/Dili' => 'Asia/Dili', - 'Asia/Dubai' => 'Asia/Dubai', - 'Asia/Dushanbe' => 'Asia/Dushanbe', - 'Asia/Gaza' => 'Asia/Gaza', - 'Asia/Harbin' => 'Asia/Harbin', - 'Asia/Hebron' => 'Asia/Hebron', - 'Asia/Ho_Chi_Minh' => 'Asia/Ho Chi Minh', - 'Asia/Hong_Kong' => 'Asia/Hong Kong', - 'Asia/Hovd' => 'Asia/Hovd', - 'Asia/Irkutsk' => 'Asia/Irkutsk', - 'Asia/Jakarta' => 'Asia/Jakarta', - 'Asia/Jayapura' => 'Asia/Jayapura', - 'Asia/Jerusalem' => 'Asia/Jerusalem', - 'Asia/Kabul' => 'Asia/Kabul', - 'Asia/Kamchatka' => 'Asia/Kamchatka', - 'Asia/Karachi' => 'Asia/Karachi', - 'Asia/Kashgar' => 'Asia/Kashgar', - 'Asia/Kathmandu' => 'Asia/Kathmandu', - 'Asia/Khandyga' => 'Asia/Khandyga', - 'Asia/Kolkata' => 'Asia/Kolkata', - 'Asia/Krasnoyarsk' => 'Asia/Krasnoyarsk', - 'Asia/Kuala_Lumpur' => 'Asia/Kuala Lumpur', - 'Asia/Kuching' => 'Asia/Kuching', - 'Asia/Kuwait' => 'Asia/Kuwait', - 'Asia/Macau' => 'Asia/Macau', - 'Asia/Magadan' => 'Asia/Magadan', - 'Asia/Makassar' => 'Asia/Makassar', - 'Asia/Manila' => 'Asia/Manila', - 'Asia/Muscat' => 'Asia/Muscat', - 'Asia/Nicosia' => 'Asia/Nicosia', - 'Asia/Novokuznetsk' => 'Asia/Novokuznetsk', - 'Asia/Novosibirsk' => 'Asia/Novosibirsk', - 'Asia/Omsk' => 'Asia/Omsk', - 'Asia/Oral' => 'Asia/Oral', - 'Asia/Phnom_Penh' => 'Asia/Phnom Penh', - 'Asia/Pontianak' => 'Asia/Pontianak', - 'Asia/Pyongyang' => 'Asia/Pyongyang', - 'Asia/Qatar' => 'Asia/Qatar', - 'Asia/Qyzylorda' => 'Asia/Qyzylorda', - 'Asia/Rangoon' => 'Asia/Rangoon', - 'Asia/Riyadh' => 'Asia/Riyadh', - 'Asia/Sakhalin' => 'Asia/Sakhalin', - 'Asia/Samarkand' => 'Asia/Samarkand', - 'Asia/Seoul' => 'Asia/Seoul', - 'Asia/Shanghai' => 'Asia/Shanghai', - 'Asia/Singapore' => 'Asia/Singapore', - 'Asia/Taipei' => 'Asia/Taipei', - 'Asia/Tashkent' => 'Asia/Tashkent', - 'Asia/Tbilisi' => 'Asia/Tbilisi', - 'Asia/Tehran' => 'Asia/Tehran', - 'Asia/Thimphu' => 'Asia/Thimphu', - 'Asia/Tokyo' => 'Asia/Tokyo', - 'Asia/Ulaanbaatar' => 'Asia/Ulaanbaatar', - 'Asia/Urumqi' => 'Asia/Urumqi', - 'Asia/Ust-Nera' => 'Asia/Ust-Nera', - 'Asia/Vientiane' => 'Asia/Vientiane', - 'Asia/Vladivostok' => 'Asia/Vladivostok', - 'Asia/Yakutsk' => 'Asia/Yakutsk', - 'Asia/Yekaterinburg' => 'Asia/Yekaterinburg', - 'Asia/Yerevan' => 'Asia/Yerevan', - - 'Atlantic/Azores' => 'Atlantic/Azores', - 'Atlantic/Bermuda' => 'Atlantic/Bermuda', - 'Atlantic/Canary' => 'Atlantic/Canary', - 'Atlantic/Cape_Verde' => 'Atlantic/Cape Verde', - 'Atlantic/Faroe' => 'Atlantic/Faroe', - 'Atlantic/Madeira' => 'Atlantic/Madeira', - 'Atlantic/Reykjavik' => 'Atlantic/Reykjavik', - 'Atlantic/South_Georgia' => 'Atlantic/South Georgia', - 'Atlantic/St_Helena' => 'Atlantic/St. Helena', - 'Atlantic/Stanley' => 'Atlantic/Stanley', - - 'Australia/Adelaide' => 'Australia/Adelaide', - 'Australia/Brisbane' => 'Australia/Brisbane', - 'Australia/Broken_Hill' => 'Australia/Broken Hill', - 'Australia/Currie' => 'Australia/Currie', - 'Australia/Darwin' => 'Australia/Darwin', - 'Australia/Eucla' => 'Australia/Eucla', - 'Australia/Hobart' => 'Australia/Hobart', - 'Australia/Lindeman' => 'Australia/Lindeman', - 'Australia/Lord_Howe' => 'Australia/Lord Howe', - 'Australia/Melbourne' => 'Australia/Melbourne', - 'Australia/Perth' => 'Australia/Perth', - 'Australia/Sydney' => 'Australia/Sydney', - - 'Europe/Amsterdam' => 'Europe/Amsterdam', - 'Europe/Andorra' => 'Europe/Andorra', - 'Europe/Athens' => 'Europe/Athens', - 'Europe/Belgrade' => 'Europe/Belgrade', - 'Europe/Berlin' => 'Europe/Berlin', - 'Europe/Bratislava' => 'Europe/Bratislava', - 'Europe/Brussels' => 'Europe/Brussels', - 'Europe/Bucharest' => 'Europe/Bucharest', - 'Europe/Budapest' => 'Europe/Budapest', - 'Europe/Busingen' => 'Europe/Busingen', - 'Europe/Chisinau' => 'Europe/Chisinau', - 'Europe/Copenhagen' => 'Europe/Copenhagen', - 'Europe/Dublin' => 'Europe/Dublin', - 'Europe/Gibraltar' => 'Europe/Gibraltar', - 'Europe/Guernsey' => 'Europe/Guernsey', - 'Europe/Helsinki' => 'Europe/Helsinki', - 'Europe/Isle_of_Man' => 'Europe/Isle of Man', - 'Europe/Istanbul' => 'Europe/Istanbul', - 'Europe/Jersey' => 'Europe/Jersey', - 'Europe/Kaliningrad' => 'Europe/Kaliningrad', - 'Europe/Kiev' => 'Europe/Kiev', - 'Europe/Lisbon' => 'Europe/Lisbon', - 'Europe/Ljubljana' => 'Europe/Ljubljana', - 'Europe/London' => 'Europe/London', - 'Europe/Luxembourg' => 'Europe/Luxembourg', - 'Europe/Madrid' => 'Europe/Madrid', - 'Europe/Malta' => 'Europe/Malta', - 'Europe/Mariehamn' => 'Europe/Mariehamn', - 'Europe/Minsk' => 'Europe/Minsk', - 'Europe/Monaco' => 'Europe/Monaco', - 'Europe/Moscow' => 'Europe/Moscow', - 'Europe/Oslo' => 'Europe/Oslo', - 'Europe/Paris' => 'Europe/Paris', - 'Europe/Podgorica' => 'Europe/Podgorica', - 'Europe/Prague' => 'Europe/Prague', - 'Europe/Riga' => 'Europe/Riga', - 'Europe/Rome' => 'Europe/Rome', - 'Europe/Samara' => 'Europe/Samara', - 'Europe/San_Marino' => 'Europe/San Marino', - 'Europe/Sarajevo' => 'Europe/Sarajevo', - 'Europe/Simferopol' => 'Europe/Simferopol', - 'Europe/Skopje' => 'Europe/Skopje', - 'Europe/Sofia' => 'Europe/Sofia', - 'Europe/Stockholm' => 'Europe/Stockholm', - 'Europe/Tallinn' => 'Europe/Tallinn', - 'Europe/Tirane' => 'Europe/Tirane', - 'Europe/Uzhgorod' => 'Europe/Uzhgorod', - 'Europe/Vaduz' => 'Europe/Vaduz', - 'Europe/Vatican' => 'Europe/Vatican', - 'Europe/Vienna' => 'Europe/Vienna', - 'Europe/Vilnius' => 'Europe/Vilnius', - 'Europe/Volgograd' => 'Europe/Volgograd', - 'Europe/Warsaw' => 'Europe/Warsaw', - 'Europe/Zagreb' => 'Europe/Zagreb', - 'Europe/Zaporozhye' => 'Europe/Zaporozhye', - 'Europe/Zurich' => 'Europe/Zurich', - - 'Indian/Antananarivo' => 'Indian/Antananarivo', - 'Indian/Chagos' => 'Indian/Chagos', - 'Indian/Christmas' => 'Indian/Christmas', - 'Indian/Cocos' => 'Indian/Cocos', - 'Indian/Comoro' => 'Indian/Comoro', - 'Indian/Kerguelen' => 'Indian/Kerguelen', - 'Indian/Mahe' => 'Indian/Mahe', - 'Indian/Maldives' => 'Indian/Maldives', - 'Indian/Mauritius' => 'Indian/Mauritius', - 'Indian/Mayotte' => 'Indian/Mayotte', - 'Indian/Reunion' => 'Indian/Reunion', - - 'Pacific/Apia' => 'Pacific/Apia', - 'Pacific/Auckland' => 'Pacific/Auckland', - 'Pacific/Chatham' => 'Pacific/Chatham', - 'Pacific/Chuuk' => 'Pacific/Chuuk', - 'Pacific/Easter' => 'Pacific/Easter', - 'Pacific/Efate' => 'Pacific/Efate', - 'Pacific/Enderbury' => 'Pacific/Enderbury', - 'Pacific/Fakaofo' => 'Pacific/Fakaofo', - 'Pacific/Fiji' => 'Pacific/Fiji', - 'Pacific/Funafuti' => 'Pacific/Funafuti', - 'Pacific/Galapagos' => 'Pacific/Galapagos', - 'Pacific/Gambier' => 'Pacific/Gambier', - 'Pacific/Guadalcanal' => 'Pacific/Guadalcanal', - 'Pacific/Guam' => 'Pacific/Guam', - 'Pacific/Honolulu' => 'Pacific/Honolulu', - 'Pacific/Johnston' => 'Pacific/Johnston', - 'Pacific/Kiritimati' => 'Pacific/Kiritimati', - 'Pacific/Kosrae' => 'Pacific/Kosrae', - 'Pacific/Kwajalein' => 'Pacific/Kwajalein', - 'Pacific/Majuro' => 'Pacific/Majuro', - 'Pacific/Marquesas' => 'Pacific/Marquesas', - 'Pacific/Midway' => 'Pacific/Midway', - 'Pacific/Nauru' => 'Pacific/Nauru', - 'Pacific/Niue' => 'Pacific/Niue', - 'Pacific/Norfolk' => 'Pacific/Norfolk', - 'Pacific/Noumea' => 'Pacific/Noumea', - 'Pacific/Pago_Pago' => 'Pacific/Pago Pago', - 'Pacific/Palau' => 'Pacific/Palau', - 'Pacific/Pitcairn' => 'Pacific/Pitcairn', - 'Pacific/Pohnpei' => 'Pacific/Pohnpei', - 'Pacific/Port_Moresby' => 'Pacific/Port Moresby', - 'Pacific/Rarotonga' => 'Pacific/Rarotonga', - 'Pacific/Saipan' => 'Pacific/Saipan', - 'Pacific/Tahiti' => 'Pacific/Tahiti', - 'Pacific/Tarawa' => 'Pacific/Tarawa', - 'Pacific/Tongatapu' => 'Pacific/Tongatapu', - 'Pacific/Wake' => 'Pacific/Wake', - 'Pacific/Wallis' => 'Pacific/Wallis', - ), - - // The value is only an example and will get replaced by the current time on view - 'dateformats' => array( - 'd M Y, H:i' => '01 Jan 2007, 13:37', - 'd M Y H:i' => '01 Jan 2007 13:37', - 'M jS, \'y, H:i' => 'Jan 1st, \'07, 13:37', - 'D M d, Y g:i a' => 'Mon Jan 01, 2007 1:37 pm', - 'F jS, Y, g:i a' => 'January 1st, 2007, 1:37 pm', - '|d M Y|, H:i' => 'Today, 13:37 / 01 Jan 2007, 13:37', - '|F jS, Y|, g:i a' => 'Today, 1:37 pm / January 1st, 2007, 1:37 pm', - ), - - // The default dateformat which will be used on new installs in this language - // Translators should change this if a the usual date format is different - 'default_dateformat' => 'D M d, Y g:i a', // Mon Jan 01, 2007 1:37 pm - -)); diff --git a/install/update/new/language/en/email/admin_activate.txt b/install/update/new/language/en/email/admin_activate.txt deleted file mode 100644 index 71faca7..0000000 --- a/install/update/new/language/en/email/admin_activate.txt +++ /dev/null @@ -1,13 +0,0 @@ -Subject: Activate user account - -Hello, - -The account owned by "{USERNAME}" has been deactivated or newly created, you should check the details of this user (if required) and handle it appropriately. - -Use this link to view the user's profile: -{U_USER_DETAILS} - -You may activate the account immediately by clicking on this link: -{U_ACTIVATE} - -{EMAIL_SIG} diff --git a/install/update/new/language/en/email/user_forgot_password.txt b/install/update/new/language/en/email/user_forgot_password.txt deleted file mode 100644 index 4826a7b..0000000 --- a/install/update/new/language/en/email/user_forgot_password.txt +++ /dev/null @@ -1,13 +0,0 @@ -Subject: Account password reset - -Hello {USERNAME} - -You are receiving this notification because you have requested to recover a forgotten password for your account on "{SITENAME}". - -To reset your password, please click the link provided below: - -{U_RESET_PASSWORD} - -If you did not authorize the request you can ignore this email. Please contact the board administrator if you keep receiving it. - -{EMAIL_SIG} diff --git a/install/update/new/language/en/install.php b/install/update/new/language/en/install.php deleted file mode 100644 index 530c003..0000000 --- a/install/update/new/language/en/install.php +++ /dev/null @@ -1,598 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -/** - * DO NOT CHANGE - */ -if (!defined('IN_PHPBB')) -{ - exit; -} - -if (empty($lang) || !is_array($lang)) -{ - $lang = array(); -} - -// DEVELOPERS PLEASE NOTE -// -// All language files should use UTF-8 as their encoding and the files must not contain a BOM. -// -// Placeholders can now contain order information, e.g. instead of -// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows -// translators to re-order the output of data while ensuring it remains correct -// -// You do not need this where single placeholders are used, e.g. 'Message %d' is fine -// equally where a string contains only two placeholders which are used to wrap text -// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine - -// Common installer pages -$lang = array_merge($lang, array( - 'INSTALL_PANEL' => 'Installation Panel', - 'SELECT_LANG' => 'Select language', - - 'STAGE_INSTALL' => 'Installing phpBB', - - // Introduction page - 'INTRODUCTION_TITLE' => 'Introduction', - 'INTRODUCTION_BODY' => 'Welcome to phpBB3!

phpBB® is the most widely used open source bulletin board solution in the world. phpBB3 is the latest installment in a package line started in 2000. Like its predecessors, phpBB3 is feature-rich, user-friendly, and fully supported by the phpBB Team. phpBB3 greatly improves on what made phpBB2 popular, and adds commonly requested features that were not present in previous versions. We hope it exceeds your expectations.

This installation system will guide you through installing phpBB3, updating to the latest version of phpBB3 from past releases, as well as converting to phpBB3 from a different discussion board system (including phpBB2). For more information, we encourage you to read the installation guide.

To read the phpBB3 license or learn about obtaining support and our stance on it, please select the respective options from the side menu. To continue, please select the appropriate tab above.', - - // Support page - 'SUPPORT_TITLE' => 'Support', - 'SUPPORT_BODY' => 'Full support will be provided for the current stable release of phpBB3, free of charge. This includes:

  • installation
  • configuration
  • technical questions
  • problems relating to potential bugs in the software
  • updating from Release Candidate (RC) versions to the latest stable version
  • converting from phpBB 2.0.x to phpBB3
  • converting from other discussion board software to phpBB3 (please see the Convertors Forum)

We encourage users still running beta versions of phpBB3 to replace their installation with a fresh copy of the latest version.

Extensions / Styles

For issues relating to Extensions, please post in the appropriate Extensions Forum.
For issues relating to styles, templates and themes, please post in the appropriate Styles Forum.

If your question relates to a specific package, please post directly in the topic dedicated to the package.

Obtaining Support

Support Section
Quick Start Guide

To ensure you stay up to date with the latest news and releases, follow us on Twitter and Facebook

', - - // License - 'LICENSE_TITLE' => 'General Public License', - - // Install page - 'INSTALL_INTRO' => 'Welcome to Installation', - 'INSTALL_INTRO_BODY' => 'With this option, it is possible to install phpBB3 onto your server.

In order to proceed, you will need your database settings. If you do not know your database settings, please contact your host and ask for them. You will not be able to continue without them. You need:

- -
    -
  • The Database Type - the database you will be using.
  • -
  • The Database server hostname or DSN - the address of the database server.
  • -
  • The Database server port - the port of the database server (most of the time this is not needed).
  • -
  • The Database name - the name of the database on the server.
  • -
  • The Database username and Database password - the login data to access the database.
  • -
- -

Note: if you are installing using SQLite, you should enter the full path to your database file in the DSN field and leave the username and password fields blank. For security reasons, you should make sure that the database file is not stored in a location accessible from the web.

- -

phpBB3 supports the following databases:

-
    -
  • MySQL 4.1.3 or above (MySQLi required)
  • -
  • PostgreSQL 8.3+
  • -
  • SQLite 3.6.15+
  • -
  • MS SQL Server 2000 or above (directly or via ODBC)
  • -
  • MS SQL Server 2005 or above (native)
  • -
  • Oracle
  • -
- -

Only those databases supported on your server will be displayed.', - - 'ACP_LINK' => 'Take me to the ACP', - - 'INSTALL_PHPBB_INSTALLED' => 'phpBB is already installed.', - 'INSTALL_PHPBB_NOT_INSTALLED' => 'phpBB is not installed yet.', -)); - -// Requirements translation -$lang = array_merge($lang, array( - // Filesystem requirements - 'FILE_NOT_EXISTS' => 'File does not exist', - 'FILE_NOT_EXISTS_EXPLAIN' => 'To be able to install phpBB the %1$s file needs to exist.', - 'FILE_NOT_EXISTS_EXPLAIN_OPTIONAL' => 'It is recommended that the %1$s file exist for a better forum user experience.', - 'FILE_NOT_WRITABLE' => 'File is not writable', - 'FILE_NOT_WRITABLE_EXPLAIN' => 'To be able to install phpBB the %1$s file needs to be writable.', - 'FILE_NOT_WRITABLE_EXPLAIN_OPTIONAL' => 'It is recommended that the %1$s file be writable for a better forum user experience.', - - 'DIRECTORY_NOT_EXISTS' => 'Directory does not exist', - 'DIRECTORY_NOT_EXISTS_EXPLAIN' => 'To be able to install phpBB the %1$s directory needs to exist.', - 'DIRECTORY_NOT_EXISTS_EXPLAIN_OPTIONAL' => 'It is recommended that the %1$s directory exist for a better forum user experience.', - 'DIRECTORY_NOT_WRITABLE' => 'Directory is not writable', - 'DIRECTORY_NOT_WRITABLE_EXPLAIN' => 'To be able to install phpBB the %1$s directory needs to be writable.', - 'DIRECTORY_NOT_WRITABLE_EXPLAIN_OPTIONAL' => 'It is recommended that the %1$s directory be writable for a better forum user experience.', - - // Server requirements - 'PHP_VERSION_REQD' => 'PHP version', - 'PHP_VERSION_REQD_EXPLAIN' => 'phpBB requires PHP version 7.1.3 or higher.', - 'PHP_GETIMAGESIZE_SUPPORT' => 'PHP getimagesize() function is required', - 'PHP_GETIMAGESIZE_SUPPORT_EXPLAIN' => 'In order for phpBB to function correctly, the getimagesize function needs to be available.', - 'PCRE_UTF_SUPPORT' => 'PCRE UTF-8 support', - 'PCRE_UTF_SUPPORT_EXPLAIN' => 'phpBB will not run if your PHP installation is not compiled with UTF-8 support in the PCRE extension.', - 'PHP_JSON_SUPPORT' => 'PHP JSON support', - 'PHP_JSON_SUPPORT_EXPLAIN' => 'In order for phpBB to function correctly, the PHP JSON extension needs to be available.', - 'PHP_XML_SUPPORT' => 'PHP XML/DOM support', - 'PHP_XML_SUPPORT_EXPLAIN' => 'In order for phpBB to function correctly, the PHP XML/DOM extension needs to be available.', - 'PHP_SUPPORTED_DB' => 'Supported databases', - 'PHP_SUPPORTED_DB_EXPLAIN' => 'You must have support for at least one compatible database within PHP. If no database modules are shown as available you should contact your hosting provider or review the relevant PHP installation documentation for advice.', - - 'RETEST_REQUIREMENTS' => 'Retest requirements', - - 'STAGE_REQUIREMENTS' => 'Check requirements', -)); - -// General error messages -$lang = array_merge($lang, array( - 'INST_ERR_MISSING_DATA' => 'You must fill out all fields in this block.', - - 'TIMEOUT_DETECTED_TITLE' => 'The installer detected a timeout', - 'TIMEOUT_DETECTED_MESSAGE' => 'The installer has detected a timeout, you may try to refresh the page, which may lead to data corruption. We suggest that you either increase your timeout settings or try to use the CLI.', -)); - -// Data obtaining translations -$lang = array_merge($lang, array( - 'STAGE_OBTAIN_DATA' => 'Set installation data', - - // - // Admin data - // - 'STAGE_ADMINISTRATOR' => 'Administrator details', - - // Form labels - 'ADMIN_CONFIG' => 'Administrator configuration', - 'ADMIN_PASSWORD' => 'Administrator password', - 'ADMIN_PASSWORD_CONFIRM' => 'Confirm administrator password', - 'ADMIN_PASSWORD_EXPLAIN' => 'Please enter a password between 6 and 30 characters in length.', - 'ADMIN_USERNAME' => 'Administrator username', - 'ADMIN_USERNAME_EXPLAIN' => 'Please enter a username between 3 and 20 characters in length.', - - // Errors - 'INST_ERR_EMAIL_INVALID' => 'The email address you entered is invalid.', - 'INST_ERR_PASSWORD_MISMATCH' => 'The passwords you entered did not match.', - 'INST_ERR_PASSWORD_TOO_LONG' => 'The password you entered is too long. The maximum length is 30 characters.', - 'INST_ERR_PASSWORD_TOO_SHORT' => 'The password you entered is too short. The minimum length is 6 characters.', - 'INST_ERR_USER_TOO_LONG' => 'The username you entered is too long. The maximum length is 20 characters.', - 'INST_ERR_USER_TOO_SHORT' => 'The username you entered is too short. The minimum length is 3 characters.', - - // - // Board data - // - // Form labels - 'BOARD_CONFIG' => 'Bulletin board configuration', - 'DEFAULT_LANGUAGE' => 'Default language', - 'BOARD_NAME' => 'Title of the board', - 'BOARD_DESCRIPTION' => 'Short description of the board', - - // - // Database data - // - 'STAGE_DATABASE' => 'Database settings', - - // Form labels - 'DB_CONFIG' => 'Database configuration', - 'DBMS' => 'Database type', - 'DB_HOST' => 'Database server hostname or DSN', - 'DB_HOST_EXPLAIN' => 'DSN stands for Data Source Name and is relevant only for ODBC installs. On PostgreSQL, use localhost to connect to the local server via UNIX domain socket and 127.0.0.1 to connect via TCP. For SQLite, enter the full path to your database file.', - 'DB_PORT' => 'Database server port', - 'DB_PORT_EXPLAIN' => 'Leave this blank unless you know the server operates on a non-standard port.', - 'DB_PASSWORD' => 'Database password', - 'DB_NAME' => 'Database name', - 'DB_USERNAME' => 'Database username', - 'DATABASE_VERSION' => 'Database version', - 'TABLE_PREFIX' => 'Prefix for tables in database', - 'TABLE_PREFIX_EXPLAIN' => 'The prefix must start with a letter and must only contain letters, numbers and underscores.', - - // Database options - 'DB_OPTION_MSSQL_ODBC' => 'MSSQL Server 2000+ via ODBC', - 'DB_OPTION_MSSQLNATIVE' => 'MSSQL Server 2005+ [ Native ]', - 'DB_OPTION_MYSQLI' => 'MySQL with MySQLi Extension', - 'DB_OPTION_ORACLE' => 'Oracle', - 'DB_OPTION_POSTGRES' => 'PostgreSQL', - 'DB_OPTION_SQLITE3' => 'SQLite 3', - - // Errors - 'INST_ERR_DB' => 'Database installation error', - 'INST_ERR_NO_DB' => 'Cannot load the PHP module for the selected database type.', - 'INST_ERR_DB_INVALID_PREFIX' => 'The prefix you entered is invalid. It must start with a letter and must only contain letters, numbers and underscores.', - 'INST_ERR_PREFIX_TOO_LONG' => 'The table prefix you have specified is too long. The maximum length is %d characters.', - 'INST_ERR_DB_NO_NAME' => 'No database name specified.', - 'INST_ERR_DB_FORUM_PATH' => 'The database file specified is within your board directory tree. You should put this file in a non web-accessible location.', - 'INST_ERR_DB_CONNECT' => 'Could not connect to the database, see error message below.', - 'INST_ERR_DB_NO_WRITABLE' => 'Both the database and the directory containing it must be writable.', - 'INST_ERR_DB_NO_ERROR' => 'No error message given.', - 'INST_ERR_PREFIX' => 'Tables with the specified prefix already exist, please choose an alternative.', - 'INST_ERR_DB_NO_MYSQLI' => 'The version of MySQL installed on this machine is incompatible with the “MySQL with MySQLi Extension” option you have selected. Please try the “MySQL” option instead.', - 'INST_ERR_DB_NO_SQLITE3' => 'The version of the SQLite extension you have installed is too old, it must be upgraded to at least 3.6.15.', - 'INST_ERR_DB_NO_ORACLE' => 'The version of Oracle installed on this machine requires you to set the NLS_CHARACTERSET parameter to UTF8. Either upgrade your installation to 9.2+ or change the parameter.', - 'INST_ERR_DB_NO_POSTGRES' => 'The database you have selected was not created in UNICODE or UTF8 encoding. Try installing with a database in UNICODE or UTF8 encoding.', - 'INST_SCHEMA_FILE_NOT_WRITABLE' => 'The schema file is not writable', - - // - // Email data - // - 'EMAIL_CONFIG' => 'E-mail configuration', - - // Package info - 'PACKAGE_VERSION' => 'Package version installed', - 'UPDATE_INCOMPLETE' => 'Your phpBB installation has not been correctly updated.', - 'UPDATE_INCOMPLETE_MORE' => 'Please read the information below in order to fix this error.', - 'UPDATE_INCOMPLETE_EXPLAIN' => '

Incomplete update

- -

We noticed that the last update of your phpBB installation hasn’t been completed. Visit the database updater, ensure Update database only is selected and click on Submit. Don\'t forget to delete the "install"-directory after you have updated the database successfully.

', - - // - // Server data - // - // Form labels - 'UPGRADE_INSTRUCTIONS' => 'A new feature release %1$s is available. Please read the release announcement to learn about what it has to offer, and how to upgrade.', - 'SERVER_CONFIG' => 'Server configuration', - 'SCRIPT_PATH' => 'Script path', - 'SCRIPT_PATH_EXPLAIN' => 'The path where phpBB is located relative to the domain name, e.g. /phpBB3.', -)); - -// Default database schema entries... -$lang = array_merge($lang, array( - 'CONFIG_BOARD_EMAIL_SIG' => 'Thanks, The Management', - 'CONFIG_SITE_DESC' => 'A short text to describe your forum', - 'CONFIG_SITENAME' => 'yourdomain.com', - - 'DEFAULT_INSTALL_POST' => 'This is an example post in your phpBB3 installation. Everything seems to be working. You may delete this post if you like and continue to set up your board. During the installation process your first category and your first forum are assigned an appropriate set of permissions for the predefined usergroups administrators, bots, global moderators, guests, registered users and registered COPPA users. If you also choose to delete your first category and your first forum, do not forget to assign permissions for all these usergroups for all new categories and forums you create. It is recommended to rename your first category and your first forum and copy permissions from these while creating new categories and forums. Have fun!', - - 'FORUMS_FIRST_CATEGORY' => 'Your first category', - 'FORUMS_TEST_FORUM_DESC' => 'Description of your first forum.', - 'FORUMS_TEST_FORUM_TITLE' => 'Your first forum', - - 'RANKS_SITE_ADMIN_TITLE' => 'Site Admin', - 'REPORT_WAREZ' => 'The post contains links to illegal or pirated software.', - 'REPORT_SPAM' => 'The reported post has the only purpose to advertise for a website or another product.', - 'REPORT_OFF_TOPIC' => 'The reported post is off topic.', - 'REPORT_OTHER' => 'The reported post does not fit into any other category, please use the further information field.', - - 'SMILIES_ARROW' => 'Arrow', - 'SMILIES_CONFUSED' => 'Confused', - 'SMILIES_COOL' => 'Cool', - 'SMILIES_CRYING' => 'Crying or Very Sad', - 'SMILIES_EMARRASSED' => 'Embarrassed', - 'SMILIES_EVIL' => 'Evil or Very Mad', - 'SMILIES_EXCLAMATION' => 'Exclamation', - 'SMILIES_GEEK' => 'Geek', - 'SMILIES_IDEA' => 'Idea', - 'SMILIES_LAUGHING' => 'Laughing', - 'SMILIES_MAD' => 'Mad', - 'SMILIES_MR_GREEN' => 'Mr. Green', - 'SMILIES_NEUTRAL' => 'Neutral', - 'SMILIES_QUESTION' => 'Question', - 'SMILIES_RAZZ' => 'Razz', - 'SMILIES_ROLLING_EYES' => 'Rolling Eyes', - 'SMILIES_SAD' => 'Sad', - 'SMILIES_SHOCKED' => 'Shocked', - 'SMILIES_SMILE' => 'Smile', - 'SMILIES_SURPRISED' => 'Surprised', - 'SMILIES_TWISTED_EVIL' => 'Twisted Evil', - 'SMILIES_UBER_GEEK' => 'Uber Geek', - 'SMILIES_VERY_HAPPY' => 'Very Happy', - 'SMILIES_WINK' => 'Wink', - - 'TOPICS_TOPIC_TITLE' => 'Welcome to phpBB3', -)); - -// Common navigation items' translation -$lang = array_merge($lang, array( - 'MENU_OVERVIEW' => 'Overview', - 'MENU_INTRO' => 'Introduction', - 'MENU_LICENSE' => 'License', - 'MENU_SUPPORT' => 'Support', -)); - -// Task names -$lang = array_merge($lang, array( - // Install filesystem - 'TASK_CREATE_CONFIG_FILE' => 'Creating configuration file', - - // Install database - 'TASK_ADD_CONFIG_SETTINGS' => 'Adding configuration settings', - 'TASK_ADD_DEFAULT_DATA' => 'Adding default settings to the database', - 'TASK_CREATE_DATABASE_SCHEMA_FILE' => 'Creating database schema file', - 'TASK_SETUP_DATABASE' => 'Setting up database', - 'TASK_CREATE_TABLES' => 'Creating tables', - - // Install data - 'TASK_ADD_BOTS' => 'Registering bots', - 'TASK_ADD_LANGUAGES' => 'Installing available languages', - 'TASK_ADD_MODULES' => 'Installing modules', - 'TASK_CREATE_SEARCH_INDEX' => 'Creating search index', - - // Install finish tasks - 'TASK_INSTALL_EXTENSIONS' => 'Installing packaged extensions', - 'TASK_NOTIFY_USER' => 'Sending notification e-mail', - 'TASK_POPULATE_MIGRATIONS' => 'Populating migrations', - - // Installer general progress messages - 'INSTALLER_FINISHED' => 'The installer has finished successfully', -)); - -// Installer's general messages -$lang = array_merge($lang, array( - 'MODULE_NOT_FOUND' => 'Module not found', - 'MODULE_NOT_FOUND_DESCRIPTION' => 'A module could not be found because the service, %s, is undefined.', - - 'TASK_NOT_FOUND' => 'Task not found', - 'TASK_NOT_FOUND_DESCRIPTION' => 'A task could not be found because the service, %s, is undefined.', - - 'SKIP_MODULE' => 'Skip “%s” module', - 'SKIP_TASK' => 'Skip “%s” task', - - 'TASK_SERVICE_INSTALLER_MISSING' => 'All installer task services should start with “installer”', - 'TASK_CLASS_NOT_FOUND' => 'Installer task service definition is invalid. Service name “%1$s” given, the expected class namespace is “%2$s” for that. For more information please see the documentation of task_interface.', - - 'INSTALLER_CONFIG_NOT_WRITABLE' => 'The installer config file is not writable.', -)); - -// CLI messages -$lang = array_merge($lang, array( - 'CLI_INSTALL_BOARD' => 'Install phpBB', - 'CLI_UPDATE_BOARD' => 'Update phpBB', - 'CLI_INSTALL_SHOW_CONFIG' => 'Show the configuration which will be used', - 'CLI_INSTALL_VALIDATE_CONFIG' => 'Validate a configuration file', - 'CLI_CONFIG_FILE' => 'Config file to use', - 'MISSING_FILE' => 'Unable to access file %1$s', - 'MISSING_DATA' => 'Config file is missing data or might contain invalid settings.', - 'INVALID_YAML_FILE' => 'Could not parse YAML file %1$s', - 'CONFIGURATION_VALID' => 'The configuration file is valid', -)); - -// Common updater messages -$lang = array_merge($lang, array( - 'UPDATE_INSTALLATION' => 'Update phpBB installation', - 'UPDATE_INSTALLATION_EXPLAIN' => 'With this option, it is possible to update your phpBB installation to the latest version.
During the process all of your files will be checked for their integrity. You are able to review all differences and files before the update.

The file update itself can be done in two different ways.

Manual Update

With this update you only download your personal set of changed files to make sure you do not lose your file modifications you may have done. After you downloaded this package you need to manually upload the files to their correct position under your phpBB root directory. Once done, you are able to do the file check stage again to see if you moved the files to their correct location.

Automatic Update with FTP

This method is similar to the first one but without the need to download the changed files and uploading them on your own. This will be done for you. In order to use this method you need to know your FTP login details since you will be asked for them. Once finished you will be redirected to the file check again to make sure everything got updated correctly.

', - 'UPDATE_INSTRUCTIONS' => ' - -

Release announcement

- -

Please read the release announcement for the latest version before you continue your update process, it may contain useful information. It also contains full download links as well as the change log.

- -
- -

How to update your installation with the Full Package

- -

The recommended way of updating your installation is using the full package. If core phpBB files have been modified in your installation you may wish to use the automatic update package in order to not lose these changes. You are also able to update your installation using the other methods listed within the INSTALL.html document. The steps for updating phpBB3 using the full package are:

- -
    -
  1. Backup all board files and the database.
  2. -
  3. Go to the phpBB.com downloads page and download the latest "Full Package" archive.
  4. -
  5. Unpack the archive.
  6. -
  7. Remove (delete) the config.php file, and the /images, /store and /files folders from the package (not your site).
  8. -
  9. Go to the ACP, Board settings, and make sure prosilver is set as the default style. If not, set it to prosilver.
  10. -
  11. Delete the /vendor and /cache folders from the board’s root folder on the host.
  12. -
  13. Via FTP or SSH upload the remaining files and folders (that is, the remaining CONTENTS of the phpBB3 folder) to the root folder of your board installation on the server, overwriting the existing files. (Note: take care not to delete any extensions in your /ext folder when uploading the new phpBB3 contents.)
  14. -
  15. Now start the update process by pointing your browser to the install folder.
  16. -
  17. Follow the steps to update the database and let that run to completion.
  18. -
  19. Via FTP or SSH delete the /install folder from the root of your board installation.

  20. -
- -

You now have a new up to date board containing all your users and posts. Follow up tasks:

-
    -
  • Update your language pack
  • -
  • Update your style

  • -
- -

How to update your installation with the Automatic Update Package

- -

The automatic update package is only recommended in case core phpBB files have been modified in your installation. You are also able to update your installation using the methods listed within the INSTALL.html document. The steps for updating phpBB3 using the automatic update package are:

- -
    -
  1. Go to the phpBB.com downloads page and download the "Automatic Update Package" archive.
  2. -
  3. Unpack the archive.
  4. -
  5. Upload the complete uncompressed "install" and "vendor" folders to your phpBB root directory (where your config.php file is).

  6. -
- -

Once uploaded your board will be offline for normal users due to the install directory you uploaded now being present.

- Now start the update process by pointing your browser to the install folder.
-
- You will then be guided through the update process. You will be notified once the update is complete. -

- ', -)); - -// Updater forms -$lang = array_merge($lang, array( - // Updater types - 'UPDATE_TYPE' => 'Type of update to run', - - 'UPDATE_TYPE_ALL' => 'Update filesystem and database', - 'UPDATE_TYPE_DB_ONLY' => 'Update database only', - - // File updater methods - 'UPDATE_FILE_METHOD_TITLE' => 'File updater methods', - - 'UPDATE_FILE_METHOD' => 'File updater method', - 'UPDATE_FILE_METHOD_DOWNLOAD' => 'Download modified files in an archive', - 'UPDATE_FILE_METHOD_FTP' => 'Update files via FTP (Automatic)', - 'UPDATE_FILE_METHOD_FILESYSTEM' => 'Update files via direct file access (Automatic)', - - // File updater archives - 'SELECT_DOWNLOAD_FORMAT' => 'Select download archive format', - - // FTP settings - 'FTP_SETTINGS' => 'FTP settings', -)); - -// Requirements messages -$lang = array_merge($lang, array( - 'UPDATE_FILES_NOT_FOUND' => 'No valid update directory was found, please make sure you uploaded the relevant files.', - - 'NO_UPDATE_FILES_UP_TO_DATE' => 'Your version is up to date. There is no need to run the update tool. If you want to make an integrity check on your files make sure you uploaded the correct update files.', - 'OLD_UPDATE_FILES' => 'Update files are out of date. The update files found are for updating from phpBB %1$s to phpBB %2$s but the latest version of phpBB is %3$s.', - 'INCOMPATIBLE_UPDATE_FILES' => 'The update files found are incompatible with your installed version. Your installed version is %1$s and the update file is for updating phpBB %2$s to %3$s.', -)); - -// Update files -$lang = array_merge($lang, array( - 'STAGE_UPDATE_FILES' => 'Update files', - - // Check files - 'UPDATE_CHECK_FILES' => 'Check files to update', - - // Update file differ - 'FILE_DIFFER_ERROR_FILE_CANNOT_BE_READ' => 'The file differ failed to open %s.', - - 'UPDATE_FILE_DIFF' => 'Diffing changed files', - 'ALL_FILES_DIFFED' => 'All modified files has been diffed.', - - // File status - 'UPDATE_CONTINUE_FILE_UPDATE' => 'Update files', - - 'DOWNLOAD' => 'Download', - 'DOWNLOAD_CONFLICTS' => 'Download merge conflicts archive', - 'DOWNLOAD_CONFLICTS_EXPLAIN' => 'Search for <<< to spot conflicts', - 'DOWNLOAD_UPDATE_METHOD' => 'Download modified files archive', - 'DOWNLOAD_UPDATE_METHOD_EXPLAIN' => 'Once downloaded you should unpack the archive. You will find the modified files you need to upload to your phpBB root directory within it. Please upload the files to their respective locations then. After you have uploaded all files, you may continue with the update process.', - - 'FILE_ALREADY_UP_TO_DATE' => 'File is already up to date.', - 'FILE_DIFF_NOT_ALLOWED' => 'File not allowed to be diffed.', - 'FILE_USED' => 'Information used from', // Single file - 'FILES_CONFLICT' => 'Conflict files', - 'FILES_CONFLICT_EXPLAIN' => 'The following files are modified and do not represent the original files from the old version. phpBB determined that these files create conflicts if they are tried to be merged. Please investigate the conflicts and try to manually resolve them or continue the update choosing the preferred merging method. If you resolve the conflicts manually check the files again after you modified them. You are also able to choose between the preferred merge method for every file. The first one will result in a file where the conflicting lines from your old file will be lost, the other one will result in losing the changes from the newer file.', - 'FILES_DELETED' => 'Deleted files', - 'FILES_DELETED_EXPLAIN' => 'The following files do not exist in the new version. These files have to be deleted from your installation.', - 'FILES_MODIFIED' => 'Modified files', - 'FILES_MODIFIED_EXPLAIN' => 'The following files are modified and do not represent the original files from the old version. The updated file will be a merge between your modifications and the new file.', - 'FILES_NEW' => 'New files', - 'FILES_NEW_EXPLAIN' => 'The following files currently do not exist within your installation. These files will be added to your installation.', - 'FILES_NEW_CONFLICT' => 'New conflicting files', - 'FILES_NEW_CONFLICT_EXPLAIN' => 'The following files are new within the latest version but it has been determined that there is already a file with the same name within the same position. This file will be overwritten by the new file.', - 'FILES_NOT_MODIFIED' => 'Not modified files', - 'FILES_NOT_MODIFIED_EXPLAIN' => 'The following files are not modified and represent the original phpBB files from the version you want to update from.', - 'FILES_UP_TO_DATE' => 'Already updated files', - 'FILES_UP_TO_DATE_EXPLAIN' => 'The following files are already up to date and do not need to be updated.', - 'FILES_VERSION' => 'Files Version', - 'TOGGLE_DISPLAY' => 'View/Hide file list', - - // File updater - 'UPDATE_UPDATING_FILES' => 'Updating files', - - 'UPDATE_FILE_UPDATER_HAS_FAILED' => 'File updater “%1$s“ has failed. The installer will try to fallback to “%2$s“.', - 'UPDATE_FILE_UPDATERS_HAVE_FAILED' => 'The file updater failed. No further fallback methods are available.', - - 'UPDATE_CONTINUE_UPDATE_PROCESS' => 'Continue update process', - 'UPDATE_RECHECK_UPDATE_FILES' => 'Check files again', -)); - -// Update database -$lang = array_merge($lang, array( - 'STAGE_UPDATE_DATABASE' => 'Update database', - - 'INLINE_UPDATE_SUCCESSFUL' => 'The database update was successful.', - - 'TASK_UPDATE_EXTENSIONS' => 'Updating extensions', -)); - -// Converter -$lang = array_merge($lang, array( - // Common converter messages - 'CONVERT_NOT_EXIST' => 'The specified convertor does not exist.', - 'DEV_NO_TEST_FILE' => 'No value has been specified for the test_file variable in the convertor. If you are a user of this convertor, you should not be seeing this error, please report this message to the convertor author. If you are a convertor author, you must specify the name of a file which exists in the source board to allow the path to it to be verified.', - 'COULD_NOT_FIND_PATH' => 'Could not find path to your former board. Please check your settings and try again.
» %s was specified as the source path.', - 'CONFIG_PHPBB_EMPTY' => 'The phpBB3 config variable for “%s” is empty.', - - 'MAKE_FOLDER_WRITABLE' => 'Please make sure that this folder exists and is writable by the webserver then try again:
»%s.', - 'MAKE_FOLDERS_WRITABLE' => 'Please make sure that these folders exist and are writable by the webserver then try again:
»%s.', - - 'INSTALL_TEST' => 'Test again', - - 'NO_TABLES_FOUND' => 'No tables found.', - 'TABLES_MISSING' => 'Could not find these tables
» %s.', - 'CHECK_TABLE_PREFIX' => 'Please check your table prefix and try again.', - - // Conversion in progress - 'CONTINUE_CONVERT' => 'Continue conversion', - 'CONTINUE_CONVERT_BODY' => 'A previous conversion attempt has been determined. You are now able to choose between starting a new conversion or continuing the conversion.', - 'CONVERT_NEW_CONVERSION' => 'New conversion', - 'CONTINUE_OLD_CONVERSION' => 'Continue previously started conversion', - - // Start conversion - 'SUB_INTRO' => 'Introduction', - 'CONVERT_INTRO' => 'Welcome to the phpBB Unified Convertor Framework', - 'CONVERT_INTRO_BODY' => 'From here, you are able to import data from other (installed) board systems. The list below shows all the conversion modules currently available. If there is no convertor shown in this list for the board software you wish to convert from, please check our website where further conversion modules may be available for download.', - 'AVAILABLE_CONVERTORS' => 'Available convertors', - 'NO_CONVERTORS' => 'No convertors are available for use.', - 'CONVERT_OPTIONS' => 'Options', - 'SOFTWARE' => 'Board software', - 'VERSION' => 'Version', - 'CONVERT' => 'Convert', - - // Settings - 'STAGE_SETTINGS' => 'Settings', - 'TABLE_PREFIX_SAME' => 'The table prefix needs to be the one used by the software you are converting from.
» Specified table prefix was %s.', - 'DEFAULT_PREFIX_IS' => 'The convertor was not able to find tables with the specified prefix. Please make sure you have entered the correct details for the board you are converting from. The default table prefix for %1$s is %2$s.', - 'SPECIFY_OPTIONS' => 'Specify conversion options', - 'FORUM_PATH' => 'Board path', - 'FORUM_PATH_EXPLAIN' => 'This is the relative path on disk to your former board from the root of this phpBB3 installation.', - 'REFRESH_PAGE' => 'Refresh page to continue conversion', - 'REFRESH_PAGE_EXPLAIN' => 'If set to yes, the convertor will refresh the page to continue the conversion after having finished a step. If this is your first conversion for testing purposes and to determine any errors in advance, we suggest to set this to No.', - - // Conversion - 'STAGE_IN_PROGRESS' => 'Conversion in progress', - - 'AUTHOR_NOTES' => 'Author notes
» %s', - 'STARTING_CONVERT' => 'Starting conversion process', - 'CONFIG_CONVERT' => 'Converting the configuration', - 'DONE' => 'Done', - 'PREPROCESS_STEP' => 'Executing pre-processing functions/queries', - 'FILLING_TABLE' => 'Filling table %s', - 'FILLING_TABLES' => 'Filling tables', - 'DB_ERR_INSERT' => 'Error while processing INSERT query.', - 'DB_ERR_LAST' => 'Error while processing query_last.', - 'DB_ERR_QUERY_FIRST' => 'Error while executing query_first.', - 'DB_ERR_QUERY_FIRST_TABLE' => 'Error while executing query_first, %s (“%s”).', - 'DB_ERR_SELECT' => 'Error while running SELECT query.', - 'STEP_PERCENT_COMPLETED' => 'Step %d of %d', - 'FINAL_STEP' => 'Process final step', - 'SYNC_FORUMS' => 'Starting to synchronise forums', - 'SYNC_POST_COUNT' => 'Synchronising post_counts', - 'SYNC_POST_COUNT_ID' => 'Synchronising post_counts from entry %1$s to %2$s.', - 'SYNC_TOPICS' => 'Starting to synchronise topics', - 'SYNC_TOPIC_ID' => 'Synchronising topics from topic_id %1$s to %2$s.', - 'PROCESS_LAST' => 'Processing last statements', - 'UPDATE_TOPICS_POSTED' => 'Generating topics posted information', - 'UPDATE_TOPICS_POSTED_ERR' => 'An error occurred while generating topics posted information. You can retry this step in the ACP after the conversion process is completed.', - 'CONTINUE_LAST' => 'Continue last statements', - 'CLEAN_VERIFY' => 'Cleaning up and verifying the final structure', - 'NOT_UNDERSTAND' => 'Could not understand %s #%d, table %s (“%s”)', - 'NAMING_CONFLICT' => 'Naming conflict: %s and %s are both aliases

%s', - - // Finish conversion - 'CONVERT_COMPLETE' => 'Conversion completed', - 'CONVERT_COMPLETE_EXPLAIN' => 'You have now successfully converted your board to phpBB 3.3. You can now login and access your board. Please ensure that the settings were transferred correctly before enabling your board by deleting the install directory. Remember that help on using phpBB is available online via the Documentation and the support forums.', - - 'CONV_ERROR_ATTACH_FTP_DIR' => 'FTP upload for attachments is enabled at the old board. Please disable the FTP upload option and make sure a valid upload directory is specified, then copy all attachment files to this new web accessible directory. Once you have done this, restart the convertor.', - 'CONV_ERROR_CONFIG_EMPTY' => 'There is no configuration information available for the conversion.', - 'CONV_ERROR_FORUM_ACCESS' => 'Unable to get forum access information.', - 'CONV_ERROR_GET_CATEGORIES' => 'Unable to get categories.', - 'CONV_ERROR_GET_CONFIG' => 'Could not retrieve your board configuration.', - 'CONV_ERROR_COULD_NOT_READ' => 'Unable to access/read “%s”.', - 'CONV_ERROR_GROUP_ACCESS' => 'Unable to get group authentication information.', - 'CONV_ERROR_INCONSISTENT_GROUPS' => 'Inconsistency in groups table detected in add_bots() - you need to add all special groups if you do it manually.', - 'CONV_ERROR_INSERT_BOT' => 'Unable to insert bot into users table.', - 'CONV_ERROR_INSERT_BOTGROUP' => 'Unable to insert bot into bots table.', - 'CONV_ERROR_INSERT_USER_GROUP' => 'Unable to insert user into user_group table.', - 'CONV_ERROR_MESSAGE_PARSER' => 'Message parser error', - 'CONV_ERROR_NO_AVATAR_PATH' => 'Note to developer: you must specify $convertor[\'avatar_path\'] to use %s.', - 'CONV_ERROR_NO_FORUM_PATH' => 'The relative path to the source board has not been specified.', - 'CONV_ERROR_NO_GALLERY_PATH' => 'Note to developer: you must specify $convertor[\'avatar_gallery_path\'] to use %s.', - 'CONV_ERROR_NO_GROUP' => 'Group “%1$s” could not be found in %2$s.', - 'CONV_ERROR_NO_RANKS_PATH' => 'Note to developer: you must specify $convertor[\'ranks_path\'] to use %s.', - 'CONV_ERROR_NO_SMILIES_PATH' => 'Note to developer: you must specify $convertor[\'smilies_path\'] to use %s.', - 'CONV_ERROR_NO_UPLOAD_DIR' => 'Note to developer: you must specify $convertor[\'upload_path\'] to use %s.', - 'CONV_ERROR_PERM_SETTING' => 'Unable to insert/update permission setting.', - 'CONV_ERROR_PM_COUNT' => 'Unable to select folder pm count.', - 'CONV_ERROR_REPLACE_CATEGORY' => 'Unable to insert new forum replacing old category.', - 'CONV_ERROR_REPLACE_FORUM' => 'Unable to insert new forum replacing old forum.', - 'CONV_ERROR_USER_ACCESS' => 'Unable to get user authentication information.', - 'CONV_ERROR_WRONG_GROUP' => 'Wrong group “%1$s” defined in %2$s.', - 'CONV_OPTIONS_BODY' => 'This page collects the data required to access the source board. Enter the database details of your former board; the converter will not change anything in the database given below. The source board should be disabled to allow a consistent conversion.', - 'CONV_SAVED_MESSAGES' => 'Saved messages', - - 'PRE_CONVERT_COMPLETE' => 'All pre-conversion steps have successfully been completed. You may now begin the actual conversion process. Please note that you may have to manually do and adjust several things. After conversion, especially check the permissions assigned, rebuild your search index which is not converted and also make sure files got copied correctly, for example avatars and smilies.', -)); diff --git a/install/update/new/language/en/migrator.php b/install/update/new/language/en/migrator.php deleted file mode 100644 index 0380254..0000000 --- a/install/update/new/language/en/migrator.php +++ /dev/null @@ -1,81 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* DO NOT CHANGE -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -if (empty($lang) || !is_array($lang)) -{ - $lang = array(); -} - -// DEVELOPERS PLEASE NOTE -// -// All language files should use UTF-8 as their encoding and the files must not contain a BOM. -// -// Placeholders can now contain order information, e.g. instead of -// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows -// translators to re-order the output of data while ensuring it remains correct -// -// You do not need this where single placeholders are used, e.g. 'Message %d' is fine -// equally where a string contains only two placeholders which are used to wrap text -// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine - -$lang = array_merge($lang, array( - 'CONFIG_NOT_EXIST' => 'The config setting "%s" unexpectedly does not exist.', - - 'GROUP_NOT_EXIST' => 'The group "%s" unexpectedly does not exist.', - - 'MIGRATION_APPLY_DEPENDENCIES' => 'Apply dependencies of %s.', - 'MIGRATION_DATA_DONE' => 'Installed Data: %1$s; Time: %2$.2f seconds', - 'MIGRATION_DATA_IN_PROGRESS' => 'Installing Data: %1$s; Time: %2$.2f seconds', - 'MIGRATION_DATA_RUNNING' => 'Installing Data: %s.', - 'MIGRATION_EFFECTIVELY_INSTALLED' => 'Migration already effectively installed (skipped): %s', - 'MIGRATION_EXCEPTION_ERROR' => 'Something went wrong during the request and an exception was thrown. The changes made before the error occurred were reversed to the best of our abilities, but you should check the board for errors:

%s', - 'MIGRATION_NOT_FULFILLABLE' => 'The migration "%1$s" is not fulfillable, missing migration "%2$s".', - 'MIGRATION_NOT_INSTALLED' => 'The migration "%s" is not installed.', - 'MIGRATION_NOT_VALID' => '%s is not a valid migration.', - 'MIGRATION_SCHEMA_DONE' => 'Installed Schema: %1$s; Time: %2$.2f seconds', - 'MIGRATION_SCHEMA_IN_PROGRESS' => 'Installing Schema: %1$s; Time: %2$.2f seconds', - 'MIGRATION_SCHEMA_RUNNING' => 'Installing Schema: %s.', - - 'MIGRATION_REVERT_DATA_DONE' => 'Reverted Data: %1$s; Time: %2$.2f seconds', - 'MIGRATION_REVERT_DATA_IN_PROGRESS' => 'Reverting Data: %1$s; Time: %2$.2f seconds', - 'MIGRATION_REVERT_DATA_RUNNING' => 'Reverting Data: %s.', - 'MIGRATION_REVERT_SCHEMA_DONE' => 'Reverted Schema: %1$s; Time: %2$.2f seconds', - 'MIGRATION_REVERT_SCHEMA_IN_PROGRESS' => 'Reverting Schema: %1$s; Time: %2$.2f seconds', - 'MIGRATION_REVERT_SCHEMA_RUNNING' => 'Reverting Schema: %s.', - - 'MIGRATION_INVALID_DATA_MISSING_CONDITION' => 'A migration is invalid. An if statement helper is missing a condition.', - 'MIGRATION_INVALID_DATA_MISSING_STEP' => 'A migration is invalid. An if statement helper is missing a valid call to a migration step.', - 'MIGRATION_INVALID_DATA_CUSTOM_NOT_CALLABLE' => 'A migration is invalid. A custom callable function could not be called.', - 'MIGRATION_INVALID_DATA_UNKNOWN_TYPE' => 'A migration is invalid. An unknown migration tool type was encountered.', - 'MIGRATION_INVALID_DATA_UNDEFINED_TOOL' => 'A migration is invalid. An undefined migration tool was encountered.', - 'MIGRATION_INVALID_DATA_UNDEFINED_METHOD' => 'A migration is invalid. An undefined migration tool method was encountered.', - - 'MODULE_ERROR' => 'An error occurred while creating a module: %s', - 'MODULE_EXISTS' => 'A module already exists: %s', - 'MODULE_EXIST_MULTIPLE' => 'Several modules with the given parent module langname already exist: %s. Try using before/after keys to clarify the module placement.', - 'MODULE_INFO_FILE_NOT_EXIST' => 'A required module info file is missing: %2$s', - 'MODULE_NOT_EXIST' => 'A required module does not exist: %s', - - 'PARENT_MODULE_FIND_ERROR' => 'Unable to determine the parent module identifier: %s', - 'PERMISSION_NOT_EXIST' => 'The permission setting "%s" unexpectedly does not exist.', - - 'ROLE_NOT_EXIST' => 'The permission role "%s" unexpectedly does not exist.', -)); diff --git a/install/update/new/language/en/posting.php b/install/update/new/language/en/posting.php deleted file mode 100644 index 639b8d8..0000000 --- a/install/update/new/language/en/posting.php +++ /dev/null @@ -1,287 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* DO NOT CHANGE -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -if (empty($lang) || !is_array($lang)) -{ - $lang = array(); -} - -// DEVELOPERS PLEASE NOTE -// -// All language files should use UTF-8 as their encoding and the files must not contain a BOM. -// -// Placeholders can now contain order information, e.g. instead of -// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows -// translators to re-order the output of data while ensuring it remains correct -// -// You do not need this where single placeholders are used, e.g. 'Message %d' is fine -// equally where a string contains only two placeholders which are used to wrap text -// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine - -$lang = array_merge($lang, array( - 'ADD_ATTACHMENT' => 'Upload attachment', - 'ADD_ATTACHMENT_EXPLAIN' => 'If you wish to attach one or more files enter the details below.', - 'ADD_FILE' => 'Add the file', - 'ADD_POLL' => 'Poll creation', - 'ADD_POLL_EXPLAIN' => 'If you do not want to add a poll to your topic leave the fields blank.', - 'ALREADY_DELETED' => 'Sorry but this message is already deleted.', - 'ATTACH_COMMENT_NO_EMOJIS' => 'The attachment comment contains forbidden characters (Emoji).', - 'ATTACH_DISK_FULL' => 'There is not enough free disk space to post this attachment.', - 'ATTACH_QUOTA_REACHED' => 'Sorry, the board attachment quota has been reached.', - 'ATTACH_SIG' => 'Attach a signature (signatures can be altered via the UCP)', - - 'BBCODE_A_HELP' => 'Inline uploaded attachment: [attachment=]filename.ext[/attachment]', - 'BBCODE_B_HELP' => 'Bold text: [b]text[/b]', - 'BBCODE_C_HELP' => 'Code display: [code]code[/code]', - 'BBCODE_D_HELP' => 'Flash: [flash=width,height]http://url[/flash]', - 'BBCODE_F_HELP' => 'Font size: [size=85]small text[/size]', - 'BBCODE_IS_OFF' => '%sBBCode%s is OFF', - 'BBCODE_IS_ON' => '%sBBCode%s is ON', - 'BBCODE_I_HELP' => 'Italic text: [i]text[/i]', - 'BBCODE_L_HELP' => 'List: [list][*]text[/list]', - 'BBCODE_LISTITEM_HELP' => 'List item: [*]text', - 'BBCODE_O_HELP' => 'Ordered list: e.g. [list=1][*]First point[/list] or [list=a][*]Point a[/list]', - 'BBCODE_P_HELP' => 'Insert image: [img]http://image_url[/img]', - 'BBCODE_Q_HELP' => 'Quote text: [quote]text[/quote]', - 'BBCODE_S_HELP' => 'Font colour: [color=red]text[/color] or [color=#FF0000]text[/color]', - 'BBCODE_U_HELP' => 'Underline text: [u]text[/u]', - 'BBCODE_W_HELP' => 'Insert URL: [url]http://url[/url] or [url=http://url]URL text[/url]', - 'BBCODE_Y_HELP' => 'List: Add list element', - 'BUMP_ERROR' => 'You cannot bump this topic so soon after the last post.', - - 'CANNOT_DELETE_REPLIED' => 'Sorry but you may only delete posts which have not been replied to.', - 'CANNOT_EDIT_POST_LOCKED' => 'This post has been locked. You can no longer edit that post.', - 'CANNOT_EDIT_TIME' => 'You can no longer edit or delete that post.', - 'CANNOT_POST_ANNOUNCE' => 'Sorry but you cannot post announcements.', - 'CANNOT_POST_STICKY' => 'Sorry but you cannot post sticky topics.', - 'CHANGE_TOPIC_TO' => 'Change topic type to', - 'CHARS_POST_CONTAINS' => array( - 1 => 'Your message contains %1$d character.', - 2 => 'Your message contains %1$d characters.', - ), - 'CHARS_SIG_CONTAINS' => array( - 1 => 'Your signature contains %1$d character.', - 2 => 'Your signature contains %1$d characters.', - ), - 'CLOSE_TAGS' => 'Close tags', - 'CURRENT_TOPIC' => 'Current topic', - - 'DELETE_FILE' => 'Delete file', - 'DELETE_MESSAGE' => 'Delete message', - 'DELETE_MESSAGE_CONFIRM' => 'Are you sure you want to delete this message?', - 'DELETE_OWN_POSTS' => 'Sorry but you can only delete your own posts.', - 'DELETE_PERMANENTLY' => 'Delete permanently', - 'DELETE_POST_CONFIRM' => 'Are you sure you want to delete this post?', - 'DELETE_POST_PERMANENTLY_CONFIRM' => 'Are you sure you want to permanently delete this post?', - 'DELETE_POST_PERMANENTLY' => array( - 1 => 'Permanently delete this post so it can not be recovered', - 2 => 'Permanently delete %1$d posts so they can not be recovered', - ), - 'DELETE_POSTS_CONFIRM' => 'Are you sure you want to delete these posts?', - 'DELETE_POSTS_PERMANENTLY_CONFIRM' => 'Are you sure you want to permanently delete these posts?', - 'DELETE_REASON' => 'Reason for deletion', - 'DELETE_REASON_EXPLAIN' => 'The specified reason for deletion will be visible to moderators.', - 'DELETE_POST_WARN' => 'Delete this post', - 'DELETE_TOPIC_CONFIRM' => 'Are you sure you want to delete this topic?', - 'DELETE_TOPIC_PERMANENTLY' => array( - 1 => 'Permanently delete this topic so it can not be recovered', - 2 => 'Permanently delete %1$d topics so they can not be recovered', - ), - 'DELETE_TOPIC_PERMANENTLY_CONFIRM' => 'Are you sure you want to permanently delete this topic?', - 'DELETE_TOPICS_CONFIRM' => 'Are you sure you want to delete these topics?', - 'DELETE_TOPICS_PERMANENTLY_CONFIRM' => 'Are you sure you want to permanently delete these topics?', - 'DISABLE_BBCODE' => 'Disable BBCode', - 'DISABLE_MAGIC_URL' => 'Do not automatically parse URLs', - 'DISABLE_SMILIES' => 'Disable smilies', - 'DISALLOWED_CONTENT' => 'The upload was rejected because the uploaded file was identified as a possible attack vector.', - 'DISALLOWED_EXTENSION' => 'The extension %s is not allowed.', - 'DRAFT_LOADED' => 'Draft loaded into posting area, you may want to finish your post now.
Your draft will be deleted after submitting this post.', - 'DRAFT_LOADED_PM' => 'Draft loaded into message area, you may want to finish your private message now.
Your draft will be deleted after submitting this private message.', - 'DRAFT_SAVED' => 'Draft successfully saved.', - 'DRAFT_TITLE' => 'Draft title', - - 'EDIT_REASON' => 'Reason for editing this post', - 'EMPTY_FILEUPLOAD' => 'The uploaded file is empty.', - 'EMPTY_MESSAGE' => 'You must enter a message when posting.', - 'EMPTY_REMOTE_DATA' => 'File could not be uploaded, please try uploading the file manually.', - - 'FLASH_IS_OFF' => '[flash] is OFF', - 'FLASH_IS_ON' => '[flash] is ON', - 'FLOOD_ERROR' => 'You cannot make another post so soon after your last.', - 'FONT_COLOR' => 'Font colour', - 'FONT_COLOR_HIDE' => 'Hide font colour', - 'FONT_HUGE' => 'Huge', - 'FONT_LARGE' => 'Large', - 'FONT_NORMAL' => 'Normal', - 'FONT_SIZE' => 'Font size', - 'FONT_SMALL' => 'Small', - 'FONT_TINY' => 'Tiny', - - 'GENERAL_UPLOAD_ERROR' => 'Could not upload attachment to %s.', - - 'IMAGES_ARE_OFF' => '[img] is OFF', - 'IMAGES_ARE_ON' => '[img] is ON', - 'INVALID_FILENAME' => '%s is an invalid filename.', - - 'LOAD' => 'Load', - 'LOAD_DRAFT' => 'Load draft', - 'LOAD_DRAFT_EXPLAIN' => 'Here you are able to select the draft you want to continue writing. Your current post will be cancelled, all current post contents will be deleted. View, edit and delete drafts within your User Control Panel.', - 'LOGIN_EXPLAIN_BUMP' => 'You need to login in order to bump topics within this forum.', - 'LOGIN_EXPLAIN_DELETE' => 'You need to login in order to delete posts within this forum.', - 'LOGIN_EXPLAIN_SOFT_DELETE' => 'You need to login in order to soft-delete posts within this forum.', - 'LOGIN_EXPLAIN_POST' => 'You need to login in order to post within this forum.', - 'LOGIN_EXPLAIN_QUOTE' => 'You need to login in order to quote posts within this forum.', - 'LOGIN_EXPLAIN_REPLY' => 'You need to login in order to reply to topics within this forum.', - - 'MAX_FONT_SIZE_EXCEEDED' => 'You may only use fonts up to size %d.', - 'MAX_FLASH_HEIGHT_EXCEEDED' => array( - 1 => 'Your flash files may only be up to %d pixel high.', - 2 => 'Your flash files may only be up to %d pixels high.', - ), - 'MAX_FLASH_WIDTH_EXCEEDED' => array( - 1 => 'Your flash files may only be up to %d pixel wide.', - 2 => 'Your flash files may only be up to %d pixels wide.', - ), - 'MAX_IMG_HEIGHT_EXCEEDED' => array( - 1 => 'Your images may only be up to %1$d pixel high.', - 2 => 'Your images may only be up to %1$d pixels high.', - ), - 'MAX_IMG_WIDTH_EXCEEDED' => array( - 1 => 'Your images may only be up to %d pixel wide.', - 2 => 'Your images may only be up to %d pixels wide.', - ), - - 'MESSAGE_BODY_EXPLAIN' => array( - 0 => '', // zero means no limit, so we don't view a message here. - 1 => 'Enter your message here, it may contain no more than %d character.', - 2 => 'Enter your message here, it may contain no more than %d characters.', - ), - 'MESSAGE_DELETED' => 'This message has been deleted successfully.', - 'MORE_SMILIES' => 'View more smilies', - - 'NOTIFY_REPLY' => 'Notify me when a reply is posted', - 'NOT_UPLOADED' => 'File could not be uploaded.', - 'NO_DELETE_POLL_OPTIONS' => 'You cannot delete existing poll options.', - 'NO_PM_ICON' => 'No PM icon', - 'NO_POLL_TITLE' => 'You have to enter a poll title.', - 'NO_POST' => 'The requested post does not exist.', - 'NO_POST_MODE' => 'No post mode specified.', - 'NO_TEMP_DIR' => 'Temporary folder could not be found or is not writable.', - - 'PARTIAL_UPLOAD' => 'The uploaded file was only partially uploaded.', - 'PHP_UPLOAD_STOPPED' => 'A PHP extension has stopped the file upload.', - 'PHP_SIZE_NA' => 'The attachment’s file size is too large.
Could not determine the maximum size defined by PHP in php.ini.', - 'PHP_SIZE_OVERRUN' => 'The attachment’s file size is too large, the maximum upload size is %1$d %2$s.
Please note this is set in php.ini and cannot be overridden.', - 'PLACE_INLINE' => 'Place inline', - 'POLL_DELETE' => 'Delete poll', - 'POLL_FOR' => 'Run poll for', - 'POLL_FOR_EXPLAIN' => 'Enter 0 for a never ending poll.', - 'POLL_MAX_OPTIONS' => 'Options per user', - 'POLL_MAX_OPTIONS_EXPLAIN' => 'This is the number of options each user may select when voting.', - 'POLL_OPTIONS' => 'Poll options', - 'POLL_OPTIONS_EXPLAIN' => array( - 1 => 'Place each option on a new line. You may enter %d option.', - 2 => 'Place each option on a new line. You may enter up to %d options.', - ), - 'POLL_OPTIONS_EDIT_EXPLAIN' => array( - 1 => 'Place each option on a new line. You may enter %d option. If you remove or add options all previous votes will be reset.', - 2 => 'Place each option on a new line. You may enter up to %d options. If you remove or add options all previous votes will be reset.', - ), - 'POLL_QUESTION' => 'Poll question', - 'POLL_TITLE_TOO_LONG' => 'The poll title must contain fewer than 100 characters.', - 'POLL_TITLE_COMP_TOO_LONG' => 'The parsed size of your poll title is too large, consider removing BBCodes or smilies.', - 'POLL_VOTE_CHANGE' => 'Allow re-voting', - 'POLL_VOTE_CHANGE_EXPLAIN' => 'If enabled users are able to change their vote.', - 'POSTED_ATTACHMENTS' => 'Posted attachments', - 'POST_APPROVAL_NOTIFY' => 'You will be notified when your post has been approved.', - 'POST_CONFIRMATION' => 'Confirmation of post', - 'POST_CONFIRM_EXPLAIN' => 'To prevent automated posts the board requires you to enter a confirmation code. The code is displayed in the image you should see below. If you are visually impaired or cannot otherwise read this code please contact the %sBoard Administrator%s.', - 'POST_DELETED' => 'This post has been deleted successfully.', - 'POST_EDITED' => 'This post has been edited successfully.', - 'POST_EDITED_MOD' => 'This post has been edited successfully, but it will need to be approved by a moderator before it is publicly viewable.', - 'POST_GLOBAL' => 'Global', - 'POST_ICON' => 'Post icon', - 'POST_NORMAL' => 'Normal', - 'POST_REVIEW' => 'Post review', - 'POST_REVIEW_EDIT' => 'Post review', - 'POST_REVIEW_EDIT_EXPLAIN' => 'This post has been altered by another user while you were editing it. You may wish to review the current version of this post and adjust your edits.', - 'POST_REVIEW_EXPLAIN' => 'At least one new post has been made to this topic. You may wish to review your post in light of this.', - 'POST_STORED' => 'This message has been posted successfully.', - 'POST_STORED_MOD' => 'This message has been submitted successfully, but it will need to be approved by a moderator before it is publicly viewable.', - 'POST_TOPIC_AS' => 'Post topic as', - 'PROGRESS_BAR' => 'Progress bar', - - 'QUOTE_DEPTH_EXCEEDED' => array( - 1 => 'You may embed only %d quote within each other.', - 2 => 'You may embed only %d quotes within each other.', - ), - 'QUOTE_NO_NESTING' => 'You may not embed quotes within each other.', - - 'REMOTE_UPLOAD_TIMEOUT' => 'The specified file could not be uploaded because the request timed out.', - 'SAVE' => 'Save', - 'SAVE_DATE' => 'Saved at', - 'SAVE_DRAFT' => 'Save draft', - 'SAVE_DRAFT_CONFIRM' => 'Please note that saved drafts only include the subject and the message, any other element will be removed. Do you want to save your draft now?', - 'SMILIES' => 'Smilies', - 'SMILIES_ARE_OFF' => 'Smilies are OFF', - 'SMILIES_ARE_ON' => 'Smilies are ON', - 'STICKY_ANNOUNCE_TIME_LIMIT'=> 'Sticky/Announcement/Global time limit', - 'STICK_TOPIC_FOR' => 'Stick topic for', - 'STICK_TOPIC_FOR_EXPLAIN' => 'Enter 0 for a never ending Sticky/Announcement/Global. Please note that this number is relative to the date of the post.', - 'STYLES_TIP' => 'Tip: Styles can be applied quickly to selected text.', - - 'TOO_FEW_CHARS' => 'Your message contains too few characters.', - 'TOO_FEW_CHARS_LIMIT' => array( - 1 => 'You need to enter at least %1$d character.', - 2 => 'You need to enter at least %1$d characters.', - ), - 'TOO_FEW_POLL_OPTIONS' => 'You must enter at least two poll options.', - 'TOO_MANY_ATTACHMENTS' => 'Cannot add another attachment, %d is the maximum.', - 'TOO_MANY_CHARS' => 'Your message contains too many characters.', - 'TOO_MANY_CHARS_LIMIT' => array( - 2 => 'The maximum number of allowed characters is %1$d.', - ), - 'TOO_MANY_POLL_OPTIONS' => 'You have tried to enter too many poll options.', - 'TOO_MANY_SMILIES' => 'Your message contains too many smilies. The maximum number of smilies allowed is %d.', - 'TOO_MANY_URLS' => 'Your message contains too many URLs. The maximum number of URLs allowed is %d.', - 'TOO_MANY_USER_OPTIONS' => 'You cannot specify more options per user than existing poll options.', - 'TOPIC_BUMPED' => 'Topic has been bumped successfully.', - - 'UNAUTHORISED_BBCODE' => 'You cannot use certain BBCodes: %s.', - 'UNSUPPORTED_CHARACTERS_MESSAGE' => 'Your message contains the following unsupported characters:
%s', - 'UNSUPPORTED_CHARACTERS_SUBJECT' => 'Your subject contains the following unsupported characters:
%s', - 'UPDATE_COMMENT' => 'Update comment', - 'URL_INVALID' => 'The URL you specified is invalid.', - 'URL_NOT_FOUND' => 'The file specified could not be found.', - 'URL_IS_OFF' => '[url] is OFF', - 'URL_IS_ON' => '[url] is ON', - 'USER_CANNOT_BUMP' => 'You cannot bump topics in this forum.', - 'USER_CANNOT_DELETE' => 'You cannot delete posts in this forum.', - 'USER_CANNOT_EDIT' => 'You cannot edit posts in this forum.', - 'USER_CANNOT_REPLY' => 'You cannot reply in this forum.', - 'USER_CANNOT_FORUM_POST' => 'You are not able to do posting operations on this forum due to the forum type not supporting it.', - - 'VIEW_MESSAGE' => '%sView your submitted message%s', - 'VIEW_PRIVATE_MESSAGE' => '%sView your submitted private message%s', - - 'WRONG_FILESIZE' => 'The file is too big, maximum allowed size is %1$d %2$s.', - 'WRONG_SIZE' => 'The image must be at least %1$s wide, %2$s high and at most %3$s wide and %4$s high. The submitted image is %5$s wide and %6$s high.', -)); diff --git a/install/update/new/language/en/ucp.php b/install/update/new/language/en/ucp.php deleted file mode 100644 index 57319ae..0000000 --- a/install/update/new/language/en/ucp.php +++ /dev/null @@ -1,666 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* DO NOT CHANGE -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -if (empty($lang) || !is_array($lang)) -{ - $lang = array(); -} - -// DEVELOPERS PLEASE NOTE -// -// All language files should use UTF-8 as their encoding and the files must not contain a BOM. -// -// Placeholders can now contain order information, e.g. instead of -// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows -// translators to re-order the output of data while ensuring it remains correct -// -// You do not need this where single placeholders are used, e.g. 'Message %d' is fine -// equally where a string contains only two placeholders which are used to wrap text -// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine - -// Privacy policy and T&C -$lang = array_merge($lang, array( - 'TERMS_OF_USE_CONTENT' => 'By accessing “%1$s” (hereinafter “we”, “us”, “our”, “%1$s”, “%2$s”), you agree to be legally bound by the following terms. If you do not agree to be legally bound by all of the following terms then please do not access and/or use “%1$s”. We may change these at any time and we’ll do our utmost in informing you, though it would be prudent to review this regularly yourself as your continued usage of “%1$s” after changes mean you agree to be legally bound by these terms as they are updated and/or amended.
-
- Our forums are powered by phpBB (hereinafter “they”, “them”, “their”, “phpBB software”, “www.phpbb.com”, “phpBB Limited”, “phpBB Teams”) which is a bulletin board solution released under the “GNU General Public License v2” (hereinafter “GPL”) and can be downloaded from www.phpbb.com. The phpBB software only facilitates internet based discussions; phpBB Limited is not responsible for what we allow and/or disallow as permissible content and/or conduct. For further information about phpBB, please see: https://www.phpbb.com/.
-
- You agree not to post any abusive, obscene, vulgar, slanderous, hateful, threatening, sexually-orientated or any other material that may violate any laws be it of your country, the country where “%1$s” is hosted or International Law. Doing so may lead to you being immediately and permanently banned, with notification of your Internet Service Provider if deemed required by us. The IP address of all posts are recorded to aid in enforcing these conditions. You agree that “%1$s” have the right to remove, edit, move or close any topic at any time should we see fit. As a user you agree to any information you have entered to being stored in a database. While this information will not be disclosed to any third party without your consent, neither “%1$s” nor phpBB shall be held responsible for any hacking attempt that may lead to the data being compromised. - ', - - 'PRIVACY_POLICY' => 'This policy explains in detail how “%1$s” along with its affiliated companies (hereinafter “we”, “us”, “our”, “%1$s”, “%2$s”) and phpBB (hereinafter “they”, “them”, “their”, “phpBB software”, “www.phpbb.com”, “phpBB Limited”, “phpBB Teams”) use any information collected during any session of usage by you (hereinafter “your information”).
-
- Your information is collected via two ways. Firstly, by browsing “%1$s” will cause the phpBB software to create a number of cookies, which are small text files that are downloaded on to your computer’s web browser temporary files. The first two cookies just contain a user identifier (hereinafter “user-id”) and an anonymous session identifier (hereinafter “session-id”), automatically assigned to you by the phpBB software. A third cookie will be created once you have browsed topics within “%1$s” and is used to store which topics have been read, thereby improving your user experience.
-
- We may also create cookies external to the phpBB software whilst browsing “%1$s”, though these are outside the scope of this document which is intended to only cover the pages created by the phpBB software. The second way in which we collect your information is by what you submit to us. This can be, and is not limited to: posting as an anonymous user (hereinafter “anonymous posts”), registering on “%1$s” (hereinafter “your account”) and posts submitted by you after registration and whilst logged in (hereinafter “your posts”).
-
- Your account will at a bare minimum contain a uniquely identifiable name (hereinafter “your user name”), a personal password used for logging into your account (hereinafter “your password”) and a personal, valid email address (hereinafter “your email”). Your information for your account at “%1$s” is protected by data-protection laws applicable in the country that hosts us. Any information beyond your user name, your password, and your email address required by “%1$s” during the registration process is either mandatory or optional, at the discretion of “%1$s”. In all cases, you have the option of what information in your account is publicly displayed. Furthermore, within your account, you have the option to opt-in or opt-out of automatically generated emails from the phpBB software.
-
- Your password is ciphered (a one-way hash) so that it is secure. However, it is recommended that you do not reuse the same password across a number of different websites. Your password is the means of accessing your account at “%1$s”, so please guard it carefully and under no circumstance will anyone affiliated with “%1$s”, phpBB or another 3rd party, legitimately ask you for your password. Should you forget your password for your account, you can use the “I forgot my password” feature provided by the phpBB software. This process will ask you to submit your user name and your email, then the phpBB software will generate a new password to reclaim your account.
- ', -)); - -// Common language entries -$lang = array_merge($lang, array( - 'ACCOUNT_ACTIVE' => 'Your account has now been activated. Thank you for registering.', - 'ACCOUNT_ACTIVE_ADMIN' => 'The account has now been activated.', - 'ACCOUNT_ACTIVE_PROFILE' => 'Your account has now been successfully reactivated.', - 'ACCOUNT_ADDED' => 'Thank you for registering, your account has been created.', - 'ACCOUNT_COPPA' => 'Your account has been created but has to be approved, please check your email for details.', - 'ACCOUNT_EMAIL_CHANGED' => 'Your account has been updated. However, this board requires account reactivation on email changes. An activation key has been sent to the new email address you provided. Please check your email for further information.', - 'ACCOUNT_EMAIL_CHANGED_ADMIN' => 'Your account has been updated. However, this board requires account reactivation by the administrators on email changes. An email has been sent to them and you will be informed when your account has been reactivated.', - 'ACCOUNT_INACTIVE' => 'Your account has been created. However, this board requires account activation. An activation key has been sent to the email address you provided. Please check your email for further information and also be sure to check your junk mail box. It may take a while to get the email depending on your email provider.', - 'ACCOUNT_INACTIVE_ADMIN' => 'Your account has been created. However, this board requires account activation by the administrator group. An email has been sent to them and you will be informed when your account has been activated.', - 'ACTIVATION_EMAIL_SENT' => 'The activation email has been sent to your email address.', - 'ACTIVATION_EMAIL_SENT_ADMIN' => 'The activation email has been sent to the administrators email addresses.', - 'ADD' => 'Add', - 'ADD_BCC' => 'Add [BCC]', - 'ADD_FOES' => 'Add new foes', - 'ADD_FOES_EXPLAIN' => 'You may enter several usernames each on a different line.', - 'ADD_FOLDER' => 'Add folder', - 'ADD_FRIENDS' => 'Add new friends', - 'ADD_FRIENDS_EXPLAIN' => 'You may enter several usernames each on a different line.', - 'ADD_NEW_RULE' => 'Add new rule', - 'ADD_RULE' => 'Add rule', - 'ADD_TO' => 'Add [To]', - 'ADD_USERS_UCP_EXPLAIN' => 'Here you can add new users to the group. You may select whether this group becomes the new default for the selected users. Please enter each username on a separate line.', - 'ADMIN_EMAIL' => 'Administrators can email me information', - 'AGREE' => 'I agree to these terms', - 'ALLOW_PM' => 'Allow users to send you private messages', - 'ALLOW_PM_EXPLAIN' => 'Note that administrators and moderators will always be able to send you messages.', - 'ALREADY_ACTIVATED' => 'You have already activated your account.', - 'ATTACHMENTS_EXPLAIN' => 'This is a list of attachments you have made in posts to this board.', - 'ATTACHMENTS_DELETED' => 'Attachments successfully deleted.', - 'ATTACHMENT_DELETED' => 'Attachment successfully deleted.', - 'ATTACHMENT_LOCKED' => 'This topic is locked, you cannot delete the attachment.', - 'AUTOLOGIN_SESSION_KEYS_DELETED'=> 'The selected "Remember Me" login keys were successfully deleted.', - 'AVATAR_CATEGORY' => 'Category', - 'AVATAR_DRIVER_GRAVATAR_TITLE' => 'Gravatar', - 'AVATAR_DRIVER_GRAVATAR_EXPLAIN'=> 'Gravatar is a service that allows you to maintain the same avatar across multiple websites. Visit Gravatar for more information.', - 'AVATAR_DRIVER_LOCAL_TITLE' => 'Gallery avatar', - 'AVATAR_DRIVER_LOCAL_EXPLAIN' => 'You can choose your avatar from a locally available set of avatars.', - 'AVATAR_DRIVER_REMOTE_TITLE' => 'Remote avatar', - 'AVATAR_DRIVER_REMOTE_EXPLAIN' => 'Link to avatar images from another website.', - 'AVATAR_DRIVER_UPLOAD_TITLE' => 'Upload avatar', - 'AVATAR_DRIVER_UPLOAD_EXPLAIN' => 'Upload your own custom avatar.', - 'AVATAR_EXPLAIN' => 'Maximum dimensions; width: %1$s, height: %2$s, file size: %3$.2f KiB.', - 'AVATAR_EXPLAIN_NO_FILESIZE' => 'Maximum dimensions; width: %1$s, height: %2$s.', - 'AVATAR_FEATURES_DISABLED' => 'The avatar functionality is currently disabled.', - 'AVATAR_GALLERY' => 'Local gallery', - 'AVATAR_GENERAL_UPLOAD_ERROR' => 'Could not upload avatar to %s.', - 'AVATAR_NOT_ALLOWED' => 'Your avatar cannot be displayed because avatars have been disallowed.', - 'AVATAR_PAGE' => 'Page', - 'AVATAR_SELECT' => 'Select your avatar', - 'AVATAR_TYPE' => 'Avatar type', - 'AVATAR_TYPE_NOT_ALLOWED' => 'Your current avatar cannot be displayed because its type has been disallowed.', - - 'BACK_TO_DRAFTS' => 'Back to saved drafts', - 'BACK_TO_LOGIN' => 'Back to login screen', - 'BIRTHDAY' => 'Birthday', - 'BIRTHDAY_EXPLAIN' => 'Setting a year will list your age when it is your birthday.', - 'BOARD_DATE_FORMAT' => 'My date format', - 'BOARD_DATE_FORMAT_EXPLAIN' => 'The syntax used is identical to the PHP date() function.', - 'BOARD_LANGUAGE' => 'My language', - 'BOARD_STYLE' => 'My board style', - 'BOARD_TIMEZONE' => 'My timezone', - 'BOOKMARKS' => 'Bookmarks', - 'BOOKMARKS_EXPLAIN' => 'You can bookmark topics for future reference. Select the checkbox for any bookmark you wish to delete, then press the Remove marked bookmarks button.', - 'BOOKMARKS_DISABLED' => 'Bookmarks are disabled on this board.', - 'BOOKMARKS_REMOVED' => 'Bookmarks removed successfully.', - - 'CANNOT_EDIT_MESSAGE_TIME' => 'You can no longer edit or delete that message.', - 'CANNOT_MOVE_TO_SAME_FOLDER'=> 'Messages cannot be moved to the folder you want to remove.', - 'CANNOT_MOVE_FROM_SPECIAL' => 'Messages cannot be moved from the outbox.', - 'CANNOT_RENAME_FOLDER' => 'This folder cannot be renamed.', - 'CANNOT_REMOVE_FOLDER' => 'This folder cannot be removed.', - 'CHANGE_DEFAULT_GROUP' => 'Change default group', - 'CHANGE_PASSWORD' => 'Change password', - 'CLICK_GOTO_FOLDER' => '%1$sGo to your “%3$s” folder%2$s', - 'CLICK_RETURN_FOLDER' => '%1$sReturn to your “%3$s” folder%2$s', - 'CONFIRMATION' => 'Confirmation of registration', - 'CONFIRM_CHANGES' => 'Confirm changes', - 'CONFIRM_EXPLAIN' => 'To prevent automated registrations the board requires you to enter a confirmation code. The code is displayed in the image you should see below. If you are visually impaired or cannot otherwise read this code please contact the %sBoard Administrator%s.', - 'VC_REFRESH' => 'Refresh confirmation code', - 'VC_REFRESH_EXPLAIN' => 'If you cannot read the code you can request a new one by clicking the button.', - - 'CONFIRM_PASSWORD' => 'Confirm password', - 'CONFIRM_PASSWORD_EXPLAIN' => 'You only need to confirm your password if you changed it above.', - 'COPPA_BIRTHDAY' => 'To continue with the registration procedure please tell us when you were born.', - 'COPPA_COMPLIANCE' => 'COPPA compliance', - 'COPPA_EXPLAIN' => 'Please note that clicking submit will create your account. However it cannot be activated until a parent or guardian approves your registration. You will be emailed a copy of the necessary form with details of where to send it.', - 'CREATE_FOLDER' => 'Add folder…', - 'CURRENT_IMAGE' => 'Current image', - 'CURRENT_PASSWORD' => 'Current password', - 'CURRENT_PASSWORD_EXPLAIN' => 'You must enter your current password if you wish to alter your email address or username.', - 'CURRENT_CHANGE_PASSWORD_EXPLAIN' => 'To change your password, your email address, or your username, you must enter your current password.', - 'CUR_PASSWORD_EMPTY' => 'You did not enter your current password.', - 'CUR_PASSWORD_ERROR' => 'The current password you entered is incorrect.', - 'CUSTOM_DATEFORMAT' => 'Custom…', - - 'DEFAULT_ACTION' => 'Default action', - 'DEFAULT_ACTION_EXPLAIN' => 'This action will be triggered if none of the above is applicable.', - 'DEFAULT_ADD_SIG' => 'Attach my signature by default', - 'DEFAULT_BBCODE' => 'Enable BBCode by default', - 'DEFAULT_NOTIFY' => 'Notify me upon replies by default', - 'DEFAULT_SMILIES' => 'Enable smilies by default', - 'DEFINED_RULES' => 'Defined rules', - 'DELETED_TOPIC' => 'Topic has been removed.', - 'DELETE_ATTACHMENT' => 'Delete attachment', - 'DELETE_ATTACHMENTS' => 'Delete attachments', - 'DELETE_ATTACHMENT_CONFIRM' => 'Are you sure you want to delete this attachment?', - 'DELETE_ATTACHMENTS_CONFIRM'=> 'Are you sure you want to delete these attachments?', - 'DELETE_AVATAR' => 'Delete image', - 'DELETE_COOKIES_CONFIRM' => 'Are you sure you want to delete all cookies set by this board?', - 'DELETE_MARKED_PM' => 'Delete marked messages', - 'DELETE_MARKED_PM_CONFIRM' => 'Are you sure you want to delete all marked messages?', - 'DELETE_OLDEST_MESSAGES' => 'Delete oldest messages', - 'DELETE_MESSAGE' => 'Delete message', - 'DELETE_MESSAGE_CONFIRM' => 'Are you sure you want to delete this private message?', - 'DELETE_MESSAGES_IN_FOLDER' => 'Delete all messages within removed folder', - 'DELETE_RULE' => 'Delete rule', - 'DELETE_RULE_CONFIRM' => 'Are you sure you want to delete this rule?', - 'DEMOTE_SELECTED' => 'Demote selected', - 'DISABLE_CENSORS' => 'Enable word censoring', - 'DISPLAY_GALLERY' => 'Display gallery', - 'DOMAIN_NO_MX_RECORD_EMAIL' => 'The entered email domain has no valid MX record.', - 'DOWNLOADS' => 'Downloads', - 'DRAFTS_DELETED' => 'All selected drafts were successfully deleted.', - 'DRAFTS_EXPLAIN' => 'Here you can view, edit and delete your saved drafts.', - 'DRAFT_UPDATED' => 'Draft successfully updated.', - - 'EDIT_DRAFT_EXPLAIN' => 'Here you are able to edit your draft. Drafts do not contain attachment and poll information.', - 'EMAIL_BANNED_EMAIL' => 'The email address you entered is not allowed to be used.', - 'EMAIL_REMIND' => 'This must be the email address associated with your account. If you have not changed this via your user control panel then it is the email address you registered your account with.', - 'EMAIL_TAKEN_EMAIL' => 'The entered email address is already in use.', - 'EMPTY_DRAFT' => 'You must enter a message to submit your changes.', - 'EMPTY_DRAFT_TITLE' => 'You must enter a draft title.', - 'EXPORT_AS_XML' => 'Export as XML', - 'EXPORT_AS_CSV' => 'Export as CSV', - 'EXPORT_AS_CSV_EXCEL' => 'Export as CSV (Excel)', - 'EXPORT_AS_TXT' => 'Export as TXT', - 'EXPORT_AS_MSG' => 'Export as MSG', - 'EXPORT_FOLDER' => 'Export this view', - - 'FIELD_REQUIRED' => 'The field “%s” must be completed.', - 'FIELD_TOO_SHORT' => array( - 1 => 'The field “%2$s” is too short, a minimum of %1$d character is required.', - 2 => 'The field “%2$s” is too short, a minimum of %1$d characters is required.', - ), - 'FIELD_TOO_LONG' => array( - 1 => 'The field “%2$s” is too long, a maximum of %1$d character is allowed.', - 2 => 'The field “%2$s” is too long, a maximum of %1$d characters is allowed.', - ), - 'FIELD_TOO_SMALL' => 'The value of “%2$s” is too small, a minimum value of %1$d is required.', - 'FIELD_TOO_LARGE' => 'The value of “%2$s” is too large, a maximum value of %1$d is allowed.', - 'FIELD_INVALID_CHARS_INVALID' => 'The field “%s” has invalid characters.', - 'FIELD_INVALID_CHARS_NUMBERS_ONLY' => 'The field “%s” has invalid characters, only numbers are allowed.', - 'FIELD_INVALID_CHARS_ALPHA_DOTS' => 'The field “%s” has invalid characters, only alphanumeric or . characters are allowed.', - 'FIELD_INVALID_CHARS_ALPHA_ONLY' => 'The field “%s” has invalid characters, only alphanumeric characters are allowed.', - 'FIELD_INVALID_CHARS_ALPHA_PUNCTUATION' => 'The field “%s” has invalid characters, only alphanumeric or _,-. characters are allowed and the first character must be alphabetic.', - 'FIELD_INVALID_CHARS_ALPHA_SPACERS' => 'The field “%s” has invalid characters, only alphanumeric, space or -+_[] characters are allowed.', - 'FIELD_INVALID_CHARS_ALPHA_UNDERSCORE' => 'The field “%s” has invalid characters, only alphanumeric or _ characters are allowed.', - 'FIELD_INVALID_CHARS_LETTER_NUM_DOTS' => 'The field “%s” has invalid characters, only letter, number or . characters are allowed.', - 'FIELD_INVALID_CHARS_LETTER_NUM_ONLY' => 'The field “%s” has invalid characters, only letter and number characters are allowed.', - 'FIELD_INVALID_CHARS_LETTER_NUM_PUNCTUATION' => 'The field “%s” has invalid characters, only letter, number or _,-. characters are allowed and the first character must be alphabetic.', - 'FIELD_INVALID_CHARS_LETTER_NUM_SPACERS' => 'The field “%s” has invalid characters, only letter, number, space or -+_[] characters are allowed.', - 'FIELD_INVALID_CHARS_LETTER_NUM_UNDERSCORE' => 'The field “%s” has invalid characters, only letter, number or _ characters are allowed.', - 'FIELD_INVALID_DATE' => 'The field “%s” has an invalid date.', - 'FIELD_INVALID_URL' => 'The field “%s” has an invalid url.', - 'FIELD_INVALID_VALUE' => 'The field “%s” has an invalid value.', - - 'FOE_MESSAGE' => 'Message from foe', - 'FOES_EXPLAIN' => 'Foes are users which will be ignored by default. Posts by these users will not be fully visible. Personal messages from foes are still permitted. Please note that you cannot ignore moderators or administrators.', - 'FOES_UPDATED' => 'Your foes list has been updated successfully.', - 'FOLDER_ADDED' => 'Folder successfully added.', - 'FOLDER_MESSAGE_STATUS' => array( - 1 => '%2$d out of %1$s stored', - 2 => '%2$d out of %1$s stored', - ), - 'FOLDER_NAME_EMPTY' => 'You must enter a name for this folder.', - 'FOLDER_NAME_EXIST' => 'Folder %s already exists.', - 'FOLDER_OPTIONS' => 'Folder options', - 'FOLDER_RENAMED' => 'Folder successfully renamed.', - 'FOLDER_REMOVED' => 'Folder successfully removed.', - 'FOLDER_STATUS_MSG' => array( - 1 => 'Folder is %3$d%% full (%2$d out of %1$s stored)', - 2 => 'Folder is %3$d%% full (%2$d out of %1$s stored)', - ), - 'FORWARD_PM' => 'Forward PM', - 'FORCE_PASSWORD_EXPLAIN' => 'Before you may continue browsing the board you are required to change your password.', - 'FRIEND_MESSAGE' => 'Message from friend', - 'FRIENDS' => 'Friends', - 'FRIENDS_EXPLAIN' => 'Friends enable you quick access to members you communicate with frequently. If the template has relevant support any posts made by a friend may be highlighted.', - 'FRIENDS_OFFLINE' => 'Offline', - 'FRIENDS_ONLINE' => 'Online', - 'FRIENDS_UPDATED' => 'Your friends list has been updated successfully.', - 'FULL_FOLDER_OPTION_CHANGED'=> 'The action to take when a folder is full has been changed successfully.', - 'FWD_ORIGINAL_MESSAGE' => '-------- Original Message --------', - 'FWD_SUBJECT' => 'Subject: %s', - 'FWD_DATE' => 'Date: %s', - 'FWD_FROM' => 'From: %s', - 'FWD_TO' => 'To: %s', - - 'GLOBAL_ANNOUNCEMENT' => 'Global announcement', - - 'GRAVATAR_AVATAR_EMAIL' => 'Gravatar email', - 'GRAVATAR_AVATAR_EMAIL_EXPLAIN' => 'Enter the email address you used for registering your account on Gravatar.', - 'GRAVATAR_AVATAR_SIZE' => 'Avatar dimensions', - 'GRAVATAR_AVATAR_SIZE_EXPLAIN' => 'Specify the width and height of the avatar, leave blank to attempt automatic verification.', - - 'HIDE_ONLINE' => 'Hide my online status', - 'HIDE_ONLINE_EXPLAIN' => 'Changing this setting won’t become effective until your next visit to the board.', - 'HOLD_NEW_MESSAGES' => 'Do not accept new messages (New messages will be held back until enough space is available)', - 'HOLD_NEW_MESSAGES_SHORT' => 'New messages will be held back', - - 'IF_FOLDER_FULL' => 'If folder is full', - 'IMPORTANT_NEWS' => 'Important announcements', - 'INVALID_USER_BIRTHDAY' => 'The entered birthday is not a valid date.', - 'INVALID_CHARS_USERNAME' => 'The username contains forbidden characters.', - 'INVALID_EMOJIS_USERNAME' => 'The username contains forbidden characters (Emoji).', - 'INVALID_CHARS_NEW_PASSWORD'=> 'The password does not contain the required characters.', - 'ITEMS_REQUIRED' => 'The items marked with * are required profile fields and need to be filled out.', - - 'JOIN_SELECTED' => 'Join selected', - - 'LANGUAGE' => 'Language', - 'LINK_REMOTE_AVATAR' => 'Link off-site', - 'LINK_REMOTE_AVATAR_EXPLAIN'=> 'Enter the URL of the location containing the avatar image you wish to link to.', - 'LINK_REMOTE_SIZE' => 'Avatar dimensions', - 'LINK_REMOTE_SIZE_EXPLAIN' => 'Specify the width and height of the avatar, leave blank to attempt automatic verification.', - 'LOGIN_EXPLAIN_UCP' => 'Please login in order to access the User Control Panel.', - 'LOGIN_LINK' => 'Link or register your account on an external service with your board account', - 'LOGIN_LINK_EXPLAIN' => 'You have attempted to login with an external service that is not yet connected to an account on this board. You must now either link this account to an existing account or create a new account.', - 'LOGIN_LINK_MISSING_DATA' => 'Data that is necessary to link your account with an external service is not available. Please restart the login process.', - 'LOGIN_LINK_NO_DATA_PROVIDED' => 'No data has been provided to this page to link an external account to a forum account. Please contact the board administrator if you continue to experience problems.', - 'LOGIN_KEY' => 'Login Key', - 'LOGIN_TIME' => 'Login Time', - 'LOGIN_REDIRECT' => 'You have been successfully logged in.', - 'LOGOUT_FAILED' => 'You were not logged out, as the request did not match your session. Please contact the board administrator if you continue to experience problems.', - 'LOGOUT_REDIRECT' => 'You have been successfully logged out.', - - 'MARK_IMPORTANT' => 'Mark/Unmark as important', - 'MARKED_MESSAGE' => 'Marked message', - 'MAX_FOLDER_REACHED' => 'Maximum number of allowed user defined folders reached.', - 'MESSAGE_BY_AUTHOR' => 'by', - 'MESSAGE_COLOURS' => 'Message colours', - 'MESSAGE_DELETED' => 'Message successfully deleted.', - 'MESSAGE_EDITED' => 'Message successfully edited.', - 'MESSAGE_HISTORY' => 'Message history', - 'MESSAGE_REMOVED_FROM_OUTBOX' => 'This message was deleted by its author.', - 'MESSAGE_REPORTED_MESSAGE' => 'Reported message', - 'MESSAGE_SENT_ON' => 'on', - 'MESSAGE_STORED' => 'This message has been sent successfully.', - 'MESSAGE_TO' => 'To', - 'MESSAGES_DELETED' => 'Messages successfully deleted', - 'MOVE_DELETED_MESSAGES_TO' => 'Move messages from removed folder to', - 'MOVE_DOWN' => 'Move down', - 'MOVE_MARKED_TO_FOLDER' => 'Move marked to %s', - 'MOVE_PM_ERROR' => array( - 1 => 'An error occurred while moving the messages to the new folder, only %2$d out of %1$s was moved.', - 2 => 'An error occurred while moving the messages to the new folder, only %2$d out of %1$s were moved.', - ), - 'MOVE_TO_FOLDER' => 'Move to folder', - 'MOVE_UP' => 'Move up', - - 'NEW_FOLDER_NAME' => 'New folder name', - 'NEW_PASSWORD' => 'New password', - 'NEW_PASSWORD_CONFIRM_EMPTY' => 'You did not enter a confirm password.', - 'NEW_PASSWORD_ERROR' => 'The passwords you entered do not match.', - - 'NOTIFICATIONS_MARK_ALL_READ' => 'Mark all notifications read', - 'NOTIFICATIONS_MARK_ALL_READ_CONFIRM' => 'Are you sure you want to mark all notifications read?', - 'NOTIFICATIONS_MARK_ALL_READ_SUCCESS' => 'All notifications have been marked read.', - 'NOTIFICATION_GROUP_MISCELLANEOUS' => 'Miscellaneous Notifications', - 'NOTIFICATION_GROUP_MODERATION' => 'Moderation Notifications', - 'NOTIFICATION_GROUP_ADMINISTRATION' => 'Administration Notifications', - 'NOTIFICATION_GROUP_POSTING' => 'Posting Notifications', - 'NOTIFICATION_METHOD_BOARD' => 'Notifications', - 'NOTIFICATION_METHOD_EMAIL' => 'Email', - 'NOTIFICATION_METHOD_JABBER' => 'Jabber', - 'NOTIFICATION_TYPE' => 'Notification type', - 'NOTIFICATION_TYPE_BOOKMARK' => 'Someone replies to a topic you have bookmarked', - 'NOTIFICATION_TYPE_GROUP_REQUEST' => 'Someone requests to join a group you lead', - 'NOTIFICATION_TYPE_IN_MODERATION_QUEUE' => 'A post or topic needs approval', - 'NOTIFICATION_TYPE_MODERATION_QUEUE' => 'Your topics/posts are approved or disapproved by a moderator', - 'NOTIFICATION_TYPE_PM' => 'Someone sends you a private message', - 'NOTIFICATION_TYPE_POST' => 'Someone replies to a topic to which you are subscribed', - 'NOTIFICATION_TYPE_QUOTE' => 'Someone quotes you in a post', - 'NOTIFICATION_TYPE_REPORT' => 'Someone reports a post', - 'NOTIFICATION_TYPE_TOPIC' => 'Someone creates a topic in a forum to which you are subscribed', - 'NOTIFICATION_TYPE_ADMIN_ACTIVATE_USER' => 'User requiring activation', - - 'NOTIFY_METHOD' => 'Notification method', - 'NOTIFY_METHOD_BOTH' => 'Both', - 'NOTIFY_METHOD_EMAIL' => 'Email only', - 'NOTIFY_METHOD_EXPLAIN' => 'Method for sending messages sent via this board.', - 'NOTIFY_METHOD_IM' => 'Jabber only', - 'NOTIFY_ON_PM' => 'Notify me on new private messages', - 'NOT_ADDED_FRIENDS_ANONYMOUS' => 'You cannot add the anonymous user to your friends list.', - 'NOT_ADDED_FRIENDS_BOTS' => 'You cannot add bots to your friends list.', - 'NOT_ADDED_FRIENDS_FOES' => 'You cannot add users to your friends list who are on your foes list.', - 'NOT_ADDED_FRIENDS_SELF' => 'You cannot add yourself to the friends list.', - 'NOT_ADDED_FOES_MOD_ADMIN' => 'You cannot add administrators and moderators to your foes list.', - 'NOT_ADDED_FOES_ANONYMOUS' => 'You cannot add the anonymous user to your foes list.', - 'NOT_ADDED_FOES_BOTS' => 'You cannot add bots to your foes list.', - 'NOT_ADDED_FOES_FRIENDS' => 'You cannot add users to your foes list who are on your friends list.', - 'NOT_ADDED_FOES_SELF' => 'You cannot add yourself to the foes list.', - 'NOT_AGREE' => 'I do not agree to these terms', - 'NOT_ENOUGH_SPACE_FOLDER' => 'The destination folder “%s” seems to be full. The requested action has not been taken.', - 'NOT_MOVED_MESSAGES' => array( - 1 => 'You have %d private message currently on hold because of full folder.', - 2 => 'You have %d private messages currently on hold because of full folder.', - ), - 'NO_ACTION_MODE' => 'No message action specified.', - 'NO_AUTHOR' => 'No author defined for this message', - 'NO_AVATAR' => 'No avatar selected', - 'NO_AVATAR_CATEGORY' => 'None', - - 'NO_AUTH_DELETE_MESSAGE' => 'You are not authorised to delete private messages.', - 'NO_AUTH_EDIT_MESSAGE' => 'You are not authorised to edit private messages.', - 'NO_AUTH_FORWARD_MESSAGE' => 'You are not authorised to forward private messages.', - 'NO_AUTH_GROUP_MESSAGE' => 'You are not authorised to send private messages to groups.', - 'NO_AUTH_PROFILEINFO' => 'You are not authorised to change your profile information.', - 'NO_AUTH_READ_HOLD_MESSAGE' => 'You are not authorised to read private messages that are on hold.', - 'NO_AUTH_READ_MESSAGE' => 'You are not authorised to read private messages.', - 'NO_AUTH_PRINT_MESSAGE' => 'You are not authorised to print private messages.', - 'NO_AUTH_READ_REMOVED_MESSAGE' => 'You are not able to read this message because it was removed by the author.', - 'NO_AUTH_SEND_MESSAGE' => 'You are not authorised to send private messages.', - 'NO_AUTH_SIGNATURE' => 'You are not authorised to define a signature.', - - 'NO_BCC_RECIPIENT' => 'None', - 'NO_BOOKMARKS' => 'You have no bookmarks.', - 'NO_BOOKMARKS_SELECTED' => 'You have selected no bookmarks.', - 'NO_EDIT_READ_MESSAGE' => 'Private message cannot be edited because it has already been read.', - 'NO_EMAIL_USER' => 'The email/username information submitted could not be found.', - 'EMAIL_NOT_UNIQUE' => 'Email you specified is used by multiple users. You must specify username as well.', - 'NO_FOES' => 'No foes currently defined', - 'NO_FRIENDS' => 'No friends currently defined', - 'NO_FRIENDS_OFFLINE' => 'No friends offline', - 'NO_FRIENDS_ONLINE' => 'No friends online', - 'NO_GROUP_SELECTED' => 'No group specified.', - 'NO_IMPORTANT_NEWS' => 'No important announcements present.', - 'NO_MESSAGE' => 'Private message could not be found.', - 'NO_NEW_FOLDER_NAME' => 'You have to specify a new folder name.', - 'NO_NEWER_PM' => 'No newer messages.', - 'NO_OLDER_PM' => 'No older messages.', - 'NO_PASSWORD_SUPPLIED' => 'You cannot login without a password.', - 'NO_RECIPIENT' => 'No recipient defined.', - 'NO_RESET_TOKEN' => 'You did not provide a password reset token.', - 'NO_RULES_DEFINED' => 'No rules defined.', - 'NO_SAVED_DRAFTS' => 'No drafts saved.', - 'NO_TO_RECIPIENT' => 'None', - 'NO_WATCHED_FORUMS' => 'You are not subscribed to any forums.', - 'NO_WATCHED_SELECTED' => 'You have not selected any subscribed topics or forums.', - 'NO_WATCHED_TOPICS' => 'You are not subscribed to any topics.', - - 'PASS_TYPE_ALPHA_EXPLAIN' => 'Password must be at least %1$s long, must contain letters in mixed case and must contain numbers.', - 'PASS_TYPE_ANY_EXPLAIN' => 'Must be at least %1$s long.', - 'PASS_TYPE_CASE_EXPLAIN' => 'Password must be at least %1$s long and must contain letters in mixed case.', - 'PASS_TYPE_SYMBOL_EXPLAIN' => 'Password must be at least %1$s long, must contain letters in mixed case, must contain numbers and must contain symbols.', - 'PASSWORD' => 'Password', - 'PASSWORD_ACTIVATED' => 'Your new password has been activated.', - 'PASSWORD_RESET' => 'Your password has been successfully reset.', - 'PASSWORD_RESET_LINK_SENT' => 'If your account exists, a password reset link was sent to your registered email address. If you do not receive an email, it may be because you are banned, your account is not activated, you have requested multiple password resets within a short time frame, or you are not allowed to change your password. Contact an administrator if any of those reasons apply. Also, please check your spam filter.', - 'PERMISSIONS_RESTORED' => 'Successfully restored original permissions.', - 'PERMISSIONS_TRANSFERRED' => 'Successfully transferred permissions from %s, you are now able to browse the board with this user’s permissions.
Please note that admin permissions were not transferred. You are able to revert to your permission set at any time.', - 'PM_DISABLED' => 'Private messaging has been disabled on this board.', - 'PM_FROM' => 'From', - 'PM_FROM_REMOVED_AUTHOR' => 'This message was sent by a user no longer registered.', - 'PM_ICON' => 'PM icon', - 'PM_INBOX' => 'Inbox', - 'PM_MARK_ALL_READ' => 'Mark all messages read', - 'PM_MARK_ALL_READ_SUCCESS' => 'All private messages in this folder have been marked read', - 'PM_NO_USERS' => 'The requested users to be added do not exist.', - 'PM_OUTBOX' => 'Outbox', - 'PM_SENTBOX' => 'Sent messages', - 'PM_SUBJECT' => 'Message subject', - 'PM_TO' => 'Send to', - 'PM_TOOLS' => 'Message tools', - 'PM_USERS_REMOVED_NO_PERMISSION' => 'Some users couldn’t be added as they do not have permission to read private messages.', - 'PM_USERS_REMOVED_NO_PM' => 'Some users couldn’t be added as they have disabled private message receipt.', - 'POST_EDIT_PM' => 'Edit message', - 'POST_FORWARD_PM' => 'Forward message', - 'POST_NEW_PM' => 'Compose message', - 'POST_PM_LOCKED' => 'Private messaging is locked.', - 'POST_PM_POST' => 'Quote post', - 'POST_QUOTE_PM' => 'Quote message', - 'POST_REPLY_PM' => 'Reply to message', - 'PRINT_PM' => 'Print view', - 'PREFERENCES_UPDATED' => 'Your preferences have been updated.', - 'PROFILE_INFO_NOTICE' => 'Please note that this information may be viewable to other members. Be careful when including any personal details. Any fields marked with a * must be completed.', - 'PROFILE_UPDATED' => 'Your profile has been updated.', - 'PROFILE_AUTOLOGIN_KEYS' => 'The "Remember Me" login keys automatically log you in when you visit the board. If you logout, the remember me login key is deleted only on the computer you are using to logout. Here you can see remember login keys created on other computers you used to access this site.', - 'PROFILE_NO_AUTOLOGIN_KEYS' => 'There are no saved "Remember Me" login keys.', - - 'RECIPIENT' => 'Recipient', - 'RECIPIENTS' => 'Recipients', - 'REGISTRATION' => 'Registration', - 'OAUTH_REGISTRATION' => 'Registration using external services', - 'RELEASE_MESSAGES' => '%sRelease all on-hold messages%s… they will be re-sorted into the appropriate folder if enough space is made available.', - 'REMOVE_ADDRESS' => 'Remove address', - 'REMOVE_SELECTED_BOOKMARKS' => 'Remove selected bookmarks', - 'REMOVE_SELECTED_BOOKMARKS_CONFIRM' => 'Are you sure you want to delete all selected bookmarks?', - 'REMOVE_BOOKMARK_MARKED' => 'Remove marked bookmarks', - 'REMOVE_FOLDER' => 'Remove folder', - 'REMOVE_FOLDER_CONFIRM' => 'Are you sure you want to remove this folder?', - 'RENAME' => 'Rename', - 'RENAME_FOLDER' => 'Rename folder', - 'REPLIED_MESSAGE' => 'Replied to message', - 'REPLY_TO_ALL' => 'Reply to sender and all recipients.', - 'REPORT_PM' => 'Report private message', - 'RESET_PASSWORD' => 'Reset password', - 'RESET_TOKEN_EXPIRED_OR_INVALID' => 'The password reset token you supplied is invalid or has expired.', - 'RESIGN_SELECTED' => 'Resign selected', - 'RETURN_FOLDER' => '%1$sReturn to previous folder%2$s', - 'RETURN_UCP' => '%sReturn to the User Control Panel%s', - 'RULE_ADDED' => 'Rule successfully added.', - 'RULE_ALREADY_DEFINED' => 'This rule was defined previously.', - 'RULE_DELETED' => 'Rule successfully removed.', - 'RULE_LIMIT_REACHED' => 'You cannot add more PM rules. You have reached the maximum number of rules.', - 'RULE_NOT_DEFINED' => 'Rule not correctly specified.', - 'RULE_REMOVED_MESSAGES' => array( - 1 => '%d private message was removed due to private message filters.', - 2 => '%d private messages were removed due to private message filters.', - ), - - 'SAME_PASSWORD_ERROR' => 'The new password you entered is the same as your current password.', - 'SEARCH_YOUR_POSTS' => 'Show your posts', - 'SENT_AT' => 'Sent', // Used before dates in private messages - 'SHOW_EMAIL' => 'Users can contact me by email', - 'SIGNATURE_EXPLAIN' => 'This is a block of text that can be added to posts you make. There is a %d character limit.', - 'SIGNATURE_PREVIEW' => 'Your signature will appear like this in posts', - 'SIGNATURE_TOO_LONG' => 'Your signature is too long.', - 'SELECT_CURRENT_TIME' => 'Select current time', - 'SELECT_TIMEZONE' => 'Select timezone', - 'SORT' => 'Sort', - 'SORT_COMMENT' => 'File comment', - 'SORT_DOWNLOADS' => 'Downloads', - 'SORT_EXTENSION' => 'Extension', - 'SORT_FILENAME' => 'Filename', - 'SORT_POST_TIME' => 'Post time', - 'SORT_SIZE' => 'File size', - - 'TIMEZONE' => 'Timezone', - 'TIMEZONE_DATE_SUGGESTION' => 'Suggestion: %s', - 'TIMEZONE_INVALID' => 'The timezone you selected is invalid.', - 'TO' => 'Recipient', - 'TO_MASS' => 'Recipients', - 'TO_ADD' => 'Add recipient', - 'TO_ADD_MASS' => 'Add recipients', - 'TO_ADD_GROUPS' => 'Add groups', - 'TOO_MANY_RECIPIENTS' => 'You tried to send a private message to too many recipients.', - 'TOO_MANY_REGISTERS' => 'You have exceeded the maximum number of registration attempts for this session. Please try again later.', - - 'UCP' => 'User Control Panel', - 'UCP_ACTIVATE' => 'Activate account', - 'UCP_ADMIN_ACTIVATE' => 'Please note that you will need to enter a valid email address before your account is activated. The administrator will review your account and if approved you will receive an email at the address you specified.', - 'UCP_ATTACHMENTS' => 'Attachments', - 'UCP_AUTH_LINK' => 'External accounts', - 'UCP_AUTH_LINK_ASK' => 'You currently have no account associated with this external service. Click the button below to link your board account to an account with this external service.', - 'UCP_AUTH_LINK_ID' => 'Unique identifier', - 'UCP_AUTH_LINK_LINK' => 'Link', - 'UCP_AUTH_LINK_MANAGE' => 'Manage external account associations', - 'UCP_AUTH_LINK_NOT_SUPPORTED' => 'Linking board accounts to external services is not supported by this board’s current authentication method.', - 'UCP_AUTH_LINK_TITLE' => 'Manage your external account associations', - 'UCP_AUTH_LINK_UNLINK' => 'Unlink', - 'UCP_COPPA_BEFORE' => 'Before %s', - 'UCP_COPPA_ON_AFTER' => 'On or after %s', - 'UCP_EMAIL_ACTIVATE' => 'Please note that you will need to enter a valid email address before your account is activated. You will receive an email at the address you provide that contains an account activation link.', - 'UCP_JABBER' => 'Jabber address', - 'UCP_LOGIN_LINK' => 'Set up an external account association', - - 'UCP_MAIN' => 'Overview', - 'UCP_MAIN_ATTACHMENTS' => 'Manage attachments', - 'UCP_MAIN_BOOKMARKS' => 'Manage bookmarks', - 'UCP_MAIN_DRAFTS' => 'Manage drafts', - 'UCP_MAIN_FRONT' => 'Front page', - 'UCP_MAIN_SUBSCRIBED' => 'Manage subscriptions', - - 'UCP_NO_ATTACHMENTS' => 'You have posted no files.', - - 'UCP_NOTIFICATION_LIST' => 'Manage notifications', - 'UCP_NOTIFICATION_LIST_EXPLAIN' => 'Here you may view all past notifications.', - 'UCP_NOTIFICATION_OPTIONS' => 'Edit notification options', - 'UCP_NOTIFICATION_OPTIONS_EXPLAIN' => 'Here you can set your preferred notification methods for the board.', - - 'UCP_PREFS' => 'Board preferences', - 'UCP_PREFS_PERSONAL' => 'Edit global settings', - 'UCP_PREFS_POST' => 'Edit posting defaults', - 'UCP_PREFS_VIEW' => 'Edit display options', - - 'UCP_PM' => 'Private messages', - 'UCP_PM_COMPOSE' => 'Compose message', - 'UCP_PM_DRAFTS' => 'Manage PM drafts', - 'UCP_PM_OPTIONS' => 'Rules, folders & settings', - 'UCP_PM_UNREAD' => 'Unread messages', - 'UCP_PM_VIEW' => 'View messages', - - 'UCP_PROFILE' => 'Profile', - 'UCP_PROFILE_AVATAR' => 'Edit avatar', - 'UCP_PROFILE_PROFILE_INFO' => 'Edit profile', - 'UCP_PROFILE_REG_DETAILS' => 'Edit account settings', - 'UCP_PROFILE_SIGNATURE' => 'Edit signature', - 'UCP_PROFILE_AUTOLOGIN_KEYS'=> 'Manage “Remember Me” login keys', - - 'UCP_USERGROUPS' => 'Usergroups', - 'UCP_USERGROUPS_MEMBER' => 'Edit memberships', - 'UCP_USERGROUPS_MANAGE' => 'Manage groups', - - 'UCP_PASSWORD_RESET_DISABLED' => 'The password reset functionality has been disabled. If you need help accessing your account, please contact the %sBoard Administrator%s', - 'UCP_REGISTER_DISABLE' => 'Creating a new account is currently not possible.', - 'UCP_RESEND' => 'Send activation email', - 'UCP_WELCOME' => 'Welcome to the User Control Panel. From here you can monitor, view and update your profile, preferences, subscribed forums and topics. You can also send messages to other users (if permitted). Please ensure you read any announcements before continuing.', - 'UCP_ZEBRA' => 'Friends & Foes', - 'UCP_ZEBRA_FOES' => 'Manage foes', - 'UCP_ZEBRA_FRIENDS' => 'Manage friends', - 'UNDISCLOSED_RECIPIENT' => 'Undisclosed Recipient', - 'UNKNOWN_FOLDER' => 'Unknown folder', - 'UNWATCH_MARKED' => 'Unwatch marked', - 'UPLOAD_AVATAR_FILE' => 'Upload from your machine', - 'UPLOAD_AVATAR_URL' => 'Upload from a URL', - 'UPLOAD_AVATAR_URL_EXPLAIN' => 'Enter the URL of the location containing the image. The image will be copied to this site.', - 'USERNAME_ALPHA_ONLY_EXPLAIN' => 'Username must be between %1$s and %2$s long and use only alphanumeric characters.', - 'USERNAME_ALPHA_SPACERS_EXPLAIN'=> 'Username must be between %1$s and %2$s long and use alphanumeric, space or -+_[] characters.', - 'USERNAME_ASCII_EXPLAIN' => 'Username must be between %1$s and %2$s long and use only ASCII characters, so no special symbols.', - 'USERNAME_LETTER_NUM_EXPLAIN' => 'Username must be between %1$s and %2$s long and use only letter or number characters.', - 'USERNAME_LETTER_NUM_SPACERS_EXPLAIN'=> 'Username must be between %1$s and %2$s long and use letter, number, space or -+_[] characters.', - 'USERNAME_CHARS_ANY_EXPLAIN' => 'Length must be between %1$s and %2$s.', - 'USERNAME_TAKEN_USERNAME' => 'The username you entered is already in use, please select an alternative.', - 'USERNAME_DISALLOWED_USERNAME' => 'The username you entered has been disallowed or contains a disallowed word. Please choose a different name.', - 'USER_NOT_FOUND_OR_INACTIVE' => 'The usernames you specified could either not be found or are not activated users.', - - 'VIEW_AVATARS' => 'Display avatars', - 'VIEW_EDIT' => 'View/Edit', - 'VIEW_FLASH' => 'Display Flash animations', - 'VIEW_IMAGES' => 'Display images within posts', - 'VIEW_NEXT_HISTORY' => 'Next PM in history', - 'VIEW_NEXT_PM' => 'Next PM', - 'VIEW_PM' => 'View message', - 'VIEW_PM_INFO' => 'Message details', - 'VIEW_PM_MESSAGES' => array( - 1 => '%d message', - 2 => '%d messages', - ), - 'VIEW_PREVIOUS_HISTORY' => 'Previous PM in history', - 'VIEW_PREVIOUS_PM' => 'Previous PM', - 'VIEW_PROFILE' => 'View profile', - 'VIEW_SIGS' => 'Display signatures', - 'VIEW_SMILIES' => 'Display smilies as images', - 'VIEW_TOPICS_DAYS' => 'Display topics from previous days', - 'VIEW_TOPICS_DIR' => 'Display topic order direction', - 'VIEW_TOPICS_KEY' => 'Display topics ordering by', - 'VIEW_POSTS_DAYS' => 'Display posts from previous days', - 'VIEW_POSTS_DIR' => 'Display post order direction', - 'VIEW_POSTS_KEY' => 'Display posts ordering by', - - 'WATCHED_EXPLAIN' => 'Below is a list of forums and topics you are subscribed to. You will be notified of new posts in either. To unsubscribe mark the forum or topic and then press the Unwatch marked button.', - 'WATCHED_FORUMS' => 'Watched forums', - 'WATCHED_TOPICS' => 'Watched topics', - 'WRONG_ACTIVATION' => 'The activation key you supplied does not match any in the database.', - - 'YOUR_DETAILS' => 'Your activity', - 'YOUR_FOES' => 'Your foes', - 'YOUR_FOES_EXPLAIN' => 'To remove usernames select them and click submit.', - 'YOUR_FRIENDS' => 'Your friends', - 'YOUR_FRIENDS_EXPLAIN' => 'To remove usernames select them and click submit.', - 'YOUR_WARNINGS' => 'Your warning level', - - 'PM_ACTION' => array( - 'PLACE_INTO_FOLDER' => 'Place into folder', - 'MARK_AS_READ' => 'Mark as read', - 'MARK_AS_IMPORTANT' => 'Mark message', - 'DELETE_MESSAGE' => 'Delete message', - ), - 'PM_CHECK' => array( - 'SUBJECT' => 'Subject', - 'SENDER' => 'Sender', - 'MESSAGE' => 'Message', - 'STATUS' => 'Message status', - 'TO' => 'Sent To', - ), - 'PM_RULE' => array( - 'IS_LIKE' => 'is like', - 'IS_NOT_LIKE' => 'is not like', - 'IS' => 'is', - 'IS_NOT' => 'is not', - 'BEGINS_WITH' => 'begins with', - 'ENDS_WITH' => 'ends with', - 'IS_FRIEND' => 'is friend', - 'IS_FOE' => 'is foe', - 'IS_USER' => 'is user', - 'IS_GROUP' => 'is in usergroup', - 'ANSWERED' => 'answered', - 'FORWARDED' => 'forwarded', - 'TO_GROUP' => 'to my default usergroup', - 'TO_ME' => 'to me', - ), - - 'GROUPS_EXPLAIN' => 'Usergroups enable board admins to better administer users. By default you will be placed in a specific group, this is your default group. This group defines how you may appear to other users, for example your username colouration, avatar, rank, etc. Depending on whether the administrator allows it you may be allowed to change your default group. You may also be placed in or allowed to join other groups. Some groups may give you additional permissions to view content or increase your capabilities in other areas.', - 'GROUP_LEADER' => 'Leaderships', - 'GROUP_MEMBER' => 'Memberships', - 'GROUP_PENDING' => 'Pending memberships', - 'GROUP_NONMEMBER' => 'Non-memberships', - 'GROUP_DETAILS' => 'Group details', - - 'NO_LEADER' => 'No group leaderships', - 'NO_MEMBER' => 'No group memberships', - 'NO_PENDING' => 'No pending memberships', - 'NO_NONMEMBER' => 'No non-member groups', -)); diff --git a/install/update/new/mcp.php b/install/update/new/mcp.php deleted file mode 100644 index c8fb023..0000000 --- a/install/update/new/mcp.php +++ /dev/null @@ -1,331 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -define('IN_PHPBB', true); -$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); -include($phpbb_root_path . 'common.' . $phpEx); -include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); -include($phpbb_root_path . 'includes/functions_mcp.' . $phpEx); -require($phpbb_root_path . 'includes/functions_module.' . $phpEx); - -// Start session management -$user->session_begin(); -$auth->acl($user->data); -$user->setup('mcp'); - -$module = new p_master(); - -// Setting a variable to let the style designer know where he is... -$template->assign_var('S_IN_MCP', true); - -// Basic parameter data -$id = $request->variable('i', ''); - -$mode = $request->variable('mode', array('')); -$mode = count($mode) ? array_shift($mode) : $request->variable('mode', ''); - -// Only Moderators can go beyond this point -if (!$user->data['is_registered']) -{ - if ($user->data['is_bot']) - { - redirect(append_sid("{$phpbb_root_path}index.$phpEx")); - } - - login_box('', $user->lang['LOGIN_EXPLAIN_MCP']); -} - -$quickmod = (isset($_REQUEST['quickmod'])) ? true : false; -$action = $request->variable('action', ''); -$action_ary = $request->variable('action', array('' => 0)); - -$forum_action = $request->variable('forum_action', ''); -if ($forum_action !== '' && $request->variable('sort', false, false, \phpbb\request\request_interface::POST)) -{ - $action = $forum_action; -} - -if (count($action_ary)) -{ - $action = key($action_ary); -} -unset($action_ary); - -if ($mode == 'topic_logs') -{ - $id = 'logs'; - $quickmod = false; -} - -$post_id = $request->variable('p', 0); -$topic_id = $request->variable('t', 0); -$forum_id = $request->variable('f', 0); -$report_id = $request->variable('r', 0); -$user_id = $request->variable('u', 0); -$username = $request->variable('username', '', true); - -if ($post_id) -{ - // We determine the topic and forum id here, to make sure the moderator really has moderative rights on this post - $sql = 'SELECT topic_id, forum_id - FROM ' . POSTS_TABLE . " - WHERE post_id = $post_id"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $topic_id = (int) $row['topic_id']; - $forum_id = (int) $row['forum_id']; -} -else if ($topic_id) -{ - $sql = 'SELECT forum_id - FROM ' . TOPICS_TABLE . " - WHERE topic_id = $topic_id"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $forum_id = (int) $row['forum_id']; -} - -// If the user doesn't have any moderator powers (globally or locally) he can't access the mcp -if (!$auth->acl_getf_global('m_')) -{ - // Except he is using one of the quickmod tools for users - $user_quickmod_actions = array( - 'lock' => 'f_user_lock', - 'make_sticky' => 'f_sticky', - 'make_announce' => 'f_announce', - 'make_global' => 'f_announce_global', - 'make_normal' => array('f_announce', 'f_announce_global', 'f_sticky') - ); - - $allow_user = false; - if ($quickmod && isset($user_quickmod_actions[$action]) && $user->data['is_registered'] && $auth->acl_gets($user_quickmod_actions[$action], $forum_id)) - { - $topic_info = phpbb_get_topic_data(array($topic_id)); - if ($topic_info[$topic_id]['topic_poster'] == $user->data['user_id']) - { - $allow_user = true; - } - } - - if (!$allow_user) - { - send_status_line(403, 'Forbidden'); - trigger_error('NOT_AUTHORISED'); - } -} - -// if the user cannot read the forum he tries to access then we won't allow mcp access either -if ($forum_id && !$auth->acl_get('f_read', $forum_id)) -{ - send_status_line(403, 'Forbidden'); - trigger_error('NOT_AUTHORISED'); -} - -/** -* Allow applying additional permissions to MCP access besides f_read -* -* @event core.mcp_global_f_read_auth_after -* @var string action The action the user tried to execute -* @var int forum_id The forum the user tried to access -* @var string mode The MCP module the user is trying to access -* @var p_master module Module system class -* @var bool quickmod True if the user is accessing using quickmod tools -* @var int topic_id The topic the user tried to access -* @since 3.1.3-RC1 -*/ -$vars = array( - 'action', - 'forum_id', - 'mode', - 'module', - 'quickmod', - 'topic_id', -); -extract($phpbb_dispatcher->trigger_event('core.mcp_global_f_read_auth_after', compact($vars))); - -if ($forum_id) -{ - $module->acl_forum_id = $forum_id; -} - -// Instantiate module system and generate list of available modules -$module->list_modules('mcp'); - -if ($quickmod) -{ - $mode = 'quickmod'; - - switch ($action) - { - case 'lock': - case 'unlock': - case 'lock_post': - case 'unlock_post': - case 'make_sticky': - case 'make_announce': - case 'make_global': - case 'make_normal': - case 'fork': - case 'move': - case 'delete_post': - case 'delete_topic': - case 'restore_topic': - $module->load('mcp', 'main', 'quickmod'); - return; - break; - - case 'topic_logs': - // Reset start parameter if we jumped from the quickmod dropdown - if ($request->variable('start', 0)) - { - $request->overwrite('start', 0); - } - - $module->set_active('logs', 'topic_logs'); - break; - - case 'merge_topic': - $module->set_active('main', 'forum_view'); - break; - - case 'split': - case 'merge': - $module->set_active('main', 'topic_view'); - break; - - default: - // If needed, the flag can be set to true within event listener - // to indicate that the action was handled properly - // and to pass by the trigger_error() call below - $is_valid_action = false; - - /** - * This event allows you to add custom quickmod options - * - * @event core.modify_quickmod_options - * @var object module Instance of module system class - * @var string action Quickmod option - * @var bool is_valid_action Flag indicating if the action was handled properly - * @since 3.1.0-a4 - */ - $vars = array('module', 'action', 'is_valid_action'); - extract($phpbb_dispatcher->trigger_event('core.modify_quickmod_options', compact($vars))); - - if (!$is_valid_action) - { - trigger_error($user->lang('QUICKMOD_ACTION_NOT_ALLOWED', $action), E_USER_ERROR); - } - break; - } -} -else -{ - // Select the active module - $module->set_active($id, $mode); -} - -// Hide some of the options if we don't have the relevant information to use them -if (!$post_id) -{ - $module->set_display('main', 'post_details', false); - $module->set_display('warn', 'warn_post', false); -} - -if ($mode == '' || $mode == 'unapproved_topics' || $mode == 'unapproved_posts' || $mode == 'deleted_topics' || $mode == 'deleted_posts') -{ - $module->set_display('queue', 'approve_details', false); -} - -if ($mode == '' || $mode == 'reports' || $mode == 'reports_closed' || $mode == 'pm_reports' || $mode == 'pm_reports_closed' || $mode == 'pm_report_details') -{ - $module->set_display('reports', 'report_details', false); -} - -if ($mode == '' || $mode == 'reports' || $mode == 'reports_closed' || $mode == 'pm_reports' || $mode == 'pm_reports_closed' || $mode == 'report_details') -{ - $module->set_display('pm_reports', 'pm_report_details', false); -} - -if (!$topic_id) -{ - $module->set_display('main', 'topic_view', false); - $module->set_display('logs', 'topic_logs', false); -} - -if (!$forum_id) -{ - $module->set_display('main', 'forum_view', false); - $module->set_display('logs', 'forum_logs', false); -} - -if (!$user_id && $username == '') -{ - $module->set_display('notes', 'user_notes', false); - $module->set_display('warn', 'warn_user', false); -} - -/** -* This event allows you to set display option for custom MCP modules -* -* @event core.modify_mcp_modules_display_option -* @var p_master module Module system class -* @var string mode MCP mode -* @var int user_id User id -* @var int forum_id Forum id -* @var int topic_id Topic id -* @var int post_id Post id -* @var string username User name -* @var int id Parent module id -* @since 3.1.0-b2 -*/ -$vars = array( - 'module', - 'mode', - 'user_id', - 'forum_id', - 'topic_id', - 'post_id', - 'username', - 'id', -); -extract($phpbb_dispatcher->trigger_event('core.modify_mcp_modules_display_option', compact($vars))); - -$template->assign_block_vars('navlinks', array( - 'BREADCRUMB_NAME' => $user->lang('MCP'), - 'U_BREADCRUMB' => append_sid("{$phpbb_root_path}mcp.$phpEx"), -)); - -// Load and execute the relevant module -$module->load_active(); - -// Assign data to the template engine for the list of modules -$module->assign_tpl_vars(append_sid("{$phpbb_root_path}mcp.$phpEx")); - -// Generate urls for letting the moderation control panel being accessed in different modes -$template->assign_vars(array( - 'U_MCP' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main'), - 'U_MCP_FORUM' => ($forum_id) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&mode=forum_view&f=$forum_id") : '', - 'U_MCP_TOPIC' => ($forum_id && $topic_id) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&mode=topic_view&t=$topic_id") : '', - 'U_MCP_POST' => ($forum_id && $topic_id && $post_id) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&mode=post_details&t=$topic_id&p=$post_id") : '', -)); - -// Generate the page, do not display/query online list -$module->display($module->get_page_title()); diff --git a/install/update/new/memberlist.php b/install/update/new/memberlist.php deleted file mode 100644 index e933b54..0000000 --- a/install/update/new/memberlist.php +++ /dev/null @@ -1,1852 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -define('IN_PHPBB', true); -$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); -include($phpbb_root_path . 'common.' . $phpEx); -include($phpbb_root_path . 'includes/functions_display.' . $phpEx); - -$mode = $request->variable('mode', ''); - -if ($mode === 'contactadmin') -{ - define('SKIP_CHECK_BAN', true); - define('SKIP_CHECK_DISABLED', true); -} - -// Start session management -$user->session_begin(); -$auth->acl($user->data); -$user->setup(array('memberlist', 'groups')); - -// Setting a variable to let the style designer know where he is... -$template->assign_var('S_IN_MEMBERLIST', true); - -// Grab data -$action = $request->variable('action', ''); -$user_id = $request->variable('u', ANONYMOUS); -$username = $request->variable('un', '', true); -$group_id = $request->variable('g', 0); -$topic_id = $request->variable('t', 0); - -// Redirect when old mode is used -if ($mode == 'leaders') -{ - send_status_line(301, 'Moved Permanently'); - redirect(append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=team')); -} - -// Check our mode... -if (!in_array($mode, array('', 'group', 'viewprofile', 'email', 'contact', 'contactadmin', 'searchuser', 'team', 'livesearch'))) -{ - trigger_error('NO_MODE'); -} - -switch ($mode) -{ - case 'email': - case 'contactadmin': - break; - - case 'livesearch': - if (!$config['allow_live_searches']) - { - trigger_error('LIVE_SEARCHES_NOT_ALLOWED'); - } - // No break - - default: - // Can this user view profiles/memberlist? - if (!$auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel')) - { - if ($user->data['user_id'] != ANONYMOUS) - { - send_status_line(403, 'Forbidden'); - trigger_error('NO_VIEW_USERS'); - } - - login_box('', ((isset($user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)])) ? $user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)] : $user->lang['LOGIN_EXPLAIN_MEMBERLIST'])); - } - break; -} - -/** @var \phpbb\group\helper $group_helper */ -$group_helper = $phpbb_container->get('group_helper'); - -$start = $request->variable('start', 0); -$submit = (isset($_POST['submit'])) ? true : false; - -$default_key = 'c'; -$sort_key = $request->variable('sk', $default_key); -$sort_dir = $request->variable('sd', 'a'); - -$user_types = array(USER_NORMAL, USER_FOUNDER); -if ($auth->acl_get('a_user')) -{ - $user_types[] = USER_INACTIVE; -} - -// What do you want to do today? ... oops, I think that line is taken ... -switch ($mode) -{ - case 'team': - // Display a listing of board admins, moderators - if (!function_exists('user_get_id_name')) - { - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - } - - $page_title = $user->lang['THE_TEAM']; - $template_html = 'memberlist_team.html'; - - $sql = 'SELECT * - FROM ' . TEAMPAGE_TABLE . ' - ORDER BY teampage_position ASC'; - $result = $db->sql_query($sql, 3600); - $teampage_data = $db->sql_fetchrowset($result); - $db->sql_freeresult($result); - - $sql_ary = array( - 'SELECT' => 'g.group_id, g.group_name, g.group_colour, g.group_type, ug.user_id as ug_user_id, t.teampage_id', - - 'FROM' => array(GROUPS_TABLE => 'g'), - - 'LEFT_JOIN' => array( - array( - 'FROM' => array(TEAMPAGE_TABLE => 't'), - 'ON' => 't.group_id = g.group_id', - ), - array( - 'FROM' => array(USER_GROUP_TABLE => 'ug'), - 'ON' => 'ug.group_id = g.group_id AND ug.user_pending = 0 AND ug.user_id = ' . (int) $user->data['user_id'], - ), - ), - ); - - $result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary)); - - $group_ids = $groups_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - if ($row['group_type'] == GROUP_HIDDEN && !$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel') && $row['ug_user_id'] != $user->data['user_id']) - { - $row['group_name'] = $user->lang['GROUP_UNDISCLOSED']; - $row['u_group'] = ''; - } - else - { - $row['group_name'] = $group_helper->get_name($row['group_name']); - $row['u_group'] = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&g=' . $row['group_id']); - } - - if ($row['teampage_id']) - { - // Only put groups into the array we want to display. - // We are fetching all groups, to ensure we got all data for default groups. - $group_ids[] = (int) $row['group_id']; - } - $groups_ary[(int) $row['group_id']] = $row; - } - $db->sql_freeresult($result); - - $sql_ary = array( - 'SELECT' => 'u.user_id, u.group_id as default_group, u.username, u.username_clean, u.user_colour, u.user_type, u.user_rank, u.user_posts, u.user_allow_pm, g.group_id', - - 'FROM' => array( - USER_GROUP_TABLE => 'ug', - ), - - 'LEFT_JOIN' => array( - array( - 'FROM' => array(USERS_TABLE => 'u'), - 'ON' => 'ug.user_id = u.user_id', - ), - array( - 'FROM' => array(GROUPS_TABLE => 'g'), - 'ON' => 'ug.group_id = g.group_id', - ), - ), - - 'WHERE' => $db->sql_in_set('g.group_id', $group_ids, false, true) . ' AND ug.user_pending = 0', - - 'ORDER_BY' => 'u.username_clean ASC', - ); - - /** - * Modify the query used to get the users for the team page - * - * @event core.memberlist_team_modify_query - * @var array sql_ary Array containing the query - * @var array group_ids Array of group ids - * @var array teampage_data The teampage data - * @since 3.1.3-RC1 - */ - $vars = array( - 'sql_ary', - 'group_ids', - 'teampage_data', - ); - extract($phpbb_dispatcher->trigger_event('core.memberlist_team_modify_query', compact($vars))); - - $result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary)); - - $user_ary = $user_ids = $group_users = array(); - while ($row = $db->sql_fetchrow($result)) - { - $row['forums'] = ''; - $row['forums_ary'] = array(); - $user_ary[(int) $row['user_id']] = $row; - $user_ids[] = (int) $row['user_id']; - $group_users[(int) $row['group_id']][] = (int) $row['user_id']; - } - $db->sql_freeresult($result); - - $user_ids = array_unique($user_ids); - - if (!empty($user_ids) && $config['teampage_forums']) - { - $template->assign_var('S_DISPLAY_MODERATOR_FORUMS', true); - // Get all moderators - $perm_ary = $auth->acl_get_list($user_ids, array('m_'), false); - - foreach ($perm_ary as $forum_id => $forum_ary) - { - foreach ($forum_ary as $auth_option => $id_ary) - { - foreach ($id_ary as $id) - { - if (!$forum_id) - { - $user_ary[$id]['forums'] = $user->lang['ALL_FORUMS']; - } - else - { - $user_ary[$id]['forums_ary'][] = $forum_id; - } - } - } - } - - $sql = 'SELECT forum_id, forum_name - FROM ' . FORUMS_TABLE; - $result = $db->sql_query($sql); - - $forums = array(); - while ($row = $db->sql_fetchrow($result)) - { - $forums[$row['forum_id']] = $row['forum_name']; - } - $db->sql_freeresult($result); - - foreach ($user_ary as $user_id => $user_data) - { - if (!$user_data['forums']) - { - foreach ($user_data['forums_ary'] as $forum_id) - { - $user_ary[$user_id]['forums_options'] = true; - if (isset($forums[$forum_id])) - { - if ($auth->acl_get('f_list', $forum_id)) - { - $user_ary[$user_id]['forums'] .= ''; - } - } - } - } - } - } - - $parent_team = 0; - foreach ($teampage_data as $team_data) - { - // If this team entry has no group, it's a category - if (!$team_data['group_id']) - { - $template->assign_block_vars('group', array( - 'GROUP_NAME' => $team_data['teampage_name'], - )); - - $parent_team = (int) $team_data['teampage_id']; - continue; - } - - $group_data = $groups_ary[(int) $team_data['group_id']]; - $group_id = (int) $team_data['group_id']; - - if (!$team_data['teampage_parent']) - { - // If the group does not have a parent category, we display the groupname as category - $template->assign_block_vars('group', array( - 'GROUP_NAME' => $group_data['group_name'], - 'GROUP_COLOR' => $group_data['group_colour'], - 'U_GROUP' => $group_data['u_group'], - )); - } - - // Display group members. - if (!empty($group_users[$group_id])) - { - foreach ($group_users[$group_id] as $user_id) - { - if (isset($user_ary[$user_id])) - { - $row = $user_ary[$user_id]; - if ($config['teampage_memberships'] == 1 && ($group_id != $groups_ary[$row['default_group']]['group_id']) && $groups_ary[$row['default_group']]['teampage_id']) - { - // Display users in their primary group, instead of the first group, when it is displayed on the teampage. - continue; - } - - $user_rank_data = phpbb_get_user_rank($row, (($row['user_id'] == ANONYMOUS) ? false : $row['user_posts'])); - - $template_vars = array( - 'USER_ID' => $row['user_id'], - 'FORUMS' => $row['forums'], - 'FORUM_OPTIONS' => (isset($row['forums_options'])) ? true : false, - 'RANK_TITLE' => $user_rank_data['title'], - - 'GROUP_NAME' => $groups_ary[$row['default_group']]['group_name'], - 'GROUP_COLOR' => $groups_ary[$row['default_group']]['group_colour'], - 'U_GROUP' => $groups_ary[$row['default_group']]['u_group'], - - 'RANK_IMG' => $user_rank_data['img'], - 'RANK_IMG_SRC' => $user_rank_data['img_src'], - - 'S_INACTIVE' => $row['user_type'] == USER_INACTIVE, - - 'U_PM' => ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($row['user_allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&u=' . $row['user_id']) : '', - - 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), - 'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), - 'USER_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), - 'U_VIEW_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']), - ); - - /** - * Modify the template vars for displaying the user in the groups on the teampage - * - * @event core.memberlist_team_modify_template_vars - * @var array template_vars Array containing the query - * @var array row Array containing the action user row - * @var array groups_ary Array of groups with all users that should be displayed - * @since 3.1.3-RC1 - */ - $vars = array( - 'template_vars', - 'row', - 'groups_ary', - ); - extract($phpbb_dispatcher->trigger_event('core.memberlist_team_modify_template_vars', compact($vars))); - - $template->assign_block_vars('group.user', $template_vars); - - if ($config['teampage_memberships'] != 2) - { - unset($user_ary[$user_id]); - } - } - } - } - } - - $template->assign_block_vars('navlinks', array( - 'BREADCRUMB_NAME' => $page_title, - 'U_BREADCRUMB' => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=team"), - )); - - $template->assign_vars(array( - 'PM_IMG' => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE'])) - ); - break; - - case 'contact': - - $page_title = $user->lang['IM_USER']; - $template_html = 'memberlist_im.html'; - - if (!$auth->acl_get('u_sendim')) - { - send_status_line(403, 'Forbidden'); - trigger_error('NOT_AUTHORISED'); - } - - $presence_img = ''; - switch ($action) - { - case 'jabber': - $lang = 'JABBER'; - $sql_field = 'user_jabber'; - $s_select = (@extension_loaded('xml') && $config['jab_enable']) ? 'S_SEND_JABBER' : 'S_NO_SEND_JABBER'; - $s_action = append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&action=$action&u=$user_id"); - break; - - default: - trigger_error('NO_MODE', E_USER_ERROR); - break; - } - - // Grab relevant data - $sql = "SELECT user_id, username, user_email, user_lang, $sql_field - FROM " . USERS_TABLE . " - WHERE user_id = $user_id - AND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')'; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - trigger_error('NO_USER'); - } - else if (empty($row[$sql_field])) - { - trigger_error('IM_NO_DATA'); - } - - // Post data grab actions - switch ($action) - { - case 'jabber': - add_form_key('memberlist_messaging'); - - if ($submit && @extension_loaded('xml') && $config['jab_enable']) - { - if (check_form_key('memberlist_messaging')) - { - - include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); - - $subject = sprintf($user->lang['IM_JABBER_SUBJECT'], $user->data['username'], $config['server_name']); - $message = $request->variable('message', '', true); - - if (empty($message)) - { - trigger_error('EMPTY_MESSAGE_IM'); - } - - $messenger = new messenger(false); - - $messenger->template('profile_send_im', $row['user_lang']); - $messenger->subject(htmlspecialchars_decode($subject)); - - $messenger->replyto($user->data['user_email']); - $messenger->set_addresses($row); - - $messenger->assign_vars(array( - 'BOARD_CONTACT' => phpbb_get_board_contact($config, $phpEx), - 'FROM_USERNAME' => htmlspecialchars_decode($user->data['username']), - 'TO_USERNAME' => htmlspecialchars_decode($row['username']), - 'MESSAGE' => htmlspecialchars_decode($message)) - ); - - $messenger->send(NOTIFY_IM); - - $s_select = 'S_SENT_JABBER'; - } - else - { - trigger_error('FORM_INVALID'); - } - } - break; - } - - $template->assign_block_vars('navlinks', array( - 'BREADCRUMB_NAME' => $page_title, - 'U_BREADCRUMB' => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&action=$action&u=$user_id"), - )); - - // Send vars to the template - $template->assign_vars(array( - 'IM_CONTACT' => $row[$sql_field], - 'A_IM_CONTACT' => addslashes($row[$sql_field]), - - 'USERNAME' => $row['username'], - 'CONTACT_NAME' => $row[$sql_field], - 'SITENAME' => $config['sitename'], - - 'PRESENCE_IMG' => $presence_img, - - 'L_SEND_IM_EXPLAIN' => $user->lang['IM_' . $lang], - 'L_IM_SENT_JABBER' => sprintf($user->lang['IM_SENT_JABBER'], $row['username']), - - $s_select => true, - 'S_IM_ACTION' => $s_action) - ); - - break; - - case 'viewprofile': - // Display a profile - if ($user_id == ANONYMOUS && !$username) - { - trigger_error('NO_USER'); - } - - // Get user... - $sql_array = array( - 'SELECT' => 'u.*', - 'FROM' => array( - USERS_TABLE => 'u' - ), - 'WHERE' => (($username) ? "u.username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'" : "u.user_id = $user_id"), - ); - - /** - * Modify user data SQL before member profile row is created - * - * @event core.memberlist_modify_viewprofile_sql - * @var int user_id The user ID - * @var string username The username - * @var array sql_array Array containing the main query - * @since 3.2.6-RC1 - */ - $vars = array( - 'user_id', - 'username', - 'sql_array', - ); - extract($phpbb_dispatcher->trigger_event('core.memberlist_modify_viewprofile_sql', compact($vars))); - - $sql = $db->sql_build_query('SELECT', $sql_array); - $result = $db->sql_query($sql); - $member = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$member) - { - trigger_error('NO_USER'); - } - - // a_user admins and founder are able to view inactive users and bots to be able to manage them more easily - // Normal users are able to see at least users having only changed their profile settings but not yet reactivated. - if (!$auth->acl_get('a_user') && $user->data['user_type'] != USER_FOUNDER) - { - if ($member['user_type'] == USER_IGNORE) - { - trigger_error('NO_USER'); - } - else if ($member['user_type'] == USER_INACTIVE && $member['user_inactive_reason'] != INACTIVE_PROFILE) - { - trigger_error('NO_USER'); - } - } - - $user_id = (int) $member['user_id']; - - // Get group memberships - // Also get visiting user's groups to determine hidden group memberships if necessary. - $auth_hidden_groups = ($user_id === (int) $user->data['user_id'] || $auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) ? true : false; - $sql_uid_ary = ($auth_hidden_groups) ? array($user_id) : array($user_id, (int) $user->data['user_id']); - - // Do the SQL thang - $sql_ary = [ - 'SELECT' => 'g.group_id, g.group_name, g.group_type, ug.user_id', - - 'FROM' => [ - GROUPS_TABLE => 'g', - ], - - 'LEFT_JOIN' => [ - [ - 'FROM' => [USER_GROUP_TABLE => 'ug'], - 'ON' => 'g.group_id = ug.group_id', - ], - ], - - 'WHERE' => $db->sql_in_set('ug.user_id', $sql_uid_ary) . ' - AND ug.user_pending = 0', - ]; - - /** - * Modify the query used to get the group data - * - * @event core.modify_memberlist_viewprofile_group_sql - * @var array sql_ary Array containing the query - * @since 3.2.6-RC1 - */ - $vars = array( - 'sql_ary', - ); - extract($phpbb_dispatcher->trigger_event('core.modify_memberlist_viewprofile_group_sql', compact($vars))); - - $result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary)); - - // Divide data into profile data and current user data - $profile_groups = $user_groups = array(); - while ($row = $db->sql_fetchrow($result)) - { - $row['user_id'] = (int) $row['user_id']; - $row['group_id'] = (int) $row['group_id']; - - if ($row['user_id'] == $user_id) - { - $profile_groups[] = $row; - } - else - { - $user_groups[$row['group_id']] = $row['group_id']; - } - } - $db->sql_freeresult($result); - - // Filter out hidden groups and sort groups by name - $group_data = $group_sort = array(); - foreach ($profile_groups as $row) - { - if (!$auth_hidden_groups && $row['group_type'] == GROUP_HIDDEN && !isset($user_groups[$row['group_id']])) - { - // Skip over hidden groups the user cannot see - continue; - } - - $row['group_name'] = $group_helper->get_name($row['group_name']); - - $group_sort[$row['group_id']] = utf8_clean_string($row['group_name']); - $group_data[$row['group_id']] = $row; - } - unset($profile_groups); - unset($user_groups); - asort($group_sort); - - /** - * Modify group data before options is created and data is unset - * - * @event core.modify_memberlist_viewprofile_group_data - * @var array group_data Array containing the group data - * @var array group_sort Array containing the sorted group data - * @since 3.2.6-RC1 - */ - $vars = array( - 'group_data', - 'group_sort', - ); - extract($phpbb_dispatcher->trigger_event('core.modify_memberlist_viewprofile_group_data', compact($vars))); - - $group_options = ''; - foreach ($group_sort as $group_id => $null) - { - $row = $group_data[$group_id]; - - $group_options .= ''; - } - unset($group_data); - unset($group_sort); - - // What colour is the zebra - $sql = 'SELECT friend, foe - FROM ' . ZEBRA_TABLE . " - WHERE zebra_id = $user_id - AND user_id = {$user->data['user_id']}"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - - $foe = $row ? (bool) $row['foe'] : false; - $friend = $row ? (bool) $row['friend'] : false; - - $db->sql_freeresult($result); - - if ($config['load_onlinetrack']) - { - $sql = 'SELECT MAX(session_time) AS session_time, MIN(session_viewonline) AS session_viewonline - FROM ' . SESSIONS_TABLE . " - WHERE session_user_id = $user_id"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $member['session_time'] = (isset($row['session_time'])) ? $row['session_time'] : 0; - $member['session_viewonline'] = (isset($row['session_viewonline'])) ? $row['session_viewonline'] : 0; - unset($row); - } - - if ($config['load_user_activity']) - { - display_user_activity($member); - } - - // Do the relevant calculations - $memberdays = max(1, round((time() - $member['user_regdate']) / 86400)); - $posts_per_day = $member['user_posts'] / $memberdays; - $percentage = ($config['num_posts']) ? min(100, ($member['user_posts'] / $config['num_posts']) * 100) : 0; - - - if ($member['user_sig']) - { - $parse_flags = ($member['user_sig_bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES; - $member['user_sig'] = generate_text_for_display($member['user_sig'], $member['user_sig_bbcode_uid'], $member['user_sig_bbcode_bitfield'], $parse_flags, true); - } - - // We need to check if the modules 'zebra' ('friends' & 'foes' mode), 'notes' ('user_notes' mode) and 'warn' ('warn_user' mode) are accessible to decide if we can display appropriate links - $zebra_enabled = $friends_enabled = $foes_enabled = $user_notes_enabled = $warn_user_enabled = false; - - // Only check if the user is logged in - if ($user->data['is_registered']) - { - if (!class_exists('p_master')) - { - include($phpbb_root_path . 'includes/functions_module.' . $phpEx); - } - $module = new p_master(); - - $module->list_modules('ucp'); - $module->list_modules('mcp'); - - $user_notes_enabled = ($module->loaded('mcp_notes', 'user_notes')) ? true : false; - $warn_user_enabled = ($module->loaded('mcp_warn', 'warn_user')) ? true : false; - $zebra_enabled = ($module->loaded('ucp_zebra')) ? true : false; - $friends_enabled = ($module->loaded('ucp_zebra', 'friends')) ? true : false; - $foes_enabled = ($module->loaded('ucp_zebra', 'foes')) ? true : false; - - unset($module); - } - - // Custom Profile Fields - $profile_fields = array(); - if ($config['load_cpf_viewprofile']) - { - /* @var $cp \phpbb\profilefields\manager */ - $cp = $phpbb_container->get('profilefields.manager'); - $profile_fields = $cp->grab_profile_fields_data($user_id); - $profile_fields = (isset($profile_fields[$user_id])) ? $cp->generate_profile_fields_template_data($profile_fields[$user_id]) : array(); - } - - /** - * Modify user data before we display the profile - * - * @event core.memberlist_view_profile - * @var array member Array with user's data - * @var bool user_notes_enabled Is the mcp user notes module enabled? - * @var bool warn_user_enabled Is the mcp warnings module enabled? - * @var bool zebra_enabled Is the ucp zebra module enabled? - * @var bool friends_enabled Is the ucp friends module enabled? - * @var bool foes_enabled Is the ucp foes module enabled? - * @var bool friend Is the user friend? - * @var bool foe Is the user foe? - * @var array profile_fields Array with user's profile field data - * @since 3.1.0-a1 - * @changed 3.1.0-b2 Added friend and foe status - * @changed 3.1.0-b3 Added profile fields data - */ - $vars = array( - 'member', - 'user_notes_enabled', - 'warn_user_enabled', - 'zebra_enabled', - 'friends_enabled', - 'foes_enabled', - 'friend', - 'foe', - 'profile_fields', - ); - extract($phpbb_dispatcher->trigger_event('core.memberlist_view_profile', compact($vars))); - - $template->assign_vars(phpbb_show_profile($member, $user_notes_enabled, $warn_user_enabled)); - - // If the user has m_approve permission or a_user permission, then list then display unapproved posts - if ($auth->acl_getf_global('m_approve') || $auth->acl_get('a_user')) - { - $sql = 'SELECT COUNT(post_id) as posts_in_queue - FROM ' . POSTS_TABLE . ' - WHERE poster_id = ' . $user_id . ' - AND ' . $db->sql_in_set('post_visibility', array(ITEM_UNAPPROVED, ITEM_REAPPROVE)); - $result = $db->sql_query($sql); - $member['posts_in_queue'] = (int) $db->sql_fetchfield('posts_in_queue'); - $db->sql_freeresult($result); - } - else - { - $member['posts_in_queue'] = 0; - } - - // Define the main array of vars to assign to memberlist_view.html - $template_ary = array( - 'L_POSTS_IN_QUEUE' => $user->lang('NUM_POSTS_IN_QUEUE', $member['posts_in_queue']), - - 'POSTS_DAY' => $user->lang('POST_DAY', $posts_per_day), - 'POSTS_PCT' => $user->lang('POST_PCT', $percentage), - - 'SIGNATURE' => $member['user_sig'], - 'POSTS_IN_QUEUE' => $member['posts_in_queue'], - - 'PM_IMG' => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE']), - 'L_SEND_EMAIL_USER' => $user->lang('SEND_EMAIL_USER', $member['username']), - 'EMAIL_IMG' => $user->img('icon_contact_email', $user->lang['EMAIL']), - 'JABBER_IMG' => $user->img('icon_contact_jabber', $user->lang['JABBER']), - 'SEARCH_IMG' => $user->img('icon_user_search', $user->lang['SEARCH']), - - 'S_PROFILE_ACTION' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group'), - 'S_GROUP_OPTIONS' => $group_options, - 'S_CUSTOM_FIELDS' => (isset($profile_fields['row']) && count($profile_fields['row'])) ? true : false, - - 'U_USER_ADMIN' => ($auth->acl_get('a_user')) ? append_sid("{$phpbb_admin_path}index.$phpEx", 'i=users&mode=overview&u=' . $user_id, true, $user->session_id) : '', - 'U_USER_BAN' => ($auth->acl_get('m_ban') && $user_id != $user->data['user_id']) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=ban&mode=user&u=' . $user_id, true, $user->session_id) : '', - 'U_MCP_QUEUE' => ($auth->acl_getf_global('m_approve')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue', true, $user->session_id) : '', - - 'U_SWITCH_PERMISSIONS' => ($auth->acl_get('a_switchperm') && $user->data['user_id'] != $user_id) ? append_sid("{$phpbb_root_path}ucp.$phpEx", "mode=switch_perm&u={$user_id}&hash=" . generate_link_hash('switchperm')) : '', - 'U_EDIT_SELF' => ($user_id == $user->data['user_id'] && $auth->acl_get('u_chgprofileinfo')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=ucp_profile&mode=profile_info') : '', - - 'S_USER_NOTES' => ($user_notes_enabled) ? true : false, - 'S_WARN_USER' => ($warn_user_enabled) ? true : false, - 'S_ZEBRA' => ($user->data['user_id'] != $user_id && $user->data['is_registered'] && $zebra_enabled) ? true : false, - 'U_ADD_FRIEND' => (!$friend && !$foe && $friends_enabled) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&add=' . urlencode(htmlspecialchars_decode($member['username']))) : '', - 'U_ADD_FOE' => (!$friend && !$foe && $foes_enabled) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&mode=foes&add=' . urlencode(htmlspecialchars_decode($member['username']))) : '', - 'U_REMOVE_FRIEND' => ($friend && $friends_enabled) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&remove=1&usernames[]=' . $user_id) : '', - 'U_REMOVE_FOE' => ($foe && $foes_enabled) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&remove=1&mode=foes&usernames[]=' . $user_id) : '', - - 'U_CANONICAL' => generate_board_url() . '/' . append_sid("memberlist.$phpEx", 'mode=viewprofile&u=' . $user_id, true, ''), - ); - - /** - * Modify user's template vars before we display the profile - * - * @event core.memberlist_modify_view_profile_template_vars - * @var array template_ary Array with user's template vars - * @since 3.2.6-RC1 - */ - $vars = array( - 'template_ary', - ); - extract($phpbb_dispatcher->trigger_event('core.memberlist_modify_view_profile_template_vars', compact($vars))); - - // Assign vars to memberlist_view.html - $template->assign_vars($template_ary); - - if (!empty($profile_fields['row'])) - { - $template->assign_vars($profile_fields['row']); - } - - if (!empty($profile_fields['blockrow'])) - { - foreach ($profile_fields['blockrow'] as $field_data) - { - $template->assign_block_vars('custom_fields', $field_data); - } - } - - // Inactive reason/account? - if ($member['user_type'] == USER_INACTIVE) - { - $user->add_lang('acp/common'); - - $inactive_reason = $user->lang['INACTIVE_REASON_UNKNOWN']; - - switch ($member['user_inactive_reason']) - { - case INACTIVE_REGISTER: - $inactive_reason = $user->lang['INACTIVE_REASON_REGISTER']; - break; - - case INACTIVE_PROFILE: - $inactive_reason = $user->lang['INACTIVE_REASON_PROFILE']; - break; - - case INACTIVE_MANUAL: - $inactive_reason = $user->lang['INACTIVE_REASON_MANUAL']; - break; - - case INACTIVE_REMIND: - $inactive_reason = $user->lang['INACTIVE_REASON_REMIND']; - break; - } - - $template->assign_vars(array( - 'S_USER_INACTIVE' => true, - 'USER_INACTIVE_REASON' => $inactive_reason) - ); - } - - // Now generate page title - $page_title = sprintf($user->lang['VIEWING_PROFILE'], $member['username']); - $template_html = 'memberlist_view.html'; - - $template->assign_block_vars('navlinks', array( - 'BREADCRUMB_NAME' => $user->lang('MEMBERLIST'), - 'U_BREADCRUMB' => append_sid("{$phpbb_root_path}memberlist.$phpEx"), - )); - $template->assign_block_vars('navlinks', array( - 'BREADCRUMB_NAME' => $member['username'], - 'U_BREADCRUMB' => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=viewprofile&u=$user_id"), - )); - - break; - - case 'contactadmin': - case 'email': - if (!class_exists('messenger')) - { - include($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); - } - - $user_id = $request->variable('u', 0); - $topic_id = $request->variable('t', 0); - - if ($user_id) - { - $form_name = 'user'; - } - else if ($topic_id) - { - $form_name = 'topic'; - } - else if ($mode === 'contactadmin') - { - $form_name = 'admin'; - } - else - { - trigger_error('NO_EMAIL'); - } - - /** @var $form \phpbb\message\form */ - $form = $phpbb_container->get('message.form.' . $form_name); - - $form->bind($request); - $error = $form->check_allow(); - if ($error) - { - trigger_error($error); - } - - if ($request->is_set_post('submit')) - { - $messenger = new messenger(false); - $form->submit($messenger); - } - - $page_title = $form->get_page_title(); - $template_html = $form->get_template_file(); - $form->render($template); - - if ($user_id) - { - $navlink_name = $user->lang('SEND_EMAIL'); - $navlink_url = append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=email&u=$user_id"); - } - else if ($topic_id) - { - $sql = 'SELECT f.parent_id, f.forum_parents, f.left_id, f.right_id, f.forum_type, f.forum_name, f.forum_id, f.forum_desc, f.forum_desc_uid, f.forum_desc_bitfield, f.forum_desc_options, f.forum_options, t.topic_title - FROM ' . FORUMS_TABLE . ' as f, - ' . TOPICS_TABLE . ' as t - WHERE t.forum_id = f.forum_id'; - $result = $db->sql_query($sql); - $topic_data = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - generate_forum_nav($topic_data); - $template->assign_block_vars('navlinks', array( - 'BREADCRUMB_NAME' => $topic_data['topic_title'], - 'U_BREADCRUMB' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t=$topic_id"), - )); - - $navlink_name = $user->lang('EMAIL_TOPIC'); - $navlink_url = append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=email&t=$topic_id"); - } - else if ($mode === 'contactadmin') - { - $navlink_name = $user->lang('CONTACT_ADMIN'); - $navlink_url = append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contactadmin"); - } - - $template->assign_block_vars('navlinks', array( - 'BREADCRUMB_NAME' => $navlink_name, - 'U_BREADCRUMB' => $navlink_url, - )); - - break; - - case 'livesearch': - - $username_chars = $request->variable('username', '', true); - - $sql = 'SELECT username, user_id, user_colour - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('user_type', $user_types) . ' - AND username_clean ' . $db->sql_like_expression(utf8_clean_string($username_chars) . $db->get_any_char()); - $result = $db->sql_query_limit($sql, 10); - $user_list = array(); - - while ($row = $db->sql_fetchrow($result)) - { - $user_list[] = array( - 'user_id' => (int) $row['user_id'], - 'result' => $row['username'], - 'username_full' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), - 'display' => get_username_string('no_profile', $row['user_id'], $row['username'], $row['user_colour']), - ); - } - $db->sql_freeresult($result); - $json_response = new \phpbb\json_response(); - $json_response->send(array( - 'keyword' => $username_chars, - 'results' => $user_list, - )); - - break; - - case 'group': - default: - // The basic memberlist - $page_title = $user->lang['MEMBERLIST']; - $template_html = 'memberlist_body.html'; - - $template->assign_block_vars('navlinks', array( - 'BREADCRUMB_NAME' => $page_title, - 'U_BREADCRUMB' => append_sid("{$phpbb_root_path}memberlist.$phpEx"), - )); - - /* @var $pagination \phpbb\pagination */ - $pagination = $phpbb_container->get('pagination'); - - // Sorting - $sort_key_text = array('a' => $user->lang['SORT_USERNAME'], 'c' => $user->lang['SORT_JOINED'], 'd' => $user->lang['SORT_POST_COUNT']); - $sort_key_sql = array('a' => 'u.username_clean', 'c' => 'u.user_regdate', 'd' => 'u.user_posts'); - - if ($config['jab_enable']) - { - $sort_key_text['k'] = $user->lang['JABBER']; - $sort_key_sql['k'] = 'u.user_jabber'; - } - - if ($auth->acl_get('a_user')) - { - $sort_key_text['e'] = $user->lang['SORT_EMAIL']; - $sort_key_sql['e'] = 'u.user_email'; - } - - if ($auth->acl_get('u_viewonline')) - { - $sort_key_text['l'] = $user->lang['SORT_LAST_ACTIVE']; - $sort_key_sql['l'] = 'u.user_lastvisit'; - } - - $sort_key_text['m'] = $user->lang['SORT_RANK']; - $sort_key_sql['m'] = 'u.user_rank'; - - $sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']); - - $s_sort_key = ''; - foreach ($sort_key_text as $key => $value) - { - $selected = ($sort_key == $key) ? ' selected="selected"' : ''; - $s_sort_key .= ''; - } - - $s_sort_dir = ''; - foreach ($sort_dir_text as $key => $value) - { - $selected = ($sort_dir == $key) ? ' selected="selected"' : ''; - $s_sort_dir .= ''; - } - - // Additional sorting options for user search ... if search is enabled, if not - // then only admins can make use of this (for ACP functionality) - $sql_select = $sql_where_data = $sql_from = $sql_where = $order_by = ''; - - - $form = $request->variable('form', ''); - $field = $request->variable('field', ''); - $select_single = $request->variable('select_single', false); - - // Search URL parameters, if any of these are in the URL we do a search - $search_params = array('username', 'email', 'jabber', 'search_group_id', 'joined_select', 'active_select', 'count_select', 'joined', 'active', 'count', 'ip'); - - // We validate form and field here, only id/class allowed - $form = (!preg_match('/^[a-z0-9_-]+$/i', $form)) ? '' : $form; - $field = (!preg_match('/^[a-z0-9_-]+$/i', $field)) ? '' : $field; - if ((($mode == '' || $mode == 'searchuser') || count(array_intersect($request->variable_names(\phpbb\request\request_interface::GET), $search_params)) > 0) && ($config['load_search'] || $auth->acl_get('a_'))) - { - $username = $request->variable('username', '', true); - $email = strtolower($request->variable('email', '')); - $jabber = $request->variable('jabber', ''); - $search_group_id = $request->variable('search_group_id', 0); - - // when using these, make sure that we actually have values defined in $find_key_match - $joined_select = $request->variable('joined_select', 'lt'); - $active_select = $request->variable('active_select', 'lt'); - $count_select = $request->variable('count_select', 'eq'); - - $joined = explode('-', $request->variable('joined', '')); - $active = explode('-', $request->variable('active', '')); - $count = ($request->variable('count', '') !== '') ? $request->variable('count', 0) : ''; - $ipdomain = $request->variable('ip', ''); - - $find_key_match = array('lt' => '<', 'gt' => '>', 'eq' => '='); - - $find_count = array('lt' => $user->lang['LESS_THAN'], 'eq' => $user->lang['EQUAL_TO'], 'gt' => $user->lang['MORE_THAN']); - $s_find_count = ''; - foreach ($find_count as $key => $value) - { - $selected = ($count_select == $key) ? ' selected="selected"' : ''; - $s_find_count .= ''; - } - - $find_time = array('lt' => $user->lang['BEFORE'], 'gt' => $user->lang['AFTER']); - $s_find_join_time = ''; - foreach ($find_time as $key => $value) - { - $selected = ($joined_select == $key) ? ' selected="selected"' : ''; - $s_find_join_time .= ''; - } - - $s_find_active_time = ''; - foreach ($find_time as $key => $value) - { - $selected = ($active_select == $key) ? ' selected="selected"' : ''; - $s_find_active_time .= ''; - } - - $sql_where .= ($username) ? ' AND u.username_clean ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), utf8_clean_string($username))) : ''; - $sql_where .= ($auth->acl_get('a_user') && $email) ? ' AND u.user_email ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), $email)) . ' ' : ''; - $sql_where .= ($jabber) ? ' AND u.user_jabber ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), $jabber)) . ' ' : ''; - $sql_where .= (is_numeric($count) && isset($find_key_match[$count_select])) ? ' AND u.user_posts ' . $find_key_match[$count_select] . ' ' . (int) $count . ' ' : ''; - - if (isset($find_key_match[$joined_select]) && count($joined) == 3) - { - $joined_time = gmmktime(0, 0, 0, (int) $joined[1], (int) $joined[2], (int) $joined[0]); - - if ($joined_time !== false) - { - $sql_where .= " AND u.user_regdate " . $find_key_match[$joined_select] . ' ' . $joined_time; - } - } - - if (isset($find_key_match[$active_select]) && count($active) == 3 && $auth->acl_get('u_viewonline')) - { - $active_time = gmmktime(0, 0, 0, (int) $active[1], (int) $active[2], (int) $active[0]); - - if ($active_time !== false) - { - if ($active_select === 'lt' && (int) $active[0] == 0 && (int) $active[1] == 0 && (int) $active[2] == 0) - { - $sql_where .= ' AND u.user_lastvisit = 0'; - } - else if ($active_select === 'gt') - { - $sql_where .= ' AND u.user_lastvisit ' . $find_key_match[$active_select] . ' ' . $active_time; - } - else - { - $sql_where .= ' AND (u.user_lastvisit > 0 AND u.user_lastvisit < ' . $active_time . ')'; - } - } - } - - $sql_where .= ($search_group_id) ? " AND u.user_id = ug.user_id AND ug.group_id = $search_group_id AND ug.user_pending = 0 " : ''; - - if ($search_group_id) - { - $sql_from = ', ' . USER_GROUP_TABLE . ' ug '; - } - - if ($ipdomain && $auth->acl_getf_global('m_info')) - { - if (strspn($ipdomain, 'abcdefghijklmnopqrstuvwxyz')) - { - $hostnames = gethostbynamel($ipdomain); - - if ($hostnames !== false) - { - $ips = "'" . implode('\', \'', array_map(array($db, 'sql_escape'), preg_replace('#([0-9]{1,3}\.[0-9]{1,3}[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})#', "\\1", gethostbynamel($ipdomain)))) . "'"; - } - else - { - $ips = false; - } - } - else - { - $ips = "'" . str_replace('*', '%', $db->sql_escape($ipdomain)) . "'"; - } - - if ($ips === false) - { - // A minor fudge but it does the job :D - $sql_where .= " AND u.user_id = 0"; - } - else - { - $ip_forums = array_keys($auth->acl_getf('m_info', true)); - - $sql = 'SELECT DISTINCT poster_id - FROM ' . POSTS_TABLE . ' - WHERE poster_ip ' . ((strpos($ips, '%') !== false) ? 'LIKE' : 'IN') . " ($ips) - AND " . $db->sql_in_set('forum_id', $ip_forums); - - /** - * Modify sql query for members search by ip address / hostname - * - * @event core.memberlist_modify_ip_search_sql_query - * @var string ipdomain The host name - * @var string ips IP address list for the given host name - * @var string sql The SQL query for searching members by IP address - * @since 3.1.7-RC1 - */ - $vars = array( - 'ipdomain', - 'ips', - 'sql', - ); - extract($phpbb_dispatcher->trigger_event('core.memberlist_modify_ip_search_sql_query', compact($vars))); - - $result = $db->sql_query($sql); - - if ($row = $db->sql_fetchrow($result)) - { - $ip_sql = array(); - do - { - $ip_sql[] = $row['poster_id']; - } - while ($row = $db->sql_fetchrow($result)); - - $sql_where .= ' AND ' . $db->sql_in_set('u.user_id', $ip_sql); - } - else - { - // A minor fudge but it does the job :D - $sql_where .= " AND u.user_id = 0"; - } - unset($ip_forums); - - $db->sql_freeresult($result); - } - } - } - - $first_char = $request->variable('first_char', ''); - - if ($first_char == 'other') - { - for ($i = 97; $i < 123; $i++) - { - $sql_where .= ' AND u.username_clean NOT ' . $db->sql_like_expression(chr($i) . $db->get_any_char()); - } - } - else if ($first_char) - { - $sql_where .= ' AND u.username_clean ' . $db->sql_like_expression(substr($first_char, 0, 1) . $db->get_any_char()); - } - - // Are we looking at a usergroup? If so, fetch additional info - // and further restrict the user info query - if ($mode == 'group') - { - // We JOIN here to save a query for determining membership for hidden groups. ;) - $sql = 'SELECT g.*, ug.user_id, ug.group_leader - FROM ' . GROUPS_TABLE . ' g - LEFT JOIN ' . USER_GROUP_TABLE . ' ug ON (ug.user_pending = 0 AND ug.user_id = ' . $user->data['user_id'] . " AND ug.group_id = $group_id) - WHERE g.group_id = $group_id"; - $result = $db->sql_query($sql); - $group_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$group_row) - { - trigger_error('NO_GROUP'); - } - - switch ($group_row['group_type']) - { - case GROUP_OPEN: - $group_row['l_group_type'] = 'OPEN'; - break; - - case GROUP_CLOSED: - $group_row['l_group_type'] = 'CLOSED'; - break; - - case GROUP_HIDDEN: - $group_row['l_group_type'] = 'HIDDEN'; - - // Check for membership or special permissions - if (!$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel') && $group_row['user_id'] != $user->data['user_id']) - { - trigger_error('NO_GROUP'); - } - break; - - case GROUP_SPECIAL: - $group_row['l_group_type'] = 'SPECIAL'; - break; - - case GROUP_FREE: - $group_row['l_group_type'] = 'FREE'; - break; - } - - $avatar_img = phpbb_get_group_avatar($group_row); - - // ... same for group rank - $group_rank_data = array( - 'title' => null, - 'img' => null, - 'img_src' => null, - ); - if ($group_row['group_rank']) - { - $group_rank_data = $group_helper->get_rank($group_row); - - if ($group_rank_data['img']) - { - $group_rank_data['img'] .= '
'; - } - } - // include modules for manage groups link display or not - // need to ensure the module is active - $can_manage_group = false; - if ($user->data['is_registered'] && $group_row['group_leader']) - { - if (!class_exists('p_master')) - { - include($phpbb_root_path . 'includes/functions_module.' . $phpEx); - } - $module = new p_master; - $module->list_modules('ucp'); - - if ($module->is_active('ucp_groups', 'manage')) - { - $can_manage_group = true; - } - unset($module); - } - - $template->assign_block_vars('navlinks', array( - 'BREADCRUMB_NAME' => $group_helper->get_name($group_row['group_name']), - 'U_BREADCRUMB' => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=group&g=$group_id"), - )); - - $template->assign_vars(array( - 'GROUP_DESC' => generate_text_for_display($group_row['group_desc'], $group_row['group_desc_uid'], $group_row['group_desc_bitfield'], $group_row['group_desc_options']), - 'GROUP_NAME' => $group_helper->get_name($group_row['group_name']), - 'GROUP_COLOR' => $group_row['group_colour'], - 'GROUP_TYPE' => $user->lang['GROUP_IS_' . $group_row['l_group_type']], - 'GROUP_RANK' => $group_rank_data['title'], - - 'AVATAR_IMG' => $avatar_img, - 'RANK_IMG' => $group_rank_data['img'], - 'RANK_IMG_SRC' => $group_rank_data['img_src'], - - 'U_PM' => ($auth->acl_get('u_sendpm') && $auth->acl_get('u_masspm_group') && $group_row['group_receive_pm'] && $config['allow_privmsg'] && $config['allow_mass_pm']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&g=' . $group_id) : '', - 'U_MANAGE' => ($can_manage_group) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=ucp_groups&mode=manage') : false,) - ); - - $sql_select = ', ug.group_leader'; - $sql_from = ', ' . USER_GROUP_TABLE . ' ug '; - $order_by = 'ug.group_leader DESC, '; - - $sql_where .= " AND ug.user_pending = 0 AND u.user_id = ug.user_id AND ug.group_id = $group_id"; - $sql_where_data = " AND u.user_id = ug.user_id AND ug.group_id = $group_id"; - } - - // Sorting and order - if (!isset($sort_key_sql[$sort_key])) - { - $sort_key = $default_key; - } - - $order_by .= $sort_key_sql[$sort_key] . ' ' . (($sort_dir == 'a') ? 'ASC' : 'DESC'); - - // Unfortunately we must do this here for sorting by rank, else the sort order is applied wrongly - if ($sort_key == 'm') - { - $order_by .= ', u.user_posts DESC'; - } - - /** - * Modify sql query data for members search - * - * @event core.memberlist_modify_sql_query_data - * @var string order_by SQL ORDER BY clause condition - * @var string sort_dir The sorting direction - * @var string sort_key The sorting key - * @var array sort_key_sql Arraty with the sorting conditions data - * @var string sql_from SQL FROM clause condition - * @var string sql_select SQL SELECT fields list - * @var string sql_where SQL WHERE clause condition - * @var string sql_where_data SQL WHERE clause additional conditions data - * @since 3.1.7-RC1 - */ - $vars = array( - 'order_by', - 'sort_dir', - 'sort_key', - 'sort_key_sql', - 'sql_from', - 'sql_select', - 'sql_where', - 'sql_where_data', - ); - extract($phpbb_dispatcher->trigger_event('core.memberlist_modify_sql_query_data', compact($vars))); - - // Count the users ... - $sql = 'SELECT COUNT(u.user_id) AS total_users - FROM ' . USERS_TABLE . " u$sql_from - WHERE " . $db->sql_in_set('u.user_type', $user_types) . " - $sql_where"; - $result = $db->sql_query($sql); - $total_users = (int) $db->sql_fetchfield('total_users'); - $db->sql_freeresult($result); - - // Build a relevant pagination_url - $params = $sort_params = array(); - - // We do not use $request->variable() here directly to save some calls (not all variables are set) - $check_params = array( - 'g' => array('g', 0), - 'sk' => array('sk', $default_key), - 'sd' => array('sd', 'a'), - 'form' => array('form', ''), - 'field' => array('field', ''), - 'select_single' => array('select_single', $select_single), - 'username' => array('username', '', true), - 'email' => array('email', ''), - 'jabber' => array('jabber', ''), - 'search_group_id' => array('search_group_id', 0), - 'joined_select' => array('joined_select', 'lt'), - 'active_select' => array('active_select', 'lt'), - 'count_select' => array('count_select', 'eq'), - 'joined' => array('joined', ''), - 'active' => array('active', ''), - 'count' => ($request->variable('count', '') !== '') ? array('count', 0) : array('count', ''), - 'ip' => array('ip', ''), - 'first_char' => array('first_char', ''), - ); - - $u_first_char_params = array(); - foreach ($check_params as $key => $call) - { - if (!isset($_REQUEST[$key])) - { - continue; - } - - $param = call_user_func_array(array($request, 'variable'), $call); - // Encode strings, convert everything else to int in order to prevent empty parameters. - $param = urlencode($key) . '=' . ((is_string($param)) ? urlencode($param) : (int) $param); - $params[] = $param; - - if ($key != 'first_char') - { - $u_first_char_params[] = $param; - } - if ($key != 'sk' && $key != 'sd') - { - $sort_params[] = $param; - } - } - - $u_hide_find_member = append_sid("{$phpbb_root_path}memberlist.$phpEx", "start=$start" . (!empty($params) ? '&' . implode('&', $params) : '')); - - if ($mode) - { - $params[] = "mode=$mode"; - $u_first_char_params[] = "mode=$mode"; - } - $sort_params[] = "mode=$mode"; - - $u_first_char_params = implode('&', $u_first_char_params); - $u_first_char_params .= ($u_first_char_params) ? '&' : ''; - - $first_characters = array(); - $first_characters[''] = $user->lang['ALL']; - for ($i = 97; $i < 123; $i++) - { - $first_characters[chr($i)] = chr($i - 32); - } - $first_characters['other'] = $user->lang['OTHER']; - - $first_char_block_vars = []; - - foreach ($first_characters as $char => $desc) - { - $first_char_block_vars[] = [ - 'DESC' => $desc, - 'VALUE' => $char, - 'S_SELECTED' => ($first_char == $char) ? true : false, - 'U_SORT' => append_sid("{$phpbb_root_path}memberlist.$phpEx", $u_first_char_params . 'first_char=' . $char) . '#memberlist', - ]; - } - - /** - * Modify memberlist sort and pagination parameters - * - * @event core.memberlist_modify_sort_pagination_params - * @var array sort_params Array with URL parameters for sorting - * @var array params Array with URL parameters for pagination - * @var array first_characters Array that maps each letter in a-z, 'other' and the empty string to their display representation - * @var string u_first_char_params Concatenated URL parameters for first character search links - * @var array first_char_block_vars Template block variables for each first character - * @var int total_users Total number of users found in this search - * @since 3.2.6-RC1 - */ - $vars = [ - 'sort_params', - 'params', - 'first_characters', - 'u_first_char_params', - 'first_char_block_vars', - 'total_users', - ]; - extract($phpbb_dispatcher->trigger_event('core.memberlist_modify_sort_pagination_params', compact($vars))); - - $template->assign_block_vars_array('first_char', $first_char_block_vars); - - $pagination_url = append_sid("{$phpbb_root_path}memberlist.$phpEx", implode('&', $params)); - $sort_url = append_sid("{$phpbb_root_path}memberlist.$phpEx", implode('&', $sort_params)); - - unset($search_params, $sort_params); - - // Some search user specific data - if (($mode == '' || $mode == 'searchuser') && ($config['load_search'] || $auth->acl_get('a_'))) - { - $group_selected = $request->variable('search_group_id', 0); - $s_group_select = ''; - $group_ids = array(); - - /** - * @todo add this to a separate function (function is responsible for returning the groups the user is able to see based on the users group membership) - */ - - if ($auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) - { - $sql = 'SELECT group_id, group_name, group_type - FROM ' . GROUPS_TABLE; - - if (!$config['coppa_enable']) - { - $sql .= " WHERE group_name <> 'REGISTERED_COPPA'"; - } - - $sql .= ' ORDER BY group_name ASC'; - } - else - { - $sql = 'SELECT g.group_id, g.group_name, g.group_type - FROM ' . GROUPS_TABLE . ' g - LEFT JOIN ' . USER_GROUP_TABLE . ' ug - ON ( - g.group_id = ug.group_id - AND ug.user_id = ' . $user->data['user_id'] . ' - AND ug.user_pending = 0 - ) - WHERE (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $user->data['user_id'] . ')'; - - if (!$config['coppa_enable']) - { - $sql .= " AND g.group_name <> 'REGISTERED_COPPA'"; - } - - $sql .= ' ORDER BY g.group_name ASC'; - } - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $group_ids[] = $row['group_id']; - $s_group_select .= ''; - } - $db->sql_freeresult($result); - - if ($group_selected !== 0 && !in_array($group_selected, $group_ids)) - { - trigger_error('NO_GROUP'); - } - - $template->assign_vars(array( - 'USERNAME' => $username, - 'EMAIL' => $email, - 'JABBER' => $jabber, - 'JOINED' => implode('-', $joined), - 'ACTIVE' => implode('-', $active), - 'COUNT' => $count, - 'IP' => $ipdomain, - - 'S_IP_SEARCH_ALLOWED' => ($auth->acl_getf_global('m_info')) ? true : false, - 'S_EMAIL_SEARCH_ALLOWED'=> ($auth->acl_get('a_user')) ? true : false, - 'S_JABBER_ENABLED' => $config['jab_enable'], - 'S_IN_SEARCH_POPUP' => ($form && $field) ? true : false, - 'S_SEARCH_USER' => ($mode == 'searchuser' || ($mode == '' && $submit)), - 'S_FORM_NAME' => $form, - 'S_FIELD_NAME' => $field, - 'S_SELECT_SINGLE' => $select_single, - 'S_COUNT_OPTIONS' => $s_find_count, - 'S_SORT_OPTIONS' => $s_sort_key, - 'S_JOINED_TIME_OPTIONS' => $s_find_join_time, - 'S_ACTIVE_TIME_OPTIONS' => $s_find_active_time, - 'S_GROUP_SELECT' => $s_group_select, - 'S_USER_SEARCH_ACTION' => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=searchuser&form=$form&field=$field")) - ); - } - - $start = $pagination->validate_start($start, $config['topics_per_page'], $total_users); - - // Get us some users :D - $sql = "SELECT u.user_id - FROM " . USERS_TABLE . " u - $sql_from - WHERE " . $db->sql_in_set('u.user_type', $user_types) . " - $sql_where - ORDER BY $order_by"; - $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); - - $user_list = array(); - while ($row = $db->sql_fetchrow($result)) - { - $user_list[] = (int) $row['user_id']; - } - $db->sql_freeresult($result); - - // Load custom profile fields - if ($config['load_cpf_memberlist']) - { - /* @var $cp \phpbb\profilefields\manager */ - $cp = $phpbb_container->get('profilefields.manager'); - - $cp_row = $cp->generate_profile_fields_template_headlines('field_show_on_ml'); - foreach ($cp_row as $profile_field) - { - $template->assign_block_vars('custom_fields', $profile_field); - } - } - - $leaders_set = false; - // So, did we get any users? - if (count($user_list)) - { - // Session time?! Session time... - $sql = 'SELECT session_user_id, MAX(session_time) AS session_time - FROM ' . SESSIONS_TABLE . ' - WHERE session_time >= ' . (time() - $config['session_length']) . ' - AND ' . $db->sql_in_set('session_user_id', $user_list) . ' - GROUP BY session_user_id'; - $result = $db->sql_query($sql); - - $session_times = array(); - while ($row = $db->sql_fetchrow($result)) - { - $session_times[$row['session_user_id']] = $row['session_time']; - } - $db->sql_freeresult($result); - - // Do the SQL thang - if ($mode == 'group') - { - $sql_from_ary = explode(',', $sql_from); - $extra_tables = []; - foreach ($sql_from_ary as $entry) - { - $table_data = explode(' ', trim($entry)); - - if (empty($table_data[0]) || empty($table_data[1])) - { - continue; - } - - $extra_tables[$table_data[0]] = $table_data[1]; - } - - $sql_array = array( - 'SELECT' => 'u.*' . $sql_select, - 'FROM' => array_merge([USERS_TABLE => 'u'], $extra_tables), - 'WHERE' => $db->sql_in_set('u.user_id', $user_list) . $sql_where_data . '', - ); - } - else - { - $sql_array = array( - 'SELECT' => 'u.*', - 'FROM' => array( - USERS_TABLE => 'u' - ), - 'WHERE' => $db->sql_in_set('u.user_id', $user_list), - ); - } - - /** - * Modify user data SQL before member row is created - * - * @event core.memberlist_modify_memberrow_sql - * @var string mode Memberlist mode - * @var string sql_select Additional select statement - * @var string sql_from Additional from statement - * @var array sql_array Array containing the main query - * @var array user_list Array containing list of users - * @since 3.2.6-RC1 - */ - $vars = array( - 'mode', - 'sql_select', - 'sql_from', - 'sql_array', - 'user_list', - ); - extract($phpbb_dispatcher->trigger_event('core.memberlist_modify_memberrow_sql', compact($vars))); - - $sql = $db->sql_build_query('SELECT', $sql_array); - $result = $db->sql_query($sql); - - $id_cache = array(); - while ($row = $db->sql_fetchrow($result)) - { - $row['session_time'] = (!empty($session_times[$row['user_id']])) ? $session_times[$row['user_id']] : 0; - $row['last_visit'] = (!empty($row['session_time'])) ? $row['session_time'] : $row['user_lastvisit']; - - $id_cache[$row['user_id']] = $row; - } - - $db->sql_freeresult($result); - - // Load custom profile fields if required - if ($config['load_cpf_memberlist']) - { - // Grab all profile fields from users in id cache for later use - similar to the poster cache - $profile_fields_cache = $cp->grab_profile_fields_data($user_list); - - // Filter the fields we don't want to show - foreach ($profile_fields_cache as $user_id => $user_profile_fields) - { - foreach ($user_profile_fields as $field_ident => $profile_field) - { - if (!$profile_field['data']['field_show_on_ml']) - { - unset($profile_fields_cache[$user_id][$field_ident]); - } - } - } - } - - // If we sort by last active date we need to adjust the id cache due to user_lastvisit not being the last active date... - if ($sort_key == 'l') - { -// uasort($id_cache, create_function('$first, $second', "return (\$first['last_visit'] == \$second['last_visit']) ? 0 : ((\$first['last_visit'] < \$second['last_visit']) ? $lesser_than : ($lesser_than * -1));")); - usort($user_list, 'phpbb_sort_last_active'); - } - - // do we need to display contact fields as such - $use_contact_fields = true; - - /** - * Modify list of users before member row is created - * - * @event core.memberlist_memberrow_before - * @var array user_list Array containing list of users - * @var bool use_contact_fields Should we display contact fields as such? - * @since 3.1.7-RC1 - */ - $vars = array('user_list', 'use_contact_fields'); - extract($phpbb_dispatcher->trigger_event('core.memberlist_memberrow_before', compact($vars))); - - for ($i = 0, $end = count($user_list); $i < $end; ++$i) - { - $user_id = $user_list[$i]; - $row = $id_cache[$user_id]; - $is_leader = (isset($row['group_leader']) && $row['group_leader']) ? true : false; - $leaders_set = ($leaders_set || $is_leader); - - $cp_row = array(); - if ($config['load_cpf_memberlist']) - { - $cp_row = (isset($profile_fields_cache[$user_id])) ? $cp->generate_profile_fields_template_data($profile_fields_cache[$user_id], $use_contact_fields) : array(); - } - - $memberrow = array_merge(phpbb_show_profile($row, false, false, false), array( - 'ROW_NUMBER' => $i + ($start + 1), - - 'S_CUSTOM_PROFILE' => (isset($cp_row['row']) && count($cp_row['row'])) ? true : false, - 'S_GROUP_LEADER' => $is_leader, - 'S_INACTIVE' => $row['user_type'] == USER_INACTIVE, - - 'U_VIEW_PROFILE' => get_username_string('profile', $user_id, $row['username']), - )); - - if (isset($cp_row['row']) && count($cp_row['row'])) - { - $memberrow = array_merge($memberrow, $cp_row['row']); - } - - $template->assign_block_vars('memberrow', $memberrow); - - if (isset($cp_row['blockrow']) && count($cp_row['blockrow'])) - { - foreach ($cp_row['blockrow'] as $field_data) - { - $template->assign_block_vars('memberrow.custom_fields', $field_data); - } - } - - unset($id_cache[$user_id]); - } - } - - $pagination->generate_template_pagination($pagination_url, 'pagination', 'start', $total_users, $config['topics_per_page'], $start); - - // Generate page - $template_vars = array( - 'TOTAL_USERS' => $user->lang('LIST_USERS', (int) $total_users), - - 'PROFILE_IMG' => $user->img('icon_user_profile', $user->lang['PROFILE']), - 'PM_IMG' => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE']), - 'EMAIL_IMG' => $user->img('icon_contact_email', $user->lang['EMAIL']), - 'JABBER_IMG' => $user->img('icon_contact_jabber', $user->lang['JABBER']), - 'SEARCH_IMG' => $user->img('icon_user_search', $user->lang['SEARCH']), - - 'U_FIND_MEMBER' => ($config['load_search'] || $auth->acl_get('a_')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser' . (($start) ? "&start=$start" : '') . (!empty($params) ? '&' . implode('&', $params) : '')) : '', - 'U_HIDE_FIND_MEMBER' => ($mode == 'searchuser' || ($mode == '' && $submit)) ? $u_hide_find_member : '', - 'U_LIVE_SEARCH' => ($config['allow_live_searches']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=livesearch') : false, - 'U_SORT_USERNAME' => $sort_url . '&sk=a&sd=' . (($sort_key == 'a' && $sort_dir == 'a') ? 'd' : 'a'), - 'U_SORT_JOINED' => $sort_url . '&sk=c&sd=' . (($sort_key == 'c' && $sort_dir == 'd') ? 'a' : 'd'), - 'U_SORT_POSTS' => $sort_url . '&sk=d&sd=' . (($sort_key == 'd' && $sort_dir == 'd') ? 'a' : 'd'), - 'U_SORT_EMAIL' => $sort_url . '&sk=e&sd=' . (($sort_key == 'e' && $sort_dir == 'd') ? 'a' : 'd'), - 'U_SORT_ACTIVE' => ($auth->acl_get('u_viewonline')) ? $sort_url . '&sk=l&sd=' . (($sort_key == 'l' && $sort_dir == 'd') ? 'a' : 'd') : '', - 'U_SORT_RANK' => $sort_url . '&sk=m&sd=' . (($sort_key == 'm' && $sort_dir == 'd') ? 'a' : 'd'), - 'U_LIST_CHAR' => $sort_url . '&sk=a&sd=' . (($sort_key == 'l' && $sort_dir == 'd') ? 'a' : 'd'), - - 'S_SHOW_GROUP' => ($mode == 'group') ? true : false, - 'S_VIEWONLINE' => $auth->acl_get('u_viewonline'), - 'S_LEADERS_SET' => $leaders_set, - 'S_MODE_SELECT' => $s_sort_key, - 'S_ORDER_SELECT' => $s_sort_dir, - 'S_MODE_ACTION' => $pagination_url, - ); - - /** - * Modify memberlist page template vars - * - * @event core.memberlist_modify_template_vars - * @var array params Array containing URL parameters - * @var string sort_url Sorting URL base - * @var array template_vars Array containing template vars - * @since 3.2.2-RC1 - */ - $vars = array('params', 'sort_url', 'template_vars'); - extract($phpbb_dispatcher->trigger_event('core.memberlist_modify_template_vars', compact($vars))); - - $template->assign_vars($template_vars); -} - -// Output the page -page_header($page_title); - -$template->set_filenames(array( - 'body' => $template_html) -); -make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx")); - -page_footer(); diff --git a/install/update/new/phpbb/auth/provider/apache.php b/install/update/new/phpbb/auth/provider/apache.php deleted file mode 100644 index a713674..0000000 --- a/install/update/new/phpbb/auth/provider/apache.php +++ /dev/null @@ -1,285 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\auth\provider; - -use phpbb\config\config; -use phpbb\db\driver\driver_interface; -use phpbb\language\language; -use phpbb\request\request_interface; -use phpbb\request\type_cast_helper; -use phpbb\user; - -/** -* Apache authentication provider for phpBB3 -*/ -class apache extends base -{ - /** @var config phpBB config */ - protected $config; - - /** @var driver_interface Database object */ - protected $db; - - /** @var language Language object */ - protected $language; - - /** @var request_interface Request object */ - protected $request; - - /** @var user User object */ - protected $user; - - /** @var string Relative path to phpBB root */ - protected $phpbb_root_path; - - /** @var string PHP file extension */ - protected $php_ext; - - /** - * Apache Authentication Constructor - * - * @param config $config Config object - * @param driver_interface $db Database object - * @param language $language Language object - * @param request_interface $request Request object - * @param user $user User object - * @param string $phpbb_root_path Relative path to phpBB root - * @param string $php_ext PHP file extension - */ - public function __construct(config $config, driver_interface $db, language $language, request_interface $request, user $user, $phpbb_root_path, $php_ext) - { - $this->config = $config; - $this->db = $db; - $this->language = $language; - $this->request = $request; - $this->user = $user; - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - } - - /** - * {@inheritdoc} - */ - public function init() - { - if (!$this->request->is_set('PHP_AUTH_USER', request_interface::SERVER) || $this->user->data['username'] !== htmlspecialchars_decode($this->request->server('PHP_AUTH_USER'))) - { - return $this->language->lang('APACHE_SETUP_BEFORE_USE'); - } - return false; - } - - /** - * {@inheritdoc} - */ - public function login($username, $password) - { - // do not allow empty password - if (!$password) - { - return array( - 'status' => LOGIN_ERROR_PASSWORD, - 'error_msg' => 'NO_PASSWORD_SUPPLIED', - 'user_row' => array('user_id' => ANONYMOUS), - ); - } - - if (!$username) - { - return array( - 'status' => LOGIN_ERROR_USERNAME, - 'error_msg' => 'LOGIN_ERROR_USERNAME', - 'user_row' => array('user_id' => ANONYMOUS), - ); - } - - if (!$this->request->is_set('PHP_AUTH_USER', request_interface::SERVER)) - { - return array( - 'status' => LOGIN_ERROR_EXTERNAL_AUTH, - 'error_msg' => 'LOGIN_ERROR_EXTERNAL_AUTH_APACHE', - 'user_row' => array('user_id' => ANONYMOUS), - ); - } - - $php_auth_user = htmlspecialchars_decode($this->request->server('PHP_AUTH_USER')); - $php_auth_pw = htmlspecialchars_decode($this->request->server('PHP_AUTH_PW')); - - if (!empty($php_auth_user) && !empty($php_auth_pw)) - { - if ($php_auth_user !== $username) - { - return array( - 'status' => LOGIN_ERROR_USERNAME, - 'error_msg' => 'LOGIN_ERROR_USERNAME', - 'user_row' => array('user_id' => ANONYMOUS), - ); - } - - $sql = 'SELECT user_id, username, user_password, user_passchg, user_email, user_type - FROM ' . USERS_TABLE . " - WHERE username = '" . $this->db->sql_escape($php_auth_user) . "'"; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if ($row) - { - // User inactive... - if ($row['user_type'] == USER_INACTIVE || $row['user_type'] == USER_IGNORE) - { - return array( - 'status' => LOGIN_ERROR_ACTIVE, - 'error_msg' => 'ACTIVE_ERROR', - 'user_row' => $row, - ); - } - - // Successful login... - return array( - 'status' => LOGIN_SUCCESS, - 'error_msg' => false, - 'user_row' => $row, - ); - } - - // this is the user's first login so create an empty profile - return array( - 'status' => LOGIN_SUCCESS_CREATE_PROFILE, - 'error_msg' => false, - 'user_row' => $this->user_row($php_auth_user), - ); - } - - // Not logged into apache - return array( - 'status' => LOGIN_ERROR_EXTERNAL_AUTH, - 'error_msg' => 'LOGIN_ERROR_EXTERNAL_AUTH_APACHE', - 'user_row' => array('user_id' => ANONYMOUS), - ); - } - - /** - * {@inheritdoc} - */ - public function autologin() - { - if (!$this->request->is_set('PHP_AUTH_USER', request_interface::SERVER)) - { - return array(); - } - - $php_auth_user = htmlspecialchars_decode($this->request->server('PHP_AUTH_USER')); - $php_auth_pw = htmlspecialchars_decode($this->request->server('PHP_AUTH_PW')); - - if (!empty($php_auth_user) && !empty($php_auth_pw)) - { - $type_cast_helper = new type_cast_helper(); - $type_cast_helper->set_var($php_auth_user, $php_auth_user, 'string', true); - - $sql = 'SELECT * - FROM ' . USERS_TABLE . " - WHERE username = '" . $this->db->sql_escape($php_auth_user) . "'"; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if ($row) - { - return ($row['user_type'] == USER_INACTIVE || $row['user_type'] == USER_IGNORE) ? array() : $row; - } - - if (!function_exists('user_add')) - { - include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext); - } - - // create the user if he does not exist yet - user_add($this->user_row($php_auth_user)); - - $sql = 'SELECT * - FROM ' . USERS_TABLE . " - WHERE username_clean = '" . $this->db->sql_escape(utf8_clean_string($php_auth_user)) . "'"; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if ($row) - { - return $row; - } - } - - return array(); - } - - /** - * This function generates an array which can be passed to the user_add - * function in order to create a user - * - * @param string $username The username of the new user. - * - * @return array Contains data that can be passed directly to - * the user_add function. - */ - private function user_row($username) - { - // first retrieve default group id - $sql = 'SELECT group_id - FROM ' . GROUPS_TABLE . " - WHERE group_name = '" . $this->db->sql_escape('REGISTERED') . "' - AND group_type = " . GROUP_SPECIAL; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if (!$row) - { - trigger_error('NO_GROUP'); - } - - // generate user account data - return array( - 'username' => $username, - 'user_password' => '', - 'user_email' => '', - 'group_id' => (int) $row['group_id'], - 'user_type' => USER_NORMAL, - 'user_ip' => $this->user->ip, - 'user_new' => ($this->config['new_member_post_limit']) ? 1 : 0, - ); - } - - /** - * {@inheritdoc} - */ - public function validate_session($user) - { - // Check if PHP_AUTH_USER is set and handle this case - if ($this->request->is_set('PHP_AUTH_USER', request_interface::SERVER)) - { - $php_auth_user = $this->request->server('PHP_AUTH_USER'); - - return ($php_auth_user === $user['username']) ? true : false; - } - - // PHP_AUTH_USER is not set. A valid session is now determined by the user type (anonymous/bot or not) - if ($user['user_type'] == USER_IGNORE) - { - return true; - } - - return false; - } -} diff --git a/install/update/new/phpbb/auth/provider/base.php b/install/update/new/phpbb/auth/provider/base.php deleted file mode 100644 index 30e0a0f..0000000 --- a/install/update/new/phpbb/auth/provider/base.php +++ /dev/null @@ -1,108 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\auth\provider; - -/** -* Base authentication provider class that all other providers should implement -*/ -abstract class base implements provider_interface -{ - /** - * {@inheritdoc} - */ - public function init() - { - return; - } - - /** - * {@inheritdoc} - */ - public function autologin() - { - return; - } - - /** - * {@inheritdoc} - */ - public function acp() - { - return; - } - - /** - * {@inheritdoc} - */ - public function get_acp_template($new_config) - { - return; - } - - /** - * {@inheritdoc} - */ - public function get_login_data() - { - return; - } - - /** - * {@inheritdoc} - */ - public function get_auth_link_data($user_id = 0) - { - return; - } - - /** - * {@inheritdoc} - */ - public function logout($data, $new_session) - { - return; - } - - /** - * {@inheritdoc} - */ - public function validate_session($user) - { - return; - } - - /** - * {@inheritdoc} - */ - public function login_link_has_necessary_data($login_link_data) - { - return; - } - - /** - * {@inheritdoc} - */ - public function link_account(array $link_data) - { - return; - } - - /** - * {@inheritdoc} - */ - public function unlink_account(array $link_data) - { - return; - } -} diff --git a/install/update/new/phpbb/auth/provider/db.php b/install/update/new/phpbb/auth/provider/db.php deleted file mode 100644 index a70734f..0000000 --- a/install/update/new/phpbb/auth/provider/db.php +++ /dev/null @@ -1,259 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\auth\provider; - -use phpbb\captcha\factory; -use phpbb\config\config; -use phpbb\db\driver\driver_interface; -use phpbb\passwords\manager; -use phpbb\request\request_interface; -use phpbb\user; - -/** - * Database authentication provider for phpBB3 - * This is for authentication via the integrated user table - */ -class db extends base -{ - /** @var factory CAPTCHA factory */ - protected $captcha_factory; - - /** @var config phpBB config */ - protected $config; - - /** @var driver_interface DBAL driver instance */ - protected $db; - - /** @var request_interface Request object */ - protected $request; - - /** @var user User object */ - protected $user; - - /** @var string phpBB root path */ - protected $phpbb_root_path; - - /** @var string PHP file extension */ - protected $php_ext; - - /** - * phpBB passwords manager - * - * @var manager - */ - protected $passwords_manager; - - /** - * Database Authentication Constructor - * - * @param factory $captcha_factory - * @param config $config - * @param driver_interface $db - * @param manager $passwords_manager - * @param request_interface $request - * @param user $user - * @param string $phpbb_root_path - * @param string $php_ext - */ - public function __construct(factory $captcha_factory, config $config, driver_interface $db, manager $passwords_manager, request_interface $request, user $user, $phpbb_root_path, $php_ext) - { - $this->captcha_factory = $captcha_factory; - $this->config = $config; - $this->db = $db; - $this->passwords_manager = $passwords_manager; - $this->request = $request; - $this->user = $user; - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - } - - /** - * {@inheritdoc} - */ - public function login($username, $password) - { - // Auth plugins get the password untrimmed. - // For compatibility we trim() here. - $password = trim($password); - - // do not allow empty password - if (!$password) - { - return array( - 'status' => LOGIN_ERROR_PASSWORD, - 'error_msg' => 'NO_PASSWORD_SUPPLIED', - 'user_row' => array('user_id' => ANONYMOUS), - ); - } - - if (!$username) - { - return array( - 'status' => LOGIN_ERROR_USERNAME, - 'error_msg' => 'LOGIN_ERROR_USERNAME', - 'user_row' => array('user_id' => ANONYMOUS), - ); - } - - $username_clean = utf8_clean_string($username); - - $sql = 'SELECT * - FROM ' . USERS_TABLE . " - WHERE username_clean = '" . $this->db->sql_escape($username_clean) . "'"; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if (($this->user->ip && !$this->config['ip_login_limit_use_forwarded']) || - ($this->user->forwarded_for && $this->config['ip_login_limit_use_forwarded'])) - { - $sql = 'SELECT COUNT(*) AS attempts - FROM ' . LOGIN_ATTEMPT_TABLE . ' - WHERE attempt_time > ' . (time() - (int) $this->config['ip_login_limit_time']); - if ($this->config['ip_login_limit_use_forwarded']) - { - $sql .= " AND attempt_forwarded_for = '" . $this->db->sql_escape($this->user->forwarded_for) . "'"; - } - else - { - $sql .= " AND attempt_ip = '" . $this->db->sql_escape($this->user->ip) . "' "; - } - - $result = $this->db->sql_query($sql); - $attempts = (int) $this->db->sql_fetchfield('attempts'); - $this->db->sql_freeresult($result); - - $attempt_data = array( - 'attempt_ip' => $this->user->ip, - 'attempt_browser' => trim(substr($this->user->browser, 0, 149)), - 'attempt_forwarded_for' => $this->user->forwarded_for, - 'attempt_time' => time(), - 'user_id' => ($row) ? (int) $row['user_id'] : 0, - 'username' => $username, - 'username_clean' => $username_clean, - ); - $sql = 'INSERT INTO ' . LOGIN_ATTEMPT_TABLE . $this->db->sql_build_array('INSERT', $attempt_data); - $this->db->sql_query($sql); - } - else - { - $attempts = 0; - } - - if (!$row) - { - if ($this->config['ip_login_limit_max'] && $attempts >= $this->config['ip_login_limit_max']) - { - return array( - 'status' => LOGIN_ERROR_ATTEMPTS, - 'error_msg' => 'LOGIN_ERROR_ATTEMPTS', - 'user_row' => array('user_id' => ANONYMOUS), - ); - } - - return array( - 'status' => LOGIN_ERROR_USERNAME, - 'error_msg' => 'LOGIN_ERROR_USERNAME', - 'user_row' => array('user_id' => ANONYMOUS), - ); - } - - $show_captcha = ($this->config['max_login_attempts'] && $row['user_login_attempts'] >= $this->config['max_login_attempts']) || - ($this->config['ip_login_limit_max'] && $attempts >= $this->config['ip_login_limit_max']); - - // If there are too many login attempts, we need to check for a confirm image - // Every auth module is able to define what to do by itself... - if ($show_captcha) - { - $captcha = $this->captcha_factory->get_instance($this->config['captcha_plugin']); - $captcha->init(CONFIRM_LOGIN); - $vc_response = $captcha->validate($row); - if ($vc_response) - { - return array( - 'status' => LOGIN_ERROR_ATTEMPTS, - 'error_msg' => 'LOGIN_ERROR_ATTEMPTS', - 'user_row' => $row, - ); - } - else - { - $captcha->reset(); - } - - } - - // Check password ... - if ($this->passwords_manager->check($password, $row['user_password'], $row)) - { - // Check for old password hash... - if ($this->passwords_manager->convert_flag || strlen($row['user_password']) == 32) - { - $hash = $this->passwords_manager->hash($password); - - // Update the password in the users table to the new format - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_password = '" . $this->db->sql_escape($hash) . "' - WHERE user_id = {$row['user_id']}"; - $this->db->sql_query($sql); - - $row['user_password'] = $hash; - } - - $sql = 'DELETE FROM ' . LOGIN_ATTEMPT_TABLE . ' - WHERE user_id = ' . $row['user_id']; - $this->db->sql_query($sql); - - if ($row['user_login_attempts'] != 0) - { - // Successful, reset login attempts (the user passed all stages) - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_login_attempts = 0 - WHERE user_id = ' . $row['user_id']; - $this->db->sql_query($sql); - } - - // User inactive... - if ($row['user_type'] == USER_INACTIVE || $row['user_type'] == USER_IGNORE) - { - return array( - 'status' => LOGIN_ERROR_ACTIVE, - 'error_msg' => 'ACTIVE_ERROR', - 'user_row' => $row, - ); - } - - // Successful login... set user_login_attempts to zero... - return array( - 'status' => LOGIN_SUCCESS, - 'error_msg' => false, - 'user_row' => $row, - ); - } - - // Password incorrect - increase login attempts - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_login_attempts = user_login_attempts + 1 - WHERE user_id = ' . (int) $row['user_id'] . ' - AND user_login_attempts < ' . LOGIN_ATTEMPTS_MAX; - $this->db->sql_query($sql); - - // Give status about wrong password... - return array( - 'status' => ($show_captcha) ? LOGIN_ERROR_ATTEMPTS : LOGIN_ERROR_PASSWORD, - 'error_msg' => 'LOGIN_ERROR_PASSWORD', - 'user_row' => $row, - ); - } -} diff --git a/install/update/new/phpbb/auth/provider/ldap.php b/install/update/new/phpbb/auth/provider/ldap.php deleted file mode 100644 index 43699f7..0000000 --- a/install/update/new/phpbb/auth/provider/ldap.php +++ /dev/null @@ -1,359 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\auth\provider; - -use phpbb\config\config; -use phpbb\db\driver\driver_interface; -use phpbb\language\language; -use phpbb\user; - -/** - * Database authentication provider for phpBB3 - * This is for authentication via the integrated user table - */ -class ldap extends base -{ - /** @var config phpBB config */ - protected $config; - - /** @var driver_interface DBAL driver interface */ - protected $db; - - /** @var language phpBB language class */ - protected $language; - - /** @var user phpBB user */ - protected $user; - - /** - * LDAP Authentication Constructor - * - * @param config $config Config object - * @param driver_interface $db DBAL driver interface - * @param language $language Language object - * @param user $user User object - */ - public function __construct(config $config, driver_interface $db, language $language, user $user) - { - $this->config = $config; - $this->db = $db; - $this->language = $language; - $this->user = $user; - } - - /** - * {@inheritdoc} - */ - public function init() - { - if (!@extension_loaded('ldap')) - { - return $this->language->lang('LDAP_NO_LDAP_EXTENSION'); - } - - $this->config['ldap_port'] = (int) $this->config['ldap_port']; - if ($this->config['ldap_port']) - { - $ldap = @ldap_connect($this->config['ldap_server'], $this->config['ldap_port']); - } - else - { - $ldap = @ldap_connect($this->config['ldap_server']); - } - - if (!$ldap) - { - return $this->language->lang('LDAP_NO_SERVER_CONNECTION'); - } - - @ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3); - @ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0); - - if ($this->config['ldap_user'] || $this->config['ldap_password']) - { - if (!@ldap_bind($ldap, htmlspecialchars_decode($this->config['ldap_user']), htmlspecialchars_decode($this->config['ldap_password']))) - { - return $this->language->lang('LDAP_INCORRECT_USER_PASSWORD'); - } - } - - // ldap_connect only checks whether the specified server is valid, so the connection might still fail - $search = @ldap_search( - $ldap, - htmlspecialchars_decode($this->config['ldap_base_dn']), - $this->ldap_user_filter($this->user->data['username']), - (empty($this->config['ldap_email'])) ? - array(htmlspecialchars_decode($this->config['ldap_uid'])) : - array(htmlspecialchars_decode($this->config['ldap_uid']), htmlspecialchars_decode($this->config['ldap_email'])), - 0, - 1 - ); - - if ($search === false) - { - return $this->language->lang('LDAP_SEARCH_FAILED'); - } - - $result = @ldap_get_entries($ldap, $search); - - @ldap_close($ldap); - - if (!is_array($result) || count($result) < 2) - { - return $this->language->lang('LDAP_NO_IDENTITY', $this->user->data['username']); - } - - if (!empty($this->config['ldap_email']) && !isset($result[0][htmlspecialchars_decode($this->config['ldap_email'])])) - { - return $this->language->lang('LDAP_NO_EMAIL'); - } - - return false; - } - - /** - * {@inheritdoc} - */ - public function login($username, $password) - { - // do not allow empty password - if (!$password) - { - return array( - 'status' => LOGIN_ERROR_PASSWORD, - 'error_msg' => 'NO_PASSWORD_SUPPLIED', - 'user_row' => array('user_id' => ANONYMOUS), - ); - } - - if (!$username) - { - return array( - 'status' => LOGIN_ERROR_USERNAME, - 'error_msg' => 'LOGIN_ERROR_USERNAME', - 'user_row' => array('user_id' => ANONYMOUS), - ); - } - - if (!@extension_loaded('ldap')) - { - return array( - 'status' => LOGIN_ERROR_EXTERNAL_AUTH, - 'error_msg' => 'LDAP_NO_LDAP_EXTENSION', - 'user_row' => array('user_id' => ANONYMOUS), - ); - } - - $this->config['ldap_port'] = (int) $this->config['ldap_port']; - if ($this->config['ldap_port']) - { - $ldap = @ldap_connect($this->config['ldap_server'], $this->config['ldap_port']); - } - else - { - $ldap = @ldap_connect($this->config['ldap_server']); - } - - if (!$ldap) - { - return array( - 'status' => LOGIN_ERROR_EXTERNAL_AUTH, - 'error_msg' => 'LDAP_NO_SERVER_CONNECTION', - 'user_row' => array('user_id' => ANONYMOUS), - ); - } - - @ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3); - @ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0); - - if ($this->config['ldap_user'] || $this->config['ldap_password']) - { - if (!@ldap_bind($ldap, htmlspecialchars_decode($this->config['ldap_user']), htmlspecialchars_decode($this->config['ldap_password']))) - { - return array( - 'status' => LOGIN_ERROR_EXTERNAL_AUTH, - 'error_msg' => 'LDAP_NO_SERVER_CONNECTION', - 'user_row' => array('user_id' => ANONYMOUS), - ); - } - } - - $search = @ldap_search( - $ldap, - htmlspecialchars_decode($this->config['ldap_base_dn']), - $this->ldap_user_filter($username), - (empty($this->config['ldap_email'])) ? - array(htmlspecialchars_decode($this->config['ldap_uid'])) : - array(htmlspecialchars_decode($this->config['ldap_uid']), htmlspecialchars_decode($this->config['ldap_email'])), - 0, - 1 - ); - - $ldap_result = @ldap_get_entries($ldap, $search); - - if (is_array($ldap_result) && count($ldap_result) > 1) - { - if (@ldap_bind($ldap, $ldap_result[0]['dn'], htmlspecialchars_decode($password))) - { - @ldap_close($ldap); - - $sql ='SELECT user_id, username, user_password, user_passchg, user_email, user_type - FROM ' . USERS_TABLE . " - WHERE username_clean = '" . $this->db->sql_escape(utf8_clean_string($username)) . "'"; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if ($row) - { - unset($ldap_result); - - // User inactive... - if ($row['user_type'] == USER_INACTIVE || $row['user_type'] == USER_IGNORE) - { - return array( - 'status' => LOGIN_ERROR_ACTIVE, - 'error_msg' => 'ACTIVE_ERROR', - 'user_row' => $row, - ); - } - - // Successful login... set user_login_attempts to zero... - return array( - 'status' => LOGIN_SUCCESS, - 'error_msg' => false, - 'user_row' => $row, - ); - } - else - { - // retrieve default group id - $sql = 'SELECT group_id - FROM ' . GROUPS_TABLE . " - WHERE group_name = '" . $this->db->sql_escape('REGISTERED') . "' - AND group_type = " . GROUP_SPECIAL; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if (!$row) - { - trigger_error('NO_GROUP'); - } - - // generate user account data - $ldap_user_row = array( - 'username' => $username, - 'user_password' => '', - 'user_email' => (!empty($this->config['ldap_email'])) ? utf8_htmlspecialchars($ldap_result[0][htmlspecialchars_decode($this->config['ldap_email'])][0]) : '', - 'group_id' => (int) $row['group_id'], - 'user_type' => USER_NORMAL, - 'user_ip' => $this->user->ip, - 'user_new' => ($this->config['new_member_post_limit']) ? 1 : 0, - ); - - unset($ldap_result); - - // this is the user's first login so create an empty profile - return array( - 'status' => LOGIN_SUCCESS_CREATE_PROFILE, - 'error_msg' => false, - 'user_row' => $ldap_user_row, - ); - } - } - else - { - unset($ldap_result); - @ldap_close($ldap); - - // Give status about wrong password... - return array( - 'status' => LOGIN_ERROR_PASSWORD, - 'error_msg' => 'LOGIN_ERROR_PASSWORD', - 'user_row' => array('user_id' => ANONYMOUS), - ); - } - } - - @ldap_close($ldap); - - return array( - 'status' => LOGIN_ERROR_USERNAME, - 'error_msg' => 'LOGIN_ERROR_USERNAME', - 'user_row' => array('user_id' => ANONYMOUS), - ); - } - - /** - * {@inheritdoc} - */ - public function acp() - { - // These are fields required in the config table - return array( - 'ldap_server', 'ldap_port', 'ldap_base_dn', 'ldap_uid', 'ldap_user_filter', 'ldap_email', 'ldap_user', 'ldap_password', - ); - } - - /** - * {@inheritdoc} - */ - public function get_acp_template($new_config) - { - return array( - 'TEMPLATE_FILE' => 'auth_provider_ldap.html', - 'TEMPLATE_VARS' => array( - 'AUTH_LDAP_BASE_DN' => $new_config['ldap_base_dn'], - 'AUTH_LDAP_EMAIL' => $new_config['ldap_email'], - 'AUTH_LDAP_PASSORD' => $new_config['ldap_password'] !== '' ? '********' : '', - 'AUTH_LDAP_PORT' => $new_config['ldap_port'], - 'AUTH_LDAP_SERVER' => $new_config['ldap_server'], - 'AUTH_LDAP_UID' => $new_config['ldap_uid'], - 'AUTH_LDAP_USER' => $new_config['ldap_user'], - 'AUTH_LDAP_USER_FILTER' => $new_config['ldap_user_filter'], - ), - ); - } - - /** - * Generates a filter string for ldap_search to find a user - * - * @param $username string Username identifying the searched user - * - * @return string A filter string for ldap_search - */ - private function ldap_user_filter($username) - { - $filter = '(' . $this->config['ldap_uid'] . '=' . $this->ldap_escape(htmlspecialchars_decode($username)) . ')'; - if ($this->config['ldap_user_filter']) - { - $_filter = ($this->config['ldap_user_filter'][0] == '(' && substr($this->config['ldap_user_filter'], -1) == ')') ? $this->config['ldap_user_filter'] : "({$this->config['ldap_user_filter']})"; - $filter = "(&{$filter}{$_filter})"; - } - return $filter; - } - - /** - * Escapes an LDAP AttributeValue - * - * @param string $string The string to be escaped - * @return string The escaped string - */ - private function ldap_escape($string) - { - return str_replace(array('*', '\\', '(', ')'), array('\\*', '\\\\', '\\(', '\\)'), $string); - } -} diff --git a/install/update/new/phpbb/auth/provider/oauth/oauth.php b/install/update/new/phpbb/auth/provider/oauth/oauth.php deleted file mode 100644 index 29ffe6d..0000000 --- a/install/update/new/phpbb/auth/provider/oauth/oauth.php +++ /dev/null @@ -1,859 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\auth\provider\oauth; - -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\ServiceFactory; -use OAuth\Common\Consumer\Credentials; -use OAuth\Common\Service\ServiceInterface; -use OAuth\OAuth1\Service\AbstractService as OAuth1Service; -use OAuth\OAuth2\Service\AbstractService as OAuth2Service; -use phpbb\auth\provider\base; -use phpbb\auth\provider\db; -use phpbb\auth\provider\oauth\service\exception; -use phpbb\config\config; -use phpbb\db\driver\driver_interface; -use phpbb\di\service_collection; -use phpbb\event\dispatcher; -use phpbb\language\language; -use phpbb\request\request_interface; -use phpbb\user; - -/** - * OAuth authentication provider for phpBB3 - */ -class oauth extends base -{ - /** @var config */ - protected $config; - - /** @var driver_interface */ - protected $db; - - /** @var db */ - protected $db_auth; - - /** @var dispatcher */ - protected $dispatcher; - - /** @var language */ - protected $language; - - /** @var request_interface */ - protected $request; - - /** @var service_collection */ - protected $service_providers; - - /** @var user */ - protected $user; - - /** @var string OAuth table: token storage */ - protected $oauth_token_table; - - /** @var string OAuth table: state */ - protected $oauth_state_table; - - /** @var string OAuth table: account association */ - protected $oauth_account_table; - - /** @var string Users table */ - protected $users_table; - - /** @var string phpBB root path */ - protected $root_path; - - /** @var string php File extension */ - protected $php_ext; - - /** - * Constructor. - * - * @param config $config Config object - * @param driver_interface $db Database object - * @param db $db_auth DB auth provider - * @param dispatcher $dispatcher Event dispatcher object - * @param language $language Language object - * @param request_interface $request Request object - * @param service_collection $service_providers OAuth providers service collection - * @param user $user User object - * @param string $oauth_token_table OAuth table: token storage - * @param string $oauth_state_table OAuth table: state - * @param string $oauth_account_table OAuth table: account association - * @param string $users_table User table - * @param string $root_path phpBB root path - * @param string $php_ext php File extension - */ - public function __construct( - config $config, - driver_interface $db, - db $db_auth, - dispatcher $dispatcher, - language $language, - request_interface $request, - service_collection $service_providers, - user $user, - $oauth_token_table, - $oauth_state_table, - $oauth_account_table, - $users_table, - $root_path, - $php_ext - ) - { - $this->config = $config; - $this->db = $db; - $this->db_auth = $db_auth; - $this->dispatcher = $dispatcher; - $this->language = $language; - $this->service_providers = $service_providers; - $this->request = $request; - $this->user = $user; - - $this->oauth_token_table = $oauth_token_table; - $this->oauth_state_table = $oauth_state_table; - $this->oauth_account_table = $oauth_account_table; - $this->users_table = $users_table; - $this->root_path = $root_path; - $this->php_ext = $php_ext; - } - - /** - * {@inheritdoc} - */ - public function init() - { - // This does not test whether or not the key and secret provided are valid. - foreach ($this->service_providers as $service_provider) - { - $credentials = $service_provider->get_service_credentials(); - - if (($credentials['key'] && !$credentials['secret']) || (!$credentials['key'] && $credentials['secret'])) - { - return $this->language->lang('AUTH_PROVIDER_OAUTH_ERROR_ELEMENT_MISSING'); - } - } - - return false; - } - - /** - * {@inheritdoc} - */ - public function login($username, $password) - { - // Temporary workaround for only having one authentication provider available - if (!$this->request->is_set('oauth_service')) - { - return $this->db_auth->login($username, $password); - } - - // Request the name of the OAuth service - $provider = $this->request->variable('oauth_service', '', false); - $service_name = $this->get_service_name($provider); - - if ($provider === '' || !array_key_exists($service_name, $this->service_providers)) - { - return [ - 'status' => LOGIN_ERROR_EXTERNAL_AUTH, - 'error_msg' => 'LOGIN_ERROR_OAUTH_SERVICE_DOES_NOT_EXIST', - 'user_row' => ['user_id' => ANONYMOUS], - ]; - } - - // Get the service credentials for the given service - $storage = new token_storage($this->db, $this->user, $this->oauth_token_table, $this->oauth_state_table); - $query = 'mode=login&login=external&oauth_service=' . $provider; - - try - { - /** @var OAuth1Service|OAuth2Service $service */ - $service = $this->get_service($provider, $storage, $query); - } - catch (\Exception $e) - { - return [ - 'status' => LOGIN_ERROR_EXTERNAL_AUTH, - 'error_msg' => $e->getMessage(), - 'user_row' => ['user_id' => ANONYMOUS], - ]; - } - - if ($this->is_set_code($service)) - { - $this->service_providers[$service_name]->set_external_service_provider($service); - - try - { - $unique_id = $this->service_providers[$service_name]->perform_auth_login(); - } - catch (exception $e) - { - return [ - 'status' => LOGIN_ERROR_EXTERNAL_AUTH, - 'error_msg' => $e->getMessage(), - 'user_row' => ['user_id' => ANONYMOUS], - ]; - } - - /** - * Check to see if this provider is already associated with an account. - * - * Enforcing a data type to make sure it are strings and not integers, - * so values are quoted in the SQL WHERE statement. - */ - $data = [ - 'provider' => (string) utf8_strtolower($provider), - 'oauth_provider_id' => (string) $unique_id - ]; - - $sql = 'SELECT user_id - FROM ' . $this->oauth_account_table . ' - WHERE ' . $this->db->sql_build_array('SELECT', $data); - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - $redirect_data = array( - 'auth_provider' => 'oauth', - 'login_link_oauth_service' => $provider, - ); - - /** - * Event is triggered before check if provider is already associated with an account - * - * @event core.oauth_login_after_check_if_provider_id_has_match - * @var array row User row - * @var array data Provider data - * @var array redirect_data Data to be appended to the redirect url - * @var ServiceInterface service OAuth service - * @since 3.2.3-RC1 - * @changed 3.2.6-RC1 Added redirect_data - */ - $vars = [ - 'row', - 'data', - 'redirect_data', - 'service', - ]; - extract($this->dispatcher->trigger_event('core.oauth_login_after_check_if_provider_id_has_match', compact($vars))); - - if (!$row) - { - // The user does not yet exist, ask to link or create profile - return [ - 'status' => LOGIN_SUCCESS_LINK_PROFILE, - 'error_msg' => 'LOGIN_OAUTH_ACCOUNT_NOT_LINKED', - 'user_row' => [], - 'redirect_data' => $redirect_data, - ]; - } - - // Retrieve the user's account - $sql = 'SELECT user_id, username, user_password, user_passchg, user_email, user_ip, user_type, user_login_attempts - FROM ' . $this->users_table . ' - WHERE user_id = ' . (int) $row['user_id']; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if (!$row) - { - return [ - 'status' => LOGIN_ERROR_EXTERNAL_AUTH, - 'error_msg' => 'AUTH_PROVIDER_OAUTH_ERROR_INVALID_ENTRY', - 'user_row' => ['user_id' => ANONYMOUS], - ]; - } - - /** - * Check if the user is banned. - * The fourth parameter (return) has to be true, otherwise the OAuth login is still called and - * an uncaught exception is thrown as there is no token stored in the database. - */ - $ban = $this->user->check_ban($row['user_id'], $row['user_ip'], $row['user_email'], true); - - if (!empty($ban)) - { - $till_date = !empty($ban['ban_end']) ? $this->user->format_date($ban['ban_end']) : ''; - $message = !empty($ban['ban_end']) ? 'BOARD_BAN_TIME' : 'BOARD_BAN_PERM'; - - $contact_link = phpbb_get_board_contact_link($this->config, $this->root_path, $this->php_ext); - - $message = $this->language->lang($message, $till_date, '', ''); - $message .= !empty($ban['ban_give_reason']) ? '

' . $this->language->lang('BOARD_BAN_REASON', $ban['ban_give_reason']) : ''; - $message .= !empty($ban['ban_triggered_by']) ? '

' . $this->language->lang('BAN_TRIGGERED_BY_' . utf8_strtoupper($ban['ban_triggered_by'])) . '' : ''; - - return [ - 'status' => LOGIN_BREAK, - 'error_msg' => $message, - 'user_row' => $row, - ]; - } - - // Update token storage to store the user_id - $storage->set_user_id($row['user_id']); - - /** - * Event is triggered after user is successfully logged in via OAuth. - * - * @event core.auth_oauth_login_after - * @var array row User row - * @since 3.1.11-RC1 - */ - $vars = [ - 'row', - ]; - extract($this->dispatcher->trigger_event('core.auth_oauth_login_after', compact($vars))); - - // The user is now authenticated and can be logged in - return [ - 'status' => LOGIN_SUCCESS, - 'error_msg' => false, - 'user_row' => $row, - ]; - } - else - { - return $this->set_redirect($service); - } - } - - /** - * {@inheritdoc} - */ - public function get_login_data() - { - $login_data = [ - 'TEMPLATE_FILE' => 'login_body_oauth.html', - 'BLOCK_VAR_NAME' => 'oauth', - 'BLOCK_VARS' => [], - ]; - - foreach ($this->service_providers as $service_name => $service_provider) - { - // Only include data if the credentials are set - $credentials = $service_provider->get_service_credentials(); - - if ($credentials['key'] && $credentials['secret']) - { - $provider = $this->get_provider($service_name); - $redirect_url = generate_board_url() . '/ucp.' . $this->php_ext . '?mode=login&login=external&oauth_service=' . $provider; - - $login_data['BLOCK_VARS'][$service_name] = [ - 'REDIRECT_URL' => redirect($redirect_url, true), - 'SERVICE_NAME' => $this->get_provider_title($provider), - ]; - } - } - - return $login_data; - } - - /** - * {@inheritdoc} - */ - public function acp() - { - $ret = []; - - foreach ($this->service_providers as $service_name => $service_provider) - { - $provider = $this->get_provider($service_name); - - $provider = utf8_strtolower($provider); - - $ret[] = 'auth_oauth_' . $provider . '_key'; - $ret[] = 'auth_oauth_' . $provider . '_secret'; - } - - return $ret; - } - - /** - * {@inheritdoc} - */ - public function get_acp_template($new_config) - { - $ret = [ - 'BLOCK_VAR_NAME' => 'oauth_services', - 'BLOCK_VARS' => [], - 'TEMPLATE_FILE' => 'auth_provider_oauth.html', - 'TEMPLATE_VARS' => [], - ]; - - foreach ($this->service_providers as $service_name => $service_provider) - { - $provider = $this->get_provider($service_name); - - $ret['BLOCK_VARS'][$provider] = [ - 'NAME' => $provider, - 'ACTUAL_NAME' => $this->get_provider_title($provider), - 'KEY' => $new_config['auth_oauth_' . utf8_strtolower($provider) . '_key'], - 'SECRET' => $new_config['auth_oauth_' . utf8_strtolower($provider) . '_secret'], - ]; - } - - return $ret; - } - - /** - * {@inheritdoc} - */ - public function login_link_has_necessary_data($login_link_data) - { - if (empty($login_link_data)) - { - return 'LOGIN_LINK_NO_DATA_PROVIDED'; - } - - if (!array_key_exists('oauth_service', $login_link_data) || !$login_link_data['oauth_service'] || - !array_key_exists('link_method', $login_link_data) || !$login_link_data['link_method']) - { - return 'LOGIN_LINK_MISSING_DATA'; - } - - return null; - } - - /** - * {@inheritdoc} - */ - public function link_account(array $link_data) - { - // Check for a valid link method (auth_link or login_link) - if (!array_key_exists('link_method', $link_data) || - !in_array($link_data['link_method'], ['auth_link', 'login_link'])) - { - return 'LOGIN_LINK_MISSING_DATA'; - } - - // We must have an oauth_service listed, check for it two ways - if (!array_key_exists('oauth_service', $link_data) || !$link_data['oauth_service']) - { - $link_data['oauth_service'] = $this->request->variable('oauth_service', ''); - - if (!$link_data['oauth_service']) - { - return 'LOGIN_LINK_MISSING_DATA'; - } - } - - $service_name = $this->get_service_name($link_data['oauth_service']); - - if (!array_key_exists($service_name, $this->service_providers)) - { - return 'LOGIN_ERROR_OAUTH_SERVICE_DOES_NOT_EXIST'; - } - - switch ($link_data['link_method']) - { - case 'auth_link': - return $this->link_account_auth_link($link_data, $service_name); - case 'login_link': - return $this->link_account_login_link($link_data, $service_name); - default: - return 'LOGIN_LINK_MISSING_DATA'; - } - } - - /** - * {@inheritdoc} - */ - public function logout($data, $new_session) - { - // Clear all tokens belonging to the user - $storage = new token_storage($this->db, $this->user, $this->oauth_token_table, $this->oauth_state_table); - $storage->clearAllTokens(); - - return; - } - - /** - * {@inheritdoc} - */ - public function get_auth_link_data($user_id = 0) - { - $user_ids = []; - $block_vars = []; - - $sql = 'SELECT oauth_provider_id, provider - FROM ' . $this->oauth_account_table . ' - WHERE user_id = ' . ($user_id > 0 ? (int) $user_id : (int) $this->user->data['user_id']); - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - $user_ids[$row['provider']] = $row['oauth_provider_id']; - } - $this->db->sql_freeresult($result); - - foreach ($this->service_providers as $service_name => $service_provider) - { - // Only include data if the credentials are set - $credentials = $service_provider->get_service_credentials(); - - if ($credentials['key'] && $credentials['secret']) - { - $provider = $this->get_provider($service_name); - - $block_vars[$service_name] = [ - 'SERVICE_NAME' => $this->get_provider_title($provider), - 'UNIQUE_ID' => isset($user_ids[$provider]) ? $user_ids[$provider] : null, - 'HIDDEN_FIELDS' => [ - 'link' => !isset($user_ids[$provider]), - 'oauth_service' => $provider, - ], - ]; - } - } - - return [ - 'BLOCK_VAR_NAME' => 'oauth', - 'BLOCK_VARS' => $block_vars, - - 'TEMPLATE_FILE' => 'ucp_auth_link_oauth.html', - ]; - } - - /** - * {@inheritdoc} - */ - public function unlink_account(array $link_data) - { - if (!array_key_exists('oauth_service', $link_data) || !$link_data['oauth_service']) - { - return 'LOGIN_LINK_MISSING_DATA'; - } - - // Remove user specified in $link_data if possible - $user_id = isset($link_data['user_id']) ? $link_data['user_id'] : $this->user->data['user_id']; - - // Remove the link - $sql = 'DELETE FROM ' . $this->oauth_account_table . " - WHERE provider = '" . $this->db->sql_escape($link_data['oauth_service']) . "' - AND user_id = " . (int) $user_id; - $this->db->sql_query($sql); - - $service_name = $this->get_service_name($link_data['oauth_service']); - - // Clear all tokens belonging to the user on this service - $storage = new token_storage($this->db, $this->user, $this->oauth_token_table, $this->oauth_state_table); - $storage->clearToken($service_name); - - return false; - } - - /** - * Performs the account linking for login_link. - * - * @param array $link_data The same variable given to - * {@see \phpbb\auth\provider\provider_interface::link_account} - * @param string $service_name The name of the service being used in linking. - * @return string|false Returns a language key (string) if an error is encountered, - * or false on success. - */ - protected function link_account_login_link(array $link_data, $service_name) - { - $storage = new token_storage($this->db, $this->user, $this->oauth_token_table, $this->oauth_state_table); - - // Check for an access token, they should have one - if (!$storage->has_access_token_by_session($service_name)) - { - return 'LOGIN_LINK_ERROR_OAUTH_NO_ACCESS_TOKEN'; - } - - // Prepare for an authentication request - $query = 'mode=login_link&login_link_oauth_service=' . $link_data['oauth_service']; - - try - { - $service = $this->get_service($link_data['oauth_service'], $storage, $query); - } - catch (\Exception $e) - { - return $e->getMessage(); - } - - $this->service_providers[$service_name]->set_external_service_provider($service); - - try - { - // The user has already authenticated successfully, request to authenticate again - $unique_id = $this->service_providers[$service_name]->perform_token_auth(); - } - catch (exception $e) - { - return $e->getMessage(); - } - - // Insert into table, they will be able to log in after this - $data = [ - 'user_id' => $link_data['user_id'], - 'provider' => utf8_strtolower($link_data['oauth_service']), - 'oauth_provider_id' => $unique_id, - ]; - - $this->link_account_perform_link($data); - - // Update token storage to store the user_id - $storage->set_user_id($link_data['user_id']); - - return false; - } - - /** - * Performs the account linking for auth_link. - * - * @param array $link_data The same variable given to - * {@see \phpbb\auth\provider\provider_interface::link_account} - * @param string $service_name The name of the service being used in linking. - * @return string|false Returns a language constant (string) if an error is encountered, - * or false on success. - */ - protected function link_account_auth_link(array $link_data, $service_name) - { - $storage = new token_storage($this->db, $this->user, $this->oauth_token_table, $this->oauth_state_table); - $query = 'i=ucp_auth_link&mode=auth_link&link=1&oauth_service=' . $link_data['oauth_service']; - - try - { - /** @var OAuth1Service|OAuth2Service $service */ - $service = $this->get_service($link_data['oauth_service'], $storage, $query); - } - catch (\Exception $e) - { - return $e->getMessage(); - } - - if ($this->is_set_code($service)) - { - $this->service_providers[$service_name]->set_external_service_provider($service); - - try - { - $unique_id = $this->service_providers[$service_name]->perform_auth_login(); - } - catch (exception $e) - { - return $e->getMessage(); - } - - // Insert into table, they will be able to log in after this - $data = [ - 'user_id' => $this->user->data['user_id'], - 'provider' => utf8_strtolower($link_data['oauth_service']), - 'oauth_provider_id' => $unique_id, - ]; - - $this->link_account_perform_link($data); - - return false; - } - else - { - return $this->set_redirect($service); - } - } - - /** - * Performs the query that inserts an account link - * - * @param array $data This array is passed to db->sql_build_array - */ - protected function link_account_perform_link(array $data) - { - // Check if the external account is already associated with other user - $sql = 'SELECT user_id - FROM ' . $this->oauth_account_table . " - WHERE provider = '" . $this->db->sql_escape($data['provider']) . "' - AND oauth_provider_id = '" . $this->db->sql_escape($data['oauth_provider_id']) . "'"; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if ($row) - { - trigger_error('AUTH_PROVIDER_OAUTH_ERROR_ALREADY_LINKED'); - } - - // Link account - $sql = 'INSERT INTO ' . $this->oauth_account_table . ' ' . $this->db->sql_build_array('INSERT', $data); - $this->db->sql_query($sql); - - /** - * Event is triggered after user links account. - * - * @event core.auth_oauth_link_after - * @var array data User row - * @since 3.1.11-RC1 - */ - $vars = [ - 'data', - ]; - extract($this->dispatcher->trigger_event('core.auth_oauth_link_after', compact($vars))); - } - - /** - * Returns a new service object. - * - * @param string $provider The name of the provider - * @param token_storage $storage Token storage object - * @param string $query The query string used for the redirect uri - * @return ServiceInterface - * @throws exception When OAuth service was not created - */ - protected function get_service($provider, token_storage $storage, $query) - { - $service_name = $this->get_service_name($provider); - - /** @see \phpbb\auth\provider\oauth\service\service_interface::get_service_credentials */ - $service_credentials = $this->service_providers[$service_name]->get_service_credentials(); - - /** @see \phpbb\auth\provider\oauth\service\service_interface::get_auth_scope */ - $scopes = $this->service_providers[$service_name]->get_auth_scope(); - - $callback = generate_board_url() . "/ucp.{$this->php_ext}?{$query}"; - - // Setup the credentials for the requests - $credentials = new Credentials( - $service_credentials['key'], - $service_credentials['secret'], - $callback - ); - - $service_factory = new ServiceFactory; - - // Allow providers to register a custom class or override the provider name - if ($class = $this->service_providers[$service_name]->get_external_service_class()) - { - if (class_exists($class)) - { - try - { - $service_factory->registerService($provider, $class); - } - catch (\OAuth\Common\Exception\Exception $e) - { - throw new exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); - } - } - else - { - $provider = $class; - } - } - - $service = $service_factory->createService($provider, $credentials, $storage, $scopes); - - if (!$service) - { - throw new exception('AUTH_PROVIDER_OAUTH_ERROR_SERVICE_NOT_CREATED'); - } - - return $service; - } - - /** - * Returns the service name for an OAuth provider name. - * - * @param string $provider The OAuth provider name - * @return string The service name - */ - protected function get_service_name($provider) - { - if (strpos($provider, 'auth.provider.oauth.service.') !== 0) - { - $provider = 'auth.provider.oauth.service.' . utf8_strtolower($provider); - } - - return $provider; - } - - /** - * Returns the OAuth provider name from a service name. - * - * @param string $service_name The service name - * @return string The OAuth provider name - */ - protected function get_provider($service_name) - { - return str_replace('auth.provider.oauth.service.', '', $service_name); - } - - /** - * Returns the localized title for the OAuth provider. - * - * @param string $provider The OAuth provider name - * @return string The OAuth provider title - */ - protected function get_provider_title($provider) - { - return $this->language->lang('AUTH_PROVIDER_OAUTH_SERVICE_' . utf8_strtoupper($provider)); - } - - /** - * Returns whether or not the authorization code is set. - * - * @param OAuth1Service|OAuth2Service $service The external OAuth service - * @return bool Whether or not the authorization code is set in the URL - * for the respective OAuth service's version - */ - protected function is_set_code($service) - { - switch ($service::OAUTH_VERSION) - { - case 1: - return $this->request->is_set('oauth_token', request_interface::GET); - - case 2: - return $this->request->is_set('code', request_interface::GET); - - default: - return false; - } - } - - /** - * Sets a redirect to the authorization uri. - * - * @param OAuth1Service|OAuth2Service $service The external OAuth service - * @return array|false Array if an error occurred, - * false on success - */ - protected function set_redirect($service) - { - $parameters = []; - - if ($service::OAUTH_VERSION === 1) - { - try - { - $token = $service->requestRequestToken(); - $parameters = ['oauth_token' => $token->getRequestToken()]; - } - catch (TokenResponseException $e) - { - return [ - 'status' => LOGIN_ERROR_EXTERNAL_AUTH, - 'error_msg' => $e->getMessage(), - 'user_row' => ['user_id' => ANONYMOUS], - ]; - } - } - - redirect($service->getAuthorizationUri($parameters), false, true); - - return false; - } -} diff --git a/install/update/new/phpbb/auth/provider/oauth/service/base.php b/install/update/new/phpbb/auth/provider/oauth/service/base.php deleted file mode 100644 index 5ab426a..0000000 --- a/install/update/new/phpbb/auth/provider/oauth/service/base.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\auth\provider\oauth\service; - -/** - * Base OAuth abstract class that all OAuth services should implement - */ -abstract class base implements service_interface -{ - /** - * External OAuth service provider - * - * @var \OAuth\Common\Service\ServiceInterface - */ - protected $service_provider; - - /** - * {@inheritdoc} - */ - public function get_auth_scope() - { - return []; - } - - /** - * {@inheritdoc} - */ - public function get_external_service_class() - { - return ''; - } - - /** - * {@inheritdoc} - */ - public function get_external_service_provider() - { - return $this->service_provider; - } - - /** - * {@inheritdoc} - */ - public function set_external_service_provider(\OAuth\Common\Service\ServiceInterface $service_provider) - { - $this->service_provider = $service_provider; - } -} diff --git a/install/update/new/phpbb/auth/provider/oauth/service/bitly.php b/install/update/new/phpbb/auth/provider/oauth/service/bitly.php deleted file mode 100644 index ca131b2..0000000 --- a/install/update/new/phpbb/auth/provider/oauth/service/bitly.php +++ /dev/null @@ -1,107 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\auth\provider\oauth\service; - -/** - * Bitly OAuth service - */ -class bitly extends base -{ - /** @var \phpbb\config\config */ - protected $config; - - /** @var \phpbb\request\request_interface */ - protected $request; - - /** - * Constructor. - * - * @param \phpbb\config\config $config Config object - * @param \phpbb\request\request_interface $request Request object - */ - public function __construct(\phpbb\config\config $config, \phpbb\request\request_interface $request) - { - $this->config = $config; - $this->request = $request; - } - - /** - * {@inheritdoc} - */ - public function get_service_credentials() - { - return [ - 'key' => $this->config['auth_oauth_bitly_key'], - 'secret' => $this->config['auth_oauth_bitly_secret'], - ]; - } - - /** - * {@inheritdoc} - */ - public function perform_auth_login() - { - if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Bitly)) - { - throw new exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); - } - - try - { - // This was a callback request, get the token - $this->service_provider->requestAccessToken($this->request->variable('code', '')); - } - catch (\OAuth\Common\Http\Exception\TokenResponseException $e) - { - throw new exception('AUTH_PROVIDER_OAUTH_ERROR_REQUEST'); - } - - try - { - // Send a request with it - $result = (array) json_decode($this->service_provider->request('user/info'), true); - } - catch (\OAuth\Common\Exception\Exception $e) - { - throw new exception('AUTH_PROVIDER_OAUTH_ERROR_REQUEST'); - } - - // Return the unique identifier returned from bitly - return $result['data']['login']; - } - - /** - * {@inheritdoc} - */ - public function perform_token_auth() - { - if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Bitly)) - { - throw new exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); - } - - try - { - // Send a request with it - $result = (array) json_decode($this->service_provider->request('user/info'), true); - } - catch (\OAuth\Common\Exception\Exception $e) - { - throw new exception('AUTH_PROVIDER_OAUTH_ERROR_REQUEST'); - } - - // Return the unique identifier - return $result['data']['login']; - } -} diff --git a/install/update/new/phpbb/auth/provider/oauth/service/facebook.php b/install/update/new/phpbb/auth/provider/oauth/service/facebook.php deleted file mode 100644 index f7dbe30..0000000 --- a/install/update/new/phpbb/auth/provider/oauth/service/facebook.php +++ /dev/null @@ -1,107 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\auth\provider\oauth\service; - -/** - * Facebook OAuth service - */ -class facebook extends base -{ - /** @var \phpbb\config\config */ - protected $config; - - /** @var \phpbb\request\request_interface */ - protected $request; - - /** - * Constructor. - * - * @param \phpbb\config\config $config Config object - * @param \phpbb\request\request_interface $request Request object - */ - public function __construct(\phpbb\config\config $config, \phpbb\request\request_interface $request) - { - $this->config = $config; - $this->request = $request; - } - - /** - * {@inheritdoc} - */ - public function get_service_credentials() - { - return [ - 'key' => $this->config['auth_oauth_facebook_key'], - 'secret' => $this->config['auth_oauth_facebook_secret'], - ]; - } - - /** - * {@inheritdoc} - */ - public function perform_auth_login() - { - if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Facebook)) - { - throw new exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); - } - - try - { - // This was a callback request, get the token - $this->service_provider->requestAccessToken($this->request->variable('code', '')); - } - catch (\OAuth\Common\Http\Exception\TokenResponseException $e) - { - throw new exception('AUTH_PROVIDER_OAUTH_ERROR_REQUEST'); - } - - try - { - // Send a request with it - $result = (array) json_decode($this->service_provider->request('/me'), true); - } - catch (\OAuth\Common\Exception\Exception $e) - { - throw new exception('AUTH_PROVIDER_OAUTH_ERROR_REQUEST'); - } - - // Return the unique identifier - return $result['id']; - } - - /** - * {@inheritdoc} - */ - public function perform_token_auth() - { - if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Facebook)) - { - throw new exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); - } - - try - { - // Send a request with it - $result = (array) json_decode($this->service_provider->request('/me'), true); - } - catch (\OAuth\Common\Exception\Exception $e) - { - throw new exception('AUTH_PROVIDER_OAUTH_ERROR_REQUEST'); - } - - // Return the unique identifier - return $result['id']; - } -} diff --git a/install/update/new/phpbb/auth/provider/oauth/service/google.php b/install/update/new/phpbb/auth/provider/oauth/service/google.php deleted file mode 100644 index 6e671ab..0000000 --- a/install/update/new/phpbb/auth/provider/oauth/service/google.php +++ /dev/null @@ -1,118 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\auth\provider\oauth\service; - -/** - * Google OAuth service - */ -class google extends base -{ - /** @var \phpbb\config\config */ - protected $config; - - /** @var \phpbb\request\request_interface */ - protected $request; - - /** - * Constructor. - * - * @param \phpbb\config\config $config Config object - * @param \phpbb\request\request_interface $request Request object - */ - public function __construct(\phpbb\config\config $config, \phpbb\request\request_interface $request) - { - $this->config = $config; - $this->request = $request; - } - - /** - * {@inheritdoc} - */ - public function get_auth_scope() - { - return [ - 'userinfo_email', - 'userinfo_profile', - ]; - } - - /** - * {@inheritdoc} - */ - public function get_service_credentials() - { - return [ - 'key' => $this->config['auth_oauth_google_key'], - 'secret' => $this->config['auth_oauth_google_secret'], - ]; - } - - /** - * {@inheritdoc} - */ - public function perform_auth_login() - { - if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Google)) - { - throw new exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); - } - - try - { - // This was a callback request, get the token - $this->service_provider->requestAccessToken($this->request->variable('code', '')); - } - catch (\OAuth\Common\Http\Exception\TokenResponseException $e) - { - throw new exception('AUTH_PROVIDER_OAUTH_ERROR_REQUEST'); - } - - try - { - // Send a request with it - $result = (array) json_decode($this->service_provider->request('https://www.googleapis.com/oauth2/v1/userinfo'), true); - } - catch (\OAuth\Common\Exception\Exception $e) - { - throw new exception('AUTH_PROVIDER_OAUTH_ERROR_REQUEST'); - } - - // Return the unique identifier - return $result['id']; - } - - /** - * {@inheritdoc} - */ - public function perform_token_auth() - { - if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Google)) - { - throw new exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); - } - - try - { - // Send a request with it - $result = (array) json_decode($this->service_provider->request('https://www.googleapis.com/oauth2/v1/userinfo'), true); - } - catch (\OAuth\Common\Exception\Exception $e) - { - throw new exception('AUTH_PROVIDER_OAUTH_ERROR_REQUEST'); - } - - // Return the unique identifier - return $result['id']; - } -} diff --git a/install/update/new/phpbb/auth/provider/oauth/service/service_interface.php b/install/update/new/phpbb/auth/provider/oauth/service/service_interface.php deleted file mode 100644 index 239e661..0000000 --- a/install/update/new/phpbb/auth/provider/oauth/service/service_interface.php +++ /dev/null @@ -1,85 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\auth\provider\oauth\service; - -/** - * OAuth service interface - */ -interface service_interface -{ - /** - * Returns an array of the scopes necessary for auth - * - * @return array An array of the required scopes - */ - public function get_auth_scope(); - - /** - * Returns an array containing the service credentials belonging to requested - * service. - * - * @return array An array containing the 'key' and the 'secret' of the - * service in the form: - * array( - * 'key' => string - * 'secret' => string - * ) - */ - public function get_service_credentials(); - - /** - * Returns the results of the authentication in json format - * - * @throws \phpbb\auth\provider\oauth\service\exception - * @return string The unique identifier returned by the service provider - * that is used to authenticate the user with phpBB. - */ - public function perform_auth_login(); - - /** - * Returns the results of the authentication in json format - * Use this function when the user already has an access token - * - * @throws \phpbb\auth\provider\oauth\service\exception - * @return string The unique identifier returned by the service provider - * that is used to authenticate the user with phpBB. - */ - public function perform_token_auth(); - - /** - * Returns the class of external library service provider that has to be used. - * - * @return string If the string is a class, it will register the provided string as a class, - * which later will be generated as the OAuth external service provider. - * If the string is not a class, it will use this string, - * trying to generate a service for the version 2 and 1 respectively: - * \OAuth\OAuth2\Service\ - * If the string is empty, it will default to OAuth's standard service classes, - * trying to generate a service for the version 2 and 1 respectively: - * \OAuth\OAuth2\Service\Facebook - */ - public function get_external_service_class(); - - /** - * Returns the external library service provider once it has been set - */ - public function get_external_service_provider(); - - /** - * Sets the external library service provider - * - * @param \OAuth\Common\Service\ServiceInterface $service_provider - */ - public function set_external_service_provider(\OAuth\Common\Service\ServiceInterface $service_provider); -} diff --git a/install/update/new/phpbb/auth/provider/oauth/service/twitter.php b/install/update/new/phpbb/auth/provider/oauth/service/twitter.php deleted file mode 100644 index 35cbc9e..0000000 --- a/install/update/new/phpbb/auth/provider/oauth/service/twitter.php +++ /dev/null @@ -1,111 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\auth\provider\oauth\service; - -/** - * Twitter OAuth service - */ -class twitter extends base -{ - /** @var \phpbb\config\config */ - protected $config; - - /** @var \phpbb\request\request_interface */ - protected $request; - - /** - * Constructor. - * - * @param \phpbb\config\config $config Config object - * @param \phpbb\request\request_interface $request Request object - */ - public function __construct(\phpbb\config\config $config, \phpbb\request\request_interface $request) - { - $this->config = $config; - $this->request = $request; - } - - /** - * {@inheritdoc} - */ - public function get_service_credentials() - { - return [ - 'key' => $this->config['auth_oauth_twitter_key'], - 'secret' => $this->config['auth_oauth_twitter_secret'], - ]; - } - - /** - * {@inheritdoc} - */ - public function perform_auth_login() - { - if (!($this->service_provider instanceof \OAuth\OAuth1\Service\Twitter)) - { - throw new exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); - } - - $storage = $this->service_provider->getStorage(); - - try - { - /** @var \OAuth\OAuth1\Token\TokenInterface $token */ - $token = $storage->retrieveAccessToken('Twitter'); - } - catch (\OAuth\Common\Storage\Exception\TokenNotFoundException $e) - { - throw new exception('AUTH_PROVIDER_OAUTH_ERROR_REQUEST'); - } - - $secret = $token->getRequestTokenSecret(); - - try - { - // This was a callback request, get the token - $this->service_provider->requestAccessToken( - $this->request->variable('oauth_token', ''), - $this->request->variable('oauth_verifier', ''), - $secret - ); - } - catch (\OAuth\Common\Http\Exception\TokenResponseException $e) - { - throw new exception('AUTH_PROVIDER_OAUTH_ERROR_REQUEST'); - } - - // Send a request with it - $result = (array) json_decode($this->service_provider->request('account/verify_credentials.json'), true); - - // Return the unique identifier - return $result['id']; - } - - /** - * {@inheritdoc} - */ - public function perform_token_auth() - { - if (!($this->service_provider instanceof \OAuth\OAuth1\Service\Twitter)) - { - throw new exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); - } - - // Send a request with it - $result = (array) json_decode($this->service_provider->request('account/verify_credentials.json'), true); - - // Return the unique identifier - return $result['id']; - } -} diff --git a/install/update/new/phpbb/auth/provider/oauth/token_storage.php b/install/update/new/phpbb/auth/provider/oauth/token_storage.php deleted file mode 100644 index c0f585d..0000000 --- a/install/update/new/phpbb/auth/provider/oauth/token_storage.php +++ /dev/null @@ -1,620 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\auth\provider\oauth; - -use OAuth\OAuth1\Token\StdOAuth1Token; -use OAuth\Common\Token\TokenInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Storage\Exception\TokenNotFoundException; -use OAuth\Common\Storage\Exception\AuthorizationStateNotFoundException; - -/** - * OAuth storage wrapper for phpBB's cache - */ -class token_storage implements TokenStorageInterface -{ - /** @var \phpbb\db\driver\driver_interface */ - protected $db; - - /** @var \phpbb\user */ - protected $user; - - /** @var string OAuth table: token storage */ - protected $oauth_token_table; - - /** @var string OAuth table: state */ - protected $oauth_state_table; - - /** @var TokenInterface OAuth token */ - protected $cachedToken; - - /** @var string OAuth state */ - protected $cachedState; - - /** - * Constructor. - * - * @param \phpbb\db\driver\driver_interface $db Database object - * @param \phpbb\user $user User object - * @param string $oauth_token_table OAuth table: token storage - * @param string $oauth_state_table OAuth table: state - */ - public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\user $user, $oauth_token_table, $oauth_state_table) - { - $this->db = $db; - $this->user = $user; - - $this->oauth_token_table = $oauth_token_table; - $this->oauth_state_table = $oauth_state_table; - } - - /** - * {@inheritdoc} - */ - public function retrieveAccessToken($service) - { - $service = $this->get_service_name_for_db($service); - - if ($this->cachedToken instanceof TokenInterface) - { - return $this->cachedToken; - } - - $data = [ - 'user_id' => (int) $this->user->data['user_id'], - 'provider' => $service, - ]; - - if ((int) $this->user->data['user_id'] === ANONYMOUS) - { - $data['session_id'] = $this->user->data['session_id']; - } - - return $this->_retrieve_access_token($data); - } - - /** - * {@inheritdoc} - */ - public function storeAccessToken($service, TokenInterface $token) - { - $service = $this->get_service_name_for_db($service); - - $this->cachedToken = $token; - - $data = [ - 'oauth_token' => $this->json_encode_token($token), - ]; - - $sql = 'UPDATE ' . $this->oauth_token_table . ' - SET ' . $this->db->sql_build_array('UPDATE', $data) . ' - WHERE user_id = ' . (int) $this->user->data['user_id'] . " - AND provider = '" . $this->db->sql_escape($service) . "'"; - - if ((int) $this->user->data['user_id'] === ANONYMOUS) - { - $sql .= " AND session_id = '" . $this->db->sql_escape($this->user->data['session_id']) . "'"; - } - - $this->db->sql_query($sql); - - if (!$this->db->sql_affectedrows()) - { - $data = [ - 'user_id' => (int) $this->user->data['user_id'], - 'provider' => $service, - 'oauth_token' => $this->json_encode_token($token), - 'session_id' => $this->user->data['session_id'], - ]; - - $sql = 'INSERT INTO ' . $this->oauth_token_table . $this->db->sql_build_array('INSERT', $data); - - $this->db->sql_query($sql); - } - - return $this; - } - - /** - * {@inheritdoc} - */ - public function hasAccessToken($service) - { - $service = $this->get_service_name_for_db($service); - - if ($this->cachedToken) - { - return true; - } - - $data = [ - 'user_id' => (int) $this->user->data['user_id'], - 'provider' => $service, - ]; - - if ((int) $this->user->data['user_id'] === ANONYMOUS) - { - $data['session_id'] = $this->user->data['session_id']; - } - - return $this->has_access_token($data); - } - - /** - * {@inheritdoc} - */ - public function clearToken($service) - { - $service = $this->get_service_name_for_db($service); - - $this->cachedToken = null; - - $sql = 'DELETE FROM ' . $this->oauth_token_table . ' - WHERE user_id = ' . (int) $this->user->data['user_id'] . " - AND provider = '" . $this->db->sql_escape($service) . "'"; - - if ((int) $this->user->data['user_id'] === ANONYMOUS) - { - $sql .= " AND session_id = '" . $this->db->sql_escape($this->user->data['session_id']) . "'"; - } - - $this->db->sql_query($sql); - - return $this; - } - - /** - * {@inheritdoc} - */ - public function clearAllTokens() - { - $this->cachedToken = null; - - $sql = 'DELETE FROM ' . $this->oauth_token_table . ' - WHERE user_id = ' . (int) $this->user->data['user_id']; - - if ((int) $this->user->data['user_id'] === ANONYMOUS) - { - $sql .= " AND session_id = '" . $this->db->sql_escape($this->user->data['session_id']) . "'"; - } - - $this->db->sql_query($sql); - - return $this; - } - - /** - * {@inheritdoc} - */ - public function storeAuthorizationState($service, $state) - { - $service = $this->get_service_name_for_db($service); - - $this->cachedState = $state; - - $data = [ - 'user_id' => (int) $this->user->data['user_id'], - 'provider' => $service, - 'oauth_state' => $state, - 'session_id' => $this->user->data['session_id'], - ]; - - $sql = 'INSERT INTO ' . $this->oauth_state_table . ' ' . $this->db->sql_build_array('INSERT', $data); - $this->db->sql_query($sql); - - return $this; - } - - /** - * {@inheritdoc} - */ - public function hasAuthorizationState($service) - { - $service = $this->get_service_name_for_db($service); - - if ($this->cachedState) - { - return true; - } - - $data = [ - 'user_id' => (int) $this->user->data['user_id'], - 'provider' => $service, - ]; - - if ((int) $this->user->data['user_id'] === ANONYMOUS) - { - $data['session_id'] = $this->user->data['session_id']; - } - - return (bool) $this->get_state_row($data); - } - - /** - * {@inheritdoc} - */ - public function retrieveAuthorizationState($service) - { - $service = $this->get_service_name_for_db($service); - - if ($this->cachedState) - { - return $this->cachedState; - } - - $data = [ - 'user_id' => (int) $this->user->data['user_id'], - 'provider' => $service, - ]; - - if ((int) $this->user->data['user_id'] === ANONYMOUS) - { - $data['session_id'] = $this->user->data['session_id']; - } - - return $this->get_state_row($data); - } - - /** - * {@inheritdoc} - */ - public function clearAuthorizationState($service) - { - $service = $this->get_service_name_for_db($service); - - $this->cachedState = null; - - $sql = 'DELETE FROM ' . $this->oauth_state_table . ' - WHERE user_id = ' . (int) $this->user->data['user_id'] . " - AND provider = '" . $this->db->sql_escape($service) . "'"; - - if ((int) $this->user->data['user_id'] === ANONYMOUS) - { - $sql .= " AND session_id = '" . $this->db->sql_escape($this->user->data['session_id']) . "'"; - } - - $this->db->sql_query($sql); - - return $this; - } - - /** - * {@inheritdoc} - */ - public function clearAllAuthorizationStates() - { - $this->cachedState = null; - - $sql = 'DELETE FROM ' . $this->oauth_state_table . ' - WHERE user_id = ' . (int) $this->user->data['user_id']; - - if ((int) $this->user->data['user_id'] === ANONYMOUS) - { - $sql .= " AND session_id = '" . $this->db->sql_escape($this->user->data['session_id']) . "'"; - } - - $this->db->sql_query($sql); - - return $this; - } - - /** - * Updates the user_id field in the database associated with the token. - * - * @param int $user_id The user identifier - * @return void - */ - public function set_user_id($user_id) - { - if (!$this->cachedToken) - { - return; - } - - $data = [ - 'user_id' => (int) $user_id, - ]; - - $sql = 'UPDATE ' . $this->oauth_token_table . ' - SET ' . $this->db->sql_build_array('UPDATE', $data) . ' - WHERE user_id = ' . (int) $this->user->data['user_id'] . " - AND session_id = '" . $this->db->sql_escape($this->user->data['session_id']) . "'"; - $this->db->sql_query($sql); - } - - /** - * Checks to see if an access token exists solely by the session_id of the user. - * - * @param string $service The OAuth service name - * @return bool true if the user's access token exists, - * false if the user's access token does not exist - */ - public function has_access_token_by_session($service) - { - $service = $this->get_service_name_for_db($service); - - if ($this->cachedToken) - { - return true; - } - - $data = [ - 'session_id' => $this->user->data['session_id'], - 'provider' => $service, - ]; - - return $this->has_access_token($data); - } - - /** - * Checks to see if a state exists solely by the session_id of the user. - * - * @param string $service The OAuth service name - * @return bool true if the user's state exists, - * false if the user's state does not exist - */ - public function has_state_by_session($service) - { - $service = $this->get_service_name_for_db($service); - - if ($this->cachedState) - { - return true; - } - - $data = [ - 'session_id' => $this->user->data['session_id'], - 'provider' => $service, - ]; - - return (bool) $this->get_state_row($data); - } - - /** - * A helper function that performs the query for has access token functions. - * - * @param array $data The SQL WHERE data - * @return bool true if the user's access token exists, - * false if the user's access token does not exist - */ - protected function has_access_token($data) - { - return (bool) $this->get_access_token_row($data); - } - - /** - * A helper function that performs the query for retrieving access token functions by session. - * Also checks if the token is a valid token. - * - * @param string $service The OAuth service provider name - * @return TokenInterface - * @throws TokenNotFoundException - */ - public function retrieve_access_token_by_session($service) - { - $service = $this->get_service_name_for_db($service); - - if ($this->cachedToken instanceof TokenInterface) - { - return $this->cachedToken; - } - - $data = [ - 'session_id' => $this->user->data['session_id'], - 'provider' => $service, - ]; - - return $this->_retrieve_access_token($data); - } - - /** - * A helper function that performs the query for retrieving state functions by session. - * - * @param string $service The OAuth service provider name - * @return string The OAuth state - * @throws AuthorizationStateNotFoundException - */ - public function retrieve_state_by_session($service) - { - $service = $this->get_service_name_for_db($service); - - if ($this->cachedState) - { - return $this->cachedState; - } - - $data = [ - 'session_id' => $this->user->data['session_id'], - 'provider' => $service, - ]; - - return $this->_retrieve_state($data); - } - - /** - * A helper function that performs the query for retrieve access token functions. - * Also checks if the token is a valid token. - * - * @param array $data The SQL WHERE data - * @return TokenInterface - * @throws TokenNotFoundException - */ - protected function _retrieve_access_token($data) - { - $row = $this->get_access_token_row($data); - - if (!$row) - { - throw new TokenNotFoundException('AUTH_PROVIDER_OAUTH_TOKEN_ERROR_NOT_STORED'); - } - - $token = $this->json_decode_token($row['oauth_token']); - - // Ensure that the token was serialized/unserialized correctly - if (!($token instanceof TokenInterface)) - { - $this->clearToken($data['provider']); - - throw new TokenNotFoundException('AUTH_PROVIDER_OAUTH_TOKEN_ERROR_INCORRECTLY_STORED'); - } - - $this->cachedToken = $token; - - return $token; - } - - /** - * A helper function that performs the query for retrieve state functions. - * - * @param array $data The SQL WHERE data - * @return string The OAuth state - * @throws AuthorizationStateNotFoundException - */ - protected function _retrieve_state($data) - { - $row = $this->get_state_row($data); - - if (!$row) - { - throw new AuthorizationStateNotFoundException(); - } - - $this->cachedState = $row['oauth_state']; - - return $this->cachedState; - } - - /** - * A helper function that performs the query for retrieving an access token. - * - * @param array $data The SQL WHERE data - * @return array|false array with the OAuth token row, - * false if the token does not exist - */ - protected function get_access_token_row($data) - { - $sql = 'SELECT oauth_token - FROM ' . $this->oauth_token_table . ' - WHERE ' . $this->db->sql_build_array('SELECT', $data); - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - return $row; - } - - /** - * A helper function that performs the query for retrieving a state. - * - * @param array $data The SQL WHERE data - * @return array|false array with the OAuth state row, - * false if the state does not exist - */ - protected function get_state_row($data) - { - $sql = 'SELECT oauth_state - FROM ' . $this->oauth_state_table . ' - WHERE ' . $this->db->sql_build_array('SELECT', $data); - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - return $row; - } - - /** - * A helper function that JSON encodes a TokenInterface's data. - * - * @param TokenInterface $token - * @return string The json encoded TokenInterface's data - */ - public function json_encode_token(TokenInterface $token) - { - $members = [ - 'accessToken' => $token->getAccessToken(), - 'endOfLife' => $token->getEndOfLife(), - 'extraParams' => $token->getExtraParams(), - 'refreshToken' => $token->getRefreshToken(), - - 'token_class' => get_class($token), - ]; - - // Handle additional data needed for OAuth1 tokens - if ($token instanceof StdOAuth1Token) - { - $members['requestToken'] = $token->getRequestToken(); - $members['requestTokenSecret'] = $token->getRequestTokenSecret(); - $members['accessTokenSecret'] = $token->getAccessTokenSecret(); - } - - return json_encode($members); - } - - /** - * A helper function that JSON decodes a data string and creates a TokenInterface. - * - * @param string $json The json encoded TokenInterface's data - * @return TokenInterface - * @throws TokenNotFoundException - */ - public function json_decode_token($json) - { - $token_data = json_decode($json, true); - - if ($token_data === null) - { - throw new TokenNotFoundException('AUTH_PROVIDER_OAUTH_TOKEN_ERROR_INCORRECTLY_STORED'); - } - - $token_class = $token_data['token_class']; - $access_token = $token_data['accessToken']; - $refresh_token = $token_data['refreshToken']; - $endOfLife = $token_data['endOfLife']; - $extra_params = $token_data['extraParams']; - - /** - * Create the token - * @var TokenInterface $token - */ - $token = new $token_class($access_token, $refresh_token, TokenInterface::EOL_NEVER_EXPIRES, $extra_params); - $token->setEndOfLife($endOfLife); - - // Handle OAuth 1.0 specific elements - if ($token instanceof StdOAuth1Token) - { - $token->setRequestToken($token_data['requestToken']); - $token->setRequestTokenSecret($token_data['requestTokenSecret']); - $token->setAccessTokenSecret($token_data['accessTokenSecret']); - } - - return $token; - } - - /** - * Returns the service name as it must be stored in the database. - * - * @param string $provider The OAuth provider name - * @return string The OAuth service name - */ - protected function get_service_name_for_db($provider) - { - // Enforce the naming convention for oauth services - if (strpos($provider, 'auth.provider.oauth.service.') !== 0) - { - $provider = 'auth.provider.oauth.service.' . strtolower($provider); - } - - return $provider; - } -} diff --git a/install/update/new/phpbb/auth/provider/provider_interface.php b/install/update/new/phpbb/auth/provider/provider_interface.php deleted file mode 100644 index 21c73a3..0000000 --- a/install/update/new/phpbb/auth/provider/provider_interface.php +++ /dev/null @@ -1,198 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\auth\provider; - -/** -* The interface authentication provider classes have to implement. -*/ -interface provider_interface -{ - /** - * Checks whether the user is currently identified to the authentication - * provider. - * Called in acp_board while setting authentication plugins. - * Changing to an authentication provider will not be permitted in acp_board - * if there is an error. - * - * @return boolean|string False if the user is identified, otherwise an - * error message, or null if not implemented. - */ - public function init(); - - /** - * Performs login. - * - * @param string $username The name of the user being authenticated. - * @param string $password The password of the user. - * @return array An associative array of the format: - * array( - * 'status' => status constant - * 'error_msg' => string - * 'user_row' => array - * ) - * A fourth key of the array may be present: - * 'redirect_data' This key is only used when 'status' is - * equal to LOGIN_SUCCESS_LINK_PROFILE and its value is an - * associative array that is turned into GET variables on - * the redirect url. - */ - public function login($username, $password); - - /** - * Autologin function - * - * @return array|null containing the user row, empty if no auto login - * should take place, or null if not implemented. - */ - public function autologin(); - - /** - * This function is used to output any required fields in the authentication - * admin panel. It also defines any required configuration table fields. - * - * @return array|null Returns null if not implemented or an array of the - * configuration fields of the provider. - */ - public function acp(); - - /** - * This function updates the template with variables related to the acp - * options with whatever configuration values are passed to it as an array. - * It then returns the name of the acp file related to this authentication - * provider. - * - * @param \phpbb\config\config $new_config Contains the new configuration values - * that have been set in acp_board. - * @return array|null Returns null if not implemented or an array with - * the template file name and an array of the vars - * that the template needs that must conform to the - * following example: - * array( - * 'TEMPLATE_FILE' => string, - * 'TEMPLATE_VARS' => array(...), - * ) - * An optional third element may be added to this - * array: 'BLOCK_VAR_NAME'. If this is present, - * then its value should be a string that is used - * to designate the name of the loop used in the - * ACP template file. When this is present, an - * additional key named 'BLOCK_VARS' is required. - * This must be an array containing at least one - * array of variables that will be assigned during - * the loop in the template. An example of this is - * presented below: - * array( - * 'BLOCK_VAR_NAME' => string, - * 'BLOCK_VARS' => array( - * 'KEY IS UNIMPORTANT' => array(...), - * ), - * 'TEMPLATE_FILE' => string, - * 'TEMPLATE_VARS' => array(...), - * ) - */ - public function get_acp_template($new_config); - - /** - * Returns an array of data necessary to build custom elements on the login - * form. - * - * @return array|null If this function is not implemented on an auth - * provider then it returns null. If it is implemented - * it will return an array of up to four elements of - * which only 'TEMPLATE_FILE'. If 'BLOCK_VAR_NAME' is - * present then 'BLOCK_VARS' must also be present in - * the array. The fourth element 'VARS' is also - * optional. The array, with all four elements present - * looks like the following: - * array( - * 'TEMPLATE_FILE' => string, - * 'BLOCK_VAR_NAME' => string, - * 'BLOCK_VARS' => array(...), - * 'VARS' => array(...), - * ) - */ - public function get_login_data(); - - /** - * Performs additional actions during logout. - * - * @param array $data An array corresponding to - * \phpbb\session::data - * @param boolean $new_session True for a new session, false for no new - * session. - */ - public function logout($data, $new_session); - - /** - * The session validation function checks whether the user is still logged - * into phpBB. - * - * @param array $user - * @return boolean true if the given user is authenticated, false if the - * session should be closed, or null if not implemented. - */ - public function validate_session($user); - - /** - * Checks to see if $login_link_data contains all information except for the - * user_id of an account needed to successfully link an external account to - * a forum account. - * - * @param array $login_link_data Any data needed to link a phpBB account to - * an external account. - * @return string|null Returns a string with a language constant if there - * is data missing or null if there is no error. - */ - public function login_link_has_necessary_data($login_link_data); - - /** - * Links an external account to a phpBB account. - * - * @param array $link_data Any data needed to link a phpBB account to - * an external account. - */ - public function link_account(array $link_data); - - /** - * Returns an array of data necessary to build the ucp_auth_link page - * - * @param int $user_id User ID for whom the data should be retrieved. - * defaults to 0, which is not a valid ID. The method - * should fall back to the current user's ID in this - * case. - * @return array|null If this function is not implemented on an auth - * provider then it returns null. If it is implemented - * it will return an array of up to four elements of - * which only 'TEMPLATE_FILE'. If 'BLOCK_VAR_NAME' is - * present then 'BLOCK_VARS' must also be present in - * the array. The fourth element 'VARS' is also - * optional. The array, with all four elements present - * looks like the following: - * array( - * 'TEMPLATE_FILE' => string, - * 'BLOCK_VAR_NAME' => string, - * 'BLOCK_VARS' => array(...), - * 'VARS' => array(...), - * ) - */ - public function get_auth_link_data($user_id = 0); - - /** - * Unlinks an external account from a phpBB account. - * - * @param array $link_data Any data needed to unlink a phpBB account - * from a phpbb account. - */ - public function unlink_account(array $link_data); -} diff --git a/install/update/new/phpbb/avatar/driver/remote.php b/install/update/new/phpbb/avatar/driver/remote.php deleted file mode 100644 index b16549f..0000000 --- a/install/update/new/phpbb/avatar/driver/remote.php +++ /dev/null @@ -1,236 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\avatar\driver; - -/** -* Handles avatars hosted remotely -*/ -class remote extends \phpbb\avatar\driver\driver -{ - /** - * {@inheritdoc} - */ - public function get_data($row) - { - return array( - 'src' => $row['avatar'], - 'width' => $row['avatar_width'], - 'height' => $row['avatar_height'], - ); - } - - /** - * {@inheritdoc} - */ - public function prepare_form($request, $template, $user, $row, &$error) - { - $template->assign_vars(array( - 'AVATAR_REMOTE_WIDTH' => ((in_array($row['avatar_type'], array(AVATAR_REMOTE, $this->get_name(), 'remote'))) && $row['avatar_width']) ? $row['avatar_width'] : $request->variable('avatar_remote_width', ''), - 'AVATAR_REMOTE_HEIGHT' => ((in_array($row['avatar_type'], array(AVATAR_REMOTE, $this->get_name(), 'remote'))) && $row['avatar_height']) ? $row['avatar_height'] : $request->variable('avatar_remote_width', ''), - 'AVATAR_REMOTE_URL' => ((in_array($row['avatar_type'], array(AVATAR_REMOTE, $this->get_name(), 'remote'))) && $row['avatar']) ? $row['avatar'] : '', - )); - - return true; - } - - /** - * {@inheritdoc} - */ - public function process_form($request, $template, $user, $row, &$error) - { - global $phpbb_dispatcher; - - $url = $request->variable('avatar_remote_url', ''); - $width = $request->variable('avatar_remote_width', 0); - $height = $request->variable('avatar_remote_height', 0); - - if (empty($url)) - { - return false; - } - - if (!preg_match('#^(http|https|ftp)://#i', $url)) - { - $url = 'http://' . $url; - } - - if (!function_exists('validate_data')) - { - require($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext); - } - - $validate_array = validate_data( - array( - 'url' => $url, - ), - array( - 'url' => array('string', true, 5, 255), - ) - ); - - $error = array_merge($error, $validate_array); - - if (!empty($error)) - { - return false; - } - - /** - * Event to make custom validation of avatar upload - * - * @event core.ucp_profile_avatar_upload_validation - * @var string url Image url - * @var string width Image width - * @var string height Image height - * @var array error Error message array - * @since 3.2.9-RC1 - */ - $vars = array('url', 'width', 'height', 'error'); - extract($phpbb_dispatcher->trigger_event('core.ucp_profile_avatar_upload_validation', compact($vars))); - - if (!empty($error)) - { - return false; - } - - // Check if this url looks alright - // Do not allow specifying the port (see RFC 3986) or IP addresses - if (!preg_match('#^(http|https|ftp)://(?:(.*?\.)*?[a-z0-9\-]+?\.[a-z]{2,4}|(?:\d{1,3}\.){3,5}\d{1,3}):?([0-9]*?).*?\.('. implode('|', $this->allowed_extensions) . ')$#i', $url) || - preg_match('@^(http|https|ftp)://[^/:?#]+:[0-9]+[/:?#]@i', $url) || - preg_match('#^(http|https|ftp)://(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])#i', $url) || - preg_match('#^(http|https|ftp)://(?:(?:(?:[\dA-F]{1,4}:){6}(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:::(?:[\dA-F]{1,4}:){0,5}(?:[\dA-F]{1,4}(?::[\dA-F]{1,4})?|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:):(?:[\dA-F]{1,4}:){4}(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,2}:(?:[\dA-F]{1,4}:){3}(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,3}:(?:[\dA-F]{1,4}:){2}(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,4}:(?:[\dA-F]{1,4}:)(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,5}:(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,6}:[\dA-F]{1,4})|(?:(?:[\dA-F]{1,4}:){1,7}:)|(?:::))#i', $url)) - { - $error[] = 'AVATAR_URL_INVALID'; - return false; - } - - // Get image dimensions - if (($width <= 0 || $height <= 0) && (($image_data = $this->imagesize->getImageSize($url)) === false)) - { - $error[] = 'UNABLE_GET_IMAGE_SIZE'; - return false; - } - - if (!empty($image_data) && ($image_data['width'] <= 0 || $image_data['height'] <= 0)) - { - $error[] = 'AVATAR_NO_SIZE'; - return false; - } - - $width = ($width && $height) ? $width : $image_data['width']; - $height = ($width && $height) ? $height : $image_data['height']; - - if ($width <= 0 || $height <= 0) - { - $error[] = 'AVATAR_NO_SIZE'; - return false; - } - - $types = \phpbb\files\upload::image_types(); - $extension = strtolower(\phpbb\files\filespec::get_extension($url)); - - // Check if this is actually an image - if ($file_stream = @fopen($url, 'r')) - { - // Timeout after 1 second - stream_set_timeout($file_stream, 1); - // read some data to ensure headers are present - fread($file_stream, 1024); - $meta = stream_get_meta_data($file_stream); - - if (isset($meta['wrapper_data']['headers']) && is_array($meta['wrapper_data']['headers'])) - { - $headers = $meta['wrapper_data']['headers']; - } - else if (isset($meta['wrapper_data']) && is_array($meta['wrapper_data'])) - { - $headers = $meta['wrapper_data']; - } - else - { - $headers = array(); - } - - foreach ($headers as $header) - { - $header = preg_split('/ /', $header, 2); - if (strtr(strtolower(trim($header[0], ':')), '_', '-') === 'content-type') - { - if (strpos($header[1], 'image/') !== 0) - { - $error[] = 'AVATAR_URL_INVALID'; - fclose($file_stream); - return false; - } - else - { - fclose($file_stream); - break; - } - } - } - } - else - { - $error[] = 'AVATAR_URL_INVALID'; - return false; - } - - if (!empty($image_data) && (!isset($types[$image_data['type']]) || !in_array($extension, $types[$image_data['type']]))) - { - if (!isset($types[$image_data['type']])) - { - $error[] = 'UNABLE_GET_IMAGE_SIZE'; - } - else - { - $error[] = array('IMAGE_FILETYPE_MISMATCH', $types[$image_data['type']][0], $extension); - } - - return false; - } - - if ($this->config['avatar_max_width'] || $this->config['avatar_max_height']) - { - if ($width > $this->config['avatar_max_width'] || $height > $this->config['avatar_max_height']) - { - $error[] = array('AVATAR_WRONG_SIZE', $this->config['avatar_min_width'], $this->config['avatar_min_height'], $this->config['avatar_max_width'], $this->config['avatar_max_height'], $width, $height); - return false; - } - } - - if ($this->config['avatar_min_width'] || $this->config['avatar_min_height']) - { - if ($width < $this->config['avatar_min_width'] || $height < $this->config['avatar_min_height']) - { - $error[] = array('AVATAR_WRONG_SIZE', $this->config['avatar_min_width'], $this->config['avatar_min_height'], $this->config['avatar_max_width'], $this->config['avatar_max_height'], $width, $height); - return false; - } - } - - return array( - 'avatar' => $url, - 'avatar_width' => $width, - 'avatar_height' => $height, - ); - } - - /** - * {@inheritdoc} - */ - public function get_template_name() - { - return 'ucp_avatar_options_remote.html'; - } -} diff --git a/install/update/new/phpbb/avatar/driver/upload.php b/install/update/new/phpbb/avatar/driver/upload.php deleted file mode 100644 index a5b704b..0000000 --- a/install/update/new/phpbb/avatar/driver/upload.php +++ /dev/null @@ -1,332 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\avatar\driver; - -/** -* Handles avatars uploaded to the board -*/ -class upload extends \phpbb\avatar\driver\driver -{ - /** - * @var \phpbb\filesystem\filesystem_interface - */ - protected $filesystem; - - /** - * @var \phpbb\event\dispatcher_interface - */ - protected $dispatcher; - - /** - * @var \phpbb\files\factory - */ - protected $files_factory; - - /** - * Construct a driver object - * - * @param \phpbb\config\config $config phpBB configuration - * @param string $phpbb_root_path Path to the phpBB root - * @param string $php_ext PHP file extension - * @param \phpbb\filesystem\filesystem_interface $filesystem phpBB filesystem helper - * @param \phpbb\path_helper $path_helper phpBB path helper - * @param \phpbb\event\dispatcher_interface $dispatcher phpBB Event dispatcher object - * @param \phpbb\files\factory $files_factory File classes factory - * @param \phpbb\cache\driver\driver_interface $cache Cache driver - */ - public function __construct(\phpbb\config\config $config, $phpbb_root_path, $php_ext, \phpbb\filesystem\filesystem_interface $filesystem, \phpbb\path_helper $path_helper, \phpbb\event\dispatcher_interface $dispatcher, \phpbb\files\factory $files_factory, \phpbb\cache\driver\driver_interface $cache = null) - { - $this->config = $config; - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - $this->filesystem = $filesystem; - $this->path_helper = $path_helper; - $this->dispatcher = $dispatcher; - $this->files_factory = $files_factory; - $this->cache = $cache; - } - - /** - * {@inheritdoc} - */ - public function get_data($row) - { - $root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $this->path_helper->get_web_root_path(); - - return array( - 'src' => $root_path . 'download/file.' . $this->php_ext . '?avatar=' . $row['avatar'], - 'width' => $row['avatar_width'], - 'height' => $row['avatar_height'], - ); - } - - /** - * {@inheritdoc} - */ - public function prepare_form($request, $template, $user, $row, &$error) - { - if (!$this->can_upload()) - { - return false; - } - - $template->assign_vars(array( - 'S_UPLOAD_AVATAR_URL' => ($this->config['allow_avatar_remote_upload']) ? true : false, - 'AVATAR_UPLOAD_SIZE' => $this->config['avatar_filesize'], - 'AVATAR_ALLOWED_EXTENSIONS' => implode(',', preg_replace('/^/', '.', $this->allowed_extensions)), - )); - - return true; - } - - /** - * {@inheritdoc} - */ - public function process_form($request, $template, $user, $row, &$error) - { - if (!$this->can_upload()) - { - return false; - } - - /** @var \phpbb\files\upload $upload */ - $upload = $this->files_factory->get('upload') - ->set_error_prefix('AVATAR_') - ->set_allowed_extensions($this->allowed_extensions) - ->set_max_filesize($this->config['avatar_filesize']) - ->set_allowed_dimensions( - $this->config['avatar_min_width'], - $this->config['avatar_min_height'], - $this->config['avatar_max_width'], - $this->config['avatar_max_height']) - ->set_disallowed_content((isset($this->config['mime_triggers']) ? explode('|', $this->config['mime_triggers']) : false)); - - $url = $request->variable('avatar_upload_url', ''); - $upload_file = $request->file('avatar_upload_file'); - - if (!empty($upload_file['name'])) - { - $file = $upload->handle_upload('files.types.form', 'avatar_upload_file'); - } - else if (!empty($this->config['allow_avatar_remote_upload']) && !empty($url)) - { - if (!preg_match('#^(http|https|ftp)://#i', $url)) - { - $url = 'http://' . $url; - } - - if (!function_exists('validate_data')) - { - require($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext); - } - - $validate_array = validate_data( - array( - 'url' => $url, - ), - array( - 'url' => array('string', true, 5, 255), - ) - ); - - $error = array_merge($error, $validate_array); - - if (!empty($error)) - { - return false; - } - - // Do not allow specifying the port (see RFC 3986) or IP addresses - // remote_upload() will do its own check for allowed filetypes - if (!preg_match('#^(http|https|ftp)://(?:(.*?\.)*?[a-z0-9\-]+?\.[a-z]{2,4}|(?:\d{1,3}\.){3,5}\d{1,3}):?([0-9]*?).*?\.('. implode('|', $this->allowed_extensions) . ')$#i', $url) || - preg_match('@^(http|https|ftp)://[^/:?#]+:[0-9]+[/:?#]@i', $url) || - preg_match('#^(http|https|ftp)://(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])#i', $url) || - preg_match('#^(http|https|ftp)://(?:(?:(?:[\dA-F]{1,4}:){6}(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:::(?:[\dA-F]{1,4}:){0,5}(?:[\dA-F]{1,4}(?::[\dA-F]{1,4})?|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:):(?:[\dA-F]{1,4}:){4}(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,2}:(?:[\dA-F]{1,4}:){3}(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,3}:(?:[\dA-F]{1,4}:){2}(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,4}:(?:[\dA-F]{1,4}:)(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,5}:(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,6}:[\dA-F]{1,4})|(?:(?:[\dA-F]{1,4}:){1,7}:)|(?:::))#i', $url)) - { - $error[] = 'AVATAR_URL_INVALID'; - return false; - } - - $file = $upload->handle_upload('files.types.remote', $url); - } - else - { - return false; - } - - $prefix = $this->config['avatar_salt'] . '_'; - $file->clean_filename('avatar', $prefix, $row['id']); - - // If there was an error during upload, then abort operation - if (count($file->error)) - { - $file->remove(); - $error = $file->error; - return false; - } - - // Calculate new destination - $destination = $this->config['avatar_path']; - - // Adjust destination path (no trailing slash) - if (substr($destination, -1, 1) == '/' || substr($destination, -1, 1) == '\\') - { - $destination = substr($destination, 0, -1); - } - - $destination = str_replace(array('../', '..\\', './', '.\\'), '', $destination); - if ($destination && ($destination[0] == '/' || $destination[0] == "\\")) - { - $destination = ''; - } - - $filedata = array( - 'filename' => $file->get('filename'), - 'filesize' => $file->get('filesize'), - 'mimetype' => $file->get('mimetype'), - 'extension' => $file->get('extension'), - 'physical_filename' => $file->get('realname'), - 'real_filename' => $file->get('uploadname'), - ); - - /** - * Before moving new file in place (and eventually overwriting the existing avatar with the newly uploaded avatar) - * - * @event core.avatar_driver_upload_move_file_before - * @var array filedata Array containing uploaded file data - * @var \phpbb\files\filespec file Instance of filespec class - * @var string destination Destination directory where the file is going to be moved - * @var string prefix Prefix for the avatar filename - * @var array row Array with avatar row data - * @var array error Array of errors, if filled in by this event file will not be moved - * @since 3.1.6-RC1 - * @changed 3.1.9-RC1 Added filedata - * @changed 3.2.3-RC1 Added file - */ - $vars = array( - 'filedata', - 'file', - 'destination', - 'prefix', - 'row', - 'error', - ); - extract($this->dispatcher->trigger_event('core.avatar_driver_upload_move_file_before', compact($vars))); - - unset($filedata); - - if (!count($error)) - { - // Move file and overwrite any existing image - $file->move_file($destination, true); - } - - // If there was an error during move, then clean up leftovers - $error = array_merge($error, $file->error); - if (count($error)) - { - $file->remove(); - return false; - } - - // Delete current avatar if not overwritten - $ext = substr(strrchr($row['avatar'], '.'), 1); - if ($ext && $ext !== $file->get('extension')) - { - $this->delete($row); - } - - return array( - 'avatar' => $row['id'] . '_' . time() . '.' . $file->get('extension'), - 'avatar_width' => $file->get('width'), - 'avatar_height' => $file->get('height'), - ); - } - - /** - * {@inheritdoc} - */ - public function prepare_form_acp($user) - { - return array( - 'allow_avatar_remote_upload'=> array('lang' => 'ALLOW_REMOTE_UPLOAD', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'avatar_filesize' => array('lang' => 'MAX_FILESIZE', 'validate' => 'int:0', 'type' => 'number:0', 'explain' => true, 'append' => ' ' . $user->lang['BYTES']), - 'avatar_path' => array('lang' => 'AVATAR_STORAGE_PATH', 'validate' => 'rpath', 'type' => 'text:20:255', 'explain' => true), - ); - } - - /** - * {@inheritdoc} - */ - public function delete($row) - { - - $error = array(); - $destination = $this->config['avatar_path']; - $prefix = $this->config['avatar_salt'] . '_'; - $ext = substr(strrchr($row['avatar'], '.'), 1); - $filename = $this->phpbb_root_path . $destination . '/' . $prefix . $row['id'] . '.' . $ext; - - /** - * Before deleting an existing avatar - * - * @event core.avatar_driver_upload_delete_before - * @var string destination Destination directory where the file is going to be deleted - * @var string prefix Prefix for the avatar filename - * @var array row Array with avatar row data - * @var array error Array of errors, if filled in by this event file will not be deleted - * @since 3.1.6-RC1 - */ - $vars = array( - 'destination', - 'prefix', - 'row', - 'error', - ); - extract($this->dispatcher->trigger_event('core.avatar_driver_upload_delete_before', compact($vars))); - - if (!count($error) && $this->filesystem->exists($filename)) - { - try - { - $this->filesystem->remove($filename); - return true; - } - catch (\phpbb\filesystem\exception\filesystem_exception $e) - { - // Fail is covered by return statement below - } - } - - return false; - } - - /** - * {@inheritdoc} - */ - public function get_template_name() - { - return 'ucp_avatar_options_upload.html'; - } - - /** - * Check if user is able to upload an avatar - * - * @return bool True if user can upload, false if not - */ - protected function can_upload() - { - return ($this->filesystem->exists($this->phpbb_root_path . $this->config['avatar_path']) && $this->filesystem->is_writable($this->phpbb_root_path . $this->config['avatar_path']) && (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on')); - } -} diff --git a/install/update/new/phpbb/cache/driver/memcached.php b/install/update/new/phpbb/cache/driver/memcached.php deleted file mode 100644 index fbb587a..0000000 --- a/install/update/new/phpbb/cache/driver/memcached.php +++ /dev/null @@ -1,148 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\cache\driver; - -if (!defined('PHPBB_ACM_MEMCACHED_PORT')) -{ - define('PHPBB_ACM_MEMCACHED_PORT', 11211); -} - -if (!defined('PHPBB_ACM_MEMCACHED_COMPRESS')) -{ - define('PHPBB_ACM_MEMCACHED_COMPRESS', true); -} - -if (!defined('PHPBB_ACM_MEMCACHED_HOST')) -{ - define('PHPBB_ACM_MEMCACHED_HOST', 'localhost'); -} - -if (!defined('PHPBB_ACM_MEMCACHED')) -{ - //can define multiple servers with host1/port1,host2/port2 format - define('PHPBB_ACM_MEMCACHED', PHPBB_ACM_MEMCACHED_HOST . '/' . PHPBB_ACM_MEMCACHED_PORT); -} - -/** -* ACM for Memcached -*/ -class memcached extends \phpbb\cache\driver\memory -{ - /** @var string Extension to use */ - protected $extension = 'memcached'; - - /** @var \Memcached Memcached class */ - protected $memcached; - - /** @var int Flags */ - protected $flags = 0; - - /** - * Memcached constructor - * - * @param string $memcached_servers Memcached servers string (optional) - */ - public function __construct($memcached_servers = '') - { - // Call the parent constructor - parent::__construct(); - - $memcached_servers = $memcached_servers ?: PHPBB_ACM_MEMCACHED; - - $this->memcached = new \Memcached(); - $this->memcached->setOption(\Memcached::OPT_BINARY_PROTOCOL, true); - // Memcached defaults to using compression, disable if we don't want - // to use it - if (!PHPBB_ACM_MEMCACHED_COMPRESS) - { - $this->memcached->setOption(\Memcached::OPT_COMPRESSION, false); - } - - $server_list = []; - foreach (explode(',', $memcached_servers) as $u) - { - if (preg_match('#(.*)/(\d+)#', $u, $parts)) - { - $server_list[] = [trim($parts[1]), (int) trim($parts[2])]; - } - } - - $this->memcached->addServers($server_list); - - if (empty($server_list) || empty($this->memcached->getStats())) - { - trigger_error('Could not connect to memcached server(s).'); - } - } - - /** - * {@inheritDoc} - */ - public function unload() - { - parent::unload(); - - unset($this->memcached); - } - - /** - * {@inheritDoc} - */ - public function purge() - { - $this->memcached->flush(); - - parent::purge(); - } - - /** - * Fetch an item from the cache - * - * @param string $var Cache key - * - * @return mixed Cached data - */ - protected function _read($var) - { - return $this->memcached->get($this->key_prefix . $var); - } - - /** - * Store data in the cache - * - * @param string $var Cache key - * @param mixed $data Data to store - * @param int $ttl Time-to-live of cached data - * @return bool True if the operation succeeded - */ - protected function _write($var, $data, $ttl = 2592000) - { - if (!$this->memcached->replace($this->key_prefix . $var, $data, $ttl)) - { - return $this->memcached->set($this->key_prefix . $var, $data, $ttl); - } - return true; - } - - /** - * Remove an item from the cache - * - * @param string $var Cache key - * @return bool True if the operation succeeded - */ - protected function _delete($var) - { - return $this->memcached->delete($this->key_prefix . $var); - } -} diff --git a/install/update/new/phpbb/cache/driver/memory.php b/install/update/new/phpbb/cache/driver/memory.php deleted file mode 100644 index 956936b..0000000 --- a/install/update/new/phpbb/cache/driver/memory.php +++ /dev/null @@ -1,282 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\cache\driver; - -/** -* ACM Abstract Memory Class -*/ -abstract class memory extends \phpbb\cache\driver\base -{ - var $key_prefix; - - /** - * Set cache path - */ - function __construct() - { - global $dbname, $table_prefix, $phpbb_container; - - $this->cache_dir = $phpbb_container->getParameter('core.cache_dir'); - $this->key_prefix = substr(md5($dbname . $table_prefix), 0, 8) . '_'; - - if (!isset($this->extension) || !extension_loaded($this->extension)) - { - global $acm_type; - - trigger_error("Could not find required extension [{$this->extension}] for the ACM module $acm_type.", E_USER_ERROR); - } - - if (isset($this->function) && !function_exists($this->function)) - { - global $acm_type; - - trigger_error("The required function [{$this->function}] is not available for the ACM module $acm_type.", E_USER_ERROR); - } - } - - /** - * {@inheritDoc} - */ - function load() - { - // grab the global cache - $data = $this->_read('global'); - - if ($data !== false) - { - $this->vars = $data; - return true; - } - - return false; - } - - /** - * {@inheritDoc} - */ - function save() - { - if (!$this->is_modified) - { - return; - } - - $this->_write('global', $this->vars, 2592000); - - $this->is_modified = false; - } - - /** - * {@inheritDoc} - */ - function tidy() - { - global $config; - - // cache has auto GC, no need to have any code here :) - $config->set('cache_last_gc', time(), false); - } - - /** - * {@inheritDoc} - */ - function get($var_name) - { - if ($var_name[0] == '_') - { - if (!$this->_exists($var_name)) - { - return false; - } - - return $this->_read($var_name); - } - else - { - return ($this->_exists($var_name)) ? $this->vars[$var_name] : false; - } - } - - /** - * {@inheritDoc} - */ - function put($var_name, $var, $ttl = 2592000) - { - if ($var_name[0] == '_') - { - $this->_write($var_name, $var, $ttl); - } - else - { - $this->vars[$var_name] = $var; - $this->is_modified = true; - } - } - - /** - * {@inheritDoc} - */ - function destroy($var_name, $table = '') - { - if ($var_name == 'sql' && !empty($table)) - { - if (!is_array($table)) - { - $table = array($table); - } - - foreach ($table as $table_name) - { - // gives us the md5s that we want - $temp = $this->_read('sql_' . $table_name); - - if ($temp === false) - { - continue; - } - - // delete each query ref - foreach ($temp as $md5_id => $void) - { - $this->_delete('sql_' . $md5_id); - } - - // delete the table ref - $this->_delete('sql_' . $table_name); - } - - return; - } - - if (!$this->_exists($var_name)) - { - return; - } - - if ($var_name[0] == '_') - { - $this->_delete($var_name); - } - else if (isset($this->vars[$var_name])) - { - $this->is_modified = true; - unset($this->vars[$var_name]); - - // We save here to let the following cache hits succeed - $this->save(); - } - } - - /** - * {@inheritDoc} - */ - function _exists($var_name) - { - if ($var_name[0] == '_') - { - return $this->_isset($var_name); - } - else - { - if (!count($this->vars)) - { - $this->load(); - } - - return isset($this->vars[$var_name]); - } - } - - /** - * {@inheritDoc} - */ - function sql_save(\phpbb\db\driver\driver_interface $db, $query, $query_result, $ttl) - { - // Remove extra spaces and tabs - $query = preg_replace('/[\n\r\s\t]+/', ' ', $query); - $query_id = md5($query); - - // determine which tables this query belongs to - // Some queries use backticks, namely the get_database_size() query - // don't check for conformity, the SQL would error and not reach here. - if (!preg_match_all('/(?:FROM \\(?(`?\\w+`?(?: \\w+)?(?:, ?`?\\w+`?(?: \\w+)?)*)\\)?)|(?:JOIN (`?\\w+`?(?: \\w+)?))/', $query, $regs, PREG_SET_ORDER)) - { - // Bail out if the match fails. - return $query_result; - } - - $tables = array(); - foreach ($regs as $match) - { - if ($match[0][0] == 'F') - { - $tables = array_merge($tables, array_map('trim', explode(',', $match[1]))); - } - else - { - $tables[] = $match[2]; - } - } - - foreach ($tables as $table_name) - { - // Remove backticks - $table_name = ($table_name[0] == '`') ? substr($table_name, 1, -1) : $table_name; - - if (($pos = strpos($table_name, ' ')) !== false) - { - $table_name = substr($table_name, 0, $pos); - } - - $temp = $this->_read('sql_' . $table_name); - - if ($temp === false) - { - $temp = array(); - } - - $temp[$query_id] = true; - - // This must never expire - $this->_write('sql_' . $table_name, $temp, 0); - } - - // store them in the right place - $this->sql_rowset[$query_id] = array(); - $this->sql_row_pointer[$query_id] = 0; - - while ($row = $db->sql_fetchrow($query_result)) - { - $this->sql_rowset[$query_id][] = $row; - } - $db->sql_freeresult($query_result); - - $this->_write('sql_' . $query_id, $this->sql_rowset[$query_id], $ttl); - - return $query_id; - } - - /** - * Check if a cache var exists - * - * @access protected - * @param string $var Cache key - * @return bool True if it exists, otherwise false - */ - function _isset($var) - { - // Most caches don't need to check - return true; - } -} diff --git a/install/update/new/phpbb/captcha/non_gd.php b/install/update/new/phpbb/captcha/non_gd.php deleted file mode 100644 index 8105187..0000000 --- a/install/update/new/phpbb/captcha/non_gd.php +++ /dev/null @@ -1,386 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\captcha; - -/** -* Main non-gd captcha class -* @ignore -*/ -class non_gd -{ - var $filtered_pngs; - var $width = 320; - var $height = 50; - - /** - * Define filtered pngs on init - */ - function __construct() - { - // If we can we will generate a single filtered png, we avoid nastiness via emulation of some Zlib stuff - $this->define_filtered_pngs(); - } - - /** - * Create the image containing $code with a seed of $seed - */ - function execute($code, $seed) - { - $img_height = $this->height - 10; - $img_width = 0; - - mt_srand($seed); - - $char_widths = $hold_chars = array(); - $code_len = strlen($code); - - for ($i = 0; $i < $code_len; $i++) - { - $char = $code[$i]; - - $width = mt_rand(0, 4); - $raw_width = $this->filtered_pngs[$char]['width']; - $char_widths[$i] = $width; - $img_width += $raw_width - $width; - - // Split the char into chunks of $raw_width + 1 length - if (empty($hold_chars[$char])) - { - $hold_chars[$char] = str_split(base64_decode($this->filtered_pngs[$char]['data']), $raw_width + 1); - } - } - - $offset_x = mt_rand(0, $this->width - $img_width); - $offset_y = mt_rand(0, $this->height - $img_height); - - $image = ''; - for ($i = 0; $i < $this->height; $i++) - { - $image .= chr(0); - - if ($i > $offset_y && $i < $offset_y + $img_height) - { - for ($j = 0; $j < $offset_x; $j++) - { - $image .= chr(mt_rand(140, 255)); - } - - for ($j = 0; $j < $code_len; $j++) - { - $image .= $this->randomise(substr($hold_chars[$code[$j]][$i - $offset_y - 1], 1), $char_widths[$j]); - } - - for ($j = $offset_x + $img_width; $j < $this->width; $j++) - { - $image .= chr(mt_rand(140, 255)); - } - } - else - { - for ($j = 0; $j < $this->width; $j++) - { - $image .= chr(mt_rand(140, 255)); - } - } - } - unset($hold_chars); - - $image = $this->create_png($image, $this->width, $this->height); - - // Output image - header('Content-Type: image/png'); - header('Cache-control: no-cache, no-store'); - echo $image; - exit; - } - - /** - * This is designed to randomise the pixels of the image data within - * certain limits so as to keep it readable. It also varies the image - * width a little - */ - function randomise($scanline, $width) - { - $new_line = ''; - - $end = strlen($scanline) - ceil($width/2); - for ($i = (int) floor($width / 2); $i < $end; $i++) - { - $pixel = ord($scanline[$i]); - - if ($pixel < 190) - { - $new_line .= chr(mt_rand(0, 205)); - } - else if ($pixel > 190) - { - $new_line .= chr(mt_rand(145, 255)); - } - else - { - $new_line .= $scanline[$i]; - } - } - - return $new_line; - } - - /** - * This creates a chunk of the given type, with the given data - * of the given length adding the relevant crc - */ - function png_chunk($length, $type, $data) - { - $raw = $type . $data; - - return pack('N', $length) . $raw . pack('N', crc32($raw)); - } - - /** - * Creates greyscale 8bit png - The PNG spec can be found at - * http://www.libpng.org/pub/png/spec/PNG-Contents.html we use - * png because it's a fully recognised open standard and supported - * by practically all modern browsers and OSs - */ - function create_png($raw_image, $width, $height) - { - // SIG - $image = pack('C8', 137, 80, 78, 71, 13, 10, 26, 10); - - // IHDR - $raw = pack('N2', $width, $height); - $raw .= pack('C5', 8, 0, 0, 0, 0); - $image .= $this->png_chunk(13, 'IHDR', $raw); - - // IDAT - if (@extension_loaded('zlib')) - { - $raw_image = gzcompress($raw_image); - $length = strlen($raw_image); - } - else - { - // The total length of this image, uncompressed, is just a calculation of pixels - $length = ($width + 1) * $height; - - // Adler-32 hash generation - // Note: The hash is _backwards_ so we must reverse it - - if (@extension_loaded('hash')) - { - $adler_hash = strrev(hash('adler32', $raw_image, true)); - } - else if (@extension_loaded('mhash')) - { - $adler_hash = strrev(mhash(MHASH_ADLER32, $raw_image)); - } - else - { - // Optimized Adler-32 loop ported from the GNU Classpath project - $temp_length = $length; - $s1 = 1; - $s2 = $index = 0; - - while ($temp_length > 0) - { - // We can defer the modulo operation: - // s1 maximally grows from 65521 to 65521 + 255 * 3800 - // s2 maximally grows by 3800 * median(s1) = 2090079800 < 2^31 - $substract_value = ($temp_length < 3800) ? $temp_length : 3800; - $temp_length -= $substract_value; - - while (--$substract_value >= 0) - { - $s1 += ord($raw_image[$index]); - $s2 += $s1; - - $index++; - } - - $s1 %= 65521; - $s2 %= 65521; - } - $adler_hash = pack('N', ($s2 << 16) | $s1); - } - - // This is the same thing as gzcompress($raw_image, 0) but does not need zlib - $raw_image = pack('C3v2', 0x78, 0x01, 0x01, $length, ~$length) . $raw_image . $adler_hash; - - // The Zlib header + Adler hash make us add on 11 - $length += 11; - } - - // IDAT - $image .= $this->png_chunk($length, 'IDAT', $raw_image); - - // IEND - $image .= $this->png_chunk(0, 'IEND', ''); - - return $image; - } - - /** - * png image data - * Each 'data' element is base64_encoded uncompressed IDAT - */ - function define_filtered_pngs() - { - $this->filtered_pngs = array( - '0' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A///////////////////olFAkBAAAGDyA4P///M31/////////////wD////////////////0dAgAAAAAAAAAAAAEcPipFGHn////////////AP//////////////6DAAAAAAAAAAAAAAAAAALSEAN+T///////////8A//////////////xAAAAAAAAAAAAAAAAAAAAAACPA/////////////wD/////////////oAAAAAAAAAAAAAAAAAAAAAAAev//////////////AP////////////8oAAAAAAAAPNj/zDAAAAAAAABD//////////////8A////////////1AAAAAAAABjw////5BAAAAAAAADo/////////////wD///////////+QAAAAAAAAbP//////QgAAAAAAAKj/////////////AP///////////1wAAAAAAACs/////8AXAAAAAAAAcP////////////8A////////////OAAAAAAAAND////dNwAAAAAAAABI/////////////wD///////////8gAAAAAAAA4P//7koACwAAAAAAACT/////////////AP///////////wgAAAAAAAD///VqAwaPAAAAAAAAEP////////////8A////////////AAAAAAAAAP/8kQYDavUAAAAAAAAA/////////////wD///////////8AAAAAAAAA/6kNAEru/wAAAAAAAAD/////////////AP///////////wAAAAAAAADAIwA33f//AAAAAAAAAP////////////8A////////////FAAAAAAAADYAI8D///8AAAAAAAAQ/////////////wD///////////8kAAAAAAAAAA2p////5AAAAAAAACD/////////////AP///////////0gAAAAAAAAFkfz////UAAAAAAAAQP////////////8A////////////cAAAAAAAAET1/////7AAAAAAAABo/////////////wD///////////+oAAAAAAAAXfX/////sAAAAAAAAGj/////////////AAAAALgAAAAAAAAwAAAAAAAAAAAAAAD////////////oAAAAAAAACOT////oEAAAAAAAAOD/////////////AP////////////8+AAAAAAAAKMz/zDQAAAAAAAA0//////////////8A////////////7jgAAAAAAAAAAAAAAAAAAAAAAKT//////////////wD///////////VqAwIAAAAAAAAAAAAAAAAAAAA8////////////////AP//////////rQcDaVEAAAAAAAAAAAAAAAAAKOj///////////////8A///////////nblnu/IAIAAAAAAAAAAAAAFzw/////////////////wD////////////79////+iITCAAAAAgSITg////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////w==', - 'width' => 40 - ), - '1' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////8BAAAAAAAP//////////////////AP////////////////////////9sAAAAAAAA//////////////////8A////////////////////////pAAAAAAAAAD//////////////////wD//////////////////////6wEAAAAAAAAAP//////////////////AP////////////////////h4AAAAAAAAAAAA//////////////////8A//////////////////ygJAAAAAAAAAAAAAD//////////////////wD//////////////9x8HAAAAAAAAAAAAAAAAP//////////////////AP//////////////AAAAAAAAAAAAAAAAAAAA//////////////////8A//////////////8AAAAAAAAAAAAAAAAAAAD//////////////////wD//////////////wAAAAAAAAR4AAAAAAAAAP//////////////////AP//////////////AAAAAAA4zP8AAAAAAAAA//////////////////8A//////////////8AAAA4sP///wAAAAAAAAD//////////////////wD//////////////yR80P//////AAAAAAAAAP//////////////////AP////////////////////////8AAAAAAAAA//////////////////8A/////////////////////////wAAAAAAAAD//////////////////wD/////////////////////////AAAAAAAAAP//////////////////AP////////////////////////8AAAAAAAAA//////////////////8A/////////////////////////wAAAAAAAAD//////////////////wD/////////////////////////AAAAAAAAAP//////////////////AP////////////////////////8AAAAAAAAA//////////////////8A/////////////////////////wAAAAAAAAD//////////////////wD/////////////////////////AAAAAAAAAP//////////////////AP////////////////////////8AAAAAAAAA//////////////////8A/////////////////////////wAAAAAAAAD//////////////////wD/////////////////////////AAAAAAAAAP//////////////////AP////////////////////////8AAAAAAAAA//////////////////8A/////////////////////////wAAAAAAAAD//////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - '2' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP/////////////////okFAkCAAABCBIfNT///////////////////8A///////////////8hAgAAAAAAAAAAAAAAFTo/////////////////wD//////////////1QAAAAAAAAAAAAAAAAAACjo////////////////AP////////////+MAAAAAAAAAAAAAAAAAAAAADj///////////////8A////////////9BAAAAAAAAAAAAAAAAAAAAAAALD//////////////wD///////////+gAAAAAAAAAHjs+KwMAAAAAAAAVP//////////////AP///////////1gAAAAAAABM/////6QAAAAAAAAU//////////////8A////////////KAAAAAAAALj/////+AAAAAAAAAD//////////////wD///////////+MfGBMOCAI8P/////wAAAAAAAACP//////////////AP///////////////////////////5wAAAAAAAAw//////////////8A///////////////////////////oFAAAAAAAAHz//////////////wD/////////////////////////6CgAAAAAAAAE3P//////////////AP///////////////////////9ggAAAAAAAAAHT///////////////8A//////////////////////+0DAAAAAAAAAA8+P///////////////wD/////////////////////gAAAAAAAAAAAKOj/////////////////AP//////////////////9FAAAAAAAAAAADzw//////////////////8A/////////////////+g4AAAAAAAAAABk/P///////////////////wD////////////////oKAAAAAAAAAAMqP//////////////////////AP//////////////6CgAAAAAAAAAMNz///////////////////////8A//////////////g4AAAAAAAAAFT0/////////////////////////wD/////////////bAAAAAAAAABU/P//////////////////////////AP///////////8wAAAAAAAAAAAAAAAAAAAAAAAAA//////////////8A////////////SAAAAAAAAAAAAAAAAAAAAAAAAAD//////////////wD//////////9wAAAAAAAAAAAAAAAAAAAAAAAAAAP//////////////AP//////////hAAAAAAAAAAAAAAAAAAAAAAAAAAA//////////////8A//////////9AAAAAAAAAAAAAAAAAAAAAAAAAAAD//////////////wD//////////xAAAAAAAAAAAAAAAAAAAAAAAAAAAP//////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - '3' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD////////////////8sGg0FAAAACA4cLz8////////////////////AP//////////////rBgAAAAAAAAAAAAAACTA//////////////////8A/////////////3QAAAAAAAAAAAAAAAAAAASs/////////////////wD///////////+YAAAAAAAAAAAAAAAAAAAAAAjc////////////////AP//////////6AwAAAAAAAAAAAAAAAAAAAAAAGT///////////////8A//////////94AAAAAAAABJDw/8g4AAAAAAAAHP///////////////wD//////////yAAAAAAAACE/////9gAAAAAAAAA////////////////AP///////////NSwiGQ4FOT//////AAAAAAAABD///////////////8A//////////////////////////+YAAAAAAAAVP///////////////wD//////////////////////P/ggAQAAAAAAATM////////////////AP////////////////////9gAAAAAAAAAAAElP////////////////8A/////////////////////0AAAAAAAAAAHLj//////////////////wD/////////////////////OAAAAAAAAAAwkPj/////////////////AP////////////////////8gAAAAAAAAAAAAINj///////////////8A/////////////////////xAAAAAAAAAAAAAAIPD//////////////wD/////////////////////uOz/4HgEAAAAAAAAhP//////////////AP///////////////////////////3wAAAAAAAAw//////////////8A////////////////////////////6AAAAAAAAAj//////////////wD/////////////////////////////AAAAAAAAAP//////////////AP//////////tJh8YEQoDNz//////+AAAAAAAAAY//////////////8A//////////88AAAAAAAAaP//////dAAAAAAAAEz//////////////wD//////////6QAAAAAAAAAdOD/5HQAAAAAAAAApP//////////////AP///////////CgAAAAAAAAAAAAAAAAAAAAAACD4//////////////8A////////////yAQAAAAAAAAAAAAAAAAAAAAEuP///////////////wD/////////////rAQAAAAAAAAAAAAAAAAABJD/////////////////AP//////////////zDQAAAAAAAAAAAAAACTA//////////////////8A/////////////////8BwOCAAAAAUNGi0/P///////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - '4' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP//////////////////////////nAAAAAAAAAD///////////////8A/////////////////////////8AEAAAAAAAAAP///////////////wD////////////////////////gGAAAAAAAAAAA////////////////AP//////////////////////9DAAAAAAAAAAAAD///////////////8A//////////////////////9UAAAAAAAAAAAAAP///////////////wD/////////////////////hAAAAAAAAAAAAAAA////////////////AP///////////////////7QAAAAAAAAAAAAAAAD///////////////8A///////////////////UDAAAAAAUAAAAAAAAAP///////////////wD/////////////////7CQAAAAABMAAAAAAAAAA////////////////AP////////////////xEAAAAAACU/wAAAAAAAAD///////////////8A////////////////cAAAAAAAZP//AAAAAAAAAP///////////////wD//////////////6AAAAAAADz8//8AAAAAAAAA////////////////AP/////////////IBAAAAAAc6P///wAAAAAAAAD///////////////8A////////////5BgAAAAADMz/////AAAAAAAAAP///////////////wD///////////g0AAAAAACk//////8AAAAAAAAA////////////////AP//////////XAAAAAAAfP///////wAAAAAAAAD///////////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///////////8A////////////////////////////AAAAAAAAAP///////////////wD///////////////////////////8AAAAAAAAA////////////////AP///////////////////////////wAAAAAAAAD///////////////8A////////////////////////////AAAAAAAAAP///////////////wD///////////////////////////8AAAAAAAAA////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - '5' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP//////////////8AAAAAAAAAAAAAAAAAAAAAAA//////////////8A///////////////MAAAAAAAAAAAAAAAAAAAAAAD//////////////wD//////////////6wAAAAAAAAAAAAAAAAAAAAAAP//////////////AP//////////////iAAAAAAAAAAAAAAAAAAAAAAA//////////////8A//////////////9kAAAAAAAAAAAAAAAAAAAAAAD//////////////wD//////////////0QAAAAAAAAAAAAAAAAAAAAAAP//////////////AP//////////////IAAAAAAAYP////////////////////////////8A//////////////wAAAAAAAB8/////////////////////////////wD/////////////3AAAAAAAAIj/////////////////////////////AP////////////+4AAAAAAAAoLRYHAAEKGTE//////////////////8A/////////////5QAAAAAAAAQAAAAAAAAAABY9P///////////////wD/////////////dAAAAAAAAAAAAAAAAAAAAAA89P//////////////AP////////////9QAAAAAAAAAAAAAAAAAAAAAABg//////////////8A/////////////zAAAAAAAAAAAAAAAAAAAAAAAADQ/////////////wD/////////////IAAAAAAAAGjY/+h4BAAAAAAAAGz/////////////AP//////////////9NS0lHSc//////90AAAAAAAALP////////////8A/////////////////////////////9QAAAAAAAAE/////////////wD//////////////////////////////wAAAAAAAAD/////////////AP/////////////////////////////8AAAAAAAAEP////////////8A////////////pIRwWEAgDOD//////8wAAAAAAAA8/////////////wD///////////9EAAAAAAAAaP//////ZAAAAAAAAHz/////////////AP///////////6QAAAAAAAAAaOD/4GQAAAAAAAAE4P////////////8A/////////////CQAAAAAAAAAAAAAAAAAAAAAAGD//////////////wD/////////////yAQAAAAAAAAAAAAAAAAAAAAc7P//////////////AP//////////////rAwAAAAAAAAAAAAAAAAAGNj///////////////8A////////////////0EAAAAAAAAAAAAAAAFTo/////////////////wD//////////////////8h4QCAAAAAcQHzU////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - '6' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD///////////////////+0ZCwMAAAUNGjI////////////////////AP/////////////////EMAAAAAAAAAAAAABM6P////////////////8A////////////////lAQAAAAAAAAAAAAAAAAo6P///////////////wD//////////////6wAAAAAAAAAAAAAAAAAAABI////////////////AP/////////////oEAAAAAAAAAAAAAAAAAAAAACw//////////////8A/////////////3AAAAAAAAAoxP/YPAAAAAAAAEj//////////////wD////////////4EAAAAAAACOD////YDCBAVGiAoP//////////////AP///////////7gAAAAAAABY//////////////////////////////8A////////////eAAAAAAAAJT//////////////////////////////wD///////////9MAAAAAAAAvP/IXBgABCx03P//////////////////AP///////////ygAAAAAAADcdAAAAAAAAAAEiP////////////////8A////////////FAAAAAAAAFAAAAAAAAAAAAAAcP///////////////wD///////////8AAAAAAAAAAAAAAAAAAAAAAAAAlP//////////////AP///////////wAAAAAAAAAAAAAAAAAAAAAAAAAQ8P////////////8A////////////AAAAAAAAAABAyP/kZAAAAAAAAACQ/////////////wD///////////8MAAAAAAAALPj/////WAAAAAAAAET/////////////AP///////////yQAAAAAAACY///////MAAAAAAAAFP////////////8A////////////SAAAAAAAAMD///////wAAAAAAAAA/////////////wD///////////9wAAAAAAAAvP///////wAAAAAAAAD/////////////AP///////////7QAAAAAAACI///////UAAAAAAAAJP////////////8A////////////+AwAAAAAACDw/////2wAAAAAAABY/////////////wD/////////////cAAAAAAAADC8/Ox4AAAAAAAAAKj/////////////AP/////////////oEAAAAAAAAAAAAAAAAAAAAAAk/P////////////8A//////////////+oAAAAAAAAAAAAAAAAAAAABLj//////////////wD///////////////+QAAAAAAAAAAAAAAAAAACQ////////////////AP////////////////+0JAAAAAAAAAAAAAAkuP////////////////8A///////////////////8sGg0FAAADCxgqPz//////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - '7' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD///////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////AP///////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////8A////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////wD///////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////AP///////////wAAAAAAAAAAAAAAAAAAAAAAAAAABP////////////8A////////////AAAAAAAAAAAAAAAAAAAAAAAAAAy4/////////////wD//////////////////////////+QUAAAAAAAEuP//////////////AP/////////////////////////8QAAAAAAAAKT///////////////8A/////////////////////////4wAAAAAAAB0/////////////////wD////////////////////////cCAAAAAAANPz/////////////////AP///////////////////////0QAAAAAAATY//////////////////8A//////////////////////+0AAAAAAAAeP///////////////////wD//////////////////////CQAAAAAABTw////////////////////AP////////////////////+gAAAAAAAAkP////////////////////8A/////////////////////ywAAAAAABDw/////////////////////wD///////////////////+4AAAAAAAAbP//////////////////////AP///////////////////1wAAAAAAADQ//////////////////////8A///////////////////4DAAAAAAAMP///////////////////////wD//////////////////7QAAAAAAAB8////////////////////////AP//////////////////aAAAAAAAAMj///////////////////////8A//////////////////8oAAAAAAAM/P///////////////////////wD/////////////////8AAAAAAAAET/////////////////////////AP////////////////+0AAAAAAAAcP////////////////////////8A/////////////////4wAAAAAAACY/////////////////////////wD/////////////////WAAAAAAAAMD/////////////////////////AP////////////////80AAAAAAAA4P////////////////////////8A/////////////////xAAAAAAAAD4/////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - '8' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD////////////////////IdDQUAAAEIEiA1P//////////////////AP/////////////////gRAAAAAAAAAAAAAAAROD///////////////8A////////////////0BgAAAAAAAAAAAAAAAAAEMj//////////////wD///////////////AcAAAAAAAAAAAAAAAAAAAAHPD/////////////AP//////////////hAAAAAAAAAAAAAAAAAAAAAAAhP////////////8A//////////////8sAAAAAAAAKMz/zCgAAAAAAAAs/////////////wD//////////////wAAAAAAAADM////zAAAAAAAAAD/////////////AP//////////////BAAAAAAAAP//////AAAAAAAABP////////////8A//////////////8sAAAAAAAAzP///9QAAAAAAAAw/////////////wD//////////////3wAAAAAAAAoyP/YNAAAAAAAAIT/////////////AP//////////////7BgAAAAAAAAAAAAAAAAAAAAc8P////////////8A////////////////xBgAAAAAAAAAAAAAAAAAGNj//////////////wD/////////////////tAQAAAAAAAAAAAAAAACo////////////////AP///////////////HAAAAAAAAAAAAAAAAAAAAB8//////////////8A//////////////9gAAAAAAAAAAAAAAAAAAAAAAB8/////////////wD/////////////wAAAAAAAAABk4P/UWAAAAAAAAATQ////////////AP////////////9UAAAAAAAAaP//////XAAAAAAAAGT///////////8A/////////////xgAAAAAAADg///////cAAAAAAAAJP///////////wD/////////////AAAAAAAAAP////////8AAAAAAAAA////////////AP////////////8AAAAAAAAA4P//////3AAAAAAAAAT///////////8A/////////////ygAAAAAAABg//////9cAAAAAAAALP///////////wD/////////////ZAAAAAAAAABY1P/cXAAAAAAAAABw////////////AP/////////////QAAAAAAAAAAAAAAAAAAAAAAAABNz///////////8A//////////////9gAAAAAAAAAAAAAAAAAAAAAAB0/////////////wD///////////////Q8AAAAAAAAAAAAAAAAAAAAUPz/////////////AP////////////////x4CAAAAAAAAAAAAAAAEIT8//////////////8A///////////////////smFQwGAAAABg0ZKT0/////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - '9' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD///////////////////ysYCwMAAAUNGiw/P//////////////////AP////////////////+4JAAAAAAAAAAAAAAkuP////////////////8A////////////////lAQAAAAAAAAAAAAAAAAAkP///////////////wD//////////////8AEAAAAAAAAAAAAAAAAAAAAqP//////////////AP/////////////8JAAAAAAAAAAAAAAAAAAAAAAQ7P////////////8A/////////////6wAAAAAAAAAfOz8vCwAAAAAAABw/////////////wD/////////////WAAAAAAAAHD/////7BgAAAAAAAz4////////////AP////////////8kAAAAAAAA1P//////hAAAAAAAALT///////////8A/////////////wAAAAAAAAD///////+4AAAAAAAAcP///////////wD/////////////AAAAAAAAAPz//////8AAAAAAAABI////////////AP////////////8UAAAAAAAAzP//////lAAAAAAAACT///////////8A/////////////0QAAAAAAABY//////gsAAAAAAAADP///////////wD/////////////kAAAAAAAAABw5P/IPAAAAAAAAAAA////////////AP/////////////wEAAAAAAAAAAAAAAAAAAAAAAAAAD///////////8A//////////////+UAAAAAAAAAAAAAAAAAAAAAAAAAP///////////wD///////////////9wAAAAAAAAAAAAAFAAAAAAAAAU////////////AP////////////////+IBAAAAAAAAABw3AAAAAAAACj///////////8A///////////////////cdCwEABhcxP+8AAAAAAAATP///////////wD//////////////////////////////5AAAAAAAAB4////////////AP//////////////////////////////UAAAAAAAALj///////////8A//////////////+kgGxUQCAM2P///+AIAAAAAAAQ+P///////////wD//////////////0gAAAAAAAA42P/EKAAAAAAAAHD/////////////AP//////////////sAAAAAAAAAAAAAAAAAAAAAAQ6P////////////8A////////////////TAAAAAAAAAAAAAAAAAAAAKz//////////////wD////////////////oKAAAAAAAAAAAAAAAAASU////////////////AP/////////////////sUAAAAAAAAAAAAAAwxP////////////////8A////////////////////yHA0FAAADCxktP///////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'A' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD//////////////////+QAAAAAAAAAAAAAAOT/////////////////AP//////////////////kAAAAAAAAAAAAAAAkP////////////////8A//////////////////88AAAAAAAAAAAAAAA8/////////////////wD/////////////////5AAAAAAAAAAAAAAAAADk////////////////AP////////////////+QAAAAAAAAAAAAAAAAAJD///////////////8A/////////////////zwAAAAAAAAAAAAAAAAAPP///////////////wD////////////////kAAAAAAAAAAgAAAAAAAAA5P//////////////AP///////////////5AAAAAAAAAAgAAAAAAAAACQ//////////////8A////////////////PAAAAAAAAAz8HAAAAAAAADz//////////////wD//////////////+QAAAAAAAAAWP9kAAAAAAAAANz/////////////AP//////////////kAAAAAAAAACk/7wAAAAAAAAAhP////////////8A//////////////88AAAAAAAABOz//BQAAAAAAAAw/////////////wD/////////////4AAAAAAAAAA8////ZAAAAAAAAADc////////////AP////////////+EAAAAAAAAAIj///+8AAAAAAAAAIT///////////8A/////////////zAAAAAAAAAA2P////wQAAAAAAAAMP///////////wD////////////cAAAAAAAAACT//////1wAAAAAAAAA3P//////////AP///////////4QAAAAAAAAAAAAAAAAAAAAAAAAAAACE//////////8A////////////MAAAAAAAAAAAAAAAAAAAAAAAAAAAADD//////////wD//////////9wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANz/////////AP//////////hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAhP////////8A//////////8wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAw/////////wD/////////3AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADc////////AP////////+EAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIT///////8A/////////zAAAAAAAAAAhP///////////2QAAAAAAAAAMP///////wD////////cAAAAAAAAAADM////////////vAAAAAAAAAAA3P//////AP///////4QAAAAAAAAAHP/////////////4DAAAAAAAAACE//////8A////////MAAAAAAAAABk//////////////9cAAAAAAAAADD//////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'B' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A//////////8AAAAAAAAAAAAAAAAAAAAAEDh83P///////////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAEhP//////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAeP////////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAxP///////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAABY////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAABT///////////8A//////////8AAAAAAAAAAP/////4zEwAAAAAAAAAAP///////////wD//////////wAAAAAAAAAA////////7AAAAAAAAAAQ////////////AP//////////AAAAAAAAAAD////////sAAAAAAAAAEj///////////8A//////////8AAAAAAAAAAP/////4zEQAAAAAAAAAtP///////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAFz/////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAiA/P////////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAIjPj//////////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAGKz/////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAJT///////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAABNz//////////wD//////////wAAAAAAAAAA///////sqCAAAAAAAAAAbP//////////AP//////////AAAAAAAAAAD/////////yAAAAAAAAAAs//////////8A//////////8AAAAAAAAAAP//////////AAAAAAAAAAT//////////wD//////////wAAAAAAAAAA/////////7wAAAAAAAAAAP//////////AP//////////AAAAAAAAAAD//////+ikGAAAAAAAAAAY//////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFT//////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAsP//////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAADj///////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAc6P///////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAATOj/////////////AP//////////AAAAAAAAAAAAAAAAAAAEIEBkkNj///////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'C' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP//////////////////5JRULBAAAAgkTIDQ//////////////////8A////////////////1FAAAAAAAAAAAAAAAABAyP///////////////wD//////////////4gEAAAAAAAAAAAAAAAAAAAElP//////////////AP////////////9wAAAAAAAAAAAAAAAAAAAAAAAAlP////////////8A////////////kAAAAAAAAAAAAAAAAAAAAAAAAAAEyP///////////wD//////////9wIAAAAAAAAAAAAAAAAAAAAAAAAAAAw////////////AP//////////WAAAAAAAAAAAWMz/8JwQAAAAAAAAAACw//////////8A/////////+wEAAAAAAAAAID//////9QMAAAAAAAAAET//////////wD/////////nAAAAAAAAAAo/P///////3wAAAAABDBspP//////////AP////////9gAAAAAAAAAIz/////////3BxQjMT0//////////////8A/////////zQAAAAAAAAAzP///////////////////////////////wD/////////GAAAAAAAAADo////////////////////////////////AP////////8AAAAAAAAAAP////////////////////////////////8A/////////wAAAAAAAAAA/////////////////////////////////wD/////////AAAAAAAAAAD/////////////////////////////////AP////////8cAAAAAAAAAOj///////////////////////////////8A/////////zgAAAAAAAAA0P/////////kIGio7P///////////////wD/////////bAAAAAAAAACg/////////5wAAAAAMHS49P//////////AP////////+oAAAAAAAAAEz/////////PAAAAAAAAAAc//////////8A//////////QIAAAAAAAAALz//////6QAAAAAAAAAAGT//////////wD//////////3AAAAAAAAAADIzo/+SEBAAAAAAAAAAAyP//////////AP//////////7BAAAAAAAAAAAAAAAAAAAAAAAAAAAED///////////8A////////////rAAAAAAAAAAAAAAAAAAAAAAAAAAE0P///////////wD/////////////fAAAAAAAAAAAAAAAAAAAAAAAAJz/////////////AP//////////////iAQAAAAAAAAAAAAAAAAAAASY//////////////8A////////////////yEAAAAAAAAAAAAAAAAA8yP///////////////wD//////////////////9yIUCwQAAAAIEB4yP//////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'D' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD///////////8AAAAAAAAAAAAAAAAADChQkOT/////////////////AP///////////wAAAAAAAAAAAAAAAAAAAAAABGjw//////////////8A////////////AAAAAAAAAAAAAAAAAAAAAAAAACDY/////////////wD///////////8AAAAAAAAAAAAAAAAAAAAAAAAAABjk////////////AP///////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAED///////////8A////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAKj//////////wD///////////8AAAAAAAAAAP///+isSAAAAAAAAAAANP//////////AP///////////wAAAAAAAAAA////////hAAAAAAAAAAA2P////////8A////////////AAAAAAAAAAD/////////MAAAAAAAAACQ/////////wD///////////8AAAAAAAAAAP////////+MAAAAAAAAAFj/////////AP///////////wAAAAAAAAAA/////////8gAAAAAAAAAMP////////8A////////////AAAAAAAAAAD/////////5AAAAAAAAAAY/////////wD///////////8AAAAAAAAAAP//////////AAAAAAAAAAD/////////AP///////////wAAAAAAAAAA//////////8AAAAAAAAAAP////////8A////////////AAAAAAAAAAD//////////wAAAAAAAAAA/////////wD///////////8AAAAAAAAAAP/////////wAAAAAAAAABD/////////AP///////////wAAAAAAAAAA/////////9QAAAAAAAAAJP////////8A////////////AAAAAAAAAAD/////////qAAAAAAAAABI/////////wD///////////8AAAAAAAAAAP////////9QAAAAAAAAAHj/////////AP///////////wAAAAAAAAAA////////uAAAAAAAAAAAvP////////8A////////////AAAAAAAAAAD////w0HwEAAAAAAAAACT8/////////wD///////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAoP//////////AP///////////wAAAAAAAAAAAAAAAAAAAAAAAAAAADz8//////////8A////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAY6P///////////wD///////////8AAAAAAAAAAAAAAAAAAAAAAAAAKNz/////////////AP///////////wAAAAAAAAAAAAAAAAAAAAAACHT0//////////////8A////////////AAAAAAAAAAAAAAAAABg4bKj0/////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'E' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////AP//////////AAAAAAAAAAD///////////////////////////////8A//////////8AAAAAAAAAAP///////////////////////////////wD//////////wAAAAAAAAAA////////////////////////////////AP//////////AAAAAAAAAAD///////////////////////////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAD//////////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAP//////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAA//////////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAD//////////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAP//////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAA//////////////8A//////////8AAAAAAAAAAP///////////////////////////////wD//////////wAAAAAAAAAA////////////////////////////////AP//////////AAAAAAAAAAD///////////////////////////////8A//////////8AAAAAAAAAAP///////////////////////////////wD//////////wAAAAAAAAAA////////////////////////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'F' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////wAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////wD/////////////AAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////AP////////////8AAAAAAAAAAAAAAAAAAAAAAAAAAP////////////8A/////////////wAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////wD/////////////AAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////AP////////////8AAAAAAAAAAAAAAAAAAAAAAAAAAP////////////8A/////////////wAAAAAAAAAA/////////////////////////////wD/////////////AAAAAAAAAAD/////////////////////////////AP////////////8AAAAAAAAAAP////////////////////////////8A/////////////wAAAAAAAAAA/////////////////////////////wD/////////////AAAAAAAAAAAAAAAAAAAAAAAA////////////////AP////////////8AAAAAAAAAAAAAAAAAAAAAAAD///////////////8A/////////////wAAAAAAAAAAAAAAAAAAAAAAAP///////////////wD/////////////AAAAAAAAAAAAAAAAAAAAAAAA////////////////AP////////////8AAAAAAAAAAAAAAAAAAAAAAAD///////////////8A/////////////wAAAAAAAAAAAAAAAAAAAAAAAP///////////////wD/////////////AAAAAAAAAAD/////////////////////////////AP////////////8AAAAAAAAAAP////////////////////////////8A/////////////wAAAAAAAAAA/////////////////////////////wD/////////////AAAAAAAAAAD/////////////////////////////AP////////////8AAAAAAAAAAP////////////////////////////8A/////////////wAAAAAAAAAA/////////////////////////////wD/////////////AAAAAAAAAAD/////////////////////////////AP////////////8AAAAAAAAAAP////////////////////////////8A/////////////wAAAAAAAAAA/////////////////////////////wD/////////////AAAAAAAAAAD/////////////////////////////AP////////////8AAAAAAAAAAP////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'G' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD//////////////////MB8TCgQAAAACCA4YJzs////////////////AP///////////////JQcAAAAAAAAAAAAAAAAAAhw8P////////////8A/////////////9gwAAAAAAAAAAAAAAAAAAAAAAAk2P///////////wD////////////EDAAAAAAAAAAAAAAAAAAAAAAAAAAc7P//////////AP//////////2AwAAAAAAAAAAAAAAAAAAAAAAAAAAABY//////////8A//////////wwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQ/////////wD/////////kAAAAAAAAAAAEHzQ/P/gmCAAAAAAAAAAAFz/////////AP////////wcAAAAAAAAACjg////////8CwAAAAAAAAgWP////////8A////////vAAAAAAAAAAI2P//////////yBRAcJjI8P///////////wD///////94AAAAAAAAAGD/////////////////////////////////AP///////0AAAAAAAAAAsP////////////////////////////////8A////////IAAAAAAAAADc/////////////////////////////////wD///////8AAAAAAAAAAP///////wAAAAAAAAAAAAAAAAD/////////AP///////wAAAAAAAAAA////////AAAAAAAAAAAAAAAAAP////////8A////////AAAAAAAAAAD///////8AAAAAAAAAAAAAAAAA/////////wD///////8gAAAAAAAAAOD//////wAAAAAAAAAAAAAAAAD/////////AP///////0AAAAAAAAAAtP//////AAAAAAAAAAAAAAAAAP////////8A////////cAAAAAAAAABw//////8AAAAAAAAAAAAAAAAA/////////wD///////+8AAAAAAAAABDs////////////AAAAAAAAAAD/////////AP////////wYAAAAAAAAADz0//////////AAAAAAAAAAAP////////8A/////////5AAAAAAAAAAACCY4P//3KhcCAAAAAAAAAAA/////////wD/////////+CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////AP//////////xAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIP////////8A////////////rAQAAAAAAAAAAAAAAAAAAAAAAAAAAGTw/////////wD/////////////vBQAAAAAAAAAAAAAAAAAAAAAADjI////////////AP//////////////8HAQAAAAAAAAAAAAAAAAAEiw//////////////8A//////////////////iwcEAgBAAABCA4aKDk/////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'H' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////8AAAAAAAAAAP///////////wAAAAAAAAAA//////////8A/////////wAAAAAAAAAA////////////AAAAAAAAAAD//////////wD/////////AAAAAAAAAAD///////////8AAAAAAAAAAP//////////AP////////8AAAAAAAAAAP///////////wAAAAAAAAAA//////////8A/////////wAAAAAAAAAA////////////AAAAAAAAAAD//////////wD/////////AAAAAAAAAAD///////////8AAAAAAAAAAP//////////AP////////8AAAAAAAAAAP///////////wAAAAAAAAAA//////////8A/////////wAAAAAAAAAA////////////AAAAAAAAAAD//////////wD/////////AAAAAAAAAAD///////////8AAAAAAAAAAP//////////AP////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//////////8A/////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//////////wD/////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP//////////AP////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//////////8A/////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//////////wD/////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP//////////AP////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//////////8A/////////wAAAAAAAAAA////////////AAAAAAAAAAD//////////wD/////////AAAAAAAAAAD///////////8AAAAAAAAAAP//////////AP////////8AAAAAAAAAAP///////////wAAAAAAAAAA//////////8A/////////wAAAAAAAAAA////////////AAAAAAAAAAD//////////wD/////////AAAAAAAAAAD///////////8AAAAAAAAAAP//////////AP////////8AAAAAAAAAAP///////////wAAAAAAAAAA//////////8A/////////wAAAAAAAAAA////////////AAAAAAAAAAD//////////wD/////////AAAAAAAAAAD///////////8AAAAAAAAAAP//////////AP////////8AAAAAAAAAAP///////////wAAAAAAAAAA//////////8A/////////wAAAAAAAAAA////////////AAAAAAAAAAD//////////wD/////////AAAAAAAAAAD///////////8AAAAAAAAAAP//////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'I' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////AAAAAAAAAAAAAAAAAAAAAAAA////////////////AP////////////8AAAAAAAAAAAAAAAAAAAAAAAD///////////////8A/////////////wAAAAAAAAAAAAAAAAAAAAAAAP///////////////wD/////////////AAAAAAAAAAAAAAAAAAAAAAAA////////////////AP////////////8AAAAAAAAAAAAAAAAAAAAAAAD///////////////8A/////////////wAAAAAAAAAAAAAAAAAAAAAAAP///////////////wD/////////////AAAAAAAAAAAAAAAAAAAAAAAA////////////////AP///////////////////wAAAAAAAAAA//////////////////////8A////////////////////AAAAAAAAAAD//////////////////////wD///////////////////8AAAAAAAAAAP//////////////////////AP///////////////////wAAAAAAAAAA//////////////////////8A////////////////////AAAAAAAAAAD//////////////////////wD///////////////////8AAAAAAAAAAP//////////////////////AP///////////////////wAAAAAAAAAA//////////////////////8A////////////////////AAAAAAAAAAD//////////////////////wD///////////////////8AAAAAAAAAAP//////////////////////AP///////////////////wAAAAAAAAAA//////////////////////8A////////////////////AAAAAAAAAAD//////////////////////wD///////////////////8AAAAAAAAAAP//////////////////////AP///////////////////wAAAAAAAAAA//////////////////////8A////////////////////AAAAAAAAAAD//////////////////////wD///////////////////8AAAAAAAAAAP//////////////////////AP////////////8AAAAAAAAAAAAAAAAAAAAAAAD///////////////8A/////////////wAAAAAAAAAAAAAAAAAAAAAAAP///////////////wD/////////////AAAAAAAAAAAAAAAAAAAAAAAA////////////////AP////////////8AAAAAAAAAAAAAAAAAAAAAAAD///////////////8A/////////////wAAAAAAAAAAAAAAAAAAAAAAAP///////////////wD/////////////AAAAAAAAAAAAAAAAAAAAAAAA////////////////AP////////////8AAAAAAAAAAAAAAAAAAAAAAAD///////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'J' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP///////////////////////////wAAAAAAAAAA//////////////8A////////////////////////////AAAAAAAAAAD//////////////wD///////////////////////////8AAAAAAAAAAP//////////////AP///////////////////////////wAAAAAAAAAA//////////////8A////////////////////////////AAAAAAAAAAD//////////////wD///////////////////////////8AAAAAAAAAAP//////////////AP///////////////////////////wAAAAAAAAAA//////////////8A////////////////////////////AAAAAAAAAAD//////////////wD///////////////////////////8AAAAAAAAAAP//////////////AP///////////////////////////wAAAAAAAAAA//////////////8A////////////////////////////AAAAAAAAAAD//////////////wD///////////////////////////8AAAAAAAAAAP//////////////AP///////////////////////////wAAAAAAAAAA//////////////8A////////////////////////////AAAAAAAAAAD//////////////wD///////////////////////////8AAAAAAAAAAP//////////////AP///////////////////////////wAAAAAAAAAA//////////////8A////////////////////////////AAAAAAAAAAj//////////////wD//////////+zMrIxwUDAQ//////wAAAAAAAAAIP//////////////AP//////////DAAAAAAAAADo////2AAAAAAAAAA0//////////////8A//////////8wAAAAAAAAAKj///+YAAAAAAAAAFj//////////////wD//////////2gAAAAAAAAAIND/yBgAAAAAAAAAkP//////////////AP//////////vAAAAAAAAAAAAAAAAAAAAAAAAADc//////////////8A////////////MAAAAAAAAAAAAAAAAAAAAAAAUP///////////////wD////////////EBAAAAAAAAAAAAAAAAAAAABjk////////////////AP////////////+sBAAAAAAAAAAAAAAAAAAY2P////////////////8A///////////////EMAAAAAAAAAAAAAAAVOj//////////////////wD/////////////////vHBAIAAAABg8fNT/////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'K' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD///////8AAAAAAAAAAP//////////wAQAAAAAAAAAAABw////////AP///////wAAAAAAAAAA/////////9AMAAAAAAAAAAAAcP////////8A////////AAAAAAAAAAD////////cGAAAAAAAAAAAAHD//////////wD///////8AAAAAAAAAAP//////6CgAAAAAAAAAAABs////////////AP///////wAAAAAAAAAA//////Q0AAAAAAAAAAAAVPz///////////8A////////AAAAAAAAAAD////8RAAAAAAAAAAAAFT8/////////////wD///////8AAAAAAAAAAP///1gAAAAAAAAAAABU/P//////////////AP///////wAAAAAAAAAA//9wAAAAAAAAAAAASPz///////////////8A////////AAAAAAAAAAD/jAAAAAAAAAAAADz0/////////////////wD///////8AAAAAAAAAAKQAAAAAAAAAAAA89P//////////////////AP///////wAAAAAAAAAABAAAAAAAAAAAFPT///////////////////8A////////AAAAAAAAAAAAAAAAAAAAAAAApP///////////////////wD///////8AAAAAAAAAAAAAAAAAAAAAAAAU8P//////////////////AP///////wAAAAAAAAAAAAAAAAAAAAAAAABk//////////////////8A////////AAAAAAAAAAAAAAAAAAAAAAAAAADE/////////////////wD///////8AAAAAAAAAAAAAAAAoEAAAAAAAACz8////////////////AP///////wAAAAAAAAAAAAAAGNiAAAAAAAAAAIj///////////////8A////////AAAAAAAAAAAAABjY//gYAAAAAAAACOD//////////////wD///////8AAAAAAAAAAAAY2P///5wAAAAAAAAASP//////////////AP///////wAAAAAAAAAAGNj//////CgAAAAAAAAAqP////////////8A////////AAAAAAAAAADI////////sAAAAAAAAAAc8P///////////wD///////8AAAAAAAAAAP//////////QAAAAAAAAABs////////////AP///////wAAAAAAAAAA///////////IAAAAAAAAAATI//////////8A////////AAAAAAAAAAD///////////9YAAAAAAAAADD8/////////wD///////8AAAAAAAAAAP///////////9wEAAAAAAAAAJD/////////AP///////wAAAAAAAAAA/////////////3AAAAAAAAAADOT///////8A////////AAAAAAAAAAD/////////////7BAAAAAAAAAAUP///////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'L' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////8AAAAAAAAAAP////////////////////////////8A/////////////wAAAAAAAAAA/////////////////////////////wD/////////////AAAAAAAAAAD/////////////////////////////AP////////////8AAAAAAAAAAP////////////////////////////8A/////////////wAAAAAAAAAA/////////////////////////////wD/////////////AAAAAAAAAAD/////////////////////////////AP////////////8AAAAAAAAAAP////////////////////////////8A/////////////wAAAAAAAAAA/////////////////////////////wD/////////////AAAAAAAAAAD/////////////////////////////AP////////////8AAAAAAAAAAP////////////////////////////8A/////////////wAAAAAAAAAA/////////////////////////////wD/////////////AAAAAAAAAAD/////////////////////////////AP////////////8AAAAAAAAAAP////////////////////////////8A/////////////wAAAAAAAAAA/////////////////////////////wD/////////////AAAAAAAAAAD/////////////////////////////AP////////////8AAAAAAAAAAP////////////////////////////8A/////////////wAAAAAAAAAA/////////////////////////////wD/////////////AAAAAAAAAAD/////////////////////////////AP////////////8AAAAAAAAAAP////////////////////////////8A/////////////wAAAAAAAAAA/////////////////////////////wD/////////////AAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////AP////////////8AAAAAAAAAAAAAAAAAAAAAAAAAAP////////////8A/////////////wAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////wD/////////////AAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////AP////////////8AAAAAAAAAAAAAAAAAAAAAAAAAAP////////////8A/////////////wAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////wD/////////////AAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'M' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A//////8AAAAAAAAAAAAAAHz//////3wAAAAAAAAAAAAAAP///////wD//////wAAAAAAAAAAAAAATP//////UAAAAAAAAAAAAAAA////////AP//////AAAAAAAAAAAAAAAc//////8cAAAAAAAAAAAAAAD///////8A//////8AAAAAAAAAAAAAAADw////8AAAAAAAAAAAAAAAAP///////wD//////wAAAAAAAAAAAAAAALz////AAAAAAAAAAAAAAAAA////////AP//////AAAAAAAAAAAAAAAAkP///5AAAAAAAAAAAAAAAAD///////8A//////8AAAAAAAAAAAAAAABc////ZAAAAAAAAAAAAAAAAP///////wD//////wAAAAAAAAAoAAAAADD///8wAAAAACQAAAAAAAAA////////AP//////AAAAAAAAAFwAAAAABPz//AgAAAAAXAAAAAAAAAD///////8A//////8AAAAAAAAAkAAAAAAA0P/UAAAAAACQAAAAAAAAAP///////wD//////wAAAAAAAADMAAAAAACg/6gAAAAAAMQAAAAAAAAA////////AP//////AAAAAAAAAPgEAAAAAHD/dAAAAAAE+AAAAAAAAAD///////8A//////8AAAAAAAAA/zQAAAAAQP9IAAAAADD/AAAAAAAAAP///////wD//////wAAAAAAAAD/bAAAAAAQ/xQAAAAAaP8AAAAAAAAA////////AP//////AAAAAAAAAP+gAAAAAADQAAAAAACc/wAAAAAAAAD///////8A//////8AAAAAAAAA/9QAAAAAAGgAAAAAAND/AAAAAAAAAP///////wD//////wAAAAAAAAD//wwAAAAAFAAAAAAM/P8AAAAAAAAA////////AP//////AAAAAAAAAP//RAAAAAAAAAAAADz//wAAAAAAAAD///////8A//////8AAAAAAAAA//94AAAAAAAAAAAAcP//AAAAAAAAAP///////wD//////wAAAAAAAAD//7AAAAAAAAAAAACo//8AAAAAAAAA////////AP//////AAAAAAAAAP//5AAAAAAAAAAAANz//wAAAAAAAAD///////8A//////8AAAAAAAAA////HAAAAAAAAAAQ////AAAAAAAAAP///////wD//////wAAAAAAAAD///9QAAAAAAAAAEz///8AAAAAAAAA////////AP//////AAAAAAAAAP///4gAAAAAAAAAfP///wAAAAAAAAD///////8A//////8AAAAAAAAA////vAAAAAAAAACw////AAAAAAAAAP///////wD//////wAAAAAAAAD////wAAAAAAAAAOz///8AAAAAAAAA////////AP//////AAAAAAAAAP////8sAAAAAAAc/////wAAAAAAAAD///////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'N' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////AAAAAAAAALD/////////////AAAAAAAAAP//////////AP////////8AAAAAAAAAFOj///////////8AAAAAAAAA//////////8A/////////wAAAAAAAAAASP///////////wAAAAAAAAD//////////wD/////////AAAAAAAAAAAAkP//////////AAAAAAAAAP//////////AP////////8AAAAAAAAAAAAI1P////////8AAAAAAAAA//////////8A/////////wAAAAAAAAAAAAAw+P///////wAAAAAAAAD//////////wD/////////AAAAAAAAAAAAAABw////////AAAAAAAAAP//////////AP////////8AAAAAAAAAAAAAAAC8//////8AAAAAAAAA//////////8A/////////wAAAAAAAAAAAAAAABzs/////wAAAAAAAAD//////////wD/////////AAAAAAAAAAAAAAAAAFD/////AAAAAAAAAP//////////AP////////8AAAAAAAAAAAAAAAAAAJz///8AAAAAAAAA//////////8A/////////wAAAAAAAAAUAAAAAAAADNz//wAAAAAAAAD//////////wD/////////AAAAAAAAALQAAAAAAAAANPz/AAAAAAAAAP//////////AP////////8AAAAAAAAA/2wAAAAAAAAAfP8AAAAAAAAA//////////8A/////////wAAAAAAAAD/+CwAAAAAAAAExAAAAAAAAAD//////////wD/////////AAAAAAAAAP//0AQAAAAAAAAgAAAAAAAAAP//////////AP////////8AAAAAAAAA////jAAAAAAAAAAAAAAAAAAA//////////8A/////////wAAAAAAAAD/////RAAAAAAAAAAAAAAAAAD//////////wD/////////AAAAAAAAAP/////kFAAAAAAAAAAAAAAAAP//////////AP////////8AAAAAAAAA//////+sAAAAAAAAAAAAAAAA//////////8A/////////wAAAAAAAAD///////9kAAAAAAAAAAAAAAD//////////wD/////////AAAAAAAAAP////////QkAAAAAAAAAAAAAP//////////AP////////8AAAAAAAAA/////////8wEAAAAAAAAAAAA//////////8A/////////wAAAAAAAAD//////////4QAAAAAAAAAAAD//////////wD/////////AAAAAAAAAP///////////DwAAAAAAAAAAP//////////AP////////8AAAAAAAAA////////////4BAAAAAAAAAA//////////8A/////////wAAAAAAAAD/////////////qAAAAAAAAAD//////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'O' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A///////////////////0qGw4HAAAABw4aKT0/////////////////wD////////////////wcAwAAAAAAAAAAAAAAAho6P//////////////AP//////////////uBQAAAAAAAAAAAAAAAAAAAAMoP////////////8A/////////////6AEAAAAAAAAAAAAAAAAAAAAAAAAkP///////////wD///////////+4BAAAAAAAAAAAAAAAAAAAAAAAAAAAoP//////////AP//////////8BQAAAAAAAAAAAAAAAAAAAAAAAAAAAAM5P////////8A//////////9wAAAAAAAAAAAsrPD/7KQsAAAAAAAAAABg/////////wD/////////+BAAAAAAAAAAUPj///////hQAAAAAAAAAAjs////////AP////////+sAAAAAAAAABDw//////////AYAAAAAAAAAKD///////8A/////////2wAAAAAAAAAdP///////////3wAAAAAAAAAYP///////wD/////////OAAAAAAAAAC4////////////xAAAAAAAAAAw////////AP////////8cAAAAAAAAAOD////////////oAAAAAAAAABT///////8A/////////wAAAAAAAAAA//////////////8AAAAAAAAAAP///////wD/////////AAAAAAAAAAD//////////////wAAAAAAAAAA////////AP////////8AAAAAAAAAAP/////////////8AAAAAAAAAAD///////8A/////////xwAAAAAAAAA5P///////////+AAAAAAAAAAHP///////wD/////////NAAAAAAAAAC8////////////uAAAAAAAAAA4////////AP////////9oAAAAAAAAAHj///////////98AAAAAAAAAGT///////8A/////////6gAAAAAAAAAGPD/////////+BgAAAAAAAAApP///////wD/////////9AwAAAAAAAAAUPz///////xcAAAAAAAAAAjs////////AP//////////cAAAAAAAAAAALKjs//CwOAAAAAAAAAAAYP////////8A///////////wFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAzk/////////wD///////////+4BAAAAAAAAAAAAAAAAAAAAAAAAAAAoP//////////AP////////////+QAAAAAAAAAAAAAAAAAAAAAAAAAJD///////////8A//////////////+sEAAAAAAAAAAAAAAAAAAAAAyg/////////////wD////////////////oZAgAAAAAAAAAAAAAAARg4P//////////////AP//////////////////9KhsOCAAAAAUMFyc7P////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'P' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP///////////wAAAAAAAAAAAAAAAAAACCxguP////////////////8A////////////AAAAAAAAAAAAAAAAAAAAAAAAOOD//////////////wD///////////8AAAAAAAAAAAAAAAAAAAAAAAAAGOD/////////////AP///////////wAAAAAAAAAAAAAAAAAAAAAAAAAARP////////////8A////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAxP///////////wD///////////8AAAAAAAAAAAAAAAAAAAAAAAAAAABo////////////AP///////////wAAAAAAAAAA////6JwMAAAAAAAAADD///////////8A////////////AAAAAAAAAAD//////6AAAAAAAAAADP///////////wD///////////8AAAAAAAAAAP//////9AAAAAAAAAAA////////////AP///////////wAAAAAAAAAA///////0AAAAAAAAAAD///////////8A////////////AAAAAAAAAAD//////5gAAAAAAAAAHP///////////wD///////////8AAAAAAAAAAP///9iICAAAAAAAAABI////////////AP///////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAJD///////////8A////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAI6P///////////wD///////////8AAAAAAAAAAAAAAAAAAAAAAAAAAIT/////////////AP///////////wAAAAAAAAAAAAAAAAAAAAAAAABU/P////////////8A////////////AAAAAAAAAAAAAAAAAAAAAAAIhPz//////////////wD///////////8AAAAAAAAAAAAAAAAABCRMkOz/////////////////AP///////////wAAAAAAAAAA//////////////////////////////8A////////////AAAAAAAAAAD//////////////////////////////wD///////////8AAAAAAAAAAP//////////////////////////////AP///////////wAAAAAAAAAA//////////////////////////////8A////////////AAAAAAAAAAD//////////////////////////////wD///////////8AAAAAAAAAAP//////////////////////////////AP///////////wAAAAAAAAAA//////////////////////////////8A////////////AAAAAAAAAAD//////////////////////////////wD///////////8AAAAAAAAAAP//////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'Q' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////SoaDQcAAAAHDhoqPT///////////////////8A//////////////BwDAAAAAAAAAAAAAAACHDo/////////////////wD///////////+4FAAAAAAAAAAAAAAAAAAAABCo////////////////AP//////////nAQAAAAAAAAAAAAAAAAAAAAAAACQ//////////////8A/////////7gEAAAAAAAAAAAAAAAAAAAAAAAAAACg/////////////wD////////wFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAzo////////////AP///////3AAAAAAAAAAACyo8P/sqCwAAAAAAAAAAGT///////////8A///////4EAAAAAAAAABM+P///////FQAAAAAAAAACPT//////////wD//////7AAAAAAAAAAFPD/////////9BgAAAAAAAAApP//////////AP//////bAAAAAAAAAB4////////////fAAAAAAAAABk//////////8A//////84AAAAAAAAALz///////////+8AAAAAAAAADT//////////wD//////xwAAAAAAAAA6P///////////+QAAAAAAAAAHP//////////AP//////AAAAAAAAAAD//////////////wAAAAAAAAAA//////////8A//////8AAAAAAAAAAP//////////////AAAAAAAAAAD//////////wD//////wAAAAAAAAAA/P////////////8AAAAAAAAAAP//////////AP//////GAAAAAAAAADg////////////4AAAAAAAAAAc//////////8A//////84AAAAAAAAALT////MJHTo//+8AAAAAAAAADT//////////wD//////2wAAAAAAAAAdP///2AAABCg/3wAAAAAAAAAZP//////////AP//////rAAAAAAAAAAY9P/sCAAAAABMGAAAAAAAAACk//////////8A///////4EAAAAAAAAABU/P+0OAAAAAAAAAAAAAAACPT//////////wD///////94AAAAAAAAAAA4sPD/gAAAAAAAAAAAAABk////////////AP////////AcAAAAAAAAAAAAAAAAAAAAAAAAAAAADOT///////////8A/////////7wEAAAAAAAAAAAAAAAAAAAAAAAAAACQ/////////////wD//////////6wEAAAAAAAAAAAAAAAAAAAAAAAAABSs////////////AP///////////7gUAAAAAAAAAAAAAAAAAAAAAAAAAABAwP////////8A//////////////BwDAAAAAAAAAAAAAAABAgAAAAAAAA8/////////wD////////////////0qGg0GAAAABgwXJjkxBgAAAAAALD/////////AP//////////////////////////////////5DQAAAAk/P////////8A////////////////////////////////////+GwAAJD//////////wD//////////////////////////////////////8A49P//////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'R' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////wAAAAAAAAAAAAAAAAAAAAQgOGSk+P///////////////wD/////////AAAAAAAAAAAAAAAAAAAAAAAAAAAcuP//////////////AP////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAEsP////////////8A/////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQ6P///////////wD/////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB8////////////AP////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAADD///////////8A/////////wAAAAAAAAAA///////svDgAAAAAAAAACP///////////wD/////////AAAAAAAAAAD/////////7AAAAAAAAAAA////////////AP////////8AAAAAAAAAAP/////////cAAAAAAAAABD///////////8A/////////wAAAAAAAAAA//////DQoCQAAAAAAAAAQP///////////wD/////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAACU////////////AP////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAIPj///////////8A/////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAzU/////////////wD/////////AAAAAAAAAAAAAAAAAAAAAAAAAAA02P//////////////AP////////8AAAAAAAAAAAAAAAAAAAAAAAxctPz///////////////8A/////////wAAAAAAAAAAAAAAAAAAAAAAAEDY/////////////////wD/////////AAAAAAAAAAD/9LAsAAAAAAAAAAzc////////////////AP////////8AAAAAAAAAAP///+wkAAAAAAAAADD8//////////////8A/////////wAAAAAAAAAA/////8QAAAAAAAAAAJD//////////////wD/////////AAAAAAAAAAD//////1QAAAAAAAAAFPD/////////////AP////////8AAAAAAAAAAP//////3AQAAAAAAAAAgP////////////8A/////////wAAAAAAAAAA////////aAAAAAAAAAAM6P///////////wD/////////AAAAAAAAAAD////////oCAAAAAAAAABs////////////AP////////8AAAAAAAAAAP////////+AAAAAAAAAAATc//////////8A/////////wAAAAAAAAAA//////////AUAAAAAAAAAFj//////////wD/////////AAAAAAAAAAD//////////5AAAAAAAAAAAND/////////AP////////8AAAAAAAAAAP//////////+CQAAAAAAAAAQP////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'S' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP/////////////////8vHBEIAgAAAQgQHC8/P////////////////8A////////////////pCQAAAAAAAAAAAAAAAAcoP///////////////wD//////////////FwAAAAAAAAAAAAAAAAAAAAAXP//////////////AP////////////9oAAAAAAAAAAAAAAAAAAAAAAAAhP////////////8A////////////zAAAAAAAAAAAAAAAAAAAAAAAAAAI6P///////////wD///////////9cAAAAAAAAAAAAAAAAAAAAAAAAAACA////////////AP///////////xgAAAAAAAAAUOD/8KwkAAAAAAAAADj///////////8A////////////AAAAAAAAAAD0/////8wABCAgICxASP///////////wD///////////8MAAAAAAAAAMz/////////////////////////////AP///////////0AAAAAAAAAACFiQxPT///////////////////////8A////////////oAAAAAAAAAAAAAAAADBwtPT//////////////////wD////////////8QAAAAAAAAAAAAAAAAAAACFTA////////////////AP/////////////oOAAAAAAAAAAAAAAAAAAAAABM6P////////////8A///////////////4fAgAAAAAAAAAAAAAAAAAAAAY2P///////////wD/////////////////7IwwAAAAAAAAAAAAAAAAAAAo+P//////////AP/////////////////////koGw0BAAAAAAAAAAAAACU//////////8A///////////////////////////4uFgAAAAAAAAAADz//////////wD//////////2BgSEA0IBwA6P///////5QAAAAAAAAADP//////////AP//////////JAAAAAAAAACc/////////AAAAAAAAAAA//////////8A//////////9YAAAAAAAAACDo///////AAAAAAAAAABT//////////wD//////////6QAAAAAAAAAACCk7P/snBQAAAAAAAAAUP//////////AP//////////+BAAAAAAAAAAAAAAAAAAAAAAAAAAAACs//////////8A////////////kAAAAAAAAAAAAAAAAAAAAAAAAAAAOP///////////wD////////////8RAAAAAAAAAAAAAAAAAAAAAAAABjc////////////AP/////////////0PAAAAAAAAAAAAAAAAAAAAAAg2P////////////8A///////////////8hBQAAAAAAAAAAAAAAAAMdPT//////////////wD/////////////////+LRwSCAMAAAAHDhoqPT/////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'T' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////AP////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///////////8A/////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///////////wD/////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////AP////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///////////8A/////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///////////wD///////////////////8AAAAAAAAAAP//////////////////////AP///////////////////wAAAAAAAAAA//////////////////////8A////////////////////AAAAAAAAAAD//////////////////////wD///////////////////8AAAAAAAAAAP//////////////////////AP///////////////////wAAAAAAAAAA//////////////////////8A////////////////////AAAAAAAAAAD//////////////////////wD///////////////////8AAAAAAAAAAP//////////////////////AP///////////////////wAAAAAAAAAA//////////////////////8A////////////////////AAAAAAAAAAD//////////////////////wD///////////////////8AAAAAAAAAAP//////////////////////AP///////////////////wAAAAAAAAAA//////////////////////8A////////////////////AAAAAAAAAAD//////////////////////wD///////////////////8AAAAAAAAAAP//////////////////////AP///////////////////wAAAAAAAAAA//////////////////////8A////////////////////AAAAAAAAAAD//////////////////////wD///////////////////8AAAAAAAAAAP//////////////////////AP///////////////////wAAAAAAAAAA//////////////////////8A////////////////////AAAAAAAAAAD//////////////////////wD///////////////////8AAAAAAAAAAP//////////////////////AP///////////////////wAAAAAAAAAA//////////////////////8A////////////////////AAAAAAAAAAD//////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'U' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////8AAAAAAAAAAP///////////wAAAAAAAAAA//////////8A/////////wAAAAAAAAAA////////////AAAAAAAAAAD//////////wD/////////AAAAAAAAAAD///////////8AAAAAAAAAAP//////////AP////////8AAAAAAAAAAP///////////wAAAAAAAAAA//////////8A/////////wAAAAAAAAAA////////////AAAAAAAAAAD//////////wD/////////AAAAAAAAAAD///////////8AAAAAAAAAAP//////////AP////////8AAAAAAAAAAP///////////wAAAAAAAAAA//////////8A/////////wAAAAAAAAAA////////////AAAAAAAAAAD//////////wD/////////AAAAAAAAAAD///////////8AAAAAAAAAAP//////////AP////////8AAAAAAAAAAP///////////wAAAAAAAAAA//////////8A/////////wAAAAAAAAAA////////////AAAAAAAAAAD//////////wD/////////AAAAAAAAAAD///////////8AAAAAAAAAAP//////////AP////////8AAAAAAAAAAP///////////wAAAAAAAAAA//////////8A/////////wAAAAAAAAAA////////////AAAAAAAAAAD//////////wD/////////AAAAAAAAAAD///////////8AAAAAAAAAAP//////////AP////////8AAAAAAAAAAP///////////wAAAAAAAAAA//////////8A/////////wAAAAAAAAAA////////////AAAAAAAAAAD//////////wD/////////JAAAAAAAAADk/////////+gAAAAAAAAAHP//////////AP////////9MAAAAAAAAAJz/////////nAAAAAAAAABE//////////8A/////////4gAAAAAAAAAHOj//////+ggAAAAAAAAAHz//////////wD/////////0AAAAAAAAAAAIJzs/+ykIAAAAAAAAAAA0P//////////AP//////////QAAAAAAAAAAAAAAAAAAAAAAAAAAAAED///////////8A///////////IBAAAAAAAAAAAAAAAAAAAAAAAAAAE0P///////////wD///////////+YAAAAAAAAAAAAAAAAAAAAAAAAAJj/////////////AP////////////+UBAAAAAAAAAAAAAAAAAAAAASU//////////////8A///////////////IPAAAAAAAAAAAAAAAAAAwyP///////////////wD/////////////////0IxYOCAIAAAEIEiAyP//////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'V' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD//////zAAAAAAAAAAYP//////////////ZAAAAAAAAAAw////////AP//////kAAAAAAAAAAU/P////////////8UAAAAAAAAAJD///////8A///////oBAAAAAAAAADE////////////xAAAAAAAAAAE7P///////wD///////9MAAAAAAAAAHD///////////94AAAAAAAAAEz/////////AP///////6gAAAAAAAAAJP///////////yQAAAAAAAAArP////////8A////////+BAAAAAAAAAA1P/////////YAAAAAAAAABT4/////////wD/////////aAAAAAAAAACE/////////4QAAAAAAAAAbP//////////AP/////////EAAAAAAAAADT/////////OAAAAAAAAADM//////////8A//////////8kAAAAAAAAAOT//////+QAAAAAAAAAKP///////////wD//////////4QAAAAAAAAAmP//////nAAAAAAAAACI////////////AP//////////5AAAAAAAAABE//////9EAAAAAAAABOT///////////8A////////////QAAAAAAAAAT0////9AgAAAAAAABI/////////////wD///////////+gAAAAAAAAAKT///+kAAAAAAAAAKj/////////////AP////////////QIAAAAAAAAXP///1wAAAAAAAAM+P////////////8A/////////////1wAAAAAAAAM+P/8DAAAAAAAAGT//////////////wD/////////////vAAAAAAAAAC8/7wAAAAAAAAAxP//////////////AP//////////////HAAAAAAAAGj/aAAAAAAAACT///////////////8A//////////////94AAAAAAAAHP8cAAAAAAAAhP///////////////wD//////////////9gAAAAAAAAAkAAAAAAAAADk////////////////AP///////////////zgAAAAAAAAQAAAAAAAAQP////////////////8A////////////////lAAAAAAAAAAAAAAAAACg/////////////////wD////////////////sCAAAAAAAAAAAAAAADPT/////////////////AP////////////////9QAAAAAAAAAAAAAABg//////////////////8A/////////////////7AAAAAAAAAAAAAAAMD//////////////////wD//////////////////BQAAAAAAAAAAAAc////////////////////AP//////////////////cAAAAAAAAAAAAHz///////////////////8A///////////////////MAAAAAAAAAAAA3P///////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'W' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A//8cAAAAAAAAALz/////4AAAAAAAAAAA6P////+8AAAAAAAAABz//wD//1QAAAAAAAAAjP////+gAAAAAAAAAACo/////4wAAAAAAAAAUP//AP//jAAAAAAAAABU/////2AAAAAAAAAAAGj/////VAAAAAAAAACM//8A///EAAAAAAAAACT/////IAAAAAAAAAAAKP////8kAAAAAAAAAMT//wD///gEAAAAAAAAAPD//+AAAAAAAAAAAAAA6P//8AAAAAAAAAAE9P//AP///zAAAAAAAAAAvP//oAAAAAAAAAAAAACo//+8AAAAAAAAADD///8A////bAAAAAAAAACM//9gAAAAAAAAAAAAAGT//4wAAAAAAAAAaP///wD///+kAAAAAAAAAFT//yAAAAAAAAAAAAAAIP//VAAAAAAAAACc////AP///9gAAAAAAAAAJP/gAAAAAAAAAAAAAAAA4P8kAAAAAAAAANT///8A/////xAAAAAAAAAA8KAAAAAAAAAAAAAAAACg8AAAAAAAAAAQ/////wD/////TAAAAAAAAAC8YAAAAAAAAAAAAAAAAGC8AAAAAAAAAET/////AP////+AAAAAAAAAAIwgAAAAAAAAAAAAAAAAIIwAAAAAAAAAfP////8A/////7gAAAAAAAAANAAAAAAAACwwAAAAAAAANAAAAAAAAACw/////wD/////8AAAAAAAAAAAAAAAAAAAdHgAAAAAAAAAAAAAAAAAAOz/////AP//////KAAAAAAAAAAAAAAAAAC4vAAAAAAAAAAAAAAAAAAg//////8A//////9gAAAAAAAAAAAAAAAACPj4CAAAAAAAAAAAAAAAAFj//////wD//////5QAAAAAAAAAAAAAAABE//9IAAAAAAAAAAAAAAAAkP//////AP//////0AAAAAAAAAAAAAAAAIj//4wAAAAAAAAAAAAAAADI//////8A///////8DAAAAAAAAAAAAAAAzP//1AAAAAAAAAAAAAAABPj//////wD///////88AAAAAAAAAAAAABT/////GAAAAAAAAAAAAAA0////////AP///////3QAAAAAAAAAAAAAWP////9gAAAAAAAAAAAAAHD///////8A////////sAAAAAAAAAAAAACg/////6QAAAAAAAAAAAAApP///////wD////////kAAAAAAAAAAAAAOT/////6AAAAAAAAAAAAADc////////AP////////8cAAAAAAAAAAAo////////MAAAAAAAAAAAEP////////8A/////////1QAAAAAAAAAAHD///////94AAAAAAAAAABM/////////wD/////////jAAAAAAAAAAAtP///////7wAAAAAAAAAAID/////////AP/////////EAAAAAAAAAAT0////////+AgAAAAAAAAAuP////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'X' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD///////9UAAAAAAAAAKz///////////+sAAAAAAAAAFD/////////AP///////+QQAAAAAAAAFOT/////////8BwAAAAAAAAM5P////////8A/////////5gAAAAAAAAATP////////9kAAAAAAAAAJD//////////wD//////////0AAAAAAAAAAoP//////wAAAAAAAAAA0/P//////////AP//////////2AgAAAAAAAAQ4P////gkAAAAAAAABMz///////////8A////////////iAAAAAAAAABA////dAAAAAAAAABw/////////////wD////////////8MAAAAAAAAACU/9AEAAAAAAAAHPD/////////////AP/////////////IBAAAAAAAAAzYMAAAAAAAAACs//////////////8A//////////////90AAAAAAAAABAAAAAAAAAATP///////////////wD///////////////QgAAAAAAAAAAAAAAAAAAzg////////////////AP///////////////7wAAAAAAAAAAAAAAAAAjP////////////////8A/////////////////2AAAAAAAAAAAAAAADD8/////////////////wD/////////////////7BQAAAAAAAAAAAAEyP//////////////////AP/////////////////gDAAAAAAAAAAAAAjY//////////////////8A/////////////////0AAAAAAAAAAAAAAADj8/////////////////wD///////////////+UAAAAAAAAAAAAAAAAAJD/////////////////AP//////////////4AwAAAAAAAAAAAAAAAAADOD///////////////8A//////////////9AAAAAAAAAAAAAAAAAAAAAQP///////////////wD/////////////nAAAAAAAAAAAWAAAAAAAAAAAlP//////////////AP///////////+QQAAAAAAAAAGD/YAAAAAAAAAAM4P////////////8A////////////TAAAAAAAAAAs9P/0LAAAAAAAAABM/////////////wD//////////6AAAAAAAAAADNT////UDAAAAAAAAACg////////////AP/////////kEAAAAAAAAACg//////+gAAAAAAAAABDk//////////8A/////////0wAAAAAAAAAYP////////9gAAAAAAAAAEz//////////wD///////+oAAAAAAAAACz0//////////QsAAAAAAAAAKT/////////AP//////7BQAAAAAAAAM1P///////////9QMAAAAAAAAFOz///////8A//////9UAAAAAAAAAKD//////////////6AAAAAAAAAAVP///////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'Y' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP///////1QAAAAAAAAAAGj//////////2gAAAAAAAAAAFT///////8A////////5BAAAAAAAAAAAMT////////EAAAAAAAAAAAQ5P///////wD/////////mAAAAAAAAAAAKPj/////+CgAAAAAAAAAAJj/////////AP//////////PAAAAAAAAAAAgP////+AAAAAAAAAAAA8//////////8A///////////YCAAAAAAAAAAE2P//2AQAAAAAAAAACNj//////////wD///////////+AAAAAAAAAAAA4//84AAAAAAAAAACA////////////AP////////////woAAAAAAAAAACUlAAAAAAAAAAAKPz///////////8A/////////////8gAAAAAAAAAABAQAAAAAAAAAADI/////////////wD//////////////2wAAAAAAAAAAAAAAAAAAAAAbP//////////////AP//////////////8BwAAAAAAAAAAAAAAAAAABzw//////////////8A////////////////tAAAAAAAAAAAAAAAAAAAtP///////////////wD/////////////////VAAAAAAAAAAAAAAAAFT/////////////////AP/////////////////oEAAAAAAAAAAAAAAQ6P////////////////8A//////////////////+cAAAAAAAAAAAAAJz//////////////////wD///////////////////9AAAAAAAAAAABA////////////////////AP///////////////////9gAAAAAAAAAANj///////////////////8A/////////////////////wAAAAAAAAAA/////////////////////wD/////////////////////AAAAAAAAAAD/////////////////////AP////////////////////8AAAAAAAAAAP////////////////////8A/////////////////////wAAAAAAAAAA/////////////////////wD/////////////////////AAAAAAAAAAD/////////////////////AP////////////////////8AAAAAAAAAAP////////////////////8A/////////////////////wAAAAAAAAAA/////////////////////wD/////////////////////AAAAAAAAAAD/////////////////////AP////////////////////8AAAAAAAAAAP////////////////////8A/////////////////////wAAAAAAAAAA/////////////////////wD/////////////////////AAAAAAAAAAD/////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'Z' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAD//////////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAP//////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAA//////////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAD//////////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAP//////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAQ//////////////8A/////////////////////////1AAAAAAAAAABLz//////////////wD///////////////////////98AAAAAAAAAACY////////////////AP//////////////////////pAAAAAAAAAAAaP////////////////8A/////////////////////8QIAAAAAAAAAET8/////////////////wD////////////////////gGAAAAAAAAAAo9P//////////////////AP//////////////////9CwAAAAAAAAAFNz///////////////////8A//////////////////xMAAAAAAAAAATA/////////////////////wD/////////////////eAAAAAAAAAAAnP//////////////////////AP///////////////5wAAAAAAAAAAHT///////////////////////8A///////////////ABAAAAAAAAABM/P///////////////////////wD/////////////3BQAAAAAAAAALPT/////////////////////////AP////////////QoAAAAAAAAABjg//////////////////////////8A///////////8SAAAAAAAAAAExP///////////////////////////wD//////////2wAAAAAAAAAAKD/////////////////////////////AP////////+YAAAAAAAAAAB8//////////////////////////////8A/////////wQAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////wD/////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////AP////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////8A/////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////wD/////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////AP////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - ); - } -} diff --git a/install/update/new/phpbb/captcha/plugins/qa.php b/install/update/new/phpbb/captcha/plugins/qa.php deleted file mode 100644 index 966b8d3..0000000 --- a/install/update/new/phpbb/captcha/plugins/qa.php +++ /dev/null @@ -1,1040 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\captcha\plugins; - -/** -* And now to something completely different. Let's make a captcha without extending the abstract class. -* QA CAPTCHA sample implementation -*/ -class qa -{ - var $confirm_id; - var $answer; - var $question_ids = []; - var $question_text; - var $question_lang; - var $question_strict; - var $attempts = 0; - var $type; - // dirty trick: 0 is false, but can still encode that the captcha is not yet validated - var $solved = 0; - - protected $table_captcha_questions; - protected $table_captcha_answers; - protected $table_qa_confirm; - - /** - * @var string name of the service. - */ - protected $service_name; - - /** - * Constructor - * - * @param string $table_captcha_questions - * @param string $table_captcha_answers - * @param string $table_qa_confirm - */ - function __construct($table_captcha_questions, $table_captcha_answers, $table_qa_confirm) - { - $this->table_captcha_questions = $table_captcha_questions; - $this->table_captcha_answers = $table_captcha_answers; - $this->table_qa_confirm = $table_qa_confirm; - } - - /** - * @param int $type as per the CAPTCHA API docs, the type - */ - function init($type) - { - global $config, $db, $user, $request; - - // load our language file - $user->add_lang('captcha_qa'); - - // read input - $this->confirm_id = $request->variable('qa_confirm_id', ''); - $this->answer = $request->variable('qa_answer', '', true); - - $this->type = (int) $type; - $this->question_lang = $user->lang_name; - - // we need all defined questions - shouldn't be too many, so we can just grab them - // try the user's lang first - $sql = 'SELECT question_id - FROM ' . $this->table_captcha_questions . " - WHERE lang_iso = '" . $db->sql_escape($user->lang_name) . "'"; - $result = $db->sql_query($sql, 3600); - - while ($row = $db->sql_fetchrow($result)) - { - $this->question_ids[$row['question_id']] = $row['question_id']; - } - $db->sql_freeresult($result); - - // fallback to the board default lang - if (!count($this->question_ids)) - { - $this->question_lang = $config['default_lang']; - - $sql = 'SELECT question_id - FROM ' . $this->table_captcha_questions . " - WHERE lang_iso = '" . $db->sql_escape($config['default_lang']) . "'"; - $result = $db->sql_query($sql, 7200); - - while ($row = $db->sql_fetchrow($result)) - { - $this->question_ids[$row['question_id']] = $row['question_id']; - } - $db->sql_freeresult($result); - } - - // final fallback to any language - if (!count($this->question_ids)) - { - $this->question_lang = ''; - - $sql = 'SELECT q.question_id, q.lang_iso - FROM ' . $this->table_captcha_questions . ' q, ' . $this->table_captcha_answers . ' a - WHERE q.question_id = a.question_id'; - $result = $db->sql_query($sql, 7200); - - while ($row = $db->sql_fetchrow($result)) - { - if (empty($this->question_lang)) - { - $this->question_lang = $row['lang_iso']; - } - $this->question_ids[$row['question_id']] = $row['question_id']; - } - $db->sql_freeresult($result); - } - - // okay, if there is a confirm_id, we try to load that confirm's state. If not, we try to find one - if (!$this->load_answer() && (!$this->load_confirm_id() || !$this->load_answer())) - { - // we have no valid confirm ID, better get ready to ask something - $this->select_question(); - } - } - - /** - * See if the captcha has created its tables. - */ - public function is_installed() - { - global $phpbb_container; - - $db_tool = $phpbb_container->get('dbal.tools'); - - return $db_tool->sql_table_exists($this->table_captcha_questions); - } - - /** - * API function - for the captcha to be available, it must have installed itself and there has to be at least one question in the board's default lang - */ - public function is_available() - { - global $config, $db, $user; - - // load language file for pretty display in the ACP dropdown - $user->add_lang('captcha_qa'); - - if (!$this->is_installed()) - { - return false; - } - - $sql = 'SELECT COUNT(question_id) AS question_count - FROM ' . $this->table_captcha_questions . " - WHERE lang_iso = '" . $db->sql_escape($config['default_lang']) . "'"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - return ((bool) $row['question_count']); - } - - /** - * API function - */ - function has_config() - { - return true; - } - - /** - * API function - */ - static public function get_name() - { - return 'CAPTCHA_QA'; - } - - /** - * @return string the name of the service corresponding to the plugin - */ - function get_service_name() - { - return $this->service_name; - } - - /** - * Set the name of the plugin - * - * @param string $name - */ - public function set_name($name) - { - $this->service_name = $name; - } - - /** - * API function - not needed as we don't display an image - */ - function execute_demo() - { - } - - /** - * API function - not needed as we don't display an image - */ - function execute() - { - } - - /** - * API function - send the question to the template - */ - function get_template() - { - global $phpbb_log, $template, $user; - - if ($this->is_solved()) - { - return false; - } - else if (empty($this->question_text) || !count($this->question_ids)) - { - /** @var \phpbb\log\log_interface $phpbb_log */ - $phpbb_log->add('critical', $user->data['user_id'], $user->ip, 'LOG_ERROR_CAPTCHA', time(), array($user->lang('CONFIRM_QUESTION_MISSING'))); - return false; - } - else - { - $template->assign_vars(array( - 'QA_CONFIRM_QUESTION' => $this->question_text, - 'QA_CONFIRM_ID' => $this->confirm_id, - 'S_CONFIRM_CODE' => true, - 'S_TYPE' => $this->type, - )); - - return 'captcha_qa.html'; - } - } - - /** - * API function - we just display a mockup so that the captcha doesn't need to be installed - */ - function get_demo_template() - { - global $config, $db, $template; - - if ($this->is_available()) - { - $sql = 'SELECT question_text - FROM ' . $this->table_captcha_questions . " - WHERE lang_iso = '" . $db->sql_escape($config['default_lang']) . "'"; - $result = $db->sql_query_limit($sql, 1); - if ($row = $db->sql_fetchrow($result)) - { - $template->assign_vars(array( - 'QA_CONFIRM_QUESTION' => $row['question_text'], - )); - } - $db->sql_freeresult($result); - } - return 'captcha_qa_acp_demo.html'; - } - - /** - * API function - */ - function get_hidden_fields() - { - $hidden_fields = array(); - - // this is required - otherwise we would forget about the captcha being already solved - if ($this->solved) - { - $hidden_fields['qa_answer'] = $this->answer; - } - $hidden_fields['qa_confirm_id'] = $this->confirm_id; - - return $hidden_fields; - } - - /** - * API function - */ - function garbage_collect($type = 0) - { - global $db; - - $sql = 'SELECT c.confirm_id - FROM ' . $this->table_qa_confirm . ' c - LEFT JOIN ' . SESSIONS_TABLE . ' s - ON (c.session_id = s.session_id) - WHERE s.session_id IS NULL' . - ((empty($type)) ? '' : ' AND c.confirm_type = ' . (int) $type); - $result = $db->sql_query($sql); - - if ($row = $db->sql_fetchrow($result)) - { - $sql_in = array(); - - do - { - $sql_in[] = (string) $row['confirm_id']; - } - while ($row = $db->sql_fetchrow($result)); - - if (count($sql_in)) - { - $sql = 'DELETE FROM ' . $this->table_qa_confirm . ' - WHERE ' . $db->sql_in_set('confirm_id', $sql_in); - $db->sql_query($sql); - } - } - $db->sql_freeresult($result); - } - - /** - * API function - we don't drop the tables here, as that would cause the loss of all entered questions. - */ - function uninstall() - { - $this->garbage_collect(0); - } - - /** - * API function - set up shop - */ - function install() - { - global $phpbb_container; - - $db_tool = $phpbb_container->get('dbal.tools'); - $schemas = array( - $this->table_captcha_questions => array ( - 'COLUMNS' => array( - 'question_id' => array('UINT', null, 'auto_increment'), - 'strict' => array('BOOL', 0), - 'lang_id' => array('UINT', 0), - 'lang_iso' => array('VCHAR:30', ''), - 'question_text' => array('TEXT_UNI', ''), - ), - 'PRIMARY_KEY' => 'question_id', - 'KEYS' => array( - 'lang' => array('INDEX', 'lang_iso'), - ), - ), - $this->table_captcha_answers => array ( - 'COLUMNS' => array( - 'question_id' => array('UINT', 0), - 'answer_text' => array('STEXT_UNI', ''), - ), - 'KEYS' => array( - 'qid' => array('INDEX', 'question_id'), - ), - ), - $this->table_qa_confirm => array ( - 'COLUMNS' => array( - 'session_id' => array('CHAR:32', ''), - 'confirm_id' => array('CHAR:32', ''), - 'lang_iso' => array('VCHAR:30', ''), - 'question_id' => array('UINT', 0), - 'attempts' => array('UINT', 0), - 'confirm_type' => array('USINT', 0), - ), - 'KEYS' => array( - 'session_id' => array('INDEX', 'session_id'), - 'lookup' => array('INDEX', array('confirm_id', 'session_id', 'lang_iso')), - ), - 'PRIMARY_KEY' => 'confirm_id', - ), - ); - - foreach ($schemas as $table => $schema) - { - if (!$db_tool->sql_table_exists($table)) - { - $db_tool->sql_create_table($table, $schema); - } - } - } - - /** - * API function - see what has to be done to validate - */ - function validate() - { - global $phpbb_log, $user; - - $error = ''; - - if (!count($this->question_ids)) - { - /** @var \phpbb\log\log_interface $phpbb_log */ - $phpbb_log->add('critical', $user->data['user_id'], $user->ip, 'LOG_ERROR_CAPTCHA', time(), array($user->lang('CONFIRM_QUESTION_MISSING'))); - return $user->lang('CONFIRM_QUESTION_MISSING'); - } - - if (!$this->confirm_id) - { - $error = $user->lang['CONFIRM_QUESTION_WRONG']; - } - else - { - if ($this->check_answer()) - { - $this->solved = true; - } - else - { - $error = $user->lang['CONFIRM_QUESTION_WRONG']; - } - } - - if (strlen($error)) - { - // okay, incorrect answer. Let's ask a new question. - $this->new_attempt(); - $this->solved = false; - - return $error; - } - else - { - return false; - } - } - - /** - * Select a question - */ - function select_question() - { - global $db, $user; - - if (!count($this->question_ids)) - { - return; - } - $this->confirm_id = md5(unique_id($user->ip)); - $this->question = (int) array_rand($this->question_ids); - - $sql = 'INSERT INTO ' . $this->table_qa_confirm . ' ' . $db->sql_build_array('INSERT', array( - 'confirm_id' => (string) $this->confirm_id, - 'session_id' => (string) $user->session_id, - 'lang_iso' => (string) $this->question_lang, - 'confirm_type' => (int) $this->type, - 'question_id' => (int) $this->question, - )); - $db->sql_query($sql); - - $this->load_answer(); - } - - /** - * New Question, if desired. - */ - function reselect_question() - { - global $db, $user; - - if (!count($this->question_ids)) - { - return; - } - - $this->question = (int) array_rand($this->question_ids); - $this->solved = 0; - - $sql = 'UPDATE ' . $this->table_qa_confirm . ' - SET question_id = ' . (int) $this->question . " - WHERE confirm_id = '" . $db->sql_escape($this->confirm_id) . "' - AND session_id = '" . $db->sql_escape($user->session_id) . "'"; - $db->sql_query($sql); - - $this->load_answer(); - } - - /** - * Wrong answer, so we increase the attempts and use a different question. - */ - function new_attempt() - { - global $db, $user; - - // yah, I would prefer a stronger rand, but this should work - $this->question = (int) array_rand($this->question_ids); - $this->solved = 0; - - $sql = 'UPDATE ' . $this->table_qa_confirm . ' - SET question_id = ' . (int) $this->question . ", - attempts = attempts + 1 - WHERE confirm_id = '" . $db->sql_escape($this->confirm_id) . "' - AND session_id = '" . $db->sql_escape($user->session_id) . "'"; - $db->sql_query($sql); - - $this->load_answer(); - } - - - /** - * See if there is already an entry for the current session. - */ - function load_confirm_id() - { - global $db, $user; - - $sql = 'SELECT confirm_id - FROM ' . $this->table_qa_confirm . " - WHERE - session_id = '" . $db->sql_escape($user->session_id) . "' - AND lang_iso = '" . $db->sql_escape($this->question_lang) . "' - AND confirm_type = " . $this->type; - $result = $db->sql_query_limit($sql, 1); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - $this->confirm_id = $row['confirm_id']; - return true; - } - return false; - } - - /** - * Look up everything we need and populate the instance variables. - */ - function load_answer() - { - global $db, $user; - - if (!strlen($this->confirm_id) || !count($this->question_ids)) - { - return false; - } - - $sql = 'SELECT con.question_id, attempts, question_text, strict - FROM ' . $this->table_qa_confirm . ' con, ' . $this->table_captcha_questions . " qes - WHERE con.question_id = qes.question_id - AND confirm_id = '" . $db->sql_escape($this->confirm_id) . "' - AND session_id = '" . $db->sql_escape($user->session_id) . "' - AND qes.lang_iso = '" . $db->sql_escape($this->question_lang) . "' - AND confirm_type = " . $this->type; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - $this->question = $row['question_id']; - - $this->attempts = $row['attempts']; - $this->question_strict = $row['strict']; - $this->question_text = $row['question_text']; - - return true; - } - - return false; - } - - /** - * The actual validation - */ - function check_answer() - { - global $db, $request; - - $answer = ($this->question_strict) ? $request->variable('qa_answer', '', true) : utf8_clean_string($request->variable('qa_answer', '', true)); - - $sql = 'SELECT answer_text - FROM ' . $this->table_captcha_answers . ' - WHERE question_id = ' . (int) $this->question; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $solution = ($this->question_strict) ? $row['answer_text'] : utf8_clean_string($row['answer_text']); - - if ($solution === $answer) - { - $this->solved = true; - - break; - } - } - $db->sql_freeresult($result); - - return $this->solved; - } - - /** - * API function - */ - function get_attempt_count() - { - return $this->attempts; - } - - /** - * API function - */ - function reset() - { - global $db, $user; - - $sql = 'DELETE FROM ' . $this->table_qa_confirm . " - WHERE session_id = '" . $db->sql_escape($user->session_id) . "' - AND confirm_type = " . (int) $this->type; - $db->sql_query($sql); - - // we leave the class usable by generating a new question - $this->select_question(); - } - - /** - * API function - */ - function is_solved() - { - global $request; - - if ($request->variable('qa_answer', false) && $this->solved === 0) - { - $this->validate(); - } - - return (bool) $this->solved; - } - - /** - * API function - The ACP backend, this marks the end of the easy methods - */ - function acp_page($id, $module) - { - global $config, $request, $phpbb_log, $template, $user; - - $user->add_lang('acp/board'); - $user->add_lang('captcha_qa'); - - if (!self::is_installed()) - { - $this->install(); - } - - $module->tpl_name = 'captcha_qa_acp'; - $module->page_title = 'ACP_VC_SETTINGS'; - $form_key = 'acp_captcha'; - add_form_key($form_key); - - $submit = $request->variable('submit', false); - $question_id = $request->variable('question_id', 0); - $action = $request->variable('action', ''); - - // we have two pages, so users might want to navigate from one to the other - $list_url = $module->u_action . "&configure=1&select_captcha=" . $this->get_service_name(); - - $template->assign_vars(array( - 'U_ACTION' => $module->u_action, - 'QUESTION_ID' => $question_id , - 'CLASS' => $this->get_service_name(), - )); - - // show the list? - if (!$question_id && $action != 'add') - { - $this->acp_question_list($module); - } - else if ($question_id && $action == 'delete') - { - if ($this->get_service_name() !== $config['captcha_plugin'] || !$this->acp_is_last($question_id)) - { - if (confirm_box(true)) - { - $this->acp_delete_question($question_id); - - trigger_error($user->lang['QUESTION_DELETED'] . adm_back_link($list_url)); - } - else - { - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( - 'question_id' => $question_id, - 'action' => $action, - 'configure' => 1, - 'select_captcha' => $this->get_service_name(), - )) - ); - } - } - else - { - trigger_error($user->lang['QA_LAST_QUESTION'] . adm_back_link($list_url), E_USER_WARNING); - } - } - else - { - // okay, show the editor - $question_input = $this->acp_get_question_input(); - $langs = $this->get_languages(); - - foreach ($langs as $lang => $entry) - { - $template->assign_block_vars('langs', array( - 'ISO' => $lang, - 'NAME' => $entry['name'], - )); - } - - $template->assign_vars(array( - 'U_LIST' => $list_url, - )); - - if ($question_id) - { - if ($question = $this->acp_get_question_data($question_id)) - { - $template->assign_vars(array( - 'QUESTION_TEXT' => ($question_input['question_text']) ? $question_input['question_text'] : $question['question_text'], - 'LANG_ISO' => ($question_input['lang_iso']) ? $question_input['lang_iso'] : $question['lang_iso'], - 'STRICT' => (isset($_REQUEST['strict'])) ? $question_input['strict'] : $question['strict'], - 'ANSWERS' => implode("\n", $question['answers']), - )); - } - else - { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($list_url)); - } - } - else - { - $template->assign_vars(array( - 'QUESTION_TEXT' => $question_input['question_text'], - 'LANG_ISO' => $question_input['lang_iso'], - 'STRICT' => $question_input['strict'], - 'ANSWERS' => (is_array($question_input['answers'])) ? implode("\n", $question_input['answers']) : '', - )); - } - - if ($submit && check_form_key($form_key)) - { - if (!$this->validate_input($question_input)) - { - $template->assign_vars(array( - 'S_ERROR' => true, - )); - } - else - { - if ($question_id) - { - $this->acp_update_question($question_input, $question_id); - } - else - { - $this->acp_add_question($question_input); - } - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_CONFIG_VISUAL'); - trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($list_url)); - } - } - else if ($submit) - { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($list_url), E_USER_WARNING); - } - } - } - - /** - * This handles the list overview - */ - function acp_question_list($module) - { - global $db, $template; - - $sql = 'SELECT * - FROM ' . $this->table_captcha_questions; - $result = $db->sql_query($sql); - - $template->assign_vars(array( - 'S_LIST' => true, - )); - - while ($row = $db->sql_fetchrow($result)) - { - $url = $module->u_action . "&question_id={$row['question_id']}&configure=1&select_captcha=" . $this->get_service_name() . '&'; - - $template->assign_block_vars('questions', array( - 'QUESTION_TEXT' => $row['question_text'], - 'QUESTION_ID' => $row['question_id'], - 'QUESTION_LANG' => $row['lang_iso'], - 'U_DELETE' => "{$url}action=delete", - 'U_EDIT' => "{$url}action=edit", - )); - } - $db->sql_freeresult($result); - } - - /** - * Grab a question and bring it into a format the editor understands - */ - function acp_get_question_data($question_id) - { - global $db; - - if ($question_id) - { - $sql = 'SELECT * - FROM ' . $this->table_captcha_questions . ' - WHERE question_id = ' . $question_id; - $result = $db->sql_query($sql); - $question = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$question) - { - return false; - } - - $question['answers'] = array(); - - $sql = 'SELECT * - FROM ' . $this->table_captcha_answers . ' - WHERE question_id = ' . $question_id; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $question['answers'][] = $row['answer_text']; - } - $db->sql_freeresult($result); - - return $question; - } - - return false; - } - - /** - * Grab a question from input and bring it into a format the editor understands - */ - function acp_get_question_input() - { - global $request; - - $answers = $request->variable('answers', '', true); - - // Convert answers into array and filter if answers are set - if (strlen($answers)) - { - $answers = array_filter(array_map('trim', explode("\n", $answers)), function ($value) { - return $value !== ''; - }); - } - - $question = array( - 'question_text' => $request->variable('question_text', '', true), - 'strict' => $request->variable('strict', false), - 'lang_iso' => $request->variable('lang_iso', ''), - 'answers' => $answers, - ); - return $question; - } - - /** - * Update a question. - * param mixed $data : an array as created from acp_get_question_input or acp_get_question_data - */ - function acp_update_question($data, $question_id) - { - global $db, $cache; - - // easier to delete all answers than to figure out which to update - $sql = 'DELETE FROM ' . $this->table_captcha_answers . " WHERE question_id = $question_id"; - $db->sql_query($sql); - - $langs = $this->get_languages(); - $question_ary = $data; - $question_ary['lang_id'] = $langs[$question_ary['lang_iso']]['id']; - unset($question_ary['answers']); - - $sql = 'UPDATE ' . $this->table_captcha_questions . ' - SET ' . $db->sql_build_array('UPDATE', $question_ary) . " - WHERE question_id = $question_id"; - $db->sql_query($sql); - - $this->acp_insert_answers($data, $question_id); - - $cache->destroy('sql', $this->table_captcha_questions); - } - - /** - * Insert a question. - * param mixed $data : an array as created from acp_get_question_input or acp_get_question_data - */ - function acp_add_question($data) - { - global $db, $cache; - - $langs = $this->get_languages(); - $question_ary = $data; - - $question_ary['lang_id'] = $langs[$data['lang_iso']]['id']; - unset($question_ary['answers']); - - $sql = 'INSERT INTO ' . $this->table_captcha_questions . ' ' . $db->sql_build_array('INSERT', $question_ary); - $db->sql_query($sql); - - $question_id = $db->sql_nextid(); - - $this->acp_insert_answers($data, $question_id); - - $cache->destroy('sql', $this->table_captcha_questions); - } - - /** - * Insert the answers. - * param mixed $data : an array as created from acp_get_question_input or acp_get_question_data - */ - function acp_insert_answers($data, $question_id) - { - global $db, $cache; - - foreach ($data['answers'] as $answer) - { - $answer_ary = array( - 'question_id' => $question_id, - 'answer_text' => $answer, - ); - - $sql = 'INSERT INTO ' . $this->table_captcha_answers . ' ' . $db->sql_build_array('INSERT', $answer_ary); - $db->sql_query($sql); - } - - $cache->destroy('sql', $this->table_captcha_answers); - } - - /** - * Delete a question. - */ - function acp_delete_question($question_id) - { - global $db, $cache; - - $tables = array($this->table_captcha_questions, $this->table_captcha_answers); - - foreach ($tables as $table) - { - $sql = "DELETE FROM $table - WHERE question_id = $question_id"; - $db->sql_query($sql); - } - - $cache->destroy('sql', $tables); - } - - /** - * Check if the entered data can be inserted/used - * param mixed $data : an array as created from acp_get_question_input or acp_get_question_data - */ - function validate_input($question_data) - { - $langs = $this->get_languages(); - - if (!isset($question_data['lang_iso']) || - !isset($question_data['question_text']) || - !isset($question_data['strict']) || - !isset($question_data['answers'])) - { - return false; - } - - if (!isset($langs[$question_data['lang_iso']]) || - !strlen($question_data['question_text']) || - !count($question_data['answers']) || - !is_array($question_data['answers'])) - { - return false; - } - - return true; - } - - /** - * List the installed language packs - */ - function get_languages() - { - global $db; - - $sql = 'SELECT * - FROM ' . LANG_TABLE; - $result = $db->sql_query($sql); - - $langs = array(); - while ($row = $db->sql_fetchrow($result)) - { - $langs[$row['lang_iso']] = array( - 'name' => $row['lang_local_name'], - 'id' => (int) $row['lang_id'], - ); - } - $db->sql_freeresult($result); - - return $langs; - } - - - - /** - * See if there is a question other than the one we have - */ - function acp_is_last($question_id) - { - global $config, $db; - - if ($question_id) - { - $sql = 'SELECT question_id - FROM ' . $this->table_captcha_questions . " - WHERE lang_iso = '" . $db->sql_escape($config['default_lang']) . "' - AND question_id <> " . (int) $question_id; - $result = $db->sql_query_limit($sql, 1); - $question = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$question) - { - return true; - } - return false; - } - } -} diff --git a/install/update/new/phpbb/class_loader.php b/install/update/new/phpbb/class_loader.php deleted file mode 100644 index a4b6931..0000000 --- a/install/update/new/phpbb/class_loader.php +++ /dev/null @@ -1,164 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb; - -/** -* The class loader resolves class names to file system paths and loads them if -* necessary. -* -* Classes have to be of the form phpbb_(dir_)*(classpart_)*, so directory names -* must never contain underscores. Example: phpbb_dir_subdir_class_name is a -* valid class name, while phpbb_dir_sub_dir_class_name is not. -* -* If every part of the class name is a directory, the last directory name is -* also used as the filename, e.g. phpbb_dir would resolve to dir/dir.php. -*/ -class class_loader -{ - private $namespace; - private $path; - private $php_ext; - private $cache; - - /** - * A map of looked up class names to paths relative to $this->path. - * This map is stored in cache and looked up if the cache is available. - * - * @var array - */ - private $cached_paths = array(); - - /** - * Creates a new \phpbb\class_loader, which loads files with the given - * file extension from the given path. - * - * @param string $namespace Required namespace for files to be loaded - * @param string $path Directory to load files from - * @param string $php_ext The file extension for PHP files - * @param \phpbb\cache\driver\driver_interface $cache An implementation of the phpBB cache interface. - */ - public function __construct($namespace, $path, $php_ext = 'php', \phpbb\cache\driver\driver_interface $cache = null) - { - if ($namespace[0] !== '\\') - { - $namespace = '\\' . $namespace; - } - - $this->namespace = $namespace; - $this->path = $path; - $this->php_ext = $php_ext; - - $this->set_cache($cache); - } - - /** - * Provide the class loader with a cache to store paths. If set to null, the - * the class loader will resolve paths by checking for the existence of every - * directory in the class name every time. - * - * @param \phpbb\cache\driver\driver_interface $cache An implementation of the phpBB cache interface. - */ - public function set_cache(\phpbb\cache\driver\driver_interface $cache = null) - { - if ($cache) - { - $this->cached_paths = $cache->get('class_loader_' . str_replace('\\', '__', $this->namespace)); - - if ($this->cached_paths === false) - { - $this->cached_paths = array(); - } - } - - $this->cache = $cache; - } - - /** - * Registers the class loader as an autoloader using SPL. - */ - public function register() - { - spl_autoload_register(array($this, 'load_class')); - } - - /** - * Removes the class loader from the SPL autoloader stack. - */ - public function unregister() - { - spl_autoload_unregister(array($this, 'load_class')); - } - - /** - * Resolves a phpBB class name to a relative path which can be included. - * - * @param string $class The class name to resolve, must be in the - * namespace the loader was constructed with. - * Has to begin with \ - * @return string|bool A relative path to the file containing the - * class or false if looking it up failed. - */ - public function resolve_path($class) - { - if (isset($this->cached_paths[$class])) - { - return $this->path . $this->cached_paths[$class] . '.' . $this->php_ext; - } - - if (!preg_match('/^' . preg_quote($this->namespace, '/') . '[a-zA-Z0-9_\\\\]+$/', $class)) - { - return false; - } - - $relative_path = str_replace('\\', '/', substr($class, strlen($this->namespace))); - - if (!file_exists($this->path . $relative_path . '.' . $this->php_ext)) - { - return false; - } - - if ($this->cache) - { - $this->cached_paths[$class] = $relative_path; - $this->cache->put('class_loader_' . str_replace('\\', '__', $this->namespace), $this->cached_paths); - } - - return $this->path . $relative_path . '.' . $this->php_ext; - } - - /** - * Resolves a class name to a path and then includes it. - * - * @param string $class The class name which is being loaded. - */ - public function load_class($class) - { - // In general $class is not supposed to contain a leading backslash, - // but sometimes it does. See tickets PHP-50731 and HHVM-1840. - if ($class[0] !== '\\') - { - $class = '\\' . $class; - } - - if (substr($class, 0, strlen($this->namespace)) === $this->namespace) - { - $path = $this->resolve_path($class); - - if ($path) - { - require $path; - } - } - } -} diff --git a/install/update/new/phpbb/config/config.php b/install/update/new/phpbb/config/config.php deleted file mode 100644 index c619cae..0000000 --- a/install/update/new/phpbb/config/config.php +++ /dev/null @@ -1,186 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\config; - -/** -* Configuration container class -*/ -class config implements \ArrayAccess, \IteratorAggregate, \Countable -{ - /** - * The configuration data - * @var array(string => string) - */ - protected $config; - - /** - * Creates a configuration container with a default set of values - * - * @param array(string => string) $config The configuration data. - */ - public function __construct(array $config) - { - $this->config = $config; - } - - /** - * Retrieves an ArrayIterator over the configuration values. - * - * @return \ArrayIterator An iterator over all config data - */ - public function getIterator() - { - return new \ArrayIterator($this->config); - } - - /** - * Checks if the specified config value exists. - * - * @param string $key The configuration option's name. - * @return bool Whether the configuration option exists. - */ - public function offsetExists($key) - { - return isset($this->config[$key]); - } - - /** - * Retrieves a configuration value. - * - * @param string $key The configuration option's name. - * @return string The configuration value - */ - public function offsetGet($key) - { - return (isset($this->config[$key])) ? $this->config[$key] : ''; - } - - /** - * Temporarily overwrites the value of a configuration variable. - * - * The configuration change will not persist. It will be lost - * after the request. - * - * @param string $key The configuration option's name. - * @param string $value The temporary value. - */ - public function offsetSet($key, $value) - { - $this->config[$key] = $value; - } - - /** - * Called when deleting a configuration value directly, triggers an error. - * - * @param string $key The configuration option's name. - */ - public function offsetUnset($key) - { - trigger_error('Config values have to be deleted explicitly with the \phpbb\config\config::delete($key) method.', E_USER_ERROR); - } - - /** - * Retrieves the number of configuration options currently set. - * - * @return int Number of config options - */ - public function count() - { - return count($this->config); - } - - /** - * Removes a configuration option - * - * @param String $key The configuration option's name - * @param bool $use_cache Whether this variable should be cached or if it - * changes too frequently to be efficiently cached - * @return null - */ - public function delete($key, $use_cache = true) - { - unset($this->config[$key]); - } - - /** - * Sets a configuration option's value - * - * @param string $key The configuration option's name - * @param string $value New configuration value - * @param bool $use_cache Whether this variable should be cached or if it - * changes too frequently to be efficiently cached. - */ - public function set($key, $value, $use_cache = true) - { - $this->config[$key] = $value; - } - - /** - * Sets a configuration option's value only if the old_value matches the - * current configuration value or the configuration value does not exist yet. - * - * @param string $key The configuration option's name - * @param string $old_value Current configuration value - * @param string $new_value New configuration value - * @param bool $use_cache Whether this variable should be cached or if it - * changes too frequently to be efficiently cached. - * @return bool True if the value was changed, false otherwise. - */ - public function set_atomic($key, $old_value, $new_value, $use_cache = true) - { - if (!isset($this->config[$key]) || $this->config[$key] == $old_value) - { - $this->config[$key] = $new_value; - return true; - } - return false; - } - - /** - * Checks configuration option's value only if the new_value matches the - * current configuration value and the configuration value does exist.Called - * only after set_atomic has been called. - * - * @param string $key The configuration option's name - * @param string $new_value New configuration value - * @throws \phpbb\exception\http_exception when config value is set and not equal to new_value. - * @return bool True if the value was changed, false otherwise. - */ - public function ensure_lock($key, $new_value) - { - if (isset($this->config[$key]) && $this->config[$key] == $new_value) - { - return true; - } - throw new \phpbb\exception\http_exception(500, 'Failure while aqcuiring locks.'); - } - - /** - * Increments an integer configuration value. - * - * @param string $key The configuration option's name - * @param int $increment Amount to increment by - * @param bool $use_cache Whether this variable should be cached or if it - * changes too frequently to be efficiently cached. - */ - function increment($key, $increment, $use_cache = true) - { - if (!isset($this->config[$key])) - { - $this->config[$key] = 0; - } - - $this->config[$key] += $increment; - } -} diff --git a/install/update/new/phpbb/config_php_file.php b/install/update/new/phpbb/config_php_file.php deleted file mode 100644 index e3f7357..0000000 --- a/install/update/new/phpbb/config_php_file.php +++ /dev/null @@ -1,166 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb; - -class config_php_file -{ - /** @var string phpBB Root Path */ - protected $phpbb_root_path; - - /** @var string php file extension */ - protected $php_ext; - - /** - * Indicates whether the php config file has been loaded. - * - * @var bool - */ - protected $config_loaded = false; - - /** - * The content of the php config file - * - * @var array - */ - protected $config_data = array(); - - /** - * The path to the config file. (Default: $phpbb_root_path . 'config.' . $php_ext) - * - * @var string - */ - protected $config_file; - - private $defined_vars; - - /** - * Constructor - * - * @param string $phpbb_root_path phpBB Root Path - * @param string $php_ext php file extension - */ - function __construct($phpbb_root_path, $php_ext) - { - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - $this->config_file = $this->phpbb_root_path . 'config.' . $this->php_ext; - } - - /** - * Set the path to the config file. - * - * @param string $config_file - */ - public function set_config_file($config_file) - { - $this->config_file = $config_file; - $this->config_loaded = false; - } - - /** - * Returns an associative array containing the variables defined by the config file. - * - * @return array Return the content of the config file or an empty array if the file does not exists. - */ - public function get_all() - { - $this->load_config_file(); - - return $this->config_data; - } - - /** - * Return the value of a variable defined into the config.php file or null if the variable does not exist. - * - * @param string $variable The name of the variable - * @return mixed Value of the variable or null if the variable is not defined. - */ - public function get($variable) - { - $this->load_config_file(); - - return isset($this->config_data[$variable]) ? $this->config_data[$variable] : null; - } - - /** - * Load the config file and store the information. - * - * @return null - */ - protected function load_config_file() - { - if (!$this->config_loaded && file_exists($this->config_file)) - { - $this->defined_vars = get_defined_vars(); - - require($this->config_file); - $this->config_data = array_diff_key(get_defined_vars(), $this->defined_vars); - - $this->config_loaded = true; - } - } - - /** - * Convert either 3.0 dbms or 3.1 db driver class name to 3.1 db driver class name. - * - * If $dbms is a valid 3.1 db driver class name, returns it unchanged. - * Otherwise prepends phpbb\db\driver\ to the dbms to convert a 3.0 dbms - * to 3.1 db driver class name. - * - * @param string $dbms dbms parameter - * @return string driver class - * @throws \RuntimeException - */ - public function convert_30_dbms_to_31($dbms) - { - // Note: this check is done first because mysqli extension - // supplies a mysqli class, and class_exists($dbms) would return - // true for mysqli class. - // However, per the docblock any valid 3.1 driver name should be - // recognized by this function, and have priority over 3.0 dbms. - if (strpos($dbms, 'phpbb\db\driver') === false && class_exists('phpbb\db\driver\\' . $dbms)) - { - return 'phpbb\db\driver\\' . $dbms; - } - - if (class_exists($dbms)) - { - // Additionally we could check that $dbms extends phpbb\db\driver\driver. - // http://php.net/manual/en/class.reflectionclass.php - // Beware of possible performance issues: - // http://stackoverflow.com/questions/294582/php-5-reflection-api-performance - // We could check for interface implementation in all paths or - // only when we do not prepend phpbb\db\driver\. - - /* - $reflection = new \ReflectionClass($dbms); - - if ($reflection->isSubclassOf('phpbb\db\driver\driver')) - { - return $dbms; - } - */ - - return $dbms; - } - - // Force use of mysqli when specifying mysql - if (preg_match('/(phpbb\\\db\\\driver\\\)?mysql$/i', $dbms)) - { - return 'phpbb\db\driver\mysqli'; - } - - throw new \RuntimeException("You have specified an invalid dbms driver: $dbms"); - } -} diff --git a/install/update/new/phpbb/console/command/cron/run.php b/install/update/new/phpbb/console/command/cron/run.php deleted file mode 100644 index 511c6bc..0000000 --- a/install/update/new/phpbb/console/command/cron/run.php +++ /dev/null @@ -1,173 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\console\command\cron; - -use phpbb\exception\runtime_exception; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Output\OutputInterface; - -class run extends \phpbb\console\command\command -{ - /** @var \phpbb\cron\manager */ - protected $cron_manager; - - /** @var \phpbb\lock\db */ - protected $lock_db; - - /** - * Construct method - * - * @param \phpbb\user $user The user object (used to get language information) - * @param \phpbb\cron\manager $cron_manager The cron manager containing - * the cron tasks to be executed. - * @param \phpbb\lock\db $lock_db The lock for accessing database. - */ - public function __construct(\phpbb\user $user, \phpbb\cron\manager $cron_manager, \phpbb\lock\db $lock_db) - { - $this->cron_manager = $cron_manager; - $this->lock_db = $lock_db; - parent::__construct($user); - } - - /** - * Sets the command name and description - * - * @return null - */ - protected function configure() - { - $this - ->setName('cron:run') - ->setDescription($this->user->lang('CLI_DESCRIPTION_CRON_RUN')) - ->setHelp($this->user->lang('CLI_HELP_CRON_RUN')) - ->addArgument('name', InputArgument::OPTIONAL, $this->user->lang('CLI_DESCRIPTION_CRON_RUN_ARGUMENT_1')) - ; - } - - /** - * Executes the command cron:run. - * - * Tries to acquire the cron lock, then if no argument has been given runs all ready cron tasks. - * If the cron lock can not be obtained, an error message is printed - * and the exit status is set to 1. - * If the verbose option is specified, each start of a task is printed. - * Otherwise there is no output. - * If an argument is given to the command, only the task whose name matches the - * argument will be started. If verbose option is specified, - * an info message containing the name of the task is printed. - * If no task matches the argument given, an error message is printed - * and the exit status is set to 2. - * - * @param InputInterface $input The input stream used to get the argument and verboe option. - * @param OutputInterface $output The output stream, used for printing verbose-mode and error information. - * - * @return int 0 if all is ok, 1 if a lock error occurred and 2 if no task matching the argument was found. - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - if ($this->lock_db->acquire()) - { - $task_name = $input->getArgument('name'); - if ($task_name) - { - $exit_status = $this->run_one($input, $output, $task_name); - } - else - { - $exit_status = $this->run_all($input, $output); - } - - $this->lock_db->release(); - return $exit_status; - } - else - { - throw new runtime_exception('CRON_LOCK_ERROR', array(), null, 1); - } - } - - /** - * Executes all ready cron tasks. - * - * If verbose mode is set, an info message will be printed if there is no task to - * be run, or else for each starting task. - * - * @see execute - * @param InputInterface $input The input stream used to get the argument and verbose option. - * @param OutputInterface $output The output stream, used for printing verbose-mode and error information. - * @return int 0 - */ - protected function run_all(InputInterface $input, OutputInterface $output) - { - $run_tasks = $this->cron_manager->find_all_ready_tasks(); - - if ($run_tasks) - { - foreach ($run_tasks as $task) - { - if ($input->getOption('verbose')) - { - $output->writeln('' . $this->user->lang('RUNNING_TASK', $task->get_name()) . ''); - } - - $task->run(); - } - } - else - { - if ($input->getOption('verbose')) - { - $output->writeln('' . $this->user->lang('CRON_NO_TASK') . ''); - } - } - - return 0; - } - - /** - * Executes a given cron task, if it is ready. - * - * If there is a task whose name matches $task_name, it is run and 0 is returned. - * and if verbose mode is set, print an info message with the name of the task. - * If there is no task matching $task_name, the function prints an error message - * and returns with status 2. - * - * @see execute - * - * @param InputInterface $input The input stream used to get the argument and verbose option. - * @param OutputInterface $output The output stream, used for printing verbose-mode and error information. - * @param string $task_name The name of the task that should be run. - * - * @return int 0 if all is well, 2 if no task matches $task_name. - */ - protected function run_one(InputInterface $input, OutputInterface $output, $task_name) - { - $task = $this->cron_manager->find_task($task_name); - if ($task) - { - if ($input->getOption('verbose')) - { - $output->writeln('' . $this->user->lang('RUNNING_TASK', $task_name) . ''); - } - - $task->run(); - return 0; - } - else - { - throw new runtime_exception('CRON_NO_SUCH_TASK', array( $task_name), null, 2); - } - } -} diff --git a/install/update/new/phpbb/console/command/extension/enable.php b/install/update/new/phpbb/console/command/extension/enable.php deleted file mode 100644 index 504b554..0000000 --- a/install/update/new/phpbb/console/command/extension/enable.php +++ /dev/null @@ -1,78 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ -namespace phpbb\console\command\extension; - -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Style\SymfonyStyle; - -class enable extends command -{ - protected function configure() - { - $this - ->setName('extension:enable') - ->setDescription($this->user->lang('CLI_DESCRIPTION_ENABLE_EXTENSION')) - ->addArgument( - 'extension-name', - InputArgument::REQUIRED, - $this->user->lang('CLI_EXTENSION_NAME') - ) - ; - } - - protected function execute(InputInterface $input, OutputInterface $output) - { - $io = new SymfonyStyle($input, $output); - - $name = $input->getArgument('extension-name'); - - if (!$this->manager->is_available($name)) - { - $io->error($this->user->lang('CLI_EXTENSION_NOT_EXIST', $name)); - return 1; - } - - $extension = $this->manager->get_extension($name); - - if (($enableable = $extension->is_enableable()) !== true) - { - $message = !empty($enableable) ? $enableable : $this->user->lang('CLI_EXTENSION_NOT_ENABLEABLE', $name); - $message = is_array($message) ? implode(PHP_EOL, $message) : $message; - $io->error($message); - return 1; - } - - if ($this->manager->is_enabled($name)) - { - $io->error($this->user->lang('CLI_EXTENSION_ENABLED', $name)); - return 1; - } - - $this->manager->enable($name); - $this->manager->load_extensions(); - - if ($this->manager->is_enabled($name)) - { - $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($name)); - $io->success($this->user->lang('CLI_EXTENSION_ENABLE_SUCCESS', $name)); - return 0; - } - else - { - $io->error($this->user->lang('CLI_EXTENSION_ENABLE_FAILURE', $name)); - return 1; - } - } -} diff --git a/install/update/new/phpbb/console/command/update/check.php b/install/update/new/phpbb/console/command/update/check.php deleted file mode 100644 index 4cd7d21..0000000 --- a/install/update/new/phpbb/console/command/update/check.php +++ /dev/null @@ -1,332 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\console\command\update; - -use phpbb\config\config; -use phpbb\exception\exception_interface; -use phpbb\language\language; -use phpbb\user; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Style\SymfonyStyle; -use Symfony\Component\DependencyInjection\ContainerInterface; - -class check extends \phpbb\console\command\command -{ - /** @var \phpbb\config\config */ - protected $config; - - /** @var \Symfony\Component\DependencyInjection\ContainerBuilder */ - protected $phpbb_container; - /** - * @var language - */ - private $language; - - /** - * Construct method - */ - public function __construct(user $user, config $config, ContainerInterface $phpbb_container, language $language) - { - $this->config = $config; - $this->phpbb_container = $phpbb_container; - $this->language = $language; - - $this->language->add_lang(array('acp/common', 'acp/extensions')); - - parent::__construct($user); - } - - /** - * Configures the service. - * - * Sets the name and description of the command. - * - * @return null - */ - protected function configure() - { - $this - ->setName('update:check') - ->setDescription($this->language->lang('CLI_DESCRIPTION_UPDATE_CHECK')) - ->addArgument('ext-name', InputArgument::OPTIONAL, $this->language->lang('CLI_DESCRIPTION_UPDATE_CHECK_ARGUMENT_1')) - ->addOption('stability', null, InputOption::VALUE_REQUIRED, $this->language->lang('CLI_DESCRIPTION_UPDATE_CHECK_OPTION_STABILITY')) - ->addOption('cache', 'c', InputOption::VALUE_NONE, $this->language->lang('CLI_DESCRIPTION_UPDATE_CHECK_OPTION_CACHE')) - ; - } - - /** - * Executes the command. - * - * Checks if an update is available. - * If at least one is available, a message is printed and if verbose mode is set the list of possible updates is printed. - * If their is none, nothing is printed unless verbose mode is set. - * - * @param InputInterface $input Input stream, used to get the options. - * @param OutputInterface $output Output stream, used to print messages. - * @return int 0 if the board is up to date, 1 if it is not and 2 if an error occurred. - * @throws \RuntimeException - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - $io = new SymfonyStyle($input, $output); - - $recheck = true; - if ($input->getOption('cache')) - { - $recheck = false; - } - - $stability = null; - if ($input->getOption('stability')) - { - $stability = $input->getOption('stability'); - if (!($stability == 'stable') && !($stability == 'unstable')) - { - $io->error($this->language->lang('CLI_ERROR_INVALID_STABILITY', $stability)); - return 3; - } - } - - $ext_name = $input->getArgument('ext-name'); - if ($ext_name != null) - { - if ($ext_name == 'all') - { - return $this->check_all_ext($io, $stability, $recheck); - } - else - { - return $this->check_ext($input, $io, $stability, $recheck, $ext_name); - } - } - else - { - return $this->check_core($input, $io, $stability, $recheck); - } - } - - /** - * Check if a given extension is up to date - * - * @param InputInterface $input Input stream, used to get the options. - * @param SymfonyStyle $io IO handler, for formatted and unified IO - * @param string $stability Force a given stability - * @param bool $recheck Disallow the use of the cache - * @param string $ext_name The extension name - * @return int - */ - protected function check_ext(InputInterface $input, SymfonyStyle $io, $stability, $recheck, $ext_name) - { - try - { - $ext_manager = $this->phpbb_container->get('ext.manager'); - $md_manager = $ext_manager->create_extension_metadata_manager($ext_name); - $updates_available = $ext_manager->version_check($md_manager, $recheck, false, $stability); - - $metadata = $md_manager->get_metadata('all'); - if ($input->getOption('verbose')) - { - $io->title($md_manager->get_metadata('display-name')); - - $io->note($this->language->lang('CURRENT_VERSION') . $this->language->lang('COLON') . ' ' . $metadata['version']); - } - - if (!empty($updates_available)) - { - if ($input->getOption('verbose')) - { - $io->caution($this->language->lang('NOT_UP_TO_DATE', $metadata['name'])); - - $this->display_versions($io, $updates_available); - } - - return 1; - } - else - { - if ($input->getOption('verbose')) - { - $io->success($this->language->lang('UPDATE_NOT_NEEDED')); - } - - return 0; - } - } - catch (\RuntimeException $e) - { - $io->error($this->language->lang('EXTENSION_NOT_INSTALLED', $ext_name)); - - return 1; - } - } - - /** - * Check if the core is up to date - * - * @param InputInterface $input Input stream, used to get the options. - * @param SymfonyStyle $io IO handler, for formatted and unified IO - * @param string $stability Force a given stability - * @param bool $recheck Disallow the use of the cache - * @return int - */ - protected function check_core(InputInterface $input, SymfonyStyle $io, $stability, $recheck) - { - $version_helper = $this->phpbb_container->get('version_helper'); - $version_helper->force_stability($stability); - - $updates_available = $version_helper->get_suggested_updates($recheck); - - if ($input->getOption('verbose')) - { - $io->title('phpBB core'); - - $io->note( $this->language->lang('CURRENT_VERSION') . $this->language->lang('COLON') . ' ' . $this->config['version']); - } - - if (!empty($updates_available)) - { - $io->caution($this->language->lang('UPDATE_NEEDED')); - - if ($input->getOption('verbose')) - { - $this->display_versions($io, $updates_available); - } - - return 1; - } - else - { - if ($input->getOption('verbose')) - { - $io->success($this->language->lang('UPDATE_NOT_NEEDED')); - } - - return 0; - } - } - - /** - * Check if all the available extensions are up to date - * - * @param SymfonyStyle $io IO handler, for formatted and unified IO - * @param string $stability Stability specifier string - * @param bool $recheck Disallow the use of the cache - * @return int - */ - protected function check_all_ext(SymfonyStyle $io, $stability, $recheck) - { - /** @var \phpbb\extension\manager $ext_manager */ - $ext_manager = $this->phpbb_container->get('ext.manager'); - - $rows = []; - - foreach ($ext_manager->all_available() as $ext_name => $ext_path) - { - $row = []; - $row[] = sprintf("%s", $ext_name); - $md_manager = $ext_manager->create_extension_metadata_manager($ext_name); - try - { - $metadata = $md_manager->get_metadata('all'); - if (isset($metadata['extra']['version-check'])) - { - try { - $updates_available = $ext_manager->version_check($md_manager, $recheck, false, $stability); - if (!empty($updates_available)) - { - $versions = array_map(function($entry) - { - return $entry['current']; - }, $updates_available); - - $row[] = sprintf("%s", $metadata['version']); - $row[] = implode(', ', $versions); - } - else - { - $row[] = sprintf("%s", $metadata['version']); - $row[] = ''; - } - } catch (\RuntimeException $e) { - $row[] = $metadata['version']; - $row[] = ''; - } - } - else - { - $row[] = $metadata['version']; - $row[] = ''; - } - } - catch (exception_interface $e) - { - $exception_message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters())); - $row[] = '' . $exception_message . ''; - } - catch (\RuntimeException $e) - { - $row[] = '' . $e->getMessage() . ''; - } - - $rows[] = $row; - } - - $io->table([ - $this->language->lang('EXTENSION_NAME'), - $this->language->lang('CURRENT_VERSION'), - $this->language->lang('LATEST_VERSION'), - ], $rows); - - return 0; - } - - /** - * Display the details of the available updates - * - * @param SymfonyStyle $io IO handler, for formatted and unified IO - * @param array $updates_available The list of the available updates - */ - protected function display_versions(SymfonyStyle $io, $updates_available) - { - $io->section($this->language->lang('UPDATES_AVAILABLE')); - - $rows = []; - foreach ($updates_available as $version_data) - { - $row = ['', '', '']; - $row[0] = $version_data['current']; - - if (isset($version_data['announcement'])) - { - $row[1] = $version_data['announcement']; - } - - if (isset($version_data['download'])) - { - $row[2] = $version_data['download']; - } - - $rows[] = $row; - } - - $io->table([ - $this->language->lang('VERSION'), - $this->language->lang('ANNOUNCEMENT_TOPIC'), - $this->language->lang('DOWNLOAD_LATEST'), - ], $rows); - } -} diff --git a/install/update/new/phpbb/console/command/user/add.php b/install/update/new/phpbb/console/command/user/add.php deleted file mode 100644 index 303216a..0000000 --- a/install/update/new/phpbb/console/command/user/add.php +++ /dev/null @@ -1,334 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\console\command\user; - -use phpbb\config\config; -use phpbb\console\command\command; -use phpbb\db\driver\driver_interface; -use phpbb\exception\runtime_exception; -use phpbb\language\language; -use phpbb\passwords\manager; -use phpbb\user; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Question\Question; -use Symfony\Component\Console\Style\SymfonyStyle; - -class add extends command -{ - /** @var array Array of interactively acquired options */ - protected $data; - - /** @var driver_interface */ - protected $db; - - /** @var config */ - protected $config; - - /** @var language */ - protected $language; - - /** @var manager */ - protected $password_manager; - - /** - * phpBB root path - * - * @var string - */ - protected $phpbb_root_path; - - /** - * PHP extension. - * - * @var string - */ - protected $php_ext; - - /** - * Construct method - * - * @param user $user - * @param driver_interface $db - * @param config $config - * @param language $language - * @param manager $password_manager - * @param string $phpbb_root_path - * @param string $php_ext - */ - public function __construct(user $user, driver_interface $db, config $config, language $language, manager $password_manager, $phpbb_root_path, $php_ext) - { - $this->db = $db; - $this->config = $config; - $this->language = $language; - $this->password_manager = $password_manager; - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - - $this->language->add_lang('ucp'); - parent::__construct($user); - } - - /** - * Sets the command name and description - * - * @return null - */ - protected function configure() - { - $this - ->setName('user:add') - ->setDescription($this->language->lang('CLI_DESCRIPTION_USER_ADD')) - ->setHelp($this->language->lang('CLI_HELP_USER_ADD')) - ->addOption( - 'username', - 'U', - InputOption::VALUE_REQUIRED, - $this->language->lang('CLI_DESCRIPTION_USER_ADD_OPTION_USERNAME') - ) - ->addOption( - 'password', - 'P', - InputOption::VALUE_REQUIRED, - $this->language->lang('CLI_DESCRIPTION_USER_ADD_OPTION_PASSWORD') - ) - ->addOption( - 'email', - 'E', - InputOption::VALUE_REQUIRED, - $this->language->lang('CLI_DESCRIPTION_USER_ADD_OPTION_EMAIL') - ) - ->addOption( - 'send-email', - null, - InputOption::VALUE_NONE, - $this->language->lang('CLI_DESCRIPTION_USER_ADD_OPTION_NOTIFY') - ) - ; - } - - /** - * Executes the command user:add - * - * Adds a new user to the database. If options are not provided, it will ask for the username, password and email. - * User is added to the registered user group. Language and timezone default to $config settings. - * - * @param InputInterface $input The input stream used to get the options - * @param OutputInterface $output The output stream, used to print messages - * - * @return int 0 if all is well, 1 if any errors occurred - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - $io = new SymfonyStyle($input, $output); - - try - { - $this->validate_user_data(); - $group_id = $this->get_group_id(); - } - catch (runtime_exception $e) - { - $io->error($e->getMessage()); - return 1; - } - - $user_row = array( - 'username' => $this->data['username'], - 'user_password' => $this->password_manager->hash($this->data['new_password']), - 'user_email' => $this->data['email'], - 'group_id' => $group_id, - 'user_timezone' => $this->config['board_timezone'], - 'user_lang' => $this->config['default_lang'], - 'user_type' => USER_NORMAL, - 'user_regdate' => time(), - ); - - $user_id = (int) user_add($user_row); - - if (!$user_id) - { - $io->error($this->language->lang('AUTH_NO_PROFILE_CREATED')); - return 1; - } - - if ($input->getOption('send-email') && $this->config['email_enable']) - { - $this->send_activation_email($user_id); - } - - $io->success($this->language->lang('CLI_USER_ADD_SUCCESS', $this->data['username'])); - - return 0; - } - - /** - * Interacts with the user. - * - * @param InputInterface $input An InputInterface instance - * @param OutputInterface $output An OutputInterface instance - */ - protected function interact(InputInterface $input, OutputInterface $output) - { - $helper = $this->getHelper('question'); - - $this->data = array( - 'username' => $input->getOption('username'), - 'new_password' => $input->getOption('password'), - 'email' => $input->getOption('email'), - ); - - if (!$this->data['username']) - { - $question = new Question($this->ask_user('USERNAME')); - $this->data['username'] = $helper->ask($input, $output, $question); - } - - if (!$this->data['new_password']) - { - $question = new Question($this->ask_user('PASSWORD')); - $question->setValidator(function ($value) use ($helper, $input, $output) { - $question = new Question($this->ask_user('CONFIRM_PASSWORD')); - $question->setHidden(true); - if ($helper->ask($input, $output, $question) != $value) - { - throw new runtime_exception($this->language->lang('NEW_PASSWORD_ERROR')); - } - return $value; - }); - $question->setHidden(true); - $question->setMaxAttempts(5); - - $this->data['new_password'] = $helper->ask($input, $output, $question); - } - - if (!$this->data['email']) - { - $question = new Question($this->ask_user('EMAIL_ADDRESS')); - $this->data['email'] = $helper->ask($input, $output, $question); - } - } - - /** - * Validate the submitted user data - * - * @throws runtime_exception if any data fails validation - * @return null - */ - protected function validate_user_data() - { - if (!function_exists('validate_data')) - { - require($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext); - } - - $error = validate_data($this->data, array( - 'username' => array( - array('string', false, $this->config['min_name_chars'], $this->config['max_name_chars']), - array('username', '')), - 'new_password' => array( - array('string', false, $this->config['min_pass_chars'], 0), - array('password')), - 'email' => array( - array('string', false, 6, 60), - array('user_email')), - )); - - if ($error) - { - throw new runtime_exception(implode("\n", array_map(array($this->language, 'lang'), $error))); - } - } - - /** - * Get the group id - * - * Go and find in the database the group_id corresponding to 'REGISTERED' - * - * @throws runtime_exception if the group id does not exist in database. - * @return null - */ - protected function get_group_id() - { - $sql = 'SELECT group_id - FROM ' . GROUPS_TABLE . " - WHERE group_name = '" . $this->db->sql_escape('REGISTERED') . "' - AND group_type = " . GROUP_SPECIAL; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if (!$row || !$row['group_id']) - { - throw new runtime_exception($this->language->lang('NO_GROUP')); - } - - return $row['group_id']; - } - - /** - * Send account activation email - * - * @param int $user_id The new user's id - * @return null - */ - protected function send_activation_email($user_id) - { - switch ($this->config['require_activation']) - { - case USER_ACTIVATION_SELF: - $email_template = 'user_welcome_inactive'; - $user_actkey = gen_rand_string(mt_rand(6, 10)); - break; - case USER_ACTIVATION_ADMIN: - $email_template = 'admin_welcome_inactive'; - $user_actkey = gen_rand_string(mt_rand(6, 10)); - break; - default: - $email_template = 'user_welcome'; - $user_actkey = ''; - break; - } - - if (!class_exists('messenger')) - { - require($this->phpbb_root_path . 'includes/functions_messenger.' . $this->php_ext); - } - - $messenger = new \messenger(false); - $messenger->template($email_template, $this->user->lang_name); - $messenger->to($this->data['email'], $this->data['username']); - $messenger->anti_abuse_headers($this->config, $this->user); - $messenger->assign_vars(array( - 'WELCOME_MSG' => htmlspecialchars_decode($this->language->lang('WELCOME_SUBJECT', $this->config['sitename'])), - 'USERNAME' => htmlspecialchars_decode($this->data['username']), - 'PASSWORD' => htmlspecialchars_decode($this->data['new_password']), - 'U_ACTIVATE' => generate_board_url() . "/ucp.{$this->php_ext}?mode=activate&u=$user_id&k=$user_actkey") - ); - - $messenger->send(NOTIFY_EMAIL); - } - - /** - * Helper to translate questions to the user - * - * @param string $key The language key - * @return string The language key translated with a colon and space appended - */ - protected function ask_user($key) - { - return $this->language->lang($key) . $this->language->lang('COLON') . ' '; - } -} diff --git a/install/update/new/phpbb/content_visibility.php b/install/update/new/phpbb/content_visibility.php deleted file mode 100644 index fbc56f3..0000000 --- a/install/update/new/phpbb/content_visibility.php +++ /dev/null @@ -1,899 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb; - -/** -* phpbb_visibility -* Handle fetching and setting the visibility for topics and posts -*/ -class content_visibility -{ - /** - * Database object - * @var \phpbb\db\driver\driver_interface - */ - protected $db; - - /** - * User object - * @var \phpbb\user - */ - protected $user; - - /** - * Auth object - * @var \phpbb\auth\auth - */ - protected $auth; - - /** - * config object - * @var \phpbb\config\config - */ - protected $config; - - /** - * Event dispatcher object - * @var \phpbb\event\dispatcher_interface - */ - protected $phpbb_dispatcher; - - /** - * phpBB root path - * @var string - */ - protected $phpbb_root_path; - - /** - * PHP Extension - * @var string - */ - protected $php_ext; - - /** - * Constructor - * - * @param \phpbb\auth\auth $auth Auth object - * @param \phpbb\config\config $config Config object - * @param \phpbb\event\dispatcher_interface $phpbb_dispatcher Event dispatcher object - * @param \phpbb\db\driver\driver_interface $db Database object - * @param \phpbb\user $user User object - * @param string $phpbb_root_path Root path - * @param string $php_ext PHP Extension - * @param string $forums_table Forums table name - * @param string $posts_table Posts table name - * @param string $topics_table Topics table name - * @param string $users_table Users table name - */ - public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\event\dispatcher_interface $phpbb_dispatcher, \phpbb\db\driver\driver_interface $db, \phpbb\user $user, $phpbb_root_path, $php_ext, $forums_table, $posts_table, $topics_table, $users_table) - { - $this->auth = $auth; - $this->config = $config; - $this->phpbb_dispatcher = $phpbb_dispatcher; - $this->db = $db; - $this->user = $user; - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - $this->forums_table = $forums_table; - $this->posts_table = $posts_table; - $this->topics_table = $topics_table; - $this->users_table = $users_table; - } - - /** - * Can the current logged-in user soft-delete posts? - * - * @param $forum_id int Forum ID whose permissions to check - * @param $poster_id int Poster ID of the post in question - * @param $post_locked bool Is the post locked? - * @return bool - */ - public function can_soft_delete($forum_id, $poster_id, $post_locked) - { - if ($this->auth->acl_get('m_softdelete', $forum_id)) - { - return true; - } - else if ($this->auth->acl_get('f_softdelete', $forum_id) && $poster_id == $this->user->data['user_id'] && !$post_locked) - { - return true; - } - - return false; - } - - /** - * Get the topics post count or the forums post/topic count based on permissions - * - * @param $mode string One of topic_posts, forum_posts or forum_topics - * @param $data array Array with the topic/forum data to calculate from - * @param $forum_id int The forum id is used for permission checks - * @return int Number of posts/topics the user can see in the topic/forum - */ - public function get_count($mode, $data, $forum_id) - { - if (!$this->auth->acl_get('m_approve', $forum_id)) - { - return (int) $data[$mode . '_approved']; - } - - return (int) $data[$mode . '_approved'] + (int) $data[$mode . '_unapproved'] + (int) $data[$mode . '_softdeleted']; - } - - - /** - * Check topic/post visibility for a given forum ID - * - * Note: Read permissions are not checked. - * - * @param $mode string Either "topic" or "post" - * @param $forum_id int The forum id is used for permission checks - * @param $data array Array with item information to check visibility - * @return bool True if the item is visible, false if not - */ - public function is_visible($mode, $forum_id, $data) - { - $visibility = $data[$mode . '_visibility']; - $poster_key = ($mode === 'topic') ? 'topic_poster' : 'poster_id'; - $is_visible = ($visibility == ITEM_APPROVED) || - ($this->config['display_unapproved_posts'] && - ($this->user->data['user_id'] != ANONYMOUS) && - ($visibility == ITEM_UNAPPROVED || $visibility == ITEM_REAPPROVE) && - ($this->user->data['user_id'] == $data[$poster_key])) || - $this->auth->acl_get('m_approve', $forum_id); - - /** - * Allow changing the result of calling is_visible - * - * @event core.phpbb_content_visibility_is_visible - * @var bool is_visible Default visibility condition, to be modified by extensions if needed. - * @var string mode Either "topic" or "post" - * @var int forum_id Forum id of the current item - * @var array data Array of item information - * @since 3.2.2-RC1 - */ - $vars = array( - 'is_visible', - 'mode', - 'forum_id', - 'data', - ); - extract($this->phpbb_dispatcher->trigger_event('core.phpbb_content_visibility_is_visible', compact($vars))); - - return $is_visible; - } - - /** - * Create topic/post visibility SQL for a given forum ID - * - * Note: Read permissions are not checked. - * - * @param $mode string Either "topic" or "post" - * @param $forum_id int The forum id is used for permission checks - * @param $table_alias string Table alias to prefix in SQL queries - * @return string The appropriate combination SQL logic for topic/post_visibility - */ - public function get_visibility_sql($mode, $forum_id, $table_alias = '') - { - $where_sql = ''; - - $get_visibility_sql_overwrite = false; - - /** - * Allow changing the result of calling get_visibility_sql - * - * @event core.phpbb_content_visibility_get_visibility_sql_before - * @var string where_sql Extra visibility conditions. It must end with either an SQL "AND" or an "OR" - * @var string mode Either "topic" or "post" depending on the query this is being used in - * @var array forum_id The forum id in which the search is made. - * @var string table_alias Table alias to prefix in SQL queries - * @var mixed get_visibility_sql_overwrite If a string, forces the function to return get_forums_visibility_sql_overwrite after executing the event - * If false, get_visibility_sql continues normally - * It must be either boolean or string - * @since 3.1.4-RC1 - */ - $vars = array( - 'where_sql', - 'mode', - 'forum_id', - 'table_alias', - 'get_visibility_sql_overwrite', - ); - extract($this->phpbb_dispatcher->trigger_event('core.phpbb_content_visibility_get_visibility_sql_before', compact($vars))); - - if ($get_visibility_sql_overwrite !== false) - { - return $get_visibility_sql_overwrite; - } - - if ($this->auth->acl_get('m_approve', $forum_id)) - { - $where_sql .= '1 = 1'; - } - else - { - $visibility_query = $table_alias . $mode . '_visibility = '; - - $where_sql .= '(' . $visibility_query . ITEM_APPROVED . ')'; - if ($this->config['display_unapproved_posts'] && ($this->user->data['user_id'] != ANONYMOUS)) - { - $poster_key = ($mode === 'topic') ? 'topic_poster' : 'poster_id'; - $where_sql .= ' OR ((' . $visibility_query . ITEM_UNAPPROVED . ' OR ' . $visibility_query . ITEM_REAPPROVE .')'; - $where_sql .= ' AND ' . $table_alias . $poster_key . ' = ' . ((int) $this->user->data['user_id']) . ')'; - } - } - return '(' . $where_sql . ')'; - } - - /** - * Create topic/post visibility SQL for a set of forums - * - * Note: Read permissions are not checked. Forums without read permissions - * should not be in $forum_ids - * - * @param $mode string Either "topic" or "post" - * @param $forum_ids array Array of forum ids which the posts/topics are limited to - * @param $table_alias string Table alias to prefix in SQL queries - * @return string The appropriate combination SQL logic for topic/post_visibility - */ - public function get_forums_visibility_sql($mode, $forum_ids = array(), $table_alias = '') - { - $where_sql = ''; - - $approve_forums = array_keys($this->auth->acl_getf('m_approve', true)); - if (!empty($forum_ids) && !empty($approve_forums)) - { - $approve_forums = array_intersect($forum_ids, $approve_forums); - $forum_ids = array_diff($forum_ids, $approve_forums); - } - - $get_forums_visibility_sql_overwrite = false; - /** - * Allow changing the result of calling get_forums_visibility_sql - * - * @event core.phpbb_content_visibility_get_forums_visibility_before - * @var string where_sql Extra visibility conditions. It must end with either an SQL "AND" or an "OR" - * @var string mode Either "topic" or "post" depending on the query this is being used in - * @var array forum_ids Array of forum ids which the posts/topics are limited to - * @var string table_alias Table alias to prefix in SQL queries - * @var array approve_forums Array of forums where the user has m_approve permissions - * @var mixed get_forums_visibility_sql_overwrite If a string, forces the function to return get_forums_visibility_sql_overwrite after executing the event - * If false, get_forums_visibility_sql continues normally - * It must be either boolean or string - * @since 3.1.3-RC1 - */ - $vars = array( - 'where_sql', - 'mode', - 'forum_ids', - 'table_alias', - 'approve_forums', - 'get_forums_visibility_sql_overwrite', - ); - extract($this->phpbb_dispatcher->trigger_event('core.phpbb_content_visibility_get_forums_visibility_before', compact($vars))); - - if ($get_forums_visibility_sql_overwrite !== false) - { - return $get_forums_visibility_sql_overwrite; - } - - // Moderator can view all posts/topics in the moderated forums - $where_sql .= '(' . $this->db->sql_in_set($table_alias . 'forum_id', $approve_forums, false, true) . ' OR '; - // Normal user can view approved items only - $where_sql .= '(' . $table_alias . $mode . '_visibility = ' . ITEM_APPROVED . ' - AND ' . $this->db->sql_in_set($table_alias . 'forum_id', $forum_ids, false, true) . '))'; - - return '(' . $where_sql . ')'; - } - - /** - * Create topic/post visibility SQL for all forums on the board - * - * Note: Read permissions are not checked. Forums without read permissions - * should be in $exclude_forum_ids - * - * @param $mode string Either "topic" or "post" - * @param $exclude_forum_ids array Array of forum ids which are excluded - * @param $table_alias string Table alias to prefix in SQL queries - * @return string The appropriate combination SQL logic for topic/post_visibility - */ - public function get_global_visibility_sql($mode, $exclude_forum_ids = array(), $table_alias = '') - { - $where_sqls = array(); - - $approve_forums = array_diff(array_keys($this->auth->acl_getf('m_approve', true)), $exclude_forum_ids); - - $visibility_sql_overwrite = null; - - /** - * Allow changing the result of calling get_global_visibility_sql - * - * @event core.phpbb_content_visibility_get_global_visibility_before - * @var array where_sqls Array of extra visibility conditions. Will be joined by imploding with "OR". - * @var string mode Either "topic" or "post" depending on the query this is being used in - * @var array exclude_forum_ids Array of forum ids the current user doesn't have access to - * @var string table_alias Table alias to prefix in SQL queries - * @var array approve_forums Array of forums where the user has m_approve permissions - * @var string visibility_sql_overwrite If not empty, forces the function to return visibility_sql_overwrite after executing the event - * @since 3.1.3-RC1 - */ - $vars = array( - 'where_sqls', - 'mode', - 'exclude_forum_ids', - 'table_alias', - 'approve_forums', - 'visibility_sql_overwrite', - ); - extract($this->phpbb_dispatcher->trigger_event('core.phpbb_content_visibility_get_global_visibility_before', compact($vars))); - - if ($visibility_sql_overwrite) - { - return $visibility_sql_overwrite; - } - - // Include approved items in all forums but the excluded - $where_sqls[] = '(' . $this->db->sql_in_set($table_alias . 'forum_id', $exclude_forum_ids, true, true) . ' - AND ' . $table_alias . $mode . '_visibility = ' . ITEM_APPROVED . ')'; - - // If user has moderator permissions, add everything in the moderated forums - if (count($approve_forums)) - { - $where_sqls[] = $this->db->sql_in_set($table_alias . 'forum_id', $approve_forums); - } - - return '(' . implode(' OR ', $where_sqls) . ')'; - } - - /** - * Change visibility status of one post or all posts of a topic - * - * @param $visibility int Element of {ITEM_APPROVED, ITEM_DELETED, ITEM_REAPPROVE} - * @param $post_id mixed Post ID or array of post IDs to act on, - * if it is empty, all posts of topic_id will be modified - * @param $topic_id int Topic where $post_id is found - * @param $forum_id int Forum where $topic_id is found - * @param $user_id int User performing the action - * @param $time int Timestamp when the action is performed - * @param $reason string Reason why the visibility was changed. - * @param $is_starter bool Is this the first post of the topic changed? - * @param $is_latest bool Is this the last post of the topic changed? - * @param $limit_visibility mixed Limit updating per topic_id to a certain visibility - * @param $limit_delete_time mixed Limit updating per topic_id to a certain deletion time - * @return array Changed post data, empty array if an error occurred. - */ - public function set_post_visibility($visibility, $post_id, $topic_id, $forum_id, $user_id, $time, $reason, $is_starter, $is_latest, $limit_visibility = false, $limit_delete_time = false) - { - if (!in_array($visibility, array(ITEM_APPROVED, ITEM_DELETED, ITEM_REAPPROVE))) - { - return array(); - } - - if ($post_id) - { - if (is_array($post_id)) - { - $where_sql = $this->db->sql_in_set('post_id', array_map('intval', $post_id)); - } - else - { - $where_sql = 'post_id = ' . (int) $post_id; - } - $where_sql .= ' AND topic_id = ' . (int) $topic_id; - } - else - { - $where_sql = 'topic_id = ' . (int) $topic_id; - - // Limit the posts to a certain visibility and deletion time - // This allows us to only restore posts, that were approved - // when the topic got soft deleted. So previous soft deleted - // and unapproved posts are still soft deleted/unapproved - if ($limit_visibility !== false) - { - $where_sql .= ' AND post_visibility = ' . (int) $limit_visibility; - } - - if ($limit_delete_time !== false) - { - $where_sql .= ' AND post_delete_time = ' . (int) $limit_delete_time; - } - } - - $sql = 'SELECT poster_id, post_id, post_postcount, post_visibility - FROM ' . $this->posts_table . ' - WHERE ' . $where_sql; - $result = $this->db->sql_query($sql); - - $post_ids = $poster_postcounts = $postcounts = $postcount_visibility = array(); - while ($row = $this->db->sql_fetchrow($result)) - { - $post_ids[] = (int) $row['post_id']; - - if ($row['post_visibility'] != $visibility) - { - if ($row['post_postcount'] && !isset($poster_postcounts[(int) $row['poster_id']])) - { - $poster_postcounts[(int) $row['poster_id']] = 1; - } - else if ($row['post_postcount']) - { - $poster_postcounts[(int) $row['poster_id']]++; - } - - if (!isset($postcount_visibility[$row['post_visibility']])) - { - $postcount_visibility[$row['post_visibility']] = 1; - } - else - { - $postcount_visibility[$row['post_visibility']]++; - } - } - } - $this->db->sql_freeresult($result); - - if (empty($post_ids)) - { - return array(); - } - - if (!function_exists('truncate_string')) - { - include($this->phpbb_root_path . 'includes/functions_content.' . $this->php_ext); - } - - $data = array( - 'post_visibility' => (int) $visibility, - 'post_delete_user' => (int) $user_id, - 'post_delete_time' => ((int) $time) ?: time(), - 'post_delete_reason' => truncate_string($reason, 255, 255, false), - ); - /** - * Perform actions right before the query to change post visibility - * - * @event core.set_post_visibility_before_sql - * @var int visibility Element of {ITEM_APPROVED, ITEM_DELETED, ITEM_REAPPROVE} - * @var array post_id Array containing all post IDs to be modified. If blank, all posts within the topic are modified. - * @var int topic_id Topic of the post IDs to be modified. - * @var int forum_id Forum ID that the topic_id resides in. - * @var int user_id User ID doing this action. - * @var int time Timestamp of this action. - * @var string reason Reason specified by the user for this change. - * @var bool is_starter Are we changing the topic's starter? - * @var bool is_latest Are we changing the topic's latest post? - * @var array data The data array for this action. - * @since 3.1.10-RC1 - * @changed 3.2.2-RC1 Use time instead of non-existent timestamp - */ - $vars = array( - 'visibility', - 'post_id', - 'topic_id', - 'forum_id', - 'user_id', - 'time', - 'reason', - 'is_starter', - 'is_latest', - 'data', - ); - extract($this->phpbb_dispatcher->trigger_event('core.set_post_visibility_before_sql', compact($vars))); - $sql = 'UPDATE ' . $this->posts_table . ' - SET ' . $this->db->sql_build_array('UPDATE', $data) . ' - WHERE ' . $this->db->sql_in_set('post_id', $post_ids); - $this->db->sql_query($sql); - - // Group the authors by post count, to reduce the number of queries - foreach ($poster_postcounts as $poster_id => $num_posts) - { - $postcounts[$num_posts][] = $poster_id; - } - - // Update users postcounts - foreach ($postcounts as $num_posts => $poster_ids) - { - if (in_array($visibility, array(ITEM_REAPPROVE, ITEM_DELETED))) - { - $sql = 'UPDATE ' . $this->users_table . ' - SET user_posts = 0 - WHERE ' . $this->db->sql_in_set('user_id', $poster_ids) . ' - AND user_posts < ' . $num_posts; - $this->db->sql_query($sql); - - $sql = 'UPDATE ' . $this->users_table . ' - SET user_posts = user_posts - ' . $num_posts . ' - WHERE ' . $this->db->sql_in_set('user_id', $poster_ids) . ' - AND user_posts >= ' . $num_posts; - $this->db->sql_query($sql); - } - else - { - $sql = 'UPDATE ' . $this->users_table . ' - SET user_posts = user_posts + ' . $num_posts . ' - WHERE ' . $this->db->sql_in_set('user_id', $poster_ids); - $this->db->sql_query($sql); - } - } - - $update_topic_postcount = true; - - // Sync the first/last topic information if needed - if (!$is_starter && $is_latest) - { - if (!function_exists('update_post_information')) - { - include($this->phpbb_root_path . 'includes/functions_posting.' . $this->php_ext); - } - - // update_post_information can only update the last post info ... - if ($topic_id) - { - update_post_information('topic', $topic_id, false); - } - if ($forum_id) - { - update_post_information('forum', $forum_id, false); - } - } - else if ($is_starter && $topic_id) - { - if (!function_exists('sync')) - { - include($this->phpbb_root_path . 'includes/functions_admin.' . $this->php_ext); - } - - // ... so we need to use sync, if the first post is changed. - // The forum is resynced recursive by sync() itself. - sync('topic', 'topic_id', $topic_id, true); - - // sync recalculates the topic replies and forum posts by itself, so we don't do that. - $update_topic_postcount = false; - } - - $topic_update_array = array(); - // Update the topic's reply count and the forum's post count - if ($update_topic_postcount) - { - $field_alias = array( - ITEM_APPROVED => 'posts_approved', - ITEM_UNAPPROVED => 'posts_unapproved', - ITEM_DELETED => 'posts_softdeleted', - ITEM_REAPPROVE => 'posts_unapproved', - ); - $cur_posts = array_fill_keys($field_alias, 0); - - foreach ($postcount_visibility as $post_visibility => $visibility_posts) - { - $cur_posts[$field_alias[(int) $post_visibility]] += $visibility_posts; - } - - $sql_ary = array(); - $recipient_field = $field_alias[$visibility]; - - foreach ($cur_posts as $field => $count) - { - // Decrease the count for the old statuses. - if ($count && $field != $recipient_field) - { - $sql_ary[$field] = " - $count"; - } - } - // Add up the count from all statuses excluding the recipient status. - $count_increase = array_sum(array_diff($cur_posts, array($recipient_field))); - - if ($count_increase) - { - $sql_ary[$recipient_field] = " + $count_increase"; - } - - if (count($sql_ary)) - { - $forum_sql = array(); - - foreach ($sql_ary as $field => $value_change) - { - $topic_update_array[] = 'topic_' . $field . ' = topic_' . $field . $value_change; - $forum_sql[] = 'forum_' . $field . ' = forum_' . $field . $value_change; - } - - $sql = 'UPDATE ' . $this->forums_table . ' - SET ' . implode(', ', $forum_sql) . ' - WHERE forum_id = ' . (int) $forum_id; - $this->db->sql_query($sql); - } - } - - if ($post_id) - { - $sql = 'SELECT 1 AS has_attachments - FROM ' . POSTS_TABLE . ' - WHERE topic_id = ' . (int) $topic_id . ' - AND post_attachment = 1 - AND post_visibility = ' . ITEM_APPROVED . ' - AND ' . $this->db->sql_in_set('post_id', $post_id, true); - $result = $this->db->sql_query_limit($sql, 1); - - $has_attachment = (bool) $this->db->sql_fetchfield('has_attachments'); - $this->db->sql_freeresult($result); - - if ($has_attachment && $visibility == ITEM_APPROVED) - { - $topic_update_array[] = 'topic_attachment = 1'; - } - else if (!$has_attachment && $visibility != ITEM_APPROVED) - { - $topic_update_array[] = 'topic_attachment = 0'; - } - } - - if (!empty($topic_update_array)) - { - // Update the number for replies and posts, and update the attachments flag - $sql = 'UPDATE ' . $this->topics_table . ' - SET ' . implode(', ', $topic_update_array) . ' - WHERE topic_id = ' . (int) $topic_id; - $this->db->sql_query($sql); - } - /** - * Perform actions after all steps to changing post visibility - * - * @event core.set_post_visibility_after - * @var int visibility Element of {ITEM_APPROVED, ITEM_DELETED, ITEM_REAPPROVE} - * @var array post_id Array containing all post IDs to be modified. If blank, all posts within the topic are modified. - * @var int topic_id Topic of the post IDs to be modified. - * @var int forum_id Forum ID that the topic_id resides in. - * @var int user_id User ID doing this action. - * @var int time Timestamp of this action. - * @var string reason Reason specified by the user for this change. - * @var bool is_starter Are we changing the topic's starter? - * @var bool is_latest Are we changing the topic's latest post? - * @var array data The data array for this action. - * @since 3.1.10-RC1 - * @changed 3.2.2-RC1 Use time instead of non-existent timestamp - */ - $vars = array( - 'visibility', - 'post_id', - 'topic_id', - 'forum_id', - 'user_id', - 'time', - 'reason', - 'is_starter', - 'is_latest', - 'data', - ); - extract($this->phpbb_dispatcher->trigger_event('core.set_post_visibility_after', compact($vars))); - return $data; - } - - /** - * Set topic visibility - * - * Allows approving (which is akin to undeleting/restore) or soft deleting an entire topic. - * Calls set_post_visibility as needed. - * - * Note: By default, when a soft deleted topic is restored. Only posts that - * were approved at the time of soft deleting, are being restored. - * Same applies to soft deleting. Only approved posts will be marked - * as soft deleted. - * If you want to update all posts, use the force option. - * - * @param $visibility int Element of {ITEM_APPROVED, ITEM_DELETED, ITEM_REAPPROVE} - * @param $topic_id mixed Topic ID to act on - * @param $forum_id int Forum where $topic_id is found - * @param $user_id int User performing the action - * @param $time int Timestamp when the action is performed - * @param $reason string Reason why the visibilty was changed. - * @param $force_update_all bool Force to update all posts within the topic - * @return array Changed topic data, empty array if an error occurred. - */ - public function set_topic_visibility($visibility, $topic_id, $forum_id, $user_id, $time, $reason, $force_update_all = false) - { - if (!in_array($visibility, array(ITEM_APPROVED, ITEM_DELETED, ITEM_REAPPROVE))) - { - return array(); - } - - if (!$force_update_all) - { - $sql = 'SELECT topic_visibility, topic_delete_time - FROM ' . $this->topics_table . ' - WHERE topic_id = ' . (int) $topic_id; - $result = $this->db->sql_query($sql); - $original_topic_data = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if (!$original_topic_data) - { - // The topic does not exist... - return array(); - } - } - - if (!function_exists('truncate_string')) - { - include($this->phpbb_root_path . 'includes/functions_content.' . $this->php_ext); - } - - // Note, we do not set a reason for the posts, just for the topic - $data = array( - 'topic_visibility' => (int) $visibility, - 'topic_delete_user' => (int) $user_id, - 'topic_delete_time' => ((int) $time) ?: time(), - 'topic_delete_reason' => truncate_string($reason, 255, 255, false), - ); - /** - * Perform actions right before the query to change topic visibility - * - * @event core.set_topic_visibility_before_sql - * @var int visibility Element of {ITEM_APPROVED, ITEM_DELETED, ITEM_REAPPROVE} - * @var int topic_id Topic of the post IDs to be modified. - * @var int forum_id Forum ID that the topic_id resides in. - * @var int user_id User ID doing this action. - * @var int time Timestamp of this action. - * @var string reason Reason specified by the user for this change. - * @var bool force_update_all Force an update on all posts within the topic, regardless of their current approval state. - * @var array data The data array for this action. - * @since 3.1.10-RC1 - * @changed 3.2.2-RC1 Use time instead of non-existent timestamp - */ - $vars = array( - 'visibility', - 'topic_id', - 'forum_id', - 'user_id', - 'time', - 'reason', - 'force_update_all', - 'data', - ); - extract($this->phpbb_dispatcher->trigger_event('core.set_topic_visibility_before_sql', compact($vars))); - $sql = 'UPDATE ' . $this->topics_table . ' - SET ' . $this->db->sql_build_array('UPDATE', $data) . ' - WHERE topic_id = ' . (int) $topic_id; - $this->db->sql_query($sql); - - if (!$this->db->sql_affectedrows()) - { - return array(); - } - - if (!$force_update_all && $original_topic_data['topic_delete_time'] && $original_topic_data['topic_visibility'] == ITEM_DELETED && $visibility == ITEM_APPROVED) - { - // If we're restoring a topic we only restore posts, that were soft deleted through the topic soft deletion. - $this->set_post_visibility($visibility, false, $topic_id, $forum_id, $user_id, $time, '', true, true, $original_topic_data['topic_visibility'], $original_topic_data['topic_delete_time']); - } - else if (!$force_update_all && $original_topic_data['topic_visibility'] == ITEM_APPROVED && $visibility == ITEM_DELETED) - { - // If we're soft deleting a topic we only mark approved posts as soft deleted. - $this->set_post_visibility($visibility, false, $topic_id, $forum_id, $user_id, $time, '', true, true, $original_topic_data['topic_visibility']); - } - else - { - $this->set_post_visibility($visibility, false, $topic_id, $forum_id, $user_id, $time, '', true, true); - } - /** - * Perform actions after all steps to changing topic visibility - * - * @event core.set_topic_visibility_after - * @var int visibility Element of {ITEM_APPROVED, ITEM_DELETED, ITEM_REAPPROVE} - * @var int topic_id Topic of the post IDs to be modified. - * @var int forum_id Forum ID that the topic_id resides in. - * @var int user_id User ID doing this action. - * @var int time Timestamp of this action. - * @var string reason Reason specified by the user for this change. - * @var bool force_update_all Force an update on all posts within the topic, regardless of their current approval state. - * @var array data The data array for this action. - * @since 3.1.10-RC1 - * @changed 3.2.2-RC1 Use time instead of non-existent timestamp - */ - $vars = array( - 'visibility', - 'topic_id', - 'forum_id', - 'user_id', - 'time', - 'reason', - 'force_update_all', - 'data', - ); - extract($this->phpbb_dispatcher->trigger_event('core.set_topic_visibility_after', compact($vars))); - return $data; - } - - /** - * Add post to topic and forum statistics - * - * @param $data array Contains information from the topics table about given topic - * @param &$sql_data array Populated with the SQL changes, may be empty at call time - * @return null - */ - public function add_post_to_statistic($data, &$sql_data) - { - $sql_data[$this->topics_table] = (($sql_data[$this->topics_table]) ? $sql_data[$this->topics_table] . ', ' : '') . 'topic_posts_approved = topic_posts_approved + 1'; - - $sql_data[$this->forums_table] = (($sql_data[$this->forums_table]) ? $sql_data[$this->forums_table] . ', ' : '') . 'forum_posts_approved = forum_posts_approved + 1'; - - if ($data['post_postcount']) - { - $sql_data[$this->users_table] = (($sql_data[$this->users_table]) ? $sql_data[$this->users_table] . ', ' : '') . 'user_posts = user_posts + 1'; - } - - $this->config->increment('num_posts', 1, false); - } - - /** - * Remove post from topic and forum statistics - * - * @param $data array Contains information from the topics table about given topic - * @param &$sql_data array Populated with the SQL changes, may be empty at call time - * @return null - */ - public function remove_post_from_statistic($data, &$sql_data) - { - if ($data['post_visibility'] == ITEM_APPROVED) - { - $sql_data[$this->topics_table] = ((!empty($sql_data[$this->topics_table])) ? $sql_data[$this->topics_table] . ', ' : '') . 'topic_posts_approved = topic_posts_approved - 1'; - $sql_data[$this->forums_table] = ((!empty($sql_data[$this->forums_table])) ? $sql_data[$this->forums_table] . ', ' : '') . 'forum_posts_approved = forum_posts_approved - 1'; - - if ($data['post_postcount']) - { - $sql_data[$this->users_table] = ((!empty($sql_data[$this->users_table])) ? $sql_data[$this->users_table] . ', ' : '') . 'user_posts = user_posts - 1'; - } - - $this->config->increment('num_posts', -1, false); - } - else if ($data['post_visibility'] == ITEM_UNAPPROVED || $data['post_visibility'] == ITEM_REAPPROVE) - { - $sql_data[FORUMS_TABLE] = (($sql_data[FORUMS_TABLE]) ? $sql_data[FORUMS_TABLE] . ', ' : '') . 'forum_posts_unapproved = forum_posts_unapproved - 1'; - $sql_data[TOPICS_TABLE] = (($sql_data[TOPICS_TABLE]) ? $sql_data[TOPICS_TABLE] . ', ' : '') . 'topic_posts_unapproved = topic_posts_unapproved - 1'; - } - else if ($data['post_visibility'] == ITEM_DELETED) - { - $sql_data[FORUMS_TABLE] = (($sql_data[FORUMS_TABLE]) ? $sql_data[FORUMS_TABLE] . ', ' : '') . 'forum_posts_softdeleted = forum_posts_softdeleted - 1'; - $sql_data[TOPICS_TABLE] = (($sql_data[TOPICS_TABLE]) ? $sql_data[TOPICS_TABLE] . ', ' : '') . 'topic_posts_softdeleted = topic_posts_softdeleted - 1'; - } - } - - /** - * Remove topic from forum statistics - * - * @param $data array Post and topic data - * @param &$sql_data array Populated with the SQL changes, may be empty at call time - * @return null - */ - public function remove_topic_from_statistic($data, &$sql_data) - { - if ($data['topic_visibility'] == ITEM_APPROVED) - { - $sql_data[FORUMS_TABLE] .= 'forum_posts_approved = forum_posts_approved - 1, forum_topics_approved = forum_topics_approved - 1'; - - if ($data['post_postcount']) - { - $sql_data[$this->users_table] = ((!empty($sql_data[$this->users_table])) ? $sql_data[$this->users_table] . ', ' : '') . 'user_posts = user_posts - 1'; - } - } - else if ($data['topic_visibility'] == ITEM_UNAPPROVED || $data['post_visibility'] == ITEM_REAPPROVE) - { - $sql_data[FORUMS_TABLE] .= 'forum_posts_unapproved = forum_posts_unapproved - 1, forum_topics_unapproved = forum_topics_unapproved - 1'; - } - else if ($data['topic_visibility'] == ITEM_DELETED) - { - $sql_data[FORUMS_TABLE] .= 'forum_posts_softdeleted = forum_posts_softdeleted - 1, forum_topics_softdeleted = forum_topics_softdeleted - 1'; - } - - } -} diff --git a/install/update/new/phpbb/controller/helper.php b/install/update/new/phpbb/controller/helper.php deleted file mode 100644 index 58a4a49..0000000 --- a/install/update/new/phpbb/controller/helper.php +++ /dev/null @@ -1,195 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\controller; - -use Symfony\Component\HttpFoundation\JsonResponse; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Routing\Generator\UrlGeneratorInterface; - -/** -* Controller helper class, contains methods that do things for controllers -*/ -class helper -{ - /** - * Template object - * @var \phpbb\template\template - */ - protected $template; - - /** - * User object - * @var \phpbb\user - */ - protected $user; - - /** - * config object - * @var \phpbb\config\config - */ - protected $config; - - /* @var \phpbb\symfony_request */ - protected $symfony_request; - - /* @var \phpbb\request\request_interface */ - protected $request; - - /** - * @var \phpbb\routing\helper - */ - protected $routing_helper; - - /** - * Constructor - * - * @param \phpbb\template\template $template Template object - * @param \phpbb\user $user User object - * @param \phpbb\config\config $config Config object - * @param \phpbb\symfony_request $symfony_request Symfony Request object - * @param \phpbb\request\request_interface $request phpBB request object - * @param \phpbb\routing\helper $routing_helper Helper to generate the routes - */ - public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, \phpbb\symfony_request $symfony_request, \phpbb\request\request_interface $request, \phpbb\routing\helper $routing_helper) - { - $this->template = $template; - $this->user = $user; - $this->config = $config; - $this->symfony_request = $symfony_request; - $this->request = $request; - $this->routing_helper = $routing_helper; - } - - /** - * Automate setting up the page and creating the response object. - * - * @param string $template_file The template handle to render - * @param string $page_title The title of the page to output - * @param int $status_code The status code to be sent to the page header - * @param bool $display_online_list Do we display online users list - * @param int $item_id Restrict online users to item id - * @param string $item Restrict online users to a certain session item, e.g. forum for session_forum_id - * @param bool $send_headers Whether headers should be sent by page_header(). Defaults to false for controllers. - * - * @return Response object containing rendered page - */ - public function render($template_file, $page_title = '', $status_code = 200, $display_online_list = false, $item_id = 0, $item = 'forum', $send_headers = false) - { - page_header($page_title, $display_online_list, $item_id, $item, $send_headers); - - $this->template->set_filenames(array( - 'body' => $template_file, - )); - - page_footer(true, false, false); - - $headers = !empty($this->user->data['is_bot']) ? array('X-PHPBB-IS-BOT' => 'yes') : array(); - - return new Response($this->template->assign_display('body'), $status_code, $headers); - } - - /** - * Generate a URL to a route - * - * @param string $route Name of the route to travel - * @param array $params String or array of additional url parameters - * @param bool $is_amp Is url using & (true) or & (false) - * @param string|bool $session_id Possibility to use a custom session id instead of the global one - * @param bool|string $reference_type The type of reference to be generated (one of the constants) - * @return string The URL already passed through append_sid() - */ - public function route($route, array $params = array(), $is_amp = true, $session_id = false, $reference_type = UrlGeneratorInterface::ABSOLUTE_PATH) - { - return $this->routing_helper->route($route, $params, $is_amp, $session_id, $reference_type); - } - - /** - * Output an error, effectively the same thing as trigger_error - * - * @param string $message The error message - * @param int $code The error code (e.g. 404, 500, 503, etc.) - * @return Response A Response instance - * - * @deprecated 3.1.3 (To be removed: 4.0.0) Use exceptions instead. - */ - public function error($message, $code = 500) - { - return $this->message($message, array(), 'INFORMATION', $code); - } - - /** - * Output a message - * - * In case of an error, please throw an exception instead - * - * @param string $message The message to display (must be a language variable) - * @param array $parameters The parameters to use with the language var - * @param string $title Title for the message (must be a language variable) - * @param int $code The HTTP status code (e.g. 404, 500, 503, etc.) - * @return Response A Response instance - */ - public function message($message, array $parameters = array(), $title = 'INFORMATION', $code = 200) - { - array_unshift($parameters, $message); - $message_text = call_user_func_array(array($this->user, 'lang'), $parameters); - $message_title = $this->user->lang($title); - - if ($this->request->is_ajax()) - { - global $refresh_data; - - return new JsonResponse( - array( - 'MESSAGE_TITLE' => $message_title, - 'MESSAGE_TEXT' => $message_text, - 'S_USER_WARNING' => false, - 'S_USER_NOTICE' => false, - 'REFRESH_DATA' => (!empty($refresh_data)) ? $refresh_data : null - ), - $code - ); - } - - $this->template->assign_vars(array( - 'MESSAGE_TEXT' => $message_text, - 'MESSAGE_TITLE' => $message_title, - )); - - return $this->render('message_body.html', $message_title, $code); - } - - /** - * Assigns automatic refresh time meta tag in template - * - * @param int $time time in seconds, when redirection should occur - * @param string $url the URL where the user should be redirected - * @return null - */ - public function assign_meta_refresh_var($time, $url) - { - $this->template->assign_vars(array( - 'META' => '', - )); - } - - /** - * Return the current url - * - * @return string - */ - public function get_current_url() - { - return generate_board_url(true) . $this->request->escape($this->symfony_request->getRequestUri(), true); - } -} diff --git a/install/update/new/phpbb/cron/controller/cron.php b/install/update/new/phpbb/cron/controller/cron.php deleted file mode 100644 index 6f0e35e..0000000 --- a/install/update/new/phpbb/cron/controller/cron.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\cron\controller; - -use Symfony\Component\HttpFoundation\Response; - -/** - * Controller for running cron jobs - */ -class cron -{ - /** - * Handles CRON requests - * - * @param string $cron_type - * - * @return Response - */ - public function handle($cron_type) - { - $response = new Response(); - $response->headers->set('Cache-Control', 'no-cache'); - $response->headers->set('Content-type', 'image/gif'); - $response->headers->set('Content-length', '43'); - $response->setContent(base64_decode('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==')); - - return $response; - } -} diff --git a/install/update/new/phpbb/cron/event/cron_runner_listener.php b/install/update/new/phpbb/cron/event/cron_runner_listener.php deleted file mode 100644 index 9e9ecf0..0000000 --- a/install/update/new/phpbb/cron/event/cron_runner_listener.php +++ /dev/null @@ -1,103 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\cron\event; - -use phpbb\cron\manager; -use phpbb\lock\db; -use phpbb\request\request_interface; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpKernel\Event\PostResponseEvent; - -/** - * Event listener that executes cron tasks, after the response was served - */ -class cron_runner_listener implements EventSubscriberInterface -{ - /** - * @var \phpbb\lock\db - */ - private $cron_lock; - - /** - * @var \phpbb\cron\manager - */ - private $cron_manager; - - /** - * @var \phpbb\request\request_interface - */ - private $request; - - /** - * Constructor - * - * @param db $lock - * @param manager $manager - * @param request_interface $request - */ - public function __construct(db $lock, manager $manager, request_interface $request) - { - $this->cron_lock = $lock; - $this->cron_manager = $manager; - $this->request = $request; - } - - /** - * Runs the cron job after the response was sent - * - * @param PostResponseEvent $event The event - */ - public function on_kernel_terminate(PostResponseEvent $event) - { - $request = $event->getRequest(); - $controller_name = $request->get('_route'); - - if ($controller_name !== 'phpbb_cron_run') - { - return; - } - - $cron_type = $request->get('cron_type'); - - if ($this->cron_lock->acquire()) - { - $task = $this->cron_manager->find_task($cron_type); - if ($task) - { - if ($task->is_parametrized()) - { - $task->parse_parameters($this->request); - } - - if ($task->is_ready()) - { - $task->run(); - } - - $this->cron_lock->release(); - } - } - } - - /** - * {@inheritdoc} - */ - static public function getSubscribedEvents() - { - return array( - KernelEvents::TERMINATE => 'on_kernel_terminate', - ); - } -} diff --git a/install/update/new/phpbb/cron/manager.php b/install/update/new/phpbb/cron/manager.php deleted file mode 100644 index 59ee693..0000000 --- a/install/update/new/phpbb/cron/manager.php +++ /dev/null @@ -1,164 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\cron; - -use phpbb\cron\task\wrapper; -use phpbb\routing\helper; - -/** -* Cron manager class. -* -* Finds installed cron tasks, stores task objects, provides task selection. -*/ -class manager -{ - /** - * @var helper - */ - protected $routing_helper; - - /** - * Set of \phpbb\cron\task\wrapper objects. - * Array holding all tasks that have been found. - * - * @var array - */ - protected $tasks = array(); - - /** - * @var string - */ - protected $phpbb_root_path; - - /** - * @var string - */ - protected $php_ext; - - /** - * Constructor. Loads all available tasks. - * - * @param array|\Traversable $tasks Provides an iterable set of task names - * @param helper $routing_helper Routing helper - * @param string $phpbb_root_path Relative path to phpBB root - * @param string $php_ext PHP file extension - */ - public function __construct($tasks, helper $routing_helper, $phpbb_root_path, $php_ext) - { - $this->routing_helper = $routing_helper; - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - - $this->load_tasks($tasks); - } - - /** - * Loads tasks given by name, wraps them - * and puts them into $this->tasks. - * - * @param array|\Traversable $tasks Array of instances of \phpbb\cron\task\task - * - * @return null - */ - public function load_tasks($tasks) - { - foreach ($tasks as $task) - { - $this->tasks[] = $this->wrap_task($task); - } - } - - /** - * Finds a task that is ready to run. - * - * If several tasks are ready, any one of them could be returned. - * - * If no tasks are ready, null is returned. - * - * @return \phpbb\cron\task\wrapper|null - */ - public function find_one_ready_task() - { - shuffle($this->tasks); - foreach ($this->tasks as $task) - { - if ($task->is_ready()) - { - return $task; - } - } - return null; - } - - /** - * Finds all tasks that are ready to run. - * - * @return array List of tasks which are ready to run (wrapped in \phpbb\cron\task\wrapper). - */ - public function find_all_ready_tasks() - { - $tasks = array(); - foreach ($this->tasks as $task) - { - if ($task->is_ready()) - { - $tasks[] = $task; - } - } - return $tasks; - } - - /** - * Finds a task by name. - * - * If there is no task with the specified name, null is returned. - * - * Web runner uses this method to resolve names to tasks. - * - * @param string $name Name of the task to look up. - * @return \phpbb\cron\task\wrapper A wrapped task corresponding to the given name, or null. - */ - public function find_task($name) - { - foreach ($this->tasks as $task) - { - if ($task->get_name() == $name) - { - return $task; - } - } - return null; - } - - /** - * Find all tasks and return them. - * - * @return array List of all tasks. - */ - public function get_tasks() - { - return $this->tasks; - } - - /** - * Wraps a task inside an instance of \phpbb\cron\task\wrapper. - * - * @param \phpbb\cron\task\task $task The task. - * @return \phpbb\cron\task\wrapper The wrapped task. - */ - public function wrap_task(\phpbb\cron\task\task $task) - { - return new wrapper($task, $this->routing_helper, $this->phpbb_root_path, $this->php_ext); - } -} diff --git a/install/update/new/phpbb/cron/task/core/update_hashes.php b/install/update/new/phpbb/cron/task/core/update_hashes.php deleted file mode 100644 index 9e938f7..0000000 --- a/install/update/new/phpbb/cron/task/core/update_hashes.php +++ /dev/null @@ -1,130 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\cron\task\core; - -/** - * Update old hashes to the current default hashing algorithm - * - * It is intended to gradually update all "old" style hashes to the - * current default hashing algorithm. - */ -class update_hashes extends \phpbb\cron\task\base -{ - /** @var \phpbb\config\config */ - protected $config; - - /** @var \phpbb\db\driver\driver_interface */ - protected $db; - - /** @var \phpbb\lock\db */ - protected $update_lock; - - /** @var \phpbb\passwords\manager */ - protected $passwords_manager; - - /** @var string Default hashing type */ - protected $default_type; - - /** - * Constructor. - * - * @param \phpbb\config\config $config - * @param \phpbb\db\driver\driver_interface $db - * @param \phpbb\lock\db $update_lock - * @param \phpbb\passwords\manager $passwords_manager - * @param array $hashing_algorithms Hashing driver - * service collection - * @param array $defaults Default password types - */ - public function __construct(\phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\lock\db $update_lock, \phpbb\passwords\manager $passwords_manager, $hashing_algorithms, $defaults) - { - $this->config = $config; - $this->db = $db; - $this->passwords_manager = $passwords_manager; - $this->update_lock = $update_lock; - - foreach ($defaults as $type) - { - if ($hashing_algorithms[$type]->is_supported() && !$hashing_algorithms[$type] instanceof \phpbb\passwords\driver\base_native) - { - $this->default_type = $type; - break; - } - } - } - - /** - * {@inheritdoc} - */ - public function is_runnable() - { - return !$this->config['use_system_cron']; - } - - /** - * {@inheritdoc} - */ - public function should_run() - { - if (!empty($this->config['update_hashes_lock'])) - { - $last_run = explode(' ', $this->config['update_hashes_lock']); - if ($last_run[0] + 60 >= time()) - { - return false; - } - } - - return $this->config['enable_update_hashes'] && $this->config['update_hashes_last_cron'] < (time() - 60); - } - - /** - * {@inheritdoc} - */ - public function run() - { - if ($this->update_lock->acquire()) - { - $sql = 'SELECT user_id, user_password - FROM ' . USERS_TABLE . ' - WHERE user_password ' . $this->db->sql_like_expression('$H$' . $this->db->get_any_char()) . ' - OR user_password ' . $this->db->sql_like_expression('$CP$' . $this->db->get_any_char()); - $result = $this->db->sql_query_limit($sql, 20); - - $affected_rows = 0; - - while ($row = $this->db->sql_fetchrow($result)) - { - $new_hash = $this->passwords_manager->hash($row['user_password'], array($this->default_type)); - - // Increase number so we know that users were selected from the database - $affected_rows++; - - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_password = '" . $this->db->sql_escape($new_hash) . "' - WHERE user_id = " . (int) $row['user_id']; - $this->db->sql_query($sql); - } - - $this->config->set('update_hashes_last_cron', time()); - $this->update_lock->release(); - - // Stop cron for good once all hashes are converted - if ($affected_rows === 0) - { - $this->config->set('enable_update_hashes', '0'); - } - } - } -} diff --git a/install/update/new/phpbb/cron/task/wrapper.php b/install/update/new/phpbb/cron/task/wrapper.php deleted file mode 100644 index 4dc3a7f..0000000 --- a/install/update/new/phpbb/cron/task/wrapper.php +++ /dev/null @@ -1,117 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\cron\task; - -use phpbb\routing\helper; - -/** -* Cron task wrapper class. -* Enhances cron tasks with convenience methods that work identically for all tasks. -*/ -class wrapper -{ - /** - * @var helper - */ - protected $routing_helper; - - /** - * @var task - */ - protected $task; - - /** - * @var string - */ - protected $phpbb_root_path; - - /** - * @var string - */ - protected $php_ext; - - /** - * Constructor. - * - * Wraps a task $task, which must implement cron_task interface. - * - * @param task $task The cron task to wrap. - * @param helper $routing_helper Routing helper for route generation - * @param string $phpbb_root_path Relative path to phpBB root - * @param string $php_ext PHP file extension - */ - public function __construct(task $task, helper $routing_helper, $phpbb_root_path, $php_ext) - { - $this->task = $task; - $this->routing_helper = $routing_helper; - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - } - - /** - * Returns whether the wrapped task is parametrised. - * - * Parametrized tasks accept parameters during initialization and must - * normally be scheduled with parameters. - * - * @return bool Whether or not this task is parametrized. - */ - public function is_parametrized() - { - return $this->task instanceof parametrized; - } - - /** - * Returns whether the wrapped task is ready to run. - * - * A task is ready to run when it is runnable according to current configuration - * and enough time has passed since it was last run. - * - * @return bool Whether the wrapped task is ready to run. - */ - public function is_ready() - { - return $this->task->is_runnable() && $this->task->should_run(); - } - - /** - * Returns a url through which this task may be invoked via web. - * - * When system cron is not in use, running a cron task is accomplished - * by outputting an image with the url returned by this function as - * source. - * - * @return string URL through which this task may be invoked. - */ - public function get_url() - { - $params['cron_type'] = $this->get_name(); - if ($this->is_parametrized()) - { - $params = array_merge($params, $this->task->get_parameters()); - } - - return $this->routing_helper->route('phpbb_cron_run', $params); - } - - /** - * Forwards all other method calls to the wrapped task implementation. - * - * @return mixed - */ - public function __call($name, $args) - { - return call_user_func_array(array($this->task, $name), $args); - } -} diff --git a/install/update/new/phpbb/db/driver/driver.php b/install/update/new/phpbb/db/driver/driver.php deleted file mode 100644 index 93f0a74..0000000 --- a/install/update/new/phpbb/db/driver/driver.php +++ /dev/null @@ -1,1246 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\db\driver; - -/** -* Database Abstraction Layer -*/ -abstract class driver implements driver_interface -{ - var $db_connect_id; - var $query_result; - var $return_on_error = false; - var $transaction = false; - var $sql_time = 0; - var $num_queries = array(); - var $open_queries = array(); - - var $curtime = 0; - var $query_hold = ''; - var $html_hold = ''; - var $sql_report = ''; - - var $persistency = false; - var $user = ''; - var $server = ''; - var $dbname = ''; - - // Set to true if error triggered - var $sql_error_triggered = false; - - // Holding the last sql query on sql error - var $sql_error_sql = ''; - // Holding the error information - only populated if sql_error_triggered is set - var $sql_error_returned = array(); - - // Holding transaction count - var $transactions = 0; - - // Supports multi inserts? - var $multi_insert = false; - - /** - * Current sql layer - */ - var $sql_layer = ''; - - /** - * Wildcards for matching any (%) or exactly one (_) character within LIKE expressions - */ - var $any_char; - var $one_char; - - /** - * Exact version of the DBAL, directly queried - */ - var $sql_server_version = false; - - const LOGICAL_OP = 0; - const STATEMENTS = 1; - const LEFT_STMT = 0; - const COMPARE_OP = 1; - const RIGHT_STMT = 2; - const SUBQUERY_OP = 3; - const SUBQUERY_SELECT_TYPE = 4; - const SUBQUERY_BUILD = 5; - - /** - * @var bool - */ - protected $debug_load_time = false; - - /** - * @var bool - */ - protected $debug_sql_explain = false; - - /** - * Constructor - */ - function __construct() - { - $this->num_queries = array( - 'cached' => 0, - 'normal' => 0, - 'total' => 0, - ); - - // Fill default sql layer based on the class being called. - // This can be changed by the specified layer itself later if needed. - $this->sql_layer = substr(get_class($this), strlen('phpbb\db\driver\\')); - - // Do not change this please! This variable is used to easy the use of it - and is hardcoded. - $this->any_char = chr(0) . '%'; - $this->one_char = chr(0) . '_'; - } - - /** - * {@inheritdoc} - */ - public function set_debug_load_time($value) - { - $this->debug_load_time = $value; - } - - /** - * {@inheritdoc} - */ - public function set_debug_sql_explain($value) - { - $this->debug_sql_explain = $value; - } - - /** - * {@inheritdoc} - */ - public function get_sql_layer() - { - return $this->sql_layer; - } - - /** - * {@inheritdoc} - */ - public function get_db_name() - { - return $this->dbname; - } - - /** - * {@inheritdoc} - */ - public function get_any_char() - { - return $this->any_char; - } - - /** - * {@inheritdoc} - */ - public function get_one_char() - { - return $this->one_char; - } - - /** - * {@inheritdoc} - */ - public function get_db_connect_id() - { - return $this->db_connect_id; - } - - /** - * {@inheritdoc} - */ - public function get_sql_error_triggered() - { - return $this->sql_error_triggered; - } - - /** - * {@inheritdoc} - */ - public function get_sql_error_sql() - { - return $this->sql_error_sql; - } - - /** - * {@inheritdoc} - */ - public function get_transaction() - { - return $this->transaction; - } - - /** - * {@inheritdoc} - */ - public function get_sql_time() - { - return $this->sql_time; - } - - /** - * {@inheritdoc} - */ - public function get_sql_error_returned() - { - return $this->sql_error_returned; - } - - /** - * {@inheritdoc} - */ - public function get_multi_insert() - { - return $this->multi_insert; - } - - /** - * {@inheritdoc} - */ - public function set_multi_insert($multi_insert) - { - $this->multi_insert = $multi_insert; - } - - /** - * {@inheritDoc} - */ - function sql_return_on_error($fail = false) - { - $this->sql_error_triggered = false; - $this->sql_error_sql = ''; - - $this->return_on_error = $fail; - } - - /** - * {@inheritDoc} - */ - function sql_num_queries($cached = false) - { - return ($cached) ? $this->num_queries['cached'] : $this->num_queries['normal']; - } - - /** - * {@inheritDoc} - */ - function sql_add_num_queries($cached = false) - { - $this->num_queries['cached'] += ($cached !== false) ? 1 : 0; - $this->num_queries['normal'] += ($cached !== false) ? 0 : 1; - $this->num_queries['total'] += 1; - } - - /** - * {@inheritDoc} - */ - function sql_close() - { - if (!$this->db_connect_id) - { - return false; - } - - if ($this->transaction) - { - do - { - $this->sql_transaction('commit'); - } - while ($this->transaction); - } - - foreach ($this->open_queries as $query_id) - { - $this->sql_freeresult($query_id); - } - - // Connection closed correctly. Set db_connect_id to false to prevent errors - if ($result = $this->_sql_close()) - { - $this->db_connect_id = false; - } - - return $result; - } - - /** - * {@inheritDoc} - */ - function sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0) - { - if (empty($query)) - { - return false; - } - - // Never use a negative total or offset - $total = ($total < 0) ? 0 : $total; - $offset = ($offset < 0) ? 0 : $offset; - - return $this->_sql_query_limit($query, $total, $offset, $cache_ttl); - } - - /** - * {@inheritDoc} - */ - function sql_fetchrowset($query_id = false) - { - if ($query_id === false) - { - $query_id = $this->query_result; - } - - if ($query_id) - { - $result = array(); - while ($row = $this->sql_fetchrow($query_id)) - { - $result[] = $row; - } - - return $result; - } - - return false; - } - - /** - * {@inheritDoc} - */ - function sql_rowseek($rownum, &$query_id) - { - global $cache; - - if ($query_id === false) - { - $query_id = $this->query_result; - } - - if ($cache && $cache->sql_exists($query_id)) - { - return $cache->sql_rowseek($rownum, $query_id); - } - - if (!$query_id) - { - return false; - } - - $this->sql_freeresult($query_id); - $query_id = $this->sql_query($this->last_query_text); - - if (!$query_id) - { - return false; - } - - // We do not fetch the row for rownum == 0 because then the next resultset would be the second row - for ($i = 0; $i < $rownum; $i++) - { - if (!$this->sql_fetchrow($query_id)) - { - return false; - } - } - - return true; - } - - /** - * {@inheritDoc} - */ - function sql_fetchfield($field, $rownum = false, $query_id = false) - { - global $cache; - - if ($query_id === false) - { - $query_id = $this->query_result; - } - - if ($query_id) - { - if ($rownum !== false) - { - $this->sql_rowseek($rownum, $query_id); - } - - if ($cache && !is_object($query_id) && $cache->sql_exists($query_id)) - { - return $cache->sql_fetchfield($query_id, $field); - } - - $row = $this->sql_fetchrow($query_id); - return (isset($row[$field])) ? $row[$field] : false; - } - - return false; - } - - /** - * {@inheritDoc} - */ - function sql_like_expression($expression) - { - $expression = str_replace(array('_', '%'), array("\_", "\%"), $expression); - $expression = str_replace(array(chr(0) . "\_", chr(0) . "\%"), array('_', '%'), $expression); - - return $this->_sql_like_expression('LIKE \'' . $this->sql_escape($expression) . '\''); - } - - /** - * {@inheritDoc} - */ - function sql_not_like_expression($expression) - { - $expression = str_replace(array('_', '%'), array("\_", "\%"), $expression); - $expression = str_replace(array(chr(0) . "\_", chr(0) . "\%"), array('_', '%'), $expression); - - return $this->_sql_not_like_expression('NOT LIKE \'' . $this->sql_escape($expression) . '\''); - } - - /** - * {@inheritDoc} - */ - public function sql_case($condition, $action_true, $action_false = false) - { - $sql_case = 'CASE WHEN ' . $condition; - $sql_case .= ' THEN ' . $action_true; - $sql_case .= ($action_false !== false) ? ' ELSE ' . $action_false : ''; - $sql_case .= ' END'; - return $sql_case; - } - - /** - * {@inheritDoc} - */ - public function sql_concatenate($expr1, $expr2) - { - return $expr1 . ' || ' . $expr2; - } - - /** - * {@inheritDoc} - */ - function sql_buffer_nested_transactions() - { - return false; - } - - /** - * {@inheritDoc} - */ - function sql_transaction($status = 'begin') - { - switch ($status) - { - case 'begin': - // If we are within a transaction we will not open another one, but enclose the current one to not loose data (preventing auto commit) - if ($this->transaction) - { - $this->transactions++; - return true; - } - - $result = $this->_sql_transaction('begin'); - - if (!$result) - { - $this->sql_error(); - } - - $this->transaction = true; - break; - - case 'commit': - // If there was a previously opened transaction we do not commit yet... - // but count back the number of inner transactions - if ($this->transaction && $this->transactions) - { - $this->transactions--; - return true; - } - - // Check if there is a transaction (no transaction can happen if - // there was an error, with a combined rollback and error returning enabled) - // This implies we have transaction always set for autocommit db's - if (!$this->transaction) - { - return false; - } - - $result = $this->_sql_transaction('commit'); - - if (!$result) - { - $this->sql_error(); - } - - $this->transaction = false; - $this->transactions = 0; - break; - - case 'rollback': - $result = $this->_sql_transaction('rollback'); - $this->transaction = false; - $this->transactions = 0; - break; - - default: - $result = $this->_sql_transaction($status); - break; - } - - return $result; - } - - /** - * {@inheritDoc} - */ - function sql_build_array($query, $assoc_ary = false) - { - if (!is_array($assoc_ary)) - { - return false; - } - - $fields = $values = array(); - - if ($query == 'INSERT' || $query == 'INSERT_SELECT') - { - foreach ($assoc_ary as $key => $var) - { - $fields[] = $key; - - if (is_array($var) && is_string($var[0])) - { - // This is used for INSERT_SELECT(s) - $values[] = $var[0]; - } - else - { - $values[] = $this->_sql_validate_value($var); - } - } - - $query = ($query == 'INSERT') ? ' (' . implode(', ', $fields) . ') VALUES (' . implode(', ', $values) . ')' : ' (' . implode(', ', $fields) . ') SELECT ' . implode(', ', $values) . ' '; - } - else if ($query == 'MULTI_INSERT') - { - trigger_error('The MULTI_INSERT query value is no longer supported. Please use sql_multi_insert() instead.', E_USER_ERROR); - } - else if ($query == 'UPDATE' || $query == 'SELECT' || $query == 'DELETE') - { - $values = array(); - foreach ($assoc_ary as $key => $var) - { - $values[] = "$key = " . $this->_sql_validate_value($var); - } - $query = implode(($query == 'UPDATE') ? ', ' : ' AND ', $values); - } - - return $query; - } - - /** - * {@inheritDoc} - */ - function sql_in_set($field, $array, $negate = false, $allow_empty_set = false) - { - $array = (array) $array; - - if (!count($array)) - { - if (!$allow_empty_set) - { - // Print the backtrace to help identifying the location of the problematic code - $this->sql_error('No values specified for SQL IN comparison'); - } - else - { - // NOT IN () actually means everything so use a tautology - if ($negate) - { - return '1=1'; - } - // IN () actually means nothing so use a contradiction - else - { - return '1=0'; - } - } - } - - if (count($array) == 1) - { - @reset($array); - $var = current($array); - - return $field . ($negate ? ' <> ' : ' = ') . $this->_sql_validate_value($var); - } - else - { - return $field . ($negate ? ' NOT IN ' : ' IN ') . '(' . implode(', ', array_map(array($this, '_sql_validate_value'), $array)) . ')'; - } - } - - /** - * {@inheritDoc} - */ - function sql_bit_and($column_name, $bit, $compare = '') - { - if (method_exists($this, '_sql_bit_and')) - { - return $this->_sql_bit_and($column_name, $bit, $compare); - } - - return $column_name . ' & ' . (1 << $bit) . (($compare) ? ' ' . $compare : ''); - } - - /** - * {@inheritDoc} - */ - function sql_bit_or($column_name, $bit, $compare = '') - { - if (method_exists($this, '_sql_bit_or')) - { - return $this->_sql_bit_or($column_name, $bit, $compare); - } - - return $column_name . ' | ' . (1 << $bit) . (($compare) ? ' ' . $compare : ''); - } - - /** - * {@inheritDoc} - */ - function cast_expr_to_bigint($expression) - { - return $expression; - } - - /** - * {@inheritDoc} - */ - function cast_expr_to_string($expression) - { - return $expression; - } - - /** - * {@inheritDoc} - */ - function sql_lower_text($column_name) - { - return "LOWER($column_name)"; - } - - /** - * {@inheritDoc} - */ - function sql_multi_insert($table, $sql_ary) - { - if (!count($sql_ary)) - { - return false; - } - - if ($this->multi_insert) - { - $ary = array(); - foreach ($sql_ary as $id => $_sql_ary) - { - // If by accident the sql array is only one-dimensional we build a normal insert statement - if (!is_array($_sql_ary)) - { - return $this->sql_query('INSERT INTO ' . $table . ' ' . $this->sql_build_array('INSERT', $sql_ary)); - } - - $values = array(); - foreach ($_sql_ary as $key => $var) - { - $values[] = $this->_sql_validate_value($var); - } - $ary[] = '(' . implode(', ', $values) . ')'; - } - - return $this->sql_query('INSERT INTO ' . $table . ' ' . ' (' . implode(', ', array_keys($sql_ary[0])) . ') VALUES ' . implode(', ', $ary)); - } - else - { - foreach ($sql_ary as $ary) - { - if (!is_array($ary)) - { - return false; - } - - $result = $this->sql_query('INSERT INTO ' . $table . ' ' . $this->sql_build_array('INSERT', $ary)); - - if (!$result) - { - return false; - } - } - } - - return true; - } - - /** - * Function for validating values - * @access private - */ - function _sql_validate_value($var) - { - if (is_null($var)) - { - return 'NULL'; - } - else if (is_string($var)) - { - return "'" . $this->sql_escape($var) . "'"; - } - else - { - return (is_bool($var)) ? intval($var) : $var; - } - } - - /** - * {@inheritDoc} - */ - function sql_build_query($query, $array) - { - $sql = ''; - switch ($query) - { - case 'SELECT': - case 'SELECT_DISTINCT'; - - $sql = str_replace('_', ' ', $query) . ' ' . $array['SELECT'] . ' FROM '; - - // Build table array. We also build an alias array for later checks. - $table_array = $aliases = array(); - $used_multi_alias = false; - - foreach ($array['FROM'] as $table_name => $alias) - { - if (is_array($alias)) - { - $used_multi_alias = true; - - foreach ($alias as $multi_alias) - { - $table_array[] = $table_name . ' ' . $multi_alias; - $aliases[] = $multi_alias; - } - } - else - { - $table_array[] = $table_name . ' ' . $alias; - $aliases[] = $alias; - } - } - - // We run the following code to determine if we need to re-order the table array. ;) - // The reason for this is that for multi-aliased tables (two equal tables) in the FROM statement the last table need to match the first comparison. - // DBMS who rely on this: Oracle, PostgreSQL and MSSQL. For all other DBMS it makes absolutely no difference in which order the table is. - if (!empty($array['LEFT_JOIN']) && count($array['FROM']) > 1 && $used_multi_alias !== false) - { - // Take first LEFT JOIN - $join = current($array['LEFT_JOIN']); - - // Determine the table used there (even if there are more than one used, we only want to have one - preg_match('/(' . implode('|', $aliases) . ')\.[^\s]+/U', str_replace(array('(', ')', 'AND', 'OR', ' '), '', $join['ON']), $matches); - - // If there is a first join match, we need to make sure the table order is correct - if (!empty($matches[1])) - { - $first_join_match = trim($matches[1]); - $table_array = $last = array(); - - foreach ($array['FROM'] as $table_name => $alias) - { - if (is_array($alias)) - { - foreach ($alias as $multi_alias) - { - ($multi_alias === $first_join_match) ? $last[] = $table_name . ' ' . $multi_alias : $table_array[] = $table_name . ' ' . $multi_alias; - } - } - else - { - ($alias === $first_join_match) ? $last[] = $table_name . ' ' . $alias : $table_array[] = $table_name . ' ' . $alias; - } - } - - $table_array = array_merge($table_array, $last); - } - } - - $sql .= $this->_sql_custom_build('FROM', implode(' CROSS JOIN ', $table_array)); - - if (!empty($array['LEFT_JOIN'])) - { - foreach ($array['LEFT_JOIN'] as $join) - { - $sql .= ' LEFT JOIN ' . key($join['FROM']) . ' ' . current($join['FROM']) . ' ON (' . $join['ON'] . ')'; - } - } - - if (!empty($array['WHERE'])) - { - $sql .= ' WHERE '; - - if (is_array($array['WHERE'])) - { - $sql_where = $this->_process_boolean_tree_first($array['WHERE']); - } - else - { - $sql_where = $array['WHERE']; - } - - $sql .= $this->_sql_custom_build('WHERE', $sql_where); - } - - if (!empty($array['GROUP_BY'])) - { - $sql .= ' GROUP BY ' . $array['GROUP_BY']; - } - - if (!empty($array['ORDER_BY'])) - { - $sql .= ' ORDER BY ' . $array['ORDER_BY']; - } - - break; - } - - return $sql; - } - - - protected function _process_boolean_tree_first($operations_ary) - { - // In cases where an array exists but there is no head condition, - // it should be because there's only 1 WHERE clause. This seems the best way to deal with it. - if ($operations_ary[self::LOGICAL_OP] !== 'AND' && - $operations_ary[self::LOGICAL_OP] !== 'OR') - { - $operations_ary = array('AND', array($operations_ary)); - } - return $this->_process_boolean_tree($operations_ary) . "\n"; - } - - protected function _process_boolean_tree($operations_ary) - { - $operation = $operations_ary[self::LOGICAL_OP]; - - foreach ($operations_ary[self::STATEMENTS] as &$condition) - { - switch ($condition[self::LOGICAL_OP]) - { - case 'AND': - case 'OR': - - $condition = ' ( ' . $this->_process_boolean_tree($condition) . ') '; - - break; - case 'NOT': - - $condition = ' NOT (' . $this->_process_boolean_tree($condition) . ') '; - - break; - - default: - - switch (count($condition)) - { - case 3: - - // Typical 3 element clause with {left hand} {operator} {right hand} - switch ($condition[self::COMPARE_OP]) - { - case 'IN': - case 'NOT_IN': - - // As this is used with an IN, assume it is a set of elements for sql_in_set() - $condition = $this->sql_in_set($condition[self::LEFT_STMT], $condition[self::RIGHT_STMT], $condition[self::COMPARE_OP] === 'NOT_IN', true); - - break; - - case 'LIKE': - - $condition = $condition[self::LEFT_STMT] . ' ' . $this->sql_like_expression($condition[self::RIGHT_STMT]) . ' '; - - break; - - case 'NOT_LIKE': - - $condition = $condition[self::LEFT_STMT] . ' ' . $this->sql_not_like_expression($condition[self::RIGHT_STMT]) . ' '; - - break; - - case 'IS_NOT': - - $condition[self::COMPARE_OP] = 'IS NOT'; - - // no break - case 'IS': - - // If the value is NULL, the string of it is the empty string ('') which is not the intended result. - // this should solve that - if ($condition[self::RIGHT_STMT] === null) - { - $condition[self::RIGHT_STMT] = 'NULL'; - } - - $condition = implode(' ', $condition); - - break; - - default: - - $condition = implode(' ', $condition); - - break; - } - - break; - - case 5: - - // Subquery with {left hand} {operator} {compare kind} {SELECT Kind } {Sub Query} - - $result = $condition[self::LEFT_STMT] . ' ' . $condition[self::COMPARE_OP] . ' ' . $condition[self::SUBQUERY_OP] . ' ( '; - $result .= $this->sql_build_query($condition[self::SUBQUERY_SELECT_TYPE], $condition[self::SUBQUERY_BUILD]); - $result .= ' )'; - $condition = $result; - - break; - - default: - // This is an unpredicted clause setup. Just join all elements. - $condition = implode(' ', $condition); - - break; - } - - break; - } - - } - - if ($operation === 'NOT') - { - $operations_ary = implode("", $operations_ary[self::STATEMENTS]); - } - else - { - $operations_ary = implode(" \n $operation ", $operations_ary[self::STATEMENTS]); - } - - return $operations_ary; - } - - - /** - * {@inheritDoc} - */ - function sql_error($sql = '') - { - global $auth, $user, $config; - - // Set var to retrieve errored status - $this->sql_error_triggered = true; - $this->sql_error_sql = $sql; - - $this->sql_error_returned = $this->_sql_error(); - - if (!$this->return_on_error) - { - $message = 'SQL ERROR [ ' . $this->sql_layer . ' ]

' . $this->sql_error_returned['message'] . ' [' . $this->sql_error_returned['code'] . ']'; - - // Show complete SQL error and path to administrators only - // Additionally show complete error on installation or if extended debug mode is enabled - // The DEBUG constant is for development only! - if ((isset($auth) && $auth->acl_get('a_')) || defined('IN_INSTALL') || $this->debug_sql_explain) - { - $message .= ($sql) ? '

SQL

' . htmlspecialchars($sql) : ''; - } - else - { - // If error occurs in initiating the session we need to use a pre-defined language string - // This could happen if the connection could not be established for example (then we are not able to grab the default language) - if (!isset($user->lang['SQL_ERROR_OCCURRED'])) - { - $message .= '

An sql error occurred while fetching this page. Please contact an administrator if this problem persists.'; - } - else - { - if (!empty($config['board_contact'])) - { - $message .= '

' . sprintf($user->lang['SQL_ERROR_OCCURRED'], '', ''); - } - else - { - $message .= '

' . sprintf($user->lang['SQL_ERROR_OCCURRED'], '', ''); - } - } - } - - if ($this->transaction) - { - $this->sql_transaction('rollback'); - } - - if (strlen($message) > 1024) - { - // We need to define $msg_long_text here to circumvent text stripping. - global $msg_long_text; - $msg_long_text = $message; - - trigger_error(false, E_USER_ERROR); - } - - trigger_error($message, E_USER_ERROR); - } - - if ($this->transaction) - { - $this->sql_transaction('rollback'); - } - - return $this->sql_error_returned; - } - - /** - * {@inheritDoc} - */ - function sql_report($mode, $query = '') - { - global $cache, $starttime, $phpbb_root_path, $phpbb_path_helper; - global $request; - - if (is_object($request) && !$request->variable('explain', false)) - { - return false; - } - - if (!$query && $this->query_hold != '') - { - $query = $this->query_hold; - } - - switch ($mode) - { - case 'display': - if (!empty($cache)) - { - $cache->unload(); - } - $this->sql_close(); - - $mtime = explode(' ', microtime()); - $totaltime = $mtime[0] + $mtime[1] - $starttime; - - echo ' - - - - - SQL Report - - - -
- -
-
-
- -
-

SQL Report

-
-

Page generated in ' . round($totaltime, 4) . " seconds with {$this->num_queries['normal']} queries" . (($this->num_queries['cached']) ? " + {$this->num_queries['cached']} " . (($this->num_queries['cached'] == 1) ? 'query' : 'queries') . ' returning data from cache' : '') . '

- -

Time spent on ' . $this->sql_layer . ' queries: ' . round($this->sql_time, 5) . 's | Time spent on PHP: ' . round($totaltime - $this->sql_time, 5) . 's

- -

- ' . $this->sql_report . ' -
- -
-
-
- -
- - '; - - exit_handler(); - - break; - - case 'stop': - $endtime = explode(' ', microtime()); - $endtime = $endtime[0] + $endtime[1]; - - $this->sql_report .= ' - - - - - - - - - - - - -
Query #' . $this->num_queries['total'] . '
- - ' . $this->html_hold . ' - -

- '; - - if ($this->query_result) - { - if (preg_match('/^(UPDATE|DELETE|REPLACE)/', $query)) - { - $this->sql_report .= 'Affected rows: ' . $this->sql_affectedrows() . ' | '; - } - $this->sql_report .= 'Before: ' . sprintf('%.5f', $this->curtime - $starttime) . 's | After: ' . sprintf('%.5f', $endtime - $starttime) . 's | Elapsed: ' . sprintf('%.5f', $endtime - $this->curtime) . 's'; - } - else - { - $error = $this->sql_error(); - $this->sql_report .= 'FAILED - ' . $this->sql_layer . ' Error ' . $error['code'] . ': ' . htmlspecialchars($error['message']); - } - - $this->sql_report .= '



'; - - $this->sql_time += $endtime - $this->curtime; - break; - - case 'start': - $this->query_hold = $query; - $this->html_hold = ''; - - $this->_sql_report($mode, $query); - - $this->curtime = explode(' ', microtime()); - $this->curtime = $this->curtime[0] + $this->curtime[1]; - - break; - - case 'add_select_row': - - $html_table = func_get_arg(2); - $row = func_get_arg(3); - - if (!$html_table && count($row)) - { - $html_table = true; - $this->html_hold .= ''; - - foreach (array_keys($row) as $val) - { - $this->html_hold .= ''; - } - $this->html_hold .= ''; - } - $this->html_hold .= ''; - - $class = 'row1'; - foreach (array_values($row) as $val) - { - $class = ($class == 'row1') ? 'row2' : 'row1'; - $this->html_hold .= ''; - } - $this->html_hold .= ''; - - return $html_table; - - break; - - case 'fromcache': - - $this->_sql_report($mode, $query); - - break; - - case 'record_fromcache': - - $endtime = func_get_arg(2); - $splittime = func_get_arg(3); - - $time_cache = $endtime - $this->curtime; - $time_db = $splittime - $endtime; - $color = ($time_db > $time_cache) ? 'green' : 'red'; - - $this->sql_report .= '
' . (($val) ? ucwords(str_replace('_', ' ', $val)) : ' ') . '
' . (($val) ? $val : ' ') . '
'; - $this->sql_report .= '
Query results obtained from the cache
'; - $this->sql_report .= '

'; - $this->sql_report .= 'Before: ' . sprintf('%.5f', $this->curtime - $starttime) . 's | After: ' . sprintf('%.5f', $endtime - $starttime) . 's | Elapsed [cache]: ' . sprintf('%.5f', ($time_cache)) . 's | Elapsed [db]: ' . sprintf('%.5f', $time_db) . 's



'; - - // Pad the start time to not interfere with page timing - $starttime += $time_db; - - break; - - default: - - $this->_sql_report($mode, $query); - - break; - } - - return true; - } - - /** - * {@inheritDoc} - */ - function get_estimated_row_count($table_name) - { - return $this->get_row_count($table_name); - } - - /** - * {@inheritDoc} - */ - function get_row_count($table_name) - { - $sql = 'SELECT COUNT(*) AS rows_total - FROM ' . $this->sql_escape($table_name); - $result = $this->sql_query($sql); - $rows_total = $this->sql_fetchfield('rows_total'); - $this->sql_freeresult($result); - - return $rows_total; - } -} diff --git a/install/update/new/phpbb/db/driver/driver_interface.php b/install/update/new/phpbb/db/driver/driver_interface.php deleted file mode 100644 index 05ff5ef..0000000 --- a/install/update/new/phpbb/db/driver/driver_interface.php +++ /dev/null @@ -1,467 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\db\driver; - -interface driver_interface -{ - /** - * Set value for load_time debug parameter - * - * @param bool $value - */ - public function set_debug_load_time($value); - - /** - * Set value for sql_explain debug parameter - * - * @param bool $value - */ - public function set_debug_sql_explain($value); - - /** - * Gets the name of the sql layer. - * - * @return string - */ - public function get_sql_layer(); - - /** - * Gets the name of the database. - * - * @return string - */ - public function get_db_name(); - - /** - * Wildcards for matching any (%) character within LIKE expressions - * - * @return string - */ - public function get_any_char(); - - /** - * Wildcards for matching exactly one (_) character within LIKE expressions - * - * @return string - */ - public function get_one_char(); - - /** - * Gets the time spent into the queries - * - * @return int - */ - public function get_sql_time(); - - /** - * Gets the connect ID. - * - * @return mixed - */ - public function get_db_connect_id(); - - /** - * Indicates if an error was triggered. - * - * @return bool - */ - public function get_sql_error_triggered(); - - /** - * Gets the last faulty query - * - * @return string - */ - public function get_sql_error_sql(); - - /** - * Indicates if we are in a transaction. - * - * @return bool - */ - public function get_transaction(); - - /** - * Gets the returned error. - * - * @return array - */ - public function get_sql_error_returned(); - - /** - * Indicates if multiple insertion can be used - * - * @return bool - */ - public function get_multi_insert(); - - /** - * Set if multiple insertion can be used - * - * @param bool $multi_insert - */ - public function set_multi_insert($multi_insert); - - /** - * Gets the exact number of rows in a specified table. - * - * @param string $table_name Table name - * @return string Exact number of rows in $table_name. - */ - public function get_row_count($table_name); - - /** - * Gets the estimated number of rows in a specified table. - * - * @param string $table_name Table name - * @return string Number of rows in $table_name. - * Prefixed with ~ if estimated (otherwise exact). - */ - public function get_estimated_row_count($table_name); - - /** - * Run LOWER() on DB column of type text (i.e. neither varchar nor char). - * - * @param string $column_name The column name to use - * @return string A SQL statement like "LOWER($column_name)" - */ - public function sql_lower_text($column_name); - - /** - * Display sql error page - * - * @param string $sql The SQL query causing the error - * @return mixed Returns the full error message, if $this->return_on_error - * is set, null otherwise - */ - public function sql_error($sql = ''); - - /** - * Returns whether results of a query need to be buffered to run a - * transaction while iterating over them. - * - * @return bool Whether buffering is required. - */ - public function sql_buffer_nested_transactions(); - - /** - * Run binary OR operator on DB column. - * - * @param string $column_name The column name to use - * @param int $bit The value to use for the OR operator, - * will be converted to (1 << $bit). Is used by options, - * using the number schema... 0, 1, 2...29 - * @param string $compare Any custom SQL code after the check (e.g. "= 0") - * @return string A SQL statement like "$column | (1 << $bit) {$compare}" - */ - public function sql_bit_or($column_name, $bit, $compare = ''); - - /** - * Version information about used database - * - * @param bool $raw Only return the fetched sql_server_version - * @param bool $use_cache Is it safe to retrieve the value from the cache - * @return string sql server version - */ - public function sql_server_info($raw = false, $use_cache = true); - - /** - * Return on error or display error message - * - * @param bool $fail Should we return on errors, or stop - * @return null - */ - public function sql_return_on_error($fail = false); - - /** - * Build sql statement from an array - * - * @param string $query Should be on of the following strings: - * INSERT, INSERT_SELECT, UPDATE, SELECT, DELETE - * @param array $assoc_ary Array with "column => value" pairs - * @return string A SQL statement like "c1 = 'a' AND c2 = 'b'" - */ - public function sql_build_array($query, $assoc_ary = array()); - - /** - * Fetch all rows - * - * @param mixed $query_id Already executed query to get the rows from, - * if false, the last query will be used. - * @return mixed Nested array if the query had rows, false otherwise - */ - public function sql_fetchrowset($query_id = false); - - /** - * SQL Transaction - * - * @param string $status Should be one of the following strings: - * begin, commit, rollback - * @return mixed Buffered, seekable result handle, false on error - */ - public function sql_transaction($status = 'begin'); - - /** - * Build a concatenated expression - * - * @param string $expr1 Base SQL expression where we append the second one - * @param string $expr2 SQL expression that is appended to the first expression - * @return string Concatenated string - */ - public function sql_concatenate($expr1, $expr2); - - /** - * Build a case expression - * - * Note: The two statements action_true and action_false must have the same - * data type (int, vchar, ...) in the database! - * - * @param string $condition The condition which must be true, - * to use action_true rather then action_else - * @param string $action_true SQL expression that is used, if the condition is true - * @param mixed $action_false SQL expression that is used, if the condition is false - * @return string CASE expression including the condition and statements - */ - public function sql_case($condition, $action_true, $action_false = false); - - /** - * Build sql statement from array for select and select distinct statements - * - * Possible query values: SELECT, SELECT_DISTINCT - * - * @param string $query Should be one of: SELECT, SELECT_DISTINCT - * @param array $array Array with the query data: - * SELECT A comma imploded list of columns to select - * FROM Array with "table => alias" pairs, - * (alias can also be an array) - * Optional: LEFT_JOIN Array of join entries: - * FROM Table that should be joined - * ON Condition for the join - * Optional: WHERE Where SQL statement - * Optional: GROUP_BY Group by SQL statement - * Optional: ORDER_BY Order by SQL statement - * @return string A SQL statement ready for execution - */ - public function sql_build_query($query, $array); - - /** - * Fetch field - * if rownum is false, the current row is used, else it is pointing to the row (zero-based) - * - * @param string $field Name of the column - * @param mixed $rownum Row number, if false the current row will be used - * and the row curser will point to the next row - * Note: $rownum is 0 based - * @param mixed $query_id Already executed query to get the rows from, - * if false, the last query will be used. - * @return mixed String value of the field in the selected row, - * false, if the row does not exist - */ - public function sql_fetchfield($field, $rownum = false, $query_id = false); - - /** - * Fetch current row - * - * @param mixed $query_id Already executed query to get the rows from, - * if false, the last query will be used. - * @return mixed Array with the current row, - * false, if the row does not exist - */ - public function sql_fetchrow($query_id = false); - - /** - * Returns SQL string to cast a string expression to an int. - * - * @param string $expression An expression evaluating to string - * @return string Expression returning an int - */ - public function cast_expr_to_bigint($expression); - - /** - * Get last inserted id after insert statement - * - * @return string Autoincrement value of the last inserted row - */ - public function sql_nextid(); - - /** - * Add to query count - * - * @param bool $cached Is this query cached? - * @return null - */ - public function sql_add_num_queries($cached = false); - - /** - * Build LIMIT query - * - * @param string $query The SQL query to execute - * @param int $total The number of rows to select - * @param int $offset - * @param int $cache_ttl Either 0 to avoid caching or - * the time in seconds which the result shall be kept in cache - * @return mixed Buffered, seekable result handle, false on error - */ - public function sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0); - - /** - * Base query method - * - * @param string $query The SQL query to execute - * @param int $cache_ttl Either 0 to avoid caching or - * the time in seconds which the result shall be kept in cache - * @return mixed Buffered, seekable result handle, false on error - */ - public function sql_query($query = '', $cache_ttl = 0); - - /** - * Returns SQL string to cast an integer expression to a string. - * - * @param string $expression An expression evaluating to int - * @return string Expression returning a string - */ - public function cast_expr_to_string($expression); - - /** - * Connect to server - * - * @param string $sqlserver Address of the database server - * @param string $sqluser User name of the SQL user - * @param string $sqlpassword Password of the SQL user - * @param string $database Name of the database - * @param mixed $port Port of the database server - * @param bool $persistency - * @param bool $new_link Should a new connection be established - * @return mixed Connection ID on success, string error message otherwise - */ - public function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false); - - /** - * Run binary AND operator on DB column. - * Results in sql statement: "{$column_name} & (1 << {$bit}) {$compare}" - * - * @param string $column_name The column name to use - * @param int $bit The value to use for the AND operator, - * will be converted to (1 << $bit). Is used by - * options, using the number schema: 0, 1, 2...29 - * @param string $compare Any custom SQL code after the check (for example "= 0") - * @return string A SQL statement like: "{$column} & (1 << {$bit}) {$compare}" - */ - public function sql_bit_and($column_name, $bit, $compare = ''); - - /** - * Free sql result - * - * @param mixed $query_id Already executed query result, - * if false, the last query will be used. - * @return null - */ - public function sql_freeresult($query_id = false); - - /** - * Return number of sql queries and cached sql queries used - * - * @param bool $cached Should we return the number of cached or normal queries? - * @return int Number of queries that have been executed - */ - public function sql_num_queries($cached = false); - - /** - * Run more than one insert statement. - * - * @param string $table Table name to run the statements on - * @param array $sql_ary Multi-dimensional array holding the statement data - * @return bool false if no statements were executed. - */ - public function sql_multi_insert($table, $sql_ary); - - /** - * Return number of affected rows - * - * @return mixed Number of the affected rows by the last query - * false if no query has been run before - */ - public function sql_affectedrows(); - - /** - * DBAL garbage collection, close SQL connection - * - * @return mixed False if no connection was opened before, - * Server response otherwise - */ - public function sql_close(); - - /** - * Seek to given row number - * - * @param mixed $rownum Row number the curser should point to - * Note: $rownum is 0 based - * @param mixed $query_id ID of the query to set the row cursor on - * if false, the last query will be used. - * $query_id will then be set correctly - * @return bool False if something went wrong - */ - public function sql_rowseek($rownum, &$query_id); - - /** - * Escape string used in sql query - * - * @param string $msg String to be escaped - * @return string Escaped version of $msg - */ - public function sql_escape($msg); - - /** - * Correctly adjust LIKE expression for special characters - * Some DBMS are handling them in a different way - * - * @param string $expression The expression to use. Every wildcard is - * escaped, except $this->any_char and $this->one_char - * @return string A SQL statement like: "LIKE 'bertie_%'" - */ - public function sql_like_expression($expression); - - /** - * Correctly adjust NOT LIKE expression for special characters - * Some DBMS are handling them in a different way - * - * @param string $expression The expression to use. Every wildcard is - * escaped, except $this->any_char and $this->one_char - * @return string A SQL statement like: "NOT LIKE 'bertie_%'" - */ - public function sql_not_like_expression($expression); - - /** - * Explain queries - * - * @param string $mode Available modes: display, start, stop, - * add_select_row, fromcache, record_fromcache - * @param string $query The Query that should be explained - * @return mixed Either a full HTML page, boolean or null - */ - public function sql_report($mode, $query = ''); - - /** - * Build IN or NOT IN sql comparison string, uses <> or = on single element - * arrays to improve comparison speed - * - * @param string $field Name of the sql column that shall be compared - * @param array $array Array of values that are (not) allowed - * @param bool $negate true for NOT IN (), false for IN () - * @param bool $allow_empty_set If true, allow $array to be empty, - * this function will return 1=1 or 1=0 then. - * @return string A SQL statement like: "IN (1, 2, 3, 4)" or "= 1" - */ - public function sql_in_set($field, $array, $negate = false, $allow_empty_set = false); -} diff --git a/install/update/new/phpbb/db/driver/factory.php b/install/update/new/phpbb/db/driver/factory.php deleted file mode 100644 index bb6e7a2..0000000 --- a/install/update/new/phpbb/db/driver/factory.php +++ /dev/null @@ -1,459 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\db\driver; - -use \Symfony\Component\DependencyInjection\ContainerInterface; - -/** -* Database Abstraction Layer -*/ -class factory implements driver_interface -{ - /** - * @var driver_interface - */ - protected $driver = null; - - /** - * @var ContainerInterface - */ - protected $container; - - /** - * Constructor. - * - * @param ContainerInterface $container A ContainerInterface instance - */ - public function __construct(ContainerInterface $container) - { - $this->container = $container; - } - - /** - * Return the current driver (and retrieved it from the container if necessary) - * - * @return driver_interface - */ - protected function get_driver() - { - if ($this->driver === null) - { - $this->driver = $this->container->get('dbal.conn.driver'); - } - - return $this->driver; - } - - /** - * Set the current driver - * - * @param driver_interface $driver - */ - public function set_driver(driver_interface $driver) - { - $this->driver = $driver; - } - - /** - * {@inheritdoc} - */ - public function set_debug_load_time($value) - { - $this->get_driver()->set_debug_load_time($value); - } - - /** - * {@inheritdoc} - */ - public function set_debug_sql_explain($value) - { - $this->get_driver()->set_debug_sql_explain($value); - } - - /** - * {@inheritdoc} - */ - public function get_sql_layer() - { - return $this->get_driver()->get_sql_layer(); - } - - /** - * {@inheritdoc} - */ - public function get_db_name() - { - return $this->get_driver()->get_db_name(); - } - - /** - * {@inheritdoc} - */ - public function get_any_char() - { - return $this->get_driver()->get_any_char(); - } - - /** - * {@inheritdoc} - */ - public function get_one_char() - { - return $this->get_driver()->get_one_char(); - } - - /** - * {@inheritdoc} - */ - public function get_db_connect_id() - { - return $this->get_driver()->get_db_connect_id(); - } - - /** - * {@inheritdoc} - */ - public function get_sql_error_triggered() - { - return $this->get_driver()->get_sql_error_triggered(); - } - - /** - * {@inheritdoc} - */ - public function get_sql_error_sql() - { - return $this->get_driver()->get_sql_error_sql(); - } - - /** - * {@inheritdoc} - */ - public function get_transaction() - { - return $this->get_driver()->get_transaction(); - } - - /** - * {@inheritdoc} - */ - public function get_sql_time() - { - return $this->get_driver()->get_sql_time(); - } - - /** - * {@inheritdoc} - */ - public function get_sql_error_returned() - { - return $this->get_driver()->get_sql_error_returned(); - } - - /** - * {@inheritdoc} - */ - public function get_multi_insert() - { - return $this->get_driver()->get_multi_insert(); - } - - /** - * {@inheritdoc} - */ - public function set_multi_insert($multi_insert) - { - $this->get_driver()->set_multi_insert($multi_insert); - } - - /** - * {@inheritdoc} - */ - public function get_row_count($table_name) - { - return $this->get_driver()->get_row_count($table_name); - } - - /** - * {@inheritdoc} - */ - public function get_estimated_row_count($table_name) - { - return $this->get_driver()->get_estimated_row_count($table_name); - } - - /** - * {@inheritdoc} - */ - public function sql_lower_text($column_name) - { - return $this->get_driver()->sql_lower_text($column_name); - } - - /** - * {@inheritdoc} - */ - public function sql_error($sql = '') - { - return $this->get_driver()->sql_error($sql); - } - - /** - * {@inheritdoc} - */ - public function sql_buffer_nested_transactions() - { - return $this->get_driver()->sql_buffer_nested_transactions(); - } - - /** - * {@inheritdoc} - */ - public function sql_bit_or($column_name, $bit, $compare = '') - { - return $this->get_driver()->sql_bit_or($column_name, $bit, $compare); - } - - /** - * {@inheritdoc} - */ - public function sql_server_info($raw = false, $use_cache = true) - { - return $this->get_driver()->sql_server_info($raw, $use_cache); - } - - /** - * {@inheritdoc} - */ - public function sql_return_on_error($fail = false) - { - return $this->get_driver()->sql_return_on_error($fail); - } - - /** - * {@inheritdoc} - */ - public function sql_build_array($query, $assoc_ary = array()) - { - return $this->get_driver()->sql_build_array($query, $assoc_ary); - } - - /** - * {@inheritdoc} - */ - public function sql_fetchrowset($query_id = false) - { - return $this->get_driver()->sql_fetchrowset($query_id); - } - - /** - * {@inheritdoc} - */ - public function sql_transaction($status = 'begin') - { - return $this->get_driver()->sql_transaction($status); - } - - /** - * {@inheritdoc} - */ - public function sql_concatenate($expr1, $expr2) - { - return $this->get_driver()->sql_concatenate($expr1, $expr2); - } - - /** - * {@inheritdoc} - */ - public function sql_case($condition, $action_true, $action_false = false) - { - return $this->get_driver()->sql_case($condition, $action_true, $action_false); - } - - /** - * {@inheritdoc} - */ - public function sql_build_query($query, $array) - { - return $this->get_driver()->sql_build_query($query, $array); - } - - /** - * {@inheritdoc} - */ - public function sql_fetchfield($field, $rownum = false, $query_id = false) - { - return $this->get_driver()->sql_fetchfield($field, $rownum, $query_id); - } - - /** - * {@inheritdoc} - */ - public function sql_fetchrow($query_id = false) - { - return $this->get_driver()->sql_fetchrow($query_id); - } - - /** - * {@inheritdoc} - */ - public function cast_expr_to_bigint($expression) - { - return $this->get_driver()->cast_expr_to_bigint($expression); - } - - /** - * {@inheritdoc} - */ - public function sql_nextid() - { - return $this->get_driver()->sql_nextid(); - } - - /** - * {@inheritdoc} - */ - public function sql_add_num_queries($cached = false) - { - return $this->get_driver()->sql_add_num_queries($cached); - } - - /** - * {@inheritdoc} - */ - public function sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0) - { - return $this->get_driver()->sql_query_limit($query, $total, $offset, $cache_ttl); - } - - /** - * {@inheritdoc} - */ - public function sql_query($query = '', $cache_ttl = 0) - { - return $this->get_driver()->sql_query($query, $cache_ttl); - } - - /** - * {@inheritdoc} - */ - public function cast_expr_to_string($expression) - { - return $this->get_driver()->cast_expr_to_string($expression); - } - - /** - * {@inheritdoc} - */ - public function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false) - { - throw new \Exception('Disabled method.'); - } - - /** - * {@inheritdoc} - */ - public function sql_bit_and($column_name, $bit, $compare = '') - { - return $this->get_driver()->sql_bit_and($column_name, $bit, $compare); - } - - /** - * {@inheritdoc} - */ - public function sql_freeresult($query_id = false) - { - return $this->get_driver()->sql_freeresult($query_id); - } - - /** - * {@inheritdoc} - */ - public function sql_num_queries($cached = false) - { - return $this->get_driver()->sql_num_queries($cached); - } - - /** - * {@inheritdoc} - */ - public function sql_multi_insert($table, $sql_ary) - { - return $this->get_driver()->sql_multi_insert($table, $sql_ary); - } - - /** - * {@inheritdoc} - */ - public function sql_affectedrows() - { - return $this->get_driver()->sql_affectedrows(); - } - - /** - * {@inheritdoc} - */ - public function sql_close() - { - return $this->get_driver()->sql_close(); - } - - /** - * {@inheritdoc} - */ - public function sql_rowseek($rownum, &$query_id) - { - return $this->get_driver()->sql_rowseek($rownum, $query_id); - } - - /** - * {@inheritdoc} - */ - public function sql_escape($msg) - { - return $this->get_driver()->sql_escape($msg); - } - - /** - * {@inheritdoc} - */ - public function sql_like_expression($expression) - { - return $this->get_driver()->sql_like_expression($expression); - } - - /** - * {@inheritdoc} - */ - public function sql_not_like_expression($expression) - { - return $this->get_driver()->sql_not_like_expression($expression); - } - - /** - * {@inheritdoc} - */ - public function sql_report($mode, $query = '') - { - return $this->get_driver()->sql_report($mode, $query); - } - - /** - * {@inheritdoc} - */ - public function sql_in_set($field, $array, $negate = false, $allow_empty_set = false) - { - return $this->get_driver()->sql_in_set($field, $array, $negate, $allow_empty_set); - } -} diff --git a/install/update/new/phpbb/db/driver/mssql_odbc.php b/install/update/new/phpbb/db/driver/mssql_odbc.php deleted file mode 100644 index 06cdce7..0000000 --- a/install/update/new/phpbb/db/driver/mssql_odbc.php +++ /dev/null @@ -1,384 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\db\driver; - -/** -* Unified ODBC functions -* Unified ODBC functions support any database having ODBC driver, for example Adabas D, IBM DB2, iODBC, Solid, Sybase SQL Anywhere... -* Here we only support MSSQL Server 2000+ because of the provided schema -* -* @note number of bytes returned for returning data depends on odbc.defaultlrl php.ini setting. -* If it is limited to 4K for example only 4K of data is returned max, resulting in incomplete theme data for example. -* @note odbc.defaultbinmode may affect UTF8 characters -*/ -class mssql_odbc extends \phpbb\db\driver\mssql_base -{ - var $last_query_text = ''; - var $connect_error = ''; - - /** - * {@inheritDoc} - */ - function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false) - { - $this->persistency = $persistency; - $this->user = $sqluser; - $this->dbname = $database; - - $port_delimiter = (defined('PHP_OS') && substr(PHP_OS, 0, 3) === 'WIN') ? ',' : ':'; - $this->server = $sqlserver . (($port) ? $port_delimiter . $port : ''); - - $max_size = @ini_get('odbc.defaultlrl'); - if (!empty($max_size)) - { - $unit = strtolower(substr($max_size, -1, 1)); - $max_size = (int) $max_size; - - if ($unit == 'k') - { - $max_size = floor($max_size / 1024); - } - else if ($unit == 'g') - { - $max_size *= 1024; - } - else if (is_numeric($unit)) - { - $max_size = floor((int) ($max_size . $unit) / 1048576); - } - $max_size = max(8, $max_size) . 'M'; - - @ini_set('odbc.defaultlrl', $max_size); - } - - if ($this->persistency) - { - if (!function_exists('odbc_pconnect')) - { - $this->connect_error = 'odbc_pconnect function does not exist, is odbc extension installed?'; - return $this->sql_error(''); - } - $this->db_connect_id = @odbc_pconnect($this->server, $this->user, $sqlpassword); - } - else - { - if (!function_exists('odbc_connect')) - { - $this->connect_error = 'odbc_connect function does not exist, is odbc extension installed?'; - return $this->sql_error(''); - } - $this->db_connect_id = @odbc_connect($this->server, $this->user, $sqlpassword); - } - - return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error(''); - } - - /** - * {@inheritDoc} - */ - function sql_server_info($raw = false, $use_cache = true) - { - global $cache; - - if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('mssqlodbc_version')) === false) - { - $result_id = @odbc_exec($this->db_connect_id, "SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY('productlevel'), SERVERPROPERTY('edition')"); - - $row = false; - if ($result_id) - { - $row = odbc_fetch_array($result_id); - odbc_free_result($result_id); - } - - $this->sql_server_version = ($row) ? trim(implode(' ', $row)) : 0; - - if (!empty($cache) && $use_cache) - { - $cache->put('mssqlodbc_version', $this->sql_server_version); - } - } - - if ($raw) - { - return $this->sql_server_version; - } - - return ($this->sql_server_version) ? 'MSSQL (ODBC)
' . $this->sql_server_version : 'MSSQL (ODBC)'; - } - - /** - * SQL Transaction - * @access private - */ - function _sql_transaction($status = 'begin') - { - switch ($status) - { - case 'begin': - return @odbc_exec($this->db_connect_id, 'BEGIN TRANSACTION'); - break; - - case 'commit': - return @odbc_exec($this->db_connect_id, 'COMMIT TRANSACTION'); - break; - - case 'rollback': - return @odbc_exec($this->db_connect_id, 'ROLLBACK TRANSACTION'); - break; - } - - return true; - } - - /** - * {@inheritDoc} - */ - function sql_query($query = '', $cache_ttl = 0) - { - if ($query != '') - { - global $cache; - - if ($this->debug_sql_explain) - { - $this->sql_report('start', $query); - } - else if ($this->debug_load_time) - { - $this->curtime = microtime(true); - } - - $this->last_query_text = $query; - $this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false; - $this->sql_add_num_queries($this->query_result); - - if ($this->query_result === false) - { - if (($this->query_result = @odbc_exec($this->db_connect_id, $query)) === false) - { - $this->sql_error($query); - } - - if ($this->debug_sql_explain) - { - $this->sql_report('stop', $query); - } - else if ($this->debug_load_time) - { - $this->sql_time += microtime(true) - $this->curtime; - } - - if (!$this->query_result) - { - return false; - } - - if ($cache && $cache_ttl) - { - $this->open_queries[(int) $this->query_result] = $this->query_result; - $this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl); - } - else if (strpos($query, 'SELECT') === 0) - { - $this->open_queries[(int) $this->query_result] = $this->query_result; - } - } - else if ($this->debug_sql_explain) - { - $this->sql_report('fromcache', $query); - } - } - else - { - return false; - } - - return $this->query_result; - } - - /** - * Build LIMIT query - */ - function _sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0) - { - $this->query_result = false; - - // Since TOP is only returning a set number of rows we won't need it if total is set to 0 (return all rows) - if ($total) - { - // We need to grab the total number of rows + the offset number of rows to get the correct result - if (strpos($query, 'SELECT DISTINCT') === 0) - { - $query = 'SELECT DISTINCT TOP ' . ($total + $offset) . ' ' . substr($query, 15); - } - else - { - $query = 'SELECT TOP ' . ($total + $offset) . ' ' . substr($query, 6); - } - } - - $result = $this->sql_query($query, $cache_ttl); - - // Seek by $offset rows - if ($offset) - { - $this->sql_rowseek($offset, $result); - } - - return $result; - } - - /** - * {@inheritDoc} - */ - function sql_affectedrows() - { - return ($this->db_connect_id) ? @odbc_num_rows($this->query_result) : false; - } - - /** - * {@inheritDoc} - */ - function sql_fetchrow($query_id = false) - { - global $cache; - - if ($query_id === false) - { - $query_id = $this->query_result; - } - - if ($cache && $cache->sql_exists($query_id)) - { - return $cache->sql_fetchrow($query_id); - } - - return ($query_id) ? odbc_fetch_array($query_id) : false; - } - - /** - * {@inheritDoc} - */ - function sql_nextid() - { - $result_id = @odbc_exec($this->db_connect_id, 'SELECT @@IDENTITY'); - - if ($result_id) - { - if (odbc_fetch_array($result_id)) - { - $id = odbc_result($result_id, 1); - odbc_free_result($result_id); - return $id; - } - odbc_free_result($result_id); - } - - return false; - } - - /** - * {@inheritDoc} - */ - function sql_freeresult($query_id = false) - { - global $cache; - - if ($query_id === false) - { - $query_id = $this->query_result; - } - - if ($cache && !is_object($query_id) && $cache->sql_exists($query_id)) - { - return $cache->sql_freeresult($query_id); - } - - if (isset($this->open_queries[(int) $query_id])) - { - unset($this->open_queries[(int) $query_id]); - return odbc_free_result($query_id); - } - - return false; - } - - /** - * return sql error array - * @access private - */ - function _sql_error() - { - if (function_exists('odbc_errormsg')) - { - $error = array( - 'message' => @odbc_errormsg(), - 'code' => @odbc_error(), - ); - } - else - { - $error = array( - 'message' => $this->connect_error, - 'code' => '', - ); - } - - return $error; - } - - /** - * Close sql connection - * @access private - */ - function _sql_close() - { - return @odbc_close($this->db_connect_id); - } - - /** - * Build db-specific report - * @access private - */ - function _sql_report($mode, $query = '') - { - switch ($mode) - { - case 'start': - break; - - case 'fromcache': - $endtime = explode(' ', microtime()); - $endtime = $endtime[0] + $endtime[1]; - - $result = @odbc_exec($this->db_connect_id, $query); - if ($result) - { - while ($void = odbc_fetch_array($result)) - { - // Take the time spent on parsing rows into account - } - odbc_free_result($result); - } - - $splittime = explode(' ', microtime()); - $splittime = $splittime[0] + $splittime[1]; - - $this->sql_report('record_fromcache', $query, $endtime, $splittime); - - break; - } - } -} diff --git a/install/update/new/phpbb/db/driver/mssqlnative.php b/install/update/new/phpbb/db/driver/mssqlnative.php deleted file mode 100644 index 30ef9d9..0000000 --- a/install/update/new/phpbb/db/driver/mssqlnative.php +++ /dev/null @@ -1,450 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* This is the MS SQL Server Native database abstraction layer. -* PHP mssql native driver required. -* @author Chris Pucci -* -*/ - -namespace phpbb\db\driver; - -class mssqlnative extends \phpbb\db\driver\mssql_base -{ - var $m_insert_id = null; - var $last_query_text = ''; - var $query_options = array(); - var $connect_error = ''; - - /** - * {@inheritDoc} - */ - function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false) - { - // Test for driver support, to avoid suppressed fatal error - if (!function_exists('sqlsrv_connect')) - { - $this->connect_error = 'Native MS SQL Server driver for PHP is missing or needs to be updated. Version 1.1 or later is required to install phpBB3. You can download the driver from: http://www.microsoft.com/sqlserver/2005/en/us/PHP-Driver.aspx'; - return $this->sql_error(''); - } - - //set up connection variables - $this->persistency = $persistency; - $this->user = $sqluser; - $this->dbname = $database; - $port_delimiter = (defined('PHP_OS') && substr(PHP_OS, 0, 3) === 'WIN') ? ',' : ':'; - $this->server = $sqlserver . (($port) ? $port_delimiter . $port : ''); - - //connect to database - $this->db_connect_id = sqlsrv_connect($this->server, array( - 'Database' => $this->dbname, - 'UID' => $this->user, - 'PWD' => $sqlpassword, - 'CharacterSet' => 'UTF-8' - )); - - return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error(''); - } - - /** - * {@inheritDoc} - */ - function sql_server_info($raw = false, $use_cache = true) - { - global $cache; - - if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('mssql_version')) === false) - { - $arr_server_info = sqlsrv_server_info($this->db_connect_id); - $this->sql_server_version = $arr_server_info['SQLServerVersion']; - - if (!empty($cache) && $use_cache) - { - $cache->put('mssql_version', $this->sql_server_version); - } - } - - if ($raw) - { - return $this->sql_server_version; - } - - return ($this->sql_server_version) ? 'MSSQL
' . $this->sql_server_version : 'MSSQL'; - } - - /** - * {@inheritDoc} - */ - function sql_buffer_nested_transactions() - { - return true; - } - - /** - * SQL Transaction - * @access private - */ - function _sql_transaction($status = 'begin') - { - switch ($status) - { - case 'begin': - return sqlsrv_begin_transaction($this->db_connect_id); - break; - - case 'commit': - return sqlsrv_commit($this->db_connect_id); - break; - - case 'rollback': - return sqlsrv_rollback($this->db_connect_id); - break; - } - return true; - } - - /** - * {@inheritDoc} - */ - function sql_query($query = '', $cache_ttl = 0) - { - if ($query != '') - { - global $cache; - - if ($this->debug_sql_explain) - { - $this->sql_report('start', $query); - } - else if ($this->debug_load_time) - { - $this->curtime = microtime(true); - } - - $this->last_query_text = $query; - $this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false; - $this->sql_add_num_queries($this->query_result); - - if ($this->query_result === false) - { - if (($this->query_result = @sqlsrv_query($this->db_connect_id, $query, array(), $this->query_options)) === false) - { - $this->sql_error($query); - } - // reset options for next query - $this->query_options = array(); - - if ($this->debug_sql_explain) - { - $this->sql_report('stop', $query); - } - else if ($this->debug_load_time) - { - $this->sql_time += microtime(true) - $this->curtime; - } - - if (!$this->query_result) - { - return false; - } - - if ($cache && $cache_ttl) - { - $this->open_queries[(int) $this->query_result] = $this->query_result; - $this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl); - } - else if (strpos($query, 'SELECT') === 0) - { - $this->open_queries[(int) $this->query_result] = $this->query_result; - } - } - else if ($this->debug_sql_explain) - { - $this->sql_report('fromcache', $query); - } - } - else - { - return false; - } - return $this->query_result; - } - - /** - * Build LIMIT query - */ - function _sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0) - { - $this->query_result = false; - - // total == 0 means all results - not zero results - if ($offset == 0 && $total !== 0) - { - if (strpos($query, "SELECT") === false) - { - $query = "TOP {$total} " . $query; - } - else - { - $query = preg_replace('/SELECT(\s*DISTINCT)?/Dsi', 'SELECT$1 TOP '.$total, $query); - } - } - else if ($offset > 0) - { - $query = preg_replace('/SELECT(\s*DISTINCT)?/Dsi', 'SELECT$1 TOP(10000000) ', $query); - $query = 'SELECT * - FROM (SELECT sub2.*, ROW_NUMBER() OVER(ORDER BY sub2.line2) AS line3 - FROM (SELECT 1 AS line2, sub1.* FROM (' . $query . ') AS sub1) as sub2) AS sub3'; - - if ($total > 0) - { - $query .= ' WHERE line3 BETWEEN ' . ($offset+1) . ' AND ' . ($offset + $total); - } - else - { - $query .= ' WHERE line3 > ' . $offset; - } - } - - $result = $this->sql_query($query, $cache_ttl); - - return $result; - } - - /** - * {@inheritDoc} - */ - function sql_affectedrows() - { - return ($this->db_connect_id) ? @sqlsrv_rows_affected($this->query_result) : false; - } - - /** - * {@inheritDoc} - */ - function sql_fetchrow($query_id = false) - { - global $cache; - - if ($query_id === false) - { - $query_id = $this->query_result; - } - - if ($cache && $cache->sql_exists($query_id)) - { - return $cache->sql_fetchrow($query_id); - } - - if (!$query_id) - { - return false; - } - - $row = sqlsrv_fetch_array($query_id, SQLSRV_FETCH_ASSOC); - - if ($row) - { - foreach ($row as $key => $value) - { - $row[$key] = ($value === ' ' || $value === null) ? '' : $value; - } - - // remove helper values from LIMIT queries - if (isset($row['line2'])) - { - unset($row['line2'], $row['line3']); - } - } - return ($row !== null) ? $row : false; - } - - /** - * {@inheritDoc} - */ - function sql_nextid() - { - $result_id = @sqlsrv_query($this->db_connect_id, 'SELECT @@IDENTITY'); - - if ($result_id) - { - $row = sqlsrv_fetch_array($result_id); - $id = $row[0]; - sqlsrv_free_stmt($result_id); - return $id; - } - else - { - return false; - } - } - - /** - * {@inheritDoc} - */ - function sql_freeresult($query_id = false) - { - global $cache; - - if ($query_id === false) - { - $query_id = $this->query_result; - } - - if ($cache && !is_object($query_id) && $cache->sql_exists($query_id)) - { - return $cache->sql_freeresult($query_id); - } - - if (isset($this->open_queries[(int) $query_id])) - { - unset($this->open_queries[(int) $query_id]); - return sqlsrv_free_stmt($query_id); - } - - return false; - } - - /** - * return sql error array - * @access private - */ - function _sql_error() - { - if (function_exists('sqlsrv_errors')) - { - $errors = @sqlsrv_errors(SQLSRV_ERR_ERRORS); - $error_message = ''; - $code = 0; - - if ($errors != null) - { - foreach ($errors as $error) - { - $error_message .= "SQLSTATE: " . $error['SQLSTATE'] . "\n"; - $error_message .= "code: " . $error['code'] . "\n"; - $code = $error['code']; - $error_message .= "message: " . $error['message'] . "\n"; - } - $this->last_error_result = $error_message; - $error = $this->last_error_result; - } - else - { - $error = (isset($this->last_error_result) && $this->last_error_result) ? $this->last_error_result : array(); - } - - $error = array( - 'message' => $error, - 'code' => $code, - ); - } - else - { - $error = array( - 'message' => $this->connect_error, - 'code' => '', - ); - } - - return $error; - } - - /** - * Close sql connection - * @access private - */ - function _sql_close() - { - return @sqlsrv_close($this->db_connect_id); - } - - /** - * Build db-specific report - * @access private - */ - function _sql_report($mode, $query = '') - { - switch ($mode) - { - case 'start': - $html_table = false; - @sqlsrv_query($this->db_connect_id, 'SET SHOWPLAN_TEXT ON;'); - if ($result = @sqlsrv_query($this->db_connect_id, $query)) - { - sqlsrv_next_result($result); - while ($row = sqlsrv_fetch_array($result)) - { - $html_table = $this->sql_report('add_select_row', $query, $html_table, $row); - } - sqlsrv_free_stmt($result); - } - @sqlsrv_query($this->db_connect_id, 'SET SHOWPLAN_TEXT OFF;'); - - if ($html_table) - { - $this->html_hold .= ''; - } - break; - - case 'fromcache': - $endtime = explode(' ', microtime()); - $endtime = $endtime[0] + $endtime[1]; - - $result = @sqlsrv_query($this->db_connect_id, $query); - if ($result) - { - while ($void = sqlsrv_fetch_array($result)) - { - // Take the time spent on parsing rows into account - } - sqlsrv_free_stmt($result); - } - - $splittime = explode(' ', microtime()); - $splittime = $splittime[0] + $splittime[1]; - - $this->sql_report('record_fromcache', $query, $endtime, $splittime); - - break; - } - } - - /** - * Utility method used to retrieve number of rows - * Emulates mysql_num_rows - * Used in acp_database.php -> write_data_mssqlnative() - * Requires a static or keyset cursor to be definde via - * mssqlnative_set_query_options() - */ - function mssqlnative_num_rows($res) - { - if ($res !== false) - { - return sqlsrv_num_rows($res); - } - else - { - return false; - } - } - - /** - * Allows setting mssqlnative specific query options passed to sqlsrv_query as 4th parameter. - */ - function mssqlnative_set_query_options($options) - { - $this->query_options = $options; - } -} diff --git a/install/update/new/phpbb/db/driver/mysqli.php b/install/update/new/phpbb/db/driver/mysqli.php deleted file mode 100644 index 0c1c063..0000000 --- a/install/update/new/phpbb/db/driver/mysqli.php +++ /dev/null @@ -1,492 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\db\driver; - -/** -* MySQLi Database Abstraction Layer -* mysqli-extension has to be compiled with: -* MySQL 4.1+ or MySQL 5.0+ -*/ -class mysqli extends \phpbb\db\driver\mysql_base -{ - var $multi_insert = true; - var $connect_error = ''; - - /** - * {@inheritDoc} - */ - function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false) - { - if (!function_exists('mysqli_connect')) - { - $this->connect_error = 'mysqli_connect function does not exist, is mysqli extension installed?'; - return $this->sql_error(''); - } - - $this->persistency = $persistency; - $this->user = $sqluser; - - // If persistent connection, set dbhost to localhost when empty and prepend it with 'p:' prefix - $this->server = ($this->persistency) ? 'p:' . (($sqlserver) ? $sqlserver : 'localhost') : $sqlserver; - - $this->dbname = $database; - $port = (!$port) ? null : $port; - - // If port is set and it is not numeric, most likely mysqli socket is set. - // Try to map it to the $socket parameter. - $socket = null; - if ($port) - { - if (is_numeric($port)) - { - $port = (int) $port; - } - else - { - $socket = $port; - $port = null; - } - } - - $this->db_connect_id = mysqli_init(); - - if (!@mysqli_real_connect($this->db_connect_id, $this->server, $this->user, $sqlpassword, $this->dbname, $port, $socket, MYSQLI_CLIENT_FOUND_ROWS)) - { - $this->db_connect_id = ''; - } - - if ($this->db_connect_id && $this->dbname != '') - { - // Disable loading local files on client side - @mysqli_options($this->db_connect_id, MYSQLI_OPT_LOCAL_INFILE, false); - - @mysqli_query($this->db_connect_id, "SET NAMES 'utf8'"); - - // enforce strict mode on databases that support it - if (version_compare($this->sql_server_info(true), '5.0.2', '>=')) - { - $result = @mysqli_query($this->db_connect_id, 'SELECT @@session.sql_mode AS sql_mode'); - if ($result) - { - $row = mysqli_fetch_assoc($result); - mysqli_free_result($result); - - $modes = array_map('trim', explode(',', $row['sql_mode'])); - } - else - { - $modes = array(); - } - - // TRADITIONAL includes STRICT_ALL_TABLES and STRICT_TRANS_TABLES - if (!in_array('TRADITIONAL', $modes)) - { - if (!in_array('STRICT_ALL_TABLES', $modes)) - { - $modes[] = 'STRICT_ALL_TABLES'; - } - - if (!in_array('STRICT_TRANS_TABLES', $modes)) - { - $modes[] = 'STRICT_TRANS_TABLES'; - } - } - - $mode = implode(',', $modes); - @mysqli_query($this->db_connect_id, "SET SESSION sql_mode='{$mode}'"); - } - return $this->db_connect_id; - } - - return $this->sql_error(''); - } - - /** - * {@inheritDoc} - */ - function sql_server_info($raw = false, $use_cache = true) - { - global $cache; - - if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('mysqli_version')) === false) - { - $result = @mysqli_query($this->db_connect_id, 'SELECT VERSION() AS version'); - if ($result) - { - $row = mysqli_fetch_assoc($result); - mysqli_free_result($result); - - $this->sql_server_version = $row['version']; - - if (!empty($cache) && $use_cache) - { - $cache->put('mysqli_version', $this->sql_server_version); - } - } - } - - return ($raw) ? $this->sql_server_version : 'MySQL(i) ' . $this->sql_server_version; - } - - /** - * SQL Transaction - * @access private - */ - function _sql_transaction($status = 'begin') - { - switch ($status) - { - case 'begin': - return @mysqli_autocommit($this->db_connect_id, false); - break; - - case 'commit': - $result = @mysqli_commit($this->db_connect_id); - @mysqli_autocommit($this->db_connect_id, true); - return $result; - break; - - case 'rollback': - $result = @mysqli_rollback($this->db_connect_id); - @mysqli_autocommit($this->db_connect_id, true); - return $result; - break; - } - - return true; - } - - /** - * {@inheritDoc} - */ - function sql_query($query = '', $cache_ttl = 0) - { - if ($query != '') - { - global $cache; - - if ($this->debug_sql_explain) - { - $this->sql_report('start', $query); - } - else if ($this->debug_load_time) - { - $this->curtime = microtime(true); - } - - $this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false; - $this->sql_add_num_queries($this->query_result); - - if ($this->query_result === false) - { - if (($this->query_result = @mysqli_query($this->db_connect_id, $query)) === false) - { - $this->sql_error($query); - } - - if ($this->debug_sql_explain) - { - $this->sql_report('stop', $query); - } - else if ($this->debug_load_time) - { - $this->sql_time += microtime(true) - $this->curtime; - } - - if (!$this->query_result) - { - return false; - } - - if ($cache && $cache_ttl) - { - $this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl); - } - } - else if ($this->debug_sql_explain) - { - $this->sql_report('fromcache', $query); - } - } - else - { - return false; - } - - return $this->query_result; - } - - /** - * {@inheritDoc} - */ - function sql_affectedrows() - { - return ($this->db_connect_id) ? @mysqli_affected_rows($this->db_connect_id) : false; - } - - /** - * {@inheritDoc} - */ - function sql_fetchrow($query_id = false) - { - global $cache; - - if ($query_id === false) - { - $query_id = $this->query_result; - } - - if ($cache && !is_object($query_id) && $cache->sql_exists($query_id)) - { - return $cache->sql_fetchrow($query_id); - } - - if ($query_id) - { - $result = mysqli_fetch_assoc($query_id); - return $result !== null ? $result : false; - } - - return false; - } - - /** - * {@inheritDoc} - */ - function sql_rowseek($rownum, &$query_id) - { - global $cache; - - if ($query_id === false) - { - $query_id = $this->query_result; - } - - if ($cache && !is_object($query_id) && $cache->sql_exists($query_id)) - { - return $cache->sql_rowseek($rownum, $query_id); - } - - return ($query_id) ? @mysqli_data_seek($query_id, $rownum) : false; - } - - /** - * {@inheritDoc} - */ - function sql_nextid() - { - return ($this->db_connect_id) ? @mysqli_insert_id($this->db_connect_id) : false; - } - - /** - * {@inheritDoc} - */ - function sql_freeresult($query_id = false) - { - global $cache; - - if ($query_id === false) - { - $query_id = $this->query_result; - } - - if ($cache && !is_object($query_id) && $cache->sql_exists($query_id)) - { - return $cache->sql_freeresult($query_id); - } - - if (!$query_id) - { - return false; - } - - if ($query_id === true) - { - return true; - } - - return mysqli_free_result($query_id); - } - - /** - * {@inheritDoc} - */ - function sql_escape($msg) - { - return @mysqli_real_escape_string($this->db_connect_id, $msg); - } - - /** - * return sql error array - * @access private - */ - function _sql_error() - { - if ($this->db_connect_id) - { - $error = array( - 'message' => @mysqli_error($this->db_connect_id), - 'code' => @mysqli_errno($this->db_connect_id) - ); - } - else if (function_exists('mysqli_connect_error')) - { - $error = array( - 'message' => @mysqli_connect_error(), - 'code' => @mysqli_connect_errno(), - ); - } - else - { - $error = array( - 'message' => $this->connect_error, - 'code' => '', - ); - } - - return $error; - } - - /** - * Close sql connection - * @access private - */ - function _sql_close() - { - return @mysqli_close($this->db_connect_id); - } - - /** - * Build db-specific report - * @access private - */ - function _sql_report($mode, $query = '') - { - static $test_prof; - - // current detection method, might just switch to see the existence of INFORMATION_SCHEMA.PROFILING - if ($test_prof === null) - { - $test_prof = false; - if (strpos(mysqli_get_server_info($this->db_connect_id), 'community') !== false) - { - $ver = mysqli_get_server_version($this->db_connect_id); - if ($ver >= 50037 && $ver < 50100) - { - $test_prof = true; - } - } - } - - switch ($mode) - { - case 'start': - - $explain_query = $query; - if (preg_match('/UPDATE ([a-z0-9_]+).*?WHERE(.*)/s', $query, $m)) - { - $explain_query = 'SELECT * FROM ' . $m[1] . ' WHERE ' . $m[2]; - } - else if (preg_match('/DELETE FROM ([a-z0-9_]+).*?WHERE(.*)/s', $query, $m)) - { - $explain_query = 'SELECT * FROM ' . $m[1] . ' WHERE ' . $m[2]; - } - - if (preg_match('/^SELECT/', $explain_query)) - { - $html_table = false; - - // begin profiling - if ($test_prof) - { - @mysqli_query($this->db_connect_id, 'SET profiling = 1;'); - } - - if ($result = @mysqli_query($this->db_connect_id, "EXPLAIN $explain_query")) - { - while ($row = mysqli_fetch_assoc($result)) - { - $html_table = $this->sql_report('add_select_row', $query, $html_table, $row); - } - mysqli_free_result($result); - } - - if ($html_table) - { - $this->html_hold .= ''; - } - - if ($test_prof) - { - $html_table = false; - - // get the last profile - if ($result = @mysqli_query($this->db_connect_id, 'SHOW PROFILE ALL;')) - { - $this->html_hold .= '
'; - while ($row = mysqli_fetch_assoc($result)) - { - // make HTML safe - if (!empty($row['Source_function'])) - { - $row['Source_function'] = str_replace(array('<', '>'), array('<', '>'), $row['Source_function']); - } - - // remove unsupported features - foreach ($row as $key => $val) - { - if ($val === null) - { - unset($row[$key]); - } - } - $html_table = $this->sql_report('add_select_row', $query, $html_table, $row); - } - mysqli_free_result($result); - } - - if ($html_table) - { - $this->html_hold .= ''; - } - - @mysqli_query($this->db_connect_id, 'SET profiling = 0;'); - } - } - - break; - - case 'fromcache': - $endtime = explode(' ', microtime()); - $endtime = $endtime[0] + $endtime[1]; - - $result = @mysqli_query($this->db_connect_id, $query); - if ($result) - { - while ($void = mysqli_fetch_assoc($result)) - { - // Take the time spent on parsing rows into account - } - mysqli_free_result($result); - } - - $splittime = explode(' ', microtime()); - $splittime = $splittime[0] + $splittime[1]; - - $this->sql_report('record_fromcache', $query, $endtime, $splittime); - - break; - } - } -} diff --git a/install/update/new/phpbb/db/driver/oracle.php b/install/update/new/phpbb/db/driver/oracle.php deleted file mode 100644 index f2a0bb5..0000000 --- a/install/update/new/phpbb/db/driver/oracle.php +++ /dev/null @@ -1,821 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\db\driver; - -/** -* Oracle Database Abstraction Layer -*/ -class oracle extends \phpbb\db\driver\driver -{ - var $last_query_text = ''; - var $connect_error = ''; - - /** - * {@inheritDoc} - */ - function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false) - { - $this->persistency = $persistency; - $this->user = $sqluser; - $this->server = $sqlserver . (($port) ? ':' . $port : ''); - $this->dbname = $database; - - $connect = $database; - - // support for "easy connect naming" - if ($sqlserver !== '' && $sqlserver !== '/') - { - if (substr($sqlserver, -1, 1) == '/') - { - $sqlserver == substr($sqlserver, 0, -1); - } - $connect = $sqlserver . (($port) ? ':' . $port : '') . '/' . $database; - } - - if ($new_link) - { - if (!function_exists('ocinlogon')) - { - $this->connect_error = 'ocinlogon function does not exist, is oci extension installed?'; - return $this->sql_error(''); - } - $this->db_connect_id = @ocinlogon($this->user, $sqlpassword, $connect, 'UTF8'); - } - else if ($this->persistency) - { - if (!function_exists('ociplogon')) - { - $this->connect_error = 'ociplogon function does not exist, is oci extension installed?'; - return $this->sql_error(''); - } - $this->db_connect_id = @ociplogon($this->user, $sqlpassword, $connect, 'UTF8'); - } - else - { - if (!function_exists('ocilogon')) - { - $this->connect_error = 'ocilogon function does not exist, is oci extension installed?'; - return $this->sql_error(''); - } - $this->db_connect_id = @ocilogon($this->user, $sqlpassword, $connect, 'UTF8'); - } - - return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error(''); - } - - /** - * {@inheritDoc} - */ - function sql_server_info($raw = false, $use_cache = true) - { - /** - * force $use_cache false. I didn't research why the caching code below is commented out - * but I assume its because the Oracle extension provides a direct method to access it - * without a query. - */ -/* - global $cache; - - if (empty($cache) || ($this->sql_server_version = $cache->get('oracle_version')) === false) - { - $result = @ociparse($this->db_connect_id, 'SELECT * FROM v$version WHERE banner LIKE \'Oracle%\''); - @ociexecute($result, OCI_DEFAULT); - @ocicommit($this->db_connect_id); - - $row = array(); - @ocifetchinto($result, $row, OCI_ASSOC + OCI_RETURN_NULLS); - @ocifreestatement($result); - $this->sql_server_version = trim($row['BANNER']); - - $cache->put('oracle_version', $this->sql_server_version); - } -*/ - $this->sql_server_version = @ociserverversion($this->db_connect_id); - - return $this->sql_server_version; - } - - /** - * SQL Transaction - * @access private - */ - function _sql_transaction($status = 'begin') - { - switch ($status) - { - case 'begin': - return true; - break; - - case 'commit': - return @ocicommit($this->db_connect_id); - break; - - case 'rollback': - return @ocirollback($this->db_connect_id); - break; - } - - return true; - } - - /** - * Oracle specific code to handle the fact that it does not compare columns properly - * @access private - */ - function _rewrite_col_compare($args) - { - if (count($args) == 4) - { - if ($args[2] == '=') - { - return '(' . $args[0] . ' OR (' . $args[1] . ' is NULL AND ' . $args[3] . ' is NULL))'; - } - else if ($args[2] == '<>') - { - // really just a fancy way of saying foo <> bar or (foo is NULL XOR bar is NULL) but SQL has no XOR :P - return '(' . $args[0] . ' OR ((' . $args[1] . ' is NULL AND ' . $args[3] . ' is NOT NULL) OR (' . $args[1] . ' is NOT NULL AND ' . $args[3] . ' is NULL)))'; - } - } - else - { - return $this->_rewrite_where($args[0]); - } - } - - /** - * Oracle specific code to handle it's lack of sanity - * @access private - */ - function _rewrite_where($where_clause) - { - preg_match_all('/\s*(AND|OR)?\s*([\w_.()]++)\s*(?:(=|<[=>]?|>=?|LIKE)\s*((?>\'(?>[^\']++|\'\')*+\'|[\d-.()]+))|((NOT )?IN\s*\((?>\'(?>[^\']++|\'\')*+\',? ?|[\d-.]+,? ?)*+\)))/', $where_clause, $result, PREG_SET_ORDER); - $out = ''; - foreach ($result as $val) - { - if (!isset($val[5])) - { - if ($val[4] !== "''") - { - $out .= $val[0]; - } - else - { - $out .= ' ' . $val[1] . ' ' . $val[2]; - if ($val[3] == '=') - { - $out .= ' is NULL'; - } - else if ($val[3] == '<>') - { - $out .= ' is NOT NULL'; - } - } - } - else - { - $in_clause = array(); - $sub_exp = substr($val[5], strpos($val[5], '(') + 1, -1); - $extra = false; - preg_match_all('/\'(?>[^\']++|\'\')*+\'|[\d-.]++/', $sub_exp, $sub_vals, PREG_PATTERN_ORDER); - $i = 0; - foreach ($sub_vals[0] as $sub_val) - { - // two things: - // 1) This determines if an empty string was in the IN clausing, making us turn it into a NULL comparison - // 2) This fixes the 1000 list limit that Oracle has (ORA-01795) - if ($sub_val !== "''") - { - $in_clause[(int) $i++/1000][] = $sub_val; - } - else - { - $extra = true; - } - } - if (!$extra && $i < 1000) - { - $out .= $val[0]; - } - else - { - $out .= ' ' . $val[1] . '('; - $in_array = array(); - - // constuct each IN() clause - foreach ($in_clause as $in_values) - { - $in_array[] = $val[2] . ' ' . (isset($val[6]) ? $val[6] : '') . 'IN(' . implode(', ', $in_values) . ')'; - } - - // Join the IN() clauses against a few ORs (IN is just a nicer OR anyway) - $out .= implode(' OR ', $in_array); - - // handle the empty string case - if ($extra) - { - $out .= ' OR ' . $val[2] . ' is ' . (isset($val[6]) ? $val[6] : '') . 'NULL'; - } - $out .= ')'; - - unset($in_array, $in_clause); - } - } - } - - return $out; - } - - /** - * {@inheritDoc} - */ - function sql_query($query = '', $cache_ttl = 0) - { - if ($query != '') - { - global $cache; - - if ($this->debug_sql_explain) - { - $this->sql_report('start', $query); - } - else if ($this->debug_load_time) - { - $this->curtime = microtime(true); - } - - $this->last_query_text = $query; - $this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false; - $this->sql_add_num_queries($this->query_result); - - if ($this->query_result === false) - { - $in_transaction = false; - if (!$this->transaction) - { - $this->sql_transaction('begin'); - } - else - { - $in_transaction = true; - } - - $array = array(); - - // We overcome Oracle's 4000 char limit by binding vars - if (strlen($query) > 4000) - { - if (preg_match('/^(INSERT INTO[^(]++)\\(([^()]+)\\) VALUES[^(]++\\((.*?)\\)$/sU', $query, $regs)) - { - if (strlen($regs[3]) > 4000) - { - $cols = explode(', ', $regs[2]); - - preg_match_all('/\'(?:[^\']++|\'\')*+\'|[\d-.]+/', $regs[3], $vals, PREG_PATTERN_ORDER); - -/* The code inside this comment block breaks clob handling, but does allow the - database restore script to work. If you want to allow no posts longer than 4KB - and/or need the db restore script, uncomment this. - - - if (count($cols) !== count($vals)) - { - // Try to replace some common data we know is from our restore script or from other sources - $regs[3] = str_replace("'||chr(47)||'", '/', $regs[3]); - $_vals = explode(', ', $regs[3]); - - $vals = array(); - $is_in_val = false; - $i = 0; - $string = ''; - - foreach ($_vals as $value) - { - if (strpos($value, "'") === false && !$is_in_val) - { - $vals[$i++] = $value; - continue; - } - - if (substr($value, -1) === "'") - { - $vals[$i] = $string . (($is_in_val) ? ', ' : '') . $value; - $string = ''; - $is_in_val = false; - - if ($vals[$i][0] !== "'") - { - $vals[$i] = "''" . $vals[$i]; - } - $i++; - continue; - } - else - { - $string .= (($is_in_val) ? ', ' : '') . $value; - $is_in_val = true; - } - } - - if ($string) - { - // New value if cols != value - $vals[(count($cols) !== count($vals)) ? $i : $i - 1] .= $string; - } - - $vals = array(0 => $vals); - } -*/ - - $inserts = $vals[0]; - unset($vals); - - foreach ($inserts as $key => $value) - { - if (!empty($value) && $value[0] === "'" && strlen($value) > 4002) // check to see if this thing is greater than the max + 'x2 - { - $inserts[$key] = ':' . strtoupper($cols[$key]); - $array[$inserts[$key]] = str_replace("''", "'", substr($value, 1, -1)); - } - } - - $query = $regs[1] . '(' . $regs[2] . ') VALUES (' . implode(', ', $inserts) . ')'; - } - } - else if (preg_match_all('/^(UPDATE [\\w_]++\\s+SET )([\\w_]++\\s*=\\s*(?:\'(?:[^\']++|\'\')*+\'|[\d-.]+)(?:,\\s*[\\w_]++\\s*=\\s*(?:\'(?:[^\']++|\'\')*+\'|[\d-.]+))*+)\\s+(WHERE.*)$/s', $query, $data, PREG_SET_ORDER)) - { - if (strlen($data[0][2]) > 4000) - { - $update = $data[0][1]; - $where = $data[0][3]; - preg_match_all('/([\\w_]++)\\s*=\\s*(\'(?:[^\']++|\'\')*+\'|[\d-.]++)/', $data[0][2], $temp, PREG_SET_ORDER); - unset($data); - - $cols = array(); - foreach ($temp as $value) - { - if (!empty($value[2]) && $value[2][0] === "'" && strlen($value[2]) > 4002) // check to see if this thing is greater than the max + 'x2 - { - $cols[] = $value[1] . '=:' . strtoupper($value[1]); - $array[$value[1]] = str_replace("''", "'", substr($value[2], 1, -1)); - } - else - { - $cols[] = $value[1] . '=' . $value[2]; - } - } - - $query = $update . implode(', ', $cols) . ' ' . $where; - unset($cols); - } - } - } - - switch (substr($query, 0, 6)) - { - case 'DELETE': - if (preg_match('/^(DELETE FROM [\w_]++ WHERE)((?:\s*(?:AND|OR)?\s*[\w_]+\s*(?:(?:=|<>)\s*(?>\'(?>[^\']++|\'\')*+\'|[\d-.]+)|(?:NOT )?IN\s*\((?>\'(?>[^\']++|\'\')*+\',? ?|[\d-.]+,? ?)*+\)))*+)$/', $query, $regs)) - { - $query = $regs[1] . $this->_rewrite_where($regs[2]); - unset($regs); - } - break; - - case 'UPDATE': - if (preg_match('/^(UPDATE [\\w_]++\\s+SET [\\w_]+\s*=\s*(?:\'(?:[^\']++|\'\')*+\'|[\d-.]++|:\w++)(?:, [\\w_]+\s*=\s*(?:\'(?:[^\']++|\'\')*+\'|[\d-.]++|:\w++))*+\\s+WHERE)(.*)$/s', $query, $regs)) - { - $query = $regs[1] . $this->_rewrite_where($regs[2]); - unset($regs); - } - break; - - case 'SELECT': - $query = preg_replace_callback('/([\w_.]++)\s*(?:(=|<>)\s*(?>\'(?>[^\']++|\'\')*+\'|[\d-.]++|([\w_.]++))|(?:NOT )?IN\s*\((?>\'(?>[^\']++|\'\')*+\',? ?|[\d-.]++,? ?)*+\))/', array($this, '_rewrite_col_compare'), $query); - break; - } - - $this->query_result = @ociparse($this->db_connect_id, $query); - - foreach ($array as $key => $value) - { - @ocibindbyname($this->query_result, $key, $array[$key], -1); - } - - $success = @ociexecute($this->query_result, OCI_DEFAULT); - - if (!$success) - { - $this->sql_error($query); - $this->query_result = false; - } - else - { - if (!$in_transaction) - { - $this->sql_transaction('commit'); - } - } - - if ($this->debug_sql_explain) - { - $this->sql_report('stop', $query); - } - else if ($this->debug_load_time) - { - $this->sql_time += microtime(true) - $this->curtime; - } - - if (!$this->query_result) - { - return false; - } - - if ($cache && $cache_ttl) - { - $this->open_queries[(int) $this->query_result] = $this->query_result; - $this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl); - } - else if (strpos($query, 'SELECT') === 0) - { - $this->open_queries[(int) $this->query_result] = $this->query_result; - } - } - else if ($this->debug_sql_explain) - { - $this->sql_report('fromcache', $query); - } - } - else - { - return false; - } - - return $this->query_result; - } - - /** - * Build LIMIT query - */ - function _sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0) - { - $this->query_result = false; - - $query = 'SELECT * FROM (SELECT /*+ FIRST_ROWS */ rownum AS xrownum, a.* FROM (' . $query . ') a WHERE rownum <= ' . ($offset + $total) . ') WHERE xrownum >= ' . $offset; - - return $this->sql_query($query, $cache_ttl); - } - - /** - * {@inheritDoc} - */ - function sql_affectedrows() - { - return ($this->query_result) ? @ocirowcount($this->query_result) : false; - } - - /** - * {@inheritDoc} - */ - function sql_fetchrow($query_id = false) - { - global $cache; - - if ($query_id === false) - { - $query_id = $this->query_result; - } - - if ($cache && $cache->sql_exists($query_id)) - { - return $cache->sql_fetchrow($query_id); - } - - if ($query_id) - { - $row = array(); - $result = ocifetchinto($query_id, $row, OCI_ASSOC + OCI_RETURN_NULLS); - - if (!$result || !$row) - { - return false; - } - - $result_row = array(); - foreach ($row as $key => $value) - { - // Oracle treats empty strings as null - if (is_null($value)) - { - $value = ''; - } - - // OCI->CLOB? - if (is_object($value)) - { - $value = $value->load(); - } - - $result_row[strtolower($key)] = $value; - } - - return $result_row; - } - - return false; - } - - /** - * {@inheritDoc} - */ - function sql_rowseek($rownum, &$query_id) - { - global $cache; - - if ($query_id === false) - { - $query_id = $this->query_result; - } - - if ($cache && $cache->sql_exists($query_id)) - { - return $cache->sql_rowseek($rownum, $query_id); - } - - if (!$query_id) - { - return false; - } - - // Reset internal pointer - @ociexecute($query_id, OCI_DEFAULT); - - // We do not fetch the row for rownum == 0 because then the next resultset would be the second row - for ($i = 0; $i < $rownum; $i++) - { - if (!$this->sql_fetchrow($query_id)) - { - return false; - } - } - - return true; - } - - /** - * {@inheritDoc} - */ - function sql_nextid() - { - $query_id = $this->query_result; - - if ($query_id !== false && $this->last_query_text != '') - { - if (preg_match('#^INSERT[\t\n ]+INTO[\t\n ]+([a-z0-9\_\-]+)#is', $this->last_query_text, $tablename)) - { - $query = 'SELECT ' . $tablename[1] . '_seq.currval FROM DUAL'; - $stmt = @ociparse($this->db_connect_id, $query); - if ($stmt) - { - $success = @ociexecute($stmt, OCI_DEFAULT); - - if ($success) - { - $temp_result = ocifetchinto($stmt, $temp_array, OCI_ASSOC + OCI_RETURN_NULLS); - ocifreestatement($stmt); - - if ($temp_result) - { - return $temp_array['CURRVAL']; - } - else - { - return false; - } - } - } - } - } - - return false; - } - - /** - * {@inheritDoc} - */ - function sql_freeresult($query_id = false) - { - global $cache; - - if ($query_id === false) - { - $query_id = $this->query_result; - } - - if ($cache && !is_object($query_id) && $cache->sql_exists($query_id)) - { - return $cache->sql_freeresult($query_id); - } - - if (isset($this->open_queries[(int) $query_id])) - { - unset($this->open_queries[(int) $query_id]); - return ocifreestatement($query_id); - } - - return false; - } - - /** - * {@inheritDoc} - */ - function sql_escape($msg) - { - return str_replace(array("'", "\0"), array("''", ''), $msg); - } - - /** - * Build LIKE expression - * @access private - */ - function _sql_like_expression($expression) - { - return $expression . " ESCAPE '\\'"; - } - - /** - * Build NOT LIKE expression - * @access private - */ - function _sql_not_like_expression($expression) - { - return $expression . " ESCAPE '\\'"; - } - - function _sql_custom_build($stage, $data) - { - return $data; - } - - function _sql_bit_and($column_name, $bit, $compare = '') - { - return 'BITAND(' . $column_name . ', ' . (1 << $bit) . ')' . (($compare) ? ' ' . $compare : ''); - } - - function _sql_bit_or($column_name, $bit, $compare = '') - { - return 'BITOR(' . $column_name . ', ' . (1 << $bit) . ')' . (($compare) ? ' ' . $compare : ''); - } - - /** - * return sql error array - * @access private - */ - function _sql_error() - { - if (function_exists('ocierror')) - { - $error = @ocierror(); - $error = (!$error) ? @ocierror($this->query_result) : $error; - $error = (!$error) ? @ocierror($this->db_connect_id) : $error; - - if ($error) - { - $this->last_error_result = $error; - } - else - { - $error = (isset($this->last_error_result) && $this->last_error_result) ? $this->last_error_result : array(); - } - } - else - { - $error = array( - 'message' => $this->connect_error, - 'code' => '', - ); - } - - return $error; - } - - /** - * Close sql connection - * @access private - */ - function _sql_close() - { - return @ocilogoff($this->db_connect_id); - } - - /** - * Build db-specific report - * @access private - */ - function _sql_report($mode, $query = '') - { - switch ($mode) - { - case 'start': - - $html_table = false; - - // Grab a plan table, any will do - $sql = "SELECT table_name - FROM USER_TABLES - WHERE table_name LIKE '%PLAN_TABLE%'"; - $stmt = ociparse($this->db_connect_id, $sql); - ociexecute($stmt); - $result = array(); - - if (ocifetchinto($stmt, $result, OCI_ASSOC + OCI_RETURN_NULLS)) - { - $table = $result['TABLE_NAME']; - - // This is the statement_id that will allow us to track the plan - $statement_id = substr(md5($query), 0, 30); - - // Remove any stale plans - $stmt2 = ociparse($this->db_connect_id, "DELETE FROM $table WHERE statement_id='$statement_id'"); - ociexecute($stmt2); - ocifreestatement($stmt2); - - // Explain the plan - $sql = "EXPLAIN PLAN - SET STATEMENT_ID = '$statement_id' - FOR $query"; - $stmt2 = ociparse($this->db_connect_id, $sql); - ociexecute($stmt2); - ocifreestatement($stmt2); - - // Get the data from the plan - $sql = "SELECT operation, options, object_name, object_type, cardinality, cost - FROM plan_table - START WITH id = 0 AND statement_id = '$statement_id' - CONNECT BY PRIOR id = parent_id - AND statement_id = '$statement_id'"; - $stmt2 = ociparse($this->db_connect_id, $sql); - ociexecute($stmt2); - - $row = array(); - while (ocifetchinto($stmt2, $row, OCI_ASSOC + OCI_RETURN_NULLS)) - { - $html_table = $this->sql_report('add_select_row', $query, $html_table, $row); - } - - ocifreestatement($stmt2); - - // Remove the plan we just made, we delete them on request anyway - $stmt2 = ociparse($this->db_connect_id, "DELETE FROM $table WHERE statement_id='$statement_id'"); - ociexecute($stmt2); - ocifreestatement($stmt2); - } - - ocifreestatement($stmt); - - if ($html_table) - { - $this->html_hold .= ''; - } - - break; - - case 'fromcache': - $endtime = explode(' ', microtime()); - $endtime = $endtime[0] + $endtime[1]; - - $result = @ociparse($this->db_connect_id, $query); - if ($result) - { - $success = @ociexecute($result, OCI_DEFAULT); - if ($success) - { - $row = array(); - - while (ocifetchinto($result, $row, OCI_ASSOC + OCI_RETURN_NULLS)) - { - // Take the time spent on parsing rows into account - } - @ocifreestatement($result); - } - } - - $splittime = explode(' ', microtime()); - $splittime = $splittime[0] + $splittime[1]; - - $this->sql_report('record_fromcache', $query, $endtime, $splittime); - - break; - } - } -} diff --git a/install/update/new/phpbb/db/driver/postgres.php b/install/update/new/phpbb/db/driver/postgres.php deleted file mode 100644 index ed330bc..0000000 --- a/install/update/new/phpbb/db/driver/postgres.php +++ /dev/null @@ -1,500 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\db\driver; - -/** -* PostgreSQL Database Abstraction Layer -* Minimum Requirement is Version 8.3+ -*/ -class postgres extends \phpbb\db\driver\driver -{ - var $multi_insert = true; - var $last_query_text = ''; - var $connect_error = ''; - - /** - * {@inheritDoc} - */ - function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false) - { - $connect_string = ''; - - if ($sqluser) - { - $connect_string .= "user=$sqluser "; - } - - if ($sqlpassword) - { - $connect_string .= "password=$sqlpassword "; - } - - if ($sqlserver) - { - // $sqlserver can carry a port separated by : for compatibility reasons - // If $sqlserver has more than one : it's probably an IPv6 address. - // In this case we only allow passing a port via the $port variable. - if (substr_count($sqlserver, ':') === 1) - { - list($sqlserver, $port) = explode(':', $sqlserver); - } - - if ($sqlserver !== 'localhost') - { - $connect_string .= "host=$sqlserver "; - } - - if ($port) - { - $connect_string .= "port=$port "; - } - } - - $schema = ''; - - if ($database) - { - $this->dbname = $database; - if (strpos($database, '.') !== false) - { - list($database, $schema) = explode('.', $database); - } - $connect_string .= "dbname=$database"; - } - - $this->persistency = $persistency; - - if ($this->persistency) - { - if (!function_exists('pg_pconnect')) - { - $this->connect_error = 'pg_pconnect function does not exist, is pgsql extension installed?'; - return $this->sql_error(''); - } - $collector = new \phpbb\error_collector; - $collector->install(); - $this->db_connect_id = (!$new_link) ? @pg_pconnect($connect_string) : @pg_pconnect($connect_string, PGSQL_CONNECT_FORCE_NEW); - } - else - { - if (!function_exists('pg_connect')) - { - $this->connect_error = 'pg_connect function does not exist, is pgsql extension installed?'; - return $this->sql_error(''); - } - $collector = new \phpbb\error_collector; - $collector->install(); - $this->db_connect_id = (!$new_link) ? @pg_connect($connect_string) : @pg_connect($connect_string, PGSQL_CONNECT_FORCE_NEW); - } - - $collector->uninstall(); - - if ($this->db_connect_id) - { - if ($schema !== '') - { - @pg_query($this->db_connect_id, 'SET search_path TO ' . $schema); - } - return $this->db_connect_id; - } - - $this->connect_error = $collector->format_errors(); - return $this->sql_error(''); - } - - /** - * {@inheritDoc} - */ - function sql_server_info($raw = false, $use_cache = true) - { - global $cache; - - if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('pgsql_version')) === false) - { - $query_id = @pg_query($this->db_connect_id, 'SELECT VERSION() AS version'); - if ($query_id) - { - $row = pg_fetch_assoc($query_id, null); - pg_free_result($query_id); - - $this->sql_server_version = (!empty($row['version'])) ? trim(substr($row['version'], 10)) : 0; - - if (!empty($cache) && $use_cache) - { - $cache->put('pgsql_version', $this->sql_server_version); - } - } - } - - return ($raw) ? $this->sql_server_version : 'PostgreSQL ' . $this->sql_server_version; - } - - /** - * SQL Transaction - * @access private - */ - function _sql_transaction($status = 'begin') - { - switch ($status) - { - case 'begin': - return @pg_query($this->db_connect_id, 'BEGIN'); - break; - - case 'commit': - return @pg_query($this->db_connect_id, 'COMMIT'); - break; - - case 'rollback': - return @pg_query($this->db_connect_id, 'ROLLBACK'); - break; - } - - return true; - } - - /** - * {@inheritDoc} - */ - function sql_query($query = '', $cache_ttl = 0) - { - if ($query != '') - { - global $cache; - - if ($this->debug_sql_explain) - { - $this->sql_report('start', $query); - } - else if ($this->debug_load_time) - { - $this->curtime = microtime(true); - } - - $this->last_query_text = $query; - $this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false; - $this->sql_add_num_queries($this->query_result); - - if ($this->query_result === false) - { - if (($this->query_result = @pg_query($this->db_connect_id, $query)) === false) - { - $this->sql_error($query); - } - - if ($this->debug_sql_explain) - { - $this->sql_report('stop', $query); - } - else if ($this->debug_load_time) - { - $this->sql_time += microtime(true) - $this->curtime; - } - - if (!$this->query_result) - { - return false; - } - - if ($cache && $cache_ttl) - { - $this->open_queries[(int) $this->query_result] = $this->query_result; - $this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl); - } - else if (strpos($query, 'SELECT') === 0) - { - $this->open_queries[(int) $this->query_result] = $this->query_result; - } - } - else if ($this->debug_sql_explain) - { - $this->sql_report('fromcache', $query); - } - } - else - { - return false; - } - - return $this->query_result; - } - - /** - * Build db-specific query data - * @access private - */ - function _sql_custom_build($stage, $data) - { - return $data; - } - - /** - * Build LIMIT query - */ - function _sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0) - { - $this->query_result = false; - - // if $total is set to 0 we do not want to limit the number of rows - if ($total == 0) - { - $total = 'ALL'; - } - - $query .= "\n LIMIT $total OFFSET $offset"; - - return $this->sql_query($query, $cache_ttl); - } - - /** - * {@inheritDoc} - */ - function sql_affectedrows() - { - return ($this->query_result) ? @pg_affected_rows($this->query_result) : false; - } - - /** - * {@inheritDoc} - */ - function sql_fetchrow($query_id = false) - { - global $cache; - - if ($query_id === false) - { - $query_id = $this->query_result; - } - - if ($cache && $cache->sql_exists($query_id)) - { - return $cache->sql_fetchrow($query_id); - } - - return ($query_id) ? pg_fetch_assoc($query_id, null) : false; - } - - /** - * {@inheritDoc} - */ - function sql_rowseek($rownum, &$query_id) - { - global $cache; - - if ($query_id === false) - { - $query_id = $this->query_result; - } - - if ($cache && $cache->sql_exists($query_id)) - { - return $cache->sql_rowseek($rownum, $query_id); - } - - return ($query_id) ? @pg_result_seek($query_id, $rownum) : false; - } - - /** - * {@inheritDoc} - */ - function sql_nextid() - { - $query_id = $this->query_result; - - if ($query_id !== false && $this->last_query_text != '') - { - if (preg_match("/^INSERT[\t\n ]+INTO[\t\n ]+([a-z0-9\_\-]+)/is", $this->last_query_text, $tablename)) - { - $query = "SELECT currval('" . $tablename[1] . "_seq') AS last_value"; - $temp_q_id = @pg_query($this->db_connect_id, $query); - - if (!$temp_q_id) - { - return false; - } - - $temp_result = pg_fetch_assoc($temp_q_id, null); - pg_free_result($query_id); - - return ($temp_result) ? $temp_result['last_value'] : false; - } - } - - return false; - } - - /** - * {@inheritDoc} - */ - function sql_freeresult($query_id = false) - { - global $cache; - - if ($query_id === false) - { - $query_id = $this->query_result; - } - - if ($cache && !is_object($query_id) && $cache->sql_exists($query_id)) - { - return $cache->sql_freeresult($query_id); - } - - if (isset($this->open_queries[(int) $query_id])) - { - unset($this->open_queries[(int) $query_id]); - return pg_free_result($query_id); - } - - return false; - } - - /** - * {@inheritDoc} - */ - function sql_escape($msg) - { - return @pg_escape_string($msg); - } - - /** - * Build LIKE expression - * @access private - */ - function _sql_like_expression($expression) - { - return $expression; - } - - /** - * Build NOT LIKE expression - * @access private - */ - function _sql_not_like_expression($expression) - { - return $expression; - } - - /** - * {@inheritDoc} - */ - function cast_expr_to_bigint($expression) - { - return 'CAST(' . $expression . ' as DECIMAL(255, 0))'; - } - - /** - * {@inheritDoc} - */ - function cast_expr_to_string($expression) - { - return 'CAST(' . $expression . ' as VARCHAR(255))'; - } - - /** - * return sql error array - * @access private - */ - function _sql_error() - { - // pg_last_error only works when there is an established connection. - // Connection errors have to be tracked by us manually. - if ($this->db_connect_id) - { - $message = @pg_last_error($this->db_connect_id); - } - else - { - $message = $this->connect_error; - } - - return array( - 'message' => $message, - 'code' => '' - ); - } - - /** - * Close sql connection - * @access private - */ - function _sql_close() - { - return @pg_close($this->db_connect_id); - } - - /** - * Build db-specific report - * @access private - */ - function _sql_report($mode, $query = '') - { - switch ($mode) - { - case 'start': - - $explain_query = $query; - if (preg_match('/UPDATE ([a-z0-9_]+).*?WHERE(.*)/s', $query, $m)) - { - $explain_query = 'SELECT * FROM ' . $m[1] . ' WHERE ' . $m[2]; - } - else if (preg_match('/DELETE FROM ([a-z0-9_]+).*?WHERE(.*)/s', $query, $m)) - { - $explain_query = 'SELECT * FROM ' . $m[1] . ' WHERE ' . $m[2]; - } - - if (preg_match('/^SELECT/', $explain_query)) - { - $html_table = false; - - if ($result = @pg_query($this->db_connect_id, "EXPLAIN $explain_query")) - { - while ($row = pg_fetch_assoc($result, null)) - { - $html_table = $this->sql_report('add_select_row', $query, $html_table, $row); - } - pg_free_result($result); - } - - if ($html_table) - { - $this->html_hold .= ''; - } - } - - break; - - case 'fromcache': - $endtime = explode(' ', microtime()); - $endtime = $endtime[0] + $endtime[1]; - - $result = @pg_query($this->db_connect_id, $query); - if ($result) - { - while ($void = pg_fetch_assoc($result, null)) - { - // Take the time spent on parsing rows into account - } - pg_free_result($result); - } - - $splittime = explode(' ', microtime()); - $splittime = $splittime[0] + $splittime[1]; - - $this->sql_report('record_fromcache', $query, $endtime, $splittime); - - break; - } - } -} diff --git a/install/update/new/phpbb/db/driver/sqlite3.php b/install/update/new/phpbb/db/driver/sqlite3.php deleted file mode 100644 index 43906f1..0000000 --- a/install/update/new/phpbb/db/driver/sqlite3.php +++ /dev/null @@ -1,430 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\db\driver; - -/** -* SQLite3 Database Abstraction Layer -* Minimum Requirement: 3.6.15+ -*/ -class sqlite3 extends \phpbb\db\driver\driver -{ - /** - * @var string Stores errors during connection setup in case the driver is not available - */ - protected $connect_error = ''; - - /** - * @var \SQLite3 The SQLite3 database object to operate against - */ - protected $dbo = null; - - /** - * {@inheritDoc} - */ - public function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false) - { - $this->persistency = false; - $this->user = $sqluser; - $this->server = $sqlserver . (($port) ? ':' . $port : ''); - $this->dbname = $database; - - if (!class_exists('SQLite3', false)) - { - $this->connect_error = 'SQLite3 not found, is the extension installed?'; - return $this->sql_error(''); - } - - try - { - $this->dbo = new \SQLite3($this->server, SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE); - $this->dbo->busyTimeout(60000); - $this->db_connect_id = true; - } - catch (\Exception $e) - { - $this->connect_error = $e->getMessage(); - return array('message' => $this->connect_error); - } - - return true; - } - - /** - * {@inheritDoc} - */ - public function sql_server_info($raw = false, $use_cache = true) - { - global $cache; - - if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('sqlite_version')) === false) - { - $version = \SQLite3::version(); - - $this->sql_server_version = $version['versionString']; - - if (!empty($cache) && $use_cache) - { - $cache->put('sqlite_version', $this->sql_server_version); - } - } - - return ($raw) ? $this->sql_server_version : 'SQLite ' . $this->sql_server_version; - } - - /** - * SQL Transaction - * - * @param string $status Should be one of the following strings: - * begin, commit, rollback - * @return bool Success/failure of the transaction query - */ - protected function _sql_transaction($status = 'begin') - { - switch ($status) - { - case 'begin': - return $this->dbo->exec('BEGIN IMMEDIATE'); - break; - - case 'commit': - return $this->dbo->exec('COMMIT'); - break; - - case 'rollback': - return @$this->dbo->exec('ROLLBACK'); - break; - } - - return true; - } - - /** - * {@inheritDoc} - */ - public function sql_query($query = '', $cache_ttl = 0) - { - if ($query != '') - { - global $cache; - - if ($this->debug_sql_explain) - { - $this->sql_report('start', $query); - } - else if ($this->debug_load_time) - { - $this->curtime = microtime(true); - } - - $this->last_query_text = $query; - $this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false; - $this->sql_add_num_queries($this->query_result); - - if ($this->query_result === false) - { - if ($this->transaction === true && strpos($query, 'INSERT') === 0) - { - $query = preg_replace('/^INSERT INTO/', 'INSERT OR ROLLBACK INTO', $query); - } - - if (($this->query_result = @$this->dbo->query($query)) === false) - { - // Try to recover a lost database connection - if ($this->dbo && !@$this->dbo->lastErrorMsg()) - { - if ($this->sql_connect($this->server, $this->user, '', $this->dbname)) - { - $this->query_result = @$this->dbo->query($query); - } - } - - if ($this->query_result === false) - { - $this->sql_error($query); - } - } - - if ($this->debug_sql_explain) - { - $this->sql_report('stop', $query); - } - else if ($this->debug_load_time) - { - $this->sql_time += microtime(true) - $this->curtime; - } - - if (!$this->query_result) - { - return false; - } - - if ($cache && $cache_ttl) - { - $this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl); - } - } - else if ($this->debug_sql_explain) - { - $this->sql_report('fromcache', $query); - } - } - else - { - return false; - } - - return $this->query_result; - } - - /** - * Build LIMIT query - * - * @param string $query The SQL query to execute - * @param int $total The number of rows to select - * @param int $offset - * @param int $cache_ttl Either 0 to avoid caching or - * the time in seconds which the result shall be kept in cache - * @return mixed Buffered, seekable result handle, false on error - */ - protected function _sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0) - { - $this->query_result = false; - - // if $total is set to 0 we do not want to limit the number of rows - if ($total == 0) - { - $total = -1; - } - - $query .= "\n LIMIT " . ((!empty($offset)) ? $offset . ', ' . $total : $total); - - return $this->sql_query($query, $cache_ttl); - } - - /** - * {@inheritDoc} - */ - public function sql_affectedrows() - { - return ($this->db_connect_id) ? $this->dbo->changes() : false; - } - - /** - * {@inheritDoc} - */ - public function sql_fetchrow($query_id = false) - { - global $cache; - - if ($query_id === false) - { - /** @var \SQLite3Result $query_id */ - $query_id = $this->query_result; - } - - if ($cache && !is_object($query_id) && $cache->sql_exists($query_id)) - { - return $cache->sql_fetchrow($query_id); - } - - return is_object($query_id) ? @$query_id->fetchArray(SQLITE3_ASSOC) : false; - } - - /** - * {@inheritDoc} - */ - public function sql_nextid() - { - return ($this->db_connect_id) ? $this->dbo->lastInsertRowID() : false; - } - - /** - * {@inheritDoc} - */ - public function sql_freeresult($query_id = false) - { - global $cache; - - if ($query_id === false) - { - $query_id = $this->query_result; - } - - if ($cache && !is_object($query_id) && $cache->sql_exists($query_id)) - { - return $cache->sql_freeresult($query_id); - } - - if ($query_id) - { - return @$query_id->finalize(); - } - } - - /** - * {@inheritDoc} - */ - public function sql_escape($msg) - { - return \SQLite3::escapeString($msg); - } - - /** - * {@inheritDoc} - * - * For SQLite an underscore is an unknown character. - */ - public function sql_like_expression($expression) - { - // Unlike LIKE, GLOB is unfortunately case sensitive. - // We only catch * and ? here, not the character map possible on file globbing. - $expression = str_replace(array(chr(0) . '_', chr(0) . '%'), array(chr(0) . '?', chr(0) . '*'), $expression); - - $expression = str_replace(array('?', '*'), array("\?", "\*"), $expression); - $expression = str_replace(array(chr(0) . "\?", chr(0) . "\*"), array('?', '*'), $expression); - - return 'GLOB \'' . $this->sql_escape($expression) . '\''; - } - - /** - * {@inheritDoc} - * - * For SQLite an underscore is an unknown character. - */ - public function sql_not_like_expression($expression) - { - // Unlike NOT LIKE, NOT GLOB is unfortunately case sensitive - // We only catch * and ? here, not the character map possible on file globbing. - $expression = str_replace(array(chr(0) . '_', chr(0) . '%'), array(chr(0) . '?', chr(0) . '*'), $expression); - - $expression = str_replace(array('?', '*'), array("\?", "\*"), $expression); - $expression = str_replace(array(chr(0) . "\?", chr(0) . "\*"), array('?', '*'), $expression); - - return 'NOT GLOB \'' . $this->sql_escape($expression) . '\''; - } - - /** - * return sql error array - * - * @return array - */ - protected function _sql_error() - { - if (class_exists('SQLite3', false) && isset($this->dbo)) - { - $error = array( - 'message' => $this->dbo->lastErrorMsg(), - 'code' => $this->dbo->lastErrorCode(), - ); - } - else - { - $error = array( - 'message' => $this->connect_error, - 'code' => '', - ); - } - - return $error; - } - - /** - * Build db-specific query data - * - * @param string $stage Available stages: FROM, WHERE - * @param mixed $data A string containing the CROSS JOIN query or an array of WHERE clauses - * - * @return string The db-specific query fragment - */ - protected function _sql_custom_build($stage, $data) - { - return $data; - } - - /** - * Close sql connection - * - * @return bool False if failure - */ - protected function _sql_close() - { - return $this->dbo->close(); - } - - /** - * Build db-specific report - * - * @param string $mode Available modes: display, start, stop, - * add_select_row, fromcache, record_fromcache - * @param string $query The Query that should be explained - * @return mixed Either a full HTML page, boolean or null - */ - protected function _sql_report($mode, $query = '') - { - switch ($mode) - { - case 'start': - - $explain_query = $query; - if (preg_match('/UPDATE ([a-z0-9_]+).*?WHERE(.*)/s', $query, $m)) - { - $explain_query = 'SELECT * FROM ' . $m[1] . ' WHERE ' . $m[2]; - } - else if (preg_match('/DELETE FROM ([a-z0-9_]+).*?WHERE(.*)/s', $query, $m)) - { - $explain_query = 'SELECT * FROM ' . $m[1] . ' WHERE ' . $m[2]; - } - - if (preg_match('/^SELECT/', $explain_query)) - { - $html_table = false; - - if ($result = $this->dbo->query("EXPLAIN QUERY PLAN $explain_query")) - { - while ($row = $result->fetchArray(SQLITE3_ASSOC)) - { - $html_table = $this->sql_report('add_select_row', $query, $html_table, $row); - } - } - - if ($html_table) - { - $this->html_hold .= ''; - } - } - - break; - - case 'fromcache': - $endtime = explode(' ', microtime()); - $endtime = $endtime[0] + $endtime[1]; - - $result = $this->dbo->query($query); - if ($result) - { - while ($void = $result->fetchArray(SQLITE3_ASSOC)) - { - // Take the time spent on parsing rows into account - } - } - - $splittime = explode(' ', microtime()); - $splittime = $splittime[0] + $splittime[1]; - - $this->sql_report('record_fromcache', $query, $endtime, $splittime); - - break; - } - } -} diff --git a/install/update/new/phpbb/db/extractor/mysql_extractor.php b/install/update/new/phpbb/db/extractor/mysql_extractor.php deleted file mode 100644 index f3cb0db..0000000 --- a/install/update/new/phpbb/db/extractor/mysql_extractor.php +++ /dev/null @@ -1,301 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\db\extractor; - -use phpbb\db\extractor\exception\extractor_not_initialized_exception; - -class mysql_extractor extends base_extractor -{ - /** - * {@inheritdoc} - */ - public function write_start($table_prefix) - { - if (!$this->is_initialized) - { - throw new extractor_not_initialized_exception(); - } - - $sql_data = "#\n"; - $sql_data .= "# phpBB Backup Script\n"; - $sql_data .= "# Dump of tables for $table_prefix\n"; - $sql_data .= "# DATE : " . gmdate("d-m-Y H:i:s", $this->time) . " GMT\n"; - $sql_data .= "#\n"; - $this->flush($sql_data); - } - - /** - * {@inheritdoc} - */ - public function write_table($table_name) - { - static $new_extract; - - if (!$this->is_initialized) - { - throw new extractor_not_initialized_exception(); - } - - if ($new_extract === null) - { - if ($this->db->get_sql_layer() === 'mysqli' || version_compare($this->db->sql_server_info(true), '3.23.20', '>=')) - { - $new_extract = true; - } - else - { - $new_extract = false; - } - } - - if ($new_extract) - { - $this->new_write_table($table_name); - } - else - { - $this->old_write_table($table_name); - } - } - - /** - * {@inheritdoc} - */ - public function write_data($table_name) - { - if (!$this->is_initialized) - { - throw new extractor_not_initialized_exception(); - } - - $this->write_data_mysqli($table_name); - } - - /** - * Extracts data from database table (for MySQLi driver) - * - * @param string $table_name name of the database table - * @return null - * @throws \phpbb\db\extractor\exception\extractor_not_initialized_exception when calling this function before init_extractor() - */ - protected function write_data_mysqli($table_name) - { - if (!$this->is_initialized) - { - throw new extractor_not_initialized_exception(); - } - - $sql = "SELECT * - FROM $table_name"; - $result = mysqli_query($this->db->get_db_connect_id(), $sql, MYSQLI_USE_RESULT); - if ($result != false) - { - $fields_cnt = mysqli_num_fields($result); - - // Get field information - $field = mysqli_fetch_fields($result); - $field_set = array(); - - for ($j = 0; $j < $fields_cnt; $j++) - { - $field_set[] = $field[$j]->name; - } - - $search = array("\\", "'", "\x00", "\x0a", "\x0d", "\x1a", '"'); - $replace = array("\\\\", "\\'", '\0', '\n', '\r', '\Z', '\\"'); - $fields = implode(', ', $field_set); - $sql_data = 'INSERT INTO ' . $table_name . ' (' . $fields . ') VALUES '; - $first_set = true; - $query_len = 0; - $max_len = get_usable_memory(); - - while ($row = mysqli_fetch_row($result)) - { - $values = array(); - if ($first_set) - { - $query = $sql_data . '('; - } - else - { - $query .= ',('; - } - - for ($j = 0; $j < $fields_cnt; $j++) - { - if (!isset($row[$j]) || is_null($row[$j])) - { - $values[$j] = 'NULL'; - } - else if (($field[$j]->flags & 32768) && !($field[$j]->flags & 1024)) - { - $values[$j] = $row[$j]; - } - else - { - $values[$j] = "'" . str_replace($search, $replace, $row[$j]) . "'"; - } - } - $query .= implode(', ', $values) . ')'; - - $query_len += strlen($query); - if ($query_len > $max_len) - { - $this->flush($query . ";\n\n"); - $query = ''; - $query_len = 0; - $first_set = true; - } - else - { - $first_set = false; - } - } - mysqli_free_result($result); - - // check to make sure we have nothing left to flush - if (!$first_set && $query) - { - $this->flush($query . ";\n\n"); - } - } - } - - /** - * Extracts database table structure (for MySQLi or MySQL 3.23.20+) - * - * @param string $table_name name of the database table - * @return null - * @throws \phpbb\db\extractor\exception\extractor_not_initialized_exception when calling this function before init_extractor() - */ - protected function new_write_table($table_name) - { - if (!$this->is_initialized) - { - throw new extractor_not_initialized_exception(); - } - - $sql = 'SHOW CREATE TABLE ' . $table_name; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - - $sql_data = '# Table: ' . $table_name . "\n"; - $sql_data .= "DROP TABLE IF EXISTS $table_name;\n"; - $this->flush($sql_data . $row['Create Table'] . ";\n\n"); - - $this->db->sql_freeresult($result); - } - - /** - * Extracts database table structure (for MySQL versions older than 3.23.20) - * - * @param string $table_name name of the database table - * @return null - * @throws \phpbb\db\extractor\exception\extractor_not_initialized_exception when calling this function before init_extractor() - */ - protected function old_write_table($table_name) - { - if (!$this->is_initialized) - { - throw new extractor_not_initialized_exception(); - } - - $sql_data = '# Table: ' . $table_name . "\n"; - $sql_data .= "DROP TABLE IF EXISTS $table_name;\n"; - $sql_data .= "CREATE TABLE $table_name(\n"; - $rows = array(); - - $sql = "SHOW FIELDS - FROM $table_name"; - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - $line = ' ' . $row['Field'] . ' ' . $row['Type']; - - if (!is_null($row['Default'])) - { - $line .= " DEFAULT '{$row['Default']}'"; - } - - if ($row['Null'] != 'YES') - { - $line .= ' NOT NULL'; - } - - if ($row['Extra'] != '') - { - $line .= ' ' . $row['Extra']; - } - - $rows[] = $line; - } - $this->db->sql_freeresult($result); - - $sql = "SHOW KEYS - FROM $table_name"; - - $result = $this->db->sql_query($sql); - - $index = array(); - while ($row = $this->db->sql_fetchrow($result)) - { - $kname = $row['Key_name']; - - if ($kname != 'PRIMARY') - { - if ($row['Non_unique'] == 0) - { - $kname = "UNIQUE|$kname"; - } - } - - if ($row['Sub_part']) - { - $row['Column_name'] .= '(' . $row['Sub_part'] . ')'; - } - $index[$kname][] = $row['Column_name']; - } - $this->db->sql_freeresult($result); - - foreach ($index as $key => $columns) - { - $line = ' '; - - if ($key == 'PRIMARY') - { - $line .= 'PRIMARY KEY (' . implode(', ', $columns) . ')'; - } - else if (strpos($key, 'UNIQUE') === 0) - { - $line .= 'UNIQUE ' . substr($key, 7) . ' (' . implode(', ', $columns) . ')'; - } - else if (strpos($key, 'FULLTEXT') === 0) - { - $line .= 'FULLTEXT ' . substr($key, 9) . ' (' . implode(', ', $columns) . ')'; - } - else - { - $line .= "KEY $key (" . implode(', ', $columns) . ')'; - } - - $rows[] = $line; - } - - $sql_data .= implode(",\n", $rows); - $sql_data .= "\n);\n\n"; - - $this->flush($sql_data); - } -} diff --git a/install/update/new/phpbb/db/migration/data/v30x/release_3_0_4_rc1.php b/install/update/new/phpbb/db/migration/data/v30x/release_3_0_4_rc1.php deleted file mode 100644 index 247ccc7..0000000 --- a/install/update/new/phpbb/db/migration/data/v30x/release_3_0_4_rc1.php +++ /dev/null @@ -1,129 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\db\migration\data\v30x; - -class release_3_0_4_rc1 extends \phpbb\db\migration\migration -{ - public function effectively_installed() - { - return phpbb_version_compare($this->config['version'], '3.0.4-RC1', '>='); - } - - static public function depends_on() - { - return array('\phpbb\db\migration\data\v30x\release_3_0_3'); - } - - public function update_schema() - { - return array( - 'add_columns' => array( - $this->table_prefix . 'profile_fields' => array( - 'field_show_profile' => array('BOOL', 0), - ), - ), - 'change_columns' => array( - $this->table_prefix . 'styles' => array( - 'style_id' => array('UINT', NULL, 'auto_increment'), - 'template_id' => array('UINT', 0), - 'theme_id' => array('UINT', 0), - 'imageset_id' => array('UINT', 0), - ), - $this->table_prefix . 'styles_imageset' => array( - 'imageset_id' => array('UINT', NULL, 'auto_increment'), - ), - $this->table_prefix . 'styles_imageset_data' => array( - 'image_id' => array('UINT', NULL, 'auto_increment'), - 'imageset_id' => array('UINT', 0), - ), - $this->table_prefix . 'styles_theme' => array( - 'theme_id' => array('UINT', NULL, 'auto_increment'), - ), - $this->table_prefix . 'styles_template' => array( - 'template_id' => array('UINT', NULL, 'auto_increment'), - ), - $this->table_prefix . 'styles_template_data' => array( - 'template_id' => array('UINT', 0), - ), - $this->table_prefix . 'forums' => array( - 'forum_style' => array('UINT', 0), - ), - $this->table_prefix . 'users' => array( - 'user_style' => array('UINT', 0), - ), - ), - ); - } - - public function revert_schema() - { - return array( - 'drop_columns' => array( - $this->table_prefix . 'profile_fields' => array( - 'field_show_profile', - ), - ), - ); - } - - public function update_data() - { - return array( - array('custom', array(array(&$this, 'update_custom_profile_fields'))), - - array('config.update', array('version', '3.0.4-RC1')), - ); - } - - public function update_custom_profile_fields() - { - // Update the Custom Profile Fields based on previous settings to the new \format - $sql = 'SELECT field_id, field_required, field_show_on_reg, field_hide - FROM ' . PROFILE_FIELDS_TABLE; - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - $sql_ary = array( - 'field_required' => 0, - 'field_show_on_reg' => 0, - 'field_hide' => 0, - 'field_show_profile'=> 0, - ); - - if ($row['field_required']) - { - $sql_ary['field_required'] = $sql_ary['field_show_on_reg'] = $sql_ary['field_show_profile'] = 1; - } - else if ($row['field_show_on_reg']) - { - $sql_ary['field_show_on_reg'] = $sql_ary['field_show_profile'] = 1; - } - else if ($row['field_hide']) - { - // Only administrators and moderators can see this CPF, if the view is enabled, they can see it, otherwise just admins in the acp_users module - $sql_ary['field_hide'] = 1; - } - else - { - // equivalent to "none", which is the "Display in user control panel" option - $sql_ary['field_show_profile'] = 1; - } - - $this->sql_query('UPDATE ' . $this->table_prefix . 'profile_fields SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE field_id = ' . $row['field_id'], $errored, $error_ary); - } - - $this->db->sql_freeresult($result); - } -} diff --git a/install/update/new/phpbb/db/migration/data/v310/softdelete_p1.php b/install/update/new/phpbb/db/migration/data/v310/softdelete_p1.php deleted file mode 100644 index 877cdc2..0000000 --- a/install/update/new/phpbb/db/migration/data/v310/softdelete_p1.php +++ /dev/null @@ -1,211 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\db\migration\data\v310; - -class softdelete_p1 extends \phpbb\db\migration\migration -{ - public function effectively_installed() - { - return $this->db_tools->sql_column_exists($this->table_prefix . 'posts', 'post_visibility'); - } - - static public function depends_on() - { - return array('\phpbb\db\migration\data\v310\dev'); - } - - public function update_schema() - { - return array( - 'add_columns' => array( - $this->table_prefix . 'forums' => array( - 'forum_posts_approved' => array('UINT', 0), - 'forum_posts_unapproved' => array('UINT', 0), - 'forum_posts_softdeleted' => array('UINT', 0), - 'forum_topics_approved' => array('UINT', 0), - 'forum_topics_unapproved' => array('UINT', 0), - 'forum_topics_softdeleted' => array('UINT', 0), - ), - $this->table_prefix . 'posts' => array( - 'post_visibility' => array('TINT:3', 0), - 'post_delete_time' => array('TIMESTAMP', 0), - 'post_delete_reason' => array('STEXT_UNI', ''), - 'post_delete_user' => array('UINT', 0), - ), - $this->table_prefix . 'topics' => array( - 'topic_visibility' => array('TINT:3', 0), - 'topic_delete_time' => array('TIMESTAMP', 0), - 'topic_delete_reason' => array('STEXT_UNI', ''), - 'topic_delete_user' => array('UINT', 0), - 'topic_posts_approved' => array('UINT', 0), - 'topic_posts_unapproved' => array('UINT', 0), - 'topic_posts_softdeleted' => array('UINT', 0), - ), - ), - 'add_index' => array( - $this->table_prefix . 'posts' => array( - 'post_visibility' => array('post_visibility'), - ), - $this->table_prefix . 'topics' => array( - 'topic_visibility' => array('topic_visibility'), - 'forum_vis_last' => array('forum_id', 'topic_visibility', 'topic_last_post_id'), - ), - ), - ); - } - - public function revert_schema() - { - return array( - 'drop_columns' => array( - $this->table_prefix . 'forums' => array( - 'forum_posts_approved', - 'forum_posts_unapproved', - 'forum_posts_softdeleted', - 'forum_topics_approved', - 'forum_topics_unapproved', - 'forum_topics_softdeleted', - ), - $this->table_prefix . 'posts' => array( - 'post_visibility', - 'post_delete_time', - 'post_delete_reason', - 'post_delete_user', - ), - $this->table_prefix . 'topics' => array( - 'topic_visibility', - 'topic_delete_time', - 'topic_delete_reason', - 'topic_delete_user', - 'topic_posts_approved', - 'topic_posts_unapproved', - 'topic_posts_softdeleted', - ), - ), - 'drop_keys' => array( - $this->table_prefix . 'posts' => array('post_visibility'), - $this->table_prefix . 'topics' => array('topic_visibility', 'forum_vis_last'), - ), - ); - } - - public function update_data() - { - return array( - array('custom', array(array($this, 'update_post_visibility'))), - array('custom', array(array($this, 'update_topic_visibility'))), - array('custom', array(array($this, 'update_topics_post_counts'))), - array('custom', array(array($this, 'update_forums_topic_and_post_counts'))), - - array('permission.add', array('f_softdelete', false)), - array('permission.add', array('m_softdelete', false)), - ); - } - - public function update_post_visibility() - { - $sql = 'UPDATE ' . $this->table_prefix . 'posts - SET post_visibility = post_approved'; - $this->sql_query($sql); - } - - public function update_topic_visibility() - { - $sql = 'UPDATE ' . $this->table_prefix . 'topics - SET topic_visibility = topic_approved'; - $this->sql_query($sql); - } - - public function update_topics_post_counts() - { - /* - * Using sql_case here to avoid "BIGINT UNSIGNED value is out of range" errors. - * As we update all topics in 2 queries, one broken topic would stop the conversion - * for all topics and the suppressed error will cause the admin to not even notice it. - */ - $sql = 'UPDATE ' . $this->table_prefix . 'topics - SET topic_posts_approved = topic_replies + 1, - topic_posts_unapproved = ' . $this->db->sql_case('topic_replies_real > topic_replies', 'topic_replies_real - topic_replies', '0') . ' - WHERE topic_visibility = ' . ITEM_APPROVED; - $this->sql_query($sql); - - $sql = 'UPDATE ' . $this->table_prefix . 'topics - SET topic_posts_approved = 0, - topic_posts_unapproved = (' . $this->db->sql_case('topic_replies_real > topic_replies', 'topic_replies_real - topic_replies', '0') . ') + 1 - WHERE topic_visibility = ' . ITEM_UNAPPROVED; - $this->sql_query($sql); - } - - public function update_forums_topic_and_post_counts($start) - { - $start = (int) $start; - $limit = 10; - $converted_forums = 0; - - if (!$start) - { - // Preserve the forum_posts value for link forums as it represents redirects. - $sql = 'UPDATE ' . $this->table_prefix . 'forums - SET forum_posts_approved = forum_posts - WHERE forum_type = ' . FORUM_LINK; - $this->db->sql_query($sql); - } - - $sql = 'SELECT forum_id, topic_visibility, COUNT(topic_id) AS sum_topics, SUM(topic_posts_approved) AS sum_posts_approved, SUM(topic_posts_unapproved) AS sum_posts_unapproved - FROM ' . $this->table_prefix . 'topics - GROUP BY forum_id, topic_visibility - ORDER BY forum_id, topic_visibility'; - $result = $this->db->sql_query_limit($sql, $limit, $start); - - $update_forums = array(); - while ($row = $this->db->sql_fetchrow($result)) - { - $converted_forums++; - - $forum_id = (int) $row['forum_id']; - if (!isset($update_forums[$forum_id])) - { - $update_forums[$forum_id] = array( - 'forum_posts_approved' => 0, - 'forum_posts_unapproved' => 0, - 'forum_topics_approved' => 0, - 'forum_topics_unapproved' => 0, - ); - } - - $update_forums[$forum_id]['forum_posts_approved'] += (int) $row['sum_posts_approved']; - $update_forums[$forum_id]['forum_posts_unapproved'] += (int) $row['sum_posts_unapproved']; - - $update_forums[$forum_id][(($row['topic_visibility'] == ITEM_APPROVED) ? 'forum_topics_approved' : 'forum_topics_unapproved')] += (int) $row['sum_topics']; - } - $this->db->sql_freeresult($result); - - foreach ($update_forums as $forum_id => $forum_data) - { - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET ' . $this->db->sql_build_array('UPDATE', $forum_data) . ' - WHERE forum_id = ' . $forum_id; - $this->sql_query($sql); - } - - if ($converted_forums < $limit) - { - // There are no more topics, we are done - return; - } - - // There are still more topics to query, return the next start value - return $start + $limit; - } -} diff --git a/install/update/new/phpbb/db/migration/data/v32x/timezone_p3.php b/install/update/new/phpbb/db/migration/data/v32x/timezone_p3.php deleted file mode 100644 index 433f62a..0000000 --- a/install/update/new/phpbb/db/migration/data/v32x/timezone_p3.php +++ /dev/null @@ -1,29 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\db\migration\data\v32x; - -class timezone_p3 extends \phpbb\db\migration\migration -{ - static public function depends_on() - { - return array('\phpbb\db\migration\data\v310\timezone'); - } - - public function update_data() - { - return array( - array('config.remove', array('board_dst')), - ); - } -} diff --git a/install/update/new/phpbb/db/migration/data/v32x/user_emoji_permission.php b/install/update/new/phpbb/db/migration/data/v32x/user_emoji_permission.php deleted file mode 100644 index 98759c7..0000000 --- a/install/update/new/phpbb/db/migration/data/v32x/user_emoji_permission.php +++ /dev/null @@ -1,44 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\db\migration\data\v32x; - -class user_emoji_permission extends \phpbb\db\migration\migration -{ - public function effectively_installed() - { - $sql = 'SELECT auth_option_id - FROM ' . ACL_OPTIONS_TABLE . " - WHERE auth_option = 'u_emoji'"; - $result = $this->db->sql_query($sql); - $auth_option_id = $this->db->sql_fetchfield('auth_option_id'); - $this->db->sql_freeresult($result); - - return $auth_option_id !== false; - } - - static public function depends_on() - { - return [ - '\phpbb\db\migration\data\v32x\v329rc1', - ]; - } - - public function update_data() - { - return [ - ['permission.add', ['u_emoji']], - ['permission.permission_set', ['REGISTERED', 'u_emoji', 'group']], - ]; - } -} diff --git a/install/update/new/phpbb/db/migration/data/v32x/v328.php b/install/update/new/phpbb/db/migration/data/v32x/v328.php deleted file mode 100644 index 28ff2c7..0000000 --- a/install/update/new/phpbb/db/migration/data/v32x/v328.php +++ /dev/null @@ -1,36 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\db\migration\data\v32x; - -class v328 extends \phpbb\db\migration\migration -{ - public function effectively_installed() - { - return phpbb_version_compare($this->config['version'], '3.2.8', '>='); - } - - static public function depends_on() - { - return array( - '\phpbb\db\migration\data\v32x\v328rc1', - ); - } - - public function update_data() - { - return array( - array('config.update', array('version', '3.2.8')), - ); - } -} diff --git a/install/update/new/phpbb/db/migration/data/v32x/v328rc1.php b/install/update/new/phpbb/db/migration/data/v32x/v328rc1.php deleted file mode 100644 index fa43cf3..0000000 --- a/install/update/new/phpbb/db/migration/data/v32x/v328rc1.php +++ /dev/null @@ -1,37 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\db\migration\data\v32x; - -class v328rc1 extends \phpbb\db\migration\migration -{ - public function effectively_installed() - { - return phpbb_version_compare($this->config['version'], '3.2.8-RC1', '>='); - } - - static public function depends_on() - { - return array( - '\phpbb\db\migration\data\v32x\timezone_p3', - '\phpbb\db\migration\data\v32x\v327', - ); - } - - public function update_data() - { - return array( - array('config.update', array('version', '3.2.8-RC1')), - ); - } -} diff --git a/install/update/new/phpbb/db/migration/data/v32x/v329.php b/install/update/new/phpbb/db/migration/data/v32x/v329.php deleted file mode 100644 index e88e264..0000000 --- a/install/update/new/phpbb/db/migration/data/v32x/v329.php +++ /dev/null @@ -1,37 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\db\migration\data\v32x; - -class v329 extends \phpbb\db\migration\migration -{ - public function effectively_installed() - { - return phpbb_version_compare($this->config['version'], '3.2.9', '>='); - } - - static public function depends_on() - { - return array( - '\phpbb\db\migration\data\v32x\v329rc1', - '\phpbb\db\migration\data\v32x\user_emoji_permission', - ); - } - - public function update_data() - { - return array( - array('config.update', array('version', '3.2.9')), - ); - } -} diff --git a/install/update/new/phpbb/db/migration/data/v32x/v329rc1.php b/install/update/new/phpbb/db/migration/data/v32x/v329rc1.php deleted file mode 100644 index 271bf62..0000000 --- a/install/update/new/phpbb/db/migration/data/v32x/v329rc1.php +++ /dev/null @@ -1,36 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\db\migration\data\v32x; - -class v329rc1 extends \phpbb\db\migration\migration -{ - public function effectively_installed() - { - return phpbb_version_compare($this->config['version'], '3.2.9-RC1', '>='); - } - - static public function depends_on() - { - return array( - '\phpbb\db\migration\data\v32x\v328', - ); - } - - public function update_data() - { - return array( - array('config.update', array('version', '3.2.9-RC1')), - ); - } -} diff --git a/install/update/new/phpbb/db/migration/data/v330/add_display_unapproved_posts_config.php b/install/update/new/phpbb/db/migration/data/v330/add_display_unapproved_posts_config.php deleted file mode 100644 index 209aba3..0000000 --- a/install/update/new/phpbb/db/migration/data/v330/add_display_unapproved_posts_config.php +++ /dev/null @@ -1,34 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\db\migration\data\v330; - -class add_display_unapproved_posts_config extends \phpbb\db\migration\migration -{ - public function effectively_installed() - { - return $this->config->offsetExists('display_unapproved_posts'); - } - - public static function depends_on() - { - return ['\phpbb\db\migration\data\v330\dev',]; - } - - public function update_data() - { - return [ - ['config.add', ['display_unapproved_posts', 1]], - ]; - } -} diff --git a/install/update/new/phpbb/db/migration/data/v330/dev.php b/install/update/new/phpbb/db/migration/data/v330/dev.php deleted file mode 100644 index 209f9fc..0000000 --- a/install/update/new/phpbb/db/migration/data/v330/dev.php +++ /dev/null @@ -1,36 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\db\migration\data\v330; - -class dev extends \phpbb\db\migration\migration -{ - public function effectively_installed() - { - return version_compare($this->config['version'], '3.3.0-dev', '>='); - } - - static public function depends_on() - { - return array( - '\phpbb\db\migration\data\v32x\v327', - ); - } - - public function update_data() - { - return array( - array('config.update', array('version', '3.3.0-dev')), - ); - } -} diff --git a/install/update/new/phpbb/db/migration/data/v330/forums_legend_limit.php b/install/update/new/phpbb/db/migration/data/v330/forums_legend_limit.php deleted file mode 100644 index c5a4bee..0000000 --- a/install/update/new/phpbb/db/migration/data/v330/forums_legend_limit.php +++ /dev/null @@ -1,49 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\db\migration\data\v330; - -class forums_legend_limit extends \phpbb\db\migration\migration -{ - public function effectively_installed() - { - return $this->db_tools->sql_column_exists($this->table_prefix . 'forums', 'display_subforum_limit'); - } - - static public function depends_on() - { - return ['\phpbb\db\migration\data\v330\v330b1']; - } - - public function update_schema() - { - return [ - 'add_columns' => [ - $this->table_prefix . 'forums' => [ - 'display_subforum_limit' => ['BOOL', 0, 'after' => 'display_subforum_list'], - ], - ], - ]; - } - - public function revert_schema() - { - return [ - 'drop_columns' => [ - $this->table_prefix . 'forums' => [ - 'display_subforum_limit', - ], - ], - ]; - } -} diff --git a/install/update/new/phpbb/db/migration/data/v330/jquery_update.php b/install/update/new/phpbb/db/migration/data/v330/jquery_update.php deleted file mode 100644 index f1ac6cd..0000000 --- a/install/update/new/phpbb/db/migration/data/v330/jquery_update.php +++ /dev/null @@ -1,37 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\db\migration\data\v330; - -class jquery_update extends \phpbb\db\migration\migration -{ - public function effectively_installed() - { - return $this->config['load_jquery_url'] === '//ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js'; - } - - static public function depends_on() - { - return array( - '\phpbb\db\migration\data\v330\dev', - ); - } - - public function update_data() - { - return array( - array('config.update', array('load_jquery_url', '//ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js')), - ); - } - -} diff --git a/install/update/new/phpbb/db/migration/data/v330/remove_attachment_flash.php b/install/update/new/phpbb/db/migration/data/v330/remove_attachment_flash.php deleted file mode 100644 index c136960..0000000 --- a/install/update/new/phpbb/db/migration/data/v330/remove_attachment_flash.php +++ /dev/null @@ -1,89 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\db\migration\data\v330; - -class remove_attachment_flash extends \phpbb\db\migration\migration -{ - // Following constants were deprecated in 3.3 - // and moved from constants.php to compatibility_globals.php, - // thus define them as class constants - const ATTACHMENT_CATEGORY_FLASH = 5; - - protected $cat_id = array( - self::ATTACHMENT_CATEGORY_FLASH, - ); - - public static function depends_on() - { - return ['\phpbb\db\migration\data\v330\dev',]; - } - - public function update_data() - { - return array( - array('custom', array(array($this, 'remove_flash_group'))), - ); - } - - public function remove_flash_group() - { - // select group ids of outdated media - $sql = 'SELECT group_id - FROM ' . EXTENSION_GROUPS_TABLE . ' - WHERE ' . $this->db->sql_in_set('cat_id', $this->cat_id); - $result = $this->db->sql_query($sql); - - $group_ids = array(); - while ($group_id = (int) $this->db->sql_fetchfield('group_id')) - { - $group_ids[] = $group_id; - } - $this->db->sql_freeresult($result); - - // nothing to do, admin has removed all the outdated media extension groups - if (empty($group_ids)) - { - return true; - } - - // get the group id of downloadable files - $sql = 'SELECT group_id - FROM ' . EXTENSION_GROUPS_TABLE . " - WHERE group_name = 'DOWNLOADABLE_FILES'"; - $result = $this->db->sql_query($sql); - $download_id = (int) $this->db->sql_fetchfield('group_id'); - $this->db->sql_freeresult($result); - - if (empty($download_id)) - { - $sql = 'UPDATE ' . EXTENSIONS_TABLE . ' - SET group_id = 0 - WHERE ' . $this->db->sql_in_set('group_id', $group_ids); - } - else - { - // move outdated media extensions to downloadable files - $sql = 'UPDATE ' . EXTENSIONS_TABLE . " - SET group_id = $download_id" . ' - WHERE ' . $this->db->sql_in_set('group_id', $group_ids); - } - - $this->db->sql_query($sql); - - // delete the now empty, outdated media extension groups - $sql = 'DELETE FROM ' . EXTENSION_GROUPS_TABLE . ' - WHERE ' . $this->db->sql_in_set('group_id', $group_ids); - $this->db->sql_query($sql); - } -} diff --git a/install/update/new/phpbb/db/migration/data/v330/remove_email_hash.php b/install/update/new/phpbb/db/migration/data/v330/remove_email_hash.php deleted file mode 100644 index 8ac8f4e..0000000 --- a/install/update/new/phpbb/db/migration/data/v330/remove_email_hash.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\db\migration\data\v330; - -class remove_email_hash extends \phpbb\db\migration\migration -{ - static public function depends_on() - { - return ['\phpbb\db\migration\data\v30x\release_3_0_0']; - } - - public function update_schema() - { - return [ - 'add_index' => [ - $this->table_prefix . 'users' => [ - 'user_email' => ['user_email'], - ], - ], - 'drop_keys' => [ - $this->table_prefix . 'users' => [ - 'user_email_hash', - ], - ], - 'drop_columns' => [ - $this->table_prefix . 'users' => ['user_email_hash'], - ], - ]; - } - - public function revert_schema() - { - return [ - 'add_columns' => [ - $this->table_prefix . 'users' => [ - 'user_email_hash' => ['BINT', 0], - ], - ], - 'add_index' => [ - $this->table_prefix . 'users' => [ - 'user_email_hash', - ], - ], - 'drop_keys' => [ - $this->table_prefix . 'users' => [ - 'user_email' => ['user_email'], - ], - ], - ]; - } -} diff --git a/install/update/new/phpbb/db/migration/data/v330/remove_max_pass_chars.php b/install/update/new/phpbb/db/migration/data/v330/remove_max_pass_chars.php deleted file mode 100644 index 10e5ee3..0000000 --- a/install/update/new/phpbb/db/migration/data/v330/remove_max_pass_chars.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\db\migration\data\v330; - -class remove_max_pass_chars extends \phpbb\db\migration\migration -{ - public function effectively_installed() - { - return !$this->config->offsetExists('max_pass_chars'); - } - - public static function depends_on() - { - return [ - '\phpbb\db\migration\data\v330\dev', - ]; - } - - public function update_data() - { - return [ - ['config.remove', ['max_pass_chars']], - ]; - } - - public function revert_data() - { - return [ - ['config.add', ['max_pass_chars', 100]], - ]; - } -} diff --git a/install/update/new/phpbb/db/migration/data/v330/reset_password.php b/install/update/new/phpbb/db/migration/data/v330/reset_password.php deleted file mode 100644 index 953d478..0000000 --- a/install/update/new/phpbb/db/migration/data/v330/reset_password.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\db\migration\data\v330; - -class reset_password extends \phpbb\db\migration\migration -{ - static public function depends_on() - { - return [ - '\phpbb\db\migration\data\v330\dev', - ]; - } - - public function update_schema() - { - return [ - 'add_columns' => [ - $this->table_prefix . 'users' => [ - 'reset_token' => ['VCHAR:64', '', 'after' => 'user_actkey'], - 'reset_token_expiration' => ['TIMESTAMP', 0, 'after' => 'reset_token'], - ], - ], - ]; - } - - public function revert_schema() - { - return [ - 'drop_columns' => [ - $this->table_prefix . 'users' => [ - 'reset_token', - 'reset_token_expiration', - ], - ], - ]; - } -} diff --git a/install/update/new/phpbb/db/migration/data/v330/v330.php b/install/update/new/phpbb/db/migration/data/v330/v330.php deleted file mode 100644 index 05baffb..0000000 --- a/install/update/new/phpbb/db/migration/data/v330/v330.php +++ /dev/null @@ -1,37 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\db\migration\data\v330; - -class v330 extends \phpbb\db\migration\migration -{ - public function effectively_installed() - { - return version_compare($this->config['version'], '3.3.0', '>='); - } - - static public function depends_on() - { - return array( - '\phpbb\db\migration\data\v32x\v329', - '\phpbb\db\migration\data\v330\v330rc1', - ); - } - - public function update_data() - { - return array( - array('config.update', array('version', '3.3.0')), - ); - } -} diff --git a/install/update/new/phpbb/db/migration/data/v330/v330b1.php b/install/update/new/phpbb/db/migration/data/v330/v330b1.php deleted file mode 100644 index 3df4450..0000000 --- a/install/update/new/phpbb/db/migration/data/v330/v330b1.php +++ /dev/null @@ -1,41 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\db\migration\data\v330; - -class v330b1 extends \phpbb\db\migration\migration -{ - public function effectively_installed() - { - return version_compare($this->config['version'], '3.3.0-b1', '>='); - } - - static public function depends_on() - { - return array( - '\phpbb\db\migration\data\v330\jquery_update', - '\phpbb\db\migration\data\v330\reset_password', - '\phpbb\db\migration\data\v330\remove_attachment_flash', - '\phpbb\db\migration\data\v330\remove_max_pass_chars', - '\phpbb\db\migration\data\v32x\v328', - '\phpbb\db\migration\data\v330\dev', - ); - } - - public function update_data() - { - return array( - array('config.update', array('version', '3.3.0-b1')), - ); - } -} diff --git a/install/update/new/phpbb/db/migration/data/v330/v330b2.php b/install/update/new/phpbb/db/migration/data/v330/v330b2.php deleted file mode 100644 index cb2198a..0000000 --- a/install/update/new/phpbb/db/migration/data/v330/v330b2.php +++ /dev/null @@ -1,39 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\db\migration\data\v330; - -class v330b2 extends \phpbb\db\migration\migration -{ - public function effectively_installed() - { - return version_compare($this->config['version'], '3.3.0-b2', '>='); - } - - static public function depends_on() - { - return array( - '\phpbb\db\migration\data\v330\add_display_unapproved_posts_config', - '\phpbb\db\migration\data\v330\forums_legend_limit', - '\phpbb\db\migration\data\v330\remove_email_hash', - '\phpbb\db\migration\data\v330\v330b1', - ); - } - - public function update_data() - { - return array( - array('config.update', array('version', '3.3.0-b2')), - ); - } -} diff --git a/install/update/new/phpbb/db/migration/data/v330/v330rc1.php b/install/update/new/phpbb/db/migration/data/v330/v330rc1.php deleted file mode 100644 index 5219375..0000000 --- a/install/update/new/phpbb/db/migration/data/v330/v330rc1.php +++ /dev/null @@ -1,36 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\db\migration\data\v330; - -class v330rc1 extends \phpbb\db\migration\migration -{ - public function effectively_installed() - { - return version_compare($this->config['version'], '3.3.0-RC1', '>='); - } - - static public function depends_on() - { - return array( - '\phpbb\db\migration\data\v330\v330b2', - ); - } - - public function update_data() - { - return array( - array('config.update', array('version', '3.3.0-RC1')), - ); - } -} diff --git a/install/update/new/phpbb/db/migration/tool/module.php b/install/update/new/phpbb/db/migration/tool/module.php deleted file mode 100644 index 93c3384..0000000 --- a/install/update/new/phpbb/db/migration/tool/module.php +++ /dev/null @@ -1,556 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\db\migration\tool; - -use phpbb\module\exception\module_exception; - -/** -* Migration module management tool -*/ -class module implements \phpbb\db\migration\tool\tool_interface -{ - /** @var \phpbb\cache\service */ - protected $cache; - - /** @var \phpbb\db\driver\driver_interface */ - protected $db; - - /** @var \phpbb\user */ - protected $user; - - /** @var \phpbb\module\module_manager */ - protected $module_manager; - - /** @var string */ - protected $phpbb_root_path; - - /** @var string */ - protected $php_ext; - - /** @var string */ - protected $modules_table; - - /** @var array */ - protected $module_categories = array(); - - /** - * Constructor - * - * @param \phpbb\db\driver\driver_interface $db - * @param \phpbb\cache\service $cache - * @param \phpbb\user $user - * @param \phpbb\module\module_manager $module_manager - * @param string $phpbb_root_path - * @param string $php_ext - * @param string $modules_table - */ - public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\cache\service $cache, \phpbb\user $user, \phpbb\module\module_manager $module_manager, $phpbb_root_path, $php_ext, $modules_table) - { - $this->db = $db; - $this->cache = $cache; - $this->user = $user; - $this->module_manager = $module_manager; - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - $this->modules_table = $modules_table; - } - - /** - * {@inheritdoc} - */ - public function get_name() - { - return 'module'; - } - - /** - * Module Exists - * - * Check if a module exists - * - * @param string $class The module class(acp|mcp|ucp) - * @param int|string|bool $parent The parent module_id|module_langname (0 for no parent). - * Use false to ignore the parent check and check class wide. - * @param int|string $module The module_id|module_langname you would like to - * check for to see if it exists - * @param bool $lazy Checks lazily if the module exists. Returns true if it exists in at - * least one given parent. - * @return bool true if module exists in *all* given parents, false if not in any given parent; - * true if ignoring parent check and module exists class wide, false if not found at all. - */ - public function exists($class, $parent, $module, $lazy = false) - { - // the main root directory should return true - if (!$module) - { - return true; - } - - $parent_sqls = []; - if ($parent !== false) - { - $parents = $this->get_parent_module_id($parent, $module, false); - if ($parents === false) - { - return false; - } - - foreach ((array) $parents as $parent_id) - { - $parent_sqls[] = 'AND parent_id = ' . (int) $parent_id; - } - } - else - { - $parent_sqls[] = ''; - } - - foreach ($parent_sqls as $parent_sql) - { - $sql = 'SELECT module_id - FROM ' . $this->modules_table . " - WHERE module_class = '" . $this->db->sql_escape($class) . "' - $parent_sql - AND " . ((is_numeric($module)) ? 'module_id = ' . (int) $module : "module_langname = '" . $this->db->sql_escape($module) . "'"); - $result = $this->db->sql_query($sql); - $module_id = $this->db->sql_fetchfield('module_id'); - $this->db->sql_freeresult($result); - - if (!$lazy && !$module_id) - { - return false; - } - if ($lazy && $module_id) - { - return true; - } - } - - // Returns true, if modules exist in all parents and false otherwise - return !$lazy; - } - - /** - * Module Add - * - * Add a new module - * - * @param string $class The module class(acp|mcp|ucp) - * @param int|string $parent The parent module_id|module_langname (0 for no parent) - * @param array $data an array of the data on the new \module. - * This can be setup in two different ways. - * 1. The "manual" way. For inserting a category or one at a time. - * It will be merged with the base array shown a bit below, - * but at the least requires 'module_langname' to be sent, and, - * if you want to create a module (instead of just a category) you must - * send module_basename and module_mode. - * array( - * 'module_enabled' => 1, - * 'module_display' => 1, - * 'module_basename' => '', - * 'module_class' => $class, - * 'parent_id' => (int) $parent, - * 'module_langname' => '', - * 'module_mode' => '', - * 'module_auth' => '', - * ) - * 2. The "automatic" way. For inserting multiple at a time based on the - * specs in the info file for the module(s). For this to work the - * modules must be correctly setup in the info file. - * An example follows (this would insert the settings, log, and flag - * modes from the includes/acp/info/acp_asacp.php file): - * array( - * 'module_basename' => 'asacp', - * 'modes' => array('settings', 'log', 'flag'), - * ) - * Optionally you may not send 'modes' and it will insert all of the - * modules in that info file. - * path, specify that here - * @return null - * @throws \phpbb\db\migration\exception - */ - public function add($class, $parent = 0, $data = array()) - { - global $user, $phpbb_log; - - // allow sending the name as a string in $data to create a category - if (!is_array($data)) - { - $data = array('module_langname' => $data); - } - - $parents = (array) $this->get_parent_module_id($parent, $data); - - if (!isset($data['module_langname'])) - { - // The "automatic" way - $basename = (isset($data['module_basename'])) ? $data['module_basename'] : ''; - $module = $this->get_module_info($class, $basename); - - foreach ($module['modes'] as $mode => $module_info) - { - if (!isset($data['modes']) || in_array($mode, $data['modes'])) - { - $new_module = array( - 'module_basename' => $basename, - 'module_langname' => $module_info['title'], - 'module_mode' => $mode, - 'module_auth' => $module_info['auth'], - 'module_display' => (isset($module_info['display'])) ? $module_info['display'] : true, - 'before' => (isset($module_info['before'])) ? $module_info['before'] : false, - 'after' => (isset($module_info['after'])) ? $module_info['after'] : false, - ); - - // Run the "manual" way with the data we've collected. - foreach ($parents as $parent) - { - $this->add($class, $parent, $new_module); - } - } - } - - return; - } - - foreach ($parents as $parent) - { - $data['parent_id'] = $parent; - - // The "manual" way - if (!$this->exists($class, false, $parent)) - { - throw new \phpbb\db\migration\exception('MODULE_NOT_EXIST', $parent); - } - - if ($this->exists($class, $parent, $data['module_langname'])) - { - throw new \phpbb\db\migration\exception('MODULE_EXISTS', $data['module_langname']); - } - - $module_data = array( - 'module_enabled' => (isset($data['module_enabled'])) ? $data['module_enabled'] : 1, - 'module_display' => (isset($data['module_display'])) ? $data['module_display'] : 1, - 'module_basename' => (isset($data['module_basename'])) ? $data['module_basename'] : '', - 'module_class' => $class, - 'parent_id' => (int) $parent, - 'module_langname' => (isset($data['module_langname'])) ? $data['module_langname'] : '', - 'module_mode' => (isset($data['module_mode'])) ? $data['module_mode'] : '', - 'module_auth' => (isset($data['module_auth'])) ? $data['module_auth'] : '', - ); - - try - { - $this->module_manager->update_module_data($module_data); - - // Success - $module_log_name = ((isset($this->user->lang[$data['module_langname']])) ? $this->user->lang[$data['module_langname']] : $data['module_langname']); - $phpbb_log->add('admin', (isset($user->data['user_id'])) ? $user->data['user_id'] : ANONYMOUS, $user->ip, 'LOG_MODULE_ADD', false, array($module_log_name)); - - // Move the module if requested above/below an existing one - if (isset($data['before']) && $data['before']) - { - $before_mode = $before_langname = ''; - if (is_array($data['before'])) - { - // Restore legacy-legacy behaviour from phpBB 3.0 - list($before_mode, $before_langname) = $data['before']; - } - else - { - // Legacy behaviour from phpBB 3.1+ - $before_langname = $data['before']; - } - - $sql = 'SELECT left_id - FROM ' . $this->modules_table . " - WHERE module_class = '" . $this->db->sql_escape($class) . "' - AND parent_id = " . (int) $parent . " - AND module_langname = '" . $this->db->sql_escape($before_langname) . "'" - . (($before_mode) ? " AND module_mode = '" . $this->db->sql_escape($before_mode) . "'" : ''); - $result = $this->db->sql_query($sql); - $to_left = (int) $this->db->sql_fetchfield('left_id'); - $this->db->sql_freeresult($result); - - $sql = 'UPDATE ' . $this->modules_table . " - SET left_id = left_id + 2, right_id = right_id + 2 - WHERE module_class = '" . $this->db->sql_escape($class) . "' - AND left_id >= $to_left - AND left_id < {$module_data['left_id']}"; - $this->db->sql_query($sql); - - $sql = 'UPDATE ' . $this->modules_table . " - SET left_id = $to_left, right_id = " . ($to_left + 1) . " - WHERE module_class = '" . $this->db->sql_escape($class) . "' - AND module_id = {$module_data['module_id']}"; - $this->db->sql_query($sql); - } - else if (isset($data['after']) && $data['after']) - { - $after_mode = $after_langname = ''; - if (is_array($data['after'])) - { - // Restore legacy-legacy behaviour from phpBB 3.0 - list($after_mode, $after_langname) = $data['after']; - } - else - { - // Legacy behaviour from phpBB 3.1+ - $after_langname = $data['after']; - } - - $sql = 'SELECT right_id - FROM ' . $this->modules_table . " - WHERE module_class = '" . $this->db->sql_escape($class) . "' - AND parent_id = " . (int) $parent . " - AND module_langname = '" . $this->db->sql_escape($after_langname) . "'" - . (($after_mode) ? " AND module_mode = '" . $this->db->sql_escape($after_mode) . "'" : ''); - $result = $this->db->sql_query($sql); - $to_right = (int) $this->db->sql_fetchfield('right_id'); - $this->db->sql_freeresult($result); - - $sql = 'UPDATE ' . $this->modules_table . " - SET left_id = left_id + 2, right_id = right_id + 2 - WHERE module_class = '" . $this->db->sql_escape($class) . "' - AND left_id >= $to_right - AND left_id < {$module_data['left_id']}"; - $this->db->sql_query($sql); - - $sql = 'UPDATE ' . $this->modules_table . ' - SET left_id = ' . ($to_right + 1) . ', right_id = ' . ($to_right + 2) . " - WHERE module_class = '" . $this->db->sql_escape($class) . "' - AND module_id = {$module_data['module_id']}"; - $this->db->sql_query($sql); - } - } - catch (module_exception $e) - { - // Error - throw new \phpbb\db\migration\exception('MODULE_ERROR', $e->getMessage()); - } - } - - // Clear the Modules Cache - $this->module_manager->remove_cache_file($class); - } - - /** - * Module Remove - * - * Remove a module - * - * @param string $class The module class(acp|mcp|ucp) - * @param int|string|bool $parent The parent module_id|module_langname(0 for no parent). - * Use false to ignore the parent check and check class wide. - * @param int|string $module The module id|module_langname - * specify that here - * @return null - * @throws \phpbb\db\migration\exception - */ - public function remove($class, $parent = 0, $module = '') - { - // Imitation of module_add's "automatic" and "manual" method so the uninstaller works from the same set of instructions for umil_auto - if (is_array($module)) - { - if (isset($module['module_langname'])) - { - // Manual Method - return $this->remove($class, $parent, $module['module_langname']); - } - - // Failed. - if (!isset($module['module_basename'])) - { - throw new \phpbb\db\migration\exception('MODULE_NOT_EXIST'); - } - - // Automatic method - $basename = $module['module_basename']; - $module_info = $this->get_module_info($class, $basename); - - foreach ($module_info['modes'] as $mode => $info) - { - if (!isset($module['modes']) || in_array($mode, $module['modes'])) - { - $this->remove($class, $parent, $info['title']); - } - } - } - else - { - if (!$this->exists($class, $parent, $module, true)) - { - return; - } - - $parent_sql = ''; - if ($parent !== false) - { - $parents = (array) $this->get_parent_module_id($parent, $module); - $parent_sql = 'AND ' . $this->db->sql_in_set('parent_id', $parents); - } - - $module_ids = array(); - if (!is_numeric($module)) - { - $sql = 'SELECT module_id - FROM ' . $this->modules_table . " - WHERE module_langname = '" . $this->db->sql_escape($module) . "' - AND module_class = '" . $this->db->sql_escape($class) . "' - $parent_sql"; - $result = $this->db->sql_query($sql); - while ($module_id = $this->db->sql_fetchfield('module_id')) - { - $module_ids[] = (int) $module_id; - } - $this->db->sql_freeresult($result); - } - else - { - $module_ids[] = (int) $module; - } - - foreach ($module_ids as $module_id) - { - $this->module_manager->delete_module($module_id, $class); - } - - $this->module_manager->remove_cache_file($class); - } - } - - /** - * {@inheritdoc} - */ - public function reverse() - { - $arguments = func_get_args(); - $original_call = array_shift($arguments); - - $call = false; - switch ($original_call) - { - case 'add': - $call = 'remove'; - break; - - case 'remove': - $call = 'add'; - break; - - case 'reverse': - // Reversing a reverse is just the call itself - $call = array_shift($arguments); - break; - } - - if ($call) - { - return call_user_func_array(array(&$this, $call), $arguments); - } - } - - /** - * Wrapper for \acp_modules::get_module_infos() - * - * @param string $class Module Class - * @param string $basename Module Basename - * @return array Module Information - * @throws \phpbb\db\migration\exception - */ - protected function get_module_info($class, $basename) - { - $module = $this->module_manager->get_module_infos($class, $basename, true); - - if (empty($module)) - { - throw new \phpbb\db\migration\exception('MODULE_INFO_FILE_NOT_EXIST', $class, $basename); - } - - return array_pop($module); - } - - /** - * Get the list of installed module categories - * key - module_id - * value - module_langname - * - * @return null - */ - protected function get_categories_list() - { - // Select the top level categories - // and 2nd level [sub]categories - $sql = 'SELECT m2.module_id, m2.module_langname - FROM ' . $this->modules_table . ' m1, ' . $this->modules_table . " m2 - WHERE m1.parent_id = 0 - AND (m1.module_id = m2.module_id OR m2.parent_id = m1.module_id) - ORDER BY m1.module_id, m2.module_id ASC"; - - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - $this->module_categories[(int) $row['module_id']] = $row['module_langname']; - } - $this->db->sql_freeresult($result); - } - - /** - * Get parent module id - * - * @param string|int $parent_id The parent module_id|module_langname - * @param int|string|array $data The module_id, module_langname for existence checking or module data array for adding - * @param bool $throw_exception The flag indicating if exception should be thrown on error - * @return mixed The int parent module_id, an array of int parent module_id values or false - * @throws \phpbb\db\migration\exception - */ - public function get_parent_module_id($parent_id, $data = '', $throw_exception = true) - { - // Allow '' to be sent as 0 - $parent_id = $parent_id ?: 0; - - if (!is_numeric($parent_id)) - { - // Refresh the $module_categories array - $this->get_categories_list(); - - // Search for the parent module_langname - $ids = array_keys($this->module_categories, $parent_id); - - switch (count($ids)) - { - // No parent with the given module_langname exist - case 0: - if ($throw_exception) - { - throw new \phpbb\db\migration\exception('MODULE_NOT_EXIST', $parent_id); - } - - return false; - break; - - // Return the module id - case 1: - return (int) $ids[0]; - break; - - default: - // This represents the old behaviour of phpBB 3.0 - return $ids; - break; - } - } - - return $parent_id; - } -} diff --git a/install/update/new/phpbb/db/migrator.php b/install/update/new/phpbb/db/migrator.php deleted file mode 100644 index 3a1ee75..0000000 --- a/install/update/new/phpbb/db/migrator.php +++ /dev/null @@ -1,1037 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\db; - -use phpbb\db\output_handler\migrator_output_handler_interface; -use phpbb\db\output_handler\null_migrator_output_handler; -use Symfony\Component\DependencyInjection\ContainerAwareInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; - -/** -* The migrator is responsible for applying new migrations in the correct order. -*/ -class migrator -{ - /** - * @var ContainerInterface - */ - protected $container; - - /** @var \phpbb\config\config */ - protected $config; - - /** @var \phpbb\db\driver\driver_interface */ - protected $db; - - /** @var \phpbb\db\tools\tools_interface */ - protected $db_tools; - - /** @var \phpbb\db\migration\helper */ - protected $helper; - - /** @var string */ - protected $table_prefix; - - /** @var string */ - protected $phpbb_root_path; - - /** @var string */ - protected $php_ext; - - /** @var string */ - protected $migrations_table; - - /** - * State of all migrations - * - * (SELECT * FROM migrations table) - * - * @var array - */ - protected $migration_state = array(); - - /** - * Array of all migrations available to be run - * - * @var array - */ - protected $migrations = array(); - - /** - * Array of migrations that have been determined to be fulfillable - * - * @var array - */ - protected $fulfillable_migrations = array(); - - /** - * 'name,' 'class,' and 'state' of the last migration run - * - * 'effectively_installed' set and set to true if the migration was effectively_installed - * - * @var array - */ - protected $last_run_migration = false; - - /** - * The output handler. A null handler is configured by default. - * - * @var migrator_output_handler_interface - */ - protected $output_handler; - - /** - * Constructor of the database migrator - */ - public function __construct(ContainerInterface $container, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\db\tools\tools_interface $db_tools, $migrations_table, $phpbb_root_path, $php_ext, $table_prefix, $tools, \phpbb\db\migration\helper $helper) - { - $this->container = $container; - $this->config = $config; - $this->db = $db; - $this->db_tools = $db_tools; - $this->helper = $helper; - - $this->migrations_table = $migrations_table; - - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - - $this->table_prefix = $table_prefix; - - $this->output_handler = new null_migrator_output_handler(); - - foreach ($tools as $tool) - { - $this->tools[$tool->get_name()] = $tool; - } - - $this->tools['dbtools'] = $this->db_tools; - - $this->load_migration_state(); - } - - /** - * Set the output handler. - * - * @param migrator_output_handler_interface $handler The output handler - */ - public function set_output_handler(migrator_output_handler_interface $handler) - { - $this->output_handler = $handler; - } - - /** - * Loads all migrations and their application state from the database. - * - * @return null - */ - public function load_migration_state() - { - $this->migration_state = array(); - - // prevent errors in case the table does not exist yet - $this->db->sql_return_on_error(true); - - $sql = "SELECT * - FROM " . $this->migrations_table; - $result = $this->db->sql_query($sql); - - if (!$this->db->get_sql_error_triggered()) - { - while ($migration = $this->db->sql_fetchrow($result)) - { - $this->migration_state[$migration['migration_name']] = $migration; - - $this->migration_state[$migration['migration_name']]['migration_depends_on'] = unserialize($migration['migration_depends_on']); - $this->migration_state[$migration['migration_name']]['migration_data_state'] = !empty($migration['migration_data_state']) ? unserialize($migration['migration_data_state']) : ''; - } - } - - $this->db->sql_freeresult($result); - - $this->db->sql_return_on_error(false); - } - - /** - * Get an array with information about the last migration run. - * - * The array contains 'name', 'class' and 'state'. 'effectively_installed' is set - * and set to true if the last migration was effectively_installed. - * - * @return array - */ - public function get_last_run_migration() - { - return $this->last_run_migration; - } - - /** - * Sets the list of available migration class names to the given array. - * - * @param array $class_names An array of migration class names - * @return null - */ - public function set_migrations($class_names) - { - foreach ($class_names as $key => $class) - { - if (!self::is_migration($class)) - { - unset($class_names[$key]); - } - } - - $this->migrations = $class_names; - } - - /** - * Get the list of available migration class names - * - * @return array Array of all migrations available to be run - */ - public function get_migrations() - { - return $this->migrations; - } - - /** - * Get the list of available and not installed migration class names - * - * @return array - */ - public function get_installable_migrations() - { - $unfinished_migrations = array(); - - foreach ($this->migrations as $name) - { - if (!isset($this->migration_state[$name]) || - !$this->migration_state[$name]['migration_schema_done'] || - !$this->migration_state[$name]['migration_data_done']) - { - $unfinished_migrations[] = $name; - } - } - - return $unfinished_migrations; - } - - /** - * Runs a single update step from the next migration to be applied. - * - * The update step can either be a schema or a (partial) data update. To - * check if update() needs to be called again use the finished() method. - * - * @return null - */ - public function update() - { - $this->container->get('dispatcher')->disable(); - $this->update_do(); - $this->container->get('dispatcher')->enable(); - } - - /** - * Get a valid migration name from the migration state array in case the - * supplied name is not in the migration state list. - * - * @param string $name Migration name - * @return string Migration name - */ - protected function get_valid_name($name) - { - // Try falling back to a valid migration name with or without leading backslash - if (!isset($this->migration_state[$name])) - { - $prepended_name = ($name[0] == '\\' ? '' : '\\') . $name; - $prefixless_name = $name[0] == '\\' ? substr($name, 1) : $name; - - if (isset($this->migration_state[$prepended_name])) - { - $name = $prepended_name; - } - else if (isset($this->migration_state[$prefixless_name])) - { - $name = $prefixless_name; - } - } - - return $name; - } - - /** - * Effectively runs a single update step from the next migration to be applied. - * - * @return null - */ - protected function update_do() - { - foreach ($this->migrations as $name) - { - $name = $this->get_valid_name($name); - - if (!isset($this->migration_state[$name]) || - !$this->migration_state[$name]['migration_schema_done'] || - !$this->migration_state[$name]['migration_data_done']) - { - if (!$this->try_apply($name)) - { - continue; - } - else - { - return; - } - } - else - { - $this->output_handler->write(array('MIGRATION_EFFECTIVELY_INSTALLED', $name), migrator_output_handler_interface::VERBOSITY_DEBUG); - } - } - } - - /** - * Attempts to apply a step of the given migration or one of its dependencies - * - * @param string $name The class name of the migration - * @return bool Whether any update step was successfully run - * @throws \phpbb\db\migration\exception - */ - protected function try_apply($name) - { - if (!class_exists($name)) - { - $this->output_handler->write(array('MIGRATION_NOT_VALID', $name), migrator_output_handler_interface::VERBOSITY_DEBUG); - return false; - } - - $migration = $this->get_migration($name); - - $state = (isset($this->migration_state[$name])) ? - $this->migration_state[$name] : - array( - 'migration_depends_on' => $migration->depends_on(), - 'migration_schema_done' => false, - 'migration_data_done' => false, - 'migration_data_state' => '', - 'migration_start_time' => 0, - 'migration_end_time' => 0, - ); - - if (!empty($state['migration_depends_on'])) - { - $this->output_handler->write(array('MIGRATION_APPLY_DEPENDENCIES', $name), migrator_output_handler_interface::VERBOSITY_DEBUG); - } - - foreach ($state['migration_depends_on'] as $depend) - { - $depend = $this->get_valid_name($depend); - - // Test all possible namings before throwing exception - if ($this->unfulfillable($depend) !== false) - { - throw new \phpbb\db\migration\exception('MIGRATION_NOT_FULFILLABLE', $name, $depend); - } - - if (!isset($this->migration_state[$depend]) || - !$this->migration_state[$depend]['migration_schema_done'] || - !$this->migration_state[$depend]['migration_data_done']) - { - return $this->try_apply($depend); - } - } - - $this->last_run_migration = array( - 'name' => $name, - 'class' => $migration, - 'state' => $state, - 'task' => '', - ); - - if (!isset($this->migration_state[$name])) - { - if ($state['migration_start_time'] == 0 && $migration->effectively_installed()) - { - $state = array( - 'migration_depends_on' => $migration->depends_on(), - 'migration_schema_done' => true, - 'migration_data_done' => true, - 'migration_data_state' => '', - 'migration_start_time' => 0, - 'migration_end_time' => 0, - ); - - $this->last_run_migration['effectively_installed'] = true; - - $this->output_handler->write(array('MIGRATION_EFFECTIVELY_INSTALLED', $name), migrator_output_handler_interface::VERBOSITY_VERBOSE); - } - else - { - $state['migration_start_time'] = time(); - } - } - - $this->set_migration_state($name, $state); - - if (!$state['migration_schema_done']) - { - $verbosity = empty($state['migration_data_state']) ? - migrator_output_handler_interface::VERBOSITY_VERBOSE : migrator_output_handler_interface::VERBOSITY_DEBUG; - $this->output_handler->write(array('MIGRATION_SCHEMA_RUNNING', $name), $verbosity); - - $this->last_run_migration['task'] = 'process_schema_step'; - - $total_time = (is_array($state['migration_data_state']) && isset($state['migration_data_state']['_total_time'])) ? - $state['migration_data_state']['_total_time'] : 0.0; - $elapsed_time = microtime(true); - - $steps = $this->helper->get_schema_steps($migration->update_schema()); - $result = $this->process_data_step($steps, $state['migration_data_state']); - - $elapsed_time = microtime(true) - $elapsed_time; - $total_time += $elapsed_time; - - if (is_array($result)) - { - $result['_total_time'] = $total_time; - } - - $state['migration_data_state'] = ($result === true) ? '' : $result; - $state['migration_schema_done'] = ($result === true); - - if ($state['migration_schema_done']) - { - $this->output_handler->write(array('MIGRATION_SCHEMA_DONE', $name, $total_time), migrator_output_handler_interface::VERBOSITY_NORMAL); - } - else - { - $this->output_handler->write(array('MIGRATION_SCHEMA_IN_PROGRESS', $name, $elapsed_time), migrator_output_handler_interface::VERBOSITY_VERY_VERBOSE); - } - } - else if (!$state['migration_data_done']) - { - try - { - $verbosity = empty($state['migration_data_state']) ? - migrator_output_handler_interface::VERBOSITY_VERBOSE : migrator_output_handler_interface::VERBOSITY_DEBUG; - $this->output_handler->write(array('MIGRATION_DATA_RUNNING', $name), $verbosity); - - $this->last_run_migration['task'] = 'process_data_step'; - - $total_time = (is_array($state['migration_data_state']) && isset($state['migration_data_state']['_total_time'])) ? - $state['migration_data_state']['_total_time'] : 0.0; - $elapsed_time = microtime(true); - - $result = $this->process_data_step($migration->update_data(), $state['migration_data_state']); - - $elapsed_time = microtime(true) - $elapsed_time; - $total_time += $elapsed_time; - - if (is_array($result)) - { - $result['_total_time'] = $total_time; - } - - $state['migration_data_state'] = ($result === true) ? '' : $result; - $state['migration_data_done'] = ($result === true); - $state['migration_end_time'] = ($result === true) ? time() : 0; - - if ($state['migration_data_done']) - { - $this->output_handler->write(array('MIGRATION_DATA_DONE', $name, $total_time), migrator_output_handler_interface::VERBOSITY_NORMAL); - } - else - { - $this->output_handler->write(array('MIGRATION_DATA_IN_PROGRESS', $name, $elapsed_time), migrator_output_handler_interface::VERBOSITY_VERY_VERBOSE); - } - } - catch (\phpbb\db\migration\exception $e) - { - // Reset data state and revert the schema changes - $state['migration_data_state'] = ''; - $this->set_migration_state($name, $state); - - $this->revert_do($name); - - throw $e; - } - } - - $this->set_migration_state($name, $state); - - return true; - } - - /** - * Runs a single revert step from the last migration installed - * - * YOU MUST ADD/SET ALL MIGRATIONS THAT COULD BE DEPENDENT ON THE MIGRATION TO REVERT TO BEFORE CALLING THIS METHOD! - * The revert step can either be a schema or a (partial) data revert. To - * check if revert() needs to be called again use the migration_state() method. - * - * @param string $migration String migration name to revert (including any that depend on this migration) - */ - public function revert($migration) - { - $this->container->get('dispatcher')->disable(); - $this->revert_do($migration); - $this->container->get('dispatcher')->enable(); - } - - /** - * Effectively runs a single revert step from the last migration installed - * - * @param string $migration String migration name to revert (including any that depend on this migration) - * @return null - */ - protected function revert_do($migration) - { - if (!isset($this->migration_state[$migration])) - { - // Not installed - return; - } - - foreach ($this->migrations as $name) - { - $state = $this->migration_state($name); - - if ($state && in_array($migration, $state['migration_depends_on']) && ($state['migration_schema_done'] || $state['migration_data_done'])) - { - $this->revert_do($name); - return; - } - } - - $this->try_revert($migration); - } - - /** - * Attempts to revert a step of the given migration or one of its dependencies - * - * @param string $name The class name of the migration - * @return bool Whether any update step was successfully run - */ - protected function try_revert($name) - { - if (!class_exists($name)) - { - return false; - } - - $migration = $this->get_migration($name); - - $state = $this->migration_state[$name]; - - $this->last_run_migration = array( - 'name' => $name, - 'class' => $migration, - 'task' => '', - ); - - if ($state['migration_data_done']) - { - $verbosity = empty($state['migration_data_state']) ? - migrator_output_handler_interface::VERBOSITY_VERBOSE : migrator_output_handler_interface::VERBOSITY_DEBUG; - $this->output_handler->write(array('MIGRATION_REVERT_DATA_RUNNING', $name), $verbosity); - - $total_time = (is_array($state['migration_data_state']) && isset($state['migration_data_state']['_total_time'])) ? - $state['migration_data_state']['_total_time'] : 0.0; - $elapsed_time = microtime(true); - - $steps = array_merge($this->helper->reverse_update_data($migration->update_data()), $migration->revert_data()); - $result = $this->process_data_step($steps, $state['migration_data_state']); - - $elapsed_time = microtime(true) - $elapsed_time; - $total_time += $elapsed_time; - - if (is_array($result)) - { - $result['_total_time'] = $total_time; - } - - $state['migration_data_state'] = ($result === true) ? '' : $result; - $state['migration_data_done'] = ($result === true) ? false : true; - - $this->set_migration_state($name, $state); - - if (!$state['migration_data_done']) - { - $this->output_handler->write(array('MIGRATION_REVERT_DATA_DONE', $name, $total_time), migrator_output_handler_interface::VERBOSITY_NORMAL); - } - else - { - $this->output_handler->write(array('MIGRATION_REVERT_DATA_IN_PROGRESS', $name, $elapsed_time), migrator_output_handler_interface::VERBOSITY_VERY_VERBOSE); - } - } - else if ($state['migration_schema_done']) - { - $verbosity = empty($state['migration_data_state']) ? - migrator_output_handler_interface::VERBOSITY_VERBOSE : migrator_output_handler_interface::VERBOSITY_DEBUG; - $this->output_handler->write(array('MIGRATION_REVERT_SCHEMA_RUNNING', $name), $verbosity); - - $total_time = (is_array($state['migration_data_state']) && isset($state['migration_data_state']['_total_time'])) ? - $state['migration_data_state']['_total_time'] : 0.0; - $elapsed_time = microtime(true); - - $steps = $this->helper->get_schema_steps($migration->revert_schema()); - $result = $this->process_data_step($steps, $state['migration_data_state']); - - $elapsed_time = microtime(true) - $elapsed_time; - $total_time += $elapsed_time; - - if (is_array($result)) - { - $result['_total_time'] = $total_time; - } - - $state['migration_data_state'] = ($result === true) ? '' : $result; - $state['migration_schema_done'] = ($result === true) ? false : true; - - if (!$state['migration_schema_done']) - { - $sql = 'DELETE FROM ' . $this->migrations_table . " - WHERE migration_name = '" . $this->db->sql_escape($name) . "'"; - $this->db->sql_query($sql); - - $this->last_run_migration = false; - unset($this->migration_state[$name]); - - $this->output_handler->write(array('MIGRATION_REVERT_SCHEMA_DONE', $name, $total_time), migrator_output_handler_interface::VERBOSITY_NORMAL); - } - else - { - $this->set_migration_state($name, $state); - - $this->output_handler->write(array('MIGRATION_REVERT_SCHEMA_IN_PROGRESS', $name, $elapsed_time), migrator_output_handler_interface::VERBOSITY_VERY_VERBOSE); - } - } - - return true; - } - - /** - * Process the data step of the migration - * - * @param array $steps The steps to run - * @param bool|string $state Current state of the migration - * @param bool $revert true to revert a data step - * @return bool|string migration state. True if completed, serialized array if not finished - * @throws \phpbb\db\migration\exception - */ - protected function process_data_step($steps, $state, $revert = false) - { - if (count($steps) === 0) - { - return true; - } - - $state = is_array($state) ? $state : false; - - // reverse order of steps if reverting - if ($revert === true) - { - $steps = array_reverse($steps); - } - - $step = $last_result = 0; - if ($state) - { - $step = $state['step']; - - // We send the result from last time to the callable function - $last_result = $state['result']; - } - - try - { - // Result will be null or true if everything completed correctly - // Stop after each update step, to let the updater control the script runtime - $result = $this->run_step($steps[$step], $last_result, $revert); - if (($result !== null && $result !== true) || $step + 1 < count($steps)) - { - return array( - 'result' => $result, - // Move on if the last call finished - 'step' => ($result !== null && $result !== true) ? $step : $step + 1, - ); - } - } - catch (\phpbb\db\migration\exception $e) - { - // We should try rolling back here - foreach ($steps as $reverse_step_identifier => $reverse_step) - { - // If we've reached the current step we can break because we reversed everything that was run - if ($reverse_step_identifier == $step) - { - break; - } - - // Reverse the step that was run - $result = $this->run_step($reverse_step, false, !$revert); - } - - throw $e; - } - - return true; - } - - /** - * Run a single step - * - * An exception should be thrown if an error occurs - * - * @param mixed $step Data step from migration - * @param mixed $last_result Result to pass to the callable (only for 'custom' method) - * @param bool $reverse False to install, True to attempt uninstallation by reversing the call - * @return null - */ - protected function run_step($step, $last_result = 0, $reverse = false) - { - $callable_and_parameters = $this->get_callable_from_step($step, $last_result, $reverse); - - if ($callable_and_parameters === false) - { - return; - } - - $callable = $callable_and_parameters[0]; - $parameters = $callable_and_parameters[1]; - - return call_user_func_array($callable, $parameters); - } - - /** - * Get a callable statement from a data step - * - * @param array $step Data step from migration - * @param mixed $last_result Result to pass to the callable (only for 'custom' method) - * @param bool $reverse False to install, True to attempt uninstallation by reversing the call - * @return array Array with parameters for call_user_func_array(), 0 is the callable, 1 is parameters - * @throws \phpbb\db\migration\exception - */ - protected function get_callable_from_step(array $step, $last_result = 0, $reverse = false) - { - $type = $step[0]; - $parameters = $step[1]; - - $parts = explode('.', $type); - - $class = $parts[0]; - $method = false; - - if (isset($parts[1])) - { - $method = $parts[1]; - } - - switch ($class) - { - case 'if': - if (!isset($parameters[0])) - { - throw new \phpbb\db\migration\exception('MIGRATION_INVALID_DATA_MISSING_CONDITION', $step); - } - - if (!isset($parameters[1])) - { - throw new \phpbb\db\migration\exception('MIGRATION_INVALID_DATA_MISSING_STEP', $step); - } - - if ($reverse) - { - // We might get unexpected results when trying - // to revert this, so just avoid it - return false; - } - - $condition = $parameters[0]; - - if (!$condition || (is_array($condition) && !$this->run_step($condition, $last_result, $reverse))) - { - return false; - } - - $step = $parameters[1]; - - return $this->get_callable_from_step($step); - break; - - case 'custom': - if (!is_callable($parameters[0])) - { - throw new \phpbb\db\migration\exception('MIGRATION_INVALID_DATA_CUSTOM_NOT_CALLABLE', $step); - } - - if ($reverse) - { - return false; - } - else - { - return array( - $parameters[0], - isset($parameters[1]) ? array_merge($parameters[1], array($last_result)) : array($last_result), - ); - } - break; - - default: - if (!$method) - { - throw new \phpbb\db\migration\exception('MIGRATION_INVALID_DATA_UNKNOWN_TYPE', $step); - } - - if (!isset($this->tools[$class])) - { - throw new \phpbb\db\migration\exception('MIGRATION_INVALID_DATA_UNDEFINED_TOOL', $step); - } - - if (!method_exists(get_class($this->tools[$class]), $method)) - { - throw new \phpbb\db\migration\exception('MIGRATION_INVALID_DATA_UNDEFINED_METHOD', $step); - } - - // Attempt to reverse operations - if ($reverse) - { - array_unshift($parameters, $method); - - return array( - array($this->tools[$class], 'reverse'), - $parameters, - ); - } - - return array( - array($this->tools[$class], $method), - $parameters, - ); - break; - } - } - - /** - * Insert/Update migration row into the database - * - * @param string $name Name of the migration - * @param array $state - * @return null - */ - protected function set_migration_state($name, $state) - { - $migration_row = $state; - $migration_row['migration_depends_on'] = serialize($state['migration_depends_on']); - $migration_row['migration_data_state'] = !empty($state['migration_data_state']) ? serialize($state['migration_data_state']) : ''; - - if (isset($this->migration_state[$name])) - { - $sql = 'UPDATE ' . $this->migrations_table . ' - SET ' . $this->db->sql_build_array('UPDATE', $migration_row) . " - WHERE migration_name = '" . $this->db->sql_escape($name) . "'"; - $this->db->sql_query($sql); - } - else - { - $migration_row['migration_name'] = $name; - $sql = 'INSERT INTO ' . $this->migrations_table . ' - ' . $this->db->sql_build_array('INSERT', $migration_row); - $this->db->sql_query($sql); - } - - $this->migration_state[$name] = $state; - - $this->last_run_migration['state'] = $state; - } - - /** - * Checks if a migration's dependencies can even theoretically be satisfied. - * - * @param string $name The class name of the migration - * @return bool|string False if fulfillable, string of missing migration name if unfulfillable - */ - public function unfulfillable($name) - { - $name = $this->get_valid_name($name); - - if (isset($this->migration_state[$name]) || isset($this->fulfillable_migrations[$name])) - { - return false; - } - - if (!class_exists($name)) - { - return $name; - } - - $migration = $this->get_migration($name); - $depends = $migration->depends_on(); - - foreach ($depends as $depend) - { - $depend = $this->get_valid_name($depend); - $unfulfillable = $this->unfulfillable($depend); - if ($unfulfillable !== false) - { - return $unfulfillable; - } - } - $this->fulfillable_migrations[$name] = true; - - return false; - } - - /** - * Checks whether all available, fulfillable migrations have been applied. - * - * @return bool Whether the migrations have been applied - */ - public function finished() - { - foreach ($this->migrations as $name) - { - if (!isset($this->migration_state[$name])) - { - // skip unfulfillable migrations, but fulfillables mean we - // are not finished yet - if ($this->unfulfillable($name) !== false) - { - continue; - } - - return false; - } - - $migration = $this->migration_state[$name]; - - if (!$migration['migration_schema_done'] || !$migration['migration_data_done']) - { - return false; - } - } - - return true; - } - - /** - * Gets a migration state (whether it is installed and to what extent) - * - * @param string $migration String migration name to check if it is installed - * @return bool|array False if the migration has not at all been installed, array - */ - public function migration_state($migration) - { - if (!isset($this->migration_state[$migration])) - { - return false; - } - - return $this->migration_state[$migration]; - } - - /** - * Helper to get a migration - * - * @param string $name Name of the migration - * @return \phpbb\db\migration\migration - */ - protected function get_migration($name) - { - $migration = new $name($this->config, $this->db, $this->db_tools, $this->phpbb_root_path, $this->php_ext, $this->table_prefix); - - if ($migration instanceof ContainerAwareInterface) - { - $migration->setContainer($this->container); - } - - return $migration; - } - - /** - * This function adds all migrations sent to it to the migrations table - * - * THIS SHOULD NOT GENERALLY BE USED! THIS IS FOR THE PHPBB INSTALLER. - * THIS WILL THROW ERRORS IF MIGRATIONS ALREADY EXIST IN THE TABLE, DO NOT CALL MORE THAN ONCE! - * - * @param array $migrations Array of migrations (names) to add to the migrations table - * @return null - */ - public function populate_migrations($migrations) - { - foreach ($migrations as $name) - { - if ($this->migration_state($name) === false) - { - $state = array( - 'migration_depends_on' => $name::depends_on(), - 'migration_schema_done' => true, - 'migration_data_done' => true, - 'migration_data_state' => '', - 'migration_start_time' => time(), - 'migration_end_time' => time(), - ); - $this->set_migration_state($name, $state); - } - } - } - - /** - * Creates the migrations table if it does not exist. - * @return null - */ - public function create_migrations_table() - { - // Make sure migrations have been installed. - if (!$this->db_tools->sql_table_exists($this->table_prefix . 'migrations')) - { - $this->db_tools->sql_create_table($this->table_prefix . 'migrations', array( - 'COLUMNS' => array( - 'migration_name' => array('VCHAR', ''), - 'migration_depends_on' => array('TEXT', ''), - 'migration_schema_done' => array('BOOL', 0), - 'migration_data_done' => array('BOOL', 0), - 'migration_data_state' => array('TEXT', ''), - 'migration_start_time' => array('TIMESTAMP', 0), - 'migration_end_time' => array('TIMESTAMP', 0), - ), - 'PRIMARY_KEY' => 'migration_name', - )); - } - } - - /** - * Check if a class is a migration. - * - * @param string $migration A migration class name - * @return bool Return true if class is a migration, false otherwise - */ - static public function is_migration($migration) - { - if (class_exists($migration)) - { - // Migration classes should extend the abstract class - // phpbb\db\migration\migration (which implements the - // migration_interface) and be instantiable. - $reflector = new \ReflectionClass($migration); - if ($reflector->implementsInterface('\phpbb\db\migration\migration_interface') && $reflector->isInstantiable()) - { - return true; - } - } - - return false; - } -} diff --git a/install/update/new/phpbb/db/tools/mssql.php b/install/update/new/phpbb/db/tools/mssql.php deleted file mode 100644 index 29f816a..0000000 --- a/install/update/new/phpbb/db/tools/mssql.php +++ /dev/null @@ -1,880 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\db\tools; - -/** - * Database Tools for handling cross-db actions such as altering columns, etc. - * Currently not supported is returning SQL for creating tables. - */ -class mssql extends tools -{ - /** - * Is the used MS SQL Server a SQL Server 2000? - * @var bool - */ - protected $is_sql_server_2000; - - /** - * Get the column types for mssql based databases - * - * @return array - */ - public static function get_dbms_type_map() - { - return array( - 'mssql' => array( - 'INT:' => '[int]', - 'BINT' => '[float]', - 'ULINT' => '[int]', - 'UINT' => '[int]', - 'UINT:' => '[int]', - 'TINT:' => '[int]', - 'USINT' => '[int]', - 'BOOL' => '[int]', - 'VCHAR' => '[varchar] (255)', - 'VCHAR:' => '[varchar] (%d)', - 'CHAR:' => '[char] (%d)', - 'XSTEXT' => '[varchar] (1000)', - 'STEXT' => '[varchar] (3000)', - 'TEXT' => '[varchar] (8000)', - 'MTEXT' => '[text]', - 'XSTEXT_UNI'=> '[nvarchar] (100)', - 'STEXT_UNI' => '[nvarchar] (255)', - 'TEXT_UNI' => '[nvarchar] (4000)', - 'MTEXT_UNI' => '[ntext]', - 'TIMESTAMP' => '[int]', - 'DECIMAL' => '[float]', - 'DECIMAL:' => '[float]', - 'PDECIMAL' => '[float]', - 'PDECIMAL:' => '[float]', - 'VCHAR_UNI' => '[nvarchar] (255)', - 'VCHAR_UNI:'=> '[nvarchar] (%d)', - 'VCHAR_CI' => '[nvarchar] (255)', - 'VARBINARY' => '[varchar] (255)', - ), - - 'mssqlnative' => array( - 'INT:' => '[int]', - 'BINT' => '[float]', - 'ULINT' => '[int]', - 'UINT' => '[int]', - 'UINT:' => '[int]', - 'TINT:' => '[int]', - 'USINT' => '[int]', - 'BOOL' => '[int]', - 'VCHAR' => '[varchar] (255)', - 'VCHAR:' => '[varchar] (%d)', - 'CHAR:' => '[char] (%d)', - 'XSTEXT' => '[varchar] (1000)', - 'STEXT' => '[varchar] (3000)', - 'TEXT' => '[varchar] (8000)', - 'MTEXT' => '[text]', - 'XSTEXT_UNI'=> '[nvarchar] (100)', - 'STEXT_UNI' => '[nvarchar] (255)', - 'TEXT_UNI' => '[nvarchar] (4000)', - 'MTEXT_UNI' => '[ntext]', - 'TIMESTAMP' => '[int]', - 'DECIMAL' => '[float]', - 'DECIMAL:' => '[float]', - 'PDECIMAL' => '[float]', - 'PDECIMAL:' => '[float]', - 'VCHAR_UNI' => '[nvarchar] (255)', - 'VCHAR_UNI:'=> '[nvarchar] (%d)', - 'VCHAR_CI' => '[nvarchar] (255)', - 'VARBINARY' => '[varchar] (255)', - ), - ); - } - - /** - * Constructor. Set DB Object and set {@link $return_statements return_statements}. - * - * @param \phpbb\db\driver\driver_interface $db Database connection - * @param bool $return_statements True if only statements should be returned and no SQL being executed - */ - public function __construct(\phpbb\db\driver\driver_interface $db, $return_statements = false) - { - parent::__construct($db, $return_statements); - - // Determine mapping database type - switch ($this->db->get_sql_layer()) - { - case 'mssql_odbc': - $this->sql_layer = 'mssql'; - break; - - case 'mssqlnative': - $this->sql_layer = 'mssqlnative'; - break; - } - - $this->dbms_type_map = self::get_dbms_type_map(); - } - - /** - * {@inheritDoc} - */ - function sql_list_tables() - { - $sql = "SELECT name - FROM sysobjects - WHERE type='U'"; - $result = $this->db->sql_query($sql); - - $tables = array(); - while ($row = $this->db->sql_fetchrow($result)) - { - $name = current($row); - $tables[$name] = $name; - } - $this->db->sql_freeresult($result); - - return $tables; - } - - /** - * {@inheritDoc} - */ - function sql_create_table($table_name, $table_data) - { - // holds the DDL for a column - $columns = $statements = array(); - - if ($this->sql_table_exists($table_name)) - { - return $this->_sql_run_sql($statements); - } - - // Begin transaction - $statements[] = 'begin'; - - // Determine if we have created a PRIMARY KEY in the earliest - $primary_key_gen = false; - - // Determine if the table requires a sequence - $create_sequence = false; - - // Begin table sql statement - $table_sql = 'CREATE TABLE [' . $table_name . '] (' . "\n"; - - if (!isset($table_data['PRIMARY_KEY'])) - { - $table_data['COLUMNS']['mssqlindex'] = array('UINT', null, 'auto_increment'); - $table_data['PRIMARY_KEY'] = 'mssqlindex'; - } - - // Iterate through the columns to create a table - foreach ($table_data['COLUMNS'] as $column_name => $column_data) - { - // here lies an array, filled with information compiled on the column's data - $prepared_column = $this->sql_prepare_column_data($table_name, $column_name, $column_data); - - if (isset($prepared_column['auto_increment']) && $prepared_column['auto_increment'] && strlen($column_name) > 26) // "${column_name}_gen" - { - trigger_error("Index name '${column_name}_gen' on table '$table_name' is too long. The maximum auto increment column length is 26 characters.", E_USER_ERROR); - } - - // here we add the definition of the new column to the list of columns - $columns[] = "\t [{$column_name}] " . $prepared_column['column_type_sql_default']; - - // see if we have found a primary key set due to a column definition if we have found it, we can stop looking - if (!$primary_key_gen) - { - $primary_key_gen = isset($prepared_column['primary_key_set']) && $prepared_column['primary_key_set']; - } - - // create sequence DDL based off of the existence of auto incrementing columns - if (!$create_sequence && isset($prepared_column['auto_increment']) && $prepared_column['auto_increment']) - { - $create_sequence = $column_name; - } - } - - // this makes up all the columns in the create table statement - $table_sql .= implode(",\n", $columns); - - // Close the table for two DBMS and add to the statements - $table_sql .= "\n);"; - $statements[] = $table_sql; - - // we have yet to create a primary key for this table, - // this means that we can add the one we really wanted instead - if (!$primary_key_gen) - { - // Write primary key - if (isset($table_data['PRIMARY_KEY'])) - { - if (!is_array($table_data['PRIMARY_KEY'])) - { - $table_data['PRIMARY_KEY'] = array($table_data['PRIMARY_KEY']); - } - - // We need the data here - $old_return_statements = $this->return_statements; - $this->return_statements = true; - - $primary_key_stmts = $this->sql_create_primary_key($table_name, $table_data['PRIMARY_KEY']); - foreach ($primary_key_stmts as $pk_stmt) - { - $statements[] = $pk_stmt; - } - - $this->return_statements = $old_return_statements; - } - } - - // Write Keys - if (isset($table_data['KEYS'])) - { - foreach ($table_data['KEYS'] as $key_name => $key_data) - { - if (!is_array($key_data[1])) - { - $key_data[1] = array($key_data[1]); - } - - $old_return_statements = $this->return_statements; - $this->return_statements = true; - - $key_stmts = ($key_data[0] == 'UNIQUE') ? $this->sql_create_unique_index($table_name, $key_name, $key_data[1]) : $this->sql_create_index($table_name, $key_name, $key_data[1]); - - foreach ($key_stmts as $key_stmt) - { - $statements[] = $key_stmt; - } - - $this->return_statements = $old_return_statements; - } - } - - // Commit Transaction - $statements[] = 'commit'; - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritDoc} - */ - function sql_list_columns($table_name) - { - $columns = array(); - - $sql = "SELECT c.name - FROM syscolumns c - LEFT JOIN sysobjects o ON c.id = o.id - WHERE o.name = '{$table_name}'"; - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - $column = strtolower(current($row)); - $columns[$column] = $column; - } - $this->db->sql_freeresult($result); - - return $columns; - } - - /** - * {@inheritDoc} - */ - function sql_index_exists($table_name, $index_name) - { - $sql = "EXEC sp_statistics '$table_name'"; - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - if ($row['TYPE'] == 3) - { - if (strtolower($row['INDEX_NAME']) == strtolower($index_name)) - { - $this->db->sql_freeresult($result); - return true; - } - } - } - $this->db->sql_freeresult($result); - - return false; - } - - /** - * {@inheritDoc} - */ - function sql_unique_index_exists($table_name, $index_name) - { - $sql = "EXEC sp_statistics '$table_name'"; - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - // Usually NON_UNIQUE is the column we want to check, but we allow for both - if ($row['TYPE'] == 3) - { - if (strtolower($row['INDEX_NAME']) == strtolower($index_name)) - { - $this->db->sql_freeresult($result); - return true; - } - } - } - $this->db->sql_freeresult($result); - - return false; - } - - /** - * {@inheritDoc} - */ - function sql_prepare_column_data($table_name, $column_name, $column_data) - { - if (strlen($column_name) > 30) - { - trigger_error("Column name '$column_name' on table '$table_name' is too long. The maximum is 30 characters.", E_USER_ERROR); - } - - // Get type - list($column_type, ) = $this->get_column_type($column_data[0]); - - // Adjust default value if db-dependent specified - if (is_array($column_data[1])) - { - $column_data[1] = (isset($column_data[1][$this->sql_layer])) ? $column_data[1][$this->sql_layer] : $column_data[1]['default']; - } - - $sql = ''; - - $return_array = array(); - - $sql .= " {$column_type} "; - $sql_default = " {$column_type} "; - - // For adding columns we need the default definition - if (!is_null($column_data[1])) - { - // For hexadecimal values do not use single quotes - if (strpos($column_data[1], '0x') === 0) - { - $return_array['default'] = 'DEFAULT (' . $column_data[1] . ') '; - $sql_default .= $return_array['default']; - } - else - { - $return_array['default'] = 'DEFAULT (' . ((is_numeric($column_data[1])) ? $column_data[1] : "'{$column_data[1]}'") . ') '; - $sql_default .= $return_array['default']; - } - } - - if (isset($column_data[2]) && $column_data[2] == 'auto_increment') - { - // $sql .= 'IDENTITY (1, 1) '; - $sql_default .= 'IDENTITY (1, 1) '; - } - - $return_array['textimage'] = $column_type === '[text]'; - - if (!is_null($column_data[1]) || (isset($column_data[2]) && $column_data[2] == 'auto_increment')) - { - $sql .= 'NOT NULL'; - $sql_default .= 'NOT NULL'; - } - else - { - $sql .= 'NULL'; - $sql_default .= 'NULL'; - } - - $return_array['column_type_sql_default'] = $sql_default; - - $return_array['column_type_sql'] = $sql; - - return $return_array; - } - - /** - * {@inheritDoc} - */ - function sql_column_add($table_name, $column_name, $column_data, $inline = false) - { - $column_data = $this->sql_prepare_column_data($table_name, $column_name, $column_data); - $statements = array(); - - // Does not support AFTER, only through temporary table - $statements[] = 'ALTER TABLE [' . $table_name . '] ADD [' . $column_name . '] ' . $column_data['column_type_sql_default']; - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritDoc} - */ - function sql_column_remove($table_name, $column_name, $inline = false) - { - $statements = array(); - - // We need the data here - $old_return_statements = $this->return_statements; - $this->return_statements = true; - - $indexes = $this->get_existing_indexes($table_name, $column_name); - $indexes = array_merge($indexes, $this->get_existing_indexes($table_name, $column_name, true)); - - // Drop any indexes - $recreate_indexes = array(); - if (!empty($indexes)) - { - foreach ($indexes as $index_name => $index_data) - { - $result = $this->sql_index_drop($table_name, $index_name); - $statements = array_merge($statements, $result); - if (count($index_data) > 1) - { - // Remove this column from the index and recreate it - $recreate_indexes[$index_name] = array_diff($index_data, array($column_name)); - } - } - } - - // Drop primary keys depending on this column - $result = $this->mssql_get_drop_default_primary_key_queries($table_name, $column_name); - $statements = array_merge($statements, $result); - - // Drop default value constraint - $result = $this->mssql_get_drop_default_constraints_queries($table_name, $column_name); - $statements = array_merge($statements, $result); - - // Remove the column - $statements[] = 'ALTER TABLE [' . $table_name . '] DROP COLUMN [' . $column_name . ']'; - - if (!empty($recreate_indexes)) - { - // Recreate indexes after we removed the column - foreach ($recreate_indexes as $index_name => $index_data) - { - $result = $this->sql_create_index($table_name, $index_name, $index_data); - $statements = array_merge($statements, $result); - } - } - - $this->return_statements = $old_return_statements; - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritDoc} - */ - function sql_index_drop($table_name, $index_name) - { - $statements = array(); - - $statements[] = 'DROP INDEX [' . $table_name . '].[' . $index_name . ']'; - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritDoc} - */ - function sql_table_drop($table_name) - { - $statements = array(); - - if (!$this->sql_table_exists($table_name)) - { - return $this->_sql_run_sql($statements); - } - - // the most basic operation, get rid of the table - $statements[] = 'DROP TABLE ' . $table_name; - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritDoc} - */ - function sql_create_primary_key($table_name, $column, $inline = false) - { - $statements = array(); - - $sql = "ALTER TABLE [{$table_name}] WITH NOCHECK ADD "; - $sql .= "CONSTRAINT [PK_{$table_name}] PRIMARY KEY CLUSTERED ("; - $sql .= '[' . implode("],\n\t\t[", $column) . ']'; - $sql .= ')'; - - $statements[] = $sql; - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritDoc} - */ - function sql_create_unique_index($table_name, $index_name, $column) - { - $statements = array(); - - if ($this->mssql_is_sql_server_2000()) - { - $this->check_index_name_length($table_name, $index_name); - } - - $statements[] = 'CREATE UNIQUE INDEX [' . $index_name . '] ON [' . $table_name . ']([' . implode('], [', $column) . '])'; - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritDoc} - */ - function sql_create_index($table_name, $index_name, $column) - { - $statements = array(); - - $this->check_index_name_length($table_name, $index_name); - - // remove index length - $column = preg_replace('#:.*$#', '', $column); - - $statements[] = 'CREATE INDEX [' . $index_name . '] ON [' . $table_name . ']([' . implode('], [', $column) . '])'; - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritdoc} - */ - protected function get_max_index_name_length() - { - if ($this->mssql_is_sql_server_2000()) - { - return parent::get_max_index_name_length(); - } - else - { - return 128; - } - } - - /** - * {@inheritDoc} - */ - function sql_list_index($table_name) - { - $index_array = array(); - $sql = "EXEC sp_statistics '$table_name'"; - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - if ($row['TYPE'] == 3) - { - $index_array[] = strtolower($row['INDEX_NAME']); - } - } - $this->db->sql_freeresult($result); - - return $index_array; - } - - /** - * {@inheritDoc} - */ - function sql_column_change($table_name, $column_name, $column_data, $inline = false) - { - $column_data = $this->sql_prepare_column_data($table_name, $column_name, $column_data); - $statements = array(); - - // We need the data here - $old_return_statements = $this->return_statements; - $this->return_statements = true; - - $indexes = $this->get_existing_indexes($table_name, $column_name); - $unique_indexes = $this->get_existing_indexes($table_name, $column_name, true); - - // Drop any indexes - if (!empty($indexes) || !empty($unique_indexes)) - { - $drop_indexes = array_merge(array_keys($indexes), array_keys($unique_indexes)); - foreach ($drop_indexes as $index_name) - { - $result = $this->sql_index_drop($table_name, $index_name); - $statements = array_merge($statements, $result); - } - } - - // Drop default value constraint - $result = $this->mssql_get_drop_default_constraints_queries($table_name, $column_name); - $statements = array_merge($statements, $result); - - // Change the column - $statements[] = 'ALTER TABLE [' . $table_name . '] ALTER COLUMN [' . $column_name . '] ' . $column_data['column_type_sql']; - - if (!empty($column_data['default']) && !$this->mssql_is_column_identity($table_name, $column_name)) - { - // Add new default value constraint - $statements[] = 'ALTER TABLE [' . $table_name . '] ADD CONSTRAINT [DF_' . $table_name . '_' . $column_name . '_1] ' . $column_data['default'] . ' FOR [' . $column_name . ']'; - } - - if (!empty($indexes)) - { - // Recreate indexes after we changed the column - foreach ($indexes as $index_name => $index_data) - { - $result = $this->sql_create_index($table_name, $index_name, $index_data); - $statements = array_merge($statements, $result); - } - } - - if (!empty($unique_indexes)) - { - // Recreate unique indexes after we changed the column - foreach ($unique_indexes as $index_name => $index_data) - { - $result = $this->sql_create_unique_index($table_name, $index_name, $index_data); - $statements = array_merge($statements, $result); - } - } - - $this->return_statements = $old_return_statements; - - return $this->_sql_run_sql($statements); - } - - /** - * Get queries to drop the default constraints of a column - * - * We need to drop the default constraints of a column, - * before being able to change their type or deleting them. - * - * @param string $table_name - * @param string $column_name - * @return array Array with SQL statements - */ - protected function mssql_get_drop_default_constraints_queries($table_name, $column_name) - { - $statements = array(); - if ($this->mssql_is_sql_server_2000()) - { - // http://msdn.microsoft.com/en-us/library/aa175912%28v=sql.80%29.aspx - // Deprecated in SQL Server 2005 - $sql = "SELECT so.name AS def_name - FROM sysobjects so - JOIN sysconstraints sc ON so.id = sc.constid - WHERE object_name(so.parent_obj) = '{$table_name}' - AND so.xtype = 'D' - AND sc.colid = (SELECT colid FROM syscolumns - WHERE id = object_id('{$table_name}') - AND name = '{$column_name}')"; - } - else - { - $sql = "SELECT dobj.name AS def_name - FROM sys.columns col - LEFT OUTER JOIN sys.objects dobj ON (dobj.object_id = col.default_object_id AND dobj.type = 'D') - WHERE col.object_id = object_id('{$table_name}') - AND col.name = '{$column_name}' - AND dobj.name IS NOT NULL"; - } - - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - $statements[] = 'ALTER TABLE [' . $table_name . '] DROP CONSTRAINT [' . $row['def_name'] . ']'; - } - $this->db->sql_freeresult($result); - - return $statements; - } - - /** - * Get queries to drop the primary keys depending on the specified column - * - * We need to drop primary keys depending on this column before being able - * to delete them. - * - * @param string $table_name - * @param string $column_name - * @return array Array with SQL statements - */ - protected function mssql_get_drop_default_primary_key_queries($table_name, $column_name) - { - $statements = array(); - - $sql = "SELECT ccu.CONSTRAINT_NAME, ccu.COLUMN_NAME - FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc - JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu ON tc.CONSTRAINT_NAME = ccu.Constraint_name - WHERE tc.TABLE_NAME = '{$table_name}' - AND tc.CONSTRAINT_TYPE = 'Primary Key' - AND ccu.COLUMN_NAME = '{$column_name}'"; - - $result = $this->db->sql_query($sql); - - while ($primary_key = $this->db->sql_fetchrow($result)) - { - $statements[] = 'ALTER TABLE [' . $table_name . '] DROP CONSTRAINT [' . $primary_key['CONSTRAINT_NAME'] . ']'; - } - $this->db->sql_freeresult($result); - - return $statements; - } - - /** - * Checks to see if column is an identity column - * - * Identity columns cannot have defaults set for them. - * - * @param string $table_name - * @param string $column_name - * @return bool true if identity, false if not - */ - protected function mssql_is_column_identity($table_name, $column_name) - { - if ($this->mssql_is_sql_server_2000()) - { - // http://msdn.microsoft.com/en-us/library/aa175912%28v=sql.80%29.aspx - // Deprecated in SQL Server 2005 - $sql = "SELECT COLUMNPROPERTY(object_id('{$table_name}'), '{$column_name}', 'IsIdentity') AS is_identity"; - } - else - { - $sql = "SELECT is_identity FROM sys.columns - WHERE object_id = object_id('{$table_name}') - AND name = '{$column_name}'"; - } - - $result = $this->db->sql_query($sql); - $is_identity = $this->db->sql_fetchfield('is_identity'); - $this->db->sql_freeresult($result); - - return (bool) $is_identity; - } - - /** - * Get a list with existing indexes for the column - * - * @param string $table_name - * @param string $column_name - * @param bool $unique Should we get unique indexes or normal ones - * @return array Array with Index name => columns - */ - public function get_existing_indexes($table_name, $column_name, $unique = false) - { - $existing_indexes = array(); - if ($this->mssql_is_sql_server_2000()) - { - // http://msdn.microsoft.com/en-us/library/aa175912%28v=sql.80%29.aspx - // Deprecated in SQL Server 2005 - $sql = "SELECT DISTINCT ix.name AS phpbb_index_name - FROM sysindexes ix - INNER JOIN sysindexkeys ixc - ON ixc.id = ix.id - AND ixc.indid = ix.indid - INNER JOIN syscolumns cols - ON cols.colid = ixc.colid - AND cols.id = ix.id - WHERE ix.id = object_id('{$table_name}') - AND cols.name = '{$column_name}' - AND INDEXPROPERTY(ix.id, ix.name, 'IsUnique') = " . ($unique ? '1' : '0'); - } - else - { - $sql = "SELECT DISTINCT ix.name AS phpbb_index_name - FROM sys.indexes ix - INNER JOIN sys.index_columns ixc - ON ixc.object_id = ix.object_id - AND ixc.index_id = ix.index_id - INNER JOIN sys.columns cols - ON cols.column_id = ixc.column_id - AND cols.object_id = ix.object_id - WHERE ix.object_id = object_id('{$table_name}') - AND cols.name = '{$column_name}' - AND ix.is_primary_key = 0 - AND ix.is_unique = " . ($unique ? '1' : '0'); - } - - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - if (!isset($row['is_unique']) || ($unique && $row['is_unique'] == 'UNIQUE') || (!$unique && $row['is_unique'] == 'NONUNIQUE')) - { - $existing_indexes[$row['phpbb_index_name']] = array(); - } - } - $this->db->sql_freeresult($result); - - if (empty($existing_indexes)) - { - return array(); - } - - if ($this->mssql_is_sql_server_2000()) - { - $sql = "SELECT DISTINCT ix.name AS phpbb_index_name, cols.name AS phpbb_column_name - FROM sysindexes ix - INNER JOIN sysindexkeys ixc - ON ixc.id = ix.id - AND ixc.indid = ix.indid - INNER JOIN syscolumns cols - ON cols.colid = ixc.colid - AND cols.id = ix.id - WHERE ix.id = object_id('{$table_name}') - AND " . $this->db->sql_in_set('ix.name', array_keys($existing_indexes)); - } - else - { - $sql = "SELECT DISTINCT ix.name AS phpbb_index_name, cols.name AS phpbb_column_name - FROM sys.indexes ix - INNER JOIN sys.index_columns ixc - ON ixc.object_id = ix.object_id - AND ixc.index_id = ix.index_id - INNER JOIN sys.columns cols - ON cols.column_id = ixc.column_id - AND cols.object_id = ix.object_id - WHERE ix.object_id = object_id('{$table_name}') - AND " . $this->db->sql_in_set('ix.name', array_keys($existing_indexes)); - } - - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - $existing_indexes[$row['phpbb_index_name']][] = $row['phpbb_column_name']; - } - $this->db->sql_freeresult($result); - - return $existing_indexes; - } - - /** - * Is the used MS SQL Server a SQL Server 2000? - * - * @return bool - */ - protected function mssql_is_sql_server_2000() - { - if ($this->is_sql_server_2000 === null) - { - $sql = "SELECT CAST(SERVERPROPERTY('productversion') AS VARCHAR(25)) AS mssql_version"; - $result = $this->db->sql_query($sql); - $properties = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - $this->is_sql_server_2000 = $properties['mssql_version'][0] == '8'; - } - - return $this->is_sql_server_2000; - } - -} diff --git a/install/update/new/phpbb/db/tools/postgres.php b/install/update/new/phpbb/db/tools/postgres.php deleted file mode 100644 index 276ac13..0000000 --- a/install/update/new/phpbb/db/tools/postgres.php +++ /dev/null @@ -1,614 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\db\tools; - -/** - * Database Tools for handling cross-db actions such as altering columns, etc. - * Currently not supported is returning SQL for creating tables. - */ -class postgres extends tools -{ - /** - * Get the column types for postgres only - * - * @return array - */ - public static function get_dbms_type_map() - { - return array( - 'postgres' => array( - 'INT:' => 'INT4', - 'BINT' => 'INT8', - 'ULINT' => 'INT4', // unsigned - 'UINT' => 'INT4', // unsigned - 'UINT:' => 'INT4', // unsigned - 'USINT' => 'INT2', // unsigned - 'BOOL' => 'INT2', // unsigned - 'TINT:' => 'INT2', - 'VCHAR' => 'varchar(255)', - 'VCHAR:' => 'varchar(%d)', - 'CHAR:' => 'char(%d)', - 'XSTEXT' => 'varchar(1000)', - 'STEXT' => 'varchar(3000)', - 'TEXT' => 'varchar(8000)', - 'MTEXT' => 'TEXT', - 'XSTEXT_UNI'=> 'varchar(100)', - 'STEXT_UNI' => 'varchar(255)', - 'TEXT_UNI' => 'varchar(4000)', - 'MTEXT_UNI' => 'TEXT', - 'TIMESTAMP' => 'INT4', // unsigned - 'DECIMAL' => 'decimal(5,2)', - 'DECIMAL:' => 'decimal(%d,2)', - 'PDECIMAL' => 'decimal(6,3)', - 'PDECIMAL:' => 'decimal(%d,3)', - 'VCHAR_UNI' => 'varchar(255)', - 'VCHAR_UNI:'=> 'varchar(%d)', - 'VCHAR_CI' => 'varchar_ci', - 'VARBINARY' => 'bytea', - ), - ); - } - - /** - * Constructor. Set DB Object and set {@link $return_statements return_statements}. - * - * @param \phpbb\db\driver\driver_interface $db Database connection - * @param bool $return_statements True if only statements should be returned and no SQL being executed - */ - public function __construct(\phpbb\db\driver\driver_interface $db, $return_statements = false) - { - parent::__construct($db, $return_statements); - - // Determine mapping database type - $this->sql_layer = 'postgres'; - - $this->dbms_type_map = self::get_dbms_type_map(); - } - - /** - * {@inheritDoc} - */ - function sql_list_tables() - { - $sql = 'SELECT relname - FROM pg_stat_user_tables'; - $result = $this->db->sql_query($sql); - - $tables = array(); - while ($row = $this->db->sql_fetchrow($result)) - { - $name = current($row); - $tables[$name] = $name; - } - $this->db->sql_freeresult($result); - - return $tables; - } - - /** - * {@inheritDoc} - */ - function sql_create_table($table_name, $table_data) - { - // holds the DDL for a column - $columns = $statements = array(); - - if ($this->sql_table_exists($table_name)) - { - return $this->_sql_run_sql($statements); - } - - // Begin transaction - $statements[] = 'begin'; - - // Determine if we have created a PRIMARY KEY in the earliest - $primary_key_gen = false; - - // Determine if the table requires a sequence - $create_sequence = false; - - // Begin table sql statement - $table_sql = 'CREATE TABLE ' . $table_name . ' (' . "\n"; - - // Iterate through the columns to create a table - foreach ($table_data['COLUMNS'] as $column_name => $column_data) - { - // here lies an array, filled with information compiled on the column's data - $prepared_column = $this->sql_prepare_column_data($table_name, $column_name, $column_data); - - if (isset($prepared_column['auto_increment']) && $prepared_column['auto_increment'] && strlen($column_name) > 26) // "${column_name}_gen" - { - trigger_error("Index name '${column_name}_gen' on table '$table_name' is too long. The maximum auto increment column length is 26 characters.", E_USER_ERROR); - } - - // here we add the definition of the new column to the list of columns - $columns[] = "\t {$column_name} " . $prepared_column['column_type_sql']; - - // see if we have found a primary key set due to a column definition if we have found it, we can stop looking - if (!$primary_key_gen) - { - $primary_key_gen = isset($prepared_column['primary_key_set']) && $prepared_column['primary_key_set']; - } - - // create sequence DDL based off of the existence of auto incrementing columns - if (!$create_sequence && isset($prepared_column['auto_increment']) && $prepared_column['auto_increment']) - { - $create_sequence = $column_name; - } - } - - // this makes up all the columns in the create table statement - $table_sql .= implode(",\n", $columns); - - // we have yet to create a primary key for this table, - // this means that we can add the one we really wanted instead - if (!$primary_key_gen) - { - // Write primary key - if (isset($table_data['PRIMARY_KEY'])) - { - if (!is_array($table_data['PRIMARY_KEY'])) - { - $table_data['PRIMARY_KEY'] = array($table_data['PRIMARY_KEY']); - } - - $table_sql .= ",\n\t PRIMARY KEY (" . implode(', ', $table_data['PRIMARY_KEY']) . ')'; - } - } - - // do we need to add a sequence for auto incrementing columns? - if ($create_sequence) - { - $statements[] = "CREATE SEQUENCE {$table_name}_seq;"; - } - - // close the table - $table_sql .= "\n);"; - $statements[] = $table_sql; - - // Write Keys - if (isset($table_data['KEYS'])) - { - foreach ($table_data['KEYS'] as $key_name => $key_data) - { - if (!is_array($key_data[1])) - { - $key_data[1] = array($key_data[1]); - } - - $old_return_statements = $this->return_statements; - $this->return_statements = true; - - $key_stmts = ($key_data[0] == 'UNIQUE') ? $this->sql_create_unique_index($table_name, $key_name, $key_data[1]) : $this->sql_create_index($table_name, $key_name, $key_data[1]); - - foreach ($key_stmts as $key_stmt) - { - $statements[] = $key_stmt; - } - - $this->return_statements = $old_return_statements; - } - } - - // Commit Transaction - $statements[] = 'commit'; - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritDoc} - */ - function sql_list_columns($table_name) - { - $columns = array(); - - $sql = "SELECT a.attname - FROM pg_class c, pg_attribute a - WHERE c.relname = '{$table_name}' - AND a.attnum > 0 - AND a.attrelid = c.oid"; - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - $column = strtolower(current($row)); - $columns[$column] = $column; - } - $this->db->sql_freeresult($result); - - return $columns; - } - - /** - * {@inheritDoc} - */ - function sql_index_exists($table_name, $index_name) - { - $sql = "SELECT ic.relname as index_name - FROM pg_class bc, pg_class ic, pg_index i - WHERE (bc.oid = i.indrelid) - AND (ic.oid = i.indexrelid) - AND (bc.relname = '" . $table_name . "') - AND (i.indisunique != 't') - AND (i.indisprimary != 't')"; - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - // This DBMS prefixes index names with the table name - $row['index_name'] = $this->strip_table_name_from_index_name($table_name, $row['index_name']); - - if (strtolower($row['index_name']) == strtolower($index_name)) - { - $this->db->sql_freeresult($result); - return true; - } - } - $this->db->sql_freeresult($result); - - return false; - } - - /** - * {@inheritDoc} - */ - function sql_unique_index_exists($table_name, $index_name) - { - $sql = "SELECT ic.relname as index_name, i.indisunique - FROM pg_class bc, pg_class ic, pg_index i - WHERE (bc.oid = i.indrelid) - AND (ic.oid = i.indexrelid) - AND (bc.relname = '" . $table_name . "') - AND (i.indisprimary != 't')"; - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - if ($row['indisunique'] != 't') - { - continue; - } - - // This DBMS prefixes index names with the table name - $row['index_name'] = $this->strip_table_name_from_index_name($table_name, $row['index_name']); - - if (strtolower($row['index_name']) == strtolower($index_name)) - { - $this->db->sql_freeresult($result); - return true; - } - } - $this->db->sql_freeresult($result); - - return false; - } - - /** - * Function to prepare some column information for better usage - * @access private - */ - function sql_prepare_column_data($table_name, $column_name, $column_data) - { - if (strlen($column_name) > 30) - { - trigger_error("Column name '$column_name' on table '$table_name' is too long. The maximum is 30 characters.", E_USER_ERROR); - } - - // Get type - list($column_type, $orig_column_type) = $this->get_column_type($column_data[0]); - - // Adjust default value if db-dependent specified - if (is_array($column_data[1])) - { - $column_data[1] = (isset($column_data[1][$this->sql_layer])) ? $column_data[1][$this->sql_layer] : $column_data[1]['default']; - } - - $sql = " {$column_type} "; - - $return_array = array( - 'column_type' => $column_type, - 'auto_increment' => false, - ); - - if (isset($column_data[2]) && $column_data[2] == 'auto_increment') - { - $default_val = "nextval('{$table_name}_seq')"; - $return_array['auto_increment'] = true; - } - else if (!is_null($column_data[1])) - { - $default_val = "'" . $column_data[1] . "'"; - $return_array['null'] = 'NOT NULL'; - $sql .= 'NOT NULL '; - } - else - { - // Integers need to have 0 instead of empty string as default - if (strpos($column_type, 'INT') === 0) - { - $default_val = '0'; - } - else - { - $default_val = "'" . $column_data[1] . "'"; - } - $return_array['null'] = 'NULL'; - $sql .= 'NULL '; - } - - $return_array['default'] = $default_val; - - $sql .= "DEFAULT {$default_val}"; - - // Unsigned? Then add a CHECK contraint - if (in_array($orig_column_type, $this->unsigned_types)) - { - $return_array['constraint'] = "CHECK ({$column_name} >= 0)"; - $sql .= " CHECK ({$column_name} >= 0)"; - } - - $return_array['column_type_sql'] = $sql; - - return $return_array; - } - - /** - * {@inheritDoc} - */ - function sql_column_add($table_name, $column_name, $column_data, $inline = false) - { - $column_data = $this->sql_prepare_column_data($table_name, $column_name, $column_data); - $statements = array(); - - // Does not support AFTER, only through temporary table - if (version_compare($this->db->sql_server_info(true), '8.0', '>=')) - { - $statements[] = 'ALTER TABLE ' . $table_name . ' ADD COLUMN "' . $column_name . '" ' . $column_data['column_type_sql']; - } - else - { - // old versions cannot add columns with default and null information - $statements[] = 'ALTER TABLE ' . $table_name . ' ADD COLUMN "' . $column_name . '" ' . $column_data['column_type'] . ' ' . $column_data['constraint']; - - if (isset($column_data['null'])) - { - if ($column_data['null'] == 'NOT NULL') - { - $statements[] = 'ALTER TABLE ' . $table_name . ' ALTER COLUMN ' . $column_name . ' SET NOT NULL'; - } - } - - if (isset($column_data['default'])) - { - $statements[] = 'ALTER TABLE ' . $table_name . ' ALTER COLUMN ' . $column_name . ' SET DEFAULT ' . $column_data['default']; - } - } - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritDoc} - */ - function sql_column_remove($table_name, $column_name, $inline = false) - { - $statements = array(); - - $statements[] = 'ALTER TABLE ' . $table_name . ' DROP COLUMN "' . $column_name . '"'; - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritDoc} - */ - function sql_index_drop($table_name, $index_name) - { - $statements = array(); - - $statements[] = 'DROP INDEX ' . $table_name . '_' . $index_name; - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritDoc} - */ - function sql_table_drop($table_name) - { - $statements = array(); - - if (!$this->sql_table_exists($table_name)) - { - return $this->_sql_run_sql($statements); - } - - // the most basic operation, get rid of the table - $statements[] = 'DROP TABLE ' . $table_name; - - // PGSQL does not "tightly" bind sequences and tables, we must guess... - $sql = "SELECT relname - FROM pg_class - WHERE relkind = 'S' - AND relname = '{$table_name}_seq'"; - $result = $this->db->sql_query($sql); - - // We don't even care about storing the results. We already know the answer if we get rows back. - if ($this->db->sql_fetchrow($result)) - { - $statements[] = "DROP SEQUENCE IF EXISTS {$table_name}_seq;\n"; - } - $this->db->sql_freeresult($result); - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritDoc} - */ - function sql_create_primary_key($table_name, $column, $inline = false) - { - $statements = array(); - - $statements[] = 'ALTER TABLE ' . $table_name . ' ADD PRIMARY KEY (' . implode(', ', $column) . ')'; - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritDoc} - */ - function sql_create_unique_index($table_name, $index_name, $column) - { - $statements = array(); - - $this->check_index_name_length($table_name, $index_name); - - $statements[] = 'CREATE UNIQUE INDEX ' . $table_name . '_' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')'; - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritDoc} - */ - function sql_create_index($table_name, $index_name, $column) - { - $statements = array(); - - $this->check_index_name_length($table_name, $index_name); - - // remove index length - $column = preg_replace('#:.*$#', '', $column); - - $statements[] = 'CREATE INDEX ' . $table_name . '_' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')'; - - return $this->_sql_run_sql($statements); - } - - - /** - * {@inheritDoc} - */ - function sql_list_index($table_name) - { - $index_array = array(); - - $sql = "SELECT ic.relname as index_name - FROM pg_class bc, pg_class ic, pg_index i - WHERE (bc.oid = i.indrelid) - AND (ic.oid = i.indexrelid) - AND (bc.relname = '" . $table_name . "') - AND (i.indisunique != 't') - AND (i.indisprimary != 't')"; - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - $row['index_name'] = $this->strip_table_name_from_index_name($table_name, $row['index_name']); - - $index_array[] = $row['index_name']; - } - $this->db->sql_freeresult($result); - - return array_map('strtolower', $index_array); - } - - /** - * {@inheritDoc} - */ - function sql_column_change($table_name, $column_name, $column_data, $inline = false) - { - $column_data = $this->sql_prepare_column_data($table_name, $column_name, $column_data); - $statements = array(); - - $sql = 'ALTER TABLE ' . $table_name . ' '; - - $sql_array = array(); - $sql_array[] = 'ALTER COLUMN ' . $column_name . ' TYPE ' . $column_data['column_type']; - - if (isset($column_data['null'])) - { - if ($column_data['null'] == 'NOT NULL') - { - $sql_array[] = 'ALTER COLUMN ' . $column_name . ' SET NOT NULL'; - } - else if ($column_data['null'] == 'NULL') - { - $sql_array[] = 'ALTER COLUMN ' . $column_name . ' DROP NOT NULL'; - } - } - - if (isset($column_data['default'])) - { - $sql_array[] = 'ALTER COLUMN ' . $column_name . ' SET DEFAULT ' . $column_data['default']; - } - - // we don't want to double up on constraints if we change different number data types - if (isset($column_data['constraint'])) - { - $constraint_sql = "SELECT consrc as constraint_data - FROM pg_constraint, pg_class bc - WHERE conrelid = bc.oid - AND bc.relname = '{$table_name}' - AND NOT EXISTS ( - SELECT * - FROM pg_constraint as c, pg_inherits as i - WHERE i.inhrelid = pg_constraint.conrelid - AND c.conname = pg_constraint.conname - AND c.consrc = pg_constraint.consrc - AND c.conrelid = i.inhparent - )"; - - $constraint_exists = false; - - $result = $this->db->sql_query($constraint_sql); - while ($row = $this->db->sql_fetchrow($result)) - { - if (trim($row['constraint_data']) == trim($column_data['constraint'])) - { - $constraint_exists = true; - break; - } - } - $this->db->sql_freeresult($result); - - if (!$constraint_exists) - { - $sql_array[] = 'ADD ' . $column_data['constraint']; - } - } - - $sql .= implode(', ', $sql_array); - - $statements[] = $sql; - - return $this->_sql_run_sql($statements); - } - - /** - * Get a list with existing indexes for the column - * - * @param string $table_name - * @param string $column_name - * @param bool $unique Should we get unique indexes or normal ones - * @return array Array with Index name => columns - */ - public function get_existing_indexes($table_name, $column_name, $unique = false) - { - // Not supported - throw new \Exception('DBMS is not supported'); - } -} diff --git a/install/update/new/phpbb/db/tools/tools.php b/install/update/new/phpbb/db/tools/tools.php deleted file mode 100644 index 1250a89..0000000 --- a/install/update/new/phpbb/db/tools/tools.php +++ /dev/null @@ -1,1879 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\db\tools; - -/** -* Database Tools for handling cross-db actions such as altering columns, etc. -* Currently not supported is returning SQL for creating tables. -*/ -class tools implements tools_interface -{ - /** - * Current sql layer - */ - var $sql_layer = ''; - - /** - * @var object DB object - */ - var $db = null; - - /** - * The Column types for every database we support - * @var array - */ - var $dbms_type_map = array(); - - /** - * Get the column types for every database we support - * - * @return array - */ - static public function get_dbms_type_map() - { - return array( - 'mysql_41' => array( - 'INT:' => 'int(%d)', - 'BINT' => 'bigint(20)', - 'ULINT' => 'INT(10) UNSIGNED', - 'UINT' => 'mediumint(8) UNSIGNED', - 'UINT:' => 'int(%d) UNSIGNED', - 'TINT:' => 'tinyint(%d)', - 'USINT' => 'smallint(4) UNSIGNED', - 'BOOL' => 'tinyint(1) UNSIGNED', - 'VCHAR' => 'varchar(255)', - 'VCHAR:' => 'varchar(%d)', - 'CHAR:' => 'char(%d)', - 'XSTEXT' => 'text', - 'XSTEXT_UNI'=> 'varchar(100)', - 'STEXT' => 'text', - 'STEXT_UNI' => 'varchar(255)', - 'TEXT' => 'text', - 'TEXT_UNI' => 'text', - 'MTEXT' => 'mediumtext', - 'MTEXT_UNI' => 'mediumtext', - 'TIMESTAMP' => 'int(11) UNSIGNED', - 'DECIMAL' => 'decimal(5,2)', - 'DECIMAL:' => 'decimal(%d,2)', - 'PDECIMAL' => 'decimal(6,3)', - 'PDECIMAL:' => 'decimal(%d,3)', - 'VCHAR_UNI' => 'varchar(255)', - 'VCHAR_UNI:'=> 'varchar(%d)', - 'VCHAR_CI' => 'varchar(255)', - 'VARBINARY' => 'varbinary(255)', - ), - - 'oracle' => array( - 'INT:' => 'number(%d)', - 'BINT' => 'number(20)', - 'ULINT' => 'number(10)', - 'UINT' => 'number(8)', - 'UINT:' => 'number(%d)', - 'TINT:' => 'number(%d)', - 'USINT' => 'number(4)', - 'BOOL' => 'number(1)', - 'VCHAR' => 'varchar2(255)', - 'VCHAR:' => 'varchar2(%d)', - 'CHAR:' => 'char(%d)', - 'XSTEXT' => 'varchar2(1000)', - 'STEXT' => 'varchar2(3000)', - 'TEXT' => 'clob', - 'MTEXT' => 'clob', - 'XSTEXT_UNI'=> 'varchar2(300)', - 'STEXT_UNI' => 'varchar2(765)', - 'TEXT_UNI' => 'clob', - 'MTEXT_UNI' => 'clob', - 'TIMESTAMP' => 'number(11)', - 'DECIMAL' => 'number(5, 2)', - 'DECIMAL:' => 'number(%d, 2)', - 'PDECIMAL' => 'number(6, 3)', - 'PDECIMAL:' => 'number(%d, 3)', - 'VCHAR_UNI' => 'varchar2(765)', - 'VCHAR_UNI:'=> array('varchar2(%d)', 'limit' => array('mult', 3, 765, 'clob')), - 'VCHAR_CI' => 'varchar2(255)', - 'VARBINARY' => 'raw(255)', - ), - - 'sqlite3' => array( - 'INT:' => 'INT(%d)', - 'BINT' => 'BIGINT(20)', - 'ULINT' => 'INTEGER UNSIGNED', - 'UINT' => 'INTEGER UNSIGNED', - 'UINT:' => 'INTEGER UNSIGNED', - 'TINT:' => 'TINYINT(%d)', - 'USINT' => 'INTEGER UNSIGNED', - 'BOOL' => 'INTEGER UNSIGNED', - 'VCHAR' => 'VARCHAR(255)', - 'VCHAR:' => 'VARCHAR(%d)', - 'CHAR:' => 'CHAR(%d)', - 'XSTEXT' => 'TEXT(65535)', - 'STEXT' => 'TEXT(65535)', - 'TEXT' => 'TEXT(65535)', - 'MTEXT' => 'MEDIUMTEXT(16777215)', - 'XSTEXT_UNI'=> 'TEXT(65535)', - 'STEXT_UNI' => 'TEXT(65535)', - 'TEXT_UNI' => 'TEXT(65535)', - 'MTEXT_UNI' => 'MEDIUMTEXT(16777215)', - 'TIMESTAMP' => 'INTEGER UNSIGNED', //'int(11) UNSIGNED', - 'DECIMAL' => 'DECIMAL(5,2)', - 'DECIMAL:' => 'DECIMAL(%d,2)', - 'PDECIMAL' => 'DECIMAL(6,3)', - 'PDECIMAL:' => 'DECIMAL(%d,3)', - 'VCHAR_UNI' => 'VARCHAR(255)', - 'VCHAR_UNI:'=> 'VARCHAR(%d)', - 'VCHAR_CI' => 'VARCHAR(255)', - 'VARBINARY' => 'BLOB', - ), - ); - } - - /** - * A list of types being unsigned for better reference in some db's - * @var array - */ - var $unsigned_types = array('ULINT', 'UINT', 'UINT:', 'USINT', 'BOOL', 'TIMESTAMP'); - - /** - * This is set to true if user only wants to return the 'to-be-executed' SQL statement(s) (as an array). - * This mode has no effect on some methods (inserting of data for example). This is expressed within the methods command. - */ - var $return_statements = false; - - /** - * Constructor. Set DB Object and set {@link $return_statements return_statements}. - * - * @param \phpbb\db\driver\driver_interface $db Database connection - * @param bool $return_statements True if only statements should be returned and no SQL being executed - */ - public function __construct(\phpbb\db\driver\driver_interface $db, $return_statements = false) - { - $this->db = $db; - $this->return_statements = $return_statements; - - $this->dbms_type_map = self::get_dbms_type_map(); - - // Determine mapping database type - switch ($this->db->get_sql_layer()) - { - case 'mysqli': - $this->sql_layer = 'mysql_41'; - break; - - default: - $this->sql_layer = $this->db->get_sql_layer(); - break; - } - } - - /** - * Setter for {@link $return_statements return_statements}. - * - * @param bool $return_statements True if SQL should not be executed but returned as strings - * @return null - */ - public function set_return_statements($return_statements) - { - $this->return_statements = $return_statements; - } - - /** - * {@inheritDoc} - */ - function sql_list_tables() - { - switch ($this->db->get_sql_layer()) - { - case 'mysqli': - $sql = 'SHOW TABLES'; - break; - - case 'sqlite3': - $sql = 'SELECT name - FROM sqlite_master - WHERE type = "table" - AND name <> "sqlite_sequence"'; - break; - - case 'oracle': - $sql = 'SELECT table_name - FROM USER_TABLES'; - break; - } - - $result = $this->db->sql_query($sql); - - $tables = array(); - while ($row = $this->db->sql_fetchrow($result)) - { - $name = current($row); - $tables[$name] = $name; - } - $this->db->sql_freeresult($result); - - return $tables; - } - - /** - * {@inheritDoc} - */ - function sql_table_exists($table_name) - { - $this->db->sql_return_on_error(true); - $result = $this->db->sql_query_limit('SELECT * FROM ' . $table_name, 1); - $this->db->sql_return_on_error(false); - - if ($result) - { - $this->db->sql_freeresult($result); - return true; - } - - return false; - } - - /** - * {@inheritDoc} - */ - function sql_create_table($table_name, $table_data) - { - // holds the DDL for a column - $columns = $statements = array(); - - if ($this->sql_table_exists($table_name)) - { - return $this->_sql_run_sql($statements); - } - - // Begin transaction - $statements[] = 'begin'; - - // Determine if we have created a PRIMARY KEY in the earliest - $primary_key_gen = false; - - // Determine if the table requires a sequence - $create_sequence = false; - - // Begin table sql statement - $table_sql = 'CREATE TABLE ' . $table_name . ' (' . "\n"; - - // Iterate through the columns to create a table - foreach ($table_data['COLUMNS'] as $column_name => $column_data) - { - // here lies an array, filled with information compiled on the column's data - $prepared_column = $this->sql_prepare_column_data($table_name, $column_name, $column_data); - - if (isset($prepared_column['auto_increment']) && $prepared_column['auto_increment'] && strlen($column_name) > 26) // "${column_name}_gen" - { - trigger_error("Index name '${column_name}_gen' on table '$table_name' is too long. The maximum auto increment column length is 26 characters.", E_USER_ERROR); - } - - // here we add the definition of the new column to the list of columns - $columns[] = "\t {$column_name} " . $prepared_column['column_type_sql']; - - // see if we have found a primary key set due to a column definition if we have found it, we can stop looking - if (!$primary_key_gen) - { - $primary_key_gen = isset($prepared_column['primary_key_set']) && $prepared_column['primary_key_set']; - } - - // create sequence DDL based off of the existence of auto incrementing columns - if (!$create_sequence && isset($prepared_column['auto_increment']) && $prepared_column['auto_increment']) - { - $create_sequence = $column_name; - } - } - - // this makes up all the columns in the create table statement - $table_sql .= implode(",\n", $columns); - - // we have yet to create a primary key for this table, - // this means that we can add the one we really wanted instead - if (!$primary_key_gen) - { - // Write primary key - if (isset($table_data['PRIMARY_KEY'])) - { - if (!is_array($table_data['PRIMARY_KEY'])) - { - $table_data['PRIMARY_KEY'] = array($table_data['PRIMARY_KEY']); - } - - switch ($this->sql_layer) - { - case 'mysql_41': - case 'sqlite3': - $table_sql .= ",\n\t PRIMARY KEY (" . implode(', ', $table_data['PRIMARY_KEY']) . ')'; - break; - - case 'oracle': - $table_sql .= ",\n\t CONSTRAINT pk_{$table_name} PRIMARY KEY (" . implode(', ', $table_data['PRIMARY_KEY']) . ')'; - break; - } - } - } - - // close the table - switch ($this->sql_layer) - { - case 'mysql_41': - // make sure the table is in UTF-8 mode - $table_sql .= "\n) CHARACTER SET `utf8` COLLATE `utf8_bin`;"; - $statements[] = $table_sql; - break; - - case 'sqlite3': - $table_sql .= "\n);"; - $statements[] = $table_sql; - break; - - case 'oracle': - $table_sql .= "\n)"; - $statements[] = $table_sql; - - // do we need to add a sequence and a tigger for auto incrementing columns? - if ($create_sequence) - { - // create the actual sequence - $statements[] = "CREATE SEQUENCE {$table_name}_seq"; - - // the trigger is the mechanism by which we increment the counter - $trigger = "CREATE OR REPLACE TRIGGER t_{$table_name}\n"; - $trigger .= "BEFORE INSERT ON {$table_name}\n"; - $trigger .= "FOR EACH ROW WHEN (\n"; - $trigger .= "\tnew.{$create_sequence} IS NULL OR new.{$create_sequence} = 0\n"; - $trigger .= ")\n"; - $trigger .= "BEGIN\n"; - $trigger .= "\tSELECT {$table_name}_seq.nextval\n"; - $trigger .= "\tINTO :new.{$create_sequence}\n"; - $trigger .= "\tFROM dual;\n"; - $trigger .= "END;"; - - $statements[] = $trigger; - } - break; - } - - // Write Keys - if (isset($table_data['KEYS'])) - { - foreach ($table_data['KEYS'] as $key_name => $key_data) - { - if (!is_array($key_data[1])) - { - $key_data[1] = array($key_data[1]); - } - - $old_return_statements = $this->return_statements; - $this->return_statements = true; - - $key_stmts = ($key_data[0] == 'UNIQUE') ? $this->sql_create_unique_index($table_name, $key_name, $key_data[1]) : $this->sql_create_index($table_name, $key_name, $key_data[1]); - - foreach ($key_stmts as $key_stmt) - { - $statements[] = $key_stmt; - } - - $this->return_statements = $old_return_statements; - } - } - - // Commit Transaction - $statements[] = 'commit'; - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritDoc} - */ - function perform_schema_changes($schema_changes) - { - if (empty($schema_changes)) - { - return; - } - - $statements = array(); - $sqlite = false; - - // For SQLite we need to perform the schema changes in a much more different way - if ($this->db->get_sql_layer() == 'sqlite3' && $this->return_statements) - { - $sqlite_data = array(); - $sqlite = true; - } - - // Drop tables? - if (!empty($schema_changes['drop_tables'])) - { - foreach ($schema_changes['drop_tables'] as $table) - { - // only drop table if it exists - if ($this->sql_table_exists($table)) - { - $result = $this->sql_table_drop($table); - if ($this->return_statements) - { - $statements = array_merge($statements, $result); - } - } - } - } - - // Add tables? - if (!empty($schema_changes['add_tables'])) - { - foreach ($schema_changes['add_tables'] as $table => $table_data) - { - $result = $this->sql_create_table($table, $table_data); - if ($this->return_statements) - { - $statements = array_merge($statements, $result); - } - } - } - - // Change columns? - if (!empty($schema_changes['change_columns'])) - { - foreach ($schema_changes['change_columns'] as $table => $columns) - { - foreach ($columns as $column_name => $column_data) - { - // If the column exists we change it, else we add it ;) - if ($column_exists = $this->sql_column_exists($table, $column_name)) - { - $result = $this->sql_column_change($table, $column_name, $column_data, true); - } - else - { - $result = $this->sql_column_add($table, $column_name, $column_data, true); - } - - if ($sqlite) - { - if ($column_exists) - { - $sqlite_data[$table]['change_columns'][] = $result; - } - else - { - $sqlite_data[$table]['add_columns'][] = $result; - } - } - else if ($this->return_statements) - { - $statements = array_merge($statements, $result); - } - } - } - } - - // Add columns? - if (!empty($schema_changes['add_columns'])) - { - foreach ($schema_changes['add_columns'] as $table => $columns) - { - foreach ($columns as $column_name => $column_data) - { - // Only add the column if it does not exist yet - if ($column_exists = $this->sql_column_exists($table, $column_name)) - { - continue; - // This is commented out here because it can take tremendous time on updates -// $result = $this->sql_column_change($table, $column_name, $column_data, true); - } - else - { - $result = $this->sql_column_add($table, $column_name, $column_data, true); - } - - if ($sqlite) - { - if ($column_exists) - { - continue; -// $sqlite_data[$table]['change_columns'][] = $result; - } - else - { - $sqlite_data[$table]['add_columns'][] = $result; - } - } - else if ($this->return_statements) - { - $statements = array_merge($statements, $result); - } - } - } - } - - // Remove keys? - if (!empty($schema_changes['drop_keys'])) - { - foreach ($schema_changes['drop_keys'] as $table => $indexes) - { - foreach ($indexes as $index_name) - { - if (!$this->sql_index_exists($table, $index_name) && !$this->sql_unique_index_exists($table, $index_name)) - { - continue; - } - - $result = $this->sql_index_drop($table, $index_name); - - if ($this->return_statements) - { - $statements = array_merge($statements, $result); - } - } - } - } - - // Drop columns? - if (!empty($schema_changes['drop_columns'])) - { - foreach ($schema_changes['drop_columns'] as $table => $columns) - { - foreach ($columns as $column) - { - // Only remove the column if it exists... - if ($this->sql_column_exists($table, $column)) - { - $result = $this->sql_column_remove($table, $column, true); - - if ($sqlite) - { - $sqlite_data[$table]['drop_columns'][] = $result; - } - else if ($this->return_statements) - { - $statements = array_merge($statements, $result); - } - } - } - } - } - - // Add primary keys? - if (!empty($schema_changes['add_primary_keys'])) - { - foreach ($schema_changes['add_primary_keys'] as $table => $columns) - { - $result = $this->sql_create_primary_key($table, $columns, true); - - if ($sqlite) - { - $sqlite_data[$table]['primary_key'] = $result; - } - else if ($this->return_statements) - { - $statements = array_merge($statements, $result); - } - } - } - - // Add unique indexes? - if (!empty($schema_changes['add_unique_index'])) - { - foreach ($schema_changes['add_unique_index'] as $table => $index_array) - { - foreach ($index_array as $index_name => $column) - { - if ($this->sql_unique_index_exists($table, $index_name)) - { - continue; - } - - $result = $this->sql_create_unique_index($table, $index_name, $column); - - if ($this->return_statements) - { - $statements = array_merge($statements, $result); - } - } - } - } - - // Add indexes? - if (!empty($schema_changes['add_index'])) - { - foreach ($schema_changes['add_index'] as $table => $index_array) - { - foreach ($index_array as $index_name => $column) - { - if ($this->sql_index_exists($table, $index_name)) - { - continue; - } - - $result = $this->sql_create_index($table, $index_name, $column); - - if ($this->return_statements) - { - $statements = array_merge($statements, $result); - } - } - } - } - - if ($sqlite) - { - foreach ($sqlite_data as $table_name => $sql_schema_changes) - { - // Create temporary table with original data - $statements[] = 'begin'; - - $sql = "SELECT sql - FROM sqlite_master - WHERE type = 'table' - AND name = '{$table_name}' - ORDER BY type DESC, name;"; - $result = $this->db->sql_query($sql); - - if (!$result) - { - continue; - } - - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - // Create a backup table and populate it, destroy the existing one - $statements[] = preg_replace('#CREATE\s+TABLE\s+"?' . $table_name . '"?#i', 'CREATE TEMPORARY TABLE ' . $table_name . '_temp', $row['sql']); - $statements[] = 'INSERT INTO ' . $table_name . '_temp SELECT * FROM ' . $table_name; - $statements[] = 'DROP TABLE ' . $table_name; - - // Get the columns... - preg_match('#\((.*)\)#s', $row['sql'], $matches); - - $plain_table_cols = trim($matches[1]); - $new_table_cols = preg_split('/,(?![\s\w]+\))/m', $plain_table_cols); - $column_list = array(); - - foreach ($new_table_cols as $declaration) - { - $entities = preg_split('#\s+#', trim($declaration)); - if ($entities[0] == 'PRIMARY') - { - continue; - } - $column_list[] = $entities[0]; - } - - // note down the primary key notation because sqlite only supports adding it to the end for the new table - $primary_key = false; - $_new_cols = array(); - - foreach ($new_table_cols as $key => $declaration) - { - $entities = preg_split('#\s+#', trim($declaration)); - if ($entities[0] == 'PRIMARY') - { - $primary_key = $declaration; - continue; - } - $_new_cols[] = $declaration; - } - - $new_table_cols = $_new_cols; - - // First of all... change columns - if (!empty($sql_schema_changes['change_columns'])) - { - foreach ($sql_schema_changes['change_columns'] as $column_sql) - { - foreach ($new_table_cols as $key => $declaration) - { - $entities = preg_split('#\s+#', trim($declaration)); - if (strpos($column_sql, $entities[0] . ' ') === 0) - { - $new_table_cols[$key] = $column_sql; - } - } - } - } - - if (!empty($sql_schema_changes['add_columns'])) - { - foreach ($sql_schema_changes['add_columns'] as $column_sql) - { - $new_table_cols[] = $column_sql; - } - } - - // Now drop them... - if (!empty($sql_schema_changes['drop_columns'])) - { - foreach ($sql_schema_changes['drop_columns'] as $column_name) - { - // Remove from column list... - $new_column_list = array(); - foreach ($column_list as $key => $value) - { - if ($value === $column_name) - { - continue; - } - - $new_column_list[] = $value; - } - - $column_list = $new_column_list; - - // Remove from table... - $_new_cols = array(); - foreach ($new_table_cols as $key => $declaration) - { - $entities = preg_split('#\s+#', trim($declaration)); - if (strpos($column_name . ' ', $entities[0] . ' ') === 0) - { - continue; - } - $_new_cols[] = $declaration; - } - $new_table_cols = $_new_cols; - } - } - - // Primary key... - if (!empty($sql_schema_changes['primary_key'])) - { - $new_table_cols[] = 'PRIMARY KEY (' . implode(', ', $sql_schema_changes['primary_key']) . ')'; - } - // Add a new one or the old primary key - else if ($primary_key !== false) - { - $new_table_cols[] = $primary_key; - } - - $columns = implode(',', $column_list); - - // create a new table and fill it up. destroy the temp one - $statements[] = 'CREATE TABLE ' . $table_name . ' (' . implode(',', $new_table_cols) . ');'; - $statements[] = 'INSERT INTO ' . $table_name . ' (' . $columns . ') SELECT ' . $columns . ' FROM ' . $table_name . '_temp;'; - $statements[] = 'DROP TABLE ' . $table_name . '_temp'; - - $statements[] = 'commit'; - } - } - - if ($this->return_statements) - { - return $statements; - } - } - - /** - * {@inheritDoc} - */ - function sql_list_columns($table_name) - { - $columns = array(); - - switch ($this->sql_layer) - { - case 'mysql_41': - $sql = "SHOW COLUMNS FROM $table_name"; - break; - - case 'oracle': - $sql = "SELECT column_name - FROM user_tab_columns - WHERE LOWER(table_name) = '" . strtolower($table_name) . "'"; - break; - - case 'sqlite3': - $sql = "SELECT sql - FROM sqlite_master - WHERE type = 'table' - AND name = '{$table_name}'"; - - $result = $this->db->sql_query($sql); - - if (!$result) - { - return false; - } - - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - preg_match('#\((.*)\)#s', $row['sql'], $matches); - - $cols = trim($matches[1]); - $col_array = preg_split('/,(?![\s\w]+\))/m', $cols); - - foreach ($col_array as $declaration) - { - $entities = preg_split('#\s+#', trim($declaration)); - if ($entities[0] == 'PRIMARY') - { - continue; - } - - $column = strtolower($entities[0]); - $columns[$column] = $column; - } - - return $columns; - break; - } - - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - $column = strtolower(current($row)); - $columns[$column] = $column; - } - $this->db->sql_freeresult($result); - - return $columns; - } - - /** - * {@inheritDoc} - */ - function sql_column_exists($table_name, $column_name) - { - $columns = $this->sql_list_columns($table_name); - - return isset($columns[$column_name]); - } - - /** - * {@inheritDoc} - */ - function sql_index_exists($table_name, $index_name) - { - switch ($this->sql_layer) - { - case 'mysql_41': - $sql = 'SHOW KEYS - FROM ' . $table_name; - $col = 'Key_name'; - break; - - case 'oracle': - $sql = "SELECT index_name - FROM user_indexes - WHERE table_name = '" . strtoupper($table_name) . "' - AND generated = 'N' - AND uniqueness = 'NONUNIQUE'"; - $col = 'index_name'; - break; - - case 'sqlite3': - $sql = "PRAGMA index_list('" . $table_name . "');"; - $col = 'name'; - break; - } - - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - if ($this->sql_layer == 'mysql_41' && !$row['Non_unique']) - { - continue; - } - - switch ($this->sql_layer) - { - // These DBMS prefix index name with the table name - case 'oracle': - case 'sqlite3': - $new_index_name = $this->check_index_name_length($table_name, $table_name . '_' . $index_name, false); - break; - default: - $new_index_name = $this->check_index_name_length($table_name, $index_name, false); - break; - } - - if (strtolower($row[$col]) == strtolower($new_index_name)) - { - $this->db->sql_freeresult($result); - return true; - } - } - $this->db->sql_freeresult($result); - - return false; - } - - /** - * {@inheritDoc} - */ - function sql_unique_index_exists($table_name, $index_name) - { - switch ($this->sql_layer) - { - case 'mysql_41': - $sql = 'SHOW KEYS - FROM ' . $table_name; - $col = 'Key_name'; - break; - - case 'oracle': - $sql = "SELECT index_name, table_owner - FROM user_indexes - WHERE table_name = '" . strtoupper($table_name) . "' - AND generated = 'N' - AND uniqueness = 'UNIQUE'"; - $col = 'index_name'; - break; - - case 'sqlite3': - $sql = "PRAGMA index_list('" . $table_name . "');"; - $col = 'name'; - break; - } - - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - if ($this->sql_layer == 'mysql_41' && ($row['Non_unique'] || $row[$col] == 'PRIMARY')) - { - continue; - } - - if ($this->sql_layer == 'sqlite3' && !$row['unique']) - { - continue; - } - - // These DBMS prefix index name with the table name - switch ($this->sql_layer) - { - case 'oracle': - // Two cases here... prefixed with U_[table_owner] and not prefixed with table_name - if (strpos($row[$col], 'U_') === 0) - { - $row[$col] = substr($row[$col], strlen('U_' . $row['table_owner']) + 1); - } - else if (strpos($row[$col], strtoupper($table_name)) === 0) - { - $row[$col] = substr($row[$col], strlen($table_name) + 1); - } - break; - - case 'sqlite3': - $row[$col] = substr($row[$col], strlen($table_name) + 1); - break; - } - - if (strtolower($row[$col]) == strtolower($index_name)) - { - $this->db->sql_freeresult($result); - return true; - } - } - $this->db->sql_freeresult($result); - - return false; - } - - /** - * Private method for performing sql statements (either execute them or return them) - * @access private - */ - function _sql_run_sql($statements) - { - if ($this->return_statements) - { - return $statements; - } - - // We could add error handling here... - foreach ($statements as $sql) - { - if ($sql === 'begin') - { - $this->db->sql_transaction('begin'); - } - else if ($sql === 'commit') - { - $this->db->sql_transaction('commit'); - } - else - { - $this->db->sql_query($sql); - } - } - - return true; - } - - /** - * Function to prepare some column information for better usage - * @access private - */ - function sql_prepare_column_data($table_name, $column_name, $column_data) - { - if (strlen($column_name) > 30) - { - trigger_error("Column name '$column_name' on table '$table_name' is too long. The maximum is 30 characters.", E_USER_ERROR); - } - - // Get type - list($column_type) = $this->get_column_type($column_data[0]); - - // Adjust default value if db-dependent specified - if (is_array($column_data[1])) - { - $column_data[1] = (isset($column_data[1][$this->sql_layer])) ? $column_data[1][$this->sql_layer] : $column_data[1]['default']; - } - - $sql = ''; - - $return_array = array(); - - switch ($this->sql_layer) - { - case 'mysql_41': - $sql .= " {$column_type} "; - - // For hexadecimal values do not use single quotes - if (!is_null($column_data[1]) && substr($column_type, -4) !== 'text' && substr($column_type, -4) !== 'blob') - { - $sql .= (strpos($column_data[1], '0x') === 0) ? "DEFAULT {$column_data[1]} " : "DEFAULT '{$column_data[1]}' "; - } - - if (!is_null($column_data[1]) || (isset($column_data[2]) && $column_data[2] == 'auto_increment')) - { - $sql .= 'NOT NULL'; - } - else - { - $sql .= 'NULL'; - } - - if (isset($column_data[2])) - { - if ($column_data[2] == 'auto_increment') - { - $sql .= ' auto_increment'; - } - else if ($this->sql_layer === 'mysql_41' && $column_data[2] == 'true_sort') - { - $sql .= ' COLLATE utf8_unicode_ci'; - } - } - - if (isset($column_data['after'])) - { - $return_array['after'] = $column_data['after']; - } - - break; - - case 'oracle': - $sql .= " {$column_type} "; - $sql .= (!is_null($column_data[1])) ? "DEFAULT '{$column_data[1]}' " : ''; - - // In Oracle empty strings ('') are treated as NULL. - // Therefore in oracle we allow NULL's for all DEFAULT '' entries - // Oracle does not like setting NOT NULL on a column that is already NOT NULL (this happens only on number fields) - if (!preg_match('/number/i', $column_type)) - { - $sql .= ($column_data[1] === '' || $column_data[1] === null) ? '' : 'NOT NULL'; - } - - $return_array['auto_increment'] = false; - if (isset($column_data[2]) && $column_data[2] == 'auto_increment') - { - $return_array['auto_increment'] = true; - } - - break; - - case 'sqlite3': - $return_array['primary_key_set'] = false; - if (isset($column_data[2]) && $column_data[2] == 'auto_increment') - { - $sql .= ' INTEGER PRIMARY KEY AUTOINCREMENT'; - $return_array['primary_key_set'] = true; - } - else - { - $sql .= ' ' . $column_type; - } - - if (!is_null($column_data[1])) - { - $sql .= ' NOT NULL '; - $sql .= "DEFAULT '{$column_data[1]}'"; - } - - break; - } - - $return_array['column_type_sql'] = $sql; - - return $return_array; - } - - /** - * Get the column's database type from the type map - * - * @param string $column_map_type - * @return array column type for this database - * and map type without length - */ - function get_column_type($column_map_type) - { - $column_type = ''; - if (strpos($column_map_type, ':') !== false) - { - list($orig_column_type, $column_length) = explode(':', $column_map_type); - if (!is_array($this->dbms_type_map[$this->sql_layer][$orig_column_type . ':'])) - { - $column_type = sprintf($this->dbms_type_map[$this->sql_layer][$orig_column_type . ':'], $column_length); - } - else - { - if (isset($this->dbms_type_map[$this->sql_layer][$orig_column_type . ':']['rule'])) - { - switch ($this->dbms_type_map[$this->sql_layer][$orig_column_type . ':']['rule'][0]) - { - case 'div': - $column_length /= $this->dbms_type_map[$this->sql_layer][$orig_column_type . ':']['rule'][1]; - $column_length = ceil($column_length); - $column_type = sprintf($this->dbms_type_map[$this->sql_layer][$orig_column_type . ':'][0], $column_length); - break; - } - } - - if (isset($this->dbms_type_map[$this->sql_layer][$orig_column_type . ':']['limit'])) - { - switch ($this->dbms_type_map[$this->sql_layer][$orig_column_type . ':']['limit'][0]) - { - case 'mult': - $column_length *= $this->dbms_type_map[$this->sql_layer][$orig_column_type . ':']['limit'][1]; - if ($column_length > $this->dbms_type_map[$this->sql_layer][$orig_column_type . ':']['limit'][2]) - { - $column_type = $this->dbms_type_map[$this->sql_layer][$orig_column_type . ':']['limit'][3]; - } - else - { - $column_type = sprintf($this->dbms_type_map[$this->sql_layer][$orig_column_type . ':'][0], $column_length); - } - break; - } - } - } - $orig_column_type .= ':'; - } - else - { - $orig_column_type = $column_map_type; - $column_type = $this->dbms_type_map[$this->sql_layer][$column_map_type]; - } - - return array($column_type, $orig_column_type); - } - - /** - * {@inheritDoc} - */ - function sql_column_add($table_name, $column_name, $column_data, $inline = false) - { - $column_data = $this->sql_prepare_column_data($table_name, $column_name, $column_data); - $statements = array(); - - switch ($this->sql_layer) - { - case 'mysql_41': - $after = (!empty($column_data['after'])) ? ' AFTER ' . $column_data['after'] : ''; - $statements[] = 'ALTER TABLE `' . $table_name . '` ADD COLUMN `' . $column_name . '` ' . $column_data['column_type_sql'] . $after; - break; - - case 'oracle': - // Does not support AFTER, only through temporary table - $statements[] = 'ALTER TABLE ' . $table_name . ' ADD ' . $column_name . ' ' . $column_data['column_type_sql']; - break; - - case 'sqlite3': - if ($inline && $this->return_statements) - { - return $column_name . ' ' . $column_data['column_type_sql']; - } - - $statements[] = 'ALTER TABLE ' . $table_name . ' ADD ' . $column_name . ' ' . $column_data['column_type_sql']; - break; - } - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritDoc} - */ - function sql_column_remove($table_name, $column_name, $inline = false) - { - $statements = array(); - - switch ($this->sql_layer) - { - case 'mysql_41': - $statements[] = 'ALTER TABLE `' . $table_name . '` DROP COLUMN `' . $column_name . '`'; - break; - - case 'oracle': - $statements[] = 'ALTER TABLE ' . $table_name . ' DROP COLUMN ' . $column_name; - break; - - case 'sqlite3': - - if ($inline && $this->return_statements) - { - return $column_name; - } - - $recreate_queries = $this->sqlite_get_recreate_table_queries($table_name, $column_name); - if (empty($recreate_queries)) - { - break; - } - - $statements[] = 'begin'; - - $sql_create_table = array_shift($recreate_queries); - - // Create a backup table and populate it, destroy the existing one - $statements[] = preg_replace('#CREATE\s+TABLE\s+"?' . $table_name . '"?#i', 'CREATE TEMPORARY TABLE ' . $table_name . '_temp', $sql_create_table); - $statements[] = 'INSERT INTO ' . $table_name . '_temp SELECT * FROM ' . $table_name; - $statements[] = 'DROP TABLE ' . $table_name; - - preg_match('#\((.*)\)#s', $sql_create_table, $matches); - - $new_table_cols = trim($matches[1]); - $old_table_cols = preg_split('/,(?![\s\w]+\))/m', $new_table_cols); - $column_list = array(); - - foreach ($old_table_cols as $declaration) - { - $entities = preg_split('#\s+#', trim($declaration)); - if ($entities[0] == 'PRIMARY' || $entities[0] === $column_name) - { - continue; - } - $column_list[] = $entities[0]; - } - - $columns = implode(',', $column_list); - - $new_table_cols = trim(preg_replace('/' . $column_name . '\b[^,]+(?:,|$)/m', '', $new_table_cols)); - if (substr($new_table_cols, -1) === ',') - { - // Remove the comma from the last entry again - $new_table_cols = substr($new_table_cols, 0, -1); - } - - // create a new table and fill it up. destroy the temp one - $statements[] = 'CREATE TABLE ' . $table_name . ' (' . $new_table_cols . ');'; - $statements = array_merge($statements, $recreate_queries); - - $statements[] = 'INSERT INTO ' . $table_name . ' (' . $columns . ') SELECT ' . $columns . ' FROM ' . $table_name . '_temp;'; - $statements[] = 'DROP TABLE ' . $table_name . '_temp'; - - $statements[] = 'commit'; - break; - } - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritDoc} - */ - function sql_index_drop($table_name, $index_name) - { - $statements = array(); - - switch ($this->sql_layer) - { - case 'mysql_41': - $index_name = $this->check_index_name_length($table_name, $index_name, false); - $statements[] = 'DROP INDEX ' . $index_name . ' ON ' . $table_name; - break; - - case 'oracle': - case 'sqlite3': - $index_name = $this->check_index_name_length($table_name, $table_name . '_' . $index_name, false); - $statements[] = 'DROP INDEX ' . $index_name; - break; - } - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritDoc} - */ - function sql_table_drop($table_name) - { - $statements = array(); - - if (!$this->sql_table_exists($table_name)) - { - return $this->_sql_run_sql($statements); - } - - // the most basic operation, get rid of the table - $statements[] = 'DROP TABLE ' . $table_name; - - switch ($this->sql_layer) - { - case 'oracle': - $sql = 'SELECT A.REFERENCED_NAME - FROM USER_DEPENDENCIES A, USER_TRIGGERS B - WHERE A.REFERENCED_TYPE = \'SEQUENCE\' - AND A.NAME = B.TRIGGER_NAME - AND B.TABLE_NAME = \'' . strtoupper($table_name) . "'"; - $result = $this->db->sql_query($sql); - - // any sequences ref'd to this table's triggers? - while ($row = $this->db->sql_fetchrow($result)) - { - $statements[] = "DROP SEQUENCE {$row['referenced_name']}"; - } - $this->db->sql_freeresult($result); - break; - } - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritDoc} - */ - function sql_create_primary_key($table_name, $column, $inline = false) - { - $statements = array(); - - switch ($this->sql_layer) - { - case 'mysql_41': - $statements[] = 'ALTER TABLE ' . $table_name . ' ADD PRIMARY KEY (' . implode(', ', $column) . ')'; - break; - - case 'oracle': - $statements[] = 'ALTER TABLE ' . $table_name . ' add CONSTRAINT pk_' . $table_name . ' PRIMARY KEY (' . implode(', ', $column) . ')'; - break; - - case 'sqlite3': - - if ($inline && $this->return_statements) - { - return $column; - } - - $recreate_queries = $this->sqlite_get_recreate_table_queries($table_name); - if (empty($recreate_queries)) - { - break; - } - - $statements[] = 'begin'; - - $sql_create_table = array_shift($recreate_queries); - - // Create a backup table and populate it, destroy the existing one - $statements[] = preg_replace('#CREATE\s+TABLE\s+"?' . $table_name . '"?#i', 'CREATE TEMPORARY TABLE ' . $table_name . '_temp', $sql_create_table); - $statements[] = 'INSERT INTO ' . $table_name . '_temp SELECT * FROM ' . $table_name; - $statements[] = 'DROP TABLE ' . $table_name; - - preg_match('#\((.*)\)#s', $sql_create_table, $matches); - - $new_table_cols = trim($matches[1]); - $old_table_cols = preg_split('/,(?![\s\w]+\))/m', $new_table_cols); - $column_list = array(); - - foreach ($old_table_cols as $declaration) - { - $entities = preg_split('#\s+#', trim($declaration)); - if ($entities[0] == 'PRIMARY') - { - continue; - } - $column_list[] = $entities[0]; - } - - $columns = implode(',', $column_list); - - // create a new table and fill it up. destroy the temp one - $statements[] = 'CREATE TABLE ' . $table_name . ' (' . $new_table_cols . ', PRIMARY KEY (' . implode(', ', $column) . '));'; - $statements = array_merge($statements, $recreate_queries); - - $statements[] = 'INSERT INTO ' . $table_name . ' (' . $columns . ') SELECT ' . $columns . ' FROM ' . $table_name . '_temp;'; - $statements[] = 'DROP TABLE ' . $table_name . '_temp'; - - $statements[] = 'commit'; - break; - } - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritDoc} - */ - function sql_create_unique_index($table_name, $index_name, $column) - { - $statements = array(); - - switch ($this->sql_layer) - { - case 'oracle': - case 'sqlite3': - $index_name = $this->check_index_name_length($table_name, $table_name . '_' . $index_name); - $statements[] = 'CREATE UNIQUE INDEX ' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')'; - break; - - case 'mysql_41': - $index_name = $this->check_index_name_length($table_name, $index_name); - $statements[] = 'ALTER TABLE ' . $table_name . ' ADD UNIQUE INDEX ' . $index_name . '(' . implode(', ', $column) . ')'; - break; - } - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritDoc} - */ - function sql_create_index($table_name, $index_name, $column) - { - $statements = array(); - - $column = preg_replace('#:.*$#', '', $column); - - switch ($this->sql_layer) - { - case 'oracle': - case 'sqlite3': - $index_name = $this->check_index_name_length($table_name, $table_name . '_' . $index_name); - $statements[] = 'CREATE INDEX ' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')'; - break; - - case 'mysql_41': - $index_name = $this->check_index_name_length($table_name, $index_name); - $statements[] = 'ALTER TABLE ' . $table_name . ' ADD INDEX ' . $index_name . ' (' . implode(', ', $column) . ')'; - break; - } - - return $this->_sql_run_sql($statements); - } - - /** - * Check whether the index name is too long - * - * @param string $table_name - * @param string $index_name - * @param bool $throw_error - * @return string The index name, shortened if too long - */ - protected function check_index_name_length($table_name, $index_name, $throw_error = true) - { - $max_index_name_length = $this->get_max_index_name_length(); - if (strlen($index_name) > $max_index_name_length) - { - // Try removing the table prefix if it's at the beginning - $table_prefix = substr(CONFIG_TABLE, 0, -6); // strlen(config) - if (strpos($index_name, $table_prefix) === 0) - { - $index_name = substr($index_name, strlen($table_prefix)); - return $this->check_index_name_length($table_name, $index_name, $throw_error); - } - - // Try removing the remaining suffix part of table name then - $table_suffix = substr($table_name, strlen($table_prefix)); - if (strpos($index_name, $table_suffix) === 0) - { - // Remove the suffix and underscore separator between table_name and index_name - $index_name = substr($index_name, strlen($table_suffix) + 1); - return $this->check_index_name_length($table_name, $index_name, $throw_error); - } - - if ($throw_error) - { - trigger_error("Index name '$index_name' on table '$table_name' is too long. The maximum is $max_index_name_length characters.", E_USER_ERROR); - } - } - - return $index_name; - } - - /** - * Get maximum index name length. Might vary depending on db type - * - * @return int Maximum index name length - */ - protected function get_max_index_name_length() - { - return 30; - } - - /** - * {@inheritDoc} - */ - function sql_list_index($table_name) - { - $index_array = array(); - - switch ($this->sql_layer) - { - case 'mysql_41': - $sql = 'SHOW KEYS - FROM ' . $table_name; - $col = 'Key_name'; - break; - - case 'oracle': - $sql = "SELECT index_name - FROM user_indexes - WHERE table_name = '" . strtoupper($table_name) . "' - AND generated = 'N' - AND uniqueness = 'NONUNIQUE'"; - $col = 'index_name'; - break; - - case 'sqlite3': - $sql = "PRAGMA index_info('" . $table_name . "');"; - $col = 'name'; - break; - } - - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - if ($this->sql_layer == 'mysql_41' && !$row['Non_unique']) - { - continue; - } - - switch ($this->sql_layer) - { - case 'oracle': - case 'sqlite3': - $row[$col] = substr($row[$col], strlen($table_name) + 1); - break; - } - - $index_array[] = $row[$col]; - } - $this->db->sql_freeresult($result); - - return array_map('strtolower', $index_array); - } - - /** - * Removes table_name from the index_name if it is at the beginning - * - * @param $table_name - * @param $index_name - * @return string - */ - protected function strip_table_name_from_index_name($table_name, $index_name) - { - return (strpos(strtoupper($index_name), strtoupper($table_name)) === 0) ? substr($index_name, strlen($table_name) + 1) : $index_name; - } - - /** - * {@inheritDoc} - */ - function sql_column_change($table_name, $column_name, $column_data, $inline = false) - { - $original_column_data = $column_data; - $column_data = $this->sql_prepare_column_data($table_name, $column_name, $column_data); - $statements = array(); - - switch ($this->sql_layer) - { - case 'mysql_41': - $statements[] = 'ALTER TABLE `' . $table_name . '` CHANGE `' . $column_name . '` `' . $column_name . '` ' . $column_data['column_type_sql']; - break; - - case 'oracle': - // We need the data here - $old_return_statements = $this->return_statements; - $this->return_statements = true; - - // Get list of existing indexes - $indexes = $this->get_existing_indexes($table_name, $column_name); - $unique_indexes = $this->get_existing_indexes($table_name, $column_name, true); - - // Drop any indexes - if (!empty($indexes) || !empty($unique_indexes)) - { - $drop_indexes = array_merge(array_keys($indexes), array_keys($unique_indexes)); - foreach ($drop_indexes as $index_name) - { - $result = $this->sql_index_drop($table_name, $this->strip_table_name_from_index_name($table_name, $index_name)); - $statements = array_merge($statements, $result); - } - } - - $temp_column_name = 'temp_' . substr(md5($column_name), 0, 25); - // Add a temporary table with the new type - $result = $this->sql_column_add($table_name, $temp_column_name, $original_column_data); - $statements = array_merge($statements, $result); - - // Copy the data to the new column - $statements[] = 'UPDATE ' . $table_name . ' SET ' . $temp_column_name . ' = ' . $column_name; - - // Drop the original column - $result = $this->sql_column_remove($table_name, $column_name); - $statements = array_merge($statements, $result); - - // Recreate the original column with the new type - $result = $this->sql_column_add($table_name, $column_name, $original_column_data); - $statements = array_merge($statements, $result); - - if (!empty($indexes)) - { - // Recreate indexes after we changed the column - foreach ($indexes as $index_name => $index_data) - { - $result = $this->sql_create_index($table_name, $this->strip_table_name_from_index_name($table_name, $index_name), $index_data); - $statements = array_merge($statements, $result); - } - } - - if (!empty($unique_indexes)) - { - // Recreate unique indexes after we changed the column - foreach ($unique_indexes as $index_name => $index_data) - { - $result = $this->sql_create_unique_index($table_name, $this->strip_table_name_from_index_name($table_name, $index_name), $index_data); - $statements = array_merge($statements, $result); - } - } - - // Copy the data to the original column - $statements[] = 'UPDATE ' . $table_name . ' SET ' . $column_name . ' = ' . $temp_column_name; - - // Drop the temporary column again - $result = $this->sql_column_remove($table_name, $temp_column_name); - $statements = array_merge($statements, $result); - - $this->return_statements = $old_return_statements; - break; - - case 'sqlite3': - - if ($inline && $this->return_statements) - { - return $column_name . ' ' . $column_data['column_type_sql']; - } - - $recreate_queries = $this->sqlite_get_recreate_table_queries($table_name); - if (empty($recreate_queries)) - { - break; - } - - $statements[] = 'begin'; - - $sql_create_table = array_shift($recreate_queries); - - // Create a temp table and populate it, destroy the existing one - $statements[] = preg_replace('#CREATE\s+TABLE\s+"?' . $table_name . '"?#i', 'CREATE TEMPORARY TABLE ' . $table_name . '_temp', $sql_create_table); - $statements[] = 'INSERT INTO ' . $table_name . '_temp SELECT * FROM ' . $table_name; - $statements[] = 'DROP TABLE ' . $table_name; - - preg_match('#\((.*)\)#s', $sql_create_table, $matches); - - $new_table_cols = trim($matches[1]); - $old_table_cols = preg_split('/,(?![\s\w]+\))/m', $new_table_cols); - $column_list = array(); - - foreach ($old_table_cols as $key => $declaration) - { - $declaration = trim($declaration); - - // Check for the beginning of the constraint section and stop - if (preg_match('/[^\(]*\s*PRIMARY KEY\s+\(/', $declaration) || - preg_match('/[^\(]*\s*UNIQUE\s+\(/', $declaration) || - preg_match('/[^\(]*\s*FOREIGN KEY\s+\(/', $declaration) || - preg_match('/[^\(]*\s*CHECK\s+\(/', $declaration)) - { - break; - } - - $entities = preg_split('#\s+#', $declaration); - $column_list[] = $entities[0]; - if ($entities[0] == $column_name) - { - $old_table_cols[$key] = $column_name . ' ' . $column_data['column_type_sql']; - } - } - - $columns = implode(',', $column_list); - - // Create a new table and fill it up. destroy the temp one - $statements[] = 'CREATE TABLE ' . $table_name . ' (' . implode(',', $old_table_cols) . ');'; - $statements = array_merge($statements, $recreate_queries); - - $statements[] = 'INSERT INTO ' . $table_name . ' (' . $columns . ') SELECT ' . $columns . ' FROM ' . $table_name . '_temp;'; - $statements[] = 'DROP TABLE ' . $table_name . '_temp'; - - $statements[] = 'commit'; - - break; - } - - return $this->_sql_run_sql($statements); - } - - /** - * Get a list with existing indexes for the column - * - * @param string $table_name - * @param string $column_name - * @param bool $unique Should we get unique indexes or normal ones - * @return array Array with Index name => columns - */ - public function get_existing_indexes($table_name, $column_name, $unique = false) - { - switch ($this->sql_layer) - { - case 'mysql_41': - case 'sqlite3': - // Not supported - throw new \Exception('DBMS is not supported'); - break; - } - - $sql = ''; - $existing_indexes = array(); - - switch ($this->sql_layer) - { - case 'oracle': - $sql = "SELECT ix.index_name AS phpbb_index_name, ix.uniqueness AS is_unique - FROM all_ind_columns ixc, all_indexes ix - WHERE ix.index_name = ixc.index_name - AND ixc.table_name = '" . strtoupper($table_name) . "' - AND ixc.column_name = '" . strtoupper($column_name) . "'"; - break; - } - - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - if (!isset($row['is_unique']) || ($unique && $row['is_unique'] == 'UNIQUE') || (!$unique && $row['is_unique'] == 'NONUNIQUE')) - { - $existing_indexes[$row['phpbb_index_name']] = array(); - } - } - $this->db->sql_freeresult($result); - - if (empty($existing_indexes)) - { - return array(); - } - - switch ($this->sql_layer) - { - case 'oracle': - $sql = "SELECT index_name AS phpbb_index_name, column_name AS phpbb_column_name - FROM all_ind_columns - WHERE table_name = '" . strtoupper($table_name) . "' - AND " . $this->db->sql_in_set('index_name', array_keys($existing_indexes)); - break; - } - - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - $existing_indexes[$row['phpbb_index_name']][] = $row['phpbb_column_name']; - } - $this->db->sql_freeresult($result); - - return $existing_indexes; - } - - /** - * Returns the Queries which are required to recreate a table including indexes - * - * @param string $table_name - * @param string $remove_column When we drop a column, we remove the column - * from all indexes. If the index has no other - * column, we drop it completly. - * @return array - */ - protected function sqlite_get_recreate_table_queries($table_name, $remove_column = '') - { - $queries = array(); - - $sql = "SELECT sql - FROM sqlite_master - WHERE type = 'table' - AND name = '{$table_name}'"; - $result = $this->db->sql_query($sql); - $sql_create_table = $this->db->sql_fetchfield('sql'); - $this->db->sql_freeresult($result); - - if (!$sql_create_table) - { - return array(); - } - $queries[] = $sql_create_table; - - $sql = "SELECT sql - FROM sqlite_master - WHERE type = 'index' - AND tbl_name = '{$table_name}'"; - $result = $this->db->sql_query($sql); - while ($sql_create_index = $this->db->sql_fetchfield('sql')) - { - if ($remove_column) - { - $match = array(); - preg_match('#(?:[\w ]+)\((.*)\)#', $sql_create_index, $match); - if (!isset($match[1])) - { - continue; - } - - // Find and remove $remove_column from the index - $columns = explode(', ', $match[1]); - $found_column = array_search($remove_column, $columns); - if ($found_column !== false) - { - unset($columns[$found_column]); - - // If the column list is not empty add the index to the list - if (!empty($columns)) - { - $queries[] = str_replace($match[1], implode(', ', $columns), $sql_create_index); - } - } - else - { - $queries[] = $sql_create_index; - } - } - else - { - $queries[] = $sql_create_index; - } - } - $this->db->sql_freeresult($result); - - return $queries; - } -} diff --git a/install/update/new/phpbb/di/container_builder.php b/install/update/new/phpbb/di/container_builder.php deleted file mode 100644 index 70ceb9b..0000000 --- a/install/update/new/phpbb/di/container_builder.php +++ /dev/null @@ -1,678 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\di; - -use phpbb\filesystem\filesystem; -use Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper; -use Symfony\Component\Config\ConfigCache; -use Symfony\Component\Config\FileLocator; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Dumper\PhpDumper; -use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; -use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; -use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass; -use Symfony\Component\Filesystem\Exception\IOException; -use Symfony\Component\Finder\Finder; -use Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass; - -class container_builder -{ - /** - * @var string The environment to use. - */ - protected $environment; - - /** - * @var string phpBB Root Path - */ - protected $phpbb_root_path; - - /** - * @var string php file extension - */ - protected $php_ext; - - /** - * The container under construction - * - * @var ContainerBuilder - */ - protected $container; - - /** - * @var \phpbb\db\driver\driver_interface - */ - protected $dbal_connection = null; - - /** - * Indicates whether extensions should be used (default to true). - * - * @var bool - */ - protected $use_extensions = true; - - /** - * Defines a custom path to find the configuration of the container (default to $this->phpbb_root_path . 'config') - * - * @var string - */ - protected $config_path = null; - - /** - * Indicates whether the container should be dumped to the filesystem (default to true). - * - * If DEBUG_CONTAINER is set this option is ignored and a new container is build. - * - * @var bool - */ - protected $use_cache = true; - - /** - * Indicates if the container should be compiled automatically (default to true). - * - * @var bool - */ - protected $compile_container = true; - - /** - * Custom parameters to inject into the container. - * - * Default to: - * array( - * 'core.root_path', $this->phpbb_root_path, - * 'core.php_ext', $this->php_ext, - * ); - * - * @var array - */ - protected $custom_parameters = []; - - /** - * @var \phpbb\config_php_file - */ - protected $config_php_file; - - /** - * @var string - */ - protected $cache_dir; - - /** - * @var array - */ - private $container_extensions; - - /** @var \Exception */ - private $build_exception; - - /** - * Constructor - * - * @param string $phpbb_root_path Path to the phpbb includes directory. - * @param string $php_ext php file extension - */ - public function __construct($phpbb_root_path, $php_ext) - { - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - } - - /** - * Build and return a new Container respecting the current configuration - * - * @return \phpbb_cache_container|ContainerBuilder - */ - public function get_container() - { - try - { - $container_filename = $this->get_container_filename(); - $config_cache = new ConfigCache($container_filename, defined('DEBUG')); - if ($this->use_cache && $config_cache->isFresh()) - { - if ($this->use_extensions) - { - $autoload_cache = new ConfigCache($this->get_autoload_filename(), defined('DEBUG')); - if (!$autoload_cache->isFresh()) - { - // autoload cache should be refreshed - $this->load_extensions(); - } - - require($this->get_autoload_filename()); - } - - require($config_cache->getPath()); - $this->container = new \phpbb_cache_container(); - } - else - { - $this->container_extensions = [ - new extension\core($this->get_config_path()), - ]; - - if ($this->use_extensions) - { - $this->load_extensions(); - } - - // Add tables extension after all extensions - $this->container_extensions[] = new extension\tables(); - - // Inject the config - if ($this->config_php_file) - { - $this->container_extensions[] = new extension\config($this->config_php_file); - } - - $this->container = $this->create_container($this->container_extensions); - - // Easy collections through tags - $this->container->addCompilerPass(new pass\collection_pass()); - - // Event listeners "phpBB style" - $this->container->addCompilerPass(new RegisterListenersPass('dispatcher', 'event.listener_listener', 'event.listener')); - - // Event listeners "Symfony style" - $this->container->addCompilerPass(new RegisterListenersPass('dispatcher')); - - if ($this->use_extensions) - { - $this->register_ext_compiler_pass(); - } - - $filesystem = new filesystem(); - $loader = new YamlFileLoader($this->container, new FileLocator($filesystem->realpath($this->get_config_path()))); - $loader->load($this->container->getParameter('core.environment') . '/config.yml'); - - $this->inject_custom_parameters(); - - if ($this->compile_container) - { - $this->container->compile(); - - if ($this->use_cache) - { - $this->dump_container($config_cache); - } - } - } - - if ($this->compile_container && $this->config_php_file) - { - $this->container->set('config.php', $this->config_php_file); - } - - $this->inject_dbal_driver(); - - return $this->container; - } - catch (\Exception $e) - { - // Don't try to recover if we are in the development environment - if ($this->get_environment() === 'development') - { - throw $e; - } - - if ($this->build_exception === null) - { - $this->build_exception = $e; - - return $this - ->without_extensions() - ->without_cache() - ->with_custom_parameters(array_merge($this->custom_parameters, [ - 'container_exception' => $e, - ])) - ->get_container(); - } - else - { - // Rethrow the original exception if it's still failing - throw $this->build_exception; - } - } - } - - /** - * Enable the extensions. - * - * @param string $environment The environment to use - * @return $this - */ - public function with_environment($environment) - { - $this->environment = $environment; - - return $this; - } - - /** - * Enable the extensions. - * - * @return $this - */ - public function with_extensions() - { - $this->use_extensions = true; - - return $this; - } - - /** - * Disable the extensions. - * - * @return $this - */ - public function without_extensions() - { - $this->use_extensions = false; - - return $this; - } - - /** - * Enable the caching of the container. - * - * If DEBUG_CONTAINER is set this option is ignored and a new container is build. - * - * @return $this - */ - public function with_cache() - { - $this->use_cache = true; - - return $this; - } - - /** - * Disable the caching of the container. - * - * @return $this - */ - public function without_cache() - { - $this->use_cache = false; - - return $this; - } - - /** - * Set the cache directory. - * - * @param string $cache_dir The cache directory. - * @return $this - */ - public function with_cache_dir($cache_dir) - { - $this->cache_dir = $cache_dir; - - return $this; - } - - /** - * Enable the compilation of the container. - * - * @return $this - */ - public function with_compiled_container() - { - $this->compile_container = true; - - return $this; - } - - /** - * Disable the compilation of the container. - * - * @return $this - */ - public function without_compiled_container() - { - $this->compile_container = false; - - return $this; - } - - /** - * Set a custom path to find the configuration of the container. - * - * @param string $config_path - * @return $this - */ - public function with_config_path($config_path) - { - $this->config_path = $config_path; - - return $this; - } - - /** - * Set custom parameters to inject into the container. - * - * @param array $custom_parameters - * @return $this - */ - public function with_custom_parameters($custom_parameters) - { - $this->custom_parameters = $custom_parameters; - - return $this; - } - - /** - * Set custom parameters to inject into the container. - * - * @param \phpbb\config_php_file $config_php_file - * @return $this - */ - public function with_config(\phpbb\config_php_file $config_php_file) - { - $this->config_php_file = $config_php_file; - - return $this; - } - - /** - * Returns the path to the container configuration (default: root_path/config) - * - * @return string - */ - protected function get_config_path() - { - return $this->config_path ?: $this->phpbb_root_path . 'config'; - } - - /** - * Returns the path to the cache directory (default: root_path/cache/environment). - * - * @return string Path to the cache directory. - */ - protected function get_cache_dir() - { - return $this->cache_dir ?: $this->phpbb_root_path . 'cache/' . $this->get_environment() . '/'; - } - - /** - * Load the enabled extensions. - */ - protected function load_extensions() - { - if ($this->config_php_file !== null) - { - // Build an intermediate container to load the ext list from the database - $container_builder = new container_builder($this->phpbb_root_path, $this->php_ext); - $ext_container = $container_builder - ->without_cache() - ->without_extensions() - ->with_config($this->config_php_file) - ->with_config_path($this->get_config_path()) - ->with_environment('production') - ->without_compiled_container() - ->get_container() - ; - - $ext_container->register('cache.driver', '\\phpbb\\cache\\driver\\dummy'); - $ext_container->compile(); - - $extensions = $ext_container->get('ext.manager')->all_enabled(); - - // Load each extension found - $autoloaders = ' $path) - { - $extension_class = '\\' . str_replace('/', '\\', $ext_name) . '\\di\\extension'; - - if (!class_exists($extension_class)) - { - $extension_class = '\\phpbb\\extension\\di\\extension_base'; - } - - $this->container_extensions[] = new $extension_class($ext_name, $path); - - // Load extension autoloader - $filename = $path . 'vendor/autoload.php'; - if (file_exists($filename)) - { - $autoloaders .= "require('{$filename}');\n"; - } - } - - $configCache = new ConfigCache($this->get_autoload_filename(), false); - $configCache->write($autoloaders); - - require($this->get_autoload_filename()); - } - else - { - // To load the extensions we need the database credentials. - // Automatically disable the extensions if we don't have them. - $this->use_extensions = false; - } - } - - /** - * Dump the container to the disk. - * - * @param ConfigCache $cache The config cache - */ - protected function dump_container($cache) - { - try - { - $dumper = new PhpDumper($this->container); - $proxy_dumper = new ProxyDumper(); - $dumper->setProxyDumper($proxy_dumper); - - $cached_container_dump = $dumper->dump(array( - 'class' => 'phpbb_cache_container', - 'base_class' => 'Symfony\\Component\\DependencyInjection\\Container', - )); - - $cache->write($cached_container_dump, $this->container->getResources()); - } - catch (IOException $e) - { - // Don't fail if the cache isn't writeable - } - } - - /** - * Create the ContainerBuilder object - * - * @param array $extensions Array of Container extension objects - * @return ContainerBuilder object - */ - protected function create_container(array $extensions) - { - $container = new ContainerBuilder(new ParameterBag($this->get_core_parameters())); - $container->setProxyInstantiator(new proxy_instantiator($this->get_cache_dir())); - - $extensions_alias = array(); - - foreach ($extensions as $extension) - { - $container->registerExtension($extension); - $extensions_alias[] = $extension->getAlias(); - } - - $container->getCompilerPassConfig()->setMergePass(new MergeExtensionConfigurationPass($extensions_alias)); - - return $container; - } - - /** - * Inject the customs parameters into the container - */ - protected function inject_custom_parameters() - { - foreach ($this->custom_parameters as $key => $value) - { - $this->container->setParameter($key, $value); - } - } - - /** - * Inject the dbal connection driver into container - */ - protected function inject_dbal_driver() - { - if (empty($this->config_php_file)) - { - return; - } - - $config_data = $this->config_php_file->get_all(); - if (!empty($config_data)) - { - if ($this->dbal_connection === null) - { - $dbal_driver_class = $this->config_php_file->convert_30_dbms_to_31($this->config_php_file->get('dbms')); - /** @var \phpbb\db\driver\driver_interface $dbal_connection */ - $this->dbal_connection = new $dbal_driver_class(); - $this->dbal_connection->sql_connect( - $this->config_php_file->get('dbhost'), - $this->config_php_file->get('dbuser'), - $this->config_php_file->get('dbpasswd'), - $this->config_php_file->get('dbname'), - $this->config_php_file->get('dbport'), - false, - defined('PHPBB_DB_NEW_LINK') && PHPBB_DB_NEW_LINK - ); - } - $this->container->set('dbal.conn.driver', $this->dbal_connection); - } - } - - /** - * Returns the core parameters. - * - * @return array An array of core parameters - */ - protected function get_core_parameters() - { - return array_merge( - array( - 'core.root_path' => $this->phpbb_root_path, - 'core.php_ext' => $this->php_ext, - 'core.environment' => $this->get_environment(), - 'core.debug' => defined('DEBUG') ? DEBUG : false, - 'core.cache_dir' => $this->get_cache_dir(), - ), - $this->get_env_parameters() - ); - } - - /** - * Gets the environment parameters. - * - * Only the parameters starting with "PHPBB__" are considered. - * - * @return array An array of parameters - */ - protected function get_env_parameters() - { - $parameters = array(); - foreach ($_SERVER as $key => $value) - { - if (0 === strpos($key, 'PHPBB__')) - { - $parameters[strtolower(str_replace('__', '.', substr($key, 9)))] = $value; - } - } - - return $parameters; - } - - /** - * Get the filename under which the dumped container will be stored. - * - * @return string Path for dumped container - */ - protected function get_container_filename() - { - $container_params = [ - 'phpbb_root_path' => $this->phpbb_root_path, - 'use_extensions' => $this->use_extensions, - 'config_path' => $this->config_path, - ]; - - return $this->get_cache_dir() . 'container_' . md5(implode(',', $container_params)) . '.' . $this->php_ext; - } - - /** - * Get the filename under which the dumped extensions autoloader will be stored. - * - * @return string Path for dumped extensions autoloader - */ - protected function get_autoload_filename() - { - $container_params = [ - 'phpbb_root_path' => $this->phpbb_root_path, - 'use_extensions' => $this->use_extensions, - 'config_path' => $this->config_path, - ]; - - return $this->get_cache_dir() . 'autoload_' . md5(implode(',', $container_params)) . '.' . $this->php_ext; - } - - /** - * Return the name of the current environment. - * - * @return string - */ - protected function get_environment() - { - return $this->environment ?: PHPBB_ENVIRONMENT; - } - - private function register_ext_compiler_pass() - { - $finder = new Finder(); - $finder - ->name('*_pass.php') - ->path('di/pass') - ->files() - ->ignoreDotFiles(true) - ->ignoreUnreadableDirs(true) - ->ignoreVCS(true) - ->followLinks() - ->in($this->phpbb_root_path . 'ext') - ; - - /** @var \SplFileInfo $pass */ - foreach ($finder as $pass) - { - $filename = $pass->getPathname(); - $filename = substr($filename, 0, -strlen('.' . $pass->getExtension())); - $filename = str_replace(DIRECTORY_SEPARATOR, '/', $filename); - $className = preg_replace('#^.*ext/#', '', $filename); - $className = '\\' . str_replace('/', '\\', $className); - - if (class_exists($className) && in_array('Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface', class_implements($className), true)) - { - $this->container->addCompilerPass(new $className()); - } - } - } -} diff --git a/install/update/new/phpbb/di/extension/container_configuration.php b/install/update/new/phpbb/di/extension/container_configuration.php deleted file mode 100644 index 57e7ef6..0000000 --- a/install/update/new/phpbb/di/extension/container_configuration.php +++ /dev/null @@ -1,63 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\di\extension; - -use Symfony\Component\Config\Definition\Builder\TreeBuilder; -use Symfony\Component\Config\Definition\ConfigurationInterface; - -class container_configuration implements ConfigurationInterface -{ - - /** - * Generates the configuration tree builder. - * - * @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The tree builder - */ - public function getConfigTreeBuilder() - { - $treeBuilder = new TreeBuilder(); - $rootNode = $treeBuilder->root('core'); - $rootNode - ->children() - ->booleanNode('require_dev_dependencies')->defaultValue(false)->end() - ->booleanNode('allow_install_dir')->defaultValue(false)->end() - ->arrayNode('debug') - ->addDefaultsIfNotSet() - ->children() - ->booleanNode('exceptions')->defaultValue(false)->end() - ->booleanNode('load_time')->defaultValue(false)->end() - ->booleanNode('sql_explain')->defaultValue(false)->end() - ->booleanNode('memory')->defaultValue(false)->end() - ->booleanNode('show_errors')->defaultValue(false)->end() - ->end() - ->end() - ->arrayNode('twig') - ->addDefaultsIfNotSet() - ->children() - ->booleanNode('debug')->defaultValue(null)->end() - ->booleanNode('auto_reload')->defaultValue(null)->end() - ->booleanNode('enable_debug_extension')->defaultValue(false)->end() - ->end() - ->end() - ->arrayNode('session') - ->addDefaultsIfNotSet() - ->children() - ->booleanNode('log_errors')->defaultValue(false)->end() - ->end() - ->end() - ->end() - ; - return $treeBuilder; - } -} diff --git a/install/update/new/phpbb/di/extension/core.php b/install/update/new/phpbb/di/extension/core.php deleted file mode 100644 index 0497c90..0000000 --- a/install/update/new/phpbb/di/extension/core.php +++ /dev/null @@ -1,132 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\di\extension; - -use Symfony\Component\Config\FileLocator; -use Symfony\Component\Config\Resource\FileResource; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; -use Symfony\Component\HttpKernel\DependencyInjection\Extension; - -/** -* Container core extension -*/ -class core extends Extension -{ - const TWIG_OPTIONS_POSITION = 7; - - /** - * Config path - * @var string - */ - protected $config_path; - - /** - * Constructor - * - * @param string $config_path Config path - */ - public function __construct($config_path) - { - $this->config_path = $config_path; - } - - /** - * Loads a specific configuration. - * - * @param array $configs An array of configuration values - * @param ContainerBuilder $container A ContainerBuilder instance - * - * @throws \InvalidArgumentException When provided tag is not defined in this extension - */ - public function load(array $configs, ContainerBuilder $container) - { - $filesystem = new \phpbb\filesystem\filesystem(); - $loader = new YamlFileLoader($container, new FileLocator($filesystem->realpath($this->config_path))); - $loader->load($container->getParameter('core.environment') . '/container/environment.yml'); - - $config = $this->getConfiguration($configs, $container); - $config = $this->processConfiguration($config, $configs); - - if ($config['require_dev_dependencies']) - { - if (!class_exists('Goutte\Client', true)) - { - trigger_error( - 'Composer development dependencies have not been set up for the ' . $container->getParameter('core.environment') . ' environment yet, run ' . - "'php ../composer.phar install --dev' from the phpBB directory to do so.", - E_USER_ERROR - ); - } - } - - $container->setParameter('allow_install_dir', $config['allow_install_dir']); - - // Set the Twig options if defined in the environment - $definition = $container->getDefinition('template.twig.environment'); - $twig_environment_options = $definition->getArgument(static::TWIG_OPTIONS_POSITION); - if ($config['twig']['debug']) - { - $twig_environment_options['debug'] = true; - } - if ($config['twig']['auto_reload']) - { - $twig_environment_options['auto_reload'] = true; - } - - // Replace the 7th argument, the options passed to the environment - $definition->replaceArgument(static::TWIG_OPTIONS_POSITION, $twig_environment_options); - - if ($config['twig']['enable_debug_extension']) - { - $definition = $container->getDefinition('template.twig.extensions.debug'); - $definition->addTag('twig.extension'); - } - - // Set the debug options - foreach ($config['debug'] as $name => $value) - { - $container->setParameter('debug.' . $name, $value); - } - - // Set the log options - foreach ($config['session'] as $name => $value) - { - $container->setParameter('session.' . $name, $value); - } - } - - /** - * {@inheritdoc} - */ - public function getConfiguration(array $config, ContainerBuilder $container) - { - $r = new \ReflectionClass('\phpbb\di\extension\container_configuration'); - $container->addResource(new FileResource($r->getFileName())); - - return new container_configuration(); - } - - /** - * Returns the recommended alias to use in XML. - * - * This alias is also the mandatory prefix to use when using YAML. - * - * @return string The alias - */ - public function getAlias() - { - return 'core'; - } -} diff --git a/install/update/new/phpbb/di/extension/tables.php b/install/update/new/phpbb/di/extension/tables.php deleted file mode 100644 index 40684b6..0000000 --- a/install/update/new/phpbb/di/extension/tables.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\di\extension; - -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\HttpKernel\DependencyInjection\Extension; - -/** - * Container tables extension - */ -class tables extends Extension -{ - /** - * {@inheritDoc} - */ - public function load(array $configs, ContainerBuilder $container) - { - // Tables is a reserved parameter and will be overwritten at all times - $tables = []; - - // Add access via 'tables' parameter to acquire array with all tables - $parameterBag = $container->getParameterBag(); - $parameters = $parameterBag->all(); - foreach ($parameters as $parameter_name => $parameter_value) - { - if (!preg_match('/tables\.(.+)/', $parameter_name, $matches)) - { - continue; - } - - $tables[$matches[1]] = $parameter_value; - } - - $container->setParameter('tables', $tables); - } - - /** - * Returns the recommended alias to use in XML. - * - * This alias is also the mandatory prefix to use when using YAML. - * - * @return string The alias - */ - public function getAlias() - { - return 'tables'; - } -} diff --git a/install/update/new/phpbb/di/service_collection.php b/install/update/new/phpbb/di/service_collection.php deleted file mode 100644 index 6298670..0000000 --- a/install/update/new/phpbb/di/service_collection.php +++ /dev/null @@ -1,122 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\di; - -use Symfony\Component\DependencyInjection\ContainerInterface; - -/** -* Collection of services to be configured at container compile time. -*/ -class service_collection extends \ArrayObject -{ - /** - * @var \Symfony\Component\DependencyInjection\ContainerInterface - */ - protected $container; - - /** - * @var array - */ - protected $service_classes; - - /** - * Constructor - * - * @param ContainerInterface $container Container object - */ - public function __construct(ContainerInterface $container) - { - $this->container = $container; - $this->service_classes = array(); - } - - /** - * {@inheritdoc} - */ - public function getIterator() - { - return new service_collection_iterator($this); - } - - /** - * {@inheritdoc} - */ - public function offsetGet($index) - { - return $this->container->get($index); - } - - /** - * Add a service to the collection - * - * @param string $name The service name - * @return void - */ - public function add($name) - { - $this->offsetSet($name, false); - } - - /** - * Add a service's class to the collection - * - * @param string $service_id - * @param string $class - */ - public function add_service_class($service_id, $class) - { - $this->service_classes[$service_id] = $class; - } - - /** - * Get services' classes - * - * @return array - */ - public function get_service_classes() - { - return $this->service_classes; - } - - /** - * Returns the service associated to a class - * - * @return mixed - * @throw \RuntimeException if the - */ - public function get_by_class($class) - { - $service_id = null; - - foreach ($this->service_classes as $id => $service_class) - { - if ($service_class === $class) - { - if ($service_id !== null) - { - throw new \RuntimeException('More than one service definitions found for class "'.$class.'" in collection.'); - } - - $service_id = $id; - } - } - - if ($service_id === null) - { - throw new \RuntimeException('No service found for class "'.$class.'" in collection.'); - } - - return $this->offsetGet($service_id); - } -} diff --git a/install/update/new/phpbb/event/md_exporter.php b/install/update/new/phpbb/event/md_exporter.php deleted file mode 100644 index 1a2d7c9..0000000 --- a/install/update/new/phpbb/event/md_exporter.php +++ /dev/null @@ -1,568 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\event; - -/** -* Crawls through a markdown file and grabs all events -*/ -class md_exporter -{ - /** @var string Path where we look for files*/ - protected $path; - - /** @var string phpBB Root Path */ - protected $root_path; - - /** @var string The minimum version for the events to return */ - protected $min_version; - - /** @var string The maximum version for the events to return */ - protected $max_version; - - /** @var string */ - protected $filter; - - /** @var string */ - protected $current_event; - - /** @var array */ - protected $events; - - /** - * @param string $phpbb_root_path - * @param mixed $extension String 'vendor/ext' to filter, null for phpBB core - * @param string $min_version - * @param string $max_version - */ - public function __construct($phpbb_root_path, $extension = null, $min_version = null, $max_version = null) - { - $this->root_path = $phpbb_root_path; - $this->path = $this->root_path; - if ($extension) - { - $this->path .= 'ext/' . $extension . '/'; - } - - $this->events = array(); - $this->events_by_file = array(); - $this->filter = $this->current_event = ''; - $this->min_version = $min_version; - $this->max_version = $max_version; - } - - /** - * Get the list of all events - * - * @return array Array with events: name => details - */ - public function get_events() - { - return $this->events; - } - - /** - * @param string $md_file Relative from phpBB root - * @return int Number of events found - * @throws \LogicException - */ - public function crawl_phpbb_directory_adm($md_file) - { - $this->crawl_eventsmd($md_file, 'adm'); - - $file_list = $this->get_recursive_file_list($this->path . 'adm/style/'); - foreach ($file_list as $file) - { - $file_name = 'adm/style/' . $file; - $this->validate_events_from_file($file_name, $this->crawl_file_for_events($file_name)); - } - - return count($this->events); - } - - /** - * @param string $md_file Relative from phpBB root - * @return int Number of events found - * @throws \LogicException - */ - public function crawl_phpbb_directory_styles($md_file) - { - $this->crawl_eventsmd($md_file, 'styles'); - - $styles = array('prosilver'); - foreach ($styles as $style) - { - $file_list = $this->get_recursive_file_list( - $this->path . 'styles/' . $style . '/template/' - ); - - foreach ($file_list as $file) - { - $file_name = 'styles/' . $style . '/template/' . $file; - $this->validate_events_from_file($file_name, $this->crawl_file_for_events($file_name)); - } - } - - return count($this->events); - } - - /** - * @param string $md_file Relative from phpBB root - * @param string $filter Should be 'styles' or 'adm' - * @return int Number of events found - * @throws \LogicException - */ - public function crawl_eventsmd($md_file, $filter) - { - if (!file_exists($this->path . $md_file)) - { - throw new \LogicException("The event docs file '{$md_file}' could not be found"); - } - - $file_content = file_get_contents($this->path . $md_file); - $this->filter = $filter; - - $events = explode("\n\n", $file_content); - foreach ($events as $event) - { - // Last row of the file - if (strpos($event, "\n===\n") === false) - { - continue; - } - - list($event_name, $details) = explode("\n===\n", $event, 2); - $this->validate_event_name($event_name); - $sorted_events = [$this->current_event, $event_name]; - natsort($sorted_events); - $this->current_event = $event_name; - - if (isset($this->events[$this->current_event])) - { - throw new \LogicException("The event '{$this->current_event}' is defined multiple times"); - } - - // Use array_values() to get actual first element and check against natural order - if (array_values($sorted_events)[0] === $event_name) - { - throw new \LogicException("The event '{$sorted_events[1]}' should be defined before '{$sorted_events[0]}'"); - } - - if (($this->filter == 'adm' && strpos($this->current_event, 'acp_') !== 0) - || ($this->filter == 'styles' && strpos($this->current_event, 'acp_') === 0)) - { - continue; - } - - list($file_details, $details) = explode("\n* Since: ", $details, 2); - - $changed_versions = array(); - if (strpos($details, "\n* Changed: ") !== false) - { - list($since, $details) = explode("\n* Changed: ", $details, 2); - while (strpos($details, "\n* Changed: ") !== false) - { - list($changed, $details) = explode("\n* Changed: ", $details, 2); - $changed_versions[] = $changed; - } - list($changed, $description) = explode("\n* Purpose: ", $details, 2); - $changed_versions[] = $changed; - } - else - { - list($since, $description) = explode("\n* Purpose: ", $details, 2); - $changed_versions = array(); - } - - $files = $this->validate_file_list($file_details); - $since = $this->validate_since($since); - $changes = array(); - foreach ($changed_versions as $changed) - { - list($changed_version, $changed_description) = $this->validate_changed($changed); - - if (isset($changes[$changed_version])) - { - throw new \LogicException("Duplicate change information found for event '{$this->current_event}'"); - } - - $changes[$changed_version] = $changed_description; - } - $description = trim($description, "\n") . "\n"; - - if (!$this->version_is_filtered($since)) - { - $is_filtered = false; - foreach ($changes as $version => $null) - { - if ($this->version_is_filtered($version)) - { - $is_filtered = true; - break; - } - } - - if (!$is_filtered) - { - continue; - } - } - - $this->events[$event_name] = array( - 'event' => $this->current_event, - 'files' => $files, - 'since' => $since, - 'changed' => $changes, - 'description' => $description, - ); - } - - return count($this->events); - } - - /** - * The version to check - * - * @param string $version - * @return bool - */ - protected function version_is_filtered($version) - { - return (!$this->min_version || phpbb_version_compare($this->min_version, $version, '<=')) - && (!$this->max_version || phpbb_version_compare($this->max_version, $version, '>=')); - } - - /** - * Format the php events as a wiki table - * - * @param string $action - * @return string Number of events found - */ - public function export_events_for_wiki($action = '') - { - if ($this->filter === 'adm') - { - if ($action === 'diff') - { - $wiki_page = '=== ACP Template Events ===' . "\n"; - } - else - { - $wiki_page = '= ACP Template Events =' . "\n"; - } - $wiki_page .= '{| class="zebra sortable" cellspacing="0" cellpadding="5"' . "\n"; - $wiki_page .= '! Identifier !! Placement !! Added in Release !! Explanation' . "\n"; - } - else - { - if ($action === 'diff') - { - $wiki_page = '=== Template Events ===' . "\n"; - } - else - { - $wiki_page = '= Template Events =' . "\n"; - } - $wiki_page .= '{| class="zebra sortable" cellspacing="0" cellpadding="5"' . "\n"; - $wiki_page .= '! Identifier !! Prosilver Placement (If applicable) !! Added in Release !! Explanation' . "\n"; - } - - foreach ($this->events as $event_name => $event) - { - $wiki_page .= "|- id=\"{$event_name}\"\n"; - $wiki_page .= "| [[#{$event_name}|{$event_name}]] || "; - - if ($this->filter === 'adm') - { - $wiki_page .= implode(', ', $event['files']['adm']); - } - else - { - $wiki_page .= implode(', ', $event['files']['prosilver']); - } - - $wiki_page .= " || {$event['since']} || " . str_replace("\n", ' ', $event['description']) . "\n"; - } - $wiki_page .= '|}' . "\n"; - - return $wiki_page; - } - - /** - * Validates a template event name - * - * @param $event_name - * @return null - * @throws \LogicException - */ - public function validate_event_name($event_name) - { - if (!preg_match('#^([a-z][a-z0-9]*(?:_[a-z][a-z0-9]*)+)$#', $event_name)) - { - throw new \LogicException("Invalid event name '{$event_name}'"); - } - } - - /** - * Validate "Since" Information - * - * @param string $since - * @return string - * @throws \LogicException - */ - public function validate_since($since) - { - if (!$this->validate_version($since)) - { - throw new \LogicException("Invalid since information found for event '{$this->current_event}'"); - } - - return $since; - } - - /** - * Validate "Changed" Information - * - * @param string $changed - * @return string - * @throws \LogicException - */ - public function validate_changed($changed) - { - if (strpos($changed, ' ') !== false) - { - list($version, $description) = explode(' ', $changed, 2); - } - else - { - $version = $changed; - $description = ''; - } - - if (!$this->validate_version($version)) - { - throw new \LogicException("Invalid changed information found for event '{$this->current_event}'"); - } - - return array($version, $description); - } - - /** - * Validate "version" Information - * - * @param string $version - * @return bool True if valid, false otherwise - */ - public function validate_version($version) - { - return preg_match('#^\d+\.\d+\.\d+(?:-(?:a|b|RC|pl)\d+)?$#', $version); - } - - /** - * Validate the files list - * - * @param string $file_details - * @return array - * @throws \LogicException - */ - public function validate_file_list($file_details) - { - $files_list = array( - 'prosilver' => array(), - 'adm' => array(), - ); - - // Multi file list - if (strpos($file_details, "* Locations:\n + ") === 0) - { - $file_details = substr($file_details, strlen("* Locations:\n + ")); - $files = explode("\n + ", $file_details); - foreach ($files as $file) - { - if (!preg_match('#^([^ ]+)( \([0-9]+\))?$#', $file)) - { - throw new \LogicException("Invalid event instances for file '{$file}' found for event '{$this->current_event}'", 1); - } - - list($file) = explode(" ", $file); - - if (!file_exists($this->path . $file) || substr($file, -5) !== '.html') - { - throw new \LogicException("Invalid file '{$file}' not found for event '{$this->current_event}'", 2); - } - - if (($this->filter !== 'adm') && strpos($file, 'styles/prosilver/template/') === 0) - { - $files_list['prosilver'][] = substr($file, strlen('styles/prosilver/template/')); - } - else if (($this->filter === 'adm') && strpos($file, 'adm/style/') === 0) - { - $files_list['adm'][] = substr($file, strlen('adm/style/')); - } - else - { - throw new \LogicException("Invalid file '{$file}' not found for event '{$this->current_event}'", 3); - } - - $this->events_by_file[$file][] = $this->current_event; - } - } - else if ($this->filter == 'adm') - { - $file = substr($file_details, strlen('* Location: ')); - if (!file_exists($this->path . $file) || substr($file, -5) !== '.html') - { - throw new \LogicException("Invalid file '{$file}' not found for event '{$this->current_event}'", 1); - } - - $files_list['adm'][] = substr($file, strlen('adm/style/')); - - $this->events_by_file[$file][] = $this->current_event; - } - else - { - throw new \LogicException("Invalid file list found for event '{$this->current_event}'", 1); - } - - return $files_list; - } - - /** - * Get all template events in a template file - * - * @param string $file - * @return array - * @throws \LogicException - */ - public function crawl_file_for_events($file) - { - if (!file_exists($this->path . $file)) - { - throw new \LogicException("File '{$file}' does not exist", 1); - } - - $event_list = array(); - $file_content = file_get_contents($this->path . $file); - - preg_match_all('/(?:{%|)/U', $file_content, $event_list); - - return $event_list[1]; - } - - /** - * Validates whether all events from $file are in the md file and vice-versa - * - * @param string $file - * @param array $events - * @return true - * @throws \LogicException - */ - public function validate_events_from_file($file, array $events) - { - if (empty($this->events_by_file[$file]) && empty($events)) - { - return true; - } - else if (empty($this->events_by_file[$file])) - { - $event_list = implode("', '", $events); - throw new \LogicException("File '{$file}' should not contain events, but contains: " - . "'{$event_list}'", 1); - } - else if (empty($events)) - { - $event_list = implode("', '", $this->events_by_file[$file]); - throw new \LogicException("File '{$file}' contains no events, but should contain: " - . "'{$event_list}'", 1); - } - - $missing_events_from_file = array(); - foreach ($this->events_by_file[$file] as $event) - { - if (!in_array($event, $events)) - { - $missing_events_from_file[] = $event; - } - } - - if (!empty($missing_events_from_file)) - { - $event_list = implode("', '", $missing_events_from_file); - throw new \LogicException("File '{$file}' does not contain events: '{$event_list}'", 2); - } - - $missing_events_from_md = array(); - foreach ($events as $event) - { - if (!in_array($event, $this->events_by_file[$file])) - { - $missing_events_from_md[] = $event; - } - } - - if (!empty($missing_events_from_md)) - { - $event_list = implode("', '", $missing_events_from_md); - throw new \LogicException("File '{$file}' contains additional events: '{$event_list}'", 3); - } - - return true; - } - - /** - * Returns a list of files in $dir - * - * Works recursive with any depth - * - * @param string $dir Directory to go through - * @return array List of files (including directories) - */ - public function get_recursive_file_list($dir) - { - try - { - $iterator = new \RecursiveIteratorIterator( - new \phpbb\recursive_dot_prefix_filter_iterator( - new \RecursiveDirectoryIterator( - $dir, - \FilesystemIterator::SKIP_DOTS - ) - ), - \RecursiveIteratorIterator::SELF_FIRST - ); - } - catch (\Exception $e) - { - return array(); - } - - $files = array(); - foreach ($iterator as $file_info) - { - /** @var \RecursiveDirectoryIterator $file_info */ - if ($file_info->isDir()) - { - continue; - } - - $relative_path = $iterator->getInnerIterator()->getSubPathname(); - - if (substr($relative_path, -5) == '.html') - { - $files[] = str_replace(DIRECTORY_SEPARATOR, '/', $relative_path); - } - } - - return $files; - } -} diff --git a/install/update/new/phpbb/extension/extension_interface.php b/install/update/new/phpbb/extension/extension_interface.php deleted file mode 100644 index 46072d4..0000000 --- a/install/update/new/phpbb/extension/extension_interface.php +++ /dev/null @@ -1,71 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\extension; - -/** -* The interface extension meta classes have to implement to run custom code -* on enable/disable/purge. -*/ -interface extension_interface -{ - /** - * Indicate whether or not the extension can be enabled. - * - * @return bool|array True if extension is enableable, array of reasons - * if not, false for generic reason. - */ - public function is_enableable(); - - /** - * enable_step is executed on enabling an extension until it returns false. - * - * Calls to this function can be made in subsequent requests, when the - * function is invoked through a webserver with a too low max_execution_time. - * - * @param mixed $old_state The return value of the previous call - * of this method, or false on the first call - * @return mixed Returns false after last step, otherwise - * temporary state which is passed as an - * argument to the next step - */ - public function enable_step($old_state); - - /** - * Disables the extension. - * - * Calls to this function can be made in subsequent requests, when the - * function is invoked through a webserver with a too low max_execution_time. - * - * @param mixed $old_state The return value of the previous call - * of this method, or false on the first call - * @return mixed Returns false after last step, otherwise - * temporary state which is passed as an - * argument to the next step - */ - public function disable_step($old_state); - - /** - * purge_step is executed on purging an extension until it returns false. - * - * Calls to this function can be made in subsequent requests, when the - * function is invoked through a webserver with a too low max_execution_time. - * - * @param mixed $old_state The return value of the previous call - * of this method, or false on the first call - * @return mixed Returns false after last step, otherwise - * temporary state which is passed as an - * argument to the next step - */ - public function purge_step($old_state); -} diff --git a/install/update/new/phpbb/extension/manager.php b/install/update/new/phpbb/extension/manager.php deleted file mode 100644 index 1ce8425..0000000 --- a/install/update/new/phpbb/extension/manager.php +++ /dev/null @@ -1,591 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\extension; - -use phpbb\exception\runtime_exception; -use phpbb\file_downloader; -use Symfony\Component\DependencyInjection\ContainerInterface; - -/** -* The extension manager provides means to activate/deactivate extensions. -*/ -class manager -{ - /** @var ContainerInterface */ - protected $container; - - protected $db; - protected $config; - protected $cache; - protected $php_ext; - protected $extensions; - protected $extension_table; - protected $phpbb_root_path; - protected $cache_name; - - /** - * Creates a manager and loads information from database - * - * @param ContainerInterface $container A container - * @param \phpbb\db\driver\driver_interface $db A database connection - * @param \phpbb\config\config $config Config object - * @param \phpbb\filesystem\filesystem_interface $filesystem - * @param string $extension_table The name of the table holding extensions - * @param string $phpbb_root_path Path to the phpbb includes directory. - * @param string $php_ext php file extension, defaults to php - * @param \phpbb\cache\service $cache A cache instance or null - * @param string $cache_name The name of the cache variable, defaults to _ext - */ - public function __construct(ContainerInterface $container, \phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\filesystem\filesystem_interface $filesystem, $extension_table, $phpbb_root_path, $php_ext = 'php', \phpbb\cache\service $cache = null, $cache_name = '_ext') - { - $this->cache = $cache; - $this->cache_name = $cache_name; - $this->config = $config; - $this->container = $container; - $this->db = $db; - $this->extension_table = $extension_table; - $this->filesystem = $filesystem; - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - - $this->extensions = ($this->cache) ? $this->cache->get($this->cache_name) : false; - - if ($this->extensions === false) - { - $this->load_extensions(); - } - } - - /** - * Loads all extension information from the database - * - * @return null - */ - public function load_extensions() - { - $this->extensions = array(); - - // Do not try to load any extensions if the extension table - // does not exist or when installing or updating. - // Note: database updater invokes this code, and in 3.0 - // there is no extension table therefore the rest of this function - // fails - if (defined('IN_INSTALL') || version_compare($this->config['version'], '3.1.0-dev', '<')) - { - return; - } - - $sql = 'SELECT * - FROM ' . $this->extension_table; - - $result = $this->db->sql_query($sql); - $extensions = $this->db->sql_fetchrowset($result); - $this->db->sql_freeresult($result); - - foreach ($extensions as $extension) - { - $extension['ext_path'] = $this->get_extension_path($extension['ext_name']); - $this->extensions[$extension['ext_name']] = $extension; - } - - ksort($this->extensions); - - if ($this->cache) - { - $this->cache->put($this->cache_name, $this->extensions); - } - } - - /** - * Generates the path to an extension - * - * @param string $name The name of the extension - * @param bool $phpbb_relative Whether the path should be relative to phpbb root - * @return string Path to an extension - */ - public function get_extension_path($name, $phpbb_relative = false) - { - $name = str_replace('.', '', $name); - - return (($phpbb_relative) ? $this->phpbb_root_path : '') . 'ext/' . $name . '/'; - } - - /** - * Instantiates the extension meta class for the extension with the given name - * - * @param string $name The extension name - * @return \phpbb\extension\extension_interface Instance of the extension meta class or - * \phpbb\extension\base if the class does not exist - */ - public function get_extension($name) - { - $extension_class_name = str_replace('/', '\\', $name) . '\\ext'; - - $migrator = $this->container->get('migrator'); - - if (class_exists($extension_class_name)) - { - return new $extension_class_name($this->container, $this->get_finder(), $migrator, $name, $this->get_extension_path($name, true)); - } - else - { - return new \phpbb\extension\base($this->container, $this->get_finder(), $migrator, $name, $this->get_extension_path($name, true)); - } - } - - /** - * Instantiates the metadata manager for the extension with the given name - * - * @param string $name The extension name - * @return \phpbb\extension\metadata_manager Instance of the metadata manager - */ - public function create_extension_metadata_manager($name) - { - if (!isset($this->extensions[$name]['metadata'])) - { - $metadata = new \phpbb\extension\metadata_manager($name, $this->get_extension_path($name, true)); - $this->extensions[$name]['metadata'] = $metadata; - } - return $this->extensions[$name]['metadata']; - } - - /** - * Update the database entry for an extension - * - * @param string $name Extension name to update - * @param array $data Data to update in the database - * @param string $action Action to perform, by default 'update', may be also 'insert' or 'delete' - */ - protected function update_state($name, $data, $action = 'update') - { - switch ($action) - { - case 'insert': - $this->extensions[$name] = $data; - $this->extensions[$name]['ext_path'] = $this->get_extension_path($name); - ksort($this->extensions); - $sql = 'INSERT INTO ' . $this->extension_table . ' ' . $this->db->sql_build_array('INSERT', $data); - $this->db->sql_query($sql); - break; - - case 'update': - $this->extensions[$name] = array_merge($this->extensions[$name], $data); - $sql = 'UPDATE ' . $this->extension_table . ' - SET ' . $this->db->sql_build_array('UPDATE', $data) . " - WHERE ext_name = '" . $this->db->sql_escape($name) . "'"; - $this->db->sql_query($sql); - break; - - case 'delete': - unset($this->extensions[$name]); - $sql = 'DELETE FROM ' . $this->extension_table . " - WHERE ext_name = '" . $this->db->sql_escape($name) . "'"; - $this->db->sql_query($sql); - break; - } - - if ($this->cache) - { - $this->cache->purge(); - } - } - - /** - * Runs a step of the extension enabling process. - * - * Allows the exentension to enable in a long running script that works - * in multiple steps across requests. State is kept for the extension - * in the extensions table. - * - * @param string $name The extension's name - * @return bool False if enabling is finished, true otherwise - */ - public function enable_step($name) - { - // ignore extensions that are already enabled - if ($this->is_enabled($name)) - { - return false; - } - - $old_state = (isset($this->extensions[$name]['ext_state'])) ? unserialize($this->extensions[$name]['ext_state']) : false; - - $extension = $this->get_extension($name); - - if (!$extension->is_enableable()) - { - return false; - } - - $state = $extension->enable_step($old_state); - - $active = ($state === false); - - $extension_data = array( - 'ext_name' => $name, - 'ext_active' => $active, - 'ext_state' => serialize($state), - ); - - $this->update_state($name, $extension_data, $this->is_configured($name) ? 'update' : 'insert'); - - if ($active) - { - $this->config->increment('assets_version', 1); - } - - return !$active; - } - - /** - * Enables an extension - * - * This method completely enables an extension. But it could be long running - * so never call this in a script that has a max_execution time. - * - * @param string $name The extension's name - * @return null - */ - public function enable($name) - { - // @codingStandardsIgnoreStart - while ($this->enable_step($name)); - // @codingStandardsIgnoreEnd - } - - /** - * Disables an extension - * - * Calls the disable method on the extension's meta class to allow it to - * process the event. - * - * @param string $name The extension's name - * @return bool False if disabling is finished, true otherwise - */ - public function disable_step($name) - { - // ignore extensions that are not enabled - if (!$this->is_enabled($name)) - { - return false; - } - - $old_state = unserialize($this->extensions[$name]['ext_state']); - - $extension = $this->get_extension($name); - $state = $extension->disable_step($old_state); - $active = ($state !== false); - - $extension_data = array( - 'ext_active' => $active, - 'ext_state' => serialize($state), - ); - $this->update_state($name, $extension_data); - - return $active; - } - - /** - * Disables an extension - * - * Disables an extension completely at once. This process could run for a - * while so never call this in a script that has a max_execution time. - * - * @param string $name The extension's name - * @return null - */ - public function disable($name) - { - // @codingStandardsIgnoreStart - while ($this->disable_step($name)); - // @codingStandardsIgnoreEnd - } - - /** - * Purge an extension - * - * Disables the extension first if active, and then calls purge on the - * extension's meta class to delete the extension's database content. - * - * @param string $name The extension's name - * @return bool False if purging is finished, true otherwise - */ - public function purge_step($name) - { - // ignore extensions that are not configured - if (!$this->is_configured($name)) - { - return false; - } - - // disable first if necessary - if ($this->extensions[$name]['ext_active']) - { - $this->disable($name); - } - - $old_state = unserialize($this->extensions[$name]['ext_state']); - - $extension = $this->get_extension($name); - $state = $extension->purge_step($old_state); - $purged = ($state === false); - - $extension_data = array( - 'ext_state' => serialize($state), - ); - - $this->update_state($name, $extension_data, $purged ? 'delete' : 'update'); - - // continue until the state is false - return !$purged; - } - - /** - * Purge an extension - * - * Purges an extension completely at once. This process could run for a while - * so never call this in a script that has a max_execution time. - * - * @param string $name The extension's name - * @return null - */ - public function purge($name) - { - // @codingStandardsIgnoreStart - while ($this->purge_step($name)); - // @codingStandardsIgnoreEnd - } - - /** - * Retrieves a list of all available extensions on the filesystem - * - * @return array An array with extension names as keys and paths to the - * extension as values - */ - public function all_available() - { - $available = array(); - if (!is_dir($this->phpbb_root_path . 'ext/')) - { - return $available; - } - - $iterator = new \RecursiveIteratorIterator( - new \phpbb\recursive_dot_prefix_filter_iterator( - new \RecursiveDirectoryIterator($this->phpbb_root_path . 'ext/', \FilesystemIterator::NEW_CURRENT_AND_KEY | \FilesystemIterator::FOLLOW_SYMLINKS) - ), - \RecursiveIteratorIterator::SELF_FIRST - ); - $iterator->setMaxDepth(2); - - foreach ($iterator as $file_info) - { - if ($file_info->isFile() && $file_info->getFilename() == 'composer.json') - { - $ext_name = $iterator->getInnerIterator()->getSubPath(); - $ext_name = str_replace(DIRECTORY_SEPARATOR, '/', $ext_name); - if ($this->is_available($ext_name)) - { - $available[$ext_name] = $this->get_extension_path($ext_name, true); - } - } - } - ksort($available); - return $available; - } - - /** - * Retrieves all configured extensions. - * - * All enabled and disabled extensions are considered configured. A purged - * extension that is no longer in the database is not configured. - * - * @param bool $phpbb_relative Whether the path should be relative to phpbb root - * - * @return array An array with extension names as keys and and the - * database stored extension information as values - */ - public function all_configured($phpbb_relative = true) - { - $configured = array(); - foreach ($this->extensions as $name => $data) - { - if ($this->is_configured($name)) - { - unset($data['metadata']); - $data['ext_path'] = ($phpbb_relative ? $this->phpbb_root_path : '') . $data['ext_path']; - $configured[$name] = $data; - } - } - return $configured; - } - - /** - * Retrieves all enabled extensions. - * @param bool $phpbb_relative Whether the path should be relative to phpbb root - * - * @return array An array with extension names as keys and and the - * database stored extension information as values - */ - public function all_enabled($phpbb_relative = true) - { - $enabled = array(); - foreach ($this->extensions as $name => $data) - { - if ($this->is_enabled($name)) - { - $enabled[$name] = ($phpbb_relative ? $this->phpbb_root_path : '') . $data['ext_path']; - } - } - return $enabled; - } - - /** - * Retrieves all disabled extensions. - * - * @param bool $phpbb_relative Whether the path should be relative to phpbb root - * - * @return array An array with extension names as keys and and the - * database stored extension information as values - */ - public function all_disabled($phpbb_relative = true) - { - $disabled = array(); - foreach ($this->extensions as $name => $data) - { - if ($this->is_disabled($name)) - { - $disabled[$name] = ($phpbb_relative ? $this->phpbb_root_path : '') . $data['ext_path']; - } - } - return $disabled; - } - - /** - * Check to see if a given extension is available on the filesystem - * - * @param string $name Extension name to check NOTE: Can be user input - * @return bool Depending on whether or not the extension is available - */ - public function is_available($name) - { - $md_manager = $this->create_extension_metadata_manager($name); - try - { - return $md_manager->get_metadata('all') && $md_manager->validate_enable(); - } - catch (\phpbb\extension\exception $e) - { - return false; - } - } - - /** - * Check to see if a given extension is enabled - * - * @param string $name Extension name to check - * @return bool Depending on whether or not the extension is enabled - */ - public function is_enabled($name) - { - return isset($this->extensions[$name]['ext_active']) && $this->extensions[$name]['ext_active']; - } - - /** - * Check to see if a given extension is disabled - * - * @param string $name Extension name to check - * @return bool Depending on whether or not the extension is disabled - */ - public function is_disabled($name) - { - return isset($this->extensions[$name]['ext_active']) && !$this->extensions[$name]['ext_active']; - } - - /** - * Check to see if a given extension is configured - * - * All enabled and disabled extensions are considered configured. A purged - * extension that is no longer in the database is not configured. - * - * @param string $name Extension name to check - * @return bool Depending on whether or not the extension is configured - */ - public function is_configured($name) - { - return isset($this->extensions[$name]['ext_active']); - } - - /** - * Check the version and return the available updates (for an extension). - * - * @param \phpbb\extension\metadata_manager $md_manager The metadata manager for the version to check. - * @param bool $force_update Ignores cached data. Defaults to false. - * @param bool $force_cache Force the use of the cache. Override $force_update. - * @param string $stability Force the stability (null by default). - * @return array - * @throws runtime_exception - */ - public function version_check(\phpbb\extension\metadata_manager $md_manager, $force_update = false, $force_cache = false, $stability = null) - { - $meta = $md_manager->get_metadata('all'); - - if (!isset($meta['extra']['version-check'])) - { - throw new runtime_exception('NO_VERSIONCHECK'); - } - - $version_check = $meta['extra']['version-check']; - - $version_helper = new \phpbb\version_helper($this->cache, $this->config, new file_downloader()); - $version_helper->set_current_version($meta['version']); - $version_helper->set_file_location($version_check['host'], $version_check['directory'], $version_check['filename'], isset($version_check['ssl']) ? $version_check['ssl'] : false); - $version_helper->force_stability($stability); - - return $version_helper->get_ext_update_on_branch($force_update, $force_cache); - } - - /** - * Check to see if a given extension is purged - * - * An extension is purged if it is available, not enabled and not disabled. - * - * @param string $name Extension name to check - * @return bool Depending on whether or not the extension is purged - */ - public function is_purged($name) - { - return $this->is_available($name) && !$this->is_configured($name); - } - - /** - * Instantiates a \phpbb\finder. - * - * @param bool $use_all_available Should we load all extensions, or just enabled ones - * @return \phpbb\finder An extension finder instance - */ - public function get_finder($use_all_available = false) - { - $finder = new \phpbb\finder($this->filesystem, $this->phpbb_root_path, $this->cache, $this->php_ext, $this->cache_name . '_finder'); - if ($use_all_available) - { - $finder->set_extensions(array_keys($this->all_available())); - } - else - { - $finder->set_extensions(array_keys($this->all_enabled())); - } - return $finder; - } -} diff --git a/install/update/new/phpbb/feed/controller/feed.php b/install/update/new/phpbb/feed/controller/feed.php deleted file mode 100644 index 7826d19..0000000 --- a/install/update/new/phpbb/feed/controller/feed.php +++ /dev/null @@ -1,410 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\feed\controller; - -use phpbb\auth\auth; -use phpbb\config\config; -use phpbb\db\driver\driver_interface; -use \phpbb\event\dispatcher_interface; -use phpbb\exception\http_exception; -use phpbb\feed\feed_interface; -use phpbb\feed\exception\feed_unavailable_exception; -use phpbb\feed\exception\unauthorized_exception; -use phpbb\feed\helper as feed_helper; -use phpbb\controller\helper as controller_helper; -use phpbb\symfony_request; -use phpbb\user; -use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Routing\Generator\UrlGeneratorInterface; - -class feed -{ - /** - * @var \Twig_Environment - */ - protected $template; - - /** - * @var symfony_request - */ - protected $request; - - /** - * @var controller_helper - */ - protected $controller_helper; - - /** - * @var config - */ - protected $config; - - /** - * @var driver_interface - */ - protected $db; - - /** - * @var ContainerInterface - */ - protected $container; - - /** - * @var feed_helper - */ - protected $feed_helper; - - /** - * @var user - */ - protected $user; - - /** - * @var auth - */ - protected $auth; - - /** - * @var dispatcher_interface - */ - protected $phpbb_dispatcher; - - /** - * @var string - */ - protected $php_ext; - - /** - * Constructor - * - * @param \Twig_Environment $twig - * @param symfony_request $request - * @param controller_helper $controller_helper - * @param config $config - * @param driver_interface $db - * @param ContainerInterface $container - * @param feed_helper $feed_helper - * @param user $user - * @param auth $auth - * @param dispatcher_interface $phpbb_dispatcher - * @param string $php_ext - */ - public function __construct(\Twig_Environment $twig, symfony_request $request, controller_helper $controller_helper, config $config, driver_interface $db, ContainerInterface $container, feed_helper $feed_helper, user $user, auth $auth, dispatcher_interface $phpbb_dispatcher, $php_ext) - { - $this->request = $request; - $this->controller_helper = $controller_helper; - $this->config = $config; - $this->db = $db; - $this->container = $container; - $this->feed_helper = $feed_helper; - $this->user = $user; - $this->auth = $auth; - $this->php_ext = $php_ext; - $this->template = $twig; - $this->phpbb_dispatcher = $phpbb_dispatcher; - } - - /** - * Controller for /feed/forums route - * - * @return Response - * - * @throws http_exception when the feed is disabled - */ - public function forums() - { - if (!$this->config['feed_overall_forums']) - { - $this->send_unavailable(); - } - - return $this->send_feed($this->container->get('feed.forums')); - } - - /** - * Controller for /feed/news route - * - * @return Response - * - * @throws http_exception when the feed is disabled - */ - public function news() - { - // Get at least one news forum - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE . ' - WHERE ' . $this->db->sql_bit_and('forum_options', FORUM_OPTION_FEED_NEWS, '<> 0'); - $result = $this->db->sql_query_limit($sql, 1, 0, 600); - $s_feed_news = (int) $this->db->sql_fetchfield('forum_id'); - $this->db->sql_freeresult($result); - - if (!$s_feed_news) - { - $this->send_unavailable(); - } - - return $this->send_feed($this->container->get('feed.news')); - } - - /** - * Controller for /feed/topics route - * - * @return Response - * - * @throws http_exception when the feed is disabled - */ - public function topics() - { - if (!$this->config['feed_topics_new']) - { - $this->send_unavailable(); - } - - return $this->send_feed($this->container->get('feed.topics')); - } - - /** - * Controller for /feed/topics_new route - * - * @return Response - * - * @throws http_exception when the feed is disabled - */ - public function topics_new() - { - return $this->topics(); - } - - /** - * Controller for /feed/topics_active route - * - * @return Response - * - * @throws http_exception when the feed is disabled - */ - public function topics_active() - { - if (!$this->config['feed_topics_active']) - { - $this->send_unavailable(); - } - - return $this->send_feed($this->container->get('feed.topics_active')); - } - - /** - * Controller for /feed/forum/{forum_id} route - * - * @param int $forum_id - * - * @return Response - * - * @throws http_exception when the feed is disabled - */ - public function forum($forum_id) - { - if (!$this->config['feed_forum']) - { - $this->send_unavailable(); - } - - return $this->send_feed($this->container->get('feed.forum')->set_forum_id($forum_id)); - } - - /** - * Controller for /feed/topic/{topic_id} route - * - * @param int $topic_id - * - * @return Response - * - * @throws http_exception when the feed is disabled - */ - public function topic($topic_id) - { - if (!$this->config['feed_topic']) - { - $this->send_unavailable(); - } - - return $this->send_feed($this->container->get('feed.topic')->set_topic_id($topic_id)); - } - - /** - * Controller for /feed/{mode] route - * - * @return Response - * - * @throws http_exception when the feed is disabled - */ - public function overall() - { - if (!$this->config['feed_overall']) - { - $this->send_unavailable(); - } - - return $this->send_feed($this->container->get('feed.overall')); - } - - /** - * Display a given feed - * - * @param feed_interface $feed - * - * @return Response - */ - protected function send_feed(feed_interface $feed) - { - try - { - return $this->send_feed_do($feed); - } - catch (feed_unavailable_exception $e) - { - throw new http_exception(Response::HTTP_NOT_FOUND, $e->getMessage(), $e->get_parameters(), $e); - } - catch (unauthorized_exception $e) - { - throw new http_exception(Response::HTTP_FORBIDDEN, $e->getMessage(), $e->get_parameters(), $e); - } - } - - /** - * Really send the feed - * - * @param feed_interface $feed - * - * @return Response - * - * @throw exception\feed_exception - */ - protected function send_feed_do(feed_interface $feed) - { - $feed_updated_time = 0; - $item_vars = array(); - - $board_url = $this->feed_helper->get_board_url(); - - // Open Feed - $feed->open(); - - // Iterate through items - while ($row = $feed->get_item()) - { - /** - * Event to modify the feed row - * - * @event core.feed_modify_feed_row - * @var feed_interface feed Feed instance - * @var array row Array with feed data - * - * @since 3.1.10-RC1 - * @changed 3.3.0 Replace forum_id, mode, topic_id with feed instance - */ - $vars = array('feed', 'row'); - extract($this->phpbb_dispatcher->trigger_event('core.feed_modify_feed_row', compact($vars))); - - // BBCode options to correctly disable urls, smilies, bbcode... - if ($feed->get('options') === null) - { - // Allow all combinations - $options = 7; - - if ($feed->get('enable_bbcode') !== null && $feed->get('enable_smilies') !== null && $feed->get('enable_magic_url') !== null) - { - $options = (($row[$feed->get('enable_bbcode')]) ? OPTION_FLAG_BBCODE : 0) + (($row[$feed->get('enable_smilies')]) ? OPTION_FLAG_SMILIES : 0) + (($row[$feed->get('enable_magic_url')]) ? OPTION_FLAG_LINKS : 0); - } - } - else - { - $options = $row[$feed->get('options')]; - } - - $title = (isset($row[$feed->get('title')]) && $row[$feed->get('title')] !== '') ? $row[$feed->get('title')] : ((isset($row[$feed->get('title2')])) ? $row[$feed->get('title2')] : ''); - - $published = ($feed->get('published') !== null) ? (int) $row[$feed->get('published')] : 0; - $updated = ($feed->get('updated') !== null) ? (int) $row[$feed->get('updated')] : 0; - - $display_attachments = ($this->auth->acl_get('u_download') && $this->auth->acl_get('f_download', $row['forum_id']) && isset($row['post_attachment']) && $row['post_attachment']) ? true : false; - - $item_row = array( - 'author' => ($feed->get('creator') !== null) ? $row[$feed->get('creator')] : '', - 'published' => ($published > 0) ? $this->feed_helper->format_date($published) : '', - 'updated' => ($updated > 0) ? $this->feed_helper->format_date($updated) : '', - 'link' => '', - 'title' => censor_text($title), - 'category' => ($this->config['feed_item_statistics'] && !empty($row['forum_id'])) ? $board_url . '/viewforum.' . $this->php_ext . '?f=' . $row['forum_id'] : '', - 'category_name' => ($this->config['feed_item_statistics'] && isset($row['forum_name'])) ? $row['forum_name'] : '', - 'description' => censor_text($this->feed_helper->generate_content($row[$feed->get('text')], $row[$feed->get('bbcode_uid')], $row[$feed->get('bitfield')], $options, $row['forum_id'], ($display_attachments ? $feed->get_attachments($row['post_id']) : array()))), - 'statistics' => '', - ); - - // Adjust items, fill link, etc. - $feed->adjust_item($item_row, $row); - - $item_vars[] = $item_row; - - $feed_updated_time = max($feed_updated_time, $published, $updated); - } - - // If we do not have any items at all, sending the current time is better than sending no time. - if (!$feed_updated_time) - { - $feed_updated_time = time(); - } - - $feed->close(); - - $content = $this->template->render('feed.xml.twig', array( - // Some default assignments - // FEED_IMAGE is not used (atom) - 'FEED_IMAGE' => '', - 'SELF_LINK' => $this->controller_helper->route($this->request->attributes->get('_route'), $this->request->attributes->get('_route_params'), true, '', UrlGeneratorInterface::ABSOLUTE_URL), - 'FEED_LINK' => $board_url . '/index.' . $this->php_ext, - 'FEED_TITLE' => $this->config['sitename'], - 'FEED_SUBTITLE' => $this->config['site_desc'], - 'FEED_UPDATED' => $this->feed_helper->format_date($feed_updated_time), - 'FEED_LANG' => $this->user->lang['USER_LANG'], - 'FEED_AUTHOR' => $this->config['sitename'], - - // Feed entries - 'FEED_ROWS' => $item_vars, - )); - - $response = new Response($content); - $response->headers->set('Content-Type', 'application/atom+xml'); - $response->setCharset('UTF-8'); - $response->setLastModified(new \DateTime('@' . $feed_updated_time)); - - if (!empty($this->user->data['is_bot'])) - { - // Let reverse proxies know we detected a bot. - $response->headers->set('X-PHPBB-IS-BOT', 'yes'); - } - - return $response; - } - - /** - * Throw and exception saying that the feed isn't available - * - * @throw http_exception - */ - protected function send_unavailable() - { - throw new http_exception(404, 'FEATURE_NOT_AVAILABLE'); - } -} diff --git a/install/update/new/phpbb/feed/topics_active.php b/install/update/new/phpbb/feed/topics_active.php deleted file mode 100644 index ee7fe17..0000000 --- a/install/update/new/phpbb/feed/topics_active.php +++ /dev/null @@ -1,147 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\feed; - -/** - * Active Topics feed - * - * This will give you the last {$this->num_items} topics - * with replies made within the last {$this->sort_days} days - * including the last post. - */ -class topics_active extends topic_base -{ - protected $sort_days = 7; - - /** - * {@inheritdoc} - */ - public function set_keys() - { - parent::set_keys(); - - $this->set('author_id', 'topic_last_poster_id'); - $this->set('creator', 'topic_last_poster_name'); - } - - /** - * {@inheritdoc} - */ - protected function get_sql() - { - $forum_ids_read = $this->get_readable_forums(); - if (empty($forum_ids_read)) - { - return false; - } - - $in_fid_ary = array_intersect($forum_ids_read, $this->get_forum_ids()); - $in_fid_ary = array_diff($in_fid_ary, $this->get_passworded_forums()); - if (empty($in_fid_ary)) - { - return false; - } - - // Search for topics in last X days - $last_post_time_sql = ($this->sort_days) ? ' AND topic_last_post_time > ' . (time() - ($this->sort_days * 24 * 3600)) : ''; - - // We really have to get the post ids first! - $sql = 'SELECT topic_last_post_id, topic_last_post_time - FROM ' . TOPICS_TABLE . ' - WHERE topic_moved_id = 0 - AND ' . $this->content_visibility->get_forums_visibility_sql('topic', $in_fid_ary) . ' - ' . $last_post_time_sql . ' - ORDER BY topic_last_post_time DESC, topic_last_post_id DESC'; - $result = $this->db->sql_query_limit($sql, $this->num_items); - - $post_ids = array(); - while ($row = $this->db->sql_fetchrow($result)) - { - $post_ids[] = (int) $row['topic_last_post_id']; - } - $this->db->sql_freeresult($result); - - if (empty($post_ids)) - { - return false; - } - - parent::fetch_attachments($post_ids); - - $this->sql = array( - 'SELECT' => 'f.forum_id, f.forum_name, - t.topic_id, t.topic_title, t.topic_posts_approved, t.topic_posts_unapproved, t.topic_posts_softdeleted, t.topic_views, - t.topic_last_poster_id, t.topic_last_poster_name, t.topic_last_post_time, - p.post_id, p.post_time, p.post_edit_time, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, p.post_attachment, t.topic_visibility', - 'FROM' => array( - TOPICS_TABLE => 't', - POSTS_TABLE => 'p', - ), - 'LEFT_JOIN' => array( - array( - 'FROM' => array(FORUMS_TABLE => 'f'), - 'ON' => 'p.forum_id = f.forum_id', - ), - ), - 'WHERE' => 'p.topic_id = t.topic_id - AND ' . $this->db->sql_in_set('p.post_id', $post_ids), - 'ORDER_BY' => 'p.post_time DESC, p.post_id DESC', - ); - - return true; - } - - /** - * Returns the ids of the forums not excluded from the active list - * - * @return int[] - */ - private function get_forum_ids() - { - static $forum_ids; - - $cache_name = 'feed_topic_active_forum_ids'; - - if (!isset($forum_ids) && ($forum_ids = $this->cache->get('_' . $cache_name)) === false) - { - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE . ' - WHERE forum_type = ' . FORUM_POST . ' - AND ' . $this->db->sql_bit_and('forum_options', FORUM_OPTION_FEED_EXCLUDE, '= 0') . ' - AND ' . $this->db->sql_bit_and('forum_flags', round(log(FORUM_FLAG_ACTIVE_TOPICS, 2)), '<> 0'); - $result = $this->db->sql_query($sql); - - $forum_ids = array(); - while ($forum_id = (int) $this->db->sql_fetchfield('forum_id')) - { - $forum_ids[$forum_id] = $forum_id; - } - $this->db->sql_freeresult($result); - - $this->cache->put('_' . $cache_name, $forum_ids, 180); - } - - return $forum_ids; - } - - /** - * {@inheritdoc} - */ - public function adjust_item(&$item_row, &$row) - { - parent::adjust_item($item_row, $row); - - $item_row['title'] = (isset($row['forum_name']) && $row['forum_name'] !== '') ? $row['forum_name'] . ' ' . $this->separator . ' ' . $item_row['title'] : $item_row['title']; - } -} diff --git a/install/update/new/phpbb/files/filespec.php b/install/update/new/phpbb/files/filespec.php deleted file mode 100644 index 1e6771a..0000000 --- a/install/update/new/phpbb/files/filespec.php +++ /dev/null @@ -1,584 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\files; - -use phpbb\language\language; - -/** - * Responsible for holding all file relevant information, as well as doing file-specific operations. - * The {@link fileupload fileupload class} can be used to upload several files, each of them being this object to operate further on. - */ -class filespec -{ - /** @var string File name */ - protected $filename = ''; - - /** @var string Real name of file */ - protected $realname = ''; - - /** @var string Upload name of file */ - protected $uploadname = ''; - - /** @var string Mimetype of file */ - protected $mimetype = ''; - - /** @var string File extension */ - protected $extension = ''; - - /** @var int File size */ - protected $filesize = 0; - - /** @var int Width of file */ - protected $width = 0; - - /** @var int Height of file */ - protected $height = 0; - - /** @var array Image info including type and size */ - protected $image_info = array(); - - /** @var string Destination file name */ - protected $destination_file = ''; - - /** @var string Destination file path */ - protected $destination_path = ''; - - /** @var bool Whether file was moved */ - protected $file_moved = false; - - /** @var bool Whether file is local */ - protected $local = false; - - /** @var bool Class initialization flag */ - protected $class_initialized = false; - - /** @var array Error array */ - public $error = array(); - - /** @var upload Instance of upload class */ - public $upload; - - /** @var \phpbb\filesystem\filesystem_interface */ - protected $filesystem; - - /** @var \bantu\IniGetWrapper\IniGetWrapper ini_get() wrapper class */ - protected $php_ini; - - /** @var \FastImageSize\FastImageSize */ - protected $imagesize; - - /** @var language Language class */ - protected $language; - - /** @var string phpBB root path */ - protected $phpbb_root_path; - - /** @var \phpbb\plupload\plupload The plupload object */ - protected $plupload; - - /** @var \phpbb\mimetype\guesser phpBB Mimetype guesser */ - protected $mimetype_guesser; - - /** - * File upload class - * - * @param \phpbb\filesystem\filesystem_interface $phpbb_filesystem Filesystem - * @param language $language Language - * @param \bantu\IniGetWrapper\IniGetWrapper $php_ini ini_get() wrapper - * @param \FastImageSize\FastImageSize $imagesize Imagesize class - * @param string $phpbb_root_path phpBB root path - * @param \phpbb\mimetype\guesser $mimetype_guesser Mime type guesser - * @param \phpbb\plupload\plupload $plupload Plupload - */ - public function __construct(\phpbb\filesystem\filesystem_interface $phpbb_filesystem, language $language, \bantu\IniGetWrapper\IniGetWrapper $php_ini, \FastImageSize\FastImageSize $imagesize, $phpbb_root_path, \phpbb\mimetype\guesser $mimetype_guesser = null, \phpbb\plupload\plupload $plupload = null) - { - $this->filesystem = $phpbb_filesystem; - $this->language = $language; - $this->php_ini = $php_ini; - $this->imagesize = $imagesize; - $this->phpbb_root_path = $phpbb_root_path; - $this->plupload = $plupload; - $this->mimetype_guesser = $mimetype_guesser; - } - - /** - * Set upload ary - * - * @param array $upload_ary Upload ary - * - * @return filespec This instance of the filespec class - */ - public function set_upload_ary($upload_ary) - { - if (!isset($upload_ary) || !count($upload_ary)) - { - return $this; - } - - $this->class_initialized = true; - $this->filename = $upload_ary['tmp_name']; - $this->filesize = $upload_ary['size']; - $name = $upload_ary['name']; - $name = trim(utf8_basename($name)); - $this->realname = $this->uploadname = $name; - $this->mimetype = $upload_ary['type']; - - // Opera adds the name to the mime type - $this->mimetype = (strpos($this->mimetype, '; name') !== false) ? str_replace(strstr($this->mimetype, '; name'), '', $this->mimetype) : $this->mimetype; - - if (!$this->mimetype) - { - $this->mimetype = 'application/octet-stream'; - } - - $this->extension = strtolower(self::get_extension($this->realname)); - - // Try to get real filesize from temporary folder (not always working) ;) - $this->filesize = ($this->get_filesize($this->filename)) ?: $this->filesize; - - $this->width = $this->height = 0; - $this->file_moved = false; - - $this->local = (isset($upload_ary['local_mode'])) ? true : false; - - return $this; - } - - /** - * Set the upload namespace - * - * @param upload $namespace Instance of upload class - * - * @return filespec This instance of the filespec class - */ - public function set_upload_namespace($namespace) - { - $this->upload = $namespace; - - return $this; - } - - /** - * Check if class members were not properly initialised yet - * - * @return bool True if there was an init error, false if not - */ - public function init_error() - { - return !$this->class_initialized; - } - - /** - * Set error in error array - * - * @param mixed $error Content for error array - * - * @return \phpbb\files\filespec This instance of the filespec class - */ - public function set_error($error) - { - $this->error[] = $error; - - return $this; - } - - /** - * Cleans destination filename - * - * @param string $mode Either real, unique, or unique_ext. Real creates a - * realname, filtering some characters, lowering every - * character. Unique creates a unique filename. - * @param string $prefix Prefix applied to filename - * @param string $user_id The user_id is only needed for when cleaning a user's avatar - */ - public function clean_filename($mode = 'unique', $prefix = '', $user_id = '') - { - if ($this->init_error()) - { - return; - } - - switch ($mode) - { - case 'real': - // Remove every extension from filename (to not let the mime bug being exposed) - if (strpos($this->realname, '.') !== false) - { - $this->realname = substr($this->realname, 0, strpos($this->realname, '.')); - } - - // Replace any chars which may cause us problems with _ - $bad_chars = array("'", "\\", ' ', '/', ':', '*', '?', '"', '<', '>', '|'); - - $this->realname = rawurlencode(str_replace($bad_chars, '_', strtolower($this->realname))); - $this->realname = preg_replace("/%(\w{2})/", '_', $this->realname); - - $this->realname = $prefix . $this->realname . '.' . $this->extension; - break; - - case 'unique': - $this->realname = $prefix . md5(unique_id()); - break; - - case 'avatar': - $this->extension = strtolower($this->extension); - $this->realname = $prefix . $user_id . '.' . $this->extension; - - break; - - case 'unique_ext': - default: - $this->realname = $prefix . md5(unique_id()) . '.' . $this->extension; - } - } - - /** - * Get property from file object - * - * @param string $property Name of property - * - * @return mixed Content of property - */ - public function get($property) - { - if ($this->init_error() || !isset($this->$property)) - { - return false; - } - - return $this->$property; - } - - /** - * Check if file is an image (mime type) - * - * @return bool true if it is an image, false if not - */ - public function is_image() - { - return (strpos($this->mimetype, 'image/') === 0); - } - - /** - * Check if the file got correctly uploaded - * - * @return bool true if it is a valid upload, false if not - */ - public function is_uploaded() - { - $is_plupload = $this->plupload && $this->plupload->is_active(); - - if (!$this->local && !$is_plupload && !is_uploaded_file($this->filename)) - { - return false; - } - - if (($this->local || $is_plupload) && !file_exists($this->filename)) - { - return false; - } - - return true; - } - - /** - * Remove file - */ - public function remove() - { - if ($this->file_moved) - { - @unlink($this->destination_file); - } - } - - /** - * Get file extension - * - * @param string $filename Filename that needs to be checked - * - * @return string Extension of the supplied filename - */ - static public function get_extension($filename) - { - $filename = utf8_basename($filename); - - if (strpos($filename, '.') === false) - { - return ''; - } - - $filename = explode('.', $filename); - return array_pop($filename); - } - - /** - * Get mime type - * - * @param string $filename Filename that needs to be checked - * @return string Mime type of supplied filename - */ - public function get_mimetype($filename) - { - if ($this->mimetype_guesser !== null) - { - $mimetype = $this->mimetype_guesser->guess($filename, $this->uploadname); - - if ($mimetype !== 'application/octet-stream') - { - $this->mimetype = $mimetype; - } - } - - return $this->mimetype; - } - - /** - * Get file size - * - * @param string $filename File name of file to check - * - * @return int File size - */ - public function get_filesize($filename) - { - return @filesize($filename); - } - - - /** - * Check the first 256 bytes for forbidden content - * - * @param array $disallowed_content Array containg disallowed content - * - * @return bool False if disallowed content found, true if not - */ - public function check_content($disallowed_content) - { - if (empty($disallowed_content)) - { - return true; - } - - $fp = @fopen($this->filename, 'rb'); - - if ($fp !== false) - { - $ie_mime_relevant = fread($fp, 256); - fclose($fp); - foreach ($disallowed_content as $forbidden) - { - if (stripos($ie_mime_relevant, '<' . $forbidden) !== false) - { - return false; - } - } - } - return true; - } - - /** - * Move file to destination folder - * The phpbb_root_path variable will be applied to the destination path - * - * @param string $destination Destination path, for example $config['avatar_path'] - * @param bool $overwrite If set to true, an already existing file will be overwritten - * @param bool $skip_image_check If set to true, the check for the file to be a valid image is skipped - * @param string|bool $chmod Permission mask for chmodding the file after a successful move. - * The mode entered here reflects the mode defined by {@link phpbb_chmod()} - * - * @return bool True if file was moved, false if not - * @access public - */ - public function move_file($destination, $overwrite = false, $skip_image_check = false, $chmod = false) - { - if (count($this->error)) - { - return false; - } - - $chmod = ($chmod === false) ? CHMOD_READ | CHMOD_WRITE : $chmod; - - // We need to trust the admin in specifying valid upload directories and an attacker not being able to overwrite it... - $this->destination_path = $this->phpbb_root_path . $destination; - - // Check if the destination path exist... - if (!file_exists($this->destination_path)) - { - @unlink($this->filename); - return false; - } - - $upload_mode = ($this->php_ini->getBool('open_basedir')) ? 'move' : 'copy'; - $upload_mode = ($this->local) ? 'local' : $upload_mode; - $this->destination_file = $this->destination_path . '/' . utf8_basename($this->realname); - - // Check if the file already exist, else there is something wrong... - if (file_exists($this->destination_file) && !$overwrite) - { - @unlink($this->filename); - $this->error[] = $this->language->lang($this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR', $this->destination_file); - $this->file_moved = false; - return false; - } - else - { - if (file_exists($this->destination_file)) - { - @unlink($this->destination_file); - } - - switch ($upload_mode) - { - case 'copy': - - if (!@copy($this->filename, $this->destination_file)) - { - if (!@move_uploaded_file($this->filename, $this->destination_file)) - { - $this->error[] = $this->language->lang($this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR', $this->destination_file); - } - } - - break; - - case 'move': - - if (!@move_uploaded_file($this->filename, $this->destination_file)) - { - if (!@copy($this->filename, $this->destination_file)) - { - $this->error[] = $this->language->lang($this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR', $this->destination_file); - } - } - - break; - - case 'local': - - if (!@copy($this->filename, $this->destination_file)) - { - $this->error[] = $this->language->lang($this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR', $this->destination_file); - } - - break; - } - - // Remove temporary filename - @unlink($this->filename); - - if (count($this->error)) - { - return false; - } - - try - { - $this->filesystem->phpbb_chmod($this->destination_file, $chmod); - } - catch (\phpbb\filesystem\exception\filesystem_exception $e) - { - // Do nothing - } - } - - // Try to get real filesize from destination folder - $this->filesize = ($this->get_filesize($this->destination_file)) ?: $this->filesize; - - // Get mimetype of supplied file - $this->mimetype = $this->get_mimetype($this->destination_file); - - if ($this->is_image() && !$skip_image_check) - { - $this->width = $this->height = 0; - - $this->image_info = $this->imagesize->getImageSize($this->destination_file, $this->mimetype); - - if ($this->image_info !== false) - { - $this->width = $this->image_info['width']; - $this->height = $this->image_info['height']; - - // Check image type - $types = upload::image_types(); - - if (!isset($types[$this->image_info['type']]) || !in_array($this->extension, $types[$this->image_info['type']])) - { - if (!isset($types[$this->image_info['type']])) - { - $this->error[] = $this->language->lang('IMAGE_FILETYPE_INVALID', $this->image_info['type'], $this->mimetype); - } - else - { - $this->error[] = $this->language->lang('IMAGE_FILETYPE_MISMATCH', $types[$this->image_info['type']][0], $this->extension); - } - } - - // Make sure the dimensions match a valid image - if (empty($this->width) || empty($this->height)) - { - $this->error[] = $this->language->lang('ATTACHED_IMAGE_NOT_IMAGE'); - } - } - else - { - $this->error[] = $this->language->lang('UNABLE_GET_IMAGE_SIZE'); - } - } - - $this->file_moved = true; - $this->additional_checks(); - unset($this->upload); - - return true; - } - - /** - * Performing additional checks - * - * @return bool False if issue was found, true if not - */ - public function additional_checks() - { - if (!$this->file_moved) - { - return false; - } - - // Filesize is too big or it's 0 if it was larger than the maxsize in the upload form - if ($this->upload->max_filesize && ($this->get('filesize') > $this->upload->max_filesize || $this->filesize == 0)) - { - $max_filesize = get_formatted_filesize($this->upload->max_filesize, false); - - $this->error[] = $this->language->lang($this->upload->error_prefix . 'WRONG_FILESIZE', $max_filesize['value'], $max_filesize['unit']); - - return false; - } - - if (!$this->upload->valid_dimensions($this)) - { - $this->error[] = $this->language->lang($this->upload->error_prefix . 'WRONG_SIZE', - $this->language->lang('PIXELS', (int) $this->upload->min_width), - $this->language->lang('PIXELS', (int) $this->upload->min_height), - $this->language->lang('PIXELS', (int) $this->upload->max_width), - $this->language->lang('PIXELS', (int) $this->upload->max_height), - $this->language->lang('PIXELS', (int) $this->width), - $this->language->lang('PIXELS', (int) $this->height)); - - return false; - } - - return true; - } -} diff --git a/install/update/new/phpbb/filesystem.php b/install/update/new/phpbb/filesystem.php deleted file mode 100644 index 6ac9459..0000000 --- a/install/update/new/phpbb/filesystem.php +++ /dev/null @@ -1,21 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb; - -/** - * @deprecated 3.2.0-dev (To be removed 4.0.0) use \phpbb\filesystem\filesystem instead - */ -class filesystem extends \phpbb\filesystem\filesystem -{ -} diff --git a/install/update/new/phpbb/filesystem/filesystem.php b/install/update/new/phpbb/filesystem/filesystem.php deleted file mode 100644 index 9acead0..0000000 --- a/install/update/new/phpbb/filesystem/filesystem.php +++ /dev/null @@ -1,916 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\filesystem; - -use phpbb\filesystem\exception\filesystem_exception; - -/** - * A class with various functions that are related to paths, files and the filesystem - */ -class filesystem implements filesystem_interface -{ - /** - * Store some information about file ownership for phpBB's chmod function - * - * @var array - */ - protected $chmod_info; - - /** - * Stores current working directory - * - * @var string|bool current working directory or false if it cannot be recovered - */ - protected $working_directory; - - /** - * Symfony's Filesystem component - * - * @var \Symfony\Component\Filesystem\Filesystem - */ - protected $symfony_filesystem; - - /** - * Constructor - */ - public function __construct() - { - $this->chmod_info = array(); - $this->symfony_filesystem = new \Symfony\Component\Filesystem\Filesystem(); - $this->working_directory = null; - } - - /** - * {@inheritdoc} - */ - public function chgrp($files, $group, $recursive = false) - { - try - { - $this->symfony_filesystem->chgrp($files, $group, $recursive); - } - catch (\Symfony\Component\Filesystem\Exception\IOException $e) - { - // Try to recover filename - // By the time this is written that is at the end of the message - $error = trim($e->getMessage()); - $file = substr($error, strrpos($error, ' ')); - - throw new filesystem_exception('FILESYSTEM_CANNOT_CHANGE_FILE_GROUP', $file, array(), $e); - } - } - - /** - * {@inheritdoc} - */ - public function chmod($files, $perms = null, $recursive = false, $force_chmod_link = false) - { - if (is_null($perms)) - { - // Default to read permission for compatibility reasons - $perms = self::CHMOD_READ; - } - - // Check if we got a permission flag - if ($perms > self::CHMOD_ALL) - { - $file_perm = $perms; - - // Extract permissions - //$owner = ($file_perm >> 6) & 7; // This will be ignored - $group = ($file_perm >> 3) & 7; - $other = ($file_perm >> 0) & 7; - - // Does any permissions provided? if so we add execute bit for directories - $group = ($group !== 0) ? ($group | self::CHMOD_EXECUTE) : $group; - $other = ($other !== 0) ? ($other | self::CHMOD_EXECUTE) : $other; - - // Compute directory permissions - $dir_perm = (self::CHMOD_ALL << 6) + ($group << 3) + ($other << 3); - } - else - { - // Add execute bit to owner if execute bit is among perms - $owner_perm = (self::CHMOD_READ | self::CHMOD_WRITE) | ($perms & self::CHMOD_EXECUTE); - $file_perm = ($owner_perm << 6) + ($perms << 3) + ($perms << 0); - - // Compute directory permissions - $perm = ($perms !== 0) ? ($perms | self::CHMOD_EXECUTE) : $perms; - $dir_perm = (($owner_perm | self::CHMOD_EXECUTE) << 6) + ($perm << 3) + ($perm << 0); - } - - // Symfony's filesystem component does not support extra execution flags on directories - // so we need to implement it again - foreach ($this->to_iterator($files) as $file) - { - if ($recursive && is_dir($file) && !is_link($file)) - { - $this->chmod(new \FilesystemIterator($file), $perms, true); - } - - // Don't chmod links as mostly those require 0777 and that cannot be changed - if (is_dir($file) || (is_link($file) && $force_chmod_link)) - { - if (true !== @chmod($file, $dir_perm)) - { - throw new filesystem_exception('FILESYSTEM_CANNOT_CHANGE_FILE_PERMISSIONS', $file, array()); - } - } - else if (is_file($file)) - { - if (true !== @chmod($file, $file_perm)) - { - throw new filesystem_exception('FILESYSTEM_CANNOT_CHANGE_FILE_PERMISSIONS', $file, array()); - } - } - } - } - - /** - * {@inheritdoc} - */ - public function chown($files, $user, $recursive = false) - { - try - { - $this->symfony_filesystem->chown($files, $user, $recursive); - } - catch (\Symfony\Component\Filesystem\Exception\IOException $e) - { - // Try to recover filename - // By the time this is written that is at the end of the message - $error = trim($e->getMessage()); - $file = substr($error, strrpos($error, ' ')); - - throw new filesystem_exception('FILESYSTEM_CANNOT_CHANGE_FILE_GROUP', $file, array(), $e); - } - } - - /** - * {@inheritdoc} - */ - public function clean_path($path) - { - $exploded = explode('/', $path); - $filtered = array(); - foreach ($exploded as $part) - { - if ($part === '.' && !empty($filtered)) - { - continue; - } - - if ($part === '..' && !empty($filtered) && $filtered[count($filtered) - 1] !== '.' && $filtered[count($filtered) - 1] !== '..') - { - array_pop($filtered); - } - else - { - $filtered[] = $part; - } - } - $path = implode('/', $filtered); - return $path; - } - - /** - * {@inheritdoc} - */ - public function copy($origin_file, $target_file, $override = false) - { - try - { - $this->symfony_filesystem->copy($origin_file, $target_file, $override); - } - catch (\Symfony\Component\Filesystem\Exception\IOException $e) - { - throw new filesystem_exception('FILESYSTEM_CANNOT_COPY_FILES', '', array(), $e); - } - } - - /** - * {@inheritdoc} - */ - public function dump_file($filename, $content) - { - try - { - $this->symfony_filesystem->dumpFile($filename, $content); - } - catch (\Symfony\Component\Filesystem\Exception\IOException $e) - { - throw new filesystem_exception('FILESYSTEM_CANNOT_DUMP_FILE', $filename, array(), $e); - } - } - - /** - * {@inheritdoc} - */ - public function exists($files) - { - return $this->symfony_filesystem->exists($files); - } - - /** - * {@inheritdoc} - */ - public function is_absolute_path($path) - { - return (isset($path[0]) && $path[0] === '/' || preg_match('#^[a-z]:[/\\\]#i', $path)) ? true : false; - } - - /** - * {@inheritdoc} - */ - public function is_readable($files, $recursive = false) - { - foreach ($this->to_iterator($files) as $file) - { - if ($recursive && is_dir($file) && !is_link($file)) - { - if (!$this->is_readable(new \FilesystemIterator($file), true)) - { - return false; - } - } - - if (!is_readable($file)) - { - return false; - } - } - - return true; - } - - /** - * {@inheritdoc} - */ - public function is_writable($files, $recursive = false) - { - if (defined('PHP_WINDOWS_VERSION_MAJOR') || !function_exists('is_writable')) - { - foreach ($this->to_iterator($files) as $file) - { - if ($recursive && is_dir($file) && !is_link($file)) - { - if (!$this->is_writable(new \FilesystemIterator($file), true)) - { - return false; - } - } - - if (!$this->phpbb_is_writable($file)) - { - return false; - } - } - } - else - { - // use built in is_writable - foreach ($this->to_iterator($files) as $file) - { - if ($recursive && is_dir($file) && !is_link($file)) - { - if (!$this->is_writable(new \FilesystemIterator($file), true)) - { - return false; - } - } - - if (!is_writable($file)) - { - return false; - } - } - } - - return true; - } - - /** - * {@inheritdoc} - */ - public function make_path_relative($end_path, $start_path) - { - return $this->symfony_filesystem->makePathRelative($end_path, $start_path); - } - - /** - * {@inheritdoc} - */ - public function mirror($origin_dir, $target_dir, \Traversable $iterator = null, $options = array()) - { - try - { - $this->symfony_filesystem->mirror($origin_dir, $target_dir, $iterator, $options); - } - catch (\Symfony\Component\Filesystem\Exception\IOException $e) - { - $msg = $e->getMessage(); - $filename = substr($msg, strpos($msg, '"'), strrpos($msg, '"')); - - throw new filesystem_exception('FILESYSTEM_CANNOT_MIRROR_DIRECTORY', $filename, array(), $e); - } - } - - /** - * {@inheritdoc} - */ - public function mkdir($dirs, $mode = 0777) - { - try - { - $this->symfony_filesystem->mkdir($dirs, $mode); - } - catch (\Symfony\Component\Filesystem\Exception\IOException $e) - { - $msg = $e->getMessage(); - $filename = substr($msg, strpos($msg, '"'), strrpos($msg, '"')); - - throw new filesystem_exception('FILESYSTEM_CANNOT_CREATE_DIRECTORY', $filename, array(), $e); - } - } - - /** - * {@inheritdoc} - */ - public function phpbb_chmod($files, $perms = null, $recursive = false, $force_chmod_link = false) - { - if (is_null($perms)) - { - // Default to read permission for compatibility reasons - $perms = self::CHMOD_READ; - } - - if (empty($this->chmod_info)) - { - if (!function_exists('fileowner') || !function_exists('filegroup')) - { - $this->chmod_info['process'] = false; - } - else - { - $common_php_owner = @fileowner(__FILE__); - $common_php_group = @filegroup(__FILE__); - - // And the owner and the groups PHP is running under. - $php_uid = (function_exists('posix_getuid')) ? @posix_getuid() : false; - $php_gids = (function_exists('posix_getgroups')) ? @posix_getgroups() : false; - - // If we are unable to get owner/group, then do not try to set them by guessing - if (!$php_uid || empty($php_gids) || !$common_php_owner || !$common_php_group) - { - $this->chmod_info['process'] = false; - } - else - { - $this->chmod_info = array( - 'process' => true, - 'common_owner' => $common_php_owner, - 'common_group' => $common_php_group, - 'php_uid' => $php_uid, - 'php_gids' => $php_gids, - ); - } - } - } - - if ($this->chmod_info['process']) - { - try - { - foreach ($this->to_iterator($files) as $file) - { - $file_uid = @fileowner($file); - $file_gid = @filegroup($file); - - // Change owner - if ($file_uid !== $this->chmod_info['common_owner']) - { - $this->chown($file, $this->chmod_info['common_owner'], $recursive); - } - - // Change group - if ($file_gid !== $this->chmod_info['common_group']) - { - $this->chgrp($file, $this->chmod_info['common_group'], $recursive); - } - - clearstatcache(); - $file_uid = @fileowner($file); - $file_gid = @filegroup($file); - } - } - catch (filesystem_exception $e) - { - $this->chmod_info['process'] = false; - } - } - - // Still able to process? - if ($this->chmod_info['process']) - { - if ($file_uid === $this->chmod_info['php_uid']) - { - $php = 'owner'; - } - else if (in_array($file_gid, $this->chmod_info['php_gids'])) - { - $php = 'group'; - } - else - { - // Since we are setting the everyone bit anyway, no need to do expensive operations - $this->chmod_info['process'] = false; - } - } - - // We are not able to determine or change something - if (!$this->chmod_info['process']) - { - $php = 'other'; - } - - switch ($php) - { - case 'owner': - try - { - $this->chmod($files, $perms, $recursive, $force_chmod_link); - clearstatcache(); - if ($this->is_readable($files) && $this->is_writable($files)) - { - break; - } - } - catch (filesystem_exception $e) - { - // Do nothing - } - case 'group': - try - { - $this->chmod($files, $perms, $recursive, $force_chmod_link); - clearstatcache(); - if ((!($perms & self::CHMOD_READ) || $this->is_readable($files, $recursive)) && (!($perms & self::CHMOD_WRITE) || $this->is_writable($files, $recursive))) - { - break; - } - } - catch (filesystem_exception $e) - { - // Do nothing - } - case 'other': - default: - $this->chmod($files, $perms, $recursive, $force_chmod_link); - break; - } - } - - /** - * {@inheritdoc} - */ - public function realpath($path) - { - if (!function_exists('realpath')) - { - return $this->phpbb_own_realpath($path); - } - - $realpath = realpath($path); - - // Strangely there are provider not disabling realpath but returning strange values. :o - // We at least try to cope with them. - if ((!$this->is_absolute_path($path) && $realpath === $path) || $realpath === false) - { - return $this->phpbb_own_realpath($path); - } - - // Check for DIRECTORY_SEPARATOR at the end (and remove it!) - if (substr($realpath, -1) === DIRECTORY_SEPARATOR) - { - $realpath = substr($realpath, 0, -1); - } - - return $realpath; - } - - /** - * {@inheritdoc} - */ - public function remove($files) - { - try - { - $this->symfony_filesystem->remove($files); - } - catch (\Symfony\Component\Filesystem\Exception\IOException $e) - { - // Try to recover filename - // By the time this is written that is at the end of the message - $error = trim($e->getMessage()); - $file = substr($error, strrpos($error, ' ')); - - throw new filesystem_exception('FILESYSTEM_CANNOT_DELETE_FILES', $file, array(), $e); - } - } - - /** - * {@inheritdoc} - */ - public function rename($origin, $target, $overwrite = false) - { - try - { - $this->symfony_filesystem->rename($origin, $target, $overwrite); - } - catch (\Symfony\Component\Filesystem\Exception\IOException $e) - { - $msg = $e->getMessage(); - $filename = substr($msg, strpos($msg, '"'), strrpos($msg, '"')); - - throw new filesystem_exception('FILESYSTEM_CANNOT_RENAME_FILE', $filename, array(), $e); - } - } - - /** - * {@inheritdoc} - */ - public function symlink($origin_dir, $target_dir, $copy_on_windows = false) - { - try - { - $this->symfony_filesystem->symlink($origin_dir, $target_dir, $copy_on_windows); - } - catch (\Symfony\Component\Filesystem\Exception\IOException $e) - { - throw new filesystem_exception('FILESYSTEM_CANNOT_CREATE_SYMLINK', $origin_dir, array(), $e); - } - } - - /** - * {@inheritdoc} - */ - public function touch($files, $time = null, $access_time = null) - { - try - { - $this->symfony_filesystem->touch($files, $time, $access_time); - } - catch (\Symfony\Component\Filesystem\Exception\IOException $e) - { - // Try to recover filename - // By the time this is written that is at the end of the message - $error = trim($e->getMessage()); - $file = substr($error, strrpos($error, ' ')); - - throw new filesystem_exception('FILESYSTEM_CANNOT_TOUCH_FILES', $file, array(), $e); - } - } - - /** - * phpBB's implementation of is_writable - * - * @todo Investigate if is_writable is still buggy - * - * @param string $file file/directory to check if writable - * - * @return bool true if the given path is writable - */ - protected function phpbb_is_writable($file) - { - if (file_exists($file)) - { - // Canonicalise path to absolute path - $file = $this->realpath($file); - - if (is_dir($file)) - { - // Test directory by creating a file inside the directory - $result = @tempnam($file, 'i_w'); - - if (is_string($result) && file_exists($result)) - { - unlink($result); - - // Ensure the file is actually in the directory (returned realpathed) - return (strpos($result, $file) === 0) ? true : false; - } - } - else - { - $handle = @fopen($file, 'c'); - - if (is_resource($handle)) - { - fclose($handle); - return true; - } - } - } - else - { - // file does not exist test if we can write to the directory - $dir = dirname($file); - - if (file_exists($dir) && is_dir($dir) && $this->phpbb_is_writable($dir)) - { - return true; - } - } - - return false; - } - - /** - * Try to resolve real path when PHP's realpath failes to do so - * - * @param string $path - * @return bool|string - */ - protected function phpbb_own_realpath($path) - { - // Replace all directory separators with '/' - $path = str_replace(DIRECTORY_SEPARATOR, '/', $path); - - $is_absolute_path = false; - $path_prefix = ''; - - if ($this->is_absolute_path($path)) - { - $is_absolute_path = true; - } - else - { - // Resolve working directory and store it - if (is_null($this->working_directory)) - { - if (function_exists('getcwd')) - { - $this->working_directory = str_replace(DIRECTORY_SEPARATOR, '/', getcwd()); - } - - // - // From this point on we really just guessing - // If chdir were called we screwed - // - else if (function_exists('debug_backtrace')) - { - $call_stack = debug_backtrace(0); - $this->working_directory = str_replace(DIRECTORY_SEPARATOR, '/', dirname($call_stack[count($call_stack) - 1]['file'])); - } - else - { - // - // Assuming that the working directory is phpBB root - // we could use this as a fallback, when phpBB will use controllers - // everywhere this will be a safe assumption - // - //$dir_parts = explode(DIRECTORY_SEPARATOR, __DIR__); - //$namespace_parts = explode('\\', trim(__NAMESPACE__, '\\')); - - //$namespace_part_count = count($namespace_parts); - - // Check if we still loading from root - //if (array_slice($dir_parts, -$namespace_part_count) === $namespace_parts) - //{ - // $this->working_directory = implode('/', array_slice($dir_parts, 0, -$namespace_part_count)); - //} - //else - //{ - // $this->working_directory = false; - //} - - $this->working_directory = false; - } - } - - if ($this->working_directory !== false) - { - $is_absolute_path = true; - $path = $this->working_directory . '/' . $path; - } - } - - if ($is_absolute_path) - { - if (defined('PHP_WINDOWS_VERSION_MAJOR')) - { - $path_prefix = $path[0] . ':'; - $path = substr($path, 2); - } - else - { - $path_prefix = ''; - } - } - - $resolved_path = $this->resolve_path($path, $path_prefix, $is_absolute_path); - if ($resolved_path === false) - { - return false; - } - - if (!@file_exists($resolved_path) || (!@is_dir($resolved_path . '/') && !is_file($resolved_path))) - { - return false; - } - - // Return OS specific directory separators - $resolved = str_replace('/', DIRECTORY_SEPARATOR, $resolved_path); - - // Check for DIRECTORY_SEPARATOR at the end (and remove it!) - if (substr($resolved, -1) === DIRECTORY_SEPARATOR) - { - return substr($resolved, 0, -1); - } - - return $resolved; - } - - /** - * Convert file(s) to \Traversable object - * - * This is the same function as Symfony's toIterator, but that is private - * so we cannot use it. - * - * @param string|array|\Traversable $files filename/list of filenames - * @return \Traversable - */ - protected function to_iterator($files) - { - if (!$files instanceof \Traversable) - { - $files = new \ArrayObject(is_array($files) ? $files : array($files)); - } - - return $files; - } - - /** - * Try to resolve symlinks in path - * - * @param string $path The path to resolve - * @param string $prefix The path prefix (on windows the drive letter) - * @param bool $absolute Whether or not the path is absolute - * @param bool $return_array Whether or not to return path parts - * - * @return string|array|bool returns the resolved path or an array of parts of the path if $return_array is true - * or false if path cannot be resolved - */ - protected function resolve_path($path, $prefix = '', $absolute = false, $return_array = false) - { - if ($return_array) - { - $path = str_replace(DIRECTORY_SEPARATOR, '/', $path); - } - - trim ($path, '/'); - $path_parts = explode('/', $path); - $resolved = array(); - $resolved_path = $prefix; - $file_found = false; - - foreach ($path_parts as $path_part) - { - if ($file_found) - { - return false; - } - - if (empty($path_part) || ($path_part === '.' && ($absolute || !empty($resolved)))) - { - continue; - } - else if ($absolute && $path_part === '..') - { - if (empty($resolved)) - { - // No directories above root - return false; - } - - array_pop($resolved); - $resolved_path = false; - } - else if ($path_part === '..' && !empty($resolved) && !in_array($resolved[count($resolved) - 1], array('.', '..'))) - { - array_pop($resolved); - $resolved_path = false; - } - else - { - if ($resolved_path === false) - { - if (empty($resolved)) - { - $resolved_path = ($absolute) ? $prefix . '/' . $path_part : $path_part; - } - else - { - $tmp_array = $resolved; - if ($absolute) - { - array_unshift($tmp_array, $prefix); - } - - $resolved_path = implode('/', $tmp_array); - } - } - - $current_path = $resolved_path . '/' . $path_part; - - // Resolve symlinks - if (@is_link($current_path)) - { - if (!function_exists('readlink')) - { - return false; - } - - $link = readlink($current_path); - - // Is link has an absolute path in it? - if ($this->is_absolute_path($link)) - { - if (defined('PHP_WINDOWS_VERSION_MAJOR')) - { - $prefix = $link[0] . ':'; - $link = substr($link, 2); - } - else - { - $prefix = ''; - } - - $resolved = $this->resolve_path($link, $prefix, true, true); - $absolute = true; - } - else - { - $resolved = $this->resolve_path($resolved_path . '/' . $link, $prefix, $absolute, true); - } - - if (!$resolved) - { - return false; - } - - $resolved_path = false; - } - else if (@is_dir($current_path . '/')) - { - $resolved[] = $path_part; - $resolved_path = $current_path; - } - else if (@is_file($current_path)) - { - $resolved[] = $path_part; - $resolved_path = $current_path; - $file_found = true; - } - else - { - return false; - } - } - } - - // If at the end of the path there were a .. or . - // we need to build the path again. - // Only doing this when a string is expected in return - if ($resolved_path === false && $return_array === false) - { - if (empty($resolved)) - { - $resolved_path = ($absolute) ? $prefix . '/' : './'; - } - else - { - $tmp_array = $resolved; - if ($absolute) - { - array_unshift($tmp_array, $prefix); - } - - $resolved_path = implode('/', $tmp_array); - } - } - - return ($return_array) ? $resolved : $resolved_path; - } -} diff --git a/install/update/new/phpbb/filesystem/filesystem_interface.php b/install/update/new/phpbb/filesystem/filesystem_interface.php deleted file mode 100644 index 39ae0c3..0000000 --- a/install/update/new/phpbb/filesystem/filesystem_interface.php +++ /dev/null @@ -1,284 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\filesystem; - -/** - * Interface for phpBB's filesystem service - */ -interface filesystem_interface -{ - /** - * chmod all permissions flag - * - * @var int - */ - const CHMOD_ALL = 7; - - /** - * chmod read permissions flag - * - * @var int - */ - const CHMOD_READ = 4; - - /** - * chmod write permissions flag - * - * @var int - */ - const CHMOD_WRITE = 2; - - /** - * chmod execute permissions flag - * - * @var int - */ - const CHMOD_EXECUTE = 1; - - /** - * Change owner group of files/directories - * - * @param string|array|\Traversable $files The file(s)/directorie(s) to change group - * @param string $group The group that should own the files/directories - * @param bool $recursive If the group should be changed recursively - * @throws \phpbb\filesystem\exception\filesystem_exception the filename which triggered the error can be - * retrieved by filesystem_exception::get_filename() - */ - public function chgrp($files, $group, $recursive = false); - - /** - * Global function for chmodding directories and files for internal use - * - * The function accepts filesystem_interface::CHMOD_ flags in the permission argument - * or the user can specify octal values (or any integer if it makes sense). All directories will have - * an execution bit appended, if the user group (owner, group or other) has any bit specified. - * - * @param string|array|\Traversable $files The file/directory to be chmodded - * @param int $perms Permissions to set - * @param bool $recursive If the permissions should be changed recursively - * @param bool $force_chmod_link Try to apply permissions to symlinks as well - * - * @throws \phpbb\filesystem\exception\filesystem_exception the filename which triggered the error can be - * retrieved by filesystem_exception::get_filename() - */ - public function chmod($files, $perms = null, $recursive = false, $force_chmod_link = false); - - /** - * Change owner group of files/directories - * - * @param string|array|\Traversable $files The file(s)/directorie(s) to change group - * @param string $user The owner user name - * @param bool $recursive Whether change the owner recursively or not - * - * @throws \phpbb\filesystem\exception\filesystem_exception the filename which triggered the error can be - * retrieved by filesystem_exception::get_filename() - */ - public function chown($files, $user, $recursive = false); - - /** - * Eliminates useless . and .. components from specified path. - * - * @param string $path Path to clean - * - * @return string Cleaned path - */ - public function clean_path($path); - - /** - * Copies a file. - * - * This method only copies the file if the origin file is newer than the target file. - * - * By default, if the target already exists, it is not overridden. - * - * @param string $origin_file The original filename - * @param string $target_file The target filename - * @param bool $override Whether to override an existing file or not - * - * @throws \phpbb\filesystem\exception\filesystem_exception When the file cannot be copied - */ - public function copy($origin_file, $target_file, $override = false); - - /** - * Atomically dumps content into a file. - * - * @param string $filename The file to be written to. - * @param string $content The data to write into the file. - * - * @throws \phpbb\filesystem\exception\filesystem_exception When the file cannot be written - */ - public function dump_file($filename, $content); - - /** - * Checks the existence of files or directories. - * - * @param string|array|\Traversable $files files/directories to check - * - * @return bool Returns true if all files/directories exist, false otherwise - */ - public function exists($files); - - /** - * Checks if a path is absolute or not - * - * @param string $path Path to check - * - * @return bool true if the path is absolute, false otherwise - */ - public function is_absolute_path($path); - - /** - * Checks if files/directories are readable - * - * @param string|array|\Traversable $files files/directories to check - * @param bool $recursive Whether or not directories should be checked recursively - * - * @return bool True when the files/directories are readable, otherwise false. - */ - public function is_readable($files, $recursive = false); - - /** - * Test if a file/directory is writable - * - * @param string|array|\Traversable $files files/directories to perform write test on - * @param bool $recursive Whether or not directories should be checked recursively - * - * @return bool True when the files/directories are writable, otherwise false. - */ - public function is_writable($files, $recursive = false); - - /** - * Given an existing path, convert it to a path relative to a given starting path - * - * @param string $end_path Absolute path of target - * @param string $start_path Absolute path where traversal begins - * - * @return string Path of target relative to starting path - */ - public function make_path_relative($end_path, $start_path); - - /** - * Mirrors a directory to another. - * - * @param string $origin_dir The origin directory - * @param string $target_dir The target directory - * @param \Traversable $iterator A Traversable instance - * @param array $options An array of boolean options - * Valid options are: - * - $options['override'] Whether to override an existing file on copy or not (see copy()) - * - $options['copy_on_windows'] Whether to copy files instead of links on Windows (see symlink()) - * - $options['delete'] Whether to delete files that are not in the source directory (defaults to false) - * - * @throws \phpbb\filesystem\exception\filesystem_exception When the file cannot be copied. - * The filename which triggered the error can be - * retrieved by filesystem_exception::get_filename() - */ - public function mirror($origin_dir, $target_dir, \Traversable $iterator = null, $options = array()); - - /** - * Creates a directory recursively. - * - * @param string|array|\Traversable $dirs The directory path - * @param int $mode The directory mode - * - * @throws \phpbb\filesystem\exception\filesystem_exception On any directory creation failure - * The filename which triggered the error can be - * retrieved by filesystem_exception::get_filename() - */ - public function mkdir($dirs, $mode = 0777); - - /** - * Global function for chmodding directories and files for internal use - * - * This function determines owner and group whom the file belongs to and user and group of PHP and then set safest possible file permissions. - * The function determines owner and group from common.php file and sets the same to the provided file. - * The function uses bit fields to build the permissions. - * The function sets the appropriate execute bit on directories. - * - * Supported constants representing bit fields are: - * - * filesystem_interface::CHMOD_ALL - all permissions (7) - * filesystem_interface::CHMOD_READ - read permission (4) - * filesystem_interface::CHMOD_WRITE - write permission (2) - * filesystem_interface::CHMOD_EXECUTE - execute permission (1) - * - * NOTE: The function uses POSIX extension and fileowner()/filegroup() functions. If any of them is disabled, this function tries to build proper permissions, by calling is_readable() and is_writable() functions. - * - * @param string|array|\Traversable $file The file/directory to be chmodded - * @param int $perms Permissions to set - * @param bool $recursive If the permissions should be changed recursively - * @param bool $force_chmod_link Try to apply permissions to symlinks as well - * - * @throws \phpbb\filesystem\exception\filesystem_exception the filename which triggered the error can be - * retrieved by filesystem_exception::get_filename() - */ - public function phpbb_chmod($file, $perms = null, $recursive = false, $force_chmod_link = false); - - /** - * A wrapper for PHP's realpath - * - * Try to resolve realpath when PHP's realpath is not available, or - * known to be buggy. - * - * @param string $path Path to resolve - * - * @return string Resolved path - */ - public function realpath($path); - - /** - * Removes files or directories. - * - * @param string|array|\Traversable $files A filename, an array of files, or a \Traversable instance to remove - * - * @throws \phpbb\filesystem\exception\filesystem_exception When removal fails. - * The filename which triggered the error can be - * retrieved by filesystem_exception::get_filename() - */ - public function remove($files); - - /** - * Renames a file or a directory. - * - * @param string $origin The origin filename or directory - * @param string $target The new filename or directory - * @param bool $overwrite Whether to overwrite the target if it already exists - * - * @throws \phpbb\filesystem\exception\filesystem_exception When target file or directory already exists, - * or origin cannot be renamed. - */ - public function rename($origin, $target, $overwrite = false); - - /** - * Creates a symbolic link or copy a directory. - * - * @param string $origin_dir The origin directory path - * @param string $target_dir The symbolic link name - * @param bool $copy_on_windows Whether to copy files if on Windows - * - * @throws \phpbb\filesystem\exception\filesystem_exception When symlink fails - */ - public function symlink($origin_dir, $target_dir, $copy_on_windows = false); - - /** - * Sets access and modification time of file. - * - * @param string|array|\Traversable $files A filename, an array of files, or a \Traversable instance to create - * @param int $time The touch time as a Unix timestamp - * @param int $access_time The access time as a Unix timestamp - * - * @throws \phpbb\filesystem\exception\filesystem_exception When touch fails - */ - public function touch($files, $time = null, $access_time = null); -} diff --git a/install/update/new/phpbb/finder.php b/install/update/new/phpbb/finder.php deleted file mode 100644 index 0a2b67a..0000000 --- a/install/update/new/phpbb/finder.php +++ /dev/null @@ -1,547 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb; - -/** -* The finder provides a simple way to locate files in the core and a set of extensions -*/ -class finder -{ - protected $extensions; - protected $filesystem; - protected $phpbb_root_path; - protected $cache; - protected $php_ext; - - /** - * The cache variable name used to store $this->cached_queries in $this->cache. - * - * Allows the use of multiple differently configured finders with the same cache. - * @var string - */ - protected $cache_name; - - /** - * An associative array, containing all search parameters set in methods. - * @var array - */ - protected $query; - - /** - * A map from md5 hashes of serialized queries to their previously retrieved - * results. - * @var array - */ - protected $cached_queries; - - /** - * Creates a new finder instance with its dependencies - * - * @param \phpbb\filesystem\filesystem_interface $filesystem Filesystem instance - * @param string $phpbb_root_path Path to the phpbb root directory - * @param \phpbb\cache\service $cache A cache instance or null - * @param string $php_ext php file extension - * @param string $cache_name The name of the cache variable, defaults to - * _ext_finder - */ - public function __construct(\phpbb\filesystem\filesystem_interface $filesystem, $phpbb_root_path = '', \phpbb\cache\service $cache = null, $php_ext = 'php', $cache_name = '_ext_finder') - { - $this->filesystem = $filesystem; - $this->phpbb_root_path = $phpbb_root_path; - $this->cache = $cache; - $this->php_ext = $php_ext; - $this->cache_name = $cache_name; - - $this->query = array( - 'core_path' => false, - 'core_suffix' => false, - 'core_prefix' => false, - 'core_directory' => false, - 'extension_suffix' => false, - 'extension_prefix' => false, - 'extension_directory' => false, - ); - $this->extensions = array(); - - $this->cached_queries = ($this->cache) ? $this->cache->get($this->cache_name) : false; - } - - /** - * Set the array of extensions - * - * @param array $extensions A list of extensions that should be searched as well - * @param bool $replace_list Should the list be emptied before adding the extensions - * @return \phpbb\finder This object for chaining calls - */ - public function set_extensions(array $extensions, $replace_list = true) - { - if ($replace_list) - { - $this->extensions = array(); - } - - foreach ($extensions as $ext_name) - { - $this->extensions[$ext_name] = $this->phpbb_root_path . 'ext/' . $ext_name . '/'; - } - return $this; - } - - /** - * Sets a core path to be searched in addition to extensions - * - * @param string $core_path The path relative to phpbb_root_path - * @return \phpbb\finder This object for chaining calls - */ - public function core_path($core_path) - { - $this->query['core_path'] = $core_path; - return $this; - } - - /** - * Sets the suffix all files found in extensions and core must match. - * - * There is no default file extension, so to find PHP files only, you will - * have to specify .php as a suffix. However when using get_classes, the .php - * file extension is automatically added to suffixes. - * - * @param string $suffix A filename suffix - * @return \phpbb\finder This object for chaining calls - */ - public function suffix($suffix) - { - $this->core_suffix($suffix); - $this->extension_suffix($suffix); - return $this; - } - - /** - * Sets a suffix all files found in extensions must match - * - * There is no default file extension, so to find PHP files only, you will - * have to specify .php as a suffix. However when using get_classes, the .php - * file extension is automatically added to suffixes. - * - * @param string $extension_suffix A filename suffix - * @return \phpbb\finder This object for chaining calls - */ - public function extension_suffix($extension_suffix) - { - $this->query['extension_suffix'] = $extension_suffix; - return $this; - } - - /** - * Sets a suffix all files found in the core path must match - * - * There is no default file extension, so to find PHP files only, you will - * have to specify .php as a suffix. However when using get_classes, the .php - * file extension is automatically added to suffixes. - * - * @param string $core_suffix A filename suffix - * @return \phpbb\finder This object for chaining calls - */ - public function core_suffix($core_suffix) - { - $this->query['core_suffix'] = $core_suffix; - return $this; - } - - /** - * Sets the prefix all files found in extensions and core must match - * - * @param string $prefix A filename prefix - * @return \phpbb\finder This object for chaining calls - */ - public function prefix($prefix) - { - $this->core_prefix($prefix); - $this->extension_prefix($prefix); - return $this; - } - - /** - * Sets a prefix all files found in extensions must match - * - * @param string $extension_prefix A filename prefix - * @return \phpbb\finder This object for chaining calls - */ - public function extension_prefix($extension_prefix) - { - $this->query['extension_prefix'] = $extension_prefix; - return $this; - } - - /** - * Sets a prefix all files found in the core path must match - * - * @param string $core_prefix A filename prefix - * @return \phpbb\finder This object for chaining calls - */ - public function core_prefix($core_prefix) - { - $this->query['core_prefix'] = $core_prefix; - return $this; - } - - /** - * Sets a directory all files found in extensions and core must be contained in - * - * Automatically sets the core_directory if its value does not differ from - * the current directory. - * - * @param string $directory - * @return \phpbb\finder This object for chaining calls - */ - public function directory($directory) - { - $this->core_directory($directory); - $this->extension_directory($directory); - return $this; - } - - /** - * Sets a directory all files found in extensions must be contained in - * - * @param string $extension_directory - * @return \phpbb\finder This object for chaining calls - */ - public function extension_directory($extension_directory) - { - $this->query['extension_directory'] = $this->sanitise_directory($extension_directory); - return $this; - } - - /** - * Sets a directory all files found in the core path must be contained in - * - * @param string $core_directory - * @return \phpbb\finder This object for chaining calls - */ - public function core_directory($core_directory) - { - $this->query['core_directory'] = $this->sanitise_directory($core_directory); - return $this; - } - - /** - * Removes occurrences of /./ and makes sure path ends without trailing slash - * - * @param string $directory A directory pattern - * @return string A cleaned up directory pattern - */ - protected function sanitise_directory($directory) - { - $directory = $this->filesystem->clean_path($directory); - $dir_len = strlen($directory); - - if ($dir_len > 1 && $directory[$dir_len - 1] === '/') - { - $directory = substr($directory, 0, -1); - } - - return $directory; - } - - /** - * Finds classes matching the configured options if they follow phpBB naming rules. - * - * The php file extension is automatically added to suffixes. - * - * Note: If a file is matched but contains a class name not following the - * phpBB naming rules an incorrect class name will be returned. - * - * @param bool $cache Whether the result should be cached - * @return array An array of found class names - */ - public function get_classes($cache = true) - { - $this->query['extension_suffix'] .= '.' . $this->php_ext; - $this->query['core_suffix'] .= '.' . $this->php_ext; - - $files = $this->find($cache, false); - - return $this->get_classes_from_files($files); - } - - /** - * Get class names from a list of files - * - * @param array $files Array of files (from find()) - * @return array Array of class names - */ - public function get_classes_from_files($files) - { - $classes = array(); - foreach ($files as $file => $ext_name) - { - $class = substr($file, 0, -strlen('.' . $this->php_ext)); - if ($ext_name === '/' && preg_match('#^includes/#', $file)) - { - $class = preg_replace('#^includes/#', '', $class); - $classes[] = 'phpbb_' . str_replace('/', '_', $class); - } - else - { - $class = preg_replace('#^ext/#', '', $class); - $classes[] = '\\' . str_replace('/', '\\', $class); - } - } - return $classes; - } - - /** - * Finds all directories matching the configured options - * - * @param bool $cache Whether the result should be cached - * @param bool $extension_keys Whether the result should have extension name as array key - * @return array An array of paths to found directories - */ - public function get_directories($cache = true, $extension_keys = false) - { - return $this->find_with_root_path($cache, true, $extension_keys); - } - - /** - * Finds all files matching the configured options. - * - * @param bool $cache Whether the result should be cached - * @return array An array of paths to found files - */ - public function get_files($cache = true) - { - return $this->find_with_root_path($cache, false); - } - - /** - * A wrapper around the general find which prepends a root path to results - * - * @param bool $cache Whether the result should be cached - * @param bool $is_dir Directories will be returned when true, only files - * otherwise - * @param bool $extension_keys If true, result will be associative array - * with extension name as key - * @return array An array of paths to found items - */ - protected function find_with_root_path($cache = true, $is_dir = false, $extension_keys = false) - { - $items = $this->find($cache, $is_dir); - - $result = array(); - foreach ($items as $item => $ext_name) - { - if ($extension_keys) - { - $result[$ext_name] = $this->phpbb_root_path . $item; - } - else - { - $result[] = $this->phpbb_root_path . $item; - } - } - - return $result; - } - - /** - * Finds all file system entries matching the configured options - * - * @param bool $cache Whether the result should be cached - * @param bool $is_dir Directories will be returned when true, only files - * otherwise - * @return array An array of paths to found items - */ - public function find($cache = true, $is_dir = false) - { - $extensions = $this->extensions; - if ($this->query['core_path']) - { - $extensions['/'] = $this->phpbb_root_path . $this->query['core_path']; - } - - $files = array(); - $file_list = $this->find_from_paths($extensions, $cache, $is_dir); - - foreach ($file_list as $file) - { - $files[$file['named_path']] = $file['ext_name']; - } - - return $files; - } - - /** - * Finds all file system entries matching the configured options for one - * specific extension - * - * @param string $extension_name Name of the extension - * @param string $extension_path Relative path to the extension root directory - * @param bool $cache Whether the result should be cached - * @param bool $is_dir Directories will be returned when true, only files - * otherwise - * @return array An array of paths to found items - */ - public function find_from_extension($extension_name, $extension_path, $cache = true, $is_dir = false) - { - $extensions = array( - $extension_name => $extension_path, - ); - - $files = array(); - $file_list = $this->find_from_paths($extensions, $cache, $is_dir); - - foreach ($file_list as $file) - { - $files[$file['named_path']] = $file['ext_name']; - } - - return $files; - } - - /** - * Finds all file system entries matching the configured options from - * an array of paths - * - * @param array $extensions Array of extensions (name => full relative path) - * @param bool $cache Whether the result should be cached - * @param bool $is_dir Directories will be returned when true, only files - * otherwise - * @return array An array of paths to found items - */ - public function find_from_paths($extensions, $cache = true, $is_dir = false) - { - $this->query['is_dir'] = $is_dir; - $query = md5(serialize($this->query) . serialize($extensions)); - - if (!defined('DEBUG') && $cache && isset($this->cached_queries[$query])) - { - return $this->cached_queries[$query]; - } - - $files = array(); - - foreach ($extensions as $name => $path) - { - $ext_name = $name; - - if (!file_exists($path)) - { - continue; - } - - if ($name === '/') - { - $location = $this->query['core_path']; - $name = ''; - $suffix = $this->query['core_suffix']; - $prefix = $this->query['core_prefix']; - $directory = $this->query['core_directory']; - } - else - { - $location = 'ext/'; - $name .= '/'; - $suffix = $this->query['extension_suffix']; - $prefix = $this->query['extension_prefix']; - $directory = $this->query['extension_directory']; - } - - // match only first directory if leading slash is given - if ($directory === '/') - { - $directory_pattern = '^' . preg_quote(DIRECTORY_SEPARATOR, '#'); - } - else if ($directory && $directory[0] === '/') - { - if (!$is_dir) - { - $path .= substr($directory, 1); - } - $directory_pattern = '^' . preg_quote(str_replace('/', DIRECTORY_SEPARATOR, $directory) . DIRECTORY_SEPARATOR, '#'); - } - else - { - $directory_pattern = preg_quote(DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $directory) . DIRECTORY_SEPARATOR, '#'); - } - if ($is_dir) - { - $directory_pattern .= '$'; - } - $directory_pattern = '#' . $directory_pattern . '#'; - - if (is_dir($path)) - { - $iterator = new \RecursiveIteratorIterator( - new \phpbb\recursive_dot_prefix_filter_iterator( - new \RecursiveDirectoryIterator( - $path, - \FilesystemIterator::SKIP_DOTS - ) - ), - \RecursiveIteratorIterator::SELF_FIRST - ); - - foreach ($iterator as $file_info) - { - $filename = $file_info->getFilename(); - - if ($file_info->isDir() == $is_dir) - { - if ($is_dir) - { - $relative_path = $iterator->getInnerIterator()->getSubPath() . DIRECTORY_SEPARATOR . basename($filename) . DIRECTORY_SEPARATOR; - if ($relative_path[0] !== DIRECTORY_SEPARATOR) - { - $relative_path = DIRECTORY_SEPARATOR . $relative_path; - } - } - else - { - $relative_path = $iterator->getInnerIterator()->getSubPathname(); - if ($directory && $directory[0] === '/') - { - $relative_path = str_replace('/', DIRECTORY_SEPARATOR, $directory) . DIRECTORY_SEPARATOR . $relative_path; - } - else - { - $relative_path = DIRECTORY_SEPARATOR . $relative_path; - } - } - - if ((!$suffix || substr($relative_path, -strlen($suffix)) === $suffix) && - (!$prefix || substr($filename, 0, strlen($prefix)) === $prefix) && - (!$directory || preg_match($directory_pattern, $relative_path))) - { - $files[] = array( - 'named_path' => str_replace(DIRECTORY_SEPARATOR, '/', $location . $name . substr($relative_path, 1)), - 'ext_name' => $ext_name, - 'path' => str_replace(array(DIRECTORY_SEPARATOR, $this->phpbb_root_path), array('/', ''), $file_info->getPath()) . '/', - 'filename' => $filename, - ); - } - } - } - } - } - - if ($cache && $this->cache) - { - $this->cached_queries[$query] = $files; - $this->cache->put($this->cache_name, $this->cached_queries); - } - - return $files; - } -} diff --git a/install/update/new/phpbb/group/helper.php b/install/update/new/phpbb/group/helper.php deleted file mode 100644 index aa3876b..0000000 --- a/install/update/new/phpbb/group/helper.php +++ /dev/null @@ -1,294 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\group; - -use phpbb\auth\auth; -use phpbb\cache\service as cache; -use phpbb\config\config; -use phpbb\language\language; -use phpbb\event\dispatcher_interface; -use phpbb\path_helper; -use phpbb\user; - -class helper -{ - /** @var auth */ - protected $auth; - - /** @var cache */ - protected $cache; - - /** @var config */ - protected $config; - - /** @var language */ - protected $language; - - /** @var dispatcher_interface */ - protected $dispatcher; - - /** @var path_helper */ - protected $path_helper; - - /** @var user */ - protected $user; - - /** @var string phpBB root path */ - protected $phpbb_root_path; - - /** @var array Return templates for a group name string */ - protected $name_strings; - - /** - * Constructor - * - * @param auth $auth Authentication object - * @param cache $cache Cache service object - * @param config $config Configuration object - * @param language $language Language object - * @param dispatcher_interface $dispatcher Event dispatcher object - * @param path_helper $path_helper Path helper object - * @param user $user User object - */ - public function __construct(auth $auth, cache $cache, config $config, language $language, dispatcher_interface $dispatcher, path_helper $path_helper, user $user) - { - $this->auth = $auth; - $this->cache = $cache; - $this->config = $config; - $this->language = $language; - $this->dispatcher = $dispatcher; - $this->path_helper = $path_helper; - $this->user = $user; - - $this->phpbb_root_path = $path_helper->get_phpbb_root_path(); - - /** @html Group name spans and links for usage in the template */ - $this->name_strings = array( - 'base_url' => "{$path_helper->get_phpbb_root_path()}memberlist.{$path_helper->get_php_ext()}?mode=group&g={GROUP_ID}", - 'tpl_noprofile' => '{GROUP_NAME}', - 'tpl_noprofile_colour' => '{GROUP_NAME}', - 'tpl_profile' => '{GROUP_NAME}', - 'tpl_profile_colour' => '{GROUP_NAME}', - ); - } - - /** - * @param $group_name string The stored group name - * - * @return string Group name or translated group name if it exists - */ - public function get_name($group_name) - { - return $this->language->is_set('G_' . utf8_strtoupper($group_name)) ? $this->language->lang('G_' . utf8_strtoupper($group_name)) : $group_name; - } - - /** - * Get group name details for placing into templates. - * - * @html Group name spans and links - * - * @param string $mode Profile (for getting an url to the profile), - * group_name (for obtaining the group name), - * colour (for obtaining the group colour), - * full (for obtaining a coloured group name link to the group's profile), - * no_profile (the same as full but forcing no profile link) - * @param int $group_id The group id - * @param string $group_name The group name - * @param string $group_colour The group colour - * @param mixed $custom_profile_url optional parameter to specify a profile url. The group id gets appended to this url as &g={group_id} - * - * @return string A string consisting of what is wanted based on $mode. - */ - public function get_name_string($mode, $group_id, $group_name, $group_colour = '', $custom_profile_url = false) - { - $s_is_bots = ($group_name === 'BOTS'); - - // This switch makes sure we only run code required for the mode - switch ($mode) - { - case 'full': - case 'no_profile': - case 'colour': - - // Build correct group colour - $group_colour = $group_colour ? '#' . $group_colour : ''; - - // Return colour - if ($mode === 'colour') - { - $group_name_string = $group_colour; - break; - } - - // no break; - - case 'group_name': - - // Build correct group name - $group_name = $this->get_name($group_name); - - // Return group name - if ($mode === 'group_name') - { - $group_name_string = $group_name; - break; - } - - // no break; - - case 'profile': - - // Build correct profile url - only show if not anonymous and permission to view profile if registered user - // For anonymous the link leads to a login page. - if ($group_id && !$s_is_bots && ($this->user->data['user_id'] == ANONYMOUS || $this->auth->acl_get('u_viewprofile'))) - { - $profile_url = ($custom_profile_url !== false) ? $custom_profile_url . '&g=' . (int) $group_id : str_replace(array('={GROUP_ID}', '=%7BGROUP_ID%7D'), '=' . (int) $group_id, append_sid($this->name_strings['base_url'])); - } - else - { - $profile_url = ''; - } - - // Return profile - if ($mode === 'profile') - { - $group_name_string = $profile_url; - break; - } - - // no break; - } - - if (!isset($group_name_string)) - { - if (($mode === 'full' && empty($profile_url)) || $mode === 'no_profile' || $s_is_bots) - { - $group_name_string = str_replace(array('{GROUP_COLOUR}', '{GROUP_NAME}'), array($group_colour, $group_name), (!$group_colour) ? $this->name_strings['tpl_noprofile'] : $this->name_strings['tpl_noprofile_colour']); - } - else - { - $group_name_string = str_replace(array('{PROFILE_URL}', '{GROUP_COLOUR}', '{GROUP_NAME}'), array($profile_url, $group_colour, $group_name), (!$group_colour) ? $this->name_strings['tpl_profile'] : $this->name_strings['tpl_profile_colour']); - } - } - - $name_strings = $this->name_strings; - - /** - * Use this event to change the output of the group name - * - * @event core.modify_group_name_string - * @var string mode profile|group_name|colour|full|no_profile - * @var int group_id The group identifier - * @var string group_name The group name - * @var string group_colour The group colour - * @var string custom_profile_url Optional parameter to specify a profile url. - * @var string group_name_string The string that has been generated - * @var array name_strings Array of original return templates - * @since 3.2.8-RC1 - */ - $vars = array( - 'mode', - 'group_id', - 'group_name', - 'group_colour', - 'custom_profile_url', - 'group_name_string', - 'name_strings', - ); - extract($this->dispatcher->trigger_event('core.modify_group_name_string', compact($vars))); - - return $group_name_string; - } - - /** - * Get group rank title and image - * - * @html Group rank image element - * - * @param array $group_data The current stored group data - * - * @return array An associative array containing the rank title (title), - * the rank image as full img tag (img) and the rank image source (img_src) - */ - public function get_rank($group_data) - { - $group_rank_data = array( - 'title' => null, - 'img' => null, - 'img_src' => null, - ); - - /** - * Preparing a group's rank before displaying - * - * @event core.get_group_rank_before - * @var array group_data Array with group's data - * @since 3.2.8-RC1 - */ - - $vars = array('group_data'); - extract($this->dispatcher->trigger_event('core.get_group_rank_before', compact($vars))); - - if (!empty($group_data['group_rank'])) - { - // Only obtain ranks if group rank is set - $ranks = $this->cache->obtain_ranks(); - - if (isset($ranks['special'][$group_data['group_rank']])) - { - $rank = $ranks['special'][$group_data['group_rank']]; - - $group_rank_data['title'] = $rank['rank_title']; - - $group_rank_data['img_src'] = (!empty($rank['rank_image'])) ? $this->path_helper->update_web_root_path($this->phpbb_root_path . $this->config['ranks_path'] . '/' . $rank['rank_image']) : ''; - - /** @html Group rank image element for usage in the template */ - $group_rank_data['img'] = (!empty($rank['rank_image'])) ? '' . $rank['rank_title'] . '' : ''; - } - } - - /** - * Modify a group's rank before displaying - * - * @event core.get_group_rank_after - * @var array group_data Array with group's data - * @var array group_rank_data Group rank data - * @since 3.2.8-RC1 - */ - - $vars = array( - 'group_data', - 'group_rank_data', - ); - extract($this->dispatcher->trigger_event('core.get_group_rank_after', compact($vars))); - - return $group_rank_data; - } - - /** - * Get group avatar. - * Wrapper function for phpbb_get_group_avatar() - * - * @param array $group_row Row from the groups table - * @param string $alt Optional language string for alt tag within image, can be a language key or text - * @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP - * @param bool $lazy If true, will be lazy loaded (requires JS) - * - * @return string Avatar html - */ - function get_avatar($group_row, $alt = 'GROUP_AVATAR', $ignore_config = false, $lazy = false) - { - return phpbb_get_group_avatar($group_row, $alt, $ignore_config, $lazy); - } -} diff --git a/install/update/new/phpbb/help/controller/bbcode.php b/install/update/new/phpbb/help/controller/bbcode.php deleted file mode 100644 index 560b0c0..0000000 --- a/install/update/new/phpbb/help/controller/bbcode.php +++ /dev/null @@ -1,90 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\help\controller; - -/** - * BBCode help page - */ -class bbcode extends controller -{ - /** - * @return string The title of the page - */ - public function display() - { - $this->language->add_lang('help/bbcode'); - - $this->template->assign_block_vars('navlinks', array( - 'BREADCRUMB_NAME' => $this->language->lang('BBCODE_GUIDE'), - 'U_BREADCRUMB' => $this->helper->route('phpbb_help_bbcode_controller'), - )); - - $this->manager->add_block( - 'HELP_BBCODE_BLOCK_INTRO', - false, - array( - 'HELP_BBCODE_INTRO_BBCODE_QUESTION' => 'HELP_BBCODE_INTRO_BBCODE_ANSWER', - ) - ); - $this->manager->add_block( - 'HELP_BBCODE_BLOCK_TEXT', - false, - array( - 'HELP_BBCODE_TEXT_BASIC_QUESTION' => 'HELP_BBCODE_TEXT_BASIC_ANSWER', - 'HELP_BBCODE_TEXT_COLOR_QUESTION' => 'HELP_BBCODE_TEXT_COLOR_ANSWER', - 'HELP_BBCODE_TEXT_COMBINE_QUESTION' => 'HELP_BBCODE_TEXT_COMBINE_ANSWER', - ) - ); - $this->manager->add_block( - 'HELP_BBCODE_BLOCK_QUOTES', - false, - array( - 'HELP_BBCODE_QUOTES_TEXT_QUESTION' => 'HELP_BBCODE_QUOTES_TEXT_ANSWER', - 'HELP_BBCODE_QUOTES_CODE_QUESTION' => 'HELP_BBCODE_QUOTES_CODE_ANSWER', - ) - ); - $this->manager->add_block( - 'HELP_BBCODE_BLOCK_LISTS', - false, - array( - 'HELP_BBCODE_LISTS_UNORDERER_QUESTION' => 'HELP_BBCODE_LISTS_UNORDERER_ANSWER', - 'HELP_BBCODE_LISTS_ORDERER_QUESTION' => 'HELP_BBCODE_LISTS_ORDERER_ANSWER', - ) - ); - $this->manager->add_block( - 'HELP_BBCODE_BLOCK_LINKS', - true, - array( - 'HELP_BBCODE_LINKS_BASIC_QUESTION' => 'HELP_BBCODE_LINKS_BASIC_ANSWER', - ) - ); - $this->manager->add_block( - 'HELP_BBCODE_BLOCK_IMAGES', - false, - array( - 'HELP_BBCODE_IMAGES_BASIC_QUESTION' => 'HELP_BBCODE_IMAGES_BASIC_ANSWER', - 'HELP_BBCODE_IMAGES_ATTACHMENT_QUESTION' => 'HELP_BBCODE_IMAGES_ATTACHMENT_ANSWER', - ) - ); - $this->manager->add_block( - 'HELP_BBCODE_BLOCK_OTHERS', - false, - array( - 'HELP_BBCODE_OTHERS_CUSTOM_QUESTION' => 'HELP_BBCODE_OTHERS_CUSTOM_ANSWER', - ) - ); - - return $this->language->lang('BBCODE_GUIDE'); - } -} diff --git a/install/update/new/phpbb/help/controller/faq.php b/install/update/new/phpbb/help/controller/faq.php deleted file mode 100644 index 0f63be5..0000000 --- a/install/update/new/phpbb/help/controller/faq.php +++ /dev/null @@ -1,170 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\help\controller; - -/** - * FAQ help page - */ -class faq extends controller -{ - /** - * @return string The title of the page - */ - public function display() - { - $this->language->add_lang('help/faq'); - - $this->template->assign_block_vars('navlinks', array( - 'BREADCRUMB_NAME' => $this->language->lang('FAQ_EXPLAIN'), - 'U_BREADCRUMB' => $this->helper->route('phpbb_help_faq_controller'), - )); - - $this->manager->add_block( - 'HELP_FAQ_BLOCK_LOGIN', - false, - array( - 'HELP_FAQ_LOGIN_REGISTER_QUESTION' => 'HELP_FAQ_LOGIN_REGISTER_ANSWER', - 'HELP_FAQ_LOGIN_COPPA_QUESTION' => 'HELP_FAQ_LOGIN_COPPA_ANSWER', - 'HELP_FAQ_LOGIN_CANNOT_REGISTER_QUESTION' => 'HELP_FAQ_LOGIN_CANNOT_REGISTER_ANSWER', - 'HELP_FAQ_LOGIN_REGISTER_CONFIRM_QUESTION' => 'HELP_FAQ_LOGIN_REGISTER_CONFIRM_ANSWER', - 'HELP_FAQ_LOGIN_CANNOT_LOGIN_QUESTION' => 'HELP_FAQ_LOGIN_CANNOT_LOGIN_ANSWER', - 'HELP_FAQ_LOGIN_CANNOT_LOGIN_ANYMORE_QUESTION' => 'HELP_FAQ_LOGIN_CANNOT_LOGIN_ANYMORE_ANSWER', - 'HELP_FAQ_LOGIN_LOST_PASSWORD_QUESTION' => 'HELP_FAQ_LOGIN_LOST_PASSWORD_ANSWER', - 'HELP_FAQ_LOGIN_AUTO_LOGOUT_QUESTION' => 'HELP_FAQ_LOGIN_AUTO_LOGOUT_ANSWER', - 'HELP_FAQ_LOGIN_DELETE_COOKIES_QUESTION' => 'HELP_FAQ_LOGIN_DELETE_COOKIES_ANSWER', - ) - ); - $this->manager->add_block( - 'HELP_FAQ_BLOCK_USERSETTINGS', - false, - array( - 'HELP_FAQ_USERSETTINGS_CHANGE_SETTINGS_QUESTION' => 'HELP_FAQ_USERSETTINGS_CHANGE_SETTINGS_ANSWER', - 'HELP_FAQ_USERSETTINGS_HIDE_ONLINE_QUESTION' => 'HELP_FAQ_USERSETTINGS_HIDE_ONLINE_ANSWER', - 'HELP_FAQ_USERSETTINGS_TIMEZONE_QUESTION' => 'HELP_FAQ_USERSETTINGS_TIMEZONE_ANSWER', - 'HELP_FAQ_USERSETTINGS_SERVERTIME_QUESTION' => 'HELP_FAQ_USERSETTINGS_SERVERTIME_ANSWER', - 'HELP_FAQ_USERSETTINGS_LANGUAGE_QUESTION' => 'HELP_FAQ_USERSETTINGS_LANGUAGE_ANSWER', - 'HELP_FAQ_USERSETTINGS_AVATAR_QUESTION' => 'HELP_FAQ_USERSETTINGS_AVATAR_ANSWER', - 'HELP_FAQ_USERSETTINGS_AVATAR_DISPLAY_QUESTION' => 'HELP_FAQ_USERSETTINGS_AVATAR_DISPLAY_ANSWER', - 'HELP_FAQ_USERSETTINGS_RANK_QUESTION' => 'HELP_FAQ_USERSETTINGS_RANK_ANSWER', - 'HELP_FAQ_USERSETTINGS_EMAIL_LOGIN_QUESTION' => 'HELP_FAQ_USERSETTINGS_EMAIL_LOGIN_ANSWER', - ) - ); - $this->manager->add_block( - 'HELP_FAQ_BLOCK_POSTING', - false, - array( - 'HELP_FAQ_POSTING_CREATE_QUESTION' => 'HELP_FAQ_POSTING_CREATE_ANSWER', - 'HELP_FAQ_POSTING_EDIT_DELETE_QUESTION' => 'HELP_FAQ_POSTING_EDIT_DELETE_ANSWER', - 'HELP_FAQ_POSTING_SIGNATURE_QUESTION' => 'HELP_FAQ_POSTING_SIGNATURE_ANSWER', - 'HELP_FAQ_POSTING_POLL_CREATE_QUESTION' => 'HELP_FAQ_POSTING_POLL_CREATE_ANSWER', - 'HELP_FAQ_POSTING_POLL_ADD_QUESTION' => 'HELP_FAQ_POSTING_POLL_ADD_ANSWER', - 'HELP_FAQ_POSTING_POLL_EDIT_QUESTION' => 'HELP_FAQ_POSTING_POLL_EDIT_ANSWER', - 'HELP_FAQ_POSTING_FORUM_RESTRICTED_QUESTION' => 'HELP_FAQ_POSTING_FORUM_RESTRICTED_ANSWER', - 'HELP_FAQ_POSTING_NO_ATTACHMENTS_QUESTION' => 'HELP_FAQ_POSTING_NO_ATTACHMENTS_ANSWER', - 'HELP_FAQ_POSTING_WARNING_QUESTION' => 'HELP_FAQ_POSTING_WARNING_ANSWER', - 'HELP_FAQ_POSTING_REPORT_QUESTION' => 'HELP_FAQ_POSTING_REPORT_ANSWER', - 'HELP_FAQ_POSTING_DRAFT_QUESTION' => 'HELP_FAQ_POSTING_DRAFT_ANSWER', - 'HELP_FAQ_POSTING_QUEUE_QUESTION' => 'HELP_FAQ_POSTING_QUEUE_ANSWER', - 'HELP_FAQ_POSTING_BUMP_QUESTION' => 'HELP_FAQ_POSTING_BUMP_ANSWER', - ) - ); - $this->manager->add_block( - 'HELP_FAQ_BLOCK_FORMATTING', - false, - array( - 'HELP_FAQ_FORMATTING_BBOCDE_QUESTION' => 'HELP_FAQ_FORMATTING_BBOCDE_ANSWER', - 'HELP_FAQ_FORMATTING_HTML_QUESTION' => 'HELP_FAQ_FORMATTING_HTML_ANSWER', - 'HELP_FAQ_FORMATTING_SMILIES_QUESTION' => 'HELP_FAQ_FORMATTING_SMILIES_ANSWER', - 'HELP_FAQ_FORMATTING_IMAGES_QUESTION' => 'HELP_FAQ_FORMATTING_IMAGES_ANSWER', - 'HELP_FAQ_FORMATTING_GLOBAL_ANNOUNCE_QUESTION' => 'HELP_FAQ_FORMATTING_GLOBAL_ANNOUNCE_ANSWER', - 'HELP_FAQ_FORMATTING_ANNOUNCEMENT_QUESTION' => 'HELP_FAQ_FORMATTING_ANNOUNCEMENT_ANSWER', - 'HELP_FAQ_FORMATTING_STICKIES_QUESTION' => 'HELP_FAQ_FORMATTING_STICKIES_ANSWER', - 'HELP_FAQ_FORMATTING_LOCKED_QUESTION' => 'HELP_FAQ_FORMATTING_LOCKED_ANSWER', - 'HELP_FAQ_FORMATTING_ICONS_QUESTION' => 'HELP_FAQ_FORMATTING_ICONS_ANSWER', - ) - ); - $this->manager->add_block( - 'HELP_FAQ_BLOCK_GROUPS', - true, - array( - 'HELP_FAQ_GROUPS_ADMINISTRATORS_QUESTION' => 'HELP_FAQ_GROUPS_ADMINISTRATORS_ANSWER', - 'HELP_FAQ_GROUPS_MODERATORS_QUESTION' => 'HELP_FAQ_GROUPS_MODERATORS_ANSWER', - 'HELP_FAQ_GROUPS_USERGROUPS_QUESTION' => 'HELP_FAQ_GROUPS_USERGROUPS_ANSWER', - 'HELP_FAQ_GROUPS_USERGROUPS_JOIN_QUESTION' => 'HELP_FAQ_GROUPS_USERGROUPS_JOIN_ANSWER', - 'HELP_FAQ_GROUPS_USERGROUPS_LEAD_QUESTION' => 'HELP_FAQ_GROUPS_USERGROUPS_LEAD_ANSWER', - 'HELP_FAQ_GROUPS_COLORS_QUESTION' => 'HELP_FAQ_GROUPS_COLORS_ANSWER', - 'HELP_FAQ_GROUPS_DEFAULT_QUESTION' => 'HELP_FAQ_GROUPS_DEFAULT_ANSWER', - 'HELP_FAQ_GROUPS_TEAM_QUESTION' => 'HELP_FAQ_GROUPS_TEAM_ANSWER', - ) - ); - $this->manager->add_block( - 'HELP_FAQ_BLOCK_PMS', - false, - array( - 'HELP_FAQ_PMS_CANNOT_SEND_QUESTION' => 'HELP_FAQ_PMS_CANNOT_SEND_ANSWER', - 'HELP_FAQ_PMS_UNWANTED_QUESTION' => 'HELP_FAQ_PMS_UNWANTED_ANSWER', - 'HELP_FAQ_PMS_SPAM_QUESTION' => 'HELP_FAQ_PMS_SPAM_ANSWER', - ) - ); - $this->manager->add_block( - 'HELP_FAQ_BLOCK_FRIENDS', - false, - array( - 'HELP_FAQ_FRIENDS_BASIC_QUESTION' => 'HELP_FAQ_FRIENDS_BASIC_ANSWER', - 'HELP_FAQ_FRIENDS_MANAGE_QUESTION' => 'HELP_FAQ_FRIENDS_MANAGE_ANSWER', - ) - ); - $this->manager->add_block( - 'HELP_FAQ_BLOCK_SEARCH', - false, - array( - 'HELP_FAQ_SEARCH_FORUM_QUESTION' => 'HELP_FAQ_SEARCH_FORUM_ANSWER', - 'HELP_FAQ_SEARCH_NO_RESULT_QUESTION' => 'HELP_FAQ_SEARCH_NO_RESULT_ANSWER', - 'HELP_FAQ_SEARCH_BLANK_QUESTION' => 'HELP_FAQ_SEARCH_BLANK_ANSWER', - 'HELP_FAQ_SEARCH_MEMBERS_QUESTION' => 'HELP_FAQ_SEARCH_MEMBERS_ANSWER', - 'HELP_FAQ_SEARCH_OWN_QUESTION' => 'HELP_FAQ_SEARCH_OWN_ANSWER', - ) - ); - $this->manager->add_block( - 'HELP_FAQ_BLOCK_BOOKMARKS', - false, - array( - 'HELP_FAQ_BOOKMARKS_DIFFERENCE_QUESTION' => 'HELP_FAQ_BOOKMARKS_DIFFERENCE_ANSWER', - 'HELP_FAQ_BOOKMARKS_TOPIC_QUESTION' => 'HELP_FAQ_BOOKMARKS_TOPIC_ANSWER', - 'HELP_FAQ_BOOKMARKS_FORUM_QUESTION' => 'HELP_FAQ_BOOKMARKS_FORUM_ANSWER', - 'HELP_FAQ_BOOKMARKS_REMOVE_QUESTION' => 'HELP_FAQ_BOOKMARKS_REMOVE_ANSWER', - ) - ); - $this->manager->add_block( - 'HELP_FAQ_BLOCK_ATTACHMENTS', - false, - array( - 'HELP_FAQ_ATTACHMENTS_ALLOWED_QUESTION' => 'HELP_FAQ_ATTACHMENTS_ALLOWED_ANSWER', - 'HELP_FAQ_ATTACHMENTS_OWN_QUESTION' => 'HELP_FAQ_ATTACHMENTS_OWN_ANSWER', - ) - ); - $this->manager->add_block( - 'HELP_FAQ_BLOCK_ISSUES', - false, - array( - 'HELP_FAQ_ISSUES_WHOIS_PHPBB_QUESTION' => 'HELP_FAQ_ISSUES_WHOIS_PHPBB_ANSWER', - 'HELP_FAQ_ISSUES_FEATURE_QUESTION' => 'HELP_FAQ_ISSUES_FEATURE_ANSWER', - 'HELP_FAQ_ISSUES_LEGAL_QUESTION' => 'HELP_FAQ_ISSUES_LEGAL_ANSWER', - 'HELP_FAQ_ISSUES_ADMIN_QUESTION' => 'HELP_FAQ_ISSUES_ADMIN_ANSWER', - ) - ); - - return $this->language->lang('FAQ_EXPLAIN'); - } -} diff --git a/install/update/new/phpbb/install/controller/helper.php b/install/update/new/phpbb/install/controller/helper.php deleted file mode 100644 index f61c7de..0000000 --- a/install/update/new/phpbb/install/controller/helper.php +++ /dev/null @@ -1,413 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\install\controller; - -use phpbb\install\helper\config; -use phpbb\install\helper\navigation\navigation_provider; -use phpbb\language\language; -use phpbb\language\language_file_helper; -use phpbb\path_helper; -use phpbb\request\request; -use phpbb\request\request_interface; -use phpbb\routing\router; -use phpbb\symfony_request; -use phpbb\template\template; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\Cookie; - -/** - * A duplicate of \phpbb\controller\helper - * - * This class is necessary because of controller\helper's legacy function calls - * to page_header() page_footer() functions which has unavailable dependencies. - */ -class helper -{ - /** - * @var config - */ - protected $installer_config; - - /** - * @var \phpbb\language\language - */ - protected $language; - - /** - * @var bool|string - */ - protected $language_cookie; - - /** - * @var \phpbb\language\language_file_helper - */ - protected $lang_helper; - - /** - * @var \phpbb\install\helper\navigation\navigation_provider - */ - protected $navigation_provider; - - /** - * @var \phpbb\template\template - */ - protected $template; - - /** - * @var \phpbb\path_helper - */ - protected $path_helper; - - /** - * @var \phpbb\request\request - */ - protected $phpbb_request; - - /** - * @var \phpbb\symfony_request - */ - protected $request; - - /** - * @var \phpbb\routing\router - */ - protected $router; - - /** - * @var string - */ - protected $phpbb_admin_path; - - /** - * @var string - */ - protected $phpbb_root_path; - - /** - * Constructor - * - * @param config $config - * @param language $language - * @param language_file_helper $lang_helper - * @param navigation_provider $nav - * @param template $template - * @param path_helper $path_helper - * @param request $phpbb_request - * @param symfony_request $request - * @param router $router - * @param string $phpbb_root_path - */ - public function __construct(config $config, language $language, language_file_helper $lang_helper, navigation_provider $nav, template $template, path_helper $path_helper, request $phpbb_request, symfony_request $request, router $router, $phpbb_root_path) - { - $this->installer_config = $config; - $this->language = $language; - $this->language_cookie = false; - $this->lang_helper = $lang_helper; - $this->navigation_provider = $nav; - $this->template = $template; - $this->path_helper = $path_helper; - $this->phpbb_request = $phpbb_request; - $this->request = $request; - $this->router = $router; - $this->phpbb_root_path = $phpbb_root_path; - $this->phpbb_admin_path = $phpbb_root_path . 'adm/'; - } - - /** - * Automate setting up the page and creating the response object. - * - * @param string $template_file The template handle to render - * @param string $page_title The title of the page to output - * @param bool $selected_language True to enable language selector it, false otherwise - * @param int $status_code The status code to be sent to the page header - * - * @return Response object containing rendered page - */ - public function render($template_file, $page_title = '', $selected_language = false, $status_code = 200) - { - $this->page_header($page_title, $selected_language); - - $this->template->set_filenames(array( - 'body' => $template_file, - )); - - $response = new Response($this->template->assign_display('body'), $status_code); - - // Set language cookie - if ($this->language_cookie !== false) - { - $cookie = new Cookie('lang', $this->language_cookie, time() + 3600); - $response->headers->setCookie($cookie); - - $this->language_cookie = false; - } - - return $response; - } - - /** - * Returns path from route name - * - * @param string $route_name - * @param array $parameters - * - * @return string - */ - public function route($route_name, $parameters = array()) - { - $url = $this->router->generate($route_name, $parameters); - - return $url; - } - - /** - * Handles language selector form - */ - public function handle_language_select() - { - $lang = null; - - // Check if language form has been submited - $submit = $this->phpbb_request->variable('change_lang', ''); - if (!empty($submit)) - { - $lang = $this->phpbb_request->variable('language', ''); - } - - // Retrieve language from cookie - $lang_cookie = $this->phpbb_request->variable('lang', '', false, request_interface::COOKIE); - if (empty($lang) && !empty($lang_cookie)) - { - $lang = $lang_cookie; - } - - $lang = (!empty($lang) && strpos($lang, '/') === false) ? $lang : null; - $this->language_cookie = $lang; - - $this->render_language_select($lang); - - if ($lang !== null) - { - $this->language->set_user_language($lang, true); - $this->installer_config->set('user_language', $lang); - } - } - - /** - * Process navigation data to reflect active/completed stages - * - * @param \phpbb\install\helper\iohandler\iohandler_interface|null $iohandler - */ - public function handle_navigation($iohandler = null) - { - $nav_data = $this->installer_config->get_navigation_data(); - - // Set active navigation stage - if (isset($nav_data['active']) && is_array($nav_data['active'])) - { - if ($iohandler !== null) - { - $iohandler->set_active_stage_menu($nav_data['active']); - } - - $this->navigation_provider->set_nav_property($nav_data['active'], array( - 'selected' => true, - 'completed' => false, - )); - } - - // Set finished navigation stages - if (isset($nav_data['finished']) && is_array($nav_data['finished'])) - { - foreach ($nav_data['finished'] as $finished_stage) - { - if ($iohandler !== null) - { - $iohandler->set_finished_stage_menu($finished_stage); - } - - $this->navigation_provider->set_nav_property($finished_stage, array( - 'selected' => false, - 'completed' => true, - )); - } - } - } - - /** - * Set default template variables - * - * @param string $page_title Title of the page - * @param bool $selected_language True to enable language selector it, false otherwise - */ - protected function page_header($page_title, $selected_language = false) - { - // Path to templates - $paths = array($this->phpbb_root_path . 'install/update/new/adm/', $this->phpbb_admin_path); - $paths = array_filter($paths, 'is_dir'); - $path = array_shift($paths); - $path = substr($path, strlen($this->phpbb_root_path)); - - $this->template->assign_vars(array( - 'L_CHANGE' => $this->language->lang('CHANGE'), - 'L_COLON' => $this->language->lang('COLON'), - 'L_INSTALL_PANEL' => $this->language->lang('INSTALL_PANEL'), - 'L_SELECT_LANG' => $this->language->lang('SELECT_LANG'), - 'L_SKIP' => $this->language->lang('SKIP'), - 'PAGE_TITLE' => $this->language->lang($page_title), - 'T_IMAGE_PATH' => $this->path_helper->get_web_root_path() . $path . 'images', - 'T_JQUERY_LINK' => $this->path_helper->get_web_root_path() . $path . '../assets/javascript/jquery-3.4.1.min.js', - 'T_TEMPLATE_PATH' => $this->path_helper->get_web_root_path() . $path . 'style', - 'T_ASSETS_PATH' => $this->path_helper->get_web_root_path() . $path . '../assets', - - 'S_CONTENT_DIRECTION' => $this->language->lang('DIRECTION'), - 'S_CONTENT_FLOW_BEGIN' => ($this->language->lang('DIRECTION') === 'ltr') ? 'left' : 'right', - 'S_CONTENT_FLOW_END' => ($this->language->lang('DIRECTION') === 'ltr') ? 'right' : 'left', - 'S_CONTENT_ENCODING' => 'UTF-8', - 'S_LANG_SELECT' => $selected_language, - - 'S_USER_LANG' => $this->language->lang('USER_LANG'), - )); - - $this->render_navigation(); - } - - /** - * Render navigation - */ - protected function render_navigation() - { - // Get navigation items - $nav_array = $this->navigation_provider->get(); - $nav_array = $this->sort_navigation_level($nav_array); - - $active_main_menu = $this->get_active_main_menu($nav_array); - - // Pass navigation to template - foreach ($nav_array as $key => $entry) - { - $this->template->assign_block_vars('t_block1', array( - 'L_TITLE' => $this->language->lang($entry['label']), - 'S_SELECTED' => ($active_main_menu === $key), - 'U_TITLE' => $this->route($entry['route']), - )); - - if (is_array($entry[0]) && $active_main_menu === $key) - { - $entry[0] = $this->sort_navigation_level($entry[0]); - - foreach ($entry[0] as $name => $sub_entry) - { - if (isset($sub_entry['stage']) && $sub_entry['stage'] === true) - { - $this->template->assign_block_vars('l_block2', array( - 'L_TITLE' => $this->language->lang($sub_entry['label']), - 'S_SELECTED' => (isset($sub_entry['selected']) && $sub_entry['selected'] === true), - 'S_COMPLETE' => (isset($sub_entry['completed']) && $sub_entry['completed'] === true), - 'STAGE_NAME' => $name, - )); - } - else - { - $this->template->assign_block_vars('l_block1', array( - 'L_TITLE' => $this->language->lang($sub_entry['label']), - 'S_SELECTED' => (isset($sub_entry['route']) && $sub_entry['route'] === $this->request->get('_route')), - 'U_TITLE' => $this->route($sub_entry['route']), - )); - } - } - } - } - } - - /** - * Render language select form - * - * @param string $selected_language - */ - protected function render_language_select($selected_language = null) - { - $langs = $this->lang_helper->get_available_languages(); - foreach ($langs as $lang) - { - $this->template->assign_block_vars('language_select_item', array( - 'VALUE' => $lang['iso'], - 'NAME' => $lang['local_name'], - 'SELECTED' => ($lang['iso'] === $selected_language), - )); - } - } - - /** - * Returns the name of the active main menu item - * - * @param array $nav_array - * - * @return string|bool Returns the name of the active main menu element, if the element not found, returns false - */ - protected function get_active_main_menu($nav_array) - { - $active_route = $this->request->get('_route'); - - foreach ($nav_array as $nav_name => $nav_options) - { - $current_menu = $nav_name; - - if (isset($nav_options['route']) && $nav_options['route'] === $active_route) - { - return $nav_name; - } - - if (is_array($nav_options[0])) - { - foreach ($nav_options[0] as $sub_menus) - { - if (isset($sub_menus['route']) && $sub_menus['route'] === $active_route) - { - return $current_menu; - } - } - } - } - - return false; - } - - /** - * Sorts the top level of navigation array - * - * @param array $nav_array Navigation array - * - * @return array - */ - protected function sort_navigation_level($nav_array) - { - $sorted = array(); - foreach ($nav_array as $key => $nav) - { - $order = (isset($nav['order'])) ? $nav['order'] : 0; - $sorted[$order][$key] = $nav; - } - - // Linearization of navigation array - $nav_array = array(); - ksort($sorted); - foreach ($sorted as $nav) - { - $nav_array = array_merge($nav_array, $nav); - } - - return $nav_array; - } -} diff --git a/install/update/new/phpbb/install/helper/container_factory.php b/install/update/new/phpbb/install/helper/container_factory.php deleted file mode 100644 index 6557602..0000000 --- a/install/update/new/phpbb/install/helper/container_factory.php +++ /dev/null @@ -1,191 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\install\helper; - -use phpbb\install\exception\cannot_build_container_exception; -use phpbb\language\language; -use phpbb\request\request; - -class container_factory -{ - /** - * @var language - */ - protected $language; - - /** - * @var string - */ - protected $phpbb_root_path; - - /** - * @var string - */ - protected $php_ext; - - /** - * @var \phpbb\request\request - */ - protected $request; - - /** - * @var update_helper - */ - protected $update_helper; - - /** - * The full phpBB container - * - * @var \Symfony\Component\DependencyInjection\ContainerInterface - */ - protected $container; - - /** - * Constructor - * - * @param language $language Language service - * @param request $request Request interface - * @param update_helper $update_helper Update helper - * @param string $phpbb_root_path Path to phpBB's root - * @param string $php_ext Extension of PHP files - */ - public function __construct(language $language, request $request, update_helper $update_helper, $phpbb_root_path, $php_ext) - { - $this->language = $language; - $this->request = $request; - $this->update_helper = $update_helper; - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - $this->container = null; - } - - /** - * Container getter - * - * @param null|string $service_name Name of the service to return - * - * @return \Symfony\Component\DependencyInjection\ContainerInterface|Object phpBB's dependency injection container - * or the service specified in $service_name - * - * @throws \phpbb\install\exception\cannot_build_container_exception When container cannot be built - * @throws \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException If the service is not defined - * @throws \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException When a circular reference is detected - * @throws \Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException When the service is not defined - */ - public function get($service_name = null) - { - // Check if container was built, if not try to build it - if ($this->container === null) - { - $this->build_container(); - } - - return ($service_name === null) ? $this->container : $this->container->get($service_name); - } - - /** - * Returns the specified parameter from the container - * - * @param string $param_name - * - * @return mixed - * - * @throws \phpbb\install\exception\cannot_build_container_exception When container cannot be built - */ - public function get_parameter($param_name) - { - // Check if container was built, if not try to build it - if ($this->container === null) - { - $this->build_container(); - } - - return $this->container->getParameter($param_name); - } - - /** - * Build dependency injection container - * - * @throws \phpbb\install\exception\cannot_build_container_exception When container cannot be built - */ - protected function build_container() - { - // If the container has been already built just return. - // Although this should never happen - if ($this->container instanceof \Symfony\Component\DependencyInjection\ContainerInterface) - { - return; - } - - // Check whether container can be built - // We need config.php for that so let's check if it has been set up yet - if (!filesize($this->phpbb_root_path . 'config.' . $this->php_ext)) - { - throw new cannot_build_container_exception(); - } - - $phpbb_config_php_file = new \phpbb\config_php_file($this->phpbb_root_path, $this->php_ext); - $phpbb_container_builder = new \phpbb\di\container_builder($this->phpbb_root_path, $this->php_ext); - - // For BC with functions that we need during install - global $phpbb_container, $table_prefix; - - $disable_super_globals = $this->request->super_globals_disabled(); - - // This is needed because container_builder::get_env_parameters() uses $_SERVER - if ($disable_super_globals) - { - $this->request->enable_super_globals(); - } - - $other_config_path = $this->phpbb_root_path . 'install/update/new/config'; - $config_path = (is_dir($other_config_path)) ? $other_config_path : $this->phpbb_root_path . 'config'; - - $this->container = $phpbb_container_builder - ->with_environment('production') - ->with_config($phpbb_config_php_file) - ->with_config_path($config_path) - ->without_compiled_container() - ->get_container(); - - // Setting request is required for the compatibility globals as those are generated from - // this container - if (!$this->container->isFrozen()) - { - $this->container->register('request')->setSynthetic(true); - $this->container->register('language')->setSynthetic(true); - } - - $this->container->set('request', $this->request); - $this->container->set('language', $this->language); - - $this->container->compile(); - - $phpbb_container = $this->container; - $table_prefix = $phpbb_config_php_file->get('table_prefix'); - - // Restore super globals to previous state - if ($disable_super_globals) - { - $this->request->disable_super_globals(); - } - - // Get compatibility globals and constants - $this->update_helper->include_file('includes/compatibility_globals.' . $this->php_ext); - - register_compatibility_globals(); - - $this->update_helper->include_file('includes/constants.' . $this->php_ext); - } -} diff --git a/install/update/new/phpbb/install/helper/database.php b/install/update/new/phpbb/install/helper/database.php deleted file mode 100644 index 51fd18f..0000000 --- a/install/update/new/phpbb/install/helper/database.php +++ /dev/null @@ -1,421 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\install\helper; - -use phpbb\install\exception\invalid_dbms_exception; - -/** - * Database related general functionality for installer - */ -class database -{ - /** - * @var \phpbb\filesystem\filesystem_interface - */ - protected $filesystem; - - /** - * @var string - */ - protected $phpbb_root_path; - - /** - * @var array - */ - protected $supported_dbms = array( - // Note: php 5.5 alpha 2 deprecated mysql. - // Keep mysqli before mysql in this list. - 'mysqli' => array( - 'LABEL' => 'MySQL with MySQLi Extension', - 'SCHEMA' => 'mysql_41', - 'MODULE' => 'mysqli', - 'DELIM' => ';', - 'DRIVER' => 'phpbb\db\driver\mysqli', - 'AVAILABLE' => true, - '2.0.x' => true, - ), - 'mssql_odbc'=> array( - 'LABEL' => 'MS SQL Server [ ODBC ]', - 'SCHEMA' => 'mssql', - 'MODULE' => 'odbc', - 'DELIM' => ';', - 'DRIVER' => 'phpbb\db\driver\mssql_odbc', - 'AVAILABLE' => true, - '2.0.x' => true, - ), - 'mssqlnative' => array( - 'LABEL' => 'MS SQL Server 2005+ [ Native ]', - 'SCHEMA' => 'mssql', - 'MODULE' => 'sqlsrv', - 'DELIM' => ';', - 'DRIVER' => 'phpbb\db\driver\mssqlnative', - 'AVAILABLE' => true, - '2.0.x' => false, - ), - 'oracle' => array( - 'LABEL' => 'Oracle', - 'SCHEMA' => 'oracle', - 'MODULE' => 'oci8', - 'DELIM' => ';', - 'DRIVER' => 'phpbb\db\driver\oracle', - 'AVAILABLE' => true, - '2.0.x' => false, - ), - 'postgres' => array( - 'LABEL' => 'PostgreSQL 8.3+', - 'SCHEMA' => 'postgres', - 'MODULE' => 'pgsql', - 'DELIM' => ';', - 'DRIVER' => 'phpbb\db\driver\postgres', - 'AVAILABLE' => true, - '2.0.x' => true, - ), - 'sqlite3' => array( - 'LABEL' => 'SQLite3', - 'SCHEMA' => 'sqlite', - 'MODULE' => 'sqlite3', - 'DELIM' => ';', - 'DRIVER' => 'phpbb\db\driver\sqlite3', - 'AVAILABLE' => true, - '2.0.x' => false, - ), - ); - - /** - * Constructor - * - * @param \phpbb\filesystem\filesystem_interface $filesystem Filesystem interface - * @param string $phpbb_root_path Path to phpBB's root - */ - public function __construct(\phpbb\filesystem\filesystem_interface $filesystem, $phpbb_root_path) - { - $this->filesystem = $filesystem; - $this->phpbb_root_path = $phpbb_root_path; - } - - /** - * Returns an array of available DBMS supported by phpBB - * - * If a DBMS is specified it will only return data for that DBMS - * and will load its extension if necessary. - * - * @param mixed $dbms name of the DBMS that's info is required or false for all DBMS info - * @param bool $return_unavailable set it to true if you expect unavailable but supported DBMS - * returned as well - * @param bool $only_20x_options set it to true if you only want to recover 2.0.x options - * - * @return array Array of available and supported DBMS - */ - public function get_available_dbms($dbms = false, $return_unavailable = false, $only_20x_options = false) - { - $available_dbms = $this->supported_dbms; - - if ($dbms) - { - if (isset($this->supported_dbms[$dbms])) - { - $available_dbms = array($dbms => $this->supported_dbms[$dbms]); - } - else - { - return array(); - } - } - - $any_dbms_available = false; - foreach ($available_dbms as $db_name => $db_array) - { - if ($only_20x_options && !$db_array['2.0.x']) - { - if ($return_unavailable) - { - $available_dbms[$db_name]['AVAILABLE'] = false; - } - else - { - unset($available_dbms[$db_name]); - } - - continue; - } - - $dll = $db_array['MODULE']; - if (!@extension_loaded($dll)) - { - if ($return_unavailable) - { - $available_dbms[$db_name]['AVAILABLE'] = false; - } - else - { - unset($available_dbms[$db_name]); - } - - continue; - } - - $any_dbms_available = true; - } - - if ($return_unavailable) - { - $available_dbms['ANY_DB_SUPPORT'] = $any_dbms_available; - } - - return $available_dbms; - } - - /** - * Removes "/* style" as well as "# style" comments from $input. - * - * @param string $sql_query Input string - * - * @return string Input string with comments removed - */ - public function remove_comments($sql_query) - { - // Remove /* */ comments (http://ostermiller.org/findcomment.html) - $sql_query = preg_replace('#/\*(.|[\r\n])*?\*/#', "\n", $sql_query); - - // Remove # style comments - $sql_query = preg_replace('/\n{2,}/', "\n", preg_replace('/^#.*$/m', "\n", $sql_query)); - - return $sql_query; - } - - /** - * split_sql_file() will split an uploaded sql file into single sql statements. - * - * Note: expects trim() to have already been run on $sql. - * - * @param string $sql SQL statements - * @param string $delimiter Delimiter between sql statements - * - * @return array Array of sql statements - */ - public function split_sql_file($sql, $delimiter) - { - $sql = str_replace("\r" , '', $sql); - $data = preg_split('/' . preg_quote($delimiter, '/') . '$/m', $sql); - - $data = array_map('trim', $data); - - // The empty case - $end_data = end($data); - - if (empty($end_data)) - { - unset($data[key($data)]); - } - - return $data; - } - - /** - * Validates table prefix - * - * @param string $dbms The selected dbms - * @param string $table_prefix The table prefix to validate - * - * @return bool|array true if table prefix is valid, array of errors otherwise - * - * @throws \phpbb\install\exception\invalid_dbms_exception When $dbms is not a valid - */ - public function validate_table_prefix($dbms, $table_prefix) - { - $errors = array(); - - if (!preg_match('#^[a-zA-Z][a-zA-Z0-9_]*$#', $table_prefix)) - { - $errors[] = array( - 'title' => 'INST_ERR_DB_INVALID_PREFIX', - ); - } - - // Do dbms specific checks - $dbms_info = $this->get_available_dbms($dbms); - switch ($dbms_info[$dbms]['SCHEMA']) - { - case 'mysql_41': - $prefix_length = 36; - break; - case 'mssql': - $prefix_length = 90; - break; - case 'oracle': - $prefix_length = 6; - break; - case 'postgres': - $prefix_length = 36; - break; - case 'sqlite': - $prefix_length = 200; - break; - default: - throw new invalid_dbms_exception(); - break; - } - - // Check the prefix length to ensure that index names are not too long - if (strlen($table_prefix) > $prefix_length) - { - $errors[] = array( - 'title' => array('INST_ERR_PREFIX_TOO_LONG', $prefix_length), - ); - } - - return (empty($errors)) ? true : $errors; - } - - /** - * Check if the user provided database parameters are correct - * - * This function checks the database connection data and also checks for - * any other problems that could cause an error during the installation - * such as if there is any database table names conflicting. - * - * Note: The function assumes that $table_prefix has been already validated - * with validate_table_prefix(). - * - * @param string $dbms Selected database type - * @param string $dbhost Database host address - * @param int $dbport Database port number - * @param string $dbuser Database username - * @param string $dbpass Database password - * @param string $dbname Database name - * @param string $table_prefix Database table prefix - * - * @return array|bool Returns true if test is successful, array of errors otherwise - */ - public function check_database_connection($dbms, $dbhost, $dbport, $dbuser, $dbpass, $dbname, $table_prefix) - { - $dbms_info = $this->get_available_dbms($dbms); - $dbms_info = $dbms_info[$dbms]; - $errors = array(); - - // Instantiate it and set return on error true - /** @var \phpbb\db\driver\driver_interface $db */ - $db = new $dbms_info['DRIVER']; - $db->sql_return_on_error(true); - - // Check that we actually have a database name before going any further - if (!in_array($dbms_info['SCHEMA'], array('sqlite', 'oracle'), true) && $dbname === '') - { - $errors[] = array( - 'title' => 'INST_ERR_DB_NO_NAME', - ); - } - - // Make sure we don't have a daft user who thinks having the SQLite database in the forum directory is a good idea - if ($dbms_info['SCHEMA'] === 'sqlite' - && stripos($this->filesystem->realpath($dbhost), $this->filesystem->realpath($this->phpbb_root_path) === 0)) - { - $errors[] = array( - 'title' =>'INST_ERR_DB_FORUM_PATH', - ); - } - - // Check if SQLite database is writable - if ($dbms_info['SCHEMA'] === 'sqlite' - && (($this->filesystem->exists($dbhost) && !$this->filesystem->is_writable($dbhost)) || !$this->filesystem->is_writable(pathinfo($dbhost, PATHINFO_DIRNAME)))) - { - $errors[] = array( - 'title' =>'INST_ERR_DB_NO_WRITABLE', - ); - } - - // Try to connect to db - if (is_array($db->sql_connect($dbhost, $dbuser, $dbpass, $dbname, $dbport, false, true))) - { - $db_error = $db->sql_error(); - $errors[] = array( - 'title' => 'INST_ERR_DB_CONNECT', - 'description' => ($db_error['message']) ? utf8_convert_message($db_error['message']) : 'INST_ERR_DB_NO_ERROR', - ); - } - else - { - // Check if there is any table name collisions - $temp_prefix = strtolower($table_prefix); - $table_ary = array( - $temp_prefix . 'attachments', - $temp_prefix . 'config', - $temp_prefix . 'sessions', - $temp_prefix . 'topics', - $temp_prefix . 'users', - ); - - $db_tools_factory = new \phpbb\db\tools\factory(); - $db_tools = $db_tools_factory->get($db); - $tables = $db_tools->sql_list_tables(); - $tables = array_map('strtolower', $tables); - $table_intersect = array_intersect($tables, $table_ary); - - if (count($table_intersect)) - { - $errors[] = array( - 'title' => 'INST_ERR_PREFIX', - ); - } - - // Check if database version is supported - switch ($dbms) - { - case 'sqlite3': - if (version_compare($db->sql_server_info(true), '3.6.15', '<')) - { - $errors[] = array( - 'title' => 'INST_ERR_DB_NO_SQLITE3', - ); - } - break; - case 'oracle': - $sql = "SELECT * - FROM NLS_DATABASE_PARAMETERS - WHERE PARAMETER = 'NLS_RDBMS_VERSION' - OR PARAMETER = 'NLS_CHARACTERSET'"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $stats[$row['parameter']] = $row['value']; - } - $db->sql_freeresult($result); - - if (version_compare($stats['NLS_RDBMS_VERSION'], '9.2', '<') && $stats['NLS_CHARACTERSET'] !== 'UTF8') - { - $errors[] = array( - 'title' => 'INST_ERR_DB_NO_ORACLE', - ); - } - break; - case 'postgres': - $sql = "SHOW server_encoding;"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row['server_encoding'] !== 'UNICODE' && $row['server_encoding'] !== 'UTF8') - { - $errors[] = array( - 'title' => 'INST_ERR_DB_NO_POSTGRES', - ); - } - break; - } - } - - return (empty($errors)) ? true : $errors; - } -} diff --git a/install/update/new/phpbb/install/helper/iohandler/iohandler_interface.php b/install/update/new/phpbb/install/helper/iohandler/iohandler_interface.php deleted file mode 100644 index 3df9a91..0000000 --- a/install/update/new/phpbb/install/helper/iohandler/iohandler_interface.php +++ /dev/null @@ -1,222 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\install\helper\iohandler; - -/** - * Input-Output handler interface for the installer - */ -interface iohandler_interface -{ - /** - * Renders or returns response message - * - * @param bool $no_more_output Whether or not there will be more output in this output unit - */ - public function send_response($no_more_output = false); - - /** - * Returns input variable - * - * @param string $name Name of the input variable to obtain - * @param mixed $default A default value that is returned if the variable was not set. - * This function will always return a value of the same type as the default. - * @param bool $multibyte If $default is a string this parameter has to be true if the variable may contain any UTF-8 characters - * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks - * - * @return mixed Value of the input variable - */ - public function get_input($name, $default, $multibyte = false); - - /** - * Returns raw input variable - * - * @param string $name Name of the input variable to obtain - * @param mixed $default A default value that is returned if the variable was not set. - * This function will always return a value of the same type as the default. - * - * @return mixed Value of the raw input variable - */ - public function get_raw_input($name, $default); - - /** - * Returns server variable - * - * This function should work the same as request_interface::server(). - * - * @param string $name Name of the server variable - * @param mixed $default Default value to return when the requested variable does not exist - * - * @return mixed Value of the server variable - */ - public function get_server_variable($name, $default = ''); - - /** - * Wrapper function for request_interface::header() - * - * @param string $name Name of the request header variable - * @param mixed $default Default value to return when the requested variable does not exist - * - * @return mixed - */ - public function get_header_variable($name, $default = ''); - - /** - * Returns true if the connection is encrypted - * - * @return bool - */ - public function is_secure(); - - /** - * Adds an error message to the rendering queue - * - * Note: When an array is passed into the parameters below, it will be - * resolved as printf($param[0], $param[1], ...). - * - * @param string|array $error_title Title of the error message. - * @param string|bool|array $error_description Description of the error (and possibly guidelines to resolve it), - * or false if the error description is not available. - */ - public function add_error_message($error_title, $error_description = false); - - /** - * Adds a warning message to the rendering queue - * - * Note: When an array is passed into the parameters below, it will be - * resolved as printf($param[0], $param[1], ...). - * - * @param string|array $warning_title Title of the warning message - * @param string|bool|array $warning_description Description of the warning (and possibly guidelines to resolve it), - * or false if the warning description is not available - */ - public function add_warning_message($warning_title, $warning_description = false); - - /** - * Adds a log message to the rendering queue - * - * Note: When an array is passed into the parameters below, it will be - * resolved as printf($param[0], $param[1], ...). - * - * @param string|array $log_title Title of the log message - * @param string|bool|array $log_description Description of the log, - * or false if the log description is not available - */ - public function add_log_message($log_title, $log_description = false); - - /** - * Adds a success message to the rendering queue - * - * Note: When an array is passed into the parameters below, it will be - * resolved as printf($param[0], $param[1], ...). - * - * @param string|array $success_title Title of the success message - * @param string|bool|array $success_description Description of the success, - * or false if the success description is not available - * - * @return null - */ - public function add_success_message($success_title, $success_description = false); - - /** - * Adds a requested data group to the rendering queue - * - * @param string $title Language variable with the title of the form - * @param array $form An array describing the required data (options etc) - */ - public function add_user_form_group($title, $form); - - /** - * Returns the rendering information for the form - * - * @param string $title Language variable with the title of the form - * @param array $form An array describing the required data (options etc) - * - * @return string Information to render the form - */ - public function generate_form_render_data($title, $form); - - /** - * Sets the number of tasks belonging to the installer in the current mode. - * - * @param int $task_count Number of tasks - * @param bool $restart Whether or not to restart the progress bar, false by default - */ - public function set_task_count($task_count, $restart = false); - - /** - * Sets the progress information - * - * @param string $task_lang_key Language key for the name of the task - * @param int $task_number Position of the current task in the task queue - */ - public function set_progress($task_lang_key, $task_number); - - /** - * Sends refresh request to the client - */ - public function request_refresh(); - - /** - * Marks stage as active in the navigation bar - * - * @param array $menu_path Array to the navigation elem - */ - public function set_active_stage_menu($menu_path); - - /** - * Marks stage as completed in the navigation bar - * - * @param array $menu_path Array to the navigation elem - */ - public function set_finished_stage_menu($menu_path); - - /** - * Finish the progress bar - * - * @param string $message_lang_key Language key for the message - */ - public function finish_progress($message_lang_key); - - /** - * Adds a download link - * - * @param string $route Route for the link - * @param string $title Language key for the title - * @param string|null|array $msg Language key for the message - */ - public function add_download_link($route, $title, $msg = null); - - /** - * Redirects the user to a new page - * - * @param string $url URL to redirect to - * @param bool $use_ajax Whether or not to use AJAX redirect - */ - public function redirect($url, $use_ajax = false); - - /** - * Renders the status of update files - * - * @param array $status_array Array containing files in groups to render - */ - public function render_update_file_status($status_array); - - /** - * Sends and sets cookies - * - * @param string $cookie_name Name of the cookie to set - * @param string $cookie_value Value of the cookie to set - */ - public function set_cookie($cookie_name, $cookie_value); -} diff --git a/install/update/new/phpbb/install/installer_configuration.php b/install/update/new/phpbb/install/installer_configuration.php deleted file mode 100644 index dfafc40..0000000 --- a/install/update/new/phpbb/install/installer_configuration.php +++ /dev/null @@ -1,146 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\install; - -use Symfony\Component\Config\Definition\Builder\TreeBuilder; -use Symfony\Component\Config\Definition\ConfigurationInterface; - -class installer_configuration implements ConfigurationInterface -{ - - /** - * Generates the configuration tree builder. - * - * @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The tree builder - */ - public function getConfigTreeBuilder() - { - $treeBuilder = new TreeBuilder(); - $rootNode = $treeBuilder->root('installer'); - $rootNode - ->children() - ->arrayNode('admin') - ->children() - ->scalarNode('name')->defaultValue('admin')->cannotBeEmpty()->end() - ->scalarNode('password')->defaultValue('adminadmin')->cannotBeEmpty()->end() - ->scalarNode('email')->defaultValue('admin@example.org')->cannotBeEmpty()->end() - ->end() - ->end() - ->arrayNode('board') - ->children() - ->scalarNode('lang') - ->defaultValue('en') - ->cannotBeEmpty() - ->end() - ->scalarNode('name') - ->defaultValue('My Board') - ->cannotBeEmpty() - ->end() - ->scalarNode('description') - ->defaultValue('My amazing new phpBB board') - ->cannotBeEmpty() - ->end() - ->end() - ->end() - ->arrayNode('database') - ->children() - ->scalarNode('dbms') - ->defaultValue('sqlite3') - ->cannotBeEmpty() - ->isRequired() - ->end() - ->scalarNode('dbhost') - ->defaultValue(null) - ->end() - ->scalarNode('dbport') - ->defaultValue(null) - ->end() - ->scalarNode('dbuser') - ->defaultValue(null) - ->end() - ->scalarNode('dbpasswd') - ->defaultValue(null) - ->end() - ->scalarNode('dbname') - ->defaultValue(null) - ->end() - ->scalarNode('table_prefix') - ->defaultValue('phpbb_') - ->cannotBeEmpty() - ->isRequired() - ->end() - ->end() - ->end() - ->arrayNode('email') - ->canBeEnabled() - ->addDefaultsIfNotSet() - ->children() - ->booleanNode('smtp_delivery') - ->defaultValue(false) - ->treatNullLike(false) - ->end() - ->scalarNode('smtp_host') - ->defaultValue(null) - ->end() - ->scalarNode('smtp_port') - ->defaultValue(null) - ->end() - ->scalarNode('smtp_auth') - ->defaultValue(null) - ->end() - ->scalarNode('smtp_user') - ->defaultValue(null) - ->end() - ->scalarNode('smtp_pass') - ->defaultValue(null) - ->end() - ->end() - ->end() - ->arrayNode('server') - ->children() - ->booleanNode('cookie_secure') - ->defaultValue(false) - ->treatNullLike(false) - ->end() - ->scalarNode('server_protocol') - ->defaultValue('http://') - ->cannotBeEmpty() - ->end() - ->booleanNode('force_server_vars') - ->defaultValue(false) - ->treatNullLike(false) - ->end() - ->scalarNode('server_name') - ->defaultValue('localhost') - ->cannotBeEmpty() - ->end() - ->integerNode('server_port') - ->defaultValue(80) - ->min(1) - ->end() - ->scalarNode('script_path') - ->defaultValue('/') - ->cannotBeEmpty() - ->end() - ->end() - ->end() - ->arrayNode('extensions') - ->prototype('scalar')->end() - ->defaultValue([]) - ->end() - ->end() - ; - return $treeBuilder; - } -} diff --git a/install/update/new/phpbb/install/module/install_database/task/add_config_settings.php b/install/update/new/phpbb/install/module/install_database/task/add_config_settings.php deleted file mode 100644 index 91d7884..0000000 --- a/install/update/new/phpbb/install/module/install_database/task/add_config_settings.php +++ /dev/null @@ -1,367 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\install\module\install_database\task; - -use phpbb\install\exception\resource_limit_reached_exception; - -/** - * Create database schema - */ -class add_config_settings extends \phpbb\install\task_base -{ - /** - * @var \phpbb\db\driver\driver_interface - */ - protected $db; - - /** - * @var \phpbb\filesystem\filesystem_interface - */ - protected $filesystem; - - /** - * @var \phpbb\install\helper\config - */ - protected $install_config; - - /** - * @var \phpbb\install\helper\iohandler\iohandler_interface - */ - protected $iohandler; - - /** - * @var \phpbb\language\language - */ - protected $language; - - /** - * @var \phpbb\passwords\manager - */ - protected $password_manager; - - /** - * @var string - */ - protected $phpbb_root_path; - - /** - * @var string - */ - protected $config_table; - - /** - * @var string - */ - protected $user_table; - - /** - * @var string - */ - protected $topics_table; - - /** - * @var string - */ - protected $forums_table; - - /** - * @var string - */ - protected $posts_table; - - /** - * @var string - */ - protected $moderator_cache_table; - - /** - * Constructor - * - * @param \phpbb\filesystem\filesystem_interface $filesystem Filesystem service - * @param \phpbb\install\helper\config $install_config Installer's config helper - * @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler Installer's input-output handler - * @param \phpbb\install\helper\container_factory $container Installer's DI container - * @param \phpbb\language\language $language Language service - * @param string $phpbb_root_path Path to phpBB's root - */ - public function __construct(\phpbb\filesystem\filesystem_interface $filesystem, - \phpbb\install\helper\config $install_config, - \phpbb\install\helper\iohandler\iohandler_interface $iohandler, - \phpbb\install\helper\container_factory $container, - \phpbb\language\language $language, - $phpbb_root_path) - { - $this->db = $container->get('dbal.conn'); - $this->filesystem = $filesystem; - $this->install_config = $install_config; - $this->iohandler = $iohandler; - $this->language = $language; - $this->password_manager = $container->get('passwords.manager'); - $this->phpbb_root_path = $phpbb_root_path; - - // Table names - $this->config_table = $container->get_parameter('tables.config'); - $this->forums_table = $container->get_parameter('tables.forums'); - $this->topics_table = $container->get_parameter('tables.topics'); - $this->user_table = $container->get_parameter('tables.users'); - $this->moderator_cache_table = $container->get_parameter('tables.moderator_cache'); - $this->posts_table = $container->get_parameter('tables.posts'); - - parent::__construct(true); - } - - /** - * {@inheritdoc} - */ - public function run() - { - $this->db->sql_return_on_error(true); - - $server_name = $this->install_config->get('server_name'); - $current_time = time(); - $user_ip = phpbb_ip_normalise($this->iohandler->get_server_variable('REMOTE_ADDR')); - $user_ip = ($user_ip === false) ? '' : $user_ip; - $referer = $this->iohandler->get_server_variable('REFERER'); - - // Calculate cookie domain - $cookie_domain = $server_name; - - if (strpos($cookie_domain, 'www.') === 0) - { - $cookie_domain = substr($cookie_domain, 3); - } - - // Set default config and post data, this applies to all DB's - $sql_ary = array( - 'INSERT INTO ' . $this->config_table . " (config_name, config_value) - VALUES ('board_startdate', '$current_time')", - - 'INSERT INTO ' . $this->config_table . " (config_name, config_value) - VALUES ('default_lang', '" . $this->db->sql_escape($this->install_config->get('default_lang')) . "')", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($this->install_config->get('server_name')) . "' - WHERE config_name = 'server_name'", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($this->install_config->get('server_port')) . "' - WHERE config_name = 'server_port'", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($this->install_config->get('board_email')) . "' - WHERE config_name = 'board_email'", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($this->install_config->get('board_email')) . "' - WHERE config_name = 'board_contact'", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($cookie_domain) . "' - WHERE config_name = 'cookie_domain'", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($this->language->lang('default_dateformat')) . "' - WHERE config_name = 'default_dateformat'", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($this->install_config->get('email_enable')) . "' - WHERE config_name = 'email_enable'", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($this->install_config->get('smtp_delivery')) . "' - WHERE config_name = 'smtp_delivery'", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($this->install_config->get('smtp_host')) . "' - WHERE config_name = 'smtp_host'", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($this->install_config->get('smtp_port')) . "' - WHERE config_name = 'smtp_port'", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($this->install_config->get('smtp_auth')) . "' - WHERE config_name = 'smtp_auth_method'", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($this->install_config->get('smtp_user')) . "' - WHERE config_name = 'smtp_username'", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($this->install_config->get('smtp_pass')) . "' - WHERE config_name = 'smtp_password'", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($this->install_config->get('cookie_secure')) . "' - WHERE config_name = 'cookie_secure'", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($this->install_config->get('force_server_vars')) . "' - WHERE config_name = 'force_server_vars'", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($this->install_config->get('script_path')) . "' - WHERE config_name = 'script_path'", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($this->install_config->get('server_protocol')) . "' - WHERE config_name = 'server_protocol'", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($this->install_config->get('admin_name')) . "' - WHERE config_name = 'newest_username'", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . md5(mt_rand()) . "' - WHERE config_name = 'avatar_salt'", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . md5(mt_rand()) . "' - WHERE config_name = 'plupload_salt'", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($this->install_config->get('board_name')) . "' - WHERE config_name = 'sitename'", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($this->install_config->get('board_description')) . "' - WHERE config_name = 'site_desc'", - - 'UPDATE ' . $this->user_table . " - SET username = '" . $this->db->sql_escape($this->install_config->get('admin_name')) . "', - user_password='" . $this->password_manager->hash($this->install_config->get('admin_passwd')) . "', - user_ip = '" . $this->db->sql_escape($user_ip) . "', - user_lang = '" . $this->db->sql_escape($this->install_config->get('user_language', 'en')) . "', - user_email='" . $this->db->sql_escape($this->install_config->get('board_email')) . "', - user_dateformat='" . $this->db->sql_escape($this->language->lang('default_dateformat')) . "', - username_clean = '" . $this->db->sql_escape(utf8_clean_string($this->install_config->get('admin_name'))) . "' - WHERE username = 'Admin'", - - 'UPDATE ' . $this->moderator_cache_table . " - SET username = '" . $this->db->sql_escape($this->install_config->get('admin_name')) . "' - WHERE username = 'Admin'", - - 'UPDATE ' . $this->forums_table . " - SET forum_last_poster_name = '" . $this->db->sql_escape($this->install_config->get('admin_name')) . "' - WHERE forum_last_poster_name = 'Admin'", - - 'UPDATE ' . $this->topics_table . " - SET topic_first_poster_name = '" . $this->db->sql_escape($this->install_config->get('admin_name')) . "', - topic_last_poster_name = '" . $this->db->sql_escape($this->install_config->get('admin_name')) . "' - WHERE topic_first_poster_name = 'Admin' - OR topic_last_poster_name = 'Admin'", - - 'UPDATE ' . $this->user_table . " - SET user_regdate = $current_time", - - 'UPDATE ' . $this->posts_table . " - SET post_time = $current_time, poster_ip = '" . $this->db->sql_escape($user_ip) . "'", - - 'UPDATE ' . $this->topics_table . " - SET topic_time = $current_time, topic_last_post_time = $current_time", - - 'UPDATE ' . $this->forums_table . " - SET forum_last_post_time = $current_time", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($this->db->sql_server_info(true)) . "' - WHERE config_name = 'dbms_version'", - ); - - if (@extension_loaded('gd')) - { - $sql_ary[] = 'UPDATE ' . $this->config_table . " - SET config_value = 'core.captcha.plugins.gd' - WHERE config_name = 'captcha_plugin'"; - - $sql_ary[] = 'UPDATE ' . $this->config_table . " - SET config_value = '1' - WHERE config_name = 'captcha_gd'"; - } - - $ref = substr($referer, strpos($referer, '://') + 3); - if (!(stripos($ref, $server_name) === 0)) - { - $sql_ary[] = 'UPDATE ' . $this->config_table . " - SET config_value = '0' - WHERE config_name = 'referer_validation'"; - } - - // We set a (semi-)unique cookie name to bypass login issues related to the cookie name. - $cookie_name = 'phpbb3_'; - $rand_str = md5(mt_rand()); - $rand_str = str_replace('0', 'z', base_convert($rand_str, 16, 35)); - $rand_str = substr($rand_str, 0, 5); - $cookie_name .= strtolower($rand_str); - - $sql_ary[] = 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($cookie_name) . "' - WHERE config_name = 'cookie_name'"; - - // Disable avatars if upload directory is not writable - if (!$this->filesystem->is_writable($this->phpbb_root_path . 'images/avatars/upload/')) - { - $sql_ary[] = 'UPDATE ' . $this->config_table . " - SET config_value = '0' - WHERE config_name = 'allow_avatar'"; - - $sql_ary[] = 'UPDATE ' . $this->config_table . " - SET config_value = '0' - WHERE config_name = 'allow_avatar_upload'"; - } - - $i = $this->install_config->get('add_config_settings_index', 0); - $total = count($sql_ary); - $sql_ary = array_slice($sql_ary, $i); - - foreach ($sql_ary as $sql) - { - if (!$this->db->sql_query($sql)) - { - $error = $this->db->sql_error($this->db->get_sql_error_sql()); - $this->iohandler->add_error_message('INST_ERR_DB', $error['message']); - } - - $i++; - - // Stop execution if resource limit is reached - if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0) - { - break; - } - } - - if ($i < $total) - { - $this->install_config->set('add_config_settings_index', $i); - throw new resource_limit_reached_exception(); - } - } - - /** - * {@inheritdoc} - */ - static public function get_step_count() - { - return 1; - } - - /** - * {@inheritdoc} - */ - public function get_task_lang_name() - { - return 'TASK_ADD_CONFIG_SETTINGS'; - } -} diff --git a/install/update/new/phpbb/install/module/install_database/task/create_schema.php b/install/update/new/phpbb/install/module/install_database/task/create_schema.php deleted file mode 100644 index 983bb42..0000000 --- a/install/update/new/phpbb/install/module/install_database/task/create_schema.php +++ /dev/null @@ -1,227 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\install\module\install_database\task; - -use phpbb\install\exception\resource_limit_reached_exception; - -/** - * Create database schema - */ -class create_schema extends \phpbb\install\task_base -{ - /** - * @var \phpbb\install\helper\config - */ - protected $config; - - /** - * @var \phpbb\db\driver\driver_interface - */ - protected $db; - - /** - * @var \phpbb\db\tools\tools_interface - */ - protected $db_tools; - - /** - * @var \phpbb\install\helper\database - */ - protected $database_helper; - - /** - * @var \phpbb\filesystem\filesystem_interface - */ - protected $filesystem; - - /** - * @var \phpbb\install\helper\iohandler\iohandler_interface - */ - protected $iohandler; - - /** - * @var string - */ - protected $phpbb_root_path; - - /** - * @var string - */ - protected $php_ext; - - /** - * Constructor - * - * @param \phpbb\install\helper\config $config Installer's config provider - * @param \phpbb\install\helper\database $db_helper Installer's database helper - * @param \phpbb\filesystem\filesystem_interface $filesystem Filesystem service - * @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler Installer's input-output handler - * @param string $phpbb_root_path Path phpBB's root - * @param string $php_ext Extension of PHP files - */ - public function __construct(\phpbb\install\helper\config $config, - \phpbb\install\helper\database $db_helper, - \phpbb\filesystem\filesystem_interface $filesystem, - \phpbb\install\helper\iohandler\iohandler_interface $iohandler, - $phpbb_root_path, - $php_ext) - { - $dbms = $db_helper->get_available_dbms($config->get('dbms')); - $dbms = $dbms[$config->get('dbms')]['DRIVER']; - $factory = new \phpbb\db\tools\factory(); - - $this->db = new $dbms(); - $this->db->sql_connect( - $config->get('dbhost'), - $config->get('dbuser'), - $config->get('dbpasswd'), - $config->get('dbname'), - $config->get('dbport'), - false, - false - ); - - $this->config = $config; - $this->db_tools = $factory->get($this->db); - $this->database_helper = $db_helper; - $this->filesystem = $filesystem; - $this->iohandler = $iohandler; - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - - parent::__construct(true); - } - - /** - * {@inheritdoc} - */ - public function run() - { - // As this task may take a large amount of time to complete refreshing the page might be necessary for some - // server configurations with limited resources - if (!$this->config->get('pre_schema_forced_refresh')) - { - if ($this->config->get_time_remaining() < 5) - { - $this->config->set('pre_schema_forced_refresh', true); - throw new resource_limit_reached_exception(); - } - } - - $this->db->sql_return_on_error(true); - - $dbms = $this->config->get('dbms'); - $dbms_info = $this->database_helper->get_available_dbms($dbms); - $schema_name = $dbms_info[$dbms]['SCHEMA']; - $delimiter = $dbms_info[$dbms]['DELIM']; - $table_prefix = $this->config->get('table_prefix'); - - if ($dbms === 'mysql') - { - $schema_name .= '_41'; - } - - $db_schema_path = $this->phpbb_root_path . 'install/schemas/' . $schema_name . '_schema.sql'; - - // Load database vendor specific code if there is any - if ($this->filesystem->exists($db_schema_path)) - { - $sql_query = @file_get_contents($db_schema_path); - $sql_query = preg_replace('#phpbb_#i', $table_prefix, $sql_query); - $sql_query = $this->database_helper->remove_comments($sql_query); - $sql_query = $this->database_helper->split_sql_file($sql_query, $delimiter); - - foreach ($sql_query as $sql) - { - if (!$this->db->sql_query($sql)) - { - $error = $this->db->sql_error($this->db->get_sql_error_sql()); - $this->iohandler->add_error_message('INST_ERR_DB', $error['message']); - } - } - - unset($sql_query); - } - - $change_prefix = false; - - // Generate database schema - if ($this->filesystem->exists($this->phpbb_root_path . 'install/schemas/schema.json')) - { - $db_table_schema = @file_get_contents($this->phpbb_root_path . 'install/schemas/schema.json'); - $db_table_schema = json_decode($db_table_schema, true); - $change_prefix = true; - } - else - { - global $table_prefix; - - $table_prefix = $this->config->get('table_prefix'); - - if (!defined('CONFIG_TABLE')) - { - // We need to include the constants file for the table constants - // when we generate the schema from the migration files. - include ($this->phpbb_root_path . 'includes/constants.' . $this->php_ext); - } - - $finder = new \phpbb\finder($this->filesystem, $this->phpbb_root_path, null, $this->php_ext); - $migrator_classes = $finder->core_path('phpbb/db/migration/data/')->get_classes(); - $factory = new \phpbb\db\tools\factory(); - $db_tools = $factory->get($this->db, true); - $schema_generator = new \phpbb\db\migration\schema_generator( - $migrator_classes, - new \phpbb\config\config(array()), - $this->db, - $db_tools, - $this->phpbb_root_path, - $this->php_ext, - $table_prefix - ); - $db_table_schema = $schema_generator->get_schema(); - } - - if (!defined('CONFIG_TABLE')) - { - // CONFIG_TABLE is required by sql_create_index() to check the - // length of index names. However table_prefix is not defined - // here yet, so we need to create the constant ourselves. - define('CONFIG_TABLE', $table_prefix . 'config'); - } - - foreach ($db_table_schema as $table_name => $table_data) - { - $this->db_tools->sql_create_table( - ( ($change_prefix) ? ($table_prefix . substr($table_name, 6)) : $table_name ), - $table_data - ); - } - } - - /** - * {@inheritdoc} - */ - static public function get_step_count() - { - return 1; - } - - /** - * {@inheritdoc} - */ - public function get_task_lang_name() - { - return 'TASK_CREATE_DATABASE_SCHEMA'; - } -} diff --git a/install/update/new/phpbb/install/module/install_database/task/set_up_database.php b/install/update/new/phpbb/install/module/install_database/task/set_up_database.php deleted file mode 100644 index 4da5ece..0000000 --- a/install/update/new/phpbb/install/module/install_database/task/set_up_database.php +++ /dev/null @@ -1,157 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\install\module\install_database\task; - -/** - * Set up database for table generation - */ -class set_up_database extends \phpbb\install\task_base -{ - /** - * @var \phpbb\install\helper\config - */ - protected $config; - - /** - * @var \phpbb\db\driver\driver_interface - */ - protected $db; - - /** - * @var \phpbb\install\helper\database - */ - protected $database_helper; - - /** - * @var \phpbb\filesystem\filesystem_interface - */ - protected $filesystem; - - /** - * @var \phpbb\install\helper\iohandler\iohandler_interface - */ - protected $iohandler; - - /** - * @var string - */ - protected $schema_file_path; - - /** - * @var string - */ - protected $phpbb_root_path; - - /** - * Constructor - * - * @param \phpbb\install\helper\config $config - * @param \phpbb\install\helper\database $db_helper - * @param \phpbb\filesystem\filesystem_interface $filesystem - * @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler - * @param string $phpbb_root_path - */ - public function __construct(\phpbb\install\helper\config $config, - \phpbb\install\helper\database $db_helper, - \phpbb\filesystem\filesystem_interface $filesystem, - \phpbb\install\helper\iohandler\iohandler_interface $iohandler, - $phpbb_root_path) - { - $dbms = $db_helper->get_available_dbms($config->get('dbms')); - $dbms = $dbms[$config->get('dbms')]['DRIVER']; - - $this->db = new $dbms(); - $this->db->sql_connect( - $config->get('dbhost'), - $config->get('dbuser'), - $config->get('dbpasswd'), - $config->get('dbname'), - $config->get('dbport'), - false, - false - ); - - $this->config = $config; - $this->database_helper = $db_helper; - $this->filesystem = $filesystem; - $this->iohandler = $iohandler; - $this->phpbb_root_path = $phpbb_root_path; - - parent::__construct(false); - } - - /** - * {@inheritdoc} - */ - public function check_requirements() - { - $dbms = $this->config->get('dbms'); - $dbms_info = $this->database_helper->get_available_dbms($dbms); - $schema_name = $dbms_info[$dbms]['SCHEMA']; - - if ($dbms === 'mysql') - { - $schema_name .= '_41'; - } - - $this->schema_file_path = $this->phpbb_root_path . 'install/schemas/' . $schema_name . '_schema.sql'; - - return $this->filesystem->exists($this->schema_file_path); - } - - /** - * {@inheritdoc} - */ - public function run() - { - $this->db->sql_return_on_error(true); - - $dbms = $this->config->get('dbms'); - $dbms_info = $this->database_helper->get_available_dbms($dbms); - $delimiter = $dbms_info[$dbms]['DELIM']; - $table_prefix = $this->config->get('table_prefix'); - - $sql_query = @file_get_contents($this->schema_file_path); - $sql_query = preg_replace('#phpbb_#i', $table_prefix, $sql_query); - $sql_query = $this->database_helper->remove_comments($sql_query); - $sql_query = $this->database_helper->split_sql_file($sql_query, $delimiter); - - foreach ($sql_query as $sql) - { - if (!$this->db->sql_query($sql)) - { - $error = $this->db->sql_error($this->db->get_sql_error_sql()); - $this->iohandler->add_error_message('INST_ERR_DB', $error['message']); - } - } - - unset($sql_query); - } - - /** - * {@inheritdoc} - */ - static public function get_step_count() - { - return 1; - } - - /** - * {@inheritdoc} - */ - public function get_task_lang_name() - { - return 'TASK_SETUP_DATABASE'; - } -} diff --git a/install/update/new/phpbb/install/module/install_filesystem/task/create_config_file.php b/install/update/new/phpbb/install/module/install_filesystem/task/create_config_file.php deleted file mode 100644 index 900d5b9..0000000 --- a/install/update/new/phpbb/install/module/install_filesystem/task/create_config_file.php +++ /dev/null @@ -1,243 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\install\module\install_filesystem\task; - -use phpbb\install\exception\user_interaction_required_exception; - -/** - * Dumps config file - */ -class create_config_file extends \phpbb\install\task_base -{ - /** - * @var \phpbb\filesystem\filesystem_interface - */ - protected $filesystem; - - /** - * @var \phpbb\install\helper\database - */ - protected $db_helper; - - /** - * @var \phpbb\install\helper\config - */ - protected $install_config; - - /** - * @var \phpbb\install\helper\iohandler\iohandler_interface - */ - protected $iohandler; - - /** - * @var string - */ - protected $phpbb_root_path; - - /** - * @var string - */ - protected $php_ext; - - /** - * @var array - */ - protected $options; - - /** - * Constructor - * - * @param \phpbb\filesystem\filesystem_interface $filesystem - * @param \phpbb\install\helper\config $install_config - * @param \phpbb\install\helper\database $db_helper - * @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler - * @param string $phpbb_root_path - * @param string $php_ext - * @param array $options - */ - public function __construct(\phpbb\filesystem\filesystem_interface $filesystem, - \phpbb\install\helper\config $install_config, - \phpbb\install\helper\database $db_helper, - \phpbb\install\helper\iohandler\iohandler_interface $iohandler, - $phpbb_root_path, - $php_ext, - $options = array()) - { - $this->install_config = $install_config; - $this->db_helper = $db_helper; - $this->filesystem = $filesystem; - $this->iohandler = $iohandler; - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - $this->options = array_merge(array( - 'debug' => false, - 'debug_container' => false, - 'environment' => null, - ), $options); - - parent::__construct(true); - } - - /** - * {@inheritdoc} - */ - public function run() - { - $config_written = true; - - // Create config.php - $path_to_config = $this->phpbb_root_path . 'config.' . $this->php_ext; - - $fp = @fopen($path_to_config, 'w'); - if (!$fp) - { - $config_written = false; - } - - $config_content = $this->get_config_data($this->options['debug'], $this->options['debug_container'], $this->options['environment']); - - if (!@fwrite($fp, $config_content)) - { - $config_written = false; - } - - @fclose($fp); - - // chmod config.php to be only readable - if ($config_written) - { - try - { - $this->filesystem->phpbb_chmod($path_to_config, \phpbb\filesystem\filesystem_interface::CHMOD_READ); - } - catch (\phpbb\filesystem\exception\filesystem_exception $e) - { - // Do nothing, the user will get a notice later - } - } - else - { - $this->iohandler->add_error_message('UNABLE_TO_WRITE_CONFIG_FILE'); - throw new user_interaction_required_exception(); - } - - // Create a lock file to indicate that there is an install in progress - $fp = @fopen($this->phpbb_root_path . 'cache/install_lock', 'wb'); - if ($fp === false) - { - // We were unable to create the lock file - abort - $this->iohandler->add_error_message('UNABLE_TO_WRITE_LOCK'); - throw new user_interaction_required_exception(); - } - @fclose($fp); - - try - { - $this->filesystem->phpbb_chmod($this->phpbb_root_path . 'cache/install_lock', 0777); - } - catch (\phpbb\filesystem\exception\filesystem_exception $e) - { - // Do nothing, the user will get a notice later - } - } - - /** - * Returns the content which should be dumped to config.php - * - * @param bool $debug If the debug constants should be enabled by default or not - * @param bool $debug_container If the container should be compiled on - * every page load or not - * @param string $environment The environment to use - * - * @return string content to be written to the config file - */ - protected function get_config_data($debug = false, $debug_container = false, $environment = null) - { - $config_content = "install_config->get('dbms'); - $db_driver = $this->db_helper->get_available_dbms($dbms); - $db_driver = $db_driver[$dbms]['DRIVER']; - - $config_data_array = array( - 'dbms' => $db_driver, - 'dbhost' => $this->install_config->get('dbhost'), - 'dbport' => $this->install_config->get('dbport'), - 'dbname' => $this->install_config->get('dbname'), - 'dbuser' => $this->install_config->get('dbuser'), - 'dbpasswd' => $this->install_config->get('dbpasswd'), - 'table_prefix' => $this->install_config->get('table_prefix'), - - 'phpbb_adm_relative_path' => 'adm/', - - 'acm_type' => 'phpbb\cache\driver\file', - ); - - foreach ($config_data_array as $key => $value) - { - $config_content .= "\${$key} = '" . str_replace("'", "\\'", str_replace('\\', '\\\\', $value)) . "';\n"; - } - - $config_content .= "\n@define('PHPBB_INSTALLED', true);\n"; - - if ($environment) - { - $config_content .= "@define('PHPBB_ENVIRONMENT', 'test');\n"; - } - else if ($debug) - { - $config_content .= "@define('PHPBB_ENVIRONMENT', 'development');\n"; - } - else - { - $config_content .= "@define('PHPBB_ENVIRONMENT', 'production');\n"; - } - - if ($debug_container) - { - $config_content .= "@define('DEBUG_CONTAINER', true);\n"; - } - else - { - $config_content .= "// @define('DEBUG_CONTAINER', true);\n"; - } - - if ($environment === 'test') - { - $config_content .= "@define('DEBUG_TEST', true);\n"; - - // Mandatory for the functional tests, will be removed by PHPBB3-12623 - $config_content .= "@define('DEBUG', true);\n"; - } - - return $config_content; - } - - /** - * {@inheritdoc} - */ - static public function get_step_count() - { - return 1; - } - - /** - * {@inheritdoc} - */ - public function get_task_lang_name() - { - return 'TASK_CREATE_CONFIG_FILE'; - } -} diff --git a/install/update/new/phpbb/install/module/requirements/task/check_server_environment.php b/install/update/new/phpbb/install/module/requirements/task/check_server_environment.php deleted file mode 100644 index 41aa826..0000000 --- a/install/update/new/phpbb/install/module/requirements/task/check_server_environment.php +++ /dev/null @@ -1,207 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\install\module\requirements\task; - -/** - * Installer task that checks if the server meats phpBB requirements - */ -class check_server_environment extends \phpbb\install\task_base -{ - /** - * @var \phpbb\install\helper\database - */ - protected $database_helper; - - /** - * @var \phpbb\install\helper\iohandler\iohandler_interface - */ - protected $response_helper; - - /** - * @var bool - */ - protected $tests_passed; - - /** - * Constructor - * - * @param \phpbb\install\helper\database $database_helper - * @param \phpbb\install\helper\iohandler\iohandler_interface $response - */ - public function __construct(\phpbb\install\helper\database $database_helper, - \phpbb\install\helper\iohandler\iohandler_interface $response) - { - $this->database_helper = $database_helper; - $this->response_helper = $response; - $this->tests_passed = true; - - parent::__construct(true); - } - - /** - * {@inheritdoc} - */ - public function run() - { - // - // Check requirements - // The error messages should be set in the check_ functions - // - - // Check PHP version - $this->check_php_version(); - - // Check for getimagesize() - $this->check_image_size(); - - // Check for PCRE support - $this->check_pcre(); - - // Check for JSON support - $this->check_json(); - - // XML extension support check - $this->check_xml(); - - // Check for dbms support - $this->check_available_dbms(); - - return $this->tests_passed; - } - - /** - * Sets $this->tests_passed - * - * @param bool $is_passed - */ - protected function set_test_passed($is_passed) - { - // If one test failed, tests_passed should be false - $this->tests_passed = (!$this->tests_passed) ? false : $is_passed; - } - - /** - * Check if the requirements for PHP version is met - */ - protected function check_php_version() - { - if (version_compare(PHP_VERSION, '7.1.3', '<')) - { - $this->response_helper->add_error_message('PHP_VERSION_REQD', 'PHP_VERSION_REQD_EXPLAIN'); - - $this->set_test_passed(false); - return; - } - - $this->set_test_passed(true); - } - - /** - * Checks if the installed PHP has getimagesize() available - */ - protected function check_image_size() - { - if (!@function_exists('getimagesize')) - { - $this->response_helper->add_error_message('PHP_GETIMAGESIZE_SUPPORT', 'PHP_GETIMAGESIZE_SUPPORT_EXPLAIN'); - - $this->set_test_passed(false); - return; - } - - $this->set_test_passed(true); - } - - /** - * Checks if the installed PHP supports PCRE - */ - protected function check_pcre() - { - if (@preg_match('//u', '')) - { - $this->set_test_passed(true); - return; - } - - $this->response_helper->add_error_message('PCRE_UTF_SUPPORT', 'PCRE_UTF_SUPPORT_EXPLAIN'); - - $this->set_test_passed(false); - } - - /** - * Checks whether PHP's JSON extension is available or not - */ - protected function check_json() - { - if (@extension_loaded('json')) - { - $this->set_test_passed(true); - return; - } - - $this->response_helper->add_error_message('PHP_JSON_SUPPORT', 'PHP_JSON_SUPPORT_EXPLAIN'); - - $this->set_test_passed(false); - } - - /** - * Checks whether or not the XML PHP extension is available (Required by the text formatter) - */ - protected function check_xml() - { - if (class_exists('DOMDocument')) - { - $this->set_test_passed(true); - return; - } - - $this->response_helper->add_error_message('PHP_XML_SUPPORT', 'PHP_XML_SUPPORT_EXPLAIN'); - - $this->set_test_passed(false); - } - - /** - * Check if any supported DBMS is available - */ - protected function check_available_dbms() - { - $available_dbms = $this->database_helper->get_available_dbms(false, true); - - if ($available_dbms['ANY_DB_SUPPORT']) - { - $this->set_test_passed(true); - return; - } - - $this->response_helper->add_error_message('PHP_SUPPORTED_DB', 'PHP_SUPPORTED_DB_EXPLAIN'); - - $this->set_test_passed(false); - } - - /** - * {@inheritdoc} - */ - static public function get_step_count() - { - return 0; - } - - /** - * {@inheritdoc} - */ - public function get_task_lang_name() - { - return ''; - } -} diff --git a/install/update/new/phpbb/install/module_base.php b/install/update/new/phpbb/install/module_base.php deleted file mode 100644 index 4464a89..0000000 --- a/install/update/new/phpbb/install/module_base.php +++ /dev/null @@ -1,213 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\install; - -use phpbb\di\ordered_service_collection; -use phpbb\install\exception\resource_limit_reached_exception; -use phpbb\install\helper\config; -use phpbb\install\helper\iohandler\iohandler_interface; - -/** - * Base class for installer module - */ -abstract class module_base implements module_interface -{ - /** - * @var config - */ - protected $install_config; - - /** - * @var iohandler_interface - */ - protected $iohandler; - - /** - * @var bool - */ - protected $is_essential; - - /** - * Array of tasks for installer module - * - * @var ordered_service_collection - */ - protected $task_collection; - - /** - * @var array - */ - protected $task_step_count; - - /** - * @var bool - */ - protected $allow_progress_bar; - - /** - * Installer module constructor - * - * @param ordered_service_collection $tasks array of installer tasks for installer module - * @param bool $essential flag indicating whether the module is essential or not - * @param bool $allow_progress_bar flag indicating whether or not to send progress information from within the module - */ - public function __construct(ordered_service_collection $tasks, $essential = true, $allow_progress_bar = true) - { - $this->task_collection = $tasks; - $this->is_essential = $essential; - $this->allow_progress_bar = $allow_progress_bar; - } - - /** - * Dependency getter - * - * @param config $config - * @param iohandler_interface $iohandler - */ - public function setup(config $config, iohandler_interface $iohandler) - { - $this->install_config = $config; - $this->iohandler = $iohandler; - } - - /** - * {@inheritdoc} - */ - public function is_essential() - { - return $this->is_essential; - } - - /** - * {@inheritdoc} - * - * Overwrite this method if your task is non-essential! - */ - public function check_requirements() - { - return true; - } - - /** - * {@inheritdoc} - */ - public function run() - { - // Recover install progress - $task_index = $this->recover_progress(); - $iterator = $this->task_collection->getIterator(); - - if ($task_index < $iterator->count()) - { - $iterator->seek($task_index); - } - else - { - $this->install_config->set_finished_task(0); - return; - } - - while ($iterator->valid()) - { - $task = $iterator->current(); - $name = $iterator->key(); - - // Check if we can run the task - if (!$task->is_essential() && !$task->check_requirements()) - { - $this->iohandler->add_log_message(array( - 'SKIP_TASK', - $name, - )); - - $this->install_config->increment_current_task_progress($this->task_step_count[$name] ?? false); - } - else - { - // Send progress information - if ($this->allow_progress_bar) - { - $this->iohandler->set_progress( - $task->get_task_lang_name(), - $this->install_config->get_current_task_progress() - ); - - $this->iohandler->send_response(); - } - - $task->run(); - - if ($this->allow_progress_bar) - { - // Only increment progress by one, as if a task has more than one steps - // then that should be incremented in the task itself - $this->install_config->increment_current_task_progress(); - } - } - - $task_index++; - $this->install_config->set_finished_task($task_index); - $iterator->next(); - - // Send progress information - if ($this->allow_progress_bar) - { - $this->iohandler->set_progress( - $task->get_task_lang_name(), - $this->install_config->get_current_task_progress() - ); - } - - $this->iohandler->send_response(); - - // Stop execution if resource limit is reached - if ($iterator->valid() && ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0)) - { - throw new resource_limit_reached_exception(); - } - } - - // Module finished, so clear task progress - $this->install_config->set_finished_task(0); - } - - /** - * Returns the next task's name - * - * @return string Index of the array element of the next task - */ - protected function recover_progress() - { - $progress_array = $this->install_config->get_progress_data(); - return $progress_array['last_task_index']; - } - - /** - * {@inheritdoc} - */ - public function get_step_count() - { - $task_step_count = 0; - $task_class_names = $this->task_collection->get_service_classes(); - - foreach ($task_class_names as $name => $task_class) - { - $step_count = $task_class::get_step_count(); - $task_step_count += $step_count; - $this->task_step_count[$name] = $step_count; - } - - return $task_step_count; - } -} diff --git a/install/update/new/phpbb/language/language_file_loader.php b/install/update/new/phpbb/language/language_file_loader.php deleted file mode 100644 index 2910dd3..0000000 --- a/install/update/new/phpbb/language/language_file_loader.php +++ /dev/null @@ -1,207 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\language; - -use \phpbb\language\exception\language_file_not_found; - -/** - * Language file loader - */ -class language_file_loader -{ - /** - * @var string Path to phpBB's root - */ - protected $phpbb_root_path; - - /** - * @var string Extension of PHP files - */ - protected $php_ext; - - /** - * @var \phpbb\extension\manager Extension manager - */ - protected $extension_manager; - - /** - * Constructor - * - * @param string $phpbb_root_path Path to phpBB's root - * @param string $php_ext Extension of PHP files - */ - public function __construct($phpbb_root_path, $php_ext) - { - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - - $this->extension_manager = null; - } - - /** - * Extension manager setter - * - * @param \phpbb\extension\manager $extension_manager Extension manager - */ - public function set_extension_manager(\phpbb\extension\manager $extension_manager) - { - $this->extension_manager = $extension_manager; - } - - /** - * Loads language array for the given component - * - * @param string $component Name of the language component - * @param string|array $locale ISO code of the language to load, or array of ISO codes if you want to - * specify additional language fallback steps - * @param array $lang Array reference containing language strings - */ - public function load($component, $locale, &$lang) - { - $locale = (array) $locale; - - // Determine path to language directory - $path = $this->phpbb_root_path . 'language/'; - - $this->load_file($path, $component, $locale, $lang); - } - - /** - * Loads language array for the given extension component - * - * @param string $extension Name of the extension - * @param string $component Name of the language component - * @param string|array $locale ISO code of the language to load, or array of ISO codes if you want to - * specify additional language fallback steps - * @param array $lang Array reference containing language strings - */ - public function load_extension($extension, $component, $locale, &$lang) - { - // Check if extension manager was loaded - if ($this->extension_manager === null) - { - // If not, let's return - return; - } - - $locale = (array) $locale; - - // Determine path to language directory - $path = $this->extension_manager->get_extension_path($extension, true) . 'language/'; - - $this->load_file($path, $component, $locale, $lang); - } - - /** - * Prepares language file loading - * - * @param string $path Path to search for file in - * @param string $component Name of the language component - * @param array $locale Array containing language fallback options - * @param array $lang Array reference of language strings - */ - protected function load_file($path, $component, $locale, &$lang) - { - // This is BC stuff and not the best idea as it makes language fallback - // implementation quite hard like below. - if (strpos($this->phpbb_root_path . $component, $path) === 0) - { - // Filter out the path - $path_diff = str_replace($path, '', dirname($this->phpbb_root_path . $component)); - $language_file = basename($component, '.' . $this->php_ext); - $component = ''; - - // This step is needed to resolve language/en/subdir style $component - // $path already points to the language base directory so we need to eliminate - // the first directory from the path (that should be the language directory) - $path_diff_parts = explode('/', $path_diff); - - if (count($path_diff_parts) > 1) - { - array_shift($path_diff_parts); - $component = implode('/', $path_diff_parts) . '/'; - } - - $component .= $language_file; - } - - // Determine filename - $filename = $component . '.' . $this->php_ext; - - // Determine path to file - $file_path = $this->get_language_file_path($path, $filename, $locale); - - // Load language array - $this->load_language_file($file_path, $lang); - } - - /** - * This function implements language fallback logic - * - * @param string $path Path to language directory - * @param string $filename Filename to load language strings from - * @param array $locales Array containing language fallback options - * - * @return string Relative path to language file - * - * @throws language_file_not_found When the path to the file cannot be resolved - */ - protected function get_language_file_path($path, $filename, $locales) - { - $language_file_path = $filename; - - // Language fallback logic - foreach ($locales as $locale) - { - $language_file_path = $path . $locale . '/' . $filename; - - // If we are in install, try to use the updated version, when available - if (defined('IN_INSTALL')) - { - $install_language_path = str_replace('language/', 'install/update/new/language/', $language_file_path); - if (file_exists($install_language_path)) - { - return $install_language_path; - } - } - - if (file_exists($language_file_path)) - { - return $language_file_path; - } - } - - // The language file is not exist - throw new language_file_not_found('Language file ' . $language_file_path . ' couldn\'t be opened.'); - } - - /** - * Loads language file - * - * @param string $path Path to language file to load - * @param array $lang Reference of the array of language strings - */ - protected function load_language_file($path, &$lang) - { - // Do not suppress error if in DEBUG mode - if (defined('DEBUG')) - { - include $path; - } - else - { - @include $path; - } - } -} diff --git a/install/update/new/phpbb/lock/db.php b/install/update/new/phpbb/lock/db.php deleted file mode 100644 index eea919f..0000000 --- a/install/update/new/phpbb/lock/db.php +++ /dev/null @@ -1,153 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\lock; - -/** -* Database locking class -*/ -class db -{ - /** - * Name of the config variable this lock uses - * @var string - */ - private $config_name; - - /** - * Unique identifier for this lock. - * - * @var string - */ - private $unique_id; - - /** - * Stores the state of this lock - * @var bool - */ - private $locked; - - /** - * The phpBB configuration - * @var \phpbb\config\config - */ - private $config; - - /** - * A database connection - * @var \phpbb\db\driver\driver_interface - */ - private $db; - - /** - * Creates a named released instance of the lock. - * - * You have to call acquire() to actually create the lock. - * - * @param string $config_name A config variable to be used for locking - * @param \phpbb\config\config $config The phpBB configuration - * @param \phpbb\db\driver\driver_interface $db A database connection - */ - public function __construct($config_name, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db) - { - $this->config_name = $config_name; - $this->config = $config; - $this->db = $db; - } - - /** - * Tries to acquire the lock by updating - * the configuration variable in the database. - * - * As a lock may only be held by one process at a time, lock - * acquisition may fail if another process is holding the lock - * or if another process obtained the lock but never released it. - * Locks are forcibly released after a timeout of 1 hour. - * - * @return bool true if lock was acquired - * false otherwise - */ - public function acquire() - { - if ($this->locked) - { - return false; - } - - if (!isset($this->config[$this->config_name])) - { - $this->config->set($this->config_name, '0', false); - } - $lock_value = $this->config[$this->config_name]; - - // make sure lock cannot be acquired by multiple processes - if ($lock_value) - { - // if the other process is running more than an hour already we have to assume it - // aborted without cleaning the lock - $time = explode(' ', $lock_value); - $time = $time[0]; - - if ($time + 3600 >= time()) - { - return false; - } - } - - $this->unique_id = time() . ' ' . unique_id(); - - // try to update the config value, if it was already modified by another - // process we failed to acquire the lock. - $this->locked = $this->config->set_atomic($this->config_name, $lock_value, $this->unique_id, false); - - if ($this->locked == true) - { - if ($this->config->ensure_lock($this->config_name, $this->unique_id)) - { - return true; - } - } - return $this->locked; - } - - /** - * Does this process own the lock? - * - * @return bool true if lock is owned - * false otherwise - */ - public function owns_lock() - { - return (bool) $this->locked; - } - - /** - * Releases the lock. - * - * The lock must have been previously obtained, that is, acquire() call - * was issued and returned true. - * - * Note: Attempting to release a lock that is already released, - * that is, calling release() multiple times, is harmless. - * - * @return null - */ - public function release() - { - if ($this->locked) - { - $this->config->set_atomic($this->config_name, $this->unique_id, '0', false); - $this->locked = false; - } - } -} diff --git a/install/update/new/phpbb/lock/flock.php b/install/update/new/phpbb/lock/flock.php deleted file mode 100644 index af051af..0000000 --- a/install/update/new/phpbb/lock/flock.php +++ /dev/null @@ -1,144 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\lock; - -/** -* File locking class -*/ -class flock -{ - /** - * Path to the file to which access is controlled - * - * @var string - */ - private $path; - - /** - * File pointer for the lock file - * @var string - */ - private $lock_fp; - - /** - * Constructor. - * - * You have to call acquire() to actually acquire the lock. - * - * @param string $path Path to the file to which access is controlled - */ - public function __construct($path) - { - $this->path = $path; - $this->lock_fp = null; - } - - /** - * Tries to acquire the lock. - * - * If the lock is already held by another process, this call will block - * until the other process releases the lock. If a lock is acquired and - * is not released before script finishes but the process continues to - * live (apache/fastcgi) then subsequent processes trying to acquire - * the same lock will be blocked forever. - * - * If the lock is already held by the same process via another instance - * of this class, this call will block forever. - * - * If flock function is disabled in php or fails to work, lock - * acquisition will fail and false will be returned. - * - * @return bool true if lock was acquired - * false otherwise - */ - public function acquire() - { - if ($this->lock_fp) - { - return false; - } - - // For systems that can't have two processes opening - // one file for writing simultaneously - if (file_exists($this->path . '.lock')) - { - $mode = 'rb'; - } - else - { - $mode = 'wb'; - } - - $this->lock_fp = @fopen($this->path . '.lock', $mode); - - if ($mode == 'wb') - { - if (!$this->lock_fp) - { - // Two processes may attempt to create lock file at the same time. - // Have the losing process try opening the lock file again for reading - // on the assumption that the winning process created it - $mode = 'rb'; - $this->lock_fp = @fopen($this->path . '.lock', $mode); - } - else - { - // Only need to set mode when the lock file is written - @chmod($this->path . '.lock', 0666); - } - } - - if ($this->lock_fp) - { - if (!@flock($this->lock_fp, LOCK_EX)) - { - throw new \phpbb\exception\http_exception(500, 'Failure while aqcuiring locks.'); - } - } - - return (bool) $this->lock_fp; - } - - /** - * Does this process own the lock? - * - * @return bool true if lock is owned - * false otherwise - */ - public function owns_lock() - { - return (bool) $this->lock_fp; - } - - /** - * Releases the lock. - * - * The lock must have been previously obtained, that is, acquire() call - * was issued and returned true. - * - * Note: Attempting to release a lock that is already released, - * that is, calling release() multiple times, is harmless. - * - * @return null - */ - public function release() - { - if ($this->lock_fp) - { - @flock($this->lock_fp, LOCK_UN); - fclose($this->lock_fp); - $this->lock_fp = null; - } - } -} diff --git a/install/update/new/phpbb/message/form.php b/install/update/new/phpbb/message/form.php deleted file mode 100644 index 6573a04..0000000 --- a/install/update/new/phpbb/message/form.php +++ /dev/null @@ -1,175 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\message; - -/** -* Abstract class form -*/ -abstract class form -{ - /** @var \phpbb\auth\auth */ - protected $auth; - /** @var \phpbb\config\config */ - protected $config; - /** @var \phpbb\db\driver\driver_interface */ - protected $db; - /** @var \phpbb\message\message */ - protected $message; - /** @var \phpbb\user */ - protected $user; - - /** @var string */ - protected $phpbb_root_path; - /** @var string */ - protected $phpEx; - - /** @var array */ - protected $errors = array(); - /** @var bool */ - protected $cc_sender; - /** @var string */ - protected $body; - - /** - * Construct - * - * @param \phpbb\auth\auth $auth - * @param \phpbb\config\config $config - * @param \phpbb\db\driver\driver_interface $db - * @param \phpbb\user $user - * @param string $phpbb_root_path - * @param string $phpEx - */ - public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\user $user, $phpbb_root_path, $phpEx) - { - $this->phpbb_root_path = $phpbb_root_path; - $this->phpEx = $phpEx; - $this->user = $user; - $this->auth = $auth; - $this->config = $config; - $this->db = $db; - - $this->message = new message($config['server_name']); - $this->message->set_sender_from_user($this->user); - } - - /** - * Returns the title for the email form page - * - * @return string - */ - public function get_page_title() - { - return $this->user->lang['SEND_EMAIL']; - } - - /** - * Returns the file name of the form template - * - * @return string - */ - public function get_template_file() - { - return 'memberlist_email.html'; - } - - /** - * Checks whether the user is allowed to use the form - * - * @return false|string Error string if not allowed, false otherwise - */ - public function check_allow() - { - if (!$this->config['email_enable']) - { - return 'EMAIL_DISABLED'; - } - - if (time() - $this->user->data['user_emailtime'] < $this->config['flood_interval']) - { - return 'FLOOD_EMAIL_LIMIT'; - } - - return false; - } - - /** - * Get the return link after the message has been sent - * - * @return string - */ - public function get_return_message() - { - return sprintf($this->user->lang['RETURN_INDEX'], '', ''); - } - - /** - * Bind the values of the request to the form - * - * @param \phpbb\request\request_interface $request - * @return null - */ - public function bind(\phpbb\request\request_interface $request) - { - $this->cc_sender = $request->is_set_post('cc_sender'); - $this->body = $request->variable('message', '', true); - } - - /** - * Submit form, generate the email and send it - * - * @param \messenger $messenger - * @return null - */ - public function submit(\messenger $messenger) - { - if (!check_form_key('memberlist_email')) - { - $this->errors[] = $this->user->lang('FORM_INVALID'); - } - - if (!count($this->errors)) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_emailtime = ' . time() . ' - WHERE user_id = ' . $this->user->data['user_id']; - $this->db->sql_query($sql); - - if ($this->cc_sender && $this->user->data['is_registered']) - { - $this->message->cc_sender(); - } - - $this->message->send($messenger, phpbb_get_board_contact($this->config, $this->phpEx)); - - meta_refresh(3, append_sid($this->phpbb_root_path . 'index.' . $this->phpEx)); - trigger_error($this->user->lang['EMAIL_SENT'] . '

' . $this->get_return_message()); - } - } - - /** - * Render the template of the form - * - * @param \phpbb\template\template $template - * @return null - */ - public function render(\phpbb\template\template $template) - { - add_form_key('memberlist_email'); - - $template->assign_vars(array( - 'ERROR_MESSAGE' => (count($this->errors)) ? implode('
', $this->errors) : '', - )); - } -} diff --git a/install/update/new/phpbb/mimetype/guesser.php b/install/update/new/phpbb/mimetype/guesser.php deleted file mode 100644 index f8cbffe..0000000 --- a/install/update/new/phpbb/mimetype/guesser.php +++ /dev/null @@ -1,156 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\mimetype; - -class guesser -{ - /** - * @const Default priority for mimetype guessers - */ - const PRIORITY_DEFAULT = 0; - - /** - * @var array guessers - */ - protected $guessers; - - /** - * Construct a mimetype guesser object - * - * @param array $mimetype_guessers Mimetype guesser service collection - */ - public function __construct($mimetype_guessers) - { - $this->register_guessers($mimetype_guessers); - } - - /** - * Register MimeTypeGuessers and sort them by priority - * - * @param array $mimetype_guessers Mimetype guesser service collection - * - * @throws \LogicException If incorrect or not mimetype guessers have - * been supplied to class - */ - protected function register_guessers($mimetype_guessers) - { - foreach ($mimetype_guessers as $guesser) - { - $is_supported = (method_exists($guesser, 'is_supported')) ? 'is_supported' : ''; - $is_supported = (method_exists($guesser, 'isSupported')) ? 'isSupported' : $is_supported; - - if (empty($is_supported)) - { - throw new \LogicException('Incorrect mimetype guesser supplied.'); - } - - if ($guesser->$is_supported()) - { - $this->guessers[] = $guesser; - } - } - - if (empty($this->guessers)) - { - throw new \LogicException('No mimetype guesser supplied.'); - } - - // Sort guessers by priority - usort($this->guessers, array($this, 'sort_priority')); - } - - /** - * Sort the priority of supplied guessers - * This is a compare function for usort. A guesser with higher priority - * should be used first and vice versa. usort() orders the array values - * from low to high depending on what the comparison function returns - * to it. Return value should be smaller than 0 if value a is smaller - * than value b. This has been reversed in the comparison function in - * order to sort the guessers from high to low. - * Method has been set to public in order to allow proper testing. - * - * @param object $guesser_a Mimetype guesser a - * @param object $guesser_b Mimetype guesser b - * - * @return int If both guessers have the same priority 0, bigger - * than 0 if first guesser has lower priority, and lower - * than 0 if first guesser has higher priority - */ - public function sort_priority($guesser_a, $guesser_b) - { - $priority_a = (int) (method_exists($guesser_a, 'get_priority')) ? $guesser_a->get_priority() : self::PRIORITY_DEFAULT; - $priority_b = (int) (method_exists($guesser_b, 'get_priority')) ? $guesser_b->get_priority() : self::PRIORITY_DEFAULT; - - return $priority_b - $priority_a; - } - - /** - * Guess mimetype of supplied file - * - * @param string $file Path to file - * @param string $file_name The real file name - * - * @return string Guess for mimetype of file - */ - public function guess($file, $file_name = '') - { - if (!is_file($file)) - { - return false; - } - - if (!is_readable($file)) - { - return false; - } - - $mimetype = 'application/octet-stream'; - - foreach ($this->guessers as $guesser) - { - $mimetype_guess = $guesser->guess($file, $file_name); - - $mimetype = $this->choose_mime_type($mimetype, $mimetype_guess); - } - // Return any mimetype if we got a result or the fallback value - return $mimetype; - } - - /** - * Choose the best mime type based on the current mime type and the guess - * If a guesser returns nulls or application/octet-stream, we will keep - * the current guess. Guesses with a slash inside them will be favored over - * already existing ones. However, any guess that will pass the first check - * will always overwrite the default application/octet-stream. - * - * @param string $mime_type The current mime type - * @param string $guess The current mime type guess - * - * @return string The best mime type based on current mime type and guess - */ - public function choose_mime_type($mime_type, $guess) - { - if ($guess === null || $guess == 'application/octet-stream') - { - return $mime_type; - } - - if ($mime_type == 'application/octet-stream' || strpos($guess, '/') !== false) - { - $mime_type = $guess; - } - - return $mime_type; - } -} diff --git a/install/update/new/phpbb/notification/type/approve_post.php b/install/update/new/phpbb/notification/type/approve_post.php deleted file mode 100644 index 139b5fa..0000000 --- a/install/update/new/phpbb/notification/type/approve_post.php +++ /dev/null @@ -1,146 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\notification\type; - -/** -* Post approved notifications class -* This class handles notifications for posts when they are approved (to their authors) -*/ - -class approve_post extends \phpbb\notification\type\post -{ - /** - * Get notification type name - * - * @return string - */ - public function get_type() - { - return 'notification.type.approve_post'; - } - - /** - * Language key used to output the text - * - * @var string - */ - protected $language_key = 'NOTIFICATION_POST_APPROVED'; - - /** - * Inherit notification read status from post. - * - * @var bool - */ - protected $inherit_read_status = false; - - /** - * Notification option data (for outputting to the user) - * - * @var bool|array False if the service should use it's default data - * Array of data (including keys 'id', 'lang', and 'group') - */ - static public $notification_option = array( - 'id' => 'moderation_queue', - 'lang' => 'NOTIFICATION_TYPE_MODERATION_QUEUE', - 'group' => 'NOTIFICATION_GROUP_POSTING', - ); - - /** - * Is available - */ - public function is_available() - { - return !$this->auth->acl_get('m_approve'); - } - - /** - * Find the users who want to receive notifications - * - * @param array $post Data from submit_post - * @param array $options Options for finding users for notification - * - * @return array - */ - public function find_users_for_notification($post, $options = array()) - { - $options = array_merge(array( - 'ignore_users' => array(), - ), $options); - - return $this->get_authorised_recipients(array($post['poster_id']), $post['forum_id'], array_merge($options, array( - 'item_type' => static::$notification_option['id'], - ))); - } - - /** - * Pre create insert array function - * This allows you to perform certain actions, like run a query - * and load data, before create_insert_array() is run. The data - * returned from this function will be sent to create_insert_array(). - * - * @param array $post Post data from submit_post - * @param array $notify_users Notify users list - * Formatted from find_users_for_notification() - * @return array Whatever you want to send to create_insert_array(). - */ - public function pre_create_insert_array($post, $notify_users) - { - // In the parent class, this is used to check if the post is already - // read by a user and marks the notification read if it was marked read. - // Returning an empty array in effect, forces it to be marked as unread - // (and also saves a query) - return array(); - } - - /** - * {@inheritdoc} - */ - public function create_insert_array($post, $pre_create_data = array()) - { - $this->set_data('post_subject', $post['post_subject']); - - parent::create_insert_array($post, $pre_create_data); - - $this->notification_time = time(); - } - - /** - * {@inheritdoc} - */ - public function get_insert_array() - { - $data = parent::get_insert_array(); - $data['notification_time'] = $this->notification_time; - - return $data; - } - - /** - * Get email template - * - * @return string|bool - */ - public function get_email_template() - { - return 'post_approved'; - } - - /** - * {inheritDoc} - */ - public function get_redirect_url() - { - return $this->get_url(); - } -} diff --git a/install/update/new/phpbb/notification/type/approve_topic.php b/install/update/new/phpbb/notification/type/approve_topic.php deleted file mode 100644 index 0c34364..0000000 --- a/install/update/new/phpbb/notification/type/approve_topic.php +++ /dev/null @@ -1,137 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\notification\type; - -/** -* Topic approved notifications class -* This class handles notifications for topics when they are approved (for authors) -*/ - -class approve_topic extends \phpbb\notification\type\topic -{ - /** - * Get notification type name - * - * @return string - */ - public function get_type() - { - return 'notification.type.approve_topic'; - } - - /** - * Language key used to output the text - * - * @var string - */ - protected $language_key = 'NOTIFICATION_TOPIC_APPROVED'; - - /** - * Inherit notification read status from topic. - * - * @var bool - */ - protected $inherit_read_status = false; - - /** - * Notification option data (for outputting to the user) - * - * @var bool|array False if the service should use it's default data - * Array of data (including keys 'id', 'lang', and 'group') - */ - static public $notification_option = array( - 'id' => 'moderation_queue', - 'lang' => 'NOTIFICATION_TYPE_MODERATION_QUEUE', - 'group' => 'NOTIFICATION_GROUP_POSTING', - ); - - /** - * Is available - */ - public function is_available() - { - return !$this->auth->acl_get('m_approve'); - } - - /** - * Find the users who want to receive notifications - * - * @param array $post Data from submit_post - * @param array $options Options for finding users for notification - * - * @return array - */ - public function find_users_for_notification($post, $options = array()) - { - $options = array_merge(array( - 'ignore_users' => array(), - ), $options); - - return $this->get_authorised_recipients(array($post['poster_id']), $post['forum_id'], array_merge($options, array( - 'item_type' => static::$notification_option['id'], - ))); - } - - /** - * Pre create insert array function - * This allows you to perform certain actions, like run a query - * and load data, before create_insert_array() is run. The data - * returned from this function will be sent to create_insert_array(). - * - * @param array $post Post data from submit_post - * @param array $notify_users Notify users list - * Formatted from find_users_for_notification() - * @return array Whatever you want to send to create_insert_array(). - */ - public function pre_create_insert_array($post, $notify_users) - { - // In the parent class, this is used to check if the post is already - // read by a user and marks the notification read if it was marked read. - // Returning an empty array in effect, forces it to be marked as unread - // (and also saves a query) - return array(); - } - - /** - * {@inheritdoc} - */ - public function create_insert_array($post, $pre_create_data = array()) - { - - parent::create_insert_array($post, $pre_create_data); - - $this->notification_time = time(); - } - - /** - * {@inheritdoc} - */ - public function get_insert_array() - { - $data = parent::get_insert_array(); - $data['notification_time'] = $this->notification_time; - - return $data; - } - - /** - * Get email template - * - * @return string|bool - */ - public function get_email_template() - { - return 'topic_approved'; - } -} diff --git a/install/update/new/phpbb/notification/type/base.php b/install/update/new/phpbb/notification/type/base.php deleted file mode 100644 index e4600ad..0000000 --- a/install/update/new/phpbb/notification/type/base.php +++ /dev/null @@ -1,577 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\notification\type; - -/** -* Base notifications class -*/ -abstract class base implements \phpbb\notification\type\type_interface -{ - /** @var \phpbb\notification\manager */ - protected $notification_manager; - - /** @var \phpbb\db\driver\driver_interface */ - protected $db; - - /** @var \phpbb\language\language */ - protected $language; - - /** @var \phpbb\user */ - protected $user; - - /** @var \phpbb\auth\auth */ - protected $auth; - - /** @var string */ - protected $phpbb_root_path; - - /** @var string */ - protected $php_ext; - - /** @var string */ - protected $user_notifications_table; - - /** - * Notification option data (for outputting to the user) - * - * @var bool|array False if the service should use its default data - * Array of data (including keys 'id', 'lang', and 'group') - */ - static public $notification_option = false; - - /** - * The notification_type_id, set upon creation of the class - * This is the notification_type_id from the notification_types table - * - * @var int - */ - protected $notification_type_id; - - /** - * Identification data - * notification_type_id - ID of the item type (auto generated, from notification types table) - * item_id - ID of the item (e.g. post_id, msg_id) - * item_parent_id - Parent item id (ex: for topic => forum_id, for post => topic_id, etc) - * user_id - * notification_read - * notification_time - * notification_data (special serialized field that each notification type can use to store stuff) - * - * @var array $data Notification row from the database - * This must be private, all interaction should use __get(), __set(), get_data(), set_data() - */ - private $data = array(); - - /** - * Notification Type Base Constructor - * - * @param \phpbb\db\driver\driver_interface $db - * @param \phpbb\language\language $language - * @param \phpbb\user $user - * @param \phpbb\auth\auth $auth - * @param string $phpbb_root_path - * @param string $php_ext - * @param string $user_notifications_table - */ - public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\language\language $language, \phpbb\user $user, \phpbb\auth\auth $auth, $phpbb_root_path, $php_ext, $user_notifications_table) - { - $this->db = $db; - $this->language = $language; - $this->user = $user; - $this->auth = $auth; - - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - - $this->user_notifications_table = $user_notifications_table; - } - - /** - * Set notification manager (required) - * - * @param \phpbb\notification\manager $notification_manager - */ - public function set_notification_manager(\phpbb\notification\manager $notification_manager) - { - $this->notification_manager = $notification_manager; - - $this->notification_type_id = $this->notification_manager->get_notification_type_id($this->get_type()); - } - - /** - * Set initial data from the database - * - * @param array $data Row directly from the database - */ - public function set_initial_data($data = array()) - { - // The row from the database (unless this is a new notification we're going to add) - $this->data = $data; - $this->data['notification_data'] = (isset($this->data['notification_data'])) ? unserialize($this->data['notification_data']) : array(); - } - - /** - * Magic method to get data from this notification - * - * @param mixed $name - * @return mixed - */ - public function __get($name) - { - return (!isset($this->data[$name])) ? null : $this->data[$name]; - } - - - /** - * Magic method to set data on this notification - * - * @param mixed $name - * @param mixed $value - * - * @return null - */ - public function __set($name, $value) - { - $this->data[$name] = $value; - } - - - /** - * Magic method to get a string of this notification - * - * Primarily for testing - * - * @return mixed - */ - public function __toString() - { - return (!empty($this->data)) ? var_export($this->data, true) : $this->get_type(); - } - - /** - * Get special data (only important for the classes that extend this) - * - * @param string $name Name of the variable to get - * @return mixed - */ - protected function get_data($name) - { - return ($name === false) ? $this->data['notification_data'] : ((isset($this->data['notification_data'][$name])) ? $this->data['notification_data'][$name] : null); - } - - /** - * Set special data (only important for the classes that extend this) - * - * @param string $name Name of the variable to set - * @param mixed $value Value to set to the variable - * @return mixed - */ - protected function set_data($name, $value) - { - $this->data['notification_data'][$name] = $value; - } - - /** - * {@inheritdoc} - */ - public function create_insert_array($type_data, $pre_create_data = array()) - { - // Defaults - $this->data = array_merge(array( - 'item_id' => static::get_item_id($type_data), - 'notification_type_id' => $this->notification_type_id, - 'item_parent_id' => static::get_item_parent_id($type_data), - - 'notification_time' => time(), - 'notification_read' => false, - - 'notification_data' => array(), - ), $this->data); - } - - /** - * {@inheritdoc} - */ - public function get_insert_array() - { - $data = $this->data; - - $data['notification_data'] = serialize($data['notification_data']); - - return $data; - } - - /** - * Function for preparing the data for update in an SQL query - * (The service handles insertion) - * - * @param array $type_data Data unique to this notification type - * @return array Array of data ready to be updated in the database - */ - public function create_update_array($type_data) - { - $this->create_insert_array($type_data); - $data = $this->get_insert_array(); - - // Unset data unique to each row - unset( - $data['notification_time'], // Also unsetting time, since it always tries to change the time to current (if you actually need to change the time, over-ride this function) - $data['notification_id'], - $data['notification_read'], - $data['user_id'] - ); - - return $data; - } - - /** - * Mark this item read - * - * @param bool $return True to return a string containing the SQL code to update this item, False to execute it (Default: False) - * @return string|null If $return is False, nothing will be returned, else the sql code to update this item - */ - public function mark_read($return = false) - { - return $this->mark(false, $return); - } - - /** - * Mark this item unread - * - * @param bool $return True to return a string containing the SQL code to update this item, False to execute it (Default: False) - * @return string|null If $return is False, nothing will be returned, else the sql code to update this item - */ - public function mark_unread($return = false) - { - return $this->mark(true, $return); - } - - /** - * {inheritDoc} - */ - public function get_redirect_url() - { - return $this->get_url(); - } - - /** - * Prepare to output the notification to the template - * - * @return array Template variables - */ - public function prepare_for_display() - { - $mark_hash = generate_link_hash('mark_notification_read'); - - if ($this->get_url()) - { - $u_mark_read = append_sid($this->phpbb_root_path . 'index.' . $this->php_ext, 'mark_notification=' . $this->notification_id . '&hash=' . $mark_hash); - } - else - { - $redirect = (($this->user->page['page_dir']) ? $this->user->page['page_dir'] . '/' : '') . $this->user->page['page_name'] . (($this->user->page['query_string']) ? '?' . $this->user->page['query_string'] : ''); - - $u_mark_read = append_sid($this->phpbb_root_path . 'index.' . $this->php_ext, 'mark_notification=' . $this->notification_id . '&hash=' . $mark_hash . '&redirect=' . urlencode($redirect)); - } - - return array( - 'NOTIFICATION_ID' => $this->notification_id, - 'STYLING' => $this->get_style_class(), - 'AVATAR' => $this->get_avatar(), - 'FORMATTED_TITLE' => $this->get_title(), - 'REFERENCE' => $this->get_reference(), - 'FORUM' => $this->get_forum(), - 'REASON' => $this->get_reason(), - 'URL' => $this->get_url(), - 'TIME' => $this->user->format_date($this->notification_time), - 'UNREAD' => !$this->notification_read, - 'U_MARK_READ' => (!$this->notification_read) ? $u_mark_read : '', - ); - } - - /** - * -------------- Fall back functions ------------------- - */ - - /** - * URL to unsubscribe to this notification (fall back) - * - * @param string|bool $method Method name to unsubscribe from (email|jabber|etc), False to unsubscribe from all notifications for this item - * @return false - */ - public function get_unsubscribe_url($method = false) - { - return false; - } - - /** - * Get the CSS style class of the notification (fall back) - * - * @return string - */ - public function get_style_class() - { - return ''; - } - - /** - * Get the user's avatar (fall back) - * - * @return string - */ - public function get_avatar() - { - return ''; - } - - /** - * Get the reference of the notification (fall back) - * - * @return string - */ - public function get_reference() - { - return ''; - } - - /** - * Get the forum of the notification reference (fall back) - * - * @return string - */ - public function get_forum() - { - return ''; - } - - /** - * Get the reason for the notification (fall back) - * - * @return string - */ - public function get_reason() - { - return ''; - } - - /** - * Get the special items to load (fall back) - * - * @return array - */ - public function get_load_special() - { - return array(); - } - - /** - * Load the special items (fall back) - * - * @param array $data - * @param array $notifications - */ - public function load_special($data, $notifications) - { - return; - } - - /** - * Is available (fall back) - * - * @return bool - */ - public function is_available() - { - return true; - } - - /** - * Pre create insert array function (fall back) - * - * @param array $type_data - * @param array $notify_users - * @return array - */ - public function pre_create_insert_array($type_data, $notify_users) - { - return array(); - } - - /** - * -------------- Helper functions ------------------- - */ - - /** - * Find the users who want to receive notifications (helper) - * - * @param array|bool $user_ids User IDs to check if they want to receive notifications - * (Bool False to check all users besides anonymous and bots (USER_IGNORE)) - * @param array $options - * @return array - */ - protected function check_user_notification_options($user_ids = false, $options = array()) - { - $options = array_merge(array( - 'ignore_users' => array(), - 'item_type' => $this->get_type(), - 'item_id' => 0, // Global by default - ), $options); - - if ($user_ids === false) - { - $user_ids = array(); - - $sql = 'SELECT user_id - FROM ' . USERS_TABLE . ' - WHERE user_id <> ' . ANONYMOUS . ' - AND user_type <> ' . USER_IGNORE; - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - $user_ids[] = $row['user_id']; - } - $this->db->sql_freeresult($result); - } - - if (empty($user_ids)) - { - return array(); - } - - $rowset = $output = array(); - - $sql = 'SELECT user_id, method, notify - FROM ' . $this->user_notifications_table . ' - WHERE ' . $this->db->sql_in_set('user_id', $user_ids) . " - AND item_type = '" . $this->db->sql_escape($options['item_type']) . "' - AND item_id = " . (int) $options['item_id']; - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - if (isset($options['ignore_users'][$row['user_id']]) && in_array($row['method'], $options['ignore_users'][$row['user_id']])) - { - continue; - } - - if (!isset($rowset[$row['user_id']])) - { - $rowset[$row['user_id']] = array(); - } - $rowset[$row['user_id']][$row['method']] = $row['notify']; - - if (!isset($output[$row['user_id']])) - { - $output[$row['user_id']] = array(); - } - if ($row['notify']) - { - $output[$row['user_id']][] = $row['method']; - } - } - - $this->db->sql_freeresult($result); - - $default_methods = $this->notification_manager->get_default_methods(); - - foreach ($user_ids as $user_id) - { - if (isset($options['ignore_users'][$user_id])) - { - continue; - } - if (!array_key_exists($user_id, $rowset)) - { - // No rows at all for this user, use the default methods - $output[$user_id] = $default_methods; - } - else - { - foreach ($default_methods as $default_method) - { - if (!array_key_exists($default_method, $rowset[$user_id])) - { - // No user preference for this type recorded, but it should be enabled by default. - $output[$user_id][] = $default_method; - } - } - } - } - - return $output; - } - - /** - * Mark this item read/unread helper - * - * @param bool $unread Unread (True/False) (Default: False) - * @param bool $return True to return a string containing the SQL code to update this item, False to execute it (Default: False) - * @return string|null If $return is False, nothing will be returned, else the sql code to update this item - */ - protected function mark($unread = true, $return = false) - { - $this->notification_read = (bool) !$unread; - - if ($return) - { - $where = array( - 'notification_type_id = ' . (int) $this->notification_type_id, - 'item_id = ' . (int) $this->item_id, - 'user_id = ' . (int) $this->user_id, - ); - - $where = implode(' AND ', $where); - return $where; - } - else - { - $this->notification_manager->mark_notifications($this->get_type(), (int) $this->item_id, (int) $this->user_id, false, $this->notification_read); - } - - return null; - } - - /** - * Get a list of users that are authorised to receive notifications - * - * @param array $users Array of users that have subscribed to a notification - * @param int $forum_id Forum ID of the forum - * @param array $options Array of notification options - * @param bool $sort Whether the users array should be sorted. Default: false - * @return array Array of users that are authorised recipients - */ - protected function get_authorised_recipients($users, $forum_id, $options, $sort = false) - { - if (empty($users)) - { - return array(); - } - - $users = array_unique($users); - - if ($sort) - { - sort($users); - } - - $auth_read = $this->auth->acl_get_list($users, 'f_read', $forum_id); - - if (empty($auth_read)) - { - return array(); - } - - return $this->check_user_notification_options($auth_read[$forum_id]['f_read'], $options); - } -} diff --git a/install/update/new/phpbb/notification/type/post.php b/install/update/new/phpbb/notification/type/post.php deleted file mode 100644 index f0e938d..0000000 --- a/install/update/new/phpbb/notification/type/post.php +++ /dev/null @@ -1,467 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\notification\type; - -/** -* Post notifications class -* This class handles notifications for replies to a topic -*/ - -class post extends \phpbb\notification\type\base -{ - /** - * Get notification type name - * - * @return string - */ - public function get_type() - { - return 'notification.type.post'; - } - - /** - * Language key used to output the text - * - * @var string - */ - protected $language_key = 'NOTIFICATION_POST'; - - /** - * Inherit notification read status from post. - * - * @var bool - */ - protected $inherit_read_status = true; - - /** - * Notification option data (for outputting to the user) - * - * @var bool|array False if the service should use it's default data - * Array of data (including keys 'id', 'lang', and 'group') - */ - static public $notification_option = array( - 'lang' => 'NOTIFICATION_TYPE_POST', - 'group' => 'NOTIFICATION_GROUP_POSTING', - ); - - /** @var \phpbb\user_loader */ - protected $user_loader; - - /** @var \phpbb\config\config */ - protected $config; - - public function set_config(\phpbb\config\config $config) - { - $this->config = $config; - } - - public function set_user_loader(\phpbb\user_loader $user_loader) - { - $this->user_loader = $user_loader; - } - - /** - * Is available - */ - public function is_available() - { - return $this->config['allow_topic_notify']; - } - - /** - * Get the id of the item - * - * @param array $post The data from the post - * @return int The post id - */ - static public function get_item_id($post) - { - return (int) $post['post_id']; - } - - /** - * Get the id of the parent - * - * @param array $post The data from the post - * @return int The topic id - */ - static public function get_item_parent_id($post) - { - return (int) $post['topic_id']; - } - - /** - * Find the users who want to receive notifications - * - * @param array $post Data from submit_post - * @param array $options Options for finding users for notification - * - * @return array - */ - public function find_users_for_notification($post, $options = array()) - { - $options = array_merge(array( - 'ignore_users' => array(), - ), $options); - - $users = array(); - - $sql = 'SELECT user_id - FROM ' . TOPICS_WATCH_TABLE . ' - WHERE topic_id = ' . (int) $post['topic_id'] . ' - AND notify_status = ' . NOTIFY_YES . ' - AND user_id <> ' . (int) $post['poster_id']; - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - $users[] = (int) $row['user_id']; - } - $this->db->sql_freeresult($result); - - $sql = 'SELECT user_id - FROM ' . FORUMS_WATCH_TABLE . ' - WHERE forum_id = ' . (int) $post['forum_id'] . ' - AND notify_status = ' . NOTIFY_YES . ' - AND user_id <> ' . (int) $post['poster_id']; - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - $users[] = (int) $row['user_id']; - } - $this->db->sql_freeresult($result); - - $notify_users = $this->get_authorised_recipients($users, $post['forum_id'], $options, true); - - if (empty($notify_users)) - { - return array(); - } - - // Try to find the users who already have been notified about replies and have not read the topic since and just update their notifications - $notified_users = $this->notification_manager->get_notified_users($this->get_type(), array( - 'item_parent_id' => static::get_item_parent_id($post), - 'read' => 0, - )); - - foreach ($notified_users as $user => $notification_data) - { - unset($notify_users[$user]); - - /** @var post $notification */ - $notification = $this->notification_manager->get_item_type_class($this->get_type(), $notification_data); - $update_responders = $notification->add_responders($post); - if (!empty($update_responders)) - { - $this->notification_manager->update_notification($notification, $update_responders, array( - 'item_parent_id' => self::get_item_parent_id($post), - 'read' => 0, - 'user_id' => $user, - )); - } - } - - return $notify_users; - } - - /** - * Get the user's avatar - */ - public function get_avatar() - { - return $this->user_loader->get_avatar($this->get_data('poster_id'), false, true); - } - - /** - * Get the HTML formatted title of this notification - * - * @return string - */ - public function get_title() - { - $responders = $this->get_data('responders'); - $usernames = array(); - - if (!is_array($responders)) - { - $responders = array(); - } - - $responders = array_merge(array(array( - 'poster_id' => $this->get_data('poster_id'), - 'username' => $this->get_data('post_username'), - )), $responders); - - $responders_cnt = count($responders); - $responders = $this->trim_user_ary($responders); - $trimmed_responders_cnt = $responders_cnt - count($responders); - - foreach ($responders as $responder) - { - if ($responder['username']) - { - $usernames[] = $responder['username']; - } - else - { - $usernames[] = $this->user_loader->get_username($responder['poster_id'], 'no_profile'); - } - } - - if ($trimmed_responders_cnt > 20) - { - $usernames[] = $this->language->lang('NOTIFICATION_MANY_OTHERS'); - } - else if ($trimmed_responders_cnt) - { - $usernames[] = $this->language->lang('NOTIFICATION_X_OTHERS', $trimmed_responders_cnt); - } - - return $this->language->lang( - $this->language_key, - phpbb_generate_string_list($usernames, $this->user), - $responders_cnt - ); - } - - /** - * Get the HTML formatted reference of the notification - * - * @return string - */ - public function get_reference() - { - return $this->language->lang( - 'NOTIFICATION_REFERENCE', - censor_text($this->get_data('topic_title')) - ); - } - - /** - * Get email template - * - * @return string|bool - */ - public function get_email_template() - { - return 'topic_notify'; - } - - /** - * Get email template variables - * - * @return array - */ - public function get_email_template_variables() - { - if ($this->get_data('post_username')) - { - $username = $this->get_data('post_username'); - } - else - { - $username = $this->user_loader->get_username($this->get_data('poster_id'), 'username'); - } - - return array( - 'AUTHOR_NAME' => htmlspecialchars_decode($username), - 'POST_SUBJECT' => htmlspecialchars_decode(censor_text($this->get_data('post_subject'))), - 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($this->get_data('topic_title'))), - - 'U_VIEW_POST' => generate_board_url() . "/viewtopic.{$this->php_ext}?p={$this->item_id}#p{$this->item_id}", - 'U_NEWEST_POST' => generate_board_url() . "/viewtopic.{$this->php_ext}?f={$this->get_data('forum_id')}&t={$this->item_parent_id}&e=1&view=unread#unread", - 'U_TOPIC' => generate_board_url() . "/viewtopic.{$this->php_ext}?f={$this->get_data('forum_id')}&t={$this->item_parent_id}", - 'U_VIEW_TOPIC' => generate_board_url() . "/viewtopic.{$this->php_ext}?f={$this->get_data('forum_id')}&t={$this->item_parent_id}", - 'U_FORUM' => generate_board_url() . "/viewforum.{$this->php_ext}?f={$this->get_data('forum_id')}", - 'U_STOP_WATCHING_TOPIC' => generate_board_url() . "/viewtopic.{$this->php_ext}?uid={$this->user_id}&f={$this->get_data('forum_id')}&t={$this->item_parent_id}&unwatch=topic", - ); - } - - /** - * Get the url to this item - * - * @return string URL - */ - public function get_url() - { - return append_sid($this->phpbb_root_path . 'viewtopic.' . $this->php_ext, "p={$this->item_id}#p{$this->item_id}"); - } - - /** - * {inheritDoc} - */ - public function get_redirect_url() - { - return append_sid($this->phpbb_root_path . 'viewtopic.' . $this->php_ext, "t={$this->item_parent_id}&view=unread#unread"); - } - - /** - * Users needed to query before this notification can be displayed - * - * @return array Array of user_ids - */ - public function users_to_query() - { - $responders = $this->get_data('responders'); - $users = array( - $this->get_data('poster_id'), - ); - - if (is_array($responders)) - { - foreach ($responders as $responder) - { - $users[] = $responder['poster_id']; - } - } - - return $this->trim_user_ary($users); - } - - /** - * Trim the user array passed down to 3 users if the array contains - * more than 4 users. - * - * @param array $users Array of users - * @return array Trimmed array of user_ids - */ - public function trim_user_ary($users) - { - if (count($users) > 4) - { - array_splice($users, 3); - } - return $users; - } - - /** - * Pre create insert array function - * This allows you to perform certain actions, like run a query - * and load data, before create_insert_array() is run. The data - * returned from this function will be sent to create_insert_array(). - * - * @param array $post Post data from submit_post - * @param array $notify_users Notify users list - * Formatted from find_users_for_notification() - * @return array Whatever you want to send to create_insert_array(). - */ - public function pre_create_insert_array($post, $notify_users) - { - if (!count($notify_users) || !$this->inherit_read_status) - { - return array(); - } - - $tracking_data = array(); - $sql = 'SELECT user_id, mark_time FROM ' . TOPICS_TRACK_TABLE . ' - WHERE topic_id = ' . (int) $post['topic_id'] . ' - AND ' . $this->db->sql_in_set('user_id', array_keys($notify_users)); - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - $tracking_data[$row['user_id']] = $row['mark_time']; - } - $this->db->sql_freeresult($result); - - return $tracking_data; - } - - /** - * {@inheritdoc} - */ - public function create_insert_array($post, $pre_create_data = array()) - { - $this->set_data('poster_id', $post['poster_id']); - - $this->set_data('topic_title', $post['topic_title']); - - $this->set_data('post_subject', $post['post_subject']); - - $this->set_data('post_username', (($post['poster_id'] == ANONYMOUS) ? $post['post_username'] : '')); - - $this->set_data('forum_id', $post['forum_id']); - - $this->set_data('forum_name', $post['forum_name']); - - $this->notification_time = $post['post_time']; - - // Topics can be "read" before they are public (while awaiting approval). - // Make sure that if the user has read the topic, it's marked as read in the notification - if ($this->inherit_read_status && isset($pre_create_data[$this->user_id]) && $pre_create_data[$this->user_id] >= $this->notification_time) - { - $this->notification_read = true; - } - - parent::create_insert_array($post, $pre_create_data); - } - - /** - * Add responders to the notification - * - * @param mixed $post - * @return array Array of responder data - */ - public function add_responders($post) - { - // Do not add them as a responder if they were the original poster that created the notification - if ($this->get_data('poster_id') == $post['poster_id']) - { - return array(); - } - - $responders = $this->get_data('responders'); - - $responders = ($responders === null) ? array() : $responders; - - // Do not add more than 25 responders, - // we trim the username list to "a, b, c and x others" anyway - // so there is no use to add all of them anyway. - if (count($responders) > 25) - { - return array(); - } - - foreach ($responders as $responder) - { - // Do not add them as a responder multiple times - if ($responder['poster_id'] == $post['poster_id']) - { - return array(); - } - } - - $responders[] = array( - 'poster_id' => $post['poster_id'], - 'username' => (($post['poster_id'] == ANONYMOUS) ? $post['post_username'] : ''), - ); - - $this->set_data('responders', $responders); - - $serialized_data = serialize($this->get_data(false)); - - // If the data is longer then 4000 characters, it would cause a SQL error. - // We don't add the username to the list if this is the case. - if (utf8_strlen($serialized_data) >= 4000) - { - return array(); - } - - $data_array = array_merge(array( - 'post_time' => $post['post_time'], - 'post_id' => $post['post_id'], - 'topic_id' => $post['topic_id'] - ), $this->get_data(false)); - - return $data_array; - } -} diff --git a/install/update/new/phpbb/notification/type/topic.php b/install/update/new/phpbb/notification/type/topic.php deleted file mode 100644 index 2535cda..0000000 --- a/install/update/new/phpbb/notification/type/topic.php +++ /dev/null @@ -1,307 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\notification\type; - -/** -* Topic notifications class -* This class handles notifications for new topics -*/ - -class topic extends \phpbb\notification\type\base -{ - /** - * Get notification type name - * - * @return string - */ - public function get_type() - { - return 'notification.type.topic'; - } - - /** - * Language key used to output the text - * - * @var string - */ - protected $language_key = 'NOTIFICATION_TOPIC'; - - /** - * Inherit notification read status from topic. - * - * @var bool - */ - protected $inherit_read_status = true; - - /** - * Notification option data (for outputting to the user) - * - * @var bool|array False if the service should use it's default data - * Array of data (including keys 'id', 'lang', and 'group') - */ - static public $notification_option = array( - 'lang' => 'NOTIFICATION_TYPE_TOPIC', - 'group' => 'NOTIFICATION_GROUP_POSTING', - ); - - /** @var \phpbb\user_loader */ - protected $user_loader; - - /** @var \phpbb\config\config */ - protected $config; - - public function set_config(\phpbb\config\config $config) - { - $this->config = $config; - } - - public function set_user_loader(\phpbb\user_loader $user_loader) - { - $this->user_loader = $user_loader; - } - - /** - * Is available - */ - public function is_available() - { - return $this->config['allow_forum_notify']; - } - - /** - * Get the id of the item - * - * @param array $post The data from the post - * @return int The topic id - */ - static public function get_item_id($post) - { - return (int) $post['topic_id']; - } - - /** - * Get the id of the parent - * - * @param array $post The data from the post - * @return int The forum id - */ - static public function get_item_parent_id($post) - { - return (int) $post['forum_id']; - } - - /** - * Find the users who want to receive notifications - * - * @param array $topic Data from the topic - * @param array $options Options for finding users for notification - * - * @return array - */ - public function find_users_for_notification($topic, $options = array()) - { - $options = array_merge(array( - 'ignore_users' => array(), - ), $options); - - $users = array(); - - $sql = 'SELECT user_id - FROM ' . FORUMS_WATCH_TABLE . ' - WHERE forum_id = ' . (int) $topic['forum_id'] . ' - AND notify_status = ' . NOTIFY_YES . ' - AND user_id <> ' . (int) $topic['poster_id']; - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - $users[] = (int) $row['user_id']; - } - $this->db->sql_freeresult($result); - - return $this->get_authorised_recipients($users, $topic['forum_id'], $options); - } - - /** - * Get the user's avatar - */ - public function get_avatar() - { - return $this->user_loader->get_avatar($this->get_data('poster_id'), false, true); - } - - /** - * Get the HTML formatted title of this notification - * - * @return string - */ - public function get_title() - { - if ($this->get_data('post_username')) - { - $username = $this->get_data('post_username'); - } - else - { - $username = $this->user_loader->get_username($this->get_data('poster_id'), 'no_profile'); - } - - return $this->language->lang( - $this->language_key, - $username - ); - } - - /** - * Get the HTML formatted reference of the notification - * - * @return string - */ - public function get_reference() - { - return $this->language->lang( - 'NOTIFICATION_REFERENCE', - censor_text($this->get_data('topic_title')) - ); - } - - /** - * Get the forum of the notification reference - * - * @return string - */ - public function get_forum() - { - return $this->language->lang( - 'NOTIFICATION_FORUM', - $this->get_data('forum_name') - ); - } - - /** - * Get email template - * - * @return string|bool - */ - public function get_email_template() - { - return 'newtopic_notify'; - } - - /** - * Get email template variables - * - * @return array - */ - public function get_email_template_variables() - { - $board_url = generate_board_url(); - - if ($this->get_data('post_username')) - { - $username = $this->get_data('post_username'); - } - else - { - $username = $this->user_loader->get_username($this->get_data('poster_id'), 'username'); - } - - return array( - 'AUTHOR_NAME' => htmlspecialchars_decode($username), - 'FORUM_NAME' => htmlspecialchars_decode($this->get_data('forum_name')), - 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($this->get_data('topic_title'))), - - 'U_TOPIC' => "{$board_url}/viewtopic.{$this->php_ext}?f={$this->item_parent_id}&t={$this->item_id}", - 'U_VIEW_TOPIC' => "{$board_url}/viewtopic.{$this->php_ext}?f={$this->item_parent_id}&t={$this->item_id}", - 'U_FORUM' => "{$board_url}/viewforum.{$this->php_ext}?f={$this->item_parent_id}", - 'U_STOP_WATCHING_FORUM' => "{$board_url}/viewforum.{$this->php_ext}?uid={$this->user_id}&f={$this->item_parent_id}&unwatch=forum", - ); - } - - /** - * Get the url to this item - * - * @return string URL - */ - public function get_url() - { - return append_sid($this->phpbb_root_path . 'viewtopic.' . $this->php_ext, "f={$this->item_parent_id}&t={$this->item_id}"); - } - - /** - * Users needed to query before this notification can be displayed - * - * @return array Array of user_ids - */ - public function users_to_query() - { - return array($this->get_data('poster_id')); - } - - /** - * Pre create insert array function - * This allows you to perform certain actions, like run a query - * and load data, before create_insert_array() is run. The data - * returned from this function will be sent to create_insert_array(). - * - * @param array $post Post data from submit_post - * @param array $notify_users Notify users list - * Formatted from find_users_for_notification() - * @return array Whatever you want to send to create_insert_array(). - */ - public function pre_create_insert_array($post, $notify_users) - { - if (!count($notify_users) || !$this->inherit_read_status) - { - return array(); - } - - $tracking_data = array(); - $sql = 'SELECT user_id, mark_time FROM ' . TOPICS_TRACK_TABLE . ' - WHERE topic_id = ' . (int) $post['topic_id'] . ' - AND ' . $this->db->sql_in_set('user_id', array_keys($notify_users)); - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - $tracking_data[$row['user_id']] = $row['mark_time']; - } - $this->db->sql_freeresult($result); - - return $tracking_data; - } - - /** - * {@inheritdoc} - */ - public function create_insert_array($post, $pre_create_data = array()) - { - $this->set_data('poster_id', $post['poster_id']); - - $this->set_data('topic_title', $post['topic_title']); - - $this->set_data('post_username', (($post['poster_id'] == ANONYMOUS) ? $post['post_username'] : '')); - - $this->set_data('forum_name', $post['forum_name']); - - $this->notification_time = $post['post_time']; - - // Topics can be "read" before they are public (while awaiting approval). - // Make sure that if the user has read the topic, it's marked as read in the notification - if ($this->inherit_read_status && isset($pre_create_data[$this->user_id]) && $pre_create_data[$this->user_id] >= $this->notification_time) - { - $this->notification_read = true; - } - - parent::create_insert_array($post, $pre_create_data); - } -} diff --git a/install/update/new/phpbb/notification/type/type_interface.php b/install/update/new/phpbb/notification/type/type_interface.php deleted file mode 100644 index ed77335..0000000 --- a/install/update/new/phpbb/notification/type/type_interface.php +++ /dev/null @@ -1,218 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\notification\type; - -/** -* Base notifications interface -*/ -interface type_interface -{ - /** - * Get notification type name - * - * @return string - */ - public function get_type(); - - /** - * Set initial data from the database - * - * @param array $data Row directly from the database - */ - public function set_initial_data($data); - - /** - * Get the id of the item - * - * @param array $type_data The type specific data - */ - static public function get_item_id($type_data); - - /** - * Get the id of the parent - * - * @param array $type_data The type specific data - */ - static public function get_item_parent_id($type_data); - - /** - * Is this type available to the current user (defines whether or not it will be shown in the UCP Edit notification options) - * - * @return bool True/False whether or not this is available to the user - */ - public function is_available(); - - /** - * Find the users who want to receive notifications - * - * @param array $type_data The type specific data - * @param array $options Options for finding users for notification - * ignore_users => array of users and user types that should not receive notifications from this type because they've already been notified - * e.g.: array(2 => array(''), 3 => array('', 'email'), ...) - * - * @return array - */ - public function find_users_for_notification($type_data, $options); - - /** - * Users needed to query before this notification can be displayed - * - * @return array Array of user_ids - */ - public function users_to_query(); - - /** - * Get the special items to load - * - * @return array Data will be combined sent to load_special() so you can run a single query and get data required for this notification type - */ - public function get_load_special(); - - /** - * Load the special items - * - * @param array $data Data from get_load_special() - * @param array $notifications Array of notifications (key is notification_id, value is the notification objects) - */ - public function load_special($data, $notifications); - - /** - * Get the CSS style class of the notification - * - * @return string - */ - public function get_style_class(); - - /** - * Get the HTML formatted title of this notification - * - * @return string - */ - public function get_title(); - - /** - * Get the HTML formatted reference of the notification - * - * @return string - */ - public function get_reference(); - - /** - * Get the forum of the notification reference - * - * @return string - */ - public function get_forum(); - - /** - * Get the url to this item - * - * @return string URL - */ - public function get_url(); - - /** - * Get the url to redirect after the item has been marked as read - * - * @return string URL - */ - public function get_redirect_url(); - - /** - * URL to unsubscribe to this notification - * - * @param string|bool $method Method name to unsubscribe from (email|jabber|etc), False to unsubscribe from all notifications for this item - */ - public function get_unsubscribe_url($method); - - /** - * Get the user's avatar (the user who caused the notification typically) - * - * @return string - */ - public function get_avatar(); - - /** - * Prepare to output the notification to the template - */ - public function prepare_for_display(); - - /** - * Get email template - * - * @return string|bool - */ - public function get_email_template(); - - /** - * Get email template variables - * - * @return array - */ - public function get_email_template_variables(); - - /** - * Pre create insert array function - * This allows you to perform certain actions, like run a query - * and load data, before create_insert_array() is run. The data - * returned from this function will be sent to create_insert_array(). - * - * @param array $type_data The type specific data - * @param array $notify_users Notify users list - * Formatted from find_users_for_notification() - * @return array Whatever you want to send to create_insert_array(). - */ - public function pre_create_insert_array($type_data, $notify_users); - - /** - * Function for preparing the data for insertion in an SQL query - * - * @param array $type_data The type specific data - * @param array $pre_create_data Data from pre_create_insert_array() - */ - public function create_insert_array($type_data, $pre_create_data); - - /** - * Function for getting the data for insertion in an SQL query - * - * @return array Array of data ready to be inserted into the database - */ - public function get_insert_array(); - - /** - * Function for preparing the data for update in an SQL query - * (The service handles insertion) - * - * @param array $type_data Data unique to this notification type - * - * @return array Array of data ready to be updated in the database - */ - public function create_update_array($type_data); - - /** - * Mark this item read - * - * @param bool $return True to return a string containing the SQL code to update this item, False to execute it (Default: False) - * @return string - */ - public function mark_read($return = false); - - /** - * Mark this item unread - * - * @param bool $return True to return a string containing the SQL code to update this item, False to execute it (Default: False) - * @return string - */ - public function mark_unread($return = false); -} diff --git a/install/update/new/phpbb/passwords/driver/argon2i.php b/install/update/new/phpbb/passwords/driver/argon2i.php deleted file mode 100644 index 03368f6..0000000 --- a/install/update/new/phpbb/passwords/driver/argon2i.php +++ /dev/null @@ -1,78 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\passwords\driver; - -class argon2i extends base_native -{ - /** @var int Maximum memory (in bytes) that may be used to compute the Argon2 hash */ - protected $memory_cost; - - /** @var int Number of threads to use for computing the Argon2 hash */ - protected $threads; - - /** @var int Maximum amount of time it may take to compute the Argon2 hash */ - protected $time_cost; - - /** - * Constructor of passwords driver object - * - * @param \phpbb\config\config $config phpBB config - * @param \phpbb\passwords\driver\helper $helper Password driver helper - * @param int $memory_cost Maximum memory (optional) - * @param int $threads Number of threads to use (optional) - * @param int $time_cost Maximum amount of time (optional) - */ - public function __construct(\phpbb\config\config $config, helper $helper, $memory_cost = 1024, $threads = 2, $time_cost = 2) - { - parent::__construct($config, $helper); - - /** - * For Sodium implementation of argon2 algorithm (since PHP 7.4), set special value of 1 for "threads" cost factor - * See https://wiki.php.net/rfc/sodium.argon.hash and PHPBB3-16266 - * Don't allow cost factors to be below default settings where possible - */ - $this->memory_cost = max($memory_cost, defined('PASSWORD_ARGON2_DEFAULT_MEMORY_COST') ? PASSWORD_ARGON2_DEFAULT_MEMORY_COST : 1024); - $this->time_cost = max($time_cost, defined('PASSWORD_ARGON2_DEFAULT_TIME_COST') ? PASSWORD_ARGON2_DEFAULT_TIME_COST : 2); - $this->threads = (defined('PASSWORD_ARGON2_PROVIDER') && PASSWORD_ARGON2_PROVIDER == 'sodium') ? - PASSWORD_ARGON2_DEFAULT_THREADS : max($threads, defined('PASSWORD_ARGON2_DEFAULT_THREADS') ? PASSWORD_ARGON2_DEFAULT_THREADS : 1); - } - - /** - * {@inheritdoc} - */ - public function get_algo_name() - { - return 'PASSWORD_ARGON2I'; - } - - /** - * {@inheritdoc} - */ - public function get_options() - { - return [ - 'memory_cost' => $this->memory_cost, - 'time_cost' => $this->time_cost, - 'threads' => $this->threads - ]; - } - - /** - * {@inheritdoc} - */ - public function get_prefix() - { - return '$argon2i$'; - } -} diff --git a/install/update/new/phpbb/passwords/driver/argon2id.php b/install/update/new/phpbb/passwords/driver/argon2id.php deleted file mode 100644 index 9e4b08b..0000000 --- a/install/update/new/phpbb/passwords/driver/argon2id.php +++ /dev/null @@ -1,33 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\passwords\driver; - -class argon2id extends argon2i -{ - /** - * {@inheritdoc} - */ - public function get_algo_name() - { - return 'PASSWORD_ARGON2ID'; - } - - /** - * {@inheritdoc} - */ - public function get_prefix() - { - return '$argon2id$'; - } -} diff --git a/install/update/new/phpbb/passwords/driver/base_native.php b/install/update/new/phpbb/passwords/driver/base_native.php deleted file mode 100644 index 8749832..0000000 --- a/install/update/new/phpbb/passwords/driver/base_native.php +++ /dev/null @@ -1,75 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\passwords\driver; - -abstract class base_native extends base -{ - /** - * Return the constant name for this driver's algorithm - * - * @link https://www.php.net/manual/en/password.constants.php - * - * @return string - */ - abstract public function get_algo_name(); - - /** - * Return the options set for this driver instance - * - * @return array - */ - abstract public function get_options(); - - /** - * {@inheritdoc} - */ - public function check($password, $hash, $user_row = []) - { - return password_verify($password, $hash); - } - - /** - * Return the value for this driver's algorithm - * - * @return integer - */ - public function get_algo_value() - { - return constant($this->get_algo_name()); - } - - /** - * {@inheritdoc} - */ - public function hash($password) - { - return password_hash($password, $this->get_algo_value(), $this->get_options()); - } - - /** - * {@inheritdoc} - */ - public function is_supported() - { - return defined($this->get_algo_name()) && function_exists('password_hash') && function_exists('password_needs_rehash') && function_exists('password_verify'); - } - - /** - * {@inheritdoc} - */ - public function needs_rehash($hash) - { - return password_needs_rehash($hash, $this->get_algo_value(), $this->get_options()); - } -} diff --git a/install/update/new/phpbb/passwords/manager.php b/install/update/new/phpbb/passwords/manager.php deleted file mode 100644 index 54e6dce..0000000 --- a/install/update/new/phpbb/passwords/manager.php +++ /dev/null @@ -1,407 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\passwords; - -class manager -{ - /** - * Default hashing method - */ - protected $type = false; - - /** - * Hashing algorithm type map - * Will be used to map hash prefix to type - */ - protected $type_map = false; - - /** - * Service collection of hashing algorithms - * Needs to be public for passwords helper - */ - public $algorithms = false; - - /** - * Password convert flag. Signals that password should be converted - */ - public $convert_flag = false; - - /** - * Passwords helper - * @var \phpbb\passwords\helper - */ - protected $helper; - - /** - * phpBB configuration - * @var \phpbb\config\config - */ - protected $config; - - /** - * @var bool Whether or not initialized() has been called - */ - private $initialized = false; - - /** - * @var array Hashing driver service collection - */ - private $hashing_algorithms; - - /** - * @var array List of default driver types - */ - private $defaults; - - /** - * Construct a passwords object - * - * @param \phpbb\config\config $config phpBB configuration - * @param array $hashing_algorithms Hashing driver service collection - * @param \phpbb\passwords\helper $helper Passwords helper object - * @param array $defaults List of default driver types - */ - public function __construct(\phpbb\config\config $config, $hashing_algorithms, helper $helper, $defaults) - { - $this->config = $config; - $this->helper = $helper; - $this->hashing_algorithms = $hashing_algorithms; - $this->defaults = $defaults; - } - - /** - * Initialize the internal state - */ - protected function initialize() - { - if (!$this->initialized) - { - $this->initialized = true; - $this->fill_type_map($this->hashing_algorithms); - $this->register_default_type($this->defaults); - } - } - - /** - * Register default type - * Will register the first supported type from the list of default types - * - * @param array $defaults List of default types in order from first to - * use to last to use - */ - protected function register_default_type($defaults) - { - foreach ($defaults as $type) - { - if ($this->algorithms[$type]->is_supported()) - { - $this->type = $this->algorithms[$type]->get_prefix(); - break; - } - } - } - - /** - * Fill algorithm type map - * - * @param \phpbb\di\service_collection $hashing_algorithms - */ - protected function fill_type_map($hashing_algorithms) - { - foreach ($hashing_algorithms as $algorithm) - { - if (!isset($this->type_map[$algorithm->get_prefix()])) - { - $this->type_map[$algorithm->get_prefix()] = $algorithm; - } - } - $this->algorithms = $hashing_algorithms; - } - - /** - * Get the algorithm specified by a specific prefix - * - * @param string $prefix Password hash prefix - * - * @return object|bool The hash type object or false if prefix is not - * supported - */ - protected function get_algorithm($prefix) - { - if (isset($this->type_map[$prefix])) - { - return $this->type_map[$prefix]; - } - else - { - return false; - } - } - - /** - * Detect the hash type of the supplied hash - * - * @param string $hash Password hash that should be checked - * - * @return object|bool The hash type object or false if the specified - * type is not supported - */ - public function detect_algorithm($hash) - { - /* - * preg_match() will also show hashing algos like $2a\H$, which - * is a combination of bcrypt and phpass. Legacy algorithms - * like md5 will not be matched by this and need to be treated - * differently. - */ - if (!preg_match('#^\$([a-zA-Z0-9\\\]*?)\$#', $hash, $match)) - { - return false; - } - - $this->initialize(); - - // Be on the lookout for multiple hashing algorithms - // 2 is correct: H\2a > 2, H\P > 2 - if (strlen($match[1]) > 2 && strpos($match[1], '\\') !== false) - { - $hash_types = explode('\\', $match[1]); - $return_ary = array(); - foreach ($hash_types as $type) - { - // we do not support the same hashing - // algorithm more than once - if (isset($return_ary[$type])) - { - return false; - } - - $return_ary[$type] = $this->get_algorithm('$' . $type . '$'); - - if (empty($return_ary[$type])) - { - return false; - } - } - return $return_ary; - } - - // get_algorithm() will automatically return false if prefix - // is not supported - return $this->get_algorithm($match[0]); - } - - /** - * Hash supplied password - * - * @param string $password Password that should be hashed - * @param string $type Hash type. Will default to standard hash type if - * none is supplied - * @return string|bool Password hash of supplied password or false if - * if something went wrong during hashing - */ - public function hash($password, $type = '') - { - if (strlen($password) > 4096) - { - // If the password is too huge, we will simply reject it - // and not let the server try to hash it. - return false; - } - - $this->initialize(); - - // Try to retrieve algorithm by service name if type doesn't - // start with dollar sign - if (!is_array($type) && strpos($type, '$') !== 0 && isset($this->algorithms[$type])) - { - $type = $this->algorithms[$type]->get_prefix(); - } - - $type = ($type === '') ? $this->type : $type; - - if (is_array($type)) - { - return $this->combined_hash_password($password, $type); - } - - if (isset($this->type_map[$type])) - { - $hashing_algorithm = $this->type_map[$type]; - } - else - { - return false; - } - - return $hashing_algorithm->hash($password); - } - - /** - * Check supplied password against hash and set convert_flag if password - * needs to be converted to different format (preferably newer one) - * - * @param string $password Password that should be checked - * @param string $hash Stored hash - * @param array $user_row User's row in users table - * @return string|bool True if password is correct, false if not - */ - public function check($password, $hash, $user_row = array()) - { - if (strlen($password) > 4096) - { - // If the password is too huge, we will simply reject it - // and not let the server try to hash it. - return false; - } - - // Empty hashes can't be checked - if (empty($hash)) - { - return false; - } - - $this->initialize(); - - // First find out what kind of hash we're dealing with - $stored_hash_type = $this->detect_algorithm($hash); - if ($stored_hash_type == false) - { - // Still check MD5 hashes as that is what the installer - // will default to for the admin user - return $this->get_algorithm('$H$')->check($password, $hash); - } - - // Multiple hash passes needed - if (is_array($stored_hash_type)) - { - $correct = $this->check_combined_hash($password, $stored_hash_type, $hash); - $this->convert_flag = ($correct === true) ? true : false; - return $correct; - } - - if ($stored_hash_type->get_prefix() !== $this->type) - { - $this->convert_flag = true; - } - else - { - if ($stored_hash_type instanceof driver\rehashable_driver_interface) - { - $this->convert_flag = $stored_hash_type->needs_rehash($hash); - } - else - { - $this->convert_flag = false; - } - } - - // Check all legacy hash types if prefix is $CP$ - if ($stored_hash_type->get_prefix() === '$CP$') - { - // Remove $CP$ prefix for proper checking - $hash = substr($hash, 4); - - foreach ($this->type_map as $algorithm) - { - if ($algorithm->is_legacy() && $algorithm->check($password, $hash, $user_row) === true) - { - return true; - } - } - } - - return $stored_hash_type->check($password, $hash); - } - - /** - * Create combined hash from already hashed password - * - * @param string $password_hash Complete current password hash - * @param string $type Type of the hashing algorithm the password hash - * should be combined with - * @return string|bool Combined password hash if combined hashing was - * successful, else false - */ - public function combined_hash_password($password_hash, $type) - { - $this->initialize(); - - $data = array( - 'prefix' => '$', - 'settings' => '$', - ); - $hash_settings = $this->helper->get_combined_hash_settings($password_hash); - $hash = $hash_settings[0]; - - // Put settings of current hash into data array - $stored_hash_type = $this->detect_algorithm($password_hash); - $this->helper->combine_hash_output($data, 'prefix', $stored_hash_type->get_prefix()); - $this->helper->combine_hash_output($data, 'settings', $stored_hash_type->get_settings_only($password_hash)); - - // Hash current hash with the defined types - foreach ($type as $cur_type) - { - if (isset($this->algorithms[$cur_type])) - { - $new_hash_type = $this->algorithms[$cur_type]; - } - else - { - $new_hash_type = $this->get_algorithm($cur_type); - } - - if (!$new_hash_type) - { - return false; - } - - $new_hash = $new_hash_type->hash(str_replace($stored_hash_type->get_settings_only($password_hash), '', $hash)); - $this->helper->combine_hash_output($data, 'prefix', $new_hash_type->get_prefix()); - $this->helper->combine_hash_output($data, 'settings', substr(str_replace('$', '\\', $new_hash_type->get_settings_only($new_hash, true)), 0)); - $hash = str_replace($new_hash_type->get_settings_only($new_hash), '', $this->helper->obtain_hash_only($new_hash)); - } - return $this->helper->combine_hash_output($data, 'hash', $hash); - } - - /** - * Check combined password hash against the supplied password - * - * @param string $password Password entered by user - * @param array $stored_hash_type An array containing the hash types - * as described by stored password hash - * @param string $hash Stored password hash - * - * @return bool True if password is correct, false if not - */ - public function check_combined_hash($password, $stored_hash_type, $hash) - { - $i = 0; - $data = array( - 'prefix' => '$', - 'settings' => '$', - ); - $hash_settings = $this->helper->get_combined_hash_settings($hash); - foreach ($stored_hash_type as $key => $hash_type) - { - $rebuilt_hash = $this->helper->rebuild_hash($hash_type->get_prefix(), $hash_settings[$i]); - $this->helper->combine_hash_output($data, 'prefix', $key); - $this->helper->combine_hash_output($data, 'settings', $hash_settings[$i]); - $cur_hash = $hash_type->hash($password, $rebuilt_hash); - $password = str_replace($rebuilt_hash, '', $cur_hash); - $i++; - } - return ($hash === $this->helper->combine_hash_output($data, 'hash', $password)); - } -} diff --git a/install/update/new/phpbb/permissions.php b/install/update/new/phpbb/permissions.php deleted file mode 100644 index 236535c..0000000 --- a/install/update/new/phpbb/permissions.php +++ /dev/null @@ -1,365 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb; - -class permissions -{ - /** - * Event dispatcher object - * @var \phpbb\event\dispatcher_interface - */ - protected $dispatcher; - - /** - * User object - * @var \phpbb\user - */ - protected $user; - - /** - * Constructor - * - * @param \phpbb\event\dispatcher_interface $phpbb_dispatcher Event dispatcher - * @param \phpbb\user $user User Object - */ - public function __construct(\phpbb\event\dispatcher_interface $phpbb_dispatcher, \phpbb\user $user) - { - $this->dispatcher = $phpbb_dispatcher; - $this->user = $user; - - $categories = $this->categories; - $types = $this->types; - $permissions = $this->permissions; - - /** - * Allows to specify additional permission categories, types and permissions - * - * @event core.permissions - * @var array types Array with permission types (a_, u_, m_, etc.) - * @var array categories Array with permission categories (pm, post, settings, misc, etc.) - * @var array permissions Array with permissions. Each Permission has the following layout: - * '' => array( - * 'lang' => 'Language Key with a Short description', // Optional, if not set, - * // the permissions identifier '' is used with - * // all uppercase. - * 'cat' => 'Identifier of the category, the permission should be displayed in', - * ), - * Example: - * 'u_viewprofile' => array( - * 'lang' => 'ACL_U_VIEWPROFILE', - * 'cat' => 'profile', - * ), - * @since 3.1.0-a1 - */ - $vars = array('types', 'categories', 'permissions'); - extract($phpbb_dispatcher->trigger_event('core.permissions', compact($vars))); - - $this->categories = $categories; - $this->types = $types; - $this->permissions = $permissions; - } - - /** - * Returns an array with all the permission categories (pm, post, settings, misc, etc.) - * - * @return array Layout: cat-identifier => Language key - */ - public function get_categories() - { - return $this->categories; - } - - /** - * Returns the language string of a permission category - * - * @param string $category Identifier of the category - * @return string Language string - */ - public function get_category_lang($category) - { - return $this->user->lang($this->categories[$category]); - } - - /** - * Returns an array with all the permission types (a_, u_, m_, etc.) - * - * @return array Layout: type-identifier => Language key - */ - public function get_types() - { - return $this->types; - } - - /** - * Returns the language string of a permission type - * - * @param string $type Identifier of the type - * @param mixed $scope Scope of the type (should be 'global', 'local' or false) - * @return string Language string - */ - public function get_type_lang($type, $scope = false) - { - if ($scope && isset($this->types[$scope][$type])) - { - $lang_key = $this->types[$scope][$type]; - } - else if (isset($this->types[$type])) - { - $lang_key = $this->types[$type]; - } - else - { - $lang_key = 'ACL_TYPE_' . strtoupper(($scope) ? $scope . '_' . $type : $type); - } - - return $this->user->lang($lang_key); - } - - /** - * Returns an array with all the permissions. - * Each Permission has the following layout: - * '' => array( - * 'lang' => 'Language Key with a Short description', // Optional, if not set, - * // the permissions identifier '' is used with - * // all uppercase. - * 'cat' => 'Identifier of the category, the permission should be displayed in', - * ), - * Example: - * 'u_viewprofile' => array( - * 'lang' => 'ACL_U_VIEWPROFILE', - * 'cat' => 'profile', - * ), - * - * @return array - */ - public function get_permissions() - { - return $this->permissions; - } - - /** - * Returns the category of a permission - * - * @param string $permission Identifier of the permission - * @return string Returns the category identifier of the permission - */ - public function get_permission_category($permission) - { - return (isset($this->permissions[$permission]['cat'])) ? $this->permissions[$permission]['cat'] : 'misc'; - } - - /** - * Checks if a category has been defined - * - * @param string $category Identifier of the category - * @return bool True if the category is defined, false otherwise - */ - public function category_defined($category) - { - return isset($this->categories[$category]); - } - - /** - * Checks if a permission has been defined - * - * @param string $permission Identifier of the permission - * @return bool True if the permission is defined, false otherwise - */ - public function permission_defined($permission) - { - return isset($this->permissions[$permission]); - } - - /** - * Returns the language string of a permission - * - * @param string $permission Identifier of the permission - * @return string Language string - */ - public function get_permission_lang($permission) - { - return (isset($this->permissions[$permission]['lang'])) ? $this->user->lang($this->permissions[$permission]['lang']) : $this->user->lang('ACL_' . strtoupper($permission)); - } - - protected $types = array( - 'u_' => 'ACL_TYPE_U_', - 'a_' => 'ACL_TYPE_A_', - 'm_' => 'ACL_TYPE_M_', - 'f_' => 'ACL_TYPE_F_', - 'global' => array( - 'm_' => 'ACL_TYPE_GLOBAL_M_', - ), - ); - - protected $categories = array( - 'actions' => 'ACL_CAT_ACTIONS', - 'content' => 'ACL_CAT_CONTENT', - 'forums' => 'ACL_CAT_FORUMS', - 'misc' => 'ACL_CAT_MISC', - 'permissions' => 'ACL_CAT_PERMISSIONS', - 'pm' => 'ACL_CAT_PM', - 'polls' => 'ACL_CAT_POLLS', - 'post' => 'ACL_CAT_POST', - 'post_actions' => 'ACL_CAT_POST_ACTIONS', - 'posting' => 'ACL_CAT_POSTING', - 'profile' => 'ACL_CAT_PROFILE', - 'settings' => 'ACL_CAT_SETTINGS', - 'topic_actions' => 'ACL_CAT_TOPIC_ACTIONS', - 'user_group' => 'ACL_CAT_USER_GROUP', - ); - - protected $permissions = array( - // User Permissions - 'u_viewprofile' => array('lang' => 'ACL_U_VIEWPROFILE', 'cat' => 'profile'), - 'u_chgname' => array('lang' => 'ACL_U_CHGNAME', 'cat' => 'profile'), - 'u_chgpasswd' => array('lang' => 'ACL_U_CHGPASSWD', 'cat' => 'profile'), - 'u_chgemail' => array('lang' => 'ACL_U_CHGEMAIL', 'cat' => 'profile'), - 'u_chgavatar' => array('lang' => 'ACL_U_CHGAVATAR', 'cat' => 'profile'), - 'u_chggrp' => array('lang' => 'ACL_U_CHGGRP', 'cat' => 'profile'), - 'u_chgprofileinfo' => array('lang' => 'ACL_U_CHGPROFILEINFO', 'cat' => 'profile'), - - 'u_attach' => array('lang' => 'ACL_U_ATTACH', 'cat' => 'post'), - 'u_download' => array('lang' => 'ACL_U_DOWNLOAD', 'cat' => 'post'), - 'u_savedrafts' => array('lang' => 'ACL_U_SAVEDRAFTS', 'cat' => 'post'), - 'u_chgcensors' => array('lang' => 'ACL_U_CHGCENSORS', 'cat' => 'post'), - 'u_sig' => array('lang' => 'ACL_U_SIG', 'cat' => 'post'), - 'u_emoji' => array('lang' => 'ACL_U_EMOJI', 'cat' => 'post'), - - 'u_sendpm' => array('lang' => 'ACL_U_SENDPM', 'cat' => 'pm'), - 'u_masspm' => array('lang' => 'ACL_U_MASSPM', 'cat' => 'pm'), - 'u_masspm_group'=> array('lang' => 'ACL_U_MASSPM_GROUP', 'cat' => 'pm'), - 'u_readpm' => array('lang' => 'ACL_U_READPM', 'cat' => 'pm'), - 'u_pm_edit' => array('lang' => 'ACL_U_PM_EDIT', 'cat' => 'pm'), - 'u_pm_delete' => array('lang' => 'ACL_U_PM_DELETE', 'cat' => 'pm'), - 'u_pm_forward' => array('lang' => 'ACL_U_PM_FORWARD', 'cat' => 'pm'), - 'u_pm_emailpm' => array('lang' => 'ACL_U_PM_EMAILPM', 'cat' => 'pm'), - 'u_pm_printpm' => array('lang' => 'ACL_U_PM_PRINTPM', 'cat' => 'pm'), - 'u_pm_attach' => array('lang' => 'ACL_U_PM_ATTACH', 'cat' => 'pm'), - 'u_pm_download' => array('lang' => 'ACL_U_PM_DOWNLOAD', 'cat' => 'pm'), - 'u_pm_bbcode' => array('lang' => 'ACL_U_PM_BBCODE', 'cat' => 'pm'), - 'u_pm_smilies' => array('lang' => 'ACL_U_PM_SMILIES', 'cat' => 'pm'), - 'u_pm_img' => array('lang' => 'ACL_U_PM_IMG', 'cat' => 'pm'), - 'u_pm_flash' => array('lang' => 'ACL_U_PM_FLASH', 'cat' => 'pm'), - - 'u_sendemail' => array('lang' => 'ACL_U_SENDEMAIL', 'cat' => 'misc'), - 'u_sendim' => array('lang' => 'ACL_U_SENDIM', 'cat' => 'misc'), - 'u_ignoreflood' => array('lang' => 'ACL_U_IGNOREFLOOD', 'cat' => 'misc'), - 'u_hideonline' => array('lang' => 'ACL_U_HIDEONLINE', 'cat' => 'misc'), - 'u_viewonline' => array('lang' => 'ACL_U_VIEWONLINE', 'cat' => 'misc'), - 'u_search' => array('lang' => 'ACL_U_SEARCH', 'cat' => 'misc'), - - // Forum Permissions - 'f_list' => array('lang' => 'ACL_F_LIST', 'cat' => 'actions'), - 'f_list_topics' => array('lang' => 'ACL_F_LIST_TOPICS', 'cat' => 'actions'), - 'f_read' => array('lang' => 'ACL_F_READ', 'cat' => 'actions'), - 'f_search' => array('lang' => 'ACL_F_SEARCH', 'cat' => 'actions'), - 'f_subscribe' => array('lang' => 'ACL_F_SUBSCRIBE', 'cat' => 'actions'), - 'f_print' => array('lang' => 'ACL_F_PRINT', 'cat' => 'actions'), - 'f_email' => array('lang' => 'ACL_F_EMAIL', 'cat' => 'actions'), - 'f_bump' => array('lang' => 'ACL_F_BUMP', 'cat' => 'actions'), - 'f_user_lock' => array('lang' => 'ACL_F_USER_LOCK', 'cat' => 'actions'), - 'f_download' => array('lang' => 'ACL_F_DOWNLOAD', 'cat' => 'actions'), - 'f_report' => array('lang' => 'ACL_F_REPORT', 'cat' => 'actions'), - - 'f_post' => array('lang' => 'ACL_F_POST', 'cat' => 'post'), - 'f_sticky' => array('lang' => 'ACL_F_STICKY', 'cat' => 'post'), - 'f_announce' => array('lang' => 'ACL_F_ANNOUNCE', 'cat' => 'post'), - 'f_announce_global' => array('lang' => 'ACL_F_ANNOUNCE_GLOBAL', 'cat' => 'post'), - 'f_reply' => array('lang' => 'ACL_F_REPLY', 'cat' => 'post'), - 'f_edit' => array('lang' => 'ACL_F_EDIT', 'cat' => 'post'), - 'f_delete' => array('lang' => 'ACL_F_DELETE', 'cat' => 'post'), - 'f_softdelete' => array('lang' => 'ACL_F_SOFTDELETE', 'cat' => 'post'), - 'f_ignoreflood' => array('lang' => 'ACL_F_IGNOREFLOOD', 'cat' => 'post'), - 'f_postcount' => array('lang' => 'ACL_F_POSTCOUNT', 'cat' => 'post'), - 'f_noapprove' => array('lang' => 'ACL_F_NOAPPROVE', 'cat' => 'post'), - - 'f_attach' => array('lang' => 'ACL_F_ATTACH', 'cat' => 'content'), - 'f_icons' => array('lang' => 'ACL_F_ICONS', 'cat' => 'content'), - 'f_bbcode' => array('lang' => 'ACL_F_BBCODE', 'cat' => 'content'), - 'f_flash' => array('lang' => 'ACL_F_FLASH', 'cat' => 'content'), - 'f_img' => array('lang' => 'ACL_F_IMG', 'cat' => 'content'), - 'f_sigs' => array('lang' => 'ACL_F_SIGS', 'cat' => 'content'), - 'f_smilies' => array('lang' => 'ACL_F_SMILIES', 'cat' => 'content'), - - 'f_poll' => array('lang' => 'ACL_F_POLL', 'cat' => 'polls'), - 'f_vote' => array('lang' => 'ACL_F_VOTE', 'cat' => 'polls'), - 'f_votechg' => array('lang' => 'ACL_F_VOTECHG', 'cat' => 'polls'), - - // Moderator Permissions - 'm_edit' => array('lang' => 'ACL_M_EDIT', 'cat' => 'post_actions'), - 'm_delete' => array('lang' => 'ACL_M_DELETE', 'cat' => 'post_actions'), - 'm_approve' => array('lang' => 'ACL_M_APPROVE', 'cat' => 'post_actions'), - 'm_report' => array('lang' => 'ACL_M_REPORT', 'cat' => 'post_actions'), - 'm_chgposter' => array('lang' => 'ACL_M_CHGPOSTER', 'cat' => 'post_actions'), - 'm_info' => array('lang' => 'ACL_M_INFO', 'cat' => 'post_actions'), - 'm_softdelete' => array('lang' => 'ACL_M_SOFTDELETE', 'cat' => 'post_actions'), - - 'm_move' => array('lang' => 'ACL_M_MOVE', 'cat' => 'topic_actions'), - 'm_lock' => array('lang' => 'ACL_M_LOCK', 'cat' => 'topic_actions'), - 'm_split' => array('lang' => 'ACL_M_SPLIT', 'cat' => 'topic_actions'), - 'm_merge' => array('lang' => 'ACL_M_MERGE', 'cat' => 'topic_actions'), - - 'm_warn' => array('lang' => 'ACL_M_WARN', 'cat' => 'misc'), - 'm_pm_report' => array('lang' => 'ACL_M_PM_REPORT', 'cat' => 'misc'), - 'm_ban' => array('lang' => 'ACL_M_BAN', 'cat' => 'misc'), - - // Admin Permissions - 'a_board' => array('lang' => 'ACL_A_BOARD', 'cat' => 'settings'), - 'a_server' => array('lang' => 'ACL_A_SERVER', 'cat' => 'settings'), - 'a_jabber' => array('lang' => 'ACL_A_JABBER', 'cat' => 'settings'), - 'a_phpinfo' => array('lang' => 'ACL_A_PHPINFO', 'cat' => 'settings'), - - 'a_forum' => array('lang' => 'ACL_A_FORUM', 'cat' => 'forums'), - 'a_forumadd' => array('lang' => 'ACL_A_FORUMADD', 'cat' => 'forums'), - 'a_forumdel' => array('lang' => 'ACL_A_FORUMDEL', 'cat' => 'forums'), - 'a_prune' => array('lang' => 'ACL_A_PRUNE', 'cat' => 'forums'), - - 'a_icons' => array('lang' => 'ACL_A_ICONS', 'cat' => 'posting'), - 'a_words' => array('lang' => 'ACL_A_WORDS', 'cat' => 'posting'), - 'a_bbcode' => array('lang' => 'ACL_A_BBCODE', 'cat' => 'posting'), - 'a_attach' => array('lang' => 'ACL_A_ATTACH', 'cat' => 'posting'), - - 'a_user' => array('lang' => 'ACL_A_USER', 'cat' => 'user_group'), - 'a_userdel' => array('lang' => 'ACL_A_USERDEL', 'cat' => 'user_group'), - 'a_group' => array('lang' => 'ACL_A_GROUP', 'cat' => 'user_group'), - 'a_groupadd' => array('lang' => 'ACL_A_GROUPADD', 'cat' => 'user_group'), - 'a_groupdel' => array('lang' => 'ACL_A_GROUPDEL', 'cat' => 'user_group'), - 'a_ranks' => array('lang' => 'ACL_A_RANKS', 'cat' => 'user_group'), - 'a_profile' => array('lang' => 'ACL_A_PROFILE', 'cat' => 'user_group'), - 'a_names' => array('lang' => 'ACL_A_NAMES', 'cat' => 'user_group'), - 'a_ban' => array('lang' => 'ACL_A_BAN', 'cat' => 'user_group'), - - 'a_viewauth' => array('lang' => 'ACL_A_VIEWAUTH', 'cat' => 'permissions'), - 'a_authgroups' => array('lang' => 'ACL_A_AUTHGROUPS', 'cat' => 'permissions'), - 'a_authusers' => array('lang' => 'ACL_A_AUTHUSERS', 'cat' => 'permissions'), - 'a_fauth' => array('lang' => 'ACL_A_FAUTH', 'cat' => 'permissions'), - 'a_mauth' => array('lang' => 'ACL_A_MAUTH', 'cat' => 'permissions'), - 'a_aauth' => array('lang' => 'ACL_A_AAUTH', 'cat' => 'permissions'), - 'a_uauth' => array('lang' => 'ACL_A_UAUTH', 'cat' => 'permissions'), - 'a_roles' => array('lang' => 'ACL_A_ROLES', 'cat' => 'permissions'), - 'a_switchperm' => array('lang' => 'ACL_A_SWITCHPERM', 'cat' => 'permissions'), - - 'a_styles' => array('lang' => 'ACL_A_STYLES', 'cat' => 'misc'), - 'a_extensions' => array('lang' => 'ACL_A_EXTENSIONS', 'cat' => 'misc'), - 'a_viewlogs' => array('lang' => 'ACL_A_VIEWLOGS', 'cat' => 'misc'), - 'a_clearlogs' => array('lang' => 'ACL_A_CLEARLOGS', 'cat' => 'misc'), - 'a_modules' => array('lang' => 'ACL_A_MODULES', 'cat' => 'misc'), - 'a_language' => array('lang' => 'ACL_A_LANGUAGE', 'cat' => 'misc'), - 'a_email' => array('lang' => 'ACL_A_EMAIL', 'cat' => 'misc'), - 'a_bots' => array('lang' => 'ACL_A_BOTS', 'cat' => 'misc'), - 'a_reasons' => array('lang' => 'ACL_A_REASONS', 'cat' => 'misc'), - 'a_backup' => array('lang' => 'ACL_A_BACKUP', 'cat' => 'misc'), - 'a_search' => array('lang' => 'ACL_A_SEARCH', 'cat' => 'misc'), - ); -} diff --git a/install/update/new/phpbb/plupload/plupload.php b/install/update/new/phpbb/plupload/plupload.php deleted file mode 100644 index 80d7e91..0000000 --- a/install/update/new/phpbb/plupload/plupload.php +++ /dev/null @@ -1,417 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\plupload; - -/** -* This class handles all server-side plupload functions -*/ -class plupload -{ - /** - * @var string - */ - protected $phpbb_root_path; - - /** - * @var \phpbb\config\config - */ - protected $config; - - /** - * @var \phpbb\request\request_interface - */ - protected $request; - - /** - * @var \phpbb\user - */ - protected $user; - - /** - * @var \bantu\IniGetWrapper\IniGetWrapper - */ - protected $php_ini; - - /** - * @var \phpbb\mimetype\guesser - */ - protected $mimetype_guesser; - - /** - * Final destination for uploaded files, i.e. the "files" directory. - * @var string - */ - protected $upload_directory; - - /** - * Temporary upload directory for plupload uploads. - * @var string - */ - protected $temporary_directory; - - /** - * Constructor. - * - * @param string $phpbb_root_path - * @param \phpbb\config\config $config - * @param \phpbb\request\request_interface $request - * @param \phpbb\user $user - * @param \bantu\IniGetWrapper\IniGetWrapper $php_ini - * @param \phpbb\mimetype\guesser $mimetype_guesser - */ - public function __construct($phpbb_root_path, \phpbb\config\config $config, \phpbb\request\request_interface $request, \phpbb\user $user, \bantu\IniGetWrapper\IniGetWrapper $php_ini, \phpbb\mimetype\guesser $mimetype_guesser) - { - $this->phpbb_root_path = $phpbb_root_path; - $this->config = $config; - $this->request = $request; - $this->user = $user; - $this->php_ini = $php_ini; - $this->mimetype_guesser = $mimetype_guesser; - - $this->set_default_directories(); - } - - /** - * Plupload allows for chunking so we must check for that and assemble - * the whole file first before performing any checks on it. - * - * @param string $form_name The name of the file element in the upload form - * - * @return array|null null if there are no chunks to piece together - * otherwise array containing the path to the - * pieced-together file and its size - */ - public function handle_upload($form_name) - { - $chunks_expected = $this->request->variable('chunks', 0); - - // If chunking is disabled or we are not using plupload, just return - // and handle the file as usual - if ($chunks_expected < 2) - { - return; - } - - $file_name = $this->request->variable('name', ''); - $chunk = $this->request->variable('chunk', 0); - - $this->user->add_lang('plupload'); - $this->prepare_temporary_directory(); - - $file_path = $this->temporary_filepath($file_name); - $this->integrate_uploaded_file($form_name, $chunk, $file_path); - - // If we are done with all the chunks, strip the .part suffix and then - // handle the resulting file as normal, otherwise die and await the - // next chunk. - if ($chunk == $chunks_expected - 1) - { - rename("{$file_path}.part", $file_path); - - // Reset upload directories to defaults once completed - $this->set_default_directories(); - - // Need to modify some of the $_FILES values to reflect the new file - return array( - 'tmp_name' => $file_path, - 'name' => $this->request->variable('real_filename', '', true), - 'size' => filesize($file_path), - 'type' => $this->mimetype_guesser->guess($file_path, $file_name), - ); - } - else - { - $json_response = new \phpbb\json_response(); - $json_response->send(array( - 'jsonrpc' => '2.0', - 'id' => 'id', - 'result' => null, - )); - } - } - - /** - * Fill in the plupload configuration options in the template - * - * @param \phpbb\cache\service $cache - * @param \phpbb\template\template $template - * @param string $s_action The URL to submit the POST data to - * @param int $forum_id The ID of the forum - * @param int $max_files Maximum number of files allowed. 0 for unlimited. - * - * @return null - */ - public function configure(\phpbb\cache\service $cache, \phpbb\template\template $template, $s_action, $forum_id, $max_files) - { - $filters = $this->generate_filter_string($cache, $forum_id); - $chunk_size = $this->get_chunk_size(); - $resize = $this->generate_resize_string(); - - $template->assign_vars(array( - 'S_RESIZE' => $resize, - 'S_PLUPLOAD' => true, - 'FILTERS' => $filters, - 'CHUNK_SIZE' => $chunk_size, - 'S_PLUPLOAD_URL' => htmlspecialchars_decode($s_action), - 'MAX_ATTACHMENTS' => $max_files, - 'ATTACH_ORDER' => ($this->config['display_order']) ? 'asc' : 'desc', - 'L_TOO_MANY_ATTACHMENTS' => $this->user->lang('TOO_MANY_ATTACHMENTS', $max_files), - )); - - $this->user->add_lang('plupload'); - } - - /** - * Checks whether the page request was sent by plupload or not - * - * @return bool - */ - public function is_active() - { - return $this->request->header('X-PHPBB-USING-PLUPLOAD', false); - } - - /** - * Returns whether the current HTTP request is a multipart request. - * - * @return bool - */ - public function is_multipart() - { - $content_type = $this->request->server('CONTENT_TYPE'); - - return strpos($content_type, 'multipart') === 0; - } - - /** - * Sends an error message back to the client via JSON response - * - * @param int $code The error code - * @param string $msg The translation string of the message to be sent - * - * @return null - */ - public function emit_error($code, $msg) - { - $json_response = new \phpbb\json_response(); - $json_response->send(array( - 'jsonrpc' => '2.0', - 'id' => 'id', - 'error' => array( - 'code' => $code, - 'message' => $this->user->lang($msg), - ), - )); - } - - /** - * Looks at the list of allowed extensions and generates a string - * appropriate for use in configuring plupload with - * - * @param \phpbb\cache\service $cache Cache service object - * @param string $forum_id The forum identifier - * - * @return string - */ - public function generate_filter_string(\phpbb\cache\service $cache, $forum_id) - { - $groups = []; - $filters = []; - - $attach_extensions = $cache->obtain_attach_extensions($forum_id); - unset($attach_extensions['_allowed_']); - - // Re-arrange the extension array to $groups[$group_name][] - foreach ($attach_extensions as $extension => $extension_info) - { - $groups[$extension_info['group_name']]['extensions'][] = $extension; - $groups[$extension_info['group_name']]['max_file_size'] = (int) $extension_info['max_filesize']; - } - - foreach ($groups as $group => $group_info) - { - $filters[] = sprintf( - "{title: '%s', extensions: '%s', max_file_size: %s}", - addslashes(ucfirst(strtolower($group))), - addslashes(implode(',', $group_info['extensions'])), - $group_info['max_file_size'] - ); - } - - return implode(',', $filters); - } - - /** - * Generates a string that is used to tell plupload to automatically resize - * files before uploading them. - * - * @return string - */ - public function generate_resize_string() - { - $resize = ''; - if ($this->config['img_max_height'] > 0 && $this->config['img_max_width'] > 0) - { - $resize = sprintf( - 'resize: {width: %d, height: %d, quality: 85},', - (int) $this->config['img_max_width'], - (int) $this->config['img_max_height'] - ); - } - - return $resize; - } - - /** - * Checks various php.ini values to determine the maximum chunk - * size a file should be split into for upload. - * - * The intention is to calculate a value which reflects whatever - * the most restrictive limit is set to. And to then set the chunk - * size to half that value, to ensure any required transfer overhead - * and POST data remains well within the limit. Or, if all of the - * limits are set to unlimited, the chunk size will also be unlimited. - * - * @return int - * - * @access public - */ - public function get_chunk_size() - { - $max = 0; - - $limits = [ - $this->php_ini->getBytes('memory_limit'), - $this->php_ini->getBytes('upload_max_filesize'), - $this->php_ini->getBytes('post_max_size'), - ]; - - foreach ($limits as $limit_type) - { - if ($limit_type > 0) - { - $max = ($max !== 0) ? min($limit_type, $max) : $limit_type; - } - } - - return floor($max / 2); - } - - protected function temporary_filepath($file_name) - { - // Must preserve the extension for plupload to work. - return sprintf( - '%s/%s_%s%s', - $this->temporary_directory, - $this->config['plupload_salt'], - md5($file_name), - \phpbb\files\filespec::get_extension($file_name) - ); - } - - /** - * Checks whether the chunk we are about to deal with was actually uploaded - * by PHP and actually exists, if not, it generates an error - * - * @param string $form_name The name of the file in the form data - * @param int $chunk Chunk number - * @param string $file_path File path - * - * @return null - */ - protected function integrate_uploaded_file($form_name, $chunk, $file_path) - { - $is_multipart = $this->is_multipart(); - $upload = $this->request->file($form_name); - if ($is_multipart && (!isset($upload['tmp_name']) || !is_uploaded_file($upload['tmp_name']))) - { - $this->emit_error(103, 'PLUPLOAD_ERR_MOVE_UPLOADED'); - } - - $tmp_file = $this->temporary_filepath($upload['tmp_name']); - - if (!phpbb_is_writable($this->temporary_directory) || !move_uploaded_file($upload['tmp_name'], $tmp_file)) - { - $this->emit_error(103, 'PLUPLOAD_ERR_MOVE_UPLOADED'); - } - - $out = fopen("{$file_path}.part", $chunk == 0 ? 'wb' : 'ab'); - if (!$out) - { - $this->emit_error(102, 'PLUPLOAD_ERR_OUTPUT'); - } - - $in = fopen(($is_multipart) ? $tmp_file : 'php://input', 'rb'); - if (!$in) - { - $this->emit_error(101, 'PLUPLOAD_ERR_INPUT'); - } - - while ($buf = fread($in, 4096)) - { - fwrite($out, $buf); - } - - fclose($in); - fclose($out); - - if ($is_multipart) - { - unlink($tmp_file); - } - } - - /** - * Creates the temporary directory if it does not already exist. - * - * @return null - */ - protected function prepare_temporary_directory() - { - if (!file_exists($this->temporary_directory)) - { - mkdir($this->temporary_directory); - - copy( - $this->upload_directory . '/index.htm', - $this->temporary_directory . '/index.htm' - ); - } - } - - /** - * Sets the default directories for uploads - * - * @return null - */ - protected function set_default_directories() - { - $this->upload_directory = $this->phpbb_root_path . $this->config['upload_path']; - $this->temporary_directory = $this->upload_directory . '/plupload'; - } - - /** - * Sets the upload directories to the specified paths - * - * @param string $upload_directory Upload directory - * @param string $temporary_directory Temporary directory - * - * @return null - */ - public function set_upload_directories($upload_directory, $temporary_directory) - { - $this->upload_directory = $upload_directory; - $this->temporary_directory = $temporary_directory; - } -} diff --git a/install/update/new/phpbb/report/report_handler.php b/install/update/new/phpbb/report/report_handler.php deleted file mode 100644 index 97acc17..0000000 --- a/install/update/new/phpbb/report/report_handler.php +++ /dev/null @@ -1,104 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\report; - -abstract class report_handler implements report_handler_interface -{ - /** - * @var \phpbb\db\driver\driver_interface - */ - protected $db; - - /** - * @var \phpbb\event\dispatcher_interface - */ - protected $dispatcher; - - /** - * @var \phpbb\config\config - */ - protected $config; - - /** - * @var \phpbb\auth\auth - */ - protected $auth; - - /** - * @var \phpbb\user - */ - protected $user; - - /** - * @var \phpbb\notification\manager - */ - protected $notifications; - - /** - * @var array - */ - protected $report_data; - - /** - * Constructor - * - * @param \phpbb\db\driver\driver_interface $db - * @param \phpbb\event\dispatcher_interface $dispatcher - * @param \phpbb\config\db $config - * @param \phpbb\auth\auth $auth - * @param \phpbb\user $user - * @param \phpbb\notification\manager $notification - */ - public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\event\dispatcher_interface $dispatcher, \phpbb\config\config $config, \phpbb\auth\auth $auth, \phpbb\user $user, \phpbb\notification\manager $notification) - { - $this->db = $db; - $this->dispatcher = $dispatcher; - $this->config = $config; - $this->auth = $auth; - $this->user = $user; - $this->notifications = $notification; - $this->report_data = array(); - } - - /** - * Creates a report entity in the database - * - * @param array $report_data - * @return int the ID of the created entity - */ - protected function create_report(array $report_data) - { - $sql_ary = array( - 'reason_id' => (int) $report_data['reason_id'], - 'post_id' => $report_data['post_id'], - 'pm_id' => $report_data['pm_id'], - 'user_id' => (int) $this->user->data['user_id'], - 'user_notify' => (int) $report_data['user_notify'], - 'report_closed' => 0, - 'report_time' => (int) time(), - 'report_text' => (string) $report_data['report_text'], - 'reported_post_text' => $report_data['reported_post_text'], - 'reported_post_uid' => $report_data['reported_post_uid'], - 'reported_post_bitfield' => $report_data['reported_post_bitfield'], - 'reported_post_enable_bbcode' => $report_data['reported_post_enable_bbcode'], - 'reported_post_enable_smilies' => $report_data['reported_post_enable_smilies'], - 'reported_post_enable_magic_url' => $report_data['reported_post_enable_magic_url'], - ); - - $sql = 'INSERT INTO ' . REPORTS_TABLE . ' ' . $this->db->sql_build_array('INSERT', $sql_ary); - $this->db->sql_query($sql); - - return $this->db->sql_nextid(); - } -} diff --git a/install/update/new/phpbb/request/request.php b/install/update/new/phpbb/request/request.php deleted file mode 100644 index 4d7bc9e..0000000 --- a/install/update/new/phpbb/request/request.php +++ /dev/null @@ -1,454 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\request; - -/** -* All application input is accessed through this class. -* -* It provides a method to disable access to input data through super globals. -* This should force MOD authors to read about data validation. -*/ -class request implements \phpbb\request\request_interface -{ - /** - * @var array The names of super global variables that this class should protect if super globals are disabled. - */ - protected $super_globals = array( - \phpbb\request\request_interface::POST => '_POST', - \phpbb\request\request_interface::GET => '_GET', - \phpbb\request\request_interface::REQUEST => '_REQUEST', - \phpbb\request\request_interface::COOKIE => '_COOKIE', - \phpbb\request\request_interface::SERVER => '_SERVER', - \phpbb\request\request_interface::FILES => '_FILES', - ); - - /** - * @var array Stores original contents of $_REQUEST array. - */ - protected $original_request = null; - - /** - * @var - */ - protected $super_globals_disabled = false; - - /** - * @var array An associative array that has the value of super global constants as keys and holds their data as values. - */ - protected $input; - - /** - * @var \phpbb\request\type_cast_helper_interface An instance of a type cast helper providing convenience methods for type conversions. - */ - protected $type_cast_helper; - - /** - * Initialises the request class, that means it stores all input data in {@link $input input} - * and then calls {@link \phpbb\request\deactivated_super_global \phpbb\request\deactivated_super_global} - */ - public function __construct(\phpbb\request\type_cast_helper_interface $type_cast_helper = null, $disable_super_globals = true) - { - if ($type_cast_helper) - { - $this->type_cast_helper = $type_cast_helper; - } - else - { - $this->type_cast_helper = new \phpbb\request\type_cast_helper(); - } - - foreach ($this->super_globals as $const => $super_global) - { - $this->input[$const] = isset($GLOBALS[$super_global]) ? $GLOBALS[$super_global] : array(); - } - - // simulate request_order = GP - $this->original_request = $this->input[\phpbb\request\request_interface::REQUEST]; - $this->input[\phpbb\request\request_interface::REQUEST] = $this->input[\phpbb\request\request_interface::POST] + $this->input[\phpbb\request\request_interface::GET]; - - if ($disable_super_globals) - { - $this->disable_super_globals(); - } - } - - /** - * Getter for $super_globals_disabled - * - * @return bool Whether super globals are disabled or not. - */ - public function super_globals_disabled() - { - return $this->super_globals_disabled; - } - - /** - * Disables access of super globals specified in $super_globals. - * This is achieved by overwriting the super globals with instances of {@link \phpbb\request\deactivated_super_global \phpbb\request\deactivated_super_global} - */ - public function disable_super_globals() - { - if (!$this->super_globals_disabled) - { - foreach ($this->super_globals as $const => $super_global) - { - unset($GLOBALS[$super_global]); - $GLOBALS[$super_global] = new \phpbb\request\deactivated_super_global($this, $super_global, $const); - } - - $this->super_globals_disabled = true; - } - } - - /** - * Enables access of super globals specified in $super_globals if they were disabled by {@link disable_super_globals disable_super_globals}. - * This is achieved by making the super globals point to the data stored within this class in {@link $input input}. - */ - public function enable_super_globals() - { - if ($this->super_globals_disabled) - { - foreach ($this->super_globals as $const => $super_global) - { - $GLOBALS[$super_global] = $this->input[$const]; - } - - $GLOBALS['_REQUEST'] = $this->original_request; - - $this->super_globals_disabled = false; - } - } - - /** - * This function allows overwriting or setting a value in one of the super global arrays. - * - * Changes which are performed on the super globals directly will not have any effect on the results of - * other methods this class provides. Using this function should be avoided if possible! It will - * consume twice the the amount of memory of the value - * - * @param string $var_name The name of the variable that shall be overwritten - * @param mixed $value The value which the variable shall contain. - * If this is null the variable will be unset. - * @param \phpbb\request\request_interface::POST|GET|REQUEST|COOKIE $super_global - * Specifies which super global shall be changed - */ - public function overwrite($var_name, $value, $super_global = \phpbb\request\request_interface::REQUEST) - { - if (!isset($this->super_globals[$super_global])) - { - return; - } - - // setting to null means unsetting - if ($value === null) - { - unset($this->input[$super_global][$var_name]); - if (!$this->super_globals_disabled()) - { - unset($GLOBALS[$this->super_globals[$super_global]][$var_name]); - } - } - else - { - $this->input[$super_global][$var_name] = $value; - if (!$this->super_globals_disabled()) - { - $GLOBALS[$this->super_globals[$super_global]][$var_name] = $value; - } - } - } - - /** - * Central type safe input handling function. - * All variables in GET or POST requests should be retrieved through this function to maximise security. - * - * @param string|array $var_name The form variable's name from which data shall be retrieved. - * If the value is an array this may be an array of indizes which will give - * direct access to a value at any depth. E.g. if the value of "var" is array(1 => "a") - * then specifying array("var", 1) as the name will return "a". - * @param mixed $default A default value that is returned if the variable was not set. - * This function will always return a value of the same type as the default. - * @param bool $multibyte If $default is a string this parameter has to be true if the variable may contain any UTF-8 characters - * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks - * @param \phpbb\request\request_interface::POST|GET|REQUEST|COOKIE $super_global - * Specifies which super global should be used - * - * @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the - * the same as that of $default. If the variable is not set $default is returned. - */ - public function variable($var_name, $default, $multibyte = false, $super_global = \phpbb\request\request_interface::REQUEST) - { - return $this->_variable($var_name, $default, $multibyte, $super_global, true); - } - - /** - * Get a variable, but without trimming strings. - * Same functionality as variable(), except does not run trim() on strings. - * This method should be used when handling passwords. - * - * @param string|array $var_name The form variable's name from which data shall be retrieved. - * If the value is an array this may be an array of indizes which will give - * direct access to a value at any depth. E.g. if the value of "var" is array(1 => "a") - * then specifying array("var", 1) as the name will return "a". - * @param mixed $default A default value that is returned if the variable was not set. - * This function will always return a value of the same type as the default. - * @param bool $multibyte If $default is a string this parameter has to be true if the variable may contain any UTF-8 characters - * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks - * @param \phpbb\request\request_interface::POST|GET|REQUEST|COOKIE $super_global - * Specifies which super global should be used - * - * @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the - * the same as that of $default. If the variable is not set $default is returned. - */ - public function untrimmed_variable($var_name, $default, $multibyte = false, $super_global = \phpbb\request\request_interface::REQUEST) - { - return $this->_variable($var_name, $default, $multibyte, $super_global, false); - } - - /** - * {@inheritdoc} - */ - public function raw_variable($var_name, $default, $super_global = \phpbb\request\request_interface::REQUEST) - { - $path = false; - - // deep direct access to multi dimensional arrays - if (is_array($var_name)) - { - $path = $var_name; - // make sure at least the variable name is specified - if (empty($path)) - { - return (is_array($default)) ? array() : $default; - } - // the variable name is the first element on the path - $var_name = array_shift($path); - } - - if (!isset($this->input[$super_global][$var_name])) - { - return (is_array($default)) ? array() : $default; - } - $var = $this->input[$super_global][$var_name]; - - if ($path) - { - // walk through the array structure and find the element we are looking for - foreach ($path as $key) - { - if (is_array($var) && isset($var[$key])) - { - $var = $var[$key]; - } - else - { - return (is_array($default)) ? array() : $default; - } - } - } - - return $var; - } - - /** - * Shortcut method to retrieve SERVER variables. - * - * Also fall back to getenv(), some CGI setups may need it (probably not, but - * whatever). - * - * @param string|array $var_name See \phpbb\request\request_interface::variable - * @param mixed $default See \phpbb\request\request_interface::variable - * - * @return mixed The server variable value. - */ - public function server($var_name, $default = '') - { - $multibyte = true; - - if ($this->is_set($var_name, \phpbb\request\request_interface::SERVER)) - { - return $this->variable($var_name, $default, $multibyte, \phpbb\request\request_interface::SERVER); - } - else - { - $var = getenv($var_name); - $this->type_cast_helper->recursive_set_var($var, $default, $multibyte); - return $var; - } - } - - /** - * Shortcut method to retrieve the value of client HTTP headers. - * - * @param string|array $header_name The name of the header to retrieve. - * @param mixed $default See \phpbb\request\request_interface::variable - * - * @return mixed The header value. - */ - public function header($header_name, $default = '') - { - $var_name = 'HTTP_' . str_replace('-', '_', strtoupper($header_name)); - return $this->server($var_name, $default); - } - - /** - * Shortcut method to retrieve $_FILES variables - * - * @param string $form_name The name of the file input form element - * - * @return array The uploaded file's information or an empty array if the - * variable does not exist in _FILES. - */ - public function file($form_name) - { - return $this->variable($form_name, array('name' => 'none'), true, \phpbb\request\request_interface::FILES); - } - - /** - * Checks whether a certain variable was sent via POST. - * To make sure that a request was sent using POST you should call this function - * on at least one variable. - * - * @param string $name The name of the form variable which should have a - * _p suffix to indicate the check in the code that creates the form too. - * - * @return bool True if the variable was set in a POST request, false otherwise. - */ - public function is_set_post($name) - { - return $this->is_set($name, \phpbb\request\request_interface::POST); - } - - /** - * Checks whether a certain variable is set in one of the super global - * arrays. - * - * @param string $var Name of the variable - * @param \phpbb\request\request_interface::POST|GET|REQUEST|COOKIE $super_global - * Specifies the super global which shall be checked - * - * @return bool True if the variable was sent as input - */ - public function is_set($var, $super_global = \phpbb\request\request_interface::REQUEST) - { - return isset($this->input[$super_global][$var]); - } - - /** - * Checks whether the current request is an AJAX request (XMLHttpRequest) - * - * @return bool True if the current request is an ajax request - */ - public function is_ajax() - { - return $this->header('X-Requested-With') == 'XMLHttpRequest'; - } - - /** - * Checks if the current request is happening over HTTPS. - * - * @return bool True if the request is secure. - */ - public function is_secure() - { - $https = $this->server('HTTPS'); - $https = $this->server('HTTP_X_FORWARDED_PROTO') === 'https' ? 'on' : $https; - return !empty($https) && $https !== 'off'; - } - - /** - * Returns all variable names for a given super global - * - * @param \phpbb\request\request_interface::POST|GET|REQUEST|COOKIE $super_global - * The super global from which names shall be taken - * - * @return array All variable names that are set for the super global. - * Pay attention when using these, they are unsanitised! - */ - public function variable_names($super_global = \phpbb\request\request_interface::REQUEST) - { - if (!isset($this->input[$super_global])) - { - return array(); - } - - return array_keys($this->input[$super_global]); - } - - /** - * Helper function used by variable() and untrimmed_variable(). - * - * @param string|array $var_name The form variable's name from which data shall be retrieved. - * If the value is an array this may be an array of indizes which will give - * direct access to a value at any depth. E.g. if the value of "var" is array(1 => "a") - * then specifying array("var", 1) as the name will return "a". - * @param mixed $default A default value that is returned if the variable was not set. - * This function will always return a value of the same type as the default. - * @param bool $multibyte If $default is a string this parameter has to be true if the variable may contain any UTF-8 characters - * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks - * @param \phpbb\request\request_interface::POST|GET|REQUEST|COOKIE $super_global - * Specifies which super global should be used - * @param bool $trim Indicates whether trim() should be applied to string values. - * - * @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the - * the same as that of $default. If the variable is not set $default is returned. - */ - protected function _variable($var_name, $default, $multibyte = false, $super_global = \phpbb\request\request_interface::REQUEST, $trim = true) - { - $var = $this->raw_variable($var_name, $default, $super_global); - - // Return prematurely if raw variable is empty array or the same as - // the default. Using strict comparison to ensure that one can't - // prevent proper type checking on any input variable - if ($var === array() || $var === $default) - { - return $var; - } - - $this->type_cast_helper->recursive_set_var($var, $default, $multibyte, $trim); - - return $var; - } - - /** - * {@inheritdoc} - */ - public function get_super_global($super_global = \phpbb\request\request_interface::REQUEST) - { - return $this->input[$super_global]; - } - - /** - * {@inheritdoc} - */ - public function escape($var, $multibyte) - { - if (is_array($var)) - { - $result = array(); - foreach ($var as $key => $value) - { - $this->type_cast_helper->set_var($key, $key, gettype($key), $multibyte); - $result[$key] = $this->escape($value, $multibyte); - } - $var = $result; - } - else - { - $this->type_cast_helper->set_var($var, $var, 'string', $multibyte); - } - - return $var; - } -} diff --git a/install/update/new/phpbb/request/request_interface.php b/install/update/new/phpbb/request/request_interface.php deleted file mode 100644 index a1fbf0a..0000000 --- a/install/update/new/phpbb/request/request_interface.php +++ /dev/null @@ -1,177 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\request; - -/** -* An interface through which all application input can be accessed. -*/ -interface request_interface -{ - /**#@+ - * Constant identifying the super global with the same name. - */ - const POST = 0; - const GET = 1; - const REQUEST = 2; - const COOKIE = 3; - const SERVER = 4; - const FILES = 5; - /**#@-*/ - - /** - * This function allows overwriting or setting a value in one of the super global arrays. - * - * Changes which are performed on the super globals directly will not have any effect on the results of - * other methods this class provides. Using this function should be avoided if possible! It will - * consume twice the the amount of memory of the value - * - * @param string $var_name The name of the variable that shall be overwritten - * @param mixed $value The value which the variable shall contain. - * If this is null the variable will be unset. - * @param \phpbb\request\request_interface::POST|GET|REQUEST|COOKIE $super_global - * Specifies which super global shall be changed - */ - public function overwrite($var_name, $value, $super_global = \phpbb\request\request_interface::REQUEST); - - /** - * Central type safe input handling function. - * All variables in GET or POST requests should be retrieved through this function to maximise security. - * - * @param string|array $var_name The form variable's name from which data shall be retrieved. - * If the value is an array this may be an array of indizes which will give - * direct access to a value at any depth. E.g. if the value of "var" is array(1 => "a") - * then specifying array("var", 1) as the name will return "a". - * @param mixed $default A default value that is returned if the variable was not set. - * This function will always return a value of the same type as the default. - * @param bool $multibyte If $default is a string this parameter has to be true if the variable may contain any UTF-8 characters - * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks - * @param \phpbb\request\request_interface::POST|GET|REQUEST|COOKIE $super_global - * Specifies which super global should be used - * - * @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the - * the same as that of $default. If the variable is not set $default is returned. - */ - public function variable($var_name, $default, $multibyte = false, $super_global = \phpbb\request\request_interface::REQUEST); - - /** - * Get a variable without trimming strings and without escaping. - * This method MUST NOT be used with queries. - * Same functionality as variable(), except does not run trim() on strings - * and does not escape input. - * This method should only be used when the raw input is needed without - * any escaping, i.e. for database password during the installation. - * - * @param string|array $var_name The form variable's name from which data shall be retrieved. - * If the value is an array this may be an array of indizes which will give - * direct access to a value at any depth. E.g. if the value of "var" is array(1 => "a") - * then specifying array("var", 1) as the name will return "a". - * @param mixed $default A default value that is returned if the variable was not set. - * This function will always return a value of the same type as the default. - * @param \phpbb\request\request_interface::POST|GET|REQUEST|COOKIE $super_global - * Specifies which super global should be used - * - * @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the - * the same as that of $default. If the variable is not set $default is returned. - */ - public function raw_variable($var_name, $default, $super_global = \phpbb\request\request_interface::REQUEST); - - /** - * Shortcut method to retrieve SERVER variables. - * - * @param string|array $var_name See \phpbb\request\request_interface::variable - * @param mixed $default See \phpbb\request\request_interface::variable - * - * @return mixed The server variable value. - */ - public function server($var_name, $default = ''); - - /** - * Shortcut method to retrieve the value of client HTTP headers. - * - * @param string|array $header_name The name of the header to retrieve. - * @param mixed $default See \phpbb\request\request_interface::variable - * - * @return mixed The header value. - */ - public function header($header_name, $default = ''); - - /** - * Checks whether a certain variable was sent via POST. - * To make sure that a request was sent using POST you should call this function - * on at least one variable. - * - * @param string $name The name of the form variable which should have a - * _p suffix to indicate the check in the code that creates the form too. - * - * @return bool True if the variable was set in a POST request, false otherwise. - */ - public function is_set_post($name); - - /** - * Checks whether a certain variable is set in one of the super global - * arrays. - * - * @param string $var Name of the variable - * @param \phpbb\request\request_interface::POST|GET|REQUEST|COOKIE $super_global - * Specifies the super global which shall be checked - * - * @return bool True if the variable was sent as input - */ - public function is_set($var, $super_global = \phpbb\request\request_interface::REQUEST); - - /** - * Checks whether the current request is an AJAX request (XMLHttpRequest) - * - * @return bool True if the current request is an ajax request - */ - public function is_ajax(); - - /** - * Checks if the current request is happening over HTTPS. - * - * @return bool True if the request is secure. - */ - public function is_secure(); - - /** - * Returns all variable names for a given super global - * - * @param \phpbb\request\request_interface::POST|GET|REQUEST|COOKIE $super_global - * The super global from which names shall be taken - * - * @return array All variable names that are set for the super global. - * Pay attention when using these, they are unsanitised! - */ - public function variable_names($super_global = \phpbb\request\request_interface::REQUEST); - - /** - * Returns the original array of the requested super global - * - * @param \phpbb\request\request_interface::POST|GET|REQUEST|COOKIE $super_global - * The super global which will be returned - * - * @return array The original array of the requested super global. - */ - public function get_super_global($super_global = \phpbb\request\request_interface::REQUEST); - - /** - * Escape a string variable. - * - * @param mixed $value The contents to fill with - * @param bool $multibyte Indicates whether string values may contain UTF-8 characters. - * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks. - * @return string|array - */ - public function escape($value, $multibyte); -} diff --git a/install/update/new/phpbb/request/type_cast_helper.php b/install/update/new/phpbb/request/type_cast_helper.php deleted file mode 100644 index 39d5908..0000000 --- a/install/update/new/phpbb/request/type_cast_helper.php +++ /dev/null @@ -1,125 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\request; - -/** -* A helper class that provides convenience methods for type casting. -*/ -class type_cast_helper implements \phpbb\request\type_cast_helper_interface -{ - /** - * Set variable $result to a particular type. - * - * @param mixed &$result The variable to fill - * @param mixed $var The contents to fill with - * @param mixed $type The variable type. Will be used with {@link settype()} - * @param bool $multibyte Indicates whether string values may contain UTF-8 characters. - * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks. - * @param bool $trim Indicates whether trim() should be applied to string values. - * Default is true. - */ - public function set_var(&$result, $var, $type, $multibyte = false, $trim = true) - { - settype($var, $type); - $result = $var; - - if ($type == 'string') - { - $result = str_replace(array("\r\n", "\r", "\0"), array("\n", "\n", ''), $result); - - if ($trim) - { - $result = trim($result); - } - - $result = htmlspecialchars($result, ENT_COMPAT, 'UTF-8'); - - if ($multibyte) - { - $result = utf8_normalize_nfc($result); - } - - if (!empty($result)) - { - // Make sure multibyte characters are wellformed - if ($multibyte) - { - if (!preg_match('/^./u', $result)) - { - $result = ''; - } - } - else - { - // no multibyte, allow only ASCII (0-127) - $result = preg_replace('/[\x80-\xFF]/', '?', $result); - } - } - } - } - - /** - * Recursively sets a variable to a given type using {@link set_var set_var} - * - * @param string $var The value which shall be sanitised (passed by reference). - * @param mixed $default Specifies the type $var shall have. - * If it is an array and $var is not one, then an empty array is returned. - * Otherwise var is cast to the same type, and if $default is an array all - * keys and values are cast recursively using this function too. - * @param bool $multibyte Indicates whether string keys and values may contain UTF-8 characters. - * Default is false, causing all bytes outside the ASCII range (0-127) to - * be replaced with question marks. - * @param bool $trim Indicates whether trim() should be applied to string values. - * Default is true. - */ - public function recursive_set_var(&$var, $default, $multibyte, $trim = true) - { - if (is_array($var) !== is_array($default)) - { - $var = (is_array($default)) ? array() : $default; - return; - } - - if (!is_array($default)) - { - $type = gettype($default); - $this->set_var($var, $var, $type, $multibyte, $trim); - } - else - { - // make sure there is at least one key/value pair to use get the - // types from - if (empty($default)) - { - $var = array(); - return; - } - - $default_key = key($default); - $default_value = current($default); - $key_type = gettype($default_key); - - $_var = $var; - $var = array(); - - foreach ($_var as $k => $v) - { - $this->set_var($k, $k, $key_type, $multibyte); - - $this->recursive_set_var($v, $default_value, $multibyte, $trim); - $var[$k] = $v; - } - } - } -} diff --git a/install/update/new/phpbb/search/fulltext_mysql.php b/install/update/new/phpbb/search/fulltext_mysql.php deleted file mode 100644 index 42ac6ea..0000000 --- a/install/update/new/phpbb/search/fulltext_mysql.php +++ /dev/null @@ -1,1220 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\search; - -/** -* Fulltext search for MySQL -*/ -class fulltext_mysql extends \phpbb\search\base -{ - /** - * Associative array holding index stats - * @var array - */ - protected $stats = array(); - - /** - * Holds the words entered by user, obtained by splitting the entered query on whitespace - * @var array - */ - protected $split_words = array(); - - /** - * Config object - * @var \phpbb\config\config - */ - protected $config; - - /** - * Database connection - * @var \phpbb\db\driver\driver_interface - */ - protected $db; - - /** - * phpBB event dispatcher object - * @var \phpbb\event\dispatcher_interface - */ - protected $phpbb_dispatcher; - - /** - * User object - * @var \phpbb\user - */ - protected $user; - - /** - * Associative array stores the min and max word length to be searched - * @var array - */ - protected $word_length = array(); - - /** - * Contains tidied search query. - * Operators are prefixed in search query and common words excluded - * @var string - */ - protected $search_query; - - /** - * Contains common words. - * Common words are words with length less/more than min/max length - * @var array - */ - protected $common_words = array(); - - /** - * Constructor - * Creates a new \phpbb\search\fulltext_mysql, which is used as a search backend - * - * @param string|bool $error Any error that occurs is passed on through this reference variable otherwise false - * @param string $phpbb_root_path Relative path to phpBB root - * @param string $phpEx PHP file extension - * @param \phpbb\auth\auth $auth Auth object - * @param \phpbb\config\config $config Config object - * @param \phpbb\db\driver\driver_interface $db Database object - * @param \phpbb\user $user User object - * @param \phpbb\event\dispatcher_interface $phpbb_dispatcher Event dispatcher object - */ - public function __construct(&$error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher) - { - $this->config = $config; - $this->db = $db; - $this->phpbb_dispatcher = $phpbb_dispatcher; - $this->user = $user; - - $this->word_length = array('min' => $this->config['fulltext_mysql_min_word_len'], 'max' => $this->config['fulltext_mysql_max_word_len']); - - /** - * Load the UTF tools - */ - if (!function_exists('utf8_strlen')) - { - include($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); - } - - $error = false; - } - - /** - * Returns the name of this search backend to be displayed to administrators - * - * @return string Name - */ - public function get_name() - { - return 'MySQL Fulltext'; - } - - /** - * Returns the search_query - * - * @return string search query - */ - public function get_search_query() - { - return $this->search_query; - } - - /** - * Returns the common_words array - * - * @return array common words that are ignored by search backend - */ - public function get_common_words() - { - return $this->common_words; - } - - /** - * Returns the word_length array - * - * @return array min and max word length for searching - */ - public function get_word_length() - { - return $this->word_length; - } - - /** - * Checks for correct MySQL version and stores min/max word length in the config - * - * @return string|bool Language key of the error/incompatibility occurred - */ - public function init() - { - if ($this->db->get_sql_layer() != 'mysqli') - { - return $this->user->lang['FULLTEXT_MYSQL_INCOMPATIBLE_DATABASE']; - } - - $result = $this->db->sql_query('SHOW TABLE STATUS LIKE \'' . POSTS_TABLE . '\''); - $info = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - $engine = ''; - if (isset($info['Engine'])) - { - $engine = $info['Engine']; - } - else if (isset($info['Type'])) - { - $engine = $info['Type']; - } - - $fulltext_supported = - $engine === 'MyISAM' || - // FULLTEXT is supported on InnoDB since MySQL 5.6.4 according to - // http://dev.mysql.com/doc/refman/5.6/en/innodb-storage-engine.html - // We also require https://bugs.mysql.com/bug.php?id=67004 to be - // fixed for proper overall operation. Hence we require 5.6.8. - $engine === 'InnoDB' && - phpbb_version_compare($this->db->sql_server_info(true), '5.6.8', '>='); - - if (!$fulltext_supported) - { - return $this->user->lang['FULLTEXT_MYSQL_NOT_SUPPORTED']; - } - - $sql = 'SHOW VARIABLES - LIKE \'%ft\_%\''; - $result = $this->db->sql_query($sql); - - $mysql_info = array(); - while ($row = $this->db->sql_fetchrow($result)) - { - $mysql_info[$row['Variable_name']] = $row['Value']; - } - $this->db->sql_freeresult($result); - - if ($engine === 'MyISAM') - { - $this->config->set('fulltext_mysql_max_word_len', $mysql_info['ft_max_word_len']); - $this->config->set('fulltext_mysql_min_word_len', $mysql_info['ft_min_word_len']); - } - else if ($engine === 'InnoDB') - { - $this->config->set('fulltext_mysql_max_word_len', $mysql_info['innodb_ft_max_token_size']); - $this->config->set('fulltext_mysql_min_word_len', $mysql_info['innodb_ft_min_token_size']); - } - - return false; - } - - /** - * Splits keywords entered by a user into an array of words stored in $this->split_words - * Stores the tidied search query in $this->search_query - * - * @param string &$keywords Contains the keyword as entered by the user - * @param string $terms is either 'all' or 'any' - * @return bool false if no valid keywords were found and otherwise true - */ - public function split_keywords(&$keywords, $terms) - { - if ($terms == 'all') - { - $match = array('#\sand\s#iu', '#\sor\s#iu', '#\snot\s#iu', '#(^|\s)\+#', '#(^|\s)-#', '#(^|\s)\|#'); - $replace = array(' +', ' |', ' -', ' +', ' -', ' |'); - - $keywords = preg_replace($match, $replace, $keywords); - } - - // Filter out as above - $split_keywords = preg_replace("#[\n\r\t]+#", ' ', trim(htmlspecialchars_decode($keywords))); - - // Split words - $split_keywords = preg_replace('#([^\p{L}\p{N}\'*"()])#u', '$1$1', str_replace('\'\'', '\' \'', trim($split_keywords))); - $matches = array(); - preg_match_all('#(?:[^\p{L}\p{N}*"()]|^)([+\-|]?(?:[\p{L}\p{N}*"()]+\'?)*[\p{L}\p{N}*"()])(?:[^\p{L}\p{N}*"()]|$)#u', $split_keywords, $matches); - $this->split_words = $matches[1]; - - // We limit the number of allowed keywords to minimize load on the database - if ($this->config['max_num_search_keywords'] && count($this->split_words) > $this->config['max_num_search_keywords']) - { - trigger_error($this->user->lang('MAX_NUM_SEARCH_KEYWORDS_REFINE', (int) $this->config['max_num_search_keywords'], count($this->split_words))); - } - - // to allow phrase search, we need to concatenate quoted words - $tmp_split_words = array(); - $phrase = ''; - foreach ($this->split_words as $word) - { - if ($phrase) - { - $phrase .= ' ' . $word; - if (strpos($word, '"') !== false && substr_count($word, '"') % 2 == 1) - { - $tmp_split_words[] = $phrase; - $phrase = ''; - } - } - else if (strpos($word, '"') !== false && substr_count($word, '"') % 2 == 1) - { - $phrase = $word; - } - else - { - $tmp_split_words[] = $word; - } - } - if ($phrase) - { - $tmp_split_words[] = $phrase; - } - - $this->split_words = $tmp_split_words; - - unset($tmp_split_words); - unset($phrase); - - foreach ($this->split_words as $i => $word) - { - // Check for not allowed search queries for InnoDB. - // We assume similar restrictions for MyISAM, which is usually even - // slower but not as restrictive as InnoDB. - // InnoDB full-text search does not support the use of a leading - // plus sign with wildcard ('+*'), a plus and minus sign - // combination ('+-'), or leading a plus and minus sign combination. - // InnoDB full-text search only supports leading plus or minus signs. - // For example, InnoDB supports '+apple' but does not support 'apple+'. - // Specifying a trailing plus or minus sign causes InnoDB to report - // a syntax error. InnoDB full-text search does not support the use - // of multiple operators on a single search word, as in this example: - // '++apple'. Use of multiple operators on a single search word - // returns a syntax error to standard out. - // Also, ensure that the wildcard character is only used at the - // end of the line as it's intended by MySQL. - if (preg_match('#^(\+[+-]|\+\*|.+[+-]$|.+\*(?!$))#', $word)) - { - unset($this->split_words[$i]); - continue; - } - - $clean_word = preg_replace('#^[+\-|"]#', '', $word); - - // check word length - $clean_len = utf8_strlen(str_replace('*', '', $clean_word)); - if (($clean_len < $this->config['fulltext_mysql_min_word_len']) || ($clean_len > $this->config['fulltext_mysql_max_word_len'])) - { - $this->common_words[] = $word; - unset($this->split_words[$i]); - } - } - - if ($terms == 'any') - { - $this->search_query = ''; - foreach ($this->split_words as $word) - { - if ((strpos($word, '+') === 0) || (strpos($word, '-') === 0) || (strpos($word, '|') === 0)) - { - $word = substr($word, 1); - } - $this->search_query .= $word . ' '; - } - } - else - { - $this->search_query = ''; - foreach ($this->split_words as $word) - { - if ((strpos($word, '+') === 0) || (strpos($word, '-') === 0)) - { - $this->search_query .= $word . ' '; - } - else if (strpos($word, '|') === 0) - { - $this->search_query .= substr($word, 1) . ' '; - } - else - { - $this->search_query .= '+' . $word . ' '; - } - } - } - - $this->search_query = utf8_htmlspecialchars($this->search_query); - - if ($this->search_query) - { - $this->split_words = array_values($this->split_words); - sort($this->split_words); - return true; - } - return false; - } - - /** - * Turns text into an array of words - * @param string $text contains post text/subject - */ - public function split_message($text) - { - // Split words - $text = preg_replace('#([^\p{L}\p{N}\'*])#u', '$1$1', str_replace('\'\'', '\' \'', trim($text))); - $matches = array(); - preg_match_all('#(?:[^\p{L}\p{N}*]|^)([+\-|]?(?:[\p{L}\p{N}*]+\'?)*[\p{L}\p{N}*])(?:[^\p{L}\p{N}*]|$)#u', $text, $matches); - $text = $matches[1]; - - // remove too short or too long words - $text = array_values($text); - for ($i = 0, $n = count($text); $i < $n; $i++) - { - $text[$i] = trim($text[$i]); - if (utf8_strlen($text[$i]) < $this->config['fulltext_mysql_min_word_len'] || utf8_strlen($text[$i]) > $this->config['fulltext_mysql_max_word_len']) - { - unset($text[$i]); - } - } - - return array_values($text); - } - - /** - * Performs a search on keywords depending on display specific params. You have to run split_keywords() first - * - * @param string $type contains either posts or topics depending on what should be searched for - * @param string $fields contains either titleonly (topic titles should be searched), msgonly (only message bodies should be searched), firstpost (only subject and body of the first post should be searched) or all (all post bodies and subjects should be searched) - * @param string $terms is either 'all' (use query as entered, words without prefix should default to "have to be in field") or 'any' (ignore search query parts and just return all posts that contain any of the specified words) - * @param array $sort_by_sql contains SQL code for the ORDER BY part of a query - * @param string $sort_key is the key of $sort_by_sql for the selected sorting - * @param string $sort_dir is either a or d representing ASC and DESC - * @param string $sort_days specifies the maximum amount of days a post may be old - * @param array $ex_fid_ary specifies an array of forum ids which should not be searched - * @param string $post_visibility specifies which types of posts the user can view in which forums - * @param int $topic_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched - * @param array $author_ary an array of author ids if the author should be ignored during the search the array is empty - * @param string $author_name specifies the author match, when ANONYMOUS is also a search-match - * @param array &$id_ary passed by reference, to be filled with ids for the page specified by $start and $per_page, should be ordered - * @param int $start indicates the first index of the page - * @param int $per_page number of ids each page is supposed to contain - * @return boolean|int total number of results - */ - public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page) - { - // No keywords? No posts - if (!$this->search_query) - { - return false; - } - - // generate a search_key from all the options to identify the results - $search_key_array = array( - implode(', ', $this->split_words), - $type, - $fields, - $terms, - $sort_days, - $sort_key, - $topic_id, - implode(',', $ex_fid_ary), - $post_visibility, - implode(',', $author_ary) - ); - - /** - * Allow changing the search_key for cached results - * - * @event core.search_mysql_by_keyword_modify_search_key - * @var array search_key_array Array with search parameters to generate the search_key - * @var string type Searching type ('posts', 'topics') - * @var string fields Searching fields ('titleonly', 'msgonly', 'firstpost', 'all') - * @var string terms Searching terms ('all', 'any') - * @var int sort_days Time, in days, of the oldest possible post to list - * @var string sort_key The sort type used from the possible sort types - * @var int topic_id Limit the search to this topic_id only - * @var array ex_fid_ary Which forums not to search on - * @var string post_visibility Post visibility data - * @var array author_ary Array of user_id containing the users to filter the results to - * @since 3.1.7-RC1 - */ - $vars = array( - 'search_key_array', - 'type', - 'fields', - 'terms', - 'sort_days', - 'sort_key', - 'topic_id', - 'ex_fid_ary', - 'post_visibility', - 'author_ary', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_mysql_by_keyword_modify_search_key', compact($vars))); - - $search_key = md5(implode('#', $search_key_array)); - - if ($start < 0) - { - $start = 0; - } - - // try reading the results from cache - $result_count = 0; - if ($this->obtain_ids($search_key, $result_count, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE) - { - return $result_count; - } - - $id_ary = array(); - - $join_topic = ($type == 'posts') ? false : true; - - // Build sql strings for sorting - $sql_sort = $sort_by_sql[$sort_key] . (($sort_dir == 'a') ? ' ASC' : ' DESC'); - $sql_sort_table = $sql_sort_join = ''; - - switch ($sql_sort[0]) - { - case 'u': - $sql_sort_table = USERS_TABLE . ' u, '; - $sql_sort_join = ($type == 'posts') ? ' AND u.user_id = p.poster_id ' : ' AND u.user_id = t.topic_poster '; - break; - - case 't': - $join_topic = true; - break; - - case 'f': - $sql_sort_table = FORUMS_TABLE . ' f, '; - $sql_sort_join = ' AND f.forum_id = p.forum_id '; - break; - } - - // Build some display specific sql strings - switch ($fields) - { - case 'titleonly': - $sql_match = 'p.post_subject'; - $sql_match_where = ' AND p.post_id = t.topic_first_post_id'; - $join_topic = true; - break; - - case 'msgonly': - $sql_match = 'p.post_text'; - $sql_match_where = ''; - break; - - case 'firstpost': - $sql_match = 'p.post_subject, p.post_text'; - $sql_match_where = ' AND p.post_id = t.topic_first_post_id'; - $join_topic = true; - break; - - default: - $sql_match = 'p.post_subject, p.post_text'; - $sql_match_where = ''; - break; - } - - $search_query = $this->search_query; - - /** - * Allow changing the query used to search for posts using fulltext_mysql - * - * @event core.search_mysql_keywords_main_query_before - * @var string search_query The parsed keywords used for this search - * @var int result_count The previous result count for the format of the query. - * Set to 0 to force a re-count - * @var bool join_topic Weather or not TOPICS_TABLE should be CROSS JOIN'ED - * @var array author_ary Array of user_id containing the users to filter the results to - * @var string author_name An extra username to search on (!empty(author_ary) must be true, to be relevant) - * @var array ex_fid_ary Which forums not to search on - * @var int topic_id Limit the search to this topic_id only - * @var string sql_sort_table Extra tables to include in the SQL query. - * Used in conjunction with sql_sort_join - * @var string sql_sort_join SQL conditions to join all the tables used together. - * Used in conjunction with sql_sort_table - * @var int sort_days Time, in days, of the oldest possible post to list - * @var string sql_match Which columns to do the search on. - * @var string sql_match_where Extra conditions to use to properly filter the matching process - * @var string sort_by_sql The possible predefined sort types - * @var string sort_key The sort type used from the possible sort types - * @var string sort_dir "a" for ASC or "d" dor DESC for the sort order used - * @var string sql_sort The result SQL when processing sort_by_sql + sort_key + sort_dir - * @var int start How many posts to skip in the search results (used for pagination) - * @since 3.1.5-RC1 - */ - $vars = array( - 'search_query', - 'result_count', - 'join_topic', - 'author_ary', - 'author_name', - 'ex_fid_ary', - 'topic_id', - 'sql_sort_table', - 'sql_sort_join', - 'sort_days', - 'sql_match', - 'sql_match_where', - 'sort_by_sql', - 'sort_key', - 'sort_dir', - 'sql_sort', - 'start', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_mysql_keywords_main_query_before', compact($vars))); - - $sql_select = (!$result_count) ? 'SQL_CALC_FOUND_ROWS ' : ''; - $sql_select = ($type == 'posts') ? $sql_select . 'p.post_id' : 'DISTINCT ' . $sql_select . 't.topic_id'; - $sql_from = ($join_topic) ? TOPICS_TABLE . ' t, ' : ''; - $field = ($type == 'posts') ? 'post_id' : 'topic_id'; - if (count($author_ary) && $author_name) - { - // first one matches post of registered users, second one guests and deleted users - $sql_author = ' AND (' . $this->db->sql_in_set('p.poster_id', array_diff($author_ary, array(ANONYMOUS)), false, true) . ' OR p.post_username ' . $author_name . ')'; - } - else if (count($author_ary)) - { - $sql_author = ' AND ' . $this->db->sql_in_set('p.poster_id', $author_ary); - } - else - { - $sql_author = ''; - } - - $sql_where_options = $sql_sort_join; - $sql_where_options .= ($topic_id) ? ' AND p.topic_id = ' . $topic_id : ''; - $sql_where_options .= ($join_topic) ? ' AND t.topic_id = p.topic_id' : ''; - $sql_where_options .= (count($ex_fid_ary)) ? ' AND ' . $this->db->sql_in_set('p.forum_id', $ex_fid_ary, true) : ''; - $sql_where_options .= ' AND ' . $post_visibility; - $sql_where_options .= $sql_author; - $sql_where_options .= ($sort_days) ? ' AND p.post_time >= ' . (time() - ($sort_days * 86400)) : ''; - $sql_where_options .= $sql_match_where; - - $sql = "SELECT $sql_select - FROM $sql_from$sql_sort_table" . POSTS_TABLE . " p - WHERE MATCH ($sql_match) AGAINST ('" . $this->db->sql_escape(htmlspecialchars_decode($this->search_query)) . "' IN BOOLEAN MODE) - $sql_where_options - ORDER BY $sql_sort"; - $this->db->sql_return_on_error(true); - $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); - - while ($row = $this->db->sql_fetchrow($result)) - { - $id_ary[] = (int) $row[$field]; - } - $this->db->sql_freeresult($result); - - $id_ary = array_unique($id_ary); - - // if the total result count is not cached yet, retrieve it from the db - if (!$result_count && count($id_ary)) - { - $sql_found_rows = 'SELECT FOUND_ROWS() as result_count'; - $result = $this->db->sql_query($sql_found_rows); - $result_count = (int) $this->db->sql_fetchfield('result_count'); - $this->db->sql_freeresult($result); - - if (!$result_count) - { - return false; - } - } - - if ($start >= $result_count) - { - $start = floor(($result_count - 1) / $per_page) * $per_page; - - $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); - - while ($row = $this->db->sql_fetchrow($result)) - { - $id_ary[] = (int) $row[$field]; - } - $this->db->sql_freeresult($result); - - $id_ary = array_unique($id_ary); - } - - // store the ids, from start on then delete anything that isn't on the current page because we only need ids for one page - $this->save_ids($search_key, implode(' ', $this->split_words), $author_ary, $result_count, $id_ary, $start, $sort_dir); - $id_ary = array_slice($id_ary, 0, (int) $per_page); - - return $result_count; - } - - /** - * Performs a search on an author's posts without caring about message contents. Depends on display specific params - * - * @param string $type contains either posts or topics depending on what should be searched for - * @param boolean $firstpost_only if true, only topic starting posts will be considered - * @param array $sort_by_sql contains SQL code for the ORDER BY part of a query - * @param string $sort_key is the key of $sort_by_sql for the selected sorting - * @param string $sort_dir is either a or d representing ASC and DESC - * @param string $sort_days specifies the maximum amount of days a post may be old - * @param array $ex_fid_ary specifies an array of forum ids which should not be searched - * @param string $post_visibility specifies which types of posts the user can view in which forums - * @param int $topic_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched - * @param array $author_ary an array of author ids - * @param string $author_name specifies the author match, when ANONYMOUS is also a search-match - * @param array &$id_ary passed by reference, to be filled with ids for the page specified by $start and $per_page, should be ordered - * @param int $start indicates the first index of the page - * @param int $per_page number of ids each page is supposed to contain - * @return boolean|int total number of results - */ - public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page) - { - // No author? No posts - if (!count($author_ary)) - { - return 0; - } - - // generate a search_key from all the options to identify the results - $search_key_array = array( - '', - $type, - ($firstpost_only) ? 'firstpost' : '', - '', - '', - $sort_days, - $sort_key, - $topic_id, - implode(',', $ex_fid_ary), - $post_visibility, - implode(',', $author_ary), - $author_name, - ); - - /** - * Allow changing the search_key for cached results - * - * @event core.search_mysql_by_author_modify_search_key - * @var array search_key_array Array with search parameters to generate the search_key - * @var string type Searching type ('posts', 'topics') - * @var boolean firstpost_only Flag indicating if only topic starting posts are considered - * @var int sort_days Time, in days, of the oldest possible post to list - * @var string sort_key The sort type used from the possible sort types - * @var int topic_id Limit the search to this topic_id only - * @var array ex_fid_ary Which forums not to search on - * @var string post_visibility Post visibility data - * @var array author_ary Array of user_id containing the users to filter the results to - * @var string author_name The username to search on - * @since 3.1.7-RC1 - */ - $vars = array( - 'search_key_array', - 'type', - 'firstpost_only', - 'sort_days', - 'sort_key', - 'topic_id', - 'ex_fid_ary', - 'post_visibility', - 'author_ary', - 'author_name', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_mysql_by_author_modify_search_key', compact($vars))); - - $search_key = md5(implode('#', $search_key_array)); - - if ($start < 0) - { - $start = 0; - } - - // try reading the results from cache - $result_count = 0; - if ($this->obtain_ids($search_key, $result_count, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE) - { - return $result_count; - } - - $id_ary = array(); - - // Create some display specific sql strings - if ($author_name) - { - // first one matches post of registered users, second one guests and deleted users - $sql_author = '(' . $this->db->sql_in_set('p.poster_id', array_diff($author_ary, array(ANONYMOUS)), false, true) . ' OR p.post_username ' . $author_name . ')'; - } - else - { - $sql_author = $this->db->sql_in_set('p.poster_id', $author_ary); - } - $sql_fora = (count($ex_fid_ary)) ? ' AND ' . $this->db->sql_in_set('p.forum_id', $ex_fid_ary, true) : ''; - $sql_topic_id = ($topic_id) ? ' AND p.topic_id = ' . (int) $topic_id : ''; - $sql_time = ($sort_days) ? ' AND p.post_time >= ' . (time() - ($sort_days * 86400)) : ''; - $sql_firstpost = ($firstpost_only) ? ' AND p.post_id = t.topic_first_post_id' : ''; - - // Build sql strings for sorting - $sql_sort = $sort_by_sql[$sort_key] . (($sort_dir == 'a') ? ' ASC' : ' DESC'); - $sql_sort_table = $sql_sort_join = ''; - switch ($sql_sort[0]) - { - case 'u': - $sql_sort_table = USERS_TABLE . ' u, '; - $sql_sort_join = ($type == 'posts') ? ' AND u.user_id = p.poster_id ' : ' AND u.user_id = t.topic_poster '; - break; - - case 't': - $sql_sort_table = ($type == 'posts' && !$firstpost_only) ? TOPICS_TABLE . ' t, ' : ''; - $sql_sort_join = ($type == 'posts' && !$firstpost_only) ? ' AND t.topic_id = p.topic_id ' : ''; - break; - - case 'f': - $sql_sort_table = FORUMS_TABLE . ' f, '; - $sql_sort_join = ' AND f.forum_id = p.forum_id '; - break; - } - - $m_approve_fid_sql = ' AND ' . $post_visibility; - - /** - * Allow changing the query used to search for posts by author in fulltext_mysql - * - * @event core.search_mysql_author_query_before - * @var int result_count The previous result count for the format of the query. - * Set to 0 to force a re-count - * @var string sql_sort_table CROSS JOIN'ed table to allow doing the sort chosen - * @var string sql_sort_join Condition to define how to join the CROSS JOIN'ed table specifyed in sql_sort_table - * @var string type Either "posts" or "topics" specifying the type of search being made - * @var array author_ary Array of user_id containing the users to filter the results to - * @var string author_name An extra username to search on - * @var string sql_author SQL WHERE condition for the post author ids - * @var int topic_id Limit the search to this topic_id only - * @var string sql_topic_id SQL of topic_id - * @var string sort_by_sql The possible predefined sort types - * @var string sort_key The sort type used from the possible sort types - * @var string sort_dir "a" for ASC or "d" dor DESC for the sort order used - * @var string sql_sort The result SQL when processing sort_by_sql + sort_key + sort_dir - * @var string sort_days Time, in days, that the oldest post showing can have - * @var string sql_time The SQL to search on the time specifyed by sort_days - * @var bool firstpost_only Wether or not to search only on the first post of the topics - * @var string sql_firstpost The SQL with the conditions to join the tables when using firstpost_only - * @var array ex_fid_ary Forum ids that must not be searched on - * @var array sql_fora SQL query for ex_fid_ary - * @var string m_approve_fid_sql WHERE clause condition on post_visibility restrictions - * @var int start How many posts to skip in the search results (used for pagination) - * @since 3.1.5-RC1 - */ - $vars = array( - 'result_count', - 'sql_sort_table', - 'sql_sort_join', - 'type', - 'author_ary', - 'author_name', - 'sql_author', - 'topic_id', - 'sql_topic_id', - 'sort_by_sql', - 'sort_key', - 'sort_dir', - 'sql_sort', - 'sort_days', - 'sql_time', - 'firstpost_only', - 'sql_firstpost', - 'ex_fid_ary', - 'sql_fora', - 'm_approve_fid_sql', - 'start', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_mysql_author_query_before', compact($vars))); - - // If the cache was completely empty count the results - $calc_results = ($result_count) ? '' : 'SQL_CALC_FOUND_ROWS '; - - // Build the query for really selecting the post_ids - if ($type == 'posts') - { - $sql = "SELECT {$calc_results}p.post_id - FROM " . $sql_sort_table . POSTS_TABLE . ' p' . (($firstpost_only) ? ', ' . TOPICS_TABLE . ' t ' : ' ') . " - WHERE $sql_author - $sql_topic_id - $sql_firstpost - $m_approve_fid_sql - $sql_fora - $sql_sort_join - $sql_time - ORDER BY $sql_sort"; - $field = 'post_id'; - } - else - { - $sql = "SELECT {$calc_results}t.topic_id - FROM " . $sql_sort_table . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p - WHERE $sql_author - $sql_topic_id - $sql_firstpost - $m_approve_fid_sql - $sql_fora - AND t.topic_id = p.topic_id - $sql_sort_join - $sql_time - GROUP BY t.topic_id - ORDER BY $sql_sort"; - $field = 'topic_id'; - } - - // Only read one block of posts from the db and then cache it - $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); - - while ($row = $this->db->sql_fetchrow($result)) - { - $id_ary[] = (int) $row[$field]; - } - $this->db->sql_freeresult($result); - - // retrieve the total result count if needed - if (!$result_count) - { - $sql_found_rows = 'SELECT FOUND_ROWS() as result_count'; - $result = $this->db->sql_query($sql_found_rows); - $result_count = (int) $this->db->sql_fetchfield('result_count'); - $this->db->sql_freeresult($result); - - if (!$result_count) - { - return false; - } - } - - if ($start >= $result_count) - { - $start = floor(($result_count - 1) / $per_page) * $per_page; - - $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); - while ($row = $this->db->sql_fetchrow($result)) - { - $id_ary[] = (int) $row[$field]; - } - $this->db->sql_freeresult($result); - - $id_ary = array_unique($id_ary); - } - - if (count($id_ary)) - { - $this->save_ids($search_key, '', $author_ary, $result_count, $id_ary, $start, $sort_dir); - $id_ary = array_slice($id_ary, 0, $per_page); - - return $result_count; - } - return false; - } - - /** - * Destroys cached search results, that contained one of the new words in a post so the results won't be outdated - * - * @param string $mode contains the post mode: edit, post, reply, quote ... - * @param int $post_id contains the post id of the post to index - * @param string $message contains the post text of the post - * @param string $subject contains the subject of the post to index - * @param int $poster_id contains the user id of the poster - * @param int $forum_id contains the forum id of parent forum of the post - */ - public function index($mode, $post_id, &$message, &$subject, $poster_id, $forum_id) - { - // Split old and new post/subject to obtain array of words - $split_text = $this->split_message($message); - $split_title = ($subject) ? $this->split_message($subject) : array(); - - $words = array_unique(array_merge($split_text, $split_title)); - - /** - * Event to modify method arguments and words before the MySQL search index is updated - * - * @event core.search_mysql_index_before - * @var string mode Contains the post mode: edit, post, reply, quote - * @var int post_id The id of the post which is modified/created - * @var string message New or updated post content - * @var string subject New or updated post subject - * @var int poster_id Post author's user id - * @var int forum_id The id of the forum in which the post is located - * @var array words List of words added to the index - * @var array split_text Array of words from the message - * @var array split_title Array of words from the title - * @since 3.2.3-RC1 - */ - $vars = array( - 'mode', - 'post_id', - 'message', - 'subject', - 'poster_id', - 'forum_id', - 'words', - 'split_text', - 'split_title', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_mysql_index_before', compact($vars))); - - unset($split_text); - unset($split_title); - - // destroy cached search results containing any of the words removed or added - $this->destroy_cache($words, array($poster_id)); - - unset($words); - } - - /** - * Destroy cached results, that might be outdated after deleting a post - */ - public function index_remove($post_ids, $author_ids, $forum_ids) - { - $this->destroy_cache(array(), array_unique($author_ids)); - } - - /** - * Destroy old cache entries - */ - public function tidy() - { - // destroy too old cached search results - $this->destroy_cache(array()); - - $this->config->set('search_last_gc', time(), false); - } - - /** - * Create fulltext index - * - * @return string|bool error string is returned incase of errors otherwise false - */ - public function create_index($acp_module, $u_action) - { - // Make sure we can actually use MySQL with fulltext indexes - if ($error = $this->init()) - { - return $error; - } - - if (empty($this->stats)) - { - $this->get_stats(); - } - - $alter_list = array(); - - if (!isset($this->stats['post_subject'])) - { - $alter_entry = array(); - $alter_entry[] = 'MODIFY post_subject varchar(255) COLLATE utf8_unicode_ci DEFAULT \'\' NOT NULL'; - $alter_entry[] = 'ADD FULLTEXT (post_subject)'; - $alter_list[] = $alter_entry; - } - - if (!isset($this->stats['post_content'])) - { - $alter_entry = array(); - $alter_entry[] = 'MODIFY post_text mediumtext COLLATE utf8_unicode_ci NOT NULL'; - $alter_entry[] = 'ADD FULLTEXT post_content (post_text, post_subject)'; - $alter_list[] = $alter_entry; - } - - $sql_queries = []; - - foreach ($alter_list as $alter) - { - $sql_queries[] = 'ALTER TABLE ' . POSTS_TABLE . ' ' . implode(', ', $alter); - } - - if (!isset($this->stats['post_text'])) - { - $sql_queries[] = 'ALTER TABLE ' . POSTS_TABLE . ' ADD FULLTEXT post_text (post_text)'; - } - - $stats = $this->stats; - - /** - * Event to modify SQL queries before the MySQL search index is created - * - * @event core.search_mysql_create_index_before - * @var array sql_queries Array with queries for creating the search index - * @var array stats Array with statistics of the current index (read only) - * @since 3.2.3-RC1 - */ - $vars = array( - 'sql_queries', - 'stats', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_mysql_create_index_before', compact($vars))); - - foreach ($sql_queries as $sql_query) - { - $this->db->sql_query($sql_query); - } - - $this->db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE); - - return false; - } - - /** - * Drop fulltext index - * - * @return string|bool error string is returned incase of errors otherwise false - */ - public function delete_index($acp_module, $u_action) - { - // Make sure we can actually use MySQL with fulltext indexes - if ($error = $this->init()) - { - return $error; - } - - if (empty($this->stats)) - { - $this->get_stats(); - } - - $alter = array(); - - if (isset($this->stats['post_subject'])) - { - $alter[] = 'DROP INDEX post_subject'; - } - - if (isset($this->stats['post_content'])) - { - $alter[] = 'DROP INDEX post_content'; - } - - if (isset($this->stats['post_text'])) - { - $alter[] = 'DROP INDEX post_text'; - } - - $sql_queries = []; - - if (count($alter)) - { - $sql_queries[] = 'ALTER TABLE ' . POSTS_TABLE . ' ' . implode(', ', $alter); - } - - $stats = $this->stats; - - /** - * Event to modify SQL queries before the MySQL search index is deleted - * - * @event core.search_mysql_delete_index_before - * @var array sql_queries Array with queries for deleting the search index - * @var array stats Array with statistics of the current index (read only) - * @since 3.2.3-RC1 - */ - $vars = array( - 'sql_queries', - 'stats', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_mysql_delete_index_before', compact($vars))); - - foreach ($sql_queries as $sql_query) - { - $this->db->sql_query($sql_query); - } - - $this->db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE); - - return false; - } - - /** - * Returns true if both FULLTEXT indexes exist - */ - public function index_created() - { - if (empty($this->stats)) - { - $this->get_stats(); - } - - return isset($this->stats['post_subject']) && isset($this->stats['post_content']) && isset($this->stats['post_text']); - } - - /** - * Returns an associative array containing information about the indexes - */ - public function index_stats() - { - if (empty($this->stats)) - { - $this->get_stats(); - } - - return array( - $this->user->lang['FULLTEXT_MYSQL_TOTAL_POSTS'] => ($this->index_created()) ? $this->stats['total_posts'] : 0, - ); - } - - /** - * Computes the stats and store them in the $this->stats associative array - */ - protected function get_stats() - { - if (strpos($this->db->get_sql_layer(), 'mysql') === false) - { - $this->stats = array(); - return; - } - - $sql = 'SHOW INDEX - FROM ' . POSTS_TABLE; - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - // deal with older MySQL versions which didn't use Index_type - $index_type = (isset($row['Index_type'])) ? $row['Index_type'] : $row['Comment']; - - if ($index_type == 'FULLTEXT') - { - if ($row['Key_name'] == 'post_subject') - { - $this->stats['post_subject'] = $row; - } - else if ($row['Key_name'] == 'post_text') - { - $this->stats['post_text'] = $row; - } - else if ($row['Key_name'] == 'post_content') - { - $this->stats['post_content'] = $row; - } - } - } - $this->db->sql_freeresult($result); - - $this->stats['total_posts'] = empty($this->stats) ? 0 : $this->db->get_estimated_row_count(POSTS_TABLE); - } - - /** - * Display a note, that UTF-8 support is not available with certain versions of PHP - * - * @return associative array containing template and config variables - */ - public function acp() - { - $tpl = ' -
-

' . $this->user->lang['FULLTEXT_MYSQL_MIN_SEARCH_CHARS_EXPLAIN'] . '
-
' . $this->config['fulltext_mysql_min_word_len'] . '
-
-
-

' . $this->user->lang['FULLTEXT_MYSQL_MAX_SEARCH_CHARS_EXPLAIN'] . '
-
' . $this->config['fulltext_mysql_max_word_len'] . '
-
- '; - - // These are fields required in the config table - return array( - 'tpl' => $tpl, - 'config' => array() - ); - } -} diff --git a/install/update/new/phpbb/search/fulltext_native.php b/install/update/new/phpbb/search/fulltext_native.php deleted file mode 100644 index 23460d3..0000000 --- a/install/update/new/phpbb/search/fulltext_native.php +++ /dev/null @@ -1,2068 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\search; - -/** -* phpBB's own db driven fulltext search, version 2 -*/ -class fulltext_native extends \phpbb\search\base -{ - const UTF8_HANGUL_FIRST = "\xEA\xB0\x80"; - const UTF8_HANGUL_LAST = "\xED\x9E\xA3"; - const UTF8_CJK_FIRST = "\xE4\xB8\x80"; - const UTF8_CJK_LAST = "\xE9\xBE\xBB"; - const UTF8_CJK_B_FIRST = "\xF0\xA0\x80\x80"; - const UTF8_CJK_B_LAST = "\xF0\xAA\x9B\x96"; - - /** - * Associative array holding index stats - * @var array - */ - protected $stats = array(); - - /** - * Associative array stores the min and max word length to be searched - * @var array - */ - protected $word_length = array(); - - /** - * Contains tidied search query. - * Operators are prefixed in search query and common words excluded - * @var string - */ - protected $search_query; - - /** - * Contains common words. - * Common words are words with length less/more than min/max length - * @var array - */ - protected $common_words = array(); - - /** - * Post ids of posts containing words that are to be included - * @var array - */ - protected $must_contain_ids = array(); - - /** - * Post ids of posts containing words that should not be included - * @var array - */ - protected $must_not_contain_ids = array(); - - /** - * Post ids of posts containing at least one word that needs to be excluded - * @var array - */ - protected $must_exclude_one_ids = array(); - - /** - * Relative path to board root - * @var string - */ - protected $phpbb_root_path; - - /** - * PHP Extension - * @var string - */ - protected $php_ext; - - /** - * Config object - * @var \phpbb\config\config - */ - protected $config; - - /** - * Database connection - * @var \phpbb\db\driver\driver_interface - */ - protected $db; - - /** - * phpBB event dispatcher object - * @var \phpbb\event\dispatcher_interface - */ - protected $phpbb_dispatcher; - - /** - * User object - * @var \phpbb\user - */ - protected $user; - - /** - * Initialises the fulltext_native search backend with min/max word length - * - * @param boolean|string &$error is passed by reference and should either be set to false on success or an error message on failure - * @param string $phpbb_root_path phpBB root path - * @param string $phpEx PHP file extension - * @param \phpbb\auth\auth $auth Auth object - * @param \phpbb\config\config $config Config object - * @param \phpbb\db\driver\driver_interface $db Database object - * @param \phpbb\user $user User object - * @param \phpbb\event\dispatcher_interface $phpbb_dispatcher Event dispatcher object - */ - public function __construct(&$error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher) - { - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $phpEx; - $this->config = $config; - $this->db = $db; - $this->phpbb_dispatcher = $phpbb_dispatcher; - $this->user = $user; - - $this->word_length = array('min' => (int) $this->config['fulltext_native_min_chars'], 'max' => (int) $this->config['fulltext_native_max_chars']); - - /** - * Load the UTF tools - */ - if (!function_exists('utf8_decode_ncr')) - { - include($this->phpbb_root_path . 'includes/utf/utf_tools.' . $this->php_ext); - } - - $error = false; - } - - /** - * Returns the name of this search backend to be displayed to administrators - * - * @return string Name - */ - public function get_name() - { - return 'phpBB Native Fulltext'; - } - - /** - * Returns the search_query - * - * @return string search query - */ - public function get_search_query() - { - return $this->search_query; - } - - /** - * Returns the common_words array - * - * @return array common words that are ignored by search backend - */ - public function get_common_words() - { - return $this->common_words; - } - - /** - * Returns the word_length array - * - * @return array min and max word length for searching - */ - public function get_word_length() - { - return $this->word_length; - } - - /** - * This function fills $this->search_query with the cleaned user search query - * - * If $terms is 'any' then the words will be extracted from the search query - * and combined with | inside brackets. They will afterwards be treated like - * an standard search query. - * - * Then it analyses the query and fills the internal arrays $must_not_contain_ids, - * $must_contain_ids and $must_exclude_one_ids which are later used by keyword_search() - * - * @param string $keywords contains the search query string as entered by the user - * @param string $terms is either 'all' (use search query as entered, default words to 'must be contained in post') - * or 'any' (find all posts containing at least one of the given words) - * @return boolean false if no valid keywords were found and otherwise true - */ - public function split_keywords($keywords, $terms) - { - $tokens = '+-|()* '; - - $keywords = trim($this->cleanup($keywords, $tokens)); - - // allow word|word|word without brackets - if ((strpos($keywords, ' ') === false) && (strpos($keywords, '|') !== false) && (strpos($keywords, '(') === false)) - { - $keywords = '(' . $keywords . ')'; - } - - $open_bracket = $space = false; - for ($i = 0, $n = strlen($keywords); $i < $n; $i++) - { - if ($open_bracket !== false) - { - switch ($keywords[$i]) - { - case ')': - if ($open_bracket + 1 == $i) - { - $keywords[$i - 1] = '|'; - $keywords[$i] = '|'; - } - $open_bracket = false; - break; - case '(': - $keywords[$i] = '|'; - break; - case '+': - case '-': - case ' ': - $keywords[$i] = '|'; - break; - case '*': - // $i can never be 0 here since $open_bracket is initialised to false - if (strpos($tokens, $keywords[$i - 1]) !== false && ($i + 1 === $n || strpos($tokens, $keywords[$i + 1]) !== false)) - { - $keywords[$i] = '|'; - } - break; - } - } - else - { - switch ($keywords[$i]) - { - case ')': - $keywords[$i] = ' '; - break; - case '(': - $open_bracket = $i; - $space = false; - break; - case '|': - $keywords[$i] = ' '; - break; - case '-': - case '+': - $space = $keywords[$i]; - break; - case ' ': - if ($space !== false) - { - $keywords[$i] = $space; - } - break; - default: - $space = false; - } - } - } - - if ($open_bracket !== false) - { - $keywords .= ')'; - } - - $match = array( - '# +#', - '#\|\|+#', - '#(\+|\-)(?:\+|\-)+#', - '#\(\|#', - '#\|\)#', - ); - $replace = array( - ' ', - '|', - '$1', - '(', - ')', - ); - - $keywords = preg_replace($match, $replace, $keywords); - $num_keywords = count(explode(' ', $keywords)); - - // We limit the number of allowed keywords to minimize load on the database - if ($this->config['max_num_search_keywords'] && $num_keywords > $this->config['max_num_search_keywords']) - { - trigger_error($this->user->lang('MAX_NUM_SEARCH_KEYWORDS_REFINE', (int) $this->config['max_num_search_keywords'], $num_keywords)); - } - - // $keywords input format: each word separated by a space, words in a bracket are not separated - - // the user wants to search for any word, convert the search query - if ($terms == 'any') - { - $words = array(); - - preg_match_all('#([^\\s+\\-|()]+)(?:$|[\\s+\\-|()])#u', $keywords, $words); - if (count($words[1])) - { - $keywords = '(' . implode('|', $words[1]) . ')'; - } - } - - // Remove non trailing wildcards from each word to prevent a full table scan (it's now using the database index) - $match = '#\*(?!$|\s)#'; - $replace = '$1'; - $keywords = preg_replace($match, $replace, $keywords); - - // Only allow one wildcard in the search query to limit the database load - $match = '#\*#'; - $replace = '$1'; - $count_wildcards = substr_count($keywords, '*'); - - // Reverse the string to remove all wildcards except the first one - $keywords = strrev(preg_replace($match, $replace, strrev($keywords), $count_wildcards - 1)); - unset($count_wildcards); - - // set the search_query which is shown to the user - $this->search_query = $keywords; - - $exact_words = array(); - preg_match_all('#([^\\s+\\-|()]+)(?:$|[\\s+\\-|()])#u', $keywords, $exact_words); - $exact_words = $exact_words[1]; - - $common_ids = $words = array(); - - if (count($exact_words)) - { - $sql = 'SELECT word_id, word_text, word_common - FROM ' . SEARCH_WORDLIST_TABLE . ' - WHERE ' . $this->db->sql_in_set('word_text', $exact_words) . ' - ORDER BY word_count ASC'; - $result = $this->db->sql_query($sql); - - // store an array of words and ids, remove common words - while ($row = $this->db->sql_fetchrow($result)) - { - if ($row['word_common']) - { - $this->common_words[] = $row['word_text']; - $common_ids[$row['word_text']] = (int) $row['word_id']; - continue; - } - - $words[$row['word_text']] = (int) $row['word_id']; - } - $this->db->sql_freeresult($result); - } - - // Handle +, - without preceding whitespace character - $match = array('#(\S)\+#', '#(\S)-#'); - $replace = array('$1 +', '$1 +'); - - $keywords = preg_replace($match, $replace, $keywords); - - // now analyse the search query, first split it using the spaces - $query = explode(' ', $keywords); - - $this->must_contain_ids = array(); - $this->must_not_contain_ids = array(); - $this->must_exclude_one_ids = array(); - - foreach ($query as $word) - { - if (empty($word)) - { - continue; - } - - // words which should not be included - if ($word[0] == '-') - { - $word = substr($word, 1); - - // a group of which at least one may not be in the resulting posts - if ($word[0] == '(') - { - $word = array_unique(explode('|', substr($word, 1, -1))); - $mode = 'must_exclude_one'; - } - // one word which should not be in the resulting posts - else - { - $mode = 'must_not_contain'; - } - $ignore_no_id = true; - } - // words which have to be included - else - { - // no prefix is the same as a +prefix - if ($word[0] == '+') - { - $word = substr($word, 1); - } - - // a group of words of which at least one word should be in every resulting post - if ($word[0] == '(') - { - $word = array_unique(explode('|', substr($word, 1, -1))); - } - $ignore_no_id = false; - $mode = 'must_contain'; - } - - if (empty($word)) - { - continue; - } - - // if this is an array of words then retrieve an id for each - if (is_array($word)) - { - $non_common_words = array(); - $id_words = array(); - foreach ($word as $i => $word_part) - { - if (strpos($word_part, '*') !== false) - { - $len = utf8_strlen(str_replace('*', '', $word_part)); - if ($len >= $this->word_length['min'] && $len <= $this->word_length['max']) - { - $id_words[] = '\'' . $this->db->sql_escape(str_replace('*', '%', $word_part)) . '\''; - $non_common_words[] = $word_part; - } - else - { - $this->common_words[] = $word_part; - } - } - else if (isset($words[$word_part])) - { - $id_words[] = $words[$word_part]; - $non_common_words[] = $word_part; - } - else - { - $len = utf8_strlen($word_part); - if ($len < $this->word_length['min'] || $len > $this->word_length['max']) - { - $this->common_words[] = $word_part; - } - } - } - if (count($id_words)) - { - sort($id_words); - if (count($id_words) > 1) - { - $this->{$mode . '_ids'}[] = $id_words; - } - else - { - $mode = ($mode == 'must_exclude_one') ? 'must_not_contain' : $mode; - $this->{$mode . '_ids'}[] = $id_words[0]; - } - } - // throw an error if we shall not ignore unexistant words - else if (!$ignore_no_id && count($non_common_words)) - { - trigger_error(sprintf($this->user->lang['WORDS_IN_NO_POST'], implode($this->user->lang['COMMA_SEPARATOR'], $non_common_words))); - } - unset($non_common_words); - } - // else we only need one id - else if (($wildcard = strpos($word, '*') !== false) || isset($words[$word])) - { - if ($wildcard) - { - $len = utf8_strlen(str_replace('*', '', $word)); - if ($len >= $this->word_length['min'] && $len <= $this->word_length['max']) - { - $this->{$mode . '_ids'}[] = '\'' . $this->db->sql_escape(str_replace('*', '%', $word)) . '\''; - } - else - { - $this->common_words[] = $word; - } - } - else - { - $this->{$mode . '_ids'}[] = $words[$word]; - } - } - else - { - if (!isset($common_ids[$word])) - { - $len = utf8_strlen($word); - if ($len < $this->word_length['min'] || $len > $this->word_length['max']) - { - $this->common_words[] = $word; - } - } - } - } - - // Return true if all words are not common words - if (count($exact_words) - count($this->common_words) > 0) - { - return true; - } - return false; - } - - /** - * Performs a search on keywords depending on display specific params. You have to run split_keywords() first - * - * @param string $type contains either posts or topics depending on what should be searched for - * @param string $fields contains either titleonly (topic titles should be searched), msgonly (only message bodies should be searched), firstpost (only subject and body of the first post should be searched) or all (all post bodies and subjects should be searched) - * @param string $terms is either 'all' (use query as entered, words without prefix should default to "have to be in field") or 'any' (ignore search query parts and just return all posts that contain any of the specified words) - * @param array $sort_by_sql contains SQL code for the ORDER BY part of a query - * @param string $sort_key is the key of $sort_by_sql for the selected sorting - * @param string $sort_dir is either a or d representing ASC and DESC - * @param string $sort_days specifies the maximum amount of days a post may be old - * @param array $ex_fid_ary specifies an array of forum ids which should not be searched - * @param string $post_visibility specifies which types of posts the user can view in which forums - * @param int $topic_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched - * @param array $author_ary an array of author ids if the author should be ignored during the search the array is empty - * @param string $author_name specifies the author match, when ANONYMOUS is also a search-match - * @param array &$id_ary passed by reference, to be filled with ids for the page specified by $start and $per_page, should be ordered - * @param int $start indicates the first index of the page - * @param int $per_page number of ids each page is supposed to contain - * @return boolean|int total number of results - */ - public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page) - { - // No keywords? No posts. - if (empty($this->search_query)) - { - return false; - } - - // we can't search for negatives only - if (empty($this->must_contain_ids)) - { - return false; - } - - $must_contain_ids = $this->must_contain_ids; - $must_not_contain_ids = $this->must_not_contain_ids; - $must_exclude_one_ids = $this->must_exclude_one_ids; - - sort($must_contain_ids); - sort($must_not_contain_ids); - sort($must_exclude_one_ids); - - // generate a search_key from all the options to identify the results - $search_key_array = array( - serialize($must_contain_ids), - serialize($must_not_contain_ids), - serialize($must_exclude_one_ids), - $type, - $fields, - $terms, - $sort_days, - $sort_key, - $topic_id, - implode(',', $ex_fid_ary), - $post_visibility, - implode(',', $author_ary), - $author_name, - ); - - /** - * Allow changing the search_key for cached results - * - * @event core.search_native_by_keyword_modify_search_key - * @var array search_key_array Array with search parameters to generate the search_key - * @var array must_contain_ids Array with post ids of posts containing words that are to be included - * @var array must_not_contain_ids Array with post ids of posts containing words that should not be included - * @var array must_exclude_one_ids Array with post ids of posts containing at least one word that needs to be excluded - * @var string type Searching type ('posts', 'topics') - * @var string fields Searching fields ('titleonly', 'msgonly', 'firstpost', 'all') - * @var string terms Searching terms ('all', 'any') - * @var int sort_days Time, in days, of the oldest possible post to list - * @var string sort_key The sort type used from the possible sort types - * @var int topic_id Limit the search to this topic_id only - * @var array ex_fid_ary Which forums not to search on - * @var string post_visibility Post visibility data - * @var array author_ary Array of user_id containing the users to filter the results to - * @since 3.1.7-RC1 - */ - $vars = array( - 'search_key_array', - 'must_contain_ids', - 'must_not_contain_ids', - 'must_exclude_one_ids', - 'type', - 'fields', - 'terms', - 'sort_days', - 'sort_key', - 'topic_id', - 'ex_fid_ary', - 'post_visibility', - 'author_ary', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_native_by_keyword_modify_search_key', compact($vars))); - - $search_key = md5(implode('#', $search_key_array)); - - // try reading the results from cache - $total_results = 0; - if ($this->obtain_ids($search_key, $total_results, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE) - { - return $total_results; - } - - $id_ary = array(); - - $sql_where = array(); - $m_num = 0; - $w_num = 0; - - $sql_array = array( - 'SELECT' => ($type == 'posts') ? 'p.post_id' : 'p.topic_id', - 'FROM' => array( - SEARCH_WORDMATCH_TABLE => array(), - SEARCH_WORDLIST_TABLE => array(), - ), - 'LEFT_JOIN' => array(array( - 'FROM' => array(POSTS_TABLE => 'p'), - 'ON' => 'm0.post_id = p.post_id', - )), - ); - - $title_match = ''; - $left_join_topics = false; - $group_by = true; - // Build some display specific sql strings - switch ($fields) - { - case 'titleonly': - $title_match = 'title_match = 1'; - $group_by = false; - // no break - case 'firstpost': - $left_join_topics = true; - $sql_where[] = 'p.post_id = t.topic_first_post_id'; - break; - - case 'msgonly': - $title_match = 'title_match = 0'; - $group_by = false; - break; - } - - if ($type == 'topics') - { - $left_join_topics = true; - $group_by = true; - } - - /** - * @todo Add a query optimizer (handle stuff like "+(4|3) +4") - */ - - foreach ($this->must_contain_ids as $subquery) - { - if (is_array($subquery)) - { - $group_by = true; - - $word_id_sql = array(); - $word_ids = array(); - foreach ($subquery as $id) - { - if (is_string($id)) - { - $sql_array['LEFT_JOIN'][] = array( - 'FROM' => array(SEARCH_WORDLIST_TABLE => 'w' . $w_num), - 'ON' => "w$w_num.word_text LIKE $id" - ); - $word_ids[] = "w$w_num.word_id"; - - $w_num++; - } - else - { - $word_ids[] = $id; - } - } - - $sql_where[] = $this->db->sql_in_set("m$m_num.word_id", $word_ids); - - unset($word_id_sql); - unset($word_ids); - } - else if (is_string($subquery)) - { - $sql_array['FROM'][SEARCH_WORDLIST_TABLE][] = 'w' . $w_num; - - $sql_where[] = "w$w_num.word_text LIKE $subquery"; - $sql_where[] = "m$m_num.word_id = w$w_num.word_id"; - - $group_by = true; - $w_num++; - } - else - { - $sql_where[] = "m$m_num.word_id = $subquery"; - } - - $sql_array['FROM'][SEARCH_WORDMATCH_TABLE][] = 'm' . $m_num; - - if ($title_match) - { - $sql_where[] = "m$m_num.$title_match"; - } - - if ($m_num != 0) - { - $sql_where[] = "m$m_num.post_id = m0.post_id"; - } - $m_num++; - } - - foreach ($this->must_not_contain_ids as $key => $subquery) - { - if (is_string($subquery)) - { - $sql_array['LEFT_JOIN'][] = array( - 'FROM' => array(SEARCH_WORDLIST_TABLE => 'w' . $w_num), - 'ON' => "w$w_num.word_text LIKE $subquery" - ); - - $this->must_not_contain_ids[$key] = "w$w_num.word_id"; - - $group_by = true; - $w_num++; - } - } - - if (count($this->must_not_contain_ids)) - { - $sql_array['LEFT_JOIN'][] = array( - 'FROM' => array(SEARCH_WORDMATCH_TABLE => 'm' . $m_num), - 'ON' => $this->db->sql_in_set("m$m_num.word_id", $this->must_not_contain_ids) . (($title_match) ? " AND m$m_num.$title_match" : '') . " AND m$m_num.post_id = m0.post_id" - ); - - $sql_where[] = "m$m_num.word_id IS NULL"; - $m_num++; - } - - foreach ($this->must_exclude_one_ids as $ids) - { - $is_null_joins = array(); - foreach ($ids as $id) - { - if (is_string($id)) - { - $sql_array['LEFT_JOIN'][] = array( - 'FROM' => array(SEARCH_WORDLIST_TABLE => 'w' . $w_num), - 'ON' => "w$w_num.word_text LIKE $id" - ); - $id = "w$w_num.word_id"; - - $group_by = true; - $w_num++; - } - - $sql_array['LEFT_JOIN'][] = array( - 'FROM' => array(SEARCH_WORDMATCH_TABLE => 'm' . $m_num), - 'ON' => "m$m_num.word_id = $id AND m$m_num.post_id = m0.post_id" . (($title_match) ? " AND m$m_num.$title_match" : '') - ); - $is_null_joins[] = "m$m_num.word_id IS NULL"; - - $m_num++; - } - $sql_where[] = '(' . implode(' OR ', $is_null_joins) . ')'; - } - - $sql_where[] = $post_visibility; - - $search_query = $this->search_query; - $must_exclude_one_ids = $this->must_exclude_one_ids; - $must_not_contain_ids = $this->must_not_contain_ids; - $must_contain_ids = $this->must_contain_ids; - - $sql_sort_table = $sql_sort_join = $sql_match = $sql_match_where = $sql_sort = ''; - - /** - * Allow changing the query used for counting for posts using fulltext_native - * - * @event core.search_native_keywords_count_query_before - * @var string search_query The parsed keywords used for this search - * @var array must_not_contain_ids Ids that cannot be taken into account for the results - * @var array must_exclude_one_ids Ids that cannot be on the results - * @var array must_contain_ids Ids that must be on the results - * @var int total_results The previous result count for the format of the query - * Set to 0 to force a re-count - * @var array sql_array The data on how to search in the DB at this point - * @var bool left_join_topics Whether or not TOPICS_TABLE should be CROSS JOIN'ED - * @var array author_ary Array of user_id containing the users to filter the results to - * @var string author_name An extra username to search on (!empty(author_ary) must be true, to be relevant) - * @var array ex_fid_ary Which forums not to search on - * @var int topic_id Limit the search to this topic_id only - * @var string sql_sort_table Extra tables to include in the SQL query. - * Used in conjunction with sql_sort_join - * @var string sql_sort_join SQL conditions to join all the tables used together. - * Used in conjunction with sql_sort_table - * @var int sort_days Time, in days, of the oldest possible post to list - * @var string sql_where An array of the current WHERE clause conditions - * @var string sql_match Which columns to do the search on - * @var string sql_match_where Extra conditions to use to properly filter the matching process - * @var bool group_by Whether or not the SQL query requires a GROUP BY for the elements in the SELECT clause - * @var string sort_by_sql The possible predefined sort types - * @var string sort_key The sort type used from the possible sort types - * @var string sort_dir "a" for ASC or "d" dor DESC for the sort order used - * @var string sql_sort The result SQL when processing sort_by_sql + sort_key + sort_dir - * @var int start How many posts to skip in the search results (used for pagination) - * @since 3.1.5-RC1 - */ - $vars = array( - 'search_query', - 'must_not_contain_ids', - 'must_exclude_one_ids', - 'must_contain_ids', - 'total_results', - 'sql_array', - 'left_join_topics', - 'author_ary', - 'author_name', - 'ex_fid_ary', - 'topic_id', - 'sql_sort_table', - 'sql_sort_join', - 'sort_days', - 'sql_where', - 'sql_match', - 'sql_match_where', - 'group_by', - 'sort_by_sql', - 'sort_key', - 'sort_dir', - 'sql_sort', - 'start', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_native_keywords_count_query_before', compact($vars))); - - if ($topic_id) - { - $sql_where[] = 'p.topic_id = ' . $topic_id; - } - - if (count($author_ary)) - { - if ($author_name) - { - // first one matches post of registered users, second one guests and deleted users - $sql_author = '(' . $this->db->sql_in_set('p.poster_id', array_diff($author_ary, array(ANONYMOUS)), false, true) . ' OR p.post_username ' . $author_name . ')'; - } - else - { - $sql_author = $this->db->sql_in_set('p.poster_id', $author_ary); - } - $sql_where[] = $sql_author; - } - - if (count($ex_fid_ary)) - { - $sql_where[] = $this->db->sql_in_set('p.forum_id', $ex_fid_ary, true); - } - - if ($sort_days) - { - $sql_where[] = 'p.post_time >= ' . (time() - ($sort_days * 86400)); - } - - $sql_array['WHERE'] = implode(' AND ', $sql_where); - - $is_mysql = false; - // if the total result count is not cached yet, retrieve it from the db - if (!$total_results) - { - $sql = ''; - $sql_array_count = $sql_array; - - if ($left_join_topics) - { - $sql_array_count['LEFT_JOIN'][] = array( - 'FROM' => array(TOPICS_TABLE => 't'), - 'ON' => 'p.topic_id = t.topic_id' - ); - } - - switch ($this->db->get_sql_layer()) - { - case 'mysqli': - - // 3.x does not support SQL_CALC_FOUND_ROWS - // $sql_array['SELECT'] = 'SQL_CALC_FOUND_ROWS ' . $sql_array['SELECT']; - $is_mysql = true; - - break; - - case 'sqlite3': - $sql_array_count['SELECT'] = ($type == 'posts') ? 'DISTINCT p.post_id' : 'DISTINCT p.topic_id'; - $sql = 'SELECT COUNT(' . (($type == 'posts') ? 'post_id' : 'topic_id') . ') as total_results - FROM (' . $this->db->sql_build_query('SELECT', $sql_array_count) . ')'; - - // no break - - default: - $sql_array_count['SELECT'] = ($type == 'posts') ? 'COUNT(DISTINCT p.post_id) AS total_results' : 'COUNT(DISTINCT p.topic_id) AS total_results'; - $sql = (!$sql) ? $this->db->sql_build_query('SELECT', $sql_array_count) : $sql; - - $result = $this->db->sql_query($sql); - $total_results = (int) $this->db->sql_fetchfield('total_results'); - $this->db->sql_freeresult($result); - - if (!$total_results) - { - return false; - } - break; - } - - unset($sql_array_count, $sql); - } - - // Build sql strings for sorting - $sql_sort = $sort_by_sql[$sort_key] . (($sort_dir == 'a') ? ' ASC' : ' DESC'); - - switch ($sql_sort[0]) - { - case 'u': - $sql_array['FROM'][USERS_TABLE] = 'u'; - $sql_where[] = 'u.user_id = p.poster_id '; - break; - - case 't': - $left_join_topics = true; - break; - - case 'f': - $sql_array['FROM'][FORUMS_TABLE] = 'f'; - $sql_where[] = 'f.forum_id = p.forum_id'; - break; - } - - if ($left_join_topics) - { - $sql_array['LEFT_JOIN'][] = array( - 'FROM' => array(TOPICS_TABLE => 't'), - 'ON' => 'p.topic_id = t.topic_id' - ); - } - - // if using mysql and the total result count is not calculated yet, get it from the db - if (!$total_results && $is_mysql) - { - // Also count rows for the query as if there was not LIMIT. Add SQL_CALC_FOUND_ROWS to SQL - $sql_array['SELECT'] = 'SQL_CALC_FOUND_ROWS ' . $sql_array['SELECT']; - } - - $sql_array['WHERE'] = implode(' AND ', $sql_where); - $sql_array['GROUP_BY'] = ($group_by) ? (($type == 'posts') ? 'p.post_id' : 'p.topic_id') . ', ' . $sort_by_sql[$sort_key] : ''; - $sql_array['ORDER_BY'] = $sql_sort; - - unset($sql_where, $sql_sort, $group_by); - - $sql = $this->db->sql_build_query('SELECT', $sql_array); - $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); - - while ($row = $this->db->sql_fetchrow($result)) - { - $id_ary[] = (int) $row[(($type == 'posts') ? 'post_id' : 'topic_id')]; - } - $this->db->sql_freeresult($result); - - if (!$total_results && $is_mysql) - { - // Get the number of results as calculated by MySQL - $sql_count = 'SELECT FOUND_ROWS() as total_results'; - $result = $this->db->sql_query($sql_count); - $total_results = (int) $this->db->sql_fetchfield('total_results'); - $this->db->sql_freeresult($result); - - if (!$total_results) - { - return false; - } - } - - if ($start >= $total_results) - { - $start = floor(($total_results - 1) / $per_page) * $per_page; - - $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); - - while ($row = $this->db->sql_fetchrow($result)) - { - $id_ary[] = (int) $row[(($type == 'posts') ? 'post_id' : 'topic_id')]; - } - $this->db->sql_freeresult($result); - - } - - // store the ids, from start on then delete anything that isn't on the current page because we only need ids for one page - $this->save_ids($search_key, $this->search_query, $author_ary, $total_results, $id_ary, $start, $sort_dir); - $id_ary = array_slice($id_ary, 0, (int) $per_page); - - return $total_results; - } - - /** - * Performs a search on an author's posts without caring about message contents. Depends on display specific params - * - * @param string $type contains either posts or topics depending on what should be searched for - * @param boolean $firstpost_only if true, only topic starting posts will be considered - * @param array $sort_by_sql contains SQL code for the ORDER BY part of a query - * @param string $sort_key is the key of $sort_by_sql for the selected sorting - * @param string $sort_dir is either a or d representing ASC and DESC - * @param string $sort_days specifies the maximum amount of days a post may be old - * @param array $ex_fid_ary specifies an array of forum ids which should not be searched - * @param string $post_visibility specifies which types of posts the user can view in which forums - * @param int $topic_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched - * @param array $author_ary an array of author ids - * @param string $author_name specifies the author match, when ANONYMOUS is also a search-match - * @param array &$id_ary passed by reference, to be filled with ids for the page specified by $start and $per_page, should be ordered - * @param int $start indicates the first index of the page - * @param int $per_page number of ids each page is supposed to contain - * @return boolean|int total number of results - */ - public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page) - { - // No author? No posts - if (!count($author_ary)) - { - return 0; - } - - // generate a search_key from all the options to identify the results - $search_key_array = array( - '', - $type, - ($firstpost_only) ? 'firstpost' : '', - '', - '', - $sort_days, - $sort_key, - $topic_id, - implode(',', $ex_fid_ary), - $post_visibility, - implode(',', $author_ary), - $author_name, - ); - - /** - * Allow changing the search_key for cached results - * - * @event core.search_native_by_author_modify_search_key - * @var array search_key_array Array with search parameters to generate the search_key - * @var string type Searching type ('posts', 'topics') - * @var boolean firstpost_only Flag indicating if only topic starting posts are considered - * @var int sort_days Time, in days, of the oldest possible post to list - * @var string sort_key The sort type used from the possible sort types - * @var int topic_id Limit the search to this topic_id only - * @var array ex_fid_ary Which forums not to search on - * @var string post_visibility Post visibility data - * @var array author_ary Array of user_id containing the users to filter the results to - * @var string author_name The username to search on - * @since 3.1.7-RC1 - */ - $vars = array( - 'search_key_array', - 'type', - 'firstpost_only', - 'sort_days', - 'sort_key', - 'topic_id', - 'ex_fid_ary', - 'post_visibility', - 'author_ary', - 'author_name', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_native_by_author_modify_search_key', compact($vars))); - - $search_key = md5(implode('#', $search_key_array)); - - // try reading the results from cache - $total_results = 0; - if ($this->obtain_ids($search_key, $total_results, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE) - { - return $total_results; - } - - $id_ary = array(); - - // Create some display specific sql strings - if ($author_name) - { - // first one matches post of registered users, second one guests and deleted users - $sql_author = '(' . $this->db->sql_in_set('p.poster_id', array_diff($author_ary, array(ANONYMOUS)), false, true) . ' OR p.post_username ' . $author_name . ')'; - } - else - { - $sql_author = $this->db->sql_in_set('p.poster_id', $author_ary); - } - $sql_fora = (count($ex_fid_ary)) ? ' AND ' . $this->db->sql_in_set('p.forum_id', $ex_fid_ary, true) : ''; - $sql_time = ($sort_days) ? ' AND p.post_time >= ' . (time() - ($sort_days * 86400)) : ''; - $sql_topic_id = ($topic_id) ? ' AND p.topic_id = ' . (int) $topic_id : ''; - $sql_firstpost = ($firstpost_only) ? ' AND p.post_id = t.topic_first_post_id' : ''; - $post_visibility = ($post_visibility) ? ' AND ' . $post_visibility : ''; - - // Build sql strings for sorting - $sql_sort = $sort_by_sql[$sort_key] . (($sort_dir == 'a') ? ' ASC' : ' DESC'); - $sql_sort_table = $sql_sort_join = ''; - switch ($sql_sort[0]) - { - case 'u': - $sql_sort_table = USERS_TABLE . ' u, '; - $sql_sort_join = ' AND u.user_id = p.poster_id '; - break; - - case 't': - $sql_sort_table = ($type == 'posts' && !$firstpost_only) ? TOPICS_TABLE . ' t, ' : ''; - $sql_sort_join = ($type == 'posts' && !$firstpost_only) ? ' AND t.topic_id = p.topic_id ' : ''; - break; - - case 'f': - $sql_sort_table = FORUMS_TABLE . ' f, '; - $sql_sort_join = ' AND f.forum_id = p.forum_id '; - break; - } - - $select = ($type == 'posts') ? 'p.post_id' : 't.topic_id'; - $is_mysql = false; - - /** - * Allow changing the query used to search for posts by author in fulltext_native - * - * @event core.search_native_author_count_query_before - * @var int total_results The previous result count for the format of the query. - * Set to 0 to force a re-count - * @var string type The type of search being made - * @var string select SQL SELECT clause for what to get - * @var string sql_sort_table CROSS JOIN'ed table to allow doing the sort chosen - * @var string sql_sort_join Condition to define how to join the CROSS JOIN'ed table specifyed in sql_sort_table - * @var array sql_author SQL WHERE condition for the post author ids - * @var int topic_id Limit the search to this topic_id only - * @var string sort_by_sql The possible predefined sort types - * @var string sort_key The sort type used from the possible sort types - * @var string sort_dir "a" for ASC or "d" dor DESC for the sort order used - * @var string sql_sort The result SQL when processing sort_by_sql + sort_key + sort_dir - * @var string sort_days Time, in days, that the oldest post showing can have - * @var string sql_time The SQL to search on the time specifyed by sort_days - * @var bool firstpost_only Wether or not to search only on the first post of the topics - * @var string sql_firstpost The SQL used in the WHERE claused to filter by firstpost. - * @var array ex_fid_ary Forum ids that must not be searched on - * @var array sql_fora SQL query for ex_fid_ary - * @var int start How many posts to skip in the search results (used for pagination) - * @since 3.1.5-RC1 - */ - $vars = array( - 'total_results', - 'type', - 'select', - 'sql_sort_table', - 'sql_sort_join', - 'sql_author', - 'topic_id', - 'sort_by_sql', - 'sort_key', - 'sort_dir', - 'sql_sort', - 'sort_days', - 'sql_time', - 'firstpost_only', - 'sql_firstpost', - 'ex_fid_ary', - 'sql_fora', - 'start', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_native_author_count_query_before', compact($vars))); - - // If the cache was completely empty count the results - if (!$total_results) - { - switch ($this->db->get_sql_layer()) - { - case 'mysqli': -// $select = 'SQL_CALC_FOUND_ROWS ' . $select; - $is_mysql = true; - break; - - default: - if ($type == 'posts') - { - $sql = 'SELECT COUNT(p.post_id) as total_results - FROM ' . POSTS_TABLE . ' p' . (($firstpost_only) ? ', ' . TOPICS_TABLE . ' t ' : ' ') . " - WHERE $sql_author - $sql_topic_id - $sql_firstpost - $post_visibility - $sql_fora - $sql_time"; - } - else - { - if ($this->db->get_sql_layer() == 'sqlite3') - { - $sql = 'SELECT COUNT(topic_id) as total_results - FROM (SELECT DISTINCT t.topic_id'; - } - else - { - $sql = 'SELECT COUNT(DISTINCT t.topic_id) as total_results'; - } - - $sql .= ' FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p - WHERE $sql_author - $sql_topic_id - $sql_firstpost - $post_visibility - $sql_fora - AND t.topic_id = p.topic_id - $sql_time" . ($this->db->get_sql_layer() == 'sqlite3' ? ')' : ''); - } - $result = $this->db->sql_query($sql); - - $total_results = (int) $this->db->sql_fetchfield('total_results'); - $this->db->sql_freeresult($result); - - if (!$total_results) - { - return false; - } - break; - } - } - - // Build the query for really selecting the post_ids - if ($type == 'posts') - { - $sql = "SELECT $select - FROM " . $sql_sort_table . POSTS_TABLE . ' p' . (($firstpost_only) ? ', ' . TOPICS_TABLE . ' t' : '') . " - WHERE $sql_author - $sql_topic_id - $sql_firstpost - $post_visibility - $sql_fora - $sql_sort_join - $sql_time - ORDER BY $sql_sort"; - $field = 'post_id'; - } - else - { - $sql = "SELECT $select - FROM " . $sql_sort_table . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p - WHERE $sql_author - $sql_topic_id - $sql_firstpost - $post_visibility - $sql_fora - AND t.topic_id = p.topic_id - $sql_sort_join - $sql_time - GROUP BY t.topic_id, " . $sort_by_sql[$sort_key] . ' - ORDER BY ' . $sql_sort; - $field = 'topic_id'; - } - - // Only read one block of posts from the db and then cache it - $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); - - while ($row = $this->db->sql_fetchrow($result)) - { - $id_ary[] = (int) $row[$field]; - } - $this->db->sql_freeresult($result); - - if (!$total_results && $is_mysql) - { - // Count rows for the executed queries. Replace $select within $sql with SQL_CALC_FOUND_ROWS, and run it. - $sql_calc = str_replace('SELECT ' . $select, 'SELECT SQL_CALC_FOUND_ROWS ' . $select, $sql); - - $result = $this->db->sql_query($sql_calc); - $this->db->sql_freeresult($result); - - $sql_count = 'SELECT FOUND_ROWS() as total_results'; - $result = $this->db->sql_query($sql_count); - $total_results = (int) $this->db->sql_fetchfield('total_results'); - $this->db->sql_freeresult($result); - - if (!$total_results) - { - return false; - } - } - - if ($start >= $total_results) - { - $start = floor(($total_results - 1) / $per_page) * $per_page; - - $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); - - while ($row = $this->db->sql_fetchrow($result)) - { - $id_ary[] = (int) $row[$field]; - } - $this->db->sql_freeresult($result); - } - - if (count($id_ary)) - { - $this->save_ids($search_key, '', $author_ary, $total_results, $id_ary, $start, $sort_dir); - $id_ary = array_slice($id_ary, 0, $per_page); - - return $total_results; - } - return false; - } - - /** - * Split a text into words of a given length - * - * The text is converted to UTF-8, cleaned up, and split. Then, words that - * conform to the defined length range are returned in an array. - * - * NOTE: duplicates are NOT removed from the return array - * - * @param string $text Text to split, encoded in UTF-8 - * @return array Array of UTF-8 words - */ - public function split_message($text) - { - $match = $words = array(); - - /** - * Taken from the original code - */ - // Do not index code - $match[] = '#\[code(?:=.*?)?(\:?[0-9a-z]{5,})\].*?\[\/code(\:?[0-9a-z]{5,})\]#is'; - // BBcode - $match[] = '#\[\/?[a-z0-9\*\+\-]+(?:=.*?)?(?::[a-z])?(\:?[0-9a-z]{5,})\]#'; - - $min = $this->word_length['min']; - - $isset_min = $min - 1; - - /** - * Clean up the string, remove HTML tags, remove BBCodes - */ - $word = strtok($this->cleanup(preg_replace($match, ' ', strip_tags($text)), -1), ' '); - - while (strlen($word)) - { - if (strlen($word) > 255 || strlen($word) <= $isset_min) - { - /** - * Words longer than 255 bytes are ignored. This will have to be - * changed whenever we change the length of search_wordlist.word_text - * - * Words shorter than $isset_min bytes are ignored, too - */ - $word = strtok(' '); - continue; - } - - $len = utf8_strlen($word); - - /** - * Test whether the word is too short to be indexed. - * - * Note that this limit does NOT apply to CJK and Hangul - */ - if ($len < $min) - { - /** - * Note: this could be optimized. If the codepoint is lower than Hangul's range - * we know that it will also be lower than CJK ranges - */ - if ((strncmp($word, self::UTF8_HANGUL_FIRST, 3) < 0 || strncmp($word, self::UTF8_HANGUL_LAST, 3) > 0) - && (strncmp($word, self::UTF8_CJK_FIRST, 3) < 0 || strncmp($word, self::UTF8_CJK_LAST, 3) > 0) - && (strncmp($word, self::UTF8_CJK_B_FIRST, 4) < 0 || strncmp($word, self::UTF8_CJK_B_LAST, 4) > 0)) - { - $word = strtok(' '); - continue; - } - } - - $words[] = $word; - $word = strtok(' '); - } - - return $words; - } - - /** - * Updates wordlist and wordmatch tables when a message is posted or changed - * - * @param string $mode Contains the post mode: edit, post, reply, quote - * @param int $post_id The id of the post which is modified/created - * @param string &$message New or updated post content - * @param string &$subject New or updated post subject - * @param int $poster_id Post author's user id - * @param int $forum_id The id of the forum in which the post is located - */ - public function index($mode, $post_id, &$message, &$subject, $poster_id, $forum_id) - { - if (!$this->config['fulltext_native_load_upd']) - { - /** - * The search indexer is disabled, return - */ - return; - } - - // Split old and new post/subject to obtain array of 'words' - $split_text = $this->split_message($message); - $split_title = $this->split_message($subject); - - $cur_words = array('post' => array(), 'title' => array()); - - $words = array(); - if ($mode == 'edit') - { - $words['add']['post'] = array(); - $words['add']['title'] = array(); - $words['del']['post'] = array(); - $words['del']['title'] = array(); - - $sql = 'SELECT w.word_id, w.word_text, m.title_match - FROM ' . SEARCH_WORDLIST_TABLE . ' w, ' . SEARCH_WORDMATCH_TABLE . " m - WHERE m.post_id = $post_id - AND w.word_id = m.word_id"; - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - $which = ($row['title_match']) ? 'title' : 'post'; - $cur_words[$which][$row['word_text']] = $row['word_id']; - } - $this->db->sql_freeresult($result); - - $words['add']['post'] = array_diff($split_text, array_keys($cur_words['post'])); - $words['add']['title'] = array_diff($split_title, array_keys($cur_words['title'])); - $words['del']['post'] = array_diff(array_keys($cur_words['post']), $split_text); - $words['del']['title'] = array_diff(array_keys($cur_words['title']), $split_title); - } - else - { - $words['add']['post'] = $split_text; - $words['add']['title'] = $split_title; - $words['del']['post'] = array(); - $words['del']['title'] = array(); - } - - /** - * Event to modify method arguments and words before the native search index is updated - * - * @event core.search_native_index_before - * @var string mode Contains the post mode: edit, post, reply, quote - * @var int post_id The id of the post which is modified/created - * @var string message New or updated post content - * @var string subject New or updated post subject - * @var int poster_id Post author's user id - * @var int forum_id The id of the forum in which the post is located - * @var array words Grouped lists of words added to or remove from the index - * @var array split_text Array of words from the message - * @var array split_title Array of words from the title - * @var array cur_words Array of words currently in the index for comparing to new words - * when mode is edit. Empty for other modes. - * @since 3.2.3-RC1 - */ - $vars = array( - 'mode', - 'post_id', - 'message', - 'subject', - 'poster_id', - 'forum_id', - 'words', - 'split_text', - 'split_title', - 'cur_words', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_native_index_before', compact($vars))); - - unset($split_text); - unset($split_title); - - // Get unique words from the above arrays - $unique_add_words = array_unique(array_merge($words['add']['post'], $words['add']['title'])); - - // We now have unique arrays of all words to be added and removed and - // individual arrays of added and removed words for text and title. What - // we need to do now is add the new words (if they don't already exist) - // and then add (or remove) matches between the words and this post - if (count($unique_add_words)) - { - $sql = 'SELECT word_id, word_text - FROM ' . SEARCH_WORDLIST_TABLE . ' - WHERE ' . $this->db->sql_in_set('word_text', $unique_add_words); - $result = $this->db->sql_query($sql); - - $word_ids = array(); - while ($row = $this->db->sql_fetchrow($result)) - { - $word_ids[$row['word_text']] = $row['word_id']; - } - $this->db->sql_freeresult($result); - $new_words = array_diff($unique_add_words, array_keys($word_ids)); - - $this->db->sql_transaction('begin'); - if (count($new_words)) - { - $sql_ary = array(); - - foreach ($new_words as $word) - { - $sql_ary[] = array('word_text' => (string) $word, 'word_count' => 0); - } - $this->db->sql_return_on_error(true); - $this->db->sql_multi_insert(SEARCH_WORDLIST_TABLE, $sql_ary); - $this->db->sql_return_on_error(false); - } - unset($new_words, $sql_ary); - } - else - { - $this->db->sql_transaction('begin'); - } - - // now update the search match table, remove links to removed words and add links to new words - foreach ($words['del'] as $word_in => $word_ary) - { - $title_match = ($word_in == 'title') ? 1 : 0; - - if (count($word_ary)) - { - $sql_in = array(); - foreach ($word_ary as $word) - { - $sql_in[] = $cur_words[$word_in][$word]; - } - - $sql = 'DELETE FROM ' . SEARCH_WORDMATCH_TABLE . ' - WHERE ' . $this->db->sql_in_set('word_id', $sql_in) . ' - AND post_id = ' . intval($post_id) . " - AND title_match = $title_match"; - $this->db->sql_query($sql); - - $sql = 'UPDATE ' . SEARCH_WORDLIST_TABLE . ' - SET word_count = word_count - 1 - WHERE ' . $this->db->sql_in_set('word_id', $sql_in) . ' - AND word_count > 0'; - $this->db->sql_query($sql); - - unset($sql_in); - } - } - - $this->db->sql_return_on_error(true); - foreach ($words['add'] as $word_in => $word_ary) - { - $title_match = ($word_in == 'title') ? 1 : 0; - - if (count($word_ary)) - { - $sql = 'INSERT INTO ' . SEARCH_WORDMATCH_TABLE . ' (post_id, word_id, title_match) - SELECT ' . (int) $post_id . ', word_id, ' . (int) $title_match . ' - FROM ' . SEARCH_WORDLIST_TABLE . ' - WHERE ' . $this->db->sql_in_set('word_text', $word_ary); - $this->db->sql_query($sql); - - $sql = 'UPDATE ' . SEARCH_WORDLIST_TABLE . ' - SET word_count = word_count + 1 - WHERE ' . $this->db->sql_in_set('word_text', $word_ary); - $this->db->sql_query($sql); - } - } - $this->db->sql_return_on_error(false); - - $this->db->sql_transaction('commit'); - - // destroy cached search results containing any of the words removed or added - $this->destroy_cache(array_unique(array_merge($words['add']['post'], $words['add']['title'], $words['del']['post'], $words['del']['title'])), array($poster_id)); - - unset($unique_add_words); - unset($words); - unset($cur_words); - } - - /** - * Removes entries from the wordmatch table for the specified post_ids - */ - public function index_remove($post_ids, $author_ids, $forum_ids) - { - if (count($post_ids)) - { - $sql = 'SELECT w.word_id, w.word_text, m.title_match - FROM ' . SEARCH_WORDMATCH_TABLE . ' m, ' . SEARCH_WORDLIST_TABLE . ' w - WHERE ' . $this->db->sql_in_set('m.post_id', $post_ids) . ' - AND w.word_id = m.word_id'; - $result = $this->db->sql_query($sql); - - $message_word_ids = $title_word_ids = $word_texts = array(); - while ($row = $this->db->sql_fetchrow($result)) - { - if ($row['title_match']) - { - $title_word_ids[] = $row['word_id']; - } - else - { - $message_word_ids[] = $row['word_id']; - } - $word_texts[] = $row['word_text']; - } - $this->db->sql_freeresult($result); - - if (count($title_word_ids)) - { - $sql = 'UPDATE ' . SEARCH_WORDLIST_TABLE . ' - SET word_count = word_count - 1 - WHERE ' . $this->db->sql_in_set('word_id', $title_word_ids) . ' - AND word_count > 0'; - $this->db->sql_query($sql); - } - - if (count($message_word_ids)) - { - $sql = 'UPDATE ' . SEARCH_WORDLIST_TABLE . ' - SET word_count = word_count - 1 - WHERE ' . $this->db->sql_in_set('word_id', $message_word_ids) . ' - AND word_count > 0'; - $this->db->sql_query($sql); - } - - unset($title_word_ids); - unset($message_word_ids); - - $sql = 'DELETE FROM ' . SEARCH_WORDMATCH_TABLE . ' - WHERE ' . $this->db->sql_in_set('post_id', $post_ids); - $this->db->sql_query($sql); - } - - $this->destroy_cache(array_unique($word_texts), array_unique($author_ids)); - } - - /** - * Tidy up indexes: Tag 'common words' and remove - * words no longer referenced in the match table - */ - public function tidy() - { - // Is the fulltext indexer disabled? If yes then we need not - // carry on ... it's okay ... I know when I'm not wanted boo hoo - if (!$this->config['fulltext_native_load_upd']) - { - $this->config->set('search_last_gc', time(), false); - return; - } - - $destroy_cache_words = array(); - - // Remove common words - if ($this->config['num_posts'] >= 100 && $this->config['fulltext_native_common_thres']) - { - $common_threshold = ((double) $this->config['fulltext_native_common_thres']) / 100.0; - // First, get the IDs of common words - $sql = 'SELECT word_id, word_text - FROM ' . SEARCH_WORDLIST_TABLE . ' - WHERE word_count > ' . floor($this->config['num_posts'] * $common_threshold) . ' - OR word_common = 1'; - $result = $this->db->sql_query($sql); - - $sql_in = array(); - while ($row = $this->db->sql_fetchrow($result)) - { - $sql_in[] = $row['word_id']; - $destroy_cache_words[] = $row['word_text']; - } - $this->db->sql_freeresult($result); - - if (count($sql_in)) - { - // Flag the words - $sql = 'UPDATE ' . SEARCH_WORDLIST_TABLE . ' - SET word_common = 1 - WHERE ' . $this->db->sql_in_set('word_id', $sql_in); - $this->db->sql_query($sql); - - // by setting search_last_gc to the new time here we make sure that if a user reloads because the - // following query takes too long, he won't run into it again - $this->config->set('search_last_gc', time(), false); - - // Delete the matches - $sql = 'DELETE FROM ' . SEARCH_WORDMATCH_TABLE . ' - WHERE ' . $this->db->sql_in_set('word_id', $sql_in); - $this->db->sql_query($sql); - } - unset($sql_in); - } - - if (count($destroy_cache_words)) - { - // destroy cached search results containing any of the words that are now common or were removed - $this->destroy_cache(array_unique($destroy_cache_words)); - } - - $this->config->set('search_last_gc', time(), false); - } - - /** - * Deletes all words from the index - */ - public function delete_index($acp_module, $u_action) - { - $sql_queries = []; - - switch ($this->db->get_sql_layer()) - { - case 'sqlite3': - $sql_queries[] = 'DELETE FROM ' . SEARCH_WORDLIST_TABLE; - $sql_queries[] = 'DELETE FROM ' . SEARCH_WORDMATCH_TABLE; - $sql_queries[] = 'DELETE FROM ' . SEARCH_RESULTS_TABLE; - break; - - default: - $sql_queries[] = 'TRUNCATE TABLE ' . SEARCH_WORDLIST_TABLE; - $sql_queries[] = 'TRUNCATE TABLE ' . SEARCH_WORDMATCH_TABLE; - $sql_queries[] = 'TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE; - break; - } - - $stats = $this->stats; - - /** - * Event to modify SQL queries before the native search index is deleted - * - * @event core.search_native_delete_index_before - * @var array sql_queries Array with queries for deleting the search index - * @var array stats Array with statistics of the current index (read only) - * @since 3.2.3-RC1 - */ - $vars = array( - 'sql_queries', - 'stats', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_native_delete_index_before', compact($vars))); - - foreach ($sql_queries as $sql_query) - { - $this->db->sql_query($sql_query); - } - } - - /** - * Returns true if both FULLTEXT indexes exist - */ - public function index_created() - { - if (!count($this->stats)) - { - $this->get_stats(); - } - - return ($this->stats['total_words'] && $this->stats['total_matches']) ? true : false; - } - - /** - * Returns an associative array containing information about the indexes - */ - public function index_stats() - { - if (!count($this->stats)) - { - $this->get_stats(); - } - - return array( - $this->user->lang['TOTAL_WORDS'] => $this->stats['total_words'], - $this->user->lang['TOTAL_MATCHES'] => $this->stats['total_matches']); - } - - protected function get_stats() - { - $this->stats['total_words'] = $this->db->get_estimated_row_count(SEARCH_WORDLIST_TABLE); - $this->stats['total_matches'] = $this->db->get_estimated_row_count(SEARCH_WORDMATCH_TABLE); - } - - /** - * Clean up a text to remove non-alphanumeric characters - * - * This method receives a UTF-8 string, normalizes and validates it, replaces all - * non-alphanumeric characters with strings then returns the result. - * - * Any number of "allowed chars" can be passed as a UTF-8 string in NFC. - * - * @param string $text Text to split, in UTF-8 (not normalized or sanitized) - * @param string $allowed_chars String of special chars to allow - * @param string $encoding Text encoding - * @return string Cleaned up text, only alphanumeric chars are left - */ - protected function cleanup($text, $allowed_chars = null, $encoding = 'utf-8') - { - static $conv = array(), $conv_loaded = array(); - $allow = array(); - - // Convert the text to UTF-8 - $encoding = strtolower($encoding); - if ($encoding != 'utf-8') - { - $text = utf8_recode($text, $encoding); - } - - $utf_len_mask = array( - "\xC0" => 2, - "\xD0" => 2, - "\xE0" => 3, - "\xF0" => 4 - ); - - /** - * Replace HTML entities and NCRs - */ - $text = htmlspecialchars_decode(utf8_decode_ncr($text), ENT_QUOTES); - - /** - * Normalize to NFC - */ - $text = \Normalizer::normalize($text); - - /** - * The first thing we do is: - * - * - convert ASCII-7 letters to lowercase - * - remove the ASCII-7 non-alpha characters - * - remove the bytes that should not appear in a valid UTF-8 string: 0xC0, - * 0xC1 and 0xF5-0xFF - * - * @todo in theory, the third one is already taken care of during normalization and those chars should have been replaced by Unicode replacement chars - */ - $sb_match = "ISTCPAMELRDOJBNHFGVWUQKYXZ\r\n\t!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~\x00\x01\x02\x03\x04\x05\x06\x07\x08\x0B\x0C\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\xC0\xC1\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF"; - $sb_replace = 'istcpamelrdojbnhfgvwuqkyxz '; - - /** - * This is the list of legal ASCII chars, it is automatically extended - * with ASCII chars from $allowed_chars - */ - $legal_ascii = ' eaisntroludcpmghbfvq10xy2j9kw354867z'; - - /** - * Prepare an array containing the extra chars to allow - */ - if (isset($allowed_chars[0])) - { - $pos = 0; - $len = strlen($allowed_chars); - do - { - $c = $allowed_chars[$pos]; - - if ($c < "\x80") - { - /** - * ASCII char - */ - $sb_pos = strpos($sb_match, $c); - if (is_int($sb_pos)) - { - /** - * Remove the char from $sb_match and its corresponding - * replacement in $sb_replace - */ - $sb_match = substr($sb_match, 0, $sb_pos) . substr($sb_match, $sb_pos + 1); - $sb_replace = substr($sb_replace, 0, $sb_pos) . substr($sb_replace, $sb_pos + 1); - $legal_ascii .= $c; - } - - ++$pos; - } - else - { - /** - * UTF-8 char - */ - $utf_len = $utf_len_mask[$c & "\xF0"]; - $allow[substr($allowed_chars, $pos, $utf_len)] = 1; - $pos += $utf_len; - } - } - while ($pos < $len); - } - - $text = strtr($text, $sb_match, $sb_replace); - $ret = ''; - - $pos = 0; - $len = strlen($text); - - do - { - /** - * Do all consecutive ASCII chars at once - */ - if ($spn = strspn($text, $legal_ascii, $pos)) - { - $ret .= substr($text, $pos, $spn); - $pos += $spn; - } - - if ($pos >= $len) - { - return $ret; - } - - /** - * Capture the UTF char - */ - $utf_len = $utf_len_mask[$text[$pos] & "\xF0"]; - $utf_char = substr($text, $pos, $utf_len); - $pos += $utf_len; - - if (($utf_char >= self::UTF8_HANGUL_FIRST && $utf_char <= self::UTF8_HANGUL_LAST) - || ($utf_char >= self::UTF8_CJK_FIRST && $utf_char <= self::UTF8_CJK_LAST) - || ($utf_char >= self::UTF8_CJK_B_FIRST && $utf_char <= self::UTF8_CJK_B_LAST)) - { - /** - * All characters within these ranges are valid - * - * We separate them with a space in order to index each character - * individually - */ - $ret .= ' ' . $utf_char . ' '; - continue; - } - - if (isset($allow[$utf_char])) - { - /** - * The char is explicitly allowed - */ - $ret .= $utf_char; - continue; - } - - if (isset($conv[$utf_char])) - { - /** - * The char is mapped to something, maybe to itself actually - */ - $ret .= $conv[$utf_char]; - continue; - } - - /** - * The char isn't mapped, but did we load its conversion table? - * - * The search indexer table is split into blocks. The block number of - * each char is equal to its codepoint right-shifted for 11 bits. It - * means that out of the 11, 16 or 21 meaningful bits of a 2-, 3- or - * 4- byte sequence we only keep the leftmost 0, 5 or 10 bits. Thus, - * all UTF chars encoded in 2 bytes are in the same first block. - */ - if (isset($utf_char[2])) - { - if (isset($utf_char[3])) - { - /** - * 1111 0nnn 10nn nnnn 10nx xxxx 10xx xxxx - * 0000 0111 0011 1111 0010 0000 - */ - $idx = ((ord($utf_char[0]) & 0x07) << 7) | ((ord($utf_char[1]) & 0x3F) << 1) | ((ord($utf_char[2]) & 0x20) >> 5); - } - else - { - /** - * 1110 nnnn 10nx xxxx 10xx xxxx - * 0000 0111 0010 0000 - */ - $idx = ((ord($utf_char[0]) & 0x07) << 1) | ((ord($utf_char[1]) & 0x20) >> 5); - } - } - else - { - /** - * 110x xxxx 10xx xxxx - * 0000 0000 0000 0000 - */ - $idx = 0; - } - - /** - * Check if the required conv table has been loaded already - */ - if (!isset($conv_loaded[$idx])) - { - $conv_loaded[$idx] = 1; - $file = $this->phpbb_root_path . 'includes/utf/data/search_indexer_' . $idx . '.' . $this->php_ext; - - if (file_exists($file)) - { - $conv += include($file); - } - } - - if (isset($conv[$utf_char])) - { - $ret .= $conv[$utf_char]; - } - else - { - /** - * We add an entry to the conversion table so that we - * don't have to convert to codepoint and perform the checks - * that are above this block - */ - $conv[$utf_char] = ' '; - $ret .= ' '; - } - } - while (1); - - return $ret; - } - - /** - * Returns a list of options for the ACP to display - */ - public function acp() - { - /** - * if we need any options, copied from fulltext_native for now, will have to be adjusted or removed - */ - - $tpl = ' -
-

' . $this->user->lang['YES_SEARCH_UPDATE_EXPLAIN'] . '
-
-
-
-

' . $this->user->lang['MIN_SEARCH_CHARS_EXPLAIN'] . '
-
-
-
-

' . $this->user->lang['MAX_SEARCH_CHARS_EXPLAIN'] . '
-
-
-
-

' . $this->user->lang['COMMON_WORD_THRESHOLD_EXPLAIN'] . '
-
%
-
- '; - - // These are fields required in the config table - return array( - 'tpl' => $tpl, - 'config' => array('fulltext_native_load_upd' => 'bool', 'fulltext_native_min_chars' => 'integer:0:255', 'fulltext_native_max_chars' => 'integer:0:255', 'fulltext_native_common_thres' => 'double:0:100') - ); - } -} diff --git a/install/update/new/phpbb/search/fulltext_postgres.php b/install/update/new/phpbb/search/fulltext_postgres.php deleted file mode 100644 index 6241f21..0000000 --- a/install/update/new/phpbb/search/fulltext_postgres.php +++ /dev/null @@ -1,1178 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\search; - -/** -* Fulltext search for PostgreSQL -*/ -class fulltext_postgres extends \phpbb\search\base -{ - /** - * Associative array holding index stats - * @var array - */ - protected $stats = array(); - - /** - * Holds the words entered by user, obtained by splitting the entered query on whitespace - * @var array - */ - protected $split_words = array(); - - /** - * Stores the tsearch query - * @var string - */ - protected $tsearch_query; - - /** - * True if phrase search is supported. - * PostgreSQL fulltext currently doesn't support it - * @var boolean - */ - protected $phrase_search = false; - - /** - * Config object - * @var \phpbb\config\config - */ - protected $config; - - /** - * Database connection - * @var \phpbb\db\driver\driver_interface - */ - protected $db; - - /** - * phpBB event dispatcher object - * @var \phpbb\event\dispatcher_interface - */ - protected $phpbb_dispatcher; - - /** - * User object - * @var \phpbb\user - */ - protected $user; - - /** - * Contains tidied search query. - * Operators are prefixed in search query and common words excluded - * @var string - */ - protected $search_query; - - /** - * Contains common words. - * Common words are words with length less/more than min/max length - * @var array - */ - protected $common_words = array(); - - /** - * Associative array stores the min and max word length to be searched - * @var array - */ - protected $word_length = array(); - - /** - * Constructor - * Creates a new \phpbb\search\fulltext_postgres, which is used as a search backend - * - * @param string|bool $error Any error that occurs is passed on through this reference variable otherwise false - * @param string $phpbb_root_path Relative path to phpBB root - * @param string $phpEx PHP file extension - * @param \phpbb\auth\auth $auth Auth object - * @param \phpbb\config\config $config Config object - * @param \phpbb\db\driver\driver_interface Database object - * @param \phpbb\user $user User object - * @param \phpbb\event\dispatcher_interface $phpbb_dispatcher Event dispatcher object - */ - public function __construct(&$error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher) - { - $this->config = $config; - $this->db = $db; - $this->phpbb_dispatcher = $phpbb_dispatcher; - $this->user = $user; - - $this->word_length = array('min' => $this->config['fulltext_postgres_min_word_len'], 'max' => $this->config['fulltext_postgres_max_word_len']); - - /** - * Load the UTF tools - */ - if (!function_exists('utf8_strlen')) - { - include($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); - } - - $error = false; - } - - /** - * Returns the name of this search backend to be displayed to administrators - * - * @return string Name - */ - public function get_name() - { - return 'PostgreSQL Fulltext'; - } - - /** - * Returns the search_query - * - * @return string search query - */ - public function get_search_query() - { - return $this->search_query; - } - - /** - * Returns the common_words array - * - * @return array common words that are ignored by search backend - */ - public function get_common_words() - { - return $this->common_words; - } - - /** - * Returns the word_length array - * - * @return array min and max word length for searching - */ - public function get_word_length() - { - return $this->word_length; - } - - /** - * Returns if phrase search is supported or not - * - * @return bool - */ - public function supports_phrase_search() - { - return $this->phrase_search; - } - - /** - * Checks for correct PostgreSQL version and stores min/max word length in the config - * - * @return string|bool Language key of the error/incompatibility occurred - */ - public function init() - { - if ($this->db->get_sql_layer() != 'postgres') - { - return $this->user->lang['FULLTEXT_POSTGRES_INCOMPATIBLE_DATABASE']; - } - - return false; - } - - /** - * Splits keywords entered by a user into an array of words stored in $this->split_words - * Stores the tidied search query in $this->search_query - * - * @param string &$keywords Contains the keyword as entered by the user - * @param string $terms is either 'all' or 'any' - * @return bool false if no valid keywords were found and otherwise true - */ - public function split_keywords(&$keywords, $terms) - { - if ($terms == 'all') - { - $match = array('#\sand\s#iu', '#\sor\s#iu', '#\snot\s#iu', '#(^|\s)\+#', '#(^|\s)-#', '#(^|\s)\|#'); - $replace = array(' +', ' |', ' -', ' +', ' -', ' |'); - - $keywords = preg_replace($match, $replace, $keywords); - } - - // Filter out as above - $split_keywords = preg_replace("#[\"\n\r\t]+#", ' ', trim(htmlspecialchars_decode($keywords))); - - // Split words - $split_keywords = preg_replace('#([^\p{L}\p{N}\'*"()])#u', '$1$1', str_replace('\'\'', '\' \'', trim($split_keywords))); - $matches = array(); - preg_match_all('#(?:[^\p{L}\p{N}*"()]|^)([+\-|]?(?:[\p{L}\p{N}*"()]+\'?)*[\p{L}\p{N}*"()])(?:[^\p{L}\p{N}*"()]|$)#u', $split_keywords, $matches); - $this->split_words = $matches[1]; - - foreach ($this->split_words as $i => $word) - { - $clean_word = preg_replace('#^[+\-|"]#', '', $word); - - // check word length - $clean_len = utf8_strlen(str_replace('*', '', $clean_word)); - if (($clean_len < $this->config['fulltext_postgres_min_word_len']) || ($clean_len > $this->config['fulltext_postgres_max_word_len'])) - { - $this->common_words[] = $word; - unset($this->split_words[$i]); - } - } - - if ($terms == 'any') - { - $this->search_query = ''; - $this->tsearch_query = ''; - foreach ($this->split_words as $word) - { - if ((strpos($word, '+') === 0) || (strpos($word, '-') === 0) || (strpos($word, '|') === 0)) - { - $word = substr($word, 1); - } - $this->search_query .= $word . ' '; - $this->tsearch_query .= '|' . $word . ' '; - } - } - else - { - $this->search_query = ''; - $this->tsearch_query = ''; - foreach ($this->split_words as $word) - { - if (strpos($word, '+') === 0) - { - $this->search_query .= $word . ' '; - $this->tsearch_query .= '&' . substr($word, 1) . ' '; - } - else if (strpos($word, '-') === 0) - { - $this->search_query .= $word . ' '; - $this->tsearch_query .= '&!' . substr($word, 1) . ' '; - } - else if (strpos($word, '|') === 0) - { - $this->search_query .= $word . ' '; - $this->tsearch_query .= '|' . substr($word, 1) . ' '; - } - else - { - $this->search_query .= '+' . $word . ' '; - $this->tsearch_query .= '&' . $word . ' '; - } - } - } - - $this->tsearch_query = substr($this->tsearch_query, 1); - $this->search_query = utf8_htmlspecialchars($this->search_query); - - if ($this->search_query) - { - $this->split_words = array_values($this->split_words); - sort($this->split_words); - return true; - } - return false; - } - - /** - * Turns text into an array of words - * @param string $text contains post text/subject - */ - public function split_message($text) - { - // Split words - $text = preg_replace('#([^\p{L}\p{N}\'*])#u', '$1$1', str_replace('\'\'', '\' \'', trim($text))); - $matches = array(); - preg_match_all('#(?:[^\p{L}\p{N}*]|^)([+\-|]?(?:[\p{L}\p{N}*]+\'?)*[\p{L}\p{N}*])(?:[^\p{L}\p{N}*]|$)#u', $text, $matches); - $text = $matches[1]; - - // remove too short or too long words - $text = array_values($text); - for ($i = 0, $n = count($text); $i < $n; $i++) - { - $text[$i] = trim($text[$i]); - if (utf8_strlen($text[$i]) < $this->config['fulltext_postgres_min_word_len'] || utf8_strlen($text[$i]) > $this->config['fulltext_postgres_max_word_len']) - { - unset($text[$i]); - } - } - - return array_values($text); - } - - /** - * Performs a search on keywords depending on display specific params. You have to run split_keywords() first - * - * @param string $type contains either posts or topics depending on what should be searched for - * @param string $fields contains either titleonly (topic titles should be searched), msgonly (only message bodies should be searched), firstpost (only subject and body of the first post should be searched) or all (all post bodies and subjects should be searched) - * @param string $terms is either 'all' (use query as entered, words without prefix should default to "have to be in field") or 'any' (ignore search query parts and just return all posts that contain any of the specified words) - * @param array $sort_by_sql contains SQL code for the ORDER BY part of a query - * @param string $sort_key is the key of $sort_by_sql for the selected sorting - * @param string $sort_dir is either a or d representing ASC and DESC - * @param string $sort_days specifies the maximum amount of days a post may be old - * @param array $ex_fid_ary specifies an array of forum ids which should not be searched - * @param string $post_visibility specifies which types of posts the user can view in which forums - * @param int $topic_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched - * @param array $author_ary an array of author ids if the author should be ignored during the search the array is empty - * @param string $author_name specifies the author match, when ANONYMOUS is also a search-match - * @param array &$id_ary passed by reference, to be filled with ids for the page specified by $start and $per_page, should be ordered - * @param int $start indicates the first index of the page - * @param int $per_page number of ids each page is supposed to contain - * @return boolean|int total number of results - */ - public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page) - { - // No keywords? No posts - if (!$this->search_query) - { - return false; - } - - // When search query contains queries like -foo - if (strpos($this->search_query, '+') === false) - { - return false; - } - - // generate a search_key from all the options to identify the results - $search_key_array = array( - implode(', ', $this->split_words), - $type, - $fields, - $terms, - $sort_days, - $sort_key, - $topic_id, - implode(',', $ex_fid_ary), - $post_visibility, - implode(',', $author_ary) - ); - - /** - * Allow changing the search_key for cached results - * - * @event core.search_postgres_by_keyword_modify_search_key - * @var array search_key_array Array with search parameters to generate the search_key - * @var string type Searching type ('posts', 'topics') - * @var string fields Searching fields ('titleonly', 'msgonly', 'firstpost', 'all') - * @var string terms Searching terms ('all', 'any') - * @var int sort_days Time, in days, of the oldest possible post to list - * @var string sort_key The sort type used from the possible sort types - * @var int topic_id Limit the search to this topic_id only - * @var array ex_fid_ary Which forums not to search on - * @var string post_visibility Post visibility data - * @var array author_ary Array of user_id containing the users to filter the results to - * @since 3.1.7-RC1 - */ - $vars = array( - 'search_key_array', - 'type', - 'fields', - 'terms', - 'sort_days', - 'sort_key', - 'topic_id', - 'ex_fid_ary', - 'post_visibility', - 'author_ary', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_postgres_by_keyword_modify_search_key', compact($vars))); - - $search_key = md5(implode('#', $search_key_array)); - - if ($start < 0) - { - $start = 0; - } - - // try reading the results from cache - $result_count = 0; - if ($this->obtain_ids($search_key, $result_count, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE) - { - return $result_count; - } - - $id_ary = array(); - - $join_topic = ($type == 'posts') ? false : true; - - // Build sql strings for sorting - $sql_sort = $sort_by_sql[$sort_key] . (($sort_dir == 'a') ? ' ASC' : ' DESC'); - $sql_sort_table = $sql_sort_join = ''; - - switch ($sql_sort[0]) - { - case 'u': - $sql_sort_table = USERS_TABLE . ' u, '; - $sql_sort_join = ($type == 'posts') ? ' AND u.user_id = p.poster_id ' : ' AND u.user_id = t.topic_poster '; - break; - - case 't': - $join_topic = true; - break; - - case 'f': - $sql_sort_table = FORUMS_TABLE . ' f, '; - $sql_sort_join = ' AND f.forum_id = p.forum_id '; - break; - } - - // Build some display specific sql strings - switch ($fields) - { - case 'titleonly': - $sql_match = 'p.post_subject'; - $sql_match_where = ' AND p.post_id = t.topic_first_post_id'; - $join_topic = true; - break; - - case 'msgonly': - $sql_match = 'p.post_text'; - $sql_match_where = ''; - break; - - case 'firstpost': - $sql_match = 'p.post_subject, p.post_text'; - $sql_match_where = ' AND p.post_id = t.topic_first_post_id'; - $join_topic = true; - break; - - default: - $sql_match = 'p.post_subject, p.post_text'; - $sql_match_where = ''; - break; - } - - $tsearch_query = $this->tsearch_query; - - /** - * Allow changing the query used to search for posts using fulltext_postgres - * - * @event core.search_postgres_keywords_main_query_before - * @var string tsearch_query The parsed keywords used for this search - * @var int result_count The previous result count for the format of the query. - * Set to 0 to force a re-count - * @var bool join_topic Weather or not TOPICS_TABLE should be CROSS JOIN'ED - * @var array author_ary Array of user_id containing the users to filter the results to - * @var string author_name An extra username to search on (!empty(author_ary) must be true, to be relevant) - * @var array ex_fid_ary Which forums not to search on - * @var int topic_id Limit the search to this topic_id only - * @var string sql_sort_table Extra tables to include in the SQL query. - * Used in conjunction with sql_sort_join - * @var string sql_sort_join SQL conditions to join all the tables used together. - * Used in conjunction with sql_sort_table - * @var int sort_days Time, in days, of the oldest possible post to list - * @var string sql_match Which columns to do the search on. - * @var string sql_match_where Extra conditions to use to properly filter the matching process - * @var string sort_by_sql The possible predefined sort types - * @var string sort_key The sort type used from the possible sort types - * @var string sort_dir "a" for ASC or "d" dor DESC for the sort order used - * @var string sql_sort The result SQL when processing sort_by_sql + sort_key + sort_dir - * @var int start How many posts to skip in the search results (used for pagination) - * @since 3.1.5-RC1 - */ - $vars = array( - 'tsearch_query', - 'result_count', - 'join_topic', - 'author_ary', - 'author_name', - 'ex_fid_ary', - 'topic_id', - 'sql_sort_table', - 'sql_sort_join', - 'sort_days', - 'sql_match', - 'sql_match_where', - 'sort_by_sql', - 'sort_key', - 'sort_dir', - 'sql_sort', - 'start', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_postgres_keywords_main_query_before', compact($vars))); - - $sql_select = ($type == 'posts') ? 'p.post_id' : 'DISTINCT t.topic_id, ' . $sort_by_sql[$sort_key]; - $sql_from = ($join_topic) ? TOPICS_TABLE . ' t, ' : ''; - $field = ($type == 'posts') ? 'post_id' : 'topic_id'; - - if (count($author_ary) && $author_name) - { - // first one matches post of registered users, second one guests and deleted users - $sql_author = '(' . $this->db->sql_in_set('p.poster_id', array_diff($author_ary, array(ANONYMOUS)), false, true) . ' OR p.post_username ' . $author_name . ')'; - } - else if (count($author_ary)) - { - $sql_author = ' AND ' . $this->db->sql_in_set('p.poster_id', $author_ary); - } - else - { - $sql_author = ''; - } - - $sql_where_options = $sql_sort_join; - $sql_where_options .= ($topic_id) ? ' AND p.topic_id = ' . $topic_id : ''; - $sql_where_options .= ($join_topic) ? ' AND t.topic_id = p.topic_id' : ''; - $sql_where_options .= (count($ex_fid_ary)) ? ' AND ' . $this->db->sql_in_set('p.forum_id', $ex_fid_ary, true) : ''; - $sql_where_options .= ' AND ' . $post_visibility; - $sql_where_options .= $sql_author; - $sql_where_options .= ($sort_days) ? ' AND p.post_time >= ' . (time() - ($sort_days * 86400)) : ''; - $sql_where_options .= $sql_match_where; - - $sql_match = str_replace(',', " || ' ' ||", $sql_match); - $tmp_sql_match = "to_tsvector ('" . $this->db->sql_escape($this->config['fulltext_postgres_ts_name']) . "', " . $sql_match . ") @@ to_tsquery ('" . $this->db->sql_escape($this->config['fulltext_postgres_ts_name']) . "', '" . $this->db->sql_escape($this->tsearch_query) . "')"; - - $this->db->sql_transaction('begin'); - - $sql_from = "FROM $sql_from$sql_sort_table" . POSTS_TABLE . " p"; - $sql_where = "WHERE (" . $tmp_sql_match . ") - $sql_where_options"; - $sql = "SELECT $sql_select - $sql_from - $sql_where - ORDER BY $sql_sort"; - $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); - - while ($row = $this->db->sql_fetchrow($result)) - { - $id_ary[] = $row[$field]; - } - $this->db->sql_freeresult($result); - - $id_ary = array_unique($id_ary); - - // if the total result count is not cached yet, retrieve it from the db - if (!$result_count) - { - $sql_count = "SELECT COUNT(*) as result_count - $sql_from - $sql_where"; - $result = $this->db->sql_query($sql_count); - $result_count = (int) $this->db->sql_fetchfield('result_count'); - $this->db->sql_freeresult($result); - - if (!$result_count) - { - return false; - } - } - - $this->db->sql_transaction('commit'); - - if ($start >= $result_count) - { - $start = floor(($result_count - 1) / $per_page) * $per_page; - - $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); - - while ($row = $this->db->sql_fetchrow($result)) - { - $id_ary[] = $row[$field]; - } - $this->db->sql_freeresult($result); - - $id_ary = array_unique($id_ary); - } - - // store the ids, from start on then delete anything that isn't on the current page because we only need ids for one page - $this->save_ids($search_key, implode(' ', $this->split_words), $author_ary, $result_count, $id_ary, $start, $sort_dir); - $id_ary = array_slice($id_ary, 0, (int) $per_page); - - return $result_count; - } - - /** - * Performs a search on an author's posts without caring about message contents. Depends on display specific params - * - * @param string $type contains either posts or topics depending on what should be searched for - * @param boolean $firstpost_only if true, only topic starting posts will be considered - * @param array $sort_by_sql contains SQL code for the ORDER BY part of a query - * @param string $sort_key is the key of $sort_by_sql for the selected sorting - * @param string $sort_dir is either a or d representing ASC and DESC - * @param string $sort_days specifies the maximum amount of days a post may be old - * @param array $ex_fid_ary specifies an array of forum ids which should not be searched - * @param string $post_visibility specifies which types of posts the user can view in which forums - * @param int $topic_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched - * @param array $author_ary an array of author ids - * @param string $author_name specifies the author match, when ANONYMOUS is also a search-match - * @param array &$id_ary passed by reference, to be filled with ids for the page specified by $start and $per_page, should be ordered - * @param int $start indicates the first index of the page - * @param int $per_page number of ids each page is supposed to contain - * @return boolean|int total number of results - */ - public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page) - { - // No author? No posts - if (!count($author_ary)) - { - return 0; - } - - // generate a search_key from all the options to identify the results - $search_key_array = array( - '', - $type, - ($firstpost_only) ? 'firstpost' : '', - '', - '', - $sort_days, - $sort_key, - $topic_id, - implode(',', $ex_fid_ary), - $post_visibility, - implode(',', $author_ary), - $author_name, - ); - - /** - * Allow changing the search_key for cached results - * - * @event core.search_postgres_by_author_modify_search_key - * @var array search_key_array Array with search parameters to generate the search_key - * @var string type Searching type ('posts', 'topics') - * @var boolean firstpost_only Flag indicating if only topic starting posts are considered - * @var int sort_days Time, in days, of the oldest possible post to list - * @var string sort_key The sort type used from the possible sort types - * @var int topic_id Limit the search to this topic_id only - * @var array ex_fid_ary Which forums not to search on - * @var string post_visibility Post visibility data - * @var array author_ary Array of user_id containing the users to filter the results to - * @var string author_name The username to search on - * @since 3.1.7-RC1 - */ - $vars = array( - 'search_key_array', - 'type', - 'firstpost_only', - 'sort_days', - 'sort_key', - 'topic_id', - 'ex_fid_ary', - 'post_visibility', - 'author_ary', - 'author_name', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_postgres_by_author_modify_search_key', compact($vars))); - - $search_key = md5(implode('#', $search_key_array)); - - if ($start < 0) - { - $start = 0; - } - - // try reading the results from cache - $result_count = 0; - if ($this->obtain_ids($search_key, $result_count, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE) - { - return $result_count; - } - - $id_ary = array(); - - // Create some display specific sql strings - if ($author_name) - { - // first one matches post of registered users, second one guests and deleted users - $sql_author = '(' . $this->db->sql_in_set('p.poster_id', array_diff($author_ary, array(ANONYMOUS)), false, true) . ' OR p.post_username ' . $author_name . ')'; - } - else - { - $sql_author = $this->db->sql_in_set('p.poster_id', $author_ary); - } - $sql_fora = (count($ex_fid_ary)) ? ' AND ' . $this->db->sql_in_set('p.forum_id', $ex_fid_ary, true) : ''; - $sql_topic_id = ($topic_id) ? ' AND p.topic_id = ' . (int) $topic_id : ''; - $sql_time = ($sort_days) ? ' AND p.post_time >= ' . (time() - ($sort_days * 86400)) : ''; - $sql_firstpost = ($firstpost_only) ? ' AND p.post_id = t.topic_first_post_id' : ''; - - // Build sql strings for sorting - $sql_sort = $sort_by_sql[$sort_key] . (($sort_dir == 'a') ? ' ASC' : ' DESC'); - $sql_sort_table = $sql_sort_join = ''; - switch ($sql_sort[0]) - { - case 'u': - $sql_sort_table = USERS_TABLE . ' u, '; - $sql_sort_join = ($type == 'posts') ? ' AND u.user_id = p.poster_id ' : ' AND u.user_id = t.topic_poster '; - break; - - case 't': - $sql_sort_table = ($type == 'posts' && !$firstpost_only) ? TOPICS_TABLE . ' t, ' : ''; - $sql_sort_join = ($type == 'posts' && !$firstpost_only) ? ' AND t.topic_id = p.topic_id ' : ''; - break; - - case 'f': - $sql_sort_table = FORUMS_TABLE . ' f, '; - $sql_sort_join = ' AND f.forum_id = p.forum_id '; - break; - } - - $m_approve_fid_sql = ' AND ' . $post_visibility; - - /** - * Allow changing the query used to search for posts by author in fulltext_postgres - * - * @event core.search_postgres_author_count_query_before - * @var int result_count The previous result count for the format of the query. - * Set to 0 to force a re-count - * @var string sql_sort_table CROSS JOIN'ed table to allow doing the sort chosen - * @var string sql_sort_join Condition to define how to join the CROSS JOIN'ed table specifyed in sql_sort_table - * @var array author_ary Array of user_id containing the users to filter the results to - * @var string author_name An extra username to search on - * @var string sql_author SQL WHERE condition for the post author ids - * @var int topic_id Limit the search to this topic_id only - * @var string sql_topic_id SQL of topic_id - * @var string sort_by_sql The possible predefined sort types - * @var string sort_key The sort type used from the possible sort types - * @var string sort_dir "a" for ASC or "d" dor DESC for the sort order used - * @var string sql_sort The result SQL when processing sort_by_sql + sort_key + sort_dir - * @var string sort_days Time, in days, that the oldest post showing can have - * @var string sql_time The SQL to search on the time specifyed by sort_days - * @var bool firstpost_only Wether or not to search only on the first post of the topics - * @var array ex_fid_ary Forum ids that must not be searched on - * @var array sql_fora SQL query for ex_fid_ary - * @var string m_approve_fid_sql WHERE clause condition on post_visibility restrictions - * @var int start How many posts to skip in the search results (used for pagination) - * @since 3.1.5-RC1 - */ - $vars = array( - 'result_count', - 'sql_sort_table', - 'sql_sort_join', - 'author_ary', - 'author_name', - 'sql_author', - 'topic_id', - 'sql_topic_id', - 'sort_by_sql', - 'sort_key', - 'sort_dir', - 'sql_sort', - 'sort_days', - 'sql_time', - 'firstpost_only', - 'ex_fid_ary', - 'sql_fora', - 'm_approve_fid_sql', - 'start', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_postgres_author_count_query_before', compact($vars))); - - // Build the query for really selecting the post_ids - if ($type == 'posts') - { - $sql = "SELECT p.post_id - FROM " . $sql_sort_table . POSTS_TABLE . ' p' . (($firstpost_only) ? ', ' . TOPICS_TABLE . ' t ' : ' ') . " - WHERE $sql_author - $sql_topic_id - $sql_firstpost - $m_approve_fid_sql - $sql_fora - $sql_sort_join - $sql_time - ORDER BY $sql_sort"; - $field = 'post_id'; - } - else - { - $sql = "SELECT t.topic_id - FROM " . $sql_sort_table . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p - WHERE $sql_author - $sql_topic_id - $sql_firstpost - $m_approve_fid_sql - $sql_fora - AND t.topic_id = p.topic_id - $sql_sort_join - $sql_time - GROUP BY t.topic_id, $sort_by_sql[$sort_key] - ORDER BY $sql_sort"; - $field = 'topic_id'; - } - - $this->db->sql_transaction('begin'); - - // Only read one block of posts from the db and then cache it - $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); - - while ($row = $this->db->sql_fetchrow($result)) - { - $id_ary[] = $row[$field]; - } - $this->db->sql_freeresult($result); - - // retrieve the total result count if needed - if (!$result_count) - { - if ($type == 'posts') - { - $sql_count = "SELECT COUNT(*) as result_count - FROM " . $sql_sort_table . POSTS_TABLE . ' p' . (($firstpost_only) ? ', ' . TOPICS_TABLE . ' t ' : ' ') . " - WHERE $sql_author - $sql_topic_id - $sql_firstpost - $m_approve_fid_sql - $sql_fora - $sql_sort_join - $sql_time"; - } - else - { - $sql_count = "SELECT COUNT(*) as result_count - FROM " . $sql_sort_table . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p - WHERE $sql_author - $sql_topic_id - $sql_firstpost - $m_approve_fid_sql - $sql_fora - AND t.topic_id = p.topic_id - $sql_sort_join - $sql_time - GROUP BY t.topic_id, $sort_by_sql[$sort_key]"; - } - - $this->db->sql_query($sql_count); - $result_count = (int) $this->db->sql_fetchfield('result_count'); - - if (!$result_count) - { - return false; - } - } - - $this->db->sql_transaction('commit'); - - if ($start >= $result_count) - { - $start = floor(($result_count - 1) / $per_page) * $per_page; - - $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); - while ($row = $this->db->sql_fetchrow($result)) - { - $id_ary[] = (int) $row[$field]; - } - $this->db->sql_freeresult($result); - - $id_ary = array_unique($id_ary); - } - - if (count($id_ary)) - { - $this->save_ids($search_key, '', $author_ary, $result_count, $id_ary, $start, $sort_dir); - $id_ary = array_slice($id_ary, 0, $per_page); - - return $result_count; - } - return false; - } - - /** - * Destroys cached search results, that contained one of the new words in a post so the results won't be outdated - * - * @param string $mode contains the post mode: edit, post, reply, quote ... - * @param int $post_id contains the post id of the post to index - * @param string $message contains the post text of the post - * @param string $subject contains the subject of the post to index - * @param int $poster_id contains the user id of the poster - * @param int $forum_id contains the forum id of parent forum of the post - */ - public function index($mode, $post_id, &$message, &$subject, $poster_id, $forum_id) - { - // Split old and new post/subject to obtain array of words - $split_text = $this->split_message($message); - $split_title = ($subject) ? $this->split_message($subject) : array(); - - $words = array_unique(array_merge($split_text, $split_title)); - - /** - * Event to modify method arguments and words before the PostgreSQL search index is updated - * - * @event core.search_postgres_index_before - * @var string mode Contains the post mode: edit, post, reply, quote - * @var int post_id The id of the post which is modified/created - * @var string message New or updated post content - * @var string subject New or updated post subject - * @var int poster_id Post author's user id - * @var int forum_id The id of the forum in which the post is located - * @var array words Array of words added to the index - * @var array split_text Array of words from the message - * @var array split_title Array of words from the title - * @since 3.2.3-RC1 - */ - $vars = array( - 'mode', - 'post_id', - 'message', - 'subject', - 'poster_id', - 'forum_id', - 'words', - 'split_text', - 'split_title', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_postgres_index_before', compact($vars))); - - unset($split_text); - unset($split_title); - - // destroy cached search results containing any of the words removed or added - $this->destroy_cache($words, array($poster_id)); - - unset($words); - } - - /** - * Destroy cached results, that might be outdated after deleting a post - */ - public function index_remove($post_ids, $author_ids, $forum_ids) - { - $this->destroy_cache(array(), $author_ids); - } - - /** - * Destroy old cache entries - */ - public function tidy() - { - // destroy too old cached search results - $this->destroy_cache(array()); - - $this->config->set('search_last_gc', time(), false); - } - - /** - * Create fulltext index - * - * @return string|bool error string is returned incase of errors otherwise false - */ - public function create_index($acp_module, $u_action) - { - // Make sure we can actually use PostgreSQL with fulltext indexes - if ($error = $this->init()) - { - return $error; - } - - if (empty($this->stats)) - { - $this->get_stats(); - } - - $sql_queries = []; - - if (!isset($this->stats['post_subject'])) - { - $sql_queries[] = "CREATE INDEX " . POSTS_TABLE . "_" . $this->config['fulltext_postgres_ts_name'] . "_post_subject ON " . POSTS_TABLE . " USING gin (to_tsvector ('" . $this->db->sql_escape($this->config['fulltext_postgres_ts_name']) . "', post_subject))"; - } - - if (!isset($this->stats['post_content'])) - { - $sql_queries[] = "CREATE INDEX " . POSTS_TABLE . "_" . $this->config['fulltext_postgres_ts_name'] . "_post_content ON " . POSTS_TABLE . " USING gin (to_tsvector ('" . $this->db->sql_escape($this->config['fulltext_postgres_ts_name']) . "', post_text || ' ' || post_subject))"; - } - - $stats = $this->stats; - - /** - * Event to modify SQL queries before the Postgres search index is created - * - * @event core.search_postgres_create_index_before - * @var array sql_queries Array with queries for creating the search index - * @var array stats Array with statistics of the current index (read only) - * @since 3.2.3-RC1 - */ - $vars = array( - 'sql_queries', - 'stats', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_postgres_create_index_before', compact($vars))); - - foreach ($sql_queries as $sql_query) - { - $this->db->sql_query($sql_query); - } - - $this->db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE); - - return false; - } - - /** - * Drop fulltext index - * - * @return string|bool error string is returned incase of errors otherwise false - */ - public function delete_index($acp_module, $u_action) - { - // Make sure we can actually use PostgreSQL with fulltext indexes - if ($error = $this->init()) - { - return $error; - } - - if (empty($this->stats)) - { - $this->get_stats(); - } - - $sql_queries = []; - - if (isset($this->stats['post_subject'])) - { - $sql_queries[] = 'DROP INDEX ' . $this->stats['post_subject']['relname']; - } - - if (isset($this->stats['post_content'])) - { - $sql_queries[] = 'DROP INDEX ' . $this->stats['post_content']['relname']; - } - - $stats = $this->stats; - - /** - * Event to modify SQL queries before the Postgres search index is created - * - * @event core.search_postgres_delete_index_before - * @var array sql_queries Array with queries for deleting the search index - * @var array stats Array with statistics of the current index (read only) - * @since 3.2.3-RC1 - */ - $vars = array( - 'sql_queries', - 'stats', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_postgres_delete_index_before', compact($vars))); - - foreach ($sql_queries as $sql_query) - { - $this->db->sql_query($sql_query); - } - - $this->db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE); - - return false; - } - - /** - * Returns true if both FULLTEXT indexes exist - */ - public function index_created() - { - if (empty($this->stats)) - { - $this->get_stats(); - } - - return (isset($this->stats['post_subject']) && isset($this->stats['post_content'])) ? true : false; - } - - /** - * Returns an associative array containing information about the indexes - */ - public function index_stats() - { - if (empty($this->stats)) - { - $this->get_stats(); - } - - return array( - $this->user->lang['FULLTEXT_POSTGRES_TOTAL_POSTS'] => ($this->index_created()) ? $this->stats['total_posts'] : 0, - ); - } - - /** - * Computes the stats and store them in the $this->stats associative array - */ - protected function get_stats() - { - if ($this->db->get_sql_layer() != 'postgres') - { - $this->stats = array(); - return; - } - - $sql = "SELECT c2.relname, pg_catalog.pg_get_indexdef(i.indexrelid, 0, true) AS indexdef - FROM pg_catalog.pg_class c1, pg_catalog.pg_index i, pg_catalog.pg_class c2 - WHERE c1.relname = '" . POSTS_TABLE . "' - AND pg_catalog.pg_table_is_visible(c1.oid) - AND c1.oid = i.indrelid - AND i.indexrelid = c2.oid"; - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - // deal with older PostgreSQL versions which didn't use Index_type - if (strpos($row['indexdef'], 'to_tsvector') !== false) - { - if ($row['relname'] == POSTS_TABLE . '_' . $this->config['fulltext_postgres_ts_name'] . '_post_subject' || $row['relname'] == POSTS_TABLE . '_post_subject') - { - $this->stats['post_subject'] = $row; - } - else if ($row['relname'] == POSTS_TABLE . '_' . $this->config['fulltext_postgres_ts_name'] . '_post_content' || $row['relname'] == POSTS_TABLE . '_post_content') - { - $this->stats['post_content'] = $row; - } - } - } - $this->db->sql_freeresult($result); - - $this->stats['total_posts'] = $this->config['num_posts']; - } - - /** - * Display various options that can be configured for the backend from the acp - * - * @return associative array containing template and config variables - */ - public function acp() - { - $tpl = ' -
-

' . $this->user->lang['FULLTEXT_POSTGRES_VERSION_CHECK_EXPLAIN'] . '
-
' . (($this->db->get_sql_layer() == 'postgres') ? $this->user->lang['YES'] : $this->user->lang['NO']) . '
-
-
-

' . $this->user->lang['FULLTEXT_POSTGRES_TS_NAME_EXPLAIN'] . '
-
-
-
-

' . $this->user->lang['FULLTEXT_POSTGRES_MIN_WORD_LEN_EXPLAIN'] . '
-
-
-
-

' . $this->user->lang['FULLTEXT_POSTGRES_MAX_WORD_LEN_EXPLAIN'] . '
-
-
- '; - - // These are fields required in the config table - return array( - 'tpl' => $tpl, - 'config' => array('fulltext_postgres_ts_name' => 'string', 'fulltext_postgres_min_word_len' => 'integer:0:255', 'fulltext_postgres_max_word_len' => 'integer:0:255') - ); - } -} diff --git a/install/update/new/phpbb/search/fulltext_sphinx.php b/install/update/new/phpbb/search/fulltext_sphinx.php deleted file mode 100644 index d2e12fd..0000000 --- a/install/update/new/phpbb/search/fulltext_sphinx.php +++ /dev/null @@ -1,993 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\search; - -define('SPHINX_MAX_MATCHES', 20000); -define('SPHINX_CONNECT_RETRIES', 3); -define('SPHINX_CONNECT_WAIT_TIME', 300); - -/** -* Fulltext search based on the sphinx search daemon -*/ -class fulltext_sphinx -{ - /** - * Associative array holding index stats - * @var array - */ - protected $stats = array(); - - /** - * Holds the words entered by user, obtained by splitting the entered query on whitespace - * @var array - */ - protected $split_words = array(); - - /** - * Holds unique sphinx id - * @var string - */ - protected $id; - - /** - * Stores the names of both main and delta sphinx indexes - * separated by a semicolon - * @var string - */ - protected $indexes; - - /** - * Sphinx searchd client object - * @var SphinxClient - */ - protected $sphinx; - - /** - * Relative path to board root - * @var string - */ - protected $phpbb_root_path; - - /** - * PHP Extension - * @var string - */ - protected $php_ext; - - /** - * Auth object - * @var \phpbb\auth\auth - */ - protected $auth; - - /** - * Config object - * @var \phpbb\config\config - */ - protected $config; - - /** - * Database connection - * @var \phpbb\db\driver\driver_interface - */ - protected $db; - - /** - * Database Tools object - * @var \phpbb\db\tools\tools_interface - */ - protected $db_tools; - - /** - * Stores the database type if supported by sphinx - * @var string - */ - protected $dbtype; - - /** - * phpBB event dispatcher object - * @var \phpbb\event\dispatcher_interface - */ - protected $phpbb_dispatcher; - - /** - * User object - * @var \phpbb\user - */ - protected $user; - - /** - * Stores the generated content of the sphinx config file - * @var string - */ - protected $config_file_data = ''; - - /** - * Contains tidied search query. - * Operators are prefixed in search query and common words excluded - * @var string - */ - protected $search_query; - - /** - * Constructor - * Creates a new \phpbb\search\fulltext_postgres, which is used as a search backend - * - * @param string|bool $error Any error that occurs is passed on through this reference variable otherwise false - * @param string $phpbb_root_path Relative path to phpBB root - * @param string $phpEx PHP file extension - * @param \phpbb\auth\auth $auth Auth object - * @param \phpbb\config\config $config Config object - * @param \phpbb\db\driver\driver_interface Database object - * @param \phpbb\user $user User object - * @param \phpbb\event\dispatcher_interface $phpbb_dispatcher Event dispatcher object - */ - public function __construct(&$error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher) - { - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $phpEx; - $this->config = $config; - $this->phpbb_dispatcher = $phpbb_dispatcher; - $this->user = $user; - $this->db = $db; - $this->auth = $auth; - - // Initialize \phpbb\db\tools\tools object - global $phpbb_container; // TODO inject into object - $this->db_tools = $phpbb_container->get('dbal.tools'); - - if (!$this->config['fulltext_sphinx_id']) - { - $this->config->set('fulltext_sphinx_id', unique_id()); - } - $this->id = $this->config['fulltext_sphinx_id']; - $this->indexes = 'index_phpbb_' . $this->id . '_delta;index_phpbb_' . $this->id . '_main'; - - if (!class_exists('SphinxClient')) - { - require($this->phpbb_root_path . 'includes/sphinxapi.' . $this->php_ext); - } - - // Initialize sphinx client - $this->sphinx = new \SphinxClient(); - - $this->sphinx->SetServer(($this->config['fulltext_sphinx_host'] ? $this->config['fulltext_sphinx_host'] : 'localhost'), ($this->config['fulltext_sphinx_port'] ? (int) $this->config['fulltext_sphinx_port'] : 9312)); - - $error = false; - } - - /** - * Returns the name of this search backend to be displayed to administrators - * - * @return string Name - */ - public function get_name() - { - return 'Sphinx Fulltext'; - } - - /** - * Returns the search_query - * - * @return string search query - */ - public function get_search_query() - { - return $this->search_query; - } - - /** - * Returns false as there is no word_len array - * - * @return false - */ - public function get_word_length() - { - return false; - } - - /** - * Returns an empty array as there are no common_words - * - * @return array common words that are ignored by search backend - */ - public function get_common_words() - { - return array(); - } - - /** - * Checks permissions and paths, if everything is correct it generates the config file - * - * @return string|bool Language key of the error/incompatibility encountered, or false if successful - */ - public function init() - { - if ($this->db->get_sql_layer() != 'mysqli' && $this->db->get_sql_layer() != 'postgres') - { - return $this->user->lang['FULLTEXT_SPHINX_WRONG_DATABASE']; - } - - // Move delta to main index each hour - $this->config->set('search_gc', 3600); - - return false; - } - - /** - * Generates content of sphinx.conf - * - * @return bool True if sphinx.conf content is correctly generated, false otherwise - */ - protected function config_generate() - { - // Check if Database is supported by Sphinx - if ($this->db->get_sql_layer() == 'mysqli') - { - $this->dbtype = 'mysql'; - } - else if ($this->db->get_sql_layer() == 'postgres') - { - $this->dbtype = 'pgsql'; - } - else - { - $this->config_file_data = $this->user->lang('FULLTEXT_SPHINX_WRONG_DATABASE'); - return false; - } - - // Check if directory paths have been filled - if (!$this->config['fulltext_sphinx_data_path']) - { - $this->config_file_data = $this->user->lang('FULLTEXT_SPHINX_NO_CONFIG_DATA'); - return false; - } - - include($this->phpbb_root_path . 'config.' . $this->php_ext); - - /* Now that we're sure everything was entered correctly, - generate a config for the index. We use a config value - fulltext_sphinx_id for this, as it should be unique. */ - $config_object = new \phpbb\search\sphinx\config($this->config_file_data); - $config_data = array( - 'source source_phpbb_' . $this->id . '_main' => array( - array('type', $this->dbtype . ' # mysql or pgsql'), - // This config value sql_host needs to be changed incase sphinx and sql are on different servers - array('sql_host', $dbhost . ' # SQL server host sphinx connects to'), - array('sql_user', '[dbuser]'), - array('sql_pass', '[dbpassword]'), - array('sql_db', $dbname), - array('sql_port', $dbport . ' # optional, default is 3306 for mysql and 5432 for pgsql'), - array('sql_query_pre', 'SET NAMES \'utf8\''), - array('sql_query_pre', 'UPDATE ' . SPHINX_TABLE . ' SET max_doc_id = (SELECT MAX(post_id) FROM ' . POSTS_TABLE . ') WHERE counter_id = 1'), - array('sql_query_range', 'SELECT MIN(post_id), MAX(post_id) FROM ' . POSTS_TABLE . ''), - array('sql_range_step', '5000'), - array('sql_query', 'SELECT - p.post_id AS id, - p.forum_id, - p.topic_id, - p.poster_id, - p.post_visibility, - CASE WHEN p.post_id = t.topic_first_post_id THEN 1 ELSE 0 END as topic_first_post, - p.post_time, - p.post_subject, - p.post_subject as title, - p.post_text as data, - t.topic_last_post_time, - 0 as deleted - FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t - WHERE - p.topic_id = t.topic_id - AND p.post_id >= $start AND p.post_id <= $end'), - array('sql_query_post', ''), - array('sql_query_post_index', 'UPDATE ' . SPHINX_TABLE . ' SET max_doc_id = $maxid WHERE counter_id = 1'), - array('sql_attr_uint', 'forum_id'), - array('sql_attr_uint', 'topic_id'), - array('sql_attr_uint', 'poster_id'), - array('sql_attr_uint', 'post_visibility'), - array('sql_attr_bool', 'topic_first_post'), - array('sql_attr_bool', 'deleted'), - array('sql_attr_timestamp', 'post_time'), - array('sql_attr_timestamp', 'topic_last_post_time'), - array('sql_attr_string', 'post_subject'), - ), - 'source source_phpbb_' . $this->id . '_delta : source_phpbb_' . $this->id . '_main' => array( - array('sql_query_pre', 'SET NAMES \'utf8\''), - array('sql_query_range', ''), - array('sql_range_step', ''), - array('sql_query', 'SELECT - p.post_id AS id, - p.forum_id, - p.topic_id, - p.poster_id, - p.post_visibility, - CASE WHEN p.post_id = t.topic_first_post_id THEN 1 ELSE 0 END as topic_first_post, - p.post_time, - p.post_subject, - p.post_subject as title, - p.post_text as data, - t.topic_last_post_time, - 0 as deleted - FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t - WHERE - p.topic_id = t.topic_id - AND p.post_id >= ( SELECT max_doc_id FROM ' . SPHINX_TABLE . ' WHERE counter_id=1 )'), - array('sql_query_post_index', ''), - ), - 'index index_phpbb_' . $this->id . '_main' => array( - array('path', $this->config['fulltext_sphinx_data_path'] . 'index_phpbb_' . $this->id . '_main'), - array('source', 'source_phpbb_' . $this->id . '_main'), - array('docinfo', 'extern'), - array('morphology', 'none'), - array('stopwords', ''), - array('min_word_len', '2'), - array('charset_table', 'U+FF10..U+FF19->0..9, 0..9, U+FF41..U+FF5A->a..z, U+FF21..U+FF3A->a..z, A..Z->a..z, a..z, U+0149, U+017F, U+0138, U+00DF, U+00FF, U+00C0..U+00D6->U+00E0..U+00F6, U+00E0..U+00F6, U+00D8..U+00DE->U+00F8..U+00FE, U+00F8..U+00FE, U+0100->U+0101, U+0101, U+0102->U+0103, U+0103, U+0104->U+0105, U+0105, U+0106->U+0107, U+0107, U+0108->U+0109, U+0109, U+010A->U+010B, U+010B, U+010C->U+010D, U+010D, U+010E->U+010F, U+010F, U+0110->U+0111, U+0111, U+0112->U+0113, U+0113, U+0114->U+0115, U+0115, U+0116->U+0117, U+0117, U+0118->U+0119, U+0119, U+011A->U+011B, U+011B, U+011C->U+011D, U+011D, U+011E->U+011F, U+011F, U+0130->U+0131, U+0131, U+0132->U+0133, U+0133, U+0134->U+0135, U+0135, U+0136->U+0137, U+0137, U+0139->U+013A, U+013A, U+013B->U+013C, U+013C, U+013D->U+013E, U+013E, U+013F->U+0140, U+0140, U+0141->U+0142, U+0142, U+0143->U+0144, U+0144, U+0145->U+0146, U+0146, U+0147->U+0148, U+0148, U+014A->U+014B, U+014B, U+014C->U+014D, U+014D, U+014E->U+014F, U+014F, U+0150->U+0151, U+0151, U+0152->U+0153, U+0153, U+0154->U+0155, U+0155, U+0156->U+0157, U+0157, U+0158->U+0159, U+0159, U+015A->U+015B, U+015B, U+015C->U+015D, U+015D, U+015E->U+015F, U+015F, U+0160->U+0161, U+0161, U+0162->U+0163, U+0163, U+0164->U+0165, U+0165, U+0166->U+0167, U+0167, U+0168->U+0169, U+0169, U+016A->U+016B, U+016B, U+016C->U+016D, U+016D, U+016E->U+016F, U+016F, U+0170->U+0171, U+0171, U+0172->U+0173, U+0173, U+0174->U+0175, U+0175, U+0176->U+0177, U+0177, U+0178->U+00FF, U+00FF, U+0179->U+017A, U+017A, U+017B->U+017C, U+017C, U+017D->U+017E, U+017E, U+0410..U+042F->U+0430..U+044F, U+0430..U+044F, U+4E00..U+9FFF'), - array('min_prefix_len', '0'), - array('min_infix_len', '0'), - array('html_strip', '1'), - ), - 'index index_phpbb_' . $this->id . '_delta : index_phpbb_' . $this->id . '_main' => array( - array('path', $this->config['fulltext_sphinx_data_path'] . 'index_phpbb_' . $this->id . '_delta'), - array('source', 'source_phpbb_' . $this->id . '_delta'), - ), - 'indexer' => array( - array('mem_limit', $this->config['fulltext_sphinx_indexer_mem_limit'] . 'M'), - ), - 'searchd' => array( - array('listen' , ($this->config['fulltext_sphinx_host'] ? $this->config['fulltext_sphinx_host'] : 'localhost') . ':' . ($this->config['fulltext_sphinx_port'] ? $this->config['fulltext_sphinx_port'] : '9312')), - array('log', $this->config['fulltext_sphinx_data_path'] . 'log/searchd.log'), - array('query_log', $this->config['fulltext_sphinx_data_path'] . 'log/sphinx-query.log'), - array('read_timeout', '5'), - array('max_children', '30'), - array('pid_file', $this->config['fulltext_sphinx_data_path'] . 'searchd.pid'), - array('binlog_path', $this->config['fulltext_sphinx_data_path']), - ), - ); - - $non_unique = array('sql_query_pre' => true, 'sql_attr_uint' => true, 'sql_attr_timestamp' => true, 'sql_attr_str2ordinal' => true, 'sql_attr_bool' => true); - $delete = array('sql_group_column' => true, 'sql_date_column' => true, 'sql_str2ordinal_column' => true); - - /** - * Allow adding/changing the Sphinx configuration data - * - * @event core.search_sphinx_modify_config_data - * @var array config_data Array with the Sphinx configuration data - * @var array non_unique Array with the Sphinx non-unique variables to delete - * @var array delete Array with the Sphinx variables to delete - * @since 3.1.7-RC1 - */ - $vars = array( - 'config_data', - 'non_unique', - 'delete', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_sphinx_modify_config_data', compact($vars))); - - foreach ($config_data as $section_name => $section_data) - { - $section = $config_object->get_section_by_name($section_name); - if (!$section) - { - $section = $config_object->add_section($section_name); - } - - foreach ($delete as $key => $void) - { - $section->delete_variables_by_name($key); - } - - foreach ($non_unique as $key => $void) - { - $section->delete_variables_by_name($key); - } - - foreach ($section_data as $entry) - { - $key = $entry[0]; - $value = $entry[1]; - - if (!isset($non_unique[$key])) - { - $variable = $section->get_variable_by_name($key); - if (!$variable) - { - $section->create_variable($key, $value); - } - else - { - $variable->set_value($value); - } - } - else - { - $section->create_variable($key, $value); - } - } - } - $this->config_file_data = $config_object->get_data(); - - return true; - } - - /** - * Splits keywords entered by a user into an array of words stored in $this->split_words - * Stores the tidied search query in $this->search_query - * - * @param string $keywords Contains the keyword as entered by the user - * @param string $terms is either 'all' or 'any' - * @return false if no valid keywords were found and otherwise true - */ - public function split_keywords(&$keywords, $terms) - { - if ($terms == 'all') - { - $match = array('#\sand\s#i', '#\sor\s#i', '#\snot\s#i', '#\+#', '#-#', '#\|#', '#@#'); - $replace = array(' & ', ' | ', ' - ', ' +', ' -', ' |', ''); - - $keywords = preg_replace($match, $replace, $keywords); - $this->sphinx->SetMatchMode(SPH_MATCH_EXTENDED); - } - else - { - $this->sphinx->SetMatchMode(SPH_MATCH_ANY); - } - - // Keep quotes and new lines - $keywords = str_replace(array('"', "\n"), array('"', ' '), trim($keywords)); - - if (strlen($keywords) > 0) - { - $this->search_query = str_replace('"', '"', $keywords); - return true; - } - - return false; - } - - /** - * Performs a search on keywords depending on display specific params. You have to run split_keywords() first - * - * @param string $type contains either posts or topics depending on what should be searched for - * @param string $fields contains either titleonly (topic titles should be searched), msgonly (only message bodies should be searched), firstpost (only subject and body of the first post should be searched) or all (all post bodies and subjects should be searched) - * @param string $terms is either 'all' (use query as entered, words without prefix should default to "have to be in field") or 'any' (ignore search query parts and just return all posts that contain any of the specified words) - * @param array $sort_by_sql contains SQL code for the ORDER BY part of a query - * @param string $sort_key is the key of $sort_by_sql for the selected sorting - * @param string $sort_dir is either a or d representing ASC and DESC - * @param string $sort_days specifies the maximum amount of days a post may be old - * @param array $ex_fid_ary specifies an array of forum ids which should not be searched - * @param string $post_visibility specifies which types of posts the user can view in which forums - * @param int $topic_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched - * @param array $author_ary an array of author ids if the author should be ignored during the search the array is empty - * @param string $author_name specifies the author match, when ANONYMOUS is also a search-match - * @param array &$id_ary passed by reference, to be filled with ids for the page specified by $start and $per_page, should be ordered - * @param int $start indicates the first index of the page - * @param int $per_page number of ids each page is supposed to contain - * @return boolean|int total number of results - */ - public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page) - { - global $user, $phpbb_log; - - // No keywords? No posts. - if (!strlen($this->search_query) && !count($author_ary)) - { - return false; - } - - $id_ary = array(); - - // Sorting - - if ($type == 'topics') - { - switch ($sort_key) - { - case 'a': - $this->sphinx->SetGroupBy('topic_id', SPH_GROUPBY_ATTR, 'poster_id ' . (($sort_dir == 'a') ? 'ASC' : 'DESC')); - break; - - case 'f': - $this->sphinx->SetGroupBy('topic_id', SPH_GROUPBY_ATTR, 'forum_id ' . (($sort_dir == 'a') ? 'ASC' : 'DESC')); - break; - - case 'i': - - case 's': - $this->sphinx->SetGroupBy('topic_id', SPH_GROUPBY_ATTR, 'post_subject ' . (($sort_dir == 'a') ? 'ASC' : 'DESC')); - break; - - case 't': - - default: - $this->sphinx->SetGroupBy('topic_id', SPH_GROUPBY_ATTR, 'topic_last_post_time ' . (($sort_dir == 'a') ? 'ASC' : 'DESC')); - break; - } - } - else - { - switch ($sort_key) - { - case 'a': - $this->sphinx->SetSortMode(($sort_dir == 'a') ? SPH_SORT_ATTR_ASC : SPH_SORT_ATTR_DESC, 'poster_id'); - break; - - case 'f': - $this->sphinx->SetSortMode(($sort_dir == 'a') ? SPH_SORT_ATTR_ASC : SPH_SORT_ATTR_DESC, 'forum_id'); - break; - - case 'i': - - case 's': - $this->sphinx->SetSortMode(($sort_dir == 'a') ? SPH_SORT_ATTR_ASC : SPH_SORT_ATTR_DESC, 'post_subject'); - break; - - case 't': - - default: - $this->sphinx->SetSortMode(($sort_dir == 'a') ? SPH_SORT_ATTR_ASC : SPH_SORT_ATTR_DESC, 'post_time'); - break; - } - } - - // Most narrow filters first - if ($topic_id) - { - $this->sphinx->SetFilter('topic_id', array($topic_id)); - } - - /** - * Allow modifying the Sphinx search options - * - * @event core.search_sphinx_keywords_modify_options - * @var string type Searching type ('posts', 'topics') - * @var string fields Searching fields ('titleonly', 'msgonly', 'firstpost', 'all') - * @var string terms Searching terms ('all', 'any') - * @var int sort_days Time, in days, of the oldest possible post to list - * @var string sort_key The sort type used from the possible sort types - * @var int topic_id Limit the search to this topic_id only - * @var array ex_fid_ary Which forums not to search on - * @var string post_visibility Post visibility data - * @var array author_ary Array of user_id containing the users to filter the results to - * @var string author_name The username to search on - * @var object sphinx The Sphinx searchd client object - * @since 3.1.7-RC1 - */ - $sphinx = $this->sphinx; - $vars = array( - 'type', - 'fields', - 'terms', - 'sort_days', - 'sort_key', - 'topic_id', - 'ex_fid_ary', - 'post_visibility', - 'author_ary', - 'author_name', - 'sphinx', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_sphinx_keywords_modify_options', compact($vars))); - $this->sphinx = $sphinx; - unset($sphinx); - - $search_query_prefix = ''; - - switch ($fields) - { - case 'titleonly': - // Only search the title - if ($terms == 'all') - { - $search_query_prefix = '@title '; - } - // Weight for the title - $this->sphinx->SetFieldWeights(array("title" => 5, "data" => 1)); - // 1 is first_post, 0 is not first post - $this->sphinx->SetFilter('topic_first_post', array(1)); - break; - - case 'msgonly': - // Only search the body - if ($terms == 'all') - { - $search_query_prefix = '@data '; - } - // Weight for the body - $this->sphinx->SetFieldWeights(array("title" => 1, "data" => 5)); - break; - - case 'firstpost': - // More relative weight for the title, also search the body - $this->sphinx->SetFieldWeights(array("title" => 5, "data" => 1)); - // 1 is first_post, 0 is not first post - $this->sphinx->SetFilter('topic_first_post', array(1)); - break; - - default: - // More relative weight for the title, also search the body - $this->sphinx->SetFieldWeights(array("title" => 5, "data" => 1)); - break; - } - - if (count($author_ary)) - { - $this->sphinx->SetFilter('poster_id', $author_ary); - } - - // As this is not simply possible at the moment, we limit the result to approved posts. - // This will make it impossible for moderators to search unapproved and softdeleted posts, - // but at least it will also cause the same for normal users. - $this->sphinx->SetFilter('post_visibility', array(ITEM_APPROVED)); - - if (count($ex_fid_ary)) - { - // All forums that a user is allowed to access - $fid_ary = array_unique(array_intersect(array_keys($this->auth->acl_getf('f_read', true)), array_keys($this->auth->acl_getf('f_search', true)))); - // All forums that the user wants to and can search in - $search_forums = array_diff($fid_ary, $ex_fid_ary); - - if (count($search_forums)) - { - $this->sphinx->SetFilter('forum_id', $search_forums); - } - } - - $this->sphinx->SetFilter('deleted', array(0)); - - $this->sphinx->SetLimits((int) $start, (int) $per_page, max(SPHINX_MAX_MATCHES, (int) $start + $per_page)); - $result = $this->sphinx->Query($search_query_prefix . $this->sphinx->EscapeString(str_replace('"', '"', $this->search_query)), $this->indexes); - - // Could be connection to localhost:9312 failed (errno=111, - // msg=Connection refused) during rotate, retry if so - $retries = SPHINX_CONNECT_RETRIES; - while (!$result && (strpos($this->sphinx->GetLastError(), "errno=111,") !== false) && $retries--) - { - usleep(SPHINX_CONNECT_WAIT_TIME); - $result = $this->sphinx->Query($search_query_prefix . $this->sphinx->EscapeString(str_replace('"', '"', $this->search_query)), $this->indexes); - } - - if ($this->sphinx->GetLastError()) - { - $phpbb_log->add('critical', $user->data['user_id'], $user->ip, 'LOG_SPHINX_ERROR', false, array($this->sphinx->GetLastError())); - if ($this->auth->acl_get('a_')) - { - trigger_error($this->user->lang('SPHINX_SEARCH_FAILED', $this->sphinx->GetLastError())); - } - else - { - trigger_error($this->user->lang('SPHINX_SEARCH_FAILED_LOG')); - } - } - - $result_count = $result['total_found']; - - if ($result_count && $start >= $result_count) - { - $start = floor(($result_count - 1) / $per_page) * $per_page; - - $this->sphinx->SetLimits((int) $start, (int) $per_page, max(SPHINX_MAX_MATCHES, (int) $start + $per_page)); - $result = $this->sphinx->Query($search_query_prefix . $this->sphinx->EscapeString(str_replace('"', '"', $this->search_query)), $this->indexes); - - // Could be connection to localhost:9312 failed (errno=111, - // msg=Connection refused) during rotate, retry if so - $retries = SPHINX_CONNECT_RETRIES; - while (!$result && (strpos($this->sphinx->GetLastError(), "errno=111,") !== false) && $retries--) - { - usleep(SPHINX_CONNECT_WAIT_TIME); - $result = $this->sphinx->Query($search_query_prefix . $this->sphinx->EscapeString(str_replace('"', '"', $this->search_query)), $this->indexes); - } - } - - $id_ary = array(); - if (isset($result['matches'])) - { - if ($type == 'posts') - { - $id_ary = array_keys($result['matches']); - } - else - { - foreach ($result['matches'] as $key => $value) - { - $id_ary[] = $value['attrs']['topic_id']; - } - } - } - else - { - return false; - } - - $id_ary = array_slice($id_ary, 0, (int) $per_page); - - return $result_count; - } - - /** - * Performs a search on an author's posts without caring about message contents. Depends on display specific params - * - * @param string $type contains either posts or topics depending on what should be searched for - * @param boolean $firstpost_only if true, only topic starting posts will be considered - * @param array $sort_by_sql contains SQL code for the ORDER BY part of a query - * @param string $sort_key is the key of $sort_by_sql for the selected sorting - * @param string $sort_dir is either a or d representing ASC and DESC - * @param string $sort_days specifies the maximum amount of days a post may be old - * @param array $ex_fid_ary specifies an array of forum ids which should not be searched - * @param string $post_visibility specifies which types of posts the user can view in which forums - * @param int $topic_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched - * @param array $author_ary an array of author ids - * @param string $author_name specifies the author match, when ANONYMOUS is also a search-match - * @param array &$id_ary passed by reference, to be filled with ids for the page specified by $start and $per_page, should be ordered - * @param int $start indicates the first index of the page - * @param int $per_page number of ids each page is supposed to contain - * @return boolean|int total number of results - */ - public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page) - { - $this->search_query = ''; - - $this->sphinx->SetMatchMode(SPH_MATCH_FULLSCAN); - $fields = ($firstpost_only) ? 'firstpost' : 'all'; - $terms = 'all'; - return $this->keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, $id_ary, $start, $per_page); - } - - /** - * Updates wordlist and wordmatch tables when a message is posted or changed - * - * @param string $mode Contains the post mode: edit, post, reply, quote - * @param int $post_id The id of the post which is modified/created - * @param string &$message New or updated post content - * @param string &$subject New or updated post subject - * @param int $poster_id Post author's user id - * @param int $forum_id The id of the forum in which the post is located - */ - public function index($mode, $post_id, &$message, &$subject, $poster_id, $forum_id) - { - /** - * Event to modify method arguments before the Sphinx search index is updated - * - * @event core.search_sphinx_index_before - * @var string mode Contains the post mode: edit, post, reply, quote - * @var int post_id The id of the post which is modified/created - * @var string message New or updated post content - * @var string subject New or updated post subject - * @var int poster_id Post author's user id - * @var int forum_id The id of the forum in which the post is located - * @since 3.2.3-RC1 - */ - $vars = array( - 'mode', - 'post_id', - 'message', - 'subject', - 'poster_id', - 'forum_id', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_sphinx_index_before', compact($vars))); - - if ($mode == 'edit') - { - $this->sphinx->UpdateAttributes($this->indexes, array('forum_id', 'poster_id'), array((int) $post_id => array((int) $forum_id, (int) $poster_id))); - } - else if ($mode != 'post' && $post_id) - { - // Update topic_last_post_time for full topic - $sql_array = array( - 'SELECT' => 'p1.post_id', - 'FROM' => array( - POSTS_TABLE => 'p1', - ), - 'LEFT_JOIN' => array(array( - 'FROM' => array( - POSTS_TABLE => 'p2' - ), - 'ON' => 'p1.topic_id = p2.topic_id', - )), - 'WHERE' => 'p2.post_id = ' . ((int) $post_id), - ); - - $sql = $this->db->sql_build_query('SELECT', $sql_array); - $result = $this->db->sql_query($sql); - - $post_updates = array(); - $post_time = time(); - while ($row = $this->db->sql_fetchrow($result)) - { - $post_updates[(int) $row['post_id']] = array($post_time); - } - $this->db->sql_freeresult($result); - - if (count($post_updates)) - { - $this->sphinx->UpdateAttributes($this->indexes, array('topic_last_post_time'), $post_updates); - } - } - } - - /** - * Delete a post from the index after it was deleted - */ - public function index_remove($post_ids, $author_ids, $forum_ids) - { - $values = array(); - foreach ($post_ids as $post_id) - { - $values[$post_id] = array(1); - } - - $this->sphinx->UpdateAttributes($this->indexes, array('deleted'), $values); - } - - /** - * Nothing needs to be destroyed - */ - public function tidy($create = false) - { - $this->config->set('search_last_gc', time(), false); - } - - /** - * Create sphinx table - * - * @return string|bool error string is returned incase of errors otherwise false - */ - public function create_index($acp_module, $u_action) - { - if (!$this->index_created()) - { - $table_data = array( - 'COLUMNS' => array( - 'counter_id' => array('UINT', 0), - 'max_doc_id' => array('UINT', 0), - ), - 'PRIMARY_KEY' => 'counter_id', - ); - $this->db_tools->sql_create_table(SPHINX_TABLE, $table_data); - - $sql = 'TRUNCATE TABLE ' . SPHINX_TABLE; - $this->db->sql_query($sql); - - $data = array( - 'counter_id' => '1', - 'max_doc_id' => '0', - ); - $sql = 'INSERT INTO ' . SPHINX_TABLE . ' ' . $this->db->sql_build_array('INSERT', $data); - $this->db->sql_query($sql); - } - - return false; - } - - /** - * Drop sphinx table - * - * @return string|bool error string is returned incase of errors otherwise false - */ - public function delete_index($acp_module, $u_action) - { - if (!$this->index_created()) - { - return false; - } - - $this->db_tools->sql_table_drop(SPHINX_TABLE); - - return false; - } - - /** - * Returns true if the sphinx table was created - * - * @return bool true if sphinx table was created - */ - public function index_created($allow_new_files = true) - { - $created = false; - - if ($this->db_tools->sql_table_exists(SPHINX_TABLE)) - { - $created = true; - } - - return $created; - } - - /** - * Returns an associative array containing information about the indexes - * - * @return string|bool Language string of error false otherwise - */ - public function index_stats() - { - if (empty($this->stats)) - { - $this->get_stats(); - } - - return array( - $this->user->lang['FULLTEXT_SPHINX_MAIN_POSTS'] => ($this->index_created()) ? $this->stats['main_posts'] : 0, - $this->user->lang['FULLTEXT_SPHINX_DELTA_POSTS'] => ($this->index_created()) ? $this->stats['total_posts'] - $this->stats['main_posts'] : 0, - $this->user->lang['FULLTEXT_MYSQL_TOTAL_POSTS'] => ($this->index_created()) ? $this->stats['total_posts'] : 0, - ); - } - - /** - * Collects stats that can be displayed on the index maintenance page - */ - protected function get_stats() - { - if ($this->index_created()) - { - $sql = 'SELECT COUNT(post_id) as total_posts - FROM ' . POSTS_TABLE; - $result = $this->db->sql_query($sql); - $this->stats['total_posts'] = (int) $this->db->sql_fetchfield('total_posts'); - $this->db->sql_freeresult($result); - - $sql = 'SELECT COUNT(p.post_id) as main_posts - FROM ' . POSTS_TABLE . ' p, ' . SPHINX_TABLE . ' m - WHERE p.post_id <= m.max_doc_id - AND m.counter_id = 1'; - $result = $this->db->sql_query($sql); - $this->stats['main_posts'] = (int) $this->db->sql_fetchfield('main_posts'); - $this->db->sql_freeresult($result); - } - } - - /** - * Returns a list of options for the ACP to display - * - * @return associative array containing template and config variables - */ - public function acp() - { - $config_vars = array( - 'fulltext_sphinx_data_path' => 'string', - 'fulltext_sphinx_host' => 'string', - 'fulltext_sphinx_port' => 'string', - 'fulltext_sphinx_indexer_mem_limit' => 'int', - ); - - $tpl = ' - ' . $this->user->lang['FULLTEXT_SPHINX_CONFIGURE']. ' -
-

' . $this->user->lang['FULLTEXT_SPHINX_DATA_PATH_EXPLAIN'] . '
-
-
-
-

' . $this->user->lang['FULLTEXT_SPHINX_HOST_EXPLAIN'] . '
-
-
-
-

' . $this->user->lang['FULLTEXT_SPHINX_PORT_EXPLAIN'] . '
-
-
-
-

' . $this->user->lang['FULLTEXT_SPHINX_INDEXER_MEM_LIMIT_EXPLAIN'] . '
-
' . $this->user->lang['MIB'] . '
-
-
-

' . $this->user->lang['FULLTEXT_SPHINX_CONFIG_FILE_EXPLAIN'] . '
-
' . (($this->config_generate()) ? '' : $this->config_file_data) . '
-
- '; - - // These are fields required in the config table - return array( - 'tpl' => $tpl, - 'config' => $config_vars - ); - } -} diff --git a/install/update/new/phpbb/session.php b/install/update/new/phpbb/session.php deleted file mode 100644 index 6851bc8..0000000 --- a/install/update/new/phpbb/session.php +++ /dev/null @@ -1,1667 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb; - -/** -* Session class -*/ -class session -{ - var $cookie_data = array(); - var $page = array(); - var $data = array(); - var $browser = ''; - var $forwarded_for = ''; - var $host = ''; - var $session_id = ''; - var $ip = ''; - var $load = 0; - var $time_now = 0; - var $update_session_page = true; - - /** - * Extract current session page - * - * @param string $root_path current root path (phpbb_root_path) - * @return array - */ - static function extract_current_page($root_path) - { - global $request, $symfony_request, $phpbb_filesystem; - - $page_array = array(); - - // First of all, get the request uri... - $script_name = $request->escape($symfony_request->getScriptName(), true); - $args = $request->escape(explode('&', $symfony_request->getQueryString()), true); - - // If we are unable to get the script name we use REQUEST_URI as a failover and note it within the page array for easier support... - if (!$script_name) - { - $script_name = htmlspecialchars_decode($request->server('REQUEST_URI')); - $script_name = (($pos = strpos($script_name, '?')) !== false) ? substr($script_name, 0, $pos) : $script_name; - $page_array['failover'] = 1; - } - - // Replace backslashes and doubled slashes (could happen on some proxy setups) - $script_name = str_replace(array('\\', '//'), '/', $script_name); - - // Now, remove the sid and let us get a clean query string... - $use_args = array(); - - // Since some browser do not encode correctly we need to do this with some "special" characters... - // " -> %22, ' => %27, < -> %3C, > -> %3E - $find = array('"', "'", '<', '>', '"', '<', '>'); - $replace = array('%22', '%27', '%3C', '%3E', '%22', '%3C', '%3E'); - - foreach ($args as $key => $argument) - { - if (strpos($argument, 'sid=') === 0) - { - continue; - } - - $use_args[] = str_replace($find, $replace, $argument); - } - unset($args); - - // The following examples given are for an request uri of {path to the phpbb directory}/adm/index.php?i=10&b=2 - - // The current query string - $query_string = trim(implode('&', $use_args)); - - // basenamed page name (for example: index.php) - $page_name = (substr($script_name, -1, 1) == '/') ? '' : basename($script_name); - $page_name = urlencode(htmlspecialchars($page_name)); - - $symfony_request_path = $phpbb_filesystem->clean_path($symfony_request->getPathInfo()); - if ($symfony_request_path !== '/') - { - $page_name .= str_replace('%2F', '/', urlencode($symfony_request_path)); - } - - if (substr($root_path, 0, 2) === './' && strpos($root_path, '..') === false) - { - $root_dirs = explode('/', str_replace('\\', '/', rtrim($root_path, '/'))); - $page_dirs = explode('/', str_replace('\\', '/', '.')); - } - else - { - // current directory within the phpBB root (for example: adm) - $root_dirs = explode('/', str_replace('\\', '/', $phpbb_filesystem->realpath($root_path))); - $page_dirs = explode('/', str_replace('\\', '/', $phpbb_filesystem->realpath('./'))); - } - - $intersection = array_intersect_assoc($root_dirs, $page_dirs); - - $root_dirs = array_diff_assoc($root_dirs, $intersection); - $page_dirs = array_diff_assoc($page_dirs, $intersection); - - $page_dir = str_repeat('../', count($root_dirs)) . implode('/', $page_dirs); - - if ($page_dir && substr($page_dir, -1, 1) == '/') - { - $page_dir = substr($page_dir, 0, -1); - } - - // Current page from phpBB root (for example: adm/index.php?i=10&b=2) - $page = (($page_dir) ? $page_dir . '/' : '') . $page_name; - if ($query_string) - { - $page .= '?' . $query_string; - } - - // The script path from the webroot to the current directory (for example: /phpBB3/adm/) : always prefixed with / and ends in / - $script_path = $symfony_request->getBasePath(); - - // The script path from the webroot to the phpBB root (for example: /phpBB3/) - $script_dirs = explode('/', $script_path); - array_splice($script_dirs, -count($page_dirs)); - $root_script_path = implode('/', $script_dirs) . (count($root_dirs) ? '/' . implode('/', $root_dirs) : ''); - - // We are on the base level (phpBB root == webroot), lets adjust the variables a bit... - if (!$root_script_path) - { - $root_script_path = ($page_dir) ? str_replace($page_dir, '', $script_path) : $script_path; - } - - $script_path .= (substr($script_path, -1, 1) == '/') ? '' : '/'; - $root_script_path .= (substr($root_script_path, -1, 1) == '/') ? '' : '/'; - - $forum_id = $request->variable('f', 0); - // maximum forum id value is maximum value of mediumint unsigned column - $forum_id = ($forum_id > 0 && $forum_id < 16777215) ? $forum_id : 0; - - $page_array += array( - 'page_name' => $page_name, - 'page_dir' => $page_dir, - - 'query_string' => $query_string, - 'script_path' => str_replace(' ', '%20', htmlspecialchars($script_path)), - 'root_script_path' => str_replace(' ', '%20', htmlspecialchars($root_script_path)), - - 'page' => $page, - 'forum' => $forum_id, - ); - - return $page_array; - } - - /** - * Get valid hostname/port. HTTP_HOST is used, SERVER_NAME if HTTP_HOST not present. - */ - function extract_current_hostname() - { - global $config, $request; - - // Get hostname - $host = htmlspecialchars_decode($request->header('Host', $request->server('SERVER_NAME'))); - - // Should be a string and lowered - $host = (string) strtolower($host); - - // If host is equal the cookie domain or the server name (if config is set), then we assume it is valid - if ((isset($config['cookie_domain']) && $host === $config['cookie_domain']) || (isset($config['server_name']) && $host === $config['server_name'])) - { - return $host; - } - - // Is the host actually a IP? If so, we use the IP... (IPv4) - if (long2ip(ip2long($host)) === $host) - { - return $host; - } - - // Now return the hostname (this also removes any port definition). The http:// is prepended to construct a valid URL, hosts never have a scheme assigned - $host = @parse_url('http://' . $host); - $host = (!empty($host['host'])) ? $host['host'] : ''; - - // Remove any portions not removed by parse_url (#) - $host = str_replace('#', '', $host); - - // If, by any means, the host is now empty, we will use a "best approach" way to guess one - if (empty($host)) - { - if (!empty($config['server_name'])) - { - $host = $config['server_name']; - } - else if (!empty($config['cookie_domain'])) - { - $host = (strpos($config['cookie_domain'], '.') === 0) ? substr($config['cookie_domain'], 1) : $config['cookie_domain']; - } - else - { - // Set to OS hostname or localhost - $host = (function_exists('php_uname')) ? php_uname('n') : 'localhost'; - } - } - - // It may be still no valid host, but for sure only a hostname (we may further expand on the cookie domain... if set) - return $host; - } - - /** - * Start session management - * - * This is where all session activity begins. We gather various pieces of - * information from the client and server. We test to see if a session already - * exists. If it does, fine and dandy. If it doesn't we'll go on to create a - * new one ... pretty logical heh? We also examine the system load (if we're - * running on a system which makes such information readily available) and - * halt if it's above an admin definable limit. - * - * @param bool $update_session_page if true the session page gets updated. - * This can be set to circumvent certain scripts to update the users last visited page. - */ - function session_begin($update_session_page = true) - { - global $phpEx, $SID, $_SID, $_EXTRA_URL, $db, $config, $phpbb_root_path; - global $request, $phpbb_container, $user, $phpbb_log, $phpbb_dispatcher; - - // Give us some basic information - $this->time_now = time(); - $this->cookie_data = array('u' => 0, 'k' => ''); - $this->update_session_page = $update_session_page; - $this->browser = $request->header('User-Agent'); - $this->referer = $request->header('Referer'); - $this->forwarded_for = $request->header('X-Forwarded-For'); - - $this->host = $this->extract_current_hostname(); - $this->page = $this->extract_current_page($phpbb_root_path); - - // if the forwarded for header shall be checked we have to validate its contents - if ($config['forwarded_for_check']) - { - $this->forwarded_for = preg_replace('# {2,}#', ' ', str_replace(',', ' ', $this->forwarded_for)); - - // split the list of IPs - $ips = explode(' ', $this->forwarded_for); - foreach ($ips as $ip) - { - if (!filter_var($ip, FILTER_VALIDATE_IP)) - { - // contains invalid data, don't use the forwarded for header - $this->forwarded_for = ''; - break; - } - } - } - else - { - $this->forwarded_for = ''; - } - - if ($request->is_set($config['cookie_name'] . '_sid', \phpbb\request\request_interface::COOKIE) || $request->is_set($config['cookie_name'] . '_u', \phpbb\request\request_interface::COOKIE)) - { - $this->cookie_data['u'] = $request->variable($config['cookie_name'] . '_u', 0, false, \phpbb\request\request_interface::COOKIE); - $this->cookie_data['k'] = $request->variable($config['cookie_name'] . '_k', '', false, \phpbb\request\request_interface::COOKIE); - $this->session_id = $request->variable($config['cookie_name'] . '_sid', '', false, \phpbb\request\request_interface::COOKIE); - - $SID = (defined('NEED_SID')) ? '?sid=' . $this->session_id : '?sid='; - $_SID = (defined('NEED_SID')) ? $this->session_id : ''; - - if (empty($this->session_id)) - { - $this->session_id = $_SID = $request->variable('sid', ''); - $SID = '?sid=' . $this->session_id; - $this->cookie_data = array('u' => 0, 'k' => ''); - } - } - else - { - $this->session_id = $_SID = $request->variable('sid', ''); - $SID = '?sid=' . $this->session_id; - } - - $_EXTRA_URL = array(); - - // Why no forwarded_for et al? Well, too easily spoofed. With the results of my recent requests - // it's pretty clear that in the majority of cases you'll at least be left with a proxy/cache ip. - $ip = htmlspecialchars_decode($request->server('REMOTE_ADDR')); - $ip = preg_replace('# {2,}#', ' ', str_replace(',', ' ', $ip)); - - /** - * Event to alter user IP address - * - * @event core.session_ip_after - * @var string ip REMOTE_ADDR - * @since 3.1.10-RC1 - */ - $vars = array('ip'); - extract($phpbb_dispatcher->trigger_event('core.session_ip_after', compact($vars))); - - // split the list of IPs - $ips = explode(' ', trim($ip)); - - // Default IP if REMOTE_ADDR is invalid - $this->ip = '127.0.0.1'; - - foreach ($ips as $ip) - { - // Normalise IP address - $ip = phpbb_ip_normalise($ip); - - if ($ip === false) - { - // IP address is invalid. - break; - } - - // IP address is valid. - $this->ip = $ip; - } - - $this->load = false; - - // Load limit check (if applicable) - if ($config['limit_load'] || $config['limit_search_load']) - { - if ((function_exists('sys_getloadavg') && $load = sys_getloadavg()) || ($load = explode(' ', @file_get_contents('/proc/loadavg')))) - { - $this->load = array_slice($load, 0, 1); - $this->load = floatval($this->load[0]); - } - else - { - $config->set('limit_load', '0'); - $config->set('limit_search_load', '0'); - } - } - - // if no session id is set, redirect to index.php - $session_id = $request->variable('sid', ''); - if (defined('NEED_SID') && (empty($session_id) || $this->session_id !== $session_id)) - { - send_status_line(401, 'Unauthorized'); - redirect(append_sid("{$phpbb_root_path}index.$phpEx")); - } - - // if session id is set - if (!empty($this->session_id)) - { - $sql = 'SELECT u.*, s.* - FROM ' . SESSIONS_TABLE . ' s, ' . USERS_TABLE . " u - WHERE s.session_id = '" . $db->sql_escape($this->session_id) . "' - AND u.user_id = s.session_user_id"; - $result = $db->sql_query($sql); - $this->data = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - // Did the session exist in the DB? - if (isset($this->data['user_id'])) - { - // Validate IP length according to admin ... enforces an IP - // check on bots if admin requires this -// $quadcheck = ($config['ip_check_bot'] && $this->data['user_type'] & USER_BOT) ? 4 : $config['ip_check']; - - if (strpos($this->ip, ':') !== false && strpos($this->data['session_ip'], ':') !== false) - { - $s_ip = short_ipv6($this->data['session_ip'], $config['ip_check']); - $u_ip = short_ipv6($this->ip, $config['ip_check']); - } - else - { - $s_ip = implode('.', array_slice(explode('.', $this->data['session_ip']), 0, $config['ip_check'])); - $u_ip = implode('.', array_slice(explode('.', $this->ip), 0, $config['ip_check'])); - } - - $s_browser = ($config['browser_check']) ? trim(strtolower(substr($this->data['session_browser'], 0, 149))) : ''; - $u_browser = ($config['browser_check']) ? trim(strtolower(substr($this->browser, 0, 149))) : ''; - - $s_forwarded_for = ($config['forwarded_for_check']) ? substr($this->data['session_forwarded_for'], 0, 254) : ''; - $u_forwarded_for = ($config['forwarded_for_check']) ? substr($this->forwarded_for, 0, 254) : ''; - - // referer checks - // The @ before $config['referer_validation'] suppresses notices present while running the updater - $check_referer_path = (@$config['referer_validation'] == REFERER_VALIDATE_PATH); - $referer_valid = true; - - // we assume HEAD and TRACE to be foul play and thus only whitelist GET - if (@$config['referer_validation'] && strtolower($request->server('REQUEST_METHOD')) !== 'get') - { - $referer_valid = $this->validate_referer($check_referer_path); - } - - if ($u_ip === $s_ip && $s_browser === $u_browser && $s_forwarded_for === $u_forwarded_for && $referer_valid) - { - $session_expired = false; - - // Check whether the session is still valid if we have one - /* @var $provider_collection \phpbb\auth\provider_collection */ - $provider_collection = $phpbb_container->get('auth.provider_collection'); - $provider = $provider_collection->get_provider(); - - if (!($provider instanceof \phpbb\auth\provider\provider_interface)) - { - throw new \RuntimeException($provider . ' must implement \phpbb\auth\provider\provider_interface'); - } - - $ret = $provider->validate_session($this->data); - if ($ret !== null && !$ret) - { - $session_expired = true; - } - - if (!$session_expired) - { - // Check the session length timeframe if autologin is not enabled. - // Else check the autologin length... and also removing those having autologin enabled but no longer allowed board-wide. - if (!$this->data['session_autologin']) - { - if ($this->data['session_time'] < $this->time_now - ($config['session_length'] + 60)) - { - $session_expired = true; - } - } - else if (!$config['allow_autologin'] || ($config['max_autologin_time'] && $this->data['session_time'] < $this->time_now - (86400 * (int) $config['max_autologin_time']) + 60)) - { - $session_expired = true; - } - } - - if (!$session_expired) - { - $this->data['is_registered'] = ($this->data['user_id'] != ANONYMOUS && ($this->data['user_type'] == USER_NORMAL || $this->data['user_type'] == USER_FOUNDER)) ? true : false; - $this->data['is_bot'] = (!$this->data['is_registered'] && $this->data['user_id'] != ANONYMOUS) ? true : false; - $this->data['user_lang'] = basename($this->data['user_lang']); - - // Is user banned? Are they excluded? Won't return on ban, exists within method - $this->check_ban_for_current_session($config); - - return true; - } - } - else - { - // Added logging temporarily to help debug bugs... - if ($phpbb_container->getParameter('session.log_errors') && $this->data['user_id'] != ANONYMOUS) - { - if ($referer_valid) - { - $phpbb_log->add('critical', $user->data['user_id'], $user->ip, 'LOG_IP_BROWSER_FORWARDED_CHECK', false, array( - $u_ip, - $s_ip, - $u_browser, - $s_browser, - htmlspecialchars($u_forwarded_for), - htmlspecialchars($s_forwarded_for) - )); - } - else - { - $phpbb_log->add('critical', $user->data['user_id'], $user->ip, 'LOG_REFERER_INVALID', false, array($this->referer)); - } - } - } - } - } - - // If we reach here then no (valid) session exists. So we'll create a new one - return $this->session_create(); - } - - /** - * Create a new session - * - * If upon trying to start a session we discover there is nothing existing we - * jump here. Additionally this method is called directly during login to regenerate - * the session for the specific user. In this method we carry out a number of tasks; - * garbage collection, (search)bot checking, banned user comparison. Basically - * though this method will result in a new session for a specific user. - */ - function session_create($user_id = false, $set_admin = false, $persist_login = false, $viewonline = true) - { - global $SID, $_SID, $db, $config, $cache, $phpbb_container, $phpbb_dispatcher; - - $this->data = array(); - - /* Garbage collection ... remove old sessions updating user information - // if necessary. It means (potentially) 11 queries but only infrequently - if ($this->time_now > $config['session_last_gc'] + $config['session_gc']) - { - $this->session_gc(); - }*/ - - // Do we allow autologin on this board? No? Then override anything - // that may be requested here - if (!$config['allow_autologin']) - { - $this->cookie_data['k'] = $persist_login = false; - } - - /** - * Here we do a bot check, oh er saucy! No, not that kind of bot - * check. We loop through the list of bots defined by the admin and - * see if we have any useragent and/or IP matches. If we do, this is a - * bot, act accordingly - */ - $bot = false; - $active_bots = $cache->obtain_bots(); - - foreach ($active_bots as $row) - { - if ($row['bot_agent'] && preg_match('#' . str_replace('\*', '.*?', preg_quote($row['bot_agent'], '#')) . '#i', $this->browser)) - { - $bot = $row['user_id']; - } - - // If ip is supplied, we will make sure the ip is matching too... - if ($row['bot_ip'] && ($bot || !$row['bot_agent'])) - { - // Set bot to false, then we only have to set it to true if it is matching - $bot = false; - - foreach (explode(',', $row['bot_ip']) as $bot_ip) - { - $bot_ip = trim($bot_ip); - - if (!$bot_ip) - { - continue; - } - - if (strpos($this->ip, $bot_ip) === 0) - { - $bot = (int) $row['user_id']; - break; - } - } - } - - if ($bot) - { - break; - } - } - - /* @var $provider_collection \phpbb\auth\provider_collection */ - $provider_collection = $phpbb_container->get('auth.provider_collection'); - $provider = $provider_collection->get_provider(); - $this->data = $provider->autologin(); - - if ($user_id !== false && isset($this->data['user_id']) && $this->data['user_id'] != $user_id) - { - $this->data = array(); - } - - if (isset($this->data['user_id'])) - { - $this->cookie_data['k'] = ''; - $this->cookie_data['u'] = $this->data['user_id']; - } - - // If we're presented with an autologin key we'll join against it. - // Else if we've been passed a user_id we'll grab data based on that - if (isset($this->cookie_data['k']) && $this->cookie_data['k'] && $this->cookie_data['u'] && empty($this->data)) - { - $sql = 'SELECT u.* - FROM ' . USERS_TABLE . ' u, ' . SESSIONS_KEYS_TABLE . ' k - WHERE u.user_id = ' . (int) $this->cookie_data['u'] . ' - AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ") - AND k.user_id = u.user_id - AND k.key_id = '" . $db->sql_escape(md5($this->cookie_data['k'])) . "'"; - $result = $db->sql_query($sql); - $user_data = $db->sql_fetchrow($result); - - if ($user_id === false || (isset($user_data['user_id']) && $user_id == $user_data['user_id'])) - { - $this->data = $user_data; - $bot = false; - } - - $db->sql_freeresult($result); - } - - if ($user_id !== false && empty($this->data)) - { - $this->cookie_data['k'] = ''; - $this->cookie_data['u'] = $user_id; - - $sql = 'SELECT * - FROM ' . USERS_TABLE . ' - WHERE user_id = ' . (int) $this->cookie_data['u'] . ' - AND user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')'; - $result = $db->sql_query($sql); - $this->data = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - $bot = false; - } - - // Bot user, if they have a SID in the Request URI we need to get rid of it - // otherwise they'll index this page with the SID, duplicate content oh my! - if ($bot && isset($_GET['sid'])) - { - send_status_line(301, 'Moved Permanently'); - redirect(build_url(array('sid'))); - } - - // If no data was returned one or more of the following occurred: - // Key didn't match one in the DB - // User does not exist - // User is inactive - // User is bot - if (!is_array($this->data) || !count($this->data)) - { - $this->cookie_data['k'] = ''; - $this->cookie_data['u'] = ($bot) ? $bot : ANONYMOUS; - - if (!$bot) - { - $sql = 'SELECT * - FROM ' . USERS_TABLE . ' - WHERE user_id = ' . (int) $this->cookie_data['u']; - } - else - { - // We give bots always the same session if it is not yet expired. - $sql = 'SELECT u.*, s.* - FROM ' . USERS_TABLE . ' u - LEFT JOIN ' . SESSIONS_TABLE . ' s ON (s.session_user_id = u.user_id) - WHERE u.user_id = ' . (int) $bot; - } - - $result = $db->sql_query($sql); - $this->data = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - } - - if ($this->data['user_id'] != ANONYMOUS && !$bot) - { - $this->data['session_last_visit'] = (isset($this->data['session_time']) && $this->data['session_time']) ? $this->data['session_time'] : (($this->data['user_lastvisit']) ? $this->data['user_lastvisit'] : time()); - } - else - { - $this->data['session_last_visit'] = $this->time_now; - } - - // Force user id to be integer... - $this->data['user_id'] = (int) $this->data['user_id']; - - // At this stage we should have a filled data array, defined cookie u and k data. - // data array should contain recent session info if we're a real user and a recent - // session exists in which case session_id will also be set - - // Is user banned? Are they excluded? Won't return on ban, exists within method - $this->check_ban_for_current_session($config); - - $this->data['is_registered'] = (!$bot && $this->data['user_id'] != ANONYMOUS && ($this->data['user_type'] == USER_NORMAL || $this->data['user_type'] == USER_FOUNDER)) ? true : false; - $this->data['is_bot'] = ($bot) ? true : false; - - // If our friend is a bot, we re-assign a previously assigned session - if ($this->data['is_bot'] && $bot == $this->data['user_id'] && $this->data['session_id']) - { - // Only assign the current session if the ip, browser and forwarded_for match... - if (strpos($this->ip, ':') !== false && strpos($this->data['session_ip'], ':') !== false) - { - $s_ip = short_ipv6($this->data['session_ip'], $config['ip_check']); - $u_ip = short_ipv6($this->ip, $config['ip_check']); - } - else - { - $s_ip = implode('.', array_slice(explode('.', $this->data['session_ip']), 0, $config['ip_check'])); - $u_ip = implode('.', array_slice(explode('.', $this->ip), 0, $config['ip_check'])); - } - - $s_browser = ($config['browser_check']) ? trim(strtolower(substr($this->data['session_browser'], 0, 149))) : ''; - $u_browser = ($config['browser_check']) ? trim(strtolower(substr($this->browser, 0, 149))) : ''; - - $s_forwarded_for = ($config['forwarded_for_check']) ? substr($this->data['session_forwarded_for'], 0, 254) : ''; - $u_forwarded_for = ($config['forwarded_for_check']) ? substr($this->forwarded_for, 0, 254) : ''; - - if ($u_ip === $s_ip && $s_browser === $u_browser && $s_forwarded_for === $u_forwarded_for) - { - $this->session_id = $this->data['session_id']; - - // Only update session DB a minute or so after last update or if page changes - if ($this->time_now - $this->data['session_time'] > 60 || ($this->update_session_page && $this->data['session_page'] != $this->page['page'])) - { - // Update the last visit time - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_lastvisit = ' . (int) $this->data['session_time'] . ' - WHERE user_id = ' . (int) $this->data['user_id']; - $db->sql_query($sql); - } - - $SID = '?sid='; - $_SID = ''; - return true; - } - else - { - // If the ip and browser does not match make sure we only have one bot assigned to one session - $db->sql_query('DELETE FROM ' . SESSIONS_TABLE . ' WHERE session_user_id = ' . $this->data['user_id']); - } - } - - $session_autologin = (($this->cookie_data['k'] || $persist_login) && $this->data['is_registered']) ? true : false; - $set_admin = ($set_admin && $this->data['is_registered']) ? true : false; - - // Create or update the session - $sql_ary = array( - 'session_user_id' => (int) $this->data['user_id'], - 'session_start' => (int) $this->time_now, - 'session_last_visit' => (int) $this->data['session_last_visit'], - 'session_time' => (int) $this->time_now, - 'session_browser' => (string) trim(substr($this->browser, 0, 149)), - 'session_forwarded_for' => (string) $this->forwarded_for, - 'session_ip' => (string) $this->ip, - 'session_autologin' => ($session_autologin) ? 1 : 0, - 'session_admin' => ($set_admin) ? 1 : 0, - 'session_viewonline' => ($viewonline) ? 1 : 0, - ); - - if ($this->update_session_page) - { - $sql_ary['session_page'] = (string) substr($this->page['page'], 0, 199); - $sql_ary['session_forum_id'] = $this->page['forum']; - } - - $db->sql_return_on_error(true); - - $sql = 'DELETE - FROM ' . SESSIONS_TABLE . ' - WHERE session_id = \'' . $db->sql_escape($this->session_id) . '\' - AND session_user_id = ' . ANONYMOUS; - - if (!defined('IN_ERROR_HANDLER') && (!$this->session_id || !$db->sql_query($sql) || !$db->sql_affectedrows())) - { - // Limit new sessions in 1 minute period (if required) - if (empty($this->data['session_time']) && $config['active_sessions']) - { -// $db->sql_return_on_error(false); - - $sql = 'SELECT COUNT(session_id) AS sessions - FROM ' . SESSIONS_TABLE . ' - WHERE session_time >= ' . ($this->time_now - 60); - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ((int) $row['sessions'] > (int) $config['active_sessions']) - { - send_status_line(503, 'Service Unavailable'); - trigger_error('BOARD_UNAVAILABLE'); - } - } - } - - // Since we re-create the session id here, the inserted row must be unique. Therefore, we display potential errors. - // Commented out because it will not allow forums to update correctly -// $db->sql_return_on_error(false); - - // Something quite important: session_page always holds the *last* page visited, except for the *first* visit. - // We are not able to simply have an empty session_page btw, therefore we need to tell phpBB how to detect this special case. - // If the session id is empty, we have a completely new one and will set an "identifier" here. This identifier is able to be checked later. - if (empty($this->data['session_id'])) - { - // This is a temporary variable, only set for the very first visit - $this->data['session_created'] = true; - } - - $this->session_id = $this->data['session_id'] = md5(unique_id()); - - $sql_ary['session_id'] = (string) $this->session_id; - $sql_ary['session_page'] = (string) substr($this->page['page'], 0, 199); - $sql_ary['session_forum_id'] = $this->page['forum']; - - $sql = 'INSERT INTO ' . SESSIONS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); - $db->sql_query($sql); - - $db->sql_return_on_error(false); - - // Regenerate autologin/persistent login key - if ($session_autologin) - { - $this->set_login_key(); - } - - // refresh data - $SID = '?sid=' . $this->session_id; - $_SID = $this->session_id; - $this->data = array_merge($this->data, $sql_ary); - - if (!$bot) - { - $cookie_expire = $this->time_now + (($config['max_autologin_time']) ? 86400 * (int) $config['max_autologin_time'] : 31536000); - - $this->set_cookie('u', $this->cookie_data['u'], $cookie_expire); - $this->set_cookie('k', $this->cookie_data['k'], $cookie_expire); - $this->set_cookie('sid', $this->session_id, $cookie_expire); - - unset($cookie_expire); - - $sql = 'SELECT COUNT(session_id) AS sessions - FROM ' . SESSIONS_TABLE . ' - WHERE session_user_id = ' . (int) $this->data['user_id'] . ' - AND session_time >= ' . (int) ($this->time_now - (max((int) $config['session_length'], (int) $config['form_token_lifetime']))); - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ((int) $row['sessions'] <= 1 || empty($this->data['user_form_salt'])) - { - $this->data['user_form_salt'] = unique_id(); - // Update the form key - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_form_salt = \'' . $db->sql_escape($this->data['user_form_salt']) . '\' - WHERE user_id = ' . (int) $this->data['user_id']; - $db->sql_query($sql); - } - } - else - { - $this->data['session_time'] = $this->data['session_last_visit'] = $this->time_now; - - // Update the last visit time - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_lastvisit = ' . (int) $this->data['session_time'] . ' - WHERE user_id = ' . (int) $this->data['user_id']; - $db->sql_query($sql); - - $SID = '?sid='; - $_SID = ''; - } - - $session_data = $sql_ary; - /** - * Event to send new session data to extension - * Read-only event - * - * @event core.session_create_after - * @var array session_data Associative array of session keys to be updated - * @since 3.1.6-RC1 - */ - $vars = array('session_data'); - extract($phpbb_dispatcher->trigger_event('core.session_create_after', compact($vars))); - unset($session_data); - - return true; - } - - /** - * Kills a session - * - * This method does what it says on the tin. It will delete a pre-existing session. - * It resets cookie information (destroying any autologin key within that cookie data) - * and update the users information from the relevant session data. It will then - * grab guest user information. - */ - function session_kill($new_session = true) - { - global $SID, $_SID, $db, $phpbb_container, $phpbb_dispatcher; - - $sql = 'DELETE FROM ' . SESSIONS_TABLE . " - WHERE session_id = '" . $db->sql_escape($this->session_id) . "' - AND session_user_id = " . (int) $this->data['user_id']; - $db->sql_query($sql); - - $user_id = (int) $this->data['user_id']; - $session_id = $this->session_id; - /** - * Event to send session kill information to extension - * Read-only event - * - * @event core.session_kill_after - * @var int user_id user_id of the session user. - * @var string session_id current user's session_id - * @var bool new_session should we create new session for user - * @since 3.1.6-RC1 - */ - $vars = array('user_id', 'session_id', 'new_session'); - extract($phpbb_dispatcher->trigger_event('core.session_kill_after', compact($vars))); - unset($user_id); - unset($session_id); - - // Allow connecting logout with external auth method logout - /* @var $provider_collection \phpbb\auth\provider_collection */ - $provider_collection = $phpbb_container->get('auth.provider_collection'); - $provider = $provider_collection->get_provider(); - $provider->logout($this->data, $new_session); - - if ($this->data['user_id'] != ANONYMOUS) - { - // Delete existing session, update last visit info first! - if (!isset($this->data['session_time'])) - { - $this->data['session_time'] = time(); - } - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_lastvisit = ' . (int) $this->data['session_time'] . ' - WHERE user_id = ' . (int) $this->data['user_id']; - $db->sql_query($sql); - - if ($this->cookie_data['k']) - { - $sql = 'DELETE FROM ' . SESSIONS_KEYS_TABLE . ' - WHERE user_id = ' . (int) $this->data['user_id'] . " - AND key_id = '" . $db->sql_escape(md5($this->cookie_data['k'])) . "'"; - $db->sql_query($sql); - } - - // Reset the data array - $this->data = array(); - - $sql = 'SELECT * - FROM ' . USERS_TABLE . ' - WHERE user_id = ' . ANONYMOUS; - $result = $db->sql_query($sql); - $this->data = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - } - - $cookie_expire = $this->time_now - 31536000; - $this->set_cookie('u', '', $cookie_expire); - $this->set_cookie('k', '', $cookie_expire); - $this->set_cookie('sid', '', $cookie_expire); - unset($cookie_expire); - - $SID = '?sid='; - $this->session_id = $_SID = ''; - - // To make sure a valid session is created we create one for the anonymous user - if ($new_session) - { - $this->session_create(ANONYMOUS); - } - - return true; - } - - /** - * Session garbage collection - * - * This looks a lot more complex than it really is. Effectively we are - * deleting any sessions older than an admin definable limit. Due to the - * way in which we maintain session data we have to ensure we update user - * data before those sessions are destroyed. In addition this method - * removes autologin key information that is older than an admin defined - * limit. - */ - function session_gc() - { - global $db, $config, $phpbb_container, $phpbb_dispatcher; - - if (!$this->time_now) - { - $this->time_now = time(); - } - - /** - * Get expired sessions for registered users, only most recent for each user - * Inner SELECT gets most recent expired sessions for unique session_user_id - * Outer SELECT gets data for them - */ - $sql_select = 'SELECT s1.session_page, s1.session_user_id, s1.session_time AS recent_time - FROM ' . SESSIONS_TABLE . ' AS s1 - INNER JOIN ( - SELECT session_user_id, MAX(session_time) AS recent_time - FROM ' . SESSIONS_TABLE . ' - WHERE session_time < ' . ($this->time_now - (int) $config['session_length']) . ' - AND session_user_id <> ' . ANONYMOUS . ' - GROUP BY session_user_id - ) AS s2 - ON s1.session_user_id = s2.session_user_id - AND s1.session_time = s2.recent_time'; - - switch ($db->get_sql_layer()) - { - case 'sqlite3': - if (phpbb_version_compare($db->sql_server_info(true), '3.8.3', '>=')) - { - // For SQLite versions 3.8.3+ which support Common Table Expressions (CTE) - $sql = "WITH s3 (session_page, session_user_id, session_time) AS ($sql_select) - UPDATE " . USERS_TABLE . ' - SET (user_lastpage, user_lastvisit) = (SELECT session_page, session_time FROM s3 WHERE session_user_id = user_id) - WHERE EXISTS (SELECT session_user_id FROM s3 WHERE session_user_id = user_id)'; - $db->sql_query($sql); - - break; - } - - // No break, for SQLite versions prior to 3.8.3 and Oracle - case 'oracle': - $result = $db->sql_query($sql_select); - while ($row = $db->sql_fetchrow($result)) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_lastvisit = ' . (int) $row['recent_time'] . ", user_lastpage = '" . $db->sql_escape($row['session_page']) . "' - WHERE user_id = " . (int) $row['session_user_id']; - $db->sql_query($sql); - } - $db->sql_freeresult($result); - break; - - case 'mysqli': - $sql = 'UPDATE ' . USERS_TABLE . " u, - ($sql_select) s3 - SET u.user_lastvisit = s3.recent_time, u.user_lastpage = s3.session_page - WHERE u.user_id = s3.session_user_id"; - $db->sql_query($sql); - break; - - default: - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_lastvisit = s3.recent_time, user_lastpage = s3.session_page - FROM ($sql_select) s3 - WHERE user_id = s3.session_user_id"; - $db->sql_query($sql); - break; - } - - // Delete all expired sessions - $sql = 'DELETE FROM ' . SESSIONS_TABLE . ' - WHERE session_time < ' . ($this->time_now - (int) $config['session_length']); - $db->sql_query($sql); - - // Update gc timer - $config->set('session_last_gc', $this->time_now, false); - - if ($config['max_autologin_time']) - { - $sql = 'DELETE FROM ' . SESSIONS_KEYS_TABLE . ' - WHERE last_login < ' . (time() - (86400 * (int) $config['max_autologin_time'])); - $db->sql_query($sql); - } - - // only called from CRON; should be a safe workaround until the infrastructure gets going - /* @var \phpbb\captcha\factory $captcha_factory */ - $captcha_factory = $phpbb_container->get('captcha.factory'); - $captcha_factory->garbage_collect($config['captcha_plugin']); - - $sql = 'DELETE FROM ' . LOGIN_ATTEMPT_TABLE . ' - WHERE attempt_time < ' . (time() - (int) $config['ip_login_limit_time']); - $db->sql_query($sql); - - /** - * Event to trigger extension on session_gc - * - * @event core.session_gc_after - * @since 3.1.6-RC1 - */ - $phpbb_dispatcher->dispatch('core.session_gc_after'); - - return; - } - - /** - * Sets a cookie - * - * Sets a cookie of the given name with the specified data for the given length of time. If no time is specified, a session cookie will be set. - * - * @param string $name Name of the cookie, will be automatically prefixed with the phpBB cookie name. track becomes [cookie_name]_track then. - * @param string $cookiedata The data to hold within the cookie - * @param int $cookietime The expiration time as UNIX timestamp. If 0 is provided, a session cookie is set. - * @param bool $httponly Use HttpOnly. Defaults to true. Use false to make cookie accessible by client-side scripts. - */ - function set_cookie($name, $cookiedata, $cookietime, $httponly = true) - { - global $config, $phpbb_dispatcher; - - // If headers are already set, we just return - if (headers_sent()) - { - return; - } - - $disable_cookie = false; - /** - * Event to modify or disable setting cookies - * - * @event core.set_cookie - * @var bool disable_cookie Set to true to disable setting this cookie - * @var string name Name of the cookie - * @var string cookiedata The data to hold within the cookie - * @var int cookietime The expiration time as UNIX timestamp - * @var bool httponly Use HttpOnly? - * @since 3.2.9-RC1 - */ - $vars = array( - 'disable_cookie', - 'name', - 'cookiedata', - 'cookietime', - 'httponly', - ); - extract($phpbb_dispatcher->trigger_event('core.set_cookie', compact($vars))); - - if ($disable_cookie) - { - return; - } - - $name_data = rawurlencode($config['cookie_name'] . '_' . $name) . '=' . rawurlencode($cookiedata); - $expire = gmdate('D, d-M-Y H:i:s \\G\\M\\T', $cookietime); - $domain = (!$config['cookie_domain'] || $config['cookie_domain'] == '127.0.0.1' || strpos($config['cookie_domain'], '.') === false) ? '' : '; domain=' . $config['cookie_domain']; - - header('Set-Cookie: ' . $name_data . (($cookietime) ? '; expires=' . $expire : '') . '; path=' . $config['cookie_path'] . $domain . ((!$config['cookie_secure']) ? '' : '; secure') . ';' . (($httponly) ? ' HttpOnly' : ''), false); - } - - /** - * Check for banned user - * - * Checks whether the supplied user is banned by id, ip or email. If no parameters - * are passed to the method pre-existing session data is used. - * - * @param int|false $user_id The user id - * @param mixed $user_ips Can contain a string with one IP or an array of multiple IPs - * @param string|false $user_email The user email - * @param bool $return If $return is false this routine does not return on finding a banned user, - * it outputs a relevant message and stops execution. - */ - function check_ban($user_id = false, $user_ips = false, $user_email = false, $return = false) - { - global $config, $db, $phpbb_dispatcher; - - if (defined('IN_CHECK_BAN') || defined('SKIP_CHECK_BAN')) - { - return; - } - - $banned = false; - $cache_ttl = 3600; - $where_sql = array(); - - $sql = 'SELECT ban_ip, ban_userid, ban_email, ban_exclude, ban_give_reason, ban_end - FROM ' . BANLIST_TABLE . ' - WHERE '; - - // Determine which entries to check, only return those - if ($user_email === false) - { - $where_sql[] = "ban_email = ''"; - } - - if ($user_ips === false) - { - $where_sql[] = "(ban_ip = '' OR ban_exclude = 1)"; - } - - if ($user_id === false) - { - $where_sql[] = '(ban_userid = 0 OR ban_exclude = 1)'; - } - else - { - $cache_ttl = ($user_id == ANONYMOUS) ? 3600 : 0; - $_sql = '(ban_userid = ' . $user_id; - - if ($user_email !== false) - { - $_sql .= " OR ban_email <> ''"; - } - - if ($user_ips !== false) - { - $_sql .= " OR ban_ip <> ''"; - } - - $_sql .= ')'; - - $where_sql[] = $_sql; - } - - $sql .= (count($where_sql)) ? implode(' AND ', $where_sql) : ''; - $result = $db->sql_query($sql, $cache_ttl); - - $ban_triggered_by = 'user'; - while ($row = $db->sql_fetchrow($result)) - { - if ($row['ban_end'] && $row['ban_end'] < time()) - { - continue; - } - - $ip_banned = false; - if (!empty($row['ban_ip'])) - { - if (!is_array($user_ips)) - { - $ip_banned = preg_match('#^' . str_replace('\*', '.*?', preg_quote($row['ban_ip'], '#')) . '$#i', $user_ips); - } - else - { - foreach ($user_ips as $user_ip) - { - if (preg_match('#^' . str_replace('\*', '.*?', preg_quote($row['ban_ip'], '#')) . '$#i', $user_ip)) - { - $ip_banned = true; - break; - } - } - } - } - - if ((!empty($row['ban_userid']) && intval($row['ban_userid']) == $user_id) || - $ip_banned || - (!empty($row['ban_email']) && preg_match('#^' . str_replace('\*', '.*?', preg_quote($row['ban_email'], '#')) . '$#i', $user_email))) - { - if (!empty($row['ban_exclude'])) - { - $banned = false; - break; - } - else - { - $banned = true; - $ban_row = $row; - - if (!empty($row['ban_userid']) && intval($row['ban_userid']) == $user_id) - { - $ban_triggered_by = 'user'; - } - else if ($ip_banned) - { - $ban_triggered_by = 'ip'; - } - else - { - $ban_triggered_by = 'email'; - } - - // Don't break. Check if there is an exclude rule for this user - } - } - } - $db->sql_freeresult($result); - - /** - * Event to set custom ban type - * - * @event core.session_set_custom_ban - * @var bool return If $return is false this routine does not return on finding a banned user, it outputs a relevant message and stops execution - * @var bool banned Check if user already banned - * @var array|false ban_row Ban data - * @var string ban_triggered_by Method that caused ban, can be your custom method - * @since 3.1.3-RC1 - */ - $ban_row = isset($ban_row) ? $ban_row : false; - $vars = array('return', 'banned', 'ban_row', 'ban_triggered_by'); - extract($phpbb_dispatcher->trigger_event('core.session_set_custom_ban', compact($vars))); - - if ($banned && !$return) - { - global $phpbb_root_path, $phpEx; - - // If the session is empty we need to create a valid one... - if (empty($this->session_id)) - { - // This seems to be no longer needed? - #14971 -// $this->session_create(ANONYMOUS); - } - - // Initiate environment ... since it won't be set at this stage - $this->setup(); - - // Logout the user, banned users are unable to use the normal 'logout' link - if ($this->data['user_id'] != ANONYMOUS) - { - $this->session_kill(); - } - - // We show a login box here to allow founders accessing the board if banned by IP - if (defined('IN_LOGIN') && $this->data['user_id'] == ANONYMOUS) - { - $this->setup('ucp'); - $this->data['is_registered'] = $this->data['is_bot'] = false; - - // Set as a precaution to allow login_box() handling this case correctly as well as this function not being executed again. - define('IN_CHECK_BAN', 1); - - login_box("index.$phpEx"); - - // The false here is needed, else the user is able to circumvent the ban. - $this->session_kill(false); - } - - // Ok, we catch the case of an empty session id for the anonymous user... - // This can happen if the user is logging in, banned by username and the login_box() being called "again". - if (empty($this->session_id) && defined('IN_CHECK_BAN')) - { - $this->session_create(ANONYMOUS); - } - - // Determine which message to output - $till_date = ($ban_row['ban_end']) ? $this->format_date($ban_row['ban_end']) : ''; - $message = ($ban_row['ban_end']) ? 'BOARD_BAN_TIME' : 'BOARD_BAN_PERM'; - - $contact_link = phpbb_get_board_contact_link($config, $phpbb_root_path, $phpEx); - $message = sprintf($this->lang[$message], $till_date, '', ''); - $message .= ($ban_row['ban_give_reason']) ? '

' . sprintf($this->lang['BOARD_BAN_REASON'], $ban_row['ban_give_reason']) : ''; - $message .= '

' . $this->lang['BAN_TRIGGERED_BY_' . strtoupper($ban_triggered_by)] . ''; - - // A very special case... we are within the cron script which is not supposed to print out the ban message... show blank page - if (defined('IN_CRON')) - { - garbage_collection(); - exit_handler(); - exit; - } - - // To circumvent session_begin returning a valid value and the check_ban() not called on second page view, we kill the session again - $this->session_kill(false); - - trigger_error($message); - } - - if (!empty($ban_row)) - { - $ban_row['ban_triggered_by'] = $ban_triggered_by; - } - - return ($banned && $ban_row) ? $ban_row : $banned; - } - - /** - * Check the current session for bans - * - * @return true if session user is banned. - */ - protected function check_ban_for_current_session($config) - { - if (!defined('SKIP_CHECK_BAN') && $this->data['user_type'] != USER_FOUNDER) - { - if (!$config['forwarded_for_check']) - { - $this->check_ban($this->data['user_id'], $this->ip); - } - else - { - $ips = explode(' ', $this->forwarded_for); - $ips[] = $this->ip; - $this->check_ban($this->data['user_id'], $ips); - } - } - } - - /** - * Check if ip is blacklisted - * This should be called only where absolutely necessary - * - * Only IPv4 (rbldns does not support AAAA records/IPv6 lookups) - * - * @author satmd (from the php manual) - * @param string $mode register/post - spamcop for example is omitted for posting - * @param string|false $ip the IPv4 address to check - * - * @return false if ip is not blacklisted, else an array([checked server], [lookup]) - */ - function check_dnsbl($mode, $ip = false) - { - if ($ip === false) - { - $ip = $this->ip; - } - - // Neither Spamhaus nor Spamcop supports IPv6 addresses. - if (strpos($ip, ':') !== false) - { - return false; - } - - $dnsbl_check = array( - 'sbl.spamhaus.org' => 'http://www.spamhaus.org/query/bl?ip=', - ); - - if ($mode == 'register') - { - $dnsbl_check['bl.spamcop.net'] = 'http://spamcop.net/bl.shtml?'; - } - - if ($ip) - { - $quads = explode('.', $ip); - $reverse_ip = $quads[3] . '.' . $quads[2] . '.' . $quads[1] . '.' . $quads[0]; - - // Need to be listed on all servers... - $listed = true; - $info = array(); - - foreach ($dnsbl_check as $dnsbl => $lookup) - { - if (checkdnsrr($reverse_ip . '.' . $dnsbl . '.', 'A') === true) - { - $info = array($dnsbl, $lookup . $ip); - } - else - { - $listed = false; - } - } - - if ($listed) - { - return $info; - } - } - - return false; - } - - /** - * Check if URI is blacklisted - * This should be called only where absolutely necessary, for example on the submitted website field - * This function is not in use at the moment and is only included for testing purposes, it may not work at all! - * This means it is untested at the moment and therefore commented out - * - * @param string $uri URI to check - * @return true if uri is on blacklist, else false. Only blacklist is checked (~zero FP), no grey lists - function check_uribl($uri) - { - // Normally parse_url() is not intended to parse uris - // We need to get the top-level domain name anyway... change. - $uri = parse_url($uri); - - if ($uri === false || empty($uri['host'])) - { - return false; - } - - $uri = trim($uri['host']); - - if ($uri) - { - // One problem here... the return parameter for the "windows" method is different from what - // we expect... this may render this check useless... - if (checkdnsrr($uri . '.multi.uribl.com.', 'A') === true) - { - return true; - } - } - - return false; - } - */ - - /** - * Set/Update a persistent login key - * - * This method creates or updates a persistent session key. When a user makes - * use of persistent (formerly auto-) logins a key is generated and stored in the - * DB. When they revisit with the same key it's automatically updated in both the - * DB and cookie. Multiple keys may exist for each user representing different - * browsers or locations. As with _any_ non-secure-socket no passphrase login this - * remains vulnerable to exploit. - */ - function set_login_key($user_id = false, $key = false, $user_ip = false) - { - global $db; - - $user_id = ($user_id === false) ? $this->data['user_id'] : $user_id; - $user_ip = ($user_ip === false) ? $this->ip : $user_ip; - $key = ($key === false) ? (($this->cookie_data['k']) ? $this->cookie_data['k'] : false) : $key; - - $key_id = unique_id(hexdec(substr($this->session_id, 0, 8))); - - $sql_ary = array( - 'key_id' => (string) md5($key_id), - 'last_ip' => (string) $user_ip, - 'last_login' => (int) time() - ); - - if (!$key) - { - $sql_ary += array( - 'user_id' => (int) $user_id - ); - } - - if ($key) - { - $sql = 'UPDATE ' . SESSIONS_KEYS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE user_id = ' . (int) $user_id . " - AND key_id = '" . $db->sql_escape(md5($key)) . "'"; - } - else - { - $sql = 'INSERT INTO ' . SESSIONS_KEYS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); - } - $db->sql_query($sql); - - $this->cookie_data['k'] = $key_id; - - return false; - } - - /** - * Reset all login keys for the specified user - * - * This method removes all current login keys for a specified (or the current) - * user. It will be called on password change to render old keys unusable - */ - function reset_login_keys($user_id = false) - { - global $db; - - $user_id = ($user_id === false) ? (int) $this->data['user_id'] : (int) $user_id; - - $sql = 'DELETE FROM ' . SESSIONS_KEYS_TABLE . ' - WHERE user_id = ' . (int) $user_id; - $db->sql_query($sql); - - // If the user is logged in, update last visit info first before deleting sessions - $sql = 'SELECT session_time, session_page - FROM ' . SESSIONS_TABLE . ' - WHERE session_user_id = ' . (int) $user_id . ' - ORDER BY session_time DESC'; - $result = $db->sql_query_limit($sql, 1); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_lastvisit = ' . (int) $row['session_time'] . ", user_lastpage = '" . $db->sql_escape($row['session_page']) . "' - WHERE user_id = " . (int) $user_id; - $db->sql_query($sql); - } - - // Let's also clear any current sessions for the specified user_id - // If it's the current user then we'll leave this session intact - $sql_where = 'session_user_id = ' . (int) $user_id; - $sql_where .= ($user_id === (int) $this->data['user_id']) ? " AND session_id <> '" . $db->sql_escape($this->session_id) . "'" : ''; - - $sql = 'DELETE FROM ' . SESSIONS_TABLE . " - WHERE $sql_where"; - $db->sql_query($sql); - - // We're changing the password of the current user and they have a key - // Lets regenerate it to be safe - if ($user_id === (int) $this->data['user_id'] && $this->cookie_data['k']) - { - $this->set_login_key($user_id); - } - } - - - /** - * Check if the request originated from the same page. - * @param bool $check_script_path If true, the path will be checked as well - */ - function validate_referer($check_script_path = false) - { - global $config, $request; - - // no referer - nothing to validate, user's fault for turning it off (we only check on POST; so meta can't be the reason) - if (empty($this->referer) || empty($this->host)) - { - return true; - } - - $host = htmlspecialchars($this->host); - $ref = substr($this->referer, strpos($this->referer, '://') + 3); - - if (!(stripos($ref, $host) === 0) && (!$config['force_server_vars'] || !(stripos($ref, $config['server_name']) === 0))) - { - return false; - } - else if ($check_script_path && rtrim($this->page['root_script_path'], '/') !== '') - { - $ref = substr($ref, strlen($host)); - $server_port = $request->server('SERVER_PORT', 0); - - if ($server_port !== 80 && $server_port !== 443 && stripos($ref, ":$server_port") === 0) - { - $ref = substr($ref, strlen(":$server_port")); - } - - if (!(stripos(rtrim($ref, '/'), rtrim($this->page['root_script_path'], '/')) === 0)) - { - return false; - } - } - - return true; - } - - - function unset_admin() - { - global $db; - $sql = 'UPDATE ' . SESSIONS_TABLE . ' - SET session_admin = 0 - WHERE session_id = \'' . $db->sql_escape($this->session_id) . '\''; - $db->sql_query($sql); - } - - /** - * Update the session data - * - * @param array $session_data associative array of session keys to be updated - * @param string $session_id optional session_id, defaults to current user's session_id - */ - public function update_session($session_data, $session_id = null) - { - global $db, $phpbb_dispatcher; - - $session_id = ($session_id) ? $session_id : $this->session_id; - - $sql = 'UPDATE ' . SESSIONS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $session_data) . " - WHERE session_id = '" . $db->sql_escape($session_id) . "'"; - $db->sql_query($sql); - - /** - * Event to send update session information to extension - * Read-only event - * - * @event core.update_session_after - * @var array session_data Associative array of session keys to be updated - * @var string session_id current user's session_id - * @since 3.1.6-RC1 - */ - $vars = array('session_data', 'session_id'); - extract($phpbb_dispatcher->trigger_event('core.update_session_after', compact($vars))); - } - - public function update_session_infos() - { - global $config, $db, $request; - - // No need to update if it's a new session. Informations are already inserted by session_create() - if (isset($this->data['session_created']) && $this->data['session_created']) - { - return; - } - - // Do not update the session page for ajax requests, so the view online still works as intended - $page_changed = $this->update_session_page && $this->data['session_page'] != $this->page['page'] && !$request->is_ajax(); - - // Only update session DB a minute or so after last update or if page changes - if ($this->time_now - (isset($this->data['session_time']) ? $this->data['session_time'] : 0) > 60 || $page_changed) - { - $sql_ary = array('session_time' => $this->time_now); - - if ($page_changed) - { - $sql_ary['session_page'] = substr($this->page['page'], 0, 199); - $sql_ary['session_forum_id'] = $this->page['forum']; - } - - $db->sql_return_on_error(true); - - $this->update_session($sql_ary); - - $db->sql_return_on_error(false); - - $this->data = array_merge($this->data, $sql_ary); - - if ($this->data['user_id'] != ANONYMOUS && isset($config['new_member_post_limit']) && $this->data['user_new'] && $config['new_member_post_limit'] <= $this->data['user_posts']) - { - $this->leave_newly_registered(); - } - } - } -} diff --git a/install/update/new/phpbb/template/asset.php b/install/update/new/phpbb/template/asset.php deleted file mode 100644 index d6b4623..0000000 --- a/install/update/new/phpbb/template/asset.php +++ /dev/null @@ -1,203 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\template; - -class asset -{ - protected $components = array(); - - /** @var \phpbb\path_helper **/ - protected $path_helper; - - /** @var \phpbb\filesystem\filesystem */ - protected $filesystem; - - /** - * Constructor - * - * @param string $url URL - * @param \phpbb\path_helper $path_helper Path helper object - * @param \phpbb\filesystem\filesystem $filesystem - */ - public function __construct($url, \phpbb\path_helper $path_helper, \phpbb\filesystem\filesystem $filesystem) - { - $this->path_helper = $path_helper; - $this->filesystem = $filesystem; - - $this->set_url($url); - } - - /** - * Set URL - * - * @param string $url URL - */ - public function set_url($url) - { - $this->components = parse_url($url); - } - - /** - * Convert URL components into string - * - * @param array $components URL components - * @return string URL - */ - protected function join_url($components) - { - $path = ''; - if (isset($components['scheme'])) - { - $path = $components['scheme'] === '' ? '//' : $components['scheme'] . '://'; - } - - if (isset($components['user']) || isset($components['pass'])) - { - if ($path === '' && !isset($components['port'])) - { - $path = '//'; - } - $path .= $components['user']; - if (isset($components['pass'])) - { - $path .= ':' . $components['pass']; - } - $path .= '@'; - } - - if (isset($components['host'])) - { - if ($path === '' && !isset($components['port'])) - { - $path = '//'; - } - $path .= $components['host']; - if (isset($components['port'])) - { - $path .= ':' . $components['port']; - } - } - - if (isset($components['path'])) - { - $path .= $components['path']; - } - - if (isset($components['query'])) - { - $path .= '?' . $components['query']; - } - - if (isset($components['fragment'])) - { - $path .= '#' . $components['fragment']; - } - - return $path; - } - - /** - * Get URL - * - * @return string URL - */ - public function get_url() - { - return $this->path_helper->update_web_root_path($this->join_url($this->components)); - } - - /** - * Checks if URL is local and relative - * - * @return boolean True if URL is local and relative - */ - public function is_relative() - { - if (empty($this->components) || !isset($this->components['path'])) - { - // Invalid URL - return false; - } - return !isset($this->components['scheme']) && !isset($this->components['host']) && substr($this->components['path'], 0, 1) !== '/'; - } - - /** - * Get path component of current URL - * - * @return string Path - */ - public function get_path() - { - return isset($this->components['path']) ? $this->components['path'] : ''; - } - - /** - * Set path component - * - * @param string $path Path component - * @param boolean $urlencode If true, parts of path should be encoded with rawurlencode() - */ - public function set_path($path, $urlencode = false) - { - // Since 1.7.0 Twig returns the real path of the file. We need it to be relative. - $real_root_path = $this->filesystem->realpath($this->path_helper->get_phpbb_root_path()) . DIRECTORY_SEPARATOR; - - // If the asset is under the phpBB root path we need to remove its path and then prepend $phpbb_root_path - if ($real_root_path && substr($path . DIRECTORY_SEPARATOR, 0, strlen($real_root_path)) === $real_root_path) - { - $path = $this->path_helper->get_phpbb_root_path() . str_replace('\\', '/', substr($path, strlen($real_root_path))); - } - else - { - // Else we make the path relative to the current working directory - $real_root_path = $this->filesystem->realpath('.') . DIRECTORY_SEPARATOR; - if ($real_root_path && substr($path . DIRECTORY_SEPARATOR, 0, strlen($real_root_path)) === $real_root_path) - { - $path = str_replace('\\', '/', substr($path, strlen($real_root_path))); - } - } - - if ($urlencode) - { - $paths = explode('/', $path); - foreach ($paths as &$dir) - { - $dir = rawurlencode($dir); - } - $path = implode('/', $paths); - } - - $this->components['path'] = $path; - } - - /** - * Add assets_version parameter to URL. - * Parameter will not be added if assets_version already exists in URL - * - * @param string $version Version - */ - public function add_assets_version($version) - { - if (!isset($this->components['query'])) - { - $this->components['query'] = 'assets_version=' . $version; - return; - } - $query = $this->components['query']; - if (!preg_match('/(^|[&;])assets_version=/', $query)) - { - $this->components['query'] = $query . '&assets_version=' . $version; - } - } -} diff --git a/install/update/new/phpbb/template/context.php b/install/update/new/phpbb/template/context.php deleted file mode 100644 index f059c32..0000000 --- a/install/update/new/phpbb/template/context.php +++ /dev/null @@ -1,631 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\template; - -/** -* Stores variables assigned to template. -*/ -class context -{ - /** - * variable that holds all the data we'll be substituting into - * the compiled templates. Takes form: - * --> $this->tpldata[block][iteration#][child][iteration#][child2][iteration#][variablename] == value - * if it's a root-level variable, it'll be like this: - * --> $this->tpldata[.][0][varname] == value - * - * @var array - */ - private $tpldata = array('.' => array(0 => array())); - - /** - * @var array Reference to template->tpldata['.'][0] - */ - private $rootref; - - /** - * @var bool - */ - private $num_rows_is_set; - - public function __construct() - { - $this->clear(); - } - - /** - * Clears template data set. - */ - public function clear() - { - $this->tpldata = array('.' => array(0 => array())); - $this->rootref = &$this->tpldata['.'][0]; - $this->num_rows_is_set = false; - } - - /** - * Assign a single scalar value to a single key. - * - * Value can be a string, an integer or a boolean. - * - * @param string $varname Variable name - * @param string $varval Value to assign to variable - * @return true - */ - public function assign_var($varname, $varval) - { - $this->rootref[$varname] = $varval; - - return true; - } - - /** - * Append text to the string value stored in a key. - * - * Text is appended using the string concatenation operator (.). - * - * @param string $varname Variable name - * @param string $varval Value to append to variable - * @return true - */ - public function append_var($varname, $varval) - { - $this->rootref[$varname] = (isset($this->rootref[$varname]) ? $this->rootref[$varname] : '') . $varval; - - return true; - } - - /** - * Retrieve a single scalar value from a single key. - * - * @param string $varname Variable name - * @return mixed Variable value, or null if not set - */ - public function retrieve_var($varname) - { - return isset($this->rootref[$varname]) ? $this->rootref[$varname] : null; - } - - /** - * Returns a reference to template data array. - * - * This function is public so that template renderer may invoke it. - * Users should alter template variables via functions in \phpbb\template\template. - * - * Note: modifying returned array will affect data stored in the context. - * - * @return array template data - */ - public function &get_data_ref() - { - // returning a reference directly is not - // something php is capable of doing - $ref = &$this->tpldata; - - if (!$this->num_rows_is_set) - { - /* - * We do not set S_NUM_ROWS while adding a row, to reduce the complexity - * If we would set it on adding, each subsequent adding would cause - * n modifications, resulting in a O(n!) complexity, rather then O(n) - */ - foreach ($ref as $loop_name => &$loop_data) - { - if ($loop_name === '.') - { - continue; - } - - $this->set_num_rows($loop_data); - } - $this->num_rows_is_set = true; - } - - return $ref; - } - - /** - * Set S_NUM_ROWS for each row in this template block - * - * @param array $loop_data - */ - protected function set_num_rows(&$loop_data) - { - $s_num_rows = count($loop_data); - foreach ($loop_data as &$mod_block) - { - foreach ($mod_block as $sub_block_name => &$sub_block) - { - // If the key name is lowercase and the data is an array, - // it could be a template loop. So we set the S_NUM_ROWS there - // as well. - if ($sub_block_name === strtolower($sub_block_name) && is_array($sub_block)) - { - $this->set_num_rows($sub_block); - } - } - - // Check whether we are inside a block before setting the variable - if (isset($mod_block['S_BLOCK_NAME'])) - { - $mod_block['S_NUM_ROWS'] = $s_num_rows; - } - } - } - - /** - * Returns a reference to template root scope. - * - * This function is public so that template renderer may invoke it. - * Users should not need to invoke this function. - * - * Note: modifying returned array will affect data stored in the context. - * - * @return array template data - */ - public function &get_root_ref() - { - // rootref is already a reference - return $this->rootref; - } - - /** - * Assign key variable pairs from an array to a specified block - * - * @param string $blockname Name of block to assign $vararray to - * @param array $vararray A hash of variable name => value pairs - * @return true - */ - public function assign_block_vars($blockname, array $vararray) - { - $this->num_rows_is_set = false; - - // For nested block, $blockcount > 0, for top-level block, $blockcount == 0 - $blocks = explode('.', $blockname); - $blockcount = count($blocks) - 1; - - $block = &$this->tpldata; - for ($i = 0; $i < $blockcount; $i++) - { - $pos = strpos($blocks[$i], '['); - $name = ($pos !== false) ? substr($blocks[$i], 0, $pos) : $blocks[$i]; - $block = &$block[$name]; - $block_count = empty($block) ? 0 : count($block) - 1; - $index = (!$pos || strpos($blocks[$i], '[]') === $pos) ? $block_count : (min((int) substr($blocks[$i], $pos + 1, -1), $block_count)); - $block = &$block[$index]; - } - - // $block = &$block[$blocks[$i]]; // Do not traverse the last block as it might be empty - $name = $blocks[$i]; - - // Assign S_ROW_COUNT and S_ROW_NUM - $s_row_count = isset($block[$name]) ? count($block[$name]) : 0; - $vararray['S_ROW_COUNT'] = $vararray['S_ROW_NUM'] = $s_row_count; - - // Assign S_FIRST_ROW - if (!$s_row_count) - { - $vararray['S_FIRST_ROW'] = true; - } - - // Assign S_BLOCK_NAME - $vararray['S_BLOCK_NAME'] = $name; - - // Now the tricky part, we always assign S_LAST_ROW and remove the entry before - // This is much more clever than going through the complete template data on display (phew) - $vararray['S_LAST_ROW'] = true; - if ($s_row_count > 0) - { - unset($block[$name][($s_row_count - 1)]['S_LAST_ROW']); - } - - // Now we add the block that we're actually assigning to. - // We're adding a new iteration to this block with the given - // variable assignments. - $block[$name][] = $vararray; - - return true; - } - - /** - * Assign key variable pairs from an array to a whole specified block loop - * - * @param string $blockname Name of block to assign $block_vars_array to - * @param array $block_vars_array An array of hashes of variable name => value pairs - * @return true - */ - public function assign_block_vars_array($blockname, array $block_vars_array) - { - foreach ($block_vars_array as $vararray) - { - $this->assign_block_vars($blockname, $vararray); - } - - return true; - } - - /** - * Retrieve key variable pairs from the specified block - * - * @param string $blockname Name of block to retrieve $vararray from - * @param array $vararray An array of variable names, empty array retrieves all vars - * @return array of hashes with variable name as key and retrieved value or null as value - */ - public function retrieve_block_vars($blockname, array $vararray) - { - // For nested block, $blockcount > 0, for top-level block, $blockcount == 0 - $blocks = explode('.', $blockname); - $blockcount = count($blocks) - 1; - - $block = $this->tpldata; - for ($i = 0; $i <= $blockcount; $i++) - { - if (($pos = strpos($blocks[$i], '[')) !== false) - { - $name = substr($blocks[$i], 0, $pos); - - if (empty($block[$name])) - { - return array(); - } - - if (strpos($blocks[$i], '[]') === $pos) - { - $index = count($block[$name]) - 1; - } - else - { - $index = min((int) substr($blocks[$i], $pos + 1, -1), count($block[$name]) - 1); - } - } - else - { - $name = $blocks[$i]; - if (empty($block[$name])) - { - return array(); - } - - $index = count($block[$name]) - 1; - } - $block = $block[$name]; - $block = $block[$index]; - } - - $result = array(); - if ($vararray === array()) - { - // The calculated vars that depend on the block position are excluded from the complete block returned results - $excluded_vars = array('S_FIRST_ROW', 'S_LAST_ROW', 'S_BLOCK_NAME', 'S_NUM_ROWS', 'S_ROW_COUNT', 'S_ROW_NUM'); - - foreach ($block as $varname => $varvalue) - { - if ($varname === strtoupper($varname) && !is_array($varvalue) && !in_array($varname, $excluded_vars)) - { - $result[$varname] = $varvalue; - } - } - } - else - { - foreach ($vararray as $varname) - { - $result[$varname] = isset($block[$varname]) ? $block[$varname] : null; - } - } - return $result; - } - - /** - * Find the index for a specified key in the innermost specified block - * - * @param string $blockname the blockname, for example 'loop' - * @param mixed $key Key to search for - * - * array: KEY => VALUE [the key/value pair to search for within the loop to determine the correct position] - * - * int: Position [the position to search for] - * - * If key is false the position is set to 0 - * If key is true the position is set to the last entry - * - * @return mixed false if not found, index position otherwise; be sure to test with === - */ - public function find_key_index($blockname, $key) - { - // For nested block, $blockcount > 0, for top-level block, $blockcount == 0 - $blocks = explode('.', $blockname); - $blockcount = count($blocks) - 1; - - $block = $this->tpldata; - for ($i = 0; $i < $blockcount; $i++) - { - $pos = strpos($blocks[$i], '['); - $name = ($pos !== false) ? substr($blocks[$i], 0, $pos) : $blocks[$i]; - - if (!isset($block[$name])) - { - return false; - } - - $index = (!$pos || strpos($blocks[$i], '[]') === $pos) ? (count($block[$name]) - 1) : (min((int) substr($blocks[$i], $pos + 1, -1), count($block[$name]) - 1)); - - if (!isset($block[$name][$index])) - { - return false; - } - $block = $block[$name][$index]; - } - - if (!isset($block[$blocks[$i]])) - { - return false; - } - $block = $block[$blocks[$i]]; // Traverse the last block - - // Change key to zero (change first position) if false and to last position if true - if (is_bool($key)) - { - return (!$key) ? 0 : count($block) - 1; - } - - // Get correct position if array given - if (is_array($key)) - { - // Search array to get correct position - list($search_key, $search_value) = @each($key); - foreach ($block as $i => $val_ary) - { - if ($val_ary[$search_key] === $search_value) - { - return $i; - } - } - } - - return (is_int($key) && ((0 <= $key) && ($key < count($block)))) ? $key : false; - } - - /** - * Change already assigned key variable pair (one-dimensional - single loop entry) - * - * An example of how to use this function: - * {@example alter_block_array.php} - * - * @param string $blockname the blockname, for example 'loop' - * @param array $vararray the var array to insert/add or merge - * @param mixed $key Key to search for - * - * array: KEY => VALUE [the key/value pair to search for within the loop to determine the correct position] - * - * int: Position [the position to change or insert at directly given] - * - * If key is false the position is set to 0 - * If key is true the position is set to the last entry - * - * @param string $mode Mode to execute (valid modes are 'insert', 'change' and 'delete') - * - * If insert, the vararray is inserted at the given position (position counting from zero). - * If change, the current block gets merged with the vararray (resulting in new key/value pairs be added and existing keys be replaced by the new \value). - * If delete, the vararray is ignored, and the block at the given position (counting from zero) is removed. - * - * Since counting begins by zero, inserting at the last position will result in this array: array(vararray, last positioned array) - * and inserting at position 1 will result in this array: array(first positioned array, vararray, following vars) - * - * @return bool false on error, true on success - */ - public function alter_block_array($blockname, array $vararray, $key = false, $mode = 'insert') - { - $this->num_rows_is_set = false; - - // For nested block, $blockcount > 0, for top-level block, $blockcount == 0 - $blocks = explode('.', $blockname); - $blockcount = count($blocks) - 1; - - $block = &$this->tpldata; - for ($i = 0; $i < $blockcount; $i++) - { - if (($pos = strpos($blocks[$i], '[')) !== false) - { - $name = substr($blocks[$i], 0, $pos); - - if (strpos($blocks[$i], '[]') === $pos) - { - $index = count($block[$name]) - 1; - } - else - { - $index = min((int) substr($blocks[$i], $pos + 1, -1), count($block[$name]) - 1); - } - } - else - { - $name = $blocks[$i]; - $index = count($block[$name]) - 1; - } - $block = &$block[$name]; - $block = &$block[$index]; - } - $name = $blocks[$i]; - - // If last block does not exist and we are inserting, and not searching for key, we create it empty; otherwise, nothing to do - if (!isset($block[$name])) - { - if ($mode != 'insert' || is_array($key)) - { - return false; - } - $block[$name] = array(); - } - - $block = &$block[$name]; // Now we can traverse the last block - - // Change key to zero (change first position) if false and to last position if true - if ($key === false || $key === true) - { - $key = ($key === false) ? 0 : count($block); - } - - // Get correct position if array given - if (is_array($key)) - { - // Search array to get correct position - list($search_key, $search_value) = @each($key); - - $key = null; - foreach ($block as $i => $val_ary) - { - if ($val_ary[$search_key] === $search_value) - { - $key = $i; - break; - } - } - - // key/value pair not found - if ($key === null) - { - return false; - } - } - - // Insert Block - if ($mode == 'insert') - { - // Make sure we are not exceeding the last iteration - if ($key >= count($block)) - { - $key = count($block); - unset($block[($key - 1)]['S_LAST_ROW']); - $vararray['S_LAST_ROW'] = true; - } - if ($key <= 0) - { - $key = 0; - unset($block[0]['S_FIRST_ROW']); - $vararray['S_FIRST_ROW'] = true; - } - - // Assign S_BLOCK_NAME - $vararray['S_BLOCK_NAME'] = $name; - - // Re-position template blocks - for ($i = count($block); $i > $key; $i--) - { - $block[$i] = $block[$i-1]; - - $block[$i]['S_ROW_COUNT'] = $block[$i]['S_ROW_NUM'] = $i; - } - - // Insert vararray at given position - $block[$key] = $vararray; - $block[$key]['S_ROW_COUNT'] = $block[$key]['S_ROW_NUM'] = $key; - - return true; - } - - // Which block to change? - if ($mode == 'change') - { - // If key is out of bounds, do not change anything - if ($key > count($block) || $key < 0) - { - return false; - } - - if ($key == count($block)) - { - $key--; - } - - $block[$key] = array_merge($block[$key], $vararray); - - return true; - } - - // Delete Block - if ($mode == 'delete') - { - // If we are exceeding last iteration, do not delete anything - if ($key > count($block) || $key < 0) - { - return false; - } - - // If we are positioned at the end, we remove the last element - if ($key == count($block)) - { - $key--; - } - - // We are deleting the last element in the block, so remove the block - if (count($block) === 1) - { - $block = null; // unset($block); does not work on references - return true; - } - - // Re-position template blocks - for ($i = $key; $i < count($block)-1; $i++) - { - $block[$i] = $block[$i+1]; - $block[$i]['S_ROW_COUNT'] = $block[$i]['S_ROW_NUM'] = $i; - } - - // Remove the last element - unset($block[$i]); - - // Set first and last elements again, in case they were removed - $block[0]['S_FIRST_ROW'] = true; - $block[count($block)-1]['S_LAST_ROW'] = true; - - return true; - } - - return false; - } - - /** - * Reset/empty complete block - * - * @param string $blockname Name of block to destroy - * @return true - */ - public function destroy_block_vars($blockname) - { - $this->num_rows_is_set = false; - if (strpos($blockname, '.') !== false) - { - // Nested block. - $blocks = explode('.', $blockname); - $blockcount = count($blocks) - 1; - - $str = &$this->tpldata; - for ($i = 0; $i < $blockcount; $i++) - { - $str = &$str[$blocks[$i]]; - $str = &$str[count($str) - 1]; - } - - unset($str[$blocks[$blockcount]]); - } - else - { - // Top-level block. - unset($this->tpldata[$blockname]); - } - - return true; - } -} diff --git a/install/update/new/phpbb/template/template.php b/install/update/new/phpbb/template/template.php deleted file mode 100644 index 6634c28..0000000 --- a/install/update/new/phpbb/template/template.php +++ /dev/null @@ -1,224 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\template; - -interface template -{ - - /** - * Clear the cache - * - * @return \phpbb\template\template - */ - public function clear_cache(); - - /** - * Sets the template filenames for handles. - * - * @param array $filename_array Should be a hash of handle => filename pairs. - * @return \phpbb\template\template $this - */ - public function set_filenames(array $filename_array); - - /** - * Get the style tree of the style preferred by the current user - * - * @return array Style tree, most specific first - */ - public function get_user_style(); - - /** - * Set style location based on (current) user's chosen style. - * - * @param array $style_directories The directories to add style paths for - * E.g. array('ext/foo/bar/styles', 'styles') - * Default: array('styles') (phpBB's style directory) - * @return \phpbb\template\template $this - */ - public function set_style($style_directories = array('styles')); - - /** - * Set custom style location (able to use directory outside of phpBB). - * - * Note: Templates are still compiled to phpBB's cache directory. - * - * @param string|array $names Array of names or string of name of template(s) in inheritance tree order, used by extensions. - * @param string|array or string $paths Array of style paths, relative to current root directory - * @return \phpbb\template\template $this - */ - public function set_custom_style($names, $paths); - - /** - * Clears all variables and blocks assigned to this template. - * - * @return \phpbb\template\template $this - */ - public function destroy(); - - /** - * Reset/empty complete block - * - * @param string $blockname Name of block to destroy - * @return \phpbb\template\template $this - */ - public function destroy_block_vars($blockname); - - /** - * Display a template for provided handle. - * - * The template will be loaded and compiled, if necessary, first. - * - * This function calls hooks. - * - * @param string $handle Handle to display - * @return \phpbb\template\template $this - */ - public function display($handle); - - /** - * Display the handle and assign the output to a template variable - * or return the compiled result. - * - * @param string $handle Handle to operate on - * @param string $template_var Template variable to assign compiled handle to - * @param bool $return_content If true return compiled handle, otherwise assign to $template_var - * @return \phpbb\template\template|string if $return_content is true return string of the compiled handle, otherwise return $this - */ - public function assign_display($handle, $template_var = '', $return_content = true); - - /** - * Assign key variable pairs from an array - * - * @param array $vararray A hash of variable name => value pairs - * @return \phpbb\template\template $this - */ - public function assign_vars(array $vararray); - - /** - * Assign a single scalar value to a single key. - * - * Value can be a string, an integer or a boolean. - * - * @param string $varname Variable name - * @param string $varval Value to assign to variable - * @return \phpbb\template\template $this - */ - public function assign_var($varname, $varval); - - /** - * Append text to the string value stored in a key. - * - * Text is appended using the string concatenation operator (.). - * - * @param string $varname Variable name - * @param string $varval Value to append to variable - * @return \phpbb\template\template $this - */ - public function append_var($varname, $varval); - - /** - * Retrieve multiple template values - * - * @param array $vararray An array with variable names - * @return array A hash of variable name => value pairs (value is null if not set) - */ - public function retrieve_vars(array $vararray); - - /** - * Retrieve a single scalar value from a single key. - * - * @param string $varname Variable name - * @return mixed Variable value, or null if not set - */ - public function retrieve_var($varname); - - /** - * Assign key variable pairs from an array to a specified block - * @param string $blockname Name of block to assign $vararray to - * @param array $vararray A hash of variable name => value pairs - * @return \phpbb\template\template $this - */ - public function assign_block_vars($blockname, array $vararray); - - /** - * Assign key variable pairs from an array to a whole specified block loop - * @param string $blockname Name of block to assign $block_vars_array to - * @param array $block_vars_array An array of hashes of variable name => value pairs - * @return \phpbb\template\template $this - */ - public function assign_block_vars_array($blockname, array $block_vars_array); - - /** - * Retrieve variable values from an specified block - * @param string $blockname Name of block to retrieve $vararray from - * @param array $vararray An array with variable names, empty array gets all vars - * @return array A hash of variable name => value pairs (value is null if not set) - */ - public function retrieve_block_vars($blockname, array $vararray); - - /** - * Change already assigned key variable pair (one-dimensional - single loop entry) - * - * An example of how to use this function: - * {@example alter_block_array.php} - * - * @param string $blockname the blockname, for example 'loop' - * @param array $vararray the var array to insert/add or merge - * @param mixed $key Key to search for - * - * array: KEY => VALUE [the key/value pair to search for within the loop to determine the correct position] - * - * int: Position [the position to change or insert at directly given] - * - * If key is false the position is set to 0 - * If key is true the position is set to the last entry - * - * @param string $mode Mode to execute (valid modes are 'insert', 'change' and 'delete') - * - * If insert, the vararray is inserted at the given position (position counting from zero). - * If change, the current block gets merged with the vararray (resulting in new \key/value pairs be added and existing keys be replaced by the new \value). - * If delete, the vararray is ignored, and the block at the given position (counting from zero) is removed. - * - * Since counting begins by zero, inserting at the last position will result in this array: array(vararray, last positioned array) - * and inserting at position 1 will result in this array: array(first positioned array, vararray, following vars) - * - * @return bool false on error, true on success - */ - public function alter_block_array($blockname, array $vararray, $key = false, $mode = 'insert'); - - /** - * Find the index for a specified key in the innermost specified block - * - * @param string $blockname the blockname, for example 'loop' - * @param mixed $key Key to search for - * - * array: KEY => VALUE [the key/value pair to search for within the loop to determine the correct position] - * - * int: Position [the position to search for] - * - * If key is false the position is set to 0 - * If key is true the position is set to the last entry - * - * @return mixed false if not found, index position otherwise; be sure to test with === - */ - public function find_key_index($blockname, $key); - - /** - * Get path to template for handle (required for BBCode parser) - * - * @param string $handle Handle to retrieve the source file - * @return string - */ - public function get_source_file_for_handle($handle); -} diff --git a/install/update/new/phpbb/template/twig/extension.php b/install/update/new/phpbb/template/twig/extension.php deleted file mode 100644 index 1131a7f..0000000 --- a/install/update/new/phpbb/template/twig/extension.php +++ /dev/null @@ -1,201 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\template\twig; - -class extension extends \Twig_Extension -{ - /** @var \phpbb\template\context */ - protected $context; - - /** @var \phpbb\template\twig\environment */ - protected $environment; - - /** @var \phpbb\language\language */ - protected $language; - - /** - * Constructor - * - * @param \phpbb\template\context $context - * @param \phpbb\template\twig\environment $environment - * @param \phpbb\language\language $language - */ - public function __construct(\phpbb\template\context $context, \phpbb\template\twig\environment $environment, $language) - { - $this->context = $context; - $this->environment = $environment; - $this->language = $language; - } - - /** - * Get the name of this extension - * - * @return string - */ - public function getName() - { - return 'phpbb'; - } - - /** - * Returns the token parser instance to add to the existing list. - * - * @return array An array of Twig_TokenParser instances - */ - public function getTokenParsers() - { - return array( - new \phpbb\template\twig\tokenparser\defineparser, - new \phpbb\template\twig\tokenparser\includeparser, - new \phpbb\template\twig\tokenparser\includejs, - new \phpbb\template\twig\tokenparser\includecss, - new \phpbb\template\twig\tokenparser\event($this->environment), - new \phpbb\template\twig\tokenparser\includephp($this->environment), - new \phpbb\template\twig\tokenparser\php($this->environment), - ); - } - - /** - * Returns a list of filters to add to the existing list. - * - * @return array An array of filters - */ - public function getFilters() - { - return array( - new \Twig_SimpleFilter('subset', array($this, 'loop_subset'), array('needs_environment' => true)), - // @deprecated 3.2.0 Uses twig's JS escape method instead of addslashes - new \Twig_SimpleFilter('addslashes', 'addslashes'), - ); - } - - /** - * Returns a list of global functions to add to the existing list. - * - * @return array An array of global functions - */ - public function getFunctions() - { - return array( - new \Twig_SimpleFunction('lang', array($this, 'lang')), - new \Twig_SimpleFunction('lang_defined', array($this, 'lang_defined')), - new \Twig_SimpleFunction('get_class', 'get_class'), - ); - } - - /** - * Returns a list of operators to add to the existing list. - * - * @return array An array of operators - */ - public function getOperators() - { - return array( - array( - '!' => array('precedence' => 50, 'class' => 'Twig_Node_Expression_Unary_Not'), - ), - array( - // precedence settings are copied from similar operators in Twig core extension - '||' => array('precedence' => 10, 'class' => 'Twig_Node_Expression_Binary_Or', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT), - '&&' => array('precedence' => 15, 'class' => 'Twig_Node_Expression_Binary_And', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT), - - 'eq' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Equal', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT), - - 'ne' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_NotEqual', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT), - 'neq' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_NotEqual', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT), - '<>' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_NotEqual', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT), - - '===' => array('precedence' => 20, 'class' => '\phpbb\template\twig\node\expression\binary\equalequal', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT), - '!==' => array('precedence' => 20, 'class' => '\phpbb\template\twig\node\expression\binary\notequalequal', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT), - - 'gt' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Greater', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT), - 'gte' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_GreaterEqual', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT), - 'ge' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_GreaterEqual', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT), - 'lt' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Less', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT), - 'lte' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_LessEqual', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT), - 'le' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_LessEqual', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT), - - 'mod' => array('precedence' => 60, 'class' => 'Twig_Node_Expression_Binary_Mod', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT), - ), - ); - } - - /** - * Grabs a subset of a loop - * - * @param \Twig_Environment $env A Twig_Environment instance - * @param mixed $item A variable - * @param integer $start Start of the subset - * @param integer $end End of the subset - * @param Boolean $preserveKeys Whether to preserve key or not (when the input is an array) - * - * @return mixed The sliced variable - */ - public function loop_subset(\Twig_Environment $env, $item, $start, $end = null, $preserveKeys = false) - { - // We do almost the same thing as Twig's slice (array_slice), except when $end is positive - if ($end >= 1) - { - // When end is > 1, subset will end on the last item in an array with the specified $end - // This is different from slice in that it is the number we end on rather than the number - // of items to grab (length) - - // Start must always be the actual starting number for this calculation (not negative) - $start = ($start < 0) ? count($item) + $start : $start; - $end = $end - $start; - } - - // We always include the last element (this was the past design) - $end = ($end == -1 || $end === null) ? null : $end + 1; - - return twig_slice($env, $item, $start, $end, $preserveKeys); - } - - /** - * Get output for a language variable (L_FOO, LA_FOO) - * - * This function checks to see if the language var was outputted to $context - * (e.g. in the ACP, L_TITLE) - * If not, we return the result of $user->lang() - * - * @return string - */ - public function lang() - { - $args = func_get_args(); - $key = $args[0]; - - $context_vars = $this->context->get_root_ref(); - - if (is_string($key) && isset($context_vars['L_' . $key])) - { - return $context_vars['L_' . $key]; - } - - // LA_ is transformed into lang(\'$1\')|escape('js'), so we should not - // need to check for it - - return call_user_func_array(array($this->language, 'lang'), $args); - } - - /** - * Check if a language variable exists - * - * @return bool - */ - public function lang_defined($key) - { - return call_user_func_array([$this->language, 'is_set'], [$key]); - } -} diff --git a/install/update/new/phpbb/template/twig/extension/avatar.php b/install/update/new/phpbb/template/twig/extension/avatar.php deleted file mode 100644 index 7a17fd4..0000000 --- a/install/update/new/phpbb/template/twig/extension/avatar.php +++ /dev/null @@ -1,80 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\template\twig\extension; - -class avatar extends \Twig_Extension -{ - /** - * Get the name of this extension - * - * @return string - */ - public function getName() - { - return 'avatar'; - } - - /** - * Returns a list of global functions to add to the existing list. - * - * @return array An array of global functions - */ - public function getFunctions() - { - return array( - new \Twig_SimpleFunction('avatar', array($this, 'get_avatar')), - ); - } - - /** - * Get avatar for placing into templates. - * - * How to use in a template: - * - {{ avatar('mode', row, alt, ignore_config, lazy) }} - * - * The mode and row (group_row or user_row) are required. - * The other fields (alt|ignore_config|lazy) are optional. - * - * @uses \phpbb_get_group_avatar() - * @uses \phpbb_get_user_avatar() - * - * @return string The avatar HTML for the specified mode - */ - public function get_avatar() - { - $args = func_get_args(); - - $mode = (string) $args[0]; - $row = (array) $args[1]; - $alt = isset($args[2]) ? (string) $args[2] : false; - $ignore_config = isset($args[3]) ? (bool) $args[3] : false; - $lazy = isset($args[4]) ? (bool) $args[4] : false; - - // To prevent having to redefine alt attribute ('USER_AVATAR'|'GROUP_AVATAR'), we check if an alternative has been provided - switch ($mode) - { - case 'group': - return $alt ? phpbb_get_group_avatar($row, $alt, $ignore_config, $lazy) : phpbb_get_group_avatar($row); - break; - - case 'user': - return $alt ? phpbb_get_user_avatar($row, $alt, $ignore_config, $lazy) : phpbb_get_user_avatar($row); - break; - - default: - return ''; - break; - } - } -} diff --git a/install/update/new/phpbb/template/twig/extension/config.php b/install/update/new/phpbb/template/twig/extension/config.php deleted file mode 100644 index cbf6e50..0000000 --- a/install/update/new/phpbb/template/twig/extension/config.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\template\twig\extension; - -class config extends \Twig_Extension -{ - /** @var \phpbb\config\config */ - protected $config; - - /** - * Constructor. - * - * @param \phpbb\config\config $config Configuration object - */ - public function __construct(\phpbb\config\config $config) - { - $this->config = $config; - } - - /** - * Get the name of this extension - * - * @return string - */ - public function getName() - { - return 'config'; - } - - /** - * Returns a list of global functions to add to the existing list. - * - * @return array An array of global functions - */ - public function getFunctions() - { - return array( - new \Twig_SimpleFunction('config', array($this, 'get_config')), - ); - } - - /** - * Retrieves a configuration value for use in templates. - * - * @return string The configuration value - */ - public function get_config() - { - $args = func_get_args(); - - return $this->config->offsetGet($args[0]); - } -} diff --git a/install/update/new/phpbb/template/twig/extension/username.php b/install/update/new/phpbb/template/twig/extension/username.php deleted file mode 100644 index ef14969..0000000 --- a/install/update/new/phpbb/template/twig/extension/username.php +++ /dev/null @@ -1,84 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\template\twig\extension; - -class username extends \Twig_Extension -{ - /** - * Get the name of this extension - * - * @return string - */ - public function getName() - { - return 'username'; - } - - /** - * Returns a list of global functions to add to the existing list. - * - * @return array An array of global functions - */ - public function getFunctions() - { - return array( - new \Twig_SimpleFunction('username', array($this, 'get_username')), - ); - } - - /** - * Get username details for placing into templates. - * - * How to use in a template: - * - {{ username('mode', user_id, username, user_colour, guest_username, custom_profile_url) }} - * - {{ username('mode', user_row, guest_username, custom_profile_url) }} - * It's possible to provide the user identifier, name and colour separately, - * or provide the entire user row at once as an array. - * - * The mode, user_id and username are required (separately or through a user row). - * The other fields (user_colour|guest_username|custom_profile_url) are optional. - * - * @uses \get_username_string() - * - * @return string A string based on what is wanted depending on $mode - */ - public function get_username() - { - $args = func_get_args(); - - $mode = $args[0]; - $user = $args[1]; - - // If the entire user row is provided - if (is_array($user)) - { - $user_id = isset($user['user_id']) ? $user['user_id'] : ''; - $username = isset($user['username']) ? $user['username'] : ''; - $user_colour = isset($user['user_colour']) ? $user['user_colour'] : ''; - $guest_username = isset($args[2]) ? $args[2] : false; - $custom_profile_url = isset($args[3]) ? $args[3] : false; - } - else - { - // Options are provided separately - $user_id = $user; - $username = $args[2]; - $user_colour = isset($args[3]) ? $args[3] : ''; - $guest_username = isset($args[4]) ? $args[4] : false; - $custom_profile_url = isset($args[5]) ? $args[5] : false; - } - - return get_username_string($mode, $user_id, $username, $user_colour, $guest_username, $custom_profile_url); - } -} diff --git a/install/update/new/phpbb/template/twig/lexer.php b/install/update/new/phpbb/template/twig/lexer.php deleted file mode 100644 index 6615a46..0000000 --- a/install/update/new/phpbb/template/twig/lexer.php +++ /dev/null @@ -1,358 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\template\twig; - -class lexer extends \Twig_Lexer -{ - public function tokenize(\Twig_Source $source) - { - $code = $source->getCode(); - $filename = $source->getName(); - - // Our phpBB tags - // Commented out tokens are handled separately from the main replace - $phpbb_tags = array( - /*'BEGIN', - 'BEGINELSE', - 'END', - 'IF', - 'ELSE', - 'ELSEIF', - 'ENDIF', - 'DEFINE', - 'UNDEFINE',*/ - 'ENDDEFINE', - 'INCLUDE', - 'INCLUDEPHP', - 'INCLUDEJS', - 'INCLUDECSS', - 'PHP', - 'ENDPHP', - 'EVENT', - ); - - // Twig tag masks - $twig_tags = array( - 'autoescape', - 'endautoescape', - 'if', - 'elseif', - 'else', - 'endif', - 'block', - 'endblock', - 'use', - 'extends', - 'embed', - 'filter', - 'endfilter', - 'flush', - 'for', - 'endfor', - 'macro', - 'endmacro', - 'import', - 'from', - 'sandbox', - 'endsandbox', - 'set', - 'endset', - 'spaceless', - 'endspaceless', - 'verbatim', - 'endverbatim', - ); - - // Fix tokens that may have inline variables (e.g. with Twig style, {% TOKEN %} - // This also strips outer parenthesis, becomes - $code = preg_replace('##', '{% $1 $2 %}', $code); - - // Replace all of our twig masks with Twig code (e.g. with {% block $1 %}) - $code = $this->replace_twig_tag_masks($code, $twig_tags); - - // Replace all of our language variables, {L_VARNAME}, with Twig style, {{ lang('NAME') }} - // Appends any filters after lang() - $code = preg_replace('#{L_([a-zA-Z0-9_\.]+)(\|[^}]+?)?}#', '{{ lang(\'$1\')$2 }}', $code); - - // Replace all of our escaped language variables, {LA_VARNAME}, with Twig style, {{ lang('NAME')|escape('js') }} - // Appends any filters after lang(), but before escape('js') - $code = preg_replace('#{LA_([a-zA-Z0-9_\.]+)(\|[^}]+?)?}#', '{{ lang(\'$1\')$2|escape(\'js\') }}', $code); - - // Replace all of our variables, {VARNAME}, with Twig style, {{ VARNAME }} - // Appends any filters - $code = preg_replace('#{([a-zA-Z0-9_\.]+)(\|[^}]+?)?}#', '{{ $1$2 }}', $code); - - // Tokenize \Twig_Source instance - return parent::tokenize(new \Twig_Source($code, $filename)); - } - - /** - * Strip surrounding quotes - * - * First step to fix tokens that may have inline variables - * E.g. #', '', $code); - } - - /** - * Fix tokens that may have inline variables - * - * Second step to fix tokens that may have inline variables - * E.g. "; - }; - - return preg_replace_callback('##', $callback, $code); - } - - /** - * Add surrounding quotes - * - * Last step to fix tokens that may have inline variables - * E.g. #', '', $code); - } - - /** - * Fix begin tokens (convert our BEGIN to Twig for) - * - * Not meant to be used outside of this context, public because the anonymous function calls this - * - * @param string $code - * @param array $parent_nodes (used in recursion) - * @return string - */ - public function fix_begin_tokens($code, $parent_nodes = array()) - { - // PHP 5.3 cannot use $this in an anonymous function, so use this as a work-around - $parent_class = $this; - $callback = function ($matches) use ($parent_class, $parent_nodes) - { - $hard_parents = explode('.', $matches[1]); - array_pop($hard_parents); // ends with . - if ($hard_parents) - { - $parent_nodes = array_merge($hard_parents, $parent_nodes); - } - - $name = $matches[2]; - $subset = trim(substr($matches[3], 1, -1)); // Remove parenthesis - $body = $matches[4]; - - // Replace - $body = str_replace('', '{% else %}', $body); - - // Is the designer wanting to call another loop in a loop? - // - // - // - // - // 'loop2' is actually on the same nesting level as 'loop' you assign - // variables to it with template->assign_block_vars('loop2', array(...)) - if (strpos($name, '!') === 0) - { - // Count the number if ! occurrences - $count = substr_count($name, '!'); - for ($i = 0; $i < $count; $i++) - { - array_pop($parent_nodes); - $name = substr($name, 1); - } - } - - // Remove all parent nodes, e.g. foo, bar from foo.bar.foobar.VAR - foreach ($parent_nodes as $node) - { - $body = preg_replace('#([^a-zA-Z0-9_])' . $node . '\.([a-zA-Z0-9_]+)\.#', '$1$2.', $body); - } - - // Add current node to list of parent nodes for child nodes - $parent_nodes[] = $name; - - // Recursive...fix any child nodes - $body = $parent_class->fix_begin_tokens($body, $parent_nodes); - - // Need the parent variable name - array_pop($parent_nodes); - $parent = (!empty($parent_nodes)) ? end($parent_nodes) . '.' : ''; - - if ($subset !== '') - { - $subset = '|subset(' . $subset . ')'; - } - - $parent = ($parent) ?: 'loops.'; - // Turn into a Twig for loop - return "{% for {$name} in {$parent}{$name}{$subset} %}{$body}{% endfor %}"; - }; - - return preg_replace_callback('#(.+?)#s', $callback, $code); - } - - /** - * Fix IF statements - * - * @param string $code - * @return string - */ - protected function fix_if_tokens($code) - { - // Replace ELSE IF with ELSEIF - $code = preg_replace('##', '', $code); - - // Replace our "div by" with Twig's divisibleby (Twig does not like test names with spaces) - $code = preg_replace('# div by ([0-9]+)#', ' divisibleby($1)', $code); - - $callback = function($matches) - { - $inner = $matches[2]; - // Replace $TEST with definition.TEST - $inner = preg_replace('#(\s\(*!?)\$([a-zA-Z_0-9]+)#', '$1definition.$2', $inner); - - // Replace .foo with loops.foo|length - $inner = preg_replace('#(\s\(*!?)\.([a-zA-Z_0-9]+)([^a-zA-Z_0-9\.])#', '$1loops.$2|length$3', $inner); - - // Replace .foo.bar with foo.bar|length - $inner = preg_replace('#(\s\(*!?)\.([a-zA-Z_0-9\.]+)([^a-zA-Z_0-9\.])#', '$1$2|length$3', $inner); - - return ""; - }; - - return preg_replace_callback('##', $callback, $code); - } - - /** - * Fix DEFINE statements and {$VARNAME} variables - * - * @param string $code - * @return string - */ - protected function fix_define_tokens($code) - { - /** - * Changing $VARNAME to definition.varname because set is only local - * context (e.g. DEFINE $TEST will only make $TEST available in current - * template and any child templates, but not any parent templates). - * - * DEFINE handles setting it properly to definition in its node, but the - * variables reading FROM it need to be altered to definition.VARNAME - * - * Setting up definition as a class in the array passed to Twig - * ($context) makes set definition.TEST available in the global context - */ - - // Replace #', '{% DEFINE $1 %}', $code); - - // Changing UNDEFINE NAME to DEFINE NAME = null to save from creating an extra token parser/node - $code = preg_replace('##', '{% DEFINE $1= null %}', $code); - - // Replace all of our variables, {$VARNAME}, with Twig style, {{ definition.VARNAME }} - $code = preg_replace('#{\$([a-zA-Z0-9_\.]+)}#', '{{ definition.$1 }}', $code); - - // Replace all of our variables, ~ $VARNAME ~, with Twig style, ~ definition.VARNAME ~ - $code = preg_replace('#~ \$([a-zA-Z0-9_\.]+) ~#', '~ definition.$1 ~', $code); - - return $code; - } - - /** - * Replace Twig tag masks with Twig tag calls - * - * E.g. with {% block foo %} - * - * @param string $code - * @param array $twig_tags All tags we want to create a mask for - * @return string - */ - protected function replace_twig_tag_masks($code, $twig_tags) - { - $callback = function ($matches) - { - $matches[1] = strtolower($matches[1]); - - return "{% {$matches[1]}{$matches[2]}%}"; - }; - - foreach ($twig_tags as &$tag) - { - $tag = strtoupper($tag); - } - - // twig_tags is an array of the twig tags, which are all lowercase, but we use all uppercase tags - $code = preg_replace_callback('##',$callback, $code); - - return $code; - } -} diff --git a/install/update/new/phpbb/template/twig/loader.php b/install/update/new/phpbb/template/twig/loader.php deleted file mode 100644 index 0f193db..0000000 --- a/install/update/new/phpbb/template/twig/loader.php +++ /dev/null @@ -1,176 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\template\twig; - -/** -* Twig Template loader -*/ -class loader extends \Twig_Loader_Filesystem -{ - protected $safe_directories = array(); - - /** - * @var \phpbb\filesystem\filesystem_interface - */ - protected $filesystem; - - /** - * Constructor - * - * @param \phpbb\filesystem\filesystem_interface $filesystem - * @param string|array $paths - */ - public function __construct(\phpbb\filesystem\filesystem_interface $filesystem, $paths = array()) - { - $this->filesystem = $filesystem; - - parent::__construct($paths, __DIR__); - } - - /** - * Set safe directories - * - * @param array $directories Array of directories that are safe (empty to clear) - * @return \Twig_Loader_Filesystem - */ - public function setSafeDirectories($directories = array()) - { - $this->safe_directories = array(); - - if (!empty($directories)) - { - foreach ($directories as $directory) - { - $this->addSafeDirectory($directory); - } - } - - return $this; - } - - /** - * Add safe directory - * - * @param string $directory Directory that should be added - * @return \Twig_Loader_Filesystem - */ - public function addSafeDirectory($directory) - { - $directory = $this->filesystem->realpath($directory); - - if ($directory !== false) - { - $this->safe_directories[] = $directory; - } - - return $this; - } - - /** - * Get current safe directories - * - * @return array - */ - public function getSafeDirectories() - { - return $this->safe_directories; - } - - /** - * Override for parent::validateName() - * - * This is done because we added support for safe directories, and when Twig - * findTemplate() is called, validateName() is called first, which would - * always throw an exception if the file is outside of the configured - * template directories. - */ - protected function validateName($name) - { - return; - } - - /** - * Adds a realpath call to fix a BC break in Twig 1.26 (https://github.com/twigphp/Twig/issues/2145) - * - * {@inheritdoc} - */ - public function addPath($path, $namespace = self::MAIN_NAMESPACE) - { - return parent::addPath($this->filesystem->realpath($path), $namespace); - } - - /** - * Find the template - * - * Override for Twig_Loader_Filesystem::findTemplate to add support - * for loading from safe directories. - */ - protected function findTemplate($name, $throw = true) - { - $name = (string) $name; - - // normalize name - $name = preg_replace('#/{2,}#', '/', strtr($name, '\\', '/')); - - // If this is in the cache we can skip the entire process below - // as it should have already been validated - if (isset($this->cache[$name])) - { - return $this->cache[$name]; - } - - // First, find the template name. The override above of validateName - // causes the validateName process to be skipped for this call - $file = parent::findTemplate($name, $throw); - - try - { - // Try validating the name (which may throw an exception) - $this->validateName($name); - } - catch (\Twig_Error_Loader $e) - { - if (strpos($e->getRawMessage(), 'Looks like you try to load a template outside configured directories') === 0) - { - // Ok, so outside of the configured template directories, we - // can now check if we're within a "safe" directory - - // Find the real path of the directory the file is in - $directory = $this->filesystem->realpath(dirname($file)); - - if ($directory === false) - { - // Some sort of error finding the actual path, must throw the exception - throw $e; - } - - foreach ($this->safe_directories as $safe_directory) - { - if (strpos($directory, $safe_directory) === 0) - { - // The directory being loaded is below a directory - // that is "safe". We're good to load it! - return $file; - } - } - } - - // Not within any safe directories - throw $e; - } - - // No exception from validateName, safe to load. - return $file; - } -} diff --git a/install/update/new/phpbb/template/twig/node/definenode.php b/install/update/new/phpbb/template/twig/node/definenode.php deleted file mode 100644 index 1c51596..0000000 --- a/install/update/new/phpbb/template/twig/node/definenode.php +++ /dev/null @@ -1,57 +0,0 @@ - -* @copyright Portions (c) 2009 Fabien Potencier, Armin Ronacher -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\template\twig\node; - -class definenode extends \Twig_Node -{ - public function __construct($capture, \Twig_Node $name, \Twig_Node $value, $lineno, $tag = null) - { - parent::__construct(array('name' => $name, 'value' => $value), array('capture' => $capture, 'safe' => false), $lineno, $tag); - } - - /** - * Compiles the node to PHP. - * - * @param \Twig_Compiler A Twig_Compiler instance - */ - public function compile(\Twig_Compiler $compiler) - { - $compiler->addDebugInfo($this); - - if ($this->getAttribute('capture')) - { - $compiler - ->write("ob_start();\n") - ->subcompile($this->getNode('value')) - ; - - $compiler->write("\$value = ('' === \$value = ob_get_clean()) ? '' : new \Twig_Markup(\$value, \$this->env->getCharset());\n"); - } - else - { - $compiler - ->write("\$value = ") - ->subcompile($this->getNode('value')) - ->raw(";\n") - ; - } - - $compiler - ->write("\$context['definition']->set('") - ->raw($this->getNode('name')->getAttribute('name')) - ->raw("', \$value);\n") - ; - } -} diff --git a/install/update/new/phpbb/template/twig/node/includeasset.php b/install/update/new/phpbb/template/twig/node/includeasset.php deleted file mode 100644 index 69bfd58..0000000 --- a/install/update/new/phpbb/template/twig/node/includeasset.php +++ /dev/null @@ -1,65 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\template\twig\node; - -abstract class includeasset extends \Twig_Node -{ - public function __construct(\Twig_Node_Expression $expr, $lineno, $tag = null) - { - parent::__construct(array('expr' => $expr), array(), $lineno, $tag); - } - - /** - * Compiles the node to PHP. - * - * @param \Twig_Compiler A Twig_Compiler instance - */ - public function compile(\Twig_Compiler $compiler) - { - $compiler->addDebugInfo($this); - - $compiler - ->write("\$asset_file = ") - ->subcompile($this->getNode('expr')) - ->raw(";\n") - ->write("\$asset = new \phpbb\\template\\asset(\$asset_file, \$this->env->get_path_helper(), \$this->env->get_filesystem());\n") - ->write("if (substr(\$asset_file, 0, 2) !== './' && \$asset->is_relative()) {\n") - ->indent() - ->write("\$asset_path = \$asset->get_path();") - ->write("\$local_file = \$this->env->get_phpbb_root_path() . \$asset_path;\n") - ->write("if (!file_exists(\$local_file)) {\n") - ->indent() - ->write("\$local_file = \$this->env->findTemplate(\$asset_path);\n") - ->write("\$asset->set_path(\$local_file, true);\n") - ->outdent() - ->write("}\n") - ->outdent() - ->write("}\n") - ->write("\n") - ->write("if (\$asset->is_relative()) {\n") - ->indent() - ->write("\$asset->add_assets_version(\$this->env->get_phpbb_config()['assets_version']);\n") - ->outdent() - ->write("}\n") - ->write("\$this->env->get_assets_bag()->add_{$this->get_setters_name()}(\$asset);") - ; - } - - /** - * Get the name of the assets bag setter - * - * @return string (e.g. 'script') - */ - abstract public function get_setters_name(); -} diff --git a/install/update/new/phpbb/template/twig/node/includephp.php b/install/update/new/phpbb/template/twig/node/includephp.php deleted file mode 100644 index 0cf95ab..0000000 --- a/install/update/new/phpbb/template/twig/node/includephp.php +++ /dev/null @@ -1,91 +0,0 @@ - -* Sections (c) 2009 Fabien Potencier, Armin Ronacher -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\template\twig\node; - -class includephp extends \Twig_Node -{ - /** @var \Twig_Environment */ - protected $environment; - - public function __construct(\Twig_Node_Expression $expr, \phpbb\template\twig\environment $environment, $lineno, $ignoreMissing = false, $tag = null) - { - $this->environment = $environment; - - parent::__construct(array('expr' => $expr), array('ignore_missing' => (Boolean) $ignoreMissing), $lineno, $tag); - } - - /** - * Compiles the node to PHP. - * - * @param \Twig_Compiler A Twig_Compiler instance - */ - public function compile(\Twig_Compiler $compiler) - { - $compiler->addDebugInfo($this); - - $config = $this->environment->get_phpbb_config(); - - if (!$config['tpl_allow_php']) - { - $compiler - ->write("// INCLUDEPHP Disabled\n") - ; - - return; - } - - if ($this->getAttribute('ignore_missing')) - { - $compiler - ->write("try {\n") - ->indent() - ; - } - - $compiler - ->write("\$location = ") - ->subcompile($this->getNode('expr')) - ->raw(";\n") - ->write("if (phpbb_is_absolute(\$location)) {\n") - ->indent() - // Absolute path specified - ->write("require(\$location);\n") - ->outdent() - ->write("} else if (file_exists(\$this->env->get_phpbb_root_path() . \$location)) {\n") - ->indent() - // PHP file relative to phpbb_root_path - ->write("require(\$this->env->get_phpbb_root_path() . \$location);\n") - ->outdent() - ->write("} else {\n") - ->indent() - // Local path (behaves like INCLUDE) - ->write("require(\$this->env->getLoader()->getCacheKey(\$location));\n") - ->outdent() - ->write("}\n") - ; - - if ($this->getAttribute('ignore_missing')) - { - $compiler - ->outdent() - ->write("} catch (\Twig_Error_Loader \$e) {\n") - ->indent() - ->write("// ignore missing template\n") - ->outdent() - ->write("}\n\n") - ; - } - } -} diff --git a/install/update/new/phpbb/template/twig/tokenparser/defineparser.php b/install/update/new/phpbb/template/twig/tokenparser/defineparser.php deleted file mode 100644 index 6285091..0000000 --- a/install/update/new/phpbb/template/twig/tokenparser/defineparser.php +++ /dev/null @@ -1,76 +0,0 @@ - -* @copyright Portions (c) 2009 Fabien Potencier, Armin Ronacher -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\template\twig\tokenparser; - -class defineparser extends \Twig_TokenParser -{ - /** - * Parses a token and returns a node. - * - * @param \Twig_Token $token A Twig_Token instance - * - * @return \Twig_Node A Twig_Node instance - * @throws \Twig_Error_Syntax - * @throws \phpbb\template\twig\node\definenode - */ - public function parse(\Twig_Token $token) - { - $lineno = $token->getLine(); - $stream = $this->parser->getStream(); - $name = $this->parser->getExpressionParser()->parseExpression(); - - $capture = false; - if ($stream->test(\Twig_Token::OPERATOR_TYPE, '=')) - { - $stream->next(); - $value = $this->parser->getExpressionParser()->parseExpression(); - - if ($value instanceof \Twig_Node_Expression_Name) - { - // This would happen if someone improperly formed their DEFINE syntax - // e.g. - throw new \Twig_Error_Syntax('Invalid DEFINE', $token->getLine(), $this->parser->getStream()->getSourceContext()->getPath()); - } - - $stream->expect(\Twig_Token::BLOCK_END_TYPE); - } - else - { - $capture = true; - - $stream->expect(\Twig_Token::BLOCK_END_TYPE); - - $value = $this->parser->subparse(array($this, 'decideBlockEnd'), true); - $stream->expect(\Twig_Token::BLOCK_END_TYPE); - } - - return new \phpbb\template\twig\node\definenode($capture, $name, $value, $lineno, $this->getTag()); - } - - public function decideBlockEnd(\Twig_Token $token) - { - return $token->test('ENDDEFINE'); - } - - /** - * Gets the tag name associated with this token parser. - * - * @return string The tag name - */ - public function getTag() - { - return 'DEFINE'; - } -} diff --git a/install/update/new/phpbb/template/twig/tokenparser/event.php b/install/update/new/phpbb/template/twig/tokenparser/event.php deleted file mode 100644 index 92ecff4..0000000 --- a/install/update/new/phpbb/template/twig/tokenparser/event.php +++ /dev/null @@ -1,57 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\template\twig\tokenparser; - -class event extends \Twig_TokenParser -{ - /** @var \phpbb\template\twig\environment */ - protected $environment; - - /** - * Constructor - * - * @param \phpbb\template\twig\environment $environment - */ - public function __construct(\phpbb\template\twig\environment $environment) - { - $this->environment = $environment; - } - - /** - * Parses a token and returns a node. - * - * @param \Twig_Token $token A Twig_Token instance - * - * @return \Twig_Node A Twig_Node instance - */ - public function parse(\Twig_Token $token) - { - $expr = $this->parser->getExpressionParser()->parseExpression(); - - $stream = $this->parser->getStream(); - $stream->expect(\Twig_Token::BLOCK_END_TYPE); - - return new \phpbb\template\twig\node\event($expr, $this->environment, $token->getLine(), $this->getTag()); - } - - /** - * Gets the tag name associated with this token parser. - * - * @return string The tag name - */ - public function getTag() - { - return 'EVENT'; - } -} diff --git a/install/update/new/phpbb/template/twig/tokenparser/includecss.php b/install/update/new/phpbb/template/twig/tokenparser/includecss.php deleted file mode 100644 index f7e55a4..0000000 --- a/install/update/new/phpbb/template/twig/tokenparser/includecss.php +++ /dev/null @@ -1,44 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\template\twig\tokenparser; - -class includecss extends \Twig_TokenParser -{ - /** - * Parses a token and returns a node. - * - * @param \Twig_Token $token A Twig_Token instance - * - * @return \Twig_Node A Twig_Node instance - */ - public function parse(\Twig_Token $token) - { - $expr = $this->parser->getExpressionParser()->parseExpression(); - - $stream = $this->parser->getStream(); - $stream->expect(\Twig_Token::BLOCK_END_TYPE); - - return new \phpbb\template\twig\node\includecss($expr, $token->getLine(), $this->getTag()); - } - - /** - * Gets the tag name associated with this token parser. - * - * @return string The tag name - */ - public function getTag() - { - return 'INCLUDECSS'; - } -} diff --git a/install/update/new/phpbb/template/twig/tokenparser/includejs.php b/install/update/new/phpbb/template/twig/tokenparser/includejs.php deleted file mode 100644 index 598ea0a..0000000 --- a/install/update/new/phpbb/template/twig/tokenparser/includejs.php +++ /dev/null @@ -1,44 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\template\twig\tokenparser; - -class includejs extends \Twig_TokenParser -{ - /** - * Parses a token and returns a node. - * - * @param \Twig_Token $token A Twig_Token instance - * - * @return \Twig_Node A Twig_Node instance - */ - public function parse(\Twig_Token $token) - { - $expr = $this->parser->getExpressionParser()->parseExpression(); - - $stream = $this->parser->getStream(); - $stream->expect(\Twig_Token::BLOCK_END_TYPE); - - return new \phpbb\template\twig\node\includejs($expr, $token->getLine(), $this->getTag()); - } - - /** - * Gets the tag name associated with this token parser. - * - * @return string The tag name - */ - public function getTag() - { - return 'INCLUDEJS'; - } -} diff --git a/install/update/new/phpbb/template/twig/tokenparser/includeparser.php b/install/update/new/phpbb/template/twig/tokenparser/includeparser.php deleted file mode 100644 index 2fba4ac..0000000 --- a/install/update/new/phpbb/template/twig/tokenparser/includeparser.php +++ /dev/null @@ -1,44 +0,0 @@ - -* @copyright Portions (c) 2009 Fabien Potencier, Armin Ronacher -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\template\twig\tokenparser; - -class includeparser extends \Twig_TokenParser_Include -{ - /** - * Parses a token and returns a node. - * - * @param \Twig_Token $token A Twig_Token instance - * - * @return \Twig_Node A Twig_Node instance - */ - public function parse(\Twig_Token $token) - { - $expr = $this->parser->getExpressionParser()->parseExpression(); - - list($variables, $only, $ignoreMissing) = $this->parseArguments(); - - return new \phpbb\template\twig\node\includenode($expr, $variables, $only, $ignoreMissing, $token->getLine(), $this->getTag()); - } - - /** - * Gets the tag name associated with this token parser. - * - * @return string The tag name - */ - public function getTag() - { - return 'INCLUDE'; - } -} diff --git a/install/update/new/phpbb/template/twig/tokenparser/includephp.php b/install/update/new/phpbb/template/twig/tokenparser/includephp.php deleted file mode 100644 index 2fdf396..0000000 --- a/install/update/new/phpbb/template/twig/tokenparser/includephp.php +++ /dev/null @@ -1,68 +0,0 @@ - -* @copyright Portions (c) 2009 Fabien Potencier, Armin Ronacher -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\template\twig\tokenparser; - -class includephp extends \Twig_TokenParser -{ - /** @var \phpbb\template\twig\environment */ - protected $environment; - - /** - * Constructor - * - * @param \phpbb\template\twig\environment $environment - */ - public function __construct(\phpbb\template\twig\environment $environment) - { - $this->environment = $environment; - } - - /** - * Parses a token and returns a node. - * - * @param \Twig_Token $token A Twig_Token instance - * - * @return \Twig_Node A Twig_Node instance - */ - public function parse(\Twig_Token $token) - { - $expr = $this->parser->getExpressionParser()->parseExpression(); - - $stream = $this->parser->getStream(); - - $ignoreMissing = false; - if ($stream->test(\Twig_Token::NAME_TYPE, 'ignore')) - { - $stream->next(); - $stream->expect(\Twig_Token::NAME_TYPE, 'missing'); - - $ignoreMissing = true; - } - - $stream->expect(\Twig_Token::BLOCK_END_TYPE); - - return new \phpbb\template\twig\node\includephp($expr, $this->environment, $token->getLine(), $ignoreMissing, $this->getTag()); - } - - /** - * Gets the tag name associated with this token parser. - * - * @return string The tag name - */ - public function getTag() - { - return 'INCLUDEPHP'; - } -} diff --git a/install/update/new/phpbb/template/twig/tokenparser/php.php b/install/update/new/phpbb/template/twig/tokenparser/php.php deleted file mode 100644 index 3007912..0000000 --- a/install/update/new/phpbb/template/twig/tokenparser/php.php +++ /dev/null @@ -1,65 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\template\twig\tokenparser; - -class php extends \Twig_TokenParser -{ - /** @var \phpbb\template\twig\environment */ - protected $environment; - - /** - * Constructor - * - * @param \phpbb\template\twig\environment $environment - */ - public function __construct(\phpbb\template\twig\environment $environment) - { - $this->environment = $environment; - } - - /** - * Parses a token and returns a node. - * - * @param \Twig_Token $token A Twig_Token instance - * - * @return \Twig_Node A Twig_Node instance - */ - public function parse(\Twig_Token $token) - { - $stream = $this->parser->getStream(); - - $stream->expect(\Twig_Token::BLOCK_END_TYPE); - - $body = $this->parser->subparse(array($this, 'decideEnd'), true); - - $stream->expect(\Twig_Token::BLOCK_END_TYPE); - - return new \phpbb\template\twig\node\php($body, $this->environment, $token->getLine(), $this->getTag()); - } - - public function decideEnd(\Twig_Token $token) - { - return $token->test('ENDPHP'); - } - - /** - * Gets the tag name associated with this token parser. - * - * @return string The tag name - */ - public function getTag() - { - return 'PHP'; - } -} diff --git a/install/update/new/phpbb/textformatter/acp_utils_interface.php b/install/update/new/phpbb/textformatter/acp_utils_interface.php deleted file mode 100644 index cdee56f..0000000 --- a/install/update/new/phpbb/textformatter/acp_utils_interface.php +++ /dev/null @@ -1,54 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\textformatter; - -interface acp_utils_interface -{ - /** - * There is an issue with the definition - */ - const BBCODE_STATUS_INVALID_DEFINITION = 'invalid_definition'; - - /** - * There is an issue with the template - */ - const BBCODE_STATUS_INVALID_TEMPLATE = 'invalid_template'; - - /** - * The BBCode is valid and can be safely used by anyone - */ - const BBCODE_STATUS_SAFE = 'safe'; - - /** - * The BBCode is valid but may be unsafe to use - */ - const BBCODE_STATUS_UNSAFE = 'unsafe'; - - /** - * Analyse given BBCode definition for issues and safeness - * - * Required elements in the return array: - * - status: see BBCODE_STATUS_* constants - * - * Optional elements in the return array: - * - name: Name of the BBCode based on the definition. Required if status is "safe". - * - error_text: Textual description of the issue in plain text or as a L_* string. - * - error_html: Visual description of the issue in HTML. - * - * @param string $definition BBCode definition, e.g. [b]{TEXT}[/b] - * @param string $template BBCode template, e.g. {TEXT} - * @return array - */ - public function analyse_bbcode(string $definition, string $template): array; -} diff --git a/install/update/new/phpbb/textformatter/s9e/acp_utils.php b/install/update/new/phpbb/textformatter/s9e/acp_utils.php deleted file mode 100644 index c4a6680..0000000 --- a/install/update/new/phpbb/textformatter/s9e/acp_utils.php +++ /dev/null @@ -1,67 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\textformatter\s9e; - -use phpbb\textformatter\acp_utils_interface; -use s9e\TextFormatter\Configurator\Exceptions\UnsafeTemplateException; - -class acp_utils implements acp_utils_interface -{ - /** - * @var factory $factory - */ - protected $factory; - - /** - * @param factory $factory - */ - public function __construct(factory $factory) - { - $this->factory = $factory; - } - - /** - * {@inheritdoc} - */ - public function analyse_bbcode(string $definition, string $template): array - { - $configurator = $this->factory->get_configurator(); - $return = ['status' => self::BBCODE_STATUS_SAFE]; - - // Capture and normalize the BBCode name manually because there's no easy way to retrieve - // it in TextFormatter <= 2.x - if (preg_match('(\\[([-\\w]++))', $definition, $m)) - { - $return['name'] = strtoupper($m[1]); - } - - try - { - $configurator->BBCodes->addCustom($definition, $template); - } - catch (UnsafeTemplateException $e) - { - $return['status'] = self::BBCODE_STATUS_UNSAFE; - $return['error_text'] = $e->getMessage(); - $return['error_html'] = $e->highlightNode(''); - } - catch (\Exception $e) - { - $return['status'] = (preg_match('(xml|xpath|xsl)i', $e->getMessage())) ? self::BBCODE_STATUS_INVALID_TEMPLATE : self::BBCODE_STATUS_INVALID_DEFINITION; - $return['error_text'] = $e->getMessage(); - } - - return $return; - } -} diff --git a/install/update/new/phpbb/textformatter/s9e/bbcode_merger.php b/install/update/new/phpbb/textformatter/s9e/bbcode_merger.php deleted file mode 100644 index d1bedb0..0000000 --- a/install/update/new/phpbb/textformatter/s9e/bbcode_merger.php +++ /dev/null @@ -1,199 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\textformatter\s9e; - -use phpbb\textformatter\s9e\factory; -use s9e\TextFormatter\Configurator\Helpers\TemplateLoader; -use s9e\TextFormatter\Configurator\Items\UnsafeTemplate; - -class bbcode_merger -{ - /** - * @var \s9e\TextFormatter\Configurator $configurator Configurator instance used to inspect BBCodes - */ - protected $configurator; - - /** - * @param \phpbb\textformatter\s9e\factory $factory - */ - public function __construct(factory $factory) - { - $this->configurator = $factory->get_configurator(); - } - - /** - * Merge two BBCode definitions - * - * All of the arrays contain a "usage" element and a "template" element - * - * @throws InvalidArgumentException if a definition cannot be interpreted - * @throws RuntimeException if something unexpected occurs - * - * @param array $without BBCode definition without an attribute - * @param array $with BBCode definition with an attribute - * @return array Merged definition - */ - public function merge_bbcodes(array $without, array $with) - { - $without = $this->create_bbcode($without); - $with = $this->create_bbcode($with); - - // Select the appropriate strategy for merging this BBCode - if (!$this->is_optional_bbcode($without, $with) && $this->is_content_bbcode($without, $with)) - { - $merged = $this->merge_content_bbcode($without, $with); - } - else - { - $merged = $this->merge_optional_bbcode($without, $with); - } - - $merged['template'] = $this->normalize_template($merged['template']); - - return $merged; - } - - /** - * Create a custom BBCode for inspection - * - * @param array $definition Original BBCode definition - * @return array Updated definition containing a BBCode object and a Tag - */ - protected function create_bbcode(array $definition) - { - $bbcode = $this->configurator->BBCodes->addCustom( - $definition['usage'], - new UnsafeTemplate($definition['template']) - ); - - $definition['bbcode'] = $bbcode; - $definition['tag'] = $this->configurator->tags[$bbcode->tagName]; - - return $definition; - } - - /** - * Indent given template for readability - * - * @param string $template - * @return string - */ - protected function indent_template($template) - { - $dom = TemplateLoader::load($template); - $dom->formatOutput = true; - $template = TemplateLoader::save($dom); - - // Remove the first level of indentation if the template starts with whitespace - if (preg_match('(^\\n +)', $template, $m)) - { - $template = str_replace($m[0], "\n", $template); - } - - return trim($template); - } - - /** - * Test whether the two definitions form a "content"-style BBCode - * - * Such BBCodes include the [url] BBCode, which uses its text content as - * attribute if none is provided - * - * @param array $without BBCode definition without an attribute - * @param array $with BBCode definition with an attribute - * @return bool - */ - protected function is_content_bbcode(array $without, array $with) - { - // Test whether we find the same non-TEXT token between "]" and "[" in the usage - // as between ">" and "<" in the template - return (preg_match('(\\]\\s*(\\{(?!TEXT)[^}]+\\})\\s*\\[)', $without['usage'], $m) - && preg_match('(>[^<]*?' . preg_quote($m[1]) . '[^>]*?<)s', $without['template'])); - } - - /** - * Test whether the two definitions form BBCode with an optional attribute - * - * @param array $without BBCode definition without an attribute - * @param array $with BBCode definition with an attribute - * @return bool - */ - protected function is_optional_bbcode(array $without, array $with) - { - // Remove the default attribute from the definition - $with['usage'] = preg_replace('(=[^\\]]++)', '', $with['usage']); - - // Test whether both definitions are the same, regardless of case - return strcasecmp($without['usage'], $with['usage']) === 0; - } - - /** - * Merge the two BBCode definitions of a "content"-style BBCode - * - * @param array $without BBCode definition without an attribute - * @param array $with BBCode definition with an attribute - * @return array Merged definition - */ - protected function merge_content_bbcode(array $without, array $with) - { - // Convert [x={X}] into [x={X;useContent}] - $usage = preg_replace('(\\})', ';useContent}', $with['usage'], 1); - - // Use the template from the definition that uses an attribute - $template = $with['tag']->template; - - return ['usage' => $usage, 'template' => $template]; - } - - /** - * Merge the two BBCode definitions of a BBCode with an optional argument - * - * Such BBCodes include the [quote] BBCode, which takes an optional argument - * but otherwise does not behave differently - * - * @param array $without BBCode definition without an attribute - * @param array $with BBCode definition with an attribute - * @return array Merged definition - */ - protected function merge_optional_bbcode(array $without, array $with) - { - // Convert [X={X}] into [X={X?}] - $usage = preg_replace('(\\})', '?}', $with['usage'], 1); - - // Build a template for both versions - $template = '' . $with['tag']->template . '' . $without['tag']->template . ''; - - return ['usage' => $usage, 'template' => $template]; - } - - /** - * Normalize a template - * - * @param string $template - * @return string - */ - protected function normalize_template($template) - { - // Normalize the template to simplify it - $template = $this->configurator->templateNormalizer->normalizeTemplate($template); - - // Convert xsl:value-of elements back to {L_} tokens where applicable - $template = preg_replace('()', '{$1}', $template); - - // Beautify the template - $template = $this->indent_template($template); - - return $template; - } -} diff --git a/install/update/new/phpbb/textformatter/s9e/factory.php b/install/update/new/phpbb/textformatter/s9e/factory.php deleted file mode 100644 index f82c7b0..0000000 --- a/install/update/new/phpbb/textformatter/s9e/factory.php +++ /dev/null @@ -1,678 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\textformatter\s9e; - -use s9e\TextFormatter\Configurator; -use s9e\TextFormatter\Configurator\Items\AttributeFilters\RegexpFilter; -use s9e\TextFormatter\Configurator\Items\UnsafeTemplate; - -/** -* Creates s9e\TextFormatter objects -*/ -class factory implements \phpbb\textformatter\cache_interface -{ - /** - * @var \phpbb\textformatter\s9e\link_helper - */ - protected $link_helper; - - /** - * @var \phpbb\cache\driver\driver_interface - */ - protected $cache; - - /** - * @var string Path to the cache dir - */ - protected $cache_dir; - - /** - * @var string Cache key used for the parser - */ - protected $cache_key_parser; - - /** - * @var string Cache key used for the renderer - */ - protected $cache_key_renderer; - - /** - * @var \phpbb\config\config - */ - protected $config; - - /** - * @var array Custom tokens used in bbcode.html and their corresponding token from the definition - */ - protected $custom_tokens = array( - 'email' => array('{DESCRIPTION}' => '{TEXT}'), - 'flash' => array('{WIDTH}' => '{NUMBER1}', '{HEIGHT}' => '{NUMBER2}'), - 'img' => array('{URL}' => '{IMAGEURL}'), - 'list' => array('{LIST_TYPE}' => '{HASHMAP}'), - 'quote' => array('{USERNAME}' => '{TEXT1}'), - 'size' => array('{SIZE}' => '{FONTSIZE}'), - 'url' => array('{DESCRIPTION}' => '{TEXT}'), - ); - - /** - * @var \phpbb\textformatter\data_access - */ - protected $data_access; - - /** - * @var array Default BBCode definitions - */ - protected $default_definitions = array( - 'attachment' => '[ATTACHMENT index={NUMBER} filename={TEXT;useContent}]', - 'b' => '[B]{TEXT}[/B]', - 'code' => '[CODE lang={IDENTIFIER;optional}]{TEXT}[/CODE]', - 'color' => '[COLOR={COLOR}]{TEXT}[/COLOR]', - 'email' => '[EMAIL={EMAIL;useContent} subject={TEXT1;optional;postFilter=rawurlencode} body={TEXT2;optional;postFilter=rawurlencode}]{TEXT}[/EMAIL]', - 'flash' => '[FLASH={NUMBER1},{NUMBER2} width={NUMBER1;postFilter=#flashwidth} height={NUMBER2;postFilter=#flashheight} url={URL;useContent} /]', - 'i' => '[I]{TEXT}[/I]', - 'img' => '[IMG src={IMAGEURL;useContent}]', - 'list' => '[LIST type={HASHMAP=1:decimal,a:lower-alpha,A:upper-alpha,i:lower-roman,I:upper-roman;optional;postFilter=#simpletext} #createChild=LI]{TEXT}[/LIST]', - 'li' => '[* $tagName=LI]{TEXT}[/*]', - 'quote' => - "[QUOTE - author={TEXT1;optional} - post_id={UINT;optional} - post_url={URL;optional;postFilter=#false} - msg_id={UINT;optional} - msg_url={URL;optional;postFilter=#false} - profile_url={URL;optional;postFilter=#false} - time={UINT;optional} - url={URL;optional} - user_id={UINT;optional} - author={PARSE=/^\\[url=(?'url'.*?)](?'author'.*)\\[\\/url]$/i} - author={PARSE=/^\\[url](?'author'(?'url'.*?))\\[\\/url]$/i} - author={PARSE=/(?'url'https?:\\/\\/[^[\\]]+)/i} - ]{TEXT2}[/QUOTE]", - 'size' => '[SIZE={FONTSIZE}]{TEXT}[/SIZE]', - 'u' => '[U]{TEXT}[/U]', - 'url' => '[URL={URL;useContent} $forceLookahead=true]{TEXT}[/URL]', - ); - - /** - * @var array Default templates, taken from bbcode::bbcode_tpl() - */ - protected $default_templates = array( - 'b' => '', - 'i' => '', - 'u' => '', - 'img' => '{L_IMAGE}', - 'size' => 'font-size: %; line-height: normal', - 'color' => '', - 'email' => ' - - mailto: - - - ? - subject= - &body= - - - - ', - ); - - /** - * @var \phpbb\event\dispatcher_interface - */ - protected $dispatcher; - - /** - * @var \phpbb\log\log_interface - */ - protected $log; - - /** - * Constructor - * - * @param \phpbb\textformatter\data_access $data_access - * @param \phpbb\cache\driver\driver_interface $cache - * @param \phpbb\event\dispatcher_interface $dispatcher - * @param \phpbb\config\config $config - * @param \phpbb\textformatter\s9e\link_helper $link_helper - * @param \phpbb\log\log_interface $log - * @param string $cache_dir Path to the cache dir - * @param string $cache_key_parser Cache key used for the parser - * @param string $cache_key_renderer Cache key used for the renderer - */ - public function __construct(\phpbb\textformatter\data_access $data_access, \phpbb\cache\driver\driver_interface $cache, \phpbb\event\dispatcher_interface $dispatcher, \phpbb\config\config $config, \phpbb\textformatter\s9e\link_helper $link_helper, \phpbb\log\log_interface $log, $cache_dir, $cache_key_parser, $cache_key_renderer) - { - $this->link_helper = $link_helper; - $this->cache = $cache; - $this->cache_dir = $cache_dir; - $this->cache_key_parser = $cache_key_parser; - $this->cache_key_renderer = $cache_key_renderer; - $this->config = $config; - $this->data_access = $data_access; - $this->dispatcher = $dispatcher; - $this->log = $log; - } - - /** - * {@inheritdoc} - */ - public function invalidate() - { - $this->regenerate(); - } - - /** - * {@inheritdoc} - * - * Will remove old renderers from the cache dir but won't touch the current renderer - */ - public function tidy() - { - // Get the name of current renderer - $renderer_data = $this->cache->get($this->cache_key_renderer); - $renderer_file = ($renderer_data) ? $renderer_data['class'] . '.php' : null; - - foreach (glob($this->cache_dir . 's9e_*') as $filename) - { - // Only remove the file if it's not the current renderer - if (!$renderer_file || substr($filename, -strlen($renderer_file)) !== $renderer_file) - { - unlink($filename); - } - } - } - - /** - * Generate and return a new configured instance of s9e\TextFormatter\Configurator - * - * @return Configurator - */ - public function get_configurator() - { - // Create a new Configurator - $configurator = new Configurator; - - /** - * Modify the s9e\TextFormatter configurator before the default settings are set - * - * @event core.text_formatter_s9e_configure_before - * @var \s9e\TextFormatter\Configurator configurator Configurator instance - * @since 3.2.0-a1 - */ - $vars = array('configurator'); - extract($this->dispatcher->trigger_event('core.text_formatter_s9e_configure_before', compact($vars))); - - // Reset the list of allowed schemes - foreach ($configurator->urlConfig->getAllowedSchemes() as $scheme) - { - $configurator->urlConfig->disallowScheme($scheme); - } - foreach (explode(',', $this->config['allowed_schemes_links']) as $scheme) - { - $configurator->urlConfig->allowScheme(trim($scheme)); - } - - // Convert newlines to br elements by default - $configurator->rootRules->enableAutoLineBreaks(); - - // Don't automatically ignore text in places where text is not allowed - $configurator->rulesGenerator->remove('IgnoreTextIfDisallowed'); - - // Don't remove comments and instead convert them to xsl:comment elements - $configurator->templateNormalizer->remove('RemoveComments'); - $configurator->templateNormalizer->add('TransposeComments'); - - // Set the rendering engine and configure it to save to the cache dir - $configurator->rendering->engine = 'PHP'; - $configurator->rendering->engine->cacheDir = $this->cache_dir; - $configurator->rendering->engine->defaultClassPrefix = 's9e_renderer_'; - $configurator->rendering->engine->enableQuickRenderer = true; - - // Create custom filters for BBCode tokens that are supported in phpBB but not in - // s9e\TextFormatter - $filter = new RegexpFilter('#^' . get_preg_expression('relative_url') . '$#Du'); - $configurator->attributeFilters->add('#local_url', $filter); - $configurator->attributeFilters->add('#relative_url', $filter); - - // INTTEXT regexp from acp_bbcodes - $filter = new RegexpFilter('!^([\p{L}\p{N}\-+,_. ]+)$!Du'); - $configurator->attributeFilters->add('#inttext', $filter); - - // Create custom filters for Flash restrictions, which use the same values as the image - // restrictions but have their own error message - $configurator->attributeFilters - ->add('#flashheight', __NAMESPACE__ . '\\parser::filter_flash_height') - ->addParameterByName('max_img_height') - ->addParameterByName('logger'); - - $configurator->attributeFilters - ->add('#flashwidth', __NAMESPACE__ . '\\parser::filter_flash_width') - ->addParameterByName('max_img_width') - ->addParameterByName('logger'); - - // Create a custom filter for phpBB's per-mode font size limits - $configurator->attributeFilters - ->add('#fontsize', __NAMESPACE__ . '\\parser::filter_font_size') - ->addParameterByName('max_font_size') - ->addParameterByName('logger') - ->markAsSafeInCSS(); - - // Create a custom filter for image URLs - $configurator->attributeFilters - ->add('#imageurl', __NAMESPACE__ . '\\parser::filter_img_url') - ->addParameterByName('urlConfig') - ->addParameterByName('logger') - ->addParameterByName('max_img_height') - ->addParameterByName('max_img_width') - ->markAsSafeAsURL() - ->setJS('UrlFilter.filter'); - - // Add default BBCodes - foreach ($this->get_default_bbcodes($configurator) as $bbcode) - { - $this->add_bbcode($configurator, $bbcode['usage'], $bbcode['template']); - } - if (isset($configurator->tags['QUOTE'])) - { - // Remove the nesting limit and let other services remove quotes at parsing time - $configurator->tags['QUOTE']->nestingLimit = PHP_INT_MAX; - } - - // Modify the template to disable images/flash depending on user's settings - foreach (array('FLASH', 'IMG') as $name) - { - $tag = $configurator->tags[$name]; - $tag->template = '' . $tag->template . ''; - } - - // Load custom BBCodes - foreach ($this->data_access->get_bbcodes() as $row) - { - // Insert the board's URL before {LOCAL_URL} tokens - $tpl = preg_replace_callback( - '#\\{LOCAL_URL\\d*\\}#', - function ($m) - { - return generate_board_url() . '/' . $m[0]; - }, - $row['bbcode_tpl'] - ); - $this->add_bbcode($configurator, $row['bbcode_match'], $tpl); - } - - // Load smilies - foreach ($this->data_access->get_smilies() as $row) - { - $configurator->Emoticons->set( - $row['code'], - '{.}' - ); - } - - if (isset($configurator->Emoticons)) - { - // Force emoticons to be rendered as text if $S_VIEWSMILIES is not set - $configurator->Emoticons->notIfCondition = 'not($S_VIEWSMILIES)'; - - // Only parse emoticons at the beginning of the text or if they're preceded by any - // one of: a new line, a space, a dot, or a right square bracket - $configurator->Emoticons->notAfter = '[^\\n .\\]]'; - - // Ignore emoticons that are immediately followed by a "word" character - $configurator->Emoticons->notBefore = '\\w'; - } - - // Load the censored words - $censor = $this->data_access->get_censored_words(); - if (!empty($censor)) - { - // Use a namespaced tag to avoid collisions - $configurator->plugins->load('Censor', array('tagName' => 'censor:tag')); - foreach ($censor as $row) - { - $configurator->Censor->add($row['word'], $row['replacement']); - } - } - - // Load the magic links plugins. We do that after BBCodes so that they use the same tags - $this->configure_autolink($configurator); - - // Register some vars with a default value. Those should be set at runtime by whatever calls - // the parser - $configurator->registeredVars['max_font_size'] = 0; - $configurator->registeredVars['max_img_height'] = 0; - $configurator->registeredVars['max_img_width'] = 0; - - // Load the Emoji plugin and modify its tag's template to obey viewsmilies - $tag = $configurator->Emoji->getTag(); - $tag->template = ' - - {.} - - - {.} - - '; - $tag->template = '' . str_replace('class="emoji"', 'class="emoji smilies"', $tag->template) . ''; - - /** - * Modify the s9e\TextFormatter configurator after the default settings are set - * - * @event core.text_formatter_s9e_configure_after - * @var \s9e\TextFormatter\Configurator configurator Configurator instance - * @since 3.2.0-a1 - */ - $vars = array('configurator'); - extract($this->dispatcher->trigger_event('core.text_formatter_s9e_configure_after', compact($vars))); - - return $configurator; - } - - /** - * Regenerate and cache a new parser and renderer - * - * @return array Associative array with at least two elements: "parser" and "renderer" - */ - public function regenerate() - { - $configurator = $this->get_configurator(); - - // Get the censor helper and remove the Censor plugin if applicable - if (isset($configurator->Censor)) - { - $censor = $configurator->Censor->getHelper(); - unset($configurator->Censor); - unset($configurator->tags['censor:tag']); - } - - $objects = $configurator->finalize(); - - /** - * Access the objects returned by finalize() before they are saved to cache - * - * @event core.text_formatter_s9e_configure_finalize - * @var array objects Array containing a "parser" object, a "renderer" object and optionally a "js" string - * @since 3.2.2-RC1 - */ - $vars = array('objects'); - extract($this->dispatcher->trigger_event('core.text_formatter_s9e_configure_finalize', compact($vars))); - - $parser = $objects['parser']; - $renderer = $objects['renderer']; - - // Cache the parser as-is - $this->cache->put($this->cache_key_parser, $parser); - - // We need to cache the name of the renderer's generated class - $renderer_data = array('class' => get_class($renderer)); - if (isset($censor)) - { - $renderer_data['censor'] = $censor; - } - $this->cache->put($this->cache_key_renderer, $renderer_data); - - return array('parser' => $parser, 'renderer' => $renderer); - } - - /** - * Add a BBCode to given configurator - * - * @param Configurator $configurator - * @param string $usage - * @param string $template - * @return void - */ - protected function add_bbcode(Configurator $configurator, $usage, $template) - { - try - { - $configurator->BBCodes->addCustom($usage, new UnsafeTemplate($template)); - } - catch (\Exception $e) - { - $this->log->add('critical', null, null, 'LOG_BBCODE_CONFIGURATION_ERROR', false, [$usage, $e->getMessage()]); - } - } - - /** - * Configure the Autolink / Autoemail plugins used to linkify text - * - * @param \s9e\TextFormatter\Configurator $configurator - * @return void - */ - protected function configure_autolink(Configurator $configurator) - { - $configurator->plugins->load('Autoemail'); - $configurator->plugins->load('Autolink', array('matchWww' => true)); - - // Add a tag filter that creates a tag that stores and replace the - // content of a link created by the Autolink plugin - $configurator->Autolink->getTag()->filterChain - ->add(array($this->link_helper, 'generate_link_text_tag')) - ->resetParameters() - ->addParameterByName('tag') - ->addParameterByName('parser'); - - // Create a tag that will be used to display the truncated text by - // replacing the original content with the content of the @text attribute - $tag = $configurator->tags->add('LINK_TEXT'); - $tag->attributes->add('text'); - $tag->template = ''; - - $tag->filterChain - ->add(array($this->link_helper, 'truncate_local_url')) - ->resetParameters() - ->addParameterByName('tag') - ->addParameterByValue(generate_board_url() . '/'); - $tag->filterChain - ->add(array($this->link_helper, 'truncate_text')) - ->resetParameters() - ->addParameterByName('tag'); - $tag->filterChain - ->add(array($this->link_helper, 'cleanup_tag')) - ->resetParameters() - ->addParameterByName('tag') - ->addParameterByName('parser'); - } - - /** - * Escape a literal to be used in an HTML attribute in an XSL template - * - * Escapes "HTML special chars" for obvious reasons and curly braces to avoid them - * being interpreted as an attribute value template - * - * @param string $value Original string - * @return string Escaped string - */ - protected function escape_html_attribute($value) - { - return htmlspecialchars(strtr($value, ['{' => '{{', '}' => '}}']), ENT_COMPAT | ENT_XML1, 'UTF-8'); - } - - /** - * Return the default BBCodes configuration - * - * @return array 2D array. Each element has a 'usage' key, a 'template' key, and an optional 'options' key - */ - protected function get_default_bbcodes($configurator) - { - // For each BBCode, build an associative array matching style_ids to their template - $templates = array(); - foreach ($this->data_access->get_styles_templates() as $style_id => $data) - { - foreach ($this->extract_templates($data['template']) as $bbcode_name => $template) - { - $templates[$bbcode_name][$style_id] = $template; - } - - // Add default templates wherever missing, or for BBCodes that were not specified in - // this template's bitfield. For instance, prosilver has a custom template for b but its - // bitfield does not enable it so the default template is used instead - foreach ($this->default_templates as $bbcode_name => $template) - { - if (!isset($templates[$bbcode_name][$style_id]) || !in_array($bbcode_name, $data['bbcodes'], true)) - { - $templates[$bbcode_name][$style_id] = $template; - } - } - } - - // Replace custom tokens and normalize templates - foreach ($templates as $bbcode_name => $style_templates) - { - foreach ($style_templates as $i => $template) - { - if (isset($this->custom_tokens[$bbcode_name])) - { - $template = strtr($template, $this->custom_tokens[$bbcode_name]); - } - - $templates[$bbcode_name][$i] = $configurator->templateNormalizer->normalizeTemplate($template); - } - } - - $bbcodes = array(); - foreach ($this->default_definitions as $bbcode_name => $usage) - { - $bbcodes[$bbcode_name] = array( - 'usage' => $usage, - 'template' => $this->merge_templates($templates[$bbcode_name]), - ); - } - - return $bbcodes; - } - - /** - * Extract and recompose individual BBCode templates from a style's template file - * - * @param string $template Style template (bbcode.html) - * @return array Associative array matching BBCode names to their template - */ - protected function extract_templates($template) - { - // Capture the template fragments - // Allow either phpBB template or the Twig syntax - preg_match_all('#(.*?)#s', $template, $matches, PREG_SET_ORDER) ?: - preg_match_all('#{% for (.*?) in .*? %}(.*?){% endfor %}#s', $template, $matches, PREG_SET_ORDER); - - $fragments = array(); - foreach ($matches as $match) - { - // Normalize the whitespace - $fragment = preg_replace('#>\\n\\t*<#', '><', trim($match[2])); - - $fragments[$match[1]] = $fragment; - } - - // Automatically recompose templates split between *_open and *_close - foreach ($fragments as $fragment_name => $fragment) - { - if (preg_match('#^(\\w+)_close$#', $fragment_name, $match)) - { - $bbcode_name = $match[1]; - - if (isset($fragments[$bbcode_name . '_open'])) - { - $templates[$bbcode_name] = $fragments[$bbcode_name . '_open'] . '' . $fragment; - } - } - } - - // Manually recompose and overwrite irregular templates - $templates['list'] = - ' - - ' . $fragments['ulist_open_default'] . '' . $fragments['ulist_close'] . ' - - - ' . $fragments['olist_open'] . '' . $fragments['olist_close'] . ' - - - ' . $fragments['ulist_open'] . '' . $fragments['ulist_close'] . ' - - '; - - $templates['li'] = $fragments['listitem'] . '' . $fragments['listitem_close']; - - // Replace the regular quote template with the extended quote template if available - if (isset($fragments['quote_extended'])) - { - $templates['quote'] = $fragments['quote_extended']; - } - - // The [attachment] BBCode uses the inline_attachment template to output a comment that - // is post-processed by parse_attachments() - $templates['attachment'] = $fragments['inline_attachment_open'] . ' ia ia ' . $fragments['inline_attachment_close']; - - // Add fragments as templates - foreach ($fragments as $fragment_name => $fragment) - { - if (preg_match('#^\\w+$#', $fragment_name)) - { - $templates[$fragment_name] = $fragment; - } - } - - // Keep only templates that are named after an existing BBCode - $templates = array_intersect_key($templates, $this->default_definitions); - - return $templates; - } - - /** - * Merge the templates from any number of styles into one BBCode template - * - * When multiple templates are available for the same BBCode (because of multiple styles) we - * merge them into a single template that uses an xsl:choose construct that determines which - * style to use at rendering time. - * - * @param array $style_templates Associative array matching style_ids to their template - * @return string - */ - protected function merge_templates(array $style_templates) - { - // Return the template as-is if there's only one style or all styles share the same template - if (count(array_unique($style_templates)) === 1) - { - return end($style_templates); - } - - // Group identical templates together - $grouped_templates = array(); - foreach ($style_templates as $style_id => $style_template) - { - $grouped_templates[$style_template][] = '$STYLE_ID=' . $style_id; - } - - // Sort templates by frequency descending - $templates_cnt = array_map('sizeof', $grouped_templates); - array_multisort($grouped_templates, $templates_cnt); - - // Remove the most frequent template from the list; It becomes the default - reset($grouped_templates); - $default_template = key($grouped_templates); - unset($grouped_templates[$default_template]); - - // Build an xsl:choose switch - $template = ''; - foreach ($grouped_templates as $style_template => $exprs) - { - $template .= '' . $style_template . ''; - } - $template .= '' . $default_template . ''; - - return $template; - } -} diff --git a/install/update/new/phpbb/textformatter/s9e/link_helper.php b/install/update/new/phpbb/textformatter/s9e/link_helper.php deleted file mode 100644 index 1cd5dd2..0000000 --- a/install/update/new/phpbb/textformatter/s9e/link_helper.php +++ /dev/null @@ -1,115 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\textformatter\s9e; - -class link_helper -{ - /** - * Clean up and invalidate a LINK_TEXT tag if applicable - * - * Will invalidate the tag if its replacement text is the same as the original - * text and would have no visible effect - * - * @param \s9e\TextFormatter\Parser\Tag $tag LINK_TEXT tag - * @param \s9e\TextFormatter\Parser $parser Parser - * @return void - */ - public function cleanup_tag(\s9e\TextFormatter\Parser\Tag $tag, \s9e\TextFormatter\Parser $parser) - { - // Invalidate if the content of the tag matches the text attribute - $text = substr($parser->getText(), $tag->getPos(), $tag->getLen()); - if ($text === $tag->getAttribute('text')) - { - $tag->invalidate(); - } - } - - /** - * Create a LINK_TEXT tag inside of a link - * - * Meant to only apply to linkified URLs and [url] BBCodes without a parameter - * - * @param \s9e\TextFormatter\Parser\Tag $tag URL tag (start tag) - * @param \s9e\TextFormatter\Parser $parser Parser - * @return void - */ - public function generate_link_text_tag(\s9e\TextFormatter\Parser\Tag $tag, \s9e\TextFormatter\Parser $parser) - { - // Only create a LINK_TEXT tag if the start tag is paired with an end - // tag, which is the case with tags from the Autolink plugins and with - // the [url] BBCode when its content is used for the URL - if (!$tag->getEndTag() || !$this->should_shorten($tag, $parser->getText())) - { - return; - } - - // Capture the text between the start tag and its end tag - $start = $tag->getPos() + $tag->getLen(); - $end = $tag->getEndTag()->getPos(); - $length = $end - $start; - $text = substr($parser->getText(), $start, $length); - - // Create a tag that consumes the link's text and make it depends on this tag - $link_text_tag = $parser->addSelfClosingTag('LINK_TEXT', $start, $length, 10); - $link_text_tag->setAttribute('text', $text); - $tag->cascadeInvalidationTo($link_text_tag); - } - - /** - * Test whether we should shorten this tag's text - * - * Will test whether the tag either does not use any markup or uses a single - * [url] BBCode - * - * @param \s9e\TextFormatter\Parser\Tag $tag URL tag - * @param string $text Original text - * @return bool - */ - protected function should_shorten(\s9e\TextFormatter\Parser\Tag $tag, $text) - { - return ($tag->getLen() === 0 || strtolower(substr($text, $tag->getPos(), $tag->getLen())) === '[url]'); - } - - /** - * Remove the board's root URL from a the start of a string - * - * @param \s9e\TextFormatter\Parser\Tag $tag LINK_TEXT tag - * @param string $board_url Forum's root URL (with trailing slash) - * @return void - */ - public function truncate_local_url(\s9e\TextFormatter\Parser\Tag $tag, $board_url) - { - $text = $tag->getAttribute('text'); - if (stripos($text, $board_url) === 0 && strlen($text) > strlen($board_url)) - { - $tag->setAttribute('text', substr($text, strlen($board_url))); - } - } - - /** - * Truncate the replacement text set in a LINK_TEXT tag - * - * @param \s9e\TextFormatter\Parser\Tag $tag LINK_TEXT tag - * @return void - */ - public function truncate_text(\s9e\TextFormatter\Parser\Tag $tag) - { - $text = $tag->getAttribute('text'); - if (utf8_strlen($text) > 55) - { - $text = utf8_substr($text, 0, 39) . ' ... ' . utf8_substr($text, -10); - $tag->setAttribute('text', $text); - } - } -} diff --git a/install/update/new/phpbb/textformatter/s9e/parser.php b/install/update/new/phpbb/textformatter/s9e/parser.php deleted file mode 100644 index f7e4668..0000000 --- a/install/update/new/phpbb/textformatter/s9e/parser.php +++ /dev/null @@ -1,417 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\textformatter\s9e; - -use s9e\TextFormatter\Parser\AttributeFilters\UrlFilter; -use s9e\TextFormatter\Parser\Logger; -use s9e\TextFormatter\Parser\Tag; - -/** -* s9e\TextFormatter\Parser adapter -*/ -class parser implements \phpbb\textformatter\parser_interface -{ - /** - * @var \phpbb\event\dispatcher_interface - */ - protected $dispatcher; - - /** - * @var \s9e\TextFormatter\Parser - */ - protected $parser; - - /** - * Constructor - * - * @param \phpbb\cache\driver_interface $cache - * @param string $key Cache key - * @param factory $factory - * @param \phpbb\event\dispatcher_interface $dispatcher - */ - public function __construct(\phpbb\cache\driver\driver_interface $cache, $key, factory $factory, \phpbb\event\dispatcher_interface $dispatcher) - { - $parser = $cache->get($key); - if (!$parser) - { - $objects = $factory->regenerate(); - $parser = $objects['parser']; - } - - $this->dispatcher = $dispatcher; - $this->parser = $parser; - - $parser = $this; - - /** - * Configure the parser service - * - * Can be used to: - * - toggle features or BBCodes - * - register variables or custom parsers in the s9e\TextFormatter parser - * - configure the s9e\TextFormatter parser's runtime settings - * - * @event core.text_formatter_s9e_parser_setup - * @var \phpbb\textformatter\s9e\parser parser This parser service - * @since 3.2.0-a1 - */ - $vars = array('parser'); - extract($dispatcher->trigger_event('core.text_formatter_s9e_parser_setup', compact($vars))); - } - - /** - * {@inheritdoc} - */ - public function parse($text) - { - $parser = $this; - - /** - * Modify a text before it is parsed - * - * @event core.text_formatter_s9e_parse_before - * @var \phpbb\textformatter\s9e\parser parser This parser service - * @var string text The original text - * @since 3.2.0-a1 - */ - $vars = array('parser', 'text'); - extract($this->dispatcher->trigger_event('core.text_formatter_s9e_parse_before', compact($vars))); - - $xml = $this->parser->parse($text); - - /** - * Modify a parsed text in its XML form - * - * @event core.text_formatter_s9e_parse_after - * @var \phpbb\textformatter\s9e\parser parser This parser service - * @var string xml The parsed text, in XML - * @since 3.2.0-a1 - */ - $vars = array('parser', 'xml'); - extract($this->dispatcher->trigger_event('core.text_formatter_s9e_parse_after', compact($vars))); - - return $xml; - } - - /** - * {@inheritdoc} - */ - public function disable_bbcode($name) - { - $this->parser->disableTag(strtoupper($name)); - } - - /** - * {@inheritdoc} - */ - public function disable_bbcodes() - { - $this->parser->disablePlugin('BBCodes'); - } - - /** - * {@inheritdoc} - */ - public function disable_censor() - { - $this->parser->disablePlugin('Censor'); - } - - /** - * {@inheritdoc} - */ - public function disable_magic_url() - { - $this->parser->disablePlugin('Autoemail'); - $this->parser->disablePlugin('Autolink'); - } - - /** - * {@inheritdoc} - */ - public function disable_smilies() - { - $this->parser->disablePlugin('Emoticons'); - $this->parser->disablePlugin('Emoji'); - } - - /** - * {@inheritdoc} - */ - public function enable_bbcode($name) - { - $this->parser->enableTag(strtoupper($name)); - } - - /** - * {@inheritdoc} - */ - public function enable_bbcodes() - { - $this->parser->enablePlugin('BBCodes'); - } - - /** - * {@inheritdoc} - */ - public function enable_censor() - { - $this->parser->enablePlugin('Censor'); - } - - /** - * {@inheritdoc} - */ - public function enable_magic_url() - { - $this->parser->enablePlugin('Autoemail'); - $this->parser->enablePlugin('Autolink'); - } - - /** - * {@inheritdoc} - */ - public function enable_smilies() - { - $this->parser->enablePlugin('Emoticons'); - $this->parser->enablePlugin('Emoji'); - } - - /** - * {@inheritdoc} - * - * This will convert the log entries found in s9e\TextFormatter's logger into phpBB error - * messages - */ - public function get_errors() - { - $errors = array(); - foreach ($this->parser->getLogger()->getLogs() as $entry) - { - list(, $msg, $context) = $entry; - - if ($msg === 'Tag limit exceeded') - { - if ($context['tagName'] === 'E') - { - $errors[] = array('TOO_MANY_SMILIES', $context['tagLimit']); - } - else if ($context['tagName'] === 'URL') - { - $errors[] = array('TOO_MANY_URLS', $context['tagLimit']); - } - } - else if ($msg === 'MAX_FONT_SIZE_EXCEEDED') - { - $errors[] = array($msg, $context['max_size']); - } - else if (preg_match('/^MAX_(?:FLASH|IMG)_(HEIGHT|WIDTH)_EXCEEDED$/D', $msg, $m)) - { - $errors[] = array($msg, $context['max_' . strtolower($m[1])]); - } - else if ($msg === 'Tag is disabled' && $this->is_a_bbcode($context['tag'])) - { - $name = strtolower($context['tag']->getName()); - $errors[] = array('UNAUTHORISED_BBCODE', '[' . $name . ']'); - } - else if ($msg === 'UNABLE_GET_IMAGE_SIZE') - { - $errors[] = array($msg); - } - } - - // Deduplicate error messages. array_unique() only works on strings so we have to serialize - if (!empty($errors)) - { - $errors = array_map('unserialize', array_unique(array_map('serialize', $errors))); - } - - return $errors; - } - - /** - * Return the instance of s9e\TextFormatter\Parser used by this object - * - * @return \s9e\TextFormatter\Parser - */ - public function get_parser() - { - return $this->parser; - } - - /** - * {@inheritdoc} - */ - public function set_var($name, $value) - { - if ($name === 'max_smilies') - { - $this->parser->setTagLimit('E', $value ?: PHP_INT_MAX); - } - else if ($name === 'max_urls') - { - $this->parser->setTagLimit('URL', $value ?: PHP_INT_MAX); - } - else - { - $this->parser->registeredVars[$name] = $value; - } - } - - /** - * {@inheritdoc} - */ - public function set_vars(array $vars) - { - foreach ($vars as $name => $value) - { - $this->set_var($name, $value); - } - } - - /** - * Filter a flash object's height - * - * @see bbcode_firstpass::bbcode_flash() - * - * @param string $height - * @param integer $max_height - * @param Logger $logger - * @return mixed Original value if valid, FALSE otherwise - */ - static public function filter_flash_height($height, $max_height, Logger $logger) - { - if ($max_height && $height > $max_height) - { - $logger->err('MAX_FLASH_HEIGHT_EXCEEDED', array('max_height' => $max_height)); - - return false; - } - - return $height; - } - - /** - * Filter a flash object's width - * - * @see bbcode_firstpass::bbcode_flash() - * - * @param string $width - * @param integer $max_width - * @param Logger $logger - * @return mixed Original value if valid, FALSE otherwise - */ - static public function filter_flash_width($width, $max_width, Logger $logger) - { - if ($max_width && $width > $max_width) - { - $logger->err('MAX_FLASH_WIDTH_EXCEEDED', array('max_width' => $max_width)); - - return false; - } - - return $width; - } - - /** - * Filter the value used in a [size] BBCode - * - * @see bbcode_firstpass::bbcode_size() - * - * @param string $size Original size - * @param integer $max_size Maximum allowed size - * @param Logger $logger - * @return mixed Original value if valid, FALSE otherwise - */ - static public function filter_font_size($size, $max_size, Logger $logger) - { - if ($max_size && $size > $max_size) - { - $logger->err('MAX_FONT_SIZE_EXCEEDED', array('max_size' => $max_size)); - - return false; - } - - if ($size < 1 || !is_numeric($size)) - { - return false; - } - - return $size; - } - - /** - * Filter an image's URL to enforce restrictions on its dimensions - * - * @see bbcode_firstpass::bbcode_img() - * - * @param string $url Original URL - * @param array $url_config Config used by the URL filter - * @param Logger $logger - * @param integer $max_height Maximum height allowed - * @param integer $max_width Maximum width allowed - * @return string|bool Original value if valid, FALSE otherwise - */ - static public function filter_img_url($url, array $url_config, Logger $logger, $max_height, $max_width) - { - // Validate the URL - $url = UrlFilter::filter($url, $url_config, $logger); - if ($url === false) - { - return false; - } - - if ($max_height || $max_width) - { - $imagesize = new \FastImageSize\FastImageSize(); - $size_info = $imagesize->getImageSize($url); - if ($size_info === false) - { - $logger->err('UNABLE_GET_IMAGE_SIZE'); - return false; - } - - if ($max_height && $max_height < $size_info['height']) - { - $logger->err('MAX_IMG_HEIGHT_EXCEEDED', array('max_height' => $max_height)); - return false; - } - - if ($max_width && $max_width < $size_info['width']) - { - $logger->err('MAX_IMG_WIDTH_EXCEEDED', array('max_width' => $max_width)); - return false; - } - } - - return $url; - } - - /** - * Test whether given tag consumes text that looks like BBCode-styled markup - * - * @param Tag $tag Original tag - * @return bool - */ - protected function is_a_bbcode(Tag $tag) - { - if ($tag->getLen() < 3) - { - return false; - } - $markup = substr($this->parser->getText(), $tag->getPos(), $tag->getLen()); - - return (bool) preg_match('(^\\[\\w++.*?\\]$)s', $markup); - } -} diff --git a/install/update/new/phpbb/textformatter/s9e/quote_helper.php b/install/update/new/phpbb/textformatter/s9e/quote_helper.php deleted file mode 100644 index 3011ec8..0000000 --- a/install/update/new/phpbb/textformatter/s9e/quote_helper.php +++ /dev/null @@ -1,87 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\textformatter\s9e; - -class quote_helper -{ - /** - * @var string Base URL for a post link, uses {POST_ID} as placeholder - */ - protected $post_url; - - /** - * @var string Base URL for a private message link, uses {MSG_ID} as placeholder - */ - protected $msg_url; - - /** - * @var string Base URL for a profile link, uses {USER_ID} as placeholder - */ - protected $profile_url; - - /** - * @var \phpbb\user - */ - protected $user; - - /** - * Constructor - * - * @param \phpbb\user $user - * @param string $root_path - * @param string $php_ext - */ - public function __construct(\phpbb\user $user, $root_path, $php_ext) - { - $this->post_url = append_sid($root_path . 'viewtopic.' . $php_ext, 'p={POST_ID}#p{POST_ID}', false); - $this->msg_url = append_sid($root_path . 'ucp.' . $php_ext, 'i=pm&mode=view&p={MSG_ID}', false); - $this->profile_url = append_sid($root_path . 'memberlist.' . $php_ext, 'mode=viewprofile&u={USER_ID}', false); - $this->user = $user; - } - - /** - * Inject dynamic metadata into QUOTE tags in given XML - * - * @param string $xml Original XML - * @return string Modified XML - */ - public function inject_metadata($xml) - { - return \s9e\TextFormatter\Utils::replaceAttributes( - $xml, - 'QUOTE', - function ($attributes) - { - if (isset($attributes['post_id'])) - { - $attributes['post_url'] = str_replace('{POST_ID}', $attributes['post_id'], $this->post_url); - } - if (isset($attributes['msg_id'])) - { - $attributes['msg_url'] = str_replace('{MSG_ID}', $attributes['msg_id'], $this->msg_url); - } - if (isset($attributes['time'])) - { - $attributes['date'] = $this->user->format_date($attributes['time']); - } - if (isset($attributes['user_id'])) - { - $attributes['profile_url'] = str_replace('{USER_ID}', $attributes['user_id'], $this->profile_url); - } - - return $attributes; - } - ); - } -} diff --git a/install/update/new/phpbb/ucp/controller/reset_password.php b/install/update/new/phpbb/ucp/controller/reset_password.php deleted file mode 100644 index 5c27c4f..0000000 --- a/install/update/new/phpbb/ucp/controller/reset_password.php +++ /dev/null @@ -1,443 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\ucp\controller; - -use phpbb\auth\auth; -use phpbb\config\config; -use phpbb\controller\helper; -use phpbb\db\driver\driver_interface; -use phpbb\event\dispatcher; -use phpbb\exception\http_exception; -use phpbb\language\language; -use phpbb\log\log_interface; -use phpbb\passwords\manager; -use phpbb\request\request_interface; -use phpbb\template\template; -use phpbb\user; -use Symfony\Component\HttpFoundation\Response; - -/** -* Handling forgotten passwords via reset password functionality -*/ -class reset_password -{ - /** @var config */ - protected $config; - - /** @var driver_interface */ - protected $db; - - /** @var dispatcher */ - protected $dispatcher; - - /** @var helper */ - protected $helper; - - /** @var language */ - protected $language; - - /** @var log_interface */ - protected $log; - - /** @var manager */ - protected $passwords_manager; - - /** @var request_interface */ - protected $request; - - /** @var template */ - protected $template; - - /** @var user */ - protected $user; - - /** @var array phpBB DB table names */ - protected $users_table; - - /** @var string phpBB root path */ - protected $root_path; - - /** @var string PHP extension */ - protected $php_ext; - - /** - * Reset password controller constructor. - * - * @param config $config - * @param driver_interface $db - * @param dispatcher $dispatcher - * @param helper $helper - * @param language $language - * @param log_interface $log - * @param manager $passwords_manager - * @param request_interface $request - * @param template $template - * @param user $user - * @param string $users_table - * @param string $root_path - * @param string $php_ext - */ - public function __construct(config $config, driver_interface $db, dispatcher $dispatcher, helper $helper, - language $language, log_interface $log, manager $passwords_manager, - request_interface $request, template $template, user $user, string $users_table, - string $root_path, string $php_ext) - { - $this->config = $config; - $this->db = $db; - $this->dispatcher = $dispatcher; - $this->helper = $helper; - $this->language = $language; - $this->log = $log; - $this->passwords_manager = $passwords_manager; - $this->request = $request; - $this->template = $template; - $this->user = $user; - $this->users_table = $users_table; - $this->root_path = $root_path; - $this->php_ext = $php_ext; - } - - /** - * Init controller - */ - protected function init_controller() - { - $this->language->add_lang('ucp'); - - if (!$this->config['allow_password_reset']) - { - throw new http_exception(Response::HTTP_OK, 'UCP_PASSWORD_RESET_DISABLED', [ - '', - '' - ]); - } - } - - /** - * Remove reset token for specified user - * - * @param int $user_id User ID - */ - protected function remove_reset_token(int $user_id) - { - $sql_ary = [ - 'reset_token' => '', - 'reset_token_expiration' => 0, - ]; - - $sql = 'UPDATE ' . $this->users_table . ' - SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE user_id = ' . $user_id; - $this->db->sql_query($sql); - } - - /** - * Handle password reset request - * - * @return Response - */ - public function request() - { - $this->init_controller(); - - $submit = $this->request->is_set_post('submit'); - $username = $this->request->variable('username', '', true); - $email = strtolower($this->request->variable('email', '')); - - add_form_key('ucp_reset_password'); - - if ($submit) - { - if (!check_form_key('ucp_reset_password')) - { - throw new http_exception(Response::HTTP_UNAUTHORIZED, 'FORM_INVALID'); - } - - if (empty($email)) - { - return $this->helper->message('NO_EMAIL_USER'); - } - - $sql_array = [ - 'SELECT' => 'user_id, username, user_permissions, user_email, user_jabber, user_notify_type, user_type,' - . ' user_lang, user_inactive_reason, reset_token, reset_token_expiration', - 'FROM' => [$this->users_table => 'u'], - 'WHERE' => "user_email = '" . $this->db->sql_escape($email) . "'" . - (!empty($username) ? " AND username_clean = '" . $this->db->sql_escape(utf8_clean_string($username)) . "'" : ''), - ]; - - /** - * Change SQL query for fetching user data - * - * @event core.ucp_remind_modify_select_sql - * @var string email User's email from the form - * @var string username User's username from the form - * @var array sql_array Fully assembled SQL query with keys SELECT, FROM, WHERE - * @since 3.1.11-RC1 - * @changed 3.3.0-b1 Moved to reset password controller - */ - $vars = [ - 'email', - 'username', - 'sql_array', - ]; - extract($this->dispatcher->trigger_event('core.ucp_remind_modify_select_sql', compact($vars))); - - $sql = $this->db->sql_build_query('SELECT', $sql_array); - $result = $this->db->sql_query_limit($sql, 2); // don't waste resources on more rows than we need - $rowset = $this->db->sql_fetchrowset($result); - $this->db->sql_freeresult($result); - - if (count($rowset) > 1) - { - $this->template->assign_vars([ - 'USERNAME_REQUIRED' => true, - 'EMAIL' => $email, - ]); - } - else - { - $message = $this->language->lang('PASSWORD_RESET_LINK_SENT') . '

' . $this->language->lang('RETURN_INDEX', 'root_path}index.{$this->php_ext}") . '">', ''); - - if (empty($rowset)) - { - return $this->helper->message($message); - } - - $user_row = $rowset[0]; - - if ($user_row['user_type'] == USER_IGNORE || $user_row['user_type'] == USER_INACTIVE) - { - return $this->helper->message($message); - } - - // Do not create multiple valid reset tokens - if (!empty($user_row['reset_token']) && (int) $user_row['reset_token_expiration'] >= time()) - { - return $this->helper->message($message); - } - - // Check users permissions - $auth = new auth(); - $auth->acl($user_row); - - if (!$auth->acl_get('u_chgpasswd')) - { - return $this->helper->message($message); - } - - // Generate reset token - $reset_token = strtolower(gen_rand_string(32)); - - $sql_ary = [ - 'reset_token' => $reset_token, - 'reset_token_expiration' => strtotime('+1 day'), - ]; - - $sql = 'UPDATE ' . $this->users_table . ' - SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE user_id = ' . $user_row['user_id']; - $this->db->sql_query($sql); - - if (!class_exists('messenger')) - { - include($this->root_path . 'includes/functions_messenger.' . $this->php_ext); - } - - /** @var \messenger $messenger */ - $messenger = new \messenger(false); - - $messenger->template('user_forgot_password', $user_row['user_lang']); - - $messenger->set_addresses($user_row); - - $messenger->anti_abuse_headers($this->config, $this->user); - - $messenger->assign_vars([ - 'USERNAME' => htmlspecialchars_decode($user_row['username']), - 'U_RESET_PASSWORD' => generate_board_url(true) . $this->helper->route('phpbb_ucp_reset_password_controller', [ - 'u' => $user_row['user_id'], - 'token' => $reset_token, - ], false) - ]); - - $messenger->send($user_row['user_notify_type']); - - return $this->helper->message($message); - } - } - - $this->template->assign_vars([ - 'USERNAME' => $username, - 'EMAIL' => $email, - 'U_RESET_PASSWORD_ACTION' => $this->helper->route('phpbb_ucp_forgot_password_controller'), - ]); - - return $this->helper->render('ucp_reset_password.html', $this->language->lang('RESET_PASSWORD')); - } - - /** - * Handle controller requests - * - * @return Response - */ - public function reset() - { - $this->init_controller(); - - $submit = $this->request->is_set_post('submit'); - $reset_token = $this->request->variable('token', ''); - $user_id = $this->request->variable('u', 0); - - if (empty($reset_token)) - { - return $this->helper->message('NO_RESET_TOKEN'); - } - - if (!$user_id) - { - return $this->helper->message('NO_USER'); - } - - add_form_key('ucp_reset_password'); - - $sql_array = [ - 'SELECT' => 'user_id, username, user_permissions, user_email, user_jabber, user_notify_type, user_type,' - . ' user_lang, user_inactive_reason, reset_token, reset_token_expiration', - 'FROM' => [$this->users_table => 'u'], - 'WHERE' => 'user_id = ' . $user_id, - ]; - - /** - * Change SQL query for fetching user data - * - * @event core.ucp_reset_password_modify_select_sql - * @var int user_id User ID from the form - * @var string reset_token Reset token - * @var array sql_array Fully assembled SQL query with keys SELECT, FROM, WHERE - * @since 3.3.0-b1 - */ - $vars = [ - 'user_id', - 'reset_token', - 'sql_array', - ]; - extract($this->dispatcher->trigger_event('core.ucp_reset_password_modify_select_sql', compact($vars))); - - $sql = $this->db->sql_build_query('SELECT', $sql_array); - $result = $this->db->sql_query_limit($sql, 1); - $user_row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - $message = $this->language->lang('RESET_TOKEN_EXPIRED_OR_INVALID') . '

' . $this->language->lang('RETURN_INDEX', 'root_path}index.{$this->php_ext}") . '">', ''); - - if (empty($user_row)) - { - return $this->helper->message($message); - } - - if (!hash_equals($reset_token, $user_row['reset_token'])) - { - return $this->helper->message($message); - } - - if ($user_row['reset_token_expiration'] < time()) - { - $this->remove_reset_token($user_id); - - return $this->helper->message($message); - } - - $errors = []; - - if ($submit) - { - if (!check_form_key('ucp_reset_password')) - { - return $this->helper->message('FORM_INVALID'); - } - - if ($user_row['user_type'] == USER_IGNORE || $user_row['user_type'] == USER_INACTIVE) - { - return $this->helper->message($message); - } - - // Check users permissions - $auth = new auth(); - $auth->acl($user_row); - - if (!$auth->acl_get('u_chgpasswd')) - { - return $this->helper->message($message); - } - - if (!function_exists('validate_data')) - { - include($this->root_path . 'includes/functions_user.' . $this->php_ext); - } - - $data = [ - 'new_password' => $this->request->untrimmed_variable('new_password', '', true), - 'password_confirm' => $this->request->untrimmed_variable('new_password_confirm', '', true), - ]; - $check_data = [ - 'new_password' => [ - ['string', false, $this->config['min_pass_chars'], 0], - ['password'], - ], - 'password_confirm' => ['string', true, $this->config['min_pass_chars'], 0], - ]; - $errors = array_merge($errors, validate_data($data, $check_data)); - if (strcmp($data['new_password'], $data['password_confirm']) !== 0) - { - $errors[] = $data['password_confirm'] ? 'NEW_PASSWORD_ERROR' : 'NEW_PASSWORD_CONFIRM_EMPTY'; - } - if (empty($errors)) - { - $sql_ary = [ - 'user_password' => $this->passwords_manager->hash($data['new_password']), - 'user_login_attempts' => 0, - 'reset_token' => '', - 'reset_token_expiration' => 0, - ]; - $sql = 'UPDATE ' . $this->users_table . ' - SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE user_id = ' . (int) $user_row['user_id']; - $this->db->sql_query($sql); - $this->log->add('user', $user_row['user_id'], $this->user->ip, 'LOG_USER_NEW_PASSWORD', false, [ - 'reportee_id' => $user_row['user_id'], - $user_row['username'] - ]); - meta_refresh(3, append_sid("{$this->root_path}index.{$this->php_ext}")); - return $this->helper->message($this->language->lang('PASSWORD_RESET')); - } - } - - if (!empty($errors)) - { - $this->template->assign_block_vars_array('PASSWORD_RESET_ERRORS', array_map([$this->language, 'lang'], $errors)); - } - - $this->template->assign_vars([ - 'S_IS_PASSWORD_RESET' => true, - 'U_RESET_PASSWORD_ACTION' => $this->helper->route('phpbb_ucp_reset_password_controller'), - 'S_HIDDEN_FIELDS' => build_hidden_fields([ - 'u' => $user_id, - 'token' => $reset_token, - ]), - ]); - - return $this->helper->render('ucp_reset_password.html', $this->language->lang('RESET_PASSWORD')); - } -} diff --git a/install/update/new/phpbb/user.php b/install/update/new/phpbb/user.php deleted file mode 100644 index 21d156e..0000000 --- a/install/update/new/phpbb/user.php +++ /dev/null @@ -1,848 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb; - -/** -* Base user class -* -* This is the overarching class which contains (through session extend) -* all methods utilised for user functionality during a session. -*/ -class user extends \phpbb\session -{ - /** - * @var \phpbb\language\language - */ - protected $language; - - var $style = array(); - var $date_format; - - /** - * DateTimeZone object holding the timezone of the user - */ - public $timezone; - - /** - * @var string Class name of datetime object - */ - protected $datetime; - - var $lang_name = false; - var $lang_id = false; - var $lang_path; - var $img_lang; - var $img_array = array(); - - /** @var bool */ - protected $is_setup_flag; - - // Able to add new options (up to id 31) - var $keyoptions = array('viewimg' => 0, 'viewflash' => 1, 'viewsmilies' => 2, 'viewsigs' => 3, 'viewavatars' => 4, 'viewcensors' => 5, 'attachsig' => 6, 'bbcode' => 8, 'smilies' => 9, 'sig_bbcode' => 15, 'sig_smilies' => 16, 'sig_links' => 17); - - /** - * Constructor to set the lang path - * - * @param \phpbb\language\language $lang phpBB's Language loader - * @param string $datetime_class Class name of datetime class - */ - function __construct(\phpbb\language\language $lang, $datetime_class) - { - global $phpbb_root_path; - - $this->lang_path = $phpbb_root_path . 'language/'; - $this->language = $lang; - $this->datetime = $datetime_class; - - $this->is_setup_flag = false; - } - - /** - * Returns whether user::setup was called - * - * @return bool - */ - public function is_setup() - { - return $this->is_setup_flag; - } - - /** - * Magic getter for BC compatibility - * - * Implement array access for user::lang. - * - * @param string $param_name Name of the BC component the user want to access - * - * @return array The appropriate array - * - * @deprecated 3.2.0-dev (To be removed: 4.0.0) - */ - public function __get($param_name) - { - if ($param_name === 'lang') - { - return $this->language->get_lang_array(); - } - else if ($param_name === 'help') - { - $help_array = $this->language->get_lang_array(); - return $help_array['__help']; - } - - return array(); - } - - /** - * Setup basic user-specific items (style, language, ...) - */ - function setup($lang_set = false, $style_id = false) - { - global $db, $request, $template, $config, $auth, $phpEx, $phpbb_root_path, $cache; - global $phpbb_dispatcher, $phpbb_container; - - $this->language->set_default_language($config['default_lang']); - - if ($this->data['user_id'] != ANONYMOUS) - { - $user_lang_name = (file_exists($this->lang_path . $this->data['user_lang'] . "/common.$phpEx")) ? $this->data['user_lang'] : basename($config['default_lang']); - $user_date_format = $this->data['user_dateformat']; - $user_timezone = $this->data['user_timezone']; - } - else - { - $lang_override = $request->variable('language', ''); - if ($lang_override) - { - $this->set_cookie('lang', $lang_override, 0, false); - } - else - { - $lang_override = $request->variable($config['cookie_name'] . '_lang', '', true, \phpbb\request\request_interface::COOKIE); - } - - if ($lang_override) - { - $use_lang = basename($lang_override); - $user_lang_name = (file_exists($this->lang_path . $use_lang . "/common.$phpEx")) ? $use_lang : basename($config['default_lang']); - $this->data['user_lang'] = $user_lang_name; - } - else - { - $user_lang_name = basename($config['default_lang']); - } - - $user_date_format = $config['default_dateformat']; - $user_timezone = $config['board_timezone']; - - /** - * If a guest user is surfing, we try to guess his/her language first by obtaining the browser language - * If re-enabled we need to make sure only those languages installed are checked - * Commented out so we do not loose the code. - - if ($request->header('Accept-Language')) - { - $accept_lang_ary = explode(',', $request->header('Accept-Language')); - - foreach ($accept_lang_ary as $accept_lang) - { - // Set correct format ... guess full xx_YY form - $accept_lang = substr($accept_lang, 0, 2) . '_' . strtoupper(substr($accept_lang, 3, 2)); - $accept_lang = basename($accept_lang); - - if (file_exists($this->lang_path . $accept_lang . "/common.$phpEx")) - { - $user_lang_name = $config['default_lang'] = $accept_lang; - break; - } - else - { - // No match on xx_YY so try xx - $accept_lang = substr($accept_lang, 0, 2); - $accept_lang = basename($accept_lang); - - if (file_exists($this->lang_path . $accept_lang . "/common.$phpEx")) - { - $user_lang_name = $config['default_lang'] = $accept_lang; - break; - } - } - } - } - */ - } - - $user_data = $this->data; - $lang_set_ext = array(); - - /** - * Event to load language files and modify user data on every page - * - * Note: To load language file with this event, see description - * of lang_set_ext variable. - * - * @event core.user_setup - * @var array user_data Array with user's data row - * @var string user_lang_name Basename of the user's langauge - * @var string user_date_format User's date/time format - * @var string user_timezone User's timezone, should be one of - * http://www.php.net/manual/en/timezones.php - * @var mixed lang_set String or array of language files - * @var array lang_set_ext Array containing entries of format - * array( - * 'ext_name' => (string) [extension name], - * 'lang_set' => (string|array) [language files], - * ) - * For performance reasons, only load translations - * that are absolutely needed globally using this - * event. Use local events otherwise. - * @var mixed style_id Style we are going to display - * @since 3.1.0-a1 - */ - $vars = array( - 'user_data', - 'user_lang_name', - 'user_date_format', - 'user_timezone', - 'lang_set', - 'lang_set_ext', - 'style_id', - ); - extract($phpbb_dispatcher->trigger_event('core.user_setup', compact($vars))); - - $this->data = $user_data; - $this->lang_name = $user_lang_name; - $this->date_format = $user_date_format; - - $this->language->set_user_language($user_lang_name); - - try - { - $this->timezone = new \DateTimeZone($user_timezone); - } - catch (\Exception $e) - { - // If the timezone the user has selected is invalid, we fall back to UTC. - $this->timezone = new \DateTimeZone('UTC'); - } - - $this->add_lang($lang_set); - unset($lang_set); - - foreach ($lang_set_ext as $ext_lang_pair) - { - $this->add_lang_ext($ext_lang_pair['ext_name'], $ext_lang_pair['lang_set']); - } - unset($lang_set_ext); - - $style_request = $request->variable('style', 0); - if ($style_request && (!$config['override_user_style'] || $auth->acl_get('a_styles')) && !defined('ADMIN_START')) - { - global $SID, $_EXTRA_URL; - - $style_id = $style_request; - $SID .= '&style=' . $style_id; - $_EXTRA_URL = array('style=' . $style_id); - } - else - { - // Set up style - $style_id = ($style_id) ? $style_id : ((!$config['override_user_style']) ? $this->data['user_style'] : $config['default_style']); - } - - $sql = 'SELECT * - FROM ' . STYLES_TABLE . " s - WHERE s.style_id = $style_id"; - $result = $db->sql_query($sql, 3600); - $this->style = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - // Fallback to user's standard style - if (!$this->style && $style_id != $this->data['user_style']) - { - $style_id = $this->data['user_style']; - - $sql = 'SELECT * - FROM ' . STYLES_TABLE . " s - WHERE s.style_id = $style_id"; - $result = $db->sql_query($sql, 3600); - $this->style = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - } - - // Fallback to board's default style - if (!$this->style) - { - // Verify default style exists in the database - $sql = 'SELECT style_id - FROM ' . STYLES_TABLE . ' - WHERE style_id = ' . (int) $config['default_style']; - $result = $db->sql_query($sql); - $style_id = (int) $db->sql_fetchfield('style_id'); - $db->sql_freeresult($result); - - if ($style_id > 0) - { - $db->sql_transaction('begin'); - - // Update $user row - $sql = 'SELECT * - FROM ' . STYLES_TABLE . ' - WHERE style_id = ' . (int) $config['default_style']; - $result = $db->sql_query($sql); - $this->style = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - // Update user style preference - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_style = ' . (int) $style_id . ' - WHERE user_id = ' . (int) $this->data['user_id']; - $db->sql_query($sql); - - $db->sql_transaction('commit'); - } - } - - // This should never happen - if (!$this->style) - { - trigger_error($this->language->lang('NO_STYLE_DATA', $this->data['user_style'], $this->data['user_id']), E_USER_ERROR); - } - - // Now parse the cfg file and cache it - $parsed_items = $cache->obtain_cfg_items($this->style); - - $check_for = array( - 'pagination_sep' => (string) ', ' - ); - - foreach ($check_for as $key => $default_value) - { - $this->style[$key] = (isset($parsed_items[$key])) ? $parsed_items[$key] : $default_value; - settype($this->style[$key], gettype($default_value)); - - if (is_string($default_value)) - { - $this->style[$key] = htmlspecialchars($this->style[$key]); - } - } - - $template->set_style(); - - $this->img_lang = $this->lang_name; - - // Call phpbb_user_session_handler() in case external application want to "bend" some variables or replace classes... - // After calling it we continue script execution... - phpbb_user_session_handler(); - - /** - * Execute code at the end of user setup - * - * @event core.user_setup_after - * @since 3.1.6-RC1 - */ - $phpbb_dispatcher->dispatch('core.user_setup_after'); - - // If this function got called from the error handler we are finished here. - if (defined('IN_ERROR_HANDLER')) - { - return; - } - - // Disable board if the install/ directory is still present - // For the brave development army we do not care about this, else we need to comment out this every time we develop locally - if (!$phpbb_container->getParameter('allow_install_dir') && !defined('ADMIN_START') && !defined('IN_INSTALL') && !defined('IN_LOGIN') && file_exists($phpbb_root_path . 'install') && !is_file($phpbb_root_path . 'install')) - { - // Adjust the message slightly according to the permissions - if ($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) - { - $message = 'REMOVE_INSTALL'; - } - else - { - $message = (!empty($config['board_disable_msg'])) ? $config['board_disable_msg'] : 'BOARD_DISABLE'; - } - trigger_error($message); - } - - // Is board disabled and user not an admin or moderator? - if ($config['board_disable'] && !defined('IN_INSTALL') && !defined('IN_LOGIN') && !defined('SKIP_CHECK_DISABLED') && !$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_')) - { - if ($this->data['is_bot']) - { - send_status_line(503, 'Service Unavailable'); - } - - $message = (!empty($config['board_disable_msg'])) ? $config['board_disable_msg'] : 'BOARD_DISABLE'; - trigger_error($message); - } - - // Is load exceeded? - if ($config['limit_load'] && $this->load !== false) - { - if ($this->load > floatval($config['limit_load']) && !defined('IN_LOGIN') && !defined('IN_ADMIN')) - { - // Set board disabled to true to let the admins/mods get the proper notification - $config['board_disable'] = '1'; - - if (!$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_')) - { - if ($this->data['is_bot']) - { - send_status_line(503, 'Service Unavailable'); - } - trigger_error('BOARD_UNAVAILABLE'); - } - } - } - - if (isset($this->data['session_viewonline'])) - { - // Make sure the user is able to hide his session - if (!$this->data['session_viewonline']) - { - // Reset online status if not allowed to hide the session... - if (!$auth->acl_get('u_hideonline')) - { - $sql = 'UPDATE ' . SESSIONS_TABLE . ' - SET session_viewonline = 1 - WHERE session_user_id = ' . $this->data['user_id']; - $db->sql_query($sql); - $this->data['session_viewonline'] = 1; - } - } - else if (!$this->data['user_allow_viewonline']) - { - // the user wants to hide and is allowed to -> cloaking device on. - if ($auth->acl_get('u_hideonline')) - { - $sql = 'UPDATE ' . SESSIONS_TABLE . ' - SET session_viewonline = 0 - WHERE session_user_id = ' . $this->data['user_id']; - $db->sql_query($sql); - $this->data['session_viewonline'] = 0; - } - } - } - - // Does the user need to change their password? If so, redirect to the - // ucp profile reg_details page ... of course do not redirect if we're already in the ucp - if (!defined('IN_ADMIN') && !defined('ADMIN_START') && $config['chg_passforce'] && !empty($this->data['is_registered']) && $auth->acl_get('u_chgpasswd') && $this->data['user_passchg'] < time() - ($config['chg_passforce'] * 86400)) - { - if (strpos($this->page['query_string'], 'mode=reg_details') === false && $this->page['page_name'] != "ucp.$phpEx") - { - redirect(append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=profile&mode=reg_details')); - } - } - - $this->is_setup_flag = true; - - return; - } - - /** - * More advanced language substitution - * Function to mimic sprintf() with the possibility of using phpBB's language system to substitute nullar/singular/plural forms. - * Params are the language key and the parameters to be substituted. - * This function/functionality is inspired by SHS` and Ashe. - * - * Example call: $user->lang('NUM_POSTS_IN_QUEUE', 1); - * - * If the first parameter is an array, the elements are used as keys and subkeys to get the language entry: - * Example: $user->lang(array('datetime', 'AGO'), 1) uses $user->lang['datetime']['AGO'] as language entry. - * - * @deprecated 3.2.0-dev (To be removed 4.0.0) - */ - function lang() - { - $args = func_get_args(); - return call_user_func_array(array($this->language, 'lang'), $args); - } - - /** - * Determine which plural form we should use. - * For some languages this is not as simple as for English. - * - * @param $number int|float The number we want to get the plural case for. Float numbers are floored. - * @param $force_rule mixed False to use the plural rule of the language package - * or an integer to force a certain plural rule - * @return int|bool The plural-case we need to use for the number plural-rule combination, false if $force_rule - * was invalid. - * - * @deprecated: 3.2.0-dev (To be removed: 4.0.0) - */ - function get_plural_form($number, $force_rule = false) - { - return $this->language->get_plural_form($number, $force_rule); - } - - /** - * Add Language Items - use_db and use_help are assigned where needed (only use them to force inclusion) - * - * @param mixed $lang_set specifies the language entries to include - * @param bool $use_db internal variable for recursion, do not use @deprecated 3.2.0-dev (To be removed: 4.0.0) - * @param bool $use_help internal variable for recursion, do not use @deprecated 3.2.0-dev (To be removed: 4.0.0) - * @param string $ext_name The extension to load language from, or empty for core files - * - * Examples: - * - * $lang_set = array('posting', 'help' => 'faq'); - * $lang_set = array('posting', 'viewtopic', 'help' => array('bbcode', 'faq')) - * $lang_set = array(array('posting', 'viewtopic'), 'help' => array('bbcode', 'faq')) - * $lang_set = 'posting' - * $lang_set = array('help' => 'faq', 'db' => array('help:faq', 'posting')) - * - * - * Note: $use_db and $use_help should be removed. The old function was kept for BC purposes, - * so the BC logic is handled here. - * - * @deprecated: 3.2.0-dev (To be removed: 4.0.0) - */ - function add_lang($lang_set, $use_db = false, $use_help = false, $ext_name = '') - { - if (is_array($lang_set)) - { - foreach ($lang_set as $key => $lang_file) - { - // Please do not delete this line. - // We have to force the type here, else [array] language inclusion will not work - $key = (string) $key; - - if ($key == 'db') - { - // This is never used - $this->add_lang($lang_file, true, $use_help, $ext_name); - } - else if ($key == 'help') - { - $this->add_lang($lang_file, $use_db, true, $ext_name); - } - else if (!is_array($lang_file)) - { - $this->set_lang($lang_file, $use_help, $ext_name); - } - else - { - $this->add_lang($lang_file, $use_db, $use_help, $ext_name); - } - } - unset($lang_set); - } - else if ($lang_set) - { - $this->set_lang($lang_set, $use_help, $ext_name); - } - } - - /** - * BC function for loading language files - * - * @deprecated 3.2.0-dev (To be removed: 4.0.0) - */ - private function set_lang($lang_set, $use_help, $ext_name) - { - if (empty($ext_name)) - { - $ext_name = null; - } - - if ($use_help && strpos($lang_set, '/') !== false) - { - $component = dirname($lang_set) . '/help_' . basename($lang_set); - - if ($component[0] === '/') - { - $component = substr($component, 1); - } - } - else - { - $component = (($use_help) ? 'help_' : '') . $lang_set; - } - - $this->language->add_lang($component, $ext_name); - } - - /** - * Add Language Items from an extension - use_db and use_help are assigned where needed (only use them to force inclusion) - * - * @param string $ext_name The extension to load language from, or empty for core files - * @param mixed $lang_set specifies the language entries to include - * @param bool $use_db internal variable for recursion, do not use - * @param bool $use_help internal variable for recursion, do not use - * - * Note: $use_db and $use_help should be removed. Kept for BC purposes. - * - * @deprecated: 3.2.0-dev (To be removed: 4.0.0) - */ - function add_lang_ext($ext_name, $lang_set, $use_db = false, $use_help = false) - { - if ($ext_name === '/') - { - $ext_name = ''; - } - - $this->add_lang($lang_set, $use_db, $use_help, $ext_name); - } - - /** - * Format user date - * - * @param int $gmepoch unix timestamp - * @param string $format date format in date() notation. | used to indicate relative dates, for example |d m Y|, h:i is translated to Today, h:i. - * @param bool $forcedate force non-relative date format. - * - * @return mixed translated date - */ - function format_date($gmepoch, $format = false, $forcedate = false) - { - global $phpbb_dispatcher; - static $utc; - - if (!isset($utc)) - { - $utc = new \DateTimeZone('UTC'); - } - - $format_date_override = false; - $function_arguments = func_get_args(); - /** - * Execute code and/or override format_date() - * - * To override the format_date() function generated value - * set $format_date_override to new return value - * - * @event core.user_format_date_override - * @var DateTimeZone utc Is DateTimeZone in UTC - * @var array function_arguments is array comprising a function's argument list - * @var string format_date_override Shall we return custom format (string) or not (false) - * @since 3.2.1-RC1 - */ - $vars = array('utc', 'function_arguments', 'format_date_override'); - extract($phpbb_dispatcher->trigger_event('core.user_format_date_override', compact($vars))); - - if (!$format_date_override) - { - $time = new $this->datetime($this, '@' . (int) $gmepoch, $utc); - $time->setTimezone($this->timezone); - - return $time->format($format, $forcedate); - } - else - { - return $format_date_override; - } - } - - /** - * Create a \phpbb\datetime object in the context of the current user - * - * @since 3.1 - * @param string $time String in a format accepted by strtotime(). - * @param DateTimeZone $timezone Time zone of the time. - * @return \phpbb\datetime Date time object linked to the current users locale - */ - public function create_datetime($time = 'now', \DateTimeZone $timezone = null) - { - $timezone = $timezone ?: $this->timezone; - return new $this->datetime($this, $time, $timezone); - } - - /** - * Get the UNIX timestamp for a datetime in the users timezone, so we can store it in the database. - * - * @param string $format Format of the entered date/time - * @param string $time Date/time with the timezone applied - * @param DateTimeZone $timezone Timezone of the date/time, falls back to timezone of current user - * @return int Returns the unix timestamp - */ - public function get_timestamp_from_format($format, $time, \DateTimeZone $timezone = null) - { - $timezone = $timezone ?: $this->timezone; - $date = \DateTime::createFromFormat($format, $time, $timezone); - return ($date !== false) ? $date->format('U') : false; - } - - /** - * Get language id currently used by the user - */ - function get_iso_lang_id() - { - global $config, $db; - - if (!empty($this->lang_id)) - { - return $this->lang_id; - } - - if (!$this->lang_name) - { - $this->lang_name = $config['default_lang']; - } - - $sql = 'SELECT lang_id - FROM ' . LANG_TABLE . " - WHERE lang_iso = '" . $db->sql_escape($this->lang_name) . "'"; - $result = $db->sql_query($sql); - $this->lang_id = (int) $db->sql_fetchfield('lang_id'); - $db->sql_freeresult($result); - - return $this->lang_id; - } - - /** - * Get users profile fields - */ - function get_profile_fields($user_id) - { - global $db; - - if (isset($this->profile_fields)) - { - return; - } - - $sql = 'SELECT * - FROM ' . PROFILE_FIELDS_DATA_TABLE . " - WHERE user_id = $user_id"; - $result = $db->sql_query_limit($sql, 1); - $this->profile_fields = (!($row = $db->sql_fetchrow($result))) ? array() : $row; - $db->sql_freeresult($result); - } - - /** - * Specify/Get image - */ - function img($img, $alt = '') - { - $title = ''; - - if ($alt) - { - $alt = $this->language->lang($alt); - $title = ' title="' . $alt . '"'; - } - return '' . $alt . ''; - } - - /** - * Get option bit field from user options. - * - * @param int $key option key, as defined in $keyoptions property. - * @param int $data bit field value to use, or false to use $this->data['user_options'] - * @return bool true if the option is set in the bit field, false otherwise - */ - function optionget($key, $data = false) - { - $var = ($data !== false) ? $data : $this->data['user_options']; - return phpbb_optionget($this->keyoptions[$key], $var); - } - - /** - * Set option bit field for user options. - * - * @param int $key Option key, as defined in $keyoptions property. - * @param bool $value True to set the option, false to clear the option. - * @param int $data Current bit field value, or false to use $this->data['user_options'] - * @return int|bool If $data is false, the bit field is modified and - * written back to $this->data['user_options'], and - * return value is true if the bit field changed and - * false otherwise. If $data is not false, the new - * bitfield value is returned. - */ - function optionset($key, $value, $data = false) - { - $var = ($data !== false) ? $data : $this->data['user_options']; - - $new_var = phpbb_optionset($this->keyoptions[$key], $value, $var); - - if ($data === false) - { - if ($new_var != $var) - { - $this->data['user_options'] = $new_var; - return true; - } - else - { - return false; - } - } - else - { - return $new_var; - } - } - - /** - * Function to make the user leave the NEWLY_REGISTERED system group. - * @access public - */ - function leave_newly_registered() - { - if (empty($this->data['user_new'])) - { - return false; - } - - if (!function_exists('remove_newly_registered')) - { - global $phpbb_root_path, $phpEx; - - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - } - if ($group = remove_newly_registered($this->data['user_id'], $this->data)) - { - $this->data['group_id'] = $group; - - } - $this->data['user_permissions'] = ''; - $this->data['user_new'] = 0; - - return true; - } - - /** - * Returns all password protected forum ids the user is currently NOT authenticated for. - * - * @return array Array of forum ids - * @access public - */ - function get_passworded_forums() - { - global $db; - - $sql = 'SELECT f.forum_id, fa.user_id - FROM ' . FORUMS_TABLE . ' f - LEFT JOIN ' . FORUMS_ACCESS_TABLE . " fa - ON (fa.forum_id = f.forum_id - AND fa.session_id = '" . $db->sql_escape($this->session_id) . "') - WHERE f.forum_password <> ''"; - $result = $db->sql_query($sql); - - $forum_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $forum_id = (int) $row['forum_id']; - - if ($row['user_id'] != $this->data['user_id']) - { - $forum_ids[$forum_id] = $forum_id; - } - } - $db->sql_freeresult($result); - - return $forum_ids; - } -} diff --git a/install/update/new/phpbb/user_loader.php b/install/update/new/phpbb/user_loader.php deleted file mode 100644 index 3dacf07..0000000 --- a/install/update/new/phpbb/user_loader.php +++ /dev/null @@ -1,238 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb; - -/** -* User loader class -* -* This handles loading users from the database and -* storing in them in a temporary cache so we do not -* have to query the same user multiple times in -* different services. -*/ -class user_loader -{ - /** @var \phpbb\db\driver\driver_interface */ - protected $db = null; - - /** @var string */ - protected $phpbb_root_path = null; - - /** @var string */ - protected $php_ext = null; - - /** @var string */ - protected $users_table = null; - - /** - * Users loaded from the DB - * - * @var array Array of user data that we've loaded from the DB - */ - protected $users = array(); - - /** - * User loader constructor - * - * @param \phpbb\db\driver\driver_interface $db A database connection - * @param string $phpbb_root_path Path to the phpbb includes directory. - * @param string $php_ext php file extension - * @param string $users_table The name of the database table (phpbb_users) - */ - public function __construct(\phpbb\db\driver\driver_interface $db, $phpbb_root_path, $php_ext, $users_table) - { - $this->db = $db; - - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - - $this->users_table = $users_table; - } - - /** - * Load user helper - * - * @param array $user_ids - * @param array $ignore_types user types to ignore - */ - public function load_users(array $user_ids, array $ignore_types = array()) - { - $user_ids[] = ANONYMOUS; - - // Make user_ids unique and convert to integer. - $user_ids = array_map('intval', array_unique($user_ids)); - - // Do not load users we already have in $this->users - $user_ids = array_diff($user_ids, array_keys($this->users)); - - if (count($user_ids)) - { - $sql = 'SELECT * - FROM ' . $this->users_table . ' - WHERE ' . $this->db->sql_in_set('user_id', $user_ids) . ' - AND ' . $this->db->sql_in_set('user_type', $ignore_types, true, true); - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - $this->users[$row['user_id']] = $row; - } - $this->db->sql_freeresult($result); - } - } - - /** - * Load a user by username - * - * Stores the full data in the user cache so they do not need to be loaded again - * Returns the user id so you may use get_user() from the returned value - * - * @param string $username Raw username to load (will be cleaned) - * @return int User ID for the username - */ - public function load_user_by_username($username) - { - $sql = 'SELECT * - FROM ' . $this->users_table . " - WHERE username_clean = '" . $this->db->sql_escape(utf8_clean_string($username)) . "'"; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if ($row) - { - $this->users[$row['user_id']] = $row; - - return $row['user_id']; - } - - return ANONYMOUS; - } - - /** - * Get a user row from our users cache - * - * @param int $user_id User ID of the user you want to retrieve - * @param bool $query Should we query the database if this user has not yet been loaded? - * Typically this should be left as false and you should make sure - * you load users ahead of time with load_users() - * @return array|bool Row from the database of the user or Anonymous if the user wasn't loaded/does not exist - * or bool False if the anonymous user was not loaded - */ - public function get_user($user_id, $query = false) - { - if (isset($this->users[$user_id])) - { - return $this->users[$user_id]; - } - // Query them if we must (if ANONYMOUS is sent as the user_id and we have not loaded Anonymous yet, we must load Anonymous as a last resort) - else if ($query || $user_id == ANONYMOUS) - { - $this->load_users(array($user_id)); - - return $this->get_user($user_id); - } - - return $this->get_user(ANONYMOUS); - } - - /** - * Get username - * - * @param int $user_id User ID of the user you want to retrieve the username for - * @param string $mode The mode to load (same as get_username_string). One of the following: - * profile (for getting an url to the profile) - * username (for obtaining the username) - * colour (for obtaining the user colour) - * full (for obtaining a html string representing a coloured link to the users profile) - * no_profile (the same as full but forcing no profile link) - * @param string $guest_username Optional parameter to specify the guest username. It will be used in favor of the GUEST language variable then. - * @param string $custom_profile_url Optional parameter to specify a profile url. The user id get appended to this url as &u={user_id} - * @param bool $query Should we query the database if this user has not yet been loaded? - * Typically this should be left as false and you should make sure - * you load users ahead of time with load_users() - * @return string - */ - public function get_username($user_id, $mode, $guest_username = false, $custom_profile_url = false, $query = false) - { - if (!($user = $this->get_user($user_id, $query))) - { - return ''; - } - - return get_username_string($mode, $user['user_id'], $user['username'], $user['user_colour'], $guest_username, $custom_profile_url); - } - - /** - * Get avatar - * - * @param int $user_id User ID of the user you want to retrieve the avatar for - * @param bool $query Should we query the database if this user has not yet been loaded? - * Typically this should be left as false and you should make sure - * you load users ahead of time with load_users() - * @param bool @lazy If true, will be lazy loaded (requires JS) - * @return string - */ - public function get_avatar($user_id, $query = false, $lazy = false) - { - if (!($user = $this->get_user($user_id, $query))) - { - return ''; - } - - $row = array( - 'avatar' => $user['user_avatar'], - 'avatar_type' => $user['user_avatar_type'], - 'avatar_width' => $user['user_avatar_width'], - 'avatar_height' => $user['user_avatar_height'], - ); - - return phpbb_get_avatar($row, 'USER_AVATAR', false, $lazy); - } - - /** - * Get rank - * - * @param int $user_id User ID of the user you want to retrieve the rank for - * @param bool $query Should we query the database if this user has not yet been loaded? - * Typically this should be left as false and you should make sure - * you load users ahead of time with load_users() - * @return array Array with keys 'rank_title', 'rank_img', and 'rank_img_src' - */ - public function get_rank($user_id, $query = false) - { - if (!($user = $this->get_user($user_id, $query))) - { - return ''; - } - - if (!function_exists('phpbb_get_user_rank')) - { - include($this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext); - } - - $rank = array( - 'rank_title', - 'rank_img', - 'rank_img_src', - ); - - $user_rank_data = phpbb_get_user_rank($user, (($user['user_id'] == ANONYMOUS) ? false : $user['user_posts'])); - $rank['rank_title'] = $user_rank_data['title']; - $rank['rank_img'] = $user_rank_data['img']; - $rank['rank_img_src'] = $user_rank_data['img_src']; - - return $rank; - } -} diff --git a/install/update/new/posting.php b/install/update/new/posting.php deleted file mode 100644 index c4042e4..0000000 --- a/install/update/new/posting.php +++ /dev/null @@ -1,2041 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -define('IN_PHPBB', true); -$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); -include($phpbb_root_path . 'common.' . $phpEx); -include($phpbb_root_path . 'includes/functions_posting.' . $phpEx); -include($phpbb_root_path . 'includes/functions_display.' . $phpEx); -include($phpbb_root_path . 'includes/message_parser.' . $phpEx); - - -// Start session management -$user->session_begin(); -$auth->acl($user->data); - - -// Grab only parameters needed here -$post_id = $request->variable('p', 0); -$topic_id = $request->variable('t', 0); -$forum_id = $request->variable('f', 0); -$draft_id = $request->variable('d', 0); - -$preview = (isset($_POST['preview'])) ? true : false; -$save = (isset($_POST['save'])) ? true : false; -$load = (isset($_POST['load'])) ? true : false; -$confirm = $request->is_set_post('confirm'); -$cancel = (isset($_POST['cancel']) && !isset($_POST['save'])) ? true : false; - -$refresh = (isset($_POST['add_file']) || isset($_POST['delete_file']) || $save || $load || $preview); -$submit = $request->is_set_post('post') && !$refresh && !$preview; -$mode = $request->variable('mode', ''); - -// If the user is not allowed to delete the post, we try to soft delete it, so we overwrite the mode here. -if ($mode == 'delete' && (($confirm && !$request->is_set_post('delete_permanent')) || !$auth->acl_gets('f_delete', 'm_delete', $forum_id))) -{ - $mode = 'soft_delete'; -} - -$error = $post_data = array(); -$current_time = time(); - -/** -* This event allows you to alter the above parameters, such as submit and mode -* -* Note: $refresh must be true to retain previously submitted form data. -* -* Note: The template class will not work properly until $user->setup() is -* called, and it has not been called yet. Extensions requiring template -* assignments should use an event that comes later in this file. -* -* @event core.modify_posting_parameters -* @var int post_id ID of the post -* @var int topic_id ID of the topic -* @var int forum_id ID of the forum -* @var int draft_id ID of the draft -* @var bool submit Whether or not the form has been submitted -* @var bool preview Whether or not the post is being previewed -* @var bool save Whether or not a draft is being saved -* @var bool load Whether or not a draft is being loaded -* @var bool cancel Whether or not to cancel the form (returns to -* viewtopic or viewforum depending on if the user -* is posting a new topic or editing a post) -* @var bool refresh Whether or not to retain previously submitted data -* @var string mode What action to take if the form has been submitted -* post|reply|quote|edit|delete|bump|smilies|popup -* @var array error Any error strings; a non-empty array aborts -* form submission. -* NOTE: Should be actual language strings, NOT -* language keys. -* @since 3.1.0-a1 -* @changed 3.1.2-RC1 Removed 'delete' var as it does not exist -* @changed 3.2.4-RC1 Remove unused 'lastclick' var -*/ -$vars = array( - 'post_id', - 'topic_id', - 'forum_id', - 'draft_id', - 'submit', - 'preview', - 'save', - 'load', - 'cancel', - 'refresh', - 'mode', - 'error', -); -extract($phpbb_dispatcher->trigger_event('core.modify_posting_parameters', compact($vars))); - -// Was cancel pressed? If so then redirect to the appropriate page -if ($cancel) -{ - $f = ($forum_id) ? 'f=' . $forum_id . '&' : ''; - $redirect = ($post_id) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", $f . 'p=' . $post_id) . '#p' . $post_id : (($topic_id) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", $f . 't=' . $topic_id) : (($forum_id) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id) : append_sid("{$phpbb_root_path}index.$phpEx"))); - redirect($redirect); -} - -if (in_array($mode, array('post', 'reply', 'quote', 'edit', 'delete')) && !$forum_id) -{ - trigger_error('NO_FORUM'); -} - -/* @var $phpbb_content_visibility \phpbb\content_visibility */ -$phpbb_content_visibility = $phpbb_container->get('content.visibility'); - -// We need to know some basic information in all cases before we do anything. -switch ($mode) -{ - case 'post': - $sql = 'SELECT * - FROM ' . FORUMS_TABLE . " - WHERE forum_id = $forum_id"; - break; - - case 'bump': - case 'reply': - if (!$topic_id) - { - trigger_error('NO_TOPIC'); - } - - // Force forum id - $sql = 'SELECT forum_id - FROM ' . TOPICS_TABLE . ' - WHERE topic_id = ' . $topic_id; - $result = $db->sql_query($sql); - $f_id = (int) $db->sql_fetchfield('forum_id'); - $db->sql_freeresult($result); - - $forum_id = (!$f_id) ? $forum_id : $f_id; - - $sql = 'SELECT f.*, t.* - FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f - WHERE t.topic_id = $topic_id - AND f.forum_id = t.forum_id - AND " . $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.'); - break; - - case 'quote': - case 'edit': - case 'delete': - case 'soft_delete': - if (!$post_id) - { - $user->setup('posting'); - trigger_error('NO_POST'); - } - - // Force forum id - $sql = 'SELECT forum_id - FROM ' . POSTS_TABLE . ' - WHERE post_id = ' . $post_id; - $result = $db->sql_query($sql); - $f_id = (int) $db->sql_fetchfield('forum_id'); - $db->sql_freeresult($result); - - $forum_id = (!$f_id) ? $forum_id : $f_id; - - $sql = 'SELECT f.*, t.*, p.*, u.username, u.username_clean, u.user_sig, u.user_sig_bbcode_uid, u.user_sig_bbcode_bitfield - FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . ' f, ' . USERS_TABLE . " u - WHERE p.post_id = $post_id - AND t.topic_id = p.topic_id - AND u.user_id = p.poster_id - AND f.forum_id = t.forum_id - AND " . $phpbb_content_visibility->get_visibility_sql('post', $forum_id, 'p.'); - break; - - case 'smilies': - $sql = ''; - generate_smilies('window', $forum_id); - break; - - case 'popup': - if ($forum_id) - { - $sql = 'SELECT forum_style - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . $forum_id; - } - else - { - phpbb_upload_popup(); - return; - } - break; - - default: - $sql = ''; - break; -} - -if (!$sql) -{ - $user->setup('posting'); - trigger_error('NO_POST_MODE'); -} - -$result = $db->sql_query($sql); -$post_data = $db->sql_fetchrow($result); -$db->sql_freeresult($result); - -if (!$post_data) -{ - if (!($mode == 'post' || $mode == 'bump' || $mode == 'reply')) - { - $user->setup('posting'); - } - trigger_error(($mode == 'post' || $mode == 'bump' || $mode == 'reply') ? 'NO_TOPIC' : 'NO_POST'); -} - -/** -* This event allows you to bypass reply/quote test of an unapproved post. -* -* @event core.posting_modify_row_data -* @var array post_data All post data from database -* @var string mode What action to take if the form has been submitted -* post|reply|quote|edit|delete|bump|smilies|popup -* @var int topic_id ID of the topic -* @var int forum_id ID of the forum -* @since 3.2.8-RC1 -*/ -$vars = array( - 'post_data', - 'mode', - 'topic_id', - 'forum_id', -); -extract($phpbb_dispatcher->trigger_event('core.posting_modify_row_data', compact($vars))); - -// Not able to reply to unapproved posts/topics -// TODO: add more descriptive language key -if ($auth->acl_get('m_approve', $forum_id) && ((($mode == 'reply' || $mode == 'bump') && $post_data['topic_visibility'] != ITEM_APPROVED) || ($mode == 'quote' && $post_data['post_visibility'] != ITEM_APPROVED))) -{ - trigger_error(($mode == 'reply' || $mode == 'bump') ? 'TOPIC_UNAPPROVED' : 'POST_UNAPPROVED'); -} - -if ($mode == 'popup') -{ - phpbb_upload_popup($post_data['forum_style']); - return; -} - -$user->setup(array('posting', 'mcp', 'viewtopic'), $post_data['forum_style']); - -// Use post_row values in favor of submitted ones... -$forum_id = (!empty($post_data['forum_id'])) ? (int) $post_data['forum_id'] : (int) $forum_id; -$topic_id = (!empty($post_data['topic_id'])) ? (int) $post_data['topic_id'] : (int) $topic_id; -$post_id = (!empty($post_data['post_id'])) ? (int) $post_data['post_id'] : (int) $post_id; - -// Need to login to passworded forum first? -if ($post_data['forum_password']) -{ - login_forum_box(array( - 'forum_id' => $forum_id, - 'forum_name' => $post_data['forum_name'], - 'forum_password' => $post_data['forum_password']) - ); -} - -// Check permissions -if ($user->data['is_bot']) -{ - redirect(append_sid("{$phpbb_root_path}index.$phpEx")); -} - -// Is the user able to read within this forum? -if (!$auth->acl_get('f_read', $forum_id)) -{ - if ($user->data['user_id'] != ANONYMOUS) - { - trigger_error('USER_CANNOT_READ'); - } - $message = $user->lang['LOGIN_EXPLAIN_POST']; - - if ($request->is_ajax()) - { - $json = new phpbb\json_response(); - $json->send(array( - 'title' => $user->lang['INFORMATION'], - 'message' => $message, - )); - } - - login_box('', $message); -} - -// Permission to do the action asked? -$is_authed = false; - -switch ($mode) -{ - case 'post': - if ($auth->acl_get('f_post', $forum_id)) - { - $is_authed = true; - } - break; - - case 'bump': - if ($auth->acl_get('f_bump', $forum_id)) - { - $is_authed = true; - } - break; - - case 'quote': - - $post_data['post_edit_locked'] = 0; - - // no break; - - case 'reply': - if ($auth->acl_get('f_reply', $forum_id)) - { - $is_authed = true; - } - break; - - case 'edit': - if ($user->data['is_registered'] && $auth->acl_gets('f_edit', 'm_edit', $forum_id)) - { - $is_authed = true; - } - break; - - case 'delete': - if ($user->data['is_registered'] && ($auth->acl_get('m_delete', $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)))) - { - $is_authed = true; - } - - // no break; - - case 'soft_delete': - if (!$is_authed && $user->data['is_registered'] && $phpbb_content_visibility->can_soft_delete($forum_id, $post_data['poster_id'], $post_data['post_edit_locked'])) - { - // Fall back to soft_delete if we have no permissions to delete posts but to soft delete them - $is_authed = true; - $mode = 'soft_delete'; - } - break; -} -/** -* This event allows you to do extra auth checks and verify if the user -* has the required permissions -* -* Extensions should only change the error and is_authed variables. -* -* @event core.modify_posting_auth -* @var int post_id ID of the post -* @var int topic_id ID of the topic -* @var int forum_id ID of the forum -* @var int draft_id ID of the draft -* @var bool submit Whether or not the form has been submitted -* @var bool preview Whether or not the post is being previewed -* @var bool save Whether or not a draft is being saved -* @var bool load Whether or not a draft is being loaded -* @var bool refresh Whether or not to retain previously submitted data -* @var string mode What action to take if the form has been submitted -* post|reply|quote|edit|delete|bump|smilies|popup -* @var array error Any error strings; a non-empty array aborts -* form submission. -* NOTE: Should be actual language strings, NOT -* language keys. -* @var bool is_authed Does the user have the required permissions? -* @var array post_data All post data from database -* @since 3.1.3-RC1 -* @changed 3.1.10-RC1 Added post_data -* @changed 3.2.4-RC1 Remove unused 'lastclick' var -*/ -$vars = array( - 'post_id', - 'topic_id', - 'forum_id', - 'draft_id', - 'submit', - 'preview', - 'save', - 'load', - 'refresh', - 'mode', - 'error', - 'is_authed', - 'post_data', -); -extract($phpbb_dispatcher->trigger_event('core.modify_posting_auth', compact($vars))); - -if (!$is_authed || !empty($error)) -{ - $check_auth = ($mode == 'quote') ? 'reply' : (($mode == 'soft_delete') ? 'delete' : $mode); - - if ($user->data['is_registered']) - { - trigger_error(empty($error) ? 'USER_CANNOT_' . strtoupper($check_auth) : implode('
', $error)); - } - $message = $user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)]; - - if ($request->is_ajax()) - { - $json = new phpbb\json_response(); - $json->send(array( - 'title' => $user->lang['INFORMATION'], - 'message' => $message, - )); - } - - login_box('', $message); -} - -if ($config['enable_post_confirm'] && !$user->data['is_registered']) -{ - $captcha = $phpbb_container->get('captcha.factory')->get_instance($config['captcha_plugin']); - $captcha->init(CONFIRM_POST); -} - -// Is the user able to post within this forum? -if ($post_data['forum_type'] != FORUM_POST && in_array($mode, array('post', 'bump', 'quote', 'reply'))) -{ - trigger_error('USER_CANNOT_FORUM_POST'); -} - -// Forum/Topic locked? -if (($post_data['forum_status'] == ITEM_LOCKED || (isset($post_data['topic_status']) && $post_data['topic_status'] == ITEM_LOCKED)) && !$auth->acl_get('m_edit', $forum_id)) -{ - trigger_error(($post_data['forum_status'] == ITEM_LOCKED) ? 'FORUM_LOCKED' : 'TOPIC_LOCKED'); -} - -// Can we edit this post ... if we're a moderator with rights then always yes -// else it depends on editing times, lock status and if we're the correct user -if ($mode == 'edit' && !$auth->acl_get('m_edit', $forum_id)) -{ - $force_edit_allowed = false; - - $s_cannot_edit = $user->data['user_id'] != $post_data['poster_id']; - $s_cannot_edit_time = $config['edit_time'] && $post_data['post_time'] <= time() - ($config['edit_time'] * 60); - $s_cannot_edit_locked = $post_data['post_edit_locked']; - - /** - * This event allows you to modify the conditions for the "cannot edit post" checks - * - * @event core.posting_modify_cannot_edit_conditions - * @var array post_data Array with post data - * @var bool force_edit_allowed Allow the user to edit the post (all permissions and conditions are ignored) - * @var bool s_cannot_edit User can not edit the post because it's not his - * @var bool s_cannot_edit_locked User can not edit the post because it's locked - * @var bool s_cannot_edit_time User can not edit the post because edit_time has passed - * @since 3.1.0-b4 - */ - $vars = array( - 'post_data', - 'force_edit_allowed', - 's_cannot_edit', - 's_cannot_edit_locked', - 's_cannot_edit_time', - ); - extract($phpbb_dispatcher->trigger_event('core.posting_modify_cannot_edit_conditions', compact($vars))); - - if (!$force_edit_allowed) - { - if ($s_cannot_edit) - { - trigger_error('USER_CANNOT_EDIT'); - } - else if ($s_cannot_edit_time) - { - trigger_error('CANNOT_EDIT_TIME'); - } - else if ($s_cannot_edit_locked) - { - trigger_error('CANNOT_EDIT_POST_LOCKED'); - } - } -} - -// Handle delete mode... -if ($mode == 'delete' || $mode == 'soft_delete') -{ - if ($mode == 'soft_delete' && $post_data['post_visibility'] == ITEM_DELETED) - { - $user->setup('posting'); - trigger_error('NO_POST'); - } - - $delete_reason = $request->variable('delete_reason', '', true); - phpbb_handle_post_delete($forum_id, $topic_id, $post_id, $post_data, ($mode == 'soft_delete' && !$request->is_set_post('delete_permanent')), $delete_reason); - return; -} - -// Handle bump mode... -if ($mode == 'bump') -{ - if ($bump_time = bump_topic_allowed($forum_id, $post_data['topic_bumped'], $post_data['topic_last_post_time'], $post_data['topic_poster'], $post_data['topic_last_poster_id']) - && check_link_hash($request->variable('hash', ''), "topic_{$post_data['topic_id']}")) - { - $meta_url = phpbb_bump_topic($forum_id, $topic_id, $post_data, $current_time); - meta_refresh(3, $meta_url); - $message = $user->lang['TOPIC_BUMPED']; - - if (!$request->is_ajax()) - { - $message .= '

' . $user->lang('VIEW_MESSAGE', '', ''); - $message .= '

' . $user->lang('RETURN_FORUM', '', ''); - } - - trigger_error($message); - } - - trigger_error('BUMP_ERROR'); -} - -// Subject length limiting to 60 characters if first post... -if ($mode == 'post' || ($mode == 'edit' && $post_data['topic_first_post_id'] == $post_data['post_id'])) -{ - $template->assign_var('S_NEW_MESSAGE', true); -} - -// Determine some vars -if (isset($post_data['poster_id']) && $post_data['poster_id'] == ANONYMOUS) -{ - $post_data['quote_username'] = (!empty($post_data['post_username'])) ? $post_data['post_username'] : $user->lang['GUEST']; -} -else -{ - $post_data['quote_username'] = isset($post_data['username']) ? $post_data['username'] : ''; -} - -$post_data['post_edit_locked'] = (isset($post_data['post_edit_locked'])) ? (int) $post_data['post_edit_locked'] : 0; -$post_data['post_subject_md5'] = (isset($post_data['post_subject']) && $mode == 'edit') ? md5($post_data['post_subject']) : ''; -$post_data['post_subject'] = (in_array($mode, array('quote', 'edit'))) ? $post_data['post_subject'] : ((isset($post_data['topic_title'])) ? $post_data['topic_title'] : ''); -$post_data['topic_time_limit'] = (isset($post_data['topic_time_limit'])) ? (($post_data['topic_time_limit']) ? (int) $post_data['topic_time_limit'] / 86400 : (int) $post_data['topic_time_limit']) : 0; -$post_data['poll_length'] = (!empty($post_data['poll_length'])) ? (int) $post_data['poll_length'] / 86400 : 0; -$post_data['poll_start'] = (!empty($post_data['poll_start'])) ? (int) $post_data['poll_start'] : 0; -$post_data['icon_id'] = (!isset($post_data['icon_id']) || in_array($mode, array('quote', 'reply'))) ? 0 : (int) $post_data['icon_id']; -$post_data['poll_options'] = array(); - -// Get Poll Data -if ($post_data['poll_start']) -{ - $sql = 'SELECT poll_option_text - FROM ' . POLL_OPTIONS_TABLE . " - WHERE topic_id = $topic_id - ORDER BY poll_option_id"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $post_data['poll_options'][] = trim($row['poll_option_text']); - } - $db->sql_freeresult($result); -} - -/** -* This event allows you to modify the post data before parsing -* -* @event core.posting_modify_post_data -* @var int forum_id ID of the forum -* @var string mode What action to take if the form has been submitted -* post|reply|quote|edit|delete|bump|smilies|popup -* @var array post_data Array with post data -* @var int post_id ID of the post -* @var int topic_id ID of the topic -* @since 3.2.2-RC1 -*/ -$vars = array( - 'forum_id', - 'mode', - 'post_data', - 'post_id', - 'topic_id', -); -extract($phpbb_dispatcher->trigger_event('core.posting_modify_post_data', compact($vars))); - -if ($mode == 'edit') -{ - $original_poll_data = array( - 'poll_title' => $post_data['poll_title'], - 'poll_length' => $post_data['poll_length'], - 'poll_max_options' => $post_data['poll_max_options'], - 'poll_option_text' => implode("\n", $post_data['poll_options']), - 'poll_start' => $post_data['poll_start'], - 'poll_last_vote' => $post_data['poll_last_vote'], - 'poll_vote_change' => $post_data['poll_vote_change'], - ); -} - -$orig_poll_options_size = count($post_data['poll_options']); - -$message_parser = new parse_message(); -/* @var $plupload \phpbb\plupload\plupload */ -$plupload = $phpbb_container->get('plupload'); - -/* @var $mimetype_guesser \phpbb\mimetype\guesser */ -$mimetype_guesser = $phpbb_container->get('mimetype.guesser'); -$message_parser->set_plupload($plupload); - -if (isset($post_data['post_text'])) -{ - $message_parser->message = &$post_data['post_text']; - unset($post_data['post_text']); -} - -// Set some default variables -$uninit = array('post_attachment' => 0, 'poster_id' => $user->data['user_id'], 'enable_magic_url' => 0, 'topic_status' => 0, 'topic_type' => POST_NORMAL, 'post_subject' => '', 'topic_title' => '', 'post_time' => 0, 'post_edit_reason' => '', 'notify_set' => 0); - -/** -* This event allows you to modify the default variables for post_data, and unset them in post_data if needed -* -* @event core.posting_modify_default_variables -* @var array post_data Array with post data -* @var array uninit Array with default vars to put into post_data, if they aren't there -* @since 3.2.5-RC1 -*/ -$vars = array( - 'post_data', - 'uninit', -); -extract($phpbb_dispatcher->trigger_event('core.posting_modify_default_variables', compact($vars))); - -foreach ($uninit as $var_name => $default_value) -{ - if (!isset($post_data[$var_name])) - { - $post_data[$var_name] = $default_value; - } -} -unset($uninit); - -// Always check if the submitted attachment data is valid and belongs to the user. -// Further down (especially in submit_post()) we do not check this again. -$message_parser->get_submitted_attachment_data($post_data['poster_id']); - -if ($post_data['post_attachment'] && !$submit && !$refresh && !$preview && $mode == 'edit') -{ - // Do not change to SELECT * - $sql = 'SELECT attach_id, is_orphan, attach_comment, real_filename, filesize - FROM ' . ATTACHMENTS_TABLE . " - WHERE post_msg_id = $post_id - AND in_message = 0 - AND is_orphan = 0 - ORDER BY attach_id DESC"; - $result = $db->sql_query($sql); - $message_parser->attachment_data = array_merge($message_parser->attachment_data, $db->sql_fetchrowset($result)); - $db->sql_freeresult($result); -} - -if ($post_data['poster_id'] == ANONYMOUS) -{ - $post_data['username'] = ($mode == 'quote' || $mode == 'edit') ? trim($post_data['post_username']) : ''; -} -else -{ - $post_data['username'] = ($mode == 'quote' || $mode == 'edit') ? trim($post_data['username']) : ''; -} - -$post_data['enable_urls'] = $post_data['enable_magic_url']; - -if ($mode != 'edit') -{ - $post_data['enable_sig'] = ($config['allow_sig'] && $user->optionget('attachsig')) ? true: false; - $post_data['enable_smilies'] = ($config['allow_smilies'] && $user->optionget('smilies')) ? true : false; - $post_data['enable_bbcode'] = ($config['allow_bbcode'] && $user->optionget('bbcode')) ? true : false; - $post_data['enable_urls'] = true; -} - -if ($mode == 'post') -{ - $post_data['topic_status'] = ($request->is_set_post('lock_topic') && $auth->acl_gets('m_lock', 'f_user_lock', $forum_id)) ? ITEM_LOCKED : ITEM_UNLOCKED; -} - -$post_data['enable_magic_url'] = $post_data['drafts'] = false; - -// User own some drafts? -if ($user->data['is_registered'] && $auth->acl_get('u_savedrafts') && ($mode == 'reply' || $mode == 'post' || $mode == 'quote')) -{ - $sql = 'SELECT draft_id - FROM ' . DRAFTS_TABLE . ' - WHERE user_id = ' . $user->data['user_id'] . - (($forum_id) ? ' AND forum_id = ' . (int) $forum_id : '') . - (($topic_id) ? ' AND topic_id = ' . (int) $topic_id : '') . - (($draft_id) ? " AND draft_id <> $draft_id" : ''); - $result = $db->sql_query_limit($sql, 1); - - if ($db->sql_fetchrow($result)) - { - $post_data['drafts'] = true; - } - $db->sql_freeresult($result); -} - -$check_value = (($post_data['enable_bbcode']+1) << 8) + (($post_data['enable_smilies']+1) << 4) + (($post_data['enable_urls']+1) << 2) + (($post_data['enable_sig']+1) << 1); - -// Check if user is watching this topic -if ($mode != 'post' && $config['allow_topic_notify'] && $user->data['is_registered']) -{ - $sql = 'SELECT topic_id - FROM ' . TOPICS_WATCH_TABLE . ' - WHERE topic_id = ' . $topic_id . ' - AND user_id = ' . $user->data['user_id']; - $result = $db->sql_query($sql); - $post_data['notify_set'] = (int) $db->sql_fetchfield('topic_id'); - $db->sql_freeresult($result); -} - -// Do we want to edit our post ? -if ($mode == 'edit' && $post_data['bbcode_uid']) -{ - $message_parser->bbcode_uid = $post_data['bbcode_uid']; -} - -// HTML, BBCode, Smilies, Images and Flash status -$bbcode_status = ($config['allow_bbcode'] && $auth->acl_get('f_bbcode', $forum_id)) ? true : false; -$smilies_status = ($config['allow_smilies'] && $auth->acl_get('f_smilies', $forum_id)) ? true : false; -$img_status = ($bbcode_status && $auth->acl_get('f_img', $forum_id)) ? true : false; -$url_status = ($config['allow_post_links']) ? true : false; -$flash_status = ($bbcode_status && $auth->acl_get('f_flash', $forum_id) && $config['allow_post_flash']) ? true : false; -$quote_status = true; - -// Save Draft -if ($save && $user->data['is_registered'] && $auth->acl_get('u_savedrafts') && ($mode == 'reply' || $mode == 'post' || $mode == 'quote')) -{ - $subject = $request->variable('subject', '', true); - $subject = (!$subject && $mode != 'post') ? $post_data['topic_title'] : $subject; - $message = $request->variable('message', '', true); - - if ($subject && $message) - { - if (confirm_box(true)) - { - $message_parser->message = $message; - $message_parser->parse($post_data['enable_bbcode'], ($config['allow_post_links']) ? $post_data['enable_urls'] : false, $post_data['enable_smilies'], $img_status, $flash_status, $quote_status, $config['allow_post_links']); - - $sql = 'INSERT INTO ' . DRAFTS_TABLE . ' ' . $db->sql_build_array('INSERT', array( - 'user_id' => (int) $user->data['user_id'], - 'topic_id' => (int) $topic_id, - 'forum_id' => (int) $forum_id, - 'save_time' => (int) $current_time, - 'draft_subject' => (string) $subject, - 'draft_message' => (string) $message_parser->message) - ); - $db->sql_query($sql); - - $meta_info = ($mode == 'post') ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id) : append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id"); - - meta_refresh(3, $meta_info); - - $message = $user->lang['DRAFT_SAVED'] . '

'; - $message .= ($mode != 'post') ? sprintf($user->lang['RETURN_TOPIC'], '', '') . '

' : ''; - $message .= sprintf($user->lang['RETURN_FORUM'], '', ''); - - trigger_error($message); - } - else - { - $s_hidden_fields = build_hidden_fields(array( - 'mode' => $mode, - 'save' => true, - 'f' => $forum_id, - 't' => $topic_id, - 'subject' => $subject, - 'message' => $message, - 'attachment_data' => $message_parser->attachment_data, - ) - ); - - $hidden_fields = array( - 'icon_id' => 0, - - 'disable_bbcode' => false, - 'disable_smilies' => false, - 'disable_magic_url' => false, - 'attach_sig' => true, - 'lock_topic' => false, - - 'topic_type' => POST_NORMAL, - 'topic_time_limit' => 0, - - 'poll_title' => '', - 'poll_option_text' => '', - 'poll_max_options' => 1, - 'poll_length' => 0, - 'poll_vote_change' => false, - ); - - foreach ($hidden_fields as $name => $default) - { - if (!isset($_POST[$name])) - { - // Don't include it, if its not available - unset($hidden_fields[$name]); - continue; - } - - if (is_bool($default)) - { - // Use the string representation - $hidden_fields[$name] = $request->variable($name, ''); - } - else - { - $hidden_fields[$name] = $request->variable($name, $default); - } - } - - $s_hidden_fields .= build_hidden_fields($hidden_fields); - - confirm_box(false, 'SAVE_DRAFT', $s_hidden_fields); - } - } - else - { - if (utf8_clean_string($subject) === '') - { - $error[] = $user->lang['EMPTY_SUBJECT']; - } - - if (utf8_clean_string($message) === '') - { - $error[] = $user->lang['TOO_FEW_CHARS']; - } - } - unset($subject, $message); -} - -// Load requested Draft -if ($draft_id && ($mode == 'reply' || $mode == 'quote' || $mode == 'post') && $user->data['is_registered'] && $auth->acl_get('u_savedrafts')) -{ - $sql = 'SELECT draft_subject, draft_message - FROM ' . DRAFTS_TABLE . " - WHERE draft_id = $draft_id - AND user_id = " . $user->data['user_id']; - $result = $db->sql_query_limit($sql, 1); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - $post_data['post_subject'] = $row['draft_subject']; - $message_parser->message = $row['draft_message']; - - $template->assign_var('S_DRAFT_LOADED', true); - } - else - { - $draft_id = 0; - } -} - -// Load draft overview -if ($load && ($mode == 'reply' || $mode == 'quote' || $mode == 'post') && $post_data['drafts']) -{ - load_drafts($topic_id, $forum_id); -} - -/** @var \phpbb\textformatter\utils_interface $bbcode_utils */ -$bbcode_utils = $phpbb_container->get('text_formatter.utils'); - -if ($submit || $preview || $refresh) -{ - $post_data['topic_cur_post_id'] = $request->variable('topic_cur_post_id', 0); - $post_data['post_subject'] = $request->variable('subject', '', true); - $message_parser->message = $request->variable('message', '', true); - - $post_data['username'] = $request->variable('username', $post_data['username'], true); - $post_data['post_edit_reason'] = ($request->variable('edit_reason', false, false, \phpbb\request\request_interface::POST) && $mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? $request->variable('edit_reason', '', true) : ''; - - $post_data['orig_topic_type'] = $post_data['topic_type']; - $post_data['topic_type'] = $request->variable('topic_type', (($mode != 'post') ? (int) $post_data['topic_type'] : POST_NORMAL)); - $post_data['topic_time_limit'] = $request->variable('topic_time_limit', (($mode != 'post') ? (int) $post_data['topic_time_limit'] : 0)); - - if ($post_data['enable_icons'] && $auth->acl_get('f_icons', $forum_id)) - { - $post_data['icon_id'] = $request->variable('icon', (int) $post_data['icon_id']); - } - - $post_data['enable_bbcode'] = (!$bbcode_status || isset($_POST['disable_bbcode'])) ? false : true; - $post_data['enable_smilies'] = (!$smilies_status || isset($_POST['disable_smilies'])) ? false : true; - $post_data['enable_urls'] = (isset($_POST['disable_magic_url'])) ? 0 : 1; - $post_data['enable_sig'] = (!$config['allow_sig'] || !$auth->acl_get('f_sigs', $forum_id) || !$auth->acl_get('u_sig')) ? false : ((isset($_POST['attach_sig']) && $user->data['is_registered']) ? true : false); - - if ($config['allow_topic_notify'] && $user->data['is_registered']) - { - $notify = (isset($_POST['notify'])) ? true : false; - } - else - { - $notify = false; - } - - $topic_lock = (isset($_POST['lock_topic'])) ? true : false; - $post_lock = (isset($_POST['lock_post'])) ? true : false; - $poll_delete = (isset($_POST['poll_delete'])) ? true : false; - - if ($submit) - { - $status_switch = (($post_data['enable_bbcode']+1) << 8) + (($post_data['enable_smilies']+1) << 4) + (($post_data['enable_urls']+1) << 2) + (($post_data['enable_sig']+1) << 1); - $status_switch = ($status_switch != $check_value); - } - else - { - $status_switch = 1; - } - - // Delete Poll - if ($poll_delete && $mode == 'edit' && count($post_data['poll_options']) && - ((!$post_data['poll_last_vote'] && $post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) || $auth->acl_get('m_delete', $forum_id))) - { - if ($submit && check_form_key('posting')) - { - $sql = 'DELETE FROM ' . POLL_OPTIONS_TABLE . " - WHERE topic_id = $topic_id"; - $db->sql_query($sql); - - $sql = 'DELETE FROM ' . POLL_VOTES_TABLE . " - WHERE topic_id = $topic_id"; - $db->sql_query($sql); - - $topic_sql = array( - 'poll_title' => '', - 'poll_start' => 0, - 'poll_length' => 0, - 'poll_last_vote' => 0, - 'poll_max_options' => 0, - 'poll_vote_change' => 0 - ); - - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $topic_sql) . " - WHERE topic_id = $topic_id"; - $db->sql_query($sql); - } - - $post_data['poll_title'] = $post_data['poll_option_text'] = ''; - $post_data['poll_vote_change'] = $post_data['poll_max_options'] = $post_data['poll_length'] = 0; - } - else - { - $post_data['poll_title'] = $request->variable('poll_title', '', true); - $post_data['poll_length'] = $request->variable('poll_length', 0); - $post_data['poll_option_text'] = $request->variable('poll_option_text', '', true); - $post_data['poll_max_options'] = $request->variable('poll_max_options', 1); - $post_data['poll_vote_change'] = ($auth->acl_get('f_votechg', $forum_id) && $auth->acl_get('f_vote', $forum_id) && isset($_POST['poll_vote_change'])) ? 1 : 0; - } - - // If replying/quoting and last post id has changed - // give user option to continue submit or return to post - // notify and show user the post made between his request and the final submit - if (($mode == 'reply' || $mode == 'quote') && $post_data['topic_cur_post_id'] && $post_data['topic_cur_post_id'] != $post_data['topic_last_post_id']) - { - // Only do so if it is allowed forum-wide - if ($post_data['forum_flags'] & FORUM_FLAG_POST_REVIEW) - { - if (topic_review($topic_id, $forum_id, 'post_review', $post_data['topic_cur_post_id'])) - { - $template->assign_var('S_POST_REVIEW', true); - } - - $submit = false; - $refresh = true; - } - } - - // Parse Attachments - before checksum is calculated - if ($message_parser->check_attachment_form_token($language, $request, 'posting')) - { - $message_parser->parse_attachments('fileupload', $mode, $forum_id, $submit, $preview, $refresh); - } - - /** - * This event allows you to modify message text before parsing - * - * @event core.posting_modify_message_text - * @var array post_data Array with post data - * @var string mode What action to take if the form is submitted - * post|reply|quote|edit|delete|bump|smilies|popup - * @var int post_id ID of the post - * @var int topic_id ID of the topic - * @var int forum_id ID of the forum - * @var bool submit Whether or not the form has been submitted - * @var bool preview Whether or not the post is being previewed - * @var bool save Whether or not a draft is being saved - * @var bool load Whether or not a draft is being loaded - * @var bool cancel Whether or not to cancel the form (returns to - * viewtopic or viewforum depending on if the user - * is posting a new topic or editing a post) - * @var bool refresh Whether or not to retain previously submitted data - * @var object message_parser The message parser object - * @var array error Array of errors - * @since 3.1.2-RC1 - * @changed 3.1.11-RC1 Added error - */ - $vars = array( - 'post_data', - 'mode', - 'post_id', - 'topic_id', - 'forum_id', - 'submit', - 'preview', - 'save', - 'load', - 'cancel', - 'refresh', - 'message_parser', - 'error', - ); - extract($phpbb_dispatcher->trigger_event('core.posting_modify_message_text', compact($vars))); - - // Grab md5 'checksum' of new message - $message_md5 = md5($message_parser->message); - - // If editing and checksum has changed we know the post was edited while we're editing - // Notify and show user the changed post - if ($mode == 'edit' && $post_data['forum_flags'] & FORUM_FLAG_POST_REVIEW) - { - $edit_post_message_checksum = $request->variable('edit_post_message_checksum', ''); - $edit_post_subject_checksum = $request->variable('edit_post_subject_checksum', ''); - - // $post_data['post_checksum'] is the checksum of the post submitted in the meantime - // $message_md5 is the checksum of the post we're about to submit - // $edit_post_message_checksum is the checksum of the post we're editing - // ... - - // We make sure nobody else made exactly the same change - // we're about to submit by also checking $message_md5 != $post_data['post_checksum'] - if ($edit_post_message_checksum !== '' && - $edit_post_message_checksum != $post_data['post_checksum'] && - $message_md5 != $post_data['post_checksum'] - || - $edit_post_subject_checksum !== '' && - $edit_post_subject_checksum != $post_data['post_subject_md5'] && - md5($post_data['post_subject']) != $post_data['post_subject_md5']) - { - if (topic_review($topic_id, $forum_id, 'post_review_edit', $post_id)) - { - $template->assign_vars(array( - 'S_POST_REVIEW' => true, - - 'L_POST_REVIEW' => $user->lang['POST_REVIEW_EDIT'], - 'L_POST_REVIEW_EXPLAIN' => $user->lang['POST_REVIEW_EDIT_EXPLAIN'], - )); - } - - $submit = false; - $refresh = true; - } - } - - // Check checksum ... don't re-parse message if the same - $update_message = ($mode != 'edit' || $message_md5 != $post_data['post_checksum'] || $status_switch || strlen($post_data['bbcode_uid']) < BBCODE_UID_LEN) ? true : false; - - // Also check if subject got updated... - $update_subject = $mode != 'edit' || ($post_data['post_subject_md5'] && $post_data['post_subject_md5'] != md5($post_data['post_subject'])); - - // Parse message - if ($update_message) - { - if (count($message_parser->warn_msg)) - { - $error[] = implode('
', $message_parser->warn_msg); - $message_parser->warn_msg = array(); - } - - if (!$preview || !empty($message_parser->message)) - { - $message_parser->parse($post_data['enable_bbcode'], ($config['allow_post_links']) ? $post_data['enable_urls'] : false, $post_data['enable_smilies'], $img_status, $flash_status, $quote_status, $config['allow_post_links']); - } - - // On a refresh we do not care about message parsing errors - if (count($message_parser->warn_msg) && $refresh && !$preview) - { - $message_parser->warn_msg = array(); - } - } - else - { - $message_parser->bbcode_bitfield = $post_data['bbcode_bitfield']; - } - - $ignore_flood = $auth->acl_get('u_ignoreflood') ? true : $auth->acl_get('f_ignoreflood', $forum_id); - if ($mode != 'edit' && !$preview && !$refresh && $config['flood_interval'] && !$ignore_flood) - { - // Flood check - $last_post_time = 0; - - if ($user->data['is_registered']) - { - $last_post_time = $user->data['user_lastpost_time']; - } - else - { - $sql = 'SELECT post_time AS last_post_time - FROM ' . POSTS_TABLE . " - WHERE poster_ip = '" . $user->ip . "' - AND post_time > " . ($current_time - $config['flood_interval']); - $result = $db->sql_query_limit($sql, 1); - if ($row = $db->sql_fetchrow($result)) - { - $last_post_time = $row['last_post_time']; - } - $db->sql_freeresult($result); - } - - if ($last_post_time && ($current_time - $last_post_time) < intval($config['flood_interval'])) - { - $error[] = $user->lang['FLOOD_ERROR']; - } - } - - // Validate username - if (($post_data['username'] && !$user->data['is_registered']) || ($mode == 'edit' && $post_data['poster_id'] == ANONYMOUS && $post_data['username'] && $post_data['post_username'] && $post_data['post_username'] != $post_data['username'])) - { - if (!function_exists('validate_username')) - { - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - } - - $user->add_lang('ucp'); - - if (($result = validate_username($post_data['username'], (!empty($post_data['post_username'])) ? $post_data['post_username'] : '')) !== false) - { - $error[] = $user->lang[$result . '_USERNAME']; - } - - if (($result = validate_string($post_data['username'], false, $config['min_name_chars'], $config['max_name_chars'])) !== false) - { - $min_max_amount = ($result == 'TOO_SHORT') ? $config['min_name_chars'] : $config['max_name_chars']; - $error[] = $user->lang('FIELD_' . $result, $min_max_amount, $user->lang['USERNAME']); - } - } - - if ($config['enable_post_confirm'] && !$user->data['is_registered'] && in_array($mode, array('quote', 'post', 'reply'))) - { - $captcha_data = array( - 'message' => $request->variable('message', '', true), - 'subject' => $request->variable('subject', '', true), - 'username' => $request->variable('username', '', true), - ); - $vc_response = $captcha->validate($captcha_data); - if ($vc_response) - { - $error[] = $vc_response; - } - } - - // check form - if (($submit || $preview) && !check_form_key('posting')) - { - $error[] = $user->lang['FORM_INVALID']; - } - - if ($submit && $mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED && !isset($_POST['soft_delete']) && $auth->acl_get('m_approve', $forum_id)) - { - $is_first_post = ($post_id == $post_data['topic_first_post_id'] || !$post_data['topic_posts_approved']); - $is_last_post = ($post_id == $post_data['topic_last_post_id'] || !$post_data['topic_posts_approved']); - $updated_post_data = $phpbb_content_visibility->set_post_visibility(ITEM_APPROVED, $post_id, $post_data['topic_id'], $post_data['forum_id'], $user->data['user_id'], time(), '', $is_first_post, $is_last_post); - - if (!empty($updated_post_data)) - { - // Update the post_data, so we don't need to refetch it. - $post_data = array_merge($post_data, $updated_post_data); - } - } - - // Parse subject - if (!$preview && !$refresh && utf8_clean_string($post_data['post_subject']) === '' && ($mode == 'post' || ($mode == 'edit' && $post_data['topic_first_post_id'] == $post_id))) - { - $error[] = $user->lang['EMPTY_SUBJECT']; - } - - /** - * Replace Emojis and other 4bit UTF-8 chars not allowed by MySQL to UCR/NCR. - * Using their Numeric Character Reference's Hexadecimal notation. - * Check the permissions for posting Emojis first. - */ - if ($auth->acl_get('u_emoji')) - { - $post_data['post_subject'] = utf8_encode_ucr($post_data['post_subject']); - } - else - { - /** - * Check for out-of-bounds characters that are currently - * not supported by utf8_bin in MySQL - */ - if (preg_match_all('/[\x{10000}-\x{10FFFF}]/u', $post_data['post_subject'], $matches)) - { - $character_list = implode('
', $matches[0]); - - $error[] = $user->lang('UNSUPPORTED_CHARACTERS_SUBJECT', $character_list); - } - } - - $post_data['poll_last_vote'] = (isset($post_data['poll_last_vote'])) ? $post_data['poll_last_vote'] : 0; - - if ($post_data['poll_option_text'] && - ($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id']/* && (!$post_data['poll_last_vote'] || $auth->acl_get('m_edit', $forum_id))*/)) - && $auth->acl_get('f_poll', $forum_id)) - { - $poll = array( - 'poll_title' => $post_data['poll_title'], - 'poll_length' => $post_data['poll_length'], - 'poll_max_options' => $post_data['poll_max_options'], - 'poll_option_text' => $post_data['poll_option_text'], - 'poll_start' => $post_data['poll_start'], - 'poll_last_vote' => $post_data['poll_last_vote'], - 'poll_vote_change' => $post_data['poll_vote_change'], - 'enable_bbcode' => $post_data['enable_bbcode'], - 'enable_urls' => $post_data['enable_urls'], - 'enable_smilies' => $post_data['enable_smilies'], - 'img_status' => $img_status - ); - - $message_parser->parse_poll($poll); - - $post_data['poll_options'] = (isset($poll['poll_options'])) ? $poll['poll_options'] : array(); - $post_data['poll_title'] = (isset($poll['poll_title'])) ? $poll['poll_title'] : ''; - - /* We reset votes, therefore also allow removing options - if ($post_data['poll_last_vote'] && ($poll['poll_options_size'] < $orig_poll_options_size)) - { - $message_parser->warn_msg[] = $user->lang['NO_DELETE_POLL_OPTIONS']; - }*/ - } - else if ($mode == 'edit' && $post_id == $post_data['topic_first_post_id'] && $auth->acl_get('f_poll', $forum_id)) - { - // The user removed all poll options, this is equal to deleting the poll. - $poll = array( - 'poll_title' => '', - 'poll_length' => 0, - 'poll_max_options' => 0, - 'poll_option_text' => '', - 'poll_start' => 0, - 'poll_last_vote' => 0, - 'poll_vote_change' => 0, - 'poll_options' => array(), - ); - - $post_data['poll_options'] = array(); - $post_data['poll_title'] = ''; - $post_data['poll_start'] = $post_data['poll_length'] = $post_data['poll_max_options'] = $post_data['poll_last_vote'] = $post_data['poll_vote_change'] = 0; - } - else if (!$auth->acl_get('f_poll', $forum_id) && ($mode == 'edit') && ($post_id == $post_data['topic_first_post_id']) && !$bbcode_utils->is_empty($original_poll_data['poll_title'])) - { - // We have a poll but the editing user is not permitted to create/edit it. - // So we just keep the original poll-data. - // Decode the poll title and options text fisrt. - $original_poll_data['poll_title'] = $bbcode_utils->unparse($original_poll_data['poll_title']); - $original_poll_data['poll_option_text'] = $bbcode_utils->unparse($original_poll_data['poll_option_text']); - $original_poll_data['poll_options'] = explode("\n", $original_poll_data['poll_option_text']); - - $poll = array_merge($original_poll_data, array( - 'enable_bbcode' => $post_data['enable_bbcode'], - 'enable_urls' => $post_data['enable_urls'], - 'enable_smilies' => $post_data['enable_smilies'], - 'img_status' => $img_status, - )); - - $message_parser->parse_poll($poll); - - $post_data['poll_options'] = (isset($poll['poll_options'])) ? $poll['poll_options'] : array(); - $post_data['poll_title'] = (isset($poll['poll_title'])) ? $poll['poll_title'] : ''; - } - else - { - $poll = array(); - } - - // Check topic type - if ($post_data['topic_type'] != POST_NORMAL && ($mode == 'post' || ($mode == 'edit' && $post_data['topic_first_post_id'] == $post_id))) - { - switch ($post_data['topic_type']) - { - case POST_GLOBAL: - $auth_option = 'f_announce_global'; - break; - - case POST_ANNOUNCE: - $auth_option = 'f_announce'; - break; - - case POST_STICKY: - $auth_option = 'f_sticky'; - break; - - default: - $auth_option = ''; - break; - } - - if ($auth_option != '' && !$auth->acl_get($auth_option, $forum_id)) - { - // There is a special case where a user edits his post whereby the topic type got changed by an admin/mod. - // Another case would be a mod not having sticky permissions for example but edit permissions. - if ($mode == 'edit') - { - // To prevent non-authed users messing around with the topic type we reset it to the original one. - $post_data['topic_type'] = $post_data['orig_topic_type']; - } - else - { - $error[] = $user->lang['CANNOT_POST_' . str_replace('F_', '', strtoupper($auth_option))]; - } - } - } - - if (count($message_parser->warn_msg)) - { - $error[] = implode('
', $message_parser->warn_msg); - } - - // DNSBL check - if ($config['check_dnsbl'] && !$refresh) - { - if (($dnsbl = $user->check_dnsbl('post')) !== false) - { - $error[] = sprintf($user->lang['IP_BLACKLISTED'], $user->ip, $dnsbl[1]); - } - } - - /** - * This event allows you to define errors before the post action is performed - * - * @event core.posting_modify_submission_errors - * @var array post_data Array with post data - * @var array poll Array with poll data from post (must be used instead of the post_data equivalent) - * @var string mode What action to take if the form is submitted - * post|reply|quote|edit|delete|bump|smilies|popup - * @var int post_id ID of the post - * @var int topic_id ID of the topic - * @var int forum_id ID of the forum - * @var bool submit Whether or not the form has been submitted - * @var array error Any error strings; a non-empty array aborts form submission. - * NOTE: Should be actual language strings, NOT language keys. - * @since 3.1.0-RC5 - * @changed 3.1.5-RC1 Added poll array to the event - * @changed 3.2.0-a1 Removed undefined page_title - */ - $vars = array( - 'post_data', - 'poll', - 'mode', - 'post_id', - 'topic_id', - 'forum_id', - 'submit', - 'error', - ); - extract($phpbb_dispatcher->trigger_event('core.posting_modify_submission_errors', compact($vars))); - - // Store message, sync counters - if (!count($error) && $submit) - { - if ($submit) - { - // Lock/Unlock Topic - $change_topic_status = $post_data['topic_status']; - $perm_lock_unlock = ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && !empty($post_data['topic_poster']) && $user->data['user_id'] == $post_data['topic_poster'] && $post_data['topic_status'] == ITEM_UNLOCKED)) ? true : false; - - if ($post_data['topic_status'] == ITEM_LOCKED && !$topic_lock && $perm_lock_unlock) - { - $change_topic_status = ITEM_UNLOCKED; - } - else if ($post_data['topic_status'] == ITEM_UNLOCKED && $topic_lock && $perm_lock_unlock) - { - $change_topic_status = ITEM_LOCKED; - } - - if ($change_topic_status != $post_data['topic_status']) - { - $sql = 'UPDATE ' . TOPICS_TABLE . " - SET topic_status = $change_topic_status - WHERE topic_id = $topic_id - AND topic_moved_id = 0"; - $db->sql_query($sql); - - $user_lock = ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $post_data['topic_poster']) ? 'USER_' : ''; - - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_' . $user_lock . (($change_topic_status == ITEM_LOCKED) ? 'LOCK' : 'UNLOCK'), false, array( - 'forum_id' => $forum_id, - 'topic_id' => $topic_id, - $post_data['topic_title'] - )); - } - - // Lock/Unlock Post Edit - if ($mode == 'edit' && $post_data['post_edit_locked'] == ITEM_LOCKED && !$post_lock && $auth->acl_get('m_edit', $forum_id)) - { - $post_data['post_edit_locked'] = ITEM_UNLOCKED; - } - else if ($mode == 'edit' && $post_data['post_edit_locked'] == ITEM_UNLOCKED && $post_lock && $auth->acl_get('m_edit', $forum_id)) - { - $post_data['post_edit_locked'] = ITEM_LOCKED; - } - - $data = array( - 'topic_title' => (empty($post_data['topic_title'])) ? $post_data['post_subject'] : $post_data['topic_title'], - 'topic_first_post_id' => (isset($post_data['topic_first_post_id'])) ? (int) $post_data['topic_first_post_id'] : 0, - 'topic_last_post_id' => (isset($post_data['topic_last_post_id'])) ? (int) $post_data['topic_last_post_id'] : 0, - 'topic_time_limit' => (int) $post_data['topic_time_limit'], - 'topic_attachment' => (isset($post_data['topic_attachment'])) ? (int) $post_data['topic_attachment'] : 0, - 'post_id' => (int) $post_id, - 'topic_id' => (int) $topic_id, - 'forum_id' => (int) $forum_id, - 'icon_id' => (int) $post_data['icon_id'], - 'poster_id' => (int) $post_data['poster_id'], - 'enable_sig' => (bool) $post_data['enable_sig'], - 'enable_bbcode' => (bool) $post_data['enable_bbcode'], - 'enable_smilies' => (bool) $post_data['enable_smilies'], - 'enable_urls' => (bool) $post_data['enable_urls'], - 'enable_indexing' => (bool) $post_data['enable_indexing'], - 'message_md5' => (string) $message_md5, - 'post_checksum' => (isset($post_data['post_checksum'])) ? (string) $post_data['post_checksum'] : '', - 'post_edit_reason' => $post_data['post_edit_reason'], - 'post_edit_user' => ($mode == 'edit') ? $user->data['user_id'] : ((isset($post_data['post_edit_user'])) ? (int) $post_data['post_edit_user'] : 0), - 'forum_parents' => $post_data['forum_parents'], - 'forum_name' => $post_data['forum_name'], - 'notify' => $notify, - 'notify_set' => $post_data['notify_set'], - 'poster_ip' => (isset($post_data['poster_ip'])) ? $post_data['poster_ip'] : $user->ip, - 'post_edit_locked' => (int) $post_data['post_edit_locked'], - 'bbcode_bitfield' => $message_parser->bbcode_bitfield, - 'bbcode_uid' => $message_parser->bbcode_uid, - 'message' => $message_parser->message, - 'attachment_data' => $message_parser->attachment_data, - 'filename_data' => $message_parser->filename_data, - 'topic_status' => $post_data['topic_status'], - - 'topic_visibility' => (isset($post_data['topic_visibility'])) ? $post_data['topic_visibility'] : false, - 'post_visibility' => (isset($post_data['post_visibility'])) ? $post_data['post_visibility'] : false, - ); - - if ($mode == 'edit') - { - $data['topic_posts_approved'] = $post_data['topic_posts_approved']; - $data['topic_posts_unapproved'] = $post_data['topic_posts_unapproved']; - $data['topic_posts_softdeleted'] = $post_data['topic_posts_softdeleted']; - } - - // Only return the username when it is either a guest posting or we are editing a post and - // the username was supplied; otherwise post_data might hold the data of the post that is - // being quoted (which could result in the username being returned being that of the quoted - // post's poster, not the poster of the current post). See: PHPBB3-11769 for more information. - $post_author_name = ((!$user->data['is_registered'] || $mode == 'edit') && $post_data['username'] !== '') ? $post_data['username'] : ''; - - /** - * This event allows you to define errors before the post action is performed - * - * @event core.posting_modify_submit_post_before - * @var array post_data Array with post data - * @var array poll Array with poll data - * @var array data Array with post data going to be stored in the database - * @var string mode What action to take if the form is submitted - * post|reply|quote|edit|delete - * @var int post_id ID of the post - * @var int topic_id ID of the topic - * @var int forum_id ID of the forum - * @var string post_author_name Author name for guest posts - * @var bool update_message Boolean if the post message was changed - * @var bool update_subject Boolean if the post subject was changed - * NOTE: Should be actual language strings, NOT language keys. - * @since 3.1.0-RC5 - * @changed 3.1.6-RC1 remove submit and error from event Submit and Error are checked previously prior to running event - * @change 3.2.0-a1 Removed undefined page_title - */ - $vars = array( - 'post_data', - 'poll', - 'data', - 'mode', - 'post_id', - 'topic_id', - 'forum_id', - 'post_author_name', - 'update_message', - 'update_subject', - ); - extract($phpbb_dispatcher->trigger_event('core.posting_modify_submit_post_before', compact($vars))); - - // The last parameter tells submit_post if search indexer has to be run - $redirect_url = submit_post($mode, $post_data['post_subject'], $post_author_name, $post_data['topic_type'], $poll, $data, $update_message, ($update_message || $update_subject) ? true : false); - - /** - * This event allows you to define errors after the post action is performed - * - * @event core.posting_modify_submit_post_after - * @var array post_data Array with post data - * @var array poll Array with poll data - * @var array data Array with post data going to be stored in the database - * @var string mode What action to take if the form is submitted - * post|reply|quote|edit|delete - * @var int post_id ID of the post - * @var int topic_id ID of the topic - * @var int forum_id ID of the forum - * @var string post_author_name Author name for guest posts - * @var bool update_message Boolean if the post message was changed - * @var bool update_subject Boolean if the post subject was changed - * @var string redirect_url URL the user is going to be redirected to - * NOTE: Should be actual language strings, NOT language keys. - * @since 3.1.0-RC5 - * @changed 3.1.6-RC1 remove submit and error from event Submit and Error are checked previously prior to running event - * @change 3.2.0-a1 Removed undefined page_title - */ - $vars = array( - 'post_data', - 'poll', - 'data', - 'mode', - 'post_id', - 'topic_id', - 'forum_id', - 'post_author_name', - 'update_message', - 'update_subject', - 'redirect_url', - ); - extract($phpbb_dispatcher->trigger_event('core.posting_modify_submit_post_after', compact($vars))); - - if ($config['enable_post_confirm'] && !$user->data['is_registered'] && (isset($captcha) && $captcha->is_solved() === true) && ($mode == 'post' || $mode == 'reply' || $mode == 'quote')) - { - $captcha->reset(); - } - - // Handle delete mode... - if ($request->is_set_post('delete') || $request->is_set_post('delete_permanent')) - { - $delete_reason = $request->variable('delete_reason', '', true); - phpbb_handle_post_delete($forum_id, $topic_id, $post_id, $post_data, !$request->is_set_post('delete_permanent'), $delete_reason); - return; - } - - // Check the permissions for post approval. - // Moderators must go through post approval like ordinary users. - if ((!$auth->acl_get('f_noapprove', $data['forum_id']) && empty($data['force_approved_state'])) || (isset($data['force_approved_state']) && !$data['force_approved_state'])) - { - meta_refresh(10, $redirect_url); - $message = ($mode == 'edit') ? $user->lang['POST_EDITED_MOD'] : $user->lang['POST_STORED_MOD']; - $message .= (($user->data['user_id'] == ANONYMOUS) ? '' : ' '. $user->lang['POST_APPROVAL_NOTIFY']); - $message .= '

' . sprintf($user->lang['RETURN_FORUM'], '', ''); - trigger_error($message); - } - - redirect($redirect_url); - } - } -} - -// Preview -if (!count($error) && $preview) -{ - $post_data['post_time'] = ($mode == 'edit') ? $post_data['post_time'] : $current_time; - - $preview_message = $message_parser->format_display($post_data['enable_bbcode'], $post_data['enable_urls'], $post_data['enable_smilies'], false); - - $preview_signature = ($mode == 'edit') ? $post_data['user_sig'] : $user->data['user_sig']; - $preview_signature_uid = ($mode == 'edit') ? $post_data['user_sig_bbcode_uid'] : $user->data['user_sig_bbcode_uid']; - $preview_signature_bitfield = ($mode == 'edit') ? $post_data['user_sig_bbcode_bitfield'] : $user->data['user_sig_bbcode_bitfield']; - - // Signature - if ($post_data['enable_sig'] && $config['allow_sig'] && $preview_signature && $auth->acl_get('f_sigs', $forum_id)) - { - $flags = ($config['allow_sig_bbcode']) ? OPTION_FLAG_BBCODE : 0; - $flags |= ($config['allow_sig_links']) ? OPTION_FLAG_LINKS : 0; - $flags |= ($config['allow_sig_smilies']) ? OPTION_FLAG_SMILIES : 0; - - $preview_signature = generate_text_for_display($preview_signature, $preview_signature_uid, $preview_signature_bitfield, $flags, false); - } - else - { - $preview_signature = ''; - } - - $preview_subject = censor_text($post_data['post_subject']); - - // Poll Preview - if (!$poll_delete && ($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id']/* && (!$post_data['poll_last_vote'] || $auth->acl_get('m_edit', $forum_id))*/)) - && $auth->acl_get('f_poll', $forum_id)) - { - $parse_poll = new parse_message($post_data['poll_title']); - $parse_poll->bbcode_uid = $message_parser->bbcode_uid; - $parse_poll->bbcode_bitfield = $message_parser->bbcode_bitfield; - - $parse_poll->format_display($post_data['enable_bbcode'], $post_data['enable_urls'], $post_data['enable_smilies']); - - if ($post_data['poll_length']) - { - $poll_end = ($post_data['poll_length'] * 86400) + (($post_data['poll_start']) ? $post_data['poll_start'] : time()); - } - - $template->assign_vars(array( - 'S_HAS_POLL_OPTIONS' => (count($post_data['poll_options'])), - 'S_IS_MULTI_CHOICE' => ($post_data['poll_max_options'] > 1) ? true : false, - - 'POLL_QUESTION' => $parse_poll->message, - - 'L_POLL_LENGTH' => ($post_data['poll_length']) ? sprintf($user->lang['POLL_RUN_TILL'], $user->format_date($poll_end)) : '', - 'L_MAX_VOTES' => $user->lang('MAX_OPTIONS_SELECT', (int) $post_data['poll_max_options']), - )); - - $preview_poll_options = array(); - foreach ($post_data['poll_options'] as $poll_option) - { - $parse_poll->message = $poll_option; - $parse_poll->format_display($post_data['enable_bbcode'], $post_data['enable_urls'], $post_data['enable_smilies']); - $preview_poll_options[] = $parse_poll->message; - } - unset($parse_poll); - - foreach ($preview_poll_options as $key => $option) - { - $template->assign_block_vars('poll_option', array( - 'POLL_OPTION_CAPTION' => $option, - 'POLL_OPTION_ID' => $key + 1) - ); - } - unset($preview_poll_options); - } - - // Attachment Preview - if (count($message_parser->attachment_data)) - { - $template->assign_var('S_HAS_ATTACHMENTS', true); - - $update_count = array(); - $attachment_data = $message_parser->attachment_data; - - parse_attachments($forum_id, $preview_message, $attachment_data, $update_count, true); - - foreach ($attachment_data as $i => $attachment) - { - $template->assign_block_vars('attachment', array( - 'DISPLAY_ATTACHMENT' => $attachment) - ); - } - unset($attachment_data); - } - - if (!count($error)) - { - $template->assign_vars(array( - 'PREVIEW_SUBJECT' => $preview_subject, - 'PREVIEW_MESSAGE' => $preview_message, - 'PREVIEW_SIGNATURE' => $preview_signature, - - 'S_DISPLAY_PREVIEW' => !empty($preview_message), - )); - } -} - -// Remove quotes that would become nested too deep before decoding the text -$generate_quote = ($mode == 'quote' && !$submit && !$preview && !$refresh); -if ($generate_quote && $config['max_quote_depth'] > 0) -{ - $tmp_bbcode_uid = $message_parser->bbcode_uid; - $message_parser->bbcode_uid = $post_data['bbcode_uid']; - $message_parser->remove_nested_quotes($config['max_quote_depth'] - 1); - $message_parser->bbcode_uid = $tmp_bbcode_uid; -} - -// Decode text for message display -$post_data['bbcode_uid'] = ($mode == 'quote' && !$preview && !$refresh && !count($error)) ? $post_data['bbcode_uid'] : $message_parser->bbcode_uid; -$message_parser->decode_message($post_data['bbcode_uid']); - -if ($generate_quote) -{ - // Remove attachment bbcode tags from the quoted message to avoid mixing with the new post attachments if any - $message_parser->message = preg_replace('#\[attachment=([0-9]+)\](.*?)\[\/attachment\]#uis', '\\2', $message_parser->message); - - $quote_attributes = array( - 'author' => $post_data['quote_username'], - 'post_id' => $post_data['post_id'], - 'time' => $post_data['post_time'], - 'user_id' => $post_data['poster_id'], - ); - - /** - * This event allows you to modify the quote attributes of the post being quoted - * - * @event core.posting_modify_quote_attributes - * @var array quote_attributes Array with quote attributes - * @var array post_data Array with post data - * @since 3.2.6-RC1 - */ - $vars = array( - 'quote_attributes', - 'post_data', - ); - extract($phpbb_dispatcher->trigger_event('core.posting_modify_quote_attributes', compact($vars))); - - /** @var \phpbb\language\language $language */ - $language = $phpbb_container->get('language'); - phpbb_format_quote($language, $message_parser, $bbcode_utils, $bbcode_status, $quote_attributes); -} - -if (($mode == 'reply' || $mode == 'quote') && !$submit && !$preview && !$refresh) -{ - $post_data['post_subject'] = ((strpos($post_data['post_subject'], 'Re: ') !== 0) ? 'Re: ' : '') . censor_text($post_data['post_subject']); - - $post_subject = $post_data['post_subject']; - - /** - * This event allows you to modify the post subject of the post being quoted - * - * @event core.posting_modify_post_subject - * @var string post_subject String with the post subject already censored. - * @since 3.2.8-RC1 - */ - $vars = array('post_subject'); - extract($phpbb_dispatcher->trigger_event('core.posting_modify_post_subject', compact($vars))); - - $post_data['post_subject'] = $post_subject; -} - -$attachment_data = $message_parser->attachment_data; -$filename_data = $message_parser->filename_data; -$post_data['post_text'] = $message_parser->message; - -if (count($post_data['poll_options']) || (isset($post_data['poll_title']) && !$bbcode_utils->is_empty($post_data['poll_title']))) -{ - $message_parser->message = $post_data['poll_title']; - $message_parser->bbcode_uid = $post_data['bbcode_uid']; - - $message_parser->decode_message(); - $post_data['poll_title'] = $message_parser->message; - - $message_parser->message = implode("\n", $post_data['poll_options']); - $message_parser->decode_message(); - $post_data['poll_options'] = explode("\n", $message_parser->message); -} - -// MAIN POSTING PAGE BEGINS HERE - -// Forum moderators? -$moderators = array(); -if ($config['load_moderators']) -{ - get_moderators($moderators, $forum_id); -} - -// Generate smiley listing -generate_smilies('inline', $forum_id); - -// Generate inline attachment select box -posting_gen_inline_attachments($attachment_data); - -// Do show topic type selection only in first post. -$topic_type_toggle = false; - -if ($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id'])) -{ - $topic_type_toggle = posting_gen_topic_types($forum_id, $post_data['topic_type']); -} - -$s_topic_icons = false; -if ($post_data['enable_icons'] && $auth->acl_get('f_icons', $forum_id)) -{ - $s_topic_icons = posting_gen_topic_icons($mode, $post_data['icon_id']); -} - -$bbcode_checked = (isset($post_data['enable_bbcode'])) ? !$post_data['enable_bbcode'] : (($config['allow_bbcode']) ? !$user->optionget('bbcode') : 1); -$smilies_checked = (isset($post_data['enable_smilies'])) ? !$post_data['enable_smilies'] : (($config['allow_smilies']) ? !$user->optionget('smilies') : 1); -$urls_checked = (isset($post_data['enable_urls'])) ? !$post_data['enable_urls'] : 0; -$sig_checked = $post_data['enable_sig']; -$lock_topic_checked = (isset($topic_lock) && $topic_lock) ? $topic_lock : (($post_data['topic_status'] == ITEM_LOCKED) ? 1 : 0); -$lock_post_checked = (isset($post_lock)) ? $post_lock : $post_data['post_edit_locked']; - -// If the user is replying or posting and not already watching this topic but set to always being notified we need to overwrite this setting -$notify_set = ($mode != 'edit' && $config['allow_topic_notify'] && $user->data['is_registered'] && !$post_data['notify_set']) ? $user->data['user_notify'] : $post_data['notify_set']; -$notify_checked = (isset($notify)) ? $notify : (($mode == 'post') ? $user->data['user_notify'] : $notify_set); - -// Page title & action URL -$s_action = append_sid("{$phpbb_root_path}posting.$phpEx", "mode=$mode&f=$forum_id"); -$s_action .= ($topic_id) ? "&t=$topic_id" : ''; -$s_action .= ($post_id) ? "&p=$post_id" : ''; - -switch ($mode) -{ - case 'post': - $page_title = $user->lang['POST_TOPIC']; - break; - - case 'quote': - case 'reply': - $page_title = $user->lang['POST_REPLY']; - break; - - case 'delete': - case 'edit': - $page_title = $user->lang['EDIT_POST']; - break; -} - -// Build Navigation Links -generate_forum_nav($post_data); - -// Build Forum Rules -generate_forum_rules($post_data); - -// Posting uses is_solved for legacy reasons. Plugins have to use is_solved to force themselves to be displayed. -if ($config['enable_post_confirm'] && !$user->data['is_registered'] && (isset($captcha) && $captcha->is_solved() === false) && ($mode == 'post' || $mode == 'reply' || $mode == 'quote')) -{ - - $template->assign_vars(array( - 'S_CONFIRM_CODE' => true, - 'CAPTCHA_TEMPLATE' => $captcha->get_template(), - )); -} - -$s_hidden_fields = ($mode == 'reply' || $mode == 'quote') ? '' : ''; -$s_hidden_fields .= ($draft_id || isset($_REQUEST['draft_loaded'])) ? '' : ''; - -if ($mode == 'edit') -{ - $s_hidden_fields .= build_hidden_fields(array( - 'edit_post_message_checksum' => $post_data['post_checksum'], - 'edit_post_subject_checksum' => $post_data['post_subject_md5'], - )); -} - -// Add the confirm id/code pair to the hidden fields, else an error is displayed on next submit/preview -if (isset($captcha) && $captcha->is_solved() !== false) -{ - $s_hidden_fields .= build_hidden_fields($captcha->get_hidden_fields()); -} - -$form_enctype = (@ini_get('file_uploads') == '0' || strtolower(@ini_get('file_uploads')) == 'off' || !$config['allow_attachments'] || !$auth->acl_get('u_attach') || !$auth->acl_get('f_attach', $forum_id)) ? '' : ' enctype="multipart/form-data"'; -add_form_key('posting'); - -/** @var \phpbb\controller\helper $controller_helper */ -$controller_helper = $phpbb_container->get('controller.helper'); - -// Build array of variables for main posting page -$page_data = array( - 'L_POST_A' => $page_title, - 'L_ICON' => ($mode == 'reply' || $mode == 'quote' || ($mode == 'edit' && $post_id != $post_data['topic_first_post_id'])) ? $user->lang['POST_ICON'] : $user->lang['TOPIC_ICON'], - 'L_MESSAGE_BODY_EXPLAIN' => $user->lang('MESSAGE_BODY_EXPLAIN', (int) $config['max_post_chars']), - 'L_DELETE_POST_PERMANENTLY' => $user->lang('DELETE_POST_PERMANENTLY', 1), - - 'FORUM_NAME' => $post_data['forum_name'], - 'FORUM_DESC' => ($post_data['forum_desc']) ? generate_text_for_display($post_data['forum_desc'], $post_data['forum_desc_uid'], $post_data['forum_desc_bitfield'], $post_data['forum_desc_options']) : '', - 'TOPIC_TITLE' => censor_text($post_data['topic_title']), - 'MODERATORS' => (count($moderators)) ? implode($user->lang['COMMA_SEPARATOR'], $moderators[$forum_id]) : '', - 'USERNAME' => ((!$preview && $mode != 'quote') || $preview) ? $post_data['username'] : '', - 'SUBJECT' => $post_data['post_subject'], - 'MESSAGE' => $post_data['post_text'], - 'BBCODE_STATUS' => $user->lang(($bbcode_status ? 'BBCODE_IS_ON' : 'BBCODE_IS_OFF'), '', ''), - 'IMG_STATUS' => ($img_status) ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'], - 'FLASH_STATUS' => ($flash_status) ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'], - 'SMILIES_STATUS' => ($smilies_status) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'], - 'URL_STATUS' => ($bbcode_status && $url_status) ? $user->lang['URL_IS_ON'] : $user->lang['URL_IS_OFF'], - 'MAX_FONT_SIZE' => (int) $config['max_post_font_size'], - 'MINI_POST_IMG' => $user->img('icon_post_target', $user->lang['POST']), - 'POST_DATE' => ($post_data['post_time']) ? $user->format_date($post_data['post_time']) : '', - 'ERROR' => (count($error)) ? implode('
', $error) : '', - 'TOPIC_TIME_LIMIT' => (int) $post_data['topic_time_limit'], - 'EDIT_REASON' => $request->variable('edit_reason', '', true), - 'SHOW_PANEL' => $request->variable('show_panel', ''), - 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id"), - 'U_VIEW_TOPIC' => ($mode != 'post') ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id") : '', - 'U_PROGRESS_BAR' => append_sid("{$phpbb_root_path}posting.$phpEx", "f=$forum_id&mode=popup"), - 'UA_PROGRESS_BAR' => addslashes(append_sid("{$phpbb_root_path}posting.$phpEx", "f=$forum_id&mode=popup")), - - 'S_PRIVMSGS' => false, - 'S_CLOSE_PROGRESS_WINDOW' => (isset($_POST['add_file'])) ? true : false, - 'S_EDIT_POST' => ($mode == 'edit') ? true : false, - 'S_EDIT_REASON' => ($mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? true : false, - 'S_DISPLAY_USERNAME' => (!$user->data['is_registered'] || ($mode == 'edit' && $post_data['poster_id'] == ANONYMOUS)) ? true : false, - 'S_SHOW_TOPIC_ICONS' => $s_topic_icons, - 'S_DELETE_ALLOWED' => ($mode == 'edit' && (($post_id == $post_data['topic_last_post_id'] && $post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id) && !$post_data['post_edit_locked'] && ($post_data['post_time'] > time() - ($config['delete_time'] * 60) || !$config['delete_time'])) || $auth->acl_get('m_delete', $forum_id))) ? true : false, - 'S_BBCODE_ALLOWED' => ($bbcode_status) ? 1 : 0, - 'S_BBCODE_CHECKED' => ($bbcode_checked) ? ' checked="checked"' : '', - 'S_SMILIES_ALLOWED' => $smilies_status, - 'S_SMILIES_CHECKED' => ($smilies_checked) ? ' checked="checked"' : '', - 'S_SIG_ALLOWED' => ($auth->acl_get('f_sigs', $forum_id) && $config['allow_sig'] && $user->data['is_registered']) ? true : false, - 'S_SIGNATURE_CHECKED' => ($sig_checked) ? ' checked="checked"' : '', - 'S_NOTIFY_ALLOWED' => (!$user->data['is_registered'] || ($mode == 'edit' && $user->data['user_id'] != $post_data['poster_id']) || !$config['allow_topic_notify'] || !$config['email_enable']) ? false : true, - 'S_NOTIFY_CHECKED' => ($notify_checked) ? ' checked="checked"' : '', - 'S_LOCK_TOPIC_ALLOWED' => (($mode == 'edit' || $mode == 'reply' || $mode == 'quote' || $mode == 'post') && ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && !empty($post_data['topic_poster']) && $user->data['user_id'] == $post_data['topic_poster'] && $post_data['topic_status'] == ITEM_UNLOCKED))) ? true : false, - 'S_LOCK_TOPIC_CHECKED' => ($lock_topic_checked) ? ' checked="checked"' : '', - 'S_LOCK_POST_ALLOWED' => ($mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? true : false, - 'S_LOCK_POST_CHECKED' => ($lock_post_checked) ? ' checked="checked"' : '', - 'S_SOFTDELETE_CHECKED' => ($mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED) ? ' checked="checked"' : '', - 'S_SOFTDELETE_ALLOWED' => ($mode == 'edit' && $phpbb_content_visibility->can_soft_delete($forum_id, $post_data['poster_id'], $lock_post_checked)) ? true : false, - 'S_RESTORE_ALLOWED' => $auth->acl_get('m_approve', $forum_id), - 'S_IS_DELETED' => ($mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED) ? true : false, - 'S_LINKS_ALLOWED' => $url_status, - 'S_MAGIC_URL_CHECKED' => ($urls_checked) ? ' checked="checked"' : '', - 'S_TYPE_TOGGLE' => $topic_type_toggle, - 'S_SAVE_ALLOWED' => ($auth->acl_get('u_savedrafts') && $user->data['is_registered'] && $mode != 'edit') ? true : false, - 'S_HAS_DRAFTS' => ($auth->acl_get('u_savedrafts') && $user->data['is_registered'] && $post_data['drafts']) ? true : false, - 'S_FORM_ENCTYPE' => $form_enctype, - - 'S_BBCODE_IMG' => $img_status, - 'S_BBCODE_URL' => $url_status, - 'S_BBCODE_FLASH' => $flash_status, - 'S_BBCODE_QUOTE' => $quote_status, - - 'S_POST_ACTION' => $s_action, - 'S_HIDDEN_FIELDS' => $s_hidden_fields, - 'S_ATTACH_DATA' => json_encode($message_parser->attachment_data), - 'S_IN_POSTING' => true, -); - -// Build custom bbcodes array -display_custom_bbcodes(); - -// Poll entry -if (($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id']/* && (!$post_data['poll_last_vote'] || $auth->acl_get('m_edit', $forum_id))*/)) - && $auth->acl_get('f_poll', $forum_id)) -{ - $page_data = array_merge($page_data, array( - 'S_SHOW_POLL_BOX' => true, - 'S_POLL_VOTE_CHANGE' => ($auth->acl_get('f_votechg', $forum_id) && $auth->acl_get('f_vote', $forum_id)), - 'S_POLL_DELETE' => ($mode == 'edit' && count($post_data['poll_options']) && ((!$post_data['poll_last_vote'] && $post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) || $auth->acl_get('m_delete', $forum_id))), - 'S_POLL_DELETE_CHECKED' => (!empty($poll_delete)) ? true : false, - - 'L_POLL_OPTIONS_EXPLAIN' => $user->lang('POLL_OPTIONS_' . (($mode == 'edit') ? 'EDIT_' : '') . 'EXPLAIN', (int) $config['max_poll_options']), - - 'VOTE_CHANGE_CHECKED' => (!empty($post_data['poll_vote_change'])) ? ' checked="checked"' : '', - 'POLL_TITLE' => (isset($post_data['poll_title'])) ? $post_data['poll_title'] : '', - 'POLL_OPTIONS' => (!empty($post_data['poll_options'])) ? implode("\n", $post_data['poll_options']) : '', - 'POLL_MAX_OPTIONS' => (isset($post_data['poll_max_options'])) ? (int) $post_data['poll_max_options'] : 1, - 'POLL_LENGTH' => $post_data['poll_length'], - ) - ); -} - -/** -* This event allows you to modify template variables for the posting screen -* -* @event core.posting_modify_template_vars -* @var array post_data Array with post data -* @var array moderators Array with forum moderators -* @var string mode What action to take if the form is submitted -* post|reply|quote|edit|delete|bump|smilies|popup -* @var string page_title Title of the mode page -* @var bool s_topic_icons Whether or not to show the topic icons -* @var string form_enctype If attachments are allowed for this form -* "multipart/form-data" or empty string -* @var string s_action The URL to submit the POST data to -* @var string s_hidden_fields Concatenated hidden input tags of posting form -* @var int post_id ID of the post -* @var int topic_id ID of the topic -* @var int forum_id ID of the forum -* @var int draft_id ID of the draft -* @var bool submit Whether or not the form has been submitted -* @var bool preview Whether or not the post is being previewed -* @var bool save Whether or not a draft is being saved -* @var bool load Whether or not a draft is being loaded -* @var bool cancel Whether or not to cancel the form (returns to -* viewtopic or viewforum depending on if the user -* is posting a new topic or editing a post) -* @var array error Any error strings; a non-empty array aborts -* form submission. -* NOTE: Should be actual language strings, NOT -* language keys. -* @var bool refresh Whether or not to retain previously submitted data -* @var array page_data Posting page data that should be passed to the -* posting page via $template->assign_vars() -* @var object message_parser The message parser object -* @since 3.1.0-a1 -* @changed 3.1.0-b3 Added vars post_data, moderators, mode, page_title, -* s_topic_icons, form_enctype, s_action, s_hidden_fields, -* post_id, topic_id, forum_id, submit, preview, save, load, -* delete, cancel, refresh, error, page_data, message_parser -* @changed 3.1.2-RC1 Removed 'delete' var as it does not exist -* @changed 3.1.5-RC1 Added poll variables to the page_data array -* @changed 3.1.6-RC1 Added 'draft_id' var -*/ -$vars = array( - 'post_data', - 'moderators', - 'mode', - 'page_title', - 's_topic_icons', - 'form_enctype', - 's_action', - 's_hidden_fields', - 'post_id', - 'topic_id', - 'forum_id', - 'draft_id', - 'submit', - 'preview', - 'save', - 'load', - 'cancel', - 'refresh', - 'error', - 'page_data', - 'message_parser', -); -extract($phpbb_dispatcher->trigger_event('core.posting_modify_template_vars', compact($vars))); - -// Start assigning vars for main posting page ... -$template->assign_vars($page_data); - -// Show attachment box for adding attachments if true -$allowed = ($auth->acl_get('f_attach', $forum_id) && $auth->acl_get('u_attach') && $config['allow_attachments'] && $form_enctype); - -if ($allowed) -{ - $max_files = ($auth->acl_get('a_') || $auth->acl_get('m_', $forum_id)) ? 0 : (int) $config['max_attachments']; - $plupload->configure($cache, $template, $s_action, $forum_id, $max_files); -} - -// Attachment entry -posting_gen_attachment_entry($attachment_data, $filename_data, $allowed); - -// Output page ... -page_header($page_title); - -$template->set_filenames(array( - 'body' => 'posting_body.html') -); - -make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx")); - -// Topic review -if ($mode == 'reply' || $mode == 'quote') -{ - if (topic_review($topic_id, $forum_id)) - { - $template->assign_var('S_DISPLAY_REVIEW', true); - } -} - -page_footer(); diff --git a/install/update/new/report.php b/install/update/new/report.php deleted file mode 100644 index d0d7b37..0000000 --- a/install/update/new/report.php +++ /dev/null @@ -1,41 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -use Symfony\Component\HttpFoundation\RedirectResponse; - -/** -* @ignore -*/ -define('IN_PHPBB', true); -$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); -include($phpbb_root_path . 'common.' . $phpEx); - -// Start session management -$user->session_begin(); -$auth->acl($user->data); - -$post_id = $request->variable('p', 0); -$pm_id = $request->variable('pm', 0); - -$redirect_route_name = ($pm_id === 0) ? 'phpbb_report_post_controller' : 'phpbb_report_pm_controller'; - -/** @var \phpbb\controller\helper $controller_helper */ -$controller_helper = $phpbb_container->get('controller.helper'); -$response = new RedirectResponse( - $controller_helper->route($redirect_route_name, array( - 'id' => ($pm_id === 0) ? $post_id : $pm_id, - ), false), - 301 -); -$response->send(); diff --git a/install/update/new/search.php b/install/update/new/search.php deleted file mode 100644 index 5d5e9f5..0000000 --- a/install/update/new/search.php +++ /dev/null @@ -1,1569 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -define('IN_PHPBB', true); -$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); -include($phpbb_root_path . 'common.' . $phpEx); - -// Start session management -$user->session_begin(); -$auth->acl($user->data); -$user->setup('search'); - -// Define initial vars -$mode = $request->variable('mode', ''); -$search_id = $request->variable('search_id', ''); -$start = max($request->variable('start', 0), 0); -$post_id = $request->variable('p', 0); -$topic_id = $request->variable('t', 0); -$view = $request->variable('view', ''); - -$submit = $request->variable('submit', false); -$keywords = $request->variable('keywords', '', true); -$add_keywords = $request->variable('add_keywords', '', true); -$author = $request->variable('author', '', true); -$author_id = $request->variable('author_id', 0); -$show_results = ($topic_id) ? 'posts' : $request->variable('sr', 'posts'); -$show_results = ($show_results == 'posts') ? 'posts' : 'topics'; -$search_terms = $request->variable('terms', 'all'); -$search_fields = $request->variable('sf', 'all'); -$search_child = $request->variable('sc', true); - -$sort_days = $request->variable('st', 0); -$sort_key = $request->variable('sk', 't'); -$sort_dir = $request->variable('sd', 'd'); - -$return_chars = $request->variable('ch', ($topic_id) ? -1 : 300); -$search_forum = $request->variable('fid', array(0)); - -// We put login boxes for the case if search_id is newposts, egosearch or unreadposts -// because a guest should be able to log in even if guests search is not permitted - -switch ($search_id) -{ - // Egosearch is an author search - case 'egosearch': - $author_id = $user->data['user_id']; - if ($user->data['user_id'] == ANONYMOUS) - { - login_box('', $user->lang['LOGIN_EXPLAIN_EGOSEARCH']); - } - break; - - // Search for unread posts needs to be allowed and user to be logged in if topics tracking for guests is disabled - case 'unreadposts': - if (!$config['load_unreads_search']) - { - $template->assign_var('S_NO_SEARCH', true); - trigger_error('NO_SEARCH_UNREADS'); - } - else if (!$config['load_anon_lastread'] && !$user->data['is_registered']) - { - login_box('', $user->lang['LOGIN_EXPLAIN_UNREADSEARCH']); - } - break; - - // The "new posts" search uses user_lastvisit which is user based, so it should require user to log in. - case 'newposts': - if ($user->data['user_id'] == ANONYMOUS) - { - login_box('', $user->lang['LOGIN_EXPLAIN_NEWPOSTS']); - } - break; - - default: - // There's nothing to do here for now ;) - break; -} - -// Is user able to search? Has search been disabled? -if (!$auth->acl_get('u_search') || !$auth->acl_getf_global('f_search') || !$config['load_search']) -{ - $template->assign_var('S_NO_SEARCH', true); - trigger_error('NO_SEARCH'); -} - -// Check search load limit -if ($user->load && $config['limit_search_load'] && ($user->load > doubleval($config['limit_search_load']))) -{ - $template->assign_var('S_NO_SEARCH', true); - trigger_error('NO_SEARCH_LOAD'); -} - -// It is applicable if the configuration setting is non-zero, and the user cannot -// ignore the flood setting, and the search is a keyword search. -$interval = ($user->data['user_id'] == ANONYMOUS) ? $config['search_anonymous_interval'] : $config['search_interval']; -if ($interval && !in_array($search_id, array('unreadposts', 'unanswered', 'active_topics', 'egosearch')) && !$auth->acl_get('u_ignoreflood')) -{ - if ($user->data['user_last_search'] > time() - $interval) - { - $template->assign_var('S_NO_SEARCH', true); - trigger_error($user->lang('NO_SEARCH_TIME', (int) ($user->data['user_last_search'] + $interval - time()))); - } -} - -// Define some vars -$limit_days = array(0 => $user->lang['ALL_RESULTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); -$sort_by_text = array('a' => $user->lang['SORT_AUTHOR'], 't' => $user->lang['SORT_TIME'], 'f' => $user->lang['SORT_FORUM'], 'i' => $user->lang['SORT_TOPIC_TITLE'], 's' => $user->lang['SORT_POST_SUBJECT']); - -$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; -gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); - -/* @var $phpbb_content_visibility \phpbb\content_visibility */ -$phpbb_content_visibility = $phpbb_container->get('content.visibility'); - -/* @var $pagination \phpbb\pagination */ -$pagination = $phpbb_container->get('pagination'); - -$template->assign_block_vars('navlinks', array( - 'BREADCRUMB_NAME' => $user->lang('SEARCH'), - 'U_BREADCRUMB' => append_sid("{$phpbb_root_path}search.$phpEx"), -)); - -/** -* This event allows you to alter the above parameters, such as keywords and submit -* -* @event core.search_modify_submit_parameters -* @var string keywords The search keywords -* @var string author Specifies the author match, when ANONYMOUS is also a search-match -* @var int author_id ID of the author to search by -* @var string search_id Predefined search type name -* @var bool submit Whether or not the form has been submitted -* @since 3.1.10-RC1 -*/ -$vars = array( - 'keywords', - 'author', - 'author_id', - 'search_id', - 'submit', -); -extract($phpbb_dispatcher->trigger_event('core.search_modify_submit_parameters', compact($vars))); - -if ($keywords || $author || $author_id || $search_id || $submit) -{ - // clear arrays - $id_ary = array(); - - // If we are looking for authors get their ids - $author_id_ary = array(); - $sql_author_match = ''; - if ($author_id) - { - $author_id_ary[] = $author_id; - } - else if ($author) - { - if ((strpos($author, '*') !== false) && (utf8_strlen(str_replace(array('*', '%'), '', $author)) < $config['min_search_author_chars'])) - { - trigger_error($user->lang('TOO_FEW_AUTHOR_CHARS', (int) $config['min_search_author_chars'])); - } - - $sql_where = (strpos($author, '*') !== false) ? ' username_clean ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), utf8_clean_string($author))) : " username_clean = '" . $db->sql_escape(utf8_clean_string($author)) . "'"; - - $sql = 'SELECT user_id - FROM ' . USERS_TABLE . " - WHERE $sql_where - AND user_type <> " . USER_IGNORE; - $result = $db->sql_query_limit($sql, 100); - - while ($row = $db->sql_fetchrow($result)) - { - $author_id_ary[] = (int) $row['user_id']; - } - $db->sql_freeresult($result); - - $sql_where = (strpos($author, '*') !== false) ? ' post_username ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), utf8_clean_string($author))) : " post_username = '" . $db->sql_escape(utf8_clean_string($author)) . "'"; - - $sql = 'SELECT 1 as guest_post - FROM ' . POSTS_TABLE . " - WHERE $sql_where - AND poster_id = " . ANONYMOUS; - $result = $db->sql_query_limit($sql, 1); - $found_guest_post = $db->sql_fetchfield('guest_post'); - $db->sql_freeresult($result); - - if ($found_guest_post) - { - $author_id_ary[] = ANONYMOUS; - $sql_author_match = (strpos($author, '*') !== false) ? ' ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), utf8_clean_string($author))) : " = '" . $db->sql_escape(utf8_clean_string($author)) . "'"; - } - - if (!count($author_id_ary)) - { - trigger_error('NO_SEARCH_RESULTS'); - } - } - - // if we search in an existing search result just add the additional keywords. But we need to use "all search terms"-mode - // so we can keep the old keywords in their old mode, but add the new ones as required words - if ($add_keywords) - { - if ($search_terms == 'all') - { - $keywords .= ' ' . $add_keywords; - } - else - { - $search_terms = 'all'; - $keywords = implode(' |', explode(' ', preg_replace('#\s+#u', ' ', $keywords))) . ' ' .$add_keywords; - } - } - - // Which forums should not be searched? Author searches are also carried out in unindexed forums - if (empty($keywords) && count($author_id_ary)) - { - $ex_fid_ary = array_keys($auth->acl_getf('!f_read', true)); - } - else - { - $ex_fid_ary = array_unique(array_merge(array_keys($auth->acl_getf('!f_read', true)), array_keys($auth->acl_getf('!f_search', true)))); - } - - $not_in_fid = (count($ex_fid_ary)) ? 'WHERE ' . $db->sql_in_set('f.forum_id', $ex_fid_ary, true) . " OR (f.forum_password <> '' AND fa.user_id <> " . (int) $user->data['user_id'] . ')' : ""; - - $sql = 'SELECT f.forum_id, f.forum_name, f.parent_id, f.forum_type, f.right_id, f.forum_password, f.forum_flags, fa.user_id - FROM ' . FORUMS_TABLE . ' f - LEFT JOIN ' . FORUMS_ACCESS_TABLE . " fa ON (fa.forum_id = f.forum_id - AND fa.session_id = '" . $db->sql_escape($user->session_id) . "') - $not_in_fid - ORDER BY f.left_id"; - $result = $db->sql_query($sql); - - $right_id = 0; - $reset_search_forum = true; - while ($row = $db->sql_fetchrow($result)) - { - if ($row['forum_password'] && $row['user_id'] != $user->data['user_id']) - { - $ex_fid_ary[] = (int) $row['forum_id']; - continue; - } - - // Exclude forums from active topics - if (!($row['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS) && ($search_id == 'active_topics')) - { - $ex_fid_ary[] = (int) $row['forum_id']; - continue; - } - - if (count($search_forum)) - { - if ($search_child) - { - if (in_array($row['forum_id'], $search_forum) && $row['right_id'] > $right_id) - { - $right_id = (int) $row['right_id']; - } - else if ($row['right_id'] < $right_id) - { - continue; - } - } - - if (!in_array($row['forum_id'], $search_forum)) - { - $ex_fid_ary[] = (int) $row['forum_id']; - $reset_search_forum = false; - } - } - } - $db->sql_freeresult($result); - - // find out in which forums the user is allowed to view posts - $m_approve_posts_fid_sql = $phpbb_content_visibility->get_global_visibility_sql('post', $ex_fid_ary, 'p.'); - $m_approve_topics_fid_sql = $phpbb_content_visibility->get_global_visibility_sql('topic', $ex_fid_ary, 't.'); - - if ($reset_search_forum) - { - $search_forum = array(); - } - - // Select which method we'll use to obtain the post_id or topic_id information - $search_type = $config['search_type']; - - if (!class_exists($search_type)) - { - trigger_error('NO_SUCH_SEARCH_MODULE'); - } - // We do some additional checks in the module to ensure it can actually be utilised - $error = false; - $search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher); - - if ($error) - { - trigger_error($error); - } - - // let the search module split up the keywords - if ($keywords) - { - $correct_query = $search->split_keywords($keywords, $search_terms); - $common_words = $search->get_common_words(); - if (!$correct_query || (!$search->get_search_query() && !count($author_id_ary) && !$search_id)) - { - $ignored = (count($common_words)) ? sprintf($user->lang['IGNORED_TERMS_EXPLAIN'], implode(' ', $common_words)) . '
' : ''; - $word_length = $search->get_word_length(); - if ($word_length) - { - trigger_error($ignored . $user->lang('NO_KEYWORDS', $user->lang('CHARACTERS', (int) $word_length['min']), $user->lang('CHARACTERS', (int) $word_length['max']))); - } - else - { - trigger_error($ignored); - } - } - } - - if (!$keywords && count($author_id_ary)) - { - // if it is an author search we want to show topics by default - $show_results = ($topic_id) ? 'posts' : $request->variable('sr', ($search_id == 'egosearch') ? 'topics' : 'posts'); - $show_results = ($show_results == 'posts') ? 'posts' : 'topics'; - } - - // define some variables needed for retrieving post_id/topic_id information - $sort_by_sql = array('a' => 'u.username_clean', 't' => (($show_results == 'posts') ? 'p.post_time' : 't.topic_last_post_time'), 'f' => 'f.forum_id', 'i' => 't.topic_title', 's' => (($show_results == 'posts') ? 'p.post_subject' : 't.topic_title')); - - /** - * Event to modify the SQL parameters before pre-made searches - * - * @event core.search_modify_param_before - * @var string keywords String of the specified keywords - * @var array sort_by_sql Array of SQL sorting instructions - * @var array ex_fid_ary Array of excluded forum ids - * @var array author_id_ary Array of exclusive author ids - * @var string search_id The id of the search request - * @var array id_ary Array of post or topic ids for search result - * @var string show_results 'posts' or 'topics' type of ids - * @since 3.1.3-RC1 - * @changed 3.1.10-RC1 Added id_ary, show_results - */ - $vars = array( - 'keywords', - 'sort_by_sql', - 'ex_fid_ary', - 'author_id_ary', - 'search_id', - 'id_ary', - 'show_results', - ); - extract($phpbb_dispatcher->trigger_event('core.search_modify_param_before', compact($vars))); - - // pre-made searches - $sql = $field = $l_search_title = ''; - if ($search_id) - { - switch ($search_id) - { - // Oh holy Bob, bring us some activity... - case 'active_topics': - $l_search_title = $user->lang['SEARCH_ACTIVE_TOPICS']; - $show_results = 'topics'; - $sort_key = 't'; - $sort_dir = 'd'; - $sort_days = $request->variable('st', 7); - $sort_by_sql['t'] = 't.topic_last_post_time'; - - gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); - $s_sort_key = $s_sort_dir = ''; - - $last_post_time_sql = ($sort_days) ? ' AND t.topic_last_post_time > ' . (time() - ($sort_days * 24 * 3600)) : ''; - - $sql = 'SELECT t.topic_last_post_time, t.topic_id - FROM ' . TOPICS_TABLE . " t - WHERE t.topic_moved_id = 0 - $last_post_time_sql - AND " . $m_approve_topics_fid_sql . ' - ' . ((count($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '') . ' - ORDER BY t.topic_last_post_time DESC'; - $field = 'topic_id'; - break; - - case 'unanswered': - $l_search_title = $user->lang['SEARCH_UNANSWERED']; - $show_results = $request->variable('sr', 'topics'); - $show_results = ($show_results == 'posts') ? 'posts' : 'topics'; - $sort_by_sql['t'] = ($show_results == 'posts') ? 'p.post_time' : 't.topic_last_post_time'; - $sort_by_sql['s'] = ($show_results == 'posts') ? 'p.post_subject' : 't.topic_title'; - $sql_sort = 'ORDER BY ' . $sort_by_sql[$sort_key] . (($sort_dir == 'a') ? ' ASC' : ' DESC'); - - $sort_join = ($sort_key == 'f') ? FORUMS_TABLE . ' f, ' : ''; - $sql_sort = ($sort_key == 'f') ? ' AND f.forum_id = p.forum_id ' . $sql_sort : $sql_sort; - - if ($sort_days) - { - $last_post_time = 'AND p.post_time > ' . (time() - ($sort_days * 24 * 3600)); - } - else - { - $last_post_time = ''; - } - - if ($sort_key == 'a') - { - $sort_join = USERS_TABLE . ' u, '; - $sql_sort = ' AND u.user_id = p.poster_id ' . $sql_sort; - } - if ($show_results == 'posts') - { - $sql = "SELECT p.post_id - FROM $sort_join" . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t - WHERE t.topic_posts_approved = 1 - AND p.topic_id = t.topic_id - $last_post_time - AND $m_approve_posts_fid_sql - " . ((count($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . " - $sql_sort"; - $field = 'post_id'; - } - else - { - $sql = 'SELECT DISTINCT ' . $sort_by_sql[$sort_key] . ", p.topic_id - FROM $sort_join" . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t - WHERE t.topic_posts_approved = 1 - AND t.topic_moved_id = 0 - AND p.topic_id = t.topic_id - $last_post_time - AND $m_approve_topics_fid_sql - " . ((count($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . " - $sql_sort"; - $field = 'topic_id'; - } - break; - - case 'unreadposts': - $l_search_title = $user->lang['SEARCH_UNREAD']; - // force sorting - $show_results = 'topics'; - $sort_key = 't'; - $sort_by_sql['t'] = 't.topic_last_post_time'; - $sql_sort = 'ORDER BY ' . $sort_by_sql[$sort_key] . (($sort_dir == 'a') ? ' ASC' : ' DESC'); - - $sql_where = 'AND t.topic_moved_id = 0 - AND ' . $m_approve_topics_fid_sql . ' - ' . ((count($ex_fid_ary)) ? 'AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : ''); - - gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); - $s_sort_key = $s_sort_dir = $u_sort_param = $s_limit_days = ''; - - $template->assign_var('U_MARK_ALL_READ', ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}index.$phpEx", 'hash=' . generate_link_hash('global') . '&mark=forums&mark_time=' . time()) : ''); - break; - - case 'newposts': - $l_search_title = $user->lang['SEARCH_NEW']; - // force sorting - $show_results = ($request->variable('sr', 'topics') == 'posts') ? 'posts' : 'topics'; - $sort_key = 't'; - $sort_dir = 'd'; - $sort_by_sql['t'] = ($show_results == 'posts') ? 'p.post_time' : 't.topic_last_post_time'; - $sql_sort = 'ORDER BY ' . $sort_by_sql[$sort_key] . (($sort_dir == 'a') ? ' ASC' : ' DESC'); - - gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); - $s_sort_key = $s_sort_dir = $u_sort_param = $s_limit_days = ''; - - if ($show_results == 'posts') - { - $sql = 'SELECT p.post_id - FROM ' . POSTS_TABLE . ' p - WHERE p.post_time > ' . $user->data['user_lastvisit'] . ' - AND ' . $m_approve_posts_fid_sql . ' - ' . ((count($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . " - $sql_sort"; - $field = 'post_id'; - } - else - { - $sql = 'SELECT t.topic_id - FROM ' . TOPICS_TABLE . ' t - WHERE t.topic_last_post_time > ' . $user->data['user_lastvisit'] . ' - AND t.topic_moved_id = 0 - AND ' . $m_approve_topics_fid_sql . ' - ' . ((count($ex_fid_ary)) ? 'AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '') . " - $sql_sort"; -/* - [Fix] queued replies missing from "view new posts" (Bug #42705 - Patch by Paul) - - Creates temporary table, query is far from optimized - - $sql = 'SELECT t.topic_id - FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p - WHERE p.post_time > ' . $user->data['user_lastvisit'] . ' - AND t.topic_id = p.topic_id - AND t.topic_moved_id = 0 - AND ' . $m_approve_topics_fid_sql . " - GROUP BY t.topic_id - $sql_sort"; -*/ - $field = 'topic_id'; - } - break; - - case 'egosearch': - $l_search_title = $user->lang['SEARCH_SELF']; - break; - } - - $template->assign_block_vars('navlinks', array( - 'BREADCRUMB_NAME' => $l_search_title, - 'U_BREADCRUMB' => append_sid("{$phpbb_root_path}search.$phpEx", "search_id=$search_id"), - )); - } - - /** - * Event to modify data after pre-made searches - * - * @event core.search_modify_param_after - * @var string l_search_title The title of the search page - * @var string search_id Predefined search type name - * @var string show_results Display topics or posts - * @var string sql SQL query corresponding to the pre-made search id - * @since 3.1.7-RC1 - */ - $vars = array( - 'l_search_title', - 'search_id', - 'show_results', - 'sql', - ); - extract($phpbb_dispatcher->trigger_event('core.search_modify_param_after', compact($vars))); - - // show_results should not change after this - $per_page = ($show_results == 'posts') ? $config['posts_per_page'] : $config['topics_per_page']; - $total_match_count = 0; - - // Set limit for the $total_match_count to reduce server load - $total_matches_limit = 1000; - $found_more_search_matches = false; - - if ($search_id) - { - if ($sql) - { - // Only return up to $total_matches_limit+1 ids (the last one will be removed later) - $result = $db->sql_query_limit($sql, $total_matches_limit + 1); - - while ($row = $db->sql_fetchrow($result)) - { - $id_ary[] = (int) $row[$field]; - } - $db->sql_freeresult($result); - } - else if ($search_id == 'unreadposts') - { - // Only return up to $total_matches_limit+1 ids (the last one will be removed later) - $id_ary = array_keys(get_unread_topics($user->data['user_id'], $sql_where, $sql_sort, $total_matches_limit + 1)); - } - else - { - $search_id = ''; - } - - $total_match_count = count($id_ary); - if ($total_match_count) - { - // Limit the number to $total_matches_limit for pre-made searches - if ($total_match_count > $total_matches_limit) - { - $found_more_search_matches = true; - $total_match_count = $total_matches_limit; - } - - // Make sure $start is set to the last page if it exceeds the amount - $start = $pagination->validate_start($start, $per_page, $total_match_count); - - $id_ary = array_slice($id_ary, $start, $per_page); - } - else - { - // Set $start to 0 if no matches were found - $start = 0; - } - } - - // make sure that some arrays are always in the same order - sort($ex_fid_ary); - sort($author_id_ary); - - if ($search->get_search_query()) - { - $total_match_count = $search->keyword_search($show_results, $search_fields, $search_terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_posts_fid_sql, $topic_id, $author_id_ary, $sql_author_match, $id_ary, $start, $per_page); - } - else if (count($author_id_ary)) - { - $firstpost_only = ($search_fields === 'firstpost' || $search_fields == 'titleonly') ? true : false; - $total_match_count = $search->author_search($show_results, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_posts_fid_sql, $topic_id, $author_id_ary, $sql_author_match, $id_ary, $start, $per_page); - } - - /** - * Event to search otherwise than by keywords or author - * - * @event core.search_backend_search_after - * @var string show_results 'posts' or 'topics' type of ids - * @var string search_fields The data fields to search in - * @var string search_terms Is either 'all' (use query as entered, words without prefix should default to "have to be in field") or 'any' (ignore search query parts and just return all posts that contain any of the specified words) - * @var array sort_by_sql Array of SQL sorting instructions - * @var string sort_key The sort key - * @var string sort_dir The sort direction - * @var int sort_days Limit the age of results - * @var array ex_fid_ary Array of excluded forum ids - * @var string m_approve_posts_fid_sql Specifies which types of posts the user can view in which forums - * @var int topic_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched - * @var array author_id_ary Array of exclusive author ids - * @var string sql_author_match Specifies the author match, when ANONYMOUS is also a search-match - * @var array id_ary Array of post or topic ids for search result - * @var int start The starting id of the results - * @var int per_page Number of ids each page is supposed to contain - * @var int total_match_count The total number of search matches - * @since 3.1.10-RC1 - */ - $vars = array( - 'show_results', - 'search_fields', - 'search_terms', - 'sort_by_sql', - 'sort_key', - 'sort_dir', - 'sort_days', - 'ex_fid_ary', - 'm_approve_posts_fid_sql', - 'topic_id', - 'author_id_ary', - 'sql_author_match', - 'id_ary', - 'start', - 'per_page', - 'total_match_count', - ); - extract($phpbb_dispatcher->trigger_event('core.search_backend_search_after', compact($vars))); - - $sql_where = ''; - - if (count($id_ary)) - { - $sql_where .= $db->sql_in_set(($show_results == 'posts') ? 'p.post_id' : 't.topic_id', $id_ary); - $sql_where .= (count($ex_fid_ary)) ? ' AND (' . $db->sql_in_set('f.forum_id', $ex_fid_ary, true) . ' OR f.forum_id IS NULL)' : ''; - $sql_where .= ' AND ' . (($show_results == 'posts') ? $m_approve_posts_fid_sql : $m_approve_topics_fid_sql); - } - - if ($show_results == 'posts') - { - include($phpbb_root_path . 'includes/functions_posting.' . $phpEx); - } - else - { - include($phpbb_root_path . 'includes/functions_display.' . $phpEx); - } - - $user->add_lang('viewtopic'); - - // Grab icons - $icons = $cache->obtain_icons(); - - // define some vars for urls - // A single wildcard will make the search results look ugly - $hilit = phpbb_clean_search_string(str_replace(array('+', '-', '|', '(', ')', '"'), ' ', $keywords)); - $hilit = str_replace(' ', '|', $hilit); - - $u_hilit = urlencode(htmlspecialchars_decode(str_replace('|', ' ', $hilit))); - $u_show_results = '&sr=' . $show_results; - $u_search_forum = implode('&fid%5B%5D=', $search_forum); - - $u_search = append_sid("{$phpbb_root_path}search.$phpEx", $u_sort_param . $u_show_results); - $u_search .= ($search_id) ? '&search_id=' . $search_id : ''; - $u_search .= ($u_hilit) ? '&keywords=' . urlencode(htmlspecialchars_decode($keywords)) : ''; - $u_search .= ($search_terms != 'all') ? '&terms=' . $search_terms : ''; - $u_search .= ($topic_id) ? '&t=' . $topic_id : ''; - $u_search .= ($author) ? '&author=' . urlencode(htmlspecialchars_decode($author)) : ''; - $u_search .= ($author_id) ? '&author_id=' . $author_id : ''; - $u_search .= ($u_search_forum) ? '&fid%5B%5D=' . $u_search_forum : ''; - $u_search .= (!$search_child) ? '&sc=0' : ''; - $u_search .= ($search_fields != 'all') ? '&sf=' . $search_fields : ''; - $u_search .= ($return_chars != 300) ? '&ch=' . $return_chars : ''; - - /** - * Event to add or modify search URL parameters - * - * @event core.search_modify_url_parameters - * @var string u_search Search URL parameters string - * @var string search_id Predefined search type name - * @var string show_results String indicating the show results mode - * @var string sql_where The SQL WHERE string used by search to get topic data - * @var int total_match_count The total number of search matches - * @var array ex_fid_ary Array of excluded forum ids - * @since 3.1.7-RC1 - * @changed 3.1.10-RC1 Added show_results, sql_where, total_match_count - * @changed 3.1.11-RC1 Added ex_fid_ary - */ - $vars = array( - 'u_search', - 'search_id', - 'show_results', - 'sql_where', - 'total_match_count', - 'ex_fid_ary', - ); - extract($phpbb_dispatcher->trigger_event('core.search_modify_url_parameters', compact($vars))); - - if ($sql_where) - { - $zebra = []; - - if ($show_results == 'posts') - { - // @todo Joining this query to the one below? - $sql = 'SELECT zebra_id, friend, foe - FROM ' . ZEBRA_TABLE . ' - WHERE user_id = ' . $user->data['user_id']; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $zebra[($row['friend']) ? 'friend' : 'foe'][] = $row['zebra_id']; - } - $db->sql_freeresult($result); - - $sql_array = array( - 'SELECT' => 'p.*, f.forum_id, f.forum_name, t.*, u.username, u.username_clean, u.user_sig, u.user_sig_bbcode_uid, u.user_colour', - 'FROM' => array( - POSTS_TABLE => 'p', - ), - 'LEFT_JOIN' => array( - array( - 'FROM' => array(TOPICS_TABLE => 't'), - 'ON' => 'p.topic_id = t.topic_id', - ), - array( - 'FROM' => array(FORUMS_TABLE => 'f'), - 'ON' => 'p.forum_id = f.forum_id', - ), - array( - 'FROM' => array(USERS_TABLE => 'u'), - 'ON' => 'p.poster_id = u.user_id', - ), - ), - 'WHERE' => $sql_where, - 'ORDER_BY' => $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'), - ); - - /** - * Event to modify the SQL query before the posts data is retrieved - * - * @event core.search_get_posts_data - * @var array sql_array The SQL array - * @var array zebra Array of zebra data for the current user - * @var int total_match_count The total number of search matches - * @var string keywords String of the specified keywords - * @var array sort_by_sql Array of SQL sorting instructions - * @var string s_sort_dir The sort direction - * @var string s_sort_key The sort key - * @var string s_limit_days Limit the age of results - * @var array ex_fid_ary Array of excluded forum ids - * @var array author_id_ary Array of exclusive author ids - * @var string search_fields The data fields to search in - * @var int search_id The id of the search request - * @var int start The starting id of the results - * @since 3.1.0-b3 - */ - $vars = array( - 'sql_array', - 'zebra', - 'total_match_count', - 'keywords', - 'sort_by_sql', - 's_sort_dir', - 's_sort_key', - 's_limit_days', - 'ex_fid_ary', - 'author_id_ary', - 'search_fields', - 'search_id', - 'start', - ); - extract($phpbb_dispatcher->trigger_event('core.search_get_posts_data', compact($vars))); - - $sql = $db->sql_build_query('SELECT', $sql_array); - } - else - { - $sql_from = TOPICS_TABLE . ' t - LEFT JOIN ' . FORUMS_TABLE . ' f ON (f.forum_id = t.forum_id) - ' . (($sort_key == 'a') ? ' LEFT JOIN ' . USERS_TABLE . ' u ON (u.user_id = t.topic_poster) ' : ''); - $sql_select = 't.*, f.forum_id, f.forum_name'; - - if ($user->data['is_registered']) - { - if ($config['load_db_track'] && $author_id !== $user->data['user_id']) - { - $sql_from .= ' LEFT JOIN ' . TOPICS_POSTED_TABLE . ' tp ON (tp.user_id = ' . $user->data['user_id'] . ' - AND t.topic_id = tp.topic_id)'; - $sql_select .= ', tp.topic_posted'; - } - - if ($config['load_db_lastread']) - { - $sql_from .= ' LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (tt.user_id = ' . $user->data['user_id'] . ' - AND t.topic_id = tt.topic_id) - LEFT JOIN ' . FORUMS_TRACK_TABLE . ' ft ON (ft.user_id = ' . $user->data['user_id'] . ' - AND ft.forum_id = f.forum_id)'; - $sql_select .= ', tt.mark_time, ft.mark_time as f_mark_time'; - } - } - - if ($config['load_anon_lastread'] || ($user->data['is_registered'] && !$config['load_db_lastread'])) - { - $tracking_topics = $request->variable($config['cookie_name'] . '_track', '', true, \phpbb\request\request_interface::COOKIE); - $tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array(); - } - - $sql_order_by = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'); - - /** - * Event to modify the SQL query before the topic data is retrieved - * - * @event core.search_get_topic_data - * @var string sql_select The SQL SELECT string used by search to get topic data - * @var string sql_from The SQL FROM string used by search to get topic data - * @var string sql_where The SQL WHERE string used by search to get topic data - * @var int total_match_count The total number of search matches - * @var array sort_by_sql Array of SQL sorting instructions - * @var string sort_dir The sorting direction - * @var string sort_key The sorting key - * @var string sql_order_by The SQL ORDER BY string used by search to get topic data - * @since 3.1.0-a1 - * @changed 3.1.0-RC5 Added total_match_count - * @changed 3.1.7-RC1 Added sort_by_sql, sort_dir, sort_key, sql_order_by - */ - $vars = array( - 'sql_select', - 'sql_from', - 'sql_where', - 'total_match_count', - 'sort_by_sql', - 'sort_dir', - 'sort_key', - 'sql_order_by', - ); - extract($phpbb_dispatcher->trigger_event('core.search_get_topic_data', compact($vars))); - - $sql = "SELECT $sql_select - FROM $sql_from - WHERE $sql_where - ORDER BY $sql_order_by"; - } - $result = $db->sql_query($sql); - $result_topic_id = 0; - - $rowset = $attachments = $topic_tracking_info = array(); - - if ($show_results == 'topics') - { - $forums = $rowset = $shadow_topic_list = array(); - while ($row = $db->sql_fetchrow($result)) - { - $row['forum_id'] = (int) $row['forum_id']; - $row['topic_id'] = (int) $row['topic_id']; - - if ($row['topic_status'] == ITEM_MOVED) - { - $shadow_topic_list[$row['topic_moved_id']] = $row['topic_id']; - } - - $rowset[$row['topic_id']] = $row; - - if (!isset($forums[$row['forum_id']]) && $user->data['is_registered'] && $config['load_db_lastread']) - { - $forums[$row['forum_id']]['mark_time'] = $row['f_mark_time']; - } - $forums[$row['forum_id']]['topic_list'][] = $row['topic_id']; - $forums[$row['forum_id']]['rowset'][$row['topic_id']] = &$rowset[$row['topic_id']]; - } - $db->sql_freeresult($result); - - // If we have some shadow topics, update the rowset to reflect their topic information - if (count($shadow_topic_list)) - { - $sql = 'SELECT * - FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', array_keys($shadow_topic_list)); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $orig_topic_id = $shadow_topic_list[$row['topic_id']]; - - // We want to retain some values - $row = array_merge($row, array( - 'topic_moved_id' => $rowset[$orig_topic_id]['topic_moved_id'], - 'topic_status' => $rowset[$orig_topic_id]['topic_status'], - 'forum_name' => $rowset[$orig_topic_id]['forum_name']) - ); - - $rowset[$orig_topic_id] = $row; - } - $db->sql_freeresult($result); - } - unset($shadow_topic_list); - - foreach ($forums as $forum_id => $forum) - { - if ($user->data['is_registered'] && $config['load_db_lastread']) - { - $topic_tracking_info[$forum_id] = get_topic_tracking($forum_id, $forum['topic_list'], $forum['rowset'], array($forum_id => $forum['mark_time'])); - } - else if ($config['load_anon_lastread'] || $user->data['is_registered']) - { - $topic_tracking_info[$forum_id] = get_complete_topic_tracking($forum_id, $forum['topic_list']); - - if (!$user->data['is_registered']) - { - $user->data['user_lastmark'] = (isset($tracking_topics['l'])) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0; - } - } - } - unset($forums); - } - else - { - $text_only_message = ''; - $attach_list = array(); - - while ($row = $db->sql_fetchrow($result)) - { - /** - * Modify the row of a post result before the post_text is trimmed - * - * @event core.search_modify_post_row - * @var string hilit String to highlight - * @var array row Array with the post data - * @var string u_hilit Highlight string to be injected into URL - * @var string view Search results view mode - * @var array zebra Array with zebra data for the current user - * @since 3.2.2-RC1 - */ - $vars = array( - 'hilit', - 'row', - 'u_hilit', - 'view', - 'zebra', - ); - extract($phpbb_dispatcher->trigger_event('core.search_modify_post_row', compact($vars))); - - // We pre-process some variables here for later usage - $row['post_text'] = censor_text($row['post_text']); - - $text_only_message = $row['post_text']; - // make list items visible as such - if ($row['bbcode_uid']) - { - $text_only_message = str_replace('[*:' . $row['bbcode_uid'] . ']', '⋅ ', $text_only_message); - // no BBCode in text only message - strip_bbcode($text_only_message, $row['bbcode_uid']); - } - - if ($return_chars == -1 || utf8_strlen($text_only_message) < ($return_chars + 3)) - { - $row['display_text_only'] = false; - - // Does this post have an attachment? If so, add it to the list - if ($row['post_attachment'] && $config['allow_attachments']) - { - $attach_list[$row['forum_id']][] = $row['post_id']; - } - } - else - { - $row['post_text'] = $text_only_message; - $row['display_text_only'] = true; - } - - $rowset[] = $row; - } - $db->sql_freeresult($result); - - unset($text_only_message); - - // Pull attachment data - if (count($attach_list)) - { - $use_attach_list = $attach_list; - $attach_list = array(); - - foreach ($use_attach_list as $forum_id => $_list) - { - if ($auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id)) - { - $attach_list = array_merge($attach_list, $_list); - } - } - } - - if (count($attach_list)) - { - $sql = 'SELECT * - FROM ' . ATTACHMENTS_TABLE . ' - WHERE ' . $db->sql_in_set('post_msg_id', $attach_list) . ' - AND in_message = 0 - ORDER BY filetime DESC, post_msg_id ASC'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $attachments[$row['post_msg_id']][] = $row; - } - $db->sql_freeresult($result); - } - } - - if ($hilit) - { - // Remove bad highlights - $hilit_array = array_filter(explode('|', $hilit), 'strlen'); - foreach ($hilit_array as $key => $value) - { - $hilit_array[$key] = phpbb_clean_search_string($value); - $hilit_array[$key] = str_replace('\*', '\w*?', preg_quote($hilit_array[$key], '#')); - $hilit_array[$key] = preg_replace('#(^|\s)\\\\w\*\?(\s|$)#', '$1\w+?$2', $hilit_array[$key]); - } - $hilit = implode('|', $hilit_array); - } - - /** - * Modify the rowset data - * - * @event core.search_modify_rowset - * @var array attachments Array with posts attachments data - * @var string hilit String to highlight - * @var array rowset Array with the search results data - * @var string show_results String indicating the show results mode - * @var array topic_tracking_info Array with the topics tracking data - * @var string u_hilit Highlight string to be injected into URL - * @var string view Search results view mode - * @var array zebra Array with zebra data for the current user - * @since 3.1.0-b4 - * @changed 3.1.0-b5 Added var show_results - */ - $vars = array( - 'attachments', - 'hilit', - 'rowset', - 'show_results', - 'topic_tracking_info', - 'u_hilit', - 'view', - 'zebra', - ); - extract($phpbb_dispatcher->trigger_event('core.search_modify_rowset', compact($vars))); - - foreach ($rowset as $row) - { - $forum_id = $row['forum_id']; - $result_topic_id = $row['topic_id']; - $topic_title = censor_text($row['topic_title']); - $replies = $phpbb_content_visibility->get_count('topic_posts', $row, $forum_id) - 1; - - $view_topic_url_params = "f=$forum_id&t=$result_topic_id" . (($u_hilit) ? "&hilit=$u_hilit" : ''); - $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params); - - $folder_img = $folder_alt = $u_mcp_queue = ''; - $topic_type = $posts_unapproved = 0; - $unread_topic = $topic_unapproved = $topic_deleted = false; - - if ($show_results == 'topics') - { - if ($config['load_db_track'] && $author_id === $user->data['user_id']) - { - $row['topic_posted'] = 1; - } - - topic_status($row, $replies, (isset($topic_tracking_info[$forum_id][$row['topic_id']]) && $row['topic_last_post_time'] > $topic_tracking_info[$forum_id][$row['topic_id']]) ? true : false, $folder_img, $folder_alt, $topic_type); - - $unread_topic = (isset($topic_tracking_info[$forum_id][$row['topic_id']]) && $row['topic_last_post_time'] > $topic_tracking_info[$forum_id][$row['topic_id']]) ? true : false; - - $topic_unapproved = (($row['topic_visibility'] == ITEM_UNAPPROVED || $row['topic_visibility'] == ITEM_REAPPROVE) && $auth->acl_get('m_approve', $forum_id)) ? true : false; - $posts_unapproved = ($row['topic_visibility'] == ITEM_APPROVED && $row['topic_posts_unapproved'] && $auth->acl_get('m_approve', $forum_id)) ? true : false; - $topic_deleted = $row['topic_visibility'] == ITEM_DELETED; - $u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . "&t=$result_topic_id", true, $user->session_id) : ''; - $u_mcp_queue = (!$u_mcp_queue && $topic_deleted) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue&mode=deleted_topics&t=$result_topic_id", true, $user->session_id) : $u_mcp_queue; - - $row['topic_title'] = preg_replace('#(?!<.*)(?]*(?:)#isu', '$1', $row['topic_title']); - - $tpl_ary = array( - 'TOPIC_AUTHOR' => get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), - 'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), - 'TOPIC_AUTHOR_FULL' => get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), - 'FIRST_POST_TIME' => $user->format_date($row['topic_time']), - 'FIRST_POST_TIME_RFC3339' => gmdate(DATE_RFC3339, $row['topic_time']), - 'LAST_POST_SUBJECT' => $row['topic_last_post_subject'], - 'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']), - 'LAST_POST_TIME_RFC3339' => gmdate(DATE_RFC3339, $row['topic_last_post_time']), - 'LAST_VIEW_TIME' => $user->format_date($row['topic_last_view_time']), - 'LAST_VIEW_TIME_RFC3339' => gmdate(DATE_RFC3339, $row['topic_last_view_time']), - 'LAST_POST_AUTHOR' => get_username_string('username', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), - 'LAST_POST_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), - 'LAST_POST_AUTHOR_FULL' => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), - - 'TOPIC_TYPE' => $topic_type, - - 'TOPIC_IMG_STYLE' => $folder_img, - 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt), - 'TOPIC_FOLDER_IMG_ALT' => $user->lang[$folder_alt], - - 'TOPIC_ICON_IMG' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['img'] : '', - 'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['width'] : '', - 'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['height'] : '', - 'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id) && $row['topic_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', - 'UNAPPROVED_IMG' => ($topic_unapproved || $posts_unapproved) ? $user->img('icon_topic_unapproved', ($topic_unapproved) ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '', - - 'S_TOPIC_TYPE' => $row['topic_type'], - 'S_USER_POSTED' => (!empty($row['topic_posted'])) ? true : false, - 'S_UNREAD_TOPIC' => $unread_topic, - - 'S_TOPIC_REPORTED' => (!empty($row['topic_reported']) && $auth->acl_get('m_report', $forum_id)) ? true : false, - 'S_TOPIC_UNAPPROVED' => $topic_unapproved, - 'S_POSTS_UNAPPROVED' => $posts_unapproved, - 'S_TOPIC_DELETED' => $topic_deleted, - 'S_HAS_POLL' => ($row['poll_start']) ? true : false, - - 'U_LAST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params . '&p=' . $row['topic_last_post_id']) . '#p' . $row['topic_last_post_id'], - 'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), - 'U_TOPIC_AUTHOR' => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), - 'U_NEWEST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params . '&view=unread') . '#unread', - 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=reports&t=' . $result_topic_id, true, $user->session_id), - 'U_MCP_QUEUE' => $u_mcp_queue, - ); - } - else - { - if ((isset($zebra['foe']) && in_array($row['poster_id'], $zebra['foe'])) && (!$view || $view != 'show' || $post_id != $row['post_id'])) - { - $template->assign_block_vars('searchresults', array( - 'S_IGNORE_POST' => true, - - 'L_IGNORE_POST' => sprintf($user->lang['POST_BY_FOE'], $row['username'], "', '')) - ); - - continue; - } - - // Replace naughty words such as farty pants - $row['post_subject'] = censor_text($row['post_subject']); - - if ($row['display_text_only']) - { - // now find context for the searched words - $row['post_text'] = get_context($row['post_text'], array_filter(explode('|', $hilit), 'strlen'), $return_chars); - $row['post_text'] = bbcode_nl2br($row['post_text']); - } - else - { - $parse_flags = ($row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES; - $row['post_text'] = generate_text_for_display($row['post_text'], $row['bbcode_uid'], $row['bbcode_bitfield'], $parse_flags, false); - - if (!empty($attachments[$row['post_id']])) - { - parse_attachments($forum_id, $row['post_text'], $attachments[$row['post_id']], $update_count); - - // we only display inline attachments - unset($attachments[$row['post_id']]); - } - } - - if ($hilit) - { - // post highlighting - $row['post_text'] = preg_replace('#(?!<.*)(?]*(?:)#isu', '$1', $row['post_text']); - $row['post_subject'] = preg_replace('#(?!<.*)(?]*(?:)#isu', '$1', $row['post_subject']); - } - - $tpl_ary = array( - 'POST_AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), - 'POST_AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), - 'POST_AUTHOR' => get_username_string('username', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), - 'U_POST_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), - - 'POST_SUBJECT' => $row['post_subject'], - 'POST_DATE' => (!empty($row['post_time'])) ? $user->format_date($row['post_time']) : '', - 'MESSAGE' => $row['post_text'] - ); - } - - $tpl_ary = array_merge($tpl_ary, array( - 'FORUM_ID' => $forum_id, - 'TOPIC_ID' => $result_topic_id, - 'POST_ID' => ($show_results == 'posts') ? $row['post_id'] : false, - - 'FORUM_TITLE' => $row['forum_name'], - 'TOPIC_TITLE' => $topic_title, - 'TOPIC_REPLIES' => $replies, - 'TOPIC_VIEWS' => $row['topic_views'], - - 'U_VIEW_TOPIC' => $view_topic_url, - 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id), - 'U_VIEW_POST' => (!empty($row['post_id'])) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=" . $row['topic_id'] . '&p=' . $row['post_id'] . (($u_hilit) ? '&hilit=' . $u_hilit : '')) . '#p' . $row['post_id'] : '', - )); - - /** - * Modify the topic data before it is assigned to the template - * - * @event core.search_modify_tpl_ary - * @var array row Array with topic data - * @var array tpl_ary Template block array with topic data - * @var string show_results Display topics or posts - * @var string topic_title Cleaned topic title - * @var int replies The number of topic replies - * @var string view_topic_url The URL to the topic - * @var string folder_img The folder image of the topic - * @var string folder_alt The alt attribute of the topic folder img - * @var int topic_type The topic type - * @var bool unread_topic Whether the topic has unread posts - * @var bool topic_unapproved Whether the topic is unapproved - * @var int posts_unapproved The number of unapproved posts - * @var bool topic_deleted Whether the topic has been deleted - * @var string u_mcp_queue The URL to the corresponding MCP queue page - * @var array zebra The zebra data of the current user - * @var array attachments All the attachments of the search results - * @since 3.1.0-a1 - * @changed 3.1.0-b3 Added vars show_results, topic_title, replies, - * view_topic_url, folder_img, folder_alt, topic_type, unread_topic, - * topic_unapproved, posts_unapproved, topic_deleted, u_mcp_queue, - * zebra, attachments - */ - $vars = array( - 'row', - 'tpl_ary', - 'show_results', - 'topic_title', - 'replies', - 'view_topic_url', - 'folder_img', - 'folder_alt', - 'topic_type', - 'unread_topic', - 'topic_unapproved', - 'posts_unapproved', - 'topic_deleted', - 'u_mcp_queue', - 'zebra', - 'attachments', - ); - extract($phpbb_dispatcher->trigger_event('core.search_modify_tpl_ary', compact($vars))); - - $template->assign_block_vars('searchresults', $tpl_ary); - - if ($show_results == 'topics') - { - $pagination->generate_template_pagination($view_topic_url, 'searchresults.pagination', 'start', $replies + 1, $config['posts_per_page'], 1, true, true); - } - } - - if ($topic_id && ($topic_id == $result_topic_id)) - { - $template->assign_vars(array( - 'SEARCH_TOPIC' => $topic_title, - 'L_RETURN_TO_TOPIC' => $user->lang('RETURN_TO', $topic_title), - 'U_SEARCH_TOPIC' => $view_topic_url - )); - } - } - unset($rowset); - - // Output header - if ($found_more_search_matches) - { - $l_search_matches = $user->lang('FOUND_MORE_SEARCH_MATCHES', (int) $total_match_count); - } - else - { - $l_search_matches = $user->lang('FOUND_SEARCH_MATCHES', (int) $total_match_count); - } - - // Check if search backend supports phrase search or not - $phrase_search_disabled = ''; - if (strpos(html_entity_decode($keywords), '"') !== false && method_exists($search, 'supports_phrase_search')) - { - $phrase_search_disabled = $search->supports_phrase_search() ? false : true; - } - - $pagination->generate_template_pagination($u_search, 'pagination', 'start', $total_match_count, $per_page, $start); - - $template->assign_vars(array( - 'SEARCH_TITLE' => $l_search_title, - 'SEARCH_MATCHES' => $l_search_matches, - 'SEARCH_WORDS' => $keywords, - 'SEARCHED_QUERY' => $search->get_search_query(), - 'IGNORED_WORDS' => (!empty($common_words)) ? implode(' ', $common_words) : '', - - 'PHRASE_SEARCH_DISABLED' => $phrase_search_disabled, - - 'TOTAL_MATCHES' => $total_match_count, - 'SEARCH_IN_RESULTS' => ($search_id) ? false : true, - - 'S_SELECT_SORT_DIR' => $s_sort_dir, - 'S_SELECT_SORT_KEY' => $s_sort_key, - 'S_SELECT_SORT_DAYS' => $s_limit_days, - 'S_SEARCH_ACTION' => $u_search, - 'S_SHOW_TOPICS' => ($show_results == 'posts') ? false : true, - - 'GOTO_PAGE_IMG' => $user->img('icon_post_target', 'GOTO_PAGE'), - 'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'), - 'REPORTED_IMG' => $user->img('icon_topic_reported', 'TOPIC_REPORTED'), - 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'TOPIC_UNAPPROVED'), - 'DELETED_IMG' => $user->img('icon_topic_deleted', 'TOPIC_DELETED'), - 'POLL_IMG' => $user->img('icon_topic_poll', 'TOPIC_POLL'), - 'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'), - - 'U_SEARCH_WORDS' => $u_search, - )); - - /** - * Modify the title and/or load data for the search results page - * - * @event core.search_results_modify_search_title - * @var int author_id ID of the author to search by - * @var string l_search_title The title of the search page - * @var string search_id Predefined search type name - * @var string show_results Search results output mode - topics or posts - * @var int start The starting id of the results - * @var int total_match_count The count of search results - * @var string keywords The search keywords - * @since 3.1.0-RC4 - * @changed 3.1.6-RC1 Added total_match_count and keywords - */ - $vars = array( - 'author_id', - 'l_search_title', - 'search_id', - 'show_results', - 'start', - 'total_match_count', - 'keywords', - ); - extract($phpbb_dispatcher->trigger_event('core.search_results_modify_search_title', compact($vars))); - - page_header(($l_search_title) ? $l_search_title : $user->lang['SEARCH']); - - $template->set_filenames(array( - 'body' => 'search_results.html') - ); - make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx")); - - page_footer(); -} - -// Search forum -$rowset = array(); -$s_forums = ''; -$sql = 'SELECT f.forum_id, f.forum_name, f.parent_id, f.forum_type, f.left_id, f.right_id, f.forum_password, f.enable_indexing, fa.user_id - FROM ' . FORUMS_TABLE . ' f - LEFT JOIN ' . FORUMS_ACCESS_TABLE . " fa ON (fa.forum_id = f.forum_id - AND fa.session_id = '" . $db->sql_escape($user->session_id) . "') - ORDER BY f.left_id ASC"; -$result = $db->sql_query($sql); - -while ($row = $db->sql_fetchrow($result)) -{ - $rowset[(int) $row['forum_id']] = $row; -} -$db->sql_freeresult($result); - -$right = $cat_right = $padding_inc = 0; -$padding = $forum_list = $holding = ''; -$pad_store = array('0' => ''); - -/** -* Modify the forum select list for advanced search page -* -* @event core.search_modify_forum_select_list -* @var array rowset Array with the forums list data -* @since 3.1.10-RC1 -*/ -$vars = array('rowset'); -extract($phpbb_dispatcher->trigger_event('core.search_modify_forum_select_list', compact($vars))); - -foreach ($rowset as $row) -{ - if ($row['forum_type'] == FORUM_CAT && ($row['left_id'] + 1 == $row['right_id'])) - { - // Non-postable forum with no subforums, don't display - continue; - } - - if ($row['forum_type'] == FORUM_POST && ($row['left_id'] + 1 == $row['right_id']) && !$row['enable_indexing']) - { - // Postable forum with no subforums and indexing disabled, don't display - continue; - } - - if ($row['forum_type'] == FORUM_LINK || ($row['forum_password'] && !$row['user_id'])) - { - // if this forum is a link or password protected (user has not entered the password yet) then skip to the next branch - continue; - } - - if ($row['left_id'] < $right) - { - $padding .= '   '; - $pad_store[$row['parent_id']] = $padding; - } - else if ($row['left_id'] > $right + 1) - { - if (isset($pad_store[$row['parent_id']])) - { - $padding = $pad_store[$row['parent_id']]; - } - else - { - continue; - } - } - - $right = $row['right_id']; - - if ($auth->acl_gets('!f_search', '!f_list', $row['forum_id'])) - { - // if the user does not have permissions to search or see this forum skip only this forum/category - continue; - } - - $selected = (in_array($row['forum_id'], $search_forum)) ? ' selected="selected"' : ''; - - if ($row['left_id'] > $cat_right) - { - // make sure we don't forget anything - $s_forums .= $holding; - $holding = ''; - } - - if ($row['right_id'] - $row['left_id'] > 1) - { - $cat_right = max($cat_right, $row['right_id']); - - $holding .= ''; - } - else - { - $s_forums .= $holding . ''; - $holding = ''; - } -} - -if ($holding) -{ - $s_forums .= $holding; -} - -unset($pad_store); -unset($rowset); - -if (!$s_forums) -{ - trigger_error('NO_SEARCH'); -} - -// Number of chars returned -$s_characters = ''; -$s_characters .= ''; -$s_characters .= ''; -$s_characters .= ''; - -for ($i = 100; $i <= 1000; $i += 100) -{ - $selected = ($i == 300) ? ' selected="selected"' : ''; - $s_characters .= ''; -} - -$s_hidden_fields = array('t' => $topic_id); - -if ($_SID) -{ - $s_hidden_fields['sid'] = $_SID; -} - -if (!empty($_EXTRA_URL)) -{ - foreach ($_EXTRA_URL as $url_param) - { - $url_param = explode('=', $url_param, 2); - $s_hidden_fields[$url_param[0]] = $url_param[1]; - } -} - -$template->assign_vars(array( - 'S_SEARCH_ACTION' => append_sid("{$phpbb_root_path}search.$phpEx", false, true, 0), // We force no ?sid= appending by using 0 - 'S_HIDDEN_FIELDS' => build_hidden_fields($s_hidden_fields), - 'S_CHARACTER_OPTIONS' => $s_characters, - 'S_FORUM_OPTIONS' => $s_forums, - 'S_SELECT_SORT_DIR' => $s_sort_dir, - 'S_SELECT_SORT_KEY' => $s_sort_key, - 'S_SELECT_SORT_DAYS' => $s_limit_days, - 'S_IN_SEARCH' => true, -)); - -// only show recent searches to search administrators -if ($auth->acl_get('a_search')) -{ - // Handle large objects differently for Oracle and MSSQL - switch ($db->get_sql_layer()) - { - case 'oracle': - $sql = 'SELECT search_time, search_keywords - FROM ' . SEARCH_RESULTS_TABLE . ' - WHERE dbms_lob.getlength(search_keywords) > 0 - ORDER BY search_time DESC'; - break; - - case 'mssql_odbc': - case 'mssqlnative': - $sql = 'SELECT search_time, search_keywords - FROM ' . SEARCH_RESULTS_TABLE . ' - WHERE DATALENGTH(search_keywords) > 0 - ORDER BY search_time DESC'; - break; - - default: - $sql = 'SELECT search_time, search_keywords - FROM ' . SEARCH_RESULTS_TABLE . ' - WHERE search_keywords <> \'\' - ORDER BY search_time DESC'; - break; - } - $result = $db->sql_query_limit($sql, 5); - - while ($row = $db->sql_fetchrow($result)) - { - $keywords = $row['search_keywords']; - - $template->assign_block_vars('recentsearch', array( - 'KEYWORDS' => $keywords, - 'TIME' => $user->format_date($row['search_time']), - - 'U_KEYWORDS' => append_sid("{$phpbb_root_path}search.$phpEx", 'keywords=' . urlencode(htmlspecialchars_decode($keywords))) - )); - } - $db->sql_freeresult($result); -} - -// Output the basic page -page_header($user->lang['SEARCH']); - -$template->set_filenames(array( - 'body' => 'search_body.html') -); -make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx")); - -page_footer(); diff --git a/install/update/new/styles/prosilver/style.cfg b/install/update/new/styles/prosilver/style.cfg deleted file mode 100644 index 0c7eba6..0000000 --- a/install/update/new/styles/prosilver/style.cfg +++ /dev/null @@ -1,32 +0,0 @@ -# -# phpBB Style Configuration File -# -# This file is part of the phpBB Forum Software package. -# -# @copyright (c) phpBB Limited -# @license GNU General Public License, version 2 (GPL-2.0) -# -# For full copyright and license information, please see -# the docs/CREDITS.txt file. -# -# At the left is the name, please do not change this -# At the right the value is entered -# -# Values get trimmed, if you want to add a space in front or at the end of -# the value, then enclose the value with single or double quotes. -# Single and double quotes do not need to be escaped. -# -# - -# General Information about this style -name = prosilver -copyright = © phpBB Limited, 2007 -style_version = 3.3.0 -phpbb_version = 3.3.0 - -# Defining a different template bitfield -# template_bitfield = //g= - -# Parent style -# Set value to empty or to this style's name if this style does not have a parent style -parent = prosilver diff --git a/install/update/new/styles/prosilver/template/attachment.html b/install/update/new/styles/prosilver/template/attachment.html deleted file mode 100644 index 45b9dc2..0000000 --- a/install/update/new/styles/prosilver/template/attachment.html +++ /dev/null @@ -1,35 +0,0 @@ - - - - -

[{_file.DENIED_MESSAGE}]

- - - - -
-
{% if _file.COMMENT %}{{ _file.COMMENT|e('html') }}{% else %}{{ _file.DOWNLOAD_NAME }}{% endif %}
-
{_file.COMMENT}
-
- - - -
-
{% if _file.COMMENT %}{{ _file.COMMENT|e('html') }}{% else %}{{ _file.DOWNLOAD_NAME }}{% endif %}
-
{_file.COMMENT}
-
{_file.DOWNLOAD_NAME} ({_file.FILESIZE} {_file.SIZE_LANG}) {_file.L_DOWNLOAD_COUNT}
-
- - - -
-
{_file.UPLOAD_ICON} {_file.DOWNLOAD_NAME}
-
{_file.COMMENT}
-
({_file.FILESIZE} {_file.SIZE_LANG}) {_file.L_DOWNLOAD_COUNT}
-
- - - - - - diff --git a/install/update/new/styles/prosilver/template/bbcode.html b/install/update/new/styles/prosilver/template/bbcode.html deleted file mode 100644 index b37ba23..0000000 --- a/install/update/new/styles/prosilver/template/bbcode.html +++ /dev/null @@ -1,79 +0,0 @@ -
    -
      -
    - -
      -
    - -
  • -
  • - -
    {USERNAME} {L_WROTE}{L_COLON} -
    -
    - -
    - - uncited - -
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    -
    -
    - -
    -
    - - -

    {L_CODE}{L_COLON} {L_SELECT_ALL_CODE}

    
    -
    - -
    -
    - - - - - - - - - - -{TEXT} - -{TEXT} - -{L_IMAGE} - -{DESCRIPTION} - -{DESCRIPTION} - - diff --git a/install/update/new/styles/prosilver/template/captcha_recaptcha.html b/install/update/new/styles/prosilver/template/captcha_recaptcha.html deleted file mode 100644 index 8fc7faa..0000000 --- a/install/update/new/styles/prosilver/template/captcha_recaptcha.html +++ /dev/null @@ -1,9 +0,0 @@ - - - {% INCLUDEJS RECAPTCHA_SERVER ~ '.js?onload=phpbbRecaptchaOnLoad&hl=' ~ lang('RECAPTCHA_LANG') %} -
    - -{L_RECAPTCHA_NOT_AVAILABLE} - diff --git a/install/update/new/styles/prosilver/template/forum_fn.js b/install/update/new/styles/prosilver/template/forum_fn.js deleted file mode 100644 index 2e39365..0000000 --- a/install/update/new/styles/prosilver/template/forum_fn.js +++ /dev/null @@ -1,937 +0,0 @@ -/* global phpbb */ - -/** -* phpBB3 forum functions -*/ - -/** -* Find a member -*/ -function find_username(url) { - 'use strict'; - - popup(url, 760, 570, '_usersearch'); - return false; -} - -/** -* Window popup -*/ -function popup(url, width, height, name) { - 'use strict'; - - if (!name) { - name = '_popup'; - } - - window.open(url.replace(/&/g, '&'), name, 'height=' + height + ',resizable=yes,scrollbars=yes, width=' + width); - return false; -} - -/** -* Jump to page -*/ -function pageJump(item) { - 'use strict'; - - var page = parseInt(item.val(), 10), - perPage = item.attr('data-per-page'), - baseUrl = item.attr('data-base-url'), - startName = item.attr('data-start-name'); - - if (page !== null && !isNaN(page) && page === Math.floor(page) && page > 0) { - if (baseUrl.indexOf('?') === -1) { - document.location.href = baseUrl + '?' + startName + '=' + ((page - 1) * perPage); - } else { - document.location.href = baseUrl.replace(/&/g, '&') + '&' + startName + '=' + ((page - 1) * perPage); - } - } -} - -/** -* Mark/unmark checklist -* id = ID of parent container, name = name prefix, state = state [true/false] -*/ -function marklist(id, name, state) { - 'use strict'; - - jQuery('#' + id + ' input[type=checkbox][name]').each(function() { - var $this = jQuery(this); - if ($this.attr('name').substr(0, name.length) === name && !$this.prop('disabled')) { - $this.prop('checked', state); - } - }); -} - -/** -* Resize viewable area for attached image or topic review panel (possibly others to come) -* e = element -*/ -function viewableArea(e, itself) { - 'use strict'; - - if (!e) { - return; - } - - if (!itself) { - e = e.parentNode; - } - - if (!e.vaHeight) { - // Store viewable area height before changing style to auto - e.vaHeight = e.offsetHeight; - e.vaMaxHeight = e.style.maxHeight; - e.style.height = 'auto'; - e.style.maxHeight = 'none'; - e.style.overflow = 'visible'; - } else { - // Restore viewable area height to the default - e.style.height = e.vaHeight + 'px'; - e.style.overflow = 'auto'; - e.style.maxHeight = e.vaMaxHeight; - e.vaHeight = false; - } -} - -/** -* Alternate display of subPanels -*/ -jQuery(function($) { - 'use strict'; - - $('.sub-panels').each(function() { - - var $childNodes = $('a[data-subpanel]', this), - panels = $childNodes.map(function () { - return this.getAttribute('data-subpanel'); - }), - showPanel = this.getAttribute('data-show-panel'); - - if (panels.length) { - activateSubPanel(showPanel, panels); - $childNodes.click(function () { - activateSubPanel(this.getAttribute('data-subpanel'), panels); - return false; - }); - } - }); -}); - -/** -* Activate specific subPanel -*/ -function activateSubPanel(p, panels) { - 'use strict'; - - var i, showPanel; - - if (typeof p === 'string') { - showPanel = p; - } - $('input[name="show_panel"]').val(showPanel); - - if (typeof panels === 'undefined') { - panels = jQuery('.sub-panels a[data-subpanel]').map(function() { - return this.getAttribute('data-subpanel'); - }); - } - - for (i = 0; i < panels.length; i++) { - jQuery('#' + panels[i]).css('display', panels[i] === showPanel ? 'block' : 'none'); - jQuery('#' + panels[i] + '-tab').toggleClass('activetab', panels[i] === showPanel); - } -} - -function selectCode(a) { - 'use strict'; - - // Get ID of code block - var e = a.parentNode.parentNode.getElementsByTagName('CODE')[0]; - var s, r; - - // Not IE and IE9+ - if (window.getSelection) { - s = window.getSelection(); - // Safari and Chrome - if (s.setBaseAndExtent) { - var l = (e.innerText.length > 1) ? e.innerText.length - 1 : 1; - try { - s.setBaseAndExtent(e, 0, e, l); - } catch (error) { - r = document.createRange(); - r.selectNodeContents(e); - s.removeAllRanges(); - s.addRange(r); - } - } - // Firefox and Opera - else { - // workaround for bug # 42885 - if (window.opera && e.innerHTML.substring(e.innerHTML.length - 4) === '
    ') { - e.innerHTML = e.innerHTML + ' '; - } - - r = document.createRange(); - r.selectNodeContents(e); - s.removeAllRanges(); - s.addRange(r); - } - } - // Some older browsers - else if (document.getSelection) { - s = document.getSelection(); - r = document.createRange(); - r.selectNodeContents(e); - s.removeAllRanges(); - s.addRange(r); - } - // IE - else if (document.selection) { - r = document.body.createTextRange(); - r.moveToElementText(e); - r.select(); - } -} - -var inAutocomplete = false; -var lastKeyEntered = ''; - -/** -* Check event key -*/ -function phpbbCheckKey(event) { - 'use strict'; - - // Keycode is array down or up? - if (event.keyCode && (event.keyCode === 40 || event.keyCode === 38)) { - inAutocomplete = true; - } - - // Make sure we are not within an "autocompletion" field - if (inAutocomplete) { - // If return pressed and key changed we reset the autocompletion - if (!lastKeyEntered || lastKeyEntered === event.which) { - inAutocomplete = false; - return true; - } - } - - // Keycode is not return, then return. ;) - if (event.which !== 13) { - lastKeyEntered = event.which; - return true; - } - - return false; -} - -/** -* Apply onkeypress event for forcing default submit button on ENTER key press -*/ -jQuery(function($) { - 'use strict'; - - $('form input[type=text], form input[type=password]').on('keypress', function (e) { - var defaultButton = $(this).parents('form').find('input[type=submit].default-submit-action'); - - if (!defaultButton || defaultButton.length <= 0) { - return true; - } - - if (phpbbCheckKey(e)) { - return true; - } - - if ((e.which && e.which === 13) || (e.keyCode && e.keyCode === 13)) { - defaultButton.click(); - return false; - } - - return true; - }); -}); - -/** -* Functions for user search popup -*/ -function insertUser(formId, value) { - 'use strict'; - - var $form = jQuery(formId), - formName = $form.attr('data-form-name'), - fieldName = $form.attr('data-field-name'), - item = opener.document.forms[formName][fieldName]; - - if (item.value.length && item.type === 'textarea') { - value = item.value + '\n' + value; - } - - item.value = value; -} - -function insert_marked_users(formId, users) { - 'use strict'; - - $(users).filter(':checked').each(function() { - insertUser(formId, this.value); - }); - - window.close(); -} - -function insert_single_user(formId, user) { - 'use strict'; - - insertUser(formId, user); - window.close(); -} - -/** -* Parse document block -*/ -function parseDocument($container) { - 'use strict'; - - var test = document.createElement('div'), - oldBrowser = (typeof test.style.borderRadius === 'undefined'), - $body = $('body'); - - /** - * Reset avatar dimensions when changing URL or EMAIL - */ - $container.find('input[data-reset-on-edit]').on('keyup', function() { - $(this.getAttribute('data-reset-on-edit')).val(''); - }); - - /** - * Pagination - */ - $container.find('.pagination .page-jump-form :button').click(function() { - var $input = $(this).siblings('input.inputbox'); - pageJump($input); - }); - - $container.find('.pagination .page-jump-form input.inputbox').on('keypress', function(event) { - if (event.which === 13 || event.keyCode === 13) { - event.preventDefault(); - pageJump($(this)); - } - }); - - $container.find('.pagination .dropdown-trigger').click(function() { - var $dropdownContainer = $(this).parent(); - // Wait a little bit to make sure the dropdown has activated - setTimeout(function() { - if ($dropdownContainer.hasClass('dropdown-visible')) { - $dropdownContainer.find('input.inputbox').focus(); - } - }, 100); - }); - - /** - * Adjust HTML code for IE8 and older versions - */ - // if (oldBrowser) { - // // Fix .linklist.bulletin lists - // $container - // .find('ul.linklist.bulletin > li') - // .filter(':first-child, .rightside:last-child') - // .addClass('no-bulletin'); - // } - - /** - * Resize navigation (breadcrumbs) block to keep all links on same line - */ - $container.find('.navlinks').each(function() { - var $this = $(this), - $left = $this.children().not('.rightside'), - $right = $this.children('.rightside'); - - if ($left.length !== 1 || !$right.length) { - return; - } - - function resize() { - var width = 0, - diff = $left.outerWidth(true) - $left.width(), - minWidth = Math.max($this.width() / 3, 240), - maxWidth; - - $right.each(function() { - var $this = $(this); - if ($this.is(':visible')) { - width += $this.outerWidth(true); - } - }); - - maxWidth = $this.width() - width - diff; - $left.css('max-width', Math.floor(Math.max(maxWidth, minWidth)) + 'px'); - } - - resize(); - $(window).resize(resize); - }); - - /** - * Makes breadcrumbs responsive - */ - $container.find('.breadcrumbs:not([data-skip-responsive])').each(function() { - var $this = $(this), - $links = $this.find('.crumb'), - length = $links.length, - classes = ['wrapped-max', 'wrapped-wide', 'wrapped-medium', 'wrapped-small', 'wrapped-tiny'], - classesLength = classes.length, - maxHeight = 0, - lastWidth = false, - wrapped = false; - - // Set tooltips - $this.find('a').each(function() { - var $link = $(this); - $link.attr('title', $link.text()); - }); - - // Function that checks breadcrumbs - function check() { - var height = $this.height(), - width; - - // Test max-width set in code for .navlinks above - width = parseInt($this.css('max-width'), 10); - if (!width) { - width = $body.width(); - } - - maxHeight = parseInt($this.css('line-height'), 10); - $links.each(function() { - if ($(this).height() > 0) { - maxHeight = Math.max(maxHeight, $(this).outerHeight(true)); - } - }); - - if (height <= maxHeight) { - if (!wrapped || lastWidth === false || lastWidth >= width) { - return; - } - } - lastWidth = width; - - if (wrapped) { - $this.removeClass('wrapped').find('.crumb.wrapped').removeClass('wrapped ' + classes.join(' ')); - if ($this.height() <= maxHeight) { - return; - } - } - - wrapped = true; - $this.addClass('wrapped'); - if ($this.height() <= maxHeight) { - return; - } - - for (var i = 0; i < classesLength; i++) { - for (var j = length - 1; j >= 0; j--) { - $links.eq(j).addClass('wrapped ' + classes[i]); - if ($this.height() <= maxHeight) { - return; - } - } - } - } - - // Run function and set event - check(); - $(window).resize(check); - }); - - /** - * Responsive link lists - */ - var selector = '.linklist:not(.navlinks, [data-skip-responsive]),' + - '.postbody .post-buttons:not([data-skip-responsive])'; - $container.find(selector).each(function() { - var $this = $(this), - filterSkip = '.breadcrumbs, [data-skip-responsive]', - filterLast = '.edit-icon, .quote-icon, [data-last-responsive]', - $linksAll = $this.children(), - $linksNotSkip = $linksAll.not(filterSkip), // All items that can potentially be hidden - $linksFirst = $linksNotSkip.not(filterLast), // The items that will be hidden first - $linksLast = $linksNotSkip.filter(filterLast), // The items that will be hidden last - persistent = $this.attr('id') === 'nav-main', // Does this list already have a menu (such as quick-links)? - html = '', - slack = 3; // Vertical slack space (in pixels). Determines how sensitive the script is in determining whether a line-break has occurred. - - // Add a hidden drop-down menu to each links list (except those that already have one) - if (!persistent) { - if ($linksNotSkip.is('.rightside')) { - $linksNotSkip.filter('.rightside:first').before(html); - $this.children('.responsive-menu').addClass('rightside'); - } else { - $this.append(html); - } - } - - // Set some object references and initial states - var $menu = $this.children('.responsive-menu'), - $menuContents = $menu.find('.dropdown-contents'), - persistentContent = $menuContents.find('li:not(.separator)').length, - lastWidth = false, - compact = false, - responsive1 = false, - responsive2 = false, - copied1 = false, - copied2 = false, - maxHeight = 0; - - // Find the tallest element in the list (we assume that all elements are roughly the same height) - $linksAll.each(function() { - if (!$(this).height()) { - return; - } - maxHeight = Math.max(maxHeight, $(this).outerHeight(true)); - }); - if (maxHeight < 1) { - return; // Shouldn't be possible, but just in case, abort - } else { - maxHeight = maxHeight + slack; - } - - function check() { - var width = $body.width(); - // We can't make it any smaller than this, so just skip - if (responsive2 && compact && (width <= lastWidth)) { - return; - } - lastWidth = width; - - // Reset responsive and compact layout - if (responsive1 || responsive2) { - $linksNotSkip.removeClass('hidden'); - $menuContents.children('.clone').addClass('hidden'); - responsive1 = responsive2 = false; - } - if (compact) { - $this.removeClass('compact'); - compact = false; - } - - // Unhide the quick-links menu if it has "persistent" content - if (persistent && persistentContent) { - $menu.removeClass('hidden'); - } else { - $menu.addClass('hidden'); - } - - // Nothing to resize if block's height is not bigger than tallest element's height - if ($this.height() <= maxHeight) { - return; - } - - // STEP 1: Compact - if (!compact) { - $this.addClass('compact'); - compact = true; - } - if ($this.height() <= maxHeight) { - return; - } - - // STEP 2: First responsive set - compact - if (compact) { - $this.removeClass('compact'); - compact = false; - } - // Copy the list items to the dropdown - if (!copied1) { - var $clones1 = $linksFirst.clone(); - $menuContents.prepend($clones1.addClass('clone clone-first').removeClass('leftside rightside')); - - if ($this.hasClass('post-buttons')) { - $('.button', $menuContents).removeClass('button'); - $('.sr-only', $menuContents).removeClass('sr-only'); - $('.js-responsive-menu-link').addClass('button').addClass('button-icon-only'); - $('.js-responsive-menu-link .icon').removeClass('fa-bars').addClass('fa-ellipsis-h'); - } - copied1 = true; - } - if (!responsive1) { - $linksFirst.addClass('hidden'); - responsive1 = true; - $menuContents.children('.clone-first').removeClass('hidden'); - $menu.removeClass('hidden'); - } - if ($this.height() <= maxHeight) { - return; - } - - // STEP 3: First responsive set + compact - if (!compact) { - $this.addClass('compact'); - compact = true; - } - if ($this.height() <= maxHeight) { - return; - } - - // STEP 4: Last responsive set - compact - if (!$linksLast.length) { - return; // No other links to hide, can't do more - } - if (compact) { - $this.removeClass('compact'); - compact = false; - } - // Copy the list items to the dropdown - if (!copied2) { - var $clones2 = $linksLast.clone(); - $menuContents.prepend($clones2.addClass('clone clone-last').removeClass('leftside rightside')); - copied2 = true; - } - if (!responsive2) { - $linksLast.addClass('hidden'); - responsive2 = true; - $menuContents.children('.clone-last').removeClass('hidden'); - } - if ($this.height() <= maxHeight) { - return; - } - - // STEP 5: Last responsive set + compact - if (!compact) { - $this.addClass('compact'); - compact = true; - } - } - - if (!persistent) { - phpbb.registerDropdown($menu.find('a.js-responsive-menu-link'), $menu.find('.dropdown'), false); - } - - // If there are any images in the links list, run the check again after they have loaded - $linksAll.find('img').each(function() { - $(this).on('load', function() { - check(); - }); - }); - - check(); - $(window).resize(check); - }); - - /** - * Do not run functions below for old browsers - */ - if (oldBrowser) { - return; - } - - /** - * Adjust topiclist lists with check boxes - */ - $container.find('ul.topiclist dd.mark').siblings('dt').children('.list-inner').addClass('with-mark'); - - /** - * Appends contents of all extra columns to first column in - * .topiclist lists for mobile devices. Copies contents as is. - * - * To add that functionality to .topiclist list simply add - * responsive-show-all to list of classes - */ - $container.find('.topiclist.responsive-show-all > li > dl').each(function() { - var $this = $(this), - $block = $this.find('dt .responsive-show:last-child'), - first = true; - - // Create block that is visible only on mobile devices - if (!$block.length) { - $this.find('dt > .list-inner').append('
- -
-
- - - - -
-
- -
    - - - - - -
  • - -
    -
    - -
    - - - - - - {forumrow.FORUM_IMAGE} - - - {forumrow.FORUM_NAME} -
    {forumrow.FORUM_DESC} - -
    {forumrow.L_MODERATOR_STR}{L_COLON} {forumrow.MODERATORS} - - - -
    {forumrow.L_SUBFORUM_STR}{L_COLON} - - - {forumrow.subforum.SUBFORUM_NAME}{L_COMMA_SEPARATOR} - - - - - - - -
    -
    - -
    {L_REDIRECTS}{L_COLON} {forumrow.CLICKS}
    - -
    {forumrow.TOPICS} {L_TOPICS}
    -
    {forumrow.POSTS} {L_POSTS}
    -
    - - - - {L_TOPICS_UNAPPROVED} - - - - {L_POSTS_UNAPPROVED_FORUM} - - - - {L_LAST_POST} - - - {forumrow.LAST_POST_SUBJECT_TRUNCATED}
    - - {L_POST_BY_AUTHOR} {forumrow.LAST_POSTER_FULL} - - - {L_VIEW_LATEST_POST} - - -
    - - {% if forumrow.U_UNAPPROVED_TOPICS %} - {{ lang('TOPIC_UNAPPROVED_FORUM', forumrow.TOPICS) }} - {% else %} - {{ lang('NO_POSTS') }} - {% endif %} - -
    -
    - -
     
    - -
    - -
  • - - - - -
- -
-
- - - - -
-
- {L_NO_FORUMS} -
-
- diff --git a/install/update/new/styles/prosilver/template/mcp_forum.html b/install/update/new/styles/prosilver/template/mcp_forum.html deleted file mode 100644 index 82df5d5..0000000 --- a/install/update/new/styles/prosilver/template/mcp_forum.html +++ /dev/null @@ -1,155 +0,0 @@ - - - - - -

{L_FORUM}{L_COLON} {FORUM_NAME}

- -
- -
-
- -
- -
- - -
    -
  • -
    -
    {L_TOPICS}
    -
    {L_REPLIES}
    -
    {L_LAST_POST}
    -
    {L_MARK}
    -
    -
  • -
-
    - - -
  • -
    -
    style="background-image: url({T_ICONS_PATH}{topicrow.TOPIC_ICON_IMG}); background-repeat: no-repeat;"> - -
    - - [ {L_SELECT_MERGE} ]   - - {topicrow.TOPIC_TITLE} - - - - {L_TOPIC_UNAPPROVED} - - - - - {L_TOPIC_DELETED} - - - - - {L_TOPIC_REPORTED} - - -  [ {L_DELETE_SHADOW_TOPIC} ] -
    - - - - - - - - -
    - - {% EVENT topiclist_row_topic_by_author_before %} - {L_POST_BY_AUTHOR} {topicrow.TOPIC_AUTHOR_FULL} » {topicrow.FIRST_POST_TIME} - {% EVENT topiclist_row_topic_by_author_after %} -
    - -
    -
    -
    {topicrow.REPLIES} {L_REPLIES}
    -
    {L_LAST_POST} {L_POST_BY_AUTHOR} {topicrow.LAST_POST_AUTHOR_FULL}
    {topicrow.LAST_POST_TIME}
    - -
    - checked="checked" />  -
    - -
    -
  • - -
- -
    -
  • {L_NO_TOPICS}

  • -
- - -
- - - -
- -
-
- - -
- - - - - - {S_FORM_TOKEN} -
- -
- - diff --git a/install/update/new/styles/prosilver/template/mcp_move.html b/install/update/new/styles/prosilver/template/mcp_move.html deleted file mode 100644 index 63197ef..0000000 --- a/install/update/new/styles/prosilver/template/mcp_move.html +++ /dev/null @@ -1,73 +0,0 @@ - - -

{MESSAGE_TITLE}

-

{MESSAGE_TEXT}

- -

{ADDITIONAL_MSG}

- - - - - - - - - - - -
-   - -
- - - - - - - -
- -
-
- -
-

{MESSAGE_TITLE}

-

{ADDITIONAL_MSG}

- -
- {% EVENT mcp_move_destination_forum_before %} -
-
-
-
-
-
- {% EVENT mcp_move_destination_forum_after %} -
-
 
-
{MESSAGE_TEXT}
-
-
- -
- {S_HIDDEN_FIELDS}  - - {S_FORM_TOKEN} -
- -
- -
-
-
- - - diff --git a/install/update/new/styles/prosilver/template/mcp_topic.html b/install/update/new/styles/prosilver/template/mcp_topic.html deleted file mode 100644 index 889cab8..0000000 --- a/install/update/new/styles/prosilver/template/mcp_topic.html +++ /dev/null @@ -1,202 +0,0 @@ - - - - -
- -
-
- -
-
-

{L_POSTS_PER_PAGE_EXPLAIN}
-
-
-
-
-
{S_SELECT_SORT_DAYS}  
-
-
- - -
-

{L_SPLIT_TOPIC_EXPLAIN}

- - -
-
-
-
-
- - - -
-
-
-
- -
-
-
-
-
- - - -
-

{L_MERGE_TOPIC_EXPLAIN}

-
-
-
- - {L_SELECT_TOPIC} -
-
{TO_TOPIC_INFO}
-
-
- - -
-
- -
-
- -

- {L_EXPAND_VIEW} - {L_TOPIC_REVIEW}{L_COLON} {TOPIC_TITLE} -

- -
- - -
-
- -
- - - -

{postrow.POST_SUBJECT}

- - - -

- - {postrow.MINI_POST} - {L_POSTED} {postrow.POST_DATE} {L_POST_BY_AUTHOR} {% EVENT mcp_topic_post_author_full_prepend %}{postrow.POST_AUTHOR_FULL}{% EVENT mcp_topic_post_author_full_append %} [ {L_POST_DETAILS} ] -

- - - -

- {L_POST_UNAPPROVED} -

- - - -

- {L_POST_DELETED} -

- - - -

- {L_POST_REPORTED} -

- - -
{postrow.MESSAGE}
- - - - -
-
{L_ATTACHMENTS}
- -
{postrow.attachment.DISPLAY_ATTACHMENT}
- -
- - - - -
- -
-
- -
- -
- -
- -
- -
-
- -
-   - - -{S_HIDDEN_FIELDS} -{S_FORM_TOKEN} -
- -
- - diff --git a/install/update/new/styles/prosilver/template/memberlist_body.html b/install/update/new/styles/prosilver/template/memberlist_body.html deleted file mode 100644 index b8ff092..0000000 --- a/install/update/new/styles/prosilver/template/memberlist_body.html +++ /dev/null @@ -1,190 +0,0 @@ - - - -
- - - - - - - - -{% EVENT memberlist_body_page_header_after %} - - - {% EVENT memberlist_body_group_name_before %} -

style="color:#{GROUP_COLOR};">{GROUP_NAME}

- {% EVENT memberlist_body_group_name_after %} - -

{L_MANAGE_GROUP}

- -

{GROUP_DESC} {GROUP_TYPE}

- - {% EVENT memberlist_body_group_desc_after %} - -

- {AVATAR_IMG} - {% EVENT memberlist_body_group_rank_before %} - {% if RANK_IMG %}{{ RANK_IMG }}{% endif %} - {% if GROUP_RANK %} - {% if not RANK_IMG %} - {{ lang('GROUP_RANK') ~ lang('COLON') }} - {% endif %} - {{ GROUP_RANK }} - {% endif %} - {% EVENT memberlist_body_group_rank_after %} -

- - {% EVENT memberlist_body_page_title_before %} -

{PAGE_TITLE}{L_COLON} {SEARCH_WORDS}

- -
- - - -
- - - -
-
- - - - - - - - - - {% EVENT memberlist_body_memberlist_after %} - - - - - - - - - - - - - - -
{L_RANK}{L_GROUP_LEADER}{L_USERNAME}{L_POSTS}{L_COMMA_SEPARATOR} {custom_fields.PROFILE_FIELD_NAME}{L_JOINED}{L_LAST_ACTIVE}
 
- -
-
- -
-
- - - - - - - - - - - {% EVENT memberlist_body_leaders_set_after %} - - - - - - - {% EVENT memberlist_body_show_group_after %} - - - - - - - - - - - - - - - {% EVENT memberlist_body_memberrow_after %} - - - - - - - -
{L_RANK}{L_GROUP_MEMBERS}{L_USERNAME}{L_POSTS}{% for field in custom_fields %}{% if not loop.first %}{L_COMMA_SEPARATOR} {% endif %}{{ field.PROFILE_FIELD_NAME }}{% endfor %}{L_JOINED}{L_LAST_ACTIVE}{L_GROUP_MEMBERS}{L_POSTS}{L_COMMA_SEPARATOR} {custom_fields.PROFILE_FIELD_NAME}{L_JOINED}{L_LAST_ACTIVE}
{memberrow.RANK_IMG}{memberrow.RANK_TITLE} {memberrow.USERNAME_FULL} ({L_INACTIVE})
{L_SELECT} ]
{memberrow.POSTS}{memberrow.POSTS} - {%- for field in memberrow.custom_fields -%} - - {%- else -%} -   - {%- endfor -%} - {memberrow.JOINED}{memberrow.LAST_ACTIVE} 
{L_NO_MEMBERS}
- -
-
- - -
- - -
- - - -
-
- - - -
- - - -
- - -
- -
- -
- -{% EVENT memberlist_body_page_footer_before %} - - - - - - - diff --git a/install/update/new/styles/prosilver/template/memberlist_search.html b/install/update/new/styles/prosilver/template/memberlist_search.html deleted file mode 100644 index 34915eb..0000000 --- a/install/update/new/styles/prosilver/template/memberlist_search.html +++ /dev/null @@ -1,87 +0,0 @@ -

{L_FIND_USERNAME}

- -
-
-
- -

{L_FIND_USERNAME_EXPLAIN}

- - -
-
-
-
- - -
-
- -
-
-
-
- - -
-
-
-
- -
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
- -
-
-
-
- -
-
-
-
- - -
- -
- -
- -
-   - - {S_FORM_TOKEN} -
- -
-
- -
diff --git a/install/update/new/styles/prosilver/template/navbar_header.html b/install/update/new/styles/prosilver/template/navbar_header.html deleted file mode 100644 index 4a1a436..0000000 --- a/install/update/new/styles/prosilver/template/navbar_header.html +++ /dev/null @@ -1,212 +0,0 @@ - diff --git a/install/update/new/styles/prosilver/template/overall_footer.html b/install/update/new/styles/prosilver/template/overall_footer.html deleted file mode 100644 index d1b8863..0000000 --- a/install/update/new/styles/prosilver/template/overall_footer.html +++ /dev/null @@ -1,120 +0,0 @@ - -
- - - - - -
- -
- - {RUN_CRON_TASK} -
- - - - - - - - - - - - - - - - - - -{$SCRIPTS} - - - - - diff --git a/install/update/new/styles/prosilver/template/overall_header.html b/install/update/new/styles/prosilver/template/overall_header.html deleted file mode 100644 index 2867802..0000000 --- a/install/update/new/styles/prosilver/template/overall_header.html +++ /dev/null @@ -1,133 +0,0 @@ - - - - - - -{META} -<!-- IF UNREAD_NOTIFICATIONS_COUNT -->({UNREAD_NOTIFICATIONS_COUNT}) <!-- ENDIF --><!-- IF not S_VIEWTOPIC and not S_VIEWFORUM -->{SITENAME} - <!-- ENDIF --><!-- IF S_IN_MCP -->{L_MCP} - <!-- ELSEIF S_IN_UCP -->{L_UCP} - <!-- ENDIF -->{PAGE_TITLE}<!-- IF S_VIEWTOPIC or S_VIEWFORUM --> - {SITENAME}<!-- ENDIF --> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -{$STYLESHEETS} - - - - - - - - -
- - - - - - -
- -
-
- {L_INFORMATION}{L_COLON} {L_BOARD_DISABLED} -
-
- - - diff --git a/install/update/new/styles/prosilver/template/plupload.html b/install/update/new/styles/prosilver/template/plupload.html deleted file mode 100644 index 9425b7d..0000000 --- a/install/update/new/styles/prosilver/template/plupload.html +++ /dev/null @@ -1,75 +0,0 @@ - - - diff --git a/install/update/new/styles/prosilver/template/posting_attach_body.html b/install/update/new/styles/prosilver/template/posting_attach_body.html deleted file mode 100644 index 0363fe0..0000000 --- a/install/update/new/styles/prosilver/template/posting_attach_body.html +++ /dev/null @@ -1,93 +0,0 @@ -
-
- -

{L_ADD_ATTACHMENT_EXPLAIN}

- -
-
-
-
- - -
-
-
-
-
-
-
- -
- -
- - {% EVENT posting_attach_body_file_list_before %} -
-
- - - - - - - - - - - - - - - - - {% EVENT posting_attach_body_attach_row_before %} - - {% EVENT posting_attach_body_attach_row_prepend %} - - - - - - - {% EVENT posting_attach_body_attach_row_append %} - - {% EVENT posting_attach_body_attach_row_after %} - -
{L_PLUPLOAD_FILENAME}{L_FILE_COMMENT}{L_PLUPLOAD_SIZE}{L_PLUPLOAD_STATUS}
- - - {% if S_BBCODE_ALLOWED %} {% endif %} - - - - - - - - - - - - -
- {attach_row.FILENAME} - {% EVENT posting_attach_body_attach_row_controls_prepend %} - - {% if S_BBCODE_ALLOWED and S_INLINE_ATTACHMENT_OPTIONS %} {% endif %} - - - {% EVENT posting_attach_body_attach_row_controls_append %} - - - - {attach_row.S_HIDDEN} - - {attach_row.FILESIZE} - - -
-
-
- {% EVENT posting_attach_body_file_list_after %} -
-
diff --git a/install/update/new/styles/prosilver/template/posting_buttons.html b/install/update/new/styles/prosilver/template/posting_buttons.html deleted file mode 100644 index 1564b5f..0000000 --- a/install/update/new/styles/prosilver/template/posting_buttons.html +++ /dev/null @@ -1,105 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - diff --git a/install/update/new/styles/prosilver/template/posting_layout.html b/install/update/new/styles/prosilver/template/posting_layout.html deleted file mode 100644 index 7c9deb5..0000000 --- a/install/update/new/styles/prosilver/template/posting_layout.html +++ /dev/null @@ -1,65 +0,0 @@ - - - -

{TOPIC_TITLE}

- -

{FORUM_NAME}

- - - -
-
- - - {L_FORUM_RULES} - - {L_FORUM_RULES}
- {FORUM_RULES} - - -
-
- - -
- - -
-
- -

{L_INFORMATION}

-

{L_DRAFT_LOADED}

- -
-
- - - - - - - - -
-
- -

{L_POST_A}

- - - - - {S_FORM_TOKEN} -
-
- - - - - - - - - -
- - diff --git a/install/update/new/styles/prosilver/template/posting_poll_body.html b/install/update/new/styles/prosilver/template/posting_poll_body.html deleted file mode 100644 index 7956496..0000000 --- a/install/update/new/styles/prosilver/template/posting_poll_body.html +++ /dev/null @@ -1,53 +0,0 @@ -
-
- - -

{L_ADD_POLL_EXPLAIN}

- - -
- -
-
-
-
- - - -
-
-
-
-
-

{L_POLL_OPTIONS_EXPLAIN}
-
-
- -
- -
-
-
-
{L_POLL_MAX_OPTIONS_EXPLAIN}
-
-
-
-
-
{L_POLL_FOR_EXPLAIN}
-
- - -
- -
-
-
-
- - - - -
- -
-
diff --git a/install/update/new/styles/prosilver/template/posting_review.html b/install/update/new/styles/prosilver/template/posting_review.html deleted file mode 100644 index e5d285e..0000000 --- a/install/update/new/styles/prosilver/template/posting_review.html +++ /dev/null @@ -1,44 +0,0 @@ -

{L_POST_REVIEW}

- -

{L_POST_REVIEW_EXPLAIN}

- - - -
-
- {post_review_row.L_IGNORE_POST} - -
-
- - -
-

{post_review_row.POST_SUBJECT}

-

- - {post_review_row.MINI_POST} - - - {post_review_row.MINI_POST} - - - {L_POST_BY_AUTHOR} {post_review_row.POST_AUTHOR_FULL} » {post_review_row.POST_DATE} -

-
{post_review_row.MESSAGE}
- - -
-
{L_ATTACHMENTS}
- -
{post_review_row.attachment.DISPLAY_ATTACHMENT}
- -
- - -
- -
-
- - -
diff --git a/install/update/new/styles/prosilver/template/posting_topic_review.html b/install/update/new/styles/prosilver/template/posting_topic_review.html deleted file mode 100644 index 209dadf..0000000 --- a/install/update/new/styles/prosilver/template/posting_topic_review.html +++ /dev/null @@ -1,89 +0,0 @@ - -

- {L_EXPAND_VIEW} - {L_TOPIC_REVIEW}{L_COLON} {TOPIC_TITLE} -

- -
- - - - -
-
- {topic_review_row.L_IGNORE_POST} - -
-
- {topic_review_row.L_DELETE_POST} - -
-
- - -
-

{topic_review_row.POST_SUBJECT}

- - - - - - -

- - {topic_review_row.MINI_POST} - - - {topic_review_row.MINI_POST} - - - {L_POST_BY_AUTHOR} {topic_review_row.POST_AUTHOR_FULL} » {topic_review_row.POST_DATE} -

- - -
{topic_review_row.MESSAGE}
- - - - -
-
{L_ATTACHMENTS}
- -
{topic_review_row.attachment.DISPLAY_ATTACHMENT}
- -
- - - - - -
-
-
- -
- -
- -

- - {L_BACK_TO_TOP} - -

diff --git a/install/update/new/styles/prosilver/template/search_results.html b/install/update/new/styles/prosilver/template/search_results.html deleted file mode 100644 index 9ee13a4..0000000 --- a/install/update/new/styles/prosilver/template/search_results.html +++ /dev/null @@ -1,244 +0,0 @@ - - - - -

{SEARCH_TITLE}{SEARCH_MATCHES}{L_COLON} {SEARCH_WORDS}

-

{L_SEARCHED_QUERY}{L_COLON} {SEARCHED_QUERY}

-

{L_IGNORED_TERMS}{L_COLON} {IGNORED_WORDS}

-

{L_PHRASE_SEARCH_DISABLED}

- - - - - - - - - - -
- - - - - - - - -
- - - - - -
- -
-
    -
  • -
    -
    {L_TOPICS}
    -
    {L_REPLIES}
    -
    {L_VIEWS}
    -
    {L_LAST_POST}
    -
    -
  • -
- - -
-
- -
-
- {L_NO_SEARCH_RESULTS} -
-
- - - - - - -
-
- - -
- {searchresults.L_IGNORE_POST} -
- -
- -
{L_POST_BY_AUTHOR} {searchresults.POST_AUTHOR_FULL}
-
{searchresults.POST_DATE}
-
{L_FORUM}{L_COLON} {searchresults.FORUM_TITLE}
-
{L_TOPIC}{L_COLON} {searchresults.TOPIC_TITLE}
- -
{L_REPLIES}{L_COLON} {searchresults.TOPIC_REPLIES}
-
{L_VIEWS}{L_COLON} {searchresults.TOPIC_VIEWS}
- -
- -
-

{searchresults.POST_SUBJECT}

-
{searchresults.MESSAGE}
- -
- - - - - - -
-
- - -
-
- {L_NO_SEARCH_RESULTS} -
-
- - - -
- -
- -
- - - -
- - - - diff --git a/install/update/new/styles/prosilver/template/simple_footer.html b/install/update/new/styles/prosilver/template/simple_footer.html deleted file mode 100644 index fde162a..0000000 --- a/install/update/new/styles/prosilver/template/simple_footer.html +++ /dev/null @@ -1,40 +0,0 @@ -
- - - -
-
 
-
-
- -
- - - -

-
-
- - - -
-
-
- - - - - - - - - -{$SCRIPTS} - -{% EVENT simple_footer_body_after %} - - - diff --git a/install/update/new/styles/prosilver/template/ucp_agreement.html b/install/update/new/styles/prosilver/template/ucp_agreement.html deleted file mode 100644 index 7959925..0000000 --- a/install/update/new/styles/prosilver/template/ucp_agreement.html +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - -
-

- - {S_HIDDEN_FIELDS} -

-
- -
- - - -
- -
-
-
-

{SITENAME} - {L_REGISTRATION}

- -

{L_COPPA_BIRTHDAY}{L_TERMS_OF_USE}

- -
-
-
- -
-
-
- - - - -   - - - {S_HIDDEN_FIELDS} - {S_FORM_TOKEN} -
-
-
-
- - - -
-
-
-

{SITENAME} - {AGREEMENT_TITLE}

-

{AGREEMENT_TEXT}

-
-
-
- - - - diff --git a/install/update/new/styles/prosilver/template/ucp_attachments.html b/install/update/new/styles/prosilver/template/ucp_attachments.html deleted file mode 100644 index cfdbf9c..0000000 --- a/install/update/new/styles/prosilver/template/ucp_attachments.html +++ /dev/null @@ -1,83 +0,0 @@ - - -
- -

{L_TITLE}

- -
-
- -

{L_ATTACHMENTS_EXPLAIN}

- - -
- -
- - - - -
- - {S_FORM_TOKEN} - - -
- - -

{L_UCP_NO_ATTACHMENTS}

- - -
-
- - -
- - - {S_FORM_TOKEN} -
- -
- - diff --git a/install/update/new/styles/prosilver/template/ucp_avatar_options_upload.html b/install/update/new/styles/prosilver/template/ucp_avatar_options_upload.html deleted file mode 100644 index 666950e..0000000 --- a/install/update/new/styles/prosilver/template/ucp_avatar_options_upload.html +++ /dev/null @@ -1,11 +0,0 @@ -
-
-
-
- - -
-

{L_UPLOAD_AVATAR_URL_EXPLAIN}
-
-
- diff --git a/install/update/new/styles/prosilver/template/ucp_groups_manage.html b/install/update/new/styles/prosilver/template/ucp_groups_manage.html deleted file mode 100644 index adc8c61..0000000 --- a/install/update/new/styles/prosilver/template/ucp_groups_manage.html +++ /dev/null @@ -1,247 +0,0 @@ - - - style="color:#{GROUP_COLOR};">{L_USERGROUPS} :: {GROUP_NAME} - -
- -
-
- - -
-

{ERROR_MSG}

-
- - -

{L_GROUPS_EXPLAIN}

- - -

{L_GROUP_DETAILS}

- -
-
-
-
style="color: #{GROUP_COLOUR};">{GROUP_NAME} -
-
-
-
-
-
  
-
- -
-

{L_GROUP_TYPE_EXPLAIN}
-
- - - - -
-
- - - -
- -
-
- -
-
-

{L_GROUP_SETTINGS_SAVE}

- -
-
-

{L_GROUP_COLOR_EXPLAIN}
-
- -     - [ {L_COLOUR_SWATCH} ] - -
-
-
-
-
-
-
- -
-
- - - -
- {S_HIDDEN_FIELDS} -   - - {S_FORM_TOKEN} -
- - - - - - - - - - - - - - - - - - - - - - - - - -
{L_GROUP_LEAD}{L_GROUP_DEFAULT}{L_POSTS}{L_JOINED}{L_MARK}
{leader.USERNAME_FULL}{L_YES}{L_NO}{leader.USER_POSTS}{leader.JOINED} 
- - - - - - - - - - - - - - - - - - -
{L_GROUP_PENDING}{L_GROUP_DEFAULT}{L_POSTS}{L_JOINED}{L_MARK}
- - - - - - - - - - - - - - - - - - - - - - -
{L_GROUP_APPROVED}{L_GROUP_DEFAULT}{L_POSTS}{L_JOINED}{L_MARK}
{member.USERNAME_FULL}{L_YES}{L_NO}{member.USER_POSTS}{member.JOINED}
- - - - - - - - - - - -
{L_MEMBERS}
{L_GROUPS_NO_MEMBERS}
- - -
- -
- - -
-
- -
- - - -
- -
-
- -

{L_ADD_USERS}

- -

{L_ADD_USERS_UCP_EXPLAIN}

- -
-
-

{L_USER_GROUP_DEFAULT_EXPLAIN}
-
- - -
-
-
-

{L_USERNAMES_EXPLAIN}
-
-
{L_FIND_USERNAME}
-
-
- -
-
- -
- - {S_FORM_TOKEN} -
- - - - -
    -
  • -
    -
    {L_GROUP_LEADER}
    -
    {L_OPTIONS}
    -
    -
  • -
- - -

{L_NO_LEADERS}

- - -
-
- - - - - diff --git a/install/update/new/styles/prosilver/template/ucp_pm_history.html b/install/update/new/styles/prosilver/template/ucp_pm_history.html deleted file mode 100644 index b53eb0c..0000000 --- a/install/update/new/styles/prosilver/template/ucp_pm_history.html +++ /dev/null @@ -1,56 +0,0 @@ - -

- {L_EXPAND_VIEW} - {L_MESSAGE_HISTORY}{L_COLON} -

- - -
- - -
-
- -
-

class="current">{history_row.SUBJECT}

- - - - - - - - -

- {history_row.MINI_POST} {L_SENT_AT}{L_COLON} {history_row.SENT_DATE} -
- {L_MESSAGE_BY_AUTHOR} {history_row.MESSAGE_AUTHOR_FULL} -

-
{history_row.MESSAGE}{L_MESSAGE_REMOVED_FROM_OUTBOX}
- -
- -
-
- -
- - -
-

- - {L_BACK_TO_TOP} - -

diff --git a/install/update/new/styles/prosilver/template/ucp_pm_viewmessage_print.html b/install/update/new/styles/prosilver/template/ucp_pm_viewmessage_print.html deleted file mode 100644 index 41ff5b8..0000000 --- a/install/update/new/styles/prosilver/template/ucp_pm_viewmessage_print.html +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - -{META} -{SITENAME} • {PAGE_TITLE} - - - - - - -
- - - - -
-
{PAGE_NUMBER}
-
-

{SUBJECT}

-
{L_SENT_AT} {SENT_DATE}
-
{L_PM_FROM} {MESSAGE_AUTHOR}
- -
{L_TO} {to_recipient.NAME} 
- - -
{L_BCC} {bcc_recipient.NAME} 
- -
-
{MESSAGE}
-
-
-
- - -
- - - diff --git a/install/update/new/styles/prosilver/template/ucp_profile_profile_info.html b/install/update/new/styles/prosilver/template/ucp_profile_profile_info.html deleted file mode 100644 index ac0cd15..0000000 --- a/install/update/new/styles/prosilver/template/ucp_profile_profile_info.html +++ /dev/null @@ -1,51 +0,0 @@ - - -
- -

{L_TITLE} [ {L_VIEW_PROFILE} ]

- -
-
-

{L_PROFILE_INFO_NOTICE}

- -
-

{ERROR}

- - -
-

{L_BIRTHDAY_EXPLAIN}
-
- - - -
-
- - -
-
-
-
- - -
-
for="{profile_fields.FIELD_ID}">{profile_fields.LANG_NAME}{L_COLON} * -
{profile_fields.LANG_EXPLAIN}
-
{profile_fields.ERROR}
-
{profile_fields.FIELD}
-
- - -
- -
-
- -
- {S_HIDDEN_FIELDS}  - - {S_FORM_TOKEN} -
-
- - diff --git a/install/update/new/styles/prosilver/template/ucp_register.html b/install/update/new/styles/prosilver/template/ucp_register.html deleted file mode 100644 index f44382f..0000000 --- a/install/update/new/styles/prosilver/template/ucp_register.html +++ /dev/null @@ -1,117 +0,0 @@ - - - - -{% if PROVIDER_TEMPLATE_FILE %} -
-
- -

{{ SITENAME }} - {{ lang('OAUTH_REGISTRATION') }}

- - {% include PROVIDER_TEMPLATE_FILE %} -
-
-{% endif %} - -
- -
-
- -

{SITENAME} - {L_REGISTRATION}

- -
-
{ERROR}
- -
{L_REG_COND}
- - -
-

{L_USERNAME_EXPLAIN}
-
-
-
-
-
-
-
-

{L_PASSWORD_EXPLAIN}
-
-
-
-
-
-
- - -
- - -
-
-
-
- - - - - -
{L_ITEMS_REQUIRED}
- - -
-
for="{profile_fields.FIELD_ID}">{profile_fields.LANG_NAME}{L_COLON} * -
{profile_fields.LANG_EXPLAIN} -
{profile_fields.ERROR}
-
{profile_fields.FIELD}
-
- - - - -
-
-
- - - - - - -
-
- -

{L_COPPA_COMPLIANCE}

- -

{L_COPPA_EXPLAIN}

-
-
- - - - -
-
- -
- {S_HIDDEN_FIELDS} -   - - {S_FORM_TOKEN} -
- -
-
-
- - diff --git a/install/update/new/styles/prosilver/template/ucp_reset_password.html b/install/update/new/styles/prosilver/template/ucp_reset_password.html deleted file mode 100644 index 0a05f69..0000000 --- a/install/update/new/styles/prosilver/template/ucp_reset_password.html +++ /dev/null @@ -1,49 +0,0 @@ - - -
- -
-
- -
-

{{ lang('RESET_PASSWORD') }}

- -
- {% if S_IS_PASSWORD_RESET %} - {% if PASSWORD_RESET_ERRORS %}

{{ PASSWORD_RESET_ERRORS | join('
') }}

{% endif %} -
-
-
-
-
-
-
-
- {% else %} - {% if USERNAME_REQUIRED %} -

{{ lang('EMAIL_NOT_UNIQUE') }}

- {% endif %} -
-

{{ lang('EMAIL_REMIND') }}
-
-
- {% if USERNAME_REQUIRED %} -
-
-
-
- {% endif %} - {% endif %} -
-
 
-
{{ S_HIDDEN_FIELDS }} 
-
- {{ S_FORM_TOKEN }} -
-
- -
-
-
- - diff --git a/install/update/new/styles/prosilver/template/viewforum_body.html b/install/update/new/styles/prosilver/template/viewforum_body.html deleted file mode 100644 index 40beb78..0000000 --- a/install/update/new/styles/prosilver/template/viewforum_body.html +++ /dev/null @@ -1,315 +0,0 @@ - - -

{FORUM_NAME}

- - -
- -
{FORUM_DESC}
-

{L_MODERATOR}{L_MODERATORS}{L_COLON} {MODERATORS}

-
- - - -
-
- - - {L_FORUM_RULES} - - {L_FORUM_RULES}
- {FORUM_RULES} - - -
-
- - - - - - - - - - -
- - - - - - - {L_BUTTON_FORUM_LOCKED} - - {L_BUTTON_NEW_TOPIC} - - - - - - - - - - - -
- - - - -
-
- {L_NO_READ_ACCESS} -
-
- - - -
- -
-
- -
-

{L_LOGIN_LOGOUT}  •  {L_REGISTER}

- -
-
-
-
-
-
-
-
-
-
-
-
-
 
-
-
- {S_LOGIN_REDIRECT} - {S_FORM_TOKEN_LOGIN} -
-
- -
-
- -
- - - - - - - - - - - -
-
- - - -
-
-
    -
  • -
    - id="active_topics">
    {L_ACTIVE_TOPICS}{L_ANNOUNCEMENTS}{L_TOPICS}
    -
    {L_REPLIES}
    -
    {L_VIEWS}
    -
    {L_LAST_POST}
    -
    -
  • -
- -
-
- - - - -
-
- {L_NO_TOPICS} -
-
- -
-
- {L_NO_FORUMS_IN_CATEGORY} -
-
- - - - -
- - - - - - {L_BUTTON_FORUM_LOCKED} - - {L_BUTTON_NEW_TOPIC} - - - - - - - -
- -
- - - -
- - - - - -
-

{L_WHO_IS_ONLINE}

-

{LOGGED_IN_USER_LIST}

-
- - - -
-

{L_FORUM_PERMISSIONS}

-

{rules.RULE}

-
- - - diff --git a/install/update/new/styles/prosilver/template/viewtopic_body.html b/install/update/new/styles/prosilver/template/viewtopic_body.html deleted file mode 100644 index 6af33f2..0000000 --- a/install/update/new/styles/prosilver/template/viewtopic_body.html +++ /dev/null @@ -1,459 +0,0 @@ - - - -

{TOPIC_TITLE}

- - -
{FORUM_DESC}
- - -

- {L_MODERATOR}{L_MODERATORS}{L_COLON} {MODERATORS} -

- - - -
-
- - - {L_FORUM_RULES} - - {L_FORUM_RULES}
- {FORUM_RULES} - - -
-
- - -
- - - - - - {L_BUTTON_TOPIC_LOCKED} - - {L_BUTTON_POST_REPLY} - - - - - - - - - - - - - - - - -
- - - - -
- -
-
- -
-

{POLL_QUESTION}

-

{L_POLL_LENGTH}
{L_MAX_VOTES}

- -
- - -
title="{L_POLL_VOTED_OPTION}" data-alt-text="{L_POLL_VOTED_OPTION}" data-poll-option-id="{poll_option.POLL_OPTION_ID}"> -
{poll_option.POLL_OPTION_CAPTION}
-
checked="checked" /> checked="checked" />
-
{poll_option.POLL_OPTION_RESULT}
-
{L_NO_VOTES}{poll_option.POLL_OPTION_PERCENT}
-
- - - -
-
 
-
{L_TOTAL_VOTES}{L_COLON} {TOTAL_VOTES}
-
- - -
-
 
-
-
- - - -
-
 
-
{L_VIEW_RESULTS}
-
- -
- -
- -
- {S_FORM_TOKEN} - {S_HIDDEN_FIELDS} -
- -
-
- - - - - - - - data-url="{postrow.U_MINI_POST}"> - -
-
- -
style="display: none;"> -
-
- - - {postrow.POSTER_AVATAR}{postrow.POSTER_AVATAR} - - -
- - {postrow.POST_AUTHOR_FULL}{postrow.POST_AUTHOR_FULL} - -
- - -
{postrow.RANK_TITLE}
{postrow.RANK_IMG}
- - -
{L_POSTS}{L_COLON} {postrow.POSTER_POSTS}
-
{L_JOINED}{L_COLON} {postrow.POSTER_JOINED}
-
{L_WARNINGS}{L_COLON} {postrow.POSTER_WARNINGS}
- - - -
{postrow.PROFILE_FIELD1_NAME}{L_COLON} {postrow.PROFILE_FIELD1_VALUE}
- - - - - -
{postrow.custom_fields.PROFILE_FIELD_NAME}{L_COLON} {postrow.custom_fields.PROFILE_FIELD_VALUE}
- - - - - - -
- {L_CONTACT}{L_COLON} - -
- - - -
- -
- - -
- {postrow.L_POST_DELETED_MESSAGE}
- {postrow.L_POST_DISPLAY} -
- -
- {postrow.L_IGNORE_POST}
- {postrow.L_POST_DISPLAY} -
- - -
style="display: none;"> - - -

class="first">{postrow.POST_ICON_IMG_ALT} {postrow.POST_SUBJECT}

- - - - - - - - - - - -

- - {postrow.MINI_POST} - - - {postrow.MINI_POST} - - - {L_POST_BY_AUTHOR} {postrow.POST_AUTHOR_FULL} » -

- - - - -
-

- - {L_POST_UNAPPROVED_ACTION} - - - - {S_FORM_TOKEN} -

-
- -

- - {L_POST_UNAPPROVED_EXPLAIN} -

- - -
-

- {L_POST_DELETED_ACTION} - - - - - - {S_FORM_TOKEN} -

-
- - - -

- {L_POST_REPORTED} -

- - -
{postrow.MESSAGE}
- - - - -
-
- {L_ATTACHMENTS} -
- -
{postrow.attachment.DISPLAY_ATTACHMENT}
- -
- - - -
{L_DOWNLOAD_NOTICE}
- -
- {postrow.DELETED_MESSAGE} -
{L_REASON}{L_COLON} {postrow.DELETE_REASON} -
- -
- {postrow.EDITED_MESSAGE} -
{L_REASON}{L_COLON} {postrow.EDIT_REASON} -
- - -


{postrow.BUMPED_MESSAGE}
- -
{postrow.SIGNATURE}
- - -
- -
- - - - - -
-
- -
- - - - - - - - -
- - - - - - {L_BUTTON_TOPIC_LOCKED} - - {L_BUTTON_POST_REPLY} - - - - - - - - -
- -
- - - - - - - - - - - -
- - - - - -
-

{L_WHO_IS_ONLINE}

-

{LOGGED_IN_USER_LIST}

-
- - - diff --git a/install/update/new/styles/prosilver/template/viewtopic_print.html b/install/update/new/styles/prosilver/template/viewtopic_print.html deleted file mode 100644 index 658062f..0000000 --- a/install/update/new/styles/prosilver/template/viewtopic_print.html +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - -{META} -{SITENAME} • {PAGE_TITLE} - - - - - - -
- - - - -
-
{PAGE_NUMBER}
- -
-

{postrow.POST_SUBJECT}

-
{L_POSTED}{L_COLON} {postrow.POST_DATE}
-
{L_POST_BY_AUTHOR} {postrow.POST_AUTHOR}
-
{postrow.MESSAGE}
-
-
- -
- - -
- - - diff --git a/install/update/new/styles/prosilver/theme/colours.css b/install/update/new/styles/prosilver/theme/colours.css deleted file mode 100644 index 04a8958..0000000 --- a/install/update/new/styles/prosilver/theme/colours.css +++ /dev/null @@ -1,1168 +0,0 @@ -/* --------------------------------------------------------------- -Colours and backgrounds for common.css --------------------------------------------------------------- */ - -html, body { - color: #536482; - background-color: #F5F7FA; -} - -h1 { - color: #FFFFFF; -} - -h2 { - color: #28313F; -} - -h3 { - border-bottom-color: #CCCCCC; - color: #115098; -} - -hr { - border-color: #FFFFFF; - border-top-color: #CCCCCC; -} - -/* --------------------------------------------------------------- -Colours and backgrounds for links.css --------------------------------------------------------------- */ - -a { color: #105289; } -a:hover { color: #D31141; } - -/* Links on gradient backgrounds */ -.forumbg .header a, .forabg .header a, th a { - color: #FFFFFF; -} - -.forumbg .header a:hover, .forabg .header a:hover, th a:hover { - color: #A8D8FF; -} - -/* Notification mark read link */ -.dropdown-extended a.mark_read { - background-color: #FFFFFF; -} - -/* Post body links */ -.postlink { - border-bottom-color: #368AD2; - color: #368AD2; -} - -.postlink:visited { - border-bottom-color: #5D8FBD; - color: #5D8FBD; -} - -.postlink:hover { - background-color: #D0E4F6; - color: #0D4473; -} - -.signature a, .signature a:hover { - background-color: transparent; -} - -/* Back to top of page */ -.top i { - color: #999999; -} - -/* Arrow links */ -.arrow-left:hover, .arrow-right:hover { - color: #368AD2; -} - -/* Round cornered boxes and backgrounds ----------------------------------------- */ -.wrap { - background-color: #FFF; - border-color: #E6E9ED; -} - -.headerbar { - color: #FFFFFF; -} - -.headerbar, .forumbg { - background-color: #12A3EB; - background-image: -webkit-linear-gradient(top, #6ACEFF 0%, #0076B1 2px, #12A3EB 92px, #12A3EB 100%); - background-image: linear-gradient(to bottom, #6ACEFF 0%,#0076B1 2px,#12A3EB 92px,#12A3EB 100%); - background-repeat: repeat-x; -} - -.forabg { - background-color: #0076B1; - background-image: -webkit-linear-gradient(top, #6ACEFF 0%, #12A3EB 2px, #0076B1 92px, #0076B1 100%); - background-image: linear-gradient(to bottom, #6ACEFF 0%,#12A3EB 2px,#0076B1 92px,#0076B1 100%); - background-repeat: repeat-x; -} - -.navbar { - background-color: #CADCEB; -} - -.panel { - background-color: #ECF1F3; - color: #28313F; -} - -.post:target .content { - color: #000000; -} - -.post:target h3 a { - color: #000000; -} - -.bg1 { - background-color: #ECF3F7; -} - -table.zebra-list tr:nth-child(odd) td, ul.zebra-list li:nth-child(odd) { - background-color: #ECF3F7; -} - -.bg2 { - background-color: #E1EBF2; -} - -table.zebra-list tr:nth-child(even) td, ul.zebra-list li:nth-child(even) { - background-color: #E1EBF2; -} - -.bg3 { - background-color: #CADCEB; -} - -.ucprowbg { - background-color: #DCDEE2; -} - -.fieldsbg { - background-color: #E7E8EA; -} - -.site_logo { - background-image: url("./images/site_logo.svg"); -} - -/* Horizontal lists -----------------------------------------*/ - -ul.navlinks { - border-top-color: #FFFFFF; -} - -/* Table styles -----------------------------------------*/ -table.table1 thead th { - color: #FFFFFF; -} - -table.table1 tbody tr { - border-color: #BFC1CF; -} - -table.table1 tbody tr:hover, table.table1 tbody tr.hover { - background-color: #CFE1F6; - color: #000; -} - -table.table1 td { - color: #536482; -} - -table.table1 tbody td { - border-top-color: #FAFAFA; -} - -table.table1 tbody th { - border-bottom-color: #000000; - color: #333333; - background-color: #FFFFFF; -} - -table.info tbody th { - color: #000000; -} - -/* Misc layout styles ----------------------------------------- */ -dl.details dt { - color: #000000; -} - -dl.details dd { - color: #536482; -} - -.sep { - color: #1198D9; -} - -/* Icon styles ----------------------------------------- */ -.icon.icon-blue, a:hover .icon.icon-blue { - color: #196db5; -} - -.icon.icon-green, a:hover .icon.icon-green{ - color: #1b9A1B; -} - -.icon.icon-red, a:hover .icon.icon-red{ - color: #BC2A4D; -} - -.icon.icon-orange, a:hover .icon.icon-orange{ - color: #FF6600; -} - -.icon.icon-bluegray, a:hover .icon.icon-bluegray{ - color: #536482; -} - -.icon.icon-gray, a:hover .icon.icon-gray{ - color: #777777; -} - -.icon.icon-lightgray, a:hover .icon.icon-lightgray{ - color: #999999; -} - -.icon.icon-black, a:hover .icon.icon-black{ - color: #333333; -} - -.alert_close .icon:before { - background-color: #FFFFFF; -} - -/* Jumpbox */ -.jumpbox .dropdown li { - border-top-color: #CCCCCC; -} - -.jumpbox-cat-link { - background-color: #0076b1; - border-top-color: #0076B1; - color: #FFFFFF; -} - -.jumpbox-cat-link:hover { - background-color: #12A3EB; - border-top-color: #12A3EB; - color: #FFFFFF; -} - -.jumpbox-forum-link { - background-color: #E1EBF2; -} - -.jumpbox-forum-link:hover { - background-color: #F6F4D0; -} - -.jumpbox .dropdown .pointer-inner { - border-color: #E1EBF2 transparent; -} - -.jumpbox-sub-link { - background-color: #E1EBF2; -} - -.jumpbox-sub-link:hover { - background-color: #F1F8FF; -} - -/* Miscellaneous styles ----------------------------------------- */ - -.copyright { - color: #555555; -} - -.error { - color: #BC2A4D; -} - -.reported { - background-color: #F7ECEF; -} - -li.reported:hover { - background-color: #ECD5D8 !important; -} -.sticky, .announce { - /* you can add a background for stickies and announcements*/ -} - -div.rules { - background-color: #ECD5D8; - color: #BC2A4D; -} - -p.post-notice { - background-color: #ECD5D8; - background-image: none; -} - -/* --------------------------------------------------------------- -Colours and backgrounds for content.css --------------------------------------------------------------- */ - -ul.forums { - background-color: #EEF5F9; /* Old browsers */ /* FF3.6+ */ - background-image: -webkit-linear-gradient(top, #D2E0EB 0%, #EEF5F9 100%); - background-image: linear-gradient(to bottom, #D2E0EB 0%,#EEF5F9 100%); /* W3C */ - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#D2E0EB', endColorstr='#EEF5F9',GradientType=0 ); /* IE6-9 */ -} - -ul.topiclist li { - color: #4C5D77; -} - -ul.topiclist dd { - border-left-color: #FFFFFF; -} - -.rtl ul.topiclist dd { - border-right-color: #FFFFFF; - border-left-color: transparent; -} - -li.row { - border-top-color: #FFFFFF; - border-bottom-color: #00608F; -} - -li.row strong { - color: #000000; -} - -li.row:hover { - background-color: #F6F4D0; -} - -li.row:hover dd { - border-left-color: #CCCCCC; -} - -.rtl li.row:hover dd { - border-right-color: #CCCCCC; - border-left-color: transparent; -} - -li.header dt, li.header dd { - color: #FFFFFF; -} - -/* Post body styles -----------------------------------------*/ -.postbody { - color: #333333; -} - -/* Content container styles -----------------------------------------*/ -.content { - color: #333333; -} - -.content h2, .panel h2 { - color: #115098; - border-bottom-color: #CCCCCC; -} - -dl.faq dt { - color: #333333; -} - -.posthilit { - background-color: #F3BFCC; - color: #BC2A4D; -} - -.announce, .unreadpost { - /* Highlight the announcements & unread posts box */ -} - -/* Post signature */ -.signature { - border-top-color: #CCCCCC; -} - -/* Post noticies */ -.notice { - border-top-color: #CCCCCC; -} - -/* BB Code styles -----------------------------------------*/ -/* Quote block */ -blockquote { - background-color: #EBEADD; - border-color:#DBDBCE; -} - -blockquote blockquote { - /* Nested quotes */ - background-color:#EFEED9; -} - -blockquote blockquote blockquote { - /* Nested quotes */ - background-color: #EBEADD; -} - -/* Code block */ -.codebox { - background-color: #FFFFFF; - border-color: #C9D2D8; -} - -.codebox p { - border-bottom-color: #CCCCCC; -} - -.codebox code { - color: #2E8B57; -} - -/* Attachments -----------------------------------------*/ -.attachbox { - background-color: #FFFFFF; - border-color: #C9D2D8; -} - -.pm-message .attachbox { - background-color: #F2F3F3; -} - -.attachbox dd { - border-top-color: #C9D2D8; -} - -.attachbox p { - color: #666666; -} - -.attachbox p.stats { - color: #666666; -} - -.attach-image img { - border-color: #999999; -} - -/* Inline image thumbnails */ - -dl.file dd { - color: #666666; -} - -dl.thumbnail img { - border-color: #666666; - background-color: #FFFFFF; -} - -dl.thumbnail dd { - color: #666666; -} - -dl.thumbnail dt a:hover { - background-color: #EEEEEE; -} - -dl.thumbnail dt a:hover img { - border-color: #368AD2; -} - -/* Post poll styles -----------------------------------------*/ - -fieldset.polls dl { - border-top-color: #DCDEE2; - color: #666666; -} - -fieldset.polls dl.voted { - color: #000000; -} - -fieldset.polls dd div { - color: #FFFFFF; -} - -.rtl .pollbar1, .rtl .pollbar2, .rtl .pollbar3, .rtl .pollbar4, .rtl .pollbar5 { - border-right-color: transparent; -} - -.pollbar1 { - background-color: #AA2346; - border-bottom-color: #74162C; - border-right-color: #74162C; -} - -.rtl .pollbar1 { - border-left-color: #74162C; -} - -.pollbar2 { - background-color: #BE1E4A; - border-bottom-color: #8C1C38; - border-right-color: #8C1C38; -} - -.rtl .pollbar2 { - border-left-color: #8C1C38; -} - -.pollbar3 { - background-color: #D11A4E; - border-bottom-color: #AA2346; - border-right-color: #AA2346; -} - -.rtl .pollbar3 { - border-left-color: #AA2346; -} - -.pollbar4 { - background-color: #E41653; - border-bottom-color: #BE1E4A; - border-right-color: #BE1E4A; -} - -.rtl .pollbar4 { - border-left-color: #BE1E4A; -} - -.pollbar5 { - background-color: #F81157; - border-bottom-color: #D11A4E; - border-right-color: #D11A4E; -} - -.rtl .pollbar5 { - border-left-color: #D11A4E; -} - -/* Poster profile block -----------------------------------------*/ -.postprofile { - color: #666666; - border-color: #FFFFFF; -} - -.pm .postprofile { - border-color: #DDDDDD; -} - -.postprofile strong { - color: #000000; -} - -.online { - background-image: url("./en/icon_user_online.gif"); -} - -dd.profile-warnings { - color: #BC2A4D; -} - -/* --------------------------------------------------------------- -Colours and backgrounds for buttons.css --------------------------------------------------------------- */ -.button { - border-color: #C7C3BF; - background-color: #E9E9E9; /* Old browsers */ /* FF3.6+ */ - background-image: -webkit-linear-gradient(top, #FFFFFF 0%, #E9E9E9 100%); - background-image: linear-gradient(to bottom, #FFFFFF 0%,#E9E9E9 100%); /* W3C */ - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#FFFFFF', endColorstr='#E9E9E9',GradientType=0 ); /* IE6-9 */ - box-shadow: 0 0 0 1px #FFFFFF inset; - -webkit-box-shadow: 0 0 0 1px #FFFFFF inset; - color: #D31141; -} - -.button:hover, -.button:focus { - border-color: #0A8ED0; - background-color: #FFFFFF; /* Old browsers */ /* FF3.6+ */ - background-image: -webkit-linear-gradient(top, #E9E9E9 0%, #FFFFFF 100%); - background-image: linear-gradient(to bottom, #E9E9E9 0%,#FFFFFF 100%); /* W3C */ - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#E9E9E9', endColorstr='#FFFFFF',GradientType=0 ); /* IE6-9 */ - text-shadow: 1px 1px 0 #FFFFFF, -1px -1px 0 #FFFFFF, -1px -1px 0 rgba(188, 42, 77, 0.2); -} - - -.button .icon, -.button-secondary { - color: #8f8f8f; -} - -.button-secondary:focus, -.button-secondary:hover, -.button:focus .icon, -.button:hover .icon { - color: #0A8ED0; -} - -.button-search:hover, -.button-search-end:hover { - border-color: #C7C3BF; -} - -.caret { border-color: #DADADA; } -.caret { border-color: #C7C3BF; } - -.contact-icons a { border-color: #DCDCDC; } -.contact-icons a:hover { background-color: #F2F6F9; } - -/* Pagination ----------------------------------------- */ - -.pagination li a { - background: #ECEDEE; - filter: none; - border-color: #B4BAC0; - box-shadow: none; - -webkit-box-shadow: none; - color: #5C758C; -} - -.pagination li.ellipsis span { - background: transparent; - color: #000000; -} - -.pagination li.active span { - background: #4692BF; - border-color: #4692BF; - color: #FFFFFF; -} - -.pagination li a:hover, .pagination li a:hover .icon, .pagination .dropdown-visible a.dropdown-trigger, .nojs .pagination .dropdown-container:hover a.dropdown-trigger { - background: #368AD2; - border-color: #368AD2; - filter: none; - color: #FFFFFF; - text-shadow: none; -} - -/* Search box ---------------------------------------------- */ - -.search-box .inputbox, -.search-box .inputbox:hover, -.search-box .inputbox:focus { - border-color: #C7C3BF; -} - -.search-header { - box-shadow: 0 0 10px #0075B0; -} - -.search-results li:hover, -.search-results li.active { - background-color: #CFE1F6; -} - -/* Icon images ----------------------------------------- */ - -.contact-icon { background-image: url("./images/icons_contact.png"); } - -/* Profile & navigation icons */ -.pm-icon { background-position: 0 0; } -.email-icon { background-position: -21px 0; } -.jabber-icon { background-position: -80px 0; } -.phpbb_icq-icon { background-position: -61px 0 ; } -.phpbb_wlm-icon { background-position: -182px 0; } -.phpbb_aol-icon { background-position: -244px 0; } -.phpbb_website-icon { background-position: -40px 0; } -.phpbb_youtube-icon { background-position: -98px 0; } -.phpbb_facebook-icon { background-position: -119px 0; } -.phpbb_googleplus-icon { background-position: -140px 0; } -.phpbb_skype-icon { background-position: -161px 0; } -.phpbb_twitter-icon { background-position: -203px 0; } -.phpbb_yahoo-icon { background-position: -224px 0; } - -/* Forum icons & Topic icons */ -.global_read { background-image: url("./images/announce_read.gif"); } -.global_read_mine { background-image: url("./images/announce_read_mine.gif"); } -.global_read_locked { background-image: url("./images/announce_read_locked.gif"); } -.global_read_locked_mine { background-image: url("./images/announce_read_locked_mine.gif"); } -.global_unread { background-image: url("./images/announce_unread.gif"); } -.global_unread_mine { background-image: url("./images/announce_unread_mine.gif"); } -.global_unread_locked { background-image: url("./images/announce_unread_locked.gif"); } -.global_unread_locked_mine { background-image: url("./images/announce_unread_locked_mine.gif"); } - -.announce_read { background-image: url("./images/announce_read.gif"); } -.announce_read_mine { background-image: url("./images/announce_read_mine.gif"); } -.announce_read_locked { background-image: url("./images/announce_read_locked.gif"); } -.announce_read_locked_mine { background-image: url("./images/announce_read_locked_mine.gif"); } -.announce_unread { background-image: url("./images/announce_unread.gif"); } -.announce_unread_mine { background-image: url("./images/announce_unread_mine.gif"); } -.announce_unread_locked { background-image: url("./images/announce_unread_locked.gif"); } -.announce_unread_locked_mine { background-image: url("./images/announce_unread_locked_mine.gif"); } - -.forum_link { background-image: url("./images/forum_link.gif"); } -.forum_read { background-image: url("./images/forum_read.gif"); } -.forum_read_locked { background-image: url("./images/forum_read_locked.gif"); } -.forum_read_subforum { background-image: url("./images/forum_read_subforum.gif"); } -.forum_unread { background-image: url("./images/forum_unread.gif"); } -.forum_unread_locked { background-image: url("./images/forum_unread_locked.gif"); } -.forum_unread_subforum { background-image: url("./images/forum_unread_subforum.gif"); } - -.sticky_read { background-image: url("./images/sticky_read.gif"); } -.sticky_read_mine { background-image: url("./images/sticky_read_mine.gif"); } -.sticky_read_locked { background-image: url("./images/sticky_read_locked.gif"); } -.sticky_read_locked_mine { background-image: url("./images/sticky_read_locked_mine.gif"); } -.sticky_unread { background-image: url("./images/sticky_unread.gif"); } -.sticky_unread_mine { background-image: url("./images/sticky_unread_mine.gif"); } -.sticky_unread_locked { background-image: url("./images/sticky_unread_locked.gif"); } -.sticky_unread_locked_mine { background-image: url("./images/sticky_unread_locked_mine.gif"); } - -.topic_moved { background-image: url("./images/topic_moved.gif"); } -.pm_read, -.topic_read { background-image: url("./images/topic_read.gif"); } -.topic_read_mine { background-image: url("./images/topic_read_mine.gif"); } -.topic_read_hot { background-image: url("./images/topic_read_hot.gif"); } -.topic_read_hot_mine { background-image: url("./images/topic_read_hot_mine.gif"); } -.topic_read_locked { background-image: url("./images/topic_read_locked.gif"); } -.topic_read_locked_mine { background-image: url("./images/topic_read_locked_mine.gif"); } -.pm_unread, -.topic_unread { background-image: url("./images/topic_unread.gif"); } -.topic_unread_mine { background-image: url("./images/topic_unread_mine.gif"); } -.topic_unread_hot { background-image: url("./images/topic_unread_hot.gif"); } -.topic_unread_hot_mine { background-image: url("./images/topic_unread_hot_mine.gif"); } -.topic_unread_locked { background-image: url("./images/topic_unread_locked.gif"); } -.topic_unread_locked_mine { background-image: url("./images/topic_unread_locked_mine.gif"); } - - -/* --------------------------------------------------------------- -Colours and backgrounds for cp.css --------------------------------------------------------------- */ - -/* Main CP box -----------------------------------------*/ - -.panel-container h3, .panel-container hr, .cp-menu hr { - border-color: #A4B3BF; -} - -.panel-container .panel li.row { - border-bottom-color: #B5C1CB; - border-top-color: #F9F9F9; -} - -ul.cplist { - border-top-color: #B5C1CB; -} - -.panel-container .panel li.header dd, .panel-container .panel li.header dt { - color: #000000; -} - -.panel-container table.table1 thead th { - color: #333333; - border-bottom-color: #333333; -} - -.cp-main .pm-message { - border-color: #DBDEE2; - background-color: #FFFFFF; -} - -/* CP tabbed menu -----------------------------------------*/ -.tabs .tab > a { - background: #BACCD9; - color: #536482; -} - -.tabs .tab > a:hover { - background: #DDEDFB; - color: #D31141; -} - -.tabs .activetab > a, -.tabs .activetab > a:hover { - background-color: #CADCEB; /* Old browsers */ /* FF3.6+ */ - background-image: -webkit-linear-gradient(top, #E2F2FF 0%, #CADCEB 100%); - background-image: linear-gradient(to bottom, #E2F2FF 0%,#CADCEB 100%); /* W3C */ - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#E2F2FF', endColorstr='#CADCEB',GradientType=0 ); /* IE6-9 */ - border-color: #CADCEB; - box-shadow: 0 1px 1px #F2F9FF inset; - color: #333333; -} - -.tabs .activetab > a:hover { - color: #000000; -} - -/* Mini tabbed menu used in MCP -----------------------------------------*/ -.minitabs .tab > a { - background-color: #E1EBF2; -} - -.minitabs .activetab > a, -.minitabs .activetab > a:hover { - background-color: #F9F9F9; - color: #333333; -} - -/* Responsive tabs -----------------------------------------*/ -.responsive-tab .responsive-tab-link:before { - border-color: #536482; -} - -.responsive-tab .responsive-tab-link:hover:before { - border-color: #D31141; -} - -/* UCP navigation menu -----------------------------------------*/ - -/* Link styles for the sub-section links */ -.navigation a { - color: #333; - background: #CADCEB; /* Old browsers */ /* FF3.6+ */ - background: -webkit-linear-gradient(left, #B4C4D1 50%, #CADCEB 100%); - background: linear-gradient(to right, #B4C4D1 50%,#CADCEB 100%); /* W3C */ - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#B4C4D1', endColorstr='#CADCEB',GradientType=1 ); /* IE6-9 */ -} - -.rtl .navigation a { - background: #B4C4D1; /* Old browsers */ /* FF3.6+ */ - background: -webkit-linear-gradient(left, #CADCEB 50%, #B4C4D1 100%); - background: linear-gradient(to right, #CADCEB 50%,#B4C4D1 100%); /* W3C */ - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#CADCEB', endColorstr='#B4C4D1',GradientType=1 ); /* IE6-9 */ -} - -.navigation a:hover { - background: #AABAC6; - color: #BC2A4D; - filter: progid:DXImageTransform.Microsoft.gradient(enabled = false); -} - -.navigation .active-subsection a { - background: #F9F9F9; - color: #D31141; - filter: progid:DXImageTransform.Microsoft.gradient(enabled = false); -} - -.navigation .active-subsection a:hover { - color: #D31141; -} - -@media only screen and (max-width: 900px), only screen and (max-device-width: 900px) -{ - #navigation a, .rtl #navigation a { - background: #B2C2CF; - } -} - -/* Preferences pane layout -----------------------------------------*/ -.panel-container h2 { - color: #333333; -} - -.panel-container .panel { - background-color: #F9F9F9; -} - -.cp-main .pm { - background-color: #FFFFFF; -} - -/* Friends list */ -.cp-mini { - background-color: #EEF5F9; -} - -dl.mini dt { - color: #425067; -} - -/* PM Styles -----------------------------------------*/ -/* PM Message history */ -.current { - color: #000000 !important; -} - -/* PM marking colours */ -.pmlist li.pm_message_reported_colour, .pm_message_reported_colour { - border-left-color: #BC2A4D; - border-right-color: #BC2A4D; -} - -.pmlist li.pm_marked_colour, .pm_marked_colour { - border-color: #FF6600; -} - -.pmlist li.pm_replied_colour, .pm_replied_colour { - border-color: #A9B8C2; -} - -.pmlist li.pm_friend_colour, .pm_friend_colour { - border-color: #5D8FBD; -} - -.pmlist li.pm_foe_colour, .pm_foe_colour { - border-color: #000000; -} - -/* Avatar gallery */ -.gallery label { - background: #FFFFFF; - border-color: #CCC; -} - -.gallery label:hover { - background-color: #EEE; -} - -/* --------------------------------------------------------------- -Colours and backgrounds for forms.css --------------------------------------------------------------- */ - -/* General form styles -----------------------------------------*/ -select { - border-color: #666666; - background-color: #FAFAFA; - color: #000; -} - -label { - color: #425067; -} - -option.disabled-option { - color: graytext; -} - -/* Definition list layout for forms ----------------------------------------- */ -dd label { - color: #333; -} - -fieldset.fields1 { - background-color: transparent; -} - -/* Hover effects */ -fieldset dl:hover dt label { - color: #000000; -} - -fieldset.fields2 dl:hover dt label { - color: inherit; -} - -/* Quick-login on index page */ -fieldset.quick-login input.inputbox { - background-color: #F2F3F3; -} - -/* Posting page styles -----------------------------------------*/ - -.message-box textarea { - color: #333333; -} - -.message-box textarea.drag-n-drop { - outline-color: rgba(102, 102, 102, 0.5); -} - -.message-box textarea.drag-n-drop-highlight { - outline-color: rgba(17, 163, 234, 0.5); -} - -/* Input field styles ----------------------------------------- */ -.inputbox { - background-color: #FFFFFF; - border-color: #B4BAC0; - color: #333333; -} - -.inputbox:-moz-placeholder { - color: #333333; -} - -.inputbox::-webkit-input-placeholder { - color: #333333; -} - -.inputbox:hover { - border-color: #11A3EA; -} - -.inputbox:focus { - border-color: #11A3EA; -} - -.inputbox:focus:-moz-placeholder { - color: transparent; -} - -.inputbox:focus::-webkit-input-placeholder { - color: transparent; -} - - -/* Form button styles ----------------------------------------- */ - -a.button1, input.button1, input.button3, a.button2, input.button2 { - color: #000; - background-color: #EFEFEF; /* Old browsers */ /* FF3.6+ */ - background-image: -webkit-linear-gradient(top, #D2D2D2 0%, #EFEFEF 100%); - background-image: linear-gradient(to bottom, #D2D2D2 0%,#EFEFEF 100%); /* W3C */ - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#D2D2D2', endColorstr='#EFEFEF',GradientType=0 ); /* IE6-9 */ -} - -a.button1, input.button1 { - border-color: #666666; -} - -input.button3 { - background-image: none; -} - -/* Alternative button */ -a.button2, input.button2, input.button3 { - border-color: #666666; -} - -/* button in the style of the form buttons */ -a.button1, a.button2 { - color: #000000; -} - -/* Hover states */ -a.button1:hover, input.button1:hover, a.button2:hover, input.button2:hover, input.button3:hover { - border-color: #D31141; - color: #D31141; - background-color: #D2D2D2; /* Old browsers */ /* FF3.6+ */ - background-image: -webkit-linear-gradient(top, #EFEFEF 0%, #D2D2D2 100%); - background-image: linear-gradient(to bottom, #EFEFEF 0%,#D2D2D2 100%); /* W3C */ - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#EFEFEF', endColorstr='#D2D2D2',GradientType=0 ); /* IE6-9 */ -} - -/* Focus states */ -input.button1:focus, input.button2:focus, input.button3:focus { - border-color: #11A3EA; - color: #0F4987; -} - -input.disabled { - color: #666666; -} - -/* jQuery popups ----------------------------------------- */ -.phpbb_alert { - background-color: #FFFFFF; - border-color: #999999; -} -.darken { - background-color: #000000; -} - -.loading_indicator { - background-color: #000000; - background-image: url("./images/loading.gif"); -} - -.dropdown-extended ul li { - border-top-color: #B9B9B9; -} - -.dropdown-extended ul li:hover { - background-color: #CFE1F6; - color: #000000; -} - -.dropdown-extended .header, .dropdown-extended .footer { - border-color: #B9B9B9; - color: #000000; -} - -.dropdown-extended .footer { - border-top-style: solid; - border-top-width: 1px; -} - -.dropdown-extended .header { - background-color: #F1F8FF; /* Old browsers */ /* FF3.6+ */ - background-image: -webkit-linear-gradient(top, #F1F8FF 0%, #CADCEB 100%); - background-image: linear-gradient(to bottom, #F1F8FF 0%,#CADCEB 100%); /* W3C */ - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#F1F8FF', endColorstr='#CADCEB',GradientType=0 ); /* IE6-9 */ -} - -.dropdown .pointer { - border-color: #B9B9B9 transparent; -} - -.dropdown .pointer-inner { - border-color: #FFF transparent; -} - -.dropdown-extended .pointer-inner { - border-color: #F1F8FF transparent; -} - -.dropdown .dropdown-contents { - background: #fff; - border-color: #B9B9B9; - box-shadow: 1px 3px 5px rgba(0, 0, 0, 0.2); -} - -.dropdown-up .dropdown-contents { - box-shadow: 1px 0 5px rgba(0, 0, 0, 0.2); -} - -.dropdown li, .dropdown li li { - border-color: #DCDCDC; -} - -.dropdown li.separator { - border-color: #DCDCDC; -} - -/* Notifications ----------------------------------------- */ - -.notification_list p.notification-time { - color: #4C5D77; -} - -li.notification-reported strong, li.notification-disapproved strong { - color: #D31141; -} - -.badge { - background-color: #D31141; - color: #ffffff; -} diff --git a/install/update/new/styles/prosilver/theme/common.css b/install/update/new/styles/prosilver/theme/common.css deleted file mode 100644 index eb04c66..0000000 --- a/install/update/new/styles/prosilver/theme/common.css +++ /dev/null @@ -1,1288 +0,0 @@ -/* General Markup Styles ----------------------------------------- */ -html { - font-size: 100%; - /* Always show a scrollbar for short pages - stops the jump when the scrollbar appears. non-IE browsers */ - height: 101%; -} - -body { - font-family: Verdana, Helvetica, Arial, sans-serif; - font-size: 10px; - line-height: normal; - margin: 0; - padding: 12px 0; - word-wrap: break-word; - -webkit-print-color-adjust: exact; -} - -h1 { - /* Forum name */ - font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; - margin-right: 200px; - margin-top: 15px; - font-weight: bold; - font-size: 2em; -} - -h2 { - /* Forum header titles */ - font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; - font-weight: normal; - font-size: 2em; - margin: 0.8em 0 0.2em 0; -} - -h2.solo { - margin-bottom: 1em; -} - -h3 { - /* Sub-headers (also used as post headers, but defined later) */ - font-family: Arial, Helvetica, sans-serif; - font-weight: bold; - text-transform: uppercase; - border-bottom: 1px solid transparent; - margin-bottom: 3px; - padding-bottom: 2px; - font-size: 1.05em; - margin-top: 20px; -} - -h4 { - /* Forum and topic list titles */ - font-family: "Trebuchet MS", Verdana, Helvetica, Arial, Sans-serif; - font-size: 1.3em; -} - -p { - line-height: 1.3em; - font-size: 1.1em; - margin-bottom: 1.5em; -} - -img { - border-width: 0; -} - -hr { - border: 0 solid transparent; - border-top-width: 1px; - height: 1px; - margin: 5px 0; - display: block; - clear: both; -} - -hr.dashed { - border-top-style: dashed; - margin: 10px 0; -} - -hr.divider { - display: none; -} - -p.right { - text-align: right; -} - -p.jumpbox-return { - margin-top: 10px; - margin-bottom: 0; - float: left; -} - -b, strong { - font-weight: bold; -} - -.text-strong { - font-weight: bold; -} - -i, em { - font-style: italic; -} - -.text-italics { - font-style: italic; -} - -u { - text-decoration: underline; -} - -ul { - list-style-type: disc; -} - -ol { - list-style-type: decimal; -} - -li { - display: list-item; -} - -ul ul, ol ul { - list-style-type: circle; -} - -ol ol ul, ol ul ul, ul ol ul, ul ul ul { - list-style-type: square; -} - -a:hover { text-decoration: underline; } - -/* Main blocks ----------------------------------------- */ -.wrap { - border: 1px solid transparent; - border-radius: 8px; - margin: 0 auto; - max-width: 1152px; - min-width: 625px; - padding: 15px; -} - -@media only screen and (max-width: 1220px), only screen and (max-device-width: 1220px) { - .wrap { - margin: 0 12px; - } -} - -.page-body { - margin: 4px 0; - clear: both; -} - -.page-footer { - clear: both; -} - -.page-footer h3 { - margin-top: 20px; -} - -.logo { - float: left; - width: auto; - padding: 10px 13px 0 10px; -} - -.logo:hover { - text-decoration: none; -} - -.site_logo { - background-repeat: no-repeat; - display: inline-block; - width: 149px; - height: 52px; -} - -/* Site description and logo */ -.site-description { - float: left; - width: 65%; -} - -.site-description h1 { - margin-right: 0; -} - -/* Round cornered boxes and backgrounds ----------------------------------------- */ -.headerbar { - margin-bottom: 4px; - padding: 5px; - border-radius: 7px; -} - -.navbar { - padding: 3px 10px; - border-radius: 7px; -} - -.forabg { - margin-bottom: 4px; - padding: 5px; - clear: both; - border-radius: 7px; -} - -.forumbg { - margin-bottom: 4px; - padding: 5px; - clear: both; - border-radius: 7px; -} - -.panel { - margin-bottom: 4px; - padding: 5px 10px; - border-radius: 7px; -} - -.post { - padding: 5px 10px; - margin-bottom: 4px; - background-repeat: no-repeat; - background-position: 100% 0; - border-radius: 7px; - position: relative; -} - -.rowbg { - margin: 5px 5px 2px 5px; -} - -/* Horizontal lists -----------------------------------------*/ -.navbar ul.linklist { - padding: 2px 0; - list-style-type: none; -} - -ul.linklist { - display: block; - margin: 0; -} - -.cp-main .panel { - padding: 5px 10px; -} - -ul.linklist > li { - float: left; - font-size: 1.1em; - line-height: 2.2em; - list-style-type: none; - margin-right: 7px; - padding-top: 1px; - width: auto; -} - -ul.linklist > li.rightside, p.rightside, a.rightside { - float: right; - margin-right: 0; - margin-left: 7px; - text-align: right; -} - -ul.navlinks { - border-top: 1px solid transparent; -} - -ul.leftside { - float: left; - margin-left: 0; - margin-right: 5px; - text-align: left; -} - -ul.rightside { - float: right; - margin-left: 5px; - margin-right: -5px; - text-align: right; -} - -ul.linklist li.responsive-menu { - position: relative; - margin: 0 5px 0 0; -} - -.hasjs ul.linklist.leftside, .hasjs ul.linklist.rightside { - max-width: 48%; -} - -.hasjs ul.linklist.fullwidth { - max-width: none; -} - -li.responsive-menu.dropdown-right .dropdown { - left: -9px; -} - -li.responsive-menu.dropdown-left .dropdown { - right: -6px; -} - -ul.linklist .dropdown { - top: 22px; -} - -ul.linklist .dropdown-up .dropdown { - bottom: 18px; - top: auto; -} - -/* Bulletin icons for list items -----------------------------------------*/ -ul.linklist.bulletin > li:before { - display: inline-block; - content: "\2022"; - font-size: inherit; - line-height: inherit; - padding-right: 4px; -} - -ul.linklist.bulletin > li:first-child:before, -ul.linklist.bulletin > li.rightside:last-child:before { - content: none; -} - -ul.linklist.bulletin > li.no-bulletin:before { - content: none; -} - -.responsive-menu:before { - display: none !important; -} - -/* Profile in overall_header.html */ -.header-profile { - display: inline-block; - vertical-align: top; -} - -a.header-avatar, -a.header-avatar:hover { - text-decoration: none; -} - -a.header-avatar img { - margin-bottom: 2px; - max-height: 20px; - vertical-align: middle; - width: auto; -} - -a.header-avatar span:after { - content: '\f0dd'; - display: inline-block; - font: normal normal normal 14px/1 FontAwesome; - padding-left: 6px; - padding-top: 2px; - vertical-align: top; -} - -/* Dropdown menu -----------------------------------------*/ -.dropdown-container { - position: relative; -} - -.dropdown-container-right { - float: right; -} - -.dropdown-container-left { - float: left; -} - -.nojs .dropdown-container:hover .dropdown { - display: block !important; -} - -.dropdown { - display: none; - position: absolute; - left: 0; - top: 1.2em; - z-index: 2; - border: 1px solid transparent; - border-radius: 5px; - padding: 9px 0 0; - margin-right: -500px; -} - -.dropdown.live-search { - top: auto; -} - -.dropdown-container.topic-tools { - float: left; -} - -.dropdown-up .dropdown { - top: auto; - bottom: 1.2em; - padding: 0 0 9px; -} - -.dropdown-left .dropdown, .nojs .rightside .dropdown { - left: auto; - right: 0; - margin-left: -500px; - margin-right: 0; -} - -.dropdown-button-control .dropdown { - top: 24px; -} - -.dropdown-button-control.dropdown-up .dropdown { - top: auto; - bottom: 24px; -} - -.dropdown .pointer, .dropdown .pointer-inner { - position: absolute; - width: 0; - height: 0; - border-top-width: 0; - border-bottom: 10px solid transparent; - border-left: 10px dashed transparent; - border-right: 10px dashed transparent; - -webkit-transform: rotate(360deg); /* better anti-aliasing in webkit */ - display: block; -} - -.dropdown-up .pointer, .dropdown-up .pointer-inner { - border-bottom-width: 0; - border-top: 10px solid transparent; -} - -.dropdown .pointer { - right: auto; - left: 10px; - top: -1px; - z-index: 3; -} - -.dropdown-up .pointer { - bottom: -1px; - top: auto; -} - -.dropdown-left .dropdown .pointer, .nojs .rightside .dropdown .pointer { - left: auto; - right: 10px; -} - -.dropdown .pointer-inner { - top: auto; - bottom: -11px; - left: -10px; -} - -.dropdown-up .pointer-inner { - bottom: auto; - top: -11px; -} - -.dropdown .dropdown-contents { - z-index: 2; - overflow: hidden; - overflow-y: auto; - border: 1px solid transparent; - border-radius: 5px; - padding: 5px; - position: relative; - max-height: 300px; -} - -.dropdown-contents a { - display: block; - padding: 5px; -} - -.jumpbox { - margin: 5px 0; -} - -.jumpbox .dropdown li { - border-top: 1px solid transparent; -} - -.jumpbox .dropdown-select { - margin: 0; -} - -.jumpbox .dropdown-contents { - padding: 0; - text-decoration: none; -} - -.jumpbox .dropdown-contents li { - padding: 0; -} - -.jumpbox .dropdown-contents a { - margin-right: 20px; - padding: 5px 10px; - text-decoration: none; - width: 100%; -} - -.jumpbox .spacer { - display: inline-block; - width: 0px; -} - -.jumpbox .spacer + .spacer { - width: 20px; -} - -.dropdown-contents a { - display: block; - padding: 5px; -} - -.jumpbox .dropdown-select { - margin: 0; -} - -.jumpbox .dropdown-contents a { - text-decoration: none; -} - -.dropdown li { - display: list-item; - border-top: 1px dotted transparent; - float: none !important; - line-height: normal !important; - font-size: 1em !important; - list-style: none; - margin: 0; - white-space: nowrap; - text-align: left; -} - -.dropdown-contents > li { - padding-right: 15px; -} - -.dropdown-nonscroll > li { - padding-right: 0; -} - -.dropdown li:first-child, .dropdown li.separator + li, .dropdown li li { - border-top: 0; -} - -.dropdown li li:first-child { - margin-top: 4px; -} - -.dropdown li li:last-child { - padding-bottom: 0; -} - -.dropdown li li { - border-top: 1px dotted transparent; - padding-left: 18px; -} - -.wrap .dropdown li, .dropdown.wrap li, .dropdown-extended li { - white-space: normal; -} - -.dropdown li.separator { - border-top: 1px solid transparent; - padding: 0; -} - -.dropdown li.separator:first-child, .dropdown li.separator:last-child { - display: none !important; -} - -/* Responsive breadcrumbs -----------------------------------------*/ -.breadcrumbs .crumb { - float: left; - font-weight: bold; - word-wrap: normal; -} - -.breadcrumbs .crumb:before { - content: '\2039'; - font-weight: bold; - padding: 0 0.5em; -} - -.breadcrumbs .crumb:first-child:before { - content: none; -} - -.breadcrumbs .crumb a { - white-space: nowrap; - text-overflow: ellipsis; - vertical-align: bottom; - overflow: hidden; -} - -.breadcrumbs.wrapped .crumb a { letter-spacing: -.3px; } -.breadcrumbs.wrapped .crumb.wrapped-medium a { letter-spacing: -.4px; } -.breadcrumbs.wrapped .crumb.wrapped-tiny a { letter-spacing: -.5px; } - -.breadcrumbs .crumb.wrapped-max a { max-width: 120px; } -.breadcrumbs .crumb.wrapped-wide a { max-width: 100px; } -.breadcrumbs .crumb.wrapped-medium a { max-width: 80px; } -.breadcrumbs .crumb.wrapped-small a { max-width: 60px; } -.breadcrumbs .crumb.wrapped-tiny a { max-width: 40px; } - -/* Table styles -----------------------------------------*/ -table.table1 { - width: 100%; -} - -.ucp-main table.table1 { - padding: 2px; -} - -table.table1 thead th { - font-weight: normal; - text-transform: uppercase; - line-height: 1.3em; - font-size: 1em; - padding: 0 0 4px 3px; -} - -table.table1 thead th span { - padding-left: 7px; -} - -table.table1 tbody tr { - border: 1px solid transparent; -} - -table.table1 td { - font-size: 1.1em; -} - -table.table1 tbody td { - padding: 5px; - border-top: 1px solid transparent; -} - -table.table1 tbody th { - padding: 5px; - border-bottom: 1px solid transparent; - text-align: left; -} - -/* Specific column styles */ -table.table1 .name { text-align: left; } -table.table1 .center { text-align: center; } -table.table1 .reportby { width: 15%; } -table.table1 .posts { text-align: center; width: 7%; } -table.table1 .joined { text-align: left; width: 15%; } -table.table1 .active { text-align: left; width: 15%; } -table.table1 .mark { text-align: center; width: 7%; } -table.table1 .info { text-align: left; width: 30%; } -table.table1 .info div { width: 100%; white-space: normal; overflow: hidden; } -table.table1 .autocol { line-height: 2em; white-space: nowrap; } -table.table1 thead .autocol { padding-left: 1em; } - -table.table1 span.rank-img { - float: right; - width: auto; -} - -table.info td { - padding: 3px; -} - -table.info tbody th { - padding: 3px; - text-align: right; - vertical-align: top; - font-weight: normal; -} - -.forumbg table.table1 { - margin: 0; -} - -.forumbg-table > .inner { - margin: 0 -1px; -} - -.color_palette_placeholder table { - border-collapse: separate; - border-spacing: 1px; -} - -/* Misc layout styles ----------------------------------------- */ -/* column[1-2] styles are containers for two column layouts */ -.column1 { - float: left; - clear: left; - width: 49%; -} - -.column2 { - float: right; - clear: right; - width: 49%; -} - -/* General classes for placing floating blocks */ -.left-box { - float: left; - width: auto; - text-align: left; - max-width: 100%; -} - -.left-box.profile-details { - width: 80%; -} - -.right-box { - float: right; - width: auto; - text-align: right; - max-width: 100%; -} - -dl.details { - /*font-family: "Lucida Grande", Verdana, Helvetica, Arial, sans-serif;*/ - font-size: 1.1em; -} - -dl.details dt { - float: left; - clear: left; - width: 30%; - text-align: right; - display: block; -} - -dl.details dd { - margin-left: 0; - padding-left: 5px; - margin-bottom: 5px; - float: left; - width: 65%; - overflow: hidden; - text-overflow: ellipsis; -} - -.clearfix, fieldset dl, ul.topiclist dl, dl.polls { - overflow: hidden; -} - -fieldset.fields1 ul.recipients { - list-style-type: none; - line-height: 1.8; - max-height: 150px; - overflow-y: auto; -} - -fieldset.fields1 dd.recipients { - clear: left; - margin-left: 1em; -} - -fieldset.fields1 ul.recipients input.button2{ - font-size: 0.8em; - margin-right: 0; - padding: 0; -} - -fieldset.fields1 dl.pmlist > dt { - width: auto !important; -} - -fieldset.fields1 dl.pmlist dd.recipients { - margin-left: 0 !important; -} - -/* Action-bars (container for post/reply buttons, pagination, etc.) ----------------------------------------- */ -.action-bar { - font-size: 11px; - margin: 4px 0; -} - -.forabg + .action-bar { - margin-top: 2em; -} - -.action-bar .button { - margin-right: 5px; - float: left; -} - -.action-bar .button-search { - margin-right: 0; -} - -/* Pagination ----------------------------------------- */ -.pagination { - float: right; - text-align: right; - width: auto; -} - -.action-bar.bar-bottom .pagination { - margin-top: 0; -} - -.action-bar .pagination .button { - margin-right: 0; - float: none; -} - -.pagination > ul { - display: inline-block; - list-style: none !important; - margin-left: 5px; -} - -.pagination > ul > li { - display: inline-block !important; - padding: 0; - font-size: 100%; - line-height: normal; - vertical-align: middle; -} - -.pagination li a, .pagination li span { - border-radius: 2px; - padding: 2px 5px; -} - -.pagination li.active span { - display: inline-block; - font-size: 13px; - font-weight: normal; - font-family: "Open Sans", "Droid Sans", Verdana, Arial, Helvetica; - line-height: 1.4; - text-align: center; - white-space: nowrap; - vertical-align: middle; - border: 1px solid transparent; -} - -.pagination li.ellipsis span { - border: none; - padding: 0; -} - -.pagination li.page-jump { - margin-right: 5px; -} - -.pagination li.page-jump a { - padding: 0 8px; -} - -.pagination li.page-jump a i { - font-size: 21px; -} - -.pagination .arrow a { - padding: 2px 0; -} - -/* Pagination in viewforum for multipage topics */ -.row .pagination { - display: block; - margin-top: 3px; - margin-bottom: 3px; -} - -.row .pagination > ul { - margin: 0; -} - -.row .pagination li a, .row .pagination li span { - border-radius: 2px; - padding: 1px 3px; - font-size: 9px; -} - -/* jQuery popups ----------------------------------------- */ -.phpbb_alert { - border: 1px solid transparent; - display: none; - left: 0; - padding: 0 25px 20px 25px; - position: fixed; - right: 0; - top: 150px; - z-index: 50; - width: 620px; - margin: 0 auto; -} - -@media only screen and (max-height: 500px), only screen and (max-device-width: 500px) -{ - .phpbb_alert { - top: 25px; - } -} - -.phpbb_alert .alert_close { - float: right; - margin-right: -36px; - margin-top: -8px; -} - -.phpbb_alert p { - margin: 8px 0; - padding-bottom: 8px; -} - -.phpbb_alert label { - display: block; - margin: 8px 0; - padding-bottom: 8px; -} - -.phpbb_alert div.alert_text > p, -.phpbb_alert div.alert_text > label, -.phpbb_alert div.alert_text > select, -.phpbb_alert div.alert_text > textarea, -.phpbb_alert div.alert_text > input { - font-size: 1.1em; -} - -.darkenwrapper { - display: none; - position: relative; - z-index: 44; -} - -.darken { - position: fixed; - left: 0; - top: 0; - width: 100%; - height: 100%; - opacity: 0.5; - z-index: 45; -} - -.loading_indicator { - background: center center no-repeat; - border-radius: 5px; - display: none; - opacity: 0.8; - margin-top: -50px; - margin-left: -50px; - height: 50px; - width: 50px; - position: fixed; - left: 50%; - top: 50%; - z-index: 51; -} - -/* Miscellaneous styles ----------------------------------------- */ -.copyright { - font-size: 10px; - text-align: center; - padding: 10px; -} - -.footer-row { - font-size: 10px; - line-height: 1.8; - margin: 0; -} - -.small { - font-size: 0.9em !important; -} - -.titlespace { - margin-bottom: 15px; -} - -.headerspace { - margin-top: 20px; -} - -.error { - font-weight: bold; - font-size: 1em; -} - -div.rules { - margin: 10px 0; - font-size: 1.1em; - padding: 5px 10px; - border-radius: 7px; -} - -div.rules ul, div.rules ol { - margin-left: 20px; -} - -p.post-notice { - position: relative; - padding: 5px; - min-height: 14px; - margin-bottom: 1em; -} - -form > p.post-notice strong { - line-height: 20px; -} - -.stat-block { - clear: both; -} - -.top-anchor { - display: block; - position: absolute; - top: -20px; -} - -.clear { - display: block; - clear: both; - font-size: 1px; - line-height: 1px; - background: transparent; -} - -/* Inner box-model clearing */ -.inner:after, -ul.linklist:after, -.action-bar:after, -.notification_text:after, -.tabs-container:after, -.tabs > ul:after, -.minitabs > ul:after, -.postprofile .avatar-container:after { - clear: both; - content: ''; - display: block; -} - -.emoji { - min-height: 18px; - min-width: 18px; - height: 1em; - width: 1em; -} - -.smilies { - vertical-align: text-bottom; -} - -.icon-notification { - position: relative; -} - -.member-search { - float: left; - margin: 0; - padding: 6px 10px; -} - -.member-search strong { - font-size: 0.95em; -} - -.dropdown-extended { - display: none; - z-index: 1; -} - -.dropdown-extended ul { - max-height: 350px; - overflow-y: auto; - overflow-x: hidden; - clear: both; -} - -.dropdown-extended ul li { - padding: 0; - margin: 0 !important; - float: none; - border-top: 1px solid; - list-style-type: none; - font-size: 0.95em; - clear: both; - position: relative; -} - -.dropdown-extended ul li:first-child { - border-top: none; -} - -.dropdown-extended ul li.no_notifications { - padding: 10px; -} - -.dropdown-extended .dropdown-contents { - max-height: none; - padding: 0; - position: absolute; - width: 340px; -} - -.nojs .dropdown-extended .dropdown-contents { - position: relative; -} - -.dropdown-extended .header { - padding: 0 10px; - font-family: Arial, "Helvetica Neue", Helvetica, Arial, sans-serif; - font-weight: bold; - text-align: left; - text-shadow: 1px 1px 1px white; - text-transform: uppercase; - line-height: 3em; - border-bottom: 1px solid; - border-radius: 5px 5px 0 0; -} - -.dropdown-extended .header .header_settings { - float: right; - font-weight: normal; - text-transform: none; -} - -.dropdown-extended .header .header_settings a { - display: inline-block; - padding: 0 5px; -} - -.dropdown-extended .header:after { - content: ''; - display: table; - clear: both; -} - -.dropdown-extended .footer { - text-align: center; - font-size: 1.1em; -} - -.dropdown-extended ul li a, .dropdown-extended ul li.no-url { - padding: 8px; -} - -.dropdown-extended .footer > a { - padding: 5px 0; -} - -.dropdown-extended ul li a, .notification_list dt > a, .dropdown-extended .footer > a { - display: block; - text-decoration: none; -} - -.notification_list ul li img { - float: left; - max-height: 50px; - max-width: 50px; - width: auto !important; - height: auto !important; - margin-right: 5px; -} - -.notification_list ul li p { - margin-bottom: 4px; - font-size: 1em; -} - -.notification_list p.notification-reference, -.notification_list p.notification-location, -.notification_list li a p.notification-reason { - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} - -.notification_list p.notification-time { - font-size: 0.9em; - margin: 0; - text-align: right; -} - -.notification_list div.notifications { - margin-left: 50px; - padding: 5px; -} - -.notification_list div.notifications a { - display: block; -} - -.notification_list p.notifications_title { - font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; - font-size: 1.2em !important; -} - -.notification_list p.notifications_title strong { - font-weight: bold; -} - -.notification_list p.notifications_time { - font-size: 0.9em !important; -} - -.notification_text { - margin-left: 58px; -} - -.badge { - border-radius: 10px; - opacity: 0.8; - text-align: center; - white-space: nowrap; - font-size: 10px; - line-height: 1; - float: right; - display: inline-block; - margin-left: 3px; - vertical-align: baseline; - position: relative; - top: 3px; - padding: 4px 6px; -} - -.badge.hidden { - display: none; -} - -/* Navbar specific list items -----------------------------------------*/ - -.linklist .quick-links { - margin: 0 7px 0 0; -} - -.linklist.compact .rightside > a > span { - display: none; -} - -.dropdown-page-jump .dropdown { - top: 20px; -} - -.dropdown-page-jump.dropdown-up .dropdown { - bottom: 20px; -} - -.dropdown-page-jump input.tiny { - width: 50px; -} - -.dropdown .clone.hidden { - display: none; -} - -.dropdown .clone.hidden + li.separator { - display: none; -} - -.dropdown .clone.hidden + li { - border-top: none; -} diff --git a/install/update/new/styles/prosilver/theme/forms.css b/install/update/new/styles/prosilver/theme/forms.css deleted file mode 100644 index 99c898f..0000000 --- a/install/update/new/styles/prosilver/theme/forms.css +++ /dev/null @@ -1,429 +0,0 @@ -/* Form Styles ----------------------------------------- */ - -/* General form styles -----------------------------------------*/ -fieldset { - border-width: 0; - font-family: Verdana, Helvetica, Arial, sans-serif; - font-size: 1.1em; -} - -input { - font-weight: normal; - vertical-align: middle; - padding: 0 3px; - font-size: 1em; - font-family: Verdana, Helvetica, Arial, sans-serif; -} - -select { - font-family: Verdana, Helvetica, Arial, sans-serif; - font-weight: normal; - cursor: pointer; - vertical-align: middle; - border: 1px solid transparent; - padding: 1px; - font-size: 1em; -} - -select:focus { - outline-style: none; -} - -option { - padding-right: 1em; -} - -select optgroup option { - padding-right: 1em; - font-family: Verdana, Helvetica, Arial, sans-serif; -} - -textarea { - font-family: "Lucida Grande", Verdana, Helvetica, Arial, sans-serif; - width: 60%; - padding: 2px; - font-size: 1em; - line-height: 1.4em; -} - -label { - cursor: default; - padding-right: 5px; -} - -label input { - vertical-align: middle; -} - -label img { - vertical-align: middle; -} - -/* Definition list layout for forms ----------------------------------------- */ -fieldset dl { - padding: 4px 0; -} - -fieldset dt { - float: left; - width: 40%; - text-align: left; - display: block; -} - -fieldset dd { - margin-left: 41%; - vertical-align: top; - margin-bottom: 3px; -} - -/* Specific layout 1 */ -fieldset.fields1 dt { - width: 15em; - border-right-width: 0; -} - -fieldset.fields1 dd { - margin-left: 15em; - border-left-width: 0; -} - -fieldset.fields1 div { - margin-bottom: 3px; -} - -/* Set it back to 0px for the reCaptcha divs: PHPBB3-9587 */ -fieldset.fields1 .live-search div { - margin-bottom: 0; -} - -/* Specific layout 2 */ -fieldset.fields2 dt { - width: 15em; - border-right-width: 0; -} - -fieldset.fields2 dd { - margin-left: 16em; - border-left-width: 0; -} - -/* Form elements */ -dt label { - font-weight: bold; - text-align: left; -} - -dd label { - white-space: nowrap; -} - -dd input, dd textarea { - margin-right: 3px; -} - -dd select { - width: auto; -} - -dd select[multiple] { - width: 100%; -} - -dd textarea { - width: 85%; -} - -/* Hover effects */ -.timezone { - width: 95%; -} - -/* Browser-specific tweaks */ -button::-moz-focus-inner { - padding: 0; - border: 0 -} - -/* Quick-login on index page */ -fieldset.quick-login { - margin-top: 5px; -} - -fieldset.quick-login input { - width: auto; -} - -fieldset.quick-login input.inputbox { - width: 15%; - vertical-align: middle; - margin-right: 5px; -} - -fieldset.quick-login label { - white-space: nowrap; - padding-right: 2px; -} - -/* Display options on viewtopic/viewforum pages */ -fieldset.display-options { - text-align: center; - margin: 3px 0 5px 0; -} - -fieldset.display-options label { - white-space: nowrap; - padding-right: 2px; -} - -fieldset.display-options a { - margin-top: 3px; -} - -.dropdown fieldset.display-options { - font-size: 1em; - margin: 0; - padding: 0; -} - -.dropdown fieldset.display-options label { - display: block; - margin: 4px; - padding: 0; - text-align: right; - white-space: nowrap; -} - -.dropdown fieldset.display-options select { - min-width: 120px; -} - -/* Display actions for ucp and mcp pages */ -fieldset.display-actions { - text-align: right; - line-height: 2em; - white-space: nowrap; - padding-right: 1em; -} - -fieldset.display-actions label { - white-space: nowrap; - padding-right: 2px; -} - -fieldset.sort-options { - line-height: 2em; -} - -/* MCP forum selection*/ -fieldset.forum-selection { - margin: 5px 0 3px 0; - float: right; -} - -fieldset.forum-selection2 { - margin: 13px 0 3px 0; - float: right; -} - -/* Submit button fieldset */ -fieldset.submit-buttons { - text-align: center; - vertical-align: middle; - margin: 5px 0; -} - -fieldset.submit-buttons input { - vertical-align: middle; -} - -/* Posting page styles -----------------------------------------*/ - -/* Buttons used in the editor */ -.format-buttons { - margin: 15px 0 2px 0; -} - -.format-buttons input, .format-buttons select { - vertical-align: middle; -} - -/* Main message box */ -.message-box { - width: 80%; -} - -.message-box textarea { - font-family: "Trebuchet MS", Verdana, Helvetica, Arial, sans-serif; - width: 450px; - height: 270px; - min-width: 100%; - max-width: 100%; - font-size: 1.2em; - resize: vertical; - outline: 3px dashed transparent; - outline-offset: -4px; - -webkit-transition: all .5s ease, height 1ms linear; - -moz-transition: all .5s ease, height 1ms linear; - -ms-transition: all .5s ease, height 1ms linear; - -o-transition: all .5s ease, height 1ms linear; - transition: all .5s ease, height 1ms linear; -} - -/* Emoticons panel */ -.smiley-box { - width: 18%; - float: right; -} - -.smiley-box img { - margin: 3px; -} - -/* Input field styles ----------------------------------------- */ -.inputbox { - border: 1px solid transparent; - padding: 2px; -} - -.inputbox:hover, .inputbox:focus { - border: 1px solid transparent; - outline-style: none; -} - -input.inputbox { width: 85%; } -input.medium { width: 50%; } -input.narrow { width: 25%; } -input.tiny { width: 150px; } - -textarea.inputbox { - width: 85%; -} - -.autowidth { - width: auto !important; -} - -input[type="number"] { - -moz-padding-end: 0; -} - -input[type="search"] { - -webkit-appearance: textfield; - -webkit-box-sizing: content-box; -} - -input[type="search"]::-webkit-search-decoration, input[type="search"]::-webkit-search-results-button, input[type="search"]::-webkit-search-results-decoration { - display: none; -} - -input[type="search"]::-webkit-search-cancel-button { - cursor: pointer; -} - -/* Form button styles ----------------------------------------- */ -input.button1, input.button2 { - font-size: 1em; -} - -a.button1, input.button1, input.button3, a.button2, input.button2 { - width: auto !important; - padding-top: 1px; - padding-bottom: 1px; - font-family: "Lucida Grande", Verdana, Helvetica, Arial, sans-serif; - background: transparent none repeat-x top left; - line-height: 1.5; -} - -a.button1, input.button1 { - font-weight: bold; - border: 1px solid transparent; -} - -input.button3 { - padding: 0; - margin: 0; - line-height: 5px; - height: 12px; - background-image: none; - font-variant: small-caps; -} - -input[type="button"], input[type="submit"], input[type="reset"], input[type="checkbox"], input[type="radio"], .search-results li { - cursor: pointer; -} - -/* Alternative button */ -a.button2, input.button2, input.button3 { - border: 1px solid transparent; -} - -/* button in the style of the form buttons */ -a.button1, a.button2 { - text-decoration: none; - padding: 0 3px; - vertical-align: text-bottom; -} - -/* Hover states */ -a.button1:hover, input.button1:hover, a.button2:hover, input.button2:hover, input.button3:hover { - border: 1px solid transparent; -} - -input.disabled { - font-weight: normal; -} - -/* Focus states */ -input.button1:focus, input.button2:focus, input.button3:focus { - outline-style: none; -} - -/* Topic and forum Search */ -.search-box { - float: left; -} - -.search-box .inputbox { - background-image: none; - border-right-width: 0; - border-radius: 4px 0 0 4px; - float: left; - height: 24px; - padding: 3px; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; -} - -/* Search box (header) ---------------------------------------------- */ -.search-header { - border-radius: 4px; - display: block; - float: right; - margin-right: 5px; - margin-top: 30px; -} - -.search-header .inputbox { border: 0; } - -.navbar .linklist > li.responsive-search { display: none; } - -input.search { - background-image: none; - background-repeat: no-repeat; - background-position: left 1px; - padding-left: 17px; -} - -.full { width: 95%; } -.medium { width: 50%;} -.narrow { width: 25%;} -.tiny { width: 10%;} diff --git a/install/update/new/styles/prosilver/theme/icons.css b/install/update/new/styles/prosilver/theme/icons.css deleted file mode 100644 index 3ac5984..0000000 --- a/install/update/new/styles/prosilver/theme/icons.css +++ /dev/null @@ -1,96 +0,0 @@ -/* -------------------------------------------------------------- - $Icons --------------------------------------------------------------- */ - -/* Global module setup ---------------------------------*/ - -/* Renamed version of .fa class for agnostic usage of icon fonts. - * Just change the name of the font after the 14/1 to the name of - * the font you wish to use. - */ -.icon, .button .icon, blockquote cite:before, .uncited:before { - display: inline-block; - font-weight: normal; - font-style: normal; - font-variant: normal; - font-family: FontAwesome; - font-size: 14px; - line-height: 1; - text-rendering: auto; /* optimizelegibility throws things off #1094 */ - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -.icon:before { padding-right: 2px; } - -.button .icon:before { - padding-right: 0; -} - -/* Icon size classes - Default size is 14px, use these for small variations */ - -.icon.icon-xl { - font-size: 20px; -} - -.icon.icon-lg { - font-size: 16px; -} - -.icon.icon-md { - font-size: 10px; -} - -.icon.icon-sm { - font-size: 8px; -} - -/* icon modifiers */ -.icon-tiny { - width: 12px; - transform: scale(0.65, 0.75); - vertical-align: text-bottom; - font-size: 16px; -} - -.arrow-left .icon { - float: left; -} - -.arrow-left:hover .icon { - margin-left: -5px; - margin-right: 5px; -} - -.arrow-right .icon { - float: right; -} - -.arrow-right:hover .icon { - margin-left: 5px; - margin-right: -5px; -} - -.post-buttons .dropdown-contents .icon { - float: right; - margin-left: 5px; -} - -.alert_close .icon:before { - padding: 0; - border-radius: 50%; - width: 11px; - display: block; - line-height: .9; - height: 12px; -} - -blockquote cite:before, .uncited:before { - content: '\f10d'; /* Font Awesome quote-left */ -} - -.rtl blockquote cite:before, .rtl .uncited:before { - content: '\f10e'; /* Font Awesome quote-right */ -} - diff --git a/install/update/new/styles/prosilver/theme/images/site_logo.svg b/install/update/new/styles/prosilver/theme/images/site_logo.svg deleted file mode 100644 index 4ce8903..0000000 --- a/install/update/new/styles/prosilver/theme/images/site_logo.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/install/update/new/styles/prosilver/theme/plupload.css b/install/update/new/styles/prosilver/theme/plupload.css deleted file mode 100644 index b1f3ae2..0000000 --- a/install/update/new/styles/prosilver/theme/plupload.css +++ /dev/null @@ -1,90 +0,0 @@ -.attach-panel-multi { - display: none; - margin-bottom: 1em; -} - -.attach-row-tpl { - display: none; -} - -.file-list td { - vertical-align: middle; -} - -.attach-name { - width: 50%; -} - -.attach-comment { - width: 30%; -} - -.attach-comment .inputbox { - resize: vertical; - width: 100%; -} - -.attach-filesize { - width: 15%; -} - -.attach-status { - width: 5%; -} - -.attach-filesize, .attach-status { - text-align: center; -} - -.attach-controls { - display: inline-block; - float: right; -} - -.nojs .file-inline-bbcode { - display: none; -} - -.file-total-progress { - height: 2px; - display: block; - position: relative; - margin: 4px -10px -6px -10px; -} - -.file-progress { - background-color: #CCCCCC; - display:inline-block; - height: 8px; - width: 50px; -} - -.file-progress-bar, .file-total-progress-bar { - background-color: green; - display: block; - height: 100%; - width: 0; -} - -.file-status.file-working { - background: url('./images/plupload/throbber.gif'); -} - -.file-status.file-uploaded { - background: url('./images/plupload/done.gif'); -} - -.file-status.file-error { - background: url('./images/plupload/error.gif'); -} - -.file-status { - display: inline-block; - height: 16px; - width: 16px; -} - -.file-name { - max-width: 65%; - vertical-align: bottom; -} diff --git a/install/update/new/styles/prosilver/theme/print.css b/install/update/new/styles/prosilver/theme/print.css deleted file mode 100644 index ee916dc..0000000 --- a/install/update/new/styles/prosilver/theme/print.css +++ /dev/null @@ -1,150 +0,0 @@ -/* Print Style Sheet ----------------------------------------- */ - - -/* Lots still TODO here! */ - -/* General markup styles */ -* { - padding: 0; - margin: 0; -} - -body { - font: 11pt Verdana, Arial, Helvetica, sans-serif; - color:#000000; -} - -a:link { color: #000000; text-decoration: none; } -a:visited { color: #000000; text-decoration: none; } -a:active { color: #000000; text-decoration: none; } - -img, .noprint, .navbar, .box1, .divider, .signature { display: none; } -/* Display smilies (Bug #47265) */ -.content img { - display: inline; -} - -/* Container for the main body */ -.wrap { - margin: 0 2em; -} - -p { font-size: 85%; } -.copyright { font-size: 75%; } -.page-number { float:right; width: auto; text-align: right; font-size: 75%; } - -h1, h2, h3, h1 a, h2 a, h3 a { - font-family: "Trebuchet MS",georgia,Verdana,Sans-serif; - color: #000000; - background: none; - text-decoration: none; - font-weight: bold; -} - -h1 { font-size: 20pt; } -h2 { font-size: 16pt; margin-top: 1em; } -h3 { font-size: 14pt; margin-top: 1em; } - -.content { - font-size: 11pt; - line-height: 14pt; - margin-bottom: 1em; - font-family: "Lucida Grande", "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif; - overflow: hidden; -} - -/* CSS2 Print tip from: http://www.alistapart.com/articles/goingtoprint/ */ -.postbody a:link, .postbody a:visited, .postbody a:hover, .postbody a:active { - text-decoration: underline; - padding: 0.1em 0.2em; - margin: -0.1em -0.2em; - color: #666; - background: none; - font-size: 100%; -} - -html>body .postbody a:link:after, html>body .postbody a:visited:after { - content: " (" attr(href) ") "; - font-size: 90%; - text-decoration: none; -} - -hr { - height: 1px; - background-color: #999999; - border-width: 0; -} - -.author { - font-family: Verdana, Arial, Helvetica, sans-serif; - font-size: 75%; - margin-bottom: 0.6em; -} - -.date { - font-family: Verdana, Arial, Helvetica, sans-serif; - float: right; - position: relative; - text-align: right; - font-size: 75%; -} - -/* Don't want to print url for names or titles in content area */ -.postbody .author a:link, .postbody .author a:visited, -html>body .postbody .author a:link:after, -html>body .postbody .author a:visited:after, -.postquote .quote-by a:link, .postquote .quote-by a:visited, -html>body .postquote .quote-by a:link:after, -html>body .postquote .quote-by a:visited:after, -html>body .postbody h1 a:link:after, html>body .postbody h2 a:link:after { - text-decoration: none; - content: ""; -} - -/* Poster profile */ -.postprofile { display: none; } -.grip-show { display:none; } - -/* Quote */ -.postquote, blockquote { - font-size: 85%; - margin: 1em 18% 1em 4%; - padding: 0.5em; - position: relative; - line-height: 1.5em; - border: 1px #999999 solid; -} - -.postquote img { display: none; } -.postquote span { display: block; } -.postquote span .postquote { font-size: 100%; } -.quote-by, blockquote cite { - color: black; - display : block; - font-weight: bold; -} - -/* List */ -ol, ul { - margin-left: 15pt -} - -/* Misc page elements */ -div.spacer { clear: both; } - -code { display: block; } - -/* Accessibility tweaks: Mozilla.org */ -.skip_link { display: none; } - -.codebox p { display: none; } - -/* stylelint-disable declaration-property-unit-whitelist */ -.emoji { - min-height: 18px; - min-width: 18px; - height: 1em; - width: 1em; -} -/* stylelint-enable declaration-property-unit-whitelist */ diff --git a/install/update/new/styles/prosilver/theme/stylesheet.css b/install/update/new/styles/prosilver/theme/stylesheet.css deleted file mode 100644 index c402d56..0000000 --- a/install/update/new/styles/prosilver/theme/stylesheet.css +++ /dev/null @@ -1,21 +0,0 @@ -/* phpBB3 Style Sheet - -------------------------------------------------------------- - Style name: prosilver (the default phpBB 3.3.x style) - Based on style: - Original author: Tom Beddard ( http://www.subblue.com/ ) - Modified by: phpBB Limited ( https://www.phpbb.com/ ) - -------------------------------------------------------------- -*/ - -@import url("normalize.css?v=3.3"); -@import url("base.css?v=3.3"); -@import url("utilities.css?v=3.3"); -@import url("common.css?v=3.3"); -@import url("links.css?v=3.3"); -@import url("content.css?v=3.3"); -@import url("buttons.css?v=3.3"); -@import url("cp.css?v=3.3"); -@import url("forms.css?v=3.3"); -@import url("icons.css?v=3.3"); -@import url("colours.css?v=3.3"); -@import url("responsive.css?v=3.3"); diff --git a/install/update/new/ucp.php b/install/update/new/ucp.php deleted file mode 100644 index 0992e3e..0000000 --- a/install/update/new/ucp.php +++ /dev/null @@ -1,413 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -define('IN_PHPBB', true); -$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); -require($phpbb_root_path . 'common.' . $phpEx); -require($phpbb_root_path . 'includes/functions_user.' . $phpEx); -require($phpbb_root_path . 'includes/functions_module.' . $phpEx); - -// Basic parameter data -$id = $request->variable('i', ''); -$mode = $request->variable('mode', ''); - -if (in_array($mode, array('login', 'login_link', 'logout', 'confirm', 'sendpassword', 'activate'))) -{ - define('IN_LOGIN', true); -} - -if ($mode === 'delete_cookies') -{ - define('SKIP_CHECK_BAN', true); - define('SKIP_CHECK_DISABLED', true); -} - -// Start session management -$user->session_begin(); -$auth->acl($user->data); -$user->setup('ucp'); - -// Setting a variable to let the style designer know where he is... -$template->assign_var('S_IN_UCP', true); - -$module = new p_master(); -$default = false; - -// Basic "global" modes -switch ($mode) -{ - case 'activate': - $module->load('ucp', 'activate'); - $module->display($user->lang['UCP_ACTIVATE']); - - redirect(append_sid("{$phpbb_root_path}index.$phpEx")); - break; - - case 'resend_act': - $module->load('ucp', 'resend'); - $module->display($user->lang['UCP_RESEND']); - break; - - case 'sendpassword': - /** @var \phpbb\controller\helper $controller_helper */ - $controller_helper = $phpbb_container->get('controller.helper'); - - redirect($controller_helper->route('phpbb_ucp_forgot_password_controller')); - break; - - case 'register': - if ($user->data['is_registered'] || isset($_REQUEST['not_agreed'])) - { - redirect(append_sid("{$phpbb_root_path}index.$phpEx")); - } - - $module->load('ucp', 'register'); - $module->display($user->lang['REGISTER']); - break; - - case 'confirm': - $module->load('ucp', 'confirm'); - break; - - case 'login': - if ($user->data['is_registered']) - { - redirect(append_sid("{$phpbb_root_path}index.$phpEx")); - } - - login_box($request->variable('redirect', "index.$phpEx")); - break; - - case 'login_link': - if ($user->data['is_registered']) - { - redirect(append_sid("{$phpbb_root_path}index.$phpEx")); - } - - $module->load('ucp', 'login_link'); - $module->display($user->lang['UCP_LOGIN_LINK']); - break; - - case 'logout': - if ($user->data['user_id'] != ANONYMOUS && $request->is_set('sid') && $request->variable('sid', '') === $user->session_id) - { - $user->session_kill(); - } - else if ($user->data['user_id'] != ANONYMOUS) - { - meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx")); - - $message = $user->lang['LOGOUT_FAILED'] . '

' . sprintf($user->lang['RETURN_INDEX'], '
', ' '); - trigger_error($message); - } - - redirect(append_sid("{$phpbb_root_path}index.$phpEx")); - break; - - case 'terms': - case 'privacy': - - $message = ($mode == 'terms') ? 'TERMS_OF_USE_CONTENT' : 'PRIVACY_POLICY'; - $title = ($mode == 'terms') ? 'TERMS_USE' : 'PRIVACY'; - - if (empty($user->lang[$message])) - { - if ($user->data['is_registered']) - { - redirect(append_sid("{$phpbb_root_path}index.$phpEx")); - } - - login_box(); - } - - $template->set_filenames(array( - 'body' => 'ucp_agreement.html') - ); - - // Disable online list - page_header($user->lang[$title]); - - $template->assign_vars(array( - 'S_AGREEMENT' => true, - 'AGREEMENT_TITLE' => $user->lang[$title], - 'AGREEMENT_TEXT' => sprintf($user->lang[$message], $config['sitename'], generate_board_url()), - 'U_BACK' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'), - 'L_BACK' => $user->lang['BACK_TO_PREV'], - )); - - page_footer(); - - break; - - case 'delete_cookies': - - // Delete Cookies with dynamic names (do NOT delete poll cookies) - if (confirm_box(true)) - { - $set_time = time() - 31536000; - - foreach ($request->variable_names(\phpbb\request\request_interface::COOKIE) as $cookie_name) - { - $cookie_data = $request->variable($cookie_name, '', true, \phpbb\request\request_interface::COOKIE); - - // Only delete board cookies, no other ones... - if (strpos($cookie_name, $config['cookie_name'] . '_') !== 0) - { - continue; - } - - $cookie_name = str_replace($config['cookie_name'] . '_', '', $cookie_name); - - /** - * Event to save custom cookies from deletion - * - * @event core.ucp_delete_cookies - * @var string cookie_name Cookie name to checking - * @var bool retain_cookie Do we retain our cookie or not, true if retain - * @since 3.1.3-RC1 - */ - $retain_cookie = false; - $vars = array('cookie_name', 'retain_cookie'); - extract($phpbb_dispatcher->trigger_event('core.ucp_delete_cookies', compact($vars))); - if ($retain_cookie) - { - continue; - } - - // Polls are stored as {cookie_name}_poll_{topic_id}, cookie_name_ got removed, therefore checking for poll_ - if (strpos($cookie_name, 'poll_') !== 0) - { - $user->set_cookie($cookie_name, '', $set_time); - } - } - - $user->set_cookie('track', '', $set_time); - $user->set_cookie('u', '', $set_time); - $user->set_cookie('k', '', $set_time); - $user->set_cookie('sid', '', $set_time); - - // We destroy the session here, the user will be logged out nevertheless - $user->session_kill(); - $user->session_begin(); - - meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx")); - - $message = $user->lang['COOKIES_DELETED'] . '

' . sprintf($user->lang['RETURN_INDEX'], '', ''); - trigger_error($message); - } - else - { - confirm_box(false, 'DELETE_COOKIES', ''); - } - - redirect(append_sid("{$phpbb_root_path}index.$phpEx")); - - break; - - case 'switch_perm': - - $user_id = $request->variable('u', 0); - - $sql = 'SELECT * - FROM ' . USERS_TABLE . ' - WHERE user_id = ' . (int) $user_id; - $result = $db->sql_query($sql); - $user_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$auth->acl_get('a_switchperm') || !$user_row || $user_id == $user->data['user_id'] || !check_link_hash($request->variable('hash', ''), 'switchperm')) - { - redirect(append_sid("{$phpbb_root_path}index.$phpEx")); - } - - include($phpbb_root_path . 'includes/acp/auth.' . $phpEx); - - $auth_admin = new auth_admin(); - if (!$auth_admin->ghost_permissions($user_id, $user->data['user_id'])) - { - redirect(append_sid("{$phpbb_root_path}index.$phpEx")); - } - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ACL_TRANSFER_PERMISSIONS', false, array($user_row['username'])); - - $message = sprintf($user->lang['PERMISSIONS_TRANSFERRED'], $user_row['username']) . '

' . sprintf($user->lang['RETURN_INDEX'], '', ''); - - /** - * Event to run code after permissions are switched - * - * @event core.ucp_switch_permissions - * @var int user_id User ID to switch permission to - * @var array user_row User data - * @var string message Success message - * @since 3.1.11-RC1 - */ - $vars = array('user_id', 'user_row', 'message'); - extract($phpbb_dispatcher->trigger_event('core.ucp_switch_permissions', compact($vars))); - - trigger_error($message); - - break; - - case 'restore_perm': - - if (!$user->data['user_perm_from'] || !$auth->acl_get('a_switchperm')) - { - redirect(append_sid("{$phpbb_root_path}index.$phpEx")); - } - - $auth->acl_cache($user->data); - - $sql = 'SELECT username - FROM ' . USERS_TABLE . ' - WHERE user_id = ' . $user->data['user_perm_from']; - $result = $db->sql_query($sql); - $username = $db->sql_fetchfield('username'); - $db->sql_freeresult($result); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ACL_RESTORE_PERMISSIONS', false, array($username)); - - $message = $user->lang['PERMISSIONS_RESTORED'] . '

' . sprintf($user->lang['RETURN_INDEX'], '', ''); - - /** - * Event to run code after permissions are restored - * - * @event core.ucp_restore_permissions - * @var string username User name - * @var string message Success message - * @since 3.1.11-RC1 - */ - $vars = array('username', 'message'); - extract($phpbb_dispatcher->trigger_event('core.ucp_restore_permissions', compact($vars))); - - trigger_error($message); - - break; - - default: - $default = true; - break; -} - -// We use this approach because it does not impose large code changes -if (!$default) -{ - return true; -} - -// Only registered users can go beyond this point -if (!$user->data['is_registered']) -{ - if ($user->data['is_bot']) - { - redirect(append_sid("{$phpbb_root_path}index.$phpEx")); - } - - if ($id == 'pm' && $mode == 'view' && isset($_GET['p'])) - { - $redirect_url = append_sid("{$phpbb_root_path}ucp.$phpEx?i=pm&p=" . $request->variable('p', 0)); - login_box($redirect_url, $user->lang['LOGIN_EXPLAIN_UCP']); - } - - login_box('', $user->lang['LOGIN_EXPLAIN_UCP']); -} - -// Instantiate module system and generate list of available modules -$module->list_modules('ucp'); - -// Check if the zebra module is set -if ($module->is_active('zebra', 'friends')) -{ - // Output listing of friends online - $update_time = $config['load_online_time'] * 60; - - $sql_ary = array( - 'SELECT' => 'u.user_id, u.username, u.username_clean, u.user_colour, MAX(s.session_time) as online_time, MIN(s.session_viewonline) AS viewonline', - - 'FROM' => array( - USERS_TABLE => 'u', - ZEBRA_TABLE => 'z', - ), - - 'LEFT_JOIN' => array( - array( - 'FROM' => array(SESSIONS_TABLE => 's'), - 'ON' => 's.session_user_id = z.zebra_id', - ), - ), - - 'WHERE' => 'z.user_id = ' . $user->data['user_id'] . ' - AND z.friend = 1 - AND u.user_id = z.zebra_id', - - 'GROUP_BY' => 'z.zebra_id, u.user_id, u.username_clean, u.user_colour, u.username', - - 'ORDER_BY' => 'u.username_clean ASC', - ); - - $sql = $db->sql_build_query('SELECT_DISTINCT', $sql_ary); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $which = (time() - $update_time < $row['online_time'] && ($row['viewonline'] || $auth->acl_get('u_viewonline'))) ? 'online' : 'offline'; - - $template->assign_block_vars("friends_{$which}", array( - 'USER_ID' => $row['user_id'], - - 'U_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']), - 'USER_COLOUR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), - 'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), - 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'])) - ); - } - $db->sql_freeresult($result); -} - -// Do not display subscribed topics/forums if not allowed -if (!$config['allow_topic_notify'] && !$config['allow_forum_notify']) -{ - $module->set_display('main', 'subscribed', false); -} - -/** -* Use this event to enable and disable additional UCP modules -* -* @event core.ucp_display_module_before -* @var p_master module Object holding all modules and their status -* @var mixed id Active module category (can be the int or string) -* @var string mode Active module -* @since 3.1.0-a1 -*/ -$vars = array('module', 'id', 'mode'); -extract($phpbb_dispatcher->trigger_event('core.ucp_display_module_before', compact($vars))); - -$template->assign_block_vars('navlinks', array( - 'BREADCRUMB_NAME' => $user->lang('UCP'), - 'U_BREADCRUMB' => append_sid("{$phpbb_root_path}ucp.$phpEx"), -)); - -// Select the active module -$module->set_active($id, $mode); - -// Load and execute the relevant module -$module->load_active(); - -// Assign data to the template engine for the list of modules -$module->assign_tpl_vars(append_sid("{$phpbb_root_path}ucp.$phpEx")); - -// Generate the page, do not display/query online list -$module->display($module->get_page_title()); diff --git a/install/update/new/viewforum.php b/install/update/new/viewforum.php deleted file mode 100644 index eb6b37a..0000000 --- a/install/update/new/viewforum.php +++ /dev/null @@ -1,1064 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -define('IN_PHPBB', true); -$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); -include($phpbb_root_path . 'common.' . $phpEx); -include($phpbb_root_path . 'includes/functions_display.' . $phpEx); - -// Start session -$user->session_begin(); -$auth->acl($user->data); - -// Start initial var setup -$forum_id = $request->variable('f', 0); -$mark_read = $request->variable('mark', ''); -$start = $request->variable('start', 0); - -$default_sort_days = (!empty($user->data['user_topic_show_days'])) ? $user->data['user_topic_show_days'] : 0; -$default_sort_key = (!empty($user->data['user_topic_sortby_type'])) ? $user->data['user_topic_sortby_type'] : 't'; -$default_sort_dir = (!empty($user->data['user_topic_sortby_dir'])) ? $user->data['user_topic_sortby_dir'] : 'd'; - -$sort_days = $request->variable('st', $default_sort_days); -$sort_key = $request->variable('sk', $default_sort_key); -$sort_dir = $request->variable('sd', $default_sort_dir); - -/* @var $pagination \phpbb\pagination */ -$pagination = $phpbb_container->get('pagination'); - -// Check if the user has actually sent a forum ID with his/her request -// If not give them a nice error page. -if (!$forum_id) -{ - trigger_error('NO_FORUM'); -} - -$sql_from = FORUMS_TABLE . ' f'; -$lastread_select = ''; - -// Grab appropriate forum data -if ($config['load_db_lastread'] && $user->data['is_registered']) -{ - $sql_from .= ' LEFT JOIN ' . FORUMS_TRACK_TABLE . ' ft ON (ft.user_id = ' . $user->data['user_id'] . ' - AND ft.forum_id = f.forum_id)'; - $lastread_select .= ', ft.mark_time'; -} - -if ($user->data['is_registered']) -{ - $sql_from .= ' LEFT JOIN ' . FORUMS_WATCH_TABLE . ' fw ON (fw.forum_id = f.forum_id AND fw.user_id = ' . $user->data['user_id'] . ')'; - $lastread_select .= ', fw.notify_status'; -} - -$sql = "SELECT f.* $lastread_select - FROM $sql_from - WHERE f.forum_id = $forum_id"; -$result = $db->sql_query($sql); -$forum_data = $db->sql_fetchrow($result); -$db->sql_freeresult($result); - -if (!$forum_data) -{ - trigger_error('NO_FORUM'); -} - - -// Configure style, language, etc. -$user->setup('viewforum', $forum_data['forum_style']); - -// Redirect to login upon emailed notification links -if (isset($_GET['e']) && !$user->data['is_registered']) -{ - login_box('', $user->lang['LOGIN_NOTIFY_FORUM']); -} - -// Permissions check -if (!$auth->acl_gets('f_list', 'f_list_topics', 'f_read', $forum_id) || ($forum_data['forum_type'] == FORUM_LINK && $forum_data['forum_link'] && !$auth->acl_get('f_read', $forum_id))) -{ - if ($user->data['user_id'] != ANONYMOUS) - { - send_status_line(403, 'Forbidden'); - trigger_error('SORRY_AUTH_READ'); - } - - login_box('', $user->lang['LOGIN_VIEWFORUM']); -} - -// Forum is passworded ... check whether access has been granted to this -// user this session, if not show login box -if ($forum_data['forum_password']) -{ - login_forum_box($forum_data); -} - -// Is this forum a link? ... User got here either because the -// number of clicks is being tracked or they guessed the id -if ($forum_data['forum_type'] == FORUM_LINK && $forum_data['forum_link']) -{ - // Does it have click tracking enabled? - if ($forum_data['forum_flags'] & FORUM_FLAG_LINK_TRACK) - { - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET forum_posts_approved = forum_posts_approved + 1 - WHERE forum_id = ' . $forum_id; - $db->sql_query($sql); - } - - // We redirect to the url. The third parameter indicates that external redirects are allowed. - redirect($forum_data['forum_link'], false, true); - return; -} - -// Build navigation links -generate_forum_nav($forum_data); - -// Forum Rules -if ($auth->acl_get('f_read', $forum_id)) -{ - generate_forum_rules($forum_data); -} - -// Do we have subforums? -$active_forum_ary = $moderators = array(); - -if ($forum_data['left_id'] != $forum_data['right_id'] - 1) -{ - list($active_forum_ary, $moderators) = display_forums($forum_data, $config['load_moderators'], $config['load_moderators']); -} -else -{ - $template->assign_var('S_HAS_SUBFORUM', false); - if ($config['load_moderators']) - { - get_moderators($moderators, $forum_id); - } -} - -// Is a forum specific topic count required? -if ($forum_data['forum_topics_per_page']) -{ - $config['topics_per_page'] = $forum_data['forum_topics_per_page']; -} - -/* @var $phpbb_content_visibility \phpbb\content_visibility */ -$phpbb_content_visibility = $phpbb_container->get('content.visibility'); - -// Dump out the page header and load viewforum template -$topics_count = $phpbb_content_visibility->get_count('forum_topics', $forum_data, $forum_id); -$start = $pagination->validate_start($start, $config['topics_per_page'], $topics_count); - -$page_title = $forum_data['forum_name'] . ($start ? ' - ' . $user->lang('PAGE_TITLE_NUMBER', $pagination->get_on_page($config['topics_per_page'], $start)) : ''); - -/** -* You can use this event to modify the page title of the viewforum page -* -* @event core.viewforum_modify_page_title -* @var string page_title Title of the viewforum page -* @var array forum_data Array with forum data -* @var int forum_id The forum ID -* @var int start Start offset used to calculate the page -* @since 3.2.2-RC1 -*/ -$vars = array('page_title', 'forum_data', 'forum_id', 'start'); -extract($phpbb_dispatcher->trigger_event('core.viewforum_modify_page_title', compact($vars))); - -page_header($page_title, true, $forum_id); - -$template->set_filenames(array( - 'body' => 'viewforum_body.html') -); - -make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"), $forum_id); - -$template->assign_vars(array( - 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . (($start == 0) ? '' : "&start=$start")), -)); - -// Not postable forum or showing active topics? -if (!($forum_data['forum_type'] == FORUM_POST || (($forum_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS) && $forum_data['forum_type'] == FORUM_CAT))) -{ - page_footer(); -} - -// Ok, if someone has only list-access, we only display the forum list. -// We also make this circumstance available to the template in case we want to display a notice. ;) -if (!$auth->acl_gets('f_read', 'f_list_topics', $forum_id)) -{ - $template->assign_vars(array( - 'S_NO_READ_ACCESS' => true, - )); - - page_footer(); -} - -// Handle marking posts -if ($mark_read == 'topics') -{ - $token = $request->variable('hash', ''); - if (check_link_hash($token, 'global')) - { - markread('topics', array($forum_id), false, $request->variable('mark_time', 0)); - } - $redirect_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id); - meta_refresh(3, $redirect_url); - - if ($request->is_ajax()) - { - // Tell the ajax script what language vars and URL need to be replaced - $data = array( - 'NO_UNREAD_POSTS' => $user->lang['NO_UNREAD_POSTS'], - 'UNREAD_POSTS' => $user->lang['UNREAD_POSTS'], - 'U_MARK_TOPICS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'hash=' . generate_link_hash('global') . "&f=$forum_id&mark=topics&mark_time=" . time(), false) : '', - 'MESSAGE_TITLE' => $user->lang['INFORMATION'], - 'MESSAGE_TEXT' => $user->lang['TOPICS_MARKED'] - ); - $json_response = new \phpbb\json_response(); - $json_response->send($data); - } - - trigger_error($user->lang['TOPICS_MARKED'] . '

' . sprintf($user->lang['RETURN_FORUM'], '', '')); -} - -// Do the forum Prune thang - cron type job ... -if (!$config['use_system_cron']) -{ - /* @var $cron \phpbb\cron\manager */ - $cron = $phpbb_container->get('cron.manager'); - - $task = $cron->find_task('cron.task.core.prune_forum'); - $task->set_forum_data($forum_data); - - if ($task->is_ready()) - { - $url = $task->get_url(); - $template->assign_var('RUN_CRON_TASK', 'cron'); - } - else - { - // See if we should prune the shadow topics instead - $task = $cron->find_task('cron.task.core.prune_shadow_topics'); - $task->set_forum_data($forum_data); - - if ($task->is_ready()) - { - $url = $task->get_url(); - $template->assign_var('RUN_CRON_TASK', 'cron'); - } - } -} - -// Forum rules and subscription info -$s_watching_forum = array( - 'link' => '', - 'link_toggle' => '', - 'title' => '', - 'title_toggle' => '', - 'is_watching' => false, -); - -if ($config['allow_forum_notify'] && $forum_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_subscribe', $forum_id) || $user->data['user_id'] == ANONYMOUS)) -{ - $notify_status = (isset($forum_data['notify_status'])) ? $forum_data['notify_status'] : NULL; - watch_topic_forum('forum', $s_watching_forum, $user->data['user_id'], $forum_id, 0, $notify_status, $start, $forum_data['forum_name']); -} - -$s_forum_rules = ''; -gen_forum_auth_level('forum', $forum_id, $forum_data['forum_status']); - -// Topic ordering options -$limit_days = array(0 => $user->lang['ALL_TOPICS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); - -$sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 'r' => $user->lang['REPLIES'], 's' => $user->lang['SUBJECT'], 'v' => $user->lang['VIEWS']); -$sort_by_sql = array('a' => 't.topic_first_poster_name', 't' => array('t.topic_last_post_time', 't.topic_last_post_id'), 'r' => (($auth->acl_get('m_approve', $forum_id)) ? 't.topic_posts_approved + t.topic_posts_unapproved + t.topic_posts_softdeleted' : 't.topic_posts_approved'), 's' => 'LOWER(t.topic_title)', 'v' => 't.topic_views'); - -/** - * Modify the topic ordering if needed - * - * @event core.viewforum_modify_topic_ordering - * @var array sort_by_text Topic ordering options - * @var array sort_by_sql Topic orderings options SQL equivalent - * @since 3.2.5-RC1 - */ -$vars = array( - 'sort_by_text', - 'sort_by_sql', -); -extract($phpbb_dispatcher->trigger_event('core.viewforum_modify_topic_ordering', compact($vars))); - -$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; -gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param, $default_sort_days, $default_sort_key, $default_sort_dir); - -// Limit topics to certain time frame, obtain correct topic count -if ($sort_days) -{ - $min_post_time = time() - ($sort_days * 86400); - - $sql_array = array( - 'SELECT' => 'COUNT(t.topic_id) AS num_topics', - 'FROM' => array( - TOPICS_TABLE => 't', - ), - 'WHERE' => 't.forum_id = ' . $forum_id . ' - AND (t.topic_last_post_time >= ' . $min_post_time . ' - OR t.topic_type = ' . POST_ANNOUNCE . ' - OR t.topic_type = ' . POST_GLOBAL . ') - AND ' . $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.'), - ); - - /** - * Modify the sort data SQL query for getting additional fields if needed - * - * @event core.viewforum_modify_sort_data_sql - * @var int forum_id The forum_id whose topics are being listed - * @var int start Variable containing start for pagination - * @var int sort_days The oldest topic displayable in elapsed days - * @var string sort_key The sorting by. It is one of the first character of (in low case): - * Author, Post time, Replies, Subject, Views - * @var string sort_dir Either "a" for ascending or "d" for descending - * @var array sql_array The SQL array to get the data of all topics - * @since 3.1.9-RC1 - */ - $vars = array( - 'forum_id', - 'start', - 'sort_days', - 'sort_key', - 'sort_dir', - 'sql_array', - ); - extract($phpbb_dispatcher->trigger_event('core.viewforum_modify_sort_data_sql', compact($vars))); - - $result = $db->sql_query($db->sql_build_query('SELECT', $sql_array)); - $topics_count = (int) $db->sql_fetchfield('num_topics'); - $db->sql_freeresult($result); - - if (isset($_POST['sort'])) - { - $start = 0; - } - $sql_limit_time = "AND t.topic_last_post_time >= $min_post_time"; - - // Make sure we have information about day selection ready - $template->assign_var('S_SORT_DAYS', true); -} -else -{ - $sql_limit_time = ''; -} - -// Basic pagewide vars -$post_alt = ($forum_data['forum_status'] == ITEM_LOCKED) ? $user->lang['FORUM_LOCKED'] : $user->lang['POST_NEW_TOPIC']; - -// Display active topics? -$s_display_active = ($forum_data['forum_type'] == FORUM_CAT && ($forum_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS)) ? true : false; - -$s_search_hidden_fields = array('fid' => array($forum_id)); -if ($_SID) -{ - $s_search_hidden_fields['sid'] = $_SID; -} - -if (!empty($_EXTRA_URL)) -{ - foreach ($_EXTRA_URL as $url_param) - { - $url_param = explode('=', $url_param, 2); - $s_search_hidden_fields[$url_param[0]] = $url_param[1]; - } -} - -$template->assign_vars(array( - 'MODERATORS' => (!empty($moderators[$forum_id])) ? implode($user->lang['COMMA_SEPARATOR'], $moderators[$forum_id]) : '', - - 'POST_IMG' => ($forum_data['forum_status'] == ITEM_LOCKED) ? $user->img('button_topic_locked', $post_alt) : $user->img('button_topic_new', $post_alt), - 'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'), - 'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'), - 'FOLDER_IMG' => $user->img('topic_read', 'NO_UNREAD_POSTS'), - 'FOLDER_UNREAD_IMG' => $user->img('topic_unread', 'UNREAD_POSTS'), - 'FOLDER_HOT_IMG' => $user->img('topic_read_hot', 'NO_UNREAD_POSTS_HOT'), - 'FOLDER_HOT_UNREAD_IMG' => $user->img('topic_unread_hot', 'UNREAD_POSTS_HOT'), - 'FOLDER_LOCKED_IMG' => $user->img('topic_read_locked', 'NO_UNREAD_POSTS_LOCKED'), - 'FOLDER_LOCKED_UNREAD_IMG' => $user->img('topic_unread_locked', 'UNREAD_POSTS_LOCKED'), - 'FOLDER_STICKY_IMG' => $user->img('sticky_read', 'POST_STICKY'), - 'FOLDER_STICKY_UNREAD_IMG' => $user->img('sticky_unread', 'POST_STICKY'), - 'FOLDER_ANNOUNCE_IMG' => $user->img('announce_read', 'POST_ANNOUNCEMENT'), - 'FOLDER_ANNOUNCE_UNREAD_IMG'=> $user->img('announce_unread', 'POST_ANNOUNCEMENT'), - 'FOLDER_MOVED_IMG' => $user->img('topic_moved', 'TOPIC_MOVED'), - 'REPORTED_IMG' => $user->img('icon_topic_reported', 'TOPIC_REPORTED'), - 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'TOPIC_UNAPPROVED'), - 'DELETED_IMG' => $user->img('icon_topic_deleted', 'TOPIC_DELETED'), - 'POLL_IMG' => $user->img('icon_topic_poll', 'TOPIC_POLL'), - 'GOTO_PAGE_IMG' => $user->img('icon_post_target', 'GOTO_PAGE'), - - 'L_NO_TOPICS' => ($forum_data['forum_status'] == ITEM_LOCKED) ? $user->lang['POST_FORUM_LOCKED'] : $user->lang['NO_TOPICS'], - - 'S_DISPLAY_POST_INFO' => ($forum_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS)) ? true : false, - - 'S_IS_POSTABLE' => ($forum_data['forum_type'] == FORUM_POST) ? true : false, - 'S_USER_CAN_POST' => ($auth->acl_get('f_post', $forum_id)) ? true : false, - 'S_DISPLAY_ACTIVE' => $s_display_active, - 'S_SELECT_SORT_DIR' => $s_sort_dir, - 'S_SELECT_SORT_KEY' => $s_sort_key, - 'S_SELECT_SORT_DAYS' => $s_limit_days, - 'S_TOPIC_ICONS' => ($s_display_active && count($active_forum_ary)) ? max($active_forum_ary['enable_icons']) : (($forum_data['enable_icons']) ? true : false), - 'U_WATCH_FORUM_LINK' => $s_watching_forum['link'], - 'U_WATCH_FORUM_TOGGLE' => $s_watching_forum['link_toggle'], - 'S_WATCH_FORUM_TITLE' => $s_watching_forum['title'], - 'S_WATCH_FORUM_TOGGLE' => $s_watching_forum['title_toggle'], - 'S_WATCHING_FORUM' => $s_watching_forum['is_watching'], - 'S_FORUM_ACTION' => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . (($start == 0) ? '' : "&start=$start")), - 'S_DISPLAY_SEARCHBOX' => ($auth->acl_get('u_search') && $auth->acl_get('f_search', $forum_id) && $config['load_search']) ? true : false, - 'S_SEARCHBOX_ACTION' => append_sid("{$phpbb_root_path}search.$phpEx"), - 'S_SEARCH_LOCAL_HIDDEN_FIELDS' => build_hidden_fields($s_search_hidden_fields), - 'S_SINGLE_MODERATOR' => (!empty($moderators[$forum_id]) && count($moderators[$forum_id]) > 1) ? false : true, - 'S_IS_LOCKED' => ($forum_data['forum_status'] == ITEM_LOCKED) ? true : false, - 'S_VIEWFORUM' => true, - - 'U_MCP' => ($auth->acl_get('m_', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "f=$forum_id&i=main&mode=forum_view", true, $user->session_id) : '', - 'U_POST_NEW_TOPIC' => ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS) ? append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=post&f=' . $forum_id) : '', - 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . ((strlen($u_sort_param)) ? "&$u_sort_param" : '') . (($start == 0) ? '' : "&start=$start")), - 'U_CANONICAL' => generate_board_url() . '/' . append_sid("viewforum.$phpEx", "f=$forum_id" . (($start) ? "&start=$start" : ''), true, ''), - 'U_MARK_TOPICS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'hash=' . generate_link_hash('global') . "&f=$forum_id&mark=topics&mark_time=" . time()) : '', -)); - -// Grab icons -$icons = $cache->obtain_icons(); - -// Grab all topic data -$rowset = $announcement_list = $topic_list = $global_announce_forums = array(); - -$sql_array = array( - 'SELECT' => 't.*', - 'FROM' => array( - TOPICS_TABLE => 't' - ), - 'LEFT_JOIN' => array(), -); - -/** -* Event to modify the SQL query before the topic data is retrieved -* -* It may also be used to override the above assigned template vars -* -* @event core.viewforum_get_topic_data -* @var array forum_data Array with forum data -* @var array sql_array The SQL array to get the data of all topics -* @var int forum_id The forum_id whose topics are being listed -* @var int topics_count The total number of topics for display -* @var int sort_days The oldest topic displayable in elapsed days -* @var string sort_key The sorting by. It is one of the first character of (in low case): -* Author, Post time, Replies, Subject, Views -* @var string sort_dir Either "a" for ascending or "d" for descending -* @since 3.1.0-a1 -* @changed 3.1.0-RC4 Added forum_data var -* @changed 3.1.4-RC1 Added forum_id, topics_count, sort_days, sort_key and sort_dir vars -* @changed 3.1.9-RC1 Fix types of properties -*/ -$vars = array( - 'forum_data', - 'sql_array', - 'forum_id', - 'topics_count', - 'sort_days', - 'sort_key', - 'sort_dir', -); -extract($phpbb_dispatcher->trigger_event('core.viewforum_get_topic_data', compact($vars))); - -$sql_approved = ' AND ' . $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.'); - -if ($user->data['is_registered']) -{ - if ($config['load_db_track']) - { - $sql_array['LEFT_JOIN'][] = array('FROM' => array(TOPICS_POSTED_TABLE => 'tp'), 'ON' => 'tp.topic_id = t.topic_id AND tp.user_id = ' . $user->data['user_id']); - $sql_array['SELECT'] .= ', tp.topic_posted'; - } - - if ($config['load_db_lastread']) - { - $sql_array['LEFT_JOIN'][] = array('FROM' => array(TOPICS_TRACK_TABLE => 'tt'), 'ON' => 'tt.topic_id = t.topic_id AND tt.user_id = ' . $user->data['user_id']); - $sql_array['SELECT'] .= ', tt.mark_time'; - - if ($s_display_active && count($active_forum_ary)) - { - $sql_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TRACK_TABLE => 'ft'), 'ON' => 'ft.forum_id = t.forum_id AND ft.user_id = ' . $user->data['user_id']); - $sql_array['SELECT'] .= ', ft.mark_time AS forum_mark_time'; - } - } -} - -if ($forum_data['forum_type'] == FORUM_POST) -{ - // Get global announcement forums - $g_forum_ary = $auth->acl_getf('f_read', true); - $g_forum_ary = array_unique(array_keys($g_forum_ary)); - - $sql_anounce_array['LEFT_JOIN'] = $sql_array['LEFT_JOIN']; - $sql_anounce_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 'f.forum_id = t.forum_id'); - $sql_anounce_array['SELECT'] = $sql_array['SELECT'] . ', f.forum_name'; - - // Obtain announcements ... removed sort ordering, sort by time in all cases - $sql_ary = array( - 'SELECT' => $sql_anounce_array['SELECT'], - 'FROM' => $sql_array['FROM'], - 'LEFT_JOIN' => $sql_anounce_array['LEFT_JOIN'], - - 'WHERE' => '(t.forum_id = ' . $forum_id . ' - AND t.topic_type = ' . POST_ANNOUNCE . ') OR - (' . $db->sql_in_set('t.forum_id', $g_forum_ary, false, true) . ' - AND t.topic_type = ' . POST_GLOBAL . ')', - - 'ORDER_BY' => 't.topic_time DESC', - ); - - /** - * Event to modify the SQL query before the announcement topic ids data is retrieved - * - * @event core.viewforum_get_announcement_topic_ids_data - * @var array forum_data Data about the forum - * @var array g_forum_ary Global announcement forums array - * @var array sql_anounce_array SQL announcement array - * @var array sql_ary SQL query array to get the announcement topic ids data - * @var int forum_id The forum ID - * - * @since 3.1.10-RC1 - */ - $vars = array( - 'forum_data', - 'g_forum_ary', - 'sql_anounce_array', - 'sql_ary', - 'forum_id', - ); - extract($phpbb_dispatcher->trigger_event('core.viewforum_get_announcement_topic_ids_data', compact($vars))); - - $sql = $db->sql_build_query('SELECT', $sql_ary); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if (!$phpbb_content_visibility->is_visible('topic', $row['forum_id'], $row)) - { - // Do not display announcements that are waiting for approval or soft deleted. - continue; - } - - $rowset[$row['topic_id']] = $row; - $announcement_list[] = $row['topic_id']; - - if ($forum_id != $row['forum_id']) - { - $topics_count++; - $global_announce_forums[] = $row['forum_id']; - } - } - $db->sql_freeresult($result); -} - -$forum_tracking_info = array(); - -if ($user->data['is_registered'] && $config['load_db_lastread']) -{ - $forum_tracking_info[$forum_id] = $forum_data['mark_time']; - - if (!empty($global_announce_forums)) - { - $sql = 'SELECT forum_id, mark_time - FROM ' . FORUMS_TRACK_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $global_announce_forums) . ' - AND user_id = ' . $user->data['user_id']; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $forum_tracking_info[$row['forum_id']] = $row['mark_time']; - } - $db->sql_freeresult($result); - } -} - -// If the user is trying to reach late pages, start searching from the end -$store_reverse = false; -$sql_limit = $config['topics_per_page']; -if ($start > $topics_count / 2) -{ - $store_reverse = true; - - // Select the sort order - $direction = (($sort_dir == 'd') ? 'ASC' : 'DESC'); - - $sql_limit = $pagination->reverse_limit($start, $sql_limit, $topics_count - count($announcement_list)); - $sql_start = $pagination->reverse_start($start, $sql_limit, $topics_count - count($announcement_list)); -} -else -{ - // Select the sort order - $direction = (($sort_dir == 'd') ? 'DESC' : 'ASC'); - $sql_start = $start; -} - -/** - * Modify the topics sort ordering if needed - * - * @event core.viewforum_modify_sort_direction - * @var string direction Topics sort order - * @since 3.2.5-RC1 - */ -$vars = array( - 'direction', -); -extract($phpbb_dispatcher->trigger_event('core.viewforum_modify_sort_direction', compact($vars))); - -if (is_array($sort_by_sql[$sort_key])) -{ - $sql_sort_order = implode(' ' . $direction . ', ', $sort_by_sql[$sort_key]) . ' ' . $direction; -} -else -{ - $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . $direction; -} - -if ($forum_data['forum_type'] == FORUM_POST || !count($active_forum_ary)) -{ - $sql_where = 't.forum_id = ' . $forum_id; -} -else if (empty($active_forum_ary['exclude_forum_id'])) -{ - $sql_where = $db->sql_in_set('t.forum_id', $active_forum_ary['forum_id']); -} -else -{ - $get_forum_ids = array_diff($active_forum_ary['forum_id'], $active_forum_ary['exclude_forum_id']); - $sql_where = (count($get_forum_ids)) ? $db->sql_in_set('t.forum_id', $get_forum_ids) : 't.forum_id = ' . $forum_id; -} - -// Grab just the sorted topic ids -$sql_ary = array( - 'SELECT' => 't.topic_id', - 'FROM' => array( - TOPICS_TABLE => 't', - ), - 'WHERE' => "$sql_where - AND t.topic_type IN (" . POST_NORMAL . ', ' . POST_STICKY . ") - $sql_approved - $sql_limit_time", - 'ORDER_BY' => 't.topic_type ' . ((!$store_reverse) ? 'DESC' : 'ASC') . ', ' . $sql_sort_order, -); - -/** -* Event to modify the SQL query before the topic ids data is retrieved -* -* @event core.viewforum_get_topic_ids_data -* @var array forum_data Data about the forum -* @var array sql_ary SQL query array to get the topic ids data -* @var string sql_approved Topic visibility SQL string -* @var int sql_limit Number of records to select -* @var string sql_limit_time SQL string to limit topic_last_post_time data -* @var array sql_sort_order SQL sorting string -* @var int sql_start Offset point to start selection from -* @var string sql_where SQL WHERE clause string -* @var bool store_reverse Flag indicating if we select from the late pages -* -* @since 3.1.0-RC4 -* -* @changed 3.1.3 Added forum_data -*/ -$vars = array( - 'forum_data', - 'sql_ary', - 'sql_approved', - 'sql_limit', - 'sql_limit_time', - 'sql_sort_order', - 'sql_start', - 'sql_where', - 'store_reverse', -); -extract($phpbb_dispatcher->trigger_event('core.viewforum_get_topic_ids_data', compact($vars))); - -$sql = $db->sql_build_query('SELECT', $sql_ary); -$result = $db->sql_query_limit($sql, $sql_limit, $sql_start); - -while ($row = $db->sql_fetchrow($result)) -{ - $topic_list[] = (int) $row['topic_id']; -} -$db->sql_freeresult($result); - -// For storing shadow topics -$shadow_topic_list = array(); - -if (count($topic_list)) -{ - // SQL array for obtaining topics/stickies - $sql_array = array( - 'SELECT' => $sql_array['SELECT'], - 'FROM' => $sql_array['FROM'], - 'LEFT_JOIN' => $sql_array['LEFT_JOIN'], - - 'WHERE' => $db->sql_in_set('t.topic_id', $topic_list), - ); - - // If store_reverse, then first obtain topics, then stickies, else the other way around... - // Funnily enough you typically save one query if going from the last page to the middle (store_reverse) because - // the number of stickies are not known - $sql = $db->sql_build_query('SELECT', $sql_array); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if ($row['topic_status'] == ITEM_MOVED) - { - $shadow_topic_list[$row['topic_moved_id']] = $row['topic_id']; - } - - $rowset[$row['topic_id']] = $row; - } - $db->sql_freeresult($result); -} - -// If we have some shadow topics, update the rowset to reflect their topic information -if (count($shadow_topic_list)) -{ - // SQL array for obtaining shadow topics - $sql_array = array( - 'SELECT' => 't.*', - 'FROM' => array( - TOPICS_TABLE => 't' - ), - 'WHERE' => $db->sql_in_set('t.topic_id', array_keys($shadow_topic_list)), - ); - - /** - * Event to modify the SQL query before the shadowtopic data is retrieved - * - * @event core.viewforum_get_shadowtopic_data - * @var array sql_array SQL array to get the data of any shadowtopics - * @since 3.1.0-a1 - */ - $vars = array('sql_array'); - extract($phpbb_dispatcher->trigger_event('core.viewforum_get_shadowtopic_data', compact($vars))); - - $sql = $db->sql_build_query('SELECT', $sql_array); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $orig_topic_id = $shadow_topic_list[$row['topic_id']]; - - // If the shadow topic is already listed within the rowset (happens for active topics for example), then do not include it... - if (isset($rowset[$row['topic_id']])) - { - // We need to remove any trace regarding this topic. :) - unset($rowset[$orig_topic_id]); - unset($topic_list[array_search($orig_topic_id, $topic_list)]); - $topics_count--; - - continue; - } - - // Do not include those topics the user has no permission to access - if (!$auth->acl_gets('f_read', 'f_list_topics', $row['forum_id'])) - { - // We need to remove any trace regarding this topic. :) - unset($rowset[$orig_topic_id]); - unset($topic_list[array_search($orig_topic_id, $topic_list)]); - $topics_count--; - - continue; - } - - // We want to retain some values - $row = array_merge($row, array( - 'topic_moved_id' => $rowset[$orig_topic_id]['topic_moved_id'], - 'topic_status' => $rowset[$orig_topic_id]['topic_status'], - 'topic_type' => $rowset[$orig_topic_id]['topic_type'], - 'topic_title' => $rowset[$orig_topic_id]['topic_title'], - )); - - // Shadow topics are never reported - $row['topic_reported'] = 0; - - $rowset[$orig_topic_id] = $row; - } - $db->sql_freeresult($result); -} -unset($shadow_topic_list); - -// Ok, adjust topics count for active topics list -if ($s_display_active) -{ - $topics_count = 1; -} - -// We need to remove the global announcements from the forums total topic count, -// otherwise the number is different from the one on the forum list -$total_topic_count = $topics_count - count($announcement_list); - -$base_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . ((strlen($u_sort_param)) ? "&$u_sort_param" : '')); -$pagination->generate_template_pagination($base_url, 'pagination', 'start', $total_topic_count, $config['topics_per_page'], $start); - -$template->assign_vars(array( - 'TOTAL_TOPICS' => ($s_display_active) ? false : $user->lang('VIEW_FORUM_TOPICS', (int) $total_topic_count), -)); - -$topic_list = ($store_reverse) ? array_merge($announcement_list, array_reverse($topic_list)) : array_merge($announcement_list, $topic_list); -$topic_tracking_info = $tracking_topics = array(); - -/** -* Modify topics data before we display the viewforum page -* -* @event core.viewforum_modify_topics_data -* @var array topic_list Array with current viewforum page topic ids -* @var array rowset Array with topics data (in topic_id => topic_data format) -* @var int total_topic_count Forum's total topic count -* @var int forum_id Forum identifier -* @since 3.1.0-b3 -* @changed 3.1.11-RC1 Added forum_id -*/ -$vars = array('topic_list', 'rowset', 'total_topic_count', 'forum_id'); -extract($phpbb_dispatcher->trigger_event('core.viewforum_modify_topics_data', compact($vars))); - -// Okay, lets dump out the page ... -if (count($topic_list)) -{ - $mark_forum_read = true; - $mark_time_forum = 0; - - // Generate topic forum list... - $topic_forum_list = array(); - foreach ($rowset as $t_id => $row) - { - if (isset($forum_tracking_info[$row['forum_id']])) - { - $row['forum_mark_time'] = $forum_tracking_info[$row['forum_id']]; - } - - $topic_forum_list[$row['forum_id']]['forum_mark_time'] = ($config['load_db_lastread'] && $user->data['is_registered'] && isset($row['forum_mark_time'])) ? $row['forum_mark_time'] : 0; - $topic_forum_list[$row['forum_id']]['topics'][] = (int) $t_id; - } - - if ($config['load_db_lastread'] && $user->data['is_registered']) - { - foreach ($topic_forum_list as $f_id => $topic_row) - { - $topic_tracking_info += get_topic_tracking($f_id, $topic_row['topics'], $rowset, array($f_id => $topic_row['forum_mark_time'])); - } - } - else if ($config['load_anon_lastread'] || $user->data['is_registered']) - { - foreach ($topic_forum_list as $f_id => $topic_row) - { - $topic_tracking_info += get_complete_topic_tracking($f_id, $topic_row['topics']); - } - } - - unset($topic_forum_list); - - if (!$s_display_active) - { - if ($config['load_db_lastread'] && $user->data['is_registered']) - { - $mark_time_forum = (!empty($forum_data['mark_time'])) ? $forum_data['mark_time'] : $user->data['user_lastmark']; - } - else if ($config['load_anon_lastread'] || $user->data['is_registered']) - { - if (!$user->data['is_registered']) - { - $user->data['user_lastmark'] = (isset($tracking_topics['l'])) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0; - } - $mark_time_forum = (isset($tracking_topics['f'][$forum_id])) ? (int) (base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate']) : $user->data['user_lastmark']; - } - } - - $s_type_switch = 0; - foreach ($topic_list as $topic_id) - { - $row = &$rowset[$topic_id]; - - $topic_forum_id = ($row['forum_id']) ? (int) $row['forum_id'] : $forum_id; - - // This will allow the style designer to output a different header - // or even separate the list of announcements from sticky and normal topics - $s_type_switch_test = ($row['topic_type'] == POST_ANNOUNCE || $row['topic_type'] == POST_GLOBAL) ? 1 : 0; - - // Replies - $replies = $phpbb_content_visibility->get_count('topic_posts', $row, $topic_forum_id) - 1; - // Correction for case of unapproved topic visible to poster - if ($replies < 0) - { - $replies = 0; - } - - if ($row['topic_status'] == ITEM_MOVED) - { - $topic_id = $row['topic_moved_id']; - $unread_topic = false; - } - else - { - $unread_topic = (isset($topic_tracking_info[$topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false; - } - - // Get folder img, topic status/type related information - $folder_img = $folder_alt = $topic_type = ''; - topic_status($row, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type); - - // Generate all the URIs ... - $view_topic_url_params = 'f=' . $row['forum_id'] . '&t=' . $topic_id; - $view_topic_url = $auth->acl_get('f_read', $forum_id) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params) : false; - - $topic_unapproved = (($row['topic_visibility'] == ITEM_UNAPPROVED || $row['topic_visibility'] == ITEM_REAPPROVE) && $auth->acl_get('m_approve', $row['forum_id'])); - $posts_unapproved = ($row['topic_visibility'] == ITEM_APPROVED && $row['topic_posts_unapproved'] && $auth->acl_get('m_approve', $row['forum_id'])); - $topic_deleted = $row['topic_visibility'] == ITEM_DELETED; - - $u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . "&t=$topic_id", true, $user->session_id) : ''; - $u_mcp_queue = (!$u_mcp_queue && $topic_deleted) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=deleted_topics&t=' . $topic_id, true, $user->session_id) : $u_mcp_queue; - - // Send vars to template - $topic_row = array( - 'FORUM_ID' => $row['forum_id'], - 'TOPIC_ID' => $topic_id, - 'TOPIC_AUTHOR' => get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), - 'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), - 'TOPIC_AUTHOR_FULL' => get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), - 'FIRST_POST_TIME' => $user->format_date($row['topic_time']), - 'FIRST_POST_TIME_RFC3339' => gmdate(DATE_RFC3339, $row['topic_time']), - 'LAST_POST_SUBJECT' => censor_text($row['topic_last_post_subject']), - 'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']), - 'LAST_POST_TIME_RFC3339' => gmdate(DATE_RFC3339, $row['topic_last_post_time']), - 'LAST_VIEW_TIME' => $user->format_date($row['topic_last_view_time']), - 'LAST_VIEW_TIME_RFC3339' => gmdate(DATE_RFC3339, $row['topic_last_view_time']), - 'LAST_POST_AUTHOR' => get_username_string('username', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), - 'LAST_POST_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), - 'LAST_POST_AUTHOR_FULL' => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), - - 'REPLIES' => $replies, - 'VIEWS' => $row['topic_views'], - 'TOPIC_TITLE' => censor_text($row['topic_title']), - 'TOPIC_TYPE' => $topic_type, - 'FORUM_NAME' => (isset($row['forum_name'])) ? $row['forum_name'] : $forum_data['forum_name'], - - 'TOPIC_IMG_STYLE' => $folder_img, - 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt), - 'TOPIC_FOLDER_IMG_ALT' => $user->lang[$folder_alt], - - 'TOPIC_ICON_IMG' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['img'] : '', - 'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['width'] : '', - 'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['height'] : '', - 'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['topic_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', - 'UNAPPROVED_IMG' => ($topic_unapproved || $posts_unapproved) ? $user->img('icon_topic_unapproved', ($topic_unapproved) ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '', - - 'S_TOPIC_TYPE' => $row['topic_type'], - 'S_USER_POSTED' => (isset($row['topic_posted']) && $row['topic_posted']) ? true : false, - 'S_UNREAD_TOPIC' => $unread_topic, - 'S_TOPIC_REPORTED' => (!empty($row['topic_reported']) && $auth->acl_get('m_report', $row['forum_id'])) ? true : false, - 'S_TOPIC_UNAPPROVED' => $topic_unapproved, - 'S_POSTS_UNAPPROVED' => $posts_unapproved, - 'S_TOPIC_DELETED' => $topic_deleted, - 'S_HAS_POLL' => ($row['poll_start']) ? true : false, - 'S_POST_ANNOUNCE' => ($row['topic_type'] == POST_ANNOUNCE) ? true : false, - 'S_POST_GLOBAL' => ($row['topic_type'] == POST_GLOBAL) ? true : false, - 'S_POST_STICKY' => ($row['topic_type'] == POST_STICKY) ? true : false, - 'S_TOPIC_LOCKED' => ($row['topic_status'] == ITEM_LOCKED) ? true : false, - 'S_TOPIC_MOVED' => ($row['topic_status'] == ITEM_MOVED) ? true : false, - - 'U_NEWEST_POST' => $auth->acl_get('f_read', $forum_id) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params . '&view=unread') . '#unread' : false, - 'U_LAST_POST' => $auth->acl_get('f_read', $forum_id) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params . '&p=' . $row['topic_last_post_id']) . '#p' . $row['topic_last_post_id'] : false, - 'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), - 'U_TOPIC_AUTHOR' => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), - 'U_VIEW_TOPIC' => $view_topic_url, - 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']), - 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=reports&f=' . $row['forum_id'] . '&t=' . $topic_id, true, $user->session_id), - 'U_MCP_QUEUE' => $u_mcp_queue, - - 'S_TOPIC_TYPE_SWITCH' => ($s_type_switch == $s_type_switch_test) ? -1 : $s_type_switch_test, - ); - - /** - * Modify the topic data before it is assigned to the template - * - * @event core.viewforum_modify_topicrow - * @var array row Array with topic data - * @var array topic_row Template array with topic data - * @var bool s_type_switch Flag indicating if the topic type is [global] announcement - * @var bool s_type_switch_test Flag indicating if the test topic type is [global] announcement - * @since 3.1.0-a1 - * - * @changed 3.1.10-RC1 Added s_type_switch, s_type_switch_test - */ - $vars = array('row', 'topic_row', 's_type_switch', 's_type_switch_test'); - extract($phpbb_dispatcher->trigger_event('core.viewforum_modify_topicrow', compact($vars))); - - $template->assign_block_vars('topicrow', $topic_row); - - $pagination->generate_template_pagination($view_topic_url, 'topicrow.pagination', 'start', $replies + 1, $config['posts_per_page'], 1, true, true); - - $s_type_switch = ($row['topic_type'] == POST_ANNOUNCE || $row['topic_type'] == POST_GLOBAL) ? 1 : 0; - - /** - * Event after the topic data has been assigned to the template - * - * @event core.viewforum_topic_row_after - * @var array row Array with the topic data - * @var array rowset Array with topics data (in topic_id => topic_data format) - * @var bool s_type_switch Flag indicating if the topic type is [global] announcement - * @var int topic_id The topic ID - * @var array topic_list Array with current viewforum page topic ids - * @var array topic_row Template array with topic data - * @since 3.1.3-RC1 - */ - $vars = array( - 'row', - 'rowset', - 's_type_switch', - 'topic_id', - 'topic_list', - 'topic_row', - ); - extract($phpbb_dispatcher->trigger_event('core.viewforum_topic_row_after', compact($vars))); - - if ($unread_topic) - { - $mark_forum_read = false; - } - - unset($rowset[$topic_id]); - } -} - -/** -* This event is to perform additional actions on viewforum page -* -* @event core.viewforum_generate_page_after -* @var array forum_data Array with the forum data -* @since 3.2.2-RC1 -*/ -$vars = array('forum_data'); -extract($phpbb_dispatcher->trigger_event('core.viewforum_generate_page_after', compact($vars))); - -// This is rather a fudge but it's the best I can think of without requiring information -// on all topics (as we do in 2.0.x). It looks for unread or new topics, if it doesn't find -// any it updates the forum last read cookie. This requires that the user visit the forum -// after reading a topic -if ($forum_data['forum_type'] == FORUM_POST && count($topic_list) && $mark_forum_read) -{ - update_forum_tracking_info($forum_id, $forum_data['forum_last_post_time'], false, $mark_time_forum); -} - -page_footer(); diff --git a/install/update/new/viewonline.php b/install/update/new/viewonline.php deleted file mode 100644 index 1b28750..0000000 --- a/install/update/new/viewonline.php +++ /dev/null @@ -1,522 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -define('IN_PHPBB', true); -$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); -include($phpbb_root_path . 'common.' . $phpEx); - -// Start session management -$user->session_begin(); -$auth->acl($user->data); -$user->setup('memberlist'); - -// Get and set some variables -$mode = $request->variable('mode', ''); -$session_id = $request->variable('s', ''); -$start = $request->variable('start', 0); -$sort_key = $request->variable('sk', 'b'); -$sort_dir = $request->variable('sd', 'd'); -$show_guests = ($config['load_online_guests']) ? $request->variable('sg', 0) : 0; - -// Can this user view profiles/memberlist? -if (!$auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel')) -{ - if ($user->data['user_id'] != ANONYMOUS) - { - send_status_line(403, 'Forbidden'); - trigger_error('NO_VIEW_USERS'); - } - - login_box('', $user->lang['LOGIN_EXPLAIN_VIEWONLINE']); -} - -/* @var $pagination \phpbb\pagination */ -$pagination = $phpbb_container->get('pagination'); - -/* @var $viewonline_helper \phpbb\viewonline_helper */ -$viewonline_helper = $phpbb_container->get('viewonline_helper'); - -$sort_key_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_JOINED'], 'c' => $user->lang['SORT_LOCATION']); -$sort_key_sql = array('a' => 'u.username_clean', 'b' => 's.session_time', 'c' => 's.session_page'); - -// Sorting and order -if (!isset($sort_key_text[$sort_key])) -{ - $sort_key = 'b'; -} - -$order_by = $sort_key_sql[$sort_key] . ' ' . (($sort_dir == 'a') ? 'ASC' : 'DESC'); - -// Whois requested -if ($mode == 'whois' && $auth->acl_get('a_') && $session_id) -{ - if (!function_exists('user_get_id_name')) - { - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - } - - $sql = 'SELECT u.user_id, u.username, u.user_type, s.session_ip - FROM ' . USERS_TABLE . ' u, ' . SESSIONS_TABLE . " s - WHERE s.session_id = '" . $db->sql_escape($session_id) . "' - AND u.user_id = s.session_user_id"; - $result = $db->sql_query($sql); - - if ($row = $db->sql_fetchrow($result)) - { - $template->assign_var('WHOIS', user_ipwhois($row['session_ip'])); - } - $db->sql_freeresult($result); - - // Output the page - page_header($user->lang['WHO_IS_ONLINE']); - - $template->set_filenames(array( - 'body' => 'viewonline_whois.html') - ); - make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx")); - - page_footer(); -} - -$user->update_session_infos(); - -// Forum info -$sql_ary = array( - 'SELECT' => 'f.forum_id, f.forum_name, f.parent_id, f.forum_type, f.left_id, f.right_id', - 'FROM' => array( - FORUMS_TABLE => 'f', - ), - 'ORDER_BY' => 'f.left_id ASC', -); - -/** -* Modify the forum data SQL query for getting additional fields if needed -* -* @event core.viewonline_modify_forum_data_sql -* @var array sql_ary The SQL array -* @since 3.1.5-RC1 -*/ -$vars = array('sql_ary'); -extract($phpbb_dispatcher->trigger_event('core.viewonline_modify_forum_data_sql', compact($vars))); - -$result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary), 600); -unset($sql_ary); - -$forum_data = array(); -while ($row = $db->sql_fetchrow($result)) -{ - $forum_data[$row['forum_id']] = $row; -} -$db->sql_freeresult($result); - -$guest_counter = 0; - -// Get number of online guests (if we do not display them) -if (!$show_guests) -{ - switch ($db->get_sql_layer()) - { - case 'sqlite3': - $sql = 'SELECT COUNT(session_ip) as num_guests - FROM ( - SELECT DISTINCT session_ip - FROM ' . SESSIONS_TABLE . ' - WHERE session_user_id = ' . ANONYMOUS . ' - AND session_time >= ' . (time() - ($config['load_online_time'] * 60)) . - ')'; - break; - - default: - $sql = 'SELECT COUNT(DISTINCT session_ip) as num_guests - FROM ' . SESSIONS_TABLE . ' - WHERE session_user_id = ' . ANONYMOUS . ' - AND session_time >= ' . (time() - ($config['load_online_time'] * 60)); - break; - } - $result = $db->sql_query($sql); - $guest_counter = (int) $db->sql_fetchfield('num_guests'); - $db->sql_freeresult($result); -} - -// Get user list -$sql_ary = array( - 'SELECT' => 'u.user_id, u.username, u.username_clean, u.user_type, u.user_colour, s.session_id, s.session_time, s.session_page, s.session_ip, s.session_browser, s.session_viewonline, s.session_forum_id', - 'FROM' => array( - USERS_TABLE => 'u', - SESSIONS_TABLE => 's', - ), - 'WHERE' => 'u.user_id = s.session_user_id - AND s.session_time >= ' . (time() - ($config['load_online_time'] * 60)) . - ((!$show_guests) ? ' AND s.session_user_id <> ' . ANONYMOUS : ''), - 'ORDER_BY' => $order_by, -); - -/** -* Modify the SQL query for getting the user data to display viewonline list -* -* @event core.viewonline_modify_sql -* @var array sql_ary The SQL array -* @var bool show_guests Do we display guests in the list -* @var int guest_counter Number of guests displayed -* @var array forum_data Array with forum data -* @since 3.1.0-a1 -* @changed 3.1.0-a2 Added vars guest_counter and forum_data -*/ -$vars = array('sql_ary', 'show_guests', 'guest_counter', 'forum_data'); -extract($phpbb_dispatcher->trigger_event('core.viewonline_modify_sql', compact($vars))); - -$result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary)); - -$prev_id = $prev_ip = $user_list = array(); -$logged_visible_online = $logged_hidden_online = $counter = 0; - -/** @var \phpbb\controller\helper $controller_helper */ -$controller_helper = $phpbb_container->get('controller.helper'); - -/** @var \phpbb\group\helper $group_helper */ -$group_helper = $phpbb_container->get('group_helper'); - -while ($row = $db->sql_fetchrow($result)) -{ - if ($row['user_id'] != ANONYMOUS && !isset($prev_id[$row['user_id']])) - { - $view_online = $s_user_hidden = false; - $user_colour = ($row['user_colour']) ? ' style="color:#' . $row['user_colour'] . '" class="username-coloured"' : ''; - - $username_full = ($row['user_type'] != USER_IGNORE) ? get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']) : '' . $row['username'] . ''; - - if (!$row['session_viewonline']) - { - $view_online = ($auth->acl_get('u_viewonline') || $row['user_id'] === $user->data['user_id']) ? true : false; - $logged_hidden_online++; - - $username_full = '' . $username_full . ''; - $s_user_hidden = true; - } - else - { - $view_online = true; - $logged_visible_online++; - } - - $prev_id[$row['user_id']] = 1; - - if ($view_online) - { - $counter++; - } - - if (!$view_online || $counter > $start + $config['topics_per_page'] || $counter <= $start) - { - continue; - } - } - else if ($show_guests && $row['user_id'] == ANONYMOUS && !isset($prev_ip[$row['session_ip']])) - { - $prev_ip[$row['session_ip']] = 1; - $guest_counter++; - $counter++; - - if ($counter > $start + $config['topics_per_page'] || $counter <= $start) - { - continue; - } - - $s_user_hidden = false; - $username_full = get_username_string('full', $row['user_id'], $user->lang['GUEST']); - } - else - { - continue; - } - - $on_page = $viewonline_helper->get_user_page($row['session_page']); - - switch ($on_page[1]) - { - case 'index': - $location = $user->lang['INDEX']; - $location_url = append_sid("{$phpbb_root_path}index.$phpEx"); - break; - - case $phpbb_adm_relative_path . 'index': - $location = $user->lang['ACP']; - $location_url = append_sid("{$phpbb_root_path}index.$phpEx"); - break; - - case 'posting': - case 'viewforum': - case 'viewtopic': - $forum_id = $row['session_forum_id']; - - if ($forum_id && $auth->acl_get('f_list', $forum_id)) - { - $location = ''; - $location_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id); - - if ($forum_data[$forum_id]['forum_type'] == FORUM_LINK) - { - $location = sprintf($user->lang['READING_LINK'], $forum_data[$forum_id]['forum_name']); - break; - } - - switch ($on_page[1]) - { - case 'posting': - preg_match('#mode=([a-z]+)#', $row['session_page'], $on_page); - $posting_mode = (!empty($on_page[1])) ? $on_page[1] : ''; - - switch ($posting_mode) - { - case 'reply': - case 'quote': - $location = sprintf($user->lang['REPLYING_MESSAGE'], $forum_data[$forum_id]['forum_name']); - break; - - default: - $location = sprintf($user->lang['POSTING_MESSAGE'], $forum_data[$forum_id]['forum_name']); - break; - } - break; - - case 'viewtopic': - $location = sprintf($user->lang['READING_TOPIC'], $forum_data[$forum_id]['forum_name']); - break; - - case 'viewforum': - $location = sprintf($user->lang['READING_FORUM'], $forum_data[$forum_id]['forum_name']); - break; - } - } - else - { - $location = $user->lang['INDEX']; - $location_url = append_sid("{$phpbb_root_path}index.$phpEx"); - } - break; - - case 'search': - $location = $user->lang['SEARCHING_FORUMS']; - $location_url = append_sid("{$phpbb_root_path}search.$phpEx"); - break; - - case 'viewonline': - $location = $user->lang['VIEWING_ONLINE']; - $location_url = append_sid("{$phpbb_root_path}viewonline.$phpEx"); - break; - - case 'memberlist': - $location_url = append_sid("{$phpbb_root_path}memberlist.$phpEx"); - - if (strpos($row['session_page'], 'mode=viewprofile') !== false) - { - $location = $user->lang['VIEWING_MEMBER_PROFILE']; - } - else if (strpos($row['session_page'], 'mode=contactadmin') !== false) - { - $location = $user->lang['VIEWING_CONTACT_ADMIN']; - $location_url = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contactadmin'); - } - else - { - $location = $user->lang['VIEWING_MEMBERS']; - } - break; - - case 'mcp': - $location = $user->lang['VIEWING_MCP']; - $location_url = append_sid("{$phpbb_root_path}index.$phpEx"); - break; - - case 'ucp': - $location = $user->lang['VIEWING_UCP']; - - // Grab some common modules - $url_params = array( - 'mode=register' => 'VIEWING_REGISTER', - 'i=pm&mode=compose' => 'POSTING_PRIVATE_MESSAGE', - 'i=pm&' => 'VIEWING_PRIVATE_MESSAGES', - 'i=profile&' => 'CHANGING_PROFILE', - 'i=prefs&' => 'CHANGING_PREFERENCES', - ); - - foreach ($url_params as $param => $lang) - { - if (strpos($row['session_page'], $param) !== false) - { - $location = $user->lang[$lang]; - break; - } - } - - $location_url = append_sid("{$phpbb_root_path}index.$phpEx"); - break; - - case 'download/file': - $location = $user->lang['DOWNLOADING_FILE']; - $location_url = append_sid("{$phpbb_root_path}index.$phpEx"); - break; - - case 'report': - $location = $user->lang['REPORTING_POST']; - $location_url = append_sid("{$phpbb_root_path}index.$phpEx"); - break; - - default: - $location = $user->lang['INDEX']; - $location_url = append_sid("{$phpbb_root_path}index.$phpEx"); - - if ($row['session_page'] === 'app.' . $phpEx . '/help/faq' || - $row['session_page'] === 'app.' . $phpEx . '/help/bbcode') - { - $location = $user->lang['VIEWING_FAQ']; - $location_url = $controller_helper->route('phpbb_help_faq_controller'); - } - break; - } - - /** - * Overwrite the location's name and URL, which are displayed in the list - * - * @event core.viewonline_overwrite_location - * @var array on_page File name and query string - * @var array row Array with the users sql row - * @var string location Page name to displayed in the list - * @var string location_url Page url to displayed in the list - * @var array forum_data Array with forum data - * @since 3.1.0-a1 - * @changed 3.1.0-a2 Added var forum_data - */ - $vars = array('on_page', 'row', 'location', 'location_url', 'forum_data'); - extract($phpbb_dispatcher->trigger_event('core.viewonline_overwrite_location', compact($vars))); - - $template_row = array( - 'USERNAME' => $row['username'], - 'USERNAME_COLOUR' => $row['user_colour'], - 'USERNAME_FULL' => $username_full, - 'LASTUPDATE' => $user->format_date($row['session_time']), - 'FORUM_LOCATION' => $location, - 'USER_IP' => ($auth->acl_get('a_')) ? (($mode == 'lookup' && $session_id == $row['session_id']) ? gethostbyaddr($row['session_ip']) : $row['session_ip']) : '', - 'USER_BROWSER' => ($auth->acl_get('a_user')) ? $row['session_browser'] : '', - - 'U_USER_PROFILE' => ($row['user_type'] != USER_IGNORE) ? get_username_string('profile', $row['user_id'], '') : '', - 'U_USER_IP' => append_sid("{$phpbb_root_path}viewonline.$phpEx", 'mode=lookup' . (($mode != 'lookup' || $row['session_id'] != $session_id) ? '&s=' . $row['session_id'] : '') . "&sg=$show_guests&start=$start&sk=$sort_key&sd=$sort_dir"), - 'U_WHOIS' => append_sid("{$phpbb_root_path}viewonline.$phpEx", 'mode=whois&s=' . $row['session_id']), - 'U_FORUM_LOCATION' => $location_url, - - 'S_USER_HIDDEN' => $s_user_hidden, - 'S_GUEST' => ($row['user_id'] == ANONYMOUS) ? true : false, - 'S_USER_TYPE' => $row['user_type'], - ); - - /** - * Modify viewonline template data before it is displayed in the list - * - * @event core.viewonline_modify_user_row - * @var array on_page File name and query string - * @var array row Array with the users sql row - * @var array forum_data Array with forum data - * @var array template_row Array with template variables for the user row - * @since 3.1.0-RC4 - */ - $vars = array('on_page', 'row', 'forum_data', 'template_row'); - extract($phpbb_dispatcher->trigger_event('core.viewonline_modify_user_row', compact($vars))); - - $template->assign_block_vars('user_row', $template_row); -} -$db->sql_freeresult($result); -unset($prev_id, $prev_ip); - -$order_legend = ($config['legend_sort_groupname']) ? 'group_name' : 'group_legend'; -// Grab group details for legend display -if ($auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) -{ - $sql = 'SELECT group_id, group_name, group_colour, group_type, group_legend - FROM ' . GROUPS_TABLE . ' - WHERE group_legend > 0 - ORDER BY ' . $order_legend . ' ASC'; -} -else -{ - $sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type, g.group_legend - FROM ' . GROUPS_TABLE . ' g - LEFT JOIN ' . USER_GROUP_TABLE . ' ug - ON ( - g.group_id = ug.group_id - AND ug.user_id = ' . $user->data['user_id'] . ' - AND ug.user_pending = 0 - ) - WHERE g.group_legend > 0 - AND (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $user->data['user_id'] . ') - ORDER BY g.' . $order_legend . ' ASC'; -} -$result = $db->sql_query($sql); - -$legend = ''; -while ($row = $db->sql_fetchrow($result)) -{ - if ($row['group_name'] == 'BOTS') - { - $legend .= (($legend != '') ? ', ' : '') . '' . $user->lang['G_BOTS'] . ''; - } - else - { - $legend .= (($legend != '') ? ', ' : '') . '' . $group_helper->get_name($row['group_name']) . ''; - } -} -$db->sql_freeresult($result); - -// Refreshing the page every 60 seconds... -meta_refresh(60, append_sid("{$phpbb_root_path}viewonline.$phpEx", "sg=$show_guests&sk=$sort_key&sd=$sort_dir&start=$start")); - -$start = $pagination->validate_start($start, $config['topics_per_page'], $counter); -$base_url = append_sid("{$phpbb_root_path}viewonline.$phpEx", "sg=$show_guests&sk=$sort_key&sd=$sort_dir"); -$pagination->generate_template_pagination($base_url, 'pagination', 'start', $counter, $config['topics_per_page'], $start); - -$template->assign_block_vars('navlinks', array( - 'BREADCRUMB_NAME' => $user->lang('WHO_IS_ONLINE'), - 'U_BREADCRUMB' => append_sid("{$phpbb_root_path}viewonline.$phpEx"), -)); - -// Send data to template -$template->assign_vars(array( - 'TOTAL_REGISTERED_USERS_ONLINE' => $user->lang('REG_USERS_ONLINE', (int) $logged_visible_online, $user->lang('HIDDEN_USERS_ONLINE', (int) $logged_hidden_online)), - 'TOTAL_GUEST_USERS_ONLINE' => $user->lang('GUEST_USERS_ONLINE', (int) $guest_counter), - 'LEGEND' => $legend, - - 'U_SORT_USERNAME' => append_sid("{$phpbb_root_path}viewonline.$phpEx", 'sk=a&sd=' . (($sort_key == 'a' && $sort_dir == 'a') ? 'd' : 'a') . '&sg=' . ((int) $show_guests)), - 'U_SORT_UPDATED' => append_sid("{$phpbb_root_path}viewonline.$phpEx", 'sk=b&sd=' . (($sort_key == 'b' && $sort_dir == 'a') ? 'd' : 'a') . '&sg=' . ((int) $show_guests)), - 'U_SORT_LOCATION' => append_sid("{$phpbb_root_path}viewonline.$phpEx", 'sk=c&sd=' . (($sort_key == 'c' && $sort_dir == 'a') ? 'd' : 'a') . '&sg=' . ((int) $show_guests)), - - 'U_SWITCH_GUEST_DISPLAY' => append_sid("{$phpbb_root_path}viewonline.$phpEx", 'sg=' . ((int) !$show_guests)), - 'L_SWITCH_GUEST_DISPLAY' => ($show_guests) ? $user->lang['HIDE_GUESTS'] : $user->lang['DISPLAY_GUESTS'], - 'S_SWITCH_GUEST_DISPLAY' => ($config['load_online_guests']) ? true : false, - 'S_VIEWONLINE' => true, -)); - -// We do not need to load the who is online box here. ;) -$config['load_online'] = false; - -// Output the page -page_header($user->lang['WHO_IS_ONLINE']); - -$template->set_filenames(array( - 'body' => 'viewonline_body.html') -); -make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx")); - -page_footer(); diff --git a/install/update/new/viewtopic.php b/install/update/new/viewtopic.php deleted file mode 100644 index df241a5..0000000 --- a/install/update/new/viewtopic.php +++ /dev/null @@ -1,2427 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -define('IN_PHPBB', true); -$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); -include($phpbb_root_path . 'common.' . $phpEx); -include($phpbb_root_path . 'includes/functions_display.' . $phpEx); -include($phpbb_root_path . 'includes/bbcode.' . $phpEx); -include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - -// Start session management -$user->session_begin(); -$auth->acl($user->data); - -// Initial var setup -$forum_id = $request->variable('f', 0); -$topic_id = $request->variable('t', 0); -$post_id = $request->variable('p', 0); -$voted_id = $request->variable('vote_id', array('' => 0)); - -$voted_id = (count($voted_id) > 1) ? array_unique($voted_id) : $voted_id; - - -$start = $request->variable('start', 0); -$view = $request->variable('view', ''); - -$default_sort_days = (!empty($user->data['user_post_show_days'])) ? $user->data['user_post_show_days'] : 0; -$default_sort_key = (!empty($user->data['user_post_sortby_type'])) ? $user->data['user_post_sortby_type'] : 't'; -$default_sort_dir = (!empty($user->data['user_post_sortby_dir'])) ? $user->data['user_post_sortby_dir'] : 'a'; - -$sort_days = $request->variable('st', $default_sort_days); -$sort_key = $request->variable('sk', $default_sort_key); -$sort_dir = $request->variable('sd', $default_sort_dir); - -$update = $request->variable('update', false); - -/* @var $pagination \phpbb\pagination */ -$pagination = $phpbb_container->get('pagination'); - -$s_can_vote = false; -/** -* @todo normalize? -*/ -$hilit_words = $request->variable('hilit', '', true); - -// Do we have a topic or post id? -if (!$topic_id && !$post_id) -{ - trigger_error('NO_TOPIC'); -} - -/* @var $phpbb_content_visibility \phpbb\content_visibility */ -$phpbb_content_visibility = $phpbb_container->get('content.visibility'); - -// Find topic id if user requested a newer or older topic -if ($view && !$post_id) -{ - if (!$forum_id) - { - $sql = 'SELECT forum_id - FROM ' . TOPICS_TABLE . " - WHERE topic_id = $topic_id"; - $result = $db->sql_query($sql); - $forum_id = (int) $db->sql_fetchfield('forum_id'); - $db->sql_freeresult($result); - - if (!$forum_id) - { - trigger_error('NO_TOPIC'); - } - } - - if ($view == 'unread') - { - // Get topic tracking info - $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id); - $topic_last_read = (isset($topic_tracking_info[$topic_id])) ? $topic_tracking_info[$topic_id] : 0; - - $sql = 'SELECT post_id, topic_id, forum_id - FROM ' . POSTS_TABLE . " - WHERE topic_id = $topic_id - AND " . $phpbb_content_visibility->get_visibility_sql('post', $forum_id) . " - AND post_time > $topic_last_read - AND forum_id = $forum_id - ORDER BY post_time ASC, post_id ASC"; - $result = $db->sql_query_limit($sql, 1); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - $sql = 'SELECT topic_last_post_id as post_id, topic_id, forum_id - FROM ' . TOPICS_TABLE . ' - WHERE topic_id = ' . $topic_id; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - } - - if (!$row) - { - // Setup user environment so we can process lang string - $user->setup('viewtopic'); - - trigger_error('NO_TOPIC'); - } - - $post_id = $row['post_id']; - $topic_id = $row['topic_id']; - } - else if ($view == 'next' || $view == 'previous') - { - $sql_condition = ($view == 'next') ? '>' : '<'; - $sql_ordering = ($view == 'next') ? 'ASC' : 'DESC'; - - $sql = 'SELECT forum_id, topic_last_post_time - FROM ' . TOPICS_TABLE . ' - WHERE topic_id = ' . $topic_id; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - $user->setup('viewtopic'); - // OK, the topic doesn't exist. This error message is not helpful, but technically correct. - trigger_error(($view == 'next') ? 'NO_NEWER_TOPICS' : 'NO_OLDER_TOPICS'); - } - else - { - $sql = 'SELECT topic_id, forum_id - FROM ' . TOPICS_TABLE . ' - WHERE forum_id = ' . $row['forum_id'] . " - AND topic_moved_id = 0 - AND topic_last_post_time $sql_condition {$row['topic_last_post_time']} - AND " . $phpbb_content_visibility->get_visibility_sql('topic', $row['forum_id']) . " - ORDER BY topic_last_post_time $sql_ordering, topic_last_post_id $sql_ordering"; - $result = $db->sql_query_limit($sql, 1); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - $sql = 'SELECT forum_style - FROM ' . FORUMS_TABLE . " - WHERE forum_id = $forum_id"; - $result = $db->sql_query($sql); - $forum_style = (int) $db->sql_fetchfield('forum_style'); - $db->sql_freeresult($result); - - $user->setup('viewtopic', $forum_style); - trigger_error(($view == 'next') ? 'NO_NEWER_TOPICS' : 'NO_OLDER_TOPICS'); - } - else - { - $topic_id = $row['topic_id']; - $forum_id = $row['forum_id']; - } - } - } - - if (isset($row) && $row['forum_id']) - { - $forum_id = $row['forum_id']; - } -} - -// This rather complex gaggle of code handles querying for topics but -// also allows for direct linking to a post (and the calculation of which -// page the post is on and the correct display of viewtopic) -$sql_array = array( - 'SELECT' => 't.*, f.*', - - 'FROM' => array(FORUMS_TABLE => 'f'), -); - -// The FROM-Order is quite important here, else t.* columns can not be correctly bound. -if ($post_id) -{ - $sql_array['SELECT'] .= ', p.post_visibility, p.post_time, p.post_id'; - $sql_array['FROM'][POSTS_TABLE] = 'p'; -} - -// Topics table need to be the last in the chain -$sql_array['FROM'][TOPICS_TABLE] = 't'; - -if ($user->data['is_registered']) -{ - $sql_array['SELECT'] .= ', tw.notify_status'; - $sql_array['LEFT_JOIN'] = array(); - - $sql_array['LEFT_JOIN'][] = array( - 'FROM' => array(TOPICS_WATCH_TABLE => 'tw'), - 'ON' => 'tw.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = tw.topic_id' - ); - - if ($config['allow_bookmarks']) - { - $sql_array['SELECT'] .= ', bm.topic_id as bookmarked'; - $sql_array['LEFT_JOIN'][] = array( - 'FROM' => array(BOOKMARKS_TABLE => 'bm'), - 'ON' => 'bm.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = bm.topic_id' - ); - } - - if ($config['load_db_lastread']) - { - $sql_array['SELECT'] .= ', tt.mark_time, ft.mark_time as forum_mark_time'; - - $sql_array['LEFT_JOIN'][] = array( - 'FROM' => array(TOPICS_TRACK_TABLE => 'tt'), - 'ON' => 'tt.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = tt.topic_id' - ); - - $sql_array['LEFT_JOIN'][] = array( - 'FROM' => array(FORUMS_TRACK_TABLE => 'ft'), - 'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND t.forum_id = ft.forum_id' - ); - } -} - -if (!$post_id) -{ - $sql_array['WHERE'] = "t.topic_id = $topic_id"; -} -else -{ - $sql_array['WHERE'] = "p.post_id = $post_id AND t.topic_id = p.topic_id"; -} - -$sql_array['WHERE'] .= ' AND f.forum_id = t.forum_id'; - -$sql = $db->sql_build_query('SELECT', $sql_array); -$result = $db->sql_query($sql); -$topic_data = $db->sql_fetchrow($result); -$db->sql_freeresult($result); - -// link to unapproved post or incorrect link -if (!$topic_data) -{ - // If post_id was submitted, we try at least to display the topic as a last resort... - if ($post_id && $topic_id) - { - redirect(append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t=$topic_id" . (($forum_id) ? "&f=$forum_id" : ''))); - } - - trigger_error('NO_TOPIC'); -} - -$forum_id = (int) $topic_data['forum_id']; - -/** - * Modify the forum ID to handle the correct display of viewtopic if needed - * - * @event core.viewtopic_modify_forum_id - * @var string forum_id forum ID - * @var array topic_data array of topic's data - * @since 3.2.5-RC1 - */ -$vars = array( - 'forum_id', - 'topic_data', -); -extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_forum_id', compact($vars))); - -// If the request is missing the f parameter, the forum id in the user session data is 0 at the moment. -// Let's fix that now so that the user can't hide from the forum's Who Is Online list. -$user->page['forum'] = $forum_id; - -// Now we know the forum_id and can check the permissions -if (!$phpbb_content_visibility->is_visible('topic', $forum_id, $topic_data)) -{ - trigger_error('NO_TOPIC'); -} - -// This is for determining where we are (page) -if ($post_id) -{ - // are we where we are supposed to be? - if (($topic_data['post_visibility'] == ITEM_UNAPPROVED || $topic_data['post_visibility'] == ITEM_REAPPROVE) && !$auth->acl_get('m_approve', $topic_data['forum_id'])) - { - // If post_id was submitted, we try at least to display the topic as a last resort... - if ($topic_id) - { - redirect(append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t=$topic_id" . (($forum_id) ? "&f=$forum_id" : ''))); - } - - trigger_error('NO_TOPIC'); - } - if ($post_id == $topic_data['topic_first_post_id'] || $post_id == $topic_data['topic_last_post_id']) - { - $check_sort = ($post_id == $topic_data['topic_first_post_id']) ? 'd' : 'a'; - - if ($sort_dir == $check_sort) - { - $topic_data['prev_posts'] = $phpbb_content_visibility->get_count('topic_posts', $topic_data, $forum_id) - 1; - } - else - { - $topic_data['prev_posts'] = 0; - } - } - else - { - $sql = 'SELECT COUNT(p.post_id) AS prev_posts - FROM ' . POSTS_TABLE . " p - WHERE p.topic_id = {$topic_data['topic_id']} - AND " . $phpbb_content_visibility->get_visibility_sql('post', $forum_id, 'p.'); - - if ($sort_dir == 'd') - { - $sql .= " AND (p.post_time > {$topic_data['post_time']} OR (p.post_time = {$topic_data['post_time']} AND p.post_id >= {$topic_data['post_id']}))"; - } - else - { - $sql .= " AND (p.post_time < {$topic_data['post_time']} OR (p.post_time = {$topic_data['post_time']} AND p.post_id <= {$topic_data['post_id']}))"; - } - - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $topic_data['prev_posts'] = $row['prev_posts'] - 1; - } -} - -$topic_id = (int) $topic_data['topic_id']; -$topic_replies = $phpbb_content_visibility->get_count('topic_posts', $topic_data, $forum_id) - 1; - -// Check sticky/announcement/global time limit -if (($topic_data['topic_type'] != POST_NORMAL) && $topic_data['topic_time_limit'] && ($topic_data['topic_time'] + $topic_data['topic_time_limit']) < time()) -{ - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_type = ' . POST_NORMAL . ', topic_time_limit = 0 - WHERE topic_id = ' . $topic_id; - $db->sql_query($sql); - - $topic_data['topic_type'] = POST_NORMAL; - $topic_data['topic_time_limit'] = 0; -} - -// Setup look and feel -$user->setup('viewtopic', $topic_data['forum_style']); - -if ($view == 'print' && !$auth->acl_get('f_print', $forum_id)) -{ - send_status_line(403, 'Forbidden'); - trigger_error('NO_AUTH_PRINT_TOPIC'); -} - -$overrides_f_read_check = false; -$overrides_forum_password_check = false; -$topic_tracking_info = isset($topic_tracking_info) ? $topic_tracking_info : null; - -/** -* Event to apply extra permissions and to override original phpBB's f_read permission and forum password check -* on viewtopic access -* -* @event core.viewtopic_before_f_read_check -* @var int forum_id The forum id from where the topic belongs -* @var int topic_id The id of the topic the user tries to access -* @var int post_id The id of the post the user tries to start viewing at. -* It may be 0 for none given. -* @var array topic_data All the information from the topic and forum tables for this topic -* It includes posts information if post_id is not 0 -* @var bool overrides_f_read_check Set true to remove f_read check afterwards -* @var bool overrides_forum_password_check Set true to remove forum_password check afterwards -* @var array topic_tracking_info Information upon calling get_topic_tracking() -* Set it to NULL to allow auto-filling later. -* Set it to an array to override original data. -* @since 3.1.3-RC1 -*/ -$vars = array( - 'forum_id', - 'topic_id', - 'post_id', - 'topic_data', - 'overrides_f_read_check', - 'overrides_forum_password_check', - 'topic_tracking_info', -); -extract($phpbb_dispatcher->trigger_event('core.viewtopic_before_f_read_check', compact($vars))); - -// Start auth check -if (!$overrides_f_read_check && !$auth->acl_get('f_read', $forum_id)) -{ - if ($user->data['user_id'] != ANONYMOUS) - { - send_status_line(403, 'Forbidden'); - trigger_error('SORRY_AUTH_READ'); - } - - login_box('', $user->lang['LOGIN_VIEWFORUM']); -} - -// Forum is passworded ... check whether access has been granted to this -// user this session, if not show login box -if (!$overrides_forum_password_check && $topic_data['forum_password']) -{ - login_forum_box($topic_data); -} - -// Redirect to login upon emailed notification links if user is not logged in. -if (isset($_GET['e']) && $user->data['user_id'] == ANONYMOUS) -{ - login_box(build_url('e') . '#unread', $user->lang['LOGIN_NOTIFY_TOPIC']); -} - -// What is start equal to? -if ($post_id) -{ - $start = floor(($topic_data['prev_posts']) / $config['posts_per_page']) * $config['posts_per_page']; -} - -// Get topic tracking info -if (!isset($topic_tracking_info)) -{ - $topic_tracking_info = array(); - - // Get topic tracking info - if ($config['load_db_lastread'] && $user->data['is_registered']) - { - $tmp_topic_data = array($topic_id => $topic_data); - $topic_tracking_info = get_topic_tracking($forum_id, $topic_id, $tmp_topic_data, array($forum_id => $topic_data['forum_mark_time'])); - unset($tmp_topic_data); - } - else if ($config['load_anon_lastread'] || $user->data['is_registered']) - { - $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id); - } -} - -// Post ordering options -$limit_days = array(0 => $user->lang['ALL_POSTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); - -$sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']); -$sort_by_sql = array('a' => array('u.username_clean', 'p.post_id'), 't' => array('p.post_time', 'p.post_id'), 's' => array('p.post_subject', 'p.post_id')); -$join_user_sql = array('a' => true, 't' => false, 's' => false); - -$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; - -/** -* Event to add new sorting options -* -* @event core.viewtopic_gen_sort_selects_before -* @var array limit_days Limit results by time -* @var array sort_by_text Language strings for sorting options -* @var array sort_by_sql SQL conditions for sorting options -* @var array join_user_sql SQL joins required for sorting options -* @var int sort_days User selected sort days -* @var string sort_key User selected sort key -* @var string sort_dir User selected sort direction -* @var string s_limit_days Initial value of limit days selectbox -* @var string s_sort_key Initial value of sort key selectbox -* @var string s_sort_dir Initial value of sort direction selectbox -* @var string u_sort_param Initial value of sorting form action -* @since 3.2.8-RC1 -*/ -$vars = array( - 'limit_days', - 'sort_by_text', - 'sort_by_sql', - 'join_user_sql', - 'sort_days', - 'sort_key', - 'sort_dir', - 's_limit_days', - 's_sort_key', - 's_sort_dir', - 'u_sort_param', -); -extract($phpbb_dispatcher->trigger_event('core.viewtopic_gen_sort_selects_before', compact($vars))); - -gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param, $default_sort_days, $default_sort_key, $default_sort_dir); - -// Obtain correct post count and ordering SQL if user has -// requested anything different -if ($sort_days) -{ - $min_post_time = time() - ($sort_days * 86400); - - $sql = 'SELECT COUNT(post_id) AS num_posts - FROM ' . POSTS_TABLE . " - WHERE topic_id = $topic_id - AND post_time >= $min_post_time - AND " . $phpbb_content_visibility->get_visibility_sql('post', $forum_id); - $result = $db->sql_query($sql); - $total_posts = (int) $db->sql_fetchfield('num_posts'); - $db->sql_freeresult($result); - - $limit_posts_time = "AND p.post_time >= $min_post_time "; - - if (isset($_POST['sort'])) - { - $start = 0; - } -} -else -{ - $total_posts = $topic_replies + 1; - $limit_posts_time = ''; -} - -// Was a highlight request part of the URI? -$highlight_match = $highlight = ''; -if ($hilit_words) -{ - $highlight_match = phpbb_clean_search_string($hilit_words); - $highlight = urlencode($highlight_match); - $highlight_match = str_replace('\*', '\w+?', preg_quote($highlight_match, '#')); - $highlight_match = preg_replace('#(?<=^|\s)\\\\w\*\?(?=\s|$)#', '\w+?', $highlight_match); - $highlight_match = str_replace(' ', '|', $highlight_match); -} - -// Make sure $start is set to the last page if it exceeds the amount -$start = $pagination->validate_start($start, $config['posts_per_page'], $total_posts); - -// General Viewtopic URL for return links -$viewtopic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start") . ((strlen($u_sort_param)) ? "&$u_sort_param" : '') . (($highlight_match) ? "&hilit=$highlight" : '')); - -// Are we watching this topic? -$s_watching_topic = array( - 'link' => '', - 'link_toggle' => '', - 'title' => '', - 'title_toggle' => '', - 'is_watching' => false, -); - -if ($config['allow_topic_notify']) -{ - $notify_status = (isset($topic_data['notify_status'])) ? $topic_data['notify_status'] : null; - watch_topic_forum('topic', $s_watching_topic, $user->data['user_id'], $forum_id, $topic_id, $notify_status, $start, $topic_data['topic_title']); - - // Reset forum notification if forum notify is set - if ($config['allow_forum_notify'] && $auth->acl_get('f_subscribe', $forum_id)) - { - $s_watching_forum = $s_watching_topic; - watch_topic_forum('forum', $s_watching_forum, $user->data['user_id'], $forum_id, 0); - } -} - -/** -* Event to modify highlight. -* -* @event core.viewtopic_highlight_modify -* @var string highlight String to be highlighted -* @var string highlight_match Highlight string to be used in preg_replace -* @var array topic_data Topic data -* @var int start Pagination start -* @var int total_posts Number of posts -* @var string viewtopic_url Current viewtopic URL -* @since 3.1.11-RC1 -*/ -$vars = array( - 'highlight', - 'highlight_match', - 'topic_data', - 'start', - 'total_posts', - 'viewtopic_url', -); -extract($phpbb_dispatcher->trigger_event('core.viewtopic_highlight_modify', compact($vars))); - -// Bookmarks -if ($config['allow_bookmarks'] && $user->data['is_registered'] && $request->variable('bookmark', 0)) -{ - if (check_link_hash($request->variable('hash', ''), "topic_$topic_id")) - { - if (!$topic_data['bookmarked']) - { - $sql = 'INSERT INTO ' . BOOKMARKS_TABLE . ' ' . $db->sql_build_array('INSERT', array( - 'user_id' => $user->data['user_id'], - 'topic_id' => $topic_id, - )); - $db->sql_query($sql); - } - else - { - $sql = 'DELETE FROM ' . BOOKMARKS_TABLE . " - WHERE user_id = {$user->data['user_id']} - AND topic_id = $topic_id"; - $db->sql_query($sql); - } - $message = (($topic_data['bookmarked']) ? $user->lang['BOOKMARK_REMOVED'] : $user->lang['BOOKMARK_ADDED']); - - if (!$request->is_ajax()) - { - $message .= '

' . $user->lang('RETURN_TOPIC', '', ''); - } - } - else - { - $message = $user->lang['BOOKMARK_ERR']; - - if (!$request->is_ajax()) - { - $message .= '

' . $user->lang('RETURN_TOPIC', '', ''); - } - } - meta_refresh(3, $viewtopic_url); - - trigger_error($message); -} - -// Grab ranks -$ranks = $cache->obtain_ranks(); - -// Grab icons -$icons = $cache->obtain_icons(); - -// Grab extensions -$extensions = array(); -if ($topic_data['topic_attachment']) -{ - $extensions = $cache->obtain_attach_extensions($forum_id); -} - -// Forum rules listing -$s_forum_rules = ''; -gen_forum_auth_level('topic', $forum_id, $topic_data['forum_status']); - -// Quick mod tools -$allow_change_type = ($auth->acl_get('m_', $forum_id) || ($user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'])) ? true : false; - -$s_quickmod_action = append_sid( - "{$phpbb_root_path}mcp.$phpEx", - array( - 'f' => $forum_id, - 't' => $topic_id, - 'start' => $start, - 'quickmod' => 1, - 'redirect' => urlencode(str_replace('&', '&', $viewtopic_url)), - ), - true, - $user->session_id -); - -$quickmod_array = array( -// 'key' => array('LANG_KEY', $userHasPermissions), - - 'lock' => array('LOCK_TOPIC', ($topic_data['topic_status'] == ITEM_UNLOCKED) && ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster']))), - 'unlock' => array('UNLOCK_TOPIC', ($topic_data['topic_status'] != ITEM_UNLOCKED) && ($auth->acl_get('m_lock', $forum_id))), - 'delete_topic' => array('DELETE_TOPIC', ($auth->acl_get('m_delete', $forum_id) || (($topic_data['topic_visibility'] != ITEM_DELETED) && $auth->acl_get('m_softdelete', $forum_id)))), - 'restore_topic' => array('RESTORE_TOPIC', (($topic_data['topic_visibility'] == ITEM_DELETED) && $auth->acl_get('m_approve', $forum_id))), - 'move' => array('MOVE_TOPIC', $auth->acl_get('m_move', $forum_id) && $topic_data['topic_status'] != ITEM_MOVED), - 'split' => array('SPLIT_TOPIC', $auth->acl_get('m_split', $forum_id)), - 'merge' => array('MERGE_POSTS', $auth->acl_get('m_merge', $forum_id)), - 'merge_topic' => array('MERGE_TOPIC', $auth->acl_get('m_merge', $forum_id)), - 'fork' => array('FORK_TOPIC', $auth->acl_get('m_move', $forum_id)), - 'make_normal' => array('MAKE_NORMAL', ($allow_change_type && $auth->acl_gets('f_sticky', 'f_announce', 'f_announce_global', $forum_id) && $topic_data['topic_type'] != POST_NORMAL)), - 'make_sticky' => array('MAKE_STICKY', ($allow_change_type && $auth->acl_get('f_sticky', $forum_id) && $topic_data['topic_type'] != POST_STICKY)), - 'make_announce' => array('MAKE_ANNOUNCE', ($allow_change_type && $auth->acl_get('f_announce', $forum_id) && $topic_data['topic_type'] != POST_ANNOUNCE)), - 'make_global' => array('MAKE_GLOBAL', ($allow_change_type && $auth->acl_get('f_announce_global', $forum_id) && $topic_data['topic_type'] != POST_GLOBAL)), - 'topic_logs' => array('VIEW_TOPIC_LOGS', $auth->acl_get('m_', $forum_id)), -); - -/** -* Event to modify data in the quickmod_array before it gets sent to the -* phpbb_add_quickmod_option function. -* -* @event core.viewtopic_add_quickmod_option_before -* @var int forum_id Forum ID -* @var int post_id Post ID -* @var array quickmod_array Array with quick moderation options data -* @var array topic_data Array with topic data -* @var int topic_id Topic ID -* @var array topic_tracking_info Array with topic tracking data -* @var string viewtopic_url URL to the topic page -* @var bool allow_change_type Topic change permissions check -* @since 3.1.9-RC1 -*/ -$vars = array( - 'forum_id', - 'post_id', - 'quickmod_array', - 'topic_data', - 'topic_id', - 'topic_tracking_info', - 'viewtopic_url', - 'allow_change_type', -); -extract($phpbb_dispatcher->trigger_event('core.viewtopic_add_quickmod_option_before', compact($vars))); - -foreach ($quickmod_array as $option => $qm_ary) -{ - if (!empty($qm_ary[1])) - { - phpbb_add_quickmod_option($s_quickmod_action, $option, $qm_ary[0]); - } -} - -// Navigation links -generate_forum_nav($topic_data); - -// Forum Rules -generate_forum_rules($topic_data); - -// Moderators -$forum_moderators = array(); -if ($config['load_moderators']) -{ - get_moderators($forum_moderators, $forum_id); -} - -// This is only used for print view so ... -$server_path = (!$view) ? $phpbb_root_path : generate_board_url() . '/'; - -// Replace naughty words in title -$topic_data['topic_title'] = censor_text($topic_data['topic_title']); - -$s_search_hidden_fields = array( - 't' => $topic_id, - 'sf' => 'msgonly', -); -if ($_SID) -{ - $s_search_hidden_fields['sid'] = $_SID; -} - -if (!empty($_EXTRA_URL)) -{ - foreach ($_EXTRA_URL as $url_param) - { - $url_param = explode('=', $url_param, 2); - $s_search_hidden_fields[$url_param[0]] = $url_param[1]; - } -} - -// If we've got a hightlight set pass it on to pagination. -$base_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id" . ((strlen($u_sort_param)) ? "&$u_sort_param" : '') . (($highlight_match) ? "&hilit=$highlight" : '')); - -/** -* Event to modify data before template variables are being assigned -* -* @event core.viewtopic_assign_template_vars_before -* @var string base_url URL to be passed to generate pagination -* @var int forum_id Forum ID -* @var int post_id Post ID -* @var array quickmod_array Array with quick moderation options data -* @var int start Pagination information -* @var array topic_data Array with topic data -* @var int topic_id Topic ID -* @var array topic_tracking_info Array with topic tracking data -* @var int total_posts Topic total posts count -* @var string viewtopic_url URL to the topic page -* @since 3.1.0-RC4 -* @changed 3.1.2-RC1 Added viewtopic_url -*/ -$vars = array( - 'base_url', - 'forum_id', - 'post_id', - 'quickmod_array', - 'start', - 'topic_data', - 'topic_id', - 'topic_tracking_info', - 'total_posts', - 'viewtopic_url', -); -extract($phpbb_dispatcher->trigger_event('core.viewtopic_assign_template_vars_before', compact($vars))); - -$pagination->generate_template_pagination($base_url, 'pagination', 'start', $total_posts, $config['posts_per_page'], $start); - -// Send vars to template -$template->assign_vars(array( - 'FORUM_ID' => $forum_id, - 'FORUM_NAME' => $topic_data['forum_name'], - 'FORUM_DESC' => generate_text_for_display($topic_data['forum_desc'], $topic_data['forum_desc_uid'], $topic_data['forum_desc_bitfield'], $topic_data['forum_desc_options']), - 'TOPIC_ID' => $topic_id, - 'TOPIC_TITLE' => $topic_data['topic_title'], - 'TOPIC_POSTER' => $topic_data['topic_poster'], - - 'TOPIC_AUTHOR_FULL' => get_username_string('full', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']), - 'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']), - 'TOPIC_AUTHOR' => get_username_string('username', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']), - - 'TOTAL_POSTS' => $user->lang('VIEW_TOPIC_POSTS', (int) $total_posts), - 'U_MCP' => ($auth->acl_get('m_', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&mode=topic_view&f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start") . ((strlen($u_sort_param)) ? "&$u_sort_param" : ''), true, $user->session_id) : '', - 'MODERATORS' => (isset($forum_moderators[$forum_id]) && count($forum_moderators[$forum_id])) ? implode($user->lang['COMMA_SEPARATOR'], $forum_moderators[$forum_id]) : '', - - 'POST_IMG' => ($topic_data['forum_status'] == ITEM_LOCKED) ? $user->img('button_topic_locked', 'FORUM_LOCKED') : $user->img('button_topic_new', 'POST_NEW_TOPIC'), - 'QUOTE_IMG' => $user->img('icon_post_quote', 'REPLY_WITH_QUOTE'), - 'REPLY_IMG' => ($topic_data['forum_status'] == ITEM_LOCKED || $topic_data['topic_status'] == ITEM_LOCKED) ? $user->img('button_topic_locked', 'TOPIC_LOCKED') : $user->img('button_topic_reply', 'REPLY_TO_TOPIC'), - 'EDIT_IMG' => $user->img('icon_post_edit', 'EDIT_POST'), - 'DELETE_IMG' => $user->img('icon_post_delete', 'DELETE_POST'), - 'DELETED_IMG' => $user->img('icon_topic_deleted', 'POST_DELETED_RESTORE'), - 'INFO_IMG' => $user->img('icon_post_info', 'VIEW_INFO'), - 'PROFILE_IMG' => $user->img('icon_user_profile', 'READ_PROFILE'), - 'SEARCH_IMG' => $user->img('icon_user_search', 'SEARCH_USER_POSTS'), - 'PM_IMG' => $user->img('icon_contact_pm', 'SEND_PRIVATE_MESSAGE'), - 'EMAIL_IMG' => $user->img('icon_contact_email', 'SEND_EMAIL'), - 'JABBER_IMG' => $user->img('icon_contact_jabber', 'JABBER') , - 'REPORT_IMG' => $user->img('icon_post_report', 'REPORT_POST'), - 'REPORTED_IMG' => $user->img('icon_topic_reported', 'POST_REPORTED'), - 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'POST_UNAPPROVED'), - 'WARN_IMG' => $user->img('icon_user_warn', 'WARN_USER'), - - 'S_IS_LOCKED' => ($topic_data['topic_status'] == ITEM_UNLOCKED && $topic_data['forum_status'] == ITEM_UNLOCKED) ? false : true, - 'S_SELECT_SORT_DIR' => $s_sort_dir, - 'S_SELECT_SORT_KEY' => $s_sort_key, - 'S_SELECT_SORT_DAYS' => $s_limit_days, - 'S_SINGLE_MODERATOR' => (!empty($forum_moderators[$forum_id]) && count($forum_moderators[$forum_id]) > 1) ? false : true, - 'S_TOPIC_ACTION' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start")), - 'S_MOD_ACTION' => $s_quickmod_action, - - 'L_RETURN_TO_FORUM' => $user->lang('RETURN_TO', $topic_data['forum_name']), - 'S_VIEWTOPIC' => true, - 'S_UNREAD_VIEW' => $view == 'unread', - 'S_DISPLAY_SEARCHBOX' => ($auth->acl_get('u_search') && $auth->acl_get('f_search', $forum_id) && $config['load_search']) ? true : false, - 'S_SEARCHBOX_ACTION' => append_sid("{$phpbb_root_path}search.$phpEx"), - 'S_SEARCH_LOCAL_HIDDEN_FIELDS' => build_hidden_fields($s_search_hidden_fields), - - 'S_DISPLAY_POST_INFO' => ($topic_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS)) ? true : false, - 'S_DISPLAY_REPLY_INFO' => ($topic_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_reply', $forum_id) || $user->data['user_id'] == ANONYMOUS)) ? true : false, - 'S_ENABLE_FEEDS_TOPIC' => ($config['feed_topic'] && !phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $topic_data['forum_options'])) ? true : false, - - 'U_TOPIC' => "{$server_path}viewtopic.$phpEx?f=$forum_id&t=$topic_id", - 'U_FORUM' => $server_path, - 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start") . (strlen($u_sort_param) ? "&$u_sort_param" : '')), - 'U_CANONICAL' => generate_board_url() . '/' . append_sid("viewtopic.$phpEx", "t=$topic_id" . (($start) ? "&start=$start" : ''), true, ''), - 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id), - 'U_VIEW_OLDER_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&view=previous"), - 'U_VIEW_NEWER_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&view=next"), - 'U_PRINT_TOPIC' => ($auth->acl_get('f_print', $forum_id)) ? $viewtopic_url . '&view=print' : '', - 'U_EMAIL_TOPIC' => ($auth->acl_get('f_email', $forum_id) && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=email&t=$topic_id") : '', - - 'U_WATCH_TOPIC' => $s_watching_topic['link'], - 'U_WATCH_TOPIC_TOGGLE' => $s_watching_topic['link_toggle'], - 'S_WATCH_TOPIC_TITLE' => $s_watching_topic['title'], - 'S_WATCH_TOPIC_TOGGLE' => $s_watching_topic['title_toggle'], - 'S_WATCHING_TOPIC' => $s_watching_topic['is_watching'], - - 'U_BOOKMARK_TOPIC' => ($user->data['is_registered'] && $config['allow_bookmarks']) ? $viewtopic_url . '&bookmark=1&hash=' . generate_link_hash("topic_$topic_id") : '', - 'S_BOOKMARK_TOPIC' => ($user->data['is_registered'] && $config['allow_bookmarks'] && $topic_data['bookmarked']) ? $user->lang['BOOKMARK_TOPIC_REMOVE'] : $user->lang['BOOKMARK_TOPIC'], - 'S_BOOKMARK_TOGGLE' => (!$user->data['is_registered'] || !$config['allow_bookmarks'] || !$topic_data['bookmarked']) ? $user->lang['BOOKMARK_TOPIC_REMOVE'] : $user->lang['BOOKMARK_TOPIC'], - 'S_BOOKMARKED_TOPIC' => ($user->data['is_registered'] && $config['allow_bookmarks'] && $topic_data['bookmarked']) ? true : false, - - 'U_POST_NEW_TOPIC' => ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=post&f=$forum_id") : '', - 'U_POST_REPLY_TOPIC' => ($auth->acl_get('f_reply', $forum_id) || $user->data['user_id'] == ANONYMOUS) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=reply&f=$forum_id&t=$topic_id") : '', - 'U_BUMP_TOPIC' => (bump_topic_allowed($forum_id, $topic_data['topic_bumped'], $topic_data['topic_last_post_time'], $topic_data['topic_poster'], $topic_data['topic_last_poster_id'])) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=bump&f=$forum_id&t=$topic_id&hash=" . generate_link_hash("topic_$topic_id")) : '') -); - -// Does this topic contain a poll? -if (!empty($topic_data['poll_start'])) -{ - $sql = 'SELECT o.*, p.bbcode_bitfield, p.bbcode_uid - FROM ' . POLL_OPTIONS_TABLE . ' o, ' . POSTS_TABLE . " p - WHERE o.topic_id = $topic_id - AND p.post_id = {$topic_data['topic_first_post_id']} - AND p.topic_id = o.topic_id - ORDER BY o.poll_option_id"; - $result = $db->sql_query($sql); - - $poll_info = $vote_counts = array(); - while ($row = $db->sql_fetchrow($result)) - { - $poll_info[] = $row; - $option_id = (int) $row['poll_option_id']; - $vote_counts[$option_id] = (int) $row['poll_option_total']; - } - $db->sql_freeresult($result); - - $cur_voted_id = array(); - if ($user->data['is_registered']) - { - $sql = 'SELECT poll_option_id - FROM ' . POLL_VOTES_TABLE . ' - WHERE topic_id = ' . $topic_id . ' - AND vote_user_id = ' . $user->data['user_id']; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $cur_voted_id[] = $row['poll_option_id']; - } - $db->sql_freeresult($result); - } - else - { - // Cookie based guest tracking ... I don't like this but hum ho - // it's oft requested. This relies on "nice" users who don't feel - // the need to delete cookies to mess with results. - if ($request->is_set($config['cookie_name'] . '_poll_' . $topic_id, \phpbb\request\request_interface::COOKIE)) - { - $cur_voted_id = explode(',', $request->variable($config['cookie_name'] . '_poll_' . $topic_id, '', true, \phpbb\request\request_interface::COOKIE)); - $cur_voted_id = array_map('intval', $cur_voted_id); - } - } - - // Can not vote at all if no vote permission - $s_can_vote = ($auth->acl_get('f_vote', $forum_id) && - (($topic_data['poll_length'] != 0 && $topic_data['poll_start'] + $topic_data['poll_length'] > time()) || $topic_data['poll_length'] == 0) && - $topic_data['topic_status'] != ITEM_LOCKED && - $topic_data['forum_status'] != ITEM_LOCKED && - (!count($cur_voted_id) || - ($auth->acl_get('f_votechg', $forum_id) && $topic_data['poll_vote_change']))) ? true : false; - $s_display_results = (!$s_can_vote || ($s_can_vote && count($cur_voted_id)) || $view == 'viewpoll') ? true : false; - - /** - * Event to manipulate the poll data - * - * @event core.viewtopic_modify_poll_data - * @var array cur_voted_id Array with options' IDs current user has voted for - * @var int forum_id The topic's forum id - * @var array poll_info Array with the poll information - * @var bool s_can_vote Flag indicating if a user can vote - * @var bool s_display_results Flag indicating if results or poll options should be displayed - * @var int topic_id The id of the topic the user tries to access - * @var array topic_data All the information from the topic and forum tables for this topic - * @var string viewtopic_url URL to the topic page - * @var array vote_counts Array with the vote counts for every poll option - * @var array voted_id Array with updated options' IDs current user is voting for - * @since 3.1.5-RC1 - */ - $vars = array( - 'cur_voted_id', - 'forum_id', - 'poll_info', - 's_can_vote', - 's_display_results', - 'topic_id', - 'topic_data', - 'viewtopic_url', - 'vote_counts', - 'voted_id', - ); - extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_poll_data', compact($vars))); - - if ($update && $s_can_vote) - { - - if (!count($voted_id) || count($voted_id) > $topic_data['poll_max_options'] || in_array(VOTE_CONVERTED, $cur_voted_id) || !check_form_key('posting')) - { - $redirect_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start")); - - meta_refresh(5, $redirect_url); - if (!count($voted_id)) - { - $message = 'NO_VOTE_OPTION'; - } - else if (count($voted_id) > $topic_data['poll_max_options']) - { - $message = 'TOO_MANY_VOTE_OPTIONS'; - } - else if (in_array(VOTE_CONVERTED, $cur_voted_id)) - { - $message = 'VOTE_CONVERTED'; - } - else - { - $message = 'FORM_INVALID'; - } - - $message = $user->lang[$message] . '

' . sprintf($user->lang['RETURN_TOPIC'], '', ''); - trigger_error($message); - } - - foreach ($voted_id as $option) - { - if (in_array($option, $cur_voted_id)) - { - continue; - } - - $sql = 'UPDATE ' . POLL_OPTIONS_TABLE . ' - SET poll_option_total = poll_option_total + 1 - WHERE poll_option_id = ' . (int) $option . ' - AND topic_id = ' . (int) $topic_id; - $db->sql_query($sql); - - $vote_counts[$option]++; - - if ($user->data['is_registered']) - { - $sql_ary = array( - 'topic_id' => (int) $topic_id, - 'poll_option_id' => (int) $option, - 'vote_user_id' => (int) $user->data['user_id'], - 'vote_user_ip' => (string) $user->ip, - ); - - $sql = 'INSERT INTO ' . POLL_VOTES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); - $db->sql_query($sql); - } - } - - foreach ($cur_voted_id as $option) - { - if (!in_array($option, $voted_id)) - { - $sql = 'UPDATE ' . POLL_OPTIONS_TABLE . ' - SET poll_option_total = poll_option_total - 1 - WHERE poll_option_id = ' . (int) $option . ' - AND topic_id = ' . (int) $topic_id; - $db->sql_query($sql); - - $vote_counts[$option]--; - - if ($user->data['is_registered']) - { - $sql = 'DELETE FROM ' . POLL_VOTES_TABLE . ' - WHERE topic_id = ' . (int) $topic_id . ' - AND poll_option_id = ' . (int) $option . ' - AND vote_user_id = ' . (int) $user->data['user_id']; - $db->sql_query($sql); - } - } - } - - if ($user->data['user_id'] == ANONYMOUS && !$user->data['is_bot']) - { - $user->set_cookie('poll_' . $topic_id, implode(',', $voted_id), time() + 31536000); - } - - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET poll_last_vote = ' . time() . " - WHERE topic_id = $topic_id"; - //, topic_last_post_time = ' . time() . " -- for bumping topics with new votes, ignore for now - $db->sql_query($sql); - - $redirect_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start")); - $message = $user->lang['VOTE_SUBMITTED'] . '

' . sprintf($user->lang['RETURN_TOPIC'], '', ''); - - if ($request->is_ajax()) - { - // Filter out invalid options - $valid_user_votes = array_intersect(array_keys($vote_counts), $voted_id); - - $data = array( - 'NO_VOTES' => $user->lang['NO_VOTES'], - 'success' => true, - 'user_votes' => array_flip($valid_user_votes), - 'vote_counts' => $vote_counts, - 'total_votes' => array_sum($vote_counts), - 'can_vote' => !count($valid_user_votes) || ($auth->acl_get('f_votechg', $forum_id) && $topic_data['poll_vote_change']), - ); - - /** - * Event to manipulate the poll data sent by AJAX response - * - * @event core.viewtopic_modify_poll_ajax_data - * @var array data JSON response data - * @var array valid_user_votes Valid user votes - * @var array vote_counts Vote counts - * @var int forum_id Forum ID - * @var array topic_data Topic data - * @var array poll_info Array with the poll information - * @since 3.2.4-RC1 - */ - $vars = array( - 'data', - 'valid_user_votes', - 'vote_counts', - 'forum_id', - 'topic_data', - 'poll_info', - ); - extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_poll_ajax_data', compact($vars))); - - $json_response = new \phpbb\json_response(); - $json_response->send($data); - } - - meta_refresh(5, $redirect_url); - trigger_error($message); - } - - $poll_total = 0; - $poll_most = 0; - foreach ($poll_info as $poll_option) - { - $poll_total += $poll_option['poll_option_total']; - $poll_most = ($poll_option['poll_option_total'] >= $poll_most) ? $poll_option['poll_option_total'] : $poll_most; - } - - $parse_flags = ($poll_info[0]['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES; - - for ($i = 0, $size = count($poll_info); $i < $size; $i++) - { - $poll_info[$i]['poll_option_text'] = generate_text_for_display($poll_info[$i]['poll_option_text'], $poll_info[$i]['bbcode_uid'], $poll_option['bbcode_bitfield'], $parse_flags, true); - } - - $topic_data['poll_title'] = generate_text_for_display($topic_data['poll_title'], $poll_info[0]['bbcode_uid'], $poll_info[0]['bbcode_bitfield'], $parse_flags, true); - - $poll_template_data = $poll_options_template_data = array(); - foreach ($poll_info as $poll_option) - { - $option_pct = ($poll_total > 0) ? $poll_option['poll_option_total'] / $poll_total : 0; - $option_pct_txt = sprintf("%.1d%%", round($option_pct * 100)); - $option_pct_rel = ($poll_most > 0) ? $poll_option['poll_option_total'] / $poll_most : 0; - $option_pct_rel_txt = sprintf("%.1d%%", round($option_pct_rel * 100)); - $option_most_votes = ($poll_option['poll_option_total'] > 0 && $poll_option['poll_option_total'] == $poll_most) ? true : false; - - $poll_options_template_data[] = array( - 'POLL_OPTION_ID' => $poll_option['poll_option_id'], - 'POLL_OPTION_CAPTION' => $poll_option['poll_option_text'], - 'POLL_OPTION_RESULT' => $poll_option['poll_option_total'], - 'POLL_OPTION_PERCENT' => $option_pct_txt, - 'POLL_OPTION_PERCENT_REL' => $option_pct_rel_txt, - 'POLL_OPTION_PCT' => round($option_pct * 100), - 'POLL_OPTION_WIDTH' => round($option_pct * 250), - 'POLL_OPTION_VOTED' => (in_array($poll_option['poll_option_id'], $cur_voted_id)) ? true : false, - 'POLL_OPTION_MOST_VOTES' => $option_most_votes, - ); - } - - $poll_end = $topic_data['poll_length'] + $topic_data['poll_start']; - - $poll_template_data = array( - 'POLL_QUESTION' => $topic_data['poll_title'], - 'TOTAL_VOTES' => $poll_total, - 'POLL_LEFT_CAP_IMG' => $user->img('poll_left'), - 'POLL_RIGHT_CAP_IMG'=> $user->img('poll_right'), - - 'L_MAX_VOTES' => $user->lang('MAX_OPTIONS_SELECT', (int) $topic_data['poll_max_options']), - 'L_POLL_LENGTH' => ($topic_data['poll_length']) ? sprintf($user->lang[($poll_end > time()) ? 'POLL_RUN_TILL' : 'POLL_ENDED_AT'], $user->format_date($poll_end)) : '', - - 'S_HAS_POLL' => true, - 'S_CAN_VOTE' => $s_can_vote, - 'S_DISPLAY_RESULTS' => $s_display_results, - 'S_IS_MULTI_CHOICE' => ($topic_data['poll_max_options'] > 1) ? true : false, - 'S_POLL_ACTION' => $viewtopic_url, - - 'U_VIEW_RESULTS' => $viewtopic_url . '&view=viewpoll', - ); - - /** - * Event to add/modify poll template data - * - * @event core.viewtopic_modify_poll_template_data - * @var array cur_voted_id Array with options' IDs current user has voted for - * @var int poll_end The poll end time - * @var array poll_info Array with the poll information - * @var array poll_options_template_data Array with the poll options template data - * @var array poll_template_data Array with the common poll template data - * @var int poll_total Total poll votes count - * @var int poll_most Mostly voted option votes count - * @var array topic_data All the information from the topic and forum tables for this topic - * @var string viewtopic_url URL to the topic page - * @var array vote_counts Array with the vote counts for every poll option - * @var array voted_id Array with updated options' IDs current user is voting for - * @since 3.1.5-RC1 - */ - $vars = array( - 'cur_voted_id', - 'poll_end', - 'poll_info', - 'poll_options_template_data', - 'poll_template_data', - 'poll_total', - 'poll_most', - 'topic_data', - 'viewtopic_url', - 'vote_counts', - 'voted_id', - ); - extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_poll_template_data', compact($vars))); - - $template->assign_block_vars_array('poll_option', $poll_options_template_data); - - $template->assign_vars($poll_template_data); - - unset($poll_end, $poll_info, $poll_options_template_data, $poll_template_data, $voted_id); -} - -// If the user is trying to reach the second half of the topic, fetch it starting from the end -$store_reverse = false; -$sql_limit = $config['posts_per_page']; -$sql_sort_order = $direction = ''; - -if ($start > $total_posts / 2) -{ - $store_reverse = true; - - // Select the sort order - $direction = (($sort_dir == 'd') ? 'ASC' : 'DESC'); - - $sql_limit = $pagination->reverse_limit($start, $sql_limit, $total_posts); - $sql_start = $pagination->reverse_start($start, $sql_limit, $total_posts); -} -else -{ - // Select the sort order - $direction = (($sort_dir == 'd') ? 'DESC' : 'ASC'); - $sql_start = $start; -} - -if (is_array($sort_by_sql[$sort_key])) -{ - $sql_sort_order = implode(' ' . $direction . ', ', $sort_by_sql[$sort_key]) . ' ' . $direction; -} -else -{ - $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . $direction; -} - -// Container for user details, only process once -$post_list = $user_cache = $id_cache = $attachments = $attach_list = $rowset = $update_count = $post_edit_list = $post_delete_list = array(); -$has_unapproved_attachments = $has_approved_attachments = $display_notice = false; -$i = $i_total = 0; - -// Go ahead and pull all data for this topic -$sql = 'SELECT p.post_id - FROM ' . POSTS_TABLE . ' p' . (($join_user_sql[$sort_key]) ? ', ' . USERS_TABLE . ' u': '') . " - WHERE p.topic_id = $topic_id - AND " . $phpbb_content_visibility->get_visibility_sql('post', $forum_id, 'p.') . " - " . (($join_user_sql[$sort_key]) ? 'AND u.user_id = p.poster_id': '') . " - $limit_posts_time - ORDER BY $sql_sort_order"; - -/** -* Event to modify the SQL query that gets post_list -* -* @event core.viewtopic_modify_post_list_sql -* @var string sql The SQL query to generate the post_list -* @var int sql_limit The number of posts the query fetches -* @var int sql_start The index the query starts to fetch from -* @var string sort_key Key the posts are sorted by -* @var string sort_days Display posts of previous x days -* @var int forum_id Forum ID -* @since 3.2.4-RC1 -*/ -$vars = array( - 'sql', - 'sql_limit', - 'sql_start', - 'sort_key', - 'sort_days', - 'forum_id', -); -extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_post_list_sql', compact($vars))); - -$result = $db->sql_query_limit($sql, $sql_limit, $sql_start); - -$i = ($store_reverse) ? $sql_limit - 1 : 0; -while ($row = $db->sql_fetchrow($result)) -{ - $post_list[$i] = (int) $row['post_id']; - ($store_reverse) ? $i-- : $i++; -} -$db->sql_freeresult($result); - -if (!count($post_list)) -{ - if ($sort_days) - { - trigger_error('NO_POSTS_TIME_FRAME'); - } - else - { - trigger_error('NO_TOPIC'); - } -} - -// Holding maximum post time for marking topic read -// We need to grab it because we do reverse ordering sometimes -$max_post_time = 0; - -$sql_ary = array( - 'SELECT' => 'u.*, z.friend, z.foe, p.*', - - 'FROM' => array( - USERS_TABLE => 'u', - POSTS_TABLE => 'p', - ), - - 'LEFT_JOIN' => array( - array( - 'FROM' => array(ZEBRA_TABLE => 'z'), - 'ON' => 'z.user_id = ' . $user->data['user_id'] . ' AND z.zebra_id = p.poster_id', - ), - ), - - 'WHERE' => $db->sql_in_set('p.post_id', $post_list) . ' - AND u.user_id = p.poster_id', -); - -/** -* Event to modify the SQL query before the post and poster data is retrieved -* -* @event core.viewtopic_get_post_data -* @var int forum_id Forum ID -* @var int topic_id Topic ID -* @var array topic_data Array with topic data -* @var array post_list Array with post_ids we are going to retrieve -* @var int sort_days Display posts of previous x days -* @var string sort_key Key the posts are sorted by -* @var string sort_dir Direction the posts are sorted by -* @var int start Pagination information -* @var array sql_ary The SQL array to get the data of posts and posters -* @since 3.1.0-a1 -* @changed 3.1.0-a2 Added vars forum_id, topic_id, topic_data, post_list, sort_days, sort_key, sort_dir, start -*/ -$vars = array( - 'forum_id', - 'topic_id', - 'topic_data', - 'post_list', - 'sort_days', - 'sort_key', - 'sort_dir', - 'start', - 'sql_ary', -); -extract($phpbb_dispatcher->trigger_event('core.viewtopic_get_post_data', compact($vars))); - -$sql = $db->sql_build_query('SELECT', $sql_ary); -$result = $db->sql_query($sql); - -$now = $user->create_datetime(); -$now = phpbb_gmgetdate($now->getTimestamp() + $now->getOffset()); - -// Posts are stored in the $rowset array while $attach_list, $user_cache -// and the global bbcode_bitfield are built -while ($row = $db->sql_fetchrow($result)) -{ - // Set max_post_time - if ($row['post_time'] > $max_post_time) - { - $max_post_time = $row['post_time']; - } - - $poster_id = (int) $row['poster_id']; - - // Does post have an attachment? If so, add it to the list - if ($row['post_attachment'] && $config['allow_attachments']) - { - $attach_list[] = (int) $row['post_id']; - - if ($row['post_visibility'] == ITEM_UNAPPROVED || $row['post_visibility'] == ITEM_REAPPROVE) - { - $has_unapproved_attachments = true; - } - else if ($row['post_visibility'] == ITEM_APPROVED) - { - $has_approved_attachments = true; - } - } - - $rowset_data = array( - 'hide_post' => (($row['foe'] || $row['post_visibility'] == ITEM_DELETED) && ($view != 'show' || $post_id != $row['post_id'])) ? true : false, - - 'post_id' => $row['post_id'], - 'post_time' => $row['post_time'], - 'user_id' => $row['user_id'], - 'username' => $row['username'], - 'user_colour' => $row['user_colour'], - 'topic_id' => $row['topic_id'], - 'forum_id' => $row['forum_id'], - 'post_subject' => $row['post_subject'], - 'post_edit_count' => $row['post_edit_count'], - 'post_edit_time' => $row['post_edit_time'], - 'post_edit_reason' => $row['post_edit_reason'], - 'post_edit_user' => $row['post_edit_user'], - 'post_edit_locked' => $row['post_edit_locked'], - 'post_delete_time' => $row['post_delete_time'], - 'post_delete_reason'=> $row['post_delete_reason'], - 'post_delete_user' => $row['post_delete_user'], - - // Make sure the icon actually exists - 'icon_id' => (isset($icons[$row['icon_id']]['img'], $icons[$row['icon_id']]['height'], $icons[$row['icon_id']]['width'])) ? $row['icon_id'] : 0, - 'post_attachment' => $row['post_attachment'], - 'post_visibility' => $row['post_visibility'], - 'post_reported' => $row['post_reported'], - 'post_username' => $row['post_username'], - 'post_text' => $row['post_text'], - 'bbcode_uid' => $row['bbcode_uid'], - 'bbcode_bitfield' => $row['bbcode_bitfield'], - 'enable_smilies' => $row['enable_smilies'], - 'enable_sig' => $row['enable_sig'], - 'friend' => $row['friend'], - 'foe' => $row['foe'], - ); - - /** - * Modify the post rowset containing data to be displayed with posts - * - * @event core.viewtopic_post_rowset_data - * @var array rowset_data Array with the rowset data for this post - * @var array row Array with original user and post data - * @since 3.1.0-a1 - */ - $vars = array('rowset_data', 'row'); - extract($phpbb_dispatcher->trigger_event('core.viewtopic_post_rowset_data', compact($vars))); - - $rowset[$row['post_id']] = $rowset_data; - - // Cache various user specific data ... so we don't have to recompute - // this each time the same user appears on this page - if (!isset($user_cache[$poster_id])) - { - if ($poster_id == ANONYMOUS) - { - $user_cache_data = array( - 'user_type' => USER_IGNORE, - 'joined' => '', - 'posts' => '', - - 'sig' => '', - 'sig_bbcode_uid' => '', - 'sig_bbcode_bitfield' => '', - - 'online' => false, - 'avatar' => ($user->optionget('viewavatars')) ? phpbb_get_user_avatar($row) : '', - 'rank_title' => '', - 'rank_image' => '', - 'rank_image_src' => '', - 'pm' => '', - 'email' => '', - 'jabber' => '', - 'search' => '', - 'age' => '', - - 'username' => $row['username'], - 'user_colour' => $row['user_colour'], - 'contact_user' => '', - - 'warnings' => 0, - 'allow_pm' => 0, - ); - - /** - * Modify the guest user's data displayed with the posts - * - * @event core.viewtopic_cache_guest_data - * @var array user_cache_data Array with the user's data - * @var int poster_id Poster's user id - * @var array row Array with original user and post data - * @since 3.1.0-a1 - */ - $vars = array('user_cache_data', 'poster_id', 'row'); - extract($phpbb_dispatcher->trigger_event('core.viewtopic_cache_guest_data', compact($vars))); - - $user_cache[$poster_id] = $user_cache_data; - - $user_rank_data = phpbb_get_user_rank($row, false); - $user_cache[$poster_id]['rank_title'] = $user_rank_data['title']; - $user_cache[$poster_id]['rank_image'] = $user_rank_data['img']; - $user_cache[$poster_id]['rank_image_src'] = $user_rank_data['img_src']; - } - else - { - $user_sig = ''; - - // We add the signature to every posters entry because enable_sig is post dependent - if ($row['user_sig'] && $config['allow_sig'] && $user->optionget('viewsigs')) - { - $user_sig = $row['user_sig']; - } - - $id_cache[] = $poster_id; - - $user_cache_data = array( - 'user_type' => $row['user_type'], - 'user_inactive_reason' => $row['user_inactive_reason'], - - 'joined' => $user->format_date($row['user_regdate']), - 'posts' => $row['user_posts'], - 'warnings' => (isset($row['user_warnings'])) ? $row['user_warnings'] : 0, - - 'sig' => $user_sig, - 'sig_bbcode_uid' => (!empty($row['user_sig_bbcode_uid'])) ? $row['user_sig_bbcode_uid'] : '', - 'sig_bbcode_bitfield' => (!empty($row['user_sig_bbcode_bitfield'])) ? $row['user_sig_bbcode_bitfield'] : '', - - 'viewonline' => $row['user_allow_viewonline'], - 'allow_pm' => $row['user_allow_pm'], - - 'avatar' => ($user->optionget('viewavatars')) ? phpbb_get_user_avatar($row) : '', - 'age' => '', - - 'rank_title' => '', - 'rank_image' => '', - 'rank_image_src' => '', - - 'username' => $row['username'], - 'user_colour' => $row['user_colour'], - 'contact_user' => $user->lang('CONTACT_USER', get_username_string('username', $poster_id, $row['username'], $row['user_colour'], $row['username'])), - - 'online' => false, - 'jabber' => ($config['jab_enable'] && $row['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&action=jabber&u=$poster_id") : '', - 'search' => ($config['load_search'] && $auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id=$poster_id&sr=posts") : '', - - 'author_full' => get_username_string('full', $poster_id, $row['username'], $row['user_colour']), - 'author_colour' => get_username_string('colour', $poster_id, $row['username'], $row['user_colour']), - 'author_username' => get_username_string('username', $poster_id, $row['username'], $row['user_colour']), - 'author_profile' => get_username_string('profile', $poster_id, $row['username'], $row['user_colour']), - ); - - /** - * Modify the users' data displayed with their posts - * - * @event core.viewtopic_cache_user_data - * @var array user_cache_data Array with the user's data - * @var int poster_id Poster's user id - * @var array row Array with original user and post data - * @since 3.1.0-a1 - */ - $vars = array('user_cache_data', 'poster_id', 'row'); - extract($phpbb_dispatcher->trigger_event('core.viewtopic_cache_user_data', compact($vars))); - - $user_cache[$poster_id] = $user_cache_data; - - $user_rank_data = phpbb_get_user_rank($row, $row['user_posts']); - $user_cache[$poster_id]['rank_title'] = $user_rank_data['title']; - $user_cache[$poster_id]['rank_image'] = $user_rank_data['img']; - $user_cache[$poster_id]['rank_image_src'] = $user_rank_data['img_src']; - - if ((!empty($row['user_allow_viewemail']) && $auth->acl_get('u_sendemail')) || $auth->acl_get('a_email')) - { - $user_cache[$poster_id]['email'] = ($config['board_email_form'] && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=email&u=$poster_id") : (($config['board_hide_emails'] && !$auth->acl_get('a_email')) ? '' : 'mailto:' . $row['user_email']); - } - else - { - $user_cache[$poster_id]['email'] = ''; - } - - if ($config['allow_birthdays'] && !empty($row['user_birthday'])) - { - list($bday_day, $bday_month, $bday_year) = array_map('intval', explode('-', $row['user_birthday'])); - - if ($bday_year) - { - $diff = $now['mon'] - $bday_month; - if ($diff == 0) - { - $diff = ($now['mday'] - $bday_day < 0) ? 1 : 0; - } - else - { - $diff = ($diff < 0) ? 1 : 0; - } - - $user_cache[$poster_id]['age'] = (int) ($now['year'] - $bday_year - $diff); - } - } - } - } -} -$db->sql_freeresult($result); - -// Load custom profile fields -if ($config['load_cpf_viewtopic']) -{ - /* @var $cp \phpbb\profilefields\manager */ - $cp = $phpbb_container->get('profilefields.manager'); - - // Grab all profile fields from users in id cache for later use - similar to the poster cache - $profile_fields_tmp = $cp->grab_profile_fields_data($id_cache); - - // filter out fields not to be displayed on viewtopic. Yes, it's a hack, but this shouldn't break any MODs. - $profile_fields_cache = array(); - foreach ($profile_fields_tmp as $profile_user_id => $profile_fields) - { - $profile_fields_cache[$profile_user_id] = array(); - foreach ($profile_fields as $used_ident => $profile_field) - { - if ($profile_field['data']['field_show_on_vt']) - { - $profile_fields_cache[$profile_user_id][$used_ident] = $profile_field; - } - } - } - unset($profile_fields_tmp); -} - -// Generate online information for user -if ($config['load_onlinetrack'] && count($id_cache)) -{ - $sql = 'SELECT session_user_id, MAX(session_time) as online_time, MIN(session_viewonline) AS viewonline - FROM ' . SESSIONS_TABLE . ' - WHERE ' . $db->sql_in_set('session_user_id', $id_cache) . ' - GROUP BY session_user_id'; - $result = $db->sql_query($sql); - - $update_time = $config['load_online_time'] * 60; - while ($row = $db->sql_fetchrow($result)) - { - $user_cache[$row['session_user_id']]['online'] = (time() - $update_time < $row['online_time'] && (($row['viewonline']) || $auth->acl_get('u_viewonline'))) ? true : false; - } - $db->sql_freeresult($result); -} -unset($id_cache); - -// Pull attachment data -if (count($attach_list)) -{ - if ($auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id)) - { - $sql = 'SELECT * - FROM ' . ATTACHMENTS_TABLE . ' - WHERE ' . $db->sql_in_set('post_msg_id', $attach_list) . ' - AND in_message = 0 - ORDER BY attach_id DESC, post_msg_id ASC'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $attachments[$row['post_msg_id']][] = $row; - } - $db->sql_freeresult($result); - - // No attachments exist, but post table thinks they do so go ahead and reset post_attach flags - if (!count($attachments)) - { - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET post_attachment = 0 - WHERE ' . $db->sql_in_set('post_id', $attach_list); - $db->sql_query($sql); - - // We need to update the topic indicator too if the complete topic is now without an attachment - if (count($rowset) != $total_posts) - { - // Not all posts are displayed so we query the db to find if there's any attachment for this topic - $sql = 'SELECT a.post_msg_id as post_id - FROM ' . ATTACHMENTS_TABLE . ' a, ' . POSTS_TABLE . " p - WHERE p.topic_id = $topic_id - AND p.post_visibility = " . ITEM_APPROVED . ' - AND p.topic_id = a.topic_id'; - $result = $db->sql_query_limit($sql, 1); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - $sql = 'UPDATE ' . TOPICS_TABLE . " - SET topic_attachment = 0 - WHERE topic_id = $topic_id"; - $db->sql_query($sql); - } - } - else - { - $sql = 'UPDATE ' . TOPICS_TABLE . " - SET topic_attachment = 0 - WHERE topic_id = $topic_id"; - $db->sql_query($sql); - } - } - else if ($has_approved_attachments && !$topic_data['topic_attachment']) - { - // Topic has approved attachments but its flag is wrong - $sql = 'UPDATE ' . TOPICS_TABLE . " - SET topic_attachment = 1 - WHERE topic_id = $topic_id"; - $db->sql_query($sql); - - $topic_data['topic_attachment'] = 1; - } - else if ($has_unapproved_attachments && !$topic_data['topic_attachment']) - { - // Topic has only unapproved attachments but we have the right to see and download them - $topic_data['topic_attachment'] = 1; - } - } - else - { - $display_notice = true; - } -} - -if ($config['enable_accurate_pm_button']) -{ - // Get the list of users who can receive private messages - $can_receive_pm_list = $auth->acl_get_list(array_keys($user_cache), 'u_readpm'); - $can_receive_pm_list = (empty($can_receive_pm_list) || !isset($can_receive_pm_list[0]['u_readpm'])) ? array() : $can_receive_pm_list[0]['u_readpm']; - - // Get the list of permanently banned users - $permanently_banned_users = phpbb_get_banned_user_ids(array_keys($user_cache), false); -} -else -{ - $can_receive_pm_list = array_keys($user_cache); - $permanently_banned_users = []; -} - -$i_total = count($rowset) - 1; -$prev_post_id = ''; - -$template->assign_vars(array( - 'S_HAS_ATTACHMENTS' => $topic_data['topic_attachment'], - 'S_NUM_POSTS' => count($post_list)) -); - -/** -* Event to modify the post, poster and attachment data before assigning the posts -* -* @event core.viewtopic_modify_post_data -* @var int forum_id Forum ID -* @var int topic_id Topic ID -* @var array topic_data Array with topic data -* @var array post_list Array with post_ids we are going to display -* @var array rowset Array with post_id => post data -* @var array user_cache Array with prepared user data -* @var int start Pagination information -* @var int sort_days Display posts of previous x days -* @var string sort_key Key the posts are sorted by -* @var string sort_dir Direction the posts are sorted by -* @var bool display_notice Shall we display a notice instead of attachments -* @var bool has_approved_attachments Does the topic have approved attachments -* @var array attachments List of attachments post_id => array of attachments -* @var array permanently_banned_users List of permanently banned users -* @var array can_receive_pm_list Array with posters that can receive pms -* @since 3.1.0-RC3 -*/ -$vars = array( - 'forum_id', - 'topic_id', - 'topic_data', - 'post_list', - 'rowset', - 'user_cache', - 'sort_days', - 'sort_key', - 'sort_dir', - 'start', - 'permanently_banned_users', - 'can_receive_pm_list', - 'display_notice', - 'has_approved_attachments', - 'attachments', -); -extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_post_data', compact($vars))); - -// Output the posts -$first_unread = $post_unread = false; -for ($i = 0, $end = count($post_list); $i < $end; ++$i) -{ - // A non-existing rowset only happens if there was no user present for the entered poster_id - // This could be a broken posts table. - if (!isset($rowset[$post_list[$i]])) - { - continue; - } - - $row = $rowset[$post_list[$i]]; - $poster_id = $row['user_id']; - - // End signature parsing, only if needed - if ($user_cache[$poster_id]['sig'] && $row['enable_sig'] && empty($user_cache[$poster_id]['sig_parsed'])) - { - $parse_flags = ($user_cache[$poster_id]['sig_bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES; - $user_cache[$poster_id]['sig'] = generate_text_for_display($user_cache[$poster_id]['sig'], $user_cache[$poster_id]['sig_bbcode_uid'], $user_cache[$poster_id]['sig_bbcode_bitfield'], $parse_flags, true); - $user_cache[$poster_id]['sig_parsed'] = true; - } - - // Parse the message and subject - $parse_flags = ($row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES; - $message = generate_text_for_display($row['post_text'], $row['bbcode_uid'], $row['bbcode_bitfield'], $parse_flags, true); - - if (!empty($attachments[$row['post_id']])) - { - parse_attachments($forum_id, $message, $attachments[$row['post_id']], $update_count); - } - - // Replace naughty words such as farty pants - $row['post_subject'] = censor_text($row['post_subject']); - - // Highlight active words (primarily for search) - if ($highlight_match) - { - $message = preg_replace('#(?!<.*)(?]*(?:)#is', '\1', $message); - $row['post_subject'] = preg_replace('#(?!<.*)(?]*(?:)#is', '\1', $row['post_subject']); - } - - // Editing information - if (($row['post_edit_count'] && $config['display_last_edited']) || $row['post_edit_reason']) - { - // Get usernames for all following posts if not already stored - if (!count($post_edit_list) && ($row['post_edit_reason'] || ($row['post_edit_user'] && !isset($user_cache[$row['post_edit_user']])))) - { - // Remove all post_ids already parsed (we do not have to check them) - $post_storage_list = (!$store_reverse) ? array_slice($post_list, $i) : array_slice(array_reverse($post_list), $i); - - $sql = 'SELECT DISTINCT u.user_id, u.username, u.user_colour - FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u - WHERE ' . $db->sql_in_set('p.post_id', $post_storage_list) . ' - AND p.post_edit_count <> 0 - AND p.post_edit_user <> 0 - AND p.post_edit_user = u.user_id'; - $result2 = $db->sql_query($sql); - while ($user_edit_row = $db->sql_fetchrow($result2)) - { - $post_edit_list[$user_edit_row['user_id']] = $user_edit_row; - } - $db->sql_freeresult($result2); - - unset($post_storage_list); - } - - if ($row['post_edit_reason']) - { - // User having edited the post also being the post author? - if (!$row['post_edit_user'] || $row['post_edit_user'] == $poster_id) - { - $display_username = get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']); - } - else - { - $display_username = get_username_string('full', $row['post_edit_user'], $post_edit_list[$row['post_edit_user']]['username'], $post_edit_list[$row['post_edit_user']]['user_colour']); - } - - $l_edited_by = $user->lang('EDITED_TIMES_TOTAL', (int) $row['post_edit_count'], $display_username, $user->format_date($row['post_edit_time'], false, true)); - } - else - { - if ($row['post_edit_user'] && !isset($user_cache[$row['post_edit_user']])) - { - $user_cache[$row['post_edit_user']] = $post_edit_list[$row['post_edit_user']]; - } - - // User having edited the post also being the post author? - if (!$row['post_edit_user'] || $row['post_edit_user'] == $poster_id) - { - $display_username = get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']); - } - else - { - $display_username = get_username_string('full', $row['post_edit_user'], $user_cache[$row['post_edit_user']]['username'], $user_cache[$row['post_edit_user']]['user_colour']); - } - - $l_edited_by = $user->lang('EDITED_TIMES_TOTAL', (int) $row['post_edit_count'], $display_username, $user->format_date($row['post_edit_time'], false, true)); - } - } - else - { - $l_edited_by = ''; - } - - // Deleting information - if ($row['post_visibility'] == ITEM_DELETED && $row['post_delete_user']) - { - // Get usernames for all following posts if not already stored - if (!count($post_delete_list) && ($row['post_delete_reason'] || ($row['post_delete_user'] && !isset($user_cache[$row['post_delete_user']])))) - { - // Remove all post_ids already parsed (we do not have to check them) - $post_storage_list = (!$store_reverse) ? array_slice($post_list, $i) : array_slice(array_reverse($post_list), $i); - - $sql = 'SELECT DISTINCT u.user_id, u.username, u.user_colour - FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u - WHERE ' . $db->sql_in_set('p.post_id', $post_storage_list) . ' - AND p.post_delete_user <> 0 - AND p.post_delete_user = u.user_id'; - $result2 = $db->sql_query($sql); - while ($user_delete_row = $db->sql_fetchrow($result2)) - { - $post_delete_list[$user_delete_row['user_id']] = $user_delete_row; - } - $db->sql_freeresult($result2); - - unset($post_storage_list); - } - - if ($row['post_delete_user'] && !isset($user_cache[$row['post_delete_user']])) - { - $user_cache[$row['post_delete_user']] = $post_delete_list[$row['post_delete_user']]; - } - - $display_postername = get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']); - - // User having deleted the post also being the post author? - if (!$row['post_delete_user'] || $row['post_delete_user'] == $poster_id) - { - $display_username = $display_postername; - } - else - { - $display_username = get_username_string('full', $row['post_delete_user'], $user_cache[$row['post_delete_user']]['username'], $user_cache[$row['post_delete_user']]['user_colour']); - } - - if ($row['post_delete_reason']) - { - $l_deleted_message = $user->lang('POST_DELETED_BY_REASON', $display_postername, $display_username, $user->format_date($row['post_delete_time'], false, true), $row['post_delete_reason']); - } - else - { - $l_deleted_message = $user->lang('POST_DELETED_BY', $display_postername, $display_username, $user->format_date($row['post_delete_time'], false, true)); - } - $l_deleted_by = $user->lang('DELETED_INFORMATION', $display_username, $user->format_date($row['post_delete_time'], false, true)); - } - else - { - $l_deleted_by = $l_deleted_message = ''; - } - - // Bump information - if ($topic_data['topic_bumped'] && $row['post_id'] == $topic_data['topic_last_post_id'] && isset($user_cache[$topic_data['topic_bumper']]) ) - { - // It is safe to grab the username from the user cache array, we are at the last - // post and only the topic poster and last poster are allowed to bump. - // Admins and mods are bound to the above rules too... - $l_bumped_by = sprintf($user->lang['BUMPED_BY'], $user_cache[$topic_data['topic_bumper']]['username'], $user->format_date($topic_data['topic_last_post_time'], false, true)); - } - else - { - $l_bumped_by = ''; - } - - $cp_row = array(); - - // - if ($config['load_cpf_viewtopic']) - { - $cp_row = (isset($profile_fields_cache[$poster_id])) ? $cp->generate_profile_fields_template_data($profile_fields_cache[$poster_id]) : array(); - } - - $post_unread = (isset($topic_tracking_info[$topic_id]) && $row['post_time'] > $topic_tracking_info[$topic_id]) ? true : false; - - $s_first_unread = false; - if (!$first_unread && $post_unread) - { - $s_first_unread = $first_unread = true; - } - - $force_edit_allowed = $force_delete_allowed = $force_softdelete_allowed = false; - - $s_cannot_edit = !$auth->acl_get('f_edit', $forum_id) || $user->data['user_id'] != $poster_id; - $s_cannot_edit_time = $config['edit_time'] && $row['post_time'] <= time() - ($config['edit_time'] * 60); - $s_cannot_edit_locked = $topic_data['topic_status'] == ITEM_LOCKED || $row['post_edit_locked']; - - $s_cannot_delete = $user->data['user_id'] != $poster_id || ( - !$auth->acl_get('f_delete', $forum_id) && - (!$auth->acl_get('f_softdelete', $forum_id) || $row['post_visibility'] == ITEM_DELETED) - ); - $s_cannot_delete_lastpost = $topic_data['topic_last_post_id'] != $row['post_id']; - $s_cannot_delete_time = $config['delete_time'] && $row['post_time'] <= time() - ($config['delete_time'] * 60); - // we do not want to allow removal of the last post if a moderator locked it! - $s_cannot_delete_locked = $topic_data['topic_status'] == ITEM_LOCKED || $row['post_edit_locked']; - - /** - * This event allows you to modify the conditions for the "can edit post" and "can delete post" checks - * - * @event core.viewtopic_modify_post_action_conditions - * @var array row Array with post data - * @var array topic_data Array with topic data - * @var bool force_edit_allowed Allow the user to edit the post (all permissions and conditions are ignored) - * @var bool s_cannot_edit User can not edit the post because it's not his - * @var bool s_cannot_edit_locked User can not edit the post because it's locked - * @var bool s_cannot_edit_time User can not edit the post because edit_time has passed - * @var bool force_delete_allowed Allow the user to delete the post (all permissions and conditions are ignored) - * @var bool s_cannot_delete User can not delete the post because it's not his - * @var bool s_cannot_delete_lastpost User can not delete the post because it's not the last post of the topic - * @var bool s_cannot_delete_locked User can not delete the post because it's locked - * @var bool s_cannot_delete_time User can not delete the post because edit_time has passed - * @var bool force_softdelete_allowed Allow the user to ыoftdelete the post (all permissions and conditions are ignored) - * @since 3.1.0-b4 - * @changed 3.1.11-RC1 Added force_softdelete_allowed var - */ - $vars = array( - 'row', - 'topic_data', - 'force_edit_allowed', - 's_cannot_edit', - 's_cannot_edit_locked', - 's_cannot_edit_time', - 'force_delete_allowed', - 's_cannot_delete', - 's_cannot_delete_lastpost', - 's_cannot_delete_locked', - 's_cannot_delete_time', - 'force_softdelete_allowed', - ); - extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_post_action_conditions', compact($vars))); - - $edit_allowed = $force_edit_allowed || ($user->data['is_registered'] && ($auth->acl_get('m_edit', $forum_id) || ( - !$s_cannot_edit && - !$s_cannot_edit_time && - !$s_cannot_edit_locked - ))); - - $quote_allowed = $auth->acl_get('m_edit', $forum_id) || ($topic_data['topic_status'] != ITEM_LOCKED && - ($user->data['user_id'] == ANONYMOUS || $auth->acl_get('f_reply', $forum_id)) - ); - - // Only display the quote button if the post is quotable. Posts not approved are not quotable. - $quote_allowed = ($quote_allowed && $row['post_visibility'] == ITEM_APPROVED) ? true : false; - - $delete_allowed = $force_delete_allowed || ($user->data['is_registered'] && ( - ($auth->acl_get('m_delete', $forum_id) || ($auth->acl_get('m_softdelete', $forum_id) && $row['post_visibility'] != ITEM_DELETED)) || - (!$s_cannot_delete && !$s_cannot_delete_lastpost && !$s_cannot_delete_time && !$s_cannot_delete_locked) - )); - - $softdelete_allowed = $force_softdelete_allowed || (($auth->acl_get('m_softdelete', $forum_id) || - ($auth->acl_get('f_softdelete', $forum_id) && $user->data['user_id'] == $poster_id)) && ($row['post_visibility'] != ITEM_DELETED)); - - $permanent_delete_allowed = $force_delete_allowed || ($auth->acl_get('m_delete', $forum_id) || - ($auth->acl_get('f_delete', $forum_id) && $user->data['user_id'] == $poster_id)); - - // Can this user receive a Private Message? - $can_receive_pm = ( - // They must be a "normal" user - $user_cache[$poster_id]['user_type'] != USER_IGNORE && - - // They must not be deactivated by the administrator - ($user_cache[$poster_id]['user_type'] != USER_INACTIVE || $user_cache[$poster_id]['user_inactive_reason'] != INACTIVE_MANUAL) && - - // They must be able to read PMs - in_array($poster_id, $can_receive_pm_list) && - - // They must not be permanently banned - !in_array($poster_id, $permanently_banned_users) && - - // They must allow users to contact via PM - (($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) || $user_cache[$poster_id]['allow_pm']) - ); - - $u_pm = ''; - - if ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && $can_receive_pm) - { - $u_pm = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&action=quotepost&p=' . $row['post_id']); - } - - // - $post_row = array( - 'POST_AUTHOR_FULL' => ($poster_id != ANONYMOUS) ? $user_cache[$poster_id]['author_full'] : get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), - 'POST_AUTHOR_COLOUR' => ($poster_id != ANONYMOUS) ? $user_cache[$poster_id]['author_colour'] : get_username_string('colour', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), - 'POST_AUTHOR' => ($poster_id != ANONYMOUS) ? $user_cache[$poster_id]['author_username'] : get_username_string('username', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), - 'U_POST_AUTHOR' => ($poster_id != ANONYMOUS) ? $user_cache[$poster_id]['author_profile'] : get_username_string('profile', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), - - 'RANK_TITLE' => $user_cache[$poster_id]['rank_title'], - 'RANK_IMG' => $user_cache[$poster_id]['rank_image'], - 'RANK_IMG_SRC' => $user_cache[$poster_id]['rank_image_src'], - 'POSTER_JOINED' => $user_cache[$poster_id]['joined'], - 'POSTER_POSTS' => $user_cache[$poster_id]['posts'], - 'POSTER_AVATAR' => $user_cache[$poster_id]['avatar'], - 'POSTER_WARNINGS' => $auth->acl_get('m_warn') ? $user_cache[$poster_id]['warnings'] : '', - 'POSTER_AGE' => $user_cache[$poster_id]['age'], - 'CONTACT_USER' => $user_cache[$poster_id]['contact_user'], - - 'POST_DATE' => $user->format_date($row['post_time'], false, ($view == 'print') ? true : false), - 'POST_DATE_RFC3339' => gmdate(DATE_RFC3339, $row['post_time']), - 'POST_SUBJECT' => $row['post_subject'], - 'MESSAGE' => $message, - 'SIGNATURE' => ($row['enable_sig']) ? $user_cache[$poster_id]['sig'] : '', - 'EDITED_MESSAGE' => $l_edited_by, - 'EDIT_REASON' => $row['post_edit_reason'], - 'DELETED_MESSAGE' => $l_deleted_by, - 'DELETE_REASON' => $row['post_delete_reason'], - 'BUMPED_MESSAGE' => $l_bumped_by, - - 'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'), - 'POST_ICON_IMG' => ($topic_data['enable_icons'] && !empty($row['icon_id'])) ? $icons[$row['icon_id']]['img'] : '', - 'POST_ICON_IMG_WIDTH' => ($topic_data['enable_icons'] && !empty($row['icon_id'])) ? $icons[$row['icon_id']]['width'] : '', - 'POST_ICON_IMG_HEIGHT' => ($topic_data['enable_icons'] && !empty($row['icon_id'])) ? $icons[$row['icon_id']]['height'] : '', - 'POST_ICON_IMG_ALT' => ($topic_data['enable_icons'] && !empty($row['icon_id'])) ? $icons[$row['icon_id']]['alt'] : '', - 'ONLINE_IMG' => ($poster_id == ANONYMOUS || !$config['load_onlinetrack']) ? '' : (($user_cache[$poster_id]['online']) ? $user->img('icon_user_online', 'ONLINE') : $user->img('icon_user_offline', 'OFFLINE')), - 'S_ONLINE' => ($poster_id == ANONYMOUS || !$config['load_onlinetrack']) ? false : (($user_cache[$poster_id]['online']) ? true : false), - - 'U_EDIT' => ($edit_allowed) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=edit&f=$forum_id&p={$row['post_id']}") : '', - 'U_QUOTE' => ($quote_allowed) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=quote&f=$forum_id&p={$row['post_id']}") : '', - 'U_INFO' => ($auth->acl_get('m_info', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&mode=post_details&f=$forum_id&p=" . $row['post_id'], true, $user->session_id) : '', - 'U_DELETE' => ($delete_allowed) ? append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=' . (($softdelete_allowed) ? 'soft_delete' : 'delete') . "&f=$forum_id&p={$row['post_id']}") : '', - - 'U_SEARCH' => $user_cache[$poster_id]['search'], - 'U_PM' => $u_pm, - 'U_EMAIL' => $user_cache[$poster_id]['email'], - 'U_JABBER' => $user_cache[$poster_id]['jabber'], - - 'U_APPROVE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue&p={$row['post_id']}&f=$forum_id&redirect=" . urlencode(str_replace('&', '&', $viewtopic_url . '&p=' . $row['post_id'] . '#p' . $row['post_id']))), - 'U_REPORT' => ($auth->acl_get('f_report', $forum_id)) ? $phpbb_container->get('controller.helper')->route('phpbb_report_post_controller', array('id' => $row['post_id'])) : '', - 'U_MCP_REPORT' => ($auth->acl_get('m_report', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=report_details&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '', - 'U_MCP_APPROVE' => ($auth->acl_get('m_approve', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=approve_details&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '', - 'U_MCP_RESTORE' => ($auth->acl_get('m_approve', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=' . (($topic_data['topic_visibility'] != ITEM_DELETED) ? 'deleted_posts' : 'deleted_topics') . '&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '', - 'U_MINI_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $row['post_id']) . '#p' . $row['post_id'], - 'U_NEXT_POST_ID' => ($i < $i_total && isset($rowset[$post_list[$i + 1]])) ? $rowset[$post_list[$i + 1]]['post_id'] : '', - 'U_PREV_POST_ID' => $prev_post_id, - 'U_NOTES' => ($auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $poster_id, true, $user->session_id) : '', - 'U_WARN' => ($auth->acl_get('m_warn') && $poster_id != $user->data['user_id'] && $poster_id != ANONYMOUS) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_post&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '', - - 'POST_ID' => $row['post_id'], - 'POST_NUMBER' => $i + $start + 1, - 'POSTER_ID' => $poster_id, - 'MINI_POST' => ($post_unread) ? $user->lang['UNREAD_POST'] : $user->lang['POST'], - - - 'S_HAS_ATTACHMENTS' => (!empty($attachments[$row['post_id']])) ? true : false, - 'S_MULTIPLE_ATTACHMENTS' => !empty($attachments[$row['post_id']]) && count($attachments[$row['post_id']]) > 1, - 'S_POST_UNAPPROVED' => ($row['post_visibility'] == ITEM_UNAPPROVED || $row['post_visibility'] == ITEM_REAPPROVE) ? true : false, - 'S_CAN_APPROVE' => $auth->acl_get('m_approve', $forum_id), - 'S_POST_DELETED' => ($row['post_visibility'] == ITEM_DELETED) ? true : false, - 'L_POST_DELETED_MESSAGE' => $l_deleted_message, - 'S_POST_REPORTED' => ($row['post_reported'] && $auth->acl_get('m_report', $forum_id)) ? true : false, - 'S_DISPLAY_NOTICE' => $display_notice && $row['post_attachment'], - 'S_FRIEND' => ($row['friend']) ? true : false, - 'S_UNREAD_POST' => $post_unread, - 'S_FIRST_UNREAD' => $s_first_unread, - 'S_CUSTOM_FIELDS' => (isset($cp_row['row']) && count($cp_row['row'])) ? true : false, - 'S_TOPIC_POSTER' => ($topic_data['topic_poster'] == $poster_id) ? true : false, - 'S_FIRST_POST' => ($topic_data['topic_first_post_id'] == $row['post_id']) ? true : false, - - 'S_IGNORE_POST' => ($row['foe']) ? true : false, - 'L_IGNORE_POST' => ($row['foe']) ? sprintf($user->lang['POST_BY_FOE'], get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username'])) : '', - 'S_POST_HIDDEN' => $row['hide_post'], - 'L_POST_DISPLAY' => ($row['hide_post']) ? $user->lang('POST_DISPLAY', '', '') : '', - 'S_DELETE_PERMANENT' => $permanent_delete_allowed, - ); - - $user_poster_data = $user_cache[$poster_id]; - - $current_row_number = $i; - - /** - * Modify the posts template block - * - * @event core.viewtopic_modify_post_row - * @var int start Start item of this page - * @var int current_row_number Number of the post on this page - * @var int end Number of posts on this page - * @var int total_posts Total posts count - * @var int poster_id Post author id - * @var array row Array with original post and user data - * @var array cp_row Custom profile field data of the poster - * @var array attachments List of attachments - * @var array user_poster_data Poster's data from user cache - * @var array post_row Template block array of the post - * @var array topic_data Array with topic data - * @var array user_cache Array with cached user data - * @var array post_edit_list Array with post edited list - * @since 3.1.0-a1 - * @changed 3.1.0-a3 Added vars start, current_row_number, end, attachments - * @changed 3.1.0-b3 Added topic_data array, total_posts - * @changed 3.1.0-RC3 Added poster_id - * @changed 3.2.2-RC1 Added user_cache and post_edit_list - */ - $vars = array( - 'start', - 'current_row_number', - 'end', - 'total_posts', - 'poster_id', - 'row', - 'cp_row', - 'attachments', - 'user_poster_data', - 'post_row', - 'topic_data', - 'user_cache', - 'post_edit_list', - ); - extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_post_row', compact($vars))); - - $i = $current_row_number; - - if (isset($cp_row['row']) && count($cp_row['row'])) - { - $post_row = array_merge($post_row, $cp_row['row']); - } - - // Dump vars into template - $template->assign_block_vars('postrow', $post_row); - - $contact_fields = array( - array( - 'ID' => 'pm', - 'NAME' => $user->lang['SEND_PRIVATE_MESSAGE'], - 'U_CONTACT' => $post_row['U_PM'], - ), - array( - 'ID' => 'email', - 'NAME' => $user->lang['SEND_EMAIL'], - 'U_CONTACT' => $user_cache[$poster_id]['email'], - ), - array( - 'ID' => 'jabber', - 'NAME' => $user->lang['JABBER'], - 'U_CONTACT' => $user_cache[$poster_id]['jabber'], - ), - ); - - foreach ($contact_fields as $field) - { - if ($field['U_CONTACT']) - { - $template->assign_block_vars('postrow.contact', $field); - } - } - - if (!empty($cp_row['blockrow'])) - { - foreach ($cp_row['blockrow'] as $field_data) - { - $template->assign_block_vars('postrow.custom_fields', $field_data); - - if ($field_data['S_PROFILE_CONTACT']) - { - $template->assign_block_vars('postrow.contact', array( - 'ID' => $field_data['PROFILE_FIELD_IDENT'], - 'NAME' => $field_data['PROFILE_FIELD_NAME'], - 'U_CONTACT' => $field_data['PROFILE_FIELD_CONTACT'], - )); - } - } - } - - // Display not already displayed Attachments for this post, we already parsed them. ;) - if (!empty($attachments[$row['post_id']])) - { - foreach ($attachments[$row['post_id']] as $attachment) - { - $template->assign_block_vars('postrow.attachment', array( - 'DISPLAY_ATTACHMENT' => $attachment) - ); - } - } - - $current_row_number = $i; - - /** - * Event after the post data has been assigned to the template - * - * @event core.viewtopic_post_row_after - * @var int start Start item of this page - * @var int current_row_number Number of the post on this page - * @var int end Number of posts on this page - * @var int total_posts Total posts count - * @var array row Array with original post and user data - * @var array cp_row Custom profile field data of the poster - * @var array attachments List of attachments - * @var array user_poster_data Poster's data from user cache - * @var array post_row Template block array of the post - * @var array topic_data Array with topic data - * @since 3.1.0-a3 - * @changed 3.1.0-b3 Added topic_data array, total_posts - */ - $vars = array( - 'start', - 'current_row_number', - 'end', - 'total_posts', - 'row', - 'cp_row', - 'attachments', - 'user_poster_data', - 'post_row', - 'topic_data', - ); - extract($phpbb_dispatcher->trigger_event('core.viewtopic_post_row_after', compact($vars))); - - $i = $current_row_number; - - $prev_post_id = $row['post_id']; - - unset($rowset[$post_list[$i]]); - unset($attachments[$row['post_id']]); -} -unset($rowset, $user_cache); - -// Update topic view and if necessary attachment view counters ... but only for humans and if this is the first 'page view' -if (isset($user->data['session_page']) && !$user->data['is_bot'] && (strpos($user->data['session_page'], '&t=' . $topic_id) === false || isset($user->data['session_created']))) -{ - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_views = topic_views + 1, topic_last_view_time = ' . time() . " - WHERE topic_id = $topic_id"; - $db->sql_query($sql); - - // Update the attachment download counts - if (count($update_count)) - { - $sql = 'UPDATE ' . ATTACHMENTS_TABLE . ' - SET download_count = download_count + 1 - WHERE ' . $db->sql_in_set('attach_id', array_unique($update_count)); - $db->sql_query($sql); - } -} - -// Only mark topic if it's currently unread. Also make sure we do not set topic tracking back if earlier pages are viewed. -if (isset($topic_tracking_info[$topic_id]) && $topic_data['topic_last_post_time'] > $topic_tracking_info[$topic_id] && $max_post_time > $topic_tracking_info[$topic_id]) -{ - markread('topic', $forum_id, $topic_id, $max_post_time); - - // Update forum info - $all_marked_read = update_forum_tracking_info($forum_id, $topic_data['forum_last_post_time'], (isset($topic_data['forum_mark_time'])) ? $topic_data['forum_mark_time'] : false, false); -} -else -{ - $all_marked_read = true; -} - -// If there are absolutely no more unread posts in this forum -// and unread posts shown, we can safely show the #unread link -if ($all_marked_read) -{ - if ($post_unread) - { - $template->assign_vars(array( - 'U_VIEW_UNREAD_POST' => '#unread', - )); - } - else if (isset($topic_tracking_info[$topic_id]) && $topic_data['topic_last_post_time'] > $topic_tracking_info[$topic_id]) - { - $template->assign_vars(array( - 'U_VIEW_UNREAD_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&view=unread") . '#unread', - )); - } -} -else if (!$all_marked_read) -{ - $last_page = ((floor($start / $config['posts_per_page']) + 1) == max(ceil($total_posts / $config['posts_per_page']), 1)) ? true : false; - - // What can happen is that we are at the last displayed page. If so, we also display the #unread link based in $post_unread - if ($last_page && $post_unread) - { - $template->assign_vars(array( - 'U_VIEW_UNREAD_POST' => '#unread', - )); - } - else if (!$last_page) - { - $template->assign_vars(array( - 'U_VIEW_UNREAD_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&view=unread") . '#unread', - )); - } -} - -// let's set up quick_reply -$s_quick_reply = false; -if ($user->data['is_registered'] && $config['allow_quick_reply'] && ($topic_data['forum_flags'] & FORUM_FLAG_QUICK_REPLY) && $auth->acl_get('f_reply', $forum_id)) -{ - // Quick reply enabled forum - $s_quick_reply = (($topic_data['forum_status'] == ITEM_UNLOCKED && $topic_data['topic_status'] == ITEM_UNLOCKED) || $auth->acl_get('m_edit', $forum_id)) ? true : false; -} - -if ($s_can_vote || $s_quick_reply) -{ - add_form_key('posting'); - - if ($s_quick_reply) - { - $s_attach_sig = $config['allow_sig'] && $user->optionget('attachsig') && $auth->acl_get('f_sigs', $forum_id) && $auth->acl_get('u_sig'); - $s_smilies = $config['allow_smilies'] && $user->optionget('smilies') && $auth->acl_get('f_smilies', $forum_id); - $s_bbcode = $config['allow_bbcode'] && $user->optionget('bbcode') && $auth->acl_get('f_bbcode', $forum_id); - $s_notify = $config['allow_topic_notify'] && ($user->data['user_notify'] || $s_watching_topic['is_watching']); - - $qr_hidden_fields = array( - 'topic_cur_post_id' => (int) $topic_data['topic_last_post_id'], - 'topic_id' => (int) $topic_data['topic_id'], - 'forum_id' => (int) $forum_id, - ); - - // Originally we use checkboxes and check with isset(), so we only provide them if they would be checked - (!$s_bbcode) ? $qr_hidden_fields['disable_bbcode'] = 1 : true; - (!$s_smilies) ? $qr_hidden_fields['disable_smilies'] = 1 : true; - (!$config['allow_post_links']) ? $qr_hidden_fields['disable_magic_url'] = 1 : true; - ($s_attach_sig) ? $qr_hidden_fields['attach_sig'] = 1 : true; - ($s_notify) ? $qr_hidden_fields['notify'] = 1 : true; - ($topic_data['topic_status'] == ITEM_LOCKED) ? $qr_hidden_fields['lock_topic'] = 1 : true; - - $tpl_ary = [ - 'S_QUICK_REPLY' => true, - 'U_QR_ACTION' => append_sid("{$phpbb_root_path}posting.$phpEx", "mode=reply&f=$forum_id&t=$topic_id"), - 'QR_HIDDEN_FIELDS' => build_hidden_fields($qr_hidden_fields), - 'SUBJECT' => 'Re: ' . censor_text($topic_data['topic_title']), - ]; - - /** - * Event after the quick-reply has been setup - * - * @event core.viewtopic_modify_quick_reply_template_vars - * @var array tpl_ary Array with template data - * @var array topic_data Array with topic data - * @since 3.2.9-RC1 - */ - $vars = ['tpl_ary', 'topic_data']; - extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_quick_reply_template_vars', compact($vars))); - - $template->assign_vars($tpl_ary); - } -} -// now I have the urge to wash my hands :( - - -// We overwrite $_REQUEST['f'] if there is no forum specified -// to be able to display the correct online list. -// One downside is that the user currently viewing this topic/post is not taken into account. -if (!$request->variable('f', 0)) -{ - $request->overwrite('f', $forum_id); -} - -// We need to do the same with the topic_id. See #53025. -if (!$request->variable('t', 0) && !empty($topic_id)) -{ - $request->overwrite('t', $topic_id); -} - -$page_title = $topic_data['topic_title'] . ($start ? ' - ' . sprintf($user->lang['PAGE_TITLE_NUMBER'], $pagination->get_on_page($config['posts_per_page'], $start)) : ''); - -/** -* You can use this event to modify the page title of the viewtopic page -* -* @event core.viewtopic_modify_page_title -* @var string page_title Title of the viewtopic page -* @var array topic_data Array with topic data -* @var int forum_id Forum ID of the topic -* @var int start Start offset used to calculate the page -* @var array post_list Array with post_ids we are going to display -* @since 3.1.0-a1 -* @changed 3.1.0-RC4 Added post_list var -*/ -$vars = array('page_title', 'topic_data', 'forum_id', 'start', 'post_list'); -extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_page_title', compact($vars))); - -// Output the page -page_header($page_title, true, $forum_id); - -$template->set_filenames(array( - 'body' => ($view == 'print') ? 'viewtopic_print.html' : 'viewtopic_body.html') -); -make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"), $forum_id); - -page_footer(); diff --git a/install/update/old/.htaccess b/install/update/old/.htaccess deleted file mode 100644 index 53bce76..0000000 --- a/install/update/old/.htaccess +++ /dev/null @@ -1,85 +0,0 @@ - -RewriteEngine on - -# -# Uncomment the statement below if URL rewriting doesn't -# work properly. If you installed phpBB in a subdirectory -# of your site, properly set the argument for the statement. -# e.g.: if your domain is test.com and you installed phpBB -# in http://www.test.com/phpBB/index.php you have to set -# the statement RewriteBase /phpBB/ -# -#RewriteBase / - -# -# Uncomment the statement below if you want to make use of -# HTTP authentication and it does not already work. -# This could be required if you are for example using PHP via Apache CGI. -# -#RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L] - -# -# The following 3 lines will rewrite URLs passed through the front controller -# to not require app.php in the actual URL. In other words, a controller is -# by default accessed at /app.php/my/controller, but can also be accessed at -# /my/controller -# -RewriteCond %{REQUEST_FILENAME} !-f -RewriteCond %{REQUEST_FILENAME} !-d -RewriteRule ^(.*)$ app.php [QSA,L] - -# -# If symbolic links are not already being followed, -# uncomment the line below. -# http://anothersysadmin.wordpress.com/2008/06/10/mod_rewrite-forbidden-403-with-apache-228/ -# -#Options +FollowSymLinks - - -# With Apache 2.4 the "Order, Deny" syntax has been deprecated and moved from -# module mod_authz_host to a new module called mod_access_compat (which may be -# disabled) and a new "Require" syntax has been introduced to mod_authz_host. -# We could just conditionally provide both versions, but unfortunately Apache -# does not explicitly tell us its version if the module mod_version is not -# available. In this case, we check for the availability of module -# mod_authz_core (which should be on 2.4 or higher only) as a best guess. - - - - Order Allow,Deny - Deny from All - - - Order Allow,Deny - Deny from All - - - = 2.4> - - Require all denied - - - Require all denied - - - - - - - Order Allow,Deny - Deny from All - - - Order Allow,Deny - Deny from All - - - - - Require all denied - - - Require all denied - - - diff --git a/install/update/old/adm/index.php b/install/update/old/adm/index.php deleted file mode 100644 index d27f56f..0000000 --- a/install/update/old/adm/index.php +++ /dev/null @@ -1,91 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -*/ -define('IN_PHPBB', true); -define('ADMIN_START', true); -define('NEED_SID', true); - -// Include files -$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); -require($phpbb_root_path . 'common.' . $phpEx); -require($phpbb_root_path . 'includes/functions_acp.' . $phpEx); -require($phpbb_root_path . 'includes/functions_admin.' . $phpEx); -require($phpbb_root_path . 'includes/functions_module.' . $phpEx); - -// Start session management -$user->session_begin(); -$auth->acl($user->data); -$user->setup('acp/common'); -// End session management - -// Have they authenticated (again) as an admin for this session? -if (!isset($user->data['session_admin']) || !$user->data['session_admin']) -{ - login_box('', $user->lang['LOGIN_ADMIN_CONFIRM'], $user->lang['LOGIN_ADMIN_SUCCESS'], true, false); -} - -// Is user any type of admin? No, then stop here, each script needs to -// check specific permissions but this is a catchall -if (!$auth->acl_get('a_')) -{ - send_status_line(403, 'Forbidden'); - trigger_error('NO_ADMIN'); -} - -// We define the admin variables now, because the user is now able to use the admin related features... -define('IN_ADMIN', true); - -// Some oft used variables -$safe_mode = (@ini_get('safe_mode') == '1' || strtolower(@ini_get('safe_mode')) === 'on') ? true : false; -$file_uploads = (@ini_get('file_uploads') == '1' || strtolower(@ini_get('file_uploads')) === 'on') ? true : false; -$module_id = $request->variable('i', ''); -$mode = $request->variable('mode', ''); - -// Set custom style for admin area -$template->set_custom_style(array( - array( - 'name' => 'adm', - 'ext_path' => 'adm/style/', - ), -), $phpbb_admin_path . 'style'); - -$template->assign_var('T_ASSETS_PATH', $phpbb_root_path . 'assets'); -$template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style'); - -// Instantiate new module -$module = new p_master(); - -// Instantiate module system and generate list of available modules -$module->list_modules('acp'); - -// Select the active module -$module->set_active($module_id, $mode); - -// Assign data to the template engine for the list of modules -// We do this before loading the active module for correct menu display in trigger_error -$module->assign_tpl_vars(append_sid("{$phpbb_admin_path}index.$phpEx")); - -// Load and execute the relevant module -$module->load_active(); - -// Generate the page -adm_page_header($module->get_page_title()); - -$template->set_filenames(array( - 'body' => $module->get_tpl_name(), -)); - -adm_page_footer(); diff --git a/install/update/old/adm/style/acp_attachments.html b/install/update/old/adm/style/acp_attachments.html deleted file mode 100644 index 868e256..0000000 --- a/install/update/old/adm/style/acp_attachments.html +++ /dev/null @@ -1,487 +0,0 @@ - - - - - - « {L_BACK} - - -

{L_TITLE}

- -

{L_TITLE_EXPLAIN}

- - -
-

{L_WARNING}

-

{WARNING_MSG}

-
- - - -
-

{L_NOTIFY}

-

{NOTIFY_MSG}

-
- - - -

{L_UPLOADING_FILES}

- - - :: {upload.FILE_INFO}
- {upload.DENIED}{upload.ERROR_MSG}{L_SUCCESSFULLY_UPLOADED} -

- - - - - - -
- - - - - -
- {options.LEGEND} - - -
-

{options.TITLE_EXPLAIN}
-
{options.CONTENT}
-
- - - -
- -
- {L_SUBMIT} -   - -
- - -
-

{L_SECURE_DOWNLOAD_NOTICE}

-
- - -
- {L_SECURE_TITLE} -

{L_DOWNLOAD_ADD_IPS_EXPLAIN}

-
-
-
-
-
-

{L_EXCLUDE_ENTERED_IP}
-
-
-
- -

- -

-
- -
- {L_REMOVE_IPS} - -

{L_DOWNLOAD_REMOVE_IPS_EXPLAIN}

-
-
-
-
- -

- -

-
- - -

{L_NO_IPS_DEFINED}

- - {S_FORM_TOKEN} - -
- - - - - - -
-
- - - - {L_LEGEND} -
-
-
-
-
-

{L_SPECIAL_CATEGORY_EXPLAIN}
-
{S_CATEGORY_SELECT}
-
-
-
-
checked="checked" />
-
-
-
-
checked="checked" />
-
-
-
-
-
 src="{ROOT_PATH}images/spacer.gif"src="{UPLOAD_ICON_SRC}" id="image_upload_icon" alt="" title="" /> 
-
-
-
-
-
-
-
-
{ASSIGNED_EXTENSIONS}
[{L_GO_TO_EXTENSIONS} ]
-
-
-
-

{L_ALLOWED_FORUMS_EXPLAIN}
-
-
-
-
- -

-   - -

- {S_FORM_TOKEN} -
- -
- - -
-
- {L_TITLE} - - - - - - - - - - - - - - - - - - - - - - - - -
{L_EXTENSION_GROUP}{L_SPECIAL_CATEGORY}{L_OPTIONS}
 
{groups.GROUP_NAME} -
» {L_NOT_ALLOWED_IN_PM} -
» {L_ONLY_ALLOWED_IN_PM} -
» {L_NOT_ALLOWED_IN_PM_POST} -
» {L_ALLOWED_IN_PM_POST} -
{groups.CATEGORY} {ICON_EDIT}  {ICON_DELETE} 
-

- {L_CREATE_GROUP}{L_COLON} - -

- {S_FORM_TOKEN} -
-
- - - - - -
-
- {L_ADD_EXTENSION} -
-
-
-
-
-
-
{GROUP_SELECT_OPTIONS}
-
- -

- -

- {S_FORM_TOKEN} -
-
- -
- -
- {L_TITLE} - - - - - - - - - - - - - - - - - - - - - - - - -
{L_EXTENSION}{L_EXTENSION_GROUP}{L_DELETE}
 
{extensions.EXTENSION}{extensions.GROUP_OPTIONS}
- -

-   - -

- {S_FORM_TOKEN} -
-
- - - -
- -
- {L_TITLE} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{L_FILENAME}{L_FILEDATE}{L_FILESIZE}{L_ATTACH_POST_ID}{L_ATTACH_TO_POST}{L_DELETE}
{orphan.REAL_FILENAME}{orphan.FILETIME}{orphan.FILESIZE}{L_ATTACH_ID}{L_COLON}
 {L_MARK_ALL} :: {L_UNMARK_ALL}{L_MARK_ALL} :: {L_UNMARK_ALL}
- -
-

{L_NO_ATTACHMENTS}

-
- - - - - - - -

-   - -

- - - {S_FORM_TOKEN} -
-
- - - -
- -
- {L_TITLE} - - - - - - - - - - - - - - - - - - - - - - - -
{L_FILENAME}{L_POSTED}{L_FILESIZE}{L_MARK}
- {L_EXTENSION_GROUP}{L_COLON} {attachments.EXT_GROUP_NAME}{L_NO_EXT_GROUP}
{attachments.L_DOWNLOAD_COUNT}
{L_IN} {L_PRIVATE_MESSAGE} - {attachments.REAL_FILENAME}
{attachments.COMMENT}
{attachments.L_DOWNLOAD_COUNT}
{L_TOPIC}{L_COLON} {attachments.TOPIC_TITLE} -
{attachments.FILETIME}
{L_POST_BY_AUTHOR} {attachments.ATTACHMENT_POSTER}
{attachments.FILESIZE}
- -
-

{L_NO_ATTACHMENTS}

-
- - - - - - -
- {L_DISPLAY_LOG}{L_COLON}  {S_LIMIT_DAYS} {L_SORT_BY}{L_COLON} {S_SORT_KEY} {S_SORT_DIR} - -
- -
- - -
-
-

- {L_MARK_ALL} • - {L_UNMARK_ALL} -

-
- - {S_FORM_TOKEN} -
-
- - -
- {L_RESYNC_STATS} -
-
-

{L_RESYNC_FILES_STATS_EXPLAIN}
-
-
-
-
- - - - diff --git a/install/update/old/adm/style/acp_avatar_options_upload.html b/install/update/old/adm/style/acp_avatar_options_upload.html deleted file mode 100644 index 63a734e..0000000 --- a/install/update/old/adm/style/acp_avatar_options_upload.html +++ /dev/null @@ -1,11 +0,0 @@ -
-
-
-
- - -
-

{L_UPLOAD_AVATAR_URL_EXPLAIN}
-
-
- diff --git a/install/update/old/adm/style/acp_ban.html b/install/update/old/adm/style/acp_ban.html deleted file mode 100644 index f224994..0000000 --- a/install/update/old/adm/style/acp_ban.html +++ /dev/null @@ -1,131 +0,0 @@ - - - - -

{L_ACP_BAN_EXPLAIN}

- -

{L_TITLE}

- -

{L_EXPLAIN}

- - - -
- -
- {L_TITLE} -
-
-
-
[ {L_FIND_USERNAME} ]
-
-
-
-
- -
-
-

{L_BAN_EXCLUDE_EXPLAIN}
-
-
-
-
-
-
-
-
-
-
-
- -

-   - -

-{S_FORM_TOKEN} -
-
- -

- -

{L_UNBAN_TITLE}

- -

{L_UNBAN_EXPLAIN}

- -
- -
- {L_UNBAN_TITLE} - - -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -

-   - -

- {S_FORM_TOKEN} -
- - - -

{L_NO_BAN_CELL}

- {S_FORM_TOKEN} - - - - -
- - diff --git a/install/update/old/adm/style/acp_contact.html b/install/update/old/adm/style/acp_contact.html deleted file mode 100644 index 828fd4b..0000000 --- a/install/update/old/adm/style/acp_contact.html +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - -

{L_ACP_CONTACT_SETTINGS}

- -

{L_ACP_CONTACT_SETTINGS_EXPLAIN}

- -
-
- {L_GENERAL_OPTIONS} -
-

{L_CONTACT_US_ENABLE_EXPLAIN}
-
- - -
-
-
- - -
- {L_CONTACT_US_INFO_PREVIEW} -

{CONTACT_US_INFO_PREVIEW}

-
- - -
- {L_CONTACT_US_INFO} -

{L_CONTACT_US_INFO_EXPLAIN}

- - - -
-
-
- -
- -
- -
- - - - - - - - - -
-
{L_OPTIONS}{L_COLON} {BBCODE_STATUS} :: {IMG_STATUS} :: {FLASH_STATUS} :: {URL_STATUS} :: {SMILIES_STATUS}
-
-
- -
-   - - {S_FORM_TOKEN} -
-
- - diff --git a/install/update/old/adm/style/acp_database.html b/install/update/old/adm/style/acp_database.html deleted file mode 100644 index ed0f4dd..0000000 --- a/install/update/old/adm/style/acp_database.html +++ /dev/null @@ -1,96 +0,0 @@ - - - - - -

{L_ACP_RESTORE}

- -

{L_ACP_RESTORE_EXPLAIN}

- - -
- -
- {L_RESTORE_OPTIONS} -
-
-
-
- -

-   -   -

- {S_FORM_TOKEN} -
-
- -
-

{L_ACP_NO_ITEMS}

-
- - - -

{L_ACP_BACKUP}

- -

{L_ACP_BACKUP_EXPLAIN}

- - - -
- -
- {L_BACKUP_OPTIONS} -
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
-
{L_SELECT_ALL} :: {L_DESELECT_ALL}
-
- -

-   - -

- {S_FORM_TOKEN} -
-
- - - - diff --git a/install/update/old/adm/style/acp_ext_list.html b/install/update/old/adm/style/acp_ext_list.html deleted file mode 100644 index 8e2c745..0000000 --- a/install/update/old/adm/style/acp_ext_list.html +++ /dev/null @@ -1,123 +0,0 @@ - - - - -

{L_EXTENSIONS_ADMIN}

- -

{L_EXTENSIONS_EXPLAIN}

- -
- {L_BROWSE_EXTENSIONS_DATABASE}{L_VERSIONCHECK_FORCE_UPDATE_ALL}{L_SETTINGS} -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{L_EXTENSION_NAME}{L_CURRENT_VERSION}{L_EXTENSION_OPTIONS}{L_EXTENSION_ACTIONS}
{L_EXTENSIONS_ENABLED}
{enabled.META_DISPLAY_NAME} - - {enabled.META_VERSION} - - - {enabled.META_VERSION} - - {L_DETAILS} - - title="{enabled.actions.L_ACTION_EXPLAIN}">{enabled.actions.L_ACTION} -  |  - -
{L_EXTENSIONS_DISABLED}
{disabled.META_DISPLAY_NAME} - - {disabled.META_VERSION} - - - {disabled.META_VERSION} - - - {L_DETAILS} - - - title="{disabled.actions.L_ACTION_EXPLAIN}">{disabled.actions.L_ACTION} -  |  - -
- - - - - - - - - - - - - - - - - - - - - -
{L_EXTENSION_INSTALL_HEADLINE}
{L_EXTENSION_INSTALL_EXPLAIN}
{L_EXTENSION_UPDATE_HEADLINE}
{L_EXTENSION_UPDATE_EXPLAIN}
{L_EXTENSION_REMOVE_HEADLINE}
{L_EXTENSION_REMOVE_EXPLAIN}
- - diff --git a/install/update/old/adm/style/acp_forums.html b/install/update/old/adm/style/acp_forums.html deleted file mode 100644 index 965438f..0000000 --- a/install/update/old/adm/style/acp_forums.html +++ /dev/null @@ -1,519 +0,0 @@ - - - - - - - - - « {L_BACK} - -

{L_TITLE} :: {FORUM_NAME}

- -

{L_FORUM_EDIT_EXPLAIN}

- - -
-

{L_WARNING}

-

{ERROR_MSG}

-
- - -
- -
- {L_FORUM_SETTINGS} - -
-
-
-
- -
-
-
-
-
-
-
- - - - -
-
-
-
- -
-

{L_COPY_PERMISSIONS_EXPLAIN}
-
-
- -
-
-
-
-
-

{L_FORUM_DESC_EXPLAIN}
-
-
- -
-
-
-

{L_FORUM_IMAGE_EXPLAIN}
-
- -
{L_FORUM_IMAGE}
- -
-
-

{L_FORUM_PASSWORD_EXPLAIN}
-
-
-
-

{L_FORUM_PASSWORD_CONFIRM_EXPLAIN}
-
-
- -
-

{L_FORUM_PASSWORD_UNSET_EXPLAIN}
-
-
- -
-
-
-
- -
- -
-
- {L_GENERAL_FORUM_SETTINGS} -
-

{L_DISPLAY_ACTIVE_TOPICS_EXPLAIN}
-
-
-
-
-
- -
-
- {L_GENERAL_FORUM_SETTINGS} - -
-
-
-
-
-

{L_LIST_SUBFORUMS_EXPLAIN}
-
-
-
-
-

{L_LIST_INDEX_EXPLAIN}
-
-
-
-
-

{L_ENABLE_POST_REVIEW_EXPLAIN}
-
-
-
-
-

{L_ENABLE_QUICK_REPLY_EXPLAIN}
-
-
-
-
-

{L_ENABLE_INDEXING_EXPLAIN}
-
-
-
-
-
-
-
-
-
-

{L_ENABLE_RECENT_EXPLAIN}
-
-
-
-
-

{L_FORUM_TOPICS_PAGE_EXPLAIN}
-
-
- -
- -
- {L_FORUM_PRUNE_SETTINGS} - -
-

{L_FORUM_AUTO_PRUNE_EXPLAIN}
-
-
-
-
-

{L_AUTO_PRUNE_FREQ_EXPLAIN}
-
{L_DAYS}
-
-
-

{L_AUTO_PRUNE_DAYS_EXPLAIN}
-
{L_DAYS}
-
-
-

{L_AUTO_PRUNE_VIEWED_EXPLAIN}
-
{L_DAYS}
-
-
-

{L_PRUNE_OLD_POLLS_EXPLAIN}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

{L_FORUM_PRUNE_SHADOW_EXPLAIN}
-
-
-
-
-

{L_AUTO_PRUNE_SHADOW_FREQ_EXPLAIN}
-
{L_DAYS}
-
-
-

{L_AUTO_PRUNE_SHADOW_DAYS_EXPLAIN}
-
{L_DAYS}
-
- -
-
- - - -
-
- {L_FORUM_RULES} - -
-

{L_FORUM_RULES_LINK_EXPLAIN}
-
-
- -
-
-
{FORUM_RULES_PREVIEW}
-
- -
-

{L_FORUM_RULES_EXPLAIN}
-
-
- -
-
- -
-
- - - -
- {L_SUBMIT} -   - - {S_FORM_TOKEN} -
-
- - - - « {L_BACK} - -

{L_FORUM_DELETE}

- -

{L_FORUM_DELETE_EXPLAIN}

- - -
-

{L_WARNING}

-

{ERROR_MSG}

-
- - -
- -
- {L_FORUM_DELETE} -
-
-
{FORUM_NAME}
-
- -
-
-
- -
- -
- - -
-
-
- -
- -
- - -

- -

- {S_FORM_TOKEN} -
-
- - - - - -

{L_FORUM_ADMIN}

- -

{L_FORUM_ADMIN_EXPLAIN}

- -

{L_PROGRESS_EXPLAIN}

- - - - - -

{L_FORUM_ADMIN}

- -

{L_FORUM_ADMIN_EXPLAIN}

- - -
-

{L_WARNING}

-

{ERROR_MSG}

-
- - - - - -
-

{L_NOTIFY}

-

{L_FORUM_RESYNCED}

-
- - -

{NAVIGATION} [{L_EDIT} | {L_DELETE} | {L_RESYNC}]

- - - - - - - - - - - - - -
{forums.FOLDER_IMAGE} -
{forums.FORUM_IMAGE}
- {forums.FORUM_NAME}{forums.FORUM_NAME} -
{forums.FORUM_DESCRIPTION} -

{L_TOPICS}{L_COLON} {forums.FORUM_TOPICS} / {L_POSTS}{L_COLON} {forums.FORUM_POSTS} -
- - {ICON_MOVE_UP} - - {ICON_MOVE_DOWN} - {ICON_EDIT} - - {ICON_SYNC} - - {ICON_SYNC_DISABLED} - - {ICON_DELETE} -
- - -
- -
- {L_SELECT_FORUM}{L_COLON} - - - {S_FORM_TOKEN} -
-
- -
- -
- - - - - {S_FORM_TOKEN} -
-
- - - - diff --git a/install/update/old/adm/style/acp_groups.html b/install/update/old/adm/style/acp_groups.html deleted file mode 100644 index d009637..0000000 --- a/install/update/old/adm/style/acp_groups.html +++ /dev/null @@ -1,333 +0,0 @@ - - - - - - - « {L_BACK} - -

{L_ACP_GROUPS_MANAGE}

- -

{L_GROUP_EDIT_EXPLAIN}

- - -
-

{L_WARNING}

-

{ERROR_MSG}

-
- - -
- -
- {L_GROUP_DETAILS} -
-
for="group_name">{L_GROUP_NAME}{L_COLON}
-
{GROUP_NAME}
-
-
-
-
-
- -
-
- -
-

{L_GROUP_TYPE_EXPLAIN}
-
- - - - -
-
- - - - - -
-

{L_COPY_PERMISSIONS_EXPLAIN}
-
-
- -
- -
- {L_GROUP_OPTIONS_SAVE} - - -
-

{L_GROUP_FOUNDER_MANAGE_EXPLAIN}
-
-
- -
-

{L_GROUP_SKIP_AUTH_EXPLAIN}
-
-
-
-
-
-
-
-
-
-
-
-

{L_GROUP_RECEIVE_PM_EXPLAIN}
-
-
- -
- -
- {L_GROUP_SETTINGS_SAVE} -
-

{L_GROUP_MESSAGE_LIMIT_EXPLAIN}
-
-
-
-

{L_GROUP_MAX_RECIPIENTS_EXPLAIN}
-
-
-
-

{L_GROUP_COLOR_EXPLAIN}
-
- -        - [ {L_COLOUR_SWATCH} ] - -
-
-
-
-
-
-
- -
- {L_GROUP_AVATAR} -
-

{L_AVATAR_EXPLAIN}
-
{AVATAR}
-
-
-
-
-
-
-
- -
-

{avatar_drivers.L_EXPLAIN}

- {avatar_drivers.OUTPUT} -
- -
-
- -
- {L_SUBMIT} -   - - {S_FORM_TOKEN} -
-
- - - - « {L_BACK} - -

{L_GROUP_MEMBERS} :: {GROUP_NAME}

- -

{L_GROUP_MEMBERS_EXPLAIN}

- -
- -
- » {L_MAKE_DEFAULT_FOR_ALL} -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{L_USERNAME}{L_GROUP_DEFAULT}{L_JOINED}{L_POSTS}{L_MARK}
{L_GROUP_LEAD}
{leader.USERNAME}{leader.USERNAME}{L_YES}{L_NO}{leader.JOINED}{leader.USER_POSTS}
{L_GROUPS_NO_MODS}
{L_GROUP_APPROVED}
{L_GROUP_PENDING}
{member.USERNAME}{member.USERNAME}{L_YES}{L_NO}{member.JOINED}{member.USER_POSTS}
{L_GROUPS_NO_MEMBERS}
- - -
- - -

{L_MARK_ALL}{L_UNMARK_ALL}

-
- -

{L_ADD_USERS}

- -

{L_ADD_USERS_EXPLAIN}

- -
- {L_ADD_USERS} -
-
-
-
-
-
-

{L_USER_GROUP_DEFAULT_EXPLAIN}
-
-
-
-
-

{L_USERNAMES_EXPLAIN}
-
-
[ {L_FIND_USERNAME} ]
-
- -

- -

- {S_FORM_TOKEN} -
-
- - - -

{L_ACP_GROUPS_MANAGE}

- -

{L_ACP_GROUPS_MANAGE_EXPLAIN}

- - -
-

{L_WARNING}

-

{ERROR_MSG}

-
- - -

{L_USER_DEF_GROUPS}

- -

{L_USER_DEF_GROUPS_EXPLAIN}

- -
- - - - - - - - - - - - - - - - - - - - - - -
{L_GROUP}{L_TOTAL_MEMBERS}{L_PENDING_MEMBERS}{L_OPTIONS}{L_ACTION}
{L_NO_GROUPS_CREATED}
- - -
- - {L_CREATE_GROUP}{L_COLON} - - - {S_FORM_TOKEN} -
-
- -

{L_SPECIAL_GROUPS}

- -

{L_SPECIAL_GROUPS_EXPLAIN}

- - - - - - - - - - - - - - - - - - - - - - - - - -
{L_GROUP}{L_TOTAL_MEMBERS}{L_PENDING_MEMBERS}{L_OPTIONS}{L_ACTION}
style="color: #{groups.GROUP_COLOR}">{groups.GROUP_NAME}{groups.TOTAL_MEMBERS}{groups.PENDING_MEMBERS}{L_SETTINGS}{L_MEMBERS}{L_DELETE}{L_DELETE}
- - - - diff --git a/install/update/old/adm/style/acp_help_phpbb.html b/install/update/old/adm/style/acp_help_phpbb.html deleted file mode 100644 index 478ecc1..0000000 --- a/install/update/old/adm/style/acp_help_phpbb.html +++ /dev/null @@ -1,61 +0,0 @@ - - - - -

{L_ACP_HELP_PHPBB}

- -
-
- -
-

{L_SEND_STATISTICS}

-

{L_EXPLAIN_SEND_STATISTICS}

-
- -
-
- -
- {providers.NAME} - -
-
{providers.values.KEY}
-
{providers.values.VALUE}
-
- -
- -
-
-
-
-
- checked="checked" /> - -
-
{L_SEND_STATISTICS_LONG}
-
-
- -
-

- - - -

- {S_FORM_TOKEN} -
-
-
-
-
-

- - -

-
-
- - diff --git a/install/update/old/adm/style/acp_icons.html b/install/update/old/adm/style/acp_icons.html deleted file mode 100644 index 5493cbd..0000000 --- a/install/update/old/adm/style/acp_icons.html +++ /dev/null @@ -1,282 +0,0 @@ - - - - - - - - - « {L_BACK} - -

{L_TITLE}

- -

{L_EXPLAIN}

- -
- -
- {L_TITLE} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{L_CONFIG}
{L_URL}{L_LOCATION}{L_SMILIES_CODE}{L_SMILIES_EMOTION}{L_WIDTH}{L_HEIGHT}{L_ALT_TEXT}{L_DISPLAY_ON_POSTING}{L_ORDER}{L_ADD} ({L_MARK_ALL})
{items.TEXT_ALT}[{items.IMG}] - - - - -
{L_ADD_SMILEY_CODE}
{L_NO_ICONS}
- -

-   - -

- {S_FORM_TOKEN} -
-
- - - - « {L_BACK} - -

{L_TITLE}

- -

{L_EXPLAIN}

- -
- -
- {L_IMPORT} - - -

{L_NO_PAK_OPTIONS}

- - -
-
-
-
-

{L_CURRENT_EXPLAIN}
-
- -
- - -

- -

- - {S_FORM_TOKEN} -
-
- - - -

{L_TITLE}

- -

{L_EXPLAIN}

- - -
-

{L_NOTIFY}

-

{NOTICE}

-
- - -
- - - -
- - {L_TITLE} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{L_TITLE}{L_CODE}{L_EMOTION}{L_OPTIONS}
{L_NOT_DISPLAYED}
{items.ALT_TEXT}{items.CODE}{items.EMOTION} - - {ICON_MOVE_UP} - - {ICON_MOVE_DOWN} - {ICON_EDIT} {ICON_DELETE} -
{L_ACP_NO_ITEMS}
- -

-     -

- {S_FORM_TOKEN} -
-
- - - - diff --git a/install/update/old/adm/style/acp_language.html b/install/update/old/adm/style/acp_language.html deleted file mode 100644 index 79fef94..0000000 --- a/install/update/old/adm/style/acp_language.html +++ /dev/null @@ -1,116 +0,0 @@ - - - - - - - « {L_BACK} - -

{L_LANGUAGE_PACK_DETAILS}

- -
- -
- {LANG_LOCAL_NAME} -
-
-
-
-
-
-
-
-
-
-
{LANG_ISO}
-
-
-
-
-
- -

- -

- {S_FORM_TOKEN} -
-
- - -

{L_MISSING_FILES}

- -
- {L_MISSING_LANG_FILES} - - » {missing_files.FILE_NAME}
- -
- - - -

{L_MISSING_VARS_EXPLAIN}

- -
- {L_MISSING_LANG_VARIABLES} - -
-
- -
{missing_varfile.variable.VAR_NAME}
- -
- -
- - - -

{L_ACP_LANGUAGE_PACKS}

- -

{L_ACP_LANGUAGE_PACKS_EXPLAIN}

- -
- {L_BROWSE_LANGUAGE_PACKS_DATABASE} -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{L_LANGUAGE_PACK_NAME}{L_LANGUAGE_PACK_LOCALNAME}{L_LANGUAGE_PACK_ISO}{L_LANGUAGE_PACK_USED_BY}{L_OPTIONS}
{L_INSTALLED_LANGUAGE_PACKS}
{lang.ENGLISH_NAME} {lang.TAG}{lang.LOCAL_NAME}{lang.ISO}{lang.USED_BY}{L_DELETE}
{L_UNINSTALLED_LANGUAGE_PACKS}
{notinst.NAME}{notinst.LOCAL_NAME}{notinst.ISO}{L_INSTALL}
- - - - diff --git a/install/update/old/adm/style/acp_main.html b/install/update/old/adm/style/acp_main.html deleted file mode 100644 index 12477a4..0000000 --- a/install/update/old/adm/style/acp_main.html +++ /dev/null @@ -1,312 +0,0 @@ - - - - - - -

{L_PERMISSIONS_TRANSFERRED}

- -

{L_PERMISSIONS_TRANSFERRED_EXPLAIN}

- - - -

{L_WELCOME_PHPBB}

- -

{L_ADMIN_INTRO}

- - -
-

{L_UPDATE_INCOMPLETE} {L_MORE_INFORMATION}

-
- -
-

{L_VERSIONCHECK_FAIL}

-

{VERSIONCHECK_FAIL_REASON}

-

{L_VERSIONCHECK_FORCE_UPDATE} · {L_MORE_INFORMATION}

-
- -
-

{L_VERSION_NOT_UP_TO_DATE_TITLE}

-

{L_VERSIONCHECK_FORCE_UPDATE} · {L_MORE_INFORMATION}

-
- - -
-

{UPGRADE_INSTRUCTIONS}

-
- - - -
-

{L_WARNING}

-

{L_NO_SEARCH_INDEX}

-
- - - -
-

{L_WARNING}

-

{L_REMOVE_INSTALL}

-
- - - - -
-

{L_ERROR_MBSTRING_FUNC_OVERLOAD}

-

{L_ERROR_MBSTRING_FUNC_OVERLOAD_EXPLAIN}

-
- - - -
-

{L_ERROR_MBSTRING_ENCODING_TRANSLATION}

-

{L_ERROR_MBSTRING_ENCODING_TRANSLATION_EXPLAIN}

-
- - - -
-

{L_ERROR_MBSTRING_HTTP_INPUT}

-

{L_ERROR_MBSTRING_HTTP_INPUT_EXPLAIN}

-
- - - -
-

{L_ERROR_MBSTRING_HTTP_OUTPUT}

-

{L_ERROR_MBSTRING_HTTP_OUTPUT_EXPLAIN}

-
- - - - -
-

{L_WRITABLE_CONFIG}

-
- - - -
-

{L_PHP_VERSION_OLD}

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{L_FORUM_STATS}
{L_STATISTIC}{L_VALUE}{L_STATISTIC}{L_VALUE}
{L_NUMBER_POSTS}{L_COLON} {TOTAL_POSTS}{L_POSTS_PER_DAY}{L_COLON} {POSTS_PER_DAY}
{L_NUMBER_TOPICS}{L_COLON} {TOTAL_TOPICS}{L_TOPICS_PER_DAY}{L_COLON} {TOPICS_PER_DAY}
{L_NUMBER_USERS}{L_COLON} {TOTAL_USERS}{L_USERS_PER_DAY}{L_COLON} {USERS_PER_DAY}
{L_NUMBER_FILES}{L_COLON} {TOTAL_FILES}{L_FILES_PER_DAY}{L_COLON} {FILES_PER_DAY}
{L_BOARD_STARTED}{L_COLON} {START_DATE}{L_AVATAR_DIR_SIZE}{L_COLON} {AVATAR_DIR_SIZE}
{L_DATABASE_SIZE}{L_COLON} {DBSIZE}{L_UPLOAD_DIR_SIZE}{L_COLON} {UPLOAD_DIR_SIZE}
{L_DATABASE_SERVER_INFO}{L_COLON} {DATABASE_INFO}{L_GZIP_COMPRESSION}{L_COLON} {GZIP_COMPRESSION}
{L_PHP_VERSION}{L_COLON} {PHP_VERSION_INFO}{L_NUMBER_ORPHAN}{L_COLON} - - {TOTAL_ORPHAN} - - {TOTAL_ORPHAN} - -   
{L_BOARD_VERSION}{L_COLON} - style="color: #228822;" style="color: #BC2A4D;" title="{L_MORE_INFORMATION}">{BOARD_VERSION}{L_VERSIONCHECK_FORCE_UPDATE} ] -   
- - -
- {L_STATISTIC_RESYNC_OPTIONS} - -
-
-

 
-
-
-
- -
-
-

 
-
-
-
- -
-
-

{L_RESYNC_STATS_EXPLAIN}
-
-
-
- -
-
-

{L_RESYNC_POSTCOUNTS_EXPLAIN}
-
-
-
- -
-
-

{L_RESYNC_POST_MARKING_EXPLAIN}
-
-
-
- - -
-
-

{L_PURGE_SESSIONS_EXPLAIN}
-
-
-
- - -
-
-

{L_PURGE_CACHE_EXPLAIN}
-
-
-
- - -
- - - -

{L_ADMIN_LOG}

- -

{L_ADMIN_LOG_INDEX_EXPLAIN}

- - - - - - - - - - - - - - - - - - - - - - -
{L_USERNAME}{L_IP}{L_TIME}{L_ACTION}
{log.USERNAME}{log.IP}{log.DATE}{log.ACTION}
- - - -

{L_INACTIVE_USERS}

- -

{L_INACTIVE_USERS_EXPLAIN_INDEX}

- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{L_USERNAME}{L_JOINED}{L_INACTIVE_DATE}{L_LAST_VISIT}{L_INACTIVE_REASON}
- {inactive.USERNAME_FULL} -
{L_POSTS}{L_COLON} {inactive.POSTS} [{L_SEARCH_USER_POSTS}] -
{inactive.JOINED}{inactive.INACTIVE_DATE}{inactive.LAST_VISIT} - {inactive.REASON} -
{inactive.REMINDED_EXPLAIN} -
{L_NO_INACTIVE_USERS}
- - - - - diff --git a/install/update/old/adm/style/acp_modules.html b/install/update/old/adm/style/acp_modules.html deleted file mode 100644 index 3c97706..0000000 --- a/install/update/old/adm/style/acp_modules.html +++ /dev/null @@ -1,203 +0,0 @@ - - - - - - - - - « {L_BACK} - -

{L_TITLE} :: {MODULENAME}

- -

{L_EDIT_MODULE_EXPLAIN}

- - -
-

{L_WARNING}

-

{ERROR_MSG}

-
- - -
- -
- {L_GENERAL_OPTIONS} -
-

- {L_MODULE_LANGNAME_EXPLAIN}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
style="display: none;"> -
-

{L_MODULE_DISPLAYED_EXPLAIN}
-
-
-
-
-

- {L_CHOOSE_MODULE_EXPLAIN}
-
-
-
-

- {L_CHOOSE_MODE_EXPLAIN}
-
-
-
- -

- - - -   - -

- {S_FORM_TOKEN} -
-
- - - -

{L_ACP_MODULE_MANAGEMENT}

- -

{L_ACP_MODULE_MANAGEMENT_EXPLAIN}

- - -
-

{L_WARNING}

-

{ERROR_MSG}

-
- - - - - - - - -
{NAVIGATION} [{L_EDIT} | {L_DELETE} | {L_DISABLE}{L_ENABLE}]
- - - - - - - - - - - - - - -
{modules.MODULE_IMAGE}{modules.MODULE_TITLE} [{L_HIDDEN_MODULE}] {L_DISABLE}{L_ENABLE}  - - {ICON_MOVE_UP} - - {ICON_MOVE_DOWN} - {ICON_EDIT} - {ICON_DELETE} -
- - -
 
- -
- -
- - - - -
- -
- -
- -
- - - - - -
- -
- -
 

- -
-
- {L_SELECT_MODULE}{L_COLON} - - -
-
- - - - diff --git a/install/update/old/adm/style/acp_permission_roles.html b/install/update/old/adm/style/acp_permission_roles.html deleted file mode 100644 index b3137f1..0000000 --- a/install/update/old/adm/style/acp_permission_roles.html +++ /dev/null @@ -1,191 +0,0 @@ - - - - - - - - - - - « {L_BACK} - -

{L_TITLE}

- -

{L_EXPLAIN}

- -
- » {L_SET_ROLE_PERMISSIONS} - -
- -
- {L_ROLE_DETAILS} -
-
-
-
-
-

{L_ROLE_DESCRIPTION_EXPLAIN}
-
-
- -

- - {S_FORM_TOKEN} -

-
- - - -

{L_ROLE_ASSIGNED_TO}

- - - - - -

- - - - » {L_BACK_TO_TOP}
-

- -

- -

{L_ACL_TYPE}

- -
- -
-
- -
- -
style="display: none;"> -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
{L_ACL_SETTING}{L_ACL_YES}{L_ACL_NO}{L_ACL_NEVER}
{auth.mask.PERMISSION}
-
-
- -
- -
- -
- - {S_FORM_TOKEN} -
-
- - » {L_BACK_TO_TOP}
-
- - - -

{L_TITLE}

- -

{L_EXPLAIN}

- -
- - - - - - - - - - - - - - - - - - -
{L_ROLE_NAME}{L_OPTIONS}
{roles.ROLE_NAME} -
{roles.ROLE_DESCRIPTION} -
{L_VIEW_ASSIGNED_ITEMS}{L_VIEW_ASSIGNED_ITEMS} - - {ICON_MOVE_UP} - - {ICON_MOVE_DOWN} - {ICON_EDIT} - {ICON_DELETE} -
- -
- {L_CREATE_ROLE}{L_COLON}
- {S_FORM_TOKEN} -
-
- - - - - -

{L_ROLE_ASSIGNED_TO}

- - - - - - - - diff --git a/install/update/old/adm/style/acp_posting_buttons.html b/install/update/old/adm/style/acp_posting_buttons.html deleted file mode 100644 index c3c42f8..0000000 --- a/install/update/old/adm/style/acp_posting_buttons.html +++ /dev/null @@ -1,71 +0,0 @@ - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
- diff --git a/install/update/old/adm/style/acp_ranks.html b/install/update/old/adm/style/acp_ranks.html deleted file mode 100644 index e67c9ac..0000000 --- a/install/update/old/adm/style/acp_ranks.html +++ /dev/null @@ -1,107 +0,0 @@ - - - - - - - « {L_BACK} - - - -

{L_ACP_MANAGE_RANKS}

- -

{L_ACP_RANKS_EXPLAIN}

- -
- -
- {L_ACP_RANKS} - - - -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
style="display: none;"> -
-
-
-
-
- - - -

- - -   - - {S_FORM_TOKEN} -

-
-
- - - -

{L_ACP_MANAGE_RANKS}

- -

{L_ACP_RANKS_EXPLAIN}

- -
-
- {L_ACP_MANAGE_RANKS} - - - - - - - - - - - - - - - - - - - - - - - - -
{L_RANK_IMAGE}{L_RANK_TITLE}{L_RANK_MINIMUM}{L_ACTION}
{ranks.RANK_TITLE}  -  {ranks.RANK_TITLE}  -  {ranks.MIN_POSTS}{ICON_EDIT} {ICON_DELETE}
- -

- - {S_FORM_TOKEN} -

-
-
- - - - diff --git a/install/update/old/adm/style/acp_search.html b/install/update/old/adm/style/acp_search.html deleted file mode 100644 index f7ad3c5..0000000 --- a/install/update/old/adm/style/acp_search.html +++ /dev/null @@ -1,159 +0,0 @@ - - - - - -

{L_ACP_SEARCH_SETTINGS}

- -

{L_ACP_SEARCH_SETTINGS_EXPLAIN}

- - - - - - - -

{L_ACP_SEARCH_INDEX}

- - -

{L_CONTINUE_EXPLAIN}

- -
-
- {L_SUBMIT} -   - - {S_FORM_TOKEN} -
-
- - -

{L_ACP_SEARCH_INDEX_EXPLAIN}

- - - - - -
- -
- - {backend.S_HIDDEN_FIELDS} - - {L_INDEX_STATS}{L_COLON} {backend.L_NAME} ({L_ACTIVE}) - - - - - - - - - - - - - - - - - - - - - - -
{backend.L_NAME} ({L_ACTIVE})
{L_STATISTIC}{L_VALUE}{L_STATISTIC}{L_VALUE}
{backend.data.STATISTIC_1}{L_COLON}{backend.data.VALUE_1}{backend.data.STATISTIC_2}{L_COLON}{backend.data.VALUE_2}
- - - -

- - - - - - - -

- {S_FORM_TOKEN} -
- -
- - - - - - - diff --git a/install/update/old/adm/style/acp_styles.html b/install/update/old/adm/style/acp_styles.html deleted file mode 100644 index 38bec5a..0000000 --- a/install/update/old/adm/style/acp_styles.html +++ /dev/null @@ -1,176 +0,0 @@ - - - - - - « {L_BACK} - - - -
- -
-

{MESSAGE_TITLE}

-

{MESSAGE_TEXT}

- - - - - {S_HIDDEN_FIELDS} - -
-   - -
- -
- -
- - -

{L_TITLE}

- -

{L_EXPLAIN}

- -
- {L_BROWSE_STYLES_DATABASE} -
- -
-{S_HIDDEN_FIELDS} -{S_FORM_TOKEN} - - - -
-
-
-
-
-
-
-
{STYLE_PATH}
-
-
-
-
{STYLE_VERSION}
-
-
-
-
{STYLE_COPYRIGHT}
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
- -
- -
- {L_SUBMIT} -   - - {S_FORM_TOKEN} -
- - - - - - - - - - - - {STYLES_LIST_EXTRA} - - - - - - - - - - - - - - - - - - {styles_list.EXTRA} - - - - -
{L_STYLE_NAME}{L_STYLE_PHPBB_VERSION}{L_STYLE_USED_BY}{L_ACTIONS} 
- - - - - {styles_list.STYLE_NAME} -
{styles_list.STYLE_COPYRIGHT}
- - {styles_list.STYLE_NAME} - - -
{styles_list.COMMENT}
- - -
{L_STYLE_PATH}{L_COLON} {styles_list.STYLE_PATH_FULL}
- -
{styles_list.STYLE_PHPBB_VERSION}{styles_list.USERS} - - | - - {styles_list.actions.L_ACTION} - - {styles_list.actions.HTML} - - - - - - -   - - - - -
- - - -
- - - -
- - -
- - - - diff --git a/install/update/old/adm/style/acp_users_overview.html b/install/update/old/adm/style/acp_users_overview.html deleted file mode 100644 index 506101c..0000000 --- a/install/update/old/adm/style/acp_users_overview.html +++ /dev/null @@ -1,169 +0,0 @@ -
- -
- {L_ACP_USER_OVERVIEW} -
-

{L_NAME_CHARS_EXPLAIN}
-
-
[ {L_USE_PERMISSIONS} ]
-
- -
-
-
{USER_INACTIVE_REASON}
-
- -
-
-
{USER_REGISTERED}
-
- -
-
-
{REGISTERED_IP}
-
[ {L_WHOIS} ]
-
- -
-
-
{USER_LASTACTIVE}
-
-
-
-
- - - {USER_POSTS} - - {USER_POSTS} - - - - ({L_POSTS_IN_QUEUE}) - - ({L_POSTS_IN_QUEUE}) - -
-
-
-
-
{USER_WARNINGS}
-
-
-

{L_FOUNDER_EXPLAIN}
-
-
-
-
-
-
-
-
-

{L_CHANGE_PASSWORD_EXPLAIN}
-
-
-
-

{L_CONFIRM_PASSWORD_EXPLAIN}
-
-
- - -

- - - {S_FORM_TOKEN} -

- -
-
- - - - - -
- -
- {L_USER_TOOLS} -
-
-
-
- - -

- - {S_FORM_TOKEN} -

- -
- -
- - -
-
- {L_DELETE_USER} -
-

{L_DELETE_USER_EXPLAIN}
-
- - - - {L_USER_NO_POSTS_TO_DELETE} - -
-
-

- - - {S_FORM_TOKEN} -

-
-
- - diff --git a/install/update/old/adm/style/acp_users_prefs.html b/install/update/old/adm/style/acp_users_prefs.html deleted file mode 100644 index 484c5b3..0000000 --- a/install/update/old/adm/style/acp_users_prefs.html +++ /dev/null @@ -1,151 +0,0 @@ - - -
- -
- {L_UCP_PREFS_PERSONAL} - -
-
-
-
-
-
-
-
-
-
-
-

{L_ALLOW_PM_EXPLAIN}
-
-
-
-
-
-
-
-
-
-

{L_NOTIFY_METHOD_EXPLAIN}
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-

{L_BOARD_DATE_FORMAT_EXPLAIN}
-
-
style="display:none;">
-
- -
- -
- {L_UCP_PREFS_POST} - -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
- -
- {L_UCP_PREFS_VIEW} - -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
{S_TOPIC_SORT_DAYS}
-
-
-
-
{S_TOPIC_SORT_KEY}
-
-
-
-
{S_TOPIC_SORT_DIR}
-
-
-
-
{S_POST_SORT_DAYS}
-
-
-
-
{S_POST_SORT_KEY}
-
-
-
-
{S_POST_SORT_DIR}
-
- -
- -
- - {S_FORM_TOKEN} -
- -
diff --git a/install/update/old/adm/style/acp_users_signature.html b/install/update/old/adm/style/acp_users_signature.html deleted file mode 100644 index c7ec5cc..0000000 --- a/install/update/old/adm/style/acp_users_signature.html +++ /dev/null @@ -1,52 +0,0 @@ - - -
- - -
- {L_ADMIN_SIG_PREVIEW} -

{SIGNATURE_PREVIEW}

-
- - -
- {L_SIGNATURE} -

{L_SIGNATURE_EXPLAIN}

- - - -
-
-
-
-
- - - - - - - - - -
-
{L_OPTIONS}{L_COLON} {BBCODE_STATUS} :: {IMG_STATUS} :: {FLASH_STATUS} :: {URL_STATUS} :: {SMILIES_STATUS}
-
-
- -
-   - - {S_FORM_TOKEN} -
-
diff --git a/install/update/old/adm/style/admin.css b/install/update/old/adm/style/admin.css deleted file mode 100644 index 7cf6c22..0000000 --- a/install/update/old/adm/style/admin.css +++ /dev/null @@ -1,2720 +0,0 @@ -/* phpBB 3.2 Admin Style Sheet - ------------------------------------------------------------------------ - Original author: subBlue ( http://www.subblue.com/ ) - Copyright (c) phpBB Limited - - For full copyright and license information, please see - the docs/CREDITS.txt file. - ------------------------------------------------------------------------ -*/ - -/* General markup styles ----------------------------------------- */ -* { - /* Reset browsers default margin, padding and font sizes */ - margin: 0; - padding: 0; - font-size: 100%; -} - -abbr { - text-decoration: none; -} - -body, div, p, th, td, li, dd { - font-size: x-small; - voice-family: "\"}\""; - voice-family: inherit; - font-size: small; -} - -html>body, html>div, html>p, html>th, html>td, html>li, html>dd { - font-size: small; -} - -html { - color: #536482; - background: #DBD7D1; - /* Always show a scrollbar for short pages - stops the jump when the scrollbar appears. non-ie browsers */ - height: 100%; - margin-bottom: 1px; - word-wrap: break-word; -} - -body { - /* Text-Sizing with ems: http://www.clagnut.com/blog/348/ */ - font-family: "Lucida Grande", Verdana, Helvetica, Arial, sans-serif; - color: #536482; - background: #DBD7D1; - font-size: 62.5%; /* This sets the default font size to be equivalent to 10px */ - margin: 10px 15px; -} - -code, samp { - font-size: 1.2em; -} - -img { - border: 0; -} - -h1 { - font-family: "Trebuchet MS", Helvetica, sans-serif; - font-size: 1.70em; - font-weight: normal; - color: #333333; -} - -h2, caption { - font-family: "Trebuchet MS", Helvetica, sans-serif; - font-size: 1.40em; - font-weight: normal; - color: #115098; - text-align: left; - margin-top: 25px; -} - -.rtl h2, .rtl caption { - text-align: right; -} - -h3, h4 { - font-family: "Trebuchet MS", Helvetica, sans-serif; - font-size: 1.20em; - text-decoration: none; - line-height: 1.20em; - margin-top: 25px; -} - -p { - margin-bottom: 0.7em; - line-height: 1.40em; - font-size: 0.90em; -} - -ul { - list-style: disc; - margin: 0 0 1em 2em; -} - -.rtl ul { - margin: 0 2em 1em 0; -} - -hr { - border: 0 none; - border-top: 1px dashed #999999; - margin-bottom: 5px; - padding-bottom: 5px; - height: 1px; -} - -.centered-text { - text-align: center; -} - -.search-box { - float: left; -} - -.rtl .search-box { - float: right; -} - -.small { - font-size: 0.85em; -} - -.hidden { - display: none; -} - -@media only screen and (max-width: 800px), only screen and (max-device-width: 800px) -{ - body { - margin: 5px 5px 0; - } -} - -@media only screen and (max-width: 700px), only screen and (max-device-width: 700px) -{ - html, body { - height: auto; - margin: 0; - padding: 0; - } -} - - -/* General links */ -a:link, a:visited { - color: #105289; - text-decoration: none; -} - -a:hover { - color: #BC2A4D; - text-decoration: underline; -} - -a:active { - color: #368AD2; - text-decoration: none; -} - -.install-body p a { - font-weight: bold; -} - -a#maincontent, a#acl, a#assigned_to { - display: block; -} - -/* List items */ -ul, ol { - list-style-position: inside; - margin-left: 1em; -} - -li { - display: list-item; - list-style-type: inherit; -} - - -/* Main blocks ----------------------------------------- */ -#wrap { - padding: 0 0 15px 0; - min-width: 615px; -} - -#page-header { - text-align: right; - background: url("../images/phpbb_logo.png") top left no-repeat; - height: 54px; - font-size: 0.85em; - margin-bottom: 10px; -} - -.rtl #page-header { - text-align: left; - background: url("../images/phpbb_logo.png") top right no-repeat; -} - -#page-header h1 { - color: #767676; - font-family: "Trebuchet MS",Helvetica,sans-serif; - font-size: 1.70em; - padding-top: 10px; -} - -#page-header p { - font-size: 1.00em; -} - -#page-header p#skip { - display: none; -} - -#page-body { - min-width: 650px; -} - -.copyright { - font-size: 0.75em; - text-align: center; -} - -#content { - padding: 30px 10px 10px; - position: relative; -} - -#content h1 { - color: #115098; - line-height: 1.2em; - margin-bottom: 0; -} - -#main { - float: right; - width: 100%; - margin: 0 0 0 -210px; -} - -.rtl #main { - float: left; - margin: 0 -210px 0 0; -} - -.main { - margin-left: 210px; -} - -.rtl .main { - margin-left: 0; - margin-right: 210px; -} - -#page-body.simple-page-body { - padding: 0; - padding-right: 10px; - min-width: 0; -} - -@media only screen and (max-width: 700px), only screen and (max-device-width: 700px) -{ - #wrap, #page-body, #page-body.simple-page-body { - padding: 0; - min-width: 300px; - } - - #page-header { - margin: 5px; - padding-left: 160px; - height: auto; - min-height: 54px; - overflow: hidden; - } - - .rtl #page-header { - padding-right: 160px; - padding-left: 0; - } - - #page-header h1 { - font-size: 1.2em; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - } - - #page-header fieldset { - margin-top: 5px; - } - - #main, .rtl #main, .main, .rtl .main { - float: none; - width: auto; - margin: 0; - } - - #content { - background: #F3F3F3 url("../images/innerbox_bg.gif") repeat-x top; - padding: 5px; - } - - #page-footer { - padding: 0 5px 5px; - } -} - -@media only screen and (max-width: 400px), only screen and (max-device-width: 400px) -{ - #page-header { - background-size: 76px 26.5px; - padding-left: 80px; - min-height: 30px; - } - - .rtl #page-header { - padding-right: 80px; - } - - #page-header h1 { - padding-top: 0; - font-size: 1.1em; - } -} - - -/* Tabbed menu -----------------------------------------*/ -#tabs { - font-family: Arial, Helvetica, sans-serif; - line-height: normal; - margin: 0 7px; - position: relative; - z-index: 2; -} - -#tabs > ul { - list-style: none; - margin: 0; - padding: 0; -} - -#tabs .tab { - display: inline-block; - float: left; - font-size: 0.85em; - font-weight: bold; - line-height: 14px; -} - -.rtl #tabs .tab { - float: right; -} - -#tabs .tab > a { - background: #D4D6DA; - background: -moz-linear-gradient(top, #CACBCF 0%, #D4D6DA 100%); - background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #CACBCF), color-stop(100%, #D4D6DA)); - background: -webkit-linear-gradient(top, #CACBCF 0%, #D4D6DA 100%); - background: -o-linear-gradient(top, #CACBCF 0%, #D4D6DA 100%); - background: -ms-linear-gradient(top, #CACBCF 0%, #D4D6DA 100%); - background: linear-gradient(to bottom, #CACBCF 0%, #D4D6DA 100%); - border: 1px solid #BBB; - border-bottom-width: 0; - border-radius: 5px 5px 0 0; - color: #767676; - display: block; - font-weight: bold; - margin: 1px 1px 2px 0; - padding: 6px 9px 4px; - position: relative; - text-decoration: none; - text-transform: uppercase; - white-space: nowrap; - cursor: pointer; -} - -#tabs .tab > a:hover { - background: #F1F1EE; - border-color: #C0BFBB; - color: #BC2A4D; -} - -#tabs .activetab > a, -#tabs .activetab > a:hover { - background: #DCDEE2; - background: -moz-linear-gradient(top, #F2F2F2 0%, #DCDEE2 100%); - background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #F2F2F2), color-stop(100%, #DCDEE2)); - background: -webkit-linear-gradient(top, #F2F2F2 0%, #DCDEE2 100%); - background: -o-linear-gradient(top, #F2F2F2 0%, #DCDEE2 100%); - background: -ms-linear-gradient(top, #F2F2F2 0%, #DCDEE2 100%); - background: linear-gradient(to bottom, #F2F2F2 0%, #DCDEE2 100%); - border-color: #999; - border-bottom: 2px solid #DCDEE2; - box-shadow: 0 1px 1px #FFF inset; - color: #23649F; - margin: 0 1px 0 0; - padding: 7px 10px 4px; -} - -#tabs .activetab > a:hover { - color: #115098; -} - -/* Responsive tabs -----------------------------------------*/ -.responsive-tab { - position: relative; -} - -.responsive-tab > a.responsive-tab-link { - display: block; - font-size: 16px; - position: relative; - width: 16px; - line-height: 14px; - text-decoration: none; - padding-left: 9px !important; - padding-right: 9px !important; -} - -.responsive-tab .responsive-tab-link:before { - content: ''; - position: absolute; - left: 10px; - top: 7px; - height: .125em; - width: 14px; - border-bottom: 0.125em solid #767676; - border-top: 0.375em double #767676; -} - -.responsive-tab .responsive-tab-link:hover:before { - border-color: #BC2A4D; -} - -.responsive-tab.activetab .responsive-tab-link:before { - border-color: #23649F; -} - -.responsive-tab.activetab .responsive-tab-link:hover:before { - border-color: #115098; -} - -#tabs .dropdown, #minitabs .dropdown { - top: 20px; - margin-right: -2px; - font-weight: normal; -} - -#tabs .dropdown-right .dropdown { - margin-left: -2px; -} - -#tabs .dropdown-contents { - list-style: none; - margin: 0; -} - -#tabs .dropdown li { - border-bottom: 1px dotted #DCDCDC; -} - -#tabs .dropdown li:last-child { - border-bottom: none; -} - -#tabs .dropdown a { - display: block; - padding: 4px 8px; - text-align: right; -} - -/* Main Panel ----------------------------------------- */ -#acp { - position: relative; - top: -2px; - margin: 0 0 2px; - padding: 3px 1px; - min-width: 550px; - background: #F3F3F3 url("../images/innerbox_bg.gif") repeat-x top; - border: 1px #999999 solid; - border-radius: 5px; - box-shadow: #FFF 0 0 0 1px inset; -} - -#acp:first-child { - top: 0; -} - -.panel { - background: #F3F3F3 url("../images/innerbox_bg.gif") repeat-x top; - padding: 5px 0; - border-radius: 5px; - overflow: hidden; -} - -@media only screen and (max-width: 700px), only screen and (max-device-width: 700px) -{ - #acp { - min-width: 0; - min-height: 0; - border-radius: 0; - border-width: 1px 0; - background: #fff; - padding: 1px 0; - box-shadow: none; - } -} - -/* Sub-navigation Menu ----------------------------------------- */ - -/* Menu */ -#menu { - float: left; - width: 200px; - font-size: 1.00em; - padding: 0; - border-right: 1px solid #CCCFD3; - position: relative; -} - -.rtl #menu { - float: right; - border: none; - border-left: 1px solid #CCCFD3; -} - -#menu p { - font-size: 0.85em; -} - -#menu ul { - list-style: none; - margin: 0; - padding: 0; - word-wrap: normal; -} - -/* Default list state */ -#menu li, #menu .header { - padding: 0; - margin: 0; - font-size: 0.85em; - font-weight: bold; - display: block; -} - -/* Link styles for the sub-section links */ -#menu li span { - display: block; - padding: 3px 3px 3px 8px; - margin: 1px 0; - text-decoration: none; - font-weight: normal; - color: #138ECB; -} - -.rtl #menu li span { - padding: 3px 8px 3px 3px; -} - -#menu li a:hover, #menu li a:hover span { - text-decoration: none; - background-color: #FFFFFF; - color: #BC2A4D; -} - -#menu li a:active, #menu li a:active span { - color: #F632A0; -} - -#menu li#activemenu a span { - text-decoration: none; - font-weight: bold; - color: #1180B7; - background: transparent url("../images/arrow_right.gif") 0% 50% no-repeat; -} - -.rtl #menu li#activemenu a span { - background: transparent url("../images/arrow_left.gif") 100% 50% no-repeat; -} - -#menu li#activemenu a:hover span, #menu li#activemenu span { - text-decoration: none; - font-weight: bold; - color: #BC2A4D; - background: #FFFFFF url("../images/arrow_right.gif") 1% 50% no-repeat; -} - -.rtl #menu li#activemenu a:hover span, .rtl #menu li#activemenu span { - background: #FFFFFF url("../images/arrow_left.gif") 99% 50% no-repeat; -} - -#menu li a:active, #menu li a:active span, #menu li#activemenu a:active span { - color: #F632A0; -} - -#menu li span.completed { - text-decoration: none; - padding: 3px 3px 3px 12px; - background: url("../images/arrow_down.gif") 1% 50% no-repeat; -} - -.rtl #menu li span.completed { - text-decoration: none; - padding: 3px 12px 3px 3px; - background: url("../images/arrow_down.gif") 99% 50% no-repeat; -} - -#menu .header { - font-family: Tahoma, Helvetica, sans-serif; - display: block; - font-weight: bold; - color: #115098; - border-bottom: 1px solid #327AA5; - padding: 4px 0 2px; - margin-top: 15px; - text-transform: uppercase; - font-size: 0.75em; - text-decoration: none; - cursor: inherit; - outline-style: none; -} - -@media only screen and (max-width: 700px), only screen and (max-device-width: 700px) -{ - #menu, .rtl #menu { - float: none; - width: auto; - border-width: 0; - max-width: 200px; - margin: 0 auto 10px; - } - - #menu p { - text-align: center; - } - - #menu .menu-block.active { - margin: 0 -5px; - padding: 0 5px 3px; - background: rgba(255, 255, 255, .5); - border-radius: 5px; - } - - #menu .menu-block.no-header.active { - padding-top: 3px; - } - - #menu .menu-block .header { - margin-top: 5px; - cursor: pointer; - border-bottom-width: 0; - position: relative; - text-decoration: underline; - } - - #menu .menu-block .header:focus, #menu .menu-block.active .header { - color: #D31141; - text-decoration: none; - } - - #menu .menu-block ul { - display: none; - } - - .nojs #menu .menu-block:hover ul, #menu .menu-block.active ul, #menu .menu-block.no-header ul { - display: block; - } - - #menu .menu-block li:last-child { - border-bottom: 1px solid #327AA5; - } - - #menu .menu-block:last-child li:last-child, #menu .menu-block.active li:last-child { - border-bottom-width: 0; - } - - #menu .menu-block li a span { - border-radius: 2px; - } -} - - -/* Table styles ----------------------------------------- */ - -table { - width: 100%; - border: 1px solid #CCCFD3; - background-color: #FFFFFF; - padding: 1px; -} - -th { - padding: 3px 4px; - color: #FFFFFF; - background: #70AED3 url("../images/gradient2b.gif") bottom left repeat-x; - border-top: 1px solid #6DACD2; - border-bottom: 1px solid #327AA5; - text-align: left; - font-size: 0.75em; - text-transform: uppercase; -} - -td { - text-align: left; - font-size: 0.85em; - padding: 4px; - line-height: 1.20em; -} - -.rtl th, .rtl td { - text-align: right; -} - -.table1 { - border-collapse: separate; - border-spacing: 1px; - clear: both; -} - -dt#color_palette_placeholder table { - margin-right: 5px; - width: 80px; -} - -#color_palette_placeholder td { - padding: 0; -} - -table.type2 { - border: none; - background: none; - padding: 0; -} - -table.type2 th { - background: none; - border-top: none; - text-align: center; - color: #115098; - padding: 2px 0; -} - -table.type2 td { - padding: 0; - font-size: 1em; -} - -table.type2 td.name { - padding: 2px; - vertical-align: middle; -} - -table.type3 { - float: right; - width: 300px; - border: none; - background-color: transparent; - padding: 0; -} - -.rtl table.type3 { - float: left; -} - -table.type3 thead th { - background-color: transparent; - border-top: none; - text-align: center; - color: #115098; - padding: 0 3px; - font-size: 0.85em; - font-weight: normal; - text-transform: none; -} - -table.type3 tbody th { - border-top: none; - text-align: left; - text-transform: none; - padding: 0; - border: none; - font-size: 0.90em; - font-weight: normal; - width: 100%; -} - -.rtl table.type3 tbody th { - text-align: right; -} - -table.type3 td { - text-align: center; - padding: 1px; -} - -th.name { - text-align: left; - width: auto; -} - -.rtl th.name { - text-align: right; -} - -td.name { - text-align: left; - font-weight: bold; -} - -.rtl td.name { - text-align: right; -} - -.entry { - text-align: left; - font-weight: normal; -} - -.rtl .entry { - text-align: right; -} - -.row1 { - background-color: #F9F9F9; -} - -table.zebra-table tbody tr:nth-child(odd) { - background-color: #F9F9F9; -} - -.row2 { - word-break: break-all; - background-color: #DCEBFE; -} - -table.zebra-table tbody tr:nth-child(even) { - background-color: #DCEBFE; -} - -.row3 { background-color: #DBDFE2; } -.row4 { background-color: #E4E8EB; } -.col1 { background-color: #DCEBFE; } -.col2 { background-color: #F9F9F9; } - -/* 4 row background colours for trees */ -.row1a { background-color: #F9F9F9; } -.row1b { background-color: #F6F6F6; } -.row2a { background-color: #E7EEF4; } -.row2b { background-color: #E3EBF2; } - -tr.row-highlight:hover td { background-color: #DBDFE2; } - -.spacer { - background-color: #DBDFE2; - height: 1px; - line-height: 1px; -} - -/* Deactivated row */ -.row-inactive { - color: #999; -} -.row-inactive a, .row-inactive strong { - color: #888; -} -.row-inactive a:hover { - color: #BC2A4D; -} - -/* Specific tables */ -table.forums td.folder { - width: 27px; - text-align: center; -} - -table td.actions { - vertical-align: middle; - width: 100px; - text-align: center; - white-space: nowrap; -} - -table tr:first-child td.actions .up, table tr:last-child td.actions .down { - display: none; -} - -table tr:first-child td.actions .up-disabled, table tr:last-child td.actions .down-disabled { - display: inline !important; -} - -table.styles td.users, table td.mark { - text-align: center; -} - -table.fixed-width-table { - table-layout: fixed; - word-break: break-word; -} - -@media only screen and (max-width: 700px), only screen and (max-device-width: 700px) -{ - table.responsive, table.responsive tbody, table.responsive tr, table.responsive td { - display: block; - } - - table.responsive thead, table.responsive th, table.responsive colgroup { - display: none; - } - - table.responsive.show-header thead, table.responsive.show-header th:first-child, table.responsive caption { - display: block; - width: auto !important; - text-align: left !important; - margin: 0; - } - - table.responsive { - background: transparent none; - border-width: 0; - padding: 0; - } - - table.responsive caption { - padding: 3px 4px; - color: #FFFFFF; - background: #70AED3 url("../images/gradient2b.gif") bottom left repeat-x; - border-top: 1px solid #6DACD2; - border-bottom: 1px solid #327AA5; - text-align: left; - font-size: 0.75em; - font-weight: bold; - text-transform: uppercase; - } - - table.responsive.show-header th:first-child span.rank-img, table.responsive.no-caption caption, table.responsive.no-header thead { - display: none; - } - - table.responsive tr { - margin: 2px 0; - border: 1px solid #CCCFD3; - background-color: #FFFFFF; - padding: 1px 1px 0; - overflow: hidden; - } - - table.responsive tr.row1 td { background-color: #F9F9F9; } - table.responsive tr.row2 td { background-color: #DCEBFE; } - table.responsive tr.row3 td { background-color: #DBDFE2; } - table.responsive tr.row4 td { background-color: #E4E8EB; } - table.responsive tr.col1 td { background-color: #DCEBFE; } - table.responsive tr.col2 td { background-color: #F9F9F9; } - table.responsive tr.row1a td { background-color: #F9F9F9; } - table.responsive tr.row1b td { background-color: #F6F6F6; } - table.responsive tr.row2a td { background-color: #E7EEF4; } - table.responsive tr.row2b td { background-color: #E3EBF2; } - - table.responsive td { - width: auto !important; - text-align: left !important; - padding: 4px; - margin-bottom: 1px; - } - - .rtl table.responsive td { - text-align: right !important; - } - - table.responsive td.empty { - display: none !important; - } - - table.responsive td > dfn { - display: inline-block !important; - } - - table.responsive td > dfn:after { - content: ':'; - padding-right: 5px; - } - - table.responsive.two-columns td { - width: 50% !important; - float: left; - -moz-box-sizing: border-box; - box-sizing: border-box; - } - - .rtl table.responsive.two-columns td { - float: right; - } - - table.responsive.two-columns td:nth-child(2n+1) { - clear: left; - } - - table.responsive span.rank-img { - float: none; - padding-right: 5px; - } - - table.responsive#memberlist td:first-child input[type="checkbox"] { - float: right; - } - - /* Specific tables */ - table.responsive.forums td.folder { - float: left; - width: 27px; - background: transparent; - } - .rtl table.responsive.forums td.folder { - float: right; - } - - table.responsive.forums td.forum-desc { - margin-left: 35px; - min-height: 27px; - background: transparent; - } - - .rtl table.responsive.forums td.forum-desc { - margin-left: 0; - margin-right: 35px; - } - - table.responsive td.actions { - clear: both; - text-align: right !important; - } - - .rtl table.responsive td.actions { - text-align: left !important; - } - - table.responsive.styles tr.responsive-style-row td:first-child { - padding-left: 4px !important; - padding-right: 4px !important; - } - - table.responsive.styles td:first-child > dfn, table.responsive td.actions > dfn { - display: none !important; - } - - .horizontal-palette td:nth-child(2n), .vertical-palette tr:nth-child(2n) { - display: none; - } - - .colour-palette a { - display: inline-block !important; - } -} - -/* General form styles -----------------------------------------*/ -fieldset { - margin: 15px 0; - padding: 10px; - border-top: 1px solid #D7D7D7; - border-right: 1px solid #CCCCCC; - border-bottom: 1px solid #CCCCCC; - border-left: 1px solid #D7D7D7; - background-color: #FFFFFF; - position: relative; - border-radius: 3px; -} - -fieldset h2 { - margin-top: 0; -} - -.rtl fieldset { - border-top: 1px solid #D7D7D7; - border-right: 1px solid #D7D7D7; - border-bottom: 1px solid #CCCCCC; - border-left: 1px solid #CCCCCC; -} - -fieldset p { - font-size: 0.85em; -} - -legend { - padding: 1px 0; - font-family: Tahoma,arial,Verdana,Sans-serif; - font-size: .9em; - font-weight: bold; - color: #115098; - margin-top: -.4em; - position: relative; - text-transform: none; - line-height: 1.2em; - top: -.2em; - vertical-align: middle; -} - -input, textarea { - font-family: Verdana, Helvetica, Arial, sans-serif; - font-size: 0.90em; - font-weight: normal; - vertical-align: middle; - padding: 2px; - color: #111111; - border-left: 1px solid #AFAEAA; - border-top: 1px solid #AFAEAA; - border-right: 1px solid #D5D5C8; - border-bottom: 1px solid #D5D5C8; - background-color: #E3DFD8; -} - -.rtl input, .rtl textarea { - border-left: 1px solid #D5D5C8; - border-top: 1px solid #AFAEAA; - border-right: 1px solid #AFAEAA; - border-bottom: 1px solid #D5D5C8; -} - -input:hover, textarea:hover { - border-left: 1px solid #AFAEAA; - border-top: 1px solid #AFAEAA; - border-right: 1px solid #AFAEAA; - border-bottom: 1px solid #AFAEAA; - background-color: #E9E9E2; -} - -input.langvalue, textarea.langvalue { - width: 90%; -} - -input[type="number"] { - width: 60px; - -moz-padding-end: 0; -} - -optgroup, select { - background-color: #FAFAFA; - border: 1px solid #666666; - font-family: Verdana, Helvetica, Arial, sans-serif; - font-size: 0.85em; - font-weight: normal; - font-style: normal; - cursor: pointer; - padding: 1px; - vertical-align: middle; - width: auto; - color: #000; -} - -select:focus { - outline-style: none; -} - -optgroup { - font-size: 1.00em; - font-weight: bold; -} - -optgroup.disabled-options { - display: none; - background-color: gray; -} - -option { - padding: 0 1em 0 0; - color: #000; -} - -option.disabled-option { - color: graytext; -} - -.rtl option { - padding: 0 0 0 1em; -} - -.sep { - font-weight: bold; -} - -.username-coloured { - font-weight: bold; -} - -textarea { - font-family: Verdana, Helvetica, Arial, sans-serif; - font-size: 0.85em; - width: 60%; - padding: 2px; -} - -label { - cursor: pointer; - font-size: 0.85em; - padding: 0 5px 0 0; -} - -.rtl label { - padding: 0 0 0 5px; -} - -label input { - font-size: 1.00em; - vertical-align: middle; -} - -label img { - vertical-align: middle; -} - -fieldset.quick, p.quick { - margin: 0 0 5px; - padding: 5px 0 0; - border: none; - background-color: transparent; - text-align: right; -} - -.rtl fieldset.quick, .rtl p.quick { - text-align: left; -} - -fieldset.quick legend { - display: none; -} - -fieldset.tabulated { - background: none; - margin: 0; - margin-top: 5px; - padding: 0; - border: 0; -} - -fieldset.tabulated legend { - display: none; -} - -fieldset.nobg { - margin: 15px 0 0 0; - padding: 0; - border: none; - background-color: transparent; -} - -fieldset.display-options { - margin: 15px 0 2px 0; - padding: 0 0 4px 0; - border: none; - background-color: transparent; - text-align: center; - font-size: 0.85em; -} - -fieldset.display-options select, fieldset.display-options input, fieldset.display-options label { - font-size: 1.00em; - vertical-align: middle; -} - -select option.disabled { - background-color: #bbb; - color: #fff; -} - -/* Special case inputs */ -select#board_timezone, -select#full_folder_action { - width: 95%; -} - -@media only screen and (max-width: 700px), only screen and (max-device-width: 700px) -{ - fieldset { - padding: 5px; - } - - fieldset.quick, p.quick { - float: none !important; - text-align: center; - } - - fieldset.display-options { - clear: both; - } -} - -/* Definition list layout for forms - Other general def. list properties defined in prosilver_main.css ----------------------------------------- */ -dl { - font-family: Verdana, Helvetica, Arial, sans-serif; - font-size: 1.00em; -} - -dt { - float: left; - width: auto; -} - -.rtl dt { - float: right; -} - -dd { color: #666666;} -dd + dd { padding-top: 5px;} -dt span { padding: 0 5px 0 0;} -.rtl dt span { padding: 0 0 0 5px;} - -dt .explain { font-style: italic;} - -dt label { - font-size: 1.00em; - text-align: left; - font-weight: bold; - color: #4A5A73; -} - -.rtl dt label { - text-align: right; -} - -dd label { - font-size: 1.00em; - white-space: nowrap; - margin: 0 10px 0 0; - color: #4A5A73; -} - -.rtl dd label { - margin: 0 0 0 10px; -} - -html>body dd label input { vertical-align: text-bottom;} /* Tweak for Moz to align checkboxes/radio buttons nicely */ - -dd input { - font-size: 1.00em; - max-width: 100%; - margin: 2px 0; -} - -dd select { - font-size: 100%; - font-size: 1em; - width: auto; - max-width: 100%; - margin: 2px 0; -} - -dd textarea { - font-size: 0.90em; - width: 90%; -} - -fieldset dl { - margin-bottom: 10px; - font-size: 0.85em; -} - -fieldset dt { - width: 45%; - text-align: left; - border: none; - border-right: 1px solid #CCCCCC; - padding-top: 3px; -} - -.rtl fieldset dt { - text-align: right; - border: none; - border-left: 1px solid #CCCCCC; -} - -fieldset #color_palette_placeholder { - padding-top: 0; -} - -fieldset dd { - margin: 0 0 0 45%; - padding: 0 0 0 5px; - border: none; - border-left: 1px solid #CCCCCC; - vertical-align: top; - font-size: 1.00em; -} - -.rtl fieldset dd { - margin: 0 45% 0 0; - padding: 0 5px 0 0; - border: none; - border-right: 1px solid #CCCCCC; -} - -dd.full, .rtl dd.full { - margin: 0; - border: 0; - padding: 0; - padding-top: 3px; - text-align: center; - width: 95%; -} - -/* Hover highlights for form rows */ -fieldset dl:hover dt, fieldset dl:hover dd { - border-color: #666666; -} - -fieldset dl:hover dt label { - color: #000000; -} - -fieldset dl dd label:hover { - color: #BC2A4D; -} - -input:focus, textarea:focus { - border: 1px solid #BC2A4D; - background-color: #E9E9E2; - color: #BC2A4D; - outline-style: none; -} - -@media only screen and (max-width: 700px), only screen and (max-device-width: 700px) -{ - fieldset dl { - margin-bottom: 5px; - padding-bottom: 5px; - border-bottom: 1px solid #e8e8e8; - } - - fieldset > dl:last-child, fieldset > form:last-child > dl:last-child { - border-bottom-width: 0; - margin-bottom: 0; - } - - fieldset dt, .rtl fieldset dt, fieldset dd, .rtl fieldset dd { - border-width: 0; - margin-left: 0; - margin-right: 0; - float: none; - width: auto; - } - - fieldset .responsive-columns dt { - float: left; - } - - .ltr fieldset dd { - padding-left: 20px; - } - - .rtl fieldset dd { - padding-right: 20px; - } - - select, dd select, dd input { - max-width: 300px; - } - - input[type="number"], dd input[type="number"] { - max-width: 70px; - } -} - -@media only screen and (max-width: 400px), only screen and (max-device-width: 400px) -{ - select, dd select, dd input { - max-width: 240px; - } -} - -/* Submit button fieldset or paragraph ----------------------------------------- */ -fieldset.submit-buttons { - text-align: center; - border: none; - background-color: transparent; - margin: 0; - padding: 4px; - margin-top: -1px; -} - -p.submit-buttons { - text-align: center; - margin: 0; - padding: 4px; - margin-top: 10px; -} - -fieldset.submit-buttons input, p.submit-buttons input { - padding: 3px 2px; -} - -fieldset.submit-buttons legend { - display: none; -} - -@media only screen and (max-width: 700px), only screen and (max-device-width: 700px) -{ - p.submit-buttons { - margin-top: 0; - } -} - -/* Input field styles ----------------------------------------- */ - -input.radio, input.checkbox, input.permissions-checkbox { - width: auto !important; - background-color: transparent; - border: none; - cursor: pointer; -} - -input.full, -textarea.full { - width: 99%; -} - -input.medium { width: 50%;} -input.narrow { width: 25%;} -input.tiny { width: 10%;} -input.autowidth { width: auto !important;} -.box2 .inputbox { background-color: #E9E9E9;} - -/* Form button styles ----------------------------------------- */ -a.button1, input.button1, -a.button2, input.button2 { - width: auto !important; - padding: 1px 3px 0 3px; - font-family: "Lucida Grande", Verdana, Helvetica, Arial, sans-serif; - color: #000; - font-size: 0.85em; - background: #EFEFEF url("../images/bg_button.gif") repeat-x top; - cursor: pointer; -} - -a.button1, input.button1 { - font-weight: bold; - border: 1px solid #666666; -} - -/* Alternative button */ -a.button2, input.button2 { - border: 1px solid #666666; -} - -/* button in the style of the form buttons */ -a.button1, a.button1:link, a.button1:visited, a.button1:active, -a.button2, a.button2:link, a.button2:visited, a.button2:active { - text-decoration: none; - color: #000000; - padding: 4px 8px; -} - -/* Hover states */ -a.button1:hover, input.button1:hover, -a.button2:hover, input.button2:hover { - border: 1px solid #BC2A4D; - background: #EFEFEF url("../images/bg_button.gif") repeat bottom; - color: #BC2A4D; -} - -input.disabled { - font-weight: normal; - color: #666666; -} - -/* Focus states */ -input.button1:focus, input.button2:focus { - outline-style: none; -} - -/* jQuery popups ----------------------------------------- */ -.phpbb_alert { - background-color: #FFFFFF; - border: 1px solid #999999; - position: fixed; - display: none; - top: 150px; - left: 0; - right: 0; - width: 620px; - margin: 0 auto; - z-index: 50; - padding: 25px; - padding: 0 25px 20px 25px; -} - -.phpbb_alert .alert_close { - display: block; - float: right; - width: 16px; - height: 16px; - overflow: hidden; - text-decoration: none !important; - background: transparent url("../images/alert_close.png") 0 0 no-repeat; - margin-top: -7px; - margin-right: -31px; -} -.phpbb_alert .alert_close:hover { - background-position: 0 -16px; -} - - -.phpbb_alert p { - margin: 8px 0; - padding-bottom: 8px; -} - -.phpbb_alert label { - display: block; - margin: 8px 0; - padding-bottom: 8px; -} - -.phpbb_alert div.alert_text > p, -.phpbb_alert div.alert_text > label, -.phpbb_alert div.alert_text > select, -.phpbb_alert div.alert_text > textarea, -.phpbb_alert div.alert_text > input { - font-size: 0.9em; -} - -#darkenwrapper { - display: none; - position: relative; - z-index: 44; -} - -#darken { - position: fixed; - left: 0; - top: 0; - width: 100%; - height: 100%; - background-color: #000000; - opacity: 0.5; - z-index: 45; -} - -@media only screen and (max-height: 500px), only screen and (max-device-width: 500px) -{ - .phpbb_alert { - top: 25px; - } -} - -@media only screen and (max-width: 700px), only screen and (max-device-width: 700px) -{ - .phpbb_alert { - width: auto; - margin: 0 25px; - } -} - -#loading_indicator { - background: #000000 url("../images/loading.gif") center center no-repeat; - border-radius: 5px; - display: none; - opacity: 0.8; - margin-top: -50px; - margin-left: -50px; - height: 50px; - width: 50px; - position: fixed; - left: 50%; - top: 50%; - z-index: 51; -} - -/* Pagination ----------------------------------------- */ -.pagination { - font-size: .85em; - height: 1%; /* IE tweak (holly hack) */ - width: auto; - text-align: right; - margin: 5px 0; -} - -.top-pagination { - float: right; - margin: 15px 0 5px 0; -} - -.rtl .pagination { - text-align: left; - float: left; -} - -li.pagination { - margin-top: 0; -} - -.pagination img { - vertical-align: middle; -} - -.pagination ul { - display: inline-block; - *display: inline; /* IE7 inline-block hack */ - *zoom: 1; - margin-left: 0; - margin-bottom: 0; -} - -li.pagination ul { - margin-top: -2px; - vertical-align: middle; -} - -.pagination ul li, dl .pagination ul li, dl.icon .pagination ul li { - display: inline; - padding: 0; - font-size: 100%; - line-height: normal; -} - -.pagination li a, .pagnation li span, li .pagination li a, li .pagnation li span, .pagination li.active span, .pagination li.ellipsis span { - font-weight: normal; - text-decoration: none; - padding: 0 2px; - border: 1px solid transparent; - font-size: 0.9em; - line-height: 1.5em; -} - -.pagination li a, .pagination li a:link, .pagination li a:visited { - color: #5C758C; - background-color: #ECEDEE; - border-color: #B4BAC0; -} - -.pagination li.ellipsis span { - background-color: transparent; - color: #000000; -} - -.pagination li.active span { - color: #FFFFFF; - background-color: #4692BF; - border-color: #4692BF; -} - -.pagination li a:hover, .pagination .active a:hover { - color: #FFFFFF; - background-color: #368AD2; - border-color: #368AD2; -} - -.pagination li a:active, .pagination li.active a:active { - color: #5C758C; - background-color: #ECEDEE; - border-color: #B4BAC0; -} - -@media only screen and (max-width: 700px), only screen and (max-device-width: 700px) -{ - .pagination, .rtl .pagination { - float: none; - text-align: center; - margin: 5px 0; - } - - .pagination li a, .pagination li span { - display: inline-block; - min-width: 10px; - } -} - -/* Action Highlighting ----------------------------------------- */ -.successbox, .errorbox, .warningbox { - padding: 8px; - margin: 10px 0; - color: #FFFFFF; - text-align: center; - clear: both; -} - -.success { - color: #228822; -} - -.error { - color: #BC2A4D; -} - -.successbox { - background-color: #228822; -} - -.errorbox { - background-color: #BC2A4D; -} - -.warningbox { - background-color: #fca600; -} - -.successbox h3, .errorbox h3 { - color: #FFFFFF; - margin: 0 0 0.5em; - font-size: 1.10em; - font-family: "Lucida Grande",Verdana,Helvetica,Arial,sans-serif; -} - -.successbox p, .errorbox p { - color: #FFFFFF; - font-size: 0.85em; - margin-bottom: 0; -} - -.errorbox a:link, .errorbox a:active, .errorbox a:visited, -.successbox a:link, .successbox a:active, .successbox a:visited { - color: #DBD7D1; - text-decoration: underline; - font-weight: bold; -} - -.errorbox a:hover, .successbox a:hover { - color: #FFFFFF; - text-decoration: none; - font-weight: bold; -} - -#log-container { - display: none; - max-height: 300px; - padding: 8px; - margin: 10px 0; - clear: both; - overflow-y: auto; - background-color: #FFFFFF; -} - -#log-container.show_log_container { - display: block; - border: 1px solid #DBD7D1; -} - -.log { - font-size: 0.8em; -} - -.notice { - background-color: #62A5CC; -} - -.download-box { - margin: 10px 0 10px 0; -} - -/* Special cases for the error page */ -#errorpage #page-header a { - font-weight: bold; - line-height: 6em; -} - -#errorpage #content { - padding-top: 10px; -} - -#errorpage #content h1 { - color: #DF075C; -} - -#errorpage #content h2 { - margin-top: 20px; - margin-bottom: 5px; - border-bottom: 1px solid #CCCCCC; - padding-bottom: 5px; - color: #333333; -} - -/* Tooltip for permission roles */ -.tooltip { - width: 200px; - color: #000; - text-align: center; - border: 1px solid #AAA; -} - -.tooltip span.top { - background: #EFEFEF; - font-weight: bold; - padding: 2px; -} - -.tooltip span.bottom { - padding: 5px; - color: #000000; - background: #FFFFFF; -} - -/* - Format Buttons for signature editor -*/ -#format-buttons { - margin: 15px 0 2px 0; -} - -#format-buttons input, #format-buttons select { - vertical-align: middle; -} - -.row, fieldset dl { - overflow: hidden; -} - -/* Syntax Highlighting ----------------------------------------- */ -.sourcenum { - color: gray; - font-family: Monaco, 'Courier New', monospace; - font-size: 1.25em; - font-weight: bold; - line-height: 1.20em; - text-align: right; - padding: 0; -} - -.rtl .sourcenum { - text-align: left; -} - -.source { - font-family: Monaco, 'Courier New', monospace; - font-size: 1.25em; - line-height: 1.20em; - padding: 0; -} - -.syntaxbg { - color: #FFFFFF; -} - -.syntaxcomment { - color: #FF8000; -} - -.syntaxdefault { - color: #0000BB; -} - -.syntaxhtml { - color: #000000; -} - -.syntaxkeyword { - color: #007700; -} - -.syntaxstring { - color: #DD0000; -} - -/* Permission interface ----------------------------------------- */ - -.column1, .column2 { - width: 48%; - float: left; -} - -.ltr .column2, .rtl .column1 { - float: right; -} - -fieldset.permissions legend { - text-transform: none; -} - -fieldset.permissions legend input{ - height: 1.1em; -} - -/* Permission sections */ -fieldset.permissions .permissions-simple { - text-align: left; - padding-top: 3px; -} - -.rtl fieldset.permissions .permissions-simple { - text-align: right; -} - -fieldset.permissions .permissions-advanced { - padding: 10px 0 0 5px; - vertical-align: top; - clear: right; -} - -.rtl fieldset.permissions .permissions-advanced { - padding: 10px 5px 0 0; - clear: left; -} - -fieldset.permissions .permissions-switch { - float: right; -} - -.rtl fieldset.permissions .permissions-switch { - float: left; -} - -fieldset.permissions .padding { -} - -.permissions-switch { - margin-top: -6px; - font-size: .9em; -} - -.permissions-switch a { - text-decoration: underline; -} - -.permissions-reset { - padding-bottom: 10px; -} - -.permissions-reset a { - font-size: .85em; -} - -/* Tabbed menu */ -.permissions-category { - line-height: normal; - margin: 0 0 -1px 7px; - min-width: 570px; - font-size: 0.85em; -} - -.rtl .permissions-category { - margin: 0 7px -1px 0; -} - -.permissions-category ul { - margin: 0; - padding: 0; - list-style: none; -} - -.permissions-category li { - display: inline; - margin: 0; - padding: 0; - font-size: 1em; - font-weight: bold; -} - -.permissions-category a { - float: left; - background: url("../images/bg_tabs_alt1.gif") no-repeat 0% -35px; - margin: 0 1px 0 0; - padding: 0 0 0 6px; - text-decoration: none; - position: relative; -} - -.rtl .permissions-category a { - float: right; -} - -.permissions-category a span.tabbg { - float: left; - display: block; - background: url("../images/bg_tabs_alt2.gif") no-repeat 100% -35px; - padding: 7px 12px 6px 6px; - color: #536482; - white-space: nowrap; -} - -.rtl .permissions-category a span.tabbg { - float: right; -} - -/* Commented Backslash Hack hides rule from IE5-Mac \*/ -.permissions-category a span.tabbg, .rtl .permissions-category a span.tabbg { float: none;} -/* End hack */ - -.permissions-category a:hover span.tabbg { - color: #DD6900; -} - -.permissions-category .activetab a { - background-position: 0 0; -} - -.permissions-category .activetab a span.tabbg { - background-position: 100% 0; - padding-bottom: 7px; - color: #333333; -} - -.permissions-category a:hover { - background-position: 0 -70px; -} - -.permissions-category a:hover span.tabbg { - background-position: 100% -70px; -} - -.permissions-category .activetab a:hover span.tabbg { - color: #333333; - background-position: 100% 0; -} - -.permissions-category .activetab a:hover { - background-position: 0 0; -} - -.permissions-category a span.colour { - border: 1px solid #536482; - display: block; - float: left; - width: 10px; - height: 10px; - margin: 0 5px 0 0; -} - -/* Most browsers will have to live with a left aligned icon in RTL mode, as (currently) only Firefox 3.0 Alpha 3 renders it correctly without destroying it -.rtl .permissions-category a span.colour { - float: right; - margin: 0 0 0 5px; -} -*/ - -.permissions-category .activetab span.colour { - border-color: #333333; -} - -.permissions-category a:hover span.colour { - border-color: #DD6900; -} - -.permissions-category .activetab a:hover span.colour { - border-color: #333333; -} - -/* Permission preset colours */ -.permissions-preset-yes span.colour, -.yes { - background-color: #86F786; -} - -.permissions-preset-custom span.colour { - background-color: #B2BBDD; -} - -.permissions-preset-never span.colour { - background-color: #DD0000; -} - -.permissions-preset-no span.colour, -.never { - background-color: #EFB0B2; -} - -/* Permission panel ----------------------------------------- */ -.permissions-panel { - float: left; - background-color: #CADCEB; - width: 100%; - border-radius: 5px; - overflow: hidden; - padding: 5px 0; -} - -.rtl .permissions-panel { - float: right; -} - -/* Permission table ----------------------------------------- */ -.permissions-panel .tablewrap { - margin: 0 10px; -} - -.permissions-panel table { - width: 100%; -} - -.permissions-panel th { - text-transform: none; -} - -.permissions-panel th.value { - text-align: center; -} - -.permissions-panel th.name { - text-align: left; - width: auto; - text-transform: none; -} - -.rtl .permissions-panel th.name { - text-align: right; -} - -.permissions-panel th.permissions-name { - border: none; - color: #536482; - font-weight: normal; -} - -.permissions-panel th.permissions-name a.trace { - display: inline; -} - -.permissions-panel th.row3 { - background-image: none; - background-color: #D1D7DC; - color: #536482; - border: none; -} - -.permissions-panel th.row4 { - background-image: none; - background-color: #E4E8EB; - color: #536482; - border: none; -} - -.permissions-panel th a:link, .permissions-panel th a:hover, .permissions-panel th a:visited { - display: block; - color: #FFFFFF; - text-decoration: underline; -} - -.permissions-panel td.permissions-yes label:hover { - background-color: #86F786; -} - -.permissions-panel td.permissions-no label:hover { - background-color: #EFB0B2; -} - -.permissions-panel td.permissions-never label:hover { - background-color: #DD0000; -} - -.permissions-panel td { - padding: 0; - text-align: center; - width: 10%; -} - -.permissions-panel td label { - display: block; - margin: 0; - padding: 0; -} - -@media only screen and (max-width: 700px), only screen and (max-device-width: 700px) -{ - .column1, .column2 { - float: none !important; - width: auto; - } - - .permissions-simple { - clear: both; - } - - .permissions-simple td, .permissions-simple dd { - width: auto !important; - margin-left: 0 !important; - margin-right: 0 !important; - } - - .permissions-simple dd { - margin-top: 5px; - } - - .permissions-panel .tablewrap { - margin: 0 5px; - } - - .permissions-category { - min-width: 0; - margin: 0 !important; - } - - .permissions-category a, .permissions-category a span.tabbg { - display: block; - float: none !important; - background: transparent none; - } - - .permissions-category a { - background: #d9e5ee; - margin: 5px 0; - padding: 0 !important; - border-radius: 3px; - text-decoration: underline; - } - - .permissions-category .activetab a { - background-color: #dd6900; - color: #fff; - } - - .permissions-category a span.tabbg { - color: inherit !important; - padding-top: 6px !important; - padding-bottom: 6px !important; - } - - .permissions-category .activetab span.colour { - border-color: #fff; - } -} - -/* Avatars gallery ----------------------------------------- */ -#gallery { - display: block; - margin: 0 -5px; - padding: 0; - overflow: hidden; -} - -#gallery li { - display: block; - float: left; - border: 1px solid #ccc; - border-radius: 2px; - background: #fff; - padding: 5px; - margin: 5px; -} - -#gallery li:hover { - background-color: #eee; -} - -#gallery li label { - display: block; - text-align: center; - padding: 0; -} - -/* Dropdown menu -----------------------------------------*/ -.dropdown { - position: absolute; - left: 0; - top: 22px; - z-index: 2; - border: 1px solid transparent; - border-radius: 5px; - padding: 9px 0 0; -} - -.dropdown-up .dropdown { - top: auto; - bottom: 18px; - padding: 0 0 9px; -} - -.dropdown-left .dropdown { - left: auto; - right: 0; -} - -.dropdown .pointer, .dropdown .pointer-inner { - position: absolute; - width: 0; - height: 0; - border-top-width: 0; - border-bottom: 10px solid transparent; - border-left: 10px dashed transparent; - border-right: 10px dashed transparent; - -webkit-transform: rotate(360deg); /* better anti-aliasing in webkit */ - display: block; -} - -.dropdown-up .pointer, .dropdown-up .pointer-inner { - border-bottom-width: 0; - border-top: 10px solid transparent; -} - -.dropdown .pointer { - right: auto; - left: 10px; - top: 0; - z-index: 3; -} - -.dropdown-up .pointer { - bottom: 0; - top: auto; -} - -.dropdown-left .dropdown .pointer { - left: auto; - right: 10px; -} - -.dropdown .pointer-inner { - top: auto; - bottom: -11px; - left: -10px; -} - -.dropdown-up .pointer-inner { - bottom: auto; - top: -11px; -} - -.dropdown .pointer { - border-color: #B9B9B9 transparent; -} - -.dropdown .pointer-inner { - border-color: #FFF transparent; -} - -.dropdown .dropdown-contents { - z-index: 2; - overflow: hidden; - overflow-y: auto; - background: #fff; - border: 1px solid #b9b9b9; - border-radius: 5px; - padding: 5px; - position: relative; - min-width: 40px; - max-height: 200px; - box-shadow: 1px 3px 5px rgba(0, 0, 0, 0.2); - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; -} - -.dropdown-up .dropdown-contents { - box-shadow: 1px 0 5px rgba(0, 0, 0, 0.2); -} - -.dropdown li { - float: none; - margin: 0; - white-space: nowrap; - text-align: left; -} - -.rtl .dropdown li { - text-align: right; -} -.wrap .dropdown li, .dropdown.wrap li { - white-space: normal; -} - -.dropdown li:before, .dropdown li:after { - display: none !important; -} - -.roles-options > .dropdown { - left: auto; - top: 3.2em; - width: 250px; -} - -.rtl .roles-options > .dropdown { - right: auto; -} - -.roles-options { - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - -o-user-select: none; - user-select: none; - width: 250px; -} - -.roles-options > span { - border: 1px solid #DEDEDE; - border-radius: 3px; - padding: 4px; - width: 250px; - display: none; - background: url('../images/arrow_down.gif') no-repeat 245px .7em; -} - -.rtl .roles-options > span { - background: url('../images/arrow_down.gif') no-repeat 7px .7em; -} - -.roles-options li { - list-style: none; -} - -.roles-highlight { - background-color: #1e90ff; - color: #fff; -} - - -/* Classes for additional tasks ----------------------------------------- */ - -.current-ext { - color: #228822; -} - -.outdated-ext { - color: #BC2A4D; -} - -.phpinfo { - overflow: auto; - width: 99%; - direction: ltr; -} - -.phpinfo td, .phpinfo th, .phpinfo h2, .phpinfo h1 { - text-align: left; -} - -.requirements_not_met { - padding: 5px; - background-color: #BC2A4D; -} - -.requirements_not_met dt label, .requirements_not_met dd p { - color: #FFFFFF; - font-size: 1.4em; -} - -@media only screen and (max-width: 700px), only screen and (max-device-width: 700px) -{ - .responsive-hide { display: none !important; } - .responsive-show { display: block !important; } - .responsive-show-inline { display: inline !important; } - .responsive-show-inline-block { display: inline-block !important; } -} - -.clearfix { - overflow: hidden; -} - -.pagination:after, -#page-header:after, -#page-body:after, -#tabs:after, -#tabs > ul:after, -#tabs li:after, -#acp:after, -#content:after { - content: ''; - clear: both; - display: block; -} - -#progress-bar { - position: relative; - width: 90%; - text-align: center; - height: 25px; - margin: 20px auto; - border: 1px solid #cecece; -} - -#progress-bar #progress-bar-text { - position: absolute; - top: 0; - width: 100%; - color: #000; -} - -#progress-bar #progress-bar-filler { - display: block; - position: relative; - top: 0; - left: 0; - background-color: #3c84ad; - width: 0; - height: 25px; - overflow: hidden; - color: #fff; -} - -#progress-bar p { - line-height: 25px; - font-weight: bold; -} - -.send-stats-row { - margin: 15px 0; -} - -.send-stats-row:before { - display: table; - content: " "; -} - -.send-stats-tile { - position: relative; - padding: 14px; - margin-bottom: 20px; - background-color: #eff0f2; - border-radius: 6px; - box-shadow: rgba(0,0,0,0.3) 1px 1px 5px; -} - -.send-stats-tile h2 { - margin-top: 0; - text-align: center; - padding-bottom: 1em; -} - -.send-stats-tile i { - padding-right: 0.3em; -} - -.icon { - font-family: FontAwesome; - font-style: normal; -} - -.send-stats-data-row { - background: #f9f9f9; - border-radius: 6px; - border: #DEDEDE 1px solid; - padding: 10px; - border-top-width: 0; - border-top-right-radius: 0; - border-top-left-radius: 0; -} - -.send-stats-data-hidden .configlist { - display: none; -} - -.send-stats-data-only-row { - border-radius: 6px !important; - border-bottom-width: 1px !important; -} - -.send-stats-data-hidden { - padding: 0; - border: none; -} - -.send-stats-row > .send-stats-data-row:first-child { - background-color: #d9edf7; - border-bottom-width: 0; - border-top-right-radius: 6px; - border-top-left-radius: 6px; - border-top-width: 1px; - border-bottom-left-radius: 0; - border-bottom-right-radius: 0; -} - -.send-stats-settings dt, .send-stats-settings dd { - min-width: 25px; -} - -.send-stats-settings dd { - line-height: 1.5em; -} - -.send-stats-settings input { - display: none; -} - -.send-stats-settings input[type=checkbox] + label:before { - content: "\f096"; - font-family: FontAwesome; - font-size: 1.5em; -} - -.send-stats-settings input[type=checkbox]:checked + label:before { - content: "\f14a"; - color: #3c763d; -} - -.send-stats-data-row a:hover span { - text-decoration: underline; -} - -.send-stats-data-row a { - text-decoration: none; - cursor: default; -} - -.send-stats-data-row i { - padding-left: 6px; -} - -.configlist { - word-wrap: break-word; - word-break: break-all; -} - -/* stylelint-disable declaration-property-unit-whitelist */ -.emoji { - min-height: 18px; - min-width: 18px; - height: 1em; - width: 1em; -} -/* stylelint-enable declaration-property-unit-whitelist */ diff --git a/install/update/old/adm/style/admin.js b/install/update/old/adm/style/admin.js deleted file mode 100644 index 551c78a..0000000 --- a/install/update/old/adm/style/admin.js +++ /dev/null @@ -1,258 +0,0 @@ -/** -* phpBB3 ACP functions -*/ - -/** -* Parse document block -*/ -function parse_document(container) -{ - var test = document.createElement('div'), - oldBrowser = (typeof test.style.borderRadius == 'undefined'); - - delete test; - - /** - * Navigation - */ - container.find('#menu').each(function() { - var menu = $(this), - blocks = menu.children('.menu-block'); - - if (!blocks.length) { - return; - } - - // Set onclick event - blocks.children('a.header').click(function() { - var parent = $(this).parent(); - if (!parent.hasClass('active')) { - parent.siblings().removeClass('active'); - } - parent.toggleClass('active'); - }); - - // Set active menu - menu.find('#activemenu').parents('.menu-block').addClass('active'); - - // Check if there is active menu - if (!blocks.filter('.active').length) { - blocks.filter(':first').addClass('active'); - } - }); - - /** - * Responsive tables - */ - container.find('table').not('.not-responsive').each(function() { - var $this = $(this), - th = $this.find('thead > tr > th'), - columns = th.length, - headers = [], - totalHeaders = 0, - i, headersLength; - - // Find columns - $this.find('colgroup:first').children().each(function(i) { - var column = $(this); - $this.find('td:nth-child(' + (i + 1) + ')').addClass(column.prop('className')); - }); - - // Styles table - if ($this.hasClass('styles')) { - $this.find('td:first-child[style]').each(function() { - var style = $(this).attr('style'); - if (style.length) { - $(this).parent('tr').attr('style', style.toLowerCase().replace('padding', 'margin')).addClass('responsive-style-row'); - } - }); - } - - // Find each header - if (!$this.data('no-responsive-header')) - { - th.each(function(column) { - var cell = $(this), - colspan = parseInt(cell.attr('colspan')), - dfn = cell.attr('data-dfn'), - text = dfn ? dfn : $.trim(cell.text()); - - if (text == ' ') text = ''; - colspan = isNaN(colspan) || colspan < 1 ? 1 : colspan; - - for (i=0; i - $this.addClass('responsive'); - - if (totalHeaders < 2) { - $this.addClass('show-header'); - return; - } - - $this.find('tbody > tr').each(function() { - var row = $(this), - cells = row.children('td'), - column = 0; - - if (cells.length == 1) { - row.addClass('big-column'); - return; - } - - cells.each(function() { - var cell = $(this), - colspan = parseInt(cell.attr('colspan')), - text = $.trim(cell.text()); - - if (headersLength <= column) { - return; - } - - if ((text.length && text !== '-') || cell.children().length) { - if (headers[column] != '') { - cell.prepend('' + headers[column] + ''); - } - } - else { - cell.addClass('empty'); - } - - colspan = isNaN(colspan) || colspan < 1 ? 1 : colspan; - column += colspan; - }); - }); - - // Remove in disabled extensions list - $this.find('tr.ext_disabled > .empty:nth-child(2) + .empty').siblings(':first-child').children('dfn').remove(); - }); - - /** - * Hide empty responsive tables - */ - container.find('table.responsive > tbody').each(function() { - var items = $(this).children('tr'); - if (items.length == 0) - { - $(this).parent('table:first').addClass('responsive-hide'); - } - }); - - /** - * Fieldsets with empty - */ - container.find('fieldset dt > span:last-child').each(function() { - var $this = $(this); - if ($this.html() == ' ') { - $this.addClass('responsive-hide'); - } - - }); - - /** - * Responsive tabs - */ - container.find('#tabs').not('[data-skip-responsive]').each(function() { - var $this = $(this), - $body = $('body'), - ul = $this.children(), - tabs = ul.children().not('[data-skip-responsive]'), - links = tabs.children('a'), - item = ul.append('').find('li.responsive-tab'), - menu = item.find('.dropdown-contents'), - maxHeight = 0, - lastWidth = false, - responsive = false; - - links.each(function() { - var link = $(this); - maxHeight = Math.max(maxHeight, Math.max(link.outerHeight(true), link.parent().outerHeight(true))); - }) - - function check() { - var width = $body.width(), - height = $this.height(); - - if (arguments.length == 0 && (!responsive || width <= lastWidth) && height <= maxHeight) { - return; - } - - tabs.show(); - item.hide(); - - lastWidth = width; - height = $this.height(); - if (height <= maxHeight) { - responsive = false; - if (item.hasClass('dropdown-visible')) { - phpbb.toggleDropdown.call(item.find('a.responsive-tab-link').get(0)); - } - return; - } - - responsive = true; - item.show(); - menu.html(''); - - var availableTabs = tabs.filter(':not(.activetab, .responsive-tab)'), - total = availableTabs.length, - i, tab; - - for (i = total - 1; i >= 0; i --) { - tab = availableTabs.eq(i); - menu.prepend(tab.clone(true).removeClass('tab')); - tab.hide(); - if ($this.height() <= maxHeight) { - menu.find('a').click(function() { check(true); }); - return; - } - } - menu.find('a').click(function() { check(true); }); - } - - phpbb.registerDropdown(item.find('a.responsive-tab-link'), item.find('.dropdown'), {visibleClass: 'activetab', verticalDirection: 'down'}); - - check(true); - $(window).resize(check); - }); -} - -/** -* Run onload functions -*/ -(function($) { - $(document).ready(function() { - // Swap .nojs and .hasjs - $('body.nojs').toggleClass('nojs hasjs'); - - // Focus forms - $('form[data-focus]:first').each(function() { - $('#' + this.getAttribute('data-focus')).focus(); - }); - - parse_document($('body')); - - $('#questionnaire-form').css('display', 'none'); - var $triggerConfiglist = $('#trigger-configlist'); - - $triggerConfiglist.on('click', function () { - var $configlist = $('#configlist'); - $configlist.closest('.send-stats-data-row').toggleClass('send-stats-data-hidden'); - $configlist.closest('.send-stats-row').find('.send-stats-data-row:first-child').toggleClass('send-stats-data-only-row'); - $(this).find('i').toggleClass('fa-angle-down fa-angle-up'); - }); - - $('#configlist').closest('.send-stats-data-row').addClass('send-stats-data-hidden'); - }); -})(jQuery); diff --git a/install/update/old/adm/style/ajax.js b/install/update/old/adm/style/ajax.js deleted file mode 100644 index 895bb05..0000000 --- a/install/update/old/adm/style/ajax.js +++ /dev/null @@ -1,332 +0,0 @@ -/* global phpbb */ - -(function($) { // Avoid conflicts with other libraries - -'use strict'; - - -phpbb.prepareSendStats = function () { - var $form = $('#acp_help_phpbb'); - var $dark = $('#darkenwrapper'); - var $loadingIndicator; - - $form.on('submit', function (event) { - var $this = $(this), - currentTime = Math.floor(new Date().getTime() / 1000), - statsTime = parseInt($this.find('input[name=help_send_statistics_time]').val(), 10); - - event.preventDefault(); - $this.unbind('submit'); - - // Skip ajax request if form is submitted too early or send stats - // checkbox is not checked - if (!$this.find('input[name=help_send_statistics]').is(':checked') || - statsTime > currentTime) { - $form.find('input[type=submit]').click(); - setTimeout(function () { - $form.find('input[type=submit]').click(); - }, 300); - return; - } - - /** - * Handler for AJAX errors - */ - function errorHandler(jqXHR, textStatus, errorThrown) { - if (typeof console !== 'undefined' && console.log) { - console.log('AJAX error. status: ' + textStatus + ', message: ' + errorThrown); - } - phpbb.clearLoadingTimeout(); - var errorText = ''; - - if (typeof errorThrown === 'string' && errorThrown.length > 0) { - errorText = errorThrown; - } else { - errorText = $dark.attr('data-ajax-error-text-' + textStatus); - if (typeof errorText !== 'string' || !errorText.length) { - errorText = $dark.attr('data-ajax-error-text'); - } - } - phpbb.alert($dark.attr('data-ajax-error-title'), errorText); - } - - /** - * This is a private function used to handle the callbacks, refreshes - * and alert. It calls the callback, refreshes the page if necessary, and - * displays an alert to the user and removes it after an amount of time. - * - * It cannot be called from outside this function, and is purely here to - * avoid repetition of code. - * - * @param {object} res The object sent back by the server. - */ - function returnHandler(res) { - phpbb.clearLoadingTimeout(); - - // If a confirmation is not required, display an alert and call the - // callbacks. - $dark.fadeOut(phpbb.alertTime); - - if ($loadingIndicator) { - $loadingIndicator.fadeOut(phpbb.alertTime); - } - - var $sendStatisticsSuccess = $('', { - type: 'hidden', - name: 'send_statistics_response', - value: res - }); - $sendStatisticsSuccess.appendTo('p.submit-buttons'); - - // Finish actual form submission - $form.find('input[type=submit]').click(); - } - - $loadingIndicator = phpbb.loadingIndicator(); - - $.ajax({ - url: $this.attr('data-ajax-action').replace('&', '&'), - type: 'POST', - data: 'systemdata=' + encodeURIComponent($this.find('input[name=systemdata]').val()), - success: returnHandler, - error: errorHandler, - cache: false - }).always(function() { - if ($loadingIndicator && $loadingIndicator.is(':visible')) { - $loadingIndicator.fadeOut(phpbb.alertTime); - } - }); - }); -}; - -/** - * The following callbacks are for reording items. row_down - * is triggered when an item is moved down, and row_up is triggered when - * an item is moved up. It moves the row up or down, and deactivates / - * activates any up / down icons that require it (the ones at the top or bottom). - */ -phpbb.addAjaxCallback('row_down', function(res) { - if (typeof res.success === 'undefined' || !res.success) { - return; - } - - var $firstTr = $(this).parents('tr'), - $secondTr = $firstTr.next(); - - $firstTr.insertAfter($secondTr); -}); - -phpbb.addAjaxCallback('row_up', function(res) { - if (typeof res.success === 'undefined' || !res.success) { - return; - } - - var $secondTr = $(this).parents('tr'), - $firstTr = $secondTr.prev(); - - $secondTr.insertBefore($firstTr); -}); - -/** - * This callback replaces activate links with deactivate links and vice versa. - * It does this by replacing the text, and replacing all instances of "activate" - * in the href with "deactivate", and vice versa. - */ -phpbb.addAjaxCallback('activate_deactivate', function(res) { - var $this = $(this), - newHref = $this.attr('href'); - - $this.text(res.text); - - if (newHref.indexOf('deactivate') !== -1) { - newHref = newHref.replace('deactivate', 'activate'); - } else { - newHref = newHref.replace('activate', 'deactivate'); - } - - $this.attr('href', newHref); -}); - -/** - * The removes the parent row of the link or form that triggered the callback, - * and is good for stuff like the removal of forums. - */ -phpbb.addAjaxCallback('row_delete', function(res) { - if (res.SUCCESS !== false) { - $(this).parents('tr').remove(); - } -}); - -/** - * Handler for submitting permissions form in chunks - * This call will submit permissions forms in chunks of 5 fieldsets. - */ -function submitPermissions() { - var $form = $('form#set-permissions'), - fieldsetList = $form.find('fieldset[id^=perm]'), - formDataSets = [], - dataSetIndex = 0, - $submitAllButton = $form.find('input[type=submit][name^=action]')[0], - $submitButton = $form.find('input[type=submit][data-clicked=true]')[0]; - - // Set proper start values for handling refresh of page - var permissionSubmitSize = 0, - permissionRequestCount = 0, - forumIds = [], - permissionSubmitFailed = false; - - if ($submitAllButton !== $submitButton) { - fieldsetList = $form.find('fieldset#' + $submitButton.closest('fieldset.permissions').id); - } - - $.each(fieldsetList, function (key, value) { - dataSetIndex = Math.floor(key / 5); - var $fieldset = $('fieldset#' + value.id); - if (key % 5 === 0) { - formDataSets[dataSetIndex] = $fieldset.find('select:visible, input:not([data-name])').serialize(); - } else { - formDataSets[dataSetIndex] += '&' + $fieldset.find('select:visible, input:not([data-name])').serialize(); - } - - // Find proper role value - var roleInput = $fieldset.find('input[name^=role][data-name]'); - if (roleInput.val()) { - formDataSets[dataSetIndex] += '&' + roleInput.attr('name') + '=' + roleInput.val(); - } else { - formDataSets[dataSetIndex] += '&' + roleInput.attr('name') + '=' + - $fieldset.find('select[name="' + roleInput.attr('name') + '"]').val(); - } - }); - - permissionSubmitSize = formDataSets.length; - - // Add each forum ID to forum ID list to preserve selected forums - $.each($form.find('input[type=hidden][name^=forum_id]'), function (key, value) { - if (value.name.match(/^forum_id\[([0-9]+)\]$/)) { - forumIds.push(value.value); - } - }); - - /** - * Handler for submitted permissions form chunk - * - * @param {object} res Object returned by AJAX call - */ - function handlePermissionReturn(res) { - permissionRequestCount++; - var $dark = $('#darkenwrapper'); - - if (res.S_USER_WARNING) { - phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); - permissionSubmitFailed = true; - } else if (!permissionSubmitFailed && res.S_USER_NOTICE) { - // Display success message at the end of submitting the form - if (permissionRequestCount >= permissionSubmitSize) { - var $alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); - var $alertBoxLink = $alert.find('p.alert_text > a'); - - // Create form to submit instead of normal "Back to previous page" link - if ($alertBoxLink) { - // Remove forum_id[] from URL - $alertBoxLink.attr('href', $alertBoxLink.attr('href').replace(/(&forum_id\[\]=[0-9]+)/g, '')); - var previousPageForm = '
'; - $.each(forumIds, function (key, value) { - previousPageForm += ''; - }); - previousPageForm += '
'; - - $alertBoxLink.on('click', function (e) { - var $previousPageForm = $(previousPageForm); - $('body').append($previousPageForm); - e.preventDefault(); - $previousPageForm.submit(); - }); - } - - // Do not allow closing alert - $dark.off('click'); - $alert.find('.alert_close').hide(); - - if (typeof res.REFRESH_DATA !== 'undefined') { - setTimeout(function () { - // Create forum to submit using POST. This will prevent - // exceeding the maximum length of URLs - var form = '
'; - $.each(forumIds, function (key, value) { - form += ''; - }); - form += '
'; - $form = $(form); - $('body').append($form); - - // Hide the alert even if we refresh the page, in case the user - // presses the back button. - $dark.fadeOut(phpbb.alertTime, function () { - if (typeof $alert !== 'undefined') { - $alert.hide(); - } - }); - - // Submit form - $form.submit(); - }, res.REFRESH_DATA.time * 1000); // Server specifies time in seconds - } - } - } - } - - // Create AJAX request for each form data set - $.each(formDataSets, function (key, formData) { - $.ajax({ - url: $form.action, - type: 'POST', - data: formData + '&' + $submitButton.name + '=' + encodeURIComponent($submitButton.value) + - '&creation_time=' + $form.find('input[type=hidden][name=creation_time]')[0].value + - '&form_token=' + $form.find('input[type=hidden][name=form_token]')[0].value + - '&' + $form.children('input[type=hidden]').serialize() + - '&' + $form.find('input[type=checkbox][name^=inherit]').serialize(), - success: handlePermissionReturn, - error: handlePermissionReturn - }); - }); -} - -$('[data-ajax]').each(function() { - var $this = $(this), - ajax = $this.attr('data-ajax'); - - if (ajax !== 'false') { - var fn = (ajax !== 'true') ? ajax : null; - phpbb.ajaxify({ - selector: this, - refresh: $this.attr('data-refresh') !== undefined, - callback: fn - }); - } -}); - -/** -* Automatically resize textarea -*/ -$(function() { - phpbb.resizeTextArea($('textarea:not(.no-auto-resize)'), {minHeight: 75}); - - var $setPermissionsForm = $('form#set-permissions'); - if ($setPermissionsForm.length) { - $setPermissionsForm.on('submit', function (e) { - submitPermissions(); - e.preventDefault(); - }); - $setPermissionsForm.find('input[type=submit]').click(function() { - $('input[type=submit]', $(this).parents($('form#set-permissions'))).removeAttr('data-clicked'); - $(this).attr('data-clicked', true); - }); - } - - if ($('#acp_help_phpbb')) { - phpbb.prepareSendStats(); - } -}); - - -})(jQuery); // Avoid conflicts with other libraries diff --git a/install/update/old/adm/style/captcha_recaptcha.html b/install/update/old/adm/style/captcha_recaptcha.html deleted file mode 100644 index 3f61c76..0000000 --- a/install/update/old/adm/style/captcha_recaptcha.html +++ /dev/null @@ -1,14 +0,0 @@ - -
-
- - - -
-
-
- -{L_RECAPTCHA_NOT_AVAILABLE} - diff --git a/install/update/old/adm/style/installer_footer.html b/install/update/old/adm/style/installer_footer.html deleted file mode 100644 index fefa8f6..0000000 --- a/install/update/old/adm/style/installer_footer.html +++ /dev/null @@ -1,30 +0,0 @@ -
-
-
-
-
- - -
- - - - - - - -{$SCRIPTS} - - - diff --git a/install/update/old/adm/style/overall_footer.html b/install/update/old/adm/style/overall_footer.html deleted file mode 100644 index 8745286..0000000 --- a/install/update/old/adm/style/overall_footer.html +++ /dev/null @@ -1,46 +0,0 @@ -
-
-
-
-
- - -
- - - - - - - - -{$SCRIPTS} - - - diff --git a/install/update/old/adm/style/overall_header.html b/install/update/old/adm/style/overall_header.html deleted file mode 100644 index 8279ac3..0000000 --- a/install/update/old/adm/style/overall_header.html +++ /dev/null @@ -1,157 +0,0 @@ - - - - - - -{META} -{PAGE_TITLE} - - - - - - - - -{$STYLESHEETS} - - - - - - - - - -
- - -
-
- -
- -
-
- - - -
- -
-
- {% if CONTAINER_EXCEPTION !== false %} -
-

{{ lang('CONTAINER_EXCEPTION') }}


-

{{ lang('EXCEPTION') }}{{ lang('COLON') }} {{ CONTAINER_EXCEPTION.getMessage() }}

-
{{ CONTAINER_EXCEPTION.getTraceAsString() }}
-
- {% endif %} diff --git a/install/update/old/adm/style/permission_forum_copy.html b/install/update/old/adm/style/permission_forum_copy.html deleted file mode 100644 index b1539af..0000000 --- a/install/update/old/adm/style/permission_forum_copy.html +++ /dev/null @@ -1,40 +0,0 @@ - - - - -

{L_ACP_FORUM_PERMISSIONS_COPY}

- - {L_ACP_FORUM_PERMISSIONS_COPY_EXPLAIN} - -
- -
- {L_LOOK_UP_FORUM} - -
-

{L_COPY_PERMISSIONS_FORUM_FROM_EXPLAIN}
-
-
-
- -
- {L_LOOK_UP_FORUM} -

{L_LOOK_UP_FORUMS_EXPLAIN}

- -
-

{L_COPY_PERMISSIONS_FORUM_TO_EXPLAIN}
-
-
-
- -
- {L_SUBMIT} -   - - {S_HIDDEN_FIELDS} - {S_FORM_TOKEN} -
- -
- - diff --git a/install/update/old/adm/style/permission_mask.html b/install/update/old/adm/style/permission_mask.html deleted file mode 100644 index c556664..0000000 --- a/install/update/old/adm/style/permission_mask.html +++ /dev/null @@ -1,150 +0,0 @@ - - - - - -
-

{p_mask.NAME} [{p_mask.L_ACL_TYPE}]

- - -
-
- - - - - - {p_mask.f_mask.PADDING}{p_mask.f_mask.PADDING}{p_mask.f_mask.NAME} - - - -
-
- {% if p_mask.f_mask.role_options %} -
- -
- {% else %} -
{L_NO_ROLE_AVAILABLE}
- {% endif %} -
- - - - - -
- - - diff --git a/install/update/old/adm/style/permissions.js b/install/update/old/adm/style/permissions.js deleted file mode 100644 index 9178ada..0000000 --- a/install/update/old/adm/style/permissions.js +++ /dev/null @@ -1,300 +0,0 @@ -/** -* Hide and show all checkboxes -* status = true (show boxes), false (hide boxes) -*/ -function display_checkboxes(status) { - var form = document.getElementById('set-permissions'); - var cb = document.getElementsByTagName('input'); - var display; - - //show - if (status) { - display = 'inline'; - } - //hide - else { - display = 'none'; - } - - for (var i = 0; i < cb.length; i++ ) { - if (cb[i].className === 'permissions-checkbox') { - cb[i].style.display = display; - } - } -} - -/** -* Change opacity of element -* e = element -* value = 0 (hidden) till 10 (fully visible) -*/ -function set_opacity(e, value) { - e.style.opacity = value/10; - - //IE opacity currently turned off, because of its astronomical stupidity - //e.style.filter = 'alpha(opacity=' + value*10 + ')'; -} - -/** -* Reset the opacity and checkboxes -* block_id = id of the element that needs to be toggled -*/ -function toggle_opacity(block_id) { - var cb = document.getElementById('checkbox' + block_id); - var fs = document.getElementById('perm' + block_id); - - if (cb.checked) { - set_opacity(fs, 5); - } else { - set_opacity(fs, 10); - } -} - -/** -* Reset the opacity and checkboxes -* value = 0 (checked) and 1 (unchecked) -* except_id = id of the element not to hide -*/ -function reset_opacity(status, except_id) { - var perm = document.getElementById('set-permissions'); - var fs = perm.getElementsByTagName('fieldset'); - var opacity = 5; - - if (status) { - opacity = 10; - } - - for (var i = 0; i < fs.length; i++ ) { - if (fs[i].className !== 'quick') { - set_opacity(fs[i], opacity); - } - } - - if (typeof(except_id) !== 'undefined') { - set_opacity(document.getElementById('perm' + except_id), 10); - } - - //reset checkboxes too - marklist('set-permissions', 'inherit', !status); -} - -/** -* Check whether we have a full radiobutton row of true -* index = offset for the row of inputs (0 == first row, 1 == second, 2 == third), -* rb = array of radiobuttons -*/ -function get_radio_status(index, rb) { - for (var i = index; i < rb.length; i = i + 3 ) { - if (rb[i].checked !== true) { - if (i > index) { - //at least one is true, but not all (custom) - return 2; - } - //first one is not true - return 0; - } - } - - // all radiobuttons true - return 1; -} - -/** -* Set tab colours -* id = panel the tab needs to be set for, -* init = initialising on open, -* quick = If no calculation needed, this contains the colour -*/ -function set_colours(id, init, quick) { - var table = document.getElementById('table' + id); - var tab = document.getElementById('tab' + id); - - if (typeof(quick) !== 'undefined') { - tab.className = 'permissions-preset-' + quick + ' activetab'; - return; - } - - var rb = table.getElementsByTagName('input'); - var colour = 'custom'; - - var status = get_radio_status(0, rb); - - if (status === 1) { - colour = 'yes'; - } else if (status === 0) { - // We move on to No - status = get_radio_status(1, rb); - - if (status === 1) { - colour = 'no'; - } else if (status === 0) { - // We move on to Never - status = get_radio_status(2, rb); - - if (status === 1) { - colour = 'never'; - } - } - } - - if (init) { - tab.className = 'permissions-preset-' + colour; - } else { - tab.className = 'permissions-preset-' + colour + ' activetab'; - } -} - -/** -* Initialise advanced tab colours on first load -* block_id = block that is opened -*/ -function init_colours(block_id) { - var block = document.getElementById('advanced' + block_id); - var panels = block.getElementsByTagName('div'); - var tab = document.getElementById('tab' + id); - - for (var i = 0; i < panels.length; i++) { - if (panels[i].className === 'permissions-panel') { - set_colours(panels[i].id.replace(/options/, ''), true); - } - } - - tab.className = tab.className + ' activetab'; -} - -/** -* Show/hide option panels -* value = suffix for ID to show -* adv = we are opening advanced permissions -* view = called from view permissions -*/ -function swap_options(pmask, fmask, cat, adv, view) { - id = pmask + fmask + cat; - active_option = active_pmask + active_fmask + active_cat; - - var old_tab = document.getElementById('tab' + active_option); - var new_tab = document.getElementById('tab' + id); - var adv_block = document.getElementById('advanced' + pmask + fmask); - - if (adv_block.style.display === 'block' && adv === true) { - phpbb.toggleDisplay('advanced' + pmask + fmask, -1); - reset_opacity(1); - display_checkboxes(false); - return; - } - - // no need to set anything if we are clicking on the same tab again - if (new_tab === old_tab && !adv) { - return; - } - - // init colours - if (adv && (pmask + fmask) !== (active_pmask + active_fmask)) { - init_colours(pmask + fmask); - display_checkboxes(true); - reset_opacity(1); - } else if (adv) { - //Checkbox might have been clicked, but we need full visibility - display_checkboxes(true); - reset_opacity(1); - } - - // set active tab - old_tab.className = old_tab.className.replace(/\ activetab/g, ''); - new_tab.className = new_tab.className + ' activetab'; - - if (id === active_option && adv !== true) { - return; - } - - phpbb.toggleDisplay('options' + active_option, -1); - - //hiding and showing the checkbox - if (document.getElementById('checkbox' + active_pmask + active_fmask)) { - phpbb.toggleDisplay('checkbox' + pmask + fmask, -1); - - if ((pmask + fmask) !== (active_pmask + active_fmask)) { - document.getElementById('checkbox' + active_pmask + active_fmask).style.display = 'inline'; - } - } - - if (!view) { - phpbb.toggleDisplay('advanced' + active_pmask + active_fmask, -1); - } - - if (!view) { - phpbb.toggleDisplay('advanced' + pmask + fmask, 1); - } - phpbb.toggleDisplay('options' + id, 1); - - active_pmask = pmask; - active_fmask = fmask; - active_cat = cat; -} - -/** -* Mark all radio buttons in one panel -* id = table ID container, s = status ['y'/'u'/'n'] -*/ -function mark_options(id, s) { - var t = document.getElementById(id); - - if (!t) { - return; - } - - var rb = t.getElementsByTagName('input'); - - for (var r = 0; r < rb.length; r++) { - if (rb[r].id.substr(rb[r].id.length-1) === s) { - rb[r].checked = true; - } - } -} - -function mark_one_option(id, field_name, s) { - var t = document.getElementById(id); - - if (!t) { - return; - } - - var rb = t.getElementsByTagName('input'); - - for (var r = 0; r < rb.length; r++) { - if (rb[r].id.substr(rb[r].id.length-field_name.length-3, field_name.length) === field_name && rb[r].id.substr(rb[r].id.length-1) === s) { - rb[r].checked = true; - } - } -} - -/** -* Reset role dropdown field to Select role... if an option gets changed -*/ -function reset_role(id) { - var t = document.getElementById(id); - - if (!t) { - return; - } - - t.options[0].selected = true; -} - -/** -* Load role and set options accordingly -*/ -function set_role_settings(role_id, target_id) { - settings = role_options[role_id]; - - if (!settings) { - return; - } - - // Mark all options to no (unset) first... - mark_options(target_id, 'u'); - - for (var r in settings) { - mark_one_option(target_id, r, (settings[r] === 1) ? 'y' : 'n'); - } -} diff --git a/install/update/old/adm/style/progress_bar.html b/install/update/old/adm/style/progress_bar.html deleted file mode 100644 index 1822675..0000000 --- a/install/update/old/adm/style/progress_bar.html +++ /dev/null @@ -1,40 +0,0 @@ - - - - -
-

{L_PROGRESS}

- {L_PROGRESS} -

{L_PROGRESS_EXPLAIN}

-
- - - - diff --git a/install/update/old/adm/style/simple_footer.html b/install/update/old/adm/style/simple_footer.html deleted file mode 100644 index 08ee0a7..0000000 --- a/install/update/old/adm/style/simple_footer.html +++ /dev/null @@ -1,27 +0,0 @@ - -

-
- - - - - - - - -{$SCRIPTS} - - - diff --git a/install/update/old/adm/style/simple_header.html b/install/update/old/adm/style/simple_header.html deleted file mode 100644 index 439645a..0000000 --- a/install/update/old/adm/style/simple_header.html +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - -{META} -{PAGE_TITLE} - - - - - -{$STYLESHEETS} - - - - - - - -
diff --git a/install/update/old/assets/cookieconsent/cookieconsent.min.css b/install/update/old/assets/cookieconsent/cookieconsent.min.css deleted file mode 100644 index 03c69fe..0000000 --- a/install/update/old/assets/cookieconsent/cookieconsent.min.css +++ /dev/null @@ -1,6 +0,0 @@ -.cc-window{opacity:1;transition:opacity 1s ease}.cc-window.cc-invisible{opacity:0}.cc-animate.cc-revoke{transition:transform 1s ease}.cc-animate.cc-revoke.cc-top{transform:translateY(-2em)}.cc-animate.cc-revoke.cc-bottom{transform:translateY(2em)}.cc-animate.cc-revoke.cc-active.cc-bottom,.cc-animate.cc-revoke.cc-active.cc-top,.cc-revoke:hover{transform:translateY(0)}.cc-grower{max-height:0;overflow:hidden;transition:max-height 1s} -.cc-link,.cc-revoke:hover{text-decoration:underline}.cc-revoke,.cc-window{position:fixed;overflow:hidden;box-sizing:border-box;font-family:Helvetica,Calibri,Arial,sans-serif;font-size:16px;line-height:1.5em;display:-ms-flexbox;display:flex;-ms-flex-wrap:nowrap;flex-wrap:nowrap;z-index:9999}.cc-window.cc-static{position:static}.cc-window.cc-floating{padding:2em;max-width:24em;-ms-flex-direction:column;flex-direction:column}.cc-window.cc-banner{padding:1em 1.8em;width:100%;-ms-flex-direction:row;flex-direction:row}.cc-revoke{padding:.5em}.cc-header{font-size:18px;font-weight:700}.cc-btn,.cc-close,.cc-link,.cc-revoke{cursor:pointer}.cc-link{opacity:.8;display:inline-block;padding:.2em}.cc-link:hover{opacity:1}.cc-link:active,.cc-link:visited{color:initial}.cc-btn{display:block;padding:.4em .8em;font-size:.9em;font-weight:700;border-width:2px;border-style:solid;text-align:center;white-space:nowrap}.cc-banner .cc-btn:last-child{min-width:140px}.cc-highlight .cc-btn:first-child{background-color:transparent;border-color:transparent}.cc-highlight .cc-btn:first-child:focus,.cc-highlight .cc-btn:first-child:hover{background-color:transparent;text-decoration:underline}.cc-close{display:block;position:absolute;top:.5em;right:.5em;font-size:1.6em;opacity:.9;line-height:.75}.cc-close:focus,.cc-close:hover{opacity:1} -.cc-revoke.cc-top{top:0;left:3em;border-bottom-left-radius:.5em;border-bottom-right-radius:.5em}.cc-revoke.cc-bottom{bottom:0;left:3em;border-top-left-radius:.5em;border-top-right-radius:.5em}.cc-revoke.cc-left{left:3em;right:unset}.cc-revoke.cc-right{right:3em;left:unset}.cc-top{top:1em}.cc-left{left:1em}.cc-right{right:1em}.cc-bottom{bottom:1em}.cc-floating>.cc-link{margin-bottom:1em}.cc-floating .cc-message{display:block;margin-bottom:1em}.cc-window.cc-floating .cc-compliance{-ms-flex:1;flex:1}.cc-window.cc-banner{-ms-flex-align:center;align-items:center}.cc-banner.cc-top{left:0;right:0;top:0}.cc-banner.cc-bottom{left:0;right:0;bottom:0}.cc-banner .cc-message{-ms-flex:1;flex:1}.cc-compliance{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-line-pack:justify;align-content:space-between}.cc-compliance>.cc-btn{-ms-flex:1;flex:1}.cc-btn+.cc-btn{margin-left:.5em} -@media print{.cc-revoke,.cc-window{display:none}}@media screen and (max-width:900px){.cc-btn{white-space:normal}}@media screen and (max-width:414px) and (orientation:portrait),screen and (max-width:736px) and (orientation:landscape){.cc-window.cc-top{top:0}.cc-window.cc-bottom{bottom:0}.cc-window.cc-banner,.cc-window.cc-left,.cc-window.cc-right{left:0;right:0}.cc-window.cc-banner{-ms-flex-direction:column;flex-direction:column}.cc-window.cc-banner .cc-compliance{-ms-flex:1;flex:1}.cc-window.cc-floating{max-width:none}.cc-window .cc-message{margin-bottom:1em}.cc-window.cc-banner{-ms-flex-align:unset;align-items:unset}} -.cc-floating.cc-theme-classic{padding:1.2em;border-radius:5px}.cc-floating.cc-type-info.cc-theme-classic .cc-compliance{text-align:center;display:inline;-ms-flex:none;flex:none}.cc-theme-classic .cc-btn{border-radius:5px}.cc-theme-classic .cc-btn:last-child{min-width:140px}.cc-floating.cc-type-info.cc-theme-classic .cc-btn{display:inline-block} -.cc-theme-edgeless.cc-window{padding:0}.cc-floating.cc-theme-edgeless .cc-message{margin:2em 2em 1.5em}.cc-banner.cc-theme-edgeless .cc-btn{margin:0;padding:.8em 1.8em;height:100%}.cc-banner.cc-theme-edgeless .cc-message{margin-left:1em}.cc-floating.cc-theme-edgeless .cc-btn+.cc-btn{margin-left:0} \ No newline at end of file diff --git a/install/update/old/assets/cookieconsent/cookieconsent.min.js b/install/update/old/assets/cookieconsent/cookieconsent.min.js deleted file mode 100644 index 8e44bdd..0000000 --- a/install/update/old/assets/cookieconsent/cookieconsent.min.js +++ /dev/null @@ -1 +0,0 @@ -!function(e){if(!e.hasInitialised){var t={escapeRegExp:function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},hasClass:function(e,t){var i=" ";return 1===e.nodeType&&(i+e.className+i).replace(/[\n\t]/g,i).indexOf(i+t+i)>=0},addClass:function(e,t){e.className+=" "+t},removeClass:function(e,t){var i=new RegExp("\\b"+this.escapeRegExp(t)+"\\b");e.className=e.className.replace(i,"")},interpolateString:function(e,t){var i=/{{([a-z][a-z0-9\-_]*)}}/gi;return e.replace(i,function(e){return t(arguments[1])||""})},getCookie:function(e){var t="; "+document.cookie,i=t.split("; "+e+"=");return 2!=i.length?void 0:i.pop().split(";").shift()},setCookie:function(e,t,i,n,o){var s=new Date;s.setDate(s.getDate()+(i||365));var r=[e+"="+t,"expires="+s.toUTCString(),"path="+(o||"/")];n&&r.push("domain="+n),document.cookie=r.join(";")},deepExtend:function(e,t){for(var i in t)t.hasOwnProperty(i)&&(i in e&&this.isPlainObject(e[i])&&this.isPlainObject(t[i])?this.deepExtend(e[i],t[i]):e[i]=t[i]);return e},throttle:function(e,t){var i=!1;return function(){i||(e.apply(this,arguments),i=!0,setTimeout(function(){i=!1},t))}},hash:function(e){var t,i,n,o=0;if(0===e.length)return o;for(t=0,n=e.length;t=128?"#000":"#fff"},getLuminance:function(e){var t=parseInt(this.normaliseHex(e),16),i=38,n=(t>>16)+i,o=(t>>8&255)+i,s=(255&t)+i,r=(16777216+65536*(n<255?n<1?0:n:255)+256*(o<255?o<1?0:o:255)+(s<255?s<1?0:s:255)).toString(16).slice(1);return"#"+r},isMobile:function(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)},isPlainObject:function(e){return"object"==typeof e&&null!==e&&e.constructor==Object}};e.status={deny:"deny",allow:"allow",dismiss:"dismiss"},e.transitionEnd=function(){var e=document.createElement("div"),t={t:"transitionend",OT:"oTransitionEnd",msT:"MSTransitionEnd",MozT:"transitionend",WebkitT:"webkitTransitionEnd"};for(var i in t)if(t.hasOwnProperty(i)&&"undefined"!=typeof e.style[i+"ransition"])return t[i];return""}(),e.hasTransition=!!e.transitionEnd;var i=Object.keys(e.status).map(t.escapeRegExp);e.customStyles={},e.Popup=function(){function n(){this.initialise.apply(this,arguments)}function o(e){this.openingTimeout=null,t.removeClass(e,"cc-invisible")}function s(t){t.style.display="none",t.removeEventListener(e.transitionEnd,this.afterTransition),this.afterTransition=null}function r(){var t=this.options.onInitialise.bind(this);if(!window.navigator.cookieEnabled)return t(e.status.deny),!0;if(window.CookiesOK||window.navigator.CookiesOK)return t(e.status.allow),!0;var i=Object.keys(e.status),n=this.getStatus(),o=i.indexOf(n)>=0;return o&&t(n),o}function a(){var e=this.options.position.split("-"),t=[];return e.forEach(function(e){t.push("cc-"+e)}),t}function c(){var e=this.options,i="top"==e.position||"bottom"==e.position?"banner":"floating";t.isMobile()&&(i="floating");var n=["cc-"+i,"cc-type-"+e.type,"cc-theme-"+e.theme];e["static"]&&n.push("cc-static"),n.push.apply(n,a.call(this));p.call(this,this.options.palette);return this.customStyleSelector&&n.push(this.customStyleSelector),n}function l(){var e={},i=this.options;i.showLink||(i.elements.link="",i.elements.messagelink=i.elements.message),Object.keys(i.elements).forEach(function(n){e[n]=t.interpolateString(i.elements[n],function(e){var t=i.content[e];return e&&"string"==typeof t&&t.length?t:""})});var n=i.compliance[i.type];n||(n=i.compliance.info),e.compliance=t.interpolateString(n,function(t){return e[t]});var o=i.layouts[i.layout];return o||(o=i.layouts.basic),t.interpolateString(o,function(t){return e[t]})}function u(i){var n=this.options,o=document.createElement("div"),s=n.container&&1===n.container.nodeType?n.container:document.body;o.innerHTML=i;var r=o.children[0];return r.style.display="none",t.hasClass(r,"cc-window")&&e.hasTransition&&t.addClass(r,"cc-invisible"),this.onButtonClick=h.bind(this),r.addEventListener("click",this.onButtonClick),n.autoAttach&&(s.firstChild?s.insertBefore(r,s.firstChild):s.appendChild(r)),r}function h(n){var o=n.target;if(t.hasClass(o,"cc-btn")){var s=o.className.match(new RegExp("\\bcc-("+i.join("|")+")\\b")),r=s&&s[1]||!1;r&&(this.setStatus(r),this.close(!0))}t.hasClass(o,"cc-close")&&(this.setStatus(e.status.dismiss),this.close(!0)),t.hasClass(o,"cc-revoke")&&this.revokeChoice()}function p(e){var i=t.hash(JSON.stringify(e)),n="cc-color-override-"+i,o=t.isPlainObject(e);return this.customStyleSelector=o?n:null,o&&d(i,e,"."+n),o}function d(i,n,o){if(e.customStyles[i])return void++e.customStyles[i].references;var s={},r=n.popup,a=n.button,c=n.highlight;r&&(r.text=r.text?r.text:t.getContrast(r.background),r.link=r.link?r.link:r.text,s[o+".cc-window"]=["color: "+r.text,"background-color: "+r.background],s[o+".cc-revoke"]=["color: "+r.text,"background-color: "+r.background],s[o+" .cc-link,"+o+" .cc-link:active,"+o+" .cc-link:visited"]=["color: "+r.link],a&&(a.text=a.text?a.text:t.getContrast(a.background),a.border=a.border?a.border:"transparent",s[o+" .cc-btn"]=["color: "+a.text,"border-color: "+a.border,"background-color: "+a.background],"transparent"!=a.background&&(s[o+" .cc-btn:hover, "+o+" .cc-btn:focus"]=["background-color: "+v(a.background)]),c?(c.text=c.text?c.text:t.getContrast(c.background),c.border=c.border?c.border:"transparent",s[o+" .cc-highlight .cc-btn:first-child"]=["color: "+c.text,"border-color: "+c.border,"background-color: "+c.background]):s[o+" .cc-highlight .cc-btn:first-child"]=["color: "+r.text]));var l=document.createElement("style");document.head.appendChild(l),e.customStyles[i]={references:1,element:l.sheet};var u=-1;for(var h in s)s.hasOwnProperty(h)&&l.sheet.insertRule(h+"{"+s[h].join(";")+"}",++u)}function v(e){return e=t.normaliseHex(e),"000000"==e?"#222":t.getLuminance(e)}function f(i){if(t.isPlainObject(i)){var n=t.hash(JSON.stringify(i)),o=e.customStyles[n];if(o&&!--o.references){var s=o.element.ownerNode;s&&s.parentNode&&s.parentNode.removeChild(s),e.customStyles[n]=null}}}function m(e,t){for(var i=0,n=e.length;i=0&&(this.dismissTimeout=window.setTimeout(function(){t(e.status.dismiss)},Math.floor(i)));var n=this.options.dismissOnScroll;if("number"==typeof n&&n>=0){var o=function(i){window.pageYOffset>Math.floor(n)&&(t(e.status.dismiss),window.removeEventListener("scroll",o),this.onWindowScroll=null)};this.onWindowScroll=o,window.addEventListener("scroll",o)}}function y(){if("info"!=this.options.type&&(this.options.revokable=!0),t.isMobile()&&(this.options.animateRevokable=!1),this.options.revokable){var e=a.call(this);this.options.animateRevokable&&e.push("cc-animate"),this.customStyleSelector&&e.push(this.customStyleSelector);var i=this.options.revokeBtn.replace("{{classes}}",e.join(" "));this.revokeBtn=u.call(this,i);var n=this.revokeBtn;if(this.options.animateRevokable){var o=t.throttle(function(e){var i=!1,o=20,s=window.innerHeight-20;t.hasClass(n,"cc-top")&&e.clientYs&&(i=!0),i?t.hasClass(n,"cc-active")||t.addClass(n,"cc-active"):t.hasClass(n,"cc-active")&&t.removeClass(n,"cc-active")},200);this.onMouseMove=o,window.addEventListener("mousemove",o)}}}var g={enabled:!0,container:null,cookie:{name:"cookieconsent_status",path:"/",domain:"",expiryDays:365},onPopupOpen:function(){},onPopupClose:function(){},onInitialise:function(e){},onStatusChange:function(e,t){},onRevokeChoice:function(){},content:{header:"Cookies used on the website!",message:"This website uses cookies to ensure you get the best experience on our website.",dismiss:"Got it!",allow:"Allow cookies",deny:"Decline",link:"Learn more",href:"http://cookiesandyou.com",close:"❌"},elements:{header:'{{header}} ',message:'{{message}}',messagelink:'{{message}} {{link}}',dismiss:'{{dismiss}}',allow:'{{allow}}',deny:'{{deny}}',link:'{{link}}',close:'{{close}}'},window:'',revokeBtn:'
Cookie Policy
',compliance:{info:'
{{dismiss}}
',"opt-in":'
{{dismiss}}{{allow}}
',"opt-out":'
{{deny}}{{dismiss}}
'},type:"info",layouts:{basic:"{{messagelink}}{{compliance}}","basic-close":"{{messagelink}}{{compliance}}{{close}}","basic-header":"{{header}}{{message}}{{link}}{{compliance}}"},layout:"basic",position:"bottom",theme:"block","static":!1,palette:null,revokable:!1,animateRevokable:!0,showLink:!0,dismissOnScroll:!1,dismissOnTimeout:!1,autoOpen:!0,autoAttach:!0,whitelistPage:[],blacklistPage:[],overrideHTML:null};return n.prototype.initialise=function(e){this.options&&this.destroy(),t.deepExtend(this.options={},g),t.isPlainObject(e)&&t.deepExtend(this.options,e),r.call(this)&&(this.options.enabled=!1),m(this.options.blacklistPage,location.pathname)&&(this.options.enabled=!1),m(this.options.whitelistPage,location.pathname)&&(this.options.enabled=!0);var i=this.options.window.replace("{{classes}}",c.call(this).join(" ")).replace("{{children}}",l.call(this)),n=this.options.overrideHTML;if("string"==typeof n&&n.length&&(i=n),this.options["static"]){var o=u.call(this,'
'+i+"
");o.style.display="",this.element=o.firstChild,this.element.style.display="none",t.addClass(this.element,"cc-invisible")}else this.element=u.call(this,i);b.call(this),y.call(this),this.options.autoOpen&&this.autoOpen()},n.prototype.destroy=function(){this.onButtonClick&&this.element&&(this.element.removeEventListener("click",this.onButtonClick),this.onButtonClick=null),this.dismissTimeout&&(clearTimeout(this.dismissTimeout),this.dismissTimeout=null),this.onWindowScroll&&(window.removeEventListener("scroll",this.onWindowScroll),this.onWindowScroll=null),this.onMouseMove&&(window.removeEventListener("mousemove",this.onMouseMove),this.onMouseMove=null),this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.element=null,this.revokeBtn&&this.revokeBtn.parentNode&&this.revokeBtn.parentNode.removeChild(this.revokeBtn),this.revokeBtn=null,f(this.options.palette),this.options=null},n.prototype.open=function(t){if(this.element)return this.isOpen()||(e.hasTransition?this.fadeIn():this.element.style.display="",this.options.revokable&&this.toggleRevokeButton(),this.options.onPopupOpen.call(this)),this},n.prototype.close=function(t){if(this.element)return this.isOpen()&&(e.hasTransition?this.fadeOut():this.element.style.display="none",t&&this.options.revokable&&this.toggleRevokeButton(!0),this.options.onPopupClose.call(this)),this},n.prototype.fadeIn=function(){var i=this.element;if(e.hasTransition&&i&&(this.afterTransition&&s.call(this,i),t.hasClass(i,"cc-invisible"))){if(i.style.display="",this.options["static"]){var n=this.element.clientHeight;this.element.parentNode.style.maxHeight=n+"px"}var r=20;this.openingTimeout=setTimeout(o.bind(this,i),r)}},n.prototype.fadeOut=function(){var i=this.element;e.hasTransition&&i&&(this.openingTimeout&&(clearTimeout(this.openingTimeout),o.bind(this,i)),t.hasClass(i,"cc-invisible")||(this.options["static"]&&(this.element.parentNode.style.maxHeight=""),this.afterTransition=s.bind(this,i),i.addEventListener(e.transitionEnd,this.afterTransition),t.addClass(i,"cc-invisible")))},n.prototype.isOpen=function(){return this.element&&""==this.element.style.display&&(!e.hasTransition||!t.hasClass(this.element,"cc-invisible"))},n.prototype.toggleRevokeButton=function(e){this.revokeBtn&&(this.revokeBtn.style.display=e?"":"none")},n.prototype.revokeChoice=function(e){this.options.enabled=!0,this.clearStatus(),this.options.onRevokeChoice.call(this),e||this.autoOpen()},n.prototype.hasAnswered=function(t){return Object.keys(e.status).indexOf(this.getStatus())>=0},n.prototype.hasConsented=function(t){var i=this.getStatus();return i==e.status.allow||i==e.status.dismiss},n.prototype.autoOpen=function(e){!this.hasAnswered()&&this.options.enabled&&this.open()},n.prototype.setStatus=function(i){var n=this.options.cookie,o=t.getCookie(n.name),s=Object.keys(e.status).indexOf(o)>=0;Object.keys(e.status).indexOf(i)>=0?(t.setCookie(n.name,i,n.expiryDays,n.domain,n.path),this.options.onStatusChange.call(this,i,s)):this.clearStatus()},n.prototype.getStatus=function(){return t.getCookie(this.options.cookie.name)},n.prototype.clearStatus=function(){var e=this.options.cookie;t.setCookie(e.name,"",-1,e.domain,e.path)},n}(),e.Location=function(){function e(e){t.deepExtend(this.options={},s),t.isPlainObject(e)&&t.deepExtend(this.options,e),this.currentServiceIndex=-1}function i(e,t,i){var n,o=document.createElement("script");o.type="text/"+(e.type||"javascript"),o.src=e.src||e,o.async=!1,o.onreadystatechange=o.onload=function(){var e=o.readyState;clearTimeout(n),t.done||e&&!/loaded|complete/.test(e)||(t.done=!0,t(),o.onreadystatechange=o.onload=null)},document.body.appendChild(o),n=setTimeout(function(){t.done=!0,t(),o.onreadystatechange=o.onload=null},i)}function n(e,t,i,n,o){var s=new(window.XMLHttpRequest||window.ActiveXObject)("MSXML2.XMLHTTP.3.0");if(s.open(n?"POST":"GET",e,1),s.setRequestHeader("X-Requested-With","XMLHttpRequest"),s.setRequestHeader("Content-type","application/x-www-form-urlencoded"),Array.isArray(o))for(var r=0,a=o.length;r3&&t(s)}),s.send(n)}function o(e){return new Error("Error ["+(e.code||"UNKNOWN")+"]: "+e.error)}var s={timeout:5e3,services:["freegeoip","ipinfo","maxmind"],serviceDefinitions:{freegeoip:function(){return{url:"//freegeoip.net/json/?callback={callback}",isScript:!0,callback:function(e,t){try{var i=JSON.parse(t);return i.error?o(i):{code:i.country_code}}catch(n){return o({error:"Invalid response ("+n+")"})}}}},ipinfo:function(){return{url:"//ipinfo.io",headers:["Accept: application/json"],callback:function(e,t){try{var i=JSON.parse(t);return i.error?o(i):{code:i.country}}catch(n){return o({error:"Invalid response ("+n+")"})}}}},ipinfodb:function(e){return{url:"//api.ipinfodb.com/v3/ip-country/?key={api_key}&format=json&callback={callback}",isScript:!0,callback:function(e,t){try{var i=JSON.parse(t);return"ERROR"==i.statusCode?o({error:i.statusMessage}):{code:i.countryCode}}catch(n){return o({error:"Invalid response ("+n+")"})}}}},maxmind:function(){return{url:"//js.maxmind.com/js/apis/geoip2/v2.1/geoip2.js",isScript:!0,callback:function(e){return window.geoip2?void geoip2.country(function(t){try{e({code:t.country.iso_code})}catch(i){e(o(i))}},function(t){e(o(t))}):void e(new Error("Unexpected response format. The downloaded script should have exported `geoip2` to the global scope"))}}}}};return e.prototype.getNextService=function(){var e;do e=this.getServiceByIdx(++this.currentServiceIndex);while(this.currentServiceIndex=0,revokable:t.revokable.indexOf(e)>=0,explicitAction:t.explicitAction.indexOf(e)>=0}},e.prototype.applyLaw=function(e,t){var i=this.get(t);return i.hasLaw||(e.enabled=!1),this.options.regionalLaw&&(i.revokable&&(e.revokable=!0),i.explicitAction&&(e.dismissOnScroll=!1,e.dismissOnTimeout=!1)),e},e}(),e.initialise=function(t,i,n){var o=new e.Law(t.law);i||(i=function(){}),n||(n=function(){}),e.getCountryCode(t,function(n){delete t.law,delete t.location,n.code&&(t=o.applyLaw(t,n.code)),i(new e.Popup(t))},function(i){delete t.law,delete t.location,n(i,new e.Popup(t))})},e.getCountryCode=function(t,i,n){if(t.law&&t.law.countryCode)return void i({code:t.law.countryCode});if(t.location){var o=new e.Location(t.location);return void o.locate(function(e){i(e||{})},n)}i({})},e.utils=t,e.hasInitialised=!0,window.cookieconsent=e}}(window.cookieconsent||{}); \ No newline at end of file diff --git a/install/update/old/assets/javascript/core.js b/install/update/old/assets/javascript/core.js deleted file mode 100644 index 5218a8c..0000000 --- a/install/update/old/assets/javascript/core.js +++ /dev/null @@ -1,1684 +0,0 @@ -/* global bbfontstyle */ - -var phpbb = {}; -phpbb.alertTime = 100; - -(function($) { // Avoid conflicts with other libraries - -'use strict'; - -// define a couple constants for keydown functions. -var keymap = { - TAB: 9, - ENTER: 13, - ESC: 27 -}; - -var $dark = $('#darkenwrapper'); -var $loadingIndicator; -var phpbbAlertTimer = null; - -phpbb.isTouch = (window && typeof window.ontouchstart !== 'undefined'); - -// Add ajax pre-filter to prevent cross-domain script execution -$.ajaxPrefilter(function(s) { - if (s.crossDomain) { - s.contents.script = false; - } -}); - -/** - * Display a loading screen - * - * @returns {object} Returns loadingIndicator. - */ -phpbb.loadingIndicator = function() { - if (!$loadingIndicator) { - $loadingIndicator = $('
', { - 'id': 'loading_indicator', - 'class': 'loading_indicator' - }); - $loadingIndicator.appendTo('#page-footer'); - } - - if (!$loadingIndicator.is(':visible')) { - $loadingIndicator.fadeIn(phpbb.alertTime); - // Wait 60 seconds and display an error if nothing has been returned by then. - phpbb.clearLoadingTimeout(); - phpbbAlertTimer = setTimeout(function() { - phpbb.showTimeoutMessage(); - }, 60000); - } - - return $loadingIndicator; -}; - -/** - * Show timeout message - */ -phpbb.showTimeoutMessage = function () { - var $alert = $('#phpbb_alert'); - - if ($loadingIndicator.is(':visible')) { - phpbb.alert($alert.attr('data-l-err'), $alert.attr('data-l-timeout-processing-req')); - } -}; - -/** - * Clear loading alert timeout -*/ -phpbb.clearLoadingTimeout = function() { - if (phpbbAlertTimer !== null) { - clearTimeout(phpbbAlertTimer); - phpbbAlertTimer = null; - } -}; - - -/** -* Close popup alert after a specified delay -* -* @param {int} delay Delay in ms until darkenwrapper's click event is triggered -*/ -phpbb.closeDarkenWrapper = function(delay) { - phpbbAlertTimer = setTimeout(function() { - $('#darkenwrapper').trigger('click'); - }, delay); -}; - -/** - * Display a simple alert similar to JSs native alert(). - * - * You can only call one alert or confirm box at any one time. - * - * @param {string} title Title of the message, eg "Information" (HTML). - * @param {string} msg Message to display (HTML). - * - * @returns {object} Returns the div created. - */ -phpbb.alert = function(title, msg) { - var $alert = $('#phpbb_alert'); - $alert.find('.alert_title').html(title); - $alert.find('.alert_text').html(msg); - - $(document).on('keydown.phpbb.alert', function(e) { - if (e.keyCode === keymap.ENTER || e.keyCode === keymap.ESC) { - phpbb.alert.close($alert, true); - e.preventDefault(); - e.stopPropagation(); - } - }); - phpbb.alert.open($alert); - - return $alert; -}; - -/** -* Handler for opening an alert box. -* -* @param {jQuery} $alert jQuery object. -*/ -phpbb.alert.open = function($alert) { - if (!$dark.is(':visible')) { - $dark.fadeIn(phpbb.alertTime); - } - - if ($loadingIndicator && $loadingIndicator.is(':visible')) { - $loadingIndicator.fadeOut(phpbb.alertTime, function() { - $dark.append($alert); - $alert.fadeIn(phpbb.alertTime); - }); - } else if ($dark.is(':visible')) { - $dark.append($alert); - $alert.fadeIn(phpbb.alertTime); - } else { - $dark.append($alert); - $alert.show(); - $dark.fadeIn(phpbb.alertTime); - } - - $alert.on('click', function(e) { - e.stopPropagation(); - }); - - $dark.one('click', function(e) { - phpbb.alert.close($alert, true); - e.preventDefault(); - e.stopPropagation(); - }); - - $alert.find('.alert_close').one('click', function(e) { - phpbb.alert.close($alert, true); - e.preventDefault(); - }); -}; - -/** -* Handler for closing an alert box. -* -* @param {jQuery} $alert jQuery object. -* @param {bool} fadedark Whether to remove dark background. -*/ -phpbb.alert.close = function($alert, fadedark) { - var $fade = (fadedark) ? $dark : $alert; - - $fade.fadeOut(phpbb.alertTime, function() { - $alert.hide(); - }); - - $alert.find('.alert_close').off('click'); - $(document).off('keydown.phpbb.alert'); -}; - -/** - * Display a simple yes / no box to the user. - * - * You can only call one alert or confirm box at any one time. - * - * @param {string} msg Message to display (HTML). - * @param {function} callback Callback. Bool param, whether the user pressed - * yes or no (or whatever their language is). - * @param {bool} fadedark Remove the dark background when done? Defaults - * to yes. - * - * @returns {object} Returns the div created. - */ -phpbb.confirm = function(msg, callback, fadedark) { - var $confirmDiv = $('#phpbb_confirm'); - $confirmDiv.find('.alert_text').html(msg); - fadedark = typeof fadedark !== 'undefined' ? fadedark : true; - - $(document).on('keydown.phpbb.alert', function(e) { - if (e.keyCode === keymap.ENTER || e.keyCode === keymap.ESC) { - var name = (e.keyCode === keymap.ENTER) ? 'confirm' : 'cancel'; - - $('input[name="' + name + '"]').trigger('click'); - e.preventDefault(); - e.stopPropagation(); - } - }); - - $confirmDiv.find('input[type="button"]').one('click.phpbb.confirmbox', function(e) { - var confirmed = this.name === 'confirm'; - - callback(confirmed); - $confirmDiv.find('input[type="button"]').off('click.phpbb.confirmbox'); - phpbb.alert.close($confirmDiv, fadedark || !confirmed); - - e.preventDefault(); - e.stopPropagation(); - }); - - phpbb.alert.open($confirmDiv); - - return $confirmDiv; -}; - -/** - * Turn a querystring into an array. - * - * @argument {string} string The querystring to parse. - * @returns {object} The object created. - */ -phpbb.parseQuerystring = function(string) { - var params = {}, i, split; - - string = string.split('&'); - for (i = 0; i < string.length; i++) { - split = string[i].split('='); - params[split[0]] = decodeURIComponent(split[1]); - } - return params; -}; - - -/** - * Makes a link use AJAX instead of loading an entire page. - * - * This function will work for links (both standard links and links which - * invoke confirm_box) and forms. It will be called automatically for links - * and forms with the data-ajax attribute set, and will call the necessary - * callback. - * - * For more info, view the following page on the phpBB wiki: - * http://wiki.phpbb.com/JavaScript_Function.phpbb.ajaxify - * - * @param {object} options Options. - */ -phpbb.ajaxify = function(options) { - var $elements = $(options.selector), - refresh = options.refresh, - callback = options.callback, - overlay = (typeof options.overlay !== 'undefined') ? options.overlay : true, - isForm = $elements.is('form'), - isText = $elements.is('input[type="text"], textarea'), - eventName; - - if (isForm) { - eventName = 'submit'; - } else if (isText) { - eventName = 'keyup'; - } else { - eventName = 'click'; - } - - $elements.on(eventName, function(event) { - var action, method, data, submit, that = this, $this = $(this); - - if ($this.find('input[type="submit"][data-clicked]').attr('data-ajax') === 'false') { - return; - } - - /** - * Handler for AJAX errors - */ - function errorHandler(jqXHR, textStatus, errorThrown) { - if (typeof console !== 'undefined' && console.log) { - console.log('AJAX error. status: ' + textStatus + ', message: ' + errorThrown); - } - phpbb.clearLoadingTimeout(); - var responseText, errorText = false; - try { - responseText = JSON.parse(jqXHR.responseText); - responseText = responseText.message; - } catch (e) {} - if (typeof responseText === 'string' && responseText.length > 0) { - errorText = responseText; - } else if (typeof errorThrown === 'string' && errorThrown.length > 0) { - errorText = errorThrown; - } else { - errorText = $dark.attr('data-ajax-error-text-' + textStatus); - if (typeof errorText !== 'string' || !errorText.length) { - errorText = $dark.attr('data-ajax-error-text'); - } - } - phpbb.alert($dark.attr('data-ajax-error-title'), errorText); - } - - /** - * This is a private function used to handle the callbacks, refreshes - * and alert. It calls the callback, refreshes the page if necessary, and - * displays an alert to the user and removes it after an amount of time. - * - * It cannot be called from outside this function, and is purely here to - * avoid repetition of code. - * - * @param {object} res The object sent back by the server. - */ - function returnHandler(res) { - var alert; - - phpbb.clearLoadingTimeout(); - - // Is a confirmation required? - if (typeof res.S_CONFIRM_ACTION === 'undefined') { - // If a confirmation is not required, display an alert and call the - // callbacks. - if (typeof res.MESSAGE_TITLE !== 'undefined') { - alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); - } else { - $dark.fadeOut(phpbb.alertTime); - - if ($loadingIndicator) { - $loadingIndicator.fadeOut(phpbb.alertTime); - } - } - - if (typeof phpbb.ajaxCallbacks[callback] === 'function') { - phpbb.ajaxCallbacks[callback].call(that, res); - } - - // If the server says to refresh the page, check whether the page should - // be refreshed and refresh page after specified time if required. - if (res.REFRESH_DATA) { - if (typeof refresh === 'function') { - refresh = refresh(res.REFRESH_DATA.url); - } else if (typeof refresh !== 'boolean') { - refresh = false; - } - - phpbbAlertTimer = setTimeout(function() { - if (refresh) { - window.location = res.REFRESH_DATA.url; - } - - // Hide the alert even if we refresh the page, in case the user - // presses the back button. - $dark.fadeOut(phpbb.alertTime, function() { - if (typeof alert !== 'undefined') { - alert.hide(); - } - }); - }, res.REFRESH_DATA.time * 1000); // Server specifies time in seconds - } - } else { - // If confirmation is required, display a dialog to the user. - phpbb.confirm(res.MESSAGE_BODY, function(del) { - if (!del) { - return; - } - - phpbb.loadingIndicator(); - data = $('
' + res.S_HIDDEN_FIELDS + '
').serialize(); - $.ajax({ - url: res.S_CONFIRM_ACTION, - type: 'POST', - data: data + '&confirm=' + res.YES_VALUE + '&' + $('form', '#phpbb_confirm').serialize(), - success: returnHandler, - error: errorHandler - }); - }, false); - } - } - - // If the element is a form, POST must be used and some extra data must - // be taken from the form. - var runFilter = (typeof options.filter === 'function'); - data = {}; - - if (isForm) { - action = $this.attr('action').replace('&', '&'); - data = $this.serializeArray(); - method = $this.attr('method') || 'GET'; - - if ($this.find('input[type="submit"][data-clicked]')) { - submit = $this.find('input[type="submit"][data-clicked]'); - data.push({ - name: submit.attr('name'), - value: submit.val() - }); - } - } else if (isText) { - var name = $this.attr('data-name') || this.name; - action = $this.attr('data-url').replace('&', '&'); - data[name] = this.value; - method = 'POST'; - } else { - action = this.href; - data = null; - method = 'GET'; - } - - var sendRequest = function() { - var dataOverlay = $this.attr('data-overlay'); - if (overlay && (typeof dataOverlay === 'undefined' || dataOverlay === 'true')) { - phpbb.loadingIndicator(); - } - - var request = $.ajax({ - url: action, - type: method, - data: data, - success: returnHandler, - error: errorHandler, - cache: false - }); - - request.always(function() { - if ($loadingIndicator && $loadingIndicator.is(':visible')) { - $loadingIndicator.fadeOut(phpbb.alertTime); - } - }); - }; - - // If filter function returns false, cancel the AJAX functionality, - // and return true (meaning that the HTTP request will be sent normally). - if (runFilter && !options.filter.call(this, data, event, sendRequest)) { - return; - } - - sendRequest(); - event.preventDefault(); - }); - - if (isForm) { - $elements.find('input:submit').click(function () { - var $this = $(this); - - // Remove data-clicked attribute from any submit button of form - $this.parents('form:first').find('input:submit[data-clicked]').removeAttr('data-clicked'); - - $this.attr('data-clicked', 'true'); - }); - } - - return this; -}; - -phpbb.search = { - cache: { - data: [] - }, - tpl: [], - container: [] -}; - -/** - * Get cached search data. - * - * @param {string} id Search ID. - * @returns {bool|object} Cached data object. Returns false if no data exists. - */ -phpbb.search.cache.get = function(id) { - if (this.data[id]) { - return this.data[id]; - } - return false; -}; - -/** - * Set search cache data value. - * - * @param {string} id Search ID. - * @param {string} key Data key. - * @param {string} value Data value. - */ -phpbb.search.cache.set = function(id, key, value) { - if (!this.data[id]) { - this.data[id] = { results: [] }; - } - this.data[id][key] = value; -}; - -/** - * Cache search result. - * - * @param {string} id Search ID. - * @param {string} keyword Keyword. - * @param {Array} results Search results. - */ -phpbb.search.cache.setResults = function(id, keyword, results) { - this.data[id].results[keyword] = results; -}; - -/** - * Trim spaces from keyword and lower its case. - * - * @param {string} keyword Search keyword to clean. - * @returns {string} Cleaned string. - */ -phpbb.search.cleanKeyword = function(keyword) { - return $.trim(keyword).toLowerCase(); -}; - -/** - * Get clean version of search keyword. If textarea supports several keywords - * (one per line), it fetches the current keyword based on the caret position. - * - * @param {jQuery} $input Search input|textarea. - * @param {string} keyword Input|textarea value. - * @param {bool} multiline Whether textarea supports multiple search keywords. - * - * @returns string Clean string. - */ -phpbb.search.getKeyword = function($input, keyword, multiline) { - if (multiline) { - var line = phpbb.search.getKeywordLine($input); - keyword = keyword.split('\n').splice(line, 1); - } - return phpbb.search.cleanKeyword(keyword); -}; - -/** - * Get the textarea line number on which the keyword resides - for textareas - * that support multiple keywords (one per line). - * - * @param {jQuery} $textarea Search textarea. - * @returns {int} The line number. - */ -phpbb.search.getKeywordLine = function ($textarea) { - var selectionStart = $textarea.get(0).selectionStart; - return $textarea.val().substr(0, selectionStart).split('\n').length - 1; -}; - -/** - * Set the value on the input|textarea. If textarea supports multiple - * keywords, only the active keyword is replaced. - * - * @param {jQuery} $input Search input|textarea. - * @param {string} value Value to set. - * @param {bool} multiline Whether textarea supports multiple search keywords. - */ -phpbb.search.setValue = function($input, value, multiline) { - if (multiline) { - var line = phpbb.search.getKeywordLine($input), - lines = $input.val().split('\n'); - lines[line] = value; - value = lines.join('\n'); - } - $input.val(value); -}; - -/** - * Sets the onclick event to set the value on the input|textarea to the - * selected search result. - * - * @param {jQuery} $input Search input|textarea. - * @param {object} value Result object. - * @param {jQuery} $row Result element. - * @param {jQuery} $container jQuery object for the search container. - */ -phpbb.search.setValueOnClick = function($input, value, $row, $container) { - $row.click(function() { - phpbb.search.setValue($input, value.result, $input.attr('data-multiline')); - $container.hide(); - }); -}; - -/** - * Runs before the AJAX search request is sent and determines whether - * there is a need to contact the server. If there are cached results - * already, those are displayed instead. Executes the AJAX request function - * itself due to the need to use a timeout to limit the number of requests. - * - * @param {Array} data Data to be sent to the server. - * @param {object} event Onkeyup event object. - * @param {function} sendRequest Function to execute AJAX request. - * - * @returns {bool} Returns false. - */ -phpbb.search.filter = function(data, event, sendRequest) { - var $this = $(this), - dataName = ($this.attr('data-name') !== undefined) ? $this.attr('data-name') : $this.attr('name'), - minLength = parseInt($this.attr('data-min-length'), 10), - searchID = $this.attr('data-results'), - keyword = phpbb.search.getKeyword($this, data[dataName], $this.attr('data-multiline')), - cache = phpbb.search.cache.get(searchID), - proceed = true; - data[dataName] = keyword; - - if (cache.timeout) { - clearTimeout(cache.timeout); - } - - var timeout = setTimeout(function() { - // Check min length and existence of cache. - if (minLength > keyword.length) { - proceed = false; - } else if (cache.lastSearch) { - // Has the keyword actually changed? - if (cache.lastSearch === keyword) { - proceed = false; - } else { - // Do we already have results for this? - if (cache.results[keyword]) { - var response = { - keyword: keyword, - results: cache.results[keyword] - }; - phpbb.search.handleResponse(response, $this, true); - proceed = false; - } - - // If the previous search didn't yield results and the string only had characters added to it, - // then we won't bother sending a request. - if (keyword.indexOf(cache.lastSearch) === 0 && cache.results[cache.lastSearch].length === 0) { - phpbb.search.cache.set(searchID, 'lastSearch', keyword); - phpbb.search.cache.setResults(searchID, keyword, []); - proceed = false; - } - } - } - - if (proceed) { - sendRequest.call(this); - } - }, 350); - phpbb.search.cache.set(searchID, 'timeout', timeout); - - return false; -}; - -/** - * Handle search result response. - * - * @param {object} res Data received from server. - * @param {jQuery} $input Search input|textarea. - * @param {bool} fromCache Whether the results are from the cache. - * @param {function} callback Optional callback to run when assigning each search result. - */ -phpbb.search.handleResponse = function(res, $input, fromCache, callback) { - if (typeof res !== 'object') { - return; - } - - var searchID = $input.attr('data-results'), - $container = $(searchID); - - if (this.cache.get(searchID).callback) { - callback = this.cache.get(searchID).callback; - } else if (typeof callback === 'function') { - this.cache.set(searchID, 'callback', callback); - } - - if (!fromCache) { - this.cache.setResults(searchID, res.keyword, res.results); - } - - this.cache.set(searchID, 'lastSearch', res.keyword); - this.showResults(res.results, $input, $container, callback); -}; - -/** - * Show search results. - * - * @param {Array} results Search results. - * @param {jQuery} $input Search input|textarea. - * @param {jQuery} $container Search results container element. - * @param {function} callback Optional callback to run when assigning each search result. - */ -phpbb.search.showResults = function(results, $input, $container, callback) { - var $resultContainer = $('.search-results', $container); - this.clearResults($resultContainer); - - if (!results.length) { - $container.hide(); - return; - } - - var searchID = $container.attr('id'), - tpl, - row; - - if (!this.tpl[searchID]) { - tpl = $('.search-result-tpl', $container); - this.tpl[searchID] = tpl.clone().removeClass('search-result-tpl'); - tpl.remove(); - } - tpl = this.tpl[searchID]; - - $.each(results, function(i, item) { - row = tpl.clone(); - row.find('.search-result').html(item.display); - - if (typeof callback === 'function') { - callback.call(this, $input, item, row, $container); - } - row.appendTo($resultContainer).show(); - }); - $container.show(); -}; - -/** - * Clear search results. - * - * @param {jQuery} $container Search results container. - */ -phpbb.search.clearResults = function($container) { - $container.children(':not(.search-result-tpl)').remove(); -}; - -$('#phpbb').click(function() { - var $this = $(this); - - if (!$this.is('.live-search') && !$this.parents().is('.live-search')) { - $('.live-search').hide(); - } -}); - -phpbb.history = {}; - -/** -* Check whether a method in the native history object is supported. -* -* @param {string} fn Method name. -* @returns {bool} Returns true if the method is supported. -*/ -phpbb.history.isSupported = function(fn) { - return !(typeof history === 'undefined' || typeof history[fn] === 'undefined'); -}; - -/** -* Wrapper for the pushState and replaceState methods of the -* native history object. -* -* @param {string} mode Mode. Either push or replace. -* @param {string} url New URL. -* @param {string} [title] Optional page title. -* @param {object} [obj] Optional state object. -*/ -phpbb.history.alterUrl = function(mode, url, title, obj) { - var fn = mode + 'State'; - - if (!url || !phpbb.history.isSupported(fn)) { - return; - } - if (!title) { - title = document.title; - } - if (!obj) { - obj = null; - } - - history[fn](obj, title, url); -}; - -/** -* Wrapper for the native history.replaceState method. -* -* @param {string} url New URL. -* @param {string} [title] Optional page title. -* @param {object} [obj] Optional state object. -*/ -phpbb.history.replaceUrl = function(url, title, obj) { - phpbb.history.alterUrl('replace', url, title, obj); -}; - -/** -* Wrapper for the native history.pushState method. -* -* @param {string} url New URL. -* @param {string} [title] Optional page title. -* @param {object} [obj] Optional state object. -*/ -phpbb.history.pushUrl = function(url, title, obj) { - phpbb.history.alterUrl('push', url, title, obj); -}; - -/** -* Hide the optgroups that are not the selected timezone -* -* @param {bool} keepSelection Shall we keep the value selected, or shall the -* user be forced to repick one. -*/ -phpbb.timezoneSwitchDate = function(keepSelection) { - var $timezoneCopy = $('#timezone_copy'); - var $timezone = $('#timezone'); - var $tzDate = $('#tz_date'); - var $tzSelectDateSuggest = $('#tz_select_date_suggest'); - - if ($timezoneCopy.length === 0) { - // We make a backup of the original dropdown, so we can remove optgroups - // instead of setting display to none, because IE and chrome will not - // hide options inside of optgroups and selects via css - $timezone.clone() - .attr('id', 'timezone_copy') - .css('display', 'none') - .attr('name', 'tz_copy') - .insertAfter('#timezone'); - } else { - // Copy the content of our backup, so we can remove all unneeded options - $timezone.html($timezoneCopy.html()); - } - - if ($tzDate.val() !== '') { - $timezone.children('optgroup').remove(':not([data-tz-value="' + $tzDate.val() + '"])'); - } - - if ($tzDate.val() === $tzSelectDateSuggest.attr('data-suggested-tz')) { - $tzSelectDateSuggest.css('display', 'none'); - } else { - $tzSelectDateSuggest.css('display', 'inline'); - } - - var $tzOptions = $timezone.children('optgroup[data-tz-value="' + $tzDate.val() + '"]').children('option'); - - if ($tzOptions.length === 1) { - // If there is only one timezone for the selected date, we just select that automatically. - $tzOptions.prop('selected', true); - keepSelection = true; - } - - if (typeof keepSelection !== 'undefined' && !keepSelection) { - var $timezoneOptions = $timezone.find('optgroup option'); - if ($timezoneOptions.filter(':selected').length <= 0) { - $timezoneOptions.filter(':first').prop('selected', true); - } - } -}; - -/** -* Display the date/time select -*/ -phpbb.timezoneEnableDateSelection = function() { - $('#tz_select_date').css('display', 'block'); -}; - -/** -* Preselect a date/time or suggest one, if it is not picked. -* -* @param {bool} forceSelector Shall we select the suggestion? -*/ -phpbb.timezonePreselectSelect = function(forceSelector) { - - // The offset returned here is in minutes and negated. - var offset = (new Date()).getTimezoneOffset(); - var sign = '-'; - - if (offset < 0) { - sign = '+'; - offset = -offset; - } - - var minutes = offset % 60; - var hours = (offset - minutes) / 60; - - if (hours < 10) { - hours = '0' + hours.toString(); - } else { - hours = hours.toString(); - } - - if (minutes < 10) { - minutes = '0' + minutes.toString(); - } else { - minutes = minutes.toString(); - } - - var prefix = 'UTC' + sign + hours + ':' + minutes; - var prefixLength = prefix.length; - var selectorOptions = $('option', '#tz_date'); - var i; - - var $tzSelectDateSuggest = $('#tz_select_date_suggest'); - - for (i = 0; i < selectorOptions.length; ++i) { - var option = selectorOptions[i]; - - if (option.value.substring(0, prefixLength) === prefix) { - if ($('#tz_date').val() !== option.value && !forceSelector) { - // We do not select the option for the user, but notify him, - // that we would suggest a different setting. - phpbb.timezoneSwitchDate(true); - $tzSelectDateSuggest.css('display', 'inline'); - } else { - option.selected = true; - phpbb.timezoneSwitchDate(!forceSelector); - $tzSelectDateSuggest.css('display', 'none'); - } - - var suggestion = $tzSelectDateSuggest.attr('data-l-suggestion'); - - $tzSelectDateSuggest.attr('title', suggestion.replace('%s', option.innerHTML)); - $tzSelectDateSuggest.attr('value', suggestion.replace('%s', option.innerHTML.substring(0, 9))); - $tzSelectDateSuggest.attr('data-suggested-tz', option.innerHTML); - - // Found the suggestion, there cannot be more, so return from here. - return; - } - } -}; - -phpbb.ajaxCallbacks = {}; - -/** - * Adds an AJAX callback to be used by phpbb.ajaxify. - * - * See the phpbb.ajaxify comments for information on stuff like parameters. - * - * @param {string} id The name of the callback. - * @param {function} callback The callback to be called. - */ -phpbb.addAjaxCallback = function(id, callback) { - if (typeof callback === 'function') { - phpbb.ajaxCallbacks[id] = callback; - } - return this; -}; - -/** - * This callback handles live member searches. - */ -phpbb.addAjaxCallback('member_search', function(res) { - phpbb.search.handleResponse(res, $(this), false, phpbb.getFunctionByName('phpbb.search.setValueOnClick')); -}); - -/** - * This callback alternates text - it replaces the current text with the text in - * the alt-text data attribute, and replaces the text in the attribute with the - * current text so that the process can be repeated. - */ -phpbb.addAjaxCallback('alt_text', function() { - var $anchor, - updateAll = $(this).data('update-all'), - altText; - - if (updateAll !== undefined && updateAll.length) { - $anchor = $(updateAll); - } else { - $anchor = $(this); - } - - $anchor.each(function() { - var $this = $(this); - altText = $this.attr('data-alt-text'); - $this.attr('data-alt-text', $.trim($this.text())); - $this.attr('title', altText); - $this.children('span').text(altText); - }); -}); - -/** - * This callback is based on the alt_text callback. - * - * It replaces the current text with the text in the alt-text data attribute, - * and replaces the text in the attribute with the current text so that the - * process can be repeated. - * Additionally it replaces the class of the link's parent - * and changes the link itself. - */ -phpbb.addAjaxCallback('toggle_link', function() { - var $anchor, - updateAll = $(this).data('update-all') , - toggleText, - toggleUrl, - toggleClass; - - if (updateAll !== undefined && updateAll.length) { - $anchor = $(updateAll); - } else { - $anchor = $(this); - } - - $anchor.each(function() { - var $this = $(this); - - // Toggle link url - toggleUrl = $this.attr('data-toggle-url'); - $this.attr('data-toggle-url', $this.attr('href')); - $this.attr('href', toggleUrl); - - // Toggle class of link parent - toggleClass = $this.attr('data-toggle-class'); - $this.attr('data-toggle-class', $this.children().attr('class')); - $this.children('.icon').attr('class', toggleClass); - - // Toggle link text - toggleText = $this.attr('data-toggle-text'); - $this.attr('data-toggle-text', $this.children('span').text()); - $this.attr('title', $.trim(toggleText)); - $this.children('span').text(toggleText); - }); -}); - -/** -* Automatically resize textarea -* -* This function automatically resizes textarea elements when user -* types text. -* -* @param {jQuery} $items jQuery object(s) to resize -* @param {object} [options] Optional parameter that adjusts default -* configuration. See configuration variable -* -* Optional parameters: -* minWindowHeight {number} Minimum browser window height when textareas are resized. Default = 500 -* minHeight {number} Minimum height of textarea. Default = 200 -* maxHeight {number} Maximum height of textarea. Default = 500 -* heightDiff {number} Minimum difference between window and textarea height. Default = 200 -* resizeCallback {function} Function to call after resizing textarea -* resetCallback {function} Function to call when resize has been canceled - -* Callback function format: function(item) {} -* this points to DOM object -* item is a jQuery object, same as this -*/ -phpbb.resizeTextArea = function($items, options) { - // Configuration - var configuration = { - minWindowHeight: 500, - minHeight: 200, - maxHeight: 500, - heightDiff: 200, - resizeCallback: function() {}, - resetCallback: function() {} - }; - - if (phpbb.isTouch) { - return; - } - - if (arguments.length > 1) { - configuration = $.extend(configuration, options); - } - - function resetAutoResize(item) { - var $item = $(item); - if ($item.hasClass('auto-resized')) { - $(item) - .css({ height: '', resize: '' }) - .removeClass('auto-resized'); - configuration.resetCallback.call(item, $item); - } - } - - function autoResize(item) { - function setHeight(height) { - height += parseInt($item.css('height'), 10) - $item.innerHeight(); - $item - .css({ height: height + 'px', resize: 'none' }) - .addClass('auto-resized'); - configuration.resizeCallback.call(item, $item); - } - - var windowHeight = $(window).height(); - - if (windowHeight < configuration.minWindowHeight) { - resetAutoResize(item); - return; - } - - var maxHeight = Math.min( - Math.max(windowHeight - configuration.heightDiff, configuration.minHeight), - configuration.maxHeight - ), - $item = $(item), - height = parseInt($item.innerHeight(), 10), - scrollHeight = (item.scrollHeight) ? item.scrollHeight : 0; - - if (height < 0) { - return; - } - - if (height > maxHeight) { - setHeight(maxHeight); - } else if (scrollHeight > (height + 5)) { - setHeight(Math.min(maxHeight, scrollHeight)); - } - } - - $items.on('focus change keyup', function() { - $(this).each(function() { - autoResize(this); - }); - }).change(); - - $(window).resize(function() { - $items.each(function() { - if ($(this).hasClass('auto-resized')) { - autoResize(this); - } - }); - }); -}; - -/** -* Check if cursor in textarea is currently inside a bbcode tag -* -* @param {object} textarea Textarea DOM object -* @param {Array} startTags List of start tags to look for -* For example, Array('[code]', '[code=') -* @param {Array} endTags List of end tags to look for -* For example, Array('[/code]') -* -* @returns {boolean} True if cursor is in bbcode tag -*/ -phpbb.inBBCodeTag = function(textarea, startTags, endTags) { - var start = textarea.selectionStart, - lastEnd = -1, - lastStart = -1, - i, index, value; - - if (typeof start !== 'number') { - return false; - } - - value = textarea.value.toLowerCase(); - - for (i = 0; i < startTags.length; i++) { - var tagLength = startTags[i].length; - if (start >= tagLength) { - index = value.lastIndexOf(startTags[i], start - tagLength); - lastStart = Math.max(lastStart, index); - } - } - if (lastStart === -1) { - return false; - } - - if (start > 0) { - for (i = 0; i < endTags.length; i++) { - index = value.lastIndexOf(endTags[i], start - 1); - lastEnd = Math.max(lastEnd, index); - } - } - - return (lastEnd < lastStart); -}; - - -/** -* Adjust textarea to manage code bbcode -* -* This function allows to use tab characters when typing code -* and keeps indentation of previous line of code when adding new -* line while typing code. -* -* Editor's functionality is changed only when cursor is between -* [code] and [/code] bbcode tags. -* -* @param {object} textarea Textarea DOM object to apply editor to -*/ -phpbb.applyCodeEditor = function(textarea) { - // list of allowed start and end bbcode code tags, in lower case - var startTags = ['[code]', '[code='], - startTagsEnd = ']', - endTags = ['[/code]']; - - if (!textarea || typeof textarea.selectionStart !== 'number') { - return; - } - - if ($(textarea).data('code-editor') === true) { - return; - } - - function inTag() { - return phpbb.inBBCodeTag(textarea, startTags, endTags); - } - - /** - * Get line of text before cursor - * - * @param {boolean} stripCodeStart If true, only part of line - * after [code] tag will be returned. - * - * @returns {string} Line of text - */ - function getLastLine(stripCodeStart) { - var start = textarea.selectionStart, - value = textarea.value, - index = value.lastIndexOf('\n', start - 1); - - value = value.substring(index + 1, start); - - if (stripCodeStart) { - for (var i = 0; i < startTags.length; i++) { - index = value.lastIndexOf(startTags[i]); - if (index >= 0) { - var tagLength = startTags[i].length; - - value = value.substring(index + tagLength); - if (startTags[i].lastIndexOf(startTagsEnd) !== tagLength) { - index = value.indexOf(startTagsEnd); - - if (index >= 0) { - value = value.substr(index + 1); - } - } - } - } - } - - return value; - } - - /** - * Append text at cursor position - * - * @param {string} text Text to append - */ - function appendText(text) { - var start = textarea.selectionStart, - end = textarea.selectionEnd, - value = textarea.value; - - textarea.value = value.substr(0, start) + text + value.substr(end); - textarea.selectionStart = textarea.selectionEnd = start + text.length; - } - - $(textarea).data('code-editor', true).on('keydown', function(event) { - var key = event.keyCode || event.which; - - // intercept tabs - if (key === keymap.TAB && - !event.ctrlKey && - !event.shiftKey && - !event.altKey && - !event.metaKey) { - if (inTag()) { - appendText('\t'); - event.preventDefault(); - return; - } - } - - // intercept new line characters - if (key === keymap.ENTER) { - if (inTag()) { - var lastLine = getLastLine(true), - code = '' + /^\s*/g.exec(lastLine); - - if (code.length > 0) { - appendText('\n' + code); - event.preventDefault(); - } - } - } - }); -}; - -/** - * Show drag and drop animation when textarea is present - * - * This function will enable the drag and drop animation for a specified - * textarea. - * - * @param {HTMLElement} textarea Textarea DOM object to apply editor to - */ -phpbb.showDragNDrop = function(textarea) { - if (!textarea) { - return; - } - - $('body').on('dragenter dragover', function () { - $(textarea).addClass('drag-n-drop'); - }).on('dragleave dragout dragend drop', function() { - $(textarea).removeClass('drag-n-drop'); - }); - $(textarea).on('dragenter dragover', function () { - $(textarea).addClass('drag-n-drop-highlight'); - }).on('dragleave dragout dragend drop', function() { - $(textarea).removeClass('drag-n-drop-highlight'); - }); -}; - -/** -* List of classes that toggle dropdown menu, -* list of classes that contain visible dropdown menu -* -* Add your own classes to strings with comma (probably you -* will never need to do that) -*/ -phpbb.dropdownHandles = '.dropdown-container.dropdown-visible .dropdown-toggle'; -phpbb.dropdownVisibleContainers = '.dropdown-container.dropdown-visible'; - -/** -* Dropdown toggle event handler -* This handler is used by phpBB.registerDropdown() and other functions -*/ -phpbb.toggleDropdown = function() { - var $this = $(this), - options = $this.data('dropdown-options'), - parent = options.parent, - visible = parent.hasClass('dropdown-visible'), - direction; - - if (!visible) { - // Hide other dropdown menus - $(phpbb.dropdownHandles).each(phpbb.toggleDropdown); - - // Figure out direction of dropdown - direction = options.direction; - var verticalDirection = options.verticalDirection, - offset = $this.offset(); - - if (direction === 'auto') { - if (($(window).width() - $this.outerWidth(true)) / 2 > offset.left) { - direction = 'right'; - } else { - direction = 'left'; - } - } - parent.toggleClass(options.leftClass, direction === 'left') - .toggleClass(options.rightClass, direction === 'right'); - - if (verticalDirection === 'auto') { - var height = $(window).height(), - top = offset.top - $(window).scrollTop(); - - verticalDirection = (top < height * 0.7) ? 'down' : 'up'; - } - parent.toggleClass(options.upClass, verticalDirection === 'up') - .toggleClass(options.downClass, verticalDirection === 'down'); - } - - options.dropdown.toggle(); - parent.toggleClass(options.visibleClass, !visible) - .toggleClass('dropdown-visible', !visible); - - // Check dimensions when showing dropdown - // !visible because variable shows state of dropdown before it was toggled - if (!visible) { - var windowWidth = $(window).width(); - - options.dropdown.find('.dropdown-contents').each(function() { - var $this = $(this); - - $this.css({ - marginLeft: 0, - left: 0, - marginRight: 0, - maxWidth: (windowWidth - 4) + 'px' - }); - - var offset = $this.offset().left, - width = $this.outerWidth(true); - - if (offset < 2) { - $this.css('left', (2 - offset) + 'px'); - } else if ((offset + width + 2) > windowWidth) { - $this.css('margin-left', (windowWidth - offset - width - 2) + 'px'); - } - - // Check whether the vertical scrollbar is present. - $this.toggleClass('dropdown-nonscroll', this.scrollHeight === $this.innerHeight()); - - }); - var freeSpace = parent.offset().left - 4; - - if (direction === 'left') { - options.dropdown.css('margin-left', '-' + freeSpace + 'px'); - - // Try to position the notification dropdown correctly in RTL-responsive mode - if (options.dropdown.hasClass('dropdown-extended')) { - var contentWidth, - fullFreeSpace = freeSpace + parent.outerWidth(); - - options.dropdown.find('.dropdown-contents').each(function() { - contentWidth = parseInt($(this).outerWidth(), 10); - $(this).css({ marginLeft: 0, left: 0 }); - }); - - var maxOffset = Math.min(contentWidth, fullFreeSpace) + 'px'; - options.dropdown.css({ - width: maxOffset, - marginLeft: -maxOffset - }); - } - } else { - options.dropdown.css('margin-right', '-' + (windowWidth + freeSpace) + 'px'); - } - } - - // Prevent event propagation - if (arguments.length > 0) { - try { - var e = arguments[0]; - e.preventDefault(); - e.stopPropagation(); - } catch (error) { } - } - return false; -}; - -/** -* Toggle dropdown submenu -*/ -phpbb.toggleSubmenu = function(e) { - $(this).siblings('.dropdown-submenu').toggle(); - e.preventDefault(); -}; - -/** -* Register dropdown menu -* Shows/hides dropdown, decides which side to open to -* -* @param {jQuery} toggle Link that toggles dropdown. -* @param {jQuery} dropdown Dropdown menu. -* @param {Object} options List of options. Optional. -*/ -phpbb.registerDropdown = function(toggle, dropdown, options) { - var ops = { - parent: toggle.parent(), // Parent item to add classes to - direction: 'auto', // Direction of dropdown menu. Possible values: auto, left, right - verticalDirection: 'auto', // Vertical direction. Possible values: auto, up, down - visibleClass: 'visible', // Class to add to parent item when dropdown is visible - leftClass: 'dropdown-left', // Class to add to parent item when dropdown opens to left side - rightClass: 'dropdown-right', // Class to add to parent item when dropdown opens to right side - upClass: 'dropdown-up', // Class to add to parent item when dropdown opens above menu item - downClass: 'dropdown-down' // Class to add to parent item when dropdown opens below menu item - }; - if (options) { - ops = $.extend(ops, options); - } - ops.dropdown = dropdown; - - ops.parent.addClass('dropdown-container'); - toggle.addClass('dropdown-toggle'); - - toggle.data('dropdown-options', ops); - - toggle.click(phpbb.toggleDropdown); - $('.dropdown-toggle-submenu', ops.parent).click(phpbb.toggleSubmenu); -}; - -/** -* Get the HTML for a color palette table. -* -* @param {string} dir Palette direction - either v or h -* @param {int} width Palette cell width. -* @param {int} height Palette cell height. -*/ -phpbb.colorPalette = function(dir, width, height) { - var r, g, b, - numberList = new Array(6), - color = '', - html = ''; - - numberList[0] = '00'; - numberList[1] = '40'; - numberList[2] = '80'; - numberList[3] = 'BF'; - numberList[4] = 'FF'; - - var tableClass = (dir === 'h') ? 'horizontal-palette' : 'vertical-palette'; - html += ''; - - for (r = 0; r < 5; r++) { - if (dir === 'h') { - html += ''; - } - - for (g = 0; g < 5; g++) { - if (dir === 'v') { - html += ''; - } - - for (b = 0; b < 5; b++) { - color = '' + numberList[r] + numberList[g] + numberList[b]; - html += ''; - } - - if (dir === 'v') { - html += ''; - } - } - - if (dir === 'h') { - html += ''; - } - } - html += '
'; - html += '
'; - return html; -}; - -/** -* Register a color palette. -* -* @param {jQuery} el jQuery object for the palette container. -*/ -phpbb.registerPalette = function(el) { - var orientation = el.attr('data-orientation'), - height = el.attr('data-height'), - width = el.attr('data-width'), - target = el.attr('data-target'), - bbcode = el.attr('data-bbcode'); - - // Insert the palette HTML into the container. - el.html(phpbb.colorPalette(orientation, width, height)); - - // Add toggle control. - $('#color_palette_toggle').click(function(e) { - el.toggle(); - e.preventDefault(); - }); - - // Attach event handler when a palette cell is clicked. - $(el).on('click', 'a', function(e) { - var color = $(this).attr('data-color'); - - if (bbcode) { - bbfontstyle('[color=#' + color + ']', '[/color]'); - } else { - $(target).val(color); - } - e.preventDefault(); - }); -}; - -/** -* Set display of page element -* -* @param {string} id The ID of the element to change -* @param {int} action Set to 0 if element display should be toggled, -1 for -* hiding the element, and 1 for showing it. -* @param {string} type Display type that should be used, e.g. inline, block or -* other CSS "display" types -*/ -phpbb.toggleDisplay = function(id, action, type) { - if (!type) { - type = 'block'; - } - - var $element = $('#' + id); - - var display = $element.css('display'); - if (!action) { - action = (display === '' || display === type) ? -1 : 1; - } - $element.css('display', ((action === 1) ? type : 'none')); -}; - -/** -* Toggle additional settings based on the selected -* option of select element. -* -* @param {jQuery} el jQuery select element object. -*/ -phpbb.toggleSelectSettings = function(el) { - el.children().each(function() { - var $this = $(this), - $setting = $($this.data('toggle-setting')); - $setting.toggle($this.is(':selected')); - - // Disable any input elements that are not visible right now - if ($this.is(':selected')) { - $($this.data('toggle-setting') + ' input').prop('disabled', false); - } else { - $($this.data('toggle-setting') + ' input').prop('disabled', true); - } - }); -}; - -/** -* Get function from name. -* Based on http://stackoverflow.com/a/359910 -* -* @param {string} functionName Function to get. -* @returns function -*/ -phpbb.getFunctionByName = function (functionName) { - var namespaces = functionName.split('.'), - func = namespaces.pop(), - context = window; - - for (var i = 0; i < namespaces.length; i++) { - context = context[namespaces[i]]; - } - return context[func]; -}; - -/** -* Register page dropdowns. -*/ -phpbb.registerPageDropdowns = function() { - var $body = $('body'); - - $body.find('.dropdown-container').each(function() { - var $this = $(this), - $trigger = $this.find('.dropdown-trigger:first'), - $contents = $this.find('.dropdown'), - options = { - direction: 'auto', - verticalDirection: 'auto' - }, - data; - - if (!$trigger.length) { - data = $this.attr('data-dropdown-trigger'); - $trigger = data ? $this.children(data) : $this.children('a:first'); - } - - if (!$contents.length) { - data = $this.attr('data-dropdown-contents'); - $contents = data ? $this.children(data) : $this.children('div:first'); - } - - if (!$trigger.length || !$contents.length) { - return; - } - - if ($this.hasClass('dropdown-up')) { - options.verticalDirection = 'up'; - } - if ($this.hasClass('dropdown-down')) { - options.verticalDirection = 'down'; - } - if ($this.hasClass('dropdown-left')) { - options.direction = 'left'; - } - if ($this.hasClass('dropdown-right')) { - options.direction = 'right'; - } - - phpbb.registerDropdown($trigger, $contents, options); - }); - - // Hide active dropdowns when click event happens outside - $body.click(function(e) { - var $parents = $(e.target).parents(); - if (!$parents.is(phpbb.dropdownVisibleContainers)) { - $(phpbb.dropdownHandles).each(phpbb.toggleDropdown); - } - }); -}; - -/** - * Handle avatars to be lazy loaded. - */ -phpbb.lazyLoadAvatars = function loadAvatars() { - $('.avatar[data-src]').each(function () { - var $avatar = $(this); - - $avatar - .attr('src', $avatar.data('src')) - .removeAttr('data-src'); - }); -}; - -$(window).on('load', phpbb.lazyLoadAvatars); - -/** -* Apply code editor to all textarea elements with data-bbcode attribute -*/ -$(function() { - $('textarea[data-bbcode]').each(function() { - phpbb.applyCodeEditor(this); - }); - - phpbb.registerPageDropdowns(); - - $('[data-orientation]').each(function() { - phpbb.registerPalette($(this)); - }); - - // Update browser history URL to point to specific post in viewtopic.php - // when using view=unread#unread link. - phpbb.history.replaceUrl($('#unread[data-url]').data('url')); - - // Hide settings that are not selected via select element. - $('select[data-togglable-settings]').each(function() { - var $this = $(this); - - $this.change(function() { - phpbb.toggleSelectSettings($this); - }); - phpbb.toggleSelectSettings($this); - }); -}); - -})(jQuery); // Avoid conflicts with other libraries diff --git a/install/update/old/assets/javascript/editor.js b/install/update/old/assets/javascript/editor.js deleted file mode 100644 index 23244f5..0000000 --- a/install/update/old/assets/javascript/editor.js +++ /dev/null @@ -1,425 +0,0 @@ -/** -* bbCode control by subBlue design [ www.subBlue.com ] -* Includes unixsafe colour palette selector by SHS` -*/ - -// Startup variables -var imageTag = false; -var theSelection = false; -var bbcodeEnabled = true; - -// Check for Browser & Platform for PC & IE specific bits -// More details from: http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html -var clientPC = navigator.userAgent.toLowerCase(); // Get client info -var clientVer = parseInt(navigator.appVersion, 10); // Get browser version - -var is_ie = ((clientPC.indexOf('msie') !== -1) && (clientPC.indexOf('opera') === -1)); -var is_win = ((clientPC.indexOf('win') !== -1) || (clientPC.indexOf('16bit') !== -1)); -var baseHeight; - -/** -* Shows the help messages in the helpline window -*/ -function helpline(help) { - document.forms[form_name].helpbox.value = help_line[help]; -} - -/** -* Fix a bug involving the TextRange object. From -* http://www.frostjedi.com/terra/scripts/demo/caretBug.html -*/ -function initInsertions() { - var doc; - - if (document.forms[form_name]) { - doc = document; - } else { - doc = opener.document; - } - - var textarea = doc.forms[form_name].elements[text_name]; - - if (is_ie && typeof(baseHeight) !== 'number') { - textarea.focus(); - baseHeight = doc.selection.createRange().duplicate().boundingHeight; - - if (!document.forms[form_name]) { - document.body.focus(); - } - } -} - -/** -* bbstyle -*/ -function bbstyle(bbnumber) { - if (bbnumber !== -1) { - bbfontstyle(bbtags[bbnumber], bbtags[bbnumber+1]); - } else { - insert_text('[*]'); - document.forms[form_name].elements[text_name].focus(); - } -} - -/** -* Apply bbcodes -*/ -function bbfontstyle(bbopen, bbclose) { - theSelection = false; - - var textarea = document.forms[form_name].elements[text_name]; - - textarea.focus(); - - if ((clientVer >= 4) && is_ie && is_win) { - // Get text selection - theSelection = document.selection.createRange().text; - - if (theSelection) { - // Add tags around selection - document.selection.createRange().text = bbopen + theSelection + bbclose; - textarea.focus(); - theSelection = ''; - return; - } - } else if (textarea.selectionEnd && (textarea.selectionEnd - textarea.selectionStart > 0)) { - mozWrap(textarea, bbopen, bbclose); - textarea.focus(); - theSelection = ''; - return; - } - - //The new position for the cursor after adding the bbcode - var caret_pos = getCaretPosition(textarea).start; - var new_pos = caret_pos + bbopen.length; - - // Open tag - insert_text(bbopen + bbclose); - - // Center the cursor when we don't have a selection - // Gecko and proper browsers - if (!isNaN(textarea.selectionStart)) { - textarea.selectionStart = new_pos; - textarea.selectionEnd = new_pos; - } - // IE - else if (document.selection) { - var range = textarea.createTextRange(); - range.move("character", new_pos); - range.select(); - storeCaret(textarea); - } - - textarea.focus(); -} - -/** -* Insert text at position -*/ -function insert_text(text, spaces, popup) { - var textarea; - - if (!popup) { - textarea = document.forms[form_name].elements[text_name]; - } else { - textarea = opener.document.forms[form_name].elements[text_name]; - } - - if (spaces) { - text = ' ' + text + ' '; - } - - // Since IE9, IE also has textarea.selectionStart, but it still needs to be treated the old way. - // Therefore we simply add a !is_ie here until IE fixes the text-selection completely. - if (!isNaN(textarea.selectionStart) && !is_ie) { - var sel_start = textarea.selectionStart; - var sel_end = textarea.selectionEnd; - - mozWrap(textarea, text, ''); - textarea.selectionStart = sel_start + text.length; - textarea.selectionEnd = sel_end + text.length; - } else if (textarea.createTextRange && textarea.caretPos) { - if (baseHeight !== textarea.caretPos.boundingHeight) { - textarea.focus(); - storeCaret(textarea); - } - - var caret_pos = textarea.caretPos; - caret_pos.text = caret_pos.text.charAt(caret_pos.text.length - 1) === ' ' ? caret_pos.text + text + ' ' : caret_pos.text + text; - } else { - textarea.value = textarea.value + text; - } - - if (!popup) { - textarea.focus(); - } -} - -/** -* Add inline attachment at position -*/ -function attachInline(index, filename) { - insert_text('[attachment=' + index + ']' + filename + '[/attachment]'); - document.forms[form_name].elements[text_name].focus(); -} - -/** -* Add quote text to message -*/ -function addquote(post_id, username, l_wrote, attributes) { - var message_name = 'message_' + post_id; - var theSelection = ''; - var divarea = false; - var i; - - if (l_wrote === undefined) { - // Backwards compatibility - l_wrote = 'wrote'; - } - if (typeof attributes !== 'object') { - attributes = {}; - } - - if (document.all) { - divarea = document.all[message_name]; - } else { - divarea = document.getElementById(message_name); - } - - // Get text selection - not only the post content :( - // IE9 must use the document.selection method but has the *.getSelection so we just force no IE - if (window.getSelection && !is_ie && !window.opera) { - theSelection = window.getSelection().toString(); - } else if (document.getSelection && !is_ie) { - theSelection = document.getSelection(); - } else if (document.selection) { - theSelection = document.selection.createRange().text; - } - - if (theSelection === '' || typeof theSelection === 'undefined' || theSelection === null) { - if (divarea.innerHTML) { - theSelection = divarea.innerHTML.replace(/
/ig, '\n'); - theSelection = theSelection.replace(//ig, '\n'); - theSelection = theSelection.replace(/<\;/ig, '<'); - theSelection = theSelection.replace(/>\;/ig, '>'); - theSelection = theSelection.replace(/&\;/ig, '&'); - theSelection = theSelection.replace(/ \;/ig, ' '); - } else if (document.all) { - theSelection = divarea.innerText; - } else if (divarea.textContent) { - theSelection = divarea.textContent; - } else if (divarea.firstChild.nodeValue) { - theSelection = divarea.firstChild.nodeValue; - } - } - - if (theSelection) { - if (bbcodeEnabled) { - attributes.author = username; - insert_text(generateQuote(theSelection, attributes)); - } else { - insert_text(username + ' ' + l_wrote + ':' + '\n'); - var lines = split_lines(theSelection); - for (i = 0; i < lines.length; i++) { - insert_text('> ' + lines[i] + '\n'); - } - } - } -} - -/** -* Create a quote block for given text -* -* Possible attributes: -* - author: author's name (usually a username) -* - post_id: post_id of the post being quoted -* - user_id: user_id of the user being quoted -* - time: timestamp of the original message -* -* @param {!string} text Quote's text -* @param {!Object} attributes Quote's attributes -* @return {!string} Quote block to be used in a new post/text -*/ -function generateQuote(text, attributes) { - text = text.replace(/^\s+/, '').replace(/\s+$/, ''); - var quote = '[quote'; - if (attributes.author) { - // Add the author as the BBCode's default attribute - quote += '=' + formatAttributeValue(attributes.author); - delete attributes.author; - } - for (var name in attributes) { - if (attributes.hasOwnProperty(name)) { - var value = attributes[name]; - quote += ' ' + name + '=' + formatAttributeValue(value.toString()); - } - } - quote += ']'; - var newline = ((quote + text + '[/quote]').length > 80 || text.indexOf('\n') > -1) ? '\n' : ''; - quote += newline + text + newline + '[/quote]'; - - return quote; -} - -/** -* Format given string to be used as an attribute value -* -* Will return the string as-is if it can be used in a BBCode without quotes. Otherwise, -* it will use either single- or double- quotes depending on whichever requires less escaping. -* Quotes and backslashes are escaped with backslashes where necessary -* -* @param {!string} str Original string -* @return {!string} Same string if possible, escaped string within quotes otherwise -*/ -function formatAttributeValue(str) { - if (!/[ "'\\\]]/.test(str)) { - // Return as-is if it contains none of: space, ' " \ or ] - return str; - } - var singleQuoted = "'" + str.replace(/[\\']/g, '\\$&') + "'", - doubleQuoted = '"' + str.replace(/[\\"]/g, '\\$&') + '"'; - - return (singleQuoted.length < doubleQuoted.length) ? singleQuoted : doubleQuoted; -} - -function split_lines(text) { - var lines = text.split('\n'); - var splitLines = new Array(); - var j = 0; - var i; - - for(i = 0; i < lines.length; i++) { - if (lines[i].length <= 80) { - splitLines[j] = lines[i]; - j++; - } else { - var line = lines[i]; - var splitAt; - do { - splitAt = line.indexOf(' ', 80); - - if (splitAt === -1) { - splitLines[j] = line; - j++; - } else { - splitLines[j] = line.substring(0, splitAt); - line = line.substring(splitAt); - j++; - } - } - while(splitAt !== -1); - } - } - return splitLines; -} - -/** -* From http://www.massless.org/mozedit/ -*/ -function mozWrap(txtarea, open, close) { - var selLength = (typeof(txtarea.textLength) === 'undefined') ? txtarea.value.length : txtarea.textLength; - var selStart = txtarea.selectionStart; - var selEnd = txtarea.selectionEnd; - var scrollTop = txtarea.scrollTop; - - var s1 = (txtarea.value).substring(0,selStart); - var s2 = (txtarea.value).substring(selStart, selEnd); - var s3 = (txtarea.value).substring(selEnd, selLength); - - txtarea.value = s1 + open + s2 + close + s3; - txtarea.selectionStart = selStart + open.length; - txtarea.selectionEnd = selEnd + open.length; - txtarea.focus(); - txtarea.scrollTop = scrollTop; - - return; -} - -/** -* Insert at Caret position. Code from -* http://www.faqts.com/knowledge_base/view.phtml/aid/1052/fid/130 -*/ -function storeCaret(textEl) { - if (textEl.createTextRange && document.selection) { - textEl.caretPos = document.selection.createRange().duplicate(); - } -} - -/** -* Caret Position object -*/ -function caretPosition() { - var start = null; - var end = null; -} - -/** -* Get the caret position in an textarea -*/ -function getCaretPosition(txtarea) { - var caretPos = new caretPosition(); - - // simple Gecko/Opera way - if (txtarea.selectionStart || txtarea.selectionStart === 0) { - caretPos.start = txtarea.selectionStart; - caretPos.end = txtarea.selectionEnd; - } - // dirty and slow IE way - else if (document.selection) { - // get current selection - var range = document.selection.createRange(); - - // a new selection of the whole textarea - var range_all = document.body.createTextRange(); - range_all.moveToElementText(txtarea); - - // calculate selection start point by moving beginning of range_all to beginning of range - var sel_start; - for (sel_start = 0; range_all.compareEndPoints('StartToStart', range) < 0; sel_start++) { - range_all.moveStart('character', 1); - } - - txtarea.sel_start = sel_start; - - // we ignore the end value for IE, this is already dirty enough and we don't need it - caretPos.start = txtarea.sel_start; - caretPos.end = txtarea.sel_start; - } - - return caretPos; -} - -/** -* Allow to use tab character when typing code -* Keep indentation of last line of code when typing code -*/ -(function($) { - $(document).ready(function() { - var doc, textarea; - - // find textarea, make sure browser supports necessary functions - if (document.forms[form_name]) { - doc = document; - } else { - doc = opener.document; - } - - if (!doc.forms[form_name]) { - return; - } - - textarea = doc.forms[form_name].elements[text_name]; - - phpbb.applyCodeEditor(textarea); - if ($('#attach-panel').length) { - phpbb.showDragNDrop(textarea); - } - - $('textarea').on('keydown', function (e) { - if (e.which === 13 && (e.metaKey || e.ctrlKey)) { - $(this).closest('form').find(':submit').click(); - } - }); - }); -})(jQuery); - diff --git a/install/update/old/assets/javascript/plupload.js b/install/update/old/assets/javascript/plupload.js deleted file mode 100644 index 495d756..0000000 --- a/install/update/old/assets/javascript/plupload.js +++ /dev/null @@ -1,657 +0,0 @@ -/* global phpbb, plupload, attachInline */ - -plupload.addI18n(phpbb.plupload.i18n); -phpbb.plupload.ids = []; - -(function($) { // Avoid conflicts with other libraries - -'use strict'; - -/** - * Set up the uploader. - */ -phpbb.plupload.initialize = function() { - // Initialize the Plupload uploader. - phpbb.plupload.uploader.init(); - - // Set attachment data. - phpbb.plupload.setData(phpbb.plupload.data); - phpbb.plupload.updateMultipartParams(phpbb.plupload.getSerializedData()); - - // Only execute if Plupload initialized successfully. - phpbb.plupload.uploader.bind('Init', function() { - phpbb.plupload.form = $(phpbb.plupload.config.form_hook)[0]; - phpbb.plupload.rowTpl = $('#attach-row-tpl')[0].outerHTML; - - // Hide the basic upload panel and remove the attach row template. - $('#attach-row-tpl, #attach-panel-basic').remove(); - // Show multi-file upload options. - $('#attach-panel-multi').show(); - }); - - phpbb.plupload.uploader.bind('PostInit', function() { - // Point out the drag-and-drop zone if it's supported. - if (phpbb.plupload.uploader.features.dragdrop) { - $('#drag-n-drop-message').show(); - } - - // Ensure "Add files" button position is correctly calculated. - if ($('#attach-panel-multi').is(':visible')) { - phpbb.plupload.uploader.refresh(); - } - $('[data-subpanel="attach-panel"]').one('click', function() { - phpbb.plupload.uploader.refresh(); - }); - }); -}; - -/** - * Unsets all elements in the object uploader.settings.multipart_params whose keys - * begin with 'attachment_data[' - */ -phpbb.plupload.clearParams = function() { - var obj = phpbb.plupload.uploader.settings.multipart_params; - for (var key in obj) { - if (!obj.hasOwnProperty(key) || key.indexOf('attachment_data[') !== 0) { - continue; - } - - delete phpbb.plupload.uploader.settings.multipart_params[key]; - } -}; - -/** - * Update uploader.settings.multipart_params object with new data. - * - * @param {object} obj - */ -phpbb.plupload.updateMultipartParams = function(obj) { - var settings = phpbb.plupload.uploader.settings; - settings.multipart_params = $.extend(settings.multipart_params, obj); -}; - -/** - * Convert the array of attachment objects into an object that PHP would expect as POST data. - * - * @returns {object} An object in the form 'attachment_data[i][key]': value as - * expected by the server - */ -phpbb.plupload.getSerializedData = function() { - var obj = {}; - for (var i = 0; i < phpbb.plupload.data.length; i++) { - var datum = phpbb.plupload.data[i]; - for (var key in datum) { - if (!datum.hasOwnProperty(key)) { - continue; - } - - obj['attachment_data[' + i + '][' + key + ']'] = datum[key]; - } - } - return obj; -}; - -/** - * Get the index from the phpbb.plupload.data array where the given - * attachment id appears. - * - * @param {int} attachId The attachment id of the file. - * @returns {bool|int} Index of the file if exists, otherwise false. - */ -phpbb.plupload.getIndex = function(attachId) { - var index = $.inArray(Number(attachId), phpbb.plupload.ids); - return (index !== -1) ? index : false; -}; - -/** - * Set the data in phpbb.plupload.data and phpbb.plupload.ids arrays. - * - * @param {Array} data Array containing the new data to use. In the form of - * array(index => object(property: value). Requires attach_id to be one of the object properties. - */ -phpbb.plupload.setData = function(data) { - // Make sure that the array keys are reset. - phpbb.plupload.ids = phpbb.plupload.data = []; - phpbb.plupload.data = data; - - for (var i = 0; i < data.length; i++) { - phpbb.plupload.ids.push(Number(data[i].attach_id)); - } -}; - -/** - * Update the attachment data in the HTML and the phpbb & phpbb.plupload objects. - * - * @param {Array} data Array containing the new data to use. - * @param {string} action The action that required the update. Used to update the inline attachment bbcodes. - * @param {int} index The index from phpbb.plupload_ids that was affected by the action. - * @param {Array} downloadUrl Optional array of download urls to update. - */ -phpbb.plupload.update = function(data, action, index, downloadUrl) { - - phpbb.plupload.updateBbcode(action, index); - phpbb.plupload.setData(data); - phpbb.plupload.updateRows(downloadUrl); - phpbb.plupload.clearParams(); - phpbb.plupload.updateMultipartParams(phpbb.plupload.getSerializedData()); -}; - -/** - * Update the relevant elements and hidden data for all attachments. - * - * @param {Array} downloadUrl Optional array of download urls to update. - */ -phpbb.plupload.updateRows = function(downloadUrl) { - for (var i = 0; i < phpbb.plupload.ids.length; i++) { - phpbb.plupload.updateRow(i, downloadUrl); - } -}; - -/** - * Insert a row for a new attachment. This expects an HTML snippet in the HTML - * using the id "attach-row-tpl" to be present. This snippet is cloned and the - * data for the file inserted into it. The row is then appended or prepended to - * #file-list based on the attach_order setting. - * - * @param {object} file Plupload file object for the new attachment. - */ -phpbb.plupload.insertRow = function(file) { - var row = $(phpbb.plupload.rowTpl); - - row.attr('id', file.id); - row.find('.file-name').html(plupload.xmlEncode(file.name)); - row.find('.file-size').html(plupload.formatSize(file.size)); - - if (phpbb.plupload.order === 'desc') { - $('#file-list').prepend(row); - } else { - $('#file-list').append(row); - } -}; - -/** - * Update the relevant elements and hidden data for an attachment. - * - * @param {int} index The index from phpbb.plupload.ids of the attachment to edit. - * @param {Array} downloadUrl Optional array of download urls to update. - */ -phpbb.plupload.updateRow = function(index, downloadUrl) { - var attach = phpbb.plupload.data[index], - row = $('[data-attach-id="' + attach.attach_id + '"]'); - - // Add the link to the file - if (typeof downloadUrl !== 'undefined' && typeof downloadUrl[index] !== 'undefined') { - var url = downloadUrl[index].replace('&', '&'), - link = $(''); - - link.attr('href', url).html(attach.real_filename); - row.find('.file-name').html(link); - } - - row.find('textarea').attr('name', 'comment_list[' + index + ']'); - phpbb.plupload.updateHiddenData(row, attach, index); -}; - -/** - * Update hidden input data for an attachment. - * - * @param {object} row jQuery object for the attachment row. - * @param {object} attach Attachment data object from phpbb.plupload.data - * @param {int} index Attachment index from phpbb.plupload.ids - */ -phpbb.plupload.updateHiddenData = function(row, attach, index) { - row.find('input[type="hidden"]').remove(); - - for (var key in attach) { - if (!attach.hasOwnProperty(key)) { - return; - } - - var input = $('') - .attr('type', 'hidden') - .attr('name', 'attachment_data[' + index + '][' + key + ']') - .attr('value', attach[key]); - $(row).append(input); - } -}; - -/** - * Deleting a file removes it from the queue and fires an AJAX event to the - * server to tell it to remove the temporary attachment. The server - * responds with the updated attachment data list so that any future - * uploads can maintain state with the server - * - * @param {object} row jQuery object for the attachment row. - * @param {int} attachId Attachment id of the file to be removed. - */ -phpbb.plupload.deleteFile = function(row, attachId) { - // If there's no attach id, then the file hasn't been uploaded. Simply delete the row. - if (typeof attachId === 'undefined') { - var file = phpbb.plupload.uploader.getFile(row.attr('id')); - phpbb.plupload.uploader.removeFile(file); - - row.slideUp(100, function() { - row.remove(); - phpbb.plupload.hideEmptyList(); - }); - } - - var index = phpbb.plupload.getIndex(attachId); - row.find('.file-status').toggleClass('file-uploaded file-working'); - - if (index === false) { - return; - } - var fields = {}; - fields['delete_file[' + index + ']'] = 1; - - var always = function() { - row.find('.file-status').removeClass('file-working'); - }; - - var done = function(response) { - if (typeof response !== 'object') { - return; - } - - // trigger_error() was called which likely means a permission error was encountered. - if (typeof response.title !== 'undefined') { - phpbb.plupload.uploader.trigger('Error', { message: response.message }); - // We will have to assume that the deletion failed. So leave the file status as uploaded. - row.find('.file-status').toggleClass('file-uploaded'); - - return; - } - phpbb.plupload.update(response, 'removal', index); - // Check if the user can upload files now if he had reached the max files limit. - phpbb.plupload.handleMaxFilesReached(); - - if (row.attr('id')) { - var file = phpbb.plupload.uploader.getFile(row.attr('id')); - phpbb.plupload.uploader.removeFile(file); - } - row.slideUp(100, function() { - row.remove(); - // Hide the file list if it's empty now. - phpbb.plupload.hideEmptyList(); - }); - phpbb.plupload.uploader.trigger('FilesRemoved'); - }; - - $.ajax(phpbb.plupload.config.url, { - type: 'POST', - data: $.extend(fields, phpbb.plupload.getSerializedData()), - headers: phpbb.plupload.config.headers - }) - .always(always) - .done(done); -}; - -/** - * Check the attachment list and hide its container if it's empty. - */ -phpbb.plupload.hideEmptyList = function() { - if (!$('#file-list').children().length) { - $('#file-list-container').slideUp(100); - } -}; - -/** - * Update the indices used in inline attachment bbcodes. This ensures that the - * bbcodes correspond to the correct file after a file is added or removed. - * This should be called before the phpbb.plupload,data and phpbb.plupload.ids - * arrays are updated, otherwise it will not work correctly. - * - * @param {string} action The action that occurred -- either "addition" or "removal" - * @param {int} index The index of the attachment from phpbb.plupload.ids that was affected. - */ -phpbb.plupload.updateBbcode = function(action, index) { - var textarea = $('#message', phpbb.plupload.form), - text = textarea.val(), - removal = (action === 'removal'); - - // Return if the bbcode isn't used at all. - if (text.indexOf('[attachment=') === -1) { - return; - } - - function runUpdate(i) { - var regex = new RegExp('\\[attachment=' + i + '\\](.*?)\\[\\/attachment\\]', 'g'); - text = text.replace(regex, function updateBbcode(_, fileName) { - // Remove the bbcode if the file was removed. - if (removal && index === i) { - return ''; - } - var newIndex = i + ((removal) ? -1 : 1); - return '[attachment=' + newIndex + ']' + fileName + '[/attachment]'; - }); - } - - // Loop forwards when removing and backwards when adding ensures we don't - // corrupt the bbcode index. - var i; - if (removal) { - for (i = index; i < phpbb.plupload.ids.length; i++) { - runUpdate(i); - } - } else { - for (i = phpbb.plupload.ids.length - 1; i >= index; i--) { - runUpdate(i); - } - } - - textarea.val(text); -}; - -/** - * Get Plupload file objects based on their upload status. - * - * @param {int} status Plupload status - plupload.DONE, plupload.FAILED, - * plupload.QUEUED, plupload.STARTED, plupload.STOPPED - * - * @returns {Array} The Plupload file objects matching the status. - */ -phpbb.plupload.getFilesByStatus = function(status) { - var files = []; - - $.each(phpbb.plupload.uploader.files, function(i, file) { - if (file.status === status) { - files.push(file); - } - }); - return files; -}; - -/** - * Check whether the user has reached the maximun number of files that he's allowed - * to upload. If so, disables the uploader and marks the queued files as failed. Otherwise - * makes sure that the uploader is enabled. - * - * @returns {bool} True if the limit has been reached. False if otherwise. - */ -phpbb.plupload.handleMaxFilesReached = function() { - // If there is no limit, the user is an admin or moderator. - if (!phpbb.plupload.maxFiles) { - return false; - } - - if (phpbb.plupload.maxFiles <= phpbb.plupload.ids.length) { - // Fail the rest of the queue. - phpbb.plupload.markQueuedFailed(phpbb.plupload.lang.TOO_MANY_ATTACHMENTS); - // Disable the uploader. - phpbb.plupload.disableUploader(); - phpbb.plupload.uploader.trigger('Error', { message: phpbb.plupload.lang.TOO_MANY_ATTACHMENTS }); - - return true; - } else if (phpbb.plupload.maxFiles > phpbb.plupload.ids.length) { - // Enable the uploader if the user is under the limit - phpbb.plupload.enableUploader(); - } - return false; -}; - -/** - * Disable the uploader - */ -phpbb.plupload.disableUploader = function() { - $('#add_files').addClass('disabled'); - phpbb.plupload.uploader.disableBrowse(); -}; - -/** - * Enable the uploader - */ -phpbb.plupload.enableUploader = function() { - $('#add_files').removeClass('disabled'); - phpbb.plupload.uploader.disableBrowse(false); -}; - -/** - * Mark all queued files as failed. - * - * @param {string} error Error message to present to the user. - */ -phpbb.plupload.markQueuedFailed = function(error) { - var files = phpbb.plupload.getFilesByStatus(plupload.QUEUED); - - $.each(files, function(i, file) { - $('#' + file.id).find('.file-progress').hide(); - phpbb.plupload.fileError(file, error); - }); -}; - -/** - * Marks a file as failed and sets the error message for it. - * - * @param {object} file Plupload file object that failed. - * @param {string} error Error message to present to the user. - */ -phpbb.plupload.fileError = function(file, error) { - file.status = plupload.FAILED; - file.error = error; - $('#' + file.id).find('.file-status') - .addClass('file-error') - .attr({ - 'data-error-title': phpbb.plupload.lang.ERROR, - 'data-error-message': error - }); -}; - - -/** - * Set up the Plupload object and get some basic data. - */ -phpbb.plupload.uploader = new plupload.Uploader(phpbb.plupload.config); -phpbb.plupload.initialize(); - -var $fileList = $('#file-list'); - -/** - * Insert inline attachment bbcode. - */ -$fileList.on('click', '.file-inline-bbcode', function(e) { - var attachId = $(this).parents('.attach-row').attr('data-attach-id'), - index = phpbb.plupload.getIndex(attachId); - - attachInline(index, phpbb.plupload.data[index].real_filename); - e.preventDefault(); -}); - -/** - * Delete a file. - */ -$fileList.on('click', '.file-delete', function(e) { - var row = $(this).parents('.attach-row'), - attachId = row.attr('data-attach-id'); - - phpbb.plupload.deleteFile(row, attachId); - e.preventDefault(); -}); - -/** - * Display the error message for a particular file when the error icon is clicked. - */ -$fileList.on('click', '.file-error', function(e) { - phpbb.alert($(this).attr('data-error-title'), $(this).attr('data-error-message')); - e.preventDefault(); -}); - -/** - * Fires when an error occurs. - */ -phpbb.plupload.uploader.bind('Error', function(up, error) { - error.file.name = plupload.xmlEncode(error.file.name); - - // The error message that Plupload provides for these is vague, so we'll be more specific. - if (error.code === plupload.FILE_EXTENSION_ERROR) { - error.message = plupload.translate('Invalid file extension:') + ' ' + error.file.name; - } else if (error.code === plupload.FILE_SIZE_ERROR) { - error.message = plupload.translate('File too large:') + ' ' + error.file.name; - } - phpbb.alert(phpbb.plupload.lang.ERROR, error.message); -}); - -/** - * Fires before a given file is about to be uploaded. This allows us to - * send the real filename along with the chunk. This is necessary because - * for some reason the filename is set to 'blob' whenever a file is chunked - * - * @param {object} up The plupload.Uploader object - * @param {object} file The plupload.File object that is about to be uploaded - */ -phpbb.plupload.uploader.bind('BeforeUpload', function(up, file) { - if (phpbb.plupload.handleMaxFilesReached()) { - return; - } - - phpbb.plupload.updateMultipartParams({ real_filename: file.name }); -}); - -/** - * Fired when a single chunk of any given file is uploaded. This parses the - * response from the server and checks for an error. If an error occurs it - * is reported to the user and the upload of this particular file is halted - * - * @param {object} up The plupload.Uploader object - * @param {object} file The plupload.File object whose chunk has just - * been uploaded - * @param {object} response The response object from the server - */ -phpbb.plupload.uploader.bind('ChunkUploaded', function(up, file, response) { - if (response.chunk >= response.chunks - 1) { - return; - } - - var json = {}; - try { - json = $.parseJSON(response.response); - } catch (e) { - file.status = plupload.FAILED; - up.trigger('FileUploaded', file, { - response: JSON.stringify({ - error: { - message: 'Error parsing server response.' - } - }) - }); - } - - // If trigger_error() was called, then a permission error likely occurred. - if (typeof json.title !== 'undefined') { - json.error = { message: json.message }; - } - - if (json.error) { - file.status = plupload.FAILED; - up.trigger('FileUploaded', file, { - response: JSON.stringify({ - error: { - message: json.error.message - } - }) - }); - } -}); - -/** - * Fires when files are added to the queue. - */ -phpbb.plupload.uploader.bind('FilesAdded', function(up, files) { - // Prevent unnecessary requests to the server if the user already uploaded - // the maximum number of files allowed. - if (phpbb.plupload.handleMaxFilesReached()) { - return; - } - - // Switch the active tab if the style supports it - if (typeof activateSubPanel === 'function') { - activateSubPanel('attach-panel'); // jshint ignore: line - } - - // Show the file list if there aren't any files currently. - var $fileListContainer = $('#file-list-container'); - if (!$fileListContainer.is(':visible')) { - $fileListContainer.show(100); - } - - $.each(files, function(i, file) { - phpbb.plupload.insertRow(file); - }); - - up.bind('UploadProgress', function(up, file) { - $('.file-progress-bar', '#' + file.id).css('width', file.percent + '%'); - $('#file-total-progress-bar').css('width', up.total.percent + '%'); - }); - - // Do not allow more files to be added to the running queue. - phpbb.plupload.disableUploader(); - - // Start uploading the files once the user has selected them. - up.start(); -}); - - -/** - * Fires when an entire file has been uploaded. It checks for errors - * returned by the server otherwise parses the list of attachment data and - * appends it to the next file upload so that the server can maintain state - * with regards to the attachments in a given post - * - * @param {object} up The plupload.Uploader object - * @param {object} file The plupload.File object that has just been - * uploaded - * @param {string} response The response string from the server - */ -phpbb.plupload.uploader.bind('FileUploaded', function(up, file, response) { - var json = {}, - row = $('#' + file.id), - error; - - // Hide the progress indicator. - row.find('.file-progress').hide(); - - try { - json = JSON.parse(response.response); - } catch (e) { - error = 'Error parsing server response.'; - } - - // If trigger_error() was called, then a permission error likely occurred. - if (typeof json.title !== 'undefined') { - error = json.message; - up.trigger('Error', { message: error }); - - // The rest of the queue will fail. - phpbb.plupload.markQueuedFailed(error); - } else if (json.error) { - error = json.error.message; - } - - if (typeof error !== 'undefined') { - phpbb.plupload.fileError(file, error); - } else if (file.status === plupload.DONE) { - file.attachment_data = json.data[0]; - - row.attr('data-attach-id', file.attachment_data.attach_id); - row.find('.file-inline-bbcode').show(); - row.find('.file-status').addClass('file-uploaded'); - phpbb.plupload.update(json.data, 'addition', 0, [json.download_url]); - } -}); - -/** - * Fires when the entire queue of files have been uploaded. - */ -phpbb.plupload.uploader.bind('UploadComplete', function() { - // Hide the progress bar - setTimeout(function() { - $('#file-total-progress-bar').fadeOut(500, function() { - $(this).css('width', 0).show(); - }); - }, 2000); - - // Re-enable the uploader - phpbb.plupload.enableUploader(); -}); - -})(jQuery); // Avoid conflicts with other libraries diff --git a/install/update/old/common.php b/install/update/old/common.php deleted file mode 100644 index 172503f..0000000 --- a/install/update/old/common.php +++ /dev/null @@ -1,164 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* Minimum Requirement: PHP 5.4.0 -*/ - -if (!defined('IN_PHPBB')) -{ - exit; -} - -require($phpbb_root_path . 'includes/startup.' . $phpEx); -require($phpbb_root_path . 'phpbb/class_loader.' . $phpEx); - -$phpbb_class_loader = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}phpbb/", $phpEx); -$phpbb_class_loader->register(); - -$phpbb_config_php_file = new \phpbb\config_php_file($phpbb_root_path, $phpEx); -extract($phpbb_config_php_file->get_all()); - -if (!defined('PHPBB_ENVIRONMENT')) -{ - @define('PHPBB_ENVIRONMENT', 'production'); -} - -if (!defined('PHPBB_INSTALLED')) -{ - // Redirect the user to the installer - require($phpbb_root_path . 'includes/functions.' . $phpEx); - - // We have to generate a full HTTP/1.1 header here since we can't guarantee to have any of the information - // available as used by the redirect function - $server_name = (!empty($_SERVER['HTTP_HOST'])) ? strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME')); - $server_port = (!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT'); - $secure = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 1 : 0; - - if (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') - { - $secure = 1; - $server_port = 443; - } - - $script_name = (!empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : getenv('PHP_SELF'); - if (!$script_name) - { - $script_name = (!empty($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : getenv('REQUEST_URI'); - } - - // $phpbb_root_path accounts for redirects from e.g. /adm - $script_path = trim(dirname($script_name)) . '/' . $phpbb_root_path . 'install/app.' . $phpEx; - // Replace any number of consecutive backslashes and/or slashes with a single slash - // (could happen on some proxy setups and/or Windows servers) - $script_path = preg_replace('#[\\\\/]{2,}#', '/', $script_path); - - // Eliminate . and .. from the path - require($phpbb_root_path . 'phpbb/filesystem.' . $phpEx); - $phpbb_filesystem = new phpbb\filesystem\filesystem(); - $script_path = $phpbb_filesystem->clean_path($script_path); - - $url = (($secure) ? 'https://' : 'http://') . $server_name; - - if ($server_port && (($secure && $server_port <> 443) || (!$secure && $server_port <> 80))) - { - // HTTP HOST can carry a port number... - if (strpos($server_name, ':') === false) - { - $url .= ':' . $server_port; - } - } - - $url .= $script_path; - header('Location: ' . $url); - exit; -} - -// In case $phpbb_adm_relative_path is not set (in case of an update), use the default. -$phpbb_adm_relative_path = (isset($phpbb_adm_relative_path)) ? $phpbb_adm_relative_path : 'adm/'; -$phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : $phpbb_root_path . $phpbb_adm_relative_path; - -// Include files -require($phpbb_root_path . 'includes/functions.' . $phpEx); -require($phpbb_root_path . 'includes/functions_content.' . $phpEx); -include($phpbb_root_path . 'includes/functions_compatibility.' . $phpEx); - -require($phpbb_root_path . 'includes/constants.' . $phpEx); -require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); - -if (PHPBB_ENVIRONMENT === 'development') -{ - \phpbb\debug\debug::enable(); -} -else -{ - set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); -} - -$phpbb_class_loader_ext = new \phpbb\class_loader('\\', "{$phpbb_root_path}ext/", $phpEx); -$phpbb_class_loader_ext->register(); - -// Set up container -try -{ - $phpbb_container_builder = new \phpbb\di\container_builder($phpbb_root_path, $phpEx); - $phpbb_container = $phpbb_container_builder->with_config($phpbb_config_php_file)->get_container(); -} -catch (InvalidArgumentException $e) -{ - if (PHPBB_ENVIRONMENT !== 'development') - { - trigger_error( - 'The requested environment ' . PHPBB_ENVIRONMENT . ' is not available.', - E_USER_ERROR - ); - } - else - { - throw $e; - } -} - -$phpbb_class_loader->set_cache($phpbb_container->get('cache.driver')); -$phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver')); - -require($phpbb_root_path . 'includes/compatibility_globals.' . $phpEx); - -register_compatibility_globals(); - -// Add own hook handler -require($phpbb_root_path . 'includes/hooks/index.' . $phpEx); -$phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display'))); - -/* @var $phpbb_hook_finder \phpbb\hook\finder */ -$phpbb_hook_finder = $phpbb_container->get('hook_finder'); - -foreach ($phpbb_hook_finder->find() as $hook) -{ - @include($phpbb_root_path . 'includes/hooks/' . $hook . '.' . $phpEx); -} - -/** -* Main event which is triggered on every page -* -* You can use this event to load function files and initiate objects -* -* NOTE: At this point the global session ($user) and permissions ($auth) -* do NOT exist yet. If you need to use the user object -* (f.e. to include language files) or need to check permissions, -* please use the core.user_setup event instead! -* -* @event core.common -* @since 3.1.0-a1 -*/ -$phpbb_dispatcher->dispatch('core.common'); diff --git a/install/update/old/composer.json b/install/update/old/composer.json deleted file mode 100644 index d192fd5..0000000 --- a/install/update/old/composer.json +++ /dev/null @@ -1,75 +0,0 @@ -{ - "name": "phpbb/phpbb", - "description": "phpBB Forum Software application", - "type": "project", - "keywords": ["phpbb", "forum"], - "homepage": "https://www.phpbb.com", - "license": "GPL-2.0-only", - "authors": [ - { - "name": "phpBB Limited", - "email": "operations@phpbb.com", - "homepage": "https://www.phpbb.com/go/authors" - } - ], - "support": { - "issues": "https://tracker.phpbb.com", - "forum": "https://www.phpbb.com/community/", - "wiki": "https://wiki.phpbb.com", - "irc": "irc://irc.freenode.org/phpbb" - }, - "scripts": { - "post-update-cmd": "echo 'You MUST manually modify the clean-vendor-dir target in build/build.xml when adding or upgrading dependencies.'" - }, - "replace": { - "phpbb/phpbb-core": "self.version" - }, - "require": { - "php": ">=5.4", - "bantu/ini-get-wrapper": "1.0.*", - "google/recaptcha": "~1.1", - "guzzlehttp/guzzle": "~5.3", - "lusitanian/oauth": "^0.8.1", - "marc1706/fast-image-size": "^1.1", - "paragonie/random_compat": "^1.4", - "patchwork/utf8": "^1.1", - "s9e/text-formatter": "^1.3", - "symfony/config": "^2.8", - "symfony/console": "^2.8", - "symfony/debug": "^2.8", - "symfony/dependency-injection": "^2.8", - "symfony/event-dispatcher": "^2.8", - "symfony/filesystem": "^2.8", - "symfony/finder": "^2.8", - "symfony/http-foundation": "^2.8", - "symfony/http-kernel": "^2.8", - "symfony/proxy-manager-bridge": "^2.8", - "symfony/routing": "^2.8", - "symfony/twig-bridge": "^2.8", - "symfony/yaml": "^2.8", - "twig/twig": "^1.0" - }, - "require-dev": { - "fabpot/goutte": "~2.0", - "facebook/webdriver": "~1.1", - "laravel/homestead": "~2.2", - "phing/phing": "2.4.*", - "phpunit/dbunit": "1.3.*", - "phpunit/phpunit": "^4.1", - "sami/sami": "1.*", - "squizlabs/php_codesniffer": "2.*", - "symfony/browser-kit": "^2.8", - "symfony/css-selector": "^2.8", - "symfony/dom-crawler": "^2.8" - }, - "extra": { - "branch-alias": { - "dev-master": "3.2.x-dev" - } - }, - "config": { - "platform": { - "php": "5.4.7" - } - } -} diff --git a/install/update/old/composer.lock b/install/update/old/composer.lock deleted file mode 100644 index 2c338bf..0000000 --- a/install/update/old/composer.lock +++ /dev/null @@ -1,3644 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", - "This file is @generated automatically" - ], - "content-hash": "6daa2f5f7a161377dee1835bd4d5b463", - "packages": [ - { - "name": "bantu/ini-get-wrapper", - "version": "v1.0.1", - "source": { - "type": "git", - "url": "https://github.com/bantuXorg/php-ini-get-wrapper.git", - "reference": "4770c7feab370c62e23db4f31c112b7c6d90aee2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/bantuXorg/php-ini-get-wrapper/zipball/4770c7feab370c62e23db4f31c112b7c6d90aee2", - "reference": "4770c7feab370c62e23db4f31c112b7c6d90aee2", - "shasum": "" - }, - "require-dev": { - "phpunit/phpunit": "3.7.*" - }, - "type": "library", - "autoload": { - "psr-4": { - "bantu\\IniGetWrapper\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Convenience wrapper around ini_get()", - "time": "2014-09-15T13:12:35+00:00" - }, - { - "name": "google/recaptcha", - "version": "1.1.2", - "source": { - "type": "git", - "url": "https://github.com/google/recaptcha.git", - "reference": "2b7e00566afca82a38a1d3adb8e42c118006296e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/google/recaptcha/zipball/2b7e00566afca82a38a1d3adb8e42c118006296e", - "reference": "2b7e00566afca82a38a1d3adb8e42c118006296e", - "shasum": "" - }, - "require": { - "php": ">=5.3.2" - }, - "require-dev": { - "phpunit/phpunit": "4.5.*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1.x-dev" - } - }, - "autoload": { - "psr-4": { - "ReCaptcha\\": "src/ReCaptcha" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "description": "Client library for reCAPTCHA, a free service that protect websites from spam and abuse.", - "homepage": "http://www.google.com/recaptcha/", - "keywords": [ - "Abuse", - "captcha", - "recaptcha", - "spam" - ], - "time": "2015-09-02T17:23:59+00:00" - }, - { - "name": "guzzlehttp/guzzle", - "version": "5.3.3", - "source": { - "type": "git", - "url": "https://github.com/guzzle/guzzle.git", - "reference": "93bbdb30d59be6cd9839495306c65f2907370eb9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/93bbdb30d59be6cd9839495306c65f2907370eb9", - "reference": "93bbdb30d59be6cd9839495306c65f2907370eb9", - "shasum": "" - }, - "require": { - "guzzlehttp/ringphp": "^1.1", - "php": ">=5.4.0", - "react/promise": "^2.2" - }, - "require-dev": { - "ext-curl": "*", - "phpunit/phpunit": "^4.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "GuzzleHttp\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients", - "homepage": "http://guzzlephp.org/", - "keywords": [ - "client", - "curl", - "framework", - "http", - "http client", - "rest", - "web service" - ], - "time": "2018-07-31T13:33:10+00:00" - }, - { - "name": "guzzlehttp/ringphp", - "version": "1.1.1", - "source": { - "type": "git", - "url": "https://github.com/guzzle/RingPHP.git", - "reference": "5e2a174052995663dd68e6b5ad838afd47dd615b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/RingPHP/zipball/5e2a174052995663dd68e6b5ad838afd47dd615b", - "reference": "5e2a174052995663dd68e6b5ad838afd47dd615b", - "shasum": "" - }, - "require": { - "guzzlehttp/streams": "~3.0", - "php": ">=5.4.0", - "react/promise": "~2.0" - }, - "require-dev": { - "ext-curl": "*", - "phpunit/phpunit": "~4.0" - }, - "suggest": { - "ext-curl": "Guzzle will use specific adapters if cURL is present" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1-dev" - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\Ring\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "description": "Provides a simple API and specification that abstracts away the details of HTTP into a single PHP function.", - "time": "2018-07-31T13:22:33+00:00" - }, - { - "name": "guzzlehttp/streams", - "version": "3.0.0", - "source": { - "type": "git", - "url": "https://github.com/guzzle/streams.git", - "reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/streams/zipball/47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5", - "reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5", - "shasum": "" - }, - "require": { - "php": ">=5.4.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0-dev" - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\Stream\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "description": "Provides a simple abstraction over streams of data", - "homepage": "http://guzzlephp.org/", - "keywords": [ - "Guzzle", - "stream" - ], - "time": "2014-10-12T19:18:40+00:00" - }, - { - "name": "ircmaxell/password-compat", - "version": "v1.0.4", - "source": { - "type": "git", - "url": "https://github.com/ircmaxell/password_compat.git", - "reference": "5c5cde8822a69545767f7c7f3058cb15ff84614c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/ircmaxell/password_compat/zipball/5c5cde8822a69545767f7c7f3058cb15ff84614c", - "reference": "5c5cde8822a69545767f7c7f3058cb15ff84614c", - "shasum": "" - }, - "require-dev": { - "phpunit/phpunit": "4.*" - }, - "type": "library", - "autoload": { - "files": [ - "lib/password.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Anthony Ferrara", - "email": "ircmaxell@php.net", - "homepage": "http://blog.ircmaxell.com" - } - ], - "description": "A compatibility library for the proposed simplified password hashing algorithm: https://wiki.php.net/rfc/password_hash", - "homepage": "https://github.com/ircmaxell/password_compat", - "keywords": [ - "hashing", - "password" - ], - "time": "2014-11-20T16:49:30+00:00" - }, - { - "name": "lusitanian/oauth", - "version": "v0.8.11", - "source": { - "type": "git", - "url": "https://github.com/Lusitanian/PHPoAuthLib.git", - "reference": "fc11a53db4b66da555a6a11fce294f574a8374f9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Lusitanian/PHPoAuthLib/zipball/fc11a53db4b66da555a6a11fce294f574a8374f9", - "reference": "fc11a53db4b66da555a6a11fce294f574a8374f9", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "require-dev": { - "phpunit/phpunit": "3.7.*", - "predis/predis": "0.8.*@dev", - "squizlabs/php_codesniffer": "2.*", - "symfony/http-foundation": "~2.1" - }, - "suggest": { - "ext-openssl": "Allows for usage of secure connections with the stream-based HTTP client.", - "predis/predis": "Allows using the Redis storage backend.", - "symfony/http-foundation": "Allows using the Symfony Session storage backend." - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "0.1-dev" - } - }, - "autoload": { - "psr-0": { - "OAuth": "src", - "OAuth\\Unit": "tests" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "David Desberg", - "email": "david@daviddesberg.com" - }, - { - "name": "Elliot Chance", - "email": "elliotchance@gmail.com" - }, - { - "name": "Pieter Hordijk", - "email": "info@pieterhordijk.com" - } - ], - "description": "PHP 5.3+ oAuth 1/2 Library", - "keywords": [ - "Authentication", - "authorization", - "oauth", - "security" - ], - "time": "2016-07-12T22:15:00+00:00" - }, - { - "name": "marc1706/fast-image-size", - "version": "v1.1.4", - "source": { - "type": "git", - "url": "https://github.com/marc1706/fast-image-size.git", - "reference": "c4ded0223a4e49ae45a2183a69f6afac5baf7250" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/marc1706/fast-image-size/zipball/c4ded0223a4e49ae45a2183a69f6afac5baf7250", - "reference": "c4ded0223a4e49ae45a2183a69f6afac5baf7250", - "shasum": "" - }, - "require": { - "ext-mbstring": "*", - "php": ">=5.3.0" - }, - "require-dev": { - "phpunit/phpunit": "4.*" - }, - "type": "library", - "autoload": { - "psr-4": { - "FastImageSize\\": "lib", - "FastImageSize\\tests\\": "tests" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Marc Alexander", - "email": "admin@m-a-styles.de", - "homepage": "https://www.m-a-styles.de", - "role": "Developer" - } - ], - "description": "fast-image-size is a PHP library that does almost everything PHP's getimagesize() does but without the large overhead of downloading the complete file.", - "homepage": "https://www.m-a-styles.de", - "keywords": [ - "fast", - "getimagesize", - "image", - "imagesize", - "php", - "size" - ], - "time": "2017-10-23T18:52:01+00:00" - }, - { - "name": "ocramius/proxy-manager", - "version": "1.0.2", - "source": { - "type": "git", - "url": "https://github.com/Ocramius/ProxyManager.git", - "reference": "57e9272ec0e8deccf09421596e0e2252df440e11" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Ocramius/ProxyManager/zipball/57e9272ec0e8deccf09421596e0e2252df440e11", - "reference": "57e9272ec0e8deccf09421596e0e2252df440e11", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "zendframework/zend-code": ">2.2.5,<3.0" - }, - "require-dev": { - "ext-phar": "*", - "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "1.5.*" - }, - "suggest": { - "ocramius/generated-hydrator": "To have very fast object to array to object conversion for ghost objects", - "zendframework/zend-json": "To have the JsonRpc adapter (Remote Object feature)", - "zendframework/zend-soap": "To have the Soap adapter (Remote Object feature)", - "zendframework/zend-stdlib": "To use the hydrator proxy", - "zendframework/zend-xmlrpc": "To have the XmlRpc adapter (Remote Object feature)" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "psr-0": { - "ProxyManager\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com", - "homepage": "http://ocramius.github.com/" - } - ], - "description": "A library providing utilities to generate, instantiate and generally operate with Object Proxies", - "homepage": "https://github.com/Ocramius/ProxyManager", - "keywords": [ - "aop", - "lazy loading", - "proxy", - "proxy pattern", - "service proxies" - ], - "time": "2015-08-09T04:28:19+00:00" - }, - { - "name": "paragonie/random_compat", - "version": "v1.4.3", - "source": { - "type": "git", - "url": "https://github.com/paragonie/random_compat.git", - "reference": "9b3899e3c3ddde89016f576edb8c489708ad64cd" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/paragonie/random_compat/zipball/9b3899e3c3ddde89016f576edb8c489708ad64cd", - "reference": "9b3899e3c3ddde89016f576edb8c489708ad64cd", - "shasum": "" - }, - "require": { - "php": ">=5.2.0" - }, - "require-dev": { - "phpunit/phpunit": "4.*|5.*" - }, - "suggest": { - "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." - }, - "type": "library", - "autoload": { - "files": [ - "lib/random.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Paragon Initiative Enterprises", - "email": "security@paragonie.com", - "homepage": "https://paragonie.com" - } - ], - "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", - "keywords": [ - "csprng", - "pseudorandom", - "random" - ], - "time": "2017-03-13T16:22:52+00:00" - }, - { - "name": "patchwork/utf8", - "version": "v1.3.1", - "source": { - "type": "git", - "url": "https://github.com/tchwork/utf8.git", - "reference": "30ec6451aec7d2536f0af8fe535f70c764f2c47a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/tchwork/utf8/zipball/30ec6451aec7d2536f0af8fe535f70c764f2c47a", - "reference": "30ec6451aec7d2536f0af8fe535f70c764f2c47a", - "shasum": "" - }, - "require": { - "lib-pcre": ">=7.3", - "php": ">=5.3.0" - }, - "suggest": { - "ext-iconv": "Use iconv for best performance", - "ext-intl": "Use Intl for best performance", - "ext-mbstring": "Use Mbstring for best performance", - "ext-wfio": "Use WFIO for UTF-8 filesystem access on Windows" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3-dev" - } - }, - "autoload": { - "psr-4": { - "Patchwork\\": "src/Patchwork/" - }, - "classmap": [ - "src/Normalizer.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "(Apache-2.0 or GPL-2.0)" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - } - ], - "description": "Portable and performant UTF-8, Unicode and Grapheme Clusters for PHP", - "homepage": "https://github.com/tchwork/utf8", - "keywords": [ - "grapheme", - "i18n", - "unicode", - "utf-8", - "utf8" - ], - "time": "2016-05-18T13:57:10+00:00" - }, - { - "name": "psr/log", - "version": "1.1.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/log.git", - "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd", - "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Log\\": "Psr/Log/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for logging libraries", - "homepage": "https://github.com/php-fig/log", - "keywords": [ - "log", - "psr", - "psr-3" - ], - "time": "2018-11-20T15:27:04+00:00" - }, - { - "name": "react/promise", - "version": "v2.7.1", - "source": { - "type": "git", - "url": "https://github.com/reactphp/promise.git", - "reference": "31ffa96f8d2ed0341a57848cbb84d88b89dd664d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/reactphp/promise/zipball/31ffa96f8d2ed0341a57848cbb84d88b89dd664d", - "reference": "31ffa96f8d2ed0341a57848cbb84d88b89dd664d", - "shasum": "" - }, - "require": { - "php": ">=5.4.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.8" - }, - "type": "library", - "autoload": { - "psr-4": { - "React\\Promise\\": "src/" - }, - "files": [ - "src/functions_include.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jan Sorgalla", - "email": "jsorgalla@gmail.com" - } - ], - "description": "A lightweight implementation of CommonJS Promises/A for PHP", - "keywords": [ - "promise", - "promises" - ], - "time": "2019-01-07T21:25:54+00:00" - }, - { - "name": "s9e/text-formatter", - "version": "1.4.2", - "source": { - "type": "git", - "url": "https://github.com/s9e/TextFormatter.git", - "reference": "dc7efff70b67b9cee00881ad3bef0a1da076b31e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/s9e/TextFormatter/zipball/dc7efff70b67b9cee00881ad3bef0a1da076b31e", - "reference": "dc7efff70b67b9cee00881ad3bef0a1da076b31e", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-filter": "*", - "lib-pcre": ">=7.2", - "php": ">=5.4.7" - }, - "require-dev": { - "matthiasmullie/minify": "*", - "php-coveralls/php-coveralls": "*", - "s9e/regexp-builder": "1.*" - }, - "suggest": { - "ext-curl": "Improves the performance of the MediaEmbed plugin and some JavaScript minifiers", - "ext-intl": "Allows international URLs to be accepted by the URL filter", - "ext-json": "Enables the generation of a JavaScript parser", - "ext-mbstring": "Improves the performance of the PHP renderer", - "ext-tokenizer": "Improves the performance of the PHP renderer", - "ext-xsl": "Enables the XSLT renderer", - "ext-zlib": "Enables gzip compression when scraping content via the MediaEmbed plugin" - }, - "type": "library", - "autoload": { - "psr-4": { - "s9e\\TextFormatter\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Multi-purpose text formatting and markup library. Plugins offer support for BBCodes, Markdown, emoticons, HTML, embedding media (YouTube, etc...), enhanced typography and more.", - "homepage": "https://github.com/s9e/TextFormatter/", - "keywords": [ - "bbcode", - "bbcodes", - "blog", - "censor", - "embed", - "emoji", - "emoticons", - "engine", - "forum", - "html", - "markdown", - "markup", - "media", - "parser", - "shortcodes" - ], - "time": "2019-03-27T14:19:41+00:00" - }, - { - "name": "symfony/config", - "version": "v2.8.49", - "source": { - "type": "git", - "url": "https://github.com/symfony/config.git", - "reference": "7dd5f5040dc04c118d057fb5886563963eb70011" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/7dd5f5040dc04c118d057fb5886563963eb70011", - "reference": "7dd5f5040dc04c118d057fb5886563963eb70011", - "shasum": "" - }, - "require": { - "php": ">=5.3.9", - "symfony/filesystem": "~2.3|~3.0.0", - "symfony/polyfill-ctype": "~1.8" - }, - "require-dev": { - "symfony/yaml": "~2.7|~3.0.0" - }, - "suggest": { - "symfony/yaml": "To use the yaml reference dumper" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Config\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Config Component", - "homepage": "https://symfony.com", - "time": "2018-11-26T09:38:12+00:00" - }, - { - "name": "symfony/console", - "version": "v2.8.49", - "source": { - "type": "git", - "url": "https://github.com/symfony/console.git", - "reference": "cbcf4b5e233af15cd2bbd50dee1ccc9b7927dc12" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/cbcf4b5e233af15cd2bbd50dee1ccc9b7927dc12", - "reference": "cbcf4b5e233af15cd2bbd50dee1ccc9b7927dc12", - "shasum": "" - }, - "require": { - "php": ">=5.3.9", - "symfony/debug": "^2.7.2|~3.0.0", - "symfony/polyfill-mbstring": "~1.0" - }, - "require-dev": { - "psr/log": "~1.0", - "symfony/event-dispatcher": "~2.1|~3.0.0", - "symfony/process": "~2.1|~3.0.0" - }, - "suggest": { - "psr/log-implementation": "For using the console logger", - "symfony/event-dispatcher": "", - "symfony/process": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Console\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Console Component", - "homepage": "https://symfony.com", - "time": "2018-11-20T15:55:20+00:00" - }, - { - "name": "symfony/debug", - "version": "v2.8.49", - "source": { - "type": "git", - "url": "https://github.com/symfony/debug.git", - "reference": "74251c8d50dd3be7c4ce0c7b862497cdc641a5d0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/74251c8d50dd3be7c4ce0c7b862497cdc641a5d0", - "reference": "74251c8d50dd3be7c4ce0c7b862497cdc641a5d0", - "shasum": "" - }, - "require": { - "php": ">=5.3.9", - "psr/log": "~1.0" - }, - "conflict": { - "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" - }, - "require-dev": { - "symfony/class-loader": "~2.2|~3.0.0", - "symfony/http-kernel": "~2.3.24|~2.5.9|^2.6.2|~3.0.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Debug\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Debug Component", - "homepage": "https://symfony.com", - "time": "2018-11-11T11:18:13+00:00" - }, - { - "name": "symfony/dependency-injection", - "version": "v2.8.49", - "source": { - "type": "git", - "url": "https://github.com/symfony/dependency-injection.git", - "reference": "a2f40df187f0053bc361bcea3b27ff2b85744d9f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/a2f40df187f0053bc361bcea3b27ff2b85744d9f", - "reference": "a2f40df187f0053bc361bcea3b27ff2b85744d9f", - "shasum": "" - }, - "require": { - "php": ">=5.3.9" - }, - "conflict": { - "symfony/expression-language": "<2.6" - }, - "require-dev": { - "symfony/config": "~2.2|~3.0.0", - "symfony/expression-language": "~2.6|~3.0.0", - "symfony/yaml": "~2.3.42|~2.7.14|~2.8.7|~3.0.7" - }, - "suggest": { - "symfony/config": "", - "symfony/expression-language": "For using expressions in service container configuration", - "symfony/proxy-manager-bridge": "Generate service proxies to lazy load them", - "symfony/yaml": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\DependencyInjection\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony DependencyInjection Component", - "homepage": "https://symfony.com", - "time": "2018-11-11T11:18:13+00:00" - }, - { - "name": "symfony/event-dispatcher", - "version": "v2.8.49", - "source": { - "type": "git", - "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "a77e974a5fecb4398833b0709210e3d5e334ffb0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/a77e974a5fecb4398833b0709210e3d5e334ffb0", - "reference": "a77e974a5fecb4398833b0709210e3d5e334ffb0", - "shasum": "" - }, - "require": { - "php": ">=5.3.9" - }, - "require-dev": { - "psr/log": "~1.0", - "symfony/config": "^2.0.5|~3.0.0", - "symfony/dependency-injection": "~2.6|~3.0.0", - "symfony/expression-language": "~2.6|~3.0.0", - "symfony/stopwatch": "~2.3|~3.0.0" - }, - "suggest": { - "symfony/dependency-injection": "", - "symfony/http-kernel": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\EventDispatcher\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony EventDispatcher Component", - "homepage": "https://symfony.com", - "time": "2018-11-21T14:20:20+00:00" - }, - { - "name": "symfony/filesystem", - "version": "v2.8.49", - "source": { - "type": "git", - "url": "https://github.com/symfony/filesystem.git", - "reference": "7ae46872dad09dffb7fe1e93a0937097339d0080" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/7ae46872dad09dffb7fe1e93a0937097339d0080", - "reference": "7ae46872dad09dffb7fe1e93a0937097339d0080", - "shasum": "" - }, - "require": { - "php": ">=5.3.9", - "symfony/polyfill-ctype": "~1.8" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Filesystem\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Filesystem Component", - "homepage": "https://symfony.com", - "time": "2018-11-11T11:18:13+00:00" - }, - { - "name": "symfony/finder", - "version": "v2.8.49", - "source": { - "type": "git", - "url": "https://github.com/symfony/finder.git", - "reference": "1444eac52273e345d9b95129bf914639305a9ba4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/1444eac52273e345d9b95129bf914639305a9ba4", - "reference": "1444eac52273e345d9b95129bf914639305a9ba4", - "shasum": "" - }, - "require": { - "php": ">=5.3.9" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Finder\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Finder Component", - "homepage": "https://symfony.com", - "time": "2018-11-11T11:18:13+00:00" - }, - { - "name": "symfony/http-foundation", - "version": "v2.8.49", - "source": { - "type": "git", - "url": "https://github.com/symfony/http-foundation.git", - "reference": "d0ab719bedc9fc6748a95b2dcb04137292a27b92" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/d0ab719bedc9fc6748a95b2dcb04137292a27b92", - "reference": "d0ab719bedc9fc6748a95b2dcb04137292a27b92", - "shasum": "" - }, - "require": { - "php": ">=5.3.9", - "symfony/polyfill-mbstring": "~1.1", - "symfony/polyfill-php54": "~1.0", - "symfony/polyfill-php55": "~1.0" - }, - "require-dev": { - "symfony/expression-language": "~2.4|~3.0.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\HttpFoundation\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony HttpFoundation Component", - "homepage": "https://symfony.com", - "time": "2018-11-25T11:27:05+00:00" - }, - { - "name": "symfony/http-kernel", - "version": "v2.8.49", - "source": { - "type": "git", - "url": "https://github.com/symfony/http-kernel.git", - "reference": "3df0207d4c973eb9c91b38a608aef4654dc256fa" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/3df0207d4c973eb9c91b38a608aef4654dc256fa", - "reference": "3df0207d4c973eb9c91b38a608aef4654dc256fa", - "shasum": "" - }, - "require": { - "php": ">=5.3.9", - "psr/log": "~1.0", - "symfony/debug": "^2.6.2", - "symfony/event-dispatcher": "^2.6.7|~3.0.0", - "symfony/http-foundation": "~2.7.36|~2.8.29|~3.1.6", - "symfony/polyfill-ctype": "~1.8" - }, - "conflict": { - "symfony/config": "<2.7", - "twig/twig": "<1.34|<2.4,>=2" - }, - "require-dev": { - "symfony/browser-kit": "~2.3|~3.0.0", - "symfony/class-loader": "~2.1|~3.0.0", - "symfony/config": "~2.8", - "symfony/console": "~2.3|~3.0.0", - "symfony/css-selector": "^2.0.5|~3.0.0", - "symfony/dependency-injection": "~2.8|~3.0.0", - "symfony/dom-crawler": "^2.0.5|~3.0.0", - "symfony/expression-language": "~2.4|~3.0.0", - "symfony/finder": "^2.0.5|~3.0.0", - "symfony/process": "^2.0.5|~3.0.0", - "symfony/routing": "~2.8|~3.0.0", - "symfony/stopwatch": "~2.3|~3.0.0", - "symfony/templating": "~2.2|~3.0.0", - "symfony/translation": "^2.0.5|~3.0.0", - "symfony/var-dumper": "~2.6|~3.0.0" - }, - "suggest": { - "symfony/browser-kit": "", - "symfony/class-loader": "", - "symfony/config": "", - "symfony/console": "", - "symfony/dependency-injection": "", - "symfony/finder": "", - "symfony/var-dumper": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\HttpKernel\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony HttpKernel Component", - "homepage": "https://symfony.com", - "time": "2018-12-06T14:45:07+00:00" - }, - { - "name": "symfony/polyfill-ctype", - "version": "v1.11.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "82ebae02209c21113908c229e9883c419720738a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/82ebae02209c21113908c229e9883c419720738a", - "reference": "82ebae02209c21113908c229e9883c419720738a", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "suggest": { - "ext-ctype": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.11-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Ctype\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - }, - { - "name": "Gert de Pagter", - "email": "backendtea@gmail.com" - } - ], - "description": "Symfony polyfill for ctype functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "ctype", - "polyfill", - "portable" - ], - "time": "2019-02-06T07:57:58+00:00" - }, - { - "name": "symfony/polyfill-mbstring", - "version": "v1.11.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "fe5e94c604826c35a32fa832f35bd036b6799609" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/fe5e94c604826c35a32fa832f35bd036b6799609", - "reference": "fe5e94c604826c35a32fa832f35bd036b6799609", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "suggest": { - "ext-mbstring": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.11-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Mbstring\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for the Mbstring extension", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "mbstring", - "polyfill", - "portable", - "shim" - ], - "time": "2019-02-06T07:57:58+00:00" - }, - { - "name": "symfony/polyfill-php54", - "version": "v1.11.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php54.git", - "reference": "2964b17ddc32dba7bcba009d5501c84d3fba1452" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php54/zipball/2964b17ddc32dba7bcba009d5501c84d3fba1452", - "reference": "2964b17ddc32dba7bcba009d5501c84d3fba1452", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.11-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php54\\": "" - }, - "files": [ - "bootstrap.php" - ], - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 5.4+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "time": "2019-02-06T07:57:58+00:00" - }, - { - "name": "symfony/polyfill-php55", - "version": "v1.11.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php55.git", - "reference": "96fa25cef405ea452919559a0025d5dc16e30e4c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php55/zipball/96fa25cef405ea452919559a0025d5dc16e30e4c", - "reference": "96fa25cef405ea452919559a0025d5dc16e30e4c", - "shasum": "" - }, - "require": { - "ircmaxell/password-compat": "~1.0", - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.11-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php55\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 5.5+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "time": "2019-02-06T07:57:58+00:00" - }, - { - "name": "symfony/proxy-manager-bridge", - "version": "v2.8.49", - "source": { - "type": "git", - "url": "https://github.com/symfony/proxy-manager-bridge.git", - "reference": "9c5f8d58e9c8017affdbeaec86c89d558aee4ec8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/proxy-manager-bridge/zipball/9c5f8d58e9c8017affdbeaec86c89d558aee4ec8", - "reference": "9c5f8d58e9c8017affdbeaec86c89d558aee4ec8", - "shasum": "" - }, - "require": { - "ocramius/proxy-manager": "~0.4|~1.0|~2.0", - "php": ">=5.3.9", - "symfony/dependency-injection": "~2.8|~3.0.0" - }, - "require-dev": { - "symfony/config": "~2.3|~3.0.0" - }, - "type": "symfony-bridge", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Bridge\\ProxyManager\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony ProxyManager Bridge", - "homepage": "https://symfony.com", - "time": "2018-11-11T11:18:13+00:00" - }, - { - "name": "symfony/routing", - "version": "v2.8.49", - "source": { - "type": "git", - "url": "https://github.com/symfony/routing.git", - "reference": "8b0df6869d1997baafff6a1541826eac5a03d067" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/routing/zipball/8b0df6869d1997baafff6a1541826eac5a03d067", - "reference": "8b0df6869d1997baafff6a1541826eac5a03d067", - "shasum": "" - }, - "require": { - "php": ">=5.3.9" - }, - "conflict": { - "symfony/config": "<2.7" - }, - "require-dev": { - "doctrine/annotations": "~1.0", - "psr/log": "~1.0", - "symfony/config": "~2.7|~3.0.0", - "symfony/expression-language": "~2.4|~3.0.0", - "symfony/http-foundation": "~2.3|~3.0.0", - "symfony/yaml": "^2.0.5|~3.0.0" - }, - "suggest": { - "doctrine/annotations": "For using the annotation loader", - "symfony/config": "For using the all-in-one router or any loader", - "symfony/dependency-injection": "For loading routes from a service", - "symfony/expression-language": "For using expression matching", - "symfony/http-foundation": "For using a Symfony Request object", - "symfony/yaml": "For using the YAML loader" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Routing\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Routing Component", - "homepage": "https://symfony.com", - "keywords": [ - "router", - "routing", - "uri", - "url" - ], - "time": "2018-11-20T15:55:20+00:00" - }, - { - "name": "symfony/twig-bridge", - "version": "v2.8.49", - "source": { - "type": "git", - "url": "https://github.com/symfony/twig-bridge.git", - "reference": "ecc1e30d05fa99f25b504e2d6a8684555ae39f7c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/twig-bridge/zipball/ecc1e30d05fa99f25b504e2d6a8684555ae39f7c", - "reference": "ecc1e30d05fa99f25b504e2d6a8684555ae39f7c", - "shasum": "" - }, - "require": { - "php": ">=5.3.9", - "twig/twig": "~1.34|~2.4" - }, - "conflict": { - "symfony/form": "<2.8.23" - }, - "require-dev": { - "symfony/asset": "~2.7|~3.0.0", - "symfony/console": "~2.8|~3.0.0", - "symfony/expression-language": "~2.4|~3.0.0", - "symfony/finder": "~2.3|~3.0.0", - "symfony/form": "^2.8.23", - "symfony/http-foundation": "^2.8.29|~3.0.0", - "symfony/http-kernel": "~2.8|~3.0.0", - "symfony/polyfill-intl-icu": "~1.0", - "symfony/routing": "~2.2|~3.0.0", - "symfony/security": "^2.8.31|^3.3.13", - "symfony/security-acl": "~2.6|~3.0.0", - "symfony/stopwatch": "~2.2|~3.0.0", - "symfony/templating": "~2.1|~3.0.0", - "symfony/translation": "~2.7|~3.0.0", - "symfony/var-dumper": "~2.7.16|~2.8.9|~3.0.9", - "symfony/yaml": "^2.0.5|~3.0.0" - }, - "suggest": { - "symfony/asset": "For using the AssetExtension", - "symfony/expression-language": "For using the ExpressionExtension", - "symfony/finder": "", - "symfony/form": "For using the FormExtension", - "symfony/http-kernel": "For using the HttpKernelExtension", - "symfony/routing": "For using the RoutingExtension", - "symfony/security": "For using the SecurityExtension", - "symfony/stopwatch": "For using the StopwatchExtension", - "symfony/templating": "For using the TwigEngine", - "symfony/translation": "For using the TranslationExtension", - "symfony/var-dumper": "For using the DumpExtension", - "symfony/yaml": "For using the YamlExtension" - }, - "type": "symfony-bridge", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Bridge\\Twig\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Twig Bridge", - "homepage": "https://symfony.com", - "time": "2018-11-11T11:18:13+00:00" - }, - { - "name": "symfony/yaml", - "version": "v2.8.49", - "source": { - "type": "git", - "url": "https://github.com/symfony/yaml.git", - "reference": "02c1859112aa779d9ab394ae4f3381911d84052b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/02c1859112aa779d9ab394ae4f3381911d84052b", - "reference": "02c1859112aa779d9ab394ae4f3381911d84052b", - "shasum": "" - }, - "require": { - "php": ">=5.3.9", - "symfony/polyfill-ctype": "~1.8" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Yaml\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Yaml Component", - "homepage": "https://symfony.com", - "time": "2018-11-11T11:18:13+00:00" - }, - { - "name": "twig/twig", - "version": "v1.39.1", - "source": { - "type": "git", - "url": "https://github.com/twigphp/Twig.git", - "reference": "23e7b6f0cfa1d7ba3de69f30d8e05cf957412fec" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/23e7b6f0cfa1d7ba3de69f30d8e05cf957412fec", - "reference": "23e7b6f0cfa1d7ba3de69f30d8e05cf957412fec", - "shasum": "" - }, - "require": { - "php": ">=5.4.0", - "symfony/polyfill-ctype": "^1.8" - }, - "require-dev": { - "psr/container": "^1.0", - "symfony/debug": "^2.7", - "symfony/phpunit-bridge": "^3.4.19|^4.1.8" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.39-dev" - } - }, - "autoload": { - "psr-0": { - "Twig_": "lib/" - }, - "psr-4": { - "Twig\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, - { - "name": "Armin Ronacher", - "email": "armin.ronacher@active-4.com", - "role": "Project Founder" - }, - { - "name": "Twig Team", - "homepage": "https://twig.symfony.com/contributors", - "role": "Contributors" - } - ], - "description": "Twig, the flexible, fast, and secure template language for PHP", - "homepage": "https://twig.symfony.com", - "keywords": [ - "templating" - ], - "time": "2019-04-16T17:12:57+00:00" - }, - { - "name": "zendframework/zend-code", - "version": "2.5.1", - "source": { - "type": "git", - "url": "https://github.com/zendframework/zend-code.git", - "reference": "5d998f261ec2a55171c71da57a11622745680153" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-code/zipball/5d998f261ec2a55171c71da57a11622745680153", - "reference": "5d998f261ec2a55171c71da57a11622745680153", - "shasum": "" - }, - "require": { - "php": ">=5.3.23", - "zendframework/zend-eventmanager": "~2.5" - }, - "require-dev": { - "doctrine/common": ">=2.1", - "fabpot/php-cs-fixer": "1.7.*", - "phpunit/phpunit": "~4.0", - "zendframework/zend-stdlib": "~2.5", - "zendframework/zend-version": "~2.5" - }, - "suggest": { - "doctrine/common": "Doctrine\\Common >=2.1 for annotation features", - "zendframework/zend-stdlib": "Zend\\Stdlib component" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.5-dev", - "dev-develop": "2.6-dev" - } - }, - "autoload": { - "psr-4": { - "Zend\\Code\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "description": "provides facilities to generate arbitrary code using an object oriented interface", - "homepage": "https://github.com/zendframework/zend-code", - "keywords": [ - "code", - "zf2" - ], - "time": "2015-06-03T15:31:59+00:00" - }, - { - "name": "zendframework/zend-eventmanager", - "version": "2.5.1", - "source": { - "type": "git", - "url": "https://github.com/zendframework/zend-eventmanager.git", - "reference": "d94a16039144936f107f906896349900fd634443" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-eventmanager/zipball/d94a16039144936f107f906896349900fd634443", - "reference": "d94a16039144936f107f906896349900fd634443", - "shasum": "" - }, - "require": { - "php": ">=5.3.23", - "zendframework/zend-stdlib": "~2.5" - }, - "require-dev": { - "fabpot/php-cs-fixer": "1.7.*", - "phpunit/phpunit": "~4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.5-dev", - "dev-develop": "2.6-dev" - } - }, - "autoload": { - "psr-4": { - "Zend\\EventManager\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "homepage": "https://github.com/zendframework/zend-eventmanager", - "keywords": [ - "eventmanager", - "zf2" - ], - "time": "2015-06-03T15:32:01+00:00" - }, - { - "name": "zendframework/zend-stdlib", - "version": "2.5.1", - "source": { - "type": "git", - "url": "https://github.com/zendframework/zend-stdlib.git", - "reference": "cc8e90a60dd5d44b9730b77d07b97550091da1ae" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-stdlib/zipball/cc8e90a60dd5d44b9730b77d07b97550091da1ae", - "reference": "cc8e90a60dd5d44b9730b77d07b97550091da1ae", - "shasum": "" - }, - "require": { - "php": ">=5.3.23" - }, - "require-dev": { - "fabpot/php-cs-fixer": "1.7.*", - "phpunit/phpunit": "~4.0", - "zendframework/zend-config": "~2.5", - "zendframework/zend-eventmanager": "~2.5", - "zendframework/zend-filter": "~2.5", - "zendframework/zend-inputfilter": "~2.5", - "zendframework/zend-serializer": "~2.5", - "zendframework/zend-servicemanager": "~2.5" - }, - "suggest": { - "zendframework/zend-eventmanager": "To support aggregate hydrator usage", - "zendframework/zend-filter": "To support naming strategy hydrator usage", - "zendframework/zend-serializer": "Zend\\Serializer component", - "zendframework/zend-servicemanager": "To support hydrator plugin manager usage" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.5-dev", - "dev-develop": "2.6-dev" - } - }, - "autoload": { - "psr-4": { - "Zend\\Stdlib\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "homepage": "https://github.com/zendframework/zend-stdlib", - "keywords": [ - "stdlib", - "zf2" - ], - "time": "2015-06-03T15:32:03+00:00" - } - ], - "packages-dev": [ - { - "name": "doctrine/instantiator", - "version": "1.0.5", - "source": { - "type": "git", - "url": "https://github.com/doctrine/instantiator.git", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", - "shasum": "" - }, - "require": { - "php": ">=5.3,<8.0-DEV" - }, - "require-dev": { - "athletic/athletic": "~0.1.8", - "ext-pdo": "*", - "ext-phar": "*", - "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "~2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com", - "homepage": "http://ocramius.github.com/" - } - ], - "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://github.com/doctrine/instantiator", - "keywords": [ - "constructor", - "instantiate" - ], - "time": "2015-06-14T21:17:01+00:00" - }, - { - "name": "fabpot/goutte", - "version": "v2.0.4", - "source": { - "type": "git", - "url": "https://github.com/FriendsOfPHP/Goutte.git", - "reference": "0ad3ee6dc2d0aaa832a80041a1e09bf394e99802" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/FriendsOfPHP/Goutte/zipball/0ad3ee6dc2d0aaa832a80041a1e09bf394e99802", - "reference": "0ad3ee6dc2d0aaa832a80041a1e09bf394e99802", - "shasum": "" - }, - "require": { - "guzzlehttp/guzzle": ">=4,<6", - "php": ">=5.4.0", - "symfony/browser-kit": "~2.1", - "symfony/css-selector": "~2.1", - "symfony/dom-crawler": "~2.1" - }, - "type": "application", - "extra": { - "branch-alias": { - "dev-master": "2.0-dev" - } - }, - "autoload": { - "psr-4": { - "Goutte\\": "Goutte" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "A simple PHP Web Scraper", - "homepage": "https://github.com/FriendsOfPHP/Goutte", - "keywords": [ - "scraper" - ], - "time": "2015-05-05T21:14:57+00:00" - }, - { - "name": "facebook/webdriver", - "version": "1.1.3", - "source": { - "type": "git", - "url": "https://github.com/facebook/php-webdriver.git", - "reference": "b7186fb1bcfda956d237f59face250d06ef47253" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/facebook/php-webdriver/zipball/b7186fb1bcfda956d237f59face250d06ef47253", - "reference": "b7186fb1bcfda956d237f59face250d06ef47253", - "shasum": "" - }, - "require": { - "ext-curl": "*", - "php": ">=5.3.19" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^1.11", - "phpunit/phpunit": "4.6.* || ~5.0", - "squizlabs/php_codesniffer": "^2.6" - }, - "suggest": { - "phpdocumentor/phpdocumentor": "2.*" - }, - "type": "library", - "autoload": { - "psr-4": { - "Facebook\\WebDriver\\": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "description": "A PHP client for WebDriver", - "homepage": "https://github.com/facebook/php-webdriver", - "keywords": [ - "facebook", - "php", - "selenium", - "webdriver" - ], - "time": "2016-08-10T00:44:08+00:00" - }, - { - "name": "laravel/homestead", - "version": "v2.2.2", - "source": { - "type": "git", - "url": "https://github.com/laravel/homestead.git", - "reference": "f4e45f895d8707042c2d0698627d33c484e7c6ba" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/laravel/homestead/zipball/f4e45f895d8707042c2d0698627d33c484e7c6ba", - "reference": "f4e45f895d8707042c2d0698627d33c484e7c6ba", - "shasum": "" - }, - "require": { - "php": ">=5.4", - "symfony/console": "~2.0 || ~3.0", - "symfony/process": "~2.0 || ~3.0" - }, - "bin": [ - "homestead" - ], - "type": "library", - "autoload": { - "psr-4": { - "Laravel\\Homestead\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Taylor Otwell", - "email": "taylorotwell@gmail.com" - } - ], - "description": "A virtual machine for web artisans.", - "time": "2016-09-17T04:42:33+00:00" - }, - { - "name": "michelf/php-markdown", - "version": "1.8.0", - "source": { - "type": "git", - "url": "https://github.com/michelf/php-markdown.git", - "reference": "01ab082b355bf188d907b9929cd99b2923053495" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/michelf/php-markdown/zipball/01ab082b355bf188d907b9929cd99b2923053495", - "reference": "01ab082b355bf188d907b9929cd99b2923053495", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Michelf\\": "Michelf/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Michel Fortin", - "email": "michel.fortin@michelf.ca", - "homepage": "https://michelf.ca/", - "role": "Developer" - }, - { - "name": "John Gruber", - "homepage": "https://daringfireball.net/" - } - ], - "description": "PHP Markdown", - "homepage": "https://michelf.ca/projects/php-markdown/", - "keywords": [ - "markdown" - ], - "time": "2018-01-15T00:49:33+00:00" - }, - { - "name": "nikic/php-parser", - "version": "v0.9.5", - "source": { - "type": "git", - "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "ef70767475434bdb3615b43c327e2cae17ef12eb" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/ef70767475434bdb3615b43c327e2cae17ef12eb", - "reference": "ef70767475434bdb3615b43c327e2cae17ef12eb", - "shasum": "" - }, - "require": { - "ext-tokenizer": "*", - "php": ">=5.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "0.9-dev" - } - }, - "autoload": { - "psr-0": { - "PHPParser": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Nikita Popov" - } - ], - "description": "A PHP parser written in PHP", - "keywords": [ - "parser", - "php" - ], - "time": "2014-07-23T18:24:17+00:00" - }, - { - "name": "phing/phing", - "version": "2.4.14", - "source": { - "type": "git", - "url": "https://github.com/phingofficial/phing.git", - "reference": "41075d93ca254f1c90c79ec7ce81be2b2629e138" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phingofficial/phing/zipball/41075d93ca254f1c90c79ec7ce81be2b2629e138", - "reference": "41075d93ca254f1c90c79ec7ce81be2b2629e138", - "shasum": "" - }, - "require": { - "php": ">=5.2.0" - }, - "bin": [ - "bin/phing" - ], - "type": "library", - "autoload": { - "classmap": [ - "classes/phing/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "classes" - ], - "license": [ - "LGPL3" - ], - "authors": [ - { - "name": "Michiel Rook", - "email": "mrook@php.net" - }, - { - "name": "Phing Community", - "homepage": "http://www.phing.info/trac/wiki/Development/Contributors" - } - ], - "description": "PHing Is Not GNU make; it's a PHP project build system or build tool based on Apache Ant.", - "homepage": "http://www.phing.info/", - "keywords": [ - "build", - "task", - "tool" - ], - "time": "2012-11-29T21:23:47+00:00" - }, - { - "name": "phpdocumentor/reflection-docblock", - "version": "2.0.5", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "e6a969a640b00d8daa3c66518b0405fb41ae0c4b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/e6a969a640b00d8daa3c66518b0405fb41ae0c4b", - "reference": "e6a969a640b00d8daa3c66518b0405fb41ae0c4b", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "suggest": { - "dflydev/markdown": "~1.0", - "erusev/parsedown": "~1.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "psr-0": { - "phpDocumentor": [ - "src/" - ] - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "mike.vanriel@naenius.com" - } - ], - "time": "2016-01-25T08:17:30+00:00" - }, - { - "name": "phpspec/prophecy", - "version": "1.8.0", - "source": { - "type": "git", - "url": "https://github.com/phpspec/prophecy.git", - "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/4ba436b55987b4bf311cb7c6ba82aa528aac0a06", - "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.0.2", - "php": "^5.3|^7.0", - "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0", - "sebastian/comparator": "^1.1|^2.0|^3.0", - "sebastian/recursion-context": "^1.0|^2.0|^3.0" - }, - "require-dev": { - "phpspec/phpspec": "^2.5|^3.2", - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.8.x-dev" - } - }, - "autoload": { - "psr-0": { - "Prophecy\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Konstantin Kudryashov", - "email": "ever.zet@gmail.com", - "homepage": "http://everzet.com" - }, - { - "name": "Marcello Duarte", - "email": "marcello.duarte@gmail.com" - } - ], - "description": "Highly opinionated mocking framework for PHP 5.3+", - "homepage": "https://github.com/phpspec/prophecy", - "keywords": [ - "Double", - "Dummy", - "fake", - "mock", - "spy", - "stub" - ], - "time": "2018-08-05T17:53:17+00:00" - }, - { - "name": "phpunit/dbunit", - "version": "1.3.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/dbunit.git", - "reference": "1507040c2541bdffd7fbd71fc792cecdea6a7c61" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/dbunit/zipball/1507040c2541bdffd7fbd71fc792cecdea6a7c61", - "reference": "1507040c2541bdffd7fbd71fc792cecdea6a7c61", - "shasum": "" - }, - "require": { - "ext-pdo": "*", - "ext-simplexml": "*", - "php": ">=5.3.3", - "phpunit/phpunit": "~3.7|~4.0", - "symfony/yaml": "~2.1" - }, - "bin": [ - "composer/bin/dbunit" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3.x-dev" - } - }, - "autoload": { - "classmap": [ - "PHPUnit/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "", - "../../symfony/yaml/" - ], - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "DbUnit port for PHP/PHPUnit to support database interaction testing.", - "homepage": "https://github.com/sebastianbergmann/dbunit/", - "keywords": [ - "database", - "testing", - "xunit" - ], - "abandoned": true, - "time": "2015-03-29T14:23:04+00:00" - }, - { - "name": "phpunit/php-code-coverage", - "version": "2.2.4", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/eabf68b476ac7d0f73793aada060f1c1a9bf8979", - "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "phpunit/php-file-iterator": "~1.3", - "phpunit/php-text-template": "~1.2", - "phpunit/php-token-stream": "~1.3", - "sebastian/environment": "^1.3.2", - "sebastian/version": "~1.0" - }, - "require-dev": { - "ext-xdebug": ">=2.1.4", - "phpunit/phpunit": "~4" - }, - "suggest": { - "ext-dom": "*", - "ext-xdebug": ">=2.2.1", - "ext-xmlwriter": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.2.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", - "homepage": "https://github.com/sebastianbergmann/php-code-coverage", - "keywords": [ - "coverage", - "testing", - "xunit" - ], - "time": "2015-10-06T15:47:00+00:00" - }, - { - "name": "phpunit/php-file-iterator", - "version": "1.4.5", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/730b01bc3e867237eaac355e06a36b85dd93a8b4", - "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "FilterIterator implementation that filters files based on a list of suffixes.", - "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", - "keywords": [ - "filesystem", - "iterator" - ], - "time": "2017-11-27T13:52:08+00:00" - }, - { - "name": "phpunit/php-text-template", - "version": "1.2.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Simple template engine.", - "homepage": "https://github.com/sebastianbergmann/php-text-template/", - "keywords": [ - "template" - ], - "time": "2015-06-21T13:50:34+00:00" - }, - { - "name": "phpunit/php-timer", - "version": "1.0.9", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", - "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", - "shasum": "" - }, - "require": { - "php": "^5.3.3 || ^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Utility class for timing", - "homepage": "https://github.com/sebastianbergmann/php-timer/", - "keywords": [ - "timer" - ], - "time": "2017-02-26T11:10:40+00:00" - }, - { - "name": "phpunit/php-token-stream", - "version": "1.4.12", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "1ce90ba27c42e4e44e6d8458241466380b51fa16" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/1ce90ba27c42e4e44e6d8458241466380b51fa16", - "reference": "1ce90ba27c42e4e44e6d8458241466380b51fa16", - "shasum": "" - }, - "require": { - "ext-tokenizer": "*", - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Wrapper around PHP's tokenizer extension.", - "homepage": "https://github.com/sebastianbergmann/php-token-stream/", - "keywords": [ - "tokenizer" - ], - "time": "2017-12-04T08:55:13+00:00" - }, - { - "name": "phpunit/phpunit", - "version": "4.8.36", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "46023de9a91eec7dfb06cc56cb4e260017298517" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/46023de9a91eec7dfb06cc56cb4e260017298517", - "reference": "46023de9a91eec7dfb06cc56cb4e260017298517", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-json": "*", - "ext-pcre": "*", - "ext-reflection": "*", - "ext-spl": "*", - "php": ">=5.3.3", - "phpspec/prophecy": "^1.3.1", - "phpunit/php-code-coverage": "~2.1", - "phpunit/php-file-iterator": "~1.4", - "phpunit/php-text-template": "~1.2", - "phpunit/php-timer": "^1.0.6", - "phpunit/phpunit-mock-objects": "~2.3", - "sebastian/comparator": "~1.2.2", - "sebastian/diff": "~1.2", - "sebastian/environment": "~1.3", - "sebastian/exporter": "~1.2", - "sebastian/global-state": "~1.0", - "sebastian/version": "~1.0", - "symfony/yaml": "~2.1|~3.0" - }, - "suggest": { - "phpunit/php-invoker": "~1.1" - }, - "bin": [ - "phpunit" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.8.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "The PHP Unit Testing framework.", - "homepage": "https://phpunit.de/", - "keywords": [ - "phpunit", - "testing", - "xunit" - ], - "time": "2017-06-21T08:07:12+00:00" - }, - { - "name": "phpunit/phpunit-mock-objects", - "version": "2.3.8", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/ac8e7a3db35738d56ee9a76e78a4e03d97628983", - "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.0.2", - "php": ">=5.3.3", - "phpunit/php-text-template": "~1.2", - "sebastian/exporter": "~1.2" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "suggest": { - "ext-soap": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.3.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Mock Object library for PHPUnit", - "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", - "keywords": [ - "mock", - "xunit" - ], - "abandoned": true, - "time": "2015-10-02T06:51:40+00:00" - }, - { - "name": "pimple/pimple", - "version": "v1.0.2", - "source": { - "type": "git", - "url": "https://github.com/silexphp/Pimple.git", - "reference": "ae11e57e8c2bb414b2ff93396dbbfc0eb92feb94" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/silexphp/Pimple/zipball/ae11e57e8c2bb414b2ff93396dbbfc0eb92feb94", - "reference": "ae11e57e8c2bb414b2ff93396dbbfc0eb92feb94", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-0": { - "Pimple": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "Pimple is a simple Dependency Injection Container for PHP 5.3", - "homepage": "http://pimple.sensiolabs.org", - "keywords": [ - "container", - "dependency injection" - ], - "time": "2013-03-08T08:21:40+00:00" - }, - { - "name": "sami/sami", - "version": "v1.4.1", - "source": { - "type": "git", - "url": "https://github.com/FriendsOfPHP/Sami.git", - "reference": "160018bfefffa730dc35a2c606691a45acbf41a1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/FriendsOfPHP/Sami/zipball/160018bfefffa730dc35a2c606691a45acbf41a1", - "reference": "160018bfefffa730dc35a2c606691a45acbf41a1", - "shasum": "" - }, - "require": { - "michelf/php-markdown": "~1.3", - "nikic/php-parser": "0.9.*", - "php": ">=5.3.0", - "pimple/pimple": "1.0.*", - "symfony/console": "~2.1", - "symfony/filesystem": "~2.1", - "symfony/finder": "~2.1", - "symfony/process": "~2.1", - "symfony/yaml": "~2.1", - "twig/twig": "1.*" - }, - "bin": [ - "sami.php" - ], - "type": "application", - "extra": { - "branch-alias": { - "dev-master": "1.4-dev" - } - }, - "autoload": { - "psr-0": { - "Sami": "." - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "Sami, an API documentation generator", - "homepage": "http://sami.sensiolabs.org", - "keywords": [ - "phpdoc" - ], - "abandoned": true, - "time": "2015-06-05T03:36:34+00:00" - }, - { - "name": "sebastian/comparator", - "version": "1.2.4", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", - "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "sebastian/diff": "~1.2", - "sebastian/exporter": "~1.2 || ~2.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides the functionality to compare PHP values for equality", - "homepage": "http://www.github.com/sebastianbergmann/comparator", - "keywords": [ - "comparator", - "compare", - "equality" - ], - "time": "2017-01-29T09:50:25+00:00" - }, - { - "name": "sebastian/diff", - "version": "1.4.3", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/7f066a26a962dbe58ddea9f72a4e82874a3975a4", - "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4", - "shasum": "" - }, - "require": { - "php": "^5.3.3 || ^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Kore Nordmann", - "email": "mail@kore-nordmann.de" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Diff implementation", - "homepage": "https://github.com/sebastianbergmann/diff", - "keywords": [ - "diff" - ], - "time": "2017-05-22T07:24:03+00:00" - }, - { - "name": "sebastian/environment", - "version": "1.3.8", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "be2c607e43ce4c89ecd60e75c6a85c126e754aea" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/be2c607e43ce4c89ecd60e75c6a85c126e754aea", - "reference": "be2c607e43ce4c89ecd60e75c6a85c126e754aea", - "shasum": "" - }, - "require": { - "php": "^5.3.3 || ^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.8 || ^5.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides functionality to handle HHVM/PHP environments", - "homepage": "http://www.github.com/sebastianbergmann/environment", - "keywords": [ - "Xdebug", - "environment", - "hhvm" - ], - "time": "2016-08-18T05:49:44+00:00" - }, - { - "name": "sebastian/exporter", - "version": "1.2.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "42c4c2eec485ee3e159ec9884f95b431287edde4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/42c4c2eec485ee3e159ec9884f95b431287edde4", - "reference": "42c4c2eec485ee3e159ec9884f95b431287edde4", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "sebastian/recursion-context": "~1.0" - }, - "require-dev": { - "ext-mbstring": "*", - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - } - ], - "description": "Provides the functionality to export PHP variables for visualization", - "homepage": "http://www.github.com/sebastianbergmann/exporter", - "keywords": [ - "export", - "exporter" - ], - "time": "2016-06-17T09:04:28+00:00" - }, - { - "name": "sebastian/global-state", - "version": "1.1.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bc37d50fea7d017d3d340f230811c9f1d7280af4", - "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.2" - }, - "suggest": { - "ext-uopz": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Snapshotting of global state", - "homepage": "http://www.github.com/sebastianbergmann/global-state", - "keywords": [ - "global state" - ], - "time": "2015-10-12T03:26:01+00:00" - }, - { - "name": "sebastian/recursion-context", - "version": "1.0.5", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "b19cc3298482a335a95f3016d2f8a6950f0fbcd7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/b19cc3298482a335a95f3016d2f8a6950f0fbcd7", - "reference": "b19cc3298482a335a95f3016d2f8a6950f0fbcd7", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - } - ], - "description": "Provides functionality to recursively process PHP variables", - "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2016-10-03T07:41:43+00:00" - }, - { - "name": "sebastian/version", - "version": "1.0.6", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/version.git", - "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", - "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", - "shasum": "" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Library that helps with managing the version number of Git-hosted PHP projects", - "homepage": "https://github.com/sebastianbergmann/version", - "time": "2015-06-21T13:59:46+00:00" - }, - { - "name": "squizlabs/php_codesniffer", - "version": "2.9.2", - "source": { - "type": "git", - "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "2acf168de78487db620ab4bc524135a13cfe6745" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/2acf168de78487db620ab4bc524135a13cfe6745", - "reference": "2acf168de78487db620ab4bc524135a13cfe6745", - "shasum": "" - }, - "require": { - "ext-simplexml": "*", - "ext-tokenizer": "*", - "ext-xmlwriter": "*", - "php": ">=5.1.2" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "bin": [ - "scripts/phpcs", - "scripts/phpcbf" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.x-dev" - } - }, - "autoload": { - "classmap": [ - "CodeSniffer.php", - "CodeSniffer/CLI.php", - "CodeSniffer/Exception.php", - "CodeSniffer/File.php", - "CodeSniffer/Fixer.php", - "CodeSniffer/Report.php", - "CodeSniffer/Reporting.php", - "CodeSniffer/Sniff.php", - "CodeSniffer/Tokens.php", - "CodeSniffer/Reports/", - "CodeSniffer/Tokenizers/", - "CodeSniffer/DocGenerators/", - "CodeSniffer/Standards/AbstractPatternSniff.php", - "CodeSniffer/Standards/AbstractScopeSniff.php", - "CodeSniffer/Standards/AbstractVariableSniff.php", - "CodeSniffer/Standards/IncorrectPatternException.php", - "CodeSniffer/Standards/Generic/Sniffs/", - "CodeSniffer/Standards/MySource/Sniffs/", - "CodeSniffer/Standards/PEAR/Sniffs/", - "CodeSniffer/Standards/PSR1/Sniffs/", - "CodeSniffer/Standards/PSR2/Sniffs/", - "CodeSniffer/Standards/Squiz/Sniffs/", - "CodeSniffer/Standards/Zend/Sniffs/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Greg Sherwood", - "role": "lead" - } - ], - "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "http://www.squizlabs.com/php-codesniffer", - "keywords": [ - "phpcs", - "standards" - ], - "time": "2018-11-07T22:31:41+00:00" - }, - { - "name": "symfony/browser-kit", - "version": "v2.8.49", - "source": { - "type": "git", - "url": "https://github.com/symfony/browser-kit.git", - "reference": "b507697225f32a76a9d333d0766fb46353e9d00d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/browser-kit/zipball/b507697225f32a76a9d333d0766fb46353e9d00d", - "reference": "b507697225f32a76a9d333d0766fb46353e9d00d", - "shasum": "" - }, - "require": { - "php": ">=5.3.9", - "symfony/dom-crawler": "~2.1|~3.0.0" - }, - "require-dev": { - "symfony/css-selector": "^2.0.5|~3.0.0", - "symfony/process": "~2.3.34|^2.7.6|~3.0.0" - }, - "suggest": { - "symfony/process": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\BrowserKit\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony BrowserKit Component", - "homepage": "https://symfony.com", - "time": "2018-11-26T06:55:10+00:00" - }, - { - "name": "symfony/css-selector", - "version": "v2.8.49", - "source": { - "type": "git", - "url": "https://github.com/symfony/css-selector.git", - "reference": "7b1692e418d7ccac24c373528453bc90e42797de" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/css-selector/zipball/7b1692e418d7ccac24c373528453bc90e42797de", - "reference": "7b1692e418d7ccac24c373528453bc90e42797de", - "shasum": "" - }, - "require": { - "php": ">=5.3.9" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\CssSelector\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jean-François Simon", - "email": "jeanfrancois.simon@sensiolabs.com" - }, - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony CssSelector Component", - "homepage": "https://symfony.com", - "time": "2018-11-11T11:18:13+00:00" - }, - { - "name": "symfony/dom-crawler", - "version": "v2.8.49", - "source": { - "type": "git", - "url": "https://github.com/symfony/dom-crawler.git", - "reference": "2cdc7d3909eea6f982a6298d2e9ab7db01b6403c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/2cdc7d3909eea6f982a6298d2e9ab7db01b6403c", - "reference": "2cdc7d3909eea6f982a6298d2e9ab7db01b6403c", - "shasum": "" - }, - "require": { - "php": ">=5.3.9", - "symfony/polyfill-ctype": "~1.8", - "symfony/polyfill-mbstring": "~1.0" - }, - "require-dev": { - "symfony/css-selector": "~2.8|~3.0.0" - }, - "suggest": { - "symfony/css-selector": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\DomCrawler\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony DomCrawler Component", - "homepage": "https://symfony.com", - "time": "2018-11-24T22:30:19+00:00" - }, - { - "name": "symfony/process", - "version": "v2.8.49", - "source": { - "type": "git", - "url": "https://github.com/symfony/process.git", - "reference": "c3591a09c78639822b0b290d44edb69bf9f05dc8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/c3591a09c78639822b0b290d44edb69bf9f05dc8", - "reference": "c3591a09c78639822b0b290d44edb69bf9f05dc8", - "shasum": "" - }, - "require": { - "php": ">=5.3.9" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Process\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Process Component", - "homepage": "https://symfony.com", - "time": "2018-11-11T11:18:13+00:00" - } - ], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": [], - "prefer-stable": false, - "prefer-lowest": false, - "platform": { - "php": ">=5.4" - }, - "platform-dev": [], - "platform-overrides": { - "php": "5.4.7" - } -} diff --git a/install/update/old/config/default/container/parameters.yml b/install/update/old/config/default/container/parameters.yml deleted file mode 100644 index 8ecc142..0000000 --- a/install/update/old/config/default/container/parameters.yml +++ /dev/null @@ -1,20 +0,0 @@ -parameters: - # Disable the usage of the super globals (_GET, _POST, _SERVER...) - core.disable_super_globals: true - - # Datetime class to use - datetime.class: \phpbb\datetime - - # Mimetype guesser priorities - mimetype.guesser.priority.lowest: -2 - mimetype.guesser.priority.low: -1 - mimetype.guesser.priority.default: 0 - mimetype.guesser.priority.high: 1 - mimetype.guesser.priority.highest: 2 - - # List of default password driver types - passwords.algorithms: - - passwords.driver.bcrypt_2y - - passwords.driver.bcrypt - - passwords.driver.salted_md5 - - passwords.driver.phpass diff --git a/install/update/old/config/default/container/services.yml b/install/update/old/config/default/container/services.yml deleted file mode 100644 index 9bb1d67..0000000 --- a/install/update/old/config/default/container/services.yml +++ /dev/null @@ -1,169 +0,0 @@ -imports: - - { resource: services_attachment.yml } - - { resource: services_auth.yml } - - { resource: services_avatar.yml } - - { resource: services_captcha.yml } - - { resource: services_console.yml } - - { resource: services_content.yml } - - { resource: services_cron.yml } - - { resource: services_db.yml } - - { resource: services_event.yml } - - { resource: services_feed.yml } - - { resource: services_files.yml } - - { resource: services_filesystem.yml } - - { resource: services_help.yml } - - { resource: services_hook.yml } - - { resource: services_http.yml } - - { resource: services_language.yml } - - { resource: services_migrator.yml } - - { resource: services_mimetype_guesser.yml } - - { resource: services_module.yml } - - { resource: services_notification.yml } - - { resource: services_password.yml } - - { resource: services_php.yml } - - { resource: services_profilefield.yml } - - { resource: services_report.yml } - - { resource: services_routing.yml } - - { resource: services_text_formatter.yml } - - { resource: services_text_reparser.yml } - - { resource: services_twig.yml } - - { resource: services_user.yml } - - - { resource: tables.yml } - - { resource: parameters.yml } - -services: - cache: - class: phpbb\cache\service - arguments: - - '@cache.driver' - - '@config' - - '@dbal.conn' - - '%core.root_path%' - - '%core.php_ext%' - - cache.driver: - class: '%cache.driver.class%' - - class_loader: - class: phpbb\class_loader - arguments: - - phpbb\ - - '%core.root_path%includes/' - - '%core.php_ext%' - calls: - - [register, []] - - [set_cache, ['@cache.driver']] - - class_loader.ext: - class: phpbb\class_loader - arguments: - - \ - - '%core.root_path%ext/' - - '%core.php_ext%' - calls: - - [register, []] - - [set_cache, ['@cache.driver']] - - config: - class: phpbb\config\db - arguments: - - '@dbal.conn' - - '@cache.driver' - - '%tables.config%' - - config.php: - synthetic: true - - config_text: - class: phpbb\config\db_text - arguments: - - '@dbal.conn' - - '%tables.config_text%' - - controller.helper: - class: phpbb\controller\helper - arguments: - - '@template' - - '@user' - - '@config' - - '@symfony_request' - - '@request' - - '@routing.helper' - - controller.resolver: - class: phpbb\controller\resolver - arguments: - - '@service_container' - - '%core.root_path%' - - '@template' - - ext.manager: - class: phpbb\extension\manager - arguments: - - '@service_container' - - '@dbal.conn' - - '@config' - - '@filesystem' - - '%tables.ext%' - - '%core.root_path%' - - '%core.php_ext%' - - '@cache' - - file_downloader: - class: phpbb\file_downloader - - file_locator: - class: phpbb\routing\file_locator - arguments: - - '@filesystem' - - '%core.root_path%' - - group_helper: - class: phpbb\group\helper - arguments: - - '@language' - - log: - class: phpbb\log\log - arguments: - - '@dbal.conn' - - '@user' - - '@auth' - - '@dispatcher' - - '%core.root_path%' - - '%core.adm_relative_path%' - - '%core.php_ext%' - - '%tables.log%' - - path_helper: - class: phpbb\path_helper - arguments: - - '@symfony_request' - - '@filesystem' - - '@request' - - '%core.root_path%' - - '%core.php_ext%' - - '%core.adm_relative_path%' - - plupload: - class: phpbb\plupload\plupload - arguments: - - '%core.root_path%' - - '@config' - - '@request' - - '@user' - - '@php_ini' - - '@mimetype.guesser' - - upload_imagesize: - class: FastImageSize\FastImageSize - - version_helper: - class: phpbb\version_helper - shared: false - arguments: - - '@cache' - - '@config' - - '@file_downloader' - - '@user' diff --git a/install/update/old/config/default/container/services_auth.yml b/install/update/old/config/default/container/services_auth.yml deleted file mode 100644 index ed8dc90..0000000 --- a/install/update/old/config/default/container/services_auth.yml +++ /dev/null @@ -1,110 +0,0 @@ -services: -# ----- Auth management ----- - auth: - class: phpbb\auth\auth - -# ----- Auth providers ----- - auth.provider_collection: - class: phpbb\auth\provider_collection - arguments: - - '@service_container' - - '@config' - tags: - - { name: service_collection, tag: auth.provider } - - auth.provider.db: - class: phpbb\auth\provider\db - arguments: - - '@dbal.conn' - - '@config' - - '@passwords.manager' - - '@request' - - '@user' - - '@service_container' - - '%core.root_path%' - - '%core.php_ext%' - tags: - - { name: auth.provider } - - auth.provider.apache: - class: phpbb\auth\provider\apache - arguments: - - '@dbal.conn' - - '@config' - - '@passwords.manager' - - '@request' - - '@user' - - '%core.root_path%' - - '%core.php_ext%' - tags: - - { name: auth.provider } - - auth.provider.ldap: - class: phpbb\auth\provider\ldap - arguments: - - '@dbal.conn' - - '@config' - - '@passwords.manager' - - '@user' - tags: - - { name: auth.provider } - - auth.provider.oauth: - class: phpbb\auth\provider\oauth\oauth - arguments: - - '@dbal.conn' - - '@config' - - '@passwords.manager' - - '@request' - - '@user' - - '%tables.auth_provider_oauth_token_storage%' - - '%tables.auth_provider_oauth_states%' - - '%tables.auth_provider_oauth_account_assoc%' - - '@auth.provider.oauth.service_collection' - - '%tables.users%' - - '@service_container' - - '@dispatcher' - - '%core.root_path%' - - '%core.php_ext%' - tags: - - { name: auth.provider } - -# ----- OAuth services providers ----- - auth.provider.oauth.service_collection: - class: phpbb\di\service_collection - arguments: - - '@service_container' - tags: - - { name: service_collection, tag: auth.provider.oauth.service } - - auth.provider.oauth.service.bitly: - class: phpbb\auth\provider\oauth\service\bitly - arguments: - - '@config' - - '@request' - tags: - - { name: auth.provider.oauth.service } - - auth.provider.oauth.service.facebook: - class: phpbb\auth\provider\oauth\service\facebook - arguments: - - '@config' - - '@request' - tags: - - { name: auth.provider.oauth.service } - - auth.provider.oauth.service.google: - class: phpbb\auth\provider\oauth\service\google - arguments: - - '@config' - - '@request' - tags: - - { name: auth.provider.oauth.service } - - auth.provider.oauth.service.twitter: - class: phpbb\auth\provider\oauth\service\twitter - arguments: - - '@config' - - '@request' - tags: - - { name: auth.provider.oauth.service } diff --git a/install/update/old/config/default/container/services_console.yml b/install/update/old/config/default/container/services_console.yml deleted file mode 100644 index 05e467f..0000000 --- a/install/update/old/config/default/container/services_console.yml +++ /dev/null @@ -1,295 +0,0 @@ -services: - console.exception_subscriber: - class: phpbb\console\exception_subscriber - arguments: - - '@language' - tags: - - { name: kernel.event_subscriber } - - console.command_collection: - class: phpbb\di\service_collection - arguments: - - '@service_container' - tags: - - { name: service_collection, tag: console.command } - - console.command.cache.purge: - class: phpbb\console\command\cache\purge - arguments: - - '@user' - - '@cache.driver' - - '@dbal.conn' - - '@auth' - - '@log' - - '@config' - tags: - - { name: console.command } - - console.command.config.delete: - class: phpbb\console\command\config\delete - arguments: - - '@user' - - '@config' - tags: - - { name: console.command } - - console.command.config.increment: - class: phpbb\console\command\config\increment - arguments: - - '@user' - - '@config' - tags: - - { name: console.command } - - console.command.config.get: - class: phpbb\console\command\config\get - arguments: - - '@user' - - '@config' - tags: - - { name: console.command } - - console.command.config.set: - class: phpbb\console\command\config\set - arguments: - - '@user' - - '@config' - tags: - - { name: console.command } - - console.command.config.set_atomic: - class: phpbb\console\command\config\set_atomic - arguments: - - '@user' - - '@config' - tags: - - { name: console.command } - - console.command.cron.list: - class: phpbb\console\command\cron\cron_list - arguments: - - '@user' - - '@cron.manager' - tags: - - { name: console.command } - - console.command.cron.run: - class: phpbb\console\command\cron\run - arguments: - - '@user' - - '@cron.manager' - - '@cron.lock_db' - tags: - - { name: console.command } - - console.command.db.list: - class: phpbb\console\command\db\list_command - arguments: - - '@user' - - '@migrator' - - '@ext.manager' - - '@config' - - '@cache' - tags: - - { name: console.command } - - console.command.db.migrate: - class: phpbb\console\command\db\migrate - arguments: - - '@user' - - '@language' - - '@migrator' - - '@ext.manager' - - '@config' - - '@cache' - - '@log' - - '@filesystem' - - '%core.root_path%' - tags: - - { name: console.command } - - console.command.db.revert: - class: phpbb\console\command\db\revert - parent: console.command.db.migrate - tags: - - { name: console.command } - - console.command.dev.migration_tips: - class: phpbb\console\command\dev\migration_tips - arguments: - - '@user' - - '@ext.manager' - tags: - - { name: console.command } - - console.command.extension.disable: - class: phpbb\console\command\extension\disable - arguments: - - '@user' - - '@ext.manager' - - '@log' - tags: - - { name: console.command } - - console.command.extension.enable: - class: phpbb\console\command\extension\enable - arguments: - - '@user' - - '@ext.manager' - - '@log' - tags: - - { name: console.command } - - console.command.extension.purge: - class: phpbb\console\command\extension\purge - arguments: - - '@user' - - '@ext.manager' - - '@log' - tags: - - { name: console.command } - - console.command.extension.show: - class: phpbb\console\command\extension\show - arguments: - - '@user' - - '@ext.manager' - - '@log' - tags: - - { name: console.command } - - console.command.fixup.recalculate_email_hash: - class: phpbb\console\command\fixup\recalculate_email_hash - arguments: - - '@user' - - '@dbal.conn' - tags: - - { name: console.command } - - console.command.fixup.update_hashes: - class: phpbb\console\command\fixup\update_hashes - arguments: - - '@config' - - '@user' - - '@dbal.conn' - - '@passwords.manager' - - '@passwords.driver_collection' - - '%passwords.algorithms%' - tags: - - { name: console.command } - - console.command.fixup.fix_left_right_ids: - class: phpbb\console\command\fixup\fix_left_right_ids - arguments: - - '@user' - - '@dbal.conn' - - '@cache.driver' - tags: - - { name: console.command } - - console.command.reparser.list: - class: phpbb\console\command\reparser\list_all - arguments: - - '@user' - - '@text_reparser_collection' - tags: - - { name: console.command } - - console.command.reparser.reparse: - class: phpbb\console\command\reparser\reparse - arguments: - - '@user' - - '@text_reparser.lock' - - '@text_reparser.manager' - - '@text_reparser_collection' - tags: - - { name: console.command } - - console.command.thumbnail.delete: - class: phpbb\console\command\thumbnail\delete - arguments: - - '@config' - - '@user' - - '@dbal.conn' - - '%core.root_path%' - tags: - - { name: console.command } - - console.command.thumbnail.generate: - class: phpbb\console\command\thumbnail\generate - arguments: - - '@config' - - '@user' - - '@dbal.conn' - - '@cache' - - '%core.root_path%' - - '%core.php_ext%' - tags: - - { name: console.command } - - console.command.thumbnail.recreate: - class: phpbb\console\command\thumbnail\recreate - arguments: - - '@user' - tags: - - { name: console.command } - - console.command.update.check: - class: phpbb\console\command\update\check - arguments: - - '@user' - - '@config' - - '@service_container' - - '@language' - tags: - - { name: console.command } - - console.command.user.activate: - class: phpbb\console\command\user\activate - arguments: - - '@user' - - '@dbal.conn' - - '@config' - - '@language' - - '@log' - - '@notification_manager' - - '@user_loader' - - '%core.root_path%' - - '%core.php_ext%' - tags: - - { name: console.command } - - console.command.user.add: - class: phpbb\console\command\user\add - arguments: - - '@user' - - '@dbal.conn' - - '@config' - - '@language' - - '@passwords.manager' - - '%core.root_path%' - - '%core.php_ext%' - tags: - - { name: console.command } - - console.command.user.delete: - class: phpbb\console\command\user\delete - arguments: - - '@user' - - '@dbal.conn' - - '@language' - - '@log' - - '@user_loader' - - '%core.root_path%' - - '%core.php_ext%' - tags: - - { name: console.command } - - console.command.user.reclean: - class: phpbb\console\command\user\reclean - arguments: - - '@user' - - '@dbal.conn' - - '@language' - tags: - - { name: console.command } diff --git a/install/update/old/config/default/container/services_cron.yml b/install/update/old/config/default/container/services_cron.yml deleted file mode 100644 index d7f6388..0000000 --- a/install/update/old/config/default/container/services_cron.yml +++ /dev/null @@ -1,235 +0,0 @@ -services: - cron.manager: - class: phpbb\cron\manager - arguments: - - '@cron.task_collection' - - '%core.root_path%' - - '%core.php_ext%' - - cron.lock_db: - class: phpbb\lock\db - arguments: - - cron_lock - - '@config' - - '@dbal.conn' - -# ----- Cron tasks ----- - cron.task_collection: - class: phpbb\di\service_collection - arguments: - - '@service_container' - tags: - - { name: service_collection, tag: cron.task } - - cron.task.core.prune_all_forums: - class: phpbb\cron\task\core\prune_all_forums - arguments: - - '%core.root_path%' - - '%core.php_ext%' - - '@config' - - '@dbal.conn' - calls: - - [set_name, [cron.task.core.prune_all_forums]] - tags: - - { name: cron.task } - - cron.task.core.prune_forum: - class: phpbb\cron\task\core\prune_forum - arguments: - - '%core.root_path%' - - '%core.php_ext%' - - '@config' - - '@dbal.conn' - calls: - - [set_name, [cron.task.core.prune_forum]] - tags: - - { name: cron.task } - - cron.task.core.prune_shadow_topics: - class: phpbb\cron\task\core\prune_shadow_topics - arguments: - - '%core.root_path%' - - '%core.php_ext%' - - '@config' - - '@dbal.conn' - - '@log' - - '@user' - calls: - - [set_name, [cron.task.core.prune_shadow_topics]] - tags: - - { name: cron.task } - - cron.task.core.prune_notifications: - class: phpbb\cron\task\core\prune_notifications - arguments: - - '@config' - - '@notification_manager' - calls: - - [set_name, [cron.task.core.prune_notifications]] - tags: - - { name: cron.task } - - cron.task.core.queue: - class: phpbb\cron\task\core\queue - arguments: - - '%core.root_path%' - - '%core.php_ext%' - - '@config' - - '%core.cache_dir%' - calls: - - [set_name, [cron.task.core.queue]] - tags: - - { name: cron.task } - - cron.task.core.tidy_cache: - class: phpbb\cron\task\core\tidy_cache - arguments: - - '@config' - - '@cache.driver' - calls: - - [set_name, [cron.task.core.tidy_cache]] - tags: - - { name: cron.task } - - cron.task.core.tidy_database: - class: phpbb\cron\task\core\tidy_database - arguments: - - '%core.root_path%' - - '%core.php_ext%' - - '@config' - calls: - - [set_name, [cron.task.core.tidy_database]] - tags: - - { name: cron.task } - - cron.task.core.tidy_plupload: - class: phpbb\cron\task\core\tidy_plupload - arguments: - - '%core.root_path%' - - '@config' - - '@log' - - '@user' - calls: - - [set_name, [cron.task.core.tidy_plupload]] - tags: - - { name: cron.task } - - cron.task.core.tidy_search: - class: phpbb\cron\task\core\tidy_search - arguments: - - '%core.root_path%' - - '%core.php_ext%' - - '@auth' - - '@config' - - '@dbal.conn' - - '@user' - - '@dispatcher' - calls: - - [set_name, [cron.task.core.tidy_search]] - tags: - - { name: cron.task } - - cron.task.core.tidy_sessions: - class: phpbb\cron\task\core\tidy_sessions - arguments: - - '@config' - - '@user' - calls: - - [set_name, [cron.task.core.tidy_sessions]] - tags: - - { name: cron.task } - - cron.task.core.tidy_warnings: - class: phpbb\cron\task\core\tidy_warnings - arguments: - - '%core.root_path%' - - '%core.php_ext%' - - '@config' - calls: - - [set_name, [cron.task.core.tidy_warnings]] - tags: - - { name: cron.task } - - cron.task.text_reparser.pm_text: - class: phpbb\cron\task\text_reparser\reparser - arguments: - - '@config' - - '@config_text' - - '@text_reparser.lock' - - '@text_reparser.manager' - - '@text_reparser_collection' - calls: - - [set_name, [cron.task.text_reparser.pm_text]] - - [set_reparser, [text_reparser.pm_text]] - tags: - - { name: cron.task } - - cron.task.text_reparser.poll_option: - class: phpbb\cron\task\text_reparser\reparser - arguments: - - '@config' - - '@config_text' - - '@text_reparser.lock' - - '@text_reparser.manager' - - '@text_reparser_collection' - calls: - - [set_name, [cron.task.text_reparser.poll_option]] - - [set_reparser, [text_reparser.poll_option]] - tags: - - { name: cron.task } - - cron.task.text_reparser.poll_title: - class: phpbb\cron\task\text_reparser\reparser - arguments: - - '@config' - - '@config_text' - - '@text_reparser.lock' - - '@text_reparser.manager' - - '@text_reparser_collection' - calls: - - [set_name, [cron.task.text_reparser.poll_title]] - - [set_reparser, [text_reparser.poll_title]] - tags: - - { name: cron.task } - - cron.task.text_reparser.post_text: - class: phpbb\cron\task\text_reparser\reparser - arguments: - - '@config' - - '@config_text' - - '@text_reparser.lock' - - '@text_reparser.manager' - - '@text_reparser_collection' - calls: - - [set_name, [cron.task.text_reparser.post_text]] - - [set_reparser, [text_reparser.post_text]] - tags: - - { name: cron.task } - - cron.task.text_reparser.user_signature: - class: phpbb\cron\task\text_reparser\reparser - arguments: - - '@config' - - '@config_text' - - '@text_reparser.lock' - - '@text_reparser.manager' - - '@text_reparser_collection' - calls: - - [set_name, [cron.task.text_reparser.user_signature]] - - [set_reparser, [text_reparser.user_signature]] - tags: - - { name: cron.task } - - cron.task.core.update_hashes: - class: phpbb\cron\task\core\update_hashes - arguments: - - '@config' - - '@dbal.conn' - - '@passwords.update.lock' - - '@passwords.manager' - - '@passwords.driver_collection' - - '%passwords.algorithms%' - calls: - - [set_name, [cron.task.core.update_hashes]] - tags: - - { name: cron.task } diff --git a/install/update/old/config/default/container/services_password.yml b/install/update/old/config/default/container/services_password.yml deleted file mode 100644 index d5f5fe2..0000000 --- a/install/update/old/config/default/container/services_password.yml +++ /dev/null @@ -1,136 +0,0 @@ -parameters: - passwords.driver.bcrypt_cost: 10 - -services: -# ----- Password management ----- - passwords.manager: - class: phpbb\passwords\manager - arguments: - - '@config' - - '@passwords.driver_collection' - - '@passwords.helper' - - '%passwords.algorithms%' - - passwords.helper: - class: phpbb\passwords\helper - - passwords.driver_helper: - class: phpbb\passwords\driver\helper - arguments: - - '@config' - -# ----- Password's drivers ----- - passwords.driver_collection: - class: phpbb\di\service_collection - arguments: - - '@service_container' - tags: - - { name: service_collection, tag: passwords.driver } - - passwords.driver.bcrypt: - class: phpbb\passwords\driver\bcrypt - arguments: - - '@config' - - '@passwords.driver_helper' - - '%passwords.driver.bcrypt_cost%' - tags: - - { name: passwords.driver } - - passwords.driver.bcrypt_2y: - class: phpbb\passwords\driver\bcrypt_2y - arguments: - - '@config' - - '@passwords.driver_helper' - - '%passwords.driver.bcrypt_cost%' - tags: - - { name: passwords.driver } - - passwords.driver.bcrypt_wcf2: - class: phpbb\passwords\driver\bcrypt_wcf2 - arguments: - - '@passwords.driver.bcrypt' - - '@passwords.driver_helper' - tags: - - { name: passwords.driver } - - passwords.driver.salted_md5: - class: phpbb\passwords\driver\salted_md5 - arguments: - - '@config' - - '@passwords.driver_helper' - tags: - - { name: passwords.driver } - - passwords.driver.phpass: - class: phpbb\passwords\driver\phpass - arguments: - - '@config' - - '@passwords.driver_helper' - tags: - - { name: passwords.driver } - - passwords.driver.convert_password: - class: phpbb\passwords\driver\convert_password - arguments: - - '@config' - - '@passwords.driver_helper' - tags: - - { name: passwords.driver } - - passwords.driver.sha1_smf: - class: phpbb\passwords\driver\sha1_smf - arguments: - - '@config' - - '@passwords.driver_helper' - tags: - - { name: passwords.driver } - - passwords.driver.sha1_wcf1: - class: phpbb\passwords\driver\sha1_wcf1 - arguments: - - '@config' - - '@passwords.driver_helper' - tags: - - { name: passwords.driver } - - passwords.driver.sha1: - class: phpbb\passwords\driver\sha1 - arguments: - - '@config' - - '@passwords.driver_helper' - tags: - - { name: passwords.driver } - - passwords.driver.md5_phpbb2: - class: phpbb\passwords\driver\md5_phpbb2 - arguments: - - '@request' - - '@passwords.driver.salted_md5' - - '@passwords.driver_helper' - - '%core.root_path%' - - '%core.php_ext%' - tags: - - { name: passwords.driver } - - passwords.driver.md5_mybb: - class: phpbb\passwords\driver\md5_mybb - arguments: - - '@config' - - '@passwords.driver_helper' - tags: - - { name: passwords.driver } - - passwords.driver.md5_vb: - class: phpbb\passwords\driver\md5_vb - arguments: - - '@config' - - '@passwords.driver_helper' - tags: - - { name: passwords.driver } - - passwords.update.lock: - class: phpbb\lock\db - arguments: - - update_hashes_lock - - '@config' - - '@dbal.conn' diff --git a/install/update/old/config/default/container/services_routing.yml b/install/update/old/config/default/container/services_routing.yml deleted file mode 100644 index 3048145..0000000 --- a/install/update/old/config/default/container/services_routing.yml +++ /dev/null @@ -1,79 +0,0 @@ -services: - router: - class: phpbb\routing\router - arguments: - - '@service_container' - - '@routing.chained_resources_locator' - - '@routing.delegated_loader' - - '%core.php_ext%' - - '%core.cache_dir%' - - router.listener: - class: Symfony\Component\HttpKernel\EventListener\RouterListener - arguments: - - '@router' - - null - - null - - '@request_stack' - tags: - - { name: kernel.event_subscriber } - - routing.helper: - class: phpbb\routing\helper - arguments: - - '@config' - - '@router' - - '@symfony_request' - - '@request' - - '@filesystem' - - '%core.root_path%' - - '%core.php_ext%' - -# ---- Route loaders ---- - - routing.delegated_loader: - class: Symfony\Component\Config\Loader\DelegatingLoader - arguments: - - '@routing.resolver' - - routing.resolver: - class: phpbb\routing\loader_resolver - arguments: - - '@routing.loader.collection' - - routing.loader.collection: - class: phpbb\di\service_collection - arguments: - - '@service_container' - tags: - - { name: service_collection, tag: routing.loader } - - routing.loader.yaml: - class: Symfony\Component\Routing\Loader\YamlFileLoader - arguments: - - '@file_locator' - tags: - - { name: routing.loader } - -# ---- Resources Locators ---- - - routing.chained_resources_locator: - class: phpbb\routing\resources_locator\chained_resources_locator - arguments: - - '@routing.resources_locator.collection' - - routing.resources_locator.collection: - class: phpbb\di\service_collection - arguments: - - '@service_container' - tags: - - { name: service_collection, tag: routing.resources_locator } - - routing.resources_locator.default: - class: phpbb\routing\resources_locator\default_resources_locator - arguments: - - '%core.root_path%' - - '%core.environment%' - - '@ext.manager' - tags: - - { name: routing.resources_locator } diff --git a/install/update/old/config/default/container/services_text_formatter.yml b/install/update/old/config/default/container/services_text_formatter.yml deleted file mode 100644 index 07087cd..0000000 --- a/install/update/old/config/default/container/services_text_formatter.yml +++ /dev/null @@ -1,79 +0,0 @@ -parameters: - text_formatter.cache.dir: '%core.cache_dir%' - text_formatter.cache.parser.key: _text_formatter_parser - text_formatter.cache.renderer.key: _text_formatter_renderer - -services: - text_formatter.cache: - alias: text_formatter.s9e.factory - - text_formatter.data_access: - class: phpbb\textformatter\data_access - arguments: - - '@dbal.conn' - - '%tables.bbcodes%' - - '%tables.smilies%' - - '%tables.styles%' - - '%tables.words%' - - '%core.root_path%styles/' - - text_formatter.parser: - alias: text_formatter.s9e.parser - - text_formatter.renderer: - alias: text_formatter.s9e.renderer - - text_formatter.utils: - alias: text_formatter.s9e.utils - - text_formatter.s9e.bbcode_merger: - class: phpbb\textformatter\s9e\bbcode_merger - arguments: - - '@text_formatter.s9e.factory' - - text_formatter.s9e.factory: - class: phpbb\textformatter\s9e\factory - arguments: - - '@text_formatter.data_access' - - '@cache.driver' - - '@dispatcher' - - '@config' - - '@text_formatter.s9e.link_helper' - - '@log' - - '%text_formatter.cache.dir%' - - '%text_formatter.cache.parser.key%' - - '%text_formatter.cache.renderer.key%' - - text_formatter.s9e.link_helper: - class: phpbb\textformatter\s9e\link_helper - - text_formatter.s9e.parser: - class: phpbb\textformatter\s9e\parser - arguments: - - '@cache.driver' - - '%text_formatter.cache.parser.key%' - - '@text_formatter.s9e.factory' - - '@dispatcher' - - text_formatter.s9e.quote_helper: - class: phpbb\textformatter\s9e\quote_helper - arguments: - - '@user' - - '%core.root_path%' - - '%core.php_ext%' - - text_formatter.s9e.renderer: - class: phpbb\textformatter\s9e\renderer - arguments: - - '@cache.driver' - - '%text_formatter.cache.dir%' - - '%text_formatter.cache.renderer.key%' - - '@text_formatter.s9e.factory' - - '@dispatcher' - calls: - - [configure_quote_helper, ['@text_formatter.s9e.quote_helper']] - - [configure_smilies_path, ['@config', '@path_helper']] - - [configure_user, ['@user', '@config', '@auth']] - - text_formatter.s9e.utils: - class: phpbb\textformatter\s9e\utils diff --git a/install/update/old/config/default/container/services_twig.yml b/install/update/old/config/default/container/services_twig.yml deleted file mode 100644 index a9b5b6d..0000000 --- a/install/update/old/config/default/container/services_twig.yml +++ /dev/null @@ -1,68 +0,0 @@ -parameters: - core.template.cache_path: '%core.cache_dir%twig/' - -services: - template.twig.environment: - class: phpbb\template\twig\environment - arguments: - - '@config' - - '@filesystem' - - '@path_helper' - - '%core.template.cache_path%' - - '@ext.manager' - - '@template.twig.loader' - - '@dispatcher' - - [] - calls: - - [setLexer, ['@template.twig.lexer']] - - template.twig.lexer: - class: phpbb\template\twig\lexer - lazy: true - arguments: - - '@template.twig.environment' - - template.twig.loader: - class: phpbb\template\twig\loader - arguments: - - '@filesystem' - - template.twig.extensions.collection: - class: phpbb\di\service_collection - arguments: - - '@service_container' - tags: - - { name: service_collection, tag: twig.extension } - - template.twig.extensions.phpbb: - class: phpbb\template\twig\extension - arguments: - - '@template_context' - - '@language' - tags: - - { name: twig.extension } - - template.twig.extensions.routing: - class: phpbb\template\twig\extension\routing - arguments: - - '@routing.helper' - tags: - - { name: twig.extension } - - template.twig.extensions.debug: - class: Twig_Extension_Debug - - template: - class: phpbb\template\twig\twig - arguments: - - '@path_helper' - - '@config' - - '@template_context' - - '@template.twig.environment' - - '%core.template.cache_path%' - - '@user' - - '@template.twig.extensions.collection' - - '@ext.manager' - - template_context: - class: phpbb\template\context diff --git a/install/update/old/config/default/routing/routing.yml b/install/update/old/config/default/routing/routing.yml deleted file mode 100644 index f381f02..0000000 --- a/install/update/old/config/default/routing/routing.yml +++ /dev/null @@ -1,24 +0,0 @@ -# Structure: -# -# foo_controller: -# path: /foo -# defaults: { _controller: foo_sevice:method } -# -# The above will be accessed via app.php?controller=foo and it will -# instantiate the 'foo_service' service and call the 'method' method. -# - -phpbb_feed_routing: - resource: feed.yml - prefix: /feed - -phpbb_feed_index: - path: /feed - defaults: { _controller: phpbb.feed.controller:overall } - -phpbb_help_routing: - resource: help.yml - prefix: /help - -phpbb_report_routing: - resource: report.yml diff --git a/install/update/old/cron.php b/install/update/old/cron.php deleted file mode 100644 index 2f51994..0000000 --- a/install/update/old/cron.php +++ /dev/null @@ -1,84 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -*/ -define('IN_PHPBB', true); -define('IN_CRON', true); -$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); -include($phpbb_root_path . 'common.' . $phpEx); - -// Do not update users last page entry -$user->session_begin(false); -$auth->acl($user->data); - -function output_image() -{ - // Output transparent gif - header('Cache-Control: no-cache'); - header('Content-type: image/gif'); - header('Content-length: 43'); - - echo base64_decode('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='); - - // Flush here to prevent browser from showing the page as loading while - // running cron. - flush(); -} - -// Thanks to various fatal errors and lack of try/finally, it is quite easy to leave -// the cron lock locked, especially when working on cron-related code. -// -// Attempt to alleviate the problem by doing setup outside of the lock as much as possible. - -$cron_type = $request->variable('cron_type', ''); - -// Comment this line out for debugging so the page does not return an image. -output_image(); - -/* @var $cron_lock \phpbb\lock\db */ -$cron_lock = $phpbb_container->get('cron.lock_db'); -if ($cron_lock->acquire()) -{ - /* @var $cron \phpbb\cron\manager */ - $cron = $phpbb_container->get('cron.manager'); - - $task = $cron->find_task($cron_type); - if ($task) - { - /** - * This event enables you to catch the task before it runs - * - * @event core.cron_run_before - * @var \phpbb\cron\task\wrapper task Current Cron task - * @since 3.1.8-RC1 - */ - $vars = array( - 'task', - ); - extract($phpbb_dispatcher->trigger_event('core.cron_run_before', compact($vars))); - - if ($task->is_parametrized()) - { - $task->parse_parameters($request); - } - if ($task->is_ready()) - { - $task->run(); - } - } - $cron_lock->release(); -} - -garbage_collection(); diff --git a/install/update/old/download/file.php b/install/update/old/download/file.php deleted file mode 100644 index 9ee489c..0000000 --- a/install/update/old/download/file.php +++ /dev/null @@ -1,326 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -define('IN_PHPBB', true); -$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); - -// Thank you sun. -if (isset($_SERVER['CONTENT_TYPE'])) -{ - if ($_SERVER['CONTENT_TYPE'] === 'application/x-java-archive') - { - exit; - } -} -else if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'Java') !== false) -{ - exit; -} - -if (isset($_GET['avatar'])) -{ - require($phpbb_root_path . 'includes/startup.' . $phpEx); - - require($phpbb_root_path . 'phpbb/class_loader.' . $phpEx); - $phpbb_class_loader = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}phpbb/", $phpEx); - $phpbb_class_loader->register(); - - $phpbb_config_php_file = new \phpbb\config_php_file($phpbb_root_path, $phpEx); - extract($phpbb_config_php_file->get_all()); - - if (!defined('PHPBB_ENVIRONMENT')) - { - @define('PHPBB_ENVIRONMENT', 'production'); - } - - if (!defined('PHPBB_INSTALLED') || empty($dbms) || empty($acm_type)) - { - exit; - } - - require($phpbb_root_path . 'includes/constants.' . $phpEx); - require($phpbb_root_path . 'includes/functions.' . $phpEx); - require($phpbb_root_path . 'includes/functions_download' . '.' . $phpEx); - require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); - - // Setup class loader first - $phpbb_class_loader_ext = new \phpbb\class_loader('\\', "{$phpbb_root_path}ext/", $phpEx); - $phpbb_class_loader_ext->register(); - - // Set up container - $phpbb_container_builder = new \phpbb\di\container_builder($phpbb_root_path, $phpEx); - $phpbb_container = $phpbb_container_builder->with_config($phpbb_config_php_file)->get_container(); - - $phpbb_class_loader->set_cache($phpbb_container->get('cache.driver')); - $phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver')); - - // set up caching - /* @var $cache \phpbb\cache\service */ - $cache = $phpbb_container->get('cache'); - - /* @var $phpbb_dispatcher \phpbb\event\dispatcher */ - $phpbb_dispatcher = $phpbb_container->get('dispatcher'); - - /* @var $request \phpbb\request\request_interface */ - $request = $phpbb_container->get('request'); - - /* @var $db \phpbb\db\driver\driver_interface */ - $db = $phpbb_container->get('dbal.conn'); - - /* @var $phpbb_log \phpbb\log\log_interface */ - $phpbb_log = $phpbb_container->get('log'); - - unset($dbpasswd); - - /* @var $config \phpbb\config\config */ - $config = $phpbb_container->get('config'); - - // load extensions - /* @var $phpbb_extension_manager \phpbb\extension\manager */ - $phpbb_extension_manager = $phpbb_container->get('ext.manager'); - - // worst-case default - $browser = strtolower($request->header('User-Agent', 'msie 6.0')); - - /* @var $phpbb_avatar_manager \phpbb\avatar\manager */ - $phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); - - $filename = $request->variable('avatar', ''); - $avatar_group = false; - $exit = false; - - if (isset($filename[0]) && $filename[0] === 'g') - { - $avatar_group = true; - $filename = substr($filename, 1); - } - - // '==' is not a bug - . as the first char is as bad as no dot at all - if (strpos($filename, '.') == false) - { - send_status_line(403, 'Forbidden'); - $exit = true; - } - - if (!$exit) - { - $ext = substr(strrchr($filename, '.'), 1); - $stamp = (int) substr(stristr($filename, '_'), 1); - $filename = (int) $filename; - $exit = set_modified_headers($stamp, $browser); - } - if (!$exit && !in_array($ext, array('png', 'gif', 'jpg', 'jpeg'))) - { - // no way such an avatar could exist. They are not following the rules, stop the show. - send_status_line(403, 'Forbidden'); - $exit = true; - } - - - if (!$exit) - { - if (!$filename) - { - // no way such an avatar could exist. They are not following the rules, stop the show. - send_status_line(403, 'Forbidden'); - } - else - { - send_avatar_to_browser(($avatar_group ? 'g' : '') . $filename . '.' . $ext, $browser); - } - } - file_gc(); -} - -// implicit else: we are not in avatar mode -include($phpbb_root_path . 'common.' . $phpEx); -require($phpbb_root_path . 'includes/functions_download' . '.' . $phpEx); - -$attach_id = $request->variable('id', 0); -$mode = $request->variable('mode', ''); -$thumbnail = $request->variable('t', false); - -// Start session management, do not update session page. -$user->session_begin(false); -$auth->acl($user->data); -$user->setup('viewtopic'); - -$phpbb_content_visibility = $phpbb_container->get('content.visibility'); - -if (!$config['allow_attachments'] && !$config['allow_pm_attach']) -{ - send_status_line(404, 'Not Found'); - trigger_error('ATTACHMENT_FUNCTIONALITY_DISABLED'); -} - -if (!$attach_id) -{ - send_status_line(404, 'Not Found'); - trigger_error('NO_ATTACHMENT_SELECTED'); -} - -$sql = 'SELECT attach_id, post_msg_id, topic_id, in_message, poster_id, is_orphan, physical_filename, real_filename, extension, mimetype, filesize, filetime - FROM ' . ATTACHMENTS_TABLE . " - WHERE attach_id = $attach_id"; -$result = $db->sql_query($sql); -$attachment = $db->sql_fetchrow($result); -$db->sql_freeresult($result); - -if (!$attachment) -{ - send_status_line(404, 'Not Found'); - trigger_error('ERROR_NO_ATTACHMENT'); -} -else if (!download_allowed()) -{ - send_status_line(403, 'Forbidden'); - trigger_error($user->lang['LINKAGE_FORBIDDEN']); -} -else -{ - $attachment['physical_filename'] = utf8_basename($attachment['physical_filename']); - - if (!$attachment['in_message'] && !$config['allow_attachments'] || $attachment['in_message'] && !$config['allow_pm_attach']) - { - send_status_line(404, 'Not Found'); - trigger_error('ATTACHMENT_FUNCTIONALITY_DISABLED'); - } - - if ($attachment['is_orphan']) - { - // We allow admins having attachment permissions to see orphan attachments... - $own_attachment = ($auth->acl_get('a_attach') || $attachment['poster_id'] == $user->data['user_id']) ? true : false; - - if (!$own_attachment || ($attachment['in_message'] && !$auth->acl_get('u_pm_download')) || (!$attachment['in_message'] && !$auth->acl_get('u_download'))) - { - send_status_line(404, 'Not Found'); - trigger_error('ERROR_NO_ATTACHMENT'); - } - - // Obtain all extensions... - $extensions = $cache->obtain_attach_extensions(true); - } - else - { - if (!$attachment['in_message']) - { - phpbb_download_handle_forum_auth($db, $auth, $attachment['topic_id']); - - $sql = 'SELECT forum_id, post_visibility - FROM ' . POSTS_TABLE . ' - WHERE post_id = ' . (int) $attachment['post_msg_id']; - $result = $db->sql_query($sql); - $post_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$post_row || !$phpbb_content_visibility->is_visible('post', $post_row['forum_id'], $post_row)) - { - // Attachment of a soft deleted post and the user is not allowed to see the post - send_status_line(404, 'Not Found'); - trigger_error('ERROR_NO_ATTACHMENT'); - } - } - else - { - // Attachment is in a private message. - $post_row = array('forum_id' => false); - phpbb_download_handle_pm_auth($db, $auth, $user->data['user_id'], $attachment['post_msg_id']); - } - - $extensions = array(); - if (!extension_allowed($post_row['forum_id'], $attachment['extension'], $extensions)) - { - send_status_line(403, 'Forbidden'); - trigger_error(sprintf($user->lang['EXTENSION_DISABLED_AFTER_POSTING'], $attachment['extension'])); - } - } - - $download_mode = (int) $extensions[$attachment['extension']]['download_mode']; - $display_cat = $extensions[$attachment['extension']]['display_cat']; - - if (($display_cat == ATTACHMENT_CATEGORY_IMAGE || $display_cat == ATTACHMENT_CATEGORY_THUMB) && !$user->optionget('viewimg')) - { - $display_cat = ATTACHMENT_CATEGORY_NONE; - } - - if ($display_cat == ATTACHMENT_CATEGORY_FLASH && !$user->optionget('viewflash')) - { - $display_cat = ATTACHMENT_CATEGORY_NONE; - } - - /** - * Event to modify data before sending file to browser - * - * @event core.download_file_send_to_browser_before - * @var int attach_id The attachment ID - * @var array attachment Array with attachment data - * @var int display_cat Attachment category - * @var int download_mode File extension specific download mode - * @var array extensions Array with file extensions data - * @var string mode Download mode - * @var bool thumbnail Flag indicating if the file is a thumbnail - * @since 3.1.6-RC1 - * @changed 3.1.7-RC1 Fixing wrong name of a variable (replacing "extension" by "extensions") - */ - $vars = array( - 'attach_id', - 'attachment', - 'display_cat', - 'download_mode', - 'extensions', - 'mode', - 'thumbnail', - ); - extract($phpbb_dispatcher->trigger_event('core.download_file_send_to_browser_before', compact($vars))); - - if ($thumbnail) - { - $attachment['physical_filename'] = 'thumb_' . $attachment['physical_filename']; - } - else if ($display_cat == ATTACHMENT_CATEGORY_NONE && !$attachment['is_orphan'] && !phpbb_http_byte_range($attachment['filesize'])) - { - // Update download count - phpbb_increment_downloads($db, $attachment['attach_id']); - } - - if ($display_cat == ATTACHMENT_CATEGORY_IMAGE && $mode === 'view' && (strpos($attachment['mimetype'], 'image') === 0) && (strpos(strtolower($user->browser), 'msie') !== false) && !phpbb_is_greater_ie_version($user->browser, 7)) - { - wrap_img_in_html(append_sid($phpbb_root_path . 'download/file.' . $phpEx, 'id=' . $attachment['attach_id']), $attachment['real_filename']); - file_gc(); - } - else - { - // Determine the 'presenting'-method - if ($download_mode == PHYSICAL_LINK) - { - // This presenting method should no longer be used - if (!@is_dir($phpbb_root_path . $config['upload_path'])) - { - send_status_line(500, 'Internal Server Error'); - trigger_error($user->lang['PHYSICAL_DOWNLOAD_NOT_POSSIBLE']); - } - - redirect($phpbb_root_path . $config['upload_path'] . '/' . $attachment['physical_filename']); - file_gc(); - } - else - { - send_file_to_browser($attachment, $config['upload_path'], $display_cat); - file_gc(); - } - } -} diff --git a/install/update/old/ext/phpbb/viglink/acp/viglink_helper.php b/install/update/old/ext/phpbb/viglink/acp/viglink_helper.php deleted file mode 100644 index 86568de..0000000 --- a/install/update/old/ext/phpbb/viglink/acp/viglink_helper.php +++ /dev/null @@ -1,146 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - */ - -namespace phpbb\viglink\acp; - -/** - * Class to handle allowing or disallowing VigLink services - */ -class viglink_helper -{ - /** @var \phpbb\cache\driver\driver_interface $cache */ - protected $cache; - - /** @var \phpbb\config\config $config */ - protected $config; - - /** @var \phpbb\file_downloader $file_downloader */ - protected $file_downloader; - - /** @var \phpbb\language\language $language */ - protected $language; - - /** @var \phpbb\log\log $log */ - protected $log; - - /** @var \phpbb\user $user */ - protected $user; - - /** @var bool Use SSL or not */ - protected $use_ssl = false; - - /** - * Constructor - * - * @param \phpbb\cache\driver\driver_interface $cache - * @param \phpbb\config\config $config - * @param \phpbb\file_downloader $file_downloader - * @param \phpbb\language\language $language - * @param \phpbb\log\log $log - * @param \phpbb\user $user - */ - public function __construct(\phpbb\cache\driver\driver_interface $cache, \phpbb\config\config $config, \phpbb\file_downloader $file_downloader, \phpbb\language\language $language, \phpbb\log\log $log, \phpbb\user $user) - { - $this->cache = $cache; - $this->config = $config; - $this->file_downloader = $file_downloader; - $this->language = $language; - $this->log = $log; - $this->user = $user; - } - - /** - * Obtains the latest VigLink services information from phpBB - * - * @param bool $force_update Ignores cached data. Defaults to false. - * @param bool $force_cache Force the use of the cache. Override $force_update. - * - * @throws \RuntimeException - * - * @return void - */ - public function set_viglink_services($force_update = false, $force_cache = false) - { - $cache_key = '_versioncheck_viglink_' . $this->use_ssl; - - $info = $this->cache->get($cache_key); - - if ($info === false && $force_cache) - { - throw new \RuntimeException($this->language->lang('VERSIONCHECK_FAIL')); - } - else if ($info === false || $force_update) - { - try - { - $info = $this->file_downloader->get('www.phpbb.com', '/viglink', 'enabled', 443); - } - catch (\phpbb\exception\runtime_exception $exception) - { - $prepare_parameters = array_merge(array($exception->getMessage()), $exception->get_parameters()); - throw new \RuntimeException(call_user_func_array(array($this->language, 'lang'), $prepare_parameters)); - } - - if ($info === '0') - { - $this->set_viglink_configs(array( - 'allow_viglink_phpbb' => false, - )); - } - else - { - $info = '1'; - $this->set_viglink_configs(array( - 'allow_viglink_phpbb' => true, - )); - } - - $this->cache->put($cache_key, $info, 86400); // 24 hours - } - } - - /** - * Sets VigLink service configs as determined by phpBB - * - * @param array $data Array of VigLink file data. - * - * @return void - */ - protected function set_viglink_configs($data) - { - $viglink_configs = array( - 'allow_viglink_phpbb', - 'phpbb_viglink_api_key', - ); - - foreach ($viglink_configs as $cfg_name) - { - if (array_key_exists($cfg_name, $data) && ($data[$cfg_name] != $this->config[$cfg_name] || !isset($this->config[$cfg_name]))) - { - $this->config->set($cfg_name, $data[$cfg_name]); - } - } - - $this->config->set('viglink_last_gc', time(), false); - } - - /** - * Log a VigLink error message to the error log - * - * @param string $message The error message - */ - public function log_viglink_error($message) - { - $user_id = empty($this->user->data) ? ANONYMOUS : $this->user->data['user_id']; - $user_ip = empty($this->user->ip) ? '' : $this->user->ip; - - $this->log->add('critical', $user_id, $user_ip, 'LOG_VIGLINK_CHECK_FAIL', false, array($message)); - } -} diff --git a/install/update/old/ext/phpbb/viglink/composer.json b/install/update/old/ext/phpbb/viglink/composer.json deleted file mode 100644 index 30312e3..0000000 --- a/install/update/old/ext/phpbb/viglink/composer.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "phpbb/viglink", - "type": "phpbb-extension", - "description": "The VigLink extension for phpBB makes it possible to earn revenue, without any change to the user experience, when users post and follow links to commercial sites.", - "homepage": "https://www.phpbb.com", - "version": "1.0.4", - "keywords": ["phpbb", "extension", "viglink"], - "license": "GPL-2.0-only", - "authors": [ - { - "name": "phpBB Limited", - "email": "operations@phpbb.com", - "homepage": "https://www.phpbb.com/go/authors" - } - ], - "require": { - "php": ">=5.4", - "phpbb/phpbb": ">=3.2.0-b1", - "composer/installers": "~1.0" - }, - "extra": { - "display-name": "VigLink", - "soft-require": { - "phpbb/phpbb": ">=3.2.0-b1,<3.3" - } - } -} diff --git a/install/update/old/ext/phpbb/viglink/composer.lock b/install/update/old/ext/phpbb/viglink/composer.lock deleted file mode 100644 index f03a73d..0000000 --- a/install/update/old/ext/phpbb/viglink/composer.lock +++ /dev/null @@ -1,115 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", - "This file is @generated automatically" - ], - "hash": "155838fcd9206482cc645c3de6a7e8db", - "content-hash": "610135270d537f2e8580b747c6b57ce9", - "packages": [ - { - "name": "composer/installers", - "version": "v1.0.20", - "source": { - "type": "git", - "url": "https://github.com/composer/installers.git", - "reference": "1bff8aa77a18f3616f468ed8000cf86a5725bac3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/composer/installers/zipball/1bff8aa77a18f3616f468ed8000cf86a5725bac3", - "reference": "1bff8aa77a18f3616f468ed8000cf86a5725bac3", - "shasum": "" - }, - "replace": { - "roundcube/plugin-installer": "*", - "shama/baton": "*" - }, - "require-dev": { - "composer/composer": "1.0.*@dev", - "phpunit/phpunit": "4.1.*" - }, - "type": "composer-installer", - "extra": { - "class": "Composer\\Installers\\Installer", - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "psr-0": { - "Composer\\Installers\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Kyle Robinson Young", - "email": "kyle@dontkry.com", - "homepage": "https://github.com/shama" - } - ], - "description": "A multi-framework Composer library installer", - "homepage": "http://composer.github.com/installers/", - "keywords": [ - "Craft", - "Dolibarr", - "Hurad", - "MODX Evo", - "OXID", - "SMF", - "Thelia", - "WolfCMS", - "agl", - "annotatecms", - "bitrix", - "cakephp", - "chef", - "codeigniter", - "concrete5", - "croogo", - "dokuwiki", - "drupal", - "elgg", - "fuelphp", - "grav", - "installer", - "joomla", - "kohana", - "laravel", - "lithium", - "magento", - "mako", - "mediawiki", - "modulework", - "moodle", - "phpbb", - "piwik", - "ppi", - "puppet", - "roundcube", - "shopware", - "silverstripe", - "symfony", - "typo3", - "wordpress", - "zend", - "zikula" - ], - "time": "2015-01-11 03:51:11" - } - ], - "packages-dev": [], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": [], - "prefer-stable": false, - "prefer-lowest": false, - "platform": { - "php": ">=5.3.3" - }, - "platform-dev": [] -} diff --git a/install/update/old/ext/phpbb/viglink/styles/all/theme/viglink.css b/install/update/old/ext/phpbb/viglink/styles/all/theme/viglink.css deleted file mode 100644 index c507a54..0000000 --- a/install/update/old/ext/phpbb/viglink/styles/all/theme/viglink.css +++ /dev/null @@ -1,18 +0,0 @@ -/* phpBB VigLink Extension Style Sheet - ------------------------------------------------------------------------ - Copyright (c) phpBB Limited - - For full copyright and license information, please see - the docs/CREDITS.txt file. - ------------------------------------------------------------------------ -*/ - -.viglink-header { - background: url('images/VigLink_logo.png') no-repeat 0 0; - padding-bottom: 18px; - padding-left: 142px; -} - -.send-stats-tile > .viglink-header-h2 { - margin-bottom: 10px; -} diff --git a/install/update/old/feed.php b/install/update/old/feed.php deleted file mode 100644 index 1480867..0000000 --- a/install/update/old/feed.php +++ /dev/null @@ -1,58 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -* Idea and original RSS Feed 2.0 MOD (Version 1.0.8/9) by leviatan21 -* Original MOD: http://www.phpbb.com/community/viewtopic.php?f=69&t=1214645 -* MOD Author Profile: http://www.phpbb.com/community/memberlist.php?mode=viewprofile&u=345763 -* MOD Author Homepage: http://www.mssti.com/phpbb3/ -* -**/ - -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\Routing\Exception\InvalidParameterException; - -/** -* @ignore -**/ -define('IN_PHPBB', true); -$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); -include($phpbb_root_path . 'common.' . $phpEx); - -/** @var \phpbb\controller\helper $controller_helper */ -$controller_helper = $phpbb_container->get('controller.helper'); - -$forum_id = $request->variable('f', 0); -$topic_id = $request->variable('t', 0); -$mode = $request->variable('mode', ''); - -if ($forum_id !== 0) -{ - $url = $controller_helper->route('phpbb_feed_forum', array('forum_id' => $forum_id)); -} -else if ($topic_id !== 0) -{ - $url = $controller_helper->route('phpbb_feed_topic', array('topic_id' => $topic_id)); -} -else -{ - try - { - $url = $controller_helper->route('phpbb_feed_overall', array('mode' => $mode)); - } - catch (InvalidParameterException $e) - { - $url = $controller_helper->route('phpbb_feed_index'); - } -} - -$response = new RedirectResponse($url, 301); -$response->send(); diff --git a/install/update/old/includes/acp/acp_attachments.php b/install/update/old/includes/acp/acp_attachments.php deleted file mode 100644 index 5b1db5c..0000000 --- a/install/update/old/includes/acp/acp_attachments.php +++ /dev/null @@ -1,1732 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -class acp_attachments -{ - /** @var \phpbb\db\driver\driver_interface */ - protected $db; - - /** @var \phpbb\config\config */ - protected $config; - - /** @var ContainerBuilder */ - protected $phpbb_container; - - /** @var \phpbb\template\template */ - protected $template; - - /** @var \phpbb\user */ - protected $user; - - /** @var \phpbb\filesystem\filesystem_interface */ - protected $filesystem; - - /** @var \phpbb\attachment\manager */ - protected $attachment_manager; - - public $id; - public $u_action; - protected $new_config; - - function main($id, $mode) - { - global $db, $user, $auth, $template, $cache, $phpbb_container, $phpbb_filesystem, $phpbb_dispatcher; - global $config, $phpbb_admin_path, $phpbb_root_path, $phpEx, $phpbb_log, $request; - - $this->id = $id; - $this->db = $db; - $this->config = $config; - $this->template = $template; - $this->user = $user; - $this->phpbb_container = $phpbb_container; - $this->filesystem = $phpbb_filesystem; - $this->attachment_manager = $phpbb_container->get('attachment.manager'); - - $user->add_lang(array('posting', 'viewtopic', 'acp/attachments')); - - $error = $notify = array(); - $submit = (isset($_POST['submit'])) ? true : false; - $action = $request->variable('action', ''); - - $form_key = 'acp_attach'; - add_form_key($form_key); - - if ($submit && !check_form_key($form_key)) - { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - switch ($mode) - { - case 'attach': - $l_title = 'ACP_ATTACHMENT_SETTINGS'; - break; - - case 'extensions': - $l_title = 'ACP_MANAGE_EXTENSIONS'; - break; - - case 'ext_groups': - $l_title = 'ACP_EXTENSION_GROUPS'; - break; - - case 'orphan': - $l_title = 'ACP_ORPHAN_ATTACHMENTS'; - break; - - case 'manage': - $l_title = 'ACP_MANAGE_ATTACHMENTS'; - break; - - default: - trigger_error('NO_MODE', E_USER_ERROR); - break; - } - - $this->tpl_name = 'acp_attachments'; - $this->page_title = $l_title; - - $template->assign_vars(array( - 'L_TITLE' => $user->lang[$l_title], - 'L_TITLE_EXPLAIN' => $user->lang[$l_title . '_EXPLAIN'], - 'U_ACTION' => $this->u_action) - ); - - switch ($mode) - { - case 'attach': - - if (!function_exists('get_supported_image_types')) - { - include($phpbb_root_path . 'includes/functions_posting.' . $phpEx); - } - - $sql = 'SELECT group_name, cat_id - FROM ' . EXTENSION_GROUPS_TABLE . ' - WHERE cat_id > 0 - ORDER BY cat_id'; - $result = $db->sql_query($sql); - - $s_assigned_groups = array(); - while ($row = $db->sql_fetchrow($result)) - { - $row['group_name'] = (isset($user->lang['EXT_GROUP_' . $row['group_name']])) ? $user->lang['EXT_GROUP_' . $row['group_name']] : $row['group_name']; - $s_assigned_groups[$row['cat_id']][] = $row['group_name']; - } - $db->sql_freeresult($result); - - $l_legend_cat_images = $user->lang['SETTINGS_CAT_IMAGES'] . ' [' . $user->lang['ASSIGNED_GROUP'] . ': ' . ((!empty($s_assigned_groups[ATTACHMENT_CATEGORY_IMAGE])) ? implode($user->lang['COMMA_SEPARATOR'], $s_assigned_groups[ATTACHMENT_CATEGORY_IMAGE]) : $user->lang['NO_EXT_GROUP']) . ']'; - - $display_vars = array( - 'title' => 'ACP_ATTACHMENT_SETTINGS', - 'vars' => array( - 'legend1' => 'ACP_ATTACHMENT_SETTINGS', - - 'img_max_width' => array('lang' => 'MAX_IMAGE_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false,), - 'img_max_height' => array('lang' => 'MAX_IMAGE_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false,), - 'img_link_width' => array('lang' => 'IMAGE_LINK_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false,), - 'img_link_height' => array('lang' => 'IMAGE_LINK_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false,), - - 'allow_attachments' => array('lang' => 'ALLOW_ATTACHMENTS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_pm_attach' => array('lang' => 'ALLOW_PM_ATTACHMENTS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'upload_path' => array('lang' => 'UPLOAD_DIR', 'validate' => 'wpath', 'type' => 'text:25:100', 'explain' => true), - 'display_order' => array('lang' => 'DISPLAY_ORDER', 'validate' => 'bool', 'type' => 'custom', 'method' => 'display_order', 'explain' => true), - 'attachment_quota' => array('lang' => 'ATTACH_QUOTA', 'validate' => 'string', 'type' => 'custom', 'method' => 'max_filesize', 'explain' => true), - 'max_filesize' => array('lang' => 'ATTACH_MAX_FILESIZE', 'validate' => 'string', 'type' => 'custom', 'method' => 'max_filesize', 'explain' => true), - 'max_filesize_pm' => array('lang' => 'ATTACH_MAX_PM_FILESIZE','validate' => 'string', 'type' => 'custom', 'method' => 'max_filesize', 'explain' => true), - 'max_attachments' => array('lang' => 'MAX_ATTACHMENTS', 'validate' => 'int:0:999', 'type' => 'number:0:999', 'explain' => false), - 'max_attachments_pm' => array('lang' => 'MAX_ATTACHMENTS_PM', 'validate' => 'int:0:999', 'type' => 'number:0:999', 'explain' => false), - 'secure_downloads' => array('lang' => 'SECURE_DOWNLOADS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'secure_allow_deny' => array('lang' => 'SECURE_ALLOW_DENY', 'validate' => 'int', 'type' => 'custom', 'method' => 'select_allow_deny', 'explain' => true), - 'secure_allow_empty_referer' => array('lang' => 'SECURE_EMPTY_REFERRER', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'check_attachment_content' => array('lang' => 'CHECK_CONTENT', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - - 'legend2' => $l_legend_cat_images, - 'img_display_inlined' => array('lang' => 'DISPLAY_INLINED', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'img_create_thumbnail' => array('lang' => 'CREATE_THUMBNAIL', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'img_max_thumb_width' => array('lang' => 'MAX_THUMB_WIDTH', 'validate' => 'int:0:999999999999999', 'type' => 'number:0:999999999999999', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), - 'img_min_thumb_filesize' => array('lang' => 'MIN_THUMB_FILESIZE', 'validate' => 'int:0:999999999999999', 'type' => 'number:0:999999999999999', 'explain' => true, 'append' => ' ' . $user->lang['BYTES']), - 'img_max' => array('lang' => 'MAX_IMAGE_SIZE', 'validate' => 'int:0:9999', 'type' => 'dimension:0:9999', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), - 'img_link' => array('lang' => 'IMAGE_LINK_SIZE', 'validate' => 'int:0:9999', 'type' => 'dimension:0:9999', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), - ) - ); - - /** - * Event to add and/or modify acp_attachement configurations - * - * @event core.acp_attachments_config_edit_add - * @var array display_vars Array of config values to display and process - * @var string mode Mode of the config page we are displaying - * @var boolean submit Do we display the form or process the submission - * @since 3.1.11-RC1 - */ - $vars = array('display_vars', 'mode', 'submit'); - extract($phpbb_dispatcher->trigger_event('core.acp_attachments_config_edit_add', compact($vars))); - - $this->new_config = $config; - $cfg_array = (isset($_REQUEST['config'])) ? $request->variable('config', array('' => '')) : $this->new_config; - $error = array(); - - // We validate the complete config if whished - validate_config_vars($display_vars['vars'], $cfg_array, $error); - - // Do not write values if there is an error - if (count($error)) - { - $submit = false; - } - - // We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to... - foreach ($display_vars['vars'] as $config_name => $null) - { - if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false) - { - continue; - } - - $this->new_config[$config_name] = $config_value = $cfg_array[$config_name]; - - if (in_array($config_name, array('attachment_quota', 'max_filesize', 'max_filesize_pm'))) - { - $size_var = $request->variable($config_name, ''); - $this->new_config[$config_name] = $config_value = ($size_var == 'kb') ? round($config_value * 1024) : (($size_var == 'mb') ? round($config_value * 1048576) : $config_value); - } - - if ($submit) - { - $config->set($config_name, $config_value); - } - } - - $this->perform_site_list(); - - if ($submit) - { - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_CONFIG_ATTACH'); - - // Check Settings - $this->test_upload($error, $this->new_config['upload_path'], false); - - if (!count($error)) - { - trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action)); - } - } - - $template->assign_var('S_ATTACHMENT_SETTINGS', true); - - // Secure Download Options - Same procedure as with banning - $allow_deny = ($this->new_config['secure_allow_deny']) ? 'ALLOWED' : 'DISALLOWED'; - - $sql = 'SELECT * - FROM ' . SITELIST_TABLE; - $result = $db->sql_query($sql); - - $defined_ips = ''; - $ips = array(); - - while ($row = $db->sql_fetchrow($result)) - { - $value = ($row['site_ip']) ? $row['site_ip'] : $row['site_hostname']; - if ($value) - { - $defined_ips .= '' . $value . ''; - $ips[$row['site_id']] = $value; - } - } - $db->sql_freeresult($result); - - $template->assign_vars(array( - 'S_SECURE_DOWNLOADS' => $this->new_config['secure_downloads'], - 'S_DEFINED_IPS' => ($defined_ips != '') ? true : false, - 'S_WARNING' => (count($error)) ? true : false, - - 'WARNING_MSG' => implode('
', $error), - 'DEFINED_IPS' => $defined_ips, - - 'L_SECURE_TITLE' => $user->lang['DEFINE_' . $allow_deny . '_IPS'], - 'L_IP_EXCLUDE' => $user->lang['EXCLUDE_FROM_' . $allow_deny . '_IP'], - 'L_REMOVE_IPS' => $user->lang['REMOVE_' . $allow_deny . '_IPS']) - ); - - // Output relevant options - foreach ($display_vars['vars'] as $config_key => $vars) - { - if (!is_array($vars) && strpos($config_key, 'legend') === false) - { - continue; - } - - if (strpos($config_key, 'legend') !== false) - { - $template->assign_block_vars('options', array( - 'S_LEGEND' => true, - 'LEGEND' => (isset($user->lang[$vars])) ? $user->lang[$vars] : $vars) - ); - - continue; - } - - $type = explode(':', $vars['type']); - - $l_explain = ''; - if ($vars['explain'] && isset($vars['lang_explain'])) - { - $l_explain = (isset($user->lang[$vars['lang_explain']])) ? $user->lang[$vars['lang_explain']] : $vars['lang_explain']; - } - else if ($vars['explain']) - { - $l_explain = (isset($user->lang[$vars['lang'] . '_EXPLAIN'])) ? $user->lang[$vars['lang'] . '_EXPLAIN'] : ''; - } - - $content = build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars); - if (empty($content)) - { - continue; - } - - $template->assign_block_vars('options', array( - 'KEY' => $config_key, - 'TITLE' => $user->lang[$vars['lang']], - 'S_EXPLAIN' => $vars['explain'], - 'TITLE_EXPLAIN' => $l_explain, - 'CONTENT' => $content, - ) - ); - - unset($display_vars['vars'][$config_key]); - } - - break; - - case 'extensions': - - if ($submit || isset($_POST['add_extension_check'])) - { - if ($submit) - { - // Change Extensions ? - $extension_change_list = $request->variable('extension_change_list', array(0)); - $group_select_list = $request->variable('group_select', array(0)); - - // Generate correct Change List - $extensions = array(); - - for ($i = 0, $size = count($extension_change_list); $i < $size; $i++) - { - $extensions[$extension_change_list[$i]]['group_id'] = $group_select_list[$i]; - } - - $sql = 'SELECT * - FROM ' . EXTENSIONS_TABLE . ' - ORDER BY extension_id'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if ($row['group_id'] != $extensions[$row['extension_id']]['group_id']) - { - $sql = 'UPDATE ' . EXTENSIONS_TABLE . ' - SET group_id = ' . (int) $extensions[$row['extension_id']]['group_id'] . ' - WHERE extension_id = ' . $row['extension_id']; - $db->sql_query($sql); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ATTACH_EXT_UPDATE', false, array($row['extension'])); - } - } - $db->sql_freeresult($result); - - // Delete Extension? - $extension_id_list = $request->variable('extension_id_list', array(0)); - - if (count($extension_id_list)) - { - $sql = 'SELECT extension - FROM ' . EXTENSIONS_TABLE . ' - WHERE ' . $db->sql_in_set('extension_id', $extension_id_list); - $result = $db->sql_query($sql); - - $extension_list = ''; - while ($row = $db->sql_fetchrow($result)) - { - $extension_list .= ($extension_list == '') ? $row['extension'] : ', ' . $row['extension']; - } - $db->sql_freeresult($result); - - $sql = 'DELETE - FROM ' . EXTENSIONS_TABLE . ' - WHERE ' . $db->sql_in_set('extension_id', $extension_id_list); - $db->sql_query($sql); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ATTACH_EXT_DEL', false, array($extension_list)); - } - } - - // Add Extension? - $add_extension = strtolower($request->variable('add_extension', '')); - $add_extension_group = $request->variable('add_group_select', 0); - $add = (isset($_POST['add_extension_check'])) ? true : false; - - if ($add_extension && $add) - { - if (!count($error)) - { - $sql = 'SELECT extension_id - FROM ' . EXTENSIONS_TABLE . " - WHERE extension = '" . $db->sql_escape($add_extension) . "'"; - $result = $db->sql_query($sql); - - if ($row = $db->sql_fetchrow($result)) - { - $error[] = sprintf($user->lang['EXTENSION_EXIST'], $add_extension); - } - $db->sql_freeresult($result); - - if (!count($error)) - { - $sql_ary = array( - 'group_id' => $add_extension_group, - 'extension' => $add_extension - ); - - $db->sql_query('INSERT INTO ' . EXTENSIONS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ATTACH_EXT_ADD', false, array($add_extension)); - } - } - } - - if (!count($error)) - { - $notify[] = $user->lang['EXTENSIONS_UPDATED']; - } - - $cache->destroy('_extensions'); - } - - $template->assign_vars(array( - 'S_EXTENSIONS' => true, - 'ADD_EXTENSION' => (isset($add_extension)) ? $add_extension : '', - 'GROUP_SELECT_OPTIONS' => (isset($_POST['add_extension_check'])) ? $this->group_select('add_group_select', $add_extension_group, 'extension_group') : $this->group_select('add_group_select', false, 'extension_group')) - ); - - $sql = 'SELECT * - FROM ' . EXTENSIONS_TABLE . ' - ORDER BY group_id, extension'; - $result = $db->sql_query($sql); - - if ($row = $db->sql_fetchrow($result)) - { - $old_group_id = $row['group_id']; - do - { - $s_spacer = false; - - $current_group_id = $row['group_id']; - if ($old_group_id != $current_group_id) - { - $s_spacer = true; - $old_group_id = $current_group_id; - } - - $template->assign_block_vars('extensions', array( - 'S_SPACER' => $s_spacer, - 'EXTENSION_ID' => $row['extension_id'], - 'EXTENSION' => $row['extension'], - 'GROUP_OPTIONS' => $this->group_select('group_select[]', $row['group_id'])) - ); - } - while ($row = $db->sql_fetchrow($result)); - } - $db->sql_freeresult($result); - - break; - - case 'ext_groups': - - $template->assign_var('S_EXTENSION_GROUPS', true); - - if ($submit) - { - $action = $request->variable('action', ''); - $group_id = $request->variable('g', 0); - - if ($action != 'add' && $action != 'edit') - { - trigger_error('NO_MODE', E_USER_ERROR); - } - - if (!$group_id && $action == 'edit') - { - trigger_error($user->lang['NO_EXT_GROUP_SPECIFIED'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - if ($group_id) - { - $sql = 'SELECT * - FROM ' . EXTENSION_GROUPS_TABLE . " - WHERE group_id = $group_id"; - $result = $db->sql_query($sql); - $ext_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$ext_row) - { - trigger_error($user->lang['NO_EXT_GROUP_SPECIFIED'] . adm_back_link($this->u_action), E_USER_WARNING); - } - } - else - { - $ext_row = array(); - } - - $group_name = $request->variable('group_name', '', true); - $new_group_name = ($action == 'add') ? $group_name : (($ext_row['group_name'] != $group_name) ? $group_name : ''); - - if (!$group_name) - { - $error[] = $user->lang['NO_EXT_GROUP_NAME']; - } - - // Check New Group Name - if ($new_group_name) - { - $sql = 'SELECT group_id - FROM ' . EXTENSION_GROUPS_TABLE . " - WHERE LOWER(group_name) = '" . $db->sql_escape(utf8_strtolower($new_group_name)) . "'"; - if ($group_id) - { - $sql .= ' AND group_id <> ' . $group_id; - } - $result = $db->sql_query($sql); - - if ($db->sql_fetchrow($result)) - { - $error[] = sprintf($user->lang['EXTENSION_GROUP_EXIST'], $new_group_name); - } - $db->sql_freeresult($result); - } - - if (!count($error)) - { - // Ok, build the update/insert array - $upload_icon = $request->variable('upload_icon', 'no_image'); - $size_select = $request->variable('size_select', 'b'); - $forum_select = $request->variable('forum_select', false); - $allowed_forums = $request->variable('allowed_forums', array(0)); - $allow_in_pm = (isset($_POST['allow_in_pm'])) ? true : false; - $max_filesize = $request->variable('max_filesize', 0); - $max_filesize = ($size_select == 'kb') ? round($max_filesize * 1024) : (($size_select == 'mb') ? round($max_filesize * 1048576) : $max_filesize); - $allow_group = (isset($_POST['allow_group'])) ? true : false; - - if ($max_filesize == $config['max_filesize']) - { - $max_filesize = 0; - } - - if (!count($allowed_forums)) - { - $forum_select = false; - } - - $group_ary = array( - 'group_name' => $group_name, - 'cat_id' => $request->variable('special_category', ATTACHMENT_CATEGORY_NONE), - 'allow_group' => ($allow_group) ? 1 : 0, - 'upload_icon' => ($upload_icon == 'no_image') ? '' : $upload_icon, - 'max_filesize' => $max_filesize, - 'allowed_forums'=> ($forum_select) ? serialize($allowed_forums) : '', - 'allow_in_pm' => ($allow_in_pm) ? 1 : 0, - ); - - if ($action == 'add') - { - $group_ary['download_mode'] = INLINE_LINK; - } - - $sql = ($action == 'add') ? 'INSERT INTO ' . EXTENSION_GROUPS_TABLE . ' ' : 'UPDATE ' . EXTENSION_GROUPS_TABLE . ' SET '; - $sql .= $db->sql_build_array((($action == 'add') ? 'INSERT' : 'UPDATE'), $group_ary); - $sql .= ($action == 'edit') ? " WHERE group_id = $group_id" : ''; - - $db->sql_query($sql); - - if ($action == 'add') - { - $group_id = $db->sql_nextid(); - } - - $group_name = (isset($user->lang['EXT_GROUP_' . $group_name])) ? $user->lang['EXT_GROUP_' . $group_name] : $group_name; - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ATTACH_EXTGROUP_' . strtoupper($action), false, array($group_name)); - } - - $extension_list = $request->variable('extensions', array(0)); - - if ($action == 'edit' && count($extension_list)) - { - $sql = 'UPDATE ' . EXTENSIONS_TABLE . " - SET group_id = 0 - WHERE group_id = $group_id"; - $db->sql_query($sql); - } - - if (count($extension_list)) - { - $sql = 'UPDATE ' . EXTENSIONS_TABLE . " - SET group_id = $group_id - WHERE " . $db->sql_in_set('extension_id', $extension_list); - $db->sql_query($sql); - } - - $cache->destroy('_extensions'); - - if (!count($error)) - { - $notify[] = $user->lang['SUCCESS_EXTENSION_GROUP_' . strtoupper($action)]; - } - } - - $cat_lang = array( - ATTACHMENT_CATEGORY_NONE => $user->lang['NO_FILE_CAT'], - ATTACHMENT_CATEGORY_IMAGE => $user->lang['CAT_IMAGES'], - ATTACHMENT_CATEGORY_FLASH => $user->lang['CAT_FLASH_FILES'], - ); - - $group_id = $request->variable('g', 0); - $action = (isset($_POST['add'])) ? 'add' : $action; - - switch ($action) - { - case 'delete': - - if (confirm_box(true)) - { - $sql = 'SELECT group_name - FROM ' . EXTENSION_GROUPS_TABLE . " - WHERE group_id = $group_id"; - $result = $db->sql_query($sql); - $group_name = (string) $db->sql_fetchfield('group_name'); - $db->sql_freeresult($result); - - $sql = 'DELETE - FROM ' . EXTENSION_GROUPS_TABLE . " - WHERE group_id = $group_id"; - $db->sql_query($sql); - - // Set corresponding Extensions to a pending Group - $sql = 'UPDATE ' . EXTENSIONS_TABLE . " - SET group_id = 0 - WHERE group_id = $group_id"; - $db->sql_query($sql); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ATTACH_EXTGROUP_DEL', false, array($group_name)); - - $cache->destroy('_extensions'); - - trigger_error($user->lang['EXTENSION_GROUP_DELETED'] . adm_back_link($this->u_action)); - } - else - { - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( - 'i' => $id, - 'mode' => $mode, - 'group_id' => $group_id, - 'action' => 'delete', - ))); - } - - break; - - case 'edit': - - if (!$group_id) - { - trigger_error($user->lang['NO_EXT_GROUP_SPECIFIED'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - $sql = 'SELECT * - FROM ' . EXTENSION_GROUPS_TABLE . " - WHERE group_id = $group_id"; - $result = $db->sql_query($sql); - $ext_group_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $forum_ids = (!$ext_group_row['allowed_forums']) ? array() : unserialize(trim($ext_group_row['allowed_forums'])); - - // no break; - - case 'add': - - if ($action == 'add') - { - $ext_group_row = array( - 'group_name' => $request->variable('group_name', '', true), - 'cat_id' => 0, - 'allow_group' => 1, - 'allow_in_pm' => 1, - 'upload_icon' => '', - 'max_filesize' => 0, - ); - - $forum_ids = array(); - } - - $sql = 'SELECT * - FROM ' . EXTENSIONS_TABLE . " - WHERE group_id = $group_id - OR group_id = 0 - ORDER BY extension"; - $result = $db->sql_query($sql); - $extensions = $db->sql_fetchrowset($result); - $db->sql_freeresult($result); - - if ($ext_group_row['max_filesize'] == 0) - { - $ext_group_row['max_filesize'] = (int) $config['max_filesize']; - } - - $max_filesize = get_formatted_filesize($ext_group_row['max_filesize'], false, array('mb', 'kb', 'b')); - $size_format = $max_filesize['si_identifier']; - $ext_group_row['max_filesize'] = $max_filesize['value']; - - $img_path = $config['upload_icons_path']; - - $filename_list = ''; - $no_image_select = false; - - $imglist = filelist($phpbb_root_path . $img_path); - - if (!empty($imglist[''])) - { - $imglist = array_values($imglist); - $imglist = $imglist[0]; - - foreach ($imglist as $key => $img) - { - if (!$ext_group_row['upload_icon']) - { - $no_image_select = true; - $selected = ''; - } - else - { - $selected = ($ext_group_row['upload_icon'] == $img) ? ' selected="selected"' : ''; - } - - if (strlen($img) > 255) - { - continue; - } - - $filename_list .= ''; - } - } - - $i = 0; - $assigned_extensions = ''; - foreach ($extensions as $num => $row) - { - if ($row['group_id'] == $group_id && $group_id) - { - $assigned_extensions .= ($i) ? ', ' . $row['extension'] : $row['extension']; - $i++; - } - } - - $s_extension_options = ''; - foreach ($extensions as $row) - { - $s_extension_options .= '' . $row['extension'] . ''; - } - - $template->assign_vars(array( - 'IMG_PATH' => $img_path, - 'ACTION' => $action, - 'GROUP_ID' => $group_id, - 'GROUP_NAME' => $ext_group_row['group_name'], - 'ALLOW_GROUP' => $ext_group_row['allow_group'], - 'ALLOW_IN_PM' => $ext_group_row['allow_in_pm'], - 'UPLOAD_ICON_SRC' => $phpbb_root_path . $img_path . '/' . $ext_group_row['upload_icon'], - 'EXTGROUP_FILESIZE' => $ext_group_row['max_filesize'], - 'ASSIGNED_EXTENSIONS' => $assigned_extensions, - - 'S_CATEGORY_SELECT' => $this->category_select('special_category', $group_id, 'category'), - 'S_EXT_GROUP_SIZE_OPTIONS' => size_select_options($size_format), - 'S_EXTENSION_OPTIONS' => $s_extension_options, - 'S_FILENAME_LIST' => $filename_list, - 'S_EDIT_GROUP' => true, - 'S_NO_IMAGE' => $no_image_select, - 'S_FORUM_IDS' => (count($forum_ids)) ? true : false, - - 'U_EXTENSIONS' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=$id&mode=extensions"), - 'U_BACK' => $this->u_action, - - 'L_LEGEND' => $user->lang[strtoupper($action) . '_EXTENSION_GROUP']) - ); - - $s_forum_id_options = ''; - - /** @todo use in-built function **/ - - $sql = 'SELECT forum_id, forum_name, parent_id, forum_type, left_id, right_id - FROM ' . FORUMS_TABLE . ' - ORDER BY left_id ASC'; - $result = $db->sql_query($sql, 600); - - $right = $cat_right = $padding_inc = 0; - $padding = $forum_list = $holding = ''; - $padding_store = array('0' => ''); - - while ($row = $db->sql_fetchrow($result)) - { - if ($row['forum_type'] == FORUM_CAT && ($row['left_id'] + 1 == $row['right_id'])) - { - // Non-postable forum with no subforums, don't display - continue; - } - - if (!$auth->acl_get('f_list', $row['forum_id'])) - { - // if the user does not have permissions to list this forum skip - continue; - } - - if ($row['left_id'] < $right) - { - $padding .= '   '; - $padding_store[$row['parent_id']] = $padding; - } - else if ($row['left_id'] > $right + 1) - { - $padding = empty($padding_store[$row['parent_id']]) ? '' : $padding_store[$row['parent_id']]; - } - - $right = $row['right_id']; - - $selected = (in_array($row['forum_id'], $forum_ids)) ? ' selected="selected"' : ''; - - if ($row['left_id'] > $cat_right) - { - // make sure we don't forget anything - $s_forum_id_options .= $holding; - $holding = ''; - } - - if ($row['right_id'] - $row['left_id'] > 1) - { - $cat_right = max($cat_right, $row['right_id']); - - $holding .= ''; - } - else - { - $s_forum_id_options .= $holding . ''; - $holding = ''; - } - } - - if ($holding) - { - $s_forum_id_options .= $holding; - } - - $db->sql_freeresult($result); - unset($padding_store); - - $template->assign_vars(array( - 'S_FORUM_ID_OPTIONS' => $s_forum_id_options) - ); - - break; - } - - $sql = 'SELECT * - FROM ' . EXTENSION_GROUPS_TABLE . ' - ORDER BY allow_group DESC, allow_in_pm DESC, group_name'; - $result = $db->sql_query($sql); - - $old_allow_group = $old_allow_pm = 1; - while ($row = $db->sql_fetchrow($result)) - { - $s_add_spacer = ($old_allow_group != $row['allow_group'] || $old_allow_pm != $row['allow_in_pm']) ? true : false; - - $template->assign_block_vars('groups', array( - 'S_ADD_SPACER' => $s_add_spacer, - 'S_ALLOWED_IN_PM' => ($row['allow_in_pm']) ? true : false, - 'S_GROUP_ALLOWED' => ($row['allow_group']) ? true : false, - - 'U_EDIT' => $this->u_action . "&action=edit&g={$row['group_id']}", - 'U_DELETE' => $this->u_action . "&action=delete&g={$row['group_id']}", - - 'GROUP_NAME' => (isset($user->lang['EXT_GROUP_' . $row['group_name']])) ? $user->lang['EXT_GROUP_' . $row['group_name']] : $row['group_name'], - 'CATEGORY' => $cat_lang[$row['cat_id']], - ) - ); - - $old_allow_group = $row['allow_group']; - $old_allow_pm = $row['allow_in_pm']; - } - $db->sql_freeresult($result); - - break; - - case 'orphan': - - /* @var $pagination \phpbb\pagination */ - $pagination = $this->phpbb_container->get('pagination'); - - if ($submit) - { - $delete_files = (isset($_POST['delete'])) ? array_keys($request->variable('delete', array('' => 0))) : array(); - $add_files = (isset($_POST['add'])) ? array_keys($request->variable('add', array('' => 0))) : array(); - $post_ids = $request->variable('post_id', array('' => 0)); - - if (count($delete_files)) - { - $sql = 'SELECT * - FROM ' . ATTACHMENTS_TABLE . ' - WHERE ' . $db->sql_in_set('attach_id', $delete_files) . ' - AND is_orphan = 1'; - $result = $db->sql_query($sql); - - $delete_files = array(); - while ($row = $db->sql_fetchrow($result)) - { - $this->attachment_manager->unlink($row['physical_filename'], 'file'); - - if ($row['thumbnail']) - { - $this->attachment_manager->unlink($row['physical_filename'], 'thumbnail'); - } - - $delete_files[$row['attach_id']] = $row['real_filename']; - } - $db->sql_freeresult($result); - } - - if (count($delete_files)) - { - $sql = 'DELETE FROM ' . ATTACHMENTS_TABLE . ' - WHERE ' . $db->sql_in_set('attach_id', array_keys($delete_files)); - $db->sql_query($sql); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ATTACH_ORPHAN_DEL', false, array(implode(', ', $delete_files))); - $notify[] = sprintf($user->lang['LOG_ATTACH_ORPHAN_DEL'], implode($user->lang['COMMA_SEPARATOR'], $delete_files)); - } - - $upload_list = array(); - foreach ($add_files as $attach_id) - { - if (!isset($delete_files[$attach_id]) && !empty($post_ids[$attach_id])) - { - $upload_list[$attach_id] = $post_ids[$attach_id]; - } - } - unset($add_files); - - if (count($upload_list)) - { - $template->assign_var('S_UPLOADING_FILES', true); - - $sql = 'SELECT forum_id, forum_name - FROM ' . FORUMS_TABLE; - $result = $db->sql_query($sql); - - $forum_names = array(); - while ($row = $db->sql_fetchrow($result)) - { - $forum_names[$row['forum_id']] = $row['forum_name']; - } - $db->sql_freeresult($result); - - $sql = 'SELECT forum_id, topic_id, post_id, poster_id - FROM ' . POSTS_TABLE . ' - WHERE ' . $db->sql_in_set('post_id', $upload_list); - $result = $db->sql_query($sql); - - $post_info = array(); - while ($row = $db->sql_fetchrow($result)) - { - $post_info[$row['post_id']] = $row; - } - $db->sql_freeresult($result); - - // Select those attachments we want to change... - $sql = 'SELECT * - FROM ' . ATTACHMENTS_TABLE . ' - WHERE ' . $db->sql_in_set('attach_id', array_keys($upload_list)) . ' - AND is_orphan = 1'; - $result = $db->sql_query($sql); - - $files_added = $space_taken = 0; - while ($row = $db->sql_fetchrow($result)) - { - $post_row = $post_info[$upload_list[$row['attach_id']]]; - - $template->assign_block_vars('upload', array( - 'FILE_INFO' => sprintf($user->lang['UPLOADING_FILE_TO'], $row['real_filename'], $post_row['post_id']), - 'S_DENIED' => (!$auth->acl_get('f_attach', $post_row['forum_id'])) ? true : false, - 'L_DENIED' => (!$auth->acl_get('f_attach', $post_row['forum_id'])) ? sprintf($user->lang['UPLOAD_DENIED_FORUM'], $forum_names[$row['forum_id']]) : '') - ); - - if (!$auth->acl_get('f_attach', $post_row['forum_id'])) - { - continue; - } - - // Adjust attachment entry - $sql_ary = array( - 'in_message' => 0, - 'is_orphan' => 0, - 'poster_id' => $post_row['poster_id'], - 'post_msg_id' => $post_row['post_id'], - 'topic_id' => $post_row['topic_id'], - ); - - $sql = 'UPDATE ' . ATTACHMENTS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE attach_id = ' . $row['attach_id']; - $db->sql_query($sql); - - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET post_attachment = 1 - WHERE post_id = ' . $post_row['post_id']; - $db->sql_query($sql); - - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_attachment = 1 - WHERE topic_id = ' . $post_row['topic_id']; - $db->sql_query($sql); - - $space_taken += $row['filesize']; - $files_added++; - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ATTACH_FILEUPLOAD', false, array($post_row['post_id'], $row['real_filename'])); - } - $db->sql_freeresult($result); - - if ($files_added) - { - $config->increment('upload_dir_size', $space_taken, false); - $config->increment('num_files', $files_added, false); - } - } - } - - $template->assign_vars(array( - 'S_ORPHAN' => true) - ); - - $attachments_per_page = (int) $config['topics_per_page']; - - // Get total number or orphans older than 3 hours - $sql = 'SELECT COUNT(attach_id) as num_files, SUM(filesize) as total_size - FROM ' . ATTACHMENTS_TABLE . ' - WHERE is_orphan = 1 - AND filetime < ' . (time() - 3*60*60); - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $num_files = (int) $row['num_files']; - $total_size = (int) $row['total_size']; - $this->db->sql_freeresult($result); - - $start = $request->variable('start', 0); - $start = $pagination->validate_start($start, $attachments_per_page, $num_files); - - // Just get the files with is_orphan set and older than 3 hours - $sql = 'SELECT * - FROM ' . ATTACHMENTS_TABLE . ' - WHERE is_orphan = 1 - AND filetime < ' . (time() - 3*60*60) . ' - ORDER BY filetime DESC'; - $result = $db->sql_query_limit($sql, $attachments_per_page, $start); - - while ($row = $db->sql_fetchrow($result)) - { - $template->assign_block_vars('orphan', array( - 'FILESIZE' => get_formatted_filesize($row['filesize']), - 'FILETIME' => $user->format_date($row['filetime']), - 'REAL_FILENAME' => utf8_basename($row['real_filename']), - 'PHYSICAL_FILENAME' => utf8_basename($row['physical_filename']), - 'ATTACH_ID' => $row['attach_id'], - 'POST_IDS' => (!empty($post_ids[$row['attach_id']])) ? $post_ids[$row['attach_id']] : '', - 'U_FILE' => append_sid($phpbb_root_path . 'download/file.' . $phpEx, 'mode=view&id=' . $row['attach_id'])) - ); - } - $db->sql_freeresult($result); - - $pagination->generate_template_pagination( - $this->u_action, - 'pagination', - 'start', - $num_files, - $attachments_per_page, - $start - ); - - $template->assign_vars(array( - 'TOTAL_FILES' => $num_files, - 'TOTAL_SIZE' => get_formatted_filesize($total_size), - )); - - break; - - case 'manage': - - if ($submit) - { - $delete_files = (isset($_POST['delete'])) ? array_keys($request->variable('delete', array('' => 0))) : array(); - - if (count($delete_files)) - { - // Select those attachments we want to delete... - $sql = 'SELECT real_filename - FROM ' . ATTACHMENTS_TABLE . ' - WHERE ' . $db->sql_in_set('attach_id', $delete_files) . ' - AND is_orphan = 0'; - $result = $db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) - { - $deleted_filenames[] = $row['real_filename']; - } - $db->sql_freeresult($result); - - if ($num_deleted = $this->attachment_manager->delete('attach', $delete_files)) - { - if (count($delete_files) != $num_deleted) - { - $error[] = $user->lang['FILES_GONE']; - } - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ATTACHMENTS_DELETED', false, array(implode(', ', $deleted_filenames))); - $notify[] = sprintf($user->lang['LOG_ATTACHMENTS_DELETED'], implode($user->lang['COMMA_SEPARATOR'], $deleted_filenames)); - } - else - { - $error[] = $user->lang['NO_FILES_TO_DELETE']; - } - } - } - - if ($action == 'stats') - { - $this->handle_stats_resync(); - } - - $stats_error = $this->check_stats_accuracy(); - - if ($stats_error) - { - $error[] = $stats_error; - } - - $template->assign_vars(array( - 'S_MANAGE' => true, - )); - - $start = $request->variable('start', 0); - - // Sort keys - $sort_days = $request->variable('st', 0); - $sort_key = $request->variable('sk', 't'); - $sort_dir = $request->variable('sd', 'd'); - - // Sorting - $limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); - $sort_by_text = array('f' => $user->lang['FILENAME'], 't' => $user->lang['FILEDATE'], 's' => $user->lang['FILESIZE'], 'x' => $user->lang['EXTENSION'], 'd' => $user->lang['DOWNLOADS'],'p' => $user->lang['ATTACH_POST_TYPE'], 'u' => $user->lang['AUTHOR']); - $sort_by_sql = array('f' => 'a.real_filename', 't' => 'a.filetime', 's' => 'a.filesize', 'x' => 'a.extension', 'd' => 'a.download_count', 'p' => 'a.in_message', 'u' => 'u.username'); - - $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; - gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); - - $min_filetime = ($sort_days) ? (time() - ($sort_days * 86400)) : ''; - $limit_filetime = ($min_filetime) ? " AND a.filetime >= $min_filetime " : ''; - $start = ($sort_days && isset($_POST['sort'])) ? 0 : $start; - - $attachments_per_page = (int) $config['topics_per_page']; - - $stats = $this->get_attachment_stats($limit_filetime); - $num_files = $stats['num_files']; - $total_size = $stats['upload_dir_size']; - - // Make sure $start is set to the last page if it exceeds the amount - /* @var $pagination \phpbb\pagination */ - $pagination = $phpbb_container->get('pagination'); - $start = $pagination->validate_start($start, $attachments_per_page, $num_files); - - // If the user is trying to reach the second half of the attachments list, fetch it starting from the end - $store_reverse = false; - $sql_limit = $attachments_per_page; - - if ($start > $num_files / 2) - { - $store_reverse = true; - - // Select the sort order. Add time sort anchor for non-time sorting cases - $sql_sort_anchor = ($sort_key != 't') ? ', a.filetime ' . (($sort_dir == 'd') ? 'ASC' : 'DESC') : ''; - $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'ASC' : 'DESC') . $sql_sort_anchor; - $sql_limit = $pagination->reverse_limit($start, $sql_limit, $num_files); - $sql_start = $pagination->reverse_start($start, $sql_limit, $num_files); - } - else - { - // Select the sort order. Add time sort anchor for non-time sorting cases - $sql_sort_anchor = ($sort_key != 't') ? ', a.filetime ' . (($sort_dir == 'd') ? 'DESC' : 'ASC') : ''; - $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC') . $sql_sort_anchor; - $sql_start = $start; - } - - $attachments_list = array(); - - // Just get the files - $sql = 'SELECT a.*, u.username, u.user_colour, t.topic_title - FROM ' . ATTACHMENTS_TABLE . ' a - LEFT JOIN ' . USERS_TABLE . ' u ON (u.user_id = a.poster_id) - LEFT JOIN ' . TOPICS_TABLE . " t ON (a.topic_id = t.topic_id) - WHERE a.is_orphan = 0 - $limit_filetime - ORDER BY $sql_sort_order"; - $result = $db->sql_query_limit($sql, $sql_limit, $sql_start); - - $i = ($store_reverse) ? $sql_limit - 1 : 0; - - // Store increment value in a variable to save some conditional calls - $i_increment = ($store_reverse) ? -1 : 1; - while ($attachment_row = $db->sql_fetchrow($result)) - { - $attachments_list[$i] = $attachment_row; - $i = $i + $i_increment; - } - $db->sql_freeresult($result); - - $base_url = $this->u_action . "&$u_sort_param"; - $pagination->generate_template_pagination($base_url, 'pagination', 'start', $num_files, $attachments_per_page, $start); - - $template->assign_vars(array( - 'TOTAL_FILES' => $num_files, - 'TOTAL_SIZE' => get_formatted_filesize($total_size), - - 'S_LIMIT_DAYS' => $s_limit_days, - 'S_SORT_KEY' => $s_sort_key, - 'S_SORT_DIR' => $s_sort_dir) - ); - - // Grab extensions - $extensions = $cache->obtain_attach_extensions(true); - - for ($i = 0, $end = count($attachments_list); $i < $end; ++$i) - { - $row = $attachments_list[$i]; - - $row['extension'] = strtolower(trim((string) $row['extension'])); - $comment = ($row['attach_comment'] && !$row['in_message']) ? str_replace(array("\n", "\r"), array('
', "\n"), $row['attach_comment']) : ''; - $display_cat = isset($extensions[$row['extension']]['display_cat']) ? $extensions[$row['extension']]['display_cat'] : ATTACHMENT_CATEGORY_NONE; - $l_downloaded_viewed = ($display_cat == ATTACHMENT_CATEGORY_NONE) ? 'DOWNLOAD_COUNTS' : 'VIEWED_COUNTS'; - - $template->assign_block_vars('attachments', array( - 'ATTACHMENT_POSTER' => get_username_string('full', (int) $row['poster_id'], (string) $row['username'], (string) $row['user_colour'], (string) $row['username']), - 'FILESIZE' => get_formatted_filesize((int) $row['filesize']), - 'FILETIME' => $user->format_date((int) $row['filetime']), - 'REAL_FILENAME' => (!$row['in_message']) ? utf8_basename((string) $row['real_filename']) : '', - 'PHYSICAL_FILENAME' => utf8_basename((string) $row['physical_filename']), - 'EXT_GROUP_NAME' => (!empty($extensions[$row['extension']]['group_name'])) ? $user->lang['EXT_GROUP_' . $extensions[$row['extension']]['group_name']] : '', - 'COMMENT' => $comment, - 'TOPIC_TITLE' => (!$row['in_message']) ? (string) $row['topic_title'] : '', - 'ATTACH_ID' => (int) $row['attach_id'], - 'POST_ID' => (int) $row['post_msg_id'], - 'TOPIC_ID' => (int) $row['topic_id'], - 'POST_IDS' => (!empty($post_ids[$row['attach_id']])) ? (int) $post_ids[$row['attach_id']] : '', - - 'L_DOWNLOAD_COUNT' => $user->lang($l_downloaded_viewed, (int) $row['download_count']), - - 'S_IN_MESSAGE' => (bool) $row['in_message'], - - 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t={$row['topic_id']}&p={$row['post_msg_id']}") . "#p{$row['post_msg_id']}", - 'U_FILE' => append_sid($phpbb_root_path . 'download/file.' . $phpEx, 'mode=view&id=' . $row['attach_id'])) - ); - } - - break; - } - - if (count($error)) - { - $template->assign_vars(array( - 'S_WARNING' => true, - 'WARNING_MSG' => implode('
', $error)) - ); - } - - if (count($notify)) - { - $template->assign_vars(array( - 'S_NOTIFY' => true, - 'NOTIFY_MSG' => implode('
', $notify)) - ); - } - } - - /** - * Get attachment file count and size of upload directory - * - * @param $limit string Additional limit for WHERE clause to filter stats by. - * @return array Returns array with stats: num_files and upload_dir_size - */ - public function get_attachment_stats($limit = '') - { - $sql = 'SELECT COUNT(a.attach_id) AS num_files, SUM(a.filesize) AS upload_dir_size - FROM ' . ATTACHMENTS_TABLE . " a - WHERE a.is_orphan = 0 - $limit"; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - return array( - 'num_files' => (int) $row['num_files'], - 'upload_dir_size' => (float) $row['upload_dir_size'], - ); - } - - /** - * Set config attachment stat values - * - * @param $stats array Array of config key => value pairs to set. - * @return null - */ - public function set_attachment_stats($stats) - { - foreach ($stats as $key => $value) - { - $this->config->set($key, $value, true); - } - } - - /** - * Check accuracy of attachment statistics. - * - * @return bool|string Returns false if stats are correct or error message - * otherwise. - */ - public function check_stats_accuracy() - { - // Get fresh stats. - $stats = $this->get_attachment_stats(); - - // Get current files stats - $num_files = (int) $this->config['num_files']; - $total_size = (float) $this->config['upload_dir_size']; - - if (($num_files != $stats['num_files']) || ($total_size != $stats['upload_dir_size'])) - { - $u_resync = $this->u_action . '&action=stats'; - - return $this->user->lang( - 'FILES_STATS_WRONG', - (int) $stats['num_files'], - get_formatted_filesize($stats['upload_dir_size']), - '', - '' - ); - } - return false; - } - - /** - * Handle stats resync. - * - * @return null - */ - public function handle_stats_resync() - { - if (!confirm_box(true)) - { - confirm_box(false, $this->user->lang['RESYNC_FILES_STATS_CONFIRM'], build_hidden_fields(array( - 'i' => $this->id, - 'mode' => 'manage', - 'action' => 'stats', - ))); - } - else - { - $this->set_attachment_stats($this->get_attachment_stats()); - - /* @var $log \phpbb\log\log_interface */ - $log = $this->phpbb_container->get('log'); - $log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_RESYNC_FILES_STATS'); - } - - } - - /** - * Build Select for category items - */ - function category_select($select_name, $group_id = false, $key = '') - { - global $db, $user; - - $types = array( - ATTACHMENT_CATEGORY_NONE => $user->lang['NO_FILE_CAT'], - ATTACHMENT_CATEGORY_IMAGE => $user->lang['CAT_IMAGES'], - ATTACHMENT_CATEGORY_FLASH => $user->lang['CAT_FLASH_FILES'], - ); - - if ($group_id) - { - $sql = 'SELECT cat_id - FROM ' . EXTENSION_GROUPS_TABLE . ' - WHERE group_id = ' . (int) $group_id; - $result = $db->sql_query($sql); - - $cat_type = (!($row = $db->sql_fetchrow($result))) ? ATTACHMENT_CATEGORY_NONE : $row['cat_id']; - - $db->sql_freeresult($result); - } - else - { - $cat_type = ATTACHMENT_CATEGORY_NONE; - } - - $group_select = ''; - - return $group_select; - } - - /** - * Extension group select - */ - function group_select($select_name, $default_group = false, $key = '') - { - global $db, $user; - - $group_select = ''; - - return $group_select; - } - - /** - * Test Settings - */ - function test_upload(&$error, $upload_dir, $create_directory = false) - { - global $user, $phpbb_root_path; - - // Does the target directory exist, is it a directory and writable. - if ($create_directory) - { - if (!file_exists($phpbb_root_path . $upload_dir)) - { - @mkdir($phpbb_root_path . $upload_dir, 0777); - - try - { - $this->filesystem->phpbb_chmod($phpbb_root_path . $upload_dir, CHMOD_READ | CHMOD_WRITE); - } - catch (\phpbb\filesystem\exception\filesystem_exception $e) - { - // Do nothing - } - } - } - - if (!file_exists($phpbb_root_path . $upload_dir)) - { - $error[] = sprintf($user->lang['NO_UPLOAD_DIR'], $upload_dir); - return; - } - - if (!is_dir($phpbb_root_path . $upload_dir)) - { - $error[] = sprintf($user->lang['UPLOAD_NOT_DIR'], $upload_dir); - return; - } - - if (!$this->filesystem->is_writable($phpbb_root_path . $upload_dir)) - { - $error[] = sprintf($user->lang['NO_WRITE_UPLOAD'], $upload_dir); - return; - } - } - - /** - * Perform operations on sites for external linking - */ - function perform_site_list() - { - global $db, $user, $request, $phpbb_log; - - if (isset($_REQUEST['securesubmit'])) - { - // Grab the list of entries - $ips = $request->variable('ips', ''); - $ip_list = array_unique(explode("\n", $ips)); - $ip_list_log = implode(', ', $ip_list); - - $ip_exclude = (int) $request->variable('ipexclude', false, false, \phpbb\request\request_interface::POST); - - $iplist = array(); - $hostlist = array(); - - foreach ($ip_list as $item) - { - if (preg_match('#^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})[ ]*\-[ ]*([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$#', trim($item), $ip_range_explode)) - { - // Don't ask about all this, just don't ask ... ! - $ip_1_counter = $ip_range_explode[1]; - $ip_1_end = $ip_range_explode[5]; - - while ($ip_1_counter <= $ip_1_end) - { - $ip_2_counter = ($ip_1_counter == $ip_range_explode[1]) ? $ip_range_explode[2] : 0; - $ip_2_end = ($ip_1_counter < $ip_1_end) ? 254 : $ip_range_explode[6]; - - if ($ip_2_counter == 0 && $ip_2_end == 254) - { - $ip_2_counter = 256; - - $iplist[] = "'$ip_1_counter.*'"; - } - - while ($ip_2_counter <= $ip_2_end) - { - $ip_3_counter = ($ip_2_counter == $ip_range_explode[2] && $ip_1_counter == $ip_range_explode[1]) ? $ip_range_explode[3] : 0; - $ip_3_end = ($ip_2_counter < $ip_2_end || $ip_1_counter < $ip_1_end) ? 254 : $ip_range_explode[7]; - - if ($ip_3_counter == 0 && $ip_3_end == 254) - { - $ip_3_counter = 256; - - $iplist[] = "'$ip_1_counter.$ip_2_counter.*'"; - } - - while ($ip_3_counter <= $ip_3_end) - { - $ip_4_counter = ($ip_3_counter == $ip_range_explode[3] && $ip_2_counter == $ip_range_explode[2] && $ip_1_counter == $ip_range_explode[1]) ? $ip_range_explode[4] : 0; - $ip_4_end = ($ip_3_counter < $ip_3_end || $ip_2_counter < $ip_2_end) ? 254 : $ip_range_explode[8]; - - if ($ip_4_counter == 0 && $ip_4_end == 254) - { - $ip_4_counter = 256; - - $iplist[] = "'$ip_1_counter.$ip_2_counter.$ip_3_counter.*'"; - } - - while ($ip_4_counter <= $ip_4_end) - { - $iplist[] = "'$ip_1_counter.$ip_2_counter.$ip_3_counter.$ip_4_counter'"; - $ip_4_counter++; - } - $ip_3_counter++; - } - $ip_2_counter++; - } - $ip_1_counter++; - } - } - else if (preg_match('#^([0-9]{1,3})\.([0-9\*]{1,3})\.([0-9\*]{1,3})\.([0-9\*]{1,3})$#', trim($item)) || preg_match('#^[a-f0-9:]+\*?$#i', trim($item))) - { - $iplist[] = "'" . trim($item) . "'"; - } - else if (preg_match('#^([\w\-_]\.?){2,}$#is', trim($item))) - { - $hostlist[] = "'" . trim($item) . "'"; - } - else if (preg_match("#^([a-z0-9\-\*\._/]+?)$#is", trim($item))) - { - $hostlist[] = "'" . trim($item) . "'"; - } - } - - $sql = 'SELECT site_ip, site_hostname - FROM ' . SITELIST_TABLE . " - WHERE ip_exclude = $ip_exclude"; - $result = $db->sql_query($sql); - - if ($row = $db->sql_fetchrow($result)) - { - $iplist_tmp = array(); - $hostlist_tmp = array(); - do - { - if ($row['site_ip']) - { - if (strlen($row['site_ip']) > 40) - { - continue; - } - - $iplist_tmp[] = "'" . $row['site_ip'] . "'"; - } - else if ($row['site_hostname']) - { - if (strlen($row['site_hostname']) > 255) - { - continue; - } - - $hostlist_tmp[] = "'" . $row['site_hostname'] . "'"; - } - // break; - } - while ($row = $db->sql_fetchrow($result)); - - $iplist = array_unique(array_diff($iplist, $iplist_tmp)); - $hostlist = array_unique(array_diff($hostlist, $hostlist_tmp)); - unset($iplist_tmp); - unset($hostlist_tmp); - } - $db->sql_freeresult($result); - - if (count($iplist)) - { - foreach ($iplist as $ip_entry) - { - $sql = 'INSERT INTO ' . SITELIST_TABLE . " (site_ip, ip_exclude) - VALUES ($ip_entry, $ip_exclude)"; - $db->sql_query($sql); - } - } - - if (count($hostlist)) - { - foreach ($hostlist as $host_entry) - { - $sql = 'INSERT INTO ' . SITELIST_TABLE . " (site_hostname, ip_exclude) - VALUES ($host_entry, $ip_exclude)"; - $db->sql_query($sql); - } - } - - if (!empty($ip_list_log)) - { - // Update log - $log_entry = ($ip_exclude) ? 'LOG_DOWNLOAD_EXCLUDE_IP' : 'LOG_DOWNLOAD_IP'; - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, $log_entry, false, array($ip_list_log)); - } - - trigger_error($user->lang['SECURE_DOWNLOAD_UPDATE_SUCCESS'] . adm_back_link($this->u_action)); - } - else if (isset($_POST['unsecuresubmit'])) - { - $unip_sql = $request->variable('unip', array(0)); - - if (count($unip_sql)) - { - $l_unip_list = ''; - - // Grab details of ips for logging information later - $sql = 'SELECT site_ip, site_hostname - FROM ' . SITELIST_TABLE . ' - WHERE ' . $db->sql_in_set('site_id', $unip_sql); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $l_unip_list .= (($l_unip_list != '') ? ', ' : '') . (($row['site_ip']) ? $row['site_ip'] : $row['site_hostname']); - } - $db->sql_freeresult($result); - - $sql = 'DELETE FROM ' . SITELIST_TABLE . ' - WHERE ' . $db->sql_in_set('site_id', $unip_sql); - $db->sql_query($sql); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_DOWNLOAD_REMOVE_IP', false, array($l_unip_list)); - } - - trigger_error($user->lang['SECURE_DOWNLOAD_UPDATE_SUCCESS'] . adm_back_link($this->u_action)); - } - } - - /** - * Write display_order config field - */ - function display_order($value, $key = '') - { - $radio_ary = array(0 => 'DESCENDING', 1 => 'ASCENDING'); - - return h_radio('config[display_order]', $radio_ary, $value, $key); - } - - /** - * Adjust all three max_filesize config vars for display - */ - function max_filesize($value, $key = '') - { - // Determine size var and adjust the value accordingly - $filesize = get_formatted_filesize($value, false, array('mb', 'kb', 'b')); - $size_var = $filesize['si_identifier']; - $value = $filesize['value']; - - // size and maxlength must not be specified for input of type number - return ' '; - } - - /** - * Write secure_allow_deny config field - */ - function select_allow_deny($value, $key = '') - { - $radio_ary = array(1 => 'ORDER_ALLOW_DENY', 0 => 'ORDER_DENY_ALLOW'); - - return h_radio('config[' . $key . ']', $radio_ary, $value, $key); - } - -} diff --git a/install/update/old/includes/acp/acp_bbcodes.php b/install/update/old/includes/acp/acp_bbcodes.php deleted file mode 100644 index 1f7374a..0000000 --- a/install/update/old/includes/acp/acp_bbcodes.php +++ /dev/null @@ -1,620 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -class acp_bbcodes -{ - var $u_action; - - function main($id, $mode) - { - global $db, $user, $template, $cache, $request, $phpbb_dispatcher, $phpbb_container; - global $phpbb_log; - - $user->add_lang('acp/posting'); - - // Set up general vars - $action = $request->variable('action', ''); - $bbcode_id = $request->variable('bbcode', 0); - $submit = $request->is_set_post('submit'); - - $this->tpl_name = 'acp_bbcodes'; - $this->page_title = 'ACP_BBCODES'; - $form_key = 'acp_bbcodes'; - - add_form_key($form_key); - - if ($submit && !check_form_key($form_key)) - { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - // Set up mode-specific vars - switch ($action) - { - case 'add': - $bbcode_match = $bbcode_tpl = $bbcode_helpline = ''; - $display_on_posting = 0; - break; - - case 'edit': - $sql = 'SELECT bbcode_match, bbcode_tpl, display_on_posting, bbcode_helpline - FROM ' . BBCODES_TABLE . ' - WHERE bbcode_id = ' . $bbcode_id; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - trigger_error($user->lang['BBCODE_NOT_EXIST'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - $bbcode_match = $row['bbcode_match']; - $bbcode_tpl = htmlspecialchars($row['bbcode_tpl']); - $display_on_posting = $row['display_on_posting']; - $bbcode_helpline = $row['bbcode_helpline']; - break; - - case 'modify': - $sql = 'SELECT bbcode_id, bbcode_tag - FROM ' . BBCODES_TABLE . ' - WHERE bbcode_id = ' . $bbcode_id; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - trigger_error($user->lang['BBCODE_NOT_EXIST'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - // No break here - - case 'create': - $display_on_posting = $request->variable('display_on_posting', 0); - - $bbcode_match = $request->variable('bbcode_match', ''); - $bbcode_tpl = htmlspecialchars_decode($request->variable('bbcode_tpl', '', true)); - $bbcode_helpline = $request->variable('bbcode_helpline', '', true); - break; - } - - // Do major work - switch ($action) - { - case 'edit': - case 'add': - - $tpl_ary = array( - 'S_EDIT_BBCODE' => true, - 'U_BACK' => $this->u_action, - 'U_ACTION' => $this->u_action . '&action=' . (($action == 'add') ? 'create' : 'modify') . (($bbcode_id) ? "&bbcode=$bbcode_id" : ''), - - 'L_BBCODE_USAGE_EXPLAIN'=> sprintf($user->lang['BBCODE_USAGE_EXPLAIN'], '', ''), - 'BBCODE_MATCH' => $bbcode_match, - 'BBCODE_TPL' => $bbcode_tpl, - 'BBCODE_HELPLINE' => $bbcode_helpline, - 'DISPLAY_ON_POSTING' => $display_on_posting, - ); - - $bbcode_tokens = array('TEXT', 'SIMPLETEXT', 'INTTEXT', 'IDENTIFIER', 'NUMBER', 'EMAIL', 'URL', 'LOCAL_URL', 'RELATIVE_URL', 'COLOR'); - - /** - * Modify custom bbcode template data before we display the add/edit form - * - * @event core.acp_bbcodes_edit_add - * @var string action Type of the action: add|edit - * @var array tpl_ary Array with custom bbcode add/edit data - * @var int bbcode_id When editing: the bbcode id, - * when creating: 0 - * @var array bbcode_tokens Array of bbcode tokens - * @since 3.1.0-a3 - */ - $vars = array('action', 'tpl_ary', 'bbcode_id', 'bbcode_tokens'); - extract($phpbb_dispatcher->trigger_event('core.acp_bbcodes_edit_add', compact($vars))); - - $template->assign_vars($tpl_ary); - - foreach ($bbcode_tokens as $token) - { - $template->assign_block_vars('token', array( - 'TOKEN' => '{' . $token . '}', - 'EXPLAIN' => ($token === 'LOCAL_URL') ? $user->lang(array('tokens', $token), generate_board_url() . '/') : $user->lang(array('tokens', $token)), - )); - } - - return; - - break; - - case 'modify': - case 'create': - - $sql_ary = $hidden_fields = array(); - - /** - * Modify custom bbcode data before the modify/create action - * - * @event core.acp_bbcodes_modify_create - * @var string action Type of the action: modify|create - * @var array sql_ary Array with new bbcode data - * @var int bbcode_id When editing: the bbcode id, - * when creating: 0 - * @var bool display_on_posting Display bbcode on posting form - * @var string bbcode_match The bbcode usage string to match - * @var string bbcode_tpl The bbcode HTML replacement string - * @var string bbcode_helpline The bbcode help line string - * @var array hidden_fields Array of hidden fields for use when - * submitting form when $warn_text is true - * @since 3.1.0-a3 - */ - $vars = array( - 'action', - 'sql_ary', - 'bbcode_id', - 'display_on_posting', - 'bbcode_match', - 'bbcode_tpl', - 'bbcode_helpline', - 'hidden_fields', - ); - extract($phpbb_dispatcher->trigger_event('core.acp_bbcodes_modify_create', compact($vars))); - - $warn_text = preg_match('%<[^>]*\{text[\d]*\}[^>]*>%i', $bbcode_tpl); - if (!$warn_text || confirm_box(true)) - { - $data = $this->build_regexp($bbcode_match, $bbcode_tpl); - - // Make sure the user didn't pick a "bad" name for the BBCode tag. - $hard_coded = array('code', 'quote', 'quote=', 'attachment', 'attachment=', 'b', 'i', 'url', 'url=', 'img', 'size', 'size=', 'color', 'color=', 'u', 'list', 'list=', 'email', 'email=', 'flash', 'flash='); - - if (($action == 'modify' && strtolower($data['bbcode_tag']) !== strtolower($row['bbcode_tag'])) || ($action == 'create')) - { - $sql = 'SELECT 1 as test - FROM ' . BBCODES_TABLE . " - WHERE LOWER(bbcode_tag) = '" . $db->sql_escape(strtolower($data['bbcode_tag'])) . "'"; - $result = $db->sql_query($sql); - $info = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - // Grab the end, interrogate the last closing tag - if ($info['test'] === '1' || in_array(strtolower($data['bbcode_tag']), $hard_coded) || (preg_match('#\[/([^[]*)]$#', $bbcode_match, $regs) && in_array(strtolower($regs[1]), $hard_coded))) - { - trigger_error($user->lang['BBCODE_INVALID_TAG_NAME'] . adm_back_link($this->u_action), E_USER_WARNING); - } - } - - if (substr($data['bbcode_tag'], -1) === '=') - { - $test = substr($data['bbcode_tag'], 0, -1); - } - else - { - $test = $data['bbcode_tag']; - } - - if (!preg_match('%\\[' . $test . '[^]]*].*?\\[/' . $test . ']%s', $bbcode_match)) - { - trigger_error($user->lang['BBCODE_OPEN_ENDED_TAG'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - if (strlen($data['bbcode_tag']) > 16) - { - trigger_error($user->lang['BBCODE_TAG_TOO_LONG'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - if (strlen($bbcode_match) > 4000) - { - trigger_error($user->lang['BBCODE_TAG_DEF_TOO_LONG'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - if (strlen($bbcode_helpline) > 255) - { - trigger_error($user->lang['BBCODE_HELPLINE_TOO_LONG'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - $sql_ary = array_merge($sql_ary, array( - 'bbcode_tag' => $data['bbcode_tag'], - 'bbcode_match' => $bbcode_match, - 'bbcode_tpl' => $bbcode_tpl, - 'display_on_posting' => $display_on_posting, - 'bbcode_helpline' => $bbcode_helpline, - 'first_pass_match' => $data['first_pass_match'], - 'first_pass_replace' => $data['first_pass_replace'], - 'second_pass_match' => $data['second_pass_match'], - 'second_pass_replace' => $data['second_pass_replace'] - )); - - if ($action == 'create') - { - $sql = 'SELECT MAX(bbcode_id) as max_bbcode_id - FROM ' . BBCODES_TABLE; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - $bbcode_id = (int) $row['max_bbcode_id'] + 1; - - // Make sure it is greater than the core bbcode ids... - if ($bbcode_id <= NUM_CORE_BBCODES) - { - $bbcode_id = NUM_CORE_BBCODES + 1; - } - } - else - { - $bbcode_id = NUM_CORE_BBCODES + 1; - } - - if ($bbcode_id > BBCODE_LIMIT) - { - trigger_error($user->lang['TOO_MANY_BBCODES'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - $sql_ary['bbcode_id'] = (int) $bbcode_id; - - $db->sql_query('INSERT INTO ' . BBCODES_TABLE . $db->sql_build_array('INSERT', $sql_ary)); - $cache->destroy('sql', BBCODES_TABLE); - $phpbb_container->get('text_formatter.cache')->invalidate(); - - $lang = 'BBCODE_ADDED'; - $log_action = 'LOG_BBCODE_ADD'; - } - else - { - $sql = 'UPDATE ' . BBCODES_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE bbcode_id = ' . $bbcode_id; - $db->sql_query($sql); - $cache->destroy('sql', BBCODES_TABLE); - $phpbb_container->get('text_formatter.cache')->invalidate(); - - $lang = 'BBCODE_EDITED'; - $log_action = 'LOG_BBCODE_EDIT'; - } - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, $log_action, false, array($data['bbcode_tag'])); - - /** - * Event after a BBCode has been added or updated - * - * @event core.acp_bbcodes_modify_create_after - * @var string action Type of the action: modify|create - * @var int bbcode_id The id of the added or updated bbcode - * @var array sql_ary Array with bbcode data (read only) - * @since 3.2.4-RC1 - */ - $vars = array( - 'action', - 'bbcode_id', - 'sql_ary', - ); - extract($phpbb_dispatcher->trigger_event('core.acp_bbcodes_modify_create_after', compact($vars))); - - trigger_error($user->lang[$lang] . adm_back_link($this->u_action)); - } - else - { - confirm_box(false, $user->lang['BBCODE_DANGER'], build_hidden_fields(array_merge($hidden_fields, array( - 'action' => $action, - 'bbcode' => $bbcode_id, - 'bbcode_match' => $bbcode_match, - 'bbcode_tpl' => htmlspecialchars($bbcode_tpl), - 'bbcode_helpline' => $bbcode_helpline, - 'display_on_posting' => $display_on_posting, - ))) - , 'confirm_bbcode.html'); - } - - break; - - case 'delete': - - $sql = 'SELECT bbcode_tag - FROM ' . BBCODES_TABLE . " - WHERE bbcode_id = $bbcode_id"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - if (confirm_box(true)) - { - $bbcode_tag = $row['bbcode_tag']; - - $db->sql_query('DELETE FROM ' . BBCODES_TABLE . " WHERE bbcode_id = $bbcode_id"); - $cache->destroy('sql', BBCODES_TABLE); - $phpbb_container->get('text_formatter.cache')->invalidate(); - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_BBCODE_DELETE', false, array($bbcode_tag)); - - /** - * Event after a BBCode has been deleted - * - * @event core.acp_bbcodes_delete_after - * @var string action Type of the action: delete - * @var int bbcode_id The id of the deleted bbcode - * @var string bbcode_tag The tag of the deleted bbcode - * @since 3.2.4-RC1 - */ - $vars = array( - 'action', - 'bbcode_id', - 'bbcode_tag', - ); - extract($phpbb_dispatcher->trigger_event('core.acp_bbcodes_delete_after', compact($vars))); - - if ($request->is_ajax()) - { - $json_response = new \phpbb\json_response; - $json_response->send(array( - 'MESSAGE_TITLE' => $user->lang['INFORMATION'], - 'MESSAGE_TEXT' => $user->lang['BBCODE_DELETED'], - 'REFRESH_DATA' => array( - 'time' => 3 - ) - )); - } - } - else - { - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( - 'bbcode' => $bbcode_id, - 'i' => $id, - 'mode' => $mode, - 'action' => $action)) - ); - } - } - - break; - } - - $u_action = $this->u_action; - - $template_data = array( - 'U_ACTION' => $this->u_action . '&action=add', - ); - - $sql_ary = array( - 'SELECT' => 'b.*', - 'FROM' => array(BBCODES_TABLE => 'b'), - 'ORDER_BY' => 'b.bbcode_tag', - ); - - /** - * Modify custom bbcode template data before we display the form - * - * @event core.acp_bbcodes_display_form - * @var string action Type of the action: modify|create - * @var array sql_ary The SQL array to get custom bbcode data - * @var array template_data Array with form template data - * @var string u_action The u_action link - * @since 3.1.0-a3 - */ - $vars = array('action', 'sql_ary', 'template_data', 'u_action'); - extract($phpbb_dispatcher->trigger_event('core.acp_bbcodes_display_form', compact($vars))); - - $result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary)); - - $template->assign_vars($template_data); - - while ($row = $db->sql_fetchrow($result)) - { - $bbcodes_array = array( - 'BBCODE_TAG' => $row['bbcode_tag'], - 'U_EDIT' => $u_action . '&action=edit&bbcode=' . $row['bbcode_id'], - 'U_DELETE' => $u_action . '&action=delete&bbcode=' . $row['bbcode_id'], - ); - - /** - * Modify display of custom bbcodes in the form - * - * @event core.acp_bbcodes_display_bbcodes - * @var array row Array with current bbcode data - * @var array bbcodes_array Array of bbcodes template data - * @var string u_action The u_action link - * @since 3.1.0-a3 - */ - $vars = array('bbcodes_array', 'row', 'u_action'); - extract($phpbb_dispatcher->trigger_event('core.acp_bbcodes_display_bbcodes', compact($vars))); - - $template->assign_block_vars('bbcodes', $bbcodes_array); - - } - $db->sql_freeresult($result); - } - - /* - * Build regular expression for custom bbcode - */ - function build_regexp(&$bbcode_match, &$bbcode_tpl) - { - $bbcode_match = trim($bbcode_match); - $bbcode_tpl = trim($bbcode_tpl); - - // Allow unicode characters for URL|LOCAL_URL|RELATIVE_URL|INTTEXT tokens - $utf8 = preg_match('/(URL|LOCAL_URL|RELATIVE_URL|INTTEXT)/', $bbcode_match); - - $fp_match = preg_quote($bbcode_match, '!'); - $fp_replace = preg_replace('#^\[(.*?)\]#', '[$1:$uid]', $bbcode_match); - $fp_replace = preg_replace('#\[/(.*?)\]$#', '[/$1:$uid]', $fp_replace); - - $sp_match = preg_quote($bbcode_match, '!'); - $sp_match = preg_replace('#^\\\\\[(.*?)\\\\\]#', '\[$1:$uid\]', $sp_match); - $sp_match = preg_replace('#\\\\\[/(.*?)\\\\\]$#', '\[/$1:$uid\]', $sp_match); - $sp_replace = $bbcode_tpl; - - // @todo Make sure to change this too if something changed in message parsing - $tokens = array( - 'URL' => array( - '!(?:(' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('url')) . ')|(' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('www_url')) . '))!ie' => "\$this->bbcode_specialchars(('\$1') ? '\$1' : 'http://\$2')" - ), - 'LOCAL_URL' => array( - '!(' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('relative_url')) . ')!e' => "\$this->bbcode_specialchars('$1')" - ), - 'RELATIVE_URL' => array( - '!(' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('relative_url')) . ')!e' => "\$this->bbcode_specialchars('$1')" - ), - 'EMAIL' => array( - '!(' . get_preg_expression('email') . ')!ie' => "\$this->bbcode_specialchars('$1')" - ), - 'TEXT' => array( - '!(.*?)!es' => "str_replace(array(\"\\r\\n\", '\\\"', '\\'', '(', ')'), array(\"\\n\", '\"', ''', '(', ')'), trim('\$1'))" - ), - 'SIMPLETEXT' => array( - '!([a-zA-Z0-9-+.,_ ]+)!' => "$1" - ), - 'INTTEXT' => array( - '!([\p{L}\p{N}\-+,_. ]+)!u' => "$1" - ), - 'IDENTIFIER' => array( - '!([a-zA-Z0-9-_]+)!' => "$1" - ), - 'COLOR' => array( - '!([a-z]+|#[0-9abcdef]+)!i' => '$1' - ), - 'NUMBER' => array( - '!([0-9]+)!' => '$1' - ) - ); - - $sp_tokens = array( - 'URL' => '(?i)((?:' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('url')) . ')|(?:' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('www_url')) . '))(?-i)', - 'LOCAL_URL' => '(?i)(' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('relative_url')) . ')(?-i)', - 'RELATIVE_URL' => '(?i)(' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('relative_url')) . ')(?-i)', - 'EMAIL' => '(' . get_preg_expression('email') . ')', - 'TEXT' => '(.*?)', - 'SIMPLETEXT' => '([a-zA-Z0-9-+.,_ ]+)', - 'INTTEXT' => '([\p{L}\p{N}\-+,_. ]+)', - 'IDENTIFIER' => '([a-zA-Z0-9-_]+)', - 'COLOR' => '([a-zA-Z]+|#[0-9abcdefABCDEF]+)', - 'NUMBER' => '([0-9]+)', - ); - - $pad = 0; - $modifiers = 'i'; - $modifiers .= ($utf8) ? 'u' : ''; - - if (preg_match_all('/\{(' . implode('|', array_keys($tokens)) . ')[0-9]*\}/i', $bbcode_match, $m)) - { - foreach ($m[0] as $n => $token) - { - $token_type = $m[1][$n]; - - reset($tokens[strtoupper($token_type)]); - list($match, $replace) = each($tokens[strtoupper($token_type)]); - - // Pad backreference numbers from tokens - if (preg_match_all('/(?lang['BBCODE_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - $fp_match = preg_replace_callback('#\[/?' . $bbcode_search . '#i', function ($match) { - return strtolower($match[0]); - }, $fp_match); - $fp_replace = preg_replace_callback('#\[/?' . $bbcode_search . '#i', function ($match) { - return strtolower($match[0]); - }, $fp_replace); - $sp_match = preg_replace_callback('#\[/?' . $bbcode_search . '#i', function ($match) { - return strtolower($match[0]); - }, $sp_match); - $sp_replace = preg_replace_callback('#\[/?' . $bbcode_search . '#i', function ($match) { - return strtolower($match[0]); - }, $sp_replace); - - return array( - 'bbcode_tag' => $bbcode_tag, - 'first_pass_match' => $fp_match, - 'first_pass_replace' => $fp_replace, - 'second_pass_match' => $sp_match, - 'second_pass_replace' => $sp_replace - ); - } -} diff --git a/install/update/old/includes/acp/acp_board.php b/install/update/old/includes/acp/acp_board.php deleted file mode 100644 index e348c76..0000000 --- a/install/update/old/includes/acp/acp_board.php +++ /dev/null @@ -1,1178 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @todo add cron intervals to server settings? (database_gc, queue_interval, session_gc, search_gc, cache_gc, warnings_gc) -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -class acp_board -{ - var $u_action; - var $new_config; - - function main($id, $mode) - { - global $user, $template, $request, $language; - global $config, $phpbb_root_path, $phpEx; - global $cache, $phpbb_container, $phpbb_dispatcher, $phpbb_log; - - /** @var \phpbb\language\language $language Language object */ - $language = $phpbb_container->get('language'); - - $user->add_lang('acp/board'); - - $submit = (isset($_POST['submit']) || isset($_POST['allow_quick_reply_enable'])) ? true : false; - - $form_key = 'acp_board'; - add_form_key($form_key); - - /** - * Validation types are: - * string, int, bool, - * script_path (absolute path in url - beginning with / and no trailing slash), - * rpath (relative), rwpath (realtive, writable), path (relative path, but able to escape the root), wpath (writable) - */ - switch ($mode) - { - case 'settings': - $display_vars = array( - 'title' => 'ACP_BOARD_SETTINGS', - 'vars' => array( - 'legend1' => 'ACP_BOARD_SETTINGS', - 'sitename' => array('lang' => 'SITE_NAME', 'validate' => 'string', 'type' => 'text:40:255', 'explain' => false), - 'site_desc' => array('lang' => 'SITE_DESC', 'validate' => 'string', 'type' => 'text:40:255', 'explain' => false), - 'site_home_url' => array('lang' => 'SITE_HOME_URL', 'validate' => 'url', 'type' => 'url:40:255', 'explain' => true), - 'site_home_text' => array('lang' => 'SITE_HOME_TEXT', 'validate' => 'string', 'type' => 'text:40:255', 'explain' => true), - 'board_index_text' => array('lang' => 'BOARD_INDEX_TEXT', 'validate' => 'string', 'type' => 'text:40:255', 'explain' => true), - 'board_disable' => array('lang' => 'DISABLE_BOARD', 'validate' => 'bool', 'type' => 'custom', 'method' => 'board_disable', 'explain' => true), - 'board_disable_msg' => false, - 'default_lang' => array('lang' => 'DEFAULT_LANGUAGE', 'validate' => 'lang', 'type' => 'select', 'function' => 'language_select', 'params' => array('{CONFIG_VALUE}'), 'explain' => false), - 'default_dateformat' => array('lang' => 'DEFAULT_DATE_FORMAT', 'validate' => 'string', 'type' => 'custom', 'method' => 'dateformat_select', 'explain' => true), - 'board_timezone' => array('lang' => 'SYSTEM_TIMEZONE', 'validate' => 'timezone', 'type' => 'custom', 'method' => 'timezone_select', 'explain' => true), - - 'legend2' => 'BOARD_STYLE', - 'default_style' => array('lang' => 'DEFAULT_STYLE', 'validate' => 'int', 'type' => 'select', 'function' => 'style_select', 'params' => array('{CONFIG_VALUE}', false), 'explain' => true), - 'guest_style' => array('lang' => 'GUEST_STYLE', 'validate' => 'int', 'type' => 'select', 'function' => 'style_select', 'params' => array($this->guest_style_get(), false), 'explain' => true), - 'override_user_style' => array('lang' => 'OVERRIDE_STYLE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - - 'legend3' => 'WARNINGS', - 'warnings_expire_days' => array('lang' => 'WARNINGS_EXPIRE', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']), - - 'legend4' => 'ACP_SUBMIT_CHANGES', - ) - ); - break; - - case 'features': - $display_vars = array( - 'title' => 'ACP_BOARD_FEATURES', - 'vars' => array( - 'legend1' => 'ACP_BOARD_FEATURES', - 'allow_privmsg' => array('lang' => 'BOARD_PM', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'allow_topic_notify' => array('lang' => 'ALLOW_TOPIC_NOTIFY', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_forum_notify' => array('lang' => 'ALLOW_FORUM_NOTIFY', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_namechange' => array('lang' => 'ALLOW_NAME_CHANGE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_attachments' => array('lang' => 'ALLOW_ATTACHMENTS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_pm_attach' => array('lang' => 'ALLOW_PM_ATTACHMENTS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_pm_report' => array('lang' => 'ALLOW_PM_REPORT', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'allow_bbcode' => array('lang' => 'ALLOW_BBCODE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_smilies' => array('lang' => 'ALLOW_SMILIES', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_sig' => array('lang' => 'ALLOW_SIG', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_board_notifications' => array('lang' => 'ALLOW_BOARD_NOTIFICATIONS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_nocensors' => array('lang' => 'ALLOW_NO_CENSORS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'allow_bookmarks' => array('lang' => 'ALLOW_BOOKMARKS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'allow_birthdays' => array('lang' => 'ALLOW_BIRTHDAYS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'display_last_subject' => array('lang' => 'DISPLAY_LAST_SUBJECT', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'allow_quick_reply' => array('lang' => 'ALLOW_QUICK_REPLY', 'validate' => 'bool', 'type' => 'custom', 'method' => 'quick_reply', 'explain' => true), - - 'legend2' => 'ACP_LOAD_SETTINGS', - 'load_birthdays' => array('lang' => 'YES_BIRTHDAYS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'load_moderators' => array('lang' => 'YES_MODERATORS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'load_jumpbox' => array('lang' => 'YES_JUMPBOX', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'load_cpf_memberlist' => array('lang' => 'LOAD_CPF_MEMBERLIST', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'load_cpf_pm' => array('lang' => 'LOAD_CPF_PM', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'load_cpf_viewprofile' => array('lang' => 'LOAD_CPF_VIEWPROFILE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'load_cpf_viewtopic' => array('lang' => 'LOAD_CPF_VIEWTOPIC', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - - 'legend3' => 'ACP_SUBMIT_CHANGES', - ) - ); - break; - - case 'avatar': - /* @var $phpbb_avatar_manager \phpbb\avatar\manager */ - $phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); - $avatar_drivers = $phpbb_avatar_manager->get_all_drivers(); - - $avatar_vars = array(); - foreach ($avatar_drivers as $current_driver) - { - /** @var \phpbb\avatar\driver\driver_interface $driver */ - $driver = $phpbb_avatar_manager->get_driver($current_driver, false); - - /* - * First grab the settings for enabling/disabling the avatar - * driver and afterwards grab additional settings the driver - * might have. - */ - $avatar_vars += $phpbb_avatar_manager->get_avatar_settings($driver); - $avatar_vars += $driver->prepare_form_acp($user); - } - - $display_vars = array( - 'title' => 'ACP_AVATAR_SETTINGS', - 'vars' => array( - 'legend1' => 'ACP_AVATAR_SETTINGS', - - 'avatar_min_width' => array('lang' => 'MIN_AVATAR_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false), - 'avatar_min_height' => array('lang' => 'MIN_AVATAR_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false), - 'avatar_max_width' => array('lang' => 'MAX_AVATAR_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false), - 'avatar_max_height' => array('lang' => 'MAX_AVATAR_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false), - - 'allow_avatar' => array('lang' => 'ALLOW_AVATARS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'avatar_min' => array('lang' => 'MIN_AVATAR_SIZE', 'validate' => 'int:0', 'type' => 'dimension:0', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), - 'avatar_max' => array('lang' => 'MAX_AVATAR_SIZE', 'validate' => 'int:0', 'type' => 'dimension:0', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), - ) - ); - - if (!empty($avatar_vars)) - { - $display_vars['vars'] += $avatar_vars; - } - break; - - case 'message': - $display_vars = array( - 'title' => 'ACP_MESSAGE_SETTINGS', - 'lang' => 'ucp', - 'vars' => array( - 'legend1' => 'GENERAL_SETTINGS', - 'allow_privmsg' => array('lang' => 'BOARD_PM', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'pm_max_boxes' => array('lang' => 'BOXES_MAX', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true), - 'pm_max_msgs' => array('lang' => 'BOXES_LIMIT', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true), - 'full_folder_action' => array('lang' => 'FULL_FOLDER_ACTION', 'validate' => 'int', 'type' => 'select', 'method' => 'full_folder_select', 'explain' => true), - 'pm_edit_time' => array('lang' => 'PM_EDIT_TIME', 'validate' => 'int:0:99999', 'type' => 'number:0:99999', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']), - 'pm_max_recipients' => array('lang' => 'PM_MAX_RECIPIENTS', 'validate' => 'int:0:99999', 'type' => 'number:0:99999', 'explain' => true), - - 'legend2' => 'GENERAL_OPTIONS', - 'allow_mass_pm' => array('lang' => 'ALLOW_MASS_PM', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'auth_bbcode_pm' => array('lang' => 'ALLOW_BBCODE_PM', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'auth_smilies_pm' => array('lang' => 'ALLOW_SMILIES_PM', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_pm_attach' => array('lang' => 'ALLOW_PM_ATTACHMENTS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_sig_pm' => array('lang' => 'ALLOW_SIG_PM', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'print_pm' => array('lang' => 'ALLOW_PRINT_PM', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'forward_pm' => array('lang' => 'ALLOW_FORWARD_PM', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'auth_img_pm' => array('lang' => 'ALLOW_IMG_PM', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'auth_flash_pm' => array('lang' => 'ALLOW_FLASH_PM', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'enable_pm_icons' => array('lang' => 'ENABLE_PM_ICONS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - - 'legend3' => 'ACP_SUBMIT_CHANGES', - ) - ); - break; - - case 'post': - $display_vars = array( - 'title' => 'ACP_POST_SETTINGS', - 'vars' => array( - 'legend1' => 'GENERAL_OPTIONS', - 'allow_topic_notify' => array('lang' => 'ALLOW_TOPIC_NOTIFY', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_forum_notify' => array('lang' => 'ALLOW_FORUM_NOTIFY', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_bbcode' => array('lang' => 'ALLOW_BBCODE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_post_flash' => array('lang' => 'ALLOW_POST_FLASH', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'allow_smilies' => array('lang' => 'ALLOW_SMILIES', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_post_links' => array('lang' => 'ALLOW_POST_LINKS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'allowed_schemes_links' => array('lang' => 'ALLOWED_SCHEMES_LINKS', 'validate' => 'string', 'type' => 'text:0:255', 'explain' => true), - 'allow_nocensors' => array('lang' => 'ALLOW_NO_CENSORS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'allow_bookmarks' => array('lang' => 'ALLOW_BOOKMARKS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'enable_post_confirm' => array('lang' => 'VISUAL_CONFIRM_POST', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'allow_quick_reply' => array('lang' => 'ALLOW_QUICK_REPLY', 'validate' => 'bool', 'type' => 'custom', 'method' => 'quick_reply', 'explain' => true), - - 'legend2' => 'POSTING', - 'bump_type' => false, - 'edit_time' => array('lang' => 'EDIT_TIME', 'validate' => 'int:0:99999', 'type' => 'number:0:99999', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']), - 'delete_time' => array('lang' => 'DELETE_TIME', 'validate' => 'int:0:99999', 'type' => 'number:0:99999', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']), - 'display_last_edited' => array('lang' => 'DISPLAY_LAST_EDITED', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'flood_interval' => array('lang' => 'FLOOD_INTERVAL', 'validate' => 'int:0:9999999999', 'type' => 'number:0:9999999999', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']), - 'bump_interval' => array('lang' => 'BUMP_INTERVAL', 'validate' => 'int:0', 'type' => 'custom', 'method' => 'bump_interval', 'explain' => true), - 'topics_per_page' => array('lang' => 'TOPICS_PER_PAGE', 'validate' => 'int:1:9999', 'type' => 'number:1:9999', 'explain' => false), - 'posts_per_page' => array('lang' => 'POSTS_PER_PAGE', 'validate' => 'int:1:9999', 'type' => 'number:1:9999', 'explain' => false), - 'smilies_per_page' => array('lang' => 'SMILIES_PER_PAGE', 'validate' => 'int:1:9999', 'type' => 'number:1:9999', 'explain' => false), - 'hot_threshold' => array('lang' => 'HOT_THRESHOLD', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true), - 'max_poll_options' => array('lang' => 'MAX_POLL_OPTIONS', 'validate' => 'int:2:127', 'type' => 'number:2:127', 'explain' => false), - 'max_post_chars' => array('lang' => 'CHAR_LIMIT', 'validate' => 'int:0:999999', 'type' => 'number:0:999999', 'explain' => true), - 'min_post_chars' => array('lang' => 'MIN_CHAR_LIMIT', 'validate' => 'int:1:999999', 'type' => 'number:1:999999', 'explain' => true), - 'max_post_smilies' => array('lang' => 'SMILIES_LIMIT', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true), - 'max_post_urls' => array('lang' => 'MAX_POST_URLS', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true), - 'max_post_font_size' => array('lang' => 'MAX_POST_FONT_SIZE', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true, 'append' => ' %'), - 'max_quote_depth' => array('lang' => 'QUOTE_DEPTH_LIMIT', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true), - 'max_post_img_width' => array('lang' => 'MAX_POST_IMG_WIDTH', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), - 'max_post_img_height' => array('lang' => 'MAX_POST_IMG_HEIGHT', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), - - 'legend3' => 'ACP_SUBMIT_CHANGES', - ) - ); - break; - - case 'signature': - $display_vars = array( - 'title' => 'ACP_SIGNATURE_SETTINGS', - 'vars' => array( - 'legend1' => 'GENERAL_OPTIONS', - 'allow_sig' => array('lang' => 'ALLOW_SIG', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_sig_bbcode' => array('lang' => 'ALLOW_SIG_BBCODE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_sig_img' => array('lang' => 'ALLOW_SIG_IMG', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_sig_flash' => array('lang' => 'ALLOW_SIG_FLASH', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_sig_smilies' => array('lang' => 'ALLOW_SIG_SMILIES', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_sig_links' => array('lang' => 'ALLOW_SIG_LINKS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - - 'legend2' => 'GENERAL_SETTINGS', - 'max_sig_chars' => array('lang' => 'MAX_SIG_LENGTH', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true), - 'max_sig_urls' => array('lang' => 'MAX_SIG_URLS', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true), - 'max_sig_font_size' => array('lang' => 'MAX_SIG_FONT_SIZE', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true, 'append' => ' %'), - 'max_sig_smilies' => array('lang' => 'MAX_SIG_SMILIES', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true), - 'max_sig_img_width' => array('lang' => 'MAX_SIG_IMG_WIDTH', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), - 'max_sig_img_height' => array('lang' => 'MAX_SIG_IMG_HEIGHT', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), - - 'legend3' => 'ACP_SUBMIT_CHANGES', - ) - ); - break; - - case 'registration': - $display_vars = array( - 'title' => 'ACP_REGISTER_SETTINGS', - 'vars' => array( - 'legend1' => 'GENERAL_SETTINGS', - 'max_name_chars' => array('lang' => 'USERNAME_LENGTH', 'validate' => 'int:8:180', 'type' => false, 'method' => false, 'explain' => false,), - 'max_pass_chars' => array('lang' => 'PASSWORD_LENGTH', 'validate' => 'int:8:255', 'type' => false, 'method' => false, 'explain' => false,), - - 'require_activation' => array('lang' => 'ACC_ACTIVATION', 'validate' => 'int', 'type' => 'select', 'method' => 'select_acc_activation', 'explain' => true), - 'new_member_post_limit' => array('lang' => 'NEW_MEMBER_POST_LIMIT', 'validate' => 'int:0:255', 'type' => 'number:0:255', 'explain' => true, 'append' => ' ' . $user->lang['POSTS']), - 'new_member_group_default'=> array('lang' => 'NEW_MEMBER_GROUP_DEFAULT', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'min_name_chars' => array('lang' => 'USERNAME_LENGTH', 'validate' => 'int:1', 'type' => 'custom:5:180', 'method' => 'username_length', 'explain' => true), - 'min_pass_chars' => array('lang' => 'PASSWORD_LENGTH', 'validate' => 'int:1', 'type' => 'custom', 'method' => 'password_length', 'explain' => true), - 'allow_name_chars' => array('lang' => 'USERNAME_CHARS', 'validate' => 'string', 'type' => 'select', 'method' => 'select_username_chars', 'explain' => true), - 'pass_complex' => array('lang' => 'PASSWORD_TYPE', 'validate' => 'string', 'type' => 'select', 'method' => 'select_password_chars', 'explain' => true), - 'chg_passforce' => array('lang' => 'FORCE_PASS_CHANGE', 'validate' => 'int:0:999', 'type' => 'number:0:999', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']), - - 'legend2' => 'GENERAL_OPTIONS', - 'allow_namechange' => array('lang' => 'ALLOW_NAME_CHANGE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_emailreuse' => array('lang' => 'ALLOW_EMAIL_REUSE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'enable_confirm' => array('lang' => 'VISUAL_CONFIRM_REG', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'max_login_attempts' => array('lang' => 'MAX_LOGIN_ATTEMPTS', 'validate' => 'int:0:999', 'type' => 'number:0:999', 'explain' => true), - 'max_reg_attempts' => array('lang' => 'REG_LIMIT', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true), - - 'legend3' => 'COPPA', - 'coppa_enable' => array('lang' => 'ENABLE_COPPA', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'coppa_mail' => array('lang' => 'COPPA_MAIL', 'validate' => 'string', 'type' => 'textarea:5:40', 'explain' => true), - 'coppa_fax' => array('lang' => 'COPPA_FAX', 'validate' => 'string', 'type' => 'text:25:100', 'explain' => false), - - 'legend4' => 'ACP_SUBMIT_CHANGES', - ) - ); - break; - - case 'feed': - $display_vars = array( - 'title' => 'ACP_FEED_MANAGEMENT', - 'vars' => array( - 'legend1' => 'ACP_FEED_GENERAL', - 'feed_enable' => array('lang' => 'ACP_FEED_ENABLE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true ), - 'feed_item_statistics' => array('lang' => 'ACP_FEED_ITEM_STATISTICS', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), - 'feed_http_auth' => array('lang' => 'ACP_FEED_HTTP_AUTH', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), - - 'legend2' => 'ACP_FEED_POST_BASED', - 'feed_limit_post' => array('lang' => 'ACP_FEED_LIMIT', 'validate' => 'int:5:9999', 'type' => 'number:5:9999', 'explain' => true), - 'feed_overall' => array('lang' => 'ACP_FEED_OVERALL', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true ), - 'feed_forum' => array('lang' => 'ACP_FEED_FORUM', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true ), - 'feed_topic' => array('lang' => 'ACP_FEED_TOPIC', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true ), - - 'legend3' => 'ACP_FEED_TOPIC_BASED', - 'feed_limit_topic' => array('lang' => 'ACP_FEED_LIMIT', 'validate' => 'int:5:9999', 'type' => 'number:5:9999', 'explain' => true), - 'feed_topics_new' => array('lang' => 'ACP_FEED_TOPICS_NEW', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true ), - 'feed_topics_active' => array('lang' => 'ACP_FEED_TOPICS_ACTIVE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true ), - 'feed_news_id' => array('lang' => 'ACP_FEED_NEWS', 'validate' => 'string', 'type' => 'custom', 'method' => 'select_news_forums', 'explain' => true), - - 'legend4' => 'ACP_FEED_SETTINGS_OTHER', - 'feed_overall_forums' => array('lang' => 'ACP_FEED_OVERALL_FORUMS', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true ), - 'feed_exclude_id' => array('lang' => 'ACP_FEED_EXCLUDE_ID', 'validate' => 'string', 'type' => 'custom', 'method' => 'select_exclude_forums', 'explain' => true), - ) - ); - break; - - case 'cookie': - $display_vars = array( - 'title' => 'ACP_COOKIE_SETTINGS', - 'vars' => array( - 'legend1' => 'ACP_COOKIE_SETTINGS', - 'cookie_domain' => array('lang' => 'COOKIE_DOMAIN', 'validate' => 'string', 'type' => 'text::255', 'explain' => true), - 'cookie_name' => array('lang' => 'COOKIE_NAME', 'validate' => 'string', 'type' => 'text::16', 'explain' => true), - 'cookie_path' => array('lang' => 'COOKIE_PATH', 'validate' => 'string', 'type' => 'text::255', 'explain' => true), - 'cookie_secure' => array('lang' => 'COOKIE_SECURE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), - 'cookie_notice' => array('lang' => 'COOKIE_NOTICE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), - ) - ); - break; - - case 'load': - $display_vars = array( - 'title' => 'ACP_LOAD_SETTINGS', - 'vars' => array( - 'legend1' => 'GENERAL_SETTINGS', - 'limit_load' => array('lang' => 'LIMIT_LOAD', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true), - 'session_length' => array('lang' => 'SESSION_LENGTH', 'validate' => 'int:60:9999999999', 'type' => 'number:60:9999999999', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']), - 'active_sessions' => array('lang' => 'LIMIT_SESSIONS', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true), - 'load_online_time' => array('lang' => 'ONLINE_LENGTH', 'validate' => 'int:0:999', 'type' => 'number:0:999', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']), - 'read_notification_expire_days' => array('lang' => 'READ_NOTIFICATION_EXPIRE_DAYS', 'validate' => 'int:0', 'type' => 'number:0', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']), - - 'legend2' => 'GENERAL_OPTIONS', - 'load_notifications' => array('lang' => 'LOAD_NOTIFICATIONS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'load_db_track' => array('lang' => 'YES_POST_MARKING', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'load_db_lastread' => array('lang' => 'YES_READ_MARKING', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'load_anon_lastread' => array('lang' => 'YES_ANON_READ_MARKING', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'load_online' => array('lang' => 'YES_ONLINE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'load_online_guests' => array('lang' => 'YES_ONLINE_GUESTS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'load_onlinetrack' => array('lang' => 'YES_ONLINE_TRACK', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'load_birthdays' => array('lang' => 'YES_BIRTHDAYS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'load_unreads_search' => array('lang' => 'YES_UNREAD_SEARCH', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'load_moderators' => array('lang' => 'YES_MODERATORS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'load_jumpbox' => array('lang' => 'YES_JUMPBOX', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'load_user_activity' => array('lang' => 'LOAD_USER_ACTIVITY', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'load_user_activity_limit' => array('lang' => 'LOAD_USER_ACTIVITY_LIMIT', 'validate' => 'int:0:99999999', 'type' => 'number:0:99999999', 'explain' => true), - 'load_tplcompile' => array('lang' => 'RECOMPILE_STYLES', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'allow_cdn' => array('lang' => 'ALLOW_CDN', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'enable_accurate_pm_button' => array('lang' => 'YES_ACCURATE_PM_BUTTON', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'allow_live_searches' => array('lang' => 'ALLOW_LIVE_SEARCHES', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - - 'legend3' => 'CUSTOM_PROFILE_FIELDS', - 'load_cpf_memberlist' => array('lang' => 'LOAD_CPF_MEMBERLIST', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'load_cpf_pm' => array('lang' => 'LOAD_CPF_PM', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'load_cpf_viewprofile' => array('lang' => 'LOAD_CPF_VIEWPROFILE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'load_cpf_viewtopic' => array('lang' => 'LOAD_CPF_VIEWTOPIC', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - - 'legend4' => 'ACP_SUBMIT_CHANGES', - ) - ); - break; - - case 'auth': - $display_vars = array( - 'title' => 'ACP_AUTH_SETTINGS', - 'vars' => array( - 'legend1' => 'ACP_AUTH_SETTINGS', - 'auth_method' => array('lang' => 'AUTH_METHOD', 'validate' => 'string', 'type' => 'select:1:toggable', 'method' => 'select_auth_method', 'explain' => false), - ) - ); - break; - - case 'server': - $display_vars = array( - 'title' => 'ACP_SERVER_SETTINGS', - 'vars' => array( - 'legend1' => 'ACP_SERVER_SETTINGS', - 'gzip_compress' => array('lang' => 'ENABLE_GZIP', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'use_system_cron' => array('lang' => 'USE_SYSTEM_CRON', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - - 'legend2' => 'PATH_SETTINGS', - 'enable_mod_rewrite' => array('lang' => 'MOD_REWRITE_ENABLE', 'validate' => 'bool', 'type' => 'custom', 'method' => 'enable_mod_rewrite', 'explain' => true), - 'smilies_path' => array('lang' => 'SMILIES_PATH', 'validate' => 'rpath', 'type' => 'text:20:255', 'explain' => true), - 'icons_path' => array('lang' => 'ICONS_PATH', 'validate' => 'rpath', 'type' => 'text:20:255', 'explain' => true), - 'upload_icons_path' => array('lang' => 'UPLOAD_ICONS_PATH', 'validate' => 'rpath', 'type' => 'text:20:255', 'explain' => true), - 'ranks_path' => array('lang' => 'RANKS_PATH', 'validate' => 'rpath', 'type' => 'text:20:255', 'explain' => true), - - 'legend3' => 'SERVER_URL_SETTINGS', - 'force_server_vars' => array('lang' => 'FORCE_SERVER_VARS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'server_protocol' => array('lang' => 'SERVER_PROTOCOL', 'validate' => 'string', 'type' => 'text:10:10', 'explain' => true), - 'server_name' => array('lang' => 'SERVER_NAME', 'validate' => 'string', 'type' => 'text:40:255', 'explain' => true), - 'server_port' => array('lang' => 'SERVER_PORT', 'validate' => 'int:0:99999', 'type' => 'number:0:99999', 'explain' => true), - 'script_path' => array('lang' => 'SCRIPT_PATH', 'validate' => 'script_path', 'type' => 'text::255', 'explain' => true), - - 'legend4' => 'ACP_SUBMIT_CHANGES', - ) - ); - break; - - case 'security': - $display_vars = array( - 'title' => 'ACP_SECURITY_SETTINGS', - 'vars' => array( - 'legend1' => 'ACP_SECURITY_SETTINGS', - 'allow_autologin' => array('lang' => 'ALLOW_AUTOLOGIN', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'allow_password_reset' => array('lang' => 'ALLOW_PASSWORD_RESET', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'max_autologin_time' => array('lang' => 'AUTOLOGIN_LENGTH', 'validate' => 'int:0:99999', 'type' => 'number:0:99999', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']), - 'ip_check' => array('lang' => 'IP_VALID', 'validate' => 'int', 'type' => 'custom', 'method' => 'select_ip_check', 'explain' => true), - 'browser_check' => array('lang' => 'BROWSER_VALID', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'forwarded_for_check' => array('lang' => 'FORWARDED_FOR_VALID', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'referer_validation' => array('lang' => 'REFERRER_VALID', 'validate' => 'int:0:3','type' => 'custom', 'method' => 'select_ref_check', 'explain' => true), - 'remote_upload_verify' => array('lang' => 'UPLOAD_CERT_VALID', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'check_dnsbl' => array('lang' => 'CHECK_DNSBL', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'email_check_mx' => array('lang' => 'EMAIL_CHECK_MX', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'max_pass_chars' => array('lang' => 'PASSWORD_LENGTH', 'validate' => 'int:8:255', 'type' => false, 'method' => false, 'explain' => false,), - 'min_pass_chars' => array('lang' => 'PASSWORD_LENGTH', 'validate' => 'int:1', 'type' => 'custom', 'method' => 'password_length', 'explain' => true), - 'pass_complex' => array('lang' => 'PASSWORD_TYPE', 'validate' => 'string', 'type' => 'select', 'method' => 'select_password_chars', 'explain' => true), - 'chg_passforce' => array('lang' => 'FORCE_PASS_CHANGE', 'validate' => 'int:0:999', 'type' => 'number:0:999', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']), - 'max_login_attempts' => array('lang' => 'MAX_LOGIN_ATTEMPTS', 'validate' => 'int:0:999', 'type' => 'number:0:999', 'explain' => true), - 'ip_login_limit_max' => array('lang' => 'IP_LOGIN_LIMIT_MAX', 'validate' => 'int:0:999', 'type' => 'number:0:999', 'explain' => true), - 'ip_login_limit_time' => array('lang' => 'IP_LOGIN_LIMIT_TIME', 'validate' => 'int:0:99999', 'type' => 'number:0:99999', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']), - 'ip_login_limit_use_forwarded' => array('lang' => 'IP_LOGIN_LIMIT_USE_FORWARDED', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'tpl_allow_php' => array('lang' => 'TPL_ALLOW_PHP', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'form_token_lifetime' => array('lang' => 'FORM_TIME_MAX', 'validate' => 'int:-1:99999', 'type' => 'number:-1:99999', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']), - 'form_token_sid_guests' => array('lang' => 'FORM_SID_GUESTS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - - ) - ); - break; - - case 'email': - $display_vars = array( - 'title' => 'ACP_EMAIL_SETTINGS', - 'vars' => array( - 'legend1' => 'GENERAL_SETTINGS', - 'email_enable' => array('lang' => 'ENABLE_EMAIL', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), - 'board_email_form' => array('lang' => 'BOARD_EMAIL_FORM', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), - 'email_package_size' => array('lang' => 'EMAIL_PACKAGE_SIZE', 'validate' => 'int:0', 'type' => 'number:0:99999', 'explain' => true), - 'board_contact' => array('lang' => 'CONTACT_EMAIL', 'validate' => 'email', 'type' => 'email:25:100', 'explain' => true), - 'board_contact_name' => array('lang' => 'CONTACT_EMAIL_NAME', 'validate' => 'string', 'type' => 'text:25:50', 'explain' => true), - 'board_email' => array('lang' => 'ADMIN_EMAIL', 'validate' => 'email', 'type' => 'email:25:100', 'explain' => true), - 'email_force_sender' => array('lang' => 'EMAIL_FORCE_SENDER', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'board_email_sig' => array('lang' => 'EMAIL_SIG', 'validate' => 'string', 'type' => 'textarea:5:30', 'explain' => true), - 'board_hide_emails' => array('lang' => 'BOARD_HIDE_EMAILS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'send_test_email' => array('lang' => 'SEND_TEST_EMAIL', 'validate' => 'bool', 'type' => 'custom', 'method' => 'send_test_email', 'explain' => true), - - 'legend2' => 'SMTP_SETTINGS', - 'smtp_delivery' => array('lang' => 'USE_SMTP', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'smtp_host' => array('lang' => 'SMTP_SERVER', 'validate' => 'string', 'type' => 'text:25:50', 'explain' => true), - 'smtp_port' => array('lang' => 'SMTP_PORT', 'validate' => 'int:0:99999', 'type' => 'number:0:99999', 'explain' => true), - 'smtp_auth_method' => array('lang' => 'SMTP_AUTH_METHOD', 'validate' => 'string', 'type' => 'select', 'method' => 'mail_auth_select', 'explain' => true), - 'smtp_username' => array('lang' => 'SMTP_USERNAME', 'validate' => 'string', 'type' => 'text:25:255', 'explain' => true), - 'smtp_password' => array('lang' => 'SMTP_PASSWORD', 'validate' => 'string', 'type' => 'password:25:255', 'explain' => true), - 'smtp_verify_peer' => array('lang' => 'SMTP_VERIFY_PEER', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'smtp_verify_peer_name' => array('lang' => 'SMTP_VERIFY_PEER_NAME', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'smtp_allow_self_signed'=> array('lang' => 'SMTP_ALLOW_SELF_SIGNED','validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - - 'legend3' => 'ACP_SUBMIT_CHANGES', - ) - ); - break; - - default: - trigger_error('NO_MODE', E_USER_ERROR); - break; - } - - /** - * Event to add and/or modify acp_board configurations - * - * @event core.acp_board_config_edit_add - * @var array display_vars Array of config values to display and process - * @var string mode Mode of the config page we are displaying - * @var boolean submit Do we display the form or process the submission - * @since 3.1.0-a4 - */ - $vars = array('display_vars', 'mode', 'submit'); - extract($phpbb_dispatcher->trigger_event('core.acp_board_config_edit_add', compact($vars))); - - if (isset($display_vars['lang'])) - { - $user->add_lang($display_vars['lang']); - } - - $this->new_config = clone $config; - $cfg_array = (isset($_REQUEST['config'])) ? $request->variable('config', array('' => ''), true) : $this->new_config; - $error = array(); - - // We validate the complete config if wished - validate_config_vars($display_vars['vars'], $cfg_array, $error); - - if ($submit && !check_form_key($form_key)) - { - $error[] = $user->lang['FORM_INVALID']; - } - // Do not write values if there is an error - if (count($error)) - { - $submit = false; - } - - // We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to... - foreach ($display_vars['vars'] as $config_name => $data) - { - if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false) - { - continue; - } - - if ($config_name == 'auth_method' || $config_name == 'feed_news_id' || $config_name == 'feed_exclude_id') - { - continue; - } - - if ($config_name == 'guest_style') - { - if (isset($cfg_array[$config_name])) - { - $this->guest_style_set($cfg_array[$config_name]); - } - continue; - } - - $this->new_config[$config_name] = $config_value = $cfg_array[$config_name]; - - if ($submit) - { - if (strpos($data['type'], 'password') === 0 && $config_value === '********') - { - // Do not update password fields if the content is ********, - // because that is the password replacement we use to not - // send the password to the output - continue; - } - $config->set($config_name, $config_value); - - if ($config_name == 'allow_quick_reply' && isset($_POST['allow_quick_reply_enable'])) - { - enable_bitfield_column_flag(FORUMS_TABLE, 'forum_flags', round(log(FORUM_FLAG_QUICK_REPLY, 2))); - } - } - } - - // Invalidate the text_formatter cache when posting options are changed - if ($mode == 'post' && $submit) - { - $phpbb_container->get('text_formatter.cache')->invalidate(); - } - - // Store news and exclude ids - if ($mode == 'feed' && $submit) - { - $cache->destroy('_feed_news_forum_ids'); - $cache->destroy('_feed_excluded_forum_ids'); - - $this->store_feed_forums(FORUM_OPTION_FEED_NEWS, 'feed_news_id'); - $this->store_feed_forums(FORUM_OPTION_FEED_EXCLUDE, 'feed_exclude_id'); - } - - if ($mode == 'auth') - { - // Retrieve a list of auth plugins and check their config values - /* @var $auth_providers \phpbb\auth\provider_collection */ - $auth_providers = $phpbb_container->get('auth.provider_collection'); - - $updated_auth_settings = false; - $old_auth_config = array(); - foreach ($auth_providers as $provider) - { - /** @var \phpbb\auth\provider\provider_interface $provider */ - if ($fields = $provider->acp()) - { - // Check if we need to create config fields for this plugin and save config when submit was pressed - foreach ($fields as $field) - { - if (!isset($config[$field])) - { - $config->set($field, ''); - } - - if (!isset($cfg_array[$field]) || strpos($field, 'legend') !== false) - { - continue; - } - - if (substr($field, -9) === '_password' && $cfg_array[$field] === '********') - { - // Do not update password fields if the content is ********, - // because that is the password replacement we use to not - // send the password to the output - continue; - } - - $old_auth_config[$field] = $this->new_config[$field]; - $config_value = $cfg_array[$field]; - $this->new_config[$field] = $config_value; - - if ($submit) - { - $updated_auth_settings = true; - $config->set($field, $config_value); - } - } - } - unset($fields); - } - - if ($submit && (($cfg_array['auth_method'] != $this->new_config['auth_method']) || $updated_auth_settings)) - { - $method = basename($cfg_array['auth_method']); - if (array_key_exists('auth.provider.' . $method, $auth_providers)) - { - $provider = $auth_providers['auth.provider.' . $method]; - if ($error = $provider->init()) - { - foreach ($old_auth_config as $config_name => $config_value) - { - $config->set($config_name, $config_value); - } - trigger_error($error . adm_back_link($this->u_action), E_USER_WARNING); - } - $config->set('auth_method', basename($cfg_array['auth_method'])); - } - else - { - trigger_error('NO_AUTH_PLUGIN', E_USER_ERROR); - } - } - } - - if ($mode == 'email' && $request->is_set_post('send_test_email')) - { - if ($config['email_enable']) - { - include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); - - $messenger = new messenger(false); - $messenger->template('test'); - $messenger->set_addresses($user->data); - $messenger->anti_abuse_headers($config, $user); - $messenger->assign_vars(array( - 'USERNAME' => htmlspecialchars_decode($user->data['username']), - )); - $messenger->send(NOTIFY_EMAIL); - - trigger_error($user->lang('TEST_EMAIL_SENT') . adm_back_link($this->u_action)); - } - else - { - $user->add_lang('memberlist'); - trigger_error($user->lang('EMAIL_DISABLED') . adm_back_link($this->u_action), E_USER_WARNING); - } - } - - if ($submit) - { - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_CONFIG_' . strtoupper($mode)); - - $message = $user->lang('CONFIG_UPDATED'); - $message_type = E_USER_NOTICE; - if (!$config['email_enable'] && in_array($mode, array('email', 'registration')) && - in_array($config['require_activation'], array(USER_ACTIVATION_SELF, USER_ACTIVATION_ADMIN))) - { - $message .= '

' . $user->lang('ACC_ACTIVATION_WARNING'); - $message_type = E_USER_WARNING; - } - trigger_error($message . adm_back_link($this->u_action), $message_type); - } - - $this->tpl_name = 'acp_board'; - $this->page_title = $display_vars['title']; - - $template->assign_vars(array( - 'L_TITLE' => $user->lang[$display_vars['title']], - 'L_TITLE_EXPLAIN' => $user->lang[$display_vars['title'] . '_EXPLAIN'], - - 'S_ERROR' => (count($error)) ? true : false, - 'ERROR_MSG' => implode('
', $error), - - 'U_ACTION' => $this->u_action) - ); - - // Output relevant page - foreach ($display_vars['vars'] as $config_key => $vars) - { - if (!is_array($vars) && strpos($config_key, 'legend') === false) - { - continue; - } - - if (strpos($config_key, 'legend') !== false) - { - $template->assign_block_vars('options', array( - 'S_LEGEND' => true, - 'LEGEND' => (isset($user->lang[$vars])) ? $user->lang[$vars] : $vars) - ); - - continue; - } - - $type = explode(':', $vars['type']); - - $l_explain = ''; - if ($vars['explain'] && isset($vars['lang_explain'])) - { - $l_explain = (isset($user->lang[$vars['lang_explain']])) ? $user->lang[$vars['lang_explain']] : $vars['lang_explain']; - } - else if ($vars['explain']) - { - $l_explain = (isset($user->lang[$vars['lang'] . '_EXPLAIN'])) ? $user->lang[$vars['lang'] . '_EXPLAIN'] : ''; - } - - $content = build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars); - - if (empty($content)) - { - continue; - } - - $template->assign_block_vars('options', array( - 'KEY' => $config_key, - 'TITLE' => (isset($user->lang[$vars['lang']])) ? $user->lang[$vars['lang']] : $vars['lang'], - 'S_EXPLAIN' => $vars['explain'] && !empty($l_explain), - 'TITLE_EXPLAIN' => $l_explain, - 'CONTENT' => $content, - ) - ); - - unset($display_vars['vars'][$config_key]); - } - - if ($mode == 'auth') - { - $template->assign_var('S_AUTH', true); - - foreach ($auth_providers as $provider) - { - $auth_tpl = $provider->get_acp_template($this->new_config); - if ($auth_tpl) - { - if (array_key_exists('BLOCK_VAR_NAME', $auth_tpl)) - { - foreach ($auth_tpl['BLOCK_VARS'] as $block_vars) - { - $template->assign_block_vars($auth_tpl['BLOCK_VAR_NAME'], $block_vars); - } - } - $template->assign_vars($auth_tpl['TEMPLATE_VARS']); - $template->assign_block_vars('auth_tpl', array( - 'TEMPLATE_FILE' => $auth_tpl['TEMPLATE_FILE'], - )); - } - } - } - } - - /** - * Select auth method - */ - function select_auth_method($selected_method, $key = '') - { - global $phpbb_container; - - /* @var $auth_providers \phpbb\auth\provider_collection */ - $auth_providers = $phpbb_container->get('auth.provider_collection'); - $auth_plugins = array(); - - foreach ($auth_providers as $key => $value) - { - if (!($value instanceof \phpbb\auth\provider\provider_interface)) - { - continue; - } - $auth_plugins[] = str_replace('auth.provider.', '', $key); - } - - sort($auth_plugins); - - $auth_select = ''; - foreach ($auth_plugins as $method) - { - $selected = ($selected_method == $method) ? ' selected="selected"' : ''; - $auth_select .= "'; - } - - return $auth_select; - } - - /** - * Select mail authentication method - */ - function mail_auth_select($selected_method, $key = '') - { - global $user; - - $auth_methods = array('PLAIN', 'LOGIN', 'CRAM-MD5', 'DIGEST-MD5', 'POP-BEFORE-SMTP'); - $s_smtp_auth_options = ''; - - foreach ($auth_methods as $method) - { - $s_smtp_auth_options .= ''; - } - - return $s_smtp_auth_options; - } - - /** - * Select full folder action - */ - function full_folder_select($value, $key = '') - { - global $user; - - return ''; - } - - /** - * Select ip validation - */ - function select_ip_check($value, $key = '') - { - $radio_ary = array(4 => 'ALL', 3 => 'CLASS_C', 2 => 'CLASS_B', 0 => 'NO_IP_VALIDATION'); - - return h_radio('config[ip_check]', $radio_ary, $value, $key); - } - - /** - * Select referer validation - */ - function select_ref_check($value, $key = '') - { - $radio_ary = array(REFERER_VALIDATE_PATH => 'REF_PATH', REFERER_VALIDATE_HOST => 'REF_HOST', REFERER_VALIDATE_NONE => 'NO_REF_VALIDATION'); - - return h_radio('config[referer_validation]', $radio_ary, $value, $key); - } - - /** - * Select account activation method - */ - function select_acc_activation($selected_value, $value) - { - global $user, $config; - - $act_ary = array( - 'ACC_DISABLE' => array(true, USER_ACTIVATION_DISABLE), - 'ACC_NONE' => array(true, USER_ACTIVATION_NONE), - 'ACC_USER' => array($config['email_enable'], USER_ACTIVATION_SELF), - 'ACC_ADMIN' => array($config['email_enable'], USER_ACTIVATION_ADMIN), - ); - - $act_options = ''; - foreach ($act_ary as $key => $data) - { - list($available, $value) = $data; - $selected = ($selected_value == $value) ? ' selected="selected"' : ''; - $class = (!$available) ? ' class="disabled-option"' : ''; - $act_options .= ''; - } - - return $act_options; - } - - /** - * Maximum/Minimum username length - */ - function username_length($value, $key = '') - { - global $user; - - return ' ' . $user->lang['MIN_CHARS'] . '   ' . $user->lang['MAX_CHARS']; - } - - /** - * Allowed chars in usernames - */ - function select_username_chars($selected_value, $key) - { - global $user; - - $user_char_ary = array('USERNAME_CHARS_ANY', 'USERNAME_ALPHA_ONLY', 'USERNAME_ALPHA_SPACERS', 'USERNAME_LETTER_NUM', 'USERNAME_LETTER_NUM_SPACERS', 'USERNAME_ASCII'); - $user_char_options = ''; - foreach ($user_char_ary as $user_type) - { - $selected = ($selected_value == $user_type) ? ' selected="selected"' : ''; - $user_char_options .= ''; - } - - return $user_char_options; - } - - /** - * Maximum/Minimum password length - */ - function password_length($value, $key) - { - global $user; - - return ' ' . $user->lang['MIN_CHARS'] . '   ' . $user->lang['MAX_CHARS']; - } - - /** - * Required chars in passwords - */ - function select_password_chars($selected_value, $key) - { - global $user; - - $pass_type_ary = array('PASS_TYPE_ANY', 'PASS_TYPE_CASE', 'PASS_TYPE_ALPHA', 'PASS_TYPE_SYMBOL'); - $pass_char_options = ''; - foreach ($pass_type_ary as $pass_type) - { - $selected = ($selected_value == $pass_type) ? ' selected="selected"' : ''; - $pass_char_options .= ''; - } - - return $pass_char_options; - } - - /** - * Select bump interval - */ - function bump_interval($value, $key) - { - global $user; - - $s_bump_type = ''; - $types = array('m' => 'MINUTES', 'h' => 'HOURS', 'd' => 'DAYS'); - foreach ($types as $type => $lang) - { - $selected = ($this->new_config['bump_type'] == $type) ? ' selected="selected"' : ''; - $s_bump_type .= ''; - } - - return ' '; - } - - /** - * Board disable option and message - */ - function board_disable($value, $key) - { - $radio_ary = array(1 => 'YES', 0 => 'NO'); - - return h_radio('config[board_disable]', $radio_ary, $value) . '
'; - } - - /** - * Global quick reply enable/disable setting and button to enable in all forums - */ - function quick_reply($value, $key) - { - global $user; - - $radio_ary = array(1 => 'YES', 0 => 'NO'); - - return h_radio('config[allow_quick_reply]', $radio_ary, $value) . - '

'; - } - - /** - * Select guest timezone - */ - function timezone_select($value, $key) - { - global $template, $user; - - $timezone_select = phpbb_timezone_select($template, $user, $value, true); - - return ''; - } - - /** - * Get guest style - */ - public function guest_style_get() - { - global $db; - - $sql = 'SELECT user_style - FROM ' . USERS_TABLE . ' - WHERE user_id = ' . ANONYMOUS; - $result = $db->sql_query($sql); - - $style = (int) $db->sql_fetchfield('user_style'); - $db->sql_freeresult($result); - - return $style; - } - - /** - * Set guest style - * - * @param int $style_id The style ID - */ - public function guest_style_set($style_id) - { - global $db; - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_style = ' . (int) $style_id . ' - WHERE user_id = ' . ANONYMOUS; - $db->sql_query($sql); - } - - /** - * Select default dateformat - */ - function dateformat_select($value, $key) - { - global $user, $config; - - // Let the format_date function operate with the acp values - $old_tz = $user->timezone; - try - { - $user->timezone = new DateTimeZone($config['board_timezone']); - } - catch (\Exception $e) - { - // If the board timezone is invalid, we just use the users timezone. - } - - $dateformat_options = ''; - - foreach ($user->lang['dateformats'] as $format => $null) - { - $dateformat_options .= ''; - } - - $dateformat_options .= ''; - - // Reset users date options - $user->timezone = $old_tz; - - return " - "; - } - - /** - * Select multiple forums - */ - function select_news_forums($value, $key) - { - $forum_list = make_forum_select(false, false, true, true, true, false, true); - - // Build forum options - $s_forum_options = ''; - - return $s_forum_options; - } - - function select_exclude_forums($value, $key) - { - $forum_list = make_forum_select(false, false, true, true, true, false, true); - - // Build forum options - $s_forum_options = ''; - - return $s_forum_options; - } - - function store_feed_forums($option, $key) - { - global $db, $cache, $request; - - // Get key - $values = $request->variable($key, array(0 => 0)); - - // Empty option bit for all forums - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET forum_options = forum_options - ' . (1 << $option) . ' - WHERE ' . $db->sql_bit_and('forum_options', $option, '<> 0'); - $db->sql_query($sql); - - // Already emptied for all... - if (count($values)) - { - // Set for selected forums - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET forum_options = forum_options + ' . (1 << $option) . ' - WHERE ' . $db->sql_in_set('forum_id', $values); - $db->sql_query($sql); - } - - // Empty sql cache for forums table because options changed - $cache->destroy('sql', FORUMS_TABLE); - } - - /** - * Option to enable/disable removal of 'app.php' from URLs - * - * Note that if mod_rewrite is on, URLs without app.php will still work, - * but any paths generated by the controller helper url() method will not - * contain app.php. - * - * @param int $value The current config value - * @param string $key The config key - * @return string The HTML for the form field - */ - function enable_mod_rewrite($value, $key) - { - global $user; - - // Determine whether mod_rewrite is enabled on the server - // NOTE: This only works on Apache servers on which PHP is NOT - // installed as CGI. In that case, there is no way for PHP to - // determine whether or not the Apache module is enabled. - // - // To be clear on the value of $mod_rewite: - // null = Cannot determine whether or not the server has mod_rewrite - // enabled - // false = Can determine that the server does NOT have mod_rewrite - // enabled - // true = Can determine that the server DOES have mod_rewrite_enabled - $mod_rewrite = null; - if (function_exists('apache_get_modules')) - { - $mod_rewrite = (bool) in_array('mod_rewrite', apache_get_modules()); - } - - // If $message is false, mod_rewrite is enabled. - // Otherwise, it is not and we need to: - // 1) disable the form field - // 2) make sure the config value is set to 0 - // 3) append the message to the return - $value = ($mod_rewrite === false) ? 0 : $value; - $message = $mod_rewrite === null ? 'MOD_REWRITE_INFORMATION_UNAVAILABLE' : ($mod_rewrite === false ? 'MOD_REWRITE_DISABLED' : false); - - // Let's do some friendly HTML injection if we want to disable the - // form field because h_radio() has no pretty way of doing so - $field_name = 'config[enable_mod_rewrite]' . ($message === 'MOD_REWRITE_DISABLED' ? '" disabled="disabled' : ''); - - return h_radio($field_name, array(1 => 'YES', 0 => 'NO'), $value) . - ($message !== false ? '
' . $user->lang($message) . '' : ''); - } - - function send_test_email($value, $key) - { - global $user; - - return ''; - } -} diff --git a/install/update/old/includes/acp/acp_database.php b/install/update/old/includes/acp/acp_database.php deleted file mode 100644 index 05f2b98..0000000 --- a/install/update/old/includes/acp/acp_database.php +++ /dev/null @@ -1,622 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -class acp_database -{ - var $db_tools; - var $u_action; - public $page_title; - - function main($id, $mode) - { - global $cache, $db, $user, $template, $table_prefix, $request; - global $phpbb_root_path, $phpbb_container, $phpbb_log; - - $this->db_tools = $phpbb_container->get('dbal.tools'); - - $user->add_lang('acp/database'); - - $this->tpl_name = 'acp_database'; - $this->page_title = 'ACP_DATABASE'; - - $action = $request->variable('action', ''); - - $form_key = 'acp_database'; - add_form_key($form_key); - - $template->assign_vars(array( - 'MODE' => $mode - )); - - switch ($mode) - { - case 'backup': - - $this->page_title = 'ACP_BACKUP'; - - switch ($action) - { - case 'download': - $type = $request->variable('type', ''); - $table = array_intersect($this->db_tools->sql_list_tables(), $request->variable('table', array(''))); - $format = $request->variable('method', ''); - $where = $request->variable('where', ''); - - if (!count($table)) - { - trigger_error($user->lang['TABLE_SELECT_ERROR'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - if (!check_form_key($form_key)) - { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - $store = $structure = $schema_data = false; - - if ($where == 'store') - { - $store = true; - } - - if ($type == 'full' || $type == 'structure') - { - $structure = true; - } - - if ($type == 'full' || $type == 'data') - { - $schema_data = true; - } - - @set_time_limit(1200); - @set_time_limit(0); - - $time = time(); - - $filename = 'backup_' . $time . '_' . unique_id(); - - /** @var phpbb\db\extractor\extractor_interface $extractor Database extractor */ - $extractor = $phpbb_container->get('dbal.extractor'); - $extractor->init_extractor($format, $filename, $time, false, $store); - - $extractor->write_start($table_prefix); - - foreach ($table as $table_name) - { - // Get the table structure - if ($structure) - { - $extractor->write_table($table_name); - } - else - { - // We might wanna empty out all that junk :D - switch ($db->get_sql_layer()) - { - case 'sqlite3': - $extractor->flush('DELETE FROM ' . $table_name . ";\n"); - break; - - case 'mssql_odbc': - case 'mssqlnative': - $extractor->flush('TRUNCATE TABLE ' . $table_name . "GO\n"); - break; - - case 'oracle': - $extractor->flush('TRUNCATE TABLE ' . $table_name . "/\n"); - break; - - default: - $extractor->flush('TRUNCATE TABLE ' . $table_name . ";\n"); - break; - } - } - - // Data - if ($schema_data) - { - $extractor->write_data($table_name); - } - } - - $extractor->write_end(); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_DB_BACKUP'); - - trigger_error($user->lang['BACKUP_SUCCESS'] . adm_back_link($this->u_action)); - break; - - default: - $tables = $this->db_tools->sql_list_tables(); - asort($tables); - foreach ($tables as $table_name) - { - if (strlen($table_prefix) === 0 || stripos($table_name, $table_prefix) === 0) - { - $template->assign_block_vars('tables', array( - 'TABLE' => $table_name - )); - } - } - unset($tables); - - $template->assign_vars(array( - 'U_ACTION' => $this->u_action . '&action=download' - )); - - $available_methods = array('gzip' => 'zlib', 'bzip2' => 'bz2'); - - foreach ($available_methods as $type => $module) - { - if (!@extension_loaded($module)) - { - continue; - } - - $template->assign_block_vars('methods', array( - 'TYPE' => $type - )); - } - - $template->assign_block_vars('methods', array( - 'TYPE' => 'text' - )); - break; - } - break; - - case 'restore': - - $this->page_title = 'ACP_RESTORE'; - - switch ($action) - { - case 'submit': - $delete = $request->variable('delete', ''); - $file = $request->variable('file', ''); - - $backup_info = $this->get_backup_file($phpbb_root_path . 'store/', $file); - - if (empty($backup_info) || !is_readable($backup_info['file_name'])) - { - trigger_error($user->lang['BACKUP_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - if ($delete) - { - if (confirm_box(true)) - { - unlink($backup_info['file_name']); - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_DB_DELETE'); - trigger_error($user->lang['BACKUP_DELETE'] . adm_back_link($this->u_action)); - } - else - { - confirm_box(false, $user->lang['DELETE_SELECTED_BACKUP'], build_hidden_fields(array('delete' => $delete, 'file' => $file))); - } - } - else if (confirm_box(true)) - { - switch ($backup_info['extensions']) - { - case 'sql': - $fp = fopen($backup_info['file_name'], 'rb'); - $read = 'fread'; - $seek = 'fseek'; - $eof = 'feof'; - $close = 'fclose'; - $fgetd = 'fgetd'; - break; - - case 'sql.bz2': - $fp = bzopen($backup_info['file_name'], 'r'); - $read = 'bzread'; - $seek = ''; - $eof = 'feof'; - $close = 'bzclose'; - $fgetd = 'fgetd_seekless'; - break; - - case 'sql.gz': - $fp = gzopen($backup_info['file_name'], 'rb'); - $read = 'gzread'; - $seek = 'gzseek'; - $eof = 'gzeof'; - $close = 'gzclose'; - $fgetd = 'fgetd'; - break; - - default: - trigger_error($user->lang['BACKUP_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); - return; - } - - switch ($db->get_sql_layer()) - { - case 'mysql': - case 'mysql4': - case 'mysqli': - case 'sqlite3': - while (($sql = $fgetd($fp, ";\n", $read, $seek, $eof)) !== false) - { - $db->sql_query($sql); - } - break; - - case 'postgres': - $delim = ";\n"; - while (($sql = $fgetd($fp, $delim, $read, $seek, $eof)) !== false) - { - $query = trim($sql); - - if (substr($query, 0, 13) == 'CREATE DOMAIN') - { - list(, , $domain) = explode(' ', $query); - $sql = "SELECT domain_name - FROM information_schema.domains - WHERE domain_name = '$domain';"; - $result = $db->sql_query($sql); - if (!$db->sql_fetchrow($result)) - { - $db->sql_query($query); - } - $db->sql_freeresult($result); - } - else - { - $db->sql_query($query); - } - - if (substr($query, 0, 4) == 'COPY') - { - while (($sub = $fgetd($fp, "\n", $read, $seek, $eof)) !== '\.') - { - if ($sub === false) - { - trigger_error($user->lang['RESTORE_FAILURE'] . adm_back_link($this->u_action), E_USER_WARNING); - } - pg_put_line($db->get_db_connect_id(), $sub . "\n"); - } - pg_put_line($db->get_db_connect_id(), "\\.\n"); - pg_end_copy($db->get_db_connect_id()); - } - } - break; - - case 'oracle': - while (($sql = $fgetd($fp, "/\n", $read, $seek, $eof)) !== false) - { - $db->sql_query($sql); - } - break; - - case 'mssql_odbc': - case 'mssqlnative': - while (($sql = $fgetd($fp, "GO\n", $read, $seek, $eof)) !== false) - { - $db->sql_query($sql); - } - break; - } - - $close($fp); - - // Purge the cache due to updated data - $cache->purge(); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_DB_RESTORE'); - trigger_error($user->lang['RESTORE_SUCCESS'] . adm_back_link($this->u_action)); - break; - } - else - { - confirm_box(false, $user->lang['RESTORE_SELECTED_BACKUP'], build_hidden_fields(array('file' => $file))); - } - - default: - $backup_files = $this->get_file_list($phpbb_root_path . 'store/'); - - if (!empty($backup_files)) - { - krsort($backup_files); - - foreach ($backup_files as $name => $file) - { - $template->assign_block_vars('files', array( - 'FILE' => sha1($file), - 'NAME' => $user->format_date($name, 'd-m-Y H:i', true), - 'SUPPORTED' => true, - )); - } - } - - $template->assign_vars(array( - 'U_ACTION' => $this->u_action . '&action=submit' - )); - break; - } - break; - } - } - - /** - * Get backup file from file hash - * - * @param string $directory Relative path to directory - * @param string $file_hash Hash of selected file - * - * @return array Backup file data or empty array if unable to find file - */ - protected function get_backup_file($directory, $file_hash) - { - $backup_data = []; - - $file_list = $this->get_file_list($directory); - $supported_extensions = $this->get_supported_extensions(); - - foreach ($file_list as $file) - { - preg_match('#^backup_(\d{10,})_(?:[a-z\d]{16}|[a-z\d]{32})\.(sql(?:\.(?:gz|bz2))?)$#i', $file, $matches); - if (sha1($file) === $file_hash && in_array($matches[2], $supported_extensions)) - { - $backup_data = [ - 'file_name' => $directory . $file, - 'extension' => $matches[2], - ]; - break; - } - } - - return $backup_data; - } - - /** - * Get backup file list for directory - * - * @param string $directory Relative path to backup directory - * - * @return array List of backup files in specified directory - */ - protected function get_file_list($directory) - { - $supported_extensions = $this->get_supported_extensions(); - - $dh = @opendir($directory); - - $backup_files = []; - - if ($dh) - { - while (($file = readdir($dh)) !== false) - { - if (preg_match('#^backup_(\d{10,})_(?:[a-z\d]{16}|[a-z\d]{32})\.(sql(?:\.(?:gz|bz2))?)$#i', $file, $matches)) - { - if (in_array($matches[2], $supported_extensions)) - { - $backup_files[(int) $matches[1]] = $file; - } - } - } - closedir($dh); - } - - return $backup_files; - } - - /** - * Get supported extensions for backup - * - * @return array List of supported extensions - */ - protected function get_supported_extensions() - { - $extensions = ['sql']; - $available_methods = ['sql.gz' => 'zlib', 'sql.bz2' => 'bz2']; - - foreach ($available_methods as $type => $module) - { - if (!@extension_loaded($module)) - { - continue; - } - $extensions[] = $type; - } - - return $extensions; - } -} - -// get how much space we allow for a chunk of data, very similar to phpMyAdmin's way of doing things ;-) (hey, we only do this for MySQL anyway :P) -function get_usable_memory() -{ - $val = trim(@ini_get('memory_limit')); - - if (preg_match('/(\\d+)([mkg]?)/i', $val, $regs)) - { - $memory_limit = (int) $regs[1]; - switch ($regs[2]) - { - - case 'k': - case 'K': - $memory_limit *= 1024; - break; - - case 'm': - case 'M': - $memory_limit *= 1048576; - break; - - case 'g': - case 'G': - $memory_limit *= 1073741824; - break; - } - - // how much memory PHP requires at the start of export (it is really a little less) - if ($memory_limit > 6100000) - { - $memory_limit -= 6100000; - } - - // allow us to consume half of the total memory available - $memory_limit /= 2; - } - else - { - // set the buffer to 1M if we have no clue how much memory PHP will give us :P - $memory_limit = 1048576; - } - - return $memory_limit; -} - -function sanitize_data_mssql($text) -{ - $data = preg_split('/[\n\t\r\b\f]/', $text); - preg_match_all('/[\n\t\r\b\f]/', $text, $matches); - - $val = array(); - - foreach ($data as $value) - { - if (strlen($value)) - { - $val[] = "'" . $value . "'"; - } - if (count($matches[0])) - { - $val[] = 'char(' . ord(array_shift($matches[0])) . ')'; - } - } - - return implode('+', $val); -} - -function sanitize_data_oracle($text) -{ -// $data = preg_split('/[\0\n\t\r\b\f\'"\/\\\]/', $text); -// preg_match_all('/[\0\n\t\r\b\f\'"\/\\\]/', $text, $matches); - $data = preg_split('/[\0\b\f\'\/]/', $text); - preg_match_all('/[\0\r\b\f\'\/]/', $text, $matches); - - $val = array(); - - foreach ($data as $value) - { - if (strlen($value)) - { - $val[] = "'" . $value . "'"; - } - if (count($matches[0])) - { - $val[] = 'chr(' . ord(array_shift($matches[0])) . ')'; - } - } - - return implode('||', $val); -} - -function sanitize_data_generic($text) -{ - $data = preg_split('/[\n\t\r\b\f]/', $text); - preg_match_all('/[\n\t\r\b\f]/', $text, $matches); - - $val = array(); - - foreach ($data as $value) - { - if (strlen($value)) - { - $val[] = "'" . $value . "'"; - } - if (count($matches[0])) - { - $val[] = "'" . array_shift($matches[0]) . "'"; - } - } - - return implode('||', $val); -} - -// modified from PHP.net -function fgetd(&$fp, $delim, $read, $seek, $eof, $buffer = 8192) -{ - $record = ''; - $delim_len = strlen($delim); - - while (!$eof($fp)) - { - $pos = strpos($record, $delim); - if ($pos === false) - { - $record .= $read($fp, $buffer); - if ($eof($fp) && ($pos = strpos($record, $delim)) !== false) - { - $seek($fp, $pos + $delim_len - strlen($record), SEEK_CUR); - return substr($record, 0, $pos); - } - } - else - { - $seek($fp, $pos + $delim_len - strlen($record), SEEK_CUR); - return substr($record, 0, $pos); - } - } - - return false; -} - -function fgetd_seekless(&$fp, $delim, $read, $seek, $eof, $buffer = 8192) -{ - static $array = array(); - static $record = ''; - - if (!count($array)) - { - while (!$eof($fp)) - { - if (strpos($record, $delim) !== false) - { - $array = explode($delim, $record); - $record = array_pop($array); - break; - } - else - { - $record .= $read($fp, $buffer); - } - } - if ($eof($fp) && strpos($record, $delim) !== false) - { - $array = explode($delim, $record); - $record = array_pop($array); - } - } - - if (count($array)) - { - return array_shift($array); - } - - return false; -} diff --git a/install/update/old/includes/acp/acp_extensions.php b/install/update/old/includes/acp/acp_extensions.php deleted file mode 100644 index a1cb210..0000000 --- a/install/update/old/includes/acp/acp_extensions.php +++ /dev/null @@ -1,665 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -use phpbb\exception\exception_interface; -use phpbb\exception\version_check_exception; - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -class acp_extensions -{ - var $u_action; - var $tpl_name; - var $page_title; - - private $config; - private $template; - private $user; - private $log; - private $request; - private $phpbb_dispatcher; - private $ext_manager; - private $phpbb_container; - private $php_ini; - - function main() - { - // Start the page - global $config, $user, $template, $request, $phpbb_extension_manager, $phpbb_root_path, $phpbb_log, $phpbb_dispatcher, $phpbb_container; - - $this->config = $config; - $this->template = $template; - $this->user = $user; - $this->request = $request; - $this->log = $phpbb_log; - $this->phpbb_dispatcher = $phpbb_dispatcher; - $this->ext_manager = $phpbb_extension_manager; - $this->phpbb_container = $phpbb_container; - $this->php_ini = $this->phpbb_container->get('php_ini'); - - $this->user->add_lang(array('install', 'acp/extensions', 'migrator')); - - $this->page_title = 'ACP_EXTENSIONS'; - - $action = $this->request->variable('action', 'list'); - $ext_name = $this->request->variable('ext_name', ''); - - // What is a safe limit of execution time? Half the max execution time should be safe. - $safe_time_limit = ($this->php_ini->getNumeric('max_execution_time') / 2); - $start_time = time(); - - // Cancel action - if ($this->request->is_set_post('cancel')) - { - $action = 'list'; - $ext_name = ''; - } - - if (in_array($action, array('enable', 'disable', 'delete_data')) && !check_link_hash($this->request->variable('hash', ''), $action . '.' . $ext_name)) - { - trigger_error('FORM_INVALID', E_USER_WARNING); - } - - /** - * Event to run a specific action on extension - * - * @event core.acp_extensions_run_action_before - * @var string action Action to run; if the event completes execution of the action, should be set to 'none' - * @var string u_action Url we are at - * @var string ext_name Extension name from request - * @var int safe_time_limit Safe limit of execution time - * @var int start_time Start time - * @var string tpl_name Template file to load - * @since 3.1.11-RC1 - * @changed 3.2.1-RC1 Renamed to core.acp_extensions_run_action_before, added tpl_name, added action 'none' - */ - $u_action = $this->u_action; - $tpl_name = ''; - $vars = array('action', 'u_action', 'ext_name', 'safe_time_limit', 'start_time', 'tpl_name'); - extract($this->phpbb_dispatcher->trigger_event('core.acp_extensions_run_action_before', compact($vars))); - - // In case they have been updated by the event - $this->u_action = $u_action; - $this->tpl_name = $tpl_name; - - // If they've specified an extension, let's load the metadata manager and validate it. - if ($ext_name) - { - $md_manager = $this->ext_manager->create_extension_metadata_manager($ext_name); - - try - { - $md_manager->get_metadata('all'); - } - catch (exception_interface $e) - { - $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters())); - trigger_error($message . adm_back_link($this->u_action), E_USER_WARNING); - } - } - - // What are we doing? - switch ($action) - { - case 'none': - // Intentionally empty, used by extensions that execute additional actions in the prior event - break; - - case 'set_config_version_check_force_unstable': - $force_unstable = $this->request->variable('force_unstable', false); - - if ($force_unstable) - { - $s_hidden_fields = build_hidden_fields(array( - 'force_unstable' => $force_unstable, - )); - - confirm_box(false, $this->user->lang('EXTENSION_FORCE_UNSTABLE_CONFIRM'), $s_hidden_fields); - } - else - { - $this->config->set('extension_force_unstable', false); - trigger_error($this->user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action)); - } - break; - - case 'list': - default: - if (confirm_box(true)) - { - $this->config->set('extension_force_unstable', true); - trigger_error($this->user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action)); - } - - $this->list_enabled_exts(); - $this->list_disabled_exts(); - $this->list_available_exts(); - - $this->template->assign_vars(array( - 'U_VERSIONCHECK_FORCE' => $this->u_action . '&action=list&versioncheck_force=1', - 'FORCE_UNSTABLE' => $this->config['extension_force_unstable'], - 'U_ACTION' => $this->u_action, - )); - - $this->tpl_name = 'acp_ext_list'; - break; - - case 'enable_pre': - try - { - $md_manager->validate_enable(); - } - catch (exception_interface $e) - { - $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters())); - trigger_error($message . adm_back_link($this->u_action), E_USER_WARNING); - } - - $extension = $this->ext_manager->get_extension($ext_name); - if (!$extension->is_enableable()) - { - trigger_error($this->user->lang['EXTENSION_NOT_ENABLEABLE'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - if ($this->ext_manager->is_enabled($ext_name)) - { - redirect($this->u_action); - } - - $this->tpl_name = 'acp_ext_enable'; - - $this->template->assign_vars(array( - 'PRE' => true, - 'L_CONFIRM_MESSAGE' => $this->user->lang('EXTENSION_ENABLE_CONFIRM', $md_manager->get_metadata('display-name')), - 'U_ENABLE' => $this->u_action . '&action=enable&ext_name=' . urlencode($ext_name) . '&hash=' . generate_link_hash('enable.' . $ext_name), - )); - break; - - case 'enable': - try - { - $md_manager->validate_enable(); - } - catch (exception_interface $e) - { - $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters())); - trigger_error($message . adm_back_link($this->u_action), E_USER_WARNING); - } - - $extension = $this->ext_manager->get_extension($ext_name); - if (!$extension->is_enableable()) - { - trigger_error($this->user->lang['EXTENSION_NOT_ENABLEABLE'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - try - { - while ($this->ext_manager->enable_step($ext_name)) - { - // Are we approaching the time limit? If so we want to pause the update and continue after refreshing - if ((time() - $start_time) >= $safe_time_limit) - { - $this->template->assign_var('S_NEXT_STEP', true); - - meta_refresh(0, $this->u_action . '&action=enable&ext_name=' . urlencode($ext_name) . '&hash=' . generate_link_hash('enable.' . $ext_name)); - } - } - - // Update custom style for admin area - $this->template->set_custom_style(array( - array( - 'name' => 'adm', - 'ext_path' => 'adm/style/', - ), - ), array($phpbb_root_path . 'adm/style')); - - $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_EXT_ENABLE', time(), array($ext_name)); - } - catch (\phpbb\db\migration\exception $e) - { - $this->template->assign_var('MIGRATOR_ERROR', $e->getLocalisedMessage($this->user)); - } - - $this->tpl_name = 'acp_ext_enable'; - - $this->template->assign_vars(array( - 'U_RETURN' => $this->u_action . '&action=list', - )); - break; - - case 'disable_pre': - if (!$this->ext_manager->is_enabled($ext_name)) - { - redirect($this->u_action); - } - - $this->tpl_name = 'acp_ext_disable'; - - $this->template->assign_vars(array( - 'PRE' => true, - 'L_CONFIRM_MESSAGE' => $this->user->lang('EXTENSION_DISABLE_CONFIRM', $md_manager->get_metadata('display-name')), - 'U_DISABLE' => $this->u_action . '&action=disable&ext_name=' . urlencode($ext_name) . '&hash=' . generate_link_hash('disable.' . $ext_name), - )); - break; - - case 'disable': - if (!$this->ext_manager->is_enabled($ext_name)) - { - redirect($this->u_action); - } - - while ($this->ext_manager->disable_step($ext_name)) - { - // Are we approaching the time limit? If so we want to pause the update and continue after refreshing - if ((time() - $start_time) >= $safe_time_limit) - { - $this->template->assign_var('S_NEXT_STEP', true); - - meta_refresh(0, $this->u_action . '&action=disable&ext_name=' . urlencode($ext_name) . '&hash=' . generate_link_hash('disable.' . $ext_name)); - } - } - $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_EXT_DISABLE', time(), array($ext_name)); - - $this->tpl_name = 'acp_ext_disable'; - - $this->template->assign_vars(array( - 'U_RETURN' => $this->u_action . '&action=list', - )); - break; - - case 'delete_data_pre': - if ($this->ext_manager->is_enabled($ext_name)) - { - redirect($this->u_action); - } - $this->tpl_name = 'acp_ext_delete_data'; - - $this->template->assign_vars(array( - 'PRE' => true, - 'L_CONFIRM_MESSAGE' => $this->user->lang('EXTENSION_DELETE_DATA_CONFIRM', $md_manager->get_metadata('display-name')), - 'U_PURGE' => $this->u_action . '&action=delete_data&ext_name=' . urlencode($ext_name) . '&hash=' . generate_link_hash('delete_data.' . $ext_name), - )); - break; - - case 'delete_data': - if ($this->ext_manager->is_enabled($ext_name)) - { - redirect($this->u_action); - } - - try - { - while ($this->ext_manager->purge_step($ext_name)) - { - // Are we approaching the time limit? If so we want to pause the update and continue after refreshing - if ((time() - $start_time) >= $safe_time_limit) - { - $this->template->assign_var('S_NEXT_STEP', true); - - meta_refresh(0, $this->u_action . '&action=delete_data&ext_name=' . urlencode($ext_name) . '&hash=' . generate_link_hash('delete_data.' . $ext_name)); - } - } - $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_EXT_PURGE', time(), array($ext_name)); - } - catch (\phpbb\db\migration\exception $e) - { - $this->template->assign_var('MIGRATOR_ERROR', $e->getLocalisedMessage($this->user)); - } - - $this->tpl_name = 'acp_ext_delete_data'; - - $this->template->assign_vars(array( - 'U_RETURN' => $this->u_action . '&action=list', - )); - break; - - case 'details': - // Output it to the template - $meta = $md_manager->get_metadata('all'); - $this->output_metadata_to_template($meta); - - if (isset($meta['extra']['version-check'])) - { - try - { - $updates_available = $this->ext_manager->version_check($md_manager, $this->request->variable('versioncheck_force', false), false, $this->config['extension_force_unstable'] ? 'unstable' : null); - - $this->template->assign_vars(array( - 'S_UP_TO_DATE' => empty($updates_available), - 'UP_TO_DATE_MSG' => $this->user->lang(empty($updates_available) ? 'UP_TO_DATE' : 'NOT_UP_TO_DATE', $md_manager->get_metadata('display-name')), - )); - - $this->template->assign_block_vars('updates_available', $updates_available); - } - catch (exception_interface $e) - { - $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters())); - - $this->template->assign_vars(array( - 'S_VERSIONCHECK_FAIL' => true, - 'VERSIONCHECK_FAIL_REASON' => ($e->getMessage() !== 'VERSIONCHECK_FAIL') ? $message : '', - )); - } - $this->template->assign_var('S_VERSIONCHECK', true); - } - else - { - $this->template->assign_var('S_VERSIONCHECK', false); - } - - $this->template->assign_vars(array( - 'U_BACK' => $this->u_action . '&action=list', - 'U_VERSIONCHECK_FORCE' => $this->u_action . '&action=details&versioncheck_force=1&ext_name=' . urlencode($md_manager->get_metadata('name')), - )); - - $this->tpl_name = 'acp_ext_details'; - break; - } - - /** - * Event to run after a specific action on extension has completed - * - * @event core.acp_extensions_run_action_after - * @var string action Action that has run - * @var string u_action Url we are at - * @var string ext_name Extension name from request - * @var int safe_time_limit Safe limit of execution time - * @var int start_time Start time - * @var string tpl_name Template file to load - * @since 3.1.11-RC1 - */ - $u_action = $this->u_action; - $tpl_name = $this->tpl_name; - $vars = array('action', 'u_action', 'ext_name', 'safe_time_limit', 'start_time', 'tpl_name'); - extract($this->phpbb_dispatcher->trigger_event('core.acp_extensions_run_action_after', compact($vars))); - - // In case they have been updated by the event - $this->u_action = $u_action; - $this->tpl_name = $tpl_name; - } - - /** - * Lists all the enabled extensions and dumps to the template - * - * @return null - */ - public function list_enabled_exts() - { - $enabled_extension_meta_data = array(); - - foreach ($this->ext_manager->all_enabled() as $name => $location) - { - $md_manager = $this->ext_manager->create_extension_metadata_manager($name); - - try - { - $meta = $md_manager->get_metadata('all'); - $enabled_extension_meta_data[$name] = array( - 'META_DISPLAY_NAME' => $md_manager->get_metadata('display-name'), - 'META_VERSION' => $meta['version'], - ); - - if (isset($meta['extra']['version-check'])) - { - try - { - $force_update = $this->request->variable('versioncheck_force', false); - $updates = $this->ext_manager->version_check($md_manager, $force_update, !$force_update); - - $enabled_extension_meta_data[$name]['S_UP_TO_DATE'] = empty($updates); - $enabled_extension_meta_data[$name]['S_VERSIONCHECK'] = true; - $enabled_extension_meta_data[$name]['U_VERSIONCHECK_FORCE'] = $this->u_action . '&action=details&versioncheck_force=1&ext_name=' . urlencode($md_manager->get_metadata('name')); - } - catch (exception_interface $e) - { - // Ignore exceptions due to the version check - } - } - else - { - $enabled_extension_meta_data[$name]['S_VERSIONCHECK'] = false; - } - } - catch (exception_interface $e) - { - $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters())); - $this->template->assign_block_vars('disabled', array( - 'META_DISPLAY_NAME' => $this->user->lang('EXTENSION_INVALID_LIST', $name, $message), - 'S_VERSIONCHECK' => false, - )); - } - catch (\RuntimeException $e) - { - $enabled_extension_meta_data[$name]['S_VERSIONCHECK'] = false; - } - } - - uasort($enabled_extension_meta_data, array($this, 'sort_extension_meta_data_table')); - - foreach ($enabled_extension_meta_data as $name => $block_vars) - { - $block_vars['NAME'] = $name; - $block_vars['U_DETAILS'] = $this->u_action . '&action=details&ext_name=' . urlencode($name); - - $this->template->assign_block_vars('enabled', $block_vars); - - $this->output_actions('enabled', array( - 'DISABLE' => $this->u_action . '&action=disable_pre&ext_name=' . urlencode($name), - )); - } - } - - /** - * Lists all the disabled extensions and dumps to the template - * - * @return null - */ - public function list_disabled_exts() - { - $disabled_extension_meta_data = array(); - - foreach ($this->ext_manager->all_disabled() as $name => $location) - { - $md_manager = $this->ext_manager->create_extension_metadata_manager($name); - - try - { - $meta = $md_manager->get_metadata('all'); - $disabled_extension_meta_data[$name] = array( - 'META_DISPLAY_NAME' => $md_manager->get_metadata('display-name'), - 'META_VERSION' => $meta['version'], - ); - - if (isset($meta['extra']['version-check'])) - { - $force_update = $this->request->variable('versioncheck_force', false); - $updates = $this->ext_manager->version_check($md_manager, $force_update, !$force_update); - - $disabled_extension_meta_data[$name]['S_UP_TO_DATE'] = empty($updates); - $disabled_extension_meta_data[$name]['S_VERSIONCHECK'] = true; - $disabled_extension_meta_data[$name]['U_VERSIONCHECK_FORCE'] = $this->u_action . '&action=details&versioncheck_force=1&ext_name=' . urlencode($md_manager->get_metadata('name')); - } - else - { - $disabled_extension_meta_data[$name]['S_VERSIONCHECK'] = false; - } - } - catch (version_check_exception $e) - { - $disabled_extension_meta_data[$name]['S_VERSIONCHECK'] = false; - } - catch (exception_interface $e) - { - $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters())); - $this->template->assign_block_vars('disabled', array( - 'META_DISPLAY_NAME' => $this->user->lang('EXTENSION_INVALID_LIST', $name, $message), - 'S_VERSIONCHECK' => false, - )); - } - catch (\RuntimeException $e) - { - $disabled_extension_meta_data[$name]['S_VERSIONCHECK'] = false; - } - } - - uasort($disabled_extension_meta_data, array($this, 'sort_extension_meta_data_table')); - - foreach ($disabled_extension_meta_data as $name => $block_vars) - { - $block_vars['NAME'] = $name; - $block_vars['U_DETAILS'] = $this->u_action . '&action=details&ext_name=' . urlencode($name); - - $this->template->assign_block_vars('disabled', $block_vars); - - $this->output_actions('disabled', array( - 'ENABLE' => $this->u_action . '&action=enable_pre&ext_name=' . urlencode($name), - 'DELETE_DATA' => $this->u_action . '&action=delete_data_pre&ext_name=' . urlencode($name), - )); - } - } - - /** - * Lists all the available extensions and dumps to the template - * - * @return null - */ - public function list_available_exts() - { - $uninstalled = array_diff_key($this->ext_manager->all_available(), $this->ext_manager->all_configured()); - - $available_extension_meta_data = array(); - - foreach ($uninstalled as $name => $location) - { - $md_manager = $this->ext_manager->create_extension_metadata_manager($name); - - try - { - $meta = $md_manager->get_metadata('all'); - $available_extension_meta_data[$name] = array( - 'META_DISPLAY_NAME' => $md_manager->get_metadata('display-name'), - 'META_VERSION' => $meta['version'], - ); - - if (isset($meta['extra']['version-check'])) - { - $force_update = $this->request->variable('versioncheck_force', false); - $updates = $this->ext_manager->version_check($md_manager, $force_update, !$force_update); - - $available_extension_meta_data[$name]['S_UP_TO_DATE'] = empty($updates); - $available_extension_meta_data[$name]['S_VERSIONCHECK'] = true; - $available_extension_meta_data[$name]['U_VERSIONCHECK_FORCE'] = $this->u_action . '&action=details&versioncheck_force=1&ext_name=' . urlencode($md_manager->get_metadata('name')); - } - else - { - $available_extension_meta_data[$name]['S_VERSIONCHECK'] = false; - } - } - catch (version_check_exception $e) - { - $available_extension_meta_data[$name]['S_VERSIONCHECK'] = false; - } - catch (exception_interface $e) - { - $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters())); - $this->template->assign_block_vars('disabled', array( - 'META_DISPLAY_NAME' => $this->user->lang('EXTENSION_INVALID_LIST', $name, $message), - 'S_VERSIONCHECK' => false, - )); - } - } - - uasort($available_extension_meta_data, array($this, 'sort_extension_meta_data_table')); - - foreach ($available_extension_meta_data as $name => $block_vars) - { - $block_vars['NAME'] = $name; - $block_vars['U_DETAILS'] = $this->u_action . '&action=details&ext_name=' . urlencode($name); - - $this->template->assign_block_vars('disabled', $block_vars); - - $this->output_actions('disabled', array( - 'ENABLE' => $this->u_action . '&action=enable_pre&ext_name=' . urlencode($name), - )); - } - } - - /** - * Output actions to a block - * - * @param string $block - * @param array $actions - */ - private function output_actions($block, $actions) - { - foreach ($actions as $lang => $url) - { - $this->template->assign_block_vars($block . '.actions', array( - 'L_ACTION' => $this->user->lang('EXTENSION_' . $lang), - 'L_ACTION_EXPLAIN' => (isset($this->user->lang['EXTENSION_' . $lang . '_EXPLAIN'])) ? $this->user->lang('EXTENSION_' . $lang . '_EXPLAIN') : '', - 'U_ACTION' => $url, - )); - } - } - - /** - * Sort helper for the table containing the metadata about the extensions. - */ - protected function sort_extension_meta_data_table($val1, $val2) - { - return strnatcasecmp($val1['META_DISPLAY_NAME'], $val2['META_DISPLAY_NAME']); - } - - /** - * Outputs extension metadata into the template - * - * @param array $metadata Array with all metadata for the extension - * @return null - */ - public function output_metadata_to_template($metadata) - { - $this->template->assign_vars(array( - 'META_NAME' => $metadata['name'], - 'META_TYPE' => $metadata['type'], - 'META_DESCRIPTION' => (isset($metadata['description'])) ? $metadata['description'] : '', - 'META_HOMEPAGE' => (isset($metadata['homepage'])) ? $metadata['homepage'] : '', - 'META_VERSION' => $metadata['version'], - 'META_TIME' => (isset($metadata['time'])) ? $metadata['time'] : '', - 'META_LICENSE' => $metadata['license'], - - 'META_REQUIRE_PHP' => (isset($metadata['require']['php'])) ? $metadata['require']['php'] : '', - 'META_REQUIRE_PHP_FAIL' => (isset($metadata['require']['php'])) ? false : true, - - 'META_REQUIRE_PHPBB' => (isset($metadata['extra']['soft-require']['phpbb/phpbb'])) ? $metadata['extra']['soft-require']['phpbb/phpbb'] : '', - 'META_REQUIRE_PHPBB_FAIL' => (isset($metadata['extra']['soft-require']['phpbb/phpbb'])) ? false : true, - - 'META_DISPLAY_NAME' => (isset($metadata['extra']['display-name'])) ? $metadata['extra']['display-name'] : '', - )); - - foreach ($metadata['authors'] as $author) - { - $this->template->assign_block_vars('meta_authors', array( - 'AUTHOR_NAME' => $author['name'], - 'AUTHOR_EMAIL' => (isset($author['email'])) ? $author['email'] : '', - 'AUTHOR_HOMEPAGE' => (isset($author['homepage'])) ? $author['homepage'] : '', - 'AUTHOR_ROLE' => (isset($author['role'])) ? $author['role'] : '', - )); - } - } -} diff --git a/install/update/old/includes/acp/acp_forums.php b/install/update/old/includes/acp/acp_forums.php deleted file mode 100644 index be5a7a2..0000000 --- a/install/update/old/includes/acp/acp_forums.php +++ /dev/null @@ -1,2179 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -class acp_forums -{ - var $u_action; - var $parent_id = 0; - - function main($id, $mode) - { - global $db, $user, $auth, $template, $cache, $request, $phpbb_dispatcher; - global $phpbb_admin_path, $phpbb_root_path, $phpEx, $phpbb_log; - - $user->add_lang('acp/forums'); - $this->tpl_name = 'acp_forums'; - $this->page_title = 'ACP_MANAGE_FORUMS'; - - $form_key = 'acp_forums'; - add_form_key($form_key); - - $action = $request->variable('action', ''); - $update = (isset($_POST['update'])) ? true : false; - $forum_id = $request->variable('f', 0); - - $this->parent_id = $request->variable('parent_id', 0); - $forum_data = $errors = array(); - if ($update && !check_form_key($form_key)) - { - $update = false; - $errors[] = $user->lang['FORM_INVALID']; - } - - // Check additional permissions - switch ($action) - { - case 'progress_bar': - $start = $request->variable('start', 0); - $total = $request->variable('total', 0); - - $this->display_progress_bar($start, $total); - break; - - case 'delete': - - if (!$auth->acl_get('a_forumdel')) - { - trigger_error($user->lang['NO_PERMISSION_FORUM_DELETE'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); - } - - break; - - case 'add': - - if (!$auth->acl_get('a_forumadd')) - { - trigger_error($user->lang['NO_PERMISSION_FORUM_ADD'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); - } - - break; - } - - // Major routines - if ($update) - { - switch ($action) - { - case 'delete': - $action_subforums = $request->variable('action_subforums', ''); - $subforums_to_id = $request->variable('subforums_to_id', 0); - $action_posts = $request->variable('action_posts', ''); - $posts_to_id = $request->variable('posts_to_id', 0); - - $errors = $this->delete_forum($forum_id, $action_posts, $action_subforums, $posts_to_id, $subforums_to_id); - - if (count($errors)) - { - break; - } - - $auth->acl_clear_prefetch(); - $cache->destroy('sql', FORUMS_TABLE); - - trigger_error($user->lang['FORUM_DELETED'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id)); - - break; - - case 'edit': - $forum_data = array( - 'forum_id' => $forum_id - ); - - // No break here - - case 'add': - - $forum_data += array( - 'parent_id' => $request->variable('forum_parent_id', $this->parent_id), - 'forum_type' => $request->variable('forum_type', FORUM_POST), - 'type_action' => $request->variable('type_action', ''), - 'forum_status' => $request->variable('forum_status', ITEM_UNLOCKED), - 'forum_parents' => '', - 'forum_name' => $request->variable('forum_name', '', true), - 'forum_link' => $request->variable('forum_link', ''), - 'forum_link_track' => $request->variable('forum_link_track', false), - 'forum_desc' => $request->variable('forum_desc', '', true), - 'forum_desc_uid' => '', - 'forum_desc_options' => 7, - 'forum_desc_bitfield' => '', - 'forum_rules' => $request->variable('forum_rules', '', true), - 'forum_rules_uid' => '', - 'forum_rules_options' => 7, - 'forum_rules_bitfield' => '', - 'forum_rules_link' => $request->variable('forum_rules_link', ''), - 'forum_image' => $request->variable('forum_image', ''), - 'forum_style' => $request->variable('forum_style', 0), - 'display_subforum_list' => $request->variable('display_subforum_list', false), - 'display_on_index' => $request->variable('display_on_index', false), - 'forum_topics_per_page' => $request->variable('topics_per_page', 0), - 'enable_indexing' => $request->variable('enable_indexing', true), - 'enable_icons' => $request->variable('enable_icons', false), - 'enable_prune' => $request->variable('enable_prune', false), - 'enable_post_review' => $request->variable('enable_post_review', true), - 'enable_quick_reply' => $request->variable('enable_quick_reply', false), - 'enable_shadow_prune' => $request->variable('enable_shadow_prune', false), - 'prune_days' => $request->variable('prune_days', 7), - 'prune_viewed' => $request->variable('prune_viewed', 7), - 'prune_freq' => $request->variable('prune_freq', 1), - 'prune_old_polls' => $request->variable('prune_old_polls', false), - 'prune_announce' => $request->variable('prune_announce', false), - 'prune_sticky' => $request->variable('prune_sticky', false), - 'prune_shadow_days' => $request->variable('prune_shadow_days', 7), - 'prune_shadow_freq' => $request->variable('prune_shadow_freq', 1), - 'forum_password' => $request->variable('forum_password', '', true), - 'forum_password_confirm'=> $request->variable('forum_password_confirm', '', true), - 'forum_password_unset' => $request->variable('forum_password_unset', false), - ); - - /** - * Request forum data and operate on it (parse texts, etc.) - * - * @event core.acp_manage_forums_request_data - * @var string action Type of the action: add|edit - * @var array forum_data Array with new forum data - * @since 3.1.0-a1 - */ - $vars = array('action', 'forum_data'); - extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_request_data', compact($vars))); - - // On add, add empty forum_options... else do not consider it (not updating it) - if ($action == 'add') - { - $forum_data['forum_options'] = 0; - } - - // Use link_display_on_index setting if forum type is link - if ($forum_data['forum_type'] == FORUM_LINK) - { - $forum_data['display_on_index'] = $request->variable('link_display_on_index', false); - } - - // Linked forums and categories are not able to be locked... - if ($forum_data['forum_type'] == FORUM_LINK || $forum_data['forum_type'] == FORUM_CAT) - { - $forum_data['forum_status'] = ITEM_UNLOCKED; - } - - $forum_data['show_active'] = ($forum_data['forum_type'] == FORUM_POST) ? $request->variable('display_recent', true) : $request->variable('display_active', false); - - // Get data for forum rules if specified... - if ($forum_data['forum_rules']) - { - generate_text_for_storage($forum_data['forum_rules'], $forum_data['forum_rules_uid'], $forum_data['forum_rules_bitfield'], $forum_data['forum_rules_options'], $request->variable('rules_parse_bbcode', false), $request->variable('rules_parse_urls', false), $request->variable('rules_parse_smilies', false)); - } - - // Get data for forum description if specified - if ($forum_data['forum_desc']) - { - generate_text_for_storage($forum_data['forum_desc'], $forum_data['forum_desc_uid'], $forum_data['forum_desc_bitfield'], $forum_data['forum_desc_options'], $request->variable('desc_parse_bbcode', false), $request->variable('desc_parse_urls', false), $request->variable('desc_parse_smilies', false)); - } - - $errors = $this->update_forum_data($forum_data); - - if (!count($errors)) - { - $forum_perm_from = $request->variable('forum_perm_from', 0); - $cache->destroy('sql', FORUMS_TABLE); - - $copied_permissions = false; - // Copy permissions? - if ($forum_perm_from && $forum_perm_from != $forum_data['forum_id'] && - ($action != 'edit' || empty($forum_id) || ($auth->acl_get('a_fauth') && $auth->acl_get('a_authusers') && $auth->acl_get('a_authgroups') && $auth->acl_get('a_mauth')))) - { - copy_forum_permissions($forum_perm_from, $forum_data['forum_id'], ($action == 'edit') ? true : false); - phpbb_cache_moderators($db, $cache, $auth); - $copied_permissions = true; - } -/* Commented out because of questionable UI workflow - re-visit for 3.0.7 - else if (!$this->parent_id && $action != 'edit' && $auth->acl_get('a_fauth') && $auth->acl_get('a_authusers') && $auth->acl_get('a_authgroups') && $auth->acl_get('a_mauth')) - { - $this->copy_permission_page($forum_data); - return; - } -*/ - $auth->acl_clear_prefetch(); - - $acl_url = '&mode=setting_forum_local&forum_id[]=' . $forum_data['forum_id']; - - $message = ($action == 'add') ? $user->lang['FORUM_CREATED'] : $user->lang['FORUM_UPDATED']; - - // redirect directly to permission settings screen if authed - if ($action == 'add' && !$copied_permissions && $auth->acl_get('a_fauth')) - { - $message .= '

' . sprintf($user->lang['REDIRECT_ACL'], '', ''); - - meta_refresh(4, append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions' . $acl_url)); - } - - trigger_error($message . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id)); - } - - break; - } - } - - switch ($action) - { - case 'move_up': - case 'move_down': - - if (!$forum_id) - { - trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); - } - - $sql = 'SELECT * - FROM ' . FORUMS_TABLE . " - WHERE forum_id = $forum_id"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); - } - - $move_forum_name = $this->move_forum_by($row, $action, 1); - - if ($move_forum_name !== false) - { - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_' . strtoupper($action), false, array($row['forum_name'], $move_forum_name)); - $cache->destroy('sql', FORUMS_TABLE); - } - - if ($request->is_ajax()) - { - $json_response = new \phpbb\json_response; - $json_response->send(array('success' => ($move_forum_name !== false))); - } - - break; - - case 'sync': - if (!$forum_id) - { - trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); - } - - @set_time_limit(0); - - $sql = 'SELECT forum_name, (forum_topics_approved + forum_topics_unapproved + forum_topics_softdeleted) AS total_topics - FROM ' . FORUMS_TABLE . " - WHERE forum_id = $forum_id"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); - } - - if ($row['total_topics']) - { - $sql = 'SELECT MIN(topic_id) as min_topic_id, MAX(topic_id) as max_topic_id - FROM ' . TOPICS_TABLE . ' - WHERE forum_id = ' . $forum_id; - $result = $db->sql_query($sql); - $row2 = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - // Typecast to int if there is no data available - $row2['min_topic_id'] = (int) $row2['min_topic_id']; - $row2['max_topic_id'] = (int) $row2['max_topic_id']; - - $start = $request->variable('start', $row2['min_topic_id']); - - $batch_size = 2000; - $end = $start + $batch_size; - - // Sync all topics in batch mode... - sync('topic', 'range', 'topic_id BETWEEN ' . $start . ' AND ' . $end, true, true); - - if ($end < $row2['max_topic_id']) - { - // We really need to find a way of showing statistics... no progress here - $sql = 'SELECT COUNT(topic_id) as num_topics - FROM ' . TOPICS_TABLE . ' - WHERE forum_id = ' . $forum_id . ' - AND topic_id BETWEEN ' . $start . ' AND ' . $end; - $result = $db->sql_query($sql); - $topics_done = $request->variable('topics_done', 0) + (int) $db->sql_fetchfield('num_topics'); - $db->sql_freeresult($result); - - $start += $batch_size; - - $url = $this->u_action . "&parent_id={$this->parent_id}&f=$forum_id&action=sync&start=$start&topics_done=$topics_done&total={$row['total_topics']}"; - - meta_refresh(0, $url); - - $template->assign_vars(array( - 'U_PROGRESS_BAR' => $this->u_action . "&action=progress_bar&start=$topics_done&total={$row['total_topics']}", - 'UA_PROGRESS_BAR' => addslashes($this->u_action . "&action=progress_bar&start=$topics_done&total={$row['total_topics']}"), - 'S_CONTINUE_SYNC' => true, - 'L_PROGRESS_EXPLAIN' => sprintf($user->lang['SYNC_IN_PROGRESS_EXPLAIN'], $topics_done, $row['total_topics'])) - ); - - return; - } - } - - $url = $this->u_action . "&parent_id={$this->parent_id}&f=$forum_id&action=sync_forum"; - meta_refresh(0, $url); - - $template->assign_vars(array( - 'U_PROGRESS_BAR' => $this->u_action . '&action=progress_bar', - 'UA_PROGRESS_BAR' => addslashes($this->u_action . '&action=progress_bar'), - 'S_CONTINUE_SYNC' => true, - 'L_PROGRESS_EXPLAIN' => sprintf($user->lang['SYNC_IN_PROGRESS_EXPLAIN'], 0, $row['total_topics'])) - ); - - return; - - break; - - case 'sync_forum': - - $sql = 'SELECT forum_name, forum_type - FROM ' . FORUMS_TABLE . " - WHERE forum_id = $forum_id"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); - } - - sync('forum', 'forum_id', $forum_id, false, true); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_SYNC', false, array($row['forum_name'])); - - $cache->destroy('sql', FORUMS_TABLE); - - $template->assign_var('L_FORUM_RESYNCED', sprintf($user->lang['FORUM_RESYNCED'], $row['forum_name'])); - - break; - - case 'add': - case 'edit': - - if ($update) - { - $forum_data['forum_flags'] = 0; - $forum_data['forum_flags'] += ($request->variable('forum_link_track', false)) ? FORUM_FLAG_LINK_TRACK : 0; - $forum_data['forum_flags'] += ($request->variable('prune_old_polls', false)) ? FORUM_FLAG_PRUNE_POLL : 0; - $forum_data['forum_flags'] += ($request->variable('prune_announce', false)) ? FORUM_FLAG_PRUNE_ANNOUNCE : 0; - $forum_data['forum_flags'] += ($request->variable('prune_sticky', false)) ? FORUM_FLAG_PRUNE_STICKY : 0; - $forum_data['forum_flags'] += ($forum_data['show_active']) ? FORUM_FLAG_ACTIVE_TOPICS : 0; - $forum_data['forum_flags'] += ($request->variable('enable_post_review', true)) ? FORUM_FLAG_POST_REVIEW : 0; - $forum_data['forum_flags'] += ($request->variable('enable_quick_reply', false)) ? FORUM_FLAG_QUICK_REPLY : 0; - } - - // Initialise $row, so we always have it in the event - $row = array(); - - // Show form to create/modify a forum - if ($action == 'edit') - { - $this->page_title = 'EDIT_FORUM'; - $row = $this->get_forum_info($forum_id); - $old_forum_type = $row['forum_type']; - - if (!$update) - { - $forum_data = $row; - } - else - { - $forum_data['left_id'] = $row['left_id']; - $forum_data['right_id'] = $row['right_id']; - } - - // Make sure no direct child forums are able to be selected as parents. - $exclude_forums = array(); - foreach (get_forum_branch($forum_id, 'children') as $row) - { - $exclude_forums[] = $row['forum_id']; - } - - $parents_list = make_forum_select($forum_data['parent_id'], $exclude_forums, false, false, false); - - $forum_data['forum_password_confirm'] = $forum_data['forum_password']; - } - else - { - $this->page_title = 'CREATE_FORUM'; - - $forum_id = $this->parent_id; - $parents_list = make_forum_select($this->parent_id, false, false, false, false); - - // Fill forum data with default values - if (!$update) - { - $forum_data = array( - 'parent_id' => $this->parent_id, - 'forum_type' => FORUM_POST, - 'forum_status' => ITEM_UNLOCKED, - 'forum_name' => $request->variable('forum_name', '', true), - 'forum_link' => '', - 'forum_link_track' => false, - 'forum_desc' => '', - 'forum_rules' => '', - 'forum_rules_link' => '', - 'forum_image' => '', - 'forum_style' => 0, - 'display_subforum_list' => true, - 'display_on_index' => false, - 'forum_topics_per_page' => 0, - 'enable_indexing' => true, - 'enable_icons' => false, - 'enable_prune' => false, - 'prune_days' => 7, - 'prune_viewed' => 7, - 'prune_freq' => 1, - 'enable_shadow_prune' => false, - 'prune_shadow_days' => 7, - 'prune_shadow_freq' => 1, - 'forum_flags' => FORUM_FLAG_POST_REVIEW + FORUM_FLAG_ACTIVE_TOPICS, - 'forum_options' => 0, - 'forum_password' => '', - 'forum_password_confirm'=> '', - ); - } - } - - /** - * Initialise data before we display the add/edit form - * - * @event core.acp_manage_forums_initialise_data - * @var string action Type of the action: add|edit - * @var bool update Do we display the form only - * or did the user press submit - * @var int forum_id When editing: the forum id, - * when creating: the parent forum id - * @var array row Array with current forum data - * empty when creating new forum - * @var array forum_data Array with new forum data - * @var string parents_list List of parent options - * @since 3.1.0-a1 - */ - $vars = array('action', 'update', 'forum_id', 'row', 'forum_data', 'parents_list'); - extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_initialise_data', compact($vars))); - - $forum_rules_data = array( - 'text' => $forum_data['forum_rules'], - 'allow_bbcode' => true, - 'allow_smilies' => true, - 'allow_urls' => true - ); - - $forum_desc_data = array( - 'text' => $forum_data['forum_desc'], - 'allow_bbcode' => true, - 'allow_smilies' => true, - 'allow_urls' => true - ); - - $forum_rules_preview = ''; - - // Parse rules if specified - if ($forum_data['forum_rules']) - { - if (!isset($forum_data['forum_rules_uid'])) - { - // Before we are able to display the preview and plane text, we need to parse our $request->variable()'d value... - $forum_data['forum_rules_uid'] = ''; - $forum_data['forum_rules_bitfield'] = ''; - $forum_data['forum_rules_options'] = 0; - - generate_text_for_storage($forum_data['forum_rules'], $forum_data['forum_rules_uid'], $forum_data['forum_rules_bitfield'], $forum_data['forum_rules_options'], $request->variable('rules_allow_bbcode', false), $request->variable('rules_allow_urls', false), $request->variable('rules_allow_smilies', false)); - } - - // Generate preview content - $forum_rules_preview = generate_text_for_display($forum_data['forum_rules'], $forum_data['forum_rules_uid'], $forum_data['forum_rules_bitfield'], $forum_data['forum_rules_options']); - - // decode... - $forum_rules_data = generate_text_for_edit($forum_data['forum_rules'], $forum_data['forum_rules_uid'], $forum_data['forum_rules_options']); - } - - // Parse desciption if specified - if ($forum_data['forum_desc']) - { - if (!isset($forum_data['forum_desc_uid'])) - { - // Before we are able to display the preview and plane text, we need to parse our $request->variable()'d value... - $forum_data['forum_desc_uid'] = ''; - $forum_data['forum_desc_bitfield'] = ''; - $forum_data['forum_desc_options'] = 0; - - generate_text_for_storage($forum_data['forum_desc'], $forum_data['forum_desc_uid'], $forum_data['forum_desc_bitfield'], $forum_data['forum_desc_options'], $request->variable('desc_allow_bbcode', false), $request->variable('desc_allow_urls', false), $request->variable('desc_allow_smilies', false)); - } - - // decode... - $forum_desc_data = generate_text_for_edit($forum_data['forum_desc'], $forum_data['forum_desc_uid'], $forum_data['forum_desc_options']); - } - - $forum_type_options = ''; - $forum_type_ary = array(FORUM_CAT => 'CAT', FORUM_POST => 'FORUM', FORUM_LINK => 'LINK'); - - foreach ($forum_type_ary as $value => $lang) - { - $forum_type_options .= ''; - } - - $styles_list = style_select($forum_data['forum_style'], true); - - $statuslist = ''; - - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE . ' - WHERE forum_type = ' . FORUM_POST . " - AND forum_id <> $forum_id"; - $result = $db->sql_query_limit($sql, 1); - - $postable_forum_exists = false; - if ($db->sql_fetchrow($result)) - { - $postable_forum_exists = true; - } - $db->sql_freeresult($result); - - // Subforum move options - if ($action == 'edit' && $forum_data['forum_type'] == FORUM_CAT) - { - $subforums_id = array(); - $subforums = get_forum_branch($forum_id, 'children'); - - foreach ($subforums as $row) - { - $subforums_id[] = $row['forum_id']; - } - - $forums_list = make_forum_select($forum_data['parent_id'], $subforums_id); - - if ($postable_forum_exists) - { - $template->assign_vars(array( - 'S_MOVE_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $subforums_id)) // , false, true, false??? - ); - } - - $template->assign_vars(array( - 'S_HAS_SUBFORUMS' => ($forum_data['right_id'] - $forum_data['left_id'] > 1) ? true : false, - 'S_FORUMS_LIST' => $forums_list) - ); - } - else if ($postable_forum_exists) - { - $template->assign_vars(array( - 'S_MOVE_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $forum_id, false, true, false)) - ); - } - - $s_show_display_on_index = false; - - if ($forum_data['parent_id'] > 0) - { - // if this forum is a subforum put the "display on index" checkbox - if ($parent_info = $this->get_forum_info($forum_data['parent_id'])) - { - if ($parent_info['parent_id'] > 0 || $parent_info['forum_type'] == FORUM_CAT) - { - $s_show_display_on_index = true; - } - } - } - - if (strlen($forum_data['forum_password']) == 32) - { - $errors[] = $user->lang['FORUM_PASSWORD_OLD']; - } - - $template_data = array( - 'S_EDIT_FORUM' => true, - 'S_ERROR' => (count($errors)) ? true : false, - 'S_PARENT_ID' => $this->parent_id, - 'S_FORUM_PARENT_ID' => $forum_data['parent_id'], - 'S_ADD_ACTION' => ($action == 'add') ? true : false, - - 'U_BACK' => $this->u_action . '&parent_id=' . $this->parent_id, - 'U_EDIT_ACTION' => $this->u_action . "&parent_id={$this->parent_id}&action=$action&f=$forum_id", - - 'L_COPY_PERMISSIONS_EXPLAIN' => $user->lang['COPY_PERMISSIONS_' . strtoupper($action) . '_EXPLAIN'], - 'L_TITLE' => $user->lang[$this->page_title], - 'ERROR_MSG' => (count($errors)) ? implode('
', $errors) : '', - - 'FORUM_NAME' => $forum_data['forum_name'], - 'FORUM_DATA_LINK' => $forum_data['forum_link'], - 'FORUM_IMAGE' => $forum_data['forum_image'], - 'FORUM_IMAGE_SRC' => ($forum_data['forum_image']) ? $phpbb_root_path . $forum_data['forum_image'] : '', - 'FORUM_POST' => FORUM_POST, - 'FORUM_LINK' => FORUM_LINK, - 'FORUM_CAT' => FORUM_CAT, - 'PRUNE_FREQ' => $forum_data['prune_freq'], - 'PRUNE_DAYS' => $forum_data['prune_days'], - 'PRUNE_VIEWED' => $forum_data['prune_viewed'], - 'PRUNE_SHADOW_FREQ' => $forum_data['prune_shadow_freq'], - 'PRUNE_SHADOW_DAYS' => $forum_data['prune_shadow_days'], - 'TOPICS_PER_PAGE' => $forum_data['forum_topics_per_page'], - 'FORUM_RULES_LINK' => $forum_data['forum_rules_link'], - 'FORUM_RULES' => $forum_data['forum_rules'], - 'FORUM_RULES_PREVIEW' => $forum_rules_preview, - 'FORUM_RULES_PLAIN' => $forum_rules_data['text'], - 'S_BBCODE_CHECKED' => ($forum_rules_data['allow_bbcode']) ? true : false, - 'S_SMILIES_CHECKED' => ($forum_rules_data['allow_smilies']) ? true : false, - 'S_URLS_CHECKED' => ($forum_rules_data['allow_urls']) ? true : false, - 'S_FORUM_PASSWORD_SET' => (empty($forum_data['forum_password'])) ? false : true, - - 'FORUM_DESC' => $forum_desc_data['text'], - 'S_DESC_BBCODE_CHECKED' => ($forum_desc_data['allow_bbcode']) ? true : false, - 'S_DESC_SMILIES_CHECKED' => ($forum_desc_data['allow_smilies']) ? true : false, - 'S_DESC_URLS_CHECKED' => ($forum_desc_data['allow_urls']) ? true : false, - - 'S_FORUM_TYPE_OPTIONS' => $forum_type_options, - 'S_STATUS_OPTIONS' => $statuslist, - 'S_PARENT_OPTIONS' => $parents_list, - 'S_STYLES_OPTIONS' => $styles_list, - 'S_FORUM_OPTIONS' => make_forum_select(($action == 'add') ? $forum_data['parent_id'] : false, ($action == 'edit') ? $forum_data['forum_id'] : false, false, false, false), - 'S_SHOW_DISPLAY_ON_INDEX' => $s_show_display_on_index, - 'S_FORUM_POST' => ($forum_data['forum_type'] == FORUM_POST) ? true : false, - 'S_FORUM_ORIG_POST' => (isset($old_forum_type) && $old_forum_type == FORUM_POST) ? true : false, - 'S_FORUM_ORIG_CAT' => (isset($old_forum_type) && $old_forum_type == FORUM_CAT) ? true : false, - 'S_FORUM_ORIG_LINK' => (isset($old_forum_type) && $old_forum_type == FORUM_LINK) ? true : false, - 'S_FORUM_LINK' => ($forum_data['forum_type'] == FORUM_LINK) ? true : false, - 'S_FORUM_CAT' => ($forum_data['forum_type'] == FORUM_CAT) ? true : false, - 'S_ENABLE_INDEXING' => ($forum_data['enable_indexing']) ? true : false, - 'S_TOPIC_ICONS' => ($forum_data['enable_icons']) ? true : false, - 'S_DISPLAY_SUBFORUM_LIST' => ($forum_data['display_subforum_list']) ? true : false, - 'S_DISPLAY_ON_INDEX' => ($forum_data['display_on_index']) ? true : false, - 'S_PRUNE_ENABLE' => ($forum_data['enable_prune']) ? true : false, - 'S_PRUNE_SHADOW_ENABLE' => ($forum_data['enable_shadow_prune']) ? true : false, - 'S_FORUM_LINK_TRACK' => ($forum_data['forum_flags'] & FORUM_FLAG_LINK_TRACK) ? true : false, - 'S_PRUNE_OLD_POLLS' => ($forum_data['forum_flags'] & FORUM_FLAG_PRUNE_POLL) ? true : false, - 'S_PRUNE_ANNOUNCE' => ($forum_data['forum_flags'] & FORUM_FLAG_PRUNE_ANNOUNCE) ? true : false, - 'S_PRUNE_STICKY' => ($forum_data['forum_flags'] & FORUM_FLAG_PRUNE_STICKY) ? true : false, - 'S_DISPLAY_ACTIVE_TOPICS' => ($forum_data['forum_type'] == FORUM_POST) ? ($forum_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS) : true, - 'S_ENABLE_ACTIVE_TOPICS' => ($forum_data['forum_type'] == FORUM_CAT) ? ($forum_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS) : false, - 'S_ENABLE_POST_REVIEW' => ($forum_data['forum_flags'] & FORUM_FLAG_POST_REVIEW) ? true : false, - 'S_ENABLE_QUICK_REPLY' => ($forum_data['forum_flags'] & FORUM_FLAG_QUICK_REPLY) ? true : false, - 'S_CAN_COPY_PERMISSIONS' => ($action != 'edit' || empty($forum_id) || ($auth->acl_get('a_fauth') && $auth->acl_get('a_authusers') && $auth->acl_get('a_authgroups') && $auth->acl_get('a_mauth'))) ? true : false, - ); - - /** - * Modify forum template data before we display the form - * - * @event core.acp_manage_forums_display_form - * @var string action Type of the action: add|edit - * @var bool update Do we display the form only - * or did the user press submit - * @var int forum_id When editing: the forum id, - * when creating: the parent forum id - * @var array row Array with current forum data - * empty when creating new forum - * @var array forum_data Array with new forum data - * @var string parents_list List of parent options - * @var array errors Array of errors, if you add errors - * ensure to update the template variables - * S_ERROR and ERROR_MSG to display it - * @var array template_data Array with new forum data - * @since 3.1.0-a1 - */ - $vars = array( - 'action', - 'update', - 'forum_id', - 'row', - 'forum_data', - 'parents_list', - 'errors', - 'template_data', - ); - extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_display_form', compact($vars))); - - $template->assign_vars($template_data); - - return; - - break; - - case 'delete': - - if (!$forum_id) - { - trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); - } - - $forum_data = $this->get_forum_info($forum_id); - - $subforums_id = array(); - $subforums = get_forum_branch($forum_id, 'children'); - - foreach ($subforums as $row) - { - $subforums_id[] = $row['forum_id']; - } - - $forums_list = make_forum_select($forum_data['parent_id'], $subforums_id); - - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE . ' - WHERE forum_type = ' . FORUM_POST . " - AND forum_id <> $forum_id"; - $result = $db->sql_query_limit($sql, 1); - - if ($db->sql_fetchrow($result)) - { - $template->assign_vars(array( - 'S_MOVE_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $subforums_id, false, true)) // , false, true, false??? - ); - } - $db->sql_freeresult($result); - - $parent_id = ($this->parent_id == $forum_id) ? 0 : $this->parent_id; - - $template->assign_vars(array( - 'S_DELETE_FORUM' => true, - 'U_ACTION' => $this->u_action . "&parent_id={$parent_id}&action=delete&f=$forum_id", - 'U_BACK' => $this->u_action . '&parent_id=' . $this->parent_id, - - 'FORUM_NAME' => $forum_data['forum_name'], - 'S_FORUM_POST' => ($forum_data['forum_type'] == FORUM_POST) ? true : false, - 'S_FORUM_LINK' => ($forum_data['forum_type'] == FORUM_LINK) ? true : false, - 'S_HAS_SUBFORUMS' => ($forum_data['right_id'] - $forum_data['left_id'] > 1) ? true : false, - 'S_FORUMS_LIST' => $forums_list, - 'S_ERROR' => (count($errors)) ? true : false, - 'ERROR_MSG' => (count($errors)) ? implode('
', $errors) : '') - ); - - return; - break; - - case 'copy_perm': - $forum_perm_from = $request->variable('forum_perm_from', 0); - - // Copy permissions? - if (!empty($forum_perm_from) && $forum_perm_from != $forum_id) - { - copy_forum_permissions($forum_perm_from, $forum_id, true); - phpbb_cache_moderators($db, $cache, $auth); - $auth->acl_clear_prefetch(); - $cache->destroy('sql', FORUMS_TABLE); - - $acl_url = '&mode=setting_forum_local&forum_id[]=' . $forum_id; - - $message = $user->lang['FORUM_UPDATED']; - - // Redirect to permissions - if ($auth->acl_get('a_fauth')) - { - $message .= '

' . sprintf($user->lang['REDIRECT_ACL'], '', ''); - } - - trigger_error($message . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id)); - } - - break; - } - - // Default management page - if (!$this->parent_id) - { - $navigation = $user->lang['FORUM_INDEX']; - } - else - { - $navigation = '' . $user->lang['FORUM_INDEX'] . ''; - - $forums_nav = get_forum_branch($this->parent_id, 'parents', 'descending'); - foreach ($forums_nav as $row) - { - if ($row['forum_id'] == $this->parent_id) - { - $navigation .= ' -> ' . $row['forum_name']; - } - else - { - $navigation .= ' -> ' . $row['forum_name'] . ''; - } - } - } - - // Jumpbox - $forum_box = make_forum_select($this->parent_id, false, false, false, false); //make_forum_select($this->parent_id); - - if ($action == 'sync' || $action == 'sync_forum') - { - $template->assign_var('S_RESYNCED', true); - } - - $sql = 'SELECT * - FROM ' . FORUMS_TABLE . " - WHERE parent_id = $this->parent_id - ORDER BY left_id"; - $result = $db->sql_query($sql); - - $rowset = array(); - while ($row = $db->sql_fetchrow($result)) - { - $rowset[(int) $row['forum_id']] = $row; - } - $db->sql_freeresult($result); - - /** - * Modify the forum list data - * - * @event core.acp_manage_forums_modify_forum_list - * @var array rowset Array with the forums list data - * @since 3.1.10-RC1 - */ - $vars = array('rowset'); - extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_modify_forum_list', compact($vars))); - - if (!empty($rowset)) - { - foreach ($rowset as $row) - { - $forum_type = $row['forum_type']; - - if ($row['forum_status'] == ITEM_LOCKED) - { - $folder_image = '' . $user->lang['LOCKED'] . ''; - } - else - { - switch ($forum_type) - { - case FORUM_LINK: - $folder_image = '' . $user->lang['LINK'] . ''; - break; - - default: - $folder_image = ($row['left_id'] + 1 != $row['right_id']) ? '' . $user->lang['SUBFORUM'] . '' : '' . $user->lang['FOLDER'] . ''; - break; - } - } - - $url = $this->u_action . "&parent_id=$this->parent_id&f={$row['forum_id']}"; - - $template->assign_block_vars('forums', array( - 'FOLDER_IMAGE' => $folder_image, - 'FORUM_IMAGE' => ($row['forum_image']) ? '' : '', - 'FORUM_IMAGE_SRC' => ($row['forum_image']) ? $phpbb_root_path . $row['forum_image'] : '', - 'FORUM_NAME' => $row['forum_name'], - 'FORUM_DESCRIPTION' => generate_text_for_display($row['forum_desc'], $row['forum_desc_uid'], $row['forum_desc_bitfield'], $row['forum_desc_options']), - 'FORUM_TOPICS' => $row['forum_topics_approved'], - 'FORUM_POSTS' => $row['forum_posts_approved'], - - 'S_FORUM_LINK' => ($forum_type == FORUM_LINK) ? true : false, - 'S_FORUM_POST' => ($forum_type == FORUM_POST) ? true : false, - - 'U_FORUM' => $this->u_action . '&parent_id=' . $row['forum_id'], - 'U_MOVE_UP' => $url . '&action=move_up', - 'U_MOVE_DOWN' => $url . '&action=move_down', - 'U_EDIT' => $url . '&action=edit', - 'U_DELETE' => $url . '&action=delete', - 'U_SYNC' => $url . '&action=sync') - ); - } - } - else if ($this->parent_id) - { - $row = $this->get_forum_info($this->parent_id); - - $url = $this->u_action . '&parent_id=' . $this->parent_id . '&f=' . $row['forum_id']; - - $template->assign_vars(array( - 'S_NO_FORUMS' => true, - - 'U_EDIT' => $url . '&action=edit', - 'U_DELETE' => $url . '&action=delete', - 'U_SYNC' => $url . '&action=sync') - ); - } - unset($rowset); - - $template->assign_vars(array( - 'ERROR_MSG' => (count($errors)) ? implode('
', $errors) : '', - 'NAVIGATION' => $navigation, - 'FORUM_BOX' => $forum_box, - 'U_SEL_ACTION' => $this->u_action, - 'U_ACTION' => $this->u_action . '&parent_id=' . $this->parent_id, - - 'U_PROGRESS_BAR' => $this->u_action . '&action=progress_bar', - 'UA_PROGRESS_BAR' => addslashes($this->u_action . '&action=progress_bar'), - )); - } - - /** - * Get forum details - */ - function get_forum_info($forum_id) - { - global $db; - - $sql = 'SELECT * - FROM ' . FORUMS_TABLE . " - WHERE forum_id = $forum_id"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - trigger_error("Forum #$forum_id does not exist", E_USER_ERROR); - } - - return $row; - } - - /** - * Update forum data - */ - function update_forum_data(&$forum_data_ary) - { - global $db, $user, $cache, $phpbb_root_path, $phpbb_container, $phpbb_dispatcher, $phpbb_log, $request; - - $errors = array(); - - $forum_data = $forum_data_ary; - /** - * Validate the forum data before we create/update the forum - * - * @event core.acp_manage_forums_validate_data - * @var array forum_data Array with new forum data - * @var array errors Array of errors, should be strings and not - * language key. - * @since 3.1.0-a1 - */ - $vars = array('forum_data', 'errors'); - extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_validate_data', compact($vars))); - $forum_data_ary = $forum_data; - unset($forum_data); - - if ($forum_data_ary['forum_name'] == '') - { - $errors[] = $user->lang['FORUM_NAME_EMPTY']; - } - - if (utf8_strlen($forum_data_ary['forum_desc']) > 4000) - { - $errors[] = $user->lang['FORUM_DESC_TOO_LONG']; - } - - if (utf8_strlen($forum_data_ary['forum_rules']) > 4000) - { - $errors[] = $user->lang['FORUM_RULES_TOO_LONG']; - } - - if ($forum_data_ary['forum_password'] || $forum_data_ary['forum_password_confirm']) - { - if ($forum_data_ary['forum_password'] != $forum_data_ary['forum_password_confirm']) - { - $forum_data_ary['forum_password'] = $forum_data_ary['forum_password_confirm'] = ''; - $errors[] = $user->lang['FORUM_PASSWORD_MISMATCH']; - } - } - - if ($forum_data_ary['prune_days'] < 0 || $forum_data_ary['prune_viewed'] < 0 || $forum_data_ary['prune_freq'] < 0) - { - $forum_data_ary['prune_days'] = $forum_data_ary['prune_viewed'] = $forum_data_ary['prune_freq'] = 0; - $errors[] = $user->lang['FORUM_DATA_NEGATIVE']; - } - - $range_test_ary = array( - array('lang' => 'FORUM_TOPICS_PAGE', 'value' => $forum_data_ary['forum_topics_per_page'], 'column_type' => 'USINT:0'), - ); - - if (!empty($forum_data_ary['forum_image']) && !file_exists($phpbb_root_path . $forum_data_ary['forum_image'])) - { - $errors[] = $user->lang['FORUM_IMAGE_NO_EXIST']; - } - - validate_range($range_test_ary, $errors); - - // Set forum flags - // 1 = link tracking - // 2 = prune old polls - // 4 = prune announcements - // 8 = prune stickies - // 16 = show active topics - // 32 = enable post review - $forum_data_ary['forum_flags'] = 0; - $forum_data_ary['forum_flags'] += ($forum_data_ary['forum_link_track']) ? FORUM_FLAG_LINK_TRACK : 0; - $forum_data_ary['forum_flags'] += ($forum_data_ary['prune_old_polls']) ? FORUM_FLAG_PRUNE_POLL : 0; - $forum_data_ary['forum_flags'] += ($forum_data_ary['prune_announce']) ? FORUM_FLAG_PRUNE_ANNOUNCE : 0; - $forum_data_ary['forum_flags'] += ($forum_data_ary['prune_sticky']) ? FORUM_FLAG_PRUNE_STICKY : 0; - $forum_data_ary['forum_flags'] += ($forum_data_ary['show_active']) ? FORUM_FLAG_ACTIVE_TOPICS : 0; - $forum_data_ary['forum_flags'] += ($forum_data_ary['enable_post_review']) ? FORUM_FLAG_POST_REVIEW : 0; - $forum_data_ary['forum_flags'] += ($forum_data_ary['enable_quick_reply']) ? FORUM_FLAG_QUICK_REPLY : 0; - - // Unset data that are not database fields - $forum_data_sql = $forum_data_ary; - - unset($forum_data_sql['forum_link_track']); - unset($forum_data_sql['prune_old_polls']); - unset($forum_data_sql['prune_announce']); - unset($forum_data_sql['prune_sticky']); - unset($forum_data_sql['show_active']); - unset($forum_data_sql['enable_post_review']); - unset($forum_data_sql['enable_quick_reply']); - unset($forum_data_sql['forum_password_confirm']); - - // What are we going to do tonight Brain? The same thing we do everynight, - // try to take over the world ... or decide whether to continue update - // and if so, whether it's a new forum/cat/link or an existing one - if (count($errors)) - { - return $errors; - } - - // As we don't know the old password, it's kinda tricky to detect changes - if ($forum_data_sql['forum_password_unset']) - { - $forum_data_sql['forum_password'] = ''; - } - else if (empty($forum_data_sql['forum_password'])) - { - unset($forum_data_sql['forum_password']); - } - else - { - // Instantiate passwords manager - /* @var $passwords_manager \phpbb\passwords\manager */ - $passwords_manager = $phpbb_container->get('passwords.manager'); - - $forum_data_sql['forum_password'] = $passwords_manager->hash($forum_data_sql['forum_password']); - } - unset($forum_data_sql['forum_password_unset']); - - $forum_data = $forum_data_ary; - /** - * Remove invalid values from forum_data_sql that should not be updated - * - * @event core.acp_manage_forums_update_data_before - * @var array forum_data Array with forum data - * @var array forum_data_sql Array with data we are going to update - * If forum_data_sql[forum_id] is set, we update - * that forum, otherwise a new one is created. - * @since 3.1.0-a1 - */ - $vars = array('forum_data', 'forum_data_sql'); - extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_update_data_before', compact($vars))); - $forum_data_ary = $forum_data; - unset($forum_data); - - $is_new_forum = !isset($forum_data_sql['forum_id']); - - if ($is_new_forum) - { - // no forum_id means we're creating a new forum - unset($forum_data_sql['type_action']); - - if ($forum_data_sql['parent_id']) - { - $sql = 'SELECT left_id, right_id, forum_type - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . $forum_data_sql['parent_id']; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - trigger_error($user->lang['PARENT_NOT_EXIST'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); - } - - if ($row['forum_type'] == FORUM_LINK) - { - $errors[] = $user->lang['PARENT_IS_LINK_FORUM']; - return $errors; - } - - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET left_id = left_id + 2, right_id = right_id + 2 - WHERE left_id > ' . $row['right_id']; - $db->sql_query($sql); - - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET right_id = right_id + 2 - WHERE ' . $row['left_id'] . ' BETWEEN left_id AND right_id'; - $db->sql_query($sql); - - $forum_data_sql['left_id'] = $row['right_id']; - $forum_data_sql['right_id'] = $row['right_id'] + 1; - } - else - { - $sql = 'SELECT MAX(right_id) AS right_id - FROM ' . FORUMS_TABLE; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $forum_data_sql['left_id'] = $row['right_id'] + 1; - $forum_data_sql['right_id'] = $row['right_id'] + 2; - } - - $sql = 'INSERT INTO ' . FORUMS_TABLE . ' ' . $db->sql_build_array('INSERT', $forum_data_sql); - $db->sql_query($sql); - - $forum_data_ary['forum_id'] = $db->sql_nextid(); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_ADD', false, array($forum_data_ary['forum_name'])); - } - else - { - $row = $this->get_forum_info($forum_data_sql['forum_id']); - - if ($row['forum_type'] == FORUM_POST && $row['forum_type'] != $forum_data_sql['forum_type']) - { - // Has subforums and want to change into a link? - if ($row['right_id'] - $row['left_id'] > 1 && $forum_data_sql['forum_type'] == FORUM_LINK) - { - $errors[] = $user->lang['FORUM_WITH_SUBFORUMS_NOT_TO_LINK']; - return $errors; - } - - // we're turning a postable forum into a non-postable forum - if ($forum_data_sql['type_action'] == 'move') - { - $to_forum_id = $request->variable('to_forum_id', 0); - - if ($to_forum_id) - { - $errors = $this->move_forum_content($forum_data_sql['forum_id'], $to_forum_id); - } - else - { - return array($user->lang['NO_DESTINATION_FORUM']); - } - } - else if ($forum_data_sql['type_action'] == 'delete') - { - $errors = $this->delete_forum_content($forum_data_sql['forum_id']); - } - else - { - return array($user->lang['NO_FORUM_ACTION']); - } - - $forum_data_sql['forum_posts_approved'] = $forum_data_sql['forum_posts_unapproved'] = $forum_data_sql['forum_posts_softdeleted'] = $forum_data_sql['forum_topics_approved'] = $forum_data_sql['forum_topics_unapproved'] = $forum_data_sql['forum_topics_softdeleted'] = 0; - $forum_data_sql['forum_last_post_id'] = $forum_data_sql['forum_last_poster_id'] = $forum_data_sql['forum_last_post_time'] = 0; - $forum_data_sql['forum_last_poster_name'] = $forum_data_sql['forum_last_poster_colour'] = ''; - } - else if ($row['forum_type'] == FORUM_CAT && $forum_data_sql['forum_type'] == FORUM_LINK) - { - // Has subforums? - if ($row['right_id'] - $row['left_id'] > 1) - { - // We are turning a category into a link - but need to decide what to do with the subforums. - $action_subforums = $request->variable('action_subforums', ''); - $subforums_to_id = $request->variable('subforums_to_id', 0); - - if ($action_subforums == 'delete') - { - $rows = get_forum_branch($row['forum_id'], 'children', 'descending', false); - - foreach ($rows as $_row) - { - // Do not remove the forum id we are about to change. ;) - if ($_row['forum_id'] == $row['forum_id']) - { - continue; - } - - $forum_ids[] = $_row['forum_id']; - $errors = array_merge($errors, $this->delete_forum_content($_row['forum_id'])); - } - - if (count($errors)) - { - return $errors; - } - - if (count($forum_ids)) - { - $sql = 'DELETE FROM ' . FORUMS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $forum_ids); - $db->sql_query($sql); - - $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $forum_ids); - $db->sql_query($sql); - - $sql = 'DELETE FROM ' . ACL_USERS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $forum_ids); - $db->sql_query($sql); - - // Delete forum ids from extension groups table - $sql = 'SELECT group_id, allowed_forums - FROM ' . EXTENSION_GROUPS_TABLE; - $result = $db->sql_query($sql); - - while ($_row = $db->sql_fetchrow($result)) - { - if (!$_row['allowed_forums']) - { - continue; - } - - $allowed_forums = unserialize(trim($_row['allowed_forums'])); - $allowed_forums = array_diff($allowed_forums, $forum_ids); - - $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . " - SET allowed_forums = '" . ((count($allowed_forums)) ? serialize($allowed_forums) : '') . "' - WHERE group_id = {$_row['group_id']}"; - $db->sql_query($sql); - } - $db->sql_freeresult($result); - - $cache->destroy('_extensions'); - } - } - else if ($action_subforums == 'move') - { - if (!$subforums_to_id) - { - return array($user->lang['NO_DESTINATION_FORUM']); - } - - $sql = 'SELECT forum_name - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . $subforums_to_id; - $result = $db->sql_query($sql); - $_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$_row) - { - return array($user->lang['NO_FORUM']); - } - - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE . " - WHERE parent_id = {$row['forum_id']}"; - $result = $db->sql_query($sql); - - while ($_row = $db->sql_fetchrow($result)) - { - $this->move_forum($_row['forum_id'], $subforums_to_id); - } - $db->sql_freeresult($result); - - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET parent_id = $subforums_to_id - WHERE parent_id = {$row['forum_id']}"; - $db->sql_query($sql); - } - - // Adjust the left/right id - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET right_id = left_id + 1 - WHERE forum_id = ' . $row['forum_id']; - $db->sql_query($sql); - } - } - else if ($row['forum_type'] == FORUM_CAT && $forum_data_sql['forum_type'] == FORUM_POST) - { - // Changing a category to a forum? Reset the data (you can't post directly in a cat, you must use a forum) - $forum_data_sql['forum_posts_approved'] = 0; - $forum_data_sql['forum_posts_unapproved'] = 0; - $forum_data_sql['forum_posts_softdeleted'] = 0; - $forum_data_sql['forum_topics_approved'] = 0; - $forum_data_sql['forum_topics_unapproved'] = 0; - $forum_data_sql['forum_topics_softdeleted'] = 0; - $forum_data_sql['forum_last_post_id'] = 0; - $forum_data_sql['forum_last_post_subject'] = ''; - $forum_data_sql['forum_last_post_time'] = 0; - $forum_data_sql['forum_last_poster_id'] = 0; - $forum_data_sql['forum_last_poster_name'] = ''; - $forum_data_sql['forum_last_poster_colour'] = ''; - } - - if (count($errors)) - { - return $errors; - } - - if ($row['parent_id'] != $forum_data_sql['parent_id']) - { - if ($row['forum_id'] != $forum_data_sql['parent_id']) - { - $errors = $this->move_forum($forum_data_sql['forum_id'], $forum_data_sql['parent_id']); - } - else - { - $forum_data_sql['parent_id'] = $row['parent_id']; - } - } - - if (count($errors)) - { - return $errors; - } - - unset($forum_data_sql['type_action']); - - if ($row['forum_name'] != $forum_data_sql['forum_name']) - { - // the forum name has changed, clear the parents list of all forums (for safety) - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET forum_parents = ''"; - $db->sql_query($sql); - } - - // Setting the forum id to the forum id is not really received well by some dbs. ;) - $forum_id = $forum_data_sql['forum_id']; - unset($forum_data_sql['forum_id']); - - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $forum_data_sql) . ' - WHERE forum_id = ' . $forum_id; - $db->sql_query($sql); - - // Add it back - $forum_data_ary['forum_id'] = $forum_id; - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_EDIT', false, array($forum_data_ary['forum_name'])); - } - - $forum_data = $forum_data_ary; - /** - * Event after a forum was updated or created - * - * @event core.acp_manage_forums_update_data_after - * @var array forum_data Array with forum data - * @var array forum_data_sql Array with data we updated - * @var bool is_new_forum Did we create a forum or update one - * If you want to overwrite this value, - * ensure to set forum_data_sql[forum_id] - * @var array errors Array of errors, should be strings and not - * language key. - * @since 3.1.0-a1 - */ - $vars = array('forum_data', 'forum_data_sql', 'is_new_forum', 'errors'); - extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_update_data_after', compact($vars))); - $forum_data_ary = $forum_data; - unset($forum_data); - - return $errors; - } - - /** - * Move forum - */ - function move_forum($from_id, $to_id) - { - global $db, $user, $phpbb_dispatcher; - - $errors = array(); - - // Check if we want to move to a parent with link type - if ($to_id > 0) - { - $to_data = $this->get_forum_info($to_id); - - if ($to_data['forum_type'] == FORUM_LINK) - { - $errors[] = $user->lang['PARENT_IS_LINK_FORUM']; - } - } - - /** - * Event when we move all children of one forum to another - * - * This event may be triggered, when a forum is deleted - * - * @event core.acp_manage_forums_move_children - * @var int from_id If of the current parent forum - * @var int to_id If of the new parent forum - * @var array errors Array of errors, should be strings and not - * language key. - * @since 3.1.0-a1 - */ - $vars = array('from_id', 'to_id', 'errors'); - extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_move_children', compact($vars))); - - // Return if there were errors - if (!empty($errors)) - { - return $errors; - } - - $db->sql_transaction('begin'); - - $moved_forums = get_forum_branch($from_id, 'children', 'descending'); - $from_data = $moved_forums[0]; - $diff = count($moved_forums) * 2; - - $moved_ids = array(); - for ($i = 0, $size = count($moved_forums); $i < $size; ++$i) - { - $moved_ids[] = $moved_forums[$i]['forum_id']; - } - - // Resync parents - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET right_id = right_id - $diff, forum_parents = '' - WHERE left_id < " . $from_data['right_id'] . " - AND right_id > " . $from_data['right_id']; - $db->sql_query($sql); - - // Resync righthand side of tree - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET left_id = left_id - $diff, right_id = right_id - $diff, forum_parents = '' - WHERE left_id > " . $from_data['right_id']; - $db->sql_query($sql); - - if ($to_id > 0) - { - // Retrieve $to_data again, it may have been changed... - $to_data = $this->get_forum_info($to_id); - - // Resync new parents - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET right_id = right_id + $diff, forum_parents = '' - WHERE " . $to_data['right_id'] . ' BETWEEN left_id AND right_id - AND ' . $db->sql_in_set('forum_id', $moved_ids, true); - $db->sql_query($sql); - - // Resync the righthand side of the tree - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET left_id = left_id + $diff, right_id = right_id + $diff, forum_parents = '' - WHERE left_id > " . $to_data['right_id'] . ' - AND ' . $db->sql_in_set('forum_id', $moved_ids, true); - $db->sql_query($sql); - - // Resync moved branch - $to_data['right_id'] += $diff; - - if ($to_data['right_id'] > $from_data['right_id']) - { - $diff = '+ ' . ($to_data['right_id'] - $from_data['right_id'] - 1); - } - else - { - $diff = '- ' . abs($to_data['right_id'] - $from_data['right_id'] - 1); - } - } - else - { - $sql = 'SELECT MAX(right_id) AS right_id - FROM ' . FORUMS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $moved_ids, true); - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $diff = '+ ' . ($row['right_id'] - $from_data['left_id'] + 1); - } - - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET left_id = left_id $diff, right_id = right_id $diff, forum_parents = '' - WHERE " . $db->sql_in_set('forum_id', $moved_ids); - $db->sql_query($sql); - - $db->sql_transaction('commit'); - - return $errors; - } - - /** - * Move forum content from one to another forum - */ - function move_forum_content($from_id, $to_id, $sync = true) - { - global $db, $phpbb_dispatcher; - - $errors = array(); - - /** - * Event when we move content from one forum to another - * - * @event core.acp_manage_forums_move_content - * @var int from_id If of the current parent forum - * @var int to_id If of the new parent forum - * @var bool sync Shall we sync the "to"-forum's data - * @var array errors Array of errors, should be strings and not - * language key. If this array is not empty, - * The content will not be moved. - * @since 3.1.0-a1 - */ - $vars = array('from_id', 'to_id', 'sync', 'errors'); - extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_move_content', compact($vars))); - - // Return if there were errors - if (!empty($errors)) - { - return $errors; - } - - $table_ary = array(LOG_TABLE, POSTS_TABLE, TOPICS_TABLE, DRAFTS_TABLE, TOPICS_TRACK_TABLE); - - /** - * Perform additional actions before move forum content - * - * @event core.acp_manage_forums_move_content_sql_before - * @var array table_ary Array of tables from which forum_id will be updated - * @since 3.2.4-RC1 - */ - $vars = array('table_ary'); - extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_move_content_sql_before', compact($vars))); - - foreach ($table_ary as $table) - { - $sql = "UPDATE $table - SET forum_id = $to_id - WHERE forum_id = $from_id"; - $db->sql_query($sql); - } - unset($table_ary); - - $table_ary = array(FORUMS_ACCESS_TABLE, FORUMS_TRACK_TABLE, FORUMS_WATCH_TABLE, MODERATOR_CACHE_TABLE); - - foreach ($table_ary as $table) - { - $sql = "DELETE FROM $table - WHERE forum_id = $from_id"; - $db->sql_query($sql); - } - - if ($sync) - { - // Delete ghost topics that link back to the same forum then resync counters - sync('topic_moved'); - sync('forum', 'forum_id', $to_id, false, true); - } - - return array(); - } - - /** - * Remove complete forum - */ - function delete_forum($forum_id, $action_posts = 'delete', $action_subforums = 'delete', $posts_to_id = 0, $subforums_to_id = 0) - { - global $db, $user, $cache, $phpbb_log; - - $forum_data = $this->get_forum_info($forum_id); - - $errors = array(); - $log_action_posts = $log_action_forums = $posts_to_name = $subforums_to_name = ''; - $forum_ids = array($forum_id); - - if ($action_posts == 'delete') - { - $log_action_posts = 'POSTS'; - $errors = array_merge($errors, $this->delete_forum_content($forum_id)); - } - else if ($action_posts == 'move') - { - if (!$posts_to_id) - { - $errors[] = $user->lang['NO_DESTINATION_FORUM']; - } - else - { - $log_action_posts = 'MOVE_POSTS'; - - $sql = 'SELECT forum_name - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . $posts_to_id; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - $errors[] = $user->lang['NO_FORUM']; - } - else - { - $posts_to_name = $row['forum_name']; - $errors = array_merge($errors, $this->move_forum_content($forum_id, $posts_to_id)); - } - } - } - - if (count($errors)) - { - return $errors; - } - - if ($action_subforums == 'delete') - { - $log_action_forums = 'FORUMS'; - $rows = get_forum_branch($forum_id, 'children', 'descending', false); - - foreach ($rows as $row) - { - $forum_ids[] = $row['forum_id']; - $errors = array_merge($errors, $this->delete_forum_content($row['forum_id'])); - } - - if (count($errors)) - { - return $errors; - } - - $diff = count($forum_ids) * 2; - - $sql = 'DELETE FROM ' . FORUMS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $forum_ids); - $db->sql_query($sql); - - $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $forum_ids); - $db->sql_query($sql); - - $sql = 'DELETE FROM ' . ACL_USERS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $forum_ids); - $db->sql_query($sql); - } - else if ($action_subforums == 'move') - { - if (!$subforums_to_id) - { - $errors[] = $user->lang['NO_DESTINATION_FORUM']; - } - else - { - $log_action_forums = 'MOVE_FORUMS'; - - $sql = 'SELECT forum_name - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . $subforums_to_id; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - $errors[] = $user->lang['NO_FORUM']; - } - else - { - $subforums_to_name = $row['forum_name']; - - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE . " - WHERE parent_id = $forum_id"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $this->move_forum($row['forum_id'], $subforums_to_id); - } - $db->sql_freeresult($result); - - // Grab new forum data for correct tree updating later - $forum_data = $this->get_forum_info($forum_id); - - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET parent_id = $subforums_to_id - WHERE parent_id = $forum_id"; - $db->sql_query($sql); - - $diff = 2; - $sql = 'DELETE FROM ' . FORUMS_TABLE . " - WHERE forum_id = $forum_id"; - $db->sql_query($sql); - - $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . " - WHERE forum_id = $forum_id"; - $db->sql_query($sql); - - $sql = 'DELETE FROM ' . ACL_USERS_TABLE . " - WHERE forum_id = $forum_id"; - $db->sql_query($sql); - } - } - - if (count($errors)) - { - return $errors; - } - } - else - { - $diff = 2; - $sql = 'DELETE FROM ' . FORUMS_TABLE . " - WHERE forum_id = $forum_id"; - $db->sql_query($sql); - - $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . " - WHERE forum_id = $forum_id"; - $db->sql_query($sql); - - $sql = 'DELETE FROM ' . ACL_USERS_TABLE . " - WHERE forum_id = $forum_id"; - $db->sql_query($sql); - } - - // Resync tree - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET right_id = right_id - $diff - WHERE left_id < {$forum_data['right_id']} AND right_id > {$forum_data['right_id']}"; - $db->sql_query($sql); - - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET left_id = left_id - $diff, right_id = right_id - $diff - WHERE left_id > {$forum_data['right_id']}"; - $db->sql_query($sql); - - // Delete forum ids from extension groups table - $sql = 'SELECT group_id, allowed_forums - FROM ' . EXTENSION_GROUPS_TABLE; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if (!$row['allowed_forums']) - { - continue; - } - - $allowed_forums = unserialize(trim($row['allowed_forums'])); - $allowed_forums = array_diff($allowed_forums, $forum_ids); - - $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . " - SET allowed_forums = '" . ((count($allowed_forums)) ? serialize($allowed_forums) : '') . "' - WHERE group_id = {$row['group_id']}"; - $db->sql_query($sql); - } - $db->sql_freeresult($result); - - $cache->destroy('_extensions'); - - $log_action = implode('_', array($log_action_posts, $log_action_forums)); - - switch ($log_action) - { - case 'MOVE_POSTS_MOVE_FORUMS': - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_DEL_MOVE_POSTS_MOVE_FORUMS', false, array($posts_to_name, $subforums_to_name, $forum_data['forum_name'])); - break; - - case 'MOVE_POSTS_FORUMS': - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_DEL_MOVE_POSTS_FORUMS', false, array($posts_to_name, $forum_data['forum_name'])); - break; - - case 'POSTS_MOVE_FORUMS': - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_DEL_POSTS_MOVE_FORUMS', false, array($subforums_to_name, $forum_data['forum_name'])); - break; - - case '_MOVE_FORUMS': - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_DEL_MOVE_FORUMS', false, array($subforums_to_name, $forum_data['forum_name'])); - break; - - case 'MOVE_POSTS_': - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_DEL_MOVE_POSTS', false, array($posts_to_name, $forum_data['forum_name'])); - break; - - case 'POSTS_FORUMS': - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_DEL_POSTS_FORUMS', false, array($forum_data['forum_name'])); - break; - - case '_FORUMS': - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_DEL_FORUMS', false, array($forum_data['forum_name'])); - break; - - case 'POSTS_': - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_DEL_POSTS', false, array($forum_data['forum_name'])); - break; - - default: - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_DEL_FORUM', false, array($forum_data['forum_name'])); - break; - } - - return $errors; - } - - /** - * Delete forum content - */ - function delete_forum_content($forum_id) - { - global $db, $config, $phpbb_root_path, $phpEx, $phpbb_container, $phpbb_dispatcher; - - include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx); - - $db->sql_transaction('begin'); - - // Select then delete all attachments - $sql = 'SELECT a.topic_id - FROM ' . POSTS_TABLE . ' p, ' . ATTACHMENTS_TABLE . " a - WHERE p.forum_id = $forum_id - AND a.in_message = 0 - AND a.topic_id = p.topic_id"; - $result = $db->sql_query($sql); - - $topic_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $topic_ids[] = $row['topic_id']; - } - $db->sql_freeresult($result); - - /** @var \phpbb\attachment\manager $attachment_manager */ - $attachment_manager = $phpbb_container->get('attachment.manager'); - $attachment_manager->delete('topic', $topic_ids, false); - unset($attachment_manager); - - // Delete shadow topics pointing to topics in this forum - delete_topic_shadows($forum_id); - - // Before we remove anything we make sure we are able to adjust the post counts later. ;) - $sql = 'SELECT poster_id - FROM ' . POSTS_TABLE . ' - WHERE forum_id = ' . $forum_id . ' - AND post_postcount = 1 - AND post_visibility = ' . ITEM_APPROVED; - $result = $db->sql_query($sql); - - $post_counts = array(); - while ($row = $db->sql_fetchrow($result)) - { - $post_counts[$row['poster_id']] = (!empty($post_counts[$row['poster_id']])) ? $post_counts[$row['poster_id']] + 1 : 1; - } - $db->sql_freeresult($result); - - switch ($db->get_sql_layer()) - { - case 'mysql4': - case 'mysqli': - - // Delete everything else and thank MySQL for offering multi-table deletion - $tables_ary = array( - SEARCH_WORDMATCH_TABLE => 'post_id', - REPORTS_TABLE => 'post_id', - WARNINGS_TABLE => 'post_id', - BOOKMARKS_TABLE => 'topic_id', - TOPICS_WATCH_TABLE => 'topic_id', - TOPICS_POSTED_TABLE => 'topic_id', - POLL_OPTIONS_TABLE => 'topic_id', - POLL_VOTES_TABLE => 'topic_id', - ); - - $sql = 'DELETE ' . POSTS_TABLE; - $sql_using = "\nFROM " . POSTS_TABLE; - $sql_where = "\nWHERE " . POSTS_TABLE . ".forum_id = $forum_id\n"; - - foreach ($tables_ary as $table => $field) - { - $sql .= ", $table "; - $sql_using .= ", $table "; - $sql_where .= "\nAND $table.$field = " . POSTS_TABLE . ".$field"; - } - - $db->sql_query($sql . $sql_using . $sql_where); - - break; - - default: - - // Delete everything else and curse your DB for not offering multi-table deletion - $tables_ary = array( - 'post_id' => array( - SEARCH_WORDMATCH_TABLE, - REPORTS_TABLE, - WARNINGS_TABLE, - ), - - 'topic_id' => array( - BOOKMARKS_TABLE, - TOPICS_WATCH_TABLE, - TOPICS_POSTED_TABLE, - POLL_OPTIONS_TABLE, - POLL_VOTES_TABLE, - ) - ); - - // Amount of rows we select and delete in one iteration. - $batch_size = 500; - - foreach ($tables_ary as $field => $tables) - { - $start = 0; - - do - { - $sql = "SELECT $field - FROM " . POSTS_TABLE . ' - WHERE forum_id = ' . $forum_id; - $result = $db->sql_query_limit($sql, $batch_size, $start); - - $ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $ids[] = $row[$field]; - } - $db->sql_freeresult($result); - - if (count($ids)) - { - $start += count($ids); - - foreach ($tables as $table) - { - $db->sql_query("DELETE FROM $table WHERE " . $db->sql_in_set($field, $ids)); - } - } - } - while (count($ids) == $batch_size); - } - unset($ids); - - break; - } - - $table_ary = array(FORUMS_ACCESS_TABLE, FORUMS_TRACK_TABLE, FORUMS_WATCH_TABLE, LOG_TABLE, MODERATOR_CACHE_TABLE, POSTS_TABLE, TOPICS_TABLE, TOPICS_TRACK_TABLE); - - /** - * Perform additional actions before forum content deletion - * - * @event core.delete_forum_content_before_query - * @var array table_ary Array of tables from which all rows will be deleted that hold the forum_id - * @var int forum_id the forum id - * @var array topic_ids Array of the topic ids from the forum to be deleted - * @var array post_counts Array of counts of posts in the forum, by poster_id - * @since 3.1.6-RC1 - */ - $vars = array( - 'table_ary', - 'forum_id', - 'topic_ids', - 'post_counts', - ); - extract($phpbb_dispatcher->trigger_event('core.delete_forum_content_before_query', compact($vars))); - - foreach ($table_ary as $table) - { - $db->sql_query("DELETE FROM $table WHERE forum_id = $forum_id"); - } - - // Set forum ids to 0 - $table_ary = array(DRAFTS_TABLE); - - foreach ($table_ary as $table) - { - $db->sql_query("UPDATE $table SET forum_id = 0 WHERE forum_id = $forum_id"); - } - - // Adjust users post counts - if (count($post_counts)) - { - foreach ($post_counts as $poster_id => $substract) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_posts = 0 - WHERE user_id = ' . $poster_id . ' - AND user_posts < ' . $substract; - $db->sql_query($sql); - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_posts = user_posts - ' . $substract . ' - WHERE user_id = ' . $poster_id . ' - AND user_posts >= ' . $substract; - $db->sql_query($sql); - } - } - - $db->sql_transaction('commit'); - - // Make sure the overall post/topic count is correct... - $sql = 'SELECT COUNT(post_id) AS stat - FROM ' . POSTS_TABLE . ' - WHERE post_visibility = ' . ITEM_APPROVED; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $config->set('num_posts', (int) $row['stat'], false); - - $sql = 'SELECT COUNT(topic_id) AS stat - FROM ' . TOPICS_TABLE . ' - WHERE topic_visibility = ' . ITEM_APPROVED; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $config->set('num_topics', (int) $row['stat'], false); - - $sql = 'SELECT COUNT(attach_id) as stat - FROM ' . ATTACHMENTS_TABLE; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $config->set('num_files', (int) $row['stat'], false); - - $sql = 'SELECT SUM(filesize) as stat - FROM ' . ATTACHMENTS_TABLE; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $config->set('upload_dir_size', (float) $row['stat'], false); - - return array(); - } - - /** - * Move forum position by $steps up/down - */ - function move_forum_by($forum_row, $action = 'move_up', $steps = 1) - { - global $db; - - /** - * Fetch all the siblings between the module's current spot - * and where we want to move it to. If there are less than $steps - * siblings between the current spot and the target then the - * module will move as far as possible - */ - $sql = 'SELECT forum_id, forum_name, left_id, right_id - FROM ' . FORUMS_TABLE . " - WHERE parent_id = {$forum_row['parent_id']} - AND " . (($action == 'move_up') ? "right_id < {$forum_row['right_id']} ORDER BY right_id DESC" : "left_id > {$forum_row['left_id']} ORDER BY left_id ASC"); - $result = $db->sql_query_limit($sql, $steps); - - $target = array(); - while ($row = $db->sql_fetchrow($result)) - { - $target = $row; - } - $db->sql_freeresult($result); - - if (!count($target)) - { - // The forum is already on top or bottom - return false; - } - - /** - * $left_id and $right_id define the scope of the nodes that are affected by the move. - * $diff_up and $diff_down are the values to substract or add to each node's left_id - * and right_id in order to move them up or down. - * $move_up_left and $move_up_right define the scope of the nodes that are moving - * up. Other nodes in the scope of ($left_id, $right_id) are considered to move down. - */ - if ($action == 'move_up') - { - $left_id = $target['left_id']; - $right_id = $forum_row['right_id']; - - $diff_up = $forum_row['left_id'] - $target['left_id']; - $diff_down = $forum_row['right_id'] + 1 - $forum_row['left_id']; - - $move_up_left = $forum_row['left_id']; - $move_up_right = $forum_row['right_id']; - } - else - { - $left_id = $forum_row['left_id']; - $right_id = $target['right_id']; - - $diff_up = $forum_row['right_id'] + 1 - $forum_row['left_id']; - $diff_down = $target['right_id'] - $forum_row['right_id']; - - $move_up_left = $forum_row['right_id'] + 1; - $move_up_right = $target['right_id']; - } - - // Now do the dirty job - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET left_id = left_id + CASE - WHEN left_id BETWEEN {$move_up_left} AND {$move_up_right} THEN -{$diff_up} - ELSE {$diff_down} - END, - right_id = right_id + CASE - WHEN right_id BETWEEN {$move_up_left} AND {$move_up_right} THEN -{$diff_up} - ELSE {$diff_down} - END, - forum_parents = '' - WHERE - left_id BETWEEN {$left_id} AND {$right_id} - AND right_id BETWEEN {$left_id} AND {$right_id}"; - $db->sql_query($sql); - - return $target['forum_name']; - } - - /** - * Display progress bar for syncinc forums - */ - function display_progress_bar($start, $total) - { - global $template, $user; - - adm_page_header($user->lang['SYNC_IN_PROGRESS']); - - $template->set_filenames(array( - 'body' => 'progress_bar.html') - ); - - $template->assign_vars(array( - 'L_PROGRESS' => $user->lang['SYNC_IN_PROGRESS'], - 'L_PROGRESS_EXPLAIN' => ($start && $total) ? sprintf($user->lang['SYNC_IN_PROGRESS_EXPLAIN'], $start, $total) : $user->lang['SYNC_IN_PROGRESS']) - ); - - adm_page_footer(); - } - - /** - * Display copy permission page - * Not used at the moment - we will have a look at it for 3.0.7 - */ - function copy_permission_page($forum_data) - { - global $phpEx, $phpbb_admin_path, $template, $user; - - $acl_url = '&mode=setting_forum_local&forum_id[]=' . $forum_data['forum_id']; - $action = append_sid($this->u_action . "&parent_id={$this->parent_id}&f={$forum_data['forum_id']}&action=copy_perm"); - - $l_acl = sprintf($user->lang['COPY_TO_ACL'], '', ''); - - $this->tpl_name = 'acp_forums_copy_perm'; - - $template->assign_vars(array( - 'U_ACL' => append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions' . $acl_url), - 'L_ACL_LINK' => $l_acl, - 'L_BACK_LINK' => adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), - 'S_COPY_ACTION' => $action, - 'S_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $forum_data['forum_id'], false, false, false), - )); - } - -} diff --git a/install/update/old/includes/acp/acp_help_phpbb.php b/install/update/old/includes/acp/acp_help_phpbb.php deleted file mode 100644 index a36b36e..0000000 --- a/install/update/old/includes/acp/acp_help_phpbb.php +++ /dev/null @@ -1,143 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -class acp_help_phpbb -{ - var $u_action; - - function main($id, $mode) - { - global $config, $request, $template, $user, $phpbb_dispatcher, $phpbb_admin_path, $phpbb_root_path, $phpEx; - - if (!class_exists('phpbb_questionnaire_data_collector')) - { - include($phpbb_root_path . 'includes/questionnaire/questionnaire.' . $phpEx); - } - - $collect_url = "https://www.phpbb.com/stats/receive_stats.php"; - - $this->tpl_name = 'acp_help_phpbb'; - $this->page_title = 'ACP_HELP_PHPBB'; - - $submit = ($request->is_set_post('submit')) ? true : false; - - $form_key = 'acp_help_phpbb'; - add_form_key($form_key); - $error = array(); - - if ($submit && !check_form_key($form_key)) - { - $error[] = $user->lang['FORM_INVALID']; - } - // Do not write values if there is an error - if (count($error)) - { - $submit = false; - } - - // generate a unique id if necessary - if (!isset($config['questionnaire_unique_id'])) - { - $install_id = unique_id(); - $config->set('questionnaire_unique_id', $install_id); - } - else - { - $install_id = $config['questionnaire_unique_id']; - } - - $collector = new phpbb_questionnaire_data_collector($install_id); - - // Add data provider - $collector->add_data_provider(new phpbb_questionnaire_php_data_provider()); - $collector->add_data_provider(new phpbb_questionnaire_system_data_provider()); - $collector->add_data_provider(new phpbb_questionnaire_phpbb_data_provider($config)); - - /** - * Event to modify ACP help phpBB page and/or listen to submit - * - * @event core.acp_help_phpbb_submit_before - * @var boolean submit Do we display the form or process the submission - * @since 3.2.0-RC2 - */ - $vars = array('submit'); - extract($phpbb_dispatcher->trigger_event('core.acp_help_phpbb_submit_before', compact($vars))); - - if ($submit) - { - $config->set('help_send_statistics', $request->variable('help_send_statistics', false)); - $response = $request->variable('send_statistics_response', ''); - - $config->set('help_send_statistics_time', time()); - - if (!empty($response)) - { - if ((strpos($response, 'Thank you') !== false || strpos($response, 'Flood protection') !== false)) - { - trigger_error($user->lang('THANKS_SEND_STATISTICS') . adm_back_link($this->u_action)); - } - else - { - trigger_error($user->lang('FAIL_SEND_STATISTICS') . adm_back_link($this->u_action)); - } - } - - trigger_error($user->lang('CONFIG_UPDATED') . adm_back_link($this->u_action)); - } - - $template->assign_vars(array( - 'U_COLLECT_STATS' => $collect_url, - 'S_COLLECT_STATS' => (!empty($config['help_send_statistics'])) ? true : false, - 'RAW_DATA' => $collector->get_data_for_form(), - 'U_ACP_MAIN' => append_sid("{$phpbb_admin_path}index.$phpEx"), - 'U_ACTION' => $this->u_action, - // Pass earliest time we should try to send stats again - 'COLLECT_STATS_TIME' => intval($config['help_send_statistics_time']) + 86400, - )); - - $raw = $collector->get_data_raw(); - - foreach ($raw as $provider => $data) - { - if ($provider == 'install_id') - { - $data = array($provider => $data); - } - - $template->assign_block_vars('providers', array( - 'NAME' => htmlspecialchars($provider), - )); - - foreach ($data as $key => $value) - { - if (is_array($value)) - { - $value = utf8_wordwrap(serialize($value), 75, "\n", true); - } - - $template->assign_block_vars('providers.values', array( - 'KEY' => utf8_htmlspecialchars($key), - 'VALUE' => utf8_htmlspecialchars($value), - )); - } - } - } -} diff --git a/install/update/old/includes/acp/acp_main.php b/install/update/old/includes/acp/acp_main.php deleted file mode 100644 index 8f169d1..0000000 --- a/install/update/old/includes/acp/acp_main.php +++ /dev/null @@ -1,707 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -class acp_main -{ - var $u_action; - - function main($id, $mode) - { - global $config, $db, $cache, $user, $auth, $template, $request, $phpbb_log; - global $phpbb_root_path, $phpbb_admin_path, $phpEx, $phpbb_container, $phpbb_dispatcher, $phpbb_filesystem; - - // Show restore permissions notice - if ($user->data['user_perm_from'] && $auth->acl_get('a_switchperm')) - { - $this->tpl_name = 'acp_main'; - $this->page_title = 'ACP_MAIN'; - - $sql = 'SELECT user_id, username, user_colour - FROM ' . USERS_TABLE . ' - WHERE user_id = ' . $user->data['user_perm_from']; - $result = $db->sql_query($sql); - $user_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $perm_from = get_username_string('full', $user_row['user_id'], $user_row['username'], $user_row['user_colour']); - - $template->assign_vars(array( - 'S_RESTORE_PERMISSIONS' => true, - 'U_RESTORE_PERMISSIONS' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=restore_perm'), - 'PERM_FROM' => $perm_from, - 'L_PERMISSIONS_TRANSFERRED_EXPLAIN' => sprintf($user->lang['PERMISSIONS_TRANSFERRED_EXPLAIN'], $perm_from, append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=restore_perm')), - )); - - return; - } - - $action = $request->variable('action', ''); - - if ($action) - { - if ($action === 'admlogout') - { - $user->unset_admin(); - redirect(append_sid("{$phpbb_root_path}index.$phpEx")); - } - - if (!confirm_box(true)) - { - switch ($action) - { - case 'online': - $confirm = true; - $confirm_lang = 'RESET_ONLINE_CONFIRM'; - break; - case 'stats': - $confirm = true; - $confirm_lang = 'RESYNC_STATS_CONFIRM'; - break; - case 'user': - $confirm = true; - $confirm_lang = 'RESYNC_POSTCOUNTS_CONFIRM'; - break; - case 'date': - $confirm = true; - $confirm_lang = 'RESET_DATE_CONFIRM'; - break; - case 'db_track': - $confirm = true; - $confirm_lang = 'RESYNC_POST_MARKING_CONFIRM'; - break; - case 'purge_cache': - $confirm = true; - $confirm_lang = 'PURGE_CACHE_CONFIRM'; - break; - case 'purge_sessions': - $confirm = true; - $confirm_lang = 'PURGE_SESSIONS_CONFIRM'; - break; - - default: - $confirm = true; - $confirm_lang = 'CONFIRM_OPERATION'; - } - - if ($confirm) - { - confirm_box(false, $user->lang[$confirm_lang], build_hidden_fields(array( - 'i' => $id, - 'mode' => $mode, - 'action' => $action, - ))); - } - } - else - { - switch ($action) - { - - case 'online': - if (!$auth->acl_get('a_board')) - { - send_status_line(403, 'Forbidden'); - trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - $config->set('record_online_users', 1, false); - $config->set('record_online_date', time(), false); - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_RESET_ONLINE'); - - if ($request->is_ajax()) - { - trigger_error('RESET_ONLINE_SUCCESS'); - } - break; - - case 'stats': - if (!$auth->acl_get('a_board')) - { - send_status_line(403, 'Forbidden'); - trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - $sql = 'SELECT COUNT(post_id) AS stat - FROM ' . POSTS_TABLE . ' - WHERE post_visibility = ' . ITEM_APPROVED; - $result = $db->sql_query($sql); - $config->set('num_posts', (int) $db->sql_fetchfield('stat'), false); - $db->sql_freeresult($result); - - $sql = 'SELECT COUNT(topic_id) AS stat - FROM ' . TOPICS_TABLE . ' - WHERE topic_visibility = ' . ITEM_APPROVED; - $result = $db->sql_query($sql); - $config->set('num_topics', (int) $db->sql_fetchfield('stat'), false); - $db->sql_freeresult($result); - - $sql = 'SELECT COUNT(user_id) AS stat - FROM ' . USERS_TABLE . ' - WHERE user_type IN (' . USER_NORMAL . ',' . USER_FOUNDER . ')'; - $result = $db->sql_query($sql); - $config->set('num_users', (int) $db->sql_fetchfield('stat'), false); - $db->sql_freeresult($result); - - $sql = 'SELECT COUNT(attach_id) as stat - FROM ' . ATTACHMENTS_TABLE . ' - WHERE is_orphan = 0'; - $result = $db->sql_query($sql); - $config->set('num_files', (int) $db->sql_fetchfield('stat'), false); - $db->sql_freeresult($result); - - $sql = 'SELECT SUM(filesize) as stat - FROM ' . ATTACHMENTS_TABLE . ' - WHERE is_orphan = 0'; - $result = $db->sql_query($sql); - $config->set('upload_dir_size', (float) $db->sql_fetchfield('stat'), false); - $db->sql_freeresult($result); - - if (!function_exists('update_last_username')) - { - include($phpbb_root_path . "includes/functions_user.$phpEx"); - } - update_last_username(); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_RESYNC_STATS'); - - if ($request->is_ajax()) - { - trigger_error('RESYNC_STATS_SUCCESS'); - } - break; - - case 'user': - if (!$auth->acl_get('a_board')) - { - send_status_line(403, 'Forbidden'); - trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - // Resync post counts - $start = $max_post_id = 0; - - // Find the maximum post ID, we can only stop the cycle when we've reached it - $sql = 'SELECT MAX(forum_last_post_id) as max_post_id - FROM ' . FORUMS_TABLE; - $result = $db->sql_query($sql); - $max_post_id = (int) $db->sql_fetchfield('max_post_id'); - $db->sql_freeresult($result); - - // No maximum post id? :o - if (!$max_post_id) - { - $sql = 'SELECT MAX(post_id) as max_post_id - FROM ' . POSTS_TABLE; - $result = $db->sql_query($sql); - $max_post_id = (int) $db->sql_fetchfield('max_post_id'); - $db->sql_freeresult($result); - } - - // Still no maximum post id? Then we are finished - if (!$max_post_id) - { - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_RESYNC_POSTCOUNTS'); - break; - } - - $step = ($config['num_posts']) ? (max((int) ($config['num_posts'] / 5), 20000)) : 20000; - $db->sql_query('UPDATE ' . USERS_TABLE . ' SET user_posts = 0'); - - while ($start < $max_post_id) - { - $sql = 'SELECT COUNT(post_id) AS num_posts, poster_id - FROM ' . POSTS_TABLE . ' - WHERE post_id BETWEEN ' . ($start + 1) . ' AND ' . ($start + $step) . ' - AND post_postcount = 1 AND post_visibility = ' . ITEM_APPROVED . ' - GROUP BY poster_id'; - $result = $db->sql_query($sql); - - if ($row = $db->sql_fetchrow($result)) - { - do - { - $sql = 'UPDATE ' . USERS_TABLE . " SET user_posts = user_posts + {$row['num_posts']} WHERE user_id = {$row['poster_id']}"; - $db->sql_query($sql); - } - while ($row = $db->sql_fetchrow($result)); - } - $db->sql_freeresult($result); - - $start += $step; - } - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_RESYNC_POSTCOUNTS'); - - if ($request->is_ajax()) - { - trigger_error('RESYNC_POSTCOUNTS_SUCCESS'); - } - break; - - case 'date': - if (!$auth->acl_get('a_board')) - { - send_status_line(403, 'Forbidden'); - trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - $config->set('board_startdate', time() - 1); - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_RESET_DATE'); - - if ($request->is_ajax()) - { - trigger_error('RESET_DATE_SUCCESS'); - } - break; - - case 'db_track': - switch ($db->get_sql_layer()) - { - case 'sqlite3': - $db->sql_query('DELETE FROM ' . TOPICS_POSTED_TABLE); - break; - - default: - $db->sql_query('TRUNCATE TABLE ' . TOPICS_POSTED_TABLE); - break; - } - - // This can get really nasty... therefore we only do the last six months - $get_from_time = time() - (6 * 4 * 7 * 24 * 60 * 60); - - // Select forum ids, do not include categories - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE . ' - WHERE forum_type <> ' . FORUM_CAT; - $result = $db->sql_query($sql); - - $forum_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $forum_ids[] = $row['forum_id']; - } - $db->sql_freeresult($result); - - // Any global announcements? ;) - $forum_ids[] = 0; - - // Now go through the forums and get us some topics... - foreach ($forum_ids as $forum_id) - { - $sql = 'SELECT p.poster_id, p.topic_id - FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t - WHERE t.forum_id = ' . $forum_id . ' - AND t.topic_moved_id = 0 - AND t.topic_last_post_time > ' . $get_from_time . ' - AND t.topic_id = p.topic_id - AND p.poster_id <> ' . ANONYMOUS . ' - GROUP BY p.poster_id, p.topic_id'; - $result = $db->sql_query($sql); - - $posted = array(); - while ($row = $db->sql_fetchrow($result)) - { - $posted[$row['poster_id']][] = $row['topic_id']; - } - $db->sql_freeresult($result); - - $sql_ary = array(); - foreach ($posted as $user_id => $topic_row) - { - foreach ($topic_row as $topic_id) - { - $sql_ary[] = array( - 'user_id' => (int) $user_id, - 'topic_id' => (int) $topic_id, - 'topic_posted' => 1, - ); - } - } - unset($posted); - - if (count($sql_ary)) - { - $db->sql_multi_insert(TOPICS_POSTED_TABLE, $sql_ary); - } - } - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_RESYNC_POST_MARKING'); - - if ($request->is_ajax()) - { - trigger_error('RESYNC_POST_MARKING_SUCCESS'); - } - break; - - case 'purge_cache': - $config->increment('assets_version', 1); - $cache->purge(); - - // Remove old renderers from the text_formatter service. Since this - // operation is performed after the cache is purged, there is not "current" - // renderer and in effect all renderers will be purged - $phpbb_container->get('text_formatter.cache')->tidy(); - - // Clear permissions - $auth->acl_clear_prefetch(); - phpbb_cache_moderators($db, $cache, $auth); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_PURGE_CACHE'); - - if ($request->is_ajax()) - { - trigger_error('PURGE_CACHE_SUCCESS'); - } - break; - - case 'purge_sessions': - if ((int) $user->data['user_type'] !== USER_FOUNDER) - { - send_status_line(403, 'Forbidden'); - trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - $tables = array(CONFIRM_TABLE, SESSIONS_TABLE); - - foreach ($tables as $table) - { - switch ($db->get_sql_layer()) - { - case 'sqlite3': - $db->sql_query("DELETE FROM $table"); - break; - - default: - $db->sql_query("TRUNCATE TABLE $table"); - break; - } - } - - // let's restore the admin session - $reinsert_ary = array( - 'session_id' => (string) $user->session_id, - 'session_page' => (string) substr($user->page['page'], 0, 199), - 'session_forum_id' => $user->page['forum'], - 'session_user_id' => (int) $user->data['user_id'], - 'session_start' => (int) $user->data['session_start'], - 'session_last_visit' => (int) $user->data['session_last_visit'], - 'session_time' => (int) $user->time_now, - 'session_browser' => (string) trim(substr($user->browser, 0, 149)), - 'session_forwarded_for' => (string) $user->forwarded_for, - 'session_ip' => (string) $user->ip, - 'session_autologin' => (int) $user->data['session_autologin'], - 'session_admin' => 1, - 'session_viewonline' => (int) $user->data['session_viewonline'], - ); - - $sql = 'INSERT INTO ' . SESSIONS_TABLE . ' ' . $db->sql_build_array('INSERT', $reinsert_ary); - $db->sql_query($sql); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_PURGE_SESSIONS'); - - if ($request->is_ajax()) - { - trigger_error('PURGE_SESSIONS_SUCCESS'); - } - break; - } - } - } - - // Version check - $user->add_lang('install'); - - if ($auth->acl_get('a_server') && version_compare(PHP_VERSION, '5.4.0', '<')) - { - $template->assign_vars(array( - 'S_PHP_VERSION_OLD' => true, - 'L_PHP_VERSION_OLD' => sprintf($user->lang['PHP_VERSION_OLD'], PHP_VERSION, '5.4.0', '', ''), - )); - } - - if ($auth->acl_get('a_board')) - { - $version_helper = $phpbb_container->get('version_helper'); - try - { - $recheck = $request->variable('versioncheck_force', false); - $updates_available = $version_helper->get_update_on_branch($recheck); - $upgrades_available = $version_helper->get_suggested_updates(); - if (!empty($upgrades_available)) - { - $upgrades_available = array_pop($upgrades_available); - } - - $template->assign_vars(array( - 'S_VERSION_UP_TO_DATE' => empty($updates_available), - 'S_VERSION_UPGRADEABLE' => !empty($upgrades_available), - 'UPGRADE_INSTRUCTIONS' => !empty($upgrades_available) ? $user->lang('UPGRADE_INSTRUCTIONS', $upgrades_available['current'], $upgrades_available['announcement']) : false, - )); - } - catch (\RuntimeException $e) - { - $message = call_user_func_array(array($user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters())); - $template->assign_vars(array( - 'S_VERSIONCHECK_FAIL' => true, - 'VERSIONCHECK_FAIL_REASON' => ($e->getMessage() !== 'VERSIONCHECK_FAIL') ? $message : '', - )); - } - } - else - { - // We set this template var to true, to not display an outdated version notice. - $template->assign_var('S_VERSION_UP_TO_DATE', true); - } - - // Incomplete update? - if (phpbb_version_compare($config['version'], PHPBB_VERSION, '<')) - { - $template->assign_var('S_UPDATE_INCOMPLETE', true); - } - - /** - * Notice admin - * - * @event core.acp_main_notice - * @since 3.1.0-RC3 - */ - $phpbb_dispatcher->dispatch('core.acp_main_notice'); - - // Get forum statistics - $total_posts = $config['num_posts']; - $total_topics = $config['num_topics']; - $total_users = $config['num_users']; - $total_files = $config['num_files']; - - $start_date = $user->format_date($config['board_startdate']); - - $boarddays = (time() - $config['board_startdate']) / 86400; - - $posts_per_day = sprintf('%.2f', $total_posts / $boarddays); - $topics_per_day = sprintf('%.2f', $total_topics / $boarddays); - $users_per_day = sprintf('%.2f', $total_users / $boarddays); - $files_per_day = sprintf('%.2f', $total_files / $boarddays); - - $upload_dir_size = get_formatted_filesize($config['upload_dir_size']); - - $avatar_dir_size = 0; - - if ($avatar_dir = @opendir($phpbb_root_path . $config['avatar_path'])) - { - while (($file = readdir($avatar_dir)) !== false) - { - if ($file[0] != '.' && $file != 'CVS' && strpos($file, 'index.') === false) - { - $avatar_dir_size += filesize($phpbb_root_path . $config['avatar_path'] . '/' . $file); - } - } - closedir($avatar_dir); - - $avatar_dir_size = get_formatted_filesize($avatar_dir_size); - } - else - { - // Couldn't open Avatar dir. - $avatar_dir_size = $user->lang['NOT_AVAILABLE']; - } - - if ($posts_per_day > $total_posts) - { - $posts_per_day = $total_posts; - } - - if ($topics_per_day > $total_topics) - { - $topics_per_day = $total_topics; - } - - if ($users_per_day > $total_users) - { - $users_per_day = $total_users; - } - - if ($files_per_day > $total_files) - { - $files_per_day = $total_files; - } - - if ($config['allow_attachments'] || $config['allow_pm_attach']) - { - $sql = 'SELECT COUNT(attach_id) AS total_orphan - FROM ' . ATTACHMENTS_TABLE . ' - WHERE is_orphan = 1 - AND filetime < ' . (time() - 3*60*60); - $result = $db->sql_query($sql); - $total_orphan = (int) $db->sql_fetchfield('total_orphan'); - $db->sql_freeresult($result); - } - else - { - $total_orphan = false; - } - - $dbsize = get_database_size(); - - $template->assign_vars(array( - 'TOTAL_POSTS' => $total_posts, - 'POSTS_PER_DAY' => $posts_per_day, - 'TOTAL_TOPICS' => $total_topics, - 'TOPICS_PER_DAY' => $topics_per_day, - 'TOTAL_USERS' => $total_users, - 'USERS_PER_DAY' => $users_per_day, - 'TOTAL_FILES' => $total_files, - 'FILES_PER_DAY' => $files_per_day, - 'START_DATE' => $start_date, - 'AVATAR_DIR_SIZE' => $avatar_dir_size, - 'DBSIZE' => $dbsize, - 'UPLOAD_DIR_SIZE' => $upload_dir_size, - 'TOTAL_ORPHAN' => $total_orphan, - 'S_TOTAL_ORPHAN' => ($total_orphan === false) ? false : true, - 'GZIP_COMPRESSION' => ($config['gzip_compress'] && @extension_loaded('zlib')) ? $user->lang['ON'] : $user->lang['OFF'], - 'DATABASE_INFO' => $db->sql_server_info(), - 'PHP_VERSION_INFO' => PHP_VERSION, - 'BOARD_VERSION' => $config['version'], - - 'U_ACTION' => $this->u_action, - 'U_ADMIN_LOG' => append_sid("{$phpbb_admin_path}index.$phpEx", 'i=logs&mode=admin'), - 'U_INACTIVE_USERS' => append_sid("{$phpbb_admin_path}index.$phpEx", 'i=inactive&mode=list'), - 'U_VERSIONCHECK' => append_sid("{$phpbb_admin_path}index.$phpEx", 'i=update&mode=version_check'), - 'U_VERSIONCHECK_FORCE' => append_sid("{$phpbb_admin_path}index.$phpEx", 'versioncheck_force=1'), - 'U_ATTACH_ORPHAN' => append_sid("{$phpbb_admin_path}index.$phpEx", 'i=acp_attachments&mode=orphan'), - - 'S_VERSIONCHECK' => ($auth->acl_get('a_board')) ? true : false, - 'S_ACTION_OPTIONS' => ($auth->acl_get('a_board')) ? true : false, - 'S_FOUNDER' => ($user->data['user_type'] == USER_FOUNDER) ? true : false, - ) - ); - - $log_data = array(); - $log_count = false; - - if ($auth->acl_get('a_viewlogs')) - { - view_log('admin', $log_data, $log_count, 5); - - foreach ($log_data as $row) - { - $template->assign_block_vars('log', array( - 'USERNAME' => $row['username_full'], - 'IP' => $row['ip'], - 'DATE' => $user->format_date($row['time']), - 'ACTION' => $row['action']) - ); - } - } - - if ($auth->acl_get('a_user')) - { - $user->add_lang('memberlist'); - - $inactive = array(); - $inactive_count = 0; - - view_inactive_users($inactive, $inactive_count, 10); - - foreach ($inactive as $row) - { - $template->assign_block_vars('inactive', array( - 'INACTIVE_DATE' => $user->format_date($row['user_inactive_time']), - 'REMINDED_DATE' => $user->format_date($row['user_reminded_time']), - 'JOINED' => $user->format_date($row['user_regdate']), - 'LAST_VISIT' => (!$row['user_lastvisit']) ? ' - ' : $user->format_date($row['user_lastvisit']), - - 'REASON' => $row['inactive_reason'], - 'USER_ID' => $row['user_id'], - 'POSTS' => ($row['user_posts']) ? $row['user_posts'] : 0, - 'REMINDED' => $row['user_reminded'], - - 'REMINDED_EXPLAIN' => $user->lang('USER_LAST_REMINDED', (int) $row['user_reminded'], $user->format_date($row['user_reminded_time'])), - - 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], false, append_sid("{$phpbb_admin_path}index.$phpEx", 'i=users&mode=overview')), - 'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), - 'USER_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), - - 'U_USER_ADMIN' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=users&mode=overview&u={$row['user_id']}"), - 'U_SEARCH_USER' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id={$row['user_id']}&sr=posts") : '', - )); - } - - $option_ary = array('activate' => 'ACTIVATE', 'delete' => 'DELETE'); - if ($config['email_enable']) - { - $option_ary += array('remind' => 'REMIND'); - } - - $template->assign_vars(array( - 'S_INACTIVE_USERS' => true, - 'S_INACTIVE_OPTIONS' => build_select($option_ary)) - ); - } - - // Warn if install is still present - if (file_exists($phpbb_root_path . 'install') && !is_file($phpbb_root_path . 'install')) - { - $template->assign_var('S_REMOVE_INSTALL', true); - } - - // Warn if no search index is created - if ($config['num_posts'] && class_exists($config['search_type'])) - { - $error = false; - $search_type = $config['search_type']; - $search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher); - - if (!$search->index_created()) - { - $template->assign_vars(array( - 'S_SEARCH_INDEX_MISSING' => true, - 'L_NO_SEARCH_INDEX' => $user->lang('NO_SEARCH_INDEX', $search->get_name(), '', ''), - )); - } - } - - if (!defined('PHPBB_DISABLE_CONFIG_CHECK') && file_exists($phpbb_root_path . 'config.' . $phpEx) && $phpbb_filesystem->is_writable($phpbb_root_path . 'config.' . $phpEx)) - { - // World-Writable? (000x) - $template->assign_var('S_WRITABLE_CONFIG', (bool) (@fileperms($phpbb_root_path . 'config.' . $phpEx) & 0x0002)); - } - - if (extension_loaded('mbstring')) - { - $template->assign_vars(array( - 'S_MBSTRING_LOADED' => true, - 'S_MBSTRING_FUNC_OVERLOAD_FAIL' => (intval(@ini_get('mbstring.func_overload')) & (MB_OVERLOAD_MAIL | MB_OVERLOAD_STRING)), - 'S_MBSTRING_ENCODING_TRANSLATION_FAIL' => (@ini_get('mbstring.encoding_translation') != 0), - 'S_MBSTRING_HTTP_INPUT_FAIL' => !in_array(@ini_get('mbstring.http_input'), array('pass', '')), - 'S_MBSTRING_HTTP_OUTPUT_FAIL' => !in_array(@ini_get('mbstring.http_output'), array('pass', '')), - )); - } - - // Fill dbms version if not yet filled - if (empty($config['dbms_version'])) - { - $config->set('dbms_version', $db->sql_server_info(true)); - } - - $this->tpl_name = 'acp_main'; - $this->page_title = 'ACP_MAIN'; - } -} diff --git a/install/update/old/includes/acp/acp_permissions.php b/install/update/old/includes/acp/acp_permissions.php deleted file mode 100644 index e683b19..0000000 --- a/install/update/old/includes/acp/acp_permissions.php +++ /dev/null @@ -1,1346 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -class acp_permissions -{ - var $u_action; - var $permission_dropdown; - - /** - * @var $phpbb_permissions \phpbb\permissions - */ - protected $permissions; - - function main($id, $mode) - { - global $db, $user, $auth, $template, $phpbb_container, $request; - global $config, $phpbb_root_path, $phpEx; - - if (!function_exists('user_get_id_name')) - { - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - } - - if (!class_exists('auth_admin')) - { - include($phpbb_root_path . 'includes/acp/auth.' . $phpEx); - } - - $this->permissions = $phpbb_container->get('acl.permissions'); - - $auth_admin = new auth_admin(); - - $user->add_lang('acp/permissions'); - add_permission_language(); - - $this->tpl_name = 'acp_permissions'; - - // Trace has other vars - if ($mode == 'trace') - { - $user_id = $request->variable('u', 0); - $forum_id = $request->variable('f', 0); - $permission = $request->variable('auth', ''); - - $this->tpl_name = 'permission_trace'; - - if ($user_id && isset($auth_admin->acl_options['id'][$permission]) && $auth->acl_get('a_viewauth')) - { - $this->page_title = sprintf($user->lang['TRACE_PERMISSION'], $this->permissions->get_permission_lang($permission)); - $this->permission_trace($user_id, $forum_id, $permission); - return; - } - trigger_error('NO_MODE', E_USER_ERROR); - } - - // Copy forum permissions - if ($mode == 'setting_forum_copy') - { - $this->tpl_name = 'permission_forum_copy'; - - if ($auth->acl_get('a_fauth') && $auth->acl_get('a_authusers') && $auth->acl_get('a_authgroups') && $auth->acl_get('a_mauth')) - { - $this->page_title = 'ACP_FORUM_PERMISSIONS_COPY'; - $this->copy_forum_permissions(); - return; - } - - trigger_error('NO_MODE', E_USER_ERROR); - } - - // Set some vars - $action = $request->variable('action', array('' => 0)); - $action = key($action); - $action = (isset($_POST['psubmit'])) ? 'apply_permissions' : $action; - - $all_forums = $request->variable('all_forums', 0); - $subforum_id = $request->variable('subforum_id', 0); - $forum_id = $request->variable('forum_id', array(0)); - - $username = $request->variable('username', array(''), true); - $usernames = $request->variable('usernames', '', true); - $user_id = $request->variable('user_id', array(0)); - - $group_id = $request->variable('group_id', array(0)); - $select_all_groups = $request->variable('select_all_groups', 0); - - $form_name = 'acp_permissions'; - add_form_key($form_name); - - // If select all groups is set, we pre-build the group id array (this option is used for other screens to link to the permission settings screen) - if ($select_all_groups) - { - // Add default groups to selection - $sql_and = (!$config['coppa_enable']) ? " AND group_name <> 'REGISTERED_COPPA'" : ''; - - $sql = 'SELECT group_id - FROM ' . GROUPS_TABLE . ' - WHERE group_type = ' . GROUP_SPECIAL . " - $sql_and"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $group_id[] = $row['group_id']; - } - $db->sql_freeresult($result); - } - - // Map usernames to ids and vice versa - if ($usernames) - { - $username = explode("\n", $usernames); - } - unset($usernames); - - if (count($username) && !count($user_id)) - { - user_get_id_name($user_id, $username); - - if (!count($user_id)) - { - trigger_error($user->lang['SELECTED_USER_NOT_EXIST'] . adm_back_link($this->u_action), E_USER_WARNING); - } - } - unset($username); - - // Build forum ids (of all forums are checked or subforum listing used) - if ($all_forums) - { - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE . ' - ORDER BY left_id'; - $result = $db->sql_query($sql); - - $forum_id = array(); - while ($row = $db->sql_fetchrow($result)) - { - $forum_id[] = (int) $row['forum_id']; - } - $db->sql_freeresult($result); - } - else if ($subforum_id) - { - $forum_id = array(); - foreach (get_forum_branch($subforum_id, 'children') as $row) - { - $forum_id[] = (int) $row['forum_id']; - } - } - - // Define some common variables for every mode - $permission_scope = (strpos($mode, '_global') !== false) ? 'global' : 'local'; - - // Showing introductionary page? - if ($mode == 'intro') - { - $this->page_title = 'ACP_PERMISSIONS'; - - $template->assign_vars(array( - 'S_INTRO' => true) - ); - - return; - } - - switch ($mode) - { - case 'setting_user_global': - case 'setting_group_global': - $this->permission_dropdown = array('u_', 'm_', 'a_'); - $permission_victim = ($mode == 'setting_user_global') ? array('user') : array('group'); - $this->page_title = ($mode == 'setting_user_global') ? 'ACP_USERS_PERMISSIONS' : 'ACP_GROUPS_PERMISSIONS'; - break; - - case 'setting_user_local': - case 'setting_group_local': - $this->permission_dropdown = array('f_', 'm_'); - $permission_victim = ($mode == 'setting_user_local') ? array('user', 'forums') : array('group', 'forums'); - $this->page_title = ($mode == 'setting_user_local') ? 'ACP_USERS_FORUM_PERMISSIONS' : 'ACP_GROUPS_FORUM_PERMISSIONS'; - break; - - case 'setting_admin_global': - case 'setting_mod_global': - $this->permission_dropdown = (strpos($mode, '_admin_') !== false) ? array('a_') : array('m_'); - $permission_victim = array('usergroup'); - $this->page_title = ($mode == 'setting_admin_global') ? 'ACP_ADMINISTRATORS' : 'ACP_GLOBAL_MODERATORS'; - break; - - case 'setting_mod_local': - case 'setting_forum_local': - $this->permission_dropdown = ($mode == 'setting_mod_local') ? array('m_') : array('f_'); - $permission_victim = array('forums', 'usergroup'); - $this->page_title = ($mode == 'setting_mod_local') ? 'ACP_FORUM_MODERATORS' : 'ACP_FORUM_PERMISSIONS'; - break; - - case 'view_admin_global': - case 'view_user_global': - case 'view_mod_global': - $this->permission_dropdown = ($mode == 'view_admin_global') ? array('a_') : (($mode == 'view_user_global') ? array('u_') : array('m_')); - $permission_victim = array('usergroup_view'); - $this->page_title = ($mode == 'view_admin_global') ? 'ACP_VIEW_ADMIN_PERMISSIONS' : (($mode == 'view_user_global') ? 'ACP_VIEW_USER_PERMISSIONS' : 'ACP_VIEW_GLOBAL_MOD_PERMISSIONS'); - break; - - case 'view_mod_local': - case 'view_forum_local': - $this->permission_dropdown = ($mode == 'view_mod_local') ? array('m_') : array('f_'); - $permission_victim = array('forums', 'usergroup_view'); - $this->page_title = ($mode == 'view_mod_local') ? 'ACP_VIEW_FORUM_MOD_PERMISSIONS' : 'ACP_VIEW_FORUM_PERMISSIONS'; - break; - - default: - trigger_error('NO_MODE', E_USER_ERROR); - break; - } - - $template->assign_vars(array( - 'L_TITLE' => $user->lang[$this->page_title], - 'L_EXPLAIN' => $user->lang[$this->page_title . '_EXPLAIN']) - ); - - // Get permission type - $permission_type = $request->variable('type', $this->permission_dropdown[0]); - - if (!in_array($permission_type, $this->permission_dropdown)) - { - trigger_error($user->lang['WRONG_PERMISSION_TYPE'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - // Handle actions - if (strpos($mode, 'setting_') === 0 && $action) - { - switch ($action) - { - case 'delete': - if (confirm_box(true)) - { - // All users/groups selected? - $all_users = (isset($_POST['all_users'])) ? true : false; - $all_groups = (isset($_POST['all_groups'])) ? true : false; - - if ($all_users || $all_groups) - { - $items = $this->retrieve_defined_user_groups($permission_scope, $forum_id, $permission_type); - - if ($all_users && count($items['user_ids'])) - { - $user_id = $items['user_ids']; - } - else if ($all_groups && count($items['group_ids'])) - { - $group_id = $items['group_ids']; - } - } - - if (count($user_id) || count($group_id)) - { - $this->remove_permissions($mode, $permission_type, $auth_admin, $user_id, $group_id, $forum_id); - } - else - { - trigger_error($user->lang['NO_USER_GROUP_SELECTED'] . adm_back_link($this->u_action), E_USER_WARNING); - } - } - else - { - if (isset($_POST['cancel'])) - { - $u_redirect = $this->u_action . '&type=' . $permission_type; - foreach ($forum_id as $fid) - { - $u_redirect .= '&forum_id[]=' . $fid; - } - redirect($u_redirect); - } - - $s_hidden_fields = array( - 'i' => $id, - 'mode' => $mode, - 'action' => array($action => 1), - 'user_id' => $user_id, - 'group_id' => $group_id, - 'forum_id' => $forum_id, - 'type' => $permission_type, - ); - if (isset($_POST['all_users'])) - { - $s_hidden_fields['all_users'] = 1; - } - if (isset($_POST['all_groups'])) - { - $s_hidden_fields['all_groups'] = 1; - } - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields($s_hidden_fields)); - } - break; - - case 'apply_permissions': - if (!isset($_POST['setting'])) - { - send_status_line(403, 'Forbidden'); - trigger_error($user->lang['NO_AUTH_SETTING_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); - } - if (!check_form_key($form_name)) - { - trigger_error($user->lang['FORM_INVALID']. adm_back_link($this->u_action), E_USER_WARNING); - } - - $this->set_permissions($mode, $permission_type, $auth_admin, $user_id, $group_id); - break; - - case 'apply_all_permissions': - if (!isset($_POST['setting'])) - { - send_status_line(403, 'Forbidden'); - trigger_error($user->lang['NO_AUTH_SETTING_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); - } - if (!check_form_key($form_name)) - { - trigger_error($user->lang['FORM_INVALID']. adm_back_link($this->u_action), E_USER_WARNING); - } - - $this->set_all_permissions($mode, $permission_type, $auth_admin, $user_id, $group_id); - break; - } - } - - // Go through the screens/options needed and present them in correct order - foreach ($permission_victim as $victim) - { - switch ($victim) - { - case 'forum_dropdown': - - if (count($forum_id)) - { - $this->check_existence('forum', $forum_id); - continue 2; - } - - $template->assign_vars(array( - 'S_SELECT_FORUM' => true, - 'S_FORUM_OPTIONS' => make_forum_select(false, false, true, false, false)) - ); - - break; - - case 'forums': - - if (count($forum_id)) - { - $this->check_existence('forum', $forum_id); - continue 2; - } - - $forum_list = make_forum_select(false, false, true, false, false, false, true); - - // Build forum options - $s_forum_options = ''; - foreach ($forum_list as $f_id => $f_row) - { - $s_forum_options .= ''; - } - - // Build subforum options - $s_subforum_options = $this->build_subforum_options($forum_list); - - $template->assign_vars(array( - 'S_SELECT_FORUM' => true, - 'S_FORUM_OPTIONS' => $s_forum_options, - 'S_SUBFORUM_OPTIONS' => $s_subforum_options, - 'S_FORUM_ALL' => true, - 'S_FORUM_MULTIPLE' => true) - ); - - break; - - case 'user': - - if (count($user_id)) - { - $this->check_existence('user', $user_id); - continue 2; - } - - $template->assign_vars(array( - 'S_SELECT_USER' => true, - 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=select_victim&field=username&select_single=true'), - )); - - break; - - case 'group': - - if (count($group_id)) - { - $this->check_existence('group', $group_id); - continue 2; - } - - $template->assign_vars(array( - 'S_SELECT_GROUP' => true, - 'S_GROUP_OPTIONS' => group_select_options(false, false, false), // Show all groups - )); - - break; - - case 'usergroup': - case 'usergroup_view': - - $all_users = (isset($_POST['all_users'])) ? true : false; - $all_groups = (isset($_POST['all_groups'])) ? true : false; - - if ((count($user_id) && !$all_users) || (count($group_id) && !$all_groups)) - { - if (count($user_id)) - { - $this->check_existence('user', $user_id); - } - - if (count($group_id)) - { - $this->check_existence('group', $group_id); - } - - continue 2; - } - - // Now we check the users... because the "all"-selection is different here (all defined users/groups) - $items = $this->retrieve_defined_user_groups($permission_scope, $forum_id, $permission_type); - - if ($all_users && count($items['user_ids'])) - { - $user_id = $items['user_ids']; - continue 2; - } - - if ($all_groups && count($items['group_ids'])) - { - $group_id = $items['group_ids']; - continue 2; - } - - $template->assign_vars(array( - 'S_SELECT_USERGROUP' => ($victim == 'usergroup') ? true : false, - 'S_SELECT_USERGROUP_VIEW' => ($victim == 'usergroup_view') ? true : false, - 'S_DEFINED_USER_OPTIONS' => $items['user_ids_options'], - 'S_DEFINED_GROUP_OPTIONS' => $items['group_ids_options'], - 'S_ADD_GROUP_OPTIONS' => group_select_options(false, $items['group_ids'], false), // Show all groups - 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=add_user&field=username&select_single=true'), - )); - - break; - } - - // The S_ALLOW_SELECT parameter below is a measure to lower memory usage. - // If there are more than 5 forums selected the admin is not able to select all users/groups too. - // We need to see if the number of forums can be increased or need to be decreased. - - // Setting permissions screen - $s_hidden_fields = build_hidden_fields(array( - 'user_id' => $user_id, - 'group_id' => $group_id, - 'forum_id' => $forum_id, - 'type' => $permission_type, - )); - - $template->assign_vars(array( - 'U_ACTION' => $this->u_action, - 'ANONYMOUS_USER_ID' => ANONYMOUS, - - 'S_SELECT_VICTIM' => true, - 'S_ALLOW_ALL_SELECT' => (count($forum_id) > 5) ? false : true, - 'S_CAN_SELECT_USER' => ($auth->acl_get('a_authusers')) ? true : false, - 'S_CAN_SELECT_GROUP' => ($auth->acl_get('a_authgroups')) ? true : false, - 'S_HIDDEN_FIELDS' => $s_hidden_fields) - ); - - // Let the forum names being displayed - if (count($forum_id)) - { - $sql = 'SELECT forum_name - FROM ' . FORUMS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $forum_id) . ' - ORDER BY left_id ASC'; - $result = $db->sql_query($sql); - - $forum_names = array(); - while ($row = $db->sql_fetchrow($result)) - { - $forum_names[] = $row['forum_name']; - } - $db->sql_freeresult($result); - - $template->assign_vars(array( - 'S_FORUM_NAMES' => (count($forum_names)) ? true : false, - 'FORUM_NAMES' => implode($user->lang['COMMA_SEPARATOR'], $forum_names)) - ); - } - - return; - } - - // Setting permissions screen - $s_hidden_fields = build_hidden_fields(array( - 'user_id' => $user_id, - 'group_id' => $group_id, - 'forum_id' => $forum_id, - 'type' => $permission_type, - )); - - // Do not allow forum_ids being set and no other setting defined (will bog down the server too much) - if (count($forum_id) && !count($user_id) && !count($group_id)) - { - trigger_error($user->lang['ONLY_FORUM_DEFINED'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - $template->assign_vars(array( - 'S_PERMISSION_DROPDOWN' => (count($this->permission_dropdown) > 1) ? $this->build_permission_dropdown($this->permission_dropdown, $permission_type, $permission_scope) : false, - 'L_PERMISSION_TYPE' => $this->permissions->get_type_lang($permission_type), - - 'U_ACTION' => $this->u_action, - 'S_HIDDEN_FIELDS' => $s_hidden_fields) - ); - - if (strpos($mode, 'setting_') === 0) - { - $template->assign_vars(array( - 'S_SETTING_PERMISSIONS' => true) - ); - - $hold_ary = $auth_admin->get_mask('set', (count($user_id)) ? $user_id : false, (count($group_id)) ? $group_id : false, (count($forum_id)) ? $forum_id : false, $permission_type, $permission_scope, ACL_NO); - $auth_admin->display_mask('set', $permission_type, $hold_ary, ((count($user_id)) ? 'user' : 'group'), (($permission_scope == 'local') ? true : false)); - } - else - { - $template->assign_vars(array( - 'S_VIEWING_PERMISSIONS' => true) - ); - - $hold_ary = $auth_admin->get_mask('view', (count($user_id)) ? $user_id : false, (count($group_id)) ? $group_id : false, (count($forum_id)) ? $forum_id : false, $permission_type, $permission_scope, ACL_NEVER); - $auth_admin->display_mask('view', $permission_type, $hold_ary, ((count($user_id)) ? 'user' : 'group'), (($permission_scope == 'local') ? true : false)); - } - } - - /** - * Build +subforum options - */ - function build_subforum_options($forum_list) - { - global $user; - - $s_options = ''; - - $forum_list = array_merge($forum_list); - - foreach ($forum_list as $key => $row) - { - if ($row['disabled']) - { - continue; - } - - $s_options .= ''; - } - - return $s_options; - } - - /** - * Build dropdown field for changing permission types - */ - function build_permission_dropdown($options, $default_option, $permission_scope) - { - global $auth; - - $s_dropdown_options = ''; - foreach ($options as $setting) - { - if (!$auth->acl_get('a_' . str_replace('_', '', $setting) . 'auth')) - { - continue; - } - - $selected = ($setting == $default_option) ? ' selected="selected"' : ''; - $l_setting = $this->permissions->get_type_lang($setting, $permission_scope); - $s_dropdown_options .= ''; - } - - return $s_dropdown_options; - } - - /** - * Check if selected items exist. Remove not found ids and if empty return error. - */ - function check_existence($mode, &$ids) - { - global $db, $user; - - switch ($mode) - { - case 'user': - $table = USERS_TABLE; - $sql_id = 'user_id'; - break; - - case 'group': - $table = GROUPS_TABLE; - $sql_id = 'group_id'; - break; - - case 'forum': - $table = FORUMS_TABLE; - $sql_id = 'forum_id'; - break; - } - - if (count($ids)) - { - $sql = "SELECT $sql_id - FROM $table - WHERE " . $db->sql_in_set($sql_id, $ids); - $result = $db->sql_query($sql); - - $ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $ids[] = (int) $row[$sql_id]; - } - $db->sql_freeresult($result); - } - - if (!count($ids)) - { - trigger_error($user->lang['SELECTED_' . strtoupper($mode) . '_NOT_EXIST'] . adm_back_link($this->u_action), E_USER_WARNING); - } - } - - /** - * Apply permissions - */ - function set_permissions($mode, $permission_type, $auth_admin, &$user_id, &$group_id) - { - global $db, $cache, $user, $auth; - global $request; - - $psubmit = $request->variable('psubmit', array(0 => array(0 => 0))); - - // User or group to be set? - $ug_type = (count($user_id)) ? 'user' : 'group'; - - // Check the permission setting again - if (!$auth->acl_get('a_' . str_replace('_', '', $permission_type) . 'auth') || !$auth->acl_get('a_auth' . $ug_type . 's')) - { - send_status_line(403, 'Forbidden'); - trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - // We loop through the auth settings defined in our submit - list($ug_id, ) = each($psubmit); - list($forum_id, ) = each($psubmit[$ug_id]); - - $settings = $request->variable('setting', array(0 => array(0 => array('' => 0))), false, \phpbb\request\request_interface::POST); - if (empty($settings) || empty($settings[$ug_id]) || empty($settings[$ug_id][$forum_id])) - { - trigger_error('WRONG_PERMISSION_SETTING_FORMAT', E_USER_WARNING); - } - - $auth_settings = $settings[$ug_id][$forum_id]; - - // Do we have a role we want to set? - $roles = $request->variable('role', array(0 => array(0 => 0)), false, \phpbb\request\request_interface::POST); - $assigned_role = (isset($roles[$ug_id][$forum_id])) ? (int) $roles[$ug_id][$forum_id] : 0; - - // Do the admin want to set these permissions to other items too? - $inherit = $request->variable('inherit', array(0 => array(0))); - - $ug_id = array($ug_id); - $forum_id = array($forum_id); - - if (count($inherit)) - { - foreach ($inherit as $_ug_id => $forum_id_ary) - { - // Inherit users/groups? - if (!in_array($_ug_id, $ug_id)) - { - $ug_id[] = $_ug_id; - } - - // Inherit forums? - $forum_id = array_merge($forum_id, array_keys($forum_id_ary)); - } - } - - $forum_id = array_unique($forum_id); - - // If the auth settings differ from the assigned role, then do not set a role... - if ($assigned_role) - { - if (!$this->check_assigned_role($assigned_role, $auth_settings)) - { - $assigned_role = 0; - } - } - - // Update the permission set... - $auth_admin->acl_set($ug_type, $forum_id, $ug_id, $auth_settings, $assigned_role); - - // Do we need to recache the moderator lists? - if ($permission_type == 'm_') - { - phpbb_cache_moderators($db, $cache, $auth); - } - - // Remove users who are now moderators or admins from everyones foes list - if ($permission_type == 'm_' || $permission_type == 'a_') - { - phpbb_update_foes($db, $auth, $group_id, $user_id); - } - - $this->log_action($mode, 'add', $permission_type, $ug_type, $ug_id, $forum_id); - - meta_refresh(5, $this->u_action); - trigger_error($user->lang['AUTH_UPDATED'] . adm_back_link($this->u_action)); - } - - /** - * Apply all permissions - */ - function set_all_permissions($mode, $permission_type, $auth_admin, &$user_id, &$group_id) - { - global $db, $cache, $user, $auth; - global $request; - - // User or group to be set? - $ug_type = (count($user_id)) ? 'user' : 'group'; - - // Check the permission setting again - if (!$auth->acl_get('a_' . str_replace('_', '', $permission_type) . 'auth') || !$auth->acl_get('a_auth' . $ug_type . 's')) - { - send_status_line(403, 'Forbidden'); - trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - $auth_settings = $request->variable('setting', array(0 => array(0 => array('' => 0))), false, \phpbb\request\request_interface::POST); - $auth_roles = $request->variable('role', array(0 => array(0 => 0)), false, \phpbb\request\request_interface::POST); - $ug_ids = $forum_ids = array(); - - // We need to go through the auth settings - foreach ($auth_settings as $ug_id => $forum_auth_row) - { - $ug_id = (int) $ug_id; - $ug_ids[] = $ug_id; - - foreach ($forum_auth_row as $forum_id => $auth_options) - { - $forum_id = (int) $forum_id; - $forum_ids[] = $forum_id; - - // Check role... - $assigned_role = (isset($auth_roles[$ug_id][$forum_id])) ? (int) $auth_roles[$ug_id][$forum_id] : 0; - - // If the auth settings differ from the assigned role, then do not set a role... - if ($assigned_role) - { - if (!$this->check_assigned_role($assigned_role, $auth_options)) - { - $assigned_role = 0; - } - } - - // Update the permission set... - $auth_admin->acl_set($ug_type, $forum_id, $ug_id, $auth_options, $assigned_role, false); - } - } - - $auth_admin->acl_clear_prefetch(); - - // Do we need to recache the moderator lists? - if ($permission_type == 'm_') - { - phpbb_cache_moderators($db, $cache, $auth); - } - - // Remove users who are now moderators or admins from everyones foes list - if ($permission_type == 'm_' || $permission_type == 'a_') - { - phpbb_update_foes($db, $auth, $group_id, $user_id); - } - - $this->log_action($mode, 'add', $permission_type, $ug_type, $ug_ids, $forum_ids); - - if ($mode == 'setting_forum_local' || $mode == 'setting_mod_local') - { - meta_refresh(5, $this->u_action . '&forum_id[]=' . implode('&forum_id[]=', $forum_ids)); - trigger_error($user->lang['AUTH_UPDATED'] . adm_back_link($this->u_action . '&forum_id[]=' . implode('&forum_id[]=', $forum_ids))); - } - else - { - meta_refresh(5, $this->u_action); - trigger_error($user->lang['AUTH_UPDATED'] . adm_back_link($this->u_action)); - } - } - - /** - * Compare auth settings with auth settings from role - * returns false if they differ, true if they are equal - */ - function check_assigned_role($role_id, &$auth_settings) - { - global $db; - - $sql = 'SELECT o.auth_option, r.auth_setting - FROM ' . ACL_OPTIONS_TABLE . ' o, ' . ACL_ROLES_DATA_TABLE . ' r - WHERE o.auth_option_id = r.auth_option_id - AND r.role_id = ' . $role_id; - $result = $db->sql_query($sql); - - $test_auth_settings = array(); - while ($row = $db->sql_fetchrow($result)) - { - $test_auth_settings[$row['auth_option']] = $row['auth_setting']; - } - $db->sql_freeresult($result); - - // We need to add any ACL_NO setting from auth_settings to compare correctly - foreach ($auth_settings as $option => $setting) - { - if ($setting == ACL_NO) - { - $test_auth_settings[$option] = $setting; - } - } - - if (count(array_diff_assoc($auth_settings, $test_auth_settings))) - { - return false; - } - - return true; - } - - /** - * Remove permissions - */ - function remove_permissions($mode, $permission_type, $auth_admin, &$user_id, &$group_id, &$forum_id) - { - global $user, $db, $cache, $auth; - - // User or group to be set? - $ug_type = (count($user_id)) ? 'user' : 'group'; - - // Check the permission setting again - if (!$auth->acl_get('a_' . str_replace('_', '', $permission_type) . 'auth') || !$auth->acl_get('a_auth' . $ug_type . 's')) - { - send_status_line(403, 'Forbidden'); - trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - $auth_admin->acl_delete($ug_type, (($ug_type == 'user') ? $user_id : $group_id), (count($forum_id) ? $forum_id : false), $permission_type); - - // Do we need to recache the moderator lists? - if ($permission_type == 'm_') - { - phpbb_cache_moderators($db, $cache, $auth); - } - - $this->log_action($mode, 'del', $permission_type, $ug_type, (($ug_type == 'user') ? $user_id : $group_id), (count($forum_id) ? $forum_id : array(0 => 0))); - - if ($mode == 'setting_forum_local' || $mode == 'setting_mod_local') - { - meta_refresh(5, $this->u_action . '&forum_id[]=' . implode('&forum_id[]=', $forum_id)); - trigger_error($user->lang['AUTH_UPDATED'] . adm_back_link($this->u_action . '&forum_id[]=' . implode('&forum_id[]=', $forum_id))); - } - else - { - meta_refresh(5, $this->u_action); - trigger_error($user->lang['AUTH_UPDATED'] . adm_back_link($this->u_action)); - } - } - - /** - * Log permission changes - */ - function log_action($mode, $action, $permission_type, $ug_type, $ug_id, $forum_id) - { - global $db, $user, $phpbb_log, $phpbb_container; - - if (!is_array($ug_id)) - { - $ug_id = array($ug_id); - } - - if (!is_array($forum_id)) - { - $forum_id = array($forum_id); - } - - // Logging ... first grab user or groupnames ... - $sql = ($ug_type == 'group') ? 'SELECT group_name as name, group_type FROM ' . GROUPS_TABLE . ' WHERE ' : 'SELECT username as name FROM ' . USERS_TABLE . ' WHERE '; - $sql .= $db->sql_in_set(($ug_type == 'group') ? 'group_id' : 'user_id', array_map('intval', $ug_id)); - $result = $db->sql_query($sql); - - /** @var \phpbb\group\helper $group_helper */ - $group_helper = $phpbb_container->get('group_helper'); - - $l_ug_list = ''; - while ($row = $db->sql_fetchrow($result)) - { - $group_name = $group_helper->get_name($row['name']); - $l_ug_list .= (($l_ug_list != '') ? ', ' : '') . ((isset($row['group_type']) && $row['group_type'] == GROUP_SPECIAL) ? '' . $group_name . '' : $group_name); - } - $db->sql_freeresult($result); - - $mode = str_replace('setting_', '', $mode); - - if ($forum_id[0] == 0) - { - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ACL_' . strtoupper($action) . '_' . strtoupper($mode) . '_' . strtoupper($permission_type), false, array($l_ug_list)); - } - else - { - // Grab the forum details if non-zero forum_id - $sql = 'SELECT forum_name - FROM ' . FORUMS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $forum_id); - $result = $db->sql_query($sql); - - $l_forum_list = ''; - while ($row = $db->sql_fetchrow($result)) - { - $l_forum_list .= (($l_forum_list != '') ? ', ' : '') . $row['forum_name']; - } - $db->sql_freeresult($result); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ACL_' . strtoupper($action) . '_' . strtoupper($mode) . '_' . strtoupper($permission_type), false, array($l_forum_list, $l_ug_list)); - } - } - - /** - * Display a complete trace tree for the selected permission to determine where settings are set/unset - */ - function permission_trace($user_id, $forum_id, $permission) - { - global $db, $template, $user, $auth, $request, $phpbb_container; - - if ($user_id != $user->data['user_id']) - { - $userdata = $auth->obtain_user_data($user_id); - } - else - { - $userdata = $user->data; - } - - if (!$userdata) - { - trigger_error('NO_USERS', E_USER_ERROR); - } - - /** @var \phpbb\group\helper $group_helper */ - $group_helper = $phpbb_container->get('group_helper'); - - $forum_name = false; - - if ($forum_id) - { - $sql = 'SELECT forum_name - FROM ' . FORUMS_TABLE . " - WHERE forum_id = $forum_id"; - $result = $db->sql_query($sql, 3600); - $forum_name = $db->sql_fetchfield('forum_name'); - $db->sql_freeresult($result); - } - - $back = $request->variable('back', 0); - - $template->assign_vars(array( - 'PERMISSION' => $this->permissions->get_permission_lang($permission), - 'PERMISSION_USERNAME' => $userdata['username'], - 'FORUM_NAME' => $forum_name, - - 'S_GLOBAL_TRACE' => ($forum_id) ? false : true, - - 'U_BACK' => ($back) ? build_url(array('f', 'back')) . "&f=$back" : '') - ); - - $template->assign_block_vars('trace', array( - 'WHO' => $user->lang['DEFAULT'], - 'INFORMATION' => $user->lang['TRACE_DEFAULT'], - - 'S_SETTING_NO' => true, - 'S_TOTAL_NO' => true) - ); - - $sql = 'SELECT DISTINCT g.group_name, g.group_id, g.group_type - FROM ' . GROUPS_TABLE . ' g - LEFT JOIN ' . USER_GROUP_TABLE . ' ug ON (ug.group_id = g.group_id) - WHERE ug.user_id = ' . $user_id . ' - AND ug.user_pending = 0 - AND NOT (ug.group_leader = 1 AND g.group_skip_auth = 1) - ORDER BY g.group_type DESC, g.group_id DESC'; - $result = $db->sql_query($sql); - - $groups = array(); - while ($row = $db->sql_fetchrow($result)) - { - $groups[$row['group_id']] = array( - 'auth_setting' => ACL_NO, - 'group_name' => $group_helper->get_name($row['group_name']), - ); - } - $db->sql_freeresult($result); - - $total = ACL_NO; - $add_key = (($forum_id) ? '_LOCAL' : ''); - - if (count($groups)) - { - // Get group auth settings - $hold_ary = $auth->acl_group_raw_data(array_keys($groups), $permission, $forum_id); - - foreach ($hold_ary as $group_id => $forum_ary) - { - $groups[$group_id]['auth_setting'] = $hold_ary[$group_id][$forum_id][$permission]; - } - unset($hold_ary); - - foreach ($groups as $id => $row) - { - switch ($row['auth_setting']) - { - case ACL_NO: - $information = $user->lang['TRACE_GROUP_NO' . $add_key]; - break; - - case ACL_YES: - $information = ($total == ACL_YES) ? $user->lang['TRACE_GROUP_YES_TOTAL_YES' . $add_key] : (($total == ACL_NEVER) ? $user->lang['TRACE_GROUP_YES_TOTAL_NEVER' . $add_key] : $user->lang['TRACE_GROUP_YES_TOTAL_NO' . $add_key]); - $total = ($total == ACL_NO) ? ACL_YES : $total; - break; - - case ACL_NEVER: - $information = ($total == ACL_YES) ? $user->lang['TRACE_GROUP_NEVER_TOTAL_YES' . $add_key] : (($total == ACL_NEVER) ? $user->lang['TRACE_GROUP_NEVER_TOTAL_NEVER' . $add_key] : $user->lang['TRACE_GROUP_NEVER_TOTAL_NO' . $add_key]); - $total = ACL_NEVER; - break; - } - - $template->assign_block_vars('trace', array( - 'WHO' => $row['group_name'], - 'INFORMATION' => $information, - - 'S_SETTING_NO' => ($row['auth_setting'] == ACL_NO) ? true : false, - 'S_SETTING_YES' => ($row['auth_setting'] == ACL_YES) ? true : false, - 'S_SETTING_NEVER' => ($row['auth_setting'] == ACL_NEVER) ? true : false, - 'S_TOTAL_NO' => ($total == ACL_NO) ? true : false, - 'S_TOTAL_YES' => ($total == ACL_YES) ? true : false, - 'S_TOTAL_NEVER' => ($total == ACL_NEVER) ? true : false) - ); - } - } - - // Get user specific permission... globally or for this forum - $hold_ary = $auth->acl_user_raw_data($user_id, $permission, $forum_id); - $auth_setting = (!count($hold_ary)) ? ACL_NO : $hold_ary[$user_id][$forum_id][$permission]; - - switch ($auth_setting) - { - case ACL_NO: - $information = ($total == ACL_NO) ? $user->lang['TRACE_USER_NO_TOTAL_NO' . $add_key] : $user->lang['TRACE_USER_KEPT' . $add_key]; - $total = ($total == ACL_NO) ? ACL_NEVER : $total; - break; - - case ACL_YES: - $information = ($total == ACL_YES) ? $user->lang['TRACE_USER_YES_TOTAL_YES' . $add_key] : (($total == ACL_NEVER) ? $user->lang['TRACE_USER_YES_TOTAL_NEVER' . $add_key] : $user->lang['TRACE_USER_YES_TOTAL_NO' . $add_key]); - $total = ($total == ACL_NO) ? ACL_YES : $total; - break; - - case ACL_NEVER: - $information = ($total == ACL_YES) ? $user->lang['TRACE_USER_NEVER_TOTAL_YES' . $add_key] : (($total == ACL_NEVER) ? $user->lang['TRACE_USER_NEVER_TOTAL_NEVER' . $add_key] : $user->lang['TRACE_USER_NEVER_TOTAL_NO' . $add_key]); - $total = ACL_NEVER; - break; - } - - $template->assign_block_vars('trace', array( - 'WHO' => $userdata['username'], - 'INFORMATION' => $information, - - 'S_SETTING_NO' => ($auth_setting == ACL_NO) ? true : false, - 'S_SETTING_YES' => ($auth_setting == ACL_YES) ? true : false, - 'S_SETTING_NEVER' => ($auth_setting == ACL_NEVER) ? true : false, - 'S_TOTAL_NO' => false, - 'S_TOTAL_YES' => ($total == ACL_YES) ? true : false, - 'S_TOTAL_NEVER' => ($total == ACL_NEVER) ? true : false) - ); - - if ($forum_id != 0 && isset($auth->acl_options['global'][$permission])) - { - if ($user_id != $user->data['user_id']) - { - $auth2 = new \phpbb\auth\auth(); - $auth2->acl($userdata); - $auth_setting = $auth2->acl_get($permission); - } - else - { - $auth_setting = $auth->acl_get($permission); - } - - if ($auth_setting) - { - $information = ($total == ACL_YES) ? $user->lang['TRACE_USER_GLOBAL_YES_TOTAL_YES'] : $user->lang['TRACE_USER_GLOBAL_YES_TOTAL_NEVER']; - $total = ACL_YES; - } - else - { - $information = $user->lang['TRACE_USER_GLOBAL_NEVER_TOTAL_KEPT']; - } - - // If there is no auth information we do not need to worry the user by showing non-relevant data. - if ($auth_setting) - { - $template->assign_block_vars('trace', array( - 'WHO' => sprintf($user->lang['TRACE_GLOBAL_SETTING'], $userdata['username']), - 'INFORMATION' => sprintf($information, '", ''), - - 'S_SETTING_NO' => false, - 'S_SETTING_YES' => $auth_setting, - 'S_SETTING_NEVER' => !$auth_setting, - 'S_TOTAL_NO' => false, - 'S_TOTAL_YES' => ($total == ACL_YES) ? true : false, - 'S_TOTAL_NEVER' => ($total == ACL_NEVER) ? true : false) - ); - } - } - - // Take founder status into account, overwriting the default values - if ($userdata['user_type'] == USER_FOUNDER && strpos($permission, 'a_') === 0) - { - $template->assign_block_vars('trace', array( - 'WHO' => $userdata['username'], - 'INFORMATION' => $user->lang['TRACE_USER_FOUNDER'], - - 'S_SETTING_NO' => ($auth_setting == ACL_NO) ? true : false, - 'S_SETTING_YES' => ($auth_setting == ACL_YES) ? true : false, - 'S_SETTING_NEVER' => ($auth_setting == ACL_NEVER) ? true : false, - 'S_TOTAL_NO' => false, - 'S_TOTAL_YES' => true, - 'S_TOTAL_NEVER' => false) - ); - - $total = ACL_YES; - } - - // Total value... - $template->assign_vars(array( - 'S_RESULT_NO' => ($total == ACL_NO) ? true : false, - 'S_RESULT_YES' => ($total == ACL_YES) ? true : false, - 'S_RESULT_NEVER' => ($total == ACL_NEVER) ? true : false, - )); - } - - /** - * Handles copying permissions from one forum to others - */ - function copy_forum_permissions() - { - global $db, $auth, $cache, $template, $user, $request; - - $user->add_lang('acp/forums'); - - $submit = isset($_POST['submit']) ? true : false; - - if ($submit) - { - $src = $request->variable('src_forum_id', 0); - $dest = $request->variable('dest_forum_ids', array(0)); - - if (confirm_box(true)) - { - if (copy_forum_permissions($src, $dest)) - { - phpbb_cache_moderators($db, $cache, $auth); - - $auth->acl_clear_prefetch(); - $cache->destroy('sql', FORUMS_TABLE); - - trigger_error($user->lang['AUTH_UPDATED'] . adm_back_link($this->u_action)); - } - else - { - trigger_error($user->lang['SELECTED_FORUM_NOT_EXIST'] . adm_back_link($this->u_action), E_USER_WARNING); - } - } - else - { - $s_hidden_fields = array( - 'submit' => $submit, - 'src_forum_id' => $src, - 'dest_forum_ids' => $dest, - ); - - $s_hidden_fields = build_hidden_fields($s_hidden_fields); - - confirm_box(false, $user->lang['COPY_PERMISSIONS_CONFIRM'], $s_hidden_fields); - } - } - - $template->assign_vars(array( - 'S_FORUM_OPTIONS' => make_forum_select(false, false, false, false, false), - )); - } - - /** - * Get already assigned users/groups - */ - function retrieve_defined_user_groups($permission_scope, $forum_id, $permission_type) - { - global $db, $phpbb_container; - - /** @var \phpbb\group\helper $group_helper */ - $group_helper = $phpbb_container->get('group_helper'); - - $sql_forum_id = ($permission_scope == 'global') ? 'AND a.forum_id = 0' : ((count($forum_id)) ? 'AND ' . $db->sql_in_set('a.forum_id', $forum_id) : 'AND a.forum_id <> 0'); - - // Permission options are only able to be a permission set... therefore we will pre-fetch the possible options and also the possible roles - $option_ids = $role_ids = array(); - - $sql = 'SELECT auth_option_id - FROM ' . ACL_OPTIONS_TABLE . ' - WHERE auth_option ' . $db->sql_like_expression($permission_type . $db->get_any_char()); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $option_ids[] = (int) $row['auth_option_id']; - } - $db->sql_freeresult($result); - - if (count($option_ids)) - { - $sql = 'SELECT DISTINCT role_id - FROM ' . ACL_ROLES_DATA_TABLE . ' - WHERE ' . $db->sql_in_set('auth_option_id', $option_ids); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $role_ids[] = (int) $row['role_id']; - } - $db->sql_freeresult($result); - } - - if (count($option_ids) && count($role_ids)) - { - $sql_where = 'AND (' . $db->sql_in_set('a.auth_option_id', $option_ids) . ' OR ' . $db->sql_in_set('a.auth_role_id', $role_ids) . ')'; - } - else if (count($role_ids)) - { - $sql_where = 'AND ' . $db->sql_in_set('a.auth_role_id', $role_ids); - } - else if (count($option_ids)) - { - $sql_where = 'AND ' . $db->sql_in_set('a.auth_option_id', $option_ids); - } - - // Not ideal, due to the filesort, non-use of indexes, etc. - $sql = 'SELECT DISTINCT u.user_id, u.username, u.username_clean, u.user_regdate - FROM ' . USERS_TABLE . ' u, ' . ACL_USERS_TABLE . " a - WHERE u.user_id = a.user_id - $sql_forum_id - $sql_where - ORDER BY u.username_clean, u.user_regdate ASC"; - $result = $db->sql_query($sql); - - $s_defined_user_options = ''; - $defined_user_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $s_defined_user_options .= ''; - $defined_user_ids[] = $row['user_id']; - } - $db->sql_freeresult($result); - - $sql = 'SELECT DISTINCT g.group_type, g.group_name, g.group_id - FROM ' . GROUPS_TABLE . ' g, ' . ACL_GROUPS_TABLE . " a - WHERE g.group_id = a.group_id - $sql_forum_id - $sql_where - ORDER BY g.group_type DESC, g.group_name ASC"; - $result = $db->sql_query($sql); - - $s_defined_group_options = ''; - $defined_group_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $s_defined_group_options .= '' . $group_helper->get_name($row['group_name']) . ''; - $defined_group_ids[] = $row['group_id']; - } - $db->sql_freeresult($result); - - return array( - 'group_ids' => $defined_group_ids, - 'group_ids_options' => $s_defined_group_options, - 'user_ids' => $defined_user_ids, - 'user_ids_options' => $s_defined_user_options - ); - } -} diff --git a/install/update/old/includes/acp/acp_prune.php b/install/update/old/includes/acp/acp_prune.php deleted file mode 100644 index 3eee4f7..0000000 --- a/install/update/old/includes/acp/acp_prune.php +++ /dev/null @@ -1,587 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -class acp_prune -{ - var $u_action; - - function main($id, $mode) - { - global $user, $phpEx, $phpbb_root_path; - - $user->add_lang('acp/prune'); - - if (!function_exists('user_active_flip')) - { - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - } - - switch ($mode) - { - case 'forums': - $this->tpl_name = 'acp_prune_forums'; - $this->page_title = 'ACP_PRUNE_FORUMS'; - $this->prune_forums($id, $mode); - break; - - case 'users': - $this->tpl_name = 'acp_prune_users'; - $this->page_title = 'ACP_PRUNE_USERS'; - $this->prune_users($id, $mode); - break; - } - } - - /** - * Prune forums - */ - function prune_forums($id, $mode) - { - global $db, $user, $auth, $template, $phpbb_log, $request, $phpbb_dispatcher; - - $all_forums = $request->variable('all_forums', 0); - $forum_id = $request->variable('f', array(0)); - $submit = (isset($_POST['submit'])) ? true : false; - - if ($all_forums) - { - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE . ' - ORDER BY left_id'; - $result = $db->sql_query($sql); - - $forum_id = array(); - while ($row = $db->sql_fetchrow($result)) - { - $forum_id[] = $row['forum_id']; - } - $db->sql_freeresult($result); - } - - if ($submit) - { - if (confirm_box(true)) - { - $prune_posted = $request->variable('prune_days', 0); - $prune_viewed = $request->variable('prune_vieweddays', 0); - $prune_all = (!$prune_posted && !$prune_viewed) ? true : false; - - $prune_flags = 0; - $prune_flags += ($request->variable('prune_old_polls', 0)) ? 2 : 0; - $prune_flags += ($request->variable('prune_announce', 0)) ? 4 : 0; - $prune_flags += ($request->variable('prune_sticky', 0)) ? 8 : 0; - - // Convert days to seconds for timestamp functions... - $prunedate_posted = time() - ($prune_posted * 86400); - $prunedate_viewed = time() - ($prune_viewed * 86400); - - $template->assign_vars(array( - 'S_PRUNED' => true) - ); - - $sql_forum = (count($forum_id)) ? ' AND ' . $db->sql_in_set('forum_id', $forum_id) : ''; - - // Get a list of forum's or the data for the forum that we are pruning. - $sql = 'SELECT forum_id, forum_name - FROM ' . FORUMS_TABLE . ' - WHERE forum_type = ' . FORUM_POST . " - $sql_forum - ORDER BY left_id ASC"; - $result = $db->sql_query($sql); - - if ($row = $db->sql_fetchrow($result)) - { - $prune_ids = array(); - $p_result['topics'] = 0; - $p_result['posts'] = 0; - $log_data = ''; - - do - { - if (!$auth->acl_get('f_list', $row['forum_id'])) - { - continue; - } - - if ($prune_all) - { - $p_result = prune($row['forum_id'], 'posted', time(), $prune_flags, false); - } - else - { - if ($prune_posted) - { - $return = prune($row['forum_id'], 'posted', $prunedate_posted, $prune_flags, false); - $p_result['topics'] += $return['topics']; - $p_result['posts'] += $return['posts']; - } - - if ($prune_viewed) - { - $return = prune($row['forum_id'], 'viewed', $prunedate_viewed, $prune_flags, false); - $p_result['topics'] += $return['topics']; - $p_result['posts'] += $return['posts']; - } - } - - $prune_ids[] = $row['forum_id']; - - $template->assign_block_vars('pruned', array( - 'FORUM_NAME' => $row['forum_name'], - 'NUM_TOPICS' => $p_result['topics'], - 'NUM_POSTS' => $p_result['posts']) - ); - - $log_data .= (($log_data != '') ? ', ' : '') . $row['forum_name']; - } - while ($row = $db->sql_fetchrow($result)); - - // Sync all pruned forums at once - sync('forum', 'forum_id', $prune_ids, true, true); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_PRUNE', false, array($log_data)); - } - $db->sql_freeresult($result); - - return; - } - else - { - $hidden_fields = array( - 'i' => $id, - 'mode' => $mode, - 'submit' => 1, - 'all_forums' => $all_forums, - 'f' => $forum_id, - - 'prune_days' => $request->variable('prune_days', 0), - 'prune_vieweddays' => $request->variable('prune_vieweddays', 0), - 'prune_old_polls' => $request->variable('prune_old_polls', 0), - 'prune_announce' => $request->variable('prune_announce', 0), - 'prune_sticky' => $request->variable('prune_sticky', 0), - ); - - /** - * Use this event to pass data from the prune form to the confirmation screen - * - * @event core.prune_forums_settings_confirm - * @var array hidden_fields Hidden fields that are passed through the confirm screen - * @since 3.2.2-RC1 - */ - $vars = array('hidden_fields'); - extract($phpbb_dispatcher->trigger_event('core.prune_forums_settings_confirm', compact($vars))); - - confirm_box(false, $user->lang['PRUNE_FORUM_CONFIRM'], build_hidden_fields($hidden_fields)); - } - } - - // If they haven't selected a forum for pruning yet then - // display a select box to use for pruning. - if (!count($forum_id)) - { - $template->assign_vars(array( - 'U_ACTION' => $this->u_action, - 'S_SELECT_FORUM' => true, - 'S_FORUM_OPTIONS' => make_forum_select(false, false, false)) - ); - } - else - { - $sql = 'SELECT forum_id, forum_name - FROM ' . FORUMS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $forum_id); - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - - if (!$row) - { - $db->sql_freeresult($result); - trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - $forum_list = $s_hidden_fields = ''; - do - { - $forum_list .= (($forum_list != '') ? ', ' : '') . '' . $row['forum_name'] . ''; - $s_hidden_fields .= ''; - } - while ($row = $db->sql_fetchrow($result)); - - $db->sql_freeresult($result); - - $l_selected_forums = (count($forum_id) == 1) ? 'SELECTED_FORUM' : 'SELECTED_FORUMS'; - - $template_data = array( - 'L_SELECTED_FORUMS' => $user->lang[$l_selected_forums], - 'U_ACTION' => $this->u_action, - 'U_BACK' => $this->u_action, - 'FORUM_LIST' => $forum_list, - 'S_HIDDEN_FIELDS' => $s_hidden_fields, - ); - - /** - * Event to add/modify prune forums settings template data - * - * @event core.prune_forums_settings_template_data - * @var array template_data Array with form template data - * @since 3.2.2-RC1 - */ - $vars = array('template_data'); - extract($phpbb_dispatcher->trigger_event('core.prune_forums_settings_template_data', compact($vars))); - - $template->assign_vars($template_data); - } - } - - /** - * Prune users - */ - function prune_users($id, $mode) - { - global $db, $user, $auth, $template, $phpbb_log, $request; - global $phpbb_root_path, $phpbb_admin_path, $phpEx, $phpbb_container; - - /** @var \phpbb\group\helper $group_helper */ - $group_helper = $phpbb_container->get('group_helper'); - - $user->add_lang('memberlist'); - - $prune = (isset($_POST['prune'])) ? true : false; - - if ($prune) - { - $action = $request->variable('action', 'deactivate'); - $deleteposts = $request->variable('deleteposts', 0); - - if (confirm_box(true)) - { - $user_ids = $usernames = array(); - - $this->get_prune_users($user_ids, $usernames); - if (count($user_ids)) - { - if ($action == 'deactivate') - { - user_active_flip('deactivate', $user_ids); - $l_log = 'LOG_PRUNE_USER_DEAC'; - } - else if ($action == 'delete') - { - if ($deleteposts) - { - user_delete('remove', $user_ids); - - $l_log = 'LOG_PRUNE_USER_DEL_DEL'; - } - else - { - user_delete('retain', $user_ids, true); - - $l_log = 'LOG_PRUNE_USER_DEL_ANON'; - } - } - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, $l_log, false, array(implode(', ', $usernames))); - $msg = $user->lang['USER_' . strtoupper($action) . '_SUCCESS']; - } - else - { - $msg = $user->lang['USER_PRUNE_FAILURE']; - } - - trigger_error($msg . adm_back_link($this->u_action)); - } - else - { - // We list the users which will be pruned... - $user_ids = $usernames = array(); - $this->get_prune_users($user_ids, $usernames); - - if (!count($user_ids)) - { - trigger_error($user->lang['USER_PRUNE_FAILURE'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - // Assign to template - foreach ($user_ids as $user_id) - { - $template->assign_block_vars('users', array( - 'USERNAME' => $usernames[$user_id], - 'USER_ID' => $user_id, - 'U_PROFILE' => get_username_string('profile', $user_id, $usernames[$user_id]), - 'U_USER_ADMIN' => ($auth->acl_get('a_user')) ? append_sid("{$phpbb_admin_path}index.$phpEx", 'i=users&mode=overview&u=' . $user_id, true, $user->session_id) : '', - )); - } - - $template->assign_vars(array( - 'S_DEACTIVATE' => ($action == 'deactivate') ? true : false, - 'S_DELETE' => ($action == 'delete') ? true : false, - )); - - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( - 'i' => $id, - 'mode' => $mode, - 'prune' => 1, - - 'deleteposts' => $request->variable('deleteposts', 0), - 'action' => $request->variable('action', ''), - )), 'confirm_body_prune.html'); - } - } - - $find_count = array('lt' => $user->lang['LESS_THAN'], 'eq' => $user->lang['EQUAL_TO'], 'gt' => $user->lang['MORE_THAN']); - $s_find_count = ''; - - foreach ($find_count as $key => $value) - { - $selected = ($key == 'eq') ? ' selected="selected"' : ''; - $s_find_count .= ''; - } - - $find_time = array('lt' => $user->lang['BEFORE'], 'gt' => $user->lang['AFTER']); - $s_find_active_time = ''; - foreach ($find_time as $key => $value) - { - $s_find_active_time .= ''; - } - - $sql = 'SELECT group_id, group_name - FROM ' . GROUPS_TABLE . ' - WHERE group_type <> ' . GROUP_SPECIAL . ' - ORDER BY group_name ASC'; - $result = $db->sql_query($sql); - - $s_group_list = ''; - while ($row = $db->sql_fetchrow($result)) - { - $s_group_list .= ''; - } - $db->sql_freeresult($result); - - if ($s_group_list) - { - // Only prepend the "All groups" option if there are groups, - // otherwise we don't want to display this option at all. - $s_group_list = '' . $s_group_list; - } - - $template->assign_vars(array( - 'U_ACTION' => $this->u_action, - 'S_ACTIVE_OPTIONS' => $s_find_active_time, - 'S_GROUP_LIST' => $s_group_list, - 'S_COUNT_OPTIONS' => $s_find_count, - 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=acp_prune&field=users'), - )); - } - - /** - * Get user_ids/usernames from those being pruned - */ - function get_prune_users(&$user_ids, &$usernames) - { - global $user, $db, $request; - - $users_by_name = $request->variable('users', '', true); - $users_by_id = $request->variable('user_ids', array(0)); - $group_id = $request->variable('group_id', 0); - $posts_on_queue = (trim($request->variable('posts_on_queue', '')) === '') ? false : $request->variable('posts_on_queue', 0); - - if ($users_by_name) - { - $users = explode("\n", $users_by_name); - $where_sql = ' AND ' . $db->sql_in_set('username_clean', array_map('utf8_clean_string', $users)); - } - else if (!empty($users_by_id)) - { - $user_ids = $users_by_id; - user_get_id_name($user_ids, $usernames); - - $where_sql = ' AND ' . $db->sql_in_set('user_id', $user_ids); - } - else - { - $username = $request->variable('username', '', true); - $email = $request->variable('email', ''); - - $active_select = $request->variable('active_select', 'lt'); - $count_select = $request->variable('count_select', 'eq'); - $queue_select = $request->variable('queue_select', 'gt'); - $joined_before = $request->variable('joined_before', ''); - $joined_after = $request->variable('joined_after', ''); - $active = $request->variable('active', ''); - - $count = ($request->variable('count', '') === '') ? false : $request->variable('count', 0); - - $active = ($active) ? explode('-', $active) : array(); - $joined_before = ($joined_before) ? explode('-', $joined_before) : array(); - $joined_after = ($joined_after) ? explode('-', $joined_after) : array(); - - // calculate the conditions required by the join time criteria - $joined_sql = ''; - if (!empty($joined_before) && !empty($joined_after)) - { - // if the two entered dates are equal, we need to adjust - // so that our time range is a full day instead of 1 second - if ($joined_after == $joined_before) - { - $joined_after[2] += 1; - } - - $joined_sql = ' AND user_regdate BETWEEN ' . gmmktime(0, 0, 0, (int) $joined_after[1], (int) $joined_after[2], (int) $joined_after[0]) . - ' AND ' . gmmktime(0, 0, 0, (int) $joined_before[1], (int) $joined_before[2], (int) $joined_before[0]); - } - else if (empty($joined_before) && !empty($joined_after)) - { - $joined_sql = ' AND user_regdate > ' . gmmktime(0, 0, 0, (int) $joined_after[1], (int) $joined_after[2], (int) $joined_after[0]); - } - else if (empty($joined_after) && !empty($joined_before)) - { - $joined_sql = ' AND user_regdate < ' . gmmktime(0, 0, 0, (int) $joined_before[1], (int) $joined_before[2], (int) $joined_before[0]); - } - // implicit else when both arrays are empty do nothing - - if ((count($active) && count($active) != 3) || (count($joined_before) && count($joined_before) != 3) || (count($joined_after) && count($joined_after) != 3)) - { - trigger_error($user->lang['WRONG_ACTIVE_JOINED_DATE'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - $key_match = array('lt' => '<', 'gt' => '>', 'eq' => '='); - - $where_sql = ''; - $where_sql .= ($username) ? ' AND username_clean ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), utf8_clean_string($username))) : ''; - $where_sql .= ($email) ? ' AND user_email ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), $email)) . ' ' : ''; - $where_sql .= $joined_sql; - $where_sql .= ($count !== false) ? " AND user_posts " . $key_match[$count_select] . ' ' . (int) $count . ' ' : ''; - - // First handle pruning of users who never logged in, last active date is 0000-00-00 - if (count($active) && (int) $active[0] == 0 && (int) $active[1] == 0 && (int) $active[2] == 0) - { - $where_sql .= ' AND user_lastvisit = 0'; - } - else if (count($active) && $active_select != 'lt') - { - $where_sql .= ' AND user_lastvisit ' . $key_match[$active_select] . ' ' . gmmktime(0, 0, 0, (int) $active[1], (int) $active[2], (int) $active[0]); - } - else if (count($active)) - { - $where_sql .= ' AND (user_lastvisit > 0 AND user_lastvisit < ' . gmmktime(0, 0, 0, (int) $active[1], (int) $active[2], (int) $active[0]) . ')'; - } - } - - // If no search criteria were provided, go no further. - if (!$where_sql && !$group_id && $posts_on_queue === false) - { - return; - } - - // Get bot ids - $sql = 'SELECT user_id - FROM ' . BOTS_TABLE; - $result = $db->sql_query($sql); - - $bot_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $bot_ids[] = $row['user_id']; - } - $db->sql_freeresult($result); - - // Protect the admin, do not prune if no options are given... - if ($where_sql) - { - // Do not prune founder members - $sql = 'SELECT user_id, username - FROM ' . USERS_TABLE . ' - WHERE user_id <> ' . ANONYMOUS . ' - AND user_type <> ' . USER_FOUNDER . " - $where_sql"; - $result = $db->sql_query($sql); - - $user_ids = $usernames = array(); - - while ($row = $db->sql_fetchrow($result)) - { - // Do not prune bots and the user currently pruning. - if ($row['user_id'] != $user->data['user_id'] && !in_array($row['user_id'], $bot_ids)) - { - $user_ids[] = $row['user_id']; - $usernames[$row['user_id']] = $row['username']; - } - } - $db->sql_freeresult($result); - } - - if ($group_id) - { - $sql = 'SELECT u.user_id, u.username - FROM ' . USER_GROUP_TABLE . ' ug, ' . USERS_TABLE . ' u - WHERE ug.group_id = ' . (int) $group_id . ' - AND ug.user_id <> ' . ANONYMOUS . ' - AND u.user_type <> ' . USER_FOUNDER . ' - AND ug.user_pending = 0 - AND u.user_id = ug.user_id - ' . (!empty($user_ids) ? ' AND ' . $db->sql_in_set('ug.user_id', $user_ids) : ''); - $result = $db->sql_query($sql); - - // we're performing an intersection operation, so all the relevant users - // come from this most recent query (which was limited to the results of the - // previous query) - $user_ids = $usernames = array(); - while ($row = $db->sql_fetchrow($result)) - { - // Do not prune bots and the user currently pruning. - if ($row['user_id'] != $user->data['user_id'] && !in_array($row['user_id'], $bot_ids)) - { - $user_ids[] = $row['user_id']; - $usernames[$row['user_id']] = $row['username']; - } - } - $db->sql_freeresult($result); - } - - if ($posts_on_queue !== false) - { - $sql = 'SELECT u.user_id, u.username, COUNT(p.post_id) AS queue_posts - FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u - WHERE u.user_id <> ' . ANONYMOUS . ' - AND u.user_type <> ' . USER_FOUNDER . ' - AND ' . $db->sql_in_set('p.post_visibility', array(ITEM_UNAPPROVED, ITEM_REAPPROVE)) . ' - AND u.user_id = p.poster_id - ' . (!empty($user_ids) ? ' AND ' . $db->sql_in_set('p.poster_id', $user_ids) : '') . ' - GROUP BY p.poster_id - HAVING queue_posts ' . $key_match[$queue_select] . ' ' . $posts_on_queue; - $result = $db->sql_query($sql); - - // same intersection logic as the above group ID portion - $user_ids = $usernames = array(); - while ($row = $db->sql_fetchrow($result)) - { - // Do not prune bots and the user currently pruning. - if ($row['user_id'] != $user->data['user_id'] && !in_array($row['user_id'], $bot_ids)) - { - $user_ids[] = $row['user_id']; - $usernames[$row['user_id']] = $row['username']; - } - } - $db->sql_freeresult($result); - } - } -} diff --git a/install/update/old/includes/acp/acp_reasons.php b/install/update/old/includes/acp/acp_reasons.php deleted file mode 100644 index dfb2ccb..0000000 --- a/install/update/old/includes/acp/acp_reasons.php +++ /dev/null @@ -1,394 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -class acp_reasons -{ - var $u_action; - - function main($id, $mode) - { - global $db, $user, $template; - global $request, $phpbb_log; - - $user->add_lang(array('mcp', 'acp/posting')); - - // Set up general vars - $action = $request->variable('action', ''); - $submit = (isset($_POST['submit'])) ? true : false; - $reason_id = $request->variable('id', 0); - - $this->tpl_name = 'acp_reasons'; - $this->page_title = 'ACP_REASONS'; - - $form_name = 'acp_reason'; - add_form_key('acp_reason'); - - $error = array(); - - switch ($action) - { - case 'add': - case 'edit': - - $reason_row = array( - 'reason_title' => $request->variable('reason_title', '', true), - 'reason_description' => $request->variable('reason_description', '', true), - ); - - if ($submit) - { - if (!check_form_key($form_name)) - { - $error[] = $user->lang['FORM_INVALID']; - } - // Reason specified? - if (!$reason_row['reason_title'] || !$reason_row['reason_description']) - { - $error[] = $user->lang['NO_REASON_INFO']; - } - - $check_double = ($action == 'add') ? true : false; - - if ($action == 'edit') - { - $sql = 'SELECT reason_title - FROM ' . REPORTS_REASONS_TABLE . " - WHERE reason_id = $reason_id"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (strtolower($row['reason_title']) == 'other' || strtolower($reason_row['reason_title']) == 'other') - { - $reason_row['reason_title'] = 'other'; - } - - if ($row['reason_title'] != $reason_row['reason_title']) - { - $check_double = true; - } - } - - // Check for same reason if adding it... - if ($check_double) - { - $sql = 'SELECT reason_id - FROM ' . REPORTS_REASONS_TABLE . " - WHERE reason_title = '" . $db->sql_escape($reason_row['reason_title']) . "'"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row || ($action == 'add' && strtolower($reason_row['reason_title']) == 'other')) - { - $error[] = $user->lang['REASON_ALREADY_EXIST']; - } - } - - if (!count($error)) - { - // New reason? - if ($action == 'add') - { - // Get new order... - $sql = 'SELECT MAX(reason_order) as max_reason_order - FROM ' . REPORTS_REASONS_TABLE; - $result = $db->sql_query($sql); - $max_order = (int) $db->sql_fetchfield('max_reason_order'); - $db->sql_freeresult($result); - - $sql_ary = array( - 'reason_title' => (string) $reason_row['reason_title'], - 'reason_description' => (string) $reason_row['reason_description'], - 'reason_order' => $max_order + 1 - ); - - $db->sql_query('INSERT INTO ' . REPORTS_REASONS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); - - $log = 'ADDED'; - } - else if ($reason_id) - { - $sql_ary = array( - 'reason_title' => (string) $reason_row['reason_title'], - 'reason_description' => (string) $reason_row['reason_description'], - ); - - $db->sql_query('UPDATE ' . REPORTS_REASONS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE reason_id = ' . $reason_id); - - $log = 'UPDATED'; - } - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_REASON_' . $log, false, array($reason_row['reason_title'])); - trigger_error($user->lang['REASON_' . $log] . adm_back_link($this->u_action)); - } - } - else if ($reason_id) - { - $sql = 'SELECT * - FROM ' . REPORTS_REASONS_TABLE . ' - WHERE reason_id = ' . $reason_id; - $result = $db->sql_query($sql); - $reason_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$reason_row) - { - trigger_error($user->lang['NO_REASON'] . adm_back_link($this->u_action), E_USER_WARNING); - } - } - - $l_title = ($action == 'edit') ? 'EDIT' : 'ADD'; - - $translated = false; - - // If the reason is defined within the language file, we will use the localized version, else just use the database entry... - if (isset($user->lang['report_reasons']['TITLE'][strtoupper($reason_row['reason_title'])]) && isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($reason_row['reason_title'])])) - { - $translated = true; - } - - $template->assign_vars(array( - 'L_TITLE' => $user->lang['REASON_' . $l_title], - 'U_ACTION' => $this->u_action . "&id=$reason_id&action=$action", - 'U_BACK' => $this->u_action, - 'ERROR_MSG' => (count($error)) ? implode('
', $error) : '', - - 'REASON_TITLE' => $reason_row['reason_title'], - 'REASON_DESCRIPTION' => $reason_row['reason_description'], - - 'TRANSLATED_TITLE' => ($translated) ? $user->lang['report_reasons']['TITLE'][strtoupper($reason_row['reason_title'])] : '', - 'TRANSLATED_DESCRIPTION'=> ($translated) ? $user->lang['report_reasons']['DESCRIPTION'][strtoupper($reason_row['reason_title'])] : '', - - 'S_AVAILABLE_TITLES' => implode($user->lang['COMMA_SEPARATOR'], array_map('htmlspecialchars', array_keys($user->lang['report_reasons']['TITLE']))), - 'S_EDIT_REASON' => true, - 'S_TRANSLATED' => $translated, - 'S_ERROR' => (count($error)) ? true : false, - ) - ); - - return; - break; - - case 'delete': - - $sql = 'SELECT * - FROM ' . REPORTS_REASONS_TABLE . ' - WHERE reason_id = ' . $reason_id; - $result = $db->sql_query($sql); - $reason_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$reason_row) - { - trigger_error($user->lang['NO_REASON'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - if (strtolower($reason_row['reason_title']) == 'other') - { - trigger_error($user->lang['NO_REMOVE_DEFAULT_REASON'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - // Let the deletion be confirmed... - if (confirm_box(true)) - { - $sql = 'SELECT reason_id - FROM ' . REPORTS_REASONS_TABLE . " - WHERE LOWER(reason_title) = 'other'"; - $result = $db->sql_query($sql); - $other_reason_id = (int) $db->sql_fetchfield('reason_id'); - $db->sql_freeresult($result); - - switch ($db->get_sql_layer()) - { - // The ugly one! - case 'mysqli': - case 'mysql4': - case 'mysql': - // Change the reports using this reason to 'other' - $sql = 'UPDATE ' . REPORTS_TABLE . ' - SET reason_id = ' . $other_reason_id . ", report_text = CONCAT('" . $db->sql_escape($reason_row['reason_description']) . "\n\n', report_text) - WHERE reason_id = $reason_id"; - break; - - // Standard? What's that? - case 'mssql_odbc': - case 'mssqlnative': - // Change the reports using this reason to 'other' - $sql = "DECLARE @ptrval binary(16) - - SELECT @ptrval = TEXTPTR(report_text) - FROM " . REPORTS_TABLE . " - WHERE reason_id = " . $reason_id . " - - UPDATETEXT " . REPORTS_TABLE . ".report_text @ptrval 0 0 '" . $db->sql_escape($reason_row['reason_description']) . "\n\n' - - UPDATE " . REPORTS_TABLE . ' - SET reason_id = ' . $other_reason_id . " - WHERE reason_id = $reason_id"; - break; - - // Teh standard - case 'postgres': - case 'oracle': - case 'sqlite3': - // Change the reports using this reason to 'other' - $sql = 'UPDATE ' . REPORTS_TABLE . ' - SET reason_id = ' . $other_reason_id . ", report_text = '" . $db->sql_escape($reason_row['reason_description']) . "\n\n' || report_text - WHERE reason_id = $reason_id"; - break; - } - $db->sql_query($sql); - - $db->sql_query('DELETE FROM ' . REPORTS_REASONS_TABLE . ' WHERE reason_id = ' . $reason_id); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_REASON_REMOVED', false, array($reason_row['reason_title'])); - trigger_error($user->lang['REASON_REMOVED'] . adm_back_link($this->u_action)); - } - else - { - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( - 'i' => $id, - 'mode' => $mode, - 'action' => $action, - 'id' => $reason_id)) - ); - } - - break; - - case 'move_up': - case 'move_down': - - if (!check_link_hash($request->variable('hash', ''), 'acp_reasons')) - { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - $sql = 'SELECT reason_order - FROM ' . REPORTS_REASONS_TABLE . " - WHERE reason_id = $reason_id"; - $result = $db->sql_query($sql); - $order = $db->sql_fetchfield('reason_order'); - $db->sql_freeresult($result); - - if ($order === false || ($order == 0 && $action == 'move_up')) - { - break; - } - $order = (int) $order; - $order_total = $order * 2 + (($action == 'move_up') ? -1 : 1); - - $sql = 'UPDATE ' . REPORTS_REASONS_TABLE . ' - SET reason_order = ' . $order_total . ' - reason_order - WHERE reason_order IN (' . $order . ', ' . (($action == 'move_up') ? $order - 1 : $order + 1) . ')'; - $db->sql_query($sql); - - if ($request->is_ajax()) - { - $json_response = new \phpbb\json_response; - $json_response->send(array( - 'success' => (bool) $db->sql_affectedrows(), - )); - } - break; - } - - // By default, check that order is valid and fix it if necessary - $sql = 'SELECT reason_id, reason_order - FROM ' . REPORTS_REASONS_TABLE . ' - ORDER BY reason_order'; - $result = $db->sql_query($sql); - - if ($row = $db->sql_fetchrow($result)) - { - $order = 0; - do - { - ++$order; - - if ($row['reason_order'] != $order) - { - $sql = 'UPDATE ' . REPORTS_REASONS_TABLE . " - SET reason_order = $order - WHERE reason_id = {$row['reason_id']}"; - $db->sql_query($sql); - } - } - while ($row = $db->sql_fetchrow($result)); - } - $db->sql_freeresult($result); - - $template->assign_vars(array( - 'U_ACTION' => $this->u_action, - ) - ); - - // Reason count - $sql = 'SELECT reason_id, COUNT(reason_id) AS reason_count - FROM ' . REPORTS_TABLE . ' - GROUP BY reason_id'; - $result = $db->sql_query($sql); - - $reason_count = array(); - while ($row = $db->sql_fetchrow($result)) - { - $reason_count[$row['reason_id']] = $row['reason_count']; - } - $db->sql_freeresult($result); - - $sql = 'SELECT * - FROM ' . REPORTS_REASONS_TABLE . ' - ORDER BY reason_order ASC'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $translated = false; - $other_reason = ($row['reason_title'] == 'other') ? true : false; - - // If the reason is defined within the language file, we will use the localized version, else just use the database entry... - if (isset($user->lang['report_reasons']['TITLE'][strtoupper($row['reason_title'])]) && isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])])) - { - $row['reason_description'] = $user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])]; - $row['reason_title'] = $user->lang['report_reasons']['TITLE'][strtoupper($row['reason_title'])]; - - $translated = true; - } - - $template->assign_block_vars('reasons', array( - 'REASON_TITLE' => $row['reason_title'], - 'REASON_DESCRIPTION' => $row['reason_description'], - 'REASON_COUNT' => (isset($reason_count[$row['reason_id']])) ? $reason_count[$row['reason_id']] : 0, - - 'S_TRANSLATED' => $translated, - 'S_OTHER_REASON' => $other_reason, - - 'U_EDIT' => $this->u_action . '&action=edit&id=' . $row['reason_id'], - 'U_DELETE' => (!$other_reason) ? $this->u_action . '&action=delete&id=' . $row['reason_id'] : '', - 'U_MOVE_UP' => $this->u_action . '&action=move_up&id=' . $row['reason_id'] . '&hash=' . generate_link_hash('acp_reasons'), - 'U_MOVE_DOWN' => $this->u_action . '&action=move_down&id=' . $row['reason_id'] . '&hash=' . generate_link_hash('acp_reasons')) - ); - } - $db->sql_freeresult($result); - } -} diff --git a/install/update/old/includes/acp/acp_styles.php b/install/update/old/includes/acp/acp_styles.php deleted file mode 100644 index 1bf5a3c..0000000 --- a/install/update/old/includes/acp/acp_styles.php +++ /dev/null @@ -1,1373 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -class acp_styles -{ - public $u_action; - - protected $u_base_action; - protected $s_hidden_fields; - protected $mode; - protected $styles_path; - protected $styles_path_absolute = 'styles'; - protected $default_style = 0; - protected $styles_list_cols = 0; - protected $reserved_style_names = array('adm', 'admin', 'all'); - - /** @var \phpbb\config\config */ - protected $config; - - /** @var \phpbb\db\driver\driver_interface */ - protected $db; - - /** @var \phpbb\user */ - protected $user; - - /** @var \phpbb\template\template */ - protected $template; - - /** @var \phpbb\request\request_interface */ - protected $request; - - /** @var \phpbb\cache\driver\driver_interface */ - protected $cache; - - /** @var \phpbb\auth\auth */ - protected $auth; - - /** @var \phpbb\textformatter\cache_interface */ - protected $text_formatter_cache; - - /** @var string */ - protected $phpbb_root_path; - - /** @var string */ - protected $php_ext; - - /** @var \phpbb\event\dispatcher_interface */ - protected $dispatcher; - - public function main($id, $mode) - { - global $db, $user, $phpbb_admin_path, $phpbb_root_path, $phpEx, $template, $request, $cache, $auth, $config, $phpbb_dispatcher, $phpbb_container; - - $this->db = $db; - $this->user = $user; - $this->template = $template; - $this->request = $request; - $this->cache = $cache; - $this->auth = $auth; - $this->text_formatter_cache = $phpbb_container->get('text_formatter.cache'); - $this->config = $config; - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $phpEx; - $this->dispatcher = $phpbb_dispatcher; - - $this->default_style = $config['default_style']; - $this->styles_path = $this->phpbb_root_path . $this->styles_path_absolute . '/'; - - $this->u_base_action = append_sid("{$phpbb_admin_path}index.{$this->php_ext}", "i={$id}"); - $this->s_hidden_fields = array( - 'mode' => $mode, - ); - - $this->user->add_lang('acp/styles'); - - $this->tpl_name = 'acp_styles'; - $this->page_title = 'ACP_CAT_STYLES'; - $this->mode = $mode; - - $action = $this->request->variable('action', ''); - $post_actions = array('install', 'activate', 'deactivate', 'uninstall'); - - foreach ($post_actions as $key) - { - if ($this->request->is_set_post($key)) - { - $action = $key; - } - } - - // The uninstall action uses confirm_box() to verify the validity of the request, - // so there is no need to check for a valid token here. - if (in_array($action, $post_actions) && $action != 'uninstall') - { - $is_valid_request = check_link_hash($request->variable('hash', ''), $action) || check_form_key('styles_management'); - - if (!$is_valid_request) - { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); - } - } - - if ($action != '') - { - $this->s_hidden_fields['action'] = $action; - } - - $this->template->assign_vars(array( - 'U_ACTION' => $this->u_base_action, - 'S_HIDDEN_FIELDS' => build_hidden_fields($this->s_hidden_fields) - ) - ); - - /** - * Run code before ACP styles action execution - * - * @event core.acp_styles_action_before - * @var int id Module ID - * @var string mode Active module - * @var string action Module that should be run - * @since 3.1.7-RC1 - */ - $vars = array('id', 'mode', 'action'); - extract($this->dispatcher->trigger_event('core.acp_styles_action_before', compact($vars))); - - // Execute actions - switch ($action) - { - case 'install': - $this->action_install(); - return; - case 'uninstall': - $this->action_uninstall(); - return; - case 'activate': - $this->action_activate(); - return; - case 'deactivate': - $this->action_deactivate(); - return; - case 'details': - $this->action_details(); - return; - default: - $this->frontend(); - } - } - - /** - * Main page - */ - protected function frontend() - { - add_form_key('styles_management'); - - // Check mode - switch ($this->mode) - { - case 'style': - $this->welcome_message('ACP_STYLES', 'ACP_STYLES_EXPLAIN'); - $this->show_installed(); - return; - case 'install': - $this->welcome_message('INSTALL_STYLES', 'INSTALL_STYLES_EXPLAIN'); - $this->show_available(); - return; - } - trigger_error($this->user->lang['NO_MODE'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - /** - * Install style(s) - */ - protected function action_install() - { - // Get list of styles to install - $dirs = $this->request_vars('dir', '', true); - - // Get list of styles that can be installed - $styles = $this->find_available(false); - - // Install each style - $messages = array(); - $installed_names = array(); - $installed_dirs = array(); - foreach ($dirs as $dir) - { - if (in_array($dir, $this->reserved_style_names)) - { - $messages[] = $this->user->lang('STYLE_NAME_RESERVED', htmlspecialchars($dir)); - continue; - } - - $found = false; - foreach ($styles as &$style) - { - // Check if: - // 1. Directory matches directory we are looking for - // 2. Style is not installed yet - // 3. Style with same name or directory hasn't been installed already within this function - if ($style['style_path'] == $dir && empty($style['_installed']) && !in_array($style['style_path'], $installed_dirs) && !in_array($style['style_name'], $installed_names)) - { - // Install style - $style['style_active'] = 1; - $style['style_id'] = $this->install_style($style); - $style['_installed'] = true; - $found = true; - $installed_names[] = $style['style_name']; - $installed_dirs[] = $style['style_path']; - $messages[] = sprintf($this->user->lang['STYLE_INSTALLED'], htmlspecialchars($style['style_name'])); - } - } - if (!$found) - { - $messages[] = sprintf($this->user->lang['STYLE_NOT_INSTALLED'], htmlspecialchars($dir)); - } - } - - // Invalidate the text formatter's cache for the new styles to take effect - if (!empty($installed_names)) - { - $this->text_formatter_cache->invalidate(); - } - - // Show message - if (!count($messages)) - { - trigger_error($this->user->lang['NO_MATCHING_STYLES_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); - } - $message = implode('
', $messages); - $message .= '

« ' . $this->user->lang('STYLE_INSTALLED_RETURN_INSTALLED_STYLES') . ''; - $message .= '

» ' . $this->user->lang('STYLE_INSTALLED_RETURN_UNINSTALLED_STYLES') . ''; - trigger_error($message, E_USER_NOTICE); - } - - /** - * Confirm styles removal - */ - protected function action_uninstall() - { - // Get list of styles to uninstall - $ids = $this->request_vars('id', 0, true); - - // Check if confirmation box was submitted - if (confirm_box(true)) - { - // Uninstall - $this->action_uninstall_confirmed($ids, $this->request->variable('confirm_delete_files', false)); - return; - } - - // Confirm box - $s_hidden = build_hidden_fields(array( - 'action' => 'uninstall', - 'ids' => $ids - )); - $this->template->assign_var('S_CONFIRM_DELETE', true); - confirm_box(false, $this->user->lang['CONFIRM_UNINSTALL_STYLES'], $s_hidden, 'acp_styles.html'); - - // Canceled - show styles list - $this->frontend(); - } - - /** - * Uninstall styles(s) - * - * @param array $ids List of style IDs - * @param bool $delete_files If true, script will attempt to remove files for selected styles - */ - protected function action_uninstall_confirmed($ids, $delete_files) - { - global $user, $phpbb_log; - - $default = $this->default_style; - $uninstalled = array(); - $messages = array(); - - // Check styles list - foreach ($ids as $id) - { - if (!$id) - { - trigger_error($this->user->lang['INVALID_STYLE_ID'] . adm_back_link($this->u_action), E_USER_WARNING); - } - if ($id == $default) - { - trigger_error($this->user->lang['UNINSTALL_DEFAULT'] . adm_back_link($this->u_action), E_USER_WARNING); - } - $uninstalled[$id] = false; - } - - // Order by reversed style_id, so parent styles would be removed after child styles - // This way parent and child styles can be removed in same function call - $sql = 'SELECT * - FROM ' . STYLES_TABLE . ' - WHERE style_id IN (' . implode(', ', $ids) . ') - ORDER BY style_id DESC'; - $result = $this->db->sql_query($sql); - - $rows = $this->db->sql_fetchrowset($result); - $this->db->sql_freeresult($result); - - // Uinstall each style - $uninstalled = array(); - foreach ($rows as $style) - { - $result = $this->uninstall_style($style, $delete_files); - - if (is_string($result)) - { - $messages[] = $result; - continue; - } - $messages[] = sprintf($this->user->lang['STYLE_UNINSTALLED'], $style['style_name']); - $uninstalled[] = $style['style_name']; - - // Attempt to delete files - if ($delete_files) - { - $messages[] = sprintf($this->user->lang[$this->delete_style_files($style['style_path']) ? 'DELETE_STYLE_FILES_SUCCESS' : 'DELETE_STYLE_FILES_FAILED'], $style['style_name']); - } - } - - if (empty($messages)) - { - // Nothing to uninstall? - trigger_error($this->user->lang['NO_MATCHING_STYLES_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - // Log action - if (count($uninstalled)) - { - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_STYLE_DELETE', false, array(implode(', ', $uninstalled))); - } - - // Clear cache - $this->cache->purge(); - - // Show message - trigger_error(implode('
', $messages) . adm_back_link($this->u_action), E_USER_NOTICE); - } - - /** - * Activate styles - */ - protected function action_activate() - { - // Get list of styles to activate - $ids = $this->request_vars('id', 0, true); - - // Activate styles - $sql = 'UPDATE ' . STYLES_TABLE . ' - SET style_active = 1 - WHERE style_id IN (' . implode(', ', $ids) . ')'; - $this->db->sql_query($sql); - - // Purge cache - $this->cache->destroy('sql', STYLES_TABLE); - - // Show styles list - $this->frontend(); - } - - /** - * Deactivate styles - */ - protected function action_deactivate() - { - // Get list of styles to deactivate - $ids = $this->request_vars('id', 0, true); - - // Check for default style - foreach ($ids as $id) - { - if ($id == $this->default_style) - { - trigger_error($this->user->lang['DEACTIVATE_DEFAULT'] . adm_back_link($this->u_action), E_USER_WARNING); - } - } - - // Reset default style for users who use selected styles - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_style = ' . (int) $this->default_style . ' - WHERE user_style IN (' . implode(', ', $ids) . ')'; - $this->db->sql_query($sql); - - // Deactivate styles - $sql = 'UPDATE ' . STYLES_TABLE . ' - SET style_active = 0 - WHERE style_id IN (' . implode(', ', $ids) . ')'; - $this->db->sql_query($sql); - - // Purge cache - $this->cache->destroy('sql', STYLES_TABLE); - - // Show styles list - $this->frontend(); - } - - /** - * Show style details - */ - protected function action_details() - { - global $user, $phpbb_log; - - $id = $this->request->variable('id', 0); - if (!$id) - { - trigger_error($this->user->lang['NO_MATCHING_STYLES_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - // Get all styles - $styles = $this->get_styles(); - usort($styles, array($this, 'sort_styles')); - - // Find current style - $style = false; - foreach ($styles as $row) - { - if ($row['style_id'] == $id) - { - $style = $row; - break; - } - } - - if ($style === false) - { - trigger_error($this->user->lang['NO_MATCHING_STYLES_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - // Read style configuration file - $style_cfg = $this->read_style_cfg($style['style_path']); - - // Find all available parent styles - $list = $this->find_possible_parents($styles, $id); - - // Add form key - $form_key = 'acp_styles'; - add_form_key($form_key); - - // Change data - if ($this->request->variable('update', false)) - { - if (!check_form_key($form_key)) - { - trigger_error($this->user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - $update = array( - 'style_name' => trim($this->request->variable('style_name', $style['style_name'])), - 'style_parent_id' => $this->request->variable('style_parent', (int) $style['style_parent_id']), - 'style_active' => $this->request->variable('style_active', (int) $style['style_active']), - ); - $update_action = $this->u_action . '&action=details&id=' . $id; - - // Check style name - if ($update['style_name'] != $style['style_name']) - { - if (!strlen($update['style_name'])) - { - trigger_error($this->user->lang['STYLE_ERR_STYLE_NAME'] . adm_back_link($update_action), E_USER_WARNING); - } - foreach ($styles as $row) - { - if ($row['style_name'] == $update['style_name']) - { - trigger_error($this->user->lang['STYLE_ERR_NAME_EXIST'] . adm_back_link($update_action), E_USER_WARNING); - } - } - } - else - { - unset($update['style_name']); - } - - // Check parent style id - if ($update['style_parent_id'] != $style['style_parent_id']) - { - if ($update['style_parent_id'] != 0) - { - $found = false; - foreach ($list as $row) - { - if ($row['style_id'] == $update['style_parent_id']) - { - $found = true; - $update['style_parent_tree'] = ($row['style_parent_tree'] != '' ? $row['style_parent_tree'] . '/' : '') . $row['style_path']; - break; - } - } - if (!$found) - { - trigger_error($this->user->lang['STYLE_ERR_INVALID_PARENT'] . adm_back_link($update_action), E_USER_WARNING); - } - } - else - { - $update['style_parent_tree'] = ''; - } - } - else - { - unset($update['style_parent_id']); - } - - // Check style_active - if ($update['style_active'] != $style['style_active']) - { - if (!$update['style_active'] && $this->default_style == $style['style_id']) - { - trigger_error($this->user->lang['DEACTIVATE_DEFAULT'] . adm_back_link($update_action), E_USER_WARNING); - } - } - else - { - unset($update['style_active']); - } - - // Update data - if (count($update)) - { - $sql = 'UPDATE ' . STYLES_TABLE . ' - SET ' . $this->db->sql_build_array('UPDATE', $update) . " - WHERE style_id = $id"; - $this->db->sql_query($sql); - - $style = array_merge($style, $update); - - if (isset($update['style_parent_id'])) - { - // Update styles tree - $styles = $this->get_styles(); - if ($this->update_styles_tree($styles, $style)) - { - // Something was changed in styles tree, purge all cache - $this->cache->purge(); - } - } - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_STYLE_EDIT_DETAILS', false, array($style['style_name'])); - } - - // Update default style - $default = $this->request->variable('style_default', 0); - if ($default) - { - if (!$style['style_active']) - { - trigger_error($this->user->lang['STYLE_DEFAULT_CHANGE_INACTIVE'] . adm_back_link($update_action), E_USER_WARNING); - } - $this->config->set('default_style', $id); - $this->cache->purge(); - } - - // Show styles list - $this->frontend(); - return; - } - - // Show page title - $this->welcome_message('ACP_STYLES', null); - - // Show parent styles - foreach ($list as $row) - { - $this->template->assign_block_vars('parent_styles', array( - 'STYLE_ID' => $row['style_id'], - 'STYLE_NAME' => htmlspecialchars($row['style_name']), - 'LEVEL' => $row['level'], - 'SPACER' => str_repeat('  ', $row['level']), - ) - ); - } - - // Show style details - $this->template->assign_vars(array( - 'S_STYLE_DETAILS' => true, - 'STYLE_ID' => $style['style_id'], - 'STYLE_NAME' => htmlspecialchars($style['style_name']), - 'STYLE_PATH' => htmlspecialchars($style['style_path']), - 'STYLE_VERSION' => htmlspecialchars($style_cfg['style_version']), - 'STYLE_COPYRIGHT' => strip_tags($style['style_copyright']), - 'STYLE_PARENT' => $style['style_parent_id'], - 'S_STYLE_ACTIVE' => $style['style_active'], - 'S_STYLE_DEFAULT' => ($style['style_id'] == $this->default_style) - ) - ); - } - - /** - * List installed styles - */ - protected function show_installed() - { - // Get all installed styles - $styles = $this->get_styles(); - - if (!count($styles)) - { - trigger_error($this->user->lang['NO_MATCHING_STYLES_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - usort($styles, array($this, 'sort_styles')); - - // Get users - $users = $this->get_users(); - - // Add users counter to rows - foreach ($styles as &$style) - { - $style['_users'] = isset($users[$style['style_id']]) ? $users[$style['style_id']] : 0; - } - - // Set up styles list variables - // Addons should increase this number and update template variable - $this->styles_list_cols = 4; - $this->template->assign_var('STYLES_LIST_COLS', $this->styles_list_cols); - - // Show styles list - $this->show_styles_list($styles, 0, 0); - - // Show styles with invalid inherits_id - foreach ($styles as $style) - { - if (empty($style['_shown'])) - { - $style['_note'] = sprintf($this->user->lang['REQUIRES_STYLE'], htmlspecialchars($style['style_parent_tree'])); - $this->list_style($style, 0); - } - } - - // Add buttons - $this->template->assign_block_vars('extra_actions', array( - 'ACTION_NAME' => 'activate', - 'L_ACTION' => $this->user->lang['STYLE_ACTIVATE'], - ) - ); - - $this->template->assign_block_vars('extra_actions', array( - 'ACTION_NAME' => 'deactivate', - 'L_ACTION' => $this->user->lang['STYLE_DEACTIVATE'], - ) - ); - - if (isset($this->style_counters) && $this->style_counters['total'] > 1) - { - $this->template->assign_block_vars('extra_actions', array( - 'ACTION_NAME' => 'uninstall', - 'L_ACTION' => $this->user->lang['STYLE_UNINSTALL'], - ) - ); - } - } - - /** - * Show list of styles that can be installed - */ - protected function show_available() - { - // Get list of styles - $styles = $this->find_available(true); - - // Show styles - if (empty($styles)) - { - trigger_error($this->user->lang['NO_UNINSTALLED_STYLE'] . adm_back_link($this->u_base_action), E_USER_NOTICE); - } - - usort($styles, array($this, 'sort_styles')); - - $this->styles_list_cols = 3; - $this->template->assign_vars(array( - 'STYLES_LIST_COLS' => $this->styles_list_cols, - 'STYLES_LIST_HIDE_COUNT' => true - ) - ); - - // Show styles - foreach ($styles as &$style) - { - // Check if style has a parent style in styles list - $has_parent = false; - if ($style['_inherit_name'] != '') - { - foreach ($styles as $parent_style) - { - if ($parent_style['style_name'] == $style['_inherit_name'] && empty($parent_style['_shown'])) - { - // Show parent style first - $has_parent = true; - } - } - } - if (!$has_parent) - { - $this->list_style($style, 0); - $this->show_available_child_styles($styles, $style['style_name'], 1); - } - } - - // Show styles that do not have parent style in styles list - foreach ($styles as $style) - { - if (empty($style['_shown'])) - { - $this->list_style($style, 0); - } - } - - // Add button - if (isset($this->style_counters) && $this->style_counters['caninstall'] > 0) - { - $this->template->assign_block_vars('extra_actions', array( - 'ACTION_NAME' => 'install', - 'L_ACTION' => $this->user->lang['INSTALL_STYLES'], - ) - ); - } - } - - /** - * Find styles available for installation - * - * @param bool $all if true, function will return all installable styles. if false, function will return only styles that can be installed - * @return array List of styles - */ - protected function find_available($all) - { - // Get list of installed styles - $installed = $this->get_styles(); - - $installed_dirs = array(); - $installed_names = array(); - foreach ($installed as $style) - { - $installed_dirs[] = $style['style_path']; - $installed_names[$style['style_name']] = array( - 'path' => $style['style_path'], - 'id' => $style['style_id'], - 'parent' => $style['style_parent_id'], - 'tree' => (strlen($style['style_parent_tree']) ? $style['style_parent_tree'] . '/' : '') . $style['style_path'], - ); - } - - // Get list of directories - $dirs = $this->find_style_dirs(); - - // Find styles that can be installed - $styles = array(); - foreach ($dirs as $dir) - { - if (in_array($dir, $installed_dirs)) - { - // Style is already installed - continue; - } - $cfg = $this->read_style_cfg($dir); - if ($cfg === false) - { - // Invalid style.cfg - continue; - } - - // Style should be available for installation - $parent = $cfg['parent']; - $style = array( - 'style_id' => 0, - 'style_name' => $cfg['name'], - 'style_copyright' => $cfg['copyright'], - 'style_active' => 0, - 'style_path' => $dir, - 'bbcode_bitfield' => $cfg['template_bitfield'], - 'style_parent_id' => 0, - 'style_parent_tree' => '', - // Extra values for styles list - // All extra variable start with _ so they won't be confused with data that can be added to styles table - '_inherit_name' => $parent, - '_available' => true, - '_note' => '', - ); - - // Check style inheritance - if ($parent != '') - { - if (isset($installed_names[$parent])) - { - // Parent style is installed - $row = $installed_names[$parent]; - $style['style_parent_id'] = $row['id']; - $style['style_parent_tree'] = $row['tree']; - } - else - { - // Parent style is not installed yet - $style['_available'] = false; - $style['_note'] = sprintf($this->user->lang['REQUIRES_STYLE'], htmlspecialchars($parent)); - } - } - - if ($all || $style['_available']) - { - $styles[] = $style; - } - } - - return $styles; - } - - /** - * Show styles list - * - * @param array $styles styles list - * @param int $parent parent style id - * @param int $level style inheritance level - */ - protected function show_styles_list(&$styles, $parent, $level) - { - foreach ($styles as &$style) - { - if (empty($style['_shown']) && $style['style_parent_id'] == $parent) - { - $this->list_style($style, $level); - $this->show_styles_list($styles, $style['style_id'], $level + 1); - } - } - } - - /** - * Show available styles tree - * - * @param array $styles Styles list, passed as reference - * @param string $name Name of parent style - * @param int $level Styles tree level - */ - protected function show_available_child_styles(&$styles, $name, $level) - { - foreach ($styles as &$style) - { - if (empty($style['_shown']) && $style['_inherit_name'] == $name) - { - $this->list_style($style, $level); - $this->show_available_child_styles($styles, $style['style_name'], $level + 1); - } - } - } - - /** - * Update styles tree - * - * @param array $styles Styles list, passed as reference - * @param array|false $style Current style, false if root - * @return bool True if something was updated, false if not - */ - protected function update_styles_tree(&$styles, $style = false) - { - $parent_id = ($style === false) ? 0 : $style['style_id']; - $parent_tree = ($style === false) ? '' : ($style['style_parent_tree'] == '' ? '' : $style['style_parent_tree']) . $style['style_path']; - $update = false; - $updated = false; - foreach ($styles as &$row) - { - if ($row['style_parent_id'] == $parent_id) - { - if ($row['style_parent_tree'] != $parent_tree) - { - $row['style_parent_tree'] = $parent_tree; - $update = true; - } - $updated |= $this->update_styles_tree($styles, $row); - } - } - if ($update) - { - $sql = 'UPDATE ' . STYLES_TABLE . " - SET style_parent_tree = '" . $this->db->sql_escape($parent_tree) . "' - WHERE style_parent_id = {$parent_id}"; - $this->db->sql_query($sql); - $updated = true; - } - return $updated; - } - - /** - * Find all possible parent styles for style - * - * @param array $styles list of styles - * @param int $id id of style - * @param int $parent current parent style id - * @param int $level current tree level - * @return array Style ids, names and levels - */ - protected function find_possible_parents($styles, $id = -1, $parent = 0, $level = 0) - { - $results = array(); - foreach ($styles as $style) - { - if ($style['style_id'] != $id && $style['style_parent_id'] == $parent) - { - $results[] = array( - 'style_id' => $style['style_id'], - 'style_name' => $style['style_name'], - 'style_path' => $style['style_path'], - 'style_parent_id' => $style['style_parent_id'], - 'style_parent_tree' => $style['style_parent_tree'], - 'level' => $level - ); - $results = array_merge($results, $this->find_possible_parents($styles, $id, $style['style_id'], $level + 1)); - } - } - return $results; - } - - /** - * Show item in styles list - * - * @param array $style style row - * @param int $level style inheritance level - */ - protected function list_style(&$style, $level) - { - // Mark row as shown - if (!empty($style['_shown'])) - { - return; - } - - $style['_shown'] = true; - - // Generate template variables - $actions = array(); - $row = array( - // Style data - 'STYLE_ID' => $style['style_id'], - 'STYLE_NAME' => htmlspecialchars($style['style_name']), - 'STYLE_PHPBB_VERSION' => $this->read_style_cfg($style['style_path'])['phpbb_version'], - 'STYLE_PATH' => htmlspecialchars($style['style_path']), - 'STYLE_COPYRIGHT' => strip_tags($style['style_copyright']), - 'STYLE_ACTIVE' => $style['style_active'], - - // Additional data - 'DEFAULT' => ($style['style_id'] && $style['style_id'] == $this->default_style), - 'USERS' => (isset($style['_users'])) ? $style['_users'] : '', - 'LEVEL' => $level, - 'PADDING' => (4 + 16 * $level), - 'SHOW_COPYRIGHT' => ($style['style_id']) ? false : true, - 'STYLE_PATH_FULL' => htmlspecialchars($this->styles_path_absolute . '/' . $style['style_path']) . '/', - - // Comment to show below style - 'COMMENT' => (isset($style['_note'])) ? $style['_note'] : '', - - // The following variables should be used by hooks to add custom HTML code - 'EXTRA' => '', - 'EXTRA_OPTIONS' => '' - ); - - // Status specific data - if ($style['style_id']) - { - // Style is installed - - // Details - $actions[] = array( - 'U_ACTION' => $this->u_action . '&action=details&id=' . $style['style_id'], - 'L_ACTION' => $this->user->lang['DETAILS'] - ); - - // Activate/Deactive - $action_name = ($style['style_active'] ? 'de' : '') . 'activate'; - - $actions[] = array( - 'U_ACTION' => $this->u_action . '&action=' . $action_name . '&hash=' . generate_link_hash($action_name) . '&id=' . $style['style_id'], - 'L_ACTION' => $this->user->lang['STYLE_' . ($style['style_active'] ? 'DE' : '') . 'ACTIVATE'] - ); - -/* // Export - $actions[] = array( - 'U_ACTION' => $this->u_action . '&action=export&hash=' . generate_link_hash('export') . '&id=' . $style['style_id'], - 'L_ACTION' => $this->user->lang['EXPORT'] - ); */ - - // Uninstall - $actions[] = array( - 'U_ACTION' => $this->u_action . '&action=uninstall&hash=' . generate_link_hash('uninstall') . '&id=' . $style['style_id'], - 'L_ACTION' => $this->user->lang['STYLE_UNINSTALL'] - ); - - // Preview - $actions[] = array( - 'U_ACTION' => append_sid($this->phpbb_root_path . 'index.' . $this->php_ext, 'style=' . $style['style_id']), - 'L_ACTION' => $this->user->lang['PREVIEW'] - ); - } - else - { - // Style is not installed - if (empty($style['_available'])) - { - $actions[] = array( - 'HTML' => $this->user->lang['CANNOT_BE_INSTALLED'] - ); - } - else - { - $actions[] = array( - 'U_ACTION' => $this->u_action . '&action=install&hash=' . generate_link_hash('install') . '&dir=' . urlencode($style['style_path']), - 'L_ACTION' => $this->user->lang['INSTALL_STYLE'] - ); - } - } - - // todo: add hook - - // Assign template variables - $this->template->assign_block_vars('styles_list', $row); - foreach ($actions as $action) - { - $this->template->assign_block_vars('styles_list.actions', $action); - } - - // Increase counters - $counter = ($style['style_id']) ? ($style['style_active'] ? 'active' : 'inactive') : (empty($style['_available']) ? 'cannotinstall' : 'caninstall'); - if (!isset($this->style_counters)) - { - $this->style_counters = array( - 'total' => 0, - 'active' => 0, - 'inactive' => 0, - 'caninstall' => 0, - 'cannotinstall' => 0 - ); - } - $this->style_counters[$counter]++; - $this->style_counters['total']++; - } - - /** - * Show welcome message - * - * @param string $title main title - * @param string $description page description - */ - protected function welcome_message($title, $description) - { - $this->template->assign_vars(array( - 'L_TITLE' => $this->user->lang[$title], - 'L_EXPLAIN' => (isset($this->user->lang[$description])) ? $this->user->lang[$description] : '' - ) - ); - } - - /** - * Find all directories that have styles - * - * @return array Directory names - */ - protected function find_style_dirs() - { - $styles = array(); - - $dp = @opendir($this->styles_path); - if ($dp) - { - while (($file = readdir($dp)) !== false) - { - $dir = $this->styles_path . $file; - if ($file[0] == '.' || !is_dir($dir)) - { - continue; - } - - if (file_exists("{$dir}/style.cfg")) - { - $styles[] = $file; - } - } - closedir($dp); - } - - return $styles; - } - - /** - * Sort styles - */ - public function sort_styles($style1, $style2) - { - if ($style1['style_active'] != $style2['style_active']) - { - return ($style1['style_active']) ? -1 : 1; - } - if (isset($style1['_available']) && $style1['_available'] != $style2['_available']) - { - return ($style1['_available']) ? -1 : 1; - } - return strcasecmp(isset($style1['style_name']) ? $style1['style_name'] : $style1['name'], isset($style2['style_name']) ? $style2['style_name'] : $style2['name']); - } - - /** - * Read style configuration file - * - * @param string $dir style directory - * @return array|bool Style data, false on error - */ - protected function read_style_cfg($dir) - { - static $required = array('name', 'phpbb_version', 'copyright'); - $cfg = parse_cfg_file($this->styles_path . $dir . '/style.cfg'); - - // Check if it is a valid file - foreach ($required as $key) - { - if (!isset($cfg[$key])) - { - return false; - } - } - - // Check data - if (!isset($cfg['parent']) || !is_string($cfg['parent']) || $cfg['parent'] == $cfg['name']) - { - $cfg['parent'] = ''; - } - if (!isset($cfg['template_bitfield'])) - { - $cfg['template_bitfield'] = $this->default_bitfield(); - } - - return $cfg; - } - - /** - * Install style - * - * @param array $style style data - * @return int Style id - */ - protected function install_style($style) - { - global $user, $phpbb_log; - - // Generate row - $sql_ary = array(); - foreach ($style as $key => $value) - { - if ($key != 'style_id' && substr($key, 0, 1) != '_') - { - $sql_ary[$key] = $value; - } - } - - // Add to database - $this->db->sql_transaction('begin'); - - $sql = 'INSERT INTO ' . STYLES_TABLE . ' - ' . $this->db->sql_build_array('INSERT', $sql_ary); - $this->db->sql_query($sql); - - $id = $this->db->sql_nextid(); - - $this->db->sql_transaction('commit'); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_STYLE_ADD', false, array($sql_ary['style_name'])); - - return $id; - } - - /** - * Lists all styles - * - * @return array Rows with styles data - */ - protected function get_styles() - { - $sql = 'SELECT * - FROM ' . STYLES_TABLE; - $result = $this->db->sql_query($sql); - - $rows = $this->db->sql_fetchrowset($result); - $this->db->sql_freeresult($result); - - return $rows; - } - - /** - * Count users for each style - * - * @return array Styles in following format: [style_id] = number of users - */ - protected function get_users() - { - $sql = 'SELECT user_style, COUNT(user_style) AS style_count - FROM ' . USERS_TABLE . ' - GROUP BY user_style'; - $result = $this->db->sql_query($sql); - - $style_count = array(); - while ($row = $this->db->sql_fetchrow($result)) - { - $style_count[$row['user_style']] = $row['style_count']; - } - $this->db->sql_freeresult($result); - - return $style_count; - } - - /** - * Uninstall style - * - * @param array $style Style data - * @return bool|string True on success, error message on error - */ - protected function uninstall_style($style) - { - $id = $style['style_id']; - $path = $style['style_path']; - - // Check if style has child styles - $sql = 'SELECT style_id - FROM ' . STYLES_TABLE . ' - WHERE style_parent_id = ' . (int) $id . " OR style_parent_tree = '" . $this->db->sql_escape($path) . "'"; - $result = $this->db->sql_query($sql); - - $conflict = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if ($conflict !== false) - { - return sprintf($this->user->lang['STYLE_UNINSTALL_DEPENDENT'], $style['style_name']); - } - - // Change default style for users - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_style = ' . (int) $this->default_style . ' - WHERE user_style = ' . $id; - $this->db->sql_query($sql); - - // Uninstall style - $sql = 'DELETE FROM ' . STYLES_TABLE . ' - WHERE style_id = ' . $id; - $this->db->sql_query($sql); - return true; - } - - /** - * Delete all files in style directory - * - * @param string $path Style directory - * @param string $dir Directory to remove inside style's directory - * @return bool True on success, false on error - */ - protected function delete_style_files($path, $dir = '') - { - $dirname = $this->styles_path . $path . $dir; - $result = true; - - $dp = @opendir($dirname); - - if ($dp) - { - while (($file = readdir($dp)) !== false) - { - if ($file == '.' || $file == '..') - { - continue; - } - $filename = $dirname . '/' . $file; - if (is_dir($filename)) - { - if (!$this->delete_style_files($path, $dir . '/' . $file)) - { - $result = false; - } - } - else - { - if (!@unlink($filename)) - { - $result = false; - } - } - } - closedir($dp); - } - if (!@rmdir($dirname)) - { - return false; - } - - return $result; - } - - /** - * Get list of items from posted data - * - * @param string $name Variable name - * @param string|int $default Default value for array - * @param bool $error If true, error will be triggered if list is empty - * @return array Items - */ - protected function request_vars($name, $default, $error = false) - { - $item = $this->request->variable($name, $default); - $items = $this->request->variable($name . 's', array($default)); - - if (count($items) == 1 && $items[0] == $default) - { - $items = array(); - } - - if ($item != $default && !count($items)) - { - $items[] = $item; - } - - if ($error && !count($items)) - { - trigger_error($this->user->lang['NO_MATCHING_STYLES_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - return $items; - } - - /** - * Generates default bitfield - * - * This bitfield decides which bbcodes are defined in a template. - * - * @return string Bitfield - */ - protected function default_bitfield() - { - static $value; - if (isset($value)) - { - return $value; - } - - // Hardcoded template bitfield to add for new templates - $default_bitfield = '1111111111111'; - - $bitfield = new bitfield(); - for ($i = 0; $i < strlen($default_bitfield); $i++) - { - if ($default_bitfield[$i] == '1') - { - $bitfield->set($i); - } - } - - return $bitfield->get_base64(); - } - -} diff --git a/install/update/old/includes/acp/acp_update.php b/install/update/old/includes/acp/acp_update.php deleted file mode 100644 index 9124a59..0000000 --- a/install/update/old/includes/acp/acp_update.php +++ /dev/null @@ -1,86 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -class acp_update -{ - var $u_action; - - function main($id, $mode) - { - global $config, $user, $template, $request; - global $phpbb_root_path, $phpEx, $phpbb_container; - - $user->add_lang('install'); - - $this->tpl_name = 'acp_update'; - $this->page_title = 'ACP_VERSION_CHECK'; - - /* @var $version_helper \phpbb\version_helper */ - $version_helper = $phpbb_container->get('version_helper'); - try - { - $recheck = $request->variable('versioncheck_force', false); - $updates_available = $version_helper->get_update_on_branch($recheck); - $upgrades_available = $version_helper->get_suggested_updates(); - if (!empty($upgrades_available)) - { - $upgrades_available = array_pop($upgrades_available); - } - } - catch (\RuntimeException $e) - { - $template->assign_var('S_VERSIONCHECK_FAIL', true); - - $updates_available = array(); - } - - if (!empty($updates_available)) - { - $template->assign_block_vars('updates_available', $updates_available); - } - - $update_link = $phpbb_root_path . 'install/app.' . $phpEx; - - $template->assign_vars(array( - 'S_UP_TO_DATE' => empty($updates_available), - 'U_ACTION' => $this->u_action, - 'U_VERSIONCHECK_FORCE' => append_sid($this->u_action . '&versioncheck_force=1'), - - 'CURRENT_VERSION' => $config['version'], - - 'UPDATE_INSTRUCTIONS' => sprintf($user->lang['UPDATE_INSTRUCTIONS'], $update_link), - 'S_VERSION_UPGRADEABLE' => !empty($upgrades_available), - 'UPGRADE_INSTRUCTIONS' => !empty($upgrades_available) ? $user->lang('UPGRADE_INSTRUCTIONS', $upgrades_available['current'], $upgrades_available['announcement']) : false, - )); - - // Incomplete update? - if (phpbb_version_compare($config['version'], PHPBB_VERSION, '<')) - { - $database_update_link = $phpbb_root_path . 'install/app.php/update'; - - $template->assign_vars(array( - 'S_UPDATE_INCOMPLETE' => true, - 'FILES_VERSION' => PHPBB_VERSION, - 'INCOMPLETE_INSTRUCTIONS' => $user->lang('UPDATE_INCOMPLETE_EXPLAIN', $database_update_link), - )); - } - } -} diff --git a/install/update/old/includes/acp/acp_users.php b/install/update/old/includes/acp/acp_users.php deleted file mode 100644 index 2d1eaad..0000000 --- a/install/update/old/includes/acp/acp_users.php +++ /dev/null @@ -1,2692 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -class acp_users -{ - var $u_action; - var $p_master; - - function __construct($p_master) - { - $this->p_master = $p_master; - } - - function main($id, $mode) - { - global $config, $db, $user, $auth, $template; - global $phpbb_root_path, $phpbb_admin_path, $phpEx; - global $phpbb_dispatcher, $request; - global $phpbb_container, $phpbb_log; - - $user->add_lang(array('posting', 'ucp', 'acp/users')); - $this->tpl_name = 'acp_users'; - - $error = array(); - $username = $request->variable('username', '', true); - $user_id = $request->variable('u', 0); - $action = $request->variable('action', ''); - - // Get referer to redirect user to the appropriate page after delete action - $redirect = $request->variable('redirect', ''); - $redirect_tag = "redirect=$redirect"; - $redirect_url = append_sid("{$phpbb_admin_path}index.$phpEx", "i=$redirect"); - - $submit = (isset($_POST['update']) && !isset($_POST['cancel'])) ? true : false; - - $form_name = 'acp_users'; - add_form_key($form_name); - - // Whois (special case) - if ($action == 'whois') - { - if (!function_exists('user_get_id_name')) - { - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - } - - $this->page_title = 'WHOIS'; - $this->tpl_name = 'simple_body'; - - $user_ip = phpbb_ip_normalise($request->variable('user_ip', '')); - $domain = gethostbyaddr($user_ip); - $ipwhois = user_ipwhois($user_ip); - - $template->assign_vars(array( - 'MESSAGE_TITLE' => sprintf($user->lang['IP_WHOIS_FOR'], $domain), - 'MESSAGE_TEXT' => nl2br($ipwhois)) - ); - - return; - } - - // Show user selection mask - if (!$username && !$user_id) - { - $this->page_title = 'SELECT_USER'; - - $template->assign_vars(array( - 'U_ACTION' => $this->u_action, - 'ANONYMOUS_USER_ID' => ANONYMOUS, - - 'S_SELECT_USER' => true, - 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=select_user&field=username&select_single=true'), - )); - - return; - } - - if (!$user_id) - { - $sql = 'SELECT user_id - FROM ' . USERS_TABLE . " - WHERE username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'"; - $result = $db->sql_query($sql); - $user_id = (int) $db->sql_fetchfield('user_id'); - $db->sql_freeresult($result); - - if (!$user_id) - { - trigger_error($user->lang['NO_USER'] . adm_back_link($this->u_action), E_USER_WARNING); - } - } - - // Generate content for all modes - $sql = 'SELECT u.*, s.* - FROM ' . USERS_TABLE . ' u - LEFT JOIN ' . SESSIONS_TABLE . ' s ON (s.session_user_id = u.user_id) - WHERE u.user_id = ' . $user_id . ' - ORDER BY s.session_time DESC'; - $result = $db->sql_query_limit($sql, 1); - $user_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$user_row) - { - trigger_error($user->lang['NO_USER'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - // Generate overall "header" for user admin - $s_form_options = ''; - - // Build modes dropdown list - $sql = 'SELECT module_mode, module_auth - FROM ' . MODULES_TABLE . " - WHERE module_basename = 'acp_users' - AND module_enabled = 1 - AND module_class = 'acp' - ORDER BY left_id, module_mode"; - $result = $db->sql_query($sql); - - $dropdown_modes = array(); - while ($row = $db->sql_fetchrow($result)) - { - if (!$this->p_master->module_auth_self($row['module_auth'])) - { - continue; - } - - $dropdown_modes[$row['module_mode']] = true; - } - $db->sql_freeresult($result); - - foreach ($dropdown_modes as $module_mode => $null) - { - $selected = ($mode == $module_mode) ? ' selected="selected"' : ''; - $s_form_options .= ''; - } - - $template->assign_vars(array( - 'U_BACK' => (empty($redirect)) ? $this->u_action : $redirect_url, - 'U_MODE_SELECT' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=$id&u=$user_id"), - 'U_ACTION' => $this->u_action . '&u=' . $user_id . ((empty($redirect)) ? '' : '&' . $redirect_tag), - 'S_FORM_OPTIONS' => $s_form_options, - 'MANAGED_USERNAME' => $user_row['username']) - ); - - // Prevent normal users/admins change/view founders if they are not a founder by themselves - if ($user->data['user_type'] != USER_FOUNDER && $user_row['user_type'] == USER_FOUNDER) - { - trigger_error($user->lang['NOT_MANAGE_FOUNDER'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - $this->page_title = $user_row['username'] . ' :: ' . $user->lang('ACP_USER_' . strtoupper($mode)); - - switch ($mode) - { - case 'overview': - - if (!function_exists('user_get_id_name')) - { - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - } - - $user->add_lang('acp/ban'); - - $delete = $request->variable('delete', 0); - $delete_type = $request->variable('delete_type', ''); - $ip = $request->variable('ip', 'ip'); - - /** - * Run code at beginning of ACP users overview - * - * @event core.acp_users_overview_before - * @var array user_row Current user data - * @var string mode Active module - * @var string action Module that should be run - * @var bool submit Do we display the form only - * or did the user press submit - * @var array error Array holding error messages - * @since 3.1.3-RC1 - */ - $vars = array('user_row', 'mode', 'action', 'submit', 'error'); - extract($phpbb_dispatcher->trigger_event('core.acp_users_overview_before', compact($vars))); - - if ($submit) - { - if ($delete) - { - if (!$auth->acl_get('a_userdel')) - { - send_status_line(403, 'Forbidden'); - trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - // Check if the user wants to remove himself or the guest user account - if ($user_id == ANONYMOUS) - { - trigger_error($user->lang['CANNOT_REMOVE_ANONYMOUS'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - // Founders can not be deleted. - if ($user_row['user_type'] == USER_FOUNDER) - { - trigger_error($user->lang['CANNOT_REMOVE_FOUNDER'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - if ($user_id == $user->data['user_id']) - { - trigger_error($user->lang['CANNOT_REMOVE_YOURSELF'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - if ($delete_type) - { - if (confirm_box(true)) - { - user_delete($delete_type, $user_id, $user_row['username']); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_DELETED', false, array($user_row['username'])); - trigger_error($user->lang['USER_DELETED'] . adm_back_link( - (empty($redirect)) ? $this->u_action : $redirect_url - ) - ); - } - else - { - $delete_confirm_hidden_fields = array( - 'u' => $user_id, - 'i' => $id, - 'mode' => $mode, - 'action' => $action, - 'update' => true, - 'delete' => 1, - 'delete_type' => $delete_type, - ); - - // Checks if the redirection page is specified - if (!empty($redirect)) - { - $delete_confirm_hidden_fields['redirect'] = $redirect; - } - - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields($delete_confirm_hidden_fields)); - } - } - else - { - trigger_error($user->lang['NO_MODE'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - } - - // Handle quicktool actions - switch ($action) - { - case 'banuser': - case 'banemail': - case 'banip': - - if ($user_id == $user->data['user_id']) - { - trigger_error($user->lang['CANNOT_BAN_YOURSELF'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - if ($user_id == ANONYMOUS) - { - trigger_error($user->lang['CANNOT_BAN_ANONYMOUS'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - if ($user_row['user_type'] == USER_FOUNDER) - { - trigger_error($user->lang['CANNOT_BAN_FOUNDER'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - if (!check_form_key($form_name)) - { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - $ban = array(); - - switch ($action) - { - case 'banuser': - $ban[] = $user_row['username']; - $reason = 'USER_ADMIN_BAN_NAME_REASON'; - break; - - case 'banemail': - $ban[] = $user_row['user_email']; - $reason = 'USER_ADMIN_BAN_EMAIL_REASON'; - break; - - case 'banip': - $ban[] = $user_row['user_ip']; - - $sql = 'SELECT DISTINCT poster_ip - FROM ' . POSTS_TABLE . " - WHERE poster_id = $user_id"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $ban[] = $row['poster_ip']; - } - $db->sql_freeresult($result); - - $reason = 'USER_ADMIN_BAN_IP_REASON'; - break; - } - - $ban_reason = $request->variable('ban_reason', $user->lang[$reason], true); - $ban_give_reason = $request->variable('ban_give_reason', '', true); - - // Log not used at the moment, we simply utilize the ban function. - $result = user_ban(substr($action, 3), $ban, 0, 0, 0, $ban_reason, $ban_give_reason); - - trigger_error((($result === false) ? $user->lang['BAN_ALREADY_ENTERED'] : $user->lang['BAN_SUCCESSFUL']) . adm_back_link($this->u_action . '&u=' . $user_id)); - - break; - - case 'reactivate': - - if ($user_id == $user->data['user_id']) - { - trigger_error($user->lang['CANNOT_FORCE_REACT_YOURSELF'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - if (!check_form_key($form_name)) - { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - if ($user_row['user_type'] == USER_FOUNDER) - { - trigger_error($user->lang['CANNOT_FORCE_REACT_FOUNDER'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - if ($user_row['user_type'] == USER_IGNORE) - { - trigger_error($user->lang['CANNOT_FORCE_REACT_BOT'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - if ($config['email_enable']) - { - if (!class_exists('messenger')) - { - include($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); - } - - $server_url = generate_board_url(); - - $user_actkey = gen_rand_string(mt_rand(6, 10)); - $email_template = ($user_row['user_type'] == USER_NORMAL) ? 'user_reactivate_account' : 'user_resend_inactive'; - - if ($user_row['user_type'] == USER_NORMAL) - { - user_active_flip('deactivate', $user_id, INACTIVE_REMIND); - } - else - { - // Grabbing the last confirm key - we only send a reminder - $sql = 'SELECT user_actkey - FROM ' . USERS_TABLE . ' - WHERE user_id = ' . $user_id; - $result = $db->sql_query($sql); - $user_activation_key = (string) $db->sql_fetchfield('user_actkey'); - $db->sql_freeresult($result); - - $user_actkey = empty($user_activation_key) ? $user_actkey : $user_activation_key; - } - - if ($user_row['user_type'] == USER_NORMAL || empty($user_activation_key)) - { - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_actkey = '" . $db->sql_escape($user_actkey) . "' - WHERE user_id = $user_id"; - $db->sql_query($sql); - } - - $messenger = new messenger(false); - - $messenger->template($email_template, $user_row['user_lang']); - - $messenger->set_addresses($user_row); - - $messenger->anti_abuse_headers($config, $user); - - $messenger->assign_vars(array( - 'WELCOME_MSG' => htmlspecialchars_decode(sprintf($user->lang['WELCOME_SUBJECT'], $config['sitename'])), - 'USERNAME' => htmlspecialchars_decode($user_row['username']), - 'U_ACTIVATE' => "$server_url/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k=$user_actkey") - ); - - $messenger->send(NOTIFY_EMAIL); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_REACTIVATE', false, array($user_row['username'])); - $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_REACTIVATE_USER', false, array( - 'reportee_id' => $user_id - )); - - trigger_error($user->lang['FORCE_REACTIVATION_SUCCESS'] . adm_back_link($this->u_action . '&u=' . $user_id)); - } - - break; - - case 'active': - - if ($user_id == $user->data['user_id']) - { - // It is only deactivation since the user is already activated (else he would not have reached this page) - trigger_error($user->lang['CANNOT_DEACTIVATE_YOURSELF'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - if (!check_form_key($form_name)) - { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - if ($user_row['user_type'] == USER_FOUNDER) - { - trigger_error($user->lang['CANNOT_DEACTIVATE_FOUNDER'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - if ($user_row['user_type'] == USER_IGNORE) - { - trigger_error($user->lang['CANNOT_DEACTIVATE_BOT'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - user_active_flip('flip', $user_id); - - if ($user_row['user_type'] == USER_INACTIVE) - { - if ($config['require_activation'] == USER_ACTIVATION_ADMIN) - { - /* @var $phpbb_notifications \phpbb\notification\manager */ - $phpbb_notifications = $phpbb_container->get('notification_manager'); - $phpbb_notifications->delete_notifications('notification.type.admin_activate_user', $user_row['user_id']); - - if (!class_exists('messenger')) - { - include($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); - } - - $messenger = new messenger(false); - - $messenger->template('admin_welcome_activated', $user_row['user_lang']); - - $messenger->set_addresses($user_row); - - $messenger->anti_abuse_headers($config, $user); - - $messenger->assign_vars(array( - 'USERNAME' => htmlspecialchars_decode($user_row['username'])) - ); - - $messenger->send(NOTIFY_EMAIL); - } - } - - $message = ($user_row['user_type'] == USER_INACTIVE) ? 'USER_ADMIN_ACTIVATED' : 'USER_ADMIN_DEACTIVED'; - $log = ($user_row['user_type'] == USER_INACTIVE) ? 'LOG_USER_ACTIVE' : 'LOG_USER_INACTIVE'; - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, $log, false, array($user_row['username'])); - $phpbb_log->add('user', $user->data['user_id'], $user->ip, $log . '_USER', false, array( - 'reportee_id' => $user_id - )); - - trigger_error($user->lang[$message] . adm_back_link($this->u_action . '&u=' . $user_id)); - - break; - - case 'delsig': - - if (!check_form_key($form_name)) - { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - $sql_ary = array( - 'user_sig' => '', - 'user_sig_bbcode_uid' => '', - 'user_sig_bbcode_bitfield' => '' - ); - - $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " - WHERE user_id = $user_id"; - $db->sql_query($sql); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_DEL_SIG', false, array($user_row['username'])); - $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_DEL_SIG_USER', false, array( - 'reportee_id' => $user_id - )); - - trigger_error($user->lang['USER_ADMIN_SIG_REMOVED'] . adm_back_link($this->u_action . '&u=' . $user_id)); - - break; - - case 'delavatar': - - if (!check_form_key($form_name)) - { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - // Delete old avatar if present - /* @var $phpbb_avatar_manager \phpbb\avatar\manager */ - $phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); - $phpbb_avatar_manager->handle_avatar_delete($db, $user, $phpbb_avatar_manager->clean_row($user_row, 'user'), USERS_TABLE, 'user_'); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_DEL_AVATAR', false, array($user_row['username'])); - $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_DEL_AVATAR_USER', false, array( - 'reportee_id' => $user_id - )); - - trigger_error($user->lang['USER_ADMIN_AVATAR_REMOVED'] . adm_back_link($this->u_action . '&u=' . $user_id)); - break; - - case 'delposts': - - if (confirm_box(true)) - { - // Delete posts, attachments, etc. - delete_posts('poster_id', $user_id); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_DEL_POSTS', false, array($user_row['username'])); - trigger_error($user->lang['USER_POSTS_DELETED'] . adm_back_link($this->u_action . '&u=' . $user_id)); - } - else - { - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( - 'u' => $user_id, - 'i' => $id, - 'mode' => $mode, - 'action' => $action, - 'update' => true)) - ); - } - - break; - - case 'delattach': - - if (confirm_box(true)) - { - /** @var \phpbb\attachment\manager $attachment_manager */ - $attachment_manager = $phpbb_container->get('attachment.manager'); - $attachment_manager->delete('user', $user_id); - unset($attachment_manager); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_DEL_ATTACH', false, array($user_row['username'])); - trigger_error($user->lang['USER_ATTACHMENTS_REMOVED'] . adm_back_link($this->u_action . '&u=' . $user_id)); - } - else - { - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( - 'u' => $user_id, - 'i' => $id, - 'mode' => $mode, - 'action' => $action, - 'update' => true)) - ); - } - - break; - - case 'deloutbox': - - if (confirm_box(true)) - { - $msg_ids = array(); - $lang = 'EMPTY'; - - $sql = 'SELECT msg_id - FROM ' . PRIVMSGS_TO_TABLE . " - WHERE author_id = $user_id - AND folder_id = " . PRIVMSGS_OUTBOX; - $result = $db->sql_query($sql); - - if ($row = $db->sql_fetchrow($result)) - { - if (!function_exists('delete_pm')) - { - include($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx); - } - - do - { - $msg_ids[] = (int) $row['msg_id']; - } - while ($row = $db->sql_fetchrow($result)); - - $db->sql_freeresult($result); - - delete_pm($user_id, $msg_ids, PRIVMSGS_OUTBOX); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_DEL_OUTBOX', false, array($user_row['username'])); - - $lang = 'EMPTIED'; - } - $db->sql_freeresult($result); - - trigger_error($user->lang['USER_OUTBOX_' . $lang] . adm_back_link($this->u_action . '&u=' . $user_id)); - } - else - { - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( - 'u' => $user_id, - 'i' => $id, - 'mode' => $mode, - 'action' => $action, - 'update' => true)) - ); - } - break; - - case 'moveposts': - - if (!check_form_key($form_name)) - { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - $user->add_lang('acp/forums'); - - $new_forum_id = $request->variable('new_f', 0); - - if (!$new_forum_id) - { - $this->page_title = 'USER_ADMIN_MOVE_POSTS'; - - $template->assign_vars(array( - 'S_SELECT_FORUM' => true, - 'U_ACTION' => $this->u_action . "&action=$action&u=$user_id", - 'U_BACK' => $this->u_action . "&u=$user_id", - 'S_FORUM_OPTIONS' => make_forum_select(false, false, false, true)) - ); - - return; - } - - // Is the new forum postable to? - $sql = 'SELECT forum_name, forum_type - FROM ' . FORUMS_TABLE . " - WHERE forum_id = $new_forum_id"; - $result = $db->sql_query($sql); - $forum_info = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$forum_info) - { - trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - if ($forum_info['forum_type'] != FORUM_POST) - { - trigger_error($user->lang['MOVE_POSTS_NO_POSTABLE_FORUM'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - // Two stage? - // Move topics comprising only posts from this user - $topic_id_ary = $move_topic_ary = $move_post_ary = $new_topic_id_ary = array(); - $forum_id_ary = array($new_forum_id); - - $sql = 'SELECT topic_id, post_visibility, COUNT(post_id) AS total_posts - FROM ' . POSTS_TABLE . " - WHERE poster_id = $user_id - AND forum_id <> $new_forum_id - GROUP BY topic_id, post_visibility"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $topic_id_ary[$row['topic_id']][$row['post_visibility']] = $row['total_posts']; - } - $db->sql_freeresult($result); - - if (count($topic_id_ary)) - { - $sql = 'SELECT topic_id, forum_id, topic_title, topic_posts_approved, topic_posts_unapproved, topic_posts_softdeleted, topic_attachment - FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', array_keys($topic_id_ary)); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if ($topic_id_ary[$row['topic_id']][ITEM_APPROVED] == $row['topic_posts_approved'] - && $topic_id_ary[$row['topic_id']][ITEM_UNAPPROVED] == $row['topic_posts_unapproved'] - && $topic_id_ary[$row['topic_id']][ITEM_REAPPROVE] == $row['topic_posts_unapproved'] - && $topic_id_ary[$row['topic_id']][ITEM_DELETED] == $row['topic_posts_softdeleted']) - { - $move_topic_ary[] = $row['topic_id']; - } - else - { - $move_post_ary[$row['topic_id']]['title'] = $row['topic_title']; - $move_post_ary[$row['topic_id']]['attach'] = ($row['topic_attachment']) ? 1 : 0; - } - - $forum_id_ary[] = $row['forum_id']; - } - $db->sql_freeresult($result); - } - - // Entire topic comprises posts by this user, move these topics - if (count($move_topic_ary)) - { - move_topics($move_topic_ary, $new_forum_id, false); - } - - if (count($move_post_ary)) - { - // Create new topic - // Update post_ids, report_ids, attachment_ids - foreach ($move_post_ary as $topic_id => $post_ary) - { - // Create new topic - $sql = 'INSERT INTO ' . TOPICS_TABLE . ' ' . $db->sql_build_array('INSERT', array( - 'topic_poster' => $user_id, - 'topic_time' => time(), - 'forum_id' => $new_forum_id, - 'icon_id' => 0, - 'topic_visibility' => ITEM_APPROVED, - 'topic_title' => $post_ary['title'], - 'topic_first_poster_name' => $user_row['username'], - 'topic_type' => POST_NORMAL, - 'topic_time_limit' => 0, - 'topic_attachment' => $post_ary['attach']) - ); - $db->sql_query($sql); - - $new_topic_id = $db->sql_nextid(); - - // Move posts - $sql = 'UPDATE ' . POSTS_TABLE . " - SET forum_id = $new_forum_id, topic_id = $new_topic_id - WHERE topic_id = $topic_id - AND poster_id = $user_id"; - $db->sql_query($sql); - - if ($post_ary['attach']) - { - $sql = 'UPDATE ' . ATTACHMENTS_TABLE . " - SET topic_id = $new_topic_id - WHERE topic_id = $topic_id - AND poster_id = $user_id"; - $db->sql_query($sql); - } - - $new_topic_id_ary[] = $new_topic_id; - } - } - - $forum_id_ary = array_unique($forum_id_ary); - $topic_id_ary = array_unique(array_merge(array_keys($topic_id_ary), $new_topic_id_ary)); - - if (count($topic_id_ary)) - { - sync('topic_reported', 'topic_id', $topic_id_ary); - sync('topic', 'topic_id', $topic_id_ary); - } - - if (count($forum_id_ary)) - { - sync('forum', 'forum_id', $forum_id_ary, false, true); - } - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_MOVE_POSTS', false, array($user_row['username'], $forum_info['forum_name'])); - $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_MOVE_POSTS_USER', false, array( - 'reportee_id' => $user_id, - $forum_info['forum_name'] - )); - - trigger_error($user->lang['USER_POSTS_MOVED'] . adm_back_link($this->u_action . '&u=' . $user_id)); - - break; - - case 'leave_nr': - - if (confirm_box(true)) - { - remove_newly_registered($user_id, $user_row); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_REMOVED_NR', false, array($user_row['username'])); - trigger_error($user->lang['USER_LIFTED_NR'] . adm_back_link($this->u_action . '&u=' . $user_id)); - } - else - { - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( - 'u' => $user_id, - 'i' => $id, - 'mode' => $mode, - 'action' => $action, - 'update' => true)) - ); - } - - break; - - default: - $u_action = $this->u_action; - - /** - * Run custom quicktool code - * - * @event core.acp_users_overview_run_quicktool - * @var string action Quick tool that should be run - * @var array user_row Current user data - * @var string u_action The u_action link - * @since 3.1.0-a1 - * @changed 3.2.2-RC1 Added u_action - */ - $vars = array('action', 'user_row', 'u_action'); - extract($phpbb_dispatcher->trigger_event('core.acp_users_overview_run_quicktool', compact($vars))); - - unset($u_action); - break; - } - - // Handle registration info updates - $data = array( - 'username' => $request->variable('user', $user_row['username'], true), - 'user_founder' => $request->variable('user_founder', ($user_row['user_type'] == USER_FOUNDER) ? 1 : 0), - 'email' => strtolower($request->variable('user_email', $user_row['user_email'])), - 'new_password' => $request->variable('new_password', '', true), - 'password_confirm' => $request->variable('password_confirm', '', true), - ); - - // Validation data - we do not check the password complexity setting here - $check_ary = array( - 'new_password' => array( - array('string', true, $config['min_pass_chars'], $config['max_pass_chars']), - array('password')), - 'password_confirm' => array('string', true, $config['min_pass_chars'], $config['max_pass_chars']), - ); - - // Check username if altered - if ($data['username'] != $user_row['username']) - { - $check_ary += array( - 'username' => array( - array('string', false, $config['min_name_chars'], $config['max_name_chars']), - array('username', $user_row['username']) - ), - ); - } - - // Check email if altered - if ($data['email'] != $user_row['user_email']) - { - $check_ary += array( - 'email' => array( - array('string', false, 6, 60), - array('user_email', $user_row['user_email']), - ), - ); - } - - $error = validate_data($data, $check_ary); - - if ($data['new_password'] && $data['password_confirm'] != $data['new_password']) - { - $error[] = 'NEW_PASSWORD_ERROR'; - } - - if (!check_form_key($form_name)) - { - $error[] = 'FORM_INVALID'; - } - - // Instantiate passwords manager - /* @var $passwords_manager \phpbb\passwords\manager */ - $passwords_manager = $phpbb_container->get('passwords.manager'); - - // Which updates do we need to do? - $update_username = ($user_row['username'] != $data['username']) ? $data['username'] : false; - $update_password = $data['new_password'] && !$passwords_manager->check($data['new_password'], $user_row['user_password']); - $update_email = ($data['email'] != $user_row['user_email']) ? $data['email'] : false; - - if (!count($error)) - { - $sql_ary = array(); - - if ($user_row['user_type'] != USER_FOUNDER || $user->data['user_type'] == USER_FOUNDER) - { - // Only allow founders updating the founder status... - if ($user->data['user_type'] == USER_FOUNDER) - { - // Setting a normal member to be a founder - if ($data['user_founder'] && $user_row['user_type'] != USER_FOUNDER) - { - // Make sure the user is not setting an Inactive or ignored user to be a founder - if ($user_row['user_type'] == USER_IGNORE) - { - trigger_error($user->lang['CANNOT_SET_FOUNDER_IGNORED'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - if ($user_row['user_type'] == USER_INACTIVE) - { - trigger_error($user->lang['CANNOT_SET_FOUNDER_INACTIVE'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - $sql_ary['user_type'] = USER_FOUNDER; - } - else if (!$data['user_founder'] && $user_row['user_type'] == USER_FOUNDER) - { - // Check if at least one founder is present - $sql = 'SELECT user_id - FROM ' . USERS_TABLE . ' - WHERE user_type = ' . USER_FOUNDER . ' - AND user_id <> ' . $user_id; - $result = $db->sql_query_limit($sql, 1); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - $sql_ary['user_type'] = USER_NORMAL; - } - else - { - trigger_error($user->lang['AT_LEAST_ONE_FOUNDER'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - } - } - } - - /** - * Modify user data before we update it - * - * @event core.acp_users_overview_modify_data - * @var array user_row Current user data - * @var array data Submitted user data - * @var array sql_ary User data we udpate - * @since 3.1.0-a1 - */ - $vars = array('user_row', 'data', 'sql_ary'); - extract($phpbb_dispatcher->trigger_event('core.acp_users_overview_modify_data', compact($vars))); - - if ($update_username !== false) - { - $sql_ary['username'] = $update_username; - $sql_ary['username_clean'] = utf8_clean_string($update_username); - - $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_UPDATE_NAME', false, array( - 'reportee_id' => $user_id, - $user_row['username'], - $update_username - )); - } - - if ($update_email !== false) - { - $sql_ary += array( - 'user_email' => $update_email, - 'user_email_hash' => phpbb_email_hash($update_email), - ); - - $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_UPDATE_EMAIL', false, array( - 'reportee_id' => $user_id, - $user_row['username'], - $user_row['user_email'], - $update_email - )); - } - - if ($update_password) - { - $sql_ary += array( - 'user_password' => $passwords_manager->hash($data['new_password']), - 'user_passchg' => time(), - ); - - $user->reset_login_keys($user_id); - - $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_NEW_PASSWORD', false, array( - 'reportee_id' => $user_id, - $user_row['username'] - )); - } - - if (count($sql_ary)) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE user_id = ' . $user_id; - $db->sql_query($sql); - } - - if ($update_username) - { - user_update_name($user_row['username'], $update_username); - } - - // Let the users permissions being updated - $auth->acl_clear_prefetch($user_id); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_USER_UPDATE', false, array($data['username'])); - - trigger_error($user->lang['USER_OVERVIEW_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); - } - - // Replace "error" strings with their real, localised form - $error = array_map(array($user, 'lang'), $error); - } - - if ($user_id == $user->data['user_id']) - { - $quick_tool_ary = array('delsig' => 'DEL_SIG', 'delavatar' => 'DEL_AVATAR', 'moveposts' => 'MOVE_POSTS', 'delposts' => 'DEL_POSTS', 'delattach' => 'DEL_ATTACH', 'deloutbox' => 'DEL_OUTBOX'); - if ($user_row['user_new']) - { - $quick_tool_ary['leave_nr'] = 'LEAVE_NR'; - } - } - else - { - $quick_tool_ary = array(); - - if ($user_row['user_type'] != USER_FOUNDER) - { - $quick_tool_ary += array('banuser' => 'BAN_USER', 'banemail' => 'BAN_EMAIL', 'banip' => 'BAN_IP'); - } - - if ($user_row['user_type'] != USER_FOUNDER && $user_row['user_type'] != USER_IGNORE) - { - $quick_tool_ary += array('active' => (($user_row['user_type'] == USER_INACTIVE) ? 'ACTIVATE' : 'DEACTIVATE')); - } - - $quick_tool_ary += array('delsig' => 'DEL_SIG', 'delavatar' => 'DEL_AVATAR', 'moveposts' => 'MOVE_POSTS', 'delposts' => 'DEL_POSTS', 'delattach' => 'DEL_ATTACH', 'deloutbox' => 'DEL_OUTBOX'); - - if ($config['email_enable'] && ($user_row['user_type'] == USER_NORMAL || $user_row['user_type'] == USER_INACTIVE)) - { - $quick_tool_ary['reactivate'] = 'FORCE'; - } - - if ($user_row['user_new']) - { - $quick_tool_ary['leave_nr'] = 'LEAVE_NR'; - } - } - - if ($config['load_onlinetrack']) - { - $sql = 'SELECT MAX(session_time) AS session_time, MIN(session_viewonline) AS session_viewonline - FROM ' . SESSIONS_TABLE . " - WHERE session_user_id = $user_id"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $user_row['session_time'] = (isset($row['session_time'])) ? $row['session_time'] : 0; - $user_row['session_viewonline'] = (isset($row['session_viewonline'])) ? $row['session_viewonline'] : 0; - unset($row); - } - - /** - * Add additional quick tool options and overwrite user data - * - * @event core.acp_users_display_overview - * @var array user_row Array with user data - * @var array quick_tool_ary Ouick tool options - * @since 3.1.0-a1 - */ - $vars = array('user_row', 'quick_tool_ary'); - extract($phpbb_dispatcher->trigger_event('core.acp_users_display_overview', compact($vars))); - - $s_action_options = ''; - foreach ($quick_tool_ary as $value => $lang) - { - $s_action_options .= ''; - } - - $last_active = (!empty($user_row['session_time'])) ? $user_row['session_time'] : $user_row['user_lastvisit']; - - $inactive_reason = ''; - if ($user_row['user_type'] == USER_INACTIVE) - { - $inactive_reason = $user->lang['INACTIVE_REASON_UNKNOWN']; - - switch ($user_row['user_inactive_reason']) - { - case INACTIVE_REGISTER: - $inactive_reason = $user->lang['INACTIVE_REASON_REGISTER']; - break; - - case INACTIVE_PROFILE: - $inactive_reason = $user->lang['INACTIVE_REASON_PROFILE']; - break; - - case INACTIVE_MANUAL: - $inactive_reason = $user->lang['INACTIVE_REASON_MANUAL']; - break; - - case INACTIVE_REMIND: - $inactive_reason = $user->lang['INACTIVE_REASON_REMIND']; - break; - } - } - - // Posts in Queue - $sql = 'SELECT COUNT(post_id) as posts_in_queue - FROM ' . POSTS_TABLE . ' - WHERE poster_id = ' . $user_id . ' - AND ' . $db->sql_in_set('post_visibility', array(ITEM_UNAPPROVED, ITEM_REAPPROVE)); - $result = $db->sql_query($sql); - $user_row['posts_in_queue'] = (int) $db->sql_fetchfield('posts_in_queue'); - $db->sql_freeresult($result); - - $sql = 'SELECT post_id - FROM ' . POSTS_TABLE . ' - WHERE poster_id = '. $user_id; - $result = $db->sql_query_limit($sql, 1); - $user_row['user_has_posts'] = (bool) $db->sql_fetchfield('post_id'); - $db->sql_freeresult($result); - - $template->assign_vars(array( - 'L_NAME_CHARS_EXPLAIN' => $user->lang($config['allow_name_chars'] . '_EXPLAIN', $user->lang('CHARACTERS', (int) $config['min_name_chars']), $user->lang('CHARACTERS', (int) $config['max_name_chars'])), - 'L_CHANGE_PASSWORD_EXPLAIN' => $user->lang($config['pass_complex'] . '_EXPLAIN', $user->lang('CHARACTERS', (int) $config['min_pass_chars']), $user->lang('CHARACTERS', (int) $config['max_pass_chars'])), - 'L_POSTS_IN_QUEUE' => $user->lang('NUM_POSTS_IN_QUEUE', $user_row['posts_in_queue']), - 'S_FOUNDER' => ($user->data['user_type'] == USER_FOUNDER) ? true : false, - - 'S_OVERVIEW' => true, - 'S_USER_IP' => ($user_row['user_ip']) ? true : false, - 'S_USER_FOUNDER' => ($user_row['user_type'] == USER_FOUNDER) ? true : false, - 'S_ACTION_OPTIONS' => $s_action_options, - 'S_OWN_ACCOUNT' => ($user_id == $user->data['user_id']) ? true : false, - 'S_USER_INACTIVE' => ($user_row['user_type'] == USER_INACTIVE) ? true : false, - - 'U_SHOW_IP' => $this->u_action . "&u=$user_id&ip=" . (($ip == 'ip') ? 'hostname' : 'ip'), - 'U_WHOIS' => $this->u_action . "&action=whois&user_ip={$user_row['user_ip']}", - 'U_MCP_QUEUE' => ($auth->acl_getf_global('m_approve')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue', true, $user->session_id) : '', - 'U_SEARCH_USER' => ($config['load_search'] && $auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id={$user_row['user_id']}&sr=posts") : '', - - 'U_SWITCH_PERMISSIONS' => ($auth->acl_get('a_switchperm') && $user->data['user_id'] != $user_row['user_id']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", "mode=switch_perm&u={$user_row['user_id']}&hash=" . generate_link_hash('switchperm')) : '', - - 'POSTS_IN_QUEUE' => $user_row['posts_in_queue'], - 'USER' => $user_row['username'], - 'USER_REGISTERED' => $user->format_date($user_row['user_regdate']), - 'REGISTERED_IP' => ($ip == 'hostname') ? gethostbyaddr($user_row['user_ip']) : $user_row['user_ip'], - 'USER_LASTACTIVE' => ($last_active) ? $user->format_date($last_active) : ' - ', - 'USER_EMAIL' => $user_row['user_email'], - 'USER_WARNINGS' => $user_row['user_warnings'], - 'USER_POSTS' => $user_row['user_posts'], - 'USER_HAS_POSTS' => $user_row['user_has_posts'], - 'USER_INACTIVE_REASON' => $inactive_reason, - )); - - break; - - case 'feedback': - - $user->add_lang('mcp'); - - // Set up general vars - $start = $request->variable('start', 0); - $deletemark = (isset($_POST['delmarked'])) ? true : false; - $deleteall = (isset($_POST['delall'])) ? true : false; - $marked = $request->variable('mark', array(0)); - $message = $request->variable('message', '', true); - - /* @var $pagination \phpbb\pagination */ - $pagination = $phpbb_container->get('pagination'); - - // Sort keys - $sort_days = $request->variable('st', 0); - $sort_key = $request->variable('sk', 't'); - $sort_dir = $request->variable('sd', 'd'); - - // Delete entries if requested and able - if (($deletemark || $deleteall) && $auth->acl_get('a_clearlogs')) - { - if (!check_form_key($form_name)) - { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - $where_sql = ''; - if ($deletemark && $marked) - { - $sql_in = array(); - foreach ($marked as $mark) - { - $sql_in[] = $mark; - } - $where_sql = ' AND ' . $db->sql_in_set('log_id', $sql_in); - unset($sql_in); - } - - if ($where_sql || $deleteall) - { - $sql = 'DELETE FROM ' . LOG_TABLE . ' - WHERE log_type = ' . LOG_USERS . " - AND reportee_id = $user_id - $where_sql"; - $db->sql_query($sql); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_CLEAR_USER', false, array($user_row['username'])); - } - } - - if ($submit && $message) - { - if (!check_form_key($form_name)) - { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_FEEDBACK', false, array($user_row['username'])); - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_USER_FEEDBACK', false, array( - 'forum_id' => 0, - 'topic_id' => 0, - $user_row['username'] - )); - $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_GENERAL', false, array( - 'reportee_id' => $user_id, - $message - )); - - trigger_error($user->lang['USER_FEEDBACK_ADDED'] . adm_back_link($this->u_action . '&u=' . $user_id)); - } - - // Sorting - $limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); - $sort_by_text = array('u' => $user->lang['SORT_USERNAME'], 't' => $user->lang['SORT_DATE'], 'i' => $user->lang['SORT_IP'], 'o' => $user->lang['SORT_ACTION']); - $sort_by_sql = array('u' => 'u.username_clean', 't' => 'l.log_time', 'i' => 'l.log_ip', 'o' => 'l.log_operation'); - - $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; - gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); - - // Define where and sort sql for use in displaying logs - $sql_where = ($sort_days) ? (time() - ($sort_days * 86400)) : 0; - $sql_sort = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'); - - // Grab log data - $log_data = array(); - $log_count = 0; - $start = view_log('user', $log_data, $log_count, $config['topics_per_page'], $start, 0, 0, $user_id, $sql_where, $sql_sort); - - $base_url = $this->u_action . "&u=$user_id&$u_sort_param"; - $pagination->generate_template_pagination($base_url, 'pagination', 'start', $log_count, $config['topics_per_page'], $start); - - $template->assign_vars(array( - 'S_FEEDBACK' => true, - - 'S_LIMIT_DAYS' => $s_limit_days, - 'S_SORT_KEY' => $s_sort_key, - 'S_SORT_DIR' => $s_sort_dir, - 'S_CLEARLOGS' => $auth->acl_get('a_clearlogs')) - ); - - foreach ($log_data as $row) - { - $template->assign_block_vars('log', array( - 'USERNAME' => $row['username_full'], - 'IP' => $row['ip'], - 'DATE' => $user->format_date($row['time']), - 'ACTION' => nl2br($row['action']), - 'ID' => $row['id']) - ); - } - - break; - - case 'warnings': - $user->add_lang('mcp'); - - // Set up general vars - $deletemark = (isset($_POST['delmarked'])) ? true : false; - $deleteall = (isset($_POST['delall'])) ? true : false; - $confirm = (isset($_POST['confirm'])) ? true : false; - $marked = $request->variable('mark', array(0)); - - // Delete entries if requested and able - if ($deletemark || $deleteall || $confirm) - { - if (confirm_box(true)) - { - $where_sql = ''; - $deletemark = $request->variable('delmarked', 0); - $deleteall = $request->variable('delall', 0); - if ($deletemark && $marked) - { - $where_sql = ' AND ' . $db->sql_in_set('warning_id', array_values($marked)); - } - - if ($where_sql || $deleteall) - { - $sql = 'DELETE FROM ' . WARNINGS_TABLE . " - WHERE user_id = $user_id - $where_sql"; - $db->sql_query($sql); - - if ($deleteall) - { - $log_warnings = $deleted_warnings = 0; - } - else - { - $num_warnings = (int) $db->sql_affectedrows(); - $deleted_warnings = ' user_warnings - ' . $num_warnings; - $log_warnings = ($num_warnings > 2) ? 2 : $num_warnings; - } - - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_warnings = $deleted_warnings - WHERE user_id = $user_id"; - $db->sql_query($sql); - - if ($log_warnings) - { - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_WARNINGS_DELETED', false, array($user_row['username'], $num_warnings)); - } - else - { - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_WARNINGS_DELETED_ALL', false, array($user_row['username'])); - } - } - } - else - { - $s_hidden_fields = array( - 'i' => $id, - 'mode' => $mode, - 'u' => $user_id, - 'mark' => $marked, - ); - if (isset($_POST['delmarked'])) - { - $s_hidden_fields['delmarked'] = 1; - } - if (isset($_POST['delall'])) - { - $s_hidden_fields['delall'] = 1; - } - if (isset($_POST['delall']) || (isset($_POST['delmarked']) && count($marked))) - { - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields($s_hidden_fields)); - } - } - } - - $sql = 'SELECT w.warning_id, w.warning_time, w.post_id, l.log_operation, l.log_data, l.user_id AS mod_user_id, m.username AS mod_username, m.user_colour AS mod_user_colour - FROM ' . WARNINGS_TABLE . ' w - LEFT JOIN ' . LOG_TABLE . ' l - ON (w.log_id = l.log_id) - LEFT JOIN ' . USERS_TABLE . ' m - ON (l.user_id = m.user_id) - WHERE w.user_id = ' . $user_id . ' - ORDER BY w.warning_time DESC'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if (!$row['log_operation']) - { - // We do not have a log-entry anymore, so there is no data available - $row['action'] = $user->lang['USER_WARNING_LOG_DELETED']; - } - else - { - $row['action'] = (isset($user->lang[$row['log_operation']])) ? $user->lang[$row['log_operation']] : '{' . ucfirst(str_replace('_', ' ', $row['log_operation'])) . '}'; - if (!empty($row['log_data'])) - { - $log_data_ary = @unserialize($row['log_data']); - $log_data_ary = ($log_data_ary === false) ? array() : $log_data_ary; - - if (isset($user->lang[$row['log_operation']])) - { - // Check if there are more occurrences of % than arguments, if there are we fill out the arguments array - // It doesn't matter if we add more arguments than placeholders - if ((substr_count($row['action'], '%') - count($log_data_ary)) > 0) - { - $log_data_ary = array_merge($log_data_ary, array_fill(0, substr_count($row['action'], '%') - count($log_data_ary), '')); - } - $row['action'] = vsprintf($row['action'], $log_data_ary); - $row['action'] = bbcode_nl2br(censor_text($row['action'])); - } - else if (!empty($log_data_ary)) - { - $row['action'] .= '
' . implode('', $log_data_ary); - } - } - } - - $template->assign_block_vars('warn', array( - 'ID' => $row['warning_id'], - 'USERNAME' => ($row['log_operation']) ? get_username_string('full', $row['mod_user_id'], $row['mod_username'], $row['mod_user_colour']) : '-', - 'ACTION' => make_clickable($row['action']), - 'DATE' => $user->format_date($row['warning_time']), - )); - } - $db->sql_freeresult($result); - - $template->assign_vars(array( - 'S_WARNINGS' => true, - )); - - break; - - case 'profile': - - if (!function_exists('user_get_id_name')) - { - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - } - - /* @var $cp \phpbb\profilefields\manager */ - $cp = $phpbb_container->get('profilefields.manager'); - - $cp_data = $cp_error = array(); - - $sql = 'SELECT lang_id - FROM ' . LANG_TABLE . " - WHERE lang_iso = '" . $db->sql_escape($user->data['user_lang']) . "'"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $user_row['iso_lang_id'] = $row['lang_id']; - - $data = array( - 'jabber' => $request->variable('jabber', $user_row['user_jabber'], true), - 'bday_day' => 0, - 'bday_month' => 0, - 'bday_year' => 0, - ); - - if ($user_row['user_birthday']) - { - list($data['bday_day'], $data['bday_month'], $data['bday_year']) = explode('-', $user_row['user_birthday']); - } - - $data['bday_day'] = $request->variable('bday_day', $data['bday_day']); - $data['bday_month'] = $request->variable('bday_month', $data['bday_month']); - $data['bday_year'] = $request->variable('bday_year', $data['bday_year']); - $data['user_birthday'] = sprintf('%2d-%2d-%4d', $data['bday_day'], $data['bday_month'], $data['bday_year']); - - /** - * Modify user data on editing profile in ACP - * - * @event core.acp_users_modify_profile - * @var array data Array with user profile data - * @var bool submit Flag indicating if submit button has been pressed - * @var int user_id The user id - * @var array user_row Array with the full user data - * @since 3.1.4-RC1 - */ - $vars = array('data', 'submit', 'user_id', 'user_row'); - extract($phpbb_dispatcher->trigger_event('core.acp_users_modify_profile', compact($vars))); - - if ($submit) - { - $error = validate_data($data, array( - 'jabber' => array( - array('string', true, 5, 255), - array('jabber')), - 'bday_day' => array('num', true, 1, 31), - 'bday_month' => array('num', true, 1, 12), - 'bday_year' => array('num', true, 1901, gmdate('Y', time())), - 'user_birthday' => array('date', true), - )); - - // validate custom profile fields - $cp->submit_cp_field('profile', $user_row['iso_lang_id'], $cp_data, $cp_error); - - if (count($cp_error)) - { - $error = array_merge($error, $cp_error); - } - if (!check_form_key($form_name)) - { - $error[] = 'FORM_INVALID'; - } - - /** - * Validate profile data in ACP before submitting to the database - * - * @event core.acp_users_profile_validate - * @var array data Array with user profile data - * @var int user_id The user id - * @var array user_row Array with the full user data - * @var array error Array with the form errors - * @since 3.1.4-RC1 - * @changed 3.1.12-RC1 Removed submit, added user_id, user_row - */ - $vars = array('data', 'user_id', 'user_row', 'error'); - extract($phpbb_dispatcher->trigger_event('core.acp_users_profile_validate', compact($vars))); - - if (!count($error)) - { - $sql_ary = array( - 'user_jabber' => $data['jabber'], - 'user_birthday' => $data['user_birthday'], - ); - - /** - * Modify profile data in ACP before submitting to the database - * - * @event core.acp_users_profile_modify_sql_ary - * @var array cp_data Array with the user custom profile fields data - * @var array data Array with user profile data - * @var int user_id The user id - * @var array user_row Array with the full user data - * @var array sql_ary Array with sql data - * @since 3.1.4-RC1 - */ - $vars = array('cp_data', 'data', 'user_id', 'user_row', 'sql_ary'); - extract($phpbb_dispatcher->trigger_event('core.acp_users_profile_modify_sql_ary', compact($vars))); - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " - WHERE user_id = $user_id"; - $db->sql_query($sql); - - // Update Custom Fields - $cp->update_profile_field_data($user_id, $cp_data); - - trigger_error($user->lang['USER_PROFILE_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); - } - - // Replace "error" strings with their real, localised form - $error = array_map(array($user, 'lang'), $error); - } - - $s_birthday_day_options = ''; - for ($i = 1; $i < 32; $i++) - { - $selected = ($i == $data['bday_day']) ? ' selected="selected"' : ''; - $s_birthday_day_options .= ""; - } - - $s_birthday_month_options = ''; - for ($i = 1; $i < 13; $i++) - { - $selected = ($i == $data['bday_month']) ? ' selected="selected"' : ''; - $s_birthday_month_options .= ""; - } - - $now = getdate(); - $s_birthday_year_options = ''; - for ($i = $now['year'] - 100; $i <= $now['year']; $i++) - { - $selected = ($i == $data['bday_year']) ? ' selected="selected"' : ''; - $s_birthday_year_options .= ""; - } - unset($now); - - $template->assign_vars(array( - 'JABBER' => $data['jabber'], - 'S_BIRTHDAY_DAY_OPTIONS' => $s_birthday_day_options, - 'S_BIRTHDAY_MONTH_OPTIONS' => $s_birthday_month_options, - 'S_BIRTHDAY_YEAR_OPTIONS' => $s_birthday_year_options, - - 'S_PROFILE' => true) - ); - - // Get additional profile fields and assign them to the template block var 'profile_fields' - $user->get_profile_fields($user_id); - - $cp->generate_profile_fields('profile', $user_row['iso_lang_id']); - - break; - - case 'prefs': - - if (!function_exists('user_get_id_name')) - { - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - } - - $data = array( - 'dateformat' => $request->variable('dateformat', $user_row['user_dateformat'], true), - 'lang' => basename($request->variable('lang', $user_row['user_lang'])), - 'tz' => $request->variable('tz', $user_row['user_timezone']), - 'style' => $request->variable('style', $user_row['user_style']), - 'viewemail' => $request->variable('viewemail', $user_row['user_allow_viewemail']), - 'massemail' => $request->variable('massemail', $user_row['user_allow_massemail']), - 'hideonline' => $request->variable('hideonline', !$user_row['user_allow_viewonline']), - 'notifymethod' => $request->variable('notifymethod', $user_row['user_notify_type']), - 'notifypm' => $request->variable('notifypm', $user_row['user_notify_pm']), - 'allowpm' => $request->variable('allowpm', $user_row['user_allow_pm']), - - 'topic_sk' => $request->variable('topic_sk', ($user_row['user_topic_sortby_type']) ? $user_row['user_topic_sortby_type'] : 't'), - 'topic_sd' => $request->variable('topic_sd', ($user_row['user_topic_sortby_dir']) ? $user_row['user_topic_sortby_dir'] : 'd'), - 'topic_st' => $request->variable('topic_st', ($user_row['user_topic_show_days']) ? $user_row['user_topic_show_days'] : 0), - - 'post_sk' => $request->variable('post_sk', ($user_row['user_post_sortby_type']) ? $user_row['user_post_sortby_type'] : 't'), - 'post_sd' => $request->variable('post_sd', ($user_row['user_post_sortby_dir']) ? $user_row['user_post_sortby_dir'] : 'a'), - 'post_st' => $request->variable('post_st', ($user_row['user_post_show_days']) ? $user_row['user_post_show_days'] : 0), - - 'view_images' => $request->variable('view_images', $this->optionget($user_row, 'viewimg')), - 'view_flash' => $request->variable('view_flash', $this->optionget($user_row, 'viewflash')), - 'view_smilies' => $request->variable('view_smilies', $this->optionget($user_row, 'viewsmilies')), - 'view_sigs' => $request->variable('view_sigs', $this->optionget($user_row, 'viewsigs')), - 'view_avatars' => $request->variable('view_avatars', $this->optionget($user_row, 'viewavatars')), - 'view_wordcensor' => $request->variable('view_wordcensor', $this->optionget($user_row, 'viewcensors')), - - 'bbcode' => $request->variable('bbcode', $this->optionget($user_row, 'bbcode')), - 'smilies' => $request->variable('smilies', $this->optionget($user_row, 'smilies')), - 'sig' => $request->variable('sig', $this->optionget($user_row, 'attachsig')), - 'notify' => $request->variable('notify', $user_row['user_notify']), - ); - - /** - * Modify users preferences data - * - * @event core.acp_users_prefs_modify_data - * @var array data Array with users preferences data - * @var array user_row Array with user data - * @since 3.1.0-b3 - */ - $vars = array('data', 'user_row'); - extract($phpbb_dispatcher->trigger_event('core.acp_users_prefs_modify_data', compact($vars))); - - if ($submit) - { - $error = validate_data($data, array( - 'dateformat' => array('string', false, 1, 64), - 'lang' => array('match', false, '#^[a-z_\-]{2,}$#i'), - 'tz' => array('timezone'), - - 'topic_sk' => array('string', false, 1, 1), - 'topic_sd' => array('string', false, 1, 1), - 'post_sk' => array('string', false, 1, 1), - 'post_sd' => array('string', false, 1, 1), - )); - - if (!check_form_key($form_name)) - { - $error[] = 'FORM_INVALID'; - } - - if (!count($error)) - { - $this->optionset($user_row, 'viewimg', $data['view_images']); - $this->optionset($user_row, 'viewflash', $data['view_flash']); - $this->optionset($user_row, 'viewsmilies', $data['view_smilies']); - $this->optionset($user_row, 'viewsigs', $data['view_sigs']); - $this->optionset($user_row, 'viewavatars', $data['view_avatars']); - $this->optionset($user_row, 'viewcensors', $data['view_wordcensor']); - $this->optionset($user_row, 'bbcode', $data['bbcode']); - $this->optionset($user_row, 'smilies', $data['smilies']); - $this->optionset($user_row, 'attachsig', $data['sig']); - - $sql_ary = array( - 'user_options' => $user_row['user_options'], - - 'user_allow_pm' => $data['allowpm'], - 'user_allow_viewemail' => $data['viewemail'], - 'user_allow_massemail' => $data['massemail'], - 'user_allow_viewonline' => !$data['hideonline'], - 'user_notify_type' => $data['notifymethod'], - 'user_notify_pm' => $data['notifypm'], - - 'user_dateformat' => $data['dateformat'], - 'user_lang' => $data['lang'], - 'user_timezone' => $data['tz'], - 'user_style' => $data['style'], - - 'user_topic_sortby_type' => $data['topic_sk'], - 'user_post_sortby_type' => $data['post_sk'], - 'user_topic_sortby_dir' => $data['topic_sd'], - 'user_post_sortby_dir' => $data['post_sd'], - - 'user_topic_show_days' => $data['topic_st'], - 'user_post_show_days' => $data['post_st'], - - 'user_notify' => $data['notify'], - ); - - /** - * Modify SQL query before users preferences are updated - * - * @event core.acp_users_prefs_modify_sql - * @var array data Array with users preferences data - * @var array user_row Array with user data - * @var array sql_ary SQL array with users preferences data to update - * @var array error Array with errors data - * @since 3.1.0-b3 - */ - $vars = array('data', 'user_row', 'sql_ary', 'error'); - extract($phpbb_dispatcher->trigger_event('core.acp_users_prefs_modify_sql', compact($vars))); - - if (!count($error)) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " - WHERE user_id = $user_id"; - $db->sql_query($sql); - - // Check if user has an active session - if ($user_row['session_id']) - { - // We'll update the session if user_allow_viewonline has changed and the user is a bot - // Or if it's a regular user and the admin set it to hide the session - if ($user_row['user_allow_viewonline'] != $sql_ary['user_allow_viewonline'] && $user_row['user_type'] == USER_IGNORE - || $user_row['user_allow_viewonline'] && !$sql_ary['user_allow_viewonline']) - { - // We also need to check if the user has the permission to cloak. - $user_auth = new \phpbb\auth\auth(); - $user_auth->acl($user_row); - - $session_sql_ary = array( - 'session_viewonline' => ($user_auth->acl_get('u_hideonline')) ? $sql_ary['user_allow_viewonline'] : true, - ); - - $sql = 'UPDATE ' . SESSIONS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $session_sql_ary) . " - WHERE session_user_id = $user_id"; - $db->sql_query($sql); - - unset($user_auth); - } - } - - trigger_error($user->lang['USER_PREFS_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); - } - } - - // Replace "error" strings with their real, localised form - $error = array_map(array($user, 'lang'), $error); - } - - $dateformat_options = ''; - foreach ($user->lang['dateformats'] as $format => $null) - { - $dateformat_options .= ''; - } - - $s_custom = false; - - $dateformat_options .= ''; - - $sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']); - - // Topic ordering options - $limit_topic_days = array(0 => $user->lang['ALL_TOPICS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); - $sort_by_topic_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 'r' => $user->lang['REPLIES'], 's' => $user->lang['SUBJECT'], 'v' => $user->lang['VIEWS']); - - // Post ordering options - $limit_post_days = array(0 => $user->lang['ALL_POSTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); - $sort_by_post_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']); - - $_options = array('topic', 'post'); - foreach ($_options as $sort_option) - { - ${'s_limit_' . $sort_option . '_days'} = ''; - - ${'s_sort_' . $sort_option . '_key'} = ''; - - ${'s_sort_' . $sort_option . '_dir'} = ''; - } - - phpbb_timezone_select($template, $user, $data['tz'], true); - $user_prefs_data = array( - 'S_PREFS' => true, - 'S_JABBER_DISABLED' => ($config['jab_enable'] && $user_row['user_jabber'] && @extension_loaded('xml')) ? false : true, - - 'VIEW_EMAIL' => $data['viewemail'], - 'MASS_EMAIL' => $data['massemail'], - 'ALLOW_PM' => $data['allowpm'], - 'HIDE_ONLINE' => $data['hideonline'], - 'NOTIFY_EMAIL' => ($data['notifymethod'] == NOTIFY_EMAIL) ? true : false, - 'NOTIFY_IM' => ($data['notifymethod'] == NOTIFY_IM) ? true : false, - 'NOTIFY_BOTH' => ($data['notifymethod'] == NOTIFY_BOTH) ? true : false, - 'NOTIFY_PM' => $data['notifypm'], - 'BBCODE' => $data['bbcode'], - 'SMILIES' => $data['smilies'], - 'ATTACH_SIG' => $data['sig'], - 'NOTIFY' => $data['notify'], - 'VIEW_IMAGES' => $data['view_images'], - 'VIEW_FLASH' => $data['view_flash'], - 'VIEW_SMILIES' => $data['view_smilies'], - 'VIEW_SIGS' => $data['view_sigs'], - 'VIEW_AVATARS' => $data['view_avatars'], - 'VIEW_WORDCENSOR' => $data['view_wordcensor'], - - 'S_TOPIC_SORT_DAYS' => $s_limit_topic_days, - 'S_TOPIC_SORT_KEY' => $s_sort_topic_key, - 'S_TOPIC_SORT_DIR' => $s_sort_topic_dir, - 'S_POST_SORT_DAYS' => $s_limit_post_days, - 'S_POST_SORT_KEY' => $s_sort_post_key, - 'S_POST_SORT_DIR' => $s_sort_post_dir, - - 'DATE_FORMAT' => $data['dateformat'], - 'S_DATEFORMAT_OPTIONS' => $dateformat_options, - 'S_CUSTOM_DATEFORMAT' => $s_custom, - 'DEFAULT_DATEFORMAT' => $config['default_dateformat'], - 'A_DEFAULT_DATEFORMAT' => addslashes($config['default_dateformat']), - - 'S_LANG_OPTIONS' => language_select($data['lang']), - 'S_STYLE_OPTIONS' => style_select($data['style']), - ); - - /** - * Modify users preferences data before assigning it to the template - * - * @event core.acp_users_prefs_modify_template_data - * @var array data Array with users preferences data - * @var array user_row Array with user data - * @var array user_prefs_data Array with users preferences data to be assigned to the template - * @since 3.1.0-b3 - */ - $vars = array('data', 'user_row', 'user_prefs_data'); - extract($phpbb_dispatcher->trigger_event('core.acp_users_prefs_modify_template_data', compact($vars))); - - $template->assign_vars($user_prefs_data); - - break; - - case 'avatar': - - $avatars_enabled = false; - /** @var \phpbb\avatar\manager $phpbb_avatar_manager */ - $phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); - - if ($config['allow_avatar']) - { - $avatar_drivers = $phpbb_avatar_manager->get_enabled_drivers(); - - // This is normalised data, without the user_ prefix - $avatar_data = \phpbb\avatar\manager::clean_row($user_row, 'user'); - - if ($submit) - { - if (check_form_key($form_name)) - { - $driver_name = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', '')); - - if (in_array($driver_name, $avatar_drivers) && !$request->is_set_post('avatar_delete')) - { - $driver = $phpbb_avatar_manager->get_driver($driver_name); - $result = $driver->process_form($request, $template, $user, $avatar_data, $error); - - if ($result && empty($error)) - { - // Success! Lets save the result in the database - $result = array( - 'user_avatar_type' => $driver_name, - 'user_avatar' => $result['avatar'], - 'user_avatar_width' => $result['avatar_width'], - 'user_avatar_height' => $result['avatar_height'], - ); - - /** - * Modify users preferences data before assigning it to the template - * - * @event core.acp_users_avatar_sql - * @var array user_row Array with user data - * @var array result Array with user avatar data to be updated in the DB - * @since 3.2.4-RC1 - */ - $vars = array('user_row', 'result'); - extract($phpbb_dispatcher->trigger_event('core.acp_users_avatar_sql', compact($vars))); - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $result) . ' - WHERE user_id = ' . (int) $user_id; - - $db->sql_query($sql); - trigger_error($user->lang['USER_AVATAR_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); - } - } - } - else - { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - } - - // Handle deletion of avatars - if ($request->is_set_post('avatar_delete')) - { - if (!confirm_box(true)) - { - confirm_box(false, $user->lang('CONFIRM_AVATAR_DELETE'), build_hidden_fields(array( - 'avatar_delete' => true)) - ); - } - else - { - $phpbb_avatar_manager->handle_avatar_delete($db, $user, $avatar_data, USERS_TABLE, 'user_'); - - trigger_error($user->lang['USER_AVATAR_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); - } - } - - $selected_driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', $user_row['user_avatar_type'])); - - // Assign min and max values before generating avatar driver html - $template->assign_vars(array( - 'AVATAR_MIN_WIDTH' => $config['avatar_min_width'], - 'AVATAR_MAX_WIDTH' => $config['avatar_max_width'], - 'AVATAR_MIN_HEIGHT' => $config['avatar_min_height'], - 'AVATAR_MAX_HEIGHT' => $config['avatar_max_height'], - )); - - foreach ($avatar_drivers as $current_driver) - { - $driver = $phpbb_avatar_manager->get_driver($current_driver); - - $avatars_enabled = true; - $template->set_filenames(array( - 'avatar' => $driver->get_acp_template_name(), - )); - - if ($driver->prepare_form($request, $template, $user, $avatar_data, $error)) - { - $driver_name = $phpbb_avatar_manager->prepare_driver_name($current_driver); - $driver_upper = strtoupper($driver_name); - - $template->assign_block_vars('avatar_drivers', array( - 'L_TITLE' => $user->lang($driver_upper . '_TITLE'), - 'L_EXPLAIN' => $user->lang($driver_upper . '_EXPLAIN'), - - 'DRIVER' => $driver_name, - 'SELECTED' => $current_driver == $selected_driver, - 'OUTPUT' => $template->assign_display('avatar'), - )); - } - } - } - - // Avatar manager is not initialized if avatars are disabled - if (isset($phpbb_avatar_manager)) - { - // Replace "error" strings with their real, localised form - $error = $phpbb_avatar_manager->localize_errors($user, $error); - } - - $avatar = phpbb_get_user_avatar($user_row, 'USER_AVATAR', true); - - $template->assign_vars(array( - 'S_AVATAR' => true, - 'ERROR' => (!empty($error)) ? implode('
', $error) : '', - 'AVATAR' => (empty($avatar) ? '' : $avatar), - - 'S_FORM_ENCTYPE' => ' enctype="multipart/form-data"', - - 'L_AVATAR_EXPLAIN' => $user->lang(($config['avatar_filesize'] == 0) ? 'AVATAR_EXPLAIN_NO_FILESIZE' : 'AVATAR_EXPLAIN', $config['avatar_max_width'], $config['avatar_max_height'], $config['avatar_filesize'] / 1024), - - 'S_AVATARS_ENABLED' => ($config['allow_avatar'] && $avatars_enabled), - )); - - break; - - case 'rank': - - if ($submit) - { - if (!check_form_key($form_name)) - { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - $rank_id = $request->variable('user_rank', 0); - - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_rank = $rank_id - WHERE user_id = $user_id"; - $db->sql_query($sql); - - trigger_error($user->lang['USER_RANK_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); - } - - $sql = 'SELECT * - FROM ' . RANKS_TABLE . ' - WHERE rank_special = 1 - ORDER BY rank_title'; - $result = $db->sql_query($sql); - - $s_rank_options = ''; - - while ($row = $db->sql_fetchrow($result)) - { - $selected = ($user_row['user_rank'] && $row['rank_id'] == $user_row['user_rank']) ? ' selected="selected"' : ''; - $s_rank_options .= ''; - } - $db->sql_freeresult($result); - - $template->assign_vars(array( - 'S_RANK' => true, - 'S_RANK_OPTIONS' => $s_rank_options) - ); - - break; - - case 'sig': - - if (!function_exists('display_custom_bbcodes')) - { - include($phpbb_root_path . 'includes/functions_display.' . $phpEx); - } - - $enable_bbcode = ($config['allow_sig_bbcode']) ? $this->optionget($user_row, 'sig_bbcode') : false; - $enable_smilies = ($config['allow_sig_smilies']) ? $this->optionget($user_row, 'sig_smilies') : false; - $enable_urls = ($config['allow_sig_links']) ? $this->optionget($user_row, 'sig_links') : false; - - $bbcode_flags = ($enable_bbcode ? OPTION_FLAG_BBCODE : 0) + ($enable_smilies ? OPTION_FLAG_SMILIES : 0) + ($enable_urls ? OPTION_FLAG_LINKS : 0); - - $decoded_message = generate_text_for_edit($user_row['user_sig'], $user_row['user_sig_bbcode_uid'], $bbcode_flags); - $signature = $request->variable('signature', $decoded_message['text'], true); - $signature_preview = ''; - - if ($submit || $request->is_set_post('preview')) - { - $enable_bbcode = ($config['allow_sig_bbcode']) ? !$request->variable('disable_bbcode', false) : false; - $enable_smilies = ($config['allow_sig_smilies']) ? !$request->variable('disable_smilies', false) : false; - $enable_urls = ($config['allow_sig_links']) ? !$request->variable('disable_magic_url', false) : false; - - if (!check_form_key($form_name)) - { - $error[] = 'FORM_INVALID'; - } - } - - $bbcode_uid = $bbcode_bitfield = $bbcode_flags = ''; - $warn_msg = generate_text_for_storage( - $signature, - $bbcode_uid, - $bbcode_bitfield, - $bbcode_flags, - $enable_bbcode, - $enable_urls, - $enable_smilies, - $config['allow_sig_img'], - $config['allow_sig_flash'], - true, - $config['allow_sig_links'], - 'sig' - ); - - if (count($warn_msg)) - { - $error += $warn_msg; - } - - if (!$submit) - { - // Parse it for displaying - $signature_preview = generate_text_for_display($signature, $bbcode_uid, $bbcode_bitfield, $bbcode_flags); - } - else - { - if (!count($error)) - { - $this->optionset($user_row, 'sig_bbcode', $enable_bbcode); - $this->optionset($user_row, 'sig_smilies', $enable_smilies); - $this->optionset($user_row, 'sig_links', $enable_urls); - - $sql_ary = array( - 'user_sig' => $signature, - 'user_options' => $user_row['user_options'], - 'user_sig_bbcode_uid' => $bbcode_uid, - 'user_sig_bbcode_bitfield' => $bbcode_bitfield, - ); - - /** - * Modify user signature before it is stored in the DB - * - * @event core.acp_users_modify_signature_sql_ary - * @var array user_row Array with user data - * @var array sql_ary Array with user signature data to be updated in the DB - * @since 3.2.4-RC1 - */ - $vars = array('user_row', 'sql_ary'); - extract($phpbb_dispatcher->trigger_event('core.acp_users_modify_signature_sql_ary', compact($vars))); - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE user_id = ' . $user_id; - $db->sql_query($sql); - - trigger_error($user->lang['USER_SIG_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); - } - } - - // Replace "error" strings with their real, localised form - $error = array_map(array($user, 'lang'), $error); - - if ($request->is_set_post('preview')) - { - $decoded_message = generate_text_for_edit($signature, $bbcode_uid, $bbcode_flags); - } - - /** @var \phpbb\controller\helper $controller_helper */ - $controller_helper = $phpbb_container->get('controller.helper'); - - $template->assign_vars(array( - 'S_SIGNATURE' => true, - - 'SIGNATURE' => $decoded_message['text'], - 'SIGNATURE_PREVIEW' => $signature_preview, - - 'S_BBCODE_CHECKED' => (!$enable_bbcode) ? ' checked="checked"' : '', - 'S_SMILIES_CHECKED' => (!$enable_smilies) ? ' checked="checked"' : '', - 'S_MAGIC_URL_CHECKED' => (!$enable_urls) ? ' checked="checked"' : '', - - 'BBCODE_STATUS' => $user->lang(($config['allow_sig_bbcode'] ? 'BBCODE_IS_ON' : 'BBCODE_IS_OFF'), '', ''), - 'SMILIES_STATUS' => ($config['allow_sig_smilies']) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'], - 'IMG_STATUS' => ($config['allow_sig_img']) ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'], - 'FLASH_STATUS' => ($config['allow_sig_flash']) ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'], - 'URL_STATUS' => ($config['allow_sig_links']) ? $user->lang['URL_IS_ON'] : $user->lang['URL_IS_OFF'], - - 'L_SIGNATURE_EXPLAIN' => $user->lang('SIGNATURE_EXPLAIN', (int) $config['max_sig_chars']), - - 'S_BBCODE_ALLOWED' => $config['allow_sig_bbcode'], - 'S_SMILIES_ALLOWED' => $config['allow_sig_smilies'], - 'S_BBCODE_IMG' => ($config['allow_sig_img']) ? true : false, - 'S_BBCODE_FLASH' => ($config['allow_sig_flash']) ? true : false, - 'S_LINKS_ALLOWED' => ($config['allow_sig_links']) ? true : false) - ); - - // Assigning custom bbcodes - display_custom_bbcodes(); - - break; - - case 'attach': - /* @var $pagination \phpbb\pagination */ - $pagination = $phpbb_container->get('pagination'); - - $start = $request->variable('start', 0); - $deletemark = (isset($_POST['delmarked'])) ? true : false; - $marked = $request->variable('mark', array(0)); - - // Sort keys - $sort_key = $request->variable('sk', 'a'); - $sort_dir = $request->variable('sd', 'd'); - - if ($deletemark && count($marked)) - { - $sql = 'SELECT attach_id - FROM ' . ATTACHMENTS_TABLE . ' - WHERE poster_id = ' . $user_id . ' - AND is_orphan = 0 - AND ' . $db->sql_in_set('attach_id', $marked); - $result = $db->sql_query($sql); - - $marked = array(); - while ($row = $db->sql_fetchrow($result)) - { - $marked[] = $row['attach_id']; - } - $db->sql_freeresult($result); - } - - if ($deletemark && count($marked)) - { - if (confirm_box(true)) - { - $sql = 'SELECT real_filename - FROM ' . ATTACHMENTS_TABLE . ' - WHERE ' . $db->sql_in_set('attach_id', $marked); - $result = $db->sql_query($sql); - - $log_attachments = array(); - while ($row = $db->sql_fetchrow($result)) - { - $log_attachments[] = $row['real_filename']; - } - $db->sql_freeresult($result); - - /** @var \phpbb\attachment\manager $attachment_manager */ - $attachment_manager = $phpbb_container->get('attachment.manager'); - $attachment_manager->delete('attach', $marked); - unset($attachment_manager); - - $message = (count($log_attachments) == 1) ? $user->lang['ATTACHMENT_DELETED'] : $user->lang['ATTACHMENTS_DELETED']; - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ATTACHMENTS_DELETED', false, array(implode($user->lang['COMMA_SEPARATOR'], $log_attachments))); - trigger_error($message . adm_back_link($this->u_action . '&u=' . $user_id)); - } - else - { - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( - 'u' => $user_id, - 'i' => $id, - 'mode' => $mode, - 'action' => $action, - 'delmarked' => true, - 'mark' => $marked)) - ); - } - } - - $sk_text = array('a' => $user->lang['SORT_FILENAME'], 'c' => $user->lang['SORT_EXTENSION'], 'd' => $user->lang['SORT_SIZE'], 'e' => $user->lang['SORT_DOWNLOADS'], 'f' => $user->lang['SORT_POST_TIME'], 'g' => $user->lang['SORT_TOPIC_TITLE']); - $sk_sql = array('a' => 'a.real_filename', 'c' => 'a.extension', 'd' => 'a.filesize', 'e' => 'a.download_count', 'f' => 'a.filetime', 'g' => 't.topic_title'); - - $sd_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']); - - $s_sort_key = ''; - foreach ($sk_text as $key => $value) - { - $selected = ($sort_key == $key) ? ' selected="selected"' : ''; - $s_sort_key .= ''; - } - - $s_sort_dir = ''; - foreach ($sd_text as $key => $value) - { - $selected = ($sort_dir == $key) ? ' selected="selected"' : ''; - $s_sort_dir .= ''; - } - - if (!isset($sk_sql[$sort_key])) - { - $sort_key = 'a'; - } - - $order_by = $sk_sql[$sort_key] . ' ' . (($sort_dir == 'a') ? 'ASC' : 'DESC'); - - $sql = 'SELECT COUNT(attach_id) as num_attachments - FROM ' . ATTACHMENTS_TABLE . " - WHERE poster_id = $user_id - AND is_orphan = 0"; - $result = $db->sql_query_limit($sql, 1); - $num_attachments = (int) $db->sql_fetchfield('num_attachments'); - $db->sql_freeresult($result); - - $sql = 'SELECT a.*, t.topic_title, p.message_subject as message_title - FROM ' . ATTACHMENTS_TABLE . ' a - LEFT JOIN ' . TOPICS_TABLE . ' t ON (a.topic_id = t.topic_id - AND a.in_message = 0) - LEFT JOIN ' . PRIVMSGS_TABLE . ' p ON (a.post_msg_id = p.msg_id - AND a.in_message = 1) - WHERE a.poster_id = ' . $user_id . " - AND a.is_orphan = 0 - ORDER BY $order_by"; - $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); - - while ($row = $db->sql_fetchrow($result)) - { - if ($row['in_message']) - { - $view_topic = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=pm&p={$row['post_msg_id']}"); - } - else - { - $view_topic = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t={$row['topic_id']}&p={$row['post_msg_id']}") . '#p' . $row['post_msg_id']; - } - - $template->assign_block_vars('attach', array( - 'REAL_FILENAME' => $row['real_filename'], - 'COMMENT' => nl2br($row['attach_comment']), - 'EXTENSION' => $row['extension'], - 'SIZE' => get_formatted_filesize($row['filesize']), - 'DOWNLOAD_COUNT' => $row['download_count'], - 'POST_TIME' => $user->format_date($row['filetime']), - 'TOPIC_TITLE' => ($row['in_message']) ? $row['message_title'] : $row['topic_title'], - - 'ATTACH_ID' => $row['attach_id'], - 'POST_ID' => $row['post_msg_id'], - 'TOPIC_ID' => $row['topic_id'], - - 'S_IN_MESSAGE' => $row['in_message'], - - 'U_DOWNLOAD' => append_sid("{$phpbb_root_path}download/file.$phpEx", 'mode=view&id=' . $row['attach_id']), - 'U_VIEW_TOPIC' => $view_topic) - ); - } - $db->sql_freeresult($result); - - $base_url = $this->u_action . "&u=$user_id&sk=$sort_key&sd=$sort_dir"; - $pagination->generate_template_pagination($base_url, 'pagination', 'start', $num_attachments, $config['topics_per_page'], $start); - - $template->assign_vars(array( - 'S_ATTACHMENTS' => true, - 'S_SORT_KEY' => $s_sort_key, - 'S_SORT_DIR' => $s_sort_dir, - )); - - break; - - case 'groups': - - if (!function_exists('group_user_attributes')) - { - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - } - - $user->add_lang(array('groups', 'acp/groups')); - $group_id = $request->variable('g', 0); - - if ($group_id) - { - // Check the founder only entry for this group to make sure everything is well - $sql = 'SELECT group_founder_manage - FROM ' . GROUPS_TABLE . ' - WHERE group_id = ' . $group_id; - $result = $db->sql_query($sql); - $founder_manage = (int) $db->sql_fetchfield('group_founder_manage'); - $db->sql_freeresult($result); - - if ($user->data['user_type'] != USER_FOUNDER && $founder_manage) - { - trigger_error($user->lang['NOT_ALLOWED_MANAGE_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - } - - switch ($action) - { - case 'demote': - case 'promote': - case 'default': - if (!$group_id) - { - trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - if (!check_link_hash($request->variable('hash', ''), 'acp_users')) - { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - group_user_attributes($action, $group_id, $user_id); - - if ($action == 'default') - { - $user_row['group_id'] = $group_id; - } - break; - - case 'delete': - - if (confirm_box(true)) - { - if (!$group_id) - { - trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - if ($error = group_user_del($group_id, $user_id)) - { - trigger_error($user->lang[$error] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - $error = array(); - - // The delete action was successful - therefore update the user row... - $sql = 'SELECT u.*, s.* - FROM ' . USERS_TABLE . ' u - LEFT JOIN ' . SESSIONS_TABLE . ' s ON (s.session_user_id = u.user_id) - WHERE u.user_id = ' . $user_id . ' - ORDER BY s.session_time DESC'; - $result = $db->sql_query_limit($sql, 1); - $user_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - } - else - { - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( - 'u' => $user_id, - 'i' => $id, - 'mode' => $mode, - 'action' => $action, - 'g' => $group_id)) - ); - } - - break; - - case 'approve': - - if (confirm_box(true)) - { - if (!$group_id) - { - trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - group_user_attributes($action, $group_id, $user_id); - } - else - { - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( - 'u' => $user_id, - 'i' => $id, - 'mode' => $mode, - 'action' => $action, - 'g' => $group_id)) - ); - } - - break; - } - - // Add user to group? - if ($submit) - { - - if (!check_form_key($form_name)) - { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - if (!$group_id) - { - trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - // Add user/s to group - if ($error = group_user_add($group_id, $user_id)) - { - trigger_error($user->lang[$error] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - $error = array(); - } - - /** @var \phpbb\group\helper $group_helper */ - $group_helper = $phpbb_container->get('group_helper'); - - $sql = 'SELECT ug.*, g.* - FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . " ug - WHERE ug.user_id = $user_id - AND g.group_id = ug.group_id - ORDER BY g.group_type DESC, ug.user_pending ASC, g.group_name"; - $result = $db->sql_query($sql); - - $i = 0; - $group_data = $id_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - $type = ($row['group_type'] == GROUP_SPECIAL) ? 'special' : (($row['user_pending']) ? 'pending' : 'normal'); - - $group_data[$type][$i]['group_id'] = $row['group_id']; - $group_data[$type][$i]['group_name'] = $row['group_name']; - $group_data[$type][$i]['group_leader'] = ($row['group_leader']) ? 1 : 0; - - $id_ary[] = $row['group_id']; - - $i++; - } - $db->sql_freeresult($result); - - // Select box for other groups - $sql = 'SELECT group_id, group_name, group_type, group_founder_manage - FROM ' . GROUPS_TABLE . ' - ' . ((count($id_ary)) ? 'WHERE ' . $db->sql_in_set('group_id', $id_ary, true) : '') . ' - ORDER BY group_type DESC, group_name ASC'; - $result = $db->sql_query($sql); - - $s_group_options = ''; - while ($row = $db->sql_fetchrow($result)) - { - if (!$config['coppa_enable'] && $row['group_name'] == 'REGISTERED_COPPA') - { - continue; - } - - // Do not display those groups not allowed to be managed - if ($user->data['user_type'] != USER_FOUNDER && $row['group_founder_manage']) - { - continue; - } - - $s_group_options .= '' . $group_helper->get_name($row['group_name']) . ''; - } - $db->sql_freeresult($result); - - $current_type = ''; - foreach ($group_data as $group_type => $data_ary) - { - if ($current_type != $group_type) - { - $template->assign_block_vars('group', array( - 'S_NEW_GROUP_TYPE' => true, - 'GROUP_TYPE' => $user->lang['USER_GROUP_' . strtoupper($group_type)]) - ); - } - - foreach ($data_ary as $data) - { - $template->assign_block_vars('group', array( - 'U_EDIT_GROUP' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=groups&mode=manage&action=edit&u=$user_id&g={$data['group_id']}&back_link=acp_users_groups"), - 'U_DEFAULT' => $this->u_action . "&action=default&u=$user_id&g=" . $data['group_id'] . '&hash=' . generate_link_hash('acp_users'), - 'U_DEMOTE_PROMOTE' => $this->u_action . '&action=' . (($data['group_leader']) ? 'demote' : 'promote') . "&u=$user_id&g=" . $data['group_id'] . '&hash=' . generate_link_hash('acp_users'), - 'U_DELETE' => $this->u_action . "&action=delete&u=$user_id&g=" . $data['group_id'], - 'U_APPROVE' => ($group_type == 'pending') ? $this->u_action . "&action=approve&u=$user_id&g=" . $data['group_id'] : '', - - 'GROUP_NAME' => $group_helper->get_name($data['group_name']), - 'L_DEMOTE_PROMOTE' => ($data['group_leader']) ? $user->lang['GROUP_DEMOTE'] : $user->lang['GROUP_PROMOTE'], - - 'S_IS_MEMBER' => ($group_type != 'pending') ? true : false, - 'S_NO_DEFAULT' => ($user_row['group_id'] != $data['group_id']) ? true : false, - 'S_SPECIAL_GROUP' => ($group_type == 'special') ? true : false, - ) - ); - } - } - - $template->assign_vars(array( - 'S_GROUPS' => true, - 'S_GROUP_OPTIONS' => $s_group_options) - ); - - break; - - case 'perm': - - if (!class_exists('auth_admin')) - { - include($phpbb_root_path . 'includes/acp/auth.' . $phpEx); - } - - $auth_admin = new auth_admin(); - - $user->add_lang('acp/permissions'); - add_permission_language(); - - $forum_id = $request->variable('f', 0); - - // Global Permissions - if (!$forum_id) - { - // Select auth options - $sql = 'SELECT auth_option, is_local, is_global - FROM ' . ACL_OPTIONS_TABLE . ' - WHERE auth_option ' . $db->sql_like_expression($db->get_any_char() . '_') . ' - AND is_global = 1 - ORDER BY auth_option'; - $result = $db->sql_query($sql); - - $hold_ary = array(); - - while ($row = $db->sql_fetchrow($result)) - { - $hold_ary = $auth_admin->get_mask('view', $user_id, false, false, $row['auth_option'], 'global', ACL_NEVER); - $auth_admin->display_mask('view', $row['auth_option'], $hold_ary, 'user', false, false); - } - $db->sql_freeresult($result); - - unset($hold_ary); - } - else - { - $sql = 'SELECT auth_option, is_local, is_global - FROM ' . ACL_OPTIONS_TABLE . " - WHERE auth_option " . $db->sql_like_expression($db->get_any_char() . '_') . " - AND is_local = 1 - ORDER BY is_global DESC, auth_option"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $hold_ary = $auth_admin->get_mask('view', $user_id, false, $forum_id, $row['auth_option'], 'local', ACL_NEVER); - $auth_admin->display_mask('view', $row['auth_option'], $hold_ary, 'user', true, false); - } - $db->sql_freeresult($result); - } - - $s_forum_options = ''; - $s_forum_options .= make_forum_select($forum_id, false, true, false, false, false); - - $template->assign_vars(array( - 'S_PERMISSIONS' => true, - - 'S_GLOBAL' => (!$forum_id) ? true : false, - 'S_FORUM_OPTIONS' => $s_forum_options, - - 'U_ACTION' => $this->u_action . '&u=' . $user_id, - 'U_USER_PERMISSIONS' => append_sid("{$phpbb_admin_path}index.$phpEx" ,'i=permissions&mode=setting_user_global&user_id[]=' . $user_id), - 'U_USER_FORUM_PERMISSIONS' => append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions&mode=setting_user_local&user_id[]=' . $user_id)) - ); - - break; - - default: - - /** - * Additional modes provided by extensions - * - * @event core.acp_users_mode_add - * @var string mode New mode - * @var int user_id User id of the user to manage - * @var array user_row Array with user data - * @var array error Array with errors data - * @since 3.2.2-RC1 - */ - $vars = array('mode', 'user_id', 'user_row', 'error'); - extract($phpbb_dispatcher->trigger_event('core.acp_users_mode_add', compact($vars))); - - break; - } - - // Assign general variables - $template->assign_vars(array( - 'S_ERROR' => (count($error)) ? true : false, - 'ERROR_MSG' => (count($error)) ? implode('
', $error) : '') - ); - } - - /** - * Set option bit field for user options in a user row array. - * - * Optionset replacement for this module based on $user->optionset. - * - * @param array $user_row Row from the users table. - * @param int $key Option key, as defined in $user->keyoptions property. - * @param bool $value True to set the option, false to clear the option. - * @param int $data Current bit field value, or false to use $user_row['user_options'] - * @return int|bool If $data is false, the bit field is modified and - * written back to $user_row['user_options'], and - * return value is true if the bit field changed and - * false otherwise. If $data is not false, the new - * bitfield value is returned. - */ - function optionset(&$user_row, $key, $value, $data = false) - { - global $user; - - $var = ($data !== false) ? $data : $user_row['user_options']; - - $new_var = phpbb_optionset($user->keyoptions[$key], $value, $var); - - if ($data === false) - { - if ($new_var != $var) - { - $user_row['user_options'] = $new_var; - return true; - } - else - { - return false; - } - } - else - { - return $new_var; - } - } - - /** - * Get option bit field from user options in a user row array. - * - * Optionget replacement for this module based on $user->optionget. - * - * @param array $user_row Row from the users table. - * @param int $key option key, as defined in $user->keyoptions property. - * @param int $data bit field value to use, or false to use $user_row['user_options'] - * @return bool true if the option is set in the bit field, false otherwise - */ - function optionget(&$user_row, $key, $data = false) - { - global $user; - - $var = ($data !== false) ? $data : $user_row['user_options']; - return phpbb_optionget($user->keyoptions[$key], $var); - } -} diff --git a/install/update/old/includes/acp/auth.php b/install/update/old/includes/acp/auth.php deleted file mode 100644 index b414a31..0000000 --- a/install/update/old/includes/acp/auth.php +++ /dev/null @@ -1,1323 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* ACP Permission/Auth class -*/ -class auth_admin extends \phpbb\auth\auth -{ - /** - * Init auth settings - */ - function __construct() - { - global $db, $cache; - - if (($this->acl_options = $cache->get('_acl_options')) === false) - { - $sql = 'SELECT auth_option_id, auth_option, is_global, is_local - FROM ' . ACL_OPTIONS_TABLE . ' - ORDER BY auth_option_id'; - $result = $db->sql_query($sql); - - $global = $local = 0; - $this->acl_options = array(); - while ($row = $db->sql_fetchrow($result)) - { - if ($row['is_global']) - { - $this->acl_options['global'][$row['auth_option']] = $global++; - } - - if ($row['is_local']) - { - $this->acl_options['local'][$row['auth_option']] = $local++; - } - - $this->acl_options['id'][$row['auth_option']] = (int) $row['auth_option_id']; - $this->acl_options['option'][(int) $row['auth_option_id']] = $row['auth_option']; - } - $db->sql_freeresult($result); - - $cache->put('_acl_options', $this->acl_options); - } - } - - /** - * Get permission mask - * This function only supports getting permissions of one type (for example a_) - * - * @param set|view $mode defines the permissions we get, view gets effective permissions (checking user AND group permissions), set only gets the user or group permission set alone - * @param mixed $user_id user ids to search for (a user_id or a group_id has to be specified at least) - * @param mixed $group_id group ids to search for, return group related settings (a user_id or a group_id has to be specified at least) - * @param mixed $forum_id forum_ids to search for. Defining a forum id also means getting local settings - * @param string $auth_option the auth_option defines the permission setting to look for (a_ for example) - * @param local|global $scope the scope defines the permission scope. If local, a forum_id is additionally required - * @param ACL_NEVER|ACL_NO|ACL_YES $acl_fill defines the mode those permissions not set are getting filled with - */ - function get_mask($mode, $user_id = false, $group_id = false, $forum_id = false, $auth_option = false, $scope = false, $acl_fill = ACL_NEVER) - { - global $db, $user; - - $hold_ary = array(); - $view_user_mask = ($mode == 'view' && $group_id === false) ? true : false; - - if ($auth_option === false || $scope === false) - { - return array(); - } - - $acl_user_function = ($mode == 'set') ? 'acl_user_raw_data' : 'acl_raw_data'; - - if (!$view_user_mask) - { - if ($forum_id !== false) - { - $hold_ary = ($group_id !== false) ? $this->acl_group_raw_data($group_id, $auth_option . '%', $forum_id) : $this->$acl_user_function($user_id, $auth_option . '%', $forum_id); - } - else - { - $hold_ary = ($group_id !== false) ? $this->acl_group_raw_data($group_id, $auth_option . '%', ($scope == 'global') ? 0 : false) : $this->$acl_user_function($user_id, $auth_option . '%', ($scope == 'global') ? 0 : false); - } - } - - // Make sure hold_ary is filled with every setting (prevents missing forums/users/groups) - $ug_id = ($group_id !== false) ? ((!is_array($group_id)) ? array($group_id) : $group_id) : ((!is_array($user_id)) ? array($user_id) : $user_id); - $forum_ids = ($forum_id !== false) ? ((!is_array($forum_id)) ? array($forum_id) : $forum_id) : (($scope == 'global') ? array(0) : array()); - - // Only those options we need - $compare_options = array_diff(preg_replace('/^((?!' . $auth_option . ').+)|(' . $auth_option . ')$/', '', array_keys($this->acl_options[$scope])), array('')); - - // If forum_ids is false and the scope is local we actually want to have all forums within the array - if ($scope == 'local' && !count($forum_ids)) - { - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE; - $result = $db->sql_query($sql, 120); - - while ($row = $db->sql_fetchrow($result)) - { - $forum_ids[] = (int) $row['forum_id']; - } - $db->sql_freeresult($result); - } - - if ($view_user_mask) - { - $auth2 = null; - - $sql = 'SELECT user_id, user_permissions, user_type - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('user_id', $ug_id); - $result = $db->sql_query($sql); - - while ($userdata = $db->sql_fetchrow($result)) - { - if ($user->data['user_id'] != $userdata['user_id']) - { - $auth2 = new \phpbb\auth\auth(); - $auth2->acl($userdata); - } - else - { - global $auth; - $auth2 = &$auth; - } - - $hold_ary[$userdata['user_id']] = array(); - foreach ($forum_ids as $f_id) - { - $hold_ary[$userdata['user_id']][$f_id] = array(); - foreach ($compare_options as $option) - { - $hold_ary[$userdata['user_id']][$f_id][$option] = $auth2->acl_get($option, $f_id); - } - } - } - $db->sql_freeresult($result); - - unset($userdata); - unset($auth2); - } - - foreach ($ug_id as $_id) - { - if (!isset($hold_ary[$_id])) - { - $hold_ary[$_id] = array(); - } - - foreach ($forum_ids as $f_id) - { - if (!isset($hold_ary[$_id][$f_id])) - { - $hold_ary[$_id][$f_id] = array(); - } - } - } - - // Now, we need to fill the gaps with $acl_fill. ;) - - // Now switch back to keys - if (count($compare_options)) - { - $compare_options = array_combine($compare_options, array_fill(1, count($compare_options), $acl_fill)); - } - - // Defining the user-function here to save some memory - $return_acl_fill = function () use ($acl_fill) - { - return $acl_fill; - }; - - // Actually fill the gaps - if (count($hold_ary)) - { - foreach ($hold_ary as $ug_id => $row) - { - foreach ($row as $id => $options) - { - // Do not include the global auth_option - unset($options[$auth_option]); - - // Not a "fine" solution, but at all it's a 1-dimensional - // array_diff_key function filling the resulting array values with zeros - // The differences get merged into $hold_ary (all permissions having $acl_fill set) - $hold_ary[$ug_id][$id] = array_merge($options, - - array_map($return_acl_fill, - array_flip( - array_diff( - array_keys($compare_options), array_keys($options) - ) - ) - ) - ); - } - } - } - else - { - $hold_ary[($group_id !== false) ? $group_id : $user_id][(int) $forum_id] = $compare_options; - } - - return $hold_ary; - } - - /** - * Get permission mask for roles - * This function only supports getting masks for one role - */ - function get_role_mask($role_id) - { - global $db; - - $hold_ary = array(); - - // Get users having this role set... - $sql = 'SELECT user_id, forum_id - FROM ' . ACL_USERS_TABLE . ' - WHERE auth_role_id = ' . $role_id . ' - ORDER BY forum_id'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $hold_ary[$row['forum_id']]['users'][] = $row['user_id']; - } - $db->sql_freeresult($result); - - // Now grab groups... - $sql = 'SELECT group_id, forum_id - FROM ' . ACL_GROUPS_TABLE . ' - WHERE auth_role_id = ' . $role_id . ' - ORDER BY forum_id'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $hold_ary[$row['forum_id']]['groups'][] = $row['group_id']; - } - $db->sql_freeresult($result); - - return $hold_ary; - } - - /** - * Display permission mask (assign to template) - */ - function display_mask($mode, $permission_type, &$hold_ary, $user_mode = 'user', $local = false, $group_display = true) - { - global $template, $user, $db, $phpbb_container; - - /* @var $phpbb_permissions \phpbb\permissions */ - $phpbb_permissions = $phpbb_container->get('acl.permissions'); - - /** @var \phpbb\group\helper $group_helper */ - $group_helper = $phpbb_container->get('group_helper'); - - // Define names for template loops, might be able to be set - $tpl_pmask = 'p_mask'; - $tpl_fmask = 'f_mask'; - $tpl_category = 'category'; - $tpl_mask = 'mask'; - - $l_acl_type = $phpbb_permissions->get_type_lang($permission_type, (($local) ? 'local' : 'global')); - - // Allow trace for viewing permissions and in user mode - $show_trace = ($mode == 'view' && $user_mode == 'user') ? true : false; - - // Get names - if ($user_mode == 'user') - { - $sql = 'SELECT user_id as ug_id, username as ug_name - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('user_id', array_keys($hold_ary)) . ' - ORDER BY username_clean ASC'; - } - else - { - $sql = 'SELECT group_id as ug_id, group_name as ug_name, group_type - FROM ' . GROUPS_TABLE . ' - WHERE ' . $db->sql_in_set('group_id', array_keys($hold_ary)) . ' - ORDER BY group_type DESC, group_name ASC'; - } - $result = $db->sql_query($sql); - - $ug_names_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - $ug_names_ary[$row['ug_id']] = ($user_mode == 'user') ? $row['ug_name'] : $group_helper->get_name($row['ug_name']); - } - $db->sql_freeresult($result); - - // Get used forums - $forum_ids = array(); - foreach ($hold_ary as $ug_id => $row) - { - $forum_ids = array_merge($forum_ids, array_keys($row)); - } - $forum_ids = array_unique($forum_ids); - - $forum_names_ary = array(); - if ($local) - { - $forum_names_ary = make_forum_select(false, false, true, false, false, false, true); - - // Remove the disabled ones, since we do not create an option field here... - foreach ($forum_names_ary as $key => $value) - { - if (!$value['disabled']) - { - continue; - } - unset($forum_names_ary[$key]); - } - } - else - { - $forum_names_ary[0] = $l_acl_type; - } - - // Get available roles - $sql = 'SELECT * - FROM ' . ACL_ROLES_TABLE . " - WHERE role_type = '" . $db->sql_escape($permission_type) . "' - ORDER BY role_order ASC"; - $result = $db->sql_query($sql); - - $roles = array(); - while ($row = $db->sql_fetchrow($result)) - { - $roles[$row['role_id']] = $row; - } - $db->sql_freeresult($result); - - $cur_roles = $this->acl_role_data($user_mode, $permission_type, array_keys($hold_ary)); - - // Build js roles array (role data assignments) - $s_role_js_array = ''; - - if (count($roles)) - { - $s_role_js_array = array(); - - // Make sure every role (even if empty) has its array defined - foreach ($roles as $_role_id => $null) - { - $s_role_js_array[$_role_id] = "\n" . 'role_options[' . $_role_id . '] = new Array();' . "\n"; - } - - $sql = 'SELECT r.role_id, o.auth_option, r.auth_setting - FROM ' . ACL_ROLES_DATA_TABLE . ' r, ' . ACL_OPTIONS_TABLE . ' o - WHERE o.auth_option_id = r.auth_option_id - AND ' . $db->sql_in_set('r.role_id', array_keys($roles)); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $flag = substr($row['auth_option'], 0, strpos($row['auth_option'], '_') + 1); - if ($flag == $row['auth_option']) - { - continue; - } - - $s_role_js_array[$row['role_id']] .= 'role_options[' . $row['role_id'] . '][\'' . addslashes($row['auth_option']) . '\'] = ' . $row['auth_setting'] . '; '; - } - $db->sql_freeresult($result); - - $s_role_js_array = implode('', $s_role_js_array); - } - - $template->assign_var('S_ROLE_JS_ARRAY', $s_role_js_array); - unset($s_role_js_array); - - // Now obtain memberships - $user_groups_default = $user_groups_custom = array(); - if ($user_mode == 'user' && $group_display) - { - $sql = 'SELECT group_id, group_name, group_type - FROM ' . GROUPS_TABLE . ' - ORDER BY group_type DESC, group_name ASC'; - $result = $db->sql_query($sql); - - $groups = array(); - while ($row = $db->sql_fetchrow($result)) - { - $groups[$row['group_id']] = $row; - } - $db->sql_freeresult($result); - - $memberships = group_memberships(false, array_keys($hold_ary), false); - - // User is not a member of any group? Bad admin, bad bad admin... - if ($memberships) - { - foreach ($memberships as $row) - { - $user_groups_default[$row['user_id']][] = $group_helper->get_name($groups[$row['group_id']]['group_name']); - } - } - unset($memberships, $groups); - } - - // If we only have one forum id to display or being in local mode and more than one user/group to display, - // we switch the complete interface to group by user/usergroup instead of grouping by forum - // To achieve this, we need to switch the array a bit - if (count($forum_ids) == 1 || ($local && count($ug_names_ary) > 1)) - { - $hold_ary_temp = $hold_ary; - $hold_ary = array(); - foreach ($hold_ary_temp as $ug_id => $row) - { - foreach ($forum_names_ary as $forum_id => $forum_row) - { - if (isset($row[$forum_id])) - { - $hold_ary[$forum_id][$ug_id] = $row[$forum_id]; - } - } - } - unset($hold_ary_temp); - - foreach ($hold_ary as $forum_id => $forum_array) - { - $content_array = $categories = array(); - $this->build_permission_array($hold_ary[$forum_id], $content_array, $categories, array_keys($ug_names_ary)); - - $template->assign_block_vars($tpl_pmask, array( - 'NAME' => ($forum_id == 0) ? $forum_names_ary[0] : $forum_names_ary[$forum_id]['forum_name'], - 'PADDING' => ($forum_id == 0) ? '' : $forum_names_ary[$forum_id]['padding'], - - 'CATEGORIES' => implode('', $categories), - - 'L_ACL_TYPE' => $l_acl_type, - - 'S_LOCAL' => ($local) ? true : false, - 'S_GLOBAL' => (!$local) ? true : false, - 'S_NUM_CATS' => count($categories), - 'S_VIEW' => ($mode == 'view') ? true : false, - 'S_NUM_OBJECTS' => count($content_array), - 'S_USER_MODE' => ($user_mode == 'user') ? true : false, - 'S_GROUP_MODE' => ($user_mode == 'group') ? true : false) - ); - - @reset($content_array); - while (list($ug_id, $ug_array) = each($content_array)) - { - // Build role dropdown options - $current_role_id = (isset($cur_roles[$ug_id][$forum_id])) ? $cur_roles[$ug_id][$forum_id] : 0; - - $role_options = array(); - - $s_role_options = ''; - $current_role_id = (isset($cur_roles[$ug_id][$forum_id])) ? $cur_roles[$ug_id][$forum_id] : 0; - - @reset($roles); - while (list($role_id, $role_row) = each($roles)) - { - $role_description = (!empty($user->lang[$role_row['role_description']])) ? $user->lang[$role_row['role_description']] : nl2br($role_row['role_description']); - $role_name = (!empty($user->lang[$role_row['role_name']])) ? $user->lang[$role_row['role_name']] : $role_row['role_name']; - - $title = ($role_description) ? ' title="' . $role_description . '"' : ''; - $s_role_options .= ''; - - $role_options[] = array( - 'ID' => $role_id, - 'ROLE_NAME' => $role_name, - 'TITLE' => $role_description, - 'SELECTED' => $role_id == $current_role_id, - ); - } - - if ($s_role_options) - { - $s_role_options = '' . $s_role_options; - } - - if (!$current_role_id && $mode != 'view') - { - $s_custom_permissions = false; - - foreach ($ug_array as $key => $value) - { - if ($value['S_NEVER'] || $value['S_YES']) - { - $s_custom_permissions = true; - break; - } - } - } - else - { - $s_custom_permissions = false; - } - - $template->assign_block_vars($tpl_pmask . '.' . $tpl_fmask, array( - 'NAME' => $ug_names_ary[$ug_id], - 'UG_ID' => $ug_id, - 'S_ROLE_OPTIONS' => $s_role_options, - 'S_CUSTOM' => $s_custom_permissions, - 'FORUM_ID' => $forum_id, - 'S_ROLE_ID' => $current_role_id, - )); - - $template->assign_block_vars_array($tpl_pmask . '.' . $tpl_fmask . '.role_options', $role_options); - - $this->assign_cat_array($ug_array, $tpl_pmask . '.' . $tpl_fmask . '.' . $tpl_category, $tpl_mask, $ug_id, $forum_id, ($mode == 'view'), $show_trace); - - unset($content_array[$ug_id]); - } - - unset($hold_ary[$forum_id]); - } - } - else - { - foreach ($ug_names_ary as $ug_id => $ug_name) - { - if (!isset($hold_ary[$ug_id])) - { - continue; - } - - $content_array = $categories = array(); - $this->build_permission_array($hold_ary[$ug_id], $content_array, $categories, array_keys($forum_names_ary)); - - $template->assign_block_vars($tpl_pmask, array( - 'NAME' => $ug_name, - 'CATEGORIES' => implode('', $categories), - - 'USER_GROUPS_DEFAULT' => ($user_mode == 'user' && isset($user_groups_default[$ug_id]) && count($user_groups_default[$ug_id])) ? implode($user->lang['COMMA_SEPARATOR'], $user_groups_default[$ug_id]) : '', - 'USER_GROUPS_CUSTOM' => ($user_mode == 'user' && isset($user_groups_custom[$ug_id]) && count($user_groups_custom[$ug_id])) ? implode($user->lang['COMMA_SEPARATOR'], $user_groups_custom[$ug_id]) : '', - 'L_ACL_TYPE' => $l_acl_type, - - 'S_LOCAL' => ($local) ? true : false, - 'S_GLOBAL' => (!$local) ? true : false, - 'S_NUM_CATS' => count($categories), - 'S_VIEW' => ($mode == 'view') ? true : false, - 'S_NUM_OBJECTS' => count($content_array), - 'S_USER_MODE' => ($user_mode == 'user') ? true : false, - 'S_GROUP_MODE' => ($user_mode == 'group') ? true : false) - ); - - @reset($content_array); - while (list($forum_id, $forum_array) = each($content_array)) - { - // Build role dropdown options - $current_role_id = (isset($cur_roles[$ug_id][$forum_id])) ? $cur_roles[$ug_id][$forum_id] : 0; - - $role_options = array(); - - $current_role_id = (isset($cur_roles[$ug_id][$forum_id])) ? $cur_roles[$ug_id][$forum_id] : 0; - $s_role_options = ''; - - @reset($roles); - while (list($role_id, $role_row) = each($roles)) - { - $role_description = (!empty($user->lang[$role_row['role_description']])) ? $user->lang[$role_row['role_description']] : nl2br($role_row['role_description']); - $role_name = (!empty($user->lang[$role_row['role_name']])) ? $user->lang[$role_row['role_name']] : $role_row['role_name']; - - $title = ($role_description) ? ' title="' . $role_description . '"' : ''; - $s_role_options .= ''; - - $role_options[] = array( - 'ID' => $role_id, - 'ROLE_NAME' => $role_name, - 'TITLE' => $role_description, - 'SELECTED' => $role_id == $current_role_id, - ); - } - - if ($s_role_options) - { - $s_role_options = '' . $s_role_options; - } - - if (!$current_role_id && $mode != 'view') - { - $s_custom_permissions = false; - - foreach ($forum_array as $key => $value) - { - if ($value['S_NEVER'] || $value['S_YES']) - { - $s_custom_permissions = true; - break; - } - } - } - else - { - $s_custom_permissions = false; - } - - $template->assign_block_vars($tpl_pmask . '.' . $tpl_fmask, array( - 'NAME' => ($forum_id == 0) ? $forum_names_ary[0] : $forum_names_ary[$forum_id]['forum_name'], - 'PADDING' => ($forum_id == 0) ? '' : $forum_names_ary[$forum_id]['padding'], - 'S_CUSTOM' => $s_custom_permissions, - 'UG_ID' => $ug_id, - 'S_ROLE_OPTIONS' => $s_role_options, - 'FORUM_ID' => $forum_id) - ); - - $template->assign_block_vars_array($tpl_pmask . '.' . $tpl_fmask . '.role_options', $role_options); - - $this->assign_cat_array($forum_array, $tpl_pmask . '.' . $tpl_fmask . '.' . $tpl_category, $tpl_mask, $ug_id, $forum_id, ($mode == 'view'), $show_trace); - } - - unset($hold_ary[$ug_id], $ug_names_ary[$ug_id]); - } - } - } - - /** - * Display permission mask for roles - */ - function display_role_mask(&$hold_ary) - { - global $db, $template, $user, $phpbb_root_path, $phpEx; - global $phpbb_container; - - if (!count($hold_ary)) - { - return; - } - - /** @var \phpbb\group\helper $group_helper */ - $group_helper = $phpbb_container->get('group_helper'); - - // Get forum names - $sql = 'SELECT forum_id, forum_name - FROM ' . FORUMS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', array_keys($hold_ary)) . ' - ORDER BY left_id'; - $result = $db->sql_query($sql); - - // If the role is used globally, then reflect that - $forum_names = (isset($hold_ary[0])) ? array(0 => '') : array(); - while ($row = $db->sql_fetchrow($result)) - { - $forum_names[$row['forum_id']] = $row['forum_name']; - } - $db->sql_freeresult($result); - - foreach ($forum_names as $forum_id => $forum_name) - { - $auth_ary = $hold_ary[$forum_id]; - - $template->assign_block_vars('role_mask', array( - 'NAME' => ($forum_id == 0) ? $user->lang['GLOBAL_MASK'] : $forum_name, - 'FORUM_ID' => $forum_id) - ); - - if (isset($auth_ary['users']) && count($auth_ary['users'])) - { - $sql = 'SELECT user_id, username - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('user_id', $auth_ary['users']) . ' - ORDER BY username_clean ASC'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $template->assign_block_vars('role_mask.users', array( - 'USER_ID' => $row['user_id'], - 'USERNAME' => get_username_string('username', $row['user_id'], $row['username']), - 'U_PROFILE' => get_username_string('profile', $row['user_id'], $row['username']), - )); - } - $db->sql_freeresult($result); - } - - if (isset($auth_ary['groups']) && count($auth_ary['groups'])) - { - $sql = 'SELECT group_id, group_name, group_type - FROM ' . GROUPS_TABLE . ' - WHERE ' . $db->sql_in_set('group_id', $auth_ary['groups']) . ' - ORDER BY group_type ASC, group_name'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $template->assign_block_vars('role_mask.groups', array( - 'GROUP_ID' => $row['group_id'], - 'GROUP_NAME' => $group_helper->get_name($row['group_name']), - 'U_PROFILE' => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=group&g={$row['group_id']}")) - ); - } - $db->sql_freeresult($result); - } - } - } - - /** - * NOTE: this function is not in use atm - * Add a new option to the list ... $options is a hash of form -> - * $options = array( - * 'local' => array('option1', 'option2', ...), - * 'global' => array('optionA', 'optionB', ...) - * ); - */ - function acl_add_option($options) - { - global $db, $cache; - - if (!is_array($options)) - { - return false; - } - - $cur_options = array(); - - // Determine current options - $sql = 'SELECT auth_option, is_global, is_local - FROM ' . ACL_OPTIONS_TABLE . ' - ORDER BY auth_option_id'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $cur_options[$row['auth_option']] = ($row['is_global'] && $row['is_local']) ? 'both' : (($row['is_global']) ? 'global' : 'local'); - } - $db->sql_freeresult($result); - - // Here we need to insert new options ... this requires discovering whether - // an options is global, local or both and whether we need to add an permission - // set flag (x_) - $new_options = array('local' => array(), 'global' => array()); - - foreach ($options as $type => $option_ary) - { - $option_ary = array_unique($option_ary); - - foreach ($option_ary as $option_value) - { - $new_options[$type][] = $option_value; - - $flag = substr($option_value, 0, strpos($option_value, '_') + 1); - - if (!in_array($flag, $new_options[$type])) - { - $new_options[$type][] = $flag; - } - } - } - unset($options); - - $options = array(); - $options['local'] = array_diff($new_options['local'], $new_options['global']); - $options['global'] = array_diff($new_options['global'], $new_options['local']); - $options['both'] = array_intersect($new_options['local'], $new_options['global']); - - // Now check which options to add/update - $add_options = $update_options = array(); - - // First local ones... - foreach ($options as $type => $option_ary) - { - foreach ($option_ary as $option) - { - if (!isset($cur_options[$option])) - { - $add_options[] = array( - 'auth_option' => (string) $option, - 'is_global' => ($type == 'global' || $type == 'both') ? 1 : 0, - 'is_local' => ($type == 'local' || $type == 'both') ? 1 : 0 - ); - - continue; - } - - // Else, update existing entry if it is changed... - if ($type === $cur_options[$option]) - { - continue; - } - - // New type is always both: - // If is now both, we set both. - // If it was global the new one is local and we need to set it to both - // If it was local the new one is global and we need to set it to both - $update_options[] = $option; - } - } - - if (!empty($add_options)) - { - $db->sql_multi_insert(ACL_OPTIONS_TABLE, $add_options); - } - - if (!empty($update_options)) - { - $sql = 'UPDATE ' . ACL_OPTIONS_TABLE . ' - SET is_global = 1, is_local = 1 - WHERE ' . $db->sql_in_set('auth_option', $update_options); - $db->sql_query($sql); - } - - $cache->destroy('_acl_options'); - $this->acl_clear_prefetch(); - - // Because we just changed the options and also purged the options cache, we instantly update/regenerate it for later calls to succeed. - $this->acl_options = array(); - $this->__construct(); - - return true; - } - - /** - * Set a user or group ACL record - */ - function acl_set($ug_type, $forum_id, $ug_id, $auth, $role_id = 0, $clear_prefetch = true) - { - global $db; - - // One or more forums - if (!is_array($forum_id)) - { - $forum_id = array($forum_id); - } - - // One or more users - if (!is_array($ug_id)) - { - $ug_id = array($ug_id); - } - - $ug_id_sql = $db->sql_in_set($ug_type . '_id', array_map('intval', $ug_id)); - $forum_sql = $db->sql_in_set('forum_id', array_map('intval', $forum_id)); - - // Instead of updating, inserting, removing we just remove all current settings and re-set everything... - $table = ($ug_type == 'user') ? ACL_USERS_TABLE : ACL_GROUPS_TABLE; - $id_field = $ug_type . '_id'; - - // Get any flags as required - reset($auth); - $flag = key($auth); - $flag = substr($flag, 0, strpos($flag, '_') + 1); - - // This ID (the any-flag) is set if one or more permissions are true... - $any_option_id = (int) $this->acl_options['id'][$flag]; - - // Remove any-flag from auth ary - if (isset($auth[$flag])) - { - unset($auth[$flag]); - } - - // Remove current auth options... - $auth_option_ids = array((int) $any_option_id); - foreach ($auth as $auth_option => $auth_setting) - { - $auth_option_ids[] = (int) $this->acl_options['id'][$auth_option]; - } - - $sql = "DELETE FROM $table - WHERE $forum_sql - AND $ug_id_sql - AND " . $db->sql_in_set('auth_option_id', $auth_option_ids); - $db->sql_query($sql); - - // Remove those having a role assigned... the correct type of course... - $sql = 'SELECT role_id - FROM ' . ACL_ROLES_TABLE . " - WHERE role_type = '" . $db->sql_escape($flag) . "'"; - $result = $db->sql_query($sql); - - $role_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $role_ids[] = $row['role_id']; - } - $db->sql_freeresult($result); - - if (count($role_ids)) - { - $sql = "DELETE FROM $table - WHERE $forum_sql - AND $ug_id_sql - AND auth_option_id = 0 - AND " . $db->sql_in_set('auth_role_id', $role_ids); - $db->sql_query($sql); - } - - // Ok, include the any-flag if one or more auth options are set to yes... - foreach ($auth as $auth_option => $setting) - { - if ($setting == ACL_YES && (!isset($auth[$flag]) || $auth[$flag] == ACL_NEVER)) - { - $auth[$flag] = ACL_YES; - } - } - - $sql_ary = array(); - foreach ($forum_id as $forum) - { - $forum = (int) $forum; - - if ($role_id) - { - foreach ($ug_id as $id) - { - $sql_ary[] = array( - $id_field => (int) $id, - 'forum_id' => (int) $forum, - 'auth_option_id' => 0, - 'auth_setting' => 0, - 'auth_role_id' => (int) $role_id, - ); - } - } - else - { - foreach ($auth as $auth_option => $setting) - { - $auth_option_id = (int) $this->acl_options['id'][$auth_option]; - - if ($setting != ACL_NO) - { - foreach ($ug_id as $id) - { - $sql_ary[] = array( - $id_field => (int) $id, - 'forum_id' => (int) $forum, - 'auth_option_id' => (int) $auth_option_id, - 'auth_setting' => (int) $setting - ); - } - } - } - } - } - - $db->sql_multi_insert($table, $sql_ary); - - if ($clear_prefetch) - { - $this->acl_clear_prefetch(); - } - } - - /** - * Set a role-specific ACL record - */ - function acl_set_role($role_id, $auth) - { - global $db; - - // Get any-flag as required - reset($auth); - $flag = key($auth); - $flag = substr($flag, 0, strpos($flag, '_') + 1); - - // Remove any-flag from auth ary - if (isset($auth[$flag])) - { - unset($auth[$flag]); - } - - // Re-set any flag... - foreach ($auth as $auth_option => $setting) - { - if ($setting == ACL_YES && (!isset($auth[$flag]) || $auth[$flag] == ACL_NEVER)) - { - $auth[$flag] = ACL_YES; - } - } - - $sql_ary = array(); - foreach ($auth as $auth_option => $setting) - { - $auth_option_id = (int) $this->acl_options['id'][$auth_option]; - - if ($setting != ACL_NO) - { - $sql_ary[] = array( - 'role_id' => (int) $role_id, - 'auth_option_id' => (int) $auth_option_id, - 'auth_setting' => (int) $setting - ); - } - } - - // If no data is there, we set the any-flag to ACL_NEVER... - if (!count($sql_ary)) - { - $sql_ary[] = array( - 'role_id' => (int) $role_id, - 'auth_option_id' => (int) $this->acl_options['id'][$flag], - 'auth_setting' => ACL_NEVER - ); - } - - // Remove current auth options... - $sql = 'DELETE FROM ' . ACL_ROLES_DATA_TABLE . ' - WHERE role_id = ' . $role_id; - $db->sql_query($sql); - - // Now insert the new values - $db->sql_multi_insert(ACL_ROLES_DATA_TABLE, $sql_ary); - - $this->acl_clear_prefetch(); - } - - /** - * Remove local permission - */ - function acl_delete($mode, $ug_id = false, $forum_id = false, $permission_type = false) - { - global $db; - - if ($ug_id === false && $forum_id === false) - { - return; - } - - $option_id_ary = array(); - $table = ($mode == 'user') ? ACL_USERS_TABLE : ACL_GROUPS_TABLE; - $id_field = $mode . '_id'; - - $where_sql = array(); - - if ($forum_id !== false) - { - $where_sql[] = (!is_array($forum_id)) ? 'forum_id = ' . (int) $forum_id : $db->sql_in_set('forum_id', array_map('intval', $forum_id)); - } - - if ($ug_id !== false) - { - $where_sql[] = (!is_array($ug_id)) ? $id_field . ' = ' . (int) $ug_id : $db->sql_in_set($id_field, array_map('intval', $ug_id)); - } - - // There seem to be auth options involved, therefore we need to go through the list and make sure we capture roles correctly - if ($permission_type !== false) - { - // Get permission type - $sql = 'SELECT auth_option, auth_option_id - FROM ' . ACL_OPTIONS_TABLE . " - WHERE auth_option " . $db->sql_like_expression($permission_type . $db->get_any_char()); - $result = $db->sql_query($sql); - - $auth_id_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - $option_id_ary[] = $row['auth_option_id']; - $auth_id_ary[$row['auth_option']] = ACL_NO; - } - $db->sql_freeresult($result); - - // First of all, lets grab the items having roles with the specified auth options assigned - $sql = "SELECT auth_role_id, $id_field, forum_id - FROM $table, " . ACL_ROLES_TABLE . " r - WHERE auth_role_id <> 0 - AND auth_role_id = r.role_id - AND r.role_type = '{$permission_type}' - AND " . implode(' AND ', $where_sql) . ' - ORDER BY auth_role_id'; - $result = $db->sql_query($sql); - - $cur_role_auth = array(); - while ($row = $db->sql_fetchrow($result)) - { - $cur_role_auth[$row['auth_role_id']][$row['forum_id']][] = $row[$id_field]; - } - $db->sql_freeresult($result); - - // Get role data for resetting data - if (count($cur_role_auth)) - { - $sql = 'SELECT ao.auth_option, rd.role_id, rd.auth_setting - FROM ' . ACL_OPTIONS_TABLE . ' ao, ' . ACL_ROLES_DATA_TABLE . ' rd - WHERE ao.auth_option_id = rd.auth_option_id - AND ' . $db->sql_in_set('rd.role_id', array_keys($cur_role_auth)); - $result = $db->sql_query($sql); - - $auth_settings = array(); - while ($row = $db->sql_fetchrow($result)) - { - // We need to fill all auth_options, else setting it will fail... - if (!isset($auth_settings[$row['role_id']])) - { - $auth_settings[$row['role_id']] = $auth_id_ary; - } - $auth_settings[$row['role_id']][$row['auth_option']] = $row['auth_setting']; - } - $db->sql_freeresult($result); - - // Set the options - foreach ($cur_role_auth as $role_id => $auth_row) - { - foreach ($auth_row as $f_id => $ug_row) - { - $this->acl_set($mode, $f_id, $ug_row, $auth_settings[$role_id], 0, false); - } - } - } - } - - // Now, normally remove permissions... - if ($permission_type !== false) - { - $where_sql[] = $db->sql_in_set('auth_option_id', array_map('intval', $option_id_ary)); - } - - $sql = "DELETE FROM $table - WHERE " . implode(' AND ', $where_sql); - $db->sql_query($sql); - - $this->acl_clear_prefetch(); - } - - /** - * Assign category to template - * used by display_mask() - */ - function assign_cat_array(&$category_array, $tpl_cat, $tpl_mask, $ug_id, $forum_id, $s_view, $show_trace = false) - { - global $template, $phpbb_admin_path, $phpEx, $phpbb_container; - - /* @var $phpbb_permissions \phpbb\permissions */ - $phpbb_permissions = $phpbb_container->get('acl.permissions'); - - @reset($category_array); - while (list($cat, $cat_array) = each($category_array)) - { - if (!$phpbb_permissions->category_defined($cat)) - { - continue; - } - - $template->assign_block_vars($tpl_cat, array( - 'S_YES' => ($cat_array['S_YES'] && !$cat_array['S_NEVER'] && !$cat_array['S_NO']) ? true : false, - 'S_NEVER' => ($cat_array['S_NEVER'] && !$cat_array['S_YES'] && !$cat_array['S_NO']) ? true : false, - 'S_NO' => ($cat_array['S_NO'] && !$cat_array['S_NEVER'] && !$cat_array['S_YES']) ? true : false, - - 'CAT_NAME' => $phpbb_permissions->get_category_lang($cat), - )); - - /* Sort permissions by name (more naturaly and user friendly than sorting by a primary key) - * Commented out due to it's memory consumption and time needed - * - $key_array = array_intersect(array_keys($user->lang), array_map(create_function('$a', 'return "acl_" . $a;'), array_keys($cat_array['permissions']))); - $values_array = $cat_array['permissions']; - - $cat_array['permissions'] = array(); - - foreach ($key_array as $key) - { - $key = str_replace('acl_', '', $key); - $cat_array['permissions'][$key] = $values_array[$key]; - } - unset($key_array, $values_array); -*/ - @reset($cat_array['permissions']); - while (list($permission, $allowed) = each($cat_array['permissions'])) - { - if (!$phpbb_permissions->permission_defined($permission)) - { - continue; - } - - if ($s_view) - { - $template->assign_block_vars($tpl_cat . '.' . $tpl_mask, array( - 'S_YES' => ($allowed == ACL_YES) ? true : false, - 'S_NEVER' => ($allowed == ACL_NEVER) ? true : false, - - 'UG_ID' => $ug_id, - 'FORUM_ID' => $forum_id, - 'FIELD_NAME' => $permission, - 'S_FIELD_NAME' => 'setting[' . $ug_id . '][' . $forum_id . '][' . $permission . ']', - - 'U_TRACE' => ($show_trace) ? append_sid("{$phpbb_admin_path}index.$phpEx", "i=permissions&mode=trace&u=$ug_id&f=$forum_id&auth=$permission") : '', - 'UA_TRACE' => ($show_trace) ? append_sid("{$phpbb_admin_path}index.$phpEx", "i=permissions&mode=trace&u=$ug_id&f=$forum_id&auth=$permission", false) : '', - - 'PERMISSION' => $phpbb_permissions->get_permission_lang($permission), - )); - } - else - { - $template->assign_block_vars($tpl_cat . '.' . $tpl_mask, array( - 'S_YES' => ($allowed == ACL_YES) ? true : false, - 'S_NEVER' => ($allowed == ACL_NEVER) ? true : false, - 'S_NO' => ($allowed == ACL_NO) ? true : false, - - 'UG_ID' => $ug_id, - 'FORUM_ID' => $forum_id, - 'FIELD_NAME' => $permission, - 'S_FIELD_NAME' => 'setting[' . $ug_id . '][' . $forum_id . '][' . $permission . ']', - - 'U_TRACE' => ($show_trace) ? append_sid("{$phpbb_admin_path}index.$phpEx", "i=permissions&mode=trace&u=$ug_id&f=$forum_id&auth=$permission") : '', - 'UA_TRACE' => ($show_trace) ? append_sid("{$phpbb_admin_path}index.$phpEx", "i=permissions&mode=trace&u=$ug_id&f=$forum_id&auth=$permission", false) : '', - - 'PERMISSION' => $phpbb_permissions->get_permission_lang($permission), - )); - } - } - } - } - - /** - * Building content array from permission rows with explicit key ordering - * used by display_mask() - */ - function build_permission_array(&$permission_row, &$content_array, &$categories, $key_sort_array) - { - global $phpbb_container; - - /* @var $phpbb_permissions \phpbb\permissions */ - $phpbb_permissions = $phpbb_container->get('acl.permissions'); - - foreach ($key_sort_array as $forum_id) - { - if (!isset($permission_row[$forum_id])) - { - continue; - } - - $permissions = $permission_row[$forum_id]; - ksort($permissions); - - @reset($permissions); - while (list($permission, $auth_setting) = each($permissions)) - { - $cat = $phpbb_permissions->get_permission_category($permission); - - // Build our categories array - if (!isset($categories[$cat])) - { - $categories[$cat] = $phpbb_permissions->get_category_lang($cat); - } - - // Build our content array - if (!isset($content_array[$forum_id])) - { - $content_array[$forum_id] = array(); - } - - if (!isset($content_array[$forum_id][$cat])) - { - $content_array[$forum_id][$cat] = array( - 'S_YES' => false, - 'S_NEVER' => false, - 'S_NO' => false, - 'permissions' => array(), - ); - } - - $content_array[$forum_id][$cat]['S_YES'] |= ($auth_setting == ACL_YES) ? true : false; - $content_array[$forum_id][$cat]['S_NEVER'] |= ($auth_setting == ACL_NEVER) ? true : false; - $content_array[$forum_id][$cat]['S_NO'] |= ($auth_setting == ACL_NO) ? true : false; - - $content_array[$forum_id][$cat]['permissions'][$permission] = $auth_setting; - } - } - } - - /** - * Use permissions from another user. This transferes a permission set from one user to another. - * The other user is always able to revert back to his permission set. - * This function does not check for lower/higher permissions, it is possible for the user to gain - * "more" permissions by this. - * Admin permissions will not be copied. - */ - function ghost_permissions($from_user_id, $to_user_id) - { - global $db; - - if ($to_user_id == ANONYMOUS) - { - return false; - } - - $hold_ary = $this->acl_raw_data_single_user($from_user_id); - - // Key 0 in $hold_ary are global options, all others are forum_ids - - // We disallow copying admin permissions - foreach ($this->acl_options['global'] as $opt => $id) - { - if (strpos($opt, 'a_') === 0) - { - $hold_ary[0][$this->acl_options['id'][$opt]] = ACL_NEVER; - } - } - - // Force a_switchperm to be allowed - $hold_ary[0][$this->acl_options['id']['a_switchperm']] = ACL_YES; - - $user_permissions = $this->build_bitstring($hold_ary); - - if (!$user_permissions) - { - return false; - } - - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_permissions = '" . $db->sql_escape($user_permissions) . "', - user_perm_from = $from_user_id - WHERE user_id = " . $to_user_id; - $db->sql_query($sql); - - return true; - } -} diff --git a/install/update/old/includes/bbcode.php b/install/update/old/includes/bbcode.php deleted file mode 100644 index c31b63a..0000000 --- a/install/update/old/includes/bbcode.php +++ /dev/null @@ -1,707 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* BBCode class -*/ -class bbcode -{ - var $bbcode_uid = ''; - var $bbcode_bitfield = ''; - var $bbcode_cache = array(); - var $bbcode_template = array(); - - var $bbcodes = array(); - - var $template_bitfield; - - /** - * Constructor - */ - function __construct($bitfield = '') - { - $this->bbcode_set_bitfield($bitfield); - } - - /** - * Init bbcode cache entries if bitfield is specified - * - * @param string $bbcode_bitfield The bbcode bitfield - */ - function bbcode_set_bitfield($bitfield = '') - { - if ($bitfield) - { - $this->bbcode_bitfield = $bitfield; - $this->bbcode_cache_init(); - } - } - - /** - * Second pass bbcodes - */ - function bbcode_second_pass(&$message, $bbcode_uid = '', $bbcode_bitfield = false) - { - if ($bbcode_uid) - { - $this->bbcode_uid = $bbcode_uid; - } - - if ($bbcode_bitfield !== false) - { - $this->bbcode_bitfield = $bbcode_bitfield; - - // Init those added with a new bbcode_bitfield (already stored codes will not get parsed again) - $this->bbcode_cache_init(); - } - - if (!$this->bbcode_bitfield) - { - // Remove the uid from tags that have not been transformed into HTML - if ($this->bbcode_uid) - { - $message = str_replace(':' . $this->bbcode_uid, '', $message); - } - - return; - } - - $str = array('search' => array(), 'replace' => array()); - $preg = array('search' => array(), 'replace' => array()); - - $bitfield = new bitfield($this->bbcode_bitfield); - $bbcodes_set = $bitfield->get_all_set(); - - $undid_bbcode_specialchars = false; - foreach ($bbcodes_set as $bbcode_id) - { - if (!empty($this->bbcode_cache[$bbcode_id])) - { - foreach ($this->bbcode_cache[$bbcode_id] as $type => $array) - { - foreach ($array as $search => $replace) - { - ${$type}['search'][] = str_replace('$uid', $this->bbcode_uid, $search); - ${$type}['replace'][] = $replace; - } - - if (count($str['search'])) - { - $message = str_replace($str['search'], $str['replace'], $message); - $str = array('search' => array(), 'replace' => array()); - } - - if (count($preg['search'])) - { - // we need to turn the entities back into their original form to allow the - // search patterns to work properly - if (!$undid_bbcode_specialchars) - { - $message = str_replace(array(':', '.'), array(':', '.'), $message); - $undid_bbcode_specialchars = true; - } - - foreach ($preg['search'] as $key => $search) - { - if (is_callable($preg['replace'][$key])) - { - $message = preg_replace_callback($search, $preg['replace'][$key], $message); - } - else - { - $message = preg_replace($search, $preg['replace'][$key], $message); - } - } - - $preg = array('search' => array(), 'replace' => array()); - } - } - } - } - - // Remove the uid from tags that have not been transformed into HTML - $message = str_replace(':' . $this->bbcode_uid, '', $message); - } - - /** - * Init bbcode cache - * - * requires: $this->bbcode_bitfield - * sets: $this->bbcode_cache with bbcode templates needed for bbcode_bitfield - */ - function bbcode_cache_init() - { - global $user, $phpbb_dispatcher, $phpbb_extension_manager, $phpbb_container, $phpbb_filesystem; - - if (empty($this->template_filename)) - { - $this->template_bitfield = new bitfield($user->style['bbcode_bitfield']); - - $template = new \phpbb\template\twig\twig( - $phpbb_container->get('path_helper'), - $phpbb_container->get('config'), - new \phpbb\template\context(), - new \phpbb\template\twig\environment( - $phpbb_container->get('config'), - $phpbb_container->get('filesystem'), - $phpbb_container->get('path_helper'), - $phpbb_container->getParameter('core.cache_dir'), - $phpbb_container->get('ext.manager'), - new \phpbb\template\twig\loader( - $phpbb_filesystem - ) - ), - $phpbb_container->getParameter('core.cache_dir'), - $phpbb_container->get('user'), - $phpbb_container->get('template.twig.extensions.collection'), - $phpbb_extension_manager - ); - - $template->set_style(); - $template->set_filenames(array('bbcode.html' => 'bbcode.html')); - $this->template_filename = $template->get_source_file_for_handle('bbcode.html'); - } - - $bbcode_ids = $rowset = $sql = array(); - - $bitfield = new bitfield($this->bbcode_bitfield); - $bbcodes_set = $bitfield->get_all_set(); - - foreach ($bbcodes_set as $bbcode_id) - { - if (isset($this->bbcode_cache[$bbcode_id])) - { - // do not try to re-cache it if it's already in - continue; - } - $bbcode_ids[] = $bbcode_id; - - if ($bbcode_id > NUM_CORE_BBCODES) - { - $sql[] = $bbcode_id; - } - } - - if (count($sql)) - { - global $db; - - $sql = 'SELECT * - FROM ' . BBCODES_TABLE . ' - WHERE ' . $db->sql_in_set('bbcode_id', $sql); - $result = $db->sql_query($sql, 3600); - - while ($row = $db->sql_fetchrow($result)) - { - // To circumvent replacing newlines with
for the generated html, - // we use carriage returns here. They are later changed back to newlines - $row['bbcode_tpl'] = str_replace("\n", "\r", $row['bbcode_tpl']); - $row['second_pass_replace'] = str_replace("\n", "\r", $row['second_pass_replace']); - - $rowset[$row['bbcode_id']] = $row; - } - $db->sql_freeresult($result); - } - - // To perform custom second pass in extension, use $this->bbcode_second_pass_by_extension() - // method which accepts variable number of parameters - foreach ($bbcode_ids as $bbcode_id) - { - switch ($bbcode_id) - { - case BBCODE_ID_QUOTE: - $this->bbcode_cache[$bbcode_id] = array( - 'str' => array( - '[/quote:$uid]' => $this->bbcode_tpl('quote_close', $bbcode_id) - ), - 'preg' => array( - '#\[quote(?:="(.*?)")?:$uid\]((?!\[quote(?:=".*?")?:$uid\]).)?#is' => function ($match) { - if (!isset($match[2])) - { - $match[2] = ''; - } - - return $this->bbcode_second_pass_quote($match[1], $match[2]); - }, - ) - ); - break; - - case BBCODE_ID_B: - $this->bbcode_cache[$bbcode_id] = array( - 'str' => array( - '[b:$uid]' => $this->bbcode_tpl('b_open', $bbcode_id), - '[/b:$uid]' => $this->bbcode_tpl('b_close', $bbcode_id), - ) - ); - break; - - case BBCODE_ID_I: - $this->bbcode_cache[$bbcode_id] = array( - 'str' => array( - '[i:$uid]' => $this->bbcode_tpl('i_open', $bbcode_id), - '[/i:$uid]' => $this->bbcode_tpl('i_close', $bbcode_id), - ) - ); - break; - - case BBCODE_ID_URL: - $this->bbcode_cache[$bbcode_id] = array( - 'preg' => array( - '#\[url:$uid\]((.*?))\[/url:$uid\]#s' => $this->bbcode_tpl('url', $bbcode_id), - '#\[url=([^\[]+?):$uid\](.*?)\[/url:$uid\]#s' => $this->bbcode_tpl('url', $bbcode_id), - ) - ); - break; - - case BBCODE_ID_IMG: - if ($user->optionget('viewimg')) - { - $this->bbcode_cache[$bbcode_id] = array( - 'preg' => array( - '#\[img:$uid\](.*?)\[/img:$uid\]#s' => $this->bbcode_tpl('img', $bbcode_id), - ) - ); - } - else - { - $this->bbcode_cache[$bbcode_id] = array( - 'preg' => array( - '#\[img:$uid\](.*?)\[/img:$uid\]#s' => str_replace('$2', '[ img ]', $this->bbcode_tpl('url', $bbcode_id, true)), - ) - ); - } - break; - - case BBCODE_ID_SIZE: - $this->bbcode_cache[$bbcode_id] = array( - 'preg' => array( - '#\[size=([\-\+]?\d+):$uid\](.*?)\[/size:$uid\]#s' => $this->bbcode_tpl('size', $bbcode_id), - ) - ); - break; - - case BBCODE_ID_COLOR: - $this->bbcode_cache[$bbcode_id] = array( - 'preg' => array( - '!\[color=(#[0-9a-f]{3}|#[0-9a-f]{6}|[a-z\-]+):$uid\](.*?)\[/color:$uid\]!is' => $this->bbcode_tpl('color', $bbcode_id), - ) - ); - break; - - case BBCODE_ID_U: - $this->bbcode_cache[$bbcode_id] = array( - 'str' => array( - '[u:$uid]' => $this->bbcode_tpl('u_open', $bbcode_id), - '[/u:$uid]' => $this->bbcode_tpl('u_close', $bbcode_id), - ) - ); - break; - - case BBCODE_ID_CODE: - $this->bbcode_cache[$bbcode_id] = array( - 'preg' => array( - '#\[code(?:=([a-z]+))?:$uid\](.*?)\[/code:$uid\]#is' => function ($match) { - return $this->bbcode_second_pass_code($match[1], $match[2]); - }, - ) - ); - break; - - case BBCODE_ID_LIST: - $this->bbcode_cache[$bbcode_id] = array( - 'preg' => array( - '#(\[\/?(list|\*):[mou]?:?$uid\])[\n]{1}#' => "\$1", - '#(\[list=([^\[]+):$uid\])[\n]{1}#' => "\$1", - '#\[list=([^\[]+):$uid\]#' => function ($match) { - return $this->bbcode_list($match[1]); - }, - ), - 'str' => array( - '[list:$uid]' => $this->bbcode_tpl('ulist_open_default', $bbcode_id), - '[/list:u:$uid]' => $this->bbcode_tpl('ulist_close', $bbcode_id), - '[/list:o:$uid]' => $this->bbcode_tpl('olist_close', $bbcode_id), - '[*:$uid]' => $this->bbcode_tpl('listitem', $bbcode_id), - '[/*:$uid]' => $this->bbcode_tpl('listitem_close', $bbcode_id), - '[/*:m:$uid]' => $this->bbcode_tpl('listitem_close', $bbcode_id) - ), - ); - break; - - case BBCODE_ID_EMAIL: - $this->bbcode_cache[$bbcode_id] = array( - 'preg' => array( - '#\[email:$uid\]((.*?))\[/email:$uid\]#is' => $this->bbcode_tpl('email', $bbcode_id), - '#\[email=([^\[]+):$uid\](.*?)\[/email:$uid\]#is' => $this->bbcode_tpl('email', $bbcode_id) - ) - ); - break; - - case BBCODE_ID_FLASH: - if ($user->optionget('viewflash')) - { - $this->bbcode_cache[$bbcode_id] = array( - 'preg' => array( - '#\[flash=([0-9]+),([0-9]+):$uid\](.*?)\[/flash:$uid\]#' => $this->bbcode_tpl('flash', $bbcode_id), - ) - ); - } - else - { - $this->bbcode_cache[$bbcode_id] = array( - 'preg' => array( - '#\[flash=([0-9]+),([0-9]+):$uid\](.*?)\[/flash:$uid\]#' => str_replace('$1', '$3', str_replace('$2', '[ flash ]', $this->bbcode_tpl('url', $bbcode_id, true))) - ) - ); - } - break; - - case BBCODE_ID_ATTACH: - $this->bbcode_cache[$bbcode_id] = array( - 'str' => array( - '[/attachment:$uid]' => $this->bbcode_tpl('inline_attachment_close', $bbcode_id) - ), - 'preg' => array( - '#\[attachment=([0-9]+):$uid\]#' => $this->bbcode_tpl('inline_attachment_open', $bbcode_id) - ) - ); - break; - - default: - if (isset($rowset[$bbcode_id])) - { - if ($this->template_bitfield->get($bbcode_id)) - { - // The bbcode requires a custom template to be loaded - if (!$bbcode_tpl = $this->bbcode_tpl($rowset[$bbcode_id]['bbcode_tag'], $bbcode_id)) - { - // For some reason, the required template seems not to be available, use the default template - $bbcode_tpl = (!empty($rowset[$bbcode_id]['second_pass_replace'])) ? $rowset[$bbcode_id]['second_pass_replace'] : $rowset[$bbcode_id]['bbcode_tpl']; - } - else - { - // In order to use templates with custom bbcodes we need - // to replace all {VARS} to corresponding backreferences - // Note that backreferences are numbered from bbcode_match - if (preg_match_all('/\{(URL|LOCAL_URL|EMAIL|TEXT|SIMPLETEXT|INTTEXT|IDENTIFIER|COLOR|NUMBER)[0-9]*\}/', $rowset[$bbcode_id]['bbcode_match'], $m)) - { - foreach ($m[0] as $i => $tok) - { - $bbcode_tpl = str_replace($tok, '$' . ($i + 1), $bbcode_tpl); - } - } - } - } - else - { - // Default template - $bbcode_tpl = (!empty($rowset[$bbcode_id]['second_pass_replace'])) ? $rowset[$bbcode_id]['second_pass_replace'] : $rowset[$bbcode_id]['bbcode_tpl']; - } - - // Replace {L_*} lang strings - $bbcode_tpl = preg_replace_callback('/{L_([A-Z0-9_]+)}/', function ($match) use ($user) { - return (!empty($user->lang[$match[1]])) ? $user->lang($match[1]) : ucwords(strtolower(str_replace('_', ' ', $match[1]))); - }, $bbcode_tpl); - - if (!empty($rowset[$bbcode_id]['second_pass_replace'])) - { - // The custom BBCode requires second-pass pattern replacements - $this->bbcode_cache[$bbcode_id] = array( - 'preg' => array($rowset[$bbcode_id]['second_pass_match'] => $bbcode_tpl) - ); - } - else - { - $this->bbcode_cache[$bbcode_id] = array( - 'str' => array($rowset[$bbcode_id]['second_pass_match'] => $bbcode_tpl) - ); - } - } - else - { - $this->bbcode_cache[$bbcode_id] = false; - } - break; - } - } - - $bbcode_cache = $this->bbcode_cache; - $bbcode_bitfield = $this->bbcode_bitfield; - $bbcode_uid = $this->bbcode_uid; - - /** - * Use this event to modify the bbcode_cache - * - * @event core.bbcode_cache_init_end - * @var array bbcode_cache The array of cached search and replace patterns of bbcodes - * @var string bbcode_bitfield The bbcode bitfield - * @var string bbcode_uid The bbcode uid - * @since 3.1.3-RC1 - */ - $vars = array('bbcode_cache', 'bbcode_bitfield', 'bbcode_uid'); - extract($phpbb_dispatcher->trigger_event('core.bbcode_cache_init_end', compact($vars))); - - $this->bbcode_cache = $bbcode_cache; - $this->bbcode_bitfield = $bbcode_bitfield; - $this->bbcode_uid = $bbcode_uid; - } - - /** - * Return bbcode template - */ - function bbcode_tpl($tpl_name, $bbcode_id = -1, $skip_bitfield_check = false) - { - static $bbcode_hardtpl = array(); - if (empty($bbcode_hardtpl)) - { - global $user; - - $bbcode_hardtpl = array( - 'b_open' => '', - 'b_close' => '', - 'i_open' => '', - 'i_close' => '', - 'u_open' => '', - 'u_close' => '', - 'img' => '' . $user->lang['IMAGE'] . '', - 'size' => '$2', - 'color' => '$2', - 'email' => '$2' - ); - } - - if ($bbcode_id != -1 && !$skip_bitfield_check && !$this->template_bitfield->get($bbcode_id)) - { - return (isset($bbcode_hardtpl[$tpl_name])) ? $bbcode_hardtpl[$tpl_name] : false; - } - - if (empty($this->bbcode_template)) - { - if (($tpl = file_get_contents($this->template_filename)) === false) - { - trigger_error('Could not load bbcode template', E_USER_ERROR); - } - - // replace \ with \\ and then ' with \'. - $tpl = str_replace('\\', '\\\\', $tpl); - $tpl = str_replace("'", "\'", $tpl); - - // strip newlines and indent - $tpl = preg_replace("/\n[\n\r\s\t]*/", '', $tpl); - - // Turn template blocks into PHP assignment statements for the values of $bbcode_tpl.. - $this->bbcode_template = array(); - - // Capture the BBCode template matches - // Allow phpBB template or the Twig syntax - $matches = (preg_match_all('#(.*?)#', $tpl, $match)) ?: - preg_match_all('#{% for (.*?) in .*? %}(.*?){% endfor %}#s', $tpl, $match); - - for ($i = 0; $i < $matches; $i++) - { - if (empty($match[1][$i])) - { - continue; - } - - $this->bbcode_template[$match[1][$i]] = $this->bbcode_tpl_replace($match[1][$i], $match[2][$i]); - } - } - - return (isset($this->bbcode_template[$tpl_name])) ? $this->bbcode_template[$tpl_name] : ((isset($bbcode_hardtpl[$tpl_name])) ? $bbcode_hardtpl[$tpl_name] : false); - } - - /** - * Return bbcode template replacement - */ - function bbcode_tpl_replace($tpl_name, $tpl) - { - global $user; - - static $replacements = array( - 'quote_username_open' => array('{USERNAME}' => '$1'), - 'color' => array('{COLOR}' => '$1', '{TEXT}' => '$2'), - 'size' => array('{SIZE}' => '$1', '{TEXT}' => '$2'), - 'img' => array('{URL}' => '$1'), - 'flash' => array('{WIDTH}' => '$1', '{HEIGHT}' => '$2', '{URL}' => '$3'), - 'url' => array('{URL}' => '$1', '{DESCRIPTION}' => '$2'), - 'email' => array('{EMAIL}' => '$1', '{DESCRIPTION}' => '$2') - ); - - $tpl = preg_replace_callback('/{L_([A-Z0-9_]+)}/', function ($match) use ($user) { - return (!empty($user->lang[$match[1]])) ? $user->lang($match[1]) : ucwords(strtolower(str_replace('_', ' ', $match[1]))); - }, $tpl); - - if (!empty($replacements[$tpl_name])) - { - $tpl = strtr($tpl, $replacements[$tpl_name]); - } - - return trim($tpl); - } - - /** - * Second parse list bbcode - */ - function bbcode_list($type) - { - if ($type == '') - { - $tpl = 'ulist_open_default'; - $type = 'default'; - } - else if ($type == 'i') - { - $tpl = 'olist_open'; - $type = 'lower-roman'; - } - else if ($type == 'I') - { - $tpl = 'olist_open'; - $type = 'upper-roman'; - } - else if (preg_match('#^(disc|circle|square)$#i', $type)) - { - $tpl = 'ulist_open'; - $type = strtolower($type); - } - else if (preg_match('#^[a-z]$#', $type)) - { - $tpl = 'olist_open'; - $type = 'lower-alpha'; - } - else if (preg_match('#[A-Z]#', $type)) - { - $tpl = 'olist_open'; - $type = 'upper-alpha'; - } - else if (is_numeric($type)) - { - $tpl = 'olist_open'; - $type = 'decimal'; - } - else - { - $tpl = 'olist_open'; - $type = 'decimal'; - } - - return str_replace('{LIST_TYPE}', $type, $this->bbcode_tpl($tpl)); - } - - /** - * Second parse quote tag - */ - function bbcode_second_pass_quote($username, $quote) - { - // when using the /e modifier, preg_replace slashes double-quotes but does not - // seem to slash anything else - $quote = str_replace('\"', '"', $quote); - $username = str_replace('\"', '"', $username); - - // remove newline at the beginning - if ($quote == "\n") - { - $quote = ''; - } - - $quote = (($username) ? str_replace('$1', $username, $this->bbcode_tpl('quote_username_open')) : $this->bbcode_tpl('quote_open')) . $quote; - - return $quote; - } - - /** - * Second parse code tag - */ - function bbcode_second_pass_code($type, $code) - { - // when using the /e modifier, preg_replace slashes double-quotes but does not - // seem to slash anything else - $code = str_replace('\"', '"', $code); - - switch ($type) - { - case 'php': - // Not the english way, but valid because of hardcoded syntax highlighting - if (strpos($code, '
') === 0) - { - $code = substr($code, 41); - } - - // no break; - - default: - $code = str_replace("\t", '   ', $code); - $code = str_replace(' ', '  ', $code); - $code = str_replace(' ', '  ', $code); - $code = str_replace("\n ", "\n ", $code); - - // keep space at the beginning - if (!empty($code) && $code[0] == ' ') - { - $code = ' ' . substr($code, 1); - } - - // remove newline at the beginning - if (!empty($code) && $code[0] == "\n") - { - $code = substr($code, 1); - } - break; - } - - $code = $this->bbcode_tpl('code_open') . $code . $this->bbcode_tpl('code_close'); - - return $code; - } - - /** - * Function to perform custom bbcode second pass by extensions - * can be used to assign bbcode pattern replacement - * Example: '#\[list=([^\[]+):$uid\]#e' => "\$this->bbcode_second_pass_by_extension('\$1')" - * - * Accepts variable number of parameters - * - * @return mixed Second pass result - */ - function bbcode_second_pass_by_extension() - { - global $phpbb_dispatcher; - - $return = false; - $params_array = func_get_args(); - - /** - * Event to perform bbcode second pass with - * the custom validating methods provided by extensions - * - * @event core.bbcode_second_pass_by_extension - * @var array params_array Array with the function parameters - * @var mixed return Second pass result to return - * - * @since 3.1.5-RC1 - */ - $vars = array('params_array', 'return'); - extract($phpbb_dispatcher->trigger_event('core.bbcode_second_pass_by_extension', compact($vars))); - - return $return; - } -} diff --git a/install/update/old/includes/compatibility_globals.php b/install/update/old/includes/compatibility_globals.php deleted file mode 100644 index ad394e3..0000000 --- a/install/update/old/includes/compatibility_globals.php +++ /dev/null @@ -1,84 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** - * Sets compatibility globals in the global scope - * - * This function registers compatibility variables to the global - * variable scope. This is required to make it possible to include this file - * in a service. - */ -function register_compatibility_globals() -{ - global $phpbb_container; - - global $cache, $phpbb_dispatcher, $request, $user, $auth, $db, $config, $language, $phpbb_log; - global $symfony_request, $phpbb_filesystem, $phpbb_path_helper, $phpbb_extension_manager, $template; - - // set up caching - /* @var $cache \phpbb\cache\service */ - $cache = $phpbb_container->get('cache'); - - // Instantiate some basic classes - /* @var $phpbb_dispatcher \phpbb\event\dispatcher */ - $phpbb_dispatcher = $phpbb_container->get('dispatcher'); - - /* @var $request \phpbb\request\request_interface */ - $request = $phpbb_container->get('request'); - // Inject request instance, so only this instance is used with request_var - request_var('', 0, false, false, $request); - - /* @var $user \phpbb\user */ - $user = $phpbb_container->get('user'); - - /* @var \phpbb\language\language $language */ - $language = $phpbb_container->get('language'); - - /* @var $auth \phpbb\auth\auth */ - $auth = $phpbb_container->get('auth'); - - /* @var $db \phpbb\db\driver\driver_interface */ - $db = $phpbb_container->get('dbal.conn'); - - // Grab global variables, re-cache if necessary - /* @var $config phpbb\config\db */ - $config = $phpbb_container->get('config'); - set_config('', '', false, $config); - set_config_count('', 0, false, $config); - - /* @var $phpbb_log \phpbb\log\log_interface */ - $phpbb_log = $phpbb_container->get('log'); - - /* @var $symfony_request \phpbb\symfony_request */ - $symfony_request = $phpbb_container->get('symfony_request'); - - /* @var $phpbb_filesystem \phpbb\filesystem\filesystem_interface */ - $phpbb_filesystem = $phpbb_container->get('filesystem'); - - /* @var $phpbb_path_helper \phpbb\path_helper */ - $phpbb_path_helper = $phpbb_container->get('path_helper'); - - // load extensions - /* @var $phpbb_extension_manager \phpbb\extension\manager */ - $phpbb_extension_manager = $phpbb_container->get('ext.manager'); - - /* @var $template \phpbb\template\template */ - $template = $phpbb_container->get('template'); -} diff --git a/install/update/old/includes/constants.php b/install/update/old/includes/constants.php deleted file mode 100644 index 3effe6c..0000000 --- a/install/update/old/includes/constants.php +++ /dev/null @@ -1,316 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* valid external constants: -* PHPBB_MSG_HANDLER -* PHPBB_DB_NEW_LINK -* PHPBB_ROOT_PATH -* PHPBB_ADMIN_PATH -*/ - -// phpBB Version -@define('PHPBB_VERSION', '3.2.7'); - -// QA-related -// define('PHPBB_QA', 1); - -// User related -define('ANONYMOUS', 1); - -define('USER_ACTIVATION_NONE', 0); -define('USER_ACTIVATION_SELF', 1); -define('USER_ACTIVATION_ADMIN', 2); -define('USER_ACTIVATION_DISABLE', 3); - -define('AVATAR_UPLOAD', 1); -define('AVATAR_REMOTE', 2); -define('AVATAR_GALLERY', 3); - -define('USER_NORMAL', 0); -define('USER_INACTIVE', 1); -define('USER_IGNORE', 2); -define('USER_FOUNDER', 3); - -define('INACTIVE_REGISTER', 1); // Newly registered account -define('INACTIVE_PROFILE', 2); // Profile details changed -define('INACTIVE_MANUAL', 3); // Account deactivated by administrator -define('INACTIVE_REMIND', 4); // Forced user account reactivation - -// ACL -define('ACL_NEVER', 0); -define('ACL_YES', 1); -define('ACL_NO', -1); - -// Login error codes -define('LOGIN_CONTINUE', 1); -define('LOGIN_BREAK', 2); -define('LOGIN_SUCCESS', 3); -define('LOGIN_SUCCESS_CREATE_PROFILE', 20); -define('LOGIN_SUCCESS_LINK_PROFILE', 21); -define('LOGIN_ERROR_USERNAME', 10); -define('LOGIN_ERROR_PASSWORD', 11); -define('LOGIN_ERROR_ACTIVE', 12); -define('LOGIN_ERROR_ATTEMPTS', 13); -define('LOGIN_ERROR_EXTERNAL_AUTH', 14); -define('LOGIN_ERROR_PASSWORD_CONVERT', 15); - -// Maximum login attempts -// The value is arbitrary, but it has to fit into the user_login_attempts field. -define('LOGIN_ATTEMPTS_MAX', 100); - -// Group settings -define('GROUP_OPEN', 0); -define('GROUP_CLOSED', 1); -define('GROUP_HIDDEN', 2); -define('GROUP_SPECIAL', 3); -define('GROUP_FREE', 4); - -// Forum/Topic states -define('FORUM_CAT', 0); -define('FORUM_POST', 1); -define('FORUM_LINK', 2); -define('ITEM_UNLOCKED', 0); -define('ITEM_LOCKED', 1); -define('ITEM_MOVED', 2); - -define('ITEM_UNAPPROVED', 0); // => has not yet been approved -define('ITEM_APPROVED', 1); // => has been approved, and has not been soft deleted -define('ITEM_DELETED', 2); // => has been soft deleted -define('ITEM_REAPPROVE', 3); // => has been edited and needs to be re-approved - -// Forum Flags -define('FORUM_FLAG_LINK_TRACK', 1); -define('FORUM_FLAG_PRUNE_POLL', 2); -define('FORUM_FLAG_PRUNE_ANNOUNCE', 4); -define('FORUM_FLAG_PRUNE_STICKY', 8); -define('FORUM_FLAG_ACTIVE_TOPICS', 16); -define('FORUM_FLAG_POST_REVIEW', 32); -define('FORUM_FLAG_QUICK_REPLY', 64); - -// Forum Options... sequential order. Modifications should begin at number 10 (number 29 is maximum) -define('FORUM_OPTION_FEED_NEWS', 1); -define('FORUM_OPTION_FEED_EXCLUDE', 2); - -// Optional text flags -define('OPTION_FLAG_BBCODE', 1); -define('OPTION_FLAG_SMILIES', 2); -define('OPTION_FLAG_LINKS', 4); - -// Topic types -define('POST_NORMAL', 0); -define('POST_STICKY', 1); -define('POST_ANNOUNCE', 2); -define('POST_GLOBAL', 3); - -// Lastread types -define('TRACK_NORMAL', 0); -define('TRACK_POSTED', 1); - -// Notify methods -define('NOTIFY_EMAIL', 0); -define('NOTIFY_IM', 1); -define('NOTIFY_BOTH', 2); - -// Notify status -define('NOTIFY_YES', 0); -define('NOTIFY_NO', 1); - -// Email Priority Settings -define('MAIL_LOW_PRIORITY', 4); -define('MAIL_NORMAL_PRIORITY', 3); -define('MAIL_HIGH_PRIORITY', 2); - -// Log types -define('LOG_ADMIN', 0); -define('LOG_MOD', 1); -define('LOG_CRITICAL', 2); -define('LOG_USERS', 3); - -// Private messaging - Do NOT change these values -define('PRIVMSGS_HOLD_BOX', -4); -define('PRIVMSGS_NO_BOX', -3); -define('PRIVMSGS_OUTBOX', -2); -define('PRIVMSGS_SENTBOX', -1); -define('PRIVMSGS_INBOX', 0); - -// Full Folder Actions -define('FULL_FOLDER_NONE', -3); -define('FULL_FOLDER_DELETE', -2); -define('FULL_FOLDER_HOLD', -1); - -// Download Modes - Attachments -define('INLINE_LINK', 1); -// This mode is only used internally to allow modders extending the attachment functionality -define('PHYSICAL_LINK', 2); - -// Confirm types -define('CONFIRM_REG', 1); -define('CONFIRM_LOGIN', 2); -define('CONFIRM_POST', 3); -define('CONFIRM_REPORT', 4); - -// Categories - Attachments -define('ATTACHMENT_CATEGORY_NONE', 0); -define('ATTACHMENT_CATEGORY_IMAGE', 1); // Inline Images -define('ATTACHMENT_CATEGORY_WM', 2); // Windows Media Files - Streaming - @deprecated 3.2 -define('ATTACHMENT_CATEGORY_RM', 3); // Real Media Files - Streaming - @deprecated 3.2 -define('ATTACHMENT_CATEGORY_THUMB', 4); // Not used within the database, only while displaying posts -define('ATTACHMENT_CATEGORY_FLASH', 5); // Flash/SWF files -define('ATTACHMENT_CATEGORY_QUICKTIME', 6); // Quicktime/Mov files - @deprecated 3.2 - -// BBCode UID length -define('BBCODE_UID_LEN', 8); - -// Number of core BBCodes -define('NUM_CORE_BBCODES', 12); -define('NUM_PREDEFINED_BBCODES', 22); - -// BBCode IDs -define('BBCODE_ID_QUOTE', 0); -define('BBCODE_ID_B', 1); -define('BBCODE_ID_I', 2); -define('BBCODE_ID_URL', 3); -define('BBCODE_ID_IMG', 4); -define('BBCODE_ID_SIZE', 5); -define('BBCODE_ID_COLOR', 6); -define('BBCODE_ID_U', 7); -define('BBCODE_ID_CODE', 8); -define('BBCODE_ID_LIST', 9); -define('BBCODE_ID_EMAIL', 10); -define('BBCODE_ID_FLASH', 11); -define('BBCODE_ID_ATTACH', 12); - -// BBCode hard limit -define('BBCODE_LIMIT', 1511); - -// Smiley hard limit -define('SMILEY_LIMIT', 1000); - -// Magic url types -define('MAGIC_URL_EMAIL', 1); -define('MAGIC_URL_FULL', 2); -define('MAGIC_URL_LOCAL', 3); -define('MAGIC_URL_WWW', 4); - -// Profile Field Types -define('FIELD_INT', 1); -define('FIELD_STRING', 2); -define('FIELD_TEXT', 3); -define('FIELD_BOOL', 4); -define('FIELD_DROPDOWN', 5); -define('FIELD_DATE', 6); - -// referer validation -define('REFERER_VALIDATE_NONE', 0); -define('REFERER_VALIDATE_HOST', 1); -define('REFERER_VALIDATE_PATH', 2); - -// phpbb_chmod() permissions -@define('CHMOD_ALL', 7); -@define('CHMOD_READ', 4); -@define('CHMOD_WRITE', 2); -@define('CHMOD_EXECUTE', 1); - -// Captcha code length -define('CAPTCHA_MIN_CHARS', 4); -define('CAPTCHA_MAX_CHARS', 7); - -// Additional constants -define('VOTE_CONVERTED', 127); - -// BC global FTW -global $table_prefix; - -// Table names -define('ACL_GROUPS_TABLE', $table_prefix . 'acl_groups'); -define('ACL_OPTIONS_TABLE', $table_prefix . 'acl_options'); -define('ACL_ROLES_DATA_TABLE', $table_prefix . 'acl_roles_data'); -define('ACL_ROLES_TABLE', $table_prefix . 'acl_roles'); -define('ACL_USERS_TABLE', $table_prefix . 'acl_users'); -define('ATTACHMENTS_TABLE', $table_prefix . 'attachments'); -define('BANLIST_TABLE', $table_prefix . 'banlist'); -define('BBCODES_TABLE', $table_prefix . 'bbcodes'); -define('BOOKMARKS_TABLE', $table_prefix . 'bookmarks'); -define('BOTS_TABLE', $table_prefix . 'bots'); -@define('CONFIG_TABLE', $table_prefix . 'config'); -define('CONFIG_TEXT_TABLE', $table_prefix . 'config_text'); -define('CONFIRM_TABLE', $table_prefix . 'confirm'); -define('DISALLOW_TABLE', $table_prefix . 'disallow'); -define('DRAFTS_TABLE', $table_prefix . 'drafts'); -define('EXT_TABLE', $table_prefix . 'ext'); -define('EXTENSIONS_TABLE', $table_prefix . 'extensions'); -define('EXTENSION_GROUPS_TABLE', $table_prefix . 'extension_groups'); -define('FORUMS_TABLE', $table_prefix . 'forums'); -define('FORUMS_ACCESS_TABLE', $table_prefix . 'forums_access'); -define('FORUMS_TRACK_TABLE', $table_prefix . 'forums_track'); -define('FORUMS_WATCH_TABLE', $table_prefix . 'forums_watch'); -define('GROUPS_TABLE', $table_prefix . 'groups'); -define('ICONS_TABLE', $table_prefix . 'icons'); -define('LANG_TABLE', $table_prefix . 'lang'); -define('LOG_TABLE', $table_prefix . 'log'); -define('LOGIN_ATTEMPT_TABLE', $table_prefix . 'login_attempts'); -define('MIGRATIONS_TABLE', $table_prefix . 'migrations'); -define('MODERATOR_CACHE_TABLE', $table_prefix . 'moderator_cache'); -define('MODULES_TABLE', $table_prefix . 'modules'); -define('NOTIFICATION_TYPES_TABLE', $table_prefix . 'notification_types'); -define('NOTIFICATIONS_TABLE', $table_prefix . 'notifications'); -define('POLL_OPTIONS_TABLE', $table_prefix . 'poll_options'); -define('POLL_VOTES_TABLE', $table_prefix . 'poll_votes'); -define('POSTS_TABLE', $table_prefix . 'posts'); -define('PRIVMSGS_TABLE', $table_prefix . 'privmsgs'); -define('PRIVMSGS_FOLDER_TABLE', $table_prefix . 'privmsgs_folder'); -define('PRIVMSGS_RULES_TABLE', $table_prefix . 'privmsgs_rules'); -define('PRIVMSGS_TO_TABLE', $table_prefix . 'privmsgs_to'); -define('PROFILE_FIELDS_TABLE', $table_prefix . 'profile_fields'); -define('PROFILE_FIELDS_DATA_TABLE', $table_prefix . 'profile_fields_data'); -define('PROFILE_FIELDS_LANG_TABLE', $table_prefix . 'profile_fields_lang'); -define('PROFILE_LANG_TABLE', $table_prefix . 'profile_lang'); -define('RANKS_TABLE', $table_prefix . 'ranks'); -define('REPORTS_TABLE', $table_prefix . 'reports'); -define('REPORTS_REASONS_TABLE', $table_prefix . 'reports_reasons'); -define('SEARCH_RESULTS_TABLE', $table_prefix . 'search_results'); -define('SEARCH_WORDLIST_TABLE', $table_prefix . 'search_wordlist'); -define('SEARCH_WORDMATCH_TABLE', $table_prefix . 'search_wordmatch'); -define('SESSIONS_TABLE', $table_prefix . 'sessions'); -define('SESSIONS_KEYS_TABLE', $table_prefix . 'sessions_keys'); -define('SITELIST_TABLE', $table_prefix . 'sitelist'); -define('SMILIES_TABLE', $table_prefix . 'smilies'); -define('SPHINX_TABLE', $table_prefix . 'sphinx'); -define('STYLES_TABLE', $table_prefix . 'styles'); -define('STYLES_TEMPLATE_TABLE', $table_prefix . 'styles_template'); -define('STYLES_TEMPLATE_DATA_TABLE',$table_prefix . 'styles_template_data'); -define('STYLES_THEME_TABLE', $table_prefix . 'styles_theme'); -define('STYLES_IMAGESET_TABLE', $table_prefix . 'styles_imageset'); -define('STYLES_IMAGESET_DATA_TABLE',$table_prefix . 'styles_imageset_data'); -define('TEAMPAGE_TABLE', $table_prefix . 'teampage'); -define('TOPICS_TABLE', $table_prefix . 'topics'); -define('TOPICS_POSTED_TABLE', $table_prefix . 'topics_posted'); -define('TOPICS_TRACK_TABLE', $table_prefix . 'topics_track'); -define('TOPICS_WATCH_TABLE', $table_prefix . 'topics_watch'); -define('USER_GROUP_TABLE', $table_prefix . 'user_group'); -define('USER_NOTIFICATIONS_TABLE', $table_prefix . 'user_notifications'); -define('USERS_TABLE', $table_prefix . 'users'); -define('WARNINGS_TABLE', $table_prefix . 'warnings'); -define('WORDS_TABLE', $table_prefix . 'words'); -define('ZEBRA_TABLE', $table_prefix . 'zebra'); - -// Additional tables diff --git a/install/update/old/includes/diff/engine.php b/install/update/old/includes/diff/engine.php deleted file mode 100644 index 757fdad..0000000 --- a/install/update/old/includes/diff/engine.php +++ /dev/null @@ -1,555 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* Code from pear.php.net, Text_Diff-1.1.0 package -* http://pear.php.net/package/Text_Diff/ (native engine) -* -* Modified by phpBB Limited to meet our coding standards -* and being able to integrate into phpBB -* -* Class used internally by Text_Diff to actually compute the diffs. This -* class is implemented using native PHP code. -* -* The algorithm used here is mostly lifted from the perl module -* Algorithm::Diff (version 1.06) by Ned Konz, which is available at: -* http://www.perl.com/CPAN/authors/id/N/NE/NEDKONZ/Algorithm-Diff-1.06.zip -* -* More ideas are taken from: http://www.ics.uci.edu/~eppstein/161/960229.html -* -* Some ideas (and a bit of code) are taken from analyze.c, of GNU -* diffutils-2.7, which can be found at: -* ftp://gnudist.gnu.org/pub/gnu/diffutils/diffutils-2.7.tar.gz -* -* Some ideas (subdivision by NCHUNKS > 2, and some optimizations) are from -* Geoffrey T. Dairiki . The original PHP version of this -* code was written by him, and is used/adapted with his permission. -* -* Copyright 2004-2008 The Horde Project (http://www.horde.org/) -* -* @author Geoffrey T. Dairiki -* @package diff -* -* @access private -*/ -class diff_engine -{ - /** - * If set to true we trim all lines before we compare them. This ensures that sole space/tab changes do not trigger diffs. - */ - var $skip_whitespace_changes = true; - - function diff(&$from_lines, &$to_lines, $preserve_cr = true) - { - // Remove empty lines... - // If preserve_cr is true, we basically only change \r\n and bare \r to \n to get the same carriage returns for both files - // If it is false, we try to only use \n once per line and ommit all empty lines to be able to get a proper data diff - - if (is_array($from_lines)) - { - $from_lines = implode("\n", $from_lines); - } - - if (is_array($to_lines)) - { - $to_lines = implode("\n", $to_lines); - } - - if ($preserve_cr) - { - $from_lines = explode("\n", str_replace("\r", "\n", str_replace("\r\n", "\n", $from_lines))); - $to_lines = explode("\n", str_replace("\r", "\n", str_replace("\r\n", "\n", $to_lines))); - } - else - { - $from_lines = explode("\n", preg_replace('#[\n\r]+#', "\n", $from_lines)); - $to_lines = explode("\n", preg_replace('#[\n\r]+#', "\n", $to_lines)); - } - - $n_from = count($from_lines); - $n_to = count($to_lines); - - $this->xchanged = $this->ychanged = $this->xv = $this->yv = $this->xind = $this->yind = array(); - unset($this->seq, $this->in_seq, $this->lcs); - - // Skip leading common lines. - for ($skip = 0; $skip < $n_from && $skip < $n_to; $skip++) - { - if (trim($from_lines[$skip]) !== trim($to_lines[$skip])) - { - break; - } - $this->xchanged[$skip] = $this->ychanged[$skip] = false; - } - - // Skip trailing common lines. - $xi = $n_from; - $yi = $n_to; - - for ($endskip = 0; --$xi > $skip && --$yi > $skip; $endskip++) - { - if (trim($from_lines[$xi]) !== trim($to_lines[$yi])) - { - break; - } - $this->xchanged[$xi] = $this->ychanged[$yi] = false; - } - - // Ignore lines which do not exist in both files. - for ($xi = $skip; $xi < $n_from - $endskip; $xi++) - { - if ($this->skip_whitespace_changes) $xhash[trim($from_lines[$xi])] = 1; else $xhash[$from_lines[$xi]] = 1; - } - - for ($yi = $skip; $yi < $n_to - $endskip; $yi++) - { - $line = ($this->skip_whitespace_changes) ? trim($to_lines[$yi]) : $to_lines[$yi]; - - if (($this->ychanged[$yi] = empty($xhash[$line]))) - { - continue; - } - $yhash[$line] = 1; - $this->yv[] = $line; - $this->yind[] = $yi; - } - - for ($xi = $skip; $xi < $n_from - $endskip; $xi++) - { - $line = ($this->skip_whitespace_changes) ? trim($from_lines[$xi]) : $from_lines[$xi]; - - if (($this->xchanged[$xi] = empty($yhash[$line]))) - { - continue; - } - $this->xv[] = $line; - $this->xind[] = $xi; - } - - // Find the LCS. - $this->_compareseq(0, count($this->xv), 0, count($this->yv)); - - // Merge edits when possible. - if ($this->skip_whitespace_changes) - { - $from_lines_clean = array_map('trim', $from_lines); - $to_lines_clean = array_map('trim', $to_lines); - - $this->_shift_boundaries($from_lines_clean, $this->xchanged, $this->ychanged); - $this->_shift_boundaries($to_lines_clean, $this->ychanged, $this->xchanged); - - unset($from_lines_clean, $to_lines_clean); - } - else - { - $this->_shift_boundaries($from_lines, $this->xchanged, $this->ychanged); - $this->_shift_boundaries($to_lines, $this->ychanged, $this->xchanged); - } - - // Compute the edit operations. - $edits = array(); - $xi = $yi = 0; - - while ($xi < $n_from || $yi < $n_to) - { - // Skip matching "snake". - $copy = array(); - - while ($xi < $n_from && $yi < $n_to && !$this->xchanged[$xi] && !$this->ychanged[$yi]) - { - $copy[] = $from_lines[$xi++]; - $yi++; - } - - if ($copy) - { - $edits[] = new diff_op_copy($copy); - } - - // Find deletes & adds. - $delete = array(); - while ($xi < $n_from && $this->xchanged[$xi]) - { - $delete[] = $from_lines[$xi++]; - } - - $add = array(); - while ($yi < $n_to && $this->ychanged[$yi]) - { - $add[] = $to_lines[$yi++]; - } - - if ($delete && $add) - { - $edits[] = new diff_op_change($delete, $add); - } - else if ($delete) - { - $edits[] = new diff_op_delete($delete); - } - else if ($add) - { - $edits[] = new diff_op_add($add); - } - } - - return $edits; - } - - /** - * Divides the Largest Common Subsequence (LCS) of the sequences (XOFF, - * XLIM) and (YOFF, YLIM) into NCHUNKS approximately equally sized segments. - * - * Returns (LCS, PTS). LCS is the length of the LCS. PTS is an array of - * NCHUNKS+1 (X, Y) indexes giving the diving points between sub - * sequences. The first sub-sequence is contained in (X0, X1), (Y0, Y1), - * the second in (X1, X2), (Y1, Y2) and so on. Note that (X0, Y0) == - * (XOFF, YOFF) and (X[NCHUNKS], Y[NCHUNKS]) == (XLIM, YLIM). - * - * This function assumes that the first lines of the specified portions of - * the two files do not match, and likewise that the last lines do not - * match. The caller must trim matching lines from the beginning and end - * of the portions it is going to specify. - */ - function _diag($xoff, $xlim, $yoff, $ylim, $nchunks) - { - $flip = false; - - if ($xlim - $xoff > $ylim - $yoff) - { - // Things seems faster (I'm not sure I understand why) when the shortest sequence is in X. - $flip = true; - list($xoff, $xlim, $yoff, $ylim) = array($yoff, $ylim, $xoff, $xlim); - } - - if ($flip) - { - for ($i = $ylim - 1; $i >= $yoff; $i--) - { - $ymatches[$this->xv[$i]][] = $i; - } - } - else - { - for ($i = $ylim - 1; $i >= $yoff; $i--) - { - $ymatches[$this->yv[$i]][] = $i; - } - } - - $this->lcs = 0; - $this->seq[0]= $yoff - 1; - $this->in_seq = array(); - $ymids[0] = array(); - - $numer = $xlim - $xoff + $nchunks - 1; - $x = $xoff; - - for ($chunk = 0; $chunk < $nchunks; $chunk++) - { - if ($chunk > 0) - { - for ($i = 0; $i <= $this->lcs; $i++) - { - $ymids[$i][$chunk - 1] = $this->seq[$i]; - } - } - - $x1 = $xoff + (int)(($numer + ($xlim - $xoff) * $chunk) / $nchunks); - - for (; $x < $x1; $x++) - { - $line = $flip ? $this->yv[$x] : $this->xv[$x]; - if (empty($ymatches[$line])) - { - continue; - } - $matches = $ymatches[$line]; - - reset($matches); - while (list(, $y) = each($matches)) - { - if (empty($this->in_seq[$y])) - { - $k = $this->_lcs_pos($y); - $ymids[$k] = $ymids[$k - 1]; - break; - } - } - - // no reset() here - while (list(, $y) = each($matches)) - { - if ($y > $this->seq[$k - 1]) - { - // Optimization: this is a common case: next match is just replacing previous match. - $this->in_seq[$this->seq[$k]] = false; - $this->seq[$k] = $y; - $this->in_seq[$y] = 1; - } - else if (empty($this->in_seq[$y])) - { - $k = $this->_lcs_pos($y); - $ymids[$k] = $ymids[$k - 1]; - } - } - } - } - - $seps[] = $flip ? array($yoff, $xoff) : array($xoff, $yoff); - $ymid = $ymids[$this->lcs]; - - for ($n = 0; $n < $nchunks - 1; $n++) - { - $x1 = $xoff + (int)(($numer + ($xlim - $xoff) * $n) / $nchunks); - $y1 = $ymid[$n] + 1; - $seps[] = $flip ? array($y1, $x1) : array($x1, $y1); - } - $seps[] = $flip ? array($ylim, $xlim) : array($xlim, $ylim); - - return array($this->lcs, $seps); - } - - function _lcs_pos($ypos) - { - $end = $this->lcs; - - if ($end == 0 || $ypos > $this->seq[$end]) - { - $this->seq[++$this->lcs] = $ypos; - $this->in_seq[$ypos] = 1; - return $this->lcs; - } - - $beg = 1; - while ($beg < $end) - { - $mid = (int)(($beg + $end) / 2); - if ($ypos > $this->seq[$mid]) - { - $beg = $mid + 1; - } - else - { - $end = $mid; - } - } - - $this->in_seq[$this->seq[$end]] = false; - $this->seq[$end] = $ypos; - $this->in_seq[$ypos] = 1; - - return $end; - } - - /** - * Finds LCS of two sequences. - * - * The results are recorded in the vectors $this->{x,y}changed[], by - * storing a 1 in the element for each line that is an insertion or - * deletion (ie. is not in the LCS). - * - * The subsequence of file 0 is (XOFF, XLIM) and likewise for file 1. - * - * Note that XLIM, YLIM are exclusive bounds. All line numbers are - * origin-0 and discarded lines are not counted. - */ - function _compareseq($xoff, $xlim, $yoff, $ylim) - { - // Slide down the bottom initial diagonal. - while ($xoff < $xlim && $yoff < $ylim && $this->xv[$xoff] == $this->yv[$yoff]) - { - ++$xoff; - ++$yoff; - } - - // Slide up the top initial diagonal. - while ($xlim > $xoff && $ylim > $yoff && $this->xv[$xlim - 1] == $this->yv[$ylim - 1]) - { - --$xlim; - --$ylim; - } - - if ($xoff == $xlim || $yoff == $ylim) - { - $lcs = 0; - } - else - { - // This is ad hoc but seems to work well. - // $nchunks = sqrt(min($xlim - $xoff, $ylim - $yoff) / 2.5); - // $nchunks = max(2,min(8,(int)$nchunks)); - $nchunks = min(7, $xlim - $xoff, $ylim - $yoff) + 1; - list($lcs, $seps) = $this->_diag($xoff, $xlim, $yoff, $ylim, $nchunks); - } - - if ($lcs == 0) - { - // X and Y sequences have no common subsequence: mark all changed. - while ($yoff < $ylim) - { - $this->ychanged[$this->yind[$yoff++]] = 1; - } - - while ($xoff < $xlim) - { - $this->xchanged[$this->xind[$xoff++]] = 1; - } - } - else - { - // Use the partitions to split this problem into subproblems. - reset($seps); - $pt1 = $seps[0]; - - while ($pt2 = next($seps)) - { - $this->_compareseq($pt1[0], $pt2[0], $pt1[1], $pt2[1]); - $pt1 = $pt2; - } - } - } - - /** - * Adjusts inserts/deletes of identical lines to join changes as much as possible. - * - * We do something when a run of changed lines include a line at one end - * and has an excluded, identical line at the other. We are free to - * choose which identical line is included. 'compareseq' usually chooses - * the one at the beginning, but usually it is cleaner to consider the - * following identical line to be the "change". - * - * This is extracted verbatim from analyze.c (GNU diffutils-2.7). - */ - function _shift_boundaries($lines, &$changed, $other_changed) - { - $i = 0; - $j = 0; - - $len = count($lines); - $other_len = count($other_changed); - - while (1) - { - // Scan forward to find the beginning of another run of - // changes. Also keep track of the corresponding point in the other file. - // - // Throughout this code, $i and $j are adjusted together so that - // the first $i elements of $changed and the first $j elements of - // $other_changed both contain the same number of zeros (unchanged lines). - // - // Furthermore, $j is always kept so that $j == $other_len or $other_changed[$j] == false. - while ($j < $other_len && $other_changed[$j]) - { - $j++; - } - - while ($i < $len && ! $changed[$i]) - { - $i++; - $j++; - - while ($j < $other_len && $other_changed[$j]) - { - $j++; - } - } - - if ($i == $len) - { - break; - } - - $start = $i; - - // Find the end of this run of changes. - while (++$i < $len && $changed[$i]) - { - continue; - } - - do - { - // Record the length of this run of changes, so that we can later determine whether the run has grown. - $runlength = $i - $start; - - // Move the changed region back, so long as the previous unchanged line matches the last changed one. - // This merges with previous changed regions. - while ($start > 0 && $lines[$start - 1] == $lines[$i - 1]) - { - $changed[--$start] = 1; - $changed[--$i] = false; - - while ($start > 0 && $changed[$start - 1]) - { - $start--; - } - - while ($other_changed[--$j]) - { - continue; - } - } - - // Set CORRESPONDING to the end of the changed run, at the last point where it corresponds to a changed run in the - // other file. CORRESPONDING == LEN means no such point has been found. - $corresponding = $j < $other_len ? $i : $len; - - // Move the changed region forward, so long as the first changed line matches the following unchanged one. - // This merges with following changed regions. - // Do this second, so that if there are no merges, the changed region is moved forward as far as possible. - while ($i < $len && $lines[$start] == $lines[$i]) - { - $changed[$start++] = false; - $changed[$i++] = 1; - - while ($i < $len && $changed[$i]) - { - $i++; - } - - $j++; - if ($j < $other_len && $other_changed[$j]) - { - $corresponding = $i; - while ($j < $other_len && $other_changed[$j]) - { - $j++; - } - } - } - } - while ($runlength != $i - $start); - - // If possible, move the fully-merged run of changes back to a corresponding run in the other file. - while ($corresponding < $i) - { - $changed[--$start] = 1; - $changed[--$i] = 0; - - while ($other_changed[--$j]) - { - continue; - } - } - } - } -} diff --git a/install/update/old/includes/functions.php b/install/update/old/includes/functions.php deleted file mode 100644 index 5234c34..0000000 --- a/install/update/old/includes/functions.php +++ /dev/null @@ -1,4945 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -// Common global functions -/** -* Load the autoloaders added by the extensions. -* -* @param string $phpbb_root_path Path to the phpbb root directory. -*/ -function phpbb_load_extensions_autoloaders($phpbb_root_path) -{ - $iterator = new \RecursiveIteratorIterator( - new \phpbb\recursive_dot_prefix_filter_iterator( - new \RecursiveDirectoryIterator( - $phpbb_root_path . 'ext/', - \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS - ) - ), - \RecursiveIteratorIterator::SELF_FIRST - ); - $iterator->setMaxDepth(2); - - foreach ($iterator as $file_info) - { - if ($file_info->getFilename() === 'vendor' && $iterator->getDepth() === 2) - { - $filename = $file_info->getRealPath() . '/autoload.php'; - if (file_exists($filename)) - { - require $filename; - } - } - } -} - -/** -* Casts a variable to the given type. -* -* @deprecated -*/ -function set_var(&$result, $var, $type, $multibyte = false) -{ - // no need for dependency injection here, if you have the object, call the method yourself! - $type_cast_helper = new \phpbb\request\type_cast_helper(); - $type_cast_helper->set_var($result, $var, $type, $multibyte); -} - -/** -* Generates an alphanumeric random string of given length -* -* @param int $num_chars Length of random string, defaults to 8. -* This number should be less or equal than 64. -* -* @return string -*/ -function gen_rand_string($num_chars = 8) -{ - $range = array_merge(range('A', 'Z'), range(0, 9)); - $size = count($range); - - $output = ''; - for ($i = 0; $i < $num_chars; $i++) - { - $rand = random_int(0, $size-1); - $output .= $range[$rand]; - } - - return $output; -} - -/** -* Generates a user-friendly alphanumeric random string of given length -* We remove 0 and O so users cannot confuse those in passwords etc. -* -* @param int $num_chars Length of random string, defaults to 8. -* This number should be less or equal than 64. -* -* @return string -*/ -function gen_rand_string_friendly($num_chars = 8) -{ - $range = array_merge(range('A', 'N'), range('P', 'Z'), range(1, 9)); - $size = count($range); - - $output = ''; - for ($i = 0; $i < $num_chars; $i++) - { - $rand = random_int(0, $size-1); - $output .= $range[$rand]; - } - - return $output; -} - -/** -* Return unique id -*/ -function unique_id() -{ - return strtolower(gen_rand_string(16)); -} - -/** -* Wrapper for mt_rand() which allows swapping $min and $max parameters. -* -* PHP does not allow us to swap the order of the arguments for mt_rand() anymore. -* (since PHP 5.3.4, see http://bugs.php.net/46587) -* -* @param int $min Lowest value to be returned -* @param int $max Highest value to be returned -* -* @return int Random integer between $min and $max (or $max and $min) -*/ -function phpbb_mt_rand($min, $max) -{ - return ($min > $max) ? mt_rand($max, $min) : mt_rand($min, $max); -} - -/** -* Wrapper for getdate() which returns the equivalent array for UTC timestamps. -* -* @param int $time Unix timestamp (optional) -* -* @return array Returns an associative array of information related to the timestamp. -* See http://www.php.net/manual/en/function.getdate.php -*/ -function phpbb_gmgetdate($time = false) -{ - if ($time === false) - { - $time = time(); - } - - // getdate() interprets timestamps in local time. - // What follows uses the fact that getdate() and - // date('Z') balance each other out. - return getdate($time - date('Z')); -} - -/** -* Return formatted string for filesizes -* -* @param mixed $value filesize in bytes -* (non-negative number; int, float or string) -* @param bool $string_only true if language string should be returned -* @param array $allowed_units only allow these units (data array indexes) -* -* @return mixed data array if $string_only is false -*/ -function get_formatted_filesize($value, $string_only = true, $allowed_units = false) -{ - global $user; - - $available_units = array( - 'tb' => array( - 'min' => 1099511627776, // pow(2, 40) - 'index' => 4, - 'si_unit' => 'TB', - 'iec_unit' => 'TIB', - ), - 'gb' => array( - 'min' => 1073741824, // pow(2, 30) - 'index' => 3, - 'si_unit' => 'GB', - 'iec_unit' => 'GIB', - ), - 'mb' => array( - 'min' => 1048576, // pow(2, 20) - 'index' => 2, - 'si_unit' => 'MB', - 'iec_unit' => 'MIB', - ), - 'kb' => array( - 'min' => 1024, // pow(2, 10) - 'index' => 1, - 'si_unit' => 'KB', - 'iec_unit' => 'KIB', - ), - 'b' => array( - 'min' => 0, - 'index' => 0, - 'si_unit' => 'BYTES', // Language index - 'iec_unit' => 'BYTES', // Language index - ), - ); - - foreach ($available_units as $si_identifier => $unit_info) - { - if (!empty($allowed_units) && $si_identifier != 'b' && !in_array($si_identifier, $allowed_units)) - { - continue; - } - - if ($value >= $unit_info['min']) - { - $unit_info['si_identifier'] = $si_identifier; - - break; - } - } - unset($available_units); - - for ($i = 0; $i < $unit_info['index']; $i++) - { - $value /= 1024; - } - $value = round($value, 2); - - // Lookup units in language dictionary - $unit_info['si_unit'] = (isset($user->lang[$unit_info['si_unit']])) ? $user->lang[$unit_info['si_unit']] : $unit_info['si_unit']; - $unit_info['iec_unit'] = (isset($user->lang[$unit_info['iec_unit']])) ? $user->lang[$unit_info['iec_unit']] : $unit_info['iec_unit']; - - // Default to IEC - $unit_info['unit'] = $unit_info['iec_unit']; - - if (!$string_only) - { - $unit_info['value'] = $value; - - return $unit_info; - } - - return $value . ' ' . $unit_info['unit']; -} - -/** -* Determine whether we are approaching the maximum execution time. Should be called once -* at the beginning of the script in which it's used. -* @return bool Either true if the maximum execution time is nearly reached, or false -* if some time is still left. -*/ -function still_on_time($extra_time = 15) -{ - static $max_execution_time, $start_time; - - $current_time = microtime(true); - - if (empty($max_execution_time)) - { - $max_execution_time = (function_exists('ini_get')) ? (int) @ini_get('max_execution_time') : (int) @get_cfg_var('max_execution_time'); - - // If zero, then set to something higher to not let the user catch the ten seconds barrier. - if ($max_execution_time === 0) - { - $max_execution_time = 50 + $extra_time; - } - - $max_execution_time = min(max(10, ($max_execution_time - $extra_time)), 50); - - // For debugging purposes - // $max_execution_time = 10; - - global $starttime; - $start_time = (empty($starttime)) ? $current_time : $starttime; - } - - return (ceil($current_time - $start_time) < $max_execution_time) ? true : false; -} - -/** -* Hashes an email address to a big integer -* -* @param string $email Email address -* -* @return string Unsigned Big Integer -*/ -function phpbb_email_hash($email) -{ - return sprintf('%u', crc32(strtolower($email))) . strlen($email); -} - -/** -* Wrapper for version_compare() that allows using uppercase A and B -* for alpha and beta releases. -* -* See http://www.php.net/manual/en/function.version-compare.php -* -* @param string $version1 First version number -* @param string $version2 Second version number -* @param string $operator Comparison operator (optional) -* -* @return mixed Boolean (true, false) if comparison operator is specified. -* Integer (-1, 0, 1) otherwise. -*/ -function phpbb_version_compare($version1, $version2, $operator = null) -{ - $version1 = strtolower($version1); - $version2 = strtolower($version2); - - if (is_null($operator)) - { - return version_compare($version1, $version2); - } - else - { - return version_compare($version1, $version2, $operator); - } -} - -// functions used for building option fields - -/** -* Pick a language, any language ... -*/ -function language_select($default = '') -{ - global $db; - - $sql = 'SELECT lang_iso, lang_local_name - FROM ' . LANG_TABLE . ' - ORDER BY lang_english_name'; - $result = $db->sql_query($sql); - - $lang_options = ''; - while ($row = $db->sql_fetchrow($result)) - { - $selected = ($row['lang_iso'] == $default) ? ' selected="selected"' : ''; - $lang_options .= ''; - } - $db->sql_freeresult($result); - - return $lang_options; -} - -/** -* Pick a template/theme combo, -*/ -function style_select($default = '', $all = false) -{ - global $db; - - $sql_where = (!$all) ? 'WHERE style_active = 1 ' : ''; - $sql = 'SELECT style_id, style_name - FROM ' . STYLES_TABLE . " - $sql_where - ORDER BY style_name"; - $result = $db->sql_query($sql); - - $style_options = ''; - while ($row = $db->sql_fetchrow($result)) - { - $selected = ($row['style_id'] == $default) ? ' selected="selected"' : ''; - $style_options .= ''; - } - $db->sql_freeresult($result); - - return $style_options; -} - -/** -* Format the timezone offset with hours and minutes -* -* @param int $tz_offset Timezone offset in seconds -* @param bool $show_null Whether null offsets should be shown -* @return string Normalized offset string: -7200 => -02:00 -* 16200 => +04:30 -*/ -function phpbb_format_timezone_offset($tz_offset, $show_null = false) -{ - $sign = ($tz_offset < 0) ? '-' : '+'; - $time_offset = abs($tz_offset); - - if ($time_offset == 0 && $show_null == false) - { - return ''; - } - - $offset_seconds = $time_offset % 3600; - $offset_minutes = $offset_seconds / 60; - $offset_hours = ($time_offset - $offset_seconds) / 3600; - - $offset_string = sprintf("%s%02d:%02d", $sign, $offset_hours, $offset_minutes); - return $offset_string; -} - -/** -* Compares two time zone labels. -* Arranges them in increasing order by timezone offset. -* Places UTC before other timezones in the same offset. -*/ -function phpbb_tz_select_compare($a, $b) -{ - $a_sign = $a[3]; - $b_sign = $b[3]; - if ($a_sign != $b_sign) - { - return $a_sign == '-' ? -1 : 1; - } - - $a_offset = substr($a, 4, 5); - $b_offset = substr($b, 4, 5); - if ($a_offset == $b_offset) - { - $a_name = substr($a, 12); - $b_name = substr($b, 12); - if ($a_name == $b_name) - { - return 0; - } - else if ($a_name == 'UTC') - { - return -1; - } - else if ($b_name == 'UTC') - { - return 1; - } - else - { - return $a_name < $b_name ? -1 : 1; - } - } - else - { - if ($a_sign == '-') - { - return $a_offset > $b_offset ? -1 : 1; - } - else - { - return $a_offset < $b_offset ? -1 : 1; - } - } -} - -/** -* Return list of timezone identifiers -* We also add the selected timezone if we can create an object with it. -* DateTimeZone::listIdentifiers seems to not add all identifiers to the list, -* because some are only kept for backward compatible reasons. If the user has -* a deprecated value, we add it here, so it can still be kept. Once the user -* changed his value, there is no way back to deprecated values. -* -* @param string $selected_timezone Additional timezone that shall -* be added to the list of identiers -* @return array DateTimeZone::listIdentifiers and additional -* selected_timezone if it is a valid timezone. -*/ -function phpbb_get_timezone_identifiers($selected_timezone) -{ - $timezones = DateTimeZone::listIdentifiers(); - - if (!in_array($selected_timezone, $timezones)) - { - try - { - // Add valid timezones that are currently selected but not returned - // by DateTimeZone::listIdentifiers - $validate_timezone = new DateTimeZone($selected_timezone); - $timezones[] = $selected_timezone; - } - catch (\Exception $e) - { - } - } - - return $timezones; -} - -/** -* Options to pick a timezone and date/time -* -* @param \phpbb\template\template $template phpBB template object -* @param \phpbb\user $user Object of the current user -* @param string $default A timezone to select -* @param boolean $truncate Shall we truncate the options text -* -* @return array Returns an array containing the options for the time selector. -*/ -function phpbb_timezone_select($template, $user, $default = '', $truncate = false) -{ - static $timezones; - - $default_offset = ''; - if (!isset($timezones)) - { - $unsorted_timezones = phpbb_get_timezone_identifiers($default); - - $timezones = array(); - foreach ($unsorted_timezones as $timezone) - { - $tz = new DateTimeZone($timezone); - $dt = $user->create_datetime('now', $tz); - $offset = $dt->getOffset(); - $current_time = $dt->format($user->lang['DATETIME_FORMAT'], true); - $offset_string = phpbb_format_timezone_offset($offset, true); - $timezones['UTC' . $offset_string . ' - ' . $timezone] = array( - 'tz' => $timezone, - 'offset' => $offset_string, - 'current' => $current_time, - ); - if ($timezone === $default) - { - $default_offset = 'UTC' . $offset_string; - } - } - unset($unsorted_timezones); - - uksort($timezones, 'phpbb_tz_select_compare'); - } - - $tz_select = $opt_group = ''; - - foreach ($timezones as $key => $timezone) - { - if ($opt_group != $timezone['offset']) - { - // Generate tz_select for backwards compatibility - $tz_select .= ($opt_group) ? '' : ''; - $tz_select .= ''; - $opt_group = $timezone['offset']; - $template->assign_block_vars('timezone_select', array( - 'LABEL' => $user->lang(array('timezones', 'UTC_OFFSET_CURRENT'), $timezone['offset'], $timezone['current']), - 'VALUE' => $key . ' - ' . $timezone['current'], - )); - - $selected = (!empty($default_offset) && strpos($key, $default_offset) !== false) ? ' selected="selected"' : ''; - $template->assign_block_vars('timezone_date', array( - 'VALUE' => $key . ' - ' . $timezone['current'], - 'SELECTED' => !empty($selected), - 'TITLE' => $user->lang(array('timezones', 'UTC_OFFSET_CURRENT'), $timezone['offset'], $timezone['current']), - )); - } - - $label = $timezone['tz']; - if (isset($user->lang['timezones'][$label])) - { - $label = $user->lang['timezones'][$label]; - } - $title = $user->lang(array('timezones', 'UTC_OFFSET_CURRENT'), $timezone['offset'], $label); - - if ($truncate) - { - $label = truncate_string($label, 50, 255, false, '...'); - } - - // Also generate timezone_select for backwards compatibility - $selected = ($timezone['tz'] === $default) ? ' selected="selected"' : ''; - $tz_select .= ''; - $template->assign_block_vars('timezone_select.timezone_options', array( - 'TITLE' => $title, - 'VALUE' => $timezone['tz'], - 'SELECTED' => !empty($selected), - 'LABEL' => $label, - )); - } - $tz_select .= ''; - - return $tz_select; -} - -// Functions handling topic/post tracking/marking - -/** -* Marks a topic/forum as read -* Marks a topic as posted to -* -* @param string $mode (all, topics, topic, post) -* @param int|bool $forum_id Used in all, topics, and topic mode -* @param int|bool $topic_id Used in topic and post mode -* @param int $post_time 0 means current time(), otherwise to set a specific mark time -* @param int $user_id can only be used with $mode == 'post' -*/ -function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $user_id = 0) -{ - global $db, $user, $config; - global $request, $phpbb_container, $phpbb_dispatcher; - - $post_time = ($post_time === 0 || $post_time > time()) ? time() : (int) $post_time; - - $should_markread = true; - - /** - * This event is used for performing actions directly before marking forums, - * topics or posts as read. - * - * It is also possible to prevent the marking. For that, the $should_markread parameter - * should be set to FALSE. - * - * @event core.markread_before - * @var string mode Variable containing marking mode value - * @var mixed forum_id Variable containing forum id, or false - * @var mixed topic_id Variable containing topic id, or false - * @var int post_time Variable containing post time - * @var int user_id Variable containing the user id - * @var bool should_markread Flag indicating if the markread should be done or not. - * @since 3.1.4-RC1 - */ - $vars = array( - 'mode', - 'forum_id', - 'topic_id', - 'post_time', - 'user_id', - 'should_markread', - ); - extract($phpbb_dispatcher->trigger_event('core.markread_before', compact($vars))); - - if (!$should_markread) - { - return; - } - - if ($mode == 'all') - { - if (empty($forum_id)) - { - // Mark all forums read (index page) - /* @var $phpbb_notifications \phpbb\notification\manager */ - $phpbb_notifications = $phpbb_container->get('notification_manager'); - - // Mark all topic notifications read for this user - $phpbb_notifications->mark_notifications(array( - 'notification.type.topic', - 'notification.type.quote', - 'notification.type.bookmark', - 'notification.type.post', - 'notification.type.approve_topic', - 'notification.type.approve_post', - ), false, $user->data['user_id'], $post_time); - - if ($config['load_db_lastread'] && $user->data['is_registered']) - { - // Mark all forums read (index page) - $tables = array(TOPICS_TRACK_TABLE, FORUMS_TRACK_TABLE); - foreach ($tables as $table) - { - $sql = 'DELETE FROM ' . $table . " - WHERE user_id = {$user->data['user_id']} - AND mark_time < $post_time"; - $db->sql_query($sql); - } - - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_lastmark = $post_time - WHERE user_id = {$user->data['user_id']} - AND user_lastmark < $post_time"; - $db->sql_query($sql); - } - else if ($config['load_anon_lastread'] || $user->data['is_registered']) - { - $tracking_topics = $request->variable($config['cookie_name'] . '_track', '', true, \phpbb\request\request_interface::COOKIE); - $tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array(); - - unset($tracking_topics['tf']); - unset($tracking_topics['t']); - unset($tracking_topics['f']); - $tracking_topics['l'] = base_convert($post_time - $config['board_startdate'], 10, 36); - - $user->set_cookie('track', tracking_serialize($tracking_topics), $post_time + 31536000); - $request->overwrite($config['cookie_name'] . '_track', tracking_serialize($tracking_topics), \phpbb\request\request_interface::COOKIE); - - unset($tracking_topics); - - if ($user->data['is_registered']) - { - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_lastmark = $post_time - WHERE user_id = {$user->data['user_id']} - AND user_lastmark < $post_time"; - $db->sql_query($sql); - } - } - } - } - else if ($mode == 'topics') - { - // Mark all topics in forums read - if (!is_array($forum_id)) - { - $forum_id = array($forum_id); - } - else - { - $forum_id = array_unique($forum_id); - } - - /* @var $phpbb_notifications \phpbb\notification\manager */ - $phpbb_notifications = $phpbb_container->get('notification_manager'); - - $phpbb_notifications->mark_notifications_by_parent(array( - 'notification.type.topic', - 'notification.type.approve_topic', - ), $forum_id, $user->data['user_id'], $post_time); - - // Mark all post/quote notifications read for this user in this forum - $topic_ids = array(); - $sql = 'SELECT topic_id - FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $forum_id); - $result = $db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) - { - $topic_ids[] = $row['topic_id']; - } - $db->sql_freeresult($result); - - $phpbb_notifications->mark_notifications_by_parent(array( - 'notification.type.quote', - 'notification.type.bookmark', - 'notification.type.post', - 'notification.type.approve_post', - ), $topic_ids, $user->data['user_id'], $post_time); - - // Add 0 to forums array to mark global announcements correctly - // $forum_id[] = 0; - - if ($config['load_db_lastread'] && $user->data['is_registered']) - { - $sql = 'DELETE FROM ' . TOPICS_TRACK_TABLE . " - WHERE user_id = {$user->data['user_id']} - AND mark_time < $post_time - AND " . $db->sql_in_set('forum_id', $forum_id); - $db->sql_query($sql); - - $sql = 'SELECT forum_id - FROM ' . FORUMS_TRACK_TABLE . " - WHERE user_id = {$user->data['user_id']} - AND " . $db->sql_in_set('forum_id', $forum_id); - $result = $db->sql_query($sql); - - $sql_update = array(); - while ($row = $db->sql_fetchrow($result)) - { - $sql_update[] = (int) $row['forum_id']; - } - $db->sql_freeresult($result); - - if (count($sql_update)) - { - $sql = 'UPDATE ' . FORUMS_TRACK_TABLE . " - SET mark_time = $post_time - WHERE user_id = {$user->data['user_id']} - AND mark_time < $post_time - AND " . $db->sql_in_set('forum_id', $sql_update); - $db->sql_query($sql); - } - - if ($sql_insert = array_diff($forum_id, $sql_update)) - { - $sql_ary = array(); - foreach ($sql_insert as $f_id) - { - $sql_ary[] = array( - 'user_id' => (int) $user->data['user_id'], - 'forum_id' => (int) $f_id, - 'mark_time' => $post_time, - ); - } - - $db->sql_multi_insert(FORUMS_TRACK_TABLE, $sql_ary); - } - } - else if ($config['load_anon_lastread'] || $user->data['is_registered']) - { - $tracking = $request->variable($config['cookie_name'] . '_track', '', true, \phpbb\request\request_interface::COOKIE); - $tracking = ($tracking) ? tracking_unserialize($tracking) : array(); - - foreach ($forum_id as $f_id) - { - $topic_ids36 = (isset($tracking['tf'][$f_id])) ? $tracking['tf'][$f_id] : array(); - - if (isset($tracking['tf'][$f_id])) - { - unset($tracking['tf'][$f_id]); - } - - foreach ($topic_ids36 as $topic_id36) - { - unset($tracking['t'][$topic_id36]); - } - - if (isset($tracking['f'][$f_id])) - { - unset($tracking['f'][$f_id]); - } - - $tracking['f'][$f_id] = base_convert($post_time - $config['board_startdate'], 10, 36); - } - - if (isset($tracking['tf']) && empty($tracking['tf'])) - { - unset($tracking['tf']); - } - - $user->set_cookie('track', tracking_serialize($tracking), $post_time + 31536000); - $request->overwrite($config['cookie_name'] . '_track', tracking_serialize($tracking), \phpbb\request\request_interface::COOKIE); - - unset($tracking); - } - } - else if ($mode == 'topic') - { - if ($topic_id === false || $forum_id === false) - { - return; - } - - /* @var $phpbb_notifications \phpbb\notification\manager */ - $phpbb_notifications = $phpbb_container->get('notification_manager'); - - // Mark post notifications read for this user in this topic - $phpbb_notifications->mark_notifications(array( - 'notification.type.topic', - 'notification.type.approve_topic', - ), $topic_id, $user->data['user_id'], $post_time); - - $phpbb_notifications->mark_notifications_by_parent(array( - 'notification.type.quote', - 'notification.type.bookmark', - 'notification.type.post', - 'notification.type.approve_post', - ), $topic_id, $user->data['user_id'], $post_time); - - if ($config['load_db_lastread'] && $user->data['is_registered']) - { - $sql = 'UPDATE ' . TOPICS_TRACK_TABLE . " - SET mark_time = $post_time - WHERE user_id = {$user->data['user_id']} - AND mark_time < $post_time - AND topic_id = $topic_id"; - $db->sql_query($sql); - - // insert row - if (!$db->sql_affectedrows()) - { - $db->sql_return_on_error(true); - - $sql_ary = array( - 'user_id' => (int) $user->data['user_id'], - 'topic_id' => (int) $topic_id, - 'forum_id' => (int) $forum_id, - 'mark_time' => $post_time, - ); - - $db->sql_query('INSERT INTO ' . TOPICS_TRACK_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); - - $db->sql_return_on_error(false); - } - } - else if ($config['load_anon_lastread'] || $user->data['is_registered']) - { - $tracking = $request->variable($config['cookie_name'] . '_track', '', true, \phpbb\request\request_interface::COOKIE); - $tracking = ($tracking) ? tracking_unserialize($tracking) : array(); - - $topic_id36 = base_convert($topic_id, 10, 36); - - if (!isset($tracking['t'][$topic_id36])) - { - $tracking['tf'][$forum_id][$topic_id36] = true; - } - - $tracking['t'][$topic_id36] = base_convert($post_time - (int) $config['board_startdate'], 10, 36); - - // If the cookie grows larger than 10000 characters we will remove the smallest value - // This can result in old topics being unread - but most of the time it should be accurate... - if (strlen($request->variable($config['cookie_name'] . '_track', '', true, \phpbb\request\request_interface::COOKIE)) > 10000) - { - //echo 'Cookie grown too large' . print_r($tracking, true); - - // We get the ten most minimum stored time offsets and its associated topic ids - $time_keys = array(); - for ($i = 0; $i < 10 && count($tracking['t']); $i++) - { - $min_value = min($tracking['t']); - $m_tkey = array_search($min_value, $tracking['t']); - unset($tracking['t'][$m_tkey]); - - $time_keys[$m_tkey] = $min_value; - } - - // Now remove the topic ids from the array... - foreach ($tracking['tf'] as $f_id => $topic_id_ary) - { - foreach ($time_keys as $m_tkey => $min_value) - { - if (isset($topic_id_ary[$m_tkey])) - { - $tracking['f'][$f_id] = $min_value; - unset($tracking['tf'][$f_id][$m_tkey]); - } - } - } - - if ($user->data['is_registered']) - { - $user->data['user_lastmark'] = intval(base_convert(max($time_keys) + $config['board_startdate'], 36, 10)); - - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_lastmark = $post_time - WHERE user_id = {$user->data['user_id']} - AND mark_time < $post_time"; - $db->sql_query($sql); - } - else - { - $tracking['l'] = max($time_keys); - } - } - - $user->set_cookie('track', tracking_serialize($tracking), $post_time + 31536000); - $request->overwrite($config['cookie_name'] . '_track', tracking_serialize($tracking), \phpbb\request\request_interface::COOKIE); - } - } - else if ($mode == 'post') - { - if ($topic_id === false) - { - return; - } - - $use_user_id = (!$user_id) ? $user->data['user_id'] : $user_id; - - if ($config['load_db_track'] && $use_user_id != ANONYMOUS) - { - $db->sql_return_on_error(true); - - $sql_ary = array( - 'user_id' => (int) $use_user_id, - 'topic_id' => (int) $topic_id, - 'topic_posted' => 1, - ); - - $db->sql_query('INSERT INTO ' . TOPICS_POSTED_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); - - $db->sql_return_on_error(false); - } - } - - /** - * This event is used for performing actions directly after forums, - * topics or posts have been marked as read. - * - * @event core.markread_after - * @var string mode Variable containing marking mode value - * @var mixed forum_id Variable containing forum id, or false - * @var mixed topic_id Variable containing topic id, or false - * @var int post_time Variable containing post time - * @var int user_id Variable containing the user id - * @since 3.2.6-RC1 - */ - $vars = array( - 'mode', - 'forum_id', - 'topic_id', - 'post_time', - 'user_id', - ); - extract($phpbb_dispatcher->trigger_event('core.markread_after', compact($vars))); -} - -/** -* Get topic tracking info by using already fetched info -*/ -function get_topic_tracking($forum_id, $topic_ids, &$rowset, $forum_mark_time, $global_announce_list = false) -{ - global $user; - - $last_read = array(); - - if (!is_array($topic_ids)) - { - $topic_ids = array($topic_ids); - } - - foreach ($topic_ids as $topic_id) - { - if (!empty($rowset[$topic_id]['mark_time'])) - { - $last_read[$topic_id] = $rowset[$topic_id]['mark_time']; - } - } - - $topic_ids = array_diff($topic_ids, array_keys($last_read)); - - if (count($topic_ids)) - { - $mark_time = array(); - - if (!empty($forum_mark_time[$forum_id]) && $forum_mark_time[$forum_id] !== false) - { - $mark_time[$forum_id] = $forum_mark_time[$forum_id]; - } - - $user_lastmark = (isset($mark_time[$forum_id])) ? $mark_time[$forum_id] : $user->data['user_lastmark']; - - foreach ($topic_ids as $topic_id) - { - $last_read[$topic_id] = $user_lastmark; - } - } - - return $last_read; -} - -/** -* Get topic tracking info from db (for cookie based tracking only this function is used) -*/ -function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_list = false) -{ - global $config, $user, $request; - - $last_read = array(); - - if (!is_array($topic_ids)) - { - $topic_ids = array($topic_ids); - } - - if ($config['load_db_lastread'] && $user->data['is_registered']) - { - global $db; - - $sql = 'SELECT topic_id, mark_time - FROM ' . TOPICS_TRACK_TABLE . " - WHERE user_id = {$user->data['user_id']} - AND " . $db->sql_in_set('topic_id', $topic_ids); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $last_read[$row['topic_id']] = $row['mark_time']; - } - $db->sql_freeresult($result); - - $topic_ids = array_diff($topic_ids, array_keys($last_read)); - - if (count($topic_ids)) - { - $sql = 'SELECT forum_id, mark_time - FROM ' . FORUMS_TRACK_TABLE . " - WHERE user_id = {$user->data['user_id']} - AND forum_id = $forum_id"; - $result = $db->sql_query($sql); - - $mark_time = array(); - while ($row = $db->sql_fetchrow($result)) - { - $mark_time[$row['forum_id']] = $row['mark_time']; - } - $db->sql_freeresult($result); - - $user_lastmark = (isset($mark_time[$forum_id])) ? $mark_time[$forum_id] : $user->data['user_lastmark']; - - foreach ($topic_ids as $topic_id) - { - $last_read[$topic_id] = $user_lastmark; - } - } - } - else if ($config['load_anon_lastread'] || $user->data['is_registered']) - { - global $tracking_topics; - - if (!isset($tracking_topics) || !count($tracking_topics)) - { - $tracking_topics = $request->variable($config['cookie_name'] . '_track', '', true, \phpbb\request\request_interface::COOKIE); - $tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array(); - } - - if (!$user->data['is_registered']) - { - $user_lastmark = (isset($tracking_topics['l'])) ? base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate'] : 0; - } - else - { - $user_lastmark = $user->data['user_lastmark']; - } - - foreach ($topic_ids as $topic_id) - { - $topic_id36 = base_convert($topic_id, 10, 36); - - if (isset($tracking_topics['t'][$topic_id36])) - { - $last_read[$topic_id] = base_convert($tracking_topics['t'][$topic_id36], 36, 10) + $config['board_startdate']; - } - } - - $topic_ids = array_diff($topic_ids, array_keys($last_read)); - - if (count($topic_ids)) - { - $mark_time = array(); - - if (isset($tracking_topics['f'][$forum_id])) - { - $mark_time[$forum_id] = base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate']; - } - - $user_lastmark = (isset($mark_time[$forum_id])) ? $mark_time[$forum_id] : $user_lastmark; - - foreach ($topic_ids as $topic_id) - { - $last_read[$topic_id] = $user_lastmark; - } - } - } - - return $last_read; -} - -/** -* Get list of unread topics -* -* @param int $user_id User ID (or false for current user) -* @param string $sql_extra Extra WHERE SQL statement -* @param string $sql_sort ORDER BY SQL sorting statement -* @param string $sql_limit Limits the size of unread topics list, 0 for unlimited query -* @param string $sql_limit_offset Sets the offset of the first row to search, 0 to search from the start -* -* @return array[int][int] Topic ids as keys, mark_time of topic as value -*/ -function get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $sql_limit = 1001, $sql_limit_offset = 0) -{ - global $config, $db, $user, $request; - global $phpbb_dispatcher; - - $user_id = ($user_id === false) ? (int) $user->data['user_id'] : (int) $user_id; - - // Data array we're going to return - $unread_topics = array(); - - if (empty($sql_sort)) - { - $sql_sort = 'ORDER BY t.topic_last_post_time DESC, t.topic_last_post_id DESC'; - } - - if ($config['load_db_lastread'] && $user->data['is_registered']) - { - // Get list of the unread topics - $last_mark = (int) $user->data['user_lastmark']; - - $sql_array = array( - 'SELECT' => 't.topic_id, t.topic_last_post_time, tt.mark_time as topic_mark_time, ft.mark_time as forum_mark_time', - - 'FROM' => array(TOPICS_TABLE => 't'), - - 'LEFT_JOIN' => array( - array( - 'FROM' => array(TOPICS_TRACK_TABLE => 'tt'), - 'ON' => "tt.user_id = $user_id AND t.topic_id = tt.topic_id", - ), - array( - 'FROM' => array(FORUMS_TRACK_TABLE => 'ft'), - 'ON' => "ft.user_id = $user_id AND t.forum_id = ft.forum_id", - ), - ), - - 'WHERE' => " - t.topic_last_post_time > $last_mark AND - ( - (tt.mark_time IS NOT NULL AND t.topic_last_post_time > tt.mark_time) OR - (tt.mark_time IS NULL AND ft.mark_time IS NOT NULL AND t.topic_last_post_time > ft.mark_time) OR - (tt.mark_time IS NULL AND ft.mark_time IS NULL) - ) - $sql_extra - $sql_sort", - ); - - /** - * Change SQL query for fetching unread topics data - * - * @event core.get_unread_topics_modify_sql - * @var array sql_array Fully assembled SQL query with keys SELECT, FROM, LEFT_JOIN, WHERE - * @var int last_mark User's last_mark time - * @var string sql_extra Extra WHERE SQL statement - * @var string sql_sort ORDER BY SQL sorting statement - * @since 3.1.4-RC1 - */ - $vars = array( - 'sql_array', - 'last_mark', - 'sql_extra', - 'sql_sort', - ); - extract($phpbb_dispatcher->trigger_event('core.get_unread_topics_modify_sql', compact($vars))); - - $sql = $db->sql_build_query('SELECT', $sql_array); - $result = $db->sql_query_limit($sql, $sql_limit, $sql_limit_offset); - - while ($row = $db->sql_fetchrow($result)) - { - $topic_id = (int) $row['topic_id']; - $unread_topics[$topic_id] = ($row['topic_mark_time']) ? (int) $row['topic_mark_time'] : (($row['forum_mark_time']) ? (int) $row['forum_mark_time'] : $last_mark); - } - $db->sql_freeresult($result); - } - else if ($config['load_anon_lastread'] || $user->data['is_registered']) - { - global $tracking_topics; - - if (empty($tracking_topics)) - { - $tracking_topics = $request->variable($config['cookie_name'] . '_track', '', false, \phpbb\request\request_interface::COOKIE); - $tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array(); - } - - if (!$user->data['is_registered']) - { - $user_lastmark = (isset($tracking_topics['l'])) ? base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate'] : 0; - } - else - { - $user_lastmark = (int) $user->data['user_lastmark']; - } - - $sql = 'SELECT t.topic_id, t.forum_id, t.topic_last_post_time - FROM ' . TOPICS_TABLE . ' t - WHERE t.topic_last_post_time > ' . $user_lastmark . " - $sql_extra - $sql_sort"; - $result = $db->sql_query_limit($sql, $sql_limit, $sql_limit_offset); - - while ($row = $db->sql_fetchrow($result)) - { - $forum_id = (int) $row['forum_id']; - $topic_id = (int) $row['topic_id']; - $topic_id36 = base_convert($topic_id, 10, 36); - - if (isset($tracking_topics['t'][$topic_id36])) - { - $last_read = base_convert($tracking_topics['t'][$topic_id36], 36, 10) + $config['board_startdate']; - - if ($row['topic_last_post_time'] > $last_read) - { - $unread_topics[$topic_id] = $last_read; - } - } - else if (isset($tracking_topics['f'][$forum_id])) - { - $mark_time = base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate']; - - if ($row['topic_last_post_time'] > $mark_time) - { - $unread_topics[$topic_id] = $mark_time; - } - } - else - { - $unread_topics[$topic_id] = $user_lastmark; - } - } - $db->sql_freeresult($result); - } - - return $unread_topics; -} - -/** -* Check for read forums and update topic tracking info accordingly -* -* @param int $forum_id the forum id to check -* @param int $forum_last_post_time the forums last post time -* @param int $f_mark_time the forums last mark time if user is registered and load_db_lastread enabled -* @param int $mark_time_forum false if the mark time needs to be obtained, else the last users forum mark time -* -* @return true if complete forum got marked read, else false. -*/ -function update_forum_tracking_info($forum_id, $forum_last_post_time, $f_mark_time = false, $mark_time_forum = false) -{ - global $db, $tracking_topics, $user, $config, $request, $phpbb_container; - - // Determine the users last forum mark time if not given. - if ($mark_time_forum === false) - { - if ($config['load_db_lastread'] && $user->data['is_registered']) - { - $mark_time_forum = (!empty($f_mark_time)) ? $f_mark_time : $user->data['user_lastmark']; - } - else if ($config['load_anon_lastread'] || $user->data['is_registered']) - { - $tracking_topics = $request->variable($config['cookie_name'] . '_track', '', true, \phpbb\request\request_interface::COOKIE); - $tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array(); - - if (!$user->data['is_registered']) - { - $user->data['user_lastmark'] = (isset($tracking_topics['l'])) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0; - } - - $mark_time_forum = (isset($tracking_topics['f'][$forum_id])) ? (int) (base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate']) : $user->data['user_lastmark']; - } - } - - // Handle update of unapproved topics info. - // Only update for moderators having m_approve permission for the forum. - /* @var $phpbb_content_visibility \phpbb\content_visibility */ - $phpbb_content_visibility = $phpbb_container->get('content.visibility'); - - // Check the forum for any left unread topics. - // If there are none, we mark the forum as read. - if ($config['load_db_lastread'] && $user->data['is_registered']) - { - if ($mark_time_forum >= $forum_last_post_time) - { - // We do not need to mark read, this happened before. Therefore setting this to true - $row = true; - } - else - { - $sql = 'SELECT t.forum_id - FROM ' . TOPICS_TABLE . ' t - LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt - ON (tt.topic_id = t.topic_id - AND tt.user_id = ' . $user->data['user_id'] . ') - WHERE t.forum_id = ' . $forum_id . ' - AND t.topic_last_post_time > ' . $mark_time_forum . ' - AND t.topic_moved_id = 0 - AND ' . $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.') . ' - AND (tt.topic_id IS NULL - OR tt.mark_time < t.topic_last_post_time)'; - $result = $db->sql_query_limit($sql, 1); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - } - } - else if ($config['load_anon_lastread'] || $user->data['is_registered']) - { - // Get information from cookie - if (!isset($tracking_topics['tf'][$forum_id])) - { - // We do not need to mark read, this happened before. Therefore setting this to true - $row = true; - } - else - { - $sql = 'SELECT t.topic_id - FROM ' . TOPICS_TABLE . ' t - WHERE t.forum_id = ' . $forum_id . ' - AND t.topic_last_post_time > ' . $mark_time_forum . ' - AND t.topic_moved_id = 0 - AND ' . $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.'); - $result = $db->sql_query($sql); - - $check_forum = $tracking_topics['tf'][$forum_id]; - $unread = false; - - while ($row = $db->sql_fetchrow($result)) - { - if (!isset($check_forum[base_convert($row['topic_id'], 10, 36)])) - { - $unread = true; - break; - } - } - $db->sql_freeresult($result); - - $row = $unread; - } - } - else - { - $row = true; - } - - if (!$row) - { - markread('topics', $forum_id); - return true; - } - - return false; -} - -/** -* Transform an array into a serialized format -*/ -function tracking_serialize($input) -{ - $out = ''; - foreach ($input as $key => $value) - { - if (is_array($value)) - { - $out .= $key . ':(' . tracking_serialize($value) . ');'; - } - else - { - $out .= $key . ':' . $value . ';'; - } - } - return $out; -} - -/** -* Transform a serialized array into an actual array -*/ -function tracking_unserialize($string, $max_depth = 3) -{ - $n = strlen($string); - if ($n > 10010) - { - die('Invalid data supplied'); - } - $data = $stack = array(); - $key = ''; - $mode = 0; - $level = &$data; - for ($i = 0; $i < $n; ++$i) - { - switch ($mode) - { - case 0: - switch ($string[$i]) - { - case ':': - $level[$key] = 0; - $mode = 1; - break; - case ')': - unset($level); - $level = array_pop($stack); - $mode = 3; - break; - default: - $key .= $string[$i]; - } - break; - - case 1: - switch ($string[$i]) - { - case '(': - if (count($stack) >= $max_depth) - { - die('Invalid data supplied'); - } - $stack[] = &$level; - $level[$key] = array(); - $level = &$level[$key]; - $key = ''; - $mode = 0; - break; - default: - $level[$key] = $string[$i]; - $mode = 2; - break; - } - break; - - case 2: - switch ($string[$i]) - { - case ')': - unset($level); - $level = array_pop($stack); - $mode = 3; - break; - case ';': - $key = ''; - $mode = 0; - break; - default: - $level[$key] .= $string[$i]; - break; - } - break; - - case 3: - switch ($string[$i]) - { - case ')': - unset($level); - $level = array_pop($stack); - break; - case ';': - $key = ''; - $mode = 0; - break; - default: - die('Invalid data supplied'); - break; - } - break; - } - } - - if (count($stack) != 0 || ($mode != 0 && $mode != 3)) - { - die('Invalid data supplied'); - } - - return $level; -} - -// Server functions (building urls, redirecting...) - -/** -* Append session id to url. -* This function supports hooks. -* -* @param string $url The url the session id needs to be appended to (can have params) -* @param mixed $params String or array of additional url parameters -* @param bool $is_amp Is url using & (true) or & (false) -* @param string $session_id Possibility to use a custom session id instead of the global one -* @param bool $is_route Is url generated by a route. -* -* @return string The corrected url. -* -* Examples: -* -* append_sid("{$phpbb_root_path}viewtopic.$phpEx?t=1&f=2"); -* append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=1&f=2'); -* append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=1&f=2', false); -* append_sid("{$phpbb_root_path}viewtopic.$phpEx", array('t' => 1, 'f' => 2)); -* -* -*/ -function append_sid($url, $params = false, $is_amp = true, $session_id = false, $is_route = false) -{ - global $_SID, $_EXTRA_URL, $phpbb_hook, $phpbb_path_helper; - global $phpbb_dispatcher; - - if ($params === '' || (is_array($params) && empty($params))) - { - // Do not append the ? if the param-list is empty anyway. - $params = false; - } - - // Update the root path with the correct relative web path - if (!$is_route && $phpbb_path_helper instanceof \phpbb\path_helper) - { - $url = $phpbb_path_helper->update_web_root_path($url); - } - - $append_sid_overwrite = false; - - /** - * This event can either supplement or override the append_sid() function - * - * To override this function, the event must set $append_sid_overwrite to - * the new URL value, which will be returned following the event - * - * @event core.append_sid - * @var string url The url the session id needs - * to be appended to (can have - * params) - * @var mixed params String or array of additional - * url parameters - * @var bool is_amp Is url using & (true) or - * & (false) - * @var bool|string session_id Possibility to use a custom - * session id (string) instead of - * the global one (false) - * @var bool|string append_sid_overwrite Overwrite function (string - * URL) or not (false) - * @var bool is_route Is url generated by a route. - * @since 3.1.0-a1 - */ - $vars = array('url', 'params', 'is_amp', 'session_id', 'append_sid_overwrite', 'is_route'); - extract($phpbb_dispatcher->trigger_event('core.append_sid', compact($vars))); - - if ($append_sid_overwrite) - { - return $append_sid_overwrite; - } - - // The following hook remains for backwards compatibility, though use of - // the event above is preferred. - // Developers using the hook function need to globalise the $_SID and $_EXTRA_URL on their own and also handle it appropriately. - // They could mimic most of what is within this function - if (!empty($phpbb_hook) && $phpbb_hook->call_hook(__FUNCTION__, $url, $params, $is_amp, $session_id)) - { - if ($phpbb_hook->hook_return(__FUNCTION__)) - { - return $phpbb_hook->hook_return_result(__FUNCTION__); - } - } - - $params_is_array = is_array($params); - - // Get anchor - $anchor = ''; - if (strpos($url, '#') !== false) - { - list($url, $anchor) = explode('#', $url, 2); - $anchor = '#' . $anchor; - } - else if (!$params_is_array && strpos($params, '#') !== false) - { - list($params, $anchor) = explode('#', $params, 2); - $anchor = '#' . $anchor; - } - - // Handle really simple cases quickly - if ($_SID == '' && $session_id === false && empty($_EXTRA_URL) && !$params_is_array && !$anchor) - { - if ($params === false) - { - return $url; - } - - $url_delim = (strpos($url, '?') === false) ? '?' : (($is_amp) ? '&' : '&'); - return $url . ($params !== false ? $url_delim. $params : ''); - } - - // Assign sid if session id is not specified - if ($session_id === false) - { - $session_id = $_SID; - } - - $amp_delim = ($is_amp) ? '&' : '&'; - $url_delim = (strpos($url, '?') === false) ? '?' : $amp_delim; - - // Appending custom url parameter? - $append_url = (!empty($_EXTRA_URL)) ? implode($amp_delim, $_EXTRA_URL) : ''; - - // Use the short variant if possible ;) - if ($params === false) - { - // Append session id - if (!$session_id) - { - return $url . (($append_url) ? $url_delim . $append_url : '') . $anchor; - } - else - { - return $url . (($append_url) ? $url_delim . $append_url . $amp_delim : $url_delim) . 'sid=' . $session_id . $anchor; - } - } - - // Build string if parameters are specified as array - if (is_array($params)) - { - $output = array(); - - foreach ($params as $key => $item) - { - if ($item === NULL) - { - continue; - } - - if ($key == '#') - { - $anchor = '#' . $item; - continue; - } - - $output[] = $key . '=' . $item; - } - - $params = implode($amp_delim, $output); - } - - // Append session id and parameters (even if they are empty) - // If parameters are empty, the developer can still append his/her parameters without caring about the delimiter - return $url . (($append_url) ? $url_delim . $append_url . $amp_delim : $url_delim) . $params . ((!$session_id) ? '' : $amp_delim . 'sid=' . $session_id) . $anchor; -} - -/** -* Generate board url (example: http://www.example.com/phpBB) -* -* @param bool $without_script_path if set to true the script path gets not appended (example: http://www.example.com) -* -* @return string the generated board url -*/ -function generate_board_url($without_script_path = false) -{ - global $config, $user, $request, $symfony_request; - - $server_name = $user->host; - - // Forcing server vars is the only way to specify/override the protocol - if ($config['force_server_vars'] || !$server_name) - { - $server_protocol = ($config['server_protocol']) ? $config['server_protocol'] : (($config['cookie_secure']) ? 'https://' : 'http://'); - $server_name = $config['server_name']; - $server_port = (int) $config['server_port']; - $script_path = $config['script_path']; - - $url = $server_protocol . $server_name; - $cookie_secure = $config['cookie_secure']; - } - else - { - $server_port = (int) $symfony_request->getPort(); - - $forwarded_proto = $request->server('HTTP_X_FORWARDED_PROTO'); - - if (!empty($forwarded_proto) && $forwarded_proto === 'https') - { - $server_port = 443; - } - // Do not rely on cookie_secure, users seem to think that it means a secured cookie instead of an encrypted connection - $cookie_secure = $request->is_secure() ? 1 : 0; - $url = (($cookie_secure) ? 'https://' : 'http://') . $server_name; - - $script_path = $user->page['root_script_path']; - } - - if ($server_port && (($cookie_secure && $server_port <> 443) || (!$cookie_secure && $server_port <> 80))) - { - // HTTP HOST can carry a port number (we fetch $user->host, but for old versions this may be true) - if (strpos($server_name, ':') === false) - { - $url .= ':' . $server_port; - } - } - - if (!$without_script_path) - { - $url .= $script_path; - } - - // Strip / from the end - if (substr($url, -1, 1) == '/') - { - $url = substr($url, 0, -1); - } - - return $url; -} - -/** -* Redirects the user to another page then exits the script nicely -* This function is intended for urls within the board. It's not meant to redirect to cross-domains. -* -* @param string $url The url to redirect to -* @param bool $return If true, do not redirect but return the sanitized URL. Default is no return. -* @param bool $disable_cd_check If true, redirect() will redirect to an external domain. If false, the redirect point to the boards url if it does not match the current domain. Default is false. -*/ -function redirect($url, $return = false, $disable_cd_check = false) -{ - global $user, $phpbb_path_helper, $phpbb_dispatcher; - - if (!$user->is_setup()) - { - $user->add_lang('common'); - } - - // Make sure no &'s are in, this will break the redirect - $url = str_replace('&', '&', $url); - - // Determine which type of redirect we need to handle... - $url_parts = @parse_url($url); - - if ($url_parts === false) - { - // Malformed url - trigger_error('INSECURE_REDIRECT', E_USER_WARNING); - } - else if (!empty($url_parts['scheme']) && !empty($url_parts['host'])) - { - // Attention: only able to redirect within the same domain if $disable_cd_check is false (yourdomain.com -> www.yourdomain.com will not work) - if (!$disable_cd_check && $url_parts['host'] !== $user->host) - { - trigger_error('INSECURE_REDIRECT', E_USER_WARNING); - } - } - else if ($url[0] == '/') - { - // Absolute uri, prepend direct url... - $url = generate_board_url(true) . $url; - } - else - { - // Relative uri - $pathinfo = pathinfo($url); - - // Is the uri pointing to the current directory? - if ($pathinfo['dirname'] == '.') - { - $url = str_replace('./', '', $url); - - // Strip / from the beginning - if ($url && substr($url, 0, 1) == '/') - { - $url = substr($url, 1); - } - } - - $url = $phpbb_path_helper->remove_web_root_path($url); - - if ($user->page['page_dir']) - { - $url = $user->page['page_dir'] . '/' . $url; - } - - $url = generate_board_url() . '/' . $url; - } - - // Clean URL and check if we go outside the forum directory - $url = $phpbb_path_helper->clean_url($url); - - if (!$disable_cd_check && strpos($url, generate_board_url(true) . '/') !== 0) - { - trigger_error('INSECURE_REDIRECT', E_USER_WARNING); - } - - // Make sure no linebreaks are there... to prevent http response splitting for PHP < 4.4.2 - if (strpos(urldecode($url), "\n") !== false || strpos(urldecode($url), "\r") !== false || strpos($url, ';') !== false) - { - trigger_error('INSECURE_REDIRECT', E_USER_WARNING); - } - - // Now, also check the protocol and for a valid url the last time... - $allowed_protocols = array('http', 'https', 'ftp', 'ftps'); - $url_parts = parse_url($url); - - if ($url_parts === false || empty($url_parts['scheme']) || !in_array($url_parts['scheme'], $allowed_protocols)) - { - trigger_error('INSECURE_REDIRECT', E_USER_WARNING); - } - - /** - * Execute code and/or overwrite redirect() - * - * @event core.functions.redirect - * @var string url The url - * @var bool return If true, do not redirect but return the sanitized URL. - * @var bool disable_cd_check If true, redirect() will redirect to an external domain. If false, the redirect point to the boards url if it does not match the current domain. - * @since 3.1.0-RC3 - */ - $vars = array('url', 'return', 'disable_cd_check'); - extract($phpbb_dispatcher->trigger_event('core.functions.redirect', compact($vars))); - - if ($return) - { - return $url; - } - else - { - garbage_collection(); - } - - // Redirect via an HTML form for PITA webservers - if (@preg_match('#WebSTAR|Xitami#', getenv('SERVER_SOFTWARE'))) - { - header('Refresh: 0; URL=' . $url); - - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo '' . $user->lang['REDIRECT'] . ''; - echo ''; - echo ''; - echo '
' . sprintf($user->lang['URL_REDIRECT'], '', '') . '
'; - echo ''; - echo ''; - - exit; - } - - // Behave as per HTTP/1.1 spec for others - header('Location: ' . $url); - exit; -} - -/** -* Re-Apply session id after page reloads -*/ -function reapply_sid($url, $is_route = false) -{ - global $phpEx, $phpbb_root_path; - - if ($url === "index.$phpEx") - { - return append_sid("index.$phpEx"); - } - else if ($url === "{$phpbb_root_path}index.$phpEx") - { - return append_sid("{$phpbb_root_path}index.$phpEx"); - } - - // Remove previously added sid - if (strpos($url, 'sid=') !== false) - { - // All kind of links - $url = preg_replace('/(\?)?(&|&)?sid=[a-z0-9]+/', '', $url); - // if the sid was the first param, make the old second as first ones - $url = preg_replace("/$phpEx(&|&)+?/", "$phpEx?", $url); - } - - return append_sid($url, false, true, false, $is_route); -} - -/** -* Returns url from the session/current page with an re-appended SID with optionally stripping vars from the url -*/ -function build_url($strip_vars = false) -{ - global $config, $user, $phpbb_path_helper; - - $page = $phpbb_path_helper->get_valid_page($user->page['page'], $config['enable_mod_rewrite']); - - // Append SID - $redirect = append_sid($page, false, false); - - if ($strip_vars !== false) - { - $redirect = $phpbb_path_helper->strip_url_params($redirect, $strip_vars, false); - } - else - { - $redirect = str_replace('&', '&', $redirect); - } - - return $redirect . ((strpos($redirect, '?') === false) ? '?' : ''); -} - -/** -* Meta refresh assignment -* Adds META template variable with meta http tag. -* -* @param int $time Time in seconds for meta refresh tag -* @param string $url URL to redirect to. The url will go through redirect() first before the template variable is assigned -* @param bool $disable_cd_check If true, meta_refresh() will redirect to an external domain. If false, the redirect point to the boards url if it does not match the current domain. Default is false. -*/ -function meta_refresh($time, $url, $disable_cd_check = false) -{ - global $template, $refresh_data, $request; - - $url = redirect($url, true, $disable_cd_check); - if ($request->is_ajax()) - { - $refresh_data = array( - 'time' => $time, - 'url' => $url, - ); - } - else - { - // For XHTML compatibility we change back & to & - $url = str_replace('&', '&', $url); - - $template->assign_vars(array( - 'META' => '') - ); - } - - return $url; -} - -/** -* Outputs correct status line header. -* -* Depending on php sapi one of the two following forms is used: -* -* Status: 404 Not Found -* -* HTTP/1.x 404 Not Found -* -* HTTP version is taken from HTTP_VERSION environment variable, -* and defaults to 1.0. -* -* Sample usage: -* -* send_status_line(404, 'Not Found'); -* -* @param int $code HTTP status code -* @param string $message Message for the status code -* @return null -*/ -function send_status_line($code, $message) -{ - if (substr(strtolower(@php_sapi_name()), 0, 3) === 'cgi') - { - // in theory, we shouldn't need that due to php doing it. Reality offers a differing opinion, though - header("Status: $code $message", true, $code); - } - else - { - $version = phpbb_request_http_version(); - header("$version $code $message", true, $code); - } -} - -/** -* Returns the HTTP version used in the current request. -* -* Handles the case of being called before $request is present, -* in which case it falls back to the $_SERVER superglobal. -* -* @return string HTTP version -*/ -function phpbb_request_http_version() -{ - global $request; - - $version = ''; - if ($request && $request->server('SERVER_PROTOCOL')) - { - $version = $request->server('SERVER_PROTOCOL'); - } - else if (isset($_SERVER['SERVER_PROTOCOL'])) - { - $version = $_SERVER['SERVER_PROTOCOL']; - } - - if (!empty($version) && is_string($version) && preg_match('#^HTTP/[0-9]\.[0-9]$#', $version)) - { - return $version; - } - - return 'HTTP/1.0'; -} - -//Form validation - - -/** -* Add a secret hash for use in links/GET requests -* @param string $link_name The name of the link; has to match the name used in check_link_hash, otherwise no restrictions apply -* @return string the hash - -*/ -function generate_link_hash($link_name) -{ - global $user; - - if (!isset($user->data["hash_$link_name"])) - { - $user->data["hash_$link_name"] = substr(sha1($user->data['user_form_salt'] . $link_name), 0, 8); - } - - return $user->data["hash_$link_name"]; -} - - -/** -* checks a link hash - for GET requests -* @param string $token the submitted token -* @param string $link_name The name of the link -* @return boolean true if all is fine -*/ -function check_link_hash($token, $link_name) -{ - return $token === generate_link_hash($link_name); -} - -/** -* Add a secret token to the form (requires the S_FORM_TOKEN template variable) -* @param string $form_name The name of the form; has to match the name used in check_form_key, otherwise no restrictions apply -* @param string $template_variable_suffix A string that is appended to the name of the template variable to which the form elements are assigned -*/ -function add_form_key($form_name, $template_variable_suffix = '') -{ - global $config, $template, $user, $phpbb_dispatcher; - - $now = time(); - $token_sid = ($user->data['user_id'] == ANONYMOUS && !empty($config['form_token_sid_guests'])) ? $user->session_id : ''; - $token = sha1($now . $user->data['user_form_salt'] . $form_name . $token_sid); - - $s_fields = build_hidden_fields(array( - 'creation_time' => $now, - 'form_token' => $token, - )); - - /** - * Perform additional actions on creation of the form token - * - * @event core.add_form_key - * @var string form_name The form name - * @var int now Current time timestamp - * @var string s_fields Generated hidden fields - * @var string token Form token - * @var string token_sid User session ID - * @var string template_variable_suffix The string that is appended to template variable name - * - * @since 3.1.0-RC3 - * @changed 3.1.11-RC1 Added template_variable_suffix - */ - $vars = array( - 'form_name', - 'now', - 's_fields', - 'token', - 'token_sid', - 'template_variable_suffix', - ); - extract($phpbb_dispatcher->trigger_event('core.add_form_key', compact($vars))); - - $template->assign_var('S_FORM_TOKEN' . $template_variable_suffix, $s_fields); -} - -/** - * Check the form key. Required for all altering actions not secured by confirm_box - * - * @param string $form_name The name of the form; has to match the name used - * in add_form_key, otherwise no restrictions apply - * @param int $timespan The maximum acceptable age for a submitted form - * in seconds. Defaults to the config setting. - * @return bool True, if the form key was valid, false otherwise - */ -function check_form_key($form_name, $timespan = false) -{ - global $config, $request, $user; - - if ($timespan === false) - { - // we enforce a minimum value of half a minute here. - $timespan = ($config['form_token_lifetime'] == -1) ? -1 : max(30, $config['form_token_lifetime']); - } - - if ($request->is_set_post('creation_time') && $request->is_set_post('form_token')) - { - $creation_time = abs($request->variable('creation_time', 0)); - $token = $request->variable('form_token', ''); - - $diff = time() - $creation_time; - - // If creation_time and the time() now is zero we can assume it was not a human doing this (the check for if ($diff)... - if (defined('DEBUG_TEST') || $diff && ($diff <= $timespan || $timespan === -1)) - { - $token_sid = ($user->data['user_id'] == ANONYMOUS && !empty($config['form_token_sid_guests'])) ? $user->session_id : ''; - $key = sha1($creation_time . $user->data['user_form_salt'] . $form_name . $token_sid); - - if ($key === $token) - { - return true; - } - } - } - - return false; -} - -// Message/Login boxes - -/** -* Build Confirm box -* @param boolean $check True for checking if confirmed (without any additional parameters) and false for displaying the confirm box -* @param string|array $title Title/Message used for confirm box. -* message text is _CONFIRM appended to title. -* If title cannot be found in user->lang a default one is displayed -* If title_CONFIRM cannot be found in user->lang the text given is used. -* If title is an array, the first array value is used as explained per above, -* all other array values are sent as parameters to the language function. -* @param string $hidden Hidden variables -* @param string $html_body Template used for confirm box -* @param string $u_action Custom form action -* -* @return bool True if confirmation was successful, false if not -*/ -function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_body.html', $u_action = '') -{ - global $user, $template, $db, $request; - global $config, $language, $phpbb_path_helper; - - if (isset($_POST['cancel'])) - { - return false; - } - - $confirm = ($language->lang('YES') === $request->variable('confirm', '', true, \phpbb\request\request_interface::POST)); - - if ($check && $confirm) - { - $user_id = $request->variable('confirm_uid', 0); - $session_id = $request->variable('sess', ''); - $confirm_key = $request->variable('confirm_key', ''); - - if ($user_id != $user->data['user_id'] || $session_id != $user->session_id || !$confirm_key || !$user->data['user_last_confirm_key'] || $confirm_key != $user->data['user_last_confirm_key']) - { - return false; - } - - // Reset user_last_confirm_key - $sql = 'UPDATE ' . USERS_TABLE . " SET user_last_confirm_key = '' - WHERE user_id = " . $user->data['user_id']; - $db->sql_query($sql); - - return true; - } - else if ($check) - { - return false; - } - - $s_hidden_fields = build_hidden_fields(array( - 'confirm_uid' => $user->data['user_id'], - 'sess' => $user->session_id, - 'sid' => $user->session_id, - )); - - // generate activation key - $confirm_key = gen_rand_string(10); - - // generate language strings - if (is_array($title)) - { - $key = array_shift($title); - $count = array_shift($title); - $confirm_title = $language->is_set($key) ? $language->lang($key, $count, $title) : $language->lang('CONFIRM'); - $confirm_text = $language->is_set($key . '_CONFIRM') ? $language->lang($key . '_CONFIRM', $count, $title) : $key; - } - else - { - $confirm_title = $language->is_set($title) ? $language->lang($title) : $language->lang('CONFIRM'); - $confirm_text = $language->is_set($title . '_CONFIRM') ? $language->lang($title . '_CONFIRM') : $title; - } - - if (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin']) - { - adm_page_header($confirm_title); - } - else - { - page_header($confirm_title); - } - - $template->set_filenames(array( - 'body' => $html_body) - ); - - // If activation key already exist, we better do not re-use the key (something very strange is going on...) - if ($request->variable('confirm_key', '')) - { - // This should not occur, therefore we cancel the operation to safe the user - return false; - } - - // re-add sid / transform & to & for user->page (user->page is always using &) - $use_page = ($u_action) ? $u_action : str_replace('&', '&', $user->page['page']); - $u_action = reapply_sid($phpbb_path_helper->get_valid_page($use_page, $config['enable_mod_rewrite'])); - $u_action .= ((strpos($u_action, '?') === false) ? '?' : '&') . 'confirm_key=' . $confirm_key; - - $template->assign_vars(array( - 'MESSAGE_TITLE' => $confirm_title, - 'MESSAGE_TEXT' => $confirm_text, - - 'YES_VALUE' => $language->lang('YES'), - 'S_CONFIRM_ACTION' => $u_action, - 'S_HIDDEN_FIELDS' => $hidden . $s_hidden_fields, - 'S_AJAX_REQUEST' => $request->is_ajax(), - )); - - $sql = 'UPDATE ' . USERS_TABLE . " SET user_last_confirm_key = '" . $db->sql_escape($confirm_key) . "' - WHERE user_id = " . $user->data['user_id']; - $db->sql_query($sql); - - if ($request->is_ajax()) - { - $u_action .= '&confirm_uid=' . $user->data['user_id'] . '&sess=' . $user->session_id . '&sid=' . $user->session_id; - $json_response = new \phpbb\json_response; - $json_response->send(array( - 'MESSAGE_BODY' => $template->assign_display('body'), - 'MESSAGE_TITLE' => $confirm_title, - 'MESSAGE_TEXT' => $confirm_text, - - 'YES_VALUE' => $language->lang('YES'), - 'S_CONFIRM_ACTION' => str_replace('&', '&', $u_action), //inefficient, rewrite whole function - 'S_HIDDEN_FIELDS' => $hidden . $s_hidden_fields - )); - } - - if (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin']) - { - adm_page_footer(); - } - else - { - page_footer(); - } - - exit; // unreachable, page_footer() above will call exit() -} - -/** -* Generate login box or verify password -*/ -function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = false, $s_display = true) -{ - global $user, $template, $auth, $phpEx, $phpbb_root_path, $config; - global $request, $phpbb_container, $phpbb_dispatcher, $phpbb_log; - - $err = ''; - $form_name = 'login'; - - // Make sure user->setup() has been called - if (!$user->is_setup()) - { - $user->setup(); - } - - /** - * This event allows an extension to modify the login process - * - * @event core.login_box_before - * @var string redirect Redirect string - * @var string l_explain Explain language string - * @var string l_success Success language string - * @var bool admin Is admin? - * @var bool s_display Display full login form? - * @var string err Error string - * @since 3.1.9-RC1 - */ - $vars = array('redirect', 'l_explain', 'l_success', 'admin', 's_display', 'err'); - extract($phpbb_dispatcher->trigger_event('core.login_box_before', compact($vars))); - - // Print out error if user tries to authenticate as an administrator without having the privileges... - if ($admin && !$auth->acl_get('a_')) - { - // Not authd - // anonymous/inactive users are never able to go to the ACP even if they have the relevant permissions - if ($user->data['is_registered']) - { - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ADMIN_AUTH_FAIL'); - } - send_status_line(403, 'Forbidden'); - trigger_error('NO_AUTH_ADMIN'); - } - - if (empty($err) && ($request->is_set_post('login') || ($request->is_set('login') && $request->variable('login', '') == 'external'))) - { - // Get credential - if ($admin) - { - $credential = $request->variable('credential', ''); - - if (strspn($credential, 'abcdef0123456789') !== strlen($credential) || strlen($credential) != 32) - { - if ($user->data['is_registered']) - { - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ADMIN_AUTH_FAIL'); - } - send_status_line(403, 'Forbidden'); - trigger_error('NO_AUTH_ADMIN'); - } - - $password = $request->untrimmed_variable('password_' . $credential, '', true); - } - else - { - $password = $request->untrimmed_variable('password', '', true); - } - - $username = $request->variable('username', '', true); - $autologin = $request->is_set_post('autologin'); - $viewonline = (int) !$request->is_set_post('viewonline'); - $admin = ($admin) ? 1 : 0; - $viewonline = ($admin) ? $user->data['session_viewonline'] : $viewonline; - - // Check if the supplied username is equal to the one stored within the database if re-authenticating - if ($admin && utf8_clean_string($username) != utf8_clean_string($user->data['username'])) - { - // We log the attempt to use a different username... - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ADMIN_AUTH_FAIL'); - - send_status_line(403, 'Forbidden'); - trigger_error('NO_AUTH_ADMIN_USER_DIFFER'); - } - - // Check form key - if ($password && !check_form_key($form_name)) - { - $result = array( - 'status' => false, - 'error_msg' => 'FORM_INVALID', - ); - } - else - { - // If authentication is successful we redirect user to previous page - $result = $auth->login($username, $password, $autologin, $viewonline, $admin); - } - - // If admin authentication and login, we will log if it was a success or not... - // We also break the operation on the first non-success login - it could be argued that the user already knows - if ($admin) - { - if ($result['status'] == LOGIN_SUCCESS) - { - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ADMIN_AUTH_SUCCESS'); - } - else - { - // Only log the failed attempt if a real user tried to. - // anonymous/inactive users are never able to go to the ACP even if they have the relevant permissions - if ($user->data['is_registered']) - { - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ADMIN_AUTH_FAIL'); - } - } - } - - // The result parameter is always an array, holding the relevant information... - if ($result['status'] == LOGIN_SUCCESS) - { - $redirect = $request->variable('redirect', "{$phpbb_root_path}index.$phpEx"); - - /** - * This event allows an extension to modify the redirection when a user successfully logs in - * - * @event core.login_box_redirect - * @var string redirect Redirect string - * @var bool admin Is admin? - * @var array result Result from auth provider - * @since 3.1.0-RC5 - * @changed 3.1.9-RC1 Removed undefined return variable - * @changed 3.2.4-RC1 Added result - */ - $vars = array('redirect', 'admin', 'result'); - extract($phpbb_dispatcher->trigger_event('core.login_box_redirect', compact($vars))); - - // append/replace SID (may change during the session for AOL users) - $redirect = reapply_sid($redirect); - - // Special case... the user is effectively banned, but we allow founders to login - if (defined('IN_CHECK_BAN') && $result['user_row']['user_type'] != USER_FOUNDER) - { - return; - } - - redirect($redirect); - } - - // Something failed, determine what... - if ($result['status'] == LOGIN_BREAK) - { - trigger_error($result['error_msg']); - } - - // Special cases... determine - switch ($result['status']) - { - case LOGIN_ERROR_PASSWORD_CONVERT: - $err = sprintf( - $user->lang[$result['error_msg']], - ($config['email_enable']) ? '' : '', - ($config['email_enable']) ? '' : '', - '', - '' - ); - break; - - case LOGIN_ERROR_ATTEMPTS: - - $captcha = $phpbb_container->get('captcha.factory')->get_instance($config['captcha_plugin']); - $captcha->init(CONFIRM_LOGIN); - // $captcha->reset(); - - $template->assign_vars(array( - 'CAPTCHA_TEMPLATE' => $captcha->get_template(), - )); - // no break; - - // Username, password, etc... - default: - $err = $user->lang[$result['error_msg']]; - - // Assign admin contact to some error messages - if ($result['error_msg'] == 'LOGIN_ERROR_USERNAME' || $result['error_msg'] == 'LOGIN_ERROR_PASSWORD') - { - $err = sprintf($user->lang[$result['error_msg']], '', ''); - } - - break; - } - - /** - * This event allows an extension to process when a user fails a login attempt - * - * @event core.login_box_failed - * @var array result Login result data - * @var string username User name used to login - * @var string password Password used to login - * @var string err Error message - * @since 3.1.3-RC1 - */ - $vars = array('result', 'username', 'password', 'err'); - extract($phpbb_dispatcher->trigger_event('core.login_box_failed', compact($vars))); - } - - // Assign credential for username/password pair - $credential = ($admin) ? md5(unique_id()) : false; - - $s_hidden_fields = array( - 'sid' => $user->session_id, - ); - - if ($redirect) - { - $s_hidden_fields['redirect'] = $redirect; - } - - if ($admin) - { - $s_hidden_fields['credential'] = $credential; - } - - /* @var $provider_collection \phpbb\auth\provider_collection */ - $provider_collection = $phpbb_container->get('auth.provider_collection'); - $auth_provider = $provider_collection->get_provider(); - - $auth_provider_data = $auth_provider->get_login_data(); - if ($auth_provider_data) - { - if (isset($auth_provider_data['VARS'])) - { - $template->assign_vars($auth_provider_data['VARS']); - } - - if (isset($auth_provider_data['BLOCK_VAR_NAME'])) - { - foreach ($auth_provider_data['BLOCK_VARS'] as $block_vars) - { - $template->assign_block_vars($auth_provider_data['BLOCK_VAR_NAME'], $block_vars); - } - } - - $template->assign_vars(array( - 'PROVIDER_TEMPLATE_FILE' => $auth_provider_data['TEMPLATE_FILE'], - )); - } - - // Add form token for login box - add_form_key($form_name, '_LOGIN'); - - $s_hidden_fields = build_hidden_fields($s_hidden_fields); - - $login_box_template_data = array( - 'LOGIN_ERROR' => $err, - 'LOGIN_EXPLAIN' => $l_explain, - - 'U_SEND_PASSWORD' => ($config['email_enable']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=sendpassword') : '', - 'U_RESEND_ACTIVATION' => ($config['require_activation'] == USER_ACTIVATION_SELF && $config['email_enable']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=resend_act') : '', - 'U_TERMS_USE' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=terms'), - 'U_PRIVACY' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=privacy'), - 'UA_PRIVACY' => addslashes(append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=privacy')), - - 'S_DISPLAY_FULL_LOGIN' => ($s_display) ? true : false, - 'S_HIDDEN_FIELDS' => $s_hidden_fields, - - 'S_ADMIN_AUTH' => $admin, - 'USERNAME' => ($admin) ? $user->data['username'] : '', - - 'USERNAME_CREDENTIAL' => 'username', - 'PASSWORD_CREDENTIAL' => ($admin) ? 'password_' . $credential : 'password', - ); - - /** - * Event to add/modify login box template data - * - * @event core.login_box_modify_template_data - * @var int admin Flag whether user is admin - * @var string username User name - * @var int autologin Flag whether autologin is enabled - * @var string redirect Redirect URL - * @var array login_box_template_data Array with the login box template data - * @since 3.2.3-RC2 - */ - $vars = array( - 'admin', - 'username', - 'autologin', - 'redirect', - 'login_box_template_data', - ); - extract($phpbb_dispatcher->trigger_event('core.login_box_modify_template_data', compact($vars))); - - $template->assign_vars($login_box_template_data); - - page_header($user->lang['LOGIN']); - - $template->set_filenames(array( - 'body' => 'login_body.html') - ); - make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx")); - - page_footer(); -} - -/** -* Generate forum login box -*/ -function login_forum_box($forum_data) -{ - global $db, $phpbb_container, $request, $template, $user, $phpbb_dispatcher, $phpbb_root_path, $phpEx; - - $password = $request->variable('password', '', true); - - $sql = 'SELECT forum_id - FROM ' . FORUMS_ACCESS_TABLE . ' - WHERE forum_id = ' . $forum_data['forum_id'] . ' - AND user_id = ' . $user->data['user_id'] . " - AND session_id = '" . $db->sql_escape($user->session_id) . "'"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - return true; - } - - if ($password) - { - // Remove expired authorised sessions - $sql = 'SELECT f.session_id - FROM ' . FORUMS_ACCESS_TABLE . ' f - LEFT JOIN ' . SESSIONS_TABLE . ' s ON (f.session_id = s.session_id) - WHERE s.session_id IS NULL'; - $result = $db->sql_query($sql); - - if ($row = $db->sql_fetchrow($result)) - { - $sql_in = array(); - do - { - $sql_in[] = (string) $row['session_id']; - } - while ($row = $db->sql_fetchrow($result)); - - // Remove expired sessions - $sql = 'DELETE FROM ' . FORUMS_ACCESS_TABLE . ' - WHERE ' . $db->sql_in_set('session_id', $sql_in); - $db->sql_query($sql); - } - $db->sql_freeresult($result); - - /* @var $passwords_manager \phpbb\passwords\manager */ - $passwords_manager = $phpbb_container->get('passwords.manager'); - - if ($passwords_manager->check($password, $forum_data['forum_password'])) - { - $sql_ary = array( - 'forum_id' => (int) $forum_data['forum_id'], - 'user_id' => (int) $user->data['user_id'], - 'session_id' => (string) $user->session_id, - ); - - $db->sql_query('INSERT INTO ' . FORUMS_ACCESS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); - - return true; - } - - $template->assign_var('LOGIN_ERROR', $user->lang['WRONG_PASSWORD']); - } - - /** - * Performing additional actions, load additional data on forum login - * - * @event core.login_forum_box - * @var array forum_data Array with forum data - * @var string password Password entered - * @since 3.1.0-RC3 - */ - $vars = array('forum_data', 'password'); - extract($phpbb_dispatcher->trigger_event('core.login_forum_box', compact($vars))); - - page_header($user->lang['LOGIN']); - - // Add form token for login box - add_form_key('login', '_LOGIN'); - - $template->assign_vars(array( - 'FORUM_NAME' => isset($forum_data['forum_name']) ? $forum_data['forum_name'] : '', - 'S_LOGIN_ACTION' => build_url(array('f')), - 'S_HIDDEN_FIELDS' => build_hidden_fields(array('f' => $forum_data['forum_id']))) - ); - - $template->set_filenames(array( - 'body' => 'login_forum.html') - ); - - make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"), $forum_data['forum_id']); - - page_footer(); -} - -// Little helpers - -/** -* Little helper for the build_hidden_fields function -*/ -function _build_hidden_fields($key, $value, $specialchar, $stripslashes) -{ - $hidden_fields = ''; - - if (!is_array($value)) - { - $value = ($stripslashes) ? stripslashes($value) : $value; - $value = ($specialchar) ? htmlspecialchars($value, ENT_COMPAT, 'UTF-8') : $value; - - $hidden_fields .= '' . "\n"; - } - else - { - foreach ($value as $_key => $_value) - { - $_key = ($stripslashes) ? stripslashes($_key) : $_key; - $_key = ($specialchar) ? htmlspecialchars($_key, ENT_COMPAT, 'UTF-8') : $_key; - - $hidden_fields .= _build_hidden_fields($key . '[' . $_key . ']', $_value, $specialchar, $stripslashes); - } - } - - return $hidden_fields; -} - -/** -* Build simple hidden fields from array -* -* @param array $field_ary an array of values to build the hidden field from -* @param bool $specialchar if true, keys and values get specialchared -* @param bool $stripslashes if true, keys and values get stripslashed -* -* @return string the hidden fields -*/ -function build_hidden_fields($field_ary, $specialchar = false, $stripslashes = false) -{ - $s_hidden_fields = ''; - - foreach ($field_ary as $name => $vars) - { - $name = ($stripslashes) ? stripslashes($name) : $name; - $name = ($specialchar) ? htmlspecialchars($name, ENT_COMPAT, 'UTF-8') : $name; - - $s_hidden_fields .= _build_hidden_fields($name, $vars, $specialchar, $stripslashes); - } - - return $s_hidden_fields; -} - -/** -* Parse cfg file -*/ -function parse_cfg_file($filename, $lines = false) -{ - $parsed_items = array(); - - if ($lines === false) - { - $lines = file($filename); - } - - foreach ($lines as $line) - { - $line = trim($line); - - if (!$line || $line[0] == '#' || ($delim_pos = strpos($line, '=')) === false) - { - continue; - } - - // Determine first occurrence, since in values the equal sign is allowed - $key = htmlspecialchars(strtolower(trim(substr($line, 0, $delim_pos)))); - $value = trim(substr($line, $delim_pos + 1)); - - if (in_array($value, array('off', 'false', '0'))) - { - $value = false; - } - else if (in_array($value, array('on', 'true', '1'))) - { - $value = true; - } - else if (!trim($value)) - { - $value = ''; - } - else if (($value[0] == "'" && $value[strlen($value) - 1] == "'") || ($value[0] == '"' && $value[strlen($value) - 1] == '"')) - { - $value = htmlspecialchars(substr($value, 1, strlen($value)-2)); - } - else - { - $value = htmlspecialchars($value); - } - - $parsed_items[$key] = $value; - } - - if (isset($parsed_items['parent']) && isset($parsed_items['name']) && $parsed_items['parent'] == $parsed_items['name']) - { - unset($parsed_items['parent']); - } - - return $parsed_items; -} - -/** -* Return a nicely formatted backtrace. -* -* Turns the array returned by debug_backtrace() into HTML markup. -* Also filters out absolute paths to phpBB root. -* -* @return string HTML markup -*/ -function get_backtrace() -{ - $output = '
'; - $backtrace = debug_backtrace(); - - // We skip the first one, because it only shows this file/function - unset($backtrace[0]); - - foreach ($backtrace as $trace) - { - // Strip the current directory from path - $trace['file'] = (empty($trace['file'])) ? '(not given by php)' : htmlspecialchars(phpbb_filter_root_path($trace['file'])); - $trace['line'] = (empty($trace['line'])) ? '(not given by php)' : $trace['line']; - - // Only show function arguments for include etc. - // Other parameters may contain sensible information - $argument = ''; - if (!empty($trace['args'][0]) && in_array($trace['function'], array('include', 'require', 'include_once', 'require_once'))) - { - $argument = htmlspecialchars(phpbb_filter_root_path($trace['args'][0])); - } - - $trace['class'] = (!isset($trace['class'])) ? '' : $trace['class']; - $trace['type'] = (!isset($trace['type'])) ? '' : $trace['type']; - - $output .= '
'; - $output .= 'FILE: ' . $trace['file'] . '
'; - $output .= 'LINE: ' . ((!empty($trace['line'])) ? $trace['line'] : '') . '
'; - - $output .= 'CALL: ' . htmlspecialchars($trace['class'] . $trace['type'] . $trace['function']); - $output .= '(' . (($argument !== '') ? "'$argument'" : '') . ')
'; - } - $output .= '
'; - return $output; -} - -/** -* This function returns a regular expression pattern for commonly used expressions -* Use with / as delimiter for email mode and # for url modes -* mode can be: email|bbcode_htm|url|url_inline|www_url|www_url_inline|relative_url|relative_url_inline|ipv4|ipv6 -*/ -function get_preg_expression($mode) -{ - switch ($mode) - { - case 'email': - // Regex written by James Watts and Francisco Jose Martin Moreno - // http://fightingforalostcause.net/misc/2006/compare-email-regex.php - return '((?:[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*(?:[\w\!\#$\%\'\*\+\-\/\=\?\^\`{\|\}\~]|&)+)@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,63})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)'; - break; - - case 'bbcode_htm': - return array( - '#.*?#', - '#.*?#', - '#\2#', - '#.*?#', - '#(?:0|[1-9](?:(?:0|[1-9])+)*))[.](?(?:0|[1-9](?:(?:0|[1-9])+)*))[.](?(?:0|[1-9](?:(?:0|[1-9])+)*))(?:-(?(?:(?:(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?|(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?)|(?:0|[1-9](?:(?:0|[1-9])+)*))(?:[.](?:(?:(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?|(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?)|(?:0|[1-9](?:(?:0|[1-9])+)*)))*))?(?:[+](?(?:(?:(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?|(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?)|(?:(?:0|[1-9])+))(?:[.](?:(?:(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?|(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?)|(?:(?:0|[1-9])+)))*))?)$/'; - break; - } - - return ''; -} - -/** -* Generate regexp for naughty words censoring -* Depends on whether installed PHP version supports unicode properties -* -* @param string $word word template to be replaced -* -* @return string $preg_expr regex to use with word censor -*/ -function get_censor_preg_expression($word) -{ - // Unescape the asterisk to simplify further conversions - $word = str_replace('\*', '*', preg_quote($word, '#')); - - // Replace asterisk(s) inside the pattern, at the start and at the end of it with regexes - $word = preg_replace(array('#(?<=[\p{Nd}\p{L}_])\*+(?=[\p{Nd}\p{L}_])#iu', '#^\*+#', '#\*+$#'), array('([\x20]*?|[\p{Nd}\p{L}_-]*?)', '[\p{Nd}\p{L}_-]*?', '[\p{Nd}\p{L}_-]*?'), $word); - - // Generate the final substitution - $preg_expr = '#(? strlen($longest_match)) - { - $longest_match = $match[0]; - $longest_match_offset = $match[1]; - } - } - - $ret = substr_replace($ret, '', $longest_match_offset, strlen($longest_match)); - - if ($longest_match_offset == strlen($ret)) - { - $ret .= ':'; - } - - if ($longest_match_offset == 0) - { - $ret = ':' . $ret; - } - - return $ret; - - default: - return false; - } -} - -/** -* Wrapper for inet_pton() -* -* Converts a human readable IP address to its packed in_addr representation -* inet_pton() is supported by PHP since 5.1.0, since 5.3.0 also on Windows. -* -* @param string $address A human readable IPv4 or IPv6 address. -* -* @return mixed false if address is invalid, -* in_addr representation of the given address otherwise (string) -*/ -function phpbb_inet_pton($address) -{ - $ret = ''; - if (preg_match(get_preg_expression('ipv4'), $address)) - { - foreach (explode('.', $address) as $part) - { - $ret .= ($part <= 0xF ? '0' : '') . dechex($part); - } - - return pack('H*', $ret); - } - - if (preg_match(get_preg_expression('ipv6'), $address)) - { - $parts = explode(':', $address); - $missing_parts = 8 - count($parts) + 1; - - if (substr($address, 0, 2) === '::') - { - ++$missing_parts; - } - - if (substr($address, -2) === '::') - { - ++$missing_parts; - } - - $embedded_ipv4 = false; - $last_part = end($parts); - - if (preg_match(get_preg_expression('ipv4'), $last_part)) - { - $parts[count($parts) - 1] = ''; - $last_part = phpbb_inet_pton($last_part); - $embedded_ipv4 = true; - --$missing_parts; - } - - foreach ($parts as $i => $part) - { - if (strlen($part)) - { - $ret .= str_pad($part, 4, '0', STR_PAD_LEFT); - } - else if ($i && $i < count($parts) - 1) - { - $ret .= str_repeat('0000', $missing_parts); - } - } - - $ret = pack('H*', $ret); - - if ($embedded_ipv4) - { - $ret .= $last_part; - } - - return $ret; - } - - return false; -} - -/** -* Wrapper for php's checkdnsrr function. -* -* @param string $host Fully-Qualified Domain Name -* @param string $type Resource record type to lookup -* Supported types are: MX (default), A, AAAA, NS, TXT, CNAME -* Other types may work or may not work -* -* @return mixed true if entry found, -* false if entry not found, -* null if this function is not supported by this environment -* -* Since null can also be returned, you probably want to compare the result -* with === true or === false, -*/ -function phpbb_checkdnsrr($host, $type = 'MX') -{ - // The dot indicates to search the DNS root (helps those having DNS prefixes on the same domain) - if (substr($host, -1) == '.') - { - $host_fqdn = $host; - $host = substr($host, 0, -1); - } - else - { - $host_fqdn = $host . '.'; - } - // $host has format some.host.example.com - // $host_fqdn has format some.host.example.com. - - // If we're looking for an A record we can use gethostbyname() - if ($type == 'A' && function_exists('gethostbyname')) - { - return (@gethostbyname($host_fqdn) == $host_fqdn) ? false : true; - } - - if (function_exists('checkdnsrr')) - { - return checkdnsrr($host_fqdn, $type); - } - - if (function_exists('dns_get_record')) - { - // dns_get_record() expects an integer as second parameter - // We have to convert the string $type to the corresponding integer constant. - $type_constant = 'DNS_' . $type; - $type_param = (defined($type_constant)) ? constant($type_constant) : DNS_ANY; - - // dns_get_record() might throw E_WARNING and return false for records that do not exist - $resultset = @dns_get_record($host_fqdn, $type_param); - - if (empty($resultset) || !is_array($resultset)) - { - return false; - } - else if ($type_param == DNS_ANY) - { - // $resultset is a non-empty array - return true; - } - - foreach ($resultset as $result) - { - if ( - isset($result['host']) && $result['host'] == $host && - isset($result['type']) && $result['type'] == $type - ) - { - return true; - } - } - - return false; - } - - // If we're on Windows we can still try to call nslookup via exec() as a last resort - if (DIRECTORY_SEPARATOR == '\\' && function_exists('exec')) - { - @exec('nslookup -type=' . escapeshellarg($type) . ' ' . escapeshellarg($host_fqdn), $output); - - // If output is empty, the nslookup failed - if (empty($output)) - { - return NULL; - } - - foreach ($output as $line) - { - $line = trim($line); - - if (empty($line)) - { - continue; - } - - // Squash tabs and multiple whitespaces to a single whitespace. - $line = preg_replace('/\s+/', ' ', $line); - - switch ($type) - { - case 'MX': - if (stripos($line, "$host MX") === 0) - { - return true; - } - break; - - case 'NS': - if (stripos($line, "$host nameserver") === 0) - { - return true; - } - break; - - case 'TXT': - if (stripos($line, "$host text") === 0) - { - return true; - } - break; - - case 'CNAME': - if (stripos($line, "$host canonical name") === 0) - { - return true; - } - break; - - default: - case 'AAAA': - // AAAA records returned by nslookup on Windows XP/2003 have this format. - // Later Windows versions use the A record format below for AAAA records. - if (stripos($line, "$host AAAA IPv6 address") === 0) - { - return true; - } - // No break - - case 'A': - if (!empty($host_matches)) - { - // Second line - if (stripos($line, "Address: ") === 0) - { - return true; - } - else - { - $host_matches = false; - } - } - else if (stripos($line, "Name: $host") === 0) - { - // First line - $host_matches = true; - } - break; - } - } - - return false; - } - - return NULL; -} - -// Handler, header and footer - -/** -* Error and message handler, call with trigger_error if read -*/ -function msg_handler($errno, $msg_text, $errfile, $errline) -{ - global $cache, $db, $auth, $template, $config, $user, $request; - global $phpbb_root_path, $msg_title, $msg_long_text, $phpbb_log; - - // Do not display notices if we suppress them via @ - if (error_reporting() == 0 && $errno != E_USER_ERROR && $errno != E_USER_WARNING && $errno != E_USER_NOTICE) - { - return; - } - - // Message handler is stripping text. In case we need it, we are possible to define long text... - if (isset($msg_long_text) && $msg_long_text && !$msg_text) - { - $msg_text = $msg_long_text; - } - - switch ($errno) - { - case E_NOTICE: - case E_WARNING: - - // Check the error reporting level and return if the error level does not match - // If DEBUG is defined the default level is E_ALL - if (($errno & ((defined('DEBUG')) ? E_ALL : error_reporting())) == 0) - { - return; - } - - if (strpos($errfile, 'cache') === false && strpos($errfile, 'template.') === false) - { - $errfile = phpbb_filter_root_path($errfile); - $msg_text = phpbb_filter_root_path($msg_text); - $error_name = ($errno === E_WARNING) ? 'PHP Warning' : 'PHP Notice'; - echo '[phpBB Debug] ' . $error_name . ': in file ' . $errfile . ' on line ' . $errline . ': ' . $msg_text . '
' . "\n"; - - // we are writing an image - the user won't see the debug, so let's place it in the log - if (defined('IMAGE_OUTPUT') || defined('IN_CRON')) - { - $phpbb_log->add('critical', $user->data['user_id'], $user->ip, 'LOG_IMAGE_GENERATION_ERROR', false, array($errfile, $errline, $msg_text)); - } - // echo '

BACKTRACE
' . get_backtrace() . '
' . "\n"; - } - - return; - - break; - - case E_USER_ERROR: - - if (!empty($user) && $user->is_setup()) - { - $msg_text = (!empty($user->lang[$msg_text])) ? $user->lang[$msg_text] : $msg_text; - $msg_title = (!isset($msg_title)) ? $user->lang['GENERAL_ERROR'] : ((!empty($user->lang[$msg_title])) ? $user->lang[$msg_title] : $msg_title); - - $l_return_index = sprintf($user->lang['RETURN_INDEX'], '', ''); - $l_notify = ''; - - if (!empty($config['board_contact'])) - { - $l_notify = '

' . sprintf($user->lang['NOTIFY_ADMIN_EMAIL'], $config['board_contact']) . '

'; - } - } - else - { - $msg_title = 'General Error'; - $l_return_index = 'Return to index page'; - $l_notify = ''; - - if (!empty($config['board_contact'])) - { - $l_notify = '

Please notify the board administrator or webmaster: ' . $config['board_contact'] . '

'; - } - } - - $log_text = $msg_text; - $backtrace = get_backtrace(); - if ($backtrace) - { - $log_text .= '

BACKTRACE
' . $backtrace; - } - - if (defined('IN_INSTALL') || defined('DEBUG') || isset($auth) && $auth->acl_get('a_')) - { - $msg_text = $log_text; - - // If this is defined there already was some output - // So let's not break it - if (defined('IN_DB_UPDATE')) - { - echo '
' . $msg_text . '
'; - - $db->sql_return_on_error(true); - phpbb_end_update($cache, $config); - } - } - - if ((defined('IN_CRON') || defined('IMAGE_OUTPUT')) && isset($db)) - { - // let's avoid loops - $db->sql_return_on_error(true); - $phpbb_log->add('critical', $user->data['user_id'], $user->ip, 'LOG_GENERAL_ERROR', false, array($msg_title, $log_text)); - $db->sql_return_on_error(false); - } - - // Do not send 200 OK, but service unavailable on errors - send_status_line(503, 'Service Unavailable'); - - garbage_collection(); - - // Try to not call the adm page data... - - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo '' . $msg_title . ''; - echo ''; - echo ''; - echo ''; - echo '
'; - echo ' '; - echo '
'; - echo '
'; - echo '
'; - echo '

' . $msg_title . '

'; - - echo '
' . $msg_text . '
'; - - echo $l_notify; - - echo '
'; - echo '
'; - echo '
'; - echo ' '; - echo '
'; - echo ''; - echo ''; - - exit_handler(); - - // On a fatal error (and E_USER_ERROR *is* fatal) we never want other scripts to continue and force an exit here. - exit; - break; - - case E_USER_WARNING: - case E_USER_NOTICE: - - define('IN_ERROR_HANDLER', true); - - if (empty($user->data)) - { - $user->session_begin(); - } - - // We re-init the auth array to get correct results on login/logout - $auth->acl($user->data); - - if (!$user->is_setup()) - { - $user->setup(); - } - - if ($msg_text == 'ERROR_NO_ATTACHMENT' || $msg_text == 'NO_FORUM' || $msg_text == 'NO_TOPIC' || $msg_text == 'NO_USER') - { - send_status_line(404, 'Not Found'); - } - - $msg_text = (!empty($user->lang[$msg_text])) ? $user->lang[$msg_text] : $msg_text; - $msg_title = (!isset($msg_title)) ? $user->lang['INFORMATION'] : ((!empty($user->lang[$msg_title])) ? $user->lang[$msg_title] : $msg_title); - - if (!defined('HEADER_INC')) - { - if (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin']) - { - adm_page_header($msg_title); - } - else - { - page_header($msg_title); - } - } - - $template->set_filenames(array( - 'body' => 'message_body.html') - ); - - $template->assign_vars(array( - 'MESSAGE_TITLE' => $msg_title, - 'MESSAGE_TEXT' => $msg_text, - 'S_USER_WARNING' => ($errno == E_USER_WARNING) ? true : false, - 'S_USER_NOTICE' => ($errno == E_USER_NOTICE) ? true : false) - ); - - if ($request->is_ajax()) - { - global $refresh_data; - - $json_response = new \phpbb\json_response; - $json_response->send(array( - 'MESSAGE_TITLE' => $msg_title, - 'MESSAGE_TEXT' => $msg_text, - 'S_USER_WARNING' => ($errno == E_USER_WARNING) ? true : false, - 'S_USER_NOTICE' => ($errno == E_USER_NOTICE) ? true : false, - 'REFRESH_DATA' => (!empty($refresh_data)) ? $refresh_data : null - )); - } - - // We do not want the cron script to be called on error messages - define('IN_CRON', true); - - if (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin']) - { - adm_page_footer(); - } - else - { - page_footer(); - } - - exit_handler(); - break; - - // PHP4 compatibility - case E_DEPRECATED: - return true; - break; - } - - // If we notice an error not handled here we pass this back to PHP by returning false - // This may not work for all php versions - return false; -} - -/** -* Removes absolute path to phpBB root directory from error messages -* and converts backslashes to forward slashes. -* -* @param string $errfile Absolute file path -* (e.g. /var/www/phpbb3/phpBB/includes/functions.php) -* Please note that if $errfile is outside of the phpBB root, -* the root path will not be found and can not be filtered. -* @return string Relative file path -* (e.g. /includes/functions.php) -*/ -function phpbb_filter_root_path($errfile) -{ - global $phpbb_filesystem; - - static $root_path; - - if (empty($root_path)) - { - if ($phpbb_filesystem) - { - $root_path = $phpbb_filesystem->realpath(dirname(__FILE__) . '/../'); - } - else - { - $filesystem = new \phpbb\filesystem\filesystem(); - $root_path = $filesystem->realpath(dirname(__FILE__) . '/../'); - } - } - - return str_replace(array($root_path, '\\'), array('[ROOT]', '/'), $errfile); -} - -/** -* Queries the session table to get information about online guests -* @param int $item_id Limits the search to the item with this id -* @param string $item The name of the item which is stored in the session table as session_{$item}_id -* @return int The number of active distinct guest sessions -*/ -function obtain_guest_count($item_id = 0, $item = 'forum') -{ - global $db, $config; - - if ($item_id) - { - $reading_sql = ' AND s.session_' . $item . '_id = ' . (int) $item_id; - } - else - { - $reading_sql = ''; - } - $time = (time() - (intval($config['load_online_time']) * 60)); - - // Get number of online guests - - if ($db->get_sql_layer() === 'sqlite3') - { - $sql = 'SELECT COUNT(session_ip) as num_guests - FROM ( - SELECT DISTINCT s.session_ip - FROM ' . SESSIONS_TABLE . ' s - WHERE s.session_user_id = ' . ANONYMOUS . ' - AND s.session_time >= ' . ($time - ((int) ($time % 60))) . - $reading_sql . - ')'; - } - else - { - $sql = 'SELECT COUNT(DISTINCT s.session_ip) as num_guests - FROM ' . SESSIONS_TABLE . ' s - WHERE s.session_user_id = ' . ANONYMOUS . ' - AND s.session_time >= ' . ($time - ((int) ($time % 60))) . - $reading_sql; - } - $result = $db->sql_query($sql); - $guests_online = (int) $db->sql_fetchfield('num_guests'); - $db->sql_freeresult($result); - - return $guests_online; -} - -/** -* Queries the session table to get information about online users -* @param int $item_id Limits the search to the item with this id -* @param string $item The name of the item which is stored in the session table as session_{$item}_id -* @return array An array containing the ids of online, hidden and visible users, as well as statistical info -*/ -function obtain_users_online($item_id = 0, $item = 'forum') -{ - global $db, $config; - - $reading_sql = ''; - if ($item_id !== 0) - { - $reading_sql = ' AND s.session_' . $item . '_id = ' . (int) $item_id; - } - - $online_users = array( - 'online_users' => array(), - 'hidden_users' => array(), - 'total_online' => 0, - 'visible_online' => 0, - 'hidden_online' => 0, - 'guests_online' => 0, - ); - - if ($config['load_online_guests']) - { - $online_users['guests_online'] = obtain_guest_count($item_id, $item); - } - - // a little discrete magic to cache this for 30 seconds - $time = (time() - (intval($config['load_online_time']) * 60)); - - $sql = 'SELECT s.session_user_id, s.session_ip, s.session_viewonline - FROM ' . SESSIONS_TABLE . ' s - WHERE s.session_time >= ' . ($time - ((int) ($time % 30))) . - $reading_sql . - ' AND s.session_user_id <> ' . ANONYMOUS; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - // Skip multiple sessions for one user - if (!isset($online_users['online_users'][$row['session_user_id']])) - { - $online_users['online_users'][$row['session_user_id']] = (int) $row['session_user_id']; - if ($row['session_viewonline']) - { - $online_users['visible_online']++; - } - else - { - $online_users['hidden_users'][$row['session_user_id']] = (int) $row['session_user_id']; - $online_users['hidden_online']++; - } - } - } - $online_users['total_online'] = $online_users['guests_online'] + $online_users['visible_online'] + $online_users['hidden_online']; - $db->sql_freeresult($result); - - return $online_users; -} - -/** -* Uses the result of obtain_users_online to generate a localized, readable representation. -* @param mixed $online_users result of obtain_users_online - array with user_id lists for total, hidden and visible users, and statistics -* @param int $item_id Indicate that the data is limited to one item and not global -* @param string $item The name of the item which is stored in the session table as session_{$item}_id -* @return array An array containing the string for output to the template -*/ -function obtain_users_online_string($online_users, $item_id = 0, $item = 'forum') -{ - global $config, $db, $user, $auth, $phpbb_dispatcher; - - $user_online_link = $rowset = array(); - // Need caps version of $item for language-strings - $item_caps = strtoupper($item); - - if (count($online_users['online_users'])) - { - $sql_ary = array( - 'SELECT' => 'u.username, u.username_clean, u.user_id, u.user_type, u.user_allow_viewonline, u.user_colour', - 'FROM' => array( - USERS_TABLE => 'u', - ), - 'WHERE' => $db->sql_in_set('u.user_id', $online_users['online_users']), - 'ORDER_BY' => 'u.username_clean ASC', - ); - - /** - * Modify SQL query to obtain online users data - * - * @event core.obtain_users_online_string_sql - * @var array online_users Array with online users data - * from obtain_users_online() - * @var int item_id Restrict online users to item id - * @var string item Restrict online users to a certain - * session item, e.g. forum for - * session_forum_id - * @var array sql_ary SQL query array to obtain users online data - * @since 3.1.4-RC1 - * @changed 3.1.7-RC1 Change sql query into array and adjust var accordingly. Allows extension authors the ability to adjust the sql_ary. - */ - $vars = array('online_users', 'item_id', 'item', 'sql_ary'); - extract($phpbb_dispatcher->trigger_event('core.obtain_users_online_string_sql', compact($vars))); - - $result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary)); - $rowset = $db->sql_fetchrowset($result); - $db->sql_freeresult($result); - - foreach ($rowset as $row) - { - // User is logged in and therefore not a guest - if ($row['user_id'] != ANONYMOUS) - { - if (isset($online_users['hidden_users'][$row['user_id']])) - { - $row['username'] = '' . $row['username'] . ''; - } - - if (!isset($online_users['hidden_users'][$row['user_id']]) || $auth->acl_get('u_viewonline') || $row['user_id'] === $user->data['user_id']) - { - $user_online_link[$row['user_id']] = get_username_string(($row['user_type'] <> USER_IGNORE) ? 'full' : 'no_profile', $row['user_id'], $row['username'], $row['user_colour']); - } - } - } - } - - /** - * Modify online userlist data - * - * @event core.obtain_users_online_string_before_modify - * @var array online_users Array with online users data - * from obtain_users_online() - * @var int item_id Restrict online users to item id - * @var string item Restrict online users to a certain - * session item, e.g. forum for - * session_forum_id - * @var array rowset Array with online users data - * @var array user_online_link Array with online users items (usernames) - * @since 3.1.10-RC1 - */ - $vars = array( - 'online_users', - 'item_id', - 'item', - 'rowset', - 'user_online_link', - ); - extract($phpbb_dispatcher->trigger_event('core.obtain_users_online_string_before_modify', compact($vars))); - - $online_userlist = implode(', ', $user_online_link); - - if (!$online_userlist) - { - $online_userlist = $user->lang['NO_ONLINE_USERS']; - } - - if ($item_id === 0) - { - $online_userlist = $user->lang['REGISTERED_USERS'] . ' ' . $online_userlist; - } - else if ($config['load_online_guests']) - { - $online_userlist = $user->lang('BROWSING_' . $item_caps . '_GUESTS', $online_users['guests_online'], $online_userlist); - } - else - { - $online_userlist = sprintf($user->lang['BROWSING_' . $item_caps], $online_userlist); - } - // Build online listing - $visible_online = $user->lang('REG_USERS_TOTAL', (int) $online_users['visible_online']); - $hidden_online = $user->lang('HIDDEN_USERS_TOTAL', (int) $online_users['hidden_online']); - - if ($config['load_online_guests']) - { - $guests_online = $user->lang('GUEST_USERS_TOTAL', (int) $online_users['guests_online']); - $l_online_users = $user->lang('ONLINE_USERS_TOTAL_GUESTS', (int) $online_users['total_online'], $visible_online, $hidden_online, $guests_online); - } - else - { - $l_online_users = $user->lang('ONLINE_USERS_TOTAL', (int) $online_users['total_online'], $visible_online, $hidden_online); - } - - /** - * Modify online userlist data - * - * @event core.obtain_users_online_string_modify - * @var array online_users Array with online users data - * from obtain_users_online() - * @var int item_id Restrict online users to item id - * @var string item Restrict online users to a certain - * session item, e.g. forum for - * session_forum_id - * @var array rowset Array with online users data - * @var array user_online_link Array with online users items (usernames) - * @var string online_userlist String containing users online list - * @var string l_online_users String with total online users count info - * @since 3.1.4-RC1 - */ - $vars = array( - 'online_users', - 'item_id', - 'item', - 'rowset', - 'user_online_link', - 'online_userlist', - 'l_online_users', - ); - extract($phpbb_dispatcher->trigger_event('core.obtain_users_online_string_modify', compact($vars))); - - return array( - 'online_userlist' => $online_userlist, - 'l_online_users' => $l_online_users, - ); -} - -/** -* Get option bitfield from custom data -* -* @param int $bit The bit/value to get -* @param int $data Current bitfield to check -* @return bool Returns true if value of constant is set in bitfield, else false -*/ -function phpbb_optionget($bit, $data) -{ - return ($data & 1 << (int) $bit) ? true : false; -} - -/** -* Set option bitfield -* -* @param int $bit The bit/value to set/unset -* @param bool $set True if option should be set, false if option should be unset. -* @param int $data Current bitfield to change -* -* @return int The new bitfield -*/ -function phpbb_optionset($bit, $set, $data) -{ - if ($set && !($data & 1 << $bit)) - { - $data += 1 << $bit; - } - else if (!$set && ($data & 1 << $bit)) - { - $data -= 1 << $bit; - } - - return $data; -} - -/** -* Login using http authenticate. -* -* @param array $param Parameter array, see $param_defaults array. -* -* @return null -*/ -function phpbb_http_login($param) -{ - global $auth, $user, $request; - global $config; - - $param_defaults = array( - 'auth_message' => '', - - 'autologin' => false, - 'viewonline' => true, - 'admin' => false, - ); - - // Overwrite default values with passed values - $param = array_merge($param_defaults, $param); - - // User is already logged in - // We will not overwrite his session - if (!empty($user->data['is_registered'])) - { - return; - } - - // $_SERVER keys to check - $username_keys = array( - 'PHP_AUTH_USER', - 'Authorization', - 'REMOTE_USER', 'REDIRECT_REMOTE_USER', - 'HTTP_AUTHORIZATION', 'REDIRECT_HTTP_AUTHORIZATION', - 'REMOTE_AUTHORIZATION', 'REDIRECT_REMOTE_AUTHORIZATION', - 'AUTH_USER', - ); - - $password_keys = array( - 'PHP_AUTH_PW', - 'REMOTE_PASSWORD', - 'AUTH_PASSWORD', - ); - - $username = null; - foreach ($username_keys as $k) - { - if ($request->is_set($k, \phpbb\request\request_interface::SERVER)) - { - $username = htmlspecialchars_decode($request->server($k)); - break; - } - } - - $password = null; - foreach ($password_keys as $k) - { - if ($request->is_set($k, \phpbb\request\request_interface::SERVER)) - { - $password = htmlspecialchars_decode($request->server($k)); - break; - } - } - - // Decode encoded information (IIS, CGI, FastCGI etc.) - if (!is_null($username) && is_null($password) && strpos($username, 'Basic ') === 0) - { - list($username, $password) = explode(':', base64_decode(substr($username, 6)), 2); - } - - if (!is_null($username) && !is_null($password)) - { - set_var($username, $username, 'string', true); - set_var($password, $password, 'string', true); - - $auth_result = $auth->login($username, $password, $param['autologin'], $param['viewonline'], $param['admin']); - - if ($auth_result['status'] == LOGIN_SUCCESS) - { - return; - } - else if ($auth_result['status'] == LOGIN_ERROR_ATTEMPTS) - { - send_status_line(401, 'Unauthorized'); - - trigger_error('NOT_AUTHORISED'); - } - } - - // Prepend sitename to auth_message - $param['auth_message'] = ($param['auth_message'] === '') ? $config['sitename'] : $config['sitename'] . ' - ' . $param['auth_message']; - - // We should probably filter out non-ASCII characters - RFC2616 - $param['auth_message'] = preg_replace('/[\x80-\xFF]/', '?', $param['auth_message']); - - header('WWW-Authenticate: Basic realm="' . $param['auth_message'] . '"'); - send_status_line(401, 'Unauthorized'); - - trigger_error('NOT_AUTHORISED'); -} - -/** -* Escapes and quotes a string for use as an HTML/XML attribute value. -* -* This is a port of Python xml.sax.saxutils quoteattr. -* -* The function will attempt to choose a quote character in such a way as to -* avoid escaping quotes in the string. If this is not possible the string will -* be wrapped in double quotes and double quotes will be escaped. -* -* @param string $data The string to be escaped -* @param array $entities Associative array of additional entities to be escaped -* @return string Escaped and quoted string -*/ -function phpbb_quoteattr($data, $entities = null) -{ - $data = str_replace('&', '&', $data); - $data = str_replace('>', '>', $data); - $data = str_replace('<', '<', $data); - - $data = str_replace("\n", ' ', $data); - $data = str_replace("\r", ' ', $data); - $data = str_replace("\t", ' ', $data); - - if (!empty($entities)) - { - $data = str_replace(array_keys($entities), array_values($entities), $data); - } - - if (strpos($data, '"') !== false) - { - if (strpos($data, "'") !== false) - { - $data = '"' . str_replace('"', '"', $data) . '"'; - } - else - { - $data = "'" . $data . "'"; - } - } - else - { - $data = '"' . $data . '"'; - } - - return $data; -} - -/** -* Converts query string (GET) parameters in request into hidden fields. -* -* Useful for forwarding GET parameters when submitting forms with GET method. -* -* It is possible to omit some of the GET parameters, which is useful if -* they are specified in the form being submitted. -* -* sid is always omitted. -* -* @param \phpbb\request\request $request Request object -* @param array $exclude A list of variable names that should not be forwarded -* @return string HTML with hidden fields -*/ -function phpbb_build_hidden_fields_for_query_params($request, $exclude = null) -{ - $names = $request->variable_names(\phpbb\request\request_interface::GET); - $hidden = ''; - foreach ($names as $name) - { - // Sessions are dealt with elsewhere, omit sid always - if ($name == 'sid') - { - continue; - } - - // Omit any additional parameters requested - if (!empty($exclude) && in_array($name, $exclude)) - { - continue; - } - - $escaped_name = phpbb_quoteattr($name); - - // Note: we might retrieve the variable from POST or cookies - // here. To avoid exposing cookies, skip variables that are - // overwritten somewhere other than GET entirely. - $value = $request->variable($name, '', true); - $get_value = $request->variable($name, '', true, \phpbb\request\request_interface::GET); - if ($value === $get_value) - { - $escaped_value = phpbb_quoteattr($value); - $hidden .= ""; - } - } - return $hidden; -} - -/** -* Get user avatar -* -* @param array $user_row Row from the users table -* @param string $alt Optional language string for alt tag within image, can be a language key or text -* @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP -* @param bool $lazy If true, will be lazy loaded (requires JS) -* -* @return string Avatar html -*/ -function phpbb_get_user_avatar($user_row, $alt = 'USER_AVATAR', $ignore_config = false, $lazy = false) -{ - $row = \phpbb\avatar\manager::clean_row($user_row, 'user'); - return phpbb_get_avatar($row, $alt, $ignore_config, $lazy); -} - -/** -* Get group avatar -* -* @param array $group_row Row from the groups table -* @param string $alt Optional language string for alt tag within image, can be a language key or text -* @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP -* @param bool $lazy If true, will be lazy loaded (requires JS) -* -* @return string Avatar html -*/ -function phpbb_get_group_avatar($user_row, $alt = 'GROUP_AVATAR', $ignore_config = false, $lazy = false) -{ - $row = \phpbb\avatar\manager::clean_row($user_row, 'group'); - return phpbb_get_avatar($row, $alt, $ignore_config, $lazy); -} - -/** -* Get avatar -* -* @param array $row Row cleaned by \phpbb\avatar\manager::clean_row -* @param string $alt Optional language string for alt tag within image, can be a language key or text -* @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP -* @param bool $lazy If true, will be lazy loaded (requires JS) -* -* @return string Avatar html -*/ -function phpbb_get_avatar($row, $alt, $ignore_config = false, $lazy = false) -{ - global $user, $config; - global $phpbb_container, $phpbb_dispatcher; - - if (!$config['allow_avatar'] && !$ignore_config) - { - return ''; - } - - $avatar_data = array( - 'src' => $row['avatar'], - 'width' => $row['avatar_width'], - 'height' => $row['avatar_height'], - ); - - /* @var $phpbb_avatar_manager \phpbb\avatar\manager */ - $phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); - $driver = $phpbb_avatar_manager->get_driver($row['avatar_type'], !$ignore_config); - $html = ''; - - if ($driver) - { - $html = $driver->get_custom_html($user, $row, $alt); - $avatar_data = $driver->get_data($row); - } - else - { - $avatar_data['src'] = ''; - } - - if (empty($html) && !empty($avatar_data['src'])) - { - if ($lazy) - { - // Determine board url - we may need it later - $board_url = generate_board_url() . '/'; - // This path is sent with the base template paths in the assign_vars() - // call below. We need to correct it in case we are accessing from a - // controller because the web paths will be incorrect otherwise. - $phpbb_path_helper = $phpbb_container->get('path_helper'); - $corrected_path = $phpbb_path_helper->get_web_root_path(); - - $web_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? $board_url : $corrected_path; - - $theme = "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme'; - - $src = 'src="' . $theme . '/images/no_avatar.gif" data-src="' . $avatar_data['src'] . '"'; - } - else - { - $src = 'src="' . $avatar_data['src'] . '"'; - } - - $html = ''; - } - - /** - * Event to modify HTML tag of avatar - * - * @event core.get_avatar_after - * @var array row Row cleaned by \phpbb\avatar\manager::clean_row - * @var string alt Optional language string for alt tag within image, can be a language key or text - * @var bool ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP - * @var array avatar_data The HTML attributes for avatar tag - * @var string html The HTML tag of generated avatar - * @since 3.1.6-RC1 - */ - $vars = array('row', 'alt', 'ignore_config', 'avatar_data', 'html'); - extract($phpbb_dispatcher->trigger_event('core.get_avatar_after', compact($vars))); - - return $html; -} - -/** -* Generate page header -*/ -function page_header($page_title = '', $display_online_list = false, $item_id = 0, $item = 'forum', $send_headers = true) -{ - global $db, $config, $template, $SID, $_SID, $_EXTRA_URL, $user, $auth, $phpEx, $phpbb_root_path; - global $phpbb_dispatcher, $request, $phpbb_container, $phpbb_admin_path; - - if (defined('HEADER_INC')) - { - return; - } - - define('HEADER_INC', true); - - // A listener can set this variable to `true` when it overrides this function - $page_header_override = false; - - /** - * Execute code and/or overwrite page_header() - * - * @event core.page_header - * @var string page_title Page title - * @var bool display_online_list Do we display online users list - * @var string item Restrict online users to a certain - * session item, e.g. forum for - * session_forum_id - * @var int item_id Restrict online users to item id - * @var bool page_header_override Shall we return instead of running - * the rest of page_header() - * @since 3.1.0-a1 - */ - $vars = array('page_title', 'display_online_list', 'item_id', 'item', 'page_header_override'); - extract($phpbb_dispatcher->trigger_event('core.page_header', compact($vars))); - - if ($page_header_override) - { - return; - } - - // gzip_compression - if ($config['gzip_compress']) - { - // to avoid partially compressed output resulting in blank pages in - // the browser or error messages, compression is disabled in a few cases: - // - // 1) if headers have already been sent, this indicates plaintext output - // has been started so further content must not be compressed - // 2) the length of the current output buffer is non-zero. This means - // there is already some uncompressed content in this output buffer - // so further output must not be compressed - // 3) if more than one level of output buffering is used because we - // cannot test all output buffer level content lengths. One level - // could be caused by php.ini output_buffering. Anything - // beyond that is manual, so the code wrapping phpBB in output buffering - // can easily compress the output itself. - // - if (@extension_loaded('zlib') && !headers_sent() && ob_get_level() <= 1 && ob_get_length() == 0) - { - ob_start('ob_gzhandler'); - } - } - - $user->update_session_infos(); - - // Generate logged in/logged out status - if ($user->data['user_id'] != ANONYMOUS) - { - $u_login_logout = append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=logout', true, $user->session_id); - $l_login_logout = $user->lang['LOGOUT']; - } - else - { - $u_login_logout = append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'); - $l_login_logout = $user->lang['LOGIN']; - } - - // Last visit date/time - $s_last_visit = ($user->data['user_id'] != ANONYMOUS) ? $user->format_date($user->data['session_last_visit']) : ''; - - // Get users online list ... if required - $l_online_users = $online_userlist = $l_online_record = $l_online_time = ''; - - if ($config['load_online'] && $config['load_online_time'] && $display_online_list) - { - /** - * Load online data: - * For obtaining another session column use $item and $item_id in the function-parameter, whereby the column is session_{$item}_id. - */ - $item_id = max($item_id, 0); - - $online_users = obtain_users_online($item_id, $item); - $user_online_strings = obtain_users_online_string($online_users, $item_id, $item); - - $l_online_users = $user_online_strings['l_online_users']; - $online_userlist = $user_online_strings['online_userlist']; - $total_online_users = $online_users['total_online']; - - if ($total_online_users > $config['record_online_users']) - { - $config->set('record_online_users', $total_online_users, false); - $config->set('record_online_date', time(), false); - } - - $l_online_record = $user->lang('RECORD_ONLINE_USERS', (int) $config['record_online_users'], $user->format_date($config['record_online_date'], false, true)); - - $l_online_time = $user->lang('VIEW_ONLINE_TIMES', (int) $config['load_online_time']); - } - - $s_privmsg_new = false; - - // Check for new private messages if user is logged in - if (!empty($user->data['is_registered'])) - { - if ($user->data['user_new_privmsg']) - { - if (!$user->data['user_last_privmsg'] || $user->data['user_last_privmsg'] > $user->data['session_last_visit']) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_last_privmsg = ' . $user->data['session_last_visit'] . ' - WHERE user_id = ' . $user->data['user_id']; - $db->sql_query($sql); - - $s_privmsg_new = true; - } - else - { - $s_privmsg_new = false; - } - } - else - { - $s_privmsg_new = false; - } - } - - $forum_id = $request->variable('f', 0); - $topic_id = $request->variable('t', 0); - - $s_feed_news = false; - - // Get option for news - if ($config['feed_enable']) - { - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE . ' - WHERE ' . $db->sql_bit_and('forum_options', FORUM_OPTION_FEED_NEWS, '<> 0'); - $result = $db->sql_query_limit($sql, 1, 0, 600); - $s_feed_news = (int) $db->sql_fetchfield('forum_id'); - $db->sql_freeresult($result); - } - - // Determine board url - we may need it later - $board_url = generate_board_url() . '/'; - // This path is sent with the base template paths in the assign_vars() - // call below. We need to correct it in case we are accessing from a - // controller because the web paths will be incorrect otherwise. - /* @var $phpbb_path_helper \phpbb\path_helper */ - $phpbb_path_helper = $phpbb_container->get('path_helper'); - $corrected_path = $phpbb_path_helper->get_web_root_path(); - $web_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? $board_url : $corrected_path; - - // Send a proper content-language to the output - $user_lang = $user->lang['USER_LANG']; - if (strpos($user_lang, '-x-') !== false) - { - $user_lang = substr($user_lang, 0, strpos($user_lang, '-x-')); - } - - $s_search_hidden_fields = array(); - if ($_SID) - { - $s_search_hidden_fields['sid'] = $_SID; - } - - if (!empty($_EXTRA_URL)) - { - foreach ($_EXTRA_URL as $url_param) - { - $url_param = explode('=', $url_param, 2); - $s_search_hidden_fields[$url_param[0]] = $url_param[1]; - } - } - - $dt = $user->create_datetime(); - $timezone_offset = $user->lang(array('timezones', 'UTC_OFFSET'), phpbb_format_timezone_offset($dt->getOffset())); - $timezone_name = $user->timezone->getName(); - if (isset($user->lang['timezones'][$timezone_name])) - { - $timezone_name = $user->lang['timezones'][$timezone_name]; - } - - // Output the notifications - $notifications = false; - if ($config['load_notifications'] && $config['allow_board_notifications'] && $user->data['user_id'] != ANONYMOUS && $user->data['user_type'] != USER_IGNORE) - { - /* @var $phpbb_notifications \phpbb\notification\manager */ - $phpbb_notifications = $phpbb_container->get('notification_manager'); - - $notifications = $phpbb_notifications->load_notifications('notification.method.board', array( - 'all_unread' => true, - 'limit' => 5, - )); - - foreach ($notifications['notifications'] as $notification) - { - $template->assign_block_vars('notifications', $notification->prepare_for_display()); - } - } - - /** @var \phpbb\controller\helper $controller_helper */ - $controller_helper = $phpbb_container->get('controller.helper'); - $notification_mark_hash = generate_link_hash('mark_all_notifications_read'); - - $s_login_redirect = build_hidden_fields(array('redirect' => $phpbb_path_helper->remove_web_root_path(build_url()))); - /** - * Workaround for missing template variable in pre phpBB 3.2.6 styles. - * @deprecated 3.2.7 (To be removed: 3.3.0-a1) - */ - $form_token_login = $template->retrieve_var('S_FORM_TOKEN_LOGIN'); - if (!empty($form_token_login)) - { - $s_login_redirect .= $form_token_login; - // Remove S_FORM_TOKEN_LOGIN as it's already appended to S_LOGIN_REDIRECT - $template->assign_var('S_FORM_TOKEN_LOGIN', ''); - } - - // The following assigns all _common_ variables that may be used at any point in a template. - $template->assign_vars(array( - 'SITENAME' => $config['sitename'], - 'SITE_DESCRIPTION' => $config['site_desc'], - 'PAGE_TITLE' => $page_title, - 'SCRIPT_NAME' => str_replace('.' . $phpEx, '', $user->page['page_name']), - 'LAST_VISIT_DATE' => sprintf($user->lang['YOU_LAST_VISIT'], $s_last_visit), - 'LAST_VISIT_YOU' => $s_last_visit, - 'CURRENT_TIME' => sprintf($user->lang['CURRENT_TIME'], $user->format_date(time(), false, true)), - 'TOTAL_USERS_ONLINE' => $l_online_users, - 'LOGGED_IN_USER_LIST' => $online_userlist, - 'RECORD_USERS' => $l_online_record, - - 'PRIVATE_MESSAGE_COUNT' => (!empty($user->data['user_unread_privmsg'])) ? $user->data['user_unread_privmsg'] : 0, - 'CURRENT_USER_AVATAR' => phpbb_get_user_avatar($user->data), - 'CURRENT_USERNAME_SIMPLE' => get_username_string('no_profile', $user->data['user_id'], $user->data['username'], $user->data['user_colour']), - 'CURRENT_USERNAME_FULL' => get_username_string('full', $user->data['user_id'], $user->data['username'], $user->data['user_colour']), - 'UNREAD_NOTIFICATIONS_COUNT' => ($notifications !== false) ? $notifications['unread_count'] : '', - 'NOTIFICATIONS_COUNT' => ($notifications !== false) ? $notifications['unread_count'] : '', - 'U_VIEW_ALL_NOTIFICATIONS' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=ucp_notifications'), - 'U_MARK_ALL_NOTIFICATIONS' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=ucp_notifications&mode=notification_list&mark=all&token=' . $notification_mark_hash), - 'U_NOTIFICATION_SETTINGS' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=ucp_notifications&mode=notification_options'), - 'S_NOTIFICATIONS_DISPLAY' => $config['load_notifications'] && $config['allow_board_notifications'], - - 'S_USER_NEW_PRIVMSG' => $user->data['user_new_privmsg'], - 'S_USER_UNREAD_PRIVMSG' => $user->data['user_unread_privmsg'], - 'S_USER_NEW' => $user->data['user_new'], - - 'SID' => $SID, - '_SID' => $_SID, - 'SESSION_ID' => $user->session_id, - 'ROOT_PATH' => $web_path, - 'BOARD_URL' => $board_url, - - 'L_LOGIN_LOGOUT' => $l_login_logout, - 'L_INDEX' => ($config['board_index_text'] !== '') ? $config['board_index_text'] : $user->lang['FORUM_INDEX'], - 'L_SITE_HOME' => ($config['site_home_text'] !== '') ? $config['site_home_text'] : $user->lang['HOME'], - 'L_ONLINE_EXPLAIN' => $l_online_time, - - 'U_PRIVATEMSGS' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&folder=inbox'), - 'U_RETURN_INBOX' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&folder=inbox'), - 'U_MEMBERLIST' => append_sid("{$phpbb_root_path}memberlist.$phpEx"), - 'U_VIEWONLINE' => ($auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel')) ? append_sid("{$phpbb_root_path}viewonline.$phpEx") : '', - 'U_LOGIN_LOGOUT' => $u_login_logout, - 'U_INDEX' => append_sid("{$phpbb_root_path}index.$phpEx"), - 'U_SEARCH' => append_sid("{$phpbb_root_path}search.$phpEx"), - 'U_SITE_HOME' => $config['site_home_url'], - 'U_REGISTER' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register'), - 'U_PROFILE' => append_sid("{$phpbb_root_path}ucp.$phpEx"), - 'U_USER_PROFILE' => get_username_string('profile', $user->data['user_id'], $user->data['username'], $user->data['user_colour']), - 'U_MODCP' => append_sid("{$phpbb_root_path}mcp.$phpEx", false, true, $user->session_id), - 'U_FAQ' => $controller_helper->route('phpbb_help_faq_controller'), - 'U_SEARCH_SELF' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=egosearch'), - 'U_SEARCH_NEW' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=newposts'), - 'U_SEARCH_UNANSWERED' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=unanswered'), - 'U_SEARCH_UNREAD' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=unreadposts'), - 'U_SEARCH_ACTIVE_TOPICS'=> append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=active_topics'), - 'U_DELETE_COOKIES' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=delete_cookies'), - 'U_CONTACT_US' => ($config['contact_admin_form_enable'] && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contactadmin') : '', - 'U_TEAM' => (!$auth->acl_get('u_viewprofile')) ? '' : append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=team'), - 'U_TERMS_USE' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=terms'), - 'U_PRIVACY' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=privacy'), - 'UA_PRIVACY' => addslashes(append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=privacy')), - 'U_RESTORE_PERMISSIONS' => ($user->data['user_perm_from'] && $auth->acl_get('a_switchperm')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=restore_perm') : '', - 'U_FEED' => $controller_helper->route('phpbb_feed_index'), - - 'S_USER_LOGGED_IN' => ($user->data['user_id'] != ANONYMOUS) ? true : false, - 'S_AUTOLOGIN_ENABLED' => ($config['allow_autologin']) ? true : false, - 'S_BOARD_DISABLED' => ($config['board_disable']) ? true : false, - 'S_REGISTERED_USER' => (!empty($user->data['is_registered'])) ? true : false, - 'S_IS_BOT' => (!empty($user->data['is_bot'])) ? true : false, - 'S_USER_LANG' => $user_lang, - 'S_USER_BROWSER' => (isset($user->data['session_browser'])) ? $user->data['session_browser'] : $user->lang['UNKNOWN_BROWSER'], - 'S_USERNAME' => $user->data['username'], - 'S_CONTENT_DIRECTION' => $user->lang['DIRECTION'], - 'S_CONTENT_FLOW_BEGIN' => ($user->lang['DIRECTION'] == 'ltr') ? 'left' : 'right', - 'S_CONTENT_FLOW_END' => ($user->lang['DIRECTION'] == 'ltr') ? 'right' : 'left', - 'S_CONTENT_ENCODING' => 'UTF-8', - 'S_TIMEZONE' => sprintf($user->lang['ALL_TIMES'], $timezone_offset, $timezone_name), - 'S_DISPLAY_ONLINE_LIST' => ($l_online_time) ? 1 : 0, - 'S_DISPLAY_SEARCH' => (!$config['load_search']) ? 0 : (isset($auth) ? ($auth->acl_get('u_search') && $auth->acl_getf_global('f_search')) : 1), - 'S_DISPLAY_PM' => ($config['allow_privmsg'] && !empty($user->data['is_registered']) && ($auth->acl_get('u_readpm') || $auth->acl_get('u_sendpm'))) ? true : false, - 'S_DISPLAY_MEMBERLIST' => (isset($auth)) ? $auth->acl_get('u_viewprofile') : 0, - 'S_NEW_PM' => ($s_privmsg_new) ? 1 : 0, - 'S_REGISTER_ENABLED' => ($config['require_activation'] != USER_ACTIVATION_DISABLE) ? true : false, - 'S_FORUM_ID' => $forum_id, - 'S_TOPIC_ID' => $topic_id, - - 'S_LOGIN_ACTION' => ((!defined('ADMIN_START')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login') : append_sid("{$phpbb_admin_path}index.$phpEx", false, true, $user->session_id)), - 'S_LOGIN_REDIRECT' => $s_login_redirect, - - 'S_ENABLE_FEEDS' => ($config['feed_enable']) ? true : false, - 'S_ENABLE_FEEDS_OVERALL' => ($config['feed_overall']) ? true : false, - 'S_ENABLE_FEEDS_FORUMS' => ($config['feed_overall_forums']) ? true : false, - 'S_ENABLE_FEEDS_TOPICS' => ($config['feed_topics_new']) ? true : false, - 'S_ENABLE_FEEDS_TOPICS_ACTIVE' => ($config['feed_topics_active']) ? true : false, - 'S_ENABLE_FEEDS_NEWS' => ($s_feed_news) ? true : false, - - 'S_LOAD_UNREADS' => ($config['load_unreads_search'] && ($config['load_anon_lastread'] || $user->data['is_registered'])) ? true : false, - - 'S_SEARCH_HIDDEN_FIELDS' => build_hidden_fields($s_search_hidden_fields), - - 'T_ASSETS_VERSION' => $config['assets_version'], - 'T_ASSETS_PATH' => "{$web_path}assets", - 'T_THEME_PATH' => "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme', - 'T_TEMPLATE_PATH' => "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/template', - 'T_SUPER_TEMPLATE_PATH' => "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/template', - 'T_IMAGES_PATH' => "{$web_path}images/", - 'T_SMILIES_PATH' => "{$web_path}{$config['smilies_path']}/", - 'T_AVATAR_PATH' => "{$web_path}{$config['avatar_path']}/", - 'T_AVATAR_GALLERY_PATH' => "{$web_path}{$config['avatar_gallery_path']}/", - 'T_ICONS_PATH' => "{$web_path}{$config['icons_path']}/", - 'T_RANKS_PATH' => "{$web_path}{$config['ranks_path']}/", - 'T_UPLOAD_PATH' => "{$web_path}{$config['upload_path']}/", - 'T_STYLESHEET_LINK' => "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme/stylesheet.css?assets_version=' . $config['assets_version'], - 'T_STYLESHEET_LANG_LINK'=> "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme/' . $user->lang_name . '/stylesheet.css?assets_version=' . $config['assets_version'], - 'T_FONT_AWESOME_LINK' => !empty($config['allow_cdn']) && !empty($config['load_font_awesome_url']) ? $config['load_font_awesome_url'] : "{$web_path}assets/css/font-awesome.min.css?assets_version=" . $config['assets_version'], - 'T_JQUERY_LINK' => !empty($config['allow_cdn']) && !empty($config['load_jquery_url']) ? $config['load_jquery_url'] : "{$web_path}assets/javascript/jquery.min.js?assets_version=" . $config['assets_version'], - 'S_ALLOW_CDN' => !empty($config['allow_cdn']), - 'S_COOKIE_NOTICE' => !empty($config['cookie_notice']), - - 'T_THEME_NAME' => rawurlencode($user->style['style_path']), - 'T_THEME_LANG_NAME' => $user->lang_name, - 'T_TEMPLATE_NAME' => $user->style['style_path'], - 'T_SUPER_TEMPLATE_NAME' => rawurlencode((isset($user->style['style_parent_tree']) && $user->style['style_parent_tree']) ? $user->style['style_parent_tree'] : $user->style['style_path']), - 'T_IMAGES' => 'images', - 'T_SMILIES' => $config['smilies_path'], - 'T_AVATAR' => $config['avatar_path'], - 'T_AVATAR_GALLERY' => $config['avatar_gallery_path'], - 'T_ICONS' => $config['icons_path'], - 'T_RANKS' => $config['ranks_path'], - 'T_UPLOAD' => $config['upload_path'], - - 'SITE_LOGO_IMG' => $user->img('site_logo'), - )); - - $http_headers = array(); - - if ($send_headers) - { - // An array of http headers that phpbb will set. The following event may override these. - $http_headers += array( - // application/xhtml+xml not used because of IE - 'Content-type' => 'text/html; charset=UTF-8', - 'Cache-Control' => 'private, no-cache="set-cookie"', - 'Expires' => gmdate('D, d M Y H:i:s', time()) . ' GMT', - ); - if (!empty($user->data['is_bot'])) - { - // Let reverse proxies know we detected a bot. - $http_headers['X-PHPBB-IS-BOT'] = 'yes'; - } - } - - /** - * Execute code and/or overwrite _common_ template variables after they have been assigned. - * - * @event core.page_header_after - * @var string page_title Page title - * @var bool display_online_list Do we display online users list - * @var string item Restrict online users to a certain - * session item, e.g. forum for - * session_forum_id - * @var int item_id Restrict online users to item id - * @var array http_headers HTTP headers that should be set by phpbb - * - * @since 3.1.0-b3 - */ - $vars = array('page_title', 'display_online_list', 'item_id', 'item', 'http_headers'); - extract($phpbb_dispatcher->trigger_event('core.page_header_after', compact($vars))); - - foreach ($http_headers as $hname => $hval) - { - header((string) $hname . ': ' . (string) $hval); - } - - return; -} - -/** -* Check and display the SQL report if requested. -* -* @param \phpbb\request\request_interface $request Request object -* @param \phpbb\auth\auth $auth Auth object -* @param \phpbb\db\driver\driver_interface $db Database connection -*/ -function phpbb_check_and_display_sql_report(\phpbb\request\request_interface $request, \phpbb\auth\auth $auth, \phpbb\db\driver\driver_interface $db) -{ - if ($request->variable('explain', false) && $auth->acl_get('a_') && defined('DEBUG')) - { - $db->sql_report('display'); - } -} - -/** -* Generate the debug output string -* -* @param \phpbb\db\driver\driver_interface $db Database connection -* @param \phpbb\config\config $config Config object -* @param \phpbb\auth\auth $auth Auth object -* @param \phpbb\user $user User object -* @param \phpbb\event\dispatcher_interface $phpbb_dispatcher Event dispatcher -* @return string -*/ -function phpbb_generate_debug_output(\phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\auth\auth $auth, \phpbb\user $user, \phpbb\event\dispatcher_interface $phpbb_dispatcher) -{ - $debug_info = array(); - - // Output page creation time - if (defined('PHPBB_DISPLAY_LOAD_TIME')) - { - if (isset($GLOBALS['starttime'])) - { - $totaltime = microtime(true) - $GLOBALS['starttime']; - $debug_info[] = sprintf('Time: %.3fs', $db->get_sql_time(), ($totaltime - $db->get_sql_time()), $totaltime); - } - - $debug_info[] = sprintf('Queries: %d', $db->sql_num_queries(true), $db->sql_num_queries()); - - $memory_usage = memory_get_peak_usage(); - if ($memory_usage) - { - $memory_usage = get_formatted_filesize($memory_usage); - - $debug_info[] = 'Peak Memory Usage: ' . $memory_usage; - } - } - - if (defined('DEBUG')) - { - $debug_info[] = 'GZIP: ' . (($config['gzip_compress'] && @extension_loaded('zlib')) ? 'On' : 'Off'); - - if ($user->load) - { - $debug_info[] = 'Load: ' . $user->load; - } - - if ($auth->acl_get('a_')) - { - $debug_info[] = 'SQL Explain'; - } - } - - /** - * Modify debug output information - * - * @event core.phpbb_generate_debug_output - * @var array debug_info Array of strings with debug information - * - * @since 3.1.0-RC3 - */ - $vars = array('debug_info'); - extract($phpbb_dispatcher->trigger_event('core.phpbb_generate_debug_output', compact($vars))); - - return implode(' | ', $debug_info); -} - -/** -* Generate page footer -* -* @param bool $run_cron Whether or not to run the cron -* @param bool $display_template Whether or not to display the template -* @param bool $exit_handler Whether or not to run the exit_handler() -*/ -function page_footer($run_cron = true, $display_template = true, $exit_handler = true) -{ - global $db, $config, $template, $user, $auth, $cache, $phpEx; - global $request, $phpbb_dispatcher, $phpbb_admin_path; - - // A listener can set this variable to `true` when it overrides this function - $page_footer_override = false; - - /** - * Execute code and/or overwrite page_footer() - * - * @event core.page_footer - * @var bool run_cron Shall we run cron tasks - * @var bool page_footer_override Shall we return instead of running - * the rest of page_footer() - * @since 3.1.0-a1 - */ - $vars = array('run_cron', 'page_footer_override'); - extract($phpbb_dispatcher->trigger_event('core.page_footer', compact($vars))); - - if ($page_footer_override) - { - return; - } - - phpbb_check_and_display_sql_report($request, $auth, $db); - - $template->assign_vars(array( - 'DEBUG_OUTPUT' => phpbb_generate_debug_output($db, $config, $auth, $user, $phpbb_dispatcher), - 'TRANSLATION_INFO' => (!empty($user->lang['TRANSLATION_INFO'])) ? $user->lang['TRANSLATION_INFO'] : '', - 'CREDIT_LINE' => $user->lang('POWERED_BY', 'phpBB® Forum Software © phpBB Limited'), - - 'U_ACP' => ($auth->acl_get('a_') && !empty($user->data['is_registered'])) ? append_sid("{$phpbb_admin_path}index.$phpEx", false, true, $user->session_id) : '') - ); - - // Call cron-type script - $call_cron = false; - if (!defined('IN_CRON') && !$config['use_system_cron'] && $run_cron && !$config['board_disable'] && !$user->data['is_bot'] && !$cache->get('_cron.lock_check')) - { - $call_cron = true; - $time_now = (!empty($user->time_now) && is_int($user->time_now)) ? $user->time_now : time(); - - // Any old lock present? - if (!empty($config['cron_lock'])) - { - $cron_time = explode(' ', $config['cron_lock']); - - // If 1 hour lock is present we do not call cron.php - if ($cron_time[0] + 3600 >= $time_now) - { - $call_cron = false; - } - } - } - - // Call cron job? - if ($call_cron) - { - global $phpbb_container; - - /* @var $cron \phpbb\cron\manager */ - $cron = $phpbb_container->get('cron.manager'); - $task = $cron->find_one_ready_task(); - - if ($task) - { - $url = $task->get_url(); - $template->assign_var('RUN_CRON_TASK', 'cron'); - } - else - { - $cache->put('_cron.lock_check', true, 60); - } - } - - /** - * Execute code and/or modify output before displaying the template. - * - * @event core.page_footer_after - * @var bool display_template Whether or not to display the template - * @var bool exit_handler Whether or not to run the exit_handler() - * - * @since 3.1.0-RC5 - */ - $vars = array('display_template', 'exit_handler'); - extract($phpbb_dispatcher->trigger_event('core.page_footer_after', compact($vars))); - - if ($display_template) - { - $template->display('body'); - } - - garbage_collection(); - - if ($exit_handler) - { - exit_handler(); - } -} - -/** -* Closing the cache object and the database -* Cool function name, eh? We might want to add operations to it later -*/ -function garbage_collection() -{ - global $cache, $db; - global $phpbb_dispatcher; - - if (!empty($phpbb_dispatcher)) - { - /** - * Unload some objects, to free some memory, before we finish our task - * - * @event core.garbage_collection - * @since 3.1.0-a1 - */ - $phpbb_dispatcher->dispatch('core.garbage_collection'); - } - - // Unload cache, must be done before the DB connection if closed - if (!empty($cache)) - { - $cache->unload(); - } - - // Close our DB connection. - if (!empty($db)) - { - $db->sql_close(); - } -} - -/** -* Handler for exit calls in phpBB. -* This function supports hooks. -* -* Note: This function is called after the template has been outputted. -*/ -function exit_handler() -{ - global $phpbb_hook; - - if (!empty($phpbb_hook) && $phpbb_hook->call_hook(__FUNCTION__)) - { - if ($phpbb_hook->hook_return(__FUNCTION__)) - { - return $phpbb_hook->hook_return_result(__FUNCTION__); - } - } - - // As a pre-caution... some setups display a blank page if the flush() is not there. - (ob_get_level() > 0) ? @ob_flush() : @flush(); - - exit; -} - -/** -* Handler for init calls in phpBB. This function is called in \phpbb\user::setup(); -* This function supports hooks. -*/ -function phpbb_user_session_handler() -{ - global $phpbb_hook; - - if (!empty($phpbb_hook) && $phpbb_hook->call_hook(__FUNCTION__)) - { - if ($phpbb_hook->hook_return(__FUNCTION__)) - { - return $phpbb_hook->hook_return_result(__FUNCTION__); - } - } - - return; -} - -/** -* Casts a numeric string $input to an appropriate numeric type (i.e. integer or float) -* -* @param string $input A numeric string. -* -* @return int|float Integer $input if $input fits integer, -* float $input otherwise. -*/ -function phpbb_to_numeric($input) -{ - return ($input > PHP_INT_MAX) ? (float) $input : (int) $input; -} - -/** -* Get the board contact details (e.g. for emails) -* -* @param \phpbb\config\config $config -* @param string $phpEx -* @return string -*/ -function phpbb_get_board_contact(\phpbb\config\config $config, $phpEx) -{ - if ($config['contact_admin_form_enable']) - { - return generate_board_url() . '/memberlist.' . $phpEx . '?mode=contactadmin'; - } - else - { - return $config['board_contact']; - } -} - -/** -* Get a clickable board contact details link -* -* @param \phpbb\config\config $config -* @param string $phpbb_root_path -* @param string $phpEx -* @return string -*/ -function phpbb_get_board_contact_link(\phpbb\config\config $config, $phpbb_root_path, $phpEx) -{ - if ($config['contact_admin_form_enable'] && $config['email_enable']) - { - return append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contactadmin'); - } - else - { - return 'mailto:' . htmlspecialchars($config['board_contact']); - } -} diff --git a/install/update/old/includes/functions_acp.php b/install/update/old/includes/functions_acp.php deleted file mode 100644 index dd326c3..0000000 --- a/install/update/old/includes/functions_acp.php +++ /dev/null @@ -1,726 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* Header for acp pages -*/ -function adm_page_header($page_title) -{ - global $config, $user, $template; - global $phpbb_root_path, $phpbb_admin_path, $phpEx, $SID, $_SID; - global $phpbb_dispatcher, $phpbb_container; - - if (defined('HEADER_INC')) - { - return; - } - - define('HEADER_INC', true); - - // A listener can set this variable to `true` when it overrides this function - $adm_page_header_override = false; - - /** - * Execute code and/or overwrite adm_page_header() - * - * @event core.adm_page_header - * @var string page_title Page title - * @var bool adm_page_header_override Shall we return instead of - * running the rest of adm_page_header() - * @since 3.1.0-a1 - */ - $vars = array('page_title', 'adm_page_header_override'); - extract($phpbb_dispatcher->trigger_event('core.adm_page_header', compact($vars))); - - if ($adm_page_header_override) - { - return; - } - - $user->update_session_infos(); - - // gzip_compression - if ($config['gzip_compress']) - { - if (@extension_loaded('zlib') && !headers_sent()) - { - ob_start('ob_gzhandler'); - } - } - - $template->assign_vars(array( - 'PAGE_TITLE' => $page_title, - 'USERNAME' => $user->data['username'], - - 'SID' => $SID, - '_SID' => $_SID, - 'SESSION_ID' => $user->session_id, - 'ROOT_PATH' => $phpbb_root_path, - 'ADMIN_ROOT_PATH' => $phpbb_admin_path, - - 'U_LOGOUT' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=logout'), - 'U_ADM_LOGOUT' => append_sid("{$phpbb_admin_path}index.$phpEx", 'action=admlogout'), - 'U_ADM_INDEX' => append_sid("{$phpbb_admin_path}index.$phpEx"), - 'U_INDEX' => append_sid("{$phpbb_root_path}index.$phpEx"), - - 'T_IMAGES_PATH' => "{$phpbb_root_path}images/", - 'T_SMILIES_PATH' => "{$phpbb_root_path}{$config['smilies_path']}/", - 'T_AVATAR_PATH' => "{$phpbb_root_path}{$config['avatar_path']}/", - 'T_AVATAR_GALLERY_PATH' => "{$phpbb_root_path}{$config['avatar_gallery_path']}/", - 'T_ICONS_PATH' => "{$phpbb_root_path}{$config['icons_path']}/", - 'T_RANKS_PATH' => "{$phpbb_root_path}{$config['ranks_path']}/", - 'T_UPLOAD_PATH' => "{$phpbb_root_path}{$config['upload_path']}/", - 'T_FONT_AWESOME_LINK' => !empty($config['allow_cdn']) && !empty($config['load_font_awesome_url']) ? $config['load_font_awesome_url'] : "{$phpbb_root_path}assets/css/font-awesome.min.css?assets_version=" . $config['assets_version'], - - 'T_ASSETS_VERSION' => $config['assets_version'], - - 'ICON_MOVE_UP' => '' . $user->lang['MOVE_UP'] . '', - 'ICON_MOVE_UP_DISABLED' => '' . $user->lang['MOVE_UP'] . '', - 'ICON_MOVE_DOWN' => '' . $user->lang['MOVE_DOWN'] . '', - 'ICON_MOVE_DOWN_DISABLED' => '' . $user->lang['MOVE_DOWN'] . '', - 'ICON_EDIT' => '' . $user->lang['EDIT'] . '', - 'ICON_EDIT_DISABLED' => '' . $user->lang['EDIT'] . '', - 'ICON_DELETE' => '' . $user->lang['DELETE'] . '', - 'ICON_DELETE_DISABLED' => '' . $user->lang['DELETE'] . '', - 'ICON_SYNC' => '' . $user->lang['RESYNC'] . '', - 'ICON_SYNC_DISABLED' => '' . $user->lang['RESYNC'] . '', - - 'S_USER_LANG' => $user->lang['USER_LANG'], - 'S_CONTENT_DIRECTION' => $user->lang['DIRECTION'], - 'S_CONTENT_ENCODING' => 'UTF-8', - 'S_CONTENT_FLOW_BEGIN' => ($user->lang['DIRECTION'] == 'ltr') ? 'left' : 'right', - 'S_CONTENT_FLOW_END' => ($user->lang['DIRECTION'] == 'ltr') ? 'right' : 'left', - - 'CONTAINER_EXCEPTION' => $phpbb_container->hasParameter('container_exception') ? $phpbb_container->getParameter('container_exception') : false, - )); - - // An array of http headers that phpbb will set. The following event may override these. - $http_headers = array( - // application/xhtml+xml not used because of IE - 'Content-type' => 'text/html; charset=UTF-8', - 'Cache-Control' => 'private, no-cache="set-cookie"', - 'Expires' => gmdate('D, d M Y H:i:s', time()) . ' GMT', - ); - - /** - * Execute code and/or overwrite _common_ template variables after they have been assigned. - * - * @event core.adm_page_header_after - * @var string page_title Page title - * @var array http_headers HTTP headers that should be set by phpbb - * - * @since 3.1.0-RC3 - */ - $vars = array('page_title', 'http_headers'); - extract($phpbb_dispatcher->trigger_event('core.adm_page_header_after', compact($vars))); - - foreach ($http_headers as $hname => $hval) - { - header((string) $hname . ': ' . (string) $hval); - } - - return; -} - -/** -* Page footer for acp pages -*/ -function adm_page_footer($copyright_html = true) -{ - global $db, $config, $template, $user, $auth; - global $phpbb_root_path; - global $request, $phpbb_dispatcher; - - // A listener can set this variable to `true` when it overrides this function - $adm_page_footer_override = false; - - /** - * Execute code and/or overwrite adm_page_footer() - * - * @event core.adm_page_footer - * @var bool copyright_html Shall we display the copyright? - * @var bool adm_page_footer_override Shall we return instead of - * running the rest of adm_page_footer() - * @since 3.1.0-a1 - */ - $vars = array('copyright_html', 'adm_page_footer_override'); - extract($phpbb_dispatcher->trigger_event('core.adm_page_footer', compact($vars))); - - if ($adm_page_footer_override) - { - return; - } - - phpbb_check_and_display_sql_report($request, $auth, $db); - - $template->assign_vars(array( - 'DEBUG_OUTPUT' => phpbb_generate_debug_output($db, $config, $auth, $user, $phpbb_dispatcher), - 'TRANSLATION_INFO' => (!empty($user->lang['TRANSLATION_INFO'])) ? $user->lang['TRANSLATION_INFO'] : '', - 'S_COPYRIGHT_HTML' => $copyright_html, - 'CREDIT_LINE' => $user->lang('POWERED_BY', 'phpBB® Forum Software © phpBB Limited'), - 'T_JQUERY_LINK' => !empty($config['allow_cdn']) && !empty($config['load_jquery_url']) ? $config['load_jquery_url'] : "{$phpbb_root_path}assets/javascript/jquery.min.js", - 'S_ALLOW_CDN' => !empty($config['allow_cdn']), - 'VERSION' => $config['version']) - ); - - $template->display('body'); - - garbage_collection(); - exit_handler(); -} - -/** -* Generate back link for acp pages -*/ -function adm_back_link($u_action) -{ - global $user; - return '

« ' . $user->lang['BACK_TO_PREV'] . ''; -} - -/** -* Build select field options in acp pages -*/ -function build_select($option_ary, $option_default = false) -{ - global $user; - - $html = ''; - foreach ($option_ary as $value => $title) - { - $selected = ($option_default !== false && $value == $option_default) ? ' selected="selected"' : ''; - $html .= ''; - } - - return $html; -} - -/** -* Build radio fields in acp pages -*/ -function h_radio($name, $input_ary, $input_default = false, $id = false, $key = false, $separator = '') -{ - global $user; - - $html = ''; - $id_assigned = false; - foreach ($input_ary as $value => $title) - { - $selected = ($input_default !== false && $value == $input_default) ? ' checked="checked"' : ''; - $html .= '' . $separator; - $id_assigned = true; - } - - return $html; -} - -/** -* Build configuration template for acp configuration pages -*/ -function build_cfg_template($tpl_type, $key, &$new_ary, $config_key, $vars) -{ - global $user, $module, $phpbb_dispatcher; - - $tpl = ''; - $name = 'config[' . $config_key . ']'; - - // Make sure there is no notice printed out for non-existent config options (we simply set them) - if (!isset($new_ary[$config_key])) - { - $new_ary[$config_key] = ''; - } - - switch ($tpl_type[0]) - { - case 'password': - if ($new_ary[$config_key] !== '') - { - // replace passwords with asterixes - $new_ary[$config_key] = '********'; - } - case 'text': - case 'url': - case 'email': - case 'tel': - case 'search': - // maxlength and size are only valid for these types and will be - // ignored for other input types. - $size = (int) $tpl_type[1]; - $maxlength = (int) $tpl_type[2]; - - $tpl = ''; - break; - - case 'color': - case 'datetime': - case 'datetime-local': - case 'month': - case 'week': - $tpl = ''; - break; - - case 'date': - case 'time': - case 'number': - case 'range': - $max = ''; - $min = ( isset($tpl_type[1]) ) ? (int) $tpl_type[1] : false; - if ( isset($tpl_type[2]) ) - { - $max = (int) $tpl_type[2]; - } - - $tpl = ''; - break; - - case 'dimension': - $max = ''; - - $min = (int) $tpl_type[1]; - - if ( isset($tpl_type[2]) ) - { - $max = (int) $tpl_type[2]; - } - - $tpl = ' x '; - break; - - case 'textarea': - $rows = (int) $tpl_type[1]; - $cols = (int) $tpl_type[2]; - - $tpl = ''; - break; - - case 'radio': - $key_yes = ($new_ary[$config_key]) ? ' checked="checked"' : ''; - $key_no = (!$new_ary[$config_key]) ? ' checked="checked"' : ''; - - $tpl_type_cond = explode('_', $tpl_type[1]); - $type_no = ($tpl_type_cond[0] == 'disabled' || $tpl_type_cond[0] == 'enabled') ? false : true; - - $tpl_no = ''; - $tpl_yes = ''; - - $tpl = ($tpl_type_cond[0] == 'yes' || $tpl_type_cond[0] == 'enabled') ? $tpl_yes . $tpl_no : $tpl_no . $tpl_yes; - break; - - case 'select': - case 'custom': - - if (isset($vars['method'])) - { - $call = array($module->module, $vars['method']); - } - else if (isset($vars['function'])) - { - $call = $vars['function']; - } - else - { - break; - } - - if (isset($vars['params'])) - { - $args = array(); - foreach ($vars['params'] as $value) - { - switch ($value) - { - case '{CONFIG_VALUE}': - $value = $new_ary[$config_key]; - break; - - case '{KEY}': - $value = $key; - break; - } - - $args[] = $value; - } - } - else - { - $args = array($new_ary[$config_key], $key); - } - - $return = call_user_func_array($call, $args); - - if ($tpl_type[0] == 'select') - { - $size = (isset($tpl_type[1])) ? (int) $tpl_type[1] : 1; - $data_toggle = (!empty($tpl_type[2])) ? ' data-togglable-settings="true"' : ''; - - $tpl = ''; - } - else - { - $tpl = $return; - } - - break; - - default: - break; - } - - if (isset($vars['append'])) - { - $tpl .= $vars['append']; - } - - $new = $new_ary; - /** - * Overwrite the html code we display for the config value - * - * @event core.build_config_template - * @var array tpl_type Config type array: - * 0 => data type - * 1 [optional] => string: size, int: minimum - * 2 [optional] => string: max. length, int: maximum - * @var string key Should be used for the id attribute in html - * @var array new Array with the config values we display - * @var string name Should be used for the name attribute - * @var array vars Array with the options for the config - * @var string tpl The resulting html code we display - * @since 3.1.0-a1 - */ - $vars = array('tpl_type', 'key', 'new', 'name', 'vars', 'tpl'); - extract($phpbb_dispatcher->trigger_event('core.build_config_template', compact($vars))); - $new_ary = $new; - unset($new); - - return $tpl; -} - -/** -* Going through a config array and validate values, writing errors to $error. The validation method accepts parameters separated by ':' for string and int. -* The first parameter defines the type to be used, the second the lower bound and the third the upper bound. Only the type is required. -*/ -function validate_config_vars($config_vars, &$cfg_array, &$error) -{ - global $phpbb_root_path, $user, $phpbb_dispatcher, $phpbb_filesystem, $language; - - $type = 0; - $min = 1; - $max = 2; - - foreach ($config_vars as $config_name => $config_definition) - { - if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false) - { - continue; - } - - if (!isset($config_definition['validate'])) - { - continue; - } - - $validator = explode(':', $config_definition['validate']); - - // Validate a bit. ;) (0 = type, 1 = min, 2= max) - switch ($validator[$type]) - { - case 'url': - $cfg_array[$config_name] = trim($cfg_array[$config_name]); - - if (!empty($cfg_array[$config_name]) && !preg_match('#^' . get_preg_expression('url') . '$#iu', $cfg_array[$config_name])) - { - $error[] = $language->lang('URL_INVALID', $language->lang($config_definition['lang'])); - } - - // no break here - - case 'string': - $length = utf8_strlen($cfg_array[$config_name]); - - // the column is a VARCHAR - $validator[$max] = (isset($validator[$max])) ? min(255, $validator[$max]) : 255; - - if (isset($validator[$min]) && $length < $validator[$min]) - { - $error[] = sprintf($user->lang['SETTING_TOO_SHORT'], $user->lang[$config_definition['lang']], $validator[$min]); - } - else if (isset($validator[$max]) && $length > $validator[2]) - { - $error[] = sprintf($user->lang['SETTING_TOO_LONG'], $user->lang[$config_definition['lang']], $validator[$max]); - } - break; - - case 'bool': - $cfg_array[$config_name] = ($cfg_array[$config_name]) ? 1 : 0; - break; - - case 'int': - $cfg_array[$config_name] = (int) $cfg_array[$config_name]; - - if (isset($validator[$min]) && $cfg_array[$config_name] < $validator[$min]) - { - $error[] = sprintf($user->lang['SETTING_TOO_LOW'], $user->lang[$config_definition['lang']], $validator[$min]); - } - else if (isset($validator[$max]) && $cfg_array[$config_name] > $validator[$max]) - { - $error[] = sprintf($user->lang['SETTING_TOO_BIG'], $user->lang[$config_definition['lang']], $validator[$max]); - } - - if (strpos($config_name, '_max') !== false) - { - // Min/max pairs of settings should ensure that min <= max - // Replace _max with _min to find the name of the minimum - // corresponding configuration variable - $min_name = str_replace('_max', '_min', $config_name); - - if (isset($cfg_array[$min_name]) && is_numeric($cfg_array[$min_name]) && $cfg_array[$config_name] < $cfg_array[$min_name]) - { - // A minimum value exists and the maximum value is less than it - $error[] = sprintf($user->lang['SETTING_TOO_LOW'], $user->lang[$config_definition['lang']], (int) $cfg_array[$min_name]); - } - } - break; - - case 'email': - if (!preg_match('/^' . get_preg_expression('email') . '$/i', $cfg_array[$config_name])) - { - $error[] = $user->lang['EMAIL_INVALID_EMAIL']; - } - break; - - // Absolute path - case 'script_path': - if (!$cfg_array[$config_name]) - { - break; - } - - $destination = str_replace('\\', '/', $cfg_array[$config_name]); - - if ($destination !== '/') - { - // Adjust destination path (no trailing slash) - if (substr($destination, -1, 1) == '/') - { - $destination = substr($destination, 0, -1); - } - - $destination = str_replace(array('../', './'), '', $destination); - - if ($destination[0] != '/') - { - $destination = '/' . $destination; - } - } - - $cfg_array[$config_name] = trim($destination); - - break; - - // Absolute path - case 'lang': - if (!$cfg_array[$config_name]) - { - break; - } - - $cfg_array[$config_name] = basename($cfg_array[$config_name]); - - if (!file_exists($phpbb_root_path . 'language/' . $cfg_array[$config_name] . '/')) - { - $error[] = $user->lang['WRONG_DATA_LANG']; - } - break; - - // Relative path (appended $phpbb_root_path) - case 'rpath': - case 'rwpath': - if (!$cfg_array[$config_name]) - { - break; - } - - $destination = $cfg_array[$config_name]; - - // Adjust destination path (no trailing slash) - if (substr($destination, -1, 1) == '/' || substr($destination, -1, 1) == '\\') - { - $destination = substr($destination, 0, -1); - } - - $destination = str_replace(array('../', '..\\', './', '.\\'), '', $destination); - if ($destination && ($destination[0] == '/' || $destination[0] == "\\")) - { - $destination = ''; - } - - $cfg_array[$config_name] = trim($destination); - - // Path being relative (still prefixed by phpbb_root_path), but with the ability to escape the root dir... - case 'path': - case 'wpath': - - if (!$cfg_array[$config_name]) - { - break; - } - - $cfg_array[$config_name] = trim($cfg_array[$config_name]); - - // Make sure no NUL byte is present... - if (strpos($cfg_array[$config_name], "\0") !== false || strpos($cfg_array[$config_name], '%00') !== false) - { - $cfg_array[$config_name] = ''; - break; - } - - $path = $phpbb_root_path . $cfg_array[$config_name]; - - if (!file_exists($path)) - { - $error[] = sprintf($user->lang['DIRECTORY_DOES_NOT_EXIST'], $cfg_array[$config_name]); - } - - if (file_exists($path) && !is_dir($path)) - { - $error[] = sprintf($user->lang['DIRECTORY_NOT_DIR'], $cfg_array[$config_name]); - } - - // Check if the path is writable - if ($config_definition['validate'] == 'wpath' || $config_definition['validate'] == 'rwpath') - { - if (file_exists($path) && !$phpbb_filesystem->is_writable($path)) - { - $error[] = sprintf($user->lang['DIRECTORY_NOT_WRITABLE'], $cfg_array[$config_name]); - } - } - - break; - - default: - /** - * Validate a config value - * - * @event core.validate_config_variable - * @var array cfg_array Array with config values - * @var string config_name Name of the config we validate - * @var array config_definition Array with the options for - * this config - * @var array error Array of errors, the errors should - * be strings only, language keys are - * not replaced afterwards - * @since 3.1.0-a1 - */ - $vars = array('cfg_array', 'config_name', 'config_definition', 'error'); - extract($phpbb_dispatcher->trigger_event('core.validate_config_variable', compact($vars))); - break; - } - } - - return; -} - -/** -* Checks whatever or not a variable is OK for use in the Database -* param mixed $value_ary An array of the form array(array('lang' => ..., 'value' => ..., 'column_type' =>))' -* param mixed $error The error array -*/ -function validate_range($value_ary, &$error) -{ - global $user; - - $column_types = array( - 'BOOL' => array('php_type' => 'int', 'min' => 0, 'max' => 1), - 'USINT' => array('php_type' => 'int', 'min' => 0, 'max' => 65535), - 'UINT' => array('php_type' => 'int', 'min' => 0, 'max' => (int) 0x7fffffff), - // Do not use (int) 0x80000000 - it evaluates to different - // values on 32-bit and 64-bit systems. - // Apparently -2147483648 is a float on 32-bit systems, - // despite fitting in an int, thus explicit cast is needed. - 'INT' => array('php_type' => 'int', 'min' => (int) -2147483648, 'max' => (int) 0x7fffffff), - 'TINT' => array('php_type' => 'int', 'min' => -128, 'max' => 127), - - 'VCHAR' => array('php_type' => 'string', 'min' => 0, 'max' => 255), - ); - foreach ($value_ary as $value) - { - $column = explode(':', $value['column_type']); - if (!isset($column_types[$column[0]])) - { - continue; - } - else - { - $type = $column_types[$column[0]]; - } - - switch ($type['php_type']) - { - case 'string' : - $max = (isset($column[1])) ? min($column[1],$type['max']) : $type['max']; - if (utf8_strlen($value['value']) > $max) - { - $error[] = sprintf($user->lang['SETTING_TOO_LONG'], $user->lang[$value['lang']], $max); - } - break; - - case 'int': - $min = (isset($column[1])) ? max($column[1],$type['min']) : $type['min']; - $max = (isset($column[2])) ? min($column[2],$type['max']) : $type['max']; - if ($value['value'] < $min) - { - $error[] = sprintf($user->lang['SETTING_TOO_LOW'], $user->lang[$value['lang']], $min); - } - else if ($value['value'] > $max) - { - $error[] = sprintf($user->lang['SETTING_TOO_BIG'], $user->lang[$value['lang']], $max); - } - break; - } - } -} - -/** -* Inserts new config display_vars into an exisiting display_vars array -* at the given position. -* -* @param array $display_vars An array of existing config display vars -* @param array $add_config_vars An array of new config display vars -* @param array $where Where to place the new config vars, -* before or after an exisiting config, as an array -* of the form: array('after' => 'config_name') or -* array('before' => 'config_name'). -* @return array The array of config display vars -*/ -function phpbb_insert_config_array($display_vars, $add_config_vars, $where) -{ - if (is_array($where) && array_key_exists(current($where), $display_vars)) - { - $position = array_search(current($where), array_keys($display_vars)) + ((key($where) == 'before') ? 0 : 1); - $display_vars = array_merge( - array_slice($display_vars, 0, $position), - $add_config_vars, - array_slice($display_vars, $position) - ); - } - - return $display_vars; -} diff --git a/install/update/old/includes/functions_admin.php b/install/update/old/includes/functions_admin.php deleted file mode 100644 index c19d48b..0000000 --- a/install/update/old/includes/functions_admin.php +++ /dev/null @@ -1,3109 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* Recalculate Nested Sets -* -* @param int $new_id first left_id (should start with 1) -* @param string $pkey primary key-column (containing the id for the parent_id of the children) -* @param string $table constant or fullname of the table -* @param int $parent_id parent_id of the current set (default = 0) -* @param array $where contains strings to compare closer on the where statement (additional) -*/ -function recalc_nested_sets(&$new_id, $pkey, $table, $parent_id = 0, $where = array()) -{ - global $db; - - $sql = 'SELECT * - FROM ' . $table . ' - WHERE parent_id = ' . (int) $parent_id . - ((!empty($where)) ? ' AND ' . implode(' AND ', $where) : '') . ' - ORDER BY left_id ASC'; - $result = $db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) - { - // First we update the left_id for this module - if ($row['left_id'] != $new_id) - { - $db->sql_query('UPDATE ' . $table . ' SET ' . $db->sql_build_array('UPDATE', array('left_id' => $new_id)) . " WHERE $pkey = {$row[$pkey]}"); - } - $new_id++; - - // Then we go through any children and update their left/right id's - recalc_nested_sets($new_id, $pkey, $table, $row[$pkey], $where); - - // Then we come back and update the right_id for this module - if ($row['right_id'] != $new_id) - { - $db->sql_query('UPDATE ' . $table . ' SET ' . $db->sql_build_array('UPDATE', array('right_id' => $new_id)) . " WHERE $pkey = {$row[$pkey]}"); - } - $new_id++; - } - $db->sql_freeresult($result); -} - -/** -* Simple version of jumpbox, just lists authed forums -*/ -function make_forum_select($select_id = false, $ignore_id = false, $ignore_acl = false, $ignore_nonpost = false, $ignore_emptycat = true, $only_acl_post = false, $return_array = false) -{ - global $db, $auth, $phpbb_dispatcher; - - // This query is identical to the jumpbox one - $sql = 'SELECT forum_id, forum_name, parent_id, forum_type, forum_flags, forum_options, left_id, right_id - FROM ' . FORUMS_TABLE . ' - ORDER BY left_id ASC'; - $result = $db->sql_query($sql, 600); - - $rowset = array(); - while ($row = $db->sql_fetchrow($result)) - { - $rowset[(int) $row['forum_id']] = $row; - } - $db->sql_freeresult($result); - - $right = 0; - $padding_store = array('0' => ''); - $padding = ''; - $forum_list = ($return_array) ? array() : ''; - - /** - * Modify the forum list data - * - * @event core.make_forum_select_modify_forum_list - * @var array rowset Array with the forums list data - * @since 3.1.10-RC1 - */ - $vars = array('rowset'); - extract($phpbb_dispatcher->trigger_event('core.make_forum_select_modify_forum_list', compact($vars))); - - // Sometimes it could happen that forums will be displayed here not be displayed within the index page - // This is the result of forums not displayed at index, having list permissions and a parent of a forum with no permissions. - // If this happens, the padding could be "broken" - - foreach ($rowset as $row) - { - if ($row['left_id'] < $right) - { - $padding .= '   '; - $padding_store[$row['parent_id']] = $padding; - } - else if ($row['left_id'] > $right + 1) - { - $padding = (isset($padding_store[$row['parent_id']])) ? $padding_store[$row['parent_id']] : ''; - } - - $right = $row['right_id']; - $disabled = false; - - if (!$ignore_acl && $auth->acl_gets(array('f_list', 'a_forum', 'a_forumadd', 'a_forumdel'), $row['forum_id'])) - { - if ($only_acl_post && !$auth->acl_get('f_post', $row['forum_id']) || (!$auth->acl_get('m_approve', $row['forum_id']) && !$auth->acl_get('f_noapprove', $row['forum_id']))) - { - $disabled = true; - } - } - else if (!$ignore_acl) - { - continue; - } - - if ( - ((is_array($ignore_id) && in_array($row['forum_id'], $ignore_id)) || $row['forum_id'] == $ignore_id) - || - // Non-postable forum with no subforums, don't display - ($row['forum_type'] == FORUM_CAT && ($row['left_id'] + 1 == $row['right_id']) && $ignore_emptycat) - || - ($row['forum_type'] != FORUM_POST && $ignore_nonpost) - ) - { - $disabled = true; - } - - if ($return_array) - { - // Include some more information... - $selected = (is_array($select_id)) ? ((in_array($row['forum_id'], $select_id)) ? true : false) : (($row['forum_id'] == $select_id) ? true : false); - $forum_list[$row['forum_id']] = array_merge(array('padding' => $padding, 'selected' => ($selected && !$disabled), 'disabled' => $disabled), $row); - } - else - { - $selected = (is_array($select_id)) ? ((in_array($row['forum_id'], $select_id)) ? ' selected="selected"' : '') : (($row['forum_id'] == $select_id) ? ' selected="selected"' : ''); - $forum_list .= ''; - } - } - unset($padding_store, $rowset); - - return $forum_list; -} - -/** -* Generate size select options -*/ -function size_select_options($size_compare) -{ - global $user; - - $size_types_text = array($user->lang['BYTES'], $user->lang['KIB'], $user->lang['MIB']); - $size_types = array('b', 'kb', 'mb'); - - $s_size_options = ''; - - for ($i = 0, $size = count($size_types_text); $i < $size; $i++) - { - $selected = ($size_compare == $size_types[$i]) ? ' selected="selected"' : ''; - $s_size_options .= ''; - } - - return $s_size_options; -} - -/** -* Generate list of groups (option fields without select) -* -* @param int $group_id The default group id to mark as selected -* @param array $exclude_ids The group ids to exclude from the list, false (default) if you whish to exclude no id -* @param int $manage_founder If set to false (default) all groups are returned, if 0 only those groups returned not being managed by founders only, if 1 only those groups returned managed by founders only. -* -* @return string The list of options. -*/ -function group_select_options($group_id, $exclude_ids = false, $manage_founder = false) -{ - global $db, $config, $phpbb_container; - - /** @var \phpbb\group\helper $group_helper */ - $group_helper = $phpbb_container->get('group_helper'); - - $exclude_sql = ($exclude_ids !== false && count($exclude_ids)) ? 'WHERE ' . $db->sql_in_set('group_id', array_map('intval', $exclude_ids), true) : ''; - $sql_and = (!$config['coppa_enable']) ? (($exclude_sql) ? ' AND ' : ' WHERE ') . "group_name <> 'REGISTERED_COPPA'" : ''; - $sql_founder = ($manage_founder !== false) ? (($exclude_sql || $sql_and) ? ' AND ' : ' WHERE ') . 'group_founder_manage = ' . (int) $manage_founder : ''; - - $sql = 'SELECT group_id, group_name, group_type - FROM ' . GROUPS_TABLE . " - $exclude_sql - $sql_and - $sql_founder - ORDER BY group_type DESC, group_name ASC"; - $result = $db->sql_query($sql); - - $s_group_options = ''; - while ($row = $db->sql_fetchrow($result)) - { - $selected = ($row['group_id'] == $group_id) ? ' selected="selected"' : ''; - $s_group_options .= '' . $group_helper->get_name($row['group_name']) . ''; - } - $db->sql_freeresult($result); - - return $s_group_options; -} - -/** -* Obtain authed forums list -*/ -function get_forum_list($acl_list = 'f_list', $id_only = true, $postable_only = false, $no_cache = false) -{ - global $db, $auth, $phpbb_dispatcher; - static $forum_rows; - - if (!isset($forum_rows)) - { - // This query is identical to the jumpbox one - $expire_time = ($no_cache) ? 0 : 600; - - $sql = 'SELECT forum_id, forum_name, parent_id, forum_type, left_id, right_id - FROM ' . FORUMS_TABLE . ' - ORDER BY left_id ASC'; - $result = $db->sql_query($sql, $expire_time); - - $forum_rows = array(); - - $right = $padding = 0; - $padding_store = array('0' => 0); - - while ($row = $db->sql_fetchrow($result)) - { - if ($row['left_id'] < $right) - { - $padding++; - $padding_store[$row['parent_id']] = $padding; - } - else if ($row['left_id'] > $right + 1) - { - // Ok, if the $padding_store for this parent is empty there is something wrong. For now we will skip over it. - // @todo digging deep to find out "how" this can happen. - $padding = (isset($padding_store[$row['parent_id']])) ? $padding_store[$row['parent_id']] : $padding; - } - - $right = $row['right_id']; - $row['padding'] = $padding; - - $forum_rows[] = $row; - } - $db->sql_freeresult($result); - unset($padding_store); - } - - $rowset = array(); - foreach ($forum_rows as $row) - { - if ($postable_only && $row['forum_type'] != FORUM_POST) - { - continue; - } - - if ($acl_list == '' || ($acl_list != '' && $auth->acl_gets($acl_list, $row['forum_id']))) - { - $rowset[] = ($id_only) ? (int) $row['forum_id'] : $row; - } - } - - /** - * Modify the forum list data - * - * @event core.get_forum_list_modify_data - * @var array rowset Array with the forum list data - * @since 3.1.10-RC1 - */ - $vars = array('rowset'); - extract($phpbb_dispatcher->trigger_event('core.get_forum_list_modify_data', compact($vars))); - - return $rowset; -} - -/** -* Get forum branch -*/ -function get_forum_branch($forum_id, $type = 'all', $order = 'descending', $include_forum = true) -{ - global $db; - - switch ($type) - { - case 'parents': - $condition = 'f1.left_id BETWEEN f2.left_id AND f2.right_id'; - break; - - case 'children': - $condition = 'f2.left_id BETWEEN f1.left_id AND f1.right_id'; - break; - - default: - $condition = 'f2.left_id BETWEEN f1.left_id AND f1.right_id OR f1.left_id BETWEEN f2.left_id AND f2.right_id'; - break; - } - - $rows = array(); - - $sql = 'SELECT f2.* - FROM ' . FORUMS_TABLE . ' f1 - LEFT JOIN ' . FORUMS_TABLE . " f2 ON ($condition) - WHERE f1.forum_id = $forum_id - ORDER BY f2.left_id " . (($order == 'descending') ? 'ASC' : 'DESC'); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if (!$include_forum && $row['forum_id'] == $forum_id) - { - continue; - } - - $rows[] = $row; - } - $db->sql_freeresult($result); - - return $rows; -} - -/** -* Copies permissions from one forum to others -* -* @param int $src_forum_id The source forum we want to copy permissions from -* @param array $dest_forum_ids The destination forum(s) we want to copy to -* @param bool $clear_dest_perms True if destination permissions should be deleted -* @param bool $add_log True if log entry should be added -* -* @return bool False on error -*/ -function copy_forum_permissions($src_forum_id, $dest_forum_ids, $clear_dest_perms = true, $add_log = true) -{ - global $db, $user, $phpbb_log; - - // Only one forum id specified - if (!is_array($dest_forum_ids)) - { - $dest_forum_ids = array($dest_forum_ids); - } - - // Make sure forum ids are integers - $src_forum_id = (int) $src_forum_id; - $dest_forum_ids = array_map('intval', $dest_forum_ids); - - // No source forum or no destination forums specified - if (empty($src_forum_id) || empty($dest_forum_ids)) - { - return false; - } - - // Check if source forum exists - $sql = 'SELECT forum_name - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . $src_forum_id; - $result = $db->sql_query($sql); - $src_forum_name = $db->sql_fetchfield('forum_name'); - $db->sql_freeresult($result); - - // Source forum doesn't exist - if (empty($src_forum_name)) - { - return false; - } - - // Check if destination forums exists - $sql = 'SELECT forum_id, forum_name - FROM ' . FORUMS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $dest_forum_ids); - $result = $db->sql_query($sql); - - $dest_forum_ids = $dest_forum_names = array(); - while ($row = $db->sql_fetchrow($result)) - { - $dest_forum_ids[] = (int) $row['forum_id']; - $dest_forum_names[] = $row['forum_name']; - } - $db->sql_freeresult($result); - - // No destination forum exists - if (empty($dest_forum_ids)) - { - return false; - } - - // From the mysql documentation: - // Prior to MySQL 4.0.14, the target table of the INSERT statement cannot appear - // in the FROM clause of the SELECT part of the query. This limitation is lifted in 4.0.14. - // Due to this we stay on the safe side if we do the insertion "the manual way" - - // Rowsets we're going to insert - $users_sql_ary = $groups_sql_ary = array(); - - // Query acl users table for source forum data - $sql = 'SELECT user_id, auth_option_id, auth_role_id, auth_setting - FROM ' . ACL_USERS_TABLE . ' - WHERE forum_id = ' . $src_forum_id; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $row = array( - 'user_id' => (int) $row['user_id'], - 'auth_option_id' => (int) $row['auth_option_id'], - 'auth_role_id' => (int) $row['auth_role_id'], - 'auth_setting' => (int) $row['auth_setting'], - ); - - foreach ($dest_forum_ids as $dest_forum_id) - { - $users_sql_ary[] = $row + array('forum_id' => $dest_forum_id); - } - } - $db->sql_freeresult($result); - - // Query acl groups table for source forum data - $sql = 'SELECT group_id, auth_option_id, auth_role_id, auth_setting - FROM ' . ACL_GROUPS_TABLE . ' - WHERE forum_id = ' . $src_forum_id; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $row = array( - 'group_id' => (int) $row['group_id'], - 'auth_option_id' => (int) $row['auth_option_id'], - 'auth_role_id' => (int) $row['auth_role_id'], - 'auth_setting' => (int) $row['auth_setting'], - ); - - foreach ($dest_forum_ids as $dest_forum_id) - { - $groups_sql_ary[] = $row + array('forum_id' => $dest_forum_id); - } - } - $db->sql_freeresult($result); - - $db->sql_transaction('begin'); - - // Clear current permissions of destination forums - if ($clear_dest_perms) - { - $sql = 'DELETE FROM ' . ACL_USERS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $dest_forum_ids); - $db->sql_query($sql); - - $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $dest_forum_ids); - $db->sql_query($sql); - } - - $db->sql_multi_insert(ACL_USERS_TABLE, $users_sql_ary); - $db->sql_multi_insert(ACL_GROUPS_TABLE, $groups_sql_ary); - - if ($add_log) - { - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_COPIED_PERMISSIONS', false, array($src_forum_name, implode(', ', $dest_forum_names))); - } - - $db->sql_transaction('commit'); - - return true; -} - -/** -* Get physical file listing -*/ -function filelist($rootdir, $dir = '', $type = 'gif|jpg|jpeg|png') -{ - $matches = array($dir => array()); - - // Remove initial / if present - $rootdir = (substr($rootdir, 0, 1) == '/') ? substr($rootdir, 1) : $rootdir; - // Add closing / if not present - $rootdir = ($rootdir && substr($rootdir, -1) != '/') ? $rootdir . '/' : $rootdir; - - // Remove initial / if present - $dir = (substr($dir, 0, 1) == '/') ? substr($dir, 1) : $dir; - // Add closing / if not present - $dir = ($dir && substr($dir, -1) != '/') ? $dir . '/' : $dir; - - if (!is_dir($rootdir . $dir)) - { - return $matches; - } - - $dh = @opendir($rootdir . $dir); - - if (!$dh) - { - return $matches; - } - - while (($fname = readdir($dh)) !== false) - { - if (is_file("$rootdir$dir$fname")) - { - if (filesize("$rootdir$dir$fname") && preg_match('#\.' . $type . '$#i', $fname)) - { - $matches[$dir][] = $fname; - } - } - else if ($fname[0] != '.' && is_dir("$rootdir$dir$fname")) - { - $matches += filelist($rootdir, "$dir$fname", $type); - } - } - closedir($dh); - - return $matches; -} - -/** -* Move topic(s) -*/ -function move_topics($topic_ids, $forum_id, $auto_sync = true) -{ - global $db, $phpbb_dispatcher; - - if (empty($topic_ids)) - { - return; - } - - $forum_ids = array($forum_id); - - if (!is_array($topic_ids)) - { - $topic_ids = array($topic_ids); - } - - $sql = 'DELETE FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_moved_id', $topic_ids) . ' - AND forum_id = ' . $forum_id; - $db->sql_query($sql); - - if ($auto_sync) - { - $sql = 'SELECT DISTINCT forum_id - FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', $topic_ids); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $forum_ids[] = $row['forum_id']; - } - $db->sql_freeresult($result); - } - - $table_ary = array(TOPICS_TABLE, POSTS_TABLE, LOG_TABLE, DRAFTS_TABLE, TOPICS_TRACK_TABLE); - - /** - * Perform additional actions before topics move - * - * @event core.move_topics_before_query - * @var array table_ary Array of tables from which forum_id will be updated for all rows that hold the moved topics - * @var array topic_ids Array of the moved topic ids - * @var string forum_id The forum id from where the topics are moved - * @var array forum_ids Array of the forums where the topics are moving (includes also forum_id) - * @var bool auto_sync Whether or not to perform auto sync - * @since 3.1.5-RC1 - */ - $vars = array( - 'table_ary', - 'topic_ids', - 'forum_id', - 'forum_ids', - 'auto_sync', - ); - extract($phpbb_dispatcher->trigger_event('core.move_topics_before_query', compact($vars))); - - foreach ($table_ary as $table) - { - $sql = "UPDATE $table - SET forum_id = $forum_id - WHERE " . $db->sql_in_set('topic_id', $topic_ids); - $db->sql_query($sql); - } - unset($table_ary); - - if ($auto_sync) - { - sync('forum', 'forum_id', $forum_ids, true, true); - unset($forum_ids); - } -} - -/** -* Move post(s) -*/ -function move_posts($post_ids, $topic_id, $auto_sync = true) -{ - global $db, $phpbb_dispatcher; - - if (!is_array($post_ids)) - { - $post_ids = array($post_ids); - } - - $forum_ids = array(); - $topic_ids = array($topic_id); - - $sql = 'SELECT DISTINCT topic_id, forum_id - FROM ' . POSTS_TABLE . ' - WHERE ' . $db->sql_in_set('post_id', $post_ids); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $forum_ids[] = (int) $row['forum_id']; - $topic_ids[] = (int) $row['topic_id']; - } - $db->sql_freeresult($result); - - $sql = 'SELECT forum_id - FROM ' . TOPICS_TABLE . ' - WHERE topic_id = ' . $topic_id; - $result = $db->sql_query($sql); - $forum_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$forum_row) - { - trigger_error('NO_TOPIC'); - } - - /** - * Perform additional actions before moving posts - * - * @event core.move_posts_before - * @var array post_ids Array of post ids to move - * @var int topic_id The topic id the posts are moved to - * @var bool auto_sync Whether or not to perform auto sync - * @var array forum_ids Array of the forum ids the posts are moved from - * @var array topic_ids Array of the topic ids the posts are moved from - * @var array forum_row Array with the forum id of the topic the posts are moved to - * @since 3.1.7-RC1 - */ - $vars = array( - 'post_ids', - 'topic_id', - 'auto_sync', - 'forum_ids', - 'topic_ids', - 'forum_row', - ); - extract($phpbb_dispatcher->trigger_event('core.move_posts_before', compact($vars))); - - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET forum_id = ' . (int) $forum_row['forum_id'] . ", topic_id = $topic_id - WHERE " . $db->sql_in_set('post_id', $post_ids); - $db->sql_query($sql); - - $sql = 'UPDATE ' . ATTACHMENTS_TABLE . " - SET topic_id = $topic_id, in_message = 0 - WHERE " . $db->sql_in_set('post_msg_id', $post_ids); - $db->sql_query($sql); - - /** - * Perform additional actions after moving posts - * - * @event core.move_posts_after - * @var array post_ids Array of the moved post ids - * @var int topic_id The topic id the posts are moved to - * @var bool auto_sync Whether or not to perform auto sync - * @var array forum_ids Array of the forum ids the posts are moved from - * @var array topic_ids Array of the topic ids the posts are moved from - * @var array forum_row Array with the forum id of the topic the posts are moved to - * @since 3.1.7-RC1 - */ - $vars = array( - 'post_ids', - 'topic_id', - 'auto_sync', - 'forum_ids', - 'topic_ids', - 'forum_row', - ); - extract($phpbb_dispatcher->trigger_event('core.move_posts_after', compact($vars))); - - if ($auto_sync) - { - $forum_ids[] = (int) $forum_row['forum_id']; - - sync('topic_reported', 'topic_id', $topic_ids); - sync('topic_attachment', 'topic_id', $topic_ids); - sync('topic', 'topic_id', $topic_ids, true); - sync('forum', 'forum_id', $forum_ids, true, true); - - /** - * Perform additional actions after move post sync - * - * @event core.move_posts_sync_after - * @var array post_ids Array of the moved post ids - * @var int topic_id The topic id the posts are moved to - * @var bool auto_sync Whether or not to perform auto sync - * @var array forum_ids Array of the forum ids the posts are moved from - * @var array topic_ids Array of the topic ids the posts are moved from - * @var array forum_row Array with the forum id of the topic the posts are moved to - * @since 3.1.11-RC1 - */ - $vars = array( - 'post_ids', - 'topic_id', - 'auto_sync', - 'forum_ids', - 'topic_ids', - 'forum_row', - ); - extract($phpbb_dispatcher->trigger_event('core.move_posts_sync_after', compact($vars))); - } - - // Update posted information - update_posted_info($topic_ids); -} - -/** -* Remove topic(s) -*/ -function delete_topics($where_type, $where_ids, $auto_sync = true, $post_count_sync = true, $call_delete_posts = true) -{ - global $db, $config, $phpbb_container, $phpbb_dispatcher; - - $approved_topics = 0; - $forum_ids = $topic_ids = array(); - - if ($where_type === 'range') - { - $where_clause = $where_ids; - } - else - { - $where_ids = (is_array($where_ids)) ? array_unique($where_ids) : array($where_ids); - - if (!count($where_ids)) - { - return array('topics' => 0, 'posts' => 0); - } - - $where_clause = $db->sql_in_set($where_type, $where_ids); - } - - // Making sure that delete_posts does not call delete_topics again... - $return = array( - 'posts' => ($call_delete_posts) ? delete_posts($where_type, $where_ids, false, true, $post_count_sync, false) : 0, - ); - - $sql = 'SELECT topic_id, forum_id, topic_visibility, topic_moved_id - FROM ' . TOPICS_TABLE . ' - WHERE ' . $where_clause; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $forum_ids[] = $row['forum_id']; - $topic_ids[] = $row['topic_id']; - - if ($row['topic_visibility'] == ITEM_APPROVED && !$row['topic_moved_id']) - { - $approved_topics++; - } - } - $db->sql_freeresult($result); - - $return['topics'] = count($topic_ids); - - if (!count($topic_ids)) - { - return $return; - } - - $db->sql_transaction('begin'); - - $table_ary = array(BOOKMARKS_TABLE, TOPICS_TRACK_TABLE, TOPICS_POSTED_TABLE, POLL_VOTES_TABLE, POLL_OPTIONS_TABLE, TOPICS_WATCH_TABLE, TOPICS_TABLE); - - /** - * Perform additional actions before topic(s) deletion - * - * @event core.delete_topics_before_query - * @var array table_ary Array of tables from which all rows will be deleted that hold a topic_id occuring in topic_ids - * @var array topic_ids Array of topic ids to delete - * @since 3.1.4-RC1 - */ - $vars = array( - 'table_ary', - 'topic_ids', - ); - extract($phpbb_dispatcher->trigger_event('core.delete_topics_before_query', compact($vars))); - - foreach ($table_ary as $table) - { - $sql = "DELETE FROM $table - WHERE " . $db->sql_in_set('topic_id', $topic_ids); - $db->sql_query($sql); - } - unset($table_ary); - - /** - * Perform additional actions after topic(s) deletion - * - * @event core.delete_topics_after_query - * @var array topic_ids Array of topic ids that were deleted - * @since 3.1.4-RC1 - */ - $vars = array( - 'topic_ids', - ); - extract($phpbb_dispatcher->trigger_event('core.delete_topics_after_query', compact($vars))); - - $moved_topic_ids = array(); - - // update the other forums - $sql = 'SELECT topic_id, forum_id - FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_moved_id', $topic_ids); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $forum_ids[] = $row['forum_id']; - $moved_topic_ids[] = $row['topic_id']; - } - $db->sql_freeresult($result); - - if (count($moved_topic_ids)) - { - $sql = 'DELETE FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', $moved_topic_ids); - $db->sql_query($sql); - } - - $db->sql_transaction('commit'); - - if ($auto_sync) - { - sync('forum', 'forum_id', array_unique($forum_ids), true, true); - sync('topic_reported', $where_type, $where_ids); - } - - if ($approved_topics) - { - $config->increment('num_topics', $approved_topics * (-1), false); - } - - /* @var $phpbb_notifications \phpbb\notification\manager */ - $phpbb_notifications = $phpbb_container->get('notification_manager'); - - $phpbb_notifications->delete_notifications(array( - 'notification.type.topic', - 'notification.type.approve_topic', - 'notification.type.topic_in_queue', - ), $topic_ids); - - return $return; -} - -/** -* Remove post(s) -*/ -function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync = true, $post_count_sync = true, $call_delete_topics = true) -{ - global $db, $config, $phpbb_root_path, $phpEx, $auth, $user, $phpbb_container, $phpbb_dispatcher; - - // Notifications types to delete - $delete_notifications_types = array( - 'notification.type.quote', - 'notification.type.approve_post', - 'notification.type.post_in_queue', - 'notification.type.report_post', - ); - - /** - * Perform additional actions before post(s) deletion - * - * @event core.delete_posts_before - * @var string where_type Variable containing posts deletion mode - * @var mixed where_ids Array or comma separated list of posts ids to delete - * @var bool auto_sync Flag indicating if topics/forums should be synchronized - * @var bool posted_sync Flag indicating if topics_posted table should be resynchronized - * @var bool post_count_sync Flag indicating if posts count should be resynchronized - * @var bool call_delete_topics Flag indicating if topics having no posts should be deleted - * @var array delete_notifications_types Array with notifications types to delete - * @since 3.1.0-a4 - */ - $vars = array( - 'where_type', - 'where_ids', - 'auto_sync', - 'posted_sync', - 'post_count_sync', - 'call_delete_topics', - 'delete_notifications_types', - ); - extract($phpbb_dispatcher->trigger_event('core.delete_posts_before', compact($vars))); - - if ($where_type === 'range') - { - $where_clause = $where_ids; - } - else - { - if (is_array($where_ids)) - { - $where_ids = array_unique($where_ids); - } - else - { - $where_ids = array($where_ids); - } - - if (!count($where_ids)) - { - return false; - } - - $where_ids = array_map('intval', $where_ids); - -/* Possible code for splitting post deletion - if (count($where_ids) >= 1001) - { - // Split into chunks of 1000 - $chunks = array_chunk($where_ids, 1000); - - foreach ($chunks as $_where_ids) - { - delete_posts($where_type, $_where_ids, $auto_sync, $posted_sync, $post_count_sync, $call_delete_topics); - } - - return; - }*/ - - $where_clause = $db->sql_in_set($where_type, $where_ids); - } - - $approved_posts = 0; - $post_ids = $topic_ids = $forum_ids = $post_counts = $remove_topics = array(); - - $sql = 'SELECT post_id, poster_id, post_visibility, post_postcount, topic_id, forum_id - FROM ' . POSTS_TABLE . ' - WHERE ' . $where_clause; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $post_ids[] = (int) $row['post_id']; - $poster_ids[] = (int) $row['poster_id']; - $topic_ids[] = (int) $row['topic_id']; - $forum_ids[] = (int) $row['forum_id']; - - if ($row['post_postcount'] && $post_count_sync && $row['post_visibility'] == ITEM_APPROVED) - { - $post_counts[$row['poster_id']] = (!empty($post_counts[$row['poster_id']])) ? $post_counts[$row['poster_id']] + 1 : 1; - } - - if ($row['post_visibility'] == ITEM_APPROVED) - { - $approved_posts++; - } - } - $db->sql_freeresult($result); - - if (!count($post_ids)) - { - return false; - } - - $db->sql_transaction('begin'); - - $table_ary = array(POSTS_TABLE, REPORTS_TABLE); - - /** - * Perform additional actions during post(s) deletion before running the queries - * - * @event core.delete_posts_in_transaction_before - * @var array post_ids Array with deleted posts' ids - * @var array poster_ids Array with deleted posts' author ids - * @var array topic_ids Array with deleted posts' topic ids - * @var array forum_ids Array with deleted posts' forum ids - * @var string where_type Variable containing posts deletion mode - * @var mixed where_ids Array or comma separated list of post ids to delete - * @var array delete_notifications_types Array with notifications types to delete - * @var array table_ary Array with table names to delete data from - * @since 3.1.7-RC1 - */ - $vars = array( - 'post_ids', - 'poster_ids', - 'topic_ids', - 'forum_ids', - 'where_type', - 'where_ids', - 'delete_notifications_types', - 'table_ary', - ); - extract($phpbb_dispatcher->trigger_event('core.delete_posts_in_transaction_before', compact($vars))); - - foreach ($table_ary as $table) - { - $sql = "DELETE FROM $table - WHERE " . $db->sql_in_set('post_id', $post_ids); - $db->sql_query($sql); - } - unset($table_ary); - - // Adjust users post counts - if (count($post_counts) && $post_count_sync) - { - foreach ($post_counts as $poster_id => $substract) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_posts = 0 - WHERE user_id = ' . $poster_id . ' - AND user_posts < ' . $substract; - $db->sql_query($sql); - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_posts = user_posts - ' . $substract . ' - WHERE user_id = ' . $poster_id . ' - AND user_posts >= ' . $substract; - $db->sql_query($sql); - } - } - - // Remove topics now having no posts? - if (count($topic_ids)) - { - $sql = 'SELECT topic_id - FROM ' . POSTS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', $topic_ids) . ' - GROUP BY topic_id'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $remove_topics[] = $row['topic_id']; - } - $db->sql_freeresult($result); - - // Actually, those not within remove_topics should be removed. ;) - $remove_topics = array_diff($topic_ids, $remove_topics); - } - - // Remove the message from the search index - $search_type = $config['search_type']; - - if (!class_exists($search_type)) - { - trigger_error('NO_SUCH_SEARCH_MODULE'); - } - - $error = false; - $search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher); - - if ($error) - { - trigger_error($error); - } - - $search->index_remove($post_ids, $poster_ids, $forum_ids); - - /** @var \phpbb\attachment\manager $attachment_manager */ - $attachment_manager = $phpbb_container->get('attachment.manager'); - $attachment_manager->delete('post', $post_ids, false); - unset($attachment_manager); - - /** - * Perform additional actions during post(s) deletion - * - * @event core.delete_posts_in_transaction - * @var array post_ids Array with deleted posts' ids - * @var array poster_ids Array with deleted posts' author ids - * @var array topic_ids Array with deleted posts' topic ids - * @var array forum_ids Array with deleted posts' forum ids - * @var string where_type Variable containing posts deletion mode - * @var mixed where_ids Array or comma separated list of posts ids to delete - * @var array delete_notifications_types Array with notifications types to delete - * @since 3.1.0-a4 - */ - $vars = array( - 'post_ids', - 'poster_ids', - 'topic_ids', - 'forum_ids', - 'where_type', - 'where_ids', - 'delete_notifications_types', - ); - extract($phpbb_dispatcher->trigger_event('core.delete_posts_in_transaction', compact($vars))); - - $db->sql_transaction('commit'); - - /** - * Perform additional actions after post(s) deletion - * - * @event core.delete_posts_after - * @var array post_ids Array with deleted posts' ids - * @var array poster_ids Array with deleted posts' author ids - * @var array topic_ids Array with deleted posts' topic ids - * @var array forum_ids Array with deleted posts' forum ids - * @var string where_type Variable containing posts deletion mode - * @var mixed where_ids Array or comma separated list of posts ids to delete - * @var array delete_notifications_types Array with notifications types to delete - * @since 3.1.0-a4 - */ - $vars = array( - 'post_ids', - 'poster_ids', - 'topic_ids', - 'forum_ids', - 'where_type', - 'where_ids', - 'delete_notifications_types', - ); - extract($phpbb_dispatcher->trigger_event('core.delete_posts_after', compact($vars))); - - // Resync topics_posted table - if ($posted_sync) - { - update_posted_info($topic_ids); - } - - if ($auto_sync) - { - sync('topic_reported', 'topic_id', $topic_ids); - sync('topic', 'topic_id', $topic_ids, true); - sync('forum', 'forum_id', $forum_ids, true, true); - } - - if ($approved_posts && $post_count_sync) - { - $config->increment('num_posts', $approved_posts * (-1), false); - } - - // We actually remove topics now to not be inconsistent (the delete_topics function calls this function too) - if (count($remove_topics) && $call_delete_topics) - { - delete_topics('topic_id', $remove_topics, $auto_sync, $post_count_sync, false); - } - - /* @var $phpbb_notifications \phpbb\notification\manager */ - $phpbb_notifications = $phpbb_container->get('notification_manager'); - - $phpbb_notifications->delete_notifications($delete_notifications_types, $post_ids); - - return count($post_ids); -} - -/** -* Delete Attachments -* -* @deprecated 3.2.0-a1 (To be removed: 3.4.0) -* -* @param string $mode can be: post|message|topic|attach|user -* @param mixed $ids can be: post_ids, message_ids, topic_ids, attach_ids, user_ids -* @param bool $resync set this to false if you are deleting posts or topics -*/ -function delete_attachments($mode, $ids, $resync = true) -{ - global $phpbb_container; - - /** @var \phpbb\attachment\manager $attachment_manager */ - $attachment_manager = $phpbb_container->get('attachment.manager'); - $num_deleted = $attachment_manager->delete($mode, $ids, $resync); - - unset($attachment_manager); - - return $num_deleted; -} - -/** -* Deletes shadow topics pointing to a specified forum. -* -* @param int $forum_id The forum id -* @param string $sql_more Additional WHERE statement, e.g. t.topic_time < (time() - 1234) -* @param bool $auto_sync Will call sync() if this is true -* -* @return array Array with affected forums -*/ -function delete_topic_shadows($forum_id, $sql_more = '', $auto_sync = true) -{ - global $db; - - if (!$forum_id) - { - // Nothing to do. - return; - } - - // Set of affected forums we have to resync - $sync_forum_ids = array(); - - // Amount of topics we select and delete at once. - $batch_size = 500; - - do - { - $sql = 'SELECT t2.forum_id, t2.topic_id - FROM ' . TOPICS_TABLE . ' t2, ' . TOPICS_TABLE . ' t - WHERE t2.topic_moved_id = t.topic_id - AND t.forum_id = ' . (int) $forum_id . ' - ' . (($sql_more) ? 'AND ' . $sql_more : ''); - $result = $db->sql_query_limit($sql, $batch_size); - - $topic_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $topic_ids[] = (int) $row['topic_id']; - - $sync_forum_ids[(int) $row['forum_id']] = (int) $row['forum_id']; - } - $db->sql_freeresult($result); - - if (!empty($topic_ids)) - { - $sql = 'DELETE FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', $topic_ids); - $db->sql_query($sql); - } - } - while (count($topic_ids) == $batch_size); - - if ($auto_sync) - { - sync('forum', 'forum_id', $sync_forum_ids, true, true); - } - - return $sync_forum_ids; -} - -/** -* Update/Sync posted information for topics -*/ -function update_posted_info(&$topic_ids) -{ - global $db, $config; - - if (empty($topic_ids) || !$config['load_db_track']) - { - return; - } - - // First of all, let us remove any posted information for these topics - $sql = 'DELETE FROM ' . TOPICS_POSTED_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', $topic_ids); - $db->sql_query($sql); - - // Now, let us collect the user/topic combos for rebuilding the information - $sql = 'SELECT poster_id, topic_id - FROM ' . POSTS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', $topic_ids) . ' - AND poster_id <> ' . ANONYMOUS . ' - GROUP BY poster_id, topic_id'; - $result = $db->sql_query($sql); - - $posted = array(); - while ($row = $db->sql_fetchrow($result)) - { - // Add as key to make them unique (grouping by) and circumvent empty keys on array_unique - $posted[$row['poster_id']][] = $row['topic_id']; - } - $db->sql_freeresult($result); - - // Now add the information... - $sql_ary = array(); - foreach ($posted as $user_id => $topic_row) - { - foreach ($topic_row as $topic_id) - { - $sql_ary[] = array( - 'user_id' => (int) $user_id, - 'topic_id' => (int) $topic_id, - 'topic_posted' => 1, - ); - } - } - unset($posted); - - $db->sql_multi_insert(TOPICS_POSTED_TABLE, $sql_ary); -} - -/** -* Delete attached file -* -* @deprecated 3.2.0-a1 (To be removed: 3.4.0) -*/ -function phpbb_unlink($filename, $mode = 'file', $entry_removed = false) -{ - global $phpbb_container; - - /** @var \phpbb\attachment\manager $attachment_manager */ - $attachment_manager = $phpbb_container->get('attachment.manager'); - $unlink = $attachment_manager->unlink($filename, $mode, $entry_removed); - unset($attachment_manager); - - return $unlink; -} - -/** -* All-encompasing sync function -* -* Exaples: -* -* sync('topic', 'topic_id', 123); // resync topic #123 -* sync('topic', 'forum_id', array(2, 3)); // resync topics from forum #2 and #3 -* sync('topic'); // resync all topics -* sync('topic', 'range', 'topic_id BETWEEN 1 AND 60'); // resync a range of topics/forums (only available for 'topic' and 'forum' modes) -* -* -* Modes: -* - forum Resync complete forum -* - topic Resync topics -* - topic_moved Removes topic shadows that would be in the same forum as the topic they link to -* - topic_visibility Resyncs the topic_visibility flag according to the status of the first post -* - post_reported Resyncs the post_reported flag, relying on actual reports -* - topic_reported Resyncs the topic_reported flag, relying on post_reported flags -* - post_attachement Same as post_reported, but with attachment flags -* - topic_attachement Same as topic_reported, but with attachment flags -*/ -function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $sync_extra = false) -{ - global $db; - - if (is_array($where_ids)) - { - $where_ids = array_unique($where_ids); - $where_ids = array_map('intval', $where_ids); - } - else if ($where_type != 'range') - { - $where_ids = ($where_ids) ? array((int) $where_ids) : array(); - } - - if ($mode == 'forum' || $mode == 'topic' || $mode == 'topic_visibility' || $mode == 'topic_reported' || $mode == 'post_reported') - { - if (!$where_type) - { - $where_sql = ''; - $where_sql_and = 'WHERE'; - } - else if ($where_type == 'range') - { - // Only check a range of topics/forums. For instance: 'topic_id BETWEEN 1 AND 60' - $where_sql = 'WHERE (' . $mode[0] . ".$where_ids)"; - $where_sql_and = $where_sql . "\n\tAND"; - } - else - { - // Do not sync the "global forum" - $where_ids = array_diff($where_ids, array(0)); - - if (!count($where_ids)) - { - // Empty array with IDs. This means that we don't have any work to do. Just return. - return; - } - - // Limit the topics/forums we are syncing, use specific topic/forum IDs. - // $where_type contains the field for the where clause (forum_id, topic_id) - $where_sql = 'WHERE ' . $db->sql_in_set($mode[0] . '.' . $where_type, $where_ids); - $where_sql_and = $where_sql . "\n\tAND"; - } - } - else - { - if (!count($where_ids)) - { - return; - } - - // $where_type contains the field for the where clause (forum_id, topic_id) - $where_sql = 'WHERE ' . $db->sql_in_set($mode[0] . '.' . $where_type, $where_ids); - $where_sql_and = $where_sql . "\n\tAND"; - } - - switch ($mode) - { - case 'topic_moved': - $db->sql_transaction('begin'); - switch ($db->get_sql_layer()) - { - case 'mysql4': - case 'mysqli': - $sql = 'DELETE FROM ' . TOPICS_TABLE . ' - USING ' . TOPICS_TABLE . ' t1, ' . TOPICS_TABLE . " t2 - WHERE t1.topic_moved_id = t2.topic_id - AND t1.forum_id = t2.forum_id"; - $db->sql_query($sql); - break; - - default: - $sql = 'SELECT t1.topic_id - FROM ' .TOPICS_TABLE . ' t1, ' . TOPICS_TABLE . " t2 - WHERE t1.topic_moved_id = t2.topic_id - AND t1.forum_id = t2.forum_id"; - $result = $db->sql_query($sql); - - $topic_id_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - $topic_id_ary[] = $row['topic_id']; - } - $db->sql_freeresult($result); - - if (!count($topic_id_ary)) - { - return; - } - - $sql = 'DELETE FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', $topic_id_ary); - $db->sql_query($sql); - - break; - } - - $db->sql_transaction('commit'); - break; - - case 'topic_visibility': - - $db->sql_transaction('begin'); - - $sql = 'SELECT t.topic_id, p.post_visibility - FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p - $where_sql_and p.topic_id = t.topic_id - AND p.post_visibility = " . ITEM_APPROVED; - $result = $db->sql_query($sql); - - $topics_approved = array(); - while ($row = $db->sql_fetchrow($result)) - { - $topics_approved[] = (int) $row['topic_id']; - } - $db->sql_freeresult($result); - - $sql = 'SELECT t.topic_id, p.post_visibility - FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p - $where_sql_and " . $db->sql_in_set('t.topic_id', $topics_approved, true, true) . ' - AND p.topic_id = t.topic_id - AND p.post_visibility = ' . ITEM_DELETED; - $result = $db->sql_query($sql); - - $topics_softdeleted = array(); - while ($row = $db->sql_fetchrow($result)) - { - $topics_softdeleted[] = (int) $row['topic_id']; - } - $db->sql_freeresult($result); - - $topics_softdeleted = array_diff($topics_softdeleted, $topics_approved); - $topics_not_unapproved = array_merge($topics_softdeleted, $topics_approved); - - $update_ary = array( - ITEM_UNAPPROVED => (!empty($topics_not_unapproved)) ? $where_sql_and . ' ' . $db->sql_in_set('topic_id', $topics_not_unapproved, true) : '', - ITEM_APPROVED => (!empty($topics_approved)) ? ' WHERE ' . $db->sql_in_set('topic_id', $topics_approved) : '', - ITEM_DELETED => (!empty($topics_softdeleted)) ? ' WHERE ' . $db->sql_in_set('topic_id', $topics_softdeleted) : '', - ); - - foreach ($update_ary as $visibility => $sql_where) - { - if ($sql_where) - { - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_visibility = ' . $visibility . ' - ' . $sql_where; - $db->sql_query($sql); - } - } - - $db->sql_transaction('commit'); - break; - - case 'post_reported': - $post_ids = $post_reported = array(); - - $db->sql_transaction('begin'); - - $sql = 'SELECT p.post_id, p.post_reported - FROM ' . POSTS_TABLE . " p - $where_sql - GROUP BY p.post_id, p.post_reported"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $post_ids[$row['post_id']] = $row['post_id']; - if ($row['post_reported']) - { - $post_reported[$row['post_id']] = 1; - } - } - $db->sql_freeresult($result); - - $sql = 'SELECT DISTINCT(post_id) - FROM ' . REPORTS_TABLE . ' - WHERE ' . $db->sql_in_set('post_id', $post_ids) . ' - AND report_closed = 0'; - $result = $db->sql_query($sql); - - $post_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - if (!isset($post_reported[$row['post_id']])) - { - $post_ids[] = $row['post_id']; - } - else - { - unset($post_reported[$row['post_id']]); - } - } - $db->sql_freeresult($result); - - // $post_reported should be empty by now, if it's not it contains - // posts that are falsely flagged as reported - foreach ($post_reported as $post_id => $void) - { - $post_ids[] = $post_id; - } - - if (count($post_ids)) - { - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET post_reported = 1 - post_reported - WHERE ' . $db->sql_in_set('post_id', $post_ids); - $db->sql_query($sql); - } - - $db->sql_transaction('commit'); - break; - - case 'topic_reported': - if ($sync_extra) - { - sync('post_reported', $where_type, $where_ids); - } - - $topic_ids = $topic_reported = array(); - - $db->sql_transaction('begin'); - - $sql = 'SELECT DISTINCT(t.topic_id) - FROM ' . POSTS_TABLE . " t - $where_sql_and t.post_reported = 1"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $topic_reported[$row['topic_id']] = 1; - } - $db->sql_freeresult($result); - - $sql = 'SELECT t.topic_id, t.topic_reported - FROM ' . TOPICS_TABLE . " t - $where_sql"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if ($row['topic_reported'] ^ isset($topic_reported[$row['topic_id']])) - { - $topic_ids[] = $row['topic_id']; - } - } - $db->sql_freeresult($result); - - if (count($topic_ids)) - { - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_reported = 1 - topic_reported - WHERE ' . $db->sql_in_set('topic_id', $topic_ids); - $db->sql_query($sql); - } - - $db->sql_transaction('commit'); - break; - - case 'post_attachment': - $post_ids = $post_attachment = array(); - - $db->sql_transaction('begin'); - - $sql = 'SELECT p.post_id, p.post_attachment - FROM ' . POSTS_TABLE . " p - $where_sql - GROUP BY p.post_id, p.post_attachment"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $post_ids[$row['post_id']] = $row['post_id']; - if ($row['post_attachment']) - { - $post_attachment[$row['post_id']] = 1; - } - } - $db->sql_freeresult($result); - - $sql = 'SELECT DISTINCT(post_msg_id) - FROM ' . ATTACHMENTS_TABLE . ' - WHERE ' . $db->sql_in_set('post_msg_id', $post_ids) . ' - AND in_message = 0'; - $result = $db->sql_query($sql); - - $post_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - if (!isset($post_attachment[$row['post_msg_id']])) - { - $post_ids[] = $row['post_msg_id']; - } - else - { - unset($post_attachment[$row['post_msg_id']]); - } - } - $db->sql_freeresult($result); - - // $post_attachment should be empty by now, if it's not it contains - // posts that are falsely flagged as having attachments - foreach ($post_attachment as $post_id => $void) - { - $post_ids[] = $post_id; - } - - if (count($post_ids)) - { - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET post_attachment = 1 - post_attachment - WHERE ' . $db->sql_in_set('post_id', $post_ids); - $db->sql_query($sql); - } - - $db->sql_transaction('commit'); - break; - - case 'topic_attachment': - if ($sync_extra) - { - sync('post_attachment', $where_type, $where_ids); - } - - $topic_ids = $topic_attachment = array(); - - $db->sql_transaction('begin'); - - $sql = 'SELECT DISTINCT(t.topic_id) - FROM ' . POSTS_TABLE . " t - $where_sql_and t.post_attachment = 1"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $topic_attachment[$row['topic_id']] = 1; - } - $db->sql_freeresult($result); - - $sql = 'SELECT t.topic_id, t.topic_attachment - FROM ' . TOPICS_TABLE . " t - $where_sql"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if ($row['topic_attachment'] ^ isset($topic_attachment[$row['topic_id']])) - { - $topic_ids[] = $row['topic_id']; - } - } - $db->sql_freeresult($result); - - if (count($topic_ids)) - { - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_attachment = 1 - topic_attachment - WHERE ' . $db->sql_in_set('topic_id', $topic_ids); - $db->sql_query($sql); - } - - $db->sql_transaction('commit'); - - break; - - case 'forum': - - $db->sql_transaction('begin'); - - // 1: Get the list of all forums - $sql = 'SELECT f.* - FROM ' . FORUMS_TABLE . " f - $where_sql"; - $result = $db->sql_query($sql); - - $forum_data = $forum_ids = $post_ids = $last_post_id = $post_info = array(); - while ($row = $db->sql_fetchrow($result)) - { - if ($row['forum_type'] == FORUM_LINK) - { - continue; - } - - $forum_id = (int) $row['forum_id']; - $forum_ids[$forum_id] = $forum_id; - - $forum_data[$forum_id] = $row; - if ($sync_extra) - { - $forum_data[$forum_id]['posts_approved'] = 0; - $forum_data[$forum_id]['posts_unapproved'] = 0; - $forum_data[$forum_id]['posts_softdeleted'] = 0; - $forum_data[$forum_id]['topics_approved'] = 0; - $forum_data[$forum_id]['topics_unapproved'] = 0; - $forum_data[$forum_id]['topics_softdeleted'] = 0; - } - $forum_data[$forum_id]['last_post_id'] = 0; - $forum_data[$forum_id]['last_post_subject'] = ''; - $forum_data[$forum_id]['last_post_time'] = 0; - $forum_data[$forum_id]['last_poster_id'] = 0; - $forum_data[$forum_id]['last_poster_name'] = ''; - $forum_data[$forum_id]['last_poster_colour'] = ''; - } - $db->sql_freeresult($result); - - if (!count($forum_ids)) - { - break; - } - - $forum_ids = array_values($forum_ids); - - // 2: Get topic counts for each forum (optional) - if ($sync_extra) - { - $sql = 'SELECT forum_id, topic_visibility, COUNT(topic_id) AS total_topics - FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $forum_ids) . ' - GROUP BY forum_id, topic_visibility'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $forum_id = (int) $row['forum_id']; - - if ($row['topic_visibility'] == ITEM_APPROVED) - { - $forum_data[$forum_id]['topics_approved'] = $row['total_topics']; - } - else if ($row['topic_visibility'] == ITEM_UNAPPROVED || $row['topic_visibility'] == ITEM_REAPPROVE) - { - $forum_data[$forum_id]['topics_unapproved'] = $row['total_topics']; - } - else if ($row['topic_visibility'] == ITEM_DELETED) - { - $forum_data[$forum_id]['topics_softdeleted'] = $row['total_topics']; - } - } - $db->sql_freeresult($result); - } - - // 3: Get post count for each forum (optional) - if ($sync_extra) - { - if (count($forum_ids) == 1) - { - $sql = 'SELECT SUM(t.topic_posts_approved) AS forum_posts_approved, SUM(t.topic_posts_unapproved) AS forum_posts_unapproved, SUM(t.topic_posts_softdeleted) AS forum_posts_softdeleted - FROM ' . TOPICS_TABLE . ' t - WHERE ' . $db->sql_in_set('t.forum_id', $forum_ids) . ' - AND t.topic_status <> ' . ITEM_MOVED; - } - else - { - $sql = 'SELECT t.forum_id, SUM(t.topic_posts_approved) AS forum_posts_approved, SUM(t.topic_posts_unapproved) AS forum_posts_unapproved, SUM(t.topic_posts_softdeleted) AS forum_posts_softdeleted - FROM ' . TOPICS_TABLE . ' t - WHERE ' . $db->sql_in_set('t.forum_id', $forum_ids) . ' - AND t.topic_status <> ' . ITEM_MOVED . ' - GROUP BY t.forum_id'; - } - - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $forum_id = (count($forum_ids) == 1) ? (int) $forum_ids[0] : (int) $row['forum_id']; - - $forum_data[$forum_id]['posts_approved'] = (int) $row['forum_posts_approved']; - $forum_data[$forum_id]['posts_unapproved'] = (int) $row['forum_posts_unapproved']; - $forum_data[$forum_id]['posts_softdeleted'] = (int) $row['forum_posts_softdeleted']; - } - $db->sql_freeresult($result); - } - - // 4: Get last_post_id for each forum - if (count($forum_ids) == 1) - { - $sql = 'SELECT MAX(t.topic_last_post_id) as last_post_id - FROM ' . TOPICS_TABLE . ' t - WHERE ' . $db->sql_in_set('t.forum_id', $forum_ids) . ' - AND t.topic_visibility = ' . ITEM_APPROVED; - } - else - { - $sql = 'SELECT t.forum_id, MAX(t.topic_last_post_id) as last_post_id - FROM ' . TOPICS_TABLE . ' t - WHERE ' . $db->sql_in_set('t.forum_id', $forum_ids) . ' - AND t.topic_visibility = ' . ITEM_APPROVED . ' - GROUP BY t.forum_id'; - } - - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $forum_id = (count($forum_ids) == 1) ? (int) $forum_ids[0] : (int) $row['forum_id']; - - $forum_data[$forum_id]['last_post_id'] = (int) $row['last_post_id']; - - $post_ids[] = $row['last_post_id']; - } - $db->sql_freeresult($result); - - // 5: Retrieve last_post infos - if (count($post_ids)) - { - $sql = 'SELECT p.post_id, p.poster_id, p.post_subject, p.post_time, p.post_username, u.username, u.user_colour - FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u - WHERE ' . $db->sql_in_set('p.post_id', $post_ids) . ' - AND p.poster_id = u.user_id'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $post_info[$row['post_id']] = $row; - } - $db->sql_freeresult($result); - - foreach ($forum_data as $forum_id => $data) - { - if ($data['last_post_id']) - { - if (isset($post_info[$data['last_post_id']])) - { - $forum_data[$forum_id]['last_post_subject'] = $post_info[$data['last_post_id']]['post_subject']; - $forum_data[$forum_id]['last_post_time'] = $post_info[$data['last_post_id']]['post_time']; - $forum_data[$forum_id]['last_poster_id'] = $post_info[$data['last_post_id']]['poster_id']; - $forum_data[$forum_id]['last_poster_name'] = ($post_info[$data['last_post_id']]['poster_id'] != ANONYMOUS) ? $post_info[$data['last_post_id']]['username'] : $post_info[$data['last_post_id']]['post_username']; - $forum_data[$forum_id]['last_poster_colour'] = $post_info[$data['last_post_id']]['user_colour']; - } - else - { - // For some reason we did not find the post in the db - $forum_data[$forum_id]['last_post_id'] = 0; - $forum_data[$forum_id]['last_post_subject'] = ''; - $forum_data[$forum_id]['last_post_time'] = 0; - $forum_data[$forum_id]['last_poster_id'] = 0; - $forum_data[$forum_id]['last_poster_name'] = ''; - $forum_data[$forum_id]['last_poster_colour'] = ''; - } - } - } - unset($post_info); - } - - // 6: Now do that thing - $fieldnames = array('last_post_id', 'last_post_subject', 'last_post_time', 'last_poster_id', 'last_poster_name', 'last_poster_colour'); - - if ($sync_extra) - { - array_push($fieldnames, 'posts_approved', 'posts_unapproved', 'posts_softdeleted', 'topics_approved', 'topics_unapproved', 'topics_softdeleted'); - } - - foreach ($forum_data as $forum_id => $row) - { - $sql_ary = array(); - - foreach ($fieldnames as $fieldname) - { - if ($row['forum_' . $fieldname] != $row[$fieldname]) - { - if (preg_match('#(name|colour|subject)$#', $fieldname)) - { - $sql_ary['forum_' . $fieldname] = (string) $row[$fieldname]; - } - else - { - $sql_ary['forum_' . $fieldname] = (int) $row[$fieldname]; - } - } - } - - if (count($sql_ary)) - { - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE forum_id = ' . $forum_id; - $db->sql_query($sql); - } - } - - $db->sql_transaction('commit'); - break; - - case 'topic': - $topic_data = $post_ids = $resync_forums = $delete_topics = $delete_posts = $moved_topics = array(); - - $db->sql_transaction('begin'); - - $sql = 'SELECT t.topic_id, t.forum_id, t.topic_moved_id, t.topic_visibility, ' . (($sync_extra) ? 't.topic_attachment, t.topic_reported, ' : '') . 't.topic_poster, t.topic_time, t.topic_posts_approved, t.topic_posts_unapproved, t.topic_posts_softdeleted, t.topic_first_post_id, t.topic_first_poster_name, t.topic_first_poster_colour, t.topic_last_post_id, t.topic_last_post_subject, t.topic_last_poster_id, t.topic_last_poster_name, t.topic_last_poster_colour, t.topic_last_post_time - FROM ' . TOPICS_TABLE . " t - $where_sql"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if ($row['topic_moved_id']) - { - $moved_topics[] = $row['topic_id']; - continue; - } - - $topic_id = (int) $row['topic_id']; - $topic_data[$topic_id] = $row; - $topic_data[$topic_id]['visibility'] = ITEM_UNAPPROVED; - $topic_data[$topic_id]['posts_approved'] = 0; - $topic_data[$topic_id]['posts_unapproved'] = 0; - $topic_data[$topic_id]['posts_softdeleted'] = 0; - $topic_data[$topic_id]['first_post_id'] = 0; - $topic_data[$topic_id]['last_post_id'] = 0; - unset($topic_data[$topic_id]['topic_id']); - - // This array holds all topic_ids - $delete_topics[$topic_id] = ''; - - if ($sync_extra) - { - $topic_data[$topic_id]['reported'] = 0; - $topic_data[$topic_id]['attachment'] = 0; - } - } - $db->sql_freeresult($result); - - // Use "t" as table alias because of the $where_sql clause - // NOTE: 't.post_visibility' in the GROUP BY is causing a major slowdown. - $sql = 'SELECT t.topic_id, t.post_visibility, COUNT(t.post_id) AS total_posts, MIN(t.post_id) AS first_post_id, MAX(t.post_id) AS last_post_id - FROM ' . POSTS_TABLE . " t - $where_sql - GROUP BY t.topic_id, t.post_visibility"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $topic_id = (int) $row['topic_id']; - - $row['first_post_id'] = (int) $row['first_post_id']; - $row['last_post_id'] = (int) $row['last_post_id']; - - if (!isset($topic_data[$topic_id])) - { - // Hey, these posts come from a topic that does not exist - $delete_posts[$topic_id] = ''; - } - else - { - // Unset the corresponding entry in $delete_topics - // When we'll be done, only topics with no posts will remain - unset($delete_topics[$topic_id]); - - if ($row['post_visibility'] == ITEM_APPROVED) - { - $topic_data[$topic_id]['posts_approved'] = $row['total_posts']; - } - else if ($row['post_visibility'] == ITEM_UNAPPROVED || $row['post_visibility'] == ITEM_REAPPROVE) - { - $topic_data[$topic_id]['posts_unapproved'] = $row['total_posts']; - } - else if ($row['post_visibility'] == ITEM_DELETED) - { - $topic_data[$topic_id]['posts_softdeleted'] = $row['total_posts']; - } - - if ($row['post_visibility'] == ITEM_APPROVED) - { - $topic_data[$topic_id]['visibility'] = ITEM_APPROVED; - $topic_data[$topic_id]['first_post_id'] = $row['first_post_id']; - $topic_data[$topic_id]['last_post_id'] = $row['last_post_id']; - } - else if ($topic_data[$topic_id]['visibility'] != ITEM_APPROVED) - { - // If there is no approved post, we take the min/max of the other visibilities - // for the last and first post info, because it is only visible to moderators anyway - $topic_data[$topic_id]['first_post_id'] = (!empty($topic_data[$topic_id]['first_post_id'])) ? min($topic_data[$topic_id]['first_post_id'], $row['first_post_id']) : $row['first_post_id']; - $topic_data[$topic_id]['last_post_id'] = max($topic_data[$topic_id]['last_post_id'], $row['last_post_id']); - - if ($topic_data[$topic_id]['visibility'] == ITEM_UNAPPROVED || $topic_data[$topic_id]['visibility'] == ITEM_REAPPROVE) - { - // Soft delete status is stronger than unapproved. - $topic_data[$topic_id]['visibility'] = $row['post_visibility']; - } - } - } - } - $db->sql_freeresult($result); - - foreach ($topic_data as $topic_id => $row) - { - $post_ids[] = $row['first_post_id']; - if ($row['first_post_id'] != $row['last_post_id']) - { - $post_ids[] = $row['last_post_id']; - } - } - - // Now we delete empty topics and orphan posts - if (count($delete_posts)) - { - delete_posts('topic_id', array_keys($delete_posts), false); - unset($delete_posts); - } - - if (!count($topic_data)) - { - // If we get there, topic ids were invalid or topics did not contain any posts - delete_topics($where_type, $where_ids, true); - return; - } - - if (count($delete_topics)) - { - $delete_topic_ids = array(); - foreach ($delete_topics as $topic_id => $void) - { - unset($topic_data[$topic_id]); - $delete_topic_ids[] = $topic_id; - } - - delete_topics('topic_id', $delete_topic_ids, false); - unset($delete_topics, $delete_topic_ids); - } - - $sql = 'SELECT p.post_id, p.topic_id, p.post_visibility, p.poster_id, p.post_subject, p.post_username, p.post_time, u.username, u.user_colour - FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u - WHERE ' . $db->sql_in_set('p.post_id', $post_ids) . ' - AND u.user_id = p.poster_id'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $topic_id = intval($row['topic_id']); - - if ($row['post_id'] == $topic_data[$topic_id]['first_post_id']) - { - $topic_data[$topic_id]['time'] = $row['post_time']; - $topic_data[$topic_id]['poster'] = $row['poster_id']; - $topic_data[$topic_id]['first_poster_name'] = ($row['poster_id'] == ANONYMOUS) ? $row['post_username'] : $row['username']; - $topic_data[$topic_id]['first_poster_colour'] = $row['user_colour']; - } - - if ($row['post_id'] == $topic_data[$topic_id]['last_post_id']) - { - $topic_data[$topic_id]['last_poster_id'] = $row['poster_id']; - $topic_data[$topic_id]['last_post_subject'] = $row['post_subject']; - $topic_data[$topic_id]['last_post_time'] = $row['post_time']; - $topic_data[$topic_id]['last_poster_name'] = ($row['poster_id'] == ANONYMOUS) ? $row['post_username'] : $row['username']; - $topic_data[$topic_id]['last_poster_colour'] = $row['user_colour']; - } - } - $db->sql_freeresult($result); - - // Make sure shadow topics do link to existing topics - if (count($moved_topics)) - { - $delete_topics = array(); - - $sql = 'SELECT t1.topic_id, t1.topic_moved_id - FROM ' . TOPICS_TABLE . ' t1 - LEFT JOIN ' . TOPICS_TABLE . ' t2 ON (t2.topic_id = t1.topic_moved_id) - WHERE ' . $db->sql_in_set('t1.topic_id', $moved_topics) . ' - AND t2.topic_id IS NULL'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $delete_topics[] = $row['topic_id']; - } - $db->sql_freeresult($result); - - if (count($delete_topics)) - { - delete_topics('topic_id', $delete_topics, false); - } - unset($delete_topics); - - // Make sure shadow topics having no last post data being updated (this only rarely happens...) - $sql = 'SELECT topic_id, topic_moved_id, topic_last_post_id, topic_first_post_id - FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', $moved_topics) . ' - AND topic_last_post_time = 0'; - $result = $db->sql_query($sql); - - $shadow_topic_data = $post_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $shadow_topic_data[$row['topic_moved_id']] = $row; - $post_ids[] = $row['topic_last_post_id']; - $post_ids[] = $row['topic_first_post_id']; - } - $db->sql_freeresult($result); - - $sync_shadow_topics = array(); - if (count($post_ids)) - { - $sql = 'SELECT p.post_id, p.topic_id, p.post_visibility, p.poster_id, p.post_subject, p.post_username, p.post_time, u.username, u.user_colour - FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u - WHERE ' . $db->sql_in_set('p.post_id', $post_ids) . ' - AND u.user_id = p.poster_id'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $topic_id = (int) $row['topic_id']; - - // Ok, there should be a shadow topic. If there isn't, then there's something wrong with the db. - // However, there's not much we can do about it. - if (!empty($shadow_topic_data[$topic_id])) - { - if ($row['post_id'] == $shadow_topic_data[$topic_id]['topic_first_post_id']) - { - $orig_topic_id = $shadow_topic_data[$topic_id]['topic_id']; - - if (!isset($sync_shadow_topics[$orig_topic_id])) - { - $sync_shadow_topics[$orig_topic_id] = array(); - } - - $sync_shadow_topics[$orig_topic_id]['topic_time'] = $row['post_time']; - $sync_shadow_topics[$orig_topic_id]['topic_poster'] = $row['poster_id']; - $sync_shadow_topics[$orig_topic_id]['topic_first_poster_name'] = ($row['poster_id'] == ANONYMOUS) ? $row['post_username'] : $row['username']; - $sync_shadow_topics[$orig_topic_id]['topic_first_poster_colour'] = $row['user_colour']; - } - - if ($row['post_id'] == $shadow_topic_data[$topic_id]['topic_last_post_id']) - { - $orig_topic_id = $shadow_topic_data[$topic_id]['topic_id']; - - if (!isset($sync_shadow_topics[$orig_topic_id])) - { - $sync_shadow_topics[$orig_topic_id] = array(); - } - - $sync_shadow_topics[$orig_topic_id]['topic_last_poster_id'] = $row['poster_id']; - $sync_shadow_topics[$orig_topic_id]['topic_last_post_subject'] = $row['post_subject']; - $sync_shadow_topics[$orig_topic_id]['topic_last_post_time'] = $row['post_time']; - $sync_shadow_topics[$orig_topic_id]['topic_last_poster_name'] = ($row['poster_id'] == ANONYMOUS) ? $row['post_username'] : $row['username']; - $sync_shadow_topics[$orig_topic_id]['topic_last_poster_colour'] = $row['user_colour']; - } - } - } - $db->sql_freeresult($result); - - $shadow_topic_data = array(); - - // Update the information we collected - if (count($sync_shadow_topics)) - { - foreach ($sync_shadow_topics as $sync_topic_id => $sql_ary) - { - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE topic_id = ' . $sync_topic_id; - $db->sql_query($sql); - } - } - } - - unset($sync_shadow_topics, $shadow_topic_data); - } - - // These are fields that will be synchronised - $fieldnames = array('time', 'visibility', 'posts_approved', 'posts_unapproved', 'posts_softdeleted', 'poster', 'first_post_id', 'first_poster_name', 'first_poster_colour', 'last_post_id', 'last_post_subject', 'last_post_time', 'last_poster_id', 'last_poster_name', 'last_poster_colour'); - - if ($sync_extra) - { - // This routine assumes that post_reported values are correct - // if they are not, use sync('post_reported') first - $sql = 'SELECT t.topic_id, p.post_id - FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p - $where_sql_and p.topic_id = t.topic_id - AND p.post_reported = 1 - GROUP BY t.topic_id, p.post_id"; - $result = $db->sql_query($sql); - - $fieldnames[] = 'reported'; - while ($row = $db->sql_fetchrow($result)) - { - $topic_data[intval($row['topic_id'])]['reported'] = 1; - } - $db->sql_freeresult($result); - - // This routine assumes that post_attachment values are correct - // if they are not, use sync('post_attachment') first - $sql = 'SELECT t.topic_id, p.post_id - FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p - $where_sql_and p.topic_id = t.topic_id - AND p.post_attachment = 1 - GROUP BY t.topic_id, p.post_id"; - $result = $db->sql_query($sql); - - $fieldnames[] = 'attachment'; - while ($row = $db->sql_fetchrow($result)) - { - $topic_data[intval($row['topic_id'])]['attachment'] = 1; - } - $db->sql_freeresult($result); - } - - foreach ($topic_data as $topic_id => $row) - { - $sql_ary = array(); - - foreach ($fieldnames as $fieldname) - { - if (isset($row[$fieldname]) && isset($row['topic_' . $fieldname]) && $row['topic_' . $fieldname] != $row[$fieldname]) - { - $sql_ary['topic_' . $fieldname] = $row[$fieldname]; - } - } - - if (count($sql_ary)) - { - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE topic_id = ' . $topic_id; - $db->sql_query($sql); - - $resync_forums[$row['forum_id']] = $row['forum_id']; - } - } - unset($topic_data); - - $db->sql_transaction('commit'); - - // if some topics have been resync'ed then resync parent forums - // except when we're only syncing a range, we don't want to sync forums during - // batch processing. - if ($resync_parents && count($resync_forums) && $where_type != 'range') - { - sync('forum', 'forum_id', array_values($resync_forums), true, true); - } - break; - } - - return; -} - -/** -* Prune function -*/ -function prune($forum_id, $prune_mode, $prune_date, $prune_flags = 0, $auto_sync = true, $prune_limit = 0) -{ - global $db, $phpbb_dispatcher; - - if (!is_array($forum_id)) - { - $forum_id = array($forum_id); - } - - if (!count($forum_id)) - { - return; - } - - $sql_and = ''; - - if (!($prune_flags & FORUM_FLAG_PRUNE_ANNOUNCE)) - { - $sql_and .= ' AND topic_type <> ' . POST_ANNOUNCE; - $sql_and .= ' AND topic_type <> ' . POST_GLOBAL; - } - - if (!($prune_flags & FORUM_FLAG_PRUNE_STICKY)) - { - $sql_and .= ' AND topic_type <> ' . POST_STICKY; - } - - if ($prune_mode == 'posted') - { - $sql_and .= " AND topic_last_post_time < $prune_date"; - } - - if ($prune_mode == 'viewed') - { - $sql_and .= " AND topic_last_view_time < $prune_date"; - } - - if ($prune_mode == 'shadow') - { - $sql_and .= ' AND topic_status = ' . ITEM_MOVED . " AND topic_last_post_time < $prune_date"; - } - - /** - * Use this event to modify the SQL that selects topics to be pruned - * - * @event core.prune_sql - * @var string forum_id The forum id - * @var string prune_mode The prune mode - * @var string prune_date The prune date - * @var int prune_flags The prune flags - * @var bool auto_sync Whether or not to perform auto sync - * @var string sql_and SQL text appended to where clause - * @var int prune_limit The prune limit - * @since 3.1.3-RC1 - * @changed 3.1.10-RC1 Added prune_limit - */ - $vars = array( - 'forum_id', - 'prune_mode', - 'prune_date', - 'prune_flags', - 'auto_sync', - 'sql_and', - 'prune_limit', - ); - extract($phpbb_dispatcher->trigger_event('core.prune_sql', compact($vars))); - - $sql = 'SELECT topic_id - FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $forum_id) . " - AND poll_start = 0 - $sql_and"; - $result = $db->sql_query_limit($sql, $prune_limit); - - $topic_list = array(); - while ($row = $db->sql_fetchrow($result)) - { - $topic_list[] = $row['topic_id']; - } - $db->sql_freeresult($result); - - if ($prune_flags & FORUM_FLAG_PRUNE_POLL) - { - $sql = 'SELECT topic_id - FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $forum_id) . " - AND poll_start > 0 - AND poll_last_vote < $prune_date - $sql_and"; - $result = $db->sql_query_limit($sql, $prune_limit); - - while ($row = $db->sql_fetchrow($result)) - { - $topic_list[] = $row['topic_id']; - } - $db->sql_freeresult($result); - - $topic_list = array_unique($topic_list); - } - - /** - * Perform additional actions before topic deletion via pruning - * - * @event core.prune_delete_before - * @var int[] topic_list The IDs of the topics to be deleted - * @since 3.2.2-RC1 - */ - $vars = array('topic_list'); - extract($phpbb_dispatcher->trigger_event('core.prune_delete_before', compact($vars))); - - return delete_topics('topic_id', $topic_list, $auto_sync, false); -} - -/** -* Function auto_prune(), this function now relies on passed vars -*/ -function auto_prune($forum_id, $prune_mode, $prune_flags, $prune_days, $prune_freq) -{ - global $db, $user, $phpbb_log; - - $sql = 'SELECT forum_name - FROM ' . FORUMS_TABLE . " - WHERE forum_id = $forum_id"; - $result = $db->sql_query($sql, 3600); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - $prune_date = time() - ($prune_days * 86400); - $next_prune = time() + ($prune_freq * 86400); - - $result = prune($forum_id, $prune_mode, $prune_date, $prune_flags, true, 300); - - if ($result['topics'] == 0 && $result['posts'] == 0) - { - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET prune_next = $next_prune - WHERE forum_id = $forum_id"; - $db->sql_query($sql); - } - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_AUTO_PRUNE', false, array($row['forum_name'])); - } - - return; -} - -/** -* Cache moderators. Called whenever permissions are changed -* via admin_permissions. Changes of usernames and group names -* must be carried through for the moderators table. -* -* @param \phpbb\db\driver\driver_interface $db Database connection -* @param \phpbb\cache\driver\driver_interface Cache driver -* @param \phpbb\auth\auth $auth Authentication object -* @return null -*/ -function phpbb_cache_moderators($db, $cache, $auth) -{ - // Remove cached sql results - $cache->destroy('sql', MODERATOR_CACHE_TABLE); - - // Clear table - switch ($db->get_sql_layer()) - { - case 'sqlite3': - $db->sql_query('DELETE FROM ' . MODERATOR_CACHE_TABLE); - break; - - default: - $db->sql_query('TRUNCATE TABLE ' . MODERATOR_CACHE_TABLE); - break; - } - - // We add moderators who have forum moderator permissions without an explicit ACL_NEVER setting - $sql_ary = array(); - - // Grab all users having moderative options... - $hold_ary = $auth->acl_user_raw_data(false, 'm_%', false); - - // Add users? - if (!empty($hold_ary)) - { - // At least one moderative option warrants a display - $ug_id_ary = array_keys($hold_ary); - - // Remove users who have group memberships with DENY moderator permissions - $sql_ary_deny = array( - 'SELECT' => 'a.forum_id, ug.user_id, g.group_id', - - 'FROM' => array( - ACL_OPTIONS_TABLE => 'o', - USER_GROUP_TABLE => 'ug', - GROUPS_TABLE => 'g', - ACL_GROUPS_TABLE => 'a', - ), - - 'LEFT_JOIN' => array( - array( - 'FROM' => array(ACL_ROLES_DATA_TABLE => 'r'), - 'ON' => 'a.auth_role_id = r.role_id', - ), - ), - - 'WHERE' => '(o.auth_option_id = a.auth_option_id OR o.auth_option_id = r.auth_option_id) - AND ((a.auth_setting = ' . ACL_NEVER . ' AND r.auth_setting IS NULL) - OR r.auth_setting = ' . ACL_NEVER . ') - AND a.group_id = ug.group_id - AND g.group_id = ug.group_id - AND NOT (ug.group_leader = 1 AND g.group_skip_auth = 1) - AND ' . $db->sql_in_set('ug.user_id', $ug_id_ary) . " - AND ug.user_pending = 0 - AND o.auth_option " . $db->sql_like_expression('m_' . $db->get_any_char()), - ); - $sql = $db->sql_build_query('SELECT', $sql_ary_deny); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if (isset($hold_ary[$row['user_id']][$row['forum_id']])) - { - unset($hold_ary[$row['user_id']][$row['forum_id']]); - } - } - $db->sql_freeresult($result); - - if (count($hold_ary)) - { - // Get usernames... - $sql = 'SELECT user_id, username - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('user_id', array_keys($hold_ary)); - $result = $db->sql_query($sql); - - $usernames_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - $usernames_ary[$row['user_id']] = $row['username']; - } - $db->sql_freeresult($result); - - foreach ($hold_ary as $user_id => $forum_id_ary) - { - // Do not continue if user does not exist - if (!isset($usernames_ary[$user_id])) - { - continue; - } - - foreach ($forum_id_ary as $forum_id => $auth_ary) - { - $sql_ary[] = array( - 'forum_id' => (int) $forum_id, - 'user_id' => (int) $user_id, - 'username' => (string) $usernames_ary[$user_id], - 'group_id' => 0, - 'group_name' => '' - ); - } - } - } - } - - // Now to the groups... - $hold_ary = $auth->acl_group_raw_data(false, 'm_%', false); - - if (!empty($hold_ary)) - { - $ug_id_ary = array_keys($hold_ary); - - // Make sure not hidden or special groups are involved... - $sql = 'SELECT group_name, group_id, group_type - FROM ' . GROUPS_TABLE . ' - WHERE ' . $db->sql_in_set('group_id', $ug_id_ary); - $result = $db->sql_query($sql); - - $groupnames_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - if ($row['group_type'] == GROUP_HIDDEN || $row['group_type'] == GROUP_SPECIAL) - { - unset($hold_ary[$row['group_id']]); - } - - $groupnames_ary[$row['group_id']] = $row['group_name']; - } - $db->sql_freeresult($result); - - foreach ($hold_ary as $group_id => $forum_id_ary) - { - // If there is no group, we do not assign it... - if (!isset($groupnames_ary[$group_id])) - { - continue; - } - - foreach ($forum_id_ary as $forum_id => $auth_ary) - { - $flag = false; - foreach ($auth_ary as $auth_option => $setting) - { - // Make sure at least one ACL_YES option is set... - if ($setting == ACL_YES) - { - $flag = true; - break; - } - } - - if (!$flag) - { - continue; - } - - $sql_ary[] = array( - 'forum_id' => (int) $forum_id, - 'user_id' => 0, - 'username' => '', - 'group_id' => (int) $group_id, - 'group_name' => (string) $groupnames_ary[$group_id] - ); - } - } - } - - $db->sql_multi_insert(MODERATOR_CACHE_TABLE, $sql_ary); -} - -/** -* View log -* -* @param string $mode The mode defines which log_type is used and from which log the entry is retrieved -* @param array &$log The result array with the logs -* @param mixed &$log_count If $log_count is set to false, we will skip counting all entries in the database. -* Otherwise an integer with the number of total matching entries is returned. -* @param int $limit Limit the number of entries that are returned -* @param int $offset Offset when fetching the log entries, f.e. when paginating -* @param mixed $forum_id Restrict the log entries to the given forum_id (can also be an array of forum_ids) -* @param int $topic_id Restrict the log entries to the given topic_id -* @param int $user_id Restrict the log entries to the given user_id -* @param int $log_time Only get log entries newer than the given timestamp -* @param string $sort_by SQL order option, e.g. 'l.log_time DESC' -* @param string $keywords Will only return log entries that have the keywords in log_operation or log_data -* -* @return int Returns the offset of the last valid page, if the specified offset was invalid (too high) -*/ -function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $limit_days = 0, $sort_by = 'l.log_time DESC', $keywords = '') -{ - global $phpbb_log; - - $count_logs = ($log_count !== false); - - $log = $phpbb_log->get_logs($mode, $count_logs, $limit, $offset, $forum_id, $topic_id, $user_id, $limit_days, $sort_by, $keywords); - $log_count = $phpbb_log->get_log_count(); - - return $phpbb_log->get_valid_offset(); -} - -/** -* Removes moderators and administrators from foe lists. -* -* @param \phpbb\db\driver\driver_interface $db Database connection -* @param \phpbb\auth\auth $auth Authentication object -* @param array|bool $group_id If an array, remove all members of this group from foe lists, or false to ignore -* @param array|bool $user_id If an array, remove this user from foe lists, or false to ignore -* @return null -*/ -function phpbb_update_foes($db, $auth, $group_id = false, $user_id = false) -{ - // update foes for some user - if (is_array($user_id) && count($user_id)) - { - $sql = 'DELETE FROM ' . ZEBRA_TABLE . ' - WHERE ' . $db->sql_in_set('zebra_id', $user_id) . ' - AND foe = 1'; - $db->sql_query($sql); - return; - } - - // update foes for some group - if (is_array($group_id) && count($group_id)) - { - // Grab group settings... - $sql_ary = array( - 'SELECT' => 'a.group_id', - - 'FROM' => array( - ACL_OPTIONS_TABLE => 'ao', - ACL_GROUPS_TABLE => 'a', - ), - - 'LEFT_JOIN' => array( - array( - 'FROM' => array(ACL_ROLES_DATA_TABLE => 'r'), - 'ON' => 'a.auth_role_id = r.role_id', - ), - ), - - 'WHERE' => '(ao.auth_option_id = a.auth_option_id OR ao.auth_option_id = r.auth_option_id) - AND ' . $db->sql_in_set('a.group_id', $group_id) . " - AND ao.auth_option IN ('a_', 'm_')", - - 'GROUP_BY' => 'a.group_id', - ); - $sql = $db->sql_build_query('SELECT', $sql_ary); - $result = $db->sql_query($sql); - - $groups = array(); - while ($row = $db->sql_fetchrow($result)) - { - $groups[] = (int) $row['group_id']; - } - $db->sql_freeresult($result); - - if (!count($groups)) - { - return; - } - - switch ($db->get_sql_layer()) - { - case 'mysqli': - case 'mysql4': - $sql = 'DELETE ' . (($db->get_sql_layer() === 'mysqli' || version_compare($db->sql_server_info(true), '4.1', '>=')) ? 'z.*' : ZEBRA_TABLE) . ' - FROM ' . ZEBRA_TABLE . ' z, ' . USER_GROUP_TABLE . ' ug - WHERE z.zebra_id = ug.user_id - AND z.foe = 1 - AND ' . $db->sql_in_set('ug.group_id', $groups); - $db->sql_query($sql); - break; - - default: - $sql = 'SELECT user_id - FROM ' . USER_GROUP_TABLE . ' - WHERE ' . $db->sql_in_set('group_id', $groups); - $result = $db->sql_query($sql); - - $users = array(); - while ($row = $db->sql_fetchrow($result)) - { - $users[] = (int) $row['user_id']; - } - $db->sql_freeresult($result); - - if (count($users)) - { - $sql = 'DELETE FROM ' . ZEBRA_TABLE . ' - WHERE ' . $db->sql_in_set('zebra_id', $users) . ' - AND foe = 1'; - $db->sql_query($sql); - } - break; - } - - return; - } - - // update foes for everyone - $perms = array(); - foreach ($auth->acl_get_list(false, array('a_', 'm_'), false) as $forum_id => $forum_ary) - { - foreach ($forum_ary as $auth_option => $user_ary) - { - $perms = array_merge($perms, $user_ary); - } - } - - if (count($perms)) - { - $sql = 'DELETE FROM ' . ZEBRA_TABLE . ' - WHERE ' . $db->sql_in_set('zebra_id', array_unique($perms)) . ' - AND foe = 1'; - $db->sql_query($sql); - } - unset($perms); -} - -/** -* Lists inactive users -*/ -function view_inactive_users(&$users, &$user_count, $limit = 0, $offset = 0, $limit_days = 0, $sort_by = 'user_inactive_time DESC') -{ - global $db, $user; - - $sql = 'SELECT COUNT(user_id) AS user_count - FROM ' . USERS_TABLE . ' - WHERE user_type = ' . USER_INACTIVE . - (($limit_days) ? " AND user_inactive_time >= $limit_days" : ''); - $result = $db->sql_query($sql); - $user_count = (int) $db->sql_fetchfield('user_count'); - $db->sql_freeresult($result); - - if ($user_count == 0) - { - // Save the queries, because there are no users to display - return 0; - } - - if ($offset >= $user_count) - { - $offset = ($offset - $limit < 0) ? 0 : $offset - $limit; - } - - $sql = 'SELECT * - FROM ' . USERS_TABLE . ' - WHERE user_type = ' . USER_INACTIVE . - (($limit_days) ? " AND user_inactive_time >= $limit_days" : '') . " - ORDER BY $sort_by"; - $result = $db->sql_query_limit($sql, $limit, $offset); - - while ($row = $db->sql_fetchrow($result)) - { - $row['inactive_reason'] = $user->lang['INACTIVE_REASON_UNKNOWN']; - switch ($row['user_inactive_reason']) - { - case INACTIVE_REGISTER: - $row['inactive_reason'] = $user->lang['INACTIVE_REASON_REGISTER']; - break; - - case INACTIVE_PROFILE: - $row['inactive_reason'] = $user->lang['INACTIVE_REASON_PROFILE']; - break; - - case INACTIVE_MANUAL: - $row['inactive_reason'] = $user->lang['INACTIVE_REASON_MANUAL']; - break; - - case INACTIVE_REMIND: - $row['inactive_reason'] = $user->lang['INACTIVE_REASON_REMIND']; - break; - } - - $users[] = $row; - } - $db->sql_freeresult($result); - - return $offset; -} - -/** -* Lists warned users -*/ -function view_warned_users(&$users, &$user_count, $limit = 0, $offset = 0, $limit_days = 0, $sort_by = 'user_warnings DESC') -{ - global $db; - - $sql = 'SELECT user_id, username, user_colour, user_warnings, user_last_warning - FROM ' . USERS_TABLE . ' - WHERE user_warnings > 0 - ' . (($limit_days) ? "AND user_last_warning >= $limit_days" : '') . " - ORDER BY $sort_by"; - $result = $db->sql_query_limit($sql, $limit, $offset); - $users = $db->sql_fetchrowset($result); - $db->sql_freeresult($result); - - $sql = 'SELECT count(user_id) AS user_count - FROM ' . USERS_TABLE . ' - WHERE user_warnings > 0 - ' . (($limit_days) ? "AND user_last_warning >= $limit_days" : ''); - $result = $db->sql_query($sql); - $user_count = (int) $db->sql_fetchfield('user_count'); - $db->sql_freeresult($result); - - return; -} - -/** -* Get database size -* Currently only mysql and mssql are supported -*/ -function get_database_size() -{ - global $db, $user, $table_prefix; - - $database_size = false; - - // This code is heavily influenced by a similar routine in phpMyAdmin 2.2.0 - switch ($db->get_sql_layer()) - { - case 'mysql': - case 'mysql4': - case 'mysqli': - $sql = 'SELECT VERSION() AS mysql_version'; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - $version = $row['mysql_version']; - - if (preg_match('#(3\.23|[45]\.|10\.[0-9]\.[0-9]{1,2}-+Maria)#', $version)) - { - $db_name = (preg_match('#^(?:3\.23\.(?:[6-9]|[1-9]{2}))|[45]\.|10\.[0-9]\.[0-9]{1,2}-+Maria#', $version)) ? "`{$db->get_db_name()}`" : $db->get_db_name(); - - $sql = 'SHOW TABLE STATUS - FROM ' . $db_name; - $result = $db->sql_query($sql, 7200); - - $database_size = 0; - while ($row = $db->sql_fetchrow($result)) - { - if ((isset($row['Type']) && $row['Type'] != 'MRG_MyISAM') || (isset($row['Engine']) && ($row['Engine'] == 'MyISAM' || $row['Engine'] == 'InnoDB' || $row['Engine'] == 'Aria'))) - { - if ($table_prefix != '') - { - if (strpos($row['Name'], $table_prefix) !== false) - { - $database_size += $row['Data_length'] + $row['Index_length']; - } - } - else - { - $database_size += $row['Data_length'] + $row['Index_length']; - } - } - } - $db->sql_freeresult($result); - } - } - break; - - case 'sqlite3': - global $dbhost; - - if (file_exists($dbhost)) - { - $database_size = filesize($dbhost); - } - - break; - - case 'mssql_odbc': - case 'mssqlnative': - $sql = 'SELECT @@VERSION AS mssql_version'; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $sql = 'SELECT ((SUM(size) * 8.0) * 1024.0) as dbsize - FROM sysfiles'; - - if ($row) - { - // Azure stats are stored elsewhere - if (strpos($row['mssql_version'], 'SQL Azure') !== false) - { - $sql = 'SELECT ((SUM(reserved_page_count) * 8.0) * 1024.0) as dbsize - FROM sys.dm_db_partition_stats'; - } - } - - $result = $db->sql_query($sql, 7200); - $database_size = ($row = $db->sql_fetchrow($result)) ? $row['dbsize'] : false; - $db->sql_freeresult($result); - break; - - case 'postgres': - $sql = "SELECT proname - FROM pg_proc - WHERE proname = 'pg_database_size'"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row['proname'] == 'pg_database_size') - { - $database = $db->get_db_name(); - if (strpos($database, '.') !== false) - { - list($database, ) = explode('.', $database); - } - - $sql = "SELECT oid - FROM pg_database - WHERE datname = '$database'"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $oid = $row['oid']; - - $sql = 'SELECT pg_database_size(' . $oid . ') as size'; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $database_size = $row['size']; - } - break; - - case 'oracle': - $sql = 'SELECT SUM(bytes) as dbsize - FROM user_segments'; - $result = $db->sql_query($sql, 7200); - $database_size = ($row = $db->sql_fetchrow($result)) ? $row['dbsize'] : false; - $db->sql_freeresult($result); - break; - } - - $database_size = ($database_size !== false) ? get_formatted_filesize($database_size) : $user->lang['NOT_AVAILABLE']; - - return $database_size; -} - -/* -* Tidy Warnings -* Remove all warnings which have now expired from the database -* The duration of a warning can be defined by the administrator -* This only removes the warning and reduces the associated count, -* it does not remove the user note recording the contents of the warning -*/ -function tidy_warnings() -{ - global $db, $config; - - $expire_date = time() - ($config['warnings_expire_days'] * 86400); - $warning_list = $user_list = array(); - - $sql = 'SELECT * FROM ' . WARNINGS_TABLE . " - WHERE warning_time < $expire_date"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $warning_list[] = $row['warning_id']; - $user_list[$row['user_id']] = isset($user_list[$row['user_id']]) ? ++$user_list[$row['user_id']] : 1; - } - $db->sql_freeresult($result); - - if (count($warning_list)) - { - $db->sql_transaction('begin'); - - $sql = 'DELETE FROM ' . WARNINGS_TABLE . ' - WHERE ' . $db->sql_in_set('warning_id', $warning_list); - $db->sql_query($sql); - - foreach ($user_list as $user_id => $value) - { - $sql = 'UPDATE ' . USERS_TABLE . " SET user_warnings = user_warnings - $value - WHERE user_id = $user_id"; - $db->sql_query($sql); - } - - $db->sql_transaction('commit'); - } - - $config->set('warnings_last_gc', time(), false); -} - -/** -* Tidy database, doing some maintanance tasks -*/ -function tidy_database() -{ - global $config, $db; - - // Here we check permission consistency - - // Sometimes, it can happen permission tables having forums listed which do not exist - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE; - $result = $db->sql_query($sql); - - $forum_ids = array(0); - while ($row = $db->sql_fetchrow($result)) - { - $forum_ids[] = $row['forum_id']; - } - $db->sql_freeresult($result); - - $db->sql_transaction('begin'); - - // Delete those rows from the acl tables not having listed the forums above - $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $forum_ids, true); - $db->sql_query($sql); - - $sql = 'DELETE FROM ' . ACL_USERS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $forum_ids, true); - $db->sql_query($sql); - - $db->sql_transaction('commit'); - - $config->set('database_last_gc', time(), false); -} - -/** -* Add permission language - this will make sure custom files will be included -*/ -function add_permission_language() -{ - global $user, $phpEx, $phpbb_extension_manager; - - // add permission language files from extensions - $finder = $phpbb_extension_manager->get_finder(); - - $lang_files = $finder - ->prefix('permissions_') - ->suffix(".$phpEx") - ->core_path('language/') - ->extension_directory('/language') - ->find(); - - foreach ($lang_files as $lang_file => $ext_name) - { - if ($ext_name === '/') - { - $user->add_lang($lang_file); - } - else - { - $user->add_lang_ext($ext_name, $lang_file); - } - } -} - -/** - * Enables a particular flag in a bitfield column of a given table. - * - * @param string $table_name The table to update - * @param string $column_name The column containing a bitfield to update - * @param int $flag The binary flag which is OR-ed with the current column value - * @param string $sql_more This string is attached to the sql query generated to update the table. - * - * @return null - */ -function enable_bitfield_column_flag($table_name, $column_name, $flag, $sql_more = '') -{ - global $db; - - $sql = 'UPDATE ' . $table_name . ' - SET ' . $column_name . ' = ' . $db->sql_bit_or($column_name, $flag) . ' - ' . $sql_more; - $db->sql_query($sql); -} diff --git a/install/update/old/includes/functions_compatibility.php b/install/update/old/includes/functions_compatibility.php deleted file mode 100644 index e95fa40..0000000 --- a/install/update/old/includes/functions_compatibility.php +++ /dev/null @@ -1,513 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* Get user avatar -* -* @deprecated 3.1.0-a1 (To be removed: 3.3.0) -* -* @param string $avatar Users assigned avatar name -* @param int $avatar_type Type of avatar -* @param string $avatar_width Width of users avatar -* @param string $avatar_height Height of users avatar -* @param string $alt Optional language string for alt tag within image, can be a language key or text -* @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP -* @param bool $lazy If true, will be lazy loaded (requires JS) -* -* @return string Avatar image -*/ -function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $alt = 'USER_AVATAR', $ignore_config = false, $lazy = false) -{ - // map arguments to new function phpbb_get_avatar() - $row = array( - 'avatar' => $avatar, - 'avatar_type' => $avatar_type, - 'avatar_width' => $avatar_width, - 'avatar_height' => $avatar_height, - ); - - return phpbb_get_avatar($row, $alt, $ignore_config, $lazy); -} - -/** -* Hash the password -* -* @deprecated 3.1.0-a2 (To be removed: 3.3.0) -* -* @param string $password Password to be hashed -* -* @return string|bool Password hash or false if something went wrong during hashing -*/ -function phpbb_hash($password) -{ - global $phpbb_container; - - /* @var $passwords_manager \phpbb\passwords\manager */ - $passwords_manager = $phpbb_container->get('passwords.manager'); - return $passwords_manager->hash($password); -} - -/** -* Check for correct password -* -* @deprecated 3.1.0-a2 (To be removed: 3.3.0) -* -* @param string $password The password in plain text -* @param string $hash The stored password hash -* -* @return bool Returns true if the password is correct, false if not. -*/ -function phpbb_check_hash($password, $hash) -{ - global $phpbb_container; - - /* @var $passwords_manager \phpbb\passwords\manager */ - $passwords_manager = $phpbb_container->get('passwords.manager'); - return $passwords_manager->check($password, $hash); -} - -/** -* Eliminates useless . and .. components from specified path. -* -* Deprecated, use filesystem class instead -* -* @param string $path Path to clean -* @return string Cleaned path -* -* @deprecated 3.1.0 (To be removed: 3.3.0) -*/ -function phpbb_clean_path($path) -{ - global $phpbb_path_helper, $phpbb_container; - - if (!$phpbb_path_helper && $phpbb_container) - { - /* @var $phpbb_path_helper \phpbb\path_helper */ - $phpbb_path_helper = $phpbb_container->get('path_helper'); - } - else if (!$phpbb_path_helper) - { - global $phpbb_root_path, $phpEx; - - // The container is not yet loaded, use a new instance - if (!class_exists('\phpbb\path_helper')) - { - require($phpbb_root_path . 'phpbb/path_helper.' . $phpEx); - } - - $request = new phpbb\request\request(); - $phpbb_path_helper = new phpbb\path_helper( - new phpbb\symfony_request( - $request - ), - new phpbb\filesystem\filesystem(), - $request, - $phpbb_root_path, - $phpEx - ); - } - - return $phpbb_path_helper->clean_path($path); -} - -/** -* Pick a timezone -* -* @param string $default A timezone to select -* @param boolean $truncate Shall we truncate the options text -* -* @return string Returns the options for timezone selector only -* -* @deprecated 3.1.0 (To be removed: 3.3.0) -*/ -function tz_select($default = '', $truncate = false) -{ - global $template, $user; - - return phpbb_timezone_select($template, $user, $default, $truncate); -} - -/** -* Cache moderators. Called whenever permissions are changed -* via admin_permissions. Changes of usernames and group names -* must be carried through for the moderators table. -* -* @deprecated 3.1.0 (To be removed: 3.3.0) -* @return null -*/ -function cache_moderators() -{ - global $db, $cache, $auth; - return phpbb_cache_moderators($db, $cache, $auth); -} - -/** -* Removes moderators and administrators from foe lists. -* -* @deprecated 3.1.0 (To be removed: 3.3.0) -* @param array|bool $group_id If an array, remove all members of this group from foe lists, or false to ignore -* @param array|bool $user_id If an array, remove this user from foe lists, or false to ignore -* @return null -*/ -function update_foes($group_id = false, $user_id = false) -{ - global $db, $auth; - return phpbb_update_foes($db, $auth, $group_id, $user_id); -} - -/** -* Get user rank title and image -* -* @param int $user_rank the current stored users rank id -* @param int $user_posts the users number of posts -* @param string &$rank_title the rank title will be stored here after execution -* @param string &$rank_img the rank image as full img tag is stored here after execution -* @param string &$rank_img_src the rank image source is stored here after execution -* -* @deprecated 3.1.0-RC5 (To be removed: 3.3.0) -* -* Note: since we do not want to break backwards-compatibility, this function will only properly assign ranks to guests if you call it for them with user_posts == false -*/ -function get_user_rank($user_rank, $user_posts, &$rank_title, &$rank_img, &$rank_img_src) -{ - global $phpbb_root_path, $phpEx; - if (!function_exists('phpbb_get_user_rank')) - { - include($phpbb_root_path . 'includes/functions_display.' . $phpEx); - } - - $rank_data = phpbb_get_user_rank(array('user_rank' => $user_rank), $user_posts); - $rank_title = $rank_data['title']; - $rank_img = $rank_data['img']; - $rank_img_src = $rank_data['img_src']; -} - -/** - * Retrieve contents from remotely stored file - * - * @deprecated 3.1.2 Use file_downloader instead - */ -function get_remote_file($host, $directory, $filename, &$errstr, &$errno, $port = 80, $timeout = 6) -{ - global $phpbb_container; - - // Get file downloader and assign $errstr and $errno - /* @var $file_downloader \phpbb\file_downloader */ - $file_downloader = $phpbb_container->get('file_downloader'); - - $file_data = $file_downloader->get($host, $directory, $filename, $port, $timeout); - $errstr = $file_downloader->get_error_string(); - $errno = $file_downloader->get_error_number(); - - return $file_data; -} - -/** - * Add log entry - * - * @param string $mode The mode defines which log_type is used and from which log the entry is retrieved - * @param int $forum_id Mode 'mod' ONLY: forum id of the related item, NOT INCLUDED otherwise - * @param int $topic_id Mode 'mod' ONLY: topic id of the related item, NOT INCLUDED otherwise - * @param int $reportee_id Mode 'user' ONLY: user id of the reportee, NOT INCLUDED otherwise - * @param string $log_operation Name of the operation - * @param array $additional_data More arguments can be added, depending on the log_type - * - * @return int|bool Returns the log_id, if the entry was added to the database, false otherwise. - * - * @deprecated 3.1.0 (To be removed: 3.3.0) - */ -function add_log() -{ - global $phpbb_log, $user; - - $args = func_get_args(); - $mode = array_shift($args); - - // This looks kind of dirty, but add_log has some additional data before the log_operation - $additional_data = array(); - switch ($mode) - { - case 'admin': - case 'critical': - break; - case 'mod': - $additional_data['forum_id'] = array_shift($args); - $additional_data['topic_id'] = array_shift($args); - break; - case 'user': - $additional_data['reportee_id'] = array_shift($args); - break; - } - - $log_operation = array_shift($args); - $additional_data = array_merge($additional_data, $args); - - $user_id = (empty($user->data)) ? ANONYMOUS : $user->data['user_id']; - $user_ip = (empty($user->ip)) ? '' : $user->ip; - - return $phpbb_log->add($mode, $user_id, $user_ip, $log_operation, time(), $additional_data); -} - -/** - * Sets a configuration option's value. - * - * Please note that this function does not update the is_dynamic value for - * an already existing config option. - * - * @param string $config_name The configuration option's name - * @param string $config_value New configuration value - * @param bool $is_dynamic Whether this variable should be cached (false) or - * if it changes too frequently (true) to be - * efficiently cached. - * - * @return null - * - * @deprecated 3.1.0 (To be removed: 3.3.0) - */ -function set_config($config_name, $config_value, $is_dynamic = false, \phpbb\config\config $set_config = null) -{ - static $config = null; - - if ($set_config !== null) - { - $config = $set_config; - - if (empty($config_name)) - { - return; - } - } - - $config->set($config_name, $config_value, !$is_dynamic); -} - -/** - * Increments an integer config value directly in the database. - * - * @param string $config_name The configuration option's name - * @param int $increment Amount to increment by - * @param bool $is_dynamic Whether this variable should be cached (false) or - * if it changes too frequently (true) to be - * efficiently cached. - * - * @return null - * - * @deprecated 3.1.0 (To be removed: 3.3.0) - */ -function set_config_count($config_name, $increment, $is_dynamic = false, \phpbb\config\config $set_config = null) -{ - static $config = null; - if ($set_config !== null) - { - $config = $set_config; - if (empty($config_name)) - { - return; - } - } - $config->increment($config_name, $increment, !$is_dynamic); -} - -/** - * Wrapper function of \phpbb\request\request::variable which exists for backwards compatability. - * See {@link \phpbb\request\request_interface::variable \phpbb\request\request_interface::variable} for - * documentation of this function's use. - * - * @deprecated 3.1.0 (To be removed: 3.3.0) - * @param mixed $var_name The form variable's name from which data shall be retrieved. - * If the value is an array this may be an array of indizes which will give - * direct access to a value at any depth. E.g. if the value of "var" is array(1 => "a") - * then specifying array("var", 1) as the name will return "a". - * If you pass an instance of {@link \phpbb\request\request_interface phpbb_request_interface} - * as this parameter it will overwrite the current request class instance. If you do - * not do so, it will create its own instance (but leave superglobals enabled). - * @param mixed $default A default value that is returned if the variable was not set. - * This function will always return a value of the same type as the default. - * @param bool $multibyte If $default is a string this paramater has to be true if the variable may contain any UTF-8 characters - * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks - * @param bool $cookie This param is mapped to \phpbb\request\request_interface::COOKIE as the last param for - * \phpbb\request\request_interface::variable for backwards compatability reasons. - * @param \phpbb\request\request_interface|null|false If an instance of \phpbb\request\request_interface is given the instance is stored in - * a static variable and used for all further calls where this parameters is null. Until - * the function is called with an instance it automatically creates a new \phpbb\request\request - * instance on every call. By passing false this per-call instantiation can be restored - * after having passed in a \phpbb\request\request_interface instance. - * - * @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the - * the same as that of $default. If the variable is not set $default is returned. - */ -function request_var($var_name, $default, $multibyte = false, $cookie = false, $request = null) -{ - // This is all just an ugly hack to add "Dependency Injection" to a function - // the only real code is the function call which maps this function to a method. - static $static_request = null; - if ($request instanceof \phpbb\request\request_interface) - { - $static_request = $request; - if (empty($var_name)) - { - return; - } - } - else if ($request === false) - { - $static_request = null; - if (empty($var_name)) - { - return; - } - } - $tmp_request = $static_request; - // no request class set, create a temporary one ourselves to keep backwards compatibility - if ($tmp_request === null) - { - // false param: enable super globals, so the created request class does not - // make super globals inaccessible everywhere outside this function. - $tmp_request = new \phpbb\request\request(new \phpbb\request\type_cast_helper(), false); - } - return $tmp_request->variable($var_name, $default, $multibyte, ($cookie) ? \phpbb\request\request_interface::COOKIE : \phpbb\request\request_interface::REQUEST); -} - -/** - * Get tables of a database - * - * @deprecated 3.1.0 (To be removed: 3.3.0) - */ -function get_tables($db) -{ - $db_tools_factory = new \phpbb\db\tools\factory(); - $db_tools = $db_tools_factory->get($db); - - return $db_tools->sql_list_tables(); -} - -/** - * Global function for chmodding directories and files for internal use - * - * This function determines owner and group whom the file belongs to and user and group of PHP and then set safest possible file permissions. - * The function determines owner and group from common.php file and sets the same to the provided file. - * The function uses bit fields to build the permissions. - * The function sets the appropiate execute bit on directories. - * - * Supported constants representing bit fields are: - * - * CHMOD_ALL - all permissions (7) - * CHMOD_READ - read permission (4) - * CHMOD_WRITE - write permission (2) - * CHMOD_EXECUTE - execute permission (1) - * - * NOTE: The function uses POSIX extension and fileowner()/filegroup() functions. If any of them is disabled, this function tries to build proper permissions, by calling is_readable() and is_writable() functions. - * - * @param string $filename The file/directory to be chmodded - * @param int $perms Permissions to set - * - * @return bool true on success, otherwise false - * - * @deprecated 3.2.0-dev use \phpbb\filesystem\filesystem::phpbb_chmod() instead - */ -function phpbb_chmod($filename, $perms = CHMOD_READ) -{ - global $phpbb_filesystem; - - try - { - $phpbb_filesystem->phpbb_chmod($filename, $perms); - } - catch (\phpbb\filesystem\exception\filesystem_exception $e) - { - return false; - } - - return true; -} - -/** - * Test if a file/directory is writable - * - * This function calls the native is_writable() when not running under - * Windows and it is not disabled. - * - * @param string $file Path to perform write test on - * @return bool True when the path is writable, otherwise false. - * - * @deprecated 3.2.0-dev use \phpbb\filesystem\filesystem::is_writable() instead - */ -function phpbb_is_writable($file) -{ - global $phpbb_filesystem; - - return $phpbb_filesystem->is_writable($file); -} - -/** - * Checks if a path ($path) is absolute or relative - * - * @param string $path Path to check absoluteness of - * @return boolean - * - * @deprecated 3.2.0-dev use \phpbb\filesystem\filesystem::is_absolute_path() instead - */ -function phpbb_is_absolute($path) -{ - global $phpbb_filesystem; - - return $phpbb_filesystem->is_absolute_path($path); -} - -/** - * A wrapper for realpath - * - * @deprecated 3.2.0-dev use \phpbb\filesystem\filesystem::realpath() instead - */ -function phpbb_realpath($path) -{ - global $phpbb_filesystem; - - return $phpbb_filesystem->realpath($path); -} - -/** - * Determine which plural form we should use. - * For some languages this is not as simple as for English. - * - * @param $rule int ID of the plural rule we want to use, see https://area51.phpbb.com/docs/dev/32x/language/plurals.html - * @param $number int|float The number we want to get the plural case for. Float numbers are floored. - * @return int The plural-case we need to use for the number plural-rule combination - * - * @deprecated 3.2.0-dev (To be removed: 3.3.0) - */ -function phpbb_get_plural_form($rule, $number) -{ - global $phpbb_container; - - /** @var \phpbb\language\language $language */ - $language = $phpbb_container->get('language'); - return $language->get_plural_form($number, $rule); -} - -/** -* @return bool Always true -* @deprecated 3.2.0-dev -*/ -function phpbb_pcre_utf8_support() -{ - return true; -} diff --git a/install/update/old/includes/functions_compress.php b/install/update/old/includes/functions_compress.php deleted file mode 100644 index e86da77..0000000 --- a/install/update/old/includes/functions_compress.php +++ /dev/null @@ -1,830 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* Class for handling archives (compression/decompression) -*/ -class compress -{ - var $fp = 0; - - /** - * @var array - */ - protected $filelist = array(); - - /** - * Add file to archive - */ - function add_file($src, $src_rm_prefix = '', $src_add_prefix = '', $skip_files = '') - { - global $phpbb_root_path; - - $skip_files = explode(',', $skip_files); - - // Remove rm prefix from src path - $src_path = ($src_rm_prefix) ? preg_replace('#^(' . preg_quote($src_rm_prefix, '#') . ')#', '', $src) : $src; - // Add src prefix - $src_path = ($src_add_prefix) ? ($src_add_prefix . ((substr($src_add_prefix, -1) != '/') ? '/' : '') . $src_path) : $src_path; - // Remove initial "/" if present - $src_path = (substr($src_path, 0, 1) == '/') ? substr($src_path, 1) : $src_path; - - if (is_file($phpbb_root_path . $src)) - { - $this->data($src_path, file_get_contents("$phpbb_root_path$src"), stat("$phpbb_root_path$src"), false); - } - else if (is_dir($phpbb_root_path . $src)) - { - // Clean up path, add closing / if not present - $src_path = ($src_path && substr($src_path, -1) != '/') ? $src_path . '/' : $src_path; - - $filelist = filelist("$phpbb_root_path$src", '', '*'); - krsort($filelist); - - /** - * Commented out, as adding the folders produces corrupted archives - if ($src_path) - { - $this->data($src_path, '', true, stat("$phpbb_root_path$src")); - } - */ - - foreach ($filelist as $path => $file_ary) - { - /** - * Commented out, as adding the folders produces corrupted archives - if ($path) - { - // Same as for src_path - $path = (substr($path, 0, 1) == '/') ? substr($path, 1) : $path; - $path = ($path && substr($path, -1) != '/') ? $path . '/' : $path; - - $this->data("$src_path$path", '', true, stat("$phpbb_root_path$src$path")); - } - */ - - foreach ($file_ary as $file) - { - if (in_array($path . $file, $skip_files)) - { - continue; - } - - $this->data("$src_path$path$file", file_get_contents("$phpbb_root_path$src$path$file"), stat("$phpbb_root_path$src$path$file"), false); - } - } - } - else - { - // $src does not exist - return false; - } - - return true; - } - - /** - * Add custom file (the filepath will not be adjusted) - */ - function add_custom_file($src, $filename) - { - if (!file_exists($src)) - { - return false; - } - - $this->data($filename, file_get_contents($src), stat($src), false); - return true; - } - - /** - * Add file data - */ - function add_data($src, $name) - { - $stat = array(); - $stat[2] = 436; //384 - $stat[4] = $stat[5] = 0; - $stat[7] = strlen($src); - $stat[9] = time(); - $this->data($name, $src, $stat, false); - return true; - } - - /** - * Checks if a file by that name as already been added and, if it has, - * returns a new, unique name. - * - * @param string $name The filename - * @return string A unique filename - */ - protected function unique_filename($name) - { - if (isset($this->filelist[$name])) - { - $start = $name; - $ext = ''; - $this->filelist[$name]++; - - // Separate the extension off the end of the filename to preserve it - $pos = strrpos($name, '.'); - if ($pos !== false) - { - $start = substr($name, 0, $pos); - $ext = substr($name, $pos); - } - - return $start . '_' . $this->filelist[$name] . $ext; - } - - $this->filelist[$name] = 0; - return $name; - } - - /** - * Return available methods - * - * @return array Array of strings of available compression methods (.tar, .tar.gz, .zip, etc.) - */ - static public function methods() - { - $methods = array('.tar'); - $available_methods = array('.tar.gz' => 'zlib', '.tar.bz2' => 'bz2', '.zip' => 'zlib'); - - foreach ($available_methods as $type => $module) - { - if (!@extension_loaded($module)) - { - continue; - } - $methods[] = $type; - } - - return $methods; - } -} - -/** -* Zip creation class from phpMyAdmin 2.3.0 (c) Tobias Ratschiller, Olivier Müller, Loïc Chapeaux, -* Marc Delisle, http://www.phpmyadmin.net/ -* -* Zip extraction function by Alexandre Tedeschi, alexandrebr at gmail dot com -* -* Modified extensively by psoTFX and DavidMJ, (c) phpBB Limited, 2003 -* -* Based on work by Eric Mueller and Denis125 -* Official ZIP file format: http://www.pkware.com/appnote.txt -*/ -class compress_zip extends compress -{ - var $datasec = array(); - var $ctrl_dir = array(); - var $eof_cdh = "\x50\x4b\x05\x06\x00\x00\x00\x00"; - - var $old_offset = 0; - var $datasec_len = 0; - - /** - * @var \phpbb\filesystem\filesystem_interface - */ - protected $filesystem; - - /** - * Constructor - */ - function __construct($mode, $file) - { - global $phpbb_filesystem; - - $this->fp = @fopen($file, $mode . 'b'); - $this->filesystem = ($phpbb_filesystem instanceof \phpbb\filesystem\filesystem_interface) ? $phpbb_filesystem : new \phpbb\filesystem\filesystem(); - - if (!$this->fp) - { - trigger_error('Unable to open file ' . $file . ' [' . $mode . 'b]'); - } - } - - /** - * Convert unix to dos time - */ - function unix_to_dos_time($time) - { - $timearray = (!$time) ? getdate() : getdate($time); - - if ($timearray['year'] < 1980) - { - $timearray['year'] = 1980; - $timearray['mon'] = $timearray['mday'] = 1; - $timearray['hours'] = $timearray['minutes'] = $timearray['seconds'] = 0; - } - - return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) | ($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1); - } - - /** - * Extract archive - */ - function extract($dst) - { - // Loop the file, looking for files and folders - $dd_try = false; - rewind($this->fp); - - while (!feof($this->fp)) - { - // Check if the signature is valid... - $signature = fread($this->fp, 4); - - switch ($signature) - { - // 'Local File Header' - case "\x50\x4b\x03\x04": - // Lets get everything we need. - // We don't store the version needed to extract, the general purpose bit flag or the date and time fields - $data = unpack("@4/vc_method/@10/Vcrc/Vc_size/Vuc_size/vname_len/vextra_field", fread($this->fp, 26)); - $file_name = fread($this->fp, $data['name_len']); // filename - - if ($data['extra_field']) - { - fread($this->fp, $data['extra_field']); // extra field - } - - $target_filename = "$dst$file_name"; - - if (!$data['uc_size'] && !$data['crc'] && substr($file_name, -1, 1) == '/') - { - if (!is_dir($target_filename)) - { - $str = ''; - $folders = explode('/', $target_filename); - - // Create and folders and subfolders if they do not exist - foreach ($folders as $folder) - { - $folder = trim($folder); - if (!$folder) - { - continue; - } - - $str = (!empty($str)) ? $str . '/' . $folder : $folder; - if (!is_dir($str)) - { - if (!@mkdir($str, 0777)) - { - trigger_error("Could not create directory $folder"); - } - - try - { - $this->filesystem->phpbb_chmod($str, CHMOD_READ | CHMOD_WRITE); - } - catch (\phpbb\filesystem\exception\filesystem_exception $e) - { - // Do nothing - } - } - } - } - // This is a directory, we are not writting files - continue; - } - else - { - // Some archivers are punks, they don't include folders in their archives! - $str = ''; - $folders = explode('/', pathinfo($target_filename, PATHINFO_DIRNAME)); - - // Create and folders and subfolders if they do not exist - foreach ($folders as $folder) - { - $folder = trim($folder); - if (!$folder) - { - continue; - } - - $str = (!empty($str)) ? $str . '/' . $folder : $folder; - if (!is_dir($str)) - { - if (!@mkdir($str, 0777)) - { - trigger_error("Could not create directory $folder"); - } - - try - { - $this->filesystem->phpbb_chmod($str, CHMOD_READ | CHMOD_WRITE); - } - catch (\phpbb\filesystem\exception\filesystem_exception $e) - { - // Do nothing - } - } - } - } - - if (!$data['uc_size']) - { - $content = ''; - } - else - { - $content = fread($this->fp, $data['c_size']); - } - - $fp = fopen($target_filename, "w"); - - switch ($data['c_method']) - { - case 0: - // Not compressed - fwrite($fp, $content); - break; - - case 8: - // Deflate - fwrite($fp, gzinflate($content, $data['uc_size'])); - break; - - case 12: - // Bzip2 - fwrite($fp, bzdecompress($content)); - break; - } - - fclose($fp); - break; - - // We hit the 'Central Directory Header', we can stop because nothing else in here requires our attention - // or we hit the end of the central directory record, we can safely end the loop as we are totally finished with looking for files and folders - case "\x50\x4b\x01\x02": - // This case should simply never happen.. but it does exist.. - case "\x50\x4b\x05\x06": - break 2; - - // 'Packed to Removable Disk', ignore it and look for the next signature... - case 'PK00': - continue 2; - - // We have encountered a header that is weird. Lets look for better data... - default: - if (!$dd_try) - { - // Unexpected header. Trying to detect wrong placed 'Data Descriptor'; - $dd_try = true; - fseek($this->fp, 8, SEEK_CUR); // Jump over 'crc-32'(4) 'compressed-size'(4), 'uncompressed-size'(4) - continue 2; - } - trigger_error("Unexpected header, ending loop"); - break 2; - } - - $dd_try = false; - } - } - - /** - * Close archive - */ - function close() - { - // Write out central file directory and footer ... if it exists - if (count($this->ctrl_dir)) - { - fwrite($this->fp, $this->file()); - } - fclose($this->fp); - } - - /** - * Create the structures ... note we assume version made by is MSDOS - */ - function data($name, $data, $stat, $is_dir = false) - { - $name = str_replace('\\', '/', $name); - $name = $this->unique_filename($name); - - $hexdtime = pack('V', $this->unix_to_dos_time($stat[9])); - - if ($is_dir) - { - $unc_len = $c_len = $crc = 0; - $zdata = ''; - $var_ext = 10; - } - else - { - $unc_len = strlen($data); - $crc = crc32($data); - $zdata = gzdeflate($data); - $c_len = strlen($zdata); - $var_ext = 20; - - // Did we compress? No, then use data as is - if ($c_len >= $unc_len) - { - $zdata = $data; - $c_len = $unc_len; - $var_ext = 10; - } - } - unset($data); - - // If we didn't compress set method to store, else deflate - $c_method = ($c_len == $unc_len) ? "\x00\x00" : "\x08\x00"; - - // Are we a file or a directory? Set archive for file - $attrib = ($is_dir) ? 16 : 32; - - // File Record Header - $fr = "\x50\x4b\x03\x04"; // Local file header 4bytes - $fr .= pack('v', $var_ext); // ver needed to extract 2bytes - $fr .= "\x00\x00"; // gen purpose bit flag 2bytes - $fr .= $c_method; // compression method 2bytes - $fr .= $hexdtime; // last mod time and date 2+2bytes - $fr .= pack('V', $crc); // crc32 4bytes - $fr .= pack('V', $c_len); // compressed filesize 4bytes - $fr .= pack('V', $unc_len); // uncompressed filesize 4bytes - $fr .= pack('v', strlen($name));// length of filename 2bytes - - $fr .= pack('v', 0); // extra field length 2bytes - $fr .= $name; - $fr .= $zdata; - unset($zdata); - - $this->datasec_len += strlen($fr); - - // Add data to file ... by writing data out incrementally we save some memory - fwrite($this->fp, $fr); - unset($fr); - - // Central Directory Header - $cdrec = "\x50\x4b\x01\x02"; // header 4bytes - $cdrec .= "\x00\x00"; // version made by - $cdrec .= pack('v', $var_ext); // version needed to extract - $cdrec .= "\x00\x00"; // gen purpose bit flag - $cdrec .= $c_method; // compression method - $cdrec .= $hexdtime; // last mod time & date - $cdrec .= pack('V', $crc); // crc32 - $cdrec .= pack('V', $c_len); // compressed filesize - $cdrec .= pack('V', $unc_len); // uncompressed filesize - $cdrec .= pack('v', strlen($name)); // length of filename - $cdrec .= pack('v', 0); // extra field length - $cdrec .= pack('v', 0); // file comment length - $cdrec .= pack('v', 0); // disk number start - $cdrec .= pack('v', 0); // internal file attributes - $cdrec .= pack('V', $attrib); // external file attributes - $cdrec .= pack('V', $this->old_offset); // relative offset of local header - $cdrec .= $name; - - // Save to central directory - $this->ctrl_dir[] = $cdrec; - - $this->old_offset = $this->datasec_len; - } - - /** - * file - */ - function file() - { - $ctrldir = implode('', $this->ctrl_dir); - - return $ctrldir . $this->eof_cdh . - pack('v', count($this->ctrl_dir)) . // total # of entries "on this disk" - pack('v', count($this->ctrl_dir)) . // total # of entries overall - pack('V', strlen($ctrldir)) . // size of central dir - pack('V', $this->datasec_len) . // offset to start of central dir - "\x00\x00"; // .zip file comment length - } - - /** - * Download archive - */ - function download($filename, $download_name = false) - { - global $phpbb_root_path; - - if ($download_name === false) - { - $download_name = $filename; - } - - $mimetype = 'application/zip'; - - header('Cache-Control: private, no-cache'); - header("Content-Type: $mimetype; name=\"$download_name.zip\""); - header("Content-disposition: attachment; filename=$download_name.zip"); - - $fp = @fopen("{$phpbb_root_path}store/$filename.zip", 'rb'); - if ($fp) - { - while ($buffer = fread($fp, 1024)) - { - echo $buffer; - } - fclose($fp); - } - } -} - -/** -* Tar/tar.gz compression routine -* Header/checksum creation derived from tarfile.pl, (c) Tom Horsley, 1994 -*/ -class compress_tar extends compress -{ - var $isgz = false; - var $isbz = false; - var $filename = ''; - var $mode = ''; - var $type = ''; - var $wrote = false; - - /** - * @var \phpbb\filesystem\filesystem_interface - */ - protected $filesystem; - - /** - * Constructor - */ - function __construct($mode, $file, $type = '') - { - global $phpbb_filesystem; - - $type = (!$type) ? $file : $type; - $this->isgz = preg_match('#(\.tar\.gz|\.tgz)$#', $type); - $this->isbz = preg_match('#\.tar\.bz2$#', $type); - - $this->mode = &$mode; - $this->file = &$file; - $this->type = &$type; - $this->open(); - - $this->filesystem = ($phpbb_filesystem instanceof \phpbb\filesystem\filesystem_interface) ? $phpbb_filesystem : new \phpbb\filesystem\filesystem(); - } - - /** - * Extract archive - */ - function extract($dst) - { - $fzread = ($this->isbz && function_exists('bzread')) ? 'bzread' : (($this->isgz && @extension_loaded('zlib')) ? 'gzread' : 'fread'); - - // Run through the file and grab directory entries - while ($buffer = $fzread($this->fp, 512)) - { - $tmp = unpack('A6magic', substr($buffer, 257, 6)); - - if (trim($tmp['magic']) == 'ustar') - { - $tmp = unpack('A100name', $buffer); - $filename = trim($tmp['name']); - - $tmp = unpack('Atype', substr($buffer, 156, 1)); - $filetype = (int) trim($tmp['type']); - - $tmp = unpack('A12size', substr($buffer, 124, 12)); - $filesize = octdec((int) trim($tmp['size'])); - - $target_filename = "$dst$filename"; - - if ($filetype == 5) - { - if (!is_dir($target_filename)) - { - $str = ''; - $folders = explode('/', $target_filename); - - // Create and folders and subfolders if they do not exist - foreach ($folders as $folder) - { - $folder = trim($folder); - if (!$folder) - { - continue; - } - - $str = (!empty($str)) ? $str . '/' . $folder : $folder; - if (!is_dir($str)) - { - if (!@mkdir($str, 0777)) - { - trigger_error("Could not create directory $folder"); - } - - try - { - $this->filesystem->phpbb_chmod($str, CHMOD_READ | CHMOD_WRITE); - } - catch (\phpbb\filesystem\exception\filesystem_exception $e) - { - // Do nothing - } - } - } - } - } - else if ($filesize >= 0 && ($filetype == 0 || $filetype == "\0")) - { - // Some archivers are punks, they don't properly order the folders in their archives! - $str = ''; - $folders = explode('/', pathinfo($target_filename, PATHINFO_DIRNAME)); - - // Create and folders and subfolders if they do not exist - foreach ($folders as $folder) - { - $folder = trim($folder); - if (!$folder) - { - continue; - } - - $str = (!empty($str)) ? $str . '/' . $folder : $folder; - if (!is_dir($str)) - { - if (!@mkdir($str, 0777)) - { - trigger_error("Could not create directory $folder"); - } - - try - { - $this->filesystem->phpbb_chmod($str, CHMOD_READ | CHMOD_WRITE); - } - catch (\phpbb\filesystem\exception\filesystem_exception $e) - { - // Do nothing - } - } - } - - // Write out the files - if (!($fp = fopen($target_filename, 'wb'))) - { - trigger_error("Couldn't create file $filename"); - } - - try - { - $this->filesystem->phpbb_chmod($target_filename, CHMOD_READ); - } - catch (\phpbb\filesystem\exception\filesystem_exception $e) - { - // Do nothing - } - - // Grab the file contents - fwrite($fp, ($filesize) ? $fzread($this->fp, ($filesize + 511) &~ 511) : '', $filesize); - fclose($fp); - } - } - } - } - - /** - * Close archive - */ - function close() - { - $fzclose = ($this->isbz && function_exists('bzclose')) ? 'bzclose' : (($this->isgz && @extension_loaded('zlib')) ? 'gzclose' : 'fclose'); - - if ($this->wrote) - { - $fzwrite = ($this->isbz && function_exists('bzwrite')) ? 'bzwrite' : (($this->isgz && @extension_loaded('zlib')) ? 'gzwrite' : 'fwrite'); - - // The end of a tar archive ends in two records of all NULLs (1024 bytes of \0) - $fzwrite($this->fp, str_repeat("\0", 1024)); - } - - $fzclose($this->fp); - } - - /** - * Create the structures - */ - function data($name, $data, $stat, $is_dir = false) - { - $name = $this->unique_filename($name); - $this->wrote = true; - $fzwrite = ($this->isbz && function_exists('bzwrite')) ? 'bzwrite' : (($this->isgz && @extension_loaded('zlib')) ? 'gzwrite' : 'fwrite'); - - $typeflag = ($is_dir) ? '5' : ''; - - // This is the header data, it contains all the info we know about the file or folder that we are about to archive - $header = ''; - $header .= pack('a100', $name); // file name - $header .= pack('a8', sprintf("%07o", $stat[2])); // file mode - $header .= pack('a8', sprintf("%07o", $stat[4])); // owner id - $header .= pack('a8', sprintf("%07o", $stat[5])); // group id - $header .= pack('a12', sprintf("%011o", $stat[7])); // file size - $header .= pack('a12', sprintf("%011o", $stat[9])); // last mod time - - // Checksum - $checksum = 0; - for ($i = 0; $i < 148; $i++) - { - $checksum += ord($header[$i]); - } - - // We precompute the rest of the hash, this saves us time in the loop and allows us to insert our hash without resorting to string functions - $checksum += 2415 + (($is_dir) ? 53 : 0); - - $header .= pack('a8', sprintf("%07o", $checksum)); // checksum - $header .= pack('a1', $typeflag); // link indicator - $header .= pack('a100', ''); // name of linked file - $header .= pack('a6', 'ustar'); // ustar indicator - $header .= pack('a2', '00'); // ustar version - $header .= pack('a32', 'Unknown'); // owner name - $header .= pack('a32', 'Unknown'); // group name - $header .= pack('a8', ''); // device major number - $header .= pack('a8', ''); // device minor number - $header .= pack('a155', ''); // filename prefix - $header .= pack('a12', ''); // end - - // This writes the entire file in one shot. Header, followed by data and then null padded to a multiple of 512 - $fzwrite($this->fp, $header . (($stat[7] !== 0 && !$is_dir) ? $data . str_repeat("\0", (($stat[7] + 511) &~ 511) - $stat[7]) : '')); - unset($data); - } - - /** - * Open archive - */ - function open() - { - $fzopen = ($this->isbz && function_exists('bzopen')) ? 'bzopen' : (($this->isgz && @extension_loaded('zlib')) ? 'gzopen' : 'fopen'); - $this->fp = @$fzopen($this->file, $this->mode . (($fzopen == 'bzopen') ? '' : 'b') . (($fzopen == 'gzopen') ? '9' : '')); - - if (!$this->fp) - { - trigger_error('Unable to open file ' . $this->file . ' [' . $fzopen . ' - ' . $this->mode . 'b]'); - } - } - - /** - * Download archive - */ - function download($filename, $download_name = false) - { - global $phpbb_root_path; - - if ($download_name === false) - { - $download_name = $filename; - } - - switch ($this->type) - { - case '.tar': - $mimetype = 'application/x-tar'; - break; - - case '.tar.gz': - $mimetype = 'application/x-gzip'; - break; - - case '.tar.bz2': - $mimetype = 'application/x-bzip2'; - break; - - default: - $mimetype = 'application/octet-stream'; - break; - } - - header('Cache-Control: private, no-cache'); - header("Content-Type: $mimetype; name=\"$download_name$this->type\""); - header("Content-disposition: attachment; filename=$download_name$this->type"); - - $fp = @fopen("{$phpbb_root_path}store/$filename$this->type", 'rb'); - if ($fp) - { - while ($buffer = fread($fp, 1024)) - { - echo $buffer; - } - fclose($fp); - } - } -} diff --git a/install/update/old/includes/functions_content.php b/install/update/old/includes/functions_content.php deleted file mode 100644 index a15a03f..0000000 --- a/install/update/old/includes/functions_content.php +++ /dev/null @@ -1,1805 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* gen_sort_selects() -* make_jumpbox() -* bump_topic_allowed() -* get_context() -* phpbb_clean_search_string() -* decode_message() -* strip_bbcode() -* generate_text_for_display() -* generate_text_for_storage() -* generate_text_for_edit() -* make_clickable_callback() -* make_clickable() -* censor_text() -* bbcode_nl2br() -* smiley_text() -* parse_attachments() -* extension_allowed() -* truncate_string() -* get_username_string() -* class bitfield -*/ - -/** -* Generate sort selection fields -*/ -function gen_sort_selects(&$limit_days, &$sort_by_text, &$sort_days, &$sort_key, &$sort_dir, &$s_limit_days, &$s_sort_key, &$s_sort_dir, &$u_sort_param, $def_st = false, $def_sk = false, $def_sd = false) -{ - global $user, $phpbb_dispatcher; - - $sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']); - - $sorts = array( - 'st' => array( - 'key' => 'sort_days', - 'default' => $def_st, - 'options' => $limit_days, - 'output' => &$s_limit_days, - ), - - 'sk' => array( - 'key' => 'sort_key', - 'default' => $def_sk, - 'options' => $sort_by_text, - 'output' => &$s_sort_key, - ), - - 'sd' => array( - 'key' => 'sort_dir', - 'default' => $def_sd, - 'options' => $sort_dir_text, - 'output' => &$s_sort_dir, - ), - ); - $u_sort_param = ''; - - foreach ($sorts as $name => $sort_ary) - { - $key = $sort_ary['key']; - $selected = ${$sort_ary['key']}; - - // Check if the key is selectable. If not, we reset to the default or first key found. - // This ensures the values are always valid. We also set $sort_dir/sort_key/etc. to the - // correct value, else the protection is void. ;) - if (!isset($sort_ary['options'][$selected])) - { - if ($sort_ary['default'] !== false) - { - $selected = ${$key} = $sort_ary['default']; - } - else - { - @reset($sort_ary['options']); - $selected = ${$key} = key($sort_ary['options']); - } - } - - $sort_ary['output'] = ''; - - $u_sort_param .= ($selected !== $sort_ary['default']) ? ((strlen($u_sort_param)) ? '&' : '') . "{$name}={$selected}" : ''; - } - - /** - * Run code before generated sort selects are returned - * - * @event core.gen_sort_selects_after - * @var int limit_days Days limit - * @var array sort_by_text Sort by text options - * @var int sort_days Sort by days flag - * @var string sort_key Sort key - * @var string sort_dir Sort dir - * @var string s_limit_days String of days limit - * @var string s_sort_key String of sort key - * @var string s_sort_dir String of sort dir - * @var string u_sort_param Sort URL params - * @var bool def_st Default sort days - * @var bool def_sk Default sort key - * @var bool def_sd Default sort dir - * @var array sorts Sorts - * @since 3.1.9-RC1 - */ - $vars = array( - 'limit_days', - 'sort_by_text', - 'sort_days', - 'sort_key', - 'sort_dir', - 's_limit_days', - 's_sort_key', - 's_sort_dir', - 'u_sort_param', - 'def_st', - 'def_sk', - 'def_sd', - 'sorts', - ); - extract($phpbb_dispatcher->trigger_event('core.gen_sort_selects_after', compact($vars))); - - return; -} - -/** -* Generate Jumpbox -*/ -function make_jumpbox($action, $forum_id = false, $select_all = false, $acl_list = false, $force_display = false) -{ - global $config, $auth, $template, $user, $db, $phpbb_path_helper, $phpbb_dispatcher; - - // We only return if the jumpbox is not forced to be displayed (in case it is needed for functionality) - if (!$config['load_jumpbox'] && $force_display === false) - { - return; - } - - $sql = 'SELECT forum_id, forum_name, parent_id, forum_type, left_id, right_id - FROM ' . FORUMS_TABLE . ' - ORDER BY left_id ASC'; - $result = $db->sql_query($sql, 600); - - $rowset = array(); - while ($row = $db->sql_fetchrow($result)) - { - $rowset[(int) $row['forum_id']] = $row; - } - $db->sql_freeresult($result); - - $right = $padding = 0; - $padding_store = array('0' => 0); - $display_jumpbox = false; - $iteration = 0; - - /** - * Modify the jumpbox forum list data - * - * @event core.make_jumpbox_modify_forum_list - * @var array rowset Array with the forums list data - * @since 3.1.10-RC1 - */ - $vars = array('rowset'); - extract($phpbb_dispatcher->trigger_event('core.make_jumpbox_modify_forum_list', compact($vars))); - - // Sometimes it could happen that forums will be displayed here not be displayed within the index page - // This is the result of forums not displayed at index, having list permissions and a parent of a forum with no permissions. - // If this happens, the padding could be "broken" - - foreach ($rowset as $row) - { - if ($row['left_id'] < $right) - { - $padding++; - $padding_store[$row['parent_id']] = $padding; - } - else if ($row['left_id'] > $right + 1) - { - // Ok, if the $padding_store for this parent is empty there is something wrong. For now we will skip over it. - // @todo digging deep to find out "how" this can happen. - $padding = (isset($padding_store[$row['parent_id']])) ? $padding_store[$row['parent_id']] : $padding; - } - - $right = $row['right_id']; - - if ($row['forum_type'] == FORUM_CAT && ($row['left_id'] + 1 == $row['right_id'])) - { - // Non-postable forum with no subforums, don't display - continue; - } - - if (!$auth->acl_get('f_list', $row['forum_id'])) - { - // if the user does not have permissions to list this forum skip - continue; - } - - if ($acl_list && !$auth->acl_gets($acl_list, $row['forum_id'])) - { - continue; - } - - $tpl_ary = array(); - if (!$display_jumpbox) - { - $tpl_ary[] = array( - 'FORUM_ID' => ($select_all) ? 0 : -1, - 'FORUM_NAME' => ($select_all) ? $user->lang['ALL_FORUMS'] : $user->lang['SELECT_FORUM'], - 'S_FORUM_COUNT' => $iteration, - 'LINK' => $phpbb_path_helper->append_url_params($action, array('f' => $forum_id)), - ); - - $iteration++; - $display_jumpbox = true; - } - - $tpl_ary[] = array( - 'FORUM_ID' => $row['forum_id'], - 'FORUM_NAME' => $row['forum_name'], - 'SELECTED' => ($row['forum_id'] == $forum_id) ? ' selected="selected"' : '', - 'S_FORUM_COUNT' => $iteration, - 'S_IS_CAT' => ($row['forum_type'] == FORUM_CAT) ? true : false, - 'S_IS_LINK' => ($row['forum_type'] == FORUM_LINK) ? true : false, - 'S_IS_POST' => ($row['forum_type'] == FORUM_POST) ? true : false, - 'LINK' => $phpbb_path_helper->append_url_params($action, array('f' => $row['forum_id'])), - ); - - /** - * Modify the jumpbox before it is assigned to the template - * - * @event core.make_jumpbox_modify_tpl_ary - * @var array row The data of the forum - * @var array tpl_ary Template data of the forum - * @since 3.1.10-RC1 - */ - $vars = array( - 'row', - 'tpl_ary', - ); - extract($phpbb_dispatcher->trigger_event('core.make_jumpbox_modify_tpl_ary', compact($vars))); - - $template->assign_block_vars_array('jumpbox_forums', $tpl_ary); - - unset($tpl_ary); - - for ($i = 0; $i < $padding; $i++) - { - $template->assign_block_vars('jumpbox_forums.level', array()); - } - $iteration++; - } - unset($padding_store, $rowset); - - $url_parts = $phpbb_path_helper->get_url_parts($action); - - $template->assign_vars(array( - 'S_DISPLAY_JUMPBOX' => $display_jumpbox, - 'S_JUMPBOX_ACTION' => $action, - 'HIDDEN_FIELDS_FOR_JUMPBOX' => build_hidden_fields($url_parts['params']), - )); - - return; -} - -/** -* Bump Topic Check - used by posting and viewtopic -*/ -function bump_topic_allowed($forum_id, $topic_bumped, $last_post_time, $topic_poster, $last_topic_poster) -{ - global $config, $auth, $user; - - // Check permission and make sure the last post was not already bumped - if (!$auth->acl_get('f_bump', $forum_id) || $topic_bumped) - { - return false; - } - - // Check bump time range, is the user really allowed to bump the topic at this time? - $bump_time = ($config['bump_type'] == 'm') ? $config['bump_interval'] * 60 : (($config['bump_type'] == 'h') ? $config['bump_interval'] * 3600 : $config['bump_interval'] * 86400); - - // Check bump time - if ($last_post_time + $bump_time > time()) - { - return false; - } - - // Check bumper, only topic poster and last poster are allowed to bump - if ($topic_poster != $user->data['user_id'] && $last_topic_poster != $user->data['user_id']) - { - return false; - } - - // A bump time of 0 will completely disable the bump feature... not intended but might be useful. - return $bump_time; -} - -/** -* Generates a text with approx. the specified length which contains the specified words and their context -* -* @param string $text The full text from which context shall be extracted -* @param string $words An array of words which should be contained in the result, has to be a valid part of a PCRE pattern (escape with preg_quote!) -* @param int $length The desired length of the resulting text, however the result might be shorter or longer than this value -* -* @return string Context of the specified words separated by "..." -*/ -function get_context($text, $words, $length = 400) -{ - // first replace all whitespaces with single spaces - $text = preg_replace('/ +/', ' ', strtr($text, "\t\n\r\x0C ", ' ')); - - // we need to turn the entities back into their original form, to not cut the message in between them - $entities = array('<', '>', '[', ']', '.', ':', ':'); - $characters = array('<', '>', '[', ']', '.', ':', ':'); - $text = str_replace($entities, $characters, $text); - - $word_indizes = array(); - if (count($words)) - { - $match = ''; - // find the starting indizes of all words - foreach ($words as $word) - { - if ($word) - { - if (preg_match('#(?:[^\w]|^)(' . $word . ')(?:[^\w]|$)#i', $text, $match)) - { - if (empty($match[1])) - { - continue; - } - - $pos = utf8_strpos($text, $match[1]); - if ($pos !== false) - { - $word_indizes[] = $pos; - } - } - } - } - unset($match); - - if (count($word_indizes)) - { - $word_indizes = array_unique($word_indizes); - sort($word_indizes); - - $wordnum = count($word_indizes); - // number of characters on the right and left side of each word - $sequence_length = (int) ($length / (2 * $wordnum)) - 2; - $final_text = ''; - $word = $j = 0; - $final_text_index = -1; - - // cycle through every character in the original text - for ($i = $word_indizes[$word], $n = utf8_strlen($text); $i < $n; $i++) - { - // if the current position is the start of one of the words then append $sequence_length characters to the final text - if (isset($word_indizes[$word]) && ($i == $word_indizes[$word])) - { - if ($final_text_index < $i - $sequence_length - 1) - { - $final_text .= '... ' . preg_replace('#^([^ ]*)#', '', utf8_substr($text, $i - $sequence_length, $sequence_length)); - } - else - { - // if the final text is already nearer to the current word than $sequence_length we only append the text - // from its current index on and distribute the unused length to all other sequenes - $sequence_length += (int) (($final_text_index - $i + $sequence_length + 1) / (2 * $wordnum)); - $final_text .= utf8_substr($text, $final_text_index + 1, $i - $final_text_index - 1); - } - $final_text_index = $i - 1; - - // add the following characters to the final text (see below) - $word++; - $j = 1; - } - - if ($j > 0) - { - // add the character to the final text and increment the sequence counter - $final_text .= utf8_substr($text, $i, 1); - $final_text_index++; - $j++; - - // if this is a whitespace then check whether we are done with this sequence - if (utf8_substr($text, $i, 1) == ' ') - { - // only check whether we have to exit the context generation completely if we haven't already reached the end anyway - if ($i + 4 < $n) - { - if (($j > $sequence_length && $word >= $wordnum) || utf8_strlen($final_text) > $length) - { - $final_text .= ' ...'; - break; - } - } - else - { - // make sure the text really reaches the end - $j -= 4; - } - - // stop context generation and wait for the next word - if ($j > $sequence_length) - { - $j = 0; - } - } - } - } - return str_replace($characters, $entities, $final_text); - } - } - - if (!count($words) || !count($word_indizes)) - { - return str_replace($characters, $entities, ((utf8_strlen($text) >= $length + 3) ? utf8_substr($text, 0, $length) . '...' : $text)); - } -} - -/** -* Cleans a search string by removing single wildcards from it and replacing multiple spaces with a single one. -* -* @param string $search_string The full search string which should be cleaned. -* -* @return string The cleaned search string without any wildcards and multiple spaces. -*/ -function phpbb_clean_search_string($search_string) -{ - // This regular expressions matches every single wildcard. - // That means one after a whitespace or the beginning of the string or one before a whitespace or the end of the string. - $search_string = preg_replace('#(?<=^|\s)\*+(?=\s|$)#', '', $search_string); - $search_string = trim($search_string); - $search_string = preg_replace(array('#\s+#u', '#\*+#u'), array(' ', '*'), $search_string); - return $search_string; -} - -/** -* Decode text whereby text is coming from the db and expected to be pre-parsed content -* We are placing this outside of the message parser because we are often in need of it... -* -* NOTE: special chars are kept encoded -* -* @param string &$message Original message, passed by reference -* @param string $bbcode_uid BBCode UID -* @return null -*/ -function decode_message(&$message, $bbcode_uid = '') -{ - global $phpbb_container, $phpbb_dispatcher; - - /** - * Use this event to modify the message before it is decoded - * - * @event core.decode_message_before - * @var string message_text The message content - * @var string bbcode_uid The message BBCode UID - * @since 3.1.9-RC1 - */ - $message_text = $message; - $vars = array('message_text', 'bbcode_uid'); - extract($phpbb_dispatcher->trigger_event('core.decode_message_before', compact($vars))); - $message = $message_text; - - if (preg_match('#^<[rt][ >]#', $message)) - { - $message = htmlspecialchars($phpbb_container->get('text_formatter.utils')->unparse($message), ENT_COMPAT); - } - else - { - if ($bbcode_uid) - { - $match = array('
', "[/*:m:$bbcode_uid]", ":u:$bbcode_uid", ":o:$bbcode_uid", ":$bbcode_uid"); - $replace = array("\n", '', '', '', ''); - } - else - { - $match = array('
'); - $replace = array("\n"); - } - - $message = str_replace($match, $replace, $message); - - $match = get_preg_expression('bbcode_htm'); - $replace = array('\1', '\1', '\2', '\2', '\1', '', ''); - - $message = preg_replace($match, $replace, $message); - } - - /** - * Use this event to modify the message after it is decoded - * - * @event core.decode_message_after - * @var string message_text The message content - * @var string bbcode_uid The message BBCode UID - * @since 3.1.9-RC1 - */ - $message_text = $message; - $vars = array('message_text', 'bbcode_uid'); - extract($phpbb_dispatcher->trigger_event('core.decode_message_after', compact($vars))); - $message = $message_text; -} - -/** -* Strips all bbcode from a text in place -*/ -function strip_bbcode(&$text, $uid = '') -{ - global $phpbb_container; - - if (preg_match('#^<[rt][ >]#', $text)) - { - $text = $phpbb_container->get('text_formatter.utils')->clean_formatting($text); - } - else - { - if (!$uid) - { - $uid = '[0-9a-z]{5,}'; - } - - $text = preg_replace("#\[\/?[a-z0-9\*\+\-]+(?:=(?:".*"|[^\]]*))?(?::[a-z])?(\:$uid)\]#", ' ', $text); - - $match = get_preg_expression('bbcode_htm'); - $replace = array('\1', '\1', '\2', '\1', '', ''); - - $text = preg_replace($match, $replace, $text); - } -} - -/** -* For display of custom parsed text on user-facing pages -* Expects $text to be the value directly from the database (stored value) -*/ -function generate_text_for_display($text, $uid, $bitfield, $flags, $censor_text = true) -{ - static $bbcode; - global $auth, $config, $user; - global $phpbb_dispatcher, $phpbb_container; - - if ($text === '') - { - return ''; - } - - /** - * Use this event to modify the text before it is parsed - * - * @event core.modify_text_for_display_before - * @var string text The text to parse - * @var string uid The BBCode UID - * @var string bitfield The BBCode Bitfield - * @var int flags The BBCode Flags - * @var bool censor_text Whether or not to apply word censors - * @since 3.1.0-a1 - */ - $vars = array('text', 'uid', 'bitfield', 'flags', 'censor_text'); - extract($phpbb_dispatcher->trigger_event('core.modify_text_for_display_before', compact($vars))); - - if (preg_match('#^<[rt][ >]#', $text)) - { - $renderer = $phpbb_container->get('text_formatter.renderer'); - - // Temporarily switch off viewcensors if applicable - $old_censor = $renderer->get_viewcensors(); - - // Check here if the user is having viewing censors disabled (and also allowed to do so). - if (!$user->optionget('viewcensors') && $config['allow_nocensors'] && $auth->acl_get('u_chgcensors')) - { - $censor_text = false; - } - - if ($old_censor !== $censor_text) - { - $renderer->set_viewcensors($censor_text); - } - - $text = $renderer->render($text); - - // Restore the previous value - if ($old_censor !== $censor_text) - { - $renderer->set_viewcensors($old_censor); - } - } - else - { - if ($censor_text) - { - $text = censor_text($text); - } - - // Parse bbcode if bbcode uid stored and bbcode enabled - if ($uid && ($flags & OPTION_FLAG_BBCODE)) - { - if (!class_exists('bbcode')) - { - global $phpbb_root_path, $phpEx; - include($phpbb_root_path . 'includes/bbcode.' . $phpEx); - } - - if (empty($bbcode)) - { - $bbcode = new bbcode($bitfield); - } - else - { - $bbcode->bbcode_set_bitfield($bitfield); - } - - $bbcode->bbcode_second_pass($text, $uid); - } - - $text = bbcode_nl2br($text); - $text = smiley_text($text, !($flags & OPTION_FLAG_SMILIES)); - } - - /** - * Use this event to modify the text after it is parsed - * - * @event core.modify_text_for_display_after - * @var string text The text to parse - * @var string uid The BBCode UID - * @var string bitfield The BBCode Bitfield - * @var int flags The BBCode Flags - * @since 3.1.0-a1 - */ - $vars = array('text', 'uid', 'bitfield', 'flags'); - extract($phpbb_dispatcher->trigger_event('core.modify_text_for_display_after', compact($vars))); - - return $text; -} - -/** -* For parsing custom parsed text to be stored within the database. -* This function additionally returns the uid and bitfield that needs to be stored. -* Expects $text to be the value directly from $request->variable() and in it's non-parsed form -* -* @param string $text The text to be replaced with the parsed one -* @param string $uid The BBCode uid for this parse -* @param string $bitfield The BBCode bitfield for this parse -* @param int $flags The allow_bbcode, allow_urls and allow_smilies compiled into a single integer. -* @param bool $allow_bbcode If BBCode is allowed (i.e. if BBCode is parsed) -* @param bool $allow_urls If urls is allowed -* @param bool $allow_smilies If smilies are allowed -* @param bool $allow_img_bbcode -* @param bool $allow_flash_bbcode -* @param bool $allow_quote_bbcode -* @param bool $allow_url_bbcode -* @param string $mode Mode to parse text as, e.g. post or sig -* -* @return array An array of string with the errors that occurred while parsing -*/ -function generate_text_for_storage(&$text, &$uid, &$bitfield, &$flags, $allow_bbcode = false, $allow_urls = false, $allow_smilies = false, $allow_img_bbcode = true, $allow_flash_bbcode = true, $allow_quote_bbcode = true, $allow_url_bbcode = true, $mode = 'post') -{ - global $phpbb_root_path, $phpEx, $phpbb_dispatcher; - - /** - * Use this event to modify the text before it is prepared for storage - * - * @event core.modify_text_for_storage_before - * @var string text The text to parse - * @var string uid The BBCode UID - * @var string bitfield The BBCode Bitfield - * @var int flags The BBCode Flags - * @var bool allow_bbcode Whether or not to parse BBCode - * @var bool allow_urls Whether or not to parse URLs - * @var bool allow_smilies Whether or not to parse Smilies - * @var bool allow_img_bbcode Whether or not to parse the [img] BBCode - * @var bool allow_flash_bbcode Whether or not to parse the [flash] BBCode - * @var bool allow_quote_bbcode Whether or not to parse the [quote] BBCode - * @var bool allow_url_bbcode Whether or not to parse the [url] BBCode - * @var string mode Mode to parse text as, e.g. post or sig - * @since 3.1.0-a1 - * @changed 3.2.0-a1 Added mode - */ - $vars = array( - 'text', - 'uid', - 'bitfield', - 'flags', - 'allow_bbcode', - 'allow_urls', - 'allow_smilies', - 'allow_img_bbcode', - 'allow_flash_bbcode', - 'allow_quote_bbcode', - 'allow_url_bbcode', - 'mode', - ); - extract($phpbb_dispatcher->trigger_event('core.modify_text_for_storage_before', compact($vars))); - - $uid = $bitfield = ''; - $flags = (($allow_bbcode) ? OPTION_FLAG_BBCODE : 0) + (($allow_smilies) ? OPTION_FLAG_SMILIES : 0) + (($allow_urls) ? OPTION_FLAG_LINKS : 0); - - if (!class_exists('parse_message')) - { - include($phpbb_root_path . 'includes/message_parser.' . $phpEx); - } - - $message_parser = new parse_message($text); - $message_parser->parse($allow_bbcode, $allow_urls, $allow_smilies, $allow_img_bbcode, $allow_flash_bbcode, $allow_quote_bbcode, $allow_url_bbcode, true, $mode); - - $text = $message_parser->message; - $uid = $message_parser->bbcode_uid; - - // If the bbcode_bitfield is empty, there is no need for the uid to be stored. - if (!$message_parser->bbcode_bitfield) - { - $uid = ''; - } - - $bitfield = $message_parser->bbcode_bitfield; - - /** - * Use this event to modify the text after it is prepared for storage - * - * @event core.modify_text_for_storage_after - * @var string text The text to parse - * @var string uid The BBCode UID - * @var string bitfield The BBCode Bitfield - * @var int flags The BBCode Flags - * @var string message_parser The message_parser object - * @since 3.1.0-a1 - * @changed 3.1.11-RC1 Added message_parser to vars - */ - $vars = array('text', 'uid', 'bitfield', 'flags', 'message_parser'); - extract($phpbb_dispatcher->trigger_event('core.modify_text_for_storage_after', compact($vars))); - - return $message_parser->warn_msg; -} - -/** -* For decoding custom parsed text for edits as well as extracting the flags -* Expects $text to be the value directly from the database (pre-parsed content) -*/ -function generate_text_for_edit($text, $uid, $flags) -{ - global $phpbb_dispatcher; - - /** - * Use this event to modify the text before it is decoded for editing - * - * @event core.modify_text_for_edit_before - * @var string text The text to parse - * @var string uid The BBCode UID - * @var int flags The BBCode Flags - * @since 3.1.0-a1 - */ - $vars = array('text', 'uid', 'flags'); - extract($phpbb_dispatcher->trigger_event('core.modify_text_for_edit_before', compact($vars))); - - decode_message($text, $uid); - - /** - * Use this event to modify the text after it is decoded for editing - * - * @event core.modify_text_for_edit_after - * @var string text The text to parse - * @var int flags The BBCode Flags - * @since 3.1.0-a1 - */ - $vars = array('text', 'flags'); - extract($phpbb_dispatcher->trigger_event('core.modify_text_for_edit_after', compact($vars))); - - return array( - 'allow_bbcode' => ($flags & OPTION_FLAG_BBCODE) ? 1 : 0, - 'allow_smilies' => ($flags & OPTION_FLAG_SMILIES) ? 1 : 0, - 'allow_urls' => ($flags & OPTION_FLAG_LINKS) ? 1 : 0, - 'text' => $text - ); -} - -/** -* A subroutine of make_clickable used with preg_replace -* It places correct HTML around an url, shortens the displayed text -* and makes sure no entities are inside URLs -*/ -function make_clickable_callback($type, $whitespace, $url, $relative_url, $class) -{ - $orig_url = $url; - $orig_relative = $relative_url; - $append = ''; - $url = htmlspecialchars_decode($url); - $relative_url = htmlspecialchars_decode($relative_url); - - // make sure no HTML entities were matched - $chars = array('<', '>', '"'); - $split = false; - - foreach ($chars as $char) - { - $next_split = strpos($url, $char); - if ($next_split !== false) - { - $split = ($split !== false) ? min($split, $next_split) : $next_split; - } - } - - if ($split !== false) - { - // an HTML entity was found, so the URL has to end before it - $append = substr($url, $split) . $relative_url; - $url = substr($url, 0, $split); - $relative_url = ''; - } - else if ($relative_url) - { - // same for $relative_url - $split = false; - foreach ($chars as $char) - { - $next_split = strpos($relative_url, $char); - if ($next_split !== false) - { - $split = ($split !== false) ? min($split, $next_split) : $next_split; - } - } - - if ($split !== false) - { - $append = substr($relative_url, $split); - $relative_url = substr($relative_url, 0, $split); - } - } - - // if the last character of the url is a punctuation mark, exclude it from the url - $last_char = ($relative_url) ? $relative_url[strlen($relative_url) - 1] : $url[strlen($url) - 1]; - - switch ($last_char) - { - case '.': - case '?': - case '!': - case ':': - case ',': - $append = $last_char; - if ($relative_url) - { - $relative_url = substr($relative_url, 0, -1); - } - else - { - $url = substr($url, 0, -1); - } - break; - - // set last_char to empty here, so the variable can be used later to - // check whether a character was removed - default: - $last_char = ''; - break; - } - - $short_url = (utf8_strlen($url) > 55) ? utf8_substr($url, 0, 39) . ' ... ' . utf8_substr($url, -10) : $url; - - switch ($type) - { - case MAGIC_URL_LOCAL: - $tag = 'l'; - $relative_url = preg_replace('/[&?]sid=[0-9a-f]{32}$/', '', preg_replace('/([&?])sid=[0-9a-f]{32}&/', '$1', $relative_url)); - $url = $url . '/' . $relative_url; - $text = $relative_url; - - // this url goes to http://domain.tld/path/to/board/ which - // would result in an empty link if treated as local so - // don't touch it and let MAGIC_URL_FULL take care of it. - if (!$relative_url) - { - return $whitespace . $orig_url . '/' . $orig_relative; // slash is taken away by relative url pattern - } - break; - - case MAGIC_URL_FULL: - $tag = 'm'; - $text = $short_url; - break; - - case MAGIC_URL_WWW: - $tag = 'w'; - $url = 'http://' . $url; - $text = $short_url; - break; - - case MAGIC_URL_EMAIL: - $tag = 'e'; - $text = $short_url; - $url = 'mailto:' . $url; - break; - } - - $url = htmlspecialchars($url); - $text = htmlspecialchars($text); - $append = htmlspecialchars($append); - - $html = "$whitespace$text$append"; - - return $html; -} - -/** -* make_clickable function -* -* Replace magic urls of form http://xxx.xxx., www.xxx. and xxx@xxx.xxx. -* Cuts down displayed size of link if over 50 chars, turns absolute links -* into relative versions when the server/script path matches the link -*/ -function make_clickable($text, $server_url = false, $class = 'postlink') -{ - if ($server_url === false) - { - $server_url = generate_board_url(); - } - - static $static_class; - static $magic_url_match_args; - - if (!isset($magic_url_match_args[$server_url]) || $static_class != $class) - { - $static_class = $class; - $class = ($static_class) ? ' class="' . $static_class . '"' : ''; - $local_class = ($static_class) ? ' class="' . $static_class . '-local"' : ''; - - if (!is_array($magic_url_match_args)) - { - $magic_url_match_args = array(); - } - - // relative urls for this board - $magic_url_match_args[$server_url][] = array( - '#(^|[\n\t (>.])(' . preg_quote($server_url, '#') . ')/(' . get_preg_expression('relative_url_inline') . ')#iu', - MAGIC_URL_LOCAL, - $local_class, - ); - - // matches a xxxx://aaaaa.bbb.cccc. ... - $magic_url_match_args[$server_url][] = array( - '#(^|[\n\t (>.])(' . get_preg_expression('url_inline') . ')#iu', - MAGIC_URL_FULL, - $class, - ); - - // matches a "www.xxxx.yyyy[/zzzz]" kinda lazy URL thing - $magic_url_match_args[$server_url][] = array( - '#(^|[\n\t (>])(' . get_preg_expression('www_url_inline') . ')#iu', - MAGIC_URL_WWW, - $class, - ); - - // matches an email@domain type address at the start of a line, or after a space or after what might be a BBCode. - $magic_url_match_args[$server_url][] = array( - '/(^|[\n\t (>])(' . get_preg_expression('email') . ')/iu', - MAGIC_URL_EMAIL, - '', - ); - } - - foreach ($magic_url_match_args[$server_url] as $magic_args) - { - if (preg_match($magic_args[0], $text, $matches)) - { - $text = preg_replace_callback($magic_args[0], function($matches) use ($magic_args) - { - $relative_url = isset($matches[3]) ? $matches[3] : ''; - return make_clickable_callback($magic_args[1], $matches[1], $matches[2], $relative_url, $magic_args[2]); - }, $text); - } - } - - return $text; -} - -/** -* Censoring -*/ -function censor_text($text) -{ - static $censors; - - // Nothing to do? - if ($text === '') - { - return ''; - } - - // We moved the word censor checks in here because we call this function quite often - and then only need to do the check once - if (!isset($censors) || !is_array($censors)) - { - global $config, $user, $auth, $cache; - - // We check here if the user is having viewing censors disabled (and also allowed to do so). - if (!$user->optionget('viewcensors') && $config['allow_nocensors'] && $auth->acl_get('u_chgcensors')) - { - $censors = array(); - } - else - { - $censors = $cache->obtain_word_list(); - } - } - - if (count($censors)) - { - return preg_replace($censors['match'], $censors['replace'], $text); - } - - return $text; -} - -/** -* custom version of nl2br which takes custom BBCodes into account -*/ -function bbcode_nl2br($text) -{ - // custom BBCodes might contain carriage returns so they - // are not converted into
so now revert that - $text = str_replace(array("\n", "\r"), array('
', "\n"), $text); - return $text; -} - -/** -* Smiley processing -*/ -function smiley_text($text, $force_option = false) -{ - global $config, $user, $phpbb_path_helper, $phpbb_dispatcher; - - if ($force_option || !$config['allow_smilies'] || !$user->optionget('viewsmilies')) - { - return preg_replace('##', ''; - } - } - - $filesize = get_formatted_filesize($attachment['filesize'], false); - - $comment = bbcode_nl2br(censor_text($attachment['attach_comment'])); - - $block_array += array( - 'UPLOAD_ICON' => $upload_icon, - 'FILESIZE' => $filesize['value'], - 'SIZE_LANG' => $filesize['unit'], - 'DOWNLOAD_NAME' => utf8_basename($attachment['real_filename']), - 'COMMENT' => $comment, - ); - - $denied = false; - - if (!extension_allowed($forum_id, $attachment['extension'], $extensions)) - { - $denied = true; - - $block_array += array( - 'S_DENIED' => true, - 'DENIED_MESSAGE' => sprintf($user->lang['EXTENSION_DISABLED_AFTER_POSTING'], $attachment['extension']) - ); - } - - if (!$denied) - { - $display_cat = $extensions[$attachment['extension']]['display_cat']; - - if ($display_cat == ATTACHMENT_CATEGORY_IMAGE) - { - if ($attachment['thumbnail']) - { - $display_cat = ATTACHMENT_CATEGORY_THUMB; - } - else - { - if ($config['img_display_inlined']) - { - if ($config['img_link_width'] || $config['img_link_height']) - { - $dimension = @getimagesize($filename); - - // If the dimensions could not be determined or the image being 0x0 we display it as a link for safety purposes - if ($dimension === false || empty($dimension[0]) || empty($dimension[1])) - { - $display_cat = ATTACHMENT_CATEGORY_NONE; - } - else - { - $display_cat = ($dimension[0] <= $config['img_link_width'] && $dimension[1] <= $config['img_link_height']) ? ATTACHMENT_CATEGORY_IMAGE : ATTACHMENT_CATEGORY_NONE; - } - } - } - else - { - $display_cat = ATTACHMENT_CATEGORY_NONE; - } - } - } - - // Make some descisions based on user options being set. - if (($display_cat == ATTACHMENT_CATEGORY_IMAGE || $display_cat == ATTACHMENT_CATEGORY_THUMB) && !$user->optionget('viewimg')) - { - $display_cat = ATTACHMENT_CATEGORY_NONE; - } - - if ($display_cat == ATTACHMENT_CATEGORY_FLASH && !$user->optionget('viewflash')) - { - $display_cat = ATTACHMENT_CATEGORY_NONE; - } - - $download_link = append_sid("{$phpbb_root_path}download/file.$phpEx", 'id=' . $attachment['attach_id']); - $l_downloaded_viewed = 'VIEWED_COUNTS'; - - switch ($display_cat) - { - // Images - case ATTACHMENT_CATEGORY_IMAGE: - $inline_link = append_sid("{$phpbb_root_path}download/file.$phpEx", 'id=' . $attachment['attach_id']); - $download_link .= '&mode=view'; - - $block_array += array( - 'S_IMAGE' => true, - 'U_INLINE_LINK' => $inline_link, - ); - - $update_count_ary[] = $attachment['attach_id']; - break; - - // Images, but display Thumbnail - case ATTACHMENT_CATEGORY_THUMB: - $thumbnail_link = append_sid("{$phpbb_root_path}download/file.$phpEx", 'id=' . $attachment['attach_id'] . '&t=1'); - $download_link .= '&mode=view'; - - $block_array += array( - 'S_THUMBNAIL' => true, - 'THUMB_IMAGE' => $thumbnail_link, - ); - - $update_count_ary[] = $attachment['attach_id']; - break; - - // Macromedia Flash Files - case ATTACHMENT_CATEGORY_FLASH: - list($width, $height) = @getimagesize($filename); - - $block_array += array( - 'S_FLASH_FILE' => true, - 'WIDTH' => $width, - 'HEIGHT' => $height, - 'U_VIEW_LINK' => $download_link . '&view=1', - ); - - // Viewed/Heared File ... update the download count - $update_count_ary[] = $attachment['attach_id']; - break; - - default: - $l_downloaded_viewed = 'DOWNLOAD_COUNTS'; - - $block_array += array( - 'S_FILE' => true, - ); - break; - } - - if (!isset($attachment['download_count'])) - { - $attachment['download_count'] = 0; - } - - $block_array += array( - 'U_DOWNLOAD_LINK' => $download_link, - 'L_DOWNLOAD_COUNT' => $user->lang($l_downloaded_viewed, (int) $attachment['download_count']), - ); - } - - $update_count = $update_count_ary; - /** - * Use this event to modify the attachment template data. - * - * This event is triggered once per attachment. - * - * @event core.parse_attachments_modify_template_data - * @var array attachment Array with attachment data - * @var array block_array Template data of the attachment - * @var int display_cat Attachment category data - * @var string download_link Attachment download link - * @var array extensions Array with attachment extensions data - * @var mixed forum_id The forum id the attachments are displayed in (false if in private message) - * @var bool preview Flag indicating if we are in post preview mode - * @var array update_count Array with attachment ids to update download count - * @since 3.1.0-RC5 - */ - $vars = array( - 'attachment', - 'block_array', - 'display_cat', - 'download_link', - 'extensions', - 'forum_id', - 'preview', - 'update_count', - ); - extract($phpbb_dispatcher->trigger_event('core.parse_attachments_modify_template_data', compact($vars))); - $update_count_ary = $update_count; - unset($update_count); - - $template->assign_block_vars('_file', $block_array); - - $compiled_attachments[] = $template->assign_display('attachment_tpl'); - } - - $attachments = $compiled_attachments; - unset($compiled_attachments); - - $unset_tpl = array(); - - preg_match_all('#(.*?)#', $message, $matches, PREG_PATTERN_ORDER); - - $replace = array(); - foreach ($matches[0] as $num => $capture) - { - $index = $matches[1][$num]; - - $replace['from'][] = $matches[0][$num]; - $replace['to'][] = (isset($attachments[$index])) ? $attachments[$index] : sprintf($user->lang['MISSING_INLINE_ATTACHMENT'], $matches[2][array_search($index, $matches[1])]); - - $unset_tpl[] = $index; - } - - if (isset($replace['from'])) - { - $message = str_replace($replace['from'], $replace['to'], $message); - } - - $unset_tpl = array_unique($unset_tpl); - - // Sort correctly - if ($config['display_order']) - { - // Ascending sort - krsort($attachments); - } - else - { - // Descending sort - ksort($attachments); - } - - // Needed to let not display the inlined attachments at the end of the post again - foreach ($unset_tpl as $index) - { - unset($attachments[$index]); - } -} - -/** -* Check if extension is allowed to be posted. -* -* @param mixed $forum_id The forum id to check or false if private message -* @param string $extension The extension to check, for example zip. -* @param array &$extensions The extension array holding the information from the cache (will be obtained if empty) -* -* @return bool False if the extension is not allowed to be posted, else true. -*/ -function extension_allowed($forum_id, $extension, &$extensions) -{ - if (empty($extensions)) - { - global $cache; - $extensions = $cache->obtain_attach_extensions($forum_id); - } - - return (!isset($extensions['_allowed_'][$extension])) ? false : true; -} - -/** -* Truncates string while retaining special characters if going over the max length -* The default max length is 60 at the moment -* The maximum storage length is there to fit the string within the given length. The string may be further truncated due to html entities. -* For example: string given is 'a "quote"' (length: 9), would be a stored as 'a "quote"' (length: 19) -* -* @param string $string The text to truncate to the given length. String is specialchared. -* @param int $max_length Maximum length of string (multibyte character count as 1 char / Html entity count as 1 char) -* @param int $max_store_length Maximum character length of string (multibyte character count as 1 char / Html entity count as entity chars). -* @param bool $allow_reply Allow Re: in front of string -* NOTE: This parameter can cause undesired behavior (returning strings longer than $max_store_length) and is deprecated. -* @param string $append String to be appended -*/ -function truncate_string($string, $max_length = 60, $max_store_length = 255, $allow_reply = false, $append = '') -{ - $strip_reply = false; - $stripped = false; - if ($allow_reply && strpos($string, 'Re: ') === 0) - { - $strip_reply = true; - $string = substr($string, 4); - } - - $_chars = utf8_str_split(htmlspecialchars_decode($string)); - $chars = array_map('utf8_htmlspecialchars', $_chars); - - // Now check the length ;) - if (count($chars) > $max_length) - { - // Cut off the last elements from the array - $string = implode('', array_slice($chars, 0, $max_length - utf8_strlen($append))); - $stripped = true; - } - - // Due to specialchars, we may not be able to store the string... - if (utf8_strlen($string) > $max_store_length) - { - // let's split again, we do not want half-baked strings where entities are split - $_chars = utf8_str_split(htmlspecialchars_decode($string)); - $chars = array_map('utf8_htmlspecialchars', $_chars); - - do - { - array_pop($chars); - $string = implode('', $chars); - } - while (!empty($chars) && utf8_strlen($string) > $max_store_length); - } - - if ($strip_reply) - { - $string = 'Re: ' . $string; - } - - if ($append != '' && $stripped) - { - $string = $string . $append; - } - - return $string; -} - -/** -* Get username details for placing into templates. -* This function caches all modes on first call, except for no_profile and anonymous user - determined by $user_id. -* -* @param string $mode Can be profile (for getting an url to the profile), username (for obtaining the username), colour (for obtaining the user colour), full (for obtaining a html string representing a coloured link to the users profile) or no_profile (the same as full but forcing no profile link) -* @param int $user_id The users id -* @param string $username The users name -* @param string $username_colour The users colour -* @param string $guest_username optional parameter to specify the guest username. It will be used in favor of the GUEST language variable then. -* @param string $custom_profile_url optional parameter to specify a profile url. The user id get appended to this url as &u={user_id} -* -* @return string A string consisting of what is wanted based on $mode. -*/ -function get_username_string($mode, $user_id, $username, $username_colour = '', $guest_username = false, $custom_profile_url = false) -{ - static $_profile_cache; - global $phpbb_dispatcher; - - // We cache some common variables we need within this function - if (empty($_profile_cache)) - { - global $phpbb_root_path, $phpEx; - - $_profile_cache['base_url'] = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u={USER_ID}'); - $_profile_cache['tpl_noprofile'] = '{USERNAME}'; - $_profile_cache['tpl_noprofile_colour'] = '{USERNAME}'; - $_profile_cache['tpl_profile'] = '{USERNAME}'; - $_profile_cache['tpl_profile_colour'] = '{USERNAME}'; - } - - global $user, $auth; - - // This switch makes sure we only run code required for the mode - switch ($mode) - { - case 'full': - case 'no_profile': - case 'colour': - - // Build correct username colour - $username_colour = ($username_colour) ? '#' . $username_colour : ''; - - // Return colour - if ($mode == 'colour') - { - $username_string = $username_colour; - break; - } - - // no break; - - case 'username': - - // Build correct username - if ($guest_username === false) - { - $username = ($username) ? $username : $user->lang['GUEST']; - } - else - { - $username = ($user_id && $user_id != ANONYMOUS) ? $username : ((!empty($guest_username)) ? $guest_username : $user->lang['GUEST']); - } - - // Return username - if ($mode == 'username') - { - $username_string = $username; - break; - } - - // no break; - - case 'profile': - - // Build correct profile url - only show if not anonymous and permission to view profile if registered user - // For anonymous the link leads to a login page. - if ($user_id && $user_id != ANONYMOUS && ($user->data['user_id'] == ANONYMOUS || $auth->acl_get('u_viewprofile'))) - { - $profile_url = ($custom_profile_url !== false) ? $custom_profile_url . '&u=' . (int) $user_id : str_replace(array('={USER_ID}', '=%7BUSER_ID%7D'), '=' . (int) $user_id, $_profile_cache['base_url']); - } - else - { - $profile_url = ''; - } - - // Return profile - if ($mode == 'profile') - { - $username_string = $profile_url; - break; - } - - // no break; - } - - if (!isset($username_string)) - { - if (($mode == 'full' && !$profile_url) || $mode == 'no_profile') - { - $username_string = str_replace(array('{USERNAME_COLOUR}', '{USERNAME}'), array($username_colour, $username), (!$username_colour) ? $_profile_cache['tpl_noprofile'] : $_profile_cache['tpl_noprofile_colour']); - } - else - { - $username_string = str_replace(array('{PROFILE_URL}', '{USERNAME_COLOUR}', '{USERNAME}'), array($profile_url, $username_colour, $username), (!$username_colour) ? $_profile_cache['tpl_profile'] : $_profile_cache['tpl_profile_colour']); - } - } - - /** - * Use this event to change the output of get_username_string() - * - * @event core.modify_username_string - * @var string mode profile|username|colour|full|no_profile - * @var int user_id String or array of additional url - * parameters - * @var string username The user's username - * @var string username_colour The user's colour - * @var string guest_username Optional parameter to specify the - * guest username. - * @var string custom_profile_url Optional parameter to specify a - * profile url. - * @var string username_string The string that has been generated - * @var array _profile_cache Array of original return templates - * @since 3.1.0-a1 - */ - $vars = array( - 'mode', - 'user_id', - 'username', - 'username_colour', - 'guest_username', - 'custom_profile_url', - 'username_string', - '_profile_cache', - ); - extract($phpbb_dispatcher->trigger_event('core.modify_username_string', compact($vars))); - - return $username_string; -} - -/** - * Add an option to the quick-mod tools. - * - * @param string $url The recepting URL for the quickmod actions. - * @param string $option The language key for the value of the option. - * @param string $lang_string The language string to use. - */ -function phpbb_add_quickmod_option($url, $option, $lang_string) -{ - global $template, $user, $phpbb_path_helper; - - $lang_string = $user->lang($lang_string); - $template->assign_block_vars('quickmod', array( - 'VALUE' => $option, - 'TITLE' => $lang_string, - 'LINK' => $phpbb_path_helper->append_url_params($url, array('action' => $option)), - )); -} - -/** -* Concatenate an array into a string list. -* -* @param array $items Array of items to concatenate -* @param object $user The phpBB $user object. -* -* @return string String list. Examples: "A"; "A and B"; "A, B, and C" -*/ -function phpbb_generate_string_list($items, $user) -{ - if (empty($items)) - { - return ''; - } - - $count = count($items); - $last_item = array_pop($items); - $lang_key = 'STRING_LIST_MULTI'; - - if ($count == 1) - { - return $last_item; - } - else if ($count == 2) - { - $lang_key = 'STRING_LIST_SIMPLE'; - } - $list = implode($user->lang['COMMA_SEPARATOR'], $items); - - return $user->lang($lang_key, $list, $last_item); -} - -class bitfield -{ - var $data; - - function __construct($bitfield = '') - { - $this->data = base64_decode($bitfield); - } - - /** - */ - function get($n) - { - // Get the ($n / 8)th char - $byte = $n >> 3; - - if (strlen($this->data) >= $byte + 1) - { - $c = $this->data[$byte]; - - // Lookup the ($n % 8)th bit of the byte - $bit = 7 - ($n & 7); - return (bool) (ord($c) & (1 << $bit)); - } - else - { - return false; - } - } - - function set($n) - { - $byte = $n >> 3; - $bit = 7 - ($n & 7); - - if (strlen($this->data) >= $byte + 1) - { - $this->data[$byte] = $this->data[$byte] | chr(1 << $bit); - } - else - { - $this->data .= str_repeat("\0", $byte - strlen($this->data)); - $this->data .= chr(1 << $bit); - } - } - - function clear($n) - { - $byte = $n >> 3; - - if (strlen($this->data) >= $byte + 1) - { - $bit = 7 - ($n & 7); - $this->data[$byte] = $this->data[$byte] &~ chr(1 << $bit); - } - } - - function get_blob() - { - return $this->data; - } - - function get_base64() - { - return base64_encode($this->data); - } - - function get_bin() - { - $bin = ''; - $len = strlen($this->data); - - for ($i = 0; $i < $len; ++$i) - { - $bin .= str_pad(decbin(ord($this->data[$i])), 8, '0', STR_PAD_LEFT); - } - - return $bin; - } - - function get_all_set() - { - return array_keys(array_filter(str_split($this->get_bin()))); - } - - function merge($bitfield) - { - $this->data = $this->data | $bitfield->get_blob(); - } -} - -/** - * Formats the quote according to the given BBCode status setting - * - * @param phpbb\language\language $language Language class - * @param parse_message $message_parser Message parser class - * @param phpbb\textformatter\utils_interface $text_formatter_utils Text formatter utilities - * @param bool $bbcode_status The status of the BBCode setting - * @param array $quote_attributes The attributes of the quoted post - * @param string $message_link Link of the original quoted post - */ -function phpbb_format_quote($language, $message_parser, $text_formatter_utils, $bbcode_status, $quote_attributes, $message_link = '') -{ - if ($bbcode_status) - { - $quote_text = $text_formatter_utils->generate_quote( - censor_text($message_parser->message), - $quote_attributes - ); - - $message_parser->message = $quote_text . "\n\n"; - } - else - { - $offset = 0; - $quote_string = "> "; - $message = censor_text(trim($message_parser->message)); - // see if we are nesting. It's easily tricked but should work for one level of nesting - if (strpos($message, ">") !== false) - { - $offset = 10; - } - $message = utf8_wordwrap($message, 75 + $offset, "\n"); - - $message = $quote_string . $message; - $message = str_replace("\n", "\n" . $quote_string, $message); - - $message_parser->message = $quote_attributes['author'] . " " . $language->lang('WROTE') . ":\n" . $message . "\n"; - } - - if ($message_link) - { - $message_parser->message = $message_link . $message_parser->message; - } -} diff --git a/install/update/old/includes/functions_convert.php b/install/update/old/includes/functions_convert.php deleted file mode 100644 index 2cfbe95..0000000 --- a/install/update/old/includes/functions_convert.php +++ /dev/null @@ -1,2514 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* Default avatar width/height -* @ignore -*/ -define('DEFAULT_AVATAR_X', 80); -define('DEFAULT_AVATAR_Y', 80); - -// Global functions - all functions can be used by convertors - -// SIMPLE FUNCTIONS - -/** -* Return the preceding value -*/ -function dec($var) -{ - return --$var; -} - -/** -* Return the next value -*/ -function inc($var) -{ - return ++$var; -} - -/** -* Return whether the value is positive -*/ -function is_positive($n) -{ - return ($n > 0) ? 1 : 0; -} - -/** -* Boolean inverse of the value -*/ -function not($var) -{ - return ($var) ? 0 : 1; -} - -/** -* Convert a textual value to it's equivalent boolean value -* -* @param string $str String to convert (converts yes, on, y, 1 and true to boolean true) -* @return boolean The equivalent value -*/ -function str_to_bool($str) -{ - $str = strtolower($str); - return ($str == 'yes' || $str == 'on' || $str == 'y' || $str == 'true' || $str == '1') ? true : false; -} - -/** -* Function to mimic php's empty() function (it is the same) -*/ -function is_empty($mixed) -{ - return empty($mixed); -} - -/** -* Convert the name of a user's primary group to the appropriate equivalent phpBB group id -* -* @param string $status The name of the group -* @return int The group_id corresponding to the equivalent group -*/ -function str_to_primary_group($status) -{ - switch (ucfirst(strtolower($status))) - { - case 'Administrator': - return get_group_id('administrators'); - break; - - case 'Super moderator': - case 'Global moderator': - case 'Moderator': - return get_group_id('global_moderators'); - break; - - case 'Guest': - case 'Anonymous': - return get_group_id('guests'); - break; - - default: - return get_group_id('registered'); - break; - } -} - -/** -* Convert a boolean into the appropriate phpBB constant indicating whether the item is locked -*/ -function is_item_locked($bool) -{ - return ($bool) ? ITEM_LOCKED : ITEM_UNLOCKED; -} - -/** -* Convert a value from days to seconds -*/ -function days_to_seconds($days) -{ - return ($days * 86400); -} - -/** -* Determine whether a user is anonymous and return the appropriate new user_id -*/ -function is_user_anonymous($user_id) -{ - return ($user_id > ANONYMOUS) ? $user_id : ANONYMOUS; -} - -/** -* Generate a key value based on existing values -* -* @param int $pad Amount to add to the maximum value -* @return int Key value -*/ -function auto_id($pad = 0) -{ - global $auto_id, $convert_row; - - if (!empty($convert_row['max_id'])) - { - return $convert_row['max_id'] + $pad; - } - - return $auto_id + $pad; -} - -/** -* Convert a boolean into the appropriate phpBB constant indicating whether the user is active -*/ -function set_user_type($user_active) -{ - return ($user_active) ? USER_NORMAL : USER_INACTIVE; -} - -/** -* Convert a value from minutes to hours -*/ -function minutes_to_hours($minutes) -{ - return ($minutes / 3600); -} - -/** -* Return the group_id for a given group name -*/ -function get_group_id($group_name) -{ - global $db, $group_mapping; - - if (empty($group_mapping)) - { - $sql = 'SELECT group_name, group_id - FROM ' . GROUPS_TABLE; - $result = $db->sql_query($sql); - - $group_mapping = array(); - while ($row = $db->sql_fetchrow($result)) - { - $group_mapping[strtoupper($row['group_name'])] = (int) $row['group_id']; - } - $db->sql_freeresult($result); - } - - if (!count($group_mapping)) - { - add_default_groups(); - return get_group_id($group_name); - } - - if (isset($group_mapping[strtoupper($group_name)])) - { - return $group_mapping[strtoupper($group_name)]; - } - - return $group_mapping['REGISTERED']; -} - -/** -* Generate the email hash stored in the users table -* -* Note: Deprecated, calls should directly go to phpbb_email_hash() -*/ -function gen_email_hash($email) -{ - return phpbb_email_hash($email); -} - -/** -* Convert a boolean into the appropriate phpBB constant indicating whether the topic is locked -*/ -function is_topic_locked($bool) -{ - return (!empty($bool)) ? ITEM_LOCKED : ITEM_UNLOCKED; -} - -/** -* Generate a bbcode_uid value -*/ -function make_uid($timestamp) -{ - static $last_timestamp, $last_uid; - - if (empty($last_timestamp) || $timestamp != $last_timestamp) - { - $last_uid = substr(base_convert(unique_id(), 16, 36), 0, BBCODE_UID_LEN); - } - $last_timestamp = $timestamp; - return $last_uid; -} - - -/** -* Validate a website address -*/ -function validate_website($url) -{ - if ($url === 'http://') - { - return ''; - } - else if (!preg_match('#^http[s]?://#i', $url) && strlen($url) > 0) - { - return 'http://' . $url; - } - return $url; -} - -/** -* Convert nulls to zeros for fields which allowed a NULL value in the source but not the destination -*/ -function null_to_zero($value) -{ - return ($value === NULL) ? 0 : $value; -} - -/** -* Convert nulls to empty strings for fields which allowed a NULL value in the source but not the destination -*/ -function null_to_str($value) -{ - return ($value === NULL) ? '' : $value; -} - -// EXTENDED FUNCTIONS - -/** -* Get old config value -*/ -function get_config_value($config_name) -{ - static $convert_config; - - if (!isset($convert_config)) - { - $convert_config = get_config(); - } - - if (!isset($convert_config[$config_name])) - { - return false; - } - - return (empty($convert_config[$config_name])) ? '' : $convert_config[$config_name]; -} - -/** -* Convert an IP address from the hexadecimal notation to normal dotted-quad notation -*/ -function decode_ip($int_ip) -{ - if (!$int_ip) - { - return $int_ip; - } - - $hexipbang = explode('.', chunk_split($int_ip, 2, '.')); - - // Any mod changing the way ips are stored? Then we are not able to convert and enter the ip "as is" to not "destroy" anything... - if (count($hexipbang) < 4) - { - return $int_ip; - } - - return hexdec($hexipbang[0]) . '.' . hexdec($hexipbang[1]) . '.' . hexdec($hexipbang[2]) . '.' . hexdec($hexipbang[3]); -} - -/** -* Reverse the encoding of wild-carded bans -*/ -function decode_ban_ip($int_ip) -{ - return str_replace('255', '*', decode_ip($int_ip)); -} - -/** -* Determine the MIME-type of a specified filename -* This does not actually inspect the file, but simply uses the file extension -*/ -function mimetype($filename) -{ - if (!preg_match('/\.([a-z0-9]+)$/i', $filename, $m)) - { - return 'application/octet-stream'; - } - - switch (strtolower($m[1])) - { - case 'zip': return 'application/zip'; - case 'jpeg': return 'image/jpeg'; - case 'jpg': return 'image/jpeg'; - case 'jpe': return 'image/jpeg'; - case 'png': return 'image/png'; - case 'gif': return 'image/gif'; - case 'htm': - case 'html': return 'text/html'; - case 'tif': return 'image/tiff'; - case 'tiff': return 'image/tiff'; - case 'ras': return 'image/x-cmu-raster'; - case 'pnm': return 'image/x-portable-anymap'; - case 'pbm': return 'image/x-portable-bitmap'; - case 'pgm': return 'image/x-portable-graymap'; - case 'ppm': return 'image/x-portable-pixmap'; - case 'rgb': return 'image/x-rgb'; - case 'xbm': return 'image/x-xbitmap'; - case 'xpm': return 'image/x-xpixmap'; - case 'xwd': return 'image/x-xwindowdump'; - case 'z': return 'application/x-compress'; - case 'gtar': return 'application/x-gtar'; - case 'tgz': return 'application/x-gtar'; - case 'gz': return 'application/x-gzip'; - case 'tar': return 'application/x-tar'; - case 'xls': return 'application/excel'; - case 'pdf': return 'application/pdf'; - case 'ppt': return 'application/powerpoint'; - case 'rm': return 'application/vnd.rn-realmedia'; - case 'wma': return 'audio/x-ms-wma'; - case 'swf': return 'application/x-shockwave-flash'; - case 'ief': return 'image/ief'; - case 'doc': - case 'dot': - case 'wrd': return 'application/msword'; - case 'ai': - case 'eps': - case 'ps': return 'application/postscript'; - case 'asc': - case 'txt': - case 'c': - case 'cc': - case 'h': - case 'hh': - case 'cpp': - case 'hpp': - case 'php': - case 'php3': return 'text/plain'; - default: return 'application/octet-stream'; - } -} - -/** -* Obtain the dimensions of all remotely hosted avatars -* This should only be called from execute_last -* There can be significant network overhead if there are a large number of remote avatars -* @todo Look at the option of allowing the user to decide whether this is called or to force the dimensions -*/ -function remote_avatar_dims() -{ - global $db; - - $sql = 'SELECT user_id, user_avatar - FROM ' . USERS_TABLE . ' - WHERE user_avatar_type = ' . AVATAR_REMOTE; - $result = $db->sql_query($sql); - - $remote_avatars = array(); - while ($row = $db->sql_fetchrow($result)) - { - $remote_avatars[(int) $row['user_id']] = $row['user_avatar']; - } - $db->sql_freeresult($result); - - foreach ($remote_avatars as $user_id => $avatar) - { - $width = (int) get_remote_avatar_dim($avatar, 0); - $height = (int) get_remote_avatar_dim($avatar, 1); - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_avatar_width = ' . (int) $width . ', user_avatar_height = ' . (int) $height . ' - WHERE user_id = ' . $user_id; - $db->sql_query($sql); - } -} - -function import_avatar_gallery($gallery_name = '', $subdirs_as_galleries = false) -{ - global $config, $convert, $user; - - $relative_path = empty($convert->convertor['source_path_absolute']); - - // check for trailing slash - if (rtrim($convert->convertor['avatar_gallery_path'], '/') === '') - { - $convert->p_master->error(sprintf($user->lang['CONV_ERROR_NO_GALLERY_PATH'], 'import_avatar_gallery()'), __LINE__, __FILE__); - } - - $src_path = relative_base(path($convert->convertor['avatar_gallery_path'], $relative_path), $relative_path); - - if (is_dir($src_path)) - { - // Do not die on failure... safe mode restrictions may be in effect. - copy_dir($convert->convertor['avatar_gallery_path'], path($config['avatar_gallery_path']) . $gallery_name, !$subdirs_as_galleries, false, false, $relative_path); - - // only doing 1 level deep. (ibf 1.x) - // notes: ibf has 2 tiers: directly in the avatar directory for base gallery (handled in the above statement), plus subdirs(handled below). - // recursive subdirs ignored. -- i don't know if other forums support recursive galleries. if they do, this following code could be upgraded to be recursive. - if ($subdirs_as_galleries) - { - $dirlist = array(); - if ($handle = @opendir($src_path)) - { - while ($entry = readdir($handle)) - { - if ($entry[0] == '.' || $entry == 'CVS' || $entry == 'index.htm') - { - continue; - } - - if (is_dir($src_path . $entry)) - { - $dirlist[] = $entry; - } - } - closedir($handle); - } - else if ($dir = @dir($src_path)) - { - while ($entry = $dir->read()) - { - if ($entry[0] == '.' || $entry == 'CVS' || $entry == 'index.htm') - { - continue; - } - - if (is_dir($src_path . $entry)) - { - $dirlist[] = $entry; - } - } - $dir->close(); - } - - for ($i = 0, $end = count($dirlist); $i < $end; ++$i) - { - $dir = $dirlist[$i]; - - // Do not die on failure... safe mode restrictions may be in effect. - copy_dir(path($convert->convertor['avatar_gallery_path'], $relative_path) . $dir, path($config['avatar_gallery_path']) . $dir, true, false, false, $relative_path); - } - } - } -} - -function import_attachment_files($category_name = '') -{ - global $config, $convert, $db, $user; - - $sql = 'SELECT config_value AS upload_path - FROM ' . CONFIG_TABLE . " - WHERE config_name = 'upload_path'"; - $result = $db->sql_query($sql); - $config['upload_path'] = $db->sql_fetchfield('upload_path'); - $db->sql_freeresult($result); - - $relative_path = empty($convert->convertor['source_path_absolute']); - - if (empty($convert->convertor['upload_path'])) - { - $convert->p_master->error(sprintf($user->lang['CONV_ERROR_NO_UPLOAD_DIR'], 'import_attachment_files()'), __LINE__, __FILE__); - } - - if (is_dir(relative_base(path($convert->convertor['upload_path'], $relative_path), $relative_path))) - { - copy_dir($convert->convertor['upload_path'], path($config['upload_path']) . $category_name, true, false, true, $relative_path); - } -} - -function attachment_forum_perms($forum_id) -{ - if (!is_array($forum_id)) - { - $forum_id = array($forum_id); - } - - return serialize($forum_id); -} - -// base64todec function -// -> from php manual? -function base64_unpack($string) -{ - $chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+-'; - $base = strlen($chars); - - $length = strlen($string); - $number = 0; - - for ($i = 1; $i <= $length; $i++) - { - $pos = $length - $i; - $operand = strpos($chars, substr($string, $pos, 1)); - $exponent = pow($base, $i-1); - $dec_value = $operand * $exponent; - $number += $dec_value; - } - - return $number; -} - -function _import_check($config_var, $source, $use_target) -{ - global $convert, $config; - - $result = array( - 'orig_source' => $source, - 'copied' => false, - 'relative_path' => (empty($convert->convertor['source_path_absolute'])) ? true : false, - ); - - // copy file will prepend $phpBB_root_path - $target = $config[$config_var] . '/' . utf8_basename(($use_target === false) ? $source : $use_target); - - if (!empty($convert->convertor[$config_var]) && strpos($source, $convert->convertor[$config_var]) !== 0) - { - $source = $convert->convertor[$config_var] . $source; - } - - $result['source'] = $source; - - if (file_exists(relative_base($source, $result['relative_path'], __LINE__, __FILE__))) - { - $result['copied'] = copy_file($source, $target, false, false, $result['relative_path']); - } - - if ($result['copied']) - { - $result['target'] = utf8_basename($target); - } - else - { - $result['target'] = ($use_target !== false) ? $result['orig_source'] : utf8_basename($target); - } - - return $result; -} - -function import_attachment($source, $use_target = false) -{ - if (empty($source)) - { - return ''; - } - - global $convert, $config, $user; - - // check for trailing slash - if (rtrim($convert->convertor['upload_path'], '/') === '') - { - $convert->p_master->error(sprintf($user->lang['CONV_ERROR_NO_UPLOAD_DIR'], 'import_attachment()'), __LINE__, __FILE__); - } - - $result = _import_check('upload_path', $source, $use_target); - - if ($result['copied']) - { - // Thumbnails? - if (is_array($convert->convertor['thumbnails'])) - { - $thumb_dir = $convert->convertor['thumbnails'][0]; - $thumb_prefix = $convert->convertor['thumbnails'][1]; - $thumb_source = $thumb_dir . $thumb_prefix . utf8_basename($result['source']); - - if (strpos($thumb_source, $convert->convertor['upload_path']) !== 0) - { - $thumb_source = $convert->convertor['upload_path'] . $thumb_source; - } - $thumb_target = $config['upload_path'] . '/thumb_' . $result['target']; - - if (file_exists(relative_base($thumb_source, $result['relative_path'], __LINE__, __FILE__))) - { - copy_file($thumb_source, $thumb_target, false, false, $result['relative_path']); - } - } - } - - return $result['target']; -} - -function import_rank($source, $use_target = false) -{ - if (empty($source)) - { - return ''; - } - - global $convert, $user; - - if (!isset($convert->convertor['ranks_path'])) - { - $convert->p_master->error(sprintf($user->lang['CONV_ERROR_NO_RANKS_PATH'], 'import_rank()'), __LINE__, __FILE__); - } - - $result = _import_check('ranks_path', $source, $use_target); - return $result['target']; -} - -function import_smiley($source, $use_target = false) -{ - if (empty($source)) - { - return ''; - } - - global $convert, $user; - - // check for trailing slash - if (rtrim($convert->convertor['smilies_path'], '/') === '') - { - $convert->p_master->error(sprintf($user->lang['CONV_ERROR_NO_SMILIES_PATH'], 'import_smiley()'), __LINE__, __FILE__); - } - - $result = _import_check('smilies_path', $source, $use_target); - return $result['target']; -} - -/* -*/ -function import_avatar($source, $use_target = false, $user_id = false) -{ - if (empty($source) || preg_match('#^https?:#i', $source) || preg_match('#blank\.(gif|png)$#i', $source)) - { - return; - } - - global $convert, $config, $user; - - // check for trailing slash - if (rtrim($convert->convertor['avatar_path'], '/') === '') - { - $convert->p_master->error(sprintf($user->lang['CONV_ERROR_NO_AVATAR_PATH'], 'import_avatar()'), __LINE__, __FILE__); - } - - if ($use_target === false && $user_id !== false) - { - $use_target = $config['avatar_salt'] . '_' . $user_id . '.' . substr(strrchr($source, '.'), 1); - } - - _import_check('avatar_path', $source, $use_target); - - return ((!empty($user_id)) ? $user_id : $use_target) . '.' . substr(strrchr($source, '.'), 1); -} - -/** -* @todo all image dimension functions below (there are a *lot*) should get revisited and converted to one or two functions (no more needed, really). -*/ - -/** -* Calculate the size of the specified image -* Called from the following functions for calculating the size of specific image types -*/ -function get_image_dim($source) -{ - if (empty($source)) - { - return array(0, 0); - } - - global $convert; - - $relative_path = empty($convert->convertor['source_path_absolute']); - - if (file_exists(relative_base($source, $relative_path))) - { - $image = relative_base($source, $relative_path); - return @getimagesize($image); - } - - return false; -} - -/** -* Obtain the width of the specified smilie -*/ -function get_smiley_width($src) -{ - return get_smiley_dim($src, 0); -} - -/** -* Obtain the height of the specified smilie -*/ -function get_smiley_height($src) -{ - return get_smiley_dim($src, 1); -} - -/** -* Obtain the size of the specified smilie (using the cache if possible) and cache the value -*/ -function get_smiley_dim($source, $axis) -{ - if (empty($source)) - { - return 15; - } - - static $smiley_cache = array(); - - if (isset($smiley_cache[$source])) - { - return $smiley_cache[$source][$axis]; - } - - global $convert, $user; - - $orig_source = $source; - - if (!isset($convert->convertor['smilies_path'])) - { - $convert->p_master->error(sprintf($user->lang['CONV_ERROR_NO_SMILIES_PATH'], 'get_smiley_dim()'), __LINE__, __FILE__); - } - - if (!empty($convert->convertor['smilies_path']) && strpos($source, $convert->convertor['smilies_path']) !== 0) - { - $source = $convert->convertor['smilies_path'] . $source; - } - - $smiley_cache[$orig_source] = get_image_dim($source); - - if (empty($smiley_cache[$orig_source]) || empty($smiley_cache[$orig_source][0]) || empty($smiley_cache[$orig_source][1])) - { - $smiley_cache[$orig_source] = array(15, 15); - return 15; - } - - return $smiley_cache[$orig_source][$axis]; -} - -/** -* Obtain the width of the specified avatar -*/ -function get_avatar_width($src, $func = false, $arg1 = false, $arg2 = false) -{ - return get_avatar_dim($src, 0, $func, $arg1, $arg2); -} - -/** -* Obtain the height of the specified avatar -*/ -function get_avatar_height($src, $func = false, $arg1 = false, $arg2 = false) -{ - return get_avatar_dim($src, 1, $func, $arg1, $arg2); -} - -/** -*/ -function get_avatar_dim($src, $axis, $func = false, $arg1 = false, $arg2 = false) -{ - $avatar_type = AVATAR_UPLOAD; - - if ($func) - { - if ($arg1 || $arg2) - { - $ary = array($arg1); - - if ($arg2) - { - $ary[] = $arg2; - } - - $avatar_type = call_user_func_array($func, $ary); - } - else - { - $avatar_type = call_user_func($func); - } - } - - switch ($avatar_type) - { - case AVATAR_UPLOAD: - return get_upload_avatar_dim($src, $axis); - break; - - case AVATAR_GALLERY: - return get_gallery_avatar_dim($src, $axis); - break; - - case AVATAR_REMOTE: - // see notes on this functions usage and (hopefully) model $func to avoid this accordingly - return get_remote_avatar_dim($src, $axis); - break; - - default: - $default_x = (defined('DEFAULT_AVATAR_X_CUSTOM')) ? DEFAULT_AVATAR_X_CUSTOM : DEFAULT_AVATAR_X; - $default_y = (defined('DEFAULT_AVATAR_Y_CUSTOM')) ? DEFAULT_AVATAR_Y_CUSTOM : DEFAULT_AVATAR_Y; - - return $axis ? $default_y : $default_x; - break; - } -} - -/** -* Obtain the size of the specified uploaded avatar (using the cache if possible) and cache the value -*/ -function get_upload_avatar_dim($source, $axis) -{ - static $cachedims = false; - static $cachekey = false; - - if (empty($source)) - { - return 0; - } - - if ($cachekey == $source) - { - return $cachedims[$axis]; - } - - if (substr($source, 0, 7) == 'upload:') - { - $source = substr($source, 7); - } - - global $convert, $user; - - if (!isset($convert->convertor['avatar_path'])) - { - $convert->p_master->error(sprintf($user->lang['CONV_ERROR_NO_AVATAR_PATH'], 'get_upload_avatar_dim()'), __LINE__, __FILE__); - } - - if (!empty($convert->convertor['avatar_path']) && strpos($source, $convert->convertor['avatar_path']) !== 0) - { - $source = path($convert->convertor['avatar_path'], empty($convert->convertor['source_path_absolute'])) . $source; - } - - $cachedims = get_image_dim($source); - - if (empty($cachedims) || empty($cachedims[0]) || empty($cachedims[1])) - { - $default_x = (defined('DEFAULT_AVATAR_X_CUSTOM')) ? DEFAULT_AVATAR_X_CUSTOM : DEFAULT_AVATAR_X; - $default_y = (defined('DEFAULT_AVATAR_Y_CUSTOM')) ? DEFAULT_AVATAR_Y_CUSTOM : DEFAULT_AVATAR_Y; - - $cachedims = array($default_x, $default_y); - } - - return $cachedims[$axis]; -} - -/** -* Obtain the size of the specified gallery avatar (using the cache if possible) and cache the value -*/ -function get_gallery_avatar_dim($source, $axis) -{ - if (empty($source)) - { - return 0; - } - - static $avatar_cache = array(); - - if (isset($avatar_cache[$source])) - { - return $avatar_cache[$source][$axis]; - } - - global $convert, $user; - - $orig_source = $source; - - if (!isset($convert->convertor['avatar_gallery_path'])) - { - $convert->p_master->error(sprintf($user->lang['CONV_ERROR_NO_GALLERY_PATH'], 'get_gallery_avatar_dim()'), __LINE__, __FILE__); - } - - if (!empty($convert->convertor['avatar_gallery_path']) && strpos($source, $convert->convertor['avatar_gallery_path']) !== 0) - { - $source = path($convert->convertor['avatar_gallery_path'], empty($convert->convertor['source_path_absolute'])) . $source; - } - - $avatar_cache[$orig_source] = get_image_dim($source); - - if (empty($avatar_cache[$orig_source]) || empty($avatar_cache[$orig_source][0]) || empty($avatar_cache[$orig_source][1])) - { - $default_x = (defined('DEFAULT_AVATAR_X_CUSTOM')) ? DEFAULT_AVATAR_X_CUSTOM : DEFAULT_AVATAR_X; - $default_y = (defined('DEFAULT_AVATAR_Y_CUSTOM')) ? DEFAULT_AVATAR_Y_CUSTOM : DEFAULT_AVATAR_Y; - - $avatar_cache[$orig_source] = array($default_x, $default_y); - } - - return $avatar_cache[$orig_source][$axis]; -} - -/** -* Obtain the size of the specified remote avatar (using the cache if possible) and cache the value -* Whilst it's unlikely that remote avatars will be duplicated, it is possible so caching seems the best option -* This should only be called from a post processing step due to the possibility of network timeouts -*/ -function get_remote_avatar_dim($src, $axis) -{ - if (empty($src)) - { - return 0; - } - - static $remote_avatar_cache = array(); - - // an ugly hack: we assume that the dimensions of each remote avatar are accessed exactly twice (x and y) - if (isset($remote_avatar_cache[$src])) - { - $retval = $remote_avatar_cache[$src][$axis]; - unset($remote_avatar_cache); - return $retval; - } - - $url_info = @parse_url($src); - if (empty($url_info['host'])) - { - return 0; - } - $host = $url_info['host']; - $port = (isset($url_info['port'])) ? $url_info['port'] : 0; - $protocol = (isset($url_info['scheme'])) ? $url_info['scheme'] : 'http'; - if (empty($port)) - { - switch (strtolower($protocol)) - { - case 'ftp': - $port = 21; - break; - - case 'https': - $port = 443; - break; - - default: - $port = 80; - } - } - - $timeout = @ini_get('default_socket_timeout'); - @ini_set('default_socket_timeout', 2); - - // We're just trying to reach the server to avoid timeouts - $fp = @fsockopen($host, $port, $errno, $errstr, 1); - if ($fp) - { - $remote_avatar_cache[$src] = @getimagesize($src); - fclose($fp); - } - - $default_x = (defined('DEFAULT_AVATAR_X_CUSTOM')) ? DEFAULT_AVATAR_X_CUSTOM : DEFAULT_AVATAR_X; - $default_y = (defined('DEFAULT_AVATAR_Y_CUSTOM')) ? DEFAULT_AVATAR_Y_CUSTOM : DEFAULT_AVATAR_Y; - $default = array($default_x, $default_y); - - if (empty($remote_avatar_cache[$src]) || empty($remote_avatar_cache[$src][0]) || empty($remote_avatar_cache[$src][1])) - { - $remote_avatar_cache[$src] = $default; - } - else - { - // We trust gallery and uploaded avatars to conform to the size settings; we might have to adjust here - if ($remote_avatar_cache[$src][0] > $default_x || $remote_avatar_cache[$src][1] > $default_y) - { - $bigger = ($remote_avatar_cache[$src][0] > $remote_avatar_cache[$src][1]) ? 0 : 1; - $ratio = $default[$bigger] / $remote_avatar_cache[$src][$bigger]; - $remote_avatar_cache[$src][0] = (int) ($remote_avatar_cache[$src][0] * $ratio); - $remote_avatar_cache[$src][1] = (int) ($remote_avatar_cache[$src][1] * $ratio); - } - } - - @ini_set('default_socket_timeout', $timeout); - return $remote_avatar_cache[$src][$axis]; -} - -function set_user_options() -{ - global $convert_row; - - // Key need to be set in row, else default value is chosen - $keyoptions = array( - 'viewimg' => array('bit' => 0, 'default' => 1), - 'viewflash' => array('bit' => 1, 'default' => 1), - 'viewsmilies' => array('bit' => 2, 'default' => 1), - 'viewsigs' => array('bit' => 3, 'default' => 1), - 'viewavatars' => array('bit' => 4, 'default' => 1), - 'viewcensors' => array('bit' => 5, 'default' => 1), - 'attachsig' => array('bit' => 6, 'default' => 0), - 'bbcode' => array('bit' => 8, 'default' => 1), - 'smilies' => array('bit' => 9, 'default' => 1), - 'sig_bbcode' => array('bit' => 15, 'default' => 1), - 'sig_smilies' => array('bit' => 16, 'default' => 1), - 'sig_links' => array('bit' => 17, 'default' => 1), - ); - - $option_field = 0; - - foreach ($keyoptions as $key => $key_ary) - { - $value = (isset($convert_row[$key])) ? (int) $convert_row[$key] : $key_ary['default']; - - if ($value && !($option_field & 1 << $key_ary['bit'])) - { - $option_field += 1 << $key_ary['bit']; - } - } - - return $option_field; -} - -/** -* Index messages on the fly as we convert them -* @todo naderman, can you check that this works with the new search plugins as it's use is currently disabled (and thus untested) -function search_indexing($message = '') -{ - global $fulltext_search, $convert_row; - - if (!isset($convert_row['post_id'])) - { - return; - } - - if (!$message) - { - if (!isset($convert_row['message'])) - { - return; - } - - $message = $convert_row['message']; - } - - $title = (isset($convert_row['title'])) ? $convert_row['title'] : ''; - - $fulltext_search->index('post', $convert_row['post_id'], $message, $title, $convert_row['poster_id'], $convert_row['forum_id']); -} -*/ - -function make_unique_filename($filename) -{ - if (!strlen($filename)) - { - $filename = md5(unique_id()) . '.dat'; - } - else if ($filename[0] == '.') - { - $filename = md5(unique_id()) . $filename; - } - else if (preg_match('/\.([a-z]+)$/i', $filename, $m)) - { - $filename = preg_replace('/\.([a-z]+)$/i', '_' . md5(unique_id()) . '.\1', $filename); - } - else - { - $filename .= '_' . md5(unique_id()) . '.dat'; - } - - return $filename; -} - -function words_unique(&$words) -{ - reset($words); - $return_array = array(); - - $word = current($words); - do - { - $return_array[$word] = $word; - } - while ($word = next($words)); - - return $return_array; -} - -/** -* Adds a user to the specified group and optionally makes them a group leader -* This function does not create the group if it does not exist and so should only be called after the groups have been created -*/ -function add_user_group($group_id, $user_id, $group_leader = false) -{ - global $db; - - $sql = 'INSERT INTO ' . USER_GROUP_TABLE . ' ' . $db->sql_build_array('INSERT', array( - 'group_id' => $group_id, - 'user_id' => $user_id, - 'group_leader' => ($group_leader) ? 1 : 0, - 'user_pending' => 0)); - $db->sql_query($sql); -} - -// STANDALONE FUNCTIONS - -/** -* Add users to the pre-defined "special" groups -* -* @param string $group The name of the special group to add to -* @param string $select_query An SQL query to retrieve the user(s) to add to the group -*/ -function user_group_auth($group, $select_query, $use_src_db) -{ - global $convert, $user, $db, $src_db, $same_db; - - if (!in_array($group, array('guests', 'registered', 'registered_coppa', 'global_moderators', 'administrators', 'bots'))) - { - $convert->p_master->error(sprintf($user->lang['CONV_ERROR_WRONG_GROUP'], $group, 'user_group_auth()'), __LINE__, __FILE__, true); - return; - } - - $sql = 'SELECT group_id - FROM ' . GROUPS_TABLE . " - WHERE group_name = '" . $db->sql_escape(strtoupper($group)) . "'"; - $result = $db->sql_query($sql); - $group_id = (int) $db->sql_fetchfield('group_id'); - $db->sql_freeresult($result); - - if (!$group_id) - { - $convert->p_master->error(sprintf($user->lang['CONV_ERROR_NO_GROUP'], $group, 'user_group_auth()'), __LINE__, __FILE__, true); - return; - } - - if ($same_db || !$use_src_db) - { - $sql = 'INSERT INTO ' . USER_GROUP_TABLE . ' (user_id, group_id, user_pending) - ' . str_replace('{' . strtoupper($group) . '}', $group_id . ', 0', $select_query); - $db->sql_query($sql); - } - else - { - $result = $src_db->sql_query(str_replace('{' . strtoupper($group) . '}', $group_id . ' ', $select_query)); - while ($row = $src_db->sql_fetchrow($result)) - { - // this might become quite a lot of INSERTS unfortunately - $sql = 'INSERT INTO ' . USER_GROUP_TABLE . " (user_id, group_id, user_pending) - VALUES ({$row['user_id']}, $group_id, 0)"; - $db->sql_query($sql); - } - $src_db->sql_freeresult($result); - } -} - -/** -* Retrieves configuration information from the source forum and caches it as an array -* Both database and file driven configuration formats can be handled -* (the type used is specified in $config_schema, see convert_phpbb20.php for more details) -*/ -function get_config() -{ - static $convert_config; - global $user; - - if (isset($convert_config)) - { - return $convert_config; - } - - global $src_db, $same_db; - global $convert; - - if ($convert->config_schema['table_format'] != 'file') - { - if ($convert->mysql_convert && $same_db) - { - $src_db->sql_query("SET NAMES 'binary'"); - } - - $sql = 'SELECT * FROM ' . $convert->src_table_prefix . $convert->config_schema['table_name']; - $result = $src_db->sql_query($sql); - $row = $src_db->sql_fetchrow($result); - - if (!$row) - { - $convert->p_master->error($user->lang['CONV_ERROR_GET_CONFIG'], __LINE__, __FILE__); - } - } - - if (is_array($convert->config_schema['table_format'])) - { - $convert_config = array(); - list($key, $val) = each($convert->config_schema['table_format']); - - do - { - $convert_config[$row[$key]] = $row[$val]; - } - while ($row = $src_db->sql_fetchrow($result)); - $src_db->sql_freeresult($result); - - if ($convert->mysql_convert && $same_db) - { - $src_db->sql_query("SET NAMES 'utf8'"); - } - } - else if ($convert->config_schema['table_format'] == 'file') - { - $filename = $convert->options['forum_path'] . '/' . $convert->config_schema['filename']; - if (!file_exists($filename)) - { - $convert->p_master->error($user->lang('FILE_NOT_FOUND', $filename), __LINE__, __FILE__); - } - - if (isset($convert->config_schema['array_name'])) - { - unset($convert->config_schema['array_name']); - } - - $convert_config = extract_variables_from_file($filename); - if (!empty($convert->config_schema['array_name'])) - { - $convert_config = $convert_config[$convert->config_schema['array_name']]; - } - } - else - { - $convert_config = $row; - if ($convert->mysql_convert && $same_db) - { - $src_db->sql_query("SET NAMES 'utf8'"); - } - } - - if (!count($convert_config)) - { - $convert->p_master->error($user->lang['CONV_ERROR_CONFIG_EMPTY'], __LINE__, __FILE__); - } - - return $convert_config; -} - -/** -* Transfers the relevant configuration information from the source forum -* The mapping of fields is specified in $config_schema, see convert_phpbb20.php for more details -*/ -function restore_config($schema) -{ - global $config; - - $convert_config = get_config(); - - foreach ($schema['settings'] as $config_name => $src) - { - if (preg_match('/(.*)\((.*)\)/', $src, $m)) - { - $var = (empty($m[2]) || empty($convert_config[$m[2]])) ? "''" : "'" . addslashes($convert_config[$m[2]]) . "'"; - $exec = '$config_value = ' . $m[1] . '(' . $var . ');'; - // @codingStandardsIgnoreStart - eval($exec); - // @codingStandardsIgnoreEnd - } - else - { - if ($schema['table_format'] != 'file' || empty($schema['array_name'])) - { - $config_value = (isset($convert_config[$src])) ? $convert_config[$src] : ''; - } - else if (!empty($schema['array_name'])) - { - $src_ary = $schema['array_name']; - $config_value = (isset($convert_config[$src_ary][$src])) ? $convert_config[$src_ary][$src] : ''; - } - } - - if ($config_value !== '') - { - // Most are... - if (is_string($config_value)) - { - $config_value = truncate_string(utf8_htmlspecialchars($config_value), 255, 255, false); - } - - $config->set($config_name, $config_value); - } - } -} - -/** -* Update the count of PM's in custom folders for all users -*/ -function update_folder_pm_count() -{ - global $db; - - $sql = 'SELECT user_id, folder_id, COUNT(msg_id) as num_messages - FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE folder_id NOT IN (' . PRIVMSGS_NO_BOX . ', ' . PRIVMSGS_HOLD_BOX . ', ' . PRIVMSGS_INBOX . ', ' . PRIVMSGS_OUTBOX . ', ' . PRIVMSGS_SENTBOX . ') - GROUP BY folder_id, user_id'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $db->sql_query('UPDATE ' . PRIVMSGS_FOLDER_TABLE . ' SET pm_count = ' . $row['num_messages'] . ' - WHERE user_id = ' . $row['user_id'] . ' AND folder_id = ' . $row['folder_id']); - } - $db->sql_freeresult($result); -} - -// Functions mainly used by the main convertor script - -function path($path, $path_relative = true) -{ - if ($path === false) - { - return ''; - } - - if (substr($path, -1) != '/') - { - $path .= '/'; - } - - if (!$path_relative) - { - return $path; - } - - if (substr($path, 0, 1) == '/') - { - $path = substr($path, 1); - } - - return $path; -} - -/** -* Extract the variables defined in a configuration file -* @todo As noted by Xore we need to look at this from a security perspective -*/ -function extract_variables_from_file($_filename) -{ - include($_filename); - - $vars = get_defined_vars(); - unset($vars['_filename']); - - return $vars; -} - -function get_path($src_path, $src_url, $test_file) -{ - global $phpbb_root_path, $phpEx; - - $board_config = get_config(); - - $test_file = preg_replace('/\.php$/i', ".$phpEx", $test_file); - $src_path = path($src_path); - - if (@file_exists($phpbb_root_path . $src_path . $test_file)) - { - return $src_path; - } - - if (!empty($src_url) && !empty($board_config['server_name'])) - { - if (!preg_match('#https?://([^/]+)(.*)#i', $src_url, $m)) - { - return false; - } - - if ($m[1] != $board_config['server_name']) - { - return false; - } - - $url_parts = explode('/', $m[2]); - if (substr($src_url, -1) != '/') - { - if (preg_match('/.*\.([a-z0-9]{3,4})$/i', $url_parts[count($url_parts) - 1])) - { - $url_parts[count($url_parts) - 1] = ''; - } - else - { - $url_parts[] = ''; - } - } - - $script_path = $board_config['script_path']; - if (substr($script_path, -1) == '/') - { - $script_path = substr($script_path, 0, -1); - } - - $path_array = array(); - - $phpbb_parts = explode('/', $script_path); - for ($i = 0, $end = count($url_parts); $i < $end; ++$i) - { - if ($i < count($phpbb_parts[$i]) && $url_parts[$i] == $phpbb_parts[$i]) - { - $path_array[] = $url_parts[$i]; - unset($url_parts[$i]); - } - else - { - $path = ''; - for ($j = $i, $end2 = count($phpbb_parts); $j < $end2; ++$j) - { - $path .= '../'; - } - $path .= implode('/', $url_parts); - break; - } - } - - if (!empty($path)) - { - if (@file_exists($phpbb_root_path . $path . $test_file)) - { - return $path; - } - } - } - - return false; -} - -function compare_table($tables, $tablename, &$prefixes) -{ - for ($i = 0, $table_size = count($tables); $i < $table_size; ++$i) - { - if (preg_match('/(.*)' . $tables[$i] . '$/', $tablename, $m)) - { - if (empty($m[1])) - { - $m[1] = '*'; - } - - if (isset($prefixes[$m[1]])) - { - $prefixes[$m[1]]++; - } - else - { - $prefixes[$m[1]] = 1; - } - } - } -} - -/** -* Grant permissions to a specified user or group -* -* @param string $ug_type user|group|user_role|group_role -* @param mixed $forum_id forum ids (array|int|0) -> 0 == all forums -* @param mixed $ug_id [int] user_id|group_id : [string] usergroup name -* @param mixed $acl_list [string] acl entry : [array] acl entries : [string] role entry -* @param int $setting ACL_YES|ACL_NO|ACL_NEVER -*/ -function mass_auth($ug_type, $forum_id, $ug_id, $acl_list, $setting = ACL_NO) -{ - global $db; - static $acl_option_ids, $group_ids; - - if (($ug_type == 'group' || $ug_type == 'group_role') && is_string($ug_id)) - { - if (!isset($group_ids[$ug_id])) - { - $sql = 'SELECT group_id - FROM ' . GROUPS_TABLE . " - WHERE group_name = '" . $db->sql_escape(strtoupper($ug_id)) . "'"; - $result = $db->sql_query_limit($sql, 1); - $id = (int) $db->sql_fetchfield('group_id'); - $db->sql_freeresult($result); - - if (!$id) - { - return; - } - - $group_ids[$ug_id] = $id; - } - - $ug_id = (int) $group_ids[$ug_id]; - } - - $table = ($ug_type == 'user' || $ug_type == 'user_role') ? ACL_USERS_TABLE : ACL_GROUPS_TABLE; - $id_field = ($ug_type == 'user' || $ug_type == 'user_role') ? 'user_id' : 'group_id'; - - // Role based permissions are the simplest to handle so check for them first - if ($ug_type == 'user_role' || $ug_type == 'group_role') - { - if (is_numeric($forum_id)) - { - $sql = 'SELECT role_id - FROM ' . ACL_ROLES_TABLE . " - WHERE role_name = 'ROLE_" . $db->sql_escape($acl_list) . "'"; - $result = $db->sql_query_limit($sql, 1); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - // If we have no role id there is something wrong here - if ($row) - { - $sql = "INSERT INTO $table ($id_field, forum_id, auth_role_id) VALUES ($ug_id, $forum_id, " . $row['role_id'] . ')'; - $db->sql_query($sql); - } - } - - return; - } - - // Build correct parameters - $auth = array(); - - if (!is_array($acl_list)) - { - $auth = array($acl_list => $setting); - } - else - { - foreach ($acl_list as $auth_option) - { - $auth[$auth_option] = $setting; - } - } - unset($acl_list); - - if (!is_array($forum_id)) - { - $forum_id = array($forum_id); - } - - // Set any flags as required - foreach ($auth as $auth_option => $acl_setting) - { - $flag = substr($auth_option, 0, strpos($auth_option, '_') + 1); - if (empty($auth[$flag])) - { - $auth[$flag] = $acl_setting; - } - } - - if (!is_array($acl_option_ids) || empty($acl_option_ids)) - { - $sql = 'SELECT auth_option_id, auth_option - FROM ' . ACL_OPTIONS_TABLE; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $acl_option_ids[$row['auth_option']] = $row['auth_option_id']; - } - $db->sql_freeresult($result); - } - - $sql_forum = 'AND ' . $db->sql_in_set('a.forum_id', array_map('intval', $forum_id), false, true); - - $sql = ($ug_type == 'user') ? 'SELECT o.auth_option_id, o.auth_option, a.forum_id, a.auth_setting FROM ' . ACL_USERS_TABLE . ' a, ' . ACL_OPTIONS_TABLE . " o WHERE a.auth_option_id = o.auth_option_id $sql_forum AND a.user_id = $ug_id" : 'SELECT o.auth_option_id, o.auth_option, a.forum_id, a.auth_setting FROM ' . ACL_GROUPS_TABLE . ' a, ' . ACL_OPTIONS_TABLE . " o WHERE a.auth_option_id = o.auth_option_id $sql_forum AND a.group_id = $ug_id"; - $result = $db->sql_query($sql); - - $cur_auth = array(); - while ($row = $db->sql_fetchrow($result)) - { - $cur_auth[$row['forum_id']][$row['auth_option_id']] = $row['auth_setting']; - } - $db->sql_freeresult($result); - - $sql_ary = array(); - foreach ($forum_id as $forum) - { - foreach ($auth as $auth_option => $setting) - { - $auth_option_id = $acl_option_ids[$auth_option]; - - if (!$auth_option_id) - { - continue; - } - - switch ($setting) - { - case ACL_NO: - if (isset($cur_auth[$forum][$auth_option_id])) - { - $sql_ary['delete'][] = "DELETE FROM $table - WHERE forum_id = $forum - AND auth_option_id = $auth_option_id - AND $id_field = $ug_id"; - } - break; - - default: - if (!isset($cur_auth[$forum][$auth_option_id])) - { - $sql_ary['insert'][] = "$ug_id, $forum, $auth_option_id, $setting"; - } - else if ($cur_auth[$forum][$auth_option_id] != $setting) - { - $sql_ary['update'][] = "UPDATE " . $table . " - SET auth_setting = $setting - WHERE $id_field = $ug_id - AND forum_id = $forum - AND auth_option_id = $auth_option_id"; - } - } - } - } - unset($cur_auth); - - $sql = ''; - foreach ($sql_ary as $sql_type => $sql_subary) - { - switch ($sql_type) - { - case 'insert': - switch ($db->get_sql_layer()) - { - case 'mysql': - case 'mysql4': - $sql = 'VALUES ' . implode(', ', preg_replace('#^(.*?)$#', '(\1)', $sql_subary)); - break; - - case 'sqlite3': - case 'mssqlnative': - $sql = implode(' UNION ALL ', preg_replace('#^(.*?)$#', 'SELECT \1', $sql_subary)); - break; - - default: - foreach ($sql_subary as $sql) - { - $sql = "INSERT INTO $table ($id_field, forum_id, auth_option_id, auth_setting) VALUES ($sql)"; - $db->sql_query($sql); - $sql = ''; - } - } - - if ($sql != '') - { - $sql = "INSERT INTO $table ($id_field, forum_id, auth_option_id, auth_setting) $sql"; - $db->sql_query($sql); - } - break; - - case 'update': - case 'delete': - foreach ($sql_subary as $sql) - { - $db->sql_query($sql); - $sql = ''; - } - break; - } - unset($sql_ary[$sql_type]); - } - unset($sql_ary); - -} - -/** -* Update the count of unread private messages for all users -*/ -function update_unread_count() -{ - global $db; - - $sql = 'SELECT user_id, COUNT(msg_id) as num_messages - FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE pm_unread = 1 - AND folder_id <> ' . PRIVMSGS_OUTBOX . ' - GROUP BY user_id'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $db->sql_query('UPDATE ' . USERS_TABLE . ' SET user_unread_privmsg = ' . $row['num_messages'] . ' - WHERE user_id = ' . $row['user_id']); - } - $db->sql_freeresult($result); -} - -/** -* Add any of the pre-defined "special" groups which are missing from the database -*/ -function add_default_groups() -{ - global $db; - - $default_groups = array( - 'GUESTS' => array('', 0, 0), - 'REGISTERED' => array('', 0, 0), - 'REGISTERED_COPPA' => array('', 0, 0), - 'GLOBAL_MODERATORS' => array('00AA00', 2, 0), - 'ADMINISTRATORS' => array('AA0000', 1, 1), - 'BOTS' => array('9E8DA7', 0, 0), - 'NEWLY_REGISTERED' => array('', 0, 0), - ); - - $sql = 'SELECT * - FROM ' . GROUPS_TABLE . ' - WHERE ' . $db->sql_in_set('group_name', array_keys($default_groups)); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - unset($default_groups[strtoupper($row['group_name'])]); - } - $db->sql_freeresult($result); - - $sql_ary = array(); - - foreach ($default_groups as $name => $data) - { - $sql_ary[] = array( - 'group_name' => (string) $name, - 'group_desc' => '', - 'group_desc_uid' => '', - 'group_desc_bitfield' => '', - 'group_type' => GROUP_SPECIAL, - 'group_colour' => (string) $data[0], - 'group_legend' => (int) $data[1], - 'group_founder_manage' => (int) $data[2], - ); - } - - if (count($sql_ary)) - { - $db->sql_multi_insert(GROUPS_TABLE, $sql_ary); - } -} - -function add_groups_to_teampage() -{ - global $db; - - $teampage_groups = array( - 'ADMINISTRATORS' => 1, - 'GLOBAL_MODERATORS' => 2, - ); - - $sql = 'SELECT * - FROM ' . GROUPS_TABLE . ' - WHERE ' . $db->sql_in_set('group_name', array_keys($teampage_groups)); - $result = $db->sql_query($sql); - - $teampage_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - $teampage_ary[] = array( - 'group_id' => (int) $row['group_id'], - 'teampage_name' => '', - 'teampage_position' => (int) $teampage_groups[$row['group_name']], - 'teampage_parent' => 0, - ); - } - $db->sql_freeresult($result); - - if (count($teampage_ary)) - { - $db->sql_multi_insert(TEAMPAGE_TABLE, $teampage_ary); - } -} - - -/** -* Sync post count. We might need to do this in batches. -*/ -function sync_post_count($offset, $limit) -{ - global $db; - $sql = 'SELECT COUNT(post_id) AS num_posts, poster_id - FROM ' . POSTS_TABLE . ' - WHERE post_postcount = 1 - AND post_visibility = ' . ITEM_APPROVED . ' - GROUP BY poster_id - ORDER BY poster_id'; - $result = $db->sql_query_limit($sql, $limit, $offset); - - while ($row = $db->sql_fetchrow($result)) - { - $db->sql_query('UPDATE ' . USERS_TABLE . " SET user_posts = {$row['num_posts']} WHERE user_id = {$row['poster_id']}"); - } - $db->sql_freeresult($result); -} - -/** -* Add the search bots into the database -* This code should be used in execute_last if the source database did not have bots -* If you are converting bots this function should not be called -* @todo We might want to look at sharing the bot list between the install code and this code for consistancy -*/ -function add_bots() -{ - global $db, $convert, $user, $config, $phpbb_root_path, $phpEx; - - $db->sql_query($convert->truncate_statement . BOTS_TABLE); - - $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . " WHERE group_name = 'BOTS'"; - $result = $db->sql_query($sql); - $group_id = (int) $db->sql_fetchfield('group_id', false, $result); - $db->sql_freeresult($result); - - if (!$group_id) - { - add_default_groups(); - - $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . " WHERE group_name = 'BOTS'"; - $result = $db->sql_query($sql); - $group_id = (int) $db->sql_fetchfield('group_id', false, $result); - $db->sql_freeresult($result); - - if (!$group_id) - { - global $install; - $install->error($user->lang['CONV_ERROR_INCONSISTENT_GROUPS'], __LINE__, __FILE__); - } - } - - $bots = array( - 'AdsBot [Google]' => array('AdsBot-Google', ''), - 'Alexa [Bot]' => array('ia_archiver', ''), - 'Alta Vista [Bot]' => array('Scooter/', ''), - 'Ask Jeeves [Bot]' => array('Ask Jeeves', ''), - 'Baidu [Spider]' => array('Baiduspider+(', ''), - 'Bing [Bot]' => array('bingbot/', ''), - 'Exabot [Bot]' => array('Exabot/', ''), - 'FAST Enterprise [Crawler]' => array('FAST Enterprise Crawler', ''), - 'FAST WebCrawler [Crawler]' => array('FAST-WebCrawler/', ''), - 'Francis [Bot]' => array('http://www.neomo.de/', ''), - 'Gigabot [Bot]' => array('Gigabot/', ''), - 'Google Adsense [Bot]' => array('Mediapartners-Google', ''), - 'Google Desktop' => array('Google Desktop', ''), - 'Google Feedfetcher' => array('Feedfetcher-Google', ''), - 'Google [Bot]' => array('Googlebot', ''), - 'Heise IT-Markt [Crawler]' => array('heise-IT-Markt-Crawler', ''), - 'Heritrix [Crawler]' => array('heritrix/1.', ''), - 'IBM Research [Bot]' => array('ibm.com/cs/crawler', ''), - 'ICCrawler - ICjobs' => array('ICCrawler - ICjobs', ''), - 'ichiro [Crawler]' => array('ichiro/2', ''), - 'Majestic-12 [Bot]' => array('MJ12bot/', ''), - 'Metager [Bot]' => array('MetagerBot/', ''), - 'MSN NewsBlogs' => array('msnbot-NewsBlogs/', ''), - 'MSN [Bot]' => array('msnbot/', ''), - 'MSNbot Media' => array('msnbot-media/', ''), - 'NG-Search [Bot]' => array('NG-Search/', ''), - 'Nutch [Bot]' => array('http://lucene.apache.org/nutch/', ''), - 'Nutch/CVS [Bot]' => array('NutchCVS/', ''), - 'OmniExplorer [Bot]' => array('OmniExplorer_Bot/', ''), - 'Online link [Validator]' => array('online link validator', ''), - 'psbot [Picsearch]' => array('psbot/0', ''), - 'Seekport [Bot]' => array('Seekbot/', ''), - 'Sensis [Crawler]' => array('Sensis Web Crawler', ''), - 'SEO Crawler' => array('SEO search Crawler/', ''), - 'Seoma [Crawler]' => array('Seoma [SEO Crawler]', ''), - 'SEOSearch [Crawler]' => array('SEOsearch/', ''), - 'Snappy [Bot]' => array('Snappy/1.1 ( http://www.urltrends.com/ )', ''), - 'Steeler [Crawler]' => array('http://www.tkl.iis.u-tokyo.ac.jp/~crawler/', ''), - 'Synoo [Bot]' => array('SynooBot/', ''), - 'Telekom [Bot]' => array('crawleradmin.t-info@telekom.de', ''), - 'TurnitinBot [Bot]' => array('TurnitinBot/', ''), - 'Voyager [Bot]' => array('voyager/1.0', ''), - 'W3 [Sitesearch]' => array('W3 SiteSearch Crawler', ''), - 'W3C [Linkcheck]' => array('W3C-checklink/', ''), - 'W3C [Validator]' => array('W3C_*Validator', ''), - 'WiseNut [Bot]' => array('http://www.WISEnutbot.com', ''), - 'YaCy [Bot]' => array('yacybot', ''), - 'Yahoo MMCrawler [Bot]' => array('Yahoo-MMCrawler/', ''), - 'Yahoo Slurp [Bot]' => array('Yahoo! DE Slurp', ''), - 'Yahoo [Bot]' => array('Yahoo! Slurp', ''), - 'YahooSeeker [Bot]' => array('YahooSeeker/', ''), - ); - - if (!function_exists('user_add')) - { - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - } - - foreach ($bots as $bot_name => $bot_ary) - { - $user_row = array( - 'user_type' => USER_IGNORE, - 'group_id' => $group_id, - 'username' => $bot_name, - 'user_regdate' => time(), - 'user_password' => '', - 'user_colour' => '9E8DA7', - 'user_email' => '', - 'user_lang' => $config['default_lang'], - 'user_style' => 1, - 'user_timezone' => 'UTC', - 'user_allow_massemail' => 0, - ); - - $user_id = user_add($user_row); - - if ($user_id) - { - $sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $db->sql_build_array('INSERT', array( - 'bot_active' => 1, - 'bot_name' => $bot_name, - 'user_id' => $user_id, - 'bot_agent' => $bot_ary[0], - 'bot_ip' => $bot_ary[1]) - ); - $db->sql_query($sql); - } - } -} - -/** -* Update any dynamic configuration variables after the conversion is finished -* @todo Confirm that this updates all relevant values since it has not necessarily been kept in sync with all changes -*/ -function update_dynamic_config() -{ - global $db, $config; - - // Get latest username - $sql = 'SELECT user_id, username, user_colour - FROM ' . USERS_TABLE . ' - WHERE user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')'; - - if (!empty($config['increment_user_id'])) - { - $sql .= ' AND user_id <> ' . $config['increment_user_id']; - } - - $sql .= ' ORDER BY user_id DESC'; - - $result = $db->sql_query_limit($sql, 1); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - $config->set('newest_user_id', $row['user_id'], false); - $config->set('newest_username', $row['username'], false); - $config->set('newest_user_colour', $row['user_colour'], false); - } - -// Also do not reset record online user/date. There will be old data or the fresh data from the schema. -// set_config('record_online_users', 1, true); -// set_config('record_online_date', time(), true); - - $sql = 'SELECT COUNT(post_id) AS stat - FROM ' . POSTS_TABLE . ' - WHERE post_visibility = ' . ITEM_APPROVED; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $config->set('num_posts', (int) $row['stat'], false); - - $sql = 'SELECT COUNT(topic_id) AS stat - FROM ' . TOPICS_TABLE . ' - WHERE topic_visibility = ' . ITEM_APPROVED; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $config->set('num_topics', (int) $row['stat'], false); - - $sql = 'SELECT COUNT(user_id) AS stat - FROM ' . USERS_TABLE . ' - WHERE user_type IN (' . USER_NORMAL . ',' . USER_FOUNDER . ')'; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $config->set('num_users', (int) $row['stat'], false); - - $sql = 'SELECT COUNT(attach_id) as stat - FROM ' . ATTACHMENTS_TABLE . ' - WHERE is_orphan = 0'; - $result = $db->sql_query($sql); - $config->set('num_files', (int) $db->sql_fetchfield('stat'), false); - $db->sql_freeresult($result); - - $sql = 'SELECT SUM(filesize) as stat - FROM ' . ATTACHMENTS_TABLE . ' - WHERE is_orphan = 0'; - $result = $db->sql_query($sql); - $config->set('upload_dir_size', (float) $db->sql_fetchfield('stat'), false); - $db->sql_freeresult($result); - - /** - * We do not resync users post counts - this can be done by the admin after conversion if wanted. - $sql = 'SELECT COUNT(post_id) AS num_posts, poster_id - FROM ' . POSTS_TABLE . ' - WHERE post_postcount = 1 - GROUP BY poster_id'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $db->sql_query('UPDATE ' . USERS_TABLE . " SET user_posts = {$row['num_posts']} WHERE user_id = {$row['poster_id']}"); - } - $db->sql_freeresult($result); - */ -} - -/** -* Updates topics_posted entries -*/ -function update_topics_posted() -{ - global $db; - - switch ($db->get_sql_layer()) - { - case 'sqlite3': - $db->sql_query('DELETE FROM ' . TOPICS_POSTED_TABLE); - break; - - default: - $db->sql_query('TRUNCATE TABLE ' . TOPICS_POSTED_TABLE); - break; - } - - // This can get really nasty... therefore we only do the last six months - $get_from_time = time() - (6 * 4 * 7 * 24 * 60 * 60); - - // Select forum ids, do not include categories - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE . ' - WHERE forum_type <> ' . FORUM_CAT; - $result = $db->sql_query($sql); - - $forum_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $forum_ids[] = $row['forum_id']; - } - $db->sql_freeresult($result); - - // Any global announcements? ;) - $forum_ids[] = 0; - - // Now go through the forums and get us some topics... - foreach ($forum_ids as $forum_id) - { - $sql = 'SELECT p.poster_id, p.topic_id - FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t - WHERE t.forum_id = ' . $forum_id . ' - AND t.topic_moved_id = 0 - AND t.topic_last_post_time > ' . $get_from_time . ' - AND t.topic_id = p.topic_id - AND p.poster_id <> ' . ANONYMOUS . ' - GROUP BY p.poster_id, p.topic_id'; - $result = $db->sql_query($sql); - - $posted = array(); - while ($row = $db->sql_fetchrow($result)) - { - $posted[$row['poster_id']][] = $row['topic_id']; - } - $db->sql_freeresult($result); - - $sql_ary = array(); - foreach ($posted as $user_id => $topic_row) - { - foreach ($topic_row as $topic_id) - { - $sql_ary[] = array( - 'user_id' => (int) $user_id, - 'topic_id' => (int) $topic_id, - 'topic_posted' => 1, - ); - } - } - unset($posted); - - if (count($sql_ary)) - { - $db->sql_multi_insert(TOPICS_POSTED_TABLE, $sql_ary); - } - } -} - -/** -* Ensure that all users have a default group specified and update related information such as their colour -*/ -function fix_empty_primary_groups() -{ - global $db; - - // Set group ids for users not already having it - $sql = 'UPDATE ' . USERS_TABLE . ' SET group_id = ' . get_group_id('registered') . ' - WHERE group_id = 0 AND user_type = ' . USER_INACTIVE; - $db->sql_query($sql); - - $sql = 'UPDATE ' . USERS_TABLE . ' SET group_id = ' . get_group_id('registered') . ' - WHERE group_id = 0 AND user_type = ' . USER_NORMAL; - $db->sql_query($sql); - - $db->sql_query('UPDATE ' . USERS_TABLE . ' SET group_id = ' . get_group_id('guests') . ' WHERE user_id = ' . ANONYMOUS); - - $sql = 'SELECT user_id FROM ' . USER_GROUP_TABLE . ' WHERE group_id = ' . get_group_id('administrators'); - $result = $db->sql_query($sql); - - $user_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $user_ids[] = $row['user_id']; - } - $db->sql_freeresult($result); - - if (count($user_ids)) - { - $db->sql_query('UPDATE ' . USERS_TABLE . ' SET group_id = ' . get_group_id('administrators') . ' - WHERE group_id = 0 AND ' . $db->sql_in_set('user_id', $user_ids)); - } - - $sql = 'SELECT user_id FROM ' . USER_GROUP_TABLE . ' WHERE group_id = ' . get_group_id('global_moderators'); - $result = $db->sql_query($sql); - - $user_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $user_ids[] = $row['user_id']; - } - $db->sql_freeresult($result); - - if (count($user_ids)) - { - $db->sql_query('UPDATE ' . USERS_TABLE . ' SET group_id = ' . get_group_id('global_moderators') . ' - WHERE group_id = 0 AND ' . $db->sql_in_set('user_id', $user_ids)); - } - - // Set user colour - $sql = 'SELECT group_id, group_colour FROM ' . GROUPS_TABLE . " - WHERE group_colour <> ''"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $db->sql_query('UPDATE ' . USERS_TABLE . " SET user_colour = '{$row['group_colour']}' WHERE group_id = {$row['group_id']}"); - } - $db->sql_freeresult($result); -} - -/** -* Cleanly remove invalid user entries after converting the users table... -*/ -function remove_invalid_users() -{ - global $db, $phpEx, $phpbb_root_path; - - // username_clean is UNIQUE - $sql = 'SELECT user_id - FROM ' . USERS_TABLE . " - WHERE username_clean = ''"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - if (!function_exists('user_delete')) - { - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - } - - user_delete('remove', $row['user_id']); - } -} - -function convert_bbcode($message, $convert_size = true, $extended_bbcodes = false) -{ - static $orig, $repl, $origx, $replx, $str_from, $str_to; - - if (empty($orig)) - { - $orig = $repl = array(); - - $orig[] = '#\[(php|sql)\](.*?)\[/(php|sql)\]#is'; - $repl[] = '[code]\2[/code]'; - - $orig[] = '#\[font=[^\]]+\](.*?)\[/font\]#is'; - $repl[] = '\1'; - - $orig[] = '#\[align=[a-z]+\](.*?)\[/align\]#is'; - $repl[] = '\1'; - - $orig[] = '#\[/list=.*?\]#is'; - $repl[] = '[/list]'; - - $origx = array( - '#\[glow[^\]]+\](.*?)\[/glow\]#is', - '#\[shadow[^\]]+\](.*?)\[/shadow\]#is', - '#\[flash[^\]]+\](.*?)\[/flash\]#is' - ); - - $replx = array( - '\1', - '\1', - '[url=\1]Flash[/url]' - ); - - $str_from = array( - '[ftp]', '[/ftp]', - '[ftp=', '[/ftp]', - '[pre]', '[/pre]', - '[table]', '[/table]', - '[td]', '[/td]', - '[tr]', '[/tr]', - '[s]', '[/s]', - '[left]', '[/left]', - '[right]', '[/right]', - '[center]', '[/center]', - '[sub]', '[/sub]', - '[sup]', '[/sup]', - '[tt]', '[/tt]', - '[move]', '[/move]', - '[hr]' - ); - - $str_to = array( - '[url]', '[/url]', - '[url=', '[/url]', - '[code]', '[/code]', - "\n", '', - '', '', - "\n", '', - '', '', - '', '', - '', '', - '', '', - '', '', - '', '', - '', '', - '', '', - "\n\n" - ); - - for ($i = 0, $end = count($str_from); $i < $end; ++$i) - { - $origx[] = '#\\' . str_replace(']', '\\]', $str_from[$i]) . '#is'; - $replx[] = $str_to[$i]; - } - } - - if (preg_match_all('#\[email=([^\]]+)\](.*?)\[/email\]#i', $message, $m)) - { - for ($i = 0, $end = count($m[1]); $i < $end; ++$i) - { - if ($m[1][$i] == $m[2][$i]) - { - $message = str_replace($m[0][$i], '[email]' . $m[1][$i] . '[/email]', $message); - } - else - { - $message = str_replace($m[0][$i], $m[2][$i] . ' ([email]' . $m[1][$i] . '[/email])', $message); - } - } - } - - if ($convert_size && preg_match('#\[size=[0-9]+\].*?\[/size\]#i', $message)) - { - $size = array(9, 9, 12, 15, 18, 24, 29, 29, 29, 29); - $message = preg_replace('#\[size=([0-9]+)\](.*?)\[/size\]#i', '[size=\1]\2[/size]', $message); - $message = preg_replace('#\[size=[0-9]{2,}\](.*?)\[/size\]#i', '[size=29]\1[/size]', $message); - - for ($i = count($size); $i;) - { - $i--; - $message = str_replace('[size=' . $i . ']', '[size=' . $size[$i] . ']', $message); - } - } - - if ($extended_bbcodes) - { - $message = preg_replace($origx, $replx, $message); - } - - $message = preg_replace($orig, $repl, $message); - return $message; -} - - -function copy_file($src, $trg, $overwrite = false, $die_on_failure = true, $source_relative_path = true) -{ - global $convert, $phpbb_root_path, $user, $phpbb_filesystem; - - /** @var \phpbb\filesystem\filesystem_interface $filesystem */ - $filesystem = $phpbb_filesystem; - - if (substr($trg, -1) == '/') - { - $trg .= utf8_basename($src); - } - $src_path = relative_base($src, $source_relative_path, __LINE__, __FILE__); - $trg_path = $trg; - - if (!$overwrite && @file_exists($trg_path)) - { - return true; - } - - if (!@file_exists($src_path)) - { - return; - } - - $path = $phpbb_root_path; - $parts = explode('/', $trg); - unset($parts[count($parts) - 1]); - - for ($i = 0, $end = count($parts); $i < $end; ++$i) - { - $path .= $parts[$i] . '/'; - - if (!is_dir($path)) - { - @mkdir($path, 0777); - } - } - - if (!$filesystem->is_writable($path)) - { - @chmod($path, 0777); - } - - if (!@copy($src_path, $phpbb_root_path . $trg_path)) - { - $convert->p_master->error(sprintf($user->lang['COULD_NOT_COPY'], $src_path, $phpbb_root_path . $trg_path), __LINE__, __FILE__, !$die_on_failure); - return; - } - - if ($perm = @fileperms($src_path)) - { - @chmod($phpbb_root_path . $trg_path, $perm); - } - - return true; -} - -function copy_dir($src, $trg, $copy_subdirs = true, $overwrite = false, $die_on_failure = true, $source_relative_path = true) -{ - global $convert, $phpbb_root_path, $config, $user, $phpbb_filesystem; - - /** @var \phpbb\filesystem\filesystem_interface $filesystem */ - $filesystem = $phpbb_filesystem; - - $dirlist = $filelist = $bad_dirs = array(); - $src = path($src, $source_relative_path); - $trg = path($trg); - $src_path = relative_base($src, $source_relative_path, __LINE__, __FILE__); - $trg_path = $phpbb_root_path . $trg; - - if (!is_dir($trg_path)) - { - @mkdir($trg_path, 0777); - @chmod($trg_path, 0777); - } - - if (!$filesystem->is_writable($trg_path)) - { - $bad_dirs[] = path($config['script_path']) . $trg; - } - - if ($handle = @opendir($src_path)) - { - while ($entry = readdir($handle)) - { - if ($entry[0] == '.' || $entry == 'CVS' || $entry == 'index.htm') - { - continue; - } - - if (is_dir($src_path . $entry)) - { - $dirlist[] = $entry; - } - else - { - $filelist[] = $entry; - } - } - closedir($handle); - } - else if ($dir = @dir($src_path)) - { - while ($entry = $dir->read()) - { - if ($entry[0] == '.' || $entry == 'CVS' || $entry == 'index.htm') - { - continue; - } - - if (is_dir($src_path . $entry)) - { - $dirlist[] = $entry; - } - else - { - $filelist[] = $entry; - } - } - $dir->close(); - } - else - { - $convert->p_master->error(sprintf($user->lang['CONV_ERROR_COULD_NOT_READ'], relative_base($src, $source_relative_path)), __LINE__, __FILE__); - } - - if ($copy_subdirs) - { - for ($i = 0, $end = count($dirlist); $i < $end; ++$i) - { - $dir = $dirlist[$i]; - - if ($dir == 'CVS') - { - continue; - } - - if (!is_dir($trg_path . $dir)) - { - @mkdir($trg_path . $dir, 0777); - @chmod($trg_path . $dir, 0777); - } - - if (!$filesystem->is_writable($trg_path . $dir)) - { - $bad_dirs[] = $trg . $dir; - $bad_dirs[] = $trg_path . $dir; - } - - if (!count($bad_dirs)) - { - copy_dir($src . $dir, $trg . $dir, true, $overwrite, $die_on_failure, $source_relative_path); - } - } - } - - if (count($bad_dirs)) - { - $str = (count($bad_dirs) == 1) ? $user->lang['MAKE_FOLDER_WRITABLE'] : $user->lang['MAKE_FOLDERS_WRITABLE']; - sort($bad_dirs); - $convert->p_master->error(sprintf($str, implode('
', $bad_dirs)), __LINE__, __FILE__); - } - - for ($i = 0, $end = count($filelist); $i < $end; ++$i) - { - copy_file($src . $filelist[$i], $trg . $filelist[$i], $overwrite, $die_on_failure, $source_relative_path); - } -} - -function relative_base($path, $is_relative = true, $line = false, $file = false) -{ - global $convert, $user; - - if (!$is_relative) - { - return $path; - } - - if (empty($convert->options['forum_path']) && $is_relative) - { - $line = $line ? $line : __LINE__; - $file = $file ? $file : __FILE__; - - $convert->p_master->error($user->lang['CONV_ERROR_NO_FORUM_PATH'], $line, $file); - } - - return $convert->options['forum_path'] . '/' . $path; -} - -function get_smiley_display() -{ - static $smiley_count = 0; - $smiley_count++; - return ($smiley_count < 50) ? 1 : 0; -} - - -function fill_dateformat($user_dateformat) -{ - global $config; - - return ((empty($user_dateformat)) ? $config['default_dateformat'] : $user_dateformat); -} diff --git a/install/update/old/includes/functions_display.php b/install/update/old/includes/functions_display.php deleted file mode 100644 index 7924670..0000000 --- a/install/update/old/includes/functions_display.php +++ /dev/null @@ -1,1733 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* Display Forums -*/ -function display_forums($root_data = '', $display_moderators = true, $return_moderators = false) -{ - global $db, $auth, $user, $template; - global $phpbb_root_path, $phpEx, $config; - global $request, $phpbb_dispatcher, $phpbb_container; - - $forum_rows = $subforums = $forum_ids = $forum_ids_moderator = $forum_moderators = $active_forum_ary = array(); - $parent_id = $visible_forums = 0; - - // Mark forums read? - $mark_read = $request->variable('mark', ''); - - if ($mark_read == 'all') - { - $mark_read = ''; - } - - if (!$root_data) - { - if ($mark_read == 'forums') - { - $mark_read = 'all'; - } - - $root_data = array('forum_id' => 0); - $sql_where = ''; - } - else - { - $sql_where = 'left_id > ' . $root_data['left_id'] . ' AND left_id < ' . $root_data['right_id']; - } - - // Handle marking everything read - if ($mark_read == 'all') - { - $redirect = build_url(array('mark', 'hash', 'mark_time')); - meta_refresh(3, $redirect); - - if (check_link_hash($request->variable('hash', ''), 'global')) - { - markread('all', false, false, $request->variable('mark_time', 0)); - - if ($request->is_ajax()) - { - // Tell the ajax script what language vars and URL need to be replaced - $data = array( - 'NO_UNREAD_POSTS' => $user->lang['NO_UNREAD_POSTS'], - 'UNREAD_POSTS' => $user->lang['UNREAD_POSTS'], - 'U_MARK_FORUMS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}index.$phpEx", 'hash=' . generate_link_hash('global') . '&mark=forums&mark_time=' . time()) : '', - 'MESSAGE_TITLE' => $user->lang['INFORMATION'], - 'MESSAGE_TEXT' => $user->lang['FORUMS_MARKED'] - ); - $json_response = new \phpbb\json_response(); - $json_response->send($data); - } - - trigger_error( - $user->lang['FORUMS_MARKED'] . '

' . - sprintf($user->lang['RETURN_INDEX'], '', '') - ); - } - else - { - trigger_error(sprintf($user->lang['RETURN_PAGE'], '', '')); - } - } - - // Display list of active topics for this category? - $show_active = (isset($root_data['forum_flags']) && ($root_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS)) ? true : false; - - $sql_array = array( - 'SELECT' => 'f.*', - 'FROM' => array( - FORUMS_TABLE => 'f' - ), - 'LEFT_JOIN' => array(), - ); - - if ($config['load_db_lastread'] && $user->data['is_registered']) - { - $sql_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TRACK_TABLE => 'ft'), 'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND ft.forum_id = f.forum_id'); - $sql_array['SELECT'] .= ', ft.mark_time'; - } - else if ($config['load_anon_lastread'] || $user->data['is_registered']) - { - $tracking_topics = $request->variable($config['cookie_name'] . '_track', '', true, \phpbb\request\request_interface::COOKIE); - $tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array(); - - if (!$user->data['is_registered']) - { - $user->data['user_lastmark'] = (isset($tracking_topics['l'])) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0; - } - } - - if ($show_active) - { - $sql_array['LEFT_JOIN'][] = array( - 'FROM' => array(FORUMS_ACCESS_TABLE => 'fa'), - 'ON' => "fa.forum_id = f.forum_id AND fa.session_id = '" . $db->sql_escape($user->session_id) . "'" - ); - - $sql_array['SELECT'] .= ', fa.user_id'; - } - - $sql_ary = array( - 'SELECT' => $sql_array['SELECT'], - 'FROM' => $sql_array['FROM'], - 'LEFT_JOIN' => $sql_array['LEFT_JOIN'], - - 'WHERE' => $sql_where, - - 'ORDER_BY' => 'f.left_id', - ); - - /** - * Event to modify the SQL query before the forum data is queried - * - * @event core.display_forums_modify_sql - * @var array sql_ary The SQL array to get the data of the forums - * @since 3.1.0-a1 - */ - $vars = array('sql_ary'); - extract($phpbb_dispatcher->trigger_event('core.display_forums_modify_sql', compact($vars))); - - $sql = $db->sql_build_query('SELECT', $sql_ary); - $result = $db->sql_query($sql); - - $forum_tracking_info = $valid_categories = array(); - $branch_root_id = $root_data['forum_id']; - - /* @var $phpbb_content_visibility \phpbb\content_visibility */ - $phpbb_content_visibility = $phpbb_container->get('content.visibility'); - - while ($row = $db->sql_fetchrow($result)) - { - /** - * Event to modify the data set of a forum - * - * This event is triggered once per forum - * - * @event core.display_forums_modify_row - * @var int branch_root_id Last top-level forum - * @var array row The data of the forum - * @since 3.1.0-a1 - */ - $vars = array('branch_root_id', 'row'); - extract($phpbb_dispatcher->trigger_event('core.display_forums_modify_row', compact($vars))); - - $forum_id = $row['forum_id']; - - // Mark forums read? - if ($mark_read == 'forums') - { - if ($auth->acl_get('f_list', $forum_id)) - { - $forum_ids[] = $forum_id; - } - - continue; - } - - // Category with no members - if ($row['forum_type'] == FORUM_CAT && ($row['left_id'] + 1 == $row['right_id'])) - { - continue; - } - - // Skip branch - if (isset($right_id)) - { - if ($row['left_id'] < $right_id) - { - continue; - } - unset($right_id); - } - - if (!$auth->acl_get('f_list', $forum_id)) - { - // if the user does not have permissions to list this forum, skip everything until next branch - $right_id = $row['right_id']; - continue; - } - - if ($config['load_db_lastread'] && $user->data['is_registered']) - { - $forum_tracking_info[$forum_id] = (!empty($row['mark_time'])) ? $row['mark_time'] : $user->data['user_lastmark']; - } - else if ($config['load_anon_lastread'] || $user->data['is_registered']) - { - if (!$user->data['is_registered']) - { - $user->data['user_lastmark'] = (isset($tracking_topics['l'])) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0; - } - $forum_tracking_info[$forum_id] = (isset($tracking_topics['f'][$forum_id])) ? (int) (base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate']) : $user->data['user_lastmark']; - } - - // Lets check whether there are unapproved topics/posts, so we can display an information to moderators - $row['forum_id_unapproved_topics'] = ($auth->acl_get('m_approve', $forum_id) && $row['forum_topics_unapproved']) ? $forum_id : 0; - $row['forum_id_unapproved_posts'] = ($auth->acl_get('m_approve', $forum_id) && $row['forum_posts_unapproved']) ? $forum_id : 0; - $row['forum_posts'] = $phpbb_content_visibility->get_count('forum_posts', $row, $forum_id); - $row['forum_topics'] = $phpbb_content_visibility->get_count('forum_topics', $row, $forum_id); - - // Display active topics from this forum? - if ($show_active && $row['forum_type'] == FORUM_POST && $auth->acl_get('f_read', $forum_id) && ($row['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS)) - { - if (!isset($active_forum_ary['forum_topics'])) - { - $active_forum_ary['forum_topics'] = 0; - } - - if (!isset($active_forum_ary['forum_posts'])) - { - $active_forum_ary['forum_posts'] = 0; - } - - $active_forum_ary['forum_id'][] = $forum_id; - $active_forum_ary['enable_icons'][] = $row['enable_icons']; - $active_forum_ary['forum_topics'] += $row['forum_topics']; - $active_forum_ary['forum_posts'] += $row['forum_posts']; - - // If this is a passworded forum we do not show active topics from it if the user is not authorised to view it... - if ($row['forum_password'] && $row['user_id'] != $user->data['user_id']) - { - $active_forum_ary['exclude_forum_id'][] = $forum_id; - } - } - - // Fill list of categories with forums - if (isset($forum_rows[$row['parent_id']])) - { - $valid_categories[$row['parent_id']] = true; - } - - // - if ($row['parent_id'] == $root_data['forum_id'] || $row['parent_id'] == $branch_root_id) - { - if ($row['forum_type'] != FORUM_CAT) - { - $forum_ids_moderator[] = (int) $forum_id; - } - - // Direct child of current branch - $parent_id = $forum_id; - $forum_rows[$forum_id] = $row; - - if ($row['forum_type'] == FORUM_CAT && $row['parent_id'] == $root_data['forum_id']) - { - $branch_root_id = $forum_id; - } - $forum_rows[$parent_id]['forum_id_last_post'] = $row['forum_id']; - $forum_rows[$parent_id]['forum_password_last_post'] = $row['forum_password']; - $forum_rows[$parent_id]['orig_forum_last_post_time'] = $row['forum_last_post_time']; - } - else if ($row['forum_type'] != FORUM_CAT) - { - $subforums[$parent_id][$forum_id]['display'] = ($row['display_on_index']) ? true : false; - $subforums[$parent_id][$forum_id]['name'] = $row['forum_name']; - $subforums[$parent_id][$forum_id]['orig_forum_last_post_time'] = $row['forum_last_post_time']; - $subforums[$parent_id][$forum_id]['children'] = array(); - $subforums[$parent_id][$forum_id]['type'] = $row['forum_type']; - - if (isset($subforums[$parent_id][$row['parent_id']]) && !$row['display_on_index']) - { - $subforums[$parent_id][$row['parent_id']]['children'][] = $forum_id; - } - - if (!$forum_rows[$parent_id]['forum_id_unapproved_topics'] && $row['forum_id_unapproved_topics']) - { - $forum_rows[$parent_id]['forum_id_unapproved_topics'] = $forum_id; - } - - if (!$forum_rows[$parent_id]['forum_id_unapproved_posts'] && $row['forum_id_unapproved_posts']) - { - $forum_rows[$parent_id]['forum_id_unapproved_posts'] = $forum_id; - } - - $forum_rows[$parent_id]['forum_topics'] += $row['forum_topics']; - - // Do not list redirects in LINK Forums as Posts. - if ($row['forum_type'] != FORUM_LINK) - { - $forum_rows[$parent_id]['forum_posts'] += $row['forum_posts']; - } - - if ($row['forum_last_post_time'] > $forum_rows[$parent_id]['forum_last_post_time']) - { - $forum_rows[$parent_id]['forum_last_post_id'] = $row['forum_last_post_id']; - $forum_rows[$parent_id]['forum_last_post_subject'] = $row['forum_last_post_subject']; - $forum_rows[$parent_id]['forum_last_post_time'] = $row['forum_last_post_time']; - $forum_rows[$parent_id]['forum_last_poster_id'] = $row['forum_last_poster_id']; - $forum_rows[$parent_id]['forum_last_poster_name'] = $row['forum_last_poster_name']; - $forum_rows[$parent_id]['forum_last_poster_colour'] = $row['forum_last_poster_colour']; - $forum_rows[$parent_id]['forum_id_last_post'] = $forum_id; - $forum_rows[$parent_id]['forum_password_last_post'] = $row['forum_password']; - } - } - - /** - * Event to modify the forum rows data set - * - * This event is triggered once per forum - * - * @event core.display_forums_modify_forum_rows - * @var array forum_rows Data array of all forums we display - * @var array subforums Data array of all subforums we display - * @var int branch_root_id Current top-level forum - * @var int parent_id Current parent forum - * @var array row The data of the forum - * @since 3.1.0-a1 - */ - $vars = array('forum_rows', 'subforums', 'branch_root_id', 'parent_id', 'row'); - extract($phpbb_dispatcher->trigger_event('core.display_forums_modify_forum_rows', compact($vars))); - } - $db->sql_freeresult($result); - - // Handle marking posts - if ($mark_read == 'forums') - { - $redirect = build_url(array('mark', 'hash', 'mark_time')); - $token = $request->variable('hash', ''); - if (check_link_hash($token, 'global')) - { - markread('topics', $forum_ids, false, $request->variable('mark_time', 0)); - $message = sprintf($user->lang['RETURN_FORUM'], '', ''); - meta_refresh(3, $redirect); - - if ($request->is_ajax()) - { - // Tell the ajax script what language vars and URL need to be replaced - $data = array( - 'NO_UNREAD_POSTS' => $user->lang['NO_UNREAD_POSTS'], - 'UNREAD_POSTS' => $user->lang['UNREAD_POSTS'], - 'U_MARK_FORUMS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'hash=' . generate_link_hash('global') . '&f=' . $root_data['forum_id'] . '&mark=forums&mark_time=' . time()) : '', - 'MESSAGE_TITLE' => $user->lang['INFORMATION'], - 'MESSAGE_TEXT' => $user->lang['FORUMS_MARKED'] - ); - $json_response = new \phpbb\json_response(); - $json_response->send($data); - } - - trigger_error($user->lang['FORUMS_MARKED'] . '

' . $message); - } - else - { - $message = sprintf($user->lang['RETURN_PAGE'], '', ''); - meta_refresh(3, $redirect); - trigger_error($message); - } - - } - - // Grab moderators ... if necessary - if ($display_moderators) - { - if ($return_moderators) - { - $forum_ids_moderator[] = $root_data['forum_id']; - } - get_moderators($forum_moderators, $forum_ids_moderator); - } - - /** - * Event to perform additional actions before the forum list is being generated - * - * @event core.display_forums_before - * @var array active_forum_ary Array with forum data to display active topics - * @var bool display_moderators Flag indicating if we display forum moderators - * @var array forum_moderators Array with forum moderators list - * @var array forum_rows Data array of all forums we display - * @var bool return_moderators Flag indicating if moderators list should be returned - * @var array root_data Array with the root forum data - * @since 3.1.4-RC1 - */ - $vars = array( - 'active_forum_ary', - 'display_moderators', - 'forum_moderators', - 'forum_rows', - 'return_moderators', - 'root_data', - ); - extract($phpbb_dispatcher->trigger_event('core.display_forums_before', compact($vars))); - - // Used to tell whatever we have to create a dummy category or not. - $last_catless = true; - foreach ($forum_rows as $row) - { - // Category - if ($row['parent_id'] == $root_data['forum_id'] && $row['forum_type'] == FORUM_CAT) - { - // Do not display categories without any forums to display - if (!isset($valid_categories[$row['forum_id']])) - { - continue; - } - - $cat_row = array( - 'S_IS_CAT' => true, - 'FORUM_ID' => $row['forum_id'], - 'FORUM_NAME' => $row['forum_name'], - 'FORUM_DESC' => generate_text_for_display($row['forum_desc'], $row['forum_desc_uid'], $row['forum_desc_bitfield'], $row['forum_desc_options']), - 'FORUM_FOLDER_IMG' => '', - 'FORUM_FOLDER_IMG_SRC' => '', - 'FORUM_IMAGE' => ($row['forum_image']) ? '' . $user->lang['FORUM_CAT'] . '' : '', - 'FORUM_IMAGE_SRC' => ($row['forum_image']) ? $phpbb_root_path . $row['forum_image'] : '', - 'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']), - ); - - /** - * Modify the template data block of the 'category' - * - * This event is triggered once per 'category' - * - * @event core.display_forums_modify_category_template_vars - * @var array cat_row Template data of the 'category' - * @var bool last_catless The flag indicating whether the last forum had a parent category - * @var array root_data Array with the root forum data - * @var array row The data of the 'category' - * @since 3.1.0-RC4 - * @changed 3.1.7-RC1 Removed undefined catless variable - */ - $vars = array( - 'cat_row', - 'last_catless', - 'root_data', - 'row', - ); - extract($phpbb_dispatcher->trigger_event('core.display_forums_modify_category_template_vars', compact($vars))); - - $template->assign_block_vars('forumrow', $cat_row); - - continue; - } - - $visible_forums++; - $forum_id = $row['forum_id']; - - $forum_unread = (isset($forum_tracking_info[$forum_id]) && $row['orig_forum_last_post_time'] > $forum_tracking_info[$forum_id]) ? true : false; - - $folder_image = $folder_alt = $l_subforums = ''; - $subforums_list = array(); - - // Generate list of subforums if we need to - if (isset($subforums[$forum_id])) - { - foreach ($subforums[$forum_id] as $subforum_id => $subforum_row) - { - $subforum_unread = (isset($forum_tracking_info[$subforum_id]) && $subforum_row['orig_forum_last_post_time'] > $forum_tracking_info[$subforum_id]) ? true : false; - - if (!$subforum_unread && !empty($subforum_row['children'])) - { - foreach ($subforum_row['children'] as $child_id) - { - if (isset($forum_tracking_info[$child_id]) && $subforums[$forum_id][$child_id]['orig_forum_last_post_time'] > $forum_tracking_info[$child_id]) - { - // Once we found an unread child forum, we can drop out of this loop - $subforum_unread = true; - break; - } - } - } - - if ($subforum_row['display'] && $subforum_row['name']) - { - $subforums_list[] = array( - 'link' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $subforum_id), - 'name' => $subforum_row['name'], - 'unread' => $subforum_unread, - 'type' => $subforum_row['type'], - ); - } - else - { - unset($subforums[$forum_id][$subforum_id]); - } - - // If one subforum is unread the forum gets unread too... - if ($subforum_unread) - { - $forum_unread = true; - } - } - - $l_subforums = (count($subforums[$forum_id]) == 1) ? $user->lang['SUBFORUM'] : $user->lang['SUBFORUMS']; - $folder_image = ($forum_unread) ? 'forum_unread_subforum' : 'forum_read_subforum'; - } - else - { - switch ($row['forum_type']) - { - case FORUM_POST: - $folder_image = ($forum_unread) ? 'forum_unread' : 'forum_read'; - break; - - case FORUM_LINK: - $folder_image = 'forum_link'; - break; - } - } - - // Which folder should we display? - if ($row['forum_status'] == ITEM_LOCKED) - { - $folder_image = ($forum_unread) ? 'forum_unread_locked' : 'forum_read_locked'; - $folder_alt = 'FORUM_LOCKED'; - } - else - { - $folder_alt = ($forum_unread) ? 'UNREAD_POSTS' : 'NO_UNREAD_POSTS'; - } - - // Create last post link information, if appropriate - if ($row['forum_last_post_id']) - { - if ($row['forum_password_last_post'] === '' && $auth->acl_gets('f_read', 'f_list_topics', $row['forum_id_last_post'])) - { - $last_post_subject = censor_text($row['forum_last_post_subject']); - $last_post_subject_truncated = truncate_string($last_post_subject, 30, 255, false, $user->lang['ELLIPSIS']); - } - else - { - $last_post_subject = $last_post_subject_truncated = ''; - } - $last_post_time = $user->format_date($row['forum_last_post_time']); - $last_post_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id_last_post'] . '&p=' . $row['forum_last_post_id']) . '#p' . $row['forum_last_post_id']; - } - else - { - $last_post_subject = $last_post_time = $last_post_url = $last_post_subject_truncated = ''; - } - - // Output moderator listing ... if applicable - $l_moderator = $moderators_list = ''; - if ($display_moderators && !empty($forum_moderators[$forum_id])) - { - $l_moderator = (count($forum_moderators[$forum_id]) == 1) ? $user->lang['MODERATOR'] : $user->lang['MODERATORS']; - $moderators_list = implode($user->lang['COMMA_SEPARATOR'], $forum_moderators[$forum_id]); - } - - $l_post_click_count = ($row['forum_type'] == FORUM_LINK) ? 'CLICKS' : 'POSTS'; - $post_click_count = ($row['forum_type'] != FORUM_LINK || $row['forum_flags'] & FORUM_FLAG_LINK_TRACK) ? $row['forum_posts'] : ''; - - $s_subforums_list = $subforums_row = array(); - foreach ($subforums_list as $subforum) - { - $s_subforums_list[] = '' . $subforum['name'] . ''; - $subforums_row[] = array( - 'U_SUBFORUM' => $subforum['link'], - 'SUBFORUM_NAME' => $subforum['name'], - 'S_UNREAD' => $subforum['unread'], - 'IS_LINK' => $subforum['type'] == FORUM_LINK, - ); - } - $s_subforums_list = (string) implode($user->lang['COMMA_SEPARATOR'], $s_subforums_list); - $catless = ($row['parent_id'] == $root_data['forum_id']) ? true : false; - - if ($row['forum_type'] != FORUM_LINK) - { - $u_viewforum = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']); - } - else - { - // If the forum is a link and we count redirects we need to visit it - // If the forum is having a password or no read access we do not expose the link, but instead handle it in viewforum - if (($row['forum_flags'] & FORUM_FLAG_LINK_TRACK) || $row['forum_password'] || !$auth->acl_get('f_read', $forum_id)) - { - $u_viewforum = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']); - } - else - { - $u_viewforum = $row['forum_link']; - } - } - - $forum_row = array( - 'S_IS_CAT' => false, - 'S_NO_CAT' => $catless && !$last_catless, - 'S_IS_LINK' => ($row['forum_type'] == FORUM_LINK) ? true : false, - 'S_UNREAD_FORUM' => $forum_unread, - 'S_AUTH_READ' => $auth->acl_get('f_read', $row['forum_id']), - 'S_LOCKED_FORUM' => ($row['forum_status'] == ITEM_LOCKED) ? true : false, - 'S_LIST_SUBFORUMS' => ($row['display_subforum_list']) ? true : false, - 'S_SUBFORUMS' => (count($subforums_list)) ? true : false, - 'S_DISPLAY_SUBJECT' => ($last_post_subject !== '' && $config['display_last_subject']) ? true : false, - 'S_FEED_ENABLED' => ($config['feed_forum'] && !phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $row['forum_options']) && $row['forum_type'] == FORUM_POST) ? true : false, - - 'FORUM_ID' => $row['forum_id'], - 'FORUM_NAME' => $row['forum_name'], - 'FORUM_DESC' => generate_text_for_display($row['forum_desc'], $row['forum_desc_uid'], $row['forum_desc_bitfield'], $row['forum_desc_options']), - 'TOPICS' => $row['forum_topics'], - $l_post_click_count => $post_click_count, - 'FORUM_IMG_STYLE' => $folder_image, - 'FORUM_FOLDER_IMG' => $user->img($folder_image, $folder_alt), - 'FORUM_FOLDER_IMG_ALT' => isset($user->lang[$folder_alt]) ? $user->lang[$folder_alt] : '', - 'FORUM_IMAGE' => ($row['forum_image']) ? '' . $user->lang[$folder_alt] . '' : '', - 'FORUM_IMAGE_SRC' => ($row['forum_image']) ? $phpbb_root_path . $row['forum_image'] : '', - 'LAST_POST_SUBJECT' => $last_post_subject, - 'LAST_POST_SUBJECT_TRUNCATED' => $last_post_subject_truncated, - 'LAST_POST_TIME' => $last_post_time, - 'LAST_POSTER' => get_username_string('username', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']), - 'LAST_POSTER_COLOUR' => get_username_string('colour', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']), - 'LAST_POSTER_FULL' => get_username_string('full', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']), - 'MODERATORS' => $moderators_list, - 'SUBFORUMS' => $s_subforums_list, - - 'L_SUBFORUM_STR' => $l_subforums, - 'L_MODERATOR_STR' => $l_moderator, - - 'U_UNAPPROVED_TOPICS' => ($row['forum_id_unapproved_topics']) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=unapproved_topics&f=' . $row['forum_id_unapproved_topics']) : '', - 'U_UNAPPROVED_POSTS' => ($row['forum_id_unapproved_posts']) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=unapproved_posts&f=' . $row['forum_id_unapproved_posts']) : '', - 'U_VIEWFORUM' => $u_viewforum, - 'U_LAST_POSTER' => get_username_string('profile', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']), - 'U_LAST_POST' => $last_post_url, - ); - - /** - * Modify the template data block of the forum - * - * This event is triggered once per forum - * - * @event core.display_forums_modify_template_vars - * @var array forum_row Template data of the forum - * @var array row The data of the forum - * @var array subforums_row Template data of subforums - * @since 3.1.0-a1 - * @changed 3.1.0-b5 Added var subforums_row - */ - $vars = array('forum_row', 'row', 'subforums_row'); - extract($phpbb_dispatcher->trigger_event('core.display_forums_modify_template_vars', compact($vars))); - - $template->assign_block_vars('forumrow', $forum_row); - - // Assign subforums loop for style authors - $template->assign_block_vars_array('forumrow.subforum', $subforums_row); - - /** - * Modify and/or assign additional template data for the forum - * after forumrow loop has been assigned. This can be used - * to create additional forumrow subloops in extensions. - * - * This event is triggered once per forum - * - * @event core.display_forums_add_template_data - * @var array forum_row Template data of the forum - * @var array row The data of the forum - * @var array subforums_list The data of subforums - * @var array subforums_row Template data of subforums - * @var bool catless The flag indicating whether a forum has a parent category - * @since 3.1.0-b5 - */ - $vars = array( - 'forum_row', - 'row', - 'subforums_list', - 'subforums_row', - 'catless', - ); - extract($phpbb_dispatcher->trigger_event('core.display_forums_add_template_data', compact($vars))); - - $last_catless = $catless; - } - - $template->assign_vars(array( - 'U_MARK_FORUMS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'hash=' . generate_link_hash('global') . '&f=' . $root_data['forum_id'] . '&mark=forums&mark_time=' . time()) : '', - 'S_HAS_SUBFORUM' => ($visible_forums) ? true : false, - 'L_SUBFORUM' => ($visible_forums == 1) ? $user->lang['SUBFORUM'] : $user->lang['SUBFORUMS'], - 'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'), - 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'TOPICS_UNAPPROVED'), - 'UNAPPROVED_POST_IMG' => $user->img('icon_topic_unapproved', 'POSTS_UNAPPROVED_FORUM'), - )); - - /** - * Event to perform additional actions after the forum list has been generated - * - * @event core.display_forums_after - * @var array active_forum_ary Array with forum data to display active topics - * @var bool display_moderators Flag indicating if we display forum moderators - * @var array forum_moderators Array with forum moderators list - * @var array forum_rows Data array of all forums we display - * @var bool return_moderators Flag indicating if moderators list should be returned - * @var array root_data Array with the root forum data - * @since 3.1.0-RC5 - */ - $vars = array( - 'active_forum_ary', - 'display_moderators', - 'forum_moderators', - 'forum_rows', - 'return_moderators', - 'root_data', - ); - extract($phpbb_dispatcher->trigger_event('core.display_forums_after', compact($vars))); - - if ($return_moderators) - { - return array($active_forum_ary, $forum_moderators); - } - - return array($active_forum_ary, array()); -} - -/** -* Create forum rules for given forum -*/ -function generate_forum_rules(&$forum_data) -{ - if ($forum_data['forum_rules']) - { - $forum_data['forum_rules'] = generate_text_for_display($forum_data['forum_rules'], $forum_data['forum_rules_uid'], $forum_data['forum_rules_bitfield'], $forum_data['forum_rules_options']); - } - - if (!$forum_data['forum_rules'] && !$forum_data['forum_rules_link']) - { - return; - } - - global $template; - - $template->assign_vars(array( - 'S_FORUM_RULES' => true, - 'U_FORUM_RULES' => $forum_data['forum_rules_link'], - 'FORUM_RULES' => $forum_data['forum_rules']) - ); -} - -/** -* Create forum navigation links for given forum, create parent -* list if currently null, assign basic forum info to template -*/ -function generate_forum_nav(&$forum_data_ary) -{ - global $template, $auth, $config; - global $phpEx, $phpbb_root_path, $phpbb_dispatcher; - - if (!$auth->acl_get('f_list', $forum_data_ary['forum_id'])) - { - return; - } - - $navlinks_parents = $forum_template_data = array(); - - // Get forum parents - $forum_parents = get_forum_parents($forum_data_ary); - - $microdata_attr = 'data-forum-id'; - - // Build navigation links - if (!empty($forum_parents)) - { - foreach ($forum_parents as $parent_forum_id => $parent_data) - { - list($parent_name, $parent_type) = array_values($parent_data); - - // Skip this parent if the user does not have the permission to view it - if (!$auth->acl_get('f_list', $parent_forum_id)) - { - continue; - } - - $navlinks_parents[] = array( - 'S_IS_CAT' => ($parent_type == FORUM_CAT) ? true : false, - 'S_IS_LINK' => ($parent_type == FORUM_LINK) ? true : false, - 'S_IS_POST' => ($parent_type == FORUM_POST) ? true : false, - 'FORUM_NAME' => $parent_name, - 'FORUM_ID' => $parent_forum_id, - 'MICRODATA' => $microdata_attr . '="' . $parent_forum_id . '"', - 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $parent_forum_id), - ); - } - } - - $navlinks = array( - 'S_IS_CAT' => ($forum_data_ary['forum_type'] == FORUM_CAT) ? true : false, - 'S_IS_LINK' => ($forum_data_ary['forum_type'] == FORUM_LINK) ? true : false, - 'S_IS_POST' => ($forum_data_ary['forum_type'] == FORUM_POST) ? true : false, - 'FORUM_NAME' => $forum_data_ary['forum_name'], - 'FORUM_ID' => $forum_data_ary['forum_id'], - 'MICRODATA' => $microdata_attr . '="' . $forum_data_ary['forum_id'] . '"', - 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_data_ary['forum_id']), - ); - - $forum_template_data = array( - 'FORUM_ID' => $forum_data_ary['forum_id'], - 'FORUM_NAME' => $forum_data_ary['forum_name'], - 'FORUM_DESC' => generate_text_for_display($forum_data_ary['forum_desc'], $forum_data_ary['forum_desc_uid'], $forum_data_ary['forum_desc_bitfield'], $forum_data_ary['forum_desc_options']), - - 'S_ENABLE_FEEDS_FORUM' => ($config['feed_forum'] && $forum_data_ary['forum_type'] == FORUM_POST && !phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $forum_data_ary['forum_options'])) ? true : false, - ); - - $forum_data = $forum_data_ary; - /** - * Event to modify the navlinks text - * - * @event core.generate_forum_nav - * @var array forum_data Array with the forum data - * @var array forum_template_data Array with generic forum template data - * @var string microdata_attr The microdata attribute - * @var array navlinks_parents Array with the forum parents navlinks data - * @var array navlinks Array with the forum navlinks data - * @since 3.1.5-RC1 - */ - $vars = array( - 'forum_data', - 'forum_template_data', - 'microdata_attr', - 'navlinks_parents', - 'navlinks', - ); - extract($phpbb_dispatcher->trigger_event('core.generate_forum_nav', compact($vars))); - $forum_data_ary = $forum_data; - unset($forum_data); - - $template->assign_block_vars_array('navlinks', $navlinks_parents); - $template->assign_block_vars('navlinks', $navlinks); - $template->assign_vars($forum_template_data); - - return; -} - -/** -* Returns forum parents as an array. Get them from forum_data if available, or update the database otherwise -*/ -function get_forum_parents(&$forum_data) -{ - global $db; - - $forum_parents = array(); - - if ($forum_data['parent_id'] > 0) - { - if ($forum_data['forum_parents'] == '') - { - $sql = 'SELECT forum_id, forum_name, forum_type - FROM ' . FORUMS_TABLE . ' - WHERE left_id < ' . $forum_data['left_id'] . ' - AND right_id > ' . $forum_data['right_id'] . ' - ORDER BY left_id ASC'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $forum_parents[$row['forum_id']] = array($row['forum_name'], (int) $row['forum_type']); - } - $db->sql_freeresult($result); - - $forum_data['forum_parents'] = serialize($forum_parents); - - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET forum_parents = '" . $db->sql_escape($forum_data['forum_parents']) . "' - WHERE parent_id = " . $forum_data['parent_id']; - $db->sql_query($sql); - } - else - { - $forum_parents = unserialize($forum_data['forum_parents']); - } - } - - return $forum_parents; -} - -/** -* Obtain list of moderators of each forum -*/ -function get_moderators(&$forum_moderators, $forum_id = false) -{ - global $db, $phpbb_root_path, $phpEx, $user, $auth; - global $phpbb_container; - - $forum_id_ary = array(); - - if ($forum_id !== false) - { - if (!is_array($forum_id)) - { - $forum_id = array($forum_id); - } - - // Exchange key/value pair to be able to faster check for the forum id existence - $forum_id_ary = array_flip($forum_id); - } - - $sql_array = array( - 'SELECT' => 'm.*, u.user_colour, g.group_colour, g.group_type', - - 'FROM' => array( - MODERATOR_CACHE_TABLE => 'm', - ), - - 'LEFT_JOIN' => array( - array( - 'FROM' => array(USERS_TABLE => 'u'), - 'ON' => 'm.user_id = u.user_id', - ), - array( - 'FROM' => array(GROUPS_TABLE => 'g'), - 'ON' => 'm.group_id = g.group_id', - ), - ), - - 'WHERE' => 'm.display_on_index = 1', - ); - - /** @var \phpbb\group\helper $group_helper */ - $group_helper = $phpbb_container->get('group_helper'); - - // We query every forum here because for caching we should not have any parameter. - $sql = $db->sql_build_query('SELECT', $sql_array); - $result = $db->sql_query($sql, 3600); - - while ($row = $db->sql_fetchrow($result)) - { - $f_id = (int) $row['forum_id']; - - if (!isset($forum_id_ary[$f_id])) - { - continue; - } - - if (!empty($row['user_id'])) - { - $forum_moderators[$f_id][] = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']); - } - else - { - $group_name = $group_helper->get_name($row['group_name']); - - if ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')) - { - $forum_moderators[$f_id][] = '' . $group_name . ''; - } - else - { - $forum_moderators[$f_id][] = '' . $group_name . ''; - } - } - } - $db->sql_freeresult($result); - - return; -} - -/** -* User authorisation levels output -* -* @param string $mode Can be forum or topic. Not in use at the moment. -* @param int $forum_id The current forum the user is in. -* @param int $forum_status The forums status bit. -*/ -function gen_forum_auth_level($mode, $forum_id, $forum_status) -{ - global $template, $auth, $user, $config; - - $locked = ($forum_status == ITEM_LOCKED && !$auth->acl_get('m_edit', $forum_id)) ? true : false; - - $rules = array( - ($auth->acl_get('f_post', $forum_id) && !$locked) ? $user->lang['RULES_POST_CAN'] : $user->lang['RULES_POST_CANNOT'], - ($auth->acl_get('f_reply', $forum_id) && !$locked) ? $user->lang['RULES_REPLY_CAN'] : $user->lang['RULES_REPLY_CANNOT'], - ($user->data['is_registered'] && $auth->acl_gets('f_edit', 'm_edit', $forum_id) && !$locked) ? $user->lang['RULES_EDIT_CAN'] : $user->lang['RULES_EDIT_CANNOT'], - ($user->data['is_registered'] && ($auth->acl_gets('f_delete', 'm_delete', $forum_id) || $auth->acl_gets('f_softdelete', 'm_softdelete', $forum_id)) && !$locked) ? $user->lang['RULES_DELETE_CAN'] : $user->lang['RULES_DELETE_CANNOT'], - ); - - if ($config['allow_attachments']) - { - $rules[] = ($auth->acl_get('f_attach', $forum_id) && $auth->acl_get('u_attach') && !$locked) ? $user->lang['RULES_ATTACH_CAN'] : $user->lang['RULES_ATTACH_CANNOT']; - } - - foreach ($rules as $rule) - { - $template->assign_block_vars('rules', array('RULE' => $rule)); - } - - return; -} - -/** -* Generate topic status -*/ -function topic_status(&$topic_row, $replies, $unread_topic, &$folder_img, &$folder_alt, &$topic_type) -{ - global $user, $config; - - if ($topic_row['topic_status'] == ITEM_MOVED) - { - $topic_type = $user->lang['VIEW_TOPIC_MOVED']; - $folder_img = 'topic_moved'; - $folder_alt = 'TOPIC_MOVED'; - } - else - { - switch ($topic_row['topic_type']) - { - case POST_GLOBAL: - $topic_type = $user->lang['VIEW_TOPIC_GLOBAL']; - $folder = 'global_read'; - $folder_new = 'global_unread'; - break; - - case POST_ANNOUNCE: - $topic_type = $user->lang['VIEW_TOPIC_ANNOUNCEMENT']; - $folder = 'announce_read'; - $folder_new = 'announce_unread'; - break; - - case POST_STICKY: - $topic_type = $user->lang['VIEW_TOPIC_STICKY']; - $folder = 'sticky_read'; - $folder_new = 'sticky_unread'; - break; - - default: - $topic_type = ''; - $folder = 'topic_read'; - $folder_new = 'topic_unread'; - - // Hot topic threshold is for posts in a topic, which is replies + the first post. ;) - if ($config['hot_threshold'] && ($replies + 1) >= $config['hot_threshold'] && $topic_row['topic_status'] != ITEM_LOCKED) - { - $folder .= '_hot'; - $folder_new .= '_hot'; - } - break; - } - - if ($topic_row['topic_status'] == ITEM_LOCKED) - { - $topic_type = $user->lang['VIEW_TOPIC_LOCKED']; - $folder .= '_locked'; - $folder_new .= '_locked'; - } - - $folder_img = ($unread_topic) ? $folder_new : $folder; - $folder_alt = ($unread_topic) ? 'UNREAD_POSTS' : (($topic_row['topic_status'] == ITEM_LOCKED) ? 'TOPIC_LOCKED' : 'NO_UNREAD_POSTS'); - - // Posted image? - if (!empty($topic_row['topic_posted']) && $topic_row['topic_posted']) - { - $folder_img .= '_mine'; - } - } - - if ($topic_row['poll_start'] && $topic_row['topic_status'] != ITEM_MOVED) - { - $topic_type = $user->lang['VIEW_TOPIC_POLL']; - } -} - -/** -* Assign/Build custom bbcodes for display in screens supporting using of bbcodes -* The custom bbcodes buttons will be placed within the template block 'custom_tags' -*/ -function display_custom_bbcodes() -{ - global $db, $template, $user, $phpbb_dispatcher; - - // Start counting from 22 for the bbcode ids (every bbcode takes two ids - opening/closing) - $num_predefined_bbcodes = NUM_PREDEFINED_BBCODES; - - $sql_ary = array( - 'SELECT' => 'b.bbcode_id, b.bbcode_tag, b.bbcode_helpline', - 'FROM' => array(BBCODES_TABLE => 'b'), - 'WHERE' => 'b.display_on_posting = 1', - 'ORDER_BY' => 'b.bbcode_tag', - ); - - /** - * Event to modify the SQL query before custom bbcode data is queried - * - * @event core.display_custom_bbcodes_modify_sql - * @var array sql_ary The SQL array to get the bbcode data - * @var int num_predefined_bbcodes The number of predefined core bbcodes - * (multiplied by factor of 2) - * @since 3.1.0-a3 - */ - $vars = array('sql_ary', 'num_predefined_bbcodes'); - extract($phpbb_dispatcher->trigger_event('core.display_custom_bbcodes_modify_sql', compact($vars))); - - $result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary)); - - $i = 0; - while ($row = $db->sql_fetchrow($result)) - { - // If the helpline is defined within the language file, we will use the localised version, else just use the database entry... - if (isset($user->lang[strtoupper($row['bbcode_helpline'])])) - { - $row['bbcode_helpline'] = $user->lang[strtoupper($row['bbcode_helpline'])]; - } - - $custom_tags = array( - 'BBCODE_NAME' => "'[{$row['bbcode_tag']}]', '[/" . str_replace('=', '', $row['bbcode_tag']) . "]'", - 'BBCODE_ID' => $num_predefined_bbcodes + ($i * 2), - 'BBCODE_TAG' => $row['bbcode_tag'], - 'BBCODE_TAG_CLEAN' => str_replace('=', '-', $row['bbcode_tag']), - 'BBCODE_HELPLINE' => $row['bbcode_helpline'], - 'A_BBCODE_HELPLINE' => str_replace(array('&', '"', "'", '<', '>'), array('&', '"', "\'", '<', '>'), $row['bbcode_helpline']), - ); - - /** - * Event to modify the template data block of a custom bbcode - * - * This event is triggered once per bbcode - * - * @event core.display_custom_bbcodes_modify_row - * @var array custom_tags Template data of the bbcode - * @var array row The data of the bbcode - * @since 3.1.0-a1 - */ - $vars = array('custom_tags', 'row'); - extract($phpbb_dispatcher->trigger_event('core.display_custom_bbcodes_modify_row', compact($vars))); - - $template->assign_block_vars('custom_tags', $custom_tags); - - $i++; - } - $db->sql_freeresult($result); - - /** - * Display custom bbcodes - * - * @event core.display_custom_bbcodes - * @since 3.1.0-a1 - */ - $phpbb_dispatcher->dispatch('core.display_custom_bbcodes'); -} - -/** -* Display reasons -* -* @deprecated 3.2.0-dev -*/ -function display_reasons($reason_id = 0) -{ - global $phpbb_container; - - $phpbb_container->get('phpbb.report.report_reason_list_provider')->display_reasons($reason_id); -} - -/** -* Display user activity (action forum/topic) -*/ -function display_user_activity(&$userdata_ary) -{ - global $auth, $template, $db, $user, $config; - global $phpbb_root_path, $phpEx; - global $phpbb_container, $phpbb_dispatcher; - - // Do not display user activity for users having too many posts... - $limit = $config['load_user_activity_limit']; - if ($userdata_ary['user_posts'] > $limit && $limit != 0) - { - return; - } - - $forum_ary = array(); - - $forum_read_ary = $auth->acl_getf('f_read'); - foreach ($forum_read_ary as $forum_id => $allowed) - { - if ($allowed['f_read']) - { - $forum_ary[] = (int) $forum_id; - } - } - - $forum_ary = array_diff($forum_ary, $user->get_passworded_forums()); - - $active_f_row = $active_t_row = array(); - if (!empty($forum_ary)) - { - /* @var $phpbb_content_visibility \phpbb\content_visibility */ - $phpbb_content_visibility = $phpbb_container->get('content.visibility'); - - // Obtain active forum - $sql = 'SELECT forum_id, COUNT(post_id) AS num_posts - FROM ' . POSTS_TABLE . ' - WHERE poster_id = ' . $userdata_ary['user_id'] . ' - AND post_postcount = 1 - AND ' . $phpbb_content_visibility->get_forums_visibility_sql('post', $forum_ary) . ' - GROUP BY forum_id - ORDER BY num_posts DESC'; - $result = $db->sql_query_limit($sql, 1); - $active_f_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!empty($active_f_row)) - { - $sql = 'SELECT forum_name - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . $active_f_row['forum_id']; - $result = $db->sql_query($sql, 3600); - $active_f_row['forum_name'] = (string) $db->sql_fetchfield('forum_name'); - $db->sql_freeresult($result); - } - - // Obtain active topic - $sql = 'SELECT topic_id, COUNT(post_id) AS num_posts - FROM ' . POSTS_TABLE . ' - WHERE poster_id = ' . $userdata_ary['user_id'] . ' - AND post_postcount = 1 - AND ' . $phpbb_content_visibility->get_forums_visibility_sql('post', $forum_ary) . ' - GROUP BY topic_id - ORDER BY num_posts DESC'; - $result = $db->sql_query_limit($sql, 1); - $active_t_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!empty($active_t_row)) - { - $sql = 'SELECT topic_title - FROM ' . TOPICS_TABLE . ' - WHERE topic_id = ' . $active_t_row['topic_id']; - $result = $db->sql_query($sql); - $active_t_row['topic_title'] = (string) $db->sql_fetchfield('topic_title'); - $db->sql_freeresult($result); - } - } - - $userdata = $userdata_ary; - $show_user_activity = true; - /** - * Alter list of forums and topics to display as active - * - * @event core.display_user_activity_modify_actives - * @var array userdata User's data - * @var array active_f_row List of active forums - * @var array active_t_row List of active posts - * @var bool show_user_activity Show user forum and topic activity - * @since 3.1.0-RC3 - * @changed 3.2.5-RC1 Added show_user_activity into event - */ - $vars = array('userdata', 'active_f_row', 'active_t_row', 'show_user_activity'); - extract($phpbb_dispatcher->trigger_event('core.display_user_activity_modify_actives', compact($vars))); - $userdata_ary = $userdata; - unset($userdata); - - $userdata_ary['active_t_row'] = $active_t_row; - $userdata_ary['active_f_row'] = $active_f_row; - - $active_f_name = $active_f_id = $active_f_count = $active_f_pct = ''; - if (!empty($active_f_row['num_posts'])) - { - $active_f_name = $active_f_row['forum_name']; - $active_f_id = $active_f_row['forum_id']; - $active_f_count = $active_f_row['num_posts']; - $active_f_pct = ($userdata_ary['user_posts']) ? ($active_f_count / $userdata_ary['user_posts']) * 100 : 0; - } - - $active_t_name = $active_t_id = $active_t_count = $active_t_pct = ''; - if (!empty($active_t_row['num_posts'])) - { - $active_t_name = $active_t_row['topic_title']; - $active_t_id = $active_t_row['topic_id']; - $active_t_count = $active_t_row['num_posts']; - $active_t_pct = ($userdata_ary['user_posts']) ? ($active_t_count / $userdata_ary['user_posts']) * 100 : 0; - } - - $l_active_pct = ($userdata_ary['user_id'] != ANONYMOUS && $userdata_ary['user_id'] == $user->data['user_id']) ? $user->lang['POST_PCT_ACTIVE_OWN'] : $user->lang['POST_PCT_ACTIVE']; - - $template->assign_vars(array( - 'ACTIVE_FORUM' => $active_f_name, - 'ACTIVE_FORUM_POSTS' => $user->lang('USER_POSTS', (int) $active_f_count), - 'ACTIVE_FORUM_PCT' => sprintf($l_active_pct, $active_f_pct), - 'ACTIVE_TOPIC' => censor_text($active_t_name), - 'ACTIVE_TOPIC_POSTS' => $user->lang('USER_POSTS', (int) $active_t_count), - 'ACTIVE_TOPIC_PCT' => sprintf($l_active_pct, $active_t_pct), - 'U_ACTIVE_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $active_f_id), - 'U_ACTIVE_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=' . $active_t_id), - 'S_SHOW_ACTIVITY' => $show_user_activity) - ); -} - -/** -* Topic and forum watching common code -*/ -function watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id, $notify_status = 'unset', $start = 0, $item_title = '') -{ - global $db, $user, $phpEx, $start, $phpbb_root_path; - global $request; - - $table_sql = ($mode == 'forum') ? FORUMS_WATCH_TABLE : TOPICS_WATCH_TABLE; - $where_sql = ($mode == 'forum') ? 'forum_id' : 'topic_id'; - $match_id = ($mode == 'forum') ? $forum_id : $topic_id; - $u_url = "uid={$user->data['user_id']}"; - $u_url .= ($mode == 'forum') ? '&f' : '&f=' . $forum_id . '&t'; - $is_watching = 0; - - // Is user watching this topic? - if ($user_id != ANONYMOUS) - { - $can_watch = true; - - if ($notify_status == 'unset') - { - $sql = "SELECT notify_status - FROM $table_sql - WHERE $where_sql = $match_id - AND user_id = $user_id"; - $result = $db->sql_query($sql); - - $notify_status = ($row = $db->sql_fetchrow($result)) ? $row['notify_status'] : NULL; - $db->sql_freeresult($result); - } - - if (!is_null($notify_status) && $notify_status !== '') - { - if (isset($_GET['unwatch'])) - { - $uid = $request->variable('uid', 0); - $token = $request->variable('hash', ''); - - if ($token && check_link_hash($token, "{$mode}_$match_id") || confirm_box(true)) - { - if ($uid != $user_id || $request->variable('unwatch', '', false, \phpbb\request\request_interface::GET) != $mode) - { - $redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&start=$start"); - $message = $user->lang['ERR_UNWATCHING']; - - if (!$request->is_ajax()) - { - $message .= '

' . $user->lang('RETURN_' . strtoupper($mode), '', ''); - } - trigger_error($message); - } - - $sql = 'DELETE FROM ' . $table_sql . " - WHERE $where_sql = $match_id - AND user_id = $user_id"; - $db->sql_query($sql); - - $redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&start=$start"); - $message = $user->lang['NOT_WATCHING_' . strtoupper($mode)]; - - if (!$request->is_ajax()) - { - $message .= '

' . $user->lang('RETURN_' . strtoupper($mode), '', ''); - } - meta_refresh(3, $redirect_url); - trigger_error($message); - } - else - { - $s_hidden_fields = array( - 'uid' => $user->data['user_id'], - 'unwatch' => $mode, - 'start' => $start, - 'f' => $forum_id, - ); - if ($mode != 'forum') - { - $s_hidden_fields['t'] = $topic_id; - } - - if ($item_title == '') - { - $confirm_box_message = 'UNWATCH_' . strtoupper($mode); - } - else - { - $confirm_box_message = $user->lang('UNWATCH_' . strtoupper($mode) . '_DETAILED', $item_title); - } - confirm_box(false, $confirm_box_message, build_hidden_fields($s_hidden_fields)); - } - } - else - { - $is_watching = true; - - if ($notify_status != NOTIFY_YES) - { - $sql = 'UPDATE ' . $table_sql . " - SET notify_status = " . NOTIFY_YES . " - WHERE $where_sql = $match_id - AND user_id = $user_id"; - $db->sql_query($sql); - } - } - } - else - { - if (isset($_GET['watch'])) - { - $uid = $request->variable('uid', 0); - $token = $request->variable('hash', ''); - - if ($token && check_link_hash($token, "{$mode}_$match_id") || confirm_box(true)) - { - if ($uid != $user_id || $request->variable('watch', '', false, \phpbb\request\request_interface::GET) != $mode) - { - $redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&start=$start"); - $message = $user->lang['ERR_WATCHING']; - - if (!$request->is_ajax()) - { - $message .= '

' . $user->lang('RETURN_' . strtoupper($mode), '', ''); - } - trigger_error($message); - } - - $is_watching = true; - - $sql = 'INSERT INTO ' . $table_sql . " (user_id, $where_sql, notify_status) - VALUES ($user_id, $match_id, " . NOTIFY_YES . ')'; - $db->sql_query($sql); - - $redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&start=$start"); - $message = $user->lang['ARE_WATCHING_' . strtoupper($mode)]; - - if (!$request->is_ajax()) - { - $message .= '

' . $user->lang('RETURN_' . strtoupper($mode), '', ''); - } - meta_refresh(3, $redirect_url); - trigger_error($message); - } - else - { - $s_hidden_fields = array( - 'uid' => $user->data['user_id'], - 'watch' => $mode, - 'start' => $start, - 'f' => $forum_id, - ); - if ($mode != 'forum') - { - $s_hidden_fields['t'] = $topic_id; - } - - $confirm_box_message = (($item_title == '') ? 'WATCH_' . strtoupper($mode) : $user->lang('WATCH_' . strtoupper($mode) . '_DETAILED', $item_title)); - confirm_box(false, $confirm_box_message, build_hidden_fields($s_hidden_fields)); - } - } - else - { - $is_watching = 0; - } - } - } - else - { - if ((isset($_GET['unwatch']) && $request->variable('unwatch', '', false, \phpbb\request\request_interface::GET) == $mode) || - (isset($_GET['watch']) && $request->variable('watch', '', false, \phpbb\request\request_interface::GET) == $mode)) - { - login_box(); - } - else - { - $can_watch = 0; - $is_watching = 0; - } - } - - if ($can_watch) - { - $s_watching['link'] = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&" . (($is_watching) ? 'unwatch' : 'watch') . "=$mode&start=$start&hash=" . generate_link_hash("{$mode}_$match_id")); - $s_watching['link_toggle'] = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&" . ((!$is_watching) ? 'unwatch' : 'watch') . "=$mode&start=$start&hash=" . generate_link_hash("{$mode}_$match_id")); - $s_watching['title'] = $user->lang[(($is_watching) ? 'STOP' : 'START') . '_WATCHING_' . strtoupper($mode)]; - $s_watching['title_toggle'] = $user->lang[((!$is_watching) ? 'STOP' : 'START') . '_WATCHING_' . strtoupper($mode)]; - $s_watching['is_watching'] = $is_watching; - } - - return; -} - -/** -* Get user rank title and image -* -* @param array $user_data the current stored users data -* @param int $user_posts the users number of posts -* -* @return array An associative array containing the rank title (title), the rank image as full img tag (img) and the rank image source (img_src) -* -* Note: since we do not want to break backwards-compatibility, this function will only properly assign ranks to guests if you call it for them with user_posts == false -*/ -function phpbb_get_user_rank($user_data, $user_posts) -{ - global $ranks, $config, $phpbb_root_path, $phpbb_path_helper, $phpbb_dispatcher; - - $user_rank_data = array( - 'title' => null, - 'img' => null, - 'img_src' => null, - ); - - /** - * Preparing a user's rank before displaying - * - * @event core.modify_user_rank - * @var array user_data Array with user's data - * @var int user_posts User_posts to change - * @since 3.1.0-RC4 - */ - - $vars = array('user_data', 'user_posts'); - extract($phpbb_dispatcher->trigger_event('core.modify_user_rank', compact($vars))); - - if (empty($ranks)) - { - global $cache; - $ranks = $cache->obtain_ranks(); - } - - if (!empty($user_data['user_rank'])) - { - - $user_rank_data['title'] = (isset($ranks['special'][$user_data['user_rank']]['rank_title'])) ? $ranks['special'][$user_data['user_rank']]['rank_title'] : ''; - - $user_rank_data['img_src'] = (!empty($ranks['special'][$user_data['user_rank']]['rank_image'])) ? $phpbb_path_helper->update_web_root_path($phpbb_root_path . $config['ranks_path'] . '/' . $ranks['special'][$user_data['user_rank']]['rank_image']) : ''; - - $user_rank_data['img'] = (!empty($ranks['special'][$user_data['user_rank']]['rank_image'])) ? '' . $ranks['special'][$user_data['user_rank']]['rank_title'] . '' : ''; - } - else if ($user_posts !== false) - { - if (!empty($ranks['normal'])) - { - foreach ($ranks['normal'] as $rank) - { - if ($user_posts >= $rank['rank_min']) - { - $user_rank_data['title'] = $rank['rank_title']; - $user_rank_data['img_src'] = (!empty($rank['rank_image'])) ? $phpbb_path_helper->update_web_root_path($phpbb_root_path . $config['ranks_path'] . '/' . $rank['rank_image']) : ''; - $user_rank_data['img'] = (!empty($rank['rank_image'])) ? '' . $rank['rank_title'] . '' : ''; - break; - } - } - } - } - - /** - * Modify a user's rank before displaying - * - * @event core.get_user_rank_after - * @var array user_data Array with user's data - * @var int user_posts User_posts to change - * @var array user_rank_data User rank data - * @since 3.1.11-RC1 - */ - - $vars = array( - 'user_data', - 'user_posts', - 'user_rank_data', - ); - extract($phpbb_dispatcher->trigger_event('core.get_user_rank_after', compact($vars))); - - return $user_rank_data; -} - -/** -* Prepare profile data -*/ -function phpbb_show_profile($data, $user_notes_enabled = false, $warn_user_enabled = false, $check_can_receive_pm = true) -{ - global $config, $auth, $user, $phpEx, $phpbb_root_path, $phpbb_dispatcher; - - $username = $data['username']; - $user_id = $data['user_id']; - - $user_rank_data = phpbb_get_user_rank($data, (($user_id == ANONYMOUS) ? false : $data['user_posts'])); - - if ((!empty($data['user_allow_viewemail']) && $auth->acl_get('u_sendemail')) || $auth->acl_get('a_user')) - { - $email = ($config['board_email_form'] && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=email&u=' . $user_id) : (($config['board_hide_emails'] && !$auth->acl_get('a_user')) ? '' : 'mailto:' . $data['user_email']); - } - else - { - $email = ''; - } - - if ($config['load_onlinetrack']) - { - $update_time = $config['load_online_time'] * 60; - $online = (time() - $update_time < $data['session_time'] && ((isset($data['session_viewonline']) && $data['session_viewonline']) || $auth->acl_get('u_viewonline'))) ? true : false; - } - else - { - $online = false; - } - - if ($data['user_allow_viewonline'] || $auth->acl_get('u_viewonline')) - { - $last_active = (!empty($data['session_time'])) ? $data['session_time'] : $data['user_lastvisit']; - } - else - { - $last_active = ''; - } - - $age = ''; - - if ($config['allow_birthdays'] && $data['user_birthday']) - { - list($bday_day, $bday_month, $bday_year) = array_map('intval', explode('-', $data['user_birthday'])); - - if ($bday_year) - { - $now = $user->create_datetime(); - $now = phpbb_gmgetdate($now->getTimestamp() + $now->getOffset()); - - $diff = $now['mon'] - $bday_month; - if ($diff == 0) - { - $diff = ($now['mday'] - $bday_day < 0) ? 1 : 0; - } - else - { - $diff = ($diff < 0) ? 1 : 0; - } - - $age = max(0, (int) ($now['year'] - $bday_year - $diff)); - } - } - - if (!function_exists('phpbb_get_banned_user_ids')) - { - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - } - - // Can this user receive a Private Message? - $can_receive_pm = $check_can_receive_pm && ( - // They must be a "normal" user - $data['user_type'] != USER_IGNORE && - - // They must not be deactivated by the administrator - ($data['user_type'] != USER_INACTIVE || $data['user_inactive_reason'] != INACTIVE_MANUAL) && - - // They must be able to read PMs - count($auth->acl_get_list($user_id, 'u_readpm')) && - - // They must not be permanently banned - !count(phpbb_get_banned_user_ids($user_id, false)) && - - // They must allow users to contact via PM - (($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) || $data['user_allow_pm']) - ); - - // Dump it out to the template - $template_data = array( - 'AGE' => $age, - 'RANK_TITLE' => $user_rank_data['title'], - 'JOINED' => $user->format_date($data['user_regdate']), - 'LAST_ACTIVE' => (empty($last_active)) ? ' - ' : $user->format_date($last_active), - 'POSTS' => ($data['user_posts']) ? $data['user_posts'] : 0, - 'WARNINGS' => isset($data['user_warnings']) ? $data['user_warnings'] : 0, - - 'USERNAME_FULL' => get_username_string('full', $user_id, $username, $data['user_colour']), - 'USERNAME' => get_username_string('username', $user_id, $username, $data['user_colour']), - 'USER_COLOR' => get_username_string('colour', $user_id, $username, $data['user_colour']), - 'U_VIEW_PROFILE' => get_username_string('profile', $user_id, $username, $data['user_colour']), - - 'A_USERNAME' => addslashes(get_username_string('username', $user_id, $username, $data['user_colour'])), - - 'AVATAR_IMG' => phpbb_get_user_avatar($data), - 'ONLINE_IMG' => (!$config['load_onlinetrack']) ? '' : (($online) ? $user->img('icon_user_online', 'ONLINE') : $user->img('icon_user_offline', 'OFFLINE')), - 'S_ONLINE' => ($config['load_onlinetrack'] && $online) ? true : false, - 'RANK_IMG' => $user_rank_data['img'], - 'RANK_IMG_SRC' => $user_rank_data['img_src'], - 'S_JABBER_ENABLED' => ($config['jab_enable']) ? true : false, - - 'S_WARNINGS' => ($auth->acl_getf_global('m_') || $auth->acl_get('m_warn')) ? true : false, - - 'U_SEARCH_USER' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id=$user_id&sr=posts") : '', - 'U_NOTES' => ($user_notes_enabled && $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $user_id, true, $user->session_id) : '', - 'U_WARN' => ($warn_user_enabled && $auth->acl_get('m_warn')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_user&u=' . $user_id, true, $user->session_id) : '', - 'U_PM' => ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && $can_receive_pm) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&u=' . $user_id) : '', - 'U_EMAIL' => $email, - 'U_JABBER' => ($data['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=jabber&u=' . $user_id) : '', - - 'USER_JABBER' => ($config['jab_enable']) ? $data['user_jabber'] : '', - 'USER_JABBER_IMG' => ($config['jab_enable'] && $data['user_jabber']) ? $user->img('icon_contact_jabber', $data['user_jabber']) : '', - - 'L_SEND_EMAIL_USER' => $user->lang('SEND_EMAIL_USER', $username), - 'L_CONTACT_USER' => $user->lang('CONTACT_USER', $username), - 'L_VIEWING_PROFILE' => $user->lang('VIEWING_PROFILE', $username), - ); - - /** - * Preparing a user's data before displaying it in profile and memberlist - * - * @event core.memberlist_prepare_profile_data - * @var array data Array with user's data - * @var array template_data Template array with user's data - * @since 3.1.0-a1 - */ - $vars = array('data', 'template_data'); - extract($phpbb_dispatcher->trigger_event('core.memberlist_prepare_profile_data', compact($vars))); - - return $template_data; -} - -function phpbb_sort_last_active($first, $second) -{ - global $id_cache, $sort_dir; - - $lesser_than = ($sort_dir === 'd') ? -1 : 1; - - if (isset($id_cache[$first]['group_leader']) && $id_cache[$first]['group_leader'] && (!isset($id_cache[$second]['group_leader']) || !$id_cache[$second]['group_leader'])) - { - return -1; - } - else if (isset($id_cache[$second]['group_leader']) && (!isset($id_cache[$first]['group_leader']) || !$id_cache[$first]['group_leader']) && $id_cache[$second]['group_leader']) - { - return 1; - } - else - { - return $lesser_than * (int) ($id_cache[$first]['last_visit'] - $id_cache[$second]['last_visit']); - } -} diff --git a/install/update/old/includes/functions_download.php b/install/update/old/includes/functions_download.php deleted file mode 100644 index 7be12ba..0000000 --- a/install/update/old/includes/functions_download.php +++ /dev/null @@ -1,790 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* A simplified function to deliver avatars -* The argument needs to be checked before calling this function. -*/ -function send_avatar_to_browser($file, $browser) -{ - global $config, $phpbb_root_path; - - $prefix = $config['avatar_salt'] . '_'; - $image_dir = $config['avatar_path']; - - // Adjust image_dir path (no trailing slash) - if (substr($image_dir, -1, 1) == '/' || substr($image_dir, -1, 1) == '\\') - { - $image_dir = substr($image_dir, 0, -1) . '/'; - } - $image_dir = str_replace(array('../', '..\\', './', '.\\'), '', $image_dir); - - if ($image_dir && ($image_dir[0] == '/' || $image_dir[0] == '\\')) - { - $image_dir = ''; - } - $file_path = $phpbb_root_path . $image_dir . '/' . $prefix . $file; - - if ((@file_exists($file_path) && @is_readable($file_path)) && !headers_sent()) - { - header('Cache-Control: public'); - - $image_data = @getimagesize($file_path); - header('Content-Type: ' . image_type_to_mime_type($image_data[2])); - - if ((strpos(strtolower($browser), 'msie') !== false) && !phpbb_is_greater_ie_version($browser, 7)) - { - header('Content-Disposition: attachment; ' . header_filename($file)); - - if (strpos(strtolower($browser), 'msie 6.0') !== false) - { - header('Expires: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT'); - } - else - { - header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 31536000) . ' GMT'); - } - } - else - { - header('Content-Disposition: inline; ' . header_filename($file)); - header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 31536000) . ' GMT'); - } - - $size = @filesize($file_path); - if ($size) - { - header("Content-Length: $size"); - } - - if (@readfile($file_path) == false) - { - $fp = @fopen($file_path, 'rb'); - - if ($fp !== false) - { - while (!feof($fp)) - { - echo fread($fp, 8192); - } - fclose($fp); - } - } - - flush(); - } - else - { - header('HTTP/1.0 404 Not Found'); - } -} - -/** -* Wraps an url into a simple html page. Used to display attachments in IE. -* this is a workaround for now; might be moved to template system later -* direct any complaints to 1 Microsoft Way, Redmond -*/ -function wrap_img_in_html($src, $title) -{ - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo '' . $title . ''; - echo ''; - echo ''; - echo '
'; - echo '' . $title . ''; - echo '
'; - echo ''; - echo ''; -} - -/** -* Send file to browser -*/ -function send_file_to_browser($attachment, $upload_dir, $category) -{ - global $user, $db, $phpbb_dispatcher, $phpbb_root_path, $request; - - $filename = $phpbb_root_path . $upload_dir . '/' . $attachment['physical_filename']; - - if (!@file_exists($filename)) - { - send_status_line(404, 'Not Found'); - trigger_error('ERROR_NO_ATTACHMENT'); - } - - // Correct the mime type - we force application/octetstream for all files, except images - // Please do not change this, it is a security precaution - if ($category != ATTACHMENT_CATEGORY_IMAGE || strpos($attachment['mimetype'], 'image') !== 0) - { - $attachment['mimetype'] = (strpos(strtolower($user->browser), 'msie') !== false || strpos(strtolower($user->browser), 'opera') !== false) ? 'application/octetstream' : 'application/octet-stream'; - } - - if (@ob_get_length()) - { - @ob_end_clean(); - } - - // Now send the File Contents to the Browser - $size = @filesize($filename); - - /** - * Event to alter attachment before it is sent to browser. - * - * @event core.send_file_to_browser_before - * @var array attachment Attachment data - * @var string upload_dir Relative path of upload directory - * @var int category Attachment category - * @var string filename Path to file, including filename - * @var int size File size - * @since 3.1.11-RC1 - */ - $vars = array( - 'attachment', - 'upload_dir', - 'category', - 'filename', - 'size', - ); - extract($phpbb_dispatcher->trigger_event('core.send_file_to_browser_before', compact($vars))); - - // To correctly display further errors we need to make sure we are using the correct headers for both (unsetting content-length may not work) - - // Check if headers already sent or not able to get the file contents. - if (headers_sent() || !@file_exists($filename) || !@is_readable($filename)) - { - // PHP track_errors setting On? - if (!empty($php_errormsg)) - { - send_status_line(500, 'Internal Server Error'); - trigger_error($user->lang['UNABLE_TO_DELIVER_FILE'] . '
' . sprintf($user->lang['TRACKED_PHP_ERROR'], $php_errormsg)); - } - - send_status_line(500, 'Internal Server Error'); - trigger_error('UNABLE_TO_DELIVER_FILE'); - } - - // Make sure the database record for the filesize is correct - if ($size > 0 && $size != $attachment['filesize'] && strpos($attachment['physical_filename'], 'thumb_') === false) - { - // Update database record - $sql = 'UPDATE ' . ATTACHMENTS_TABLE . ' - SET filesize = ' . (int) $size . ' - WHERE attach_id = ' . (int) $attachment['attach_id']; - $db->sql_query($sql); - } - - // Now the tricky part... let's dance - header('Cache-Control: public'); - - // Send out the Headers. Do not set Content-Disposition to inline please, it is a security measure for users using the Internet Explorer. - header('Content-Type: ' . $attachment['mimetype']); - - if (phpbb_is_greater_ie_version($user->browser, 7)) - { - header('X-Content-Type-Options: nosniff'); - } - - if ($category == ATTACHMENT_CATEGORY_FLASH && $request->variable('view', 0) === 1) - { - // We use content-disposition: inline for flash files and view=1 to let it correctly play with flash player 10 - any other disposition will fail to play inline - header('Content-Disposition: inline'); - } - else - { - if (empty($user->browser) || ((strpos(strtolower($user->browser), 'msie') !== false) && !phpbb_is_greater_ie_version($user->browser, 7))) - { - header('Content-Disposition: attachment; ' . header_filename(htmlspecialchars_decode($attachment['real_filename']))); - if (empty($user->browser) || (strpos(strtolower($user->browser), 'msie 6.0') !== false)) - { - header('Expires: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT'); - } - } - else - { - header('Content-Disposition: ' . ((strpos($attachment['mimetype'], 'image') === 0) ? 'inline' : 'attachment') . '; ' . header_filename(htmlspecialchars_decode($attachment['real_filename']))); - if (phpbb_is_greater_ie_version($user->browser, 7) && (strpos($attachment['mimetype'], 'image') !== 0)) - { - header('X-Download-Options: noopen'); - } - } - } - - // Close the db connection before sending the file etc. - file_gc(false); - - if (!set_modified_headers($attachment['filetime'], $user->browser)) - { - // We make sure those have to be enabled manually by defining a constant - // because of the potential disclosure of full attachment path - // in case support for features is absent in the webserver software. - if (defined('PHPBB_ENABLE_X_ACCEL_REDIRECT') && PHPBB_ENABLE_X_ACCEL_REDIRECT) - { - // X-Accel-Redirect - http://wiki.nginx.org/XSendfile - header('X-Accel-Redirect: ' . $user->page['root_script_path'] . $upload_dir . '/' . $attachment['physical_filename']); - exit; - } - else if (defined('PHPBB_ENABLE_X_SENDFILE') && PHPBB_ENABLE_X_SENDFILE && !phpbb_http_byte_range($size)) - { - // X-Sendfile - http://blog.lighttpd.net/articles/2006/07/02/x-sendfile - // Lighttpd's X-Sendfile does not support range requests as of 1.4.26 - // and always requires an absolute path. - header('X-Sendfile: ' . dirname(__FILE__) . "/../$upload_dir/{$attachment['physical_filename']}"); - exit; - } - - if ($size) - { - header("Content-Length: $size"); - } - - // Try to deliver in chunks - @set_time_limit(0); - - $fp = @fopen($filename, 'rb'); - - if ($fp !== false) - { - // Deliver file partially if requested - if ($range = phpbb_http_byte_range($size)) - { - fseek($fp, $range['byte_pos_start']); - - send_status_line(206, 'Partial Content'); - header('Content-Range: bytes ' . $range['byte_pos_start'] . '-' . $range['byte_pos_end'] . '/' . $range['bytes_total']); - header('Content-Length: ' . $range['bytes_requested']); - - // First read chunks - while (!feof($fp) && ftell($fp) < $range['byte_pos_end'] - 8192) - { - echo fread($fp, 8192); - } - // Then, read the remainder - echo fread($fp, $range['bytes_requested'] % 8192); - } - else - { - while (!feof($fp)) - { - echo fread($fp, 8192); - } - } - fclose($fp); - } - else - { - @readfile($filename); - } - - flush(); - } - - exit; -} - -/** -* Get a browser friendly UTF-8 encoded filename -*/ -function header_filename($file) -{ - global $request; - - $user_agent = $request->header('User-Agent'); - - // There be dragons here. - // Not many follows the RFC... - if (strpos($user_agent, 'MSIE') !== false || strpos($user_agent, 'Konqueror') !== false) - { - return "filename=" . rawurlencode($file); - } - - // follow the RFC for extended filename for the rest - return "filename*=UTF-8''" . rawurlencode($file); -} - -/** -* Check if downloading item is allowed -*/ -function download_allowed() -{ - global $config, $user, $db, $request; - - if (!$config['secure_downloads']) - { - return true; - } - - $url = htmlspecialchars_decode($request->header('Referer')); - - if (!$url) - { - return ($config['secure_allow_empty_referer']) ? true : false; - } - - // Split URL into domain and script part - $url = @parse_url($url); - - if ($url === false) - { - return ($config['secure_allow_empty_referer']) ? true : false; - } - - $hostname = $url['host']; - unset($url); - - $allowed = ($config['secure_allow_deny']) ? false : true; - $iplist = array(); - - if (($ip_ary = @gethostbynamel($hostname)) !== false) - { - foreach ($ip_ary as $ip) - { - if ($ip) - { - $iplist[] = $ip; - } - } - } - - // Check for own server... - $server_name = $user->host; - - // Forcing server vars is the only way to specify/override the protocol - if ($config['force_server_vars'] || !$server_name) - { - $server_name = $config['server_name']; - } - - if (preg_match('#^.*?' . preg_quote($server_name, '#') . '.*?$#i', $hostname)) - { - $allowed = true; - } - - // Get IP's and Hostnames - if (!$allowed) - { - $sql = 'SELECT site_ip, site_hostname, ip_exclude - FROM ' . SITELIST_TABLE; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $site_ip = trim($row['site_ip']); - $site_hostname = trim($row['site_hostname']); - - if ($site_ip) - { - foreach ($iplist as $ip) - { - if (preg_match('#^' . str_replace('\*', '.*?', preg_quote($site_ip, '#')) . '$#i', $ip)) - { - if ($row['ip_exclude']) - { - $allowed = ($config['secure_allow_deny']) ? false : true; - break 2; - } - else - { - $allowed = ($config['secure_allow_deny']) ? true : false; - } - } - } - } - - if ($site_hostname) - { - if (preg_match('#^' . str_replace('\*', '.*?', preg_quote($site_hostname, '#')) . '$#i', $hostname)) - { - if ($row['ip_exclude']) - { - $allowed = ($config['secure_allow_deny']) ? false : true; - break; - } - else - { - $allowed = ($config['secure_allow_deny']) ? true : false; - } - } - } - } - $db->sql_freeresult($result); - } - - return $allowed; -} - -/** -* Check if the browser has the file already and set the appropriate headers- -* @returns false if a resend is in order. -*/ -function set_modified_headers($stamp, $browser) -{ - global $request; - - // let's see if we have to send the file at all - $last_load = $request->header('If-Modified-Since') ? strtotime(trim($request->header('If-Modified-Since'))) : false; - - if (strpos(strtolower($browser), 'msie 6.0') === false && !phpbb_is_greater_ie_version($browser, 7)) - { - if ($last_load !== false && $last_load >= $stamp) - { - send_status_line(304, 'Not Modified'); - // seems that we need those too ... browsers - header('Cache-Control: public'); - header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 31536000) . ' GMT'); - return true; - } - else - { - header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $stamp) . ' GMT'); - } - } - return false; -} - -/** -* Garbage Collection -* -* @param bool $exit Whether to die or not. -* -* @return null -*/ -function file_gc($exit = true) -{ - global $cache, $db; - - if (!empty($cache)) - { - $cache->unload(); - } - - $db->sql_close(); - - if ($exit) - { - exit; - } -} - -/** -* HTTP range support (RFC 2616 Section 14.35) -* -* Allows browsers to request partial file content -* in case a download has been interrupted. -* -* @param int $filesize the size of the file in bytes we are about to deliver -* -* @return mixed false if the whole file has to be delivered -* associative array on success -*/ -function phpbb_http_byte_range($filesize) -{ - // Only call find_range_request() once. - static $request_array; - - if (!$filesize) - { - return false; - } - - if (!isset($request_array)) - { - $request_array = phpbb_find_range_request(); - } - - return (empty($request_array)) ? false : phpbb_parse_range_request($request_array, $filesize); -} - -/** -* Searches for HTTP range request in request headers. -* -* @return mixed false if no request found -* array of strings containing the requested ranges otherwise -* e.g. array(0 => '0-0', 1 => '123-125') -*/ -function phpbb_find_range_request() -{ - global $request; - - $value = $request->header('Range'); - - // Make sure range request starts with "bytes=" - if (strpos($value, 'bytes=') === 0) - { - // Strip leading 'bytes=' - // Multiple ranges can be separated by a comma - return explode(',', substr($value, 6)); - } - - return false; -} - -/** -* Analyses a range request array. -* -* A range request can contain multiple ranges, -* we however only handle the first request and -* only support requests from a given byte to the end of the file. -* -* @param array $request_array array of strings containing the requested ranges -* @param int $filesize the full size of the file in bytes that has been requested -* -* @return mixed false if the whole file has to be delivered -* associative array on success -* byte_pos_start the first byte position, can be passed to fseek() -* byte_pos_end the last byte position -* bytes_requested the number of bytes requested -* bytes_total the full size of the file -*/ -function phpbb_parse_range_request($request_array, $filesize) -{ - $first_byte_pos = -1; - $last_byte_pos = -1; - - // Go through all ranges - foreach ($request_array as $range_string) - { - $range = explode('-', trim($range_string)); - - // "-" is invalid, "0-0" however is valid and means the very first byte. - if (count($range) != 2 || $range[0] === '' && $range[1] === '') - { - continue; - } - - // Substitute defaults - if ($range[0] === '') - { - $range[0] = 0; - } - - if ($range[1] === '') - { - $range[1] = $filesize - 1; - } - - if ($last_byte_pos >= 0 && $last_byte_pos + 1 != $range[0]) - { - // We only support contiguous ranges, no multipart stuff :( - return false; - } - - if ($range[1] && $range[1] < $range[0]) - { - // The requested range contains 0 bytes. - continue; - } - - // Return bytes from $range[0] to $range[1] - if ($first_byte_pos < 0) - { - $first_byte_pos = (int) $range[0]; - } - - $last_byte_pos = (int) $range[1]; - - if ($first_byte_pos >= $filesize) - { - // Requested range not satisfiable - return false; - } - - // Adjust last-byte-pos if it is absent or greater than the content. - if ($range[1] === '' || $last_byte_pos >= $filesize) - { - $last_byte_pos = $filesize - 1; - } - } - - if ($first_byte_pos < 0 || $last_byte_pos < 0) - { - return false; - } - - return array( - 'byte_pos_start' => $first_byte_pos, - 'byte_pos_end' => $last_byte_pos, - 'bytes_requested' => $last_byte_pos - $first_byte_pos + 1, - 'bytes_total' => $filesize, - ); -} - -/** -* Increments the download count of all provided attachments -* -* @param \phpbb\db\driver\driver_interface $db The database object -* @param array|int $ids The attach_id of each attachment -* -* @return null -*/ -function phpbb_increment_downloads($db, $ids) -{ - if (!is_array($ids)) - { - $ids = array($ids); - } - - $sql = 'UPDATE ' . ATTACHMENTS_TABLE . ' - SET download_count = download_count + 1 - WHERE ' . $db->sql_in_set('attach_id', $ids); - $db->sql_query($sql); -} - -/** -* Handles authentication when downloading attachments from a post or topic -* -* @param \phpbb\db\driver\driver_interface $db The database object -* @param \phpbb\auth\auth $auth The authentication object -* @param int $topic_id The id of the topic that we are downloading from -* -* @return null -*/ -function phpbb_download_handle_forum_auth($db, $auth, $topic_id) -{ - global $phpbb_container; - - $sql_array = array( - 'SELECT' => 't.topic_visibility, t.forum_id, f.forum_name, f.forum_password, f.parent_id', - 'FROM' => array( - TOPICS_TABLE => 't', - FORUMS_TABLE => 'f', - ), - 'WHERE' => 't.topic_id = ' . (int) $topic_id . ' - AND t.forum_id = f.forum_id', - ); - - $sql = $db->sql_build_query('SELECT', $sql_array); - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $phpbb_content_visibility = $phpbb_container->get('content.visibility'); - - if ($row && !$phpbb_content_visibility->is_visible('topic', $row['forum_id'], $row)) - { - send_status_line(404, 'Not Found'); - trigger_error('ERROR_NO_ATTACHMENT'); - } - else if ($row && $auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id'])) - { - if ($row['forum_password']) - { - // Do something else ... ? - login_forum_box($row); - } - } - else - { - send_status_line(403, 'Forbidden'); - trigger_error('SORRY_AUTH_VIEW_ATTACH'); - } -} - -/** -* Handles authentication when downloading attachments from PMs -* -* @param \phpbb\db\driver\driver_interface $db The database object -* @param \phpbb\auth\auth $auth The authentication object -* @param int $user_id The user id -* @param int $msg_id The id of the PM that we are downloading from -* -* @return null -*/ -function phpbb_download_handle_pm_auth($db, $auth, $user_id, $msg_id) -{ - global $phpbb_dispatcher; - - if (!$auth->acl_get('u_pm_download')) - { - send_status_line(403, 'Forbidden'); - trigger_error('SORRY_AUTH_VIEW_ATTACH'); - } - - $allowed = phpbb_download_check_pm_auth($db, $user_id, $msg_id); - - /** - * Event to modify PM attachments download auth - * - * @event core.modify_pm_attach_download_auth - * @var bool allowed Whether the user is allowed to download from that PM or not - * @var int msg_id The id of the PM to download from - * @var int user_id The user id for auth check - * @since 3.1.11-RC1 - */ - $vars = array('allowed', 'msg_id', 'user_id'); - extract($phpbb_dispatcher->trigger_event('core.modify_pm_attach_download_auth', compact($vars))); - - if (!$allowed) - { - send_status_line(403, 'Forbidden'); - trigger_error('ERROR_NO_ATTACHMENT'); - } -} - -/** -* Checks whether a user can download from a particular PM -* -* @param \phpbb\db\driver\driver_interface $db The database object -* @param int $user_id The user id -* @param int $msg_id The id of the PM that we are downloading from -* -* @return bool Whether the user is allowed to download from that PM or not -*/ -function phpbb_download_check_pm_auth($db, $user_id, $msg_id) -{ - // Check if the attachment is within the users scope... - $sql = 'SELECT msg_id - FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE msg_id = ' . (int) $msg_id . ' - AND ( - user_id = ' . (int) $user_id . ' - OR author_id = ' . (int) $user_id . ' - )'; - $result = $db->sql_query_limit($sql, 1); - $allowed = (bool) $db->sql_fetchfield('msg_id'); - $db->sql_freeresult($result); - - return $allowed; -} - -/** -* Check if the browser is internet explorer version 7+ -* -* @param string $user_agent User agent HTTP header -* @param int $version IE version to check against -* -* @return bool true if internet explorer version is greater than $version -*/ -function phpbb_is_greater_ie_version($user_agent, $version) -{ - if (preg_match('/msie (\d+)/', strtolower($user_agent), $matches)) - { - $ie_version = (int) $matches[1]; - return ($ie_version > $version); - } - else - { - return false; - } -} diff --git a/install/update/old/includes/functions_messenger.php b/install/update/old/includes/functions_messenger.php deleted file mode 100644 index 4f0d400..0000000 --- a/install/update/old/includes/functions_messenger.php +++ /dev/null @@ -1,1915 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* Messenger -*/ -class messenger -{ - var $msg, $replyto, $from, $subject; - var $addresses = array(); - var $extra_headers = array(); - - var $mail_priority = MAIL_NORMAL_PRIORITY; - var $use_queue = true; - - /** @var \phpbb\template\template */ - protected $template; - - /** - * Constructor - */ - function __construct($use_queue = true) - { - global $config; - - $this->use_queue = (!$config['email_package_size']) ? false : $use_queue; - $this->subject = ''; - } - - /** - * Resets all the data (address, template file, etc etc) to default - */ - function reset() - { - $this->addresses = $this->extra_headers = array(); - $this->msg = $this->replyto = $this->from = ''; - $this->mail_priority = MAIL_NORMAL_PRIORITY; - } - - /** - * Set addresses for to/im as available - * - * @param array $user User row - */ - function set_addresses($user) - { - if (isset($user['user_email']) && $user['user_email']) - { - $this->to($user['user_email'], (isset($user['username']) ? $user['username'] : '')); - } - - if (isset($user['user_jabber']) && $user['user_jabber']) - { - $this->im($user['user_jabber'], (isset($user['username']) ? $user['username'] : '')); - } - } - - /** - * Sets an email address to send to - */ - function to($address, $realname = '') - { - global $config; - - if (!trim($address)) - { - return; - } - - $pos = isset($this->addresses['to']) ? count($this->addresses['to']) : 0; - - $this->addresses['to'][$pos]['email'] = trim($address); - - // If empty sendmail_path on windows, PHP changes the to line - if (!$config['smtp_delivery'] && DIRECTORY_SEPARATOR == '\\') - { - $this->addresses['to'][$pos]['name'] = ''; - } - else - { - $this->addresses['to'][$pos]['name'] = trim($realname); - } - } - - /** - * Sets an cc address to send to - */ - function cc($address, $realname = '') - { - if (!trim($address)) - { - return; - } - - $pos = isset($this->addresses['cc']) ? count($this->addresses['cc']) : 0; - $this->addresses['cc'][$pos]['email'] = trim($address); - $this->addresses['cc'][$pos]['name'] = trim($realname); - } - - /** - * Sets an bcc address to send to - */ - function bcc($address, $realname = '') - { - if (!trim($address)) - { - return; - } - - $pos = isset($this->addresses['bcc']) ? count($this->addresses['bcc']) : 0; - $this->addresses['bcc'][$pos]['email'] = trim($address); - $this->addresses['bcc'][$pos]['name'] = trim($realname); - } - - /** - * Sets a im contact to send to - */ - function im($address, $realname = '') - { - // IM-Addresses could be empty - if (!trim($address)) - { - return; - } - - $pos = isset($this->addresses['im']) ? count($this->addresses['im']) : 0; - $this->addresses['im'][$pos]['uid'] = trim($address); - $this->addresses['im'][$pos]['name'] = trim($realname); - } - - /** - * Set the reply to address - */ - function replyto($address) - { - $this->replyto = trim($address); - } - - /** - * Set the from address - */ - function from($address) - { - $this->from = trim($address); - } - - /** - * set up subject for mail - */ - function subject($subject = '') - { - $this->subject = trim($subject); - } - - /** - * set up extra mail headers - */ - function headers($headers) - { - $this->extra_headers[] = trim($headers); - } - - /** - * Adds X-AntiAbuse headers - * - * @param array $config Configuration array - * @param user $user A user object - * - * @return null - */ - function anti_abuse_headers($config, $user) - { - $this->headers('X-AntiAbuse: Board servername - ' . mail_encode($config['server_name'])); - $this->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']); - $this->headers('X-AntiAbuse: Username - ' . mail_encode($user->data['username'])); - $this->headers('X-AntiAbuse: User IP - ' . $user->ip); - } - - /** - * Set the email priority - */ - function set_mail_priority($priority = MAIL_NORMAL_PRIORITY) - { - $this->mail_priority = $priority; - } - - /** - * Set email template to use - */ - function template($template_file, $template_lang = '', $template_path = '', $template_dir_prefix = '') - { - global $config, $phpbb_root_path, $user; - - $template_dir_prefix = (!$template_dir_prefix || $template_dir_prefix[0] === '/') ? $template_dir_prefix : '/' . $template_dir_prefix; - - $this->setup_template(); - - if (!trim($template_file)) - { - trigger_error('No template file for emailing set.', E_USER_ERROR); - } - - if (!trim($template_lang)) - { - // fall back to board default language if the user's language is - // missing $template_file. If this does not exist either, - // $this->template->set_filenames will do a trigger_error - $template_lang = basename($config['default_lang']); - } - - $ext_template_paths = array( - array( - 'name' => $template_lang . '_email', - 'ext_path' => 'language/' . $template_lang . '/email' . $template_dir_prefix, - ), - ); - - if ($template_path) - { - $template_paths = array( - $template_path . $template_dir_prefix, - ); - } - else - { - $template_path = (!empty($user->lang_path)) ? $user->lang_path : $phpbb_root_path . 'language/'; - $template_path .= $template_lang . '/email'; - - $template_paths = array( - $template_path . $template_dir_prefix, - ); - - $board_language = basename($config['default_lang']); - - // we can only specify default language fallback when the path is not a custom one for which we - // do not know the default language alternative - if ($template_lang !== $board_language) - { - $fallback_template_path = (!empty($user->lang_path)) ? $user->lang_path : $phpbb_root_path . 'language/'; - $fallback_template_path .= $board_language . '/email'; - - $template_paths[] = $fallback_template_path . $template_dir_prefix; - - $ext_template_paths[] = array( - 'name' => $board_language . '_email', - 'ext_path' => 'language/' . $board_language . '/email' . $template_dir_prefix, - ); - } - // If everything fails just fall back to en template - if ($template_lang !== 'en' && $board_language !== 'en') - { - $fallback_template_path = (!empty($user->lang_path)) ? $user->lang_path : $phpbb_root_path . 'language/'; - $fallback_template_path .= 'en/email'; - - $template_paths[] = $fallback_template_path . $template_dir_prefix; - - $ext_template_paths[] = array( - 'name' => 'en_email', - 'ext_path' => 'language/en/email' . $template_dir_prefix, - ); - } - } - - $this->set_template_paths($ext_template_paths, $template_paths); - - $this->template->set_filenames(array( - 'body' => $template_file . '.txt', - )); - - return true; - } - - /** - * assign variables to email template - */ - function assign_vars($vars) - { - $this->setup_template(); - - $this->template->assign_vars($vars); - } - - function assign_block_vars($blockname, $vars) - { - $this->setup_template(); - - $this->template->assign_block_vars($blockname, $vars); - } - - /** - * Send the mail out to the recipients set previously in var $this->addresses - * - * @param int $method User notification method NOTIFY_EMAIL|NOTIFY_IM|NOTIFY_BOTH - * @param bool $break Flag indicating if the function only formats the subject - * and the message without sending it - * - * @return bool - */ - function send($method = NOTIFY_EMAIL, $break = false) - { - global $config, $user, $phpbb_dispatcher; - - // We add some standard variables we always use, no need to specify them always - $this->assign_vars(array( - 'U_BOARD' => generate_board_url(), - 'EMAIL_SIG' => str_replace('
', "\n", "-- \n" . htmlspecialchars_decode($config['board_email_sig'])), - 'SITENAME' => htmlspecialchars_decode($config['sitename']), - )); - - $subject = $this->subject; - $template = $this->template; - /** - * Event to modify the template before parsing - * - * @event core.modify_notification_template - * @var int method User notification method NOTIFY_EMAIL|NOTIFY_IM|NOTIFY_BOTH - * @var bool break Flag indicating if the function only formats the subject - * and the message without sending it - * @var string subject The message subject - * @var \phpbb\template\template template The (readonly) template object - * @since 3.2.4-RC1 - */ - $vars = array('method', 'break', 'subject', 'template'); - extract($phpbb_dispatcher->trigger_event('core.modify_notification_template', compact($vars))); - - // Parse message through template - $message = trim($this->template->assign_display('body')); - - /** - * Event to modify notification message text after parsing - * - * @event core.modify_notification_message - * @var int method User notification method NOTIFY_EMAIL|NOTIFY_IM|NOTIFY_BOTH - * @var bool break Flag indicating if the function only formats the subject - * and the message without sending it - * @var string subject The message subject - * @var string message The message text - * @since 3.1.11-RC1 - */ - $vars = array('method', 'break', 'subject', 'message'); - extract($phpbb_dispatcher->trigger_event('core.modify_notification_message', compact($vars))); - - $this->subject = $subject; - $this->msg = $message; - unset($subject, $message, $template); - - // Because we use \n for newlines in the body message we need to fix line encoding errors for those admins who uploaded email template files in the wrong encoding - $this->msg = str_replace("\r\n", "\n", $this->msg); - - // We now try and pull a subject from the email body ... if it exists, - // do this here because the subject may contain a variable - $drop_header = ''; - $match = array(); - if (preg_match('#^(Subject:(.*?))$#m', $this->msg, $match)) - { - $this->subject = (trim($match[2]) != '') ? trim($match[2]) : (($this->subject != '') ? $this->subject : $user->lang['NO_EMAIL_SUBJECT']); - $drop_header .= '[\r\n]*?' . preg_quote($match[1], '#'); - } - else - { - $this->subject = (($this->subject != '') ? $this->subject : $user->lang['NO_EMAIL_SUBJECT']); - } - - if (preg_match('#^(List-Unsubscribe:(.*?))$#m', $this->msg, $match)) - { - $this->extra_headers[] = $match[1]; - $drop_header .= '[\r\n]*?' . preg_quote($match[1], '#'); - } - - if ($drop_header) - { - $this->msg = trim(preg_replace('#' . $drop_header . '#s', '', $this->msg)); - } - - if ($break) - { - return true; - } - - switch ($method) - { - case NOTIFY_EMAIL: - $result = $this->msg_email(); - break; - - case NOTIFY_IM: - $result = $this->msg_jabber(); - break; - - case NOTIFY_BOTH: - $result = $this->msg_email(); - $this->msg_jabber(); - break; - } - - $this->reset(); - return $result; - } - - /** - * Add error message to log - */ - function error($type, $msg) - { - global $user, $config, $request, $phpbb_log; - - // Session doesn't exist, create it - if (!isset($user->session_id) || $user->session_id === '') - { - $user->session_begin(); - } - - $calling_page = htmlspecialchars_decode($request->server('PHP_SELF')); - - switch ($type) - { - case 'EMAIL': - $message = 'EMAIL/' . (($config['smtp_delivery']) ? 'SMTP' : 'PHP/mail()') . ''; - break; - - default: - $message = "$type"; - break; - } - - $message .= '
' . htmlspecialchars($calling_page) . '

' . $msg . '
'; - $phpbb_log->add('critical', $user->data['user_id'], $user->ip, 'LOG_ERROR_' . $type, false, array($message)); - } - - /** - * Save to queue - */ - function save_queue() - { - global $config; - - if ($config['email_package_size'] && $this->use_queue && !empty($this->queue)) - { - $this->queue->save(); - return; - } - } - - /** - * Generates a valid message id to be used in emails - * - * @return string message id - */ - function generate_message_id() - { - global $config, $request; - - $domain = ($config['server_name']) ?: $request->server('SERVER_NAME', 'phpbb.generated'); - - return md5(unique_id(time())) . '@' . $domain; - } - - /** - * Return email header - */ - function build_header($to, $cc, $bcc) - { - global $config, $phpbb_dispatcher; - - // We could use keys here, but we won't do this for 3.0.x to retain backwards compatibility - $headers = array(); - - $headers[] = 'From: ' . $this->from; - - if ($cc) - { - $headers[] = 'Cc: ' . $cc; - } - - if ($bcc) - { - $headers[] = 'Bcc: ' . $bcc; - } - - $headers[] = 'Reply-To: ' . $this->replyto; - $headers[] = 'Return-Path: <' . $config['board_email'] . '>'; - $headers[] = 'Sender: <' . $config['board_email'] . '>'; - $headers[] = 'MIME-Version: 1.0'; - $headers[] = 'Message-ID: <' . $this->generate_message_id() . '>'; - $headers[] = 'Date: ' . date('r', time()); - $headers[] = 'Content-Type: text/plain; charset=UTF-8'; // format=flowed - $headers[] = 'Content-Transfer-Encoding: 8bit'; // 7bit - - $headers[] = 'X-Priority: ' . $this->mail_priority; - $headers[] = 'X-MSMail-Priority: ' . (($this->mail_priority == MAIL_LOW_PRIORITY) ? 'Low' : (($this->mail_priority == MAIL_NORMAL_PRIORITY) ? 'Normal' : 'High')); - $headers[] = 'X-Mailer: phpBB3'; - $headers[] = 'X-MimeOLE: phpBB3'; - $headers[] = 'X-phpBB-Origin: phpbb://' . str_replace(array('http://', 'https://'), array('', ''), generate_board_url()); - - /** - * Event to modify email header entries - * - * @event core.modify_email_headers - * @var array headers Array containing email header entries - * @since 3.1.11-RC1 - */ - $vars = array('headers'); - extract($phpbb_dispatcher->trigger_event('core.modify_email_headers', compact($vars))); - - if (count($this->extra_headers)) - { - $headers = array_merge($headers, $this->extra_headers); - } - - return $headers; - } - - /** - * Send out emails - */ - function msg_email() - { - global $config, $phpbb_dispatcher; - - if (empty($config['email_enable'])) - { - return false; - } - - // Addresses to send to? - if (empty($this->addresses) || (empty($this->addresses['to']) && empty($this->addresses['cc']) && empty($this->addresses['bcc']))) - { - // Send was successful. ;) - return true; - } - - $use_queue = false; - if ($config['email_package_size'] && $this->use_queue) - { - if (empty($this->queue)) - { - $this->queue = new queue(); - $this->queue->init('email', $config['email_package_size']); - } - $use_queue = true; - } - - $contact_name = htmlspecialchars_decode($config['board_contact_name']); - $board_contact = (($contact_name !== '') ? '"' . mail_encode($contact_name) . '" ' : '') . '<' . $config['board_contact'] . '>'; - - $break = false; - $addresses = $this->addresses; - $subject = $this->subject; - $msg = $this->msg; - /** - * Event to send message via external transport - * - * @event core.notification_message_email - * @var bool break Flag indicating if the function return after hook - * @var array addresses The message recipients - * @var string subject The message subject - * @var string msg The message text - * @since 3.2.4-RC1 - */ - $vars = array( - 'break', - 'addresses', - 'subject', - 'msg', - ); - extract($phpbb_dispatcher->trigger_event('core.notification_message_email', compact($vars))); - - if ($break) - { - return true; - } - - if (empty($this->replyto)) - { - $this->replyto = $board_contact; - } - - if (empty($this->from)) - { - $this->from = $board_contact; - } - - $encode_eol = ($config['smtp_delivery']) ? "\r\n" : PHP_EOL; - - // Build to, cc and bcc strings - $to = $cc = $bcc = ''; - foreach ($this->addresses as $type => $address_ary) - { - if ($type == 'im') - { - continue; - } - - foreach ($address_ary as $which_ary) - { - ${$type} .= ((${$type} != '') ? ', ' : '') . (($which_ary['name'] != '') ? mail_encode($which_ary['name'], $encode_eol) . ' <' . $which_ary['email'] . '>' : $which_ary['email']); - } - } - - // Build header - $headers = $this->build_header($to, $cc, $bcc); - - // Send message ... - if (!$use_queue) - { - $mail_to = ($to == '') ? 'undisclosed-recipients:;' : $to; - $err_msg = ''; - - if ($config['smtp_delivery']) - { - $result = smtpmail($this->addresses, mail_encode($this->subject), wordwrap(utf8_wordwrap($this->msg), 997, "\n", true), $err_msg, $headers); - } - else - { - $result = phpbb_mail($mail_to, $this->subject, $this->msg, $headers, PHP_EOL, $err_msg); - } - - if (!$result) - { - $this->error('EMAIL', $err_msg); - return false; - } - } - else - { - $this->queue->put('email', array( - 'to' => $to, - 'addresses' => $this->addresses, - 'subject' => $this->subject, - 'msg' => $this->msg, - 'headers' => $headers) - ); - } - - return true; - } - - /** - * Send jabber message out - */ - function msg_jabber() - { - global $config, $user, $phpbb_root_path, $phpEx; - - if (empty($config['jab_enable']) || empty($config['jab_host']) || empty($config['jab_username']) || empty($config['jab_password'])) - { - return false; - } - - if (empty($this->addresses['im'])) - { - // Send was successful. ;) - return true; - } - - $use_queue = false; - if ($config['jab_package_size'] && $this->use_queue) - { - if (empty($this->queue)) - { - $this->queue = new queue(); - $this->queue->init('jabber', $config['jab_package_size']); - } - $use_queue = true; - } - - $addresses = array(); - foreach ($this->addresses['im'] as $type => $uid_ary) - { - $addresses[] = $uid_ary['uid']; - } - $addresses = array_unique($addresses); - - if (!$use_queue) - { - include_once($phpbb_root_path . 'includes/functions_jabber.' . $phpEx); - $this->jabber = new jabber($config['jab_host'], $config['jab_port'], $config['jab_username'], htmlspecialchars_decode($config['jab_password']), $config['jab_use_ssl'], $config['jab_verify_peer'], $config['jab_verify_peer_name'], $config['jab_allow_self_signed']); - - if (!$this->jabber->connect()) - { - $this->error('JABBER', $user->lang['ERR_JAB_CONNECT'] . '
' . $this->jabber->get_log()); - return false; - } - - if (!$this->jabber->login()) - { - $this->error('JABBER', $user->lang['ERR_JAB_AUTH'] . '
' . $this->jabber->get_log()); - return false; - } - - foreach ($addresses as $address) - { - $this->jabber->send_message($address, $this->msg, $this->subject); - } - - $this->jabber->disconnect(); - } - else - { - $this->queue->put('jabber', array( - 'addresses' => $addresses, - 'subject' => $this->subject, - 'msg' => $this->msg) - ); - } - unset($addresses); - return true; - } - - /** - * Setup template engine - */ - protected function setup_template() - { - global $phpbb_container, $phpbb_dispatcher; - - if ($this->template instanceof \phpbb\template\template) - { - return; - } - - $template_environment = new \phpbb\template\twig\environment( - $phpbb_container->get('config'), - $phpbb_container->get('filesystem'), - $phpbb_container->get('path_helper'), - $phpbb_container->getParameter('core.template.cache_path'), - $phpbb_container->get('ext.manager'), - new \phpbb\template\twig\loader( - $phpbb_container->get('filesystem') - ), - $phpbb_dispatcher, - array() - ); - $template_environment->setLexer($phpbb_container->get('template.twig.lexer')); - - $this->template = new \phpbb\template\twig\twig( - $phpbb_container->get('path_helper'), - $phpbb_container->get('config'), - new \phpbb\template\context(), - $template_environment, - $phpbb_container->getParameter('core.template.cache_path'), - $phpbb_container->get('user'), - $phpbb_container->get('template.twig.extensions.collection'), - $phpbb_container->get('ext.manager') - ); - } - - /** - * Set template paths to load - */ - protected function set_template_paths($path_name, $paths) - { - $this->setup_template(); - - $this->template->set_custom_style($path_name, $paths); - } -} - -/** -* handling email and jabber queue -*/ -class queue -{ - var $data = array(); - var $queue_data = array(); - var $package_size = 0; - var $cache_file = ''; - var $eol = "\n"; - - /** - * @var \phpbb\filesystem\filesystem_interface - */ - protected $filesystem; - - /** - * constructor - */ - function __construct() - { - global $phpEx, $phpbb_root_path, $phpbb_filesystem, $phpbb_container; - - $this->data = array(); - $this->cache_file = $phpbb_container->getParameter('core.cache_dir') . "queue.$phpEx"; - $this->filesystem = $phpbb_filesystem; - } - - /** - * Init a queue object - */ - function init($object, $package_size) - { - $this->data[$object] = array(); - $this->data[$object]['package_size'] = $package_size; - $this->data[$object]['data'] = array(); - } - - /** - * Put object in queue - */ - function put($object, $scope) - { - $this->data[$object]['data'][] = $scope; - } - - /** - * Process queue - * Using lock file - */ - function process() - { - global $config, $phpEx, $phpbb_root_path, $user, $phpbb_dispatcher; - - $lock = new \phpbb\lock\flock($this->cache_file); - $lock->acquire(); - - // avoid races, check file existence once - $have_cache_file = file_exists($this->cache_file); - if (!$have_cache_file || $config['last_queue_run'] > time() - $config['queue_interval']) - { - if (!$have_cache_file) - { - $config->set('last_queue_run', time(), false); - } - - $lock->release(); - return; - } - - $config->set('last_queue_run', time(), false); - - include($this->cache_file); - - foreach ($this->queue_data as $object => $data_ary) - { - @set_time_limit(0); - - if (!isset($data_ary['package_size'])) - { - $data_ary['package_size'] = 0; - } - - $package_size = $data_ary['package_size']; - $num_items = (!$package_size || count($data_ary['data']) < $package_size) ? count($data_ary['data']) : $package_size; - - /* - * This code is commented out because it causes problems on some web hosts. - * The core problem is rather restrictive email sending limits. - * This code is nly useful if you have no such restrictions from the - * web host and the package size setting is wrong. - - // If the amount of emails to be sent is way more than package_size than we need to increase it to prevent backlogs... - if (count($data_ary['data']) > $package_size * 2.5) - { - $num_items = count($data_ary['data']); - } - */ - - switch ($object) - { - case 'email': - // Delete the email queued objects if mailing is disabled - if (!$config['email_enable']) - { - unset($this->queue_data['email']); - continue 2; - } - break; - - case 'jabber': - if (!$config['jab_enable']) - { - unset($this->queue_data['jabber']); - continue 2; - } - - include_once($phpbb_root_path . 'includes/functions_jabber.' . $phpEx); - $this->jabber = new jabber($config['jab_host'], $config['jab_port'], $config['jab_username'], htmlspecialchars_decode($config['jab_password']), $config['jab_use_ssl'], $config['jab_verify_peer'], $config['jab_verify_peer_name'], $config['jab_allow_self_signed']); - - if (!$this->jabber->connect()) - { - $messenger = new messenger(); - $messenger->error('JABBER', $user->lang['ERR_JAB_CONNECT']); - continue 2; - } - - if (!$this->jabber->login()) - { - $messenger = new messenger(); - $messenger->error('JABBER', $user->lang['ERR_JAB_AUTH']); - continue 2; - } - - break; - - default: - $lock->release(); - return; - } - - for ($i = 0; $i < $num_items; $i++) - { - // Make variables available... - extract(array_shift($this->queue_data[$object]['data'])); - - switch ($object) - { - case 'email': - $break = false; - /** - * Event to send message via external transport - * - * @event core.notification_message_process - * @var bool break Flag indicating if the function return after hook - * @var array addresses The message recipients - * @var string subject The message subject - * @var string msg The message text - * @since 3.2.4-RC1 - */ - $vars = array( - 'break', - 'addresses', - 'subject', - 'msg', - ); - extract($phpbb_dispatcher->trigger_event('core.notification_message_process', compact($vars))); - - if (!$break) - { - $err_msg = ''; - $to = (!$to) ? 'undisclosed-recipients:;' : $to; - - if ($config['smtp_delivery']) - { - $result = smtpmail($addresses, mail_encode($subject), wordwrap(utf8_wordwrap($msg), 997, "\n", true), $err_msg, $headers); - } - else - { - $result = phpbb_mail($to, $subject, $msg, $headers, PHP_EOL, $err_msg); - } - - if (!$result) - { - $messenger = new messenger(); - $messenger->error('EMAIL', $err_msg); - continue 2; - } - } - break; - - case 'jabber': - foreach ($addresses as $address) - { - if ($this->jabber->send_message($address, $msg, $subject) === false) - { - $messenger = new messenger(); - $messenger->error('JABBER', $this->jabber->get_log()); - continue 3; - } - } - break; - } - } - - // No more data for this object? Unset it - if (!count($this->queue_data[$object]['data'])) - { - unset($this->queue_data[$object]); - } - - // Post-object processing - switch ($object) - { - case 'jabber': - // Hang about a couple of secs to ensure the messages are - // handled, then disconnect - $this->jabber->disconnect(); - break; - } - } - - if (!count($this->queue_data)) - { - @unlink($this->cache_file); - } - else - { - if ($fp = @fopen($this->cache_file, 'wb')) - { - fwrite($fp, "queue_data = unserialize(" . var_export(serialize($this->queue_data), true) . ");\n\n?>"); - fclose($fp); - - if (function_exists('opcache_invalidate')) - { - @opcache_invalidate($this->cache_file); - } - - try - { - $this->filesystem->phpbb_chmod($this->cache_file, CHMOD_READ | CHMOD_WRITE); - } - catch (\phpbb\filesystem\exception\filesystem_exception $e) - { - // Do nothing - } - } - } - - $lock->release(); - } - - /** - * Save queue - */ - function save() - { - if (!count($this->data)) - { - return; - } - - $lock = new \phpbb\lock\flock($this->cache_file); - $lock->acquire(); - - if (file_exists($this->cache_file)) - { - include($this->cache_file); - - foreach ($this->queue_data as $object => $data_ary) - { - if (isset($this->data[$object]) && count($this->data[$object])) - { - $this->data[$object]['data'] = array_merge($data_ary['data'], $this->data[$object]['data']); - } - else - { - $this->data[$object]['data'] = $data_ary['data']; - } - } - } - - if ($fp = @fopen($this->cache_file, 'w')) - { - fwrite($fp, "queue_data = unserialize(" . var_export(serialize($this->data), true) . ");\n\n?>"); - fclose($fp); - - if (function_exists('opcache_invalidate')) - { - @opcache_invalidate($this->cache_file); - } - - try - { - $this->filesystem->phpbb_chmod($this->cache_file, CHMOD_READ | CHMOD_WRITE); - } - catch (\phpbb\filesystem\exception\filesystem_exception $e) - { - // Do nothing - } - - $this->data = array(); - } - - $lock->release(); - } -} - -/** -* Replacement or substitute for PHP's mail command -*/ -function smtpmail($addresses, $subject, $message, &$err_msg, $headers = false) -{ - global $config, $user; - - // Fix any bare linefeeds in the message to make it RFC821 Compliant. - $message = preg_replace("#(?lang['NO_EMAIL_SUBJECT'])) ? $user->lang['NO_EMAIL_SUBJECT'] : 'No email subject specified'; - return false; - } - - if (trim($message) == '') - { - $err_msg = (isset($user->lang['NO_EMAIL_MESSAGE'])) ? $user->lang['NO_EMAIL_MESSAGE'] : 'Email message was blank'; - return false; - } - - $mail_rcpt = $mail_to = $mail_cc = array(); - - // Build correct addresses for RCPT TO command and the client side display (TO, CC) - if (isset($addresses['to']) && count($addresses['to'])) - { - foreach ($addresses['to'] as $which_ary) - { - $mail_to[] = ($which_ary['name'] != '') ? mail_encode(trim($which_ary['name'])) . ' <' . trim($which_ary['email']) . '>' : '<' . trim($which_ary['email']) . '>'; - $mail_rcpt['to'][] = '<' . trim($which_ary['email']) . '>'; - } - } - - if (isset($addresses['bcc']) && count($addresses['bcc'])) - { - foreach ($addresses['bcc'] as $which_ary) - { - $mail_rcpt['bcc'][] = '<' . trim($which_ary['email']) . '>'; - } - } - - if (isset($addresses['cc']) && count($addresses['cc'])) - { - foreach ($addresses['cc'] as $which_ary) - { - $mail_cc[] = ($which_ary['name'] != '') ? mail_encode(trim($which_ary['name'])) . ' <' . trim($which_ary['email']) . '>' : '<' . trim($which_ary['email']) . '>'; - $mail_rcpt['cc'][] = '<' . trim($which_ary['email']) . '>'; - } - } - - $smtp = new smtp_class(); - - $errno = 0; - $errstr = ''; - - $smtp->add_backtrace('Connecting to ' . $config['smtp_host'] . ':' . $config['smtp_port']); - - // Ok we have error checked as much as we can to this point let's get on it already. - if (!class_exists('\phpbb\error_collector')) - { - global $phpbb_root_path, $phpEx; - include($phpbb_root_path . 'includes/error_collector.' . $phpEx); - } - $collector = new \phpbb\error_collector; - $collector->install(); - - $options = array(); - $verify_peer = (bool) $config['smtp_verify_peer']; - $verify_peer_name = (bool) $config['smtp_verify_peer_name']; - $allow_self_signed = (bool) $config['smtp_allow_self_signed']; - $remote_socket = $config['smtp_host'] . ':' . $config['smtp_port']; - - // Set ssl context options, see http://php.net/manual/en/context.ssl.php - $options['ssl'] = array('verify_peer' => $verify_peer, 'verify_peer_name' => $verify_peer_name, 'allow_self_signed' => $allow_self_signed); - $socket_context = stream_context_create($options); - - $smtp->socket = @stream_socket_client($remote_socket, $errno, $errstr, 20, STREAM_CLIENT_CONNECT, $socket_context); - $collector->uninstall(); - $error_contents = $collector->format_errors(); - - if (!$smtp->socket) - { - if ($errstr) - { - $errstr = utf8_convert_message($errstr); - } - - $err_msg = (isset($user->lang['NO_CONNECT_TO_SMTP_HOST'])) ? sprintf($user->lang['NO_CONNECT_TO_SMTP_HOST'], $errno, $errstr) : "Could not connect to smtp host : $errno : $errstr"; - $err_msg .= ($error_contents) ? '

' . htmlspecialchars($error_contents) : ''; - return false; - } - - // Wait for reply - if ($err_msg = $smtp->server_parse('220', __LINE__)) - { - $smtp->close_session($err_msg); - return false; - } - - // Let me in. This function handles the complete authentication process - if ($err_msg = $smtp->log_into_server($config['smtp_host'], $config['smtp_username'], htmlspecialchars_decode($config['smtp_password']), $config['smtp_auth_method'])) - { - $smtp->close_session($err_msg); - return false; - } - - // From this point onward most server response codes should be 250 - // Specify who the mail is from.... - $smtp->server_send('MAIL FROM:<' . $config['board_email'] . '>'); - if ($err_msg = $smtp->server_parse('250', __LINE__)) - { - $smtp->close_session($err_msg); - return false; - } - - // Specify each user to send to and build to header. - $to_header = implode(', ', $mail_to); - $cc_header = implode(', ', $mail_cc); - - // Now tell the MTA to send the Message to the following people... [TO, BCC, CC] - $rcpt = false; - foreach ($mail_rcpt as $type => $mail_to_addresses) - { - foreach ($mail_to_addresses as $mail_to_address) - { - // Add an additional bit of error checking to the To field. - if (preg_match('#[^ ]+\@[^ ]+#', $mail_to_address)) - { - $smtp->server_send("RCPT TO:$mail_to_address"); - if ($err_msg = $smtp->server_parse('250', __LINE__)) - { - // We continue... if users are not resolved we do not care - if ($smtp->numeric_response_code != 550) - { - $smtp->close_session($err_msg); - return false; - } - } - else - { - $rcpt = true; - } - } - } - } - - // We try to send messages even if a few people do not seem to have valid email addresses, but if no one has, we have to exit here. - if (!$rcpt) - { - $user->session_begin(); - $err_msg .= '

'; - $err_msg .= (isset($user->lang['INVALID_EMAIL_LOG'])) ? sprintf($user->lang['INVALID_EMAIL_LOG'], htmlspecialchars($mail_to_address)) : '' . htmlspecialchars($mail_to_address) . ' possibly an invalid email address?'; - $smtp->close_session($err_msg); - return false; - } - - // Ok now we tell the server we are ready to start sending data - $smtp->server_send('DATA'); - - // This is the last response code we look for until the end of the message. - if ($err_msg = $smtp->server_parse('354', __LINE__)) - { - $smtp->close_session($err_msg); - return false; - } - - // Send the Subject Line... - $smtp->server_send("Subject: $subject"); - - // Now the To Header. - $to_header = ($to_header == '') ? 'undisclosed-recipients:;' : $to_header; - $smtp->server_send("To: $to_header"); - - // Now the CC Header. - if ($cc_header != '') - { - $smtp->server_send("CC: $cc_header"); - } - - // Now any custom headers.... - if ($headers !== false) - { - $smtp->server_send("$headers\r\n"); - } - - // Ok now we are ready for the message... - $smtp->server_send($message); - - // Ok the all the ingredients are mixed in let's cook this puppy... - $smtp->server_send('.'); - if ($err_msg = $smtp->server_parse('250', __LINE__)) - { - $smtp->close_session($err_msg); - return false; - } - - // Now tell the server we are done and close the socket... - $smtp->server_send('QUIT'); - $smtp->close_session($err_msg); - - return true; -} - -/** -* SMTP Class -* Auth Mechanisms originally taken from the AUTH Modules found within the PHP Extension and Application Repository (PEAR) -* See docs/AUTHORS for more details -*/ -class smtp_class -{ - var $server_response = ''; - var $socket = 0; - protected $socket_tls = false; - var $responses = array(); - var $commands = array(); - var $numeric_response_code = 0; - - var $backtrace = false; - var $backtrace_log = array(); - - function __construct() - { - // Always create a backtrace for admins to identify SMTP problems - $this->backtrace = true; - $this->backtrace_log = array(); - } - - /** - * Add backtrace message for debugging - */ - function add_backtrace($message) - { - if ($this->backtrace) - { - $this->backtrace_log[] = utf8_htmlspecialchars($message); - } - } - - /** - * Send command to smtp server - */ - function server_send($command, $private_info = false) - { - fputs($this->socket, $command . "\r\n"); - - (!$private_info) ? $this->add_backtrace("# $command") : $this->add_backtrace('# Omitting sensitive information'); - - // We could put additional code here - } - - /** - * We use the line to give the support people an indication at which command the error occurred - */ - function server_parse($response, $line) - { - global $user; - - $this->server_response = ''; - $this->responses = array(); - $this->numeric_response_code = 0; - - while (substr($this->server_response, 3, 1) != ' ') - { - if (!($this->server_response = fgets($this->socket, 256))) - { - return (isset($user->lang['NO_EMAIL_RESPONSE_CODE'])) ? $user->lang['NO_EMAIL_RESPONSE_CODE'] : 'Could not get mail server response codes'; - } - $this->responses[] = substr(rtrim($this->server_response), 4); - $this->numeric_response_code = (int) substr($this->server_response, 0, 3); - - $this->add_backtrace("LINE: $line <- {$this->server_response}"); - } - - if (!(substr($this->server_response, 0, 3) == $response)) - { - $this->numeric_response_code = (int) substr($this->server_response, 0, 3); - return (isset($user->lang['EMAIL_SMTP_ERROR_RESPONSE'])) ? sprintf($user->lang['EMAIL_SMTP_ERROR_RESPONSE'], $line, $this->server_response) : "Ran into problems sending Mail at Line $line. Response: $this->server_response"; - } - - return 0; - } - - /** - * Close session - */ - function close_session(&$err_msg) - { - fclose($this->socket); - - if ($this->backtrace) - { - $message = '

Backtrace

' . implode('
', $this->backtrace_log) . '

'; - $err_msg .= $message; - } - } - - /** - * Log into server and get possible auth codes if neccessary - */ - function log_into_server($hostname, $username, $password, $default_auth_method) - { - global $user; - - // Here we try to determine the *real* hostname (reverse DNS entry preferrably) - $local_host = $user->host; - - if (function_exists('php_uname')) - { - $local_host = php_uname('n'); - - // Able to resolve name to IP - if (($addr = @gethostbyname($local_host)) !== $local_host) - { - // Able to resolve IP back to name - if (($name = @gethostbyaddr($addr)) !== $addr) - { - $local_host = $name; - } - } - } - - // If we are authenticating through pop-before-smtp, we - // have to login ones before we get authenticated - // NOTE: on some configurations the time between an update of the auth database takes so - // long that the first email send does not work. This is not a biggie on a live board (only - // the install mail will most likely fail) - but on a dynamic ip connection this might produce - // severe problems and is not fixable! - if ($default_auth_method == 'POP-BEFORE-SMTP' && $username && $password) - { - global $config; - - $errno = 0; - $errstr = ''; - - $this->server_send("QUIT"); - fclose($this->socket); - - $this->pop_before_smtp($hostname, $username, $password); - $username = $password = $default_auth_method = ''; - - // We need to close the previous session, else the server is not - // able to get our ip for matching... - if (!$this->socket = @fsockopen($config['smtp_host'], $config['smtp_port'], $errno, $errstr, 10)) - { - if ($errstr) - { - $errstr = utf8_convert_message($errstr); - } - - $err_msg = (isset($user->lang['NO_CONNECT_TO_SMTP_HOST'])) ? sprintf($user->lang['NO_CONNECT_TO_SMTP_HOST'], $errno, $errstr) : "Could not connect to smtp host : $errno : $errstr"; - return $err_msg; - } - - // Wait for reply - if ($err_msg = $this->server_parse('220', __LINE__)) - { - $this->close_session($err_msg); - return $err_msg; - } - } - - $hello_result = $this->hello($local_host); - if (!is_null($hello_result)) - { - return $hello_result; - } - - // SMTP STARTTLS (RFC 3207) - if (!$this->socket_tls) - { - $this->socket_tls = $this->starttls(); - - if ($this->socket_tls) - { - // Switched to TLS - // RFC 3207: "The client MUST discard any knowledge obtained from the server, [...]" - // So say hello again - $hello_result = $this->hello($local_host); - - if (!is_null($hello_result)) - { - return $hello_result; - } - } - } - - // If we are not authenticated yet, something might be wrong if no username and passwd passed - if (!$username || !$password) - { - return false; - } - - if (!isset($this->commands['AUTH'])) - { - return (isset($user->lang['SMTP_NO_AUTH_SUPPORT'])) ? $user->lang['SMTP_NO_AUTH_SUPPORT'] : 'SMTP server does not support authentication'; - } - - // Get best authentication method - $available_methods = explode(' ', $this->commands['AUTH']); - - // Define the auth ordering if the default auth method was not found - $auth_methods = array('PLAIN', 'LOGIN', 'CRAM-MD5', 'DIGEST-MD5'); - $method = ''; - - if (in_array($default_auth_method, $available_methods)) - { - $method = $default_auth_method; - } - else - { - foreach ($auth_methods as $_method) - { - if (in_array($_method, $available_methods)) - { - $method = $_method; - break; - } - } - } - - if (!$method) - { - return (isset($user->lang['NO_SUPPORTED_AUTH_METHODS'])) ? $user->lang['NO_SUPPORTED_AUTH_METHODS'] : 'No supported authentication methods'; - } - - $method = strtolower(str_replace('-', '_', $method)); - return $this->$method($username, $password); - } - - /** - * SMTP EHLO/HELO - * - * @return mixed Null if the authentication process is supposed to continue - * False if already authenticated - * Error message (string) otherwise - */ - protected function hello($hostname) - { - // Try EHLO first - $this->server_send("EHLO $hostname"); - if ($err_msg = $this->server_parse('250', __LINE__)) - { - // a 503 response code means that we're already authenticated - if ($this->numeric_response_code == 503) - { - return false; - } - - // If EHLO fails, we try HELO - $this->server_send("HELO $hostname"); - if ($err_msg = $this->server_parse('250', __LINE__)) - { - return ($this->numeric_response_code == 503) ? false : $err_msg; - } - } - - foreach ($this->responses as $response) - { - $response = explode(' ', $response); - $response_code = $response[0]; - unset($response[0]); - $this->commands[$response_code] = implode(' ', $response); - } - } - - /** - * SMTP STARTTLS (RFC 3207) - * - * @return bool Returns true if TLS was started - * Otherwise false - */ - protected function starttls() - { - if (!function_exists('stream_socket_enable_crypto')) - { - return false; - } - - if (!isset($this->commands['STARTTLS'])) - { - return false; - } - - $this->server_send('STARTTLS'); - - if ($err_msg = $this->server_parse('220', __LINE__)) - { - return false; - } - - $result = false; - $stream_meta = stream_get_meta_data($this->socket); - - if (socket_set_blocking($this->socket, 1)) - { - $result = stream_socket_enable_crypto($this->socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT); - socket_set_blocking($this->socket, (int) $stream_meta['blocked']); - } - - return $result; - } - - /** - * Pop before smtp authentication - */ - function pop_before_smtp($hostname, $username, $password) - { - global $user; - - if (!$this->socket = @fsockopen($hostname, 110, $errno, $errstr, 10)) - { - if ($errstr) - { - $errstr = utf8_convert_message($errstr); - } - - return (isset($user->lang['NO_CONNECT_TO_SMTP_HOST'])) ? sprintf($user->lang['NO_CONNECT_TO_SMTP_HOST'], $errno, $errstr) : "Could not connect to smtp host : $errno : $errstr"; - } - - $this->server_send("USER $username", true); - if ($err_msg = $this->server_parse('+OK', __LINE__)) - { - return $err_msg; - } - - $this->server_send("PASS $password", true); - if ($err_msg = $this->server_parse('+OK', __LINE__)) - { - return $err_msg; - } - - $this->server_send('QUIT'); - fclose($this->socket); - - return false; - } - - /** - * Plain authentication method - */ - function plain($username, $password) - { - $this->server_send('AUTH PLAIN'); - if ($err_msg = $this->server_parse('334', __LINE__)) - { - return ($this->numeric_response_code == 503) ? false : $err_msg; - } - - $base64_method_plain = base64_encode("\0" . $username . "\0" . $password); - $this->server_send($base64_method_plain, true); - if ($err_msg = $this->server_parse('235', __LINE__)) - { - return $err_msg; - } - - return false; - } - - /** - * Login authentication method - */ - function login($username, $password) - { - $this->server_send('AUTH LOGIN'); - if ($err_msg = $this->server_parse('334', __LINE__)) - { - return ($this->numeric_response_code == 503) ? false : $err_msg; - } - - $this->server_send(base64_encode($username), true); - if ($err_msg = $this->server_parse('334', __LINE__)) - { - return $err_msg; - } - - $this->server_send(base64_encode($password), true); - if ($err_msg = $this->server_parse('235', __LINE__)) - { - return $err_msg; - } - - return false; - } - - /** - * cram_md5 authentication method - */ - function cram_md5($username, $password) - { - $this->server_send('AUTH CRAM-MD5'); - if ($err_msg = $this->server_parse('334', __LINE__)) - { - return ($this->numeric_response_code == 503) ? false : $err_msg; - } - - $md5_challenge = base64_decode($this->responses[0]); - $password = (strlen($password) > 64) ? pack('H32', md5($password)) : ((strlen($password) < 64) ? str_pad($password, 64, chr(0)) : $password); - $md5_digest = md5((substr($password, 0, 64) ^ str_repeat(chr(0x5C), 64)) . (pack('H32', md5((substr($password, 0, 64) ^ str_repeat(chr(0x36), 64)) . $md5_challenge)))); - - $base64_method_cram_md5 = base64_encode($username . ' ' . $md5_digest); - - $this->server_send($base64_method_cram_md5, true); - if ($err_msg = $this->server_parse('235', __LINE__)) - { - return $err_msg; - } - - return false; - } - - /** - * digest_md5 authentication method - * A real pain in the *** - */ - function digest_md5($username, $password) - { - global $config, $user; - - $this->server_send('AUTH DIGEST-MD5'); - if ($err_msg = $this->server_parse('334', __LINE__)) - { - return ($this->numeric_response_code == 503) ? false : $err_msg; - } - - $md5_challenge = base64_decode($this->responses[0]); - - // Parse the md5 challenge - from AUTH_SASL (PEAR) - $tokens = array(); - while (preg_match('/^([a-z-]+)=("[^"]+(?host; - } - - // Maxbuf - if (empty($tokens['maxbuf'])) - { - $tokens['maxbuf'] = 65536; - } - - // Required: nonce, algorithm - if (empty($tokens['nonce']) || empty($tokens['algorithm'])) - { - $tokens = array(); - } - $md5_challenge = $tokens; - - if (!empty($md5_challenge)) - { - $str = ''; - for ($i = 0; $i < 32; $i++) - { - $str .= chr(mt_rand(0, 255)); - } - $cnonce = base64_encode($str); - - $digest_uri = 'smtp/' . $config['smtp_host']; - - $auth_1 = sprintf('%s:%s:%s', pack('H32', md5(sprintf('%s:%s:%s', $username, $md5_challenge['realm'], $password))), $md5_challenge['nonce'], $cnonce); - $auth_2 = 'AUTHENTICATE:' . $digest_uri; - $response_value = md5(sprintf('%s:%s:00000001:%s:auth:%s', md5($auth_1), $md5_challenge['nonce'], $cnonce, md5($auth_2))); - - $input_string = sprintf('username="%s",realm="%s",nonce="%s",cnonce="%s",nc="00000001",qop=auth,digest-uri="%s",response=%s,%d', $username, $md5_challenge['realm'], $md5_challenge['nonce'], $cnonce, $digest_uri, $response_value, $md5_challenge['maxbuf']); - } - else - { - return (isset($user->lang['INVALID_DIGEST_CHALLENGE'])) ? $user->lang['INVALID_DIGEST_CHALLENGE'] : 'Invalid digest challenge'; - } - - $base64_method_digest_md5 = base64_encode($input_string); - $this->server_send($base64_method_digest_md5, true); - if ($err_msg = $this->server_parse('334', __LINE__)) - { - return $err_msg; - } - - $this->server_send(' '); - if ($err_msg = $this->server_parse('235', __LINE__)) - { - return $err_msg; - } - - return false; - } -} - -/** -* Encodes the given string for proper display in UTF-8. -* -* This version is using base64 encoded data. The downside of this -* is if the mail client does not understand this encoding the user -* is basically doomed with an unreadable subject. -* -* Please note that this version fully supports RFC 2045 section 6.8. -* -* @param string $eol End of line we are using (optional to be backwards compatible) -*/ -function mail_encode($str, $eol = "\r\n") -{ - // define start delimimter, end delimiter and spacer - $start = "=?UTF-8?B?"; - $end = "?="; - $delimiter = "$eol "; - - // Maximum length is 75. $split_length *must* be a multiple of 4, but <= 75 - strlen($start . $delimiter . $end)!!! - $split_length = 60; - $encoded_str = base64_encode($str); - - // If encoded string meets the limits, we just return with the correct data. - if (strlen($encoded_str) <= $split_length) - { - return $start . $encoded_str . $end; - } - - // If there is only ASCII data, we just return what we want, correctly splitting the lines. - if (strlen($str) === utf8_strlen($str)) - { - return $start . implode($end . $delimiter . $start, str_split($encoded_str, $split_length)) . $end; - } - - // UTF-8 data, compose encoded lines - $array = utf8_str_split($str); - $str = ''; - - while (count($array)) - { - $text = ''; - - while (count($array) && intval((strlen($text . $array[0]) + 2) / 3) << 2 <= $split_length) - { - $text .= array_shift($array); - } - - $str .= $start . base64_encode($text) . $end . $delimiter; - } - - return substr($str, 0, -strlen($delimiter)); -} - -/** -* Wrapper for sending out emails with the PHP's mail function -*/ -function phpbb_mail($to, $subject, $msg, $headers, $eol, &$err_msg) -{ - global $config, $phpbb_root_path, $phpEx; - - // We use the EOL character for the OS here because the PHP mail function does not correctly transform line endings. On Windows SMTP is used (SMTP is \r\n), on UNIX a command is used... - // Reference: http://bugs.php.net/bug.php?id=15841 - $headers = implode($eol, $headers); - - if (!class_exists('\phpbb\error_collector')) - { - include($phpbb_root_path . 'includes/error_collector.' . $phpEx); - } - - $collector = new \phpbb\error_collector; - $collector->install(); - - // On some PHP Versions mail() *may* fail if there are newlines within the subject. - // Newlines are used as a delimiter for lines in mail_encode() according to RFC 2045 section 6.8. - // Because PHP can't decide what is wanted we revert back to the non-RFC-compliant way of separating by one space (Use '' as parameter to mail_encode() results in SPACE used) - $additional_parameters = $config['email_force_sender'] ? '-f' . $config['board_email'] : ''; - $result = mail($to, mail_encode($subject, ''), wordwrap(utf8_wordwrap($msg), 997, "\n", true), $headers, $additional_parameters); - - $collector->uninstall(); - $err_msg = $collector->format_errors(); - - return $result; -} diff --git a/install/update/old/includes/functions_module.php b/install/update/old/includes/functions_module.php deleted file mode 100644 index 88dafc4..0000000 --- a/install/update/old/includes/functions_module.php +++ /dev/null @@ -1,1145 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* Class handling all types of 'plugins' (a future term) -*/ -class p_master -{ - var $p_id; - var $p_class; - var $p_name; - var $p_mode; - var $p_parent; - - var $include_path = false; - var $active_module = false; - var $active_module_row_id = false; - var $acl_forum_id = false; - var $module_ary = array(); - - /** - * Constuctor - * Set module include path - */ - function __construct($include_path = false) - { - global $phpbb_root_path; - - $this->include_path = ($include_path !== false) ? $include_path : $phpbb_root_path . 'includes/'; - - // Make sure the path ends with / - if (substr($this->include_path, -1) !== '/') - { - $this->include_path .= '/'; - } - } - - /** - * Set custom include path for modules - * Schema for inclusion is include_path . modulebase - * - * @param string $include_path include path to be used. - * @access public - */ - function set_custom_include_path($include_path) - { - $this->include_path = $include_path; - - // Make sure the path ends with / - if (substr($this->include_path, -1) !== '/') - { - $this->include_path .= '/'; - } - } - - /** - * List modules - * - * This creates a list, stored in $this->module_ary of all available - * modules for the given class (ucp, mcp and acp). Additionally - * $this->module_y_ary is created with indentation information for - * displaying the module list appropriately. Only modules for which - * the user has access rights are included in these lists. - */ - function list_modules($p_class) - { - global $db, $user, $cache; - global $phpbb_dispatcher; - - // Sanitise for future path use, it's escaped as appropriate for queries - $this->p_class = str_replace(array('.', '/', '\\'), '', basename($p_class)); - - // Get cached modules - if (($this->module_cache = $cache->get('_modules_' . $this->p_class)) === false) - { - // Get modules - $sql = 'SELECT * - FROM ' . MODULES_TABLE . " - WHERE module_class = '" . $db->sql_escape($this->p_class) . "' - ORDER BY left_id ASC"; - $result = $db->sql_query($sql); - - $rows = array(); - while ($row = $db->sql_fetchrow($result)) - { - $rows[$row['module_id']] = $row; - } - $db->sql_freeresult($result); - - $this->module_cache = array(); - foreach ($rows as $module_id => $row) - { - $this->module_cache['modules'][] = $row; - $this->module_cache['parents'][$row['module_id']] = $this->get_parents($row['parent_id'], $row['left_id'], $row['right_id'], $rows); - } - unset($rows); - - $cache->put('_modules_' . $this->p_class, $this->module_cache); - } - - if (empty($this->module_cache)) - { - $this->module_cache = array('modules' => array(), 'parents' => array()); - } - - // We "could" build a true tree with this function - maybe mod authors want to use this... - // Functions for traversing and manipulating the tree are not available though - // We might re-structure the module system to use true trees in 3.2.x... - // $tree = $this->build_tree($this->module_cache['modules'], $this->module_cache['parents']); - - // Clean up module cache array to only let survive modules the user can access - $right_id = false; - - $hide_categories = array(); - foreach ($this->module_cache['modules'] as $key => $row) - { - // When the module has no mode (category) we check whether it has visible children - // before listing it as well. - if (!$row['module_mode']) - { - $hide_categories[(int) $row['module_id']] = $key; - } - - // Not allowed to view module? - if (!$this->module_auth_self($row['module_auth'])) - { - unset($this->module_cache['modules'][$key]); - continue; - } - - // Category with no members, ignore - if (!$row['module_basename'] && ($row['left_id'] + 1 == $row['right_id'])) - { - unset($this->module_cache['modules'][$key]); - continue; - } - - // Skip branch - if ($right_id !== false) - { - if ($row['left_id'] < $right_id) - { - unset($this->module_cache['modules'][$key]); - continue; - } - - $right_id = false; - } - - // Not enabled? - if (!$row['module_enabled']) - { - // If category is disabled then disable every child too - unset($this->module_cache['modules'][$key]); - $right_id = $row['right_id']; - continue; - } - - if ($row['module_mode']) - { - // The parent category has a visible child - // So remove it and all its parents from the hide array - unset($hide_categories[(int) $row['parent_id']]); - foreach ($this->module_cache['parents'][$row['module_id']] as $module_id => $row_id) - { - unset($hide_categories[$module_id]); - } - } - } - - foreach ($hide_categories as $module_id => $row_id) - { - unset($this->module_cache['modules'][$row_id]); - } - - // Re-index (this is needed, else we are not able to array_slice later) - $this->module_cache['modules'] = array_merge($this->module_cache['modules']); - - // Include MOD _info files for populating language entries within the menus - $this->add_mod_info($this->p_class); - - // Now build the module array, but exclude completely empty categories... - $right_id = false; - $names = array(); - - foreach ($this->module_cache['modules'] as $key => $row) - { - // Skip branch - if ($right_id !== false) - { - if ($row['left_id'] < $right_id) - { - continue; - } - - $right_id = false; - } - - // Category with no members on their way down (we have to check every level) - if (!$row['module_basename']) - { - $empty_category = true; - - // We go through the branch and look for an activated module - foreach (array_slice($this->module_cache['modules'], $key + 1) as $temp_row) - { - if ($temp_row['left_id'] > $row['left_id'] && $temp_row['left_id'] < $row['right_id']) - { - // Module there - if ($temp_row['module_basename'] && $temp_row['module_enabled']) - { - $empty_category = false; - break; - } - continue; - } - break; - } - - // Skip the branch - if ($empty_category) - { - $right_id = $row['right_id']; - continue; - } - } - - $depth = count($this->module_cache['parents'][$row['module_id']]); - - // We need to prefix the functions to not create a naming conflict - - // Function for building 'url_extra' - $short_name = $this->get_short_name($row['module_basename']); - - $url_func = 'phpbb_module_' . $short_name . '_url'; - if (!function_exists($url_func)) - { - $url_func = '_module_' . $short_name . '_url'; - } - - // Function for building the language name - $lang_func = 'phpbb_module_' . $short_name . '_lang'; - if (!function_exists($lang_func)) - { - $lang_func = '_module_' . $short_name . '_lang'; - } - - // Custom function for calling parameters on module init (for example assigning template variables) - $custom_func = 'phpbb_module_' . $short_name; - if (!function_exists($custom_func)) - { - $custom_func = '_module_' . $short_name; - } - - $names[$row['module_basename'] . '_' . $row['module_mode']][] = true; - - $module_row = array( - 'depth' => $depth, - - 'id' => (int) $row['module_id'], - 'parent' => (int) $row['parent_id'], - 'cat' => ($row['right_id'] > $row['left_id'] + 1) ? true : false, - - 'is_duplicate' => ($row['module_basename'] && count($names[$row['module_basename'] . '_' . $row['module_mode']]) > 1) ? true : false, - - 'name' => (string) $row['module_basename'], - 'mode' => (string) $row['module_mode'], - 'display' => (int) $row['module_display'], - - 'url_extra' => (function_exists($url_func)) ? $url_func($row['module_mode'], $row) : '', - - 'lang' => ($row['module_basename'] && function_exists($lang_func)) ? $lang_func($row['module_mode'], $row['module_langname']) : ((!empty($user->lang[$row['module_langname']])) ? $user->lang[$row['module_langname']] : $row['module_langname']), - 'langname' => $row['module_langname'], - - 'left' => $row['left_id'], - 'right' => $row['right_id'], - ); - - if (function_exists($custom_func)) - { - $custom_func($row['module_mode'], $module_row); - } - - /** - * This event allows to modify parameters for building modules list - * - * @event core.modify_module_row - * @var string url_func Function for building 'url_extra' - * @var string lang_func Function for building the language name - * @var string custom_func Custom function for calling parameters on module init - * @var array row Array holding the basic module data - * @var array module_row Array holding the module display parameters - * @since 3.1.0-b3 - */ - $vars = array('url_func', 'lang_func', 'custom_func', 'row', 'module_row'); - extract($phpbb_dispatcher->trigger_event('core.modify_module_row', compact($vars))); - - $this->module_ary[] = $module_row; - } - - unset($this->module_cache['modules'], $names); - } - - /** - * Check if a certain main module is accessible/loaded - * By giving the module mode you are able to additionally check for only one mode within the main module - * - * @param string $module_basename The module base name, for example logs, reports, main (for the mcp). - * @param mixed $module_mode The module mode to check. If provided the mode will be checked in addition for presence. - * - * @return bool Returns true if module is loaded and accessible, else returns false - */ - function loaded($module_basename, $module_mode = false) - { - if (!$this->is_full_class($module_basename)) - { - $module_basename = $this->p_class . '_' . $module_basename; - } - - if (empty($this->loaded_cache)) - { - $this->loaded_cache = array(); - - foreach ($this->module_ary as $row) - { - if (!$row['name']) - { - continue; - } - - if (!isset($this->loaded_cache[$row['name']])) - { - $this->loaded_cache[$row['name']] = array(); - } - - if (!$row['mode']) - { - continue; - } - - $this->loaded_cache[$row['name']][$row['mode']] = true; - } - } - - if ($module_mode === false) - { - return (isset($this->loaded_cache[$module_basename])) ? true : false; - } - - return (!empty($this->loaded_cache[$module_basename][$module_mode])) ? true : false; - } - - /** - * Check module authorisation. - * - * This is a non-static version that uses $this->acl_forum_id - * for the forum id. - */ - function module_auth_self($module_auth) - { - return self::module_auth($module_auth, $this->acl_forum_id); - } - - /** - * Check module authorisation. - * - * This is a static version, it must be given $forum_id. - * See also module_auth_self. - */ - static function module_auth($module_auth, $forum_id) - { - global $auth, $config; - global $request, $phpbb_extension_manager, $phpbb_dispatcher; - - $module_auth = trim($module_auth); - - // Generally allowed to access module if module_auth is empty - if (!$module_auth) - { - return true; - } - - // With the code below we make sure only those elements get eval'd we really want to be checked - preg_match_all('/(?: - "[^"\\\\]*(?:\\\\.[^"\\\\]*)*" | - \'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\' | - [(),] | - [^\s(),]+)/x', $module_auth, $match); - - // Valid tokens for auth and their replacements - $valid_tokens = array( - 'acl_([a-z0-9_]+)(,\$id)?' => '(int) $auth->acl_get(\'\\1\'\\2)', - '\$id' => '(int) $forum_id', - 'aclf_([a-z0-9_]+)' => '(int) $auth->acl_getf_global(\'\\1\')', - 'cfg_([a-z0-9_]+)' => '(int) $config[\'\\1\']', - 'request_([a-zA-Z0-9_]+)' => '$request->variable(\'\\1\', false)', - 'ext_([a-zA-Z0-9_/]+)' => 'array_key_exists(\'\\1\', $phpbb_extension_manager->all_enabled())', - 'authmethod_([a-z0-9_\\\\]+)' => '($config[\'auth_method\'] === \'\\1\')', - ); - - /** - * Alter tokens for module authorisation check - * - * @event core.module_auth - * @var array valid_tokens Valid tokens and their auth check - * replacements - * @var string module_auth The module_auth of the current - * module - * @var int forum_id The current forum_id - * @since 3.1.0-a3 - */ - $vars = array('valid_tokens', 'module_auth', 'forum_id'); - extract($phpbb_dispatcher->trigger_event('core.module_auth', compact($vars))); - - $tokens = $match[0]; - for ($i = 0, $size = count($tokens); $i < $size; $i++) - { - $token = &$tokens[$i]; - - switch ($token) - { - case ')': - case '(': - case '&&': - case '||': - case ',': - break; - - default: - if (!preg_match('#(?:' . implode(array_keys($valid_tokens), ')|(?:') . ')#', $token)) - { - $token = ''; - } - break; - } - } - - $module_auth = implode(' ', $tokens); - - // Make sure $id separation is working fine - $module_auth = str_replace(' , ', ',', $module_auth); - - $module_auth = preg_replace( - // Array keys with # prepended/appended - array_map(function($value) { - return '#' . $value . '#'; - }, array_keys($valid_tokens)), - array_values($valid_tokens), - $module_auth - ); - - $is_auth = false; - // @codingStandardsIgnoreStart - eval('$is_auth = (int) (' . $module_auth . ');'); - // @codingStandardsIgnoreEnd - - return $is_auth; - } - - /** - * Set active module - */ - function set_active($id = false, $mode = false) - { - global $request; - - $icat = false; - $this->active_module = false; - - if ($request->variable('icat', '')) - { - $icat = $id; - $id = $request->variable('icat', ''); - } - - // Restore the backslashes in class names - if (strpos($id, '-') !== false) - { - $id = str_replace('-', '\\', $id); - } - - if ($id && !is_numeric($id) && !$this->is_full_class($id)) - { - $id = $this->p_class . '_' . $id; - } - - $category = false; - foreach ($this->module_ary as $row_id => $item_ary) - { - // If this is a module and it's selected, active - // If this is a category and the module is the first within it, active - // If this is a module and no mode selected, select first mode - // If no category or module selected, go active for first module in first category - if ( - (($item_ary['name'] === $id || $item_ary['name'] === $this->p_class . '_' . $id || $item_ary['id'] === (int) $id) && (($item_ary['mode'] == $mode && !$item_ary['cat']) || ($icat && $item_ary['cat']))) || - ($item_ary['parent'] === $category && !$item_ary['cat'] && !$icat && $item_ary['display']) || - (($item_ary['name'] === $id || $item_ary['name'] === $this->p_class . '_' . $id || $item_ary['id'] === (int) $id) && !$mode && !$item_ary['cat']) || - (!$id && !$mode && !$item_ary['cat'] && $item_ary['display']) - ) - { - if ($item_ary['cat']) - { - $id = $icat; - $icat = false; - - continue; - } - - $this->p_id = $item_ary['id']; - $this->p_parent = $item_ary['parent']; - $this->p_name = $item_ary['name']; - $this->p_mode = $item_ary['mode']; - $this->p_left = $item_ary['left']; - $this->p_right = $item_ary['right']; - - $this->module_cache['parents'] = $this->module_cache['parents'][$this->p_id]; - $this->active_module = $item_ary['id']; - $this->active_module_row_id = $row_id; - - break; - } - else if (($item_ary['cat'] && $item_ary['id'] === (int) $id) || ($item_ary['parent'] === $category && $item_ary['cat'])) - { - $category = $item_ary['id']; - } - } - } - - /** - * Loads currently active module - * - * This method loads a given module, passing it the relevant id and mode. - * - * @param string|false $mode mode, as passed through to the module - * @param string|false $module_url If supplied, we use this module url - * @param bool $execute_module If true, at the end we execute the main method for the new instance - */ - function load_active($mode = false, $module_url = false, $execute_module = true) - { - global $phpbb_root_path, $phpbb_admin_path, $phpEx, $user, $template, $request; - - $module_path = $this->include_path . $this->p_class; - $icat = $request->variable('icat', ''); - - if ($this->active_module === false) - { - trigger_error('MODULE_NOT_ACCESS', E_USER_ERROR); - } - - // new modules use the full class names, old ones are always called _, e.g. acp_board - if (!class_exists($this->p_name)) - { - if (!file_exists("$module_path/{$this->p_name}.$phpEx")) - { - trigger_error($user->lang('MODULE_NOT_FIND', "$module_path/{$this->p_name}.$phpEx"), E_USER_ERROR); - } - - include("$module_path/{$this->p_name}.$phpEx"); - - if (!class_exists($this->p_name)) - { - trigger_error($user->lang('MODULE_FILE_INCORRECT_CLASS', "$module_path/{$this->p_name}.$phpEx", $this->p_name), E_USER_ERROR); - } - } - - if (!empty($mode)) - { - $this->p_mode = $mode; - } - - // Create a new instance of the desired module ... - $class_name = $this->p_name; - - $this->module = new $class_name($this); - - // We pre-define the action parameter we are using all over the place - if (defined('IN_ADMIN')) - { - /* - * If this is an extension module, we'll try to automatically set - * the style paths for the extension (the ext author can change them - * if necessary). - */ - $module_dir = explode('\\', get_class($this->module)); - - // 0 vendor, 1 extension name, ... - if (isset($module_dir[1])) - { - $module_style_dir = $phpbb_root_path . 'ext/' . $module_dir[0] . '/' . $module_dir[1] . '/adm/style'; - - if (is_dir($module_style_dir)) - { - $template->set_custom_style(array( - array( - 'name' => 'adm', - 'ext_path' => 'adm/style/', - ), - ), array($module_style_dir, $phpbb_admin_path . 'style')); - } - } - - // Is first module automatically enabled a duplicate and the category not passed yet? - if (!$icat && $this->module_ary[$this->active_module_row_id]['is_duplicate']) - { - $icat = $this->module_ary[$this->active_module_row_id]['parent']; - } - - // Not being able to overwrite ;) - $this->module->u_action = append_sid("{$phpbb_admin_path}index.$phpEx", 'i=' . $this->get_module_identifier($this->p_name)) . (($icat) ? '&icat=' . $icat : '') . "&mode={$this->p_mode}"; - } - else - { - /* - * If this is an extension module, we'll try to automatically set - * the style paths for the extension (the ext author can change them - * if necessary). - */ - $module_dir = explode('\\', get_class($this->module)); - - // 0 vendor, 1 extension name, ... - if (isset($module_dir[1])) - { - $module_style_dir = 'ext/' . $module_dir[0] . '/' . $module_dir[1] . '/styles'; - - if (is_dir($phpbb_root_path . $module_style_dir)) - { - $template->set_style(array($module_style_dir, 'styles')); - } - } - - // If user specified the module url we will use it... - if ($module_url !== false) - { - $this->module->u_action = $module_url; - } - else - { - $this->module->u_action = $phpbb_root_path . (($user->page['page_dir']) ? $user->page['page_dir'] . '/' : '') . $user->page['page_name']; - } - - $this->module->u_action = append_sid($this->module->u_action, 'i=' . $this->get_module_identifier($this->p_name)) . (($icat) ? '&icat=' . $icat : '') . "&mode={$this->p_mode}"; - } - - // Add url_extra parameter to u_action url - if (!empty($this->module_ary) && $this->active_module !== false && $this->module_ary[$this->active_module_row_id]['url_extra']) - { - $this->module->u_action .= $this->module_ary[$this->active_module_row_id]['url_extra']; - } - - // Assign the module path for re-usage - $this->module->module_path = $module_path . '/'; - - // Execute the main method for the new instance, we send the module id and mode as parameters - // Users are able to call the main method after this function to be able to assign additional parameters manually - if ($execute_module) - { - $short_name = preg_replace("#^{$this->p_class}_#", '', $this->p_name); - $this->module->main($short_name, $this->p_mode); - } - } - - /** - * Appending url parameter to the currently active module. - * - * This function is called for adding specific url parameters while executing the current module. - * It is doing the same as the _module_{name}_url() function, apart from being able to be called after - * having dynamically parsed specific parameters. This allows more freedom in choosing additional parameters. - * One example can be seen in /includes/mcp/mcp_notes.php - $this->p_master->adjust_url() call. - * - * @param string $url_extra Extra url parameters, e.g.: &u=$user_id - * - */ - function adjust_url($url_extra) - { - if (empty($this->module_ary[$this->active_module_row_id])) - { - return; - } - - $row = &$this->module_ary[$this->active_module_row_id]; - - // We check for the same url_extra in $row['url_extra'] to overcome doubled additions... - if (strpos($row['url_extra'], $url_extra) === false) - { - $row['url_extra'] .= $url_extra; - } - } - - /** - * Check if a module is active - */ - function is_active($id, $mode = false) - { - // If we find a name by this id and being enabled we have our active one... - foreach ($this->module_ary as $row_id => $item_ary) - { - if (($item_ary['name'] === $id || $item_ary['id'] === (int) $id) && $item_ary['display'] || $item_ary['name'] === $this->p_class . '_' . $id) - { - if ($mode === false || $mode === $item_ary['mode']) - { - return true; - } - } - } - - return false; - } - - /** - * Get parents - */ - function get_parents($parent_id, $left_id, $right_id, &$all_parents) - { - $parents = array(); - - if ($parent_id > 0) - { - foreach ($all_parents as $module_id => $row) - { - if ($row['left_id'] < $left_id && $row['right_id'] > $right_id) - { - $parents[$module_id] = $row['parent_id']; - } - - if ($row['left_id'] > $left_id) - { - break; - } - } - } - - return $parents; - } - - /** - * Get tree branch - */ - function get_branch($left_id, $right_id, $remaining) - { - $branch = array(); - - foreach ($remaining as $key => $row) - { - if ($row['left_id'] > $left_id && $row['left_id'] < $right_id) - { - $branch[] = $row; - continue; - } - break; - } - - return $branch; - } - - /** - * Build true binary tree from given array - * Not in use - */ - function build_tree(&$modules, &$parents) - { - $tree = array(); - - foreach ($modules as $row) - { - $branch = &$tree; - - if ($row['parent_id']) - { - // Go through the tree to find our branch - $parent_tree = $parents[$row['module_id']]; - - foreach ($parent_tree as $id => $value) - { - if (!isset($branch[$id]) && isset($branch['child'])) - { - $branch = &$branch['child']; - } - $branch = &$branch[$id]; - } - $branch = &$branch['child']; - } - - $branch[$row['module_id']] = $row; - if (!isset($branch[$row['module_id']]['child'])) - { - $branch[$row['module_id']]['child'] = array(); - } - } - - return $tree; - } - - /** - * Build navigation structure - */ - function assign_tpl_vars($module_url) - { - global $template; - - $current_id = $right_id = false; - - // Make sure the module_url has a question mark set, effectively determining the delimiter to use - $delim = (strpos($module_url, '?') === false) ? '?' : '&'; - - $current_depth = 0; - $linear_offset = 'l_block1'; - $tabular_offset = 't_block2'; - - // Generate the list of modules, we'll do this in two ways ... - // 1) In a linear fashion - // 2) In a combined tabbed + linear fashion ... tabs for the categories - // and a linear list for subcategories/items - foreach ($this->module_ary as $row_id => $item_ary) - { - // Skip hidden modules - if (!$item_ary['display']) - { - continue; - } - - // Skip branch - if ($right_id !== false) - { - if ($item_ary['left'] < $right_id) - { - continue; - } - - $right_id = false; - } - - // Category with no members on their way down (we have to check every level) - if (!$item_ary['name']) - { - $empty_category = true; - - // We go through the branch and look for an activated module - foreach (array_slice($this->module_ary, $row_id + 1) as $temp_row) - { - if ($temp_row['left'] > $item_ary['left'] && $temp_row['left'] < $item_ary['right']) - { - // Module there and displayed? - if ($temp_row['name'] && $temp_row['display']) - { - $empty_category = false; - break; - } - continue; - } - break; - } - - // Skip the branch - if ($empty_category) - { - $right_id = $item_ary['right']; - continue; - } - } - - // Select first id we can get - if (!$current_id && (isset($this->module_cache['parents'][$item_ary['id']]) || $item_ary['id'] == $this->p_id)) - { - $current_id = $item_ary['id']; - } - - $depth = $item_ary['depth']; - - if ($depth > $current_depth) - { - $linear_offset = $linear_offset . '.l_block' . ($depth + 1); - $tabular_offset = ($depth + 1 > 2) ? $tabular_offset . '.t_block' . ($depth + 1) : $tabular_offset; - } - else if ($depth < $current_depth) - { - for ($i = $current_depth - $depth; $i > 0; $i--) - { - $linear_offset = substr($linear_offset, 0, strrpos($linear_offset, '.')); - $tabular_offset = ($i + $depth > 1) ? substr($tabular_offset, 0, strrpos($tabular_offset, '.')) : $tabular_offset; - } - } - - $u_title = $module_url . $delim . 'i='; - // if the item has a name use it, else use its id - if (empty($item_ary['name'])) - { - $u_title .= $item_ary['id']; - } - else - { - // if the category has a name, then use it. - $u_title .= $this->get_module_identifier($item_ary['name']); - } - // If the item is not a category append the mode - if (!$item_ary['cat']) - { - if ($item_ary['is_duplicate']) - { - $u_title .= '&icat=' . $current_id; - } - $u_title .= '&mode=' . $item_ary['mode']; - } - - // Was not allowed in categories before - /*!$item_ary['cat'] && */ - $u_title .= (isset($item_ary['url_extra'])) ? $item_ary['url_extra'] : ''; - - // Only output a categories items if it's currently selected - if (!$depth || ($depth && (in_array($item_ary['parent'], array_values($this->module_cache['parents'])) || $item_ary['parent'] == $this->p_parent))) - { - $use_tabular_offset = (!$depth) ? 't_block1' : $tabular_offset; - - $tpl_ary = array( - 'L_TITLE' => $item_ary['lang'], - 'S_SELECTED' => (isset($this->module_cache['parents'][$item_ary['id']]) || $item_ary['id'] == $this->p_id) ? true : false, - 'U_TITLE' => $u_title - ); - - $template->assign_block_vars($use_tabular_offset, array_merge($tpl_ary, array_change_key_case($item_ary, CASE_UPPER))); - } - - $tpl_ary = array( - 'L_TITLE' => $item_ary['lang'], - 'S_SELECTED' => (isset($this->module_cache['parents'][$item_ary['id']]) || $item_ary['id'] == $this->p_id) ? true : false, - 'U_TITLE' => $u_title - ); - - $template->assign_block_vars($linear_offset, array_merge($tpl_ary, array_change_key_case($item_ary, CASE_UPPER))); - - $current_depth = $depth; - } - } - - /** - * Returns desired template name - */ - function get_tpl_name() - { - return $this->module->tpl_name . '.html'; - } - - /** - * Returns the desired page title - */ - function get_page_title() - { - global $user; - - if (!isset($this->module->page_title)) - { - return ''; - } - - return (isset($user->lang[$this->module->page_title])) ? $user->lang[$this->module->page_title] : $this->module->page_title; - } - - /** - * Load module as the current active one without the need for registering it - * - * @param string $class module class (acp/mcp/ucp) - * @param string $name module name (class name of the module, or its basename - * phpbb_ext_foo_acp_bar_module, ucp_zebra or zebra) - * @param string $mode mode, as passed through to the module - * - */ - function load($class, $name, $mode = false) - { - // new modules use the full class names, old ones are always called _, e.g. acp_board - // in the latter case this function may be called as load('acp', 'board') - if (!class_exists($name) && substr($name, 0, strlen($class) + 1) !== $class . '_') - { - $name = $class . '_' . $name; - } - - $this->p_class = $class; - $this->p_name = $name; - - // Set active module to true instead of using the id - $this->active_module = true; - - $this->load_active($mode); - } - - /** - * Display module - */ - function display($page_title, $display_online_list = false) - { - global $template, $user; - - // Generate the page - if (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin']) - { - adm_page_header($page_title); - } - else - { - page_header($page_title, $display_online_list); - } - - $template->set_filenames(array( - 'body' => $this->get_tpl_name()) - ); - - if (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin']) - { - adm_page_footer(); - } - else - { - page_footer(); - } - } - - /** - * Toggle whether this module will be displayed or not - */ - function set_display($id, $mode = false, $display = true) - { - foreach ($this->module_ary as $row_id => $item_ary) - { - if (($item_ary['name'] === $id || $item_ary['name'] === $this->p_class . '_' . $id || $item_ary['id'] === (int) $id) && (!$mode || $item_ary['mode'] === $mode)) - { - $this->module_ary[$row_id]['display'] = (int) $display; - } - } - } - - /** - * Add custom MOD info language file - */ - function add_mod_info($module_class) - { - global $config, $user, $phpEx, $phpbb_extension_manager; - - $finder = $phpbb_extension_manager->get_finder(); - - // We grab the language files from the default, English and user's language. - // So we can fall back to the other files like we do when using add_lang() - $default_lang_files = $english_lang_files = $user_lang_files = array(); - - // Search for board default language if it's not the user language - if ($config['default_lang'] != $user->lang_name) - { - $default_lang_files = $finder - ->prefix('info_' . strtolower($module_class) . '_') - ->suffix(".$phpEx") - ->extension_directory('/language/' . basename($config['default_lang'])) - ->core_path('language/' . basename($config['default_lang']) . '/mods/') - ->find(); - } - - // Search for english, if its not the default or user language - if ($config['default_lang'] != 'en' && $user->lang_name != 'en') - { - $english_lang_files = $finder - ->prefix('info_' . strtolower($module_class) . '_') - ->suffix(".$phpEx") - ->extension_directory('/language/en') - ->core_path('language/en/mods/') - ->find(); - } - - // Find files in the user's language - $user_lang_files = $finder - ->prefix('info_' . strtolower($module_class) . '_') - ->suffix(".$phpEx") - ->extension_directory('/language/' . $user->lang_name) - ->core_path('language/' . $user->lang_name . '/mods/') - ->find(); - - $lang_files = array_merge($english_lang_files, $default_lang_files, $user_lang_files); - foreach ($lang_files as $lang_file => $ext_name) - { - $user->add_lang_ext($ext_name, $lang_file); - } - } - - /** - * Retrieve shortened module basename for legacy basenames (with xcp_ prefix) - * - * @param string $basename A module basename - * @return string The basename if it starts with phpbb_ or the basename with - * the current p_class (e.g. acp_) stripped. - */ - protected function get_short_name($basename) - { - if (substr($basename, 0, 6) === 'phpbb\\' || strpos($basename, '\\') !== false) - { - return $basename; - } - - // strip xcp_ prefix from old classes - return substr($basename, strlen($this->p_class) + 1); - } - - /** - * If the basename contains a \ we don't use that for the URL. - * - * Firefox is currently unable to correctly copy a urlencoded \ - * so users will be unable to post links to modules. - * However we can replace them with dashes and re-replace them later - * - * @param string $basename Basename of the module - * @return string Identifier that should be used for - * module link creation - */ - protected function get_module_identifier($basename) - { - if (strpos($basename, '\\') === false) - { - return $basename; - } - - return str_replace('\\', '-', $basename); - } - - /** - * Checks whether the given module basename is a correct class name - * - * @param string $basename A module basename - * @return bool True if the basename starts with phpbb_ or (x)cp_, false otherwise - */ - protected function is_full_class($basename) - { - return (strpos($basename, '\\') !== false || preg_match('/^(ucp|mcp|acp)_/', $basename)); - } -} diff --git a/install/update/old/includes/functions_posting.php b/install/update/old/includes/functions_posting.php deleted file mode 100644 index 3640f54..0000000 --- a/install/update/old/includes/functions_posting.php +++ /dev/null @@ -1,2772 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* Fill smiley templates (or just the variables) with smilies, either in a window or inline -*/ -function generate_smilies($mode, $forum_id) -{ - global $db, $user, $config, $template, $phpbb_dispatcher, $request; - global $phpEx, $phpbb_root_path, $phpbb_container, $phpbb_path_helper; - - /* @var $pagination \phpbb\pagination */ - $pagination = $phpbb_container->get('pagination'); - $base_url = append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=smilies&f=' . $forum_id); - $start = $request->variable('start', 0); - - if ($mode == 'window') - { - if ($forum_id) - { - $sql = 'SELECT forum_style - FROM ' . FORUMS_TABLE . " - WHERE forum_id = $forum_id"; - $result = $db->sql_query_limit($sql, 1); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $user->setup('posting', (int) $row['forum_style']); - } - else - { - $user->setup('posting'); - } - - page_header($user->lang['SMILIES']); - - $sql = 'SELECT COUNT(smiley_id) AS item_count - FROM ' . SMILIES_TABLE . ' - GROUP BY smiley_url'; - $result = $db->sql_query($sql, 3600); - - $smiley_count = 0; - while ($row = $db->sql_fetchrow($result)) - { - ++$smiley_count; - } - $db->sql_freeresult($result); - - $template->set_filenames(array( - 'body' => 'posting_smilies.html') - ); - - $start = $pagination->validate_start($start, $config['smilies_per_page'], $smiley_count); - $pagination->generate_template_pagination($base_url, 'pagination', 'start', $smiley_count, $config['smilies_per_page'], $start); - } - - $display_link = false; - if ($mode == 'inline') - { - $sql = 'SELECT smiley_id - FROM ' . SMILIES_TABLE . ' - WHERE display_on_posting = 0'; - $result = $db->sql_query_limit($sql, 1, 0, 3600); - - if ($row = $db->sql_fetchrow($result)) - { - $display_link = true; - } - $db->sql_freeresult($result); - } - - if ($mode == 'window') - { - $sql = 'SELECT smiley_url, MIN(emotion) as emotion, MIN(code) AS code, smiley_width, smiley_height, MIN(smiley_order) AS min_smiley_order - FROM ' . SMILIES_TABLE . ' - GROUP BY smiley_url, smiley_width, smiley_height - ORDER BY min_smiley_order'; - $result = $db->sql_query_limit($sql, $config['smilies_per_page'], $start, 3600); - } - else - { - $sql = 'SELECT * - FROM ' . SMILIES_TABLE . ' - WHERE display_on_posting = 1 - ORDER BY smiley_order'; - $result = $db->sql_query($sql, 3600); - } - - $smilies = array(); - while ($row = $db->sql_fetchrow($result)) - { - if (empty($smilies[$row['smiley_url']])) - { - $smilies[$row['smiley_url']] = $row; - } - } - $db->sql_freeresult($result); - - if (count($smilies)) - { - $root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_path_helper->get_web_root_path(); - - foreach ($smilies as $row) - { - /** - * Modify smiley root path before populating smiley list - * - * @event core.generate_smilies_before - * @var string root_path root_path for smilies - * @since 3.1.11-RC1 - */ - $vars = array('root_path'); - extract($phpbb_dispatcher->trigger_event('core.generate_smilies_before', compact($vars))); - $template->assign_block_vars('smiley', array( - 'SMILEY_CODE' => $row['code'], - 'A_SMILEY_CODE' => addslashes($row['code']), - 'SMILEY_IMG' => $root_path . $config['smilies_path'] . '/' . $row['smiley_url'], - 'SMILEY_WIDTH' => $row['smiley_width'], - 'SMILEY_HEIGHT' => $row['smiley_height'], - 'SMILEY_DESC' => $row['emotion']) - ); - } - } - - /** - * This event is called after the smilies are populated - * - * @event core.generate_smilies_after - * @var string mode Mode of the smilies: window|inline - * @var int forum_id The forum ID we are currently in - * @var bool display_link Shall we display the "more smilies" link? - * @since 3.1.0-a1 - */ - $vars = array('mode', 'forum_id', 'display_link'); - extract($phpbb_dispatcher->trigger_event('core.generate_smilies_after', compact($vars))); - - if ($mode == 'inline' && $display_link) - { - $template->assign_vars(array( - 'S_SHOW_SMILEY_LINK' => true, - 'U_MORE_SMILIES' => $base_url, - )); - } - - if ($mode == 'window') - { - page_footer(); - } -} - -/** -* Update last post information -* Should be used instead of sync() if only the last post information are out of sync... faster -* -* @param string $type Can be forum|topic -* @param mixed $ids topic/forum ids -* @param bool $return_update_sql true: SQL query shall be returned, false: execute SQL -*/ -function update_post_information($type, $ids, $return_update_sql = false) -{ - global $db; - - if (empty($ids)) - { - return; - } - if (!is_array($ids)) - { - $ids = array($ids); - } - - $update_sql = $empty_forums = $not_empty_forums = array(); - - if ($type != 'topic') - { - $topic_join = ', ' . TOPICS_TABLE . ' t'; - $topic_condition = 'AND t.topic_id = p.topic_id AND t.topic_visibility = ' . ITEM_APPROVED; - } - else - { - $topic_join = ''; - $topic_condition = ''; - } - - if (count($ids) == 1) - { - $sql = 'SELECT p.post_id as last_post_id - FROM ' . POSTS_TABLE . " p $topic_join - WHERE " . $db->sql_in_set('p.' . $type . '_id', $ids) . " - $topic_condition - AND p.post_visibility = " . ITEM_APPROVED . " - ORDER BY p.post_id DESC"; - $result = $db->sql_query_limit($sql, 1); - } - else - { - $sql = 'SELECT p.' . $type . '_id, MAX(p.post_id) as last_post_id - FROM ' . POSTS_TABLE . " p $topic_join - WHERE " . $db->sql_in_set('p.' . $type . '_id', $ids) . " - $topic_condition - AND p.post_visibility = " . ITEM_APPROVED . " - GROUP BY p.{$type}_id"; - $result = $db->sql_query($sql); - } - - $last_post_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - if (count($ids) == 1) - { - $row[$type . '_id'] = $ids[0]; - } - - if ($type == 'forum') - { - $not_empty_forums[] = $row['forum_id']; - - if (empty($row['last_post_id'])) - { - $empty_forums[] = $row['forum_id']; - } - } - - $last_post_ids[] = $row['last_post_id']; - } - $db->sql_freeresult($result); - - if ($type == 'forum') - { - $empty_forums = array_merge($empty_forums, array_diff($ids, $not_empty_forums)); - - foreach ($empty_forums as $void => $forum_id) - { - $update_sql[$forum_id][] = 'forum_last_post_id = 0'; - $update_sql[$forum_id][] = "forum_last_post_subject = ''"; - $update_sql[$forum_id][] = 'forum_last_post_time = 0'; - $update_sql[$forum_id][] = 'forum_last_poster_id = 0'; - $update_sql[$forum_id][] = "forum_last_poster_name = ''"; - $update_sql[$forum_id][] = "forum_last_poster_colour = ''"; - } - } - - if (count($last_post_ids)) - { - $sql = 'SELECT p.' . $type . '_id, p.post_id, p.post_subject, p.post_time, p.poster_id, p.post_username, u.user_id, u.username, u.user_colour - FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u - WHERE p.poster_id = u.user_id - AND ' . $db->sql_in_set('p.post_id', $last_post_ids); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $update_sql[$row["{$type}_id"]][] = $type . '_last_post_id = ' . (int) $row['post_id']; - $update_sql[$row["{$type}_id"]][] = "{$type}_last_post_subject = '" . $db->sql_escape($row['post_subject']) . "'"; - $update_sql[$row["{$type}_id"]][] = $type . '_last_post_time = ' . (int) $row['post_time']; - $update_sql[$row["{$type}_id"]][] = $type . '_last_poster_id = ' . (int) $row['poster_id']; - $update_sql[$row["{$type}_id"]][] = "{$type}_last_poster_colour = '" . $db->sql_escape($row['user_colour']) . "'"; - $update_sql[$row["{$type}_id"]][] = "{$type}_last_poster_name = '" . (($row['poster_id'] == ANONYMOUS) ? $db->sql_escape($row['post_username']) : $db->sql_escape($row['username'])) . "'"; - } - $db->sql_freeresult($result); - } - unset($empty_forums, $ids, $last_post_ids); - - if ($return_update_sql || !count($update_sql)) - { - return $update_sql; - } - - $table = ($type == 'forum') ? FORUMS_TABLE : TOPICS_TABLE; - - foreach ($update_sql as $update_id => $update_sql_ary) - { - $sql = "UPDATE $table - SET " . implode(', ', $update_sql_ary) . " - WHERE {$type}_id = $update_id"; - $db->sql_query($sql); - } - - return; -} - -/** -* Generate Topic Icons for display -*/ -function posting_gen_topic_icons($mode, $icon_id) -{ - global $phpbb_root_path, $config, $template, $cache; - - // Grab icons - $icons = $cache->obtain_icons(); - - if (!$icon_id) - { - $template->assign_var('S_NO_ICON_CHECKED', ' checked="checked"'); - } - - if (count($icons)) - { - $root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_root_path; - - foreach ($icons as $id => $data) - { - if ($data['display']) - { - $template->assign_block_vars('topic_icon', array( - 'ICON_ID' => $id, - 'ICON_IMG' => $root_path . $config['icons_path'] . '/' . $data['img'], - 'ICON_WIDTH' => $data['width'], - 'ICON_HEIGHT' => $data['height'], - 'ICON_ALT' => $data['alt'], - - 'S_CHECKED' => ($id == $icon_id) ? true : false, - 'S_ICON_CHECKED' => ($id == $icon_id) ? ' checked="checked"' : '') - ); - } - } - - return true; - } - - return false; -} - -/** -* Build topic types able to be selected -*/ -function posting_gen_topic_types($forum_id, $cur_topic_type = POST_NORMAL) -{ - global $auth, $user, $template; - - $toggle = false; - - $topic_types = array( - 'sticky' => array('const' => POST_STICKY, 'lang' => 'POST_STICKY'), - 'announce' => array('const' => POST_ANNOUNCE, 'lang' => 'POST_ANNOUNCEMENT'), - 'announce_global' => array('const' => POST_GLOBAL, 'lang' => 'POST_GLOBAL') - ); - - $topic_type_array = array(); - - foreach ($topic_types as $auth_key => $topic_value) - { - if ($auth->acl_get('f_' . $auth_key, $forum_id)) - { - $toggle = true; - - $topic_type_array[] = array( - 'VALUE' => $topic_value['const'], - 'S_CHECKED' => ($cur_topic_type == $topic_value['const']) ? ' checked="checked"' : '', - 'L_TOPIC_TYPE' => $user->lang[$topic_value['lang']] - ); - } - } - - if ($toggle) - { - $topic_type_array = array_merge(array(0 => array( - 'VALUE' => POST_NORMAL, - 'S_CHECKED' => ($cur_topic_type == POST_NORMAL) ? ' checked="checked"' : '', - 'L_TOPIC_TYPE' => $user->lang['POST_NORMAL'])), - - $topic_type_array - ); - - foreach ($topic_type_array as $array) - { - $template->assign_block_vars('topic_type', $array); - } - - $template->assign_vars(array( - 'S_TOPIC_TYPE_STICKY' => ($auth->acl_get('f_sticky', $forum_id)), - 'S_TOPIC_TYPE_ANNOUNCE' => ($auth->acl_gets('f_announce', 'f_announce_global', $forum_id)), - )); - } - - return $toggle; -} - -// -// Attachment related functions -// - -/** -* Upload Attachment - filedata is generated here -* Uses upload class -* -* @deprecated 3.2.0-a1 (To be removed: 3.4.0) -* -* @param string $form_name The form name of the file upload input -* @param int $forum_id The id of the forum -* @param bool $local Whether the file is local or not -* @param string $local_storage The path to the local file -* @param bool $is_message Whether it is a PM or not -* @param array $local_filedata A filespec object created for the local file -* -* @return array File data array -*/ -function upload_attachment($form_name, $forum_id, $local = false, $local_storage = '', $is_message = false, $local_filedata = false) -{ - global $phpbb_container; - - /** @var \phpbb\attachment\manager $attachment_manager */ - $attachment_manager = $phpbb_container->get('attachment.manager'); - $file = $attachment_manager->upload($form_name, $forum_id, $local, $local_storage, $is_message, $local_filedata); - unset($attachment_manager); - - return $file; -} - -/** -* Calculate the needed size for Thumbnail -*/ -function get_img_size_format($width, $height) -{ - global $config; - - // Maximum Width the Image can take - $max_width = ($config['img_max_thumb_width']) ? $config['img_max_thumb_width'] : 400; - - if ($width > $height) - { - return array( - round($width * ($max_width / $width)), - round($height * ($max_width / $width)) - ); - } - else - { - return array( - round($width * ($max_width / $height)), - round($height * ($max_width / $height)) - ); - } -} - -/** -* Return supported image types -*/ -function get_supported_image_types($type = false) -{ - if (@extension_loaded('gd')) - { - $format = imagetypes(); - $new_type = 0; - - if ($type !== false) - { - // Type is one of the IMAGETYPE constants - it is fetched from getimagesize() - switch ($type) - { - // GIF - case IMAGETYPE_GIF: - $new_type = ($format & IMG_GIF) ? IMG_GIF : false; - break; - - // JPG, JPC, JP2 - case IMAGETYPE_JPEG: - case IMAGETYPE_JPC: - case IMAGETYPE_JPEG2000: - case IMAGETYPE_JP2: - case IMAGETYPE_JPX: - case IMAGETYPE_JB2: - $new_type = ($format & IMG_JPG) ? IMG_JPG : false; - break; - - // PNG - case IMAGETYPE_PNG: - $new_type = ($format & IMG_PNG) ? IMG_PNG : false; - break; - - // WBMP - case IMAGETYPE_WBMP: - $new_type = ($format & IMG_WBMP) ? IMG_WBMP : false; - break; - } - } - else - { - $new_type = array(); - $go_through_types = array(IMG_GIF, IMG_JPG, IMG_PNG, IMG_WBMP); - - foreach ($go_through_types as $check_type) - { - if ($format & $check_type) - { - $new_type[] = $check_type; - } - } - } - - return array( - 'gd' => ($new_type) ? true : false, - 'format' => $new_type, - 'version' => (function_exists('imagecreatetruecolor')) ? 2 : 1 - ); - } - - return array('gd' => false); -} - -/** -* Create Thumbnail -*/ -function create_thumbnail($source, $destination, $mimetype) -{ - global $config, $phpbb_filesystem, $phpbb_dispatcher; - - $min_filesize = (int) $config['img_min_thumb_filesize']; - $img_filesize = (file_exists($source)) ? @filesize($source) : false; - - if (!$img_filesize || $img_filesize <= $min_filesize) - { - return false; - } - - $dimension = @getimagesize($source); - - if ($dimension === false) - { - return false; - } - - list($width, $height, $type, ) = $dimension; - - if (empty($width) || empty($height)) - { - return false; - } - - list($new_width, $new_height) = get_img_size_format($width, $height); - - // Do not create a thumbnail if the resulting width/height is bigger than the original one - if ($new_width >= $width && $new_height >= $height) - { - return false; - } - - $thumbnail_created = false; - - /** - * Create thumbnail event to replace GD thumbnail creation with for example ImageMagick - * - * @event core.thumbnail_create_before - * @var string source Image source path - * @var string destination Thumbnail destination path - * @var string mimetype Image mime type - * @var float new_width Calculated thumbnail width - * @var float new_height Calculated thumbnail height - * @var bool thumbnail_created Set to true to skip default GD thumbnail creation - * @since 3.2.4 - */ - $vars = array( - 'source', - 'destination', - 'mimetype', - 'new_width', - 'new_height', - 'thumbnail_created', - ); - extract($phpbb_dispatcher->trigger_event('core.thumbnail_create_before', compact($vars))); - - if (!$thumbnail_created) - { - $type = get_supported_image_types($type); - - if ($type['gd']) - { - // If the type is not supported, we are not able to create a thumbnail - if ($type['format'] === false) - { - return false; - } - - switch ($type['format']) - { - case IMG_GIF: - $image = @imagecreatefromgif($source); - break; - - case IMG_JPG: - @ini_set('gd.jpeg_ignore_warning', 1); - $image = @imagecreatefromjpeg($source); - break; - - case IMG_PNG: - $image = @imagecreatefrompng($source); - break; - - case IMG_WBMP: - $image = @imagecreatefromwbmp($source); - break; - } - - if (empty($image)) - { - return false; - } - - if ($type['version'] == 1) - { - $new_image = imagecreate($new_width, $new_height); - - if ($new_image === false) - { - return false; - } - - imagecopyresized($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); - } - else - { - $new_image = imagecreatetruecolor($new_width, $new_height); - - if ($new_image === false) - { - return false; - } - - // Preserve alpha transparency (png for example) - @imagealphablending($new_image, false); - @imagesavealpha($new_image, true); - - imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); - } - - // If we are in safe mode create the destination file prior to using the gd functions to circumvent a PHP bug - if (@ini_get('safe_mode') || @strtolower(ini_get('safe_mode')) == 'on') - { - @touch($destination); - } - - switch ($type['format']) - { - case IMG_GIF: - imagegif($new_image, $destination); - break; - - case IMG_JPG: - imagejpeg($new_image, $destination, 90); - break; - - case IMG_PNG: - imagepng($new_image, $destination); - break; - - case IMG_WBMP: - imagewbmp($new_image, $destination); - break; - } - - imagedestroy($new_image); - } - else - { - return false; - } - } - - if (!file_exists($destination)) - { - return false; - } - - try - { - $phpbb_filesystem->phpbb_chmod($destination, CHMOD_READ | CHMOD_WRITE); - } - catch (\phpbb\filesystem\exception\filesystem_exception $e) - { - // Do nothing - } - - return true; -} - -/** -* Assign Inline attachments (build option fields) -*/ -function posting_gen_inline_attachments(&$attachment_data) -{ - global $template; - - if (count($attachment_data)) - { - $s_inline_attachment_options = ''; - - foreach ($attachment_data as $i => $attachment) - { - $s_inline_attachment_options .= ''; - } - - $template->assign_var('S_INLINE_ATTACHMENT_OPTIONS', $s_inline_attachment_options); - - return true; - } - - return false; -} - -/** -* Generate inline attachment entry -*/ -function posting_gen_attachment_entry($attachment_data, &$filename_data, $show_attach_box = true) -{ - global $template, $config, $phpbb_root_path, $phpEx, $user, $phpbb_dispatcher; - - // Some default template variables - $template->assign_vars(array( - 'S_SHOW_ATTACH_BOX' => $show_attach_box, - 'S_HAS_ATTACHMENTS' => count($attachment_data), - 'FILESIZE' => $config['max_filesize'], - 'FILE_COMMENT' => (isset($filename_data['filecomment'])) ? $filename_data['filecomment'] : '', - )); - - if (count($attachment_data)) - { - // We display the posted attachments within the desired order. - ($config['display_order']) ? krsort($attachment_data) : ksort($attachment_data); - - $attachrow_template_vars = []; - - foreach ($attachment_data as $count => $attach_row) - { - $hidden = ''; - $attach_row['real_filename'] = utf8_basename($attach_row['real_filename']); - - foreach ($attach_row as $key => $value) - { - $hidden .= ''; - } - - $download_link = append_sid("{$phpbb_root_path}download/file.$phpEx", 'mode=view&id=' . (int) $attach_row['attach_id'], true, ($attach_row['is_orphan']) ? $user->session_id : false); - - $attachrow_template_vars[(int) $attach_row['attach_id']] = array( - 'FILENAME' => utf8_basename($attach_row['real_filename']), - 'A_FILENAME' => addslashes(utf8_basename($attach_row['real_filename'])), - 'FILE_COMMENT' => $attach_row['attach_comment'], - 'ATTACH_ID' => $attach_row['attach_id'], - 'S_IS_ORPHAN' => $attach_row['is_orphan'], - 'ASSOC_INDEX' => $count, - 'FILESIZE' => get_formatted_filesize($attach_row['filesize']), - - 'U_VIEW_ATTACHMENT' => $download_link, - 'S_HIDDEN' => $hidden, - ); - } - - /** - * Modify inline attachments template vars - * - * @event core.modify_inline_attachments_template_vars - * @var array attachment_data Array containing attachments data - * @var array attachrow_template_vars Array containing attachments template vars - * @since 3.2.2-RC1 - */ - $vars = array('attachment_data', 'attachrow_template_vars'); - extract($phpbb_dispatcher->trigger_event('core.modify_inline_attachments_template_vars', compact($vars))); - - $template->assign_block_vars_array('attach_row', $attachrow_template_vars); - } - - return count($attachment_data); -} - -// -// General Post functions -// - -/** -* Load Drafts -*/ -function load_drafts($topic_id = 0, $forum_id = 0, $id = 0, $pm_action = '', $msg_id = 0) -{ - global $user, $db, $template, $auth; - global $phpbb_root_path, $phpbb_dispatcher, $phpEx; - - $topic_ids = $forum_ids = $draft_rows = array(); - - // Load those drafts not connected to forums/topics - // If forum_id == 0 AND topic_id == 0 then this is a PM draft - if (!$topic_id && !$forum_id) - { - $sql_and = ' AND d.forum_id = 0 AND d.topic_id = 0'; - } - else - { - $sql_and = ''; - $sql_and .= ($forum_id) ? ' AND d.forum_id = ' . (int) $forum_id : ''; - $sql_and .= ($topic_id) ? ' AND d.topic_id = ' . (int) $topic_id : ''; - } - - $sql = 'SELECT d.*, f.forum_id, f.forum_name - FROM ' . DRAFTS_TABLE . ' d - LEFT JOIN ' . FORUMS_TABLE . ' f ON (f.forum_id = d.forum_id) - WHERE d.user_id = ' . $user->data['user_id'] . " - $sql_and - ORDER BY d.save_time DESC"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if ($row['topic_id']) - { - $topic_ids[] = (int) $row['topic_id']; - } - $draft_rows[] = $row; - } - $db->sql_freeresult($result); - - if (!count($draft_rows)) - { - return; - } - - $topic_rows = array(); - if (count($topic_ids)) - { - $sql = 'SELECT topic_id, forum_id, topic_title, topic_poster - FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', array_unique($topic_ids)); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $topic_rows[$row['topic_id']] = $row; - } - $db->sql_freeresult($result); - } - - /** - * Drafts found and their topics - * Edit $draft_rows in order to add or remove drafts loaded - * - * @event core.load_drafts_draft_list_result - * @var array draft_rows The drafts query result. Includes its forum id and everything about the draft - * @var array topic_ids The list of topics got from the topics table - * @var array topic_rows The topics that draft_rows references - * @since 3.1.0-RC3 - */ - $vars = array('draft_rows', 'topic_ids', 'topic_rows'); - extract($phpbb_dispatcher->trigger_event('core.load_drafts_draft_list_result', compact($vars))); - - unset($topic_ids); - - $template->assign_var('S_SHOW_DRAFTS', true); - - foreach ($draft_rows as $draft) - { - $link_topic = $link_forum = $link_pm = false; - $view_url = $title = ''; - - if (isset($topic_rows[$draft['topic_id']]) - && ( - ($topic_rows[$draft['topic_id']]['forum_id'] && $auth->acl_get('f_read', $topic_rows[$draft['topic_id']]['forum_id'])) - || - (!$topic_rows[$draft['topic_id']]['forum_id'] && $auth->acl_getf_global('f_read')) - )) - { - $topic_forum_id = ($topic_rows[$draft['topic_id']]['forum_id']) ? $topic_rows[$draft['topic_id']]['forum_id'] : $forum_id; - - $link_topic = true; - $view_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $topic_forum_id . '&t=' . $draft['topic_id']); - $title = $topic_rows[$draft['topic_id']]['topic_title']; - - $insert_url = append_sid("{$phpbb_root_path}posting.$phpEx", 'f=' . $topic_forum_id . '&t=' . $draft['topic_id'] . '&mode=reply&d=' . $draft['draft_id']); - } - else if ($draft['forum_id'] && $auth->acl_get('f_read', $draft['forum_id'])) - { - $link_forum = true; - $view_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $draft['forum_id']); - $title = $draft['forum_name']; - - $insert_url = append_sid("{$phpbb_root_path}posting.$phpEx", 'f=' . $draft['forum_id'] . '&mode=post&d=' . $draft['draft_id']); - } - else - { - // Either display as PM draft if forum_id and topic_id are empty or if access to the forums has been denied afterwards... - $link_pm = true; - $insert_url = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=$id&mode=compose&d={$draft['draft_id']}" . (($pm_action) ? "&action=$pm_action" : '') . (($msg_id) ? "&p=$msg_id" : '')); - } - - $template->assign_block_vars('draftrow', array( - 'DRAFT_ID' => $draft['draft_id'], - 'DATE' => $user->format_date($draft['save_time']), - 'DRAFT_SUBJECT' => $draft['draft_subject'], - - 'TITLE' => $title, - 'U_VIEW' => $view_url, - 'U_INSERT' => $insert_url, - - 'S_LINK_PM' => $link_pm, - 'S_LINK_TOPIC' => $link_topic, - 'S_LINK_FORUM' => $link_forum) - ); - } -} - -/** -* Topic Review -*/ -function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id = 0, $show_quote_button = true) -{ - global $user, $auth, $db, $template; - global $config, $phpbb_root_path, $phpEx, $phpbb_container, $phpbb_dispatcher; - - /* @var $phpbb_content_visibility \phpbb\content_visibility */ - $phpbb_content_visibility = $phpbb_container->get('content.visibility'); - $sql_sort = ($mode == 'post_review') ? 'ASC' : 'DESC'; - - // Go ahead and pull all data for this topic - $sql = 'SELECT p.post_id - FROM ' . POSTS_TABLE . ' p' . " - WHERE p.topic_id = $topic_id - AND " . $phpbb_content_visibility->get_visibility_sql('post', $forum_id, 'p.') . ' - ' . (($mode == 'post_review') ? " AND p.post_id > $cur_post_id" : '') . ' - ' . (($mode == 'post_review_edit') ? " AND p.post_id = $cur_post_id" : '') . ' - ORDER BY p.post_time ' . $sql_sort . ', p.post_id ' . $sql_sort; - $result = $db->sql_query_limit($sql, $config['posts_per_page']); - - $post_list = array(); - - while ($row = $db->sql_fetchrow($result)) - { - $post_list[] = $row['post_id']; - } - - $db->sql_freeresult($result); - - if (!count($post_list)) - { - return false; - } - - // Handle 'post_review_edit' like 'post_review' from now on - if ($mode == 'post_review_edit') - { - $mode = 'post_review'; - } - - $sql_ary = array( - 'SELECT' => 'u.username, u.user_id, u.user_colour, p.*, z.friend, z.foe, uu.username as post_delete_username, uu.user_colour as post_delete_user_colour', - - 'FROM' => array( - USERS_TABLE => 'u', - POSTS_TABLE => 'p', - ), - - 'LEFT_JOIN' => array( - array( - 'FROM' => array(ZEBRA_TABLE => 'z'), - 'ON' => 'z.user_id = ' . $user->data['user_id'] . ' AND z.zebra_id = p.poster_id', - ), - array( - 'FROM' => array(USERS_TABLE => 'uu'), - 'ON' => 'uu.user_id = p.post_delete_user', - ), - ), - - 'WHERE' => $db->sql_in_set('p.post_id', $post_list) . ' - AND u.user_id = p.poster_id', - ); - - $sql = $db->sql_build_query('SELECT', $sql_ary); - $result = $db->sql_query($sql); - - $rowset = array(); - $has_attachments = false; - while ($row = $db->sql_fetchrow($result)) - { - $rowset[$row['post_id']] = $row; - - if ($row['post_attachment']) - { - $has_attachments = true; - } - } - $db->sql_freeresult($result); - - // Grab extensions - $attachments = array(); - if ($has_attachments && $auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id)) - { - // Get attachments... - $sql = 'SELECT * - FROM ' . ATTACHMENTS_TABLE . ' - WHERE ' . $db->sql_in_set('post_msg_id', $post_list) . ' - AND in_message = 0 - ORDER BY filetime DESC, post_msg_id ASC'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $attachments[$row['post_msg_id']][] = $row; - } - $db->sql_freeresult($result); - } - - /** - * Event to modify the posts list for topic reviews - * - * @event core.topic_review_modify_post_list - * @var array attachments Array with the post attachments data - * @var int cur_post_id Post offset ID - * @var int forum_id The topic's forum ID - * @var string mode The topic review mode - * @var array post_list Array with the post IDs - * @var array rowset Array with the posts data - * @var bool show_quote_button Flag indicating if the quote button should be displayed - * @var int topic_id The topic ID that is being reviewed - * @since 3.1.9-RC1 - */ - $vars = array( - 'attachments', - 'cur_post_id', - 'forum_id', - 'mode', - 'post_list', - 'rowset', - 'show_quote_button', - 'topic_id', - ); - extract($phpbb_dispatcher->trigger_event('core.topic_review_modify_post_list', compact($vars))); - - for ($i = 0, $end = count($post_list); $i < $end; ++$i) - { - // A non-existing rowset only happens if there was no user present for the entered poster_id - // This could be a broken posts table. - if (!isset($rowset[$post_list[$i]])) - { - continue; - } - - $row = $rowset[$post_list[$i]]; - - $poster_id = $row['user_id']; - $post_subject = $row['post_subject']; - - $decoded_message = false; - - if ($show_quote_button && $auth->acl_get('f_reply', $forum_id)) - { - $decoded_message = censor_text($row['post_text']); - decode_message($decoded_message, $row['bbcode_uid']); - - $decoded_message = bbcode_nl2br($decoded_message); - } - - $parse_flags = ($row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0); - $parse_flags |= ($row['enable_smilies'] ? OPTION_FLAG_SMILIES : 0); - $message = generate_text_for_display($row['post_text'], $row['bbcode_uid'], $row['bbcode_bitfield'], $parse_flags, true); - - if (!empty($attachments[$row['post_id']])) - { - $update_count = array(); - parse_attachments($forum_id, $message, $attachments[$row['post_id']], $update_count); - } - - $post_subject = censor_text($post_subject); - - $post_anchor = ($mode == 'post_review') ? 'ppr' . $row['post_id'] : 'pr' . $row['post_id']; - $u_show_post = append_sid($phpbb_root_path . 'viewtopic.' . $phpEx, "f=$forum_id&t=$topic_id&p={$row['post_id']}&view=show#p{$row['post_id']}"); - - $l_deleted_message = ''; - if ($row['post_visibility'] == ITEM_DELETED) - { - $display_postername = get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']); - - // User having deleted the post also being the post author? - if (!$row['post_delete_user'] || $row['post_delete_user'] == $poster_id) - { - $display_username = $display_postername; - } - else - { - $display_username = get_username_string('full', $row['post_delete_user'], $row['post_delete_username'], $row['post_delete_user_colour']); - } - - if ($row['post_delete_reason']) - { - $l_deleted_message = $user->lang('POST_DELETED_BY_REASON', $display_postername, $display_username, $user->format_date($row['post_delete_time'], false, true), $row['post_delete_reason']); - } - else - { - $l_deleted_message = $user->lang('POST_DELETED_BY', $display_postername, $display_username, $user->format_date($row['post_delete_time'], false, true)); - } - } - - $post_row = array( - 'POST_AUTHOR_FULL' => get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), - 'POST_AUTHOR_COLOUR' => get_username_string('colour', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), - 'POST_AUTHOR' => get_username_string('username', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), - 'U_POST_AUTHOR' => get_username_string('profile', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), - - 'S_HAS_ATTACHMENTS' => (!empty($attachments[$row['post_id']])) ? true : false, - 'S_FRIEND' => ($row['friend']) ? true : false, - 'S_IGNORE_POST' => ($row['foe']) ? true : false, - 'L_IGNORE_POST' => ($row['foe']) ? sprintf($user->lang['POST_BY_FOE'], get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), "", '') : '', - 'S_POST_DELETED' => ($row['post_visibility'] == ITEM_DELETED) ? true : false, - 'L_DELETE_POST' => $l_deleted_message, - - 'POST_SUBJECT' => $post_subject, - 'MINI_POST_IMG' => $user->img('icon_post_target', $user->lang['POST']), - 'POST_DATE' => $user->format_date($row['post_time']), - 'MESSAGE' => $message, - 'DECODED_MESSAGE' => $decoded_message, - 'POST_ID' => $row['post_id'], - 'POST_TIME' => $row['post_time'], - 'USER_ID' => $row['user_id'], - 'U_MINI_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $row['post_id']) . '#p' . $row['post_id'], - 'U_MCP_DETAILS' => ($auth->acl_get('m_info', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=post_details&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '', - 'POSTER_QUOTE' => ($show_quote_button && $auth->acl_get('f_reply', $forum_id)) ? addslashes(get_username_string('username', $poster_id, $row['username'], $row['user_colour'], $row['post_username'])) : '', - ); - - $current_row_number = $i; - - /** - * Event to modify the template data block for topic reviews - * - * @event core.topic_review_modify_row - * @var string mode The review mode - * @var int topic_id The topic that is being reviewed - * @var int forum_id The topic's forum - * @var int cur_post_id Post offset id - * @var int current_row_number Number of the current row being iterated - * @var array post_row Template block array of the current post - * @var array row Array with original post and user data - * @since 3.1.4-RC1 - */ - $vars = array( - 'mode', - 'topic_id', - 'forum_id', - 'cur_post_id', - 'current_row_number', - 'post_row', - 'row', - ); - extract($phpbb_dispatcher->trigger_event('core.topic_review_modify_row', compact($vars))); - - $template->assign_block_vars($mode . '_row', $post_row); - - // Display not already displayed Attachments for this post, we already parsed them. ;) - if (!empty($attachments[$row['post_id']])) - { - foreach ($attachments[$row['post_id']] as $attachment) - { - $template->assign_block_vars($mode . '_row.attachment', array( - 'DISPLAY_ATTACHMENT' => $attachment) - ); - } - } - - unset($rowset[$post_list[$i]]); - } - - if ($mode == 'topic_review') - { - $template->assign_var('QUOTE_IMG', $user->img('icon_post_quote', $user->lang['REPLY_WITH_QUOTE'])); - } - - return true; -} - -// -// Post handling functions -// - -/** -* Delete Post -*/ -function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false, $softdelete_reason = '') -{ - global $db, $user, $phpbb_container, $phpbb_dispatcher; - global $config, $phpEx, $phpbb_root_path; - - // Specify our post mode - $post_mode = 'delete'; - if (($data['topic_first_post_id'] === $data['topic_last_post_id']) && ($data['topic_posts_approved'] + $data['topic_posts_unapproved'] + $data['topic_posts_softdeleted'] == 1)) - { - $post_mode = 'delete_topic'; - } - else if ($data['topic_first_post_id'] == $post_id) - { - $post_mode = 'delete_first_post'; - } - else if ($data['topic_last_post_id'] == $post_id) - { - $post_mode = 'delete_last_post'; - } - $sql_data = array(); - $next_post_id = false; - - include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx); - - $db->sql_transaction('begin'); - - // we must make sure to update forums that contain the shadow'd topic - if ($post_mode == 'delete_topic') - { - $shadow_forum_ids = array(); - - $sql = 'SELECT forum_id - FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_moved_id', $topic_id); - $result = $db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) - { - if (!isset($shadow_forum_ids[(int) $row['forum_id']])) - { - $shadow_forum_ids[(int) $row['forum_id']] = 1; - } - else - { - $shadow_forum_ids[(int) $row['forum_id']]++; - } - } - $db->sql_freeresult($result); - } - - /* @var $phpbb_content_visibility \phpbb\content_visibility */ - $phpbb_content_visibility = $phpbb_container->get('content.visibility'); - - // (Soft) delete the post - if ($is_soft && ($post_mode != 'delete_topic')) - { - $phpbb_content_visibility->set_post_visibility(ITEM_DELETED, $post_id, $topic_id, $forum_id, $user->data['user_id'], time(), $softdelete_reason, ($data['topic_first_post_id'] == $post_id), ($data['topic_last_post_id'] == $post_id)); - } - else if (!$is_soft) - { - if (!delete_posts('post_id', array($post_id), false, false, false)) - { - // Try to delete topic, we may had an previous error causing inconsistency - if ($post_mode == 'delete_topic') - { - delete_topics('topic_id', array($topic_id), false); - } - trigger_error('ALREADY_DELETED'); - } - } - - $db->sql_transaction('commit'); - - // Collect the necessary information for updating the tables - $sql_data[FORUMS_TABLE] = $sql_data[TOPICS_TABLE] = ''; - switch ($post_mode) - { - case 'delete_topic': - - foreach ($shadow_forum_ids as $updated_forum => $topic_count) - { - // counting is fun! we only have to do count($forum_ids) number of queries, - // even if the topic is moved back to where its shadow lives (we count how many times it is in a forum) - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET forum_topics_approved = forum_topics_approved - ' . $topic_count . ' - WHERE forum_id = ' . $updated_forum; - $db->sql_query($sql); - update_post_information('forum', $updated_forum); - } - - if ($is_soft) - { - $phpbb_content_visibility->set_topic_visibility(ITEM_DELETED, $topic_id, $forum_id, $user->data['user_id'], time(), $softdelete_reason); - } - else - { - delete_topics('topic_id', array($topic_id), false); - - $phpbb_content_visibility->remove_topic_from_statistic($data, $sql_data); - - $update_sql = update_post_information('forum', $forum_id, true); - if (count($update_sql)) - { - $sql_data[FORUMS_TABLE] .= ($sql_data[FORUMS_TABLE]) ? ', ' : ''; - $sql_data[FORUMS_TABLE] .= implode(', ', $update_sql[$forum_id]); - } - } - - break; - - case 'delete_first_post': - $sql = 'SELECT p.post_id, p.poster_id, p.post_time, p.post_username, u.username, u.user_colour - FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . " u - WHERE p.topic_id = $topic_id - AND p.poster_id = u.user_id - AND p.post_visibility = " . ITEM_APPROVED . ' - ORDER BY p.post_time ASC, p.post_id ASC'; - $result = $db->sql_query_limit($sql, 1); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - // No approved post, so the first is a not-approved post (unapproved or soft deleted) - $sql = 'SELECT p.post_id, p.poster_id, p.post_time, p.post_username, u.username, u.user_colour - FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . " u - WHERE p.topic_id = $topic_id - AND p.poster_id = u.user_id - ORDER BY p.post_time ASC, p.post_id ASC"; - $result = $db->sql_query_limit($sql, 1); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - } - - $next_post_id = (int) $row['post_id']; - - $sql_data[TOPICS_TABLE] = $db->sql_build_array('UPDATE', array( - 'topic_poster' => (int) $row['poster_id'], - 'topic_first_post_id' => (int) $row['post_id'], - 'topic_first_poster_colour' => $row['user_colour'], - 'topic_first_poster_name' => ($row['poster_id'] == ANONYMOUS) ? $row['post_username'] : $row['username'], - 'topic_time' => (int) $row['post_time'], - )); - break; - - case 'delete_last_post': - if (!$is_soft) - { - // Update last post information when hard deleting. Soft delete already did that by itself. - $update_sql = update_post_information('forum', $forum_id, true); - if (count($update_sql)) - { - $sql_data[FORUMS_TABLE] = (($sql_data[FORUMS_TABLE]) ? $sql_data[FORUMS_TABLE] . ', ' : '') . implode(', ', $update_sql[$forum_id]); - } - - $sql_data[TOPICS_TABLE] = (($sql_data[TOPICS_TABLE]) ? $sql_data[TOPICS_TABLE] . ', ' : '') . 'topic_bumped = 0, topic_bumper = 0'; - - $update_sql = update_post_information('topic', $topic_id, true); - if (!empty($update_sql)) - { - $sql_data[TOPICS_TABLE] .= ', ' . implode(', ', $update_sql[$topic_id]); - $next_post_id = (int) str_replace('topic_last_post_id = ', '', $update_sql[$topic_id][0]); - } - } - - if (!$next_post_id) - { - $sql = 'SELECT MAX(post_id) as last_post_id - FROM ' . POSTS_TABLE . " - WHERE topic_id = $topic_id - AND " . $phpbb_content_visibility->get_visibility_sql('post', $forum_id); - $result = $db->sql_query($sql); - $next_post_id = (int) $db->sql_fetchfield('last_post_id'); - $db->sql_freeresult($result); - } - break; - - case 'delete': - $sql = 'SELECT post_id - FROM ' . POSTS_TABLE . " - WHERE topic_id = $topic_id - AND " . $phpbb_content_visibility->get_visibility_sql('post', $forum_id) . ' - AND post_time > ' . $data['post_time'] . ' - ORDER BY post_time ASC, post_id ASC'; - $result = $db->sql_query_limit($sql, 1); - $next_post_id = (int) $db->sql_fetchfield('post_id'); - $db->sql_freeresult($result); - break; - } - - if (($post_mode == 'delete') || ($post_mode == 'delete_last_post') || ($post_mode == 'delete_first_post')) - { - if (!$is_soft) - { - $phpbb_content_visibility->remove_post_from_statistic($data, $sql_data); - } - - $sql = 'SELECT 1 AS has_attachments - FROM ' . ATTACHMENTS_TABLE . ' - WHERE topic_id = ' . $topic_id; - $result = $db->sql_query_limit($sql, 1); - $has_attachments = (int) $db->sql_fetchfield('has_attachments'); - $db->sql_freeresult($result); - - if (!$has_attachments) - { - $sql_data[TOPICS_TABLE] = (($sql_data[TOPICS_TABLE]) ? $sql_data[TOPICS_TABLE] . ', ' : '') . 'topic_attachment = 0'; - } - } - - $db->sql_transaction('begin'); - - $where_sql = array( - FORUMS_TABLE => "forum_id = $forum_id", - TOPICS_TABLE => "topic_id = $topic_id", - USERS_TABLE => 'user_id = ' . $data['poster_id'], - ); - - foreach ($sql_data as $table => $update_sql) - { - if ($update_sql) - { - $db->sql_query("UPDATE $table SET $update_sql WHERE " . $where_sql[$table]); - } - } - - // Adjust posted info for this user by looking for a post by him/her within this topic... - if ($post_mode != 'delete_topic' && $config['load_db_track'] && $data['poster_id'] != ANONYMOUS) - { - $sql = 'SELECT poster_id - FROM ' . POSTS_TABLE . ' - WHERE topic_id = ' . $topic_id . ' - AND poster_id = ' . $data['poster_id']; - $result = $db->sql_query_limit($sql, 1); - $poster_id = (int) $db->sql_fetchfield('poster_id'); - $db->sql_freeresult($result); - - // The user is not having any more posts within this topic - if (!$poster_id) - { - $sql = 'DELETE FROM ' . TOPICS_POSTED_TABLE . ' - WHERE topic_id = ' . $topic_id . ' - AND user_id = ' . $data['poster_id']; - $db->sql_query($sql); - } - } - - $db->sql_transaction('commit'); - - if ($data['post_reported'] && ($post_mode != 'delete_topic')) - { - sync('topic_reported', 'topic_id', array($topic_id)); - } - - /** - * This event is used for performing actions directly after a post or topic - * has been deleted. - * - * @event core.delete_post_after - * @var int forum_id Post forum ID - * @var int topic_id Post topic ID - * @var int post_id Post ID - * @var array data Post data - * @var bool is_soft Soft delete flag - * @var string softdelete_reason Soft delete reason - * @var string post_mode delete_topic, delete_first_post, delete_last_post or delete - * @var mixed next_post_id Next post ID in the topic (post ID or false) - * - * @since 3.1.11-RC1 - */ - $vars = array( - 'forum_id', - 'topic_id', - 'post_id', - 'data', - 'is_soft', - 'softdelete_reason', - 'post_mode', - 'next_post_id', - ); - extract($phpbb_dispatcher->trigger_event('core.delete_post_after', compact($vars))); - - return $next_post_id; -} - -/** -* Submit Post -* @todo Split up and create lightweight, simple API for this. -*/ -function submit_post($mode, $subject, $username, $topic_type, &$poll_ary, &$data_ary, $update_message = true, $update_search_index = true) -{ - global $db, $auth, $user, $config, $phpEx, $phpbb_root_path, $phpbb_container, $phpbb_dispatcher, $phpbb_log, $request; - - $poll = $poll_ary; - $data = $data_ary; - /** - * Modify the data for post submitting - * - * @event core.modify_submit_post_data - * @var string mode Variable containing posting mode value - * @var string subject Variable containing post subject value - * @var string username Variable containing post author name - * @var int topic_type Variable containing topic type value - * @var array poll Array with the poll data for the post - * @var array data Array with the data for the post - * @var bool update_message Flag indicating if the post will be updated - * @var bool update_search_index Flag indicating if the search index will be updated - * @since 3.1.0-a4 - */ - $vars = array( - 'mode', - 'subject', - 'username', - 'topic_type', - 'poll', - 'data', - 'update_message', - 'update_search_index', - ); - extract($phpbb_dispatcher->trigger_event('core.modify_submit_post_data', compact($vars))); - $poll_ary = $poll; - $data_ary = $data; - unset($poll); - unset($data); - - // We do not handle erasing posts here - if ($mode == 'delete') - { - return false; - } - - if (!empty($data_ary['post_time'])) - { - $current_time = $data_ary['post_time']; - } - else - { - $current_time = time(); - } - - if ($mode == 'post') - { - $post_mode = 'post'; - $update_message = true; - } - else if ($mode != 'edit') - { - $post_mode = 'reply'; - $update_message = true; - } - else if ($mode == 'edit') - { - $post_mode = ($data_ary['topic_posts_approved'] + $data_ary['topic_posts_unapproved'] + $data_ary['topic_posts_softdeleted'] == 1) ? 'edit_topic' : (($data_ary['topic_first_post_id'] == $data_ary['post_id']) ? 'edit_first_post' : (($data_ary['topic_last_post_id'] == $data_ary['post_id']) ? 'edit_last_post' : 'edit')); - } - - // First of all make sure the subject and topic title are having the correct length. - // To achieve this without cutting off between special chars we convert to an array and then count the elements. - $subject = truncate_string($subject, 120); - $data_ary['topic_title'] = truncate_string($data_ary['topic_title'], 120); - - // Collect some basic information about which tables and which rows to update/insert - $sql_data = $topic_row = array(); - $poster_id = ($mode == 'edit') ? $data_ary['poster_id'] : (int) $user->data['user_id']; - - // Retrieve some additional information if not present - if ($mode == 'edit' && (!isset($data_ary['post_visibility']) || !isset($data_ary['topic_visibility']) || $data_ary['post_visibility'] === false || $data_ary['topic_visibility'] === false)) - { - $sql = 'SELECT p.post_visibility, t.topic_type, t.topic_posts_approved, t.topic_posts_unapproved, t.topic_posts_softdeleted, t.topic_visibility - FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p - WHERE t.topic_id = p.topic_id - AND p.post_id = ' . $data_ary['post_id']; - $result = $db->sql_query($sql); - $topic_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $data_ary['topic_visibility'] = $topic_row['topic_visibility']; - $data_ary['post_visibility'] = $topic_row['post_visibility']; - } - - // This variable indicates if the user is able to post or put into the queue - $post_visibility = ITEM_APPROVED; - - // Check the permissions for post approval. - // Moderators must go through post approval like ordinary users. - if (!$auth->acl_get('f_noapprove', $data_ary['forum_id'])) - { - // Post not approved, but in queue - $post_visibility = ITEM_UNAPPROVED; - switch ($post_mode) - { - case 'edit_first_post': - case 'edit': - case 'edit_last_post': - case 'edit_topic': - $post_visibility = ITEM_REAPPROVE; - break; - } - } - else if (isset($data_ary['post_visibility']) && $data_ary['post_visibility'] !== false) - { - $post_visibility = $data_ary['post_visibility']; - } - - // MODs/Extensions are able to force any visibility on posts - if (isset($data_ary['force_approved_state'])) - { - $post_visibility = (in_array((int) $data_ary['force_approved_state'], array(ITEM_APPROVED, ITEM_UNAPPROVED, ITEM_DELETED, ITEM_REAPPROVE))) ? (int) $data_ary['force_approved_state'] : $post_visibility; - } - if (isset($data_ary['force_visibility'])) - { - $post_visibility = (in_array((int) $data_ary['force_visibility'], array(ITEM_APPROVED, ITEM_UNAPPROVED, ITEM_DELETED, ITEM_REAPPROVE))) ? (int) $data_ary['force_visibility'] : $post_visibility; - } - - // Start the transaction here - $db->sql_transaction('begin'); - - // Collect Information - switch ($post_mode) - { - case 'post': - case 'reply': - $sql_data[POSTS_TABLE]['sql'] = array( - 'forum_id' => $data_ary['forum_id'], - 'poster_id' => (int) $user->data['user_id'], - 'icon_id' => $data_ary['icon_id'], - 'poster_ip' => $user->ip, - 'post_time' => $current_time, - 'post_visibility' => $post_visibility, - 'enable_bbcode' => $data_ary['enable_bbcode'], - 'enable_smilies' => $data_ary['enable_smilies'], - 'enable_magic_url' => $data_ary['enable_urls'], - 'enable_sig' => $data_ary['enable_sig'], - 'post_username' => (!$user->data['is_registered']) ? $username : '', - 'post_subject' => $subject, - 'post_text' => $data_ary['message'], - 'post_checksum' => $data_ary['message_md5'], - 'post_attachment' => (!empty($data_ary['attachment_data'])) ? 1 : 0, - 'bbcode_bitfield' => $data_ary['bbcode_bitfield'], - 'bbcode_uid' => $data_ary['bbcode_uid'], - 'post_postcount' => ($auth->acl_get('f_postcount', $data_ary['forum_id'])) ? 1 : 0, - 'post_edit_locked' => $data_ary['post_edit_locked'] - ); - break; - - case 'edit_first_post': - case 'edit': - - case 'edit_last_post': - case 'edit_topic': - - // If edit reason is given always display edit info - - // If editing last post then display no edit info - // If m_edit permission then display no edit info - // If normal edit display edit info - - // Display edit info if edit reason given or user is editing his post, which is not the last within the topic. - if ($data_ary['post_edit_reason'] || (!$auth->acl_get('m_edit', $data_ary['forum_id']) && ($post_mode == 'edit' || $post_mode == 'edit_first_post'))) - { - $data_ary['post_edit_reason'] = truncate_string($data_ary['post_edit_reason'], 255, 255, false); - - $sql_data[POSTS_TABLE]['sql'] = array( - 'post_edit_time' => $current_time, - 'post_edit_reason' => $data_ary['post_edit_reason'], - 'post_edit_user' => (int) $data_ary['post_edit_user'], - ); - - $sql_data[POSTS_TABLE]['stat'][] = 'post_edit_count = post_edit_count + 1'; - } - else if (!$data_ary['post_edit_reason'] && $mode == 'edit' && $auth->acl_get('m_edit', $data_ary['forum_id'])) - { - $sql_data[POSTS_TABLE]['sql'] = array( - 'post_edit_reason' => '', - ); - } - - // If the person editing this post is different to the one having posted then we will add a log entry stating the edit - // Could be simplified by only adding to the log if the edit is not tracked - but this may confuse admins/mods - if ($user->data['user_id'] != $poster_id) - { - $log_subject = ($subject) ? $subject : $data_ary['topic_title']; - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_POST_EDITED', false, array( - 'forum_id' => $data_ary['forum_id'], - 'topic_id' => $data_ary['topic_id'], - 'post_id' => $data_ary['post_id'], - $log_subject, - (!empty($username)) ? $username : $user->lang['GUEST'], - $data_ary['post_edit_reason'] - )); - } - - if (!isset($sql_data[POSTS_TABLE]['sql'])) - { - $sql_data[POSTS_TABLE]['sql'] = array(); - } - - $sql_data[POSTS_TABLE]['sql'] = array_merge($sql_data[POSTS_TABLE]['sql'], array( - 'forum_id' => $data_ary['forum_id'], - 'poster_id' => $data_ary['poster_id'], - 'icon_id' => $data_ary['icon_id'], - // We will change the visibility later - //'post_visibility' => $post_visibility, - 'enable_bbcode' => $data_ary['enable_bbcode'], - 'enable_smilies' => $data_ary['enable_smilies'], - 'enable_magic_url' => $data_ary['enable_urls'], - 'enable_sig' => $data_ary['enable_sig'], - 'post_username' => ($username && $data_ary['poster_id'] == ANONYMOUS) ? $username : '', - 'post_subject' => $subject, - 'post_checksum' => $data_ary['message_md5'], - 'post_attachment' => (!empty($data_ary['attachment_data'])) ? 1 : 0, - 'bbcode_bitfield' => $data_ary['bbcode_bitfield'], - 'bbcode_uid' => $data_ary['bbcode_uid'], - 'post_edit_locked' => $data_ary['post_edit_locked']) - ); - - if ($update_message) - { - $sql_data[POSTS_TABLE]['sql']['post_text'] = $data_ary['message']; - } - - break; - } - - // And the topic ladies and gentlemen - switch ($post_mode) - { - case 'post': - $sql_data[TOPICS_TABLE]['sql'] = array( - 'topic_poster' => (int) $user->data['user_id'], - 'topic_time' => $current_time, - 'topic_last_view_time' => $current_time, - 'forum_id' => $data_ary['forum_id'], - 'icon_id' => $data_ary['icon_id'], - 'topic_posts_approved' => ($post_visibility == ITEM_APPROVED) ? 1 : 0, - 'topic_posts_softdeleted' => ($post_visibility == ITEM_DELETED) ? 1 : 0, - 'topic_posts_unapproved' => ($post_visibility == ITEM_UNAPPROVED) ? 1 : 0, - 'topic_visibility' => $post_visibility, - 'topic_delete_user' => ($post_visibility != ITEM_APPROVED) ? (int) $user->data['user_id'] : 0, - 'topic_title' => $subject, - 'topic_first_poster_name' => (!$user->data['is_registered'] && $username) ? $username : (($user->data['user_id'] != ANONYMOUS) ? $user->data['username'] : ''), - 'topic_first_poster_colour' => $user->data['user_colour'], - 'topic_type' => $topic_type, - 'topic_time_limit' => $topic_type != POST_NORMAL ? ($data_ary['topic_time_limit'] * 86400) : 0, - 'topic_attachment' => (!empty($data_ary['attachment_data'])) ? 1 : 0, - 'topic_status' => (isset($data_ary['topic_status'])) ? $data_ary['topic_status'] : ITEM_UNLOCKED, - ); - - if (isset($poll_ary['poll_options']) && !empty($poll_ary['poll_options'])) - { - $poll_start = ($poll_ary['poll_start']) ? $poll_ary['poll_start'] : $current_time; - $poll_length = $poll_ary['poll_length'] * 86400; - if ($poll_length < 0) - { - $poll_start = $poll_start + $poll_length; - if ($poll_start < 0) - { - $poll_start = 0; - } - $poll_length = 1; - } - - $sql_data[TOPICS_TABLE]['sql'] = array_merge($sql_data[TOPICS_TABLE]['sql'], array( - 'poll_title' => $poll_ary['poll_title'], - 'poll_start' => $poll_start, - 'poll_max_options' => $poll_ary['poll_max_options'], - 'poll_length' => $poll_length, - 'poll_vote_change' => $poll_ary['poll_vote_change']) - ); - } - - $sql_data[USERS_TABLE]['stat'][] = "user_lastpost_time = $current_time" . (($auth->acl_get('f_postcount', $data_ary['forum_id']) && $post_visibility == ITEM_APPROVED) ? ', user_posts = user_posts + 1' : ''); - - if ($post_visibility == ITEM_APPROVED) - { - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_topics_approved = forum_topics_approved + 1'; - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts_approved = forum_posts_approved + 1'; - } - else if ($post_visibility == ITEM_UNAPPROVED) - { - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_topics_unapproved = forum_topics_unapproved + 1'; - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts_unapproved = forum_posts_unapproved + 1'; - } - else if ($post_visibility == ITEM_DELETED) - { - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_topics_softdeleted = forum_topics_softdeleted + 1'; - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts_softdeleted = forum_posts_softdeleted + 1'; - } - break; - - case 'reply': - $sql_data[TOPICS_TABLE]['stat'][] = 'topic_last_view_time = ' . $current_time . ', - topic_bumped = 0, - topic_bumper = 0' . - (($post_visibility == ITEM_APPROVED) ? ', topic_posts_approved = topic_posts_approved + 1' : '') . - (($post_visibility == ITEM_UNAPPROVED) ? ', topic_posts_unapproved = topic_posts_unapproved + 1' : '') . - (($post_visibility == ITEM_DELETED) ? ', topic_posts_softdeleted = topic_posts_softdeleted + 1' : '') . - ((!empty($data_ary['attachment_data']) || (isset($data_ary['topic_attachment']) && $data_ary['topic_attachment'])) ? ', topic_attachment = 1' : ''); - - $sql_data[USERS_TABLE]['stat'][] = "user_lastpost_time = $current_time" . (($auth->acl_get('f_postcount', $data_ary['forum_id']) && $post_visibility == ITEM_APPROVED) ? ', user_posts = user_posts + 1' : ''); - - if ($post_visibility == ITEM_APPROVED) - { - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts_approved = forum_posts_approved + 1'; - } - else if ($post_visibility == ITEM_UNAPPROVED) - { - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts_unapproved = forum_posts_unapproved + 1'; - } - else if ($post_visibility == ITEM_DELETED) - { - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts_softdeleted = forum_posts_softdeleted + 1'; - } - break; - - case 'edit_topic': - case 'edit_first_post': - if (isset($poll_ary['poll_options'])) - { - $poll_start = ($poll_ary['poll_start'] || empty($poll_ary['poll_options'])) ? $poll_ary['poll_start'] : $current_time; - $poll_length = $poll_ary['poll_length'] * 86400; - if ($poll_length < 0) - { - $poll_start = $poll_start + $poll_length; - if ($poll_start < 0) - { - $poll_start = 0; - } - $poll_length = 1; - } - } - - $sql_data[TOPICS_TABLE]['sql'] = array( - 'forum_id' => $data_ary['forum_id'], - 'icon_id' => $data_ary['icon_id'], - 'topic_title' => $subject, - 'topic_first_poster_name' => $username, - 'topic_type' => $topic_type, - 'topic_time_limit' => $topic_type != POST_NORMAL ? ($data_ary['topic_time_limit'] * 86400) : 0, - 'poll_title' => (isset($poll_ary['poll_options'])) ? $poll_ary['poll_title'] : '', - 'poll_start' => (isset($poll_ary['poll_options'])) ? $poll_start : 0, - 'poll_max_options' => (isset($poll_ary['poll_options'])) ? $poll_ary['poll_max_options'] : 1, - 'poll_length' => (isset($poll_ary['poll_options'])) ? $poll_length : 0, - 'poll_vote_change' => (isset($poll_ary['poll_vote_change'])) ? $poll_ary['poll_vote_change'] : 0, - 'topic_last_view_time' => $current_time, - - 'topic_attachment' => (!empty($data_ary['attachment_data'])) ? 1 : (isset($data_ary['topic_attachment']) ? $data_ary['topic_attachment'] : 0), - ); - - break; - } - - $poll = $poll_ary; - $data = $data_ary; - /** - * Modify sql query data for post submitting - * - * @event core.submit_post_modify_sql_data - * @var array data Array with the data for the post - * @var array poll Array with the poll data for the post - * @var string post_mode Variable containing posting mode value - * @var bool sql_data Array with the data for the posting SQL query - * @var string subject Variable containing post subject value - * @var int topic_type Variable containing topic type value - * @var string username Variable containing post author name - * @since 3.1.3-RC1 - */ - $vars = array( - 'data', - 'poll', - 'post_mode', - 'sql_data', - 'subject', - 'topic_type', - 'username', - ); - extract($phpbb_dispatcher->trigger_event('core.submit_post_modify_sql_data', compact($vars))); - $poll_ary = $poll; - $data_ary = $data; - unset($poll); - unset($data); - - // Submit new topic - if ($post_mode == 'post') - { - $sql = 'INSERT INTO ' . TOPICS_TABLE . ' ' . - $db->sql_build_array('INSERT', $sql_data[TOPICS_TABLE]['sql']); - $db->sql_query($sql); - - $data_ary['topic_id'] = $db->sql_nextid(); - - $sql_data[POSTS_TABLE]['sql'] = array_merge($sql_data[POSTS_TABLE]['sql'], array( - 'topic_id' => $data_ary['topic_id']) - ); - unset($sql_data[TOPICS_TABLE]['sql']); - } - - // Submit new post - if ($post_mode == 'post' || $post_mode == 'reply') - { - if ($post_mode == 'reply') - { - $sql_data[POSTS_TABLE]['sql'] = array_merge($sql_data[POSTS_TABLE]['sql'], array( - 'topic_id' => $data_ary['topic_id'], - )); - } - - $sql = 'INSERT INTO ' . POSTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_data[POSTS_TABLE]['sql']); - $db->sql_query($sql); - $data_ary['post_id'] = $db->sql_nextid(); - - if ($post_mode == 'post' || $post_visibility == ITEM_APPROVED) - { - $sql_data[TOPICS_TABLE]['sql'] = array( - 'topic_last_post_id' => $data_ary['post_id'], - 'topic_last_post_time' => $current_time, - 'topic_last_poster_id' => $sql_data[POSTS_TABLE]['sql']['poster_id'], - 'topic_last_poster_name' => ($user->data['user_id'] == ANONYMOUS) ? $sql_data[POSTS_TABLE]['sql']['post_username'] : $user->data['username'], - 'topic_last_poster_colour' => $user->data['user_colour'], - 'topic_last_post_subject' => (string) $subject, - ); - } - - if ($post_mode == 'post') - { - $sql_data[TOPICS_TABLE]['sql']['topic_first_post_id'] = $data_ary['post_id']; - } - - // Update total post count and forum information - if ($post_visibility == ITEM_APPROVED) - { - if ($post_mode == 'post') - { - $config->increment('num_topics', 1, false); - } - $config->increment('num_posts', 1, false); - - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_id = ' . $data_ary['post_id']; - $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_post_subject = '" . $db->sql_escape($subject) . "'"; - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_time = ' . $current_time; - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_id = ' . (int) $user->data['user_id']; - $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_name = '" . $db->sql_escape((!$user->data['is_registered'] && $username) ? $username : (($user->data['user_id'] != ANONYMOUS) ? $user->data['username'] : '')) . "'"; - $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_colour = '" . $db->sql_escape($user->data['user_colour']) . "'"; - } - - unset($sql_data[POSTS_TABLE]['sql']); - } - - // Update the topics table - if (isset($sql_data[TOPICS_TABLE]['sql'])) - { - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_data[TOPICS_TABLE]['sql']) . ' - WHERE topic_id = ' . $data_ary['topic_id']; - $db->sql_query($sql); - - unset($sql_data[TOPICS_TABLE]['sql']); - } - - // Update the posts table - if (isset($sql_data[POSTS_TABLE]['sql'])) - { - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_data[POSTS_TABLE]['sql']) . ' - WHERE post_id = ' . $data_ary['post_id']; - $db->sql_query($sql); - - unset($sql_data[POSTS_TABLE]['sql']); - } - - // Update Poll Tables - if (isset($poll_ary['poll_options'])) - { - $cur_poll_options = array(); - - if ($mode == 'edit') - { - $sql = 'SELECT * - FROM ' . POLL_OPTIONS_TABLE . ' - WHERE topic_id = ' . $data_ary['topic_id'] . ' - ORDER BY poll_option_id'; - $result = $db->sql_query($sql); - - $cur_poll_options = array(); - while ($row = $db->sql_fetchrow($result)) - { - $cur_poll_options[] = $row; - } - $db->sql_freeresult($result); - } - - $sql_insert_ary = array(); - - for ($i = 0, $size = count($poll_ary['poll_options']); $i < $size; $i++) - { - if (strlen(trim($poll_ary['poll_options'][$i]))) - { - if (empty($cur_poll_options[$i])) - { - // If we add options we need to put them to the end to be able to preserve votes... - $sql_insert_ary[] = array( - 'poll_option_id' => (int) count($cur_poll_options) + 1 + count($sql_insert_ary), - 'topic_id' => (int) $data_ary['topic_id'], - 'poll_option_text' => (string) $poll_ary['poll_options'][$i] - ); - } - else if ($poll_ary['poll_options'][$i] != $cur_poll_options[$i]) - { - $sql = 'UPDATE ' . POLL_OPTIONS_TABLE . " - SET poll_option_text = '" . $db->sql_escape($poll_ary['poll_options'][$i]) . "' - WHERE poll_option_id = " . $cur_poll_options[$i]['poll_option_id'] . ' - AND topic_id = ' . $data_ary['topic_id']; - $db->sql_query($sql); - } - } - } - - $db->sql_multi_insert(POLL_OPTIONS_TABLE, $sql_insert_ary); - - if (count($poll_ary['poll_options']) < count($cur_poll_options)) - { - $sql = 'DELETE FROM ' . POLL_OPTIONS_TABLE . ' - WHERE poll_option_id > ' . count($poll_ary['poll_options']) . ' - AND topic_id = ' . $data_ary['topic_id']; - $db->sql_query($sql); - } - - // If edited, we would need to reset votes (since options can be re-ordered above, you can't be sure if the change is for changing the text or adding an option - if ($mode == 'edit' && count($poll_ary['poll_options']) != count($cur_poll_options)) - { - $db->sql_query('DELETE FROM ' . POLL_VOTES_TABLE . ' WHERE topic_id = ' . $data_ary['topic_id']); - $db->sql_query('UPDATE ' . POLL_OPTIONS_TABLE . ' SET poll_option_total = 0 WHERE topic_id = ' . $data_ary['topic_id']); - } - } - - // Submit Attachments - if (!empty($data_ary['attachment_data']) && $data_ary['post_id'] && in_array($mode, array('post', 'reply', 'quote', 'edit'))) - { - $space_taken = $files_added = 0; - $orphan_rows = array(); - - foreach ($data_ary['attachment_data'] as $pos => $attach_row) - { - $orphan_rows[(int) $attach_row['attach_id']] = array(); - } - - if (count($orphan_rows)) - { - $sql = 'SELECT attach_id, filesize, physical_filename - FROM ' . ATTACHMENTS_TABLE . ' - WHERE ' . $db->sql_in_set('attach_id', array_keys($orphan_rows)) . ' - AND is_orphan = 1 - AND poster_id = ' . $user->data['user_id']; - $result = $db->sql_query($sql); - - $orphan_rows = array(); - while ($row = $db->sql_fetchrow($result)) - { - $orphan_rows[$row['attach_id']] = $row; - } - $db->sql_freeresult($result); - } - - foreach ($data_ary['attachment_data'] as $pos => $attach_row) - { - if ($attach_row['is_orphan'] && !isset($orphan_rows[$attach_row['attach_id']])) - { - continue; - } - - if (!$attach_row['is_orphan']) - { - // update entry in db if attachment already stored in db and filespace - $sql = 'UPDATE ' . ATTACHMENTS_TABLE . " - SET attach_comment = '" . $db->sql_escape($attach_row['attach_comment']) . "' - WHERE attach_id = " . (int) $attach_row['attach_id'] . ' - AND is_orphan = 0'; - $db->sql_query($sql); - } - else - { - // insert attachment into db - if (!@file_exists($phpbb_root_path . $config['upload_path'] . '/' . utf8_basename($orphan_rows[$attach_row['attach_id']]['physical_filename']))) - { - continue; - } - - $space_taken += $orphan_rows[$attach_row['attach_id']]['filesize']; - $files_added++; - - $attach_sql = array( - 'post_msg_id' => $data_ary['post_id'], - 'topic_id' => $data_ary['topic_id'], - 'is_orphan' => 0, - 'poster_id' => $poster_id, - 'attach_comment' => $attach_row['attach_comment'], - ); - - $sql = 'UPDATE ' . ATTACHMENTS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $attach_sql) . ' - WHERE attach_id = ' . $attach_row['attach_id'] . ' - AND is_orphan = 1 - AND poster_id = ' . $user->data['user_id']; - $db->sql_query($sql); - } - } - - if ($space_taken && $files_added) - { - $config->increment('upload_dir_size', $space_taken, false); - $config->increment('num_files', $files_added, false); - } - } - - $first_post_has_topic_info = ($post_mode == 'edit_first_post' && - (($post_visibility == ITEM_DELETED && $data_ary['topic_posts_softdeleted'] == 1) || - ($post_visibility == ITEM_UNAPPROVED && $data_ary['topic_posts_unapproved'] == 1) || - ($post_visibility == ITEM_REAPPROVE && $data_ary['topic_posts_unapproved'] == 1) || - ($post_visibility == ITEM_APPROVED && $data_ary['topic_posts_approved'] == 1))); - // Fix the post's and topic's visibility and first/last post information, when the post is edited - if (($post_mode != 'post' && $post_mode != 'reply') && $data_ary['post_visibility'] != $post_visibility) - { - // If the post was not approved, it could also be the starter, - // so we sync the starter after approving/restoring, to ensure that the stats are correct - // Same applies for the last post - $is_starter = ($post_mode == 'edit_first_post' || $post_mode == 'edit_topic' || $data_ary['post_visibility'] != ITEM_APPROVED); - $is_latest = ($post_mode == 'edit_last_post' || $post_mode == 'edit_topic' || $data_ary['post_visibility'] != ITEM_APPROVED); - - /* @var $phpbb_content_visibility \phpbb\content_visibility */ - $phpbb_content_visibility = $phpbb_container->get('content.visibility'); - $phpbb_content_visibility->set_post_visibility($post_visibility, $data_ary['post_id'], $data_ary['topic_id'], $data_ary['forum_id'], $user->data['user_id'], time(), '', $is_starter, $is_latest); - } - else if ($post_mode == 'edit_last_post' || $post_mode == 'edit_topic' || $first_post_has_topic_info) - { - if ($post_visibility == ITEM_APPROVED || $data_ary['topic_visibility'] == $post_visibility) - { - // only the subject can be changed from edit - $sql_data[TOPICS_TABLE]['stat'][] = "topic_last_post_subject = '" . $db->sql_escape($subject) . "'"; - - // Maybe not only the subject, but also changing anonymous usernames. ;) - if ($data_ary['poster_id'] == ANONYMOUS) - { - $sql_data[TOPICS_TABLE]['stat'][] = "topic_last_poster_name = '" . $db->sql_escape($username) . "'"; - } - - if ($post_visibility == ITEM_APPROVED) - { - // this does not _necessarily_ mean that we must update the info again, - // it just means that we might have to - $sql = 'SELECT forum_last_post_id, forum_last_post_subject - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . (int) $data_ary['forum_id']; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - // this post is the latest post in the forum, better update - if ($row['forum_last_post_id'] == $data_ary['post_id'] && ($row['forum_last_post_subject'] !== $subject || $data_ary['poster_id'] == ANONYMOUS)) - { - // the post's subject changed - if ($row['forum_last_post_subject'] !== $subject) - { - $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_post_subject = '" . $db->sql_escape($subject) . "'"; - } - - // Update the user name if poster is anonymous... just in case a moderator changed it - if ($data_ary['poster_id'] == ANONYMOUS) - { - $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_name = '" . $db->sql_escape($username) . "'"; - } - } - } - } - } - - // Update forum stats - $where_sql = array( - POSTS_TABLE => 'post_id = ' . $data_ary['post_id'], - TOPICS_TABLE => 'topic_id = ' . $data_ary['topic_id'], - FORUMS_TABLE => 'forum_id = ' . $data_ary['forum_id'], - USERS_TABLE => 'user_id = ' . $poster_id - ); - - foreach ($sql_data as $table => $update_ary) - { - if (isset($update_ary['stat']) && implode('', $update_ary['stat'])) - { - $sql = "UPDATE $table SET " . implode(', ', $update_ary['stat']) . ' WHERE ' . $where_sql[$table]; - $db->sql_query($sql); - } - } - - // Delete topic shadows (if any exist). We do not need a shadow topic for an global announcement - if ($topic_type == POST_GLOBAL) - { - $sql = 'DELETE FROM ' . TOPICS_TABLE . ' - WHERE topic_moved_id = ' . $data_ary['topic_id']; - $db->sql_query($sql); - } - - // Committing the transaction before updating search index - $db->sql_transaction('commit'); - - // Delete draft if post was loaded... - $draft_id = $request->variable('draft_loaded', 0); - if ($draft_id) - { - $sql = 'DELETE FROM ' . DRAFTS_TABLE . " - WHERE draft_id = $draft_id - AND user_id = {$user->data['user_id']}"; - $db->sql_query($sql); - } - - // Index message contents - if ($update_search_index && $data_ary['enable_indexing']) - { - // Select the search method and do some additional checks to ensure it can actually be utilised - $search_type = $config['search_type']; - - if (!class_exists($search_type)) - { - trigger_error('NO_SUCH_SEARCH_MODULE'); - } - - $error = false; - $search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher); - - if ($error) - { - trigger_error($error); - } - - $search->index($mode, $data_ary['post_id'], $data_ary['message'], $subject, $poster_id, $data_ary['forum_id']); - } - - // Topic Notification, do not change if moderator is changing other users posts... - if ($user->data['user_id'] == $poster_id) - { - if (!$data_ary['notify_set'] && $data_ary['notify']) - { - $sql = 'INSERT INTO ' . TOPICS_WATCH_TABLE . ' (user_id, topic_id) - VALUES (' . $user->data['user_id'] . ', ' . $data_ary['topic_id'] . ')'; - $db->sql_query($sql); - } - else if (($config['email_enable'] || $config['jab_enable']) && $data_ary['notify_set'] && !$data_ary['notify']) - { - $sql = 'DELETE FROM ' . TOPICS_WATCH_TABLE . ' - WHERE user_id = ' . $user->data['user_id'] . ' - AND topic_id = ' . $data_ary['topic_id']; - $db->sql_query($sql); - } - } - - if ($mode == 'post' || $mode == 'reply' || $mode == 'quote') - { - // Mark this topic as posted to - markread('post', $data_ary['forum_id'], $data_ary['topic_id']); - } - - // Mark this topic as read - // We do not use post_time here, this is intended (post_time can have a date in the past if editing a message) - markread('topic', $data_ary['forum_id'], $data_ary['topic_id'], time()); - - // - if ($config['load_db_lastread'] && $user->data['is_registered']) - { - $sql = 'SELECT mark_time - FROM ' . FORUMS_TRACK_TABLE . ' - WHERE user_id = ' . $user->data['user_id'] . ' - AND forum_id = ' . $data_ary['forum_id']; - $result = $db->sql_query($sql); - $f_mark_time = (int) $db->sql_fetchfield('mark_time'); - $db->sql_freeresult($result); - } - else if ($config['load_anon_lastread'] || $user->data['is_registered']) - { - $f_mark_time = false; - } - - if (($config['load_db_lastread'] && $user->data['is_registered']) || $config['load_anon_lastread'] || $user->data['is_registered']) - { - // Update forum info - $sql = 'SELECT forum_last_post_time - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . $data_ary['forum_id']; - $result = $db->sql_query($sql); - $forum_last_post_time = (int) $db->sql_fetchfield('forum_last_post_time'); - $db->sql_freeresult($result); - - update_forum_tracking_info($data_ary['forum_id'], $forum_last_post_time, $f_mark_time, false); - } - - // If a username was supplied or the poster is a guest, we will use the supplied username. - // Doing it this way we can use "...post by guest-username..." in notifications when - // "guest-username" is supplied or ommit the username if it is not. - $username = ($username !== '' || !$user->data['is_registered']) ? $username : $user->data['username']; - - // Send Notifications - $notification_data = array_merge($data_ary, array( - 'topic_title' => (isset($data_ary['topic_title'])) ? $data_ary['topic_title'] : $subject, - 'post_username' => $username, - 'poster_id' => $poster_id, - 'post_text' => $data_ary['message'], - 'post_time' => $current_time, - 'post_subject' => $subject, - )); - - /** - * This event allows you to modify the notification data upon submission - * - * @event core.modify_submit_notification_data - * @var array notification_data The notification data to be inserted in to the database - * @var array data_ary The data array with a lot of the post submission data - * @var string mode The posting mode - * @var int poster_id The poster id - * @since 3.2.4-RC1 - */ - $vars = array('notification_data', 'data_ary', 'mode', 'poster_id'); - extract($phpbb_dispatcher->trigger_event('core.modify_submit_notification_data', compact($vars))); - - /* @var $phpbb_notifications \phpbb\notification\manager */ - $phpbb_notifications = $phpbb_container->get('notification_manager'); - - if ($post_visibility == ITEM_APPROVED) - { - switch ($mode) - { - case 'post': - $phpbb_notifications->add_notifications(array( - 'notification.type.quote', - 'notification.type.topic', - ), $notification_data); - break; - - case 'reply': - case 'quote': - $phpbb_notifications->add_notifications(array( - 'notification.type.quote', - 'notification.type.bookmark', - 'notification.type.post', - ), $notification_data); - break; - - case 'edit_topic': - case 'edit_first_post': - case 'edit': - case 'edit_last_post': - if ($user->data['user_id'] == $poster_id) - { - $phpbb_notifications->update_notifications(array( - 'notification.type.quote', - ), $notification_data); - } - - $phpbb_notifications->update_notifications(array( - 'notification.type.bookmark', - 'notification.type.topic', - 'notification.type.post', - ), $notification_data); - break; - } - } - else if ($post_visibility == ITEM_UNAPPROVED) - { - switch ($mode) - { - case 'post': - $phpbb_notifications->add_notifications('notification.type.topic_in_queue', $notification_data); - break; - - case 'reply': - case 'quote': - $phpbb_notifications->add_notifications('notification.type.post_in_queue', $notification_data); - break; - - case 'edit_topic': - case 'edit_first_post': - case 'edit': - case 'edit_last_post': - // Nothing to do here - break; - } - } - else if ($post_visibility == ITEM_REAPPROVE) - { - switch ($mode) - { - case 'edit_topic': - case 'edit_first_post': - $phpbb_notifications->add_notifications('notification.type.topic_in_queue', $notification_data); - - // Delete the approve_post notification so we can notify the user again, - // when his post got reapproved - $phpbb_notifications->delete_notifications('notification.type.approve_post', $notification_data['post_id']); - break; - - case 'edit': - case 'edit_last_post': - $phpbb_notifications->add_notifications('notification.type.post_in_queue', $notification_data); - - // Delete the approve_post notification so we can notify the user again, - // when his post got reapproved - $phpbb_notifications->delete_notifications('notification.type.approve_post', $notification_data['post_id']); - break; - - case 'post': - case 'reply': - case 'quote': - // Nothing to do here - break; - } - } - else if ($post_visibility == ITEM_DELETED) - { - switch ($mode) - { - case 'post': - case 'reply': - case 'quote': - case 'edit_topic': - case 'edit_first_post': - case 'edit': - case 'edit_last_post': - // Nothing to do here - break; - } - } - - $params = $add_anchor = ''; - - if ($post_visibility == ITEM_APPROVED || - ($auth->acl_get('m_softdelete', $data_ary['forum_id']) && $post_visibility == ITEM_DELETED) || - ($auth->acl_get('m_approve', $data_ary['forum_id']) && in_array($post_visibility, array(ITEM_UNAPPROVED, ITEM_REAPPROVE)))) - { - $params .= '&t=' . $data_ary['topic_id']; - - if ($mode != 'post') - { - $params .= '&p=' . $data_ary['post_id']; - $add_anchor = '#p' . $data_ary['post_id']; - } - } - else if ($mode != 'post' && $post_mode != 'edit_first_post' && $post_mode != 'edit_topic') - { - $params .= '&t=' . $data_ary['topic_id']; - } - - $url = (!$params) ? "{$phpbb_root_path}viewforum.$phpEx" : "{$phpbb_root_path}viewtopic.$phpEx"; - $url = append_sid($url, 'f=' . $data_ary['forum_id'] . $params) . $add_anchor; - - $poll = $poll_ary; - $data = $data_ary; - /** - * This event is used for performing actions directly after a post or topic - * has been submitted. When a new topic is posted, the topic ID is - * available in the $data array. - * - * The only action that can be done by altering data made available to this - * event is to modify the return URL ($url). - * - * @event core.submit_post_end - * @var string mode Variable containing posting mode value - * @var string subject Variable containing post subject value - * @var string username Variable containing post author name - * @var int topic_type Variable containing topic type value - * @var array poll Array with the poll data for the post - * @var array data Array with the data for the post - * @var int post_visibility Variable containing up to date post visibility - * @var bool update_message Flag indicating if the post will be updated - * @var bool update_search_index Flag indicating if the search index will be updated - * @var string url The "Return to topic" URL - * - * @since 3.1.0-a3 - * @changed 3.1.0-RC3 Added vars mode, subject, username, topic_type, - * poll, update_message, update_search_index - */ - $vars = array( - 'mode', - 'subject', - 'username', - 'topic_type', - 'poll', - 'data', - 'post_visibility', - 'update_message', - 'update_search_index', - 'url', - ); - extract($phpbb_dispatcher->trigger_event('core.submit_post_end', compact($vars))); - $data_ary = $data; - $poll_ary = $poll; - unset($data); - unset($poll); - - return $url; -} - -/** -* Handle topic bumping -* @param int $forum_id The ID of the forum the topic is being bumped belongs to -* @param int $topic_id The ID of the topic is being bumping -* @param array $post_data Passes some topic parameters: -* - 'topic_title' -* - 'topic_last_post_id' -* - 'topic_last_poster_id' -* - 'topic_last_post_subject' -* - 'topic_last_poster_name' -* - 'topic_last_poster_colour' -* @param int $bump_time The time at which topic was bumped, usually it is a current time as obtained via time(). -* @return string An URL to the bumped topic, example: ./viewtopic.php?forum_id=1&topic_id=2&p=3#p3 -*/ -function phpbb_bump_topic($forum_id, $topic_id, $post_data, $bump_time = false) -{ - global $config, $db, $user, $phpEx, $phpbb_root_path, $phpbb_log; - - if ($bump_time === false) - { - $bump_time = time(); - } - - // Begin bumping - $db->sql_transaction('begin'); - - // Update the topic's last post post_time - $sql = 'UPDATE ' . POSTS_TABLE . " - SET post_time = $bump_time - WHERE post_id = {$post_data['topic_last_post_id']} - AND topic_id = $topic_id"; - $db->sql_query($sql); - - // Sync the topic's last post time, the rest of the topic's last post data isn't changed - $sql = 'UPDATE ' . TOPICS_TABLE . " - SET topic_last_post_time = $bump_time, - topic_bumped = 1, - topic_bumper = " . $user->data['user_id'] . " - WHERE topic_id = $topic_id"; - $db->sql_query($sql); - - // Update the forum's last post info - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET forum_last_post_id = " . $post_data['topic_last_post_id'] . ", - forum_last_poster_id = " . $post_data['topic_last_poster_id'] . ", - forum_last_post_subject = '" . $db->sql_escape($post_data['topic_last_post_subject']) . "', - forum_last_post_time = $bump_time, - forum_last_poster_name = '" . $db->sql_escape($post_data['topic_last_poster_name']) . "', - forum_last_poster_colour = '" . $db->sql_escape($post_data['topic_last_poster_colour']) . "' - WHERE forum_id = $forum_id"; - $db->sql_query($sql); - - // Update bumper's time of the last posting to prevent flood - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_lastpost_time = $bump_time - WHERE user_id = " . $user->data['user_id']; - $db->sql_query($sql); - - $db->sql_transaction('commit'); - - // Mark this topic as posted to - markread('post', $forum_id, $topic_id, $bump_time); - - // Mark this topic as read - markread('topic', $forum_id, $topic_id, $bump_time); - - // Update forum tracking info - if ($config['load_db_lastread'] && $user->data['is_registered']) - { - $sql = 'SELECT mark_time - FROM ' . FORUMS_TRACK_TABLE . ' - WHERE user_id = ' . $user->data['user_id'] . ' - AND forum_id = ' . $forum_id; - $result = $db->sql_query($sql); - $f_mark_time = (int) $db->sql_fetchfield('mark_time'); - $db->sql_freeresult($result); - } - else if ($config['load_anon_lastread'] || $user->data['is_registered']) - { - $f_mark_time = false; - } - - if (($config['load_db_lastread'] && $user->data['is_registered']) || $config['load_anon_lastread'] || $user->data['is_registered']) - { - // Update forum info - $sql = 'SELECT forum_last_post_time - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . $forum_id; - $result = $db->sql_query($sql); - $forum_last_post_time = (int) $db->sql_fetchfield('forum_last_post_time'); - $db->sql_freeresult($result); - - update_forum_tracking_info($forum_id, $forum_last_post_time, $f_mark_time, false); - } - - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_BUMP_TOPIC', false, array( - 'forum_id' => $forum_id, - 'topic_id' => $topic_id, - $post_data['topic_title'] - )); - - $url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&p={$post_data['topic_last_post_id']}") . "#p{$post_data['topic_last_post_id']}"; - - return $url; -} - -/** -* Show upload popup (progress bar) -*/ -function phpbb_upload_popup($forum_style = 0) -{ - global $template, $user; - - ($forum_style) ? $user->setup('posting', $forum_style) : $user->setup('posting'); - - page_header($user->lang['PROGRESS_BAR']); - - $template->set_filenames(array( - 'popup' => 'posting_progress_bar.html') - ); - - $template->assign_vars(array( - 'PROGRESS_BAR' => $user->img('upload_bar', $user->lang['UPLOAD_IN_PROGRESS'])) - ); - - $template->display('popup'); - - garbage_collection(); - exit_handler(); -} - -/** -* Do the various checks required for removing posts as well as removing it -* -* @param int $forum_id The id of the forum -* @param int $topic_id The id of the topic -* @param int $post_id The id of the post -* @param array $post_data Array with the post data -* @param bool $is_soft The flag indicating whether it is the soft delete mode -* @param string $delete_reason Description for the post deletion reason -* -* @return null -*/ -function phpbb_handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_soft = false, $delete_reason = '') -{ - global $user, $auth, $config, $request; - global $phpbb_root_path, $phpEx, $phpbb_log, $phpbb_dispatcher; - - $force_delete_allowed = $force_softdelete_allowed = false; - $perm_check = ($is_soft) ? 'softdelete' : 'delete'; - - /** - * This event allows to modify the conditions for the post deletion - * - * @event core.handle_post_delete_conditions - * @var int forum_id The id of the forum - * @var int topic_id The id of the topic - * @var int post_id The id of the post - * @var array post_data Array with the post data - * @var bool is_soft The flag indicating whether it is the soft delete mode - * @var string delete_reason Description for the post deletion reason - * @var bool force_delete_allowed Allow the user to delete the post (all permissions and conditions are ignored) - * @var bool force_softdelete_allowed Allow the user to softdelete the post (all permissions and conditions are ignored) - * @var string perm_check The deletion mode softdelete|delete - * @since 3.1.11-RC1 - */ - $vars = array( - 'forum_id', - 'topic_id', - 'post_id', - 'post_data', - 'is_soft', - 'delete_reason', - 'force_delete_allowed', - 'force_softdelete_allowed', - 'perm_check', - ); - extract($phpbb_dispatcher->trigger_event('core.handle_post_delete_conditions', compact($vars))); - - // If moderator removing post or user itself removing post, present a confirmation screen - if ($force_delete_allowed || ($is_soft && $force_softdelete_allowed) || $auth->acl_get("m_$perm_check", $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get("f_$perm_check", $forum_id) && $post_id == $post_data['topic_last_post_id'] && !$post_data['post_edit_locked'] && ($post_data['post_time'] > time() - ($config['delete_time'] * 60) || !$config['delete_time']))) - { - $s_hidden_fields = array( - 'p' => $post_id, - 'f' => $forum_id, - 'mode' => ($is_soft) ? 'soft_delete' : 'delete', - ); - - if (confirm_box(true)) - { - $data = array( - 'topic_first_post_id' => $post_data['topic_first_post_id'], - 'topic_last_post_id' => $post_data['topic_last_post_id'], - 'topic_posts_approved' => $post_data['topic_posts_approved'], - 'topic_posts_unapproved' => $post_data['topic_posts_unapproved'], - 'topic_posts_softdeleted' => $post_data['topic_posts_softdeleted'], - 'topic_visibility' => $post_data['topic_visibility'], - 'topic_type' => $post_data['topic_type'], - 'post_visibility' => $post_data['post_visibility'], - 'post_reported' => $post_data['post_reported'], - 'post_time' => $post_data['post_time'], - 'poster_id' => $post_data['poster_id'], - 'post_postcount' => $post_data['post_postcount'], - ); - - $next_post_id = delete_post($forum_id, $topic_id, $post_id, $data, $is_soft, $delete_reason); - $post_username = ($post_data['poster_id'] == ANONYMOUS && !empty($post_data['post_username'])) ? $post_data['post_username'] : $post_data['username']; - - if ($next_post_id === false) - { - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, (($is_soft) ? 'LOG_SOFTDELETE_TOPIC' : 'LOG_DELETE_TOPIC'), false, array( - 'forum_id' => $forum_id, - 'topic_id' => $topic_id, - $post_data['topic_title'], - $post_username, - $delete_reason - )); - - $meta_info = append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id"); - $message = $user->lang['POST_DELETED']; - } - else - { - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, (($is_soft) ? 'LOG_SOFTDELETE_POST' : 'LOG_DELETE_POST'), false, array( - 'forum_id' => $forum_id, - 'topic_id' => $topic_id, - 'post_id' => $post_id, - $post_data['post_subject'], - $post_username, - $delete_reason - )); - - $meta_info = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&p=$next_post_id") . "#p$next_post_id"; - $message = $user->lang['POST_DELETED']; - - if (!$request->is_ajax()) - { - $message .= '

' . $user->lang('RETURN_TOPIC', '', ''); - } - } - - meta_refresh(3, $meta_info); - if (!$request->is_ajax()) - { - $message .= '

' . $user->lang('RETURN_FORUM', '', ''); - } - trigger_error($message); - } - else - { - global $template; - - $can_delete = $force_delete_allowed || ($auth->acl_get('m_delete', $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get('f_delete', $forum_id))); - $can_softdelete = $force_softdelete_allowed || ($auth->acl_get('m_softdelete', $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get('f_softdelete', $forum_id))); - - $template->assign_vars(array( - 'S_SOFTDELETED' => $post_data['post_visibility'] == ITEM_DELETED, - 'S_CHECKED_PERMANENT' => $request->is_set_post('delete_permanent') ? ' checked="checked"' : '', - 'S_ALLOWED_DELETE' => $can_delete, - 'S_ALLOWED_SOFTDELETE' => $can_softdelete, - )); - - $l_confirm = 'DELETE_POST'; - if ($post_data['post_visibility'] == ITEM_DELETED) - { - $l_confirm .= '_PERMANENTLY'; - $s_hidden_fields['delete_permanent'] = '1'; - } - else if (!$can_softdelete) - { - $s_hidden_fields['delete_permanent'] = '1'; - } - - confirm_box(false, $l_confirm, build_hidden_fields($s_hidden_fields), 'confirm_delete_body.html'); - } - } - - // If we are here the user is not able to delete - present the correct error message - if ($post_data['poster_id'] != $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) - { - trigger_error('DELETE_OWN_POSTS'); - } - - if ($post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id) && $post_id != $post_data['topic_last_post_id']) - { - trigger_error('CANNOT_DELETE_REPLIED'); - } - - trigger_error('USER_CANNOT_DELETE'); -} diff --git a/install/update/old/includes/functions_privmsgs.php b/install/update/old/includes/functions_privmsgs.php deleted file mode 100644 index 444bf2c..0000000 --- a/install/update/old/includes/functions_privmsgs.php +++ /dev/null @@ -1,2264 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/* - Ability to simply add own rules by doing three things: - 1) Add an appropriate constant - 2) Add a new check array to the global_privmsgs_rules variable and the condition array (if one is required) - 3) Implement the rule logic in the check_rule() function - 4) Add a new language variable to ucp.php - - The user is then able to select the new rule. It will be checked against and handled as specified. - To add new actions (yes, checks can be added here too) to the rule management, the core code has to be modified. -*/ - -define('RULE_IS_LIKE', 1); // Is Like -define('RULE_IS_NOT_LIKE', 2); // Is Not Like -define('RULE_IS', 3); // Is -define('RULE_IS_NOT', 4); // Is Not -define('RULE_BEGINS_WITH', 5); // Begins with -define('RULE_ENDS_WITH', 6); // Ends with -define('RULE_IS_FRIEND', 7); // Is Friend -define('RULE_IS_FOE', 8); // Is Foe -define('RULE_IS_USER', 9); // Is User -define('RULE_IS_GROUP', 10); // Is In Usergroup -define('RULE_ANSWERED', 11); // Answered -define('RULE_FORWARDED', 12); // Forwarded -define('RULE_TO_GROUP', 14); // Usergroup -define('RULE_TO_ME', 15); // Me - -define('ACTION_PLACE_INTO_FOLDER', 1); -define('ACTION_MARK_AS_READ', 2); -define('ACTION_MARK_AS_IMPORTANT', 3); -define('ACTION_DELETE_MESSAGE', 4); - -define('CHECK_SUBJECT', 1); -define('CHECK_SENDER', 2); -define('CHECK_MESSAGE', 3); -define('CHECK_STATUS', 4); -define('CHECK_TO', 5); - -/** -* Global private message rules -* These rules define what to do if a rule is hit -*/ -$global_privmsgs_rules = array( - CHECK_SUBJECT => array( - RULE_IS_LIKE => array('check0' => 'message_subject'), - RULE_IS_NOT_LIKE => array('check0' => 'message_subject'), - RULE_IS => array('check0' => 'message_subject'), - RULE_IS_NOT => array('check0' => 'message_subject'), - RULE_BEGINS_WITH => array('check0' => 'message_subject'), - RULE_ENDS_WITH => array('check0' => 'message_subject'), - ), - - CHECK_SENDER => array( - RULE_IS_LIKE => array('check0' => 'username'), - RULE_IS_NOT_LIKE => array('check0' => 'username'), - RULE_IS => array('check0' => 'username'), - RULE_IS_NOT => array('check0' => 'username'), - RULE_BEGINS_WITH => array('check0' => 'username'), - RULE_ENDS_WITH => array('check0' => 'username'), - RULE_IS_FRIEND => array('check0' => 'friend'), - RULE_IS_FOE => array('check0' => 'foe'), - RULE_IS_USER => array('check0' => 'author_id'), - RULE_IS_GROUP => array('check0' => 'author_in_group'), - ), - - CHECK_MESSAGE => array( - RULE_IS_LIKE => array('check0' => 'message_text'), - RULE_IS_NOT_LIKE => array('check0' => 'message_text'), - RULE_IS => array('check0' => 'message_text'), - RULE_IS_NOT => array('check0' => 'message_text'), - ), - - CHECK_STATUS => array( - RULE_ANSWERED => array('check0' => 'pm_replied'), - RULE_FORWARDED => array('check0' => 'pm_forwarded'), - ), - - CHECK_TO => array( - RULE_TO_GROUP => array('check0' => 'to', 'check1' => 'bcc', 'check2' => 'user_in_group'), - RULE_TO_ME => array('check0' => 'to', 'check1' => 'bcc'), - ) -); - -/** -* This is for defining which condition fields to show for which Rule -*/ -$global_rule_conditions = array( - RULE_IS_LIKE => 'text', - RULE_IS_NOT_LIKE => 'text', - RULE_IS => 'text', - RULE_IS_NOT => 'text', - RULE_BEGINS_WITH => 'text', - RULE_ENDS_WITH => 'text', - RULE_IS_USER => 'user', - RULE_IS_GROUP => 'group' -); - -/** -* Get all folder -*/ -function get_folder($user_id, $folder_id = false) -{ - global $db, $user, $template; - global $phpbb_root_path, $phpEx; - - $folder = array(); - - // Get folder information - $sql = 'SELECT folder_id, COUNT(msg_id) as num_messages, SUM(pm_unread) as num_unread - FROM ' . PRIVMSGS_TO_TABLE . " - WHERE user_id = $user_id - AND folder_id <> " . PRIVMSGS_NO_BOX . ' - GROUP BY folder_id'; - $result = $db->sql_query($sql); - - $num_messages = $num_unread = array(); - while ($row = $db->sql_fetchrow($result)) - { - $num_messages[(int) $row['folder_id']] = $row['num_messages']; - $num_unread[(int) $row['folder_id']] = $row['num_unread']; - } - $db->sql_freeresult($result); - - // Make sure the default boxes are defined - $available_folder = array(PRIVMSGS_INBOX, PRIVMSGS_OUTBOX, PRIVMSGS_SENTBOX); - - foreach ($available_folder as $default_folder) - { - if (!isset($num_messages[$default_folder])) - { - $num_messages[$default_folder] = 0; - } - - if (!isset($num_unread[$default_folder])) - { - $num_unread[$default_folder] = 0; - } - } - - // Adjust unread status for outbox - $num_unread[PRIVMSGS_OUTBOX] = $num_messages[PRIVMSGS_OUTBOX]; - - $folder[PRIVMSGS_INBOX] = array( - 'folder_name' => $user->lang['PM_INBOX'], - 'num_messages' => $num_messages[PRIVMSGS_INBOX], - 'unread_messages' => $num_unread[PRIVMSGS_INBOX] - ); - - // Custom Folder - $sql = 'SELECT folder_id, folder_name, pm_count - FROM ' . PRIVMSGS_FOLDER_TABLE . " - WHERE user_id = $user_id"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $folder[$row['folder_id']] = array( - 'folder_name' => $row['folder_name'], - 'num_messages' => $row['pm_count'], - 'unread_messages' => ((isset($num_unread[$row['folder_id']])) ? $num_unread[$row['folder_id']] : 0) - ); - } - $db->sql_freeresult($result); - - $folder[PRIVMSGS_OUTBOX] = array( - 'folder_name' => $user->lang['PM_OUTBOX'], - 'num_messages' => $num_messages[PRIVMSGS_OUTBOX], - 'unread_messages' => $num_unread[PRIVMSGS_OUTBOX] - ); - - $folder[PRIVMSGS_SENTBOX] = array( - 'folder_name' => $user->lang['PM_SENTBOX'], - 'num_messages' => $num_messages[PRIVMSGS_SENTBOX], - 'unread_messages' => $num_unread[PRIVMSGS_SENTBOX] - ); - - // Define Folder Array for template designers (and for making custom folders usable by the template too) - foreach ($folder as $f_id => $folder_ary) - { - $folder_id_name = ($f_id == PRIVMSGS_INBOX) ? 'inbox' : (($f_id == PRIVMSGS_OUTBOX) ? 'outbox' : 'sentbox'); - - $template->assign_block_vars('folder', array( - 'FOLDER_ID' => $f_id, - 'FOLDER_NAME' => $folder_ary['folder_name'], - 'NUM_MESSAGES' => $folder_ary['num_messages'], - 'UNREAD_MESSAGES' => $folder_ary['unread_messages'], - - 'U_FOLDER' => ($f_id > 0) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&folder=' . $f_id) : append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&folder=' . $folder_id_name), - - 'S_CUR_FOLDER' => ($f_id === $folder_id) ? true : false, - 'S_UNREAD_MESSAGES' => ($folder_ary['unread_messages']) ? true : false, - 'S_CUSTOM_FOLDER' => ($f_id > 0) ? true : false) - ); - } - - if ($folder_id !== false && $folder_id !== PRIVMSGS_HOLD_BOX && !isset($folder[$folder_id])) - { - trigger_error('UNKNOWN_FOLDER'); - } - - return $folder; -} - -/** -* Delete Messages From Sentbox -* we are doing this here because this saves us a bunch of checks and queries -*/ -function clean_sentbox($num_sentbox_messages) -{ - global $db, $user; - - // Check Message Limit - if ($user->data['message_limit'] && $num_sentbox_messages > $user->data['message_limit']) - { - // Delete old messages - $sql = 'SELECT t.msg_id - FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p - WHERE t.msg_id = p.msg_id - AND t.user_id = ' . $user->data['user_id'] . ' - AND t.folder_id = ' . PRIVMSGS_SENTBOX . ' - ORDER BY p.message_time ASC'; - $result = $db->sql_query_limit($sql, ($num_sentbox_messages - $user->data['message_limit'])); - - $delete_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $delete_ids[] = $row['msg_id']; - } - $db->sql_freeresult($result); - delete_pm($user->data['user_id'], $delete_ids, PRIVMSGS_SENTBOX); - } -} - -/** -* Check Rule against Message Information -*/ -function check_rule(&$rules, &$rule_row, &$message_row, $user_id) -{ - if (!isset($rules[$rule_row['rule_check']][$rule_row['rule_connection']])) - { - return false; - } - - $check_ary = $rules[$rule_row['rule_check']][$rule_row['rule_connection']]; - - $result = false; - - $check0 = $message_row[$check_ary['check0']]; - - switch ($rule_row['rule_connection']) - { - case RULE_IS_LIKE: - $result = preg_match("/" . preg_quote($rule_row['rule_string'], '/') . '/i', $check0); - break; - - case RULE_IS_NOT_LIKE: - $result = !preg_match("/" . preg_quote($rule_row['rule_string'], '/') . '/i', $check0); - break; - - case RULE_IS: - $result = ($check0 == $rule_row['rule_string']); - break; - - case RULE_IS_NOT: - $result = ($check0 != $rule_row['rule_string']); - break; - - case RULE_BEGINS_WITH: - $result = preg_match("/^" . preg_quote($rule_row['rule_string'], '/') . '/i', $check0); - break; - - case RULE_ENDS_WITH: - $result = preg_match("/" . preg_quote($rule_row['rule_string'], '/') . '$/i', $check0); - break; - - case RULE_IS_FRIEND: - case RULE_IS_FOE: - case RULE_ANSWERED: - case RULE_FORWARDED: - $result = ($check0 == 1); - break; - - case RULE_IS_USER: - $result = ($check0 == $rule_row['rule_user_id']); - break; - - case RULE_IS_GROUP: - $result = in_array($rule_row['rule_group_id'], $check0); - break; - - case RULE_TO_GROUP: - $result = (in_array('g_' . $message_row[$check_ary['check2']], $check0) || in_array('g_' . $message_row[$check_ary['check2']], $message_row[$check_ary['check1']])); - break; - - case RULE_TO_ME: - $result = (in_array('u_' . $user_id, $check0) || in_array('u_' . $user_id, $message_row[$check_ary['check1']])); - break; - } - - if (!$result) - { - return false; - } - - switch ($rule_row['rule_action']) - { - case ACTION_PLACE_INTO_FOLDER: - return array('action' => $rule_row['rule_action'], 'folder_id' => $rule_row['rule_folder_id']); - break; - - case ACTION_MARK_AS_READ: - case ACTION_MARK_AS_IMPORTANT: - return array('action' => $rule_row['rule_action'], 'pm_unread' => $message_row['pm_unread'], 'pm_marked' => $message_row['pm_marked']); - break; - - case ACTION_DELETE_MESSAGE: - global $db; - - // Check for admins/mods - users are not allowed to remove those messages... - // We do the check here to make sure the data we use is consistent - $sql = 'SELECT user_id, user_type, user_permissions - FROM ' . USERS_TABLE . ' - WHERE user_id = ' . (int) $message_row['author_id']; - $result = $db->sql_query($sql); - $userdata = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $auth2 = new \phpbb\auth\auth(); - $auth2->acl($userdata); - - if (!$auth2->acl_get('a_') && !$auth2->acl_get('m_') && !$auth2->acl_getf_global('m_')) - { - return array('action' => $rule_row['rule_action'], 'pm_unread' => $message_row['pm_unread'], 'pm_marked' => $message_row['pm_marked']); - } - - return false; - break; - - default: - return false; - } - - return false; -} - -/** -* Update user PM count -*/ -function update_pm_counts() -{ - global $user, $db; - - // Update unread count - $sql = 'SELECT COUNT(msg_id) as num_messages - FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE pm_unread = 1 - AND folder_id <> ' . PRIVMSGS_OUTBOX . ' - AND user_id = ' . $user->data['user_id']; - $result = $db->sql_query($sql); - $user->data['user_unread_privmsg'] = (int) $db->sql_fetchfield('num_messages'); - $db->sql_freeresult($result); - - // Update new pm count - $sql = 'SELECT COUNT(msg_id) as num_messages - FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE pm_new = 1 - AND folder_id IN (' . PRIVMSGS_NO_BOX . ', ' . PRIVMSGS_HOLD_BOX . ') - AND user_id = ' . $user->data['user_id']; - $result = $db->sql_query($sql); - $user->data['user_new_privmsg'] = (int) $db->sql_fetchfield('num_messages'); - $db->sql_freeresult($result); - - $db->sql_query('UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', array( - 'user_unread_privmsg' => (int) $user->data['user_unread_privmsg'], - 'user_new_privmsg' => (int) $user->data['user_new_privmsg'], - )) . ' WHERE user_id = ' . $user->data['user_id']); - - // Ok, here we need to repair something, other boxes than privmsgs_no_box and privmsgs_hold_box should not carry the pm_new flag. - if (!$user->data['user_new_privmsg']) - { - $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . ' - SET pm_new = 0 - WHERE pm_new = 1 - AND folder_id NOT IN (' . PRIVMSGS_NO_BOX . ', ' . PRIVMSGS_HOLD_BOX . ') - AND user_id = ' . $user->data['user_id']; - $db->sql_query($sql); - } -} - -/** -* Place new messages into appropriate folder -*/ -function place_pm_into_folder(&$global_privmsgs_rules, $release = false) -{ - global $db, $user, $config; - - if (!$user->data['user_new_privmsg']) - { - return array('not_moved' => 0, 'removed' => 0); - } - - $user_message_rules = (int) $user->data['user_message_rules']; - $user_id = (int) $user->data['user_id']; - - $action_ary = $move_into_folder = array(); - $num_removed = 0; - - // Newly processing on-hold messages - if ($release) - { - $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . ' - SET folder_id = ' . PRIVMSGS_NO_BOX . ' - WHERE folder_id = ' . PRIVMSGS_HOLD_BOX . " - AND user_id = $user_id"; - $db->sql_query($sql); - } - - // Get those messages not yet placed into any box - $retrieve_sql = 'SELECT t.*, p.*, u.username, u.user_id, u.group_id - FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p, ' . USERS_TABLE . " u - WHERE t.user_id = $user_id - AND p.author_id = u.user_id - AND t.folder_id = " . PRIVMSGS_NO_BOX . ' - AND t.msg_id = p.msg_id'; - - // Just place into the appropriate arrays if no rules need to be checked - if (!$user_message_rules) - { - $result = $db->sql_query($retrieve_sql); - - while ($row = $db->sql_fetchrow($result)) - { - $action_ary[$row['msg_id']][] = array('action' => false); - } - $db->sql_freeresult($result); - } - else - { - $user_rules = $zebra = $check_rows = array(); - $user_ids = $memberships = array(); - - // First of all, grab all rules and retrieve friends/foes - $sql = 'SELECT * - FROM ' . PRIVMSGS_RULES_TABLE . " - WHERE user_id = $user_id"; - $result = $db->sql_query($sql); - $user_rules = $db->sql_fetchrowset($result); - $db->sql_freeresult($result); - - if (count($user_rules)) - { - $sql = 'SELECT zebra_id, friend, foe - FROM ' . ZEBRA_TABLE . " - WHERE user_id = $user_id"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $zebra[$row['zebra_id']] = $row; - } - $db->sql_freeresult($result); - } - - // Now build a bare-bone check_row array - $result = $db->sql_query($retrieve_sql); - - while ($row = $db->sql_fetchrow($result)) - { - $check_rows[] = array_merge($row, array( - 'to' => explode(':', $row['to_address']), - 'bcc' => explode(':', $row['bcc_address']), - 'friend' => (isset($zebra[$row['author_id']])) ? $zebra[$row['author_id']]['friend'] : 0, - 'foe' => (isset($zebra[$row['author_id']])) ? $zebra[$row['author_id']]['foe'] : 0, - 'user_in_group' => array($user->data['group_id']), - 'author_in_group' => array()) - ); - - $user_ids[] = $row['user_id']; - } - $db->sql_freeresult($result); - - // Retrieve user memberships - if (count($user_ids)) - { - $sql = 'SELECT * - FROM ' . USER_GROUP_TABLE . ' - WHERE ' . $db->sql_in_set('user_id', $user_ids) . ' - AND user_pending = 0'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $memberships[$row['user_id']][] = $row['group_id']; - } - $db->sql_freeresult($result); - } - - // Now place into the appropriate folder - foreach ($check_rows as $row) - { - // Add membership if set - if (isset($memberships[$row['author_id']])) - { - $row['author_in_group'] = $memberships[$row['user_id']]; - } - - // Check Rule - this should be very quick since we have all information we need - $is_match = false; - foreach ($user_rules as $rule_row) - { - if (($action = check_rule($global_privmsgs_rules, $rule_row, $row, $user_id)) !== false) - { - $is_match = true; - $action_ary[$row['msg_id']][] = $action; - } - } - - if (!$is_match) - { - $action_ary[$row['msg_id']][] = array('action' => false); - } - } - - unset($user_rules, $zebra, $check_rows, $user_ids, $memberships); - } - - // We place actions into arrays, to save queries. - $unread_ids = $delete_ids = $important_ids = array(); - - foreach ($action_ary as $msg_id => $msg_ary) - { - // It is allowed to execute actions more than once, except placing messages into folder - $folder_action = $message_removed = false; - - foreach ($msg_ary as $pos => $rule_ary) - { - if ($folder_action && $rule_ary['action'] == ACTION_PLACE_INTO_FOLDER) - { - continue; - } - - switch ($rule_ary['action']) - { - case ACTION_PLACE_INTO_FOLDER: - // Folder actions have precedence, so we will remove any other ones - $folder_action = true; - $move_into_folder[(int) $rule_ary['folder_id']][] = $msg_id; - break; - - case ACTION_MARK_AS_READ: - if ($rule_ary['pm_unread']) - { - $unread_ids[] = $msg_id; - } - break; - - case ACTION_DELETE_MESSAGE: - $delete_ids[] = $msg_id; - $message_removed = true; - break; - - case ACTION_MARK_AS_IMPORTANT: - if (!$rule_ary['pm_marked']) - { - $important_ids[] = $msg_id; - } - break; - } - } - - // We place this here because it could happen that the messages are doubled if a rule marks a message and then moves it into a specific - // folder. Here we simply move the message into the INBOX if it gets not removed and also not put into a custom folder. - if (!$folder_action && !$message_removed) - { - $move_into_folder[PRIVMSGS_INBOX][] = $msg_id; - } - } - - // Do not change the order of processing - // The number of queries needed to be executed here highly depends on the defined rules and are - // only gone through if new messages arrive. - - // Delete messages - if (count($delete_ids)) - { - $num_removed += count($delete_ids); - delete_pm($user_id, $delete_ids, PRIVMSGS_NO_BOX); - } - - // Set messages to Unread - if (count($unread_ids)) - { - $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . ' - SET pm_unread = 0 - WHERE ' . $db->sql_in_set('msg_id', $unread_ids) . " - AND user_id = $user_id - AND folder_id = " . PRIVMSGS_NO_BOX; - $db->sql_query($sql); - } - - // mark messages as important - if (count($important_ids)) - { - $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . ' - SET pm_marked = 1 - pm_marked - WHERE folder_id = ' . PRIVMSGS_NO_BOX . " - AND user_id = $user_id - AND " . $db->sql_in_set('msg_id', $important_ids); - $db->sql_query($sql); - } - - // Move into folder - $folder = array(); - - if (count($move_into_folder)) - { - // Determine Full Folder Action - we need the move to folder id later eventually - $full_folder_action = ($user->data['user_full_folder'] == FULL_FOLDER_NONE) ? ($config['full_folder_action'] - (FULL_FOLDER_NONE*(-1))) : $user->data['user_full_folder']; - - $sql_folder = array_keys($move_into_folder); - if ($full_folder_action >= 0) - { - $sql_folder[] = $full_folder_action; - } - - $sql = 'SELECT folder_id, pm_count - FROM ' . PRIVMSGS_FOLDER_TABLE . ' - WHERE ' . $db->sql_in_set('folder_id', $sql_folder) . " - AND user_id = $user_id"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $folder[(int) $row['folder_id']] = (int) $row['pm_count']; - } - $db->sql_freeresult($result); - - unset($sql_folder); - - if (isset($move_into_folder[PRIVMSGS_INBOX])) - { - $sql = 'SELECT COUNT(msg_id) as num_messages - FROM ' . PRIVMSGS_TO_TABLE . " - WHERE user_id = $user_id - AND folder_id = " . PRIVMSGS_INBOX; - $result = $db->sql_query($sql); - $folder[PRIVMSGS_INBOX] = (int) $db->sql_fetchfield('num_messages'); - $db->sql_freeresult($result); - } - } - - // Here we have ideally only one folder to move into - foreach ($move_into_folder as $folder_id => $msg_ary) - { - $dest_folder = $folder_id; - $full_folder_action = FULL_FOLDER_NONE; - - // Check Message Limit - we calculate with the complete array, most of the time it is one message - // But we are making sure that the other way around works too (more messages in queue than allowed to be stored) - if ($user->data['message_limit'] && $folder[$folder_id] && ($folder[$folder_id] + count($msg_ary)) > $user->data['message_limit']) - { - $full_folder_action = ($user->data['user_full_folder'] == FULL_FOLDER_NONE) ? ($config['full_folder_action'] - (FULL_FOLDER_NONE*(-1))) : $user->data['user_full_folder']; - - // If destination folder itself is full... - if ($full_folder_action >= 0 && ($folder[$full_folder_action] + count($msg_ary)) > $user->data['message_limit']) - { - $full_folder_action = $config['full_folder_action'] - (FULL_FOLDER_NONE*(-1)); - } - - // If Full Folder Action is to move to another folder, we simply adjust the destination folder - if ($full_folder_action >= 0) - { - $dest_folder = $full_folder_action; - } - else if ($full_folder_action == FULL_FOLDER_DELETE) - { - // Delete some messages. NOTE: Ordered by msg_id here instead of message_time! - $sql = 'SELECT msg_id - FROM ' . PRIVMSGS_TO_TABLE . " - WHERE user_id = $user_id - AND folder_id = $dest_folder - ORDER BY msg_id ASC"; - $result = $db->sql_query_limit($sql, (($folder[$dest_folder] + count($msg_ary)) - $user->data['message_limit'])); - - $delete_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $delete_ids[] = $row['msg_id']; - } - $db->sql_freeresult($result); - - $num_removed += count($delete_ids); - delete_pm($user_id, $delete_ids, $dest_folder); - } - } - - // - if ($full_folder_action == FULL_FOLDER_HOLD) - { - $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . ' - SET folder_id = ' . PRIVMSGS_HOLD_BOX . ' - WHERE folder_id = ' . PRIVMSGS_NO_BOX . " - AND user_id = $user_id - AND " . $db->sql_in_set('msg_id', $msg_ary); - $db->sql_query($sql); - } - else - { - $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . " - SET folder_id = $dest_folder, pm_new = 0 - WHERE folder_id = " . PRIVMSGS_NO_BOX . " - AND user_id = $user_id - AND pm_new = 1 - AND " . $db->sql_in_set('msg_id', $msg_ary); - $db->sql_query($sql); - - if ($dest_folder != PRIVMSGS_INBOX) - { - $sql = 'UPDATE ' . PRIVMSGS_FOLDER_TABLE . ' - SET pm_count = pm_count + ' . (int) $db->sql_affectedrows() . " - WHERE folder_id = $dest_folder - AND user_id = $user_id"; - $db->sql_query($sql); - } - } - } - - if (count($action_ary)) - { - // Move from OUTBOX to SENTBOX - // We are not checking any full folder status here... SENTBOX is a special treatment (old messages get deleted) - $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . ' - SET folder_id = ' . PRIVMSGS_SENTBOX . ' - WHERE folder_id = ' . PRIVMSGS_OUTBOX . ' - AND ' . $db->sql_in_set('msg_id', array_keys($action_ary)); - $db->sql_query($sql); - } - - // Update new/unread count - update_pm_counts(); - - // Now check how many messages got not moved... - $sql = 'SELECT COUNT(msg_id) as num_messages - FROM ' . PRIVMSGS_TO_TABLE . " - WHERE user_id = $user_id - AND folder_id = " . PRIVMSGS_HOLD_BOX; - $result = $db->sql_query($sql); - $num_not_moved = (int) $db->sql_fetchfield('num_messages'); - $db->sql_freeresult($result); - - return array('not_moved' => $num_not_moved, 'removed' => $num_removed); -} - -/** -* Move PM from one to another folder -*/ -function move_pm($user_id, $message_limit, $move_msg_ids, $dest_folder, $cur_folder_id) -{ - global $db, $user; - global $phpbb_root_path, $phpEx; - - $num_moved = 0; - - if (!is_array($move_msg_ids)) - { - $move_msg_ids = array($move_msg_ids); - } - - if (count($move_msg_ids) && !in_array($dest_folder, array(PRIVMSGS_NO_BOX, PRIVMSGS_OUTBOX, PRIVMSGS_SENTBOX)) && - !in_array($cur_folder_id, array(PRIVMSGS_NO_BOX, PRIVMSGS_OUTBOX)) && $cur_folder_id != $dest_folder) - { - // We have to check the destination folder ;) - if ($dest_folder != PRIVMSGS_INBOX) - { - $sql = 'SELECT folder_id, folder_name, pm_count - FROM ' . PRIVMSGS_FOLDER_TABLE . " - WHERE folder_id = $dest_folder - AND user_id = $user_id"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - send_status_line(403, 'Forbidden'); - trigger_error('NOT_AUTHORISED'); - } - - if ($message_limit && $row['pm_count'] + count($move_msg_ids) > $message_limit) - { - $message = sprintf($user->lang['NOT_ENOUGH_SPACE_FOLDER'], $row['folder_name']) . '

'; - $message .= sprintf($user->lang['CLICK_RETURN_FOLDER'], '', '', $row['folder_name']); - trigger_error($message); - } - } - else - { - $sql = 'SELECT COUNT(msg_id) as num_messages - FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE folder_id = ' . PRIVMSGS_INBOX . " - AND user_id = $user_id"; - $result = $db->sql_query($sql); - $num_messages = (int) $db->sql_fetchfield('num_messages'); - $db->sql_freeresult($result); - - if ($message_limit && $num_messages + count($move_msg_ids) > $message_limit) - { - $message = sprintf($user->lang['NOT_ENOUGH_SPACE_FOLDER'], $user->lang['PM_INBOX']) . '

'; - $message .= sprintf($user->lang['CLICK_RETURN_FOLDER'], '', '', $user->lang['PM_INBOX']); - trigger_error($message); - } - } - - $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . " - SET folder_id = $dest_folder - WHERE folder_id = $cur_folder_id - AND user_id = $user_id - AND " . $db->sql_in_set('msg_id', $move_msg_ids); - $db->sql_query($sql); - $num_moved = $db->sql_affectedrows(); - - // Update pm counts - if ($num_moved) - { - if (!in_array($cur_folder_id, array(PRIVMSGS_INBOX, PRIVMSGS_OUTBOX, PRIVMSGS_SENTBOX))) - { - $sql = 'UPDATE ' . PRIVMSGS_FOLDER_TABLE . " - SET pm_count = pm_count - $num_moved - WHERE folder_id = $cur_folder_id - AND user_id = $user_id"; - $db->sql_query($sql); - } - - if ($dest_folder != PRIVMSGS_INBOX) - { - $sql = 'UPDATE ' . PRIVMSGS_FOLDER_TABLE . " - SET pm_count = pm_count + $num_moved - WHERE folder_id = $dest_folder - AND user_id = $user_id"; - $db->sql_query($sql); - } - } - } - else if (in_array($cur_folder_id, array(PRIVMSGS_NO_BOX, PRIVMSGS_OUTBOX))) - { - trigger_error('CANNOT_MOVE_SPECIAL'); - } - - return $num_moved; -} - -/** -* Update unread message status -*/ -function update_unread_status($unread, $msg_id, $user_id, $folder_id) -{ - if (!$unread) - { - return; - } - - global $db, $user, $phpbb_container; - - /* @var $phpbb_notifications \phpbb\notification\manager */ - $phpbb_notifications = $phpbb_container->get('notification_manager'); - - $phpbb_notifications->mark_notifications('notification.type.pm', $msg_id, $user_id); - - $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . " - SET pm_unread = 0 - WHERE msg_id = $msg_id - AND user_id = $user_id - AND folder_id = $folder_id - AND pm_unread = 1"; - $db->sql_query($sql); - - // If the message is already marked as read, we just skip the rest to avoid negative PM count - if (!$db->sql_affectedrows()) - { - return; - } - - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_unread_privmsg = user_unread_privmsg - 1 - WHERE user_id = $user_id"; - $db->sql_query($sql); - - if ($user->data['user_id'] == $user_id) - { - $user->data['user_unread_privmsg']--; - - // Try to cope with previous wrong conversions... - if ($user->data['user_unread_privmsg'] < 0) - { - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_unread_privmsg = 0 - WHERE user_id = $user_id"; - $db->sql_query($sql); - - $user->data['user_unread_privmsg'] = 0; - } - } -} - -function mark_folder_read($user_id, $folder_id) -{ - global $db; - - $sql = 'SELECT msg_id - FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE folder_id = ' . ((int) $folder_id) . ' - AND user_id = ' . ((int) $user_id) . ' - AND pm_unread = 1'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - update_unread_status(true, $row['msg_id'], $user_id, $folder_id); - } - $db->sql_freeresult($result); -} - -/** -* Handle all actions possible with marked messages -*/ -function handle_mark_actions($user_id, $mark_action) -{ - global $db, $user, $phpbb_root_path, $phpEx, $request; - - $msg_ids = $request->variable('marked_msg_id', array(0)); - $cur_folder_id = $request->variable('cur_folder_id', PRIVMSGS_NO_BOX); - - if (!count($msg_ids)) - { - return false; - } - - switch ($mark_action) - { - case 'mark_important': - - $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . " - SET pm_marked = 1 - pm_marked - WHERE folder_id = $cur_folder_id - AND user_id = $user_id - AND " . $db->sql_in_set('msg_id', $msg_ids); - $db->sql_query($sql); - - break; - - case 'delete_marked': - - global $auth; - - if (!$auth->acl_get('u_pm_delete')) - { - send_status_line(403, 'Forbidden'); - trigger_error('NO_AUTH_DELETE_MESSAGE'); - } - - if (confirm_box(true)) - { - delete_pm($user_id, $msg_ids, $cur_folder_id); - - $success_msg = (count($msg_ids) == 1) ? 'MESSAGE_DELETED' : 'MESSAGES_DELETED'; - $redirect = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&folder=' . $cur_folder_id); - - meta_refresh(3, $redirect); - trigger_error($user->lang[$success_msg] . '

' . sprintf($user->lang['RETURN_FOLDER'], '', '')); - } - else - { - $s_hidden_fields = array( - 'cur_folder_id' => $cur_folder_id, - 'mark_option' => 'delete_marked', - 'submit_mark' => true, - 'marked_msg_id' => $msg_ids - ); - - confirm_box(false, 'DELETE_MARKED_PM', build_hidden_fields($s_hidden_fields)); - } - - break; - - default: - return false; - } - - return true; -} - -/** -* Delete PM(s) -*/ -function delete_pm($user_id, $msg_ids, $folder_id) -{ - global $db, $user, $phpbb_container, $phpbb_dispatcher; - - $user_id = (int) $user_id; - $folder_id = (int) $folder_id; - - if (!$user_id) - { - return false; - } - - if (!is_array($msg_ids)) - { - if (!$msg_ids) - { - return false; - } - $msg_ids = array($msg_ids); - } - - if (!count($msg_ids)) - { - return false; - } - - /** - * Get all info for PM(s) before they are deleted - * - * @event core.delete_pm_before - * @var int user_id ID of the user requested the message delete - * @var array msg_ids array of all messages to be deleted - * @var int folder_id ID of the user folder where the messages are stored - * @since 3.1.0-b5 - */ - $vars = array('user_id', 'msg_ids', 'folder_id'); - extract($phpbb_dispatcher->trigger_event('core.delete_pm_before', compact($vars))); - - // Get PM Information for later deleting - $sql = 'SELECT msg_id, pm_unread, pm_new - FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE ' . $db->sql_in_set('msg_id', array_map('intval', $msg_ids)) . " - AND folder_id = $folder_id - AND user_id = $user_id"; - $result = $db->sql_query($sql); - - $delete_rows = array(); - $num_unread = $num_new = $num_deleted = 0; - while ($row = $db->sql_fetchrow($result)) - { - $num_unread += (int) $row['pm_unread']; - $num_new += (int) $row['pm_new']; - - $delete_rows[$row['msg_id']] = 1; - } - $db->sql_freeresult($result); - unset($msg_ids); - - if (!count($delete_rows)) - { - return false; - } - - $db->sql_transaction('begin'); - - // if no one has read the message yet (meaning it is in users outbox) - // then mark the message as deleted... - if ($folder_id == PRIVMSGS_OUTBOX) - { - // Remove PM from Outbox - $sql = 'DELETE FROM ' . PRIVMSGS_TO_TABLE . " - WHERE user_id = $user_id AND folder_id = " . PRIVMSGS_OUTBOX . ' - AND ' . $db->sql_in_set('msg_id', array_keys($delete_rows)); - $db->sql_query($sql); - - // Update PM Information for safety - $sql = 'UPDATE ' . PRIVMSGS_TABLE . " SET message_text = '' - WHERE " . $db->sql_in_set('msg_id', array_keys($delete_rows)); - $db->sql_query($sql); - - // Set delete flag for those intended to receive the PM - // We do not remove the message actually, to retain some basic information (sent time for example) - $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . ' - SET pm_deleted = 1 - WHERE ' . $db->sql_in_set('msg_id', array_keys($delete_rows)); - $db->sql_query($sql); - - $num_deleted = $db->sql_affectedrows(); - } - else - { - // Delete private message data - $sql = 'DELETE FROM ' . PRIVMSGS_TO_TABLE . " - WHERE user_id = $user_id - AND folder_id = $folder_id - AND " . $db->sql_in_set('msg_id', array_keys($delete_rows)); - $db->sql_query($sql); - $num_deleted = $db->sql_affectedrows(); - } - - // if folder id is user defined folder then decrease pm_count - if (!in_array($folder_id, array(PRIVMSGS_INBOX, PRIVMSGS_OUTBOX, PRIVMSGS_SENTBOX, PRIVMSGS_NO_BOX))) - { - $sql = 'UPDATE ' . PRIVMSGS_FOLDER_TABLE . " - SET pm_count = pm_count - $num_deleted - WHERE folder_id = $folder_id"; - $db->sql_query($sql); - } - - // Update unread and new status field - if ($num_unread || $num_new) - { - $set_sql = ($num_unread) ? 'user_unread_privmsg = user_unread_privmsg - ' . $num_unread : ''; - - if ($num_new) - { - $set_sql .= ($set_sql != '') ? ', ' : ''; - $set_sql .= 'user_new_privmsg = user_new_privmsg - ' . $num_new; - } - - $db->sql_query('UPDATE ' . USERS_TABLE . " SET $set_sql WHERE user_id = $user_id"); - - $user->data['user_new_privmsg'] -= $num_new; - $user->data['user_unread_privmsg'] -= $num_unread; - } - - /* @var $phpbb_notifications \phpbb\notification\manager */ - $phpbb_notifications = $phpbb_container->get('notification_manager'); - - $phpbb_notifications->delete_notifications('notification.type.pm', array_keys($delete_rows)); - - // Now we have to check which messages we can delete completely - $sql = 'SELECT msg_id - FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE ' . $db->sql_in_set('msg_id', array_keys($delete_rows)); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - unset($delete_rows[$row['msg_id']]); - } - $db->sql_freeresult($result); - - $delete_ids = array_keys($delete_rows); - - if (count($delete_ids)) - { - // Check if there are any attachments we need to remove - /** @var \phpbb\attachment\manager $attachment_manager */ - $attachment_manager = $phpbb_container->get('attachment.manager'); - $attachment_manager->delete('message', $delete_ids, false); - unset($attachment_manager); - - $sql = 'DELETE FROM ' . PRIVMSGS_TABLE . ' - WHERE ' . $db->sql_in_set('msg_id', $delete_ids); - $db->sql_query($sql); - } - - $db->sql_transaction('commit'); - - return true; -} - -/** -* Delete all PM(s) for a given user and delete the ones without references -* -* @param int $user_id ID of the user whose private messages we want to delete -* -* @return boolean False if there were no pms found, true otherwise. -*/ -function phpbb_delete_user_pms($user_id) -{ - $user_id = (int) $user_id; - - if (!$user_id) - { - return false; - } - - return phpbb_delete_users_pms(array($user_id)); -} - -/** -* Delete all PM(s) for given users and delete the ones without references -* -* @param array $user_ids IDs of the users whose private messages we want to delete -* -* @return boolean False if there were no pms found, true otherwise. -*/ -function phpbb_delete_users_pms($user_ids) -{ - global $db, $phpbb_container; - - $user_id_sql = $db->sql_in_set('user_id', $user_ids); - $author_id_sql = $db->sql_in_set('author_id', $user_ids); - - // Get PM Information for later deleting - // The two queries where split, so we can use our indexes - $undelivered_msg = $delete_ids = array(); - - // Part 1: get PMs the user received - $sql = 'SELECT msg_id - FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE ' . $user_id_sql; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $msg_id = (int) $row['msg_id']; - $delete_ids[$msg_id] = $msg_id; - } - $db->sql_freeresult($result); - - // Part 2: get PMs the users sent, but are yet to be received. - // We cannot simply delete them. First we have to check - // whether another user already received and read the message. - $sql = 'SELECT msg_id - FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE ' . $author_id_sql . ' - AND folder_id = ' . PRIVMSGS_NO_BOX; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $msg_id = (int) $row['msg_id']; - $undelivered_msg[$msg_id] = $msg_id; - } - $db->sql_freeresult($result); - - if (empty($delete_ids) && empty($undelivered_msg)) - { - return false; - } - - $db->sql_transaction('begin'); - - /* @var $phpbb_notifications \phpbb\notification\manager */ - $phpbb_notifications = $phpbb_container->get('notification_manager'); - - if (!empty($undelivered_msg)) - { - // A pm is delivered, if for any recipient the message was moved - // from their NO_BOX to another folder. We do not delete such - // messages, but only delete them for users, who have not yet - // received them. - $sql = 'SELECT msg_id - FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE ' . $author_id_sql . ' - AND folder_id <> ' . PRIVMSGS_NO_BOX . ' - AND folder_id <> ' . PRIVMSGS_OUTBOX . ' - AND folder_id <> ' . PRIVMSGS_SENTBOX; - $result = $db->sql_query($sql); - - $delivered_msg = array(); - while ($row = $db->sql_fetchrow($result)) - { - $msg_id = (int) $row['msg_id']; - $delivered_msg[$msg_id] = $msg_id; - unset($undelivered_msg[$msg_id]); - } - $db->sql_freeresult($result); - - $undelivered_user = array(); - - // Count the messages we delete, so we can correct the user pm data - $sql = 'SELECT user_id, COUNT(msg_id) as num_undelivered_privmsgs - FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE ' . $author_id_sql . ' - AND folder_id = ' . PRIVMSGS_NO_BOX . ' - AND ' . $db->sql_in_set('msg_id', array_merge($undelivered_msg, $delivered_msg)) . ' - GROUP BY user_id'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $num_pms = (int) $row['num_undelivered_privmsgs']; - $undelivered_user[$num_pms][] = (int) $row['user_id']; - - if (count($undelivered_user[$num_pms]) > 50) - { - // If there are too many users affected the query might get - // too long, so we update the value for the first bunch here. - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_new_privmsg = user_new_privmsg - ' . $num_pms . ', - user_unread_privmsg = user_unread_privmsg - ' . $num_pms . ' - WHERE ' . $db->sql_in_set('user_id', $undelivered_user[$num_pms]); - $db->sql_query($sql); - unset($undelivered_user[$num_pms]); - } - } - $db->sql_freeresult($result); - - foreach ($undelivered_user as $num_pms => $undelivered_user_set) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_new_privmsg = user_new_privmsg - ' . $num_pms . ', - user_unread_privmsg = user_unread_privmsg - ' . $num_pms . ' - WHERE ' . $db->sql_in_set('user_id', $undelivered_user_set); - $db->sql_query($sql); - } - - if (!empty($delivered_msg)) - { - $sql = 'DELETE FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE folder_id = ' . PRIVMSGS_NO_BOX . ' - AND ' . $db->sql_in_set('msg_id', $delivered_msg); - $db->sql_query($sql); - - $phpbb_notifications->delete_notifications('notification.type.pm', $delivered_msg); - } - - if (!empty($undelivered_msg)) - { - $sql = 'DELETE FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE ' . $db->sql_in_set('msg_id', $undelivered_msg); - $db->sql_query($sql); - - $sql = 'DELETE FROM ' . PRIVMSGS_TABLE . ' - WHERE ' . $db->sql_in_set('msg_id', $undelivered_msg); - $db->sql_query($sql); - - $phpbb_notifications->delete_notifications('notification.type.pm', $undelivered_msg); - } - } - - // Reset the user's pm count to 0 - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_new_privmsg = 0, - user_unread_privmsg = 0 - WHERE ' . $user_id_sql; - $db->sql_query($sql); - - // Delete private message data of the user - $sql = 'DELETE FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE ' . $user_id_sql; - $db->sql_query($sql); - - if (!empty($delete_ids)) - { - // Now we have to check which messages we can delete completely - $sql = 'SELECT msg_id - FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE ' . $db->sql_in_set('msg_id', $delete_ids); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - unset($delete_ids[$row['msg_id']]); - } - $db->sql_freeresult($result); - - if (!empty($delete_ids)) - { - // Check if there are any attachments we need to remove - /** @var \phpbb\attachment\manager $attachment_manager */ - $attachment_manager = $phpbb_container->get('attachment.manager'); - $attachment_manager->delete('message', $delete_ids, false); - unset($attachment_manager); - - $sql = 'DELETE FROM ' . PRIVMSGS_TABLE . ' - WHERE ' . $db->sql_in_set('msg_id', $delete_ids); - $db->sql_query($sql); - - $phpbb_notifications->delete_notifications('notification.type.pm', $delete_ids); - } - } - - // Set the remaining author id to anonymous - // This way users are still able to read messages from users being removed - $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . ' - SET author_id = ' . ANONYMOUS . ' - WHERE ' . $author_id_sql; - $db->sql_query($sql); - - $sql = 'UPDATE ' . PRIVMSGS_TABLE . ' - SET author_id = ' . ANONYMOUS . ' - WHERE ' . $author_id_sql; - $db->sql_query($sql); - - $db->sql_transaction('commit'); - - return true; -} - -/** -* Rebuild message header -*/ -function rebuild_header($check_ary) -{ - $address = array(); - - foreach ($check_ary as $check_type => $address_field) - { - // Split Addresses into users and groups - preg_match_all('/:?(u|g)_([0-9]+):?/', $address_field, $match); - - $u = $g = array(); - foreach ($match[1] as $id => $type) - { - ${$type}[] = (int) $match[2][$id]; - } - - $_types = array('u', 'g'); - foreach ($_types as $type) - { - if (count(${$type})) - { - foreach (${$type} as $id) - { - $address[$type][$id] = $check_type; - } - } - } - } - - return $address; -} - -/** -* Print out/assign recipient information -*/ -function write_pm_addresses($check_ary, $author_id, $plaintext = false) -{ - global $db, $user, $template, $phpbb_root_path, $phpEx, $phpbb_container; - - /** @var \phpbb\group\helper $group_helper */ - $group_helper = $phpbb_container->get('group_helper'); - - $addresses = array(); - - foreach ($check_ary as $check_type => $address_field) - { - if (!is_array($address_field)) - { - // Split Addresses into users and groups - preg_match_all('/:?(u|g)_([0-9]+):?/', $address_field, $match); - - $u = $g = array(); - foreach ($match[1] as $id => $type) - { - ${$type}[] = (int) $match[2][$id]; - } - } - else - { - $u = $address_field['u']; - $g = $address_field['g']; - } - - $address = array(); - if (count($u)) - { - $sql = 'SELECT user_id, username, user_colour - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('user_id', $u); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if ($check_type == 'to' || $author_id == $user->data['user_id'] || $row['user_id'] == $user->data['user_id']) - { - if ($plaintext) - { - $address[] = $row['username']; - } - else - { - $address['user'][$row['user_id']] = array('name' => $row['username'], 'colour' => $row['user_colour']); - } - } - } - $db->sql_freeresult($result); - } - - if (count($g)) - { - if ($plaintext) - { - $sql = 'SELECT group_name, group_type - FROM ' . GROUPS_TABLE . ' - WHERE ' . $db->sql_in_set('group_id', $g); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if ($check_type == 'to' || $author_id == $user->data['user_id'] || $row['user_id'] == $user->data['user_id']) - { - $address[] = $group_helper->get_name($row['group_name']); - } - } - $db->sql_freeresult($result); - } - else - { - $sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type, ug.user_id - FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . ' ug - WHERE ' . $db->sql_in_set('g.group_id', $g) . ' - AND g.group_id = ug.group_id - AND ug.user_pending = 0'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if (!isset($address['group'][$row['group_id']])) - { - if ($check_type == 'to' || $author_id == $user->data['user_id'] || $row['user_id'] == $user->data['user_id']) - { - $row['group_name'] = $group_helper->get_name($row['group_name']); - $address['group'][$row['group_id']] = array('name' => $row['group_name'], 'colour' => $row['group_colour']); - } - } - - if (isset($address['user'][$row['user_id']])) - { - $address['user'][$row['user_id']]['in_group'] = $row['group_id']; - } - } - $db->sql_freeresult($result); - } - } - - if (count($address) && !$plaintext) - { - $template->assign_var('S_' . strtoupper($check_type) . '_RECIPIENT', true); - - foreach ($address as $type => $adr_ary) - { - foreach ($adr_ary as $id => $row) - { - $tpl_ary = array( - 'IS_GROUP' => ($type == 'group') ? true : false, - 'IS_USER' => ($type == 'user') ? true : false, - 'UG_ID' => $id, - 'NAME' => $row['name'], - 'COLOUR' => ($row['colour']) ? '#' . $row['colour'] : '', - 'TYPE' => $type, - ); - - if ($type == 'user') - { - $tpl_ary = array_merge($tpl_ary, array( - 'U_VIEW' => get_username_string('profile', $id, $row['name'], $row['colour']), - 'NAME_FULL' => get_username_string('full', $id, $row['name'], $row['colour']), - )); - } - else - { - $tpl_ary = array_merge($tpl_ary, array( - 'U_VIEW' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&g=' . $id), - )); - } - - $template->assign_block_vars($check_type . '_recipient', $tpl_ary); - } - } - } - - $addresses[$check_type] = $address; - } - - return $addresses; -} - -/** -* Get folder status -*/ -function get_folder_status($folder_id, $folder) -{ - global $user; - - if (isset($folder[$folder_id])) - { - $folder = $folder[$folder_id]; - } - else - { - return false; - } - - $return = array( - 'folder_name' => $folder['folder_name'], - 'cur' => $folder['num_messages'], - 'remaining' => ($user->data['message_limit']) ? $user->data['message_limit'] - $folder['num_messages'] : 0, - 'max' => $user->data['message_limit'], - 'percent' => ($user->data['message_limit']) ? (($user->data['message_limit'] > 0) ? floor(($folder['num_messages'] / $user->data['message_limit']) * 100) : 100) : 0, - ); - - $return['message'] = $user->lang('FOLDER_STATUS_MSG', $user->lang('MESSAGES_COUNT', (int) $return['max']), (int) $return['cur'], $return['percent']); - - return $return; -} - -// -// COMPOSE MESSAGES -// - -/** -* Submit PM -*/ -function submit_pm($mode, $subject, &$data_ary, $put_in_outbox = true) -{ - global $db, $auth, $config, $user, $phpbb_root_path, $phpbb_container, $phpbb_dispatcher, $request; - - // We do not handle erasing pms here - if ($mode == 'delete') - { - return false; - } - - $current_time = time(); - - $data = $data_ary; - /** - * Get all parts of the PM that are to be submited to the DB. - * - * @event core.submit_pm_before - * @var string mode PM Post mode - post|reply|quote|quotepost|forward|edit - * @var string subject Subject of the private message - * @var array data The whole row data of the PM. - * @since 3.1.0-b3 - */ - $vars = array('mode', 'subject', 'data'); - extract($phpbb_dispatcher->trigger_event('core.submit_pm_before', compact($vars))); - $data_ary = $data; - unset($data); - - // Collect some basic information about which tables and which rows to update/insert - $sql_data = array(); - $root_level = 0; - - // Recipient Information - $recipients = $to = $bcc = array(); - - if ($mode != 'edit') - { - // Build Recipient List - // u|g => array($user_id => 'to'|'bcc') - $_types = array('u', 'g'); - foreach ($_types as $ug_type) - { - if (isset($data_ary['address_list'][$ug_type]) && count($data_ary['address_list'][$ug_type])) - { - foreach ($data_ary['address_list'][$ug_type] as $id => $field) - { - $id = (int) $id; - - // Do not rely on the address list being "valid" - if (!$id || ($ug_type == 'u' && $id == ANONYMOUS)) - { - continue; - } - - $field = ($field == 'to') ? 'to' : 'bcc'; - if ($ug_type == 'u') - { - $recipients[$id] = $field; - } - ${$field}[] = $ug_type . '_' . $id; - } - } - } - - if (isset($data_ary['address_list']['g']) && count($data_ary['address_list']['g'])) - { - // We need to check the PM status of group members (do they want to receive PM's?) - // Only check if not a moderator or admin, since they are allowed to override this user setting - $sql_allow_pm = (!$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_')) ? ' AND u.user_allow_pm = 1' : ''; - - $sql = 'SELECT u.user_type, ug.group_id, ug.user_id - FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . ' ug - WHERE ' . $db->sql_in_set('ug.group_id', array_keys($data_ary['address_list']['g'])) . ' - AND ug.user_pending = 0 - AND u.user_id = ug.user_id - AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')' . - $sql_allow_pm; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $field = ($data_ary['address_list']['g'][$row['group_id']] == 'to') ? 'to' : 'bcc'; - $recipients[$row['user_id']] = $field; - } - $db->sql_freeresult($result); - } - - if (!count($recipients)) - { - trigger_error('NO_RECIPIENT'); - } - } - - // First of all make sure the subject are having the correct length. - $subject = truncate_string($subject); - - $db->sql_transaction('begin'); - - $sql = ''; - - switch ($mode) - { - case 'reply': - case 'quote': - $root_level = ($data_ary['reply_from_root_level']) ? $data_ary['reply_from_root_level'] : $data_ary['reply_from_msg_id']; - - // Set message_replied switch for this user - $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . ' - SET pm_replied = 1 - WHERE user_id = ' . $data_ary['from_user_id'] . ' - AND msg_id = ' . $data_ary['reply_from_msg_id']; - - // no break - - case 'forward': - case 'post': - case 'quotepost': - $sql_data = array( - 'root_level' => $root_level, - 'author_id' => $data_ary['from_user_id'], - 'icon_id' => $data_ary['icon_id'], - 'author_ip' => $data_ary['from_user_ip'], - 'message_time' => $current_time, - 'enable_bbcode' => $data_ary['enable_bbcode'], - 'enable_smilies' => $data_ary['enable_smilies'], - 'enable_magic_url' => $data_ary['enable_urls'], - 'enable_sig' => $data_ary['enable_sig'], - 'message_subject' => $subject, - 'message_text' => $data_ary['message'], - 'message_attachment'=> (!empty($data_ary['attachment_data'])) ? 1 : 0, - 'bbcode_bitfield' => $data_ary['bbcode_bitfield'], - 'bbcode_uid' => $data_ary['bbcode_uid'], - 'to_address' => implode(':', $to), - 'bcc_address' => implode(':', $bcc), - 'message_reported' => 0, - ); - break; - - case 'edit': - $sql_data = array( - 'icon_id' => $data_ary['icon_id'], - 'message_edit_time' => $current_time, - 'enable_bbcode' => $data_ary['enable_bbcode'], - 'enable_smilies' => $data_ary['enable_smilies'], - 'enable_magic_url' => $data_ary['enable_urls'], - 'enable_sig' => $data_ary['enable_sig'], - 'message_subject' => $subject, - 'message_text' => $data_ary['message'], - 'message_attachment'=> (!empty($data_ary['attachment_data'])) ? 1 : 0, - 'bbcode_bitfield' => $data_ary['bbcode_bitfield'], - 'bbcode_uid' => $data_ary['bbcode_uid'] - ); - break; - } - - if (count($sql_data)) - { - if ($mode == 'post' || $mode == 'reply' || $mode == 'quote' || $mode == 'quotepost' || $mode == 'forward') - { - $db->sql_query('INSERT INTO ' . PRIVMSGS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_data)); - $data_ary['msg_id'] = $db->sql_nextid(); - } - else if ($mode == 'edit') - { - $sql = 'UPDATE ' . PRIVMSGS_TABLE . ' - SET message_edit_count = message_edit_count + 1, ' . $db->sql_build_array('UPDATE', $sql_data) . ' - WHERE msg_id = ' . $data_ary['msg_id']; - $db->sql_query($sql); - } - } - - if ($mode != 'edit') - { - if ($sql) - { - $db->sql_query($sql); - } - unset($sql); - - $sql_ary = array(); - foreach ($recipients as $user_id => $type) - { - $sql_ary[] = array( - 'msg_id' => (int) $data_ary['msg_id'], - 'user_id' => (int) $user_id, - 'author_id' => (int) $data_ary['from_user_id'], - 'folder_id' => PRIVMSGS_NO_BOX, - 'pm_new' => 1, - 'pm_unread' => 1, - 'pm_forwarded' => ($mode == 'forward') ? 1 : 0 - ); - } - - $db->sql_multi_insert(PRIVMSGS_TO_TABLE, $sql_ary); - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_new_privmsg = user_new_privmsg + 1, user_unread_privmsg = user_unread_privmsg + 1, user_last_privmsg = ' . time() . ' - WHERE ' . $db->sql_in_set('user_id', array_keys($recipients)); - $db->sql_query($sql); - - // Put PM into outbox - if ($put_in_outbox) - { - $db->sql_query('INSERT INTO ' . PRIVMSGS_TO_TABLE . ' ' . $db->sql_build_array('INSERT', array( - 'msg_id' => (int) $data_ary['msg_id'], - 'user_id' => (int) $data_ary['from_user_id'], - 'author_id' => (int) $data_ary['from_user_id'], - 'folder_id' => PRIVMSGS_OUTBOX, - 'pm_new' => 0, - 'pm_unread' => 0, - 'pm_forwarded' => ($mode == 'forward') ? 1 : 0)) - ); - } - } - - // Set user last post time - if ($mode == 'reply' || $mode == 'quote' || $mode == 'quotepost' || $mode == 'forward' || $mode == 'post') - { - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_lastpost_time = $current_time - WHERE user_id = " . $data_ary['from_user_id']; - $db->sql_query($sql); - } - - // Submit Attachments - if (!empty($data_ary['attachment_data']) && $data_ary['msg_id'] && in_array($mode, array('post', 'reply', 'quote', 'quotepost', 'edit', 'forward'))) - { - $space_taken = $files_added = 0; - $orphan_rows = array(); - - foreach ($data_ary['attachment_data'] as $pos => $attach_row) - { - $orphan_rows[(int) $attach_row['attach_id']] = array(); - } - - if (count($orphan_rows)) - { - $sql = 'SELECT attach_id, filesize, physical_filename - FROM ' . ATTACHMENTS_TABLE . ' - WHERE ' . $db->sql_in_set('attach_id', array_keys($orphan_rows)) . ' - AND in_message = 1 - AND is_orphan = 1 - AND poster_id = ' . $user->data['user_id']; - $result = $db->sql_query($sql); - - $orphan_rows = array(); - while ($row = $db->sql_fetchrow($result)) - { - $orphan_rows[$row['attach_id']] = $row; - } - $db->sql_freeresult($result); - } - - foreach ($data_ary['attachment_data'] as $pos => $attach_row) - { - if ($attach_row['is_orphan'] && !isset($orphan_rows[$attach_row['attach_id']])) - { - continue; - } - - if (!$attach_row['is_orphan']) - { - // update entry in db if attachment already stored in db and filespace - $sql = 'UPDATE ' . ATTACHMENTS_TABLE . " - SET attach_comment = '" . $db->sql_escape($attach_row['attach_comment']) . "' - WHERE attach_id = " . (int) $attach_row['attach_id'] . ' - AND is_orphan = 0'; - $db->sql_query($sql); - } - else - { - // insert attachment into db - if (!@file_exists($phpbb_root_path . $config['upload_path'] . '/' . utf8_basename($orphan_rows[$attach_row['attach_id']]['physical_filename']))) - { - continue; - } - - $space_taken += $orphan_rows[$attach_row['attach_id']]['filesize']; - $files_added++; - - $attach_sql = array( - 'post_msg_id' => $data_ary['msg_id'], - 'topic_id' => 0, - 'is_orphan' => 0, - 'poster_id' => $data_ary['from_user_id'], - 'attach_comment' => $attach_row['attach_comment'], - ); - - $sql = 'UPDATE ' . ATTACHMENTS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $attach_sql) . ' - WHERE attach_id = ' . $attach_row['attach_id'] . ' - AND is_orphan = 1 - AND poster_id = ' . $user->data['user_id']; - $db->sql_query($sql); - } - } - - if ($space_taken && $files_added) - { - $config->increment('upload_dir_size', $space_taken, false); - $config->increment('num_files', $files_added, false); - } - } - - // Delete draft if post was loaded... - $draft_id = $request->variable('draft_loaded', 0); - if ($draft_id) - { - $sql = 'DELETE FROM ' . DRAFTS_TABLE . " - WHERE draft_id = $draft_id - AND user_id = " . $data_ary['from_user_id']; - $db->sql_query($sql); - } - - $db->sql_transaction('commit'); - - // Send Notifications - $pm_data = array_merge($data_ary, array( - 'message_subject' => $subject, - 'recipients' => $recipients, - )); - - /* @var $phpbb_notifications \phpbb\notification\manager */ - $phpbb_notifications = $phpbb_container->get('notification_manager'); - - if ($mode == 'edit') - { - $phpbb_notifications->update_notifications('notification.type.pm', $pm_data); - } - else - { - $phpbb_notifications->add_notifications('notification.type.pm', $pm_data); - } - - $data = $data_ary; - /** - * Get PM message ID after submission to DB - * - * @event core.submit_pm_after - * @var string mode PM Post mode - post|reply|quote|quotepost|forward|edit - * @var string subject Subject of the private message - * @var array data The whole row data of the PM. - * @var array pm_data The data sent to notification class - * @since 3.1.0-b5 - */ - $vars = array('mode', 'subject', 'data', 'pm_data'); - extract($phpbb_dispatcher->trigger_event('core.submit_pm_after', compact($vars))); - $data_ary = $data; - unset($data); - - return $data_ary['msg_id']; -} - -/** -* Display Message History -*/ -function message_history($msg_id, $user_id, $message_row, $folder, $in_post_mode = false) -{ - global $db, $user, $template, $phpbb_root_path, $phpEx, $auth; - - // Select all receipts and the author from the pm we currently view, to only display their pm-history - $sql = 'SELECT author_id, user_id - FROM ' . PRIVMSGS_TO_TABLE . " - WHERE msg_id = $msg_id - AND folder_id <> " . PRIVMSGS_HOLD_BOX; - $result = $db->sql_query($sql); - - $recipients = array(); - while ($row = $db->sql_fetchrow($result)) - { - $recipients[] = (int) $row['user_id']; - $recipients[] = (int) $row['author_id']; - } - $db->sql_freeresult($result); - $recipients = array_unique($recipients); - - // Get History Messages (could be newer) - $sql = 'SELECT t.*, p.*, u.* - FROM ' . PRIVMSGS_TABLE . ' p, ' . PRIVMSGS_TO_TABLE . ' t, ' . USERS_TABLE . ' u - WHERE t.msg_id = p.msg_id - AND p.author_id = u.user_id - AND t.folder_id NOT IN (' . PRIVMSGS_NO_BOX . ', ' . PRIVMSGS_HOLD_BOX . ') - AND ' . $db->sql_in_set('t.author_id', $recipients, false, true) . " - AND t.user_id = $user_id"; - - // We no longer need those. - unset($recipients); - - if (!$message_row['root_level']) - { - $sql .= " AND (p.root_level = $msg_id OR (p.root_level = 0 AND p.msg_id = $msg_id))"; - } - else - { - $sql .= " AND (p.root_level = " . $message_row['root_level'] . ' OR p.msg_id = ' . $message_row['root_level'] . ')'; - } - $sql .= ' ORDER BY p.message_time DESC'; - - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - - if (!$row) - { - $db->sql_freeresult($result); - return false; - } - - $title = $row['message_subject']; - - $rowset = array(); - $folder_url = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm') . '&folder='; - - do - { - $folder_id = (int) $row['folder_id']; - - $row['folder'][] = (isset($folder[$folder_id])) ? '' . $folder[$folder_id]['folder_name'] . '' : $user->lang['UNKNOWN_FOLDER']; - - if (isset($rowset[$row['msg_id']])) - { - $rowset[$row['msg_id']]['folder'][] = (isset($folder[$folder_id])) ? '' . $folder[$folder_id]['folder_name'] . '' : $user->lang['UNKNOWN_FOLDER']; - } - else - { - $rowset[$row['msg_id']] = $row; - } - } - while ($row = $db->sql_fetchrow($result)); - $db->sql_freeresult($result); - - if (count($rowset) == 1 && !$in_post_mode) - { - return false; - } - - $title = censor_text($title); - - $url = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm'); - $next_history_pm = $previous_history_pm = $prev_id = 0; - - // Re-order rowset to be able to get the next/prev message rows... - $rowset = array_values($rowset); - - for ($i = 0, $size = count($rowset); $i < $size; $i++) - { - $row = &$rowset[$i]; - $id = (int) $row['msg_id']; - - $author_id = $row['author_id']; - $folder_id = (int) $row['folder_id']; - - $subject = $row['message_subject']; - $message = $row['message_text']; - - $message = censor_text($message); - - $decoded_message = false; - - if ($in_post_mode && $auth->acl_get('u_sendpm') && $author_id != ANONYMOUS) - { - $decoded_message = $message; - decode_message($decoded_message, $row['bbcode_uid']); - - $decoded_message = bbcode_nl2br($decoded_message); - } - - $parse_flags = ($row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0); - $parse_flags |= ($row['enable_smilies'] ? OPTION_FLAG_SMILIES : 0); - - $message = generate_text_for_display($message, $row['bbcode_uid'], $row['bbcode_bitfield'], $parse_flags, false); - - $subject = censor_text($subject); - - if ($id == $msg_id) - { - $next_history_pm = (isset($rowset[$i + 1])) ? (int) $rowset[$i + 1]['msg_id'] : 0; - $previous_history_pm = $prev_id; - } - - $template->assign_block_vars('history_row', array( - 'MESSAGE_AUTHOR_QUOTE' => (($decoded_message) ? addslashes(get_username_string('username', $author_id, $row['username'], $row['user_colour'], $row['username'])) : ''), - 'MESSAGE_AUTHOR_FULL' => get_username_string('full', $author_id, $row['username'], $row['user_colour'], $row['username']), - 'MESSAGE_AUTHOR_COLOUR' => get_username_string('colour', $author_id, $row['username'], $row['user_colour'], $row['username']), - 'MESSAGE_AUTHOR' => get_username_string('username', $author_id, $row['username'], $row['user_colour'], $row['username']), - 'U_MESSAGE_AUTHOR' => get_username_string('profile', $author_id, $row['username'], $row['user_colour'], $row['username']), - - 'SUBJECT' => $subject, - 'SENT_DATE' => $user->format_date($row['message_time']), - 'MESSAGE' => $message, - 'FOLDER' => implode($user->lang['COMMA_SEPARATOR'], $row['folder']), - 'DECODED_MESSAGE' => $decoded_message, - - 'S_CURRENT_MSG' => ($row['msg_id'] == $msg_id), - 'S_AUTHOR_DELETED' => ($author_id == ANONYMOUS) ? true : false, - 'S_IN_POST_MODE' => $in_post_mode, - - 'MSG_ID' => $row['msg_id'], - 'MESSAGE_TIME' => $row['message_time'], - 'USER_ID' => $row['user_id'], - 'U_VIEW_MESSAGE' => "$url&f=$folder_id&p=" . $row['msg_id'], - 'U_QUOTE' => (!$in_post_mode && $auth->acl_get('u_sendpm') && $author_id != ANONYMOUS) ? "$url&mode=compose&action=quote&f=" . $folder_id . "&p=" . $row['msg_id'] : '', - 'U_POST_REPLY_PM' => ($author_id != $user->data['user_id'] && $author_id != ANONYMOUS && $auth->acl_get('u_sendpm')) ? "$url&mode=compose&action=reply&f=$folder_id&p=" . $row['msg_id'] : '') - ); - unset($rowset[$i]); - $prev_id = $id; - } - - $template->assign_vars(array( - 'QUOTE_IMG' => $user->img('icon_post_quote', $user->lang['REPLY_WITH_QUOTE']), - 'HISTORY_TITLE' => $title, - - 'U_VIEW_NEXT_HISTORY' => ($next_history_pm) ? "$url&p=" . $next_history_pm : '', - 'U_VIEW_PREVIOUS_HISTORY' => ($previous_history_pm) ? "$url&p=" . $previous_history_pm : '', - )); - - return true; -} - -/** -* Set correct users max messages in PM folder. -* If several group memberships define different amount of messages, the highest will be chosen. -*/ -function set_user_message_limit() -{ - global $user, $db, $config; - - // Get maximum about from user memberships - $message_limit = phpbb_get_max_setting_from_group($db, $user->data['user_id'], 'message_limit'); - - // If it is 0, there is no limit set and we use the maximum value within the config. - $user->data['message_limit'] = (!$message_limit) ? $config['pm_max_msgs'] : $message_limit; -} - -/** - * Get the maximum PM setting for the groups of the user - * - * @param \phpbb\db\driver\driver_interface $db - * @param int $user_id - * @param string $setting Only 'max_recipients' and 'message_limit' are supported - * @return int The maximum setting for all groups of the user, unless one group has '0' - * @throws \InvalidArgumentException If selected group setting is not supported - */ -function phpbb_get_max_setting_from_group(\phpbb\db\driver\driver_interface $db, $user_id, $setting) -{ - if ($setting !== 'max_recipients' && $setting !== 'message_limit') - { - throw new InvalidArgumentException('Setting "' . $setting . '" is not supported'); - } - - // Get maximum number of allowed recipients - $sql = 'SELECT MAX(g.group_' . $setting . ') as max_setting - FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . ' ug - WHERE ug.user_id = ' . (int) $user_id . ' - AND ug.user_pending = 0 - AND ug.group_id = g.group_id'; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - $max_setting = (int) $row['max_setting']; - - return $max_setting; -} - -/** -* Generates an array of coloured recipient names from a list of PMs - (groups & users) -* -* @param array $pm_by_id An array of rows from PRIVMSGS_TABLE, keys are the msg_ids. -* -* @return array 2D Array: array(msg_id => array('username or group string', ...), ...) -* Usernames are generated with {@link get_username_string get_username_string} -* Groups are coloured and have a link to the membership page -*/ -function get_recipient_strings($pm_by_id) -{ - global $db, $phpbb_root_path, $phpEx, $user, $phpbb_container; - - /** @var \phpbb\group\helper $group_helper */ - $group_helper = $phpbb_container->get('group_helper'); - - $address_list = $recipient_list = $address = array(); - - $_types = array('u', 'g'); - - foreach ($pm_by_id as $message_id => $row) - { - $address[$message_id] = rebuild_header(array('to' => $row['to_address'], 'bcc' => $row['bcc_address'])); - - foreach ($_types as $ug_type) - { - if (isset($address[$message_id][$ug_type]) && count($address[$message_id][$ug_type])) - { - foreach ($address[$message_id][$ug_type] as $ug_id => $in_to) - { - $recipient_list[$ug_type][$ug_id] = array('name' => $user->lang['NA'], 'colour' => ''); - } - } - } - } - - foreach ($_types as $ug_type) - { - if (!empty($recipient_list[$ug_type])) - { - if ($ug_type == 'u') - { - $sql = 'SELECT user_id as id, username as name, user_colour as colour - FROM ' . USERS_TABLE . ' - WHERE '; - } - else - { - $sql = 'SELECT group_id as id, group_name as name, group_colour as colour, group_type - FROM ' . GROUPS_TABLE . ' - WHERE '; - } - $sql .= $db->sql_in_set(($ug_type == 'u') ? 'user_id' : 'group_id', array_map('intval', array_keys($recipient_list[$ug_type]))); - - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if ($ug_type == 'g') - { - $row['name'] = $group_helper->get_name($row['name']); - } - - $recipient_list[$ug_type][$row['id']] = array('name' => $row['name'], 'colour' => $row['colour']); - } - $db->sql_freeresult($result); - } - } - - foreach ($address as $message_id => $adr_ary) - { - foreach ($adr_ary as $type => $id_ary) - { - foreach ($id_ary as $ug_id => $_id) - { - if ($type == 'u') - { - $address_list[$message_id][] = get_username_string('full', $ug_id, $recipient_list[$type][$ug_id]['name'], $recipient_list[$type][$ug_id]['colour']); - } - else - { - $user_colour = ($recipient_list[$type][$ug_id]['colour']) ? ' style="font-weight: bold; color:#' . $recipient_list[$type][$ug_id]['colour'] . '"' : ''; - $link = ''; - $address_list[$message_id][] = $link . $recipient_list[$type][$ug_id]['name'] . (($link) ? '' : ''); - } - } - } - } - - return $address_list; -} diff --git a/install/update/old/includes/functions_transfer.php b/install/update/old/includes/functions_transfer.php deleted file mode 100644 index 7427b89..0000000 --- a/install/update/old/includes/functions_transfer.php +++ /dev/null @@ -1,899 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* Transfer class, wrapper for ftp/sftp/ssh -*/ -class transfer -{ - var $connection; - var $host; - var $port; - var $username; - var $password; - var $timeout; - var $root_path; - var $tmp_path; - var $file_perms; - var $dir_perms; - - /** - * Constructor - init some basic values - */ - function __construct() - { - global $phpbb_root_path; - - $this->file_perms = 0644; - $this->dir_perms = 0777; - - // We use the store directory as temporary path to circumvent open basedir restrictions - $this->tmp_path = $phpbb_root_path . 'store/'; - } - - /** - * Write file to location - */ - function write_file($destination_file = '', $contents = '') - { - global $phpbb_root_path; - - $destination_file = $this->root_path . str_replace($phpbb_root_path, '', $destination_file); - - // need to create a temp file and then move that temp file. - // ftp functions can only move files around and can't create. - // This means that the users will need to have access to write - // temporary files or have write access on a folder within phpBB - // like the cache folder. If the user can't do either, then - // he/she needs to use the fsock ftp method - $temp_name = tempnam($this->tmp_path, 'transfer_'); - @unlink($temp_name); - - $fp = @fopen($temp_name, 'w'); - - if (!$fp) - { - trigger_error('Unable to create temporary file ' . $temp_name, E_USER_ERROR); - } - - @fwrite($fp, $contents); - @fclose($fp); - - $result = $this->overwrite_file($temp_name, $destination_file); - - // remove temporary file now - @unlink($temp_name); - - return $result; - } - - /** - * Moving file into location. If the destination file already exists it gets overwritten - */ - function overwrite_file($source_file, $destination_file) - { - /** - * @todo generally think about overwriting files in another way, by creating a temporary file and then renaming it - * @todo check for the destination file existance too - */ - $this->_delete($destination_file); - $result = $this->_put($source_file, $destination_file); - $this->_chmod($destination_file, $this->file_perms); - - return $result; - } - - /** - * Create directory structure - */ - function make_dir($dir) - { - global $phpbb_root_path; - - $dir = str_replace($phpbb_root_path, '', $dir); - $dir = explode('/', $dir); - $dirs = ''; - - for ($i = 0, $total = count($dir); $i < $total; $i++) - { - $result = true; - - if (strpos($dir[$i], '.') === 0) - { - continue; - } - $cur_dir = $dir[$i] . '/'; - - if (!file_exists($phpbb_root_path . $dirs . $cur_dir)) - { - // create the directory - $result = $this->_mkdir($dir[$i]); - $this->_chmod($dir[$i], $this->dir_perms); - } - - $this->_chdir($this->root_path . $dirs . $dir[$i]); - $dirs .= $cur_dir; - } - - $this->_chdir($this->root_path); - - /** - * @todo stack result into array to make sure every path creation has been taken care of - */ - return $result; - } - - /** - * Copy file from source location to destination location - */ - function copy_file($from_loc, $to_loc) - { - global $phpbb_root_path; - - $from_loc = ((strpos($from_loc, $phpbb_root_path) !== 0) ? $phpbb_root_path : '') . $from_loc; - $to_loc = $this->root_path . str_replace($phpbb_root_path, '', $to_loc); - - if (!file_exists($from_loc)) - { - return false; - } - - $result = $this->overwrite_file($from_loc, $to_loc); - - return $result; - } - - /** - * Remove file - */ - function delete_file($file) - { - global $phpbb_root_path; - - $file = $this->root_path . str_replace($phpbb_root_path, '', $file); - - return $this->_delete($file); - } - - /** - * Remove directory - * @todo remove child directories? - */ - function remove_dir($dir) - { - global $phpbb_root_path; - - $dir = $this->root_path . str_replace($phpbb_root_path, '', $dir); - - return $this->_rmdir($dir); - } - - /** - * Rename a file or folder - */ - function rename($old_handle, $new_handle) - { - global $phpbb_root_path; - - $old_handle = $this->root_path . str_replace($phpbb_root_path, '', $old_handle); - - return $this->_rename($old_handle, $new_handle); - } - - /** - * Check if a specified file exist... - */ - function file_exists($directory, $filename) - { - global $phpbb_root_path; - - $directory = $this->root_path . str_replace($phpbb_root_path, '', $directory); - - $this->_chdir($directory); - $result = $this->_ls(); - - if ($result !== false && is_array($result)) - { - return (in_array($filename, $result)) ? true : false; - } - - return false; - } - - /** - * Open session - */ - function open_session() - { - return $this->_init(); - } - - /** - * Close current session - */ - function close_session() - { - return $this->_close(); - } - - /** - * Determine methods able to be used - */ - static public function methods() - { - $methods = array(); - $disabled_functions = explode(',', @ini_get('disable_functions')); - - if (@extension_loaded('ftp')) - { - $methods[] = 'ftp'; - } - - if (!in_array('fsockopen', $disabled_functions)) - { - $methods[] = 'ftp_fsock'; - } - - return $methods; - } -} - -/** -* FTP transfer class -*/ -class ftp extends transfer -{ - /** - * Standard parameters for FTP session - */ - function __construct($host, $username, $password, $root_path, $port = 21, $timeout = 10) - { - $this->host = $host; - $this->port = $port; - $this->username = $username; - $this->password = $password; - $this->timeout = $timeout; - - // Make sure $this->root_path is layed out the same way as the $user->page['root_script_path'] value (/ at the end) - $this->root_path = str_replace('\\', '/', $this->root_path); - - if (!empty($root_path)) - { - $this->root_path = (($root_path[0] != '/' ) ? '/' : '') . $root_path . ((substr($root_path, -1, 1) == '/') ? '' : '/'); - } - - // Init some needed values - $this->transfer(); - - return; - } - - /** - * Requests data - */ - static public function data() - { - global $user; - - return array( - 'host' => 'localhost', - 'username' => 'anonymous', - 'password' => '', - 'root_path' => $user->page['root_script_path'], - 'port' => 21, - 'timeout' => 10 - ); - } - - /** - * Init FTP Session - * @access private - */ - function _init() - { - // connect to the server - $this->connection = @ftp_connect($this->host, $this->port, $this->timeout); - - if (!$this->connection) - { - return 'ERR_CONNECTING_SERVER'; - } - - // login to the server - if (!@ftp_login($this->connection, $this->username, $this->password)) - { - return 'ERR_UNABLE_TO_LOGIN'; - } - - // attempt to turn pasv mode on - @ftp_pasv($this->connection, true); - - // change to the root directory - if (!$this->_chdir($this->root_path)) - { - return 'ERR_CHANGING_DIRECTORY'; - } - - return true; - } - - /** - * Create Directory (MKDIR) - * @access private - */ - function _mkdir($dir) - { - return @ftp_mkdir($this->connection, $dir); - } - - /** - * Remove directory (RMDIR) - * @access private - */ - function _rmdir($dir) - { - return @ftp_rmdir($this->connection, $dir); - } - - /** - * Rename file - * @access private - */ - function _rename($old_handle, $new_handle) - { - return @ftp_rename($this->connection, $old_handle, $new_handle); - } - - /** - * Change current working directory (CHDIR) - * @access private - */ - function _chdir($dir = '') - { - if ($dir && $dir !== '/') - { - if (substr($dir, -1, 1) == '/') - { - $dir = substr($dir, 0, -1); - } - } - - return @ftp_chdir($this->connection, $dir); - } - - /** - * change file permissions (CHMOD) - * @access private - */ - function _chmod($file, $perms) - { - if (function_exists('ftp_chmod')) - { - $err = @ftp_chmod($this->connection, $perms, $file); - } - else - { - // Unfortunatly CHMOD is not expecting an octal value... - // We need to transform the integer (which was an octal) to an octal representation (to get the int) and then pass as is. ;) - $chmod_cmd = 'CHMOD ' . base_convert($perms, 10, 8) . ' ' . $file; - $err = $this->_site($chmod_cmd); - } - - return $err; - } - - /** - * Upload file to location (PUT) - * @access private - */ - function _put($from_file, $to_file) - { - // We only use the BINARY file mode to cicumvent rewrite actions from ftp server (mostly linefeeds being replaced) - $mode = FTP_BINARY; - - $to_dir = dirname($to_file); - $to_file = basename($to_file); - $this->_chdir($to_dir); - - $result = @ftp_put($this->connection, $to_file, $from_file, $mode); - $this->_chdir($this->root_path); - - return $result; - } - - /** - * Delete file (DELETE) - * @access private - */ - function _delete($file) - { - return @ftp_delete($this->connection, $file); - } - - /** - * Close ftp session (CLOSE) - * @access private - */ - function _close() - { - if (!$this->connection) - { - return false; - } - - return @ftp_quit($this->connection); - } - - /** - * Return current working directory (CWD) - * At the moment not used by parent class - * @access private - */ - function _cwd() - { - return @ftp_pwd($this->connection); - } - - /** - * Return list of files in a given directory (LS) - * @access private - */ - function _ls($dir = './') - { - $list = @ftp_nlist($this->connection, $dir); - - // See bug #46295 - Some FTP daemons don't like './' - if ($dir === './') - { - // Let's try some alternatives - $list = (empty($list)) ? @ftp_nlist($this->connection, '.') : $list; - $list = (empty($list)) ? @ftp_nlist($this->connection, '') : $list; - } - - // Return on error - if ($list === false) - { - return false; - } - - // Remove path if prepended - foreach ($list as $key => $item) - { - // Use same separator for item and dir - $item = str_replace('\\', '/', $item); - $dir = str_replace('\\', '/', $dir); - - if (!empty($dir) && strpos($item, $dir) === 0) - { - $item = substr($item, strlen($dir)); - } - - $list[$key] = $item; - } - - return $list; - } - - /** - * FTP SITE command (ftp-only function) - * @access private - */ - function _site($command) - { - return @ftp_site($this->connection, $command); - } -} - -/** -* FTP fsock transfer class -*/ -class ftp_fsock extends transfer -{ - var $data_connection; - - /** - * Standard parameters for FTP session - */ - function __construct($host, $username, $password, $root_path, $port = 21, $timeout = 10) - { - $this->host = $host; - $this->port = $port; - $this->username = $username; - $this->password = $password; - $this->timeout = $timeout; - - // Make sure $this->root_path is layed out the same way as the $user->page['root_script_path'] value (/ at the end) - $this->root_path = str_replace('\\', '/', $this->root_path); - - if (!empty($root_path)) - { - $this->root_path = (($root_path[0] != '/' ) ? '/' : '') . $root_path . ((substr($root_path, -1, 1) == '/') ? '' : '/'); - } - - // Init some needed values - parent::__construct(); - - return; - } - - /** - * Requests data - */ - static public function data() - { - global $user; - - return array( - 'host' => 'localhost', - 'username' => 'anonymous', - 'password' => '', - 'root_path' => $user->page['root_script_path'], - 'port' => 21, - 'timeout' => 10 - ); - } - - /** - * Init FTP Session - * @access private - */ - function _init() - { - $errno = 0; - $errstr = ''; - - // connect to the server - $this->connection = @fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout); - - if (!$this->connection || !$this->_check_command()) - { - return 'ERR_CONNECTING_SERVER'; - } - - @stream_set_timeout($this->connection, $this->timeout); - - // login - if (!$this->_send_command('USER', $this->username)) - { - return 'ERR_UNABLE_TO_LOGIN'; - } - - if (!$this->_send_command('PASS', $this->password)) - { - return 'ERR_UNABLE_TO_LOGIN'; - } - - // change to the root directory - if (!$this->_chdir($this->root_path)) - { - return 'ERR_CHANGING_DIRECTORY'; - } - - return true; - } - - /** - * Create Directory (MKDIR) - * @access private - */ - function _mkdir($dir) - { - return $this->_send_command('MKD', $dir); - } - - /** - * Remove directory (RMDIR) - * @access private - */ - function _rmdir($dir) - { - return $this->_send_command('RMD', $dir); - } - - /** - * Rename File - * @access private - */ - function _rename($old_handle, $new_handle) - { - $this->_send_command('RNFR', $old_handle); - return $this->_send_command('RNTO', $new_handle); - } - - /** - * Change current working directory (CHDIR) - * @access private - */ - function _chdir($dir = '') - { - if ($dir && $dir !== '/') - { - if (substr($dir, -1, 1) == '/') - { - $dir = substr($dir, 0, -1); - } - } - - return $this->_send_command('CWD', $dir); - } - - /** - * change file permissions (CHMOD) - * @access private - */ - function _chmod($file, $perms) - { - // Unfortunatly CHMOD is not expecting an octal value... - // We need to transform the integer (which was an octal) to an octal representation (to get the int) and then pass as is. ;) - return $this->_send_command('SITE CHMOD', base_convert($perms, 10, 8) . ' ' . $file); - } - - /** - * Upload file to location (PUT) - * @access private - */ - function _put($from_file, $to_file) - { - // We only use the BINARY file mode to cicumvent rewrite actions from ftp server (mostly linefeeds being replaced) - // 'I' == BINARY - // 'A' == ASCII - if (!$this->_send_command('TYPE', 'I')) - { - return false; - } - - // open the connection to send file over - if (!$this->_open_data_connection()) - { - return false; - } - - $this->_send_command('STOR', $to_file, false); - - // send the file - $fp = @fopen($from_file, 'rb'); - while (!@feof($fp)) - { - @fwrite($this->data_connection, @fread($fp, 4096)); - } - @fclose($fp); - - // close connection - $this->_close_data_connection(); - - return $this->_check_command(); - } - - /** - * Delete file (DELETE) - * @access private - */ - function _delete($file) - { - return $this->_send_command('DELE', $file); - } - - /** - * Close ftp session (CLOSE) - * @access private - */ - function _close() - { - if (!$this->connection) - { - return false; - } - - return $this->_send_command('QUIT'); - } - - /** - * Return current working directory (CWD) - * At the moment not used by parent class - * @access private - */ - function _cwd() - { - $this->_send_command('PWD', '', false); - return preg_replace('#^[0-9]{3} "(.+)" .+\r\n#', '\\1', $this->_check_command(true)); - } - - /** - * Return list of files in a given directory (LS) - * @access private - */ - function _ls($dir = './') - { - if (!$this->_open_data_connection()) - { - return false; - } - - $this->_send_command('NLST', $dir); - - $list = array(); - while (!@feof($this->data_connection)) - { - $filename = preg_replace('#[\r\n]#', '', @fgets($this->data_connection, 512)); - - if ($filename !== '') - { - $list[] = $filename; - } - } - $this->_close_data_connection(); - - // Clear buffer - $this->_check_command(); - - // See bug #46295 - Some FTP daemons don't like './' - if ($dir === './' && empty($list)) - { - // Let's try some alternatives - $list = $this->_ls('.'); - - if (empty($list)) - { - $list = $this->_ls(''); - } - - return $list; - } - - // Remove path if prepended - foreach ($list as $key => $item) - { - // Use same separator for item and dir - $item = str_replace('\\', '/', $item); - $dir = str_replace('\\', '/', $dir); - - if (!empty($dir) && strpos($item, $dir) === 0) - { - $item = substr($item, strlen($dir)); - } - - $list[$key] = $item; - } - - return $list; - } - - /** - * Send a command to server (FTP fsock only function) - * @access private - */ - function _send_command($command, $args = '', $check = true) - { - if (!empty($args)) - { - $command = "$command $args"; - } - - fwrite($this->connection, $command . "\r\n"); - - if ($check === true && !$this->_check_command()) - { - return false; - } - - return true; - } - - /** - * Opens a connection to send data (FTP fosck only function) - * @access private - */ - function _open_data_connection() - { - // Try to find out whether we have a IPv4 or IPv6 (control) connection - if (function_exists('stream_socket_get_name')) - { - $socket_name = stream_socket_get_name($this->connection, true); - $server_ip = substr($socket_name, 0, strrpos($socket_name, ':')); - } - - if (!isset($server_ip) || preg_match(get_preg_expression('ipv4'), $server_ip)) - { - // Passive mode - $this->_send_command('PASV', '', false); - - if (!$ip_port = $this->_check_command(true)) - { - return false; - } - - // open the connection to start sending the file - if (!preg_match('#[0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]+,[0-9]+#', $ip_port, $temp)) - { - // bad ip and port - return false; - } - - $temp = explode(',', $temp[0]); - $server_ip = $temp[0] . '.' . $temp[1] . '.' . $temp[2] . '.' . $temp[3]; - $server_port = $temp[4] * 256 + $temp[5]; - } - else - { - // Extended Passive Mode - RFC2428 - $this->_send_command('EPSV', '', false); - - if (!$epsv_response = $this->_check_command(true)) - { - return false; - } - - // Response looks like "229 Entering Extended Passive Mode (|||12345|)" - // where 12345 is the tcp port for the data connection - if (!preg_match('#\(\|\|\|([0-9]+)\|\)#', $epsv_response, $match)) - { - return false; - } - $server_port = (int) $match[1]; - - // fsockopen expects IPv6 address in square brackets - $server_ip = "[$server_ip]"; - } - - $errno = 0; - $errstr = ''; - - if (!$this->data_connection = @fsockopen($server_ip, $server_port, $errno, $errstr, $this->timeout)) - { - return false; - } - @stream_set_timeout($this->data_connection, $this->timeout); - - return true; - } - - /** - * Closes a connection used to send data - * @access private - */ - function _close_data_connection() - { - return @fclose($this->data_connection); - } - - /** - * Check to make sure command was successful (FTP fsock only function) - * @access private - */ - function _check_command($return = false) - { - $response = ''; - - do - { - $result = @fgets($this->connection, 512); - $response .= $result; - } - while (substr($result, 3, 1) !== ' '); - - if (!preg_match('#^[123]#', $response)) - { - return false; - } - - return ($return) ? $response : true; - } -} diff --git a/install/update/old/includes/functions_user.php b/install/update/old/includes/functions_user.php deleted file mode 100644 index fb9241d..0000000 --- a/install/update/old/includes/functions_user.php +++ /dev/null @@ -1,3759 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* Obtain user_ids from usernames or vice versa. Returns false on -* success else the error string -* -* @param array &$user_id_ary The user ids to check or empty if usernames used -* @param array &$username_ary The usernames to check or empty if user ids used -* @param mixed $user_type Array of user types to check, false if not restricting by user type -* @param boolean $update_references If false, the supplied array is unset and appears unchanged from where it was called -* @return boolean|string Returns false on success, error string on failure -*/ -function user_get_id_name(&$user_id_ary, &$username_ary, $user_type = false, $update_references = false) -{ - global $db; - - // Are both arrays already filled? Yep, return else - // are neither array filled? - if ($user_id_ary && $username_ary) - { - return false; - } - else if (!$user_id_ary && !$username_ary) - { - return 'NO_USERS'; - } - - $which_ary = ($user_id_ary) ? 'user_id_ary' : 'username_ary'; - - if (${$which_ary} && !is_array(${$which_ary})) - { - ${$which_ary} = array(${$which_ary}); - } - - $sql_in = ($which_ary == 'user_id_ary') ? array_map('intval', ${$which_ary}) : array_map('utf8_clean_string', ${$which_ary}); - - // By unsetting the array here, the values passed in at the point user_get_id_name() was called will be retained. - // Otherwise, if we don't unset (as the array was passed by reference) the original array will be updated below. - if ($update_references === false) - { - unset(${$which_ary}); - } - - $user_id_ary = $username_ary = array(); - - // Grab the user id/username records - $sql_where = ($which_ary == 'user_id_ary') ? 'user_id' : 'username_clean'; - $sql = 'SELECT user_id, username - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set($sql_where, $sql_in); - - if ($user_type !== false && !empty($user_type)) - { - $sql .= ' AND ' . $db->sql_in_set('user_type', $user_type); - } - - $result = $db->sql_query($sql); - - if (!($row = $db->sql_fetchrow($result))) - { - $db->sql_freeresult($result); - return 'NO_USERS'; - } - - do - { - $username_ary[$row['user_id']] = $row['username']; - $user_id_ary[] = $row['user_id']; - } - while ($row = $db->sql_fetchrow($result)); - $db->sql_freeresult($result); - - return false; -} - -/** -* Get latest registered username and update database to reflect it -*/ -function update_last_username() -{ - global $config, $db; - - // Get latest username - $sql = 'SELECT user_id, username, user_colour - FROM ' . USERS_TABLE . ' - WHERE user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ') - ORDER BY user_id DESC'; - $result = $db->sql_query_limit($sql, 1); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - $config->set('newest_user_id', $row['user_id'], false); - $config->set('newest_username', $row['username'], false); - $config->set('newest_user_colour', $row['user_colour'], false); - } -} - -/** -* Updates a username across all relevant tables/fields -* -* @param string $old_name the old/current username -* @param string $new_name the new username -*/ -function user_update_name($old_name, $new_name) -{ - global $config, $db, $cache, $phpbb_dispatcher; - - $update_ary = array( - FORUMS_TABLE => array( - 'forum_last_poster_id' => 'forum_last_poster_name', - ), - MODERATOR_CACHE_TABLE => array( - 'user_id' => 'username', - ), - POSTS_TABLE => array( - 'poster_id' => 'post_username', - ), - TOPICS_TABLE => array( - 'topic_poster' => 'topic_first_poster_name', - 'topic_last_poster_id' => 'topic_last_poster_name', - ), - ); - - foreach ($update_ary as $table => $field_ary) - { - foreach ($field_ary as $id_field => $name_field) - { - $sql = "UPDATE $table - SET $name_field = '" . $db->sql_escape($new_name) . "' - WHERE $name_field = '" . $db->sql_escape($old_name) . "' - AND $id_field <> " . ANONYMOUS; - $db->sql_query($sql); - } - } - - if ($config['newest_username'] == $old_name) - { - $config->set('newest_username', $new_name, false); - } - - /** - * Update a username when it is changed - * - * @event core.update_username - * @var string old_name The old username that is replaced - * @var string new_name The new username - * @since 3.1.0-a1 - */ - $vars = array('old_name', 'new_name'); - extract($phpbb_dispatcher->trigger_event('core.update_username', compact($vars))); - - // Because some tables/caches use username-specific data we need to purge this here. - $cache->destroy('sql', MODERATOR_CACHE_TABLE); -} - -/** -* Adds an user -* -* @param mixed $user_row An array containing the following keys (and the appropriate values): username, group_id (the group to place the user in), user_email and the user_type(usually 0). Additional entries not overridden by defaults will be forwarded. -* @param array $cp_data custom profile fields, see custom_profile::build_insert_sql_array -* @param array $notifications_data The notifications settings for the new user -* @return the new user's ID. -*/ -function user_add($user_row, $cp_data = false, $notifications_data = null) -{ - global $db, $config; - global $phpbb_dispatcher, $phpbb_container; - - if (empty($user_row['username']) || !isset($user_row['group_id']) || !isset($user_row['user_email']) || !isset($user_row['user_type'])) - { - return false; - } - - $username_clean = utf8_clean_string($user_row['username']); - - if (empty($username_clean)) - { - return false; - } - - $sql_ary = array( - 'username' => $user_row['username'], - 'username_clean' => $username_clean, - 'user_password' => (isset($user_row['user_password'])) ? $user_row['user_password'] : '', - 'user_email' => strtolower($user_row['user_email']), - 'user_email_hash' => phpbb_email_hash($user_row['user_email']), - 'group_id' => $user_row['group_id'], - 'user_type' => $user_row['user_type'], - ); - - // These are the additional vars able to be specified - $additional_vars = array( - 'user_permissions' => '', - 'user_timezone' => $config['board_timezone'], - 'user_dateformat' => $config['default_dateformat'], - 'user_lang' => $config['default_lang'], - 'user_style' => (int) $config['default_style'], - 'user_actkey' => '', - 'user_ip' => '', - 'user_regdate' => time(), - 'user_passchg' => time(), - 'user_options' => 230271, - // We do not set the new flag here - registration scripts need to specify it - 'user_new' => 0, - - 'user_inactive_reason' => 0, - 'user_inactive_time' => 0, - 'user_lastmark' => time(), - 'user_lastvisit' => 0, - 'user_lastpost_time' => 0, - 'user_lastpage' => '', - 'user_posts' => 0, - 'user_colour' => '', - 'user_avatar' => '', - 'user_avatar_type' => '', - 'user_avatar_width' => 0, - 'user_avatar_height' => 0, - 'user_new_privmsg' => 0, - 'user_unread_privmsg' => 0, - 'user_last_privmsg' => 0, - 'user_message_rules' => 0, - 'user_full_folder' => PRIVMSGS_NO_BOX, - 'user_emailtime' => 0, - - 'user_notify' => 0, - 'user_notify_pm' => 1, - 'user_notify_type' => NOTIFY_EMAIL, - 'user_allow_pm' => 1, - 'user_allow_viewonline' => 1, - 'user_allow_viewemail' => 1, - 'user_allow_massemail' => 1, - - 'user_sig' => '', - 'user_sig_bbcode_uid' => '', - 'user_sig_bbcode_bitfield' => '', - - 'user_form_salt' => unique_id(), - ); - - // Now fill the sql array with not required variables - foreach ($additional_vars as $key => $default_value) - { - $sql_ary[$key] = (isset($user_row[$key])) ? $user_row[$key] : $default_value; - } - - // Any additional variables in $user_row not covered above? - $remaining_vars = array_diff(array_keys($user_row), array_keys($sql_ary)); - - // Now fill our sql array with the remaining vars - if (count($remaining_vars)) - { - foreach ($remaining_vars as $key) - { - $sql_ary[$key] = $user_row[$key]; - } - } - - /** - * Use this event to modify the values to be inserted when a user is added - * - * @event core.user_add_modify_data - * @var array user_row Array of user details submitted to user_add - * @var array cp_data Array of Custom profile fields submitted to user_add - * @var array sql_ary Array of data to be inserted when a user is added - * @var array notifications_data Array of notification data to be inserted when a user is added - * @since 3.1.0-a1 - * @changed 3.1.0-b5 Added user_row and cp_data - * @changed 3.1.11-RC1 Added notifications_data - */ - $vars = array('user_row', 'cp_data', 'sql_ary', 'notifications_data'); - extract($phpbb_dispatcher->trigger_event('core.user_add_modify_data', compact($vars))); - - $sql = 'INSERT INTO ' . USERS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); - $db->sql_query($sql); - - $user_id = $db->sql_nextid(); - - // Insert Custom Profile Fields - if ($cp_data !== false && count($cp_data)) - { - $cp_data['user_id'] = (int) $user_id; - - /* @var $cp \phpbb\profilefields\manager */ - $cp = $phpbb_container->get('profilefields.manager'); - $sql = 'INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' ' . - $db->sql_build_array('INSERT', $cp->build_insert_sql_array($cp_data)); - $db->sql_query($sql); - } - - // Place into appropriate group... - $sql = 'INSERT INTO ' . USER_GROUP_TABLE . ' ' . $db->sql_build_array('INSERT', array( - 'user_id' => (int) $user_id, - 'group_id' => (int) $user_row['group_id'], - 'user_pending' => 0) - ); - $db->sql_query($sql); - - // Now make it the users default group... - group_set_user_default($user_row['group_id'], array($user_id), false); - - // Add to newly registered users group if user_new is 1 - if ($config['new_member_post_limit'] && $sql_ary['user_new']) - { - $sql = 'SELECT group_id - FROM ' . GROUPS_TABLE . " - WHERE group_name = 'NEWLY_REGISTERED' - AND group_type = " . GROUP_SPECIAL; - $result = $db->sql_query($sql); - $add_group_id = (int) $db->sql_fetchfield('group_id'); - $db->sql_freeresult($result); - - if ($add_group_id) - { - global $phpbb_log; - - // Because these actions only fill the log unnecessarily, we disable it - $phpbb_log->disable('admin'); - - // Add user to "newly registered users" group and set to default group if admin specified so. - if ($config['new_member_group_default']) - { - group_user_add($add_group_id, $user_id, false, false, true); - $user_row['group_id'] = $add_group_id; - } - else - { - group_user_add($add_group_id, $user_id); - } - - $phpbb_log->enable('admin'); - } - } - - // set the newest user and adjust the user count if the user is a normal user and no activation mail is sent - if ($user_row['user_type'] == USER_NORMAL || $user_row['user_type'] == USER_FOUNDER) - { - $config->set('newest_user_id', $user_id, false); - $config->set('newest_username', $user_row['username'], false); - $config->increment('num_users', 1, false); - - $sql = 'SELECT group_colour - FROM ' . GROUPS_TABLE . ' - WHERE group_id = ' . (int) $user_row['group_id']; - $result = $db->sql_query_limit($sql, 1); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $config->set('newest_user_colour', $row['group_colour'], false); - } - - // Use default notifications settings if notifications_data is not set - if ($notifications_data === null) - { - $notifications_data = array( - array( - 'item_type' => 'notification.type.post', - 'method' => 'notification.method.email', - ), - array( - 'item_type' => 'notification.type.topic', - 'method' => 'notification.method.email', - ), - ); - } - - /** - * Modify the notifications data to be inserted in the database when a user is added - * - * @event core.user_add_modify_notifications_data - * @var array user_row Array of user details submitted to user_add - * @var array cp_data Array of Custom profile fields submitted to user_add - * @var array sql_ary Array of data to be inserted when a user is added - * @var array notifications_data Array of notification data to be inserted when a user is added - * @since 3.2.2-RC1 - */ - $vars = array('user_row', 'cp_data', 'sql_ary', 'notifications_data'); - extract($phpbb_dispatcher->trigger_event('core.user_add_modify_notifications_data', compact($vars))); - - // Subscribe user to notifications if necessary - if (!empty($notifications_data)) - { - /* @var $phpbb_notifications \phpbb\notification\manager */ - $phpbb_notifications = $phpbb_container->get('notification_manager'); - foreach ($notifications_data as $subscription) - { - $phpbb_notifications->add_subscription($subscription['item_type'], 0, $subscription['method'], $user_id); - } - } - - /** - * Event that returns user id, user details and user CPF of newly registered user - * - * @event core.user_add_after - * @var int user_id User id of newly registered user - * @var array user_row Array of user details submitted to user_add - * @var array cp_data Array of Custom profile fields submitted to user_add - * @since 3.1.0-b5 - */ - $vars = array('user_id', 'user_row', 'cp_data'); - extract($phpbb_dispatcher->trigger_event('core.user_add_after', compact($vars))); - - return $user_id; -} - -/** - * Remove User - * - * @param string $mode Either 'retain' or 'remove' - * @param mixed $user_ids Either an array of integers or an integer - * @param bool $retain_username - * @return bool - */ -function user_delete($mode, $user_ids, $retain_username = true) -{ - global $cache, $config, $db, $user, $phpbb_dispatcher, $phpbb_container; - global $phpbb_root_path, $phpEx; - - $db->sql_transaction('begin'); - - $user_rows = array(); - if (!is_array($user_ids)) - { - $user_ids = array($user_ids); - } - - $user_id_sql = $db->sql_in_set('user_id', $user_ids); - - $sql = 'SELECT * - FROM ' . USERS_TABLE . ' - WHERE ' . $user_id_sql; - $result = $db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) - { - $user_rows[(int) $row['user_id']] = $row; - } - $db->sql_freeresult($result); - - if (empty($user_rows)) - { - return false; - } - - /** - * Event before a user is deleted - * - * @event core.delete_user_before - * @var string mode Mode of deletion (retain/delete posts) - * @var array user_ids IDs of the deleted user - * @var mixed retain_username True if username should be retained - * or false if not - * @var array user_rows Array containing data of the deleted users - * @since 3.1.0-a1 - * @changed 3.2.4-RC1 Added user_rows - */ - $vars = array('mode', 'user_ids', 'retain_username', 'user_rows'); - extract($phpbb_dispatcher->trigger_event('core.delete_user_before', compact($vars))); - - // Before we begin, we will remove the reports the user issued. - $sql = 'SELECT r.post_id, p.topic_id - FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . ' p - WHERE ' . $db->sql_in_set('r.user_id', $user_ids) . ' - AND p.post_id = r.post_id'; - $result = $db->sql_query($sql); - - $report_posts = $report_topics = array(); - while ($row = $db->sql_fetchrow($result)) - { - $report_posts[] = $row['post_id']; - $report_topics[] = $row['topic_id']; - } - $db->sql_freeresult($result); - - if (count($report_posts)) - { - $report_posts = array_unique($report_posts); - $report_topics = array_unique($report_topics); - - // Get a list of topics that still contain reported posts - $sql = 'SELECT DISTINCT topic_id - FROM ' . POSTS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', $report_topics) . ' - AND post_reported = 1 - AND ' . $db->sql_in_set('post_id', $report_posts, true); - $result = $db->sql_query($sql); - - $keep_report_topics = array(); - while ($row = $db->sql_fetchrow($result)) - { - $keep_report_topics[] = $row['topic_id']; - } - $db->sql_freeresult($result); - - if (count($keep_report_topics)) - { - $report_topics = array_diff($report_topics, $keep_report_topics); - } - unset($keep_report_topics); - - // Now set the flags back - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET post_reported = 0 - WHERE ' . $db->sql_in_set('post_id', $report_posts); - $db->sql_query($sql); - - if (count($report_topics)) - { - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_reported = 0 - WHERE ' . $db->sql_in_set('topic_id', $report_topics); - $db->sql_query($sql); - } - } - - // Remove reports - $db->sql_query('DELETE FROM ' . REPORTS_TABLE . ' WHERE ' . $user_id_sql); - - $num_users_delta = 0; - - // Get auth provider collection in case accounts might need to be unlinked - $provider_collection = $phpbb_container->get('auth.provider_collection'); - - // Some things need to be done in the loop (if the query changes based - // on which user is currently being deleted) - $added_guest_posts = 0; - foreach ($user_rows as $user_id => $user_row) - { - if ($user_row['user_avatar'] && $user_row['user_avatar_type'] == 'avatar.driver.upload') - { - avatar_delete('user', $user_row); - } - - // Unlink accounts - foreach ($provider_collection as $provider_name => $auth_provider) - { - $provider_data = $auth_provider->get_auth_link_data($user_id); - - if ($provider_data !== null) - { - $link_data = array( - 'user_id' => $user_id, - 'link_method' => 'user_delete', - ); - - // BLOCK_VARS might contain hidden fields necessary for unlinking accounts - if (isset($provider_data['BLOCK_VARS']) && is_array($provider_data['BLOCK_VARS'])) - { - foreach ($provider_data['BLOCK_VARS'] as $provider_service) - { - if (!array_key_exists('HIDDEN_FIELDS', $provider_service)) - { - $provider_service['HIDDEN_FIELDS'] = array(); - } - - $auth_provider->unlink_account(array_merge($link_data, $provider_service['HIDDEN_FIELDS'])); - } - } - else - { - $auth_provider->unlink_account($link_data); - } - } - } - - // Decrement number of users if this user is active - if ($user_row['user_type'] != USER_INACTIVE && $user_row['user_type'] != USER_IGNORE) - { - --$num_users_delta; - } - - switch ($mode) - { - case 'retain': - if ($retain_username === false) - { - $post_username = $user->lang['GUEST']; - } - else - { - $post_username = $user_row['username']; - } - - // If the user is inactive and newly registered - // we assume no posts from the user, and save - // the queries - if ($user_row['user_type'] != USER_INACTIVE || $user_row['user_inactive_reason'] != INACTIVE_REGISTER || $user_row['user_posts']) - { - // When we delete these users and retain the posts, we must assign all the data to the guest user - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET forum_last_poster_id = ' . ANONYMOUS . ", forum_last_poster_name = '" . $db->sql_escape($post_username) . "', forum_last_poster_colour = '' - WHERE forum_last_poster_id = $user_id"; - $db->sql_query($sql); - - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET poster_id = ' . ANONYMOUS . ", post_username = '" . $db->sql_escape($post_username) . "' - WHERE poster_id = $user_id"; - $db->sql_query($sql); - - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_poster = ' . ANONYMOUS . ", topic_first_poster_name = '" . $db->sql_escape($post_username) . "', topic_first_poster_colour = '' - WHERE topic_poster = $user_id"; - $db->sql_query($sql); - - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_last_poster_id = ' . ANONYMOUS . ", topic_last_poster_name = '" . $db->sql_escape($post_username) . "', topic_last_poster_colour = '' - WHERE topic_last_poster_id = $user_id"; - $db->sql_query($sql); - - // Since we change every post by this author, we need to count this amount towards the anonymous user - - if ($user_row['user_posts']) - { - $added_guest_posts += $user_row['user_posts']; - } - } - break; - - case 'remove': - // there is nothing variant specific to deleting posts - break; - } - } - - if ($num_users_delta != 0) - { - $config->increment('num_users', $num_users_delta, false); - } - - // Now do the invariant tasks - // all queries performed in one call of this function are in a single transaction - // so this is kosher - if ($mode == 'retain') - { - // Assign more data to the Anonymous user - $sql = 'UPDATE ' . ATTACHMENTS_TABLE . ' - SET poster_id = ' . ANONYMOUS . ' - WHERE ' . $db->sql_in_set('poster_id', $user_ids); - $db->sql_query($sql); - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_posts = user_posts + ' . $added_guest_posts . ' - WHERE user_id = ' . ANONYMOUS; - $db->sql_query($sql); - } - else if ($mode == 'remove') - { - if (!function_exists('delete_posts')) - { - include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); - } - - // Delete posts, attachments, etc. - // delete_posts can handle any number of IDs in its second argument - delete_posts('poster_id', $user_ids); - } - - $table_ary = [ - USERS_TABLE, - USER_GROUP_TABLE, - TOPICS_WATCH_TABLE, - FORUMS_WATCH_TABLE, - ACL_USERS_TABLE, - TOPICS_TRACK_TABLE, - TOPICS_POSTED_TABLE, - FORUMS_TRACK_TABLE, - PROFILE_FIELDS_DATA_TABLE, - MODERATOR_CACHE_TABLE, - DRAFTS_TABLE, - BOOKMARKS_TABLE, - SESSIONS_KEYS_TABLE, - PRIVMSGS_FOLDER_TABLE, - PRIVMSGS_RULES_TABLE, - $phpbb_container->getParameter('tables.auth_provider_oauth_token_storage'), - $phpbb_container->getParameter('tables.auth_provider_oauth_states'), - $phpbb_container->getParameter('tables.auth_provider_oauth_account_assoc'), - $phpbb_container->getParameter('tables.user_notifications') - ]; - - // Ignore errors on deleting from non-existent tables, e.g. when migrating - $db->sql_return_on_error(true); - // Delete the miscellaneous (non-post) data for the user - foreach ($table_ary as $table) - { - $sql = "DELETE FROM $table - WHERE " . $user_id_sql; - $db->sql_query($sql); - } - $db->sql_return_on_error(); - - $cache->destroy('sql', MODERATOR_CACHE_TABLE); - - // Change user_id to anonymous for posts edited by this user - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET post_edit_user = ' . ANONYMOUS . ' - WHERE ' . $db->sql_in_set('post_edit_user', $user_ids); - $db->sql_query($sql); - - // Change user_id to anonymous for pms edited by this user - $sql = 'UPDATE ' . PRIVMSGS_TABLE . ' - SET message_edit_user = ' . ANONYMOUS . ' - WHERE ' . $db->sql_in_set('message_edit_user', $user_ids); - $db->sql_query($sql); - - // Change user_id to anonymous for posts deleted by this user - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET post_delete_user = ' . ANONYMOUS . ' - WHERE ' . $db->sql_in_set('post_delete_user', $user_ids); - $db->sql_query($sql); - - // Change user_id to anonymous for topics deleted by this user - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_delete_user = ' . ANONYMOUS . ' - WHERE ' . $db->sql_in_set('topic_delete_user', $user_ids); - $db->sql_query($sql); - - // Delete user log entries about this user - $sql = 'DELETE FROM ' . LOG_TABLE . ' - WHERE ' . $db->sql_in_set('reportee_id', $user_ids); - $db->sql_query($sql); - - // Change user_id to anonymous for this users triggered events - $sql = 'UPDATE ' . LOG_TABLE . ' - SET user_id = ' . ANONYMOUS . ' - WHERE ' . $user_id_sql; - $db->sql_query($sql); - - // Delete the user_id from the zebra table - $sql = 'DELETE FROM ' . ZEBRA_TABLE . ' - WHERE ' . $user_id_sql . ' - OR ' . $db->sql_in_set('zebra_id', $user_ids); - $db->sql_query($sql); - - // Delete the user_id from the banlist - $sql = 'DELETE FROM ' . BANLIST_TABLE . ' - WHERE ' . $db->sql_in_set('ban_userid', $user_ids); - $db->sql_query($sql); - - // Delete the user_id from the session table - $sql = 'DELETE FROM ' . SESSIONS_TABLE . ' - WHERE ' . $db->sql_in_set('session_user_id', $user_ids); - $db->sql_query($sql); - - // Clean the private messages tables from the user - if (!function_exists('phpbb_delete_user_pms')) - { - include($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx); - } - phpbb_delete_users_pms($user_ids); - - $phpbb_notifications = $phpbb_container->get('notification_manager'); - $phpbb_notifications->delete_notifications('notification.type.admin_activate_user', $user_ids); - - $db->sql_transaction('commit'); - - /** - * Event after a user is deleted - * - * @event core.delete_user_after - * @var string mode Mode of deletion (retain/delete posts) - * @var array user_ids IDs of the deleted user - * @var mixed retain_username True if username should be retained - * or false if not - * @var array user_rows Array containing data of the deleted users - * @since 3.1.0-a1 - * @changed 3.2.2-RC1 Added user_rows - */ - $vars = array('mode', 'user_ids', 'retain_username', 'user_rows'); - extract($phpbb_dispatcher->trigger_event('core.delete_user_after', compact($vars))); - - // Reset newest user info if appropriate - if (in_array($config['newest_user_id'], $user_ids)) - { - update_last_username(); - } - - return false; -} - -/** -* Flips user_type from active to inactive and vice versa, handles group membership updates -* -* @param string $mode can be flip for flipping from active/inactive, activate or deactivate -*/ -function user_active_flip($mode, $user_id_ary, $reason = INACTIVE_MANUAL) -{ - global $config, $db, $user, $auth, $phpbb_dispatcher; - - $deactivated = $activated = 0; - $sql_statements = array(); - - if (!is_array($user_id_ary)) - { - $user_id_ary = array($user_id_ary); - } - - if (!count($user_id_ary)) - { - return; - } - - $sql = 'SELECT user_id, group_id, user_type, user_inactive_reason - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('user_id', $user_id_ary); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $sql_ary = array(); - - if ($row['user_type'] == USER_IGNORE || $row['user_type'] == USER_FOUNDER || - ($mode == 'activate' && $row['user_type'] != USER_INACTIVE) || - ($mode == 'deactivate' && $row['user_type'] == USER_INACTIVE)) - { - continue; - } - - if ($row['user_type'] == USER_INACTIVE) - { - $activated++; - } - else - { - $deactivated++; - - // Remove the users session key... - $user->reset_login_keys($row['user_id']); - } - - $sql_ary += array( - 'user_type' => ($row['user_type'] == USER_NORMAL) ? USER_INACTIVE : USER_NORMAL, - 'user_inactive_time' => ($row['user_type'] == USER_NORMAL) ? time() : 0, - 'user_inactive_reason' => ($row['user_type'] == USER_NORMAL) ? $reason : 0, - ); - - $sql_statements[$row['user_id']] = $sql_ary; - } - $db->sql_freeresult($result); - - /** - * Check or modify activated/deactivated users data before submitting it to the database - * - * @event core.user_active_flip_before - * @var string mode User type changing mode, can be: flip|activate|deactivate - * @var int reason Reason for changing user type, can be: INACTIVE_REGISTER|INACTIVE_PROFILE|INACTIVE_MANUAL|INACTIVE_REMIND - * @var int activated The number of users to be activated - * @var int deactivated The number of users to be deactivated - * @var array user_id_ary Array with user ids to change user type - * @var array sql_statements Array with users data to submit to the database, keys: user ids, values: arrays with user data - * @since 3.1.4-RC1 - */ - $vars = array('mode', 'reason', 'activated', 'deactivated', 'user_id_ary', 'sql_statements'); - extract($phpbb_dispatcher->trigger_event('core.user_active_flip_before', compact($vars))); - - if (count($sql_statements)) - { - foreach ($sql_statements as $user_id => $sql_ary) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE user_id = ' . $user_id; - $db->sql_query($sql); - } - - $auth->acl_clear_prefetch(array_keys($sql_statements)); - } - - /** - * Perform additional actions after the users have been activated/deactivated - * - * @event core.user_active_flip_after - * @var string mode User type changing mode, can be: flip|activate|deactivate - * @var int reason Reason for changing user type, can be: INACTIVE_REGISTER|INACTIVE_PROFILE|INACTIVE_MANUAL|INACTIVE_REMIND - * @var int activated The number of users to be activated - * @var int deactivated The number of users to be deactivated - * @var array user_id_ary Array with user ids to change user type - * @var array sql_statements Array with users data to submit to the database, keys: user ids, values: arrays with user data - * @since 3.1.4-RC1 - */ - $vars = array('mode', 'reason', 'activated', 'deactivated', 'user_id_ary', 'sql_statements'); - extract($phpbb_dispatcher->trigger_event('core.user_active_flip_after', compact($vars))); - - if ($deactivated) - { - $config->increment('num_users', $deactivated * (-1), false); - } - - if ($activated) - { - $config->increment('num_users', $activated, false); - } - - // Update latest username - update_last_username(); -} - -/** -* Add a ban or ban exclusion to the banlist. Bans either a user, an IP or an email address -* -* @param string $mode Type of ban. One of the following: user, ip, email -* @param mixed $ban Banned entity. Either string or array with usernames, ips or email addresses -* @param int $ban_len Ban length in minutes -* @param string $ban_len_other Ban length as a date (YYYY-MM-DD) -* @param boolean $ban_exclude Exclude these entities from banning? -* @param string $ban_reason String describing the reason for this ban -* @return boolean -*/ -function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reason, $ban_give_reason = '') -{ - global $db, $user, $cache, $phpbb_log; - - // Delete stale bans - $sql = 'DELETE FROM ' . BANLIST_TABLE . ' - WHERE ban_end < ' . time() . ' - AND ban_end <> 0'; - $db->sql_query($sql); - - $ban_list = (!is_array($ban)) ? array_unique(explode("\n", $ban)) : $ban; - $ban_list_log = implode(', ', $ban_list); - - $current_time = time(); - - // Set $ban_end to the unix time when the ban should end. 0 is a permanent ban. - if ($ban_len) - { - if ($ban_len != -1 || !$ban_len_other) - { - $ban_end = max($current_time, $current_time + ($ban_len) * 60); - } - else - { - $ban_other = explode('-', $ban_len_other); - if (count($ban_other) == 3 && ((int) $ban_other[0] < 9999) && - (strlen($ban_other[0]) == 4) && (strlen($ban_other[1]) == 2) && (strlen($ban_other[2]) == 2)) - { - $ban_end = max($current_time, $user->create_datetime() - ->setDate((int) $ban_other[0], (int) $ban_other[1], (int) $ban_other[2]) - ->setTime(0, 0, 0) - ->getTimestamp() + $user->timezone->getOffset(new DateTime('UTC'))); - } - else - { - trigger_error('LENGTH_BAN_INVALID', E_USER_WARNING); - } - } - } - else - { - $ban_end = 0; - } - - $founder = $founder_names = array(); - - if (!$ban_exclude) - { - // Create a list of founder... - $sql = 'SELECT user_id, user_email, username_clean - FROM ' . USERS_TABLE . ' - WHERE user_type = ' . USER_FOUNDER; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $founder[$row['user_id']] = $row['user_email']; - $founder_names[$row['user_id']] = $row['username_clean']; - } - $db->sql_freeresult($result); - } - - $banlist_ary = array(); - - switch ($mode) - { - case 'user': - $type = 'ban_userid'; - - // At the moment we do not support wildcard username banning - - // Select the relevant user_ids. - $sql_usernames = array(); - - foreach ($ban_list as $username) - { - $username = trim($username); - if ($username != '') - { - $clean_name = utf8_clean_string($username); - if ($clean_name == $user->data['username_clean']) - { - trigger_error('CANNOT_BAN_YOURSELF', E_USER_WARNING); - } - if (in_array($clean_name, $founder_names)) - { - trigger_error('CANNOT_BAN_FOUNDER', E_USER_WARNING); - } - $sql_usernames[] = $clean_name; - } - } - - // Make sure we have been given someone to ban - if (!count($sql_usernames)) - { - trigger_error('NO_USER_SPECIFIED', E_USER_WARNING); - } - - $sql = 'SELECT user_id - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('username_clean', $sql_usernames); - - // Do not allow banning yourself, the guest account, or founders. - $non_bannable = array($user->data['user_id'], ANONYMOUS); - if (count($founder)) - { - $sql .= ' AND ' . $db->sql_in_set('user_id', array_merge(array_keys($founder), $non_bannable), true); - } - else - { - $sql .= ' AND ' . $db->sql_in_set('user_id', $non_bannable, true); - } - - $result = $db->sql_query($sql); - - if ($row = $db->sql_fetchrow($result)) - { - do - { - $banlist_ary[] = (int) $row['user_id']; - } - while ($row = $db->sql_fetchrow($result)); - } - else - { - $db->sql_freeresult($result); - trigger_error('NO_USERS', E_USER_WARNING); - } - $db->sql_freeresult($result); - break; - - case 'ip': - $type = 'ban_ip'; - - foreach ($ban_list as $ban_item) - { - if (preg_match('#^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})[ ]*\-[ ]*([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$#', trim($ban_item), $ip_range_explode)) - { - // This is an IP range - // Don't ask about all this, just don't ask ... ! - $ip_1_counter = $ip_range_explode[1]; - $ip_1_end = $ip_range_explode[5]; - - while ($ip_1_counter <= $ip_1_end) - { - $ip_2_counter = ($ip_1_counter == $ip_range_explode[1]) ? $ip_range_explode[2] : 0; - $ip_2_end = ($ip_1_counter < $ip_1_end) ? 254 : $ip_range_explode[6]; - - if ($ip_2_counter == 0 && $ip_2_end == 254) - { - $ip_2_counter = 256; - - $banlist_ary[] = "$ip_1_counter.*"; - } - - while ($ip_2_counter <= $ip_2_end) - { - $ip_3_counter = ($ip_2_counter == $ip_range_explode[2] && $ip_1_counter == $ip_range_explode[1]) ? $ip_range_explode[3] : 0; - $ip_3_end = ($ip_2_counter < $ip_2_end || $ip_1_counter < $ip_1_end) ? 254 : $ip_range_explode[7]; - - if ($ip_3_counter == 0 && $ip_3_end == 254) - { - $ip_3_counter = 256; - - $banlist_ary[] = "$ip_1_counter.$ip_2_counter.*"; - } - - while ($ip_3_counter <= $ip_3_end) - { - $ip_4_counter = ($ip_3_counter == $ip_range_explode[3] && $ip_2_counter == $ip_range_explode[2] && $ip_1_counter == $ip_range_explode[1]) ? $ip_range_explode[4] : 0; - $ip_4_end = ($ip_3_counter < $ip_3_end || $ip_2_counter < $ip_2_end) ? 254 : $ip_range_explode[8]; - - if ($ip_4_counter == 0 && $ip_4_end == 254) - { - $ip_4_counter = 256; - - $banlist_ary[] = "$ip_1_counter.$ip_2_counter.$ip_3_counter.*"; - } - - while ($ip_4_counter <= $ip_4_end) - { - $banlist_ary[] = "$ip_1_counter.$ip_2_counter.$ip_3_counter.$ip_4_counter"; - $ip_4_counter++; - } - $ip_3_counter++; - } - $ip_2_counter++; - } - $ip_1_counter++; - } - } - else if (preg_match('#^([0-9]{1,3})\.([0-9\*]{1,3})\.([0-9\*]{1,3})\.([0-9\*]{1,3})$#', trim($ban_item)) || preg_match('#^[a-f0-9:]+\*?$#i', trim($ban_item))) - { - // Normal IP address - $banlist_ary[] = trim($ban_item); - } - else if (preg_match('#^\*$#', trim($ban_item))) - { - // Ban all IPs - $banlist_ary[] = '*'; - } - else if (preg_match('#^([\w\-_]\.?){2,}$#is', trim($ban_item))) - { - // hostname - $ip_ary = gethostbynamel(trim($ban_item)); - - if (!empty($ip_ary)) - { - foreach ($ip_ary as $ip) - { - if ($ip) - { - if (strlen($ip) > 40) - { - continue; - } - - $banlist_ary[] = $ip; - } - } - } - } - - if (empty($banlist_ary)) - { - trigger_error('NO_IPS_DEFINED', E_USER_WARNING); - } - } - break; - - case 'email': - $type = 'ban_email'; - - foreach ($ban_list as $ban_item) - { - $ban_item = trim($ban_item); - - if (preg_match('#^.*?@*|(([a-z0-9\-]+\.)+([a-z]{2,3}))$#i', $ban_item)) - { - if (strlen($ban_item) > 100) - { - continue; - } - - if (!count($founder) || !in_array($ban_item, $founder)) - { - $banlist_ary[] = $ban_item; - } - } - } - - if (count($ban_list) == 0) - { - trigger_error('NO_EMAILS_DEFINED', E_USER_WARNING); - } - break; - - default: - trigger_error('NO_MODE', E_USER_WARNING); - break; - } - - // Fetch currently set bans of the specified type and exclude state. Prevent duplicate bans. - $sql_where = ($type == 'ban_userid') ? 'ban_userid <> 0' : "$type <> ''"; - - $sql = "SELECT $type - FROM " . BANLIST_TABLE . " - WHERE $sql_where - AND ban_exclude = " . (int) $ban_exclude; - $result = $db->sql_query($sql); - - // Reset $sql_where, because we use it later... - $sql_where = ''; - - if ($row = $db->sql_fetchrow($result)) - { - $banlist_ary_tmp = array(); - do - { - switch ($mode) - { - case 'user': - $banlist_ary_tmp[] = $row['ban_userid']; - break; - - case 'ip': - $banlist_ary_tmp[] = $row['ban_ip']; - break; - - case 'email': - $banlist_ary_tmp[] = $row['ban_email']; - break; - } - } - while ($row = $db->sql_fetchrow($result)); - - $banlist_ary_tmp = array_intersect($banlist_ary, $banlist_ary_tmp); - - if (count($banlist_ary_tmp)) - { - // One or more entities are already banned/excluded, delete the existing bans, so they can be re-inserted with the given new length - $sql = 'DELETE FROM ' . BANLIST_TABLE . ' - WHERE ' . $db->sql_in_set($type, $banlist_ary_tmp) . ' - AND ban_exclude = ' . (int) $ban_exclude; - $db->sql_query($sql); - } - - unset($banlist_ary_tmp); - } - $db->sql_freeresult($result); - - // We have some entities to ban - if (count($banlist_ary)) - { - $sql_ary = array(); - - foreach ($banlist_ary as $ban_entry) - { - $sql_ary[] = array( - $type => $ban_entry, - 'ban_start' => (int) $current_time, - 'ban_end' => (int) $ban_end, - 'ban_exclude' => (int) $ban_exclude, - 'ban_reason' => (string) $ban_reason, - 'ban_give_reason' => (string) $ban_give_reason, - ); - } - - $db->sql_multi_insert(BANLIST_TABLE, $sql_ary); - - // If we are banning we want to logout anyone matching the ban - if (!$ban_exclude) - { - switch ($mode) - { - case 'user': - $sql_where = 'WHERE ' . $db->sql_in_set('session_user_id', $banlist_ary); - break; - - case 'ip': - $sql_where = 'WHERE ' . $db->sql_in_set('session_ip', $banlist_ary); - break; - - case 'email': - $banlist_ary_sql = array(); - - foreach ($banlist_ary as $ban_entry) - { - $banlist_ary_sql[] = (string) str_replace('*', '%', $ban_entry); - } - - $sql = 'SELECT user_id - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('user_email', $banlist_ary_sql); - $result = $db->sql_query($sql); - - $sql_in = array(); - - if ($row = $db->sql_fetchrow($result)) - { - do - { - $sql_in[] = $row['user_id']; - } - while ($row = $db->sql_fetchrow($result)); - - $sql_where = 'WHERE ' . $db->sql_in_set('session_user_id', $sql_in); - } - $db->sql_freeresult($result); - break; - } - - if (isset($sql_where) && $sql_where) - { - $sql = 'DELETE FROM ' . SESSIONS_TABLE . " - $sql_where"; - $db->sql_query($sql); - - if ($mode == 'user') - { - $sql = 'DELETE FROM ' . SESSIONS_KEYS_TABLE . ' ' . ((in_array('*', $banlist_ary)) ? '' : 'WHERE ' . $db->sql_in_set('user_id', $banlist_ary)); - $db->sql_query($sql); - } - } - } - - // Update log - $log_entry = ($ban_exclude) ? 'LOG_BAN_EXCLUDE_' : 'LOG_BAN_'; - - // Add to admin log, moderator log and user notes - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, $log_entry . strtoupper($mode), false, array($ban_reason, $ban_list_log)); - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, $log_entry . strtoupper($mode), false, array( - 'forum_id' => 0, - 'topic_id' => 0, - $ban_reason, - $ban_list_log - )); - if ($mode == 'user') - { - foreach ($banlist_ary as $user_id) - { - $phpbb_log->add('user', $user->data['user_id'], $user->ip, $log_entry . strtoupper($mode), false, array( - 'reportee_id' => $user_id, - $ban_reason, - $ban_list_log - )); - } - } - - $cache->destroy('sql', BANLIST_TABLE); - - return true; - } - - // There was nothing to ban/exclude. But destroying the cache because of the removal of stale bans. - $cache->destroy('sql', BANLIST_TABLE); - - return false; -} - -/** -* Unban User -*/ -function user_unban($mode, $ban) -{ - global $db, $user, $cache, $phpbb_log, $phpbb_dispatcher; - - // Delete stale bans - $sql = 'DELETE FROM ' . BANLIST_TABLE . ' - WHERE ban_end < ' . time() . ' - AND ban_end <> 0'; - $db->sql_query($sql); - - if (!is_array($ban)) - { - $ban = array($ban); - } - - $unban_sql = array_map('intval', $ban); - - if (count($unban_sql)) - { - // Grab details of bans for logging information later - switch ($mode) - { - case 'user': - $sql = 'SELECT u.username AS unban_info, u.user_id - FROM ' . USERS_TABLE . ' u, ' . BANLIST_TABLE . ' b - WHERE ' . $db->sql_in_set('b.ban_id', $unban_sql) . ' - AND u.user_id = b.ban_userid'; - break; - - case 'email': - $sql = 'SELECT ban_email AS unban_info - FROM ' . BANLIST_TABLE . ' - WHERE ' . $db->sql_in_set('ban_id', $unban_sql); - break; - - case 'ip': - $sql = 'SELECT ban_ip AS unban_info - FROM ' . BANLIST_TABLE . ' - WHERE ' . $db->sql_in_set('ban_id', $unban_sql); - break; - } - $result = $db->sql_query($sql); - - $l_unban_list = ''; - $user_ids_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - $l_unban_list .= (($l_unban_list != '') ? ', ' : '') . $row['unban_info']; - if ($mode == 'user') - { - $user_ids_ary[] = $row['user_id']; - } - } - $db->sql_freeresult($result); - - $sql = 'DELETE FROM ' . BANLIST_TABLE . ' - WHERE ' . $db->sql_in_set('ban_id', $unban_sql); - $db->sql_query($sql); - - // Add to moderator log, admin log and user notes - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_UNBAN_' . strtoupper($mode), false, array($l_unban_list)); - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_UNBAN_' . strtoupper($mode), false, array( - 'forum_id' => 0, - 'topic_id' => 0, - $l_unban_list - )); - if ($mode == 'user') - { - foreach ($user_ids_ary as $user_id) - { - $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_UNBAN_' . strtoupper($mode), false, array( - 'reportee_id' => $user_id, - $l_unban_list - )); - } - } - - /** - * Use this event to perform actions after the unban has been performed - * - * @event core.user_unban - * @var string mode One of the following: user, ip, email - * @var array user_ids_ary Array with user_ids - * @since 3.1.11-RC1 - */ - $vars = array( - 'mode', - 'user_ids_ary', - ); - extract($phpbb_dispatcher->trigger_event('core.user_unban', compact($vars))); - } - - $cache->destroy('sql', BANLIST_TABLE); - - return false; -} - -/** -* Internet Protocol Address Whois -* RFC3912: WHOIS Protocol Specification -* -* @param string $ip Ip address, either IPv4 or IPv6. -* -* @return string Empty string if not a valid ip address. -* Otherwise make_clickable()'ed whois result. -*/ -function user_ipwhois($ip) -{ - if (empty($ip)) - { - return ''; - } - - if (!preg_match(get_preg_expression('ipv4'), $ip) && !preg_match(get_preg_expression('ipv6'), $ip)) - { - return ''; - } - - // IPv4 & IPv6 addresses - $whois_host = 'whois.arin.net.'; - - $ipwhois = ''; - - if (($fsk = @fsockopen($whois_host, 43))) - { - // CRLF as per RFC3912 - fputs($fsk, "$ip\r\n"); - while (!feof($fsk)) - { - $ipwhois .= fgets($fsk, 1024); - } - @fclose($fsk); - } - - $match = array(); - - // Test for referrals from $whois_host to other whois databases, roll on rwhois - if (preg_match('#ReferralServer:[\x20]*whois://(.+)#im', $ipwhois, $match)) - { - if (strpos($match[1], ':') !== false) - { - $pos = strrpos($match[1], ':'); - $server = substr($match[1], 0, $pos); - $port = (int) substr($match[1], $pos + 1); - unset($pos); - } - else - { - $server = $match[1]; - $port = 43; - } - - $buffer = ''; - - if (($fsk = @fsockopen($server, $port))) - { - fputs($fsk, "$ip\r\n"); - while (!feof($fsk)) - { - $buffer .= fgets($fsk, 1024); - } - @fclose($fsk); - } - - // Use the result from $whois_host if we don't get any result here - $ipwhois = (empty($buffer)) ? $ipwhois : $buffer; - } - - $ipwhois = htmlspecialchars($ipwhois); - - // Magic URL ;) - return trim(make_clickable($ipwhois, false, '')); -} - -/** -* Data validation ... used primarily but not exclusively by ucp modules -* -* "Master" function for validating a range of data types -*/ -function validate_data($data, $val_ary) -{ - global $user; - - $error = array(); - - foreach ($val_ary as $var => $val_seq) - { - if (!is_array($val_seq[0])) - { - $val_seq = array($val_seq); - } - - foreach ($val_seq as $validate) - { - $function = array_shift($validate); - array_unshift($validate, $data[$var]); - - if (is_array($function)) - { - $result = call_user_func_array(array($function[0], 'validate_' . $function[1]), $validate); - } - else - { - $function_prefix = (function_exists('phpbb_validate_' . $function)) ? 'phpbb_validate_' : 'validate_'; - $result = call_user_func_array($function_prefix . $function, $validate); - } - - if ($result) - { - // Since errors are checked later for their language file existence, we need to make sure custom errors are not adjusted. - $error[] = (empty($user->lang[$result . '_' . strtoupper($var)])) ? $result : $result . '_' . strtoupper($var); - } - } - } - - return $error; -} - -/** -* Validate String -* -* @return boolean|string Either false if validation succeeded or a string which will be used as the error message (with the variable name appended) -*/ -function validate_string($string, $optional = false, $min = 0, $max = 0) -{ - if (empty($string) && $optional) - { - return false; - } - - if ($min && utf8_strlen(htmlspecialchars_decode($string)) < $min) - { - return 'TOO_SHORT'; - } - else if ($max && utf8_strlen(htmlspecialchars_decode($string)) > $max) - { - return 'TOO_LONG'; - } - - return false; -} - -/** -* Validate Number -* -* @return boolean|string Either false if validation succeeded or a string which will be used as the error message (with the variable name appended) -*/ -function validate_num($num, $optional = false, $min = 0, $max = 1E99) -{ - if (empty($num) && $optional) - { - return false; - } - - if ($num < $min) - { - return 'TOO_SMALL'; - } - else if ($num > $max) - { - return 'TOO_LARGE'; - } - - return false; -} - -/** -* Validate Date -* @param String $string a date in the dd-mm-yyyy format -* @return boolean -*/ -function validate_date($date_string, $optional = false) -{ - $date = explode('-', $date_string); - if ((empty($date) || count($date) != 3) && $optional) - { - return false; - } - else if ($optional) - { - for ($field = 0; $field <= 1; $field++) - { - $date[$field] = (int) $date[$field]; - if (empty($date[$field])) - { - $date[$field] = 1; - } - } - $date[2] = (int) $date[2]; - // assume an arbitrary leap year - if (empty($date[2])) - { - $date[2] = 1980; - } - } - - if (count($date) != 3 || !checkdate($date[1], $date[0], $date[2])) - { - return 'INVALID'; - } - - return false; -} - - -/** -* Validate Match -* -* @return boolean|string Either false if validation succeeded or a string which will be used as the error message (with the variable name appended) -*/ -function validate_match($string, $optional = false, $match = '') -{ - if (empty($string) && $optional) - { - return false; - } - - if (empty($match)) - { - return false; - } - - if (!preg_match($match, $string)) - { - return 'WRONG_DATA'; - } - - return false; -} - -/** -* Validate Language Pack ISO Name -* -* Tests whether a language name is valid and installed -* -* @param string $lang_iso The language string to test -* -* @return bool|string Either false if validation succeeded or -* a string which will be used as the error message -* (with the variable name appended) -*/ -function validate_language_iso_name($lang_iso) -{ - global $db; - - $sql = 'SELECT lang_id - FROM ' . LANG_TABLE . " - WHERE lang_iso = '" . $db->sql_escape($lang_iso) . "'"; - $result = $db->sql_query($sql); - $lang_id = (int) $db->sql_fetchfield('lang_id'); - $db->sql_freeresult($result); - - return ($lang_id) ? false : 'WRONG_DATA'; -} - -/** -* Validate Timezone Name -* -* Tests whether a timezone name is valid -* -* @param string $timezone The timezone string to test -* -* @return bool|string Either false if validation succeeded or -* a string which will be used as the error message -* (with the variable name appended) -*/ -function phpbb_validate_timezone($timezone) -{ - return (in_array($timezone, phpbb_get_timezone_identifiers($timezone))) ? false : 'TIMEZONE_INVALID'; -} - -/*** - * Validate Username - * - * Check to see if the username has been taken, or if it is disallowed. - * Also checks if it includes the " character or the 4-bytes Unicode ones - * (aka emojis) which we don't allow in usernames. - * Used for registering, changing names, and posting anonymously with a username - * - * @param string $username The username to check - * @param string $allowed_username An allowed username, default being $user->data['username'] - * - * @return mixed Either false if validation succeeded or a string which will be - * used as the error message (with the variable name appended) - */ -function validate_username($username, $allowed_username = false) -{ - global $config, $db, $user, $cache; - - $clean_username = utf8_clean_string($username); - $allowed_username = ($allowed_username === false) ? $user->data['username_clean'] : utf8_clean_string($allowed_username); - - if ($allowed_username == $clean_username) - { - return false; - } - - // The very first check is for - // out-of-bounds characters that are currently - // not supported by utf8_bin in MySQL - if (preg_match('/[\x{10000}-\x{10FFFF}]/u', $username)) - { - return 'INVALID_EMOJIS'; - } - - // ... fast checks first. - if (strpos($username, '"') !== false || strpos($username, '"') !== false || empty($clean_username)) - { - return 'INVALID_CHARS'; - } - - switch ($config['allow_name_chars']) - { - case 'USERNAME_CHARS_ANY': - $regex = '.+'; - break; - - case 'USERNAME_ALPHA_ONLY': - $regex = '[A-Za-z0-9]+'; - break; - - case 'USERNAME_ALPHA_SPACERS': - $regex = '[A-Za-z0-9-[\]_+ ]+'; - break; - - case 'USERNAME_LETTER_NUM': - $regex = '[\p{Lu}\p{Ll}\p{N}]+'; - break; - - case 'USERNAME_LETTER_NUM_SPACERS': - $regex = '[-\]_+ [\p{Lu}\p{Ll}\p{N}]+'; - break; - - case 'USERNAME_ASCII': - default: - $regex = '[\x01-\x7F]+'; - break; - } - - if (!preg_match('#^' . $regex . '$#u', $username)) - { - return 'INVALID_CHARS'; - } - - $sql = 'SELECT username - FROM ' . USERS_TABLE . " - WHERE username_clean = '" . $db->sql_escape($clean_username) . "'"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - return 'USERNAME_TAKEN'; - } - - $sql = 'SELECT group_name - FROM ' . GROUPS_TABLE . " - WHERE LOWER(group_name) = '" . $db->sql_escape(utf8_strtolower($username)) . "'"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - return 'USERNAME_TAKEN'; - } - - $bad_usernames = $cache->obtain_disallowed_usernames(); - - foreach ($bad_usernames as $bad_username) - { - if (preg_match('#^' . $bad_username . '$#', $clean_username)) - { - return 'USERNAME_DISALLOWED'; - } - } - - return false; -} - -/** -* Check to see if the password meets the complexity settings -* -* @return boolean|string Either false if validation succeeded or a string which will be used as the error message (with the variable name appended) -*/ -function validate_password($password) -{ - global $config; - - if ($password === '' || $config['pass_complex'] === 'PASS_TYPE_ANY') - { - // Password empty or no password complexity required. - return false; - } - - $upp = '\p{Lu}'; - $low = '\p{Ll}'; - $num = '\p{N}'; - $sym = '[^\p{Lu}\p{Ll}\p{N}]'; - $chars = array(); - - switch ($config['pass_complex']) - { - // No break statements below ... - // We require strong passwords in case pass_complex is not set or is invalid - default: - - // Require mixed case letters, numbers and symbols - case 'PASS_TYPE_SYMBOL': - $chars[] = $sym; - - // Require mixed case letters and numbers - case 'PASS_TYPE_ALPHA': - $chars[] = $num; - - // Require mixed case letters - case 'PASS_TYPE_CASE': - $chars[] = $low; - $chars[] = $upp; - } - - foreach ($chars as $char) - { - if (!preg_match('#' . $char . '#u', $password)) - { - return 'INVALID_CHARS'; - } - } - - return false; -} - -/** -* Check to see if email address is a valid address and contains a MX record -* -* @param string $email The email to check -* -* @return mixed Either false if validation succeeded or a string which will be used as the error message (with the variable name appended) -*/ -function phpbb_validate_email($email, $config = null) -{ - if ($config === null) - { - global $config; - } - - $email = strtolower($email); - - if (!preg_match('/^' . get_preg_expression('email') . '$/i', $email)) - { - return 'EMAIL_INVALID'; - } - - // Check MX record. - // The idea for this is from reading the UseBB blog/announcement. :) - if ($config['email_check_mx']) - { - list(, $domain) = explode('@', $email); - - if (phpbb_checkdnsrr($domain, 'A') === false && phpbb_checkdnsrr($domain, 'MX') === false) - { - return 'DOMAIN_NO_MX_RECORD'; - } - } - - return false; -} - -/** -* Check to see if email address is banned or already present in the DB -* -* @param string $email The email to check -* @param string $allowed_email An allowed email, default being $user->data['user_email'] -* -* @return mixed Either false if validation succeeded or a string which will be used as the error message (with the variable name appended) -*/ -function validate_user_email($email, $allowed_email = false) -{ - global $config, $db, $user; - - $email = strtolower($email); - $allowed_email = ($allowed_email === false) ? strtolower($user->data['user_email']) : strtolower($allowed_email); - - if ($allowed_email == $email) - { - return false; - } - - $validate_email = phpbb_validate_email($email, $config); - if ($validate_email) - { - return $validate_email; - } - - if (($ban = $user->check_ban(false, false, $email, true)) !== false) - { - return ($ban === true) ? 'EMAIL_BANNED' : (!empty($ban['ban_give_reason']) ? $ban['ban_give_reason'] : $ban); - } - - if (!$config['allow_emailreuse']) - { - $sql = 'SELECT user_email_hash - FROM ' . USERS_TABLE . " - WHERE user_email_hash = " . $db->sql_escape(phpbb_email_hash($email)); - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - return 'EMAIL_TAKEN'; - } - } - - return false; -} - -/** -* Validate jabber address -* Taken from the jabber class within flyspray (see author notes) -* -* @author flyspray.org -*/ -function validate_jabber($jid) -{ - if (!$jid) - { - return false; - } - - $separator_pos = strpos($jid, '@'); - - if ($separator_pos === false) - { - return 'WRONG_DATA'; - } - - $username = substr($jid, 0, $separator_pos); - $realm = substr($jid, $separator_pos + 1); - - if (strlen($username) == 0 || strlen($realm) < 3) - { - return 'WRONG_DATA'; - } - - $arr = explode('.', $realm); - - if (count($arr) == 0) - { - return 'WRONG_DATA'; - } - - foreach ($arr as $part) - { - if (substr($part, 0, 1) == '-' || substr($part, -1, 1) == '-') - { - return 'WRONG_DATA'; - } - - if (!preg_match("@^[a-zA-Z0-9-.]+$@", $part)) - { - return 'WRONG_DATA'; - } - } - - $boundary = array(array(0, 127), array(192, 223), array(224, 239), array(240, 247), array(248, 251), array(252, 253)); - - // Prohibited Characters RFC3454 + RFC3920 - $prohibited = array( - // Table C.1.1 - array(0x0020, 0x0020), // SPACE - // Table C.1.2 - array(0x00A0, 0x00A0), // NO-BREAK SPACE - array(0x1680, 0x1680), // OGHAM SPACE MARK - array(0x2000, 0x2001), // EN QUAD - array(0x2001, 0x2001), // EM QUAD - array(0x2002, 0x2002), // EN SPACE - array(0x2003, 0x2003), // EM SPACE - array(0x2004, 0x2004), // THREE-PER-EM SPACE - array(0x2005, 0x2005), // FOUR-PER-EM SPACE - array(0x2006, 0x2006), // SIX-PER-EM SPACE - array(0x2007, 0x2007), // FIGURE SPACE - array(0x2008, 0x2008), // PUNCTUATION SPACE - array(0x2009, 0x2009), // THIN SPACE - array(0x200A, 0x200A), // HAIR SPACE - array(0x200B, 0x200B), // ZERO WIDTH SPACE - array(0x202F, 0x202F), // NARROW NO-BREAK SPACE - array(0x205F, 0x205F), // MEDIUM MATHEMATICAL SPACE - array(0x3000, 0x3000), // IDEOGRAPHIC SPACE - // Table C.2.1 - array(0x0000, 0x001F), // [CONTROL CHARACTERS] - array(0x007F, 0x007F), // DELETE - // Table C.2.2 - array(0x0080, 0x009F), // [CONTROL CHARACTERS] - array(0x06DD, 0x06DD), // ARABIC END OF AYAH - array(0x070F, 0x070F), // SYRIAC ABBREVIATION MARK - array(0x180E, 0x180E), // MONGOLIAN VOWEL SEPARATOR - array(0x200C, 0x200C), // ZERO WIDTH NON-JOINER - array(0x200D, 0x200D), // ZERO WIDTH JOINER - array(0x2028, 0x2028), // LINE SEPARATOR - array(0x2029, 0x2029), // PARAGRAPH SEPARATOR - array(0x2060, 0x2060), // WORD JOINER - array(0x2061, 0x2061), // FUNCTION APPLICATION - array(0x2062, 0x2062), // INVISIBLE TIMES - array(0x2063, 0x2063), // INVISIBLE SEPARATOR - array(0x206A, 0x206F), // [CONTROL CHARACTERS] - array(0xFEFF, 0xFEFF), // ZERO WIDTH NO-BREAK SPACE - array(0xFFF9, 0xFFFC), // [CONTROL CHARACTERS] - array(0x1D173, 0x1D17A), // [MUSICAL CONTROL CHARACTERS] - // Table C.3 - array(0xE000, 0xF8FF), // [PRIVATE USE, PLANE 0] - array(0xF0000, 0xFFFFD), // [PRIVATE USE, PLANE 15] - array(0x100000, 0x10FFFD), // [PRIVATE USE, PLANE 16] - // Table C.4 - array(0xFDD0, 0xFDEF), // [NONCHARACTER CODE POINTS] - array(0xFFFE, 0xFFFF), // [NONCHARACTER CODE POINTS] - array(0x1FFFE, 0x1FFFF), // [NONCHARACTER CODE POINTS] - array(0x2FFFE, 0x2FFFF), // [NONCHARACTER CODE POINTS] - array(0x3FFFE, 0x3FFFF), // [NONCHARACTER CODE POINTS] - array(0x4FFFE, 0x4FFFF), // [NONCHARACTER CODE POINTS] - array(0x5FFFE, 0x5FFFF), // [NONCHARACTER CODE POINTS] - array(0x6FFFE, 0x6FFFF), // [NONCHARACTER CODE POINTS] - array(0x7FFFE, 0x7FFFF), // [NONCHARACTER CODE POINTS] - array(0x8FFFE, 0x8FFFF), // [NONCHARACTER CODE POINTS] - array(0x9FFFE, 0x9FFFF), // [NONCHARACTER CODE POINTS] - array(0xAFFFE, 0xAFFFF), // [NONCHARACTER CODE POINTS] - array(0xBFFFE, 0xBFFFF), // [NONCHARACTER CODE POINTS] - array(0xCFFFE, 0xCFFFF), // [NONCHARACTER CODE POINTS] - array(0xDFFFE, 0xDFFFF), // [NONCHARACTER CODE POINTS] - array(0xEFFFE, 0xEFFFF), // [NONCHARACTER CODE POINTS] - array(0xFFFFE, 0xFFFFF), // [NONCHARACTER CODE POINTS] - array(0x10FFFE, 0x10FFFF), // [NONCHARACTER CODE POINTS] - // Table C.5 - array(0xD800, 0xDFFF), // [SURROGATE CODES] - // Table C.6 - array(0xFFF9, 0xFFF9), // INTERLINEAR ANNOTATION ANCHOR - array(0xFFFA, 0xFFFA), // INTERLINEAR ANNOTATION SEPARATOR - array(0xFFFB, 0xFFFB), // INTERLINEAR ANNOTATION TERMINATOR - array(0xFFFC, 0xFFFC), // OBJECT REPLACEMENT CHARACTER - array(0xFFFD, 0xFFFD), // REPLACEMENT CHARACTER - // Table C.7 - array(0x2FF0, 0x2FFB), // [IDEOGRAPHIC DESCRIPTION CHARACTERS] - // Table C.8 - array(0x0340, 0x0340), // COMBINING GRAVE TONE MARK - array(0x0341, 0x0341), // COMBINING ACUTE TONE MARK - array(0x200E, 0x200E), // LEFT-TO-RIGHT MARK - array(0x200F, 0x200F), // RIGHT-TO-LEFT MARK - array(0x202A, 0x202A), // LEFT-TO-RIGHT EMBEDDING - array(0x202B, 0x202B), // RIGHT-TO-LEFT EMBEDDING - array(0x202C, 0x202C), // POP DIRECTIONAL FORMATTING - array(0x202D, 0x202D), // LEFT-TO-RIGHT OVERRIDE - array(0x202E, 0x202E), // RIGHT-TO-LEFT OVERRIDE - array(0x206A, 0x206A), // INHIBIT SYMMETRIC SWAPPING - array(0x206B, 0x206B), // ACTIVATE SYMMETRIC SWAPPING - array(0x206C, 0x206C), // INHIBIT ARABIC FORM SHAPING - array(0x206D, 0x206D), // ACTIVATE ARABIC FORM SHAPING - array(0x206E, 0x206E), // NATIONAL DIGIT SHAPES - array(0x206F, 0x206F), // NOMINAL DIGIT SHAPES - // Table C.9 - array(0xE0001, 0xE0001), // LANGUAGE TAG - array(0xE0020, 0xE007F), // [TAGGING CHARACTERS] - // RFC3920 - array(0x22, 0x22), // " - array(0x26, 0x26), // & - array(0x27, 0x27), // ' - array(0x2F, 0x2F), // / - array(0x3A, 0x3A), // : - array(0x3C, 0x3C), // < - array(0x3E, 0x3E), // > - array(0x40, 0x40) // @ - ); - - $pos = 0; - $result = true; - - while ($pos < strlen($username)) - { - $len = $uni = 0; - for ($i = 0; $i <= 5; $i++) - { - if (ord($username[$pos]) >= $boundary[$i][0] && ord($username[$pos]) <= $boundary[$i][1]) - { - $len = $i + 1; - $uni = (ord($username[$pos]) - $boundary[$i][0]) * pow(2, $i * 6); - - for ($k = 1; $k < $len; $k++) - { - $uni += (ord($username[$pos + $k]) - 128) * pow(2, ($i - $k) * 6); - } - - break; - } - } - - if ($len == 0) - { - return 'WRONG_DATA'; - } - - foreach ($prohibited as $pval) - { - if ($uni >= $pval[0] && $uni <= $pval[1]) - { - $result = false; - break 2; - } - } - - $pos = $pos + $len; - } - - if (!$result) - { - return 'WRONG_DATA'; - } - - return false; -} - -/** -* Validate hex colour value -* -* @param string $colour The hex colour value -* @param bool $optional Whether the colour value is optional. True if an empty -* string will be accepted as correct input, false if not. -* @return bool|string Error message if colour value is incorrect, false if it -* fits the hex colour code -*/ -function phpbb_validate_hex_colour($colour, $optional = false) -{ - if ($colour === '') - { - return (($optional) ? false : 'WRONG_DATA'); - } - - if (!preg_match('/^([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/', $colour)) - { - return 'WRONG_DATA'; - } - - return false; -} - -/** -* Verifies whether a style ID corresponds to an active style. -* -* @param int $style_id The style_id of a style which should be checked if activated or not. -* @return boolean -*/ -function phpbb_style_is_active($style_id) -{ - global $db; - - $sql = 'SELECT style_active - FROM ' . STYLES_TABLE . ' - WHERE style_id = '. (int) $style_id; - $result = $db->sql_query($sql); - - $style_is_active = (bool) $db->sql_fetchfield('style_active'); - $db->sql_freeresult($result); - - return $style_is_active; -} - -/** -* Remove avatar -*/ -function avatar_delete($mode, $row, $clean_db = false) -{ - global $phpbb_root_path, $config; - - // Check if the users avatar is actually *not* a group avatar - if ($mode == 'user') - { - if (strpos($row['user_avatar'], 'g') === 0 || (((int) $row['user_avatar'] !== 0) && ((int) $row['user_avatar'] !== (int) $row['user_id']))) - { - return false; - } - } - - if ($clean_db) - { - avatar_remove_db($row[$mode . '_avatar']); - } - $filename = get_avatar_filename($row[$mode . '_avatar']); - - if (file_exists($phpbb_root_path . $config['avatar_path'] . '/' . $filename)) - { - @unlink($phpbb_root_path . $config['avatar_path'] . '/' . $filename); - return true; - } - - return false; -} - -/** -* Generates avatar filename from the database entry -*/ -function get_avatar_filename($avatar_entry) -{ - global $config; - - if ($avatar_entry[0] === 'g') - { - $avatar_group = true; - $avatar_entry = substr($avatar_entry, 1); - } - else - { - $avatar_group = false; - } - $ext = substr(strrchr($avatar_entry, '.'), 1); - $avatar_entry = intval($avatar_entry); - return $config['avatar_salt'] . '_' . (($avatar_group) ? 'g' : '') . $avatar_entry . '.' . $ext; -} - -/** -* Returns an explanation string with maximum avatar settings -* -* @return string -*/ -function phpbb_avatar_explanation_string() -{ - global $config, $user; - - return $user->lang(($config['avatar_filesize'] == 0) ? 'AVATAR_EXPLAIN_NO_FILESIZE' : 'AVATAR_EXPLAIN', - $user->lang('PIXELS', (int) $config['avatar_max_width']), - $user->lang('PIXELS', (int) $config['avatar_max_height']), - round($config['avatar_filesize'] / 1024)); -} - -// -// Usergroup functions -// - -/** -* Add or edit a group. If we're editing a group we only update user -* parameters such as rank, etc. if they are changed -*/ -function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow_desc_bbcode = false, $allow_desc_urls = false, $allow_desc_smilies = false) -{ - global $db, $user, $phpbb_container, $phpbb_log; - - /** @var \phpbb\group\helper $group_helper */ - $group_helper = $phpbb_container->get('group_helper'); - - $error = array(); - - // Attributes which also affect the users table - $user_attribute_ary = array('group_colour', 'group_rank', 'group_avatar', 'group_avatar_type', 'group_avatar_width', 'group_avatar_height'); - - // Check data. Limit group name length. - if (!utf8_strlen($name) || utf8_strlen($name) > 60) - { - $error[] = (!utf8_strlen($name)) ? $user->lang['GROUP_ERR_USERNAME'] : $user->lang['GROUP_ERR_USER_LONG']; - } - - $err = group_validate_groupname($group_id, $name); - if (!empty($err)) - { - $error[] = $user->lang[$err]; - } - - if (!in_array($type, array(GROUP_OPEN, GROUP_CLOSED, GROUP_HIDDEN, GROUP_SPECIAL, GROUP_FREE))) - { - $error[] = $user->lang['GROUP_ERR_TYPE']; - } - - $group_teampage = !empty($group_attributes['group_teampage']); - unset($group_attributes['group_teampage']); - - if (!count($error)) - { - $current_legend = \phpbb\groupposition\legend::GROUP_DISABLED; - $current_teampage = \phpbb\groupposition\teampage::GROUP_DISABLED; - - /* @var $legend \phpbb\groupposition\legend */ - $legend = $phpbb_container->get('groupposition.legend'); - - /* @var $teampage \phpbb\groupposition\teampage */ - $teampage = $phpbb_container->get('groupposition.teampage'); - - if ($group_id) - { - try - { - $current_legend = $legend->get_group_value($group_id); - $current_teampage = $teampage->get_group_value($group_id); - } - catch (\phpbb\groupposition\exception $exception) - { - trigger_error($user->lang($exception->getMessage())); - } - } - - if (!empty($group_attributes['group_legend'])) - { - if (($group_id && ($current_legend == \phpbb\groupposition\legend::GROUP_DISABLED)) || !$group_id) - { - // Old group currently not in the legend or new group, add at the end. - $group_attributes['group_legend'] = 1 + $legend->get_group_count(); - } - else - { - // Group stayes in the legend - $group_attributes['group_legend'] = $current_legend; - } - } - else if ($group_id && ($current_legend != \phpbb\groupposition\legend::GROUP_DISABLED)) - { - // Group is removed from the legend - try - { - $legend->delete_group($group_id, true); - } - catch (\phpbb\groupposition\exception $exception) - { - trigger_error($user->lang($exception->getMessage())); - } - $group_attributes['group_legend'] = \phpbb\groupposition\legend::GROUP_DISABLED; - } - else - { - $group_attributes['group_legend'] = \phpbb\groupposition\legend::GROUP_DISABLED; - } - - // Unset the objects, we don't need them anymore. - unset($legend); - - $user_ary = array(); - $sql_ary = array( - 'group_name' => (string) $name, - 'group_desc' => (string) $desc, - 'group_desc_uid' => '', - 'group_desc_bitfield' => '', - 'group_type' => (int) $type, - ); - - // Parse description - if ($desc) - { - generate_text_for_storage($sql_ary['group_desc'], $sql_ary['group_desc_uid'], $sql_ary['group_desc_bitfield'], $sql_ary['group_desc_options'], $allow_desc_bbcode, $allow_desc_urls, $allow_desc_smilies); - } - - if (count($group_attributes)) - { - // Merge them with $sql_ary to properly update the group - $sql_ary = array_merge($sql_ary, $group_attributes); - } - - // Setting the log message before we set the group id (if group gets added) - $log = ($group_id) ? 'LOG_GROUP_UPDATED' : 'LOG_GROUP_CREATED'; - - if ($group_id) - { - $sql = 'SELECT user_id - FROM ' . USERS_TABLE . ' - WHERE group_id = ' . $group_id; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $user_ary[] = $row['user_id']; - } - $db->sql_freeresult($result); - - if (isset($sql_ary['group_avatar'])) - { - remove_default_avatar($group_id, $user_ary); - } - - if (isset($sql_ary['group_rank'])) - { - remove_default_rank($group_id, $user_ary); - } - - $sql = 'UPDATE ' . GROUPS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " - WHERE group_id = $group_id"; - $db->sql_query($sql); - - // Since we may update the name too, we need to do this on other tables too... - $sql = 'UPDATE ' . MODERATOR_CACHE_TABLE . " - SET group_name = '" . $db->sql_escape($sql_ary['group_name']) . "' - WHERE group_id = $group_id"; - $db->sql_query($sql); - - // One special case is the group skip auth setting. If this was changed we need to purge permissions for this group - if (isset($group_attributes['group_skip_auth'])) - { - // Get users within this group... - $sql = 'SELECT user_id - FROM ' . USER_GROUP_TABLE . ' - WHERE group_id = ' . $group_id . ' - AND user_pending = 0'; - $result = $db->sql_query($sql); - - $user_id_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - $user_id_ary[] = $row['user_id']; - } - $db->sql_freeresult($result); - - if (!empty($user_id_ary)) - { - global $auth; - - // Clear permissions cache of relevant users - $auth->acl_clear_prefetch($user_id_ary); - } - } - } - else - { - $sql = 'INSERT INTO ' . GROUPS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); - $db->sql_query($sql); - } - - // Remove the group from the teampage, only if unselected and we are editing a group, - // which is currently displayed. - if (!$group_teampage && $group_id && $current_teampage != \phpbb\groupposition\teampage::GROUP_DISABLED) - { - try - { - $teampage->delete_group($group_id); - } - catch (\phpbb\groupposition\exception $exception) - { - trigger_error($user->lang($exception->getMessage())); - } - } - - if (!$group_id) - { - $group_id = $db->sql_nextid(); - - if (isset($sql_ary['group_avatar_type']) && $sql_ary['group_avatar_type'] == 'avatar.driver.upload') - { - group_correct_avatar($group_id, $sql_ary['group_avatar']); - } - } - - try - { - if ($group_teampage && $current_teampage == \phpbb\groupposition\teampage::GROUP_DISABLED) - { - $teampage->add_group($group_id); - } - - if ($group_teampage) - { - if ($current_teampage == \phpbb\groupposition\teampage::GROUP_DISABLED) - { - $teampage->add_group($group_id); - } - } - else if ($group_id && ($current_teampage != \phpbb\groupposition\teampage::GROUP_DISABLED)) - { - $teampage->delete_group($group_id); - } - } - catch (\phpbb\groupposition\exception $exception) - { - trigger_error($user->lang($exception->getMessage())); - } - unset($teampage); - - // Set user attributes - $sql_ary = array(); - if (count($group_attributes)) - { - // Go through the user attributes array, check if a group attribute matches it and then set it. ;) - foreach ($user_attribute_ary as $attribute) - { - if (!isset($group_attributes[$attribute])) - { - continue; - } - - // If we are about to set an avatar, we will not overwrite user avatars if no group avatar is set... - if (strpos($attribute, 'group_avatar') === 0 && !$group_attributes[$attribute]) - { - continue; - } - - $sql_ary[$attribute] = $group_attributes[$attribute]; - } - } - - if (count($sql_ary) && count($user_ary)) - { - group_set_user_default($group_id, $user_ary, $sql_ary); - } - - $name = $group_helper->get_name($name); - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, $log, false, array($name)); - - group_update_listings($group_id); - } - - return (count($error)) ? $error : false; -} - - -/** -* Changes a group avatar's filename to conform to the naming scheme -*/ -function group_correct_avatar($group_id, $old_entry) -{ - global $config, $db, $phpbb_root_path; - - $group_id = (int) $group_id; - $ext = substr(strrchr($old_entry, '.'), 1); - $old_filename = get_avatar_filename($old_entry); - $new_filename = $config['avatar_salt'] . "_g$group_id.$ext"; - $new_entry = 'g' . $group_id . '_' . substr(time(), -5) . ".$ext"; - - $avatar_path = $phpbb_root_path . $config['avatar_path']; - if (@rename($avatar_path . '/'. $old_filename, $avatar_path . '/' . $new_filename)) - { - $sql = 'UPDATE ' . GROUPS_TABLE . ' - SET group_avatar = \'' . $db->sql_escape($new_entry) . "' - WHERE group_id = $group_id"; - $db->sql_query($sql); - } -} - - -/** -* Remove avatar also for users not having the group as default -*/ -function avatar_remove_db($avatar_name) -{ - global $db; - - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_avatar = '', - user_avatar_type = '' - WHERE user_avatar = '" . $db->sql_escape($avatar_name) . '\''; - $db->sql_query($sql); -} - - -/** -* Group Delete -*/ -function group_delete($group_id, $group_name = false) -{ - global $db, $cache, $auth, $user, $phpbb_root_path, $phpEx, $phpbb_dispatcher, $phpbb_container, $phpbb_log; - - if (!$group_name) - { - $group_name = get_group_name($group_id); - } - - $start = 0; - - do - { - $user_id_ary = $username_ary = array(); - - // Batch query for group members, call group_user_del - $sql = 'SELECT u.user_id, u.username - FROM ' . USER_GROUP_TABLE . ' ug, ' . USERS_TABLE . " u - WHERE ug.group_id = $group_id - AND u.user_id = ug.user_id"; - $result = $db->sql_query_limit($sql, 200, $start); - - if ($row = $db->sql_fetchrow($result)) - { - do - { - $user_id_ary[] = $row['user_id']; - $username_ary[] = $row['username']; - - $start++; - } - while ($row = $db->sql_fetchrow($result)); - - group_user_del($group_id, $user_id_ary, $username_ary, $group_name); - } - else - { - $start = 0; - } - $db->sql_freeresult($result); - } - while ($start); - - // Delete group from legend and teampage - try - { - /* @var $legend \phpbb\groupposition\legend */ - $legend = $phpbb_container->get('groupposition.legend'); - $legend->delete_group($group_id); - unset($legend); - } - catch (\phpbb\groupposition\exception $exception) - { - // The group we want to delete does not exist. - // No reason to worry, we just continue the deleting process. - //trigger_error($user->lang($exception->getMessage())); - } - - try - { - /* @var $teampage \phpbb\groupposition\teampage */ - $teampage = $phpbb_container->get('groupposition.teampage'); - $teampage->delete_group($group_id); - unset($teampage); - } - catch (\phpbb\groupposition\exception $exception) - { - // The group we want to delete does not exist. - // No reason to worry, we just continue the deleting process. - //trigger_error($user->lang($exception->getMessage())); - } - - // Delete group - $sql = 'DELETE FROM ' . GROUPS_TABLE . " - WHERE group_id = $group_id"; - $db->sql_query($sql); - - // Delete auth entries from the groups table - $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . " - WHERE group_id = $group_id"; - $db->sql_query($sql); - - /** - * Event after a group is deleted - * - * @event core.delete_group_after - * @var int group_id ID of the deleted group - * @var string group_name Name of the deleted group - * @since 3.1.0-a1 - */ - $vars = array('group_id', 'group_name'); - extract($phpbb_dispatcher->trigger_event('core.delete_group_after', compact($vars))); - - // Re-cache moderators - if (!function_exists('phpbb_cache_moderators')) - { - include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); - } - - phpbb_cache_moderators($db, $cache, $auth); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_GROUP_DELETE', false, array($group_name)); - - // Return false - no error - return false; -} - -/** -* Add user(s) to group -* -* @return mixed false if no errors occurred, else the user lang string for the relevant error, for example 'NO_USER' -*/ -function group_user_add($group_id, $user_id_ary = false, $username_ary = false, $group_name = false, $default = false, $leader = 0, $pending = 0, $group_attributes = false) -{ - global $db, $auth, $user, $phpbb_container, $phpbb_log, $phpbb_dispatcher; - - // We need both username and user_id info - $result = user_get_id_name($user_id_ary, $username_ary); - - if (empty($user_id_ary) || $result !== false) - { - return 'NO_USER'; - } - - // Because the item that gets passed into the previous function is unset, the reference is lost and our original - // array is retained - so we know there's a problem if there's a different number of ids to usernames now. - if (count($user_id_ary) != count($username_ary)) - { - return 'GROUP_USERS_INVALID'; - } - - // Remove users who are already members of this group - $sql = 'SELECT user_id, group_leader - FROM ' . USER_GROUP_TABLE . ' - WHERE ' . $db->sql_in_set('user_id', $user_id_ary) . " - AND group_id = $group_id"; - $result = $db->sql_query($sql); - - $add_id_ary = $update_id_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - $add_id_ary[] = (int) $row['user_id']; - - if ($leader && !$row['group_leader']) - { - $update_id_ary[] = (int) $row['user_id']; - } - } - $db->sql_freeresult($result); - - // Do all the users exist in this group? - $add_id_ary = array_diff($user_id_ary, $add_id_ary); - - // If we have no users - if (!count($add_id_ary) && !count($update_id_ary)) - { - return 'GROUP_USERS_EXIST'; - } - - $db->sql_transaction('begin'); - - // Insert the new users - if (count($add_id_ary)) - { - $sql_ary = array(); - - foreach ($add_id_ary as $user_id) - { - $sql_ary[] = array( - 'user_id' => (int) $user_id, - 'group_id' => (int) $group_id, - 'group_leader' => (int) $leader, - 'user_pending' => (int) $pending, - ); - } - - $db->sql_multi_insert(USER_GROUP_TABLE, $sql_ary); - } - - if (count($update_id_ary)) - { - $sql = 'UPDATE ' . USER_GROUP_TABLE . ' - SET group_leader = 1 - WHERE ' . $db->sql_in_set('user_id', $update_id_ary) . " - AND group_id = $group_id"; - $db->sql_query($sql); - } - - if ($default) - { - group_user_attributes('default', $group_id, $user_id_ary, false, $group_name, $group_attributes); - } - - $db->sql_transaction('commit'); - - // Clear permissions cache of relevant users - $auth->acl_clear_prefetch($user_id_ary); - - /** - * Event after users are added to a group - * - * @event core.group_add_user_after - * @var int group_id ID of the group to which users are added - * @var string group_name Name of the group - * @var array user_id_ary IDs of the users which are added - * @var array username_ary names of the users which are added - * @var int pending Pending setting, 1 if user(s) added are pending - * @since 3.1.7-RC1 - */ - $vars = array( - 'group_id', - 'group_name', - 'user_id_ary', - 'username_ary', - 'pending', - ); - extract($phpbb_dispatcher->trigger_event('core.group_add_user_after', compact($vars))); - - if (!$group_name) - { - $group_name = get_group_name($group_id); - } - - $log = ($leader) ? 'LOG_MODS_ADDED' : (($pending) ? 'LOG_USERS_PENDING' : 'LOG_USERS_ADDED'); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, $log, false, array($group_name, implode(', ', $username_ary))); - - group_update_listings($group_id); - - if ($pending) - { - /* @var $phpbb_notifications \phpbb\notification\manager */ - $phpbb_notifications = $phpbb_container->get('notification_manager'); - - foreach ($add_id_ary as $user_id) - { - $phpbb_notifications->add_notifications('notification.type.group_request', array( - 'group_id' => $group_id, - 'user_id' => $user_id, - 'group_name' => $group_name, - )); - } - } - - // Return false - no error - return false; -} - -/** -* Remove a user/s from a given group. When we remove users we update their -* default group_id. We do this by examining which "special" groups they belong -* to. The selection is made based on a reasonable priority system -* -* @return false if no errors occurred, else the user lang string for the relevant error, for example 'NO_USER' -*/ -function group_user_del($group_id, $user_id_ary = false, $username_ary = false, $group_name = false, $log_action = true) -{ - global $db, $auth, $config, $user, $phpbb_dispatcher, $phpbb_container, $phpbb_log; - - if ($config['coppa_enable']) - { - $group_order = array('ADMINISTRATORS', 'GLOBAL_MODERATORS', 'NEWLY_REGISTERED', 'REGISTERED_COPPA', 'REGISTERED', 'BOTS', 'GUESTS'); - } - else - { - $group_order = array('ADMINISTRATORS', 'GLOBAL_MODERATORS', 'NEWLY_REGISTERED', 'REGISTERED', 'BOTS', 'GUESTS'); - } - - // We need both username and user_id info - $result = user_get_id_name($user_id_ary, $username_ary); - - if (empty($user_id_ary) || $result !== false) - { - return 'NO_USER'; - } - - $sql = 'SELECT * - FROM ' . GROUPS_TABLE . ' - WHERE ' . $db->sql_in_set('group_name', $group_order); - $result = $db->sql_query($sql); - - $group_order_id = $special_group_data = array(); - while ($row = $db->sql_fetchrow($result)) - { - $group_order_id[$row['group_name']] = $row['group_id']; - - $special_group_data[$row['group_id']] = array( - 'group_colour' => $row['group_colour'], - 'group_rank' => $row['group_rank'], - ); - - // Only set the group avatar if one is defined... - if ($row['group_avatar']) - { - $special_group_data[$row['group_id']] = array_merge($special_group_data[$row['group_id']], array( - 'group_avatar' => $row['group_avatar'], - 'group_avatar_type' => $row['group_avatar_type'], - 'group_avatar_width' => $row['group_avatar_width'], - 'group_avatar_height' => $row['group_avatar_height']) - ); - } - } - $db->sql_freeresult($result); - - // Get users default groups - we only need to reset default group membership if the group from which the user gets removed is set as default - $sql = 'SELECT user_id, group_id - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('user_id', $user_id_ary); - $result = $db->sql_query($sql); - - $default_groups = array(); - while ($row = $db->sql_fetchrow($result)) - { - $default_groups[$row['user_id']] = $row['group_id']; - } - $db->sql_freeresult($result); - - // What special group memberships exist for these users? - $sql = 'SELECT g.group_id, g.group_name, ug.user_id - FROM ' . USER_GROUP_TABLE . ' ug, ' . GROUPS_TABLE . ' g - WHERE ' . $db->sql_in_set('ug.user_id', $user_id_ary) . " - AND g.group_id = ug.group_id - AND g.group_id <> $group_id - AND g.group_type = " . GROUP_SPECIAL . ' - ORDER BY ug.user_id, g.group_id'; - $result = $db->sql_query($sql); - - $temp_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - if ($default_groups[$row['user_id']] == $group_id && (!isset($temp_ary[$row['user_id']]) || $group_order_id[$row['group_name']] < $temp_ary[$row['user_id']])) - { - $temp_ary[$row['user_id']] = $row['group_id']; - } - } - $db->sql_freeresult($result); - - // sql_where_ary holds the new default groups and their users - $sql_where_ary = array(); - foreach ($temp_ary as $uid => $gid) - { - $sql_where_ary[$gid][] = $uid; - } - unset($temp_ary); - - foreach ($special_group_data as $gid => $default_data_ary) - { - if (isset($sql_where_ary[$gid]) && count($sql_where_ary[$gid])) - { - remove_default_rank($group_id, $sql_where_ary[$gid]); - remove_default_avatar($group_id, $sql_where_ary[$gid]); - group_set_user_default($gid, $sql_where_ary[$gid], $default_data_ary); - } - } - unset($special_group_data); - - /** - * Event before users are removed from a group - * - * @event core.group_delete_user_before - * @var int group_id ID of the group from which users are deleted - * @var string group_name Name of the group - * @var array user_id_ary IDs of the users which are removed - * @var array username_ary names of the users which are removed - * @since 3.1.0-a1 - */ - $vars = array('group_id', 'group_name', 'user_id_ary', 'username_ary'); - extract($phpbb_dispatcher->trigger_event('core.group_delete_user_before', compact($vars))); - - $sql = 'DELETE FROM ' . USER_GROUP_TABLE . " - WHERE group_id = $group_id - AND " . $db->sql_in_set('user_id', $user_id_ary); - $db->sql_query($sql); - - // Clear permissions cache of relevant users - $auth->acl_clear_prefetch($user_id_ary); - - /** - * Event after users are removed from a group - * - * @event core.group_delete_user_after - * @var int group_id ID of the group from which users are deleted - * @var string group_name Name of the group - * @var array user_id_ary IDs of the users which are removed - * @var array username_ary names of the users which are removed - * @since 3.1.7-RC1 - */ - $vars = array('group_id', 'group_name', 'user_id_ary', 'username_ary'); - extract($phpbb_dispatcher->trigger_event('core.group_delete_user_after', compact($vars))); - - if ($log_action) - { - if (!$group_name) - { - $group_name = get_group_name($group_id); - } - - $log = 'LOG_GROUP_REMOVE'; - - if ($group_name) - { - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, $log, false, array($group_name, implode(', ', $username_ary))); - } - } - - group_update_listings($group_id); - - /* @var $phpbb_notifications \phpbb\notification\manager */ - $phpbb_notifications = $phpbb_container->get('notification_manager'); - - $phpbb_notifications->delete_notifications('notification.type.group_request', $user_id_ary, $group_id); - - // Return false - no error - return false; -} - - -/** -* Removes the group avatar of the default group from the users in user_ids who have that group as default. -*/ -function remove_default_avatar($group_id, $user_ids) -{ - global $db; - - if (!is_array($user_ids)) - { - $user_ids = array($user_ids); - } - if (empty($user_ids)) - { - return false; - } - - $user_ids = array_map('intval', $user_ids); - - $sql = 'SELECT * - FROM ' . GROUPS_TABLE . ' - WHERE group_id = ' . (int) $group_id; - $result = $db->sql_query($sql); - if (!$row = $db->sql_fetchrow($result)) - { - $db->sql_freeresult($result); - return false; - } - $db->sql_freeresult($result); - - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_avatar = '', - user_avatar_type = '', - user_avatar_width = 0, - user_avatar_height = 0 - WHERE group_id = " . (int) $group_id . " - AND user_avatar = '" . $db->sql_escape($row['group_avatar']) . "' - AND " . $db->sql_in_set('user_id', $user_ids); - - $db->sql_query($sql); -} - -/** -* Removes the group rank of the default group from the users in user_ids who have that group as default. -*/ -function remove_default_rank($group_id, $user_ids) -{ - global $db; - - if (!is_array($user_ids)) - { - $user_ids = array($user_ids); - } - if (empty($user_ids)) - { - return false; - } - - $user_ids = array_map('intval', $user_ids); - - $sql = 'SELECT * - FROM ' . GROUPS_TABLE . ' - WHERE group_id = ' . (int) $group_id; - $result = $db->sql_query($sql); - if (!$row = $db->sql_fetchrow($result)) - { - $db->sql_freeresult($result); - return false; - } - $db->sql_freeresult($result); - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_rank = 0 - WHERE group_id = ' . (int) $group_id . ' - AND user_rank <> 0 - AND user_rank = ' . (int) $row['group_rank'] . ' - AND ' . $db->sql_in_set('user_id', $user_ids); - $db->sql_query($sql); -} - -/** -* This is used to promote (to leader), demote or set as default a member/s -*/ -function group_user_attributes($action, $group_id, $user_id_ary = false, $username_ary = false, $group_name = false, $group_attributes = false) -{ - global $db, $auth, $user, $phpbb_container, $phpbb_log, $phpbb_dispatcher; - - // We need both username and user_id info - $result = user_get_id_name($user_id_ary, $username_ary); - - if (empty($user_id_ary) || $result !== false) - { - return 'NO_USERS'; - } - - if (!$group_name) - { - $group_name = get_group_name($group_id); - } - - switch ($action) - { - case 'demote': - case 'promote': - - $sql = 'SELECT user_id - FROM ' . USER_GROUP_TABLE . " - WHERE group_id = $group_id - AND user_pending = 1 - AND " . $db->sql_in_set('user_id', $user_id_ary); - $result = $db->sql_query_limit($sql, 1); - $not_empty = ($db->sql_fetchrow($result)); - $db->sql_freeresult($result); - if ($not_empty) - { - return 'NO_VALID_USERS'; - } - - $sql = 'UPDATE ' . USER_GROUP_TABLE . ' - SET group_leader = ' . (($action == 'promote') ? 1 : 0) . " - WHERE group_id = $group_id - AND user_pending = 0 - AND " . $db->sql_in_set('user_id', $user_id_ary); - $db->sql_query($sql); - - $log = ($action == 'promote') ? 'LOG_GROUP_PROMOTED' : 'LOG_GROUP_DEMOTED'; - break; - - case 'approve': - // Make sure we only approve those which are pending ;) - $sql = 'SELECT u.user_id, u.user_email, u.username, u.username_clean, u.user_notify_type, u.user_jabber, u.user_lang - FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . ' ug - WHERE ug.group_id = ' . $group_id . ' - AND ug.user_pending = 1 - AND ug.user_id = u.user_id - AND ' . $db->sql_in_set('ug.user_id', $user_id_ary); - $result = $db->sql_query($sql); - - $user_id_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - $user_id_ary[] = $row['user_id']; - } - $db->sql_freeresult($result); - - if (!count($user_id_ary)) - { - return false; - } - - $sql = 'UPDATE ' . USER_GROUP_TABLE . " - SET user_pending = 0 - WHERE group_id = $group_id - AND " . $db->sql_in_set('user_id', $user_id_ary); - $db->sql_query($sql); - - /* @var $phpbb_notifications \phpbb\notification\manager */ - $phpbb_notifications = $phpbb_container->get('notification_manager'); - - $phpbb_notifications->add_notifications('notification.type.group_request_approved', array( - 'user_ids' => $user_id_ary, - 'group_id' => $group_id, - 'group_name' => $group_name, - )); - $phpbb_notifications->delete_notifications('notification.type.group_request', $user_id_ary, $group_id); - - $log = 'LOG_USERS_APPROVED'; - break; - - case 'default': - // We only set default group for approved members of the group - $sql = 'SELECT user_id - FROM ' . USER_GROUP_TABLE . " - WHERE group_id = $group_id - AND user_pending = 0 - AND " . $db->sql_in_set('user_id', $user_id_ary); - $result = $db->sql_query($sql); - - $user_id_ary = $username_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - $user_id_ary[] = $row['user_id']; - } - $db->sql_freeresult($result); - - $result = user_get_id_name($user_id_ary, $username_ary); - if (!count($user_id_ary) || $result !== false) - { - return 'NO_USERS'; - } - - $sql = 'SELECT user_id, group_id - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('user_id', $user_id_ary, false, true); - $result = $db->sql_query($sql); - - $groups = array(); - while ($row = $db->sql_fetchrow($result)) - { - if (!isset($groups[$row['group_id']])) - { - $groups[$row['group_id']] = array(); - } - $groups[$row['group_id']][] = $row['user_id']; - } - $db->sql_freeresult($result); - - foreach ($groups as $gid => $uids) - { - remove_default_rank($gid, $uids); - remove_default_avatar($gid, $uids); - } - group_set_user_default($group_id, $user_id_ary, $group_attributes); - $log = 'LOG_GROUP_DEFAULTS'; - break; - } - - /** - * Event to perform additional actions on setting user group attributes - * - * @event core.user_set_group_attributes - * @var int group_id ID of the group - * @var string group_name Name of the group - * @var array user_id_ary IDs of the users to set group attributes - * @var array username_ary Names of the users to set group attributes - * @var array group_attributes Group attributes which were changed - * @var string action Action to perform over the group members - * @since 3.1.10-RC1 - */ - $vars = array( - 'group_id', - 'group_name', - 'user_id_ary', - 'username_ary', - 'group_attributes', - 'action', - ); - extract($phpbb_dispatcher->trigger_event('core.user_set_group_attributes', compact($vars))); - - // Clear permissions cache of relevant users - $auth->acl_clear_prefetch($user_id_ary); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, $log, false, array($group_name, implode(', ', $username_ary))); - - group_update_listings($group_id); - - return false; -} - -/** -* A small version of validate_username to check for a group name's existence. To be called directly. -*/ -function group_validate_groupname($group_id, $group_name) -{ - global $db; - - $group_name = utf8_clean_string($group_name); - - if (!empty($group_id)) - { - $sql = 'SELECT group_name - FROM ' . GROUPS_TABLE . ' - WHERE group_id = ' . (int) $group_id; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - return false; - } - - $allowed_groupname = utf8_clean_string($row['group_name']); - - if ($allowed_groupname == $group_name) - { - return false; - } - } - - $sql = 'SELECT group_name - FROM ' . GROUPS_TABLE . " - WHERE LOWER(group_name) = '" . $db->sql_escape(utf8_strtolower($group_name)) . "'"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - return 'GROUP_NAME_TAKEN'; - } - - return false; -} - -/** -* Set users default group -* -* @access private -*/ -function group_set_user_default($group_id, $user_id_ary, $group_attributes = false, $update_listing = false) -{ - global $config, $phpbb_container, $db, $phpbb_dispatcher; - - if (empty($user_id_ary)) - { - return; - } - - $attribute_ary = array( - 'group_colour' => 'string', - 'group_rank' => 'int', - 'group_avatar' => 'string', - 'group_avatar_type' => 'string', - 'group_avatar_width' => 'int', - 'group_avatar_height' => 'int', - ); - - $sql_ary = array( - 'group_id' => $group_id - ); - - // Were group attributes passed to the function? If not we need to obtain them - if ($group_attributes === false) - { - $sql = 'SELECT ' . implode(', ', array_keys($attribute_ary)) . ' - FROM ' . GROUPS_TABLE . " - WHERE group_id = $group_id"; - $result = $db->sql_query($sql); - $group_attributes = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - } - - foreach ($attribute_ary as $attribute => $type) - { - if (isset($group_attributes[$attribute])) - { - // If we are about to set an avatar or rank, we will not overwrite with empty, unless we are not actually changing the default group - if ((strpos($attribute, 'group_avatar') === 0 || strpos($attribute, 'group_rank') === 0) && !$group_attributes[$attribute]) - { - continue; - } - - settype($group_attributes[$attribute], $type); - $sql_ary[str_replace('group_', 'user_', $attribute)] = $group_attributes[$attribute]; - } - } - - $updated_sql_ary = $sql_ary; - - // Before we update the user attributes, we will update the rank for users that don't have a custom rank - if (isset($sql_ary['user_rank'])) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', array('user_rank' => $sql_ary['user_rank'])) . ' - WHERE user_rank = 0 - AND ' . $db->sql_in_set('user_id', $user_id_ary); - $db->sql_query($sql); - unset($sql_ary['user_rank']); - } - - // Before we update the user attributes, we will update the avatar for users that don't have a custom avatar - $avatar_options = array('user_avatar', 'user_avatar_type', 'user_avatar_height', 'user_avatar_width'); - - if (isset($sql_ary['user_avatar'])) - { - $avatar_sql_ary = array(); - foreach ($avatar_options as $avatar_option) - { - if (isset($sql_ary[$avatar_option])) - { - $avatar_sql_ary[$avatar_option] = $sql_ary[$avatar_option]; - } - } - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $avatar_sql_ary) . " - WHERE user_avatar = '' - AND " . $db->sql_in_set('user_id', $user_id_ary); - $db->sql_query($sql); - } - - // Remove the avatar options, as we already updated them - foreach ($avatar_options as $avatar_option) - { - unset($sql_ary[$avatar_option]); - } - - if (!empty($sql_ary)) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE ' . $db->sql_in_set('user_id', $user_id_ary); - $db->sql_query($sql); - } - - if (isset($sql_ary['user_colour'])) - { - // Update any cached colour information for these users - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET forum_last_poster_colour = '" . $db->sql_escape($sql_ary['user_colour']) . "' - WHERE " . $db->sql_in_set('forum_last_poster_id', $user_id_ary); - $db->sql_query($sql); - - $sql = 'UPDATE ' . TOPICS_TABLE . " - SET topic_first_poster_colour = '" . $db->sql_escape($sql_ary['user_colour']) . "' - WHERE " . $db->sql_in_set('topic_poster', $user_id_ary); - $db->sql_query($sql); - - $sql = 'UPDATE ' . TOPICS_TABLE . " - SET topic_last_poster_colour = '" . $db->sql_escape($sql_ary['user_colour']) . "' - WHERE " . $db->sql_in_set('topic_last_poster_id', $user_id_ary); - $db->sql_query($sql); - - if (in_array($config['newest_user_id'], $user_id_ary)) - { - $config->set('newest_user_colour', $sql_ary['user_colour'], false); - } - } - - // Make all values available for the event - $sql_ary = $updated_sql_ary; - - /** - * Event when the default group is set for an array of users - * - * @event core.user_set_default_group - * @var int group_id ID of the group - * @var array user_id_ary IDs of the users - * @var array group_attributes Group attributes which were changed - * @var array update_listing Update the list of moderators and foes - * @var array sql_ary User attributes which were changed - * @since 3.1.0-a1 - */ - $vars = array('group_id', 'user_id_ary', 'group_attributes', 'update_listing', 'sql_ary'); - extract($phpbb_dispatcher->trigger_event('core.user_set_default_group', compact($vars))); - - if ($update_listing) - { - group_update_listings($group_id); - } - - // Because some tables/caches use usercolour-specific data we need to purge this here. - $phpbb_container->get('cache.driver')->destroy('sql', MODERATOR_CACHE_TABLE); -} - -/** -* Get group name -*/ -function get_group_name($group_id) -{ - global $db, $phpbb_container; - - $sql = 'SELECT group_name, group_type - FROM ' . GROUPS_TABLE . ' - WHERE group_id = ' . (int) $group_id; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - return ''; - } - - /** @var \phpbb\group\helper $group_helper */ - $group_helper = $phpbb_container->get('group_helper'); - - return $group_helper->get_name($row['group_name']); -} - -/** -* Obtain either the members of a specified group, the groups the specified user is subscribed to -* or checking if a specified user is in a specified group. This function does not return pending memberships. -* -* Note: Never use this more than once... first group your users/groups -*/ -function group_memberships($group_id_ary = false, $user_id_ary = false, $return_bool = false) -{ - global $db; - - if (!$group_id_ary && !$user_id_ary) - { - return true; - } - - if ($user_id_ary) - { - $user_id_ary = (!is_array($user_id_ary)) ? array($user_id_ary) : $user_id_ary; - } - - if ($group_id_ary) - { - $group_id_ary = (!is_array($group_id_ary)) ? array($group_id_ary) : $group_id_ary; - } - - $sql = 'SELECT ug.*, u.username, u.username_clean, u.user_email - FROM ' . USER_GROUP_TABLE . ' ug, ' . USERS_TABLE . ' u - WHERE ug.user_id = u.user_id - AND ug.user_pending = 0 AND '; - - if ($group_id_ary) - { - $sql .= ' ' . $db->sql_in_set('ug.group_id', $group_id_ary); - } - - if ($user_id_ary) - { - $sql .= ($group_id_ary) ? ' AND ' : ' '; - $sql .= $db->sql_in_set('ug.user_id', $user_id_ary); - } - - $result = ($return_bool) ? $db->sql_query_limit($sql, 1) : $db->sql_query($sql); - - $row = $db->sql_fetchrow($result); - - if ($return_bool) - { - $db->sql_freeresult($result); - return ($row) ? true : false; - } - - if (!$row) - { - return false; - } - - $return = array(); - - do - { - $return[] = $row; - } - while ($row = $db->sql_fetchrow($result)); - - $db->sql_freeresult($result); - - return $return; -} - -/** -* Re-cache moderators and foes if group has a_ or m_ permissions -*/ -function group_update_listings($group_id) -{ - global $db, $cache, $auth; - - $hold_ary = $auth->acl_group_raw_data($group_id, array('a_', 'm_')); - - if (empty($hold_ary)) - { - return; - } - - $mod_permissions = $admin_permissions = false; - - foreach ($hold_ary as $g_id => $forum_ary) - { - foreach ($forum_ary as $forum_id => $auth_ary) - { - foreach ($auth_ary as $auth_option => $setting) - { - if ($mod_permissions && $admin_permissions) - { - break 3; - } - - if ($setting != ACL_YES) - { - continue; - } - - if ($auth_option == 'm_') - { - $mod_permissions = true; - } - - if ($auth_option == 'a_') - { - $admin_permissions = true; - } - } - } - } - - if ($mod_permissions) - { - if (!function_exists('phpbb_cache_moderators')) - { - global $phpbb_root_path, $phpEx; - include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); - } - phpbb_cache_moderators($db, $cache, $auth); - } - - if ($mod_permissions || $admin_permissions) - { - if (!function_exists('phpbb_update_foes')) - { - global $phpbb_root_path, $phpEx; - include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); - } - phpbb_update_foes($db, $auth, array($group_id)); - } -} - - - -/** -* Funtion to make a user leave the NEWLY_REGISTERED system group. -* @access public -* @param $user_id The id of the user to remove from the group -*/ -function remove_newly_registered($user_id, $user_data = false) -{ - global $db; - - if ($user_data === false) - { - $sql = 'SELECT * - FROM ' . USERS_TABLE . ' - WHERE user_id = ' . $user_id; - $result = $db->sql_query($sql); - $user_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$user_row) - { - return false; - } - else - { - $user_data = $user_row; - } - } - - $sql = 'SELECT group_id - FROM ' . GROUPS_TABLE . " - WHERE group_name = 'NEWLY_REGISTERED' - AND group_type = " . GROUP_SPECIAL; - $result = $db->sql_query($sql); - $group_id = (int) $db->sql_fetchfield('group_id'); - $db->sql_freeresult($result); - - if (!$group_id) - { - return false; - } - - // We need to call group_user_del here, because this function makes sure everything is correctly changed. - // Force function to not log the removal of users from newly registered users group - group_user_del($group_id, $user_id, false, false, false); - - // Set user_new to 0 to let this not be triggered again - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_new = 0 - WHERE user_id = ' . $user_id; - $db->sql_query($sql); - - // The new users group was the users default group? - if ($user_data['group_id'] == $group_id) - { - // Which group is now the users default one? - $sql = 'SELECT group_id - FROM ' . USERS_TABLE . ' - WHERE user_id = ' . $user_id; - $result = $db->sql_query($sql); - $user_data['group_id'] = $db->sql_fetchfield('group_id'); - $db->sql_freeresult($result); - } - - return $user_data['group_id']; -} - -/** -* Gets user ids of currently banned registered users. -* -* @param array $user_ids Array of users' ids to check for banning, -* leave empty to get complete list of banned ids -* @param bool|int $ban_end Bool True to get users currently banned -* Bool False to only get permanently banned users -* Int Unix timestamp to get users banned until that time -* @return array Array of banned users' ids if any, empty array otherwise -*/ -function phpbb_get_banned_user_ids($user_ids = array(), $ban_end = true) -{ - global $db; - - $sql_user_ids = (!empty($user_ids)) ? $db->sql_in_set('ban_userid', $user_ids) : 'ban_userid <> 0'; - - // Get banned User ID's - // Ignore stale bans which were not wiped yet - $banned_ids_list = array(); - $sql = 'SELECT ban_userid - FROM ' . BANLIST_TABLE . " - WHERE $sql_user_ids - AND ban_exclude <> 1"; - - if ($ban_end === true) - { - // Banned currently - $sql .= " AND (ban_end > " . time() . ' - OR ban_end = 0)'; - } - else if ($ban_end === false) - { - // Permanently banned - $sql .= " AND ban_end = 0"; - } - else - { - // Banned until a specified time - $sql .= " AND (ban_end > " . (int) $ban_end . ' - OR ban_end = 0)'; - } - - $result = $db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) - { - $user_id = (int) $row['ban_userid']; - $banned_ids_list[$user_id] = $user_id; - } - $db->sql_freeresult($result); - - return $banned_ids_list; -} - -/** -* Function for assigning a template var if the zebra module got included -*/ -function phpbb_module_zebra($mode, &$module_row) -{ - global $template; - - $template->assign_var('S_ZEBRA_ENABLED', true); - - if ($mode == 'friends') - { - $template->assign_var('S_ZEBRA_FRIENDS_ENABLED', true); - } - - if ($mode == 'foes') - { - $template->assign_var('S_ZEBRA_FOES_ENABLED', true); - } -} diff --git a/install/update/old/includes/mcp/mcp_ban.php b/install/update/old/includes/mcp/mcp_ban.php deleted file mode 100644 index 8797f06..0000000 --- a/install/update/old/includes/mcp/mcp_ban.php +++ /dev/null @@ -1,301 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -class mcp_ban -{ - var $u_action; - - function main($id, $mode) - { - global $db, $user, $auth, $template, $request, $phpbb_dispatcher; - global $phpbb_root_path, $phpEx; - - if (!function_exists('user_ban')) - { - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - } - - // Include the admin banning interface... - if (!class_exists('acp_ban')) - { - include($phpbb_root_path . 'includes/acp/acp_ban.' . $phpEx); - } - - $bansubmit = $request->is_set_post('bansubmit'); - $unbansubmit = $request->is_set_post('unbansubmit'); - - $user->add_lang(array('acp/ban', 'acp/users')); - $this->tpl_name = 'mcp_ban'; - - /** - * Use this event to pass perform actions when a ban is issued or revoked - * - * @event core.mcp_ban_main - * @var bool bansubmit True if a ban is issued - * @var bool unbansubmit True if a ban is removed - * @var string mode Mode of the ban that is being worked on - * @since 3.1.0-RC5 - */ - $vars = array( - 'bansubmit', - 'unbansubmit', - 'mode', - ); - extract($phpbb_dispatcher->trigger_event('core.mcp_ban_main', compact($vars))); - - // Ban submitted? - if ($bansubmit) - { - // Grab the list of entries - $ban = $request->variable('ban', '', $mode === 'user'); - $ban_length = $request->variable('banlength', 0); - $ban_length_other = $request->variable('banlengthother', ''); - $ban_exclude = $request->variable('banexclude', 0); - $ban_reason = $request->variable('banreason', '', true); - $ban_give_reason = $request->variable('bangivereason', '', true); - - if ($ban) - { - if (confirm_box(true)) - { - $abort_ban = false; - /** - * Use this event to modify the ban details before the ban is performed - * - * @event core.mcp_ban_before - * @var string mode One of the following: user, ip, email - * @var string ban Either string or array with usernames, ips or email addresses - * @var int ban_length Ban length in minutes - * @var string ban_length_other Ban length as a date (YYYY-MM-DD) - * @var bool ban_exclude Are we banning or excluding from another ban - * @var string ban_reason Ban reason displayed to moderators - * @var string ban_give_reason Ban reason displayed to the banned user - * @var mixed abort_ban Either false, or an error message that is displayed to the user. - * If a string is given the bans are not issued. - * @since 3.1.0-RC5 - */ - $vars = array( - 'mode', - 'ban', - 'ban_length', - 'ban_length_other', - 'ban_exclude', - 'ban_reason', - 'ban_give_reason', - 'abort_ban', - ); - extract($phpbb_dispatcher->trigger_event('core.mcp_ban_before', compact($vars))); - - if ($abort_ban) - { - trigger_error($abort_ban); - } - user_ban($mode, $ban, $ban_length, $ban_length_other, $ban_exclude, $ban_reason, $ban_give_reason); - - /** - * Use this event to perform actions after the ban has been performed - * - * @event core.mcp_ban_after - * @var string mode One of the following: user, ip, email - * @var string ban Either string or array with usernames, ips or email addresses - * @var int ban_length Ban length in minutes - * @var string ban_length_other Ban length as a date (YYYY-MM-DD) - * @var bool ban_exclude Are we banning or excluding from another ban - * @var string ban_reason Ban reason displayed to moderators - * @var string ban_give_reason Ban reason displayed to the banned user - * @since 3.1.0-RC5 - */ - $vars = array( - 'mode', - 'ban', - 'ban_length', - 'ban_length_other', - 'ban_exclude', - 'ban_reason', - 'ban_give_reason', - ); - extract($phpbb_dispatcher->trigger_event('core.mcp_ban_after', compact($vars))); - - trigger_error($user->lang['BAN_UPDATE_SUCCESSFUL'] . '

« ' . $user->lang['BACK_TO_PREV'] . ''); - } - else - { - $hidden_fields = array( - 'mode' => $mode, - 'ban' => $ban, - 'bansubmit' => true, - 'banlength' => $ban_length, - 'banlengthother' => $ban_length_other, - 'banexclude' => $ban_exclude, - 'banreason' => $ban_reason, - 'bangivereason' => $ban_give_reason, - ); - - /** - * Use this event to pass data from the ban form to the confirmation screen - * - * @event core.mcp_ban_confirm - * @var array hidden_fields Hidden fields that are passed through the confirm screen - * @since 3.1.0-RC5 - */ - $vars = array('hidden_fields'); - extract($phpbb_dispatcher->trigger_event('core.mcp_ban_confirm', compact($vars))); - - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields($hidden_fields)); - } - } - } - else if ($unbansubmit) - { - $ban = $request->variable('unban', array('')); - - if ($ban) - { - if (confirm_box(true)) - { - user_unban($mode, $ban); - - trigger_error($user->lang['BAN_UPDATE_SUCCESSFUL'] . '

« ' . $user->lang['BACK_TO_PREV'] . ''); - } - else - { - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( - 'mode' => $mode, - 'unbansubmit' => true, - 'unban' => $ban))); - } - } - } - - // Ban length options - $ban_end_text = array(0 => $user->lang['PERMANENT'], 30 => $user->lang['30_MINS'], 60 => $user->lang['1_HOUR'], 360 => $user->lang['6_HOURS'], 1440 => $user->lang['1_DAY'], 10080 => $user->lang['7_DAYS'], 20160 => $user->lang['2_WEEKS'], 40320 => $user->lang['1_MONTH'], -1 => $user->lang['UNTIL'] . ' -> '); - - $ban_end_options = ''; - foreach ($ban_end_text as $length => $text) - { - $ban_end_options .= ''; - } - - // Define language vars - $this->page_title = $user->lang[strtoupper($mode) . '_BAN']; - - $l_ban_explain = $user->lang[strtoupper($mode) . '_BAN_EXPLAIN']; - $l_ban_exclude_explain = $user->lang[strtoupper($mode) . '_BAN_EXCLUDE_EXPLAIN']; - $l_unban_title = $user->lang[strtoupper($mode) . '_UNBAN']; - $l_unban_explain = $user->lang[strtoupper($mode) . '_UNBAN_EXPLAIN']; - $l_no_ban_cell = $user->lang[strtoupper($mode) . '_NO_BANNED']; - - switch ($mode) - { - case 'user': - $l_ban_cell = $user->lang['USERNAME']; - break; - - case 'ip': - $l_ban_cell = $user->lang['IP_HOSTNAME']; - break; - - case 'email': - $l_ban_cell = $user->lang['EMAIL_ADDRESS']; - break; - } - - acp_ban::display_ban_options($mode); - - $template->assign_vars(array( - 'L_TITLE' => $this->page_title, - 'L_EXPLAIN' => $l_ban_explain, - 'L_UNBAN_TITLE' => $l_unban_title, - 'L_UNBAN_EXPLAIN' => $l_unban_explain, - 'L_BAN_CELL' => $l_ban_cell, - 'L_BAN_EXCLUDE_EXPLAIN' => $l_ban_exclude_explain, - 'L_NO_BAN_CELL' => $l_no_ban_cell, - - 'S_USERNAME_BAN' => ($mode == 'user') ? true : false, - - 'U_ACTION' => $this->u_action, - 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=mcp_ban&field=ban'), - )); - - if ($mode === 'email' && !$auth->acl_get('a_user')) - { - return; - } - - // As a "service" we will check if any post id is specified and populate the username of the poster id if given - $post_id = $request->variable('p', 0); - $user_id = $request->variable('u', 0); - $pre_fill = false; - - if ($user_id && $user_id <> ANONYMOUS) - { - $sql = 'SELECT username, user_email, user_ip - FROM ' . USERS_TABLE . ' - WHERE user_id = ' . $user_id; - $result = $db->sql_query($sql); - switch ($mode) - { - case 'user': - $pre_fill = (string) $db->sql_fetchfield('username'); - break; - - case 'ip': - $pre_fill = (string) $db->sql_fetchfield('user_ip'); - break; - - case 'email': - $pre_fill = (string) $db->sql_fetchfield('user_email'); - break; - } - $db->sql_freeresult($result); - } - else if ($post_id) - { - $post_info = phpbb_get_post_data($post_id, 'm_ban'); - - if (count($post_info) && !empty($post_info[$post_id])) - { - switch ($mode) - { - case 'user': - $pre_fill = $post_info[$post_id]['username']; - break; - - case 'ip': - $pre_fill = $post_info[$post_id]['poster_ip']; - break; - - case 'email': - $pre_fill = $post_info[$post_id]['user_email']; - break; - } - - } - } - - if ($pre_fill) - { - // left for legacy template compatibility - $template->assign_var('USERNAMES', $pre_fill); - $template->assign_var('BAN_QUANTIFIER', $pre_fill); - } - } -} diff --git a/install/update/old/includes/mcp/mcp_logs.php b/install/update/old/includes/mcp/mcp_logs.php deleted file mode 100644 index 79f9d35..0000000 --- a/install/update/old/includes/mcp/mcp_logs.php +++ /dev/null @@ -1,230 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* mcp_logs -* Handling warning the users -*/ -class mcp_logs -{ - var $u_action; - var $p_master; - - function __construct($p_master) - { - $this->p_master = $p_master; - } - - function main($id, $mode) - { - global $auth, $db, $user, $template, $request; - global $config, $phpbb_container, $phpbb_log; - - $user->add_lang('acp/common'); - - $action = $request->variable('action', array('' => '')); - - if (is_array($action)) - { - list($action, ) = each($action); - } - else - { - $action = $request->variable('action', ''); - } - - // Set up general vars - $start = $request->variable('start', 0); - $deletemark = ($action == 'del_marked') ? true : false; - $deleteall = ($action == 'del_all') ? true : false; - $marked = $request->variable('mark', array(0)); - - // Sort keys - $sort_days = $request->variable('st', 0); - $sort_key = $request->variable('sk', 't'); - $sort_dir = $request->variable('sd', 'd'); - - $this->tpl_name = 'mcp_logs'; - $this->page_title = 'MCP_LOGS'; - - /* @var $pagination \phpbb\pagination */ - $pagination = $phpbb_container->get('pagination'); - - $forum_list = array_values(array_intersect(get_forum_list('f_read'), get_forum_list('m_'))); - $forum_list[] = 0; - - $forum_id = $topic_id = 0; - - switch ($mode) - { - case 'front': - break; - - case 'forum_logs': - $forum_id = $request->variable('f', 0); - - if (!in_array($forum_id, $forum_list)) - { - send_status_line(403, 'Forbidden'); - trigger_error('NOT_AUTHORISED'); - } - - $forum_list = array($forum_id); - break; - - case 'topic_logs': - $topic_id = $request->variable('t', 0); - - $sql = 'SELECT forum_id - FROM ' . TOPICS_TABLE . ' - WHERE topic_id = ' . $topic_id; - $result = $db->sql_query($sql); - $forum_id = (int) $db->sql_fetchfield('forum_id'); - $db->sql_freeresult($result); - - if (!in_array($forum_id, $forum_list)) - { - send_status_line(403, 'Forbidden'); - trigger_error('NOT_AUTHORISED'); - } - - $forum_list = array($forum_id); - break; - } - - // Delete entries if requested and able - if (($deletemark || $deleteall) && $auth->acl_get('a_clearlogs')) - { - if (confirm_box(true)) - { - if ($deletemark && count($marked)) - { - $conditions = array( - 'forum_id' => array('IN' => $forum_list), - 'log_id' => array('IN' => $marked), - ); - - $phpbb_log->delete('mod', $conditions); - } - else if ($deleteall) - { - $keywords = $request->variable('keywords', '', true); - - $conditions = array( - 'forum_id' => array('IN' => $forum_list), - 'keywords' => $keywords, - ); - - if ($sort_days) - { - $conditions['log_time'] = array('>=', time() - ($sort_days * 86400)); - } - - if ($mode == 'topic_logs') - { - $conditions['topic_id'] = $topic_id; - } - - $phpbb_log->delete('mod', $conditions); - } - } - else - { - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( - 'f' => $forum_id, - 't' => $topic_id, - 'start' => $start, - 'delmarked' => $deletemark, - 'delall' => $deleteall, - 'mark' => $marked, - 'st' => $sort_days, - 'sk' => $sort_key, - 'sd' => $sort_dir, - 'i' => $id, - 'mode' => $mode, - 'action' => $request->variable('action', array('' => '')))) - ); - } - } - - // Sorting - $limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); - $sort_by_text = array('u' => $user->lang['SORT_USERNAME'], 't' => $user->lang['SORT_DATE'], 'i' => $user->lang['SORT_IP'], 'o' => $user->lang['SORT_ACTION']); - $sort_by_sql = array('u' => 'u.username_clean', 't' => 'l.log_time', 'i' => 'l.log_ip', 'o' => 'l.log_operation'); - - $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; - gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); - - // Define where and sort sql for use in displaying logs - $sql_where = ($sort_days) ? (time() - ($sort_days * 86400)) : 0; - $sql_sort = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'); - - $keywords = $request->variable('keywords', '', true); - $keywords_param = !empty($keywords) ? '&keywords=' . urlencode(htmlspecialchars_decode($keywords)) : ''; - - // Grab log data - $log_data = array(); - $log_count = 0; - $start = view_log('mod', $log_data, $log_count, $config['topics_per_page'], $start, $forum_list, $topic_id, 0, $sql_where, $sql_sort, $keywords); - - $base_url = $this->u_action . "&$u_sort_param$keywords_param"; - $pagination->generate_template_pagination($base_url, 'pagination', 'start', $log_count, $config['topics_per_page'], $start); - - $template->assign_vars(array( - 'TOTAL' => $user->lang('TOTAL_LOGS', (int) $log_count), - - 'L_TITLE' => $user->lang['MCP_LOGS'], - - 'U_POST_ACTION' => $this->u_action . "&$u_sort_param$keywords_param&start=$start", - 'S_CLEAR_ALLOWED' => ($auth->acl_get('a_clearlogs')) ? true : false, - 'S_SELECT_SORT_DIR' => $s_sort_dir, - 'S_SELECT_SORT_KEY' => $s_sort_key, - 'S_SELECT_SORT_DAYS' => $s_limit_days, - 'S_LOGS' => ($log_count > 0), - 'S_KEYWORDS' => $keywords, - ) - ); - - foreach ($log_data as $row) - { - $data = array(); - - $checks = array('viewpost', 'viewtopic', 'viewforum'); - foreach ($checks as $check) - { - if (isset($row[$check]) && $row[$check]) - { - $data[] = '' . $user->lang['LOGVIEW_' . strtoupper($check)] . ''; - } - } - - $template->assign_block_vars('log', array( - 'USERNAME' => $row['username_full'], - 'IP' => $row['ip'], - 'DATE' => $user->format_date($row['time']), - 'ACTION' => $row['action'], - 'DATA' => (count($data)) ? implode(' | ', $data) : '', - 'ID' => $row['id'], - ) - ); - } - } -} diff --git a/install/update/old/includes/mcp/mcp_main.php b/install/update/old/includes/mcp/mcp_main.php deleted file mode 100644 index 4bd783b..0000000 --- a/install/update/old/includes/mcp/mcp_main.php +++ /dev/null @@ -1,1701 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* mcp_main -* Handling mcp actions -*/ -class mcp_main -{ - var $p_master; - var $u_action; - - function __construct($p_master) - { - $this->p_master = $p_master; - } - - function main($id, $mode) - { - global $auth, $user, $action; - global $phpbb_root_path, $phpEx, $request; - global $phpbb_dispatcher; - - $quickmod = ($mode == 'quickmod') ? true : false; - - switch ($action) - { - case 'lock': - case 'unlock': - $topic_ids = (!$quickmod) ? $request->variable('topic_id_list', array(0)) : array($request->variable('t', 0)); - - if (!count($topic_ids)) - { - trigger_error('NO_TOPIC_SELECTED'); - } - - lock_unlock($action, $topic_ids); - break; - - case 'lock_post': - case 'unlock_post': - - $post_ids = (!$quickmod) ? $request->variable('post_id_list', array(0)) : array($request->variable('p', 0)); - - if (!count($post_ids)) - { - trigger_error('NO_POST_SELECTED'); - } - - lock_unlock($action, $post_ids); - break; - - case 'make_announce': - case 'make_sticky': - case 'make_global': - case 'make_normal': - - $topic_ids = (!$quickmod) ? $request->variable('topic_id_list', array(0)) : array($request->variable('t', 0)); - - if (!count($topic_ids)) - { - trigger_error('NO_TOPIC_SELECTED'); - } - - change_topic_type($action, $topic_ids); - break; - - case 'move': - $user->add_lang('viewtopic'); - - $topic_ids = (!$quickmod) ? $request->variable('topic_id_list', array(0)) : array($request->variable('t', 0)); - - if (!count($topic_ids)) - { - trigger_error('NO_TOPIC_SELECTED'); - } - - mcp_move_topic($topic_ids); - break; - - case 'fork': - $user->add_lang('viewtopic'); - - $topic_ids = (!$quickmod) ? $request->variable('topic_id_list', array(0)) : array($request->variable('t', 0)); - - if (!count($topic_ids)) - { - trigger_error('NO_TOPIC_SELECTED'); - } - - mcp_fork_topic($topic_ids); - break; - - case 'delete_topic': - $user->add_lang('viewtopic'); - - // f parameter is not reliable for permission usage, however we just use it to decide - // which permission we will check later on. So if it is manipulated, we will still catch it later on. - $forum_id = $request->variable('f', 0); - $topic_ids = (!$quickmod) ? $request->variable('topic_id_list', array(0)) : array($request->variable('t', 0)); - $soft_delete = (($request->is_set_post('confirm') && !$request->is_set_post('delete_permanent')) || !$auth->acl_get('m_delete', $forum_id)) ? true : false; - - if (!count($topic_ids)) - { - trigger_error('NO_TOPIC_SELECTED'); - } - - mcp_delete_topic($topic_ids, $soft_delete, $request->variable('delete_reason', '', true)); - break; - - case 'delete_post': - $user->add_lang('posting'); - - // f parameter is not reliable for permission usage, however we just use it to decide - // which permission we will check later on. So if it is manipulated, we will still catch it later on. - $forum_id = $request->variable('f', 0); - $post_ids = (!$quickmod) ? $request->variable('post_id_list', array(0)) : array($request->variable('p', 0)); - $soft_delete = (($request->is_set_post('confirm') && !$request->is_set_post('delete_permanent')) || !$auth->acl_get('m_delete', $forum_id)) ? true : false; - - if (!count($post_ids)) - { - trigger_error('NO_POST_SELECTED'); - } - - mcp_delete_post($post_ids, $soft_delete, $request->variable('delete_reason', '', true)); - break; - - case 'restore_topic': - $user->add_lang('posting'); - - $topic_ids = (!$quickmod) ? $request->variable('topic_id_list', array(0)) : array($request->variable('t', 0)); - - if (!count($topic_ids)) - { - trigger_error('NO_TOPIC_SELECTED'); - } - - mcp_restore_topic($topic_ids); - break; - - default: - /** - * This event allows you to handle custom quickmod options - * - * @event core.modify_quickmod_actions - * @var string action Topic quick moderation action name - * @var bool quickmod Flag indicating whether MCP is in quick moderation mode - * @since 3.1.0-a4 - * @changed 3.1.0-RC4 Added variables: action, quickmod - */ - $vars = array('action', 'quickmod'); - extract($phpbb_dispatcher->trigger_event('core.modify_quickmod_actions', compact($vars))); - break; - } - - switch ($mode) - { - case 'front': - if (!function_exists('mcp_front_view')) - { - include($phpbb_root_path . 'includes/mcp/mcp_front.' . $phpEx); - } - - $user->add_lang('acp/common'); - - mcp_front_view($id, $mode, $action); - - $this->tpl_name = 'mcp_front'; - $this->page_title = 'MCP_MAIN'; - break; - - case 'forum_view': - if (!function_exists('mcp_forum_view')) - { - include($phpbb_root_path . 'includes/mcp/mcp_forum.' . $phpEx); - } - - $user->add_lang('viewforum'); - - $forum_id = $request->variable('f', 0); - - $forum_info = phpbb_get_forum_data($forum_id, 'm_', true); - - if (!count($forum_info)) - { - $this->main('main', 'front'); - return; - } - - $forum_info = $forum_info[$forum_id]; - - mcp_forum_view($id, $mode, $action, $forum_info); - - $this->tpl_name = 'mcp_forum'; - $this->page_title = 'MCP_MAIN_FORUM_VIEW'; - break; - - case 'topic_view': - if (!function_exists('mcp_topic_view')) - { - include($phpbb_root_path . 'includes/mcp/mcp_topic.' . $phpEx); - } - - mcp_topic_view($id, $mode, $action); - - $this->tpl_name = 'mcp_topic'; - $this->page_title = 'MCP_MAIN_TOPIC_VIEW'; - break; - - case 'post_details': - if (!function_exists('mcp_post_details')) - { - include($phpbb_root_path . 'includes/mcp/mcp_post.' . $phpEx); - } - - mcp_post_details($id, $mode, $action); - - $this->tpl_name = ($action == 'whois') ? 'mcp_whois' : 'mcp_post'; - $this->page_title = 'MCP_MAIN_POST_DETAILS'; - break; - - default: - if ($quickmod) - { - switch ($action) - { - case 'lock': - case 'unlock': - case 'make_announce': - case 'make_sticky': - case 'make_global': - case 'make_normal': - case 'make_onindex': - case 'move': - case 'fork': - case 'delete_topic': - trigger_error('TOPIC_NOT_EXIST'); - break; - - case 'lock_post': - case 'unlock_post': - case 'delete_post': - trigger_error('POST_NOT_EXIST'); - break; - } - } - - trigger_error('NO_MODE', E_USER_ERROR); - break; - } - } -} - -/** -* Lock/Unlock Topic/Post -*/ -function lock_unlock($action, $ids) -{ - global $user, $db, $request, $phpbb_log, $phpbb_dispatcher; - - if ($action == 'lock' || $action == 'unlock') - { - $table = TOPICS_TABLE; - $sql_id = 'topic_id'; - $set_id = 'topic_status'; - $l_prefix = 'TOPIC'; - } - else - { - $table = POSTS_TABLE; - $sql_id = 'post_id'; - $set_id = 'post_edit_locked'; - $l_prefix = 'POST'; - } - - $orig_ids = $ids; - - if (!phpbb_check_ids($ids, $table, $sql_id, array('m_lock'))) - { - // Make sure that for f_user_lock only the lock action is triggered. - if ($action != 'lock') - { - return; - } - - $ids = $orig_ids; - - if (!phpbb_check_ids($ids, $table, $sql_id, array('f_user_lock'))) - { - return; - } - } - unset($orig_ids); - - $redirect = $request->variable('redirect', build_url(array('action', 'quickmod'))); - $redirect = reapply_sid($redirect); - - $s_hidden_fields = build_hidden_fields(array( - $sql_id . '_list' => $ids, - 'action' => $action, - 'redirect' => $redirect) - ); - - if (confirm_box(true)) - { - $sql = "UPDATE $table - SET $set_id = " . (($action == 'lock' || $action == 'lock_post') ? ITEM_LOCKED : ITEM_UNLOCKED) . ' - WHERE ' . $db->sql_in_set($sql_id, $ids); - $db->sql_query($sql); - - $data = ($action == 'lock' || $action == 'unlock') ? phpbb_get_topic_data($ids) : phpbb_get_post_data($ids); - - foreach ($data as $id => $row) - { - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_' . strtoupper($action), false, array( - 'forum_id' => $row['forum_id'], - 'topic_id' => $row['topic_id'], - 'post_id' => isset($row['post_id']) ? $row['post_id'] : 0, - $row['topic_title'] - )); - } - - /** - * Perform additional actions after locking/unlocking posts/topics - * - * @event core.mcp_lock_unlock_after - * @var string action Variable containing the action we perform on the posts/topics ('lock', 'unlock', 'lock_post' or 'unlock_post') - * @var array ids Array containing the post/topic IDs that have been locked/unlocked - * @var array data Array containing posts/topics data - * @since 3.1.7-RC1 - */ - $vars = array( - 'action', - 'ids', - 'data', - ); - extract($phpbb_dispatcher->trigger_event('core.mcp_lock_unlock_after', compact($vars))); - - $success_msg = $l_prefix . ((count($ids) == 1) ? '' : 'S') . '_' . (($action == 'lock' || $action == 'lock_post') ? 'LOCKED' : 'UNLOCKED') . '_SUCCESS'; - - meta_refresh(2, $redirect); - $message = $user->lang[$success_msg]; - - if (!$request->is_ajax()) - { - $message .= '

' . $user->lang('RETURN_PAGE', '', ''); - } - trigger_error($message); - } - else - { - confirm_box(false, strtoupper($action) . '_' . $l_prefix . ((count($ids) == 1) ? '' : 'S'), $s_hidden_fields); - } - - redirect($redirect); -} - -/** -* Change Topic Type -*/ -function change_topic_type($action, $topic_ids) -{ - global $user, $db, $request, $phpbb_log, $phpbb_dispatcher; - - switch ($action) - { - case 'make_announce': - $new_topic_type = POST_ANNOUNCE; - $check_acl = 'f_announce'; - $l_new_type = (count($topic_ids) == 1) ? 'MCP_MAKE_ANNOUNCEMENT' : 'MCP_MAKE_ANNOUNCEMENTS'; - break; - - case 'make_global': - $new_topic_type = POST_GLOBAL; - $check_acl = 'f_announce_global'; - $l_new_type = (count($topic_ids) == 1) ? 'MCP_MAKE_GLOBAL' : 'MCP_MAKE_GLOBALS'; - break; - - case 'make_sticky': - $new_topic_type = POST_STICKY; - $check_acl = 'f_sticky'; - $l_new_type = (count($topic_ids) == 1) ? 'MCP_MAKE_STICKY' : 'MCP_MAKE_STICKIES'; - break; - - default: - $new_topic_type = POST_NORMAL; - $check_acl = false; - $l_new_type = (count($topic_ids) == 1) ? 'MCP_MAKE_NORMAL' : 'MCP_MAKE_NORMALS'; - break; - } - - $forum_id = phpbb_check_ids($topic_ids, TOPICS_TABLE, 'topic_id', $check_acl, true); - - if ($forum_id === false) - { - return; - } - - $redirect = $request->variable('redirect', build_url(array('action', 'quickmod'))); - $redirect = reapply_sid($redirect); - - $s_hidden_fields = array( - 'topic_id_list' => $topic_ids, - 'f' => $forum_id, - 'action' => $action, - 'redirect' => $redirect, - ); - - if (confirm_box(true)) - { - - /** - * Perform additional actions before changing topic(s) type - * - * @event core.mcp_change_topic_type_before - * @var int new_topic_type The candidated topic type. - * @var int forum_id The forum ID for the topic ID(s). - * @var array topic_ids Array containing the topic ID(s) that will be changed - * @since 3.2.6-RC1 - */ - $vars = array( - 'new_topic_type', - 'forum_id', - 'topic_ids', - ); - extract($phpbb_dispatcher->trigger_event('core.mcp_change_topic_type_before', compact($vars))); - - $db->sql_transaction('begin'); - - $sql = 'UPDATE ' . TOPICS_TABLE . " - SET topic_type = $new_topic_type - WHERE " . $db->sql_in_set('topic_id', $topic_ids); - $db->sql_query($sql); - - if (($new_topic_type == POST_GLOBAL) && count($topic_ids)) - { - // Delete topic shadows for global announcements - $sql = 'DELETE FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_moved_id', $topic_ids); - $db->sql_query($sql); - } - - $db->sql_transaction('commit'); - - $success_msg = (count($topic_ids) == 1) ? 'TOPIC_TYPE_CHANGED' : 'TOPICS_TYPE_CHANGED'; - - if (count($topic_ids)) - { - $data = phpbb_get_topic_data($topic_ids); - - foreach ($data as $topic_id => $row) - { - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_TOPIC_TYPE_CHANGED', false, array( - 'forum_id' => $forum_id, - 'topic_id' => $topic_id, - $row['topic_title'] - )); - } - } - - /** - * Perform additional actions after changing topic types - * - * @event core.mcp_change_topic_type_after - * @var int new_topic_type The newly changed topic type. - * @var int forum_id The forum ID where the newly changed topic type belongs to. - * @var array topic_ids Array containing the topic IDs that have been changed - * @since 3.2.6-RC1 - */ - $vars = array( - 'new_topic_type', - 'forum_id', - 'topic_ids', - ); - extract($phpbb_dispatcher->trigger_event('core.mcp_change_topic_type_after', compact($vars))); - - meta_refresh(2, $redirect); - $message = $user->lang[$success_msg]; - - if (!$request->is_ajax()) - { - $message .= '

' . $user->lang('RETURN_PAGE', '', ''); - } - trigger_error($message); - } - else - { - confirm_box(false, $l_new_type, build_hidden_fields($s_hidden_fields)); - } - - redirect($redirect); -} - -/** -* Move Topic -*/ -function mcp_move_topic($topic_ids) -{ - global $auth, $user, $db, $template, $phpbb_log, $request, $phpbb_dispatcher; - global $phpEx, $phpbb_root_path; - - // Here we limit the operation to one forum only - $forum_id = phpbb_check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array('m_move'), true); - - if ($forum_id === false) - { - return; - } - - $to_forum_id = $request->variable('to_forum_id', 0); - $redirect = $request->variable('redirect', build_url(array('action', 'quickmod'))); - $additional_msg = $success_msg = ''; - - $s_hidden_fields = build_hidden_fields(array( - 'topic_id_list' => $topic_ids, - 'f' => $forum_id, - 'action' => 'move', - 'redirect' => $redirect) - ); - - if ($to_forum_id) - { - $forum_data = phpbb_get_forum_data($to_forum_id, 'f_post'); - - if (!count($forum_data)) - { - $additional_msg = $user->lang['FORUM_NOT_EXIST']; - } - else - { - $forum_data = $forum_data[$to_forum_id]; - - if ($forum_data['forum_type'] != FORUM_POST) - { - $additional_msg = $user->lang['FORUM_NOT_POSTABLE']; - } - else if (!$auth->acl_get('f_post', $to_forum_id) || (!$auth->acl_get('m_approve', $to_forum_id) && !$auth->acl_get('f_noapprove', $to_forum_id))) - { - $additional_msg = $user->lang['USER_CANNOT_POST']; - } - else if ($forum_id == $to_forum_id) - { - $additional_msg = $user->lang['CANNOT_MOVE_SAME_FORUM']; - } - } - } - else if (isset($_POST['confirm'])) - { - $additional_msg = $user->lang['FORUM_NOT_EXIST']; - } - - if (!$to_forum_id || $additional_msg) - { - $request->overwrite('confirm', null, \phpbb\request\request_interface::POST); - $request->overwrite('confirm_key', null); - } - - if (confirm_box(true)) - { - $topic_data = phpbb_get_topic_data($topic_ids); - $leave_shadow = (isset($_POST['move_leave_shadow'])) ? true : false; - - $forum_sync_data = array(); - - $forum_sync_data[$forum_id] = current($topic_data); - $forum_sync_data[$to_forum_id] = $forum_data; - - $topics_moved = $topics_moved_unapproved = $topics_moved_softdeleted = 0; - $posts_moved = $posts_moved_unapproved = $posts_moved_softdeleted = 0; - - foreach ($topic_data as $topic_id => $topic_info) - { - if ($topic_info['topic_visibility'] == ITEM_APPROVED) - { - $topics_moved++; - } - else if ($topic_info['topic_visibility'] == ITEM_UNAPPROVED || $topic_info['topic_visibility'] == ITEM_REAPPROVE) - { - $topics_moved_unapproved++; - } - else if ($topic_info['topic_visibility'] == ITEM_DELETED) - { - $topics_moved_softdeleted++; - } - - $posts_moved += $topic_info['topic_posts_approved']; - $posts_moved_unapproved += $topic_info['topic_posts_unapproved']; - $posts_moved_softdeleted += $topic_info['topic_posts_softdeleted']; - } - - $db->sql_transaction('begin'); - - // Move topics, but do not resync yet - move_topics($topic_ids, $to_forum_id, false); - - if ($request->is_set_post('move_lock_topics') && $auth->acl_get('m_lock', $to_forum_id)) - { - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_status = ' . ITEM_LOCKED . ' - WHERE ' . $db->sql_in_set('topic_id', $topic_ids); - $db->sql_query($sql); - } - - $shadow_topics = 0; - $forum_ids = array($to_forum_id); - foreach ($topic_data as $topic_id => $row) - { - // Get the list of forums to resync - $forum_ids[] = $row['forum_id']; - - // We add the $to_forum_id twice, because 'forum_id' is updated - // when the topic is moved again later. - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_MOVE', false, array( - 'forum_id' => (int) $to_forum_id, - 'topic_id' => (int) $topic_id, - $row['forum_name'], - $forum_data['forum_name'], - (int) $row['forum_id'], - (int) $forum_data['forum_id'], - )); - - // Leave a redirection if required and only if the topic is visible to users - if ($leave_shadow && $row['topic_visibility'] == ITEM_APPROVED && $row['topic_type'] != POST_GLOBAL) - { - $shadow = array( - 'forum_id' => (int) $row['forum_id'], - 'icon_id' => (int) $row['icon_id'], - 'topic_attachment' => (int) $row['topic_attachment'], - 'topic_visibility' => ITEM_APPROVED, // a shadow topic is always approved - 'topic_reported' => 0, // a shadow topic is never reported - 'topic_title' => (string) $row['topic_title'], - 'topic_poster' => (int) $row['topic_poster'], - 'topic_time' => (int) $row['topic_time'], - 'topic_time_limit' => (int) $row['topic_time_limit'], - 'topic_views' => (int) $row['topic_views'], - 'topic_posts_approved' => (int) $row['topic_posts_approved'], - 'topic_posts_unapproved'=> (int) $row['topic_posts_unapproved'], - 'topic_posts_softdeleted'=> (int) $row['topic_posts_softdeleted'], - 'topic_status' => ITEM_MOVED, - 'topic_type' => POST_NORMAL, - 'topic_first_post_id' => (int) $row['topic_first_post_id'], - 'topic_first_poster_colour'=>(string) $row['topic_first_poster_colour'], - 'topic_first_poster_name'=> (string) $row['topic_first_poster_name'], - 'topic_last_post_id' => (int) $row['topic_last_post_id'], - 'topic_last_poster_id' => (int) $row['topic_last_poster_id'], - 'topic_last_poster_colour'=>(string) $row['topic_last_poster_colour'], - 'topic_last_poster_name'=> (string) $row['topic_last_poster_name'], - 'topic_last_post_subject'=> (string) $row['topic_last_post_subject'], - 'topic_last_post_time' => (int) $row['topic_last_post_time'], - 'topic_last_view_time' => (int) $row['topic_last_view_time'], - 'topic_moved_id' => (int) $row['topic_id'], - 'topic_bumped' => (int) $row['topic_bumped'], - 'topic_bumper' => (int) $row['topic_bumper'], - 'poll_title' => (string) $row['poll_title'], - 'poll_start' => (int) $row['poll_start'], - 'poll_length' => (int) $row['poll_length'], - 'poll_max_options' => (int) $row['poll_max_options'], - 'poll_last_vote' => (int) $row['poll_last_vote'] - ); - - /** - * Perform actions before shadow topic is created. - * - * @event core.mcp_main_modify_shadow_sql - * @var array shadow SQL array to be used by $db->sql_build_array - * @var array row Topic data - * @since 3.1.11-RC1 - * @changed 3.1.11-RC1 Added variable: row - */ - $vars = array( - 'shadow', - 'row', - ); - extract($phpbb_dispatcher->trigger_event('core.mcp_main_modify_shadow_sql', compact($vars))); - - $db->sql_query('INSERT INTO ' . TOPICS_TABLE . $db->sql_build_array('INSERT', $shadow)); - - // Shadow topics only count on new "topics" and not posts... a shadow topic alone has 0 posts - $shadow_topics++; - } - } - unset($topic_data); - - $sync_sql = array(); - if ($posts_moved) - { - $sync_sql[$to_forum_id][] = 'forum_posts_approved = forum_posts_approved + ' . (int) $posts_moved; - $sync_sql[$forum_id][] = 'forum_posts_approved = forum_posts_approved - ' . (int) $posts_moved; - } - if ($posts_moved_unapproved) - { - $sync_sql[$to_forum_id][] = 'forum_posts_unapproved = forum_posts_unapproved + ' . (int) $posts_moved_unapproved; - $sync_sql[$forum_id][] = 'forum_posts_unapproved = forum_posts_unapproved - ' . (int) $posts_moved_unapproved; - } - if ($posts_moved_softdeleted) - { - $sync_sql[$to_forum_id][] = 'forum_posts_softdeleted = forum_posts_softdeleted + ' . (int) $posts_moved_softdeleted; - $sync_sql[$forum_id][] = 'forum_posts_softdeleted = forum_posts_softdeleted - ' . (int) $posts_moved_softdeleted; - } - - if ($topics_moved) - { - $sync_sql[$to_forum_id][] = 'forum_topics_approved = forum_topics_approved + ' . (int) $topics_moved; - if ($topics_moved - $shadow_topics > 0) - { - $sync_sql[$forum_id][] = 'forum_topics_approved = forum_topics_approved - ' . (int) ($topics_moved - $shadow_topics); - } - } - if ($topics_moved_unapproved) - { - $sync_sql[$to_forum_id][] = 'forum_topics_unapproved = forum_topics_unapproved + ' . (int) $topics_moved_unapproved; - $sync_sql[$forum_id][] = 'forum_topics_unapproved = forum_topics_unapproved - ' . (int) $topics_moved_unapproved; - } - if ($topics_moved_softdeleted) - { - $sync_sql[$to_forum_id][] = 'forum_topics_softdeleted = forum_topics_softdeleted + ' . (int) $topics_moved_softdeleted; - $sync_sql[$forum_id][] = 'forum_topics_softdeleted = forum_topics_softdeleted - ' . (int) $topics_moved_softdeleted; - } - - $success_msg = (count($topic_ids) == 1) ? 'TOPIC_MOVED_SUCCESS' : 'TOPICS_MOVED_SUCCESS'; - - foreach ($sync_sql as $forum_id_key => $array) - { - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET ' . implode(', ', $array) . ' - WHERE forum_id = ' . $forum_id_key; - $db->sql_query($sql); - } - - $db->sql_transaction('commit'); - - sync('forum', 'forum_id', array($forum_id, $to_forum_id)); - } - else - { - $template->assign_vars(array( - 'S_FORUM_SELECT' => make_forum_select($to_forum_id, $forum_id, false, true, true, true), - 'S_CAN_LEAVE_SHADOW' => true, - 'S_CAN_LOCK_TOPIC' => ($auth->acl_get('m_lock', $to_forum_id)) ? true : false, - 'ADDITIONAL_MSG' => $additional_msg) - ); - - confirm_box(false, 'MOVE_TOPIC' . ((count($topic_ids) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_move.html'); - } - - $redirect = $request->variable('redirect', "index.$phpEx"); - $redirect = reapply_sid($redirect); - - if (!$success_msg) - { - redirect($redirect); - } - else - { - meta_refresh(3, $redirect); - - $message = $user->lang[$success_msg]; - $message .= '

' . sprintf($user->lang['RETURN_PAGE'], '', ''); - $message .= '

' . sprintf($user->lang['RETURN_FORUM'], '', ''); - $message .= '

' . sprintf($user->lang['RETURN_NEW_FORUM'], '', ''); - - trigger_error($message); - } -} - -/** -* Restore Topics -*/ -function mcp_restore_topic($topic_ids) -{ - global $user, $phpEx, $phpbb_root_path, $request, $phpbb_container, $phpbb_log; - - if (!phpbb_check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array('m_approve'))) - { - return; - } - - $redirect = $request->variable('redirect', build_url(array('action', 'quickmod'))); - $forum_id = $request->variable('f', 0); - - $s_hidden_fields = build_hidden_fields(array( - 'topic_id_list' => $topic_ids, - 'f' => $forum_id, - 'action' => 'restore_topic', - 'redirect' => $redirect, - )); - $success_msg = ''; - - if (confirm_box(true)) - { - $success_msg = (count($topic_ids) == 1) ? 'TOPIC_RESTORED_SUCCESS' : 'TOPICS_RESTORED_SUCCESS'; - - $data = phpbb_get_topic_data($topic_ids); - - /* @var $phpbb_content_visibility \phpbb\content_visibility */ - $phpbb_content_visibility = $phpbb_container->get('content.visibility'); - foreach ($data as $topic_id => $row) - { - $return = $phpbb_content_visibility->set_topic_visibility(ITEM_APPROVED, $topic_id, $row['forum_id'], $user->data['user_id'], time(), ''); - if (!empty($return)) - { - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_RESTORE_TOPIC', false, array( - 'forum_id' => $row['forum_id'], - 'topic_id' => $topic_id, - $row['topic_title'], - $row['topic_first_poster_name'] - )); - } - } - } - else - { - confirm_box(false, (count($topic_ids) == 1) ? 'RESTORE_TOPIC' : 'RESTORE_TOPICS', $s_hidden_fields); - } - - $topic_id = $request->variable('t', 0); - if (!$request->is_set('quickmod', \phpbb\request\request_interface::REQUEST)) - { - $redirect = $request->variable('redirect', "index.$phpEx"); - $redirect = reapply_sid($redirect); - $redirect_message = 'PAGE'; - } - else if ($topic_id) - { - $redirect = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=' . $topic_id); - $redirect_message = 'TOPIC'; - } - else - { - $redirect = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id); - $redirect_message = 'FORUM'; - } - - if (!$success_msg) - { - redirect($redirect); - } - else - { - meta_refresh(3, $redirect); - trigger_error($user->lang[$success_msg] . '

' . sprintf($user->lang['RETURN_' . $redirect_message], '', '')); - } -} - -/** -* Delete Topics -*/ -function mcp_delete_topic($topic_ids, $is_soft = false, $soft_delete_reason = '', $action = 'delete_topic') -{ - global $auth, $user, $db, $phpEx, $phpbb_root_path, $request, $phpbb_container, $phpbb_log; - - $check_permission = ($is_soft) ? 'm_softdelete' : 'm_delete'; - if (!phpbb_check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array($check_permission))) - { - return; - } - - $redirect = $request->variable('redirect', build_url(array('action', 'quickmod'))); - $forum_id = $request->variable('f', 0); - - $s_hidden_fields = array( - 'topic_id_list' => $topic_ids, - 'f' => $forum_id, - 'action' => $action, - 'redirect' => $redirect, - ); - $success_msg = ''; - - if (confirm_box(true)) - { - $success_msg = (count($topic_ids) == 1) ? 'TOPIC_DELETED_SUCCESS' : 'TOPICS_DELETED_SUCCESS'; - - $data = phpbb_get_topic_data($topic_ids); - - foreach ($data as $topic_id => $row) - { - if ($row['topic_moved_id']) - { - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_DELETE_SHADOW_TOPIC', false, array( - 'forum_id' => $row['forum_id'], - 'topic_id' => $topic_id, - $row['topic_title'] - )); - } - else - { - // Only soft delete non-shadow topics - if ($is_soft) - { - /* @var $phpbb_content_visibility \phpbb\content_visibility */ - $phpbb_content_visibility = $phpbb_container->get('content.visibility'); - $return = $phpbb_content_visibility->set_topic_visibility(ITEM_DELETED, $topic_id, $row['forum_id'], $user->data['user_id'], time(), $soft_delete_reason); - if (!empty($return)) - { - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_SOFTDELETE_TOPIC', false, array( - 'forum_id' => $row['forum_id'], - 'topic_id' => $topic_id, - $row['topic_title'], - $row['topic_first_poster_name'], - $soft_delete_reason - )); - } - } - else - { - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_DELETE_TOPIC', false, array( - 'forum_id' => $row['forum_id'], - 'topic_id' => $topic_id, - $row['topic_title'], - $row['topic_first_poster_name'], - $soft_delete_reason - )); - } - } - } - - if (!$is_soft) - { - delete_topics('topic_id', $topic_ids); - } - } - else - { - global $template; - - $user->add_lang('posting'); - - // If there are only shadow topics, we neither need a reason nor softdelete - $sql = 'SELECT topic_id - FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', $topic_ids) . ' - AND topic_moved_id = 0'; - $result = $db->sql_query_limit($sql, 1); - $only_shadow = !$db->sql_fetchfield('topic_id'); - $db->sql_freeresult($result); - - $only_softdeleted = false; - if (!$only_shadow && $auth->acl_get('m_delete', $forum_id) && $auth->acl_get('m_softdelete', $forum_id)) - { - // If there are only soft deleted topics, we display a message why the option is not available - $sql = 'SELECT topic_id - FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', $topic_ids) . ' - AND topic_visibility <> ' . ITEM_DELETED; - $result = $db->sql_query_limit($sql, 1); - $only_softdeleted = !$db->sql_fetchfield('topic_id'); - $db->sql_freeresult($result); - } - - $template->assign_vars(array( - 'S_SHADOW_TOPICS' => $only_shadow, - 'S_SOFTDELETED' => $only_softdeleted, - 'S_TOPIC_MODE' => true, - 'S_ALLOWED_DELETE' => $auth->acl_get('m_delete', $forum_id), - 'S_ALLOWED_SOFTDELETE' => $auth->acl_get('m_softdelete', $forum_id), - 'DELETE_TOPIC_PERMANENTLY_EXPLAIN' => $user->lang('DELETE_TOPIC_PERMANENTLY', count($topic_ids)), - )); - - $count = count($topic_ids); - $l_confirm = $count === 1 ? 'DELETE_TOPIC' : 'DELETE_TOPICS'; - if ($only_softdeleted) - { - $l_confirm = array($l_confirm . '_PERMANENTLY', $count); - $s_hidden_fields['delete_permanent'] = '1'; - } - else if ($only_shadow || !$auth->acl_get('m_softdelete', $forum_id)) - { - $s_hidden_fields['delete_permanent'] = '1'; - } - - confirm_box(false, $l_confirm, build_hidden_fields($s_hidden_fields), 'confirm_delete_body.html'); - } - - $topic_id = $request->variable('t', 0); - if (!$request->is_set('quickmod', \phpbb\request\request_interface::REQUEST)) - { - $redirect = $request->variable('redirect', "index.$phpEx"); - $redirect = reapply_sid($redirect); - $redirect_message = 'PAGE'; - } - else if ($is_soft && $topic_id) - { - $redirect = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=' . $topic_id); - $redirect_message = 'TOPIC'; - } - else - { - $redirect = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id); - $redirect_message = 'FORUM'; - } - - if (!$success_msg) - { - redirect($redirect); - } - else - { - meta_refresh(3, $redirect); - trigger_error($user->lang[$success_msg] . '

' . sprintf($user->lang['RETURN_' . $redirect_message], '', '')); - } -} - -/** -* Delete Posts -*/ -function mcp_delete_post($post_ids, $is_soft = false, $soft_delete_reason = '', $action = 'delete_post') -{ - global $auth, $user, $db, $phpEx, $phpbb_root_path, $request, $phpbb_container, $phpbb_log; - - $check_permission = ($is_soft) ? 'm_softdelete' : 'm_delete'; - if (!phpbb_check_ids($post_ids, POSTS_TABLE, 'post_id', array($check_permission))) - { - return; - } - - $redirect = $request->variable('redirect', build_url(array('action', 'quickmod'))); - $forum_id = $request->variable('f', 0); - - $s_hidden_fields = array( - 'post_id_list' => $post_ids, - 'f' => $forum_id, - 'action' => $action, - 'redirect' => $redirect, - ); - $success_msg = ''; - - if (confirm_box(true) && $is_soft) - { - $post_info = phpbb_get_post_data($post_ids); - - $topic_info = $approve_log = array(); - - // Group the posts by topic_id - foreach ($post_info as $post_id => $post_data) - { - if ($post_data['post_visibility'] != ITEM_APPROVED) - { - continue; - } - $topic_id = (int) $post_data['topic_id']; - - $topic_info[$topic_id]['posts'][] = (int) $post_id; - $topic_info[$topic_id]['forum_id'] = (int) $post_data['forum_id']; - - if ($post_id == $post_data['topic_first_post_id']) - { - $topic_info[$topic_id]['first_post'] = true; - } - - if ($post_id == $post_data['topic_last_post_id']) - { - $topic_info[$topic_id]['last_post'] = true; - } - - $approve_log[] = array( - 'forum_id' => $post_data['forum_id'], - 'topic_id' => $post_data['topic_id'], - 'post_id' => $post_id, - 'post_subject' => $post_data['post_subject'], - 'poster_id' => $post_data['poster_id'], - 'post_username' => $post_data['post_username'], - 'username' => $post_data['username'], - ); - } - - /* @var $phpbb_content_visibility \phpbb\content_visibility */ - $phpbb_content_visibility = $phpbb_container->get('content.visibility'); - foreach ($topic_info as $topic_id => $topic_data) - { - $phpbb_content_visibility->set_post_visibility(ITEM_DELETED, $topic_data['posts'], $topic_id, $topic_data['forum_id'], $user->data['user_id'], time(), $soft_delete_reason, isset($topic_data['first_post']), isset($topic_data['last_post'])); - } - $affected_topics = count($topic_info); - // None of the topics is really deleted, so a redirect won't hurt much. - $deleted_topics = 0; - - $success_msg = (count($post_info) == 1) ? $user->lang['POST_DELETED_SUCCESS'] : $user->lang['POSTS_DELETED_SUCCESS']; - - foreach ($approve_log as $row) - { - $post_username = ($row['poster_id'] == ANONYMOUS && !empty($row['post_username'])) ? $row['post_username'] : $row['username']; - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_SOFTDELETE_POST', false, array( - 'forum_id' => $row['forum_id'], - 'topic_id' => $row['topic_id'], - 'post_id' => $row['post_id'], - $row['post_subject'], - $post_username, - $soft_delete_reason - )); - } - - $topic_id = $request->variable('t', 0); - - // Return links - $return_link = array(); - if ($affected_topics == 1 && $topic_id) - { - $return_link[] = sprintf($user->lang['RETURN_TOPIC'], '', ''); - } - $return_link[] = sprintf($user->lang['RETURN_FORUM'], '', ''); - - } - else if (confirm_box(true)) - { - if (!function_exists('delete_posts')) - { - include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); - } - - // Count the number of topics that are affected - // I did not use COUNT(DISTINCT ...) because I remember having problems - // with it on older versions of MySQL -- Ashe - - $sql = 'SELECT DISTINCT topic_id - FROM ' . POSTS_TABLE . ' - WHERE ' . $db->sql_in_set('post_id', $post_ids); - $result = $db->sql_query($sql); - - $topic_id_list = array(); - while ($row = $db->sql_fetchrow($result)) - { - $topic_id_list[] = $row['topic_id']; - } - $affected_topics = count($topic_id_list); - $db->sql_freeresult($result); - - $post_data = phpbb_get_post_data($post_ids); - - foreach ($post_data as $id => $row) - { - $post_username = ($row['poster_id'] == ANONYMOUS && !empty($row['post_username'])) ? $row['post_username'] : $row['username']; - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_DELETE_POST', false, array( - 'forum_id' => $row['forum_id'], - 'topic_id' => $row['topic_id'], - 'post_id' => $row['post_id'], - $row['post_subject'], - $post_username, - $soft_delete_reason - )); - } - - // Now delete the posts, topics and forums are automatically resync'ed - delete_posts('post_id', $post_ids); - - $sql = 'SELECT COUNT(topic_id) AS topics_left - FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', $topic_id_list); - $result = $db->sql_query_limit($sql, 1); - - $deleted_topics = ($row = $db->sql_fetchrow($result)) ? ($affected_topics - $row['topics_left']) : $affected_topics; - $db->sql_freeresult($result); - - $topic_id = $request->variable('t', 0); - - // Return links - $return_link = array(); - if ($affected_topics == 1 && !$deleted_topics && $topic_id) - { - $return_link[] = sprintf($user->lang['RETURN_TOPIC'], '', ''); - } - $return_link[] = sprintf($user->lang['RETURN_FORUM'], '', ''); - - if (count($post_ids) == 1) - { - if ($deleted_topics) - { - // We deleted the only post of a topic, which in turn has - // been removed from the database - $success_msg = $user->lang['TOPIC_DELETED_SUCCESS']; - } - else - { - $success_msg = $user->lang['POST_DELETED_SUCCESS']; - } - } - else - { - if ($deleted_topics) - { - // Some of topics disappeared - $success_msg = $user->lang['POSTS_DELETED_SUCCESS'] . '

' . $user->lang['EMPTY_TOPICS_REMOVED_WARNING']; - } - else - { - $success_msg = $user->lang['POSTS_DELETED_SUCCESS']; - } - } - } - else - { - global $template; - - $user->add_lang('posting'); - - $only_softdeleted = false; - if ($auth->acl_get('m_delete', $forum_id) && $auth->acl_get('m_softdelete', $forum_id)) - { - // If there are only soft deleted posts, we display a message why the option is not available - $sql = 'SELECT post_id - FROM ' . POSTS_TABLE . ' - WHERE ' . $db->sql_in_set('post_id', $post_ids) . ' - AND post_visibility <> ' . ITEM_DELETED; - $result = $db->sql_query_limit($sql, 1); - $only_softdeleted = !$db->sql_fetchfield('post_id'); - $db->sql_freeresult($result); - } - - $template->assign_vars(array( - 'S_SOFTDELETED' => $only_softdeleted, - 'S_ALLOWED_DELETE' => $auth->acl_get('m_delete', $forum_id), - 'S_ALLOWED_SOFTDELETE' => $auth->acl_get('m_softdelete', $forum_id), - 'DELETE_POST_PERMANENTLY_EXPLAIN' => $user->lang('DELETE_POST_PERMANENTLY', count($post_ids)), - )); - - $count = count($post_ids); - $l_confirm = $count === 1 ? 'DELETE_POST' : 'DELETE_POSTS'; - if ($only_softdeleted) - { - $l_confirm = array($l_confirm . '_PERMANENTLY', $count); - $s_hidden_fields['delete_permanent'] = '1'; - } - else if (!$auth->acl_get('m_softdelete', $forum_id)) - { - $s_hidden_fields['delete_permanent'] = '1'; - } - - confirm_box(false, $l_confirm, build_hidden_fields($s_hidden_fields), 'confirm_delete_body.html'); - } - - $redirect = $request->variable('redirect', "index.$phpEx"); - $redirect = reapply_sid($redirect); - - if (!$success_msg) - { - redirect($redirect); - } - else - { - if ($affected_topics != 1 || $deleted_topics || !$topic_id) - { - $redirect = append_sid("{$phpbb_root_path}mcp.$phpEx", "f=$forum_id&i=main&mode=forum_view", false); - } - - meta_refresh(3, $redirect); - trigger_error($success_msg . '

' . sprintf($user->lang['RETURN_PAGE'], '', '') . '

' . implode('

', $return_link)); - } -} - -/** -* Fork Topic -*/ -function mcp_fork_topic($topic_ids) -{ - global $auth, $user, $db, $template, $config; - global $phpEx, $phpbb_root_path, $phpbb_log, $request, $phpbb_dispatcher; - - if (!phpbb_check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array('m_'))) - { - return; - } - - $to_forum_id = $request->variable('to_forum_id', 0); - $forum_id = $request->variable('f', 0); - $redirect = $request->variable('redirect', build_url(array('action', 'quickmod'))); - $additional_msg = $success_msg = ''; - $counter = array(); - - $s_hidden_fields = build_hidden_fields(array( - 'topic_id_list' => $topic_ids, - 'f' => $forum_id, - 'action' => 'fork', - 'redirect' => $redirect) - ); - - if ($to_forum_id) - { - $forum_data = phpbb_get_forum_data($to_forum_id, 'f_post'); - - if (!count($topic_ids)) - { - $additional_msg = $user->lang['NO_TOPIC_SELECTED']; - } - else if (!count($forum_data)) - { - $additional_msg = $user->lang['FORUM_NOT_EXIST']; - } - else - { - $forum_data = $forum_data[$to_forum_id]; - - if ($forum_data['forum_type'] != FORUM_POST) - { - $additional_msg = $user->lang['FORUM_NOT_POSTABLE']; - } - else if (!$auth->acl_get('f_post', $to_forum_id)) - { - $additional_msg = $user->lang['USER_CANNOT_POST']; - } - } - } - else if (isset($_POST['confirm'])) - { - $additional_msg = $user->lang['FORUM_NOT_EXIST']; - } - - if ($additional_msg) - { - $request->overwrite('confirm', null, \phpbb\request\request_interface::POST); - $request->overwrite('confirm_key', null); - } - - if (confirm_box(true)) - { - $topic_data = phpbb_get_topic_data($topic_ids, 'f_post'); - - $total_topics = $total_topics_unapproved = $total_topics_softdeleted = 0; - $total_posts = $total_posts_unapproved = $total_posts_softdeleted = 0; - $new_topic_id_list = array(); - - foreach ($topic_data as $topic_id => $topic_row) - { - if (!isset($search_type) && $topic_row['enable_indexing']) - { - // Select the search method and do some additional checks to ensure it can actually be utilised - $search_type = $config['search_type']; - - if (!class_exists($search_type)) - { - trigger_error('NO_SUCH_SEARCH_MODULE'); - } - - $error = false; - $search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher); - $search_mode = 'post'; - - if ($error) - { - trigger_error($error); - } - } - else if (!isset($search_type) && !$topic_row['enable_indexing']) - { - $search_type = false; - } - - $sql_ary = array( - 'forum_id' => (int) $to_forum_id, - 'icon_id' => (int) $topic_row['icon_id'], - 'topic_attachment' => (int) $topic_row['topic_attachment'], - 'topic_visibility' => (int) $topic_row['topic_visibility'], - 'topic_reported' => 0, - 'topic_title' => (string) $topic_row['topic_title'], - 'topic_poster' => (int) $topic_row['topic_poster'], - 'topic_time' => (int) $topic_row['topic_time'], - 'topic_posts_approved' => (int) $topic_row['topic_posts_approved'], - 'topic_posts_unapproved' => (int) $topic_row['topic_posts_unapproved'], - 'topic_posts_softdeleted' => (int) $topic_row['topic_posts_softdeleted'], - 'topic_status' => (int) $topic_row['topic_status'], - 'topic_type' => (int) $topic_row['topic_type'], - 'topic_first_poster_name' => (string) $topic_row['topic_first_poster_name'], - 'topic_last_poster_id' => (int) $topic_row['topic_last_poster_id'], - 'topic_last_poster_name' => (string) $topic_row['topic_last_poster_name'], - 'topic_last_post_time' => (int) $topic_row['topic_last_post_time'], - 'topic_last_view_time' => (int) $topic_row['topic_last_view_time'], - 'topic_bumped' => (int) $topic_row['topic_bumped'], - 'topic_bumper' => (int) $topic_row['topic_bumper'], - 'poll_title' => (string) $topic_row['poll_title'], - 'poll_start' => (int) $topic_row['poll_start'], - 'poll_length' => (int) $topic_row['poll_length'], - 'poll_max_options' => (int) $topic_row['poll_max_options'], - 'poll_vote_change' => (int) $topic_row['poll_vote_change'], - ); - - /** - * Perform actions before forked topic is created. - * - * @event core.mcp_main_modify_fork_sql - * @var array sql_ary SQL array to be used by $db->sql_build_array - * @var array topic_row Topic data - * @since 3.1.11-RC1 - * @changed 3.1.11-RC1 Added variable: topic_row - */ - $vars = array( - 'sql_ary', - 'topic_row', - ); - extract($phpbb_dispatcher->trigger_event('core.mcp_main_modify_fork_sql', compact($vars))); - - $db->sql_query('INSERT INTO ' . TOPICS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); - $new_topic_id = $db->sql_nextid(); - $new_topic_id_list[$topic_id] = $new_topic_id; - - switch ($topic_row['topic_visibility']) - { - case ITEM_APPROVED: - $total_topics++; - break; - case ITEM_UNAPPROVED: - case ITEM_REAPPROVE: - $total_topics_unapproved++; - break; - case ITEM_DELETED: - $total_topics_softdeleted++; - break; - } - - if ($topic_row['poll_start']) - { - $sql = 'SELECT * - FROM ' . POLL_OPTIONS_TABLE . " - WHERE topic_id = $topic_id"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $sql_ary = array( - 'poll_option_id' => (int) $row['poll_option_id'], - 'topic_id' => (int) $new_topic_id, - 'poll_option_text' => (string) $row['poll_option_text'], - 'poll_option_total' => 0 - ); - - $db->sql_query('INSERT INTO ' . POLL_OPTIONS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); - } - $db->sql_freeresult($result); - } - - $sql = 'SELECT * - FROM ' . POSTS_TABLE . " - WHERE topic_id = $topic_id - ORDER BY post_time ASC, post_id ASC"; - $result = $db->sql_query($sql); - - $post_rows = array(); - while ($row = $db->sql_fetchrow($result)) - { - $post_rows[] = $row; - } - $db->sql_freeresult($result); - - if (!count($post_rows)) - { - continue; - } - - foreach ($post_rows as $row) - { - $sql_ary = array( - 'topic_id' => (int) $new_topic_id, - 'forum_id' => (int) $to_forum_id, - 'poster_id' => (int) $row['poster_id'], - 'icon_id' => (int) $row['icon_id'], - 'poster_ip' => (string) $row['poster_ip'], - 'post_time' => (int) $row['post_time'], - 'post_visibility' => (int) $row['post_visibility'], - 'post_reported' => 0, - 'enable_bbcode' => (int) $row['enable_bbcode'], - 'enable_smilies' => (int) $row['enable_smilies'], - 'enable_magic_url' => (int) $row['enable_magic_url'], - 'enable_sig' => (int) $row['enable_sig'], - 'post_username' => (string) $row['post_username'], - 'post_subject' => (string) $row['post_subject'], - 'post_text' => (string) $row['post_text'], - 'post_edit_reason' => (string) $row['post_edit_reason'], - 'post_edit_user' => (int) $row['post_edit_user'], - 'post_checksum' => (string) $row['post_checksum'], - 'post_attachment' => (int) $row['post_attachment'], - 'bbcode_bitfield' => $row['bbcode_bitfield'], - 'bbcode_uid' => (string) $row['bbcode_uid'], - 'post_edit_time' => (int) $row['post_edit_time'], - 'post_edit_count' => (int) $row['post_edit_count'], - 'post_edit_locked' => (int) $row['post_edit_locked'], - 'post_postcount' => $row['post_postcount'], - ); - // Adjust post count only if the post can be incremented to the user counter - if ($row['post_postcount']) - { - if (isset($counter[$row['poster_id']])) - { - ++$counter[$row['poster_id']]; - } - else - { - $counter[$row['poster_id']] = 1; - } - } - $db->sql_query('INSERT INTO ' . POSTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); - $new_post_id = $db->sql_nextid(); - - /** - * Perform actions after forked topic is created. - * - * @event core.mcp_main_fork_sql_after - * @var int new_topic_id The newly created topic ID - * @var int to_forum_id The forum ID where the forked topic has been moved to - * @var int new_post_id The newly created post ID - * @var array row Post data - * @since 3.2.4-RC1 - */ - $vars = array( - 'new_topic_id', - 'to_forum_id', - 'new_post_id', - 'row', - ); - extract($phpbb_dispatcher->trigger_event('core.mcp_main_fork_sql_after', compact($vars))); - - switch ($row['post_visibility']) - { - case ITEM_APPROVED: - $total_posts++; - break; - case ITEM_UNAPPROVED: - case ITEM_REAPPROVE: - $total_posts_unapproved++; - break; - case ITEM_DELETED: - $total_posts_softdeleted++; - break; - } - - // Copy whether the topic is dotted - markread('post', $to_forum_id, $new_topic_id, 0, $row['poster_id']); - - if (!empty($search_type)) - { - $search->index($search_mode, $new_post_id, $sql_ary['post_text'], $sql_ary['post_subject'], $sql_ary['poster_id'], ($topic_row['topic_type'] == POST_GLOBAL) ? 0 : $to_forum_id); - $search_mode = 'reply'; // After one we index replies - } - - // Copy Attachments - if ($row['post_attachment']) - { - $sql = 'SELECT * FROM ' . ATTACHMENTS_TABLE . " - WHERE post_msg_id = {$row['post_id']} - AND topic_id = $topic_id - AND in_message = 0"; - $result = $db->sql_query($sql); - - $sql_ary = array(); - while ($attach_row = $db->sql_fetchrow($result)) - { - $sql_ary[] = array( - 'post_msg_id' => (int) $new_post_id, - 'topic_id' => (int) $new_topic_id, - 'in_message' => 0, - 'is_orphan' => (int) $attach_row['is_orphan'], - 'poster_id' => (int) $attach_row['poster_id'], - 'physical_filename' => (string) utf8_basename($attach_row['physical_filename']), - 'real_filename' => (string) utf8_basename($attach_row['real_filename']), - 'download_count' => (int) $attach_row['download_count'], - 'attach_comment' => (string) $attach_row['attach_comment'], - 'extension' => (string) $attach_row['extension'], - 'mimetype' => (string) $attach_row['mimetype'], - 'filesize' => (int) $attach_row['filesize'], - 'filetime' => (int) $attach_row['filetime'], - 'thumbnail' => (int) $attach_row['thumbnail'] - ); - } - $db->sql_freeresult($result); - - if (count($sql_ary)) - { - $db->sql_multi_insert(ATTACHMENTS_TABLE, $sql_ary); - } - } - } - - // Copy topic subscriptions to new topic - $sql = 'SELECT user_id, notify_status - FROM ' . TOPICS_WATCH_TABLE . ' - WHERE topic_id = ' . $topic_id; - $result = $db->sql_query($sql); - - $sql_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - $sql_ary[] = array( - 'topic_id' => (int) $new_topic_id, - 'user_id' => (int) $row['user_id'], - 'notify_status' => (int) $row['notify_status'], - ); - } - $db->sql_freeresult($result); - - if (count($sql_ary)) - { - $db->sql_multi_insert(TOPICS_WATCH_TABLE, $sql_ary); - } - - // Copy bookmarks to new topic - $sql = 'SELECT user_id - FROM ' . BOOKMARKS_TABLE . ' - WHERE topic_id = ' . $topic_id; - $result = $db->sql_query($sql); - - $sql_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - $sql_ary[] = array( - 'topic_id' => (int) $new_topic_id, - 'user_id' => (int) $row['user_id'], - ); - } - $db->sql_freeresult($result); - - if (count($sql_ary)) - { - $db->sql_multi_insert(BOOKMARKS_TABLE, $sql_ary); - } - } - - // Sync new topics, parent forums and board stats - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET forum_posts_approved = forum_posts_approved + ' . $total_posts . ', - forum_posts_unapproved = forum_posts_unapproved + ' . $total_posts_unapproved . ', - forum_posts_softdeleted = forum_posts_softdeleted + ' . $total_posts_softdeleted . ', - forum_topics_approved = forum_topics_approved + ' . $total_topics . ', - forum_topics_unapproved = forum_topics_unapproved + ' . $total_topics_unapproved . ', - forum_topics_softdeleted = forum_topics_softdeleted + ' . $total_topics_softdeleted . ' - WHERE forum_id = ' . $to_forum_id; - $db->sql_query($sql); - - if (!empty($counter)) - { - // Do only one query per user and not a query per post. - foreach ($counter as $user_id => $count) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_posts = user_posts + ' . (int) $count . ' - WHERE user_id = ' . (int) $user_id; - $db->sql_query($sql); - } - } - - sync('topic', 'topic_id', $new_topic_id_list); - sync('forum', 'forum_id', $to_forum_id); - - $config->increment('num_topics', count($new_topic_id_list), false); - $config->increment('num_posts', $total_posts, false); - - foreach ($new_topic_id_list as $topic_id => $new_topic_id) - { - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_FORK', false, array( - 'forum_id' => $to_forum_id, - 'topic_id' => $new_topic_id, - $topic_row['forum_name'] - )); - } - - $success_msg = (count($topic_ids) == 1) ? 'TOPIC_FORKED_SUCCESS' : 'TOPICS_FORKED_SUCCESS'; - } - else - { - $template->assign_vars(array( - 'S_FORUM_SELECT' => make_forum_select($to_forum_id, false, false, true, true, true), - 'S_CAN_LEAVE_SHADOW' => false, - 'ADDITIONAL_MSG' => $additional_msg) - ); - - confirm_box(false, 'FORK_TOPIC' . ((count($topic_ids) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_move.html'); - } - - $redirect = $request->variable('redirect', "index.$phpEx"); - $redirect = reapply_sid($redirect); - - if (!$success_msg) - { - redirect($redirect); - } - else - { - $redirect_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id); - meta_refresh(3, $redirect_url); - $return_link = sprintf($user->lang['RETURN_FORUM'], '', ''); - - if ($forum_id != $to_forum_id) - { - $return_link .= '

' . sprintf($user->lang['RETURN_NEW_FORUM'], '', ''); - } - - trigger_error($user->lang[$success_msg] . '

' . $return_link); - } -} diff --git a/install/update/old/includes/mcp/mcp_notes.php b/install/update/old/includes/mcp/mcp_notes.php deleted file mode 100644 index a4c2356..0000000 --- a/install/update/old/includes/mcp/mcp_notes.php +++ /dev/null @@ -1,258 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* mcp_notes -* Displays notes about a user -*/ -class mcp_notes -{ - var $p_master; - var $u_action; - - function __construct($p_master) - { - $this->p_master = $p_master; - } - - function main($id, $mode) - { - global $user, $template, $request; - global $phpbb_root_path, $phpEx; - - $action = $request->variable('action', array('' => '')); - - if (is_array($action)) - { - list($action, ) = each($action); - } - - $this->page_title = 'MCP_NOTES'; - - switch ($mode) - { - case 'front': - $template->assign_vars(array( - 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=mcp&field=username&select_single=true'), - 'U_POST_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes'), - - 'L_TITLE' => $user->lang['MCP_NOTES'], - )); - - $this->tpl_name = 'mcp_notes_front'; - break; - - case 'user_notes': - $user->add_lang('acp/common'); - - $this->mcp_notes_user_view($action); - $this->tpl_name = 'mcp_notes_user'; - break; - } - } - - /** - * Display user notes - */ - function mcp_notes_user_view($action) - { - global $config, $phpbb_log, $request; - global $template, $db, $user, $auth, $phpbb_container; - - $user_id = $request->variable('u', 0); - $username = $request->variable('username', '', true); - $start = $request->variable('start', 0); - $st = $request->variable('st', 0); - $sk = $request->variable('sk', 'b'); - $sd = $request->variable('sd', 'd'); - - /* @var $pagination \phpbb\pagination */ - $pagination = $phpbb_container->get('pagination'); - - add_form_key('mcp_notes'); - - $sql_where = ($user_id) ? "user_id = $user_id" : "username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'"; - - $sql = 'SELECT * - FROM ' . USERS_TABLE . " - WHERE $sql_where"; - $result = $db->sql_query($sql); - $userrow = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$userrow) - { - trigger_error('NO_USER'); - } - - $user_id = $userrow['user_id']; - - // Populate user id to the currently active module (this module) - // The following method is another way of adjusting module urls. It is the easy variant if we want - // to directly adjust the current module url based on data retrieved within the same module. - if (strpos($this->u_action, "&u=$user_id") === false) - { - $this->p_master->adjust_url('&u=' . $user_id); - $this->u_action .= "&u=$user_id"; - } - - $deletemark = ($action == 'del_marked') ? true : false; - $deleteall = ($action == 'del_all') ? true : false; - $marked = $request->variable('marknote', array(0)); - $usernote = $request->variable('usernote', '', true); - - // Handle any actions - if (($deletemark || $deleteall) && $auth->acl_get('a_clearlogs')) - { - $where_sql = ''; - if ($deletemark && $marked) - { - $sql_in = array(); - foreach ($marked as $mark) - { - $sql_in[] = $mark; - } - $where_sql = ' AND ' . $db->sql_in_set('log_id', $sql_in); - unset($sql_in); - } - - if ($where_sql || $deleteall) - { - if (check_form_key('mcp_notes')) - { - $sql = 'DELETE FROM ' . LOG_TABLE . ' - WHERE log_type = ' . LOG_USERS . " - AND reportee_id = $user_id - $where_sql"; - $db->sql_query($sql); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_CLEAR_USER', false, array($userrow['username'])); - - $msg = ($deletemark) ? 'MARKED_NOTES_DELETED' : 'ALL_NOTES_DELETED'; - } - else - { - $msg = 'FORM_INVALID'; - } - $redirect = $this->u_action . '&u=' . $user_id; - meta_refresh(3, $redirect); - trigger_error($user->lang[$msg] . '

' . sprintf($user->lang['RETURN_PAGE'], '', '')); - } - } - - if ($usernote && $action == 'add_feedback') - { - if (check_form_key('mcp_notes')) - { - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_FEEDBACK', false, array($userrow['username'])); - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_USER_FEEDBACK', false, array( - 'forum_id' => 0, - 'topic_id' => 0, - $userrow['username'] - )); - $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_GENERAL', false, array( - 'reportee_id' => $user_id, - $usernote - )); - - $msg = $user->lang['USER_FEEDBACK_ADDED']; - } - else - { - $msg = $user->lang['FORM_INVALID']; - } - $redirect = $this->u_action; - meta_refresh(3, $redirect); - - trigger_error($msg . '

' . sprintf($user->lang['RETURN_PAGE'], '', '')); - } - - // Generate the appropriate user information for the user we are looking at - - $rank_title = $rank_img = ''; - $avatar_img = phpbb_get_user_avatar($userrow); - - $limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); - $sort_by_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_DATE'], 'c' => $user->lang['SORT_IP'], 'd' => $user->lang['SORT_ACTION']); - $sort_by_sql = array('a' => 'u.username_clean', 'b' => 'l.log_time', 'c' => 'l.log_ip', 'd' => 'l.log_operation'); - - $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; - gen_sort_selects($limit_days, $sort_by_text, $st, $sk, $sd, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); - - // Define where and sort sql for use in displaying logs - $sql_where = ($st) ? (time() - ($st * 86400)) : 0; - $sql_sort = $sort_by_sql[$sk] . ' ' . (($sd == 'd') ? 'DESC' : 'ASC'); - - $keywords = $request->variable('keywords', '', true); - $keywords_param = !empty($keywords) ? '&keywords=' . urlencode(htmlspecialchars_decode($keywords)) : ''; - - $log_data = array(); - $log_count = 0; - $start = view_log('user', $log_data, $log_count, $config['topics_per_page'], $start, 0, 0, $user_id, $sql_where, $sql_sort, $keywords); - - if ($log_count) - { - $template->assign_var('S_USER_NOTES', true); - - foreach ($log_data as $row) - { - $template->assign_block_vars('usernotes', array( - 'REPORT_BY' => $row['username_full'], - 'REPORT_AT' => $user->format_date($row['time']), - 'ACTION' => $row['action'], - 'IP' => $row['ip'], - 'ID' => $row['id']) - ); - } - } - - $base_url = $this->u_action . "&$u_sort_param$keywords_param"; - $pagination->generate_template_pagination($base_url, 'pagination', 'start', $log_count, $config['topics_per_page'], $start); - - $template->assign_vars(array( - 'U_POST_ACTION' => $this->u_action, - 'S_CLEAR_ALLOWED' => ($auth->acl_get('a_clearlogs')) ? true : false, - 'S_SELECT_SORT_DIR' => $s_sort_dir, - 'S_SELECT_SORT_KEY' => $s_sort_key, - 'S_SELECT_SORT_DAYS' => $s_limit_days, - 'S_KEYWORDS' => $keywords, - - 'L_TITLE' => $user->lang['MCP_NOTES_USER'], - - 'TOTAL_REPORTS' => $user->lang('LIST_REPORTS', (int) $log_count), - - 'RANK_TITLE' => $rank_title, - 'JOINED' => $user->format_date($userrow['user_regdate']), - 'POSTS' => ($userrow['user_posts']) ? $userrow['user_posts'] : 0, - 'WARNINGS' => ($userrow['user_warnings']) ? $userrow['user_warnings'] : 0, - - 'USERNAME_FULL' => get_username_string('full', $userrow['user_id'], $userrow['username'], $userrow['user_colour']), - 'USERNAME_COLOUR' => get_username_string('colour', $userrow['user_id'], $userrow['username'], $userrow['user_colour']), - 'USERNAME' => get_username_string('username', $userrow['user_id'], $userrow['username'], $userrow['user_colour']), - 'U_PROFILE' => get_username_string('profile', $userrow['user_id'], $userrow['username'], $userrow['user_colour']), - - 'AVATAR_IMG' => $avatar_img, - 'RANK_IMG' => $rank_img, - ) - ); - } - -} diff --git a/install/update/old/includes/mcp/mcp_topic.php b/install/update/old/includes/mcp/mcp_topic.php deleted file mode 100644 index 68a65aa..0000000 --- a/install/update/old/includes/mcp/mcp_topic.php +++ /dev/null @@ -1,812 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* View topic in MCP -*/ -function mcp_topic_view($id, $mode, $action) -{ - global $phpEx, $phpbb_root_path, $config, $request; - global $template, $db, $user, $auth, $phpbb_container, $phpbb_dispatcher; - - $url = append_sid("{$phpbb_root_path}mcp.$phpEx?" . phpbb_extra_url()); - - /* @var $pagination \phpbb\pagination */ - $pagination = $phpbb_container->get('pagination'); - $user->add_lang('viewtopic'); - - $topic_id = $request->variable('t', 0); - $topic_info = phpbb_get_topic_data(array($topic_id), false, true); - - if (!count($topic_info)) - { - trigger_error('TOPIC_NOT_EXIST'); - } - - $topic_info = $topic_info[$topic_id]; - - // Set up some vars - $icon_id = $request->variable('icon', 0); - $subject = $request->variable('subject', '', true); - $start = $request->variable('start', 0); - $sort_days_old = $request->variable('st_old', 0); - $forum_id = $request->variable('f', 0); - $to_topic_id = $request->variable('to_topic_id', 0); - $to_forum_id = $request->variable('to_forum_id', 0); - $sort = isset($_POST['sort']) ? true : false; - $submitted_id_list = $request->variable('post_ids', array(0)); - $checked_ids = $post_id_list = $request->variable('post_id_list', array(0)); - - // Resync Topic? - if ($action == 'resync') - { - if (!function_exists('mcp_resync_topics')) - { - include($phpbb_root_path . 'includes/mcp/mcp_forum.' . $phpEx); - } - mcp_resync_topics(array($topic_id)); - } - - // Split Topic? - if ($action == 'split_all' || $action == 'split_beyond') - { - if (!$sort) - { - split_topic($action, $topic_id, $to_forum_id, $subject); - } - $action = 'split'; - } - - // Merge Posts? - if ($action == 'merge_posts') - { - if (!$sort) - { - merge_posts($topic_id, $to_topic_id); - } - $action = 'merge'; - } - - if ($action == 'split' && !$subject) - { - $subject = $topic_info['topic_title']; - } - - // Restore or pprove posts? - if (($action == 'restore' || $action == 'approve') && $auth->acl_get('m_approve', $topic_info['forum_id'])) - { - if (!class_exists('mcp_queue')) - { - include($phpbb_root_path . 'includes/mcp/mcp_queue.' . $phpEx); - } - - include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx); - include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); - - if (!count($post_id_list)) - { - trigger_error('NO_POST_SELECTED'); - } - - if (!$sort) - { - mcp_queue::approve_posts($action, $post_id_list, $id, $mode); - } - } - - // Jumpbox, sort selects and that kind of things - make_jumpbox($url . "&i=$id&mode=forum_view", $topic_info['forum_id'], false, 'm_', true); - $where_sql = ($action == 'reports') ? 'WHERE post_reported = 1 AND ' : 'WHERE'; - - $sort_days = $total = 0; - $sort_key = $sort_dir = ''; - $sort_by_sql = $sort_order_sql = array(); - phpbb_mcp_sorting('viewtopic', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $topic_info['forum_id'], $topic_id, $where_sql); - - /* @var $phpbb_content_visibility \phpbb\content_visibility */ - $phpbb_content_visibility = $phpbb_container->get('content.visibility'); - $limit_time_sql = ($sort_days) ? 'AND p.post_time >= ' . (time() - ($sort_days * 86400)) : ''; - - if ($total == -1) - { - $total = $phpbb_content_visibility->get_count('topic_posts', $topic_info, $topic_info['forum_id']); - } - - $posts_per_page = max(0, $request->variable('posts_per_page', intval($config['posts_per_page']))); - if ($posts_per_page == 0) - { - $posts_per_page = $total; - } - - if ((!empty($sort_days_old) && $sort_days_old != $sort_days) || $total <= $posts_per_page) - { - $start = 0; - } - $start = $pagination->validate_start($start, $posts_per_page, $total); - - $sql = 'SELECT u.username, u.username_clean, u.user_colour, p.* - FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u - WHERE ' . (($action == 'reports') ? 'p.post_reported = 1 AND ' : '') . ' - p.topic_id = ' . $topic_id . ' - AND ' . $phpbb_content_visibility->get_visibility_sql('post', $topic_info['forum_id'], 'p.') . ' - AND p.poster_id = u.user_id ' . - $limit_time_sql . ' - ORDER BY ' . $sort_order_sql; - $result = $db->sql_query_limit($sql, $posts_per_page, $start); - - $rowset = $post_id_list = array(); - while ($row = $db->sql_fetchrow($result)) - { - $rowset[] = $row; - $post_id_list[] = $row['post_id']; - } - $db->sql_freeresult($result); - - // Get topic tracking info - if ($config['load_db_lastread']) - { - $tmp_topic_data = array($topic_id => $topic_info); - $topic_tracking_info = get_topic_tracking($topic_info['forum_id'], $topic_id, $tmp_topic_data, array($topic_info['forum_id'] => $topic_info['forum_mark_time'])); - unset($tmp_topic_data); - } - else - { - $topic_tracking_info = get_complete_topic_tracking($topic_info['forum_id'], $topic_id); - } - - $has_unapproved_posts = $has_deleted_posts = false; - - // Grab extensions - $attachments = array(); - if ($topic_info['topic_attachment'] && count($post_id_list)) - { - // Get attachments... - if ($auth->acl_get('u_download') && $auth->acl_get('f_download', $topic_info['forum_id'])) - { - $sql = 'SELECT * - FROM ' . ATTACHMENTS_TABLE . ' - WHERE ' . $db->sql_in_set('post_msg_id', $post_id_list) . ' - AND in_message = 0 - ORDER BY filetime DESC, post_msg_id ASC'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $attachments[$row['post_msg_id']][] = $row; - } - $db->sql_freeresult($result); - } - } - - /** - * Event to modify the post data for the MCP topic review before assigning the posts - * - * @event core.mcp_topic_modify_post_data - * @var array attachments List of attachments post_id => array of attachments - * @var int forum_id The forum ID we are currently in - * @var int id ID of the tab we are displaying - * @var string mode Mode of the MCP page we are displaying - * @var array post_id_list Array with post ids we are going to display - * @var array rowset Array with the posts data - * @var int topic_id The topic ID we are currently reviewing - * @since 3.1.7-RC1 - */ - $vars = array( - 'attachments', - 'forum_id', - 'id', - 'mode', - 'post_id_list', - 'rowset', - 'topic_id', - ); - extract($phpbb_dispatcher->trigger_event('core.mcp_topic_modify_post_data', compact($vars))); - - foreach ($rowset as $i => $row) - { - $message = $row['post_text']; - $post_subject = ($row['post_subject'] != '') ? $row['post_subject'] : $topic_info['topic_title']; - - $parse_flags = ($row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES; - $message = generate_text_for_display($message, $row['bbcode_uid'], $row['bbcode_bitfield'], $parse_flags, false); - - if (!empty($attachments[$row['post_id']])) - { - $update_count = array(); - parse_attachments($topic_info['forum_id'], $message, $attachments[$row['post_id']], $update_count); - } - - if ($row['post_visibility'] == ITEM_UNAPPROVED || $row['post_visibility'] == ITEM_REAPPROVE) - { - $has_unapproved_posts = true; - } - - if ($row['post_visibility'] == ITEM_DELETED) - { - $has_deleted_posts = true; - } - - $post_unread = (isset($topic_tracking_info[$topic_id]) && $row['post_time'] > $topic_tracking_info[$topic_id]) ? true : false; - - $post_row = array( - 'POST_AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), - 'POST_AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), - 'POST_AUTHOR' => get_username_string('username', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), - 'U_POST_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), - - 'POST_DATE' => $user->format_date($row['post_time']), - 'POST_SUBJECT' => $post_subject, - 'MESSAGE' => $message, - 'POST_ID' => $row['post_id'], - 'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], '', ''), - - 'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'), - - 'S_POST_REPORTED' => ($row['post_reported'] && $auth->acl_get('m_report', $topic_info['forum_id'])), - 'S_POST_UNAPPROVED' => (($row['post_visibility'] == ITEM_UNAPPROVED || $row['post_visibility'] == ITEM_REAPPROVE) && $auth->acl_get('m_approve', $topic_info['forum_id'])), - 'S_POST_DELETED' => ($row['post_visibility'] == ITEM_DELETED && $auth->acl_get('m_approve', $topic_info['forum_id'])), - 'S_CHECKED' => (($submitted_id_list && !in_array(intval($row['post_id']), $submitted_id_list)) || in_array(intval($row['post_id']), $checked_ids)) ? true : false, - 'S_HAS_ATTACHMENTS' => (!empty($attachments[$row['post_id']])) ? true : false, - - 'U_POST_DETAILS' => "$url&i=$id&p={$row['post_id']}&mode=post_details" . (($forum_id) ? "&f=$forum_id" : ''), - 'U_MCP_APPROVE' => ($auth->acl_get('m_approve', $topic_info['forum_id'])) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=approve_details&f=' . $topic_info['forum_id'] . '&p=' . $row['post_id']) : '', - 'U_MCP_REPORT' => ($auth->acl_get('m_report', $topic_info['forum_id'])) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=report_details&f=' . $topic_info['forum_id'] . '&p=' . $row['post_id']) : '', - ); - - /** - * Event to modify the template data block for topic reviews in the MCP - * - * @event core.mcp_topic_review_modify_row - * @var int id ID of the tab we are displaying - * @var string mode Mode of the MCP page we are displaying - * @var int topic_id The topic ID we are currently reviewing - * @var int forum_id The forum ID we are currently in - * @var int start Start item of this page - * @var int current_row_number Number of the post on this page - * @var array post_row Template block array of the current post - * @var array row Array with original post and user data - * @var array topic_info Array with topic data - * @var int total Total posts count - * @since 3.1.4-RC1 - */ - $vars = array( - 'id', - 'mode', - 'topic_id', - 'forum_id', - 'start', - 'current_row_number', - 'post_row', - 'row', - 'topic_info', - 'total', - ); - extract($phpbb_dispatcher->trigger_event('core.mcp_topic_review_modify_row', compact($vars))); - - $template->assign_block_vars('postrow', $post_row); - - // Display not already displayed Attachments for this post, we already parsed them. ;) - if (!empty($attachments[$row['post_id']])) - { - foreach ($attachments[$row['post_id']] as $attachment) - { - $template->assign_block_vars('postrow.attachment', array( - 'DISPLAY_ATTACHMENT' => $attachment) - ); - } - } - - unset($rowset[$i]); - } - - // Display topic icons for split topic - $s_topic_icons = false; - - if ($auth->acl_gets('m_split', 'm_merge', (int) $topic_info['forum_id'])) - { - include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx); - $s_topic_icons = posting_gen_topic_icons('', $icon_id); - - // Has the user selected a topic for merge? - if ($to_topic_id) - { - $to_topic_info = phpbb_get_topic_data(array($to_topic_id), 'm_merge'); - - if (!count($to_topic_info)) - { - $to_topic_id = 0; - } - else - { - $to_topic_info = $to_topic_info[$to_topic_id]; - - if (!$to_topic_info['enable_icons'] || $auth->acl_get('!f_icons', $topic_info['forum_id'])) - { - $s_topic_icons = false; - } - } - } - } - - $s_hidden_fields = build_hidden_fields(array( - 'st_old' => $sort_days, - 'post_ids' => $post_id_list, - )); - - $base_url = append_sid("{$phpbb_root_path}mcp.$phpEx", "i=$id&t={$topic_info['topic_id']}&mode=$mode&action=$action&to_topic_id=$to_topic_id&posts_per_page=$posts_per_page&st=$sort_days&sk=$sort_key&sd=$sort_dir"); - if ($posts_per_page) - { - $pagination->generate_template_pagination($base_url, 'pagination', 'start', $total, $posts_per_page, $start); - } - - $template->assign_vars(array( - 'TOPIC_TITLE' => $topic_info['topic_title'], - 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $topic_info['forum_id'] . '&t=' . $topic_info['topic_id']), - - 'TO_TOPIC_ID' => $to_topic_id, - 'TO_TOPIC_INFO' => ($to_topic_id) ? sprintf($user->lang['YOU_SELECTED_TOPIC'], $to_topic_id, '' . $to_topic_info['topic_title'] . '') : '', - - 'SPLIT_SUBJECT' => $subject, - 'POSTS_PER_PAGE' => $posts_per_page, - 'ACTION' => $action, - - 'REPORTED_IMG' => $user->img('icon_topic_reported', 'POST_REPORTED'), - 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'POST_UNAPPROVED'), - 'DELETED_IMG' => $user->img('icon_topic_deleted', 'POST_DELETED_RESTORE'), - 'INFO_IMG' => $user->img('icon_post_info', 'VIEW_INFO'), - - 'S_MCP_ACTION' => "$url&i=$id&mode=$mode&action=$action&start=$start", - 'S_FORUM_SELECT' => ($to_forum_id) ? make_forum_select($to_forum_id, false, false, true, true, true) : make_forum_select($topic_info['forum_id'], false, false, true, true, true), - 'S_CAN_SPLIT' => ($auth->acl_get('m_split', $topic_info['forum_id'])) ? true : false, - 'S_CAN_MERGE' => ($auth->acl_get('m_merge', $topic_info['forum_id'])) ? true : false, - 'S_CAN_DELETE' => ($auth->acl_get('m_delete', $topic_info['forum_id'])) ? true : false, - 'S_CAN_APPROVE' => ($has_unapproved_posts && $auth->acl_get('m_approve', $topic_info['forum_id'])) ? true : false, - 'S_CAN_RESTORE' => ($has_deleted_posts && $auth->acl_get('m_approve', $topic_info['forum_id'])) ? true : false, - 'S_CAN_LOCK' => ($auth->acl_get('m_lock', $topic_info['forum_id'])) ? true : false, - 'S_CAN_REPORT' => ($auth->acl_get('m_report', $topic_info['forum_id'])) ? true : false, - 'S_CAN_SYNC' => $auth->acl_get('m_', $topic_info['forum_id']), - 'S_REPORT_VIEW' => ($action == 'reports') ? true : false, - 'S_MERGE_VIEW' => ($action == 'merge') ? true : false, - 'S_SPLIT_VIEW' => ($action == 'split') ? true : false, - - 'S_HIDDEN_FIELDS' => $s_hidden_fields, - - 'S_SHOW_TOPIC_ICONS' => $s_topic_icons, - 'S_TOPIC_ICON' => $icon_id, - - 'U_SELECT_TOPIC' => "$url&i=$id&mode=forum_view&action=merge_select" . (($forum_id) ? "&f=$forum_id" : ''), - - 'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], '', ''), - 'RETURN_FORUM' => sprintf($user->lang['RETURN_FORUM'], '', ''), - - 'TOTAL_POSTS' => $user->lang('VIEW_TOPIC_POSTS', (int) $total), - )); -} - -/** -* Split topic -*/ -function split_topic($action, $topic_id, $to_forum_id, $subject) -{ - global $db, $template, $user, $phpEx, $phpbb_root_path, $auth, $config, $phpbb_log, $request, $phpbb_dispatcher; - - $post_id_list = $request->variable('post_id_list', array(0)); - $forum_id = $request->variable('forum_id', 0); - $start = $request->variable('start', 0); - - if (!count($post_id_list)) - { - $template->assign_var('MESSAGE', $user->lang['NO_POST_SELECTED']); - return; - } - - if (!phpbb_check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_split'))) - { - return; - } - - $post_id = $post_id_list[0]; - $post_info = phpbb_get_post_data(array($post_id)); - - if (!count($post_info)) - { - $template->assign_var('MESSAGE', $user->lang['NO_POST_SELECTED']); - return; - } - - $post_info = $post_info[$post_id]; - $subject = trim($subject); - - // Make some tests - if (!$subject) - { - $template->assign_var('MESSAGE', $user->lang['EMPTY_SUBJECT']); - return; - } - - if ($to_forum_id <= 0) - { - $template->assign_var('MESSAGE', $user->lang['NO_DESTINATION_FORUM']); - return; - } - - $forum_info = phpbb_get_forum_data(array($to_forum_id), 'f_post'); - - if (!count($forum_info)) - { - $template->assign_var('MESSAGE', $user->lang['USER_CANNOT_POST']); - return; - } - - $forum_info = $forum_info[$to_forum_id]; - - if ($forum_info['forum_type'] != FORUM_POST) - { - $template->assign_var('MESSAGE', $user->lang['FORUM_NOT_POSTABLE']); - return; - } - - $redirect = $request->variable('redirect', build_url(array('quickmod'))); - - $s_hidden_fields = build_hidden_fields(array( - 'i' => 'main', - 'post_id_list' => $post_id_list, - 'f' => $forum_id, - 'mode' => 'topic_view', - 'start' => $start, - 'action' => $action, - 't' => $topic_id, - 'redirect' => $redirect, - 'subject' => $subject, - 'to_forum_id' => $to_forum_id, - 'icon' => $request->variable('icon', 0)) - ); - - if (confirm_box(true)) - { - if ($action == 'split_beyond') - { - $sort_days = $total = 0; - $sort_key = $sort_dir = ''; - $sort_by_sql = $sort_order_sql = array(); - phpbb_mcp_sorting('viewtopic', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id, $topic_id); - - $limit_time_sql = ($sort_days) ? 'AND t.topic_last_post_time >= ' . (time() - ($sort_days * 86400)) : ''; - - if ($sort_order_sql[0] == 'u') - { - $sql = 'SELECT p.post_id, p.forum_id, p.post_visibility - FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . " u - WHERE p.topic_id = $topic_id - AND p.poster_id = u.user_id - $limit_time_sql - ORDER BY $sort_order_sql"; - } - else - { - $sql = 'SELECT p.post_id, p.forum_id, p.post_visibility - FROM ' . POSTS_TABLE . " p - WHERE p.topic_id = $topic_id - $limit_time_sql - ORDER BY $sort_order_sql"; - } - $result = $db->sql_query_limit($sql, 0, $start); - - $store = false; - $post_id_list = array(); - while ($row = $db->sql_fetchrow($result)) - { - // If split from selected post (split_beyond), we split the unapproved items too. - if (($row['post_visibility'] == ITEM_UNAPPROVED || $row['post_visibility'] == ITEM_REAPPROVE) && !$auth->acl_get('m_approve', $row['forum_id'])) - { -// continue; - } - - // Start to store post_ids as soon as we see the first post that was selected - if ($row['post_id'] == $post_id) - { - $store = true; - } - - if ($store) - { - $post_id_list[] = $row['post_id']; - } - } - $db->sql_freeresult($result); - } - - if (!count($post_id_list)) - { - trigger_error('NO_POST_SELECTED'); - } - - $icon_id = $request->variable('icon', 0); - - $sql_ary = array( - 'forum_id' => $to_forum_id, - 'topic_title' => $subject, - 'icon_id' => $icon_id, - 'topic_visibility' => 1 - ); - - $sql = 'INSERT INTO ' . TOPICS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); - $db->sql_query($sql); - - $to_topic_id = $db->sql_nextid(); - move_posts($post_id_list, $to_topic_id); - - $topic_info = phpbb_get_topic_data(array($topic_id)); - $topic_info = $topic_info[$topic_id]; - - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_SPLIT_DESTINATION', false, array( - 'forum_id' => $to_forum_id, - 'topic_id' => $to_topic_id, - $subject - )); - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_SPLIT_SOURCE', false, array( - 'forum_id' => $forum_id, - 'topic_id' => $topic_id, - $topic_info['topic_title'] - )); - - // Change topic title of first post - $sql = 'UPDATE ' . POSTS_TABLE . " - SET post_subject = '" . $db->sql_escape($subject) . "' - WHERE post_id = {$post_id_list[0]}"; - $db->sql_query($sql); - - // Grab data for first post in split topic - $sql_array = array( - 'SELECT' => 'p.post_id, p.forum_id, p.poster_id, p.post_text, f.enable_indexing', - 'FROM' => array( - POSTS_TABLE => 'p', - ), - 'LEFT_JOIN' => array( - array( - 'FROM' => array(FORUMS_TABLE => 'f'), - 'ON' => 'p.forum_id = f.forum_id', - ) - ), - 'WHERE' => "post_id = {$post_id_list[0]}", - ); - $sql = $db->sql_build_query('SELECT', $sql_array); - $result = $db->sql_query($sql); - $first_post_data = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - // Index first post as if it were edited - if ($first_post_data['enable_indexing']) - { - // Select the search method and do some additional checks to ensure it can actually be utilised - $search_type = $config['search_type']; - - if (!class_exists($search_type)) - { - trigger_error('NO_SUCH_SEARCH_MODULE'); - } - - $error = false; - $search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher); - - if ($error) - { - trigger_error($error); - } - - $search->index('edit', $first_post_data['post_id'], $first_post_data['post_text'], $subject, $first_post_data['poster_id'], $first_post_data['forum_id']); - } - - // Copy topic subscriptions to new topic - $sql = 'SELECT user_id, notify_status - FROM ' . TOPICS_WATCH_TABLE . ' - WHERE topic_id = ' . $topic_id; - $result = $db->sql_query($sql); - - $sql_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - $sql_ary[] = array( - 'topic_id' => (int) $to_topic_id, - 'user_id' => (int) $row['user_id'], - 'notify_status' => (int) $row['notify_status'], - ); - } - $db->sql_freeresult($result); - - if (count($sql_ary)) - { - $db->sql_multi_insert(TOPICS_WATCH_TABLE, $sql_ary); - } - - // Copy bookmarks to new topic - $sql = 'SELECT user_id - FROM ' . BOOKMARKS_TABLE . ' - WHERE topic_id = ' . $topic_id; - $result = $db->sql_query($sql); - - $sql_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - $sql_ary[] = array( - 'topic_id' => (int) $to_topic_id, - 'user_id' => (int) $row['user_id'], - ); - } - $db->sql_freeresult($result); - - if (count($sql_ary)) - { - $db->sql_multi_insert(BOOKMARKS_TABLE, $sql_ary); - } - - $success_msg = 'TOPIC_SPLIT_SUCCESS'; - - // Update forum statistics - $config->increment('num_topics', 1, false); - - // Link back to both topics - $return_link = sprintf($user->lang['RETURN_TOPIC'], '', '') . '

' . sprintf($user->lang['RETURN_NEW_TOPIC'], '', ''); - $redirect = $request->variable('redirect', "{$phpbb_root_path}viewtopic.$phpEx?f=$to_forum_id&t=$to_topic_id"); - $redirect = reapply_sid($redirect); - - meta_refresh(3, $redirect); - trigger_error($user->lang[$success_msg] . '

' . $return_link); - } - else - { - confirm_box(false, ($action == 'split_all') ? 'SPLIT_TOPIC_ALL' : 'SPLIT_TOPIC_BEYOND', $s_hidden_fields); - } -} - -/** -* Merge selected posts into selected topic -*/ -function merge_posts($topic_id, $to_topic_id) -{ - global $db, $template, $user, $phpEx, $phpbb_root_path, $phpbb_log, $request, $phpbb_dispatcher; - - if (!$to_topic_id) - { - $template->assign_var('MESSAGE', $user->lang['NO_FINAL_TOPIC_SELECTED']); - return; - } - - $sync_topics = array($topic_id, $to_topic_id); - - $topic_data = phpbb_get_topic_data($sync_topics, 'm_merge'); - - if (!count($topic_data) || empty($topic_data[$to_topic_id])) - { - $template->assign_var('MESSAGE', $user->lang['NO_FINAL_TOPIC_SELECTED']); - return; - } - - $sync_forums = array(); - foreach ($topic_data as $data) - { - $sync_forums[$data['forum_id']] = $data['forum_id']; - } - - $topic_data = $topic_data[$to_topic_id]; - - $post_id_list = $request->variable('post_id_list', array(0)); - $start = $request->variable('start', 0); - - if (!count($post_id_list)) - { - $template->assign_var('MESSAGE', $user->lang['NO_POST_SELECTED']); - return; - } - - if (!phpbb_check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_merge'))) - { - return; - } - - $redirect = $request->variable('redirect', build_url(array('quickmod'))); - - $s_hidden_fields = build_hidden_fields(array( - 'i' => 'main', - 'post_id_list' => $post_id_list, - 'to_topic_id' => $to_topic_id, - 'mode' => 'topic_view', - 'action' => 'merge_posts', - 'start' => $start, - 'redirect' => $redirect, - 't' => $topic_id) - ); - $return_link = ''; - - if (confirm_box(true)) - { - $to_forum_id = $topic_data['forum_id']; - - move_posts($post_id_list, $to_topic_id, false); - - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_MERGE', false, array( - 'forum_id' => $to_forum_id, - 'topic_id' => $to_topic_id, - $topic_data['topic_title'] - )); - - // Message and return links - $success_msg = 'POSTS_MERGED_SUCCESS'; - - // Does the original topic still exist? If yes, link back to it - $sql = 'SELECT forum_id - FROM ' . POSTS_TABLE . ' - WHERE topic_id = ' . $topic_id; - $result = $db->sql_query_limit($sql, 1); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - $return_link .= sprintf($user->lang['RETURN_TOPIC'], '', ''); - } - else - { - if (!function_exists('phpbb_update_rows_avoiding_duplicates_notify_status')) - { - include($phpbb_root_path . 'includes/functions_database_helper.' . $phpEx); - } - - // If the topic no longer exist, we will update the topic watch table. - phpbb_update_rows_avoiding_duplicates_notify_status($db, TOPICS_WATCH_TABLE, 'topic_id', array($topic_id), $to_topic_id); - - // If the topic no longer exist, we will update the bookmarks table. - phpbb_update_rows_avoiding_duplicates($db, BOOKMARKS_TABLE, 'topic_id', array($topic_id), $to_topic_id); - } - - // Re-sync the topics and forums because the auto-sync was deactivated in the call of move_posts() - sync('topic_reported', 'topic_id', $sync_topics); - sync('topic_attachment', 'topic_id', $sync_topics); - sync('topic', 'topic_id', $sync_topics, true); - sync('forum', 'forum_id', $sync_forums, true, true); - - // Link to the new topic - $return_link .= (($return_link) ? '

' : '') . sprintf($user->lang['RETURN_NEW_TOPIC'], '', ''); - $redirect = $request->variable('redirect', "{$phpbb_root_path}viewtopic.$phpEx?f=$to_forum_id&t=$to_topic_id"); - $redirect = reapply_sid($redirect); - - /** - * Perform additional actions after merging posts. - * - * @event core.mcp_topics_merge_posts_after - * @var int topic_id The topic ID from which posts are being moved - * @var int to_topic_id The topic ID to which posts are being moved - * @since 3.1.11-RC1 - */ - $vars = array( - 'topic_id', - 'to_topic_id', - ); - extract($phpbb_dispatcher->trigger_event('core.mcp_topics_merge_posts_after', compact($vars))); - - meta_refresh(3, $redirect); - trigger_error($user->lang[$success_msg] . '

' . $return_link); - } - else - { - confirm_box(false, 'MERGE_POSTS', $s_hidden_fields); - } -} diff --git a/install/update/old/includes/mcp/mcp_warn.php b/install/update/old/includes/mcp/mcp_warn.php deleted file mode 100644 index df17513..0000000 --- a/install/update/old/includes/mcp/mcp_warn.php +++ /dev/null @@ -1,610 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* mcp_warn -* Handling warning the users -*/ -class mcp_warn -{ - var $p_master; - var $u_action; - - function __construct($p_master) - { - $this->p_master = $p_master; - } - - function main($id, $mode) - { - global $request; - - $action = $request->variable('action', array('' => '')); - - if (is_array($action)) - { - list($action, ) = each($action); - } - - $this->page_title = 'MCP_WARN'; - - add_form_key('mcp_warn'); - - switch ($mode) - { - case 'front': - $this->mcp_warn_front_view(); - $this->tpl_name = 'mcp_warn_front'; - break; - - case 'list': - $this->mcp_warn_list_view($action); - $this->tpl_name = 'mcp_warn_list'; - break; - - case 'warn_post': - $this->mcp_warn_post_view($action); - $this->tpl_name = 'mcp_warn_post'; - break; - - case 'warn_user': - $this->mcp_warn_user_view($action); - $this->tpl_name = 'mcp_warn_user'; - break; - } - } - - /** - * Generates the summary on the main page of the warning module - */ - function mcp_warn_front_view() - { - global $phpEx, $phpbb_root_path; - global $template, $db, $user; - - $template->assign_vars(array( - 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=mcp&field=username&select_single=true'), - 'U_POST_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_user'), - )); - - // Obtain a list of the 5 naughtiest users.... - // These are the 5 users with the highest warning count - $highest = array(); - $count = 0; - - view_warned_users($highest, $count, 5); - - foreach ($highest as $row) - { - $template->assign_block_vars('highest', array( - 'U_NOTES' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $row['user_id']), - - 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), - - 'WARNING_TIME' => $user->format_date($row['user_last_warning']), - 'WARNINGS' => $row['user_warnings'], - )); - } - - // And now the 5 most recent users to get in trouble - $sql = 'SELECT u.user_id, u.username, u.username_clean, u.user_colour, u.user_warnings, w.warning_time - FROM ' . USERS_TABLE . ' u, ' . WARNINGS_TABLE . ' w - WHERE u.user_id = w.user_id - ORDER BY w.warning_time DESC'; - $result = $db->sql_query_limit($sql, 5); - - while ($row = $db->sql_fetchrow($result)) - { - $template->assign_block_vars('latest', array( - 'U_NOTES' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $row['user_id']), - - 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), - - 'WARNING_TIME' => $user->format_date($row['warning_time']), - 'WARNINGS' => $row['user_warnings'], - )); - } - $db->sql_freeresult($result); - } - - /** - * Lists all users with warnings - */ - function mcp_warn_list_view($action) - { - global $phpEx, $phpbb_root_path, $config, $phpbb_container; - global $template, $user, $auth, $request; - - /* @var $pagination \phpbb\pagination */ - $pagination = $phpbb_container->get('pagination'); - $user->add_lang('memberlist'); - - $start = $request->variable('start', 0); - $st = $request->variable('st', 0); - $sk = $request->variable('sk', 'b'); - $sd = $request->variable('sd', 'd'); - - $limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); - $sort_by_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_DATE'], 'c' => $user->lang['SORT_WARNINGS']); - $sort_by_sql = array('a' => 'username_clean', 'b' => 'user_last_warning', 'c' => 'user_warnings'); - - $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; - gen_sort_selects($limit_days, $sort_by_text, $st, $sk, $sd, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); - - // Define where and sort sql for use in displaying logs - $sql_where = ($st) ? (time() - ($st * 86400)) : 0; - $sql_sort = $sort_by_sql[$sk] . ' ' . (($sd == 'd') ? 'DESC' : 'ASC'); - - $users = array(); - $user_count = 0; - - view_warned_users($users, $user_count, $config['topics_per_page'], $start, $sql_where, $sql_sort); - - foreach ($users as $row) - { - $template->assign_block_vars('user', array( - 'U_NOTES' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $row['user_id']), - - 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), - - 'WARNING_TIME' => $user->format_date($row['user_last_warning']), - 'WARNINGS' => $row['user_warnings'], - )); - } - - $base_url = append_sid("{$phpbb_root_path}mcp.$phpEx", "i=warn&mode=list&st=$st&sk=$sk&sd=$sd"); - $pagination->generate_template_pagination($base_url, 'pagination', 'start', $user_count, $config['topics_per_page'], $start); - - $template->assign_vars(array( - 'U_POST_ACTION' => $this->u_action, - 'S_CLEAR_ALLOWED' => ($auth->acl_get('a_clearlogs')) ? true : false, - 'S_SELECT_SORT_DIR' => $s_sort_dir, - 'S_SELECT_SORT_KEY' => $s_sort_key, - 'S_SELECT_SORT_DAYS' => $s_limit_days, - - 'TOTAL_USERS' => $user->lang('LIST_USERS', (int) $user_count), - )); - } - - /** - * Handles warning the user when the warning is for a specific post - */ - function mcp_warn_post_view($action) - { - global $phpEx, $phpbb_root_path, $config, $request; - global $template, $db, $user, $phpbb_dispatcher; - - $post_id = $request->variable('p', 0); - $forum_id = $request->variable('f', 0); - $notify = (isset($_REQUEST['notify_user'])) ? true : false; - $warning = $request->variable('warning', '', true); - - $sql = 'SELECT u.*, p.* - FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . " u - WHERE p.post_id = $post_id - AND u.user_id = p.poster_id"; - $result = $db->sql_query($sql); - $user_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$user_row) - { - trigger_error('NO_POST'); - } - - // There is no point issuing a warning to ignored users (ie anonymous and bots) - if ($user_row['user_type'] == USER_IGNORE) - { - trigger_error('CANNOT_WARN_ANONYMOUS'); - } - - // Prevent someone from warning themselves - if ($user_row['user_id'] == $user->data['user_id']) - { - trigger_error('CANNOT_WARN_SELF'); - } - - // Check if there is already a warning for this post to prevent multiple - // warnings for the same offence - $sql = 'SELECT post_id - FROM ' . WARNINGS_TABLE . " - WHERE post_id = $post_id"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - trigger_error('ALREADY_WARNED'); - } - - $user_id = $user_row['user_id']; - - if (strpos($this->u_action, "&f=$forum_id&p=$post_id") === false) - { - $this->p_master->adjust_url("&f=$forum_id&p=$post_id"); - $this->u_action .= "&f=$forum_id&p=$post_id"; - } - - // Check if can send a notification - if ($config['allow_privmsg']) - { - $auth2 = new \phpbb\auth\auth(); - $auth2->acl($user_row); - $s_can_notify = ($auth2->acl_get('u_readpm')) ? true : false; - unset($auth2); - } - else - { - $s_can_notify = false; - } - - // Prevent against clever people - if ($notify && !$s_can_notify) - { - $notify = false; - } - - if ($warning && $action == 'add_warning') - { - if (check_form_key('mcp_warn')) - { - $s_mcp_warn_post = true; - - /** - * Event for before warning a user for a post. - * - * @event core.mcp_warn_post_before - * @var array user_row The entire user row - * @var string warning The warning message - * @var bool notify If true, we notify the user for the warning - * @var int post_id The post id for which the warning is added - * @var bool s_mcp_warn_post If true, we add the warning else we omit it - * @since 3.1.0-b4 - */ - $vars = array( - 'user_row', - 'warning', - 'notify', - 'post_id', - 's_mcp_warn_post', - ); - extract($phpbb_dispatcher->trigger_event('core.mcp_warn_post_before', compact($vars))); - - if ($s_mcp_warn_post) - { - add_warning($user_row, $warning, $notify, $post_id); - $message = $user->lang['USER_WARNING_ADDED']; - - /** - * Event for after warning a user for a post. - * - * @event core.mcp_warn_post_after - * @var array user_row The entire user row - * @var string warning The warning message - * @var bool notify If true, the user was notified for the warning - * @var int post_id The post id for which the warning is added - * @var string message Message displayed to the moderator - * @since 3.1.0-b4 - */ - $vars = array( - 'user_row', - 'warning', - 'notify', - 'post_id', - 'message', - ); - extract($phpbb_dispatcher->trigger_event('core.mcp_warn_post_after', compact($vars))); - } - } - else - { - $message = $user->lang['FORM_INVALID']; - } - - if (!empty($message)) - { - $redirect = append_sid("{$phpbb_root_path}mcp.$phpEx", "i=notes&mode=user_notes&u=$user_id"); - meta_refresh(2, $redirect); - trigger_error($message . '

' . sprintf($user->lang['RETURN_PAGE'], '', '')); - } - } - - // OK, they didn't submit a warning so lets build the page for them to do so - - // We want to make the message available here as a reminder - // Parse the message and subject - $parse_flags = OPTION_FLAG_SMILIES | ($user_row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0); - $message = generate_text_for_display($user_row['post_text'], $user_row['bbcode_uid'], $user_row['bbcode_bitfield'], $parse_flags, true); - - // Generate the appropriate user information for the user we are looking at - if (!function_exists('phpbb_get_user_rank')) - { - include($phpbb_root_path . 'includes/functions_display.' . $phpEx); - } - - $user_rank_data = phpbb_get_user_rank($user_row, $user_row['user_posts']); - $avatar_img = phpbb_get_user_avatar($user_row); - - $template->assign_vars(array( - 'U_POST_ACTION' => $this->u_action, - - 'POST' => $message, - 'USERNAME' => $user_row['username'], - 'USER_COLOR' => (!empty($user_row['user_colour'])) ? $user_row['user_colour'] : '', - 'RANK_TITLE' => $user_rank_data['title'], - 'JOINED' => $user->format_date($user_row['user_regdate']), - 'POSTS' => ($user_row['user_posts']) ? $user_row['user_posts'] : 0, - 'WARNINGS' => ($user_row['user_warnings']) ? $user_row['user_warnings'] : 0, - - 'AVATAR_IMG' => $avatar_img, - 'RANK_IMG' => $user_rank_data['img'], - - 'L_WARNING_POST_DEFAULT' => sprintf($user->lang['WARNING_POST_DEFAULT'], generate_board_url() . "/viewtopic.$phpEx?f=$forum_id&p=$post_id#p$post_id"), - - 'S_CAN_NOTIFY' => $s_can_notify, - )); - } - - /** - * Handles warning the user - */ - function mcp_warn_user_view($action) - { - global $phpEx, $phpbb_root_path, $config, $request; - global $template, $db, $user, $phpbb_dispatcher; - - $user_id = $request->variable('u', 0); - $username = $request->variable('username', '', true); - $notify = (isset($_REQUEST['notify_user'])) ? true : false; - $warning = $request->variable('warning', '', true); - - $sql_where = ($user_id) ? "user_id = $user_id" : "username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'"; - - $sql = 'SELECT * - FROM ' . USERS_TABLE . ' - WHERE ' . $sql_where; - $result = $db->sql_query($sql); - $user_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$user_row) - { - trigger_error('NO_USER'); - } - - // Prevent someone from warning themselves - if ($user_row['user_id'] == $user->data['user_id']) - { - trigger_error('CANNOT_WARN_SELF'); - } - - $user_id = $user_row['user_id']; - - if (strpos($this->u_action, "&u=$user_id") === false) - { - $this->p_master->adjust_url('&u=' . $user_id); - $this->u_action .= "&u=$user_id"; - } - - // Check if can send a notification - if ($config['allow_privmsg']) - { - $auth2 = new \phpbb\auth\auth(); - $auth2->acl($user_row); - $s_can_notify = ($auth2->acl_get('u_readpm')) ? true : false; - unset($auth2); - } - else - { - $s_can_notify = false; - } - - // Prevent against clever people - if ($notify && !$s_can_notify) - { - $notify = false; - } - - if ($warning && $action == 'add_warning') - { - if (check_form_key('mcp_warn')) - { - $s_mcp_warn_user = true; - - /** - * Event for before warning a user from MCP. - * - * @event core.mcp_warn_user_before - * @var array user_row The entire user row - * @var string warning The warning message - * @var bool notify If true, we notify the user for the warning - * @var bool s_mcp_warn_user If true, we add the warning else we omit it - * @since 3.1.0-b4 - */ - $vars = array( - 'user_row', - 'warning', - 'notify', - 's_mcp_warn_user', - ); - extract($phpbb_dispatcher->trigger_event('core.mcp_warn_user_before', compact($vars))); - - if ($s_mcp_warn_user) - { - add_warning($user_row, $warning, $notify); - $message = $user->lang['USER_WARNING_ADDED']; - - /** - * Event for after warning a user from MCP. - * - * @event core.mcp_warn_user_after - * @var array user_row The entire user row - * @var string warning The warning message - * @var bool notify If true, the user was notified for the warning - * @var string message Message displayed to the moderator - * @since 3.1.0-b4 - */ - $vars = array( - 'user_row', - 'warning', - 'notify', - 'message', - ); - extract($phpbb_dispatcher->trigger_event('core.mcp_warn_user_after', compact($vars))); - } - } - else - { - $message = $user->lang['FORM_INVALID']; - } - - if (!empty($message)) - { - $redirect = append_sid("{$phpbb_root_path}mcp.$phpEx", "i=notes&mode=user_notes&u=$user_id"); - meta_refresh(2, $redirect); - trigger_error($message . '

' . sprintf($user->lang['RETURN_PAGE'], '', '')); - } - } - - // Generate the appropriate user information for the user we are looking at - if (!function_exists('phpbb_get_user_rank')) - { - include($phpbb_root_path . 'includes/functions_display.' . $phpEx); - } - $user_rank_data = phpbb_get_user_rank($user_row, $user_row['user_posts']); - $avatar_img = phpbb_get_user_avatar($user_row); - - // OK, they didn't submit a warning so lets build the page for them to do so - $template->assign_vars(array( - 'U_POST_ACTION' => $this->u_action, - - 'RANK_TITLE' => $user_rank_data['title'], - 'JOINED' => $user->format_date($user_row['user_regdate']), - 'POSTS' => ($user_row['user_posts']) ? $user_row['user_posts'] : 0, - 'WARNINGS' => ($user_row['user_warnings']) ? $user_row['user_warnings'] : 0, - - 'USERNAME_FULL' => get_username_string('full', $user_row['user_id'], $user_row['username'], $user_row['user_colour']), - 'USERNAME_COLOUR' => get_username_string('colour', $user_row['user_id'], $user_row['username'], $user_row['user_colour']), - 'USERNAME' => get_username_string('username', $user_row['user_id'], $user_row['username'], $user_row['user_colour']), - 'U_PROFILE' => get_username_string('profile', $user_row['user_id'], $user_row['username'], $user_row['user_colour']), - - 'AVATAR_IMG' => $avatar_img, - 'RANK_IMG' => $user_rank_data['img'], - - 'S_CAN_NOTIFY' => $s_can_notify, - )); - - return $user_id; - } -} - -/** -* Insert the warning into the database -*/ -function add_warning($user_row, $warning, $send_pm = true, $post_id = 0) -{ - global $phpEx, $phpbb_root_path, $config, $phpbb_log; - global $db, $user; - - if ($send_pm) - { - include_once($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx); - include_once($phpbb_root_path . 'includes/message_parser.' . $phpEx); - - // Attempt to translate warning to language of user being warned if user's language differs from issuer's language - if ($user_row['user_lang'] != $user->lang_name) - { - $lang = array(); - - $user_row['user_lang'] = (file_exists($phpbb_root_path . 'language/' . basename($user_row['user_lang']) . "/mcp." . $phpEx)) ? $user_row['user_lang'] : $config['default_lang']; - include($phpbb_root_path . 'language/' . basename($user_row['user_lang']) . "/mcp." . $phpEx); - - $warn_pm_subject = $lang['WARNING_PM_SUBJECT']; - $warn_pm_body = sprintf($lang['WARNING_PM_BODY'], $warning); - - unset($lang); - } - else - { - $warn_pm_subject = $user->lang('WARNING_PM_SUBJECT'); - $warn_pm_body = $user->lang('WARNING_PM_BODY', $warning); - } - - $message_parser = new parse_message(); - - $message_parser->message = $warn_pm_body; - $message_parser->parse(true, true, true, false, false, true, true); - - $pm_data = array( - 'from_user_id' => $user->data['user_id'], - 'from_user_ip' => $user->ip, - 'from_username' => $user->data['username'], - 'enable_sig' => false, - 'enable_bbcode' => true, - 'enable_smilies' => true, - 'enable_urls' => false, - 'icon_id' => 0, - 'bbcode_bitfield' => $message_parser->bbcode_bitfield, - 'bbcode_uid' => $message_parser->bbcode_uid, - 'message' => $message_parser->message, - 'address_list' => array('u' => array($user_row['user_id'] => 'to')), - ); - - submit_pm('post', $warn_pm_subject, $pm_data, false); - } - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_WARNING', false, array($user_row['username'])); - $log_id = $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_WARNING_BODY', false, array( - 'reportee_id' => $user_row['user_id'], - $warning - )); - - $sql_ary = array( - 'user_id' => $user_row['user_id'], - 'post_id' => $post_id, - 'log_id' => $log_id, - 'warning_time' => time(), - ); - - $db->sql_query('INSERT INTO ' . WARNINGS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_warnings = user_warnings + 1, - user_last_warning = ' . time() . ' - WHERE user_id = ' . $user_row['user_id']; - $db->sql_query($sql); - - // We add this to the mod log too for moderators to see that a specific user got warned. - $sql = 'SELECT forum_id, topic_id - FROM ' . POSTS_TABLE . ' - WHERE post_id = ' . $post_id; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_USER_WARNING', false, array( - 'forum_id' => $row['forum_id'], - 'topic_id' => $row['topic_id'], - 'post_id' => $post_id, - $user_row['username'] - )); -} diff --git a/install/update/old/includes/message_parser.php b/install/update/old/includes/message_parser.php deleted file mode 100644 index 0b79cca..0000000 --- a/install/update/old/includes/message_parser.php +++ /dev/null @@ -1,2059 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -if (!class_exists('bbcode')) -{ - // The following lines are for extensions which include message_parser.php - // while $phpbb_root_path and $phpEx are out of the script scope - // which may lead to the 'Undefined variable' and 'failed to open stream' errors - if (!isset($phpbb_root_path)) - { - global $phpbb_root_path; - } - - if (!isset($phpEx)) - { - global $phpEx; - } - - include($phpbb_root_path . 'includes/bbcode.' . $phpEx); -} - -/** -* BBCODE FIRSTPASS -* BBCODE first pass class (functions for parsing messages for db storage) -*/ -class bbcode_firstpass extends bbcode -{ - var $message = ''; - var $warn_msg = array(); - var $parsed_items = array(); - - /** - * Parse BBCode - */ - function parse_bbcode() - { - if (!$this->bbcodes) - { - $this->bbcode_init(); - } - - global $user; - - $this->bbcode_bitfield = ''; - $bitfield = new bitfield(); - - foreach ($this->bbcodes as $bbcode_name => $bbcode_data) - { - if (isset($bbcode_data['disabled']) && $bbcode_data['disabled']) - { - foreach ($bbcode_data['regexp'] as $regexp => $replacement) - { - if (preg_match($regexp, $this->message)) - { - $this->warn_msg[] = sprintf($user->lang['UNAUTHORISED_BBCODE'] , '[' . $bbcode_name . ']'); - continue; - } - } - } - else - { - foreach ($bbcode_data['regexp'] as $regexp => $replacement) - { - // The pattern gets compiled and cached by the PCRE extension, - // it should not demand recompilation - if (preg_match($regexp, $this->message)) - { - if (is_callable($replacement)) - { - $this->message = preg_replace_callback($regexp, $replacement, $this->message); - } - else - { - $this->message = preg_replace($regexp, $replacement, $this->message); - } - $bitfield->set($bbcode_data['bbcode_id']); - } - } - } - } - - $this->bbcode_bitfield = $bitfield->get_base64(); - } - - /** - * Prepare some bbcodes for better parsing - */ - function prepare_bbcodes() - { - // Ok, seems like users instead want the no-parsing of urls, smilies, etc. after and before and within quote tags being tagged as "not a bug". - // Fine by me ;) Will ease our live... but do not come back and cry at us, we won't hear you. - - /* Add newline at the end and in front of each quote block to prevent parsing errors (urls, smilies, etc.) - if (strpos($this->message, '[quote') !== false && strpos($this->message, '[/quote]') !== false) - { - $this->message = str_replace("\r\n", "\n", $this->message); - - // We strip newlines and spaces after and before quotes in quotes (trimming) and then add exactly one newline - $this->message = preg_replace('#\[quote(=".*?")?\]\s*(.*?)\s*\[/quote\]#siu', '[quote\1]' . "\n" . '\2' ."\n[/quote]", $this->message); - } - */ - - // Add other checks which needs to be placed before actually parsing anything (be it bbcodes, smilies, urls...) - } - - /** - * Init bbcode data for later parsing - */ - function bbcode_init($allow_custom_bbcode = true) - { - global $phpbb_dispatcher; - - static $rowset; - - $bbcode_class = $this; - - // This array holds all bbcode data. BBCodes will be processed in this - // order, so it is important to keep [code] in first position and - // [quote] in second position. - // To parse multiline URL we enable dotall option setting only for URL text - // but not for link itself, thus [url][/url] is not affected. - // - // To perform custom validation in extension, use $this->validate_bbcode_by_extension() - // method which accepts variable number of parameters - $this->bbcodes = array( - 'code' => array('bbcode_id' => BBCODE_ID_CODE, 'regexp' => array('#\[code(?:=([a-z]+))?\](.+\[/code\])#uis' => function ($match) use($bbcode_class) - { - return $bbcode_class->bbcode_code($match[1], $match[2]); - } - )), - 'quote' => array('bbcode_id' => BBCODE_ID_QUOTE, 'regexp' => array('#\[quote(?:="(.*?)")?\](.+)\[/quote\]#uis' => function ($match) use($bbcode_class) - { - return $bbcode_class->bbcode_quote($match[0]); - } - )), - 'attachment' => array('bbcode_id' => BBCODE_ID_ATTACH, 'regexp' => array('#\[attachment=([0-9]+)\](.*?)\[/attachment\]#uis' => function ($match) use($bbcode_class) - { - return $bbcode_class->bbcode_attachment($match[1], $match[2]); - } - )), - 'b' => array('bbcode_id' => BBCODE_ID_B, 'regexp' => array('#\[b\](.*?)\[/b\]#uis' => function ($match) use($bbcode_class) - { - return $bbcode_class->bbcode_strong($match[1]); - } - )), - 'i' => array('bbcode_id' => BBCODE_ID_I, 'regexp' => array('#\[i\](.*?)\[/i\]#uis' => function ($match) use($bbcode_class) - { - return $bbcode_class->bbcode_italic($match[1]); - } - )), - 'url' => array('bbcode_id' => BBCODE_ID_URL, 'regexp' => array('#\[url(=(.*))?\](?(1)((?s).*(?-s))|(.*))\[/url\]#uiU' => function ($match) use($bbcode_class) - { - return $bbcode_class->validate_url($match[2], ($match[3]) ? $match[3] : $match[4]); - } - )), - 'img' => array('bbcode_id' => BBCODE_ID_IMG, 'regexp' => array('#\[img\](.*)\[/img\]#uiU' => function ($match) use($bbcode_class) - { - return $bbcode_class->bbcode_img($match[1]); - } - )), - 'size' => array('bbcode_id' => BBCODE_ID_SIZE, 'regexp' => array('#\[size=([\-\+]?\d+)\](.*?)\[/size\]#uis' => function ($match) use($bbcode_class) - { - return $bbcode_class->bbcode_size($match[1], $match[2]); - } - )), - 'color' => array('bbcode_id' => BBCODE_ID_COLOR, 'regexp' => array('!\[color=(#[0-9a-f]{3}|#[0-9a-f]{6}|[a-z\-]+)\](.*?)\[/color\]!uis' => function ($match) use($bbcode_class) - { - return $bbcode_class->bbcode_color($match[1], $match[2]); - } - )), - 'u' => array('bbcode_id' => BBCODE_ID_U, 'regexp' => array('#\[u\](.*?)\[/u\]#uis' => function ($match) use($bbcode_class) - { - return $bbcode_class->bbcode_underline($match[1]); - } - )), - 'list' => array('bbcode_id' => BBCODE_ID_LIST, 'regexp' => array('#\[list(?:=(?:[a-z0-9]|disc|circle|square))?].*\[/list]#uis' => function ($match) use($bbcode_class) - { - return $bbcode_class->bbcode_parse_list($match[0]); - } - )), - 'email' => array('bbcode_id' => BBCODE_ID_EMAIL, 'regexp' => array('#\[email=?(.*?)?\](.*?)\[/email\]#uis' => function ($match) use($bbcode_class) - { - return $bbcode_class->validate_email($match[1], $match[2]); - } - )), - 'flash' => array('bbcode_id' => BBCODE_ID_FLASH, 'regexp' => array('#\[flash=([0-9]+),([0-9]+)\](.*?)\[/flash\]#ui' => function ($match) use($bbcode_class) - { - return $bbcode_class->bbcode_flash($match[1], $match[2], $match[3]); - } - )) - ); - - // Zero the parsed items array - $this->parsed_items = array(); - - foreach ($this->bbcodes as $tag => $bbcode_data) - { - $this->parsed_items[$tag] = 0; - } - - if (!$allow_custom_bbcode) - { - return; - } - - if (!is_array($rowset)) - { - global $db; - $rowset = array(); - - $sql = 'SELECT * - FROM ' . BBCODES_TABLE; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $rowset[] = $row; - } - $db->sql_freeresult($result); - } - - foreach ($rowset as $row) - { - $this->bbcodes[$row['bbcode_tag']] = array( - 'bbcode_id' => (int) $row['bbcode_id'], - 'regexp' => array($row['first_pass_match'] => str_replace('$uid', $this->bbcode_uid, $row['first_pass_replace'])) - ); - } - - $bbcodes = $this->bbcodes; - - /** - * Event to modify the bbcode data for later parsing - * - * @event core.modify_bbcode_init - * @var array bbcodes Array of bbcode data for use in parsing - * @var array rowset Array of bbcode data from the database - * @since 3.1.0-a3 - */ - $vars = array('bbcodes', 'rowset'); - extract($phpbb_dispatcher->trigger_event('core.modify_bbcode_init', compact($vars))); - - $this->bbcodes = $bbcodes; - } - - /** - * Making some pre-checks for bbcodes as well as increasing the number of parsed items - */ - function check_bbcode($bbcode, &$in) - { - // when using the /e modifier, preg_replace slashes double-quotes but does not - // seem to slash anything else - $in = str_replace("\r\n", "\n", str_replace('\"', '"', $in)); - - // Trimming here to make sure no empty bbcodes are parsed accidently - if (trim($in) == '') - { - return false; - } - - $this->parsed_items[$bbcode]++; - - return true; - } - - /** - * Transform some characters in valid bbcodes - */ - function bbcode_specialchars($text) - { - $str_from = array('<', '>', '[', ']', '.', ':'); - $str_to = array('<', '>', '[', ']', '.', ':'); - - return str_replace($str_from, $str_to, $text); - } - - /** - * Parse size tag - */ - function bbcode_size($stx, $in) - { - global $user, $config; - - if (!$this->check_bbcode('size', $in)) - { - return $in; - } - - if ($config['max_' . $this->mode . '_font_size'] && $config['max_' . $this->mode . '_font_size'] < $stx) - { - $this->warn_msg[] = $user->lang('MAX_FONT_SIZE_EXCEEDED', (int) $config['max_' . $this->mode . '_font_size']); - - return '[size=' . $stx . ']' . $in . '[/size]'; - } - - // Do not allow size=0 - if ($stx <= 0) - { - return '[size=' . $stx . ']' . $in . '[/size]'; - } - - return '[size=' . $stx . ':' . $this->bbcode_uid . ']' . $in . '[/size:' . $this->bbcode_uid . ']'; - } - - /** - * Parse color tag - */ - function bbcode_color($stx, $in) - { - if (!$this->check_bbcode('color', $in)) - { - return $in; - } - - return '[color=' . $stx . ':' . $this->bbcode_uid . ']' . $in . '[/color:' . $this->bbcode_uid . ']'; - } - - /** - * Parse u tag - */ - function bbcode_underline($in) - { - if (!$this->check_bbcode('u', $in)) - { - return $in; - } - - return '[u:' . $this->bbcode_uid . ']' . $in . '[/u:' . $this->bbcode_uid . ']'; - } - - /** - * Parse b tag - */ - function bbcode_strong($in) - { - if (!$this->check_bbcode('b', $in)) - { - return $in; - } - - return '[b:' . $this->bbcode_uid . ']' . $in . '[/b:' . $this->bbcode_uid . ']'; - } - - /** - * Parse i tag - */ - function bbcode_italic($in) - { - if (!$this->check_bbcode('i', $in)) - { - return $in; - } - - return '[i:' . $this->bbcode_uid . ']' . $in . '[/i:' . $this->bbcode_uid . ']'; - } - - /** - * Parse img tag - */ - function bbcode_img($in) - { - global $user, $config; - - if (!$this->check_bbcode('img', $in)) - { - return $in; - } - - $in = trim($in); - $error = false; - - $in = str_replace(' ', '%20', $in); - - // Checking urls - if (!preg_match('#^' . get_preg_expression('url') . '$#iu', $in) && !preg_match('#^' . get_preg_expression('www_url') . '$#iu', $in)) - { - return '[img]' . $in . '[/img]'; - } - - // Try to cope with a common user error... not specifying a protocol but only a subdomain - if (!preg_match('#^[a-z0-9]+://#i', $in)) - { - $in = 'http://' . $in; - } - - if ($config['max_' . $this->mode . '_img_height'] || $config['max_' . $this->mode . '_img_width']) - { - $imagesize = new \FastImageSize\FastImageSize(); - $size_info = $imagesize->getImageSize(htmlspecialchars_decode($in)); - - if ($size_info === false) - { - $error = true; - $this->warn_msg[] = $user->lang['UNABLE_GET_IMAGE_SIZE']; - } - else - { - if ($config['max_' . $this->mode . '_img_height'] && $config['max_' . $this->mode . '_img_height'] < $size_info['height']) - { - $error = true; - $this->warn_msg[] = $user->lang('MAX_IMG_HEIGHT_EXCEEDED', (int) $config['max_' . $this->mode . '_img_height']); - } - - if ($config['max_' . $this->mode . '_img_width'] && $config['max_' . $this->mode . '_img_width'] < $size_info['width']) - { - $error = true; - $this->warn_msg[] = $user->lang('MAX_IMG_WIDTH_EXCEEDED', (int) $config['max_' . $this->mode . '_img_width']); - } - } - } - - if ($error || $this->path_in_domain($in)) - { - return '[img]' . $in . '[/img]'; - } - - return '[img:' . $this->bbcode_uid . ']' . $this->bbcode_specialchars($in) . '[/img:' . $this->bbcode_uid . ']'; - } - - /** - * Parse flash tag - */ - function bbcode_flash($width, $height, $in) - { - global $user, $config; - - if (!$this->check_bbcode('flash', $in)) - { - return $in; - } - - $in = trim($in); - $error = false; - - // Do not allow 0-sizes generally being entered - if ($width <= 0 || $height <= 0) - { - return '[flash=' . $width . ',' . $height . ']' . $in . '[/flash]'; - } - - $in = str_replace(' ', '%20', $in); - - // Make sure $in is a URL. - if (!preg_match('#^' . get_preg_expression('url') . '$#iu', $in) && - !preg_match('#^' . get_preg_expression('www_url') . '$#iu', $in)) - { - return '[flash=' . $width . ',' . $height . ']' . $in . '[/flash]'; - } - - // Apply the same size checks on flash files as on images - if ($config['max_' . $this->mode . '_img_height'] || $config['max_' . $this->mode . '_img_width']) - { - if ($config['max_' . $this->mode . '_img_height'] && $config['max_' . $this->mode . '_img_height'] < $height) - { - $error = true; - $this->warn_msg[] = $user->lang('MAX_FLASH_HEIGHT_EXCEEDED', (int) $config['max_' . $this->mode . '_img_height']); - } - - if ($config['max_' . $this->mode . '_img_width'] && $config['max_' . $this->mode . '_img_width'] < $width) - { - $error = true; - $this->warn_msg[] = $user->lang('MAX_FLASH_WIDTH_EXCEEDED', (int) $config['max_' . $this->mode . '_img_width']); - } - } - - if ($error || $this->path_in_domain($in)) - { - return '[flash=' . $width . ',' . $height . ']' . $in . '[/flash]'; - } - - return '[flash=' . $width . ',' . $height . ':' . $this->bbcode_uid . ']' . $this->bbcode_specialchars($in) . '[/flash:' . $this->bbcode_uid . ']'; - } - - /** - * Parse inline attachments [ia] - */ - function bbcode_attachment($stx, $in) - { - if (!$this->check_bbcode('attachment', $in)) - { - return $in; - } - - return '[attachment=' . $stx . ':' . $this->bbcode_uid . ']' . trim($in) . '[/attachment:' . $this->bbcode_uid . ']'; - } - - /** - * Parse code text from code tag - * @access private - */ - function bbcode_parse_code($stx, &$code) - { - switch (strtolower($stx)) - { - case 'php': - - $remove_tags = false; - - $str_from = array('<', '>', '[', ']', '.', ':', ':'); - $str_to = array('<', '>', '[', ']', '.', ':', ':'); - $code = str_replace($str_from, $str_to, $code); - - if (!preg_match('/\<\?.*?\?\>/is', $code)) - { - $remove_tags = true; - $code = ""; - } - - $conf = array('highlight.bg', 'highlight.comment', 'highlight.default', 'highlight.html', 'highlight.keyword', 'highlight.string'); - foreach ($conf as $ini_var) - { - @ini_set($ini_var, str_replace('highlight.', 'syntax', $ini_var)); - } - - // Because highlight_string is specialcharing the text (but we already did this before), we have to reverse this in order to get correct results - $code = htmlspecialchars_decode($code); - $code = highlight_string($code, true); - - $str_from = array('', '', '','[', ']', '.', ':'); - $str_to = array('', '', '', '[', ']', '.', ':'); - - if ($remove_tags) - { - $str_from[] = '<?php '; - $str_to[] = ''; - $str_from[] = '<?php '; - $str_to[] = ''; - } - - $code = str_replace($str_from, $str_to, $code); - $code = preg_replace('#^()\n?(.*?)\n?()$#is', '$1$2$3', $code); - - if ($remove_tags) - { - $code = preg_replace('#()?\?>()#', '$1 $2', $code); - } - - $code = preg_replace('#^(.*)#s', '$2', $code); - $code = preg_replace('#(?:\s++| )*+$#u', '', $code); - - // remove newline at the end - if (!empty($code) && substr($code, -1) == "\n") - { - $code = substr($code, 0, -1); - } - - return "[code=$stx:" . $this->bbcode_uid . ']' . $code . '[/code:' . $this->bbcode_uid . ']'; - break; - - default: - return '[code:' . $this->bbcode_uid . ']' . $this->bbcode_specialchars($code) . '[/code:' . $this->bbcode_uid . ']'; - break; - } - } - - /** - * Parse code tag - * Expects the argument to start right after the opening [code] tag and to end with [/code] - */ - function bbcode_code($stx, $in) - { - if (!$this->check_bbcode('code', $in)) - { - return $in; - } - - // We remove the hardcoded elements from the code block here because it is not used in code blocks - // Having it here saves us one preg_replace per message containing [code] blocks - // Additionally, magic url parsing should go after parsing bbcodes, but for safety those are stripped out too... - $htm_match = get_preg_expression('bbcode_htm'); - unset($htm_match[4], $htm_match[5]); - $htm_replace = array('\1', '\1', '\2', '\1'); - - $out = $code_block = ''; - $open = 1; - - while ($in) - { - // Determine position and tag length of next code block - preg_match('#(.*?)(\[code(?:=([a-z]+))?\])(.+)#is', $in, $buffer); - $pos = (isset($buffer[1])) ? strlen($buffer[1]) : false; - $tag_length = (isset($buffer[2])) ? strlen($buffer[2]) : false; - - // Determine position of ending code tag - $pos2 = stripos($in, '[/code]'); - - // Which is the next block, ending code or code block - if ($pos !== false && $pos < $pos2) - { - // Open new block - if (!$open) - { - $out .= substr($in, 0, $pos); - $in = substr($in, $pos); - $stx = (isset($buffer[3])) ? $buffer[3] : ''; - $code_block = ''; - } - else - { - // Already opened block, just append to the current block - $code_block .= substr($in, 0, $pos) . ((isset($buffer[2])) ? $buffer[2] : ''); - $in = substr($in, $pos); - } - - $in = substr($in, $tag_length); - $open++; - } - else - { - // Close the block - if ($open == 1) - { - $code_block .= substr($in, 0, $pos2); - $code_block = preg_replace($htm_match, $htm_replace, $code_block); - - // Parse this code block - $out .= $this->bbcode_parse_code($stx, $code_block); - $code_block = ''; - $open--; - } - else if ($open) - { - // Close one open tag... add to the current code block - $code_block .= substr($in, 0, $pos2 + 7); - $open--; - } - else - { - // end code without opening code... will be always outside code block - $out .= substr($in, 0, $pos2 + 7); - } - - $in = substr($in, $pos2 + 7); - } - } - - // if now $code_block has contents we need to parse the remaining code while removing the last closing tag to match up. - if ($code_block) - { - $code_block = substr($code_block, 0, -7); - $code_block = preg_replace($htm_match, $htm_replace, $code_block); - - $out .= $this->bbcode_parse_code($stx, $code_block); - } - - return $out; - } - - /** - * Parse list bbcode - * Expects the argument to start with a tag - */ - function bbcode_parse_list($in) - { - if (!$this->check_bbcode('list', $in)) - { - return $in; - } - - // $tok holds characters to stop at. Since the string starts with a '[' we'll get everything up to the first ']' which should be the opening [list] tag - $tok = ']'; - $out = '['; - - // First character is [ - $in = substr($in, 1); - $list_end_tags = $item_end_tags = array(); - - do - { - $pos = strlen($in); - - for ($i = 0, $tok_len = strlen($tok); $i < $tok_len; ++$i) - { - $tmp_pos = strpos($in, $tok[$i]); - - if ($tmp_pos !== false && $tmp_pos < $pos) - { - $pos = $tmp_pos; - } - } - - $buffer = substr($in, 0, $pos); - $tok = $in[$pos]; - - $in = substr($in, $pos + 1); - - if ($tok == ']') - { - // if $tok is ']' the buffer holds a tag - if (strtolower($buffer) == '/list' && count($list_end_tags)) - { - // valid [/list] tag, check nesting so that we don't hit false positives - if (count($item_end_tags) && count($item_end_tags) >= count($list_end_tags)) - { - // current li tag has not been closed - $out = preg_replace('/\n?\[$/', '[', $out) . array_pop($item_end_tags) . ']['; - } - - $out .= array_pop($list_end_tags) . ']'; - $tok = '['; - } - else if (preg_match('#^list(=[0-9a-z]+)?$#i', $buffer, $m)) - { - // sub-list, add a closing tag - if (empty($m[1]) || preg_match('/^=(?:disc|square|circle)$/i', $m[1])) - { - array_push($list_end_tags, '/list:u:' . $this->bbcode_uid); - } - else - { - array_push($list_end_tags, '/list:o:' . $this->bbcode_uid); - } - $out .= 'list' . substr($buffer, 4) . ':' . $this->bbcode_uid . ']'; - $tok = '['; - } - else - { - if (($buffer == '*' || substr($buffer, -2) == '[*') && count($list_end_tags)) - { - // the buffer holds a bullet tag and we have a [list] tag open - if (count($item_end_tags) >= count($list_end_tags)) - { - if (substr($buffer, -2) == '[*') - { - $out .= substr($buffer, 0, -2) . '['; - } - // current li tag has not been closed - if (preg_match('/\n\[$/', $out, $m)) - { - $out = preg_replace('/\n\[$/', '[', $out); - $buffer = array_pop($item_end_tags) . "]\n[*:" . $this->bbcode_uid; - } - else - { - $buffer = array_pop($item_end_tags) . '][*:' . $this->bbcode_uid; - } - } - else - { - $buffer = '*:' . $this->bbcode_uid; - } - - $item_end_tags[] = '/*:m:' . $this->bbcode_uid; - } - else if ($buffer == '/*') - { - array_pop($item_end_tags); - $buffer = '/*:' . $this->bbcode_uid; - } - - $out .= $buffer . $tok; - $tok = '[]'; - } - } - else - { - // Not within a tag, just add buffer to the return string - $out .= $buffer . $tok; - $tok = ($tok == '[') ? ']' : '[]'; - } - } - while ($in); - - // do we have some tags open? close them now - if (count($item_end_tags)) - { - $out .= '[' . implode('][', $item_end_tags) . ']'; - } - if (count($list_end_tags)) - { - $out .= '[' . implode('][', $list_end_tags) . ']'; - } - - return $out; - } - - /** - * Parse quote bbcode - * Expects the argument to start with a tag - */ - function bbcode_quote($in) - { - $in = str_replace("\r\n", "\n", str_replace('\"', '"', trim($in))); - - if (!$in) - { - return ''; - } - - // To let the parser not catch tokens within quote_username quotes we encode them before we start this... - $in = preg_replace_callback('#quote="(.*?)"\]#i', function ($match) { - return 'quote="' . str_replace(array('[', ']', '\\\"'), array('[', ']', '\"'), $match[1]) . '"]'; - }, $in); - - $tok = ']'; - $out = '['; - - $in = substr($in, 1); - $close_tags = $error_ary = array(); - $buffer = ''; - - do - { - $pos = strlen($in); - for ($i = 0, $tok_len = strlen($tok); $i < $tok_len; ++$i) - { - $tmp_pos = strpos($in, $tok[$i]); - if ($tmp_pos !== false && $tmp_pos < $pos) - { - $pos = $tmp_pos; - } - } - - $buffer .= substr($in, 0, $pos); - $tok = $in[$pos]; - $in = substr($in, $pos + 1); - - if ($tok == ']') - { - if (strtolower($buffer) == '/quote' && count($close_tags) && substr($out, -1, 1) == '[') - { - // we have found a closing tag - $out .= array_pop($close_tags) . ']'; - $tok = '['; - $buffer = ''; - - /* Add space at the end of the closing tag if not happened before to allow following urls/smilies to be parsed correctly - * Do not try to think for the user. :/ Do not parse urls/smilies if there is no space - is the same as with other bbcodes too. - * Also, we won't have any spaces within $in anyway, only adding up spaces -> #10982 - if (!$in || $in[0] !== ' ') - { - $out .= ' '; - }*/ - } - else if (preg_match('#^quote(?:="(.*?)")?$#is', $buffer, $m) && substr($out, -1, 1) == '[') - { - $this->parsed_items['quote']++; - array_push($close_tags, '/quote:' . $this->bbcode_uid); - - if (isset($m[1]) && $m[1]) - { - $username = str_replace(array('[', ']'), array('[', ']'), $m[1]); - $username = preg_replace('#\[(?!b|i|u|color|url|email|/b|/i|/u|/color|/url|/email)#iU', '[$1', $username); - - $end_tags = array(); - $error = false; - - preg_match_all('#\[((?:/)?(?:[a-z]+))#i', $username, $tags); - foreach ($tags[1] as $tag) - { - if ($tag[0] != '/') - { - $end_tags[] = '/' . $tag; - } - else - { - $end_tag = array_pop($end_tags); - $error = ($end_tag != $tag) ? true : false; - } - } - - if ($error) - { - $username = $m[1]; - } - - $out .= 'quote="' . $username . '":' . $this->bbcode_uid . ']'; - } - else - { - $out .= 'quote:' . $this->bbcode_uid . ']'; - } - - $tok = '['; - $buffer = ''; - } - else if (preg_match('#^quote="(.*?)#is', $buffer, $m)) - { - // the buffer holds an invalid opening tag - $buffer .= ']'; - } - else - { - $out .= $buffer . $tok; - $tok = '[]'; - $buffer = ''; - } - } - else - { -/** -* Old quote code working fine, but having errors listed in bug #3572 -* -* $out .= $buffer . $tok; -* $tok = ($tok == '[') ? ']' : '[]'; -* $buffer = ''; -*/ - - $out .= $buffer . $tok; - - if ($tok == '[') - { - // Search the text for the next tok... if an ending quote comes first, then change tok to [] - $pos1 = stripos($in, '[/quote'); - // If the token ] comes first, we change it to ] - $pos2 = strpos($in, ']'); - // If the token [ comes first, we change it to [ - $pos3 = strpos($in, '['); - - if ($pos1 !== false && ($pos2 === false || $pos1 < $pos2) && ($pos3 === false || $pos1 < $pos3)) - { - $tok = '[]'; - } - else if ($pos3 !== false && ($pos2 === false || $pos3 < $pos2)) - { - $tok = '['; - } - else - { - $tok = ']'; - } - } - else - { - $tok = '[]'; - } - $buffer = ''; - } - } - while ($in); - - $out .= $buffer; - - if (count($close_tags)) - { - $out .= '[' . implode('][', $close_tags) . ']'; - } - - foreach ($error_ary as $error_msg) - { - $this->warn_msg[] = $error_msg; - } - - return $out; - } - - /** - * Validate email - */ - function validate_email($var1, $var2) - { - $var1 = str_replace("\r\n", "\n", str_replace('\"', '"', trim($var1))); - $var2 = str_replace("\r\n", "\n", str_replace('\"', '"', trim($var2))); - - $txt = $var2; - $email = ($var1) ? $var1 : $var2; - - $validated = true; - - if (!preg_match('/^' . get_preg_expression('email') . '$/i', $email)) - { - $validated = false; - } - - if (!$validated) - { - return '[email' . (($var1) ? "=$var1" : '') . ']' . $var2 . '[/email]'; - } - - $this->parsed_items['email']++; - - if ($var1) - { - $retval = '[email=' . $this->bbcode_specialchars($email) . ':' . $this->bbcode_uid . ']' . $txt . '[/email:' . $this->bbcode_uid . ']'; - } - else - { - $retval = '[email:' . $this->bbcode_uid . ']' . $this->bbcode_specialchars($email) . '[/email:' . $this->bbcode_uid . ']'; - } - - return $retval; - } - - /** - * Validate url - * - * @param string $var1 optional url parameter for url bbcode: [url(=$var1)]$var2[/url] - * @param string $var2 url bbcode content: [url(=$var1)]$var2[/url] - */ - function validate_url($var1, $var2) - { - $var1 = str_replace("\r\n", "\n", str_replace('\"', '"', trim($var1))); - $var2 = str_replace("\r\n", "\n", str_replace('\"', '"', trim($var2))); - - $url = ($var1) ? $var1 : $var2; - - if ($var1 && !$var2) - { - $var2 = $var1; - } - - if (!$url) - { - return '[url' . (($var1) ? '=' . $var1 : '') . ']' . $var2 . '[/url]'; - } - - $valid = false; - - $url = str_replace(' ', '%20', $url); - - // Checking urls - if (preg_match('#^' . get_preg_expression('url') . '$#iu', $url) || - preg_match('#^' . get_preg_expression('www_url') . '$#iu', $url) || - preg_match('#^' . preg_quote(generate_board_url(), '#') . get_preg_expression('relative_url') . '$#iu', $url)) - { - $valid = true; - } - - if ($valid) - { - $this->parsed_items['url']++; - - // if there is no scheme, then add http schema - if (!preg_match('#^[a-z][a-z\d+\-.]*:/{2}#i', $url)) - { - $url = 'http://' . $url; - } - - // Is this a link to somewhere inside this board? If so then remove the session id from the url - if (strpos($url, generate_board_url()) !== false && strpos($url, 'sid=') !== false) - { - $url = preg_replace('/(&|\?)sid=[0-9a-f]{32}&/', '\1', $url); - $url = preg_replace('/(&|\?)sid=[0-9a-f]{32}$/', '', $url); - $url = append_sid($url); - } - - return ($var1) ? '[url=' . $this->bbcode_specialchars($url) . ':' . $this->bbcode_uid . ']' . $var2 . '[/url:' . $this->bbcode_uid . ']' : '[url:' . $this->bbcode_uid . ']' . $this->bbcode_specialchars($url) . '[/url:' . $this->bbcode_uid . ']'; - } - - return '[url' . (($var1) ? '=' . $var1 : '') . ']' . $var2 . '[/url]'; - } - - /** - * Check if url is pointing to this domain/script_path/php-file - * - * @param string $url the url to check - * @return true if the url is pointing to this domain/script_path/php-file, false if not - * - * @access private - */ - function path_in_domain($url) - { - global $config, $phpEx, $user; - - if ($config['force_server_vars']) - { - $check_path = !empty($config['script_path']) ? $config['script_path'] : '/'; - } - else - { - $check_path = ($user->page['root_script_path'] != '/') ? substr($user->page['root_script_path'], 0, -1) : '/'; - } - - // Is the user trying to link to a php file in this domain and script path? - if (strpos($url, ".{$phpEx}") !== false && strpos($url, $check_path) !== false) - { - $server_name = $user->host; - - // Forcing server vars is the only way to specify/override the protocol - if ($config['force_server_vars'] || !$server_name) - { - $server_name = $config['server_name']; - } - - // Check again in correct order... - $pos_ext = strpos($url, ".{$phpEx}"); - $pos_path = strpos($url, $check_path); - $pos_domain = strpos($url, $server_name); - - if ($pos_domain !== false && $pos_path >= $pos_domain && $pos_ext >= $pos_path) - { - // Ok, actually we allow linking to some files (this may be able to be extended in some way later...) - if (strpos($url, '/' . $check_path . '/download/file.' . $phpEx) !== 0) - { - return false; - } - - return true; - } - } - - return false; - } -} - -/** -* Main message parser for posting, pm, etc. takes raw message -* and parses it for attachments, bbcode and smilies -*/ -class parse_message extends bbcode_firstpass -{ - var $attachment_data = array(); - var $filename_data = array(); - - // Helps ironing out user error - var $message_status = ''; - - var $allow_img_bbcode = true; - var $allow_flash_bbcode = true; - var $allow_quote_bbcode = true; - var $allow_url_bbcode = true; - - var $mode; - - /** - * The plupload object used for dealing with attachments - * @var \phpbb\plupload\plupload - */ - protected $plupload; - - /** - * Init - give message here or manually - */ - function __construct($message = '') - { - // Init BBCode UID - $this->bbcode_uid = substr(base_convert(unique_id(), 16, 36), 0, BBCODE_UID_LEN); - $this->message = $message; - } - - /** - * Parse Message - */ - function parse($allow_bbcode, $allow_magic_url, $allow_smilies, $allow_img_bbcode = true, $allow_flash_bbcode = true, $allow_quote_bbcode = true, $allow_url_bbcode = true, $update_this_message = true, $mode = 'post') - { - global $config, $user, $phpbb_dispatcher, $phpbb_container; - - $this->mode = $mode; - - foreach (array('chars', 'smilies', 'urls', 'font_size', 'img_height', 'img_width') as $key) - { - if (!isset($config['max_' . $mode . '_' . $key])) - { - $config['max_' . $mode . '_' . $key] = 0; - } - } - - $this->allow_img_bbcode = $allow_img_bbcode; - $this->allow_flash_bbcode = $allow_flash_bbcode; - $this->allow_quote_bbcode = $allow_quote_bbcode; - $this->allow_url_bbcode = $allow_url_bbcode; - - // If false, then $this->message won't be altered, the text will be returned instead. - if (!$update_this_message) - { - $tmp_message = $this->message; - $return_message = &$this->message; - } - - if ($this->message_status == 'display') - { - $this->decode_message(); - } - - // Store message length... - $message_length = ($mode == 'post') ? utf8_strlen($this->message) : utf8_strlen(preg_replace('#\[\/?[a-z\*\+\-]+(=[\S]+)?\]#ius', ' ', $this->message)); - - // Maximum message length check. 0 disables this check completely. - if ((int) $config['max_' . $mode . '_chars'] > 0 && $message_length > (int) $config['max_' . $mode . '_chars']) - { - $this->warn_msg[] = $user->lang('CHARS_' . strtoupper($mode) . '_CONTAINS', $message_length) . '
' . $user->lang('TOO_MANY_CHARS_LIMIT', (int) $config['max_' . $mode . '_chars']); - return (!$update_this_message) ? $return_message : $this->warn_msg; - } - - // Minimum message length check for post only - if ($mode === 'post') - { - if (!$message_length || $message_length < (int) $config['min_post_chars']) - { - $this->warn_msg[] = (!$message_length) ? $user->lang['TOO_FEW_CHARS'] : ($user->lang('CHARS_POST_CONTAINS', $message_length) . '
' . $user->lang('TOO_FEW_CHARS_LIMIT', (int) $config['min_post_chars'])); - return (!$update_this_message) ? $return_message : $this->warn_msg; - } - } - - /** - * This event can be used for additional message checks/cleanup before parsing - * - * @event core.message_parser_check_message - * @var bool allow_bbcode Do we allow BBCodes - * @var bool allow_magic_url Do we allow magic urls - * @var bool allow_smilies Do we allow smilies - * @var bool allow_img_bbcode Do we allow image BBCode - * @var bool allow_flash_bbcode Do we allow flash BBCode - * @var bool allow_quote_bbcode Do we allow quote BBCode - * @var bool allow_url_bbcode Do we allow url BBCode - * @var bool update_this_message Do we alter the parsed message - * @var string mode Posting mode - * @var string message The message text to parse - * @var string bbcode_bitfield The bbcode_bitfield before parsing - * @var string bbcode_uid The bbcode_uid before parsing - * @var bool return Do we return after the event is triggered if $warn_msg is not empty - * @var array warn_msg Array of the warning messages - * @since 3.1.2-RC1 - * @changed 3.1.3-RC1 Added vars $bbcode_bitfield and $bbcode_uid - */ - $message = $this->message; - $warn_msg = $this->warn_msg; - $return = false; - $bbcode_bitfield = $this->bbcode_bitfield; - $bbcode_uid = $this->bbcode_uid; - $vars = array( - 'allow_bbcode', - 'allow_magic_url', - 'allow_smilies', - 'allow_img_bbcode', - 'allow_flash_bbcode', - 'allow_quote_bbcode', - 'allow_url_bbcode', - 'update_this_message', - 'mode', - 'message', - 'bbcode_bitfield', - 'bbcode_uid', - 'return', - 'warn_msg', - ); - extract($phpbb_dispatcher->trigger_event('core.message_parser_check_message', compact($vars))); - $this->message = $message; - $this->warn_msg = $warn_msg; - $this->bbcode_bitfield = $bbcode_bitfield; - $this->bbcode_uid = $bbcode_uid; - if ($return && !empty($this->warn_msg)) - { - return (!$update_this_message) ? $return_message : $this->warn_msg; - } - - // Get the parser - $parser = $phpbb_container->get('text_formatter.parser'); - - // Set the parser's options - ($allow_bbcode) ? $parser->enable_bbcodes() : $parser->disable_bbcodes(); - ($allow_magic_url) ? $parser->enable_magic_url() : $parser->disable_magic_url(); - ($allow_smilies) ? $parser->enable_smilies() : $parser->disable_smilies(); - ($allow_img_bbcode) ? $parser->enable_bbcode('img') : $parser->disable_bbcode('img'); - ($allow_flash_bbcode) ? $parser->enable_bbcode('flash') : $parser->disable_bbcode('flash'); - ($allow_quote_bbcode) ? $parser->enable_bbcode('quote') : $parser->disable_bbcode('quote'); - ($allow_url_bbcode) ? $parser->enable_bbcode('url') : $parser->disable_bbcode('url'); - - // Set some config values - $parser->set_vars(array( - 'max_font_size' => $config['max_' . $this->mode . '_font_size'], - 'max_img_height' => $config['max_' . $this->mode . '_img_height'], - 'max_img_width' => $config['max_' . $this->mode . '_img_width'], - 'max_smilies' => $config['max_' . $this->mode . '_smilies'], - 'max_urls' => $config['max_' . $this->mode . '_urls'] - )); - - // Parse this message - $this->message = $parser->parse(htmlspecialchars_decode($this->message, ENT_QUOTES)); - - // Remove quotes that are nested too deep - if ($config['max_quote_depth'] > 0) - { - $this->remove_nested_quotes($config['max_quote_depth']); - } - - // Check for "empty" message. We do not check here for maximum length, because bbcode, smilies, etc. can add to the length. - // The maximum length check happened before any parsings. - if ($mode === 'post' && utf8_clean_string($this->message) === '') - { - $this->warn_msg[] = $user->lang['TOO_FEW_CHARS']; - return (!$update_this_message) ? $return_message : $this->warn_msg; - } - - // Remove quotes that are nested too deep - if ($config['max_quote_depth'] > 0) - { - $this->message = $phpbb_container->get('text_formatter.utils')->remove_bbcode( - $this->message, - 'quote', - $config['max_quote_depth'] - ); - } - - // Check for errors - $errors = $parser->get_errors(); - if ($errors) - { - foreach ($errors as $i => $args) - { - // Translate each error with $user->lang() - $errors[$i] = call_user_func_array(array($user, 'lang'), $args); - } - $this->warn_msg = array_merge($this->warn_msg, $errors); - - return (!$update_this_message) ? $return_message : $this->warn_msg; - } - - if (!$update_this_message) - { - unset($this->message); - $this->message = $tmp_message; - return $return_message; - } - - $this->message_status = 'parsed'; - return false; - } - - /** - * Formatting text for display - */ - function format_display($allow_bbcode, $allow_magic_url, $allow_smilies, $update_this_message = true) - { - global $phpbb_container, $phpbb_dispatcher; - - // If false, then the parsed message get returned but internal message not processed. - if (!$update_this_message) - { - $tmp_message = $this->message; - $return_message = &$this->message; - } - - $text = $this->message; - $uid = $this->bbcode_uid; - - /** - * Event to modify the text before it is parsed - * - * @event core.modify_format_display_text_before - * @var string text The message text to parse - * @var string uid The bbcode uid - * @var bool allow_bbcode Do we allow bbcodes - * @var bool allow_magic_url Do we allow magic urls - * @var bool allow_smilies Do we allow smilies - * @var bool update_this_message Do we update the internal message - * with the parsed result - * @since 3.1.6-RC1 - */ - $vars = array('text', 'uid', 'allow_bbcode', 'allow_magic_url', 'allow_smilies', 'update_this_message'); - extract($phpbb_dispatcher->trigger_event('core.modify_format_display_text_before', compact($vars))); - - $this->message = $text; - $this->bbcode_uid = $uid; - unset($text, $uid); - - // NOTE: message_status is unreliable for detecting unparsed text because some callers - // change $this->message without resetting $this->message_status to 'plain' so we - // inspect the message instead - //if ($this->message_status == 'plain') - if (!preg_match('/^<[rt][ >]/', $this->message)) - { - // Force updating message - of course. - $this->parse($allow_bbcode, $allow_magic_url, $allow_smilies, $this->allow_img_bbcode, $this->allow_flash_bbcode, $this->allow_quote_bbcode, $this->allow_url_bbcode, true); - } - - // There's a bug when previewing a topic with no poll, because the empty title of the poll - // gets parsed but $this->message still ends up empty. This fixes it, until a proper fix is - // devised - if ($this->message === '') - { - $this->message = $phpbb_container->get('text_formatter.parser')->parse($this->message); - } - - $this->message = $phpbb_container->get('text_formatter.renderer')->render($this->message); - - $text = $this->message; - $uid = $this->bbcode_uid; - - /** - * Event to modify the text after it is parsed - * - * @event core.modify_format_display_text_after - * @var string text The message text to parse - * @var string uid The bbcode uid - * @var bool allow_bbcode Do we allow bbcodes - * @var bool allow_magic_url Do we allow magic urls - * @var bool allow_smilies Do we allow smilies - * @var bool update_this_message Do we update the internal message - * with the parsed result - * @since 3.1.0-a3 - */ - $vars = array('text', 'uid', 'allow_bbcode', 'allow_magic_url', 'allow_smilies', 'update_this_message'); - extract($phpbb_dispatcher->trigger_event('core.modify_format_display_text_after', compact($vars))); - - $this->message = $text; - $this->bbcode_uid = $uid; - - if (!$update_this_message) - { - unset($this->message); - $this->message = $tmp_message; - return $return_message; - } - - $this->message_status = 'display'; - return false; - } - - /** - * Decode message to be placed back into form box - */ - function decode_message($custom_bbcode_uid = '', $update_this_message = true) - { - // If false, then the parsed message get returned but internal message not processed. - if (!$update_this_message) - { - $tmp_message = $this->message; - $return_message = &$this->message; - } - - ($custom_bbcode_uid) ? decode_message($this->message, $custom_bbcode_uid) : decode_message($this->message, $this->bbcode_uid); - - if (!$update_this_message) - { - unset($this->message); - $this->message = $tmp_message; - return $return_message; - } - - $this->message_status = 'plain'; - return false; - } - - /** - * Replace magic urls of form http://xxx.xxx., www.xxx. and xxx@xxx.xxx. - * Cuts down displayed size of link if over 50 chars, turns absolute links - * into relative versions when the server/script path matches the link - */ - function magic_url($server_url) - { - // We use the global make_clickable function - $this->message = make_clickable($this->message, $server_url); - } - - /** - * Parse Smilies - */ - function smilies($max_smilies = 0) - { - global $db, $user; - static $match; - static $replace; - - // See if the static arrays have already been filled on an earlier invocation - if (!is_array($match)) - { - $match = $replace = array(); - - // NOTE: obtain_* function? chaching the table contents? - - // For now setting the ttl to 10 minutes - switch ($db->get_sql_layer()) - { - case 'mssql_odbc': - case 'mssqlnative': - $sql = 'SELECT * - FROM ' . SMILIES_TABLE . ' - ORDER BY LEN(code) DESC'; - break; - - // LENGTH supported by MySQL, IBM DB2, Oracle and Access for sure... - default: - $sql = 'SELECT * - FROM ' . SMILIES_TABLE . ' - ORDER BY LENGTH(code) DESC'; - break; - } - $result = $db->sql_query($sql, 600); - - while ($row = $db->sql_fetchrow($result)) - { - if (empty($row['code'])) - { - continue; - } - - // (assertion) - $match[] = preg_quote($row['code'], '#'); - $replace[] = '' . $row['code'] . ''; - } - $db->sql_freeresult($result); - } - - if (count($match)) - { - if ($max_smilies) - { - // 'u' modifier has been added to correctly parse smilies within unicode strings - // For details: http://tracker.phpbb.com/browse/PHPBB3-10117 - $num_matches = preg_match_all('#(?<=^|[\n .])(?:' . implode('|', $match) . ')(?![^<>]*>)#u', $this->message, $matches); - unset($matches); - - if ($num_matches !== false && $num_matches > $max_smilies) - { - $this->warn_msg[] = sprintf($user->lang['TOO_MANY_SMILIES'], $max_smilies); - return; - } - } - - // Make sure the delimiter # is added in front and at the end of every element within $match - // 'u' modifier has been added to correctly parse smilies within unicode strings - // For details: http://tracker.phpbb.com/browse/PHPBB3-10117 - - $this->message = trim(preg_replace(explode(chr(0), '#(?<=^|[\n .])' . implode('(?![^<>]*>)#u' . chr(0) . '#(?<=^|[\n .])', $match) . '(?![^<>]*>)#u'), $replace, $this->message)); - } - } - - /** - * Parse Attachments - */ - function parse_attachments($form_name, $mode, $forum_id, $submit, $preview, $refresh, $is_message = false) - { - global $config, $auth, $user, $phpbb_root_path, $phpEx, $db, $request; - global $phpbb_container, $phpbb_dispatcher; - - $error = array(); - - $num_attachments = count($this->attachment_data); - $this->filename_data['filecomment'] = $request->variable('filecomment', '', true); - $upload = $request->file($form_name); - $upload_file = (!empty($upload) && $upload['name'] !== 'none' && trim($upload['name'])); - - $add_file = (isset($_POST['add_file'])) ? true : false; - $delete_file = (isset($_POST['delete_file'])) ? true : false; - - // First of all adjust comments if changed - $actual_comment_list = $request->variable('comment_list', array(''), true); - - foreach ($actual_comment_list as $comment_key => $comment) - { - if (!isset($this->attachment_data[$comment_key])) - { - continue; - } - - if ($this->attachment_data[$comment_key]['attach_comment'] != $actual_comment_list[$comment_key]) - { - $this->attachment_data[$comment_key]['attach_comment'] = $actual_comment_list[$comment_key]; - } - } - - $cfg = array(); - $cfg['max_attachments'] = ($is_message) ? $config['max_attachments_pm'] : $config['max_attachments']; - $forum_id = ($is_message) ? 0 : $forum_id; - - if ($submit && in_array($mode, array('post', 'reply', 'quote', 'edit')) && $upload_file) - { - if ($num_attachments < $cfg['max_attachments'] || $auth->acl_get('a_') || $auth->acl_get('m_', $forum_id)) - { - /** @var \phpbb\attachment\manager $attachment_manager */ - $attachment_manager = $phpbb_container->get('attachment.manager'); - $filedata = $attachment_manager->upload($form_name, $forum_id, false, '', $is_message); - $error = $filedata['error']; - - if ($filedata['post_attach'] && !count($error)) - { - $sql_ary = array( - 'physical_filename' => $filedata['physical_filename'], - 'attach_comment' => $this->filename_data['filecomment'], - 'real_filename' => $filedata['real_filename'], - 'extension' => $filedata['extension'], - 'mimetype' => $filedata['mimetype'], - 'filesize' => $filedata['filesize'], - 'filetime' => $filedata['filetime'], - 'thumbnail' => $filedata['thumbnail'], - 'is_orphan' => 1, - 'in_message' => ($is_message) ? 1 : 0, - 'poster_id' => $user->data['user_id'], - ); - - /** - * Modify attachment sql array on submit - * - * @event core.modify_attachment_sql_ary_on_submit - * @var array sql_ary Array containing SQL data - * @since 3.2.6-RC1 - */ - $vars = array('sql_ary'); - extract($phpbb_dispatcher->trigger_event('core.modify_attachment_sql_ary_on_submit', compact($vars))); - - $db->sql_query('INSERT INTO ' . ATTACHMENTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); - - $new_entry = array( - 'attach_id' => $db->sql_nextid(), - 'is_orphan' => 1, - 'real_filename' => $filedata['real_filename'], - 'attach_comment'=> $this->filename_data['filecomment'], - 'filesize' => $filedata['filesize'], - ); - - $this->attachment_data = array_merge(array(0 => $new_entry), $this->attachment_data); - - /** - * Modify attachment data on submit - * - * @event core.modify_attachment_data_on_submit - * @var array attachment_data Array containing attachment data - * @since 3.2.2-RC1 - */ - $attachment_data = $this->attachment_data; - $vars = array('attachment_data'); - extract($phpbb_dispatcher->trigger_event('core.modify_attachment_data_on_submit', compact($vars))); - $this->attachment_data = $attachment_data; - unset($attachment_data); - - $this->message = preg_replace_callback('#\[attachment=([0-9]+)\](.*?)\[\/attachment\]#', function ($match) { - return '[attachment='.($match[1] + 1).']' . $match[2] . '[/attachment]'; - }, $this->message); - - $this->filename_data['filecomment'] = ''; - - // This Variable is set to false here, because Attachments are entered into the - // Database in two modes, one if the id_list is 0 and the second one if post_attach is true - // Since post_attach is automatically switched to true if an Attachment got added to the filesystem, - // but we are assigning an id of 0 here, we have to reset the post_attach variable to false. - // - // This is very relevant, because it could happen that the post got not submitted, but we do not - // know this circumstance here. We could be at the posting page or we could be redirected to the entered - // post. :) - $filedata['post_attach'] = false; - } - } - else - { - $error[] = $user->lang('TOO_MANY_ATTACHMENTS', (int) $cfg['max_attachments']); - } - } - - if ($preview || $refresh || count($error)) - { - if (isset($this->plupload) && $this->plupload->is_active()) - { - $json_response = new \phpbb\json_response(); - } - - // Perform actions on temporary attachments - if ($delete_file) - { - include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx); - - $index = array_keys($request->variable('delete_file', array(0 => 0))); - $index = (!empty($index)) ? $index[0] : false; - - if ($index !== false && !empty($this->attachment_data[$index])) - { - /** @var \phpbb\attachment\manager $attachment_manager */ - $attachment_manager = $phpbb_container->get('attachment.manager'); - - // delete selected attachment - if ($this->attachment_data[$index]['is_orphan']) - { - $sql = 'SELECT attach_id, physical_filename, thumbnail - FROM ' . ATTACHMENTS_TABLE . ' - WHERE attach_id = ' . (int) $this->attachment_data[$index]['attach_id'] . ' - AND is_orphan = 1 - AND poster_id = ' . $user->data['user_id']; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - $attachment_manager->unlink($row['physical_filename'], 'file'); - - if ($row['thumbnail']) - { - $attachment_manager->unlink($row['physical_filename'], 'thumbnail'); - } - - $db->sql_query('DELETE FROM ' . ATTACHMENTS_TABLE . ' WHERE attach_id = ' . (int) $this->attachment_data[$index]['attach_id']); - } - } - else - { - $attachment_manager->delete('attach', $this->attachment_data[$index]['attach_id']); - } - - unset($this->attachment_data[$index]); - $this->message = preg_replace_callback('#\[attachment=([0-9]+)\](.*?)\[\/attachment\]#', function ($match) use($index) { - return ($match[1] == $index) ? '' : (($match[1] > $index) ? '[attachment=' . ($match[1] - 1) . ']' . $match[2] . '[/attachment]' : $match[0]); - }, $this->message); - - // Reindex Array - $this->attachment_data = array_values($this->attachment_data); - if (isset($this->plupload) && $this->plupload->is_active()) - { - $json_response->send($this->attachment_data); - } - } - } - else if (($add_file || $preview) && $upload_file) - { - if ($num_attachments < $cfg['max_attachments'] || $auth->acl_gets('m_', 'a_', $forum_id)) - { - /** @var \phpbb\attachment\manager $attachment_manager */ - $attachment_manager = $phpbb_container->get('attachment.manager'); - $filedata = $attachment_manager->upload($form_name, $forum_id, false, '', $is_message); - $error = array_merge($error, $filedata['error']); - - if (!count($error)) - { - $sql_ary = array( - 'physical_filename' => $filedata['physical_filename'], - 'attach_comment' => $this->filename_data['filecomment'], - 'real_filename' => $filedata['real_filename'], - 'extension' => $filedata['extension'], - 'mimetype' => $filedata['mimetype'], - 'filesize' => $filedata['filesize'], - 'filetime' => $filedata['filetime'], - 'thumbnail' => $filedata['thumbnail'], - 'is_orphan' => 1, - 'in_message' => ($is_message) ? 1 : 0, - 'poster_id' => $user->data['user_id'], - ); - - /** - * Modify attachment sql array on upload - * - * @event core.modify_attachment_sql_ary_on_upload - * @var array sql_ary Array containing SQL data - * @since 3.2.6-RC1 - */ - $vars = array('sql_ary'); - extract($phpbb_dispatcher->trigger_event('core.modify_attachment_sql_ary_on_upload', compact($vars))); - - $db->sql_query('INSERT INTO ' . ATTACHMENTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); - - $new_entry = array( - 'attach_id' => $db->sql_nextid(), - 'is_orphan' => 1, - 'real_filename' => $filedata['real_filename'], - 'attach_comment'=> $this->filename_data['filecomment'], - 'filesize' => $filedata['filesize'], - ); - - $this->attachment_data = array_merge(array(0 => $new_entry), $this->attachment_data); - - /** - * Modify attachment data on upload - * - * @event core.modify_attachment_data_on_upload - * @var array attachment_data Array containing attachment data - * @since 3.2.2-RC1 - */ - $attachment_data = $this->attachment_data; - $vars = array('attachment_data'); - extract($phpbb_dispatcher->trigger_event('core.modify_attachment_data_on_upload', compact($vars))); - $this->attachment_data = $attachment_data; - unset($attachment_data); - - $this->message = preg_replace_callback('#\[attachment=([0-9]+)\](.*?)\[\/attachment\]#', function ($match) { - return '[attachment=' . ($match[1] + 1) . ']' . $match[2] . '[/attachment]'; - }, $this->message); - $this->filename_data['filecomment'] = ''; - - if (isset($this->plupload) && $this->plupload->is_active()) - { - $download_url = append_sid("{$phpbb_root_path}download/file.{$phpEx}", 'mode=view&id=' . $new_entry['attach_id']); - - // Send the client the attachment data to maintain state - $json_response->send(array('data' => $this->attachment_data, 'download_url' => $download_url)); - } - } - } - else - { - $error[] = $user->lang('TOO_MANY_ATTACHMENTS', (int) $cfg['max_attachments']); - } - - if (!empty($error) && isset($this->plupload) && $this->plupload->is_active()) - { - // If this is a plupload (and thus ajax) request, give the - // client the first error we have - $json_response->send(array( - 'jsonrpc' => '2.0', - 'id' => 'id', - 'error' => array( - 'code' => 105, - 'message' => current($error), - ), - )); - } - } - } - - foreach ($error as $error_msg) - { - $this->warn_msg[] = $error_msg; - } - } - - /** - * Get Attachment Data - */ - function get_submitted_attachment_data($check_user_id = false) - { - global $user, $db; - global $request; - - $this->filename_data['filecomment'] = $request->variable('filecomment', '', true); - $attachment_data = $request->variable('attachment_data', array(0 => array('' => '')), true, \phpbb\request\request_interface::POST); - $this->attachment_data = array(); - - $check_user_id = ($check_user_id === false) ? $user->data['user_id'] : $check_user_id; - - if (!count($attachment_data)) - { - return; - } - - $not_orphan = $orphan = array(); - - foreach ($attachment_data as $pos => $var_ary) - { - if ($var_ary['is_orphan']) - { - $orphan[(int) $var_ary['attach_id']] = $pos; - } - else - { - $not_orphan[(int) $var_ary['attach_id']] = $pos; - } - } - - // Regenerate already posted attachments - if (count($not_orphan)) - { - // Get the attachment data, based on the poster id... - $sql = 'SELECT attach_id, is_orphan, real_filename, attach_comment, filesize - FROM ' . ATTACHMENTS_TABLE . ' - WHERE ' . $db->sql_in_set('attach_id', array_keys($not_orphan)) . ' - AND poster_id = ' . $check_user_id; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $pos = $not_orphan[$row['attach_id']]; - $this->attachment_data[$pos] = $row; - $this->attachment_data[$pos]['attach_comment'] = $attachment_data[$pos]['attach_comment']; - - unset($not_orphan[$row['attach_id']]); - } - $db->sql_freeresult($result); - } - - if (count($not_orphan)) - { - trigger_error('NO_ACCESS_ATTACHMENT', E_USER_ERROR); - } - - // Regenerate newly uploaded attachments - if (count($orphan)) - { - $sql = 'SELECT attach_id, is_orphan, real_filename, attach_comment, filesize - FROM ' . ATTACHMENTS_TABLE . ' - WHERE ' . $db->sql_in_set('attach_id', array_keys($orphan)) . ' - AND poster_id = ' . $user->data['user_id'] . ' - AND is_orphan = 1'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $pos = $orphan[$row['attach_id']]; - $this->attachment_data[$pos] = $row; - $this->attachment_data[$pos]['attach_comment'] = $attachment_data[$pos]['attach_comment']; - - unset($orphan[$row['attach_id']]); - } - $db->sql_freeresult($result); - } - - if (count($orphan)) - { - trigger_error('NO_ACCESS_ATTACHMENT', E_USER_ERROR); - } - - ksort($this->attachment_data); - } - - /** - * Parse Poll - */ - function parse_poll(&$poll) - { - global $user, $config; - - $poll_max_options = $poll['poll_max_options']; - - // Parse Poll Option text - $tmp_message = $this->message; - - $poll['poll_options'] = preg_split('/\s*?\n\s*/', trim($poll['poll_option_text'])); - $poll['poll_options_size'] = count($poll['poll_options']); - - foreach ($poll['poll_options'] as &$poll_option) - { - $this->message = $poll_option; - $poll_option = $this->parse($poll['enable_bbcode'], ($config['allow_post_links']) ? $poll['enable_urls'] : false, $poll['enable_smilies'], $poll['img_status'], false, false, $config['allow_post_links'], false, 'poll'); - } - unset($poll_option); - $poll['poll_option_text'] = implode("\n", $poll['poll_options']); - - // Parse Poll Title - $this->message = $poll['poll_title']; - if (!$poll['poll_title'] && $poll['poll_options_size']) - { - $this->warn_msg[] = $user->lang['NO_POLL_TITLE']; - } - else - { - if (utf8_strlen(preg_replace('#\[\/?[a-z\*\+\-]+(=[\S]+)?\]#ius', ' ', $this->message)) > 100) - { - $this->warn_msg[] = $user->lang['POLL_TITLE_TOO_LONG']; - } - $poll['poll_title'] = $this->parse($poll['enable_bbcode'], ($config['allow_post_links']) ? $poll['enable_urls'] : false, $poll['enable_smilies'], $poll['img_status'], false, false, $config['allow_post_links'], false, 'poll'); - if (strlen($poll['poll_title']) > 255) - { - $this->warn_msg[] = $user->lang['POLL_TITLE_COMP_TOO_LONG']; - } - } - - if (count($poll['poll_options']) == 1) - { - $this->warn_msg[] = $user->lang['TOO_FEW_POLL_OPTIONS']; - } - else if ($poll['poll_options_size'] > (int) $config['max_poll_options']) - { - $this->warn_msg[] = $user->lang['TOO_MANY_POLL_OPTIONS']; - } - else if ($poll_max_options > $poll['poll_options_size']) - { - $this->warn_msg[] = $user->lang['TOO_MANY_USER_OPTIONS']; - } - - $poll['poll_max_options'] = ($poll['poll_max_options'] < 1) ? 1 : (($poll['poll_max_options'] > $config['max_poll_options']) ? $config['max_poll_options'] : $poll['poll_max_options']); - - $this->message = $tmp_message; - } - - /** - * Remove nested quotes at given depth in current parsed message - * - * @param integer $max_depth Depth limit - * @return null - */ - public function remove_nested_quotes($max_depth) - { - global $phpbb_container; - - if (preg_match('#^<[rt][ >]#', $this->message)) - { - $this->message = $phpbb_container->get('text_formatter.utils')->remove_bbcode( - $this->message, - 'quote', - $max_depth - ); - - return; - } - - // Capture all [quote] and [/quote] tags - preg_match_all('(\\[/?quote(?:="(.*?)")?:' . $this->bbcode_uid . '\\])', $this->message, $matches, PREG_OFFSET_CAPTURE); - - // Iterate over the quote tags to mark the ranges that must be removed - $depth = 0; - $ranges = array(); - $start_pos = 0; - foreach ($matches[0] as $match) - { - if ($match[0][1] === '/') - { - --$depth; - if ($depth == $max_depth) - { - $end_pos = $match[1] + strlen($match[0]); - $length = $end_pos - $start_pos; - $ranges[] = array($start_pos, $length); - } - } - else - { - ++$depth; - if ($depth == $max_depth + 1) - { - $start_pos = $match[1]; - } - } - } - - foreach (array_reverse($ranges) as $range) - { - list($start_pos, $length) = $range; - $this->message = substr_replace($this->message, '', $start_pos, $length); - } - } - - /** - * Setter function for passing the plupload object - * - * @param \phpbb\plupload\plupload $plupload The plupload object - * - * @return null - */ - public function set_plupload(\phpbb\plupload\plupload $plupload) - { - $this->plupload = $plupload; - } - - /** - * Function to perform custom bbcode validation by extensions - * can be used in bbcode_init() to assign regexp replacement - * Example: 'regexp' => array('#\[b\](.*?)\[/b\]#uise' => "\$this->validate_bbcode_by_extension('\$1')") - * - * Accepts variable number of parameters - * - * @return mixed Validation result - */ - public function validate_bbcode_by_extension() - { - global $phpbb_dispatcher; - - $return = false; - $params_array = func_get_args(); - - /** - * Event to validate bbcode with the custom validating methods - * provided by extensions - * - * @event core.validate_bbcode_by_extension - * @var array params_array Array with the function parameters - * @var mixed return Validation result to return - * - * @since 3.1.5-RC1 - */ - $vars = array('params_array', 'return'); - extract($phpbb_dispatcher->trigger_event('core.validate_bbcode_by_extension', compact($vars))); - - return $return; - } -} diff --git a/install/update/old/includes/questionnaire/questionnaire.php b/install/update/old/includes/questionnaire/questionnaire.php deleted file mode 100644 index 2f80582..0000000 --- a/install/update/old/includes/questionnaire/questionnaire.php +++ /dev/null @@ -1,501 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* This class collects data which is used to create some usage statistics. -* -* The collected data is - after authorization of the administrator - submitted -* to a central server. For privacy reasons we try to collect only data which aren't private -* or don't give any information which might help to identify the user. -* -* @author Johannes Schlueter -* @copyright (c) 2007-2008 Johannes Schlueter -*/ -class phpbb_questionnaire_data_collector -{ - var $providers; - var $data = null; - var $install_id = ''; - - /** - * Constructor. - * - * @param string - */ - function __construct($install_id) - { - $this->install_id = $install_id; - $this->providers = array(); - } - - function add_data_provider($provider) - { - $this->providers[] = $provider; - } - - /** - * Get data as an array. - * - * @return array All Data - */ - function get_data_raw() - { - if (!$this->data) - { - $this->collect(); - } - - return $this->data; - } - - function get_data_for_form() - { - return base64_encode(serialize($this->get_data_raw())); - } - - /** - * Collect info into the data property. - * - * @return null - */ - function collect() - { - foreach (array_keys($this->providers) as $key) - { - $provider = $this->providers[$key]; - $this->data[$provider->get_identifier()] = $provider->get_data(); - } - $this->data['install_id'] = $this->install_id; - } -} - -/** interface: get_indentifier(), get_data() */ - -/** -* Questionnaire PHP data provider -*/ -class phpbb_questionnaire_php_data_provider -{ - function get_identifier() - { - return 'PHP'; - } - - /** - * Get data about the PHP runtime setup. - * - * @return array - */ - function get_data() - { - return array( - 'version' => PHP_VERSION, - 'sapi' => PHP_SAPI, - 'int_size' => defined('PHP_INT_SIZE') ? PHP_INT_SIZE : '', - 'safe_mode' => (int) @ini_get('safe_mode'), - 'open_basedir' => (int) @ini_get('open_basedir'), - 'memory_limit' => @ini_get('memory_limit'), - 'allow_url_fopen' => (int) @ini_get('allow_url_fopen'), - 'allow_url_include' => (int) @ini_get('allow_url_include'), - 'file_uploads' => (int) @ini_get('file_uploads'), - 'upload_max_filesize' => @ini_get('upload_max_filesize'), - 'post_max_size' => @ini_get('post_max_size'), - 'disable_functions' => @ini_get('disable_functions'), - 'disable_classes' => @ini_get('disable_classes'), - 'enable_dl' => (int) @ini_get('enable_dl'), - 'magic_quotes_gpc' => (int) @ini_get('magic_quotes_gpc'), - 'register_globals' => (int) @ini_get('register_globals'), - 'filter.default' => @ini_get('filter.default'), - 'zend.ze1_compatibility_mode' => (int) @ini_get('zend.ze1_compatibility_mode'), - 'unicode.semantics' => (int) @ini_get('unicode.semantics'), - 'zend_thread_safty' => (int) function_exists('zend_thread_id'), - 'extensions' => get_loaded_extensions(), - ); - } -} - -/** -* Questionnaire System data provider -*/ -class phpbb_questionnaire_system_data_provider -{ - function get_identifier() - { - return 'System'; - } - - /** - * Get data about the general system information, like OS or IP (shortened). - * - * @return array - */ - function get_data() - { - global $request; - - // Start discovering the IPV4 server address, if available - // Try apache, IIS, fall back to 0.0.0.0 - $server_address = htmlspecialchars_decode($request->server('SERVER_ADDR', $request->server('LOCAL_ADDR', '0.0.0.0'))); - - return array( - 'os' => PHP_OS, - 'httpd' => htmlspecialchars_decode($request->server('SERVER_SOFTWARE')), - // we don't want the real IP address (for privacy policy reasons) but only - // a network address to see whether your installation is running on a private or public network. - 'private_ip' => $this->is_private_ip($server_address), - 'ipv6' => strpos($server_address, ':') !== false, - ); - } - - /** - * Checks whether the given IP is in a private network. - * - * @param string $ip IP in v4 dot-decimal or v6 hex format - * @return bool true if the IP is from a private network, else false - */ - function is_private_ip($ip) - { - // IPv4 - if (strpos($ip, ':') === false) - { - $ip_address_ary = explode('.', $ip); - - // build ip - if (!isset($ip_address_ary[0]) || !isset($ip_address_ary[1])) - { - $ip_address_ary = explode('.', '0.0.0.0'); - } - - // IANA reserved addresses for private networks (RFC 1918) are: - // - 10.0.0.0/8 - // - 172.16.0.0/12 - // - 192.168.0.0/16 - if ($ip_address_ary[0] == '10' || - ($ip_address_ary[0] == '172' && intval($ip_address_ary[1]) > 15 && intval($ip_address_ary[1]) < 32) || - ($ip_address_ary[0] == '192' && $ip_address_ary[1] == '168')) - { - return true; - } - } - // IPv6 - else - { - // unique local unicast - $prefix = substr($ip, 0, 2); - if ($prefix == 'fc' || $prefix == 'fd') - { - return true; - } - } - - return false; - } -} - -/** -* Questionnaire phpBB data provider -*/ -class phpbb_questionnaire_phpbb_data_provider -{ - var $config; - var $unique_id; - - /** - * Constructor. - * - * @param array $config - */ - function __construct($config) - { - // generate a unique id if necessary - if (empty($config['questionnaire_unique_id'])) - { - $this->unique_id = unique_id(); - $config->set('questionnaire_unique_id', $this->unique_id); - } - else - { - $this->unique_id = $config['questionnaire_unique_id']; - } - - $this->config = $config; - } - - /** - * Returns a string identifier for this data provider - * - * @return string "phpBB" - */ - function get_identifier() - { - return 'phpBB'; - } - - /** - * Get data about this phpBB installation. - * - * @return array Relevant anonymous config options - */ - function get_data() - { - global $phpbb_config_php_file; - - extract($phpbb_config_php_file->get_all()); - unset($dbhost, $dbport, $dbname, $dbuser, $dbpasswd); // Just a precaution - - $dbms = $phpbb_config_php_file->convert_30_dbms_to_31($dbms); - - // Only send certain config vars - $config_vars = array( - 'active_sessions' => true, - 'allow_attachments' => true, - 'allow_autologin' => true, - 'allow_avatar' => true, - 'allow_avatar_local' => true, - 'allow_avatar_remote' => true, - 'allow_avatar_upload' => true, - 'allow_bbcode' => true, - 'allow_birthdays' => true, - 'allow_bookmarks' => true, - 'allow_emailreuse' => true, - 'allow_forum_notify' => true, - 'allow_mass_pm' => true, - 'allow_name_chars' => true, - 'allow_namechange' => true, - 'allow_nocensors' => true, - 'allow_pm_attach' => true, - 'allow_pm_report' => true, - 'allow_post_flash' => true, - 'allow_post_links' => true, - 'allow_privmsg' => true, - 'allow_quick_reply' => true, - 'allow_sig' => true, - 'allow_sig_bbcode' => true, - 'allow_sig_flash' => true, - 'allow_sig_img' => true, - 'allow_sig_links' => true, - 'allow_sig_pm' => true, - 'allow_sig_smilies' => true, - 'allow_smilies' => true, - 'allow_topic_notify' => true, - 'attachment_quota' => true, - 'auth_bbcode_pm' => true, - 'auth_flash_pm' => true, - 'auth_img_pm' => true, - 'auth_method' => true, - 'auth_smilies_pm' => true, - 'avatar_filesize' => true, - 'avatar_max_height' => true, - 'avatar_max_width' => true, - 'avatar_min_height' => true, - 'avatar_min_width' => true, - 'board_email_form' => true, - 'board_hide_emails' => true, - 'board_timezone' => true, - 'browser_check' => true, - 'bump_interval' => true, - 'bump_type' => true, - 'cache_gc' => true, - 'captcha_plugin' => true, - 'captcha_gd' => true, - 'captcha_gd_foreground_noise' => true, - 'captcha_gd_x_grid' => true, - 'captcha_gd_y_grid' => true, - 'captcha_gd_wave' => true, - 'captcha_gd_3d_noise' => true, - 'captcha_gd_fonts' => true, - 'confirm_refresh' => true, - 'check_attachment_content' => true, - 'check_dnsbl' => true, - 'chg_passforce' => true, - 'cookie_secure' => true, - 'coppa_enable' => true, - 'database_gc' => true, - 'dbms_version' => true, - 'default_dateformat' => true, - 'default_lang' => true, - 'display_last_edited' => true, - 'display_order' => true, - 'edit_time' => true, - 'email_check_mx' => true, - 'email_enable' => true, - 'email_force_sender' => true, - 'email_package_size' => true, - 'enable_confirm' => true, - 'enable_pm_icons' => true, - 'enable_post_confirm' => true, - 'feed_enable' => true, - 'feed_http_auth' => true, - 'feed_limit_post' => true, - 'feed_limit_topic' => true, - 'feed_overall' => true, - 'feed_overall_forums' => true, - 'feed_forum' => true, - 'feed_topic' => true, - 'feed_topics_new' => true, - 'feed_topics_active' => true, - 'feed_item_statistics' => true, - 'flood_interval' => true, - 'force_server_vars' => true, - 'form_token_lifetime' => true, - 'form_token_mintime' => true, - 'form_token_sid_guests' => true, - 'forward_pm' => true, - 'forwarded_for_check' => true, - 'full_folder_action' => true, - 'fulltext_native_common_thres' => true, - 'fulltext_native_load_upd' => true, - 'fulltext_native_max_chars' => true, - 'fulltext_native_min_chars' => true, - 'gzip_compress' => true, - 'hot_threshold' => true, - 'img_create_thumbnail' => true, - 'img_display_inlined' => true, - 'img_link_height' => true, - 'img_link_width' => true, - 'img_max_height' => true, - 'img_max_thumb_width' => true, - 'img_max_width' => true, - 'img_min_thumb_filesize' => true, - 'ip_check' => true, - 'jab_enable' => true, - 'jab_package_size' => true, - 'jab_use_ssl' => true, - 'limit_load' => true, - 'limit_search_load' => true, - 'load_anon_lastread' => true, - 'load_birthdays' => true, - 'load_cpf_memberlist' => true, - 'load_cpf_viewprofile' => true, - 'load_cpf_viewtopic' => true, - 'load_db_lastread' => true, - 'load_db_track' => true, - 'load_jumpbox' => true, - 'load_moderators' => true, - 'load_online' => true, - 'load_online_guests' => true, - 'load_online_time' => true, - 'load_onlinetrack' => true, - 'load_search' => true, - 'load_tplcompile' => true, - 'load_user_activity' => true, - 'max_attachments' => true, - 'max_attachments_pm' => true, - 'max_autologin_time' => true, - 'max_filesize' => true, - 'max_filesize_pm' => true, - 'max_login_attempts' => true, - 'max_name_chars' => true, - 'max_num_search_keywords' => true, - 'max_pass_chars' => true, - 'max_poll_options' => true, - 'max_post_chars' => true, - 'max_post_font_size' => true, - 'max_post_img_height' => true, - 'max_post_img_width' => true, - 'max_post_smilies' => true, - 'max_post_urls' => true, - 'max_quote_depth' => true, - 'max_reg_attempts' => true, - 'max_sig_chars' => true, - 'max_sig_font_size' => true, - 'max_sig_img_height' => true, - 'max_sig_img_width' => true, - 'max_sig_smilies' => true, - 'max_sig_urls' => true, - 'min_name_chars' => true, - 'min_pass_chars' => true, - 'min_post_chars' => true, - 'min_search_author_chars' => true, - 'mime_triggers' => true, - 'new_member_post_limit' => true, - 'new_member_group_default' => true, - 'override_user_style' => true, - 'pass_complex' => true, - 'pm_edit_time' => true, - 'pm_max_boxes' => true, - 'pm_max_msgs' => true, - 'pm_max_recipients' => true, - 'posts_per_page' => true, - 'print_pm' => true, - 'queue_interval' => true, - 'require_activation' => true, - 'referer_validation' => true, - 'search_block_size' => true, - 'search_gc' => true, - 'search_interval' => true, - 'search_anonymous_interval' => true, - 'search_type' => true, - 'search_store_results' => true, - 'secure_allow_deny' => true, - 'secure_allow_empty_referer' => true, - 'secure_downloads' => true, - 'session_gc' => true, - 'session_length' => true, - 'smtp_auth_method' => true, - 'smtp_delivery' => true, - 'topics_per_page' => true, - 'tpl_allow_php' => true, - 'version' => true, - 'warnings_expire_days' => true, - 'warnings_gc' => true, - - 'num_files' => true, - 'num_posts' => true, - 'num_topics' => true, - 'num_users' => true, - 'record_online_users' => true, - ); - - $result = array(); - foreach ($config_vars as $name => $void) - { - if (isset($this->config[$name])) - { - $result['config_' . $name] = $this->config[$name]; - } - } - - global $db, $request; - - $result['dbms'] = $dbms; - $result['acm_type'] = $acm_type; - $result['user_agent'] = 'Unknown'; - $result['dbms_version'] = $db->sql_server_info(true); - - // Try to get user agent vendor and version - $match = array(); - $user_agent = $request->header('User-Agent'); - $agents = array('firefox', 'msie', 'opera', 'chrome', 'safari', 'mozilla', 'seamonkey', 'konqueror', 'netscape', 'gecko', 'navigator', 'mosaic', 'lynx', 'amaya', 'omniweb', 'avant', 'camino', 'flock', 'aol'); - - // We check here 1 by 1 because some strings occur after others (for example Mozilla [...] Firefox/) - foreach ($agents as $agent) - { - if (preg_match('#(' . $agent . ')[/ ]?([0-9.]*)#i', $user_agent, $match)) - { - $result['user_agent'] = $match[1] . ' ' . $match[2]; - break; - } - } - - return $result; - } -} diff --git a/install/update/old/includes/startup.php b/install/update/old/includes/startup.php deleted file mode 100644 index 66f8565..0000000 --- a/install/update/old/includes/startup.php +++ /dev/null @@ -1,86 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -// Report all errors, except notices and deprecation messages -$level = E_ALL & ~E_NOTICE & ~E_DEPRECATED; -error_reporting($level); - -/** -* Minimum Requirement: PHP 5.4.0 -*/ -if (version_compare(PHP_VERSION, '5.4') < 0) -{ - die('You are running an unsupported PHP version. Please upgrade to PHP 5.4.0 or higher before trying to install or update to phpBB 3.2'); -} -// Register globals and magic quotes have been dropped in PHP 5.4 so no need for extra checks - - -// In PHP 5.3.0 the error level has been raised to E_WARNING which causes problems -// because we show E_WARNING errors and do not set a default timezone. -// This is because we have our own timezone handling and work in UTC only anyway. - -// So what we basically want to do is set our timezone to UTC, -// but we don't know what other scripts (such as bridges) are involved, -// so we check whether a timezone is already set by calling date_default_timezone_get(). - -// Unfortunately, date_default_timezone_get() itself might throw E_WARNING -// if no timezone has been set, so we have to keep it quiet with @. - -// date_default_timezone_get() tries to guess the correct timezone first -// and then falls back to UTC when everything fails. -// We just set the timezone to whatever date_default_timezone_get() returns. -date_default_timezone_set(@date_default_timezone_get()); - -// Autoloading of dependencies. -// Three options are supported: -// 1. If dependencies are installed with Composer, Composer will create a -// vendor/autoload.php. If this file exists it will be -// automatically used by phpBB. This is the default mode that phpBB -// will use when shipped. -// 2. To disable composer autoloading, PHPBB_NO_COMPOSER_AUTOLOAD can be specified. -// Additionally specify PHPBB_AUTOLOAD=/path/to/autoload.php in the -// environment. This is useful for running CLI scripts and tests. -// /path/to/autoload.php should define and register class loaders -// for all of phpBB's dependencies. -// 3. You can also set PHPBB_NO_COMPOSER_AUTOLOAD without setting PHPBB_AUTOLOAD. -// In this case autoloading needs to be defined before running any phpBB -// script. This might be useful in cases when phpBB is integrated into a -// larger program. -if (getenv('PHPBB_NO_COMPOSER_AUTOLOAD')) -{ - if (getenv('PHPBB_AUTOLOAD')) - { - require(getenv('PHPBB_AUTOLOAD')); - } -} -else -{ - if (!file_exists($phpbb_root_path . 'vendor/autoload.php')) - { - trigger_error( - 'Composer dependencies have not been set up yet, run ' . - "'php ../composer.phar install' from the phpBB directory to do so.", - E_USER_ERROR - ); - } - require($phpbb_root_path . 'vendor/autoload.php'); -} - -$starttime = microtime(true); diff --git a/install/update/old/includes/ucp/ucp_attachments.php b/install/update/old/includes/ucp/ucp_attachments.php deleted file mode 100644 index c1b623c..0000000 --- a/install/update/old/includes/ucp/ucp_attachments.php +++ /dev/null @@ -1,205 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* ucp_attachments -* User attachments -*/ -class ucp_attachments -{ - var $u_action; - - function main($id, $mode) - { - global $template, $user, $db, $config, $phpEx, $phpbb_root_path, $phpbb_container, $request; - - $start = $request->variable('start', 0); - $sort_key = $request->variable('sk', 'a'); - $sort_dir = $request->variable('sd', 'a'); - - $delete = (isset($_POST['delete'])) ? true : false; - $delete_ids = array_keys($request->variable('attachment', array(0))); - - if ($delete && count($delete_ids)) - { - // Validate $delete_ids... - $sql = 'SELECT attach_id - FROM ' . ATTACHMENTS_TABLE . ' - WHERE poster_id = ' . $user->data['user_id'] . ' - AND is_orphan = 0 - AND ' . $db->sql_in_set('attach_id', $delete_ids); - $result = $db->sql_query($sql); - - $delete_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $delete_ids[] = $row['attach_id']; - } - $db->sql_freeresult($result); - } - - if ($delete && count($delete_ids)) - { - $s_hidden_fields = array( - 'delete' => 1 - ); - - foreach ($delete_ids as $attachment_id) - { - $s_hidden_fields['attachment'][$attachment_id] = 1; - } - - if (confirm_box(true)) - { - /** @var \phpbb\attachment\manager $attachment_manager */ - $attachment_manager = $phpbb_container->get('attachment.manager'); - $attachment_manager->delete('attach', $delete_ids); - unset($attachment_manager); - - meta_refresh(3, $this->u_action); - $message = ((count($delete_ids) == 1) ? $user->lang['ATTACHMENT_DELETED'] : $user->lang['ATTACHMENTS_DELETED']) . '

' . sprintf($user->lang['RETURN_UCP'], '', ''); - trigger_error($message); - } - else - { - confirm_box(false, (count($delete_ids) == 1) ? 'DELETE_ATTACHMENT' : 'DELETE_ATTACHMENTS', build_hidden_fields($s_hidden_fields)); - } - } - - // Select box eventually - $sort_key_text = array('a' => $user->lang['SORT_FILENAME'], 'b' => $user->lang['SORT_COMMENT'], 'c' => $user->lang['SORT_EXTENSION'], 'd' => $user->lang['SORT_SIZE'], 'e' => $user->lang['SORT_DOWNLOADS'], 'f' => $user->lang['SORT_POST_TIME'], 'g' => $user->lang['SORT_TOPIC_TITLE']); - $sort_key_sql = array('a' => 'a.real_filename', 'b' => 'a.attach_comment', 'c' => 'a.extension', 'd' => 'a.filesize', 'e' => 'a.download_count', 'f' => 'a.filetime', 'g' => 't.topic_title'); - - $sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']); - - $s_sort_key = ''; - foreach ($sort_key_text as $key => $value) - { - $selected = ($sort_key == $key) ? ' selected="selected"' : ''; - $s_sort_key .= ''; - } - - $s_sort_dir = ''; - foreach ($sort_dir_text as $key => $value) - { - $selected = ($sort_dir == $key) ? ' selected="selected"' : ''; - $s_sort_dir .= ''; - } - - if (!isset($sort_key_sql[$sort_key])) - { - $sort_key = 'a'; - } - - $order_by = $sort_key_sql[$sort_key] . ' ' . (($sort_dir == 'a') ? 'ASC' : 'DESC'); - - $sql = 'SELECT COUNT(attach_id) as num_attachments - FROM ' . ATTACHMENTS_TABLE . ' - WHERE poster_id = ' . $user->data['user_id'] . ' - AND is_orphan = 0'; - $result = $db->sql_query($sql); - $num_attachments = $db->sql_fetchfield('num_attachments'); - $db->sql_freeresult($result); - - // Ensure start is a valid value - /* @var $pagination \phpbb\pagination */ - $pagination = $phpbb_container->get('pagination'); - $start = $pagination->validate_start($start, $config['topics_per_page'], $num_attachments); - - $sql = 'SELECT a.*, t.topic_title, p.message_subject as message_title - FROM ' . ATTACHMENTS_TABLE . ' a - LEFT JOIN ' . TOPICS_TABLE . ' t ON (a.topic_id = t.topic_id AND a.in_message = 0) - LEFT JOIN ' . PRIVMSGS_TABLE . ' p ON (a.post_msg_id = p.msg_id AND a.in_message = 1) - WHERE a.poster_id = ' . $user->data['user_id'] . " - AND a.is_orphan = 0 - ORDER BY $order_by"; - $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); - - $row_count = 0; - if ($row = $db->sql_fetchrow($result)) - { - $template->assign_var('S_ATTACHMENT_ROWS', true); - - do - { - if ($row['in_message']) - { - $view_topic = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=pm&p={$row['post_msg_id']}"); - } - else - { - $view_topic = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t={$row['topic_id']}&p={$row['post_msg_id']}") . "#p{$row['post_msg_id']}"; - } - - $template->assign_block_vars('attachrow', array( - 'ROW_NUMBER' => $row_count + ($start + 1), - 'FILENAME' => $row['real_filename'], - 'COMMENT' => bbcode_nl2br($row['attach_comment']), - 'EXTENSION' => $row['extension'], - 'SIZE' => get_formatted_filesize($row['filesize']), - 'DOWNLOAD_COUNT' => $row['download_count'], - 'POST_TIME' => $user->format_date($row['filetime']), - 'TOPIC_TITLE' => ($row['in_message']) ? $row['message_title'] : $row['topic_title'], - - 'ATTACH_ID' => $row['attach_id'], - 'POST_ID' => $row['post_msg_id'], - 'TOPIC_ID' => $row['topic_id'], - - 'S_IN_MESSAGE' => $row['in_message'], - - 'U_VIEW_ATTACHMENT' => append_sid("{$phpbb_root_path}download/file.$phpEx", 'id=' . $row['attach_id']), - 'U_VIEW_TOPIC' => $view_topic) - ); - - $row_count++; - } - while ($row = $db->sql_fetchrow($result)); - } - $db->sql_freeresult($result); - - $base_url = $this->u_action . "&sk=$sort_key&sd=$sort_dir"; - $pagination->generate_template_pagination($base_url, 'pagination', 'start', $num_attachments, $config['topics_per_page'], $start); - - $template->assign_vars(array( - 'TOTAL_ATTACHMENTS' => $num_attachments, - 'NUM_ATTACHMENTS' => $user->lang('NUM_ATTACHMENTS', $num_attachments), - - 'L_TITLE' => $user->lang['UCP_ATTACHMENTS'], - - 'U_SORT_FILENAME' => $this->u_action . "&sk=a&sd=" . (($sort_key == 'a' && $sort_dir == 'a') ? 'd' : 'a'), - 'U_SORT_FILE_COMMENT' => $this->u_action . "&sk=b&sd=" . (($sort_key == 'b' && $sort_dir == 'a') ? 'd' : 'a'), - 'U_SORT_EXTENSION' => $this->u_action . "&sk=c&sd=" . (($sort_key == 'c' && $sort_dir == 'a') ? 'd' : 'a'), - 'U_SORT_FILESIZE' => $this->u_action . "&sk=d&sd=" . (($sort_key == 'd' && $sort_dir == 'a') ? 'd' : 'a'), - 'U_SORT_DOWNLOADS' => $this->u_action . "&sk=e&sd=" . (($sort_key == 'e' && $sort_dir == 'a') ? 'd' : 'a'), - 'U_SORT_POST_TIME' => $this->u_action . "&sk=f&sd=" . (($sort_key == 'f' && $sort_dir == 'a') ? 'd' : 'a'), - 'U_SORT_TOPIC_TITLE' => $this->u_action . "&sk=g&sd=" . (($sort_key == 'g' && $sort_dir == 'a') ? 'd' : 'a'), - - 'S_DISPLAY_MARK_ALL' => ($num_attachments) ? true : false, - 'S_DISPLAY_PAGINATION' => ($num_attachments) ? true : false, - 'S_UCP_ACTION' => $this->u_action, - 'S_SORT_OPTIONS' => $s_sort_key, - 'S_ORDER_SELECT' => $s_sort_dir) - ); - - $this->tpl_name = 'ucp_attachments'; - $this->page_title = 'UCP_ATTACHMENTS'; - } -} diff --git a/install/update/old/includes/ucp/ucp_groups.php b/install/update/old/includes/ucp/ucp_groups.php deleted file mode 100644 index 2423af8..0000000 --- a/install/update/old/includes/ucp/ucp_groups.php +++ /dev/null @@ -1,1137 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* ucp_groups -*/ -class ucp_groups -{ - var $u_action; - - function main($id, $mode) - { - global $config, $phpbb_root_path, $phpEx, $phpbb_admin_path; - global $db, $user, $auth, $cache, $template; - global $request, $phpbb_container, $phpbb_log; - - /** @var \phpbb\language\language $language Language object */ - $language = $phpbb_container->get('language'); - - $user->add_lang('groups'); - - $return_page = '

' . sprintf($user->lang['RETURN_PAGE'], '', ''); - - $mark_ary = $request->variable('mark', array(0)); - $submit = $request->variable('submit', false, false, \phpbb\request\request_interface::POST); - - /** @var \phpbb\group\helper $group_helper */ - $group_helper = $phpbb_container->get('group_helper'); - - switch ($mode) - { - case 'membership': - - $this->page_title = 'UCP_USERGROUPS_MEMBER'; - - if ($submit || isset($_POST['change_default'])) - { - $action = (isset($_POST['change_default'])) ? 'change_default' : $request->variable('action', ''); - $group_id = ($action == 'change_default') ? $request->variable('default', 0) : $request->variable('selected', 0); - - if (!$group_id) - { - trigger_error('NO_GROUP_SELECTED'); - } - - $sql = 'SELECT group_id, group_name, group_type - FROM ' . GROUPS_TABLE . " - WHERE group_id IN ($group_id, {$user->data['group_id']})"; - $result = $db->sql_query($sql); - - $group_row = array(); - while ($row = $db->sql_fetchrow($result)) - { - $row['group_name'] = $group_helper->get_name($row['group_name']); - $group_row[$row['group_id']] = $row; - } - $db->sql_freeresult($result); - - if (!count($group_row)) - { - trigger_error('GROUP_NOT_EXIST'); - } - - switch ($action) - { - case 'change_default': - // User already having this group set as default? - if ($group_id == $user->data['group_id']) - { - trigger_error($user->lang['ALREADY_DEFAULT_GROUP'] . $return_page); - } - - if (!$auth->acl_get('u_chggrp')) - { - send_status_line(403, 'Forbidden'); - trigger_error($user->lang['NOT_AUTHORISED'] . $return_page); - } - - // User needs to be member of the group in order to make it default - if (!group_memberships($group_id, $user->data['user_id'], true)) - { - trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page); - } - - if (confirm_box(true)) - { - group_user_attributes('default', $group_id, $user->data['user_id']); - - $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_GROUP_CHANGE', false, array( - 'reportee_id' => $user->data['user_id'], - sprintf($user->lang['USER_GROUP_CHANGE'], $group_row[$user->data['group_id']]['group_name'], $group_row[$group_id]['group_name']) - )); - - meta_refresh(3, $this->u_action); - trigger_error($user->lang['CHANGED_DEFAULT_GROUP'] . $return_page); - } - else - { - $s_hidden_fields = array( - 'default' => $group_id, - 'change_default'=> true - ); - - confirm_box(false, sprintf($user->lang['GROUP_CHANGE_DEFAULT'], $group_row[$group_id]['group_name']), build_hidden_fields($s_hidden_fields)); - } - - break; - - case 'resign': - - // User tries to resign from default group but is not allowed to change it? - if ($group_id == $user->data['group_id'] && !$auth->acl_get('u_chggrp')) - { - trigger_error($user->lang['NOT_RESIGN_FROM_DEFAULT_GROUP'] . $return_page); - } - - if (!($row = group_memberships($group_id, $user->data['user_id']))) - { - trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page); - } - list(, $row) = each($row); - - $sql = 'SELECT group_type - FROM ' . GROUPS_TABLE . ' - WHERE group_id = ' . $group_id; - $result = $db->sql_query($sql); - $group_type = (int) $db->sql_fetchfield('group_type'); - $db->sql_freeresult($result); - - if ($group_type != GROUP_OPEN && $group_type != GROUP_FREE) - { - trigger_error($user->lang['CANNOT_RESIGN_GROUP'] . $return_page); - } - - if (confirm_box(true)) - { - group_user_del($group_id, $user->data['user_id']); - - $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_GROUP_RESIGN', false, array( - 'reportee_id' => $user->data['user_id'], - $group_row[$group_id]['group_name'] - )); - - meta_refresh(3, $this->u_action); - trigger_error($user->lang[($row['user_pending']) ? 'GROUP_RESIGNED_PENDING' : 'GROUP_RESIGNED_MEMBERSHIP'] . $return_page); - } - else - { - $s_hidden_fields = array( - 'selected' => $group_id, - 'action' => 'resign', - 'submit' => true - ); - - confirm_box(false, ($row['user_pending']) ? 'GROUP_RESIGN_PENDING' : 'GROUP_RESIGN_MEMBERSHIP', build_hidden_fields($s_hidden_fields)); - } - - break; - - case 'join': - - $sql = 'SELECT ug.*, u.username, u.username_clean, u.user_email - FROM ' . USER_GROUP_TABLE . ' ug, ' . USERS_TABLE . ' u - WHERE ug.user_id = u.user_id - AND ug.group_id = ' . $group_id . ' - AND ug.user_id = ' . $user->data['user_id']; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - if ($row['user_pending']) - { - trigger_error($user->lang['ALREADY_IN_GROUP_PENDING'] . $return_page); - } - - trigger_error($user->lang['ALREADY_IN_GROUP'] . $return_page); - } - - // Check permission to join (open group or request) - if ($group_row[$group_id]['group_type'] != GROUP_OPEN && $group_row[$group_id]['group_type'] != GROUP_FREE) - { - trigger_error($user->lang['CANNOT_JOIN_GROUP'] . $return_page); - } - - if (confirm_box(true)) - { - if ($group_row[$group_id]['group_type'] == GROUP_FREE) - { - group_user_add($group_id, $user->data['user_id']); - } - else - { - group_user_add($group_id, $user->data['user_id'], false, false, false, 0, 1); - } - - $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_GROUP_JOIN' . (($group_row[$group_id]['group_type'] == GROUP_FREE) ? '' : '_PENDING'), false, array( - 'reportee_id' => $user->data['user_id'], - $group_row[$group_id]['group_name'] - )); - - meta_refresh(3, $this->u_action); - trigger_error($user->lang[($group_row[$group_id]['group_type'] == GROUP_FREE) ? 'GROUP_JOINED' : 'GROUP_JOINED_PENDING'] . $return_page); - } - else - { - $s_hidden_fields = array( - 'selected' => $group_id, - 'action' => 'join', - 'submit' => true - ); - - confirm_box(false, ($group_row[$group_id]['group_type'] == GROUP_FREE) ? 'GROUP_JOIN' : 'GROUP_JOIN_PENDING', build_hidden_fields($s_hidden_fields)); - } - - break; - - case 'demote': - - if (!($row = group_memberships($group_id, $user->data['user_id']))) - { - trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page); - } - list(, $row) = each($row); - - if (!$row['group_leader']) - { - trigger_error($user->lang['NOT_LEADER_OF_GROUP'] . $return_page); - } - - if (confirm_box(true)) - { - group_user_attributes('demote', $group_id, $user->data['user_id']); - - $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_GROUP_DEMOTE', false, array( - 'reportee_id' => $user->data['user_id'], - $group_row[$group_id]['group_name'] - )); - - meta_refresh(3, $this->u_action); - trigger_error($user->lang['USER_GROUP_DEMOTED'] . $return_page); - } - else - { - $s_hidden_fields = array( - 'selected' => $group_id, - 'action' => 'demote', - 'submit' => true - ); - - confirm_box(false, 'USER_GROUP_DEMOTE', build_hidden_fields($s_hidden_fields)); - } - - break; - } - } - - $sql = 'SELECT g.*, ug.group_leader, ug.user_pending - FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . ' ug - WHERE ug.user_id = ' . $user->data['user_id'] . ' - AND g.group_id = ug.group_id - ORDER BY g.group_type DESC, g.group_name'; - $result = $db->sql_query($sql); - - $group_id_ary = array(); - $leader_count = $member_count = $pending_count = 0; - while ($row = $db->sql_fetchrow($result)) - { - $block = ($row['group_leader']) ? 'leader' : (($row['user_pending']) ? 'pending' : 'member'); - - switch ($row['group_type']) - { - case GROUP_OPEN: - $group_status = 'OPEN'; - break; - - case GROUP_CLOSED: - $group_status = 'CLOSED'; - break; - - case GROUP_HIDDEN: - $group_status = 'HIDDEN'; - break; - - case GROUP_SPECIAL: - $group_status = 'SPECIAL'; - break; - - case GROUP_FREE: - $group_status = 'FREE'; - break; - } - - $template->assign_block_vars($block, array( - 'GROUP_ID' => $row['group_id'], - 'GROUP_NAME' => $group_helper->get_name($row['group_name']), - 'GROUP_DESC' => ($row['group_type'] <> GROUP_SPECIAL) ? generate_text_for_display($row['group_desc'], $row['group_desc_uid'], $row['group_desc_bitfield'], $row['group_desc_options']) : $user->lang['GROUP_IS_SPECIAL'], - 'GROUP_SPECIAL' => ($row['group_type'] <> GROUP_SPECIAL) ? false : true, - 'GROUP_STATUS' => $user->lang['GROUP_IS_' . $group_status], - 'GROUP_COLOUR' => $row['group_colour'], - - 'U_VIEW_GROUP' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&g=' . $row['group_id']), - - 'S_GROUP_DEFAULT' => ($row['group_id'] == $user->data['group_id']) ? true : false, - 'S_ROW_COUNT' => ${$block . '_count'}++) - ); - - $group_id_ary[] = (int) $row['group_id']; - } - $db->sql_freeresult($result); - - // Hide hidden groups unless user is an admin with group privileges - $sql_and = ($auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) ? '<> ' . GROUP_SPECIAL : 'NOT IN (' . GROUP_SPECIAL . ', ' . GROUP_HIDDEN . ')'; - - $sql = 'SELECT group_id, group_name, group_colour, group_desc, group_desc_uid, group_desc_bitfield, group_desc_options, group_type, group_founder_manage - FROM ' . GROUPS_TABLE . ' - WHERE ' . ((count($group_id_ary)) ? $db->sql_in_set('group_id', $group_id_ary, true) . ' AND ' : '') . " - group_type $sql_and - ORDER BY group_type DESC, group_name"; - $result = $db->sql_query($sql); - - $nonmember_count = 0; - while ($row = $db->sql_fetchrow($result)) - { - switch ($row['group_type']) - { - case GROUP_OPEN: - $group_status = 'OPEN'; - break; - - case GROUP_CLOSED: - $group_status = 'CLOSED'; - break; - - case GROUP_HIDDEN: - $group_status = 'HIDDEN'; - break; - - case GROUP_SPECIAL: - $group_status = 'SPECIAL'; - break; - - case GROUP_FREE: - $group_status = 'FREE'; - break; - } - - $template->assign_block_vars('nonmember', array( - 'GROUP_ID' => $row['group_id'], - 'GROUP_NAME' => $group_helper->get_name($row['group_name']), - 'GROUP_DESC' => ($row['group_type'] <> GROUP_SPECIAL) ? generate_text_for_display($row['group_desc'], $row['group_desc_uid'], $row['group_desc_bitfield'], $row['group_desc_options']) : $user->lang['GROUP_IS_SPECIAL'], - 'GROUP_SPECIAL' => ($row['group_type'] <> GROUP_SPECIAL) ? false : true, - 'GROUP_CLOSED' => ($row['group_type'] <> GROUP_CLOSED || $auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) ? false : true, - 'GROUP_STATUS' => $user->lang['GROUP_IS_' . $group_status], - 'S_CAN_JOIN' => ($row['group_type'] == GROUP_OPEN || $row['group_type'] == GROUP_FREE) ? true : false, - 'GROUP_COLOUR' => $row['group_colour'], - - 'U_VIEW_GROUP' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&g=' . $row['group_id']), - - 'S_ROW_COUNT' => $nonmember_count++) - ); - } - $db->sql_freeresult($result); - - $template->assign_vars(array( - 'S_CHANGE_DEFAULT' => ($auth->acl_get('u_chggrp')) ? true : false, - 'S_LEADER_COUNT' => $leader_count, - 'S_MEMBER_COUNT' => $member_count, - 'S_PENDING_COUNT' => $pending_count, - 'S_NONMEMBER_COUNT' => $nonmember_count, - - 'S_UCP_ACTION' => $this->u_action) - ); - - break; - - case 'manage': - - $this->page_title = 'UCP_USERGROUPS_MANAGE'; - $action = (isset($_POST['addusers'])) ? 'addusers' : $request->variable('action', ''); - $group_id = $request->variable('g', 0); - - if (!function_exists('phpbb_get_user_rank')) - { - include($phpbb_root_path . 'includes/functions_display.' . $phpEx); - } - - add_form_key('ucp_groups'); - - if ($group_id) - { - $sql = 'SELECT g.*, t.teampage_position AS group_teampage - FROM ' . GROUPS_TABLE . ' g - LEFT JOIN ' . TEAMPAGE_TABLE . ' t - ON (t.group_id = g.group_id) - WHERE g.group_id = ' . $group_id; - $result = $db->sql_query($sql); - $group_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$group_row) - { - trigger_error($user->lang['NO_GROUP'] . $return_page); - } - - // Check if the user is allowed to manage this group if set to founder only. - if ($user->data['user_type'] != USER_FOUNDER && $group_row['group_founder_manage']) - { - trigger_error($user->lang['NOT_ALLOWED_MANAGE_GROUP'] . $return_page, E_USER_WARNING); - } - - $group_name = $group_row['group_name']; - $group_type = $group_row['group_type']; - - $avatar = phpbb_get_group_avatar($group_row, 'GROUP_AVATAR', true); - - $template->assign_vars(array( - 'GROUP_NAME' => $group_helper->get_name($group_name), - 'GROUP_INTERNAL_NAME' => $group_name, - 'GROUP_COLOUR' => (isset($group_row['group_colour'])) ? $group_row['group_colour'] : '', - 'GROUP_DESC_DISP' => generate_text_for_display($group_row['group_desc'], $group_row['group_desc_uid'], $group_row['group_desc_bitfield'], $group_row['group_desc_options']), - 'GROUP_TYPE' => $group_row['group_type'], - - 'AVATAR' => (empty($avatar) ? '' : $avatar), - 'AVATAR_IMAGE' => (empty($avatar) ? '' : $avatar), - 'AVATAR_WIDTH' => (isset($group_row['group_avatar_width'])) ? $group_row['group_avatar_width'] : '', - 'AVATAR_HEIGHT' => (isset($group_row['group_avatar_height'])) ? $group_row['group_avatar_height'] : '', - )); - } - - switch ($action) - { - case 'edit': - - if (!$group_id) - { - trigger_error($user->lang['NO_GROUP'] . $return_page); - } - - if (!($row = group_memberships($group_id, $user->data['user_id']))) - { - trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page); - } - list(, $row) = each($row); - - if (!$row['group_leader']) - { - trigger_error($user->lang['NOT_LEADER_OF_GROUP'] . $return_page); - } - - $user->add_lang(array('acp/groups', 'acp/common')); - - $update = (isset($_POST['update'])) ? true : false; - - $error = array(); - - // Setup avatar data for later - $avatars_enabled = false; - $avatar_drivers = null; - $avatar_data = null; - $avatar_error = array(); - - /** @var \phpbb\avatar\manager $phpbb_avatar_manager */ - $phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); - - if ($config['allow_avatar']) - { - $avatar_drivers = $phpbb_avatar_manager->get_enabled_drivers(); - - // This is normalised data, without the group_ prefix - $avatar_data = \phpbb\avatar\manager::clean_row($group_row, 'group'); - } - - // Handle deletion of avatars - if ($request->is_set_post('avatar_delete')) - { - if (confirm_box(true)) - { - $phpbb_avatar_manager->handle_avatar_delete($db, $user, $avatar_data, GROUPS_TABLE, 'group_'); - $cache->destroy('sql', GROUPS_TABLE); - - $message = ($action == 'edit') ? 'GROUP_UPDATED' : 'GROUP_CREATED'; - trigger_error($user->lang[$message] . $return_page); - } - else - { - confirm_box(false, $user->lang('CONFIRM_AVATAR_DELETE'), build_hidden_fields(array( - 'avatar_delete' => true, - 'i' => $id, - 'mode' => $mode, - 'g' => $group_id, - 'action' => $action)) - ); - } - } - - // Did we submit? - if ($update) - { - $group_name = $request->variable('group_name', '', true); - $group_desc = $request->variable('group_desc', '', true); - $group_type = $request->variable('group_type', GROUP_FREE); - - $allow_desc_bbcode = $request->variable('desc_parse_bbcode', false); - $allow_desc_urls = $request->variable('desc_parse_urls', false); - $allow_desc_smilies = $request->variable('desc_parse_smilies', false); - - $submit_ary = array( - 'colour' => $request->variable('group_colour', ''), - 'rank' => $request->variable('group_rank', 0), - 'receive_pm' => isset($_REQUEST['group_receive_pm']) ? 1 : 0, - 'message_limit' => $request->variable('group_message_limit', 0), - 'max_recipients'=> $request->variable('group_max_recipients', 0), - 'legend' => $group_row['group_legend'], - 'teampage' => $group_row['group_teampage'], - ); - - if ($config['allow_avatar']) - { - // Handle avatar - $driver_name = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', '')); - - if (in_array($driver_name, $avatar_drivers) && !$request->is_set_post('avatar_delete')) - { - $driver = $phpbb_avatar_manager->get_driver($driver_name); - $result = $driver->process_form($request, $template, $user, $avatar_data, $avatar_error); - - if ($result && empty($avatar_error)) - { - $result['avatar_type'] = $driver_name; - - $submit_ary = array_merge($submit_ary, $result); - } - } - - // Merge any avatars errors into the primary error array - $error = array_merge($error, $phpbb_avatar_manager->localize_errors($user, $avatar_error)); - } - - if (!check_form_key('ucp_groups')) - { - $error[] = $user->lang['FORM_INVALID']; - } - - // Validate submitted colour value - if ($colour_error = validate_data($submit_ary, array('colour' => array('hex_colour', true)))) - { - // Replace "error" string with its real, localised form - $error = array_merge($error, $colour_error); - } - - if (!count($error)) - { - // Only set the rank, colour, etc. if it's changed or if we're adding a new - // group. This prevents existing group members being updated if no changes - // were made. - // However there are some attributes that need to be set everytime, - // otherwise the group gets removed from the feature. - $set_attributes = array('legend', 'teampage'); - - $group_attributes = array(); - $test_variables = array( - 'rank' => 'int', - 'colour' => 'string', - 'avatar' => 'string', - 'avatar_type' => 'string', - 'avatar_width' => 'int', - 'avatar_height' => 'int', - 'receive_pm' => 'int', - 'legend' => 'int', - 'teampage' => 'int', - 'message_limit' => 'int', - 'max_recipients'=> 'int', - ); - - foreach ($test_variables as $test => $type) - { - if (isset($submit_ary[$test]) && ($action == 'add' || $group_row['group_' . $test] != $submit_ary[$test] || isset($group_attributes['group_avatar']) && strpos($test, 'avatar') === 0 || in_array($test, $set_attributes))) - { - settype($submit_ary[$test], $type); - $group_attributes['group_' . $test] = $group_row['group_' . $test] = $submit_ary[$test]; - } - } - - if (!($error = group_create($group_id, $group_type, $group_name, $group_desc, $group_attributes, $allow_desc_bbcode, $allow_desc_urls, $allow_desc_smilies))) - { - $cache->destroy('sql', GROUPS_TABLE); - $cache->destroy('sql', TEAMPAGE_TABLE); - - $message = ($action == 'edit') ? 'GROUP_UPDATED' : 'GROUP_CREATED'; - trigger_error($user->lang[$message] . $return_page); - } - } - - if (count($error)) - { - $error = array_map(array(&$user, 'lang'), $error); - $group_rank = $submit_ary['rank']; - - $group_desc_data = array( - 'text' => $group_desc, - 'allow_bbcode' => $allow_desc_bbcode, - 'allow_smilies' => $allow_desc_smilies, - 'allow_urls' => $allow_desc_urls - ); - } - } - else if (!$group_id) - { - $group_desc_data = array( - 'text' => '', - 'allow_bbcode' => true, - 'allow_smilies' => true, - 'allow_urls' => true - ); - $group_rank = 0; - $group_type = GROUP_OPEN; - } - else - { - $group_desc_data = generate_text_for_edit($group_row['group_desc'], $group_row['group_desc_uid'], $group_row['group_desc_options']); - $group_rank = $group_row['group_rank']; - } - - $sql = 'SELECT * - FROM ' . RANKS_TABLE . ' - WHERE rank_special = 1 - ORDER BY rank_title'; - $result = $db->sql_query($sql); - - $rank_options = ''; - while ($row = $db->sql_fetchrow($result)) - { - $selected = ($group_rank && $row['rank_id'] == $group_rank) ? ' selected="selected"' : ''; - $rank_options .= ''; - } - $db->sql_freeresult($result); - - $type_free = ($group_type == GROUP_FREE) ? ' checked="checked"' : ''; - $type_open = ($group_type == GROUP_OPEN) ? ' checked="checked"' : ''; - $type_closed = ($group_type == GROUP_CLOSED) ? ' checked="checked"' : ''; - $type_hidden = ($group_type == GROUP_HIDDEN) ? ' checked="checked"' : ''; - - // Load up stuff for avatars - if ($config['allow_avatar']) - { - $avatars_enabled = false; - $selected_driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', $avatar_data['avatar_type'])); - - // Assign min and max values before generating avatar driver html - $template->assign_vars(array( - 'AVATAR_MIN_WIDTH' => $config['avatar_min_width'], - 'AVATAR_MAX_WIDTH' => $config['avatar_max_width'], - 'AVATAR_MIN_HEIGHT' => $config['avatar_min_height'], - 'AVATAR_MAX_HEIGHT' => $config['avatar_max_height'], - )); - - foreach ($avatar_drivers as $current_driver) - { - $driver = $phpbb_avatar_manager->get_driver($current_driver); - - $avatars_enabled = true; - $template->set_filenames(array( - 'avatar' => $driver->get_template_name(), - )); - - if ($driver->prepare_form($request, $template, $user, $avatar_data, $avatar_error)) - { - $driver_name = $phpbb_avatar_manager->prepare_driver_name($current_driver); - $driver_upper = strtoupper($driver_name); - $template->assign_block_vars('avatar_drivers', array( - 'L_TITLE' => $user->lang($driver_upper . '_TITLE'), - 'L_EXPLAIN' => $user->lang($driver_upper . '_EXPLAIN'), - - 'DRIVER' => $driver_name, - 'SELECTED' => $current_driver == $selected_driver, - 'OUTPUT' => $template->assign_display('avatar'), - )); - } - } - } - - if (isset($phpbb_avatar_manager) && !$update) - { - // Merge any avatars errors into the primary error array - $error = array_merge($error, $phpbb_avatar_manager->localize_errors($user, $avatar_error)); - } - - $template->assign_vars(array( - 'S_EDIT' => true, - 'S_INCLUDE_SWATCH' => true, - 'S_FORM_ENCTYPE' => ' enctype="multipart/form-data"', - 'S_ERROR' => (count($error)) ? true : false, - 'S_SPECIAL_GROUP' => ($group_type == GROUP_SPECIAL) ? true : false, - 'S_AVATARS_ENABLED' => ($config['allow_avatar'] && $avatars_enabled), - 'S_GROUP_MANAGE' => true, - - 'ERROR_MSG' => (count($error)) ? implode('
', $error) : '', - 'GROUP_RECEIVE_PM' => (isset($group_row['group_receive_pm']) && $group_row['group_receive_pm']) ? ' checked="checked"' : '', - 'GROUP_MESSAGE_LIMIT' => (isset($group_row['group_message_limit'])) ? $group_row['group_message_limit'] : 0, - 'GROUP_MAX_RECIPIENTS' => (isset($group_row['group_max_recipients'])) ? $group_row['group_max_recipients'] : 0, - - 'GROUP_DESC' => $group_desc_data['text'], - 'S_DESC_BBCODE_CHECKED' => $group_desc_data['allow_bbcode'], - 'S_DESC_URLS_CHECKED' => $group_desc_data['allow_urls'], - 'S_DESC_SMILIES_CHECKED'=> $group_desc_data['allow_smilies'], - - 'S_RANK_OPTIONS' => $rank_options, - - 'GROUP_TYPE_FREE' => GROUP_FREE, - 'GROUP_TYPE_OPEN' => GROUP_OPEN, - 'GROUP_TYPE_CLOSED' => GROUP_CLOSED, - 'GROUP_TYPE_HIDDEN' => GROUP_HIDDEN, - 'GROUP_TYPE_SPECIAL' => GROUP_SPECIAL, - - 'GROUP_FREE' => $type_free, - 'GROUP_OPEN' => $type_open, - 'GROUP_CLOSED' => $type_closed, - 'GROUP_HIDDEN' => $type_hidden, - - 'S_UCP_ACTION' => $this->u_action . "&action=$action&g=$group_id", - 'L_AVATAR_EXPLAIN' => phpbb_avatar_explanation_string(), - )); - - break; - - case 'list': - - if (!$group_id) - { - trigger_error($user->lang['NO_GROUP'] . $return_page); - } - - if (!($row = group_memberships($group_id, $user->data['user_id']))) - { - trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page); - } - list(, $row) = each($row); - - if (!$row['group_leader']) - { - trigger_error($user->lang['NOT_LEADER_OF_GROUP'] . $return_page); - } - - $user->add_lang(array('acp/groups', 'acp/common')); - $start = $request->variable('start', 0); - - // Grab the leaders - always, on every page... - $sql = 'SELECT u.user_id, u.username, u.username_clean, u.user_colour, u.user_regdate, u.user_posts, u.group_id, ug.group_leader, ug.user_pending - FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . " ug - WHERE ug.group_id = $group_id - AND u.user_id = ug.user_id - AND ug.group_leader = 1 - ORDER BY ug.user_pending DESC, u.username_clean"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $template->assign_block_vars('leader', array( - 'USERNAME' => $row['username'], - 'USERNAME_COLOUR' => $row['user_colour'], - 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), - 'U_USER_VIEW' => get_username_string('profile', $row['user_id'], $row['username']), - 'S_GROUP_DEFAULT' => ($row['group_id'] == $group_id) ? true : false, - 'JOINED' => ($row['user_regdate']) ? $user->format_date($row['user_regdate']) : ' - ', - 'USER_POSTS' => $row['user_posts'], - 'USER_ID' => $row['user_id']) - ); - } - $db->sql_freeresult($result); - - // Total number of group members (non-leaders) - $sql = 'SELECT COUNT(user_id) AS total_members - FROM ' . USER_GROUP_TABLE . " - WHERE group_id = $group_id - AND group_leader = 0"; - $result = $db->sql_query($sql); - $total_members = (int) $db->sql_fetchfield('total_members'); - $db->sql_freeresult($result); - - // Grab the members - $sql = 'SELECT u.user_id, u.username, u.username_clean, u.user_colour, u.user_regdate, u.user_posts, u.group_id, ug.group_leader, ug.user_pending - FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . " ug - WHERE ug.group_id = $group_id - AND u.user_id = ug.user_id - AND ug.group_leader = 0 - ORDER BY ug.user_pending DESC, u.username_clean"; - $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); - - $pending = false; - $approved = false; - - while ($row = $db->sql_fetchrow($result)) - { - if ($row['user_pending'] && !$pending) - { - $template->assign_block_vars('member', array( - 'S_PENDING' => true) - ); - $template->assign_var('S_PENDING_SET', true); - - $pending = true; - } - else if (!$row['user_pending'] && !$approved) - { - $template->assign_block_vars('member', array( - 'S_APPROVED' => true) - ); - $template->assign_var('S_APPROVED_SET', true); - - $approved = true; - } - - $template->assign_block_vars('member', array( - 'USERNAME' => $row['username'], - 'USERNAME_COLOUR' => $row['user_colour'], - 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), - 'U_USER_VIEW' => get_username_string('profile', $row['user_id'], $row['username']), - 'S_GROUP_DEFAULT' => ($row['group_id'] == $group_id) ? true : false, - 'JOINED' => ($row['user_regdate']) ? $user->format_date($row['user_regdate']) : ' - ', - 'USER_POSTS' => $row['user_posts'], - 'USER_ID' => $row['user_id']) - ); - } - $db->sql_freeresult($result); - - $s_action_options = ''; - $options = array('default' => 'DEFAULT', 'approve' => 'APPROVE', 'deleteusers' => 'DELETE'); - - foreach ($options as $option => $lang) - { - $s_action_options .= ''; - } - - /* @var $pagination \phpbb\pagination */ - $pagination = $phpbb_container->get('pagination'); - $base_url = $this->u_action . "&action=$action&g=$group_id"; - $start = $pagination->validate_start($start, $config['topics_per_page'], $total_members); - $pagination->generate_template_pagination($base_url, 'pagination', 'start', $total_members, $config['topics_per_page'], $start); - - $template->assign_vars(array( - 'S_LIST' => true, - 'S_ACTION_OPTIONS' => $s_action_options, - - 'U_ACTION' => $this->u_action . "&g=$group_id", - 'S_UCP_ACTION' => $this->u_action . "&g=$group_id", - 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=ucp&field=usernames'), - )); - - break; - - case 'approve': - - if (!$group_id) - { - trigger_error($user->lang['NO_GROUP'] . $return_page); - } - - if (!($row = group_memberships($group_id, $user->data['user_id']))) - { - trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page); - } - list(, $row) = each($row); - - if (!$row['group_leader']) - { - trigger_error($user->lang['NOT_LEADER_OF_GROUP'] . $return_page); - } - - $user->add_lang('acp/groups'); - - // Approve, demote or promote - group_user_attributes('approve', $group_id, $mark_ary, false, false); - - trigger_error($user->lang['USERS_APPROVED'] . '

' . sprintf($user->lang['RETURN_PAGE'], '', '')); - - break; - - case 'default': - - if (!$group_id) - { - trigger_error($user->lang['NO_GROUP'] . $return_page); - } - - if (!($row = group_memberships($group_id, $user->data['user_id']))) - { - trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page); - } - list(, $row) = each($row); - - if (!$row['group_leader']) - { - trigger_error($user->lang['NOT_LEADER_OF_GROUP'] . $return_page); - } - - $group_row['group_name'] = $group_helper->get_name($group_row['group_name']); - - if (confirm_box(true)) - { - if (!count($mark_ary)) - { - $start = 0; - - do - { - $sql = 'SELECT user_id - FROM ' . USER_GROUP_TABLE . " - WHERE group_id = $group_id - ORDER BY user_id"; - $result = $db->sql_query_limit($sql, 200, $start); - - $mark_ary = array(); - if ($row = $db->sql_fetchrow($result)) - { - do - { - $mark_ary[] = $row['user_id']; - } - while ($row = $db->sql_fetchrow($result)); - - group_user_attributes('default', $group_id, $mark_ary, false, $group_row['group_name'], $group_row); - - $start = (count($mark_ary) < 200) ? 0 : $start + 200; - } - else - { - $start = 0; - } - $db->sql_freeresult($result); - } - while ($start); - } - else - { - group_user_attributes('default', $group_id, $mark_ary, false, $group_row['group_name'], $group_row); - } - - $user->add_lang('acp/groups'); - - trigger_error($user->lang['GROUP_DEFS_UPDATED'] . '

' . sprintf($user->lang['RETURN_PAGE'], '', '')); - } - else - { - $user->add_lang('acp/common'); - - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( - 'mark' => $mark_ary, - 'g' => $group_id, - 'i' => $id, - 'mode' => $mode, - 'action' => $action)) - ); - } - - // redirect to last screen - redirect($this->u_action . '&action=list&g=' . $group_id); - - break; - - case 'deleteusers': - - $user->add_lang(array('acp/groups', 'acp/common')); - - if (!($row = group_memberships($group_id, $user->data['user_id']))) - { - trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page); - } - list(, $row) = each($row); - - if (!$row['group_leader']) - { - trigger_error($user->lang['NOT_LEADER_OF_GROUP'] . $return_page); - } - - $group_row['group_name'] = $group_helper->get_name($group_row['group_name']); - - if (confirm_box(true)) - { - if (!$group_id) - { - trigger_error($user->lang['NO_GROUP'] . $return_page); - } - - $error = group_user_del($group_id, $mark_ary, false, $group_row['group_name']); - - if ($error) - { - trigger_error($user->lang[$error] . '

' . sprintf($user->lang['RETURN_PAGE'], '', '')); - } - - trigger_error($user->lang['GROUP_USERS_REMOVE'] . '

' . sprintf($user->lang['RETURN_PAGE'], '', '')); - } - else - { - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( - 'mark' => $mark_ary, - 'g' => $group_id, - 'i' => $id, - 'mode' => $mode, - 'action' => $action)) - ); - } - - // redirect to last screen - redirect($this->u_action . '&action=list&g=' . $group_id); - - break; - - case 'addusers': - - $user->add_lang(array('acp/groups', 'acp/common')); - - $names = $request->variable('usernames', '', true); - - if (!$group_id) - { - trigger_error($user->lang['NO_GROUP'] . $return_page); - } - - if (!$names) - { - trigger_error($user->lang['NO_USERS'] . $return_page); - } - - if (!($row = group_memberships($group_id, $user->data['user_id']))) - { - trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page); - } - list(, $row) = each($row); - - if (!$row['group_leader']) - { - trigger_error($user->lang['NOT_LEADER_OF_GROUP'] . $return_page); - } - - $name_ary = array_unique(explode("\n", $names)); - $group_name = $group_helper->get_name($group_row['group_name']); - - $default = $request->variable('default', 0); - - if (confirm_box(true)) - { - $return_manage_page = '

' . $language->lang('RETURN_PAGE', '', ''); - - // Add user/s to group - if ($error = group_user_add($group_id, false, $name_ary, $group_name, $default, 0, 0, $group_row)) - { - $display_message = $language->lang($error); - - if ($error == 'GROUP_USERS_INVALID') - { - // Find which users don't exist - $actual_name_ary = $name_ary; - $actual_user_id_ary = []; - user_get_id_name($actual_user_id_ary, $actual_name_ary, false, true); - - $display_message = $language->lang('GROUP_USERS_INVALID', implode($language->lang('COMMA_SEPARATOR'), array_udiff($name_ary, $actual_name_ary, 'strcasecmp'))); - } - - trigger_error($display_message . $return_manage_page); - } - - trigger_error($language->lang('GROUP_USERS_ADDED') . $return_manage_page); - } - else - { - $s_hidden_fields = array( - 'default' => $default, - 'usernames' => $names, - 'g' => $group_id, - 'i' => $id, - 'mode' => $mode, - 'action' => $action - ); - - confirm_box(false, $user->lang('GROUP_CONFIRM_ADD_USERS', count($name_ary), implode($user->lang['COMMA_SEPARATOR'], $name_ary)), build_hidden_fields($s_hidden_fields)); - } - - trigger_error($user->lang['NO_USERS_ADDED'] . '

' . sprintf($user->lang['RETURN_PAGE'], '', '')); - - break; - - default: - $user->add_lang('acp/common'); - - $sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_desc, g.group_desc_uid, g.group_desc_bitfield, g.group_desc_options, g.group_type, ug.group_leader - FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . ' ug - WHERE ug.user_id = ' . $user->data['user_id'] . ' - AND g.group_id = ug.group_id - AND ug.group_leader = 1 - ORDER BY g.group_type DESC, g.group_name'; - $result = $db->sql_query($sql); - - while ($value = $db->sql_fetchrow($result)) - { - $template->assign_block_vars('leader', array( - 'GROUP_NAME' => $group_helper->get_name($value['group_name']), - 'GROUP_DESC' => generate_text_for_display($value['group_desc'], $value['group_desc_uid'], $value['group_desc_bitfield'], $value['group_desc_options']), - 'GROUP_TYPE' => $value['group_type'], - 'GROUP_ID' => $value['group_id'], - 'GROUP_COLOUR' => $value['group_colour'], - - 'U_LIST' => $this->u_action . "&action=list&g={$value['group_id']}", - 'U_EDIT' => $this->u_action . "&action=edit&g={$value['group_id']}") - ); - } - $db->sql_freeresult($result); - - break; - } - - break; - } - - $this->tpl_name = 'ucp_groups_' . $mode; - } -} diff --git a/install/update/old/includes/ucp/ucp_pm.php b/install/update/old/includes/ucp/ucp_pm.php deleted file mode 100644 index 4d02620..0000000 --- a/install/update/old/includes/ucp/ucp_pm.php +++ /dev/null @@ -1,435 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* Private Message Class -* -* $_REQUEST['folder'] display folder with the id used -* $_REQUEST['folder'] inbox|outbox|sentbox display folder with the associated name -* -* Display Messages (default to inbox) - mode=view -* Display single message - mode=view&p=[msg_id] or &p=[msg_id] (short linkage) -* -* if the folder id with (&f=[folder_id]) is used when displaying messages, one query will be saved. If it is not used, phpBB needs to grab -* the folder id first in order to display the input boxes and folder names and such things. ;) phpBB always checks this against the database to make -* sure the user is able to view the message. -* -* Composing Messages (mode=compose): -* To specific user (u=[user_id]) -* To specific group (g=[group_id]) -* Quoting a post (action=quotepost&p=[post_id]) -* Quoting a PM (action=quote&p=[msg_id]) -* Forwarding a PM (action=forward&p=[msg_id]) -*/ -class ucp_pm -{ - var $u_action; - - function main($id, $mode) - { - global $user, $template, $phpbb_root_path, $auth, $phpEx, $db, $config, $request; - - if (!$user->data['is_registered']) - { - trigger_error('NO_MESSAGE'); - } - - // Is PM disabled? - if (!$config['allow_privmsg']) - { - trigger_error('PM_DISABLED'); - } - - $user->add_lang('posting'); - $template->assign_var('S_PRIVMSGS', true); - - // Folder directly specified? - $folder_specified = $request->variable('folder', ''); - - if (!in_array($folder_specified, array('inbox', 'outbox', 'sentbox'))) - { - $folder_specified = (int) $folder_specified; - } - else - { - $folder_specified = ($folder_specified == 'inbox') ? PRIVMSGS_INBOX : (($folder_specified == 'outbox') ? PRIVMSGS_OUTBOX : PRIVMSGS_SENTBOX); - } - - if (!$folder_specified) - { - $mode = (!$mode) ? $request->variable('mode', 'view') : $mode; - } - else - { - $mode = 'view'; - } - - if (!function_exists('get_folder')) - { - include($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx); - } - - switch ($mode) - { - // Compose message - case 'compose': - $action = $request->variable('action', 'post'); - - $user_folders = get_folder($user->data['user_id']); - - if ($action != 'delete' && !$auth->acl_get('u_sendpm')) - { - // trigger_error('NO_AUTH_SEND_MESSAGE'); - $template->assign_vars(array( - 'S_NO_AUTH_SEND_MESSAGE' => true, - 'S_COMPOSE_PM_VIEW' => true, - )); - - $tpl_file = 'ucp_pm_viewfolder'; - break; - } - - if (!function_exists('compose_pm')) - { - include($phpbb_root_path . 'includes/ucp/ucp_pm_compose.' . $phpEx); - } - compose_pm($id, $mode, $action, $user_folders); - - $tpl_file = 'posting_body'; - break; - - case 'options': - set_user_message_limit(); - get_folder($user->data['user_id']); - - if (!function_exists('message_options')) - { - include($phpbb_root_path . 'includes/ucp/ucp_pm_options.' . $phpEx); - } - message_options($id, $mode, $global_privmsgs_rules, $global_rule_conditions); - - $tpl_file = 'ucp_pm_options'; - break; - - case 'drafts': - - get_folder($user->data['user_id']); - $this->p_name = 'pm'; - - if (!class_exists('ucp_main')) - { - include($phpbb_root_path . 'includes/ucp/ucp_main.' . $phpEx); - } - - $module = new ucp_main($this); - $module->u_action = $this->u_action; - $module->main($id, $mode); - - $this->tpl_name = $module->tpl_name; - $this->page_title = 'UCP_PM_DRAFTS'; - - unset($module); - return; - - break; - - case 'view': - - set_user_message_limit(); - - if ($folder_specified) - { - $folder_id = $folder_specified; - $action = 'view_folder'; - } - else - { - $folder_id = $request->variable('f', PRIVMSGS_NO_BOX); - $action = $request->variable('action', 'view_folder'); - } - - $msg_id = $request->variable('p', 0); - $view = $request->variable('view', ''); - - // View message if specified - if ($msg_id) - { - $action = 'view_message'; - } - - if (!$auth->acl_get('u_readpm')) - { - send_status_line(403, 'Forbidden'); - trigger_error('NO_AUTH_READ_MESSAGE'); - } - - if ($view == 'print' && (!$config['print_pm'] || !$auth->acl_get('u_pm_printpm'))) - { - send_status_line(403, 'Forbidden'); - trigger_error('NO_AUTH_PRINT_MESSAGE'); - } - - // Do not allow hold messages to be seen - if ($folder_id == PRIVMSGS_HOLD_BOX) - { - trigger_error('NO_AUTH_READ_HOLD_MESSAGE'); - } - - // First Handle Mark actions and moving messages - $submit_mark = (isset($_POST['submit_mark'])) ? true : false; - $move_pm = (isset($_POST['move_pm'])) ? true : false; - $mark_option = $request->variable('mark_option', ''); - $dest_folder = $request->variable('dest_folder', PRIVMSGS_NO_BOX); - - // Is moving PM triggered through mark options? - if (!in_array($mark_option, array('mark_important', 'delete_marked')) && $submit_mark) - { - $move_pm = true; - $dest_folder = (int) $mark_option; - $submit_mark = false; - } - - // Move PM - if ($move_pm) - { - $move_msg_ids = (isset($_POST['marked_msg_id'])) ? $request->variable('marked_msg_id', array(0)) : array(); - $cur_folder_id = $request->variable('cur_folder_id', PRIVMSGS_NO_BOX); - - if (move_pm($user->data['user_id'], $user->data['message_limit'], $move_msg_ids, $dest_folder, $cur_folder_id)) - { - // Return to folder view if single message moved - if ($action == 'view_message') - { - $msg_id = 0; - $folder_id = $request->variable('cur_folder_id', PRIVMSGS_NO_BOX); - $action = 'view_folder'; - } - } - } - - // Message Mark Options - if ($submit_mark) - { - handle_mark_actions($user->data['user_id'], $mark_option); - } - - // If new messages arrived, place them into the appropriate folder - $num_not_moved = $num_removed = 0; - $release = $request->variable('release', 0); - - if ($user->data['user_new_privmsg'] && ($action == 'view_folder' || $action == 'view_message')) - { - $return = place_pm_into_folder($global_privmsgs_rules, $release); - $num_not_moved = $return['not_moved']; - $num_removed = $return['removed']; - } - - if (!$msg_id && $folder_id == PRIVMSGS_NO_BOX) - { - $folder_id = PRIVMSGS_INBOX; - } - else if ($msg_id && $folder_id == PRIVMSGS_NO_BOX) - { - $sql = 'SELECT folder_id - FROM ' . PRIVMSGS_TO_TABLE . " - WHERE msg_id = $msg_id - AND folder_id <> " . PRIVMSGS_NO_BOX . ' - AND user_id = ' . $user->data['user_id']; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - trigger_error('NO_MESSAGE'); - } - $folder_id = (int) $row['folder_id']; - } - - if ($request->variable('mark', '') == 'all' && check_link_hash($request->variable('token', ''), 'mark_all_pms_read')) - { - mark_folder_read($user->data['user_id'], $folder_id); - - meta_refresh(3, $this->u_action); - $message = $user->lang['PM_MARK_ALL_READ_SUCCESS']; - - if ($request->is_ajax()) - { - $json_response = new \phpbb\json_response(); - $json_response->send(array( - 'MESSAGE_TITLE' => $user->lang['INFORMATION'], - 'MESSAGE_TEXT' => $message, - 'success' => true, - )); - } - $message .= '

' . $user->lang('RETURN_UCP', '', ''); - - trigger_error($message); - } - - $message_row = array(); - if ($action == 'view_message' && $msg_id) - { - // Get Message user want to see - if ($view == 'next' || $view == 'previous') - { - $sql_condition = ($view == 'next') ? '>' : '<'; - $sql_ordering = ($view == 'next') ? 'ASC' : 'DESC'; - - $sql = 'SELECT t.msg_id - FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p, ' . PRIVMSGS_TABLE . " p2 - WHERE p2.msg_id = $msg_id - AND t.folder_id = $folder_id - AND t.user_id = " . $user->data['user_id'] . " - AND t.msg_id = p.msg_id - AND p.message_time $sql_condition p2.message_time - ORDER BY p.message_time $sql_ordering"; - $result = $db->sql_query_limit($sql, 1); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - $message = ($view == 'next') ? 'NO_NEWER_PM' : 'NO_OLDER_PM'; - trigger_error($message); - } - else - { - $msg_id = $row['msg_id']; - } - } - - $sql = 'SELECT t.*, p.*, u.* - FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p, ' . USERS_TABLE . ' u - WHERE t.user_id = ' . $user->data['user_id'] . " - AND p.author_id = u.user_id - AND t.folder_id = $folder_id - AND t.msg_id = p.msg_id - AND p.msg_id = $msg_id"; - $result = $db->sql_query($sql); - $message_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$message_row) - { - trigger_error('NO_MESSAGE'); - } - - // Update unread status - update_unread_status($message_row['pm_unread'], $message_row['msg_id'], $user->data['user_id'], $folder_id); - } - - $folder = get_folder($user->data['user_id'], $folder_id); - - $s_folder_options = $s_to_folder_options = ''; - foreach ($folder as $f_id => $folder_ary) - { - $option = '' . $folder_ary['folder_name'] . (($folder_ary['unread_messages']) ? ' [' . $folder_ary['unread_messages'] . '] ' : '') . ''; - - $s_to_folder_options .= ($f_id != PRIVMSGS_OUTBOX && $f_id != PRIVMSGS_SENTBOX) ? $option : ''; - $s_folder_options .= $option; - } - clean_sentbox($folder[PRIVMSGS_SENTBOX]['num_messages']); - - // Header for message view - folder and so on - $folder_status = get_folder_status($folder_id, $folder); - - $template->assign_vars(array( - 'CUR_FOLDER_ID' => $folder_id, - 'CUR_FOLDER_NAME' => $folder_status['folder_name'], - 'NUM_NOT_MOVED' => $num_not_moved, - 'NUM_REMOVED' => $num_removed, - 'RELEASE_MESSAGE_INFO' => sprintf($user->lang['RELEASE_MESSAGES'], '', ''), - 'NOT_MOVED_MESSAGES' => $user->lang('NOT_MOVED_MESSAGES', (int) $num_not_moved), - 'RULE_REMOVED_MESSAGES' => $user->lang('RULE_REMOVED_MESSAGES', (int) $num_removed), - - 'S_FOLDER_OPTIONS' => $s_folder_options, - 'S_TO_FOLDER_OPTIONS' => $s_to_folder_options, - 'S_FOLDER_ACTION' => $this->u_action . '&action=view_folder', - 'S_PM_ACTION' => $this->u_action . '&action=' . $action, - - 'U_INBOX' => $this->u_action . '&folder=inbox', - 'U_OUTBOX' => $this->u_action . '&folder=outbox', - 'U_SENTBOX' => $this->u_action . '&folder=sentbox', - 'U_CREATE_FOLDER' => $this->u_action . '&mode=options', - 'U_CURRENT_FOLDER' => $this->u_action . '&folder=' . $folder_id, - 'U_MARK_ALL' => $this->u_action . '&folder=' . $folder_id . '&mark=all&token=' . generate_link_hash('mark_all_pms_read'), - - 'S_IN_INBOX' => ($folder_id == PRIVMSGS_INBOX) ? true : false, - 'S_IN_OUTBOX' => ($folder_id == PRIVMSGS_OUTBOX) ? true : false, - 'S_IN_SENTBOX' => ($folder_id == PRIVMSGS_SENTBOX) ? true : false, - - 'FOLDER_STATUS' => $folder_status['message'], - 'FOLDER_MAX_MESSAGES' => $folder_status['max'], - 'FOLDER_CUR_MESSAGES' => $folder_status['cur'], - 'FOLDER_REMAINING_MESSAGES' => $folder_status['remaining'], - 'FOLDER_PERCENT' => $folder_status['percent']) - ); - - if ($action == 'view_folder') - { - if (!function_exists('view_folder')) - { - include($phpbb_root_path . 'includes/ucp/ucp_pm_viewfolder.' . $phpEx); - } - view_folder($id, $mode, $folder_id, $folder); - - $tpl_file = 'ucp_pm_viewfolder'; - } - else if ($action == 'view_message') - { - $template->assign_vars(array( - 'S_VIEW_MESSAGE' => true, - 'L_RETURN_TO_FOLDER' => $user->lang('RETURN_TO', $folder_status['folder_name']), - 'MSG_ID' => $msg_id, - )); - - if (!$msg_id) - { - trigger_error('NO_MESSAGE'); - } - - if (!function_exists('view_message')) - { - include($phpbb_root_path . 'includes/ucp/ucp_pm_viewmessage.' . $phpEx); - } - view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row); - - $tpl_file = ($view == 'print') ? 'ucp_pm_viewmessage_print' : 'ucp_pm_viewmessage'; - } - - break; - - default: - trigger_error('NO_ACTION_MODE', E_USER_ERROR); - break; - } - - $template->assign_vars(array( - 'L_TITLE' => $user->lang['UCP_PM_' . strtoupper($mode)], - 'S_UCP_ACTION' => $this->u_action . ((isset($action)) ? "&action=$action" : '')) - ); - - // Set desired template - $this->tpl_name = $tpl_file; - $this->page_title = 'UCP_PM_' . strtoupper($mode); - } -} diff --git a/install/update/old/includes/ucp/ucp_pm_compose.php b/install/update/old/includes/ucp/ucp_pm_compose.php deleted file mode 100644 index 543db4f..0000000 --- a/install/update/old/includes/ucp/ucp_pm_compose.php +++ /dev/null @@ -1,1546 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* Compose private message -* Called from ucp_pm with mode == 'compose' -*/ -function compose_pm($id, $mode, $action, $user_folders = array()) -{ - global $template, $db, $auth, $user, $cache; - global $phpbb_root_path, $phpEx, $config; - global $request, $phpbb_dispatcher, $phpbb_container; - - // Damn php and globals - i know, this is horrible - // Needed for handle_message_list_actions() - global $refresh, $submit, $preview; - - if (!function_exists('generate_smilies')) - { - include($phpbb_root_path . 'includes/functions_posting.' . $phpEx); - } - - if (!function_exists('display_custom_bbcodes')) - { - include($phpbb_root_path . 'includes/functions_display.' . $phpEx); - } - - if (!class_exists('parse_message')) - { - include($phpbb_root_path . 'includes/message_parser.' . $phpEx); - } - - if (!$action) - { - $action = 'post'; - } - add_form_key('ucp_pm_compose'); - - // Grab only parameters needed here - $to_user_id = $request->variable('u', 0); - $to_group_id = $request->variable('g', 0); - $msg_id = $request->variable('p', 0); - $draft_id = $request->variable('d', 0); - - // Reply to all triggered (quote/reply) - $reply_to_all = $request->variable('reply_to_all', 0); - - $address_list = $request->variable('address_list', array('' => array(0 => ''))); - - $preview = (isset($_POST['preview'])) ? true : false; - $save = (isset($_POST['save'])) ? true : false; - $load = (isset($_POST['load'])) ? true : false; - $cancel = (isset($_POST['cancel']) && !isset($_POST['save'])) ? true : false; - $delete = (isset($_POST['delete'])) ? true : false; - - $remove_u = (isset($_REQUEST['remove_u'])) ? true : false; - $remove_g = (isset($_REQUEST['remove_g'])) ? true : false; - $add_to = (isset($_REQUEST['add_to'])) ? true : false; - $add_bcc = (isset($_REQUEST['add_bcc'])) ? true : false; - - $refresh = isset($_POST['add_file']) || isset($_POST['delete_file']) || $save || $load - || $remove_u || $remove_g || $add_to || $add_bcc; - $submit = $request->is_set_post('post') && !$refresh && !$preview; - - $action = ($delete && !$preview && !$refresh && $submit) ? 'delete' : $action; - $select_single = ($config['allow_mass_pm'] && $auth->acl_get('u_masspm')) ? false : true; - - $error = array(); - $current_time = time(); - - /** @var \phpbb\group\helper $group_helper */ - $group_helper = $phpbb_container->get('group_helper'); - - // Was cancel pressed? If so then redirect to the appropriate page - if ($cancel) - { - if ($msg_id) - { - redirect(append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=view&action=view_message&p=' . $msg_id)); - } - redirect(append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm')); - } - - // Since viewtopic.php language entries are used in several modes, - // we include the language file here - $user->add_lang('viewtopic'); - - /** - * Modify the default vars before composing a PM - * - * @event core.ucp_pm_compose_modify_data - * @var int msg_id post_id in the page request - * @var int to_user_id The id of whom the message is to - * @var int to_group_id The id of the group the message is to - * @var bool submit Whether the form has been submitted - * @var bool preview Whether the user is previewing the PM or not - * @var string action One of: post, reply, quote, forward, quotepost, edit, delete, smilies - * @var bool delete Whether the user is deleting the PM - * @var int reply_to_all Value of reply_to_all request variable. - * @since 3.1.4-RC1 - */ - $vars = array( - 'msg_id', - 'to_user_id', - 'to_group_id', - 'submit', - 'preview', - 'action', - 'delete', - 'reply_to_all', - ); - extract($phpbb_dispatcher->trigger_event('core.ucp_pm_compose_modify_data', compact($vars))); - - // Output PM_TO box if message composing - if ($action != 'edit') - { - // Add groups to PM box - if ($config['allow_mass_pm'] && $auth->acl_get('u_masspm_group')) - { - $sql = 'SELECT g.group_id, g.group_name, g.group_type, g.group_colour - FROM ' . GROUPS_TABLE . ' g'; - - if (!$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) - { - $sql .= ' LEFT JOIN ' . USER_GROUP_TABLE . ' ug - ON ( - g.group_id = ug.group_id - AND ug.user_id = ' . $user->data['user_id'] . ' - AND ug.user_pending = 0 - ) - WHERE (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $user->data['user_id'] . ')'; - } - - $sql .= ($auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) ? ' WHERE ' : ' AND '; - - $sql .= 'g.group_receive_pm = 1 - ORDER BY g.group_type DESC, g.group_name ASC'; - $result = $db->sql_query($sql); - - $group_options = ''; - while ($row = $db->sql_fetchrow($result)) - { - $group_options .= '' . $group_helper->get_name($row['group_name']) . ''; - } - $db->sql_freeresult($result); - } - - $template->assign_vars(array( - 'S_SHOW_PM_BOX' => true, - 'S_ALLOW_MASS_PM' => ($config['allow_mass_pm'] && $auth->acl_get('u_masspm')) ? true : false, - 'S_GROUP_OPTIONS' => ($config['allow_mass_pm'] && $auth->acl_get('u_masspm_group')) ? $group_options : '', - 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=searchuser&form=postform&field=username_list&select_single=" . (int) $select_single), - )); - } - - $sql = ''; - $folder_id = 0; - - // What is all this following SQL for? Well, we need to know - // some basic information in all cases before we do anything. - switch ($action) - { - case 'post': - if (!$auth->acl_get('u_sendpm')) - { - send_status_line(403, 'Forbidden'); - trigger_error('NO_AUTH_SEND_MESSAGE'); - } - break; - - case 'reply': - case 'quote': - case 'forward': - case 'quotepost': - if (!$msg_id) - { - trigger_error('NO_MESSAGE'); - } - - if (!$auth->acl_get('u_sendpm')) - { - send_status_line(403, 'Forbidden'); - trigger_error('NO_AUTH_SEND_MESSAGE'); - } - - if ($action == 'quotepost') - { - $sql = 'SELECT p.post_id as msg_id, p.forum_id, p.post_text as message_text, p.poster_id as author_id, p.post_time as message_time, p.bbcode_bitfield, p.bbcode_uid, p.enable_sig, p.enable_smilies, p.enable_magic_url, t.topic_title as message_subject, u.username as quote_username - FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . " u - WHERE p.post_id = $msg_id - AND t.topic_id = p.topic_id - AND u.user_id = p.poster_id"; - } - else - { - $sql = 'SELECT t.folder_id, p.*, u.username as quote_username - FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p, ' . USERS_TABLE . ' u - WHERE t.user_id = ' . $user->data['user_id'] . " - AND p.author_id = u.user_id - AND t.msg_id = p.msg_id - AND p.msg_id = $msg_id"; - } - break; - - case 'edit': - if (!$msg_id) - { - trigger_error('NO_MESSAGE'); - } - - // check for outbox (not read) status, we do not allow editing if one user already having the message - $sql = 'SELECT p.*, t.folder_id - FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p - WHERE t.user_id = ' . $user->data['user_id'] . ' - AND t.folder_id = ' . PRIVMSGS_OUTBOX . " - AND t.msg_id = $msg_id - AND t.msg_id = p.msg_id"; - break; - - case 'delete': - if (!$auth->acl_get('u_pm_delete')) - { - send_status_line(403, 'Forbidden'); - trigger_error('NO_AUTH_DELETE_MESSAGE'); - } - - if (!$msg_id) - { - trigger_error('NO_MESSAGE'); - } - - $sql = 'SELECT msg_id, pm_unread, pm_new, author_id, folder_id - FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE user_id = ' . $user->data['user_id'] . " - AND msg_id = $msg_id"; - break; - - case 'smilies': - generate_smilies('window', 0); - break; - - default: - trigger_error('NO_ACTION_MODE', E_USER_ERROR); - break; - } - - if ($action == 'forward' && (!$config['forward_pm'] || !$auth->acl_get('u_pm_forward'))) - { - send_status_line(403, 'Forbidden'); - trigger_error('NO_AUTH_FORWARD_MESSAGE'); - } - - if ($action == 'edit' && !$auth->acl_get('u_pm_edit')) - { - send_status_line(403, 'Forbidden'); - trigger_error('NO_AUTH_EDIT_MESSAGE'); - } - - if ($sql) - { - /** - * Alter sql query to get message for user to write the PM - * - * @event core.ucp_pm_compose_compose_pm_basic_info_query_before - * @var string sql String with the query to be executed - * @var int msg_id topic_id in the page request - * @var int to_user_id The id of whom the message is to - * @var int to_group_id The id of the group whom the message is to - * @var bool submit Whether the user is sending the PM or not - * @var bool preview Whether the user is previewing the PM or not - * @var string action One of: post, reply, quote, forward, quotepost, edit, delete, smilies - * @var bool delete Whether the user is deleting the PM - * @var int reply_to_all Value of reply_to_all request variable. - * @since 3.1.0-RC5 - * @changed 3.2.0-a1 Removed undefined variables - */ - $vars = array( - 'sql', - 'msg_id', - 'to_user_id', - 'to_group_id', - 'submit', - 'preview', - 'action', - 'delete', - 'reply_to_all', - ); - extract($phpbb_dispatcher->trigger_event('core.ucp_pm_compose_compose_pm_basic_info_query_before', compact($vars))); - - $result = $db->sql_query($sql); - $post = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$post) - { - // If editing it could be the recipient already read the message... - if ($action == 'edit') - { - $sql = 'SELECT p.*, t.folder_id - FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p - WHERE t.user_id = ' . $user->data['user_id'] . " - AND t.msg_id = $msg_id - AND t.msg_id = p.msg_id"; - $result = $db->sql_query($sql); - $post = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($post) - { - trigger_error('NO_EDIT_READ_MESSAGE'); - } - } - - trigger_error('NO_MESSAGE'); - } - - if ($action == 'quotepost') - { - if (($post['forum_id'] && !$auth->acl_get('f_read', $post['forum_id'])) || (!$post['forum_id'] && !$auth->acl_getf_global('f_read'))) - { - send_status_line(403, 'Forbidden'); - trigger_error('NOT_AUTHORISED'); - } - - /** - * Get the result of querying for the post to be quoted in the pm message - * - * @event core.ucp_pm_compose_quotepost_query_after - * @var string sql The original SQL used in the query - * @var array post Associative array with the data of the quoted post - * @var array msg_id The post_id that was searched to get the message for quoting - * @var int to_user_id Users the message is sent to - * @var int to_group_id Groups the message is sent to - * @var bool submit Whether the user is sending the PM or not - * @var bool preview Whether the user is previewing the PM or not - * @var string action One of: post, reply, quote, forward, quotepost, edit, delete, smilies - * @var bool delete If deleting message - * @var int reply_to_all Value of reply_to_all request variable. - * @since 3.1.0-RC5 - * @changed 3.2.0-a1 Removed undefined variables - */ - $vars = array( - 'sql', - 'post', - 'msg_id', - 'to_user_id', - 'to_group_id', - 'submit', - 'preview', - 'action', - 'delete', - 'reply_to_all', - ); - extract($phpbb_dispatcher->trigger_event('core.ucp_pm_compose_quotepost_query_after', compact($vars))); - - // Passworded forum? - if ($post['forum_id']) - { - $sql = 'SELECT forum_id, forum_name, forum_password - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . (int) $post['forum_id']; - $result = $db->sql_query($sql); - $forum_data = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!empty($forum_data['forum_password'])) - { - login_forum_box($forum_data); - } - } - } - - $msg_id = (int) $post['msg_id']; - $folder_id = (isset($post['folder_id'])) ? $post['folder_id'] : 0; - $message_text = (isset($post['message_text'])) ? $post['message_text'] : ''; - - if ((!$post['author_id'] || ($post['author_id'] == ANONYMOUS && $action != 'delete')) && $msg_id) - { - trigger_error('NO_AUTHOR'); - } - - if ($action == 'quotepost') - { - // Decode text for message display - decode_message($message_text, $post['bbcode_uid']); - } - - if ($action != 'delete') - { - $enable_urls = $post['enable_magic_url']; - $enable_sig = (isset($post['enable_sig'])) ? $post['enable_sig'] : 0; - - $message_attachment = (isset($post['message_attachment'])) ? $post['message_attachment'] : 0; - $message_subject = $post['message_subject']; - $message_time = $post['message_time']; - $bbcode_uid = $post['bbcode_uid']; - - $quote_username = (isset($post['quote_username'])) ? $post['quote_username'] : ''; - $icon_id = (isset($post['icon_id'])) ? $post['icon_id'] : 0; - - if (($action == 'reply' || $action == 'quote' || $action == 'quotepost') && !count($address_list) && !$refresh && !$submit && !$preview) - { - // Add the original author as the recipient if quoting a post or only replying and not having checked "reply to all" - if ($action == 'quotepost' || !$reply_to_all) - { - $address_list = array('u' => array($post['author_id'] => 'to')); - } - else - { - // We try to include every previously listed member from the TO Header - Reply to all - $address_list = rebuild_header(array('to' => $post['to_address'])); - - // Add the author (if he is already listed then this is no shame (it will be overwritten)) - $address_list['u'][$post['author_id']] = 'to'; - - // Now, make sure the user itself is not listed. ;) - if (isset($address_list['u'][$user->data['user_id']])) - { - unset($address_list['u'][$user->data['user_id']]); - } - } - } - else if ($action == 'edit' && !count($address_list) && !$refresh && !$submit && !$preview) - { - // Rebuild TO and BCC Header - $address_list = rebuild_header(array('to' => $post['to_address'], 'bcc' => $post['bcc_address'])); - } - - if ($action == 'quotepost') - { - $check_value = 0; - } - else - { - $check_value = (($post['enable_bbcode']+1) << 8) + (($post['enable_smilies']+1) << 4) + (($enable_urls+1) << 2) + (($post['enable_sig']+1) << 1); - } - } - } - else - { - $message_attachment = 0; - $message_text = $message_subject = ''; - - /** - * Predefine message text and subject - * - * @event core.ucp_pm_compose_predefined_message - * @var string message_text Message text - * @var string message_subject Messate subject - * @since 3.1.11-RC1 - */ - $vars = array('message_text', 'message_subject'); - extract($phpbb_dispatcher->trigger_event('core.ucp_pm_compose_predefined_message', compact($vars))); - - if ($to_user_id && $to_user_id != ANONYMOUS && $action == 'post') - { - $address_list['u'][$to_user_id] = 'to'; - } - else if ($to_group_id && $action == 'post') - { - $address_list['g'][$to_group_id] = 'to'; - } - $check_value = 0; - } - - if (($to_group_id || isset($address_list['g'])) && (!$config['allow_mass_pm'] || !$auth->acl_get('u_masspm_group'))) - { - send_status_line(403, 'Forbidden'); - trigger_error('NO_AUTH_GROUP_MESSAGE'); - } - - if ($action == 'edit' && !$refresh && !$preview && !$submit) - { - if (!($message_time > time() - ($config['pm_edit_time'] * 60) || !$config['pm_edit_time'])) - { - trigger_error('CANNOT_EDIT_MESSAGE_TIME'); - } - } - - if ($action == 'post') - { - $template->assign_var('S_NEW_MESSAGE', true); - } - - if (!isset($icon_id)) - { - $icon_id = 0; - } - - /* @var $plupload \phpbb\plupload\plupload */ - $plupload = $phpbb_container->get('plupload'); - $message_parser = new parse_message(); - $message_parser->set_plupload($plupload); - - $message_parser->message = ($action == 'reply') ? '' : $message_text; - unset($message_text); - - $s_action = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=$id&mode=$mode&action=$action", true, $user->session_id); - $s_action .= (($folder_id) ? "&f=$folder_id" : '') . (($msg_id) ? "&p=$msg_id" : ''); - - // Delete triggered ? - if ($action == 'delete') - { - // Folder id has been determined by the SQL Statement - // $folder_id = $request->variable('f', PRIVMSGS_NO_BOX); - - // Do we need to confirm ? - if (confirm_box(true)) - { - delete_pm($user->data['user_id'], $msg_id, $folder_id); - - // jump to next message in "history"? nope, not for the moment. But able to be included later. - $meta_info = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=pm&folder=$folder_id"); - $message = $user->lang['MESSAGE_DELETED']; - - meta_refresh(3, $meta_info); - $message .= '

' . sprintf($user->lang['RETURN_FOLDER'], '', ''); - trigger_error($message); - } - else - { - $s_hidden_fields = array( - 'p' => $msg_id, - 'f' => $folder_id, - 'action' => 'delete' - ); - - // "{$phpbb_root_path}ucp.$phpEx?i=pm&mode=compose" - confirm_box(false, 'DELETE_MESSAGE', build_hidden_fields($s_hidden_fields)); - } - - redirect(append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=view&action=view_message&p=' . $msg_id)); - } - - // Get maximum number of allowed recipients - $max_recipients = phpbb_get_max_setting_from_group($db, $user->data['user_id'], 'max_recipients'); - - // If it is 0, there is no limit set and we use the maximum value within the config. - $max_recipients = (!$max_recipients) ? $config['pm_max_recipients'] : $max_recipients; - - // If this is a quote/reply "to all"... we may increase the max_recpients to the number of original recipients - if (($action == 'reply' || $action == 'quote') && $max_recipients && $reply_to_all) - { - // We try to include every previously listed member from the TO Header - $list = rebuild_header(array('to' => $post['to_address'])); - - // Can be an empty array too ;) - $list = (!empty($list['u'])) ? $list['u'] : array(); - $list[$post['author_id']] = 'to'; - - if (isset($list[$user->data['user_id']])) - { - unset($list[$user->data['user_id']]); - } - - $max_recipients = ($max_recipients < count($list)) ? count($list) : $max_recipients; - - unset($list); - } - - // Handle User/Group adding/removing - handle_message_list_actions($address_list, $error, $remove_u, $remove_g, $add_to, $add_bcc); - - // Check mass pm to group permission - if ((!$config['allow_mass_pm'] || !$auth->acl_get('u_masspm_group')) && !empty($address_list['g'])) - { - $address_list = array(); - $error[] = $user->lang['NO_AUTH_GROUP_MESSAGE']; - } - - // Check mass pm to users permission - if ((!$config['allow_mass_pm'] || !$auth->acl_get('u_masspm')) && num_recipients($address_list) > 1) - { - $address_list = get_recipients($address_list, 1); - $error[] = $user->lang('TOO_MANY_RECIPIENTS', 1); - } - - // Check for too many recipients - if (!empty($address_list['u']) && $max_recipients && count($address_list['u']) > $max_recipients) - { - $address_list = get_recipients($address_list, $max_recipients); - $error[] = $user->lang('TOO_MANY_RECIPIENTS', $max_recipients); - } - - // Always check if the submitted attachment data is valid and belongs to the user. - // Further down (especially in submit_post()) we do not check this again. - $message_parser->get_submitted_attachment_data(); - - if ($message_attachment && !$submit && !$refresh && !$preview && $action == 'edit') - { - // Do not change to SELECT * - $sql = 'SELECT attach_id, is_orphan, attach_comment, real_filename, filesize - FROM ' . ATTACHMENTS_TABLE . " - WHERE post_msg_id = $msg_id - AND in_message = 1 - AND is_orphan = 0 - ORDER BY filetime DESC"; - $result = $db->sql_query($sql); - $message_parser->attachment_data = array_merge($message_parser->attachment_data, $db->sql_fetchrowset($result)); - $db->sql_freeresult($result); - } - - if (!in_array($action, array('quote', 'edit', 'delete', 'forward'))) - { - $enable_sig = ($config['allow_sig'] && $config['allow_sig_pm'] && $auth->acl_get('u_sig') && $user->optionget('attachsig')); - $enable_smilies = ($config['allow_smilies'] && $auth->acl_get('u_pm_smilies') && $user->optionget('smilies')); - $enable_bbcode = ($config['allow_bbcode'] && $auth->acl_get('u_pm_bbcode') && $user->optionget('bbcode')); - $enable_urls = true; - } - - $drafts = false; - - // User own some drafts? - if ($auth->acl_get('u_savedrafts') && $action != 'delete') - { - $sql = 'SELECT draft_id - FROM ' . DRAFTS_TABLE . ' - WHERE forum_id = 0 - AND topic_id = 0 - AND user_id = ' . $user->data['user_id'] . - (($draft_id) ? " AND draft_id <> $draft_id" : ''); - $result = $db->sql_query_limit($sql, 1); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - $drafts = true; - } - } - - if ($action == 'edit') - { - $message_parser->bbcode_uid = $bbcode_uid; - } - - $bbcode_status = ($config['allow_bbcode'] && $config['auth_bbcode_pm'] && $auth->acl_get('u_pm_bbcode')) ? true : false; - $smilies_status = ($config['allow_smilies'] && $config['auth_smilies_pm'] && $auth->acl_get('u_pm_smilies')) ? true : false; - $img_status = ($config['auth_img_pm'] && $auth->acl_get('u_pm_img')) ? true : false; - $flash_status = ($config['auth_flash_pm'] && $auth->acl_get('u_pm_flash')) ? true : false; - $url_status = ($config['allow_post_links']) ? true : false; - - // Save Draft - if ($save && $auth->acl_get('u_savedrafts')) - { - $subject = $request->variable('subject', '', true); - $subject = (!$subject && $action != 'post') ? $user->lang['NEW_MESSAGE'] : $subject; - $message = $request->variable('message', '', true); - - if ($subject && $message) - { - if (confirm_box(true)) - { - $message_parser->message = $message; - $message_parser->parse($bbcode_status, $url_status, $smilies_status, $img_status, $flash_status, true, $url_status); - - $sql = 'INSERT INTO ' . DRAFTS_TABLE . ' ' . $db->sql_build_array('INSERT', array( - 'user_id' => $user->data['user_id'], - 'topic_id' => 0, - 'forum_id' => 0, - 'save_time' => $current_time, - 'draft_subject' => $subject, - 'draft_message' => $message_parser->message, - ) - ); - $db->sql_query($sql); - - $redirect_url = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=pm&mode=$mode"); - - meta_refresh(3, $redirect_url); - $message = $user->lang['DRAFT_SAVED'] . '

' . sprintf($user->lang['RETURN_UCP'], '', ''); - - trigger_error($message); - } - else - { - $s_hidden_fields = build_hidden_fields(array( - 'mode' => $mode, - 'action' => $action, - 'save' => true, - 'subject' => $subject, - 'message' => $message, - 'u' => $to_user_id, - 'g' => $to_group_id, - 'p' => $msg_id) - ); - $s_hidden_fields .= build_address_field($address_list); - - confirm_box(false, 'SAVE_DRAFT', $s_hidden_fields); - } - } - else - { - if (utf8_clean_string($subject) === '') - { - $error[] = $user->lang['EMPTY_MESSAGE_SUBJECT']; - } - - if (utf8_clean_string($message) === '') - { - $error[] = $user->lang['TOO_FEW_CHARS']; - } - } - - unset($subject, $message); - } - - // Load Draft - if ($draft_id && $auth->acl_get('u_savedrafts')) - { - $sql = 'SELECT draft_subject, draft_message - FROM ' . DRAFTS_TABLE . " - WHERE draft_id = $draft_id - AND topic_id = 0 - AND forum_id = 0 - AND user_id = " . $user->data['user_id']; - $result = $db->sql_query_limit($sql, 1); - - if ($row = $db->sql_fetchrow($result)) - { - $message_parser->message = $row['draft_message']; - $message_subject = $row['draft_subject']; - - $template->assign_var('S_DRAFT_LOADED', true); - } - else - { - $draft_id = 0; - } - $db->sql_freeresult($result); - } - - // Load Drafts - if ($load && $drafts) - { - load_drafts(0, 0, $id, $action, $msg_id); - } - - if ($submit || $preview || $refresh) - { - if (($submit || $preview) && !check_form_key('ucp_pm_compose')) - { - $error[] = $user->lang['FORM_INVALID']; - } - $subject = $request->variable('subject', '', true); - $message_parser->message = $request->variable('message', '', true); - - $icon_id = $request->variable('icon', 0); - - $enable_bbcode = (!$bbcode_status || isset($_POST['disable_bbcode'])) ? false : true; - $enable_smilies = (!$smilies_status || isset($_POST['disable_smilies'])) ? false : true; - $enable_urls = (isset($_POST['disable_magic_url'])) ? 0 : 1; - $enable_sig = (!$config['allow_sig'] ||!$config['allow_sig_pm']) ? false : ((isset($_POST['attach_sig'])) ? true : false); - - /** - * Modify private message - * - * @event core.ucp_pm_compose_modify_parse_before - * @var bool enable_bbcode Whether or not bbcode is enabled - * @var bool enable_smilies Whether or not smilies are enabled - * @var bool enable_urls Whether or not urls are enabled - * @var bool enable_sig Whether or not signature is enabled - * @var string subject PM subject text - * @var object message_parser The message parser object - * @var bool submit Whether or not the form has been sumitted - * @var bool preview Whether or not the signature is being previewed - * @var array error Any error strings - * @since 3.1.10-RC1 - */ - $vars = array( - 'enable_bbcode', - 'enable_smilies', - 'enable_urls', - 'enable_sig', - 'subject', - 'message_parser', - 'submit', - 'preview', - 'error', - ); - extract($phpbb_dispatcher->trigger_event('core.ucp_pm_compose_modify_parse_before', compact($vars))); - - // Parse Attachments - before checksum is calculated - $message_parser->parse_attachments('fileupload', $action, 0, $submit, $preview, $refresh, true); - - if (count($message_parser->warn_msg) && !($remove_u || $remove_g || $add_to || $add_bcc)) - { - $error[] = implode('
', $message_parser->warn_msg); - $message_parser->warn_msg = array(); - } - - // Parse message - $message_parser->parse($enable_bbcode, ($config['allow_post_links']) ? $enable_urls : false, $enable_smilies, $img_status, $flash_status, true, $config['allow_post_links']); - - // On a refresh we do not care about message parsing errors - if (count($message_parser->warn_msg) && !$refresh) - { - $error[] = implode('
', $message_parser->warn_msg); - } - - if ($action != 'edit' && !$preview && !$refresh && $config['flood_interval'] && !$auth->acl_get('u_ignoreflood')) - { - // Flood check - $last_post_time = $user->data['user_lastpost_time']; - - if ($last_post_time) - { - if ($last_post_time && ($current_time - $last_post_time) < intval($config['flood_interval'])) - { - $error[] = $user->lang['FLOOD_ERROR']; - } - } - } - - // Subject defined - if ($submit) - { - if (utf8_clean_string($subject) === '') - { - $error[] = $user->lang['EMPTY_MESSAGE_SUBJECT']; - } - - if (!count($address_list)) - { - $error[] = $user->lang['NO_RECIPIENT']; - } - } - - // Store message, sync counters - if (!count($error) && $submit) - { - $pm_data = array( - 'msg_id' => (int) $msg_id, - 'from_user_id' => $user->data['user_id'], - 'from_user_ip' => $user->ip, - 'from_username' => $user->data['username'], - 'reply_from_root_level' => (isset($post['root_level'])) ? (int) $post['root_level'] : 0, - 'reply_from_msg_id' => (int) $msg_id, - 'icon_id' => (int) $icon_id, - 'enable_sig' => (bool) $enable_sig, - 'enable_bbcode' => (bool) $enable_bbcode, - 'enable_smilies' => (bool) $enable_smilies, - 'enable_urls' => (bool) $enable_urls, - 'bbcode_bitfield' => $message_parser->bbcode_bitfield, - 'bbcode_uid' => $message_parser->bbcode_uid, - 'message' => $message_parser->message, - 'attachment_data' => $message_parser->attachment_data, - 'filename_data' => $message_parser->filename_data, - 'address_list' => $address_list - ); - - // ((!$message_subject) ? $subject : $message_subject) - $msg_id = submit_pm($action, $subject, $pm_data); - - $return_message_url = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=view&p=' . $msg_id); - $inbox_folder_url = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&folder=inbox'); - $outbox_folder_url = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&folder=outbox'); - - $folder_url = ''; - if (($folder_id > 0) && isset($user_folders[$folder_id])) - { - $folder_url = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&folder=' . $folder_id); - } - - $return_box_url = ($action === 'post' || $action === 'edit') ? $outbox_folder_url : $inbox_folder_url; - $return_box_lang = ($action === 'post' || $action === 'edit') ? 'PM_OUTBOX' : 'PM_INBOX'; - - $save_message = ($action === 'edit') ? $user->lang['MESSAGE_EDITED'] : $user->lang['MESSAGE_STORED']; - $message = $save_message . '

' . $user->lang('VIEW_PRIVATE_MESSAGE', '', ''); - - $last_click_type = 'CLICK_RETURN_FOLDER'; - if ($folder_url) - { - $message .= '

' . sprintf($user->lang['CLICK_RETURN_FOLDER'], '', '', $user_folders[$folder_id]['folder_name']); - $last_click_type = 'CLICK_GOTO_FOLDER'; - } - $message .= '

' . sprintf($user->lang[$last_click_type], '', '', $user->lang[$return_box_lang]); - - meta_refresh(3, $return_message_url); - trigger_error($message); - } - - $message_subject = $subject; - } - - // Preview - if (!count($error) && $preview) - { - $preview_message = $message_parser->format_display($enable_bbcode, $enable_urls, $enable_smilies, false); - - $preview_signature = $user->data['user_sig']; - $preview_signature_uid = $user->data['user_sig_bbcode_uid']; - $preview_signature_bitfield = $user->data['user_sig_bbcode_bitfield']; - - // Signature - if ($enable_sig && $config['allow_sig'] && $preview_signature) - { - $bbcode_flags = ($enable_bbcode ? OPTION_FLAG_BBCODE : 0) + ($enable_smilies ? OPTION_FLAG_SMILIES : 0) + ($enable_urls ? OPTION_FLAG_LINKS : 0); - $preview_signature = generate_text_for_display($preview_signature, $preview_signature_uid, $preview_signature_bitfield, $bbcode_flags); - } - else - { - $preview_signature = ''; - } - - // Attachment Preview - if (count($message_parser->attachment_data)) - { - $template->assign_var('S_HAS_ATTACHMENTS', true); - - $update_count = array(); - $attachment_data = $message_parser->attachment_data; - - parse_attachments(false, $preview_message, $attachment_data, $update_count, true); - - foreach ($attachment_data as $i => $attachment) - { - $template->assign_block_vars('attachment', array( - 'DISPLAY_ATTACHMENT' => $attachment) - ); - } - unset($attachment_data); - } - - $preview_subject = censor_text($subject); - - if (!count($error)) - { - $template->assign_vars(array( - 'PREVIEW_SUBJECT' => $preview_subject, - 'PREVIEW_MESSAGE' => $preview_message, - 'PREVIEW_SIGNATURE' => $preview_signature, - - 'S_DISPLAY_PREVIEW' => true) - ); - } - unset($message_text); - } - - // Decode text for message display - $bbcode_uid = (($action == 'quote' || $action == 'forward') && !$preview && !$refresh && (!count($error) || (count($error) && !$submit))) ? $bbcode_uid : $message_parser->bbcode_uid; - - $message_parser->decode_message($bbcode_uid); - - if (($action == 'quote' || $action == 'quotepost') && !$preview && !$refresh && !$submit) - { - if ($action == 'quotepost') - { - $post_id = $request->variable('p', 0); - if ($config['allow_post_links']) - { - $message_link = generate_board_url() . "/viewtopic.$phpEx?p={$post_id}#p{$post_id}"; - $message_link_subject = "{$user->lang['SUBJECT']}{$user->lang['COLON']} {$message_subject}"; - if ($bbcode_status) - { - $message_link = "[url=" . $message_link . "]" . $message_link_subject . "[/url]\n\n"; - } - else - { - $message_link = $message_link . " - " . $message_link_subject . "\n\n"; - } - } - else - { - $message_link = $user->lang['SUBJECT'] . $user->lang['COLON'] . ' ' . $message_subject . " (" . generate_board_url() . "/viewtopic.$phpEx?p={$post_id}#p{$post_id})\n\n"; - } - } - else - { - $message_link = ''; - } - $quote_attributes = array( - 'author' => $quote_username, - 'time' => $post['message_time'], - 'user_id' => $post['author_id'], - ); - if ($action === 'quotepost') - { - $quote_attributes['post_id'] = $post['msg_id']; - } - - /** @var \phpbb\language\language $language */ - $language = $phpbb_container->get('language'); - /** @var \phpbb\textformatter\utils_interface $text_formatter_utils */ - $text_formatter_utils = $phpbb_container->get('text_formatter.utils'); - phpbb_format_quote($language, $message_parser, $text_formatter_utils, $bbcode_status, $quote_attributes, $message_link); - } - - if (($action == 'reply' || $action == 'quote' || $action == 'quotepost') && !$preview && !$refresh) - { - $message_subject = ((!preg_match('/^Re:/', $message_subject)) ? 'Re: ' : '') . censor_text($message_subject); - } - - if ($action == 'forward' && !$preview && !$refresh && !$submit) - { - $fwd_to_field = write_pm_addresses(array('to' => $post['to_address']), 0, true); - - if ($config['allow_post_links']) - { - $quote_username_text = '[url=' . generate_board_url() . "/memberlist.$phpEx?mode=viewprofile&u={$post['author_id']}]{$quote_username}[/url]"; - } - else - { - $quote_username_text = $quote_username . ' (' . generate_board_url() . "/memberlist.$phpEx?mode=viewprofile&u={$post['author_id']})"; - } - - $forward_text = array(); - $forward_text[] = $user->lang['FWD_ORIGINAL_MESSAGE']; - $forward_text[] = sprintf($user->lang['FWD_SUBJECT'], censor_text($message_subject)); - $forward_text[] = sprintf($user->lang['FWD_DATE'], $user->format_date($message_time, false, true)); - $forward_text[] = sprintf($user->lang['FWD_FROM'], $quote_username_text); - $forward_text[] = sprintf($user->lang['FWD_TO'], implode($user->lang['COMMA_SEPARATOR'], $fwd_to_field['to'])); - - $quote_text = $phpbb_container->get('text_formatter.utils')->generate_quote( - censor_text($message_parser->message), - array('author' => $quote_username) - ); - $message_parser->message = implode("\n", $forward_text) . "\n\n" . $quote_text; - $message_subject = ((!preg_match('/^Fwd:/', $message_subject)) ? 'Fwd: ' : '') . censor_text($message_subject); - } - - $attachment_data = $message_parser->attachment_data; - $filename_data = $message_parser->filename_data; - $message_text = $message_parser->message; - - // MAIN PM PAGE BEGINS HERE - - // Generate smiley listing - generate_smilies('inline', 0); - - // Generate PM Icons - $s_pm_icons = false; - if ($config['enable_pm_icons']) - { - $s_pm_icons = posting_gen_topic_icons($action, $icon_id); - } - - // Generate inline attachment select box - posting_gen_inline_attachments($attachment_data); - - // Build address list for display - // array('u' => array($author_id => 'to')); - if (count($address_list)) - { - // Get Usernames and Group Names - $result = array(); - if (!empty($address_list['u'])) - { - $sql = 'SELECT user_id as id, username as name, user_colour as colour - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('user_id', array_map('intval', array_keys($address_list['u']))) . ' - ORDER BY username_clean ASC'; - $result['u'] = $db->sql_query($sql); - } - - if (!empty($address_list['g'])) - { - $sql = 'SELECT g.group_id AS id, g.group_name AS name, g.group_colour AS colour, g.group_type - FROM ' . GROUPS_TABLE . ' g'; - - if (!$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) - { - $sql .= ' LEFT JOIN ' . USER_GROUP_TABLE . ' ug - ON ( - g.group_id = ug.group_id - AND ug.user_id = ' . $user->data['user_id'] . ' - AND ug.user_pending = 0 - ) - WHERE (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $user->data['user_id'] . ')'; - } - - $sql .= ($auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) ? ' WHERE ' : ' AND '; - - $sql .= 'g.group_receive_pm = 1 - AND ' . $db->sql_in_set('g.group_id', array_map('intval', array_keys($address_list['g']))) . ' - ORDER BY g.group_name ASC'; - - $result['g'] = $db->sql_query($sql); - } - - $u = $g = array(); - $_types = array('u', 'g'); - foreach ($_types as $type) - { - if (isset($result[$type]) && $result[$type]) - { - while ($row = $db->sql_fetchrow($result[$type])) - { - if ($type == 'g') - { - $row['name'] = $group_helper->get_name($row['name']); - } - - ${$type}[$row['id']] = array('name' => $row['name'], 'colour' => $row['colour']); - } - $db->sql_freeresult($result[$type]); - } - } - - // Now Build the address list - foreach ($address_list as $type => $adr_ary) - { - foreach ($adr_ary as $id => $field) - { - if (!isset(${$type}[$id])) - { - unset($address_list[$type][$id]); - continue; - } - - $field = ($field == 'to') ? 'to' : 'bcc'; - $type = ($type == 'u') ? 'u' : 'g'; - $id = (int) $id; - - $tpl_ary = array( - 'IS_GROUP' => ($type == 'g') ? true : false, - 'IS_USER' => ($type == 'u') ? true : false, - 'UG_ID' => $id, - 'NAME' => ${$type}[$id]['name'], - 'COLOUR' => (${$type}[$id]['colour']) ? '#' . ${$type}[$id]['colour'] : '', - 'TYPE' => $type, - ); - - if ($type == 'u') - { - $tpl_ary = array_merge($tpl_ary, array( - 'U_VIEW' => get_username_string('profile', $id, ${$type}[$id]['name'], ${$type}[$id]['colour']), - 'NAME_FULL' => get_username_string('full', $id, ${$type}[$id]['name'], ${$type}[$id]['colour']), - )); - } - else - { - $tpl_ary = array_merge($tpl_ary, array( - 'U_VIEW' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&g=' . $id), - )); - } - - $template->assign_block_vars($field . '_recipient', $tpl_ary); - } - } - } - - // Build hidden address list - $s_hidden_address_field = build_address_field($address_list); - - $bbcode_checked = (isset($enable_bbcode)) ? !$enable_bbcode : (($config['allow_bbcode'] && $auth->acl_get('u_pm_bbcode')) ? !$user->optionget('bbcode') : 1); - $smilies_checked = (isset($enable_smilies)) ? !$enable_smilies : (($config['allow_smilies'] && $auth->acl_get('u_pm_smilies')) ? !$user->optionget('smilies') : 1); - $urls_checked = (isset($enable_urls)) ? !$enable_urls : 0; - $sig_checked = $enable_sig; - - switch ($action) - { - case 'post': - $page_title = $user->lang['POST_NEW_PM']; - break; - - case 'quote': - $page_title = $user->lang['POST_QUOTE_PM']; - break; - - case 'quotepost': - $page_title = $user->lang['POST_PM_POST']; - break; - - case 'reply': - $page_title = $user->lang['POST_REPLY_PM']; - break; - - case 'edit': - $page_title = $user->lang['POST_EDIT_PM']; - break; - - case 'forward': - $page_title = $user->lang['POST_FORWARD_PM']; - break; - - default: - trigger_error('NO_ACTION_MODE', E_USER_ERROR); - break; - } - - $s_hidden_fields = (isset($check_value)) ? '' : ''; - $s_hidden_fields .= ($draft_id || isset($_REQUEST['draft_loaded'])) ? '' : ''; - - $form_enctype = (@ini_get('file_uploads') == '0' || strtolower(@ini_get('file_uploads')) == 'off' || !$config['allow_pm_attach'] || !$auth->acl_get('u_pm_attach')) ? '' : ' enctype="multipart/form-data"'; - - /** @var \phpbb\controller\helper $controller_helper */ - $controller_helper = $phpbb_container->get('controller.helper'); - - // Start assigning vars for main posting page ... - $template_ary = array( - 'L_POST_A' => $page_title, - 'L_ICON' => $user->lang['PM_ICON'], - 'L_MESSAGE_BODY_EXPLAIN' => $user->lang('MESSAGE_BODY_EXPLAIN', (int) $config['max_post_chars']), - - 'SUBJECT' => (isset($message_subject)) ? $message_subject : '', - 'MESSAGE' => $message_text, - 'BBCODE_STATUS' => $user->lang(($bbcode_status ? 'BBCODE_IS_ON' : 'BBCODE_IS_OFF'), '', ''), - 'IMG_STATUS' => ($img_status) ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'], - 'FLASH_STATUS' => ($flash_status) ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'], - 'SMILIES_STATUS' => ($smilies_status) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'], - 'URL_STATUS' => ($url_status) ? $user->lang['URL_IS_ON'] : $user->lang['URL_IS_OFF'], - 'MAX_FONT_SIZE' => (int) $config['max_post_font_size'], - 'MINI_POST_IMG' => $user->img('icon_post_target', $user->lang['PM']), - 'ERROR' => (count($error)) ? implode('
', $error) : '', - 'MAX_RECIPIENTS' => ($config['allow_mass_pm'] && ($auth->acl_get('u_masspm') || $auth->acl_get('u_masspm_group'))) ? $max_recipients : 0, - - 'S_COMPOSE_PM' => true, - 'S_EDIT_POST' => ($action == 'edit'), - 'S_SHOW_PM_ICONS' => $s_pm_icons, - 'S_BBCODE_ALLOWED' => ($bbcode_status) ? 1 : 0, - 'S_BBCODE_CHECKED' => ($bbcode_checked) ? ' checked="checked"' : '', - 'S_SMILIES_ALLOWED' => $smilies_status, - 'S_SMILIES_CHECKED' => ($smilies_checked) ? ' checked="checked"' : '', - 'S_SIG_ALLOWED' => ($config['allow_sig'] && $config['allow_sig_pm'] && $auth->acl_get('u_sig')), - 'S_SIGNATURE_CHECKED' => ($sig_checked) ? ' checked="checked"' : '', - 'S_LINKS_ALLOWED' => $url_status, - 'S_MAGIC_URL_CHECKED' => ($urls_checked) ? ' checked="checked"' : '', - 'S_SAVE_ALLOWED' => ($auth->acl_get('u_savedrafts') && $action != 'edit') ? true : false, - 'S_HAS_DRAFTS' => ($auth->acl_get('u_savedrafts') && $drafts), - 'S_FORM_ENCTYPE' => $form_enctype, - 'S_ATTACH_DATA' => json_encode($message_parser->attachment_data), - - 'S_BBCODE_IMG' => $img_status, - 'S_BBCODE_FLASH' => $flash_status, - 'S_BBCODE_QUOTE' => true, - 'S_BBCODE_URL' => $url_status, - - 'S_POST_ACTION' => $s_action, - 'S_HIDDEN_ADDRESS_FIELD' => $s_hidden_address_field, - 'S_HIDDEN_FIELDS' => $s_hidden_fields, - - 'S_CLOSE_PROGRESS_WINDOW' => isset($_POST['add_file']), - 'U_PROGRESS_BAR' => append_sid("{$phpbb_root_path}posting.$phpEx", 'f=0&mode=popup'), - 'UA_PROGRESS_BAR' => addslashes(append_sid("{$phpbb_root_path}posting.$phpEx", 'f=0&mode=popup')), - ); - - /** - * Modify the default template vars - * - * @event core.ucp_pm_compose_template - * @var array template_ary Template variables - * @since 3.2.6-RC1 - */ - $vars = array('template_ary'); - extract($phpbb_dispatcher->trigger_event('core.ucp_pm_compose_template', compact($vars))); - - $template->assign_vars($template_ary); - - // Build custom bbcodes array - display_custom_bbcodes(); - - // Show attachment box for adding attachments if true - $allowed = ($auth->acl_get('u_pm_attach') && $config['allow_pm_attach'] && $form_enctype); - - if ($allowed) - { - $max_files = ($auth->acl_gets('a_', 'm_')) ? 0 : (int) $config['max_attachments_pm']; - $plupload->configure($cache, $template, $s_action, false, $max_files); - } - - // Attachment entry - posting_gen_attachment_entry($attachment_data, $filename_data, $allowed); - - // Message History - if ($action == 'reply' || $action == 'quote' || $action == 'forward') - { - if (message_history($msg_id, $user->data['user_id'], $post, array(), true)) - { - $template->assign_var('S_DISPLAY_HISTORY', true); - } - } -} - -/** -* For composing messages, handle list actions -*/ -function handle_message_list_actions(&$address_list, &$error, $remove_u, $remove_g, $add_to, $add_bcc) -{ - global $auth, $db, $user; - global $request, $phpbb_dispatcher; - - // Delete User [TO/BCC] - if ($remove_u && $request->variable('remove_u', array(0 => ''))) - { - $remove_user_id = array_keys($request->variable('remove_u', array(0 => ''))); - - if (isset($remove_user_id[0])) - { - unset($address_list['u'][(int) $remove_user_id[0]]); - } - } - - // Delete Group [TO/BCC] - if ($remove_g && $request->variable('remove_g', array(0 => ''))) - { - $remove_group_id = array_keys($request->variable('remove_g', array(0 => ''))); - - if (isset($remove_group_id[0])) - { - unset($address_list['g'][(int) $remove_group_id[0]]); - } - } - - // Add Selected Groups - $group_list = $request->variable('group_list', array(0)); - - // Build usernames to add - $usernames = $request->variable('username', '', true); - $usernames = (empty($usernames)) ? array() : array($usernames); - - $username_list = $request->variable('username_list', '', true); - if ($username_list) - { - $usernames = array_merge($usernames, explode("\n", $username_list)); - } - - // If add to or add bcc not pressed, users could still have usernames listed they want to add... - if (!$add_to && !$add_bcc && (count($group_list) || count($usernames))) - { - $add_to = true; - - global $refresh, $submit, $preview; - - $refresh = true; - $submit = false; - - // Preview is only true if there was also a message entered - if ($request->variable('message', '')) - { - $preview = true; - } - } - - // Add User/Group [TO] - if ($add_to || $add_bcc) - { - $type = ($add_to) ? 'to' : 'bcc'; - - if (count($group_list)) - { - foreach ($group_list as $group_id) - { - $address_list['g'][$group_id] = $type; - } - } - - // User ID's to add... - $user_id_ary = array(); - - // Reveal the correct user_ids - if (count($usernames)) - { - $user_id_ary = array(); - user_get_id_name($user_id_ary, $usernames, array(USER_NORMAL, USER_FOUNDER, USER_INACTIVE)); - - // If there are users not existing, we will at least print a notice... - if (!count($user_id_ary)) - { - $error[] = $user->lang['PM_NO_USERS']; - } - } - - // Add Friends if specified - $friend_list = array_keys($request->variable('add_' . $type, array(0))); - $user_id_ary = array_merge($user_id_ary, $friend_list); - - foreach ($user_id_ary as $user_id) - { - if ($user_id == ANONYMOUS) - { - continue; - } - - $address_list['u'][$user_id] = $type; - } - } - - // Check for disallowed recipients - if (!empty($address_list['u'])) - { - $can_ignore_allow_pm = $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'); - - // Administrator deactivated users check and we need to check their - // PM status (do they want to receive PM's?) - // Only check PM status if not a moderator or admin, since they - // are allowed to override this user setting - $sql = 'SELECT user_id, user_allow_pm - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('user_id', array_keys($address_list['u'])) . ' - AND ( - (user_type = ' . USER_INACTIVE . ' - AND user_inactive_reason = ' . INACTIVE_MANUAL . ') - ' . ($can_ignore_allow_pm ? '' : ' OR user_allow_pm = 0') . ' - )'; - - $result = $db->sql_query($sql); - - $removed_no_pm = $removed_no_permission = false; - while ($row = $db->sql_fetchrow($result)) - { - if (!$can_ignore_allow_pm && !$row['user_allow_pm']) - { - $removed_no_pm = true; - } - else - { - $removed_no_permission = true; - } - - unset($address_list['u'][$row['user_id']]); - } - $db->sql_freeresult($result); - - // print a notice about users not being added who do not want to receive pms - if ($removed_no_pm) - { - $error[] = $user->lang['PM_USERS_REMOVED_NO_PM']; - } - - // print a notice about users not being added who do not have permission to receive PMs - if ($removed_no_permission) - { - $error[] = $user->lang['PM_USERS_REMOVED_NO_PERMISSION']; - } - - if (!count(array_keys($address_list['u']))) - { - return; - } - - // Check if users have permission to read PMs - $can_read = $auth->acl_get_list(array_keys($address_list['u']), 'u_readpm'); - $can_read = (empty($can_read) || !isset($can_read[0]['u_readpm'])) ? array() : $can_read[0]['u_readpm']; - $cannot_read_list = array_diff(array_keys($address_list['u']), $can_read); - if (!empty($cannot_read_list)) - { - foreach ($cannot_read_list as $cannot_read) - { - unset($address_list['u'][$cannot_read]); - } - - $error[] = $user->lang['PM_USERS_REMOVED_NO_PERMISSION']; - } - - // Check if users are banned - $banned_user_list = phpbb_get_banned_user_ids(array_keys($address_list['u']), false); - if (!empty($banned_user_list)) - { - foreach ($banned_user_list as $banned_user) - { - unset($address_list['u'][$banned_user]); - } - - $error[] = $user->lang['PM_USERS_REMOVED_NO_PERMISSION']; - } - } - - /** - * Event for additional message list actions - * - * @event core.message_list_actions - * @var array address_list The assoc array with the recipient user/group ids - * @var array error The array containing error data - * @var bool remove_u The variable for removing a user - * @var bool remove_g The variable for removing a group - * @var bool add_to The variable for adding a user to the [TO] field - * @var bool add_bcc The variable for adding a user to the [BCC] field - * @since 3.2.4-RC1 - */ - $vars = array('address_list', 'error', 'remove_u', 'remove_g', 'add_to', 'add_bcc'); - extract($phpbb_dispatcher->trigger_event('core.message_list_actions', compact($vars))); -} - -/** -* Build the hidden field for the recipients. Needed, as the variable is not read via $request->variable(). -*/ -function build_address_field($address_list) -{ - $s_hidden_address_field = ''; - foreach ($address_list as $type => $adr_ary) - { - foreach ($adr_ary as $id => $field) - { - $s_hidden_address_field .= ''; - } - } - return $s_hidden_address_field; -} - -/** -* Return number of private message recipients -*/ -function num_recipients($address_list) -{ - $num_recipients = 0; - - foreach ($address_list as $field => $adr_ary) - { - $num_recipients += count($adr_ary); - } - - return $num_recipients; -} - -/** -* Get number of 'num_recipients' recipients from first position -*/ -function get_recipients($address_list, $num_recipients = 1) -{ - $recipient = array(); - - $count = 0; - foreach ($address_list as $field => $adr_ary) - { - foreach ($adr_ary as $id => $type) - { - if ($count >= $num_recipients) - { - break 2; - } - $recipient[$field][$id] = $type; - $count++; - } - } - - return $recipient; -} diff --git a/install/update/old/includes/ucp/ucp_pm_viewfolder.php b/install/update/old/includes/ucp/ucp_pm_viewfolder.php deleted file mode 100644 index 09e7bf4..0000000 --- a/install/update/old/includes/ucp/ucp_pm_viewfolder.php +++ /dev/null @@ -1,604 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* View message folder -* Called from ucp_pm with mode == 'view' && action == 'view_folder' -*/ -function view_folder($id, $mode, $folder_id, $folder) -{ - global $user, $template, $auth, $db, $cache, $request; - global $phpbb_root_path, $config, $phpEx; - - $submit_export = (isset($_POST['submit_export'])) ? true : false; - - $folder_info = get_pm_from($folder_id, $folder, $user->data['user_id']); - - if (!$submit_export) - { - $user->add_lang('viewforum'); - - // Grab icons - $icons = $cache->obtain_icons(); - - $color_rows = array('message_reported', 'marked', 'replied'); - - $_module = new p_master(); - $_module->list_modules('ucp'); - $_module->set_active('zebra'); - - $zebra_enabled = ($_module->active_module === false) ? false : true; - - unset($_module); - - if ($zebra_enabled) - { - $color_rows = array_merge($color_rows, array('friend', 'foe')); - } - - foreach ($color_rows as $var) - { - $template->assign_block_vars('pm_colour_info', array( - 'IMG' => $user->img("pm_{$var}", ''), - 'CLASS' => "pm_{$var}_colour", - 'LANG' => $user->lang[strtoupper($var) . '_MESSAGE']) - ); - } - - $mark_options = array('mark_important', 'delete_marked'); - - // Minimise edits - if (!$auth->acl_get('u_pm_delete') && $key = array_search('delete_marked', $mark_options)) - { - unset($mark_options[$key]); - } - - $s_mark_options = ''; - foreach ($mark_options as $mark_option) - { - $s_mark_options .= ''; - } - - // We do the folder moving options here too, for template authors to use... - $s_folder_move_options = ''; - if ($folder_id != PRIVMSGS_NO_BOX && $folder_id != PRIVMSGS_OUTBOX) - { - foreach ($folder as $f_id => $folder_ary) - { - if ($f_id == PRIVMSGS_OUTBOX || $f_id == PRIVMSGS_SENTBOX || $f_id == $folder_id) - { - continue; - } - - $s_folder_move_options .= ''; - $s_folder_move_options .= sprintf($user->lang['MOVE_MARKED_TO_FOLDER'], $folder_ary['folder_name']); - $s_folder_move_options .= (($folder_ary['unread_messages']) ? ' [' . $folder_ary['unread_messages'] . '] ' : '') . ''; - } - } - $friend = $foe = array(); - - // Get friends and foes - $sql = 'SELECT * - FROM ' . ZEBRA_TABLE . ' - WHERE user_id = ' . $user->data['user_id']; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $friend[$row['zebra_id']] = $row['friend']; - $foe[$row['zebra_id']] = $row['foe']; - } - $db->sql_freeresult($result); - - $template->assign_vars(array( - 'S_MARK_OPTIONS' => $s_mark_options, - 'S_MOVE_MARKED_OPTIONS' => $s_folder_move_options) - ); - - // Okay, lets dump out the page ... - if (count($folder_info['pm_list'])) - { - $address_list = array(); - - // Build Recipient List if in outbox/sentbox - max two additional queries - if ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) - { - $address_list = get_recipient_strings($folder_info['rowset']); - } - - foreach ($folder_info['pm_list'] as $message_id) - { - $row = &$folder_info['rowset'][$message_id]; - - $folder_img = ($row['pm_unread']) ? 'pm_unread' : 'pm_read'; - $folder_alt = ($row['pm_unread']) ? 'NEW_MESSAGES' : 'NO_NEW_MESSAGES'; - - // Generate all URIs ... - $view_message_url = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=$id&mode=view&f=$folder_id&p=$message_id"); - $remove_message_url = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=$id&mode=compose&action=delete&p=$message_id"); - - $row_indicator = ''; - foreach ($color_rows as $var) - { - if (($var !== 'friend' && $var !== 'foe' && $row[($var === 'message_reported') ? $var : "pm_{$var}"]) - || - (($var === 'friend' || $var === 'foe') && isset(${$var}[$row['author_id']]) && ${$var}[$row['author_id']])) - { - $row_indicator = $var; - break; - } - } - - // Send vars to template - $template->assign_block_vars('messagerow', array( - 'PM_CLASS' => ($row_indicator) ? 'pm_' . $row_indicator . '_colour' : '', - - 'MESSAGE_AUTHOR_FULL' => get_username_string('full', $row['author_id'], $row['username'], $row['user_colour'], $row['username']), - 'MESSAGE_AUTHOR_COLOUR' => get_username_string('colour', $row['author_id'], $row['username'], $row['user_colour'], $row['username']), - 'MESSAGE_AUTHOR' => get_username_string('username', $row['author_id'], $row['username'], $row['user_colour'], $row['username']), - 'U_MESSAGE_AUTHOR' => get_username_string('profile', $row['author_id'], $row['username'], $row['user_colour'], $row['username']), - - 'FOLDER_ID' => $folder_id, - 'MESSAGE_ID' => $message_id, - 'SENT_TIME' => $user->format_date($row['message_time']), - 'SUBJECT' => censor_text($row['message_subject']), - 'FOLDER' => (isset($folder[$row['folder_id']])) ? $folder[$row['folder_id']]['folder_name'] : '', - 'U_FOLDER' => (isset($folder[$row['folder_id']])) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'folder=' . $row['folder_id']) : '', - 'PM_ICON_IMG' => (!empty($icons[$row['icon_id']])) ? '' : '', - 'PM_ICON_URL' => (!empty($icons[$row['icon_id']])) ? $config['icons_path'] . '/' . $icons[$row['icon_id']]['img'] : '', - 'FOLDER_IMG' => $user->img($folder_img, $folder_alt), - 'FOLDER_IMG_STYLE' => $folder_img, - 'PM_IMG' => ($row_indicator) ? $user->img('pm_' . $row_indicator, '') : '', - 'ATTACH_ICON_IMG' => ($auth->acl_get('u_pm_download') && $row['message_attachment'] && $config['allow_pm_attach']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', - - 'S_PM_UNREAD' => ($row['pm_unread']) ? true : false, - 'S_PM_DELETED' => ($row['pm_deleted']) ? true : false, - 'S_PM_REPORTED' => (isset($row['report_id'])) ? true : false, - 'S_AUTHOR_DELETED' => ($row['author_id'] == ANONYMOUS) ? true : false, - - 'U_VIEW_PM' => ($row['pm_deleted']) ? '' : $view_message_url, - 'U_REMOVE_PM' => ($row['pm_deleted']) ? $remove_message_url : '', - 'U_MCP_REPORT' => (isset($row['report_id'])) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=pm_reports&mode=pm_report_details&r=' . $row['report_id']) : '', - 'RECIPIENTS' => ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) ? implode($user->lang['COMMA_SEPARATOR'], $address_list[$message_id]) : '') - ); - } - unset($folder_info['rowset']); - - $template->assign_vars(array( - 'S_SHOW_RECIPIENTS' => ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) ? true : false, - 'S_SHOW_COLOUR_LEGEND' => true, - - 'REPORTED_IMG' => $user->img('icon_topic_reported', 'PM_REPORTED'), - 'S_PM_ICONS' => ($config['enable_pm_icons']) ? true : false) - ); - } - } - else - { - $export_type = $request->variable('export_option', ''); - $enclosure = $request->variable('enclosure', ''); - $delimiter = $request->variable('delimiter', ''); - - if ($export_type == 'CSV' && ($delimiter === '' || $enclosure === '')) - { - $template->assign_var('PROMPT', true); - } - else - { - // Build Recipient List if in outbox/sentbox - - $address_temp = $address = $data = array(); - - if ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) - { - foreach ($folder_info['rowset'] as $message_id => $row) - { - $address_temp[$message_id] = rebuild_header(array('to' => $row['to_address'], 'bcc' => $row['bcc_address'])); - $address[$message_id] = array(); - } - } - - foreach ($folder_info['pm_list'] as $message_id) - { - $row = &$folder_info['rowset'][$message_id]; - - include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx); - - $sql = 'SELECT p.message_text, p.bbcode_uid - FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p, ' . USERS_TABLE . ' u - WHERE t.user_id = ' . $user->data['user_id'] . " - AND p.author_id = u.user_id - AND t.folder_id = $folder_id - AND t.msg_id = p.msg_id - AND p.msg_id = $message_id"; - $result = $db->sql_query_limit($sql, 1); - $message_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $_types = array('u', 'g'); - foreach ($_types as $ug_type) - { - if (isset($address_temp[$message_id][$ug_type]) && count($address_temp[$message_id][$ug_type])) - { - if (!isset($address[$message_id][$ug_type])) - { - $address[$message_id][$ug_type] = array(); - } - if ($ug_type == 'u') - { - $sql = 'SELECT user_id as id, username as name - FROM ' . USERS_TABLE . ' - WHERE '; - } - else - { - $sql = 'SELECT group_id as id, group_name as name - FROM ' . GROUPS_TABLE . ' - WHERE '; - } - $sql .= $db->sql_in_set(($ug_type == 'u') ? 'user_id' : 'group_id', array_map('intval', array_keys($address_temp[$message_id][$ug_type]))); - - $result = $db->sql_query($sql); - - while ($info_row = $db->sql_fetchrow($result)) - { - $address[$message_id][$ug_type][$address_temp[$message_id][$ug_type][$info_row['id']]][] = $info_row['name']; - unset($address_temp[$message_id][$ug_type][$info_row['id']]); - } - $db->sql_freeresult($result); - } - } - - // There is the chance that all recipients of the message got deleted. To avoid creating - // exports without recipients, we add a bogus "undisclosed recipient". - if (!(isset($address[$message_id]['g']) && count($address[$message_id]['g'])) && - !(isset($address[$message_id]['u']) && count($address[$message_id]['u']))) - { - $address[$message_id]['u'] = array(); - $address[$message_id]['u']['to'] = array(); - $address[$message_id]['u']['to'][] = $user->lang['UNDISCLOSED_RECIPIENT']; - } - - decode_message($message_row['message_text'], $message_row['bbcode_uid']); - - $data[] = array( - 'subject' => censor_text($row['message_subject']), - 'sender' => $row['username'], - // ISO 8601 date. For PHP4 we are able to hardcode the timezone because $user->format_date() does not set it. - 'date' => $user->format_date($row['message_time'], 'c', true), - 'to' => ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) ? $address[$message_id] : '', - 'message' => $message_row['message_text'] - ); - } - - switch ($export_type) - { - case 'CSV': - case 'CSV_EXCEL': - $mimetype = 'text/csv'; - $filetype = 'csv'; - - if ($export_type == 'CSV_EXCEL') - { - $enclosure = '"'; - $delimiter = ','; - $newline = "\r\n"; - } - else - { - $newline = "\n"; - } - - $string = ''; - foreach ($data as $value) - { - $recipients = $value['to']; - $value['to'] = $value['bcc'] = ''; - - if (is_array($recipients)) - { - foreach ($recipients as $values) - { - $value['bcc'] .= (isset($values['bcc']) && is_array($values['bcc'])) ? ',' . implode(',', $values['bcc']) : ''; - $value['to'] .= (isset($values['to']) && is_array($values['to'])) ? ',' . implode(',', $values['to']) : ''; - } - - // Remove the commas which will appear before the first entry. - $value['to'] = substr($value['to'], 1); - $value['bcc'] = substr($value['bcc'], 1); - } - - foreach ($value as $tag => $text) - { - $cell = str_replace($enclosure, $enclosure . $enclosure, $text); - - if (strpos($cell, $enclosure) !== false || strpos($cell, $delimiter) !== false || strpos($cell, $newline) !== false) - { - $string .= $enclosure . $text . $enclosure . $delimiter; - } - else - { - $string .= $cell . $delimiter; - } - } - $string = substr($string, 0, -1) . $newline; - } - break; - - case 'XML': - $mimetype = 'application/xml'; - $filetype = 'xml'; - $string = '' . "\n"; - $string .= "\n"; - - foreach ($data as $value) - { - $string .= "\t\n"; - - if (is_array($value['to'])) - { - foreach ($value['to'] as $key => $values) - { - foreach ($values as $type => $types) - { - foreach ($types as $name) - { - $string .= "\t\t$name\n"; - } - } - } - } - - unset($value['to']); - - foreach ($value as $tag => $text) - { - $string .= "\t\t<$tag>$text\n"; - } - - $string .= "\t\n"; - } - $string .= ''; - break; - } - - header('Cache-Control: private, no-cache'); - header("Content-Type: $mimetype; name=\"data.$filetype\""); - header("Content-disposition: attachment; filename=data.$filetype"); - echo $string; - exit; - } - } -} - -/** -* Get Messages from folder/user -*/ -function get_pm_from($folder_id, $folder, $user_id) -{ - global $user, $db, $template, $config, $auth, $phpbb_container, $phpbb_root_path, $phpEx, $request, $phpbb_dispatcher; - - $start = $request->variable('start', 0); - - // Additional vars later, pm ordering is mostly different from post ordering. :/ - $sort_days = $request->variable('st', 0); - $sort_key = $request->variable('sk', 't'); - $sort_dir = $request->variable('sd', 'd'); - - /* @var $pagination \phpbb\pagination */ - $pagination = $phpbb_container->get('pagination'); - - // PM ordering options - $limit_days = array(0 => $user->lang['ALL_MESSAGES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); - - // No sort by Author for sentbox/outbox (already only author available) - // Also, sort by msg_id for the time - private messages are not as prone to errors as posts are. - if ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) - { - $sort_by_text = array('t' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']); - $sort_by_sql = array('t' => 'p.message_time', 's' => array('p.message_subject', 'p.message_time')); - } - else - { - $sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']); - $sort_by_sql = array('a' => array('u.username_clean', 'p.message_time'), 't' => 'p.message_time', 's' => array('p.message_subject', 'p.message_time')); - } - - $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; - gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); - - $folder_sql = 't.folder_id = ' . (int) $folder_id; - - // Limit pms to certain time frame, obtain correct pm count - if ($sort_days) - { - $min_post_time = time() - ($sort_days * 86400); - - if (isset($_POST['sort'])) - { - $start = 0; - } - - $sql = 'SELECT COUNT(t.msg_id) AS pm_count - FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . " p - WHERE $folder_sql - AND t.user_id = $user_id - AND t.msg_id = p.msg_id - AND p.message_time >= $min_post_time"; - $result = $db->sql_query_limit($sql, 1); - $pm_count = (int) $db->sql_fetchfield('pm_count'); - $db->sql_freeresult($result); - - $sql_limit_time = "AND p.message_time >= $min_post_time"; - } - else - { - $pm_count = (!empty($folder[$folder_id]['num_messages'])) ? $folder[$folder_id]['num_messages'] : 0; - $sql_limit_time = ''; - } - - $base_url = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=pm&mode=view&action=view_folder&f=$folder_id&$u_sort_param"); - $start = $pagination->validate_start($start, $config['topics_per_page'], $pm_count); - $pagination->generate_template_pagination($base_url, 'pagination', 'start', $pm_count, $config['topics_per_page'], $start); - - $template_vars = array( - 'TOTAL_MESSAGES' => $user->lang('VIEW_PM_MESSAGES', (int) $pm_count), - - 'POST_IMG' => (!$auth->acl_get('u_sendpm')) ? $user->img('button_topic_locked', 'POST_PM_LOCKED') : $user->img('button_pm_new', 'POST_NEW_PM'), - - 'S_NO_AUTH_SEND_MESSAGE' => !$auth->acl_get('u_sendpm'), - - 'S_SELECT_SORT_DIR' => $s_sort_dir, - 'S_SELECT_SORT_KEY' => $s_sort_key, - 'S_SELECT_SORT_DAYS' => $s_limit_days, - 'S_TOPIC_ICONS' => ($config['enable_pm_icons']) ? true : false, - - 'U_POST_NEW_TOPIC' => ($auth->acl_get('u_sendpm')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose') : '', - 'S_PM_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", "i=pm&mode=view&action=view_folder&f=$folder_id" . (($start !== 0) ? "&start=$start" : '')), - ); - - /** - * Modify template variables before they are assigned - * - * @event core.ucp_pm_view_folder_get_pm_from_template - * @var int folder_id Folder ID - * @var array folder Folder data - * @var int user_id User ID - * @var string base_url Pagination base URL - * @var int start Pagination start - * @var int pm_count Count of PMs - * @var array template_vars Template variables to be assigned - * @since 3.1.11-RC1 - */ - $vars = array( - 'folder_id', - 'folder', - 'user_id', - 'base_url', - 'start', - 'pm_count', - 'template_vars', - ); - extract($phpbb_dispatcher->trigger_event('core.ucp_pm_view_folder_get_pm_from_template', compact($vars))); - - $template->assign_vars($template_vars); - - // Grab all pm data - $rowset = $pm_list = array(); - - // If the user is trying to reach late pages, start searching from the end - $store_reverse = false; - $sql_limit = $config['topics_per_page']; - if ($start > $pm_count / 2) - { - $store_reverse = true; - - // Select the sort order - $direction = ($sort_dir == 'd') ? 'ASC' : 'DESC'; - $sql_limit = $pagination->reverse_limit($start, $sql_limit, $pm_count); - $sql_start = $pagination->reverse_start($start, $sql_limit, $pm_count); - } - else - { - // Select the sort order - $direction = ($sort_dir == 'd') ? 'DESC' : 'ASC'; - $sql_start = $start; - } - - // Sql sort order - if (is_array($sort_by_sql[$sort_key])) - { - $sql_sort_order = implode(' ' . $direction . ', ', $sort_by_sql[$sort_key]) . ' ' . $direction; - } - else - { - $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . $direction; - } - - $sql_ary = array( - 'SELECT' => 't.*, p.root_level, p.message_time, p.message_subject, p.icon_id, p.to_address, p.message_attachment, p.bcc_address, u.username, u.username_clean, u.user_colour, p.message_reported', - 'FROM' => array( - PRIVMSGS_TO_TABLE => 't', - PRIVMSGS_TABLE => 'p', - USERS_TABLE => 'u', - ), - 'WHERE' => "t.user_id = $user_id - AND p.author_id = u.user_id - AND $folder_sql - AND t.msg_id = p.msg_id - $sql_limit_time", - 'ORDER_BY' => $sql_sort_order, - ); - - /** - * Modify SQL before it is executed - * - * @event core.ucp_pm_view_folder_get_pm_from_sql - * @var array sql_ary SQL array - * @var int sql_limit SQL limit - * @var int sql_start SQL start - * @since 3.1.11-RC1 - */ - $vars = array( - 'sql_ary', - 'sql_limit', - 'sql_start', - ); - extract($phpbb_dispatcher->trigger_event('core.ucp_pm_view_folder_get_pm_from_sql', compact($vars))); - - $result = $db->sql_query_limit($db->sql_build_query('SELECT', $sql_ary), $sql_limit, $sql_start); - - $pm_reported = array(); - while ($row = $db->sql_fetchrow($result)) - { - $rowset[$row['msg_id']] = $row; - $pm_list[] = $row['msg_id']; - if ($row['message_reported']) - { - $pm_reported[] = $row['msg_id']; - } - } - $db->sql_freeresult($result); - - // Fetch the report_ids, if there are any reported pms. - if (!empty($pm_reported) && $auth->acl_getf_global('m_report')) - { - $sql = 'SELECT pm_id, report_id - FROM ' . REPORTS_TABLE . ' - WHERE report_closed = 0 - AND ' . $db->sql_in_set('pm_id', $pm_reported); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $rowset[$row['pm_id']]['report_id'] = $row['report_id']; - } - $db->sql_freeresult($result); - } - - $pm_list = ($store_reverse) ? array_reverse($pm_list) : $pm_list; - - return array( - 'pm_count' => $pm_count, - 'pm_list' => $pm_list, - 'rowset' => $rowset - ); -} diff --git a/install/update/old/includes/ucp/ucp_profile.php b/install/update/old/includes/ucp/ucp_profile.php deleted file mode 100644 index 9a12840..0000000 --- a/install/update/old/includes/ucp/ucp_profile.php +++ /dev/null @@ -1,847 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* ucp_profile -* Changing profile settings -* -* @todo what about pertaining user_sig_options? -*/ -class ucp_profile -{ - var $u_action; - - function main($id, $mode) - { - global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx; - global $request, $phpbb_container, $phpbb_log, $phpbb_dispatcher; - - $user->add_lang('posting'); - - $submit = $request->variable('submit', false, false, \phpbb\request\request_interface::POST); - $error = $data = array(); - $s_hidden_fields = ''; - - switch ($mode) - { - case 'reg_details': - - $data = array( - 'username' => $request->variable('username', $user->data['username'], true), - 'email' => strtolower($request->variable('email', $user->data['user_email'])), - 'new_password' => $request->variable('new_password', '', true), - 'cur_password' => $request->variable('cur_password', '', true), - 'password_confirm' => $request->variable('password_confirm', '', true), - ); - - /** - * Modify user registration data on editing account settings in UCP - * - * @event core.ucp_profile_reg_details_data - * @var array data Array with current or updated user registration data - * @var bool submit Flag indicating if submit button has been pressed - * @since 3.1.4-RC1 - */ - $vars = array('data', 'submit'); - extract($phpbb_dispatcher->trigger_event('core.ucp_profile_reg_details_data', compact($vars))); - - add_form_key('ucp_reg_details'); - - if ($submit) - { - // Do not check cur_password, it is the old one. - $check_ary = array( - 'new_password' => array( - array('string', true, $config['min_pass_chars'], $config['max_pass_chars']), - array('password')), - 'password_confirm' => array('string', true, $config['min_pass_chars'], $config['max_pass_chars']), - 'email' => array( - array('string', false, 6, 60), - array('user_email')), - ); - - if ($auth->acl_get('u_chgname') && $config['allow_namechange']) - { - $check_ary['username'] = array( - array('string', false, $config['min_name_chars'], $config['max_name_chars']), - array('username'), - ); - } - - $error = validate_data($data, $check_ary); - - if ($auth->acl_get('u_chgpasswd') && $data['new_password'] && $data['password_confirm'] != $data['new_password']) - { - $error[] = ($data['password_confirm']) ? 'NEW_PASSWORD_ERROR' : 'NEW_PASSWORD_CONFIRM_EMPTY'; - } - - // Instantiate passwords manager - /* @var $passwords_manager \phpbb\passwords\manager */ - $passwords_manager = $phpbb_container->get('passwords.manager'); - - // Only check the new password against the previous password if there have been no errors - if (!count($error) && $auth->acl_get('u_chgpasswd') && $data['new_password'] && $passwords_manager->check($data['new_password'], $user->data['user_password'])) - { - $error[] = 'SAME_PASSWORD_ERROR'; - } - - if (!$passwords_manager->check($data['cur_password'], $user->data['user_password'])) - { - $error[] = ($data['cur_password']) ? 'CUR_PASSWORD_ERROR' : 'CUR_PASSWORD_EMPTY'; - } - - if (!check_form_key('ucp_reg_details')) - { - $error[] = 'FORM_INVALID'; - } - - /** - * Validate user data on editing registration data in UCP - * - * @event core.ucp_profile_reg_details_validate - * @var array data Array with user profile data - * @var bool submit Flag indicating if submit button has been pressed - * @var array error Array of any generated errors - * @since 3.1.4-RC1 - */ - $vars = array('data', 'submit', 'error'); - extract($phpbb_dispatcher->trigger_event('core.ucp_profile_reg_details_validate', compact($vars))); - - if (!count($error)) - { - $sql_ary = array( - 'username' => ($auth->acl_get('u_chgname') && $config['allow_namechange']) ? $data['username'] : $user->data['username'], - 'username_clean' => ($auth->acl_get('u_chgname') && $config['allow_namechange']) ? utf8_clean_string($data['username']) : $user->data['username_clean'], - 'user_email' => ($auth->acl_get('u_chgemail')) ? $data['email'] : $user->data['user_email'], - 'user_email_hash' => ($auth->acl_get('u_chgemail')) ? phpbb_email_hash($data['email']) : $user->data['user_email_hash'], - 'user_password' => ($auth->acl_get('u_chgpasswd') && $data['new_password']) ? $passwords_manager->hash($data['new_password']) : $user->data['user_password'], - 'user_passchg' => ($auth->acl_get('u_chgpasswd') && $data['new_password']) ? time() : 0, - ); - - if ($auth->acl_get('u_chgname') && $config['allow_namechange'] && $data['username'] != $user->data['username']) - { - $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_UPDATE_NAME', false, array( - 'reportee_id' => $user->data['user_id'], - $user->data['username'], - $data['username'] - )); - } - - if ($auth->acl_get('u_chgpasswd') && $data['new_password'] && !$passwords_manager->check($data['new_password'], $user->data['user_password'])) - { - $user->reset_login_keys(); - $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_NEW_PASSWORD', false, array( - 'reportee_id' => $user->data['user_id'], - $user->data['username'] - )); - } - - if ($auth->acl_get('u_chgemail') && $data['email'] != $user->data['user_email']) - { - $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_UPDATE_EMAIL', false, array( - 'reportee_id' => $user->data['user_id'], - $user->data['username'], - $user->data['user_email'], - $data['email'] - )); - } - - $message = 'PROFILE_UPDATED'; - - if ($auth->acl_get('u_chgemail') && $config['email_enable'] && $data['email'] != $user->data['user_email'] && $user->data['user_type'] != USER_FOUNDER && ($config['require_activation'] == USER_ACTIVATION_SELF || $config['require_activation'] == USER_ACTIVATION_ADMIN)) - { - $message = ($config['require_activation'] == USER_ACTIVATION_SELF) ? 'ACCOUNT_EMAIL_CHANGED' : 'ACCOUNT_EMAIL_CHANGED_ADMIN'; - - include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); - - $server_url = generate_board_url(); - - $user_actkey = gen_rand_string(mt_rand(6, 10)); - - $messenger = new messenger(false); - - $template_file = ($config['require_activation'] == USER_ACTIVATION_ADMIN) ? 'user_activate_inactive' : 'user_activate'; - $messenger->template($template_file, $user->data['user_lang']); - - $messenger->to($data['email'], $data['username']); - - $messenger->anti_abuse_headers($config, $user); - - $messenger->assign_vars(array( - 'USERNAME' => htmlspecialchars_decode($data['username']), - 'U_ACTIVATE' => "$server_url/ucp.$phpEx?mode=activate&u={$user->data['user_id']}&k=$user_actkey") - ); - - $messenger->send(NOTIFY_EMAIL); - - if ($config['require_activation'] == USER_ACTIVATION_ADMIN) - { - $notifications_manager = $phpbb_container->get('notification_manager'); - $notifications_manager->add_notifications('notification.type.admin_activate_user', array( - 'user_id' => $user->data['user_id'], - 'user_actkey' => $user_actkey, - 'user_regdate' => time(), // Notification time - )); - } - - user_active_flip('deactivate', $user->data['user_id'], INACTIVE_PROFILE); - - // Because we want the profile to be reactivated we set user_newpasswd to empty (else the reactivation will fail) - $sql_ary['user_actkey'] = $user_actkey; - $sql_ary['user_newpasswd'] = ''; - } - - /** - * Modify user registration data before submitting it to the database - * - * @event core.ucp_profile_reg_details_sql_ary - * @var array data Array with current or updated user registration data - * @var array sql_ary Array with user registration data to submit to the database - * @since 3.1.4-RC1 - */ - $vars = array('data', 'sql_ary'); - extract($phpbb_dispatcher->trigger_event('core.ucp_profile_reg_details_sql_ary', compact($vars))); - - if (count($sql_ary)) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE user_id = ' . $user->data['user_id']; - $db->sql_query($sql); - } - - // Need to update config, forum, topic, posting, messages, etc. - if ($data['username'] != $user->data['username'] && $auth->acl_get('u_chgname') && $config['allow_namechange']) - { - user_update_name($user->data['username'], $data['username']); - } - - // Now, we can remove the user completely (kill the session) - NOT BEFORE!!! - if (!empty($sql_ary['user_actkey'])) - { - meta_refresh(5, append_sid($phpbb_root_path . 'index.' . $phpEx)); - $message = $user->lang[$message] . '

' . sprintf($user->lang['RETURN_INDEX'], '', ''); - - // Because the user gets deactivated we log him out too, killing his session - $user->session_kill(); - } - else - { - meta_refresh(3, $this->u_action); - $message = $user->lang[$message] . '

' . sprintf($user->lang['RETURN_UCP'], '', ''); - } - - trigger_error($message); - } - - // Replace "error" strings with their real, localised form - $error = array_map(array($user, 'lang'), $error); - } - - $template->assign_vars(array( - 'ERROR' => (count($error)) ? implode('
', $error) : '', - - 'USERNAME' => $data['username'], - 'EMAIL' => $data['email'], - 'PASSWORD_CONFIRM' => $data['password_confirm'], - 'NEW_PASSWORD' => $data['new_password'], - 'CUR_PASSWORD' => '', - - 'L_USERNAME_EXPLAIN' => $user->lang($config['allow_name_chars'] . '_EXPLAIN', $user->lang('CHARACTERS', (int) $config['min_name_chars']), $user->lang('CHARACTERS', (int) $config['max_name_chars'])), - 'L_CHANGE_PASSWORD_EXPLAIN' => $user->lang($config['pass_complex'] . '_EXPLAIN', $user->lang('CHARACTERS', (int) $config['min_pass_chars']), $user->lang('CHARACTERS', (int) $config['max_pass_chars'])), - - 'S_FORCE_PASSWORD' => ($auth->acl_get('u_chgpasswd') && $config['chg_passforce'] && $user->data['user_passchg'] < time() - ($config['chg_passforce'] * 86400)) ? true : false, - 'S_CHANGE_USERNAME' => ($config['allow_namechange'] && $auth->acl_get('u_chgname')) ? true : false, - 'S_CHANGE_EMAIL' => ($auth->acl_get('u_chgemail')) ? true : false, - 'S_CHANGE_PASSWORD' => ($auth->acl_get('u_chgpasswd')) ? true : false) - ); - break; - - case 'profile_info': - // Do not display profile information panel if not authed to do so - if (!$auth->acl_get('u_chgprofileinfo')) - { - send_status_line(403, 'Forbidden'); - trigger_error('NO_AUTH_PROFILEINFO'); - } - - /* @var $cp \phpbb\profilefields\manager */ - $cp = $phpbb_container->get('profilefields.manager'); - - $cp_data = $cp_error = array(); - - $data = array( - 'jabber' => $request->variable('jabber', $user->data['user_jabber'], true), - ); - - if ($config['allow_birthdays']) - { - $data['bday_day'] = $data['bday_month'] = $data['bday_year'] = 0; - - if ($user->data['user_birthday']) - { - list($data['bday_day'], $data['bday_month'], $data['bday_year']) = explode('-', $user->data['user_birthday']); - } - - $data['bday_day'] = $request->variable('bday_day', $data['bday_day']); - $data['bday_month'] = $request->variable('bday_month', $data['bday_month']); - $data['bday_year'] = $request->variable('bday_year', $data['bday_year']); - $data['user_birthday'] = sprintf('%2d-%2d-%4d', $data['bday_day'], $data['bday_month'], $data['bday_year']); - } - - /** - * Modify user data on editing profile in UCP - * - * @event core.ucp_profile_modify_profile_info - * @var array data Array with user profile data - * @var bool submit Flag indicating if submit button has been pressed - * @since 3.1.4-RC1 - */ - $vars = array('data', 'submit'); - extract($phpbb_dispatcher->trigger_event('core.ucp_profile_modify_profile_info', compact($vars))); - - add_form_key('ucp_profile_info'); - - if ($submit) - { - $validate_array = array( - 'jabber' => array( - array('string', true, 5, 255), - array('jabber')), - ); - - if ($config['allow_birthdays']) - { - $validate_array = array_merge($validate_array, array( - 'bday_day' => array('num', true, 1, 31), - 'bday_month' => array('num', true, 1, 12), - 'bday_year' => array('num', true, 1901, gmdate('Y', time()) + 50), - 'user_birthday' => array('date', true), - )); - } - - $error = validate_data($data, $validate_array); - - // validate custom profile fields - $cp->submit_cp_field('profile', $user->get_iso_lang_id(), $cp_data, $cp_error); - - if (count($cp_error)) - { - $error = array_merge($error, $cp_error); - } - - if (!check_form_key('ucp_profile_info')) - { - $error[] = 'FORM_INVALID'; - } - - /** - * Validate user data on editing profile in UCP - * - * @event core.ucp_profile_validate_profile_info - * @var array data Array with user profile data - * @var bool submit Flag indicating if submit button has been pressed - * @var array error Array of any generated errors - * @since 3.1.4-RC1 - */ - $vars = array('data', 'submit', 'error'); - extract($phpbb_dispatcher->trigger_event('core.ucp_profile_validate_profile_info', compact($vars))); - - if (!count($error)) - { - $data['notify'] = $user->data['user_notify_type']; - - if ($data['notify'] == NOTIFY_IM && (!$config['jab_enable'] || !$data['jabber'] || !@extension_loaded('xml'))) - { - // User has not filled in a jabber address (Or one of the modules is disabled or jabber is disabled) - // Disable notify by Jabber now for this user. - $data['notify'] = NOTIFY_EMAIL; - } - - $sql_ary = array( - 'user_jabber' => $data['jabber'], - 'user_notify_type' => $data['notify'], - ); - - if ($config['allow_birthdays']) - { - $sql_ary['user_birthday'] = $data['user_birthday']; - } - - /** - * Modify profile data in UCP before submitting to the database - * - * @event core.ucp_profile_info_modify_sql_ary - * @var array cp_data Array with the user custom profile fields data - * @var array data Array with user profile data - * @var array sql_ary user options data we update - * @since 3.1.4-RC1 - */ - $vars = array('cp_data', 'data', 'sql_ary'); - extract($phpbb_dispatcher->trigger_event('core.ucp_profile_info_modify_sql_ary', compact($vars))); - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE user_id = ' . $user->data['user_id']; - $db->sql_query($sql); - - // Update Custom Fields - $cp->update_profile_field_data($user->data['user_id'], $cp_data); - - meta_refresh(3, $this->u_action); - $message = $user->lang['PROFILE_UPDATED'] . '

' . sprintf($user->lang['RETURN_UCP'], '', ''); - trigger_error($message); - } - - // Replace "error" strings with their real, localised form - $error = array_map(array($user, 'lang'), $error); - } - - if ($config['allow_birthdays']) - { - $s_birthday_day_options = ''; - for ($i = 1; $i < 32; $i++) - { - $selected = ($i == $data['bday_day']) ? ' selected="selected"' : ''; - $s_birthday_day_options .= ""; - } - - $s_birthday_month_options = ''; - for ($i = 1; $i < 13; $i++) - { - $selected = ($i == $data['bday_month']) ? ' selected="selected"' : ''; - $s_birthday_month_options .= ""; - } - - $now = getdate(); - $s_birthday_year_options = ''; - for ($i = $now['year'] - 100; $i <= $now['year']; $i++) - { - $selected = ($i == $data['bday_year']) ? ' selected="selected"' : ''; - $s_birthday_year_options .= ""; - } - unset($now); - - $template->assign_vars(array( - 'S_BIRTHDAY_DAY_OPTIONS' => $s_birthday_day_options, - 'S_BIRTHDAY_MONTH_OPTIONS' => $s_birthday_month_options, - 'S_BIRTHDAY_YEAR_OPTIONS' => $s_birthday_year_options, - 'S_BIRTHDAYS_ENABLED' => true, - )); - } - - $template->assign_vars(array( - 'ERROR' => (count($error)) ? implode('
', $error) : '', - 'S_JABBER_ENABLED' => $config['jab_enable'], - 'JABBER' => $data['jabber'], - )); - - // Get additional profile fields and assign them to the template block var 'profile_fields' - $user->get_profile_fields($user->data['user_id']); - - $cp->generate_profile_fields('profile', $user->get_iso_lang_id()); - - break; - - case 'signature': - - if (!$auth->acl_get('u_sig')) - { - send_status_line(403, 'Forbidden'); - trigger_error('NO_AUTH_SIGNATURE'); - } - - if (!function_exists('generate_smilies')) - { - include($phpbb_root_path . 'includes/functions_posting.' . $phpEx); - } - - if (!function_exists('display_custom_bbcodes')) - { - include($phpbb_root_path . 'includes/functions_display.' . $phpEx); - } - - $preview = $request->is_set_post('preview'); - - $enable_bbcode = ($config['allow_sig_bbcode']) ? $user->optionget('sig_bbcode') : false; - $enable_smilies = ($config['allow_sig_smilies']) ? $user->optionget('sig_smilies') : false; - $enable_urls = ($config['allow_sig_links']) ? $user->optionget('sig_links') : false; - - $bbcode_flags = ($enable_bbcode ? OPTION_FLAG_BBCODE : 0) + ($enable_smilies ? OPTION_FLAG_SMILIES : 0) + ($enable_urls ? OPTION_FLAG_LINKS : 0); - - $decoded_message = generate_text_for_edit($user->data['user_sig'], $user->data['user_sig_bbcode_uid'], $bbcode_flags); - $signature = $request->variable('signature', $decoded_message['text'], true); - $signature_preview = ''; - - if ($submit || $preview) - { - $enable_bbcode = ($config['allow_sig_bbcode']) ? !$request->variable('disable_bbcode', false) : false; - $enable_smilies = ($config['allow_sig_smilies']) ? !$request->variable('disable_smilies', false) : false; - $enable_urls = ($config['allow_sig_links']) ? !$request->variable('disable_magic_url', false) : false; - - if (!check_form_key('ucp_sig')) - { - $error[] = 'FORM_INVALID'; - } - } - - /** - * Modify user signature on editing profile in UCP - * - * @event core.ucp_profile_modify_signature - * @var bool enable_bbcode Whether or not bbcode is enabled - * @var bool enable_smilies Whether or not smilies are enabled - * @var bool enable_urls Whether or not urls are enabled - * @var string signature Users signature text - * @var array error Any error strings - * @var bool submit Whether or not the form has been sumitted - * @var bool preview Whether or not the signature is being previewed - * @since 3.1.10-RC1 - * @changed 3.2.0-RC2 Removed message parser - */ - $vars = array( - 'enable_bbcode', - 'enable_smilies', - 'enable_urls', - 'signature', - 'error', - 'submit', - 'preview', - ); - extract($phpbb_dispatcher->trigger_event('core.ucp_profile_modify_signature', compact($vars))); - - $bbcode_uid = $bbcode_bitfield = $bbcode_flags = ''; - $warn_msg = generate_text_for_storage( - $signature, - $bbcode_uid, - $bbcode_bitfield, - $bbcode_flags, - $enable_bbcode, - $enable_urls, - $enable_smilies, - $config['allow_sig_img'], - $config['allow_sig_flash'], - true, - $config['allow_sig_links'], - 'sig' - ); - - if (count($warn_msg)) - { - $error += $warn_msg; - } - - if (!$submit) - { - // Parse it for displaying - $signature_preview = generate_text_for_display($signature, $bbcode_uid, $bbcode_bitfield, $bbcode_flags); - } - else - { - if (!count($error)) - { - $user->optionset('sig_bbcode', $enable_bbcode); - $user->optionset('sig_smilies', $enable_smilies); - $user->optionset('sig_links', $enable_urls); - - $sql_ary = array( - 'user_sig' => $signature, - 'user_options' => $user->data['user_options'], - 'user_sig_bbcode_uid' => $bbcode_uid, - 'user_sig_bbcode_bitfield' => $bbcode_bitfield - ); - - /** - * Modify user registration data before submitting it to the database - * - * @event core.ucp_profile_modify_signature_sql_ary - * @var array sql_ary Array with user signature data to submit to the database - * @since 3.1.10-RC1 - */ - $vars = array('sql_ary'); - extract($phpbb_dispatcher->trigger_event('core.ucp_profile_modify_signature_sql_ary', compact($vars))); - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE user_id = ' . $user->data['user_id']; - $db->sql_query($sql); - - $message = $user->lang['PROFILE_UPDATED'] . '

' . sprintf($user->lang['RETURN_UCP'], '', ''); - trigger_error($message); - } - } - - // Replace "error" strings with their real, localised form - $error = array_map(array($user, 'lang'), $error); - - if ($request->is_set_post('preview')) - { - $decoded_message = generate_text_for_edit($signature, $bbcode_uid, $bbcode_flags); - } - - /** @var \phpbb\controller\helper $controller_helper */ - $controller_helper = $phpbb_container->get('controller.helper'); - - $template->assign_vars(array( - 'ERROR' => (count($error)) ? implode('
', $error) : '', - 'SIGNATURE' => $decoded_message['text'], - 'SIGNATURE_PREVIEW' => $signature_preview, - - 'S_BBCODE_CHECKED' => (!$enable_bbcode) ? ' checked="checked"' : '', - 'S_SMILIES_CHECKED' => (!$enable_smilies) ? ' checked="checked"' : '', - 'S_MAGIC_URL_CHECKED' => (!$enable_urls) ? ' checked="checked"' : '', - - 'BBCODE_STATUS' => $user->lang(($config['allow_sig_bbcode'] ? 'BBCODE_IS_ON' : 'BBCODE_IS_OFF'), '', ''), - 'SMILIES_STATUS' => ($config['allow_sig_smilies']) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'], - 'IMG_STATUS' => ($config['allow_sig_img']) ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'], - 'FLASH_STATUS' => ($config['allow_sig_flash']) ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'], - 'URL_STATUS' => ($config['allow_sig_links']) ? $user->lang['URL_IS_ON'] : $user->lang['URL_IS_OFF'], - 'MAX_FONT_SIZE' => (int) $config['max_sig_font_size'], - - 'L_SIGNATURE_EXPLAIN' => $user->lang('SIGNATURE_EXPLAIN', (int) $config['max_sig_chars']), - - 'S_BBCODE_ALLOWED' => $config['allow_sig_bbcode'], - 'S_SMILIES_ALLOWED' => $config['allow_sig_smilies'], - 'S_BBCODE_IMG' => ($config['allow_sig_img']) ? true : false, - 'S_BBCODE_FLASH' => ($config['allow_sig_flash']) ? true : false, - 'S_LINKS_ALLOWED' => ($config['allow_sig_links']) ? true : false) - ); - - add_form_key('ucp_sig'); - - // Build custom bbcodes array - display_custom_bbcodes(); - - // Generate smiley listing - generate_smilies('inline', 0); - - break; - - case 'avatar': - - add_form_key('ucp_avatar'); - - $avatars_enabled = false; - - if ($config['allow_avatar'] && $auth->acl_get('u_chgavatar')) - { - /* @var $phpbb_avatar_manager \phpbb\avatar\manager */ - $phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); - $avatar_drivers = $phpbb_avatar_manager->get_enabled_drivers(); - - // This is normalised data, without the user_ prefix - $avatar_data = \phpbb\avatar\manager::clean_row($user->data, 'user'); - - if ($submit) - { - if (check_form_key('ucp_avatar')) - { - $driver_name = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', '')); - - if (in_array($driver_name, $avatar_drivers) && !$request->is_set_post('avatar_delete')) - { - $driver = $phpbb_avatar_manager->get_driver($driver_name); - $result = $driver->process_form($request, $template, $user, $avatar_data, $error); - - if ($result && empty($error)) - { - // Success! Lets save the result in the database - $result = array( - 'user_avatar_type' => $driver_name, - 'user_avatar' => $result['avatar'], - 'user_avatar_width' => $result['avatar_width'], - 'user_avatar_height' => $result['avatar_height'], - ); - - /** - * Trigger events on successfull avatar change - * - * @event core.ucp_profile_avatar_sql - * @var array result Array with data to be stored in DB - * @since 3.1.11-RC1 - */ - $vars = array('result'); - extract($phpbb_dispatcher->trigger_event('core.ucp_profile_avatar_sql', compact($vars))); - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $result) . ' - WHERE user_id = ' . (int) $user->data['user_id']; - $db->sql_query($sql); - - meta_refresh(3, $this->u_action); - $message = $user->lang['PROFILE_UPDATED'] . '

' . sprintf($user->lang['RETURN_UCP'], '', ''); - trigger_error($message); - } - } - } - else - { - $error[] = 'FORM_INVALID'; - } - } - - // Handle deletion of avatars - if ($request->is_set_post('avatar_delete')) - { - if (!confirm_box(true)) - { - confirm_box(false, $user->lang('CONFIRM_AVATAR_DELETE'), build_hidden_fields(array( - 'avatar_delete' => true, - 'i' => $id, - 'mode' => $mode)) - ); - } - else - { - $phpbb_avatar_manager->handle_avatar_delete($db, $user, $avatar_data, USERS_TABLE, 'user_'); - - meta_refresh(3, $this->u_action); - $message = $user->lang['PROFILE_UPDATED'] . '

' . sprintf($user->lang['RETURN_UCP'], '', ''); - trigger_error($message); - } - } - - $selected_driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', $user->data['user_avatar_type'])); - - $template->assign_vars(array( - 'AVATAR_MIN_WIDTH' => $config['avatar_min_width'], - 'AVATAR_MAX_WIDTH' => $config['avatar_max_width'], - 'AVATAR_MIN_HEIGHT' => $config['avatar_min_height'], - 'AVATAR_MAX_HEIGHT' => $config['avatar_max_height'], - )); - - foreach ($avatar_drivers as $current_driver) - { - $driver = $phpbb_avatar_manager->get_driver($current_driver); - - $avatars_enabled = true; - $template->set_filenames(array( - 'avatar' => $driver->get_template_name(), - )); - - if ($driver->prepare_form($request, $template, $user, $avatar_data, $error)) - { - $driver_name = $phpbb_avatar_manager->prepare_driver_name($current_driver); - $driver_upper = strtoupper($driver_name); - - $template->assign_block_vars('avatar_drivers', array( - 'L_TITLE' => $user->lang($driver_upper . '_TITLE'), - 'L_EXPLAIN' => $user->lang($driver_upper . '_EXPLAIN'), - - 'DRIVER' => $driver_name, - 'SELECTED' => $current_driver == $selected_driver, - 'OUTPUT' => $template->assign_display('avatar'), - )); - } - } - - // Replace "error" strings with their real, localised form - $error = $phpbb_avatar_manager->localize_errors($user, $error); - } - - $avatar = phpbb_get_user_avatar($user->data, 'USER_AVATAR', true); - - $template->assign_vars(array( - 'ERROR' => (count($error)) ? implode('
', $error) : '', - 'AVATAR' => $avatar, - - 'S_FORM_ENCTYPE' => ' enctype="multipart/form-data"', - - 'L_AVATAR_EXPLAIN' => phpbb_avatar_explanation_string(), - - 'S_AVATARS_ENABLED' => ($config['allow_avatar'] && $avatars_enabled), - )); - - break; - - case 'autologin_keys': - - add_form_key('ucp_autologin_keys'); - - if ($submit) - { - $keys = $request->variable('keys', array('')); - - if (!check_form_key('ucp_autologin_keys')) - { - $error[] = 'FORM_INVALID'; - } - - if (!count($error)) - { - if (!empty($keys)) - { - foreach ($keys as $key => $id) - { - $keys[$key] = $db->sql_like_expression($id . $db->get_any_char()); - } - $sql_where = '(key_id ' . implode(' OR key_id ', $keys) . ')'; - $sql = 'DELETE FROM ' . SESSIONS_KEYS_TABLE . ' - WHERE user_id = ' . (int) $user->data['user_id'] . ' - AND ' . $sql_where ; - - $db->sql_query($sql); - - meta_refresh(3, $this->u_action); - $message = $user->lang['AUTOLOGIN_SESSION_KEYS_DELETED'] . '

' . sprintf($user->lang['RETURN_UCP'], '', ''); - trigger_error($message); - } - } - - // Replace "error" strings with their real, localised form - $error = array_map(array($user, 'lang'), $error); - } - - $sql = 'SELECT key_id, last_ip, last_login - FROM ' . SESSIONS_KEYS_TABLE . ' - WHERE user_id = ' . (int) $user->data['user_id'] . ' - ORDER BY last_login ASC'; - - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $template->assign_block_vars('sessions', array( - 'KEY' => substr($row['key_id'], 0, 8), - 'IP' => $row['last_ip'], - 'LOGIN_TIME' => $user->format_date($row['last_login']), - )); - } - - $db->sql_freeresult($result); - - break; - } - - $template->assign_vars(array( - 'ERROR' => (count($error)) ? implode('
', $error) : '', - - 'L_TITLE' => $user->lang['UCP_PROFILE_' . strtoupper($mode)], - - 'S_HIDDEN_FIELDS' => $s_hidden_fields, - 'S_UCP_ACTION' => $this->u_action) - ); - - // Set desired template - $this->tpl_name = 'ucp_profile_' . $mode; - $this->page_title = 'UCP_PROFILE_' . strtoupper($mode); - } -} diff --git a/install/update/old/includes/ucp/ucp_register.php b/install/update/old/includes/ucp/ucp_register.php deleted file mode 100644 index 0e673cb..0000000 --- a/install/update/old/includes/ucp/ucp_register.php +++ /dev/null @@ -1,709 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* ucp_register -* Board registration -*/ -class ucp_register -{ - var $u_action; - - function main($id, $mode) - { - global $config, $db, $user, $template, $phpbb_root_path, $phpEx; - global $request, $phpbb_container, $phpbb_dispatcher; - - // - if ($config['require_activation'] == USER_ACTIVATION_DISABLE || - (in_array($config['require_activation'], array(USER_ACTIVATION_SELF, USER_ACTIVATION_ADMIN)) && !$config['email_enable'])) - { - trigger_error('UCP_REGISTER_DISABLE'); - } - - $coppa = $request->is_set('coppa') ? (int) $request->variable('coppa', false) : false; - $agreed = $request->variable('agreed', false); - $submit = $request->is_set_post('submit'); - $change_lang = $request->variable('change_lang', ''); - $user_lang = $request->variable('lang', $user->lang_name); - - /** - * Add UCP register data before they are assigned to the template or submitted - * - * To assign data to the template, use $template->assign_vars() - * - * @event core.ucp_register_requests_after - * @var bool coppa Is set coppa - * @var bool agreed Did user agree to coppa? - * @var bool submit Is set post submit? - * @var string change_lang Change language request - * @var string user_lang User language request - * @since 3.1.11-RC1 - */ - $vars = array( - 'coppa', - 'agreed', - 'submit', - 'change_lang', - 'user_lang', - ); - extract($phpbb_dispatcher->trigger_event('core.ucp_register_requests_after', compact($vars))); - - if ($agreed) - { - add_form_key('ucp_register'); - } - else - { - add_form_key('ucp_register_terms'); - } - - if ($change_lang || $user_lang != $config['default_lang']) - { - $use_lang = ($change_lang) ? basename($change_lang) : basename($user_lang); - - if (!validate_language_iso_name($use_lang)) - { - if ($change_lang) - { - $submit = false; - - // Setting back agreed to let the user view the agreement in his/her language - $agreed = false; - } - - $user_lang = $use_lang; - } - else - { - $change_lang = ''; - $user_lang = $user->lang_name; - } - } - - /* @var $cp \phpbb\profilefields\manager */ - $cp = $phpbb_container->get('profilefields.manager'); - - $error = $cp_data = $cp_error = array(); - $s_hidden_fields = array(); - - // Handle login_link data added to $_hidden_fields - $login_link_data = $this->get_login_link_data_array(); - - if (!empty($login_link_data)) - { - // Confirm that we have all necessary data - /* @var $provider_collection \phpbb\auth\provider_collection */ - $provider_collection = $phpbb_container->get('auth.provider_collection'); - $auth_provider = $provider_collection->get_provider($request->variable('auth_provider', '')); - - $result = $auth_provider->login_link_has_necessary_data($login_link_data); - if ($result !== null) - { - $error[] = $user->lang[$result]; - } - - $s_hidden_fields = array_merge($s_hidden_fields, $this->get_login_link_data_for_hidden_fields($login_link_data)); - } - - if (!$agreed || ($coppa === false && $config['coppa_enable']) || ($coppa && !$config['coppa_enable'])) - { - $add_coppa = ($coppa !== false) ? '&coppa=' . $coppa : ''; - - $s_hidden_fields = array_merge($s_hidden_fields, array( - 'change_lang' => '', - )); - - // If we change the language, we want to pass on some more possible parameter. - if ($change_lang) - { - // We do not include the password - $s_hidden_fields = array_merge($s_hidden_fields, array( - 'username' => $request->variable('username', '', true), - 'email' => strtolower($request->variable('email', '')), - 'lang' => $user->lang_name, - 'tz' => $request->variable('tz', $config['board_timezone']), - )); - - } - - // Checking amount of available languages - $sql = 'SELECT lang_id - FROM ' . LANG_TABLE; - $result = $db->sql_query($sql); - - $lang_row = array(); - while ($row = $db->sql_fetchrow($result)) - { - $lang_row[] = $row; - } - $db->sql_freeresult($result); - - if ($coppa === false && $config['coppa_enable']) - { - $now = getdate(); - $coppa_birthday = $user->create_datetime() - ->setDate($now['year'] - 13, $now['mon'], $now['mday'] - 1) - ->setTime(0, 0, 0) - ->format($user->lang['DATE_FORMAT'], true); - unset($now); - - $template_vars = array( - 'S_LANG_OPTIONS' => (count($lang_row) > 1) ? language_select($user_lang) : '', - 'L_COPPA_NO' => sprintf($user->lang['UCP_COPPA_BEFORE'], $coppa_birthday), - 'L_COPPA_YES' => sprintf($user->lang['UCP_COPPA_ON_AFTER'], $coppa_birthday), - - 'U_COPPA_NO' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register&coppa=0'), - 'U_COPPA_YES' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register&coppa=1'), - - 'S_SHOW_COPPA' => true, - 'S_HIDDEN_FIELDS' => build_hidden_fields($s_hidden_fields), - 'S_UCP_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register'), - - 'COOKIE_NAME' => $config['cookie_name'], - 'COOKIE_PATH' => $config['cookie_path'], - ); - } - else - { - $template_vars = array( - 'S_LANG_OPTIONS' => (count($lang_row) > 1) ? language_select($user_lang) : '', - 'L_TERMS_OF_USE' => sprintf($user->lang['TERMS_OF_USE_CONTENT'], $config['sitename'], generate_board_url()), - - 'S_SHOW_COPPA' => false, - 'S_REGISTRATION' => true, - 'S_HIDDEN_FIELDS' => build_hidden_fields($s_hidden_fields), - 'S_UCP_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register' . $add_coppa), - - 'COOKIE_NAME' => $config['cookie_name'], - 'COOKIE_PATH' => $config['cookie_path'], - ); - } - - $tpl_name = 'ucp_agreement'; - - /** - * Allows to modify the agreements. - * - * @event core.ucp_register_agreement_modify_template_data - * @var string tpl_name Template file - * @var array template_vars Array with data about to be assigned to the template - * @var array s_hidden_fields Array with hidden form elements - * @var array lang_row Array with available languages, read only - * @since 3.2.2-RC1 - */ - $vars = array('tpl_name', 'template_vars', 's_hidden_fields', 'lang_row'); - extract($phpbb_dispatcher->trigger_event('core.ucp_register_agreement_modify_template_data', compact($vars))); - - unset($lang_row); - - $template_vars = array_merge($template_vars, array( - 'S_HIDDEN_FIELDS' => build_hidden_fields($s_hidden_fields), - )); - - $template->assign_vars($template_vars); - - /** - * Allows to modify the agreements. - * - * To assign data to the template, use $template->assign_vars() - * - * @event core.ucp_register_agreement - * @since 3.1.6-RC1 - * @deprecated 3.2.2-RC1 Replaced by core.ucp_register_agreement_modify_template_data and to be removed in 3.3.0-RC1 - */ - $phpbb_dispatcher->dispatch('core.ucp_register_agreement'); - - $this->tpl_name = $tpl_name; - return; - } - - // The CAPTCHA kicks in here. We can't help that the information gets lost on language change. - if ($config['enable_confirm']) - { - $captcha = $phpbb_container->get('captcha.factory')->get_instance($config['captcha_plugin']); - $captcha->init(CONFIRM_REG); - } - - $timezone = $config['board_timezone']; - - $data = array( - 'username' => $request->variable('username', '', true), - 'new_password' => $request->variable('new_password', '', true), - 'password_confirm' => $request->variable('password_confirm', '', true), - 'email' => strtolower($request->variable('email', '')), - 'lang' => basename($request->variable('lang', $user->lang_name)), - 'tz' => $request->variable('tz', $timezone), - ); - /** - * Add UCP register data before they are assigned to the template or submitted - * - * To assign data to the template, use $template->assign_vars() - * - * @event core.ucp_register_data_before - * @var bool submit Do we display the form only - * or did the user press submit - * @var array data Array with current ucp registration data - * @since 3.1.4-RC1 - */ - $vars = array('submit', 'data'); - extract($phpbb_dispatcher->trigger_event('core.ucp_register_data_before', compact($vars))); - - // Check and initialize some variables if needed - if ($submit) - { - $error = validate_data($data, array( - 'username' => array( - array('string', false, $config['min_name_chars'], $config['max_name_chars']), - array('username', '')), - 'new_password' => array( - array('string', false, $config['min_pass_chars'], $config['max_pass_chars']), - array('password')), - 'password_confirm' => array('string', false, $config['min_pass_chars'], $config['max_pass_chars']), - 'email' => array( - array('string', false, 6, 60), - array('user_email')), - 'tz' => array('timezone'), - 'lang' => array('language_iso_name'), - )); - - if (!check_form_key('ucp_register')) - { - $error[] = $user->lang['FORM_INVALID']; - } - - // Replace "error" strings with their real, localised form - $error = array_map(array($user, 'lang'), $error); - - if ($config['enable_confirm']) - { - $vc_response = $captcha->validate($data); - if ($vc_response !== false) - { - $error[] = $vc_response; - } - - if ($config['max_reg_attempts'] && $captcha->get_attempt_count() > $config['max_reg_attempts']) - { - $error[] = $user->lang['TOO_MANY_REGISTERS']; - } - } - - // DNSBL check - if ($config['check_dnsbl']) - { - if (($dnsbl = $user->check_dnsbl('register')) !== false) - { - $error[] = sprintf($user->lang['IP_BLACKLISTED'], $user->ip, $dnsbl[1]); - } - } - - // validate custom profile fields - $cp->submit_cp_field('register', $user->get_iso_lang_id(), $cp_data, $error); - - if (!count($error)) - { - if ($data['new_password'] != $data['password_confirm']) - { - $error[] = $user->lang['NEW_PASSWORD_ERROR']; - } - } - /** - * Check UCP registration data after they are submitted - * - * @event core.ucp_register_data_after - * @var bool submit Do we display the form only - * or did the user press submit - * @var array data Array with current ucp registration data - * @var array cp_data Array with custom profile fields data - * @var array error Array with list of errors - * @since 3.1.4-RC1 - */ - $vars = array('submit', 'data', 'cp_data', 'error'); - extract($phpbb_dispatcher->trigger_event('core.ucp_register_data_after', compact($vars))); - - if (!count($error)) - { - $server_url = generate_board_url(); - - // Which group by default? - $group_name = ($coppa) ? 'REGISTERED_COPPA' : 'REGISTERED'; - - $sql = 'SELECT group_id - FROM ' . GROUPS_TABLE . " - WHERE group_name = '" . $db->sql_escape($group_name) . "' - AND group_type = " . GROUP_SPECIAL; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - trigger_error('NO_GROUP'); - } - - $group_id = $row['group_id']; - - if (($coppa || - $config['require_activation'] == USER_ACTIVATION_SELF || - $config['require_activation'] == USER_ACTIVATION_ADMIN) && $config['email_enable']) - { - $user_actkey = gen_rand_string(mt_rand(6, 10)); - $user_type = USER_INACTIVE; - $user_inactive_reason = INACTIVE_REGISTER; - $user_inactive_time = time(); - } - else - { - $user_type = USER_NORMAL; - $user_actkey = ''; - $user_inactive_reason = 0; - $user_inactive_time = 0; - } - - // Instantiate passwords manager - /* @var $passwords_manager \phpbb\passwords\manager */ - $passwords_manager = $phpbb_container->get('passwords.manager'); - - $user_row = array( - 'username' => $data['username'], - 'user_password' => $passwords_manager->hash($data['new_password']), - 'user_email' => $data['email'], - 'group_id' => (int) $group_id, - 'user_timezone' => $data['tz'], - 'user_lang' => $data['lang'], - 'user_type' => $user_type, - 'user_actkey' => $user_actkey, - 'user_ip' => $user->ip, - 'user_regdate' => time(), - 'user_inactive_reason' => $user_inactive_reason, - 'user_inactive_time' => $user_inactive_time, - ); - - if ($config['new_member_post_limit']) - { - $user_row['user_new'] = 1; - } - /** - * Add into $user_row before user_add - * - * user_add allows adding more data into the users table - * - * @event core.ucp_register_user_row_after - * @var bool submit Do we display the form only - * or did the user press submit - * @var array cp_data Array with custom profile fields data - * @var array user_row Array with current ucp registration data - * @since 3.1.4-RC1 - */ - $vars = array('submit', 'cp_data', 'user_row'); - extract($phpbb_dispatcher->trigger_event('core.ucp_register_user_row_after', compact($vars))); - - // Register user... - $user_id = user_add($user_row, $cp_data); - - // This should not happen, because the required variables are listed above... - if ($user_id === false) - { - trigger_error('NO_USER', E_USER_ERROR); - } - - // Okay, captcha, your job is done. - if ($config['enable_confirm'] && isset($captcha)) - { - $captcha->reset(); - } - - if ($coppa && $config['email_enable']) - { - $message = $user->lang['ACCOUNT_COPPA']; - $email_template = 'coppa_welcome_inactive'; - } - else if ($config['require_activation'] == USER_ACTIVATION_SELF && $config['email_enable']) - { - $message = $user->lang['ACCOUNT_INACTIVE']; - $email_template = 'user_welcome_inactive'; - } - else if ($config['require_activation'] == USER_ACTIVATION_ADMIN && $config['email_enable']) - { - $message = $user->lang['ACCOUNT_INACTIVE_ADMIN']; - $email_template = 'admin_welcome_inactive'; - } - else - { - $message = $user->lang['ACCOUNT_ADDED']; - $email_template = 'user_welcome'; - } - - if ($config['email_enable']) - { - include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); - - $messenger = new messenger(false); - - $messenger->template($email_template, $data['lang']); - - $messenger->to($data['email'], $data['username']); - - $messenger->anti_abuse_headers($config, $user); - - $messenger->assign_vars(array( - 'WELCOME_MSG' => htmlspecialchars_decode(sprintf($user->lang['WELCOME_SUBJECT'], $config['sitename'])), - 'USERNAME' => htmlspecialchars_decode($data['username']), - 'PASSWORD' => htmlspecialchars_decode($data['new_password']), - 'U_ACTIVATE' => "$server_url/ucp.$phpEx?mode=activate&u=$user_id&k=$user_actkey") - ); - - if ($coppa) - { - $messenger->assign_vars(array( - 'FAX_INFO' => $config['coppa_fax'], - 'MAIL_INFO' => $config['coppa_mail'], - 'EMAIL_ADDRESS' => $data['email']) - ); - } - - /** - * Modify messenger data before welcome mail is sent - * - * @event core.ucp_register_welcome_email_before - * @var array user_row Array with user registration data - * @var array cp_data Array with custom profile fields data - * @var array data Array with current ucp registration data - * @var string message Message to be displayed to the user after registration - * @var string server_url Server URL - * @var int user_id New user ID - * @var string user_actkey User activation key - * @var messenger messenger phpBB Messenger - * @since 3.2.4-RC1 - */ - $vars = array( - 'user_row', - 'cp_data', - 'data', - 'message', - 'server_url', - 'user_id', - 'user_actkey', - 'messenger', - ); - extract($phpbb_dispatcher->trigger_event('core.ucp_register_welcome_email_before', compact($vars))); - - $messenger->send(NOTIFY_EMAIL); - } - - if ($config['require_activation'] == USER_ACTIVATION_ADMIN) - { - /* @var $phpbb_notifications \phpbb\notification\manager */ - $phpbb_notifications = $phpbb_container->get('notification_manager'); - $phpbb_notifications->add_notifications('notification.type.admin_activate_user', array( - 'user_id' => $user_id, - 'user_actkey' => $user_row['user_actkey'], - 'user_regdate' => $user_row['user_regdate'], - )); - } - - // Perform account linking if necessary - if (!empty($login_link_data)) - { - $login_link_data['user_id'] = $user_id; - - $result = $auth_provider->link_account($login_link_data); - - if ($result) - { - $message = $message . '

' . $user->lang[$result]; - } - } - - /** - * Perform additional actions after user registration - * - * @event core.ucp_register_register_after - * @var array user_row Array with user registration data - * @var array cp_data Array with custom profile fields data - * @var array data Array with current ucp registration data - * @var string message Message to be displayed to the user after registration - * @var string server_url Server URL - * @var int user_id New user ID - * @var string user_actkey User activation key - * @since 3.2.4-RC1 - */ - $vars = array( - 'user_row', - 'cp_data', - 'data', - 'message', - 'server_url', - 'user_id', - 'user_actkey', - ); - extract($phpbb_dispatcher->trigger_event('core.ucp_register_register_after', compact($vars))); - - $message = $message . '

' . sprintf($user->lang['RETURN_INDEX'], '', ''); - trigger_error($message); - } - } - - $s_hidden_fields = array_merge($s_hidden_fields, array( - 'agreed' => 'true', - 'change_lang' => 0, - )); - - if ($config['coppa_enable']) - { - $s_hidden_fields['coppa'] = $coppa; - } - - if ($config['enable_confirm']) - { - $s_hidden_fields = array_merge($s_hidden_fields, $captcha->get_hidden_fields()); - } - - // Visual Confirmation - Show images - if ($config['enable_confirm']) - { - $template->assign_vars(array( - 'CAPTCHA_TEMPLATE' => $captcha->get_template(), - )); - } - - // - $l_reg_cond = ''; - switch ($config['require_activation']) - { - case USER_ACTIVATION_SELF: - $l_reg_cond = $user->lang['UCP_EMAIL_ACTIVATE']; - break; - - case USER_ACTIVATION_ADMIN: - $l_reg_cond = $user->lang['UCP_ADMIN_ACTIVATE']; - break; - } - - // Assign template vars for timezone select - phpbb_timezone_select($template, $user, $data['tz'], true); - - $template_vars = array( - 'USERNAME' => $data['username'], - 'PASSWORD' => $data['new_password'], - 'PASSWORD_CONFIRM' => $data['password_confirm'], - 'EMAIL' => $data['email'], - - 'L_REG_COND' => $l_reg_cond, - 'L_USERNAME_EXPLAIN' => $user->lang($config['allow_name_chars'] . '_EXPLAIN', $user->lang('CHARACTERS', (int) $config['min_name_chars']), $user->lang('CHARACTERS', (int) $config['max_name_chars'])), - 'L_PASSWORD_EXPLAIN' => $user->lang($config['pass_complex'] . '_EXPLAIN', $user->lang('CHARACTERS', (int) $config['min_pass_chars']), $user->lang('CHARACTERS', (int) $config['max_pass_chars'])), - - 'S_LANG_OPTIONS' => language_select($data['lang']), - 'S_TZ_PRESELECT' => !$submit, - 'S_CONFIRM_REFRESH' => ($config['enable_confirm'] && $config['confirm_refresh']) ? true : false, - 'S_REGISTRATION' => true, - 'S_COPPA' => $coppa, - 'S_UCP_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register'), - - 'COOKIE_NAME' => $config['cookie_name'], - 'COOKIE_PATH' => $config['cookie_path'], - ); - - $tpl_name = 'ucp_register'; - - /** - * Modify template data on the registration page - * - * @event core.ucp_register_modify_template_data - * @var array template_vars Array with template data - * @var array data Array with user data, read only - * @var array error Array with errors - * @var array s_hidden_fields Array with hidden field elements - * @var string tpl_name Template name - * @since 3.2.2-RC1 - */ - $vars = array( - 'template_vars', - 'data', - 'error', - 's_hidden_fields', - 'tpl_name', - ); - extract($phpbb_dispatcher->trigger_event('core.ucp_register_modify_template_data', compact($vars))); - - $template_vars = array_merge($template_vars, array( - 'ERROR' => (count($error)) ? implode('
', $error) : '', - 'S_HIDDEN_FIELDS' => build_hidden_fields($s_hidden_fields), - )); - - $template->assign_vars($template_vars); - - // - $user->profile_fields = array(); - - // Generate profile fields -> Template Block Variable profile_fields - $cp->generate_profile_fields('register', $user->get_iso_lang_id()); - - // - $this->tpl_name = $tpl_name; - } - - /** - * Creates the login_link data array - * - * @return array Returns an array of all POST paramaters whose names - * begin with 'login_link_' - */ - protected function get_login_link_data_array() - { - global $request; - - $var_names = $request->variable_names(\phpbb\request\request_interface::POST); - $login_link_data = array(); - $string_start_length = strlen('login_link_'); - - foreach ($var_names as $var_name) - { - if (strpos($var_name, 'login_link_') === 0) - { - $key_name = substr($var_name, $string_start_length); - $login_link_data[$key_name] = $request->variable($var_name, '', false, \phpbb\request\request_interface::POST); - } - } - - return $login_link_data; - } - - /** - * Prepends they key names of an associative array with 'login_link_' for - * inclusion on the page as hidden fields. - * - * @param array $data The array to be modified - * @return array The modified array - */ - protected function get_login_link_data_for_hidden_fields($data) - { - $new_data = array(); - - foreach ($data as $key => $value) - { - $new_data['login_link_' . $key] = $value; - } - - return $new_data; - } -} diff --git a/install/update/old/includes/ucp/ucp_resend.php b/install/update/old/includes/ucp/ucp_resend.php deleted file mode 100644 index 44c5410..0000000 --- a/install/update/old/includes/ucp/ucp_resend.php +++ /dev/null @@ -1,163 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* ucp_resend -* Resending activation emails -*/ -class ucp_resend -{ - var $u_action; - - function main($id, $mode) - { - global $config, $phpbb_root_path, $phpEx; - global $db, $user, $auth, $template, $request; - - $username = $request->variable('username', '', true); - $email = strtolower($request->variable('email', '')); - $submit = (isset($_POST['submit'])) ? true : false; - - add_form_key('ucp_resend'); - - if ($submit) - { - if (!check_form_key('ucp_resend')) - { - trigger_error('FORM_INVALID'); - } - - $sql = 'SELECT user_id, group_id, username, user_email, user_type, user_lang, user_actkey, user_inactive_reason - FROM ' . USERS_TABLE . " - WHERE user_email_hash = '" . $db->sql_escape(phpbb_email_hash($email)) . "' - AND username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'"; - $result = $db->sql_query($sql); - $user_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$user_row) - { - trigger_error('NO_EMAIL_USER'); - } - - if ($user_row['user_type'] == USER_IGNORE) - { - trigger_error('NO_USER'); - } - - if (!$user_row['user_actkey'] && $user_row['user_type'] != USER_INACTIVE) - { - trigger_error('ACCOUNT_ALREADY_ACTIVATED'); - } - - if (!$user_row['user_actkey'] || ($user_row['user_type'] == USER_INACTIVE && $user_row['user_inactive_reason'] == INACTIVE_MANUAL)) - { - trigger_error('ACCOUNT_DEACTIVATED'); - } - - // Determine coppa status on group (REGISTERED(_COPPA)) - $sql = 'SELECT group_name, group_type - FROM ' . GROUPS_TABLE . ' - WHERE group_id = ' . $user_row['group_id']; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - trigger_error('NO_GROUP'); - } - - $coppa = ($row['group_name'] == 'REGISTERED_COPPA' && $row['group_type'] == GROUP_SPECIAL) ? true : false; - - include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); - $messenger = new messenger(false); - - if ($config['require_activation'] == USER_ACTIVATION_SELF || $coppa) - { - $messenger->template(($coppa) ? 'coppa_resend_inactive' : 'user_resend_inactive', $user_row['user_lang']); - $messenger->set_addresses($user_row); - - $messenger->anti_abuse_headers($config, $user); - - $messenger->assign_vars(array( - 'WELCOME_MSG' => htmlspecialchars_decode(sprintf($user->lang['WELCOME_SUBJECT'], $config['sitename'])), - 'USERNAME' => htmlspecialchars_decode($user_row['username']), - 'U_ACTIVATE' => generate_board_url() . "/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k={$user_row['user_actkey']}") - ); - - if ($coppa) - { - $messenger->assign_vars(array( - 'FAX_INFO' => $config['coppa_fax'], - 'MAIL_INFO' => $config['coppa_mail'], - 'EMAIL_ADDRESS' => $user_row['user_email']) - ); - } - - $messenger->send(NOTIFY_EMAIL); - } - - if ($config['require_activation'] == USER_ACTIVATION_ADMIN) - { - // Grab an array of user_id's with a_user permissions ... these users can activate a user - $admin_ary = $auth->acl_get_list(false, 'a_user', false); - - $sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('user_id', $admin_ary[0]['a_user']); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $messenger->template('admin_activate', $row['user_lang']); - $messenger->set_addresses($row); - - $messenger->anti_abuse_headers($config, $user); - - $messenger->assign_vars(array( - 'USERNAME' => htmlspecialchars_decode($user_row['username']), - 'U_USER_DETAILS' => generate_board_url() . "/memberlist.$phpEx?mode=viewprofile&u={$user_row['user_id']}", - 'U_ACTIVATE' => generate_board_url() . "/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k={$user_row['user_actkey']}") - ); - - $messenger->send($row['user_notify_type']); - } - $db->sql_freeresult($result); - } - - meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx")); - - $message = ($config['require_activation'] == USER_ACTIVATION_ADMIN) ? $user->lang['ACTIVATION_EMAIL_SENT_ADMIN'] : $user->lang['ACTIVATION_EMAIL_SENT']; - $message .= '

' . sprintf($user->lang['RETURN_INDEX'], '', ''); - trigger_error($message); - } - - $template->assign_vars(array( - 'USERNAME' => $username, - 'EMAIL' => $email, - 'S_PROFILE_ACTION' => append_sid($phpbb_root_path . 'ucp.' . $phpEx, 'mode=resend_act')) - ); - - $this->tpl_name = 'ucp_resend'; - $this->page_title = 'UCP_RESEND'; - } -} diff --git a/install/update/old/includes/utf/utf_tools.php b/install/update/old/includes/utf/utf_tools.php deleted file mode 100644 index 89de454..0000000 --- a/install/update/old/includes/utf/utf_tools.php +++ /dev/null @@ -1,1450 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -// Enforce ASCII only string handling -setlocale(LC_CTYPE, 'C'); - -/** -* Setup the UTF-8 portability layer -*/ -Patchwork\Utf8\Bootup::initUtf8Encode(); -Patchwork\Utf8\Bootup::initMbstring(); -Patchwork\Utf8\Bootup::initIntl(); - -/** -* UTF-8 tools -* -* Whenever possible, these functions will try to use PHP's built-in functions or -* extensions, otherwise they will default to custom routines. -* -*/ - -/** -* UTF-8 aware alternative to strrpos -* @ignore -*/ -function utf8_strrpos($str, $needle, $offset = null) -{ - // Emulate behaviour of strrpos rather than raising warning - if (empty($str)) - { - return false; - } - - if (is_null($offset)) - { - return mb_strrpos($str, $needle); - } - else - { - return mb_strrpos($str, $needle, $offset); - } -} - -/** -* UTF-8 aware alternative to strpos -* @ignore -*/ -function utf8_strpos($str, $needle, $offset = null) -{ - if (is_null($offset)) - { - return mb_strpos($str, $needle); - } - else - { - return mb_strpos($str, $needle, $offset); - } -} - -/** -* UTF-8 aware alternative to strtolower -* @ignore -*/ -function utf8_strtolower($str) -{ - return mb_strtolower($str); -} - -/** -* UTF-8 aware alternative to strtoupper -* @ignore -*/ -function utf8_strtoupper($str) -{ - return mb_strtoupper($str); -} - -/** -* UTF-8 aware alternative to substr -* @ignore -*/ -function utf8_substr($str, $offset, $length = null) -{ - if (is_null($length)) - { - return mb_substr($str, $offset); - } - else - { - return mb_substr($str, $offset, $length); - } -} - -/** -* Return the length (in characters) of a UTF-8 string -* @ignore -*/ -function utf8_strlen($text) -{ - return mb_strlen($text, 'utf-8'); -} - -/** -* UTF-8 aware alternative to str_split -* Convert a string to an array -* -* @author Harry Fuecks -* @param string $str UTF-8 encoded -* @param int $split_len number to characters to split string by -* @return array characters in string reverses -*/ -function utf8_str_split($str, $split_len = 1) -{ - if (!is_int($split_len) || $split_len < 1) - { - return false; - } - - $len = utf8_strlen($str); - if ($len <= $split_len) - { - return array($str); - } - - preg_match_all('/.{' . $split_len . '}|[^\x00]{1,' . $split_len . '}$/us', $str, $ar); - return $ar[0]; -} - -/** -* UTF-8 aware alternative to strspn -* Find length of initial segment matching the mask -* -* @author Harry Fuecks -*/ -function utf8_strspn($str, $mask, $start = null, $length = null) -{ - if ($start !== null || $length !== null) - { - $str = utf8_substr($str, $start, $length); - } - - preg_match('/^[' . $mask . ']+/u', $str, $matches); - - if (isset($matches[0])) - { - return utf8_strlen($matches[0]); - } - - return 0; -} - -/** -* UTF-8 aware alternative to ucfirst -* Make a string's first character uppercase -* -* @author Harry Fuecks -* @param string -* @return string with first character as upper case (if applicable) -*/ -function utf8_ucfirst($str) -{ - switch (utf8_strlen($str)) - { - case 0: - return ''; - break; - - case 1: - return utf8_strtoupper($str); - break; - - default: - preg_match('/^(.{1})(.*)$/us', $str, $matches); - return utf8_strtoupper($matches[1]) . $matches[2]; - break; - } -} - -/** -* Recode a string to UTF-8 -* -* If the encoding is not supported, the string is returned as-is -* -* @param string $string Original string -* @param string $encoding Original encoding (lowered) -* @return string The string, encoded in UTF-8 -*/ -function utf8_recode($string, $encoding) -{ - $encoding = strtolower($encoding); - - if ($encoding == 'utf-8' || !is_string($string) || empty($string)) - { - return $string; - } - - // we force iso-8859-1 to be cp1252 - if ($encoding == 'iso-8859-1') - { - $encoding = 'cp1252'; - } - // convert iso-8859-8-i to iso-8859-8 - else if ($encoding == 'iso-8859-8-i') - { - $encoding = 'iso-8859-8'; - $string = hebrev($string); - } - - // First, try iconv() - if (function_exists('iconv')) - { - $ret = @iconv($encoding, 'utf-8', $string); - - if (!empty($ret)) - { - return $ret; - } - } - - // Try the mb_string extension - if (function_exists('mb_convert_encoding')) - { - // mbstring is nasty on PHP4, we must make *sure* that we send a good encoding - switch ($encoding) - { - case 'iso-8859-1': - case 'iso-8859-2': - case 'iso-8859-4': - case 'iso-8859-7': - case 'iso-8859-9': - case 'iso-8859-15': - case 'windows-1251': - case 'windows-1252': - case 'cp1252': - case 'shift_jis': - case 'euc-kr': - case 'big5': - case 'gb2312': - $ret = @mb_convert_encoding($string, 'utf-8', $encoding); - - if (!empty($ret)) - { - return $ret; - } - } - } - - // Try the recode extension - if (function_exists('recode_string')) - { - $ret = @recode_string($encoding . '..utf-8', $string); - - if (!empty($ret)) - { - return $ret; - } - } - - // If nothing works, check if we have a custom transcoder available - if (!preg_match('#^[a-z0-9_ \\-]+$#', $encoding)) - { - // Make sure the encoding name is alphanumeric, we don't want it to be abused into loading arbitrary files - trigger_error('Unknown encoding: ' . $encoding, E_USER_ERROR); - } - - global $phpbb_root_path, $phpEx; - - // iso-8859-* character encoding - if (preg_match('/iso[_ -]?8859[_ -]?(\\d+)/', $encoding, $array)) - { - switch ($array[1]) - { - case '1': - case '2': - case '4': - case '7': - case '8': - case '9': - case '15': - if (!function_exists('iso_8859_' . $array[1])) - { - if (!file_exists($phpbb_root_path . 'includes/utf/data/recode_basic.' . $phpEx)) - { - trigger_error('Basic reencoder file is missing', E_USER_ERROR); - } - include($phpbb_root_path . 'includes/utf/data/recode_basic.' . $phpEx); - } - return call_user_func('iso_8859_' . $array[1], $string); - break; - - default: - trigger_error('Unknown encoding: ' . $encoding, E_USER_ERROR); - break; - } - } - - // CP/WIN character encoding - if (preg_match('/(?:cp|windows)[_\- ]?(\\d+)/', $encoding, $array)) - { - switch ($array[1]) - { - case '932': - break; - case '1250': - case '1251': - case '1252': - case '1254': - case '1255': - case '1256': - case '1257': - case '874': - if (!function_exists('cp' . $array[1])) - { - if (!file_exists($phpbb_root_path . 'includes/utf/data/recode_basic.' . $phpEx)) - { - trigger_error('Basic reencoder file is missing', E_USER_ERROR); - } - include($phpbb_root_path . 'includes/utf/data/recode_basic.' . $phpEx); - } - return call_user_func('cp' . $array[1], $string); - break; - - default: - trigger_error('Unknown encoding: ' . $encoding, E_USER_ERROR); - break; - } - } - - // TIS-620 - if (preg_match('/tis[_ -]?620/', $encoding)) - { - if (!function_exists('tis_620')) - { - if (!file_exists($phpbb_root_path . 'includes/utf/data/recode_basic.' . $phpEx)) - { - trigger_error('Basic reencoder file is missing', E_USER_ERROR); - } - include($phpbb_root_path . 'includes/utf/data/recode_basic.' . $phpEx); - } - return tis_620($string); - } - - // SJIS - if (preg_match('/sjis(?:[_ -]?win)?|(?:cp|ibm)[_ -]?932|shift[_ -]?jis/', $encoding)) - { - if (!function_exists('sjis')) - { - if (!file_exists($phpbb_root_path . 'includes/utf/data/recode_cjk.' . $phpEx)) - { - trigger_error('CJK reencoder file is missing', E_USER_ERROR); - } - include($phpbb_root_path . 'includes/utf/data/recode_cjk.' . $phpEx); - } - return sjis($string); - } - - // EUC_KR - if (preg_match('/euc[_ -]?kr/', $encoding)) - { - if (!function_exists('euc_kr')) - { - if (!file_exists($phpbb_root_path . 'includes/utf/data/recode_cjk.' . $phpEx)) - { - trigger_error('CJK reencoder file is missing', E_USER_ERROR); - } - include($phpbb_root_path . 'includes/utf/data/recode_cjk.' . $phpEx); - } - return euc_kr($string); - } - - // BIG-5 - if (preg_match('/big[_ -]?5/', $encoding)) - { - if (!function_exists('big5')) - { - if (!file_exists($phpbb_root_path . 'includes/utf/data/recode_cjk.' . $phpEx)) - { - trigger_error('CJK reencoder file is missing', E_USER_ERROR); - } - include($phpbb_root_path . 'includes/utf/data/recode_cjk.' . $phpEx); - } - return big5($string); - } - - // GB2312 - if (preg_match('/gb[_ -]?2312/', $encoding)) - { - if (!function_exists('gb2312')) - { - if (!file_exists($phpbb_root_path . 'includes/utf/data/recode_cjk.' . $phpEx)) - { - trigger_error('CJK reencoder file is missing', E_USER_ERROR); - } - include($phpbb_root_path . 'includes/utf/data/recode_cjk.' . $phpEx); - } - return gb2312($string); - } - - // Trigger an error?! Fow now just give bad data :-( - trigger_error('Unknown encoding: ' . $encoding, E_USER_ERROR); -} - -/** -* Replace all UTF-8 chars that are not in ASCII with their NCR -* -* @param string $text UTF-8 string in NFC -* @return string ASCII string using NCRs for non-ASCII chars -*/ -function utf8_encode_ncr($text) -{ - return preg_replace_callback('#[\\xC2-\\xF4][\\x80-\\xBF]{1,3}#', 'utf8_encode_ncr_callback', $text); -} - -/** -* Callback used in encode_ncr() -* -* Takes a UTF-8 char and replaces it with its NCR. Attention, $m is an array -* -* @param array $m 0-based numerically indexed array passed by preg_replace_callback() -* @return string A HTML NCR if the character is valid, or the original string otherwise -*/ -function utf8_encode_ncr_callback($m) -{ - return '&#' . utf8_ord($m[0]) . ';'; -} - -/** -* Converts a UTF-8 char to an NCR -* -* @param string $chr UTF-8 char -* @return integer UNICODE code point -*/ -function utf8_ord($chr) -{ - switch (strlen($chr)) - { - case 1: - return ord($chr); - break; - - case 2: - return ((ord($chr[0]) & 0x1F) << 6) | (ord($chr[1]) & 0x3F); - break; - - case 3: - return ((ord($chr[0]) & 0x0F) << 12) | ((ord($chr[1]) & 0x3F) << 6) | (ord($chr[2]) & 0x3F); - break; - - case 4: - return ((ord($chr[0]) & 0x07) << 18) | ((ord($chr[1]) & 0x3F) << 12) | ((ord($chr[2]) & 0x3F) << 6) | (ord($chr[3]) & 0x3F); - break; - - default: - return $chr; - } -} - -/** -* Converts an NCR to a UTF-8 char -* -* @param int $cp UNICODE code point -* @return string UTF-8 char -*/ -function utf8_chr($cp) -{ - if ($cp > 0xFFFF) - { - return chr(0xF0 | ($cp >> 18)) . chr(0x80 | (($cp >> 12) & 0x3F)) . chr(0x80 | (($cp >> 6) & 0x3F)) . chr(0x80 | ($cp & 0x3F)); - } - else if ($cp > 0x7FF) - { - return chr(0xE0 | ($cp >> 12)) . chr(0x80 | (($cp >> 6) & 0x3F)) . chr(0x80 | ($cp & 0x3F)); - } - else if ($cp > 0x7F) - { - return chr(0xC0 | ($cp >> 6)) . chr(0x80 | ($cp & 0x3F)); - } - else - { - return chr($cp); - } -} - -/** -* Convert Numeric Character References to UTF-8 chars -* -* Notes: -* - we do not convert NCRs recursively, if you pass &#38; it will return & -* - we DO NOT check for the existence of the Unicode characters, therefore an entity may be converted to an inexistent codepoint -* -* @param string $text String to convert, encoded in UTF-8 (no normal form required) -* @return string UTF-8 string where NCRs have been replaced with the actual chars -*/ -function utf8_decode_ncr($text) -{ - return preg_replace_callback('/&#([0-9]{1,6}|x[0-9A-F]{1,5});/i', 'utf8_decode_ncr_callback', $text); -} - -/** -* Callback used in decode_ncr() -* -* Takes a NCR (in decimal or hexadecimal) and returns a UTF-8 char. Attention, $m is an array. -* It will ignore most of invalid NCRs, but not all! -* -* @param array $m 0-based numerically indexed array passed by preg_replace_callback() -* @return string UTF-8 char -*/ -function utf8_decode_ncr_callback($m) -{ - $cp = (strncasecmp($m[1], 'x', 1)) ? $m[1] : hexdec(substr($m[1], 1)); - - return utf8_chr($cp); -} - -/** -* Case folds a unicode string as per Unicode 5.0, section 3.13 -* -* @param string $text text to be case folded -* @param string $option determines how we will fold the cases -* @return string case folded text -*/ -function utf8_case_fold($text, $option = 'full') -{ - static $uniarray = array(); - global $phpbb_root_path, $phpEx; - - // common is always set - if (!isset($uniarray['c'])) - { - $uniarray['c'] = include($phpbb_root_path . 'includes/utf/data/case_fold_c.' . $phpEx); - } - - // only set full if we need to - if ($option === 'full' && !isset($uniarray['f'])) - { - $uniarray['f'] = include($phpbb_root_path . 'includes/utf/data/case_fold_f.' . $phpEx); - } - - // only set simple if we need to - if ($option !== 'full' && !isset($uniarray['s'])) - { - $uniarray['s'] = include($phpbb_root_path . 'includes/utf/data/case_fold_s.' . $phpEx); - } - - // common is always replaced - $text = strtr($text, $uniarray['c']); - - if ($option === 'full') - { - // full replaces a character with multiple characters - $text = strtr($text, $uniarray['f']); - } - else - { - // simple replaces a character with another character - $text = strtr($text, $uniarray['s']); - } - - return $text; -} - -/** -* Takes the input and does a "special" case fold. It does minor normalization -* and returns NFKC compatable text -* -* @param string $text text to be case folded -* @param string $option determines how we will fold the cases -* @return string case folded text -*/ -function utf8_case_fold_nfkc($text, $option = 'full') -{ - static $fc_nfkc_closure = array( - "\xCD\xBA" => "\x20\xCE\xB9", - "\xCF\x92" => "\xCF\x85", - "\xCF\x93" => "\xCF\x8D", - "\xCF\x94" => "\xCF\x8B", - "\xCF\xB2" => "\xCF\x83", - "\xCF\xB9" => "\xCF\x83", - "\xE1\xB4\xAC" => "\x61", - "\xE1\xB4\xAD" => "\xC3\xA6", - "\xE1\xB4\xAE" => "\x62", - "\xE1\xB4\xB0" => "\x64", - "\xE1\xB4\xB1" => "\x65", - "\xE1\xB4\xB2" => "\xC7\x9D", - "\xE1\xB4\xB3" => "\x67", - "\xE1\xB4\xB4" => "\x68", - "\xE1\xB4\xB5" => "\x69", - "\xE1\xB4\xB6" => "\x6A", - "\xE1\xB4\xB7" => "\x6B", - "\xE1\xB4\xB8" => "\x6C", - "\xE1\xB4\xB9" => "\x6D", - "\xE1\xB4\xBA" => "\x6E", - "\xE1\xB4\xBC" => "\x6F", - "\xE1\xB4\xBD" => "\xC8\xA3", - "\xE1\xB4\xBE" => "\x70", - "\xE1\xB4\xBF" => "\x72", - "\xE1\xB5\x80" => "\x74", - "\xE1\xB5\x81" => "\x75", - "\xE1\xB5\x82" => "\x77", - "\xE2\x82\xA8" => "\x72\x73", - "\xE2\x84\x82" => "\x63", - "\xE2\x84\x83" => "\xC2\xB0\x63", - "\xE2\x84\x87" => "\xC9\x9B", - "\xE2\x84\x89" => "\xC2\xB0\x66", - "\xE2\x84\x8B" => "\x68", - "\xE2\x84\x8C" => "\x68", - "\xE2\x84\x8D" => "\x68", - "\xE2\x84\x90" => "\x69", - "\xE2\x84\x91" => "\x69", - "\xE2\x84\x92" => "\x6C", - "\xE2\x84\x95" => "\x6E", - "\xE2\x84\x96" => "\x6E\x6F", - "\xE2\x84\x99" => "\x70", - "\xE2\x84\x9A" => "\x71", - "\xE2\x84\x9B" => "\x72", - "\xE2\x84\x9C" => "\x72", - "\xE2\x84\x9D" => "\x72", - "\xE2\x84\xA0" => "\x73\x6D", - "\xE2\x84\xA1" => "\x74\x65\x6C", - "\xE2\x84\xA2" => "\x74\x6D", - "\xE2\x84\xA4" => "\x7A", - "\xE2\x84\xA8" => "\x7A", - "\xE2\x84\xAC" => "\x62", - "\xE2\x84\xAD" => "\x63", - "\xE2\x84\xB0" => "\x65", - "\xE2\x84\xB1" => "\x66", - "\xE2\x84\xB3" => "\x6D", - "\xE2\x84\xBB" => "\x66\x61\x78", - "\xE2\x84\xBE" => "\xCE\xB3", - "\xE2\x84\xBF" => "\xCF\x80", - "\xE2\x85\x85" => "\x64", - "\xE3\x89\x90" => "\x70\x74\x65", - "\xE3\x8B\x8C" => "\x68\x67", - "\xE3\x8B\x8E" => "\x65\x76", - "\xE3\x8B\x8F" => "\x6C\x74\x64", - "\xE3\x8D\xB1" => "\x68\x70\x61", - "\xE3\x8D\xB3" => "\x61\x75", - "\xE3\x8D\xB5" => "\x6F\x76", - "\xE3\x8D\xBA" => "\x69\x75", - "\xE3\x8E\x80" => "\x70\x61", - "\xE3\x8E\x81" => "\x6E\x61", - "\xE3\x8E\x82" => "\xCE\xBC\x61", - "\xE3\x8E\x83" => "\x6D\x61", - "\xE3\x8E\x84" => "\x6B\x61", - "\xE3\x8E\x85" => "\x6B\x62", - "\xE3\x8E\x86" => "\x6D\x62", - "\xE3\x8E\x87" => "\x67\x62", - "\xE3\x8E\x8A" => "\x70\x66", - "\xE3\x8E\x8B" => "\x6E\x66", - "\xE3\x8E\x8C" => "\xCE\xBC\x66", - "\xE3\x8E\x90" => "\x68\x7A", - "\xE3\x8E\x91" => "\x6B\x68\x7A", - "\xE3\x8E\x92" => "\x6D\x68\x7A", - "\xE3\x8E\x93" => "\x67\x68\x7A", - "\xE3\x8E\x94" => "\x74\x68\x7A", - "\xE3\x8E\xA9" => "\x70\x61", - "\xE3\x8E\xAA" => "\x6B\x70\x61", - "\xE3\x8E\xAB" => "\x6D\x70\x61", - "\xE3\x8E\xAC" => "\x67\x70\x61", - "\xE3\x8E\xB4" => "\x70\x76", - "\xE3\x8E\xB5" => "\x6E\x76", - "\xE3\x8E\xB6" => "\xCE\xBC\x76", - "\xE3\x8E\xB7" => "\x6D\x76", - "\xE3\x8E\xB8" => "\x6B\x76", - "\xE3\x8E\xB9" => "\x6D\x76", - "\xE3\x8E\xBA" => "\x70\x77", - "\xE3\x8E\xBB" => "\x6E\x77", - "\xE3\x8E\xBC" => "\xCE\xBC\x77", - "\xE3\x8E\xBD" => "\x6D\x77", - "\xE3\x8E\xBE" => "\x6B\x77", - "\xE3\x8E\xBF" => "\x6D\x77", - "\xE3\x8F\x80" => "\x6B\xCF\x89", - "\xE3\x8F\x81" => "\x6D\xCF\x89", - "\xE3\x8F\x83" => "\x62\x71", - "\xE3\x8F\x86" => "\x63\xE2\x88\x95\x6B\x67", - "\xE3\x8F\x87" => "\x63\x6F\x2E", - "\xE3\x8F\x88" => "\x64\x62", - "\xE3\x8F\x89" => "\x67\x79", - "\xE3\x8F\x8B" => "\x68\x70", - "\xE3\x8F\x8D" => "\x6B\x6B", - "\xE3\x8F\x8E" => "\x6B\x6D", - "\xE3\x8F\x97" => "\x70\x68", - "\xE3\x8F\x99" => "\x70\x70\x6D", - "\xE3\x8F\x9A" => "\x70\x72", - "\xE3\x8F\x9C" => "\x73\x76", - "\xE3\x8F\x9D" => "\x77\x62", - "\xE3\x8F\x9E" => "\x76\xE2\x88\x95\x6D", - "\xE3\x8F\x9F" => "\x61\xE2\x88\x95\x6D", - "\xF0\x9D\x90\x80" => "\x61", - "\xF0\x9D\x90\x81" => "\x62", - "\xF0\x9D\x90\x82" => "\x63", - "\xF0\x9D\x90\x83" => "\x64", - "\xF0\x9D\x90\x84" => "\x65", - "\xF0\x9D\x90\x85" => "\x66", - "\xF0\x9D\x90\x86" => "\x67", - "\xF0\x9D\x90\x87" => "\x68", - "\xF0\x9D\x90\x88" => "\x69", - "\xF0\x9D\x90\x89" => "\x6A", - "\xF0\x9D\x90\x8A" => "\x6B", - "\xF0\x9D\x90\x8B" => "\x6C", - "\xF0\x9D\x90\x8C" => "\x6D", - "\xF0\x9D\x90\x8D" => "\x6E", - "\xF0\x9D\x90\x8E" => "\x6F", - "\xF0\x9D\x90\x8F" => "\x70", - "\xF0\x9D\x90\x90" => "\x71", - "\xF0\x9D\x90\x91" => "\x72", - "\xF0\x9D\x90\x92" => "\x73", - "\xF0\x9D\x90\x93" => "\x74", - "\xF0\x9D\x90\x94" => "\x75", - "\xF0\x9D\x90\x95" => "\x76", - "\xF0\x9D\x90\x96" => "\x77", - "\xF0\x9D\x90\x97" => "\x78", - "\xF0\x9D\x90\x98" => "\x79", - "\xF0\x9D\x90\x99" => "\x7A", - "\xF0\x9D\x90\xB4" => "\x61", - "\xF0\x9D\x90\xB5" => "\x62", - "\xF0\x9D\x90\xB6" => "\x63", - "\xF0\x9D\x90\xB7" => "\x64", - "\xF0\x9D\x90\xB8" => "\x65", - "\xF0\x9D\x90\xB9" => "\x66", - "\xF0\x9D\x90\xBA" => "\x67", - "\xF0\x9D\x90\xBB" => "\x68", - "\xF0\x9D\x90\xBC" => "\x69", - "\xF0\x9D\x90\xBD" => "\x6A", - "\xF0\x9D\x90\xBE" => "\x6B", - "\xF0\x9D\x90\xBF" => "\x6C", - "\xF0\x9D\x91\x80" => "\x6D", - "\xF0\x9D\x91\x81" => "\x6E", - "\xF0\x9D\x91\x82" => "\x6F", - "\xF0\x9D\x91\x83" => "\x70", - "\xF0\x9D\x91\x84" => "\x71", - "\xF0\x9D\x91\x85" => "\x72", - "\xF0\x9D\x91\x86" => "\x73", - "\xF0\x9D\x91\x87" => "\x74", - "\xF0\x9D\x91\x88" => "\x75", - "\xF0\x9D\x91\x89" => "\x76", - "\xF0\x9D\x91\x8A" => "\x77", - "\xF0\x9D\x91\x8B" => "\x78", - "\xF0\x9D\x91\x8C" => "\x79", - "\xF0\x9D\x91\x8D" => "\x7A", - "\xF0\x9D\x91\xA8" => "\x61", - "\xF0\x9D\x91\xA9" => "\x62", - "\xF0\x9D\x91\xAA" => "\x63", - "\xF0\x9D\x91\xAB" => "\x64", - "\xF0\x9D\x91\xAC" => "\x65", - "\xF0\x9D\x91\xAD" => "\x66", - "\xF0\x9D\x91\xAE" => "\x67", - "\xF0\x9D\x91\xAF" => "\x68", - "\xF0\x9D\x91\xB0" => "\x69", - "\xF0\x9D\x91\xB1" => "\x6A", - "\xF0\x9D\x91\xB2" => "\x6B", - "\xF0\x9D\x91\xB3" => "\x6C", - "\xF0\x9D\x91\xB4" => "\x6D", - "\xF0\x9D\x91\xB5" => "\x6E", - "\xF0\x9D\x91\xB6" => "\x6F", - "\xF0\x9D\x91\xB7" => "\x70", - "\xF0\x9D\x91\xB8" => "\x71", - "\xF0\x9D\x91\xB9" => "\x72", - "\xF0\x9D\x91\xBA" => "\x73", - "\xF0\x9D\x91\xBB" => "\x74", - "\xF0\x9D\x91\xBC" => "\x75", - "\xF0\x9D\x91\xBD" => "\x76", - "\xF0\x9D\x91\xBE" => "\x77", - "\xF0\x9D\x91\xBF" => "\x78", - "\xF0\x9D\x92\x80" => "\x79", - "\xF0\x9D\x92\x81" => "\x7A", - "\xF0\x9D\x92\x9C" => "\x61", - "\xF0\x9D\x92\x9E" => "\x63", - "\xF0\x9D\x92\x9F" => "\x64", - "\xF0\x9D\x92\xA2" => "\x67", - "\xF0\x9D\x92\xA5" => "\x6A", - "\xF0\x9D\x92\xA6" => "\x6B", - "\xF0\x9D\x92\xA9" => "\x6E", - "\xF0\x9D\x92\xAA" => "\x6F", - "\xF0\x9D\x92\xAB" => "\x70", - "\xF0\x9D\x92\xAC" => "\x71", - "\xF0\x9D\x92\xAE" => "\x73", - "\xF0\x9D\x92\xAF" => "\x74", - "\xF0\x9D\x92\xB0" => "\x75", - "\xF0\x9D\x92\xB1" => "\x76", - "\xF0\x9D\x92\xB2" => "\x77", - "\xF0\x9D\x92\xB3" => "\x78", - "\xF0\x9D\x92\xB4" => "\x79", - "\xF0\x9D\x92\xB5" => "\x7A", - "\xF0\x9D\x93\x90" => "\x61", - "\xF0\x9D\x93\x91" => "\x62", - "\xF0\x9D\x93\x92" => "\x63", - "\xF0\x9D\x93\x93" => "\x64", - "\xF0\x9D\x93\x94" => "\x65", - "\xF0\x9D\x93\x95" => "\x66", - "\xF0\x9D\x93\x96" => "\x67", - "\xF0\x9D\x93\x97" => "\x68", - "\xF0\x9D\x93\x98" => "\x69", - "\xF0\x9D\x93\x99" => "\x6A", - "\xF0\x9D\x93\x9A" => "\x6B", - "\xF0\x9D\x93\x9B" => "\x6C", - "\xF0\x9D\x93\x9C" => "\x6D", - "\xF0\x9D\x93\x9D" => "\x6E", - "\xF0\x9D\x93\x9E" => "\x6F", - "\xF0\x9D\x93\x9F" => "\x70", - "\xF0\x9D\x93\xA0" => "\x71", - "\xF0\x9D\x93\xA1" => "\x72", - "\xF0\x9D\x93\xA2" => "\x73", - "\xF0\x9D\x93\xA3" => "\x74", - "\xF0\x9D\x93\xA4" => "\x75", - "\xF0\x9D\x93\xA5" => "\x76", - "\xF0\x9D\x93\xA6" => "\x77", - "\xF0\x9D\x93\xA7" => "\x78", - "\xF0\x9D\x93\xA8" => "\x79", - "\xF0\x9D\x93\xA9" => "\x7A", - "\xF0\x9D\x94\x84" => "\x61", - "\xF0\x9D\x94\x85" => "\x62", - "\xF0\x9D\x94\x87" => "\x64", - "\xF0\x9D\x94\x88" => "\x65", - "\xF0\x9D\x94\x89" => "\x66", - "\xF0\x9D\x94\x8A" => "\x67", - "\xF0\x9D\x94\x8D" => "\x6A", - "\xF0\x9D\x94\x8E" => "\x6B", - "\xF0\x9D\x94\x8F" => "\x6C", - "\xF0\x9D\x94\x90" => "\x6D", - "\xF0\x9D\x94\x91" => "\x6E", - "\xF0\x9D\x94\x92" => "\x6F", - "\xF0\x9D\x94\x93" => "\x70", - "\xF0\x9D\x94\x94" => "\x71", - "\xF0\x9D\x94\x96" => "\x73", - "\xF0\x9D\x94\x97" => "\x74", - "\xF0\x9D\x94\x98" => "\x75", - "\xF0\x9D\x94\x99" => "\x76", - "\xF0\x9D\x94\x9A" => "\x77", - "\xF0\x9D\x94\x9B" => "\x78", - "\xF0\x9D\x94\x9C" => "\x79", - "\xF0\x9D\x94\xB8" => "\x61", - "\xF0\x9D\x94\xB9" => "\x62", - "\xF0\x9D\x94\xBB" => "\x64", - "\xF0\x9D\x94\xBC" => "\x65", - "\xF0\x9D\x94\xBD" => "\x66", - "\xF0\x9D\x94\xBE" => "\x67", - "\xF0\x9D\x95\x80" => "\x69", - "\xF0\x9D\x95\x81" => "\x6A", - "\xF0\x9D\x95\x82" => "\x6B", - "\xF0\x9D\x95\x83" => "\x6C", - "\xF0\x9D\x95\x84" => "\x6D", - "\xF0\x9D\x95\x86" => "\x6F", - "\xF0\x9D\x95\x8A" => "\x73", - "\xF0\x9D\x95\x8B" => "\x74", - "\xF0\x9D\x95\x8C" => "\x75", - "\xF0\x9D\x95\x8D" => "\x76", - "\xF0\x9D\x95\x8E" => "\x77", - "\xF0\x9D\x95\x8F" => "\x78", - "\xF0\x9D\x95\x90" => "\x79", - "\xF0\x9D\x95\xAC" => "\x61", - "\xF0\x9D\x95\xAD" => "\x62", - "\xF0\x9D\x95\xAE" => "\x63", - "\xF0\x9D\x95\xAF" => "\x64", - "\xF0\x9D\x95\xB0" => "\x65", - "\xF0\x9D\x95\xB1" => "\x66", - "\xF0\x9D\x95\xB2" => "\x67", - "\xF0\x9D\x95\xB3" => "\x68", - "\xF0\x9D\x95\xB4" => "\x69", - "\xF0\x9D\x95\xB5" => "\x6A", - "\xF0\x9D\x95\xB6" => "\x6B", - "\xF0\x9D\x95\xB7" => "\x6C", - "\xF0\x9D\x95\xB8" => "\x6D", - "\xF0\x9D\x95\xB9" => "\x6E", - "\xF0\x9D\x95\xBA" => "\x6F", - "\xF0\x9D\x95\xBB" => "\x70", - "\xF0\x9D\x95\xBC" => "\x71", - "\xF0\x9D\x95\xBD" => "\x72", - "\xF0\x9D\x95\xBE" => "\x73", - "\xF0\x9D\x95\xBF" => "\x74", - "\xF0\x9D\x96\x80" => "\x75", - "\xF0\x9D\x96\x81" => "\x76", - "\xF0\x9D\x96\x82" => "\x77", - "\xF0\x9D\x96\x83" => "\x78", - "\xF0\x9D\x96\x84" => "\x79", - "\xF0\x9D\x96\x85" => "\x7A", - "\xF0\x9D\x96\xA0" => "\x61", - "\xF0\x9D\x96\xA1" => "\x62", - "\xF0\x9D\x96\xA2" => "\x63", - "\xF0\x9D\x96\xA3" => "\x64", - "\xF0\x9D\x96\xA4" => "\x65", - "\xF0\x9D\x96\xA5" => "\x66", - "\xF0\x9D\x96\xA6" => "\x67", - "\xF0\x9D\x96\xA7" => "\x68", - "\xF0\x9D\x96\xA8" => "\x69", - "\xF0\x9D\x96\xA9" => "\x6A", - "\xF0\x9D\x96\xAA" => "\x6B", - "\xF0\x9D\x96\xAB" => "\x6C", - "\xF0\x9D\x96\xAC" => "\x6D", - "\xF0\x9D\x96\xAD" => "\x6E", - "\xF0\x9D\x96\xAE" => "\x6F", - "\xF0\x9D\x96\xAF" => "\x70", - "\xF0\x9D\x96\xB0" => "\x71", - "\xF0\x9D\x96\xB1" => "\x72", - "\xF0\x9D\x96\xB2" => "\x73", - "\xF0\x9D\x96\xB3" => "\x74", - "\xF0\x9D\x96\xB4" => "\x75", - "\xF0\x9D\x96\xB5" => "\x76", - "\xF0\x9D\x96\xB6" => "\x77", - "\xF0\x9D\x96\xB7" => "\x78", - "\xF0\x9D\x96\xB8" => "\x79", - "\xF0\x9D\x96\xB9" => "\x7A", - "\xF0\x9D\x97\x94" => "\x61", - "\xF0\x9D\x97\x95" => "\x62", - "\xF0\x9D\x97\x96" => "\x63", - "\xF0\x9D\x97\x97" => "\x64", - "\xF0\x9D\x97\x98" => "\x65", - "\xF0\x9D\x97\x99" => "\x66", - "\xF0\x9D\x97\x9A" => "\x67", - "\xF0\x9D\x97\x9B" => "\x68", - "\xF0\x9D\x97\x9C" => "\x69", - "\xF0\x9D\x97\x9D" => "\x6A", - "\xF0\x9D\x97\x9E" => "\x6B", - "\xF0\x9D\x97\x9F" => "\x6C", - "\xF0\x9D\x97\xA0" => "\x6D", - "\xF0\x9D\x97\xA1" => "\x6E", - "\xF0\x9D\x97\xA2" => "\x6F", - "\xF0\x9D\x97\xA3" => "\x70", - "\xF0\x9D\x97\xA4" => "\x71", - "\xF0\x9D\x97\xA5" => "\x72", - "\xF0\x9D\x97\xA6" => "\x73", - "\xF0\x9D\x97\xA7" => "\x74", - "\xF0\x9D\x97\xA8" => "\x75", - "\xF0\x9D\x97\xA9" => "\x76", - "\xF0\x9D\x97\xAA" => "\x77", - "\xF0\x9D\x97\xAB" => "\x78", - "\xF0\x9D\x97\xAC" => "\x79", - "\xF0\x9D\x97\xAD" => "\x7A", - "\xF0\x9D\x98\x88" => "\x61", - "\xF0\x9D\x98\x89" => "\x62", - "\xF0\x9D\x98\x8A" => "\x63", - "\xF0\x9D\x98\x8B" => "\x64", - "\xF0\x9D\x98\x8C" => "\x65", - "\xF0\x9D\x98\x8D" => "\x66", - "\xF0\x9D\x98\x8E" => "\x67", - "\xF0\x9D\x98\x8F" => "\x68", - "\xF0\x9D\x98\x90" => "\x69", - "\xF0\x9D\x98\x91" => "\x6A", - "\xF0\x9D\x98\x92" => "\x6B", - "\xF0\x9D\x98\x93" => "\x6C", - "\xF0\x9D\x98\x94" => "\x6D", - "\xF0\x9D\x98\x95" => "\x6E", - "\xF0\x9D\x98\x96" => "\x6F", - "\xF0\x9D\x98\x97" => "\x70", - "\xF0\x9D\x98\x98" => "\x71", - "\xF0\x9D\x98\x99" => "\x72", - "\xF0\x9D\x98\x9A" => "\x73", - "\xF0\x9D\x98\x9B" => "\x74", - "\xF0\x9D\x98\x9C" => "\x75", - "\xF0\x9D\x98\x9D" => "\x76", - "\xF0\x9D\x98\x9E" => "\x77", - "\xF0\x9D\x98\x9F" => "\x78", - "\xF0\x9D\x98\xA0" => "\x79", - "\xF0\x9D\x98\xA1" => "\x7A", - "\xF0\x9D\x98\xBC" => "\x61", - "\xF0\x9D\x98\xBD" => "\x62", - "\xF0\x9D\x98\xBE" => "\x63", - "\xF0\x9D\x98\xBF" => "\x64", - "\xF0\x9D\x99\x80" => "\x65", - "\xF0\x9D\x99\x81" => "\x66", - "\xF0\x9D\x99\x82" => "\x67", - "\xF0\x9D\x99\x83" => "\x68", - "\xF0\x9D\x99\x84" => "\x69", - "\xF0\x9D\x99\x85" => "\x6A", - "\xF0\x9D\x99\x86" => "\x6B", - "\xF0\x9D\x99\x87" => "\x6C", - "\xF0\x9D\x99\x88" => "\x6D", - "\xF0\x9D\x99\x89" => "\x6E", - "\xF0\x9D\x99\x8A" => "\x6F", - "\xF0\x9D\x99\x8B" => "\x70", - "\xF0\x9D\x99\x8C" => "\x71", - "\xF0\x9D\x99\x8D" => "\x72", - "\xF0\x9D\x99\x8E" => "\x73", - "\xF0\x9D\x99\x8F" => "\x74", - "\xF0\x9D\x99\x90" => "\x75", - "\xF0\x9D\x99\x91" => "\x76", - "\xF0\x9D\x99\x92" => "\x77", - "\xF0\x9D\x99\x93" => "\x78", - "\xF0\x9D\x99\x94" => "\x79", - "\xF0\x9D\x99\x95" => "\x7A", - "\xF0\x9D\x99\xB0" => "\x61", - "\xF0\x9D\x99\xB1" => "\x62", - "\xF0\x9D\x99\xB2" => "\x63", - "\xF0\x9D\x99\xB3" => "\x64", - "\xF0\x9D\x99\xB4" => "\x65", - "\xF0\x9D\x99\xB5" => "\x66", - "\xF0\x9D\x99\xB6" => "\x67", - "\xF0\x9D\x99\xB7" => "\x68", - "\xF0\x9D\x99\xB8" => "\x69", - "\xF0\x9D\x99\xB9" => "\x6A", - "\xF0\x9D\x99\xBA" => "\x6B", - "\xF0\x9D\x99\xBB" => "\x6C", - "\xF0\x9D\x99\xBC" => "\x6D", - "\xF0\x9D\x99\xBD" => "\x6E", - "\xF0\x9D\x99\xBE" => "\x6F", - "\xF0\x9D\x99\xBF" => "\x70", - "\xF0\x9D\x9A\x80" => "\x71", - "\xF0\x9D\x9A\x81" => "\x72", - "\xF0\x9D\x9A\x82" => "\x73", - "\xF0\x9D\x9A\x83" => "\x74", - "\xF0\x9D\x9A\x84" => "\x75", - "\xF0\x9D\x9A\x85" => "\x76", - "\xF0\x9D\x9A\x86" => "\x77", - "\xF0\x9D\x9A\x87" => "\x78", - "\xF0\x9D\x9A\x88" => "\x79", - "\xF0\x9D\x9A\x89" => "\x7A", - "\xF0\x9D\x9A\xA8" => "\xCE\xB1", - "\xF0\x9D\x9A\xA9" => "\xCE\xB2", - "\xF0\x9D\x9A\xAA" => "\xCE\xB3", - "\xF0\x9D\x9A\xAB" => "\xCE\xB4", - "\xF0\x9D\x9A\xAC" => "\xCE\xB5", - "\xF0\x9D\x9A\xAD" => "\xCE\xB6", - "\xF0\x9D\x9A\xAE" => "\xCE\xB7", - "\xF0\x9D\x9A\xAF" => "\xCE\xB8", - "\xF0\x9D\x9A\xB0" => "\xCE\xB9", - "\xF0\x9D\x9A\xB1" => "\xCE\xBA", - "\xF0\x9D\x9A\xB2" => "\xCE\xBB", - "\xF0\x9D\x9A\xB3" => "\xCE\xBC", - "\xF0\x9D\x9A\xB4" => "\xCE\xBD", - "\xF0\x9D\x9A\xB5" => "\xCE\xBE", - "\xF0\x9D\x9A\xB6" => "\xCE\xBF", - "\xF0\x9D\x9A\xB7" => "\xCF\x80", - "\xF0\x9D\x9A\xB8" => "\xCF\x81", - "\xF0\x9D\x9A\xB9" => "\xCE\xB8", - "\xF0\x9D\x9A\xBA" => "\xCF\x83", - "\xF0\x9D\x9A\xBB" => "\xCF\x84", - "\xF0\x9D\x9A\xBC" => "\xCF\x85", - "\xF0\x9D\x9A\xBD" => "\xCF\x86", - "\xF0\x9D\x9A\xBE" => "\xCF\x87", - "\xF0\x9D\x9A\xBF" => "\xCF\x88", - "\xF0\x9D\x9B\x80" => "\xCF\x89", - "\xF0\x9D\x9B\x93" => "\xCF\x83", - "\xF0\x9D\x9B\xA2" => "\xCE\xB1", - "\xF0\x9D\x9B\xA3" => "\xCE\xB2", - "\xF0\x9D\x9B\xA4" => "\xCE\xB3", - "\xF0\x9D\x9B\xA5" => "\xCE\xB4", - "\xF0\x9D\x9B\xA6" => "\xCE\xB5", - "\xF0\x9D\x9B\xA7" => "\xCE\xB6", - "\xF0\x9D\x9B\xA8" => "\xCE\xB7", - "\xF0\x9D\x9B\xA9" => "\xCE\xB8", - "\xF0\x9D\x9B\xAA" => "\xCE\xB9", - "\xF0\x9D\x9B\xAB" => "\xCE\xBA", - "\xF0\x9D\x9B\xAC" => "\xCE\xBB", - "\xF0\x9D\x9B\xAD" => "\xCE\xBC", - "\xF0\x9D\x9B\xAE" => "\xCE\xBD", - "\xF0\x9D\x9B\xAF" => "\xCE\xBE", - "\xF0\x9D\x9B\xB0" => "\xCE\xBF", - "\xF0\x9D\x9B\xB1" => "\xCF\x80", - "\xF0\x9D\x9B\xB2" => "\xCF\x81", - "\xF0\x9D\x9B\xB3" => "\xCE\xB8", - "\xF0\x9D\x9B\xB4" => "\xCF\x83", - "\xF0\x9D\x9B\xB5" => "\xCF\x84", - "\xF0\x9D\x9B\xB6" => "\xCF\x85", - "\xF0\x9D\x9B\xB7" => "\xCF\x86", - "\xF0\x9D\x9B\xB8" => "\xCF\x87", - "\xF0\x9D\x9B\xB9" => "\xCF\x88", - "\xF0\x9D\x9B\xBA" => "\xCF\x89", - "\xF0\x9D\x9C\x8D" => "\xCF\x83", - "\xF0\x9D\x9C\x9C" => "\xCE\xB1", - "\xF0\x9D\x9C\x9D" => "\xCE\xB2", - "\xF0\x9D\x9C\x9E" => "\xCE\xB3", - "\xF0\x9D\x9C\x9F" => "\xCE\xB4", - "\xF0\x9D\x9C\xA0" => "\xCE\xB5", - "\xF0\x9D\x9C\xA1" => "\xCE\xB6", - "\xF0\x9D\x9C\xA2" => "\xCE\xB7", - "\xF0\x9D\x9C\xA3" => "\xCE\xB8", - "\xF0\x9D\x9C\xA4" => "\xCE\xB9", - "\xF0\x9D\x9C\xA5" => "\xCE\xBA", - "\xF0\x9D\x9C\xA6" => "\xCE\xBB", - "\xF0\x9D\x9C\xA7" => "\xCE\xBC", - "\xF0\x9D\x9C\xA8" => "\xCE\xBD", - "\xF0\x9D\x9C\xA9" => "\xCE\xBE", - "\xF0\x9D\x9C\xAA" => "\xCE\xBF", - "\xF0\x9D\x9C\xAB" => "\xCF\x80", - "\xF0\x9D\x9C\xAC" => "\xCF\x81", - "\xF0\x9D\x9C\xAD" => "\xCE\xB8", - "\xF0\x9D\x9C\xAE" => "\xCF\x83", - "\xF0\x9D\x9C\xAF" => "\xCF\x84", - "\xF0\x9D\x9C\xB0" => "\xCF\x85", - "\xF0\x9D\x9C\xB1" => "\xCF\x86", - "\xF0\x9D\x9C\xB2" => "\xCF\x87", - "\xF0\x9D\x9C\xB3" => "\xCF\x88", - "\xF0\x9D\x9C\xB4" => "\xCF\x89", - "\xF0\x9D\x9D\x87" => "\xCF\x83", - "\xF0\x9D\x9D\x96" => "\xCE\xB1", - "\xF0\x9D\x9D\x97" => "\xCE\xB2", - "\xF0\x9D\x9D\x98" => "\xCE\xB3", - "\xF0\x9D\x9D\x99" => "\xCE\xB4", - "\xF0\x9D\x9D\x9A" => "\xCE\xB5", - "\xF0\x9D\x9D\x9B" => "\xCE\xB6", - "\xF0\x9D\x9D\x9C" => "\xCE\xB7", - "\xF0\x9D\x9D\x9D" => "\xCE\xB8", - "\xF0\x9D\x9D\x9E" => "\xCE\xB9", - "\xF0\x9D\x9D\x9F" => "\xCE\xBA", - "\xF0\x9D\x9D\xA0" => "\xCE\xBB", - "\xF0\x9D\x9D\xA1" => "\xCE\xBC", - "\xF0\x9D\x9D\xA2" => "\xCE\xBD", - "\xF0\x9D\x9D\xA3" => "\xCE\xBE", - "\xF0\x9D\x9D\xA4" => "\xCE\xBF", - "\xF0\x9D\x9D\xA5" => "\xCF\x80", - "\xF0\x9D\x9D\xA6" => "\xCF\x81", - "\xF0\x9D\x9D\xA7" => "\xCE\xB8", - "\xF0\x9D\x9D\xA8" => "\xCF\x83", - "\xF0\x9D\x9D\xA9" => "\xCF\x84", - "\xF0\x9D\x9D\xAA" => "\xCF\x85", - "\xF0\x9D\x9D\xAB" => "\xCF\x86", - "\xF0\x9D\x9D\xAC" => "\xCF\x87", - "\xF0\x9D\x9D\xAD" => "\xCF\x88", - "\xF0\x9D\x9D\xAE" => "\xCF\x89", - "\xF0\x9D\x9E\x81" => "\xCF\x83", - "\xF0\x9D\x9E\x90" => "\xCE\xB1", - "\xF0\x9D\x9E\x91" => "\xCE\xB2", - "\xF0\x9D\x9E\x92" => "\xCE\xB3", - "\xF0\x9D\x9E\x93" => "\xCE\xB4", - "\xF0\x9D\x9E\x94" => "\xCE\xB5", - "\xF0\x9D\x9E\x95" => "\xCE\xB6", - "\xF0\x9D\x9E\x96" => "\xCE\xB7", - "\xF0\x9D\x9E\x97" => "\xCE\xB8", - "\xF0\x9D\x9E\x98" => "\xCE\xB9", - "\xF0\x9D\x9E\x99" => "\xCE\xBA", - "\xF0\x9D\x9E\x9A" => "\xCE\xBB", - "\xF0\x9D\x9E\x9B" => "\xCE\xBC", - "\xF0\x9D\x9E\x9C" => "\xCE\xBD", - "\xF0\x9D\x9E\x9D" => "\xCE\xBE", - "\xF0\x9D\x9E\x9E" => "\xCE\xBF", - "\xF0\x9D\x9E\x9F" => "\xCF\x80", - "\xF0\x9D\x9E\xA0" => "\xCF\x81", - "\xF0\x9D\x9E\xA1" => "\xCE\xB8", - "\xF0\x9D\x9E\xA2" => "\xCF\x83", - "\xF0\x9D\x9E\xA3" => "\xCF\x84", - "\xF0\x9D\x9E\xA4" => "\xCF\x85", - "\xF0\x9D\x9E\xA5" => "\xCF\x86", - "\xF0\x9D\x9E\xA6" => "\xCF\x87", - "\xF0\x9D\x9E\xA7" => "\xCF\x88", - "\xF0\x9D\x9E\xA8" => "\xCF\x89", - "\xF0\x9D\x9E\xBB" => "\xCF\x83", - "\xF0\x9D\x9F\x8A" => "\xCF\x9D", - ); - - // do the case fold - $text = utf8_case_fold($text, $option); - - // convert to NFKC - Normalizer::normalize($text, Normalizer::NFKC); - - // FC_NFKC_Closure, http://www.unicode.org/Public/5.0.0/ucd/DerivedNormalizationProps.txt - $text = strtr($text, $fc_nfkc_closure); - - return $text; -} - -/** -* Assume the input is NFC: -* Takes the input and does a "special" case fold. It does minor normalization as well. -* -* @param string $text text to be case folded -* @param string $option determines how we will fold the cases -* @return string case folded text -*/ -function utf8_case_fold_nfc($text, $option = 'full') -{ - static $uniarray = array(); - static $ypogegrammeni = array( - "\xCD\xBA" => "\x20\xCD\x85", - "\xE1\xBE\x80" => "\xE1\xBC\x80\xCD\x85", - "\xE1\xBE\x81" => "\xE1\xBC\x81\xCD\x85", - "\xE1\xBE\x82" => "\xE1\xBC\x82\xCD\x85", - "\xE1\xBE\x83" => "\xE1\xBC\x83\xCD\x85", - "\xE1\xBE\x84" => "\xE1\xBC\x84\xCD\x85", - "\xE1\xBE\x85" => "\xE1\xBC\x85\xCD\x85", - "\xE1\xBE\x86" => "\xE1\xBC\x86\xCD\x85", - "\xE1\xBE\x87" => "\xE1\xBC\x87\xCD\x85", - "\xE1\xBE\x88" => "\xE1\xBC\x88\xCD\x85", - "\xE1\xBE\x89" => "\xE1\xBC\x89\xCD\x85", - "\xE1\xBE\x8A" => "\xE1\xBC\x8A\xCD\x85", - "\xE1\xBE\x8B" => "\xE1\xBC\x8B\xCD\x85", - "\xE1\xBE\x8C" => "\xE1\xBC\x8C\xCD\x85", - "\xE1\xBE\x8D" => "\xE1\xBC\x8D\xCD\x85", - "\xE1\xBE\x8E" => "\xE1\xBC\x8E\xCD\x85", - "\xE1\xBE\x8F" => "\xE1\xBC\x8F\xCD\x85", - "\xE1\xBE\x90" => "\xE1\xBC\xA0\xCD\x85", - "\xE1\xBE\x91" => "\xE1\xBC\xA1\xCD\x85", - "\xE1\xBE\x92" => "\xE1\xBC\xA2\xCD\x85", - "\xE1\xBE\x93" => "\xE1\xBC\xA3\xCD\x85", - "\xE1\xBE\x94" => "\xE1\xBC\xA4\xCD\x85", - "\xE1\xBE\x95" => "\xE1\xBC\xA5\xCD\x85", - "\xE1\xBE\x96" => "\xE1\xBC\xA6\xCD\x85", - "\xE1\xBE\x97" => "\xE1\xBC\xA7\xCD\x85", - "\xE1\xBE\x98" => "\xE1\xBC\xA8\xCD\x85", - "\xE1\xBE\x99" => "\xE1\xBC\xA9\xCD\x85", - "\xE1\xBE\x9A" => "\xE1\xBC\xAA\xCD\x85", - "\xE1\xBE\x9B" => "\xE1\xBC\xAB\xCD\x85", - "\xE1\xBE\x9C" => "\xE1\xBC\xAC\xCD\x85", - "\xE1\xBE\x9D" => "\xE1\xBC\xAD\xCD\x85", - "\xE1\xBE\x9E" => "\xE1\xBC\xAE\xCD\x85", - "\xE1\xBE\x9F" => "\xE1\xBC\xAF\xCD\x85", - "\xE1\xBE\xA0" => "\xE1\xBD\xA0\xCD\x85", - "\xE1\xBE\xA1" => "\xE1\xBD\xA1\xCD\x85", - "\xE1\xBE\xA2" => "\xE1\xBD\xA2\xCD\x85", - "\xE1\xBE\xA3" => "\xE1\xBD\xA3\xCD\x85", - "\xE1\xBE\xA4" => "\xE1\xBD\xA4\xCD\x85", - "\xE1\xBE\xA5" => "\xE1\xBD\xA5\xCD\x85", - "\xE1\xBE\xA6" => "\xE1\xBD\xA6\xCD\x85", - "\xE1\xBE\xA7" => "\xE1\xBD\xA7\xCD\x85", - "\xE1\xBE\xA8" => "\xE1\xBD\xA8\xCD\x85", - "\xE1\xBE\xA9" => "\xE1\xBD\xA9\xCD\x85", - "\xE1\xBE\xAA" => "\xE1\xBD\xAA\xCD\x85", - "\xE1\xBE\xAB" => "\xE1\xBD\xAB\xCD\x85", - "\xE1\xBE\xAC" => "\xE1\xBD\xAC\xCD\x85", - "\xE1\xBE\xAD" => "\xE1\xBD\xAD\xCD\x85", - "\xE1\xBE\xAE" => "\xE1\xBD\xAE\xCD\x85", - "\xE1\xBE\xAF" => "\xE1\xBD\xAF\xCD\x85", - "\xE1\xBE\xB2" => "\xE1\xBD\xB0\xCD\x85", - "\xE1\xBE\xB3" => "\xCE\xB1\xCD\x85", - "\xE1\xBE\xB4" => "\xCE\xAC\xCD\x85", - "\xE1\xBE\xB7" => "\xE1\xBE\xB6\xCD\x85", - "\xE1\xBE\xBC" => "\xCE\x91\xCD\x85", - "\xE1\xBF\x82" => "\xE1\xBD\xB4\xCD\x85", - "\xE1\xBF\x83" => "\xCE\xB7\xCD\x85", - "\xE1\xBF\x84" => "\xCE\xAE\xCD\x85", - "\xE1\xBF\x87" => "\xE1\xBF\x86\xCD\x85", - "\xE1\xBF\x8C" => "\xCE\x97\xCD\x85", - "\xE1\xBF\xB2" => "\xE1\xBD\xBC\xCD\x85", - "\xE1\xBF\xB3" => "\xCF\x89\xCD\x85", - "\xE1\xBF\xB4" => "\xCF\x8E\xCD\x85", - "\xE1\xBF\xB7" => "\xE1\xBF\xB6\xCD\x85", - "\xE1\xBF\xBC" => "\xCE\xA9\xCD\x85", - ); - - // perform a small trick, avoid further normalization on composed points that contain U+0345 in their decomposition - $text = strtr($text, $ypogegrammeni); - - // do the case fold - $text = utf8_case_fold($text, $option); - - return $text; -} - -/** -* wrapper around PHP's native normalizer from intl -* previously a PECL extension, included in the core since PHP 5.3.0 -* http://php.net/manual/en/normalizer.normalize.php -* -* @param mixed $strings a string or an array of strings to normalize -* @return mixed the normalized content, preserving array keys if array given. -*/ -function utf8_normalize_nfc($strings) -{ - if (empty($strings)) - { - return $strings; - } - - if (!is_array($strings)) - { - if (Normalizer::isNormalized($strings)) - { - return $strings; - } - return (string) Normalizer::normalize($strings); - } - else - { - foreach ($strings as $key => $string) - { - if (is_array($string)) - { - foreach ($string as $_key => $_string) - { - if (Normalizer::isNormalized($strings[$key][$_key])) - { - continue; - } - $strings[$key][$_key] = (string) Normalizer::normalize($strings[$key][$_key]); - } - } - else - { - if (Normalizer::isNormalized($strings[$key])) - { - continue; - } - $strings[$key] = (string) Normalizer::normalize($strings[$key]); - } - } - } - - return $strings; -} - -/** -* This function is used to generate a "clean" version of a string. -* Clean means that it is a case insensitive form (case folding) and that it is normalized (NFC). -* Additionally a homographs of one character are transformed into one specific character (preferably ASCII -* if it is an ASCII character). -* -* Please be aware that if you change something within this function or within -* functions used here you need to rebuild/update the username_clean column in the users table. And all other -* columns that store a clean string otherwise you will break this functionality. -* -* @param string $text An unclean string, mabye user input (has to be valid UTF-8!) -* @return string Cleaned up version of the input string -*/ -function utf8_clean_string($text) -{ - global $phpbb_root_path, $phpEx; - - static $homographs = array(); - if (empty($homographs)) - { - $homographs = include($phpbb_root_path . 'includes/utf/data/confusables.' . $phpEx); - } - - $text = utf8_case_fold_nfkc($text); - $text = strtr($text, $homographs); - // Other control characters - $text = preg_replace('#(?:[\x00-\x1F\x7F]+|(?:\xC2[\x80-\x9F])+)#', '', $text); - - // we need to reduce multiple spaces to a single one - $text = preg_replace('# {2,}#', ' ', $text); - - // we can use trim here as all the other space characters should have been turned - // into normal ASCII spaces by now - return trim($text); -} - -/** -* A wrapper for htmlspecialchars($value, ENT_COMPAT, 'UTF-8') -*/ -function utf8_htmlspecialchars($value) -{ - return htmlspecialchars($value, ENT_COMPAT, 'UTF-8'); -} - -/** -* Trying to convert returned system message to utf8 -* -* PHP assumes such messages are ISO-8859-1 so we'll do that too -* and if it breaks messages we'll blame it on them ;-) -*/ -function utf8_convert_message($message) -{ - // First of all check if conversion is neded at all, as there is no point - // in converting ASCII messages from ISO-8859-1 to UTF-8 - if (!preg_match('/[\x80-\xFF]/', $message)) - { - return utf8_htmlspecialchars($message); - } - - // else we need to convert some part of the message - return utf8_htmlspecialchars(utf8_recode($message, 'ISO-8859-1')); -} - -/** -* UTF8-compatible wordwrap replacement -* -* @param string $string The input string -* @param int $width The column width. Defaults to 75. -* @param string $break The line is broken using the optional break parameter. Defaults to '\n'. -* @param bool $cut If the cut is set to TRUE, the string is always wrapped at the specified width. So if you have a word that is larger than the given width, it is broken apart. -* -* @return string the given string wrapped at the specified column. -* -*/ -function utf8_wordwrap($string, $width = 75, $break = "\n", $cut = false) -{ - // We first need to explode on $break, not destroying existing (intended) breaks - $lines = explode($break, $string); - $new_lines = array(0 => ''); - $index = 0; - - foreach ($lines as $line) - { - $words = explode(' ', $line); - - for ($i = 0, $size = count($words); $i < $size; $i++) - { - $word = $words[$i]; - - // If cut is true we need to cut the word if it is > width chars - if ($cut && utf8_strlen($word) > $width) - { - $words[$i] = utf8_substr($word, $width); - $word = utf8_substr($word, 0, $width); - $i--; - } - - if (utf8_strlen($new_lines[$index] . $word) > $width) - { - $new_lines[$index] = substr($new_lines[$index], 0, -1); - $index++; - $new_lines[$index] = ''; - } - - $new_lines[$index] .= $word . ' '; - } - - $new_lines[$index] = substr($new_lines[$index], 0, -1); - $index++; - $new_lines[$index] = ''; - } - - unset($new_lines[$index]); - return implode($break, $new_lines); -} - -/** -* UTF8-safe basename() function -* -* basename() has some limitations and is dependent on the locale setting -* according to the PHP manual. Therefore we provide our own locale independent -* basename function. -* -* @param string $filename The filename basename() should be applied to -* @return string The basenamed filename -*/ -function utf8_basename($filename) -{ - // We always check for forward slash AND backward slash - // because they could be mixed or "sneaked" in. ;) - // You know, never trust user input... - if (strpos($filename, '/') !== false) - { - $filename = utf8_substr($filename, utf8_strrpos($filename, '/') + 1); - } - - if (strpos($filename, '\\') !== false) - { - $filename = utf8_substr($filename, utf8_strrpos($filename, '\\') + 1); - } - - return $filename; -} diff --git a/install/update/old/index.php b/install/update/old/index.php deleted file mode 100644 index 5eee772..0000000 --- a/install/update/old/index.php +++ /dev/null @@ -1,260 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -*/ - -/** -* @ignore -*/ -define('IN_PHPBB', true); -$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); -include($phpbb_root_path . 'common.' . $phpEx); -include($phpbb_root_path . 'includes/functions_display.' . $phpEx); - -// Start session management -$user->session_begin(); -$auth->acl($user->data); -$user->setup('viewforum'); - -// Mark notifications read -if (($mark_notification = $request->variable('mark_notification', 0))) -{ - if ($user->data['user_id'] == ANONYMOUS) - { - if ($request->is_ajax()) - { - trigger_error('LOGIN_REQUIRED'); - } - login_box('', $user->lang['LOGIN_REQUIRED']); - } - - if (check_link_hash($request->variable('hash', ''), 'mark_notification_read')) - { - /* @var $phpbb_notifications \phpbb\notification\manager */ - $phpbb_notifications = $phpbb_container->get('notification_manager'); - - $notification = $phpbb_notifications->load_notifications('notification.method.board', array( - 'notification_id' => $mark_notification, - )); - - if (isset($notification['notifications'][$mark_notification])) - { - $notification = $notification['notifications'][$mark_notification]; - - $notification->mark_read(); - - /** - * You can use this event to perform additional tasks or redirect user elsewhere. - * - * @event core.index_mark_notification_after - * @var int mark_notification Notification ID - * @var \phpbb\notification\type\type_interface notification Notification instance - * @since 3.2.6-RC1 - */ - $vars = array('mark_notification', 'notification'); - extract($phpbb_dispatcher->trigger_event('core.index_mark_notification_after', compact($vars))); - - if ($request->is_ajax()) - { - $json_response = new \phpbb\json_response(); - $json_response->send(array( - 'success' => true, - )); - } - - if (($redirect = $request->variable('redirect', ''))) - { - redirect(append_sid($phpbb_root_path . $redirect)); - } - - redirect($notification->get_redirect_url()); - } - } -} - -display_forums('', $config['load_moderators']); - -$order_legend = ($config['legend_sort_groupname']) ? 'group_name' : 'group_legend'; -// Grab group details for legend display -if ($auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) -{ - $sql = 'SELECT group_id, group_name, group_colour, group_type, group_legend - FROM ' . GROUPS_TABLE . ' - WHERE group_legend > 0 - ORDER BY ' . $order_legend . ' ASC'; -} -else -{ - $sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type, g.group_legend - FROM ' . GROUPS_TABLE . ' g - LEFT JOIN ' . USER_GROUP_TABLE . ' ug - ON ( - g.group_id = ug.group_id - AND ug.user_id = ' . $user->data['user_id'] . ' - AND ug.user_pending = 0 - ) - WHERE g.group_legend > 0 - AND (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $user->data['user_id'] . ') - ORDER BY g.' . $order_legend . ' ASC'; -} -$result = $db->sql_query($sql); - -/** @var \phpbb\group\helper $group_helper */ -$group_helper = $phpbb_container->get('group_helper'); - -$legend = array(); -while ($row = $db->sql_fetchrow($result)) -{ - $colour_text = ($row['group_colour']) ? ' style="color:#' . $row['group_colour'] . '"' : ''; - $group_name = $group_helper->get_name($row['group_name']); - - if ($row['group_name'] == 'BOTS' || ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile'))) - { - $legend[] = '' . $group_name . '
'; - } - else - { - $legend[] = '' . $group_name . ''; - } -} -$db->sql_freeresult($result); - -$legend = implode($user->lang['COMMA_SEPARATOR'], $legend); - -// Generate birthday list if required ... -$show_birthdays = ($config['load_birthdays'] && $config['allow_birthdays'] && $auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel')); - -$birthdays = $birthday_list = array(); -if ($show_birthdays) -{ - $time = $user->create_datetime(); - $now = phpbb_gmgetdate($time->getTimestamp() + $time->getOffset()); - - // Display birthdays of 29th february on 28th february in non-leap-years - $leap_year_birthdays = ''; - if ($now['mday'] == 28 && $now['mon'] == 2 && !$time->format('L')) - { - $leap_year_birthdays = " OR u.user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', 29, 2)) . "%'"; - } - - $sql_ary = array( - 'SELECT' => 'u.user_id, u.username, u.user_colour, u.user_birthday', - 'FROM' => array( - USERS_TABLE => 'u', - ), - 'LEFT_JOIN' => array( - array( - 'FROM' => array(BANLIST_TABLE => 'b'), - 'ON' => 'u.user_id = b.ban_userid', - ), - ), - 'WHERE' => "(b.ban_id IS NULL OR b.ban_exclude = 1) - AND (u.user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', $now['mday'], $now['mon'])) . "%' $leap_year_birthdays) - AND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')', - ); - - /** - * Event to modify the SQL query to get birthdays data - * - * @event core.index_modify_birthdays_sql - * @var array now The assoc array with the 'now' local timestamp data - * @var array sql_ary The SQL array to get the birthdays data - * @var object time The user related Datetime object - * @since 3.1.7-RC1 - */ - $vars = array('now', 'sql_ary', 'time'); - extract($phpbb_dispatcher->trigger_event('core.index_modify_birthdays_sql', compact($vars))); - - $sql = $db->sql_build_query('SELECT', $sql_ary); - $result = $db->sql_query($sql); - $rows = $db->sql_fetchrowset($result); - $db->sql_freeresult($result); - - foreach ($rows as $row) - { - $birthday_username = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']); - $birthday_year = (int) substr($row['user_birthday'], -4); - $birthday_age = ($birthday_year) ? max(0, $now['year'] - $birthday_year) : ''; - - $birthdays[] = array( - 'USERNAME' => $birthday_username, - 'AGE' => $birthday_age, - ); - - // For 3.0 compatibility - $birthday_list[] = $birthday_username . (($birthday_age) ? " ({$birthday_age})" : ''); - } - - /** - * Event to modify the birthdays list - * - * @event core.index_modify_birthdays_list - * @var array birthdays Array with the users birthdays data - * @var array rows Array with the birthdays SQL query result - * @since 3.1.7-RC1 - */ - $vars = array('birthdays', 'rows'); - extract($phpbb_dispatcher->trigger_event('core.index_modify_birthdays_list', compact($vars))); - - $template->assign_block_vars_array('birthdays', $birthdays); -} - -// Add form token for login box -add_form_key('login', '_LOGIN'); - -// Assign index specific vars -$template->assign_vars(array( - 'TOTAL_POSTS' => $user->lang('TOTAL_POSTS_COUNT', (int) $config['num_posts']), - 'TOTAL_TOPICS' => $user->lang('TOTAL_TOPICS', (int) $config['num_topics']), - 'TOTAL_USERS' => $user->lang('TOTAL_USERS', (int) $config['num_users']), - 'NEWEST_USER' => $user->lang('NEWEST_USER', get_username_string('full', $config['newest_user_id'], $config['newest_username'], $config['newest_user_colour'])), - - 'LEGEND' => $legend, - 'BIRTHDAY_LIST' => (empty($birthday_list)) ? '' : implode($user->lang['COMMA_SEPARATOR'], $birthday_list), - - 'FORUM_IMG' => $user->img('forum_read', 'NO_UNREAD_POSTS'), - 'FORUM_UNREAD_IMG' => $user->img('forum_unread', 'UNREAD_POSTS'), - 'FORUM_LOCKED_IMG' => $user->img('forum_read_locked', 'NO_UNREAD_POSTS_LOCKED'), - 'FORUM_UNREAD_LOCKED_IMG' => $user->img('forum_unread_locked', 'UNREAD_POSTS_LOCKED'), - - 'S_LOGIN_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'), - 'U_SEND_PASSWORD' => ($config['email_enable']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=sendpassword') : '', - 'S_DISPLAY_BIRTHDAY_LIST' => $show_birthdays, - 'S_INDEX' => true, - - 'U_MARK_FORUMS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}index.$phpEx", 'hash=' . generate_link_hash('global') . '&mark=forums&mark_time=' . time()) : '', - 'U_MCP' => ($auth->acl_get('m_') || $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=front', true, $user->session_id) : '') -); - -$page_title = ($config['board_index_text'] !== '') ? $config['board_index_text'] : $user->lang['INDEX']; - -/** -* You can use this event to modify the page title and load data for the index -* -* @event core.index_modify_page_title -* @var string page_title Title of the index page -* @since 3.1.0-a1 -*/ -$vars = array('page_title'); -extract($phpbb_dispatcher->trigger_event('core.index_modify_page_title', compact($vars))); - -// Output page -page_header($page_title, true); - -$template->set_filenames(array( - 'body' => 'index_body.html') -); - -page_footer(); diff --git a/install/update/old/language/en/acp/attachments.php b/install/update/old/language/en/acp/attachments.php deleted file mode 100644 index 86430f4..0000000 --- a/install/update/old/language/en/acp/attachments.php +++ /dev/null @@ -1,169 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* DO NOT CHANGE -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -if (empty($lang) || !is_array($lang)) -{ - $lang = array(); -} - -// DEVELOPERS PLEASE NOTE -// -// All language files should use UTF-8 as their encoding and the files must not contain a BOM. -// -// Placeholders can now contain order information, e.g. instead of -// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows -// translators to re-order the output of data while ensuring it remains correct -// -// You do not need this where single placeholders are used, e.g. 'Message %d' is fine -// equally where a string contains only two placeholders which are used to wrap text -// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine - -$lang = array_merge($lang, array( - 'ACP_ATTACHMENT_SETTINGS_EXPLAIN' => 'Here you can configure the main settings for attachments and the associated special categories.', - 'ACP_EXTENSION_GROUPS_EXPLAIN' => 'Here you can add, delete, modify or disable your extension groups. Further options include the assignment of a special category to them, changing the download mechanism and defining an upload icon which will be displayed in front of the attachment which belongs to the group.', - 'ACP_MANAGE_EXTENSIONS_EXPLAIN' => 'Here you can manage your allowed extensions. To activate your extensions, please refer to the extension groups management panel. We strongly recommend not to allow scripting extensions (such as php, php3, php4, phtml, pl, cgi, py, rb, asp, aspx, and so forth…).', - 'ACP_ORPHAN_ATTACHMENTS_EXPLAIN' => 'Here you are able to see orphaned files. This happens mostly if users are attaching files but not submitting the post. You are able to delete the files or attach them to existing posts. Attaching to posts requires a valid post ID, you have to determine this ID by yourself. This will assign the already uploaded attachment to the post you entered.', - 'ADD_EXTENSION' => 'Add extension', - 'ADD_EXTENSION_GROUP' => 'Add extension group', - 'ADMIN_UPLOAD_ERROR' => 'Errors while trying to attach file: “%s”.', - 'ALLOWED_FORUMS' => 'Allowed forums', - 'ALLOWED_FORUMS_EXPLAIN' => 'Able to post the assigned extensions at the selected (or all if selected) forums.', - 'ALLOWED_IN_PM_POST' => 'Allowed', - 'ALLOW_ATTACHMENTS' => 'Allow attachments', - 'ALLOW_ALL_FORUMS' => 'Allow all forums', - 'ALLOW_IN_PM' => 'Allowed in private messaging', - 'ALLOW_PM_ATTACHMENTS' => 'Allow attachments in private messages', - 'ALLOW_SELECTED_FORUMS' => 'Only forums selected below', - 'ASSIGNED_EXTENSIONS' => 'Assigned extensions', - 'ASSIGNED_GROUP' => 'Assigned extension group', - 'ATTACH_EXTENSIONS_URL' => 'Extensions', - 'ATTACH_EXT_GROUPS_URL' => 'Extension groups', - 'ATTACH_ID' => 'ID', - 'ATTACH_MAX_FILESIZE' => 'Maximum file size', - 'ATTACH_MAX_FILESIZE_EXPLAIN' => 'Maximum size of each file. If this value is 0, the uploadable filesize is only limited by your PHP configuration.', - 'ATTACH_MAX_PM_FILESIZE' => 'Maximum file size messaging', - 'ATTACH_MAX_PM_FILESIZE_EXPLAIN' => 'Maximum size of each file, with 0 being unlimited, attached to a private message.', - 'ATTACH_ORPHAN_URL' => 'Orphan attachments', - 'ATTACH_POST_ID' => 'Post ID', - 'ATTACH_POST_TYPE' => 'Post type', - 'ATTACH_QUOTA' => 'Total attachment quota', - 'ATTACH_QUOTA_EXPLAIN' => 'Maximum drive space available for attachments for the whole board, with 0 being unlimited.', - 'ATTACH_TO_POST' => 'Attach file to post', - - 'CAT_FLASH_FILES' => 'Flash files', - 'CAT_IMAGES' => 'Images', - 'CHECK_CONTENT' => 'Check attachment files', - 'CHECK_CONTENT_EXPLAIN' => 'Some browsers can be tricked to assume an incorrect mimetype for uploaded files. This option ensures that such files likely to cause this are rejected.', - 'CREATE_GROUP' => 'Create new group', - 'CREATE_THUMBNAIL' => 'Create thumbnail', - 'CREATE_THUMBNAIL_EXPLAIN' => 'Create a thumbnail in all possible situations.', - - 'DEFINE_ALLOWED_IPS' => 'Define allowed IPs/hostnames', - 'DEFINE_DISALLOWED_IPS' => 'Define disallowed IPs/hostnames', - 'DOWNLOAD_ADD_IPS_EXPLAIN' => 'To specify several different IPs or hostnames enter each on a new line. To specify a range of IP addresses separate the start and end with a hyphen (-), to specify a wildcard use “*”.', - 'DOWNLOAD_REMOVE_IPS_EXPLAIN' => 'You can remove (or un-exclude) multiple IP addresses in one go using the appropriate combination of mouse and keyboard for your computer and browser. Excluded IPs have a blue background.', - 'DISPLAY_INLINED' => 'Display images inline', - 'DISPLAY_INLINED_EXPLAIN' => 'If set to No image attachments will show as a link.', - 'DISPLAY_ORDER' => 'Attachment display order', - 'DISPLAY_ORDER_EXPLAIN' => 'Display attachments ordered by time.', - - 'EDIT_EXTENSION_GROUP' => 'Edit extension group', - 'EXCLUDE_ENTERED_IP' => 'Enable this to exclude the entered IP/hostname.', - 'EXCLUDE_FROM_ALLOWED_IP' => 'Exclude IP from allowed IPs/hostnames', - 'EXCLUDE_FROM_DISALLOWED_IP' => 'Exclude IP from disallowed IPs/hostnames', - 'EXTENSIONS_UPDATED' => 'Extensions successfully updated.', - 'EXTENSION_EXIST' => 'The extension %s already exists.', - 'EXTENSION_GROUP' => 'Extension group', - 'EXTENSION_GROUPS' => 'Extension groups', - 'EXTENSION_GROUP_DELETED' => 'Extension group successfully deleted.', - 'EXTENSION_GROUP_EXIST' => 'The extension group %s already exists.', - - 'EXT_GROUP_ARCHIVES' => 'Archives', - 'EXT_GROUP_DOCUMENTS' => 'Documents', - 'EXT_GROUP_DOWNLOADABLE_FILES' => 'Downloadable Files', - 'EXT_GROUP_FLASH_FILES' => 'Flash Files', - 'EXT_GROUP_IMAGES' => 'Images', - 'EXT_GROUP_PLAIN_TEXT' => 'Plain Text', - - 'FILES_GONE' => 'Some of the attachments you selected for deletion do not exist. They may have been already deleted. Attachments that did exist were deleted.', - 'FILES_STATS_WRONG' => 'Your file statistics are likely inaccurate and need to be resynchronised. Actual values: number of attachments = %1$d, total size of attachments = %2$s.
Click %3$shere%4$s to resynchronise them.', - - 'GO_TO_EXTENSIONS' => 'Go to extension management screen', - 'GROUP_NAME' => 'Group name', - - 'IMAGE_LINK_SIZE' => 'Image link dimensions', - 'IMAGE_LINK_SIZE_EXPLAIN' => 'Display image attachment as an inline text link if image is larger than this. To disable this behaviour, set the values to 0px by 0px.', - - 'MAX_ATTACHMENTS' => 'Maximum number of attachments per post', - 'MAX_ATTACHMENTS_PM' => 'Maximum number of attachments per private message', - 'MAX_EXTGROUP_FILESIZE' => 'Maximum file size', - 'MAX_IMAGE_SIZE' => 'Maximum image dimensions', - 'MAX_IMAGE_SIZE_EXPLAIN' => 'Maximum size of image attachments. Set both values to 0px by 0px to disable dimension checking.', - 'MAX_THUMB_WIDTH' => 'Maximum thumbnail width/height in pixel', - 'MAX_THUMB_WIDTH_EXPLAIN' => 'A generated thumbnail will not exceed the width set here.', - 'MIN_THUMB_FILESIZE' => 'Minimum thumbnail file size', - 'MIN_THUMB_FILESIZE_EXPLAIN' => 'Do not create a thumbnail for images smaller than this.', - 'MODE_INLINE' => 'Inline', - 'MODE_PHYSICAL' => 'Physical', - - 'NOT_ALLOWED_IN_PM' => 'Only allowed in posts', - 'NOT_ALLOWED_IN_PM_POST' => 'Not allowed', - 'NOT_ASSIGNED' => 'Not assigned', - 'NO_ATTACHMENTS' => 'No attachments found for this period.', - 'NO_EXT_GROUP' => 'None', - 'NO_EXT_GROUP_NAME' => 'No group name entered', - 'NO_EXT_GROUP_SPECIFIED' => 'No extension group specified.', - 'NO_FILE_CAT' => 'None', - 'NO_IMAGE' => 'No image', - 'NO_UPLOAD_DIR' => 'The upload directory you specified does not exist.', - 'NO_WRITE_UPLOAD' => 'The upload directory you specified cannot be written to. Please alter the permissions to allow the webserver to write to it.', - - 'ONLY_ALLOWED_IN_PM' => 'Only allowed in private messages', - 'ORDER_ALLOW_DENY' => 'Allow', - 'ORDER_DENY_ALLOW' => 'Deny', - - 'REMOVE_ALLOWED_IPS' => 'Remove or un-exclude allowed IPs/hostnames', - 'REMOVE_DISALLOWED_IPS' => 'Remove or un-exclude disallowed IPs/hostnames', - 'RESYNC_FILES_STATS_CONFIRM' => 'Are you sure you wish to resynchronise file statistics?', - - 'SECURE_ALLOW_DENY' => 'Allow/Deny list', - 'SECURE_ALLOW_DENY_EXPLAIN' => 'Change the default behaviour when secure downloads are enabled of the Allow/Deny list to that of a whitelist (Allow) or a blacklist (Deny).', - 'SECURE_DOWNLOADS' => 'Enable secure downloads', - 'SECURE_DOWNLOADS_EXPLAIN' => 'With this option enabled, downloads are limited to IP’s/hostnames you define.', - 'SECURE_DOWNLOAD_NOTICE' => 'Secure Downloads are not enabled. The settings below will be applied after enabling secure downloads.', - 'SECURE_DOWNLOAD_UPDATE_SUCCESS'=> 'The IP list has been updated successfully.', - 'SECURE_EMPTY_REFERRER' => 'Allow empty referrer', - 'SECURE_EMPTY_REFERRER_EXPLAIN' => 'Secure downloads are based on referrers. Do you want to allow downloads for those omitting the referrer?', - 'SETTINGS_CAT_IMAGES' => 'Image category settings', - 'SPECIAL_CATEGORY' => 'Special category', - 'SPECIAL_CATEGORY_EXPLAIN' => 'Special categories differ between the way presented within posts.', - 'SUCCESSFULLY_UPLOADED' => 'Successfully uploaded.', - 'SUCCESS_EXTENSION_GROUP_ADD' => 'Extension group successfully added.', - 'SUCCESS_EXTENSION_GROUP_EDIT' => 'Extension group successfully updated.', - - 'UPLOADING_FILES' => 'Uploading files', - 'UPLOADING_FILE_TO' => 'Uploading file “%1$s” to post number %2$d…', - 'UPLOAD_DENIED_FORUM' => 'You do not have the permission to upload files to forum “%s”.', - 'UPLOAD_DIR' => 'Upload directory', - 'UPLOAD_DIR_EXPLAIN' => 'Storage path for attachments. Please note that if you change this directory while already having uploaded attachments you need to manually copy the files to their new location.', - 'UPLOAD_ICON' => 'Upload icon', - 'UPLOAD_NOT_DIR' => 'The upload location you specified does not appear to be a directory.', -)); diff --git a/install/update/old/language/en/acp/board.php b/install/update/old/language/en/acp/board.php deleted file mode 100644 index 9b45ffa..0000000 --- a/install/update/old/language/en/acp/board.php +++ /dev/null @@ -1,631 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* DO NOT CHANGE -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -if (empty($lang) || !is_array($lang)) -{ - $lang = array(); -} - -// DEVELOPERS PLEASE NOTE -// -// All language files should use UTF-8 as their encoding and the files must not contain a BOM. -// -// Placeholders can now contain order information, e.g. instead of -// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows -// translators to re-order the output of data while ensuring it remains correct -// -// You do not need this where single placeholders are used, e.g. 'Message %d' is fine -// equally where a string contains only two placeholders which are used to wrap text -// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine - -// Board Settings -$lang = array_merge($lang, array( - 'ACP_BOARD_SETTINGS_EXPLAIN' => 'Here you can determine the basic operation of your board, give it a fitting name and description, and among other settings adjust the default values for timezone and language.', - 'BOARD_INDEX_TEXT' => 'Board index text', - 'BOARD_INDEX_TEXT_EXPLAIN' => 'This text is displayed as the board index in the board’s breadcrumbs. If not specified, it will default to “Board index”.', - 'BOARD_STYLE' => 'Board style', - 'CUSTOM_DATEFORMAT' => 'Custom…', - 'DEFAULT_DATE_FORMAT' => 'Date format', - 'DEFAULT_DATE_FORMAT_EXPLAIN' => 'The date format is the same as the PHP date function.', - 'DEFAULT_LANGUAGE' => 'Default language', - 'DEFAULT_STYLE' => 'Default style', - 'DEFAULT_STYLE_EXPLAIN' => 'The default style for new users.', - 'DISABLE_BOARD' => 'Disable board', - 'DISABLE_BOARD_EXPLAIN' => 'This will make the board unavailable to users who are neither administrators nor moderators. You can also enter a short (255 character) message to display if you wish.', - 'DISPLAY_LAST_SUBJECT' => 'Display subject of last added post on forum list', - 'DISPLAY_LAST_SUBJECT_EXPLAIN' => 'The subject of the last added post will be displayed in the forum list with a hyperlink to the post. Subjects from password protected forums and forums in which user doesn’t have read access are not shown.', - 'GUEST_STYLE' => 'Guest style', - 'GUEST_STYLE_EXPLAIN' => 'The board style for guests.', - 'OVERRIDE_STYLE' => 'Override user style', - 'OVERRIDE_STYLE_EXPLAIN' => 'Replaces user’s (and guest’s) style with the style as defined under "Default style".', - 'SITE_DESC' => 'Site description', - 'SITE_HOME_TEXT' => 'Main website text', - 'SITE_HOME_TEXT_EXPLAIN' => 'This text will be displayed as a link to your website homepage in the board’s breadcrumbs. If not specified, it will default to “Home”.', - 'SITE_HOME_URL' => 'Main website URL', - 'SITE_HOME_URL_EXPLAIN' => 'If specified, a link to this URL will be prepended to your board’s breadcrumbs and the board logo will link to this URL instead of the forum index. An absolute URL is required, e.g. http://www.phpbb.com.', - 'SITE_NAME' => 'Site name', - 'SYSTEM_TIMEZONE' => 'Guest timezone', - 'SYSTEM_TIMEZONE_EXPLAIN' => 'Timezone to use for displaying times to users who are not logged in (guests, bots). Logged in users set their timezone during registration and can change it in their user control panel.', - 'WARNINGS_EXPIRE' => 'Warning duration', - 'WARNINGS_EXPIRE_EXPLAIN' => 'Number of days that will elapse before a warning will automatically expire from a user’s record. Set this value to 0 to make warnings permanent.', -)); - -// Board Features -$lang = array_merge($lang, array( - 'ACP_BOARD_FEATURES_EXPLAIN' => 'Here you can enable/disable several board features.', - - 'ALLOW_ATTACHMENTS' => 'Allow attachments', - 'ALLOW_BIRTHDAYS' => 'Allow birthdays', - 'ALLOW_BIRTHDAYS_EXPLAIN' => 'Allow birthdays to be entered and age being displayed in profiles. Please note the birthday list within the board index is controlled by a separate load setting.', - 'ALLOW_BOOKMARKS' => 'Allow bookmarking topics', - 'ALLOW_BOOKMARKS_EXPLAIN' => 'User is able to store personal bookmarks.', - 'ALLOW_BBCODE' => 'Allow BBCode', - 'ALLOW_FORUM_NOTIFY' => 'Allow subscribing to forums', - 'ALLOW_NAME_CHANGE' => 'Allow username changes', - 'ALLOW_NO_CENSORS' => 'Allow disabling of word censoring', - 'ALLOW_NO_CENSORS_EXPLAIN' => 'Users can choose to disable the automatic word censoring of posts and private messages.', - 'ALLOW_PM_ATTACHMENTS' => 'Allow attachments in private messages', - 'ALLOW_PM_REPORT' => 'Allow users to report private messages', - 'ALLOW_PM_REPORT_EXPLAIN' => 'If this setting is enabled, users have the option of reporting a private message they have received or sent to the board’s moderators. These private messages will then be visible in the Moderator Control Panel.', - 'ALLOW_QUICK_REPLY' => 'Allow quick reply', - 'ALLOW_QUICK_REPLY_EXPLAIN' => 'This switch allows for the quick reply to be disabled board-wide. When enabled, forum specific settings will be used to determine whether the quick reply is displayed in individual forums.', - 'ALLOW_QUICK_REPLY_BUTTON' => 'Submit and enable quick reply in all forums', - 'ALLOW_SIG' => 'Allow signatures', - 'ALLOW_SIG_BBCODE' => 'Allow BBCode in user signatures', - 'ALLOW_SIG_FLASH' => 'Allow use of [FLASH] BBCode tag in user signatures', - 'ALLOW_SIG_IMG' => 'Allow use of [IMG] BBCode tag in user signatures', - 'ALLOW_SIG_LINKS' => 'Allow use of links in user signatures', - 'ALLOW_SIG_LINKS_EXPLAIN' => 'If disallowed the [URL] BBCode tag and automatic/magic URLs are disabled.', - 'ALLOW_SIG_SMILIES' => 'Allow use of smilies in user signatures', - 'ALLOW_SMILIES' => 'Allow smilies', - 'ALLOW_TOPIC_NOTIFY' => 'Allow subscribing to topics', - 'BOARD_PM' => 'Private messaging', - 'BOARD_PM_EXPLAIN' => 'Enable private messaging for all users.', - 'ALLOW_BOARD_NOTIFICATIONS' => 'Allow board notifications', -)); - -// Avatar Settings -$lang = array_merge($lang, array( - 'ACP_AVATAR_SETTINGS_EXPLAIN' => 'Avatars are generally small, unique images a user can associate with themselves. Depending on the style they are usually displayed below the username when viewing topics. Here you can determine how users can define their avatars. Please note that in order to upload avatars you need to have created the directory you name below and ensure it can be written to by the web server. Please also note that file size limits are only imposed on uploaded avatars, they do not apply to remotely linked images.', - - 'ALLOW_AVATARS' => 'Enable avatars', - 'ALLOW_AVATARS_EXPLAIN' => 'Allow general usage of avatars;
If you disable avatars in general or avatars of a certain mode, the disabled avatars will no longer be shown on the board, but users will still be able to download their own avatars in the User Control Panel.', - 'ALLOW_GRAVATAR' => 'Enable gravatar avatars', - 'ALLOW_LOCAL' => 'Enable gallery avatars', - 'ALLOW_REMOTE' => 'Enable remote avatars', - 'ALLOW_REMOTE_EXPLAIN' => 'Avatars linked to from another website.
Warning: Enabling this feature might allow users to check for the existence of files and services that are only accessible on the local network.', - 'ALLOW_REMOTE_UPLOAD' => 'Enable remote avatar uploading', - 'ALLOW_REMOTE_UPLOAD_EXPLAIN' => 'Allow uploading of avatars from another website.
Warning: Enabling this feature might allow users to check for the existence of files and services that are only accessible on the local network.', - 'ALLOW_UPLOAD' => 'Enable avatar uploading', - 'AVATAR_GALLERY_PATH' => 'Avatar gallery path', - 'AVATAR_GALLERY_PATH_EXPLAIN' => 'Path under your phpBB root directory for pre-loaded images, e.g. images/avatars/gallery.
Double dots like ../ will be stripped from the path for security reasons.', - 'AVATAR_STORAGE_PATH' => 'Avatar storage path', - 'AVATAR_STORAGE_PATH_EXPLAIN' => 'Path under your phpBB root directory, e.g. images/avatars/upload.
Avatar uploading will not be available if this path is not writable.
Double dots like ../ will be stripped from the path for security reasons.', - 'MAX_AVATAR_SIZE' => 'Maximum avatar dimensions', - 'MAX_AVATAR_SIZE_EXPLAIN' => 'Width x Height in pixels.', - 'MAX_FILESIZE' => 'Maximum avatar file size', - 'MAX_FILESIZE_EXPLAIN' => 'For uploaded avatar files. If this value is 0, the uploaded filesize is only limited by your PHP configuration.', - 'MIN_AVATAR_SIZE' => 'Minimum avatar dimensions', - 'MIN_AVATAR_SIZE_EXPLAIN' => 'Width x Height in pixels.', -)); - -// Message Settings -$lang = array_merge($lang, array( - 'ACP_MESSAGE_SETTINGS_EXPLAIN' => 'Here you can set all default settings for private messaging.', - - 'ALLOW_BBCODE_PM' => 'Allow BBCode in private messages', - 'ALLOW_FLASH_PM' => 'Allow use of [FLASH] BBCode tag', - 'ALLOW_FLASH_PM_EXPLAIN' => 'Note that the ability to use flash in private messages, if enabled here, also depends on the permissions.', - 'ALLOW_FORWARD_PM' => 'Allow forwarding of private messages', - 'ALLOW_IMG_PM' => 'Allow use of [IMG] BBCode tag', - 'ALLOW_MASS_PM' => 'Allow sending of private messages to multiple users and groups', - 'ALLOW_MASS_PM_EXPLAIN' => 'Sending to groups can be adjusted per group within the group settings page.', - 'ALLOW_PRINT_PM' => 'Allow print view in private messaging', - 'ALLOW_QUOTE_PM' => 'Allow quotes in private messages', - 'ALLOW_SIG_PM' => 'Allow signature in private messages', - 'ALLOW_SMILIES_PM' => 'Allow smilies in private messages', - 'BOXES_LIMIT' => 'Maximum private messages per box', - 'BOXES_LIMIT_EXPLAIN' => 'Users may receive no more than this many messages in each of their private message boxes. Set this value to 0 to allow unlimited messages.', - 'BOXES_MAX' => 'Maximum private message folders', - 'BOXES_MAX_EXPLAIN' => 'By default users may create this many personal folders for private messages.', - 'ENABLE_PM_ICONS' => 'Enable use of topic icons in private messages', - 'FULL_FOLDER_ACTION' => 'Full folder default action', - 'FULL_FOLDER_ACTION_EXPLAIN'=> 'Default action to take if a user’s folder is full assuming the user’s folder action, if set at all, is not applicable. The only exception is for the “Sent messages” folder where the default action is always to delete old messages.', - 'HOLD_NEW_MESSAGES' => 'Hold new messages', - 'PM_EDIT_TIME' => 'Limit editing time', - 'PM_EDIT_TIME_EXPLAIN' => 'Limits the time available to edit a private message not already delivered. Setting the value to 0 disables this behaviour.', - 'PM_MAX_RECIPIENTS' => 'Maximum number of allowed recipients', - 'PM_MAX_RECIPIENTS_EXPLAIN' => 'The maximum number of allowed recipients in a private message. If 0 is entered, an unlimited number is allowed. This setting can be adjusted for every group within the group settings page.', -)); - -// Post Settings -$lang = array_merge($lang, array( - 'ACP_POST_SETTINGS_EXPLAIN' => 'Here you can set all default settings for posting.', - 'ALLOW_POST_LINKS' => 'Allow links in posts/private messages', - 'ALLOW_POST_LINKS_EXPLAIN' => 'If disallowed the [URL] BBCode tag and automatic/magic URLs are disabled.', - 'ALLOWED_SCHEMES_LINKS' => 'Allowed schemes in links', - 'ALLOWED_SCHEMES_LINKS_EXPLAIN' => 'Users can only post schemeless URLs or one of the comma-separated list of allowed schemes.', - 'ALLOW_POST_FLASH' => 'Allow use of [FLASH] BBCode tag in posts', - 'ALLOW_POST_FLASH_EXPLAIN' => 'If disallowed the [FLASH] BBCode tag is disabled in posts. Otherwise the permission system controls which users can use the [FLASH] BBCode tag.', - - 'BUMP_INTERVAL' => 'Bump interval', - 'BUMP_INTERVAL_EXPLAIN' => 'Number of minutes, hours or days between the last post to a topic and the ability to bump that topic. Setting the value to 0 disables bumping entirely.', - 'CHAR_LIMIT' => 'Maximum characters per post/message', - 'CHAR_LIMIT_EXPLAIN' => 'The number of characters allowed within a post/private message. Set to 0 for unlimited characters.', - 'DELETE_TIME' => 'Limit deleting time', - 'DELETE_TIME_EXPLAIN' => 'Limits the time available to delete a new post. Setting the value to 0 disables this behaviour.', - 'DISPLAY_LAST_EDITED' => 'Display last edited time information', - 'DISPLAY_LAST_EDITED_EXPLAIN' => 'Choose if the last edited by information to be displayed on posts.', - 'EDIT_TIME' => 'Limit editing time', - 'EDIT_TIME_EXPLAIN' => 'Limits the time available to edit a new post. Setting the value to 0 disables this behaviour.', - 'FLOOD_INTERVAL' => 'Flood interval', - 'FLOOD_INTERVAL_EXPLAIN' => 'Number of seconds a user must wait between posting new messages. To enable users to ignore this alter their permissions.', - 'HOT_THRESHOLD' => 'Popular topic threshold', - 'HOT_THRESHOLD_EXPLAIN' => 'Posts per topic threshold required for the popular topic annotation. Set to 0 to disable popular topics.', - 'MAX_POLL_OPTIONS' => 'Maximum number of poll options', - 'MAX_POST_FONT_SIZE' => 'Maximum font size per post', - 'MAX_POST_FONT_SIZE_EXPLAIN' => 'Maximum font size allowed in a post. Set to 0 for unlimited font size.', - 'MAX_POST_IMG_HEIGHT' => 'Maximum image height per post', - 'MAX_POST_IMG_HEIGHT_EXPLAIN' => 'Maximum height of an image/flash file in postings. Set to 0 for unlimited size.', - 'MAX_POST_IMG_WIDTH' => 'Maximum image width per post', - 'MAX_POST_IMG_WIDTH_EXPLAIN' => 'Maximum width of an image/flash file in postings. Set to 0 for unlimited size.', - 'MAX_POST_URLS' => 'Maximum links per post', - 'MAX_POST_URLS_EXPLAIN' => 'Maximum number of URLs in a post. Set to 0 for unlimited links.', - 'MIN_CHAR_LIMIT' => 'Minimum characters per post/message', - 'MIN_CHAR_LIMIT_EXPLAIN' => 'The minimum number of characters the user need to enter within a post/private message. The minimum for this setting is 1.', - 'POSTING' => 'Posting', - 'POSTS_PER_PAGE' => 'Posts per page', - 'QUOTE_DEPTH_LIMIT' => 'Maximum nesting depth for quotes', - 'QUOTE_DEPTH_LIMIT_EXPLAIN' => 'Maximum quote nesting depth in a post. Set to 0 for unlimited depth.', - 'SMILIES_LIMIT' => 'Maximum smilies per post', - 'SMILIES_LIMIT_EXPLAIN' => 'Maximum number of smilies in a post. Set to 0 for unlimited smilies.', - 'SMILIES_PER_PAGE' => 'Smilies per page', - 'TOPICS_PER_PAGE' => 'Topics per page', -)); - -// Signature Settings -$lang = array_merge($lang, array( - 'ACP_SIGNATURE_SETTINGS_EXPLAIN' => 'Here you can set all default settings for signatures.', - - 'MAX_SIG_FONT_SIZE' => 'Maximum signature font size', - 'MAX_SIG_FONT_SIZE_EXPLAIN' => 'Maximum font size allowed in user signatures. Set to 0 for unlimited size.', - 'MAX_SIG_IMG_HEIGHT' => 'Maximum signature image height', - 'MAX_SIG_IMG_HEIGHT_EXPLAIN' => 'Maximum height of an image/flash file in user signatures. Set to 0 for unlimited height.', - 'MAX_SIG_IMG_WIDTH' => 'Maximum signature image width', - 'MAX_SIG_IMG_WIDTH_EXPLAIN' => 'Maximum width of an image/flash file in user signatures. Set to 0 for unlimited width.', - 'MAX_SIG_LENGTH' => 'Maximum signature length', - 'MAX_SIG_LENGTH_EXPLAIN' => 'Maximum number of characters in user signatures.', - 'MAX_SIG_SMILIES' => 'Maximum smilies per signature', - 'MAX_SIG_SMILIES_EXPLAIN' => 'Maximum smilies allowed in user signatures. Set to 0 for unlimited smilies.', - 'MAX_SIG_URLS' => 'Maximum signature links', - 'MAX_SIG_URLS_EXPLAIN' => 'Maximum number of links in user signatures. Set to 0 for unlimited links.', -)); - -// Registration Settings -$lang = array_merge($lang, array( - 'ACP_REGISTER_SETTINGS_EXPLAIN' => 'Here you are able to define registration and profile related settings.', - - 'ACC_ACTIVATION' => 'Account activation', - 'ACC_ACTIVATION_EXPLAIN' => 'This determines whether users have immediate access to the board or if confirmation is required. You can also completely disable new registrations. “Board-wide email” must be enabled in order to use user or admin activation.', - 'ACC_ACTIVATION_WARNING' => 'Please note that the currently selected activation method requires emails to be enabled, otherwise registration will be disabled. We recommend to either select a different activation method or reenable emails.', - 'NEW_MEMBER_POST_LIMIT' => 'New member post limit', - 'NEW_MEMBER_POST_LIMIT_EXPLAIN' => 'New members are within the Newly Registered Users group until they reach this number of posts. You can use this group to keep them from using the PM system or to review their posts. A value of 0 disables this feature.', - 'NEW_MEMBER_GROUP_DEFAULT' => 'Set Newly Registered Users group to default', - 'NEW_MEMBER_GROUP_DEFAULT_EXPLAIN' => 'If set to yes, and a new member post limit is specified, newly registered users will not only be put into the Newly Registered Users group, but this group will also be their default one. This may come in handy if you want to assign a group default rank and/or avatar the user then inherits.', - - 'ACC_ADMIN' => 'By admin', - 'ACC_DISABLE' => 'Disable registration', - 'ACC_NONE' => 'No activation (immediate access)', - 'ACC_USER' => 'By user (email verification)', -// 'ACC_USER_ADMIN' => 'User + Admin', - 'ALLOW_EMAIL_REUSE' => 'Allow email address re-use', - 'ALLOW_EMAIL_REUSE_EXPLAIN' => 'Different users can register with the same email address.', - 'COPPA' => 'COPPA', - 'COPPA_FAX' => 'COPPA fax number', - 'COPPA_MAIL' => 'COPPA mailing address', - 'COPPA_MAIL_EXPLAIN' => 'This is the mailing address where parents will send COPPA registration forms.', - 'ENABLE_COPPA' => 'Enable COPPA', - 'ENABLE_COPPA_EXPLAIN' => 'This requires users to declare whether they are 13 or over for compliance with the U.S. COPPA. If this is disabled the COPPA specific groups will no longer be displayed.', - 'MAX_CHARS' => 'Max', - 'MIN_CHARS' => 'Min', - 'NO_AUTH_PLUGIN' => 'No suitable auth plugin found.', - 'PASSWORD_LENGTH' => 'Password length', - 'PASSWORD_LENGTH_EXPLAIN' => 'Minimum and maximum number of characters in passwords.', - 'REG_LIMIT' => 'Registration attempts', - 'REG_LIMIT_EXPLAIN' => 'Number of attempts users can make at solving the anti-spambot task before being locked out of that session.', - 'USERNAME_ALPHA_ONLY' => 'Alphanumeric only', - 'USERNAME_ALPHA_SPACERS' => 'Alphanumeric and spacers', - 'USERNAME_ASCII' => 'ASCII (no international unicode)', - 'USERNAME_LETTER_NUM' => 'Any letter and number', - 'USERNAME_LETTER_NUM_SPACERS' => 'Any letter, number, and spacer', - 'USERNAME_CHARS' => 'Limit username chars', - 'USERNAME_CHARS_ANY' => 'Any character', - 'USERNAME_CHARS_EXPLAIN' => 'Restrict type of characters that may be used in usernames, spacers are: space, -, +, _, [ and ].', - 'USERNAME_LENGTH' => 'Username length', - 'USERNAME_LENGTH_EXPLAIN' => 'Minimum and maximum number of characters in usernames.', -)); - -// Feeds -$lang = array_merge($lang, array( - 'ACP_FEED_MANAGEMENT' => 'General syndication feeds settings', - 'ACP_FEED_MANAGEMENT_EXPLAIN' => 'This module makes available various ATOM feeds, parsing any BBCode in posts to make them readable in external feeds.', - - 'ACP_FEED_GENERAL' => 'General feed settings', - 'ACP_FEED_POST_BASED' => 'Post-based feed settings', - 'ACP_FEED_TOPIC_BASED' => 'Topic-based feed settings', - 'ACP_FEED_SETTINGS_OTHER' => 'Other feeds and settings', - - 'ACP_FEED_ENABLE' => 'Enable feeds', - 'ACP_FEED_ENABLE_EXPLAIN' => 'Turns on or off ATOM feeds for the entire board.
Disabling this switches off all feeds, no matter how the options below are set.', - 'ACP_FEED_LIMIT' => 'Number of items', - 'ACP_FEED_LIMIT_EXPLAIN' => 'The maximum number of feed items to display.', - - 'ACP_FEED_OVERALL' => 'Enable board-wide feed', - 'ACP_FEED_OVERALL_EXPLAIN' => 'Board-wide new posts.', - 'ACP_FEED_FORUM' => 'Enable per-forum feeds', - 'ACP_FEED_FORUM_EXPLAIN' => 'Single forum and subforums new posts.', - 'ACP_FEED_TOPIC' => 'Enable per-topic feeds', - 'ACP_FEED_TOPIC_EXPLAIN' => 'Single topics new posts.', - - 'ACP_FEED_TOPICS_NEW' => 'Enable new topics feed', - 'ACP_FEED_TOPICS_NEW_EXPLAIN' => 'Enables the “New Topics” feed, which displays the last created topics including the first post.', - 'ACP_FEED_TOPICS_ACTIVE' => 'Enable active topics feed', - 'ACP_FEED_TOPICS_ACTIVE_EXPLAIN' => 'Enables the “Active Topics” feed, which displays the last active topics including the last post.', - 'ACP_FEED_NEWS' => 'News feed', - 'ACP_FEED_NEWS_EXPLAIN' => 'Pull the first post from these forums. Select no forums to disable news feed.
Select multiple forums by holding CTRL and clicking.', - - 'ACP_FEED_OVERALL_FORUMS' => 'Enable forums feed', - 'ACP_FEED_OVERALL_FORUMS_EXPLAIN' => 'Enables the “All forums” feed, which displays a list of forums.', - - 'ACP_FEED_HTTP_AUTH' => 'Allow HTTP Authentication', - 'ACP_FEED_HTTP_AUTH_EXPLAIN' => 'Enables HTTP authentication, which allows users to receive content that is hidden to guest users by adding the auth=http parameter to the feed URL. Please note that some PHP setups require additional changes to the .htaccess file. Instructions can be found in that file.', - 'ACP_FEED_ITEM_STATISTICS' => 'Item statistics', - 'ACP_FEED_ITEM_STATISTICS_EXPLAIN' => 'Display individual statistics underneath feed items
(e.g. posted by, date and time, replies, views)', - 'ACP_FEED_EXCLUDE_ID' => 'Exclude these forums', - 'ACP_FEED_EXCLUDE_ID_EXPLAIN' => 'Content from these will be not included in feeds. Select no forum to pull data from all forums.
Select/Deselect multiple forums by holding CTRL and clicking.', -)); - -// Visual Confirmation Settings -$lang = array_merge($lang, array( - 'ACP_VC_SETTINGS_EXPLAIN' => 'Here you can select and configure plugins, which are designed to block automated form submissions by spambots. These plugins typically work by challenging the user with a CAPTCHA, a test which is designed to be difficult for computers to solve.', - 'ACP_VC_EXT_GET_MORE' => 'For additional (and possibly better) anti-spam plugins, visit the phpBB.com Extensions Database. For more information on preventing spam on your board, visit the phpBB.com Knowledge Base.', - 'AVAILABLE_CAPTCHAS' => 'Available plugins', - 'CAPTCHA_UNAVAILABLE' => 'The plugin cannot be selected as its requirements are not met.', - 'CAPTCHA_GD' => 'GD image', - 'CAPTCHA_GD_3D' => 'GD 3D image', - 'CAPTCHA_GD_FOREGROUND_NOISE' => 'Foreground noise', - 'CAPTCHA_GD_EXPLAIN' => 'Uses GD to make a more advanced anti-spambot image.', - 'CAPTCHA_GD_FOREGROUND_NOISE_EXPLAIN' => 'Use foreground noise to make the image harder to read.', - 'CAPTCHA_GD_X_GRID' => 'Background noise x-axis', - 'CAPTCHA_GD_X_GRID_EXPLAIN' => 'Use lower settings of this to make the image harder to read. 0 will disable x-axis background noise.', - 'CAPTCHA_GD_Y_GRID' => 'Background noise y-axis', - 'CAPTCHA_GD_Y_GRID_EXPLAIN' => 'Use lower settings of this to make the image harder to read. 0 will disable y-axis background noise.', - 'CAPTCHA_GD_WAVE' => 'Wave distortion', - 'CAPTCHA_GD_WAVE_EXPLAIN' => 'This applies a wave distortion to the image.', - 'CAPTCHA_GD_3D_NOISE' => 'Add 3D-noise objects', - 'CAPTCHA_GD_3D_NOISE_EXPLAIN' => 'This adds additional objects to the image, over the letters.', - 'CAPTCHA_GD_FONTS' => 'Use different fonts', - 'CAPTCHA_GD_FONTS_EXPLAIN' => 'This setting controls how many different letter shapes are used. You can just use the default shapes or introduce altered letters. Adding lowercase letters is also possible.', - 'CAPTCHA_FONT_DEFAULT' => 'Default', - 'CAPTCHA_FONT_NEW' => 'New Shapes', - 'CAPTCHA_FONT_LOWER' => 'Also use lowercase', - 'CAPTCHA_NO_GD' => 'Simple image', - 'CAPTCHA_PREVIEW_MSG' => 'Your changes have not been saved, this is just a preview.', - 'CAPTCHA_PREVIEW_EXPLAIN' => 'The plugin as it would look like using the current selection.', - - 'CAPTCHA_SELECT' => 'Installed plugins', - 'CAPTCHA_SELECT_EXPLAIN' => 'The dropdown holds the plugins recognised by the board. Grey entries are not available right now and might need configuration prior to use.', - 'CAPTCHA_CONFIGURE' => 'Configure plugins', - 'CAPTCHA_CONFIGURE_EXPLAIN' => 'Change the settings for the selected plugin.', - 'CONFIGURE' => 'Configure', - 'CAPTCHA_NO_OPTIONS' => 'This plugin has no configuration options.', - - 'VISUAL_CONFIRM_POST' => 'Enable spambot countermeasures for guest postings', - 'VISUAL_CONFIRM_POST_EXPLAIN' => 'Requires guest users to pass the anti-spambot task to help prevent automated postings.', - 'VISUAL_CONFIRM_REG' => 'Enable spambot countermeasures for registrations', - 'VISUAL_CONFIRM_REG_EXPLAIN' => 'Requires new users to pass the anti-spambot task to help prevent automated registrations.', - 'VISUAL_CONFIRM_REFRESH' => 'Allow users to refresh the anti-spambot task', - 'VISUAL_CONFIRM_REFRESH_EXPLAIN' => 'Allows users to request a new anti-spambot task if they are unable to solve the current task during registration. Some plugins might not support this option.', -)); - -// Cookie Settings -$lang = array_merge($lang, array( - 'ACP_COOKIE_SETTINGS_EXPLAIN' => 'These details define the data used to send cookies to your users browsers. In most cases the default values for the cookie settings should be sufficient. If you do need to change any do so with care, incorrect settings can prevent users logging in. If you have problems with users staying logging in to your board, visit the phpBB.com Knowledge Base - Fixing incorrect cookie settings.', - - 'COOKIE_DOMAIN' => 'Cookie domain', - 'COOKIE_DOMAIN_EXPLAIN' => 'In most cases the cookie domain is optional. Leave it blank if you are unsure.

In the case where you have a board integrated with other software or have multiple domains, then to determine the cookie domain you need to do the following. If you have something like example.com and forums.example.com, or perhaps forums.example.com and blog.example.com. Remove the subdomains until you find the common domain, example.com. Now add a dot in front of the common domain and you would enter .example.com (note the dot at the beginning).', - 'COOKIE_NAME' => 'Cookie name', - 'COOKIE_NAME_EXPLAIN' => 'This can be anything what you want, make it original. Whenever the cookie settings are changed the name of the cookie should be changed.', - 'COOKIE_NOTICE' => 'Cookie notice', - 'COOKIE_NOTICE_EXPLAIN' => 'If enabled a cookie notice will be displayed to users when visiting your board. This might be required by law depending on the content of your board and enabled extensions.', - 'COOKIE_PATH' => 'Cookie path', - 'COOKIE_PATH_EXPLAIN' => 'This will usually be the same as your script path or simply a slash to make the cookie accessible across the site domain.', - 'COOKIE_SECURE' => 'Cookie secure', - 'COOKIE_SECURE_EXPLAIN' => 'If your server is running via SSL set this to enabled else leave as disabled. Having this enabled and not running via SSL will result in server errors during redirects.', - 'ONLINE_LENGTH' => 'View online time span', - 'ONLINE_LENGTH_EXPLAIN' => 'Number of minutes after which inactive users will not appear in “Who is online” listings. The higher this value the greater is the processing required to generate the listing.', - 'SESSION_LENGTH' => 'Session length', - 'SESSION_LENGTH_EXPLAIN' => 'Sessions will expire after this time, in seconds.', -)); - -// Contact Settings -$lang = array_merge($lang, array( - 'ACP_CONTACT_SETTINGS_EXPLAIN' => 'Here you can enable and disable the contact page and also add a text that is displayed on the page.', - - 'CONTACT_US_ENABLE' => 'Enable contact page', - 'CONTACT_US_ENABLE_EXPLAIN' => 'This page allows users to send emails to board administrators. Please note that board-wide emails option must be enabled as well. You can find this option in General > Client Communication > Email settings.', - - 'CONTACT_US_INFO' => 'Contact information', - 'CONTACT_US_INFO_EXPLAIN' => 'The message is displayed on the contact page', - 'CONTACT_US_INFO_PREVIEW' => 'Contact page information - Preview', - 'CONTACT_US_INFO_UPDATED' => 'Contact page information has been updated.', -)); - -// Load Settings -$lang = array_merge($lang, array( - 'ACP_LOAD_SETTINGS_EXPLAIN' => 'Here you can enable and disable certain board functions to reduce the amount of processing required. On most servers there is no need to disable any functions. However on certain systems or in shared hosting environments it may be beneficial to disable capabilities you do not really need. You can also specify limits for system load and active sessions beyond which the board will go offline.', - - 'ALLOW_CDN' => 'Allow usage of third party content delivery networks', - 'ALLOW_CDN_EXPLAIN' => 'If this setting is enabled, some files will be served from external third party servers instead of your server. This reduces the network bandwidth required by your server, but may present a privacy issue for some board administrators. In a default phpBB installation, this includes loading “jQuery” and the font “Open Sans” from Google’s content delivery network.', - 'ALLOW_LIVE_SEARCHES' => 'Allow live searches', - 'ALLOW_LIVE_SEARCHES_EXPLAIN' => 'If this setting is enabled, users are provided with keyword suggestions as they type in certain fields throughout the board.', - 'CUSTOM_PROFILE_FIELDS' => 'Custom profile fields', - 'LIMIT_LOAD' => 'Limit system load', - 'LIMIT_LOAD_EXPLAIN' => 'If the system’s 1-minute load average exceeds this value the board will automatically go offline. A value of 1.0 equals ~100% utilisation of one processor. This only functions on UNIX based servers and where this information is accessible. The value here resets itself to 0 if phpBB was unable to get the load limit.', - 'LIMIT_SESSIONS' => 'Limit sessions', - 'LIMIT_SESSIONS_EXPLAIN' => 'If the number of sessions exceeds this value within a one minute period the board will go offline. Set to 0 for unlimited sessions.', - 'LOAD_CPF_MEMBERLIST' => 'Allow styles to display custom profile fields in memberlist', - 'LOAD_CPF_PM' => 'Display custom profile fields in private messages', - 'LOAD_CPF_VIEWPROFILE' => 'Display custom profile fields in user profiles', - 'LOAD_CPF_VIEWTOPIC' => 'Display custom profile fields on topic pages', - 'LOAD_USER_ACTIVITY' => 'Show user’s activity', - 'LOAD_USER_ACTIVITY_EXPLAIN' => 'Displays active topic/forum in user profiles and user control panel. It is recommended to disable this on boards with more than one million posts.', - 'LOAD_USER_ACTIVITY_LIMIT' => 'User’s activity post limit', - 'LOAD_USER_ACTIVITY_LIMIT_EXPLAIN' => 'The active topic/forum won’t be shown for users having more than this number of posts. Set to 0 to disable the limit.', - 'READ_NOTIFICATION_EXPIRE_DAYS' => 'Read Notification Expiration', - 'READ_NOTIFICATION_EXPIRE_DAYS_EXPLAIN' => 'Number of days that will elapse before a read notification will automatically be deleted. Set this value to 0 to make notifications permanent.', - 'RECOMPILE_STYLES' => 'Recompile stale style components', - 'RECOMPILE_STYLES_EXPLAIN' => 'Check for updated style components on filesystem and recompile.', - 'YES_ACCURATE_PM_BUTTON' => 'Enable permission specific PM button in topic pages', - 'YES_ACCURATE_PM_BUTTON_EXPLAIN' => 'If this setting is enabled, only post profiles of users who are permitted to read private messages will have a private message button.', - 'YES_ANON_READ_MARKING' => 'Enable topic marking for guests', - 'YES_ANON_READ_MARKING_EXPLAIN' => 'Stores read/unread status information for guests. If disabled, posts are always marked read for guests.', - 'YES_BIRTHDAYS' => 'Enable birthday listing', - 'YES_BIRTHDAYS_EXPLAIN' => 'If disabled the birthday listing is no longer displayed. To let this setting take effect the birthday feature needs to be enabled too.', - 'YES_JUMPBOX' => 'Enable display of jumpbox', - 'YES_MODERATORS' => 'Enable display of moderators', - 'YES_ONLINE' => 'Enable online user listings', - 'YES_ONLINE_EXPLAIN' => 'Display online user information on index, forum and topic pages.', - 'YES_ONLINE_GUESTS' => 'Enable online guest listings in viewonline', - 'YES_ONLINE_GUESTS_EXPLAIN' => 'Allow display of guest user information in viewonline.', - 'YES_ONLINE_TRACK' => 'Enable display of user online/offline information', - 'YES_ONLINE_TRACK_EXPLAIN' => 'Display online information for user in profiles and topic pages.', - 'YES_POST_MARKING' => 'Enable dotted topics', - 'YES_POST_MARKING_EXPLAIN' => 'Indicates whether user has posted to a topic.', - 'YES_READ_MARKING' => 'Enable server-side topic marking', - 'YES_READ_MARKING_EXPLAIN' => 'Stores read/unread status information in the database rather than a cookie.', - 'YES_UNREAD_SEARCH' => 'Enable search for unread posts', -)); - -// Auth settings -$lang = array_merge($lang, array( - 'ACP_AUTH_SETTINGS_EXPLAIN' => 'phpBB supports authentication plug-ins, or modules. These allow you determine how users are authenticated when they log into the board. By default four plug-ins are provided: DB, LDAP, Apache, and OAuth. Not all methods require additional information so only fill out fields if they are relevant to the selected method.', - - 'AUTH_METHOD' => 'Select an authentication method', - - 'AUTH_PROVIDER_OAUTH_ERROR_ELEMENT_MISSING' => 'Both the key and secret of each enabled OAuth service provider must be provided. Only one was provided for an OAuth service provider.', - 'AUTH_PROVIDER_OAUTH_EXPLAIN' => 'Each OAuth provider requires a unique secret and key in order to authenticate with the external server. These should be supplied by the OAuth service when you register your website with them and should be entered exactly as provided to you.
Any service that does not have both a key and a secret entered here will not be available for use by the forum users. Also note, that user can still register and login using the DB authentication plug-in.', - 'AUTH_PROVIDER_OAUTH_KEY' => 'Key', - 'AUTH_PROVIDER_OAUTH_TITLE' => 'OAuth', - 'AUTH_PROVIDER_OAUTH_SECRET' => 'Secret', - - 'APACHE_SETUP_BEFORE_USE' => 'You have to setup apache authentication before you switch phpBB to this authentication method. Keep in mind that the username you use for apache authentication has to be the same as your phpBB username. Apache authentication can only be used with mod_php (not with a CGI version) and safe_mode disabled.', - - 'LDAP' => 'LDAP', - 'LDAP_DN' => 'LDAP base dn', - 'LDAP_DN_EXPLAIN' => 'This is the Distinguished Name, locating the user information, e.g. o=My Company,c=US.', - 'LDAP_EMAIL' => 'LDAP email attribute', - 'LDAP_EMAIL_EXPLAIN' => 'Set this to the name of your user entry email attribute (if one exists) in order to automatically set the email address for new users. Leaving this empty results in empty email address for users who log in for the first time.', - 'LDAP_INCORRECT_USER_PASSWORD' => 'Binding to LDAP server failed with specified user/password.', - 'LDAP_NO_EMAIL' => 'The specified email attribute does not exist.', - 'LDAP_NO_IDENTITY' => 'Could not find a login identity for %s.', - 'LDAP_PASSWORD' => 'LDAP password', - 'LDAP_PASSWORD_EXPLAIN' => 'Leave blank to use anonymous binding, otherwise fill in the password for the above user. Required for Active Directory Servers.
Warning: This password will be stored as plain text in the database, visible to everybody who can access your database or who can view this configuration page.', - 'LDAP_PORT' => 'LDAP server port', - 'LDAP_PORT_EXPLAIN' => 'Optionally you can specify a port which should be used to connect to the LDAP server instead of the default port 389.', - 'LDAP_SERVER' => 'LDAP server name', - 'LDAP_SERVER_EXPLAIN' => 'If using LDAP this is the hostname or IP address of the LDAP server. Alternatively you can specify an URL like ldap://hostname:port/', - 'LDAP_UID' => 'LDAP uid', - 'LDAP_UID_EXPLAIN' => 'This is the key under which to search for a given login identity, e.g. uid, sn, etc.', - 'LDAP_USER' => 'LDAP user dn', - 'LDAP_USER_EXPLAIN' => 'Leave blank to use anonymous binding. If filled in phpBB uses the specified distinguished name on login attempts to find the correct user, e.g. uid=Username,ou=MyUnit,o=MyCompany,c=US. Required for Active Directory Servers.', - 'LDAP_USER_FILTER' => 'LDAP user filter', - 'LDAP_USER_FILTER_EXPLAIN' => 'Optionally you can further limit the searched objects with additional filters. For example objectClass=posixGroup would result in the use of (&(uid=$username)(objectClass=posixGroup))', -)); - -// Server Settings -$lang = array_merge($lang, array( - 'ACP_SERVER_SETTINGS_EXPLAIN' => 'Here you define server and domain dependent settings. Please ensure the data you enter is accurate, errors will result in emails containing incorrect information. When entering the domain name remember it does include http:// or other protocol term. Only alter the port number if you know your server uses a different value, port 80 is correct in most cases.', - - 'ENABLE_GZIP' => 'Enable GZip compression', - 'ENABLE_GZIP_EXPLAIN' => 'Generated content will be compressed prior to sending it to the user. This can reduce network traffic but will also increase CPU usage on both server and client side. Requires zlib PHP extension to be loaded.', - 'FORCE_SERVER_VARS' => 'Force server URL settings', - 'FORCE_SERVER_VARS_EXPLAIN' => 'If set to yes the server settings defined here will be used in favour of the automatically determined values.', - 'ICONS_PATH' => 'Post icons storage path', - 'ICONS_PATH_EXPLAIN' => 'Path under your phpBB root directory, e.g. images/icons.', - 'MOD_REWRITE_ENABLE' => 'Enable URL Rewriting', - 'MOD_REWRITE_ENABLE_EXPLAIN' => 'When enabled, URLs containing ’app.php’ will be rewritten to remove the filename (i.e. app.php/foo will become /foo). Apache server’s mod_rewrite module is required for this functionality to work; if this option is enabled without mod_rewrite support, URLs on your board may be broken.', - 'MOD_REWRITE_DISABLED' => 'The mod_rewrite module on your Apache web server is disabled. Enable the module or contact your web hosting provider if you wish to enable this feature.', - 'MOD_REWRITE_INFORMATION_UNAVAILABLE' => 'We are unable to determine whether or not this server supports URL rewriting. This setting may be enabled but if URL rewriting is not available, paths generated by this board (such as for use in links) may be broken. Contact your web hosting provider if you are unsure whether or not you can safely enable this feature.', - 'PATH_SETTINGS' => 'Path settings', - 'RANKS_PATH' => 'Rank image storage path', - 'RANKS_PATH_EXPLAIN' => 'Path under your phpBB root directory, e.g. images/ranks.', - 'SCRIPT_PATH' => 'Script path', - 'SCRIPT_PATH_EXPLAIN' => 'The path where phpBB is located relative to the domain name, e.g. /phpBB3.', - 'SERVER_NAME' => 'Domain name', - 'SERVER_NAME_EXPLAIN' => 'The domain name this board runs from (for example: www.example.com).', - 'SERVER_PORT' => 'Server port', - 'SERVER_PORT_EXPLAIN' => 'The port your server is running on, usually 80, only change if different.', - 'SERVER_PROTOCOL' => 'Server protocol', - 'SERVER_PROTOCOL_EXPLAIN' => 'This is used as the server protocol if these settings are forced. If empty or not forced the protocol is determined by the cookie secure settings (http:// or https://).', - 'SERVER_URL_SETTINGS' => 'Server URL settings', - 'SMILIES_PATH' => 'Smilies storage path', - 'SMILIES_PATH_EXPLAIN' => 'Path under your phpBB root directory, e.g. images/smilies.', - 'UPLOAD_ICONS_PATH' => 'Extension group icons storage path', - 'UPLOAD_ICONS_PATH_EXPLAIN' => 'Path under your phpBB root directory, e.g. images/upload_icons.', - 'USE_SYSTEM_CRON' => 'Run periodic tasks from system cron', - 'USE_SYSTEM_CRON_EXPLAIN' => 'When off, phpBB will arrange for periodic tasks to be run automatically. When on, phpBB will not schedule any periodic tasks by itself; a system administrator must arrange for bin/phpbbcli.php cron:run to be run by the system cron facility at regular intervals (e.g. every 5 minutes).', -)); - -// Security Settings -$lang = array_merge($lang, array( - 'ACP_SECURITY_SETTINGS_EXPLAIN' => 'Here you are able to define session and login related settings.', - - 'ALL' => 'All', - 'ALLOW_AUTOLOGIN' => 'Allow "Remember Me" logins', - 'ALLOW_AUTOLOGIN_EXPLAIN' => 'Determines whether users are given "Remember Me" option when they visit the board.', - 'ALLOW_PASSWORD_RESET' => 'Allow password reset ("Forgot Password")', - 'ALLOW_PASSWORD_RESET_EXPLAIN' => 'Determines whether or not users are able to use the "I forgot my password" link on the login page to recover their account. If you use an external authentication mechanism you may wish to disable this feature.', - 'AUTOLOGIN_LENGTH' => '"Remember Me" login key expiration length (in days)', - 'AUTOLOGIN_LENGTH_EXPLAIN' => 'Number of days after which "Remember Me" login keys are removed or zero to disable.', - 'BROWSER_VALID' => 'Validate browser', - 'BROWSER_VALID_EXPLAIN' => 'Enables browser validation for each session improving security.', - 'CHECK_DNSBL' => 'Check IP against DNS Blackhole List', - 'CHECK_DNSBL_EXPLAIN' => 'If enabled the user’s IP address is checked against the following DNSBL services on registration and posting: spamcop.net and www.spamhaus.org. This lookup may take a while, depending on the server’s configuration. If slowdowns are experienced or too many false positives reported it is recommended to disable this check.', - 'CLASS_B' => 'A.B', - 'CLASS_C' => 'A.B.C', - 'EMAIL_CHECK_MX' => 'Check email domain for valid MX record', - 'EMAIL_CHECK_MX_EXPLAIN' => 'If enabled, the email domain provided on registration and profile changes is checked for a valid MX record.', - 'FORCE_PASS_CHANGE' => 'Force password change', - 'FORCE_PASS_CHANGE_EXPLAIN' => 'Require user to change their password after a set number of days. Setting this value to 0 disables this behaviour.', - 'FORM_TIME_MAX' => 'Maximum time to submit forms', - 'FORM_TIME_MAX_EXPLAIN' => 'The time a user has to submit a form. Use -1 to disable. Note that a form might become invalid if the session expires, regardless of this setting.', - 'FORM_SID_GUESTS' => 'Tie forms to guest sessions', - 'FORM_SID_GUESTS_EXPLAIN' => 'If enabled, the form token issued to guests will be session-exclusive. This can cause problems with some ISPs.', - 'FORWARDED_FOR_VALID' => 'Validate X_FORWARDED_FOR header', - 'FORWARDED_FOR_VALID_EXPLAIN' => 'Sessions will only be continued if the sent X_FORWARDED_FOR header equals the one sent with the previous request. Bans will be checked against IPs in X_FORWARDED_FOR too.', - 'IP_VALID' => 'Session IP validation', - 'IP_VALID_EXPLAIN' => 'Determines how much of the users IP is used to validate a session; All compares the complete address, A.B.C the first x.x.x, A.B the first x.x, None disables checking. On IPv6 addresses A.B.C compares the first 4 blocks and A.B the first 3 blocks.', - 'IP_LOGIN_LIMIT_MAX' => 'Maximum number of login attempts per IP address', - 'IP_LOGIN_LIMIT_MAX_EXPLAIN' => 'The threshold of login attempts allowed from a single IP address before an anti-spambot task is triggered. Enter 0 to prevent the anti-spambot task from being triggered by IP addresses.', - 'IP_LOGIN_LIMIT_TIME' => 'IP address login attempt expiration time', - 'IP_LOGIN_LIMIT_TIME_EXPLAIN' => 'Login attempts expire after this period.', - 'IP_LOGIN_LIMIT_USE_FORWARDED' => 'Limit login attempts by X_FORWARDED_FOR header', - 'IP_LOGIN_LIMIT_USE_FORWARDED_EXPLAIN' => 'Instead of limiting login attempts by IP address they are limited by X_FORWARDED_FOR values.
Warning: Only enable this if you are operating a proxy server that sets X_FORWARDED_FOR to trustworthy values.', - 'MAX_LOGIN_ATTEMPTS' => 'Maximum number of login attempts per username', - 'MAX_LOGIN_ATTEMPTS_EXPLAIN' => 'The number of login attempts allowed for a single account before the anti-spambot task is triggered. Enter 0 to prevent the anti-spambot task from being triggered for distinct user accounts.', - 'NO_IP_VALIDATION' => 'None', - 'NO_REF_VALIDATION' => 'None', - 'PASSWORD_TYPE' => 'Password complexity', - 'PASSWORD_TYPE_EXPLAIN' => 'Determines how complex a password needs to be when set or altered, subsequent options include the previous ones.', - 'PASS_TYPE_ALPHA' => 'Must contain letters and numbers', - 'PASS_TYPE_ANY' => 'No requirements', - 'PASS_TYPE_CASE' => 'Must be mixed case', - 'PASS_TYPE_SYMBOL' => 'Must contain symbols', - 'REF_HOST' => 'Only validate host', - 'REF_PATH' => 'Also validate path', - 'REFERRER_VALID' => 'Validate Referrer', - 'REFERRER_VALID_EXPLAIN' => 'If enabled, the referrer of POST requests will be checked against the host/script path settings. This may cause issues with boards using several domains and or external logins.', - 'TPL_ALLOW_PHP' => 'Allow php in templates', - 'TPL_ALLOW_PHP_EXPLAIN' => 'If this option is enabled, PHP and INCLUDEPHP statements will be recognised and parsed in templates.', - 'UPLOAD_CERT_VALID' => 'Validate upload certificate', - 'UPLOAD_CERT_VALID_EXPLAIN' => 'If enabled, certificates of remote uploads will be validated. This requires the CA bundle to be defined by the openssl.cafile or curl.cainfo setting in your php.ini.', -)); - -// Email Settings -$lang = array_merge($lang, array( - 'ACP_EMAIL_SETTINGS_EXPLAIN' => 'This information is used when the board sends emails to your users. Please ensure the email address you specify is valid, any bounced or undeliverable messages will likely be sent to that address. If your host does not provide a native (PHP based) email service you can instead send messages directly using SMTP. This requires the address of an appropriate server (ask your provider if necessary). If the server requires authentication (and only if it does) enter the necessary username, password and authentication method.', - - 'ADMIN_EMAIL' => 'From email address', - 'ADMIN_EMAIL_EXPLAIN' => 'This will be used as the from address on all emails, the technical contact email address. It will always be used as the Sender address in emails.', - 'BOARD_EMAIL_FORM' => 'Users send email via board', - 'BOARD_EMAIL_FORM_EXPLAIN' => 'Instead of showing the users email address users are able to send emails via the board.', - 'BOARD_HIDE_EMAILS' => 'Hide email addresses', - 'BOARD_HIDE_EMAILS_EXPLAIN' => 'This function keeps email addresses completely private.', - 'CONTACT_EMAIL' => 'Contact email address', - 'CONTACT_EMAIL_EXPLAIN' => 'This address will be used whenever a specific contact point is needed, e.g. spam, error output, etc. It will always be used as the From and Reply-To address in emails.', - 'CONTACT_EMAIL_NAME' => 'Contact name', - 'CONTACT_EMAIL_NAME_EXPLAIN' => 'This is the contact name that e-mail recipients will see. If you don’t want to have a contact name, leave this field empty.', - 'EMAIL_FORCE_SENDER' => 'Force from email address', - 'EMAIL_FORCE_SENDER_EXPLAIN' => 'This will set the Return-Path to the from email address instead of using the local user and hostname of the server. This setting does not apply when using SMTP.
Warning: Requires the user that the webserver runs as to be added as trusted user to the sendmail configuration.', - 'EMAIL_PACKAGE_SIZE' => 'Email package size', - 'EMAIL_PACKAGE_SIZE_EXPLAIN' => 'This is the number of maximum emails sent out in one package. This setting is applied to the internal message queue; set this value to 0 if you have problems with non-delivered notification emails.', - 'EMAIL_SIG' => 'Email signature', - 'EMAIL_SIG_EXPLAIN' => 'This text will be attached to all emails the board sends.', - 'ENABLE_EMAIL' => 'Enable board-wide emails', - 'ENABLE_EMAIL_EXPLAIN' => 'If this is set to disabled no emails will be sent by the board at all. Note the user and admin account activation settings require this setting to be enabled. If currently using “user” or “admin” activation in the activation settings, disabling this setting will disable registration.', - 'SEND_TEST_EMAIL' => 'Send a test email', - 'SEND_TEST_EMAIL_EXPLAIN' => 'This will send a test email to the address defined in your account.', - 'SMTP_ALLOW_SELF_SIGNED' => 'Allow self-signed SSL certificates', - 'SMTP_ALLOW_SELF_SIGNED_EXPLAIN'=> 'Allow connections to SMTP server with self-signed SSL certificate.
Warning: Allowing self-signed SSL certificates may cause security implications.', - 'SMTP_AUTH_METHOD' => 'Authentication method for SMTP', - 'SMTP_AUTH_METHOD_EXPLAIN' => 'Only used if a username/password is set, ask your provider if you are unsure which method to use.', - 'SMTP_CRAM_MD5' => 'CRAM-MD5', - 'SMTP_DIGEST_MD5' => 'DIGEST-MD5', - 'SMTP_LOGIN' => 'LOGIN', - 'SMTP_PASSWORD' => 'SMTP password', - 'SMTP_PASSWORD_EXPLAIN' => 'Only enter a password if your SMTP server requires it.
Warning: This password will be stored as plain text in the database, visible to everybody who can access your database or who can view this configuration page.', - 'SMTP_PLAIN' => 'PLAIN', - 'SMTP_POP_BEFORE_SMTP' => 'POP-BEFORE-SMTP', - 'SMTP_PORT' => 'SMTP server port', - 'SMTP_PORT_EXPLAIN' => 'Only change this if you know your SMTP server is on a different port.', - 'SMTP_SERVER' => 'SMTP server address and protocol', - 'SMTP_SERVER_EXPLAIN' => 'Note that you have to provide the protocol that your server uses. If you are using SSL, this has to be "ssl://your.mailserver.com"', - 'SMTP_SETTINGS' => 'SMTP settings', - 'SMTP_USERNAME' => 'SMTP username', - 'SMTP_USERNAME_EXPLAIN' => 'Only enter a username if your SMTP server requires it.', - 'SMTP_VERIFY_PEER' => 'Verify SSL certificate', - 'SMTP_VERIFY_PEER_EXPLAIN' => 'Require verification of SSL certificate used by SMTP server.
Warning: Connecting peers with unverified SSL certificates may cause security implications.', - 'SMTP_VERIFY_PEER_NAME' => 'Verify SMTP peer name', - 'SMTP_VERIFY_PEER_NAME_EXPLAIN' => 'Require verification of peer name for SMTP servers using SSL / TLS connections.
Warning: Connecting to unverified peers may cause security implications.', - 'TEST_EMAIL_SENT' => 'The test email has been sent.
If you don’t receive it, please check your emails configuration.

If you require assistance, please visit the phpBB support forums.', - - 'USE_SMTP' => 'Use SMTP server for email', - 'USE_SMTP_EXPLAIN' => 'Select “Yes” if you want or have to send email via a named server instead of the local mail function.', -)); - -// Jabber settings -$lang = array_merge($lang, array( - 'ACP_JABBER_SETTINGS_EXPLAIN' => 'Here you can enable and control the use of Jabber for instant messaging and board notifications. Jabber is an open source protocol and therefore available for use by anyone. Some Jabber servers include gateways or transports which allow you to contact users on other networks. Not all servers offer all transports and changes in protocols can prevent transports from operating. Please be sure to enter already registered account details - phpBB will use the details you enter here as is.', - - 'JAB_ALLOW_SELF_SIGNED' => 'Allow self-signed SSL certificates', - 'JAB_ALLOW_SELF_SIGNED_EXPLAIN' => 'Allow connections to Jabber server with self-signed SSL certificate.
Warning: Allowing self-signed SSL certificates may cause security implications.', - 'JAB_ENABLE' => 'Enable Jabber', - 'JAB_ENABLE_EXPLAIN' => 'Enables use of Jabber messaging and notifications.', - 'JAB_GTALK_NOTE' => 'Please note that GTalk will not work because the dns_get_record function could not be found. This function is not available in PHP4, and is not implemented on Windows platforms. It currently does not work on BSD-based systems, including Mac OS.', - 'JAB_PACKAGE_SIZE' => 'Jabber package size', - 'JAB_PACKAGE_SIZE_EXPLAIN' => 'This is the number of messages sent in one package. If set to 0 the message is sent immediately and will not be queued for later sending.', - 'JAB_PASSWORD' => 'Jabber password', - 'JAB_PASSWORD_EXPLAIN' => 'Warning: This password will be stored as plain text in the database, visible to everybody who can access your database or who can view this configuration page.', - 'JAB_PORT' => 'Jabber port', - 'JAB_PORT_EXPLAIN' => 'Leave blank unless you know it is not port 5222.', - 'JAB_SERVER' => 'Jabber server', - 'JAB_SERVER_EXPLAIN' => 'See %sjabber.org%s for a list of servers.', - 'JAB_SETTINGS_CHANGED' => 'Jabber settings changed successfully.', - 'JAB_USE_SSL' => 'Use SSL to connect', - 'JAB_USE_SSL_EXPLAIN' => 'If enabled a secure connection is tried to be established. The Jabber port will be modified to 5223 if port 5222 is specified.', - 'JAB_USERNAME' => 'Jabber username or JID', - 'JAB_USERNAME_EXPLAIN' => 'Specify a registered username or a valid JID. The username will not be checked for validity. If you only specify a username, then your JID will be the username and the server you specified above. Else, specify a valid JID, for example user@jabber.org.', - 'JAB_VERIFY_PEER' => 'Verify SSL certificate', - 'JAB_VERIFY_PEER_EXPLAIN' => 'Require verification of SSL certificate used by Jabber server.
Warning: Connecting peers with unverified SSL certificates may cause security implications.', - 'JAB_VERIFY_PEER_NAME' => 'Verify Jabber peer name', - 'JAB_VERIFY_PEER_NAME_EXPLAIN' => 'Require verification of peer name for Jabber servers using SSL / TLS connections.
Warning: Connecting to unverified peers may cause security implications.', -)); diff --git a/install/update/old/language/en/acp/common.php b/install/update/old/language/en/acp/common.php deleted file mode 100644 index 1c22535..0000000 --- a/install/update/old/language/en/acp/common.php +++ /dev/null @@ -1,833 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* DO NOT CHANGE -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -if (empty($lang) || !is_array($lang)) -{ - $lang = array(); -} - -// DEVELOPERS PLEASE NOTE -// -// All language files should use UTF-8 as their encoding and the files must not contain a BOM. -// -// Placeholders can now contain order information, e.g. instead of -// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows -// translators to re-order the output of data while ensuring it remains correct -// -// You do not need this where single placeholders are used, e.g. 'Message %d' is fine -// equally where a string contains only two placeholders which are used to wrap text -// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine - -// Common -$lang = array_merge($lang, array( - 'ACP_ADMINISTRATORS' => 'Administrators', - 'ACP_ADMIN_LOGS' => 'Admin log', - 'ACP_ADMIN_ROLES' => 'Admin roles', - 'ACP_ATTACHMENTS' => 'Attachments', - 'ACP_ATTACHMENT_SETTINGS' => 'Attachment settings', - 'ACP_AUTH_SETTINGS' => 'Authentication', - 'ACP_AUTOMATION' => 'Automation', - 'ACP_AVATAR_SETTINGS' => 'Avatar settings', - - 'ACP_BACKUP' => 'Backup', - 'ACP_BAN' => 'Banning', - 'ACP_BAN_EMAILS' => 'Ban emails', - 'ACP_BAN_IPS' => 'Ban IPs', - 'ACP_BAN_USERNAMES' => 'Ban users', - 'ACP_BBCODES' => 'BBCodes', - 'ACP_BOARD_CONFIGURATION' => 'Board configuration', - 'ACP_BOARD_FEATURES' => 'Board features', - 'ACP_BOARD_MANAGEMENT' => 'Board management', - 'ACP_BOARD_SETTINGS' => 'Board settings', - 'ACP_BOTS' => 'Spiders/Robots', - - 'ACP_CAPTCHA' => 'CAPTCHA', - - 'ACP_CAT_CUSTOMISE' => 'Customise', - 'ACP_CAT_DATABASE' => 'Database', - 'ACP_CAT_DOT_MODS' => 'Extensions', - 'ACP_CAT_FORUMS' => 'Forums', - 'ACP_CAT_GENERAL' => 'General', - 'ACP_CAT_MAINTENANCE' => 'Maintenance', - 'ACP_CAT_PERMISSIONS' => 'Permissions', - 'ACP_CAT_POSTING' => 'Posting', - 'ACP_CAT_STYLES' => 'Styles', - 'ACP_CAT_SYSTEM' => 'System', - 'ACP_CAT_USERGROUP' => 'Users and Groups', - 'ACP_CAT_USERS' => 'Users', - 'ACP_CLIENT_COMMUNICATION' => 'Client communication', - 'ACP_COOKIE_SETTINGS' => 'Cookie settings', - 'ACP_CONTACT' => 'Contact page', - 'ACP_CONTACT_SETTINGS' => 'Contact page settings', - 'ACP_CRITICAL_LOGS' => 'Error log', - 'ACP_CUSTOM_PROFILE_FIELDS' => 'Custom profile fields', - - 'ACP_DATABASE' => 'Database management', - 'ACP_DISALLOW' => 'Disallow', - 'ACP_DISALLOW_USERNAMES' => 'Disallow usernames', - - 'ACP_EMAIL_SETTINGS' => 'Email settings', - 'ACP_EXTENSION_GROUPS' => 'Manage attachment extension groups', - 'ACP_EXTENSION_MANAGEMENT' => 'Extension management', - 'ACP_EXTENSIONS' => 'Manage extensions', - - 'ACP_FORUM_BASED_PERMISSIONS' => 'Forum based permissions', - 'ACP_FORUM_LOGS' => 'Forum logs', - 'ACP_FORUM_MANAGEMENT' => 'Forum management', - 'ACP_FORUM_MODERATORS' => 'Forum moderators', - 'ACP_FORUM_PERMISSIONS' => 'Forum permissions', - 'ACP_FORUM_PERMISSIONS_COPY' => 'Copy forum permissions', - 'ACP_FORUM_ROLES' => 'Forum roles', - - 'ACP_GENERAL_CONFIGURATION' => 'General configuration', - 'ACP_GENERAL_TASKS' => 'General tasks', - 'ACP_GLOBAL_MODERATORS' => 'Global moderators', - 'ACP_GLOBAL_PERMISSIONS' => 'Global permissions', - 'ACP_GROUPS' => 'Groups', - 'ACP_GROUPS_FORUM_PERMISSIONS' => 'Group forum permissions', - 'ACP_GROUPS_MANAGE' => 'Manage groups', - 'ACP_GROUPS_MANAGEMENT' => 'Group management', - 'ACP_GROUPS_PERMISSIONS' => 'Group permissions', - 'ACP_GROUPS_POSITION' => 'Manage group positions', - - 'ACP_HELP_PHPBB' => 'Help support phpBB', - - 'ACP_ICONS' => 'Topic icons', - 'ACP_ICONS_SMILIES' => 'Topic icons/smilies', - 'ACP_INACTIVE_USERS' => 'Inactive users', - 'ACP_INDEX' => 'ACP index', - - 'ACP_JABBER_SETTINGS' => 'Jabber settings', - - 'ACP_LANGUAGE' => 'Language management', - 'ACP_LANGUAGE_PACKS' => 'Language packs', - 'ACP_LOAD_SETTINGS' => 'Load settings', - 'ACP_LOGGING' => 'Logging', - - 'ACP_MAIN' => 'ACP index', - - 'ACP_MANAGE_ATTACHMENTS' => 'Manage attachments', - 'ACP_MANAGE_ATTACHMENTS_EXPLAIN' => 'Here you can list and delete files attached to posts and private messages.', - - 'ACP_MANAGE_EXTENSIONS' => 'Manage attachment extensions', - 'ACP_MANAGE_FORUMS' => 'Manage forums', - 'ACP_MANAGE_RANKS' => 'Manage ranks', - 'ACP_MANAGE_REASONS' => 'Manage report/denial reasons', - 'ACP_MANAGE_USERS' => 'Manage users', - 'ACP_MASS_EMAIL' => 'Mass email', - 'ACP_MESSAGES' => 'Messages', - 'ACP_MESSAGE_SETTINGS' => 'Private message settings', - 'ACP_MODULE_MANAGEMENT' => 'Module management', - 'ACP_MOD_LOGS' => 'Moderator log', - 'ACP_MOD_ROLES' => 'Moderator roles', - - 'ACP_NO_ITEMS' => 'There are no items yet.', - - 'ACP_ORPHAN_ATTACHMENTS' => 'Orphaned attachments', - - 'ACP_PERMISSIONS' => 'Permissions', - 'ACP_PERMISSION_MASKS' => 'Permission masks', - 'ACP_PERMISSION_ROLES' => 'Permission roles', - 'ACP_PERMISSION_TRACE' => 'Permission trace', - 'ACP_PHP_INFO' => 'PHP information', - 'ACP_POST_SETTINGS' => 'Post settings', - 'ACP_PRUNE_FORUMS' => 'Prune forums', - 'ACP_PRUNE_USERS' => 'Prune users', - 'ACP_PRUNING' => 'Pruning', - - 'ACP_QUICK_ACCESS' => 'Quick access', - - 'ACP_RANKS' => 'Ranks', - 'ACP_REASONS' => 'Report/denial reasons', - 'ACP_REGISTER_SETTINGS' => 'User registration settings', - - 'ACP_RESTORE' => 'Restore', - - 'ACP_FEED' => 'Feed management', - 'ACP_FEED_SETTINGS' => 'Feed settings', - - 'ACP_SEARCH' => 'Search configuration', - 'ACP_SEARCH_INDEX' => 'Search index', - 'ACP_SEARCH_SETTINGS' => 'Search settings', - - 'ACP_SECURITY_SETTINGS' => 'Security settings', - 'ACP_SERVER_CONFIGURATION' => 'Server configuration', - 'ACP_SERVER_SETTINGS' => 'Server settings', - 'ACP_SIGNATURE_SETTINGS' => 'Signature settings', - 'ACP_SMILIES' => 'Smilies', - 'ACP_STYLE_MANAGEMENT' => 'Style management', - 'ACP_STYLES' => 'Styles', - 'ACP_STYLES_CACHE' => 'Purge Cache', - 'ACP_STYLES_INSTALL' => 'Install Styles', - - 'ACP_SUBMIT_CHANGES' => 'Submit changes', - - 'ACP_TEMPLATES' => 'Templates', - 'ACP_THEMES' => 'Themes', - - 'ACP_UPDATE' => 'Updating', - 'ACP_USERS_FORUM_PERMISSIONS' => 'User forum permissions', - 'ACP_USERS_LOGS' => 'User logs', - 'ACP_USERS_PERMISSIONS' => 'User permissions', - 'ACP_USER_ATTACH' => 'Attachments', - 'ACP_USER_AVATAR' => 'Avatar', - 'ACP_USER_FEEDBACK' => 'Feedback', - 'ACP_USER_GROUPS' => 'Groups', - 'ACP_USER_MANAGEMENT' => 'User management', - 'ACP_USER_OVERVIEW' => 'Overview', - 'ACP_USER_PERM' => 'Permissions', - 'ACP_USER_PREFS' => 'Preferences', - 'ACP_USER_PROFILE' => 'Profile', - 'ACP_USER_RANK' => 'Rank', - 'ACP_USER_ROLES' => 'User roles', - 'ACP_USER_SECURITY' => 'User security', - 'ACP_USER_SIG' => 'Signature', - 'ACP_USER_WARNINGS' => 'Warnings', - - 'ACP_VC_SETTINGS' => 'Spambot countermeasures', - 'ACP_VC_CAPTCHA_DISPLAY' => 'CAPTCHA image preview', - 'ACP_VERSION_CHECK' => 'Check for updates', - 'ACP_VIEW_ADMIN_PERMISSIONS' => 'View administrative permissions', - 'ACP_VIEW_FORUM_MOD_PERMISSIONS' => 'View forum moderation permissions', - 'ACP_VIEW_FORUM_PERMISSIONS' => 'View forum-based permissions', - 'ACP_VIEW_GLOBAL_MOD_PERMISSIONS' => 'View global moderation permissions', - 'ACP_VIEW_USER_PERMISSIONS' => 'View user-based permissions', - - 'ACP_WORDS' => 'Word censoring', - - 'ACTION' => 'Action', - 'ACTIONS' => 'Actions', - 'ACTIVATE' => 'Activate', - 'ADD' => 'Add', - 'ADMIN' => 'Administration', - 'ADMIN_INDEX' => 'Admin index', - 'ADMIN_PANEL' => 'Administration Control Panel', - - 'ADM_LOGOUT' => 'ACP Logout', - 'ADM_LOGGED_OUT' => 'Successfully logged out from Administration Control Panel', - - 'BACK' => 'Back', - - 'CANNOT_CHANGE_FILE_GROUP' => 'Unable to change file group', - 'CANNOT_CHANGE_FILE_PERMISSIONS' => 'Unable to change file permissions', - 'CANNOT_COPY_FILES' => 'Unable to copy files', - 'CANNOT_CREATE_SYMLINK' => 'Unable to create a symlink', - 'CANNOT_DELETE_FILES' => 'Unable to delete files from the system', - 'CANNOT_DUMP_FILE' => 'Unable to dump file', - 'CANNOT_MIRROR_DIRECTORY' => 'Unable to mirror directory', - 'CANNOT_RENAME_FILE' => 'Unable to rename a file from the system', - 'CANNOT_TOUCH_FILES' => 'Unable to determine if the file exists', - - 'CONTAINER_EXCEPTION' => 'phpBB encountered an error building the container due to an installed extension. For this reason, all extensions have been temporarily disabled. Please try purging your forum cache. All extensions will automatically be re-enabled once the container error is resolved. If this error continues, please visit phpBB.com for support.', - 'EXCEPTION' => 'Exception', - - 'COLOUR_SWATCH' => 'Web-safe colour swatch', - 'CONFIG_UPDATED' => 'Configuration updated successfully.', - 'CRON_LOCK_ERROR' => 'Could not obtain cron lock.', - 'CRON_NO_SUCH_TASK' => 'Could not find cron task “%s”.', - 'CRON_NO_TASK' => 'No cron tasks need to be run right now.', - 'CRON_NO_TASKS' => 'No cron tasks could be found.', - 'CURRENT_VERSION' => 'Current version', - - 'DEACTIVATE' => 'Deactivate', - 'DIRECTORY_DOES_NOT_EXIST' => 'The entered path “%s” does not exist.', - 'DIRECTORY_NOT_DIR' => 'The entered path “%s” is not a directory.', - 'DIRECTORY_NOT_WRITABLE' => 'The entered path “%s” is not writable.', - 'DISABLE' => 'Disable', - 'DOWNLOAD' => 'Download', - 'DOWNLOAD_AS' => 'Download as', - 'DOWNLOAD_STORE' => 'Download or store file', - 'DOWNLOAD_STORE_EXPLAIN' => 'You may directly download the file or save it in your store/ folder.', - 'DOWNLOADS' => 'Downloads', - - 'EDIT' => 'Edit', - 'ENABLE' => 'Enable', - 'EXPORT_DOWNLOAD' => 'Download', - 'EXPORT_STORE' => 'Store', - - 'GENERAL_OPTIONS' => 'General options', - 'GENERAL_SETTINGS' => 'General settings', - 'GLOBAL_MASK' => 'Global permission mask', - - 'INSTALL' => 'Install', - 'IP' => 'User IP', - 'IP_HOSTNAME' => 'IP addresses or hostnames', - - 'LATEST_VERSION' => 'Latest version', - 'LOAD_NOTIFICATIONS' => 'Display Notifications', - 'LOAD_NOTIFICATIONS_EXPLAIN' => 'Display the notifications list on every page (typically in the header).', - 'LOGGED_IN_AS' => 'You are logged in as:', - 'LOGIN_ADMIN' => 'To administer the board you must be an authenticated user.', - 'LOGIN_ADMIN_CONFIRM' => 'To administer the board you must re-authenticate yourself.', - 'LOGIN_ADMIN_SUCCESS' => 'You have successfully authenticated and will now be redirected to the Administration Control Panel.', - 'LOOK_UP_FORUM' => 'Select a forum', - 'LOOK_UP_FORUMS_EXPLAIN'=> 'You are able to select more than one forum.', - - 'MANAGE' => 'Manage', - 'MENU_TOGGLE' => 'Hide or display the side menu', - 'MORE' => 'More', // Not used at the moment - 'MORE_INFORMATION' => 'More information »', - 'MOVE_DOWN' => 'Move down', - 'MOVE_UP' => 'Move up', - - 'NOTIFY' => 'Notification', - 'NO_ADMIN' => 'You are not authorised to administer this board.', - 'NO_EMAILS_DEFINED' => 'No valid email addresses found.', - 'NO_FILES_TO_DELETE' => 'Attachments you selected for deletion do not exist.', - 'NO_PASSWORD_SUPPLIED' => 'You need to enter your password to access the Administration Control Panel.', - - 'OFF' => 'Off', - 'ON' => 'On', - - 'PARSE_BBCODE' => 'Parse BBCode', - 'PARSE_SMILIES' => 'Parse smilies', - 'PARSE_URLS' => 'Parse links', - 'PERMISSIONS_TRANSFERRED' => 'Permissions transferred', - 'PERMISSIONS_TRANSFERRED_EXPLAIN' => 'You currently have the permissions from %1$s. You are able to browse the board with this user’s permissions, but not access the administration control panel since admin permissions were not transferred. You can revert to your permission set at any time.', - 'PROCEED_TO_ACP' => '%sProceed to the ACP%s', - - 'RELEASE_ANNOUNCEMENT' => 'Announcement', - 'REMIND' => 'Remind', - 'REPARSE_LOCK_ERROR' => 'Reparsing is already in progress by another process.', - 'RESYNC' => 'Resynchronise', - - 'RUNNING_TASK' => 'Running task: %s.', - 'SELECT_ANONYMOUS' => 'Select anonymous user', - 'SELECT_OPTION' => 'Select option', - - 'SETTING_TOO_LOW' => 'The provided value for the setting “%1$s” is too low. The minimum acceptable value is %2$d.', - 'SETTING_TOO_BIG' => 'The provided value for the setting “%1$s” is too high. The maximum acceptable value is %2$d.', - 'SETTING_TOO_LONG' => 'The provided value for the setting “%1$s” is too long. The maximum acceptable length is %2$d.', - 'SETTING_TOO_SHORT' => 'The provided value for the setting “%1$s” is too short. The minimum acceptable length is %2$d.', - - 'SHOW_ALL_OPERATIONS' => 'Show all operations', - - 'TASKS_NOT_READY' => 'Not ready tasks:', - 'TASKS_READY' => 'Ready tasks:', - 'TOTAL_SIZE' => 'Total size', - - 'UCP' => 'User Control Panel', - 'URL_INVALID' => 'The provided URL for the setting “%1$s” is invalid.', - 'USERNAMES_EXPLAIN' => 'Place each username on a separate line.', - 'USER_CONTROL_PANEL' => 'User Control Panel', - - 'UPDATE_NEEDED' => 'The board is not up to date.', - 'UPDATE_NOT_NEEDED' => 'The board is up to date.', - 'UPDATES_AVAILABLE' => 'Updates available:', - - 'WARNING' => 'Warning', -)); - -// PHP info -$lang = array_merge($lang, array( - 'ACP_PHP_INFO_EXPLAIN' => 'This page lists information on the version of PHP installed on this server. It includes details of loaded modules, available variables and default settings. This information may be useful when diagnosing problems. Please be aware that some hosting companies will limit what information is displayed here for security reasons. You are advised to not give out any details on this page except when asked by official team members on the support forums.', - - 'NO_PHPINFO_AVAILABLE' => 'Information about your PHP configuration is unable to be determined. Phpinfo() has been disabled for security reasons.', -)); - -// Logs -$lang = array_merge($lang, array( - 'ACP_ADMIN_LOGS_EXPLAIN' => 'This lists all the actions carried out by board administrators. You can sort by username, date, IP or action. If you have appropriate permissions you can also clear individual operations or the log as a whole.', - 'ACP_CRITICAL_LOGS_EXPLAIN' => 'This lists the actions carried out by the board itself. This log provides you with information you are able to use for solving specific problems, for example non-delivery of emails. You can sort by username, date, IP or action. If you have appropriate permissions you can also clear individual operations or the log as a whole.', - 'ACP_MOD_LOGS_EXPLAIN' => 'This lists all actions done on forums, topics and posts as well as actions carried out on users by moderators, including banning. You can sort by username, date, IP or action. If you have appropriate permissions you can also clear individual operations or the log as a whole.', - 'ACP_USERS_LOGS_EXPLAIN' => 'This lists all actions carried out by users or on users (reports, warnings and user notes).', - 'ALL_ENTRIES' => 'All entries', - - 'DISPLAY_LOG' => 'Display entries from previous', - - 'NO_ENTRIES' => 'No log entries for this period.', - - 'SORT_IP' => 'IP address', - 'SORT_DATE' => 'Date', - 'SORT_ACTION' => 'Log action', -)); - -// Index page -$lang = array_merge($lang, array( - 'ADMIN_INTRO' => 'Thank you for choosing phpBB as your board solution. This screen will give you a quick overview of all the various statistics of your board. The links on the left hand side of this screen allow you to control every aspect of your board experience. Each page will have instructions on how to use the tools.', - 'ADMIN_LOG' => 'Logged administrator actions', - 'ADMIN_LOG_INDEX_EXPLAIN' => 'This gives an overview of the last five actions carried out by board administrators. A full copy of the log can be viewed from the appropriate menu item or following the link below.', - 'AVATAR_DIR_SIZE' => 'Avatar directory size', - - 'BOARD_STARTED' => 'Board started', - 'BOARD_VERSION' => 'Board version', - - 'DATABASE_SERVER_INFO' => 'Database server', - 'DATABASE_SIZE' => 'Database size', - - // Enviroment configuration checks, mbstring related - 'ERROR_MBSTRING_FUNC_OVERLOAD' => 'Function overloading is improperly configured', - 'ERROR_MBSTRING_FUNC_OVERLOAD_EXPLAIN' => 'mbstring.func_overload must be set to either 0 or 4. You can check the current value on the PHP information page.', - 'ERROR_MBSTRING_ENCODING_TRANSLATION' => 'Transparent character encoding is improperly configured', - 'ERROR_MBSTRING_ENCODING_TRANSLATION_EXPLAIN' => 'mbstring.encoding_translation must be set to 0. You can check the current value on the PHP information page.', - 'ERROR_MBSTRING_HTTP_INPUT' => 'HTTP input character conversion is improperly configured', - 'ERROR_MBSTRING_HTTP_INPUT_EXPLAIN' => 'mbstring.http_input must be set to pass. You can check the current value on the PHP information page.', - 'ERROR_MBSTRING_HTTP_OUTPUT' => 'HTTP output character conversion is improperly configured', - 'ERROR_MBSTRING_HTTP_OUTPUT_EXPLAIN' => 'mbstring.http_output must be set to pass. You can check the current value on the PHP information page.', - - 'FILES_PER_DAY' => 'Attachments per day', - 'FORUM_STATS' => 'Board statistics', - - 'GZIP_COMPRESSION' => 'GZip compression', - - 'NO_SEARCH_INDEX' => 'The selected search backend does not have a search index.
Please create the index for “%1$s” in the %2$ssearch index%3$s section.', - 'NOT_AVAILABLE' => 'Not available', - 'NUMBER_FILES' => 'Number of attachments', - 'NUMBER_POSTS' => 'Number of posts', - 'NUMBER_TOPICS' => 'Number of topics', - 'NUMBER_USERS' => 'Number of users', - 'NUMBER_ORPHAN' => 'Orphan attachments', - - 'PHP_VERSION' => 'PHP version', - 'PHP_VERSION_OLD' => 'The version of PHP on this server (%1$s) will no longer be supported by future versions of phpBB. The minimum required version will be PHP %2$s. %3$sDetails%4$s', - - 'POSTS_PER_DAY' => 'Posts per day', - - 'PURGE_CACHE' => 'Purge the cache', - 'PURGE_CACHE_CONFIRM' => 'Are you sure you wish to purge the cache?', - 'PURGE_CACHE_EXPLAIN' => 'Purge all cache related items, this includes any cached template files or queries.', - 'PURGE_CACHE_SUCCESS' => 'Cache successfully purged.', - - 'PURGE_SESSIONS' => 'Purge all sessions', - 'PURGE_SESSIONS_CONFIRM' => 'Are you sure you wish to purge all sessions? This will log out all users.', - 'PURGE_SESSIONS_EXPLAIN' => 'Purge all sessions. This will log out all users by truncating the session table.', - 'PURGE_SESSIONS_SUCCESS' => 'Sessions successfully purged.', - - 'RESET_DATE' => 'Reset board’s start date', - 'RESET_DATE_CONFIRM' => 'Are you sure you wish to reset the board’s start date?', - 'RESET_DATE_SUCCESS' => 'Board’s start date reset', - 'RESET_ONLINE' => 'Reset most users ever online', - 'RESET_ONLINE_CONFIRM' => 'Are you sure you wish to reset the most users ever online counter?', - 'RESET_ONLINE_SUCCESS' => 'Most users ever online reset', - 'RESYNC_POSTCOUNTS' => 'Resynchronise post counts', - 'RESYNC_POSTCOUNTS_EXPLAIN' => 'Only existing posts will be taken into consideration. Pruned posts will not be counted.', - 'RESYNC_POSTCOUNTS_CONFIRM' => 'Are you sure you wish to resynchronise post counts?', - 'RESYNC_POSTCOUNTS_SUCCESS' => 'Resynchronised post counts', - 'RESYNC_POST_MARKING' => 'Resynchronise dotted topics', - 'RESYNC_POST_MARKING_CONFIRM' => 'Are you sure you wish to resynchronise dotted topics?', - 'RESYNC_POST_MARKING_EXPLAIN' => 'First unmarks all topics and then correctly marks topics that have seen any activity during the past six months.', - 'RESYNC_POST_MARKING_SUCCESS' => 'Resynchronised dotted topics', - 'RESYNC_STATS' => 'Resynchronise statistics', - 'RESYNC_STATS_CONFIRM' => 'Are you sure you wish to resynchronise statistics?', - 'RESYNC_STATS_EXPLAIN' => 'Recalculates the total number of posts, topics, users and files.', - 'RESYNC_STATS_SUCCESS' => 'Resynchronised statistics', - 'RUN' => 'Run now', - - 'STATISTIC' => 'Statistic', - 'STATISTIC_RESYNC_OPTIONS' => 'Resynchronise or reset statistics', - - 'TIMEZONE_INVALID' => 'The timezone you selected is invalid.', - 'TIMEZONE_SELECTED' => '(currently selected)', - 'TOPICS_PER_DAY' => 'Topics per day', - - 'UPLOAD_DIR_SIZE' => 'Size of posted attachments', - 'USERS_PER_DAY' => 'Users per day', - - 'VALUE' => 'Value', - 'VERSIONCHECK_FAIL' => 'Failed to obtain latest version information.', - 'VERSIONCHECK_FORCE_UPDATE' => 'Re-Check version', - 'VERSION_CHECK' => 'Version check', - 'VERSION_CHECK_EXPLAIN' => 'Checks to see if your phpBB installation is up to date.', - 'VERSIONCHECK_INVALID_ENTRY' => 'Latest version information contains an unsupported entry.', - 'VERSIONCHECK_INVALID_URL' => 'Latest version information contains invalid URL.', - 'VERSIONCHECK_INVALID_VERSION' => 'Latest version information contains an invalid version.', - 'VERSION_NOT_UP_TO_DATE_ACP' => 'Your phpBB installation is not up to date.
Below is a link to the release announcement, which contains more information as well as instructions on updating.', - 'VERSION_NOT_UP_TO_DATE_TITLE' => 'Your phpBB installation is not up to date.', - 'VERSION_UP_TO_DATE_ACP' => 'Your phpBB installation is up to date. There are no updates available at this time.', - 'VIEW_ADMIN_LOG' => 'View administrator log', - 'VIEW_INACTIVE_USERS' => 'View inactive users', - - 'WELCOME_PHPBB' => 'Welcome to phpBB', - 'WRITABLE_CONFIG' => 'Your config file (config.php) is currently world-writable. We strongly encourage you to change the permissions to 640 or at least to 644 (for example: chmod 640 config.php).', -)); - -// Inactive Users -$lang = array_merge($lang, array( - 'INACTIVE_DATE' => 'Inactive date', - 'INACTIVE_REASON' => 'Reason', - 'INACTIVE_REASON_MANUAL' => 'Account deactivated by administrator', - 'INACTIVE_REASON_PROFILE' => 'Profile details changed', - 'INACTIVE_REASON_REGISTER' => 'Newly registered account', - 'INACTIVE_REASON_REMIND' => 'Forced user account reactivation', - 'INACTIVE_REASON_UNKNOWN' => 'Unknown', - 'INACTIVE_USERS' => 'Inactive users', - 'INACTIVE_USERS_EXPLAIN' => 'This is a list of users who have registered but whose accounts are inactive. You can activate, delete or remind (by sending an email) these users if you wish.', - 'INACTIVE_USERS_EXPLAIN_INDEX' => 'This is a list of the last 10 registered users who have inactive accounts. Accounts are inactive either because account activation was enabled in user registration settings and these users’ accounts have not yet been activated, or because these accounts have been deactivated. A full list is available by following the link below from where you can activate, delete or remind (by sending an email) these users if you wish.', - - 'NO_INACTIVE_USERS' => 'No inactive users', - - 'SORT_INACTIVE' => 'Inactive date', - 'SORT_LAST_VISIT' => 'Last visit', - 'SORT_REASON' => 'Reason', - 'SORT_REG_DATE' => 'Registration date', - 'SORT_LAST_REMINDER'=> 'Last reminded', - 'SORT_REMINDER' => 'Reminder sent', - - 'USER_IS_INACTIVE' => 'User is inactive', -)); - -// Help support phpBB page -$lang = array_merge($lang, array( - 'EXPLAIN_SEND_STATISTICS' => 'Please send information about your server and board configurations to phpBB for statistical analysis. All information that could identify you or your website has been removed - the data is entirely anonymous. We base decisions about future phpBB versions on this information. The statistics are made available publically. We also share this data with the PHP project, the programming language phpBB is made with.', - 'EXPLAIN_SHOW_STATISTICS' => 'Using the button below you can preview all variables that will be transmitted.', - 'DONT_SEND_STATISTICS' => 'Return to the ACP if you do not wish to send statistical information to phpBB.', - 'GO_ACP_MAIN' => 'Go to the ACP start page', - 'HIDE_STATISTICS' => 'Hide details', - 'SEND_STATISTICS' => 'Send statistics', - 'SEND_STATISTICS_LONG' => 'Send statistical information', - 'SHOW_STATISTICS' => 'Show details', - 'THANKS_SEND_STATISTICS' => 'Thank you for submitting your information.', - 'FAIL_SEND_STATISTICS' => 'phpBB was unable to send statistics', -)); - -// Log Entries -$lang = array_merge($lang, array( - 'LOG_ACL_ADD_USER_GLOBAL_U_' => 'Added or edited users’ user permissions
» %s', - 'LOG_ACL_ADD_GROUP_GLOBAL_U_' => 'Added or edited groups’ user permissions
» %s', - 'LOG_ACL_ADD_USER_GLOBAL_M_' => 'Added or edited users’ global moderator permissions
» %s', - 'LOG_ACL_ADD_GROUP_GLOBAL_M_' => 'Added or edited groups’ global moderator permissions
» %s', - 'LOG_ACL_ADD_USER_GLOBAL_A_' => 'Added or edited users’ administrator permissions
» %s', - 'LOG_ACL_ADD_GROUP_GLOBAL_A_' => 'Added or edited groups’ administrator permissions
» %s', - - 'LOG_ACL_ADD_ADMIN_GLOBAL_A_' => 'Added or edited Administrators
» %s', - 'LOG_ACL_ADD_MOD_GLOBAL_M_' => 'Added or edited Global Moderators
» %s', - - 'LOG_ACL_ADD_USER_LOCAL_F_' => 'Added or edited users’ forum access from %1$s
» %2$s', - 'LOG_ACL_ADD_USER_LOCAL_M_' => 'Added or edited users’ forum moderator access from %1$s
» %2$s', - 'LOG_ACL_ADD_GROUP_LOCAL_F_' => 'Added or edited groups’ forum access from %1$s
» %2$s', - 'LOG_ACL_ADD_GROUP_LOCAL_M_' => 'Added or edited groups’ forum moderator access from %1$s
» %2$s', - - 'LOG_ACL_ADD_MOD_LOCAL_M_' => 'Added or edited Moderators from %1$s
» %2$s', - 'LOG_ACL_ADD_FORUM_LOCAL_F_' => 'Added or edited forum permissions from %1$s
» %2$s', - - 'LOG_ACL_DEL_ADMIN_GLOBAL_A_' => 'Removed Administrators
» %s', - 'LOG_ACL_DEL_MOD_GLOBAL_M_' => 'Removed Global Moderators
» %s', - 'LOG_ACL_DEL_MOD_LOCAL_M_' => 'Removed Moderators from %1$s
» %2$s', - 'LOG_ACL_DEL_FORUM_LOCAL_F_' => 'Removed User/Group forum permissions from %1$s
» %2$s', - - 'LOG_ACL_TRANSFER_PERMISSIONS' => 'Permissions transferred from
» %s', - 'LOG_ACL_RESTORE_PERMISSIONS' => 'Own permissions restored after using permissions from
» %s', - - 'LOG_ADMIN_AUTH_FAIL' => 'Failed administration login attempt', - 'LOG_ADMIN_AUTH_SUCCESS' => 'Successful administration login', - - 'LOG_ATTACHMENTS_DELETED' => 'Removed user attachments
» %s', - - 'LOG_ATTACH_EXT_ADD' => 'Added or edited attachment extension
» %s', - 'LOG_ATTACH_EXT_DEL' => 'Removed attachment extension
» %s', - 'LOG_ATTACH_EXT_UPDATE' => 'Updated attachment extension
» %s', - 'LOG_ATTACH_EXTGROUP_ADD' => 'Added extension group
» %s', - 'LOG_ATTACH_EXTGROUP_EDIT' => 'Edited extension group
» %s', - 'LOG_ATTACH_EXTGROUP_DEL' => 'Removed extension group
» %s', - 'LOG_ATTACH_FILEUPLOAD' => 'Orphan File uploaded to Post
» ID %1$d - %2$s', - 'LOG_ATTACH_ORPHAN_DEL' => 'Orphan Files deleted
» %s', - - 'LOG_BAN_EXCLUDE_USER' => 'Excluded user from ban for reason “%1$s
» %2$s', - 'LOG_BAN_EXCLUDE_IP' => 'Excluded IP from ban for reason “%1$s
» %2$s', - 'LOG_BAN_EXCLUDE_EMAIL' => 'Excluded email from ban for reason “%1$s
» %2$s', - 'LOG_BAN_USER' => 'Banned user for reason “%1$s
» %2$s', - 'LOG_BAN_IP' => 'Banned IP for reason “%1$s
» %2$s', - 'LOG_BAN_EMAIL' => 'Banned email for reason “%1$s
» %2$s', - 'LOG_UNBAN_USER' => 'Unbanned user
» %s', - 'LOG_UNBAN_IP' => 'Unbanned IP
» %s', - 'LOG_UNBAN_EMAIL' => 'Unbanned email
» %s', - - 'LOG_BBCODE_ADD' => 'Added new BBCode
» %s', - 'LOG_BBCODE_EDIT' => 'Edited BBCode
» %s', - 'LOG_BBCODE_DELETE' => 'Deleted BBCode
» %s', - 'LOG_BBCODE_CONFIGURATION_ERROR' => 'Error while configuring BBCode: %1$s
» %2$s', - - 'LOG_BOT_ADDED' => 'New bot added
» %s', - 'LOG_BOT_DELETE' => 'Deleted bot
» %s', - 'LOG_BOT_UPDATED' => 'Existing bot updated
» %s', - - 'LOG_CLEAR_ADMIN' => 'Cleared admin log', - 'LOG_CLEAR_CRITICAL' => 'Cleared error log', - 'LOG_CLEAR_MOD' => 'Cleared moderator log', - 'LOG_CLEAR_USER' => 'Cleared user log
» %s', - 'LOG_CLEAR_USERS' => 'Cleared user logs', - - 'LOG_CONFIG_ATTACH' => 'Altered attachment settings', - 'LOG_CONFIG_AUTH' => 'Altered authentication settings', - 'LOG_CONFIG_AVATAR' => 'Altered avatar settings', - 'LOG_CONFIG_COOKIE' => 'Altered cookie settings', - 'LOG_CONFIG_EMAIL' => 'Altered email settings', - 'LOG_CONFIG_FEATURES' => 'Altered board features', - 'LOG_CONFIG_LOAD' => 'Altered load settings', - 'LOG_CONFIG_MESSAGE' => 'Altered private message settings', - 'LOG_CONFIG_POST' => 'Altered post settings', - 'LOG_CONFIG_REGISTRATION' => 'Altered user registration settings', - 'LOG_CONFIG_FEED' => 'Altered syndication feeds settings', - 'LOG_CONFIG_SEARCH' => 'Altered search settings', - 'LOG_CONFIG_SECURITY' => 'Altered security settings', - 'LOG_CONFIG_SERVER' => 'Altered server settings', - 'LOG_CONFIG_SETTINGS' => 'Altered board settings', - 'LOG_CONFIG_SIGNATURE' => 'Altered signature settings', - 'LOG_CONFIG_VISUAL' => 'Altered anti-spambot settings', - - 'LOG_APPROVE_TOPIC' => 'Approved topic
» %s', - 'LOG_BUMP_TOPIC' => 'User bumped topic
» %s', - 'LOG_DELETE_POST' => 'Deleted post “%1$s” written by “%2$s” for the following reason
» %3$s', - 'LOG_DELETE_SHADOW_TOPIC' => 'Deleted shadow topic
» %s', - 'LOG_DELETE_TOPIC' => 'Deleted topic “%1$s” written by “%2$s” for the following reason
» %3$s', - 'LOG_FORK' => 'Copied topic
» from %s', - 'LOG_LOCK' => 'Locked topic
» %s', - 'LOG_LOCK_POST' => 'Locked post
» %s', - 'LOG_MERGE' => 'Merged posts into topic
» %s', - 'LOG_MOVE' => 'Moved topic
» from %1$s to %2$s', - 'LOG_MOVED_TOPIC' => 'Moved topic
» %s', - 'LOG_PM_REPORT_CLOSED' => 'Closed PM report
» %s', - 'LOG_PM_REPORT_DELETED' => 'Deleted PM report
» %s', - 'LOG_POST_APPROVED' => 'Approved post
» %s', - 'LOG_POST_DISAPPROVED' => 'Disapproved post “%1$s” written by “%3$s” for the following reason
» %2$s', - 'LOG_POST_EDITED' => 'Edited post “%1$s” written by “%2$s” for the following reason
» %3$s', - 'LOG_POST_RESTORED' => 'Restored post
» %s', - 'LOG_REPORT_CLOSED' => 'Closed report
» %s', - 'LOG_REPORT_DELETED' => 'Deleted report
» %s', - 'LOG_RESTORE_TOPIC' => 'Restored topic “%1$s” written by
» %2$s', - 'LOG_SOFTDELETE_POST' => 'Soft deleted post “%1$s” written by “%2$s” for the following reason
» %3$s', - 'LOG_SOFTDELETE_TOPIC' => 'Soft deleted topic “%1$s” written by “%2$s” for the following reason
» %3$s', - 'LOG_SPLIT_DESTINATION' => 'Moved split posts
» to %s', - 'LOG_SPLIT_SOURCE' => 'Split posts
» from %s', - - 'LOG_TOPIC_APPROVED' => 'Approved topic
» %s', - 'LOG_TOPIC_RESTORED' => 'Restored topic
» %s', - 'LOG_TOPIC_DISAPPROVED' => 'Disapproved topic “%1$s” written by “%3$s” for the following reason
» %2$s', - 'LOG_TOPIC_RESYNC' => 'Resynchronised topic counters
» %s', - 'LOG_TOPIC_TYPE_CHANGED' => 'Changed topic type
» %s', - 'LOG_UNLOCK' => 'Unlocked topic
» %s', - 'LOG_UNLOCK_POST' => 'Unlocked post
» %s', - - 'LOG_DISALLOW_ADD' => 'Added disallowed username
» %s', - 'LOG_DISALLOW_DELETE' => 'Deleted disallowed username', - - 'LOG_DB_BACKUP' => 'Database backup', - 'LOG_DB_DELETE' => 'Deleted database backup', - 'LOG_DB_RESTORE' => 'Restored database backup', - - 'LOG_DOWNLOAD_EXCLUDE_IP' => 'Excluded IP/hostname from download list
» %s', - 'LOG_DOWNLOAD_IP' => 'Added IP/hostname to download list
» %s', - 'LOG_DOWNLOAD_REMOVE_IP' => 'Removed IP/hostname from download list
» %s', - - 'LOG_ERROR_JABBER' => 'Jabber error
» %s', - 'LOG_ERROR_EMAIL' => 'Email error
» %s', - 'LOG_ERROR_CAPTCHA' => 'CAPTCHA error
» %s', - - 'LOG_FORUM_ADD' => 'Created new forum
» %s', - 'LOG_FORUM_COPIED_PERMISSIONS' => 'Copied forum permissions from %1$s
» %2$s', - 'LOG_FORUM_DEL_FORUM' => 'Deleted forum
» %s', - 'LOG_FORUM_DEL_FORUMS' => 'Deleted forum and its subforums
» %s', - 'LOG_FORUM_DEL_MOVE_FORUMS' => 'Deleted forum and moved subforums to %1$s
» %2$s', - 'LOG_FORUM_DEL_MOVE_POSTS' => 'Deleted forum and moved posts to %1$s
» %2$s', - 'LOG_FORUM_DEL_MOVE_POSTS_FORUMS' => 'Deleted forum and its subforums, moved posts to %1$s
» %2$s', - 'LOG_FORUM_DEL_MOVE_POSTS_MOVE_FORUMS' => 'Deleted forum, moved posts to %1$s and subforums to %2$s
» %3$s', - 'LOG_FORUM_DEL_POSTS' => 'Deleted forum and its posts
» %s', - 'LOG_FORUM_DEL_POSTS_FORUMS' => 'Deleted forum, its posts and subforums
» %s', - 'LOG_FORUM_DEL_POSTS_MOVE_FORUMS' => 'Deleted forum and its posts, moved subforums to %1$s
» %2$s', - 'LOG_FORUM_EDIT' => 'Edited forum details
» %s', - 'LOG_FORUM_MOVE_DOWN' => 'Moved forum %1$s below %2$s', - 'LOG_FORUM_MOVE_UP' => 'Moved forum %1$s above %2$s', - 'LOG_FORUM_SYNC' => 'Re-synchronised forum
» %s', - - 'LOG_GENERAL_ERROR' => 'A general error occurred: %1$s
» %2$s', - - 'LOG_GROUP_CREATED' => 'New usergroup created
» %s', - 'LOG_GROUP_DEFAULTS' => 'Group “%1$s” made default for members
» %2$s', - 'LOG_GROUP_DELETE' => 'Usergroup deleted
» %s', - 'LOG_GROUP_DEMOTED' => 'Leaders demoted in usergroup %1$s
» %2$s', - 'LOG_GROUP_PROMOTED' => 'Members promoted to leader in usergroup %1$s
» %2$s', - 'LOG_GROUP_REMOVE' => 'Members removed from usergroup %1$s
» %2$s', - 'LOG_GROUP_UPDATED' => 'Usergroup details updated
» %s', - 'LOG_MODS_ADDED' => 'Added new leaders to usergroup %1$s
» %2$s', - 'LOG_USERS_ADDED' => 'Added new members to usergroup %1$s
» %2$s', - 'LOG_USERS_APPROVED' => 'Users approved in usergroup %1$s
» %2$s', - 'LOG_USERS_PENDING' => 'Users requested to join group “%1$s” and need to be approved
» %2$s', - - 'LOG_IMAGE_GENERATION_ERROR' => 'Error while creating image
» Error in %1$s on line %2$s: %3$s', - - 'LOG_INACTIVE_ACTIVATE' => 'Activated inactive users
» %s', - 'LOG_INACTIVE_DELETE' => 'Deleted inactive users
» %s', - 'LOG_INACTIVE_REMIND' => 'Sent reminder emails to inactive users
» %s', - 'LOG_INSTALL_CONVERTED' => 'Converted from %1$s to phpBB %2$s', - 'LOG_INSTALL_INSTALLED' => 'Installed phpBB %s', - - 'LOG_IP_BROWSER_FORWARDED_CHECK' => 'Session IP/browser/X_FORWARDED_FOR check failed
»User IP “%1$s” checked against session IP “%2$s”, user browser string “%3$s” checked against session browser string “%4$s” and user X_FORWARDED_FOR string “%5$s” checked against session X_FORWARDED_FOR string “%6$s”.', - - 'LOG_JAB_CHANGED' => 'Jabber account changed', - 'LOG_JAB_PASSCHG' => 'Jabber password changed', - 'LOG_JAB_REGISTER' => 'Jabber account registered', - 'LOG_JAB_SETTINGS_CHANGED' => 'Jabber settings changed', - - 'LOG_LANGUAGE_PACK_DELETED' => 'Deleted language pack
» %s', - 'LOG_LANGUAGE_PACK_INSTALLED' => 'Installed language pack
» %s', - 'LOG_LANGUAGE_PACK_UPDATED' => 'Updated language pack details
» %s', - 'LOG_LANGUAGE_FILE_REPLACED' => 'Replaced language file
» %s', - 'LOG_LANGUAGE_FILE_SUBMITTED' => 'Submitted language file and placed in store folder
» %s', - - 'LOG_MASS_EMAIL' => 'Sent mass email
» %s', - - 'LOG_MCP_CHANGE_POSTER' => 'Changed poster in topic “%1$s”
» from %2$s to %3$s', - - 'LOG_MODULE_DISABLE' => 'Module disabled
» %s', - 'LOG_MODULE_ENABLE' => 'Module enabled
» %s', - 'LOG_MODULE_MOVE_DOWN' => 'Module moved down
» %1$s below %2$s', - 'LOG_MODULE_MOVE_UP' => 'Module moved up
» %1$s above %2$s', - 'LOG_MODULE_REMOVED' => 'Module removed
» %s', - 'LOG_MODULE_ADD' => 'Module added
» %s', - 'LOG_MODULE_EDIT' => 'Module edited
» %s', - - 'LOG_A_ROLE_ADD' => 'Admin role added
» %s', - 'LOG_A_ROLE_EDIT' => 'Admin role edited
» %s', - 'LOG_A_ROLE_REMOVED' => 'Admin role removed
» %s', - 'LOG_F_ROLE_ADD' => 'Forum role added
» %s', - 'LOG_F_ROLE_EDIT' => 'Forum role edited
» %s', - 'LOG_F_ROLE_REMOVED' => 'Forum role removed
» %s', - 'LOG_M_ROLE_ADD' => 'Moderator role added
» %s', - 'LOG_M_ROLE_EDIT' => 'Moderator role edited
» %s', - 'LOG_M_ROLE_REMOVED' => 'Moderator role removed
» %s', - 'LOG_U_ROLE_ADD' => 'User role added
» %s', - 'LOG_U_ROLE_EDIT' => 'User role edited
» %s', - 'LOG_U_ROLE_REMOVED' => 'User role removed
» %s', - - 'LOG_PLUPLOAD_TIDY_FAILED' => 'Unable to open %1$s for tidying, check permissions.
Exception: %2$s
Trace: %3$s', - - 'LOG_PROFILE_FIELD_ACTIVATE' => 'Profile field activated
» %s', - 'LOG_PROFILE_FIELD_CREATE' => 'Profile field added
» %s', - 'LOG_PROFILE_FIELD_DEACTIVATE' => 'Profile field deactivated
» %s', - 'LOG_PROFILE_FIELD_EDIT' => 'Profile field changed
» %s', - 'LOG_PROFILE_FIELD_REMOVED' => 'Profile field removed
» %s', - - 'LOG_PRUNE' => 'Pruned forums
» %s', - 'LOG_AUTO_PRUNE' => 'Auto-pruned forums
» %s', - 'LOG_PRUNE_SHADOW' => 'Auto-pruned shadow topics
» %s', - 'LOG_PRUNE_USER_DEAC' => 'Users deactivated
» %s', - 'LOG_PRUNE_USER_DEL_DEL' => 'Users pruned and posts deleted
» %s', - 'LOG_PRUNE_USER_DEL_ANON' => 'Users pruned and posts retained
» %s', - - 'LOG_PURGE_CACHE' => 'Purged cache', - 'LOG_PURGE_SESSIONS' => 'Purged sessions', - - 'LOG_RANK_ADDED' => 'Added new rank
» %s', - 'LOG_RANK_REMOVED' => 'Removed rank
» %s', - 'LOG_RANK_UPDATED' => 'Updated rank
» %s', - - 'LOG_REASON_ADDED' => 'Added report/denial reason
» %s', - 'LOG_REASON_REMOVED' => 'Removed report/denial reason
» %s', - 'LOG_REASON_UPDATED' => 'Updated report/denial reason
» %s', - - 'LOG_REFERER_INVALID' => 'Referrer validation failed
»Referrer was “%1$s”. The request was rejected and the session killed.', - 'LOG_RESET_DATE' => 'Board start date reset', - 'LOG_RESET_ONLINE' => 'Most users online reset', - 'LOG_RESYNC_FILES_STATS' => 'File statistics resynchronised', - 'LOG_RESYNC_POSTCOUNTS' => 'User post counts resynchronised', - 'LOG_RESYNC_POST_MARKING' => 'Dotted topics resynchronised', - 'LOG_RESYNC_STATS' => 'Post, topic and user statistics resynchronised', - - 'LOG_SEARCH_INDEX_CREATED' => 'Created search index for
» %s', - 'LOG_SEARCH_INDEX_REMOVED' => 'Removed search index for
» %s', - 'LOG_SPHINX_ERROR' => 'Sphinx Error
» %s', - 'LOG_STYLE_ADD' => 'Added new style
» %s', - 'LOG_STYLE_DELETE' => 'Deleted style
» %s', - 'LOG_STYLE_EDIT_DETAILS' => 'Edited style
» %s', - 'LOG_STYLE_EXPORT' => 'Exported style
» %s', - - // @deprecated 3.1 - 'LOG_TEMPLATE_ADD_DB' => 'Added new template set to database
» %s', - // @deprecated 3.1 - 'LOG_TEMPLATE_ADD_FS' => 'Add new template set on filesystem
» %s', - 'LOG_TEMPLATE_CACHE_CLEARED' => 'Deleted cached versions of template files in template set %1$s
» %2$s', - 'LOG_TEMPLATE_DELETE' => 'Deleted template set
» %s', - 'LOG_TEMPLATE_EDIT' => 'Edited template set %1$s
» %2$s', - 'LOG_TEMPLATE_EDIT_DETAILS' => 'Edited template details
» %s', - 'LOG_TEMPLATE_EXPORT' => 'Exported template set
» %s', - // @deprecated 3.1 - 'LOG_TEMPLATE_REFRESHED' => 'Refreshed template set
» %s', - - // @deprecated 3.1 - 'LOG_THEME_ADD_DB' => 'Added new theme to database
» %s', - // @deprecated 3.1 - 'LOG_THEME_ADD_FS' => 'Add new theme on filesystem
» %s', - 'LOG_THEME_DELETE' => 'Theme deleted
» %s', - 'LOG_THEME_EDIT_DETAILS' => 'Edited theme details
» %s', - 'LOG_THEME_EDIT' => 'Edited theme %1$s', - 'LOG_THEME_EDIT_FILE' => 'Edited theme %1$s
» Modified file %2$s', - 'LOG_THEME_EXPORT' => 'Exported theme
» %s', - // @deprecated 3.1 - 'LOG_THEME_REFRESHED' => 'Refreshed theme
» %s', - - 'LOG_UPDATE_DATABASE' => 'Updated Database from version %1$s to version %2$s', - 'LOG_UPDATE_PHPBB' => 'Updated phpBB from version %1$s to version %2$s', - - 'LOG_USER_ACTIVE' => 'User activated
» %s', - 'LOG_USER_BAN_USER' => 'Banned User via user management for reason “%1$s
» %2$s', - 'LOG_USER_BAN_IP' => 'Banned IP via user management for reason “%1$s
» %2$s', - 'LOG_USER_BAN_EMAIL' => 'Banned email via user management for reason “%1$s
» %2$s', - 'LOG_USER_DELETED' => 'Deleted user
» %s', - 'LOG_USER_DEL_ATTACH' => 'Removed all attachments made by the user
» %s', - 'LOG_USER_DEL_AVATAR' => 'Removed user avatar
» %s', - 'LOG_USER_DEL_OUTBOX' => 'Emptied user outbox
» %s', - 'LOG_USER_DEL_POSTS' => 'Removed all posts made by the user
» %s', - 'LOG_USER_DEL_SIG' => 'Removed user signature
» %s', - 'LOG_USER_INACTIVE' => 'User deactivated
» %s', - 'LOG_USER_MOVE_POSTS' => 'Moved user posts
» posts by “%1$s” to forum “%2$s”', - 'LOG_USER_NEW_PASSWORD' => 'Changed user password
» %s', - 'LOG_USER_REACTIVATE' => 'Forced user account reactivation
» %s', - 'LOG_USER_REMOVED_NR' => 'Removed newly registered flag from user
» %s', - - 'LOG_USER_UPDATE_EMAIL' => 'User “%1$s” changed email
» from “%2$s” to “%3$s”', - 'LOG_USER_UPDATE_NAME' => 'Changed username
» from “%1$s” to “%2$s”', - 'LOG_USER_USER_UPDATE' => 'Updated user details
» %s', - - 'LOG_USER_ACTIVE_USER' => 'User account activated', - 'LOG_USER_DEL_AVATAR_USER' => 'User avatar removed', - 'LOG_USER_DEL_SIG_USER' => 'User signature removed', - 'LOG_USER_FEEDBACK' => 'Added user feedback
» %s', - 'LOG_USER_GENERAL' => 'Entry added:
» %s', - 'LOG_USER_INACTIVE_USER' => 'User account de-activated', - 'LOG_USER_LOCK' => 'User locked own topic
» %s', - 'LOG_USER_MOVE_POSTS_USER' => 'Moved all posts to forum» %s', - 'LOG_USER_REACTIVATE_USER' => 'Forced user account reactivation', - 'LOG_USER_UNLOCK' => 'User unlocked own topic
» %s', - 'LOG_USER_WARNING' => 'Added user warning
» %s', - 'LOG_USER_WARNING_BODY' => 'The following warning was issued to this user
» %s', - - 'LOG_USER_GROUP_CHANGE' => 'User changed default group
» %s', - 'LOG_USER_GROUP_DEMOTE' => 'User demoted as leaders from usergroup
» %s', - 'LOG_USER_GROUP_JOIN' => 'User joined group
» %s', - 'LOG_USER_GROUP_JOIN_PENDING' => 'User joined group and needs to be approved
» %s', - 'LOG_USER_GROUP_RESIGN' => 'User resigned membership from group
» %s', - - 'LOG_WARNING_DELETED' => 'Deleted user warning
» %s', - 'LOG_WARNINGS_DELETED' => array( - 1 => 'Deleted user warning
» %1$s', - 2 => 'Deleted %2$d user warnings
» %1$s', // Example: 'Deleted 2 user warnings
» username' - ), - 'LOG_WARNINGS_DELETED_ALL' => 'Deleted all user warnings
» %s', - - 'LOG_WORD_ADD' => 'Added word censor
» %s', - 'LOG_WORD_DELETE' => 'Deleted word censor
» %s', - 'LOG_WORD_EDIT' => 'Edited word censor
» %s', - - 'LOG_EXT_ENABLE' => 'Extension enabled
» %s', - 'LOG_EXT_DISABLE' => 'Extension disabled
» %s', - 'LOG_EXT_PURGE' => 'Extension’s data deleted
» %s', - 'LOG_EXT_UPDATE' => 'Extension updated
» %s', -)); diff --git a/install/update/old/language/en/acp/forums.php b/install/update/old/language/en/acp/forums.php deleted file mode 100644 index 7a71763..0000000 --- a/install/update/old/language/en/acp/forums.php +++ /dev/null @@ -1,165 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* DO NOT CHANGE -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -if (empty($lang) || !is_array($lang)) -{ - $lang = array(); -} - -// DEVELOPERS PLEASE NOTE -// -// All language files should use UTF-8 as their encoding and the files must not contain a BOM. -// -// Placeholders can now contain order information, e.g. instead of -// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows -// translators to re-order the output of data while ensuring it remains correct -// -// You do not need this where single placeholders are used, e.g. 'Message %d' is fine -// equally where a string contains only two placeholders which are used to wrap text -// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine - -// Forum Admin -$lang = array_merge($lang, array( - 'AUTO_PRUNE_DAYS' => 'Auto-prune post age', - 'AUTO_PRUNE_DAYS_EXPLAIN' => 'Number of days since last post after which topic is removed.', - 'AUTO_PRUNE_FREQ' => 'Auto-prune frequency', - 'AUTO_PRUNE_FREQ_EXPLAIN' => 'Time in days between pruning events.', - 'AUTO_PRUNE_VIEWED' => 'Auto-prune post viewed age', - 'AUTO_PRUNE_VIEWED_EXPLAIN' => 'Number of days since topic was viewed after which topic is removed.', - 'AUTO_PRUNE_SHADOW_FREQ' => 'Auto-prune shadow topics frequency', - 'AUTO_PRUNE_SHADOW_DAYS' => 'Auto-prune shadow topics age', - 'AUTO_PRUNE_SHADOW_DAYS_EXPLAIN' => 'Number of days after which shadow topic is removed.', - 'AUTO_PRUNE_SHADOW_FREQ_EXPLAIN' => 'Time in days between pruning events.', - - 'CONTINUE' => 'Continue', - 'COPY_PERMISSIONS' => 'Copy permissions from', - 'COPY_PERMISSIONS_EXPLAIN' => 'To ease up the permission setup for your new forum, you can copy the permissions of an existing forum.', - 'COPY_PERMISSIONS_ADD_EXPLAIN' => 'Once created, the forum will have the same permissions as the one you select here. If no forum is selected the newly created forum will not be visible until permissions had been set.', - 'COPY_PERMISSIONS_EDIT_EXPLAIN' => 'If you select to copy permissions, the forum will have the same permissions as the one you select here. This will overwrite any permissions you have previously set for this forum with the permissions of the forum you select here. If no forum is selected the current permissions will be kept.', - 'COPY_TO_ACL' => 'Alternatively, you are also able to %sset up new permissions%s for this forum.', - 'CREATE_FORUM' => 'Create new forum', - - 'DECIDE_MOVE_DELETE_CONTENT' => 'Delete content or move to forum', - 'DECIDE_MOVE_DELETE_SUBFORUMS' => 'Delete subforums or move to forum', - 'DEFAULT_STYLE' => 'Default style', - 'DELETE_ALL_POSTS' => 'Delete posts', - 'DELETE_SUBFORUMS' => 'Delete subforums and posts', - 'DISPLAY_ACTIVE_TOPICS' => 'Enable active topics', - 'DISPLAY_ACTIVE_TOPICS_EXPLAIN' => 'If set to yes active topics in selected subforums will be displayed under this category.', - - 'EDIT_FORUM' => 'Edit forum', - 'ENABLE_INDEXING' => 'Enable search indexing', - 'ENABLE_INDEXING_EXPLAIN' => 'If set to yes posts made to this forum will be indexed for searching.', - 'ENABLE_POST_REVIEW' => 'Enable post review', - 'ENABLE_POST_REVIEW_EXPLAIN' => 'If set to yes users are able to review their post if new posts were made to the topic while users wrote theirs. This should be disabled for chat forums.', - 'ENABLE_QUICK_REPLY' => 'Enable quick reply', - 'ENABLE_QUICK_REPLY_EXPLAIN' => 'Enables the quick reply in this forum. This setting is not considered if the quick reply is disabled board wide. The quick reply will only be displayed for users who have permission to post in this forum.', - 'ENABLE_RECENT' => 'Display active topics', - 'ENABLE_RECENT_EXPLAIN' => 'If set to yes topics made to this forum will be shown in the active topics list.', - 'ENABLE_TOPIC_ICONS' => 'Enable topic icons', - - 'FORUM_ADMIN' => 'Forum administration', - 'FORUM_ADMIN_EXPLAIN' => 'In phpBB3 everything is forum based. A category is just a special type of forum. Each forum can have an unlimited number of sub-forums and you can determine whether each may be posted to or not (i.e. whether it acts like an old category). Here you can add, edit, delete, lock, unlock individual forums as well as set certain additional controls. If your posts and topics have got out of sync you can also resynchronise a forum. You need to copy or set appropriate permissions for newly created forums to have them displayed.', - 'FORUM_AUTO_PRUNE' => 'Enable auto-pruning', - 'FORUM_AUTO_PRUNE_EXPLAIN' => 'Prunes the forum of topics, set the frequency/age parameters below.', - 'FORUM_CREATED' => 'Forum created successfully.', - 'FORUM_DATA_NEGATIVE' => 'Pruning parameters cannot be negative.', - 'FORUM_DESC_TOO_LONG' => 'The forum description is too long, it must be less than 4000 characters.', - 'FORUM_DELETE' => 'Delete forum', - 'FORUM_DELETE_EXPLAIN' => 'The form below will allow you to delete a forum. If the forum is postable you are able to decide where you want to put all topics (or forums) it contained.', - 'FORUM_DELETED' => 'Forum successfully deleted.', - 'FORUM_DESC' => 'Description', - 'FORUM_DESC_EXPLAIN' => 'Any HTML markup entered here will be displayed as is. If the selected forum type is a category the description is not used.', - 'FORUM_EDIT_EXPLAIN' => 'The form below will allow you to customise this forum. Please note that moderation and post count controls are set via forum permissions for each user or usergroup.', - 'FORUM_IMAGE' => 'Forum image', - 'FORUM_IMAGE_EXPLAIN' => 'Location, relative to the phpBB root directory, of an additional image to associate with this forum.', - 'FORUM_IMAGE_NO_EXIST' => 'The specified forum image does not exist', - 'FORUM_LINK_EXPLAIN' => 'Full URL (including the protocol, i.e.: http://) to the destination location that clicking this forum will take the user, e.g.: http://www.phpbb.com/.', - 'FORUM_LINK_TRACK' => 'Track link redirects', - 'FORUM_LINK_TRACK_EXPLAIN' => 'Records the number of times a forum link was clicked.', - 'FORUM_NAME' => 'Forum name', - 'FORUM_NAME_EMPTY' => 'You must enter a name for this forum.', - 'FORUM_PARENT' => 'Parent forum', - 'FORUM_PASSWORD' => 'Forum password', - 'FORUM_PASSWORD_CONFIRM' => 'Confirm forum password', - 'FORUM_PASSWORD_CONFIRM_EXPLAIN' => 'Only needs to be set if a forum password is entered.', - 'FORUM_PASSWORD_EXPLAIN' => 'Defines a password for this forum, use the permission system in preference.', - 'FORUM_PASSWORD_UNSET' => 'Remove forum password', - 'FORUM_PASSWORD_UNSET_EXPLAIN' => 'Check here if you want to remove the forum password.', - 'FORUM_PASSWORD_OLD' => 'The forum password is using an old hashing method and should be changed.', - 'FORUM_PASSWORD_MISMATCH' => 'The passwords you entered did not match.', - 'FORUM_PRUNE_SETTINGS' => 'Forum prune settings', - 'FORUM_PRUNE_SHADOW' => 'Enable auto-pruning of shadow topics', - 'FORUM_PRUNE_SHADOW_EXPLAIN' => 'Prunes the forum of shadow topics, set the frequency/age parameters below.', - 'FORUM_RESYNCED' => 'Forum “%s” successfully resynced', - 'FORUM_RULES_EXPLAIN' => 'Forum rules are displayed at any page within the given forum.', - 'FORUM_RULES_LINK' => 'Link to forum rules', - 'FORUM_RULES_LINK_EXPLAIN' => 'You are able to enter the URL of the page/post containing your forum rules here. This setting will override the forum rules text you specified.', - 'FORUM_RULES_PREVIEW' => 'Forum rules preview', - 'FORUM_RULES_TOO_LONG' => 'The forum rules must be less than 4000 characters.', - 'FORUM_SETTINGS' => 'Forum settings', - 'FORUM_STATUS' => 'Forum status', - 'FORUM_STYLE' => 'Forum style', - 'FORUM_TOPICS_PAGE' => 'Topics per page', - 'FORUM_TOPICS_PAGE_EXPLAIN' => 'If non-zero this value will override the default topics per page setting.', - 'FORUM_TYPE' => 'Forum type', - 'FORUM_UPDATED' => 'Forum information updated successfully.', - - 'FORUM_WITH_SUBFORUMS_NOT_TO_LINK' => 'You want to change a postable forum having subforums to a link. Please move all subforums out of this forum before you proceed, because after changing to a link you are no longer able to see the subforums currently connected to this forum.', - - 'GENERAL_FORUM_SETTINGS' => 'General forum settings', - - 'LINK' => 'Link', - 'LIST_INDEX' => 'List subforum in parent-forum’s legend', - 'LIST_INDEX_EXPLAIN' => 'Displays this forum on the index and elsewhere as a link within the legend of its parent-forum if the parent-forum’s “List subforums in legend” option is enabled.', - 'LIST_SUBFORUMS' => 'List subforums in legend', - 'LIST_SUBFORUMS_EXPLAIN' => 'Displays this forum’s subforums on the index and elsewhere as a link within the legend if their “List subforum in parent-forum’s legend” option is enabled.', - 'LOCKED' => 'Locked', - - 'MOVE_POSTS_NO_POSTABLE_FORUM' => 'The forum you selected for moving the posts to is not postable. Please select a postable forum.', - 'MOVE_POSTS_TO' => 'Move posts to', - 'MOVE_SUBFORUMS_TO' => 'Move subforums to', - - 'NO_DESTINATION_FORUM' => 'You have not specified a forum to move content to.', - 'NO_FORUM_ACTION' => 'No action defined for what happens with the forum content.', - 'NO_PARENT' => 'No parent', - 'NO_PERMISSIONS' => 'Do not copy permissions', - 'NO_PERMISSION_FORUM_ADD' => 'You do not have the necessary permissions to add forums.', - 'NO_PERMISSION_FORUM_DELETE' => 'You do not have the necessary permissions to delete forums.', - - 'PARENT_IS_LINK_FORUM' => 'The parent you specified is a forum link. Link forums are not able to hold other forums, please specify a category or forum as the parent forum.', - 'PARENT_NOT_EXIST' => 'Parent does not exist.', - 'PRUNE_ANNOUNCEMENTS' => 'Prune announcements', - 'PRUNE_STICKY' => 'Prune stickies', - 'PRUNE_OLD_POLLS' => 'Prune old polls', - 'PRUNE_OLD_POLLS_EXPLAIN' => 'Removes topics with polls not voted in for post age days.', - - 'REDIRECT_ACL' => 'Now you are able to %sset permissions%s for this forum.', - - 'SYNC_IN_PROGRESS' => 'Synchronizing forum', - 'SYNC_IN_PROGRESS_EXPLAIN' => 'Currently resyncing topic range %1$d/%2$d.', - - 'TYPE_CAT' => 'Category', - 'TYPE_FORUM' => 'Forum', - 'TYPE_LINK' => 'Link', - - 'UNLOCKED' => 'Unlocked', -)); diff --git a/install/update/old/language/en/acp/permissions.php b/install/update/old/language/en/acp/permissions.php deleted file mode 100644 index 54d968c..0000000 --- a/install/update/old/language/en/acp/permissions.php +++ /dev/null @@ -1,287 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* DO NOT CHANGE -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -if (empty($lang) || !is_array($lang)) -{ - $lang = array(); -} - -// DEVELOPERS PLEASE NOTE -// -// All language files should use UTF-8 as their encoding and the files must not contain a BOM. -// -// Placeholders can now contain order information, e.g. instead of -// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows -// translators to re-order the output of data while ensuring it remains correct -// -// You do not need this where single placeholders are used, e.g. 'Message %d' is fine -// equally where a string contains only two placeholders which are used to wrap text -// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine - -$lang = array_merge($lang, array( - 'ACP_PERMISSIONS_EXPLAIN' => ' -

Permissions are highly granular and grouped into four major sections, which are:

- -

Global Permissions

-

These are used to control access on a global level and apply to the entire bulletin board. They are further divided into User Permissions, Group Permissions, Administrators and Global Moderators.

- -

Forum Based Permissions

-

These are used to control access on a per forum basis. They are further divided into Forum Permissions, Forum Moderators, User Forum Permissions and Group Forum Permissions.

- -

Permission Roles

-

These are used to create different sets of permissions for the different permission types later being able to be assigned on a role-based basis. The default roles should cover the administration of bulletin boards large and small, though within each of the four divisions, you can add/edit/delete roles as you see fit.

- -

Permission Masks

-

These are used to view the effective permissions assigned to Users, Moderators (Local and Global), Administrators or Forums.

- -
- -

For further information on setting up and managing permissions on your phpBB3 board, please see the section on Setting permissions of our Quick Start Guide.

- ', - - 'ACL_NEVER' => 'Never', - 'ACL_SET' => 'Setting permissions', - 'ACL_SET_EXPLAIN' => 'Permissions are based on a simple YES/NO system. Setting an option to NEVER for a user or usergroup overrides any other value assigned to it. If you do not wish to assign a value for an option for this user or group select NO. If values are assigned for this option elsewhere they will be used in preference, else NEVER is assumed. All objects marked (with the checkbox in front of them) will copy the permission set you defined.', - 'ACL_SETTING' => 'Setting', - - 'ACL_TYPE_A_' => 'Administrative permissions', - 'ACL_TYPE_F_' => 'Forum permissions', - 'ACL_TYPE_M_' => 'Moderative permissions', - 'ACL_TYPE_U_' => 'User permissions', - - 'ACL_TYPE_GLOBAL_A_' => 'Administrative permissions', - 'ACL_TYPE_GLOBAL_U_' => 'User permissions', - 'ACL_TYPE_GLOBAL_M_' => 'Global Moderator permissions', - 'ACL_TYPE_LOCAL_M_' => 'Forum Moderator permissions', - 'ACL_TYPE_LOCAL_F_' => 'Forum permissions', - - 'ACL_NO' => 'No', - 'ACL_VIEW' => 'Viewing permissions', - 'ACL_VIEW_EXPLAIN' => 'Here you can see the effective permissions the user/group is having. A red square indicates that the user/group does not have the permission, a green square indicates that the user/group does have the permission.', - 'ACL_YES' => 'Yes', - - 'ACP_ADMINISTRATORS_EXPLAIN' => 'Here you can assign administrator permissions to users or groups. All users with administrator permissions can view the administration control panel.', - 'ACP_FORUM_MODERATORS_EXPLAIN' => 'Here you can assign users and groups as forum moderators. To assign users access to forums, to define global moderative permissions or administrators please use the appropriate page.', - 'ACP_FORUM_PERMISSIONS_EXPLAIN' => 'Here you can alter which users and groups can access which forums. To assign moderators or define administrators please use the appropriate page.', - 'ACP_FORUM_PERMISSIONS_COPY_EXPLAIN' => 'Here you can copy forum permissions from one forum to one or more other forums.', - 'ACP_GLOBAL_MODERATORS_EXPLAIN' => 'Here you can assign global moderator permissions to users or groups. These moderators are like ordinary moderators except they have access to every forum on your board.', - 'ACP_GROUPS_FORUM_PERMISSIONS_EXPLAIN' => 'Here you can assign forum permissions to groups.', - 'ACP_GROUPS_PERMISSIONS_EXPLAIN' => 'Here you can assign global permissions to groups - user permissions, global moderator permissions and administrator permissions. User permissions include capabilities such as the use of avatars, sending private messages, et cetera; global moderator permissions such as approving posts, manage topics, manage bans, et cetera and lastly administrator permissions such as altering permissions, define custom BBCodes, manage forums, et cetera. Individual user permissions should only be changed in rare occasions, the preferred method is putting users in groups and assigning the group permissions.', - 'ACP_ADMIN_ROLES_EXPLAIN' => 'Here you are able to manage the roles for administrative permissions. Roles are effective permissions, if you change a role the items having this role assigned will change its permissions too.', - 'ACP_FORUM_ROLES_EXPLAIN' => 'Here you are able to manage the roles for forum permissions. Roles are effective permissions, if you change a role the items having this role assigned will change its permissions too.', - 'ACP_MOD_ROLES_EXPLAIN' => 'Here you are able to manage the roles for moderative permissions. Roles are effective permissions, if you change a role the items having this role assigned will change its permissions too.', - 'ACP_USER_ROLES_EXPLAIN' => 'Here you are able to manage the roles for user permissions. Roles are effective permissions, if you change a role the items having this role assigned will change its permissions too.', - 'ACP_USERS_FORUM_PERMISSIONS_EXPLAIN' => 'Here you can assign forum permissions to users.', - 'ACP_USERS_PERMISSIONS_EXPLAIN' => 'Here you can assign global permissions to users - user permissions, global moderator permissions and administrator permissions. User permissions include capabilities such as the use of avatars, sending private messages, et cetera; global moderator permissions such as approving posts, manage topics, manage bans, et cetera and lastly administrator permissions such as altering permissions, define custom BBCodes, manage forums, et cetera. To alter these settings for large numbers of users the Group permissions system is the preferred method. User permissions should only be changed in rare occasions, the preferred method is putting users in groups and assigning the group permissions.', - 'ACP_VIEW_ADMIN_PERMISSIONS_EXPLAIN' => 'Here you can view the effective administrative permissions assigned to the selected users/groups.', - 'ACP_VIEW_GLOBAL_MOD_PERMISSIONS_EXPLAIN' => 'Here you can view the global moderative permissions assigned to the selected users/groups.', - 'ACP_VIEW_FORUM_PERMISSIONS_EXPLAIN' => 'Here you can view the forum permissions assigned to the selected users/groups and forums.', - 'ACP_VIEW_FORUM_MOD_PERMISSIONS_EXPLAIN' => 'Here you can view the forum moderator permissions assigned to the selected users/groups and forums.', - 'ACP_VIEW_USER_PERMISSIONS_EXPLAIN' => 'Here you can view the effective user permissions assigned to the selected users/groups.', - - 'ADD_GROUPS' => 'Add groups', - 'ADD_PERMISSIONS' => 'Add permissions', - 'ADD_USERS' => 'Add users', - 'ADVANCED_PERMISSIONS' => 'Advanced Permissions', - 'ALL_GROUPS' => 'Select all groups', - 'ALL_NEVER' => 'All NEVER', - 'ALL_NO' => 'All NO', - 'ALL_USERS' => 'Select all users', - 'ALL_YES' => 'All YES', - 'APPLY_ALL_PERMISSIONS' => 'Apply all permissions', - 'APPLY_PERMISSIONS' => 'Apply permissions', - 'APPLY_PERMISSIONS_EXPLAIN' => 'The permissions and role defined for this item will only be applied to this item and all checked items.', - 'AUTH_UPDATED' => 'Permissions have been updated.', - - 'COPY_PERMISSIONS_CONFIRM' => 'Are you sure you wish to carry out this operation? Please be aware that this will overwrite any existing permissions on the selected targets.', - 'COPY_PERMISSIONS_FORUM_FROM_EXPLAIN' => 'The source forum you want to copy permissions from.', - 'COPY_PERMISSIONS_FORUM_TO_EXPLAIN' => 'The destination forums you want the copied permissions applied to.', - 'COPY_PERMISSIONS_FROM' => 'Copy permissions from', - 'COPY_PERMISSIONS_TO' => 'Apply permissions to', - - 'CREATE_ROLE' => 'Create role', - 'CREATE_ROLE_FROM' => 'Use settings from…', - 'CUSTOM' => 'Custom…', - - 'DEFAULT' => 'Default', - 'DELETE_ROLE' => 'Delete role', - 'DELETE_ROLE_CONFIRM' => 'Are you sure you want to remove this role? Items having this role assigned will not lose their permission settings.', - 'DISPLAY_ROLE_ITEMS' => 'View items using this role', - - 'EDIT_PERMISSIONS' => 'Edit permissions', - 'EDIT_ROLE' => 'Edit role', - - 'GROUPS_NOT_ASSIGNED' => 'No group assigned to this role', - - 'LOOK_UP_GROUP' => 'Look up usergroup', - 'LOOK_UP_USER' => 'Look up user', - - 'MANAGE_GROUPS' => 'Manage groups', - 'MANAGE_USERS' => 'Manage users', - - 'NO_AUTH_SETTING_FOUND' => 'Permission settings not defined.', - 'NO_ROLE_ASSIGNED' => 'No role assigned…', - 'NO_ROLE_ASSIGNED_EXPLAIN' => 'Setting to this role does not change permissions on the right. If you want to unset/remove all permissions you should use the “All NO” link.', - 'NO_ROLE_AVAILABLE' => 'No role available', - 'NO_ROLE_NAME_SPECIFIED' => 'Please give the role a name.', - 'NO_ROLE_SELECTED' => 'Role could not be found.', - 'NO_USER_GROUP_SELECTED' => 'You haven’t selected any user or group.', - - 'ONLY_FORUM_DEFINED' => 'You only defined forums in your selection. Please also select at least one user or one group.', - - 'PERMISSION_APPLIED_TO_ALL' => 'Permissions and role will also be applied to all checked objects', - 'PLUS_SUBFORUMS' => '+Subforums', - - 'REMOVE_PERMISSIONS' => 'Remove permissions', - 'REMOVE_ROLE' => 'Remove role', - 'RESULTING_PERMISSION' => 'Resulting permission', - 'ROLE' => 'Role', - 'ROLE_ADD_SUCCESS' => 'Role successfully added.', - 'ROLE_ASSIGNED_TO' => 'Users/Groups assigned to %s', - 'ROLE_DELETED' => 'Role successfully removed.', - 'ROLE_DESCRIPTION' => 'Role description', - - 'ROLE_ADMIN_FORUM' => 'Forum Admin', - 'ROLE_ADMIN_FULL' => 'Full Admin', - 'ROLE_ADMIN_STANDARD' => 'Standard Admin', - 'ROLE_ADMIN_USERGROUP' => 'User and Groups Admin', - 'ROLE_FORUM_BOT' => 'Bot Access', - 'ROLE_FORUM_FULL' => 'Full Access', - 'ROLE_FORUM_LIMITED' => 'Limited Access', - 'ROLE_FORUM_LIMITED_POLLS' => 'Limited Access + Polls', - 'ROLE_FORUM_NOACCESS' => 'No Access', - 'ROLE_FORUM_ONQUEUE' => 'On Moderation Queue', - 'ROLE_FORUM_POLLS' => 'Standard Access + Polls', - 'ROLE_FORUM_READONLY' => 'Read Only Access', - 'ROLE_FORUM_STANDARD' => 'Standard Access', - 'ROLE_FORUM_NEW_MEMBER' => 'Newly Registered User Access', - 'ROLE_MOD_FULL' => 'Full Moderator', - 'ROLE_MOD_QUEUE' => 'Queue Moderator', - 'ROLE_MOD_SIMPLE' => 'Simple Moderator', - 'ROLE_MOD_STANDARD' => 'Standard Moderator', - 'ROLE_USER_FULL' => 'All Features', - 'ROLE_USER_LIMITED' => 'Limited Features', - 'ROLE_USER_NOAVATAR' => 'No Avatar', - 'ROLE_USER_NOPM' => 'No Private Messages', - 'ROLE_USER_STANDARD' => 'Standard Features', - 'ROLE_USER_NEW_MEMBER' => 'Newly Registered User Features', - - 'ROLE_DESCRIPTION_ADMIN_FORUM' => 'Can access the forum management and forum permission settings.', - 'ROLE_DESCRIPTION_ADMIN_FULL' => 'Has access to all administrative functions of this board.
Not recommended.', - 'ROLE_DESCRIPTION_ADMIN_STANDARD' => 'Has access to most administrative features but is not allowed to use server or system related tools.', - 'ROLE_DESCRIPTION_ADMIN_USERGROUP' => 'Can manage groups and users: Able to change permissions, settings, manage bans, and manage ranks.', - 'ROLE_DESCRIPTION_FORUM_BOT' => 'This role is recommended for bots and search spiders.', - 'ROLE_DESCRIPTION_FORUM_FULL' => 'Can use all forum features, including posting of announcements and stickies. Can also ignore the flood limit.
Not recommended for normal users.', - 'ROLE_DESCRIPTION_FORUM_LIMITED' => 'Can use some forum features, but cannot attach files or use post icons.', - 'ROLE_DESCRIPTION_FORUM_LIMITED_POLLS' => 'As per Limited Access but can also create polls.', - 'ROLE_DESCRIPTION_FORUM_NOACCESS' => 'Can neither see nor access the forum.', - 'ROLE_DESCRIPTION_FORUM_ONQUEUE' => 'Can use most forum features including attachments, but posts and topics need to be approved by a moderator.', - 'ROLE_DESCRIPTION_FORUM_POLLS' => 'Like Standard Access but can also create polls.', - 'ROLE_DESCRIPTION_FORUM_READONLY' => 'Can read the forum, but cannot create new topics or reply to posts.', - 'ROLE_DESCRIPTION_FORUM_STANDARD' => 'Can use most forum features including attachments and deleting own topics, but cannot lock own topics, and cannot create polls.', - 'ROLE_DESCRIPTION_FORUM_NEW_MEMBER' => 'A role for members of the special newly registered users group; contains NEVER permissions to lock features for new users.', - 'ROLE_DESCRIPTION_MOD_FULL' => 'Can use all moderating features, including banning.', - 'ROLE_DESCRIPTION_MOD_QUEUE' => 'Can use the Moderation Queue to validate and edit posts, but nothing else.', - 'ROLE_DESCRIPTION_MOD_SIMPLE' => 'Can only use basic topic actions. Cannot send warnings or use moderation queue.', - 'ROLE_DESCRIPTION_MOD_STANDARD' => 'Can use most moderating tools, but cannot ban users or change the post author.', - 'ROLE_DESCRIPTION_USER_FULL' => 'Can use all available forum features for users, including changing the user name or ignoring the flood limit.
Not recommended.', - 'ROLE_DESCRIPTION_USER_LIMITED' => 'Can access some of the user features. Attachments, emails, or instant messages are not allowed.', - 'ROLE_DESCRIPTION_USER_NOAVATAR' => 'Has a limited feature set and is not allowed to use the Avatar feature.', - 'ROLE_DESCRIPTION_USER_NOPM' => 'Has a limited feature set, and is not allowed to use Private Messages.', - 'ROLE_DESCRIPTION_USER_STANDARD' => 'Can access most but not all user features. Cannot change user name or ignore the flood limit, for instance.', - 'ROLE_DESCRIPTION_USER_NEW_MEMBER' => 'A role for members of the special newly registered users group; contains NEVER permissions to lock features for new users.', - - 'ROLE_DESCRIPTION_EXPLAIN' => 'You are able to enter a short explanation of what the role is doing or for what it is meant for. The text you enter here will be displayed within the permissions screens too.', - 'ROLE_DESCRIPTION_LONG' => 'The role description is too long, please limit it to 4000 characters.', - 'ROLE_DETAILS' => 'Role details', - 'ROLE_EDIT_SUCCESS' => 'Role successfully edited.', - 'ROLE_NAME' => 'Role name', - 'ROLE_NAME_ALREADY_EXIST' => 'A role named %s already exist for the specified permission type.', - 'ROLE_NOT_ASSIGNED' => 'Role has not been assigned yet.', - - 'SELECTED_FORUM_NOT_EXIST' => 'The selected forum(s) do not exist.', - 'SELECTED_GROUP_NOT_EXIST' => 'The selected group(s) do not exist.', - 'SELECTED_USER_NOT_EXIST' => 'The selected user(s) do not exist.', - 'SELECT_FORUM_SUBFORUM_EXPLAIN' => 'The forum you select here will include all subforums into the selection.', - 'SELECT_ROLE' => 'Select role…', - 'SELECT_TYPE' => 'Select type', - 'SET_PERMISSIONS' => 'Set permissions', - 'SET_ROLE_PERMISSIONS' => 'Set role permissions', - 'SET_USERS_PERMISSIONS' => 'Set user permissions', - 'SET_USERS_FORUM_PERMISSIONS' => 'Set user forum permissions', - - 'TRACE_DEFAULT' => 'By default every permission is NO (unset). So the permission can be overwritten by other settings.', - 'TRACE_FOR' => 'Trace for', - 'TRACE_GLOBAL_SETTING' => '%s (global)', - 'TRACE_GROUP_NEVER_TOTAL_NEVER' => 'This group’s permission is set to NEVER like the total result so the old result is kept.', - 'TRACE_GROUP_NEVER_TOTAL_NEVER_LOCAL' => 'This group’s permission for this forum is set to NEVER like the total result so the old result is kept.', - 'TRACE_GROUP_NEVER_TOTAL_NO' => 'This group’s permission is set to NEVER which becomes the new total value because it wasn’t set yet (set to NO).', - 'TRACE_GROUP_NEVER_TOTAL_NO_LOCAL' => 'This group’s permission for this forum is set to NEVER which becomes the new total value because it wasn’t set yet (set to NO).', - 'TRACE_GROUP_NEVER_TOTAL_YES' => 'This group’s permission is set to NEVER which overwrites the total YES to a NEVER for this user.', - 'TRACE_GROUP_NEVER_TOTAL_YES_LOCAL' => 'This group’s permission for this forum is set to NEVER which overwrites the total YES to a NEVER for this user.', - 'TRACE_GROUP_NO' => 'The permission is NO for this group so the old total value is kept.', - 'TRACE_GROUP_NO_LOCAL' => 'The permission is NO for this group within this forum so the old total value is kept.', - 'TRACE_GROUP_YES_TOTAL_NEVER' => 'This group’s permission is set to YES but the total NEVER cannot be overwritten.', - 'TRACE_GROUP_YES_TOTAL_NEVER_LOCAL' => 'This group’s permission for this forum is set to YES but the total NEVER cannot be overwritten.', - 'TRACE_GROUP_YES_TOTAL_NO' => 'This group’s permission is set to YES which becomes the new total value because it wasn’t set yet (set to NO).', - 'TRACE_GROUP_YES_TOTAL_NO_LOCAL' => 'This group’s permission for this forum is set to YES which becomes the new total value because it wasn’t set yet (set to NO).', - 'TRACE_GROUP_YES_TOTAL_YES' => 'This group’s permission is set to YES and the total permission is already set to YES, so the total result is kept.', - 'TRACE_GROUP_YES_TOTAL_YES_LOCAL' => 'This group’s permission for this forum is set to YES and the total permission is already set to YES, so the total result is kept.', - 'TRACE_PERMISSION' => 'Trace permission - %s', - 'TRACE_RESULT' => 'Trace result', - 'TRACE_SETTING' => 'Trace setting', - - 'TRACE_USER_GLOBAL_YES_TOTAL_YES' => 'The forum independent user permission evaluates to YES but the total permission is already set to YES, so the total result is kept. %sTrace global permission%s', - 'TRACE_USER_GLOBAL_YES_TOTAL_NEVER' => 'The forum independent user permission evaluates to YES which overwrites the current local result NEVER. %sTrace global permission%s', - 'TRACE_USER_GLOBAL_NEVER_TOTAL_KEPT' => 'The forum independent user permission evaluates to NEVER which doesn’t influence the local permission. %sTrace global permission%s', - - 'TRACE_USER_FOUNDER' => 'The user is a founder, therefore admin permissions are always set to YES.', - 'TRACE_USER_KEPT' => 'The user’s permission is NO so the old total value is kept.', - 'TRACE_USER_KEPT_LOCAL' => 'The user’s permission for this forum is NO so the old total value is kept.', - 'TRACE_USER_NEVER_TOTAL_NEVER' => 'The user’s permission is set to NEVER and the total value is set to NEVER, so nothing is changed.', - 'TRACE_USER_NEVER_TOTAL_NEVER_LOCAL' => 'The user’s permission for this forum is set to NEVER and the total value is set to NEVER, so nothing is changed.', - 'TRACE_USER_NEVER_TOTAL_NO' => 'The user’s permission is set to NEVER which becomes the total value because it was set to NO.', - 'TRACE_USER_NEVER_TOTAL_NO_LOCAL' => 'The user’s permission for this forum is set to NEVER which becomes the total value because it was set to NO.', - 'TRACE_USER_NEVER_TOTAL_YES' => 'The user’s permission is set to NEVER and overwrites the previous YES.', - 'TRACE_USER_NEVER_TOTAL_YES_LOCAL' => 'The user’s permission for this forum is set to NEVER and overwrites the previous YES.', - 'TRACE_USER_NO_TOTAL_NO' => 'The user’s permission is NO and the total value was set to NO so it defaults to NEVER.', - 'TRACE_USER_NO_TOTAL_NO_LOCAL' => 'The user’s permission for this forum is NO and the total value was set to NO so it defaults to NEVER.', - 'TRACE_USER_YES_TOTAL_NEVER' => 'The user’s permission is set to YES but the total NEVER cannot be overwritten.', - 'TRACE_USER_YES_TOTAL_NEVER_LOCAL' => 'The user’s permission for this forum is set to YES but the total NEVER cannot be overwritten.', - 'TRACE_USER_YES_TOTAL_NO' => 'The user’s permission is set to YES which becomes the total value because it was set to NO.', - 'TRACE_USER_YES_TOTAL_NO_LOCAL' => 'The user’s permission for this forum is set to YES which becomes the total value because it was set to NO.', - 'TRACE_USER_YES_TOTAL_YES' => 'The user’s permission is set to YES and the total value is set to YES, so nothing is changed.', - 'TRACE_USER_YES_TOTAL_YES_LOCAL' => 'The user’s permission for this forum is set to YES and the total value is set to YES, so nothing is changed.', - 'TRACE_WHO' => 'Who', - 'TRACE_TOTAL' => 'Total', - - 'USERS_NOT_ASSIGNED' => 'No users are assigned to this role', - 'USER_IS_MEMBER_OF_DEFAULT' => 'is a member of the following pre-defined groups', - 'USER_IS_MEMBER_OF_CUSTOM' => 'is a member of the following user defined groups', - - 'VIEW_ASSIGNED_ITEMS' => 'View assigned items', - 'VIEW_LOCAL_PERMS' => 'Local permissions', - 'VIEW_GLOBAL_PERMS' => 'Global permissions', - 'VIEW_PERMISSIONS' => 'View permissions', - - 'WRONG_PERMISSION_TYPE' => 'Wrong permission type selected.', - 'WRONG_PERMISSION_SETTING_FORMAT' => 'The permission settings are in a wrong format, phpBB is not able to process them correctly.', -)); diff --git a/install/update/old/language/en/acp/permissions_phpbb.php b/install/update/old/language/en/acp/permissions_phpbb.php deleted file mode 100644 index 64740b3..0000000 --- a/install/update/old/language/en/acp/permissions_phpbb.php +++ /dev/null @@ -1,214 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* DO NOT CHANGE -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -if (empty($lang) || !is_array($lang)) -{ - $lang = array(); -} - -// DEVELOPERS PLEASE NOTE -// -// All language files should use UTF-8 as their encoding and the files must not contain a BOM. -// -// Placeholders can now contain order information, e.g. instead of -// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows -// translators to re-order the output of data while ensuring it remains correct -// -// You do not need this where single placeholders are used, e.g. 'Message %d' is fine -// equally where a string contains only two placeholders which are used to wrap text -// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine - -/** -* EXTENSION-DEVELOPERS PLEASE NOTE -* -* You are able to put your permission sets into your extension. -* The permissions logic should be added via the 'core.permissions' event. -* You can easily add new permission categories, types and permissions, by -* simply merging them into the respective arrays. -* The respective language strings should be added into a language file, that -* start with 'permissions_', so they are automatically loaded within the ACP. -*/ - -$lang = array_merge($lang, array( - 'ACL_CAT_ACTIONS' => 'Actions', - 'ACL_CAT_CONTENT' => 'Content', - 'ACL_CAT_FORUMS' => 'Forums', - 'ACL_CAT_MISC' => 'Misc', - 'ACL_CAT_PERMISSIONS' => 'Permissions', - 'ACL_CAT_PM' => 'Private messages', - 'ACL_CAT_POLLS' => 'Polls', - 'ACL_CAT_POST' => 'Post', - 'ACL_CAT_POST_ACTIONS' => 'Post actions', - 'ACL_CAT_POSTING' => 'Posting', - 'ACL_CAT_PROFILE' => 'Profile', - 'ACL_CAT_SETTINGS' => 'Settings', - 'ACL_CAT_TOPIC_ACTIONS' => 'Topic actions', - 'ACL_CAT_USER_GROUP' => 'Users & Groups', -)); - -// User Permissions -$lang = array_merge($lang, array( - 'ACL_U_VIEWPROFILE' => 'Can view profiles, memberlist and online list', - 'ACL_U_CHGNAME' => 'Can change username', - 'ACL_U_CHGPASSWD' => 'Can change password', - 'ACL_U_CHGEMAIL' => 'Can change email address', - 'ACL_U_CHGAVATAR' => 'Can change avatar', - 'ACL_U_CHGGRP' => 'Can change default usergroup', - 'ACL_U_CHGPROFILEINFO' => 'Can change profile field information', - - 'ACL_U_ATTACH' => 'Can attach files', - 'ACL_U_DOWNLOAD' => 'Can download files', - 'ACL_U_SAVEDRAFTS' => 'Can save drafts', - 'ACL_U_CHGCENSORS' => 'Can disable word censors', - 'ACL_U_SIG' => 'Can use signature', - - 'ACL_U_SENDPM' => 'Can send private messages', - 'ACL_U_MASSPM' => 'Can send messages to multiple users', - 'ACL_U_MASSPM_GROUP'=> 'Can send messages to groups', - 'ACL_U_READPM' => 'Can read private messages', - 'ACL_U_PM_EDIT' => 'Can edit own private messages', - 'ACL_U_PM_DELETE' => 'Can remove private messages from own folder', - 'ACL_U_PM_FORWARD' => 'Can forward private messages', - 'ACL_U_PM_EMAILPM' => 'Can email private messages', - 'ACL_U_PM_PRINTPM' => 'Can print private messages', - 'ACL_U_PM_ATTACH' => 'Can attach files in private messages', - 'ACL_U_PM_DOWNLOAD' => 'Can download files in private messages', - 'ACL_U_PM_BBCODE' => 'Can use BBCode in private messages', - 'ACL_U_PM_SMILIES' => 'Can use smilies in private messages', - 'ACL_U_PM_IMG' => 'Can use [img] BBCode tag in private messages', - 'ACL_U_PM_FLASH' => 'Can use [flash] BBCode tag in private messages', - - 'ACL_U_SENDEMAIL' => 'Can send emails', - 'ACL_U_SENDIM' => 'Can send instant messages', - 'ACL_U_IGNOREFLOOD' => 'Can ignore flood limit', - 'ACL_U_HIDEONLINE' => 'Can hide online status', - 'ACL_U_VIEWONLINE' => 'Can view hidden online users', - 'ACL_U_SEARCH' => 'Can search board', -)); - -// Forum Permissions -$lang = array_merge($lang, array( - 'ACL_F_LIST' => 'Can see forum', - 'ACL_F_LIST_TOPICS' => 'Can see topics', - 'ACL_F_READ' => 'Can read forum', - 'ACL_F_SEARCH' => 'Can search the forum', - 'ACL_F_SUBSCRIBE' => 'Can subscribe forum', - 'ACL_F_PRINT' => 'Can print topics', - 'ACL_F_EMAIL' => 'Can email topics', - 'ACL_F_BUMP' => 'Can bump topics', - 'ACL_F_USER_LOCK' => 'Can lock own topics', - 'ACL_F_DOWNLOAD' => 'Can download files', - 'ACL_F_REPORT' => 'Can report posts', - - 'ACL_F_POST' => 'Can start new topics', - 'ACL_F_STICKY' => 'Can post stickies', - 'ACL_F_ANNOUNCE' => 'Can post announcements', - 'ACL_F_ANNOUNCE_GLOBAL' => 'Can post global announcements', - 'ACL_F_REPLY' => 'Can reply to topics', - 'ACL_F_EDIT' => 'Can edit own posts', - 'ACL_F_DELETE' => 'Can permanently delete own posts', - 'ACL_F_SOFTDELETE' => 'Can soft delete own posts
Moderators, who have the approve posts permission, can restore soft deleted posts.', - 'ACL_F_IGNOREFLOOD' => 'Can ignore flood limit', - 'ACL_F_POSTCOUNT' => 'Increment post counter
Please note that this setting only affects new posts.', - 'ACL_F_NOAPPROVE' => 'Can post without approval', - - 'ACL_F_ATTACH' => 'Can attach files', - 'ACL_F_ICONS' => 'Can use topic/post icons', - 'ACL_F_BBCODE' => 'Can use BBCode', - 'ACL_F_FLASH' => 'Can use [flash] BBCode tag', - 'ACL_F_IMG' => 'Can use [img] BBCode tag', - 'ACL_F_SIGS' => 'Can use signatures', - 'ACL_F_SMILIES' => 'Can use smilies', - - 'ACL_F_POLL' => 'Can create polls', - 'ACL_F_VOTE' => 'Can vote in polls', - 'ACL_F_VOTECHG' => 'Can change existing vote', -)); - -// Moderator Permissions -$lang = array_merge($lang, array( - 'ACL_M_EDIT' => 'Can edit posts', - 'ACL_M_DELETE' => 'Can permanently delete posts', - 'ACL_M_SOFTDELETE' => 'Can soft delete posts
Moderators, who have the approve posts permission, can restore soft deleted posts.', - 'ACL_M_APPROVE' => 'Can approve and restore posts', - 'ACL_M_REPORT' => 'Can close and delete reports', - 'ACL_M_CHGPOSTER' => 'Can change post author', - - 'ACL_M_MOVE' => 'Can move topics', - 'ACL_M_LOCK' => 'Can lock topics', - 'ACL_M_SPLIT' => 'Can split topics', - 'ACL_M_MERGE' => 'Can merge topics', - - 'ACL_M_INFO' => 'Can view post details', - 'ACL_M_WARN' => 'Can issue warnings
This setting is only assigned globally. It is not forum based.', // This moderator setting is only global (and not local) - 'ACL_M_PM_REPORT' => 'Can close and delete reports of private messages
This setting is only assigned globally. It is not forum based.', // This moderator setting is only global (and not local) - 'ACL_M_BAN' => 'Can manage bans
This setting is only assigned globally. It is not forum based.', // This moderator setting is only global (and not local) -)); - -// Admin Permissions -$lang = array_merge($lang, array( - 'ACL_A_BOARD' => 'Can alter board settings/check for updates', - 'ACL_A_SERVER' => 'Can alter server/communication settings', - 'ACL_A_JABBER' => 'Can alter Jabber settings', - 'ACL_A_PHPINFO' => 'Can view php settings', - - 'ACL_A_FORUM' => 'Can manage forums', - 'ACL_A_FORUMADD' => 'Can add new forums', - 'ACL_A_FORUMDEL' => 'Can delete forums', - 'ACL_A_PRUNE' => 'Can prune forums', - - 'ACL_A_ICONS' => 'Can alter topic/post icons and smilies', - 'ACL_A_WORDS' => 'Can alter word censors', - 'ACL_A_BBCODE' => 'Can define BBCode tags', - 'ACL_A_ATTACH' => 'Can alter attachment related settings', - - 'ACL_A_USER' => 'Can manage users
This also includes seeing the users browser agent within the viewonline list.', - 'ACL_A_USERDEL' => 'Can delete/prune users', - 'ACL_A_GROUP' => 'Can manage groups', - 'ACL_A_GROUPADD' => 'Can add new groups', - 'ACL_A_GROUPDEL' => 'Can delete groups', - 'ACL_A_RANKS' => 'Can manage ranks', - 'ACL_A_PROFILE' => 'Can manage custom profile fields', - 'ACL_A_NAMES' => 'Can manage disallowed names', - 'ACL_A_BAN' => 'Can manage bans', - - 'ACL_A_VIEWAUTH' => 'Can view permission masks', - 'ACL_A_AUTHGROUPS' => 'Can alter permissions for individual groups', - 'ACL_A_AUTHUSERS' => 'Can alter permissions for individual users', - 'ACL_A_FAUTH' => 'Can alter forum permission class', - 'ACL_A_MAUTH' => 'Can alter moderator permission class', - 'ACL_A_AAUTH' => 'Can alter admin permission class', - 'ACL_A_UAUTH' => 'Can alter user permission class', - 'ACL_A_ROLES' => 'Can manage roles', - 'ACL_A_SWITCHPERM' => 'Can use others permissions', - - 'ACL_A_STYLES' => 'Can manage styles', - 'ACL_A_EXTENSIONS' => 'Can manage extensions', - 'ACL_A_VIEWLOGS' => 'Can view logs', - 'ACL_A_CLEARLOGS' => 'Can clear logs', - 'ACL_A_MODULES' => 'Can manage modules', - 'ACL_A_LANGUAGE' => 'Can manage language packs', - 'ACL_A_EMAIL' => 'Can send mass email', - 'ACL_A_BOTS' => 'Can manage bots', - 'ACL_A_REASONS' => 'Can manage report/denial reasons', - 'ACL_A_BACKUP' => 'Can backup/restore database', - 'ACL_A_SEARCH' => 'Can manage search backends and settings', -)); diff --git a/install/update/old/language/en/acp/posting.php b/install/update/old/language/en/acp/posting.php deleted file mode 100644 index 119ad2d..0000000 --- a/install/update/old/language/en/acp/posting.php +++ /dev/null @@ -1,291 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* DO NOT CHANGE -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -if (empty($lang) || !is_array($lang)) -{ - $lang = array(); -} - -// DEVELOPERS PLEASE NOTE -// -// All language files should use UTF-8 as their encoding and the files must not contain a BOM. -// -// Placeholders can now contain order information, e.g. instead of -// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows -// translators to re-order the output of data while ensuring it remains correct -// -// You do not need this where single placeholders are used, e.g. 'Message %d' is fine -// equally where a string contains only two placeholders which are used to wrap text -// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine - -// BBCodes -// Note to translators: you can translate everything but what's between { and } -$lang = array_merge($lang, array( - 'ACP_BBCODES_EXPLAIN' => 'BBCode is a special implementation of HTML offering greater control over what and how something is displayed. From this page you can add, remove and edit custom BBCodes.', - 'ADD_BBCODE' => 'Add a new BBCode', - - 'BBCODE_DANGER' => 'The BBCode you are trying to add seems to use a {TEXT} token inside a HTML attribute. This is a possible XSS security issue. Try using the more restrictive {SIMPLETEXT} or {INTTEXT} types instead. Only proceed if you understand the risks involved and you consider the use of {TEXT} absolutely unavoidable.', - 'BBCODE_DANGER_PROCEED' => 'Proceed', //'I understand the risk', - - 'BBCODE_ADDED' => 'BBCode added successfully.', - 'BBCODE_EDITED' => 'BBCode edited successfully.', - 'BBCODE_DELETED' => 'The BBCode has been removed successfully.', - 'BBCODE_NOT_EXIST' => 'The BBCode you selected does not exist.', - 'BBCODE_HELPLINE' => 'Help line', - 'BBCODE_HELPLINE_EXPLAIN' => 'This field contains the mouse over text of the BBCode.', - 'BBCODE_HELPLINE_TEXT' => 'Help line text', - 'BBCODE_HELPLINE_TOO_LONG' => 'The help line you entered is too long.', - - 'BBCODE_INVALID_TAG_NAME' => 'The BBCode tag name that you selected already exists.', - 'BBCODE_INVALID' => 'Your BBCode is constructed in an invalid form.', - 'BBCODE_OPEN_ENDED_TAG' => 'Your custom BBCode must contain both an opening and a closing tag.', - 'BBCODE_TAG' => 'Tag', - 'BBCODE_TAG_TOO_LONG' => 'The tag name you selected is too long.', - 'BBCODE_TAG_DEF_TOO_LONG' => 'The tag definition that you have entered is too long, please shorten your tag definition.', - 'BBCODE_USAGE' => 'BBCode usage', - 'BBCODE_USAGE_EXAMPLE' => '[highlight={COLOR}]{TEXT}[/highlight]

[font={SIMPLETEXT1}]{SIMPLETEXT2}[/font]', - 'BBCODE_USAGE_EXPLAIN' => 'Here you define how to use the BBCode. Replace any variable input by the corresponding token (%ssee below%s).', - - 'EXAMPLE' => 'Example:', - 'EXAMPLES' => 'Examples:', - - 'HTML_REPLACEMENT' => 'HTML replacement', - 'HTML_REPLACEMENT_EXAMPLE' => '<span style="background-color: {COLOR};">{TEXT}</span>

<span style="font-family: {SIMPLETEXT1};">{SIMPLETEXT2}</span>', - 'HTML_REPLACEMENT_EXPLAIN' => 'Here you define the default HTML replacement. Do not forget to put back tokens you used above!', - - 'TOKEN' => 'Token', - 'TOKENS' => 'Tokens', - 'TOKENS_EXPLAIN' => 'Tokens are placeholders for user input. The input will be validated only if it matches the corresponding definition. If needed, you can number them by adding a number as the last character between the braces, e.g. {TEXT1}, {TEXT2}.

Within the HTML replacement you can also use any language string present in your language/ directory like this: {L_<STRINGNAME>} where <STRINGNAME> is the name of the translated string you want to add. For example, {L_WROTE} will be displayed as “wrote” or its translation according to user’s locale.

Please note that only tokens listed below are able to be used within custom BBCodes.', - 'TOKEN_DEFINITION' => 'What can it be?', - 'TOO_MANY_BBCODES' => 'You cannot create any more BBCodes. Please remove one or more BBCodes then try again.', - - 'tokens' => array( - 'TEXT' => 'Any text, including foreign characters, numbers, etc… You should not use this token in HTML tags. Instead try to use IDENTIFIER, INTTEXT or SIMPLETEXT.', - 'SIMPLETEXT' => 'Characters from the latin alphabet (A-Z), numbers, spaces, commas, dots, minus, plus, hyphen and underscore', - 'INTTEXT' => 'Unicode letter characters, numbers, spaces, commas, dots, minus, plus, hyphen, underscore and whitespaces.', - 'IDENTIFIER' => 'Characters from the latin alphabet (A-Z), numbers, hyphen and underscore', - 'NUMBER' => 'Any series of digits', - 'EMAIL' => 'A valid email address', - 'URL' => 'A valid URL using any protocol (http, ftp, etc… cannot be used for javascript exploits). If none is given, “http://” is prefixed to the string.', - 'LOCAL_URL' => 'A local URL. The URL must be relative to the topic page and cannot contain a server name or protocol, as links are prefixed with “%s”', - 'RELATIVE_URL' => 'A relative URL. You can use this to match parts of a URL, but be careful: a full URL is a valid relative URL. When you want to use relative URLs of your board, use the LOCAL_URL token.', - 'COLOR' => 'A HTML colour, can be either in the numeric form #FF1234 or a CSS colour keyword such as fuchsia or InactiveBorder', - ), -)); - -// Smilies and topic icons -$lang = array_merge($lang, array( - 'ACP_ICONS_EXPLAIN' => 'From this page you can add, remove and edit the icons users may add to their topics or posts. These icons are generally displayed next to topic titles on the forum listing, or the post subjects in topic listings. You can also install and create new packages of icons.', - 'ACP_SMILIES_EXPLAIN' => 'Smilies or emoticons are typically small, sometimes animated images used to convey an emotion or feeling. From this page you can add, remove and edit the emoticons users can use in their posts and private messages. You can also install and create new packages of smilies.', - 'ADD_SMILIES' => 'Add multiple smilies', - 'ADD_SMILEY_CODE' => 'Add additional smiley code', - 'ADD_ICONS' => 'Add multiple icons', - 'AFTER_ICONS' => 'After %s', - 'AFTER_SMILIES' => 'After %s', - - 'CODE' => 'Code', - 'CURRENT_ICONS' => 'Current icons', - 'CURRENT_ICONS_EXPLAIN' => 'Choose what to do with the currently installed icons.', - 'CURRENT_SMILIES' => 'Current smilies', - 'CURRENT_SMILIES_EXPLAIN' => 'Choose what to do with the currently installed smilies.', - - 'DISPLAY_ON_POSTING' => 'Display on posting page', - 'DISPLAY_POSTING' => 'On posting page', - 'DISPLAY_POSTING_NO' => 'Not on posting page', - - 'EDIT_ICONS' => 'Edit icons', - 'EDIT_SMILIES' => 'Edit smilies', - 'EMOTION' => 'Emotion', - 'EXPORT_ICONS' => 'Export and download icons.pak', - 'EXPORT_ICONS_EXPLAIN' => '%sOn clicking this link, the configuration for your installed icons will be packaged into icons.pak which once downloaded can be used to create a .zip or .tgz file containing all of your icons plus this icons.pak configuration file%s.', - 'EXPORT_SMILIES' => 'Export and download smilies.pak', - 'EXPORT_SMILIES_EXPLAIN' => '%sOn clicking this link, the configuration for your installed smilies will be packaged into smilies.pak which once downloaded can be used to create a .zip or .tgz file containing all of your smilies plus this smilies.pak configuration file%s.', - - 'FIRST' => 'First', - - 'ICONS_ADD' => 'Add a new icon', - 'ICONS_ADDED' => array( - 0 => 'No icons were added.', - 1 => 'The icon has been added successfully.', - 2 => 'The icons have been added successfully.', - ), - 'ICONS_CONFIG' => 'Icon configuration', - 'ICONS_DELETED' => 'The icon has been removed successfully.', - 'ICONS_EDIT' => 'Edit icon', - 'ICONS_EDITED' => array( - 0 => 'No icons were updated.', - 1 => 'The icon has been updated successfully.', - 2 => 'The icons have been updated successfully.', - ), - 'ICONS_HEIGHT' => 'Icon height', - 'ICONS_IMAGE' => 'Icon image', - 'ICONS_IMPORTED' => 'The icons pack has been installed successfully.', - 'ICONS_IMPORT_SUCCESS' => 'The icons pack was imported successfully.', - 'ICONS_LOCATION' => 'Icon location', - 'ICONS_NOT_DISPLAYED' => 'The following icons are not displayed on the posting page', - 'ICONS_ORDER' => 'Icon order', - 'ICONS_URL' => 'Icon image file', - 'ICONS_WIDTH' => 'Icon width', - 'IMPORT_ICONS' => 'Install icons package', - 'IMPORT_SMILIES' => 'Install smilies package', - - 'KEEP_ALL' => 'Keep all', - - 'MASS_ADD_SMILIES' => 'Add multiple smilies', - - 'NO_ICONS_ADD' => 'There are no icons available for adding.', - 'NO_ICONS_EDIT' => 'There are no icons available for modifying.', - 'NO_ICONS_EXPORT' => 'You have no icons with which to create a package.', - 'NO_ICONS_PAK' => 'No icon packages found.', - 'NO_SMILIES_ADD' => 'There are no smilies available for adding.', - 'NO_SMILIES_EDIT' => 'There are no smilies available for modifying.', - 'NO_SMILIES_EXPORT' => 'You have no smilies with which to create a package.', - 'NO_SMILIES_PAK' => 'No smiley packages found.', - - 'PAK_FILE_NOT_READABLE' => 'Could not read .pak file.', - - 'REPLACE_MATCHES' => 'Replace matches', - - 'SELECT_PACKAGE' => 'Select a package file', - 'SMILIES_ADD' => 'Add a new smiley', - 'SMILIES_ADDED' => array( - 0 => 'No smilies were added.', - 1 => 'The smiley has been added successfully.', - 2 => 'The smilies have been added successfully.', - ), - 'SMILIES_CODE' => 'Smiley code', - 'SMILIES_CONFIG' => 'Smiley configuration', - 'SMILIES_DELETED' => 'The smiley has been removed successfully.', - 'SMILIES_EDIT' => 'Edit smiley', - 'SMILIE_NO_CODE' => 'The smiley “%s” was ignored, as there was no code entered.', - 'SMILIE_NO_EMOTION' => 'The smiley “%s” was ignored, as there was no emotion entered.', - 'SMILIE_NO_FILE' => 'The smiley “%s” was ignored, as the file is missing.', - 'SMILIES_EDITED' => array( - 0 => 'No smilies were updated.', - 1 => 'The smiley has been updated successfully.', - 2 => 'The smilies have been updated successfully.', - ), - 'SMILIES_EMOTION' => 'Emotion', - 'SMILIES_HEIGHT' => 'Smiley height', - 'SMILIES_IMAGE' => 'Smiley image', - 'SMILIES_IMPORTED' => 'The smilies pack has been installed successfully.', - 'SMILIES_IMPORT_SUCCESS' => 'The smilies pack was imported successfully.', - 'SMILIES_LOCATION' => 'Smiley location', - 'SMILIES_NOT_DISPLAYED' => 'The following smilies are not displayed on the posting page', - 'SMILIES_ORDER' => 'Smiley order', - 'SMILIES_URL' => 'Smiley image file', - 'SMILIES_WIDTH' => 'Smiley width', - - 'TOO_MANY_SMILIES' => array( - 1 => 'Limit of %d smiley reached.', - 2 => 'Limit of %d smilies reached.', - ), - - 'WRONG_PAK_TYPE' => 'The specified package does not contain the appropriate data.', -)); - -// Word censors -$lang = array_merge($lang, array( - 'ACP_WORDS_EXPLAIN' => 'From this control panel you can add, edit, and remove words that will be automatically censored on your forums. People are still allowed to register with usernames containing these words. Wildcards (*) are accepted in the word field, e.g. *test* will match detestable, test* would match testing, *test would match detest.', - 'ADD_WORD' => 'Add new word', - - 'EDIT_WORD' => 'Edit word censor', - 'ENTER_WORD' => 'You must enter a word and its replacement.', - - 'NO_WORD' => 'No word selected for editing.', - - 'REPLACEMENT' => 'Replacement', - - 'UPDATE_WORD' => 'Update word censor', - - 'WORD' => 'Word', - 'WORD_ADDED' => 'The word censor has been successfully added.', - 'WORD_REMOVED' => 'The selected word censor has been successfully removed.', - 'WORD_UPDATED' => 'The selected word censor has been successfully updated.', -)); - -// Ranks -$lang = array_merge($lang, array( - 'ACP_RANKS_EXPLAIN' => 'Using this form you can add, edit, view and delete ranks. You can also create special ranks which can be applied to a user via the user management facility.', - 'ADD_RANK' => 'Add new rank', - - 'MUST_SELECT_RANK' => 'You must select a rank.', - - 'NO_ASSIGNED_RANK' => 'No special rank assigned.', - 'NO_RANK_TITLE' => 'You haven’t specified a title for the rank.', - 'NO_UPDATE_RANKS' => 'The rank was successfully deleted. However user accounts using this rank were not updated. You will need to manually reset the rank on these accounts.', - - 'RANK_ADDED' => 'The rank was successfully added.', - 'RANK_IMAGE' => 'Rank image', - 'RANK_IMAGE_EXPLAIN' => 'Use this to define a small image associated with the rank. The path is relative to the root phpBB directory.', - 'RANK_IMAGE_IN_USE' => '(In use)', - 'RANK_MINIMUM' => 'Minimum posts', - 'RANK_REMOVED' => 'The rank was successfully deleted.', - 'RANK_SPECIAL' => 'Set as special rank', - 'RANK_TITLE' => 'Rank title', - 'RANK_UPDATED' => 'The rank was successfully updated.', -)); - -// Disallow Usernames -$lang = array_merge($lang, array( - 'ACP_DISALLOW_EXPLAIN' => 'Here you can control usernames which will not be allowed to be used. Disallowed usernames are allowed to contain a wildcard character of *.', - 'ADD_DISALLOW_EXPLAIN' => 'You can disallow a username using the wildcard character * to match any character.', - 'ADD_DISALLOW_TITLE' => 'Add a disallowed username', - - 'DELETE_DISALLOW_EXPLAIN' => 'You can remove a disallowed username by selecting the username from this list and clicking submit.', - 'DELETE_DISALLOW_TITLE' => 'Remove a disallowed username', - 'DISALLOWED_ALREADY' => 'The name you entered is already disallowed.', - 'DISALLOWED_DELETED' => 'The disallowed username has been successfully removed.', - 'DISALLOW_SUCCESSFUL' => 'The disallowed username has been successfully added.', - - 'NO_DISALLOWED' => 'No disallowed usernames', - 'NO_USERNAME_SPECIFIED' => 'You haven’t selected or entered a username to operate with.', -)); - -// Reasons -$lang = array_merge($lang, array( - 'ACP_REASONS_EXPLAIN' => 'Here you can manage the reasons used in reports and denial messages when disapproving posts. There is one default reason (marked with a *) you are not able to remove, this reason is normally used for custom messages if no reason fits.', - 'ADD_NEW_REASON' => 'Add new reason', - 'AVAILABLE_TITLES' => 'Available localised reason titles', - - 'IS_NOT_TRANSLATED' => 'Reason has not been localised.', - 'IS_NOT_TRANSLATED_EXPLAIN' => 'Reason has not been localised. If you want to provide the localised form, specify the correct key from the language files report reasons section.', - 'IS_TRANSLATED' => 'Reason has been localised.', - 'IS_TRANSLATED_EXPLAIN' => 'Reason has been localised. If the title you enter here is specified within the language files report reasons section, the localised form of the title and description will be used.', - - 'NO_REASON' => 'Reason could not be found.', - 'NO_REASON_INFO' => 'You have to specify a title and a description for this reason.', - 'NO_REMOVE_DEFAULT_REASON' => 'You are not able to remove the default reason “Other”.', - - 'REASON_ADD' => 'Add report/denial reason', - 'REASON_ADDED' => 'Report/denial reason successfully added.', - 'REASON_ALREADY_EXIST' => 'A reason with this title already exist, please enter another title for this reason.', - 'REASON_DESCRIPTION' => 'Reason description', - 'REASON_DESC_TRANSLATED' => 'Displayed reason description', - 'REASON_EDIT' => 'Edit report/denial reason', - 'REASON_EDIT_EXPLAIN' => 'Here you are able to add or edit a reason. If the reason is translated the localised version is used instead of the description entered here.', - 'REASON_REMOVED' => 'Report/denial reason successfully removed.', - 'REASON_TITLE' => 'Reason title', - 'REASON_TITLE_TRANSLATED' => 'Displayed reason title', - 'REASON_UPDATED' => 'Report/denial reason successfully updated.', - - 'USED_IN_REPORTS' => 'Used in reports', -)); diff --git a/install/update/old/language/en/acp/profile.php b/install/update/old/language/en/acp/profile.php deleted file mode 100644 index 41cbd9c..0000000 --- a/install/update/old/language/en/acp/profile.php +++ /dev/null @@ -1,176 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* DO NOT CHANGE -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -if (empty($lang) || !is_array($lang)) -{ - $lang = array(); -} - -// DEVELOPERS PLEASE NOTE -// -// All language files should use UTF-8 as their encoding and the files must not contain a BOM. -// -// Placeholders can now contain order information, e.g. instead of -// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows -// translators to re-order the output of data while ensuring it remains correct -// -// You do not need this where single placeholders are used, e.g. 'Message %d' is fine -// equally where a string contains only two placeholders which are used to wrap text -// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine - -// Custom profile fields -$lang = array_merge($lang, array( - 'ADDED_PROFILE_FIELD' => 'Successfully added custom profile field.', - 'ALPHA_DOTS' => 'Alphanumeric and dots (periods)', - 'ALPHA_ONLY' => 'Alphanumeric only', - 'ALPHA_SPACERS' => 'Alphanumeric and spacers', - 'ALPHA_UNDERSCORE' => 'Alphanumeric and underscores', - 'ALPHA_PUNCTUATION' => 'Alphanumeric with comma, dots, underscore and dashes beginning with a letter', - 'ALWAYS_TODAY' => 'Always the current date', - - 'BOOL_ENTRIES_EXPLAIN' => 'Enter your options now', - 'BOOL_TYPE_EXPLAIN' => 'Define the type, either a checkbox or radio buttons. A checkbox will only be displayed if it is checked for a given user. In that case the second language option will be used. Radio buttons will display regardless of their value.', - - 'CHANGED_PROFILE_FIELD' => 'Successfully changed profile field.', - 'CHARS_ANY' => 'Any character', - 'CHECKBOX' => 'Checkbox', - 'COLUMNS' => 'Columns', - 'CP_LANG_DEFAULT_VALUE' => 'Default value', - 'CP_LANG_EXPLAIN' => 'Field description', - 'CP_LANG_EXPLAIN_EXPLAIN' => 'The explanation for this field presented to the user.', - 'CP_LANG_NAME' => 'Field name/title presented to the user', - 'CP_LANG_OPTIONS' => 'Options', - 'CREATE_NEW_FIELD' => 'Create new field', - 'CUSTOM_FIELDS_NOT_TRANSLATED' => 'At least one custom profile field has not yet been translated. Please enter the required information by clicking on the “Translate” link.', - - 'DEFAULT_ISO_LANGUAGE' => 'Default language [%s]', - 'DEFAULT_LANGUAGE_NOT_FILLED' => 'The language entries for the default language are not filled for this profile field.', - 'DEFAULT_VALUE' => 'Default value', - 'DELETE_PROFILE_FIELD' => 'Remove profile field', - 'DELETE_PROFILE_FIELD_CONFIRM' => 'Are you sure you want to delete this profile field?', - 'DISPLAY_AT_PROFILE' => 'Display in user control panel', - 'DISPLAY_AT_PROFILE_EXPLAIN' => 'The user is able to change this profile field within the user control panel.', - 'DISPLAY_AT_REGISTER' => 'Display on registration screen', - 'DISPLAY_AT_REGISTER_EXPLAIN' => 'If this option is enabled, the field will be displayed on registration.', - 'DISPLAY_ON_MEMBERLIST' => 'Display on memberlist screen', - 'DISPLAY_ON_MEMBERLIST_EXPLAIN' => 'If this option is enabled, the field will be displayed in the user rows on the memberlist screen.', - 'DISPLAY_ON_PM' => 'Display on view private message screen', - 'DISPLAY_ON_PM_EXPLAIN' => 'If this option is enabled, the field will be displayed in the mini-profile on the private message screen.', - 'DISPLAY_ON_VT' => 'Display on viewtopic screen', - 'DISPLAY_ON_VT_EXPLAIN' => 'If this option is enabled, the field will be displayed in the mini-profile on the topic screen.', - 'DISPLAY_PROFILE_FIELD' => 'Publicly display profile field', - 'DISPLAY_PROFILE_FIELD_EXPLAIN' => 'The profile field will be shown in all locations allowed within the load settings. Setting this to “no” will hide the field from topic pages, profiles and the memberlist.', - 'DROPDOWN_ENTRIES_EXPLAIN' => 'Enter your options now, every option in one line.', - - 'EDIT_DROPDOWN_LANG_EXPLAIN' => 'Please note that you are able to change your options text and also able to add new options to the end. It is not advised to add new options between existing options - this could result in wrong options assigned to your users. This can also happen if you remove options in-between. Removing options from the end result in users having assigned this item now reverting back to the default one.', - 'EMPTY_FIELD_IDENT' => 'Empty field identification', - 'EMPTY_USER_FIELD_NAME' => 'Please enter a field name/title', - 'ENTRIES' => 'Entries', - 'EVERYTHING_OK' => 'Everything OK', - - 'FIELD_BOOL' => 'Boolean (Yes/No)', - 'FIELD_CONTACT_DESC' => 'Contact description', - 'FIELD_CONTACT_URL' => 'Contact link', - 'FIELD_DATE' => 'Date', - 'FIELD_DESCRIPTION' => 'Field description', - 'FIELD_DESCRIPTION_EXPLAIN' => 'The explanation for this field presented to the user.', - 'FIELD_DROPDOWN' => 'Dropdown box', - 'FIELD_GOOGLEPLUS' => 'Google+', - 'FIELD_IDENT' => 'Field identification', - 'FIELD_IDENT_ALREADY_EXIST' => 'The chosen field identification already exist. Please choose another name.', - 'FIELD_IDENT_EXPLAIN' => 'The field identification is a name to identify the profile field within the database and the templates.', - 'FIELD_INT' => 'Numbers', - 'FIELD_IS_CONTACT' => 'Display field as a contact field', - 'FIELD_IS_CONTACT_EXPLAIN' => 'Contact fields are displayed within the contact section of the user profile and are displayed differently in the mini profile next to posts and private messages. You can use %s as a placeholder variable which will be replaced by a value provided by the user.', - 'FIELD_LENGTH' => 'Length of input box', - 'FIELD_NOT_FOUND' => 'Profile field not found.', - 'FIELD_STRING' => 'Single text field', - 'FIELD_TEXT' => 'Textarea', - 'FIELD_TYPE' => 'Field type', - 'FIELD_TYPE_EXPLAIN' => 'You are not able to change the field type later.', - 'FIELD_URL' => 'URL (Link)', - 'FIELD_VALIDATION' => 'Field validation', - 'FIRST_OPTION' => 'First option', - - 'HIDE_PROFILE_FIELD' => 'Hide profile field', - 'HIDE_PROFILE_FIELD_EXPLAIN' => 'Hide the profile field from all other users except the user, administrators and moderators who are still able to see this field. If the Display in user control panel option is disabled, the user will not be able to see or change this field and the field can only be changed by administrators.', - - 'INVALID_CHARS_FIELD_IDENT' => 'Field identification can only contain lowercase a-z and _', - 'INVALID_FIELD_IDENT_LEN' => 'Field identification can only be 17 characters long', - 'ISO_LANGUAGE' => 'Language [%s]', - - 'LANG_SPECIFIC_OPTIONS' => 'Language specific options [%s]', - - 'LETTER_NUM_DOTS' => 'Any letters, numbers and dots (periods)', - 'LETTER_NUM_ONLY' => 'Any letters and numbers', - 'LETTER_NUM_PUNCTUATION' => 'Any letters, numbers, comma, dots, underscores and dashes beginning with any letter', - 'LETTER_NUM_SPACERS' => 'Any letters, numbers and spacers', - 'LETTER_NUM_UNDERSCORE' => 'Any letters, numbers and underscores', - - 'MAX_FIELD_CHARS' => 'Maximum number of characters', - 'MAX_FIELD_NUMBER' => 'Highest allowed number', - 'MIN_FIELD_CHARS' => 'Minimum number of characters', - 'MIN_FIELD_NUMBER' => 'Lowest allowed number', - - 'NO_FIELD_ENTRIES' => 'No entries defined', - 'NO_FIELD_ID' => 'No field id specified.', - 'NO_FIELD_TYPE' => 'No Field type specified.', - 'NO_VALUE_OPTION' => 'Option equal to non entered value', - 'NO_VALUE_OPTION_EXPLAIN' => 'Value for a non-entry. If the field is required, the user gets an error if he choose the option selected here.', - 'NUMBERS_ONLY' => 'Only numbers (0-9)', - - 'PROFILE_BASIC_OPTIONS' => 'Basic options', - 'PROFILE_FIELD_ACTIVATED' => 'Profile field successfully activated.', - 'PROFILE_FIELD_DEACTIVATED' => 'Profile field successfully deactivated.', - 'PROFILE_LANG_OPTIONS' => 'Language specific options', - 'PROFILE_TYPE_OPTIONS' => 'Profile type specific options', - - 'RADIO_BUTTONS' => 'Radio buttons', - 'REMOVED_PROFILE_FIELD' => 'Successfully removed profile field.', - 'REQUIRED_FIELD' => 'Required field', - 'REQUIRED_FIELD_EXPLAIN' => 'Force profile field to be filled out or specified by user or administrator. If display at registration screen option is disabled, the field will only be required when the user edits their profile.', - 'ROWS' => 'Rows', - - 'SAVE' => 'Save', - 'SECOND_OPTION' => 'Second option', - 'SHOW_NOVALUE_FIELD' => 'Show field if no value was selected', - 'SHOW_NOVALUE_FIELD_EXPLAIN' => 'Determines if the profile field should be displayed if no value was selected for optional fields or if no value has been selected yet for required fields.', - 'STEP_1_EXPLAIN_CREATE' => 'Here you can enter the first basic parameters of your new profile field. This information is needed for the second step where you’ll be able to set remaining options and tweak your profile field further.', - 'STEP_1_EXPLAIN_EDIT' => 'Here you can change the basic parameters of your profile field. The relevant options are re-calculated within the second step.', - 'STEP_1_TITLE_CREATE' => 'Add profile field', - 'STEP_1_TITLE_EDIT' => 'Edit profile field', - 'STEP_2_EXPLAIN_CREATE' => 'Here you are able to define some common options you may want to adjust.', - 'STEP_2_EXPLAIN_EDIT' => 'Here you are able to change some common options.
Please note that changes to profile fields will not affect existing profile fields entered by your users.', - 'STEP_2_TITLE_CREATE' => 'Profile type specific options', - 'STEP_2_TITLE_EDIT' => 'Profile type specific options', - 'STEP_3_EXPLAIN_CREATE' => 'Since you have more than one board language installed, you have to fill out the remaining language items too. If you don’t, then default language setting for this custom profile field will be used, you are able to fill out the remaining language items later too.', - 'STEP_3_EXPLAIN_EDIT' => 'Since you have more than one board language installed, you now can change or add the remaining language items too. If you don’t, then default language setting for this custom profile field will be used.', - 'STEP_3_TITLE_CREATE' => 'Remaining language definitions', - 'STEP_3_TITLE_EDIT' => 'Language definitions', - 'STRING_DEFAULT_VALUE_EXPLAIN' => 'Enter a default phrase to be displayed, a default value. Leave empty if you want to show it empty at the first place.', - - 'TEXT_DEFAULT_VALUE_EXPLAIN' => 'Enter a default text to be displayed, a default value. Leave empty if you want to show it empty at the first place.', - 'TRANSLATE' => 'Translate', - - 'USER_FIELD_NAME' => 'Field name/title presented to the user', - - 'VISIBILITY_OPTION' => 'Visibility options', -)); diff --git a/install/update/old/language/en/acp/styles.php b/install/update/old/language/en/acp/styles.php deleted file mode 100644 index ab85d9d..0000000 --- a/install/update/old/language/en/acp/styles.php +++ /dev/null @@ -1,90 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* DO NOT CHANGE -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -if (empty($lang) || !is_array($lang)) -{ - $lang = array(); -} - -// DEVELOPERS PLEASE NOTE -// -// All language files should use UTF-8 as their encoding and the files must not contain a BOM. -// -// Placeholders can now contain order information, e.g. instead of -// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows -// translators to re-order the output of data while ensuring it remains correct -// -// You do not need this where single placeholders are used, e.g. 'Message %d' is fine -// equally where a string contains only two placeholders which are used to wrap text -// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine - -$lang = array_merge($lang, array( - 'ACP_STYLES_EXPLAIN' => 'Here you can manage the available styles on your board. You may alter existing styles, delete, deactivate, reactivate, install new ones. You can also see what a style will look like using the preview function. Also listed is the total user count for each style, note that overriding user styles will not be reflected here.', - - 'CANNOT_BE_INSTALLED' => 'Cannot be installed', - 'CONFIRM_UNINSTALL_STYLES' => 'Are you sure you wish to uninstall selected styles?', - 'COPYRIGHT' => 'Copyright', - - 'DEACTIVATE_DEFAULT' => 'You cannot deactivate the default style.', - 'DELETE_FROM_FS' => 'Delete from filesystem', - 'DELETE_STYLE_FILES_FAILED' => 'Error deleting files for style "%s".', - 'DELETE_STYLE_FILES_SUCCESS' => 'Files for style "%s" have been deleted.', - 'DETAILS' => 'Details', - - 'INHERITING_FROM' => 'Inherits from', - 'INSTALL_STYLE' => 'Install style', - 'INSTALL_STYLES' => 'Install styles', - 'INSTALL_STYLES_EXPLAIN' => 'Here you can install new styles.
If you cannot find a specific style in list below, check to make sure style is already installed. If it is not installed, check if it was uploaded correctly.', - 'INVALID_STYLE_ID' => 'Invalid style ID.', - - 'NO_MATCHING_STYLES_FOUND' => 'No styles match your query.', - 'NO_UNINSTALLED_STYLE' => 'No uninstalled styles detected.', - - 'PURGED_CACHE' => 'Cache was purged.', - - 'REQUIRES_STYLE' => 'This style requires the style "%s" to be installed.', - - 'STYLE_ACTIVATE' => 'Activate', - 'STYLE_ACTIVE' => 'Active', - 'STYLE_DEACTIVATE' => 'Deactivate', - 'STYLE_DEFAULT' => 'Make default style', - 'STYLE_DEFAULT_CHANGE_INACTIVE' => 'You must activate style before making it default style.', - 'STYLE_ERR_INVALID_PARENT' => 'Invalid parent style.', - 'STYLE_ERR_NAME_EXIST' => 'A style with that name already exists.', - 'STYLE_ERR_STYLE_NAME' => 'You must supply a name for this style.', - 'STYLE_INSTALLED' => 'Style "%s" has been installed.', - 'STYLE_INSTALLED_RETURN_INSTALLED_STYLES' => 'Return to installed styles list', - 'STYLE_INSTALLED_RETURN_UNINSTALLED_STYLES' => 'Install more styles', - 'STYLE_NAME' => 'Style name', - 'STYLE_NAME_RESERVED' => 'Style "%s" can not be installed, because the name is reserved.', - 'STYLE_NOT_INSTALLED' => 'Style "%s" was not installed.', - 'STYLE_PATH' => 'Style path', - 'STYLE_UNINSTALL' => 'Uninstall', - 'STYLE_UNINSTALL_DEPENDENT' => 'Style "%s" cannot be uninstalled because it has one or more child styles.', - 'STYLE_UNINSTALLED' => 'Style "%s" uninstalled successfully.', - 'STYLE_PHPBB_VERSION' => 'phpBB Version', - 'STYLE_USED_BY' => 'Used by (including robots)', - 'STYLE_VERSION' => 'Style version', - - 'UNINSTALL_DEFAULT' => 'You cannot uninstall the default style.', - - 'BROWSE_STYLES_DATABASE' => 'Browse styles database', -)); diff --git a/install/update/old/language/en/captcha_recaptcha.php b/install/update/old/language/en/captcha_recaptcha.php deleted file mode 100644 index dde2a4b..0000000 --- a/install/update/old/language/en/captcha_recaptcha.php +++ /dev/null @@ -1,52 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* DO NOT CHANGE -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -if (empty($lang) || !is_array($lang)) -{ - $lang = array(); -} - -// DEVELOPERS PLEASE NOTE -// -// All language files should use UTF-8 as their encoding and the files must not contain a BOM. -// -// Placeholders can now contain order information, e.g. instead of -// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows -// translators to re-order the output of data while ensuring it remains correct -// -// You do not need this where single placeholders are used, e.g. 'Message %d' is fine -// equally where a string contains only two placeholders which are used to wrap text -// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine - -$lang = array_merge($lang, array( - 'RECAPTCHA_LANG' => 'en-GB', // Find the language/country code on https://developers.google.com/recaptcha/docs/language - If no code exists for your language you can use "en" or leave the string empty - 'RECAPTCHA_NOT_AVAILABLE' => 'In order to use reCaptcha, you must create an account on www.google.com/recaptcha.', - 'CAPTCHA_RECAPTCHA' => 'reCaptcha', - 'RECAPTCHA_INCORRECT' => 'The solution you provided was incorrect', - 'RECAPTCHA_NOSCRIPT' => 'Please enable JavaScript in your browser to load the challenge.', - - 'RECAPTCHA_PUBLIC' => 'Public reCaptcha key', - 'RECAPTCHA_PUBLIC_EXPLAIN' => 'Your public reCaptcha key. Keys can be obtained on www.google.com/recaptcha.', - 'RECAPTCHA_PRIVATE' => 'Private reCaptcha key', - 'RECAPTCHA_PRIVATE_EXPLAIN' => 'Your private reCaptcha key. Keys can be obtained on www.google.com/recaptcha.', - - 'RECAPTCHA_EXPLAIN' => 'In an effort to prevent automatic submissions, we require that you complete the following challenge.', -)); diff --git a/install/update/old/language/en/cli.php b/install/update/old/language/en/cli.php deleted file mode 100644 index 505d12e..0000000 --- a/install/update/old/language/en/cli.php +++ /dev/null @@ -1,178 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* DO NOT CHANGE -*/ -if (empty($lang) || !is_array($lang)) -{ - $lang = array(); -} - -// DEVELOPERS PLEASE NOTE -// -// Placeholders can now contain order information, e.g. instead of -// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows -// translators to re-order the output of data while ensuring it remains correct -// -// You do not need this where single placeholders are used, e.g. 'Message %d' is fine -// equally where a string contains only two placeholders which are used to wrap text -// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine - -$lang = array_merge($lang, array( - 'CLI_CONFIG_CANNOT_CACHED' => 'Set this option if the configuration option changes too frequently to be efficiently cached.', - 'CLI_CONFIG_CURRENT' => 'Current configuration value, use 0 and 1 to specify boolean values', - 'CLI_CONFIG_DELETE_SUCCESS' => 'Successfully deleted config %s.', - 'CLI_CONFIG_NEW' => 'New configuration value, use 0 and 1 to specify boolean values', - 'CLI_CONFIG_NOT_EXISTS' => 'Config %s does not exist', - 'CLI_CONFIG_OPTION_NAME' => 'The configuration option’s name', - 'CLI_CONFIG_PRINT_WITHOUT_NEWLINE' => 'Set this option if the value should be printed without a new line at the end.', - 'CLI_CONFIG_INCREMENT_BY' => 'Amount to increment by', - 'CLI_CONFIG_INCREMENT_SUCCESS' => 'Successfully incremented config %s', - 'CLI_CONFIG_SET_FAILURE' => 'Could not set config %s', - 'CLI_CONFIG_SET_SUCCESS' => 'Successfully set config %s', - - 'CLI_DESCRIPTION_CRON_LIST' => 'Prints a list of ready and unready cron jobs.', - 'CLI_DESCRIPTION_CRON_RUN' => 'Runs all ready cron tasks.', - 'CLI_DESCRIPTION_CRON_RUN_ARGUMENT_1' => 'Name of the task to be run', - 'CLI_DESCRIPTION_DB_LIST' => 'List all installed and available migrations.', - 'CLI_DESCRIPTION_DB_MIGRATE' => 'Updates the database by applying migrations.', - 'CLI_DESCRIPTION_DB_REVERT' => 'Revert a migration.', - 'CLI_DESCRIPTION_DELETE_CONFIG' => 'Deletes a configuration option', - 'CLI_DESCRIPTION_DISABLE_EXTENSION' => 'Disables the specified extension.', - 'CLI_DESCRIPTION_ENABLE_EXTENSION' => 'Enables the specified extension.', - 'CLI_DESCRIPTION_FIND_MIGRATIONS' => 'Finds migrations that are not depended upon.', - 'CLI_DESCRIPTION_FIX_LEFT_RIGHT_IDS' => 'Repairs the tree structure of the forums and modules.', - 'CLI_DESCRIPTION_GET_CONFIG' => 'Gets a configuration option’s value', - 'CLI_DESCRIPTION_INCREMENT_CONFIG' => 'Increments a configuration option’s integer value', - 'CLI_DESCRIPTION_LIST_EXTENSIONS' => 'Lists all extensions in the database and on the filesystem.', - - 'CLI_DESCRIPTION_OPTION_ENV' => 'The Environment name.', - 'CLI_DESCRIPTION_OPTION_SAFE_MODE' => 'Run in Safe Mode (without extensions).', - 'CLI_DESCRIPTION_OPTION_SHELL' => 'Launch the shell.', - - 'CLI_DESCRIPTION_PURGE_EXTENSION' => 'Purges the specified extension.', - - 'CLI_DESCRIPTION_REPARSER_LIST' => 'Lists the types of text that can be reparsed.', - 'CLI_DESCRIPTION_REPARSER_AVAILABLE' => 'Available reparsers:', - 'CLI_DESCRIPTION_REPARSER_REPARSE' => 'Reparses stored text with the current text_formatter services.', - 'CLI_DESCRIPTION_REPARSER_REPARSE_ARG_1' => 'Type of text to reparse. Leave blank to reparse everything.', - 'CLI_DESCRIPTION_REPARSER_REPARSE_OPT_DRY_RUN' => 'Do not save any changes; just print what would happen', - 'CLI_DESCRIPTION_REPARSER_REPARSE_OPT_RANGE_MIN' => 'Lowest record ID to process', - 'CLI_DESCRIPTION_REPARSER_REPARSE_OPT_RANGE_MAX' => 'Highest record ID to process', - 'CLI_DESCRIPTION_REPARSER_REPARSE_OPT_RANGE_SIZE' => 'Approximate number of records to process at a time', - 'CLI_DESCRIPTION_REPARSER_REPARSE_OPT_RESUME' => 'Start reparsing where the last execution stopped', - - 'CLI_DESCRIPTION_RECALCULATE_EMAIL_HASH' => 'Recalculates the user_email_hash column of the users table.', - - 'CLI_DESCRIPTION_SET_ATOMIC_CONFIG' => 'Sets a configuration option’s value only if the old matches the current value', - 'CLI_DESCRIPTION_SET_CONFIG' => 'Sets a configuration option’s value', - - 'CLI_DESCRIPTION_THUMBNAIL_DELETE' => 'Delete all existing thumbnails.', - 'CLI_DESCRIPTION_THUMBNAIL_GENERATE' => 'Generate all missing thumbnails.', - 'CLI_DESCRIPTION_THUMBNAIL_RECREATE' => 'Recreate all thumbnails.', - - 'CLI_DESCRIPTION_UPDATE_CHECK' => 'Check if the board is up to date.', - 'CLI_DESCRIPTION_UPDATE_CHECK_ARGUMENT_1' => 'Name of the extension to check (if all, checks all the extensions)', - 'CLI_DESCRIPTION_UPDATE_CHECK_OPTION_CACHE' => 'Run check command with cache.', - 'CLI_DESCRIPTION_UPDATE_CHECK_OPTION_STABILITY' => 'Run command choosing to check only stable or unstable versions.', - - 'CLI_DESCRIPTION_UPDATE_HASH_BCRYPT' => 'Updates outdated password hashes to be hashed with bcrypt.', - - 'CLI_ERROR_INVALID_STABILITY' => '"%s" needs to be set to "stable" or "unstable".', - - 'CLI_DESCRIPTION_USER_ACTIVATE' => 'Activate (or deactivate) a user account.', - 'CLI_DESCRIPTION_USER_ACTIVATE_USERNAME' => 'Username of the account to activate.', - 'CLI_DESCRIPTION_USER_ACTIVATE_DEACTIVATE' => 'Deactivate the user’s account', - 'CLI_DESCRIPTION_USER_ACTIVATE_ACTIVE' => 'The user is already active.', - 'CLI_DESCRIPTION_USER_ACTIVATE_INACTIVE' => 'The user is already inactive.', - 'CLI_DESCRIPTION_USER_ADD' => 'Add a new user.', - 'CLI_DESCRIPTION_USER_ADD_OPTION_USERNAME' => 'Username of the new user', - 'CLI_DESCRIPTION_USER_ADD_OPTION_PASSWORD' => 'Password of the new user', - 'CLI_DESCRIPTION_USER_ADD_OPTION_EMAIL' => 'E-mail address of the new user', - 'CLI_DESCRIPTION_USER_ADD_OPTION_NOTIFY' => 'Send account activation email to the new user (not sent by default)', - 'CLI_DESCRIPTION_USER_DELETE' => 'Delete a user account.', - 'CLI_DESCRIPTION_USER_DELETE_USERNAME' => 'Username of the user to delete', - 'CLI_DESCRIPTION_USER_DELETE_OPTION_POSTS' => 'Delete all posts by the user. Without this option, the user’s posts will be retained.', - 'CLI_DESCRIPTION_USER_RECLEAN' => 'Re-clean usernames.', - - 'CLI_EXTENSION_DISABLE_FAILURE' => 'Could not disable extension %s', - 'CLI_EXTENSION_DISABLE_SUCCESS' => 'Successfully disabled extension %s', - 'CLI_EXTENSION_DISABLED' => 'Extension %s is not enabled', - 'CLI_EXTENSION_ENABLE_FAILURE' => 'Could not enable extension %s', - 'CLI_EXTENSION_ENABLE_SUCCESS' => 'Successfully enabled extension %s', - 'CLI_EXTENSION_ENABLED' => 'Extension %s is already enabled', - 'CLI_EXTENSION_NOT_EXIST' => 'Extension %s does not exist', - 'CLI_EXTENSION_NAME' => 'Name of the extension', - 'CLI_EXTENSION_PURGE_FAILURE' => 'Could not purge extension %s', - 'CLI_EXTENSION_PURGE_SUCCESS' => 'Successfully purged extension %s', - 'CLI_EXTENSION_UPDATE_FAILURE' => 'Could not update extension %s', - 'CLI_EXTENSION_UPDATE_SUCCESS' => 'Successfully updated extension %s', - 'CLI_EXTENSION_NOT_FOUND' => 'No extensions were found.', - 'CLI_EXTENSION_NOT_ENABLEABLE' => 'Extension %s is not enableable.', - 'CLI_EXTENSIONS_AVAILABLE' => 'Available', - 'CLI_EXTENSIONS_DISABLED' => 'Disabled', - 'CLI_EXTENSIONS_ENABLED' => 'Enabled', - - 'CLI_FIXUP_FIX_LEFT_RIGHT_IDS_SUCCESS' => 'Successfully repaired the tree structure of the forums and modules.', - 'CLI_FIXUP_RECALCULATE_EMAIL_HASH_SUCCESS' => 'Successfully recalculated all email hashes.', - 'CLI_FIXUP_UPDATE_HASH_BCRYPT_SUCCESS' => 'Successfully updated outdated password hashes to bcrypt.', - - 'CLI_MIGRATION_NAME' => 'Migration name, including the namespace (use forward slashes instead of backslashes to avoid problems).', - 'CLI_MIGRATIONS_AVAILABLE' => 'Available migrations', - 'CLI_MIGRATIONS_INSTALLED' => 'Installed migrations', - 'CLI_MIGRATIONS_ONLY_AVAILABLE' => 'Show only available migrations', - 'CLI_MIGRATIONS_EMPTY' => 'No migrations.', - - 'CLI_REPARSER_REPARSE_REPARSING' => 'Reparsing %1$s (range %2$d..%3$d)', - 'CLI_REPARSER_REPARSE_REPARSING_START' => 'Reparsing %s...', - 'CLI_REPARSER_REPARSE_SUCCESS' => 'Reparsing ended with success', - - // In all the case %1$s is the logical name of the file and %2$s the real name on the filesystem - // eg: big_image.png (2_a51529ae7932008cf8454a95af84cacd) generated. - 'CLI_THUMBNAIL_DELETED' => '%1$s (%2$s) deleted.', - 'CLI_THUMBNAIL_DELETING' => 'Deleting thumbnails', - 'CLI_THUMBNAIL_SKIPPED' => '%1$s (%2$s) skipped.', - 'CLI_THUMBNAIL_GENERATED' => '%1$s (%2$s) generated.', - 'CLI_THUMBNAIL_GENERATING' => 'Generating thumbnails', - 'CLI_THUMBNAIL_GENERATING_DONE' => 'All thumbnails have been regenerated.', - 'CLI_THUMBNAIL_DELETING_DONE' => 'All thumbnails have been deleted.', - - 'CLI_THUMBNAIL_NOTHING_TO_GENERATE' => 'No thumbnails to generate.', - 'CLI_THUMBNAIL_NOTHING_TO_DELETE' => 'No thumbnails to delete.', - - 'CLI_USER_ADD_SUCCESS' => 'Successfully added user %s.', - 'CLI_USER_DELETE_CONFIRM' => 'Are you sure you want to delete ‘%s’? [y/N]', - 'CLI_USER_RECLEAN_START' => 'Re-cleaning usernames', - 'CLI_USER_RECLEAN_DONE' => [ - 0 => 'Re-cleaning complete. No usernames needed to be cleaned.', - 1 => 'Re-cleaning complete. %d username was cleaned.', - 2 => 'Re-cleaning complete. %d usernames were cleaned.', - ], -)); - -// Additional help for commands. -$lang = array_merge($lang, array( - 'CLI_HELP_CRON_RUN' => $lang['CLI_DESCRIPTION_CRON_RUN'] . ' Optionally you can specify a cron task name to run only the specified cron task.', - 'CLI_HELP_USER_ACTIVATE' => 'Activate a user account, or deactivate an account using the --deactivate option. -To optionally send an activation email to the user, use the --send-email option.', - 'CLI_HELP_USER_ADD' => 'The %command.name% command adds a new user: -If this command is run without options, you will be prompted to enter them. -To optionally send an email to the new user, use the --send-email option.', - 'CLI_HELP_USER_RECLEAN' => 'Re-clean usernames will check all stored usernames and ensure clean versions are also stored. Cleaned usernames are a case insensitive form, NFC normalized and transformed to ASCII.', -)); diff --git a/install/update/old/language/en/common.php b/install/update/old/language/en/common.php deleted file mode 100644 index 8350307..0000000 --- a/install/update/old/language/en/common.php +++ /dev/null @@ -1,1438 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* DO NOT CHANGE -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -if (empty($lang) || !is_array($lang)) -{ - $lang = array(); -} - -// DEVELOPERS PLEASE NOTE -// -// All language files should use UTF-8 as their encoding and the files must not contain a BOM. -// -// Placeholders can now contain order information, e.g. instead of -// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows -// translators to re-order the output of data while ensuring it remains correct -// -// You do not need this where single placeholders are used, e.g. 'Message %d' is fine -// equally where a string contains only two placeholders which are used to wrap text -// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine -// -// Some characters you may want to copy&paste: -// ’ » “ ” … -// - -$lang = array_merge($lang, array( - 'TRANSLATION_INFO' => '', - 'DIRECTION' => 'ltr', - 'DATE_FORMAT' => '|d M Y|', // 01 Jan 2007 (with Relative days enabled) - 'DATETIME_FORMAT' => '|d M Y, H:i|', // 01 Jan 2007, 13:37 (with Relative days enabled) - 'USER_LANG' => 'en-gb', - - // You can define different rules for the determination of plural forms here. - // See https://area51.phpbb.com/docs/dev/32x/language/plurals.html for more information - // or ask the translation manager for help. - 'PLURAL_RULE' => 1, - - '1_DAY' => '1 day', - '1_MONTH' => '1 month', - '1_YEAR' => '1 year', - '2_WEEKS' => '2 weeks', - '3_MONTHS' => '3 months', - '6_MONTHS' => '6 months', - '7_DAYS' => '7 days', - - 'ACCOUNT_ALREADY_ACTIVATED' => 'Your account has already been activated.', - 'ACCOUNT_DEACTIVATED' => 'Your account has been manually deactivated and is only able to be reactivated by an administrator.', - 'ACP' => 'Administration Control Panel', - 'ACP_SHORT' => 'ACP', - 'ACTIVE' => 'active', - 'ACTIVE_ERROR' => 'The specified username is currently inactive. If you have problems activating your account, please contact a board administrator.', - 'ADMINISTRATOR' => 'Administrator', - 'ADMINISTRATORS' => 'Administrators', - 'AGE' => 'Age', - 'AIM' => 'AIM', - 'AJAX_ERROR_TITLE' => 'AJAX error', - 'AJAX_ERROR_TEXT' => 'Something went wrong when processing your request.', - 'AJAX_ERROR_TEXT_ABORT' => 'User aborted request.', - 'AJAX_ERROR_TEXT_TIMEOUT' => 'Your request timed out; please try again.', - 'AJAX_ERROR_TEXT_PARSERERROR' => 'Something went wrong with the request and the server returned an invalid reply.', - 'ALLOWED' => 'Allowed', - 'ALL_FILES' => 'All files', - 'ALL_FORUMS' => 'All forums', - 'ALL_MESSAGES' => 'All messages', - 'ALL_POSTS' => 'All posts', - 'ALL_TIMES' => 'All times are %1$s', - 'ALL_TOPICS' => 'All Topics', - 'ALT_TEXT' => 'Alternative text', - 'AND' => 'And', - 'ARE_WATCHING_FORUM' => 'You have subscribed to be notified of new posts in this forum.', - 'ARE_WATCHING_TOPIC' => 'You have subscribed to be notified of new posts in this topic.', - 'ASCENDING' => 'Ascending', - 'ATTACHMENTS' => 'Attachments', - 'ATTACHED_IMAGE_NOT_IMAGE' => 'The image file you tried to attach is invalid.', - 'AUTHOR' => 'Author', - 'AUTH_NO_PROFILE_CREATED' => 'The creation of a user profile was unsuccessful.', - 'AUTH_PROVIDER_OAUTH_ERROR_INVALID_ENTRY' => 'Invalid database entry.', - 'AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE' => 'Invalid service type provided to OAuth service handler.', - 'AUTH_PROVIDER_OAUTH_ERROR_SERVICE_NOT_CREATED' => 'OAuth service not created', - 'AUTH_PROVIDER_OAUTH_SERVICE_BITLY' => 'Bitly', - 'AUTH_PROVIDER_OAUTH_SERVICE_FACEBOOK' => 'Facebook', - 'AUTH_PROVIDER_OAUTH_SERVICE_GOOGLE' => 'Google', - 'AUTH_PROVIDER_OAUTH_SERVICE_TWITTER' => 'Twitter', - 'AUTH_PROVIDER_OAUTH_TOKEN_ERROR_NOT_STORED' => 'OAuth token not stored.', - 'AUTH_PROVIDER_OAUTH_TOKEN_ERROR_INCORRECTLY_STORED' => 'OAuth token incorrectly stored.', - 'AVATAR_DISALLOWED_CONTENT' => 'The upload was rejected because the uploaded file was identified as a possible attack vector.', - 'AVATAR_DISALLOWED_EXTENSION' => 'This file cannot be displayed because the extension %s is not allowed.', - 'AVATAR_EMPTY_REMOTE_DATA' => 'The specified avatar could not be uploaded because the remote data appears to be invalid or corrupted.', - 'AVATAR_EMPTY_FILEUPLOAD' => 'The uploaded avatar file is empty.', - 'AVATAR_INVALID_FILENAME' => '%s is an invalid filename.', - 'AVATAR_NOT_UPLOADED' => 'Avatar could not be uploaded.', - 'AVATAR_NO_TEMP_DIR' => 'Temporary folder could not be found or is not writable.', - 'AVATAR_NO_SIZE' => 'The width or height of the linked avatar could not be determined. Please enter them manually.', - 'AVATAR_PARTIAL_UPLOAD' => 'The specified file was only partially uploaded.', - 'AVATAR_PHP_SIZE_NA' => 'The avatar’s filesize is too large.
The maximum allowed filesize set in php.ini could not be determined.', - 'AVATAR_PHP_SIZE_OVERRUN' => 'The avatar’s filesize is too large. The maximum allowed upload size is %1$d %2$s.
Please note this is set in php.ini and cannot be overridden.', - 'AVATAR_REMOTE_UPLOAD_TIMEOUT' => 'The specified avatar could not be uploaded because the request timed out.', - 'AVATAR_PHP_UPLOAD_STOPPED' => 'A PHP extension has stopped the file upload.', - 'AVATAR_URL_INVALID' => 'The URL you specified is invalid.', - 'AVATAR_URL_NOT_FOUND' => 'The file specified could not be found.', - 'AVATAR_WRONG_FILESIZE' => 'The avatar’s filesize must be between 0 and %1$d %2$s.', - 'AVATAR_WRONG_SIZE' => 'The submitted avatar is %5$s wide and %6$s high. Avatars must be at least %1$s wide and %2$s high, but no larger than %3$s wide and %4$s high.', - - 'BACK_TO_TOP' => 'Top', - 'BACK_TO_PREV' => 'Back to previous page', - 'BAN_TRIGGERED_BY_EMAIL'=> 'A ban has been issued on your email address.', - 'BAN_TRIGGERED_BY_IP' => 'A ban has been issued on your IP address.', - 'BAN_TRIGGERED_BY_USER' => 'A ban has been issued on your username.', - 'BBCODE_GUIDE' => 'BBCode guide', - 'BCC' => 'BCC', - 'BIRTHDAYS' => 'Birthdays', - 'BOARD_BAN_PERM' => 'You have been permanently banned from this board.

Please contact the %2$sBoard Administrator%3$s for more information.', - 'BOARD_BAN_REASON' => 'Reason given for ban: %s', - 'BOARD_BAN_TIME' => 'You have been banned from this board until %1$s.

Please contact the %2$sBoard Administrator%3$s for more information.', - 'BOARD_DISABLE' => 'Sorry but this board is currently unavailable.', - 'BOARD_DISABLED' => 'This board is currently disabled.', - 'BOARD_UNAVAILABLE' => 'Sorry but the board is temporarily unavailable, please try again in a few minutes.', - 'BROWSING_FORUM' => 'Users browsing this forum: %1$s', - 'BROWSING_FORUM_GUESTS' => array( - 1 => 'Users browsing this forum: %2$s and %1$d guest', - 2 => 'Users browsing this forum: %2$s and %1$d guests', - ), - 'BUTTON_DELETE' => 'Delete', - 'BUTTON_EDIT' => 'Edit', - 'BUTTON_FORUM_LOCKED' => 'Locked', - 'BUTTON_INFORMATION' => 'Information', - 'BUTTON_NEW_TOPIC' => 'New Topic', - 'BUTTON_PM' => 'PM', - 'BUTTON_PM_FORWARD' => 'Forward', - 'BUTTON_PM_NEW' => 'New PM', - 'BUTTON_PM_REPLY' => 'Send Reply', - 'BUTTON_PM_REPLY_ALL' => 'Reply All', - 'BUTTON_POST_REPLY' => 'Post Reply', - 'BUTTON_QUOTE' => 'Quote', - 'BUTTON_REPORT' => 'Report', - 'BUTTON_TOPIC_LOCKED' => 'Locked', - 'BUTTON_WARN' => 'Warn', - 'BYTES' => 'Bytes', - 'BYTES_SHORT' => 'B', - - 'CANCEL' => 'Cancel', - 'CHANGE' => 'Change', - 'CHANGE_FONT_SIZE' => 'Change font size', - 'CHANGING_PREFERENCES' => 'Changing board preferences', - 'CHANGING_PROFILE' => 'Changing profile settings', - 'CHARACTERS' => array( - 1 => '%d character', - 2 => '%d characters', - ), - 'COLLAPSE_VIEW' => 'Collapse view', - 'CLOSE_WINDOW' => 'Close window', - 'COLOUR_SWATCH' => 'Colour swatch', - 'COLON' => ':', - 'COMMA_SEPARATOR' => ', ', // Comma used to join lists into a single string, use localised comma if appropriate, eg: Ideographic or Arabic - 'CONFIRM' => 'Confirm', - 'CONFIRM_CODE' => 'Confirmation code', - 'CONFIRM_CODE_EXPLAIN' => 'Enter the code exactly as it appears. All letters are case insensitive.', - 'CONFIRM_CODE_WRONG' => 'The confirmation code you entered was incorrect.', - 'CONFIRM_OPERATION' => 'Are you sure you wish to carry out this operation?', - 'CONFIRM_AVATAR_DELETE' => 'Are you sure you wish to delete this avatar?', - 'CONGRATULATIONS' => 'Congratulations to', - 'CONNECTION_FAILED' => 'Connection failed.', - 'CONNECTION_SUCCESS' => 'Connection was successful!', - 'CONTACT' => 'Contact', - 'CONTACT_USER' => 'Contact %s', - 'CONTACT_US' => 'Contact us', - 'COOKIE_CONSENT_INFO' => 'Learn more', - 'COOKIE_CONSENT_MSG' => 'This website uses cookies to ensure you get the best experience on our website.', - 'COOKIE_CONSENT_OK' => 'Got it!', - 'COOKIE_CONSENT_HREF' => 'http://cookiesandyou.com', - 'COOKIES_DELETED' => 'All board cookies successfully deleted.', - 'CURRENT_TIME' => 'It is currently %s', - - 'DAY' => 'Day', - 'DAYS' => 'Days', - 'DELETE' => 'Delete', - 'DELETE_ALL' => 'Delete all', - 'DELETE_COOKIES' => 'Delete cookies', - 'DELETE_MARKED' => 'Delete marked', - 'DELETE_POST' => 'Delete post', - 'DELIMITER' => 'Delimiter', - 'DESCENDING' => 'Descending', - 'DISABLED' => 'Disabled', - 'DISPLAY' => 'Display', - 'DISPLAY_GUESTS' => 'Display guests', - 'DISPLAY_MESSAGES' => 'Display messages from previous', - 'DISPLAY_POSTS' => 'Display posts from previous', - 'DISPLAY_TOPICS' => 'Display topics from previous', - 'DOWNLOADED' => 'Downloaded', - 'DOWNLOADING_FILE' => 'Downloading file', - 'DOWNLOAD_COUNTS' => array( - 0 => 'Not downloaded yet', - 1 => 'Downloaded %d time', - 2 => 'Downloaded %d times', - ), - - 'EDIT_POST' => 'Edit post', - 'ELLIPSIS' => '…', - 'EMAIL' => 'Email', // Short form for EMAIL_ADDRESS - 'EMAIL_ADDRESS' => 'Email address', - 'EMAIL_INVALID_EMAIL' => 'The email address you entered is invalid.', - 'EMAIL_SMTP_ERROR_RESPONSE' => 'Ran into problems sending email at Line %1$s. Response: %2$s.', - 'EMPTY_SUBJECT' => 'You must specify a subject when posting a new topic.', - 'EMPTY_MESSAGE_SUBJECT' => 'You must specify a subject when composing a new message.', - 'ENABLED' => 'Enabled', - 'ENCLOSURE' => 'Enclosure', - 'ENTER_USERNAME' => 'Enter username', - 'ERR_CHANGING_DIRECTORY' => 'Unable to change directory.', - 'ERR_CONNECTING_SERVER' => 'Error connecting to the server.', - 'ERR_JAB_AUTH' => 'Could not authorise on Jabber server.', - 'ERR_JAB_CONNECT' => 'Could not connect to Jabber server.', - 'ERR_UNABLE_TO_LOGIN' => 'The specified username or password is incorrect.', - 'ERR_UNWATCHING' => 'An error occurred while trying to unsubscribe.', - 'ERR_WATCHING' => 'An error occurred while trying to subscribe.', - 'ERR_WRONG_PATH_TO_PHPBB' => 'The phpBB path specified appears to be invalid.', - 'ERROR' => 'Error', - 'EXPAND_VIEW' => 'Expand view', - 'EXTENSION' => 'Extension', - 'EXTENSION_DISABLED' => 'The extension %s is not enabled.', - 'EXTENSION_DISABLED_AFTER_POSTING' => 'The extension %s has been deactivated and can no longer be displayed.', - 'EXTENSION_DOES_NOT_EXIST' => 'The extension %s does not exist.', - - 'FACEBOOK' => 'Facebook', - 'FAQ' => 'FAQ', - 'FAQ_EXPLAIN' => 'Frequently Asked Questions', - 'FEATURE_NOT_AVAILABLE' => 'The requested feature is not available on this board.', - 'FILENAME' => 'Filename', - 'FILESIZE' => 'File size', - 'FILEDATE' => 'File date', - 'FILE_COMMENT' => 'File comment', - 'FILE_CONTENT_ERR' => 'Could not read the contents of file: %s', - 'FILE_JSON_DECODE_ERR' => 'Failed to decode json file: %s', - 'FILE_NOT_FOUND' => 'The requested file could not be found: %s', - 'FIND_USERNAME' => 'Find a member', - 'FOLDER' => 'Folder', - 'FORGOT_PASS' => 'I forgot my password', - 'FORM_INVALID' => 'The submitted form was invalid. Try submitting again.', - 'FORUM' => 'Forum', - 'FORUMS' => 'Forums', - 'FORUMS_MARKED' => 'Forums have been marked read.', - 'FORUM_CAT' => 'Forum category', - 'FORUM_INDEX' => 'Board index', - 'FORUM_LINK' => 'Forum link', - 'FORUM_LOCATION' => 'Forum location', - 'FORUM_LOCKED' => 'Forum locked', - 'FORUM_RULES' => 'Forum rules', - 'FORUM_RULES_LINK' => 'Please click here to view the forum rules', - 'FROM' => 'from', - 'FSOCK_DISABLED' => 'The operation could not be completed because the fsockopen function has been disabled or the server being queried could not be found.', - 'FSOCK_TIMEOUT' => 'A timeout occurred while reading from the network stream.', - - 'FTP_FSOCK_HOST' => 'FTP host', - 'FTP_FSOCK_HOST_EXPLAIN' => 'FTP server used to connect your site.', - 'FTP_FSOCK_PASSWORD' => 'FTP password', - 'FTP_FSOCK_PASSWORD_EXPLAIN' => 'Password for your FTP username.', - 'FTP_FSOCK_PORT' => 'FTP port', - 'FTP_FSOCK_PORT_EXPLAIN' => 'Port used to connect to your server.', - 'FTP_FSOCK_ROOT_PATH' => 'Path to phpBB', - 'FTP_FSOCK_ROOT_PATH_EXPLAIN' => 'Path from the root to your phpBB board.', - 'FTP_FSOCK_TIMEOUT' => 'FTP timeout', - 'FTP_FSOCK_TIMEOUT_EXPLAIN' => 'The amount of time, in seconds, that the system will wait for a reply from your server.', - 'FTP_FSOCK_USERNAME' => 'FTP username', - 'FTP_FSOCK_USERNAME_EXPLAIN' => 'Username used to connect to your server.', - - 'FTP_HOST' => 'FTP host', - 'FTP_HOST_EXPLAIN' => 'FTP server used to connect your site.', - 'FTP_PASSWORD' => 'FTP password', - 'FTP_PASSWORD_EXPLAIN' => 'Password for your FTP username.', - 'FTP_PORT' => 'FTP port', - 'FTP_PORT_EXPLAIN' => 'Port used to connect to your server.', - 'FTP_ROOT_PATH' => 'Path to phpBB', - 'FTP_ROOT_PATH_EXPLAIN' => 'Path from the root to your phpBB board.', - 'FTP_TIMEOUT' => 'FTP timeout', - 'FTP_TIMEOUT_EXPLAIN' => 'The amount of time, in seconds, that the system will wait for a reply from your server.', - 'FTP_USERNAME' => 'FTP username', - 'FTP_USERNAME_EXPLAIN' => 'Username used to connect to your server.', - - 'GENERAL_ERROR' => 'General Error', - 'GB' => 'GB', - 'GIB' => 'GiB', - 'GO' => 'Go', - 'GOOGLEPLUS' => 'Google+', - 'GOTO_FIRST_POST' => 'Go to first post', - 'GOTO_LAST_POST' => 'Go to last post', - 'GOTO_PAGE' => 'Go to page', - 'GROUP' => 'Group', - 'GROUPS' => 'Groups', - 'GROUP_ERR_TYPE' => 'Inappropriate group type specified.', - 'GROUP_ERR_USERNAME' => 'No group name specified.', - 'GROUP_ERR_USER_LONG' => 'Group names cannot exceed 60 characters. The specified group name is too long.', - 'GUEST' => 'Guest', - 'GUEST_USERS_ONLINE' => array( - 1 => 'There is %d guest user online', - 2 => 'There are %d guest users online', - ), - 'GUEST_USERS_TOTAL' => array( - 1 => '%d guest', - 2 => '%d guests', - ), - 'G_ADMINISTRATORS' => 'Administrators', - 'G_BOTS' => 'Bots', - 'G_GUESTS' => 'Guests', - 'G_REGISTERED' => 'Registered users', - 'G_REGISTERED_COPPA' => 'Registered COPPA users', - 'G_GLOBAL_MODERATORS' => 'Global moderators', - 'G_NEWLY_REGISTERED' => 'Newly registered users', - - 'HIDDEN_USERS_ONLINE' => array( - 1 => '%d hidden user', - 2 => '%d hidden users', - ), - 'HIDDEN_USERS_TOTAL' => array( - 1 => '%d hidden', - 2 => '%d hidden', - ), - 'HIDE_GUESTS' => 'Hide guests', - 'HIDE_ME' => 'Hide my online status this session', - 'HOURS' => 'Hours', - 'HOME' => 'Home', - - 'ICQ' => 'ICQ', - 'IF' => 'If', - 'IMAGE' => 'Image', - 'IMAGE_FILETYPE_INVALID' => 'Image file type %d for mimetype %s not supported.', - 'IMAGE_FILETYPE_MISMATCH' => 'Image file type mismatch: expected extension %1$s but extension %2$s given.', - 'IN' => 'in', - 'INACTIVE' => 'Inactive', - 'INDEX' => 'Index page', - 'INFORMATION' => 'Information', - 'INSECURE_REDIRECT' => 'Tried to redirect to potentially insecure url.', - 'INTERESTS' => 'Interests', - 'INVALID_DIGEST_CHALLENGE' => 'Invalid digest challenge.', - 'INVALID_EMAIL_LOG' => '%s possibly an invalid email address?', - 'INVALID_FEED_ATTACHMENTS' => 'The selected feed tried fetching attachments with invalid constraints.', - 'INVALID_PLURAL_RULE' => 'The chosen plural rule is invalid. Valid values are integers between 0 and 15.', - 'IP' => 'IP', - 'IP_BLACKLISTED' => 'Your IP %1$s has been blocked because it is blacklisted. For details please see %2$s.', - - 'JABBER' => 'Jabber', - 'JOINED' => 'Joined', - 'JUMP_PAGE' => 'Enter the page number you wish to go to', - 'JUMP_TO' => 'Jump to', - 'JUMP_TO_PAGE' => 'Jump to page', - 'JUMP_TO_PAGE_CLICK' => 'Click to jump to page…', - - 'KB' => 'KB', - 'KIB' => 'KiB', - - 'LAST_POST' => 'Last post', - 'LAST_UPDATED' => 'Last updated', - 'LAST_VISIT' => 'Last visit', - 'LDAP_NO_LDAP_EXTENSION' => 'LDAP extension not available.', - 'LDAP_NO_SERVER_CONNECTION' => 'Could not connect to LDAP server.', - 'LDAP_SEARCH_FAILED' => 'An error occurred while searching the LDAP directory.', - 'LEGEND' => 'Legend', - 'LIVE_SEARCHES_NOT_ALLOWED' => 'Live searches are not allowed.', - 'LOADING' => 'Loading', - 'LOCATION' => 'Location', - 'LOCK_POST' => 'Lock post', - 'LOCK_POST_EXPLAIN' => 'Prevent editing', - 'LOCK_TOPIC' => 'Lock topic', - 'LOGIN' => 'Login', - 'LOGIN_CHECK_PM' => 'Log in to check your private messages.', - 'LOGIN_CONFIRMATION' => 'Confirmation of login', - 'LOGIN_CONFIRM_EXPLAIN' => 'To prevent brute forcing accounts the board requires you to enter a confirmation code after a maximum amount of failed logins. The code is displayed in the image you should see below. If you are visually impaired or cannot otherwise read this code please contact the %sBoard Administrator%s.', // unused - 'LOGIN_ERROR_ATTEMPTS' => 'You exceeded the maximum allowed number of login attempts. In addition to your username and password you now also have to solve the CAPTCHA below.', - 'LOGIN_ERROR_EXTERNAL_AUTH_APACHE' => 'You have not been authenticated by Apache.', - 'LOGIN_ERROR_OAUTH_SERVICE_DOES_NOT_EXIST' => 'A non-existant OAuth service has been requested.', - 'LOGIN_ERROR_PASSWORD' => 'You have specified an incorrect password. Please check your password and try again. If you continue to have problems please contact the %sBoard Administrator%s.', - 'LOGIN_ERROR_PASSWORD_CONVERT' => 'It was not possible to convert your password when updating this bulletin board’s software. Please %srequest a new password%s. If you continue to have problems please contact the %sBoard Administrator%s.', - 'LOGIN_ERROR_USERNAME' => 'You have specified an incorrect username. Please check your username and try again. If you continue to have problems please contact the %sBoard Administrator%s.', - 'LOGIN_FORUM' => 'To view or post in this forum you must enter its password.', - 'LOGIN_INFO' => 'In order to login you must be registered. Registering takes only a few moments but gives you increased capabilities. The board administrator may also grant additional permissions to registered users. Before you register please ensure you are familiar with our terms of use and related policies. Please ensure you read any forum rules as you navigate around the board.', - 'LOGIN_VIEWFORUM' => 'The board requires you to be registered and logged in to view this forum.', - 'LOGIN_EXPLAIN_EDIT' => 'In order to edit posts in this forum you have to be registered and logged in.', - 'LOGIN_EXPLAIN_VIEWONLINE' => 'In order to view the online list you have to be registered and logged in.', - 'LOGIN_REQUIRED' => 'You need to login to perform this action.', - 'LOGOUT' => 'Logout', - 'LOGOUT_USER' => 'Logout [ %s ]', - 'LOG_ME_IN' => 'Remember me', - - 'MAIN' => 'Main', - 'MARK' => 'Mark', - 'MARK_ALL' => 'Mark all', - 'MARK_ALL_READ' => 'Mark all read', - 'MARK_FORUMS_READ' => 'Mark forums read', - 'MARK_READ' => 'Mark read', - 'MARK_SUBFORUMS_READ' => 'Mark subforums read', - 'MB' => 'MB', - 'MIB' => 'MiB', - 'MCP' => 'Moderator Control Panel', - 'MCP_SHORT' => 'MCP', - 'MEMBERLIST' => 'Members', - 'MEMBERLIST_EXPLAIN' => 'View complete list of members', - 'MERGE' => 'Merge', - 'MERGE_POSTS' => 'Move posts', - 'MERGE_TOPIC' => 'Merge topic', - 'MESSAGE' => 'Message', - 'MESSAGES' => 'Messages', - 'MESSAGES_COUNT' => array( - 1 => '%d message', - 2 => '%d messages', - ), - 'MESSAGE_BODY' => 'Message body', - 'MINUTES' => 'Minutes', - 'MODERATE' => 'Moderate', - 'MODERATOR' => 'Moderator', - 'MODERATORS' => 'Moderators', - 'MODULE_NOT_ACCESS' => 'Module not accessible', - 'MODULE_NOT_FIND' => 'Cannot find module %s', - 'MODULE_FILE_INCORRECT_CLASS' => 'Module file %s does not contain correct class [%s]', - 'MONTH' => 'Month', - 'MOVE' => 'Move', - - 'NA' => 'N/A', - 'NEWEST_USER' => 'Our newest member %s', - 'NEW_MESSAGE' => 'New message', - 'NEW_MESSAGES' => 'New messages', - 'NEW_POST' => 'New post', // Not used anymore - 'NEW_POSTS' => 'New posts', // Not used anymore - 'NEXT' => 'Next', // Used in pagination - 'NEXT_STEP' => 'Next', - 'NEVER' => 'Never', - 'NO' => 'No', - 'NO_NOTIFICATIONS' => 'You have no notifications', - 'NOT_ALLOWED_MANAGE_GROUP' => 'You are not allowed to manage this group.', - 'NOT_AUTHORISED' => 'You are not authorised to access this area.', - 'NOT_WATCHING_FORUM' => 'You are no longer subscribed to updates on this forum.', - 'NOT_WATCHING_TOPIC' => 'You are no longer subscribed to this topic.', - 'NOTIFICATIONS' => 'Notifications', - // This applies for NOTIFICATION_BOOKMARK and NOTIFICATION_POST. - // %1$s will return a list of users that's concatenated using "," and "and" - see STRING_LIST - // Once the user count reaches 5 users or more, the list is trimmed using NOTIFICATION_X_OTHERS - // Once the user count reaches 20 users or more, the list is trimmed using NOTIFICATION_MANY_OTHERS - // Examples: - // A replied... - // A and B replied... - // A, B and C replied... - // A, B, C and 2 others replied... - // A, B, C and others replied... - 'NOTIFICATION_BOOKMARK' => array( - 1 => 'Reply from %1$s in bookmarked topic:', - ), - 'NOTIFICATION_FORUM' => 'Forum: %1$s', - 'NOTIFICATION_GROUP_REQUEST' => 'Group request from %1$s to join the group %2$s.', - 'NOTIFICATION_GROUP_REQUEST_APPROVED' => 'Group request approved to join the group %1$s.', - 'NOTIFICATION_METHOD_INVALID' => 'The method "%s" does not refer to a valid notification method.', - 'NOTIFICATION_PM' => 'Private Message from %1$s:', - 'NOTIFICATION_POST' => array( - 1 => 'Reply from %1$s in topic:', - ), - 'NOTIFICATION_POST_APPROVED' => 'Post approved:', - 'NOTIFICATION_POST_DISAPPROVED' => 'Post disapproved:', - 'NOTIFICATION_POST_IN_QUEUE' => 'Post approval request by %1$s:', - 'NOTIFICATION_QUOTE' => array( - 1 => 'Quoted by %1$s in:', - ), - 'NOTIFICATION_REFERENCE' => '"%1$s"', - 'NOTIFICATION_REASON' => 'Reason: %1$s.', - 'NOTIFICATION_REPORT_PM' => 'Private Message reported by %1$s:', - 'NOTIFICATION_REPORT_POST' => 'Post reported by %1$s:', - 'NOTIFICATION_REPORT_CLOSED' => 'Report closed by %1$s for:', - 'NOTIFICATION_TOPIC' => 'New topic by %1$s:', - 'NOTIFICATION_TOPIC_APPROVED' => 'Topic approved:', - 'NOTIFICATION_TOPIC_DISAPPROVED' => 'Topic disapproved:', - 'NOTIFICATION_TOPIC_IN_QUEUE' => 'Topic approval request by %1$s:', - 'NOTIFICATION_TYPE_NOT_EXIST' => 'The notification type "%s" is missing from the file system.', - 'NOTIFICATION_ADMIN_ACTIVATE_USER' => 'Activation required for deactivated or newly registered user: “%1$s”', - // Used in conjuction with NOTIFICATION_BOOKMARK and NOTIFICATION_POST. - 'NOTIFICATION_MANY_OTHERS' => 'others', - 'NOTIFICATION_X_OTHERS' => array( - 2 => '%d others', - ), - 'NOTIFY_ADMIN' => 'Please notify the board administrator or webmaster.', - 'NOTIFY_ADMIN_EMAIL' => 'Please notify the board administrator or webmaster: %1$s', - 'NO_ACCESS_ATTACHMENT' => 'You are not allowed to access this file.', - 'NO_ACTION' => 'No action specified.', - 'NO_ADMINISTRATORS' => 'There are no administrators.', - 'NO_AUTH_ADMIN' => 'Access to the Administration Control Panel is not allowed as you do not have administrative permissions.', - 'NO_AUTH_ADMIN_USER_DIFFER' => 'You are not able to re-authenticate as a different user.', - 'NO_AUTH_OPERATION' => 'You do not have the necessary permissions to complete this operation.', - 'NO_AVATARS' => 'No avatars currently available', - 'NO_CONNECT_TO_SMTP_HOST' => 'Could not connect to smtp host : %1$s : %2$s', - 'NO_BIRTHDAYS' => 'No birthdays today', - 'NO_EMAIL_MESSAGE' => 'Email message was blank.', - 'NO_EMAIL_RESPONSE_CODE' => 'Could not get mail server response codes.', - 'NO_EMAIL_SUBJECT' => 'No email subject specified.', - 'NO_FORUM' => 'The forum you selected does not exist.', - 'NO_FORUMS' => 'This board has no forums.', - 'NO_GROUP' => 'The requested usergroup does not exist.', - 'NO_GROUP_MEMBERS' => 'This group currently has no members.', - 'NO_IPS_DEFINED' => 'No IP addresses or hostnames defined', - 'NO_MEMBERS' => 'No members found for this search criterion.', - 'NO_MESSAGES' => 'No messages', - 'NO_MODE' => 'No mode specified.', - 'NO_MODERATORS' => 'There are no moderators.', - 'NO_NEW_MESSAGES' => 'No new messages', - 'NO_NEW_POSTS' => 'No new posts', // Not used anymore - 'NO_ONLINE_USERS' => 'No registered users', - 'NO_POSTS' => 'No posts', - 'NO_POSTS_TIME_FRAME' => 'No posts exist inside this topic for the selected time frame.', - 'NO_FEED_ENABLED' => 'Feeds are not available on this board.', - 'NO_FEED' => 'The requested feed is not available.', - 'NO_STYLE_DATA' => 'Could not get style data', - 'NO_SUBJECT' => 'No subject specified', // Used for posts having no subject defined but displayed within management pages. - 'NO_SUCH_SEARCH_MODULE' => 'The specified search backend doesn’t exist.', - 'NO_SUPPORTED_AUTH_METHODS' => 'No supported authentication methods.', - 'NO_TOPIC' => 'The requested topic does not exist.', - 'NO_TOPIC_FORUM' => 'The topic or forum no longer exists.', - 'NO_TOPICS' => 'There are no topics or posts in this forum.', - 'NO_TOPICS_TIME_FRAME' => 'No topics exist inside this forum for the selected time frame.', - 'NO_UNREAD_POSTS' => 'No unread posts', - 'NO_UPLOAD_FORM_FOUND' => 'Upload initiated but no valid file upload form found.', - 'NO_USER' => 'The requested user does not exist.', - 'NO_USERS' => 'The requested users do not exist.', - 'NO_USER_SPECIFIED' => 'No username was specified.', - - // Nullar/Singular/Plural language entry. The key numbers define the number range in which a certain grammatical expression is valid. - 'NUM_ATTACHMENTS' => array( - 1 => '%d attachment', - 2 => '%d attachments', - ), - 'NUM_POSTS_IN_QUEUE' => array( - 0 => 'No posts in queue', // 0 - 1 => '1 post in queue', // 1 - 2 => '%d posts in queue', // 2+ - ), - - 'OCCUPATION' => 'Occupation', - 'OFFLINE' => 'Offline', - 'ONLINE' => 'Online', - 'ONLINE_BUDDIES' => 'Online friends', - // "... :: x registered and y hidden" - 'ONLINE_USERS_TOTAL' => array( - 1 => 'In total there is %1$d user online :: %2$s and %3$s', - 2 => 'In total there are %1$d users online :: %2$s and %3$s', - ), - // "... :: x registered, y hidden and z guests" - 'ONLINE_USERS_TOTAL_GUESTS' => array( - 1 => 'In total there is %1$d user online :: %2$s, %3$s and %4$s', - 2 => 'In total there are %1$d users online :: %2$s, %3$s and %4$s', - ), - 'OPTIONS' => 'Options', - - 'PAGE_NOT_FOUND' => 'The requested page could not be found.', - 'PAGE_OF' => 'Page %1$d of %2$d', - 'PAGE_TITLE_NUMBER' => 'Page %s', - 'PASSWORD' => 'Password', - 'PIXEL' => 'px', - 'PIXELS' => array( - 1 => '%d pixel', - 2 => '%d pixels', - ), - 'PLEASE_WAIT' => 'Please wait.', - 'PM' => 'PM', - 'PM_REPORTED' => 'Click to view report', - 'POSTING_MESSAGE' => 'Posting message in %s', - 'POSTING_PRIVATE_MESSAGE' => 'Composing private message', - 'POST' => 'Post', - 'POST_ANNOUNCEMENT' => 'Announce', - 'POST_STICKY' => 'Sticky', - 'POSTED' => 'Posted', - 'POSTED_IN_FORUM' => 'in', - 'POSTED_ON_DATE' => 'on', - 'POSTS' => 'Posts', - 'POSTS_UNAPPROVED' => 'At least one post in this topic has not been approved.', - 'POSTS_UNAPPROVED_FORUM'=> 'At least one post in this forum has not been approved.', - 'POST_BY_AUTHOR' => 'by', - 'POST_BY_FOE' => '%1$s, who is currently on your ignore list, made this post.', - 'POST_DISPLAY' => '%1$sDisplay this post%2$s.', - 'POST_DAY' => '%.2f posts per day', - 'POST_DELETED_ACTION' => 'Deleted post:', - 'POST_DELETED' => 'This post has been deleted.', - 'POST_DELETED_BY' => '%2$s deleted the post by %1$s on %3$s.', - 'POST_DELETED_BY_REASON'=> '%2$s deleted the post by %1$s on %3$s for the following reason: %4$s', - 'POST_DETAILS' => 'Post details', - 'POST_NEW_TOPIC' => 'Post new topic', - 'POST_PCT' => '%.2f%% of all posts', - 'POST_PCT_ACTIVE' => '%.2f%% of user’s posts', - 'POST_PCT_ACTIVE_OWN' => '%.2f%% of your posts', - 'POST_REPLY' => 'Post a reply', - 'POST_REPORTED' => 'Click to view report', - 'POST_SUBJECT' => 'Post subject', - 'POST_TIME' => 'Post time', - 'POST_TOPIC' => 'Post a new topic', - 'POST_UNAPPROVED_ACTION' => 'Post awaiting approval:', - 'POST_UNAPPROVED' => 'This post has not been approved.', - 'POWERED_BY' => 'Powered by %s', - 'PREVIEW' => 'Preview', - 'PREVIOUS' => 'Previous', // Used in pagination - 'PREVIOUS_STEP' => 'Previous', - 'PRIVACY' => 'Privacy policy', - 'PRIVACY_LINK' => 'Privacy', - 'PRIVATE_MESSAGE' => 'Private message', - 'PRIVATE_MESSAGES' => 'Private messages', - 'PRIVATE_MESSAGING' => 'Private messaging', - 'PROFILE' => 'User Control Panel', - - 'QUICK_LINKS' => 'Quick links', - - 'RANK' => 'Rank', - 'READING_FORUM' => 'Viewing topics in %s', - 'READING_GLOBAL_ANNOUNCE' => 'Reading global announcement', - 'READING_LINK' => 'Following forum link %s', - 'READING_TOPIC' => 'Reading topic in %s', - 'READ_PROFILE' => 'Profile', - 'REASON' => 'Reason', - 'RECORD_ONLINE_USERS' => 'Most users ever online was %1$s on %2$s', - 'REDIRECT' => 'Redirect', - 'REDIRECTS' => 'Total redirects', - 'REGISTER' => 'Register', - 'REGISTERED_USERS' => 'Registered users:', - // "... and 2 hidden users online" - 'REG_USERS_ONLINE' => array( - 1 => 'There is %1$d registered user and %2$s online', - 2 => 'There are %1$d registered users and %2$s online', - ), - 'REG_USERS_TOTAL' => array( - 1 => '%d registered', - 2 => '%d registered', - ), - 'REMOVE' => 'Remove', - 'REMOVE_INSTALL' => 'Please delete, move or rename the install directory before you use your board. If this directory is still present, only the Administration Control Panel (ACP) will be accessible.', - 'REPLIES' => 'Replies', - 'REPLY_WITH_QUOTE' => 'Reply with quote', - 'REPLYING_GLOBAL_ANNOUNCE' => 'Replying to global announcement', - 'REPLYING_MESSAGE' => 'Replying to message in %s', - 'REPORT_BY' => 'Report by', - 'REPORT_POST' => 'Report this post', - 'REPORTING_POST' => 'Reporting post', - 'RESEND_ACTIVATION' => 'Resend activation email', - 'RESET' => 'Reset', - 'RESTORE_PERMISSIONS' => 'Restore permissions', - 'RETURN_INDEX' => '%sReturn to the index page%s', - 'RETURN_FORUM' => '%sReturn to the forum last visited%s', - 'RETURN_PAGE' => '%sReturn to the previous page%s', - 'RETURN_TOPIC' => '%sReturn to the topic last visited%s', - 'RETURN_TO' => 'Return to “%s”', - 'RETURN_TO_INDEX' => 'Return to Board Index', - 'FEED' => 'Feed', - 'FEED_NEWS' => 'News', - 'FEED_TOPICS_ACTIVE' => 'Active Topics', - 'FEED_TOPICS_NEW' => 'New Topics', - 'RULES_ATTACH_CAN' => 'You can post attachments in this forum', - 'RULES_ATTACH_CANNOT' => 'You cannot post attachments in this forum', - 'RULES_DELETE_CAN' => 'You can delete your posts in this forum', - 'RULES_DELETE_CANNOT' => 'You cannot delete your posts in this forum', - 'RULES_DOWNLOAD_CAN' => 'You can download attachments in this forum', - 'RULES_DOWNLOAD_CANNOT' => 'You cannot download attachments in this forum', - 'RULES_EDIT_CAN' => 'You can edit your posts in this forum', - 'RULES_EDIT_CANNOT' => 'You cannot edit your posts in this forum', - 'RULES_LOCK_CAN' => 'You can lock your topics in this forum', - 'RULES_LOCK_CANNOT' => 'You cannot lock your topics in this forum', - 'RULES_POST_CAN' => 'You can post new topics in this forum', - 'RULES_POST_CANNOT' => 'You cannot post new topics in this forum', - 'RULES_REPLY_CAN' => 'You can reply to topics in this forum', - 'RULES_REPLY_CANNOT' => 'You cannot reply to topics in this forum', - 'RULES_VOTE_CAN' => 'You can vote in polls in this forum', - 'RULES_VOTE_CANNOT' => 'You cannot vote in polls in this forum', - - 'SEARCH' => 'Search', - 'SEARCH_MINI' => 'Search…', - 'SEARCH_ADV' => 'Advanced search', - 'SEARCH_ADV_EXPLAIN' => 'View the advanced search options', - 'SEARCH_KEYWORDS' => 'Search for keywords', - 'SEARCHING_FORUMS' => 'Searching forums', - 'SEARCH_ACTIVE_TOPICS' => 'Active topics', - 'SEARCH_FOR' => 'Search for', - 'SEARCH_FORUM' => 'Search this forum…', - 'SEARCH_NEW' => 'New posts', - 'SEARCH_POSTS_BY' => 'Search posts by', - 'SEARCH_SELF' => 'Your posts', - 'SEARCH_TOPIC' => 'Search this topic…', - 'SEARCH_UNANSWERED' => 'Unanswered topics', - 'SEARCH_UNREAD' => 'Unread posts', - 'SEARCH_USER_POSTS' => 'Search user’s posts', - 'SECONDS' => 'Seconds', - 'SEE_ALL' => 'See All', - 'SELECT' => 'Select', - 'SELECT_ALL_CODE' => 'Select all', - 'SELECT_DESTINATION_FORUM' => 'Please select a destination forum', - 'SELECT_FORUM' => 'Select a forum', - 'SEND_EMAIL' => 'Send email', // Used for submit buttons - 'SEND_EMAIL_USER' => 'Send email to %s', - 'SEND_PRIVATE_MESSAGE' => 'Send private message', - 'SETTINGS' => 'Settings', - 'SIGNATURE' => 'Signature', - 'SKIP' => 'Skip to content', - 'SKYPE' => 'Skype', - 'SMTP_NO_AUTH_SUPPORT' => 'SMTP server does not support authentication.', - 'SORRY_AUTH_READ' => 'You are not authorised to read this forum.', - 'SORRY_AUTH_READ_TOPIC' => 'You are not authorised to read this topic.', - 'SORRY_AUTH_VIEW_ATTACH' => 'You are not authorised to download this attachment.', - 'SORT_BY' => 'Sort by', - 'SORT_DIRECTION' => 'Direction', - 'SORT_JOINED' => 'Joined date', - 'SORT_LOCATION' => 'Location', - 'SORT_OPTIONS' => 'Display and sorting options', - 'SORT_RANK' => 'Rank', - 'SORT_POSTS' => 'Posts', - 'SORT_TOPIC_TITLE' => 'Topic title', - 'SORT_USERNAME' => 'Username', - 'SPLIT_TOPIC' => 'Split topic', - 'SQL_ERROR_OCCURRED' => 'An SQL error occurred while fetching this page. Please contact the %sBoard Administrator%s if this problem persists.', - 'STATISTICS' => 'Statistics', - 'START_WATCHING_FORUM' => 'Subscribe forum', - 'START_WATCHING_TOPIC' => 'Subscribe topic', - 'STOP_WATCHING_FORUM' => 'Unsubscribe forum', - 'STOP_WATCHING_TOPIC' => 'Unsubscribe topic', - 'STRING_LIST_MULTI' => '%1$s, and %2$s', - 'STRING_LIST_SIMPLE' => '%1$s and %2$s', - 'SUBFORUM' => 'Subforum', - 'SUBFORUMS' => 'Subforums', - 'SUBJECT' => 'Subject', - 'SUBMIT' => 'Submit', - - 'TB' => 'TB', - 'TERMS_LINK' => 'Terms', - 'TERMS_USE' => 'Terms of use', - 'TEST_CONNECTION' => 'Test connection', - 'THE_TEAM' => 'The team', - 'TIB' => 'TiB', - 'TIME' => 'Time', - 'TIMEOUT_PROCESSING_REQ' => 'Request timed out.', - - 'TOO_LARGE' => 'The value you entered is too large.', - 'TOO_LARGE_MAX_RECIPIENTS' => 'The value of Maximum number of allowed recipients per private message setting you entered is too large.', - - 'TOO_LONG' => 'The value you entered is too long.', - - 'TOO_LONG_CONFIRM_CODE' => 'The confirm code you entered is too long.', - 'TOO_LONG_DATEFORMAT' => 'The date format you entered is too long.', - 'TOO_LONG_JABBER' => 'The Jabber account name you entered is too long.', - 'TOO_LONG_NEW_PASSWORD' => 'The password you entered is too long.', - 'TOO_LONG_PASSWORD_CONFIRM' => 'The password confirmation you entered is too long.', - 'TOO_LONG_USER_PASSWORD' => 'The password you entered is too long.', - 'TOO_LONG_USERNAME' => 'The username you entered is too long.', - 'TOO_LONG_EMAIL' => 'The email address you entered is too long.', - - 'TOO_MANY_VOTE_OPTIONS' => 'You have tried to vote for too many options.', - - 'TOO_SHORT' => 'The value you entered is too short.', - - 'TOO_SHORT_CONFIRM_CODE' => 'The confirm code you entered is too short.', - 'TOO_SHORT_DATEFORMAT' => 'The date format you entered is too short.', - 'TOO_SHORT_JABBER' => 'The Jabber account name you entered is too short.', - 'TOO_SHORT_NEW_PASSWORD' => 'The password you entered is too short.', - 'TOO_SHORT_PASSWORD_CONFIRM' => 'The password confirmation you entered is too short.', - 'TOO_SHORT_USER_PASSWORD' => 'The password you entered is too short.', - 'TOO_SHORT_USERNAME' => 'The username you entered is too short.', - 'TOO_SHORT_EMAIL' => 'The email address you entered is too short.', - 'TOO_SHORT_EMAIL_CONFIRM' => 'The email address confirmation you entered is too short.', - 'TOO_SMALL' => 'The value you entered is too small.', - 'TOO_SMALL_MAX_RECIPIENTS' => 'The value of Maximum number of allowed recipients per private message setting you entered is too small.', - - 'TOPIC' => 'Topic', - 'TOPICS' => 'Topics', - 'TOPICS_UNAPPROVED' => 'At least one topic in this forum has not been approved.', - 'TOPIC_ICON' => 'Topic icon', - 'TOPIC_LOCKED' => 'This topic is locked, you cannot edit posts or make further replies.', - 'TOPIC_LOCKED_SHORT'=> 'Topic locked', - 'TOPIC_MOVED' => 'Moved topic', - 'TOPIC_REVIEW' => 'Topic review', - 'TOPIC_TITLE' => 'Topic title', - 'TOPIC_UNAPPROVED' => 'This topic has not been approved.', - 'TOPIC_UNAPPROVED_FORUM' => array( - 1 => 'Topic awaiting approval', - 2 => 'Topics awaiting approval', - ), - 'TOPIC_DELETED' => 'This topic has been deleted.', - 'TOTAL_ATTACHMENTS' => 'Attachment(s)', - 'TOTAL_LOGS' => array( - 1 => '%d log', - 2 => '%d logs', - ), - 'TOTAL_PMS' => array( - 1 => '%d private message in total', - 2 => '%d private messages in total', - ), - 'TOPIC_POLL' => 'This topic has a poll.', - 'TOTAL_POSTS' => 'Total posts', - 'TOTAL_POSTS_COUNT' => array( - 2 => 'Total posts %d', - ), - 'TOPIC_REPORTED' => 'This topic has been reported', - 'TOTAL_TOPICS' => array( - 2 => 'Total topics %d', - ), - 'TOTAL_USERS' => array( - 2 => 'Total members %d', - ), - 'TRACKED_PHP_ERROR' => 'Tracked PHP errors: %s', - 'TWITTER' => 'Twitter', - - 'UNABLE_GET_IMAGE_SIZE' => 'It was not possible to determine the dimensions of the image. Please verify that the URL you entered is correct.', - 'UNABLE_TO_DELIVER_FILE'=> 'Unable to deliver file.', - 'UNKNOWN_BROWSER' => 'Unknown browser', - 'UNMARK_ALL' => 'Unmark all', - 'UNREAD_MESSAGES' => 'Unread messages', - 'UNREAD_POST' => 'Unread post', - 'UNREAD_POSTS' => 'Unread posts', - 'UNWATCH_FORUM_CONFIRM' => 'Are you sure you wish to unsubscribe from this forum?', - 'UNWATCH_FORUM_DETAILED' => 'Are you sure you wish to unsubscribe from the forum “%s”?', - 'UNWATCH_TOPIC_CONFIRM' => 'Are you sure you wish to unsubscribe from this topic?', - 'UNWATCH_TOPIC_DETAILED' => 'Are you sure you wish to unsubscribe from the topic “%s”?', - 'UNWATCHED_FORUMS' => 'You are no longer subscribed to the selected forums.', - 'UNWATCHED_TOPICS' => 'You are no longer subscribed to the selected topics.', - 'UNWATCHED_FORUMS_TOPICS' => 'You are no longer subscribed to the selected entries.', - 'UPDATE' => 'Update', - 'UPLOAD_IN_PROGRESS' => 'The upload is currently in progress.', - 'URL_REDIRECT' => 'If your browser does not support meta redirection %splease click HERE to be redirected%s.', - 'USERGROUPS' => 'Groups', - 'USERNAME' => 'Username', - 'USERNAMES' => 'Usernames', - 'USER_AVATAR' => 'User avatar', - 'USER_CANNOT_READ' => 'You cannot read posts in this forum.', - 'USER_POSTS' => array( - 1 => '%d Post', - 2 => '%d Posts', - ), - 'USERS' => 'Users', - 'USE_PERMISSIONS' => 'Test out user’s permissions', - - 'USER_NEW_PERMISSION_DISALLOWED' => 'We are sorry, but you are not authorised to use this feature. You may have just registered here and may need to participate more in discussions to be able to use this feature.', - - 'VARIANT_DATE_SEPARATOR' => ' / ', // Used in date format dropdown, eg: "Today, 13:37 / 01 Jan 2007, 13:37" ... to join a relative date with calendar date - 'VIEWED' => 'Viewed', - 'VIEWED_COUNTS' => array( - 0 => 'Not viewed yet', - 1 => 'Viewed %d time', - 2 => 'Viewed %d times', - ), - 'VIEWING_CONTACT_ADMIN' => 'Viewing contact page', - 'VIEWING_FAQ' => 'Viewing FAQ', - 'VIEWING_MEMBERS' => 'Viewing member details', - 'VIEWING_ONLINE' => 'Viewing who is online', - 'VIEWING_MCP' => 'Viewing moderator control panel', - 'VIEWING_MEMBER_PROFILE' => 'Viewing member profile', - 'VIEWING_PRIVATE_MESSAGES' => 'Viewing private messages', - 'VIEWING_REGISTER' => 'Registering account', - 'VIEWING_UCP' => 'Viewing user control panel', - 'VIEWS' => 'Views', - 'VIEW_BOOKMARKS' => 'View bookmarks', - 'VIEW_FORUM_LOGS' => 'View Logs', - 'VIEW_LATEST_POST' => 'View the latest post', - 'VIEW_NEWEST_POST' => 'View first unread post', - 'VIEW_NOTES' => 'View user notes', - 'VIEW_ONLINE_TIMES' => array( - 1 => 'based on users active over the past %d minute', - 2 => 'based on users active over the past %d minutes', - ), - 'VIEW_TOPIC' => 'View topic', - 'VIEW_TOPIC_ANNOUNCEMENT' => 'Announcement: ', - 'VIEW_TOPIC_GLOBAL' => 'Global Announcement: ', - 'VIEW_TOPIC_LOCKED' => 'Locked: ', - 'VIEW_TOPIC_LOGS' => 'View logs', - 'VIEW_TOPIC_MOVED' => 'Moved: ', - 'VIEW_TOPIC_POLL' => 'Poll: ', - 'VIEW_TOPIC_STICKY' => 'Sticky: ', - 'VISIT_WEBSITE' => 'Visit website', - - 'WARNINGS' => 'Warnings', - 'WARN_USER' => 'Warn user', - 'WATCH_FORUM_CONFIRM' => 'Are you sure you wish to subscribe to this forum?', - 'WATCH_FORUM_DETAILED' => 'Are you sure you wish to subscribe to the forum “%s”?', - 'WATCH_TOPIC_CONFIRM' => 'Are you sure you wish to subscribe to this topic?', - 'WATCH_TOPIC_DETAILED' => 'Are you sure you wish to subscribe to the topic “%s”?', - 'WELCOME_SUBJECT' => 'Welcome to %s forums', - 'WEBSITE' => 'Website', - 'WHOIS' => 'Whois', - 'WHO_IS_ONLINE' => 'Who is online', - 'WRONG_PASSWORD' => 'You entered an incorrect password.', - - 'WRONG_DATA_COLOUR' => 'The colour value you entered is invalid.', - 'WRONG_DATA_JABBER' => 'The name you entered is not a valid Jabber account name.', - 'WRONG_DATA_LANG' => 'The language you specified is not valid.', - 'WRONG_DATA_POST_SD' => 'The post sort direction you specified is not valid.', - 'WRONG_DATA_POST_SK' => 'The post sort option you specified is not valid.', - 'WRONG_DATA_TOPIC_SD' => 'The topic sort direction you specified is not valid.', - 'WRONG_DATA_TOPIC_SK' => 'The topic sort option you specified is not valid.', - 'WROTE' => 'wrote', - - 'YAHOO' => 'Yahoo Messenger', - 'YOUTUBE' => 'YouTube', - 'YEAR' => 'Year', - 'YEAR_MONTH_DAY' => '(YYYY-MM-DD)', - 'YES' => 'Yes', - 'YOU_LAST_VISIT' => 'Last visit was: %s', - - 'datetime' => array( - 'TODAY' => 'Today', - 'TOMORROW' => 'Tomorrow', - 'YESTERDAY' => 'Yesterday', - 'AGO' => array( - 0 => 'less than a minute ago', - 1 => '%d minute ago', - 2 => '%d minutes ago', - ), - - 'Sunday' => 'Sunday', - 'Monday' => 'Monday', - 'Tuesday' => 'Tuesday', - 'Wednesday' => 'Wednesday', - 'Thursday' => 'Thursday', - 'Friday' => 'Friday', - 'Saturday' => 'Saturday', - - 'Sun' => 'Sun', - 'Mon' => 'Mon', - 'Tue' => 'Tue', - 'Wed' => 'Wed', - 'Thu' => 'Thu', - 'Fri' => 'Fri', - 'Sat' => 'Sat', - - 'January' => 'January', - 'February' => 'February', - 'March' => 'March', - 'April' => 'April', - 'May' => 'May', - 'June' => 'June', - 'July' => 'July', - 'August' => 'August', - 'September' => 'September', - 'October' => 'October', - 'November' => 'November', - 'December' => 'December', - - 'Jan' => 'Jan', - 'Feb' => 'Feb', - 'Mar' => 'Mar', - 'Apr' => 'Apr', - 'May_short' => 'May', // Short representation of "May". May_short used because in English the short and long date are the same for May. - 'Jun' => 'Jun', - 'Jul' => 'Jul', - 'Aug' => 'Aug', - 'Sep' => 'Sep', - 'Oct' => 'Oct', - 'Nov' => 'Nov', - 'Dec' => 'Dec', - ), - - // Timezones can be translated. We use this for the Etc/GMT timezones here, - // because they are named invers to their offset. - 'timezones' => array( - 'UTC' => 'UTC', - 'UTC_OFFSET' => 'UTC%1$s', - 'UTC_OFFSET_CURRENT' => 'UTC%1$s - %2$s', - - 'Etc/GMT-12' => 'UTC+12', - 'Etc/GMT-11' => 'UTC+11', - 'Etc/GMT-10' => 'UTC+10', - 'Etc/GMT-9' => 'UTC+9', - 'Etc/GMT-8' => 'UTC+8', - 'Etc/GMT-7' => 'UTC+7', - 'Etc/GMT-6' => 'UTC+6', - 'Etc/GMT-5' => 'UTC+5', - 'Etc/GMT-4' => 'UTC+4', - 'Etc/GMT-3' => 'UTC+3', - 'Etc/GMT-2' => 'UTC+2', - 'Etc/GMT-1' => 'UTC+1', - 'Etc/GMT+1' => 'UTC-1', - 'Etc/GMT+2' => 'UTC-2', - 'Etc/GMT+3' => 'UTC-3', - 'Etc/GMT+4' => 'UTC-4', - 'Etc/GMT+5' => 'UTC-5', - 'Etc/GMT+6' => 'UTC-6', - 'Etc/GMT+7' => 'UTC-7', - 'Etc/GMT+8' => 'UTC-8', - 'Etc/GMT+9' => 'UTC-9', - 'Etc/GMT+10' => 'UTC-10', - 'Etc/GMT+11' => 'UTC-11', - 'Etc/GMT+12' => 'UTC-12', - - 'Africa/Abidjan' => 'Africa/Abidjan', - 'Africa/Accra' => 'Africa/Accra', - 'Africa/Addis_Ababa' => 'Africa/Addis Ababa', - 'Africa/Algiers' => 'Africa/Algiers', - 'Africa/Asmara' => 'Africa/Asmara', - 'Africa/Bamako' => 'Africa/Bamako', - 'Africa/Bangui' => 'Africa/Bangui', - 'Africa/Banjul' => 'Africa/Banjul', - 'Africa/Bissau' => 'Africa/Bissau', - 'Africa/Blantyre' => 'Africa/Blantyre', - 'Africa/Brazzaville' => 'Africa/Brazzaville', - 'Africa/Bujumbura' => 'Africa/Bujumbura', - 'Africa/Cairo' => 'Africa/Cairo', - 'Africa/Casablanca' => 'Africa/Casablanca', - 'Africa/Ceuta' => 'Africa/Ceuta', - 'Africa/Conakry' => 'Africa/Conakry', - 'Africa/Dakar' => 'Africa/Dakar', - 'Africa/Dar_es_Salaam' => 'Africa/Dar es Salaam', - 'Africa/Djibouti' => 'Africa/Djibouti', - 'Africa/Douala' => 'Africa/Douala', - 'Africa/El_Aaiun' => 'Africa/El Aaiun', - 'Africa/Freetown' => 'Africa/Freetown', - 'Africa/Gaborone' => 'Africa/Gaborone', - 'Africa/Harare' => 'Africa/Harare', - 'Africa/Johannesburg' => 'Africa/Johannesburg', - 'Africa/Juba' => 'Africa/Juba', - 'Africa/Kampala' => 'Africa/Kampala', - 'Africa/Khartoum' => 'Africa/Khartoum', - 'Africa/Kigali' => 'Africa/Kigali', - 'Africa/Kinshasa' => 'Africa/Kinshasa', - 'Africa/Lagos' => 'Africa/Lagos', - 'Africa/Libreville' => 'Africa/Libreville', - 'Africa/Lome' => 'Africa/Lome', - 'Africa/Luanda' => 'Africa/Luanda', - 'Africa/Lubumbashi' => 'Africa/Lubumbashi', - 'Africa/Lusaka' => 'Africa/Lusaka', - 'Africa/Malabo' => 'Africa/Malabo', - 'Africa/Maputo' => 'Africa/Maputo', - 'Africa/Maseru' => 'Africa/Maseru', - 'Africa/Mbabane' => 'Africa/Mbabane', - 'Africa/Mogadishu' => 'Africa/Mogadishu', - 'Africa/Monrovia' => 'Africa/Monrovia', - 'Africa/Nairobi' => 'Africa/Nairobi', - 'Africa/Ndjamena' => 'Africa/Ndjamena', - 'Africa/Niamey' => 'Africa/Niamey', - 'Africa/Nouakchott' => 'Africa/Nouakchott', - 'Africa/Ouagadougou' => 'Africa/Ouagadougou', - 'Africa/Porto-Novo' => 'Africa/Porto-Novo', - 'Africa/Sao_Tome' => 'Africa/Sao Tome', - 'Africa/Tripoli' => 'Africa/Tripoli', - 'Africa/Tunis' => 'Africa/Tunis', - 'Africa/Windhoek' => 'Africa/Windhoek', - - 'America/Adak' => 'America/Adak', - 'America/Anchorage' => 'America/Anchorage', - 'America/Anguilla' => 'America/Anguilla', - 'America/Antigua' => 'America/Antigua', - 'America/Araguaina' => 'America/Araguaina', - - 'America/Argentina/Buenos_Aires' => 'America/Argentina/Buenos Aires', - 'America/Argentina/Catamarca' => 'America/Argentina/Catamarca', - 'America/Argentina/Cordoba' => 'America/Argentina/Cordoba', - 'America/Argentina/Jujuy' => 'America/Argentina/Jujuy', - 'America/Argentina/La_Rioja' => 'America/Argentina/La Rioja', - 'America/Argentina/Mendoza' => 'America/Argentina/Mendoza', - 'America/Argentina/Rio_Gallegos' => 'America/Argentina/Rio Gallegos', - 'America/Argentina/Salta' => 'America/Argentina/Salta', - 'America/Argentina/San_Juan' => 'America/Argentina/San Juan', - 'America/Argentina/San_Luis' => 'America/Argentina/San Luis', - 'America/Argentina/Tucuman' => 'America/Argentina/Tucuman', - 'America/Argentina/Ushuaia' => 'America/Argentina/Ushuaia', - - 'America/Aruba' => 'America/Aruba', - 'America/Asuncion' => 'America/Asuncion', - 'America/Atikokan' => 'America/Atikokan', - 'America/Bahia' => 'America/Bahia', - 'America/Bahia_Banderas' => 'America/Bahia Banderas', - 'America/Barbados' => 'America/Barbados', - 'America/Belem' => 'America/Belem', - 'America/Belize' => 'America/Belize', - 'America/Blanc-Sablon' => 'America/Blanc-Sablon', - 'America/Boa_Vista' => 'America/Boa Vista', - 'America/Bogota' => 'America/Bogota', - 'America/Boise' => 'America/Boise', - 'America/Cambridge_Bay' => 'America/Cambridge Bay', - 'America/Campo_Grande' => 'America/Campo Grande', - 'America/Cancun' => 'America/Cancun', - 'America/Caracas' => 'America/Caracas', - 'America/Cayenne' => 'America/Cayenne', - 'America/Cayman' => 'America/Cayman', - 'America/Chicago' => 'America/Chicago', - 'America/Chihuahua' => 'America/Chihuahua', - 'America/Costa_Rica' => 'America/Costa Rica', - 'America/Creston' => 'America/Creston', - 'America/Cuiaba' => 'America/Cuiaba', - 'America/Curacao' => 'America/Curacao', - 'America/Danmarkshavn' => 'America/Danmarkshavn', - 'America/Dawson' => 'America/Dawson', - 'America/Dawson_Creek' => 'America/Dawson Creek', - 'America/Denver' => 'America/Denver', - 'America/Detroit' => 'America/Detroit', - 'America/Dominica' => 'America/Dominica', - 'America/Edmonton' => 'America/Edmonton', - 'America/Eirunepe' => 'America/Eirunepe', - 'America/El_Salvador' => 'America/El Salvador', - 'America/Fortaleza' => 'America/Fortaleza', - 'America/Glace_Bay' => 'America/Glace Bay', - 'America/Godthab' => 'America/Godthab', - 'America/Goose_Bay' => 'America/Goose Bay', - 'America/Grand_Turk' => 'America/Grand Turk', - 'America/Grenada' => 'America/Grenada', - 'America/Guadeloupe' => 'America/Guadeloupe', - 'America/Guatemala' => 'America/Guatemala', - 'America/Guayaquil' => 'America/Guayaquil', - 'America/Guyana' => 'America/Guyana', - 'America/Halifax' => 'America/Halifax', - 'America/Havana' => 'America/Havana', - 'America/Hermosillo' => 'America/Hermosillo', - 'America/Indiana/Indianapolis' => 'America/Indiana/Indianapolis', - 'America/Indiana/Knox' => 'America/Indiana/Knox', - 'America/Indiana/Marengo' => 'America/Indiana/Marengo', - 'America/Indiana/Petersburg' => 'America/Indiana/Petersburg', - 'America/Indiana/Tell_City' => 'America/Indiana/Tell City', - 'America/Indiana/Vevay' => 'America/Indiana/Vevay', - 'America/Indiana/Vincennes' => 'America/Indiana/Vincennes', - 'America/Indiana/Winamac' => 'America/Indiana/Winamac', - 'America/Inuvik' => 'America/Inuvik', - 'America/Iqaluit' => 'America/Iqaluit', - 'America/Jamaica' => 'America/Jamaica', - 'America/Juneau' => 'America/Juneau', - 'America/Kentucky/Louisville' => 'America/Kentucky/Louisville', - 'America/Kentucky/Monticello' => 'America/Kentucky/Monticello', - 'America/Kralendijk' => 'America/Kralendijk', - 'America/La_Paz' => 'America/La Paz', - 'America/Lima' => 'America/Lima', - 'America/Los_Angeles' => 'America/Los Angeles', - 'America/Lower_Princes' => 'America/Lower Princes', - 'America/Maceio' => 'America/Maceio', - 'America/Managua' => 'America/Managua', - 'America/Manaus' => 'America/Manaus', - 'America/Marigot' => 'America/Marigot', - 'America/Martinique' => 'America/Martinique', - 'America/Matamoros' => 'America/Matamoros', - 'America/Mazatlan' => 'America/Mazatlan', - 'America/Menominee' => 'America/Menominee', - 'America/Merida' => 'America/Merida', - 'America/Metlakatla' => 'America/Metlakatla', - 'America/Mexico_City' => 'America/Mexico City', - 'America/Miquelon' => 'America/Miquelon', - 'America/Moncton' => 'America/Moncton', - 'America/Monterrey' => 'America/Monterrey', - 'America/Montevideo' => 'America/Montevideo', - 'America/Montreal' => 'America/Montreal', - 'America/Montserrat' => 'America/Montserrat', - 'America/Nassau' => 'America/Nassau', - 'America/New_York' => 'America/New York', - 'America/Nipigon' => 'America/Nipigon', - 'America/Nome' => 'America/Nome', - 'America/Noronha' => 'America/Noronha', - 'America/North_Dakota/Beulah' => 'America/North Dakota/Beulah', - 'America/North_Dakota/Center' => 'America/North Dakota/Center', - 'America/North_Dakota/New_Salem' => 'America/North Dakota/New Salem', - 'America/Ojinaga' => 'America/Ojinaga', - 'America/Panama' => 'America/Panama', - 'America/Pangnirtung' => 'America/Pangnirtung', - 'America/Paramaribo' => 'America/Paramaribo', - 'America/Phoenix' => 'America/Phoenix', - 'America/Port-au-Prince' => 'America/Port-au-Prince', - 'America/Port_of_Spain' => 'America/Port of Spain', - 'America/Porto_Velho' => 'America/Porto Velho', - 'America/Puerto_Rico' => 'America/Puerto Rico', - 'America/Rainy_River' => 'America/Rainy River', - 'America/Rankin_Inlet' => 'America/Rankin Inlet', - 'America/Recife' => 'America/Recife', - 'America/Regina' => 'America/Regina', - 'America/Resolute' => 'America/Resolute', - 'America/Rio_Branco' => 'America/Rio Branco', - 'America/Santa_Isabel' => 'America/Santa Isabel', - 'America/Santarem' => 'America/Santarem', - 'America/Santiago' => 'America/Santiago', - 'America/Santo_Domingo' => 'America/Santo Domingo', - 'America/Sao_Paulo' => 'America/Sao Paulo', - 'America/Scoresbysund' => 'America/Scoresbysund', - 'America/Shiprock' => 'America/Shiprock', - 'America/Sitka' => 'America/Sitka', - 'America/St_Barthelemy' => 'America/St. Barthelemy', - 'America/St_Johns' => 'America/St. Johns', - 'America/St_Kitts' => 'America/St. Kitts', - 'America/St_Lucia' => 'America/St. Lucia', - 'America/St_Thomas' => 'America/St. Thomas', - 'America/St_Vincent' => 'America/St. Vincent', - 'America/Swift_Current' => 'America/Swift Current', - 'America/Tegucigalpa' => 'America/Tegucigalpa', - 'America/Thule' => 'America/Thule', - 'America/Thunder_Bay' => 'America/Thunder Bay', - 'America/Tijuana' => 'America/Tijuana', - 'America/Toronto' => 'America/Toronto', - 'America/Tortola' => 'America/Tortola', - 'America/Vancouver' => 'America/Vancouver', - 'America/Whitehorse' => 'America/Whitehorse', - 'America/Winnipeg' => 'America/Winnipeg', - 'America/Yakutat' => 'America/Yakutat', - 'America/Yellowknife' => 'America/Yellowknife', - - 'Antarctica/Casey' => 'Antarctica/Casey', - 'Antarctica/Davis' => 'Antarctica/Davis', - 'Antarctica/DumontDUrville' => 'Antarctica/DumontDUrville', - 'Antarctica/Macquarie' => 'Antarctica/Macquarie', - 'Antarctica/Mawson' => 'Antarctica/Mawson', - 'Antarctica/McMurdo' => 'Antarctica/McMurdo', - 'Antarctica/Palmer' => 'Antarctica/Palmer', - 'Antarctica/Rothera' => 'Antarctica/Rothera', - 'Antarctica/South_Pole' => 'Antarctica/South Pole', - 'Antarctica/Syowa' => 'Antarctica/Syowa', - 'Antarctica/Vostok' => 'Antarctica/Vostok', - - 'Arctic/Longyearbyen' => 'Arctic/Longyearbyen', - - 'Asia/Aden' => 'Asia/Aden', - 'Asia/Almaty' => 'Asia/Almaty', - 'Asia/Amman' => 'Asia/Amman', - 'Asia/Anadyr' => 'Asia/Anadyr', - 'Asia/Aqtau' => 'Asia/Aqtau', - 'Asia/Aqtobe' => 'Asia/Aqtobe', - 'Asia/Ashgabat' => 'Asia/Ashgabat', - 'Asia/Baghdad' => 'Asia/Baghdad', - 'Asia/Bahrain' => 'Asia/Bahrain', - 'Asia/Baku' => 'Asia/Baku', - 'Asia/Bangkok' => 'Asia/Bangkok', - 'Asia/Beirut' => 'Asia/Beirut', - 'Asia/Bishkek' => 'Asia/Bishkek', - 'Asia/Brunei' => 'Asia/Brunei', - 'Asia/Choibalsan' => 'Asia/Choibalsan', - 'Asia/Chongqing' => 'Asia/Chongqing', - 'Asia/Colombo' => 'Asia/Colombo', - 'Asia/Damascus' => 'Asia/Damascus', - 'Asia/Dhaka' => 'Asia/Dhaka', - 'Asia/Dili' => 'Asia/Dili', - 'Asia/Dubai' => 'Asia/Dubai', - 'Asia/Dushanbe' => 'Asia/Dushanbe', - 'Asia/Gaza' => 'Asia/Gaza', - 'Asia/Harbin' => 'Asia/Harbin', - 'Asia/Hebron' => 'Asia/Hebron', - 'Asia/Ho_Chi_Minh' => 'Asia/Ho Chi Minh', - 'Asia/Hong_Kong' => 'Asia/Hong Kong', - 'Asia/Hovd' => 'Asia/Hovd', - 'Asia/Irkutsk' => 'Asia/Irkutsk', - 'Asia/Jakarta' => 'Asia/Jakarta', - 'Asia/Jayapura' => 'Asia/Jayapura', - 'Asia/Jerusalem' => 'Asia/Jerusalem', - 'Asia/Kabul' => 'Asia/Kabul', - 'Asia/Kamchatka' => 'Asia/Kamchatka', - 'Asia/Karachi' => 'Asia/Karachi', - 'Asia/Kashgar' => 'Asia/Kashgar', - 'Asia/Kathmandu' => 'Asia/Kathmandu', - 'Asia/Khandyga' => 'Asia/Khandyga', - 'Asia/Kolkata' => 'Asia/Kolkata', - 'Asia/Krasnoyarsk' => 'Asia/Krasnoyarsk', - 'Asia/Kuala_Lumpur' => 'Asia/Kuala Lumpur', - 'Asia/Kuching' => 'Asia/Kuching', - 'Asia/Kuwait' => 'Asia/Kuwait', - 'Asia/Macau' => 'Asia/Macau', - 'Asia/Magadan' => 'Asia/Magadan', - 'Asia/Makassar' => 'Asia/Makassar', - 'Asia/Manila' => 'Asia/Manila', - 'Asia/Muscat' => 'Asia/Muscat', - 'Asia/Nicosia' => 'Asia/Nicosia', - 'Asia/Novokuznetsk' => 'Asia/Novokuznetsk', - 'Asia/Novosibirsk' => 'Asia/Novosibirsk', - 'Asia/Omsk' => 'Asia/Omsk', - 'Asia/Oral' => 'Asia/Oral', - 'Asia/Phnom_Penh' => 'Asia/Phnom Penh', - 'Asia/Pontianak' => 'Asia/Pontianak', - 'Asia/Pyongyang' => 'Asia/Pyongyang', - 'Asia/Qatar' => 'Asia/Qatar', - 'Asia/Qyzylorda' => 'Asia/Qyzylorda', - 'Asia/Rangoon' => 'Asia/Rangoon', - 'Asia/Riyadh' => 'Asia/Riyadh', - 'Asia/Sakhalin' => 'Asia/Sakhalin', - 'Asia/Samarkand' => 'Asia/Samarkand', - 'Asia/Seoul' => 'Asia/Seoul', - 'Asia/Shanghai' => 'Asia/Shanghai', - 'Asia/Singapore' => 'Asia/Singapore', - 'Asia/Taipei' => 'Asia/Taipei', - 'Asia/Tashkent' => 'Asia/Tashkent', - 'Asia/Tbilisi' => 'Asia/Tbilisi', - 'Asia/Tehran' => 'Asia/Tehran', - 'Asia/Thimphu' => 'Asia/Thimphu', - 'Asia/Tokyo' => 'Asia/Tokyo', - 'Asia/Ulaanbaatar' => 'Asia/Ulaanbaatar', - 'Asia/Urumqi' => 'Asia/Urumqi', - 'Asia/Ust-Nera' => 'Asia/Ust-Nera', - 'Asia/Vientiane' => 'Asia/Vientiane', - 'Asia/Vladivostok' => 'Asia/Vladivostok', - 'Asia/Yakutsk' => 'Asia/Yakutsk', - 'Asia/Yekaterinburg' => 'Asia/Yekaterinburg', - 'Asia/Yerevan' => 'Asia/Yerevan', - - 'Atlantic/Azores' => 'Atlantic/Azores', - 'Atlantic/Bermuda' => 'Atlantic/Bermuda', - 'Atlantic/Canary' => 'Atlantic/Canary', - 'Atlantic/Cape_Verde' => 'Atlantic/Cape Verde', - 'Atlantic/Faroe' => 'Atlantic/Faroe', - 'Atlantic/Madeira' => 'Atlantic/Madeira', - 'Atlantic/Reykjavik' => 'Atlantic/Reykjavik', - 'Atlantic/South_Georgia' => 'Atlantic/South Georgia', - 'Atlantic/St_Helena' => 'Atlantic/St. Helena', - 'Atlantic/Stanley' => 'Atlantic/Stanley', - - 'Australia/Adelaide' => 'Australia/Adelaide', - 'Australia/Brisbane' => 'Australia/Brisbane', - 'Australia/Broken_Hill' => 'Australia/Broken Hill', - 'Australia/Currie' => 'Australia/Currie', - 'Australia/Darwin' => 'Australia/Darwin', - 'Australia/Eucla' => 'Australia/Eucla', - 'Australia/Hobart' => 'Australia/Hobart', - 'Australia/Lindeman' => 'Australia/Lindeman', - 'Australia/Lord_Howe' => 'Australia/Lord Howe', - 'Australia/Melbourne' => 'Australia/Melbourne', - 'Australia/Perth' => 'Australia/Perth', - 'Australia/Sydney' => 'Australia/Sydney', - - 'Europe/Amsterdam' => 'Europe/Amsterdam', - 'Europe/Andorra' => 'Europe/Andorra', - 'Europe/Athens' => 'Europe/Athens', - 'Europe/Belgrade' => 'Europe/Belgrade', - 'Europe/Berlin' => 'Europe/Berlin', - 'Europe/Bratislava' => 'Europe/Bratislava', - 'Europe/Brussels' => 'Europe/Brussels', - 'Europe/Bucharest' => 'Europe/Bucharest', - 'Europe/Budapest' => 'Europe/Budapest', - 'Europe/Busingen' => 'Europe/Busingen', - 'Europe/Chisinau' => 'Europe/Chisinau', - 'Europe/Copenhagen' => 'Europe/Copenhagen', - 'Europe/Dublin' => 'Europe/Dublin', - 'Europe/Gibraltar' => 'Europe/Gibraltar', - 'Europe/Guernsey' => 'Europe/Guernsey', - 'Europe/Helsinki' => 'Europe/Helsinki', - 'Europe/Isle_of_Man' => 'Europe/Isle of Man', - 'Europe/Istanbul' => 'Europe/Istanbul', - 'Europe/Jersey' => 'Europe/Jersey', - 'Europe/Kaliningrad' => 'Europe/Kaliningrad', - 'Europe/Kiev' => 'Europe/Kiev', - 'Europe/Lisbon' => 'Europe/Lisbon', - 'Europe/Ljubljana' => 'Europe/Ljubljana', - 'Europe/London' => 'Europe/London', - 'Europe/Luxembourg' => 'Europe/Luxembourg', - 'Europe/Madrid' => 'Europe/Madrid', - 'Europe/Malta' => 'Europe/Malta', - 'Europe/Mariehamn' => 'Europe/Mariehamn', - 'Europe/Minsk' => 'Europe/Minsk', - 'Europe/Monaco' => 'Europe/Monaco', - 'Europe/Moscow' => 'Europe/Moscow', - 'Europe/Oslo' => 'Europe/Oslo', - 'Europe/Paris' => 'Europe/Paris', - 'Europe/Podgorica' => 'Europe/Podgorica', - 'Europe/Prague' => 'Europe/Prague', - 'Europe/Riga' => 'Europe/Riga', - 'Europe/Rome' => 'Europe/Rome', - 'Europe/Samara' => 'Europe/Samara', - 'Europe/San_Marino' => 'Europe/San Marino', - 'Europe/Sarajevo' => 'Europe/Sarajevo', - 'Europe/Simferopol' => 'Europe/Simferopol', - 'Europe/Skopje' => 'Europe/Skopje', - 'Europe/Sofia' => 'Europe/Sofia', - 'Europe/Stockholm' => 'Europe/Stockholm', - 'Europe/Tallinn' => 'Europe/Tallinn', - 'Europe/Tirane' => 'Europe/Tirane', - 'Europe/Uzhgorod' => 'Europe/Uzhgorod', - 'Europe/Vaduz' => 'Europe/Vaduz', - 'Europe/Vatican' => 'Europe/Vatican', - 'Europe/Vienna' => 'Europe/Vienna', - 'Europe/Vilnius' => 'Europe/Vilnius', - 'Europe/Volgograd' => 'Europe/Volgograd', - 'Europe/Warsaw' => 'Europe/Warsaw', - 'Europe/Zagreb' => 'Europe/Zagreb', - 'Europe/Zaporozhye' => 'Europe/Zaporozhye', - 'Europe/Zurich' => 'Europe/Zurich', - - 'Indian/Antananarivo' => 'Indian/Antananarivo', - 'Indian/Chagos' => 'Indian/Chagos', - 'Indian/Christmas' => 'Indian/Christmas', - 'Indian/Cocos' => 'Indian/Cocos', - 'Indian/Comoro' => 'Indian/Comoro', - 'Indian/Kerguelen' => 'Indian/Kerguelen', - 'Indian/Mahe' => 'Indian/Mahe', - 'Indian/Maldives' => 'Indian/Maldives', - 'Indian/Mauritius' => 'Indian/Mauritius', - 'Indian/Mayotte' => 'Indian/Mayotte', - 'Indian/Reunion' => 'Indian/Reunion', - - 'Pacific/Apia' => 'Pacific/Apia', - 'Pacific/Auckland' => 'Pacific/Auckland', - 'Pacific/Chatham' => 'Pacific/Chatham', - 'Pacific/Chuuk' => 'Pacific/Chuuk', - 'Pacific/Easter' => 'Pacific/Easter', - 'Pacific/Efate' => 'Pacific/Efate', - 'Pacific/Enderbury' => 'Pacific/Enderbury', - 'Pacific/Fakaofo' => 'Pacific/Fakaofo', - 'Pacific/Fiji' => 'Pacific/Fiji', - 'Pacific/Funafuti' => 'Pacific/Funafuti', - 'Pacific/Galapagos' => 'Pacific/Galapagos', - 'Pacific/Gambier' => 'Pacific/Gambier', - 'Pacific/Guadalcanal' => 'Pacific/Guadalcanal', - 'Pacific/Guam' => 'Pacific/Guam', - 'Pacific/Honolulu' => 'Pacific/Honolulu', - 'Pacific/Johnston' => 'Pacific/Johnston', - 'Pacific/Kiritimati' => 'Pacific/Kiritimati', - 'Pacific/Kosrae' => 'Pacific/Kosrae', - 'Pacific/Kwajalein' => 'Pacific/Kwajalein', - 'Pacific/Majuro' => 'Pacific/Majuro', - 'Pacific/Marquesas' => 'Pacific/Marquesas', - 'Pacific/Midway' => 'Pacific/Midway', - 'Pacific/Nauru' => 'Pacific/Nauru', - 'Pacific/Niue' => 'Pacific/Niue', - 'Pacific/Norfolk' => 'Pacific/Norfolk', - 'Pacific/Noumea' => 'Pacific/Noumea', - 'Pacific/Pago_Pago' => 'Pacific/Pago Pago', - 'Pacific/Palau' => 'Pacific/Palau', - 'Pacific/Pitcairn' => 'Pacific/Pitcairn', - 'Pacific/Pohnpei' => 'Pacific/Pohnpei', - 'Pacific/Port_Moresby' => 'Pacific/Port Moresby', - 'Pacific/Rarotonga' => 'Pacific/Rarotonga', - 'Pacific/Saipan' => 'Pacific/Saipan', - 'Pacific/Tahiti' => 'Pacific/Tahiti', - 'Pacific/Tarawa' => 'Pacific/Tarawa', - 'Pacific/Tongatapu' => 'Pacific/Tongatapu', - 'Pacific/Wake' => 'Pacific/Wake', - 'Pacific/Wallis' => 'Pacific/Wallis', - ), - - // The value is only an example and will get replaced by the current time on view - 'dateformats' => array( - 'd M Y, H:i' => '01 Jan 2007, 13:37', - 'd M Y H:i' => '01 Jan 2007 13:37', - 'M jS, \'y, H:i' => 'Jan 1st, \'07, 13:37', - 'D M d, Y g:i a' => 'Mon Jan 01, 2007 1:37 pm', - 'F jS, Y, g:i a' => 'January 1st, 2007, 1:37 pm', - '|d M Y|, H:i' => 'Today, 13:37 / 01 Jan 2007, 13:37', - '|F jS, Y|, g:i a' => 'Today, 1:37 pm / January 1st, 2007, 1:37 pm', - ), - - // The default dateformat which will be used on new installs in this language - // Translators should change this if a the usual date format is different - 'default_dateformat' => 'D M d, Y g:i a', // Mon Jan 01, 2007 1:37 pm - -)); diff --git a/install/update/old/language/en/email/admin_activate.txt b/install/update/old/language/en/email/admin_activate.txt deleted file mode 100644 index a53ab12..0000000 --- a/install/update/old/language/en/email/admin_activate.txt +++ /dev/null @@ -1,13 +0,0 @@ -Subject: Activate user account - -Hello, - -The account owned by "{USERNAME}" has been deactivated or newly created, you should check the details of this user (if required) and handle it appropriately. - -Use this link to view the user's profile: -{U_USER_DETAILS} - -Use this link to activate the account: -{U_ACTIVATE} - -{EMAIL_SIG} diff --git a/install/update/old/language/en/install.php b/install/update/old/language/en/install.php deleted file mode 100644 index 9bceecc..0000000 --- a/install/update/old/language/en/install.php +++ /dev/null @@ -1,599 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -/** - * DO NOT CHANGE - */ -if (!defined('IN_PHPBB')) -{ - exit; -} - -if (empty($lang) || !is_array($lang)) -{ - $lang = array(); -} - -// DEVELOPERS PLEASE NOTE -// -// All language files should use UTF-8 as their encoding and the files must not contain a BOM. -// -// Placeholders can now contain order information, e.g. instead of -// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows -// translators to re-order the output of data while ensuring it remains correct -// -// You do not need this where single placeholders are used, e.g. 'Message %d' is fine -// equally where a string contains only two placeholders which are used to wrap text -// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine - -// Common installer pages -$lang = array_merge($lang, array( - 'INSTALL_PANEL' => 'Installation Panel', - 'SELECT_LANG' => 'Select language', - - 'STAGE_INSTALL' => 'Installing phpBB', - - // Introduction page - 'INTRODUCTION_TITLE' => 'Introduction', - 'INTRODUCTION_BODY' => 'Welcome to phpBB3!

phpBB® is the most widely used open source bulletin board solution in the world. phpBB3 is the latest installment in a package line started in 2000. Like its predecessors, phpBB3 is feature-rich, user-friendly, and fully supported by the phpBB Team. phpBB3 greatly improves on what made phpBB2 popular, and adds commonly requested features that were not present in previous versions. We hope it exceeds your expectations.

This installation system will guide you through installing phpBB3, updating to the latest version of phpBB3 from past releases, as well as converting to phpBB3 from a different discussion board system (including phpBB2). For more information, we encourage you to read the installation guide.

To read the phpBB3 license or learn about obtaining support and our stance on it, please select the respective options from the side menu. To continue, please select the appropriate tab above.', - - // Support page - 'SUPPORT_TITLE' => 'Support', - 'SUPPORT_BODY' => 'Full support will be provided for the current stable release of phpBB3, free of charge. This includes:

  • installation
  • configuration
  • technical questions
  • problems relating to potential bugs in the software
  • updating from Release Candidate (RC) versions to the latest stable version
  • converting from phpBB 2.0.x to phpBB3
  • converting from other discussion board software to phpBB3 (please see the Convertors Forum)

We encourage users still running beta versions of phpBB3 to replace their installation with a fresh copy of the latest version.

Extensions / Styles

For issues relating to Extensions, please post in the appropriate Extensions Forum.
For issues relating to styles, templates and themes, please post in the appropriate Styles Forum.

If your question relates to a specific package, please post directly in the topic dedicated to the package.

Obtaining Support

Support Section
Quick Start Guide

To ensure you stay up to date with the latest news and releases, follow us on Twitter and Facebook

', - - // License - 'LICENSE_TITLE' => 'General Public License', - - // Install page - 'INSTALL_INTRO' => 'Welcome to Installation', - 'INSTALL_INTRO_BODY' => 'With this option, it is possible to install phpBB3 onto your server.

In order to proceed, you will need your database settings. If you do not know your database settings, please contact your host and ask for them. You will not be able to continue without them. You need:

- -
    -
  • The Database Type - the database you will be using.
  • -
  • The Database server hostname or DSN - the address of the database server.
  • -
  • The Database server port - the port of the database server (most of the time this is not needed).
  • -
  • The Database name - the name of the database on the server.
  • -
  • The Database username and Database password - the login data to access the database.
  • -
- -

Note: if you are installing using SQLite, you should enter the full path to your database file in the DSN field and leave the username and password fields blank. For security reasons, you should make sure that the database file is not stored in a location accessible from the web.

- -

phpBB3 supports the following databases:

-
    -
  • MySQL 3.23 or above (MySQLi supported)
  • -
  • PostgreSQL 8.3+
  • -
  • SQLite 3.6.15+
  • -
  • MS SQL Server 2000 or above (directly or via ODBC)
  • -
  • MS SQL Server 2005 or above (native)
  • -
  • Oracle
  • -
- -

Only those databases supported on your server will be displayed.', - - 'ACP_LINK' => 'Take me to the ACP', - - 'INSTALL_PHPBB_INSTALLED' => 'phpBB is already installed.', - 'INSTALL_PHPBB_NOT_INSTALLED' => 'phpBB is not installed yet.', -)); - -// Requirements translation -$lang = array_merge($lang, array( - // Filesystem requirements - 'FILE_NOT_EXISTS' => 'File does not exist', - 'FILE_NOT_EXISTS_EXPLAIN' => 'To be able to install phpBB the %1$s file needs to exist.', - 'FILE_NOT_EXISTS_EXPLAIN_OPTIONAL' => 'It is recommended that the %1$s file exist for a better forum user experience.', - 'FILE_NOT_WRITABLE' => 'File is not writable', - 'FILE_NOT_WRITABLE_EXPLAIN' => 'To be able to install phpBB the %1$s file needs to be writable.', - 'FILE_NOT_WRITABLE_EXPLAIN_OPTIONAL' => 'It is recommended that the %1$s file be writable for a better forum user experience.', - - 'DIRECTORY_NOT_EXISTS' => 'Directory does not exist', - 'DIRECTORY_NOT_EXISTS_EXPLAIN' => 'To be able to install phpBB the %1$s directory needs to exist.', - 'DIRECTORY_NOT_EXISTS_EXPLAIN_OPTIONAL' => 'It is recommended that the %1$s directory exist for a better forum user experience.', - 'DIRECTORY_NOT_WRITABLE' => 'Directory is not writable', - 'DIRECTORY_NOT_WRITABLE_EXPLAIN' => 'To be able to install phpBB the %1$s directory needs to be writable.', - 'DIRECTORY_NOT_WRITABLE_EXPLAIN_OPTIONAL' => 'It is recommended that the %1$s directory be writable for a better forum user experience.', - - // Server requirements - 'PHP_VERSION_REQD' => 'PHP version', - 'PHP_VERSION_REQD_EXPLAIN' => 'phpBB requires PHP version 5.4.0 or higher.', - 'PHP_GETIMAGESIZE_SUPPORT' => 'PHP getimagesize() function is required', - 'PHP_GETIMAGESIZE_SUPPORT_EXPLAIN' => 'In order for phpBB to function correctly, the getimagesize function needs to be available.', - 'PCRE_UTF_SUPPORT' => 'PCRE UTF-8 support', - 'PCRE_UTF_SUPPORT_EXPLAIN' => 'phpBB will not run if your PHP installation is not compiled with UTF-8 support in the PCRE extension.', - 'PHP_JSON_SUPPORT' => 'PHP JSON support', - 'PHP_JSON_SUPPORT_EXPLAIN' => 'In order for phpBB to function correctly, the PHP JSON extension needs to be available.', - 'PHP_XML_SUPPORT' => 'PHP XML/DOM support', - 'PHP_XML_SUPPORT_EXPLAIN' => 'In order for phpBB to function correctly, the PHP XML/DOM extension needs to be available.', - 'PHP_SUPPORTED_DB' => 'Supported databases', - 'PHP_SUPPORTED_DB_EXPLAIN' => 'You must have support for at least one compatible database within PHP. If no database modules are shown as available you should contact your hosting provider or review the relevant PHP installation documentation for advice.', - - 'RETEST_REQUIREMENTS' => 'Retest requirements', - - 'STAGE_REQUIREMENTS' => 'Check requirements', -)); - -// General error messages -$lang = array_merge($lang, array( - 'INST_ERR_MISSING_DATA' => 'You must fill out all fields in this block.', - - 'TIMEOUT_DETECTED_TITLE' => 'The installer detected a timeout', - 'TIMEOUT_DETECTED_MESSAGE' => 'The installer has detected a timeout, you may try to refresh the page, which may lead to data corruption. We suggest that you either increase your timeout settings or try to use the CLI.', -)); - -// Data obtaining translations -$lang = array_merge($lang, array( - 'STAGE_OBTAIN_DATA' => 'Set installation data', - - // - // Admin data - // - 'STAGE_ADMINISTRATOR' => 'Administrator details', - - // Form labels - 'ADMIN_CONFIG' => 'Administrator configuration', - 'ADMIN_PASSWORD' => 'Administrator password', - 'ADMIN_PASSWORD_CONFIRM' => 'Confirm administrator password', - 'ADMIN_PASSWORD_EXPLAIN' => 'Please enter a password between 6 and 30 characters in length.', - 'ADMIN_USERNAME' => 'Administrator username', - 'ADMIN_USERNAME_EXPLAIN' => 'Please enter a username between 3 and 20 characters in length.', - - // Errors - 'INST_ERR_EMAIL_INVALID' => 'The email address you entered is invalid.', - 'INST_ERR_PASSWORD_MISMATCH' => 'The passwords you entered did not match.', - 'INST_ERR_PASSWORD_TOO_LONG' => 'The password you entered is too long. The maximum length is 30 characters.', - 'INST_ERR_PASSWORD_TOO_SHORT' => 'The password you entered is too short. The minimum length is 6 characters.', - 'INST_ERR_USER_TOO_LONG' => 'The username you entered is too long. The maximum length is 20 characters.', - 'INST_ERR_USER_TOO_SHORT' => 'The username you entered is too short. The minimum length is 3 characters.', - - // - // Board data - // - // Form labels - 'BOARD_CONFIG' => 'Bulletin board configuration', - 'DEFAULT_LANGUAGE' => 'Default language', - 'BOARD_NAME' => 'Title of the board', - 'BOARD_DESCRIPTION' => 'Short description of the board', - - // - // Database data - // - 'STAGE_DATABASE' => 'Database settings', - - // Form labels - 'DB_CONFIG' => 'Database configuration', - 'DBMS' => 'Database type', - 'DB_HOST' => 'Database server hostname or DSN', - 'DB_HOST_EXPLAIN' => 'DSN stands for Data Source Name and is relevant only for ODBC installs. On PostgreSQL, use localhost to connect to the local server via UNIX domain socket and 127.0.0.1 to connect via TCP. For SQLite, enter the full path to your database file.', - 'DB_PORT' => 'Database server port', - 'DB_PORT_EXPLAIN' => 'Leave this blank unless you know the server operates on a non-standard port.', - 'DB_PASSWORD' => 'Database password', - 'DB_NAME' => 'Database name', - 'DB_USERNAME' => 'Database username', - 'DATABASE_VERSION' => 'Database version', - 'TABLE_PREFIX' => 'Prefix for tables in database', - 'TABLE_PREFIX_EXPLAIN' => 'The prefix must start with a letter and must only contain letters, numbers and underscores.', - - // Database options - 'DB_OPTION_MSSQL_ODBC' => 'MSSQL Server 2000+ via ODBC', - 'DB_OPTION_MSSQLNATIVE' => 'MSSQL Server 2005+ [ Native ]', - 'DB_OPTION_MYSQL' => 'MySQL', - 'DB_OPTION_MYSQLI' => 'MySQL with MySQLi Extension', - 'DB_OPTION_ORACLE' => 'Oracle', - 'DB_OPTION_POSTGRES' => 'PostgreSQL', - 'DB_OPTION_SQLITE3' => 'SQLite 3', - - // Errors - 'INST_ERR_DB' => 'Database installation error', - 'INST_ERR_NO_DB' => 'Cannot load the PHP module for the selected database type.', - 'INST_ERR_DB_INVALID_PREFIX' => 'The prefix you entered is invalid. It must start with a letter and must only contain letters, numbers and underscores.', - 'INST_ERR_PREFIX_TOO_LONG' => 'The table prefix you have specified is too long. The maximum length is %d characters.', - 'INST_ERR_DB_NO_NAME' => 'No database name specified.', - 'INST_ERR_DB_FORUM_PATH' => 'The database file specified is within your board directory tree. You should put this file in a non web-accessible location.', - 'INST_ERR_DB_CONNECT' => 'Could not connect to the database, see error message below.', - 'INST_ERR_DB_NO_WRITABLE' => 'Both the database and the directory containing it must be writable.', - 'INST_ERR_DB_NO_ERROR' => 'No error message given.', - 'INST_ERR_PREFIX' => 'Tables with the specified prefix already exist, please choose an alternative.', - 'INST_ERR_DB_NO_MYSQLI' => 'The version of MySQL installed on this machine is incompatible with the “MySQL with MySQLi Extension” option you have selected. Please try the “MySQL” option instead.', - 'INST_ERR_DB_NO_SQLITE3' => 'The version of the SQLite extension you have installed is too old, it must be upgraded to at least 3.6.15.', - 'INST_ERR_DB_NO_ORACLE' => 'The version of Oracle installed on this machine requires you to set the NLS_CHARACTERSET parameter to UTF8. Either upgrade your installation to 9.2+ or change the parameter.', - 'INST_ERR_DB_NO_POSTGRES' => 'The database you have selected was not created in UNICODE or UTF8 encoding. Try installing with a database in UNICODE or UTF8 encoding.', - 'INST_SCHEMA_FILE_NOT_WRITABLE' => 'The schema file is not writable', - - // - // Email data - // - 'EMAIL_CONFIG' => 'E-mail configuration', - - // Package info - 'PACKAGE_VERSION' => 'Package version installed', - 'UPDATE_INCOMPLETE' => 'Your phpBB installation has not been correctly updated.', - 'UPDATE_INCOMPLETE_MORE' => 'Please read the information below in order to fix this error.', - 'UPDATE_INCOMPLETE_EXPLAIN' => '

Incomplete update

- -

We noticed that the last update of your phpBB installation hasn’t been completed. Visit the database updater, ensure Update database only is selected and click on Submit. Don\'t forget to delete the "install"-directory after you have updated the database sucessfully.

', - - // - // Server data - // - // Form labels - 'UPGRADE_INSTRUCTIONS' => 'A new feature release %1$s is available. Please read the release announcement to learn about what it has to offer, and how to upgrade.', - 'SERVER_CONFIG' => 'Server configuration', - 'SCRIPT_PATH' => 'Script path', - 'SCRIPT_PATH_EXPLAIN' => 'The path where phpBB is located relative to the domain name, e.g. /phpBB3.', -)); - -// Default database schema entries... -$lang = array_merge($lang, array( - 'CONFIG_BOARD_EMAIL_SIG' => 'Thanks, The Management', - 'CONFIG_SITE_DESC' => 'A short text to describe your forum', - 'CONFIG_SITENAME' => 'yourdomain.com', - - 'DEFAULT_INSTALL_POST' => 'This is an example post in your phpBB3 installation. Everything seems to be working. You may delete this post if you like and continue to set up your board. During the installation process your first category and your first forum are assigned an appropriate set of permissions for the predefined usergroups administrators, bots, global moderators, guests, registered users and registered COPPA users. If you also choose to delete your first category and your first forum, do not forget to assign permissions for all these usergroups for all new categories and forums you create. It is recommended to rename your first category and your first forum and copy permissions from these while creating new categories and forums. Have fun!', - - 'FORUMS_FIRST_CATEGORY' => 'Your first category', - 'FORUMS_TEST_FORUM_DESC' => 'Description of your first forum.', - 'FORUMS_TEST_FORUM_TITLE' => 'Your first forum', - - 'RANKS_SITE_ADMIN_TITLE' => 'Site Admin', - 'REPORT_WAREZ' => 'The post contains links to illegal or pirated software.', - 'REPORT_SPAM' => 'The reported post has the only purpose to advertise for a website or another product.', - 'REPORT_OFF_TOPIC' => 'The reported post is off topic.', - 'REPORT_OTHER' => 'The reported post does not fit into any other category, please use the further information field.', - - 'SMILIES_ARROW' => 'Arrow', - 'SMILIES_CONFUSED' => 'Confused', - 'SMILIES_COOL' => 'Cool', - 'SMILIES_CRYING' => 'Crying or Very Sad', - 'SMILIES_EMARRASSED' => 'Embarrassed', - 'SMILIES_EVIL' => 'Evil or Very Mad', - 'SMILIES_EXCLAMATION' => 'Exclamation', - 'SMILIES_GEEK' => 'Geek', - 'SMILIES_IDEA' => 'Idea', - 'SMILIES_LAUGHING' => 'Laughing', - 'SMILIES_MAD' => 'Mad', - 'SMILIES_MR_GREEN' => 'Mr. Green', - 'SMILIES_NEUTRAL' => 'Neutral', - 'SMILIES_QUESTION' => 'Question', - 'SMILIES_RAZZ' => 'Razz', - 'SMILIES_ROLLING_EYES' => 'Rolling Eyes', - 'SMILIES_SAD' => 'Sad', - 'SMILIES_SHOCKED' => 'Shocked', - 'SMILIES_SMILE' => 'Smile', - 'SMILIES_SURPRISED' => 'Surprised', - 'SMILIES_TWISTED_EVIL' => 'Twisted Evil', - 'SMILIES_UBER_GEEK' => 'Uber Geek', - 'SMILIES_VERY_HAPPY' => 'Very Happy', - 'SMILIES_WINK' => 'Wink', - - 'TOPICS_TOPIC_TITLE' => 'Welcome to phpBB3', -)); - -// Common navigation items' translation -$lang = array_merge($lang, array( - 'MENU_OVERVIEW' => 'Overview', - 'MENU_INTRO' => 'Introduction', - 'MENU_LICENSE' => 'License', - 'MENU_SUPPORT' => 'Support', -)); - -// Task names -$lang = array_merge($lang, array( - // Install filesystem - 'TASK_CREATE_CONFIG_FILE' => 'Creating configuration file', - - // Install database - 'TASK_ADD_CONFIG_SETTINGS' => 'Adding configuration settings', - 'TASK_ADD_DEFAULT_DATA' => 'Adding default settings to the database', - 'TASK_CREATE_DATABASE_SCHEMA_FILE' => 'Creating database schema file', - 'TASK_SETUP_DATABASE' => 'Setting up database', - 'TASK_CREATE_TABLES' => 'Creating tables', - - // Install data - 'TASK_ADD_BOTS' => 'Registering bots', - 'TASK_ADD_LANGUAGES' => 'Installing available languages', - 'TASK_ADD_MODULES' => 'Installing modules', - 'TASK_CREATE_SEARCH_INDEX' => 'Creating search index', - - // Install finish tasks - 'TASK_INSTALL_EXTENSIONS' => 'Installing packaged extensions', - 'TASK_NOTIFY_USER' => 'Sending notification e-mail', - 'TASK_POPULATE_MIGRATIONS' => 'Populating migrations', - - // Installer general progress messages - 'INSTALLER_FINISHED' => 'The installer has finished successfully', -)); - -// Installer's general messages -$lang = array_merge($lang, array( - 'MODULE_NOT_FOUND' => 'Module not found', - 'MODULE_NOT_FOUND_DESCRIPTION' => 'A module could not be found because the service, %s, is undefined.', - - 'TASK_NOT_FOUND' => 'Task not found', - 'TASK_NOT_FOUND_DESCRIPTION' => 'A task could not be found because the service, %s, is undefined.', - - 'SKIP_MODULE' => 'Skip “%s” module', - 'SKIP_TASK' => 'Skip “%s” task', - - 'TASK_SERVICE_INSTALLER_MISSING' => 'All installer task services should start with “installer”', - 'TASK_CLASS_NOT_FOUND' => 'Installer task service definition is invalid. Service name “%1$s” given, the expected class namespace is “%2$s” for that. For more information please see the documentation of task_interface.', - - 'INSTALLER_CONFIG_NOT_WRITABLE' => 'The installer config file is not writable.', -)); - -// CLI messages -$lang = array_merge($lang, array( - 'CLI_INSTALL_BOARD' => 'Install phpBB', - 'CLI_UPDATE_BOARD' => 'Update phpBB', - 'CLI_INSTALL_SHOW_CONFIG' => 'Show the configuration which will be used', - 'CLI_INSTALL_VALIDATE_CONFIG' => 'Validate a configuration file', - 'CLI_CONFIG_FILE' => 'Config file to use', - 'MISSING_FILE' => 'Unable to access file %1$s', - 'MISSING_DATA' => 'Config file is missing data or might contain invalid settings.', - 'INVALID_YAML_FILE' => 'Could not parse YAML file %1$s', - 'CONFIGURATION_VALID' => 'The configuration file is valid', -)); - -// Common updater messages -$lang = array_merge($lang, array( - 'UPDATE_INSTALLATION' => 'Update phpBB installation', - 'UPDATE_INSTALLATION_EXPLAIN' => 'With this option, it is possible to update your phpBB installation to the latest version.
During the process all of your files will be checked for their integrity. You are able to review all differences and files before the update.

The file update itself can be done in two different ways.

Manual Update

With this update you only download your personal set of changed files to make sure you do not lose your file modifications you may have done. After you downloaded this package you need to manually upload the files to their correct position under your phpBB root directory. Once done, you are able to do the file check stage again to see if you moved the files to their correct location.

Automatic Update with FTP

This method is similar to the first one but without the need to download the changed files and uploading them on your own. This will be done for you. In order to use this method you need to know your FTP login details since you will be asked for them. Once finished you will be redirected to the file check again to make sure everything got updated correctly.

', - 'UPDATE_INSTRUCTIONS' => ' - -

Release announcement

- -

Please read the release announcement for the latest version before you continue your update process, it may contain useful information. It also contains full download links as well as the change log.

- -
- -

How to update your installation with the Full Package

- -

The recommended way of updating your installation is using the full package. If core phpBB files have been modified in your installation you may wish to use the automatic update package in order to not lose these changes. You are also able to update your installation using the other methods listed within the INSTALL.html document. The steps for updating phpBB3 using the full package are:

- -
    -
  1. Backup all board files and the database.
  2. -
  3. Go to the phpBB.com downloads page and download the latest "Full Package" archive.
  4. -
  5. Unpack the archive.
  6. -
  7. Remove (delete) the config.php file, and the /images, /store and /files folders from the package (not your site).
  8. -
  9. Go to the ACP, Board settings, and make sure prosilver is set as the default style. If not, set it to prosilver.
  10. -
  11. Delete the /vendor and /cache folders from the board’s root folder on the host.
  12. -
  13. Via FTP or SSH upload the remaining files and folders (that is, the remaining CONTENTS of the phpBB3 folder) to the root folder of your board installation on the server, overwriting the existing files. (Note: take care not to delete any extensions in your /ext folder when uploading the new phpBB3 contents.)
  14. -
  15. Now start the update process by pointing your browser to the install folder.
  16. -
  17. Follow the steps to update the database and let that run to completion.
  18. -
  19. Via FTP or SSH delete the /install folder from the root of your board installation.

  20. -
- -

You now have a new up to date board containing all your users and posts. Follow up tasks:

-
    -
  • Update your language pack
  • -
  • Update your style

  • -
- -

How to update your installation with the Automatic Update Package

- -

The automatic update package is only recommended in case core phpBB files have been modified in your installation. You are also able to update your installation using the methods listed within the INSTALL.html document. The steps for updating phpBB3 using the automatic update package are:

- -
    -
  1. Go to the phpBB.com downloads page and download the "Automatic Update Package" archive.
  2. -
  3. Unpack the archive.
  4. -
  5. Upload the complete uncompressed "install" and "vendor" folders to your phpBB root directory (where your config.php file is).

  6. -
- -

Once uploaded your board will be offline for normal users due to the install directory you uploaded now being present.

- Now start the update process by pointing your browser to the install folder.
-
- You will then be guided through the update process. You will be notified once the update is complete. -

- ', -)); - -// Updater forms -$lang = array_merge($lang, array( - // Updater types - 'UPDATE_TYPE' => 'Type of update to run', - - 'UPDATE_TYPE_ALL' => 'Update filesystem and database', - 'UPDATE_TYPE_DB_ONLY' => 'Update database only', - - // File updater methods - 'UPDATE_FILE_METHOD_TITLE' => 'File updater methods', - - 'UPDATE_FILE_METHOD' => 'File updater method', - 'UPDATE_FILE_METHOD_DOWNLOAD' => 'Download modified files in an archive', - 'UPDATE_FILE_METHOD_FTP' => 'Update files via FTP (Automatic)', - 'UPDATE_FILE_METHOD_FILESYSTEM' => 'Update files via direct file access (Automatic)', - - // File updater archives - 'SELECT_DOWNLOAD_FORMAT' => 'Select download archive format', - - // FTP settings - 'FTP_SETTINGS' => 'FTP settings', -)); - -// Requirements messages -$lang = array_merge($lang, array( - 'UPDATE_FILES_NOT_FOUND' => 'No valid update directory was found, please make sure you uploaded the relevant files.', - - 'NO_UPDATE_FILES_UP_TO_DATE' => 'Your version is up to date. There is no need to run the update tool. If you want to make an integrity check on your files make sure you uploaded the correct update files.', - 'OLD_UPDATE_FILES' => 'Update files are out of date. The update files found are for updating from phpBB %1$s to phpBB %2$s but the latest version of phpBB is %3$s.', - 'INCOMPATIBLE_UPDATE_FILES' => 'The update files found are incompatible with your installed version. Your installed version is %1$s and the update file is for updating phpBB %2$s to %3$s.', -)); - -// Update files -$lang = array_merge($lang, array( - 'STAGE_UPDATE_FILES' => 'Update files', - - // Check files - 'UPDATE_CHECK_FILES' => 'Check files to update', - - // Update file differ - 'FILE_DIFFER_ERROR_FILE_CANNOT_BE_READ' => 'The file differ failed to open %s.', - - 'UPDATE_FILE_DIFF' => 'Diffing changed files', - 'ALL_FILES_DIFFED' => 'All modified files has been diffed.', - - // File status - 'UPDATE_CONTINUE_FILE_UPDATE' => 'Update files', - - 'DOWNLOAD' => 'Download', - 'DOWNLOAD_CONFLICTS' => 'Download merge conflicts archive', - 'DOWNLOAD_CONFLICTS_EXPLAIN' => 'Search for <<< to spot conflicts', - 'DOWNLOAD_UPDATE_METHOD' => 'Download modified files archive', - 'DOWNLOAD_UPDATE_METHOD_EXPLAIN' => 'Once downloaded you should unpack the archive. You will find the modified files you need to upload to your phpBB root directory within it. Please upload the files to their respective locations then. After you have uploaded all files, you may continue with the update process.', - - 'FILE_ALREADY_UP_TO_DATE' => 'File is already up to date.', - 'FILE_DIFF_NOT_ALLOWED' => 'File not allowed to be diffed.', - 'FILE_USED' => 'Information used from', // Single file - 'FILES_CONFLICT' => 'Conflict files', - 'FILES_CONFLICT_EXPLAIN' => 'The following files are modified and do not represent the original files from the old version. phpBB determined that these files create conflicts if they are tried to be merged. Please investigate the conflicts and try to manually resolve them or continue the update choosing the preferred merging method. If you resolve the conflicts manually check the files again after you modified them. You are also able to choose between the preferred merge method for every file. The first one will result in a file where the conflicting lines from your old file will be lost, the other one will result in losing the changes from the newer file.', - 'FILES_DELETED' => 'Deleted files', - 'FILES_DELETED_EXPLAIN' => 'The following files do not exist in the new version. These files have to be deleted from your installation.', - 'FILES_MODIFIED' => 'Modified files', - 'FILES_MODIFIED_EXPLAIN' => 'The following files are modified and do not represent the original files from the old version. The updated file will be a merge between your modifications and the new file.', - 'FILES_NEW' => 'New files', - 'FILES_NEW_EXPLAIN' => 'The following files currently do not exist within your installation. These files will be added to your installation.', - 'FILES_NEW_CONFLICT' => 'New conflicting files', - 'FILES_NEW_CONFLICT_EXPLAIN' => 'The following files are new within the latest version but it has been determined that there is already a file with the same name within the same position. This file will be overwritten by the new file.', - 'FILES_NOT_MODIFIED' => 'Not modified files', - 'FILES_NOT_MODIFIED_EXPLAIN' => 'The following files are not modified and represent the original phpBB files from the version you want to update from.', - 'FILES_UP_TO_DATE' => 'Already updated files', - 'FILES_UP_TO_DATE_EXPLAIN' => 'The following files are already up to date and do not need to be updated.', - 'FILES_VERSION' => 'Files Version', - 'TOGGLE_DISPLAY' => 'View/Hide file list', - - // File updater - 'UPDATE_UPDATING_FILES' => 'Updating files', - - 'UPDATE_FILE_UPDATER_HAS_FAILED' => 'File updater “%1$s“ has failed. The installer will try to fallback to “%2$s“.', - 'UPDATE_FILE_UPDATERS_HAVE_FAILED' => 'The file updater failed. No further fallback methods are available.', - - 'UPDATE_CONTINUE_UPDATE_PROCESS' => 'Continue update process', - 'UPDATE_RECHECK_UPDATE_FILES' => 'Check files again', -)); - -// Update database -$lang = array_merge($lang, array( - 'STAGE_UPDATE_DATABASE' => 'Update database', - - 'INLINE_UPDATE_SUCCESSFUL' => 'The database update was successful.', - - 'TASK_UPDATE_EXTENSIONS' => 'Updating extensions', -)); - -// Converter -$lang = array_merge($lang, array( - // Common converter messages - 'CONVERT_NOT_EXIST' => 'The specified convertor does not exist.', - 'DEV_NO_TEST_FILE' => 'No value has been specified for the test_file variable in the convertor. If you are a user of this convertor, you should not be seeing this error, please report this message to the convertor author. If you are a convertor author, you must specify the name of a file which exists in the source board to allow the path to it to be verified.', - 'COULD_NOT_FIND_PATH' => 'Could not find path to your former board. Please check your settings and try again.
» %s was specified as the source path.', - 'CONFIG_PHPBB_EMPTY' => 'The phpBB3 config variable for “%s” is empty.', - - 'MAKE_FOLDER_WRITABLE' => 'Please make sure that this folder exists and is writable by the webserver then try again:
»%s.', - 'MAKE_FOLDERS_WRITABLE' => 'Please make sure that these folders exist and are writable by the webserver then try again:
»%s.', - - 'INSTALL_TEST' => 'Test again', - - 'NO_TABLES_FOUND' => 'No tables found.', - 'TABLES_MISSING' => 'Could not find these tables
» %s.', - 'CHECK_TABLE_PREFIX' => 'Please check your table prefix and try again.', - - // Conversion in progress - 'CONTINUE_CONVERT' => 'Continue conversion', - 'CONTINUE_CONVERT_BODY' => 'A previous conversion attempt has been determined. You are now able to choose between starting a new conversion or continuing the conversion.', - 'CONVERT_NEW_CONVERSION' => 'New conversion', - 'CONTINUE_OLD_CONVERSION' => 'Continue previously started conversion', - - // Start conversion - 'SUB_INTRO' => 'Introduction', - 'CONVERT_INTRO' => 'Welcome to the phpBB Unified Convertor Framework', - 'CONVERT_INTRO_BODY' => 'From here, you are able to import data from other (installed) board systems. The list below shows all the conversion modules currently available. If there is no convertor shown in this list for the board software you wish to convert from, please check our website where further conversion modules may be available for download.', - 'AVAILABLE_CONVERTORS' => 'Available convertors', - 'NO_CONVERTORS' => 'No convertors are available for use.', - 'CONVERT_OPTIONS' => 'Options', - 'SOFTWARE' => 'Board software', - 'VERSION' => 'Version', - 'CONVERT' => 'Convert', - - // Settings - 'STAGE_SETTINGS' => 'Settings', - 'TABLE_PREFIX_SAME' => 'The table prefix needs to be the one used by the software you are converting from.
» Specified table prefix was %s.', - 'DEFAULT_PREFIX_IS' => 'The convertor was not able to find tables with the specified prefix. Please make sure you have entered the correct details for the board you are converting from. The default table prefix for %1$s is %2$s.', - 'SPECIFY_OPTIONS' => 'Specify conversion options', - 'FORUM_PATH' => 'Board path', - 'FORUM_PATH_EXPLAIN' => 'This is the relative path on disk to your former board from the root of this phpBB3 installation.', - 'REFRESH_PAGE' => 'Refresh page to continue conversion', - 'REFRESH_PAGE_EXPLAIN' => 'If set to yes, the convertor will refresh the page to continue the conversion after having finished a step. If this is your first conversion for testing purposes and to determine any errors in advance, we suggest to set this to No.', - - // Conversion - 'STAGE_IN_PROGRESS' => 'Conversion in progress', - - 'AUTHOR_NOTES' => 'Author notes
» %s', - 'STARTING_CONVERT' => 'Starting conversion process', - 'CONFIG_CONVERT' => 'Converting the configuration', - 'DONE' => 'Done', - 'PREPROCESS_STEP' => 'Executing pre-processing functions/queries', - 'FILLING_TABLE' => 'Filling table %s', - 'FILLING_TABLES' => 'Filling tables', - 'DB_ERR_INSERT' => 'Error while processing INSERT query.', - 'DB_ERR_LAST' => 'Error while processing query_last.', - 'DB_ERR_QUERY_FIRST' => 'Error while executing query_first.', - 'DB_ERR_QUERY_FIRST_TABLE' => 'Error while executing query_first, %s (“%s”).', - 'DB_ERR_SELECT' => 'Error while running SELECT query.', - 'STEP_PERCENT_COMPLETED' => 'Step %d of %d', - 'FINAL_STEP' => 'Process final step', - 'SYNC_FORUMS' => 'Starting to synchronise forums', - 'SYNC_POST_COUNT' => 'Synchronising post_counts', - 'SYNC_POST_COUNT_ID' => 'Synchronising post_counts from entry %1$s to %2$s.', - 'SYNC_TOPICS' => 'Starting to synchronise topics', - 'SYNC_TOPIC_ID' => 'Synchronising topics from topic_id %1$s to %2$s.', - 'PROCESS_LAST' => 'Processing last statements', - 'UPDATE_TOPICS_POSTED' => 'Generating topics posted information', - 'UPDATE_TOPICS_POSTED_ERR' => 'An error occurred while generating topics posted information. You can retry this step in the ACP after the conversion process is completed.', - 'CONTINUE_LAST' => 'Continue last statements', - 'CLEAN_VERIFY' => 'Cleaning up and verifying the final structure', - 'NOT_UNDERSTAND' => 'Could not understand %s #%d, table %s (“%s”)', - 'NAMING_CONFLICT' => 'Naming conflict: %s and %s are both aliases

%s', - - // Finish conversion - 'CONVERT_COMPLETE' => 'Conversion completed', - 'CONVERT_COMPLETE_EXPLAIN' => 'You have now successfully converted your board to phpBB 3.2. You can now login and access your board. Please ensure that the settings were transferred correctly before enabling your board by deleting the install directory. Remember that help on using phpBB is available online via the Documentation and the support forums.', - - 'CONV_ERROR_ATTACH_FTP_DIR' => 'FTP upload for attachments is enabled at the old board. Please disable the FTP upload option and make sure a valid upload directory is specified, then copy all attachment files to this new web accessible directory. Once you have done this, restart the convertor.', - 'CONV_ERROR_CONFIG_EMPTY' => 'There is no configuration information available for the conversion.', - 'CONV_ERROR_FORUM_ACCESS' => 'Unable to get forum access information.', - 'CONV_ERROR_GET_CATEGORIES' => 'Unable to get categories.', - 'CONV_ERROR_GET_CONFIG' => 'Could not retrieve your board configuration.', - 'CONV_ERROR_COULD_NOT_READ' => 'Unable to access/read “%s”.', - 'CONV_ERROR_GROUP_ACCESS' => 'Unable to get group authentication information.', - 'CONV_ERROR_INCONSISTENT_GROUPS' => 'Inconsistency in groups table detected in add_bots() - you need to add all special groups if you do it manually.', - 'CONV_ERROR_INSERT_BOT' => 'Unable to insert bot into users table.', - 'CONV_ERROR_INSERT_BOTGROUP' => 'Unable to insert bot into bots table.', - 'CONV_ERROR_INSERT_USER_GROUP' => 'Unable to insert user into user_group table.', - 'CONV_ERROR_MESSAGE_PARSER' => 'Message parser error', - 'CONV_ERROR_NO_AVATAR_PATH' => 'Note to developer: you must specify $convertor[\'avatar_path\'] to use %s.', - 'CONV_ERROR_NO_FORUM_PATH' => 'The relative path to the source board has not been specified.', - 'CONV_ERROR_NO_GALLERY_PATH' => 'Note to developer: you must specify $convertor[\'avatar_gallery_path\'] to use %s.', - 'CONV_ERROR_NO_GROUP' => 'Group “%1$s” could not be found in %2$s.', - 'CONV_ERROR_NO_RANKS_PATH' => 'Note to developer: you must specify $convertor[\'ranks_path\'] to use %s.', - 'CONV_ERROR_NO_SMILIES_PATH' => 'Note to developer: you must specify $convertor[\'smilies_path\'] to use %s.', - 'CONV_ERROR_NO_UPLOAD_DIR' => 'Note to developer: you must specify $convertor[\'upload_path\'] to use %s.', - 'CONV_ERROR_PERM_SETTING' => 'Unable to insert/update permission setting.', - 'CONV_ERROR_PM_COUNT' => 'Unable to select folder pm count.', - 'CONV_ERROR_REPLACE_CATEGORY' => 'Unable to insert new forum replacing old category.', - 'CONV_ERROR_REPLACE_FORUM' => 'Unable to insert new forum replacing old forum.', - 'CONV_ERROR_USER_ACCESS' => 'Unable to get user authentication information.', - 'CONV_ERROR_WRONG_GROUP' => 'Wrong group “%1$s” defined in %2$s.', - 'CONV_OPTIONS_BODY' => 'This page collects the data required to access the source board. Enter the database details of your former board; the converter will not change anything in the database given below. The source board should be disabled to allow a consistent conversion.', - 'CONV_SAVED_MESSAGES' => 'Saved messages', - - 'PRE_CONVERT_COMPLETE' => 'All pre-conversion steps have successfully been completed. You may now begin the actual conversion process. Please note that you may have to manually do and adjust several things. After conversion, especially check the permissions assigned, rebuild your search index which is not converted and also make sure files got copied correctly, for example avatars and smilies.', -)); diff --git a/install/update/old/language/en/migrator.php b/install/update/old/language/en/migrator.php deleted file mode 100644 index 8a82d40..0000000 --- a/install/update/old/language/en/migrator.php +++ /dev/null @@ -1,81 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* DO NOT CHANGE -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -if (empty($lang) || !is_array($lang)) -{ - $lang = array(); -} - -// DEVELOPERS PLEASE NOTE -// -// All language files should use UTF-8 as their encoding and the files must not contain a BOM. -// -// Placeholders can now contain order information, e.g. instead of -// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows -// translators to re-order the output of data while ensuring it remains correct -// -// You do not need this where single placeholders are used, e.g. 'Message %d' is fine -// equally where a string contains only two placeholders which are used to wrap text -// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine - -$lang = array_merge($lang, array( - 'CONFIG_NOT_EXIST' => 'The config setting "%s" unexpectedly does not exist.', - - 'GROUP_NOT_EXIST' => 'The group "%s" unexpectedly does not exist.', - - 'MIGRATION_APPLY_DEPENDENCIES' => 'Apply dependencies of %s.', - 'MIGRATION_DATA_DONE' => 'Installed Data: %1$s; Time: %2$.2f seconds', - 'MIGRATION_DATA_IN_PROGRESS' => 'Installing Data: %1$s; Time: %2$.2f seconds', - 'MIGRATION_DATA_RUNNING' => 'Installing Data: %s.', - 'MIGRATION_EFFECTIVELY_INSTALLED' => 'Migration already effectively installed (skipped): %s', - 'MIGRATION_EXCEPTION_ERROR' => 'Something went wrong during the request and an exception was thrown. The changes made before the error occurred were reversed to the best of our abilities, but you should check the board for errors.', - 'MIGRATION_NOT_FULFILLABLE' => 'The migration "%1$s" is not fulfillable, missing migration "%2$s".', - 'MIGRATION_NOT_INSTALLED' => 'The migration "%s" is not installed.', - 'MIGRATION_NOT_VALID' => '%s is not a valid migration.', - 'MIGRATION_SCHEMA_DONE' => 'Installed Schema: %1$s; Time: %2$.2f seconds', - 'MIGRATION_SCHEMA_IN_PROGRESS' => 'Installing Schema: %1$s; Time: %2$.2f seconds', - 'MIGRATION_SCHEMA_RUNNING' => 'Installing Schema: %s.', - - 'MIGRATION_REVERT_DATA_DONE' => 'Reverted Data: %1$s; Time: %2$.2f seconds', - 'MIGRATION_REVERT_DATA_IN_PROGRESS' => 'Reverting Data: %1$s; Time: %2$.2f seconds', - 'MIGRATION_REVERT_DATA_RUNNING' => 'Reverting Data: %s.', - 'MIGRATION_REVERT_SCHEMA_DONE' => 'Reverted Schema: %1$s; Time: %2$.2f seconds', - 'MIGRATION_REVERT_SCHEMA_IN_PROGRESS' => 'Reverting Schema: %1$s; Time: %2$.2f seconds', - 'MIGRATION_REVERT_SCHEMA_RUNNING' => 'Reverting Schema: %s.', - - 'MIGRATION_INVALID_DATA_MISSING_CONDITION' => 'A migration is invalid. An if statement helper is missing a condition.', - 'MIGRATION_INVALID_DATA_MISSING_STEP' => 'A migration is invalid. An if statement helper is missing a valid call to a migration step.', - 'MIGRATION_INVALID_DATA_CUSTOM_NOT_CALLABLE' => 'A migration is invalid. A custom callable function could not be called.', - 'MIGRATION_INVALID_DATA_UNKNOWN_TYPE' => 'A migration is invalid. An unknown migration tool type was encountered.', - 'MIGRATION_INVALID_DATA_UNDEFINED_TOOL' => 'A migration is invalid. An undefined migration tool was encountered.', - 'MIGRATION_INVALID_DATA_UNDEFINED_METHOD' => 'A migration is invalid. An undefined migration tool method was encountered.', - - 'MODULE_ERROR' => 'An error occurred while creating a module: %s', - 'MODULE_EXISTS' => 'A module already exists: %s', - 'MODULE_EXIST_MULTIPLE' => 'Several modules with the given parent module langname already exist: %s. Try using before/after keys to clarify the module placement.', - 'MODULE_INFO_FILE_NOT_EXIST' => 'A required module info file is missing: %2$s', - 'MODULE_NOT_EXIST' => 'A required module does not exist: %s', - - 'PARENT_MODULE_FIND_ERROR' => 'Unable to determine the parent module identifier: %s', - 'PERMISSION_NOT_EXIST' => 'The permission setting "%s" unexpectedly does not exist.', - - 'ROLE_NOT_EXIST' => 'The permission role "%s" unexpectedly does not exist.', -)); diff --git a/install/update/old/language/en/posting.php b/install/update/old/language/en/posting.php deleted file mode 100644 index 11ea648..0000000 --- a/install/update/old/language/en/posting.php +++ /dev/null @@ -1,287 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* DO NOT CHANGE -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -if (empty($lang) || !is_array($lang)) -{ - $lang = array(); -} - -// DEVELOPERS PLEASE NOTE -// -// All language files should use UTF-8 as their encoding and the files must not contain a BOM. -// -// Placeholders can now contain order information, e.g. instead of -// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows -// translators to re-order the output of data while ensuring it remains correct -// -// You do not need this where single placeholders are used, e.g. 'Message %d' is fine -// equally where a string contains only two placeholders which are used to wrap text -// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine - -$lang = array_merge($lang, array( - 'ADD_ATTACHMENT' => 'Upload attachment', - 'ADD_ATTACHMENT_EXPLAIN' => 'If you wish to attach one or more files enter the details below.', - 'ADD_FILE' => 'Add the file', - 'ADD_POLL' => 'Poll creation', - 'ADD_POLL_EXPLAIN' => 'If you do not want to add a poll to your topic leave the fields blank.', - 'ALREADY_DELETED' => 'Sorry but this message is already deleted.', - 'ATTACH_DISK_FULL' => 'There is not enough free disk space to post this attachment.', - 'ATTACH_QUOTA_REACHED' => 'Sorry, the board attachment quota has been reached.', - 'ATTACH_SIG' => 'Attach a signature (signatures can be altered via the UCP)', - - 'BBCODE_A_HELP' => 'Inline uploaded attachment: [attachment=]filename.ext[/attachment]', - 'BBCODE_B_HELP' => 'Bold text: [b]text[/b]', - 'BBCODE_C_HELP' => 'Code display: [code]code[/code]', - 'BBCODE_D_HELP' => 'Flash: [flash=width,height]http://url[/flash]', - 'BBCODE_F_HELP' => 'Font size: [size=85]small text[/size]', - 'BBCODE_IS_OFF' => '%sBBCode%s is OFF', - 'BBCODE_IS_ON' => '%sBBCode%s is ON', - 'BBCODE_I_HELP' => 'Italic text: [i]text[/i]', - 'BBCODE_L_HELP' => 'List: [list][*]text[/list]', - 'BBCODE_LISTITEM_HELP' => 'List item: [*]text', - 'BBCODE_O_HELP' => 'Ordered list: e.g. [list=1][*]First point[/list] or [list=a][*]Point a[/list]', - 'BBCODE_P_HELP' => 'Insert image: [img]http://image_url[/img]', - 'BBCODE_Q_HELP' => 'Quote text: [quote]text[/quote]', - 'BBCODE_S_HELP' => 'Font colour: [color=red]text[/color] or [color=#FF0000]text[/color]', - 'BBCODE_U_HELP' => 'Underline text: [u]text[/u]', - 'BBCODE_W_HELP' => 'Insert URL: [url]http://url[/url] or [url=http://url]URL text[/url]', - 'BBCODE_Y_HELP' => 'List: Add list element', - 'BUMP_ERROR' => 'You cannot bump this topic so soon after the last post.', - - 'CANNOT_DELETE_REPLIED' => 'Sorry but you may only delete posts which have not been replied to.', - 'CANNOT_EDIT_POST_LOCKED' => 'This post has been locked. You can no longer edit that post.', - 'CANNOT_EDIT_TIME' => 'You can no longer edit or delete that post.', - 'CANNOT_POST_ANNOUNCE' => 'Sorry but you cannot post announcements.', - 'CANNOT_POST_STICKY' => 'Sorry but you cannot post sticky topics.', - 'CHANGE_TOPIC_TO' => 'Change topic type to', - 'CHARS_POST_CONTAINS' => array( - 1 => 'Your message contains %1$d character.', - 2 => 'Your message contains %1$d characters.', - ), - 'CHARS_SIG_CONTAINS' => array( - 1 => 'Your signature contains %1$d character.', - 2 => 'Your signature contains %1$d characters.', - ), - 'CLOSE_TAGS' => 'Close tags', - 'CURRENT_TOPIC' => 'Current topic', - - 'DELETE_FILE' => 'Delete file', - 'DELETE_MESSAGE' => 'Delete message', - 'DELETE_MESSAGE_CONFIRM' => 'Are you sure you want to delete this message?', - 'DELETE_OWN_POSTS' => 'Sorry but you can only delete your own posts.', - 'DELETE_PERMANENTLY' => 'Delete permanently', - 'DELETE_POST_CONFIRM' => 'Are you sure you want to delete this post?', - 'DELETE_POST_PERMANENTLY_CONFIRM' => 'Are you sure you want to permanently delete this post?', - 'DELETE_POST_PERMANENTLY' => array( - 1 => 'Permanently delete this post so it can not be recovered', - 2 => 'Permanently delete %1$d posts so they can not be recovered', - ), - 'DELETE_POSTS_CONFIRM' => 'Are you sure you want to delete these posts?', - 'DELETE_POSTS_PERMANENTLY_CONFIRM' => 'Are you sure you want to permanently delete these posts?', - 'DELETE_REASON' => 'Reason for deletion', - 'DELETE_REASON_EXPLAIN' => 'The specified reason for deletion will be visible to moderators.', - 'DELETE_POST_WARN' => 'Delete this post', - 'DELETE_TOPIC_CONFIRM' => 'Are you sure you want to delete this topic?', - 'DELETE_TOPIC_PERMANENTLY' => array( - 1 => 'Permanently delete this topic so it can not be recovered', - 2 => 'Permanently delete %1$d topics so they can not be recovered', - ), - 'DELETE_TOPIC_PERMANENTLY_CONFIRM' => 'Are you sure you want to permanently delete this topic?', - 'DELETE_TOPICS_CONFIRM' => 'Are you sure you want to delete these topics?', - 'DELETE_TOPICS_PERMANENTLY_CONFIRM' => 'Are you sure you want to permanently delete these topics?', - 'DISABLE_BBCODE' => 'Disable BBCode', - 'DISABLE_MAGIC_URL' => 'Do not automatically parse URLs', - 'DISABLE_SMILIES' => 'Disable smilies', - 'DISALLOWED_CONTENT' => 'The upload was rejected because the uploaded file was identified as a possible attack vector.', - 'DISALLOWED_EXTENSION' => 'The extension %s is not allowed.', - 'DRAFT_LOADED' => 'Draft loaded into posting area, you may want to finish your post now.
Your draft will be deleted after submitting this post.', - 'DRAFT_LOADED_PM' => 'Draft loaded into message area, you may want to finish your private message now.
Your draft will be deleted after submitting this private message.', - 'DRAFT_SAVED' => 'Draft successfully saved.', - 'DRAFT_TITLE' => 'Draft title', - - 'EDIT_REASON' => 'Reason for editing this post', - 'EMPTY_FILEUPLOAD' => 'The uploaded file is empty.', - 'EMPTY_MESSAGE' => 'You must enter a message when posting.', - 'EMPTY_REMOTE_DATA' => 'File could not be uploaded, please try uploading the file manually.', - - 'FLASH_IS_OFF' => '[flash] is OFF', - 'FLASH_IS_ON' => '[flash] is ON', - 'FLOOD_ERROR' => 'You cannot make another post so soon after your last.', - 'FONT_COLOR' => 'Font colour', - 'FONT_COLOR_HIDE' => 'Hide font colour', - 'FONT_HUGE' => 'Huge', - 'FONT_LARGE' => 'Large', - 'FONT_NORMAL' => 'Normal', - 'FONT_SIZE' => 'Font size', - 'FONT_SMALL' => 'Small', - 'FONT_TINY' => 'Tiny', - - 'GENERAL_UPLOAD_ERROR' => 'Could not upload attachment to %s.', - - 'IMAGES_ARE_OFF' => '[img] is OFF', - 'IMAGES_ARE_ON' => '[img] is ON', - 'INVALID_FILENAME' => '%s is an invalid filename.', - - 'LOAD' => 'Load', - 'LOAD_DRAFT' => 'Load draft', - 'LOAD_DRAFT_EXPLAIN' => 'Here you are able to select the draft you want to continue writing. Your current post will be cancelled, all current post contents will be deleted. View, edit and delete drafts within your User Control Panel.', - 'LOGIN_EXPLAIN_BUMP' => 'You need to login in order to bump topics within this forum.', - 'LOGIN_EXPLAIN_DELETE' => 'You need to login in order to delete posts within this forum.', - 'LOGIN_EXPLAIN_SOFT_DELETE' => 'You need to login in order to soft-delete posts within this forum.', - 'LOGIN_EXPLAIN_POST' => 'You need to login in order to post within this forum.', - 'LOGIN_EXPLAIN_QUOTE' => 'You need to login in order to quote posts within this forum.', - 'LOGIN_EXPLAIN_REPLY' => 'You need to login in order to reply to topics within this forum.', - - 'MAX_FONT_SIZE_EXCEEDED' => 'You may only use fonts up to size %d.', - 'MAX_FLASH_HEIGHT_EXCEEDED' => array( - 1 => 'Your flash files may only be up to %d pixel high.', - 2 => 'Your flash files may only be up to %d pixels high.', - ), - 'MAX_FLASH_WIDTH_EXCEEDED' => array( - 1 => 'Your flash files may only be up to %d pixel wide.', - 2 => 'Your flash files may only be up to %d pixels wide.', - ), - 'MAX_IMG_HEIGHT_EXCEEDED' => array( - 1 => 'Your images may only be up to %1$d pixel high.', - 2 => 'Your images may only be up to %1$d pixels high.', - ), - 'MAX_IMG_WIDTH_EXCEEDED' => array( - 1 => 'Your images may only be up to %d pixel wide.', - 2 => 'Your images may only be up to %d pixels wide.', - ), - - 'MESSAGE_BODY_EXPLAIN' => array( - 0 => '', // zero means no limit, so we don't view a message here. - 1 => 'Enter your message here, it may contain no more than %d character.', - 2 => 'Enter your message here, it may contain no more than %d characters.', - ), - 'MESSAGE_DELETED' => 'This message has been deleted successfully.', - 'MORE_SMILIES' => 'View more smilies', - - 'NOTIFY_REPLY' => 'Notify me when a reply is posted', - 'NOT_UPLOADED' => 'File could not be uploaded.', - 'NO_DELETE_POLL_OPTIONS' => 'You cannot delete existing poll options.', - 'NO_PM_ICON' => 'No PM icon', - 'NO_POLL_TITLE' => 'You have to enter a poll title.', - 'NO_POST' => 'The requested post does not exist.', - 'NO_POST_MODE' => 'No post mode specified.', - 'NO_TEMP_DIR' => 'Temporary folder could not be found or is not writable.', - - 'PARTIAL_UPLOAD' => 'The uploaded file was only partially uploaded.', - 'PHP_UPLOAD_STOPPED' => 'A PHP extension has stopped the file upload.', - 'PHP_SIZE_NA' => 'The attachment’s file size is too large.
Could not determine the maximum size defined by PHP in php.ini.', - 'PHP_SIZE_OVERRUN' => 'The attachment’s file size is too large, the maximum upload size is %1$d %2$s.
Please note this is set in php.ini and cannot be overridden.', - 'PLACE_INLINE' => 'Place inline', - 'POLL_DELETE' => 'Delete poll', - 'POLL_FOR' => 'Run poll for', - 'POLL_FOR_EXPLAIN' => 'Enter 0 for a never ending poll.', - 'POLL_MAX_OPTIONS' => 'Options per user', - 'POLL_MAX_OPTIONS_EXPLAIN' => 'This is the number of options each user may select when voting.', - 'POLL_OPTIONS' => 'Poll options', - 'POLL_OPTIONS_EXPLAIN' => array( - 1 => 'Place each option on a new line. You may enter %d option.', - 2 => 'Place each option on a new line. You may enter up to %d options.', - ), - 'POLL_OPTIONS_EDIT_EXPLAIN' => array( - 1 => 'Place each option on a new line. You may enter %d option. If you remove or add options all previous votes will be reset.', - 2 => 'Place each option on a new line. You may enter up to %d options. If you remove or add options all previous votes will be reset.', - ), - 'POLL_QUESTION' => 'Poll question', - 'POLL_TITLE_TOO_LONG' => 'The poll title must contain fewer than 100 characters.', - 'POLL_TITLE_COMP_TOO_LONG' => 'The parsed size of your poll title is too large, consider removing BBCodes or smilies.', - 'POLL_VOTE_CHANGE' => 'Allow re-voting', - 'POLL_VOTE_CHANGE_EXPLAIN' => 'If enabled users are able to change their vote.', - 'POSTED_ATTACHMENTS' => 'Posted attachments', - 'POST_APPROVAL_NOTIFY' => 'You will be notified when your post has been approved.', - 'POST_CONFIRMATION' => 'Confirmation of post', - 'POST_CONFIRM_EXPLAIN' => 'To prevent automated posts the board requires you to enter a confirmation code. The code is displayed in the image you should see below. If you are visually impaired or cannot otherwise read this code please contact the %sBoard Administrator%s.', - 'POST_DELETED' => 'This post has been deleted successfully.', - 'POST_EDITED' => 'This post has been edited successfully.', - 'POST_EDITED_MOD' => 'This post has been edited successfully, but it will need to be approved by a moderator before it is publicly viewable.', - 'POST_GLOBAL' => 'Global', - 'POST_ICON' => 'Post icon', - 'POST_NORMAL' => 'Normal', - 'POST_REVIEW' => 'Post review', - 'POST_REVIEW_EDIT' => 'Post review', - 'POST_REVIEW_EDIT_EXPLAIN' => 'This post has been altered by another user while you were editing it. You may wish to review the current version of this post and adjust your edits.', - 'POST_REVIEW_EXPLAIN' => 'At least one new post has been made to this topic. You may wish to review your post in light of this.', - 'POST_STORED' => 'This message has been posted successfully.', - 'POST_STORED_MOD' => 'This message has been submitted successfully, but it will need to be approved by a moderator before it is publicly viewable.', - 'POST_TOPIC_AS' => 'Post topic as', - 'PROGRESS_BAR' => 'Progress bar', - - 'QUOTE_DEPTH_EXCEEDED' => array( - 1 => 'You may embed only %d quote within each other.', - 2 => 'You may embed only %d quotes within each other.', - ), - 'QUOTE_NO_NESTING' => 'You may not embed quotes within each other.', - - 'REMOTE_UPLOAD_TIMEOUT' => 'The specified file could not be uploaded because the request timed out.', - 'SAVE' => 'Save', - 'SAVE_DATE' => 'Saved at', - 'SAVE_DRAFT' => 'Save draft', - 'SAVE_DRAFT_CONFIRM' => 'Please note that saved drafts only include the subject and the message, any other element will be removed. Do you want to save your draft now?', - 'SMILIES' => 'Smilies', - 'SMILIES_ARE_OFF' => 'Smilies are OFF', - 'SMILIES_ARE_ON' => 'Smilies are ON', - 'STICKY_ANNOUNCE_TIME_LIMIT'=> 'Sticky/Announcement/Global time limit', - 'STICK_TOPIC_FOR' => 'Stick topic for', - 'STICK_TOPIC_FOR_EXPLAIN' => 'Enter 0 for a never ending Sticky/Announcement/Global. Please note that this number is relative to the date of the post.', - 'STYLES_TIP' => 'Tip: Styles can be applied quickly to selected text.', - - 'TOO_FEW_CHARS' => 'Your message contains too few characters.', - 'TOO_FEW_CHARS_LIMIT' => array( - 1 => 'You need to enter at least %1$d character.', - 2 => 'You need to enter at least %1$d characters.', - ), - 'TOO_FEW_POLL_OPTIONS' => 'You must enter at least two poll options.', - 'TOO_MANY_ATTACHMENTS' => 'Cannot add another attachment, %d is the maximum.', - 'TOO_MANY_CHARS' => 'Your message contains too many characters.', - 'TOO_MANY_CHARS_LIMIT' => array( - 2 => 'The maximum number of allowed characters is %1$d.', - ), - 'TOO_MANY_POLL_OPTIONS' => 'You have tried to enter too many poll options.', - 'TOO_MANY_SMILIES' => 'Your message contains too many smilies. The maximum number of smilies allowed is %d.', - 'TOO_MANY_URLS' => 'Your message contains too many URLs. The maximum number of URLs allowed is %d.', - 'TOO_MANY_USER_OPTIONS' => 'You cannot specify more options per user than existing poll options.', - 'TOPIC_BUMPED' => 'Topic has been bumped successfully.', - - 'UNAUTHORISED_BBCODE' => 'You cannot use certain BBCodes: %s.', - 'UNGLOBALISE_EXPLAIN' => 'To switch this topic back from being global to a normal topic, you need to select the forum you wish this topic to be displayed.', - 'UNSUPPORTED_CHARACTERS_MESSAGE' => 'Your message contains the following unsupported characters:
%s', - 'UNSUPPORTED_CHARACTERS_SUBJECT' => 'Your subject contains the following unsupported characters:
%s', - 'UPDATE_COMMENT' => 'Update comment', - 'URL_INVALID' => 'The URL you specified is invalid.', - 'URL_NOT_FOUND' => 'The file specified could not be found.', - 'URL_IS_OFF' => '[url] is OFF', - 'URL_IS_ON' => '[url] is ON', - 'USER_CANNOT_BUMP' => 'You cannot bump topics in this forum.', - 'USER_CANNOT_DELETE' => 'You cannot delete posts in this forum.', - 'USER_CANNOT_EDIT' => 'You cannot edit posts in this forum.', - 'USER_CANNOT_REPLY' => 'You cannot reply in this forum.', - 'USER_CANNOT_FORUM_POST' => 'You are not able to do posting operations on this forum due to the forum type not supporting it.', - - 'VIEW_MESSAGE' => '%sView your submitted message%s', - 'VIEW_PRIVATE_MESSAGE' => '%sView your submitted private message%s', - - 'WRONG_FILESIZE' => 'The file is too big, maximum allowed size is %1$d %2$s.', - 'WRONG_SIZE' => 'The image must be at least %1$s wide, %2$s high and at most %3$s wide and %4$s high. The submitted image is %5$s wide and %6$s high.', -)); diff --git a/install/update/old/language/en/ucp.php b/install/update/old/language/en/ucp.php deleted file mode 100644 index 2622fb5..0000000 --- a/install/update/old/language/en/ucp.php +++ /dev/null @@ -1,662 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* DO NOT CHANGE -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -if (empty($lang) || !is_array($lang)) -{ - $lang = array(); -} - -// DEVELOPERS PLEASE NOTE -// -// All language files should use UTF-8 as their encoding and the files must not contain a BOM. -// -// Placeholders can now contain order information, e.g. instead of -// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows -// translators to re-order the output of data while ensuring it remains correct -// -// You do not need this where single placeholders are used, e.g. 'Message %d' is fine -// equally where a string contains only two placeholders which are used to wrap text -// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine - -// Privacy policy and T&C -$lang = array_merge($lang, array( - 'TERMS_OF_USE_CONTENT' => 'By accessing “%1$s” (hereinafter “we”, “us”, “our”, “%1$s”, “%2$s”), you agree to be legally bound by the following terms. If you do not agree to be legally bound by all of the following terms then please do not access and/or use “%1$s”. We may change these at any time and we’ll do our utmost in informing you, though it would be prudent to review this regularly yourself as your continued usage of “%1$s” after changes mean you agree to be legally bound by these terms as they are updated and/or amended.
-
- Our forums are powered by phpBB (hereinafter “they”, “them”, “their”, “phpBB software”, “www.phpbb.com”, “phpBB Limited”, “phpBB Teams”) which is a bulletin board solution released under the “GNU General Public License v2” (hereinafter “GPL”) and can be downloaded from www.phpbb.com. The phpBB software only facilitates internet based discussions; phpBB Limited is not responsible for what we allow and/or disallow as permissible content and/or conduct. For further information about phpBB, please see: https://www.phpbb.com/.
-
- You agree not to post any abusive, obscene, vulgar, slanderous, hateful, threatening, sexually-orientated or any other material that may violate any laws be it of your country, the country where “%1$s” is hosted or International Law. Doing so may lead to you being immediately and permanently banned, with notification of your Internet Service Provider if deemed required by us. The IP address of all posts are recorded to aid in enforcing these conditions. You agree that “%1$s” have the right to remove, edit, move or close any topic at any time should we see fit. As a user you agree to any information you have entered to being stored in a database. While this information will not be disclosed to any third party without your consent, neither “%1$s” nor phpBB shall be held responsible for any hacking attempt that may lead to the data being compromised. - ', - - 'PRIVACY_POLICY' => 'This policy explains in detail how “%1$s” along with its affiliated companies (hereinafter “we”, “us”, “our”, “%1$s”, “%2$s”) and phpBB (hereinafter “they”, “them”, “their”, “phpBB software”, “www.phpbb.com”, “phpBB Limited”, “phpBB Teams”) use any information collected during any session of usage by you (hereinafter “your information”).
-
- Your information is collected via two ways. Firstly, by browsing “%1$s” will cause the phpBB software to create a number of cookies, which are small text files that are downloaded on to your computer’s web browser temporary files. The first two cookies just contain a user identifier (hereinafter “user-id”) and an anonymous session identifier (hereinafter “session-id”), automatically assigned to you by the phpBB software. A third cookie will be created once you have browsed topics within “%1$s” and is used to store which topics have been read, thereby improving your user experience.
-
- We may also create cookies external to the phpBB software whilst browsing “%1$s”, though these are outside the scope of this document which is intended to only cover the pages created by the phpBB software. The second way in which we collect your information is by what you submit to us. This can be, and is not limited to: posting as an anonymous user (hereinafter “anonymous posts”), registering on “%1$s” (hereinafter “your account”) and posts submitted by you after registration and whilst logged in (hereinafter “your posts”).
-
- Your account will at a bare minimum contain a uniquely identifiable name (hereinafter “your user name”), a personal password used for logging into your account (hereinafter “your password”) and a personal, valid email address (hereinafter “your email”). Your information for your account at “%1$s” is protected by data-protection laws applicable in the country that hosts us. Any information beyond your user name, your password, and your email address required by “%1$s” during the registration process is either mandatory or optional, at the discretion of “%1$s”. In all cases, you have the option of what information in your account is publicly displayed. Furthermore, within your account, you have the option to opt-in or opt-out of automatically generated emails from the phpBB software.
-
- Your password is ciphered (a one-way hash) so that it is secure. However, it is recommended that you do not reuse the same password across a number of different websites. Your password is the means of accessing your account at “%1$s”, so please guard it carefully and under no circumstance will anyone affiliated with “%1$s”, phpBB or another 3rd party, legitimately ask you for your password. Should you forget your password for your account, you can use the “I forgot my password” feature provided by the phpBB software. This process will ask you to submit your user name and your email, then the phpBB software will generate a new password to reclaim your account.
- ', -)); - -// Common language entries -$lang = array_merge($lang, array( - 'ACCOUNT_ACTIVE' => 'Your account has now been activated. Thank you for registering.', - 'ACCOUNT_ACTIVE_ADMIN' => 'The account has now been activated.', - 'ACCOUNT_ACTIVE_PROFILE' => 'Your account has now been successfully reactivated.', - 'ACCOUNT_ADDED' => 'Thank you for registering, your account has been created. You may now login with your username and password.', - 'ACCOUNT_COPPA' => 'Your account has been created but has to be approved, please check your email for details.', - 'ACCOUNT_EMAIL_CHANGED' => 'Your account has been updated. However, this board requires account reactivation on email changes. An activation key has been sent to the new email address you provided. Please check your email for further information.', - 'ACCOUNT_EMAIL_CHANGED_ADMIN' => 'Your account has been updated. However, this board requires account reactivation by the administrators on email changes. An email has been sent to them and you will be informed when your account has been reactivated.', - 'ACCOUNT_INACTIVE' => 'Your account has been created. However, this board requires account activation. An activation key has been sent to the email address you provided. Please check your email for further information and also be sure to check your junk mail box. It may take a while to get the email depending on your email provider.', - 'ACCOUNT_INACTIVE_ADMIN' => 'Your account has been created. However, this board requires account activation by the administrator group. An email has been sent to them and you will be informed when your account has been activated.', - 'ACTIVATION_EMAIL_SENT' => 'The activation email has been sent to your email address.', - 'ACTIVATION_EMAIL_SENT_ADMIN' => 'The activation email has been sent to the administrators email addresses.', - 'ADD' => 'Add', - 'ADD_BCC' => 'Add [BCC]', - 'ADD_FOES' => 'Add new foes', - 'ADD_FOES_EXPLAIN' => 'You may enter several usernames each on a different line.', - 'ADD_FOLDER' => 'Add folder', - 'ADD_FRIENDS' => 'Add new friends', - 'ADD_FRIENDS_EXPLAIN' => 'You may enter several usernames each on a different line.', - 'ADD_NEW_RULE' => 'Add new rule', - 'ADD_RULE' => 'Add rule', - 'ADD_TO' => 'Add [To]', - 'ADD_USERS_UCP_EXPLAIN' => 'Here you can add new users to the group. You may select whether this group becomes the new default for the selected users. Please enter each username on a separate line.', - 'ADMIN_EMAIL' => 'Administrators can email me information', - 'AGREE' => 'I agree to these terms', - 'ALLOW_PM' => 'Allow users to send you private messages', - 'ALLOW_PM_EXPLAIN' => 'Note that administrators and moderators will always be able to send you messages.', - 'ALREADY_ACTIVATED' => 'You have already activated your account.', - 'ATTACHMENTS_EXPLAIN' => 'This is a list of attachments you have made in posts to this board.', - 'ATTACHMENTS_DELETED' => 'Attachments successfully deleted.', - 'ATTACHMENT_DELETED' => 'Attachment successfully deleted.', - 'AUTOLOGIN_SESSION_KEYS_DELETED'=> 'The selected "Remember Me" login keys were successfully deleted.', - 'AVATAR_CATEGORY' => 'Category', - 'AVATAR_DRIVER_GRAVATAR_TITLE' => 'Gravatar', - 'AVATAR_DRIVER_GRAVATAR_EXPLAIN'=> 'Gravatar is a service that allows you to maintain the same avatar across multiple websites. Visit Gravatar for more information.', - 'AVATAR_DRIVER_LOCAL_TITLE' => 'Gallery avatar', - 'AVATAR_DRIVER_LOCAL_EXPLAIN' => 'You can choose your avatar from a locally available set of avatars.', - 'AVATAR_DRIVER_REMOTE_TITLE' => 'Remote avatar', - 'AVATAR_DRIVER_REMOTE_EXPLAIN' => 'Link to avatar images from another website.', - 'AVATAR_DRIVER_UPLOAD_TITLE' => 'Upload avatar', - 'AVATAR_DRIVER_UPLOAD_EXPLAIN' => 'Upload your own custom avatar.', - 'AVATAR_EXPLAIN' => 'Maximum dimensions; width: %1$s, height: %2$s, file size: %3$.2f KiB.', - 'AVATAR_EXPLAIN_NO_FILESIZE' => 'Maximum dimensions; width: %1$s, height: %2$s.', - 'AVATAR_FEATURES_DISABLED' => 'The avatar functionality is currently disabled.', - 'AVATAR_GALLERY' => 'Local gallery', - 'AVATAR_GENERAL_UPLOAD_ERROR' => 'Could not upload avatar to %s.', - 'AVATAR_NOT_ALLOWED' => 'Your avatar cannot be displayed because avatars have been disallowed.', - 'AVATAR_PAGE' => 'Page', - 'AVATAR_SELECT' => 'Select your avatar', - 'AVATAR_TYPE' => 'Avatar type', - 'AVATAR_TYPE_NOT_ALLOWED' => 'Your current avatar cannot be displayed because its type has been disallowed.', - - 'BACK_TO_DRAFTS' => 'Back to saved drafts', - 'BACK_TO_LOGIN' => 'Back to login screen', - 'BIRTHDAY' => 'Birthday', - 'BIRTHDAY_EXPLAIN' => 'Setting a year will list your age when it is your birthday.', - 'BOARD_DATE_FORMAT' => 'My date format', - 'BOARD_DATE_FORMAT_EXPLAIN' => 'The syntax used is identical to the PHP date() function.', - 'BOARD_LANGUAGE' => 'My language', - 'BOARD_STYLE' => 'My board style', - 'BOARD_TIMEZONE' => 'My timezone', - 'BOOKMARKS' => 'Bookmarks', - 'BOOKMARKS_EXPLAIN' => 'You can bookmark topics for future reference. Select the checkbox for any bookmark you wish to delete, then press the Remove marked bookmarks button.', - 'BOOKMARKS_DISABLED' => 'Bookmarks are disabled on this board.', - 'BOOKMARKS_REMOVED' => 'Bookmarks removed successfully.', - - 'CANNOT_EDIT_MESSAGE_TIME' => 'You can no longer edit or delete that message.', - 'CANNOT_MOVE_TO_SAME_FOLDER'=> 'Messages cannot be moved to the folder you want to remove.', - 'CANNOT_MOVE_FROM_SPECIAL' => 'Messages cannot be moved from the outbox.', - 'CANNOT_RENAME_FOLDER' => 'This folder cannot be renamed.', - 'CANNOT_REMOVE_FOLDER' => 'This folder cannot be removed.', - 'CHANGE_DEFAULT_GROUP' => 'Change default group', - 'CHANGE_PASSWORD' => 'Change password', - 'CLICK_GOTO_FOLDER' => '%1$sGo to your “%3$s” folder%2$s', - 'CLICK_RETURN_FOLDER' => '%1$sReturn to your “%3$s” folder%2$s', - 'CONFIRMATION' => 'Confirmation of registration', - 'CONFIRM_CHANGES' => 'Confirm changes', - 'CONFIRM_EXPLAIN' => 'To prevent automated registrations the board requires you to enter a confirmation code. The code is displayed in the image you should see below. If you are visually impaired or cannot otherwise read this code please contact the %sBoard Administrator%s.', - 'VC_REFRESH' => 'Refresh confirmation code', - 'VC_REFRESH_EXPLAIN' => 'If you cannot read the code you can request a new one by clicking the button.', - - 'CONFIRM_PASSWORD' => 'Confirm password', - 'CONFIRM_PASSWORD_EXPLAIN' => 'You only need to confirm your password if you changed it above.', - 'COPPA_BIRTHDAY' => 'To continue with the registration procedure please tell us when you were born.', - 'COPPA_COMPLIANCE' => 'COPPA compliance', - 'COPPA_EXPLAIN' => 'Please note that clicking submit will create your account. However it cannot be activated until a parent or guardian approves your registration. You will be emailed a copy of the necessary form with details of where to send it.', - 'CREATE_FOLDER' => 'Add folder…', - 'CURRENT_IMAGE' => 'Current image', - 'CURRENT_PASSWORD' => 'Current password', - 'CURRENT_PASSWORD_EXPLAIN' => 'You must enter your current password if you wish to alter your email address or username.', - 'CURRENT_CHANGE_PASSWORD_EXPLAIN' => 'To change your password, your email address, or your username, you must enter your current password.', - 'CUR_PASSWORD_EMPTY' => 'You did not enter your current password.', - 'CUR_PASSWORD_ERROR' => 'The current password you entered is incorrect.', - 'CUSTOM_DATEFORMAT' => 'Custom…', - - 'DEFAULT_ACTION' => 'Default action', - 'DEFAULT_ACTION_EXPLAIN' => 'This action will be triggered if none of the above is applicable.', - 'DEFAULT_ADD_SIG' => 'Attach my signature by default', - 'DEFAULT_BBCODE' => 'Enable BBCode by default', - 'DEFAULT_NOTIFY' => 'Notify me upon replies by default', - 'DEFAULT_SMILIES' => 'Enable smilies by default', - 'DEFINED_RULES' => 'Defined rules', - 'DELETED_TOPIC' => 'Topic has been removed.', - 'DELETE_ATTACHMENT' => 'Delete attachment', - 'DELETE_ATTACHMENTS' => 'Delete attachments', - 'DELETE_ATTACHMENT_CONFIRM' => 'Are you sure you want to delete this attachment?', - 'DELETE_ATTACHMENTS_CONFIRM'=> 'Are you sure you want to delete these attachments?', - 'DELETE_AVATAR' => 'Delete image', - 'DELETE_COOKIES_CONFIRM' => 'Are you sure you want to delete all cookies set by this board?', - 'DELETE_MARKED_PM' => 'Delete marked messages', - 'DELETE_MARKED_PM_CONFIRM' => 'Are you sure you want to delete all marked messages?', - 'DELETE_OLDEST_MESSAGES' => 'Delete oldest messages', - 'DELETE_MESSAGE' => 'Delete message', - 'DELETE_MESSAGE_CONFIRM' => 'Are you sure you want to delete this private message?', - 'DELETE_MESSAGES_IN_FOLDER' => 'Delete all messages within removed folder', - 'DELETE_RULE' => 'Delete rule', - 'DELETE_RULE_CONFIRM' => 'Are you sure you want to delete this rule?', - 'DEMOTE_SELECTED' => 'Demote selected', - 'DISABLE_CENSORS' => 'Enable word censoring', - 'DISPLAY_GALLERY' => 'Display gallery', - 'DOMAIN_NO_MX_RECORD_EMAIL' => 'The entered email domain has no valid MX record.', - 'DOWNLOADS' => 'Downloads', - 'DRAFTS_DELETED' => 'All selected drafts were successfully deleted.', - 'DRAFTS_EXPLAIN' => 'Here you can view, edit and delete your saved drafts.', - 'DRAFT_UPDATED' => 'Draft successfully updated.', - - 'EDIT_DRAFT_EXPLAIN' => 'Here you are able to edit your draft. Drafts do not contain attachment and poll information.', - 'EMAIL_BANNED_EMAIL' => 'The email address you entered is not allowed to be used.', - 'EMAIL_REMIND' => 'This must be the email address associated with your account. If you have not changed this via your user control panel then it is the email address you registered your account with.', - 'EMAIL_TAKEN_EMAIL' => 'The entered email address is already in use.', - 'EMPTY_DRAFT' => 'You must enter a message to submit your changes.', - 'EMPTY_DRAFT_TITLE' => 'You must enter a draft title.', - 'EXPORT_AS_XML' => 'Export as XML', - 'EXPORT_AS_CSV' => 'Export as CSV', - 'EXPORT_AS_CSV_EXCEL' => 'Export as CSV (Excel)', - 'EXPORT_AS_TXT' => 'Export as TXT', - 'EXPORT_AS_MSG' => 'Export as MSG', - 'EXPORT_FOLDER' => 'Export this view', - - 'FIELD_REQUIRED' => 'The field “%s” must be completed.', - 'FIELD_TOO_SHORT' => array( - 1 => 'The field “%2$s” is too short, a minimum of %1$d character is required.', - 2 => 'The field “%2$s” is too short, a minimum of %1$d characters is required.', - ), - 'FIELD_TOO_LONG' => array( - 1 => 'The field “%2$s” is too long, a maximum of %1$d character is allowed.', - 2 => 'The field “%2$s” is too long, a maximum of %1$d characters is allowed.', - ), - 'FIELD_TOO_SMALL' => 'The value of “%2$s” is too small, a minimum value of %1$d is required.', - 'FIELD_TOO_LARGE' => 'The value of “%2$s” is too large, a maximum value of %1$d is allowed.', - 'FIELD_INVALID_CHARS_INVALID' => 'The field “%s” has invalid characters.', - 'FIELD_INVALID_CHARS_NUMBERS_ONLY' => 'The field “%s” has invalid characters, only numbers are allowed.', - 'FIELD_INVALID_CHARS_ALPHA_DOTS' => 'The field “%s” has invalid characters, only alphanumeric or . characters are allowed.', - 'FIELD_INVALID_CHARS_ALPHA_ONLY' => 'The field “%s” has invalid characters, only alphanumeric characters are allowed.', - 'FIELD_INVALID_CHARS_ALPHA_PUNCTUATION' => 'The field “%s” has invalid characters, only alphanumeric or _,-. characters are allowed and the first character must be alphabetic.', - 'FIELD_INVALID_CHARS_ALPHA_SPACERS' => 'The field “%s” has invalid characters, only alphanumeric, space or -+_[] characters are allowed.', - 'FIELD_INVALID_CHARS_ALPHA_UNDERSCORE' => 'The field “%s” has invalid characters, only alphanumeric or _ characters are allowed.', - 'FIELD_INVALID_CHARS_LETTER_NUM_DOTS' => 'The field “%s” has invalid characters, only letter, number or . characters are allowed.', - 'FIELD_INVALID_CHARS_LETTER_NUM_ONLY' => 'The field “%s” has invalid characters, only letter and number characters are allowed.', - 'FIELD_INVALID_CHARS_LETTER_NUM_PUNCTUATION' => 'The field “%s” has invalid characters, only letter, number or _,-. characters are allowed and the first character must be alphabetic.', - 'FIELD_INVALID_CHARS_LETTER_NUM_SPACERS' => 'The field “%s” has invalid characters, only letter, number, space or -+_[] characters are allowed.', - 'FIELD_INVALID_CHARS_LETTER_NUM_UNDERSCORE' => 'The field “%s” has invalid characters, only letter, number or _ characters are allowed.', - 'FIELD_INVALID_DATE' => 'The field “%s” has an invalid date.', - 'FIELD_INVALID_URL' => 'The field “%s” has an invalid url.', - 'FIELD_INVALID_VALUE' => 'The field “%s” has an invalid value.', - - 'FOE_MESSAGE' => 'Message from foe', - 'FOES_EXPLAIN' => 'Foes are users which will be ignored by default. Posts by these users will not be fully visible. Personal messages from foes are still permitted. Please note that you cannot ignore moderators or administrators.', - 'FOES_UPDATED' => 'Your foes list has been updated successfully.', - 'FOLDER_ADDED' => 'Folder successfully added.', - 'FOLDER_MESSAGE_STATUS' => array( - 1 => '%2$d out of %1$s stored', - 2 => '%2$d out of %1$s stored', - ), - 'FOLDER_NAME_EMPTY' => 'You must enter a name for this folder.', - 'FOLDER_NAME_EXIST' => 'Folder %s already exists.', - 'FOLDER_OPTIONS' => 'Folder options', - 'FOLDER_RENAMED' => 'Folder successfully renamed.', - 'FOLDER_REMOVED' => 'Folder successfully removed.', - 'FOLDER_STATUS_MSG' => array( - 1 => 'Folder is %3$d%% full (%2$d out of %1$s stored)', - 2 => 'Folder is %3$d%% full (%2$d out of %1$s stored)', - ), - 'FORWARD_PM' => 'Forward PM', - 'FORCE_PASSWORD_EXPLAIN' => 'Before you may continue browsing the board you are required to change your password.', - 'FRIEND_MESSAGE' => 'Message from friend', - 'FRIENDS' => 'Friends', - 'FRIENDS_EXPLAIN' => 'Friends enable you quick access to members you communicate with frequently. If the template has relevant support any posts made by a friend may be highlighted.', - 'FRIENDS_OFFLINE' => 'Offline', - 'FRIENDS_ONLINE' => 'Online', - 'FRIENDS_UPDATED' => 'Your friends list has been updated successfully.', - 'FULL_FOLDER_OPTION_CHANGED'=> 'The action to take when a folder is full has been changed successfully.', - 'FWD_ORIGINAL_MESSAGE' => '-------- Original Message --------', - 'FWD_SUBJECT' => 'Subject: %s', - 'FWD_DATE' => 'Date: %s', - 'FWD_FROM' => 'From: %s', - 'FWD_TO' => 'To: %s', - - 'GLOBAL_ANNOUNCEMENT' => 'Global announcement', - - 'GRAVATAR_AVATAR_EMAIL' => 'Gravatar email', - 'GRAVATAR_AVATAR_EMAIL_EXPLAIN' => 'Enter the email address you used for registering your account on Gravatar.', - 'GRAVATAR_AVATAR_SIZE' => 'Avatar dimensions', - 'GRAVATAR_AVATAR_SIZE_EXPLAIN' => 'Specify the width and height of the avatar, leave blank to attempt automatic verification.', - - 'HIDE_ONLINE' => 'Hide my online status', - 'HIDE_ONLINE_EXPLAIN' => 'Changing this setting won’t become effective until your next visit to the board.', - 'HOLD_NEW_MESSAGES' => 'Do not accept new messages (New messages will be held back until enough space is available)', - 'HOLD_NEW_MESSAGES_SHORT' => 'New messages will be held back', - - 'IF_FOLDER_FULL' => 'If folder is full', - 'IMPORTANT_NEWS' => 'Important announcements', - 'INVALID_USER_BIRTHDAY' => 'The entered birthday is not a valid date.', - 'INVALID_CHARS_USERNAME' => 'The username contains forbidden characters.', - 'INVALID_EMOJIS_USERNAME' => 'The username contains forbidden characters (Emoji).', - 'INVALID_CHARS_NEW_PASSWORD'=> 'The password does not contain the required characters.', - 'ITEMS_REQUIRED' => 'The items marked with * are required profile fields and need to be filled out.', - - 'JOIN_SELECTED' => 'Join selected', - - 'LANGUAGE' => 'Language', - 'LINK_REMOTE_AVATAR' => 'Link off-site', - 'LINK_REMOTE_AVATAR_EXPLAIN'=> 'Enter the URL of the location containing the avatar image you wish to link to.', - 'LINK_REMOTE_SIZE' => 'Avatar dimensions', - 'LINK_REMOTE_SIZE_EXPLAIN' => 'Specify the width and height of the avatar, leave blank to attempt automatic verification.', - 'LOGIN_EXPLAIN_UCP' => 'Please login in order to access the User Control Panel.', - 'LOGIN_LINK' => 'Link or register your account on an external service with your board account', - 'LOGIN_LINK_EXPLAIN' => 'You have attempted to login with an external service that is not yet connected to an account on this board. You must now either link this account to an existing account or create a new account.', - 'LOGIN_LINK_MISSING_DATA' => 'Data that is necessary to link your account with an external service is not available. Please restart the login process.', - 'LOGIN_LINK_NO_DATA_PROVIDED' => 'No data has been provided to this page to link an external account to a forum account. Please contact the board administrator if you continue to experience problems.', - 'LOGIN_KEY' => 'Login Key', - 'LOGIN_TIME' => 'Login Time', - 'LOGIN_REDIRECT' => 'You have been successfully logged in.', - 'LOGOUT_FAILED' => 'You were not logged out, as the request did not match your session. Please contact the board administrator if you continue to experience problems.', - 'LOGOUT_REDIRECT' => 'You have been successfully logged out.', - - 'MARK_IMPORTANT' => 'Mark/Unmark as important', - 'MARKED_MESSAGE' => 'Marked message', - 'MAX_FOLDER_REACHED' => 'Maximum number of allowed user defined folders reached.', - 'MESSAGE_BY_AUTHOR' => 'by', - 'MESSAGE_COLOURS' => 'Message colours', - 'MESSAGE_DELETED' => 'Message successfully deleted.', - 'MESSAGE_EDITED' => 'Message successfully edited.', - 'MESSAGE_HISTORY' => 'Message history', - 'MESSAGE_REMOVED_FROM_OUTBOX' => 'This message was deleted by its author.', - 'MESSAGE_REPORTED_MESSAGE' => 'Reported message', - 'MESSAGE_SENT_ON' => 'on', - 'MESSAGE_STORED' => 'This message has been sent successfully.', - 'MESSAGE_TO' => 'To', - 'MESSAGES_DELETED' => 'Messages successfully deleted', - 'MOVE_DELETED_MESSAGES_TO' => 'Move messages from removed folder to', - 'MOVE_DOWN' => 'Move down', - 'MOVE_MARKED_TO_FOLDER' => 'Move marked to %s', - 'MOVE_PM_ERROR' => array( - 1 => 'An error occurred while moving the messages to the new folder, only %2$d out of %1$s was moved.', - 2 => 'An error occurred while moving the messages to the new folder, only %2$d out of %1$s were moved.', - ), - 'MOVE_TO_FOLDER' => 'Move to folder', - 'MOVE_UP' => 'Move up', - - 'NEW_FOLDER_NAME' => 'New folder name', - 'NEW_PASSWORD' => 'New password', - 'NEW_PASSWORD_CONFIRM_EMPTY' => 'You did not enter a confirm password.', - 'NEW_PASSWORD_ERROR' => 'The passwords you entered do not match.', - - 'NOTIFICATIONS_MARK_ALL_READ' => 'Mark all notifications read', - 'NOTIFICATIONS_MARK_ALL_READ_CONFIRM' => 'Are you sure you want to mark all notifications read?', - 'NOTIFICATIONS_MARK_ALL_READ_SUCCESS' => 'All notifications have been marked read.', - 'NOTIFICATION_GROUP_MISCELLANEOUS' => 'Miscellaneous Notifications', - 'NOTIFICATION_GROUP_MODERATION' => 'Moderation Notifications', - 'NOTIFICATION_GROUP_ADMINISTRATION' => 'Administration Notifications', - 'NOTIFICATION_GROUP_POSTING' => 'Posting Notifications', - 'NOTIFICATION_METHOD_BOARD' => 'Notifications', - 'NOTIFICATION_METHOD_EMAIL' => 'Email', - 'NOTIFICATION_METHOD_JABBER' => 'Jabber', - 'NOTIFICATION_TYPE' => 'Notification type', - 'NOTIFICATION_TYPE_BOOKMARK' => 'Someone replies to a topic you have bookmarked', - 'NOTIFICATION_TYPE_GROUP_REQUEST' => 'Someone requests to join a group you lead', - 'NOTIFICATION_TYPE_IN_MODERATION_QUEUE' => 'A post or topic needs approval', - 'NOTIFICATION_TYPE_MODERATION_QUEUE' => 'Your topics/posts are approved or disapproved by a moderator', - 'NOTIFICATION_TYPE_PM' => 'Someone sends you a private message', - 'NOTIFICATION_TYPE_POST' => 'Someone replies to a topic to which you are subscribed', - 'NOTIFICATION_TYPE_QUOTE' => 'Someone quotes you in a post', - 'NOTIFICATION_TYPE_REPORT' => 'Someone reports a post', - 'NOTIFICATION_TYPE_TOPIC' => 'Someone creates a topic in a forum to which you are subscribed', - 'NOTIFICATION_TYPE_ADMIN_ACTIVATE_USER' => 'User requiring activation', - - 'NOTIFY_METHOD' => 'Notification method', - 'NOTIFY_METHOD_BOTH' => 'Both', - 'NOTIFY_METHOD_EMAIL' => 'Email only', - 'NOTIFY_METHOD_EXPLAIN' => 'Method for sending messages sent via this board.', - 'NOTIFY_METHOD_IM' => 'Jabber only', - 'NOTIFY_ON_PM' => 'Notify me on new private messages', - 'NOT_ADDED_FRIENDS_ANONYMOUS' => 'You cannot add the anonymous user to your friends list.', - 'NOT_ADDED_FRIENDS_BOTS' => 'You cannot add bots to your friends list.', - 'NOT_ADDED_FRIENDS_FOES' => 'You cannot add users to your friends list who are on your foes list.', - 'NOT_ADDED_FRIENDS_SELF' => 'You cannot add yourself to the friends list.', - 'NOT_ADDED_FOES_MOD_ADMIN' => 'You cannot add administrators and moderators to your foes list.', - 'NOT_ADDED_FOES_ANONYMOUS' => 'You cannot add the anonymous user to your foes list.', - 'NOT_ADDED_FOES_BOTS' => 'You cannot add bots to your foes list.', - 'NOT_ADDED_FOES_FRIENDS' => 'You cannot add users to your foes list who are on your friends list.', - 'NOT_ADDED_FOES_SELF' => 'You cannot add yourself to the foes list.', - 'NOT_AGREE' => 'I do not agree to these terms', - 'NOT_ENOUGH_SPACE_FOLDER' => 'The destination folder “%s” seems to be full. The requested action has not been taken.', - 'NOT_MOVED_MESSAGES' => array( - 1 => 'You have %d private message currently on hold because of full folder.', - 2 => 'You have %d private messages currently on hold because of full folder.', - ), - 'NO_ACTION_MODE' => 'No message action specified.', - 'NO_AUTHOR' => 'No author defined for this message', - 'NO_AVATAR' => 'No avatar selected', - 'NO_AVATAR_CATEGORY' => 'None', - - 'NO_AUTH_DELETE_MESSAGE' => 'You are not authorised to delete private messages.', - 'NO_AUTH_EDIT_MESSAGE' => 'You are not authorised to edit private messages.', - 'NO_AUTH_FORWARD_MESSAGE' => 'You are not authorised to forward private messages.', - 'NO_AUTH_GROUP_MESSAGE' => 'You are not authorised to send private messages to groups.', - 'NO_AUTH_PROFILEINFO' => 'You are not authorised to change your profile information.', - 'NO_AUTH_READ_HOLD_MESSAGE' => 'You are not authorised to read private messages that are on hold.', - 'NO_AUTH_READ_MESSAGE' => 'You are not authorised to read private messages.', - 'NO_AUTH_PRINT_MESSAGE' => 'You are not authorised to print private messages.', - 'NO_AUTH_READ_REMOVED_MESSAGE' => 'You are not able to read this message because it was removed by the author.', - 'NO_AUTH_SEND_MESSAGE' => 'You are not authorised to send private messages.', - 'NO_AUTH_SIGNATURE' => 'You are not authorised to define a signature.', - - 'NO_BCC_RECIPIENT' => 'None', - 'NO_BOOKMARKS' => 'You have no bookmarks.', - 'NO_BOOKMARKS_SELECTED' => 'You have selected no bookmarks.', - 'NO_EDIT_READ_MESSAGE' => 'Private message cannot be edited because it has already been read.', - 'NO_EMAIL_USER' => 'The email/username information submitted could not be found.', - 'EMAIL_NOT_UNIQUE' => 'Email you specified is used by multiple users. You must specify username as well.', - 'NO_FOES' => 'No foes currently defined', - 'NO_FRIENDS' => 'No friends currently defined', - 'NO_FRIENDS_OFFLINE' => 'No friends offline', - 'NO_FRIENDS_ONLINE' => 'No friends online', - 'NO_GROUP_SELECTED' => 'No group specified.', - 'NO_IMPORTANT_NEWS' => 'No important announcements present.', - 'NO_MESSAGE' => 'Private message could not be found.', - 'NO_NEW_FOLDER_NAME' => 'You have to specify a new folder name.', - 'NO_NEWER_PM' => 'No newer messages.', - 'NO_OLDER_PM' => 'No older messages.', - 'NO_PASSWORD_SUPPLIED' => 'You cannot login without a password.', - 'NO_RECIPIENT' => 'No recipient defined.', - 'NO_RULES_DEFINED' => 'No rules defined.', - 'NO_SAVED_DRAFTS' => 'No drafts saved.', - 'NO_TO_RECIPIENT' => 'None', - 'NO_WATCHED_FORUMS' => 'You are not subscribed to any forums.', - 'NO_WATCHED_SELECTED' => 'You have not selected any subscribed topics or forums.', - 'NO_WATCHED_TOPICS' => 'You are not subscribed to any topics.', - - 'PASS_TYPE_ALPHA_EXPLAIN' => 'Password must be between %1$s and %2$s long, must contain letters in mixed case and must contain numbers.', - 'PASS_TYPE_ANY_EXPLAIN' => 'Must be between %1$s and %2$s.', - 'PASS_TYPE_CASE_EXPLAIN' => 'Password must be between %1$s and %2$s long and must contain letters in mixed case.', - 'PASS_TYPE_SYMBOL_EXPLAIN' => 'Password must be between %1$s and %2$s long, must contain letters in mixed case, must contain numbers and must contain symbols.', - 'PASSWORD' => 'Password', - 'PASSWORD_ACTIVATED' => 'Your new password has been activated.', - 'PASSWORD_UPDATED_IF_EXISTED' => 'If your account exists, a new password was sent to your registered email address. If you do not receive an email, it may be because you are banned, your account is not activated, or you are not allowed to change your password. Contact admin if any of those reasons apply. Also, check your spam filter.', - 'PERMISSIONS_RESTORED' => 'Successfully restored original permissions.', - 'PERMISSIONS_TRANSFERRED' => 'Successfully transferred permissions from %s, you are now able to browse the board with this user’s permissions.
Please note that admin permissions were not transferred. You are able to revert to your permission set at any time.', - 'PM_DISABLED' => 'Private messaging has been disabled on this board.', - 'PM_FROM' => 'From', - 'PM_FROM_REMOVED_AUTHOR' => 'This message was sent by a user no longer registered.', - 'PM_ICON' => 'PM icon', - 'PM_INBOX' => 'Inbox', - 'PM_MARK_ALL_READ' => 'Mark all messages read', - 'PM_MARK_ALL_READ_SUCCESS' => 'All private messages in this folder have been marked read', - 'PM_NO_USERS' => 'The requested users to be added do not exist.', - 'PM_OUTBOX' => 'Outbox', - 'PM_SENTBOX' => 'Sent messages', - 'PM_SUBJECT' => 'Message subject', - 'PM_TO' => 'Send to', - 'PM_TOOLS' => 'Message tools', - 'PM_USERS_REMOVED_NO_PERMISSION' => 'Some users couldn’t be added as they do not have permission to read private messages.', - 'PM_USERS_REMOVED_NO_PM' => 'Some users couldn’t be added as they have disabled private message receipt.', - 'POST_EDIT_PM' => 'Edit message', - 'POST_FORWARD_PM' => 'Forward message', - 'POST_NEW_PM' => 'Compose message', - 'POST_PM_LOCKED' => 'Private messaging is locked.', - 'POST_PM_POST' => 'Quote post', - 'POST_QUOTE_PM' => 'Quote message', - 'POST_REPLY_PM' => 'Reply to message', - 'PRINT_PM' => 'Print view', - 'PREFERENCES_UPDATED' => 'Your preferences have been updated.', - 'PROFILE_INFO_NOTICE' => 'Please note that this information may be viewable to other members. Be careful when including any personal details. Any fields marked with a * must be completed.', - 'PROFILE_UPDATED' => 'Your profile has been updated.', - 'PROFILE_AUTOLOGIN_KEYS' => 'The "Remember Me" login keys automatically log you in when you visit the board. If you logout, the remember me login key is deleted only on the computer you are using to logout. Here you can see remember login keys created on other computers you used to access this site.', - 'PROFILE_NO_AUTOLOGIN_KEYS' => 'There are no saved "Remember Me" login keys.', - - 'RECIPIENT' => 'Recipient', - 'RECIPIENTS' => 'Recipients', - 'REGISTRATION' => 'Registration', - 'RELEASE_MESSAGES' => '%sRelease all on-hold messages%s… they will be re-sorted into the appropriate folder if enough space is made available.', - 'REMOVE_ADDRESS' => 'Remove address', - 'REMOVE_SELECTED_BOOKMARKS' => 'Remove selected bookmarks', - 'REMOVE_SELECTED_BOOKMARKS_CONFIRM' => 'Are you sure you want to delete all selected bookmarks?', - 'REMOVE_BOOKMARK_MARKED' => 'Remove marked bookmarks', - 'REMOVE_FOLDER' => 'Remove folder', - 'REMOVE_FOLDER_CONFIRM' => 'Are you sure you want to remove this folder?', - 'RENAME' => 'Rename', - 'RENAME_FOLDER' => 'Rename folder', - 'REPLIED_MESSAGE' => 'Replied to message', - 'REPLY_TO_ALL' => 'Reply to sender and all recipients.', - 'REPORT_PM' => 'Report private message', - 'RESIGN_SELECTED' => 'Resign selected', - 'RETURN_FOLDER' => '%1$sReturn to previous folder%2$s', - 'RETURN_UCP' => '%sReturn to the User Control Panel%s', - 'RULE_ADDED' => 'Rule successfully added.', - 'RULE_ALREADY_DEFINED' => 'This rule was defined previously.', - 'RULE_DELETED' => 'Rule successfully removed.', - 'RULE_LIMIT_REACHED' => 'You cannot add more PM rules. You have reached the maximum number of rules.', - 'RULE_NOT_DEFINED' => 'Rule not correctly specified.', - 'RULE_REMOVED_MESSAGES' => array( - 1 => '%d private message was removed due to private message filters.', - 2 => '%d private messages were removed due to private message filters.', - ), - - 'SAME_PASSWORD_ERROR' => 'The new password you entered is the same as your current password.', - 'SEARCH_YOUR_POSTS' => 'Show your posts', - 'SEND_PASSWORD' => 'Send password', - 'SENT_AT' => 'Sent', // Used before dates in private messages - 'SHOW_EMAIL' => 'Users can contact me by email', - 'SIGNATURE_EXPLAIN' => 'This is a block of text that can be added to posts you make. There is a %d character limit.', - 'SIGNATURE_PREVIEW' => 'Your signature will appear like this in posts', - 'SIGNATURE_TOO_LONG' => 'Your signature is too long.', - 'SELECT_CURRENT_TIME' => 'Select current time', - 'SELECT_TIMEZONE' => 'Select timezone', - 'SORT' => 'Sort', - 'SORT_COMMENT' => 'File comment', - 'SORT_DOWNLOADS' => 'Downloads', - 'SORT_EXTENSION' => 'Extension', - 'SORT_FILENAME' => 'Filename', - 'SORT_POST_TIME' => 'Post time', - 'SORT_SIZE' => 'File size', - - 'TIMEZONE' => 'Timezone', - 'TIMEZONE_DATE_SUGGESTION' => 'Suggestion: %s', - 'TIMEZONE_INVALID' => 'The timezone you selected is invalid.', - 'TO' => 'Recipient', - 'TO_MASS' => 'Recipients', - 'TO_ADD' => 'Add recipient', - 'TO_ADD_MASS' => 'Add recipients', - 'TO_ADD_GROUPS' => 'Add groups', - 'TOO_MANY_RECIPIENTS' => 'You tried to send a private message to too many recipients.', - 'TOO_MANY_REGISTERS' => 'You have exceeded the maximum number of registration attempts for this session. Please try again later.', - - 'UCP' => 'User Control Panel', - 'UCP_ACTIVATE' => 'Activate account', - 'UCP_ADMIN_ACTIVATE' => 'Please note that you will need to enter a valid email address before your account is activated. The administrator will review your account and if approved you will receive an email at the address you specified.', - 'UCP_ATTACHMENTS' => 'Attachments', - 'UCP_AUTH_LINK' => 'External accounts', - 'UCP_AUTH_LINK_ASK' => 'You currently have no account associated with this external service. Click the button below to link your board account to an account with this external service.', - 'UCP_AUTH_LINK_ID' => 'Unique identifier', - 'UCP_AUTH_LINK_LINK' => 'Link', - 'UCP_AUTH_LINK_MANAGE' => 'Manage external account associations', - 'UCP_AUTH_LINK_NOT_SUPPORTED' => 'Linking board accounts to external services is not supported by this board’s current authentication method.', - 'UCP_AUTH_LINK_TITLE' => 'Manage your external account associations', - 'UCP_AUTH_LINK_UNLINK' => 'Unlink', - 'UCP_COPPA_BEFORE' => 'Before %s', - 'UCP_COPPA_ON_AFTER' => 'On or after %s', - 'UCP_EMAIL_ACTIVATE' => 'Please note that you will need to enter a valid email address before your account is activated. You will receive an email at the address you provide that contains an account activation link.', - 'UCP_JABBER' => 'Jabber address', - 'UCP_LOGIN_LINK' => 'Set up an external account association', - - 'UCP_MAIN' => 'Overview', - 'UCP_MAIN_ATTACHMENTS' => 'Manage attachments', - 'UCP_MAIN_BOOKMARKS' => 'Manage bookmarks', - 'UCP_MAIN_DRAFTS' => 'Manage drafts', - 'UCP_MAIN_FRONT' => 'Front page', - 'UCP_MAIN_SUBSCRIBED' => 'Manage subscriptions', - - 'UCP_NO_ATTACHMENTS' => 'You have posted no files.', - - 'UCP_NOTIFICATION_LIST' => 'Manage notifications', - 'UCP_NOTIFICATION_LIST_EXPLAIN' => 'Here you may view all past notifications.', - 'UCP_NOTIFICATION_OPTIONS' => 'Edit notification options', - 'UCP_NOTIFICATION_OPTIONS_EXPLAIN' => 'Here you can set your preferred notification methods for the board.', - - 'UCP_PREFS' => 'Board preferences', - 'UCP_PREFS_PERSONAL' => 'Edit global settings', - 'UCP_PREFS_POST' => 'Edit posting defaults', - 'UCP_PREFS_VIEW' => 'Edit display options', - - 'UCP_PM' => 'Private messages', - 'UCP_PM_COMPOSE' => 'Compose message', - 'UCP_PM_DRAFTS' => 'Manage PM drafts', - 'UCP_PM_OPTIONS' => 'Rules, folders & settings', - 'UCP_PM_UNREAD' => 'Unread messages', - 'UCP_PM_VIEW' => 'View messages', - - 'UCP_PROFILE' => 'Profile', - 'UCP_PROFILE_AVATAR' => 'Edit avatar', - 'UCP_PROFILE_PROFILE_INFO' => 'Edit profile', - 'UCP_PROFILE_REG_DETAILS' => 'Edit account settings', - 'UCP_PROFILE_SIGNATURE' => 'Edit signature', - 'UCP_PROFILE_AUTOLOGIN_KEYS'=> 'Manage “Remember Me” login keys', - - 'UCP_USERGROUPS' => 'Usergroups', - 'UCP_USERGROUPS_MEMBER' => 'Edit memberships', - 'UCP_USERGROUPS_MANAGE' => 'Manage groups', - - 'UCP_PASSWORD_RESET_DISABLED' => 'The password reset functionality has been disabled. If you need help accessing your account, please contact the %sBoard Administrator%s', - 'UCP_REGISTER_DISABLE' => 'Creating a new account is currently not possible.', - 'UCP_REMIND' => 'Send password', - 'UCP_RESEND' => 'Send activation email', - 'UCP_WELCOME' => 'Welcome to the User Control Panel. From here you can monitor, view and update your profile, preferences, subscribed forums and topics. You can also send messages to other users (if permitted). Please ensure you read any announcements before continuing.', - 'UCP_ZEBRA' => 'Friends & Foes', - 'UCP_ZEBRA_FOES' => 'Manage foes', - 'UCP_ZEBRA_FRIENDS' => 'Manage friends', - 'UNDISCLOSED_RECIPIENT' => 'Undisclosed Recipient', - 'UNKNOWN_FOLDER' => 'Unknown folder', - 'UNWATCH_MARKED' => 'Unwatch marked', - 'UPLOAD_AVATAR_FILE' => 'Upload from your machine', - 'UPLOAD_AVATAR_URL' => 'Upload from a URL', - 'UPLOAD_AVATAR_URL_EXPLAIN' => 'Enter the URL of the location containing the image. The image will be copied to this site.', - 'USERNAME_ALPHA_ONLY_EXPLAIN' => 'Username must be between %1$s and %2$s long and use only alphanumeric characters.', - 'USERNAME_ALPHA_SPACERS_EXPLAIN'=> 'Username must be between %1$s and %2$s long and use alphanumeric, space or -+_[] characters.', - 'USERNAME_ASCII_EXPLAIN' => 'Username must be between %1$s and %2$s long and use only ASCII characters, so no special symbols.', - 'USERNAME_LETTER_NUM_EXPLAIN' => 'Username must be between %1$s and %2$s long and use only letter or number characters.', - 'USERNAME_LETTER_NUM_SPACERS_EXPLAIN'=> 'Username must be between %1$s and %2$s long and use letter, number, space or -+_[] characters.', - 'USERNAME_CHARS_ANY_EXPLAIN' => 'Length must be between %1$s and %2$s.', - 'USERNAME_TAKEN_USERNAME' => 'The username you entered is already in use, please select an alternative.', - 'USERNAME_DISALLOWED_USERNAME' => 'The username you entered has been disallowed or contains a disallowed word. Please choose a different name.', - 'USER_NOT_FOUND_OR_INACTIVE' => 'The usernames you specified could either not be found or are not activated users.', - - 'VIEW_AVATARS' => 'Display avatars', - 'VIEW_EDIT' => 'View/Edit', - 'VIEW_FLASH' => 'Display Flash animations', - 'VIEW_IMAGES' => 'Display images within posts', - 'VIEW_NEXT_HISTORY' => 'Next PM in history', - 'VIEW_NEXT_PM' => 'Next PM', - 'VIEW_PM' => 'View message', - 'VIEW_PM_INFO' => 'Message details', - 'VIEW_PM_MESSAGES' => array( - 1 => '%d message', - 2 => '%d messages', - ), - 'VIEW_PREVIOUS_HISTORY' => 'Previous PM in history', - 'VIEW_PREVIOUS_PM' => 'Previous PM', - 'VIEW_PROFILE' => 'View profile', - 'VIEW_SIGS' => 'Display signatures', - 'VIEW_SMILIES' => 'Display smilies as images', - 'VIEW_TOPICS_DAYS' => 'Display topics from previous days', - 'VIEW_TOPICS_DIR' => 'Display topic order direction', - 'VIEW_TOPICS_KEY' => 'Display topics ordering by', - 'VIEW_POSTS_DAYS' => 'Display posts from previous days', - 'VIEW_POSTS_DIR' => 'Display post order direction', - 'VIEW_POSTS_KEY' => 'Display posts ordering by', - - 'WATCHED_EXPLAIN' => 'Below is a list of forums and topics you are subscribed to. You will be notified of new posts in either. To unsubscribe mark the forum or topic and then press the Unwatch marked button.', - 'WATCHED_FORUMS' => 'Watched forums', - 'WATCHED_TOPICS' => 'Watched topics', - 'WRONG_ACTIVATION' => 'The activation key you supplied does not match any in the database.', - - 'YOUR_DETAILS' => 'Your activity', - 'YOUR_FOES' => 'Your foes', - 'YOUR_FOES_EXPLAIN' => 'To remove usernames select them and click submit.', - 'YOUR_FRIENDS' => 'Your friends', - 'YOUR_FRIENDS_EXPLAIN' => 'To remove usernames select them and click submit.', - 'YOUR_WARNINGS' => 'Your warning level', - - 'PM_ACTION' => array( - 'PLACE_INTO_FOLDER' => 'Place into folder', - 'MARK_AS_READ' => 'Mark as read', - 'MARK_AS_IMPORTANT' => 'Mark message', - 'DELETE_MESSAGE' => 'Delete message', - ), - 'PM_CHECK' => array( - 'SUBJECT' => 'Subject', - 'SENDER' => 'Sender', - 'MESSAGE' => 'Message', - 'STATUS' => 'Message status', - 'TO' => 'Sent To', - ), - 'PM_RULE' => array( - 'IS_LIKE' => 'is like', - 'IS_NOT_LIKE' => 'is not like', - 'IS' => 'is', - 'IS_NOT' => 'is not', - 'BEGINS_WITH' => 'begins with', - 'ENDS_WITH' => 'ends with', - 'IS_FRIEND' => 'is friend', - 'IS_FOE' => 'is foe', - 'IS_USER' => 'is user', - 'IS_GROUP' => 'is in usergroup', - 'ANSWERED' => 'answered', - 'FORWARDED' => 'forwarded', - 'TO_GROUP' => 'to my default usergroup', - 'TO_ME' => 'to me', - ), - - 'GROUPS_EXPLAIN' => 'Usergroups enable board admins to better administer users. By default you will be placed in a specific group, this is your default group. This group defines how you may appear to other users, for example your username colouration, avatar, rank, etc. Depending on whether the administrator allows it you may be allowed to change your default group. You may also be placed in or allowed to join other groups. Some groups may give you additional permissions to view content or increase your capabilities in other areas.', - 'GROUP_LEADER' => 'Leaderships', - 'GROUP_MEMBER' => 'Memberships', - 'GROUP_PENDING' => 'Pending memberships', - 'GROUP_NONMEMBER' => 'Non-memberships', - 'GROUP_DETAILS' => 'Group details', - - 'NO_LEADER' => 'No group leaderships', - 'NO_MEMBER' => 'No group memberships', - 'NO_PENDING' => 'No pending memberships', - 'NO_NONMEMBER' => 'No non-member groups', -)); diff --git a/install/update/old/mcp.php b/install/update/old/mcp.php deleted file mode 100644 index c4a8a66..0000000 --- a/install/update/old/mcp.php +++ /dev/null @@ -1,326 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -define('IN_PHPBB', true); -$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); -include($phpbb_root_path . 'common.' . $phpEx); -include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); -include($phpbb_root_path . 'includes/functions_mcp.' . $phpEx); -require($phpbb_root_path . 'includes/functions_module.' . $phpEx); - -// Start session management -$user->session_begin(); -$auth->acl($user->data); -$user->setup('mcp'); - -$module = new p_master(); - -// Setting a variable to let the style designer know where he is... -$template->assign_var('S_IN_MCP', true); - -// Basic parameter data -$id = $request->variable('i', ''); - -$mode = $request->variable('mode', array('')); -$mode = count($mode) ? array_shift($mode) : $request->variable('mode', ''); - -// Only Moderators can go beyond this point -if (!$user->data['is_registered']) -{ - if ($user->data['is_bot']) - { - redirect(append_sid("{$phpbb_root_path}index.$phpEx")); - } - - login_box('', $user->lang['LOGIN_EXPLAIN_MCP']); -} - -$quickmod = (isset($_REQUEST['quickmod'])) ? true : false; -$action = $request->variable('action', ''); -$action_ary = $request->variable('action', array('' => 0)); - -$forum_action = $request->variable('forum_action', ''); -if ($forum_action !== '' && $request->variable('sort', false, false, \phpbb\request\request_interface::POST)) -{ - $action = $forum_action; -} - -if (count($action_ary)) -{ - list($action, ) = each($action_ary); -} -unset($action_ary); - -if ($mode == 'topic_logs') -{ - $id = 'logs'; - $quickmod = false; -} - -$post_id = $request->variable('p', 0); -$topic_id = $request->variable('t', 0); -$forum_id = $request->variable('f', 0); -$report_id = $request->variable('r', 0); -$user_id = $request->variable('u', 0); -$username = $request->variable('username', '', true); - -if ($post_id) -{ - // We determine the topic and forum id here, to make sure the moderator really has moderative rights on this post - $sql = 'SELECT topic_id, forum_id - FROM ' . POSTS_TABLE . " - WHERE post_id = $post_id"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $topic_id = (int) $row['topic_id']; - $forum_id = (int) $row['forum_id']; -} -else if ($topic_id) -{ - $sql = 'SELECT forum_id - FROM ' . TOPICS_TABLE . " - WHERE topic_id = $topic_id"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $forum_id = (int) $row['forum_id']; -} - -// If the user doesn't have any moderator powers (globally or locally) he can't access the mcp -if (!$auth->acl_getf_global('m_')) -{ - // Except he is using one of the quickmod tools for users - $user_quickmod_actions = array( - 'lock' => 'f_user_lock', - 'make_sticky' => 'f_sticky', - 'make_announce' => 'f_announce', - 'make_global' => 'f_announce_global', - 'make_normal' => array('f_announce', 'f_announce_global', 'f_sticky') - ); - - $allow_user = false; - if ($quickmod && isset($user_quickmod_actions[$action]) && $user->data['is_registered'] && $auth->acl_gets($user_quickmod_actions[$action], $forum_id)) - { - $topic_info = phpbb_get_topic_data(array($topic_id)); - if ($topic_info[$topic_id]['topic_poster'] == $user->data['user_id']) - { - $allow_user = true; - } - } - - if (!$allow_user) - { - send_status_line(403, 'Forbidden'); - trigger_error('NOT_AUTHORISED'); - } -} - -// if the user cannot read the forum he tries to access then we won't allow mcp access either -if ($forum_id && !$auth->acl_get('f_read', $forum_id)) -{ - send_status_line(403, 'Forbidden'); - trigger_error('NOT_AUTHORISED'); -} - -/** -* Allow applying additional permissions to MCP access besides f_read -* -* @event core.mcp_global_f_read_auth_after -* @var string action The action the user tried to execute -* @var int forum_id The forum the user tried to access -* @var string mode The MCP module the user is trying to access -* @var p_master module Module system class -* @var bool quickmod True if the user is accessing using quickmod tools -* @var int topic_id The topic the user tried to access -* @since 3.1.3-RC1 -*/ -$vars = array( - 'action', - 'forum_id', - 'mode', - 'module', - 'quickmod', - 'topic_id', -); -extract($phpbb_dispatcher->trigger_event('core.mcp_global_f_read_auth_after', compact($vars))); - -if ($forum_id) -{ - $module->acl_forum_id = $forum_id; -} - -// Instantiate module system and generate list of available modules -$module->list_modules('mcp'); - -if ($quickmod) -{ - $mode = 'quickmod'; - - switch ($action) - { - case 'lock': - case 'unlock': - case 'lock_post': - case 'unlock_post': - case 'make_sticky': - case 'make_announce': - case 'make_global': - case 'make_normal': - case 'fork': - case 'move': - case 'delete_post': - case 'delete_topic': - case 'restore_topic': - $module->load('mcp', 'main', 'quickmod'); - return; - break; - - case 'topic_logs': - // Reset start parameter if we jumped from the quickmod dropdown - if ($request->variable('start', 0)) - { - $request->overwrite('start', 0); - } - - $module->set_active('logs', 'topic_logs'); - break; - - case 'merge_topic': - $module->set_active('main', 'forum_view'); - break; - - case 'split': - case 'merge': - $module->set_active('main', 'topic_view'); - break; - - default: - // If needed, the flag can be set to true within event listener - // to indicate that the action was handled properly - // and to pass by the trigger_error() call below - $is_valid_action = false; - - /** - * This event allows you to add custom quickmod options - * - * @event core.modify_quickmod_options - * @var object module Instance of module system class - * @var string action Quickmod option - * @var bool is_valid_action Flag indicating if the action was handled properly - * @since 3.1.0-a4 - */ - $vars = array('module', 'action', 'is_valid_action'); - extract($phpbb_dispatcher->trigger_event('core.modify_quickmod_options', compact($vars))); - - if (!$is_valid_action) - { - trigger_error($user->lang('QUICKMOD_ACTION_NOT_ALLOWED', $action), E_USER_ERROR); - } - break; - } -} -else -{ - // Select the active module - $module->set_active($id, $mode); -} - -// Hide some of the options if we don't have the relevant information to use them -if (!$post_id) -{ - $module->set_display('main', 'post_details', false); - $module->set_display('warn', 'warn_post', false); -} - -if ($mode == '' || $mode == 'unapproved_topics' || $mode == 'unapproved_posts' || $mode == 'deleted_topics' || $mode == 'deleted_posts') -{ - $module->set_display('queue', 'approve_details', false); -} - -if ($mode == '' || $mode == 'reports' || $mode == 'reports_closed' || $mode == 'pm_reports' || $mode == 'pm_reports_closed' || $mode == 'pm_report_details') -{ - $module->set_display('reports', 'report_details', false); -} - -if ($mode == '' || $mode == 'reports' || $mode == 'reports_closed' || $mode == 'pm_reports' || $mode == 'pm_reports_closed' || $mode == 'report_details') -{ - $module->set_display('pm_reports', 'pm_report_details', false); -} - -if (!$topic_id) -{ - $module->set_display('main', 'topic_view', false); - $module->set_display('logs', 'topic_logs', false); -} - -if (!$forum_id) -{ - $module->set_display('main', 'forum_view', false); - $module->set_display('logs', 'forum_logs', false); -} - -if (!$user_id && $username == '') -{ - $module->set_display('notes', 'user_notes', false); - $module->set_display('warn', 'warn_user', false); -} - -/** -* This event allows you to set display option for custom MCP modules -* -* @event core.modify_mcp_modules_display_option -* @var p_master module Module system class -* @var string mode MCP mode -* @var int user_id User id -* @var int forum_id Forum id -* @var int topic_id Topic id -* @var int post_id Post id -* @var string username User name -* @var int id Parent module id -* @since 3.1.0-b2 -*/ -$vars = array( - 'module', - 'mode', - 'user_id', - 'forum_id', - 'topic_id', - 'post_id', - 'username', - 'id', -); -extract($phpbb_dispatcher->trigger_event('core.modify_mcp_modules_display_option', compact($vars))); - -// Load and execute the relevant module -$module->load_active(); - -// Assign data to the template engine for the list of modules -$module->assign_tpl_vars(append_sid("{$phpbb_root_path}mcp.$phpEx")); - -// Generate urls for letting the moderation control panel being accessed in different modes -$template->assign_vars(array( - 'U_MCP' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main'), - 'U_MCP_FORUM' => ($forum_id) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&mode=forum_view&f=$forum_id") : '', - 'U_MCP_TOPIC' => ($forum_id && $topic_id) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&mode=topic_view&t=$topic_id") : '', - 'U_MCP_POST' => ($forum_id && $topic_id && $post_id) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&mode=post_details&t=$topic_id&p=$post_id") : '', -)); - -// Generate the page, do not display/query online list -$module->display($module->get_page_title()); diff --git a/install/update/old/memberlist.php b/install/update/old/memberlist.php deleted file mode 100644 index b26d7c8..0000000 --- a/install/update/old/memberlist.php +++ /dev/null @@ -1,1776 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -define('IN_PHPBB', true); -$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); -include($phpbb_root_path . 'common.' . $phpEx); -include($phpbb_root_path . 'includes/functions_display.' . $phpEx); - -$mode = $request->variable('mode', ''); - -if ($mode === 'contactadmin') -{ - define('SKIP_CHECK_BAN', true); - define('SKIP_CHECK_DISABLED', true); -} - -// Start session management -$user->session_begin(); -$auth->acl($user->data); -$user->setup(array('memberlist', 'groups')); - -// Setting a variable to let the style designer know where he is... -$template->assign_var('S_IN_MEMBERLIST', true); - -// Grab data -$action = $request->variable('action', ''); -$user_id = $request->variable('u', ANONYMOUS); -$username = $request->variable('un', '', true); -$group_id = $request->variable('g', 0); -$topic_id = $request->variable('t', 0); - -// Redirect when old mode is used -if ($mode == 'leaders') -{ - send_status_line(301, 'Moved Permanently'); - redirect(append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=team')); -} - -// Check our mode... -if (!in_array($mode, array('', 'group', 'viewprofile', 'email', 'contact', 'contactadmin', 'searchuser', 'team', 'livesearch'))) -{ - trigger_error('NO_MODE'); -} - -switch ($mode) -{ - case 'email': - case 'contactadmin': - break; - - case 'livesearch': - if (!$config['allow_live_searches']) - { - trigger_error('LIVE_SEARCHES_NOT_ALLOWED'); - } - // No break - - default: - // Can this user view profiles/memberlist? - if (!$auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel')) - { - if ($user->data['user_id'] != ANONYMOUS) - { - send_status_line(403, 'Forbidden'); - trigger_error('NO_VIEW_USERS'); - } - - login_box('', ((isset($user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)])) ? $user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)] : $user->lang['LOGIN_EXPLAIN_MEMBERLIST'])); - } - break; -} - -/** @var \phpbb\group\helper $group_helper */ -$group_helper = $phpbb_container->get('group_helper'); - -$start = $request->variable('start', 0); -$submit = (isset($_POST['submit'])) ? true : false; - -$default_key = 'c'; -$sort_key = $request->variable('sk', $default_key); -$sort_dir = $request->variable('sd', 'a'); - -$user_types = array(USER_NORMAL, USER_FOUNDER); -if ($auth->acl_get('a_user')) -{ - $user_types[] = USER_INACTIVE; -} - -// What do you want to do today? ... oops, I think that line is taken ... -switch ($mode) -{ - case 'team': - // Display a listing of board admins, moderators - if (!function_exists('user_get_id_name')) - { - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - } - - $page_title = $user->lang['THE_TEAM']; - $template_html = 'memberlist_team.html'; - - $sql = 'SELECT * - FROM ' . TEAMPAGE_TABLE . ' - ORDER BY teampage_position ASC'; - $result = $db->sql_query($sql, 3600); - $teampage_data = $db->sql_fetchrowset($result); - $db->sql_freeresult($result); - - $sql_ary = array( - 'SELECT' => 'g.group_id, g.group_name, g.group_colour, g.group_type, ug.user_id as ug_user_id, t.teampage_id', - - 'FROM' => array(GROUPS_TABLE => 'g'), - - 'LEFT_JOIN' => array( - array( - 'FROM' => array(TEAMPAGE_TABLE => 't'), - 'ON' => 't.group_id = g.group_id', - ), - array( - 'FROM' => array(USER_GROUP_TABLE => 'ug'), - 'ON' => 'ug.group_id = g.group_id AND ug.user_pending = 0 AND ug.user_id = ' . (int) $user->data['user_id'], - ), - ), - ); - - $result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary)); - - $group_ids = $groups_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - if ($row['group_type'] == GROUP_HIDDEN && !$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel') && $row['ug_user_id'] != $user->data['user_id']) - { - $row['group_name'] = $user->lang['GROUP_UNDISCLOSED']; - $row['u_group'] = ''; - } - else - { - $row['group_name'] = $group_helper->get_name($row['group_name']); - $row['u_group'] = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&g=' . $row['group_id']); - } - - if ($row['teampage_id']) - { - // Only put groups into the array we want to display. - // We are fetching all groups, to ensure we got all data for default groups. - $group_ids[] = (int) $row['group_id']; - } - $groups_ary[(int) $row['group_id']] = $row; - } - $db->sql_freeresult($result); - - $sql_ary = array( - 'SELECT' => 'u.user_id, u.group_id as default_group, u.username, u.username_clean, u.user_colour, u.user_type, u.user_rank, u.user_posts, u.user_allow_pm, g.group_id', - - 'FROM' => array( - USER_GROUP_TABLE => 'ug', - ), - - 'LEFT_JOIN' => array( - array( - 'FROM' => array(USERS_TABLE => 'u'), - 'ON' => 'ug.user_id = u.user_id', - ), - array( - 'FROM' => array(GROUPS_TABLE => 'g'), - 'ON' => 'ug.group_id = g.group_id', - ), - ), - - 'WHERE' => $db->sql_in_set('g.group_id', $group_ids, false, true) . ' AND ug.user_pending = 0', - - 'ORDER_BY' => 'u.username_clean ASC', - ); - - /** - * Modify the query used to get the users for the team page - * - * @event core.memberlist_team_modify_query - * @var array sql_ary Array containing the query - * @var array group_ids Array of group ids - * @var array teampage_data The teampage data - * @since 3.1.3-RC1 - */ - $vars = array( - 'sql_ary', - 'group_ids', - 'teampage_data', - ); - extract($phpbb_dispatcher->trigger_event('core.memberlist_team_modify_query', compact($vars))); - - $result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary)); - - $user_ary = $user_ids = $group_users = array(); - while ($row = $db->sql_fetchrow($result)) - { - $row['forums'] = ''; - $row['forums_ary'] = array(); - $user_ary[(int) $row['user_id']] = $row; - $user_ids[] = (int) $row['user_id']; - $group_users[(int) $row['group_id']][] = (int) $row['user_id']; - } - $db->sql_freeresult($result); - - $user_ids = array_unique($user_ids); - - if (!empty($user_ids) && $config['teampage_forums']) - { - $template->assign_var('S_DISPLAY_MODERATOR_FORUMS', true); - // Get all moderators - $perm_ary = $auth->acl_get_list($user_ids, array('m_'), false); - - foreach ($perm_ary as $forum_id => $forum_ary) - { - foreach ($forum_ary as $auth_option => $id_ary) - { - foreach ($id_ary as $id) - { - if (!$forum_id) - { - $user_ary[$id]['forums'] = $user->lang['ALL_FORUMS']; - } - else - { - $user_ary[$id]['forums_ary'][] = $forum_id; - } - } - } - } - - $sql = 'SELECT forum_id, forum_name - FROM ' . FORUMS_TABLE; - $result = $db->sql_query($sql); - - $forums = array(); - while ($row = $db->sql_fetchrow($result)) - { - $forums[$row['forum_id']] = $row['forum_name']; - } - $db->sql_freeresult($result); - - foreach ($user_ary as $user_id => $user_data) - { - if (!$user_data['forums']) - { - foreach ($user_data['forums_ary'] as $forum_id) - { - $user_ary[$user_id]['forums_options'] = true; - if (isset($forums[$forum_id])) - { - if ($auth->acl_get('f_list', $forum_id)) - { - $user_ary[$user_id]['forums'] .= ''; - } - } - } - } - } - } - - $parent_team = 0; - foreach ($teampage_data as $team_data) - { - // If this team entry has no group, it's a category - if (!$team_data['group_id']) - { - $template->assign_block_vars('group', array( - 'GROUP_NAME' => $team_data['teampage_name'], - )); - - $parent_team = (int) $team_data['teampage_id']; - continue; - } - - $group_data = $groups_ary[(int) $team_data['group_id']]; - $group_id = (int) $team_data['group_id']; - - if (!$team_data['teampage_parent']) - { - // If the group does not have a parent category, we display the groupname as category - $template->assign_block_vars('group', array( - 'GROUP_NAME' => $group_data['group_name'], - 'GROUP_COLOR' => $group_data['group_colour'], - 'U_GROUP' => $group_data['u_group'], - )); - } - - // Display group members. - if (!empty($group_users[$group_id])) - { - foreach ($group_users[$group_id] as $user_id) - { - if (isset($user_ary[$user_id])) - { - $row = $user_ary[$user_id]; - if ($config['teampage_memberships'] == 1 && ($group_id != $groups_ary[$row['default_group']]['group_id']) && $groups_ary[$row['default_group']]['teampage_id']) - { - // Display users in their primary group, instead of the first group, when it is displayed on the teampage. - continue; - } - - $user_rank_data = phpbb_get_user_rank($row, (($row['user_id'] == ANONYMOUS) ? false : $row['user_posts'])); - - $template_vars = array( - 'USER_ID' => $row['user_id'], - 'FORUMS' => $row['forums'], - 'FORUM_OPTIONS' => (isset($row['forums_options'])) ? true : false, - 'RANK_TITLE' => $user_rank_data['title'], - - 'GROUP_NAME' => $groups_ary[$row['default_group']]['group_name'], - 'GROUP_COLOR' => $groups_ary[$row['default_group']]['group_colour'], - 'U_GROUP' => $groups_ary[$row['default_group']]['u_group'], - - 'RANK_IMG' => $user_rank_data['img'], - 'RANK_IMG_SRC' => $user_rank_data['img_src'], - - 'S_INACTIVE' => $row['user_type'] == USER_INACTIVE, - - 'U_PM' => ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($row['user_allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&u=' . $row['user_id']) : '', - - 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), - 'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), - 'USER_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), - 'U_VIEW_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']), - ); - - /** - * Modify the template vars for displaying the user in the groups on the teampage - * - * @event core.memberlist_team_modify_template_vars - * @var array template_vars Array containing the query - * @var array row Array containing the action user row - * @var array groups_ary Array of groups with all users that should be displayed - * @since 3.1.3-RC1 - */ - $vars = array( - 'template_vars', - 'row', - 'groups_ary', - ); - extract($phpbb_dispatcher->trigger_event('core.memberlist_team_modify_template_vars', compact($vars))); - - $template->assign_block_vars('group.user', $template_vars); - - if ($config['teampage_memberships'] != 2) - { - unset($user_ary[$user_id]); - } - } - } - } - } - - $template->assign_vars(array( - 'PM_IMG' => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE'])) - ); - break; - - case 'contact': - - $page_title = $user->lang['IM_USER']; - $template_html = 'memberlist_im.html'; - - if (!$auth->acl_get('u_sendim')) - { - send_status_line(403, 'Forbidden'); - trigger_error('NOT_AUTHORISED'); - } - - $presence_img = ''; - switch ($action) - { - case 'jabber': - $lang = 'JABBER'; - $sql_field = 'user_jabber'; - $s_select = (@extension_loaded('xml') && $config['jab_enable']) ? 'S_SEND_JABBER' : 'S_NO_SEND_JABBER'; - $s_action = append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&action=$action&u=$user_id"); - break; - - default: - trigger_error('NO_MODE', E_USER_ERROR); - break; - } - - // Grab relevant data - $sql = "SELECT user_id, username, user_email, user_lang, $sql_field - FROM " . USERS_TABLE . " - WHERE user_id = $user_id - AND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')'; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - trigger_error('NO_USER'); - } - else if (empty($row[$sql_field])) - { - trigger_error('IM_NO_DATA'); - } - - // Post data grab actions - switch ($action) - { - case 'jabber': - add_form_key('memberlist_messaging'); - - if ($submit && @extension_loaded('xml') && $config['jab_enable']) - { - if (check_form_key('memberlist_messaging')) - { - - include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); - - $subject = sprintf($user->lang['IM_JABBER_SUBJECT'], $user->data['username'], $config['server_name']); - $message = $request->variable('message', '', true); - - if (empty($message)) - { - trigger_error('EMPTY_MESSAGE_IM'); - } - - $messenger = new messenger(false); - - $messenger->template('profile_send_im', $row['user_lang']); - $messenger->subject(htmlspecialchars_decode($subject)); - - $messenger->replyto($user->data['user_email']); - $messenger->set_addresses($row); - - $messenger->assign_vars(array( - 'BOARD_CONTACT' => phpbb_get_board_contact($config, $phpEx), - 'FROM_USERNAME' => htmlspecialchars_decode($user->data['username']), - 'TO_USERNAME' => htmlspecialchars_decode($row['username']), - 'MESSAGE' => htmlspecialchars_decode($message)) - ); - - $messenger->send(NOTIFY_IM); - - $s_select = 'S_SENT_JABBER'; - } - else - { - trigger_error('FORM_INVALID'); - } - } - break; - } - - // Send vars to the template - $template->assign_vars(array( - 'IM_CONTACT' => $row[$sql_field], - 'A_IM_CONTACT' => addslashes($row[$sql_field]), - - 'USERNAME' => $row['username'], - 'CONTACT_NAME' => $row[$sql_field], - 'SITENAME' => $config['sitename'], - - 'PRESENCE_IMG' => $presence_img, - - 'L_SEND_IM_EXPLAIN' => $user->lang['IM_' . $lang], - 'L_IM_SENT_JABBER' => sprintf($user->lang['IM_SENT_JABBER'], $row['username']), - - $s_select => true, - 'S_IM_ACTION' => $s_action) - ); - - break; - - case 'viewprofile': - // Display a profile - if ($user_id == ANONYMOUS && !$username) - { - trigger_error('NO_USER'); - } - - // Get user... - $sql_array = array( - 'SELECT' => 'u.*', - 'FROM' => array( - USERS_TABLE => 'u' - ), - 'WHERE' => (($username) ? "u.username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'" : "u.user_id = $user_id"), - ); - - /** - * Modify user data SQL before member profile row is created - * - * @event core.memberlist_modify_viewprofile_sql - * @var int user_id The user ID - * @var string username The username - * @var array sql_array Array containing the main query - * @since 3.2.6-RC1 - */ - $vars = array( - 'user_id', - 'username', - 'sql_array', - ); - extract($phpbb_dispatcher->trigger_event('core.memberlist_modify_viewprofile_sql', compact($vars))); - - $sql = $db->sql_build_query('SELECT', $sql_array); - $result = $db->sql_query($sql); - $member = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$member) - { - trigger_error('NO_USER'); - } - - // a_user admins and founder are able to view inactive users and bots to be able to manage them more easily - // Normal users are able to see at least users having only changed their profile settings but not yet reactivated. - if (!$auth->acl_get('a_user') && $user->data['user_type'] != USER_FOUNDER) - { - if ($member['user_type'] == USER_IGNORE) - { - trigger_error('NO_USER'); - } - else if ($member['user_type'] == USER_INACTIVE && $member['user_inactive_reason'] != INACTIVE_PROFILE) - { - trigger_error('NO_USER'); - } - } - - $user_id = (int) $member['user_id']; - - // Get group memberships - // Also get visiting user's groups to determine hidden group memberships if necessary. - $auth_hidden_groups = ($user_id === (int) $user->data['user_id'] || $auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) ? true : false; - $sql_uid_ary = ($auth_hidden_groups) ? array($user_id) : array($user_id, (int) $user->data['user_id']); - - // Do the SQL thang - $sql_ary = [ - 'SELECT' => 'g.group_id, g.group_name, g.group_type, ug.user_id', - - 'FROM' => [ - GROUPS_TABLE => 'g', - ], - - 'LEFT_JOIN' => [ - [ - 'FROM' => [USER_GROUP_TABLE => 'ug'], - 'ON' => 'g.group_id = ug.group_id', - ], - ], - - 'WHERE' => $db->sql_in_set('ug.user_id', $sql_uid_ary) . ' - AND ug.user_pending = 0', - ]; - - /** - * Modify the query used to get the group data - * - * @event core.modify_memberlist_viewprofile_group_sql - * @var array sql_ary Array containing the query - * @since 3.2.6-RC1 - */ - $vars = array( - 'sql_ary', - ); - extract($phpbb_dispatcher->trigger_event('core.modify_memberlist_viewprofile_group_sql', compact($vars))); - - $result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary)); - - // Divide data into profile data and current user data - $profile_groups = $user_groups = array(); - while ($row = $db->sql_fetchrow($result)) - { - $row['user_id'] = (int) $row['user_id']; - $row['group_id'] = (int) $row['group_id']; - - if ($row['user_id'] == $user_id) - { - $profile_groups[] = $row; - } - else - { - $user_groups[$row['group_id']] = $row['group_id']; - } - } - $db->sql_freeresult($result); - - // Filter out hidden groups and sort groups by name - $group_data = $group_sort = array(); - foreach ($profile_groups as $row) - { - if (!$auth_hidden_groups && $row['group_type'] == GROUP_HIDDEN && !isset($user_groups[$row['group_id']])) - { - // Skip over hidden groups the user cannot see - continue; - } - - $row['group_name'] = $group_helper->get_name($row['group_name']); - - $group_sort[$row['group_id']] = utf8_clean_string($row['group_name']); - $group_data[$row['group_id']] = $row; - } - unset($profile_groups); - unset($user_groups); - asort($group_sort); - - /** - * Modify group data before options is created and data is unset - * - * @event core.modify_memberlist_viewprofile_group_data - * @var array group_data Array containing the group data - * @var array group_sort Array containing the sorted group data - * @since 3.2.6-RC1 - */ - $vars = array( - 'group_data', - 'group_sort', - ); - extract($phpbb_dispatcher->trigger_event('core.modify_memberlist_viewprofile_group_data', compact($vars))); - - $group_options = ''; - foreach ($group_sort as $group_id => $null) - { - $row = $group_data[$group_id]; - - $group_options .= ''; - } - unset($group_data); - unset($group_sort); - - // What colour is the zebra - $sql = 'SELECT friend, foe - FROM ' . ZEBRA_TABLE . " - WHERE zebra_id = $user_id - AND user_id = {$user->data['user_id']}"; - - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $foe = ($row['foe']) ? true : false; - $friend = ($row['friend']) ? true : false; - $db->sql_freeresult($result); - - if ($config['load_onlinetrack']) - { - $sql = 'SELECT MAX(session_time) AS session_time, MIN(session_viewonline) AS session_viewonline - FROM ' . SESSIONS_TABLE . " - WHERE session_user_id = $user_id"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $member['session_time'] = (isset($row['session_time'])) ? $row['session_time'] : 0; - $member['session_viewonline'] = (isset($row['session_viewonline'])) ? $row['session_viewonline'] : 0; - unset($row); - } - - if ($config['load_user_activity']) - { - display_user_activity($member); - } - - // Do the relevant calculations - $memberdays = max(1, round((time() - $member['user_regdate']) / 86400)); - $posts_per_day = $member['user_posts'] / $memberdays; - $percentage = ($config['num_posts']) ? min(100, ($member['user_posts'] / $config['num_posts']) * 100) : 0; - - - if ($member['user_sig']) - { - $parse_flags = ($member['user_sig_bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES; - $member['user_sig'] = generate_text_for_display($member['user_sig'], $member['user_sig_bbcode_uid'], $member['user_sig_bbcode_bitfield'], $parse_flags, true); - } - - // We need to check if the modules 'zebra' ('friends' & 'foes' mode), 'notes' ('user_notes' mode) and 'warn' ('warn_user' mode) are accessible to decide if we can display appropriate links - $zebra_enabled = $friends_enabled = $foes_enabled = $user_notes_enabled = $warn_user_enabled = false; - - // Only check if the user is logged in - if ($user->data['is_registered']) - { - if (!class_exists('p_master')) - { - include($phpbb_root_path . 'includes/functions_module.' . $phpEx); - } - $module = new p_master(); - - $module->list_modules('ucp'); - $module->list_modules('mcp'); - - $user_notes_enabled = ($module->loaded('mcp_notes', 'user_notes')) ? true : false; - $warn_user_enabled = ($module->loaded('mcp_warn', 'warn_user')) ? true : false; - $zebra_enabled = ($module->loaded('ucp_zebra')) ? true : false; - $friends_enabled = ($module->loaded('ucp_zebra', 'friends')) ? true : false; - $foes_enabled = ($module->loaded('ucp_zebra', 'foes')) ? true : false; - - unset($module); - } - - // Custom Profile Fields - $profile_fields = array(); - if ($config['load_cpf_viewprofile']) - { - /* @var $cp \phpbb\profilefields\manager */ - $cp = $phpbb_container->get('profilefields.manager'); - $profile_fields = $cp->grab_profile_fields_data($user_id); - $profile_fields = (isset($profile_fields[$user_id])) ? $cp->generate_profile_fields_template_data($profile_fields[$user_id]) : array(); - } - - /** - * Modify user data before we display the profile - * - * @event core.memberlist_view_profile - * @var array member Array with user's data - * @var bool user_notes_enabled Is the mcp user notes module enabled? - * @var bool warn_user_enabled Is the mcp warnings module enabled? - * @var bool zebra_enabled Is the ucp zebra module enabled? - * @var bool friends_enabled Is the ucp friends module enabled? - * @var bool foes_enabled Is the ucp foes module enabled? - * @var bool friend Is the user friend? - * @var bool foe Is the user foe? - * @var array profile_fields Array with user's profile field data - * @since 3.1.0-a1 - * @changed 3.1.0-b2 Added friend and foe status - * @changed 3.1.0-b3 Added profile fields data - */ - $vars = array( - 'member', - 'user_notes_enabled', - 'warn_user_enabled', - 'zebra_enabled', - 'friends_enabled', - 'foes_enabled', - 'friend', - 'foe', - 'profile_fields', - ); - extract($phpbb_dispatcher->trigger_event('core.memberlist_view_profile', compact($vars))); - - $template->assign_vars(phpbb_show_profile($member, $user_notes_enabled, $warn_user_enabled)); - - // If the user has m_approve permission or a_user permission, then list then display unapproved posts - if ($auth->acl_getf_global('m_approve') || $auth->acl_get('a_user')) - { - $sql = 'SELECT COUNT(post_id) as posts_in_queue - FROM ' . POSTS_TABLE . ' - WHERE poster_id = ' . $user_id . ' - AND ' . $db->sql_in_set('post_visibility', array(ITEM_UNAPPROVED, ITEM_REAPPROVE)); - $result = $db->sql_query($sql); - $member['posts_in_queue'] = (int) $db->sql_fetchfield('posts_in_queue'); - $db->sql_freeresult($result); - } - else - { - $member['posts_in_queue'] = 0; - } - - // Define the main array of vars to assign to memberlist_view.html - $template_ary = array( - 'L_POSTS_IN_QUEUE' => $user->lang('NUM_POSTS_IN_QUEUE', $member['posts_in_queue']), - - 'POSTS_DAY' => $user->lang('POST_DAY', $posts_per_day), - 'POSTS_PCT' => $user->lang('POST_PCT', $percentage), - - 'SIGNATURE' => $member['user_sig'], - 'POSTS_IN_QUEUE' => $member['posts_in_queue'], - - 'PM_IMG' => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE']), - 'L_SEND_EMAIL_USER' => $user->lang('SEND_EMAIL_USER', $member['username']), - 'EMAIL_IMG' => $user->img('icon_contact_email', $user->lang['EMAIL']), - 'JABBER_IMG' => $user->img('icon_contact_jabber', $user->lang['JABBER']), - 'SEARCH_IMG' => $user->img('icon_user_search', $user->lang['SEARCH']), - - 'S_PROFILE_ACTION' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group'), - 'S_GROUP_OPTIONS' => $group_options, - 'S_CUSTOM_FIELDS' => (isset($profile_fields['row']) && count($profile_fields['row'])) ? true : false, - - 'U_USER_ADMIN' => ($auth->acl_get('a_user')) ? append_sid("{$phpbb_admin_path}index.$phpEx", 'i=users&mode=overview&u=' . $user_id, true, $user->session_id) : '', - 'U_USER_BAN' => ($auth->acl_get('m_ban') && $user_id != $user->data['user_id']) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=ban&mode=user&u=' . $user_id, true, $user->session_id) : '', - 'U_MCP_QUEUE' => ($auth->acl_getf_global('m_approve')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue', true, $user->session_id) : '', - - 'U_SWITCH_PERMISSIONS' => ($auth->acl_get('a_switchperm') && $user->data['user_id'] != $user_id) ? append_sid("{$phpbb_root_path}ucp.$phpEx", "mode=switch_perm&u={$user_id}&hash=" . generate_link_hash('switchperm')) : '', - 'U_EDIT_SELF' => ($user_id == $user->data['user_id'] && $auth->acl_get('u_chgprofileinfo')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=ucp_profile&mode=profile_info') : '', - - 'S_USER_NOTES' => ($user_notes_enabled) ? true : false, - 'S_WARN_USER' => ($warn_user_enabled) ? true : false, - 'S_ZEBRA' => ($user->data['user_id'] != $user_id && $user->data['is_registered'] && $zebra_enabled) ? true : false, - 'U_ADD_FRIEND' => (!$friend && !$foe && $friends_enabled) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&add=' . urlencode(htmlspecialchars_decode($member['username']))) : '', - 'U_ADD_FOE' => (!$friend && !$foe && $foes_enabled) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&mode=foes&add=' . urlencode(htmlspecialchars_decode($member['username']))) : '', - 'U_REMOVE_FRIEND' => ($friend && $friends_enabled) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&remove=1&usernames[]=' . $user_id) : '', - 'U_REMOVE_FOE' => ($foe && $foes_enabled) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&remove=1&mode=foes&usernames[]=' . $user_id) : '', - - 'U_CANONICAL' => generate_board_url() . '/' . append_sid("memberlist.$phpEx", 'mode=viewprofile&u=' . $user_id, true, ''), - ); - - /** - * Modify user's template vars before we display the profile - * - * @event core.memberlist_modify_view_profile_template_vars - * @var array template_ary Array with user's template vars - * @since 3.2.6-RC1 - */ - $vars = array( - 'template_ary', - ); - extract($phpbb_dispatcher->trigger_event('core.memberlist_modify_view_profile_template_vars', compact($vars))); - - // Assign vars to memberlist_view.html - $template->assign_vars($template_ary); - - if (!empty($profile_fields['row'])) - { - $template->assign_vars($profile_fields['row']); - } - - if (!empty($profile_fields['blockrow'])) - { - foreach ($profile_fields['blockrow'] as $field_data) - { - $template->assign_block_vars('custom_fields', $field_data); - } - } - - // Inactive reason/account? - if ($member['user_type'] == USER_INACTIVE) - { - $user->add_lang('acp/common'); - - $inactive_reason = $user->lang['INACTIVE_REASON_UNKNOWN']; - - switch ($member['user_inactive_reason']) - { - case INACTIVE_REGISTER: - $inactive_reason = $user->lang['INACTIVE_REASON_REGISTER']; - break; - - case INACTIVE_PROFILE: - $inactive_reason = $user->lang['INACTIVE_REASON_PROFILE']; - break; - - case INACTIVE_MANUAL: - $inactive_reason = $user->lang['INACTIVE_REASON_MANUAL']; - break; - - case INACTIVE_REMIND: - $inactive_reason = $user->lang['INACTIVE_REASON_REMIND']; - break; - } - - $template->assign_vars(array( - 'S_USER_INACTIVE' => true, - 'USER_INACTIVE_REASON' => $inactive_reason) - ); - } - - // Now generate page title - $page_title = sprintf($user->lang['VIEWING_PROFILE'], $member['username']); - $template_html = 'memberlist_view.html'; - - break; - - case 'contactadmin': - case 'email': - if (!class_exists('messenger')) - { - include($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); - } - - $user_id = $request->variable('u', 0); - $topic_id = $request->variable('t', 0); - - if ($user_id) - { - $form_name = 'user'; - } - else if ($topic_id) - { - $form_name = 'topic'; - } - else if ($mode === 'contactadmin') - { - $form_name = 'admin'; - } - else - { - trigger_error('NO_EMAIL'); - } - - /** @var $form \phpbb\message\form */ - $form = $phpbb_container->get('message.form.' . $form_name); - - $form->bind($request); - $error = $form->check_allow(); - if ($error) - { - trigger_error($error); - } - - if ($request->is_set_post('submit')) - { - $messenger = new messenger(false); - $form->submit($messenger); - } - - $page_title = $form->get_page_title(); - $template_html = $form->get_template_file(); - $form->render($template); - - break; - - case 'livesearch': - - $username_chars = $request->variable('username', '', true); - - $sql = 'SELECT username, user_id, user_colour - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('user_type', $user_types) . ' - AND username_clean ' . $db->sql_like_expression(utf8_clean_string($username_chars) . $db->get_any_char()); - $result = $db->sql_query_limit($sql, 10); - $user_list = array(); - - while ($row = $db->sql_fetchrow($result)) - { - $user_list[] = array( - 'user_id' => (int) $row['user_id'], - 'result' => $row['username'], - 'username_full' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), - 'display' => get_username_string('no_profile', $row['user_id'], $row['username'], $row['user_colour']), - ); - } - $db->sql_freeresult($result); - $json_response = new \phpbb\json_response(); - $json_response->send(array( - 'keyword' => $username_chars, - 'results' => $user_list, - )); - - break; - - case 'group': - default: - // The basic memberlist - $page_title = $user->lang['MEMBERLIST']; - $template_html = 'memberlist_body.html'; - - /* @var $pagination \phpbb\pagination */ - $pagination = $phpbb_container->get('pagination'); - - // Sorting - $sort_key_text = array('a' => $user->lang['SORT_USERNAME'], 'c' => $user->lang['SORT_JOINED'], 'd' => $user->lang['SORT_POST_COUNT']); - $sort_key_sql = array('a' => 'u.username_clean', 'c' => 'u.user_regdate', 'd' => 'u.user_posts'); - - if ($config['jab_enable']) - { - $sort_key_text['k'] = $user->lang['JABBER']; - $sort_key_sql['k'] = 'u.user_jabber'; - } - - if ($auth->acl_get('a_user')) - { - $sort_key_text['e'] = $user->lang['SORT_EMAIL']; - $sort_key_sql['e'] = 'u.user_email'; - } - - if ($auth->acl_get('u_viewonline')) - { - $sort_key_text['l'] = $user->lang['SORT_LAST_ACTIVE']; - $sort_key_sql['l'] = 'u.user_lastvisit'; - } - - $sort_key_text['m'] = $user->lang['SORT_RANK']; - $sort_key_sql['m'] = 'u.user_rank'; - - $sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']); - - $s_sort_key = ''; - foreach ($sort_key_text as $key => $value) - { - $selected = ($sort_key == $key) ? ' selected="selected"' : ''; - $s_sort_key .= ''; - } - - $s_sort_dir = ''; - foreach ($sort_dir_text as $key => $value) - { - $selected = ($sort_dir == $key) ? ' selected="selected"' : ''; - $s_sort_dir .= ''; - } - - // Additional sorting options for user search ... if search is enabled, if not - // then only admins can make use of this (for ACP functionality) - $sql_select = $sql_where_data = $sql_from = $sql_where = $order_by = ''; - - - $form = $request->variable('form', ''); - $field = $request->variable('field', ''); - $select_single = $request->variable('select_single', false); - - // Search URL parameters, if any of these are in the URL we do a search - $search_params = array('username', 'email', 'jabber', 'search_group_id', 'joined_select', 'active_select', 'count_select', 'joined', 'active', 'count', 'ip'); - - // We validate form and field here, only id/class allowed - $form = (!preg_match('/^[a-z0-9_-]+$/i', $form)) ? '' : $form; - $field = (!preg_match('/^[a-z0-9_-]+$/i', $field)) ? '' : $field; - if ((($mode == '' || $mode == 'searchuser') || count(array_intersect($request->variable_names(\phpbb\request\request_interface::GET), $search_params)) > 0) && ($config['load_search'] || $auth->acl_get('a_'))) - { - $username = $request->variable('username', '', true); - $email = strtolower($request->variable('email', '')); - $jabber = $request->variable('jabber', ''); - $search_group_id = $request->variable('search_group_id', 0); - - // when using these, make sure that we actually have values defined in $find_key_match - $joined_select = $request->variable('joined_select', 'lt'); - $active_select = $request->variable('active_select', 'lt'); - $count_select = $request->variable('count_select', 'eq'); - - $joined = explode('-', $request->variable('joined', '')); - $active = explode('-', $request->variable('active', '')); - $count = ($request->variable('count', '') !== '') ? $request->variable('count', 0) : ''; - $ipdomain = $request->variable('ip', ''); - - $find_key_match = array('lt' => '<', 'gt' => '>', 'eq' => '='); - - $find_count = array('lt' => $user->lang['LESS_THAN'], 'eq' => $user->lang['EQUAL_TO'], 'gt' => $user->lang['MORE_THAN']); - $s_find_count = ''; - foreach ($find_count as $key => $value) - { - $selected = ($count_select == $key) ? ' selected="selected"' : ''; - $s_find_count .= ''; - } - - $find_time = array('lt' => $user->lang['BEFORE'], 'gt' => $user->lang['AFTER']); - $s_find_join_time = ''; - foreach ($find_time as $key => $value) - { - $selected = ($joined_select == $key) ? ' selected="selected"' : ''; - $s_find_join_time .= ''; - } - - $s_find_active_time = ''; - foreach ($find_time as $key => $value) - { - $selected = ($active_select == $key) ? ' selected="selected"' : ''; - $s_find_active_time .= ''; - } - - $sql_where .= ($username) ? ' AND u.username_clean ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), utf8_clean_string($username))) : ''; - $sql_where .= ($auth->acl_get('a_user') && $email) ? ' AND u.user_email ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), $email)) . ' ' : ''; - $sql_where .= ($jabber) ? ' AND u.user_jabber ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), $jabber)) . ' ' : ''; - $sql_where .= (is_numeric($count) && isset($find_key_match[$count_select])) ? ' AND u.user_posts ' . $find_key_match[$count_select] . ' ' . (int) $count . ' ' : ''; - - if (isset($find_key_match[$joined_select]) && count($joined) == 3) - { - $joined_time = gmmktime(0, 0, 0, (int) $joined[1], (int) $joined[2], (int) $joined[0]); - - if ($joined_time !== false) - { - $sql_where .= " AND u.user_regdate " . $find_key_match[$joined_select] . ' ' . $joined_time; - } - } - - if (isset($find_key_match[$active_select]) && count($active) == 3 && $auth->acl_get('u_viewonline')) - { - $active_time = gmmktime(0, 0, 0, (int) $active[1], (int) $active[2], (int) $active[0]); - - if ($active_time !== false) - { - $sql_where .= " AND u.user_lastvisit " . $find_key_match[$active_select] . ' ' . $active_time; - } - } - - $sql_where .= ($search_group_id) ? " AND u.user_id = ug.user_id AND ug.group_id = $search_group_id AND ug.user_pending = 0 " : ''; - - if ($search_group_id) - { - $sql_from = ', ' . USER_GROUP_TABLE . ' ug '; - } - - if ($ipdomain && $auth->acl_getf_global('m_info')) - { - if (strspn($ipdomain, 'abcdefghijklmnopqrstuvwxyz')) - { - $hostnames = gethostbynamel($ipdomain); - - if ($hostnames !== false) - { - $ips = "'" . implode('\', \'', array_map(array($db, 'sql_escape'), preg_replace('#([0-9]{1,3}\.[0-9]{1,3}[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})#', "\\1", gethostbynamel($ipdomain)))) . "'"; - } - else - { - $ips = false; - } - } - else - { - $ips = "'" . str_replace('*', '%', $db->sql_escape($ipdomain)) . "'"; - } - - if ($ips === false) - { - // A minor fudge but it does the job :D - $sql_where .= " AND u.user_id = 0"; - } - else - { - $ip_forums = array_keys($auth->acl_getf('m_info', true)); - - $sql = 'SELECT DISTINCT poster_id - FROM ' . POSTS_TABLE . ' - WHERE poster_ip ' . ((strpos($ips, '%') !== false) ? 'LIKE' : 'IN') . " ($ips) - AND " . $db->sql_in_set('forum_id', $ip_forums); - - /** - * Modify sql query for members search by ip address / hostname - * - * @event core.memberlist_modify_ip_search_sql_query - * @var string ipdomain The host name - * @var string ips IP address list for the given host name - * @var string sql The SQL query for searching members by IP address - * @since 3.1.7-RC1 - */ - $vars = array( - 'ipdomain', - 'ips', - 'sql', - ); - extract($phpbb_dispatcher->trigger_event('core.memberlist_modify_ip_search_sql_query', compact($vars))); - - $result = $db->sql_query($sql); - - if ($row = $db->sql_fetchrow($result)) - { - $ip_sql = array(); - do - { - $ip_sql[] = $row['poster_id']; - } - while ($row = $db->sql_fetchrow($result)); - - $sql_where .= ' AND ' . $db->sql_in_set('u.user_id', $ip_sql); - } - else - { - // A minor fudge but it does the job :D - $sql_where .= " AND u.user_id = 0"; - } - unset($ip_forums); - - $db->sql_freeresult($result); - } - } - } - - $first_char = $request->variable('first_char', ''); - - if ($first_char == 'other') - { - for ($i = 97; $i < 123; $i++) - { - $sql_where .= ' AND u.username_clean NOT ' . $db->sql_like_expression(chr($i) . $db->get_any_char()); - } - } - else if ($first_char) - { - $sql_where .= ' AND u.username_clean ' . $db->sql_like_expression(substr($first_char, 0, 1) . $db->get_any_char()); - } - - // Are we looking at a usergroup? If so, fetch additional info - // and further restrict the user info query - if ($mode == 'group') - { - // We JOIN here to save a query for determining membership for hidden groups. ;) - $sql = 'SELECT g.*, ug.user_id, ug.group_leader - FROM ' . GROUPS_TABLE . ' g - LEFT JOIN ' . USER_GROUP_TABLE . ' ug ON (ug.user_pending = 0 AND ug.user_id = ' . $user->data['user_id'] . " AND ug.group_id = $group_id) - WHERE g.group_id = $group_id"; - $result = $db->sql_query($sql); - $group_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$group_row) - { - trigger_error('NO_GROUP'); - } - - switch ($group_row['group_type']) - { - case GROUP_OPEN: - $group_row['l_group_type'] = 'OPEN'; - break; - - case GROUP_CLOSED: - $group_row['l_group_type'] = 'CLOSED'; - break; - - case GROUP_HIDDEN: - $group_row['l_group_type'] = 'HIDDEN'; - - // Check for membership or special permissions - if (!$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel') && $group_row['user_id'] != $user->data['user_id']) - { - trigger_error('NO_GROUP'); - } - break; - - case GROUP_SPECIAL: - $group_row['l_group_type'] = 'SPECIAL'; - break; - - case GROUP_FREE: - $group_row['l_group_type'] = 'FREE'; - break; - } - - $avatar_img = phpbb_get_group_avatar($group_row); - - // ... same for group rank - $user_rank_data = array( - 'title' => null, - 'img' => null, - 'img_src' => null, - ); - if ($group_row['group_rank']) - { - $user_rank_data = phpbb_get_user_rank($group_row, false); - - if ($user_rank_data['img']) - { - $user_rank_data['img'] .= '
'; - } - } - // include modules for manage groups link display or not - // need to ensure the module is active - $can_manage_group = false; - if ($user->data['is_registered'] && $group_row['group_leader']) - { - if (!class_exists('p_master')) - { - include($phpbb_root_path . 'includes/functions_module.' . $phpEx); - } - $module = new p_master; - $module->list_modules('ucp'); - - if ($module->is_active('ucp_groups', 'manage')) - { - $can_manage_group = true; - } - unset($module); - } - - $template->assign_vars(array( - 'GROUP_DESC' => generate_text_for_display($group_row['group_desc'], $group_row['group_desc_uid'], $group_row['group_desc_bitfield'], $group_row['group_desc_options']), - 'GROUP_NAME' => $group_helper->get_name($group_row['group_name']), - 'GROUP_COLOR' => $group_row['group_colour'], - 'GROUP_TYPE' => $user->lang['GROUP_IS_' . $group_row['l_group_type']], - 'GROUP_RANK' => $user_rank_data['title'], - - 'AVATAR_IMG' => $avatar_img, - 'RANK_IMG' => $user_rank_data['img'], - 'RANK_IMG_SRC' => $user_rank_data['img_src'], - - 'U_PM' => ($auth->acl_get('u_sendpm') && $auth->acl_get('u_masspm_group') && $group_row['group_receive_pm'] && $config['allow_privmsg'] && $config['allow_mass_pm']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&g=' . $group_id) : '', - 'U_MANAGE' => ($can_manage_group) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=ucp_groups&mode=manage') : false,) - ); - - $sql_select = ', ug.group_leader'; - $sql_from = ', ' . USER_GROUP_TABLE . ' ug '; - $order_by = 'ug.group_leader DESC, '; - - $sql_where .= " AND ug.user_pending = 0 AND u.user_id = ug.user_id AND ug.group_id = $group_id"; - $sql_where_data = " AND u.user_id = ug.user_id AND ug.group_id = $group_id"; - } - - // Sorting and order - if (!isset($sort_key_sql[$sort_key])) - { - $sort_key = $default_key; - } - - $order_by .= $sort_key_sql[$sort_key] . ' ' . (($sort_dir == 'a') ? 'ASC' : 'DESC'); - - // Unfortunately we must do this here for sorting by rank, else the sort order is applied wrongly - if ($sort_key == 'm') - { - $order_by .= ', u.user_posts DESC'; - } - - /** - * Modify sql query data for members search - * - * @event core.memberlist_modify_sql_query_data - * @var string order_by SQL ORDER BY clause condition - * @var string sort_dir The sorting direction - * @var string sort_key The sorting key - * @var array sort_key_sql Arraty with the sorting conditions data - * @var string sql_from SQL FROM clause condition - * @var string sql_select SQL SELECT fields list - * @var string sql_where SQL WHERE clause condition - * @var string sql_where_data SQL WHERE clause additional conditions data - * @since 3.1.7-RC1 - */ - $vars = array( - 'order_by', - 'sort_dir', - 'sort_key', - 'sort_key_sql', - 'sql_from', - 'sql_select', - 'sql_where', - 'sql_where_data', - ); - extract($phpbb_dispatcher->trigger_event('core.memberlist_modify_sql_query_data', compact($vars))); - - // Count the users ... - $sql = 'SELECT COUNT(u.user_id) AS total_users - FROM ' . USERS_TABLE . " u$sql_from - WHERE " . $db->sql_in_set('u.user_type', $user_types) . " - $sql_where"; - $result = $db->sql_query($sql); - $total_users = (int) $db->sql_fetchfield('total_users'); - $db->sql_freeresult($result); - - // Build a relevant pagination_url - $params = $sort_params = array(); - - // We do not use $request->variable() here directly to save some calls (not all variables are set) - $check_params = array( - 'g' => array('g', 0), - 'sk' => array('sk', $default_key), - 'sd' => array('sd', 'a'), - 'form' => array('form', ''), - 'field' => array('field', ''), - 'select_single' => array('select_single', $select_single), - 'username' => array('username', '', true), - 'email' => array('email', ''), - 'jabber' => array('jabber', ''), - 'search_group_id' => array('search_group_id', 0), - 'joined_select' => array('joined_select', 'lt'), - 'active_select' => array('active_select', 'lt'), - 'count_select' => array('count_select', 'eq'), - 'joined' => array('joined', ''), - 'active' => array('active', ''), - 'count' => ($request->variable('count', '') !== '') ? array('count', 0) : array('count', ''), - 'ip' => array('ip', ''), - 'first_char' => array('first_char', ''), - ); - - $u_first_char_params = array(); - foreach ($check_params as $key => $call) - { - if (!isset($_REQUEST[$key])) - { - continue; - } - - $param = call_user_func_array(array($request, 'variable'), $call); - // Encode strings, convert everything else to int in order to prevent empty parameters. - $param = urlencode($key) . '=' . ((is_string($param)) ? urlencode($param) : (int) $param); - $params[] = $param; - - if ($key != 'first_char') - { - $u_first_char_params[] = $param; - } - if ($key != 'sk' && $key != 'sd') - { - $sort_params[] = $param; - } - } - - $u_hide_find_member = append_sid("{$phpbb_root_path}memberlist.$phpEx", "start=$start" . (!empty($params) ? '&' . implode('&', $params) : '')); - - if ($mode) - { - $params[] = "mode=$mode"; - $u_first_char_params[] = "mode=$mode"; - } - $sort_params[] = "mode=$mode"; - - $u_first_char_params = implode('&', $u_first_char_params); - $u_first_char_params .= ($u_first_char_params) ? '&' : ''; - - $first_characters = array(); - $first_characters[''] = $user->lang['ALL']; - for ($i = 97; $i < 123; $i++) - { - $first_characters[chr($i)] = chr($i - 32); - } - $first_characters['other'] = $user->lang['OTHER']; - - $first_char_block_vars = []; - - foreach ($first_characters as $char => $desc) - { - $first_char_block_vars[] = [ - 'DESC' => $desc, - 'VALUE' => $char, - 'S_SELECTED' => ($first_char == $char) ? true : false, - 'U_SORT' => append_sid("{$phpbb_root_path}memberlist.$phpEx", $u_first_char_params . 'first_char=' . $char) . '#memberlist', - ]; - } - - /** - * Modify memberlist sort and pagination parameters - * - * @event core.memberlist_modify_sort_pagination_params - * @var array sort_params Array with URL parameters for sorting - * @var array params Array with URL parameters for pagination - * @var array first_characters Array that maps each letter in a-z, 'other' and the empty string to their display representation - * @var string u_first_char_params Concatenated URL parameters for first character search links - * @var array first_char_block_vars Template block variables for each first character - * @var int total_users Total number of users found in this search - * @since 3.2.6-RC1 - */ - $vars = [ - 'sort_params', - 'params', - 'first_characters', - 'u_first_char_params', - 'first_char_block_vars', - 'total_users', - ]; - extract($phpbb_dispatcher->trigger_event('core.memberlist_modify_sort_pagination_params', compact($vars))); - - $template->assign_block_vars_array('first_char', $first_char_block_vars); - - $pagination_url = append_sid("{$phpbb_root_path}memberlist.$phpEx", implode('&', $params)); - $sort_url = append_sid("{$phpbb_root_path}memberlist.$phpEx", implode('&', $sort_params)); - - unset($search_params, $sort_params); - - // Some search user specific data - if (($mode == '' || $mode == 'searchuser') && ($config['load_search'] || $auth->acl_get('a_'))) - { - $group_selected = $request->variable('search_group_id', 0); - $s_group_select = ''; - $group_ids = array(); - - /** - * @todo add this to a separate function (function is responsible for returning the groups the user is able to see based on the users group membership) - */ - - if ($auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) - { - $sql = 'SELECT group_id, group_name, group_type - FROM ' . GROUPS_TABLE; - - if (!$config['coppa_enable']) - { - $sql .= " WHERE group_name <> 'REGISTERED_COPPA'"; - } - - $sql .= ' ORDER BY group_name ASC'; - } - else - { - $sql = 'SELECT g.group_id, g.group_name, g.group_type - FROM ' . GROUPS_TABLE . ' g - LEFT JOIN ' . USER_GROUP_TABLE . ' ug - ON ( - g.group_id = ug.group_id - AND ug.user_id = ' . $user->data['user_id'] . ' - AND ug.user_pending = 0 - ) - WHERE (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $user->data['user_id'] . ')'; - - if (!$config['coppa_enable']) - { - $sql .= " AND g.group_name <> 'REGISTERED_COPPA'"; - } - - $sql .= ' ORDER BY g.group_name ASC'; - } - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $group_ids[] = $row['group_id']; - $s_group_select .= ''; - } - $db->sql_freeresult($result); - - if ($group_selected !== 0 && !in_array($group_selected, $group_ids)) - { - trigger_error('NO_GROUP'); - } - - $template->assign_vars(array( - 'USERNAME' => $username, - 'EMAIL' => $email, - 'JABBER' => $jabber, - 'JOINED' => implode('-', $joined), - 'ACTIVE' => implode('-', $active), - 'COUNT' => $count, - 'IP' => $ipdomain, - - 'S_IP_SEARCH_ALLOWED' => ($auth->acl_getf_global('m_info')) ? true : false, - 'S_EMAIL_SEARCH_ALLOWED'=> ($auth->acl_get('a_user')) ? true : false, - 'S_JABBER_ENABLED' => $config['jab_enable'], - 'S_IN_SEARCH_POPUP' => ($form && $field) ? true : false, - 'S_SEARCH_USER' => ($mode == 'searchuser' || ($mode == '' && $submit)), - 'S_FORM_NAME' => $form, - 'S_FIELD_NAME' => $field, - 'S_SELECT_SINGLE' => $select_single, - 'S_COUNT_OPTIONS' => $s_find_count, - 'S_SORT_OPTIONS' => $s_sort_key, - 'S_JOINED_TIME_OPTIONS' => $s_find_join_time, - 'S_ACTIVE_TIME_OPTIONS' => $s_find_active_time, - 'S_GROUP_SELECT' => $s_group_select, - 'S_USER_SEARCH_ACTION' => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=searchuser&form=$form&field=$field")) - ); - } - - $start = $pagination->validate_start($start, $config['topics_per_page'], $total_users); - - // Get us some users :D - $sql = "SELECT u.user_id - FROM " . USERS_TABLE . " u - $sql_from - WHERE " . $db->sql_in_set('u.user_type', $user_types) . " - $sql_where - ORDER BY $order_by"; - $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); - - $user_list = array(); - while ($row = $db->sql_fetchrow($result)) - { - $user_list[] = (int) $row['user_id']; - } - $db->sql_freeresult($result); - - // Load custom profile fields - if ($config['load_cpf_memberlist']) - { - /* @var $cp \phpbb\profilefields\manager */ - $cp = $phpbb_container->get('profilefields.manager'); - - $cp_row = $cp->generate_profile_fields_template_headlines('field_show_on_ml'); - foreach ($cp_row as $profile_field) - { - $template->assign_block_vars('custom_fields', $profile_field); - } - } - - $leaders_set = false; - // So, did we get any users? - if (count($user_list)) - { - // Session time?! Session time... - $sql = 'SELECT session_user_id, MAX(session_time) AS session_time - FROM ' . SESSIONS_TABLE . ' - WHERE session_time >= ' . (time() - $config['session_length']) . ' - AND ' . $db->sql_in_set('session_user_id', $user_list) . ' - GROUP BY session_user_id'; - $result = $db->sql_query($sql); - - $session_times = array(); - while ($row = $db->sql_fetchrow($result)) - { - $session_times[$row['session_user_id']] = $row['session_time']; - } - $db->sql_freeresult($result); - - // Do the SQL thang - if ($mode == 'group') - { - $sql_from_ary = explode(',', $sql_from); - $extra_tables = []; - foreach ($sql_from_ary as $entry) - { - $table_data = explode(' ', trim($entry)); - - if (empty($table_data[0]) || empty($table_data[1])) - { - continue; - } - - $extra_tables[$table_data[0]] = $table_data[1]; - } - - $sql_array = array( - 'SELECT' => 'u.*' . $sql_select, - 'FROM' => array_merge([USERS_TABLE => 'u'], $extra_tables), - 'WHERE' => $db->sql_in_set('u.user_id', $user_list) . $sql_where_data . '', - ); - } - else - { - $sql_array = array( - 'SELECT' => 'u.*', - 'FROM' => array( - USERS_TABLE => 'u' - ), - 'WHERE' => $db->sql_in_set('u.user_id', $user_list), - ); - } - - /** - * Modify user data SQL before member row is created - * - * @event core.memberlist_modify_memberrow_sql - * @var string mode Memberlist mode - * @var string sql_select Additional select statement - * @var string sql_from Additional from statement - * @var array sql_array Array containing the main query - * @var array user_list Array containing list of users - * @since 3.2.6-RC1 - */ - $vars = array( - 'mode', - 'sql_select', - 'sql_from', - 'sql_array', - 'user_list', - ); - extract($phpbb_dispatcher->trigger_event('core.memberlist_modify_memberrow_sql', compact($vars))); - - $sql = $db->sql_build_query('SELECT', $sql_array); - $result = $db->sql_query($sql); - - $id_cache = array(); - while ($row = $db->sql_fetchrow($result)) - { - $row['session_time'] = (!empty($session_times[$row['user_id']])) ? $session_times[$row['user_id']] : 0; - $row['last_visit'] = (!empty($row['session_time'])) ? $row['session_time'] : $row['user_lastvisit']; - - $id_cache[$row['user_id']] = $row; - } - - $db->sql_freeresult($result); - - // Load custom profile fields if required - if ($config['load_cpf_memberlist']) - { - // Grab all profile fields from users in id cache for later use - similar to the poster cache - $profile_fields_cache = $cp->grab_profile_fields_data($user_list); - - // Filter the fields we don't want to show - foreach ($profile_fields_cache as $user_id => $user_profile_fields) - { - foreach ($user_profile_fields as $field_ident => $profile_field) - { - if (!$profile_field['data']['field_show_on_ml']) - { - unset($profile_fields_cache[$user_id][$field_ident]); - } - } - } - } - - // If we sort by last active date we need to adjust the id cache due to user_lastvisit not being the last active date... - if ($sort_key == 'l') - { -// uasort($id_cache, create_function('$first, $second', "return (\$first['last_visit'] == \$second['last_visit']) ? 0 : ((\$first['last_visit'] < \$second['last_visit']) ? $lesser_than : ($lesser_than * -1));")); - usort($user_list, 'phpbb_sort_last_active'); - } - - // do we need to display contact fields as such - $use_contact_fields = false; - - /** - * Modify list of users before member row is created - * - * @event core.memberlist_memberrow_before - * @var array user_list Array containing list of users - * @var bool use_contact_fields Should we display contact fields as such? - * @since 3.1.7-RC1 - */ - $vars = array('user_list', 'use_contact_fields'); - extract($phpbb_dispatcher->trigger_event('core.memberlist_memberrow_before', compact($vars))); - - for ($i = 0, $end = count($user_list); $i < $end; ++$i) - { - $user_id = $user_list[$i]; - $row = $id_cache[$user_id]; - $is_leader = (isset($row['group_leader']) && $row['group_leader']) ? true : false; - $leaders_set = ($leaders_set || $is_leader); - - $cp_row = array(); - if ($config['load_cpf_memberlist']) - { - $cp_row = (isset($profile_fields_cache[$user_id])) ? $cp->generate_profile_fields_template_data($profile_fields_cache[$user_id], $use_contact_fields) : array(); - } - - $memberrow = array_merge(phpbb_show_profile($row, false, false, false), array( - 'ROW_NUMBER' => $i + ($start + 1), - - 'S_CUSTOM_PROFILE' => (isset($cp_row['row']) && count($cp_row['row'])) ? true : false, - 'S_GROUP_LEADER' => $is_leader, - 'S_INACTIVE' => $row['user_type'] == USER_INACTIVE, - - 'U_VIEW_PROFILE' => get_username_string('profile', $user_id, $row['username']), - )); - - if (isset($cp_row['row']) && count($cp_row['row'])) - { - $memberrow = array_merge($memberrow, $cp_row['row']); - } - - $template->assign_block_vars('memberrow', $memberrow); - - if (isset($cp_row['blockrow']) && count($cp_row['blockrow'])) - { - foreach ($cp_row['blockrow'] as $field_data) - { - $template->assign_block_vars('memberrow.custom_fields', $field_data); - } - } - - unset($id_cache[$user_id]); - } - } - - $pagination->generate_template_pagination($pagination_url, 'pagination', 'start', $total_users, $config['topics_per_page'], $start); - - // Generate page - $template_vars = array( - 'TOTAL_USERS' => $user->lang('LIST_USERS', (int) $total_users), - - 'PROFILE_IMG' => $user->img('icon_user_profile', $user->lang['PROFILE']), - 'PM_IMG' => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE']), - 'EMAIL_IMG' => $user->img('icon_contact_email', $user->lang['EMAIL']), - 'JABBER_IMG' => $user->img('icon_contact_jabber', $user->lang['JABBER']), - 'SEARCH_IMG' => $user->img('icon_user_search', $user->lang['SEARCH']), - - 'U_FIND_MEMBER' => ($config['load_search'] || $auth->acl_get('a_')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser' . (($start) ? "&start=$start" : '') . (!empty($params) ? '&' . implode('&', $params) : '')) : '', - 'U_HIDE_FIND_MEMBER' => ($mode == 'searchuser' || ($mode == '' && $submit)) ? $u_hide_find_member : '', - 'U_LIVE_SEARCH' => ($config['allow_live_searches']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=livesearch') : false, - 'U_SORT_USERNAME' => $sort_url . '&sk=a&sd=' . (($sort_key == 'a' && $sort_dir == 'a') ? 'd' : 'a'), - 'U_SORT_JOINED' => $sort_url . '&sk=c&sd=' . (($sort_key == 'c' && $sort_dir == 'd') ? 'a' : 'd'), - 'U_SORT_POSTS' => $sort_url . '&sk=d&sd=' . (($sort_key == 'd' && $sort_dir == 'd') ? 'a' : 'd'), - 'U_SORT_EMAIL' => $sort_url . '&sk=e&sd=' . (($sort_key == 'e' && $sort_dir == 'd') ? 'a' : 'd'), - 'U_SORT_ACTIVE' => ($auth->acl_get('u_viewonline')) ? $sort_url . '&sk=l&sd=' . (($sort_key == 'l' && $sort_dir == 'd') ? 'a' : 'd') : '', - 'U_SORT_RANK' => $sort_url . '&sk=m&sd=' . (($sort_key == 'm' && $sort_dir == 'd') ? 'a' : 'd'), - 'U_LIST_CHAR' => $sort_url . '&sk=a&sd=' . (($sort_key == 'l' && $sort_dir == 'd') ? 'a' : 'd'), - - 'S_SHOW_GROUP' => ($mode == 'group') ? true : false, - 'S_VIEWONLINE' => $auth->acl_get('u_viewonline'), - 'S_LEADERS_SET' => $leaders_set, - 'S_MODE_SELECT' => $s_sort_key, - 'S_ORDER_SELECT' => $s_sort_dir, - 'S_MODE_ACTION' => $pagination_url, - ); - - /** - * Modify memberlist page template vars - * - * @event core.memberlist_modify_template_vars - * @var array params Array containing URL parameters - * @var string sort_url Sorting URL base - * @var array template_vars Array containing template vars - * @since 3.2.2-RC1 - */ - $vars = array('params', 'sort_url', 'template_vars'); - extract($phpbb_dispatcher->trigger_event('core.memberlist_modify_template_vars', compact($vars))); - - $template->assign_vars($template_vars); -} - -// Output the page -page_header($page_title); - -$template->set_filenames(array( - 'body' => $template_html) -); -make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx")); - -page_footer(); diff --git a/install/update/old/phpbb/auth/provider/apache.php b/install/update/old/phpbb/auth/provider/apache.php deleted file mode 100644 index aa5bf64..0000000 --- a/install/update/old/phpbb/auth/provider/apache.php +++ /dev/null @@ -1,264 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\auth\provider; - -/** -* Apache authentication provider for phpBB3 -*/ -class apache extends \phpbb\auth\provider\base -{ - /** - * phpBB passwords manager - * - * @var \phpbb\passwords\manager - */ - protected $passwords_manager; - - /** - * Apache Authentication Constructor - * - * @param \phpbb\db\driver\driver_interface $db Database object - * @param \phpbb\config\config $config Config object - * @param \phpbb\passwords\manager $passwords_manager Passwords Manager object - * @param \phpbb\request\request $request Request object - * @param \phpbb\user $user User object - * @param string $phpbb_root_path Relative path to phpBB root - * @param string $php_ext PHP file extension - */ - public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\passwords\manager $passwords_manager, \phpbb\request\request $request, \phpbb\user $user, $phpbb_root_path, $php_ext) - { - $this->db = $db; - $this->config = $config; - $this->passwords_manager = $passwords_manager; - $this->request = $request; - $this->user = $user; - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - } - - /** - * {@inheritdoc} - */ - public function init() - { - if (!$this->request->is_set('PHP_AUTH_USER', \phpbb\request\request_interface::SERVER) || $this->user->data['username'] !== htmlspecialchars_decode($this->request->server('PHP_AUTH_USER'))) - { - return $this->user->lang['APACHE_SETUP_BEFORE_USE']; - } - return false; - } - - /** - * {@inheritdoc} - */ - public function login($username, $password) - { - // do not allow empty password - if (!$password) - { - return array( - 'status' => LOGIN_ERROR_PASSWORD, - 'error_msg' => 'NO_PASSWORD_SUPPLIED', - 'user_row' => array('user_id' => ANONYMOUS), - ); - } - - if (!$username) - { - return array( - 'status' => LOGIN_ERROR_USERNAME, - 'error_msg' => 'LOGIN_ERROR_USERNAME', - 'user_row' => array('user_id' => ANONYMOUS), - ); - } - - if (!$this->request->is_set('PHP_AUTH_USER', \phpbb\request\request_interface::SERVER)) - { - return array( - 'status' => LOGIN_ERROR_EXTERNAL_AUTH, - 'error_msg' => 'LOGIN_ERROR_EXTERNAL_AUTH_APACHE', - 'user_row' => array('user_id' => ANONYMOUS), - ); - } - - $php_auth_user = htmlspecialchars_decode($this->request->server('PHP_AUTH_USER')); - $php_auth_pw = htmlspecialchars_decode($this->request->server('PHP_AUTH_PW')); - - if (!empty($php_auth_user) && !empty($php_auth_pw)) - { - if ($php_auth_user !== $username) - { - return array( - 'status' => LOGIN_ERROR_USERNAME, - 'error_msg' => 'LOGIN_ERROR_USERNAME', - 'user_row' => array('user_id' => ANONYMOUS), - ); - } - - $sql = 'SELECT user_id, username, user_password, user_passchg, user_email, user_type - FROM ' . USERS_TABLE . " - WHERE username = '" . $this->db->sql_escape($php_auth_user) . "'"; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if ($row) - { - // User inactive... - if ($row['user_type'] == USER_INACTIVE || $row['user_type'] == USER_IGNORE) - { - return array( - 'status' => LOGIN_ERROR_ACTIVE, - 'error_msg' => 'ACTIVE_ERROR', - 'user_row' => $row, - ); - } - - // Successful login... - return array( - 'status' => LOGIN_SUCCESS, - 'error_msg' => false, - 'user_row' => $row, - ); - } - - // this is the user's first login so create an empty profile - return array( - 'status' => LOGIN_SUCCESS_CREATE_PROFILE, - 'error_msg' => false, - 'user_row' => $this->user_row($php_auth_user, $php_auth_pw), - ); - } - - // Not logged into apache - return array( - 'status' => LOGIN_ERROR_EXTERNAL_AUTH, - 'error_msg' => 'LOGIN_ERROR_EXTERNAL_AUTH_APACHE', - 'user_row' => array('user_id' => ANONYMOUS), - ); - } - - /** - * {@inheritdoc} - */ - public function autologin() - { - if (!$this->request->is_set('PHP_AUTH_USER', \phpbb\request\request_interface::SERVER)) - { - return array(); - } - - $php_auth_user = htmlspecialchars_decode($this->request->server('PHP_AUTH_USER')); - $php_auth_pw = htmlspecialchars_decode($this->request->server('PHP_AUTH_PW')); - - if (!empty($php_auth_user) && !empty($php_auth_pw)) - { - set_var($php_auth_user, $php_auth_user, 'string', true); - set_var($php_auth_pw, $php_auth_pw, 'string', true); - - $sql = 'SELECT * - FROM ' . USERS_TABLE . " - WHERE username = '" . $this->db->sql_escape($php_auth_user) . "'"; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if ($row) - { - return ($row['user_type'] == USER_INACTIVE || $row['user_type'] == USER_IGNORE) ? array() : $row; - } - - if (!function_exists('user_add')) - { - include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext); - } - - // create the user if he does not exist yet - user_add($this->user_row($php_auth_user, $php_auth_pw)); - - $sql = 'SELECT * - FROM ' . USERS_TABLE . " - WHERE username_clean = '" . $this->db->sql_escape(utf8_clean_string($php_auth_user)) . "'"; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if ($row) - { - return $row; - } - } - - return array(); - } - - /** - * This function generates an array which can be passed to the user_add - * function in order to create a user - * - * @param string $username The username of the new user. - * @param string $password The password of the new user. - * @return array Contains data that can be passed directly to - * the user_add function. - */ - private function user_row($username, $password) - { - // first retrieve default group id - $sql = 'SELECT group_id - FROM ' . GROUPS_TABLE . " - WHERE group_name = '" . $this->db->sql_escape('REGISTERED') . "' - AND group_type = " . GROUP_SPECIAL; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if (!$row) - { - trigger_error('NO_GROUP'); - } - - // generate user account data - return array( - 'username' => $username, - 'user_password' => $this->passwords_manager->hash($password), - 'user_email' => '', - 'group_id' => (int) $row['group_id'], - 'user_type' => USER_NORMAL, - 'user_ip' => $this->user->ip, - 'user_new' => ($this->config['new_member_post_limit']) ? 1 : 0, - ); - } - - /** - * {@inheritdoc} - */ - public function validate_session($user) - { - // Check if PHP_AUTH_USER is set and handle this case - if ($this->request->is_set('PHP_AUTH_USER', \phpbb\request\request_interface::SERVER)) - { - $php_auth_user = $this->request->server('PHP_AUTH_USER'); - - return ($php_auth_user === $user['username']) ? true : false; - } - - // PHP_AUTH_USER is not set. A valid session is now determined by the user type (anonymous/bot or not) - if ($user['user_type'] == USER_IGNORE) - { - return true; - } - - return false; - } -} diff --git a/install/update/old/phpbb/auth/provider/base.php b/install/update/old/phpbb/auth/provider/base.php deleted file mode 100644 index dea27cc..0000000 --- a/install/update/old/phpbb/auth/provider/base.php +++ /dev/null @@ -1,108 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\auth\provider; - -/** -* Base authentication provider class that all other providers should implement -*/ -abstract class base implements \phpbb\auth\provider\provider_interface -{ - /** - * {@inheritdoc} - */ - public function init() - { - return; - } - - /** - * {@inheritdoc} - */ - public function autologin() - { - return; - } - - /** - * {@inheritdoc} - */ - public function acp() - { - return; - } - - /** - * {@inheritdoc} - */ - public function get_acp_template($new_config) - { - return; - } - - /** - * {@inheritdoc} - */ - public function get_login_data() - { - return; - } - - /** - * {@inheritdoc} - */ - public function get_auth_link_data($user_id = 0) - { - return; - } - - /** - * {@inheritdoc} - */ - public function logout($data, $new_session) - { - return; - } - - /** - * {@inheritdoc} - */ - public function validate_session($user) - { - return; - } - - /** - * {@inheritdoc} - */ - public function login_link_has_necessary_data($login_link_data) - { - return; - } - - /** - * {@inheritdoc} - */ - public function link_account(array $link_data) - { - return; - } - - /** - * {@inheritdoc} - */ - public function unlink_account(array $link_data) - { - return; - } -} diff --git a/install/update/old/phpbb/auth/provider/db.php b/install/update/old/phpbb/auth/provider/db.php deleted file mode 100644 index 1adf85e..0000000 --- a/install/update/old/phpbb/auth/provider/db.php +++ /dev/null @@ -1,240 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\auth\provider; - -/** - * Database authentication provider for phpBB3 - * This is for authentication via the integrated user table - */ -class db extends \phpbb\auth\provider\base -{ - /** - * phpBB passwords manager - * - * @var \phpbb\passwords\manager - */ - protected $passwords_manager; - - /** - * DI container - * - * @var \Symfony\Component\DependencyInjection\ContainerInterface - */ - protected $phpbb_container; - - /** - * Database Authentication Constructor - * - * @param \phpbb\db\driver\driver_interface $db - * @param \phpbb\config\config $config - * @param \phpbb\passwords\manager $passwords_manager - * @param \phpbb\request\request $request - * @param \phpbb\user $user - * @param \Symfony\Component\DependencyInjection\ContainerInterface $phpbb_container DI container - * @param string $phpbb_root_path - * @param string $php_ext - */ - public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\passwords\manager $passwords_manager, \phpbb\request\request $request, \phpbb\user $user, \Symfony\Component\DependencyInjection\ContainerInterface $phpbb_container, $phpbb_root_path, $php_ext) - { - $this->db = $db; - $this->config = $config; - $this->passwords_manager = $passwords_manager; - $this->request = $request; - $this->user = $user; - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - $this->phpbb_container = $phpbb_container; - } - - /** - * {@inheritdoc} - */ - public function login($username, $password) - { - // Auth plugins get the password untrimmed. - // For compatibility we trim() here. - $password = trim($password); - - // do not allow empty password - if (!$password) - { - return array( - 'status' => LOGIN_ERROR_PASSWORD, - 'error_msg' => 'NO_PASSWORD_SUPPLIED', - 'user_row' => array('user_id' => ANONYMOUS), - ); - } - - if (!$username) - { - return array( - 'status' => LOGIN_ERROR_USERNAME, - 'error_msg' => 'LOGIN_ERROR_USERNAME', - 'user_row' => array('user_id' => ANONYMOUS), - ); - } - - $username_clean = utf8_clean_string($username); - - $sql = 'SELECT * - FROM ' . USERS_TABLE . " - WHERE username_clean = '" . $this->db->sql_escape($username_clean) . "'"; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if (($this->user->ip && !$this->config['ip_login_limit_use_forwarded']) || - ($this->user->forwarded_for && $this->config['ip_login_limit_use_forwarded'])) - { - $sql = 'SELECT COUNT(*) AS attempts - FROM ' . LOGIN_ATTEMPT_TABLE . ' - WHERE attempt_time > ' . (time() - (int) $this->config['ip_login_limit_time']); - if ($this->config['ip_login_limit_use_forwarded']) - { - $sql .= " AND attempt_forwarded_for = '" . $this->db->sql_escape($this->user->forwarded_for) . "'"; - } - else - { - $sql .= " AND attempt_ip = '" . $this->db->sql_escape($this->user->ip) . "' "; - } - - $result = $this->db->sql_query($sql); - $attempts = (int) $this->db->sql_fetchfield('attempts'); - $this->db->sql_freeresult($result); - - $attempt_data = array( - 'attempt_ip' => $this->user->ip, - 'attempt_browser' => trim(substr($this->user->browser, 0, 149)), - 'attempt_forwarded_for' => $this->user->forwarded_for, - 'attempt_time' => time(), - 'user_id' => ($row) ? (int) $row['user_id'] : 0, - 'username' => $username, - 'username_clean' => $username_clean, - ); - $sql = 'INSERT INTO ' . LOGIN_ATTEMPT_TABLE . $this->db->sql_build_array('INSERT', $attempt_data); - $this->db->sql_query($sql); - } - else - { - $attempts = 0; - } - - if (!$row) - { - if ($this->config['ip_login_limit_max'] && $attempts >= $this->config['ip_login_limit_max']) - { - return array( - 'status' => LOGIN_ERROR_ATTEMPTS, - 'error_msg' => 'LOGIN_ERROR_ATTEMPTS', - 'user_row' => array('user_id' => ANONYMOUS), - ); - } - - return array( - 'status' => LOGIN_ERROR_USERNAME, - 'error_msg' => 'LOGIN_ERROR_USERNAME', - 'user_row' => array('user_id' => ANONYMOUS), - ); - } - - $show_captcha = ($this->config['max_login_attempts'] && $row['user_login_attempts'] >= $this->config['max_login_attempts']) || - ($this->config['ip_login_limit_max'] && $attempts >= $this->config['ip_login_limit_max']); - - // If there are too many login attempts, we need to check for a confirm image - // Every auth module is able to define what to do by itself... - if ($show_captcha) - { - /* @var $captcha_factory \phpbb\captcha\factory */ - $captcha_factory = $this->phpbb_container->get('captcha.factory'); - $captcha = $captcha_factory->get_instance($this->config['captcha_plugin']); - $captcha->init(CONFIRM_LOGIN); - $vc_response = $captcha->validate($row); - if ($vc_response) - { - return array( - 'status' => LOGIN_ERROR_ATTEMPTS, - 'error_msg' => 'LOGIN_ERROR_ATTEMPTS', - 'user_row' => $row, - ); - } - else - { - $captcha->reset(); - } - - } - - // Check password ... - if ($this->passwords_manager->check($password, $row['user_password'], $row)) - { - // Check for old password hash... - if ($this->passwords_manager->convert_flag || strlen($row['user_password']) == 32) - { - $hash = $this->passwords_manager->hash($password); - - // Update the password in the users table to the new format - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_password = '" . $this->db->sql_escape($hash) . "' - WHERE user_id = {$row['user_id']}"; - $this->db->sql_query($sql); - - $row['user_password'] = $hash; - } - - $sql = 'DELETE FROM ' . LOGIN_ATTEMPT_TABLE . ' - WHERE user_id = ' . $row['user_id']; - $this->db->sql_query($sql); - - if ($row['user_login_attempts'] != 0) - { - // Successful, reset login attempts (the user passed all stages) - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_login_attempts = 0 - WHERE user_id = ' . $row['user_id']; - $this->db->sql_query($sql); - } - - // User inactive... - if ($row['user_type'] == USER_INACTIVE || $row['user_type'] == USER_IGNORE) - { - return array( - 'status' => LOGIN_ERROR_ACTIVE, - 'error_msg' => 'ACTIVE_ERROR', - 'user_row' => $row, - ); - } - - // Successful login... set user_login_attempts to zero... - return array( - 'status' => LOGIN_SUCCESS, - 'error_msg' => false, - 'user_row' => $row, - ); - } - - // Password incorrect - increase login attempts - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_login_attempts = user_login_attempts + 1 - WHERE user_id = ' . (int) $row['user_id'] . ' - AND user_login_attempts < ' . LOGIN_ATTEMPTS_MAX; - $this->db->sql_query($sql); - - // Give status about wrong password... - return array( - 'status' => ($show_captcha) ? LOGIN_ERROR_ATTEMPTS : LOGIN_ERROR_PASSWORD, - 'error_msg' => 'LOGIN_ERROR_PASSWORD', - 'user_row' => $row, - ); - } -} diff --git a/install/update/old/phpbb/auth/provider/ldap.php b/install/update/old/phpbb/auth/provider/ldap.php deleted file mode 100644 index 0789a62..0000000 --- a/install/update/old/phpbb/auth/provider/ldap.php +++ /dev/null @@ -1,348 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\auth\provider; - -/** - * Database authentication provider for phpBB3 - * This is for authentication via the integrated user table - */ -class ldap extends \phpbb\auth\provider\base -{ - /** - * phpBB passwords manager - * - * @var \phpbb\passwords\manager - */ - protected $passwords_manager; - - /** - * LDAP Authentication Constructor - * - * @param \phpbb\db\driver\driver_interface $db Database object - * @param \phpbb\config\config $config Config object - * @param \phpbb\passwords\manager $passwords_manager Passwords manager object - * @param \phpbb\user $user User object - */ - public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\passwords\manager $passwords_manager, \phpbb\user $user) - { - $this->db = $db; - $this->config = $config; - $this->passwords_manager = $passwords_manager; - $this->user = $user; - } - - /** - * {@inheritdoc} - */ - public function init() - { - if (!@extension_loaded('ldap')) - { - return $this->user->lang['LDAP_NO_LDAP_EXTENSION']; - } - - $this->config['ldap_port'] = (int) $this->config['ldap_port']; - if ($this->config['ldap_port']) - { - $ldap = @ldap_connect($this->config['ldap_server'], $this->config['ldap_port']); - } - else - { - $ldap = @ldap_connect($this->config['ldap_server']); - } - - if (!$ldap) - { - return $this->user->lang['LDAP_NO_SERVER_CONNECTION']; - } - - @ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3); - @ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0); - - if ($this->config['ldap_user'] || $this->config['ldap_password']) - { - if (!@ldap_bind($ldap, htmlspecialchars_decode($this->config['ldap_user']), htmlspecialchars_decode($this->config['ldap_password']))) - { - return $this->user->lang['LDAP_INCORRECT_USER_PASSWORD']; - } - } - - // ldap_connect only checks whether the specified server is valid, so the connection might still fail - $search = @ldap_search( - $ldap, - htmlspecialchars_decode($this->config['ldap_base_dn']), - $this->ldap_user_filter($this->user->data['username']), - (empty($this->config['ldap_email'])) ? - array(htmlspecialchars_decode($this->config['ldap_uid'])) : - array(htmlspecialchars_decode($this->config['ldap_uid']), htmlspecialchars_decode($this->config['ldap_email'])), - 0, - 1 - ); - - if ($search === false) - { - return $this->user->lang['LDAP_SEARCH_FAILED']; - } - - $result = @ldap_get_entries($ldap, $search); - - @ldap_close($ldap); - - if (!is_array($result) || count($result) < 2) - { - return sprintf($this->user->lang['LDAP_NO_IDENTITY'], $this->user->data['username']); - } - - if (!empty($this->config['ldap_email']) && !isset($result[0][htmlspecialchars_decode($this->config['ldap_email'])])) - { - return $this->user->lang['LDAP_NO_EMAIL']; - } - - return false; - } - - /** - * {@inheritdoc} - */ - public function login($username, $password) - { - // do not allow empty password - if (!$password) - { - return array( - 'status' => LOGIN_ERROR_PASSWORD, - 'error_msg' => 'NO_PASSWORD_SUPPLIED', - 'user_row' => array('user_id' => ANONYMOUS), - ); - } - - if (!$username) - { - return array( - 'status' => LOGIN_ERROR_USERNAME, - 'error_msg' => 'LOGIN_ERROR_USERNAME', - 'user_row' => array('user_id' => ANONYMOUS), - ); - } - - if (!@extension_loaded('ldap')) - { - return array( - 'status' => LOGIN_ERROR_EXTERNAL_AUTH, - 'error_msg' => 'LDAP_NO_LDAP_EXTENSION', - 'user_row' => array('user_id' => ANONYMOUS), - ); - } - - $this->config['ldap_port'] = (int) $this->config['ldap_port']; - if ($this->config['ldap_port']) - { - $ldap = @ldap_connect($this->config['ldap_server'], $this->config['ldap_port']); - } - else - { - $ldap = @ldap_connect($this->config['ldap_server']); - } - - if (!$ldap) - { - return array( - 'status' => LOGIN_ERROR_EXTERNAL_AUTH, - 'error_msg' => 'LDAP_NO_SERVER_CONNECTION', - 'user_row' => array('user_id' => ANONYMOUS), - ); - } - - @ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3); - @ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0); - - if ($this->config['ldap_user'] || $this->config['ldap_password']) - { - if (!@ldap_bind($ldap, htmlspecialchars_decode($this->config['ldap_user']), htmlspecialchars_decode($this->config['ldap_password']))) - { - return array( - 'status' => LOGIN_ERROR_EXTERNAL_AUTH, - 'error_msg' => 'LDAP_NO_SERVER_CONNECTION', - 'user_row' => array('user_id' => ANONYMOUS), - ); - } - } - - $search = @ldap_search( - $ldap, - htmlspecialchars_decode($this->config['ldap_base_dn']), - $this->ldap_user_filter($username), - (empty($this->config['ldap_email'])) ? - array(htmlspecialchars_decode($this->config['ldap_uid'])) : - array(htmlspecialchars_decode($this->config['ldap_uid']), htmlspecialchars_decode($this->config['ldap_email'])), - 0, - 1 - ); - - $ldap_result = @ldap_get_entries($ldap, $search); - - if (is_array($ldap_result) && count($ldap_result) > 1) - { - if (@ldap_bind($ldap, $ldap_result[0]['dn'], htmlspecialchars_decode($password))) - { - @ldap_close($ldap); - - $sql ='SELECT user_id, username, user_password, user_passchg, user_email, user_type - FROM ' . USERS_TABLE . " - WHERE username_clean = '" . $this->db->sql_escape(utf8_clean_string($username)) . "'"; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if ($row) - { - unset($ldap_result); - - // User inactive... - if ($row['user_type'] == USER_INACTIVE || $row['user_type'] == USER_IGNORE) - { - return array( - 'status' => LOGIN_ERROR_ACTIVE, - 'error_msg' => 'ACTIVE_ERROR', - 'user_row' => $row, - ); - } - - // Successful login... set user_login_attempts to zero... - return array( - 'status' => LOGIN_SUCCESS, - 'error_msg' => false, - 'user_row' => $row, - ); - } - else - { - // retrieve default group id - $sql = 'SELECT group_id - FROM ' . GROUPS_TABLE . " - WHERE group_name = '" . $this->db->sql_escape('REGISTERED') . "' - AND group_type = " . GROUP_SPECIAL; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if (!$row) - { - trigger_error('NO_GROUP'); - } - - // generate user account data - $ldap_user_row = array( - 'username' => $username, - 'user_password' => $this->passwords_manager->hash($password), - 'user_email' => (!empty($this->config['ldap_email'])) ? utf8_htmlspecialchars($ldap_result[0][htmlspecialchars_decode($this->config['ldap_email'])][0]) : '', - 'group_id' => (int) $row['group_id'], - 'user_type' => USER_NORMAL, - 'user_ip' => $this->user->ip, - 'user_new' => ($this->config['new_member_post_limit']) ? 1 : 0, - ); - - unset($ldap_result); - - // this is the user's first login so create an empty profile - return array( - 'status' => LOGIN_SUCCESS_CREATE_PROFILE, - 'error_msg' => false, - 'user_row' => $ldap_user_row, - ); - } - } - else - { - unset($ldap_result); - @ldap_close($ldap); - - // Give status about wrong password... - return array( - 'status' => LOGIN_ERROR_PASSWORD, - 'error_msg' => 'LOGIN_ERROR_PASSWORD', - 'user_row' => array('user_id' => ANONYMOUS), - ); - } - } - - @ldap_close($ldap); - - return array( - 'status' => LOGIN_ERROR_USERNAME, - 'error_msg' => 'LOGIN_ERROR_USERNAME', - 'user_row' => array('user_id' => ANONYMOUS), - ); - } - - /** - * {@inheritdoc} - */ - public function acp() - { - // These are fields required in the config table - return array( - 'ldap_server', 'ldap_port', 'ldap_base_dn', 'ldap_uid', 'ldap_user_filter', 'ldap_email', 'ldap_user', 'ldap_password', - ); - } - - /** - * {@inheritdoc} - */ - public function get_acp_template($new_config) - { - return array( - 'TEMPLATE_FILE' => 'auth_provider_ldap.html', - 'TEMPLATE_VARS' => array( - 'AUTH_LDAP_BASE_DN' => $new_config['ldap_base_dn'], - 'AUTH_LDAP_EMAIL' => $new_config['ldap_email'], - 'AUTH_LDAP_PASSORD' => $new_config['ldap_password'] !== '' ? '********' : '', - 'AUTH_LDAP_PORT' => $new_config['ldap_port'], - 'AUTH_LDAP_SERVER' => $new_config['ldap_server'], - 'AUTH_LDAP_UID' => $new_config['ldap_uid'], - 'AUTH_LDAP_USER' => $new_config['ldap_user'], - 'AUTH_LDAP_USER_FILTER' => $new_config['ldap_user_filter'], - ), - ); - } - - /** - * Generates a filter string for ldap_search to find a user - * - * @param $username string Username identifying the searched user - * - * @return string A filter string for ldap_search - */ - private function ldap_user_filter($username) - { - $filter = '(' . $this->config['ldap_uid'] . '=' . $this->ldap_escape(htmlspecialchars_decode($username)) . ')'; - if ($this->config['ldap_user_filter']) - { - $_filter = ($this->config['ldap_user_filter'][0] == '(' && substr($this->config['ldap_user_filter'], -1) == ')') ? $this->config['ldap_user_filter'] : "({$this->config['ldap_user_filter']})"; - $filter = "(&{$filter}{$_filter})"; - } - return $filter; - } - - /** - * Escapes an LDAP AttributeValue - * - * @param string $string The string to be escaped - * @return string The escaped string - */ - private function ldap_escape($string) - { - return str_replace(array('*', '\\', '(', ')'), array('\\*', '\\\\', '\\(', '\\)'), $string); - } -} diff --git a/install/update/old/phpbb/auth/provider/oauth/oauth.php b/install/update/old/phpbb/auth/provider/oauth/oauth.php deleted file mode 100644 index 93419d2..0000000 --- a/install/update/old/phpbb/auth/provider/oauth/oauth.php +++ /dev/null @@ -1,747 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\auth\provider\oauth; - -use OAuth\Common\Consumer\Credentials; - -/** -* OAuth authentication provider for phpBB3 -*/ -class oauth extends \phpbb\auth\provider\base -{ - /** - * Database driver - * - * @var \phpbb\db\driver\driver_interface - */ - protected $db; - - /** - * phpBB config - * - * @var \phpbb\config\config - */ - protected $config; - - /** - * phpBB passwords manager - * - * @var \phpbb\passwords\manager - */ - protected $passwords_manager; - - /** - * phpBB request object - * - * @var \phpbb\request\request_interface - */ - protected $request; - - /** - * phpBB user - * - * @var \phpbb\user - */ - protected $user; - - /** - * OAuth token table - * - * @var string - */ - protected $auth_provider_oauth_token_storage_table; - - /** - * OAuth state table - * - * @var string - */ - protected $auth_provider_oauth_state_table; - - /** - * OAuth account association table - * - * @var string - */ - protected $auth_provider_oauth_token_account_assoc; - - /** - * All OAuth service providers - * - * @var \phpbb\di\service_collection Contains \phpbb\auth\provider\oauth\service_interface - */ - protected $service_providers; - - /** - * Users table - * - * @var string - */ - protected $users_table; - - /** - * Cached current uri object - * - * @var \OAuth\Common\Http\Uri\UriInterface|null - */ - protected $current_uri; - - /** - * DI container - * - * @var \Symfony\Component\DependencyInjection\ContainerInterface - */ - protected $phpbb_container; - - /** - * phpBB event dispatcher - * - * @var \phpbb\event\dispatcher_interface - */ - protected $dispatcher; - - /** - * phpBB root path - * - * @var string - */ - protected $phpbb_root_path; - - /** - * PHP file extension - * - * @var string - */ - protected $php_ext; - - /** - * OAuth Authentication Constructor - * - * @param \phpbb\db\driver\driver_interface $db - * @param \phpbb\config\config $config - * @param \phpbb\passwords\manager $passwords_manager - * @param \phpbb\request\request_interface $request - * @param \phpbb\user $user - * @param string $auth_provider_oauth_token_storage_table - * @param string $auth_provider_oauth_state_table - * @param string $auth_provider_oauth_token_account_assoc - * @param \phpbb\di\service_collection $service_providers Contains \phpbb\auth\provider\oauth\service_interface - * @param string $users_table - * @param \Symfony\Component\DependencyInjection\ContainerInterface $phpbb_container DI container - * @param \phpbb\event\dispatcher_interface $dispatcher phpBB event dispatcher - * @param string $phpbb_root_path - * @param string $php_ext - */ - public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\passwords\manager $passwords_manager, \phpbb\request\request_interface $request, \phpbb\user $user, $auth_provider_oauth_token_storage_table, $auth_provider_oauth_state_table, $auth_provider_oauth_token_account_assoc, \phpbb\di\service_collection $service_providers, $users_table, \Symfony\Component\DependencyInjection\ContainerInterface $phpbb_container, \phpbb\event\dispatcher_interface $dispatcher, $phpbb_root_path, $php_ext) - { - $this->db = $db; - $this->config = $config; - $this->passwords_manager = $passwords_manager; - $this->request = $request; - $this->user = $user; - $this->auth_provider_oauth_token_storage_table = $auth_provider_oauth_token_storage_table; - $this->auth_provider_oauth_state_table = $auth_provider_oauth_state_table; - $this->auth_provider_oauth_token_account_assoc = $auth_provider_oauth_token_account_assoc; - $this->service_providers = $service_providers; - $this->users_table = $users_table; - $this->phpbb_container = $phpbb_container; - $this->dispatcher = $dispatcher; - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - } - - /** - * {@inheritdoc} - */ - public function init() - { - // This does not test whether or not the key and secret provided are valid. - foreach ($this->service_providers as $service_provider) - { - $credentials = $service_provider->get_service_credentials(); - - if (($credentials['key'] && !$credentials['secret']) || (!$credentials['key'] && $credentials['secret'])) - { - return $this->user->lang['AUTH_PROVIDER_OAUTH_ERROR_ELEMENT_MISSING']; - } - } - return false; - } - - /** - * {@inheritdoc} - */ - public function login($username, $password) - { - // Temporary workaround for only having one authentication provider available - if (!$this->request->is_set('oauth_service')) - { - $provider = new \phpbb\auth\provider\db($this->db, $this->config, $this->passwords_manager, $this->request, $this->user, $this->phpbb_container, $this->phpbb_root_path, $this->php_ext); - return $provider->login($username, $password); - } - - // Request the name of the OAuth service - $service_name_original = $this->request->variable('oauth_service', '', false); - $service_name = 'auth.provider.oauth.service.' . strtolower($service_name_original); - if ($service_name_original === '' || !array_key_exists($service_name, $this->service_providers)) - { - return array( - 'status' => LOGIN_ERROR_EXTERNAL_AUTH, - 'error_msg' => 'LOGIN_ERROR_OAUTH_SERVICE_DOES_NOT_EXIST', - 'user_row' => array('user_id' => ANONYMOUS), - ); - } - - // Get the service credentials for the given service - $service_credentials = $this->service_providers[$service_name]->get_service_credentials(); - - $storage = new \phpbb\auth\provider\oauth\token_storage($this->db, $this->user, $this->auth_provider_oauth_token_storage_table, $this->auth_provider_oauth_state_table); - $query = 'mode=login&login=external&oauth_service=' . $service_name_original; - $service = $this->get_service($service_name_original, $storage, $service_credentials, $query, $this->service_providers[$service_name]->get_auth_scope()); - - if (($service::OAUTH_VERSION === 2 && $this->request->is_set('code', \phpbb\request\request_interface::GET)) - || ($service::OAUTH_VERSION === 1 && $this->request->is_set('oauth_token', \phpbb\request\request_interface::GET))) - { - $this->service_providers[$service_name]->set_external_service_provider($service); - $unique_id = $this->service_providers[$service_name]->perform_auth_login(); - - // Check to see if this provider is already assosciated with an account - $data = array( - 'provider' => $service_name_original, - 'oauth_provider_id' => $unique_id - ); - - $sql = 'SELECT user_id FROM ' . $this->auth_provider_oauth_token_account_assoc . ' - WHERE ' . $this->db->sql_build_array('SELECT', $data); - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - $redirect_data = array( - 'auth_provider' => 'oauth', - 'login_link_oauth_service' => $service_name_original, - ); - - /** - * Event is triggered before check if provider is already associated with an account - * - * @event core.oauth_login_after_check_if_provider_id_has_match - * @var array row User row - * @var array data Provider data - * @var array redirect_data Data to be appended to the redirect url - * @var \OAuth\Common\Service\ServiceInterface service OAuth service - * @since 3.2.3-RC1 - * @changed 3.2.6-RC1 Added redirect_data - */ - $vars = array( - 'row', - 'data', - 'redirect_data', - 'service', - ); - extract($this->dispatcher->trigger_event('core.oauth_login_after_check_if_provider_id_has_match', compact($vars))); - - if (!$row) - { - // The user does not yet exist, ask to link or create profile - return array( - 'status' => LOGIN_SUCCESS_LINK_PROFILE, - 'error_msg' => 'LOGIN_OAUTH_ACCOUNT_NOT_LINKED', - 'user_row' => array(), - 'redirect_data' => $redirect_data, - ); - } - - // Retrieve the user's account - $sql = 'SELECT user_id, username, user_password, user_passchg, user_email, user_type, user_login_attempts - FROM ' . $this->users_table . ' - WHERE user_id = ' . (int) $row['user_id']; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if (!$row) - { - throw new \Exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_ENTRY'); - } - - /** - * Check if the user is banned. - * The fourth parameter, return, has to be true, - * otherwise the OAuth login is still called and - * an uncaught exception is thrown as there is no - * token stored in the database. - */ - $ban = $this->user->check_ban($row['user_id'], $row['user_ip'], $row['user_email'], true); - if (!empty($ban)) - { - $till_date = !empty($ban['ban_end']) ? $this->user->format_date($ban['ban_end']) : ''; - $message = !empty($ban['ban_end']) ? 'BOARD_BAN_TIME' : 'BOARD_BAN_PERM'; - - $contact_link = phpbb_get_board_contact_link($this->config, $this->phpbb_root_path, $this->php_ext); - $message = $this->user->lang($message, $till_date, '', ''); - $message .= !empty($ban['ban_give_reason']) ? '

' . $this->user->lang('BOARD_BAN_REASON', $ban['ban_give_reason']) : ''; - $message .= !empty($ban['ban_triggered_by']) ? '

' . $this->user->lang('BAN_TRIGGERED_BY_' . strtoupper($ban['ban_triggered_by'])) . '' : ''; - - return array( - 'status' => LOGIN_BREAK, - 'error_msg' => $message, - 'user_row' => $row, - ); - } - - // Update token storage to store the user_id - $storage->set_user_id($row['user_id']); - - /** - * Event is triggered after user is successfully logged in via OAuth. - * - * @event core.auth_oauth_login_after - * @var array row User row - * @since 3.1.11-RC1 - */ - $vars = array( - 'row', - ); - extract($this->dispatcher->trigger_event('core.auth_oauth_login_after', compact($vars))); - - // The user is now authenticated and can be logged in - return array( - 'status' => LOGIN_SUCCESS, - 'error_msg' => false, - 'user_row' => $row, - ); - } - else - { - if ($service::OAUTH_VERSION === 1) - { - $token = $service->requestRequestToken(); - $url = $service->getAuthorizationUri(array('oauth_token' => $token->getRequestToken())); - } - else - { - $url = $service->getAuthorizationUri(); - } - header('Location: ' . $url); - } - } - - /** - * Returns the cached current_uri object or creates and caches it if it is - * not already created. In each case the query string is updated based on - * the $query parameter. - * - * @param string $service_name The name of the service - * @param string $query The query string of the current_uri - * used in redirects - * @return \OAuth\Common\Http\Uri\UriInterface - */ - protected function get_current_uri($service_name, $query) - { - if ($this->current_uri) - { - $this->current_uri->setQuery($query); - return $this->current_uri; - } - - $uri_factory = new \OAuth\Common\Http\Uri\UriFactory(); - $super_globals = $this->request->get_super_global(\phpbb\request\request_interface::SERVER); - if (!empty($super_globals['HTTP_X_FORWARDED_PROTO']) && $super_globals['HTTP_X_FORWARDED_PROTO'] === 'https') - { - $super_globals['HTTPS'] = 'on'; - $super_globals['SERVER_PORT'] = 443; - } - $current_uri = $uri_factory->createFromSuperGlobalArray($super_globals); - $current_uri->setQuery($query); - - $this->current_uri = $current_uri; - return $current_uri; - } - - /** - * Returns a new service object - * - * @param string $service_name The name of the service - * @param \phpbb\auth\provider\oauth\token_storage $storage - * @param array $service_credentials {@see \phpbb\auth\provider\oauth\oauth::get_service_credentials} - * @param string $query The query string of the - * current_uri used in redirection - * @param array $scopes The scope of the request against - * the api. - * @return \OAuth\Common\Service\ServiceInterface - * @throws \Exception - */ - protected function get_service($service_name, \phpbb\auth\provider\oauth\token_storage $storage, array $service_credentials, $query, array $scopes = array()) - { - $current_uri = $this->get_current_uri($service_name, $query); - - // Setup the credentials for the requests - $credentials = new Credentials( - $service_credentials['key'], - $service_credentials['secret'], - $current_uri->getAbsoluteUri() - ); - - $service_factory = new \OAuth\ServiceFactory(); - $service = $service_factory->createService($service_name, $credentials, $storage, $scopes); - - if (!$service) - { - throw new \Exception('AUTH_PROVIDER_OAUTH_ERROR_SERVICE_NOT_CREATED'); - } - - return $service; - } - - /** - * {@inheritdoc} - */ - public function get_login_data() - { - $login_data = array( - 'TEMPLATE_FILE' => 'login_body_oauth.html', - 'BLOCK_VAR_NAME' => 'oauth', - 'BLOCK_VARS' => array(), - ); - - foreach ($this->service_providers as $service_name => $service_provider) - { - // Only include data if the credentials are set - $credentials = $service_provider->get_service_credentials(); - if ($credentials['key'] && $credentials['secret']) - { - $actual_name = str_replace('auth.provider.oauth.service.', '', $service_name); - $redirect_url = build_url(false) . '&login=external&oauth_service=' . $actual_name; - $login_data['BLOCK_VARS'][$service_name] = array( - 'REDIRECT_URL' => redirect($redirect_url, true), - 'SERVICE_NAME' => $this->user->lang['AUTH_PROVIDER_OAUTH_SERVICE_' . strtoupper($actual_name)], - ); - } - } - - return $login_data; - } - - /** - * {@inheritdoc} - */ - public function acp() - { - $ret = array(); - - foreach ($this->service_providers as $service_name => $service_provider) - { - $actual_name = str_replace('auth.provider.oauth.service.', '', $service_name); - $ret[] = 'auth_oauth_' . $actual_name . '_key'; - $ret[] = 'auth_oauth_' . $actual_name . '_secret'; - } - - return $ret; - } - - /** - * {@inheritdoc} - */ - public function get_acp_template($new_config) - { - $ret = array( - 'BLOCK_VAR_NAME' => 'oauth_services', - 'BLOCK_VARS' => array(), - 'TEMPLATE_FILE' => 'auth_provider_oauth.html', - 'TEMPLATE_VARS' => array(), - ); - - foreach ($this->service_providers as $service_name => $service_provider) - { - $actual_name = str_replace('auth.provider.oauth.service.', '', $service_name); - $ret['BLOCK_VARS'][$actual_name] = array( - 'ACTUAL_NAME' => $this->user->lang['AUTH_PROVIDER_OAUTH_SERVICE_' . strtoupper($actual_name)], - 'KEY' => $new_config['auth_oauth_' . $actual_name . '_key'], - 'NAME' => $actual_name, - 'SECRET' => $new_config['auth_oauth_' . $actual_name . '_secret'], - ); - } - - return $ret; - } - - /** - * {@inheritdoc} - */ - public function login_link_has_necessary_data($login_link_data) - { - if (empty($login_link_data)) - { - return 'LOGIN_LINK_NO_DATA_PROVIDED'; - } - - if (!array_key_exists('oauth_service', $login_link_data) || !$login_link_data['oauth_service'] || - !array_key_exists('link_method', $login_link_data) || !$login_link_data['link_method']) - { - return 'LOGIN_LINK_MISSING_DATA'; - } - - return null; - } - - /** - * {@inheritdoc} - */ - public function link_account(array $link_data) - { - // Check for a valid link method (auth_link or login_link) - if (!array_key_exists('link_method', $link_data) || - !in_array($link_data['link_method'], array( - 'auth_link', - 'login_link', - ))) - { - return 'LOGIN_LINK_MISSING_DATA'; - } - - // We must have an oauth_service listed, check for it two ways - if (!array_key_exists('oauth_service', $link_data) || !$link_data['oauth_service']) - { - $link_data['oauth_service'] = $this->request->variable('oauth_service', ''); - - if (!$link_data['oauth_service']) - { - return 'LOGIN_LINK_MISSING_DATA'; - } - } - - $service_name = 'auth.provider.oauth.service.' . strtolower($link_data['oauth_service']); - if (!array_key_exists($service_name, $this->service_providers)) - { - return 'LOGIN_ERROR_OAUTH_SERVICE_DOES_NOT_EXIST'; - } - - switch ($link_data['link_method']) - { - case 'auth_link': - return $this->link_account_auth_link($link_data, $service_name); - case 'login_link': - return $this->link_account_login_link($link_data, $service_name); - } - } - - /** - * Performs the account linking for login_link - * - * @param array $link_data The same variable given to {@see \phpbb\auth\provider\provider_interface::link_account} - * @param string $service_name The name of the service being used in - * linking. - * @return string|null Returns a language constant (string) if an error is - * encountered, or null on success. - */ - protected function link_account_login_link(array $link_data, $service_name) - { - $storage = new \phpbb\auth\provider\oauth\token_storage($this->db, $this->user, $this->auth_provider_oauth_token_storage_table, $this->auth_provider_oauth_state_table); - - // Check for an access token, they should have one - if (!$storage->has_access_token_by_session($service_name)) - { - return 'LOGIN_LINK_ERROR_OAUTH_NO_ACCESS_TOKEN'; - } - - // Prepare the query string - $query = 'mode=login_link&login_link_oauth_service=' . strtolower($link_data['oauth_service']); - - // Prepare for an authentication request - $service_credentials = $this->service_providers[$service_name]->get_service_credentials(); - $scopes = $this->service_providers[$service_name]->get_auth_scope(); - $service = $this->get_service(strtolower($link_data['oauth_service']), $storage, $service_credentials, $query, $scopes); - $this->service_providers[$service_name]->set_external_service_provider($service); - - // The user has already authenticated successfully, request to authenticate again - $unique_id = $this->service_providers[$service_name]->perform_token_auth(); - - // Insert into table, they will be able to log in after this - $data = array( - 'user_id' => $link_data['user_id'], - 'provider' => strtolower($link_data['oauth_service']), - 'oauth_provider_id' => $unique_id, - ); - - $this->link_account_perform_link($data); - // Update token storage to store the user_id - $storage->set_user_id($link_data['user_id']); - } - - /** - * Performs the account linking for auth_link - * - * @param array $link_data The same variable given to {@see \phpbb\auth\provider\provider_interface::link_account} - * @param string $service_name The name of the service being used in - * linking. - * @return string|null Returns a language constant (string) if an error is - * encountered, or null on success. - */ - protected function link_account_auth_link(array $link_data, $service_name) - { - $storage = new \phpbb\auth\provider\oauth\token_storage($this->db, $this->user, $this->auth_provider_oauth_token_storage_table, $this->auth_provider_oauth_state_table); - $query = 'i=ucp_auth_link&mode=auth_link&link=1&oauth_service=' . strtolower($link_data['oauth_service']); - $service_credentials = $this->service_providers[$service_name]->get_service_credentials(); - $scopes = $this->service_providers[$service_name]->get_auth_scope(); - $service = $this->get_service(strtolower($link_data['oauth_service']), $storage, $service_credentials, $query, $scopes); - - if (($service::OAUTH_VERSION === 2 && $this->request->is_set('code', \phpbb\request\request_interface::GET)) - || ($service::OAUTH_VERSION === 1 && $this->request->is_set('oauth_token', \phpbb\request\request_interface::GET))) - { - $this->service_providers[$service_name]->set_external_service_provider($service); - $unique_id = $this->service_providers[$service_name]->perform_auth_login(); - - // Insert into table, they will be able to log in after this - $data = array( - 'user_id' => $this->user->data['user_id'], - 'provider' => strtolower($link_data['oauth_service']), - 'oauth_provider_id' => $unique_id, - ); - - $this->link_account_perform_link($data); - } - else - { - if ($service::OAUTH_VERSION === 1) - { - $token = $service->requestRequestToken(); - $url = $service->getAuthorizationUri(array('oauth_token' => $token->getRequestToken())); - } - else - { - $url = $service->getAuthorizationUri(); - } - header('Location: ' . $url); - } - } - - /** - * Performs the query that inserts an account link - * - * @param array $data This array is passed to db->sql_build_array - */ - protected function link_account_perform_link(array $data) - { - $sql = 'INSERT INTO ' . $this->auth_provider_oauth_token_account_assoc . ' - ' . $this->db->sql_build_array('INSERT', $data); - $this->db->sql_query($sql); - - /** - * Event is triggered after user links account. - * - * @event core.auth_oauth_link_after - * @var array data User row - * @since 3.1.11-RC1 - */ - $vars = array( - 'data', - ); - extract($this->dispatcher->trigger_event('core.auth_oauth_link_after', compact($vars))); - } - - /** - * {@inheritdoc} - */ - public function logout($data, $new_session) - { - // Clear all tokens belonging to the user - $storage = new \phpbb\auth\provider\oauth\token_storage($this->db, $this->user, $this->auth_provider_oauth_token_storage_table, $this->auth_provider_oauth_state_table); - $storage->clearAllTokens(); - - return; - } - - /** - * {@inheritdoc} - */ - public function get_auth_link_data($user_id = 0) - { - $block_vars = array(); - - // Get all external accounts tied to the current user - $data = array( - 'user_id' => ($user_id <= 0) ? (int) $this->user->data['user_id'] : (int) $user_id, - ); - $sql = 'SELECT oauth_provider_id, provider FROM ' . $this->auth_provider_oauth_token_account_assoc . ' - WHERE ' . $this->db->sql_build_array('SELECT', $data); - $result = $this->db->sql_query($sql); - $rows = $this->db->sql_fetchrowset($result); - $this->db->sql_freeresult($result); - - $oauth_user_ids = array(); - - if ($rows !== false && count($rows)) - { - foreach ($rows as $row) - { - $oauth_user_ids[$row['provider']] = $row['oauth_provider_id']; - } - } - unset($rows); - - foreach ($this->service_providers as $service_name => $service_provider) - { - // Only include data if the credentials are set - $credentials = $service_provider->get_service_credentials(); - if ($credentials['key'] && $credentials['secret']) - { - $actual_name = str_replace('auth.provider.oauth.service.', '', $service_name); - - $block_vars[$service_name] = array( - 'HIDDEN_FIELDS' => array( - 'link' => (!isset($oauth_user_ids[$actual_name])), - 'oauth_service' => $actual_name, - ), - - 'SERVICE_ID' => $actual_name, - 'SERVICE_NAME' => $this->user->lang['AUTH_PROVIDER_OAUTH_SERVICE_' . strtoupper($actual_name)], - 'UNIQUE_ID' => (isset($oauth_user_ids[$actual_name])) ? $oauth_user_ids[$actual_name] : null, - ); - } - } - - return array( - 'BLOCK_VAR_NAME' => 'oauth', - 'BLOCK_VARS' => $block_vars, - - 'TEMPLATE_FILE' => 'ucp_auth_link_oauth.html', - ); - } - - /** - * {@inheritdoc} - */ - public function unlink_account(array $link_data) - { - if (!array_key_exists('oauth_service', $link_data) || !$link_data['oauth_service']) - { - return 'LOGIN_LINK_MISSING_DATA'; - } - - // Remove user specified in $link_data if possible - $user_id = isset($link_data['user_id']) ? $link_data['user_id'] : $this->user->data['user_id']; - - // Remove the link - $sql = 'DELETE FROM ' . $this->auth_provider_oauth_token_account_assoc . " - WHERE provider = '" . $this->db->sql_escape($link_data['oauth_service']) . "' - AND user_id = " . (int) $user_id; - $this->db->sql_query($sql); - - // Clear all tokens belonging to the user on this service - $service_name = 'auth.provider.oauth.service.' . strtolower($link_data['oauth_service']); - $storage = new \phpbb\auth\provider\oauth\token_storage($this->db, $this->user, $this->auth_provider_oauth_token_storage_table, $this->auth_provider_oauth_state_table); - $storage->clearToken($service_name); - } -} diff --git a/install/update/old/phpbb/auth/provider/oauth/service/base.php b/install/update/old/phpbb/auth/provider/oauth/service/base.php deleted file mode 100644 index 6adf64a..0000000 --- a/install/update/old/phpbb/auth/provider/oauth/service/base.php +++ /dev/null @@ -1,51 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\auth\provider\oauth\service; - -/** -* Base OAuth abstract class that all OAuth services should implement -*/ -abstract class base implements \phpbb\auth\provider\oauth\service\service_interface -{ - /** - * External OAuth service provider - * - * @var \OAuth\Common\Service\ServiceInterface - */ - protected $service_provider; - - /** - * {@inheritdoc} - */ - public function get_external_service_provider() - { - return $this->service_provider; - } - - /** - * {@inheritdoc} - */ - public function get_auth_scope() - { - return array(); - } - - /** - * {@inheritdoc} - */ - public function set_external_service_provider(\OAuth\Common\Service\ServiceInterface $service_provider) - { - $this->service_provider = $service_provider; - } -} diff --git a/install/update/old/phpbb/auth/provider/oauth/service/bitly.php b/install/update/old/phpbb/auth/provider/oauth/service/bitly.php deleted file mode 100644 index 25e731a..0000000 --- a/install/update/old/phpbb/auth/provider/oauth/service/bitly.php +++ /dev/null @@ -1,94 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\auth\provider\oauth\service; - -/** -* Bitly OAuth service -*/ -class bitly extends \phpbb\auth\provider\oauth\service\base -{ - /** - * phpBB config - * - * @var \phpbb\config\config - */ - protected $config; - - /** - * phpBB request - * - * @var \phpbb\request\request_interface - */ - protected $request; - - /** - * Constructor - * - * @param \phpbb\config\config $config - * @param \phpbb\request\request_interface $request - */ - public function __construct(\phpbb\config\config $config, \phpbb\request\request_interface $request) - { - $this->config = $config; - $this->request = $request; - } - - /** - * {@inheritdoc} - */ - public function get_service_credentials() - { - return array( - 'key' => $this->config['auth_oauth_bitly_key'], - 'secret' => $this->config['auth_oauth_bitly_secret'], - ); - } - - /** - * {@inheritdoc} - */ - public function perform_auth_login() - { - if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Bitly)) - { - throw new \phpbb\auth\provider\oauth\service\exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); - } - - // This was a callback request from bitly, get the token - $this->service_provider->requestAccessToken($this->request->variable('code', '')); - - // Send a request with it - $result = json_decode($this->service_provider->request('user/info'), true); - - // Return the unique identifier returned from bitly - return $result['data']['login']; - } - - /** - * {@inheritdoc} - */ - public function perform_token_auth() - { - if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Bitly)) - { - throw new \phpbb\auth\provider\oauth\service\exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); - } - - // Send a request with it - $result = json_decode($this->service_provider->request('user/info'), true); - - // Return the unique identifier returned from bitly - return $result['data']['login']; - } -} diff --git a/install/update/old/phpbb/auth/provider/oauth/service/facebook.php b/install/update/old/phpbb/auth/provider/oauth/service/facebook.php deleted file mode 100644 index bb98835..0000000 --- a/install/update/old/phpbb/auth/provider/oauth/service/facebook.php +++ /dev/null @@ -1,94 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\auth\provider\oauth\service; - -/** -* Facebook OAuth service -*/ -class facebook extends base -{ - /** - * phpBB config - * - * @var \phpbb\config\config - */ - protected $config; - - /** - * phpBB request - * - * @var \phpbb\request\request_interface - */ - protected $request; - - /** - * Constructor - * - * @param \phpbb\config\config $config - * @param \phpbb\request\request_interface $request - */ - public function __construct(\phpbb\config\config $config, \phpbb\request\request_interface $request) - { - $this->config = $config; - $this->request = $request; - } - - /** - * {@inheritdoc} - */ - public function get_service_credentials() - { - return array( - 'key' => $this->config['auth_oauth_facebook_key'], - 'secret' => $this->config['auth_oauth_facebook_secret'], - ); - } - - /** - * {@inheritdoc} - */ - public function perform_auth_login() - { - if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Facebook)) - { - throw new exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); - } - - // This was a callback request, get the token - $this->service_provider->requestAccessToken($this->request->variable('code', '')); - - // Send a request with it - $result = json_decode($this->service_provider->request('/me'), true); - - // Return the unique identifier - return $result['id']; - } - - /** - * {@inheritdoc} - */ - public function perform_token_auth() - { - if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Facebook)) - { - throw new exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); - } - - // Send a request with it - $result = json_decode($this->service_provider->request('/me'), true); - - // Return the unique identifier - return $result['id']; - } -} diff --git a/install/update/old/phpbb/auth/provider/oauth/service/google.php b/install/update/old/phpbb/auth/provider/oauth/service/google.php deleted file mode 100644 index cb9f83a..0000000 --- a/install/update/old/phpbb/auth/provider/oauth/service/google.php +++ /dev/null @@ -1,105 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\auth\provider\oauth\service; - -/** -* Google OAuth service -*/ -class google extends base -{ - /** - * phpBB config - * - * @var \phpbb\config\config - */ - protected $config; - - /** - * phpBB request - * - * @var \phpbb\request\request_interface - */ - protected $request; - - /** - * Constructor - * - * @param \phpbb\config\config $config - * @param \phpbb\request\request_interface $request - */ - public function __construct(\phpbb\config\config $config, \phpbb\request\request_interface $request) - { - $this->config = $config; - $this->request = $request; - } - - /** - * {@inheritdoc} - */ - public function get_auth_scope() - { - return array( - 'userinfo_email', - 'userinfo_profile', - ); - } - - /** - * {@inheritdoc} - */ - public function get_service_credentials() - { - return array( - 'key' => $this->config['auth_oauth_google_key'], - 'secret' => $this->config['auth_oauth_google_secret'], - ); - } - - /** - * {@inheritdoc} - */ - public function perform_auth_login() - { - if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Google)) - { - throw new exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); - } - - // This was a callback request, get the token - $this->service_provider->requestAccessToken($this->request->variable('code', '')); - - // Send a request with it - $result = json_decode($this->service_provider->request('https://www.googleapis.com/oauth2/v1/userinfo'), true); - - // Return the unique identifier - return $result['id']; - } - - /** - * {@inheritdoc} - */ - public function perform_token_auth() - { - if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Google)) - { - throw new exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); - } - - // Send a request with it - $result = json_decode($this->service_provider->request('https://www.googleapis.com/oauth2/v1/userinfo'), true); - - // Return the unique identifier - return $result['id']; - } -} diff --git a/install/update/old/phpbb/auth/provider/oauth/service/service_interface.php b/install/update/old/phpbb/auth/provider/oauth/service/service_interface.php deleted file mode 100644 index e84eb24..0000000 --- a/install/update/old/phpbb/auth/provider/oauth/service/service_interface.php +++ /dev/null @@ -1,73 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\auth\provider\oauth\service; - -/** -* OAuth service interface -*/ -interface service_interface -{ - /** - * Returns an array of the scopes necessary for auth - * - * @return array An array of the required scopes - */ - public function get_auth_scope(); - - /** - * Returns the external library service provider once it has been set - * - * @param \OAuth\Common\Service\ServiceInterface|null - */ - public function get_external_service_provider(); - - /** - * Returns an array containing the service credentials belonging to requested - * service. - * - * @return array An array containing the 'key' and the 'secret' of the - * service in the form: - * array( - * 'key' => string - * 'secret' => string - * ) - */ - public function get_service_credentials(); - - /** - * Returns the results of the authentication in json format - * - * @throws \phpbb\auth\provider\oauth\service\exception - * @return string The unique identifier returned by the service provider - * that is used to authenticate the user with phpBB. - */ - public function perform_auth_login(); - - /** - * Returns the results of the authentication in json format - * Use this function when the user already has an access token - * - * @throws \phpbb\auth\provider\oauth\service\exception - * @return string The unique identifier returned by the service provider - * that is used to authenticate the user with phpBB. - */ - public function perform_token_auth(); - - /** - * Sets the external library service provider - * - * @param \OAuth\Common\Service\ServiceInterface $service_provider - */ - public function set_external_service_provider(\OAuth\Common\Service\ServiceInterface $service_provider); -} diff --git a/install/update/old/phpbb/auth/provider/oauth/service/twitter.php b/install/update/old/phpbb/auth/provider/oauth/service/twitter.php deleted file mode 100644 index 06beac5..0000000 --- a/install/update/old/phpbb/auth/provider/oauth/service/twitter.php +++ /dev/null @@ -1,102 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\auth\provider\oauth\service; - -/** -* Twitter OAuth service -*/ -class twitter extends \phpbb\auth\provider\oauth\service\base -{ - /** - * phpBB config - * - * @var \phpbb\config\config - */ - protected $config; - - /** - * phpBB request - * - * @var \phpbb\request\request_interface - */ - protected $request; - - /** - * Constructor - * - * @param \phpbb\config\config $config - * @param \phpbb\request\request_interface $request - */ - public function __construct(\phpbb\config\config $config, \phpbb\request\request_interface $request) - { - $this->config = $config; - $this->request = $request; - } - - /** - * {@inheritdoc} - */ - public function get_service_credentials() - { - return array( - 'key' => $this->config['auth_oauth_twitter_key'], - 'secret' => $this->config['auth_oauth_twitter_secret'], - ); - } - - /** - * {@inheritdoc} - */ - public function perform_auth_login() - { - if (!($this->service_provider instanceof \OAuth\OAuth1\Service\Twitter)) - { - throw new \phpbb\auth\provider\oauth\service\exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); - } - - $storage = $this->service_provider->getStorage(); - $token = $storage->retrieveAccessToken('Twitter'); - $tokensecret = $token->getRequestTokenSecret(); - - // This was a callback request from twitter, get the token - $this->service_provider->requestAccessToken( - $this->request->variable('oauth_token', ''), - $this->request->variable('oauth_verifier', ''), - $tokensecret - ); - - // Send a request with it - $result = json_decode($this->service_provider->request('account/verify_credentials.json'), true); - - // Return the unique identifier returned from twitter - return $result['id']; - } - - /** - * {@inheritdoc} - */ - public function perform_token_auth() - { - if (!($this->service_provider instanceof \OAuth\OAuth1\Service\Twitter)) - { - throw new \phpbb\auth\provider\oauth\service\exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); - } - - // Send a request with it - $result = json_decode($this->service_provider->request('account/verify_credentials.json'), true); - - // Return the unique identifier returned from twitter - return $result['id']; - } -} diff --git a/install/update/old/phpbb/auth/provider/oauth/token_storage.php b/install/update/old/phpbb/auth/provider/oauth/token_storage.php deleted file mode 100644 index b0c2fd0..0000000 --- a/install/update/old/phpbb/auth/provider/oauth/token_storage.php +++ /dev/null @@ -1,592 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\auth\provider\oauth; - -use OAuth\OAuth1\Token\StdOAuth1Token; -use OAuth\Common\Token\TokenInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Storage\Exception\TokenNotFoundException; -use OAuth\Common\Storage\Exception\AuthorizationStateNotFoundException; - -/** -* OAuth storage wrapper for phpbb's cache -*/ -class token_storage implements TokenStorageInterface -{ - /** - * Cache driver. - * - * @var \phpbb\db\driver\driver_interface - */ - protected $db; - - /** - * phpBB user - * - * @var \phpbb\user - */ - protected $user; - - /** - * OAuth token table - * - * @var string - */ - protected $oauth_token_table; - - /** - * OAuth state table - * - * @var string - */ - protected $oauth_state_table; - - /** - * @var object|TokenInterface - */ - protected $cachedToken; - - /** - * @var string - */ - protected $cachedState; - - /** - * Creates token storage for phpBB. - * - * @param \phpbb\db\driver\driver_interface $db - * @param \phpbb\user $user - * @param string $oauth_token_table - * @param string $oauth_state_table - */ - public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\user $user, $oauth_token_table, $oauth_state_table) - { - $this->db = $db; - $this->user = $user; - $this->oauth_token_table = $oauth_token_table; - $this->oauth_state_table = $oauth_state_table; - } - - /** - * {@inheritdoc} - */ - public function retrieveAccessToken($service) - { - $service = $this->get_service_name_for_db($service); - - if ($this->cachedToken instanceof TokenInterface) - { - return $this->cachedToken; - } - - $data = array( - 'user_id' => (int) $this->user->data['user_id'], - 'provider' => $service, - ); - - if ((int) $this->user->data['user_id'] === ANONYMOUS) - { - $data['session_id'] = $this->user->data['session_id']; - } - - return $this->_retrieve_access_token($data); - } - - /** - * {@inheritdoc} - */ - public function storeAccessToken($service, TokenInterface $token) - { - $service = $this->get_service_name_for_db($service); - - $this->cachedToken = $token; - - $data = array( - 'oauth_token' => $this->json_encode_token($token), - ); - - $sql = 'UPDATE ' . $this->oauth_token_table . ' - SET ' . $this->db->sql_build_array('UPDATE', $data) . ' - WHERE user_id = ' . (int) $this->user->data['user_id'] . ' - ' . ((int) $this->user->data['user_id'] === ANONYMOUS ? "AND session_id = '" . $this->db->sql_escape($this->user->data['session_id']) . "'" : '') . " - AND provider = '" . $this->db->sql_escape($service) . "'"; - $this->db->sql_query($sql); - - if (!$this->db->sql_affectedrows()) - { - $data = array( - 'user_id' => (int) $this->user->data['user_id'], - 'provider' => $service, - 'oauth_token' => $this->json_encode_token($token), - 'session_id' => $this->user->data['session_id'], - ); - - $sql = 'INSERT INTO ' . $this->oauth_token_table . $this->db->sql_build_array('INSERT', $data); - - $this->db->sql_query($sql); - } - - return $this; - } - - /** - * {@inheritdoc} - */ - public function hasAccessToken($service) - { - $service = $this->get_service_name_for_db($service); - - if ($this->cachedToken) - { - return true; - } - - $data = array( - 'user_id' => (int) $this->user->data['user_id'], - 'provider' => $service, - ); - - if ((int) $this->user->data['user_id'] === ANONYMOUS) - { - $data['session_id'] = $this->user->data['session_id']; - } - - return $this->_has_acess_token($data); - } - - /** - * {@inheritdoc} - */ - public function clearToken($service) - { - $service = $this->get_service_name_for_db($service); - - $this->cachedToken = null; - - $sql = 'DELETE FROM ' . $this->oauth_token_table . ' - WHERE user_id = ' . (int) $this->user->data['user_id'] . " - AND provider = '" . $this->db->sql_escape($service) . "'"; - - if ((int) $this->user->data['user_id'] === ANONYMOUS) - { - $sql .= " AND session_id = '" . $this->db->sql_escape($this->user->data['session_id']) . "'"; - } - - $this->db->sql_query($sql); - - return $this; - } - - /** - * {@inheritdoc} - */ - public function clearAllTokens() - { - $this->cachedToken = null; - - $sql = 'DELETE FROM ' . $this->oauth_token_table . ' - WHERE user_id = ' . (int) $this->user->data['user_id']; - - if ((int) $this->user->data['user_id'] === ANONYMOUS) - { - $sql .= " AND session_id = '" . $this->db->sql_escape($this->user->data['session_id']) . "'"; - } - - $this->db->sql_query($sql); - - return $this; - } - - /** - * {@inheritdoc} - */ - public function storeAuthorizationState($service, $state) - { - $service = $this->get_service_name_for_db($service); - - $this->cachedState = $state; - - $data = array( - 'user_id' => (int) $this->user->data['user_id'], - 'provider' => $service, - 'oauth_state' => $state, - 'session_id' => $this->user->data['session_id'], - ); - - $sql = 'INSERT INTO ' . $this->oauth_state_table . ' - ' . $this->db->sql_build_array('INSERT', $data); - $this->db->sql_query($sql); - - return $this; - } - - /** - * {@inheritdoc} - */ - public function hasAuthorizationState($service) - { - $service = $this->get_service_name_for_db($service); - - if ($this->cachedState) - { - return true; - } - - $data = array( - 'user_id' => (int) $this->user->data['user_id'], - 'provider' => $service, - ); - - if ((int) $this->user->data['user_id'] === ANONYMOUS) - { - $data['session_id'] = $this->user->data['session_id']; - } - - return (bool) $this->get_state_row($data); - } - - /** - * {@inheritdoc} - */ - public function retrieveAuthorizationState($service) - { - $service = $this->get_service_name_for_db($service); - - if ($this->cachedState) - { - return $this->cachedState; - } - - $data = array( - 'user_id' => (int) $this->user->data['user_id'], - 'provider' => $service, - ); - - if ((int) $this->user->data['user_id'] === ANONYMOUS) - { - $data['session_id'] = $this->user->data['session_id']; - } - - return $this->get_state_row($data); - } - - /** - * {@inheritdoc} - */ - public function clearAuthorizationState($service) - { - $service = $this->get_service_name_for_db($service); - - $this->cachedState = null; - - $sql = 'DELETE FROM ' . $this->oauth_state_table . ' - WHERE user_id = ' . (int) $this->user->data['user_id'] . " - AND provider = '" . $this->db->sql_escape($service) . "'"; - - if ((int) $this->user->data['user_id'] === ANONYMOUS) - { - $sql .= " AND session_id = '" . $this->db->sql_escape($this->user->data['session_id']) . "'"; - } - - $this->db->sql_query($sql); - - return $this; - } - - /** - * {@inheritdoc} - */ - public function clearAllAuthorizationStates() - { - $this->cachedState = null; - - $sql = 'DELETE FROM ' . $this->oauth_state_table . ' - WHERE user_id = ' . (int) $this->user->data['user_id']; - - if ((int) $this->user->data['user_id'] === ANONYMOUS) - { - $sql .= " AND session_id = '" . $this->db->sql_escape($this->user->data['session_id']) . "'"; - } - - $this->db->sql_query($sql); - - return $this; - } - - /** - * Updates the user_id field in the database assosciated with the token - * - * @param int $user_id - */ - public function set_user_id($user_id) - { - if (!$this->cachedToken) - { - return; - } - - $sql = 'UPDATE ' . $this->oauth_token_table . ' - SET ' . $this->db->sql_build_array('UPDATE', array( - 'user_id' => (int) $user_id - )) . ' - WHERE user_id = ' . (int) $this->user->data['user_id'] . " - AND session_id = '" . $this->db->sql_escape($this->user->data['session_id']) . "'"; - $this->db->sql_query($sql); - } - - /** - * Checks to see if an access token exists solely by the session_id of the user - * - * @param string $service The name of the OAuth service - * @return bool true if they have token, false if they don't - */ - public function has_access_token_by_session($service) - { - $service = $this->get_service_name_for_db($service); - - if ($this->cachedToken) - { - return true; - } - - $data = array( - 'session_id' => $this->user->data['session_id'], - 'provider' => $service, - ); - - return $this->_has_acess_token($data); - } - - /** - * Checks to see if a state exists solely by the session_id of the user - * - * @param string $service The name of the OAuth service - * @return bool true if they have state, false if they don't - */ - public function has_state_by_session($service) - { - $service = $this->get_service_name_for_db($service); - - if ($this->cachedState) - { - return true; - } - - $data = array( - 'session_id' => $this->user->data['session_id'], - 'provider' => $service, - ); - - return (bool) $this->get_state_row($data); - } - - /** - * A helper function that performs the query for has access token functions - * - * @param array $data - * @return bool - */ - protected function _has_acess_token($data) - { - return (bool) $this->get_access_token_row($data); - } - - public function retrieve_access_token_by_session($service) - { - $service = $this->get_service_name_for_db($service); - - if ($this->cachedToken instanceof TokenInterface) - { - return $this->cachedToken; - } - - $data = array( - 'session_id' => $this->user->data['session_id'], - 'provider' => $service, - ); - - return $this->_retrieve_access_token($data); - } - - public function retrieve_state_by_session($service) - { - $service = $this->get_service_name_for_db($service); - - if ($this->cachedState) - { - return $this->cachedState; - } - - $data = array( - 'session_id' => $this->user->data['session_id'], - 'provider' => $service, - ); - - return $this->_retrieve_state($data); - } - - /** - * A helper function that performs the query for retrieve access token functions - * Also checks if the token is a valid token - * - * @param array $data - * @return mixed - * @throws \OAuth\Common\Storage\Exception\TokenNotFoundException - */ - protected function _retrieve_access_token($data) - { - $row = $this->get_access_token_row($data); - - if (!$row) - { - throw new TokenNotFoundException('AUTH_PROVIDER_OAUTH_TOKEN_ERROR_NOT_STORED'); - } - - $token = $this->json_decode_token($row['oauth_token']); - - // Ensure that the token was serialized/unserialized correctly - if (!($token instanceof TokenInterface)) - { - $this->clearToken($data['provider']); - throw new TokenNotFoundException('AUTH_PROVIDER_OAUTH_TOKEN_ERROR_INCORRECTLY_STORED'); - } - - $this->cachedToken = $token; - return $token; - } - - /** - * A helper function that performs the query for retrieve state functions - * - * @param array $data - * @return mixed - * @throws \OAuth\Common\Storage\Exception\AuthorizationStateNotFoundException - */ - protected function _retrieve_state($data) - { - $row = $this->get_state_row($data); - - if (!$row) - { - throw new AuthorizationStateNotFoundException(); - } - - $this->cachedState = $row['oauth_state']; - return $this->cachedState; - } - - /** - * A helper function that performs the query for retrieving an access token - * - * @param array $data - * @return mixed - */ - protected function get_access_token_row($data) - { - $sql = 'SELECT oauth_token FROM ' . $this->oauth_token_table . ' - WHERE ' . $this->db->sql_build_array('SELECT', $data); - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - return $row; - } - - /** - * A helper function that performs the query for retrieving a state - * - * @param array $data - * @return mixed - */ - protected function get_state_row($data) - { - $sql = 'SELECT oauth_state FROM ' . $this->oauth_state_table . ' - WHERE ' . $this->db->sql_build_array('SELECT', $data); - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - return $row; - } - - public function json_encode_token(TokenInterface $token) - { - $members = array( - 'accessToken' => $token->getAccessToken(), - 'endOfLife' => $token->getEndOfLife(), - 'extraParams' => $token->getExtraParams(), - 'refreshToken' => $token->getRefreshToken(), - - 'token_class' => get_class($token), - ); - - // Handle additional data needed for OAuth1 tokens - if ($token instanceof StdOAuth1Token) - { - $members['requestToken'] = $token->getRequestToken(); - $members['requestTokenSecret'] = $token->getRequestTokenSecret(); - $members['accessTokenSecret'] = $token->getAccessTokenSecret(); - } - - return json_encode($members); - } - - public function json_decode_token($json) - { - $token_data = json_decode($json, true); - - if ($token_data === null) - { - throw new TokenNotFoundException('AUTH_PROVIDER_OAUTH_TOKEN_ERROR_INCORRECTLY_STORED'); - } - - $token_class = $token_data['token_class']; - $access_token = $token_data['accessToken']; - $refresh_token = $token_data['refreshToken']; - $endOfLife = $token_data['endOfLife']; - $extra_params = $token_data['extraParams']; - - // Create the token - $token = new $token_class($access_token, $refresh_token, TokenInterface::EOL_NEVER_EXPIRES, $extra_params); - $token->setEndOfLife($endOfLife); - - // Handle OAuth 1.0 specific elements - if ($token instanceof StdOAuth1Token) - { - $token->setRequestToken($token_data['requestToken']); - $token->setRequestTokenSecret($token_data['requestTokenSecret']); - $token->setAccessTokenSecret($token_data['accessTokenSecret']); - } - - return $token; - } - - /** - * Returns the name of the service as it must be stored in the database. - * - * @param string $service The name of the OAuth service - * @return string The name of the OAuth service as it needs to be stored - * in the database. - */ - protected function get_service_name_for_db($service) - { - // Enforce the naming convention for oauth services - if (strpos($service, 'auth.provider.oauth.service.') !== 0) - { - $service = 'auth.provider.oauth.service.' . strtolower($service); - } - - return $service; - } -} diff --git a/install/update/old/phpbb/auth/provider/provider_interface.php b/install/update/old/phpbb/auth/provider/provider_interface.php deleted file mode 100644 index 35e0f55..0000000 --- a/install/update/old/phpbb/auth/provider/provider_interface.php +++ /dev/null @@ -1,197 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\auth\provider; - -/** -* The interface authentication provider classes have to implement. -*/ -interface provider_interface -{ - /** - * Checks whether the user is currently identified to the authentication - * provider. - * Called in acp_board while setting authentication plugins. - * Changing to an authentication provider will not be permitted in acp_board - * if there is an error. - * - * @return boolean|string False if the user is identified, otherwise an - * error message, or null if not implemented. - */ - public function init(); - - /** - * Performs login. - * - * @param string $username The name of the user being authenticated. - * @param string $password The password of the user. - * @return array An associative array of the format: - * array( - * 'status' => status constant - * 'error_msg' => string - * 'user_row' => array - * ) - * A fourth key of the array may be present: - * 'redirect_data' This key is only used when 'status' is - * equal to LOGIN_SUCCESS_LINK_PROFILE and its value is an - * associative array that is turned into GET variables on - * the redirect url. - */ - public function login($username, $password); - - /** - * Autologin function - * - * @return array|null containing the user row, empty if no auto login - * should take place, or null if not impletmented. - */ - public function autologin(); - - /** - * This function is used to output any required fields in the authentication - * admin panel. It also defines any required configuration table fields. - * - * @return array|null Returns null if not implemented or an array of the - * configuration fields of the provider. - */ - public function acp(); - - /** - * This function updates the template with variables related to the acp - * options with whatever configuraton values are passed to it as an array. - * It then returns the name of the acp file related to this authentication - * provider. - * @param array $new_config Contains the new configuration values that - * have been set in acp_board. - * @return array|null Returns null if not implemented or an array with - * the template file name and an array of the vars - * that the template needs that must conform to the - * following example: - * array( - * 'TEMPLATE_FILE' => string, - * 'TEMPLATE_VARS' => array(...), - * ) - * An optional third element may be added to this - * array: 'BLOCK_VAR_NAME'. If this is present, - * then its value should be a string that is used - * to designate the name of the loop used in the - * ACP template file. When this is present, an - * additional key named 'BLOCK_VARS' is required. - * This must be an array containing at least one - * array of variables that will be assigned during - * the loop in the template. An example of this is - * presented below: - * array( - * 'BLOCK_VAR_NAME' => string, - * 'BLOCK_VARS' => array( - * 'KEY IS UNIMPORTANT' => array(...), - * ), - * 'TEMPLATE_FILE' => string, - * 'TEMPLATE_VARS' => array(...), - * ) - */ - public function get_acp_template($new_config); - - /** - * Returns an array of data necessary to build custom elements on the login - * form. - * - * @return array|null If this function is not implemented on an auth - * provider then it returns null. If it is implemented - * it will return an array of up to four elements of - * which only 'TEMPLATE_FILE'. If 'BLOCK_VAR_NAME' is - * present then 'BLOCK_VARS' must also be present in - * the array. The fourth element 'VARS' is also - * optional. The array, with all four elements present - * looks like the following: - * array( - * 'TEMPLATE_FILE' => string, - * 'BLOCK_VAR_NAME' => string, - * 'BLOCK_VARS' => array(...), - * 'VARS' => array(...), - * ) - */ - public function get_login_data(); - - /** - * Performs additional actions during logout. - * - * @param array $data An array corresponding to - * \phpbb\session::data - * @param boolean $new_session True for a new session, false for no new - * session. - */ - public function logout($data, $new_session); - - /** - * The session validation function checks whether the user is still logged - * into phpBB. - * - * @param array $user - * @return boolean true if the given user is authenticated, false if the - * session should be closed, or null if not implemented. - */ - public function validate_session($user); - - /** - * Checks to see if $login_link_data contains all information except for the - * user_id of an account needed to successfully link an external account to - * a forum account. - * - * @param array $login_link_data Any data needed to link a phpBB account to - * an external account. - * @return string|null Returns a string with a language constant if there - * is data missing or null if there is no error. - */ - public function login_link_has_necessary_data($login_link_data); - - /** - * Links an external account to a phpBB account. - * - * @param array $link_data Any data needed to link a phpBB account to - * an external account. - */ - public function link_account(array $link_data); - - /** - * Returns an array of data necessary to build the ucp_auth_link page - * - * @param int $user_id User ID for whom the data should be retrieved. - * defaults to 0, which is not a valid ID. The method - * should fall back to the current user's ID in this - * case. - * @return array|null If this function is not implemented on an auth - * provider then it returns null. If it is implemented - * it will return an array of up to four elements of - * which only 'TEMPLATE_FILE'. If 'BLOCK_VAR_NAME' is - * present then 'BLOCK_VARS' must also be present in - * the array. The fourth element 'VARS' is also - * optional. The array, with all four elements present - * looks like the following: - * array( - * 'TEMPLATE_FILE' => string, - * 'BLOCK_VAR_NAME' => string, - * 'BLOCK_VARS' => array(...), - * 'VARS' => array(...), - * ) - */ - public function get_auth_link_data($user_id = 0); - - /** - * Unlinks an external account from a phpBB account. - * - * @param array $link_data Any data needed to unlink a phpBB account - * from a phpbb account. - */ - public function unlink_account(array $link_data); -} diff --git a/install/update/old/phpbb/avatar/driver/remote.php b/install/update/old/phpbb/avatar/driver/remote.php deleted file mode 100644 index efc4f5e..0000000 --- a/install/update/old/phpbb/avatar/driver/remote.php +++ /dev/null @@ -1,216 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\avatar\driver; - -/** -* Handles avatars hosted remotely -*/ -class remote extends \phpbb\avatar\driver\driver -{ - /** - * {@inheritdoc} - */ - public function get_data($row) - { - return array( - 'src' => $row['avatar'], - 'width' => $row['avatar_width'], - 'height' => $row['avatar_height'], - ); - } - - /** - * {@inheritdoc} - */ - public function prepare_form($request, $template, $user, $row, &$error) - { - $template->assign_vars(array( - 'AVATAR_REMOTE_WIDTH' => ((in_array($row['avatar_type'], array(AVATAR_REMOTE, $this->get_name(), 'remote'))) && $row['avatar_width']) ? $row['avatar_width'] : $request->variable('avatar_remote_width', ''), - 'AVATAR_REMOTE_HEIGHT' => ((in_array($row['avatar_type'], array(AVATAR_REMOTE, $this->get_name(), 'remote'))) && $row['avatar_height']) ? $row['avatar_height'] : $request->variable('avatar_remote_width', ''), - 'AVATAR_REMOTE_URL' => ((in_array($row['avatar_type'], array(AVATAR_REMOTE, $this->get_name(), 'remote'))) && $row['avatar']) ? $row['avatar'] : '', - )); - - return true; - } - - /** - * {@inheritdoc} - */ - public function process_form($request, $template, $user, $row, &$error) - { - $url = $request->variable('avatar_remote_url', ''); - $width = $request->variable('avatar_remote_width', 0); - $height = $request->variable('avatar_remote_height', 0); - - if (empty($url)) - { - return false; - } - - if (!preg_match('#^(http|https|ftp)://#i', $url)) - { - $url = 'http://' . $url; - } - - if (!function_exists('validate_data')) - { - require($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext); - } - - $validate_array = validate_data( - array( - 'url' => $url, - ), - array( - 'url' => array('string', true, 5, 255), - ) - ); - - $error = array_merge($error, $validate_array); - - if (!empty($error)) - { - return false; - } - - // Check if this url looks alright - // Do not allow specifying the port (see RFC 3986) or IP addresses - if (!preg_match('#^(http|https|ftp)://(?:(.*?\.)*?[a-z0-9\-]+?\.[a-z]{2,4}|(?:\d{1,3}\.){3,5}\d{1,3}):?([0-9]*?).*?\.('. implode('|', $this->allowed_extensions) . ')$#i', $url) || - preg_match('@^(http|https|ftp)://[^/:?#]+:[0-9]+[/:?#]@i', $url) || - preg_match('#^(http|https|ftp)://(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])#i', $url) || - preg_match('#^(http|https|ftp)://(?:(?:(?:[\dA-F]{1,4}:){6}(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:::(?:[\dA-F]{1,4}:){0,5}(?:[\dA-F]{1,4}(?::[\dA-F]{1,4})?|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:):(?:[\dA-F]{1,4}:){4}(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,2}:(?:[\dA-F]{1,4}:){3}(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,3}:(?:[\dA-F]{1,4}:){2}(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,4}:(?:[\dA-F]{1,4}:)(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,5}:(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,6}:[\dA-F]{1,4})|(?:(?:[\dA-F]{1,4}:){1,7}:)|(?:::))#i', $url)) - { - $error[] = 'AVATAR_URL_INVALID'; - return false; - } - - // Get image dimensions - if (($width <= 0 || $height <= 0) && (($image_data = $this->imagesize->getImageSize($url)) === false)) - { - $error[] = 'UNABLE_GET_IMAGE_SIZE'; - return false; - } - - if (!empty($image_data) && ($image_data['width'] <= 0 || $image_data['height'] <= 0)) - { - $error[] = 'AVATAR_NO_SIZE'; - return false; - } - - $width = ($width && $height) ? $width : $image_data['width']; - $height = ($width && $height) ? $height : $image_data['height']; - - if ($width <= 0 || $height <= 0) - { - $error[] = 'AVATAR_NO_SIZE'; - return false; - } - - $types = \phpbb\files\upload::image_types(); - $extension = strtolower(\phpbb\files\filespec::get_extension($url)); - - // Check if this is actually an image - if ($file_stream = @fopen($url, 'r')) - { - // Timeout after 1 second - stream_set_timeout($file_stream, 1); - // read some data to ensure headers are present - fread($file_stream, 1024); - $meta = stream_get_meta_data($file_stream); - - if (isset($meta['wrapper_data']['headers']) && is_array($meta['wrapper_data']['headers'])) - { - $headers = $meta['wrapper_data']['headers']; - } - else if (isset($meta['wrapper_data']) && is_array($meta['wrapper_data'])) - { - $headers = $meta['wrapper_data']; - } - else - { - $headers = array(); - } - - foreach ($headers as $header) - { - $header = preg_split('/ /', $header, 2); - if (strtr(strtolower(trim($header[0], ':')), '_', '-') === 'content-type') - { - if (strpos($header[1], 'image/') !== 0) - { - $error[] = 'AVATAR_URL_INVALID'; - fclose($file_stream); - return false; - } - else - { - fclose($file_stream); - break; - } - } - } - } - else - { - $error[] = 'AVATAR_URL_INVALID'; - return false; - } - - if (!empty($image_data) && (!isset($types[$image_data['type']]) || !in_array($extension, $types[$image_data['type']]))) - { - if (!isset($types[$image_data['type']])) - { - $error[] = 'UNABLE_GET_IMAGE_SIZE'; - } - else - { - $error[] = array('IMAGE_FILETYPE_MISMATCH', $types[$image_data['type']][0], $extension); - } - - return false; - } - - if ($this->config['avatar_max_width'] || $this->config['avatar_max_height']) - { - if ($width > $this->config['avatar_max_width'] || $height > $this->config['avatar_max_height']) - { - $error[] = array('AVATAR_WRONG_SIZE', $this->config['avatar_min_width'], $this->config['avatar_min_height'], $this->config['avatar_max_width'], $this->config['avatar_max_height'], $width, $height); - return false; - } - } - - if ($this->config['avatar_min_width'] || $this->config['avatar_min_height']) - { - if ($width < $this->config['avatar_min_width'] || $height < $this->config['avatar_min_height']) - { - $error[] = array('AVATAR_WRONG_SIZE', $this->config['avatar_min_width'], $this->config['avatar_min_height'], $this->config['avatar_max_width'], $this->config['avatar_max_height'], $width, $height); - return false; - } - } - - return array( - 'avatar' => $url, - 'avatar_width' => $width, - 'avatar_height' => $height, - ); - } - - /** - * {@inheritdoc} - */ - public function get_template_name() - { - return 'ucp_avatar_options_remote.html'; - } -} diff --git a/install/update/old/phpbb/avatar/driver/upload.php b/install/update/old/phpbb/avatar/driver/upload.php deleted file mode 100644 index a012bb1..0000000 --- a/install/update/old/phpbb/avatar/driver/upload.php +++ /dev/null @@ -1,331 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\avatar\driver; - -/** -* Handles avatars uploaded to the board -*/ -class upload extends \phpbb\avatar\driver\driver -{ - /** - * @var \phpbb\filesystem\filesystem_interface - */ - protected $filesystem; - - /** - * @var \phpbb\event\dispatcher_interface - */ - protected $dispatcher; - - /** - * @var \phpbb\files\factory - */ - protected $files_factory; - - /** - * Construct a driver object - * - * @param \phpbb\config\config $config phpBB configuration - * @param string $phpbb_root_path Path to the phpBB root - * @param string $php_ext PHP file extension - * @param \phpbb\filesystem\filesystem_interface $filesystem phpBB filesystem helper - * @param \phpbb\path_helper $path_helper phpBB path helper - * @param \phpbb\event\dispatcher_interface $dispatcher phpBB Event dispatcher object - * @param \phpbb\files\factory $files_factory File classes factory - * @param \phpbb\cache\driver\driver_interface $cache Cache driver - */ - public function __construct(\phpbb\config\config $config, $phpbb_root_path, $php_ext, \phpbb\filesystem\filesystem_interface $filesystem, \phpbb\path_helper $path_helper, \phpbb\event\dispatcher_interface $dispatcher, \phpbb\files\factory $files_factory, \phpbb\cache\driver\driver_interface $cache = null) - { - $this->config = $config; - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - $this->filesystem = $filesystem; - $this->path_helper = $path_helper; - $this->dispatcher = $dispatcher; - $this->files_factory = $files_factory; - $this->cache = $cache; - } - - /** - * {@inheritdoc} - */ - public function get_data($row) - { - $root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $this->path_helper->get_web_root_path(); - - return array( - 'src' => $root_path . 'download/file.' . $this->php_ext . '?avatar=' . $row['avatar'], - 'width' => $row['avatar_width'], - 'height' => $row['avatar_height'], - ); - } - - /** - * {@inheritdoc} - */ - public function prepare_form($request, $template, $user, $row, &$error) - { - if (!$this->can_upload()) - { - return false; - } - - $template->assign_vars(array( - 'S_UPLOAD_AVATAR_URL' => ($this->config['allow_avatar_remote_upload']) ? true : false, - 'AVATAR_UPLOAD_SIZE' => $this->config['avatar_filesize'], - )); - - return true; - } - - /** - * {@inheritdoc} - */ - public function process_form($request, $template, $user, $row, &$error) - { - if (!$this->can_upload()) - { - return false; - } - - /** @var \phpbb\files\upload $upload */ - $upload = $this->files_factory->get('upload') - ->set_error_prefix('AVATAR_') - ->set_allowed_extensions($this->allowed_extensions) - ->set_max_filesize($this->config['avatar_filesize']) - ->set_allowed_dimensions( - $this->config['avatar_min_width'], - $this->config['avatar_min_height'], - $this->config['avatar_max_width'], - $this->config['avatar_max_height']) - ->set_disallowed_content((isset($this->config['mime_triggers']) ? explode('|', $this->config['mime_triggers']) : false)); - - $url = $request->variable('avatar_upload_url', ''); - $upload_file = $request->file('avatar_upload_file'); - - if (!empty($upload_file['name'])) - { - $file = $upload->handle_upload('files.types.form', 'avatar_upload_file'); - } - else if (!empty($this->config['allow_avatar_remote_upload']) && !empty($url)) - { - if (!preg_match('#^(http|https|ftp)://#i', $url)) - { - $url = 'http://' . $url; - } - - if (!function_exists('validate_data')) - { - require($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext); - } - - $validate_array = validate_data( - array( - 'url' => $url, - ), - array( - 'url' => array('string', true, 5, 255), - ) - ); - - $error = array_merge($error, $validate_array); - - if (!empty($error)) - { - return false; - } - - // Do not allow specifying the port (see RFC 3986) or IP addresses - // remote_upload() will do its own check for allowed filetypes - if (!preg_match('#^(http|https|ftp)://(?:(.*?\.)*?[a-z0-9\-]+?\.[a-z]{2,4}|(?:\d{1,3}\.){3,5}\d{1,3}):?([0-9]*?).*?\.('. implode('|', $this->allowed_extensions) . ')$#i', $url) || - preg_match('@^(http|https|ftp)://[^/:?#]+:[0-9]+[/:?#]@i', $url) || - preg_match('#^(http|https|ftp)://(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])#i', $url) || - preg_match('#^(http|https|ftp)://(?:(?:(?:[\dA-F]{1,4}:){6}(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:::(?:[\dA-F]{1,4}:){0,5}(?:[\dA-F]{1,4}(?::[\dA-F]{1,4})?|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:):(?:[\dA-F]{1,4}:){4}(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,2}:(?:[\dA-F]{1,4}:){3}(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,3}:(?:[\dA-F]{1,4}:){2}(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,4}:(?:[\dA-F]{1,4}:)(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,5}:(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,6}:[\dA-F]{1,4})|(?:(?:[\dA-F]{1,4}:){1,7}:)|(?:::))#i', $url)) - { - $error[] = 'AVATAR_URL_INVALID'; - return false; - } - - $file = $upload->handle_upload('files.types.remote', $url); - } - else - { - return false; - } - - $prefix = $this->config['avatar_salt'] . '_'; - $file->clean_filename('avatar', $prefix, $row['id']); - - // If there was an error during upload, then abort operation - if (count($file->error)) - { - $file->remove(); - $error = $file->error; - return false; - } - - // Calculate new destination - $destination = $this->config['avatar_path']; - - // Adjust destination path (no trailing slash) - if (substr($destination, -1, 1) == '/' || substr($destination, -1, 1) == '\\') - { - $destination = substr($destination, 0, -1); - } - - $destination = str_replace(array('../', '..\\', './', '.\\'), '', $destination); - if ($destination && ($destination[0] == '/' || $destination[0] == "\\")) - { - $destination = ''; - } - - $filedata = array( - 'filename' => $file->get('filename'), - 'filesize' => $file->get('filesize'), - 'mimetype' => $file->get('mimetype'), - 'extension' => $file->get('extension'), - 'physical_filename' => $file->get('realname'), - 'real_filename' => $file->get('uploadname'), - ); - - /** - * Before moving new file in place (and eventually overwriting the existing avatar with the newly uploaded avatar) - * - * @event core.avatar_driver_upload_move_file_before - * @var array filedata Array containing uploaded file data - * @var \phpbb\files\filespec file Instance of filespec class - * @var string destination Destination directory where the file is going to be moved - * @var string prefix Prefix for the avatar filename - * @var array row Array with avatar row data - * @var array error Array of errors, if filled in by this event file will not be moved - * @since 3.1.6-RC1 - * @changed 3.1.9-RC1 Added filedata - * @changed 3.2.3-RC1 Added file - */ - $vars = array( - 'filedata', - 'file', - 'destination', - 'prefix', - 'row', - 'error', - ); - extract($this->dispatcher->trigger_event('core.avatar_driver_upload_move_file_before', compact($vars))); - - unset($filedata); - - if (!count($error)) - { - // Move file and overwrite any existing image - $file->move_file($destination, true); - } - - // If there was an error during move, then clean up leftovers - $error = array_merge($error, $file->error); - if (count($error)) - { - $file->remove(); - return false; - } - - // Delete current avatar if not overwritten - $ext = substr(strrchr($row['avatar'], '.'), 1); - if ($ext && $ext !== $file->get('extension')) - { - $this->delete($row); - } - - return array( - 'avatar' => $row['id'] . '_' . time() . '.' . $file->get('extension'), - 'avatar_width' => $file->get('width'), - 'avatar_height' => $file->get('height'), - ); - } - - /** - * {@inheritdoc} - */ - public function prepare_form_acp($user) - { - return array( - 'allow_avatar_remote_upload'=> array('lang' => 'ALLOW_REMOTE_UPLOAD', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'avatar_filesize' => array('lang' => 'MAX_FILESIZE', 'validate' => 'int:0', 'type' => 'number:0', 'explain' => true, 'append' => ' ' . $user->lang['BYTES']), - 'avatar_path' => array('lang' => 'AVATAR_STORAGE_PATH', 'validate' => 'rpath', 'type' => 'text:20:255', 'explain' => true), - ); - } - - /** - * {@inheritdoc} - */ - public function delete($row) - { - - $error = array(); - $destination = $this->config['avatar_path']; - $prefix = $this->config['avatar_salt'] . '_'; - $ext = substr(strrchr($row['avatar'], '.'), 1); - $filename = $this->phpbb_root_path . $destination . '/' . $prefix . $row['id'] . '.' . $ext; - - /** - * Before deleting an existing avatar - * - * @event core.avatar_driver_upload_delete_before - * @var string destination Destination directory where the file is going to be deleted - * @var string prefix Prefix for the avatar filename - * @var array row Array with avatar row data - * @var array error Array of errors, if filled in by this event file will not be deleted - * @since 3.1.6-RC1 - */ - $vars = array( - 'destination', - 'prefix', - 'row', - 'error', - ); - extract($this->dispatcher->trigger_event('core.avatar_driver_upload_delete_before', compact($vars))); - - if (!count($error) && $this->filesystem->exists($filename)) - { - try - { - $this->filesystem->remove($filename); - return true; - } - catch (\phpbb\filesystem\exception\filesystem_exception $e) - { - // Fail is covered by return statement below - } - } - - return false; - } - - /** - * {@inheritdoc} - */ - public function get_template_name() - { - return 'ucp_avatar_options_upload.html'; - } - - /** - * Check if user is able to upload an avatar - * - * @return bool True if user can upload, false if not - */ - protected function can_upload() - { - return ($this->filesystem->exists($this->phpbb_root_path . $this->config['avatar_path']) && $this->filesystem->is_writable($this->phpbb_root_path . $this->config['avatar_path']) && (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on')); - } -} diff --git a/install/update/old/phpbb/cache/driver/memcached.php b/install/update/old/phpbb/cache/driver/memcached.php deleted file mode 100644 index 7d66759..0000000 --- a/install/update/old/phpbb/cache/driver/memcached.php +++ /dev/null @@ -1,134 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\cache\driver; - -if (!defined('PHPBB_ACM_MEMCACHED_PORT')) -{ - define('PHPBB_ACM_MEMCACHED_PORT', 11211); -} - -if (!defined('PHPBB_ACM_MEMCACHED_COMPRESS')) -{ - define('PHPBB_ACM_MEMCACHED_COMPRESS', true); -} - -if (!defined('PHPBB_ACM_MEMCACHED_HOST')) -{ - define('PHPBB_ACM_MEMCACHED_HOST', 'localhost'); -} - -if (!defined('PHPBB_ACM_MEMCACHED')) -{ - //can define multiple servers with host1/port1,host2/port2 format - define('PHPBB_ACM_MEMCACHED', PHPBB_ACM_MEMCACHED_HOST . '/' . PHPBB_ACM_MEMCACHED_PORT); -} - -/** -* ACM for Memcached -*/ -class memcached extends \phpbb\cache\driver\memory -{ - /** @var string Extension to use */ - protected $extension = 'memcached'; - - /** @var \Memcached Memcached class */ - protected $memcached; - - /** @var int Flags */ - protected $flags = 0; - - /** - * Memcached constructor - */ - public function __construct() - { - // Call the parent constructor - parent::__construct(); - - $this->memcached = new \Memcached(); - $this->memcached->setOption(\Memcached::OPT_BINARY_PROTOCOL, true); - // Memcached defaults to using compression, disable if we don't want - // to use it - if (!PHPBB_ACM_MEMCACHED_COMPRESS) - { - $this->memcached->setOption(\Memcached::OPT_COMPRESSION, false); - } - - foreach (explode(',', PHPBB_ACM_MEMCACHED) as $u) - { - preg_match('#(.*)/(\d+)#', $u, $parts); - $this->memcached->addServer(trim($parts[1]), (int) trim($parts[2])); - } - } - - /** - * {@inheritDoc} - */ - public function unload() - { - parent::unload(); - - unset($this->memcached); - } - - /** - * {@inheritDoc} - */ - public function purge() - { - $this->memcached->flush(); - - parent::purge(); - } - - /** - * Fetch an item from the cache - * - * @param string $var Cache key - * - * @return mixed Cached data - */ - protected function _read($var) - { - return $this->memcached->get($this->key_prefix . $var); - } - - /** - * Store data in the cache - * - * @param string $var Cache key - * @param mixed $data Data to store - * @param int $ttl Time-to-live of cached data - * @return bool True if the operation succeeded - */ - protected function _write($var, $data, $ttl = 2592000) - { - if (!$this->memcached->replace($this->key_prefix . $var, $data, $ttl)) - { - return $this->memcached->set($this->key_prefix . $var, $data, $ttl); - } - return true; - } - - /** - * Remove an item from the cache - * - * @param string $var Cache key - * @return bool True if the operation succeeded - */ - protected function _delete($var) - { - return $this->memcached->delete($this->key_prefix . $var); - } -} diff --git a/install/update/old/phpbb/cache/driver/memory.php b/install/update/old/phpbb/cache/driver/memory.php deleted file mode 100644 index eba9549..0000000 --- a/install/update/old/phpbb/cache/driver/memory.php +++ /dev/null @@ -1,282 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\cache\driver; - -/** -* ACM Abstract Memory Class -*/ -abstract class memory extends \phpbb\cache\driver\base -{ - var $key_prefix; - - /** - * Set cache path - */ - function __construct() - { - global $phpbb_root_path, $dbname, $table_prefix, $phpbb_container; - - $this->cache_dir = $phpbb_container->getParameter('core.cache_dir'); - $this->key_prefix = substr(md5($dbname . $table_prefix), 0, 8) . '_'; - - if (!isset($this->extension) || !extension_loaded($this->extension)) - { - global $acm_type; - - trigger_error("Could not find required extension [{$this->extension}] for the ACM module $acm_type.", E_USER_ERROR); - } - - if (isset($this->function) && !function_exists($this->function)) - { - global $acm_type; - - trigger_error("The required function [{$this->function}] is not available for the ACM module $acm_type.", E_USER_ERROR); - } - } - - /** - * {@inheritDoc} - */ - function load() - { - // grab the global cache - $data = $this->_read('global'); - - if ($data !== false) - { - $this->vars = $data; - return true; - } - - return false; - } - - /** - * {@inheritDoc} - */ - function save() - { - if (!$this->is_modified) - { - return; - } - - $this->_write('global', $this->vars, 2592000); - - $this->is_modified = false; - } - - /** - * {@inheritDoc} - */ - function tidy() - { - global $config; - - // cache has auto GC, no need to have any code here :) - $config->set('cache_last_gc', time(), false); - } - - /** - * {@inheritDoc} - */ - function get($var_name) - { - if ($var_name[0] == '_') - { - if (!$this->_exists($var_name)) - { - return false; - } - - return $this->_read($var_name); - } - else - { - return ($this->_exists($var_name)) ? $this->vars[$var_name] : false; - } - } - - /** - * {@inheritDoc} - */ - function put($var_name, $var, $ttl = 2592000) - { - if ($var_name[0] == '_') - { - $this->_write($var_name, $var, $ttl); - } - else - { - $this->vars[$var_name] = $var; - $this->is_modified = true; - } - } - - /** - * {@inheritDoc} - */ - function destroy($var_name, $table = '') - { - if ($var_name == 'sql' && !empty($table)) - { - if (!is_array($table)) - { - $table = array($table); - } - - foreach ($table as $table_name) - { - // gives us the md5s that we want - $temp = $this->_read('sql_' . $table_name); - - if ($temp === false) - { - continue; - } - - // delete each query ref - foreach ($temp as $md5_id => $void) - { - $this->_delete('sql_' . $md5_id); - } - - // delete the table ref - $this->_delete('sql_' . $table_name); - } - - return; - } - - if (!$this->_exists($var_name)) - { - return; - } - - if ($var_name[0] == '_') - { - $this->_delete($var_name); - } - else if (isset($this->vars[$var_name])) - { - $this->is_modified = true; - unset($this->vars[$var_name]); - - // We save here to let the following cache hits succeed - $this->save(); - } - } - - /** - * {@inheritDoc} - */ - function _exists($var_name) - { - if ($var_name[0] == '_') - { - return $this->_isset($var_name); - } - else - { - if (!count($this->vars)) - { - $this->load(); - } - - return isset($this->vars[$var_name]); - } - } - - /** - * {@inheritDoc} - */ - function sql_save(\phpbb\db\driver\driver_interface $db, $query, $query_result, $ttl) - { - // Remove extra spaces and tabs - $query = preg_replace('/[\n\r\s\t]+/', ' ', $query); - $query_id = md5($query); - - // determine which tables this query belongs to - // Some queries use backticks, namely the get_database_size() query - // don't check for conformity, the SQL would error and not reach here. - if (!preg_match_all('/(?:FROM \\(?(`?\\w+`?(?: \\w+)?(?:, ?`?\\w+`?(?: \\w+)?)*)\\)?)|(?:JOIN (`?\\w+`?(?: \\w+)?))/', $query, $regs, PREG_SET_ORDER)) - { - // Bail out if the match fails. - return $query_result; - } - - $tables = array(); - foreach ($regs as $match) - { - if ($match[0][0] == 'F') - { - $tables = array_merge($tables, array_map('trim', explode(',', $match[1]))); - } - else - { - $tables[] = $match[2]; - } - } - - foreach ($tables as $table_name) - { - // Remove backticks - $table_name = ($table_name[0] == '`') ? substr($table_name, 1, -1) : $table_name; - - if (($pos = strpos($table_name, ' ')) !== false) - { - $table_name = substr($table_name, 0, $pos); - } - - $temp = $this->_read('sql_' . $table_name); - - if ($temp === false) - { - $temp = array(); - } - - $temp[$query_id] = true; - - // This must never expire - $this->_write('sql_' . $table_name, $temp, 0); - } - - // store them in the right place - $this->sql_rowset[$query_id] = array(); - $this->sql_row_pointer[$query_id] = 0; - - while ($row = $db->sql_fetchrow($query_result)) - { - $this->sql_rowset[$query_id][] = $row; - } - $db->sql_freeresult($query_result); - - $this->_write('sql_' . $query_id, $this->sql_rowset[$query_id], $ttl); - - return $query_id; - } - - /** - * Check if a cache var exists - * - * @access protected - * @param string $var Cache key - * @return bool True if it exists, otherwise false - */ - function _isset($var) - { - // Most caches don't need to check - return true; - } -} diff --git a/install/update/old/phpbb/captcha/non_gd.php b/install/update/old/phpbb/captcha/non_gd.php deleted file mode 100644 index 3818672..0000000 --- a/install/update/old/phpbb/captcha/non_gd.php +++ /dev/null @@ -1,386 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\captcha; - -/** -* Main non-gd captcha class -* @ignore -*/ -class non_gd -{ - var $filtered_pngs; - var $width = 320; - var $height = 50; - - /** - * Define filtered pngs on init - */ - function __construct() - { - // If we can we will generate a single filtered png, we avoid nastiness via emulation of some Zlib stuff - $this->define_filtered_pngs(); - } - - /** - * Create the image containing $code with a seed of $seed - */ - function execute($code, $seed) - { - $img_height = $this->height - 10; - $img_width = 0; - - mt_srand($seed); - - $char_widths = $hold_chars = array(); - $code_len = strlen($code); - - for ($i = 0; $i < $code_len; $i++) - { - $char = $code[$i]; - - $width = mt_rand(0, 4); - $raw_width = $this->filtered_pngs[$char]['width']; - $char_widths[$i] = $width; - $img_width += $raw_width - $width; - - // Split the char into chunks of $raw_width + 1 length - if (empty($hold_chars[$char])) - { - $hold_chars[$char] = str_split(base64_decode($this->filtered_pngs[$char]['data']), $raw_width + 1); - } - } - - $offset_x = mt_rand(0, $this->width - $img_width); - $offset_y = mt_rand(0, $this->height - $img_height); - - $image = ''; - for ($i = 0; $i < $this->height; $i++) - { - $image .= chr(0); - - if ($i > $offset_y && $i < $offset_y + $img_height) - { - for ($j = 0; $j < $offset_x; $j++) - { - $image .= chr(mt_rand(140, 255)); - } - - for ($j = 0; $j < $code_len; $j++) - { - $image .= $this->randomise(substr($hold_chars[$code{$j}][$i - $offset_y - 1], 1), $char_widths[$j]); - } - - for ($j = $offset_x + $img_width; $j < $this->width; $j++) - { - $image .= chr(mt_rand(140, 255)); - } - } - else - { - for ($j = 0; $j < $this->width; $j++) - { - $image .= chr(mt_rand(140, 255)); - } - } - } - unset($hold_chars); - - $image = $this->create_png($image, $this->width, $this->height); - - // Output image - header('Content-Type: image/png'); - header('Cache-control: no-cache, no-store'); - echo $image; - exit; - } - - /** - * This is designed to randomise the pixels of the image data within - * certain limits so as to keep it readable. It also varies the image - * width a little - */ - function randomise($scanline, $width) - { - $new_line = ''; - - $end = strlen($scanline) - ceil($width/2); - for ($i = (int) floor($width / 2); $i < $end; $i++) - { - $pixel = ord($scanline{$i}); - - if ($pixel < 190) - { - $new_line .= chr(mt_rand(0, 205)); - } - else if ($pixel > 190) - { - $new_line .= chr(mt_rand(145, 255)); - } - else - { - $new_line .= $scanline{$i}; - } - } - - return $new_line; - } - - /** - * This creates a chunk of the given type, with the given data - * of the given length adding the relevant crc - */ - function png_chunk($length, $type, $data) - { - $raw = $type . $data; - - return pack('N', $length) . $raw . pack('N', crc32($raw)); - } - - /** - * Creates greyscale 8bit png - The PNG spec can be found at - * http://www.libpng.org/pub/png/spec/PNG-Contents.html we use - * png because it's a fully recognised open standard and supported - * by practically all modern browsers and OSs - */ - function create_png($raw_image, $width, $height) - { - // SIG - $image = pack('C8', 137, 80, 78, 71, 13, 10, 26, 10); - - // IHDR - $raw = pack('N2', $width, $height); - $raw .= pack('C5', 8, 0, 0, 0, 0); - $image .= $this->png_chunk(13, 'IHDR', $raw); - - // IDAT - if (@extension_loaded('zlib')) - { - $raw_image = gzcompress($raw_image); - $length = strlen($raw_image); - } - else - { - // The total length of this image, uncompressed, is just a calculation of pixels - $length = ($width + 1) * $height; - - // Adler-32 hash generation - // Note: The hash is _backwards_ so we must reverse it - - if (@extension_loaded('hash')) - { - $adler_hash = strrev(hash('adler32', $raw_image, true)); - } - else if (@extension_loaded('mhash')) - { - $adler_hash = strrev(mhash(MHASH_ADLER32, $raw_image)); - } - else - { - // Optimized Adler-32 loop ported from the GNU Classpath project - $temp_length = $length; - $s1 = 1; - $s2 = $index = 0; - - while ($temp_length > 0) - { - // We can defer the modulo operation: - // s1 maximally grows from 65521 to 65521 + 255 * 3800 - // s2 maximally grows by 3800 * median(s1) = 2090079800 < 2^31 - $substract_value = ($temp_length < 3800) ? $temp_length : 3800; - $temp_length -= $substract_value; - - while (--$substract_value >= 0) - { - $s1 += ord($raw_image[$index]); - $s2 += $s1; - - $index++; - } - - $s1 %= 65521; - $s2 %= 65521; - } - $adler_hash = pack('N', ($s2 << 16) | $s1); - } - - // This is the same thing as gzcompress($raw_image, 0) but does not need zlib - $raw_image = pack('C3v2', 0x78, 0x01, 0x01, $length, ~$length) . $raw_image . $adler_hash; - - // The Zlib header + Adler hash make us add on 11 - $length += 11; - } - - // IDAT - $image .= $this->png_chunk($length, 'IDAT', $raw_image); - - // IEND - $image .= $this->png_chunk(0, 'IEND', ''); - - return $image; - } - - /** - * png image data - * Each 'data' element is base64_encoded uncompressed IDAT - */ - function define_filtered_pngs() - { - $this->filtered_pngs = array( - '0' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A///////////////////olFAkBAAAGDyA4P///M31/////////////wD////////////////0dAgAAAAAAAAAAAAEcPipFGHn////////////AP//////////////6DAAAAAAAAAAAAAAAAAALSEAN+T///////////8A//////////////xAAAAAAAAAAAAAAAAAAAAAACPA/////////////wD/////////////oAAAAAAAAAAAAAAAAAAAAAAAev//////////////AP////////////8oAAAAAAAAPNj/zDAAAAAAAABD//////////////8A////////////1AAAAAAAABjw////5BAAAAAAAADo/////////////wD///////////+QAAAAAAAAbP//////QgAAAAAAAKj/////////////AP///////////1wAAAAAAACs/////8AXAAAAAAAAcP////////////8A////////////OAAAAAAAAND////dNwAAAAAAAABI/////////////wD///////////8gAAAAAAAA4P//7koACwAAAAAAACT/////////////AP///////////wgAAAAAAAD///VqAwaPAAAAAAAAEP////////////8A////////////AAAAAAAAAP/8kQYDavUAAAAAAAAA/////////////wD///////////8AAAAAAAAA/6kNAEru/wAAAAAAAAD/////////////AP///////////wAAAAAAAADAIwA33f//AAAAAAAAAP////////////8A////////////FAAAAAAAADYAI8D///8AAAAAAAAQ/////////////wD///////////8kAAAAAAAAAA2p////5AAAAAAAACD/////////////AP///////////0gAAAAAAAAFkfz////UAAAAAAAAQP////////////8A////////////cAAAAAAAAET1/////7AAAAAAAABo/////////////wD///////////+oAAAAAAAAXfX/////sAAAAAAAAGj/////////////AAAAALgAAAAAAAAwAAAAAAAAAAAAAAD////////////oAAAAAAAACOT////oEAAAAAAAAOD/////////////AP////////////8+AAAAAAAAKMz/zDQAAAAAAAA0//////////////8A////////////7jgAAAAAAAAAAAAAAAAAAAAAAKT//////////////wD///////////VqAwIAAAAAAAAAAAAAAAAAAAA8////////////////AP//////////rQcDaVEAAAAAAAAAAAAAAAAAKOj///////////////8A///////////nblnu/IAIAAAAAAAAAAAAAFzw/////////////////wD////////////79////+iITCAAAAAgSITg////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////w==', - 'width' => 40 - ), - '1' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////8BAAAAAAAP//////////////////AP////////////////////////9sAAAAAAAA//////////////////8A////////////////////////pAAAAAAAAAD//////////////////wD//////////////////////6wEAAAAAAAAAP//////////////////AP////////////////////h4AAAAAAAAAAAA//////////////////8A//////////////////ygJAAAAAAAAAAAAAD//////////////////wD//////////////9x8HAAAAAAAAAAAAAAAAP//////////////////AP//////////////AAAAAAAAAAAAAAAAAAAA//////////////////8A//////////////8AAAAAAAAAAAAAAAAAAAD//////////////////wD//////////////wAAAAAAAAR4AAAAAAAAAP//////////////////AP//////////////AAAAAAA4zP8AAAAAAAAA//////////////////8A//////////////8AAAA4sP///wAAAAAAAAD//////////////////wD//////////////yR80P//////AAAAAAAAAP//////////////////AP////////////////////////8AAAAAAAAA//////////////////8A/////////////////////////wAAAAAAAAD//////////////////wD/////////////////////////AAAAAAAAAP//////////////////AP////////////////////////8AAAAAAAAA//////////////////8A/////////////////////////wAAAAAAAAD//////////////////wD/////////////////////////AAAAAAAAAP//////////////////AP////////////////////////8AAAAAAAAA//////////////////8A/////////////////////////wAAAAAAAAD//////////////////wD/////////////////////////AAAAAAAAAP//////////////////AP////////////////////////8AAAAAAAAA//////////////////8A/////////////////////////wAAAAAAAAD//////////////////wD/////////////////////////AAAAAAAAAP//////////////////AP////////////////////////8AAAAAAAAA//////////////////8A/////////////////////////wAAAAAAAAD//////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - '2' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP/////////////////okFAkCAAABCBIfNT///////////////////8A///////////////8hAgAAAAAAAAAAAAAAFTo/////////////////wD//////////////1QAAAAAAAAAAAAAAAAAACjo////////////////AP////////////+MAAAAAAAAAAAAAAAAAAAAADj///////////////8A////////////9BAAAAAAAAAAAAAAAAAAAAAAALD//////////////wD///////////+gAAAAAAAAAHjs+KwMAAAAAAAAVP//////////////AP///////////1gAAAAAAABM/////6QAAAAAAAAU//////////////8A////////////KAAAAAAAALj/////+AAAAAAAAAD//////////////wD///////////+MfGBMOCAI8P/////wAAAAAAAACP//////////////AP///////////////////////////5wAAAAAAAAw//////////////8A///////////////////////////oFAAAAAAAAHz//////////////wD/////////////////////////6CgAAAAAAAAE3P//////////////AP///////////////////////9ggAAAAAAAAAHT///////////////8A//////////////////////+0DAAAAAAAAAA8+P///////////////wD/////////////////////gAAAAAAAAAAAKOj/////////////////AP//////////////////9FAAAAAAAAAAADzw//////////////////8A/////////////////+g4AAAAAAAAAABk/P///////////////////wD////////////////oKAAAAAAAAAAMqP//////////////////////AP//////////////6CgAAAAAAAAAMNz///////////////////////8A//////////////g4AAAAAAAAAFT0/////////////////////////wD/////////////bAAAAAAAAABU/P//////////////////////////AP///////////8wAAAAAAAAAAAAAAAAAAAAAAAAA//////////////8A////////////SAAAAAAAAAAAAAAAAAAAAAAAAAD//////////////wD//////////9wAAAAAAAAAAAAAAAAAAAAAAAAAAP//////////////AP//////////hAAAAAAAAAAAAAAAAAAAAAAAAAAA//////////////8A//////////9AAAAAAAAAAAAAAAAAAAAAAAAAAAD//////////////wD//////////xAAAAAAAAAAAAAAAAAAAAAAAAAAAP//////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - '3' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD////////////////8sGg0FAAAACA4cLz8////////////////////AP//////////////rBgAAAAAAAAAAAAAACTA//////////////////8A/////////////3QAAAAAAAAAAAAAAAAAAASs/////////////////wD///////////+YAAAAAAAAAAAAAAAAAAAAAAjc////////////////AP//////////6AwAAAAAAAAAAAAAAAAAAAAAAGT///////////////8A//////////94AAAAAAAABJDw/8g4AAAAAAAAHP///////////////wD//////////yAAAAAAAACE/////9gAAAAAAAAA////////////////AP///////////NSwiGQ4FOT//////AAAAAAAABD///////////////8A//////////////////////////+YAAAAAAAAVP///////////////wD//////////////////////P/ggAQAAAAAAATM////////////////AP////////////////////9gAAAAAAAAAAAElP////////////////8A/////////////////////0AAAAAAAAAAHLj//////////////////wD/////////////////////OAAAAAAAAAAwkPj/////////////////AP////////////////////8gAAAAAAAAAAAAINj///////////////8A/////////////////////xAAAAAAAAAAAAAAIPD//////////////wD/////////////////////uOz/4HgEAAAAAAAAhP//////////////AP///////////////////////////3wAAAAAAAAw//////////////8A////////////////////////////6AAAAAAAAAj//////////////wD/////////////////////////////AAAAAAAAAP//////////////AP//////////tJh8YEQoDNz//////+AAAAAAAAAY//////////////8A//////////88AAAAAAAAaP//////dAAAAAAAAEz//////////////wD//////////6QAAAAAAAAAdOD/5HQAAAAAAAAApP//////////////AP///////////CgAAAAAAAAAAAAAAAAAAAAAACD4//////////////8A////////////yAQAAAAAAAAAAAAAAAAAAAAEuP///////////////wD/////////////rAQAAAAAAAAAAAAAAAAABJD/////////////////AP//////////////zDQAAAAAAAAAAAAAACTA//////////////////8A/////////////////8BwOCAAAAAUNGi0/P///////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - '4' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP//////////////////////////nAAAAAAAAAD///////////////8A/////////////////////////8AEAAAAAAAAAP///////////////wD////////////////////////gGAAAAAAAAAAA////////////////AP//////////////////////9DAAAAAAAAAAAAD///////////////8A//////////////////////9UAAAAAAAAAAAAAP///////////////wD/////////////////////hAAAAAAAAAAAAAAA////////////////AP///////////////////7QAAAAAAAAAAAAAAAD///////////////8A///////////////////UDAAAAAAUAAAAAAAAAP///////////////wD/////////////////7CQAAAAABMAAAAAAAAAA////////////////AP////////////////xEAAAAAACU/wAAAAAAAAD///////////////8A////////////////cAAAAAAAZP//AAAAAAAAAP///////////////wD//////////////6AAAAAAADz8//8AAAAAAAAA////////////////AP/////////////IBAAAAAAc6P///wAAAAAAAAD///////////////8A////////////5BgAAAAADMz/////AAAAAAAAAP///////////////wD///////////g0AAAAAACk//////8AAAAAAAAA////////////////AP//////////XAAAAAAAfP///////wAAAAAAAAD///////////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///////////8A////////////////////////////AAAAAAAAAP///////////////wD///////////////////////////8AAAAAAAAA////////////////AP///////////////////////////wAAAAAAAAD///////////////8A////////////////////////////AAAAAAAAAP///////////////wD///////////////////////////8AAAAAAAAA////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - '5' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP//////////////8AAAAAAAAAAAAAAAAAAAAAAA//////////////8A///////////////MAAAAAAAAAAAAAAAAAAAAAAD//////////////wD//////////////6wAAAAAAAAAAAAAAAAAAAAAAP//////////////AP//////////////iAAAAAAAAAAAAAAAAAAAAAAA//////////////8A//////////////9kAAAAAAAAAAAAAAAAAAAAAAD//////////////wD//////////////0QAAAAAAAAAAAAAAAAAAAAAAP//////////////AP//////////////IAAAAAAAYP////////////////////////////8A//////////////wAAAAAAAB8/////////////////////////////wD/////////////3AAAAAAAAIj/////////////////////////////AP////////////+4AAAAAAAAoLRYHAAEKGTE//////////////////8A/////////////5QAAAAAAAAQAAAAAAAAAABY9P///////////////wD/////////////dAAAAAAAAAAAAAAAAAAAAAA89P//////////////AP////////////9QAAAAAAAAAAAAAAAAAAAAAABg//////////////8A/////////////zAAAAAAAAAAAAAAAAAAAAAAAADQ/////////////wD/////////////IAAAAAAAAGjY/+h4BAAAAAAAAGz/////////////AP//////////////9NS0lHSc//////90AAAAAAAALP////////////8A/////////////////////////////9QAAAAAAAAE/////////////wD//////////////////////////////wAAAAAAAAD/////////////AP/////////////////////////////8AAAAAAAAEP////////////8A////////////pIRwWEAgDOD//////8wAAAAAAAA8/////////////wD///////////9EAAAAAAAAaP//////ZAAAAAAAAHz/////////////AP///////////6QAAAAAAAAAaOD/4GQAAAAAAAAE4P////////////8A/////////////CQAAAAAAAAAAAAAAAAAAAAAAGD//////////////wD/////////////yAQAAAAAAAAAAAAAAAAAAAAc7P//////////////AP//////////////rAwAAAAAAAAAAAAAAAAAGNj///////////////8A////////////////0EAAAAAAAAAAAAAAAFTo/////////////////wD//////////////////8h4QCAAAAAcQHzU////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - '6' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD///////////////////+0ZCwMAAAUNGjI////////////////////AP/////////////////EMAAAAAAAAAAAAABM6P////////////////8A////////////////lAQAAAAAAAAAAAAAAAAo6P///////////////wD//////////////6wAAAAAAAAAAAAAAAAAAABI////////////////AP/////////////oEAAAAAAAAAAAAAAAAAAAAACw//////////////8A/////////////3AAAAAAAAAoxP/YPAAAAAAAAEj//////////////wD////////////4EAAAAAAACOD////YDCBAVGiAoP//////////////AP///////////7gAAAAAAABY//////////////////////////////8A////////////eAAAAAAAAJT//////////////////////////////wD///////////9MAAAAAAAAvP/IXBgABCx03P//////////////////AP///////////ygAAAAAAADcdAAAAAAAAAAEiP////////////////8A////////////FAAAAAAAAFAAAAAAAAAAAAAAcP///////////////wD///////////8AAAAAAAAAAAAAAAAAAAAAAAAAlP//////////////AP///////////wAAAAAAAAAAAAAAAAAAAAAAAAAQ8P////////////8A////////////AAAAAAAAAABAyP/kZAAAAAAAAACQ/////////////wD///////////8MAAAAAAAALPj/////WAAAAAAAAET/////////////AP///////////yQAAAAAAACY///////MAAAAAAAAFP////////////8A////////////SAAAAAAAAMD///////wAAAAAAAAA/////////////wD///////////9wAAAAAAAAvP///////wAAAAAAAAD/////////////AP///////////7QAAAAAAACI///////UAAAAAAAAJP////////////8A////////////+AwAAAAAACDw/////2wAAAAAAABY/////////////wD/////////////cAAAAAAAADC8/Ox4AAAAAAAAAKj/////////////AP/////////////oEAAAAAAAAAAAAAAAAAAAAAAk/P////////////8A//////////////+oAAAAAAAAAAAAAAAAAAAABLj//////////////wD///////////////+QAAAAAAAAAAAAAAAAAACQ////////////////AP////////////////+0JAAAAAAAAAAAAAAkuP////////////////8A///////////////////8sGg0FAAADCxgqPz//////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - '7' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD///////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////AP///////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////8A////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////wD///////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////AP///////////wAAAAAAAAAAAAAAAAAAAAAAAAAABP////////////8A////////////AAAAAAAAAAAAAAAAAAAAAAAAAAy4/////////////wD//////////////////////////+QUAAAAAAAEuP//////////////AP/////////////////////////8QAAAAAAAAKT///////////////8A/////////////////////////4wAAAAAAAB0/////////////////wD////////////////////////cCAAAAAAANPz/////////////////AP///////////////////////0QAAAAAAATY//////////////////8A//////////////////////+0AAAAAAAAeP///////////////////wD//////////////////////CQAAAAAABTw////////////////////AP////////////////////+gAAAAAAAAkP////////////////////8A/////////////////////ywAAAAAABDw/////////////////////wD///////////////////+4AAAAAAAAbP//////////////////////AP///////////////////1wAAAAAAADQ//////////////////////8A///////////////////4DAAAAAAAMP///////////////////////wD//////////////////7QAAAAAAAB8////////////////////////AP//////////////////aAAAAAAAAMj///////////////////////8A//////////////////8oAAAAAAAM/P///////////////////////wD/////////////////8AAAAAAAAET/////////////////////////AP////////////////+0AAAAAAAAcP////////////////////////8A/////////////////4wAAAAAAACY/////////////////////////wD/////////////////WAAAAAAAAMD/////////////////////////AP////////////////80AAAAAAAA4P////////////////////////8A/////////////////xAAAAAAAAD4/////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - '8' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD////////////////////IdDQUAAAEIEiA1P//////////////////AP/////////////////gRAAAAAAAAAAAAAAAROD///////////////8A////////////////0BgAAAAAAAAAAAAAAAAAEMj//////////////wD///////////////AcAAAAAAAAAAAAAAAAAAAAHPD/////////////AP//////////////hAAAAAAAAAAAAAAAAAAAAAAAhP////////////8A//////////////8sAAAAAAAAKMz/zCgAAAAAAAAs/////////////wD//////////////wAAAAAAAADM////zAAAAAAAAAD/////////////AP//////////////BAAAAAAAAP//////AAAAAAAABP////////////8A//////////////8sAAAAAAAAzP///9QAAAAAAAAw/////////////wD//////////////3wAAAAAAAAoyP/YNAAAAAAAAIT/////////////AP//////////////7BgAAAAAAAAAAAAAAAAAAAAc8P////////////8A////////////////xBgAAAAAAAAAAAAAAAAAGNj//////////////wD/////////////////tAQAAAAAAAAAAAAAAACo////////////////AP///////////////HAAAAAAAAAAAAAAAAAAAAB8//////////////8A//////////////9gAAAAAAAAAAAAAAAAAAAAAAB8/////////////wD/////////////wAAAAAAAAABk4P/UWAAAAAAAAATQ////////////AP////////////9UAAAAAAAAaP//////XAAAAAAAAGT///////////8A/////////////xgAAAAAAADg///////cAAAAAAAAJP///////////wD/////////////AAAAAAAAAP////////8AAAAAAAAA////////////AP////////////8AAAAAAAAA4P//////3AAAAAAAAAT///////////8A/////////////ygAAAAAAABg//////9cAAAAAAAALP///////////wD/////////////ZAAAAAAAAABY1P/cXAAAAAAAAABw////////////AP/////////////QAAAAAAAAAAAAAAAAAAAAAAAABNz///////////8A//////////////9gAAAAAAAAAAAAAAAAAAAAAAB0/////////////wD///////////////Q8AAAAAAAAAAAAAAAAAAAAUPz/////////////AP////////////////x4CAAAAAAAAAAAAAAAEIT8//////////////8A///////////////////smFQwGAAAABg0ZKT0/////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - '9' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD///////////////////ysYCwMAAAUNGiw/P//////////////////AP////////////////+4JAAAAAAAAAAAAAAkuP////////////////8A////////////////lAQAAAAAAAAAAAAAAAAAkP///////////////wD//////////////8AEAAAAAAAAAAAAAAAAAAAAqP//////////////AP/////////////8JAAAAAAAAAAAAAAAAAAAAAAQ7P////////////8A/////////////6wAAAAAAAAAfOz8vCwAAAAAAABw/////////////wD/////////////WAAAAAAAAHD/////7BgAAAAAAAz4////////////AP////////////8kAAAAAAAA1P//////hAAAAAAAALT///////////8A/////////////wAAAAAAAAD///////+4AAAAAAAAcP///////////wD/////////////AAAAAAAAAPz//////8AAAAAAAABI////////////AP////////////8UAAAAAAAAzP//////lAAAAAAAACT///////////8A/////////////0QAAAAAAABY//////gsAAAAAAAADP///////////wD/////////////kAAAAAAAAABw5P/IPAAAAAAAAAAA////////////AP/////////////wEAAAAAAAAAAAAAAAAAAAAAAAAAD///////////8A//////////////+UAAAAAAAAAAAAAAAAAAAAAAAAAP///////////wD///////////////9wAAAAAAAAAAAAAFAAAAAAAAAU////////////AP////////////////+IBAAAAAAAAABw3AAAAAAAACj///////////8A///////////////////cdCwEABhcxP+8AAAAAAAATP///////////wD//////////////////////////////5AAAAAAAAB4////////////AP//////////////////////////////UAAAAAAAALj///////////8A//////////////+kgGxUQCAM2P///+AIAAAAAAAQ+P///////////wD//////////////0gAAAAAAAA42P/EKAAAAAAAAHD/////////////AP//////////////sAAAAAAAAAAAAAAAAAAAAAAQ6P////////////8A////////////////TAAAAAAAAAAAAAAAAAAAAKz//////////////wD////////////////oKAAAAAAAAAAAAAAAAASU////////////////AP/////////////////sUAAAAAAAAAAAAAAwxP////////////////8A////////////////////yHA0FAAADCxktP///////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'A' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD//////////////////+QAAAAAAAAAAAAAAOT/////////////////AP//////////////////kAAAAAAAAAAAAAAAkP////////////////8A//////////////////88AAAAAAAAAAAAAAA8/////////////////wD/////////////////5AAAAAAAAAAAAAAAAADk////////////////AP////////////////+QAAAAAAAAAAAAAAAAAJD///////////////8A/////////////////zwAAAAAAAAAAAAAAAAAPP///////////////wD////////////////kAAAAAAAAAAgAAAAAAAAA5P//////////////AP///////////////5AAAAAAAAAAgAAAAAAAAACQ//////////////8A////////////////PAAAAAAAAAz8HAAAAAAAADz//////////////wD//////////////+QAAAAAAAAAWP9kAAAAAAAAANz/////////////AP//////////////kAAAAAAAAACk/7wAAAAAAAAAhP////////////8A//////////////88AAAAAAAABOz//BQAAAAAAAAw/////////////wD/////////////4AAAAAAAAAA8////ZAAAAAAAAADc////////////AP////////////+EAAAAAAAAAIj///+8AAAAAAAAAIT///////////8A/////////////zAAAAAAAAAA2P////wQAAAAAAAAMP///////////wD////////////cAAAAAAAAACT//////1wAAAAAAAAA3P//////////AP///////////4QAAAAAAAAAAAAAAAAAAAAAAAAAAACE//////////8A////////////MAAAAAAAAAAAAAAAAAAAAAAAAAAAADD//////////wD//////////9wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANz/////////AP//////////hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAhP////////8A//////////8wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAw/////////wD/////////3AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADc////////AP////////+EAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIT///////8A/////////zAAAAAAAAAAhP///////////2QAAAAAAAAAMP///////wD////////cAAAAAAAAAADM////////////vAAAAAAAAAAA3P//////AP///////4QAAAAAAAAAHP/////////////4DAAAAAAAAACE//////8A////////MAAAAAAAAABk//////////////9cAAAAAAAAADD//////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'B' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A//////////8AAAAAAAAAAAAAAAAAAAAAEDh83P///////////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAEhP//////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAeP////////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAxP///////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAABY////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAABT///////////8A//////////8AAAAAAAAAAP/////4zEwAAAAAAAAAAP///////////wD//////////wAAAAAAAAAA////////7AAAAAAAAAAQ////////////AP//////////AAAAAAAAAAD////////sAAAAAAAAAEj///////////8A//////////8AAAAAAAAAAP/////4zEQAAAAAAAAAtP///////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAFz/////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAiA/P////////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAIjPj//////////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAGKz/////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAJT///////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAABNz//////////wD//////////wAAAAAAAAAA///////sqCAAAAAAAAAAbP//////////AP//////////AAAAAAAAAAD/////////yAAAAAAAAAAs//////////8A//////////8AAAAAAAAAAP//////////AAAAAAAAAAT//////////wD//////////wAAAAAAAAAA/////////7wAAAAAAAAAAP//////////AP//////////AAAAAAAAAAD//////+ikGAAAAAAAAAAY//////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFT//////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAsP//////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAADj///////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAc6P///////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAATOj/////////////AP//////////AAAAAAAAAAAAAAAAAAAEIEBkkNj///////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'C' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP//////////////////5JRULBAAAAgkTIDQ//////////////////8A////////////////1FAAAAAAAAAAAAAAAABAyP///////////////wD//////////////4gEAAAAAAAAAAAAAAAAAAAElP//////////////AP////////////9wAAAAAAAAAAAAAAAAAAAAAAAAlP////////////8A////////////kAAAAAAAAAAAAAAAAAAAAAAAAAAEyP///////////wD//////////9wIAAAAAAAAAAAAAAAAAAAAAAAAAAAw////////////AP//////////WAAAAAAAAAAAWMz/8JwQAAAAAAAAAACw//////////8A/////////+wEAAAAAAAAAID//////9QMAAAAAAAAAET//////////wD/////////nAAAAAAAAAAo/P///////3wAAAAABDBspP//////////AP////////9gAAAAAAAAAIz/////////3BxQjMT0//////////////8A/////////zQAAAAAAAAAzP///////////////////////////////wD/////////GAAAAAAAAADo////////////////////////////////AP////////8AAAAAAAAAAP////////////////////////////////8A/////////wAAAAAAAAAA/////////////////////////////////wD/////////AAAAAAAAAAD/////////////////////////////////AP////////8cAAAAAAAAAOj///////////////////////////////8A/////////zgAAAAAAAAA0P/////////kIGio7P///////////////wD/////////bAAAAAAAAACg/////////5wAAAAAMHS49P//////////AP////////+oAAAAAAAAAEz/////////PAAAAAAAAAAc//////////8A//////////QIAAAAAAAAALz//////6QAAAAAAAAAAGT//////////wD//////////3AAAAAAAAAADIzo/+SEBAAAAAAAAAAAyP//////////AP//////////7BAAAAAAAAAAAAAAAAAAAAAAAAAAAED///////////8A////////////rAAAAAAAAAAAAAAAAAAAAAAAAAAE0P///////////wD/////////////fAAAAAAAAAAAAAAAAAAAAAAAAJz/////////////AP//////////////iAQAAAAAAAAAAAAAAAAAAASY//////////////8A////////////////yEAAAAAAAAAAAAAAAAA8yP///////////////wD//////////////////9yIUCwQAAAAIEB4yP//////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'D' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD///////////8AAAAAAAAAAAAAAAAADChQkOT/////////////////AP///////////wAAAAAAAAAAAAAAAAAAAAAABGjw//////////////8A////////////AAAAAAAAAAAAAAAAAAAAAAAAACDY/////////////wD///////////8AAAAAAAAAAAAAAAAAAAAAAAAAABjk////////////AP///////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAED///////////8A////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAKj//////////wD///////////8AAAAAAAAAAP///+isSAAAAAAAAAAANP//////////AP///////////wAAAAAAAAAA////////hAAAAAAAAAAA2P////////8A////////////AAAAAAAAAAD/////////MAAAAAAAAACQ/////////wD///////////8AAAAAAAAAAP////////+MAAAAAAAAAFj/////////AP///////////wAAAAAAAAAA/////////8gAAAAAAAAAMP////////8A////////////AAAAAAAAAAD/////////5AAAAAAAAAAY/////////wD///////////8AAAAAAAAAAP//////////AAAAAAAAAAD/////////AP///////////wAAAAAAAAAA//////////8AAAAAAAAAAP////////8A////////////AAAAAAAAAAD//////////wAAAAAAAAAA/////////wD///////////8AAAAAAAAAAP/////////wAAAAAAAAABD/////////AP///////////wAAAAAAAAAA/////////9QAAAAAAAAAJP////////8A////////////AAAAAAAAAAD/////////qAAAAAAAAABI/////////wD///////////8AAAAAAAAAAP////////9QAAAAAAAAAHj/////////AP///////////wAAAAAAAAAA////////uAAAAAAAAAAAvP////////8A////////////AAAAAAAAAAD////w0HwEAAAAAAAAACT8/////////wD///////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAoP//////////AP///////////wAAAAAAAAAAAAAAAAAAAAAAAAAAADz8//////////8A////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAY6P///////////wD///////////8AAAAAAAAAAAAAAAAAAAAAAAAAKNz/////////////AP///////////wAAAAAAAAAAAAAAAAAAAAAACHT0//////////////8A////////////AAAAAAAAAAAAAAAAABg4bKj0/////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'E' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////AP//////////AAAAAAAAAAD///////////////////////////////8A//////////8AAAAAAAAAAP///////////////////////////////wD//////////wAAAAAAAAAA////////////////////////////////AP//////////AAAAAAAAAAD///////////////////////////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAD//////////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAP//////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAA//////////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAD//////////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAP//////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAA//////////////8A//////////8AAAAAAAAAAP///////////////////////////////wD//////////wAAAAAAAAAA////////////////////////////////AP//////////AAAAAAAAAAD///////////////////////////////8A//////////8AAAAAAAAAAP///////////////////////////////wD//////////wAAAAAAAAAA////////////////////////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'F' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////wAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////wD/////////////AAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////AP////////////8AAAAAAAAAAAAAAAAAAAAAAAAAAP////////////8A/////////////wAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////wD/////////////AAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////AP////////////8AAAAAAAAAAAAAAAAAAAAAAAAAAP////////////8A/////////////wAAAAAAAAAA/////////////////////////////wD/////////////AAAAAAAAAAD/////////////////////////////AP////////////8AAAAAAAAAAP////////////////////////////8A/////////////wAAAAAAAAAA/////////////////////////////wD/////////////AAAAAAAAAAAAAAAAAAAAAAAA////////////////AP////////////8AAAAAAAAAAAAAAAAAAAAAAAD///////////////8A/////////////wAAAAAAAAAAAAAAAAAAAAAAAP///////////////wD/////////////AAAAAAAAAAAAAAAAAAAAAAAA////////////////AP////////////8AAAAAAAAAAAAAAAAAAAAAAAD///////////////8A/////////////wAAAAAAAAAAAAAAAAAAAAAAAP///////////////wD/////////////AAAAAAAAAAD/////////////////////////////AP////////////8AAAAAAAAAAP////////////////////////////8A/////////////wAAAAAAAAAA/////////////////////////////wD/////////////AAAAAAAAAAD/////////////////////////////AP////////////8AAAAAAAAAAP////////////////////////////8A/////////////wAAAAAAAAAA/////////////////////////////wD/////////////AAAAAAAAAAD/////////////////////////////AP////////////8AAAAAAAAAAP////////////////////////////8A/////////////wAAAAAAAAAA/////////////////////////////wD/////////////AAAAAAAAAAD/////////////////////////////AP////////////8AAAAAAAAAAP////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'G' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD//////////////////MB8TCgQAAAACCA4YJzs////////////////AP///////////////JQcAAAAAAAAAAAAAAAAAAhw8P////////////8A/////////////9gwAAAAAAAAAAAAAAAAAAAAAAAk2P///////////wD////////////EDAAAAAAAAAAAAAAAAAAAAAAAAAAc7P//////////AP//////////2AwAAAAAAAAAAAAAAAAAAAAAAAAAAABY//////////8A//////////wwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQ/////////wD/////////kAAAAAAAAAAAEHzQ/P/gmCAAAAAAAAAAAFz/////////AP////////wcAAAAAAAAACjg////////8CwAAAAAAAAgWP////////8A////////vAAAAAAAAAAI2P//////////yBRAcJjI8P///////////wD///////94AAAAAAAAAGD/////////////////////////////////AP///////0AAAAAAAAAAsP////////////////////////////////8A////////IAAAAAAAAADc/////////////////////////////////wD///////8AAAAAAAAAAP///////wAAAAAAAAAAAAAAAAD/////////AP///////wAAAAAAAAAA////////AAAAAAAAAAAAAAAAAP////////8A////////AAAAAAAAAAD///////8AAAAAAAAAAAAAAAAA/////////wD///////8gAAAAAAAAAOD//////wAAAAAAAAAAAAAAAAD/////////AP///////0AAAAAAAAAAtP//////AAAAAAAAAAAAAAAAAP////////8A////////cAAAAAAAAABw//////8AAAAAAAAAAAAAAAAA/////////wD///////+8AAAAAAAAABDs////////////AAAAAAAAAAD/////////AP////////wYAAAAAAAAADz0//////////AAAAAAAAAAAP////////8A/////////5AAAAAAAAAAACCY4P//3KhcCAAAAAAAAAAA/////////wD/////////+CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////AP//////////xAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIP////////8A////////////rAQAAAAAAAAAAAAAAAAAAAAAAAAAAGTw/////////wD/////////////vBQAAAAAAAAAAAAAAAAAAAAAADjI////////////AP//////////////8HAQAAAAAAAAAAAAAAAAAEiw//////////////8A//////////////////iwcEAgBAAABCA4aKDk/////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'H' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////8AAAAAAAAAAP///////////wAAAAAAAAAA//////////8A/////////wAAAAAAAAAA////////////AAAAAAAAAAD//////////wD/////////AAAAAAAAAAD///////////8AAAAAAAAAAP//////////AP////////8AAAAAAAAAAP///////////wAAAAAAAAAA//////////8A/////////wAAAAAAAAAA////////////AAAAAAAAAAD//////////wD/////////AAAAAAAAAAD///////////8AAAAAAAAAAP//////////AP////////8AAAAAAAAAAP///////////wAAAAAAAAAA//////////8A/////////wAAAAAAAAAA////////////AAAAAAAAAAD//////////wD/////////AAAAAAAAAAD///////////8AAAAAAAAAAP//////////AP////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//////////8A/////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//////////wD/////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP//////////AP////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//////////8A/////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//////////wD/////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP//////////AP////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//////////8A/////////wAAAAAAAAAA////////////AAAAAAAAAAD//////////wD/////////AAAAAAAAAAD///////////8AAAAAAAAAAP//////////AP////////8AAAAAAAAAAP///////////wAAAAAAAAAA//////////8A/////////wAAAAAAAAAA////////////AAAAAAAAAAD//////////wD/////////AAAAAAAAAAD///////////8AAAAAAAAAAP//////////AP////////8AAAAAAAAAAP///////////wAAAAAAAAAA//////////8A/////////wAAAAAAAAAA////////////AAAAAAAAAAD//////////wD/////////AAAAAAAAAAD///////////8AAAAAAAAAAP//////////AP////////8AAAAAAAAAAP///////////wAAAAAAAAAA//////////8A/////////wAAAAAAAAAA////////////AAAAAAAAAAD//////////wD/////////AAAAAAAAAAD///////////8AAAAAAAAAAP//////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'I' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////AAAAAAAAAAAAAAAAAAAAAAAA////////////////AP////////////8AAAAAAAAAAAAAAAAAAAAAAAD///////////////8A/////////////wAAAAAAAAAAAAAAAAAAAAAAAP///////////////wD/////////////AAAAAAAAAAAAAAAAAAAAAAAA////////////////AP////////////8AAAAAAAAAAAAAAAAAAAAAAAD///////////////8A/////////////wAAAAAAAAAAAAAAAAAAAAAAAP///////////////wD/////////////AAAAAAAAAAAAAAAAAAAAAAAA////////////////AP///////////////////wAAAAAAAAAA//////////////////////8A////////////////////AAAAAAAAAAD//////////////////////wD///////////////////8AAAAAAAAAAP//////////////////////AP///////////////////wAAAAAAAAAA//////////////////////8A////////////////////AAAAAAAAAAD//////////////////////wD///////////////////8AAAAAAAAAAP//////////////////////AP///////////////////wAAAAAAAAAA//////////////////////8A////////////////////AAAAAAAAAAD//////////////////////wD///////////////////8AAAAAAAAAAP//////////////////////AP///////////////////wAAAAAAAAAA//////////////////////8A////////////////////AAAAAAAAAAD//////////////////////wD///////////////////8AAAAAAAAAAP//////////////////////AP///////////////////wAAAAAAAAAA//////////////////////8A////////////////////AAAAAAAAAAD//////////////////////wD///////////////////8AAAAAAAAAAP//////////////////////AP////////////8AAAAAAAAAAAAAAAAAAAAAAAD///////////////8A/////////////wAAAAAAAAAAAAAAAAAAAAAAAP///////////////wD/////////////AAAAAAAAAAAAAAAAAAAAAAAA////////////////AP////////////8AAAAAAAAAAAAAAAAAAAAAAAD///////////////8A/////////////wAAAAAAAAAAAAAAAAAAAAAAAP///////////////wD/////////////AAAAAAAAAAAAAAAAAAAAAAAA////////////////AP////////////8AAAAAAAAAAAAAAAAAAAAAAAD///////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'J' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP///////////////////////////wAAAAAAAAAA//////////////8A////////////////////////////AAAAAAAAAAD//////////////wD///////////////////////////8AAAAAAAAAAP//////////////AP///////////////////////////wAAAAAAAAAA//////////////8A////////////////////////////AAAAAAAAAAD//////////////wD///////////////////////////8AAAAAAAAAAP//////////////AP///////////////////////////wAAAAAAAAAA//////////////8A////////////////////////////AAAAAAAAAAD//////////////wD///////////////////////////8AAAAAAAAAAP//////////////AP///////////////////////////wAAAAAAAAAA//////////////8A////////////////////////////AAAAAAAAAAD//////////////wD///////////////////////////8AAAAAAAAAAP//////////////AP///////////////////////////wAAAAAAAAAA//////////////8A////////////////////////////AAAAAAAAAAD//////////////wD///////////////////////////8AAAAAAAAAAP//////////////AP///////////////////////////wAAAAAAAAAA//////////////8A////////////////////////////AAAAAAAAAAj//////////////wD//////////+zMrIxwUDAQ//////wAAAAAAAAAIP//////////////AP//////////DAAAAAAAAADo////2AAAAAAAAAA0//////////////8A//////////8wAAAAAAAAAKj///+YAAAAAAAAAFj//////////////wD//////////2gAAAAAAAAAIND/yBgAAAAAAAAAkP//////////////AP//////////vAAAAAAAAAAAAAAAAAAAAAAAAADc//////////////8A////////////MAAAAAAAAAAAAAAAAAAAAAAAUP///////////////wD////////////EBAAAAAAAAAAAAAAAAAAAABjk////////////////AP////////////+sBAAAAAAAAAAAAAAAAAAY2P////////////////8A///////////////EMAAAAAAAAAAAAAAAVOj//////////////////wD/////////////////vHBAIAAAABg8fNT/////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'K' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD///////8AAAAAAAAAAP//////////wAQAAAAAAAAAAABw////////AP///////wAAAAAAAAAA/////////9AMAAAAAAAAAAAAcP////////8A////////AAAAAAAAAAD////////cGAAAAAAAAAAAAHD//////////wD///////8AAAAAAAAAAP//////6CgAAAAAAAAAAABs////////////AP///////wAAAAAAAAAA//////Q0AAAAAAAAAAAAVPz///////////8A////////AAAAAAAAAAD////8RAAAAAAAAAAAAFT8/////////////wD///////8AAAAAAAAAAP///1gAAAAAAAAAAABU/P//////////////AP///////wAAAAAAAAAA//9wAAAAAAAAAAAASPz///////////////8A////////AAAAAAAAAAD/jAAAAAAAAAAAADz0/////////////////wD///////8AAAAAAAAAAKQAAAAAAAAAAAA89P//////////////////AP///////wAAAAAAAAAABAAAAAAAAAAAFPT///////////////////8A////////AAAAAAAAAAAAAAAAAAAAAAAApP///////////////////wD///////8AAAAAAAAAAAAAAAAAAAAAAAAU8P//////////////////AP///////wAAAAAAAAAAAAAAAAAAAAAAAABk//////////////////8A////////AAAAAAAAAAAAAAAAAAAAAAAAAADE/////////////////wD///////8AAAAAAAAAAAAAAAAoEAAAAAAAACz8////////////////AP///////wAAAAAAAAAAAAAAGNiAAAAAAAAAAIj///////////////8A////////AAAAAAAAAAAAABjY//gYAAAAAAAACOD//////////////wD///////8AAAAAAAAAAAAY2P///5wAAAAAAAAASP//////////////AP///////wAAAAAAAAAAGNj//////CgAAAAAAAAAqP////////////8A////////AAAAAAAAAADI////////sAAAAAAAAAAc8P///////////wD///////8AAAAAAAAAAP//////////QAAAAAAAAABs////////////AP///////wAAAAAAAAAA///////////IAAAAAAAAAATI//////////8A////////AAAAAAAAAAD///////////9YAAAAAAAAADD8/////////wD///////8AAAAAAAAAAP///////////9wEAAAAAAAAAJD/////////AP///////wAAAAAAAAAA/////////////3AAAAAAAAAADOT///////8A////////AAAAAAAAAAD/////////////7BAAAAAAAAAAUP///////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'L' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////8AAAAAAAAAAP////////////////////////////8A/////////////wAAAAAAAAAA/////////////////////////////wD/////////////AAAAAAAAAAD/////////////////////////////AP////////////8AAAAAAAAAAP////////////////////////////8A/////////////wAAAAAAAAAA/////////////////////////////wD/////////////AAAAAAAAAAD/////////////////////////////AP////////////8AAAAAAAAAAP////////////////////////////8A/////////////wAAAAAAAAAA/////////////////////////////wD/////////////AAAAAAAAAAD/////////////////////////////AP////////////8AAAAAAAAAAP////////////////////////////8A/////////////wAAAAAAAAAA/////////////////////////////wD/////////////AAAAAAAAAAD/////////////////////////////AP////////////8AAAAAAAAAAP////////////////////////////8A/////////////wAAAAAAAAAA/////////////////////////////wD/////////////AAAAAAAAAAD/////////////////////////////AP////////////8AAAAAAAAAAP////////////////////////////8A/////////////wAAAAAAAAAA/////////////////////////////wD/////////////AAAAAAAAAAD/////////////////////////////AP////////////8AAAAAAAAAAP////////////////////////////8A/////////////wAAAAAAAAAA/////////////////////////////wD/////////////AAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////AP////////////8AAAAAAAAAAAAAAAAAAAAAAAAAAP////////////8A/////////////wAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////wD/////////////AAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////AP////////////8AAAAAAAAAAAAAAAAAAAAAAAAAAP////////////8A/////////////wAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////wD/////////////AAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'M' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A//////8AAAAAAAAAAAAAAHz//////3wAAAAAAAAAAAAAAP///////wD//////wAAAAAAAAAAAAAATP//////UAAAAAAAAAAAAAAA////////AP//////AAAAAAAAAAAAAAAc//////8cAAAAAAAAAAAAAAD///////8A//////8AAAAAAAAAAAAAAADw////8AAAAAAAAAAAAAAAAP///////wD//////wAAAAAAAAAAAAAAALz////AAAAAAAAAAAAAAAAA////////AP//////AAAAAAAAAAAAAAAAkP///5AAAAAAAAAAAAAAAAD///////8A//////8AAAAAAAAAAAAAAABc////ZAAAAAAAAAAAAAAAAP///////wD//////wAAAAAAAAAoAAAAADD///8wAAAAACQAAAAAAAAA////////AP//////AAAAAAAAAFwAAAAABPz//AgAAAAAXAAAAAAAAAD///////8A//////8AAAAAAAAAkAAAAAAA0P/UAAAAAACQAAAAAAAAAP///////wD//////wAAAAAAAADMAAAAAACg/6gAAAAAAMQAAAAAAAAA////////AP//////AAAAAAAAAPgEAAAAAHD/dAAAAAAE+AAAAAAAAAD///////8A//////8AAAAAAAAA/zQAAAAAQP9IAAAAADD/AAAAAAAAAP///////wD//////wAAAAAAAAD/bAAAAAAQ/xQAAAAAaP8AAAAAAAAA////////AP//////AAAAAAAAAP+gAAAAAADQAAAAAACc/wAAAAAAAAD///////8A//////8AAAAAAAAA/9QAAAAAAGgAAAAAAND/AAAAAAAAAP///////wD//////wAAAAAAAAD//wwAAAAAFAAAAAAM/P8AAAAAAAAA////////AP//////AAAAAAAAAP//RAAAAAAAAAAAADz//wAAAAAAAAD///////8A//////8AAAAAAAAA//94AAAAAAAAAAAAcP//AAAAAAAAAP///////wD//////wAAAAAAAAD//7AAAAAAAAAAAACo//8AAAAAAAAA////////AP//////AAAAAAAAAP//5AAAAAAAAAAAANz//wAAAAAAAAD///////8A//////8AAAAAAAAA////HAAAAAAAAAAQ////AAAAAAAAAP///////wD//////wAAAAAAAAD///9QAAAAAAAAAEz///8AAAAAAAAA////////AP//////AAAAAAAAAP///4gAAAAAAAAAfP///wAAAAAAAAD///////8A//////8AAAAAAAAA////vAAAAAAAAACw////AAAAAAAAAP///////wD//////wAAAAAAAAD////wAAAAAAAAAOz///8AAAAAAAAA////////AP//////AAAAAAAAAP////8sAAAAAAAc/////wAAAAAAAAD///////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'N' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////AAAAAAAAALD/////////////AAAAAAAAAP//////////AP////////8AAAAAAAAAFOj///////////8AAAAAAAAA//////////8A/////////wAAAAAAAAAASP///////////wAAAAAAAAD//////////wD/////////AAAAAAAAAAAAkP//////////AAAAAAAAAP//////////AP////////8AAAAAAAAAAAAI1P////////8AAAAAAAAA//////////8A/////////wAAAAAAAAAAAAAw+P///////wAAAAAAAAD//////////wD/////////AAAAAAAAAAAAAABw////////AAAAAAAAAP//////////AP////////8AAAAAAAAAAAAAAAC8//////8AAAAAAAAA//////////8A/////////wAAAAAAAAAAAAAAABzs/////wAAAAAAAAD//////////wD/////////AAAAAAAAAAAAAAAAAFD/////AAAAAAAAAP//////////AP////////8AAAAAAAAAAAAAAAAAAJz///8AAAAAAAAA//////////8A/////////wAAAAAAAAAUAAAAAAAADNz//wAAAAAAAAD//////////wD/////////AAAAAAAAALQAAAAAAAAANPz/AAAAAAAAAP//////////AP////////8AAAAAAAAA/2wAAAAAAAAAfP8AAAAAAAAA//////////8A/////////wAAAAAAAAD/+CwAAAAAAAAExAAAAAAAAAD//////////wD/////////AAAAAAAAAP//0AQAAAAAAAAgAAAAAAAAAP//////////AP////////8AAAAAAAAA////jAAAAAAAAAAAAAAAAAAA//////////8A/////////wAAAAAAAAD/////RAAAAAAAAAAAAAAAAAD//////////wD/////////AAAAAAAAAP/////kFAAAAAAAAAAAAAAAAP//////////AP////////8AAAAAAAAA//////+sAAAAAAAAAAAAAAAA//////////8A/////////wAAAAAAAAD///////9kAAAAAAAAAAAAAAD//////////wD/////////AAAAAAAAAP////////QkAAAAAAAAAAAAAP//////////AP////////8AAAAAAAAA/////////8wEAAAAAAAAAAAA//////////8A/////////wAAAAAAAAD//////////4QAAAAAAAAAAAD//////////wD/////////AAAAAAAAAP///////////DwAAAAAAAAAAP//////////AP////////8AAAAAAAAA////////////4BAAAAAAAAAA//////////8A/////////wAAAAAAAAD/////////////qAAAAAAAAAD//////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'O' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A///////////////////0qGw4HAAAABw4aKT0/////////////////wD////////////////wcAwAAAAAAAAAAAAAAAho6P//////////////AP//////////////uBQAAAAAAAAAAAAAAAAAAAAMoP////////////8A/////////////6AEAAAAAAAAAAAAAAAAAAAAAAAAkP///////////wD///////////+4BAAAAAAAAAAAAAAAAAAAAAAAAAAAoP//////////AP//////////8BQAAAAAAAAAAAAAAAAAAAAAAAAAAAAM5P////////8A//////////9wAAAAAAAAAAAsrPD/7KQsAAAAAAAAAABg/////////wD/////////+BAAAAAAAAAAUPj///////hQAAAAAAAAAAjs////////AP////////+sAAAAAAAAABDw//////////AYAAAAAAAAAKD///////8A/////////2wAAAAAAAAAdP///////////3wAAAAAAAAAYP///////wD/////////OAAAAAAAAAC4////////////xAAAAAAAAAAw////////AP////////8cAAAAAAAAAOD////////////oAAAAAAAAABT///////8A/////////wAAAAAAAAAA//////////////8AAAAAAAAAAP///////wD/////////AAAAAAAAAAD//////////////wAAAAAAAAAA////////AP////////8AAAAAAAAAAP/////////////8AAAAAAAAAAD///////8A/////////xwAAAAAAAAA5P///////////+AAAAAAAAAAHP///////wD/////////NAAAAAAAAAC8////////////uAAAAAAAAAA4////////AP////////9oAAAAAAAAAHj///////////98AAAAAAAAAGT///////8A/////////6gAAAAAAAAAGPD/////////+BgAAAAAAAAApP///////wD/////////9AwAAAAAAAAAUPz///////xcAAAAAAAAAAjs////////AP//////////cAAAAAAAAAAALKjs//CwOAAAAAAAAAAAYP////////8A///////////wFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAzk/////////wD///////////+4BAAAAAAAAAAAAAAAAAAAAAAAAAAAoP//////////AP////////////+QAAAAAAAAAAAAAAAAAAAAAAAAAJD///////////8A//////////////+sEAAAAAAAAAAAAAAAAAAAAAyg/////////////wD////////////////oZAgAAAAAAAAAAAAAAARg4P//////////////AP//////////////////9KhsOCAAAAAUMFyc7P////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'P' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP///////////wAAAAAAAAAAAAAAAAAACCxguP////////////////8A////////////AAAAAAAAAAAAAAAAAAAAAAAAOOD//////////////wD///////////8AAAAAAAAAAAAAAAAAAAAAAAAAGOD/////////////AP///////////wAAAAAAAAAAAAAAAAAAAAAAAAAARP////////////8A////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAxP///////////wD///////////8AAAAAAAAAAAAAAAAAAAAAAAAAAABo////////////AP///////////wAAAAAAAAAA////6JwMAAAAAAAAADD///////////8A////////////AAAAAAAAAAD//////6AAAAAAAAAADP///////////wD///////////8AAAAAAAAAAP//////9AAAAAAAAAAA////////////AP///////////wAAAAAAAAAA///////0AAAAAAAAAAD///////////8A////////////AAAAAAAAAAD//////5gAAAAAAAAAHP///////////wD///////////8AAAAAAAAAAP///9iICAAAAAAAAABI////////////AP///////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAJD///////////8A////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAI6P///////////wD///////////8AAAAAAAAAAAAAAAAAAAAAAAAAAIT/////////////AP///////////wAAAAAAAAAAAAAAAAAAAAAAAABU/P////////////8A////////////AAAAAAAAAAAAAAAAAAAAAAAIhPz//////////////wD///////////8AAAAAAAAAAAAAAAAABCRMkOz/////////////////AP///////////wAAAAAAAAAA//////////////////////////////8A////////////AAAAAAAAAAD//////////////////////////////wD///////////8AAAAAAAAAAP//////////////////////////////AP///////////wAAAAAAAAAA//////////////////////////////8A////////////AAAAAAAAAAD//////////////////////////////wD///////////8AAAAAAAAAAP//////////////////////////////AP///////////wAAAAAAAAAA//////////////////////////////8A////////////AAAAAAAAAAD//////////////////////////////wD///////////8AAAAAAAAAAP//////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'Q' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////SoaDQcAAAAHDhoqPT///////////////////8A//////////////BwDAAAAAAAAAAAAAAACHDo/////////////////wD///////////+4FAAAAAAAAAAAAAAAAAAAABCo////////////////AP//////////nAQAAAAAAAAAAAAAAAAAAAAAAACQ//////////////8A/////////7gEAAAAAAAAAAAAAAAAAAAAAAAAAACg/////////////wD////////wFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAzo////////////AP///////3AAAAAAAAAAACyo8P/sqCwAAAAAAAAAAGT///////////8A///////4EAAAAAAAAABM+P///////FQAAAAAAAAACPT//////////wD//////7AAAAAAAAAAFPD/////////9BgAAAAAAAAApP//////////AP//////bAAAAAAAAAB4////////////fAAAAAAAAABk//////////8A//////84AAAAAAAAALz///////////+8AAAAAAAAADT//////////wD//////xwAAAAAAAAA6P///////////+QAAAAAAAAAHP//////////AP//////AAAAAAAAAAD//////////////wAAAAAAAAAA//////////8A//////8AAAAAAAAAAP//////////////AAAAAAAAAAD//////////wD//////wAAAAAAAAAA/P////////////8AAAAAAAAAAP//////////AP//////GAAAAAAAAADg////////////4AAAAAAAAAAc//////////8A//////84AAAAAAAAALT////MJHTo//+8AAAAAAAAADT//////////wD//////2wAAAAAAAAAdP///2AAABCg/3wAAAAAAAAAZP//////////AP//////rAAAAAAAAAAY9P/sCAAAAABMGAAAAAAAAACk//////////8A///////4EAAAAAAAAABU/P+0OAAAAAAAAAAAAAAACPT//////////wD///////94AAAAAAAAAAA4sPD/gAAAAAAAAAAAAABk////////////AP////////AcAAAAAAAAAAAAAAAAAAAAAAAAAAAADOT///////////8A/////////7wEAAAAAAAAAAAAAAAAAAAAAAAAAACQ/////////////wD//////////6wEAAAAAAAAAAAAAAAAAAAAAAAAABSs////////////AP///////////7gUAAAAAAAAAAAAAAAAAAAAAAAAAABAwP////////8A//////////////BwDAAAAAAAAAAAAAAABAgAAAAAAAA8/////////wD////////////////0qGg0GAAAABgwXJjkxBgAAAAAALD/////////AP//////////////////////////////////5DQAAAAk/P////////8A////////////////////////////////////+GwAAJD//////////wD//////////////////////////////////////8A49P//////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'R' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////wAAAAAAAAAAAAAAAAAAAAQgOGSk+P///////////////wD/////////AAAAAAAAAAAAAAAAAAAAAAAAAAAcuP//////////////AP////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAEsP////////////8A/////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQ6P///////////wD/////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB8////////////AP////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAADD///////////8A/////////wAAAAAAAAAA///////svDgAAAAAAAAACP///////////wD/////////AAAAAAAAAAD/////////7AAAAAAAAAAA////////////AP////////8AAAAAAAAAAP/////////cAAAAAAAAABD///////////8A/////////wAAAAAAAAAA//////DQoCQAAAAAAAAAQP///////////wD/////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAACU////////////AP////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAIPj///////////8A/////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAzU/////////////wD/////////AAAAAAAAAAAAAAAAAAAAAAAAAAA02P//////////////AP////////8AAAAAAAAAAAAAAAAAAAAAAAxctPz///////////////8A/////////wAAAAAAAAAAAAAAAAAAAAAAAEDY/////////////////wD/////////AAAAAAAAAAD/9LAsAAAAAAAAAAzc////////////////AP////////8AAAAAAAAAAP///+wkAAAAAAAAADD8//////////////8A/////////wAAAAAAAAAA/////8QAAAAAAAAAAJD//////////////wD/////////AAAAAAAAAAD//////1QAAAAAAAAAFPD/////////////AP////////8AAAAAAAAAAP//////3AQAAAAAAAAAgP////////////8A/////////wAAAAAAAAAA////////aAAAAAAAAAAM6P///////////wD/////////AAAAAAAAAAD////////oCAAAAAAAAABs////////////AP////////8AAAAAAAAAAP////////+AAAAAAAAAAATc//////////8A/////////wAAAAAAAAAA//////////AUAAAAAAAAAFj//////////wD/////////AAAAAAAAAAD//////////5AAAAAAAAAAAND/////////AP////////8AAAAAAAAAAP//////////+CQAAAAAAAAAQP////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'S' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP/////////////////8vHBEIAgAAAQgQHC8/P////////////////8A////////////////pCQAAAAAAAAAAAAAAAAcoP///////////////wD//////////////FwAAAAAAAAAAAAAAAAAAAAAXP//////////////AP////////////9oAAAAAAAAAAAAAAAAAAAAAAAAhP////////////8A////////////zAAAAAAAAAAAAAAAAAAAAAAAAAAI6P///////////wD///////////9cAAAAAAAAAAAAAAAAAAAAAAAAAACA////////////AP///////////xgAAAAAAAAAUOD/8KwkAAAAAAAAADj///////////8A////////////AAAAAAAAAAD0/////8wABCAgICxASP///////////wD///////////8MAAAAAAAAAMz/////////////////////////////AP///////////0AAAAAAAAAACFiQxPT///////////////////////8A////////////oAAAAAAAAAAAAAAAADBwtPT//////////////////wD////////////8QAAAAAAAAAAAAAAAAAAACFTA////////////////AP/////////////oOAAAAAAAAAAAAAAAAAAAAABM6P////////////8A///////////////4fAgAAAAAAAAAAAAAAAAAAAAY2P///////////wD/////////////////7IwwAAAAAAAAAAAAAAAAAAAo+P//////////AP/////////////////////koGw0BAAAAAAAAAAAAACU//////////8A///////////////////////////4uFgAAAAAAAAAADz//////////wD//////////2BgSEA0IBwA6P///////5QAAAAAAAAADP//////////AP//////////JAAAAAAAAACc/////////AAAAAAAAAAA//////////8A//////////9YAAAAAAAAACDo///////AAAAAAAAAABT//////////wD//////////6QAAAAAAAAAACCk7P/snBQAAAAAAAAAUP//////////AP//////////+BAAAAAAAAAAAAAAAAAAAAAAAAAAAACs//////////8A////////////kAAAAAAAAAAAAAAAAAAAAAAAAAAAOP///////////wD////////////8RAAAAAAAAAAAAAAAAAAAAAAAABjc////////////AP/////////////0PAAAAAAAAAAAAAAAAAAAAAAg2P////////////8A///////////////8hBQAAAAAAAAAAAAAAAAMdPT//////////////wD/////////////////+LRwSCAMAAAAHDhoqPT/////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'T' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////AP////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///////////8A/////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///////////wD/////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////AP////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///////////8A/////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///////////wD///////////////////8AAAAAAAAAAP//////////////////////AP///////////////////wAAAAAAAAAA//////////////////////8A////////////////////AAAAAAAAAAD//////////////////////wD///////////////////8AAAAAAAAAAP//////////////////////AP///////////////////wAAAAAAAAAA//////////////////////8A////////////////////AAAAAAAAAAD//////////////////////wD///////////////////8AAAAAAAAAAP//////////////////////AP///////////////////wAAAAAAAAAA//////////////////////8A////////////////////AAAAAAAAAAD//////////////////////wD///////////////////8AAAAAAAAAAP//////////////////////AP///////////////////wAAAAAAAAAA//////////////////////8A////////////////////AAAAAAAAAAD//////////////////////wD///////////////////8AAAAAAAAAAP//////////////////////AP///////////////////wAAAAAAAAAA//////////////////////8A////////////////////AAAAAAAAAAD//////////////////////wD///////////////////8AAAAAAAAAAP//////////////////////AP///////////////////wAAAAAAAAAA//////////////////////8A////////////////////AAAAAAAAAAD//////////////////////wD///////////////////8AAAAAAAAAAP//////////////////////AP///////////////////wAAAAAAAAAA//////////////////////8A////////////////////AAAAAAAAAAD//////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'U' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////8AAAAAAAAAAP///////////wAAAAAAAAAA//////////8A/////////wAAAAAAAAAA////////////AAAAAAAAAAD//////////wD/////////AAAAAAAAAAD///////////8AAAAAAAAAAP//////////AP////////8AAAAAAAAAAP///////////wAAAAAAAAAA//////////8A/////////wAAAAAAAAAA////////////AAAAAAAAAAD//////////wD/////////AAAAAAAAAAD///////////8AAAAAAAAAAP//////////AP////////8AAAAAAAAAAP///////////wAAAAAAAAAA//////////8A/////////wAAAAAAAAAA////////////AAAAAAAAAAD//////////wD/////////AAAAAAAAAAD///////////8AAAAAAAAAAP//////////AP////////8AAAAAAAAAAP///////////wAAAAAAAAAA//////////8A/////////wAAAAAAAAAA////////////AAAAAAAAAAD//////////wD/////////AAAAAAAAAAD///////////8AAAAAAAAAAP//////////AP////////8AAAAAAAAAAP///////////wAAAAAAAAAA//////////8A/////////wAAAAAAAAAA////////////AAAAAAAAAAD//////////wD/////////AAAAAAAAAAD///////////8AAAAAAAAAAP//////////AP////////8AAAAAAAAAAP///////////wAAAAAAAAAA//////////8A/////////wAAAAAAAAAA////////////AAAAAAAAAAD//////////wD/////////JAAAAAAAAADk/////////+gAAAAAAAAAHP//////////AP////////9MAAAAAAAAAJz/////////nAAAAAAAAABE//////////8A/////////4gAAAAAAAAAHOj//////+ggAAAAAAAAAHz//////////wD/////////0AAAAAAAAAAAIJzs/+ykIAAAAAAAAAAA0P//////////AP//////////QAAAAAAAAAAAAAAAAAAAAAAAAAAAAED///////////8A///////////IBAAAAAAAAAAAAAAAAAAAAAAAAAAE0P///////////wD///////////+YAAAAAAAAAAAAAAAAAAAAAAAAAJj/////////////AP////////////+UBAAAAAAAAAAAAAAAAAAAAASU//////////////8A///////////////IPAAAAAAAAAAAAAAAAAAwyP///////////////wD/////////////////0IxYOCAIAAAEIEiAyP//////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'V' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD//////zAAAAAAAAAAYP//////////////ZAAAAAAAAAAw////////AP//////kAAAAAAAAAAU/P////////////8UAAAAAAAAAJD///////8A///////oBAAAAAAAAADE////////////xAAAAAAAAAAE7P///////wD///////9MAAAAAAAAAHD///////////94AAAAAAAAAEz/////////AP///////6gAAAAAAAAAJP///////////yQAAAAAAAAArP////////8A////////+BAAAAAAAAAA1P/////////YAAAAAAAAABT4/////////wD/////////aAAAAAAAAACE/////////4QAAAAAAAAAbP//////////AP/////////EAAAAAAAAADT/////////OAAAAAAAAADM//////////8A//////////8kAAAAAAAAAOT//////+QAAAAAAAAAKP///////////wD//////////4QAAAAAAAAAmP//////nAAAAAAAAACI////////////AP//////////5AAAAAAAAABE//////9EAAAAAAAABOT///////////8A////////////QAAAAAAAAAT0////9AgAAAAAAABI/////////////wD///////////+gAAAAAAAAAKT///+kAAAAAAAAAKj/////////////AP////////////QIAAAAAAAAXP///1wAAAAAAAAM+P////////////8A/////////////1wAAAAAAAAM+P/8DAAAAAAAAGT//////////////wD/////////////vAAAAAAAAAC8/7wAAAAAAAAAxP//////////////AP//////////////HAAAAAAAAGj/aAAAAAAAACT///////////////8A//////////////94AAAAAAAAHP8cAAAAAAAAhP///////////////wD//////////////9gAAAAAAAAAkAAAAAAAAADk////////////////AP///////////////zgAAAAAAAAQAAAAAAAAQP////////////////8A////////////////lAAAAAAAAAAAAAAAAACg/////////////////wD////////////////sCAAAAAAAAAAAAAAADPT/////////////////AP////////////////9QAAAAAAAAAAAAAABg//////////////////8A/////////////////7AAAAAAAAAAAAAAAMD//////////////////wD//////////////////BQAAAAAAAAAAAAc////////////////////AP//////////////////cAAAAAAAAAAAAHz///////////////////8A///////////////////MAAAAAAAAAAAA3P///////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'W' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A//8cAAAAAAAAALz/////4AAAAAAAAAAA6P////+8AAAAAAAAABz//wD//1QAAAAAAAAAjP////+gAAAAAAAAAACo/////4wAAAAAAAAAUP//AP//jAAAAAAAAABU/////2AAAAAAAAAAAGj/////VAAAAAAAAACM//8A///EAAAAAAAAACT/////IAAAAAAAAAAAKP////8kAAAAAAAAAMT//wD///gEAAAAAAAAAPD//+AAAAAAAAAAAAAA6P//8AAAAAAAAAAE9P//AP///zAAAAAAAAAAvP//oAAAAAAAAAAAAACo//+8AAAAAAAAADD///8A////bAAAAAAAAACM//9gAAAAAAAAAAAAAGT//4wAAAAAAAAAaP///wD///+kAAAAAAAAAFT//yAAAAAAAAAAAAAAIP//VAAAAAAAAACc////AP///9gAAAAAAAAAJP/gAAAAAAAAAAAAAAAA4P8kAAAAAAAAANT///8A/////xAAAAAAAAAA8KAAAAAAAAAAAAAAAACg8AAAAAAAAAAQ/////wD/////TAAAAAAAAAC8YAAAAAAAAAAAAAAAAGC8AAAAAAAAAET/////AP////+AAAAAAAAAAIwgAAAAAAAAAAAAAAAAIIwAAAAAAAAAfP////8A/////7gAAAAAAAAANAAAAAAAACwwAAAAAAAANAAAAAAAAACw/////wD/////8AAAAAAAAAAAAAAAAAAAdHgAAAAAAAAAAAAAAAAAAOz/////AP//////KAAAAAAAAAAAAAAAAAC4vAAAAAAAAAAAAAAAAAAg//////8A//////9gAAAAAAAAAAAAAAAACPj4CAAAAAAAAAAAAAAAAFj//////wD//////5QAAAAAAAAAAAAAAABE//9IAAAAAAAAAAAAAAAAkP//////AP//////0AAAAAAAAAAAAAAAAIj//4wAAAAAAAAAAAAAAADI//////8A///////8DAAAAAAAAAAAAAAAzP//1AAAAAAAAAAAAAAABPj//////wD///////88AAAAAAAAAAAAABT/////GAAAAAAAAAAAAAA0////////AP///////3QAAAAAAAAAAAAAWP////9gAAAAAAAAAAAAAHD///////8A////////sAAAAAAAAAAAAACg/////6QAAAAAAAAAAAAApP///////wD////////kAAAAAAAAAAAAAOT/////6AAAAAAAAAAAAADc////////AP////////8cAAAAAAAAAAAo////////MAAAAAAAAAAAEP////////8A/////////1QAAAAAAAAAAHD///////94AAAAAAAAAABM/////////wD/////////jAAAAAAAAAAAtP///////7wAAAAAAAAAAID/////////AP/////////EAAAAAAAAAAT0////////+AgAAAAAAAAAuP////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'X' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD///////9UAAAAAAAAAKz///////////+sAAAAAAAAAFD/////////AP///////+QQAAAAAAAAFOT/////////8BwAAAAAAAAM5P////////8A/////////5gAAAAAAAAATP////////9kAAAAAAAAAJD//////////wD//////////0AAAAAAAAAAoP//////wAAAAAAAAAA0/P//////////AP//////////2AgAAAAAAAAQ4P////gkAAAAAAAABMz///////////8A////////////iAAAAAAAAABA////dAAAAAAAAABw/////////////wD////////////8MAAAAAAAAACU/9AEAAAAAAAAHPD/////////////AP/////////////IBAAAAAAAAAzYMAAAAAAAAACs//////////////8A//////////////90AAAAAAAAABAAAAAAAAAATP///////////////wD///////////////QgAAAAAAAAAAAAAAAAAAzg////////////////AP///////////////7wAAAAAAAAAAAAAAAAAjP////////////////8A/////////////////2AAAAAAAAAAAAAAADD8/////////////////wD/////////////////7BQAAAAAAAAAAAAEyP//////////////////AP/////////////////gDAAAAAAAAAAAAAjY//////////////////8A/////////////////0AAAAAAAAAAAAAAADj8/////////////////wD///////////////+UAAAAAAAAAAAAAAAAAJD/////////////////AP//////////////4AwAAAAAAAAAAAAAAAAADOD///////////////8A//////////////9AAAAAAAAAAAAAAAAAAAAAQP///////////////wD/////////////nAAAAAAAAAAAWAAAAAAAAAAAlP//////////////AP///////////+QQAAAAAAAAAGD/YAAAAAAAAAAM4P////////////8A////////////TAAAAAAAAAAs9P/0LAAAAAAAAABM/////////////wD//////////6AAAAAAAAAADNT////UDAAAAAAAAACg////////////AP/////////kEAAAAAAAAACg//////+gAAAAAAAAABDk//////////8A/////////0wAAAAAAAAAYP////////9gAAAAAAAAAEz//////////wD///////+oAAAAAAAAACz0//////////QsAAAAAAAAAKT/////////AP//////7BQAAAAAAAAM1P///////////9QMAAAAAAAAFOz///////8A//////9UAAAAAAAAAKD//////////////6AAAAAAAAAAVP///////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'Y' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP///////1QAAAAAAAAAAGj//////////2gAAAAAAAAAAFT///////8A////////5BAAAAAAAAAAAMT////////EAAAAAAAAAAAQ5P///////wD/////////mAAAAAAAAAAAKPj/////+CgAAAAAAAAAAJj/////////AP//////////PAAAAAAAAAAAgP////+AAAAAAAAAAAA8//////////8A///////////YCAAAAAAAAAAE2P//2AQAAAAAAAAACNj//////////wD///////////+AAAAAAAAAAAA4//84AAAAAAAAAACA////////////AP////////////woAAAAAAAAAACUlAAAAAAAAAAAKPz///////////8A/////////////8gAAAAAAAAAABAQAAAAAAAAAADI/////////////wD//////////////2wAAAAAAAAAAAAAAAAAAAAAbP//////////////AP//////////////8BwAAAAAAAAAAAAAAAAAABzw//////////////8A////////////////tAAAAAAAAAAAAAAAAAAAtP///////////////wD/////////////////VAAAAAAAAAAAAAAAAFT/////////////////AP/////////////////oEAAAAAAAAAAAAAAQ6P////////////////8A//////////////////+cAAAAAAAAAAAAAJz//////////////////wD///////////////////9AAAAAAAAAAABA////////////////////AP///////////////////9gAAAAAAAAAANj///////////////////8A/////////////////////wAAAAAAAAAA/////////////////////wD/////////////////////AAAAAAAAAAD/////////////////////AP////////////////////8AAAAAAAAAAP////////////////////8A/////////////////////wAAAAAAAAAA/////////////////////wD/////////////////////AAAAAAAAAAD/////////////////////AP////////////////////8AAAAAAAAAAP////////////////////8A/////////////////////wAAAAAAAAAA/////////////////////wD/////////////////////AAAAAAAAAAD/////////////////////AP////////////////////8AAAAAAAAAAP////////////////////8A/////////////////////wAAAAAAAAAA/////////////////////wD/////////////////////AAAAAAAAAAD/////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - 'Z' => array( - 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAD//////////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAP//////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAA//////////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAD//////////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAP//////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAQ//////////////8A/////////////////////////1AAAAAAAAAABLz//////////////wD///////////////////////98AAAAAAAAAACY////////////////AP//////////////////////pAAAAAAAAAAAaP////////////////8A/////////////////////8QIAAAAAAAAAET8/////////////////wD////////////////////gGAAAAAAAAAAo9P//////////////////AP//////////////////9CwAAAAAAAAAFNz///////////////////8A//////////////////xMAAAAAAAAAATA/////////////////////wD/////////////////eAAAAAAAAAAAnP//////////////////////AP///////////////5wAAAAAAAAAAHT///////////////////////8A///////////////ABAAAAAAAAABM/P///////////////////////wD/////////////3BQAAAAAAAAALPT/////////////////////////AP////////////QoAAAAAAAAABjg//////////////////////////8A///////////8SAAAAAAAAAAExP///////////////////////////wD//////////2wAAAAAAAAAAKD/////////////////////////////AP////////+YAAAAAAAAAAB8//////////////////////////////8A/////////wQAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////wD/////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////AP////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////8A/////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////wD/////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////AP////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=', - 'width' => 40 - ), - ); - } -} diff --git a/install/update/old/phpbb/captcha/plugins/qa.php b/install/update/old/phpbb/captcha/plugins/qa.php deleted file mode 100644 index 70b3f72..0000000 --- a/install/update/old/phpbb/captcha/plugins/qa.php +++ /dev/null @@ -1,1040 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\captcha\plugins; - -/** -* And now to something completely different. Let's make a captcha without extending the abstract class. -* QA CAPTCHA sample implementation -*/ -class qa -{ - var $confirm_id; - var $answer; - var $question_ids; - var $question_text; - var $question_lang; - var $question_strict; - var $attempts = 0; - var $type; - // dirty trick: 0 is false, but can still encode that the captcha is not yet validated - var $solved = 0; - - protected $table_captcha_questions; - protected $table_captcha_answers; - protected $table_qa_confirm; - - /** - * @var string name of the service. - */ - protected $service_name; - - /** - * Constructor - * - * @param string $table_captcha_questions - * @param string $table_captcha_answers - * @param string $table_qa_confirm - */ - function __construct($table_captcha_questions, $table_captcha_answers, $table_qa_confirm) - { - $this->table_captcha_questions = $table_captcha_questions; - $this->table_captcha_answers = $table_captcha_answers; - $this->table_qa_confirm = $table_qa_confirm; - } - - /** - * @param int $type as per the CAPTCHA API docs, the type - */ - function init($type) - { - global $config, $db, $user, $request; - - // load our language file - $user->add_lang('captcha_qa'); - - // read input - $this->confirm_id = $request->variable('qa_confirm_id', ''); - $this->answer = $request->variable('qa_answer', '', true); - - $this->type = (int) $type; - $this->question_lang = $user->lang_name; - - // we need all defined questions - shouldn't be too many, so we can just grab them - // try the user's lang first - $sql = 'SELECT question_id - FROM ' . $this->table_captcha_questions . " - WHERE lang_iso = '" . $db->sql_escape($user->lang_name) . "'"; - $result = $db->sql_query($sql, 3600); - - while ($row = $db->sql_fetchrow($result)) - { - $this->question_ids[$row['question_id']] = $row['question_id']; - } - $db->sql_freeresult($result); - - // fallback to the board default lang - if (!count($this->question_ids)) - { - $this->question_lang = $config['default_lang']; - - $sql = 'SELECT question_id - FROM ' . $this->table_captcha_questions . " - WHERE lang_iso = '" . $db->sql_escape($config['default_lang']) . "'"; - $result = $db->sql_query($sql, 7200); - - while ($row = $db->sql_fetchrow($result)) - { - $this->question_ids[$row['question_id']] = $row['question_id']; - } - $db->sql_freeresult($result); - } - - // final fallback to any language - if (!count($this->question_ids)) - { - $this->question_lang = ''; - - $sql = 'SELECT q.question_id, q.lang_iso - FROM ' . $this->table_captcha_questions . ' q, ' . $this->table_captcha_answers . ' a - WHERE q.question_id = a.question_id'; - $result = $db->sql_query($sql, 7200); - - while ($row = $db->sql_fetchrow($result)) - { - if (empty($this->question_lang)) - { - $this->question_lang = $row['lang_iso']; - } - $this->question_ids[$row['question_id']] = $row['question_id']; - } - $db->sql_freeresult($result); - } - - // okay, if there is a confirm_id, we try to load that confirm's state. If not, we try to find one - if (!$this->load_answer() && (!$this->load_confirm_id() || !$this->load_answer())) - { - // we have no valid confirm ID, better get ready to ask something - $this->select_question(); - } - } - - /** - * See if the captcha has created its tables. - */ - public function is_installed() - { - global $phpbb_container; - - $db_tool = $phpbb_container->get('dbal.tools'); - - return $db_tool->sql_table_exists($this->table_captcha_questions); - } - - /** - * API function - for the captcha to be available, it must have installed itself and there has to be at least one question in the board's default lang - */ - public function is_available() - { - global $config, $db, $user; - - // load language file for pretty display in the ACP dropdown - $user->add_lang('captcha_qa'); - - if (!$this->is_installed()) - { - return false; - } - - $sql = 'SELECT COUNT(question_id) AS question_count - FROM ' . $this->table_captcha_questions . " - WHERE lang_iso = '" . $db->sql_escape($config['default_lang']) . "'"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - return ((bool) $row['question_count']); - } - - /** - * API function - */ - function has_config() - { - return true; - } - - /** - * API function - */ - static public function get_name() - { - return 'CAPTCHA_QA'; - } - - /** - * @return string the name of the service corresponding to the plugin - */ - function get_service_name() - { - return $this->service_name; - } - - /** - * Set the name of the plugin - * - * @param string $name - */ - public function set_name($name) - { - $this->service_name = $name; - } - - /** - * API function - not needed as we don't display an image - */ - function execute_demo() - { - } - - /** - * API function - not needed as we don't display an image - */ - function execute() - { - } - - /** - * API function - send the question to the template - */ - function get_template() - { - global $phpbb_log, $template, $user; - - if ($this->is_solved()) - { - return false; - } - else if (empty($this->question_text) || !count($this->question_ids)) - { - /** @var \phpbb\log\log_interface $phpbb_log */ - $phpbb_log->add('critical', $user->data['user_id'], $user->ip, 'LOG_ERROR_CAPTCHA', time(), array($user->lang('CONFIRM_QUESTION_MISSING'))); - return false; - } - else - { - $template->assign_vars(array( - 'QA_CONFIRM_QUESTION' => $this->question_text, - 'QA_CONFIRM_ID' => $this->confirm_id, - 'S_CONFIRM_CODE' => true, - 'S_TYPE' => $this->type, - )); - - return 'captcha_qa.html'; - } - } - - /** - * API function - we just display a mockup so that the captcha doesn't need to be installed - */ - function get_demo_template() - { - global $config, $db, $template; - - if ($this->is_available()) - { - $sql = 'SELECT question_text - FROM ' . $this->table_captcha_questions . " - WHERE lang_iso = '" . $db->sql_escape($config['default_lang']) . "'"; - $result = $db->sql_query_limit($sql, 1); - if ($row = $db->sql_fetchrow($result)) - { - $template->assign_vars(array( - 'QA_CONFIRM_QUESTION' => $row['question_text'], - )); - } - $db->sql_freeresult($result); - } - return 'captcha_qa_acp_demo.html'; - } - - /** - * API function - */ - function get_hidden_fields() - { - $hidden_fields = array(); - - // this is required - otherwise we would forget about the captcha being already solved - if ($this->solved) - { - $hidden_fields['qa_answer'] = $this->answer; - } - $hidden_fields['qa_confirm_id'] = $this->confirm_id; - - return $hidden_fields; - } - - /** - * API function - */ - function garbage_collect($type = 0) - { - global $db; - - $sql = 'SELECT c.confirm_id - FROM ' . $this->table_qa_confirm . ' c - LEFT JOIN ' . SESSIONS_TABLE . ' s - ON (c.session_id = s.session_id) - WHERE s.session_id IS NULL' . - ((empty($type)) ? '' : ' AND c.confirm_type = ' . (int) $type); - $result = $db->sql_query($sql); - - if ($row = $db->sql_fetchrow($result)) - { - $sql_in = array(); - - do - { - $sql_in[] = (string) $row['confirm_id']; - } - while ($row = $db->sql_fetchrow($result)); - - if (count($sql_in)) - { - $sql = 'DELETE FROM ' . $this->table_qa_confirm . ' - WHERE ' . $db->sql_in_set('confirm_id', $sql_in); - $db->sql_query($sql); - } - } - $db->sql_freeresult($result); - } - - /** - * API function - we don't drop the tables here, as that would cause the loss of all entered questions. - */ - function uninstall() - { - $this->garbage_collect(0); - } - - /** - * API function - set up shop - */ - function install() - { - global $phpbb_container; - - $db_tool = $phpbb_container->get('dbal.tools'); - $schemas = array( - $this->table_captcha_questions => array ( - 'COLUMNS' => array( - 'question_id' => array('UINT', null, 'auto_increment'), - 'strict' => array('BOOL', 0), - 'lang_id' => array('UINT', 0), - 'lang_iso' => array('VCHAR:30', ''), - 'question_text' => array('TEXT_UNI', ''), - ), - 'PRIMARY_KEY' => 'question_id', - 'KEYS' => array( - 'lang' => array('INDEX', 'lang_iso'), - ), - ), - $this->table_captcha_answers => array ( - 'COLUMNS' => array( - 'question_id' => array('UINT', 0), - 'answer_text' => array('STEXT_UNI', ''), - ), - 'KEYS' => array( - 'qid' => array('INDEX', 'question_id'), - ), - ), - $this->table_qa_confirm => array ( - 'COLUMNS' => array( - 'session_id' => array('CHAR:32', ''), - 'confirm_id' => array('CHAR:32', ''), - 'lang_iso' => array('VCHAR:30', ''), - 'question_id' => array('UINT', 0), - 'attempts' => array('UINT', 0), - 'confirm_type' => array('USINT', 0), - ), - 'KEYS' => array( - 'session_id' => array('INDEX', 'session_id'), - 'lookup' => array('INDEX', array('confirm_id', 'session_id', 'lang_iso')), - ), - 'PRIMARY_KEY' => 'confirm_id', - ), - ); - - foreach ($schemas as $table => $schema) - { - if (!$db_tool->sql_table_exists($table)) - { - $db_tool->sql_create_table($table, $schema); - } - } - } - - /** - * API function - see what has to be done to validate - */ - function validate() - { - global $phpbb_log, $user; - - $error = ''; - - if (!count($this->question_ids)) - { - /** @var \phpbb\log\log_interface $phpbb_log */ - $phpbb_log->add('critical', $user->data['user_id'], $user->ip, 'LOG_ERROR_CAPTCHA', time(), array($user->lang('CONFIRM_QUESTION_MISSING'))); - return $user->lang('CONFIRM_QUESTION_MISSING'); - } - - if (!$this->confirm_id) - { - $error = $user->lang['CONFIRM_QUESTION_WRONG']; - } - else - { - if ($this->check_answer()) - { - $this->solved = true; - } - else - { - $error = $user->lang['CONFIRM_QUESTION_WRONG']; - } - } - - if (strlen($error)) - { - // okay, incorrect answer. Let's ask a new question. - $this->new_attempt(); - $this->solved = false; - - return $error; - } - else - { - return false; - } - } - - /** - * Select a question - */ - function select_question() - { - global $db, $user; - - if (!count($this->question_ids)) - { - return; - } - $this->confirm_id = md5(unique_id($user->ip)); - $this->question = (int) array_rand($this->question_ids); - - $sql = 'INSERT INTO ' . $this->table_qa_confirm . ' ' . $db->sql_build_array('INSERT', array( - 'confirm_id' => (string) $this->confirm_id, - 'session_id' => (string) $user->session_id, - 'lang_iso' => (string) $this->question_lang, - 'confirm_type' => (int) $this->type, - 'question_id' => (int) $this->question, - )); - $db->sql_query($sql); - - $this->load_answer(); - } - - /** - * New Question, if desired. - */ - function reselect_question() - { - global $db, $user; - - if (!count($this->question_ids)) - { - return; - } - - $this->question = (int) array_rand($this->question_ids); - $this->solved = 0; - - $sql = 'UPDATE ' . $this->table_qa_confirm . ' - SET question_id = ' . (int) $this->question . " - WHERE confirm_id = '" . $db->sql_escape($this->confirm_id) . "' - AND session_id = '" . $db->sql_escape($user->session_id) . "'"; - $db->sql_query($sql); - - $this->load_answer(); - } - - /** - * Wrong answer, so we increase the attempts and use a different question. - */ - function new_attempt() - { - global $db, $user; - - // yah, I would prefer a stronger rand, but this should work - $this->question = (int) array_rand($this->question_ids); - $this->solved = 0; - - $sql = 'UPDATE ' . $this->table_qa_confirm . ' - SET question_id = ' . (int) $this->question . ", - attempts = attempts + 1 - WHERE confirm_id = '" . $db->sql_escape($this->confirm_id) . "' - AND session_id = '" . $db->sql_escape($user->session_id) . "'"; - $db->sql_query($sql); - - $this->load_answer(); - } - - - /** - * See if there is already an entry for the current session. - */ - function load_confirm_id() - { - global $db, $user; - - $sql = 'SELECT confirm_id - FROM ' . $this->table_qa_confirm . " - WHERE - session_id = '" . $db->sql_escape($user->session_id) . "' - AND lang_iso = '" . $db->sql_escape($this->question_lang) . "' - AND confirm_type = " . $this->type; - $result = $db->sql_query_limit($sql, 1); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - $this->confirm_id = $row['confirm_id']; - return true; - } - return false; - } - - /** - * Look up everything we need and populate the instance variables. - */ - function load_answer() - { - global $db, $user; - - if (!strlen($this->confirm_id) || !count($this->question_ids)) - { - return false; - } - - $sql = 'SELECT con.question_id, attempts, question_text, strict - FROM ' . $this->table_qa_confirm . ' con, ' . $this->table_captcha_questions . " qes - WHERE con.question_id = qes.question_id - AND confirm_id = '" . $db->sql_escape($this->confirm_id) . "' - AND session_id = '" . $db->sql_escape($user->session_id) . "' - AND qes.lang_iso = '" . $db->sql_escape($this->question_lang) . "' - AND confirm_type = " . $this->type; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - $this->question = $row['question_id']; - - $this->attempts = $row['attempts']; - $this->question_strict = $row['strict']; - $this->question_text = $row['question_text']; - - return true; - } - - return false; - } - - /** - * The actual validation - */ - function check_answer() - { - global $db, $request; - - $answer = ($this->question_strict) ? $request->variable('qa_answer', '', true) : utf8_clean_string($request->variable('qa_answer', '', true)); - - $sql = 'SELECT answer_text - FROM ' . $this->table_captcha_answers . ' - WHERE question_id = ' . (int) $this->question; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $solution = ($this->question_strict) ? $row['answer_text'] : utf8_clean_string($row['answer_text']); - - if ($solution === $answer) - { - $this->solved = true; - - break; - } - } - $db->sql_freeresult($result); - - return $this->solved; - } - - /** - * API function - */ - function get_attempt_count() - { - return $this->attempts; - } - - /** - * API function - */ - function reset() - { - global $db, $user; - - $sql = 'DELETE FROM ' . $this->table_qa_confirm . " - WHERE session_id = '" . $db->sql_escape($user->session_id) . "' - AND confirm_type = " . (int) $this->type; - $db->sql_query($sql); - - // we leave the class usable by generating a new question - $this->select_question(); - } - - /** - * API function - */ - function is_solved() - { - global $request; - - if ($request->variable('qa_answer', false) && $this->solved === 0) - { - $this->validate(); - } - - return (bool) $this->solved; - } - - /** - * API function - The ACP backend, this marks the end of the easy methods - */ - function acp_page($id, $module) - { - global $config, $request, $phpbb_log, $template, $user; - - $user->add_lang('acp/board'); - $user->add_lang('captcha_qa'); - - if (!self::is_installed()) - { - $this->install(); - } - - $module->tpl_name = 'captcha_qa_acp'; - $module->page_title = 'ACP_VC_SETTINGS'; - $form_key = 'acp_captcha'; - add_form_key($form_key); - - $submit = $request->variable('submit', false); - $question_id = $request->variable('question_id', 0); - $action = $request->variable('action', ''); - - // we have two pages, so users might want to navigate from one to the other - $list_url = $module->u_action . "&configure=1&select_captcha=" . $this->get_service_name(); - - $template->assign_vars(array( - 'U_ACTION' => $module->u_action, - 'QUESTION_ID' => $question_id , - 'CLASS' => $this->get_service_name(), - )); - - // show the list? - if (!$question_id && $action != 'add') - { - $this->acp_question_list($module); - } - else if ($question_id && $action == 'delete') - { - if ($this->get_service_name() !== $config['captcha_plugin'] || !$this->acp_is_last($question_id)) - { - if (confirm_box(true)) - { - $this->acp_delete_question($question_id); - - trigger_error($user->lang['QUESTION_DELETED'] . adm_back_link($list_url)); - } - else - { - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( - 'question_id' => $question_id, - 'action' => $action, - 'configure' => 1, - 'select_captcha' => $this->get_service_name(), - )) - ); - } - } - else - { - trigger_error($user->lang['QA_LAST_QUESTION'] . adm_back_link($list_url), E_USER_WARNING); - } - } - else - { - // okay, show the editor - $question_input = $this->acp_get_question_input(); - $langs = $this->get_languages(); - - foreach ($langs as $lang => $entry) - { - $template->assign_block_vars('langs', array( - 'ISO' => $lang, - 'NAME' => $entry['name'], - )); - } - - $template->assign_vars(array( - 'U_LIST' => $list_url, - )); - - if ($question_id) - { - if ($question = $this->acp_get_question_data($question_id)) - { - $template->assign_vars(array( - 'QUESTION_TEXT' => ($question_input['question_text']) ? $question_input['question_text'] : $question['question_text'], - 'LANG_ISO' => ($question_input['lang_iso']) ? $question_input['lang_iso'] : $question['lang_iso'], - 'STRICT' => (isset($_REQUEST['strict'])) ? $question_input['strict'] : $question['strict'], - 'ANSWERS' => implode("\n", $question['answers']), - )); - } - else - { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($list_url)); - } - } - else - { - $template->assign_vars(array( - 'QUESTION_TEXT' => $question_input['question_text'], - 'LANG_ISO' => $question_input['lang_iso'], - 'STRICT' => $question_input['strict'], - 'ANSWERS' => (is_array($question_input['answers'])) ? implode("\n", $question_input['answers']) : '', - )); - } - - if ($submit && check_form_key($form_key)) - { - if (!$this->validate_input($question_input)) - { - $template->assign_vars(array( - 'S_ERROR' => true, - )); - } - else - { - if ($question_id) - { - $this->acp_update_question($question_input, $question_id); - } - else - { - $this->acp_add_question($question_input); - } - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_CONFIG_VISUAL'); - trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($list_url)); - } - } - else if ($submit) - { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($list_url), E_USER_WARNING); - } - } - } - - /** - * This handles the list overview - */ - function acp_question_list($module) - { - global $db, $template; - - $sql = 'SELECT * - FROM ' . $this->table_captcha_questions; - $result = $db->sql_query($sql); - - $template->assign_vars(array( - 'S_LIST' => true, - )); - - while ($row = $db->sql_fetchrow($result)) - { - $url = $module->u_action . "&question_id={$row['question_id']}&configure=1&select_captcha=" . $this->get_service_name() . '&'; - - $template->assign_block_vars('questions', array( - 'QUESTION_TEXT' => $row['question_text'], - 'QUESTION_ID' => $row['question_id'], - 'QUESTION_LANG' => $row['lang_iso'], - 'U_DELETE' => "{$url}action=delete", - 'U_EDIT' => "{$url}action=edit", - )); - } - $db->sql_freeresult($result); - } - - /** - * Grab a question and bring it into a format the editor understands - */ - function acp_get_question_data($question_id) - { - global $db; - - if ($question_id) - { - $sql = 'SELECT * - FROM ' . $this->table_captcha_questions . ' - WHERE question_id = ' . $question_id; - $result = $db->sql_query($sql); - $question = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$question) - { - return false; - } - - $question['answers'] = array(); - - $sql = 'SELECT * - FROM ' . $this->table_captcha_answers . ' - WHERE question_id = ' . $question_id; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $question['answers'][] = $row['answer_text']; - } - $db->sql_freeresult($result); - - return $question; - } - - return false; - } - - /** - * Grab a question from input and bring it into a format the editor understands - */ - function acp_get_question_input() - { - global $request; - - $answers = $request->variable('answers', '', true); - - // Convert answers into array and filter if answers are set - if (strlen($answers)) - { - $answers = array_filter(array_map('trim', explode("\n", $answers)), function ($value) { - return $value !== ''; - }); - } - - $question = array( - 'question_text' => $request->variable('question_text', '', true), - 'strict' => $request->variable('strict', false), - 'lang_iso' => $request->variable('lang_iso', ''), - 'answers' => $answers, - ); - return $question; - } - - /** - * Update a question. - * param mixed $data : an array as created from acp_get_question_input or acp_get_question_data - */ - function acp_update_question($data, $question_id) - { - global $db, $cache; - - // easier to delete all answers than to figure out which to update - $sql = 'DELETE FROM ' . $this->table_captcha_answers . " WHERE question_id = $question_id"; - $db->sql_query($sql); - - $langs = $this->get_languages(); - $question_ary = $data; - $question_ary['lang_id'] = $langs[$question_ary['lang_iso']]['id']; - unset($question_ary['answers']); - - $sql = 'UPDATE ' . $this->table_captcha_questions . ' - SET ' . $db->sql_build_array('UPDATE', $question_ary) . " - WHERE question_id = $question_id"; - $db->sql_query($sql); - - $this->acp_insert_answers($data, $question_id); - - $cache->destroy('sql', $this->table_captcha_questions); - } - - /** - * Insert a question. - * param mixed $data : an array as created from acp_get_question_input or acp_get_question_data - */ - function acp_add_question($data) - { - global $db, $cache; - - $langs = $this->get_languages(); - $question_ary = $data; - - $question_ary['lang_id'] = $langs[$data['lang_iso']]['id']; - unset($question_ary['answers']); - - $sql = 'INSERT INTO ' . $this->table_captcha_questions . ' ' . $db->sql_build_array('INSERT', $question_ary); - $db->sql_query($sql); - - $question_id = $db->sql_nextid(); - - $this->acp_insert_answers($data, $question_id); - - $cache->destroy('sql', $this->table_captcha_questions); - } - - /** - * Insert the answers. - * param mixed $data : an array as created from acp_get_question_input or acp_get_question_data - */ - function acp_insert_answers($data, $question_id) - { - global $db, $cache; - - foreach ($data['answers'] as $answer) - { - $answer_ary = array( - 'question_id' => $question_id, - 'answer_text' => $answer, - ); - - $sql = 'INSERT INTO ' . $this->table_captcha_answers . ' ' . $db->sql_build_array('INSERT', $answer_ary); - $db->sql_query($sql); - } - - $cache->destroy('sql', $this->table_captcha_answers); - } - - /** - * Delete a question. - */ - function acp_delete_question($question_id) - { - global $db, $cache; - - $tables = array($this->table_captcha_questions, $this->table_captcha_answers); - - foreach ($tables as $table) - { - $sql = "DELETE FROM $table - WHERE question_id = $question_id"; - $db->sql_query($sql); - } - - $cache->destroy('sql', $tables); - } - - /** - * Check if the entered data can be inserted/used - * param mixed $data : an array as created from acp_get_question_input or acp_get_question_data - */ - function validate_input($question_data) - { - $langs = $this->get_languages(); - - if (!isset($question_data['lang_iso']) || - !isset($question_data['question_text']) || - !isset($question_data['strict']) || - !isset($question_data['answers'])) - { - return false; - } - - if (!isset($langs[$question_data['lang_iso']]) || - !strlen($question_data['question_text']) || - !count($question_data['answers']) || - !is_array($question_data['answers'])) - { - return false; - } - - return true; - } - - /** - * List the installed language packs - */ - function get_languages() - { - global $db; - - $sql = 'SELECT * - FROM ' . LANG_TABLE; - $result = $db->sql_query($sql); - - $langs = array(); - while ($row = $db->sql_fetchrow($result)) - { - $langs[$row['lang_iso']] = array( - 'name' => $row['lang_local_name'], - 'id' => (int) $row['lang_id'], - ); - } - $db->sql_freeresult($result); - - return $langs; - } - - - - /** - * See if there is a question other than the one we have - */ - function acp_is_last($question_id) - { - global $config, $db; - - if ($question_id) - { - $sql = 'SELECT question_id - FROM ' . $this->table_captcha_questions . " - WHERE lang_iso = '" . $db->sql_escape($config['default_lang']) . "' - AND question_id <> " . (int) $question_id; - $result = $db->sql_query_limit($sql, 1); - $question = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$question) - { - return true; - } - return false; - } - } -} diff --git a/install/update/old/phpbb/class_loader.php b/install/update/old/phpbb/class_loader.php deleted file mode 100644 index cfdcc2a..0000000 --- a/install/update/old/phpbb/class_loader.php +++ /dev/null @@ -1,164 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb; - -/** -* The class loader resolves class names to file system paths and loads them if -* necessary. -* -* Classes have to be of the form phpbb_(dir_)*(classpart_)*, so directory names -* must never contain underscores. Example: phpbb_dir_subdir_class_name is a -* valid class name, while phpbb_dir_sub_dir_class_name is not. -* -* If every part of the class name is a directory, the last directory name is -* also used as the filename, e.g. phpbb_dir would resolve to dir/dir.php. -*/ -class class_loader -{ - private $namespace; - private $path; - private $php_ext; - private $cache; - - /** - * A map of looked up class names to paths relative to $this->path. - * This map is stored in cache and looked up if the cache is available. - * - * @var array - */ - private $cached_paths = array(); - - /** - * Creates a new \phpbb\class_loader, which loads files with the given - * file extension from the given path. - * - * @param string $namespace Required namespace for files to be loaded - * @param string $path Directory to load files from - * @param string $php_ext The file extension for PHP files - * @param \phpbb\cache\driver\driver_interface $cache An implementation of the phpBB cache interface. - */ - public function __construct($namespace, $path, $php_ext = 'php', \phpbb\cache\driver\driver_interface $cache = null) - { - if ($namespace[0] !== '\\') - { - $namespace = '\\' . $namespace; - } - - $this->namespace = $namespace; - $this->path = $path; - $this->php_ext = $php_ext; - - $this->set_cache($cache); - } - - /** - * Provide the class loader with a cache to store paths. If set to null, the - * the class loader will resolve paths by checking for the existance of every - * directory in the class name every time. - * - * @param \phpbb\cache\driver\driver_interface $cache An implementation of the phpBB cache interface. - */ - public function set_cache(\phpbb\cache\driver\driver_interface $cache = null) - { - if ($cache) - { - $this->cached_paths = $cache->get('class_loader_' . str_replace('\\', '__', $this->namespace)); - - if ($this->cached_paths === false) - { - $this->cached_paths = array(); - } - } - - $this->cache = $cache; - } - - /** - * Registers the class loader as an autoloader using SPL. - */ - public function register() - { - spl_autoload_register(array($this, 'load_class')); - } - - /** - * Removes the class loader from the SPL autoloader stack. - */ - public function unregister() - { - spl_autoload_unregister(array($this, 'load_class')); - } - - /** - * Resolves a phpBB class name to a relative path which can be included. - * - * @param string $class The class name to resolve, must be in the - * namespace the loader was constructed with. - * Has to begin with \ - * @return string|bool A relative path to the file containing the - * class or false if looking it up failed. - */ - public function resolve_path($class) - { - if (isset($this->cached_paths[$class])) - { - return $this->path . $this->cached_paths[$class] . '.' . $this->php_ext; - } - - if (!preg_match('/^' . preg_quote($this->namespace, '/') . '[a-zA-Z0-9_\\\\]+$/', $class)) - { - return false; - } - - $relative_path = str_replace('\\', '/', substr($class, strlen($this->namespace))); - - if (!file_exists($this->path . $relative_path . '.' . $this->php_ext)) - { - return false; - } - - if ($this->cache) - { - $this->cached_paths[$class] = $relative_path; - $this->cache->put('class_loader_' . str_replace('\\', '__', $this->namespace), $this->cached_paths); - } - - return $this->path . $relative_path . '.' . $this->php_ext; - } - - /** - * Resolves a class name to a path and then includes it. - * - * @param string $class The class name which is being loaded. - */ - public function load_class($class) - { - // In general $class is not supposed to contain a leading backslash, - // but sometimes it does. See tickets PHP-50731 and HHVM-1840. - if ($class[0] !== '\\') - { - $class = '\\' . $class; - } - - if (substr($class, 0, strlen($this->namespace)) === $this->namespace) - { - $path = $this->resolve_path($class); - - if ($path) - { - require $path; - } - } - } -} diff --git a/install/update/old/phpbb/config/config.php b/install/update/old/phpbb/config/config.php deleted file mode 100644 index aaad333..0000000 --- a/install/update/old/phpbb/config/config.php +++ /dev/null @@ -1,167 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\config; - -/** -* Configuration container class -*/ -class config implements \ArrayAccess, \IteratorAggregate, \Countable -{ - /** - * The configuration data - * @var array(string => string) - */ - protected $config; - - /** - * Creates a configuration container with a default set of values - * - * @param array(string => string) $config The configuration data. - */ - public function __construct(array $config) - { - $this->config = $config; - } - - /** - * Retrieves an ArrayIterator over the configuration values. - * - * @return \ArrayIterator An iterator over all config data - */ - public function getIterator() - { - return new \ArrayIterator($this->config); - } - - /** - * Checks if the specified config value exists. - * - * @param string $key The configuration option's name. - * @return bool Whether the configuration option exists. - */ - public function offsetExists($key) - { - return isset($this->config[$key]); - } - - /** - * Retrieves a configuration value. - * - * @param string $key The configuration option's name. - * @return string The configuration value - */ - public function offsetGet($key) - { - return (isset($this->config[$key])) ? $this->config[$key] : ''; - } - - /** - * Temporarily overwrites the value of a configuration variable. - * - * The configuration change will not persist. It will be lost - * after the request. - * - * @param string $key The configuration option's name. - * @param string $value The temporary value. - */ - public function offsetSet($key, $value) - { - $this->config[$key] = $value; - } - - /** - * Called when deleting a configuration value directly, triggers an error. - * - * @param string $key The configuration option's name. - */ - public function offsetUnset($key) - { - trigger_error('Config values have to be deleted explicitly with the \phpbb\config\config::delete($key) method.', E_USER_ERROR); - } - - /** - * Retrieves the number of configuration options currently set. - * - * @return int Number of config options - */ - public function count() - { - return count($this->config); - } - - /** - * Removes a configuration option - * - * @param String $key The configuration option's name - * @param bool $use_cache Whether this variable should be cached or if it - * changes too frequently to be efficiently cached - * @return null - */ - public function delete($key, $use_cache = true) - { - unset($this->config[$key]); - } - - /** - * Sets a configuration option's value - * - * @param string $key The configuration option's name - * @param string $value New configuration value - * @param bool $use_cache Whether this variable should be cached or if it - * changes too frequently to be efficiently cached. - */ - public function set($key, $value, $use_cache = true) - { - $this->config[$key] = $value; - } - - /** - * Sets a configuration option's value only if the old_value matches the - * current configuration value or the configuration value does not exist yet. - * - * @param string $key The configuration option's name - * @param string $old_value Current configuration value - * @param string $new_value New configuration value - * @param bool $use_cache Whether this variable should be cached or if it - * changes too frequently to be efficiently cached. - * @return bool True if the value was changed, false otherwise. - */ - public function set_atomic($key, $old_value, $new_value, $use_cache = true) - { - if (!isset($this->config[$key]) || $this->config[$key] == $old_value) - { - $this->config[$key] = $new_value; - return true; - } - return false; - } - - /** - * Increments an integer configuration value. - * - * @param string $key The configuration option's name - * @param int $increment Amount to increment by - * @param bool $use_cache Whether this variable should be cached or if it - * changes too frequently to be efficiently cached. - */ - function increment($key, $increment, $use_cache = true) - { - if (!isset($this->config[$key])) - { - $this->config[$key] = 0; - } - - $this->config[$key] += $increment; - } -} diff --git a/install/update/old/phpbb/config_php_file.php b/install/update/old/phpbb/config_php_file.php deleted file mode 100644 index 7445e7d..0000000 --- a/install/update/old/phpbb/config_php_file.php +++ /dev/null @@ -1,160 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb; - -class config_php_file -{ - /** @var string phpBB Root Path */ - protected $phpbb_root_path; - - /** @var string php file extension */ - protected $php_ext; - - /** - * Indicates whether the php config file has been loaded. - * - * @var bool - */ - protected $config_loaded = false; - - /** - * The content of the php config file - * - * @var array - */ - protected $config_data = array(); - - /** - * The path to the config file. (Default: $phpbb_root_path . 'config.' . $php_ext) - * - * @var string - */ - protected $config_file; - - private $defined_vars; - - /** - * Constructor - * - * @param string $phpbb_root_path phpBB Root Path - * @param string $php_ext php file extension - */ - function __construct($phpbb_root_path, $php_ext) - { - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - $this->config_file = $this->phpbb_root_path . 'config.' . $this->php_ext; - } - - /** - * Set the path to the config file. - * - * @param string $config_file - */ - public function set_config_file($config_file) - { - $this->config_file = $config_file; - $this->config_loaded = false; - } - - /** - * Returns an associative array containing the variables defined by the config file. - * - * @return array Return the content of the config file or an empty array if the file does not exists. - */ - public function get_all() - { - $this->load_config_file(); - - return $this->config_data; - } - - /** - * Return the value of a variable defined into the config.php file or null if the variable does not exist. - * - * @param string $variable The name of the variable - * @return mixed Value of the variable or null if the variable is not defined. - */ - public function get($variable) - { - $this->load_config_file(); - - return isset($this->config_data[$variable]) ? $this->config_data[$variable] : null; - } - - /** - * Load the config file and store the information. - * - * @return null - */ - protected function load_config_file() - { - if (!$this->config_loaded && file_exists($this->config_file)) - { - $this->defined_vars = get_defined_vars(); - - require($this->config_file); - $this->config_data = array_diff_key(get_defined_vars(), $this->defined_vars); - - $this->config_loaded = true; - } - } - - /** - * Convert either 3.0 dbms or 3.1 db driver class name to 3.1 db driver class name. - * - * If $dbms is a valid 3.1 db driver class name, returns it unchanged. - * Otherwise prepends phpbb\db\driver\ to the dbms to convert a 3.0 dbms - * to 3.1 db driver class name. - * - * @param string $dbms dbms parameter - * @return string driver class - * @throws \RuntimeException - */ - public function convert_30_dbms_to_31($dbms) - { - // Note: this check is done first because mysqli extension - // supplies a mysqli class, and class_exists($dbms) would return - // true for mysqli class. - // However, per the docblock any valid 3.1 driver name should be - // recognized by this function, and have priority over 3.0 dbms. - if (strpos($dbms, 'phpbb\db\driver') === false && class_exists('phpbb\db\driver\\' . $dbms)) - { - return 'phpbb\db\driver\\' . $dbms; - } - - if (class_exists($dbms)) - { - // Additionally we could check that $dbms extends phpbb\db\driver\driver. - // http://php.net/manual/en/class.reflectionclass.php - // Beware of possible performance issues: - // http://stackoverflow.com/questions/294582/php-5-reflection-api-performance - // We could check for interface implementation in all paths or - // only when we do not prepend phpbb\db\driver\. - - /* - $reflection = new \ReflectionClass($dbms); - - if ($reflection->isSubclassOf('phpbb\db\driver\driver')) - { - return $dbms; - } - */ - - return $dbms; - } - - throw new \RuntimeException("You have specified an invalid dbms driver: $dbms"); - } -} diff --git a/install/update/old/phpbb/console/command/cron/run.php b/install/update/old/phpbb/console/command/cron/run.php deleted file mode 100644 index dea6493..0000000 --- a/install/update/old/phpbb/console/command/cron/run.php +++ /dev/null @@ -1,171 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\console\command\cron; - -use phpbb\exception\runtime_exception; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Output\OutputInterface; - -class run extends \phpbb\console\command\command -{ - /** @var \phpbb\cron\manager */ - protected $cron_manager; - - /** @var \phpbb\lock\db */ - protected $lock_db; - - /** - * Construct method - * - * @param \phpbb\user $user The user object (used to get language information) - * @param \phpbb\cron\manager $cron_manager The cron manager containing - * the cron tasks to be executed. - * @param \phpbb\lock\db $lock_db The lock for accessing database. - */ - public function __construct(\phpbb\user $user, \phpbb\cron\manager $cron_manager, \phpbb\lock\db $lock_db) - { - $this->cron_manager = $cron_manager; - $this->lock_db = $lock_db; - parent::__construct($user); - } - - /** - * Sets the command name and description - * - * @return null - */ - protected function configure() - { - $this - ->setName('cron:run') - ->setDescription($this->user->lang('CLI_DESCRIPTION_CRON_RUN')) - ->setHelp($this->user->lang('CLI_HELP_CRON_RUN')) - ->addArgument('name', InputArgument::OPTIONAL, $this->user->lang('CLI_DESCRIPTION_CRON_RUN_ARGUMENT_1')) - ; - } - - /** - * Executes the command cron:run. - * - * Tries to acquire the cron lock, then if no argument has been given runs all ready cron tasks. - * If the cron lock can not be obtained, an error message is printed - * and the exit status is set to 1. - * If the verbose option is specified, each start of a task is printed. - * Otherwise there is no output. - * If an argument is given to the command, only the task whose name matches the - * argument will be started. If verbose option is specified, - * an info message containing the name of the task is printed. - * If no task matches the argument given, an error message is printed - * and the exit status is set to 2. - * - * @param InputInterface $input The input stream used to get the argument and verboe option. - * @param OutputInterface $output The output stream, used for printing verbose-mode and error information. - * - * @return int 0 if all is ok, 1 if a lock error occured and 2 if no task matching the argument was found. - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - if ($this->lock_db->acquire()) - { - $task_name = $input->getArgument('name'); - if ($task_name) - { - $exit_status = $this->run_one($input, $output, $task_name); - } - else - { - $exit_status = $this->run_all($input, $output); - } - - $this->lock_db->release(); - return $exit_status; - } - else - { - throw new runtime_exception('CRON_LOCK_ERROR', array(), null, 1); - } - } - - /** - * Executes all ready cron tasks. - * - * If verbose mode is set, an info message will be printed if there is no task to - * be run, or else for each starting task. - * - * @see execute - * @param InputInterface $input The input stream used to get the argument and verbose option. - * @param OutputInterface $output The output stream, used for printing verbose-mode and error information. - * @return int 0 - */ - protected function run_all(InputInterface $input, OutputInterface $output) - { - $run_tasks = $this->cron_manager->find_all_ready_tasks(); - - if ($run_tasks) - { - foreach ($run_tasks as $task) - { - if ($input->getOption('verbose')) - { - $output->writeln('' . $this->user->lang('RUNNING_TASK', $task->get_name()) . ''); - } - - $task->run(); - } - } - else - { - if ($input->getOption('verbose')) - { - $output->writeln('' . $this->user->lang('CRON_NO_TASK') . ''); - } - } - - return 0; - } - - /** - * Executes a given cron task, if it is ready. - * - * If there is a task whose name matches $task_name, it is run and 0 is returned. - * and if verbose mode is set, print an info message with the name of the task. - * If there is no task matching $task_name, the function prints an error message - * and returns with status 2. - * - * @see execute - * @param string $task_name The name of the task that should be run. - * @param InputInterface $input The input stream used to get the argument and verbose option. - * @param OutputInterface $output The output stream, used for printing verbose-mode and error information. - * @return int 0 if all is well, 2 if no task matches $task_name. - */ - protected function run_one(InputInterface $input, OutputInterface $output, $task_name) - { - $task = $this->cron_manager->find_task($task_name); - if ($task) - { - if ($input->getOption('verbose')) - { - $output->writeln('' . $this->user->lang('RUNNING_TASK', $task_name) . ''); - } - - $task->run(); - return 0; - } - else - { - throw new runtime_exception('CRON_NO_SUCH_TASK', array( $task_name), null, 2); - } - } -} diff --git a/install/update/old/phpbb/console/command/extension/enable.php b/install/update/old/phpbb/console/command/extension/enable.php deleted file mode 100644 index a6f5b10..0000000 --- a/install/update/old/phpbb/console/command/extension/enable.php +++ /dev/null @@ -1,76 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ -namespace phpbb\console\command\extension; - -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Style\SymfonyStyle; - -class enable extends command -{ - protected function configure() - { - $this - ->setName('extension:enable') - ->setDescription($this->user->lang('CLI_DESCRIPTION_ENABLE_EXTENSION')) - ->addArgument( - 'extension-name', - InputArgument::REQUIRED, - $this->user->lang('CLI_EXTENSION_NAME') - ) - ; - } - - protected function execute(InputInterface $input, OutputInterface $output) - { - $io = new SymfonyStyle($input, $output); - - $name = $input->getArgument('extension-name'); - - if (!$this->manager->is_available($name)) - { - $io->error($this->user->lang('CLI_EXTENSION_NOT_EXIST', $name)); - return 1; - } - - $extension = $this->manager->get_extension($name); - - if (!$extension->is_enableable()) - { - $io->error($this->user->lang('CLI_EXTENSION_NOT_ENABLEABLE', $name)); - return 1; - } - - if ($this->manager->is_enabled($name)) - { - $io->error($this->user->lang('CLI_EXTENSION_ENABLED', $name)); - return 1; - } - - $this->manager->enable($name); - $this->manager->load_extensions(); - - if ($this->manager->is_enabled($name)) - { - $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($name)); - $io->success($this->user->lang('CLI_EXTENSION_ENABLE_SUCCESS', $name)); - return 0; - } - else - { - $io->error($this->user->lang('CLI_EXTENSION_ENABLE_FAILURE', $name)); - return 1; - } - } -} diff --git a/install/update/old/phpbb/console/command/update/check.php b/install/update/old/phpbb/console/command/update/check.php deleted file mode 100644 index 9ced651..0000000 --- a/install/update/old/phpbb/console/command/update/check.php +++ /dev/null @@ -1,331 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\console\command\update; - -use phpbb\config\config; -use phpbb\exception\exception_interface; -use phpbb\language\language; -use phpbb\user; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Style\SymfonyStyle; -use Symfony\Component\DependencyInjection\ContainerInterface; - -class check extends \phpbb\console\command\command -{ - /** @var \phpbb\config\config */ - protected $config; - - /** @var \Symfony\Component\DependencyInjection\ContainerBuilder */ - protected $phpbb_container; - /** - * @var language - */ - private $language; - - /** - * Construct method - */ - public function __construct(user $user, config $config, ContainerInterface $phpbb_container, language $language) - { - $this->config = $config; - $this->phpbb_container = $phpbb_container; - $this->language = $language; - - $this->language->add_lang(array('acp/common', 'acp/extensions')); - - parent::__construct($user); - } - - /** - * Configures the service. - * - * Sets the name and description of the command. - * - * @return null - */ - protected function configure() - { - $this - ->setName('update:check') - ->setDescription($this->language->lang('CLI_DESCRIPTION_UPDATE_CHECK')) - ->addArgument('ext-name', InputArgument::OPTIONAL, $this->language->lang('CLI_DESCRIPTION_UPDATE_CHECK_ARGUMENT_1')) - ->addOption('stability', null, InputOption::VALUE_REQUIRED, $this->language->lang('CLI_DESCRIPTION_UPDATE_CHECK_OPTION_STABILITY')) - ->addOption('cache', 'c', InputOption::VALUE_NONE, $this->language->lang('CLI_DESCRIPTION_UPDATE_CHECK_OPTION_CACHE')) - ; - } - - /** - * Executes the command. - * - * Checks if an update is available. - * If at least one is available, a message is printed and if verbose mode is set the list of possible updates is printed. - * If their is none, nothing is printed unless verbose mode is set. - * - * @param InputInterface $input Input stream, used to get the options. - * @param OutputInterface $output Output stream, used to print messages. - * @return int 0 if the board is up to date, 1 if it is not and 2 if an error occured. - * @throws \RuntimeException - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - $io = new SymfonyStyle($input, $output); - - $recheck = true; - if ($input->getOption('cache')) - { - $recheck = false; - } - - $stability = null; - if ($input->getOption('stability')) - { - $stability = $input->getOption('stability'); - if (!($stability == 'stable') && !($stability == 'unstable')) - { - $io->error($this->language->lang('CLI_ERROR_INVALID_STABILITY', $stability)); - return 3; - } - } - - $ext_name = $input->getArgument('ext-name'); - if ($ext_name != null) - { - if ($ext_name == 'all') - { - return $this->check_all_ext($io, $stability, $recheck); - } - else - { - return $this->check_ext($input, $io, $stability, $recheck, $ext_name); - } - } - else - { - return $this->check_core($input, $io, $stability, $recheck); - } - } - - /** - * Check if a given extension is up to date - * - * @param InputInterface $input Input stream, used to get the options. - * @param SymfonyStyle $io IO handler, for formatted and unified IO - * @param string $stability Force a given stability - * @param bool $recheck Disallow the use of the cache - * @param string $ext_name The extension name - * @return int - */ - protected function check_ext(InputInterface $input, SymfonyStyle $io, $stability, $recheck, $ext_name) - { - try - { - $ext_manager = $this->phpbb_container->get('ext.manager'); - $md_manager = $ext_manager->create_extension_metadata_manager($ext_name); - $updates_available = $ext_manager->version_check($md_manager, $recheck, false, $stability); - - $metadata = $md_manager->get_metadata('all'); - if ($input->getOption('verbose')) - { - $io->title($md_manager->get_metadata('display-name')); - - $io->note($this->language->lang('CURRENT_VERSION') . $this->language->lang('COLON') . ' ' . $metadata['version']); - } - - if (!empty($updates_available)) - { - if ($input->getOption('verbose')) - { - $io->caution($this->language->lang('NOT_UP_TO_DATE', $metadata['name'])); - - $this->display_versions($io, $updates_available); - } - - return 1; - } - else - { - if ($input->getOption('verbose')) - { - $io->success($this->language->lang('UPDATE_NOT_NEEDED')); - } - - return 0; - } - } - catch (\RuntimeException $e) - { - $io->error($this->language->lang('EXTENSION_NOT_INSTALLED', $ext_name)); - - return 1; - } - } - - /** - * Check if the core is up to date - * - * @param InputInterface $input Input stream, used to get the options. - * @param SymfonyStyle $io IO handler, for formatted and unified IO - * @param string $stability Force a given stability - * @param bool $recheck Disallow the use of the cache - * @return int - */ - protected function check_core(InputInterface $input, SymfonyStyle $io, $stability, $recheck) - { - $version_helper = $this->phpbb_container->get('version_helper'); - $version_helper->force_stability($stability); - - $updates_available = $version_helper->get_suggested_updates($recheck); - - if ($input->getOption('verbose')) - { - $io->title('phpBB core'); - - $io->note( $this->language->lang('CURRENT_VERSION') . $this->language->lang('COLON') . ' ' . $this->config['version']); - } - - if (!empty($updates_available)) - { - $io->caution($this->language->lang('UPDATE_NEEDED')); - - if ($input->getOption('verbose')) - { - $this->display_versions($io, $updates_available); - } - - return 1; - } - else - { - if ($input->getOption('verbose')) - { - $io->success($this->language->lang('UPDATE_NOT_NEEDED')); - } - - return 0; - } - } - - /** - * Check if all the available extensions are up to date - * - * @param SymfonyStyle $io IO handler, for formatted and unified IO - * @param bool $recheck Disallow the use of the cache - * @return int - */ - protected function check_all_ext(SymfonyStyle $io, $stability, $recheck) - { - /** @var \phpbb\extension\manager $ext_manager */ - $ext_manager = $this->phpbb_container->get('ext.manager'); - - $rows = []; - - foreach ($ext_manager->all_available() as $ext_name => $ext_path) - { - $row = []; - $row[] = sprintf("%s", $ext_name); - $md_manager = $ext_manager->create_extension_metadata_manager($ext_name); - try - { - $metadata = $md_manager->get_metadata('all'); - if (isset($metadata['extra']['version-check'])) - { - try { - $updates_available = $ext_manager->version_check($md_manager, $recheck, false, $stability); - if (!empty($updates_available)) - { - $versions = array_map(function($entry) - { - return $entry['current']; - }, $updates_available); - - $row[] = sprintf("%s", $metadata['version']); - $row[] = implode(', ', $versions); - } - else - { - $row[] = sprintf("%s", $metadata['version']); - $row[] = ''; - } - } catch (\RuntimeException $e) { - $row[] = $metadata['version']; - $row[] = ''; - } - } - else - { - $row[] = $metadata['version']; - $row[] = ''; - } - } - catch (exception_interface $e) - { - $exception_message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters())); - $row[] = '' . $exception_message . ''; - } - catch (\RuntimeException $e) - { - $row[] = '' . $e->getMessage() . ''; - } - - $rows[] = $row; - } - - $io->table([ - $this->language->lang('EXTENSION_NAME'), - $this->language->lang('CURRENT_VERSION'), - $this->language->lang('LATEST_VERSION'), - ], $rows); - - return 0; - } - - /** - * Display the details of the available updates - * - * @param SymfonyStyle $io IO handler, for formatted and unified IO - * @param array $updates_available The list of the available updates - */ - protected function display_versions(SymfonyStyle $io, $updates_available) - { - $io->section($this->language->lang('UPDATES_AVAILABLE')); - - $rows = []; - foreach ($updates_available as $version_data) - { - $row = ['', '', '']; - $row[0] = $version_data['current']; - - if (isset($version_data['announcement'])) - { - $row[1] = $version_data['announcement']; - } - - if (isset($version_data['download'])) - { - $row[2] = $version_data['download']; - } - - $rows[] = $row; - } - - $io->table([ - $this->language->lang('VERSION'), - $this->language->lang('ANNOUNCEMENT_TOPIC'), - $this->language->lang('DOWNLOAD_LATEST'), - ], $rows); - } -} diff --git a/install/update/old/phpbb/console/command/user/add.php b/install/update/old/phpbb/console/command/user/add.php deleted file mode 100644 index c60a059..0000000 --- a/install/update/old/phpbb/console/command/user/add.php +++ /dev/null @@ -1,334 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\console\command\user; - -use phpbb\config\config; -use phpbb\console\command\command; -use phpbb\db\driver\driver_interface; -use phpbb\exception\runtime_exception; -use phpbb\language\language; -use phpbb\passwords\manager; -use phpbb\user; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Question\Question; -use Symfony\Component\Console\Style\SymfonyStyle; - -class add extends command -{ - /** @var array Array of interactively acquired options */ - protected $data; - - /** @var driver_interface */ - protected $db; - - /** @var config */ - protected $config; - - /** @var language */ - protected $language; - - /** @var manager */ - protected $password_manager; - - /** - * phpBB root path - * - * @var string - */ - protected $phpbb_root_path; - - /** - * PHP extension. - * - * @var string - */ - protected $php_ext; - - /** - * Construct method - * - * @param user $user - * @param driver_interface $db - * @param config $config - * @param language $language - * @param manager $password_manager - * @param string $phpbb_root_path - * @param string $php_ext - */ - public function __construct(user $user, driver_interface $db, config $config, language $language, manager $password_manager, $phpbb_root_path, $php_ext) - { - $this->db = $db; - $this->config = $config; - $this->language = $language; - $this->password_manager = $password_manager; - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - - $this->language->add_lang('ucp'); - parent::__construct($user); - } - - /** - * Sets the command name and description - * - * @return null - */ - protected function configure() - { - $this - ->setName('user:add') - ->setDescription($this->language->lang('CLI_DESCRIPTION_USER_ADD')) - ->setHelp($this->language->lang('CLI_HELP_USER_ADD')) - ->addOption( - 'username', - 'U', - InputOption::VALUE_REQUIRED, - $this->language->lang('CLI_DESCRIPTION_USER_ADD_OPTION_USERNAME') - ) - ->addOption( - 'password', - 'P', - InputOption::VALUE_REQUIRED, - $this->language->lang('CLI_DESCRIPTION_USER_ADD_OPTION_PASSWORD') - ) - ->addOption( - 'email', - 'E', - InputOption::VALUE_REQUIRED, - $this->language->lang('CLI_DESCRIPTION_USER_ADD_OPTION_EMAIL') - ) - ->addOption( - 'send-email', - null, - InputOption::VALUE_NONE, - $this->language->lang('CLI_DESCRIPTION_USER_ADD_OPTION_NOTIFY') - ) - ; - } - - /** - * Executes the command user:add - * - * Adds a new user to the database. If options are not provided, it will ask for the username, password and email. - * User is added to the registered user group. Language and timezone default to $config settings. - * - * @param InputInterface $input The input stream used to get the options - * @param OutputInterface $output The output stream, used to print messages - * - * @return int 0 if all is well, 1 if any errors occurred - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - $io = new SymfonyStyle($input, $output); - - try - { - $this->validate_user_data(); - $group_id = $this->get_group_id(); - } - catch (runtime_exception $e) - { - $io->error($e->getMessage()); - return 1; - } - - $user_row = array( - 'username' => $this->data['username'], - 'user_password' => $this->password_manager->hash($this->data['new_password']), - 'user_email' => $this->data['email'], - 'group_id' => $group_id, - 'user_timezone' => $this->config['board_timezone'], - 'user_lang' => $this->config['default_lang'], - 'user_type' => USER_NORMAL, - 'user_regdate' => time(), - ); - - $user_id = (int) user_add($user_row); - - if (!$user_id) - { - $io->error($this->language->lang('AUTH_NO_PROFILE_CREATED')); - return 1; - } - - if ($input->getOption('send-email') && $this->config['email_enable']) - { - $this->send_activation_email($user_id); - } - - $io->success($this->language->lang('CLI_USER_ADD_SUCCESS', $this->data['username'])); - - return 0; - } - - /** - * Interacts with the user. - * - * @param InputInterface $input An InputInterface instance - * @param OutputInterface $output An OutputInterface instance - */ - protected function interact(InputInterface $input, OutputInterface $output) - { - $helper = $this->getHelper('question'); - - $this->data = array( - 'username' => $input->getOption('username'), - 'new_password' => $input->getOption('password'), - 'email' => $input->getOption('email'), - ); - - if (!$this->data['username']) - { - $question = new Question($this->ask_user('USERNAME')); - $this->data['username'] = $helper->ask($input, $output, $question); - } - - if (!$this->data['new_password']) - { - $question = new Question($this->ask_user('PASSWORD')); - $question->setValidator(function ($value) use ($helper, $input, $output) { - $question = new Question($this->ask_user('CONFIRM_PASSWORD')); - $question->setHidden(true); - if ($helper->ask($input, $output, $question) != $value) - { - throw new runtime_exception($this->language->lang('NEW_PASSWORD_ERROR')); - } - return $value; - }); - $question->setHidden(true); - $question->setMaxAttempts(5); - - $this->data['new_password'] = $helper->ask($input, $output, $question); - } - - if (!$this->data['email']) - { - $question = new Question($this->ask_user('EMAIL_ADDRESS')); - $this->data['email'] = $helper->ask($input, $output, $question); - } - } - - /** - * Validate the submitted user data - * - * @throws runtime_exception if any data fails validation - * @return null - */ - protected function validate_user_data() - { - if (!function_exists('validate_data')) - { - require($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext); - } - - $error = validate_data($this->data, array( - 'username' => array( - array('string', false, $this->config['min_name_chars'], $this->config['max_name_chars']), - array('username', '')), - 'new_password' => array( - array('string', false, $this->config['min_pass_chars'], $this->config['max_pass_chars']), - array('password')), - 'email' => array( - array('string', false, 6, 60), - array('user_email')), - )); - - if ($error) - { - throw new runtime_exception(implode("\n", array_map(array($this->language, 'lang'), $error))); - } - } - - /** - * Get the group id - * - * Go and find in the database the group_id corresponding to 'REGISTERED' - * - * @throws runtime_exception if the group id does not exist in database. - * @return null - */ - protected function get_group_id() - { - $sql = 'SELECT group_id - FROM ' . GROUPS_TABLE . " - WHERE group_name = '" . $this->db->sql_escape('REGISTERED') . "' - AND group_type = " . GROUP_SPECIAL; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if (!$row || !$row['group_id']) - { - throw new runtime_exception($this->language->lang('NO_GROUP')); - } - - return $row['group_id']; - } - - /** - * Send account activation email - * - * @param int $user_id The new user's id - * @return null - */ - protected function send_activation_email($user_id) - { - switch ($this->config['require_activation']) - { - case USER_ACTIVATION_SELF: - $email_template = 'user_welcome_inactive'; - $user_actkey = gen_rand_string(mt_rand(6, 10)); - break; - case USER_ACTIVATION_ADMIN: - $email_template = 'admin_welcome_inactive'; - $user_actkey = gen_rand_string(mt_rand(6, 10)); - break; - default: - $email_template = 'user_welcome'; - $user_actkey = ''; - break; - } - - if (!class_exists('messenger')) - { - require($this->phpbb_root_path . 'includes/functions_messenger.' . $this->php_ext); - } - - $messenger = new \messenger(false); - $messenger->template($email_template, $this->user->lang_name); - $messenger->to($this->data['email'], $this->data['username']); - $messenger->anti_abuse_headers($this->config, $this->user); - $messenger->assign_vars(array( - 'WELCOME_MSG' => htmlspecialchars_decode($this->language->lang('WELCOME_SUBJECT', $this->config['sitename'])), - 'USERNAME' => htmlspecialchars_decode($this->data['username']), - 'PASSWORD' => htmlspecialchars_decode($this->data['new_password']), - 'U_ACTIVATE' => generate_board_url() . "/ucp.{$this->php_ext}?mode=activate&u=$user_id&k=$user_actkey") - ); - - $messenger->send(NOTIFY_EMAIL); - } - - /** - * Helper to translate questions to the user - * - * @param string $key The language key - * @return string The language key translated with a colon and space appended - */ - protected function ask_user($key) - { - return $this->language->lang($key) . $this->language->lang('COLON') . ' '; - } -} diff --git a/install/update/old/phpbb/content_visibility.php b/install/update/old/phpbb/content_visibility.php deleted file mode 100644 index f023e07..0000000 --- a/install/update/old/phpbb/content_visibility.php +++ /dev/null @@ -1,885 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb; - -/** -* phpbb_visibility -* Handle fetching and setting the visibility for topics and posts -*/ -class content_visibility -{ - /** - * Database object - * @var \phpbb\db\driver\driver_interface - */ - protected $db; - - /** - * User object - * @var \phpbb\user - */ - protected $user; - - /** - * Auth object - * @var \phpbb\auth\auth - */ - protected $auth; - - /** - * config object - * @var \phpbb\config\config - */ - protected $config; - - /** - * Event dispatcher object - * @var \phpbb\event\dispatcher_interface - */ - protected $phpbb_dispatcher; - - /** - * phpBB root path - * @var string - */ - protected $phpbb_root_path; - - /** - * PHP Extension - * @var string - */ - protected $php_ext; - - /** - * Constructor - * - * @param \phpbb\auth\auth $auth Auth object - * @param \phpbb\config\config $config Config object - * @param \phpbb\event\dispatcher_interface $phpbb_dispatcher Event dispatcher object - * @param \phpbb\db\driver\driver_interface $db Database object - * @param \phpbb\user $user User object - * @param string $phpbb_root_path Root path - * @param string $php_ext PHP Extension - * @param string $forums_table Forums table name - * @param string $posts_table Posts table name - * @param string $topics_table Topics table name - * @param string $users_table Users table name - */ - public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\event\dispatcher_interface $phpbb_dispatcher, \phpbb\db\driver\driver_interface $db, \phpbb\user $user, $phpbb_root_path, $php_ext, $forums_table, $posts_table, $topics_table, $users_table) - { - $this->auth = $auth; - $this->config = $config; - $this->phpbb_dispatcher = $phpbb_dispatcher; - $this->db = $db; - $this->user = $user; - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - $this->forums_table = $forums_table; - $this->posts_table = $posts_table; - $this->topics_table = $topics_table; - $this->users_table = $users_table; - } - - /** - * Can the current logged-in user soft-delete posts? - * - * @param $forum_id int Forum ID whose permissions to check - * @param $poster_id int Poster ID of the post in question - * @param $post_locked bool Is the post locked? - * @return bool - */ - public function can_soft_delete($forum_id, $poster_id, $post_locked) - { - if ($this->auth->acl_get('m_softdelete', $forum_id)) - { - return true; - } - else if ($this->auth->acl_get('f_softdelete', $forum_id) && $poster_id == $this->user->data['user_id'] && !$post_locked) - { - return true; - } - - return false; - } - - /** - * Get the topics post count or the forums post/topic count based on permissions - * - * @param $mode string One of topic_posts, forum_posts or forum_topics - * @param $data array Array with the topic/forum data to calculate from - * @param $forum_id int The forum id is used for permission checks - * @return int Number of posts/topics the user can see in the topic/forum - */ - public function get_count($mode, $data, $forum_id) - { - if (!$this->auth->acl_get('m_approve', $forum_id)) - { - return (int) $data[$mode . '_approved']; - } - - return (int) $data[$mode . '_approved'] + (int) $data[$mode . '_unapproved'] + (int) $data[$mode . '_softdeleted']; - } - - - /** - * Check topic/post visibility for a given forum ID - * - * Note: Read permissions are not checked. - * - * @param $mode string Either "topic" or "post" - * @param $forum_id int The forum id is used for permission checks - * @param $data array Array with item information to check visibility - * @return bool True if the item is visible, false if not - */ - public function is_visible($mode, $forum_id, $data) - { - $is_visible = $this->auth->acl_get('m_approve', $forum_id) || $data[$mode . '_visibility'] == ITEM_APPROVED; - - /** - * Allow changing the result of calling is_visible - * - * @event core.phpbb_content_visibility_is_visible - * @var bool is_visible Default visibility condition, to be modified by extensions if needed. - * @var string mode Either "topic" or "post" - * @var int forum_id Forum id of the current item - * @var array data Array of item information - * @since 3.2.2-RC1 - */ - $vars = array( - 'is_visible', - 'mode', - 'forum_id', - 'data', - ); - extract($this->phpbb_dispatcher->trigger_event('core.phpbb_content_visibility_is_visible', compact($vars))); - - return $is_visible; - } - - /** - * Create topic/post visibility SQL for a given forum ID - * - * Note: Read permissions are not checked. - * - * @param $mode string Either "topic" or "post" - * @param $forum_id int The forum id is used for permission checks - * @param $table_alias string Table alias to prefix in SQL queries - * @return string The appropriate combination SQL logic for topic/post_visibility - */ - public function get_visibility_sql($mode, $forum_id, $table_alias = '') - { - $where_sql = ''; - - $get_visibility_sql_overwrite = false; - - /** - * Allow changing the result of calling get_visibility_sql - * - * @event core.phpbb_content_visibility_get_visibility_sql_before - * @var string where_sql Extra visibility conditions. It must end with either an SQL "AND" or an "OR" - * @var string mode Either "topic" or "post" depending on the query this is being used in - * @var array forum_id The forum id in which the search is made. - * @var string table_alias Table alias to prefix in SQL queries - * @var mixed get_visibility_sql_overwrite If a string, forces the function to return get_forums_visibility_sql_overwrite after executing the event - * If false, get_visibility_sql continues normally - * It must be either boolean or string - * @since 3.1.4-RC1 - */ - $vars = array( - 'where_sql', - 'mode', - 'forum_id', - 'table_alias', - 'get_visibility_sql_overwrite', - ); - extract($this->phpbb_dispatcher->trigger_event('core.phpbb_content_visibility_get_visibility_sql_before', compact($vars))); - - if ($get_visibility_sql_overwrite !== false) - { - return $get_visibility_sql_overwrite; - } - - if ($this->auth->acl_get('m_approve', $forum_id)) - { - $where_sql .= '1 = 1'; - } - else - { - $where_sql .= $table_alias . $mode . '_visibility = ' . ITEM_APPROVED; - } - - return '(' . $where_sql . ')'; - } - - /** - * Create topic/post visibility SQL for a set of forums - * - * Note: Read permissions are not checked. Forums without read permissions - * should not be in $forum_ids - * - * @param $mode string Either "topic" or "post" - * @param $forum_ids array Array of forum ids which the posts/topics are limited to - * @param $table_alias string Table alias to prefix in SQL queries - * @return string The appropriate combination SQL logic for topic/post_visibility - */ - public function get_forums_visibility_sql($mode, $forum_ids = array(), $table_alias = '') - { - $where_sql = ''; - - $approve_forums = array_keys($this->auth->acl_getf('m_approve', true)); - if (!empty($forum_ids) && !empty($approve_forums)) - { - $approve_forums = array_intersect($forum_ids, $approve_forums); - $forum_ids = array_diff($forum_ids, $approve_forums); - } - - $get_forums_visibility_sql_overwrite = false; - /** - * Allow changing the result of calling get_forums_visibility_sql - * - * @event core.phpbb_content_visibility_get_forums_visibility_before - * @var string where_sql Extra visibility conditions. It must end with either an SQL "AND" or an "OR" - * @var string mode Either "topic" or "post" depending on the query this is being used in - * @var array forum_ids Array of forum ids which the posts/topics are limited to - * @var string table_alias Table alias to prefix in SQL queries - * @var array approve_forums Array of forums where the user has m_approve permissions - * @var mixed get_forums_visibility_sql_overwrite If a string, forces the function to return get_forums_visibility_sql_overwrite after executing the event - * If false, get_forums_visibility_sql continues normally - * It must be either boolean or string - * @since 3.1.3-RC1 - */ - $vars = array( - 'where_sql', - 'mode', - 'forum_ids', - 'table_alias', - 'approve_forums', - 'get_forums_visibility_sql_overwrite', - ); - extract($this->phpbb_dispatcher->trigger_event('core.phpbb_content_visibility_get_forums_visibility_before', compact($vars))); - - if ($get_forums_visibility_sql_overwrite !== false) - { - return $get_forums_visibility_sql_overwrite; - } - - // Moderator can view all posts/topics in the moderated forums - $where_sql .= '(' . $this->db->sql_in_set($table_alias . 'forum_id', $approve_forums, false, true) . ' OR '; - // Normal user can view approved items only - $where_sql .= '(' . $table_alias . $mode . '_visibility = ' . ITEM_APPROVED . ' - AND ' . $this->db->sql_in_set($table_alias . 'forum_id', $forum_ids, false, true) . '))'; - - return '(' . $where_sql . ')'; - } - - /** - * Create topic/post visibility SQL for all forums on the board - * - * Note: Read permissions are not checked. Forums without read permissions - * should be in $exclude_forum_ids - * - * @param $mode string Either "topic" or "post" - * @param $exclude_forum_ids array Array of forum ids which are excluded - * @param $table_alias string Table alias to prefix in SQL queries - * @return string The appropriate combination SQL logic for topic/post_visibility - */ - public function get_global_visibility_sql($mode, $exclude_forum_ids = array(), $table_alias = '') - { - $where_sqls = array(); - - $approve_forums = array_diff(array_keys($this->auth->acl_getf('m_approve', true)), $exclude_forum_ids); - - $visibility_sql_overwrite = null; - - /** - * Allow changing the result of calling get_global_visibility_sql - * - * @event core.phpbb_content_visibility_get_global_visibility_before - * @var array where_sqls Array of extra visibility conditions. Will be joined by imploding with "OR". - * @var string mode Either "topic" or "post" depending on the query this is being used in - * @var array exclude_forum_ids Array of forum ids the current user doesn't have access to - * @var string table_alias Table alias to prefix in SQL queries - * @var array approve_forums Array of forums where the user has m_approve permissions - * @var string visibility_sql_overwrite If not empty, forces the function to return visibility_sql_overwrite after executing the event - * @since 3.1.3-RC1 - */ - $vars = array( - 'where_sqls', - 'mode', - 'exclude_forum_ids', - 'table_alias', - 'approve_forums', - 'visibility_sql_overwrite', - ); - extract($this->phpbb_dispatcher->trigger_event('core.phpbb_content_visibility_get_global_visibility_before', compact($vars))); - - if ($visibility_sql_overwrite) - { - return $visibility_sql_overwrite; - } - - // Include approved items in all forums but the excluded - $where_sqls[] = '(' . $this->db->sql_in_set($table_alias . 'forum_id', $exclude_forum_ids, true, true) . ' - AND ' . $table_alias . $mode . '_visibility = ' . ITEM_APPROVED . ')'; - - // If user has moderator permissions, add everything in the moderated forums - if (count($approve_forums)) - { - $where_sqls[] = $this->db->sql_in_set($table_alias . 'forum_id', $approve_forums); - } - - return '(' . implode(' OR ', $where_sqls) . ')'; - } - - /** - * Change visibility status of one post or all posts of a topic - * - * @param $visibility int Element of {ITEM_APPROVED, ITEM_DELETED, ITEM_REAPPROVE} - * @param $post_id mixed Post ID or array of post IDs to act on, - * if it is empty, all posts of topic_id will be modified - * @param $topic_id int Topic where $post_id is found - * @param $forum_id int Forum where $topic_id is found - * @param $user_id int User performing the action - * @param $time int Timestamp when the action is performed - * @param $reason string Reason why the visibility was changed. - * @param $is_starter bool Is this the first post of the topic changed? - * @param $is_latest bool Is this the last post of the topic changed? - * @param $limit_visibility mixed Limit updating per topic_id to a certain visibility - * @param $limit_delete_time mixed Limit updating per topic_id to a certain deletion time - * @return array Changed post data, empty array if an error occurred. - */ - public function set_post_visibility($visibility, $post_id, $topic_id, $forum_id, $user_id, $time, $reason, $is_starter, $is_latest, $limit_visibility = false, $limit_delete_time = false) - { - if (!in_array($visibility, array(ITEM_APPROVED, ITEM_DELETED, ITEM_REAPPROVE))) - { - return array(); - } - - if ($post_id) - { - if (is_array($post_id)) - { - $where_sql = $this->db->sql_in_set('post_id', array_map('intval', $post_id)); - } - else - { - $where_sql = 'post_id = ' . (int) $post_id; - } - $where_sql .= ' AND topic_id = ' . (int) $topic_id; - } - else - { - $where_sql = 'topic_id = ' . (int) $topic_id; - - // Limit the posts to a certain visibility and deletion time - // This allows us to only restore posts, that were approved - // when the topic got soft deleted. So previous soft deleted - // and unapproved posts are still soft deleted/unapproved - if ($limit_visibility !== false) - { - $where_sql .= ' AND post_visibility = ' . (int) $limit_visibility; - } - - if ($limit_delete_time !== false) - { - $where_sql .= ' AND post_delete_time = ' . (int) $limit_delete_time; - } - } - - $sql = 'SELECT poster_id, post_id, post_postcount, post_visibility - FROM ' . $this->posts_table . ' - WHERE ' . $where_sql; - $result = $this->db->sql_query($sql); - - $post_ids = $poster_postcounts = $postcounts = $postcount_visibility = array(); - while ($row = $this->db->sql_fetchrow($result)) - { - $post_ids[] = (int) $row['post_id']; - - if ($row['post_visibility'] != $visibility) - { - if ($row['post_postcount'] && !isset($poster_postcounts[(int) $row['poster_id']])) - { - $poster_postcounts[(int) $row['poster_id']] = 1; - } - else if ($row['post_postcount']) - { - $poster_postcounts[(int) $row['poster_id']]++; - } - - if (!isset($postcount_visibility[$row['post_visibility']])) - { - $postcount_visibility[$row['post_visibility']] = 1; - } - else - { - $postcount_visibility[$row['post_visibility']]++; - } - } - } - $this->db->sql_freeresult($result); - - if (empty($post_ids)) - { - return array(); - } - - if (!function_exists('truncate_string')) - { - include($this->phpbb_root_path . 'includes/functions_content.' . $this->php_ext); - } - - $data = array( - 'post_visibility' => (int) $visibility, - 'post_delete_user' => (int) $user_id, - 'post_delete_time' => ((int) $time) ?: time(), - 'post_delete_reason' => truncate_string($reason, 255, 255, false), - ); - /** - * Perform actions right before the query to change post visibility - * - * @event core.set_post_visibility_before_sql - * @var int visibility Element of {ITEM_APPROVED, ITEM_DELETED, ITEM_REAPPROVE} - * @var array post_id Array containing all post IDs to be modified. If blank, all posts within the topic are modified. - * @var int topic_id Topic of the post IDs to be modified. - * @var int forum_id Forum ID that the topic_id resides in. - * @var int user_id User ID doing this action. - * @var int time Timestamp of this action. - * @var string reason Reason specified by the user for this change. - * @var bool is_starter Are we changing the topic's starter? - * @var bool is_latest Are we changing the topic's latest post? - * @var array data The data array for this action. - * @since 3.1.10-RC1 - * @changed 3.2.2-RC1 Use time instead of non-existent timestamp - */ - $vars = array( - 'visibility', - 'post_id', - 'topic_id', - 'forum_id', - 'user_id', - 'time', - 'reason', - 'is_starter', - 'is_latest', - 'data', - ); - extract($this->phpbb_dispatcher->trigger_event('core.set_post_visibility_before_sql', compact($vars))); - $sql = 'UPDATE ' . $this->posts_table . ' - SET ' . $this->db->sql_build_array('UPDATE', $data) . ' - WHERE ' . $this->db->sql_in_set('post_id', $post_ids); - $this->db->sql_query($sql); - - // Group the authors by post count, to reduce the number of queries - foreach ($poster_postcounts as $poster_id => $num_posts) - { - $postcounts[$num_posts][] = $poster_id; - } - - // Update users postcounts - foreach ($postcounts as $num_posts => $poster_ids) - { - if (in_array($visibility, array(ITEM_REAPPROVE, ITEM_DELETED))) - { - $sql = 'UPDATE ' . $this->users_table . ' - SET user_posts = 0 - WHERE ' . $this->db->sql_in_set('user_id', $poster_ids) . ' - AND user_posts < ' . $num_posts; - $this->db->sql_query($sql); - - $sql = 'UPDATE ' . $this->users_table . ' - SET user_posts = user_posts - ' . $num_posts . ' - WHERE ' . $this->db->sql_in_set('user_id', $poster_ids) . ' - AND user_posts >= ' . $num_posts; - $this->db->sql_query($sql); - } - else - { - $sql = 'UPDATE ' . $this->users_table . ' - SET user_posts = user_posts + ' . $num_posts . ' - WHERE ' . $this->db->sql_in_set('user_id', $poster_ids); - $this->db->sql_query($sql); - } - } - - $update_topic_postcount = true; - - // Sync the first/last topic information if needed - if (!$is_starter && $is_latest) - { - if (!function_exists('update_post_information')) - { - include($this->phpbb_root_path . 'includes/functions_posting.' . $this->php_ext); - } - - // update_post_information can only update the last post info ... - if ($topic_id) - { - update_post_information('topic', $topic_id, false); - } - if ($forum_id) - { - update_post_information('forum', $forum_id, false); - } - } - else if ($is_starter && $topic_id) - { - if (!function_exists('sync')) - { - include($this->phpbb_root_path . 'includes/functions_admin.' . $this->php_ext); - } - - // ... so we need to use sync, if the first post is changed. - // The forum is resynced recursive by sync() itself. - sync('topic', 'topic_id', $topic_id, true); - - // sync recalculates the topic replies and forum posts by itself, so we don't do that. - $update_topic_postcount = false; - } - - $topic_update_array = array(); - // Update the topic's reply count and the forum's post count - if ($update_topic_postcount) - { - $field_alias = array( - ITEM_APPROVED => 'posts_approved', - ITEM_UNAPPROVED => 'posts_unapproved', - ITEM_DELETED => 'posts_softdeleted', - ITEM_REAPPROVE => 'posts_unapproved', - ); - $cur_posts = array_fill_keys($field_alias, 0); - - foreach ($postcount_visibility as $post_visibility => $visibility_posts) - { - $cur_posts[$field_alias[(int) $post_visibility]] += $visibility_posts; - } - - $sql_ary = array(); - $recipient_field = $field_alias[$visibility]; - - foreach ($cur_posts as $field => $count) - { - // Decrease the count for the old statuses. - if ($count && $field != $recipient_field) - { - $sql_ary[$field] = " - $count"; - } - } - // Add up the count from all statuses excluding the recipient status. - $count_increase = array_sum(array_diff($cur_posts, array($recipient_field))); - - if ($count_increase) - { - $sql_ary[$recipient_field] = " + $count_increase"; - } - - if (count($sql_ary)) - { - $forum_sql = array(); - - foreach ($sql_ary as $field => $value_change) - { - $topic_update_array[] = 'topic_' . $field . ' = topic_' . $field . $value_change; - $forum_sql[] = 'forum_' . $field . ' = forum_' . $field . $value_change; - } - - $sql = 'UPDATE ' . $this->forums_table . ' - SET ' . implode(', ', $forum_sql) . ' - WHERE forum_id = ' . (int) $forum_id; - $this->db->sql_query($sql); - } - } - - if ($post_id) - { - $sql = 'SELECT 1 AS has_attachments - FROM ' . POSTS_TABLE . ' - WHERE topic_id = ' . (int) $topic_id . ' - AND post_attachment = 1 - AND post_visibility = ' . ITEM_APPROVED . ' - AND ' . $this->db->sql_in_set('post_id', $post_id, true); - $result = $this->db->sql_query_limit($sql, 1); - - $has_attachment = (bool) $this->db->sql_fetchfield('has_attachments'); - $this->db->sql_freeresult($result); - - if ($has_attachment && $visibility == ITEM_APPROVED) - { - $topic_update_array[] = 'topic_attachment = 1'; - } - else if (!$has_attachment && $visibility != ITEM_APPROVED) - { - $topic_update_array[] = 'topic_attachment = 0'; - } - } - - if (!empty($topic_update_array)) - { - // Update the number for replies and posts, and update the attachments flag - $sql = 'UPDATE ' . $this->topics_table . ' - SET ' . implode(', ', $topic_update_array) . ' - WHERE topic_id = ' . (int) $topic_id; - $this->db->sql_query($sql); - } - /** - * Perform actions after all steps to changing post visibility - * - * @event core.set_post_visibility_after - * @var int visibility Element of {ITEM_APPROVED, ITEM_DELETED, ITEM_REAPPROVE} - * @var array post_id Array containing all post IDs to be modified. If blank, all posts within the topic are modified. - * @var int topic_id Topic of the post IDs to be modified. - * @var int forum_id Forum ID that the topic_id resides in. - * @var int user_id User ID doing this action. - * @var int time Timestamp of this action. - * @var string reason Reason specified by the user for this change. - * @var bool is_starter Are we changing the topic's starter? - * @var bool is_latest Are we changing the topic's latest post? - * @var array data The data array for this action. - * @since 3.1.10-RC1 - * @changed 3.2.2-RC1 Use time instead of non-existent timestamp - */ - $vars = array( - 'visibility', - 'post_id', - 'topic_id', - 'forum_id', - 'user_id', - 'time', - 'reason', - 'is_starter', - 'is_latest', - 'data', - ); - extract($this->phpbb_dispatcher->trigger_event('core.set_post_visibility_after', compact($vars))); - return $data; - } - - /** - * Set topic visibility - * - * Allows approving (which is akin to undeleting/restore) or soft deleting an entire topic. - * Calls set_post_visibility as needed. - * - * Note: By default, when a soft deleted topic is restored. Only posts that - * were approved at the time of soft deleting, are being restored. - * Same applies to soft deleting. Only approved posts will be marked - * as soft deleted. - * If you want to update all posts, use the force option. - * - * @param $visibility int Element of {ITEM_APPROVED, ITEM_DELETED, ITEM_REAPPROVE} - * @param $topic_id mixed Topic ID to act on - * @param $forum_id int Forum where $topic_id is found - * @param $user_id int User performing the action - * @param $time int Timestamp when the action is performed - * @param $reason string Reason why the visibilty was changed. - * @param $force_update_all bool Force to update all posts within the topic - * @return array Changed topic data, empty array if an error occured. - */ - public function set_topic_visibility($visibility, $topic_id, $forum_id, $user_id, $time, $reason, $force_update_all = false) - { - if (!in_array($visibility, array(ITEM_APPROVED, ITEM_DELETED, ITEM_REAPPROVE))) - { - return array(); - } - - if (!$force_update_all) - { - $sql = 'SELECT topic_visibility, topic_delete_time - FROM ' . $this->topics_table . ' - WHERE topic_id = ' . (int) $topic_id; - $result = $this->db->sql_query($sql); - $original_topic_data = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if (!$original_topic_data) - { - // The topic does not exist... - return array(); - } - } - - if (!function_exists('truncate_string')) - { - include($this->phpbb_root_path . 'includes/functions_content.' . $this->php_ext); - } - - // Note, we do not set a reason for the posts, just for the topic - $data = array( - 'topic_visibility' => (int) $visibility, - 'topic_delete_user' => (int) $user_id, - 'topic_delete_time' => ((int) $time) ?: time(), - 'topic_delete_reason' => truncate_string($reason, 255, 255, false), - ); - /** - * Perform actions right before the query to change topic visibility - * - * @event core.set_topic_visibility_before_sql - * @var int visibility Element of {ITEM_APPROVED, ITEM_DELETED, ITEM_REAPPROVE} - * @var int topic_id Topic of the post IDs to be modified. - * @var int forum_id Forum ID that the topic_id resides in. - * @var int user_id User ID doing this action. - * @var int time Timestamp of this action. - * @var string reason Reason specified by the user for this change. - * @var bool force_update_all Force an update on all posts within the topic, regardless of their current approval state. - * @var array data The data array for this action. - * @since 3.1.10-RC1 - * @changed 3.2.2-RC1 Use time instead of non-existent timestamp - */ - $vars = array( - 'visibility', - 'topic_id', - 'forum_id', - 'user_id', - 'time', - 'reason', - 'force_update_all', - 'data', - ); - extract($this->phpbb_dispatcher->trigger_event('core.set_topic_visibility_before_sql', compact($vars))); - $sql = 'UPDATE ' . $this->topics_table . ' - SET ' . $this->db->sql_build_array('UPDATE', $data) . ' - WHERE topic_id = ' . (int) $topic_id; - $this->db->sql_query($sql); - - if (!$this->db->sql_affectedrows()) - { - return array(); - } - - if (!$force_update_all && $original_topic_data['topic_delete_time'] && $original_topic_data['topic_visibility'] == ITEM_DELETED && $visibility == ITEM_APPROVED) - { - // If we're restoring a topic we only restore posts, that were soft deleted through the topic soft deletion. - $this->set_post_visibility($visibility, false, $topic_id, $forum_id, $user_id, $time, '', true, true, $original_topic_data['topic_visibility'], $original_topic_data['topic_delete_time']); - } - else if (!$force_update_all && $original_topic_data['topic_visibility'] == ITEM_APPROVED && $visibility == ITEM_DELETED) - { - // If we're soft deleting a topic we only mark approved posts as soft deleted. - $this->set_post_visibility($visibility, false, $topic_id, $forum_id, $user_id, $time, '', true, true, $original_topic_data['topic_visibility']); - } - else - { - $this->set_post_visibility($visibility, false, $topic_id, $forum_id, $user_id, $time, '', true, true); - } - /** - * Perform actions after all steps to changing topic visibility - * - * @event core.set_topic_visibility_after - * @var int visibility Element of {ITEM_APPROVED, ITEM_DELETED, ITEM_REAPPROVE} - * @var int topic_id Topic of the post IDs to be modified. - * @var int forum_id Forum ID that the topic_id resides in. - * @var int user_id User ID doing this action. - * @var int time Timestamp of this action. - * @var string reason Reason specified by the user for this change. - * @var bool force_update_all Force an update on all posts within the topic, regardless of their current approval state. - * @var array data The data array for this action. - * @since 3.1.10-RC1 - * @changed 3.2.2-RC1 Use time instead of non-existent timestamp - */ - $vars = array( - 'visibility', - 'topic_id', - 'forum_id', - 'user_id', - 'time', - 'reason', - 'force_update_all', - 'data', - ); - extract($this->phpbb_dispatcher->trigger_event('core.set_topic_visibility_after', compact($vars))); - return $data; - } - - /** - * Add post to topic and forum statistics - * - * @param $data array Contains information from the topics table about given topic - * @param &$sql_data array Populated with the SQL changes, may be empty at call time - * @return null - */ - public function add_post_to_statistic($data, &$sql_data) - { - $sql_data[$this->topics_table] = (($sql_data[$this->topics_table]) ? $sql_data[$this->topics_table] . ', ' : '') . 'topic_posts_approved = topic_posts_approved + 1'; - - $sql_data[$this->forums_table] = (($sql_data[$this->forums_table]) ? $sql_data[$this->forums_table] . ', ' : '') . 'forum_posts_approved = forum_posts_approved + 1'; - - if ($data['post_postcount']) - { - $sql_data[$this->users_table] = (($sql_data[$this->users_table]) ? $sql_data[$this->users_table] . ', ' : '') . 'user_posts = user_posts + 1'; - } - - $this->config->increment('num_posts', 1, false); - } - - /** - * Remove post from topic and forum statistics - * - * @param $data array Contains information from the topics table about given topic - * @param &$sql_data array Populated with the SQL changes, may be empty at call time - * @return null - */ - public function remove_post_from_statistic($data, &$sql_data) - { - if ($data['post_visibility'] == ITEM_APPROVED) - { - $sql_data[$this->topics_table] = ((!empty($sql_data[$this->topics_table])) ? $sql_data[$this->topics_table] . ', ' : '') . 'topic_posts_approved = topic_posts_approved - 1'; - $sql_data[$this->forums_table] = ((!empty($sql_data[$this->forums_table])) ? $sql_data[$this->forums_table] . ', ' : '') . 'forum_posts_approved = forum_posts_approved - 1'; - - if ($data['post_postcount']) - { - $sql_data[$this->users_table] = ((!empty($sql_data[$this->users_table])) ? $sql_data[$this->users_table] . ', ' : '') . 'user_posts = user_posts - 1'; - } - - $this->config->increment('num_posts', -1, false); - } - else if ($data['post_visibility'] == ITEM_UNAPPROVED || $data['post_visibility'] == ITEM_REAPPROVE) - { - $sql_data[FORUMS_TABLE] = (($sql_data[FORUMS_TABLE]) ? $sql_data[FORUMS_TABLE] . ', ' : '') . 'forum_posts_unapproved = forum_posts_unapproved - 1'; - $sql_data[TOPICS_TABLE] = (($sql_data[TOPICS_TABLE]) ? $sql_data[TOPICS_TABLE] . ', ' : '') . 'topic_posts_unapproved = topic_posts_unapproved - 1'; - } - else if ($data['post_visibility'] == ITEM_DELETED) - { - $sql_data[FORUMS_TABLE] = (($sql_data[FORUMS_TABLE]) ? $sql_data[FORUMS_TABLE] . ', ' : '') . 'forum_posts_softdeleted = forum_posts_softdeleted - 1'; - $sql_data[TOPICS_TABLE] = (($sql_data[TOPICS_TABLE]) ? $sql_data[TOPICS_TABLE] . ', ' : '') . 'topic_posts_softdeleted = topic_posts_softdeleted - 1'; - } - } - - /** - * Remove topic from forum statistics - * - * @param $data array Post and topic data - * @param &$sql_data array Populated with the SQL changes, may be empty at call time - * @return null - */ - public function remove_topic_from_statistic($data, &$sql_data) - { - if ($data['topic_visibility'] == ITEM_APPROVED) - { - $sql_data[FORUMS_TABLE] .= 'forum_posts_approved = forum_posts_approved - 1, forum_topics_approved = forum_topics_approved - 1'; - - if ($data['post_postcount']) - { - $sql_data[$this->users_table] = ((!empty($sql_data[$this->users_table])) ? $sql_data[$this->users_table] . ', ' : '') . 'user_posts = user_posts - 1'; - } - } - else if ($data['topic_visibility'] == ITEM_UNAPPROVED || $data['post_visibility'] == ITEM_REAPPROVE) - { - $sql_data[FORUMS_TABLE] .= 'forum_posts_unapproved = forum_posts_unapproved - 1, forum_topics_unapproved = forum_topics_unapproved - 1'; - } - else if ($data['topic_visibility'] == ITEM_DELETED) - { - $sql_data[FORUMS_TABLE] .= 'forum_posts_softdeleted = forum_posts_softdeleted - 1, forum_topics_softdeleted = forum_topics_softdeleted - 1'; - } - - } -} diff --git a/install/update/old/phpbb/controller/helper.php b/install/update/old/phpbb/controller/helper.php deleted file mode 100644 index 664b4f4..0000000 --- a/install/update/old/phpbb/controller/helper.php +++ /dev/null @@ -1,195 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\controller; - -use Symfony\Component\HttpFoundation\JsonResponse; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Routing\Generator\UrlGeneratorInterface; - -/** -* Controller helper class, contains methods that do things for controllers -*/ -class helper -{ - /** - * Template object - * @var \phpbb\template\template - */ - protected $template; - - /** - * User object - * @var \phpbb\user - */ - protected $user; - - /** - * config object - * @var \phpbb\config\config - */ - protected $config; - - /* @var \phpbb\symfony_request */ - protected $symfony_request; - - /* @var \phpbb\request\request_interface */ - protected $request; - - /** - * @var \phpbb\routing\helper - */ - protected $routing_helper; - - /** - * Constructor - * - * @param \phpbb\template\template $template Template object - * @param \phpbb\user $user User object - * @param \phpbb\config\config $config Config object - * @param \phpbb\symfony_request $symfony_request Symfony Request object - * @param \phpbb\request\request_interface $request phpBB request object - * @param \phpbb\routing\helper $routing_helper Helper to generate the routes - */ - public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, \phpbb\symfony_request $symfony_request, \phpbb\request\request_interface $request, \phpbb\routing\helper $routing_helper) - { - $this->template = $template; - $this->user = $user; - $this->config = $config; - $this->symfony_request = $symfony_request; - $this->request = $request; - $this->routing_helper = $routing_helper; - } - - /** - * Automate setting up the page and creating the response object. - * - * @param string $template_file The template handle to render - * @param string $page_title The title of the page to output - * @param int $status_code The status code to be sent to the page header - * @param bool $display_online_list Do we display online users list - * @param int $item_id Restrict online users to item id - * @param string $item Restrict online users to a certain session item, e.g. forum for session_forum_id - * @param bool $send_headers Whether headers should be sent by page_header(). Defaults to false for controllers. - * - * @return Response object containing rendered page - */ - public function render($template_file, $page_title = '', $status_code = 200, $display_online_list = false, $item_id = 0, $item = 'forum', $send_headers = false) - { - page_header($page_title, $display_online_list, $item_id, $item, $send_headers); - - $this->template->set_filenames(array( - 'body' => $template_file, - )); - - page_footer(true, false, false); - - $headers = !empty($this->user->data['is_bot']) ? array('X-PHPBB-IS-BOT' => 'yes') : array(); - - return new Response($this->template->assign_display('body'), $status_code, $headers); - } - - /** - * Generate a URL to a route - * - * @param string $route Name of the route to travel - * @param array $params String or array of additional url parameters - * @param bool $is_amp Is url using & (true) or & (false) - * @param string|bool $session_id Possibility to use a custom session id instead of the global one - * @param bool|string $reference_type The type of reference to be generated (one of the constants) - * @return string The URL already passed through append_sid() - */ - public function route($route, array $params = array(), $is_amp = true, $session_id = false, $reference_type = UrlGeneratorInterface::ABSOLUTE_PATH) - { - return $this->routing_helper->route($route, $params, $is_amp, $session_id, $reference_type); - } - - /** - * Output an error, effectively the same thing as trigger_error - * - * @param string $message The error message - * @param int $code The error code (e.g. 404, 500, 503, etc.) - * @return Response A Response instance - * - * @deprecated 3.1.3 (To be removed: 3.3.0) Use exceptions instead. - */ - public function error($message, $code = 500) - { - return $this->message($message, array(), 'INFORMATION', $code); - } - - /** - * Output a message - * - * In case of an error, please throw an exception instead - * - * @param string $message The message to display (must be a language variable) - * @param array $parameters The parameters to use with the language var - * @param string $title Title for the message (must be a language variable) - * @param int $code The HTTP status code (e.g. 404, 500, 503, etc.) - * @return Response A Response instance - */ - public function message($message, array $parameters = array(), $title = 'INFORMATION', $code = 200) - { - array_unshift($parameters, $message); - $message_text = call_user_func_array(array($this->user, 'lang'), $parameters); - $message_title = $this->user->lang($title); - - if ($this->request->is_ajax()) - { - global $refresh_data; - - return new JsonResponse( - array( - 'MESSAGE_TITLE' => $message_title, - 'MESSAGE_TEXT' => $message_text, - 'S_USER_WARNING' => false, - 'S_USER_NOTICE' => false, - 'REFRESH_DATA' => (!empty($refresh_data)) ? $refresh_data : null - ), - $code - ); - } - - $this->template->assign_vars(array( - 'MESSAGE_TEXT' => $message_text, - 'MESSAGE_TITLE' => $message_title, - )); - - return $this->render('message_body.html', $message_title, $code); - } - - /** - * Assigns automatic refresh time meta tag in template - * - * @param int $time time in seconds, when redirection should occur - * @param string $url the URL where the user should be redirected - * @return null - */ - public function assign_meta_refresh_var($time, $url) - { - $this->template->assign_vars(array( - 'META' => '', - )); - } - - /** - * Return the current url - * - * @return string - */ - public function get_current_url() - { - return generate_board_url(true) . $this->request->escape($this->symfony_request->getRequestUri(), true); - } -} diff --git a/install/update/old/phpbb/cron/manager.php b/install/update/old/phpbb/cron/manager.php deleted file mode 100644 index 9bd30a0..0000000 --- a/install/update/old/phpbb/cron/manager.php +++ /dev/null @@ -1,147 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\cron; - -/** -* Cron manager class. -* -* Finds installed cron tasks, stores task objects, provides task selection. -*/ -class manager -{ - /** - * Set of \phpbb\cron\task\wrapper objects. - * Array holding all tasks that have been found. - * - * @var array - */ - protected $tasks = array(); - - protected $phpbb_root_path; - protected $php_ext; - - /** - * Constructor. Loads all available tasks. - * - * @param array|\Traversable $tasks Provides an iterable set of task names - * @param string $phpbb_root_path Relative path to phpBB root - * @param string $php_ext PHP file extension - */ - public function __construct($tasks, $phpbb_root_path, $php_ext) - { - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - - $this->load_tasks($tasks); - } - - /** - * Loads tasks given by name, wraps them - * and puts them into $this->tasks. - * - * @param array|\Traversable $tasks Array of instances of \phpbb\cron\task\task - * - * @return null - */ - public function load_tasks($tasks) - { - foreach ($tasks as $task) - { - $this->tasks[] = $this->wrap_task($task); - } - } - - /** - * Finds a task that is ready to run. - * - * If several tasks are ready, any one of them could be returned. - * - * If no tasks are ready, null is returned. - * - * @return \phpbb\cron\task\wrapper|null - */ - public function find_one_ready_task() - { - shuffle($this->tasks); - foreach ($this->tasks as $task) - { - if ($task->is_ready()) - { - return $task; - } - } - return null; - } - - /** - * Finds all tasks that are ready to run. - * - * @return array List of tasks which are ready to run (wrapped in \phpbb\cron\task\wrapper). - */ - public function find_all_ready_tasks() - { - $tasks = array(); - foreach ($this->tasks as $task) - { - if ($task->is_ready()) - { - $tasks[] = $task; - } - } - return $tasks; - } - - /** - * Finds a task by name. - * - * If there is no task with the specified name, null is returned. - * - * Web runner uses this method to resolve names to tasks. - * - * @param string $name Name of the task to look up. - * @return \phpbb\cron\task\wrapper A wrapped task corresponding to the given name, or null. - */ - public function find_task($name) - { - foreach ($this->tasks as $task) - { - if ($task->get_name() == $name) - { - return $task; - } - } - return null; - } - - /** - * Find all tasks and return them. - * - * @return array List of all tasks. - */ - public function get_tasks() - { - return $this->tasks; - } - - /** - * Wraps a task inside an instance of \phpbb\cron\task\wrapper. - * - * @param \phpbb\cron\task\task $task The task. - * @return \phpbb\cron\task\wrapper The wrapped task. - */ - public function wrap_task(\phpbb\cron\task\task $task) - { - return new \phpbb\cron\task\wrapper($task, $this->phpbb_root_path, $this->php_ext); - } -} diff --git a/install/update/old/phpbb/cron/task/core/update_hashes.php b/install/update/old/phpbb/cron/task/core/update_hashes.php deleted file mode 100644 index ba095ab..0000000 --- a/install/update/old/phpbb/cron/task/core/update_hashes.php +++ /dev/null @@ -1,130 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\cron\task\core; - -/** - * Update old hashes to the current default hashing algorithm - * - * It is intended to gradually update all "old" style hashes to the - * current default hashing algorithm. - */ -class update_hashes extends \phpbb\cron\task\base -{ - /** @var \phpbb\config\config */ - protected $config; - - /** @var \phpbb\db\driver\driver_interface */ - protected $db; - - /** @var \phpbb\lock\db */ - protected $update_lock; - - /** @var \phpbb\passwords\manager */ - protected $passwords_manager; - - /** @var string Default hashing type */ - protected $default_type; - - /** - * Constructor. - * - * @param \phpbb\config\config $config - * @param \phpbb\db\driver\driver_interface $db - * @param \phpbb\lock\db $update_lock - * @param \phpbb\passwords\manager $passwords_manager - * @param array $hashing_algorithms Hashing driver - * service collection - * @param array $defaults Default password types - */ - public function __construct(\phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\lock\db $update_lock, \phpbb\passwords\manager $passwords_manager, $hashing_algorithms, $defaults) - { - $this->config = $config; - $this->db = $db; - $this->passwords_manager = $passwords_manager; - $this->update_lock = $update_lock; - - foreach ($defaults as $type) - { - if ($hashing_algorithms[$type]->is_supported()) - { - $this->default_type = $type; - break; - } - } - } - - /** - * {@inheritdoc} - */ - public function is_runnable() - { - return !$this->config['use_system_cron']; - } - - /** - * {@inheritdoc} - */ - public function should_run() - { - if (!empty($this->config['update_hashes_lock'])) - { - $last_run = explode(' ', $this->config['update_hashes_lock']); - if ($last_run[0] + 60 >= time()) - { - return false; - } - } - - return $this->config['enable_update_hashes'] && $this->config['update_hashes_last_cron'] < (time() - 60); - } - - /** - * {@inheritdoc} - */ - public function run() - { - if ($this->update_lock->acquire()) - { - $sql = 'SELECT user_id, user_password - FROM ' . USERS_TABLE . ' - WHERE user_password ' . $this->db->sql_like_expression('$H$' . $this->db->get_any_char()) . ' - OR user_password ' . $this->db->sql_like_expression('$CP$' . $this->db->get_any_char()); - $result = $this->db->sql_query_limit($sql, 20); - - $affected_rows = 0; - - while ($row = $this->db->sql_fetchrow($result)) - { - $new_hash = $this->passwords_manager->hash($row['user_password'], array($this->default_type)); - - // Increase number so we know that users were selected from the database - $affected_rows++; - - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_password = '" . $this->db->sql_escape($new_hash) . "' - WHERE user_id = " . (int) $row['user_id']; - $this->db->sql_query($sql); - } - - $this->config->set('update_hashes_last_cron', time()); - $this->update_lock->release(); - - // Stop cron for good once all hashes are converted - if ($affected_rows === 0) - { - $this->config->set('enable_update_hashes', '0'); - } - } - } -} diff --git a/install/update/old/phpbb/cron/task/wrapper.php b/install/update/old/phpbb/cron/task/wrapper.php deleted file mode 100644 index 8a4a8b1..0000000 --- a/install/update/old/phpbb/cron/task/wrapper.php +++ /dev/null @@ -1,106 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\cron\task; - -/** -* Cron task wrapper class. -* Enhances cron tasks with convenience methods that work identically for all tasks. -*/ -class wrapper -{ - protected $task; - protected $phpbb_root_path; - protected $php_ext; - - /** - * Constructor. - * - * Wraps a task $task, which must implement cron_task interface. - * - * @param \phpbb\cron\task\task $task The cron task to wrap. - * @param string $phpbb_root_path Relative path to phpBB root - * @param string $php_ext PHP file extension - */ - public function __construct(\phpbb\cron\task\task $task, $phpbb_root_path, $php_ext) - { - $this->task = $task; - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - } - - /** - * Returns whether the wrapped task is parametrised. - * - * Parametrized tasks accept parameters during initialization and must - * normally be scheduled with parameters. - * - * @return bool Whether or not this task is parametrized. - */ - public function is_parametrized() - { - return $this->task instanceof \phpbb\cron\task\parametrized; - } - - /** - * Returns whether the wrapped task is ready to run. - * - * A task is ready to run when it is runnable according to current configuration - * and enough time has passed since it was last run. - * - * @return bool Whether the wrapped task is ready to run. - */ - public function is_ready() - { - return $this->task->is_runnable() && $this->task->should_run(); - } - - /** - * Returns a url through which this task may be invoked via web. - * - * When system cron is not in use, running a cron task is accomplished - * by outputting an image with the url returned by this function as - * source. - * - * @return string URL through which this task may be invoked. - */ - public function get_url() - { - $name = $this->get_name(); - if ($this->is_parametrized()) - { - $params = $this->task->get_parameters(); - $extra = ''; - foreach ($params as $key => $value) - { - $extra .= '&' . $key . '=' . urlencode($value); - } - } - else - { - $extra = ''; - } - $url = append_sid($this->phpbb_root_path . 'cron.' . $this->php_ext, 'cron_type=' . $name . $extra); - return $url; - } - - /** - * Forwards all other method calls to the wrapped task implementation. - * - * @return mixed - */ - public function __call($name, $args) - { - return call_user_func_array(array($this->task, $name), $args); - } -} diff --git a/install/update/old/phpbb/db/driver/driver.php b/install/update/old/phpbb/db/driver/driver.php deleted file mode 100644 index a36ce8c..0000000 --- a/install/update/old/phpbb/db/driver/driver.php +++ /dev/null @@ -1,1220 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\db\driver; - -/** -* Database Abstraction Layer -*/ -abstract class driver implements driver_interface -{ - var $db_connect_id; - var $query_result; - var $return_on_error = false; - var $transaction = false; - var $sql_time = 0; - var $num_queries = array(); - var $open_queries = array(); - - var $curtime = 0; - var $query_hold = ''; - var $html_hold = ''; - var $sql_report = ''; - - var $persistency = false; - var $user = ''; - var $server = ''; - var $dbname = ''; - - // Set to true if error triggered - var $sql_error_triggered = false; - - // Holding the last sql query on sql error - var $sql_error_sql = ''; - // Holding the error information - only populated if sql_error_triggered is set - var $sql_error_returned = array(); - - // Holding transaction count - var $transactions = 0; - - // Supports multi inserts? - var $multi_insert = false; - - /** - * Current sql layer - */ - var $sql_layer = ''; - - /** - * Wildcards for matching any (%) or exactly one (_) character within LIKE expressions - */ - var $any_char; - var $one_char; - - /** - * Exact version of the DBAL, directly queried - */ - var $sql_server_version = false; - - const LOGICAL_OP = 0; - const STATEMENTS = 1; - const LEFT_STMT = 0; - const COMPARE_OP = 1; - const RIGHT_STMT = 2; - const SUBQUERY_OP = 3; - const SUBQUERY_SELECT_TYPE = 4; - const SUBQUERY_BUILD = 5; - - /** - * Constructor - */ - function __construct() - { - $this->num_queries = array( - 'cached' => 0, - 'normal' => 0, - 'total' => 0, - ); - - // Fill default sql layer based on the class being called. - // This can be changed by the specified layer itself later if needed. - $this->sql_layer = substr(get_class($this), strlen('phpbb\db\driver\\')); - - // Do not change this please! This variable is used to easy the use of it - and is hardcoded. - $this->any_char = chr(0) . '%'; - $this->one_char = chr(0) . '_'; - } - - /** - * {@inheritdoc} - */ - public function get_sql_layer() - { - return $this->sql_layer; - } - - /** - * {@inheritdoc} - */ - public function get_db_name() - { - return $this->dbname; - } - - /** - * {@inheritdoc} - */ - public function get_any_char() - { - return $this->any_char; - } - - /** - * {@inheritdoc} - */ - public function get_one_char() - { - return $this->one_char; - } - - /** - * {@inheritdoc} - */ - public function get_db_connect_id() - { - return $this->db_connect_id; - } - - /** - * {@inheritdoc} - */ - public function get_sql_error_triggered() - { - return $this->sql_error_triggered; - } - - /** - * {@inheritdoc} - */ - public function get_sql_error_sql() - { - return $this->sql_error_sql; - } - - /** - * {@inheritdoc} - */ - public function get_transaction() - { - return $this->transaction; - } - - /** - * {@inheritdoc} - */ - public function get_sql_time() - { - return $this->sql_time; - } - - /** - * {@inheritdoc} - */ - public function get_sql_error_returned() - { - return $this->sql_error_returned; - } - - /** - * {@inheritdoc} - */ - public function get_multi_insert() - { - return $this->multi_insert; - } - - /** - * {@inheritdoc} - */ - public function set_multi_insert($multi_insert) - { - $this->multi_insert = $multi_insert; - } - - /** - * {@inheritDoc} - */ - function sql_return_on_error($fail = false) - { - $this->sql_error_triggered = false; - $this->sql_error_sql = ''; - - $this->return_on_error = $fail; - } - - /** - * {@inheritDoc} - */ - function sql_num_queries($cached = false) - { - return ($cached) ? $this->num_queries['cached'] : $this->num_queries['normal']; - } - - /** - * {@inheritDoc} - */ - function sql_add_num_queries($cached = false) - { - $this->num_queries['cached'] += ($cached !== false) ? 1 : 0; - $this->num_queries['normal'] += ($cached !== false) ? 0 : 1; - $this->num_queries['total'] += 1; - } - - /** - * {@inheritDoc} - */ - function sql_close() - { - if (!$this->db_connect_id) - { - return false; - } - - if ($this->transaction) - { - do - { - $this->sql_transaction('commit'); - } - while ($this->transaction); - } - - foreach ($this->open_queries as $query_id) - { - $this->sql_freeresult($query_id); - } - - // Connection closed correctly. Set db_connect_id to false to prevent errors - if ($result = $this->_sql_close()) - { - $this->db_connect_id = false; - } - - return $result; - } - - /** - * {@inheritDoc} - */ - function sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0) - { - if (empty($query)) - { - return false; - } - - // Never use a negative total or offset - $total = ($total < 0) ? 0 : $total; - $offset = ($offset < 0) ? 0 : $offset; - - return $this->_sql_query_limit($query, $total, $offset, $cache_ttl); - } - - /** - * {@inheritDoc} - */ - function sql_fetchrowset($query_id = false) - { - if ($query_id === false) - { - $query_id = $this->query_result; - } - - if ($query_id) - { - $result = array(); - while ($row = $this->sql_fetchrow($query_id)) - { - $result[] = $row; - } - - return $result; - } - - return false; - } - - /** - * {@inheritDoc} - */ - function sql_rowseek($rownum, &$query_id) - { - global $cache; - - if ($query_id === false) - { - $query_id = $this->query_result; - } - - if ($cache && $cache->sql_exists($query_id)) - { - return $cache->sql_rowseek($rownum, $query_id); - } - - if (!$query_id) - { - return false; - } - - $this->sql_freeresult($query_id); - $query_id = $this->sql_query($this->last_query_text); - - if (!$query_id) - { - return false; - } - - // We do not fetch the row for rownum == 0 because then the next resultset would be the second row - for ($i = 0; $i < $rownum; $i++) - { - if (!$this->sql_fetchrow($query_id)) - { - return false; - } - } - - return true; - } - - /** - * {@inheritDoc} - */ - function sql_fetchfield($field, $rownum = false, $query_id = false) - { - global $cache; - - if ($query_id === false) - { - $query_id = $this->query_result; - } - - if ($query_id) - { - if ($rownum !== false) - { - $this->sql_rowseek($rownum, $query_id); - } - - if ($cache && !is_object($query_id) && $cache->sql_exists($query_id)) - { - return $cache->sql_fetchfield($query_id, $field); - } - - $row = $this->sql_fetchrow($query_id); - return (isset($row[$field])) ? $row[$field] : false; - } - - return false; - } - - /** - * {@inheritDoc} - */ - function sql_like_expression($expression) - { - $expression = str_replace(array('_', '%'), array("\_", "\%"), $expression); - $expression = str_replace(array(chr(0) . "\_", chr(0) . "\%"), array('_', '%'), $expression); - - return $this->_sql_like_expression('LIKE \'' . $this->sql_escape($expression) . '\''); - } - - /** - * {@inheritDoc} - */ - function sql_not_like_expression($expression) - { - $expression = str_replace(array('_', '%'), array("\_", "\%"), $expression); - $expression = str_replace(array(chr(0) . "\_", chr(0) . "\%"), array('_', '%'), $expression); - - return $this->_sql_not_like_expression('NOT LIKE \'' . $this->sql_escape($expression) . '\''); - } - - /** - * {@inheritDoc} - */ - public function sql_case($condition, $action_true, $action_false = false) - { - $sql_case = 'CASE WHEN ' . $condition; - $sql_case .= ' THEN ' . $action_true; - $sql_case .= ($action_false !== false) ? ' ELSE ' . $action_false : ''; - $sql_case .= ' END'; - return $sql_case; - } - - /** - * {@inheritDoc} - */ - public function sql_concatenate($expr1, $expr2) - { - return $expr1 . ' || ' . $expr2; - } - - /** - * {@inheritDoc} - */ - function sql_buffer_nested_transactions() - { - return false; - } - - /** - * {@inheritDoc} - */ - function sql_transaction($status = 'begin') - { - switch ($status) - { - case 'begin': - // If we are within a transaction we will not open another one, but enclose the current one to not loose data (preventing auto commit) - if ($this->transaction) - { - $this->transactions++; - return true; - } - - $result = $this->_sql_transaction('begin'); - - if (!$result) - { - $this->sql_error(); - } - - $this->transaction = true; - break; - - case 'commit': - // If there was a previously opened transaction we do not commit yet... - // but count back the number of inner transactions - if ($this->transaction && $this->transactions) - { - $this->transactions--; - return true; - } - - // Check if there is a transaction (no transaction can happen if - // there was an error, with a combined rollback and error returning enabled) - // This implies we have transaction always set for autocommit db's - if (!$this->transaction) - { - return false; - } - - $result = $this->_sql_transaction('commit'); - - if (!$result) - { - $this->sql_error(); - } - - $this->transaction = false; - $this->transactions = 0; - break; - - case 'rollback': - $result = $this->_sql_transaction('rollback'); - $this->transaction = false; - $this->transactions = 0; - break; - - default: - $result = $this->_sql_transaction($status); - break; - } - - return $result; - } - - /** - * {@inheritDoc} - */ - function sql_build_array($query, $assoc_ary = false) - { - if (!is_array($assoc_ary)) - { - return false; - } - - $fields = $values = array(); - - if ($query == 'INSERT' || $query == 'INSERT_SELECT') - { - foreach ($assoc_ary as $key => $var) - { - $fields[] = $key; - - if (is_array($var) && is_string($var[0])) - { - // This is used for INSERT_SELECT(s) - $values[] = $var[0]; - } - else - { - $values[] = $this->_sql_validate_value($var); - } - } - - $query = ($query == 'INSERT') ? ' (' . implode(', ', $fields) . ') VALUES (' . implode(', ', $values) . ')' : ' (' . implode(', ', $fields) . ') SELECT ' . implode(', ', $values) . ' '; - } - else if ($query == 'MULTI_INSERT') - { - trigger_error('The MULTI_INSERT query value is no longer supported. Please use sql_multi_insert() instead.', E_USER_ERROR); - } - else if ($query == 'UPDATE' || $query == 'SELECT' || $query == 'DELETE') - { - $values = array(); - foreach ($assoc_ary as $key => $var) - { - $values[] = "$key = " . $this->_sql_validate_value($var); - } - $query = implode(($query == 'UPDATE') ? ', ' : ' AND ', $values); - } - - return $query; - } - - /** - * {@inheritDoc} - */ - function sql_in_set($field, $array, $negate = false, $allow_empty_set = false) - { - $array = (array) $array; - - if (!count($array)) - { - if (!$allow_empty_set) - { - // Print the backtrace to help identifying the location of the problematic code - $this->sql_error('No values specified for SQL IN comparison'); - } - else - { - // NOT IN () actually means everything so use a tautology - if ($negate) - { - return '1=1'; - } - // IN () actually means nothing so use a contradiction - else - { - return '1=0'; - } - } - } - - if (count($array) == 1) - { - @reset($array); - $var = current($array); - - return $field . ($negate ? ' <> ' : ' = ') . $this->_sql_validate_value($var); - } - else - { - return $field . ($negate ? ' NOT IN ' : ' IN ') . '(' . implode(', ', array_map(array($this, '_sql_validate_value'), $array)) . ')'; - } - } - - /** - * {@inheritDoc} - */ - function sql_bit_and($column_name, $bit, $compare = '') - { - if (method_exists($this, '_sql_bit_and')) - { - return $this->_sql_bit_and($column_name, $bit, $compare); - } - - return $column_name . ' & ' . (1 << $bit) . (($compare) ? ' ' . $compare : ''); - } - - /** - * {@inheritDoc} - */ - function sql_bit_or($column_name, $bit, $compare = '') - { - if (method_exists($this, '_sql_bit_or')) - { - return $this->_sql_bit_or($column_name, $bit, $compare); - } - - return $column_name . ' | ' . (1 << $bit) . (($compare) ? ' ' . $compare : ''); - } - - /** - * {@inheritDoc} - */ - function cast_expr_to_bigint($expression) - { - return $expression; - } - - /** - * {@inheritDoc} - */ - function cast_expr_to_string($expression) - { - return $expression; - } - - /** - * {@inheritDoc} - */ - function sql_lower_text($column_name) - { - return "LOWER($column_name)"; - } - - /** - * {@inheritDoc} - */ - function sql_multi_insert($table, $sql_ary) - { - if (!count($sql_ary)) - { - return false; - } - - if ($this->multi_insert) - { - $ary = array(); - foreach ($sql_ary as $id => $_sql_ary) - { - // If by accident the sql array is only one-dimensional we build a normal insert statement - if (!is_array($_sql_ary)) - { - return $this->sql_query('INSERT INTO ' . $table . ' ' . $this->sql_build_array('INSERT', $sql_ary)); - } - - $values = array(); - foreach ($_sql_ary as $key => $var) - { - $values[] = $this->_sql_validate_value($var); - } - $ary[] = '(' . implode(', ', $values) . ')'; - } - - return $this->sql_query('INSERT INTO ' . $table . ' ' . ' (' . implode(', ', array_keys($sql_ary[0])) . ') VALUES ' . implode(', ', $ary)); - } - else - { - foreach ($sql_ary as $ary) - { - if (!is_array($ary)) - { - return false; - } - - $result = $this->sql_query('INSERT INTO ' . $table . ' ' . $this->sql_build_array('INSERT', $ary)); - - if (!$result) - { - return false; - } - } - } - - return true; - } - - /** - * Function for validating values - * @access private - */ - function _sql_validate_value($var) - { - if (is_null($var)) - { - return 'NULL'; - } - else if (is_string($var)) - { - return "'" . $this->sql_escape($var) . "'"; - } - else - { - return (is_bool($var)) ? intval($var) : $var; - } - } - - /** - * {@inheritDoc} - */ - function sql_build_query($query, $array) - { - $sql = ''; - switch ($query) - { - case 'SELECT': - case 'SELECT_DISTINCT'; - - $sql = str_replace('_', ' ', $query) . ' ' . $array['SELECT'] . ' FROM '; - - // Build table array. We also build an alias array for later checks. - $table_array = $aliases = array(); - $used_multi_alias = false; - - foreach ($array['FROM'] as $table_name => $alias) - { - if (is_array($alias)) - { - $used_multi_alias = true; - - foreach ($alias as $multi_alias) - { - $table_array[] = $table_name . ' ' . $multi_alias; - $aliases[] = $multi_alias; - } - } - else - { - $table_array[] = $table_name . ' ' . $alias; - $aliases[] = $alias; - } - } - - // We run the following code to determine if we need to re-order the table array. ;) - // The reason for this is that for multi-aliased tables (two equal tables) in the FROM statement the last table need to match the first comparison. - // DBMS who rely on this: Oracle, PostgreSQL and MSSQL. For all other DBMS it makes absolutely no difference in which order the table is. - if (!empty($array['LEFT_JOIN']) && count($array['FROM']) > 1 && $used_multi_alias !== false) - { - // Take first LEFT JOIN - $join = current($array['LEFT_JOIN']); - - // Determine the table used there (even if there are more than one used, we only want to have one - preg_match('/(' . implode('|', $aliases) . ')\.[^\s]+/U', str_replace(array('(', ')', 'AND', 'OR', ' '), '', $join['ON']), $matches); - - // If there is a first join match, we need to make sure the table order is correct - if (!empty($matches[1])) - { - $first_join_match = trim($matches[1]); - $table_array = $last = array(); - - foreach ($array['FROM'] as $table_name => $alias) - { - if (is_array($alias)) - { - foreach ($alias as $multi_alias) - { - ($multi_alias === $first_join_match) ? $last[] = $table_name . ' ' . $multi_alias : $table_array[] = $table_name . ' ' . $multi_alias; - } - } - else - { - ($alias === $first_join_match) ? $last[] = $table_name . ' ' . $alias : $table_array[] = $table_name . ' ' . $alias; - } - } - - $table_array = array_merge($table_array, $last); - } - } - - $sql .= $this->_sql_custom_build('FROM', implode(' CROSS JOIN ', $table_array)); - - if (!empty($array['LEFT_JOIN'])) - { - foreach ($array['LEFT_JOIN'] as $join) - { - $sql .= ' LEFT JOIN ' . key($join['FROM']) . ' ' . current($join['FROM']) . ' ON (' . $join['ON'] . ')'; - } - } - - if (!empty($array['WHERE'])) - { - $sql .= ' WHERE '; - - if (is_array($array['WHERE'])) - { - $sql_where = $this->_process_boolean_tree_first($array['WHERE']); - } - else - { - $sql_where = $array['WHERE']; - } - - $sql .= $this->_sql_custom_build('WHERE', $sql_where); - } - - if (!empty($array['GROUP_BY'])) - { - $sql .= ' GROUP BY ' . $array['GROUP_BY']; - } - - if (!empty($array['ORDER_BY'])) - { - $sql .= ' ORDER BY ' . $array['ORDER_BY']; - } - - break; - } - - return $sql; - } - - - protected function _process_boolean_tree_first($operations_ary) - { - // In cases where an array exists but there is no head condition, - // it should be because there's only 1 WHERE clause. This seems the best way to deal with it. - if ($operations_ary[self::LOGICAL_OP] !== 'AND' && - $operations_ary[self::LOGICAL_OP] !== 'OR') - { - $operations_ary = array('AND', array($operations_ary)); - } - return $this->_process_boolean_tree($operations_ary) . "\n"; - } - - protected function _process_boolean_tree($operations_ary) - { - $operation = $operations_ary[self::LOGICAL_OP]; - - foreach ($operations_ary[self::STATEMENTS] as &$condition) - { - switch ($condition[self::LOGICAL_OP]) - { - case 'AND': - case 'OR': - - $condition = ' ( ' . $this->_process_boolean_tree($condition) . ') '; - - break; - case 'NOT': - - $condition = ' NOT (' . $this->_process_boolean_tree($condition) . ') '; - - break; - - default: - - switch (count($condition)) - { - case 3: - - // Typical 3 element clause with {left hand} {operator} {right hand} - switch ($condition[self::COMPARE_OP]) - { - case 'IN': - case 'NOT_IN': - - // As this is used with an IN, assume it is a set of elements for sql_in_set() - $condition = $this->sql_in_set($condition[self::LEFT_STMT], $condition[self::RIGHT_STMT], $condition[self::COMPARE_OP] === 'NOT_IN', true); - - break; - - case 'LIKE': - - $condition = $condition[self::LEFT_STMT] . ' ' . $this->sql_like_expression($condition[self::RIGHT_STMT]) . ' '; - - break; - - case 'NOT_LIKE': - - $condition = $condition[self::LEFT_STMT] . ' ' . $this->sql_not_like_expression($condition[self::RIGHT_STMT]) . ' '; - - break; - - case 'IS_NOT': - - $condition[self::COMPARE_OP] = 'IS NOT'; - - // no break - case 'IS': - - // If the value is NULL, the string of it is the empty string ('') which is not the intended result. - // this should solve that - if ($condition[self::RIGHT_STMT] === null) - { - $condition[self::RIGHT_STMT] = 'NULL'; - } - - $condition = implode(' ', $condition); - - break; - - default: - - $condition = implode(' ', $condition); - - break; - } - - break; - - case 5: - - // Subquery with {left hand} {operator} {compare kind} {SELECT Kind } {Sub Query} - - $result = $condition[self::LEFT_STMT] . ' ' . $condition[self::COMPARE_OP] . ' ' . $condition[self::SUBQUERY_OP] . ' ( '; - $result .= $this->sql_build_query($condition[self::SUBQUERY_SELECT_TYPE], $condition[self::SUBQUERY_BUILD]); - $result .= ' )'; - $condition = $result; - - break; - - default: - // This is an unpredicted clause setup. Just join all elements. - $condition = implode(' ', $condition); - - break; - } - - break; - } - - } - - if ($operation === 'NOT') - { - $operations_ary = implode("", $operations_ary[self::STATEMENTS]); - } - else - { - $operations_ary = implode(" \n $operation ", $operations_ary[self::STATEMENTS]); - } - - return $operations_ary; - } - - - /** - * {@inheritDoc} - */ - function sql_error($sql = '') - { - global $auth, $user, $config; - - // Set var to retrieve errored status - $this->sql_error_triggered = true; - $this->sql_error_sql = $sql; - - $this->sql_error_returned = $this->_sql_error(); - - if (!$this->return_on_error) - { - $message = 'SQL ERROR [ ' . $this->sql_layer . ' ]

' . $this->sql_error_returned['message'] . ' [' . $this->sql_error_returned['code'] . ']'; - - // Show complete SQL error and path to administrators only - // Additionally show complete error on installation or if extended debug mode is enabled - // The DEBUG constant is for development only! - if ((isset($auth) && $auth->acl_get('a_')) || defined('IN_INSTALL') || defined('DEBUG')) - { - $message .= ($sql) ? '

SQL

' . htmlspecialchars($sql) : ''; - } - else - { - // If error occurs in initiating the session we need to use a pre-defined language string - // This could happen if the connection could not be established for example (then we are not able to grab the default language) - if (!isset($user->lang['SQL_ERROR_OCCURRED'])) - { - $message .= '

An sql error occurred while fetching this page. Please contact an administrator if this problem persists.'; - } - else - { - if (!empty($config['board_contact'])) - { - $message .= '

' . sprintf($user->lang['SQL_ERROR_OCCURRED'], '', ''); - } - else - { - $message .= '

' . sprintf($user->lang['SQL_ERROR_OCCURRED'], '', ''); - } - } - } - - if ($this->transaction) - { - $this->sql_transaction('rollback'); - } - - if (strlen($message) > 1024) - { - // We need to define $msg_long_text here to circumvent text stripping. - global $msg_long_text; - $msg_long_text = $message; - - trigger_error(false, E_USER_ERROR); - } - - trigger_error($message, E_USER_ERROR); - } - - if ($this->transaction) - { - $this->sql_transaction('rollback'); - } - - return $this->sql_error_returned; - } - - /** - * {@inheritDoc} - */ - function sql_report($mode, $query = '') - { - global $cache, $starttime, $phpbb_root_path, $phpbb_path_helper; - global $request; - - if (is_object($request) && !$request->variable('explain', false)) - { - return false; - } - - if (!$query && $this->query_hold != '') - { - $query = $this->query_hold; - } - - switch ($mode) - { - case 'display': - if (!empty($cache)) - { - $cache->unload(); - } - $this->sql_close(); - - $mtime = explode(' ', microtime()); - $totaltime = $mtime[0] + $mtime[1] - $starttime; - - echo ' - - - - - SQL Report - - - -
- -
-
-
- -
-

SQL Report

-
-

Page generated in ' . round($totaltime, 4) . " seconds with {$this->num_queries['normal']} queries" . (($this->num_queries['cached']) ? " + {$this->num_queries['cached']} " . (($this->num_queries['cached'] == 1) ? 'query' : 'queries') . ' returning data from cache' : '') . '

- -

Time spent on ' . $this->sql_layer . ' queries: ' . round($this->sql_time, 5) . 's | Time spent on PHP: ' . round($totaltime - $this->sql_time, 5) . 's

- -

- ' . $this->sql_report . ' -
- -
-
-
- -
- - '; - - exit_handler(); - - break; - - case 'stop': - $endtime = explode(' ', microtime()); - $endtime = $endtime[0] + $endtime[1]; - - $this->sql_report .= ' - - - - - - - - - - - - -
Query #' . $this->num_queries['total'] . '
- - ' . $this->html_hold . ' - -

- '; - - if ($this->query_result) - { - if (preg_match('/^(UPDATE|DELETE|REPLACE)/', $query)) - { - $this->sql_report .= 'Affected rows: ' . $this->sql_affectedrows() . ' | '; - } - $this->sql_report .= 'Before: ' . sprintf('%.5f', $this->curtime - $starttime) . 's | After: ' . sprintf('%.5f', $endtime - $starttime) . 's | Elapsed: ' . sprintf('%.5f', $endtime - $this->curtime) . 's'; - } - else - { - $error = $this->sql_error(); - $this->sql_report .= 'FAILED - ' . $this->sql_layer . ' Error ' . $error['code'] . ': ' . htmlspecialchars($error['message']); - } - - $this->sql_report .= '



'; - - $this->sql_time += $endtime - $this->curtime; - break; - - case 'start': - $this->query_hold = $query; - $this->html_hold = ''; - - $this->_sql_report($mode, $query); - - $this->curtime = explode(' ', microtime()); - $this->curtime = $this->curtime[0] + $this->curtime[1]; - - break; - - case 'add_select_row': - - $html_table = func_get_arg(2); - $row = func_get_arg(3); - - if (!$html_table && count($row)) - { - $html_table = true; - $this->html_hold .= ''; - - foreach (array_keys($row) as $val) - { - $this->html_hold .= ''; - } - $this->html_hold .= ''; - } - $this->html_hold .= ''; - - $class = 'row1'; - foreach (array_values($row) as $val) - { - $class = ($class == 'row1') ? 'row2' : 'row1'; - $this->html_hold .= ''; - } - $this->html_hold .= ''; - - return $html_table; - - break; - - case 'fromcache': - - $this->_sql_report($mode, $query); - - break; - - case 'record_fromcache': - - $endtime = func_get_arg(2); - $splittime = func_get_arg(3); - - $time_cache = $endtime - $this->curtime; - $time_db = $splittime - $endtime; - $color = ($time_db > $time_cache) ? 'green' : 'red'; - - $this->sql_report .= '
' . (($val) ? ucwords(str_replace('_', ' ', $val)) : ' ') . '
' . (($val) ? $val : ' ') . '
'; - $this->sql_report .= '
Query results obtained from the cache
'; - $this->sql_report .= '

'; - $this->sql_report .= 'Before: ' . sprintf('%.5f', $this->curtime - $starttime) . 's | After: ' . sprintf('%.5f', $endtime - $starttime) . 's | Elapsed [cache]: ' . sprintf('%.5f', ($time_cache)) . 's | Elapsed [db]: ' . sprintf('%.5f', $time_db) . 's



'; - - // Pad the start time to not interfere with page timing - $starttime += $time_db; - - break; - - default: - - $this->_sql_report($mode, $query); - - break; - } - - return true; - } - - /** - * {@inheritDoc} - */ - function get_estimated_row_count($table_name) - { - return $this->get_row_count($table_name); - } - - /** - * {@inheritDoc} - */ - function get_row_count($table_name) - { - $sql = 'SELECT COUNT(*) AS rows_total - FROM ' . $this->sql_escape($table_name); - $result = $this->sql_query($sql); - $rows_total = $this->sql_fetchfield('rows_total'); - $this->sql_freeresult($result); - - return $rows_total; - } -} diff --git a/install/update/old/phpbb/db/driver/driver_interface.php b/install/update/old/phpbb/db/driver/driver_interface.php deleted file mode 100644 index 8b487c5..0000000 --- a/install/update/old/phpbb/db/driver/driver_interface.php +++ /dev/null @@ -1,453 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\db\driver; - -interface driver_interface -{ - /** - * Gets the name of the sql layer. - * - * @return string - */ - public function get_sql_layer(); - - /** - * Gets the name of the database. - * - * @return string - */ - public function get_db_name(); - - /** - * Wildcards for matching any (%) character within LIKE expressions - * - * @return string - */ - public function get_any_char(); - - /** - * Wildcards for matching exactly one (_) character within LIKE expressions - * - * @return string - */ - public function get_one_char(); - - /** - * Gets the time spent into the queries - * - * @return int - */ - public function get_sql_time(); - - /** - * Gets the connect ID. - * - * @return mixed - */ - public function get_db_connect_id(); - - /** - * Indicates if an error was triggered. - * - * @return bool - */ - public function get_sql_error_triggered(); - - /** - * Gets the last faulty query - * - * @return string - */ - public function get_sql_error_sql(); - - /** - * Indicates if we are in a transaction. - * - * @return bool - */ - public function get_transaction(); - - /** - * Gets the returned error. - * - * @return array - */ - public function get_sql_error_returned(); - - /** - * Indicates if multiple insertion can be used - * - * @return bool - */ - public function get_multi_insert(); - - /** - * Set if multiple insertion can be used - * - * @param bool $multi_insert - */ - public function set_multi_insert($multi_insert); - - /** - * Gets the exact number of rows in a specified table. - * - * @param string $table_name Table name - * @return string Exact number of rows in $table_name. - */ - public function get_row_count($table_name); - - /** - * Gets the estimated number of rows in a specified table. - * - * @param string $table_name Table name - * @return string Number of rows in $table_name. - * Prefixed with ~ if estimated (otherwise exact). - */ - public function get_estimated_row_count($table_name); - - /** - * Run LOWER() on DB column of type text (i.e. neither varchar nor char). - * - * @param string $column_name The column name to use - * @return string A SQL statement like "LOWER($column_name)" - */ - public function sql_lower_text($column_name); - - /** - * Display sql error page - * - * @param string $sql The SQL query causing the error - * @return mixed Returns the full error message, if $this->return_on_error - * is set, null otherwise - */ - public function sql_error($sql = ''); - - /** - * Returns whether results of a query need to be buffered to run a - * transaction while iterating over them. - * - * @return bool Whether buffering is required. - */ - public function sql_buffer_nested_transactions(); - - /** - * Run binary OR operator on DB column. - * - * @param string $column_name The column name to use - * @param int $bit The value to use for the OR operator, - * will be converted to (1 << $bit). Is used by options, - * using the number schema... 0, 1, 2...29 - * @param string $compare Any custom SQL code after the check (e.g. "= 0") - * @return string A SQL statement like "$column | (1 << $bit) {$compare}" - */ - public function sql_bit_or($column_name, $bit, $compare = ''); - - /** - * Version information about used database - * - * @param bool $raw Only return the fetched sql_server_version - * @param bool $use_cache Is it safe to retrieve the value from the cache - * @return string sql server version - */ - public function sql_server_info($raw = false, $use_cache = true); - - /** - * Return on error or display error message - * - * @param bool $fail Should we return on errors, or stop - * @return null - */ - public function sql_return_on_error($fail = false); - - /** - * Build sql statement from an array - * - * @param string $query Should be on of the following strings: - * INSERT, INSERT_SELECT, UPDATE, SELECT, DELETE - * @param array $assoc_ary Array with "column => value" pairs - * @return string A SQL statement like "c1 = 'a' AND c2 = 'b'" - */ - public function sql_build_array($query, $assoc_ary = array()); - - /** - * Fetch all rows - * - * @param mixed $query_id Already executed query to get the rows from, - * if false, the last query will be used. - * @return mixed Nested array if the query had rows, false otherwise - */ - public function sql_fetchrowset($query_id = false); - - /** - * SQL Transaction - * - * @param string $status Should be one of the following strings: - * begin, commit, rollback - * @return mixed Buffered, seekable result handle, false on error - */ - public function sql_transaction($status = 'begin'); - - /** - * Build a concatenated expression - * - * @param string $expr1 Base SQL expression where we append the second one - * @param string $expr2 SQL expression that is appended to the first expression - * @return string Concatenated string - */ - public function sql_concatenate($expr1, $expr2); - - /** - * Build a case expression - * - * Note: The two statements action_true and action_false must have the same - * data type (int, vchar, ...) in the database! - * - * @param string $condition The condition which must be true, - * to use action_true rather then action_else - * @param string $action_true SQL expression that is used, if the condition is true - * @param mixed $action_false SQL expression that is used, if the condition is false - * @return string CASE expression including the condition and statements - */ - public function sql_case($condition, $action_true, $action_false = false); - - /** - * Build sql statement from array for select and select distinct statements - * - * Possible query values: SELECT, SELECT_DISTINCT - * - * @param string $query Should be one of: SELECT, SELECT_DISTINCT - * @param array $array Array with the query data: - * SELECT A comma imploded list of columns to select - * FROM Array with "table => alias" pairs, - * (alias can also be an array) - * Optional: LEFT_JOIN Array of join entries: - * FROM Table that should be joined - * ON Condition for the join - * Optional: WHERE Where SQL statement - * Optional: GROUP_BY Group by SQL statement - * Optional: ORDER_BY Order by SQL statement - * @return string A SQL statement ready for execution - */ - public function sql_build_query($query, $array); - - /** - * Fetch field - * if rownum is false, the current row is used, else it is pointing to the row (zero-based) - * - * @param string $field Name of the column - * @param mixed $rownum Row number, if false the current row will be used - * and the row curser will point to the next row - * Note: $rownum is 0 based - * @param mixed $query_id Already executed query to get the rows from, - * if false, the last query will be used. - * @return mixed String value of the field in the selected row, - * false, if the row does not exist - */ - public function sql_fetchfield($field, $rownum = false, $query_id = false); - - /** - * Fetch current row - * - * @param mixed $query_id Already executed query to get the rows from, - * if false, the last query will be used. - * @return mixed Array with the current row, - * false, if the row does not exist - */ - public function sql_fetchrow($query_id = false); - - /** - * Returns SQL string to cast a string expression to an int. - * - * @param string $expression An expression evaluating to string - * @return string Expression returning an int - */ - public function cast_expr_to_bigint($expression); - - /** - * Get last inserted id after insert statement - * - * @return string Autoincrement value of the last inserted row - */ - public function sql_nextid(); - - /** - * Add to query count - * - * @param bool $cached Is this query cached? - * @return null - */ - public function sql_add_num_queries($cached = false); - - /** - * Build LIMIT query - * - * @param string $query The SQL query to execute - * @param int $total The number of rows to select - * @param int $offset - * @param int $cache_ttl Either 0 to avoid caching or - * the time in seconds which the result shall be kept in cache - * @return mixed Buffered, seekable result handle, false on error - */ - public function sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0); - - /** - * Base query method - * - * @param string $query The SQL query to execute - * @param int $cache_ttl Either 0 to avoid caching or - * the time in seconds which the result shall be kept in cache - * @return mixed Buffered, seekable result handle, false on error - */ - public function sql_query($query = '', $cache_ttl = 0); - - /** - * Returns SQL string to cast an integer expression to a string. - * - * @param string $expression An expression evaluating to int - * @return string Expression returning a string - */ - public function cast_expr_to_string($expression); - - /** - * Connect to server - * - * @param string $sqlserver Address of the database server - * @param string $sqluser User name of the SQL user - * @param string $sqlpassword Password of the SQL user - * @param string $database Name of the database - * @param mixed $port Port of the database server - * @param bool $persistency - * @param bool $new_link Should a new connection be established - * @return mixed Connection ID on success, string error message otherwise - */ - public function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false); - - /** - * Run binary AND operator on DB column. - * Results in sql statement: "{$column_name} & (1 << {$bit}) {$compare}" - * - * @param string $column_name The column name to use - * @param int $bit The value to use for the AND operator, - * will be converted to (1 << $bit). Is used by - * options, using the number schema: 0, 1, 2...29 - * @param string $compare Any custom SQL code after the check (for example "= 0") - * @return string A SQL statement like: "{$column} & (1 << {$bit}) {$compare}" - */ - public function sql_bit_and($column_name, $bit, $compare = ''); - - /** - * Free sql result - * - * @param mixed $query_id Already executed query result, - * if false, the last query will be used. - * @return null - */ - public function sql_freeresult($query_id = false); - - /** - * Return number of sql queries and cached sql queries used - * - * @param bool $cached Should we return the number of cached or normal queries? - * @return int Number of queries that have been executed - */ - public function sql_num_queries($cached = false); - - /** - * Run more than one insert statement. - * - * @param string $table Table name to run the statements on - * @param array $sql_ary Multi-dimensional array holding the statement data - * @return bool false if no statements were executed. - */ - public function sql_multi_insert($table, $sql_ary); - - /** - * Return number of affected rows - * - * @return mixed Number of the affected rows by the last query - * false if no query has been run before - */ - public function sql_affectedrows(); - - /** - * DBAL garbage collection, close SQL connection - * - * @return mixed False if no connection was opened before, - * Server response otherwise - */ - public function sql_close(); - - /** - * Seek to given row number - * - * @param mixed $rownum Row number the curser should point to - * Note: $rownum is 0 based - * @param mixed $query_id ID of the query to set the row cursor on - * if false, the last query will be used. - * $query_id will then be set correctly - * @return bool False if something went wrong - */ - public function sql_rowseek($rownum, &$query_id); - - /** - * Escape string used in sql query - * - * @param string $msg String to be escaped - * @return string Escaped version of $msg - */ - public function sql_escape($msg); - - /** - * Correctly adjust LIKE expression for special characters - * Some DBMS are handling them in a different way - * - * @param string $expression The expression to use. Every wildcard is - * escaped, except $this->any_char and $this->one_char - * @return string A SQL statement like: "LIKE 'bertie_%'" - */ - public function sql_like_expression($expression); - - /** - * Correctly adjust NOT LIKE expression for special characters - * Some DBMS are handling them in a different way - * - * @param string $expression The expression to use. Every wildcard is - * escaped, except $this->any_char and $this->one_char - * @return string A SQL statement like: "NOT LIKE 'bertie_%'" - */ - public function sql_not_like_expression($expression); - - /** - * Explain queries - * - * @param string $mode Available modes: display, start, stop, - * add_select_row, fromcache, record_fromcache - * @param string $query The Query that should be explained - * @return mixed Either a full HTML page, boolean or null - */ - public function sql_report($mode, $query = ''); - - /** - * Build IN or NOT IN sql comparison string, uses <> or = on single element - * arrays to improve comparison speed - * - * @param string $field Name of the sql column that shall be compared - * @param array $array Array of values that are (not) allowed - * @param bool $negate true for NOT IN (), false for IN () - * @param bool $allow_empty_set If true, allow $array to be empty, - * this function will return 1=1 or 1=0 then. - * @return string A SQL statement like: "IN (1, 2, 3, 4)" or "= 1" - */ - public function sql_in_set($field, $array, $negate = false, $allow_empty_set = false); -} diff --git a/install/update/old/phpbb/db/driver/factory.php b/install/update/old/phpbb/db/driver/factory.php deleted file mode 100644 index fb3a826..0000000 --- a/install/update/old/phpbb/db/driver/factory.php +++ /dev/null @@ -1,443 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\db\driver; - -use \Symfony\Component\DependencyInjection\ContainerInterface; - -/** -* Database Abstraction Layer -*/ -class factory implements driver_interface -{ - /** - * @var driver_interface - */ - protected $driver = null; - - /** - * @var ContainerInterface - */ - protected $container; - - /** - * Constructor. - * - * @param ContainerInterface $container A ContainerInterface instance - */ - public function __construct(ContainerInterface $container) - { - $this->container = $container; - } - - /** - * Return the current driver (and retrieved it from the container if necessary) - * - * @return driver_interface - */ - protected function get_driver() - { - if ($this->driver === null) - { - $this->driver = $this->container->get('dbal.conn.driver'); - } - - return $this->driver; - } - - /** - * Set the current driver - * - * @param driver_interface $driver - */ - public function set_driver(driver_interface $driver) - { - $this->driver = $driver; - } - - /** - * {@inheritdoc} - */ - public function get_sql_layer() - { - return $this->get_driver()->get_sql_layer(); - } - - /** - * {@inheritdoc} - */ - public function get_db_name() - { - return $this->get_driver()->get_db_name(); - } - - /** - * {@inheritdoc} - */ - public function get_any_char() - { - return $this->get_driver()->get_any_char(); - } - - /** - * {@inheritdoc} - */ - public function get_one_char() - { - return $this->get_driver()->get_one_char(); - } - - /** - * {@inheritdoc} - */ - public function get_db_connect_id() - { - return $this->get_driver()->get_db_connect_id(); - } - - /** - * {@inheritdoc} - */ - public function get_sql_error_triggered() - { - return $this->get_driver()->get_sql_error_triggered(); - } - - /** - * {@inheritdoc} - */ - public function get_sql_error_sql() - { - return $this->get_driver()->get_sql_error_sql(); - } - - /** - * {@inheritdoc} - */ - public function get_transaction() - { - return $this->get_driver()->get_transaction(); - } - - /** - * {@inheritdoc} - */ - public function get_sql_time() - { - return $this->get_driver()->get_sql_time(); - } - - /** - * {@inheritdoc} - */ - public function get_sql_error_returned() - { - return $this->get_driver()->get_sql_error_returned(); - } - - /** - * {@inheritdoc} - */ - public function get_multi_insert() - { - return $this->get_driver()->get_multi_insert(); - } - - /** - * {@inheritdoc} - */ - public function set_multi_insert($multi_insert) - { - $this->get_driver()->set_multi_insert($multi_insert); - } - - /** - * {@inheritdoc} - */ - public function get_row_count($table_name) - { - return $this->get_driver()->get_row_count($table_name); - } - - /** - * {@inheritdoc} - */ - public function get_estimated_row_count($table_name) - { - return $this->get_driver()->get_estimated_row_count($table_name); - } - - /** - * {@inheritdoc} - */ - public function sql_lower_text($column_name) - { - return $this->get_driver()->sql_lower_text($column_name); - } - - /** - * {@inheritdoc} - */ - public function sql_error($sql = '') - { - return $this->get_driver()->sql_error($sql); - } - - /** - * {@inheritdoc} - */ - public function sql_buffer_nested_transactions() - { - return $this->get_driver()->sql_buffer_nested_transactions(); - } - - /** - * {@inheritdoc} - */ - public function sql_bit_or($column_name, $bit, $compare = '') - { - return $this->get_driver()->sql_bit_or($column_name, $bit, $compare); - } - - /** - * {@inheritdoc} - */ - public function sql_server_info($raw = false, $use_cache = true) - { - return $this->get_driver()->sql_server_info($raw, $use_cache); - } - - /** - * {@inheritdoc} - */ - public function sql_return_on_error($fail = false) - { - return $this->get_driver()->sql_return_on_error($fail); - } - - /** - * {@inheritdoc} - */ - public function sql_build_array($query, $assoc_ary = array()) - { - return $this->get_driver()->sql_build_array($query, $assoc_ary); - } - - /** - * {@inheritdoc} - */ - public function sql_fetchrowset($query_id = false) - { - return $this->get_driver()->sql_fetchrowset($query_id); - } - - /** - * {@inheritdoc} - */ - public function sql_transaction($status = 'begin') - { - return $this->get_driver()->sql_transaction($status); - } - - /** - * {@inheritdoc} - */ - public function sql_concatenate($expr1, $expr2) - { - return $this->get_driver()->sql_concatenate($expr1, $expr2); - } - - /** - * {@inheritdoc} - */ - public function sql_case($condition, $action_true, $action_false = false) - { - return $this->get_driver()->sql_case($condition, $action_true, $action_false); - } - - /** - * {@inheritdoc} - */ - public function sql_build_query($query, $array) - { - return $this->get_driver()->sql_build_query($query, $array); - } - - /** - * {@inheritdoc} - */ - public function sql_fetchfield($field, $rownum = false, $query_id = false) - { - return $this->get_driver()->sql_fetchfield($field, $rownum, $query_id); - } - - /** - * {@inheritdoc} - */ - public function sql_fetchrow($query_id = false) - { - return $this->get_driver()->sql_fetchrow($query_id); - } - - /** - * {@inheritdoc} - */ - public function cast_expr_to_bigint($expression) - { - return $this->get_driver()->cast_expr_to_bigint($expression); - } - - /** - * {@inheritdoc} - */ - public function sql_nextid() - { - return $this->get_driver()->sql_nextid(); - } - - /** - * {@inheritdoc} - */ - public function sql_add_num_queries($cached = false) - { - return $this->get_driver()->sql_add_num_queries($cached); - } - - /** - * {@inheritdoc} - */ - public function sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0) - { - return $this->get_driver()->sql_query_limit($query, $total, $offset, $cache_ttl); - } - - /** - * {@inheritdoc} - */ - public function sql_query($query = '', $cache_ttl = 0) - { - return $this->get_driver()->sql_query($query, $cache_ttl); - } - - /** - * {@inheritdoc} - */ - public function cast_expr_to_string($expression) - { - return $this->get_driver()->cast_expr_to_string($expression); - } - - /** - * {@inheritdoc} - */ - public function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false) - { - throw new \Exception('Disabled method.'); - } - - /** - * {@inheritdoc} - */ - public function sql_bit_and($column_name, $bit, $compare = '') - { - return $this->get_driver()->sql_bit_and($column_name, $bit, $compare); - } - - /** - * {@inheritdoc} - */ - public function sql_freeresult($query_id = false) - { - return $this->get_driver()->sql_freeresult($query_id); - } - - /** - * {@inheritdoc} - */ - public function sql_num_queries($cached = false) - { - return $this->get_driver()->sql_num_queries($cached); - } - - /** - * {@inheritdoc} - */ - public function sql_multi_insert($table, $sql_ary) - { - return $this->get_driver()->sql_multi_insert($table, $sql_ary); - } - - /** - * {@inheritdoc} - */ - public function sql_affectedrows() - { - return $this->get_driver()->sql_affectedrows(); - } - - /** - * {@inheritdoc} - */ - public function sql_close() - { - return $this->get_driver()->sql_close(); - } - - /** - * {@inheritdoc} - */ - public function sql_rowseek($rownum, &$query_id) - { - return $this->get_driver()->sql_rowseek($rownum, $query_id); - } - - /** - * {@inheritdoc} - */ - public function sql_escape($msg) - { - return $this->get_driver()->sql_escape($msg); - } - - /** - * {@inheritdoc} - */ - public function sql_like_expression($expression) - { - return $this->get_driver()->sql_like_expression($expression); - } - - /** - * {@inheritdoc} - */ - public function sql_not_like_expression($expression) - { - return $this->get_driver()->sql_not_like_expression($expression); - } - - /** - * {@inheritdoc} - */ - public function sql_report($mode, $query = '') - { - return $this->get_driver()->sql_report($mode, $query); - } - - /** - * {@inheritdoc} - */ - public function sql_in_set($field, $array, $negate = false, $allow_empty_set = false) - { - return $this->get_driver()->sql_in_set($field, $array, $negate, $allow_empty_set); - } -} diff --git a/install/update/old/phpbb/db/driver/mssql_odbc.php b/install/update/old/phpbb/db/driver/mssql_odbc.php deleted file mode 100644 index 9d9ad60..0000000 --- a/install/update/old/phpbb/db/driver/mssql_odbc.php +++ /dev/null @@ -1,385 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\db\driver; - -/** -* Unified ODBC functions -* Unified ODBC functions support any database having ODBC driver, for example Adabas D, IBM DB2, iODBC, Solid, Sybase SQL Anywhere... -* Here we only support MSSQL Server 2000+ because of the provided schema -* -* @note number of bytes returned for returning data depends on odbc.defaultlrl php.ini setting. -* If it is limited to 4K for example only 4K of data is returned max, resulting in incomplete theme data for example. -* @note odbc.defaultbinmode may affect UTF8 characters -*/ -class mssql_odbc extends \phpbb\db\driver\mssql_base -{ - var $last_query_text = ''; - var $connect_error = ''; - - /** - * {@inheritDoc} - */ - function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false) - { - $this->persistency = $persistency; - $this->user = $sqluser; - $this->dbname = $database; - - $port_delimiter = (defined('PHP_OS') && substr(PHP_OS, 0, 3) === 'WIN') ? ',' : ':'; - $this->server = $sqlserver . (($port) ? $port_delimiter . $port : ''); - - $max_size = @ini_get('odbc.defaultlrl'); - if (!empty($max_size)) - { - $unit = strtolower(substr($max_size, -1, 1)); - $max_size = (int) $max_size; - - if ($unit == 'k') - { - $max_size = floor($max_size / 1024); - } - else if ($unit == 'g') - { - $max_size *= 1024; - } - else if (is_numeric($unit)) - { - $max_size = floor((int) ($max_size . $unit) / 1048576); - } - $max_size = max(8, $max_size) . 'M'; - - @ini_set('odbc.defaultlrl', $max_size); - } - - if ($this->persistency) - { - if (!function_exists('odbc_pconnect')) - { - $this->connect_error = 'odbc_pconnect function does not exist, is odbc extension installed?'; - return $this->sql_error(''); - } - $this->db_connect_id = @odbc_pconnect($this->server, $this->user, $sqlpassword); - } - else - { - if (!function_exists('odbc_connect')) - { - $this->connect_error = 'odbc_connect function does not exist, is odbc extension installed?'; - return $this->sql_error(''); - } - $this->db_connect_id = @odbc_connect($this->server, $this->user, $sqlpassword); - } - - return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error(''); - } - - /** - * {@inheritDoc} - */ - function sql_server_info($raw = false, $use_cache = true) - { - global $cache; - - if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('mssqlodbc_version')) === false) - { - $result_id = @odbc_exec($this->db_connect_id, "SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY('productlevel'), SERVERPROPERTY('edition')"); - - $row = false; - if ($result_id) - { - $row = odbc_fetch_array($result_id); - odbc_free_result($result_id); - } - - $this->sql_server_version = ($row) ? trim(implode(' ', $row)) : 0; - - if (!empty($cache) && $use_cache) - { - $cache->put('mssqlodbc_version', $this->sql_server_version); - } - } - - if ($raw) - { - return $this->sql_server_version; - } - - return ($this->sql_server_version) ? 'MSSQL (ODBC)
' . $this->sql_server_version : 'MSSQL (ODBC)'; - } - - /** - * SQL Transaction - * @access private - */ - function _sql_transaction($status = 'begin') - { - switch ($status) - { - case 'begin': - return @odbc_exec($this->db_connect_id, 'BEGIN TRANSACTION'); - break; - - case 'commit': - return @odbc_exec($this->db_connect_id, 'COMMIT TRANSACTION'); - break; - - case 'rollback': - return @odbc_exec($this->db_connect_id, 'ROLLBACK TRANSACTION'); - break; - } - - return true; - } - - /** - * {@inheritDoc} - */ - function sql_query($query = '', $cache_ttl = 0) - { - if ($query != '') - { - global $cache; - - // EXPLAIN only in extra debug mode - if (defined('DEBUG')) - { - $this->sql_report('start', $query); - } - else if (defined('PHPBB_DISPLAY_LOAD_TIME')) - { - $this->curtime = microtime(true); - } - - $this->last_query_text = $query; - $this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false; - $this->sql_add_num_queries($this->query_result); - - if ($this->query_result === false) - { - if (($this->query_result = @odbc_exec($this->db_connect_id, $query)) === false) - { - $this->sql_error($query); - } - - if (defined('DEBUG')) - { - $this->sql_report('stop', $query); - } - else if (defined('PHPBB_DISPLAY_LOAD_TIME')) - { - $this->sql_time += microtime(true) - $this->curtime; - } - - if (!$this->query_result) - { - return false; - } - - if ($cache && $cache_ttl) - { - $this->open_queries[(int) $this->query_result] = $this->query_result; - $this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl); - } - else if (strpos($query, 'SELECT') === 0) - { - $this->open_queries[(int) $this->query_result] = $this->query_result; - } - } - else if (defined('DEBUG')) - { - $this->sql_report('fromcache', $query); - } - } - else - { - return false; - } - - return $this->query_result; - } - - /** - * Build LIMIT query - */ - function _sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0) - { - $this->query_result = false; - - // Since TOP is only returning a set number of rows we won't need it if total is set to 0 (return all rows) - if ($total) - { - // We need to grab the total number of rows + the offset number of rows to get the correct result - if (strpos($query, 'SELECT DISTINCT') === 0) - { - $query = 'SELECT DISTINCT TOP ' . ($total + $offset) . ' ' . substr($query, 15); - } - else - { - $query = 'SELECT TOP ' . ($total + $offset) . ' ' . substr($query, 6); - } - } - - $result = $this->sql_query($query, $cache_ttl); - - // Seek by $offset rows - if ($offset) - { - $this->sql_rowseek($offset, $result); - } - - return $result; - } - - /** - * {@inheritDoc} - */ - function sql_affectedrows() - { - return ($this->db_connect_id) ? @odbc_num_rows($this->query_result) : false; - } - - /** - * {@inheritDoc} - */ - function sql_fetchrow($query_id = false) - { - global $cache; - - if ($query_id === false) - { - $query_id = $this->query_result; - } - - if ($cache && $cache->sql_exists($query_id)) - { - return $cache->sql_fetchrow($query_id); - } - - return ($query_id) ? odbc_fetch_array($query_id) : false; - } - - /** - * {@inheritDoc} - */ - function sql_nextid() - { - $result_id = @odbc_exec($this->db_connect_id, 'SELECT @@IDENTITY'); - - if ($result_id) - { - if (odbc_fetch_array($result_id)) - { - $id = odbc_result($result_id, 1); - odbc_free_result($result_id); - return $id; - } - odbc_free_result($result_id); - } - - return false; - } - - /** - * {@inheritDoc} - */ - function sql_freeresult($query_id = false) - { - global $cache; - - if ($query_id === false) - { - $query_id = $this->query_result; - } - - if ($cache && !is_object($query_id) && $cache->sql_exists($query_id)) - { - return $cache->sql_freeresult($query_id); - } - - if (isset($this->open_queries[(int) $query_id])) - { - unset($this->open_queries[(int) $query_id]); - return odbc_free_result($query_id); - } - - return false; - } - - /** - * return sql error array - * @access private - */ - function _sql_error() - { - if (function_exists('odbc_errormsg')) - { - $error = array( - 'message' => @odbc_errormsg(), - 'code' => @odbc_error(), - ); - } - else - { - $error = array( - 'message' => $this->connect_error, - 'code' => '', - ); - } - - return $error; - } - - /** - * Close sql connection - * @access private - */ - function _sql_close() - { - return @odbc_close($this->db_connect_id); - } - - /** - * Build db-specific report - * @access private - */ - function _sql_report($mode, $query = '') - { - switch ($mode) - { - case 'start': - break; - - case 'fromcache': - $endtime = explode(' ', microtime()); - $endtime = $endtime[0] + $endtime[1]; - - $result = @odbc_exec($this->db_connect_id, $query); - if ($result) - { - while ($void = odbc_fetch_array($result)) - { - // Take the time spent on parsing rows into account - } - odbc_free_result($result); - } - - $splittime = explode(' ', microtime()); - $splittime = $splittime[0] + $splittime[1]; - - $this->sql_report('record_fromcache', $query, $endtime, $splittime); - - break; - } - } -} diff --git a/install/update/old/phpbb/db/driver/mssqlnative.php b/install/update/old/phpbb/db/driver/mssqlnative.php deleted file mode 100644 index a4dcac5..0000000 --- a/install/update/old/phpbb/db/driver/mssqlnative.php +++ /dev/null @@ -1,451 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* This is the MS SQL Server Native database abstraction layer. -* PHP mssql native driver required. -* @author Chris Pucci -* -*/ - -namespace phpbb\db\driver; - -class mssqlnative extends \phpbb\db\driver\mssql_base -{ - var $m_insert_id = null; - var $last_query_text = ''; - var $query_options = array(); - var $connect_error = ''; - - /** - * {@inheritDoc} - */ - function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false) - { - // Test for driver support, to avoid suppressed fatal error - if (!function_exists('sqlsrv_connect')) - { - $this->connect_error = 'Native MS SQL Server driver for PHP is missing or needs to be updated. Version 1.1 or later is required to install phpBB3. You can download the driver from: http://www.microsoft.com/sqlserver/2005/en/us/PHP-Driver.aspx'; - return $this->sql_error(''); - } - - //set up connection variables - $this->persistency = $persistency; - $this->user = $sqluser; - $this->dbname = $database; - $port_delimiter = (defined('PHP_OS') && substr(PHP_OS, 0, 3) === 'WIN') ? ',' : ':'; - $this->server = $sqlserver . (($port) ? $port_delimiter . $port : ''); - - //connect to database - $this->db_connect_id = sqlsrv_connect($this->server, array( - 'Database' => $this->dbname, - 'UID' => $this->user, - 'PWD' => $sqlpassword, - 'CharacterSet' => 'UTF-8' - )); - - return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error(''); - } - - /** - * {@inheritDoc} - */ - function sql_server_info($raw = false, $use_cache = true) - { - global $cache; - - if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('mssql_version')) === false) - { - $arr_server_info = sqlsrv_server_info($this->db_connect_id); - $this->sql_server_version = $arr_server_info['SQLServerVersion']; - - if (!empty($cache) && $use_cache) - { - $cache->put('mssql_version', $this->sql_server_version); - } - } - - if ($raw) - { - return $this->sql_server_version; - } - - return ($this->sql_server_version) ? 'MSSQL
' . $this->sql_server_version : 'MSSQL'; - } - - /** - * {@inheritDoc} - */ - function sql_buffer_nested_transactions() - { - return true; - } - - /** - * SQL Transaction - * @access private - */ - function _sql_transaction($status = 'begin') - { - switch ($status) - { - case 'begin': - return sqlsrv_begin_transaction($this->db_connect_id); - break; - - case 'commit': - return sqlsrv_commit($this->db_connect_id); - break; - - case 'rollback': - return sqlsrv_rollback($this->db_connect_id); - break; - } - return true; - } - - /** - * {@inheritDoc} - */ - function sql_query($query = '', $cache_ttl = 0) - { - if ($query != '') - { - global $cache; - - // EXPLAIN only in extra debug mode - if (defined('DEBUG')) - { - $this->sql_report('start', $query); - } - else if (defined('PHPBB_DISPLAY_LOAD_TIME')) - { - $this->curtime = microtime(true); - } - - $this->last_query_text = $query; - $this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false; - $this->sql_add_num_queries($this->query_result); - - if ($this->query_result === false) - { - if (($this->query_result = @sqlsrv_query($this->db_connect_id, $query, array(), $this->query_options)) === false) - { - $this->sql_error($query); - } - // reset options for next query - $this->query_options = array(); - - if (defined('DEBUG')) - { - $this->sql_report('stop', $query); - } - else if (defined('PHPBB_DISPLAY_LOAD_TIME')) - { - $this->sql_time += microtime(true) - $this->curtime; - } - - if (!$this->query_result) - { - return false; - } - - if ($cache && $cache_ttl) - { - $this->open_queries[(int) $this->query_result] = $this->query_result; - $this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl); - } - else if (strpos($query, 'SELECT') === 0) - { - $this->open_queries[(int) $this->query_result] = $this->query_result; - } - } - else if (defined('DEBUG')) - { - $this->sql_report('fromcache', $query); - } - } - else - { - return false; - } - return $this->query_result; - } - - /** - * Build LIMIT query - */ - function _sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0) - { - $this->query_result = false; - - // total == 0 means all results - not zero results - if ($offset == 0 && $total !== 0) - { - if (strpos($query, "SELECT") === false) - { - $query = "TOP {$total} " . $query; - } - else - { - $query = preg_replace('/SELECT(\s*DISTINCT)?/Dsi', 'SELECT$1 TOP '.$total, $query); - } - } - else if ($offset > 0) - { - $query = preg_replace('/SELECT(\s*DISTINCT)?/Dsi', 'SELECT$1 TOP(10000000) ', $query); - $query = 'SELECT * - FROM (SELECT sub2.*, ROW_NUMBER() OVER(ORDER BY sub2.line2) AS line3 - FROM (SELECT 1 AS line2, sub1.* FROM (' . $query . ') AS sub1) as sub2) AS sub3'; - - if ($total > 0) - { - $query .= ' WHERE line3 BETWEEN ' . ($offset+1) . ' AND ' . ($offset + $total); - } - else - { - $query .= ' WHERE line3 > ' . $offset; - } - } - - $result = $this->sql_query($query, $cache_ttl); - - return $result; - } - - /** - * {@inheritDoc} - */ - function sql_affectedrows() - { - return ($this->db_connect_id) ? @sqlsrv_rows_affected($this->query_result) : false; - } - - /** - * {@inheritDoc} - */ - function sql_fetchrow($query_id = false) - { - global $cache; - - if ($query_id === false) - { - $query_id = $this->query_result; - } - - if ($cache && $cache->sql_exists($query_id)) - { - return $cache->sql_fetchrow($query_id); - } - - if (!$query_id) - { - return false; - } - - $row = sqlsrv_fetch_array($query_id, SQLSRV_FETCH_ASSOC); - - if ($row) - { - foreach ($row as $key => $value) - { - $row[$key] = ($value === ' ' || $value === null) ? '' : $value; - } - - // remove helper values from LIMIT queries - if (isset($row['line2'])) - { - unset($row['line2'], $row['line3']); - } - } - return ($row !== null) ? $row : false; - } - - /** - * {@inheritDoc} - */ - function sql_nextid() - { - $result_id = @sqlsrv_query($this->db_connect_id, 'SELECT @@IDENTITY'); - - if ($result_id) - { - $row = sqlsrv_fetch_array($result_id); - $id = $row[0]; - sqlsrv_free_stmt($result_id); - return $id; - } - else - { - return false; - } - } - - /** - * {@inheritDoc} - */ - function sql_freeresult($query_id = false) - { - global $cache; - - if ($query_id === false) - { - $query_id = $this->query_result; - } - - if ($cache && !is_object($query_id) && $cache->sql_exists($query_id)) - { - return $cache->sql_freeresult($query_id); - } - - if (isset($this->open_queries[(int) $query_id])) - { - unset($this->open_queries[(int) $query_id]); - return sqlsrv_free_stmt($query_id); - } - - return false; - } - - /** - * return sql error array - * @access private - */ - function _sql_error() - { - if (function_exists('sqlsrv_errors')) - { - $errors = @sqlsrv_errors(SQLSRV_ERR_ERRORS); - $error_message = ''; - $code = 0; - - if ($errors != null) - { - foreach ($errors as $error) - { - $error_message .= "SQLSTATE: " . $error['SQLSTATE'] . "\n"; - $error_message .= "code: " . $error['code'] . "\n"; - $code = $error['code']; - $error_message .= "message: " . $error['message'] . "\n"; - } - $this->last_error_result = $error_message; - $error = $this->last_error_result; - } - else - { - $error = (isset($this->last_error_result) && $this->last_error_result) ? $this->last_error_result : array(); - } - - $error = array( - 'message' => $error, - 'code' => $code, - ); - } - else - { - $error = array( - 'message' => $this->connect_error, - 'code' => '', - ); - } - - return $error; - } - - /** - * Close sql connection - * @access private - */ - function _sql_close() - { - return @sqlsrv_close($this->db_connect_id); - } - - /** - * Build db-specific report - * @access private - */ - function _sql_report($mode, $query = '') - { - switch ($mode) - { - case 'start': - $html_table = false; - @sqlsrv_query($this->db_connect_id, 'SET SHOWPLAN_TEXT ON;'); - if ($result = @sqlsrv_query($this->db_connect_id, $query)) - { - sqlsrv_next_result($result); - while ($row = sqlsrv_fetch_array($result)) - { - $html_table = $this->sql_report('add_select_row', $query, $html_table, $row); - } - sqlsrv_free_stmt($result); - } - @sqlsrv_query($this->db_connect_id, 'SET SHOWPLAN_TEXT OFF;'); - - if ($html_table) - { - $this->html_hold .= ''; - } - break; - - case 'fromcache': - $endtime = explode(' ', microtime()); - $endtime = $endtime[0] + $endtime[1]; - - $result = @sqlsrv_query($this->db_connect_id, $query); - if ($result) - { - while ($void = sqlsrv_fetch_array($result)) - { - // Take the time spent on parsing rows into account - } - sqlsrv_free_stmt($result); - } - - $splittime = explode(' ', microtime()); - $splittime = $splittime[0] + $splittime[1]; - - $this->sql_report('record_fromcache', $query, $endtime, $splittime); - - break; - } - } - - /** - * Utility method used to retrieve number of rows - * Emulates mysql_num_rows - * Used in acp_database.php -> write_data_mssqlnative() - * Requires a static or keyset cursor to be definde via - * mssqlnative_set_query_options() - */ - function mssqlnative_num_rows($res) - { - if ($res !== false) - { - return sqlsrv_num_rows($res); - } - else - { - return false; - } - } - - /** - * Allows setting mssqlnative specific query options passed to sqlsrv_query as 4th parameter. - */ - function mssqlnative_set_query_options($options) - { - $this->query_options = $options; - } -} diff --git a/install/update/old/phpbb/db/driver/mysqli.php b/install/update/old/phpbb/db/driver/mysqli.php deleted file mode 100644 index d43e201..0000000 --- a/install/update/old/phpbb/db/driver/mysqli.php +++ /dev/null @@ -1,490 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\db\driver; - -/** -* MySQLi Database Abstraction Layer -* mysqli-extension has to be compiled with: -* MySQL 4.1+ or MySQL 5.0+ -*/ -class mysqli extends \phpbb\db\driver\mysql_base -{ - var $multi_insert = true; - var $connect_error = ''; - - /** - * {@inheritDoc} - */ - function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false) - { - if (!function_exists('mysqli_connect')) - { - $this->connect_error = 'mysqli_connect function does not exist, is mysqli extension installed?'; - return $this->sql_error(''); - } - - $this->persistency = $persistency; - $this->user = $sqluser; - - // If persistent connection, set dbhost to localhost when empty and prepend it with 'p:' prefix - $this->server = ($this->persistency) ? 'p:' . (($sqlserver) ? $sqlserver : 'localhost') : $sqlserver; - - $this->dbname = $database; - $port = (!$port) ? null : $port; - - // If port is set and it is not numeric, most likely mysqli socket is set. - // Try to map it to the $socket parameter. - $socket = null; - if ($port) - { - if (is_numeric($port)) - { - $port = (int) $port; - } - else - { - $socket = $port; - $port = null; - } - } - - $this->db_connect_id = mysqli_init(); - - if (!@mysqli_real_connect($this->db_connect_id, $this->server, $this->user, $sqlpassword, $this->dbname, $port, $socket, MYSQLI_CLIENT_FOUND_ROWS)) - { - $this->db_connect_id = ''; - } - - if ($this->db_connect_id && $this->dbname != '') - { - @mysqli_query($this->db_connect_id, "SET NAMES 'utf8'"); - - // enforce strict mode on databases that support it - if (version_compare($this->sql_server_info(true), '5.0.2', '>=')) - { - $result = @mysqli_query($this->db_connect_id, 'SELECT @@session.sql_mode AS sql_mode'); - if ($result) - { - $row = mysqli_fetch_assoc($result); - mysqli_free_result($result); - - $modes = array_map('trim', explode(',', $row['sql_mode'])); - } - else - { - $modes = array(); - } - - // TRADITIONAL includes STRICT_ALL_TABLES and STRICT_TRANS_TABLES - if (!in_array('TRADITIONAL', $modes)) - { - if (!in_array('STRICT_ALL_TABLES', $modes)) - { - $modes[] = 'STRICT_ALL_TABLES'; - } - - if (!in_array('STRICT_TRANS_TABLES', $modes)) - { - $modes[] = 'STRICT_TRANS_TABLES'; - } - } - - $mode = implode(',', $modes); - @mysqli_query($this->db_connect_id, "SET SESSION sql_mode='{$mode}'"); - } - return $this->db_connect_id; - } - - return $this->sql_error(''); - } - - /** - * {@inheritDoc} - */ - function sql_server_info($raw = false, $use_cache = true) - { - global $cache; - - if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('mysqli_version')) === false) - { - $result = @mysqli_query($this->db_connect_id, 'SELECT VERSION() AS version'); - if ($result) - { - $row = mysqli_fetch_assoc($result); - mysqli_free_result($result); - - $this->sql_server_version = $row['version']; - - if (!empty($cache) && $use_cache) - { - $cache->put('mysqli_version', $this->sql_server_version); - } - } - } - - return ($raw) ? $this->sql_server_version : 'MySQL(i) ' . $this->sql_server_version; - } - - /** - * SQL Transaction - * @access private - */ - function _sql_transaction($status = 'begin') - { - switch ($status) - { - case 'begin': - return @mysqli_autocommit($this->db_connect_id, false); - break; - - case 'commit': - $result = @mysqli_commit($this->db_connect_id); - @mysqli_autocommit($this->db_connect_id, true); - return $result; - break; - - case 'rollback': - $result = @mysqli_rollback($this->db_connect_id); - @mysqli_autocommit($this->db_connect_id, true); - return $result; - break; - } - - return true; - } - - /** - * {@inheritDoc} - */ - function sql_query($query = '', $cache_ttl = 0) - { - if ($query != '') - { - global $cache; - - // EXPLAIN only in extra debug mode - if (defined('DEBUG')) - { - $this->sql_report('start', $query); - } - else if (defined('PHPBB_DISPLAY_LOAD_TIME')) - { - $this->curtime = microtime(true); - } - - $this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false; - $this->sql_add_num_queries($this->query_result); - - if ($this->query_result === false) - { - if (($this->query_result = @mysqli_query($this->db_connect_id, $query)) === false) - { - $this->sql_error($query); - } - - if (defined('DEBUG')) - { - $this->sql_report('stop', $query); - } - else if (defined('PHPBB_DISPLAY_LOAD_TIME')) - { - $this->sql_time += microtime(true) - $this->curtime; - } - - if (!$this->query_result) - { - return false; - } - - if ($cache && $cache_ttl) - { - $this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl); - } - } - else if (defined('DEBUG')) - { - $this->sql_report('fromcache', $query); - } - } - else - { - return false; - } - - return $this->query_result; - } - - /** - * {@inheritDoc} - */ - function sql_affectedrows() - { - return ($this->db_connect_id) ? @mysqli_affected_rows($this->db_connect_id) : false; - } - - /** - * {@inheritDoc} - */ - function sql_fetchrow($query_id = false) - { - global $cache; - - if ($query_id === false) - { - $query_id = $this->query_result; - } - - if ($cache && !is_object($query_id) && $cache->sql_exists($query_id)) - { - return $cache->sql_fetchrow($query_id); - } - - if ($query_id) - { - $result = mysqli_fetch_assoc($query_id); - return $result !== null ? $result : false; - } - - return false; - } - - /** - * {@inheritDoc} - */ - function sql_rowseek($rownum, &$query_id) - { - global $cache; - - if ($query_id === false) - { - $query_id = $this->query_result; - } - - if ($cache && !is_object($query_id) && $cache->sql_exists($query_id)) - { - return $cache->sql_rowseek($rownum, $query_id); - } - - return ($query_id) ? @mysqli_data_seek($query_id, $rownum) : false; - } - - /** - * {@inheritDoc} - */ - function sql_nextid() - { - return ($this->db_connect_id) ? @mysqli_insert_id($this->db_connect_id) : false; - } - - /** - * {@inheritDoc} - */ - function sql_freeresult($query_id = false) - { - global $cache; - - if ($query_id === false) - { - $query_id = $this->query_result; - } - - if ($cache && !is_object($query_id) && $cache->sql_exists($query_id)) - { - return $cache->sql_freeresult($query_id); - } - - if (!$query_id) - { - return false; - } - - if ($query_id === true) - { - return true; - } - - return mysqli_free_result($query_id); - } - - /** - * {@inheritDoc} - */ - function sql_escape($msg) - { - return @mysqli_real_escape_string($this->db_connect_id, $msg); - } - - /** - * return sql error array - * @access private - */ - function _sql_error() - { - if ($this->db_connect_id) - { - $error = array( - 'message' => @mysqli_error($this->db_connect_id), - 'code' => @mysqli_errno($this->db_connect_id) - ); - } - else if (function_exists('mysqli_connect_error')) - { - $error = array( - 'message' => @mysqli_connect_error(), - 'code' => @mysqli_connect_errno(), - ); - } - else - { - $error = array( - 'message' => $this->connect_error, - 'code' => '', - ); - } - - return $error; - } - - /** - * Close sql connection - * @access private - */ - function _sql_close() - { - return @mysqli_close($this->db_connect_id); - } - - /** - * Build db-specific report - * @access private - */ - function _sql_report($mode, $query = '') - { - static $test_prof; - - // current detection method, might just switch to see the existance of INFORMATION_SCHEMA.PROFILING - if ($test_prof === null) - { - $test_prof = false; - if (strpos(mysqli_get_server_info($this->db_connect_id), 'community') !== false) - { - $ver = mysqli_get_server_version($this->db_connect_id); - if ($ver >= 50037 && $ver < 50100) - { - $test_prof = true; - } - } - } - - switch ($mode) - { - case 'start': - - $explain_query = $query; - if (preg_match('/UPDATE ([a-z0-9_]+).*?WHERE(.*)/s', $query, $m)) - { - $explain_query = 'SELECT * FROM ' . $m[1] . ' WHERE ' . $m[2]; - } - else if (preg_match('/DELETE FROM ([a-z0-9_]+).*?WHERE(.*)/s', $query, $m)) - { - $explain_query = 'SELECT * FROM ' . $m[1] . ' WHERE ' . $m[2]; - } - - if (preg_match('/^SELECT/', $explain_query)) - { - $html_table = false; - - // begin profiling - if ($test_prof) - { - @mysqli_query($this->db_connect_id, 'SET profiling = 1;'); - } - - if ($result = @mysqli_query($this->db_connect_id, "EXPLAIN $explain_query")) - { - while ($row = mysqli_fetch_assoc($result)) - { - $html_table = $this->sql_report('add_select_row', $query, $html_table, $row); - } - mysqli_free_result($result); - } - - if ($html_table) - { - $this->html_hold .= ''; - } - - if ($test_prof) - { - $html_table = false; - - // get the last profile - if ($result = @mysqli_query($this->db_connect_id, 'SHOW PROFILE ALL;')) - { - $this->html_hold .= '
'; - while ($row = mysqli_fetch_assoc($result)) - { - // make HTML safe - if (!empty($row['Source_function'])) - { - $row['Source_function'] = str_replace(array('<', '>'), array('<', '>'), $row['Source_function']); - } - - // remove unsupported features - foreach ($row as $key => $val) - { - if ($val === null) - { - unset($row[$key]); - } - } - $html_table = $this->sql_report('add_select_row', $query, $html_table, $row); - } - mysqli_free_result($result); - } - - if ($html_table) - { - $this->html_hold .= ''; - } - - @mysqli_query($this->db_connect_id, 'SET profiling = 0;'); - } - } - - break; - - case 'fromcache': - $endtime = explode(' ', microtime()); - $endtime = $endtime[0] + $endtime[1]; - - $result = @mysqli_query($this->db_connect_id, $query); - if ($result) - { - while ($void = mysqli_fetch_assoc($result)) - { - // Take the time spent on parsing rows into account - } - mysqli_free_result($result); - } - - $splittime = explode(' ', microtime()); - $splittime = $splittime[0] + $splittime[1]; - - $this->sql_report('record_fromcache', $query, $endtime, $splittime); - - break; - } - } -} diff --git a/install/update/old/phpbb/db/driver/oracle.php b/install/update/old/phpbb/db/driver/oracle.php deleted file mode 100644 index 5fd1470..0000000 --- a/install/update/old/phpbb/db/driver/oracle.php +++ /dev/null @@ -1,822 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\db\driver; - -/** -* Oracle Database Abstraction Layer -*/ -class oracle extends \phpbb\db\driver\driver -{ - var $last_query_text = ''; - var $connect_error = ''; - - /** - * {@inheritDoc} - */ - function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false) - { - $this->persistency = $persistency; - $this->user = $sqluser; - $this->server = $sqlserver . (($port) ? ':' . $port : ''); - $this->dbname = $database; - - $connect = $database; - - // support for "easy connect naming" - if ($sqlserver !== '' && $sqlserver !== '/') - { - if (substr($sqlserver, -1, 1) == '/') - { - $sqlserver == substr($sqlserver, 0, -1); - } - $connect = $sqlserver . (($port) ? ':' . $port : '') . '/' . $database; - } - - if ($new_link) - { - if (!function_exists('ocinlogon')) - { - $this->connect_error = 'ocinlogon function does not exist, is oci extension installed?'; - return $this->sql_error(''); - } - $this->db_connect_id = @ocinlogon($this->user, $sqlpassword, $connect, 'UTF8'); - } - else if ($this->persistency) - { - if (!function_exists('ociplogon')) - { - $this->connect_error = 'ociplogon function does not exist, is oci extension installed?'; - return $this->sql_error(''); - } - $this->db_connect_id = @ociplogon($this->user, $sqlpassword, $connect, 'UTF8'); - } - else - { - if (!function_exists('ocilogon')) - { - $this->connect_error = 'ocilogon function does not exist, is oci extension installed?'; - return $this->sql_error(''); - } - $this->db_connect_id = @ocilogon($this->user, $sqlpassword, $connect, 'UTF8'); - } - - return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error(''); - } - - /** - * {@inheritDoc} - */ - function sql_server_info($raw = false, $use_cache = true) - { - /** - * force $use_cache false. I didn't research why the caching code below is commented out - * but I assume its because the Oracle extension provides a direct method to access it - * without a query. - */ -/* - global $cache; - - if (empty($cache) || ($this->sql_server_version = $cache->get('oracle_version')) === false) - { - $result = @ociparse($this->db_connect_id, 'SELECT * FROM v$version WHERE banner LIKE \'Oracle%\''); - @ociexecute($result, OCI_DEFAULT); - @ocicommit($this->db_connect_id); - - $row = array(); - @ocifetchinto($result, $row, OCI_ASSOC + OCI_RETURN_NULLS); - @ocifreestatement($result); - $this->sql_server_version = trim($row['BANNER']); - - $cache->put('oracle_version', $this->sql_server_version); - } -*/ - $this->sql_server_version = @ociserverversion($this->db_connect_id); - - return $this->sql_server_version; - } - - /** - * SQL Transaction - * @access private - */ - function _sql_transaction($status = 'begin') - { - switch ($status) - { - case 'begin': - return true; - break; - - case 'commit': - return @ocicommit($this->db_connect_id); - break; - - case 'rollback': - return @ocirollback($this->db_connect_id); - break; - } - - return true; - } - - /** - * Oracle specific code to handle the fact that it does not compare columns properly - * @access private - */ - function _rewrite_col_compare($args) - { - if (count($args) == 4) - { - if ($args[2] == '=') - { - return '(' . $args[0] . ' OR (' . $args[1] . ' is NULL AND ' . $args[3] . ' is NULL))'; - } - else if ($args[2] == '<>') - { - // really just a fancy way of saying foo <> bar or (foo is NULL XOR bar is NULL) but SQL has no XOR :P - return '(' . $args[0] . ' OR ((' . $args[1] . ' is NULL AND ' . $args[3] . ' is NOT NULL) OR (' . $args[1] . ' is NOT NULL AND ' . $args[3] . ' is NULL)))'; - } - } - else - { - return $this->_rewrite_where($args[0]); - } - } - - /** - * Oracle specific code to handle it's lack of sanity - * @access private - */ - function _rewrite_where($where_clause) - { - preg_match_all('/\s*(AND|OR)?\s*([\w_.()]++)\s*(?:(=|<[=>]?|>=?|LIKE)\s*((?>\'(?>[^\']++|\'\')*+\'|[\d-.()]+))|((NOT )?IN\s*\((?>\'(?>[^\']++|\'\')*+\',? ?|[\d-.]+,? ?)*+\)))/', $where_clause, $result, PREG_SET_ORDER); - $out = ''; - foreach ($result as $val) - { - if (!isset($val[5])) - { - if ($val[4] !== "''") - { - $out .= $val[0]; - } - else - { - $out .= ' ' . $val[1] . ' ' . $val[2]; - if ($val[3] == '=') - { - $out .= ' is NULL'; - } - else if ($val[3] == '<>') - { - $out .= ' is NOT NULL'; - } - } - } - else - { - $in_clause = array(); - $sub_exp = substr($val[5], strpos($val[5], '(') + 1, -1); - $extra = false; - preg_match_all('/\'(?>[^\']++|\'\')*+\'|[\d-.]++/', $sub_exp, $sub_vals, PREG_PATTERN_ORDER); - $i = 0; - foreach ($sub_vals[0] as $sub_val) - { - // two things: - // 1) This determines if an empty string was in the IN clausing, making us turn it into a NULL comparison - // 2) This fixes the 1000 list limit that Oracle has (ORA-01795) - if ($sub_val !== "''") - { - $in_clause[(int) $i++/1000][] = $sub_val; - } - else - { - $extra = true; - } - } - if (!$extra && $i < 1000) - { - $out .= $val[0]; - } - else - { - $out .= ' ' . $val[1] . '('; - $in_array = array(); - - // constuct each IN() clause - foreach ($in_clause as $in_values) - { - $in_array[] = $val[2] . ' ' . (isset($val[6]) ? $val[6] : '') . 'IN(' . implode(', ', $in_values) . ')'; - } - - // Join the IN() clauses against a few ORs (IN is just a nicer OR anyway) - $out .= implode(' OR ', $in_array); - - // handle the empty string case - if ($extra) - { - $out .= ' OR ' . $val[2] . ' is ' . (isset($val[6]) ? $val[6] : '') . 'NULL'; - } - $out .= ')'; - - unset($in_array, $in_clause); - } - } - } - - return $out; - } - - /** - * {@inheritDoc} - */ - function sql_query($query = '', $cache_ttl = 0) - { - if ($query != '') - { - global $cache; - - // EXPLAIN only in extra debug mode - if (defined('DEBUG')) - { - $this->sql_report('start', $query); - } - else if (defined('PHPBB_DISPLAY_LOAD_TIME')) - { - $this->curtime = microtime(true); - } - - $this->last_query_text = $query; - $this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false; - $this->sql_add_num_queries($this->query_result); - - if ($this->query_result === false) - { - $in_transaction = false; - if (!$this->transaction) - { - $this->sql_transaction('begin'); - } - else - { - $in_transaction = true; - } - - $array = array(); - - // We overcome Oracle's 4000 char limit by binding vars - if (strlen($query) > 4000) - { - if (preg_match('/^(INSERT INTO[^(]++)\\(([^()]+)\\) VALUES[^(]++\\((.*?)\\)$/sU', $query, $regs)) - { - if (strlen($regs[3]) > 4000) - { - $cols = explode(', ', $regs[2]); - - preg_match_all('/\'(?:[^\']++|\'\')*+\'|[\d-.]+/', $regs[3], $vals, PREG_PATTERN_ORDER); - -/* The code inside this comment block breaks clob handling, but does allow the - database restore script to work. If you want to allow no posts longer than 4KB - and/or need the db restore script, uncomment this. - - - if (count($cols) !== count($vals)) - { - // Try to replace some common data we know is from our restore script or from other sources - $regs[3] = str_replace("'||chr(47)||'", '/', $regs[3]); - $_vals = explode(', ', $regs[3]); - - $vals = array(); - $is_in_val = false; - $i = 0; - $string = ''; - - foreach ($_vals as $value) - { - if (strpos($value, "'") === false && !$is_in_val) - { - $vals[$i++] = $value; - continue; - } - - if (substr($value, -1) === "'") - { - $vals[$i] = $string . (($is_in_val) ? ', ' : '') . $value; - $string = ''; - $is_in_val = false; - - if ($vals[$i][0] !== "'") - { - $vals[$i] = "''" . $vals[$i]; - } - $i++; - continue; - } - else - { - $string .= (($is_in_val) ? ', ' : '') . $value; - $is_in_val = true; - } - } - - if ($string) - { - // New value if cols != value - $vals[(count($cols) !== count($vals)) ? $i : $i - 1] .= $string; - } - - $vals = array(0 => $vals); - } -*/ - - $inserts = $vals[0]; - unset($vals); - - foreach ($inserts as $key => $value) - { - if (!empty($value) && $value[0] === "'" && strlen($value) > 4002) // check to see if this thing is greater than the max + 'x2 - { - $inserts[$key] = ':' . strtoupper($cols[$key]); - $array[$inserts[$key]] = str_replace("''", "'", substr($value, 1, -1)); - } - } - - $query = $regs[1] . '(' . $regs[2] . ') VALUES (' . implode(', ', $inserts) . ')'; - } - } - else if (preg_match_all('/^(UPDATE [\\w_]++\\s+SET )([\\w_]++\\s*=\\s*(?:\'(?:[^\']++|\'\')*+\'|[\d-.]+)(?:,\\s*[\\w_]++\\s*=\\s*(?:\'(?:[^\']++|\'\')*+\'|[\d-.]+))*+)\\s+(WHERE.*)$/s', $query, $data, PREG_SET_ORDER)) - { - if (strlen($data[0][2]) > 4000) - { - $update = $data[0][1]; - $where = $data[0][3]; - preg_match_all('/([\\w_]++)\\s*=\\s*(\'(?:[^\']++|\'\')*+\'|[\d-.]++)/', $data[0][2], $temp, PREG_SET_ORDER); - unset($data); - - $cols = array(); - foreach ($temp as $value) - { - if (!empty($value[2]) && $value[2][0] === "'" && strlen($value[2]) > 4002) // check to see if this thing is greater than the max + 'x2 - { - $cols[] = $value[1] . '=:' . strtoupper($value[1]); - $array[$value[1]] = str_replace("''", "'", substr($value[2], 1, -1)); - } - else - { - $cols[] = $value[1] . '=' . $value[2]; - } - } - - $query = $update . implode(', ', $cols) . ' ' . $where; - unset($cols); - } - } - } - - switch (substr($query, 0, 6)) - { - case 'DELETE': - if (preg_match('/^(DELETE FROM [\w_]++ WHERE)((?:\s*(?:AND|OR)?\s*[\w_]+\s*(?:(?:=|<>)\s*(?>\'(?>[^\']++|\'\')*+\'|[\d-.]+)|(?:NOT )?IN\s*\((?>\'(?>[^\']++|\'\')*+\',? ?|[\d-.]+,? ?)*+\)))*+)$/', $query, $regs)) - { - $query = $regs[1] . $this->_rewrite_where($regs[2]); - unset($regs); - } - break; - - case 'UPDATE': - if (preg_match('/^(UPDATE [\\w_]++\\s+SET [\\w_]+\s*=\s*(?:\'(?:[^\']++|\'\')*+\'|[\d-.]++|:\w++)(?:, [\\w_]+\s*=\s*(?:\'(?:[^\']++|\'\')*+\'|[\d-.]++|:\w++))*+\\s+WHERE)(.*)$/s', $query, $regs)) - { - $query = $regs[1] . $this->_rewrite_where($regs[2]); - unset($regs); - } - break; - - case 'SELECT': - $query = preg_replace_callback('/([\w_.]++)\s*(?:(=|<>)\s*(?>\'(?>[^\']++|\'\')*+\'|[\d-.]++|([\w_.]++))|(?:NOT )?IN\s*\((?>\'(?>[^\']++|\'\')*+\',? ?|[\d-.]++,? ?)*+\))/', array($this, '_rewrite_col_compare'), $query); - break; - } - - $this->query_result = @ociparse($this->db_connect_id, $query); - - foreach ($array as $key => $value) - { - @ocibindbyname($this->query_result, $key, $array[$key], -1); - } - - $success = @ociexecute($this->query_result, OCI_DEFAULT); - - if (!$success) - { - $this->sql_error($query); - $this->query_result = false; - } - else - { - if (!$in_transaction) - { - $this->sql_transaction('commit'); - } - } - - if (defined('DEBUG')) - { - $this->sql_report('stop', $query); - } - else if (defined('PHPBB_DISPLAY_LOAD_TIME')) - { - $this->sql_time += microtime(true) - $this->curtime; - } - - if (!$this->query_result) - { - return false; - } - - if ($cache && $cache_ttl) - { - $this->open_queries[(int) $this->query_result] = $this->query_result; - $this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl); - } - else if (strpos($query, 'SELECT') === 0) - { - $this->open_queries[(int) $this->query_result] = $this->query_result; - } - } - else if (defined('DEBUG')) - { - $this->sql_report('fromcache', $query); - } - } - else - { - return false; - } - - return $this->query_result; - } - - /** - * Build LIMIT query - */ - function _sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0) - { - $this->query_result = false; - - $query = 'SELECT * FROM (SELECT /*+ FIRST_ROWS */ rownum AS xrownum, a.* FROM (' . $query . ') a WHERE rownum <= ' . ($offset + $total) . ') WHERE xrownum >= ' . $offset; - - return $this->sql_query($query, $cache_ttl); - } - - /** - * {@inheritDoc} - */ - function sql_affectedrows() - { - return ($this->query_result) ? @ocirowcount($this->query_result) : false; - } - - /** - * {@inheritDoc} - */ - function sql_fetchrow($query_id = false) - { - global $cache; - - if ($query_id === false) - { - $query_id = $this->query_result; - } - - if ($cache && $cache->sql_exists($query_id)) - { - return $cache->sql_fetchrow($query_id); - } - - if ($query_id) - { - $row = array(); - $result = ocifetchinto($query_id, $row, OCI_ASSOC + OCI_RETURN_NULLS); - - if (!$result || !$row) - { - return false; - } - - $result_row = array(); - foreach ($row as $key => $value) - { - // Oracle treats empty strings as null - if (is_null($value)) - { - $value = ''; - } - - // OCI->CLOB? - if (is_object($value)) - { - $value = $value->load(); - } - - $result_row[strtolower($key)] = $value; - } - - return $result_row; - } - - return false; - } - - /** - * {@inheritDoc} - */ - function sql_rowseek($rownum, &$query_id) - { - global $cache; - - if ($query_id === false) - { - $query_id = $this->query_result; - } - - if ($cache && $cache->sql_exists($query_id)) - { - return $cache->sql_rowseek($rownum, $query_id); - } - - if (!$query_id) - { - return false; - } - - // Reset internal pointer - @ociexecute($query_id, OCI_DEFAULT); - - // We do not fetch the row for rownum == 0 because then the next resultset would be the second row - for ($i = 0; $i < $rownum; $i++) - { - if (!$this->sql_fetchrow($query_id)) - { - return false; - } - } - - return true; - } - - /** - * {@inheritDoc} - */ - function sql_nextid() - { - $query_id = $this->query_result; - - if ($query_id !== false && $this->last_query_text != '') - { - if (preg_match('#^INSERT[\t\n ]+INTO[\t\n ]+([a-z0-9\_\-]+)#is', $this->last_query_text, $tablename)) - { - $query = 'SELECT ' . $tablename[1] . '_seq.currval FROM DUAL'; - $stmt = @ociparse($this->db_connect_id, $query); - if ($stmt) - { - $success = @ociexecute($stmt, OCI_DEFAULT); - - if ($success) - { - $temp_result = ocifetchinto($stmt, $temp_array, OCI_ASSOC + OCI_RETURN_NULLS); - ocifreestatement($stmt); - - if ($temp_result) - { - return $temp_array['CURRVAL']; - } - else - { - return false; - } - } - } - } - } - - return false; - } - - /** - * {@inheritDoc} - */ - function sql_freeresult($query_id = false) - { - global $cache; - - if ($query_id === false) - { - $query_id = $this->query_result; - } - - if ($cache && !is_object($query_id) && $cache->sql_exists($query_id)) - { - return $cache->sql_freeresult($query_id); - } - - if (isset($this->open_queries[(int) $query_id])) - { - unset($this->open_queries[(int) $query_id]); - return ocifreestatement($query_id); - } - - return false; - } - - /** - * {@inheritDoc} - */ - function sql_escape($msg) - { - return str_replace(array("'", "\0"), array("''", ''), $msg); - } - - /** - * Build LIKE expression - * @access private - */ - function _sql_like_expression($expression) - { - return $expression . " ESCAPE '\\'"; - } - - /** - * Build NOT LIKE expression - * @access private - */ - function _sql_not_like_expression($expression) - { - return $expression . " ESCAPE '\\'"; - } - - function _sql_custom_build($stage, $data) - { - return $data; - } - - function _sql_bit_and($column_name, $bit, $compare = '') - { - return 'BITAND(' . $column_name . ', ' . (1 << $bit) . ')' . (($compare) ? ' ' . $compare : ''); - } - - function _sql_bit_or($column_name, $bit, $compare = '') - { - return 'BITOR(' . $column_name . ', ' . (1 << $bit) . ')' . (($compare) ? ' ' . $compare : ''); - } - - /** - * return sql error array - * @access private - */ - function _sql_error() - { - if (function_exists('ocierror')) - { - $error = @ocierror(); - $error = (!$error) ? @ocierror($this->query_result) : $error; - $error = (!$error) ? @ocierror($this->db_connect_id) : $error; - - if ($error) - { - $this->last_error_result = $error; - } - else - { - $error = (isset($this->last_error_result) && $this->last_error_result) ? $this->last_error_result : array(); - } - } - else - { - $error = array( - 'message' => $this->connect_error, - 'code' => '', - ); - } - - return $error; - } - - /** - * Close sql connection - * @access private - */ - function _sql_close() - { - return @ocilogoff($this->db_connect_id); - } - - /** - * Build db-specific report - * @access private - */ - function _sql_report($mode, $query = '') - { - switch ($mode) - { - case 'start': - - $html_table = false; - - // Grab a plan table, any will do - $sql = "SELECT table_name - FROM USER_TABLES - WHERE table_name LIKE '%PLAN_TABLE%'"; - $stmt = ociparse($this->db_connect_id, $sql); - ociexecute($stmt); - $result = array(); - - if (ocifetchinto($stmt, $result, OCI_ASSOC + OCI_RETURN_NULLS)) - { - $table = $result['TABLE_NAME']; - - // This is the statement_id that will allow us to track the plan - $statement_id = substr(md5($query), 0, 30); - - // Remove any stale plans - $stmt2 = ociparse($this->db_connect_id, "DELETE FROM $table WHERE statement_id='$statement_id'"); - ociexecute($stmt2); - ocifreestatement($stmt2); - - // Explain the plan - $sql = "EXPLAIN PLAN - SET STATEMENT_ID = '$statement_id' - FOR $query"; - $stmt2 = ociparse($this->db_connect_id, $sql); - ociexecute($stmt2); - ocifreestatement($stmt2); - - // Get the data from the plan - $sql = "SELECT operation, options, object_name, object_type, cardinality, cost - FROM plan_table - START WITH id = 0 AND statement_id = '$statement_id' - CONNECT BY PRIOR id = parent_id - AND statement_id = '$statement_id'"; - $stmt2 = ociparse($this->db_connect_id, $sql); - ociexecute($stmt2); - - $row = array(); - while (ocifetchinto($stmt2, $row, OCI_ASSOC + OCI_RETURN_NULLS)) - { - $html_table = $this->sql_report('add_select_row', $query, $html_table, $row); - } - - ocifreestatement($stmt2); - - // Remove the plan we just made, we delete them on request anyway - $stmt2 = ociparse($this->db_connect_id, "DELETE FROM $table WHERE statement_id='$statement_id'"); - ociexecute($stmt2); - ocifreestatement($stmt2); - } - - ocifreestatement($stmt); - - if ($html_table) - { - $this->html_hold .= ''; - } - - break; - - case 'fromcache': - $endtime = explode(' ', microtime()); - $endtime = $endtime[0] + $endtime[1]; - - $result = @ociparse($this->db_connect_id, $query); - if ($result) - { - $success = @ociexecute($result, OCI_DEFAULT); - if ($success) - { - $row = array(); - - while (ocifetchinto($result, $row, OCI_ASSOC + OCI_RETURN_NULLS)) - { - // Take the time spent on parsing rows into account - } - @ocifreestatement($result); - } - } - - $splittime = explode(' ', microtime()); - $splittime = $splittime[0] + $splittime[1]; - - $this->sql_report('record_fromcache', $query, $endtime, $splittime); - - break; - } - } -} diff --git a/install/update/old/phpbb/db/driver/postgres.php b/install/update/old/phpbb/db/driver/postgres.php deleted file mode 100644 index 4447661..0000000 --- a/install/update/old/phpbb/db/driver/postgres.php +++ /dev/null @@ -1,501 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\db\driver; - -/** -* PostgreSQL Database Abstraction Layer -* Minimum Requirement is Version 8.3+ -*/ -class postgres extends \phpbb\db\driver\driver -{ - var $multi_insert = true; - var $last_query_text = ''; - var $connect_error = ''; - - /** - * {@inheritDoc} - */ - function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false) - { - $connect_string = ''; - - if ($sqluser) - { - $connect_string .= "user=$sqluser "; - } - - if ($sqlpassword) - { - $connect_string .= "password=$sqlpassword "; - } - - if ($sqlserver) - { - // $sqlserver can carry a port separated by : for compatibility reasons - // If $sqlserver has more than one : it's probably an IPv6 address. - // In this case we only allow passing a port via the $port variable. - if (substr_count($sqlserver, ':') === 1) - { - list($sqlserver, $port) = explode(':', $sqlserver); - } - - if ($sqlserver !== 'localhost') - { - $connect_string .= "host=$sqlserver "; - } - - if ($port) - { - $connect_string .= "port=$port "; - } - } - - $schema = ''; - - if ($database) - { - $this->dbname = $database; - if (strpos($database, '.') !== false) - { - list($database, $schema) = explode('.', $database); - } - $connect_string .= "dbname=$database"; - } - - $this->persistency = $persistency; - - if ($this->persistency) - { - if (!function_exists('pg_pconnect')) - { - $this->connect_error = 'pg_pconnect function does not exist, is pgsql extension installed?'; - return $this->sql_error(''); - } - $collector = new \phpbb\error_collector; - $collector->install(); - $this->db_connect_id = (!$new_link) ? @pg_pconnect($connect_string) : @pg_pconnect($connect_string, PGSQL_CONNECT_FORCE_NEW); - } - else - { - if (!function_exists('pg_connect')) - { - $this->connect_error = 'pg_connect function does not exist, is pgsql extension installed?'; - return $this->sql_error(''); - } - $collector = new \phpbb\error_collector; - $collector->install(); - $this->db_connect_id = (!$new_link) ? @pg_connect($connect_string) : @pg_connect($connect_string, PGSQL_CONNECT_FORCE_NEW); - } - - $collector->uninstall(); - - if ($this->db_connect_id) - { - if ($schema !== '') - { - @pg_query($this->db_connect_id, 'SET search_path TO ' . $schema); - } - return $this->db_connect_id; - } - - $this->connect_error = $collector->format_errors(); - return $this->sql_error(''); - } - - /** - * {@inheritDoc} - */ - function sql_server_info($raw = false, $use_cache = true) - { - global $cache; - - if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('pgsql_version')) === false) - { - $query_id = @pg_query($this->db_connect_id, 'SELECT VERSION() AS version'); - if ($query_id) - { - $row = pg_fetch_assoc($query_id, null); - pg_free_result($query_id); - - $this->sql_server_version = (!empty($row['version'])) ? trim(substr($row['version'], 10)) : 0; - - if (!empty($cache) && $use_cache) - { - $cache->put('pgsql_version', $this->sql_server_version); - } - } - } - - return ($raw) ? $this->sql_server_version : 'PostgreSQL ' . $this->sql_server_version; - } - - /** - * SQL Transaction - * @access private - */ - function _sql_transaction($status = 'begin') - { - switch ($status) - { - case 'begin': - return @pg_query($this->db_connect_id, 'BEGIN'); - break; - - case 'commit': - return @pg_query($this->db_connect_id, 'COMMIT'); - break; - - case 'rollback': - return @pg_query($this->db_connect_id, 'ROLLBACK'); - break; - } - - return true; - } - - /** - * {@inheritDoc} - */ - function sql_query($query = '', $cache_ttl = 0) - { - if ($query != '') - { - global $cache; - - // EXPLAIN only in extra debug mode - if (defined('DEBUG')) - { - $this->sql_report('start', $query); - } - else if (defined('PHPBB_DISPLAY_LOAD_TIME')) - { - $this->curtime = microtime(true); - } - - $this->last_query_text = $query; - $this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false; - $this->sql_add_num_queries($this->query_result); - - if ($this->query_result === false) - { - if (($this->query_result = @pg_query($this->db_connect_id, $query)) === false) - { - $this->sql_error($query); - } - - if (defined('DEBUG')) - { - $this->sql_report('stop', $query); - } - else if (defined('PHPBB_DISPLAY_LOAD_TIME')) - { - $this->sql_time += microtime(true) - $this->curtime; - } - - if (!$this->query_result) - { - return false; - } - - if ($cache && $cache_ttl) - { - $this->open_queries[(int) $this->query_result] = $this->query_result; - $this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl); - } - else if (strpos($query, 'SELECT') === 0) - { - $this->open_queries[(int) $this->query_result] = $this->query_result; - } - } - else if (defined('DEBUG')) - { - $this->sql_report('fromcache', $query); - } - } - else - { - return false; - } - - return $this->query_result; - } - - /** - * Build db-specific query data - * @access private - */ - function _sql_custom_build($stage, $data) - { - return $data; - } - - /** - * Build LIMIT query - */ - function _sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0) - { - $this->query_result = false; - - // if $total is set to 0 we do not want to limit the number of rows - if ($total == 0) - { - $total = 'ALL'; - } - - $query .= "\n LIMIT $total OFFSET $offset"; - - return $this->sql_query($query, $cache_ttl); - } - - /** - * {@inheritDoc} - */ - function sql_affectedrows() - { - return ($this->query_result) ? @pg_affected_rows($this->query_result) : false; - } - - /** - * {@inheritDoc} - */ - function sql_fetchrow($query_id = false) - { - global $cache; - - if ($query_id === false) - { - $query_id = $this->query_result; - } - - if ($cache && $cache->sql_exists($query_id)) - { - return $cache->sql_fetchrow($query_id); - } - - return ($query_id) ? pg_fetch_assoc($query_id, null) : false; - } - - /** - * {@inheritDoc} - */ - function sql_rowseek($rownum, &$query_id) - { - global $cache; - - if ($query_id === false) - { - $query_id = $this->query_result; - } - - if ($cache && $cache->sql_exists($query_id)) - { - return $cache->sql_rowseek($rownum, $query_id); - } - - return ($query_id) ? @pg_result_seek($query_id, $rownum) : false; - } - - /** - * {@inheritDoc} - */ - function sql_nextid() - { - $query_id = $this->query_result; - - if ($query_id !== false && $this->last_query_text != '') - { - if (preg_match("/^INSERT[\t\n ]+INTO[\t\n ]+([a-z0-9\_\-]+)/is", $this->last_query_text, $tablename)) - { - $query = "SELECT currval('" . $tablename[1] . "_seq') AS last_value"; - $temp_q_id = @pg_query($this->db_connect_id, $query); - - if (!$temp_q_id) - { - return false; - } - - $temp_result = pg_fetch_assoc($temp_q_id, null); - pg_free_result($query_id); - - return ($temp_result) ? $temp_result['last_value'] : false; - } - } - - return false; - } - - /** - * {@inheritDoc} - */ - function sql_freeresult($query_id = false) - { - global $cache; - - if ($query_id === false) - { - $query_id = $this->query_result; - } - - if ($cache && !is_object($query_id) && $cache->sql_exists($query_id)) - { - return $cache->sql_freeresult($query_id); - } - - if (isset($this->open_queries[(int) $query_id])) - { - unset($this->open_queries[(int) $query_id]); - return pg_free_result($query_id); - } - - return false; - } - - /** - * {@inheritDoc} - */ - function sql_escape($msg) - { - return @pg_escape_string($msg); - } - - /** - * Build LIKE expression - * @access private - */ - function _sql_like_expression($expression) - { - return $expression; - } - - /** - * Build NOT LIKE expression - * @access private - */ - function _sql_not_like_expression($expression) - { - return $expression; - } - - /** - * {@inheritDoc} - */ - function cast_expr_to_bigint($expression) - { - return 'CAST(' . $expression . ' as DECIMAL(255, 0))'; - } - - /** - * {@inheritDoc} - */ - function cast_expr_to_string($expression) - { - return 'CAST(' . $expression . ' as VARCHAR(255))'; - } - - /** - * return sql error array - * @access private - */ - function _sql_error() - { - // pg_last_error only works when there is an established connection. - // Connection errors have to be tracked by us manually. - if ($this->db_connect_id) - { - $message = @pg_last_error($this->db_connect_id); - } - else - { - $message = $this->connect_error; - } - - return array( - 'message' => $message, - 'code' => '' - ); - } - - /** - * Close sql connection - * @access private - */ - function _sql_close() - { - return @pg_close($this->db_connect_id); - } - - /** - * Build db-specific report - * @access private - */ - function _sql_report($mode, $query = '') - { - switch ($mode) - { - case 'start': - - $explain_query = $query; - if (preg_match('/UPDATE ([a-z0-9_]+).*?WHERE(.*)/s', $query, $m)) - { - $explain_query = 'SELECT * FROM ' . $m[1] . ' WHERE ' . $m[2]; - } - else if (preg_match('/DELETE FROM ([a-z0-9_]+).*?WHERE(.*)/s', $query, $m)) - { - $explain_query = 'SELECT * FROM ' . $m[1] . ' WHERE ' . $m[2]; - } - - if (preg_match('/^SELECT/', $explain_query)) - { - $html_table = false; - - if ($result = @pg_query($this->db_connect_id, "EXPLAIN $explain_query")) - { - while ($row = pg_fetch_assoc($result, null)) - { - $html_table = $this->sql_report('add_select_row', $query, $html_table, $row); - } - pg_free_result($result); - } - - if ($html_table) - { - $this->html_hold .= ''; - } - } - - break; - - case 'fromcache': - $endtime = explode(' ', microtime()); - $endtime = $endtime[0] + $endtime[1]; - - $result = @pg_query($this->db_connect_id, $query); - if ($result) - { - while ($void = pg_fetch_assoc($result, null)) - { - // Take the time spent on parsing rows into account - } - pg_free_result($result); - } - - $splittime = explode(' ', microtime()); - $splittime = $splittime[0] + $splittime[1]; - - $this->sql_report('record_fromcache', $query, $endtime, $splittime); - - break; - } - } -} diff --git a/install/update/old/phpbb/db/driver/sqlite3.php b/install/update/old/phpbb/db/driver/sqlite3.php deleted file mode 100644 index 0508500..0000000 --- a/install/update/old/phpbb/db/driver/sqlite3.php +++ /dev/null @@ -1,431 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\db\driver; - -/** -* SQLite3 Database Abstraction Layer -* Minimum Requirement: 3.6.15+ -*/ -class sqlite3 extends \phpbb\db\driver\driver -{ - /** - * @var string Stores errors during connection setup in case the driver is not available - */ - protected $connect_error = ''; - - /** - * @var \SQLite3 The SQLite3 database object to operate against - */ - protected $dbo = null; - - /** - * {@inheritDoc} - */ - public function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false) - { - $this->persistency = false; - $this->user = $sqluser; - $this->server = $sqlserver . (($port) ? ':' . $port : ''); - $this->dbname = $database; - - if (!class_exists('SQLite3', false)) - { - $this->connect_error = 'SQLite3 not found, is the extension installed?'; - return $this->sql_error(''); - } - - try - { - $this->dbo = new \SQLite3($this->server, SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE); - $this->dbo->busyTimeout(60000); - $this->db_connect_id = true; - } - catch (\Exception $e) - { - $this->connect_error = $e->getMessage(); - return array('message' => $this->connect_error); - } - - return true; - } - - /** - * {@inheritDoc} - */ - public function sql_server_info($raw = false, $use_cache = true) - { - global $cache; - - if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('sqlite_version')) === false) - { - $version = \SQLite3::version(); - - $this->sql_server_version = $version['versionString']; - - if (!empty($cache) && $use_cache) - { - $cache->put('sqlite_version', $this->sql_server_version); - } - } - - return ($raw) ? $this->sql_server_version : 'SQLite ' . $this->sql_server_version; - } - - /** - * SQL Transaction - * - * @param string $status Should be one of the following strings: - * begin, commit, rollback - * @return bool Success/failure of the transaction query - */ - protected function _sql_transaction($status = 'begin') - { - switch ($status) - { - case 'begin': - return $this->dbo->exec('BEGIN IMMEDIATE'); - break; - - case 'commit': - return $this->dbo->exec('COMMIT'); - break; - - case 'rollback': - return @$this->dbo->exec('ROLLBACK'); - break; - } - - return true; - } - - /** - * {@inheritDoc} - */ - public function sql_query($query = '', $cache_ttl = 0) - { - if ($query != '') - { - global $cache; - - // EXPLAIN only in extra debug mode - if (defined('DEBUG')) - { - $this->sql_report('start', $query); - } - else if (defined('PHPBB_DISPLAY_LOAD_TIME')) - { - $this->curtime = microtime(true); - } - - $this->last_query_text = $query; - $this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false; - $this->sql_add_num_queries($this->query_result); - - if ($this->query_result === false) - { - if ($this->transaction === true && strpos($query, 'INSERT') === 0) - { - $query = preg_replace('/^INSERT INTO/', 'INSERT OR ROLLBACK INTO', $query); - } - - if (($this->query_result = @$this->dbo->query($query)) === false) - { - // Try to recover a lost database connection - if ($this->dbo && !@$this->dbo->lastErrorMsg()) - { - if ($this->sql_connect($this->server, $this->user, '', $this->dbname)) - { - $this->query_result = @$this->dbo->query($query); - } - } - - if ($this->query_result === false) - { - $this->sql_error($query); - } - } - - if (defined('DEBUG')) - { - $this->sql_report('stop', $query); - } - else if (defined('PHPBB_DISPLAY_LOAD_TIME')) - { - $this->sql_time += microtime(true) - $this->curtime; - } - - if (!$this->query_result) - { - return false; - } - - if ($cache && $cache_ttl) - { - $this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl); - } - } - else if (defined('DEBUG')) - { - $this->sql_report('fromcache', $query); - } - } - else - { - return false; - } - - return $this->query_result; - } - - /** - * Build LIMIT query - * - * @param string $query The SQL query to execute - * @param int $total The number of rows to select - * @param int $offset - * @param int $cache_ttl Either 0 to avoid caching or - * the time in seconds which the result shall be kept in cache - * @return mixed Buffered, seekable result handle, false on error - */ - protected function _sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0) - { - $this->query_result = false; - - // if $total is set to 0 we do not want to limit the number of rows - if ($total == 0) - { - $total = -1; - } - - $query .= "\n LIMIT " . ((!empty($offset)) ? $offset . ', ' . $total : $total); - - return $this->sql_query($query, $cache_ttl); - } - - /** - * {@inheritDoc} - */ - public function sql_affectedrows() - { - return ($this->db_connect_id) ? $this->dbo->changes() : false; - } - - /** - * {@inheritDoc} - */ - public function sql_fetchrow($query_id = false) - { - global $cache; - - if ($query_id === false) - { - /** @var \SQLite3Result $query_id */ - $query_id = $this->query_result; - } - - if ($cache && !is_object($query_id) && $cache->sql_exists($query_id)) - { - return $cache->sql_fetchrow($query_id); - } - - return is_object($query_id) ? @$query_id->fetchArray(SQLITE3_ASSOC) : false; - } - - /** - * {@inheritDoc} - */ - public function sql_nextid() - { - return ($this->db_connect_id) ? $this->dbo->lastInsertRowID() : false; - } - - /** - * {@inheritDoc} - */ - public function sql_freeresult($query_id = false) - { - global $cache; - - if ($query_id === false) - { - $query_id = $this->query_result; - } - - if ($cache && !is_object($query_id) && $cache->sql_exists($query_id)) - { - return $cache->sql_freeresult($query_id); - } - - if ($query_id) - { - return @$query_id->finalize(); - } - } - - /** - * {@inheritDoc} - */ - public function sql_escape($msg) - { - return \SQLite3::escapeString($msg); - } - - /** - * {@inheritDoc} - * - * For SQLite an underscore is an unknown character. - */ - public function sql_like_expression($expression) - { - // Unlike LIKE, GLOB is unfortunately case sensitive. - // We only catch * and ? here, not the character map possible on file globbing. - $expression = str_replace(array(chr(0) . '_', chr(0) . '%'), array(chr(0) . '?', chr(0) . '*'), $expression); - - $expression = str_replace(array('?', '*'), array("\?", "\*"), $expression); - $expression = str_replace(array(chr(0) . "\?", chr(0) . "\*"), array('?', '*'), $expression); - - return 'GLOB \'' . $this->sql_escape($expression) . '\''; - } - - /** - * {@inheritDoc} - * - * For SQLite an underscore is an unknown character. - */ - public function sql_not_like_expression($expression) - { - // Unlike NOT LIKE, NOT GLOB is unfortunately case sensitive - // We only catch * and ? here, not the character map possible on file globbing. - $expression = str_replace(array(chr(0) . '_', chr(0) . '%'), array(chr(0) . '?', chr(0) . '*'), $expression); - - $expression = str_replace(array('?', '*'), array("\?", "\*"), $expression); - $expression = str_replace(array(chr(0) . "\?", chr(0) . "\*"), array('?', '*'), $expression); - - return 'NOT GLOB \'' . $this->sql_escape($expression) . '\''; - } - - /** - * return sql error array - * - * @return array - */ - protected function _sql_error() - { - if (class_exists('SQLite3', false) && isset($this->dbo)) - { - $error = array( - 'message' => $this->dbo->lastErrorMsg(), - 'code' => $this->dbo->lastErrorCode(), - ); - } - else - { - $error = array( - 'message' => $this->connect_error, - 'code' => '', - ); - } - - return $error; - } - - /** - * Build db-specific query data - * - * @param string $stage Available stages: FROM, WHERE - * @param mixed $data A string containing the CROSS JOIN query or an array of WHERE clauses - * - * @return string The db-specific query fragment - */ - protected function _sql_custom_build($stage, $data) - { - return $data; - } - - /** - * Close sql connection - * - * @return bool False if failure - */ - protected function _sql_close() - { - return $this->dbo->close(); - } - - /** - * Build db-specific report - * - * @param string $mode Available modes: display, start, stop, - * add_select_row, fromcache, record_fromcache - * @param string $query The Query that should be explained - * @return mixed Either a full HTML page, boolean or null - */ - protected function _sql_report($mode, $query = '') - { - switch ($mode) - { - case 'start': - - $explain_query = $query; - if (preg_match('/UPDATE ([a-z0-9_]+).*?WHERE(.*)/s', $query, $m)) - { - $explain_query = 'SELECT * FROM ' . $m[1] . ' WHERE ' . $m[2]; - } - else if (preg_match('/DELETE FROM ([a-z0-9_]+).*?WHERE(.*)/s', $query, $m)) - { - $explain_query = 'SELECT * FROM ' . $m[1] . ' WHERE ' . $m[2]; - } - - if (preg_match('/^SELECT/', $explain_query)) - { - $html_table = false; - - if ($result = $this->dbo->query("EXPLAIN QUERY PLAN $explain_query")) - { - while ($row = $result->fetchArray(SQLITE3_ASSOC)) - { - $html_table = $this->sql_report('add_select_row', $query, $html_table, $row); - } - } - - if ($html_table) - { - $this->html_hold .= ''; - } - } - - break; - - case 'fromcache': - $endtime = explode(' ', microtime()); - $endtime = $endtime[0] + $endtime[1]; - - $result = $this->dbo->query($query); - if ($result) - { - while ($void = $result->fetchArray(SQLITE3_ASSOC)) - { - // Take the time spent on parsing rows into account - } - } - - $splittime = explode(' ', microtime()); - $splittime = $splittime[0] + $splittime[1]; - - $this->sql_report('record_fromcache', $query, $endtime, $splittime); - - break; - } - } -} diff --git a/install/update/old/phpbb/db/extractor/mysql_extractor.php b/install/update/old/phpbb/db/extractor/mysql_extractor.php deleted file mode 100644 index 34e309c..0000000 --- a/install/update/old/phpbb/db/extractor/mysql_extractor.php +++ /dev/null @@ -1,403 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\db\extractor; - -use phpbb\db\extractor\exception\extractor_not_initialized_exception; - -class mysql_extractor extends base_extractor -{ - /** - * {@inheritdoc} - */ - public function write_start($table_prefix) - { - if (!$this->is_initialized) - { - throw new extractor_not_initialized_exception(); - } - - $sql_data = "#\n"; - $sql_data .= "# phpBB Backup Script\n"; - $sql_data .= "# Dump of tables for $table_prefix\n"; - $sql_data .= "# DATE : " . gmdate("d-m-Y H:i:s", $this->time) . " GMT\n"; - $sql_data .= "#\n"; - $this->flush($sql_data); - } - - /** - * {@inheritdoc} - */ - public function write_table($table_name) - { - static $new_extract; - - if (!$this->is_initialized) - { - throw new extractor_not_initialized_exception(); - } - - if ($new_extract === null) - { - if ($this->db->get_sql_layer() === 'mysqli' || version_compare($this->db->sql_server_info(true), '3.23.20', '>=')) - { - $new_extract = true; - } - else - { - $new_extract = false; - } - } - - if ($new_extract) - { - $this->new_write_table($table_name); - } - else - { - $this->old_write_table($table_name); - } - } - - /** - * {@inheritdoc} - */ - public function write_data($table_name) - { - if (!$this->is_initialized) - { - throw new extractor_not_initialized_exception(); - } - - if ($this->db->get_sql_layer() === 'mysqli') - { - $this->write_data_mysqli($table_name); - } - else - { - $this->write_data_mysql($table_name); - } - } - - /** - * Extracts data from database table (for MySQLi driver) - * - * @param string $table_name name of the database table - * @return null - * @throws \phpbb\db\extractor\exception\extractor_not_initialized_exception when calling this function before init_extractor() - */ - protected function write_data_mysqli($table_name) - { - if (!$this->is_initialized) - { - throw new extractor_not_initialized_exception(); - } - - $sql = "SELECT * - FROM $table_name"; - $result = mysqli_query($this->db->get_db_connect_id(), $sql, MYSQLI_USE_RESULT); - if ($result != false) - { - $fields_cnt = mysqli_num_fields($result); - - // Get field information - $field = mysqli_fetch_fields($result); - $field_set = array(); - - for ($j = 0; $j < $fields_cnt; $j++) - { - $field_set[] = $field[$j]->name; - } - - $search = array("\\", "'", "\x00", "\x0a", "\x0d", "\x1a", '"'); - $replace = array("\\\\", "\\'", '\0', '\n', '\r', '\Z', '\\"'); - $fields = implode(', ', $field_set); - $sql_data = 'INSERT INTO ' . $table_name . ' (' . $fields . ') VALUES '; - $first_set = true; - $query_len = 0; - $max_len = get_usable_memory(); - - while ($row = mysqli_fetch_row($result)) - { - $values = array(); - if ($first_set) - { - $query = $sql_data . '('; - } - else - { - $query .= ',('; - } - - for ($j = 0; $j < $fields_cnt; $j++) - { - if (!isset($row[$j]) || is_null($row[$j])) - { - $values[$j] = 'NULL'; - } - else if (($field[$j]->flags & 32768) && !($field[$j]->flags & 1024)) - { - $values[$j] = $row[$j]; - } - else - { - $values[$j] = "'" . str_replace($search, $replace, $row[$j]) . "'"; - } - } - $query .= implode(', ', $values) . ')'; - - $query_len += strlen($query); - if ($query_len > $max_len) - { - $this->flush($query . ";\n\n"); - $query = ''; - $query_len = 0; - $first_set = true; - } - else - { - $first_set = false; - } - } - mysqli_free_result($result); - - // check to make sure we have nothing left to flush - if (!$first_set && $query) - { - $this->flush($query . ";\n\n"); - } - } - } - - /** - * Extracts data from database table (for MySQL driver) - * - * @param string $table_name name of the database table - * @return null - * @throws \phpbb\db\extractor\exception\extractor_not_initialized_exception when calling this function before init_extractor() - */ - protected function write_data_mysql($table_name) - { - if (!$this->is_initialized) - { - throw new extractor_not_initialized_exception(); - } - - $sql = "SELECT * - FROM $table_name"; - $result = mysql_unbuffered_query($sql, $this->db->get_db_connect_id()); - - if ($result != false) - { - $fields_cnt = mysql_num_fields($result); - - // Get field information - $field = array(); - for ($i = 0; $i < $fields_cnt; $i++) - { - $field[] = mysql_fetch_field($result, $i); - } - $field_set = array(); - - for ($j = 0; $j < $fields_cnt; $j++) - { - $field_set[] = $field[$j]->name; - } - - $search = array("\\", "'", "\x00", "\x0a", "\x0d", "\x1a", '"'); - $replace = array("\\\\", "\\'", '\0', '\n', '\r', '\Z', '\\"'); - $fields = implode(', ', $field_set); - $sql_data = 'INSERT INTO ' . $table_name . ' (' . $fields . ') VALUES '; - $first_set = true; - $query_len = 0; - $max_len = get_usable_memory(); - - while ($row = mysql_fetch_row($result)) - { - $values = array(); - if ($first_set) - { - $query = $sql_data . '('; - } - else - { - $query .= ',('; - } - - for ($j = 0; $j < $fields_cnt; $j++) - { - if (!isset($row[$j]) || is_null($row[$j])) - { - $values[$j] = 'NULL'; - } - else if ($field[$j]->numeric && ($field[$j]->type !== 'timestamp')) - { - $values[$j] = $row[$j]; - } - else - { - $values[$j] = "'" . str_replace($search, $replace, $row[$j]) . "'"; - } - } - $query .= implode(', ', $values) . ')'; - - $query_len += strlen($query); - if ($query_len > $max_len) - { - $this->flush($query . ";\n\n"); - $query = ''; - $query_len = 0; - $first_set = true; - } - else - { - $first_set = false; - } - } - mysql_free_result($result); - - // check to make sure we have nothing left to flush - if (!$first_set && $query) - { - $this->flush($query . ";\n\n"); - } - } - } - - /** - * Extracts database table structure (for MySQLi or MySQL 3.23.20+) - * - * @param string $table_name name of the database table - * @return null - * @throws \phpbb\db\extractor\exception\extractor_not_initialized_exception when calling this function before init_extractor() - */ - protected function new_write_table($table_name) - { - if (!$this->is_initialized) - { - throw new extractor_not_initialized_exception(); - } - - $sql = 'SHOW CREATE TABLE ' . $table_name; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - - $sql_data = '# Table: ' . $table_name . "\n"; - $sql_data .= "DROP TABLE IF EXISTS $table_name;\n"; - $this->flush($sql_data . $row['Create Table'] . ";\n\n"); - - $this->db->sql_freeresult($result); - } - - /** - * Extracts database table structure (for MySQL verisons older than 3.23.20) - * - * @param string $table_name name of the database table - * @return null - * @throws \phpbb\db\extractor\exception\extractor_not_initialized_exception when calling this function before init_extractor() - */ - protected function old_write_table($table_name) - { - if (!$this->is_initialized) - { - throw new extractor_not_initialized_exception(); - } - - $sql_data = '# Table: ' . $table_name . "\n"; - $sql_data .= "DROP TABLE IF EXISTS $table_name;\n"; - $sql_data .= "CREATE TABLE $table_name(\n"; - $rows = array(); - - $sql = "SHOW FIELDS - FROM $table_name"; - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - $line = ' ' . $row['Field'] . ' ' . $row['Type']; - - if (!is_null($row['Default'])) - { - $line .= " DEFAULT '{$row['Default']}'"; - } - - if ($row['Null'] != 'YES') - { - $line .= ' NOT NULL'; - } - - if ($row['Extra'] != '') - { - $line .= ' ' . $row['Extra']; - } - - $rows[] = $line; - } - $this->db->sql_freeresult($result); - - $sql = "SHOW KEYS - FROM $table_name"; - - $result = $this->db->sql_query($sql); - - $index = array(); - while ($row = $this->db->sql_fetchrow($result)) - { - $kname = $row['Key_name']; - - if ($kname != 'PRIMARY') - { - if ($row['Non_unique'] == 0) - { - $kname = "UNIQUE|$kname"; - } - } - - if ($row['Sub_part']) - { - $row['Column_name'] .= '(' . $row['Sub_part'] . ')'; - } - $index[$kname][] = $row['Column_name']; - } - $this->db->sql_freeresult($result); - - foreach ($index as $key => $columns) - { - $line = ' '; - - if ($key == 'PRIMARY') - { - $line .= 'PRIMARY KEY (' . implode(', ', $columns) . ')'; - } - else if (strpos($key, 'UNIQUE') === 0) - { - $line .= 'UNIQUE ' . substr($key, 7) . ' (' . implode(', ', $columns) . ')'; - } - else if (strpos($key, 'FULLTEXT') === 0) - { - $line .= 'FULLTEXT ' . substr($key, 9) . ' (' . implode(', ', $columns) . ')'; - } - else - { - $line .= "KEY $key (" . implode(', ', $columns) . ')'; - } - - $rows[] = $line; - } - - $sql_data .= implode(",\n", $rows); - $sql_data .= "\n);\n\n"; - - $this->flush($sql_data); - } -} diff --git a/install/update/old/phpbb/db/migration/data/v30x/release_3_0_4_rc1.php b/install/update/old/phpbb/db/migration/data/v30x/release_3_0_4_rc1.php deleted file mode 100644 index 1034343..0000000 --- a/install/update/old/phpbb/db/migration/data/v30x/release_3_0_4_rc1.php +++ /dev/null @@ -1,129 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\db\migration\data\v30x; - -class release_3_0_4_rc1 extends \phpbb\db\migration\migration -{ - public function effectively_installed() - { - return phpbb_version_compare($this->config['version'], '3.0.4-RC1', '>='); - } - - static public function depends_on() - { - return array('\phpbb\db\migration\data\v30x\release_3_0_3'); - } - - public function update_schema() - { - return array( - 'add_columns' => array( - $this->table_prefix . 'profile_fields' => array( - 'field_show_profile' => array('BOOL', 0), - ), - ), - 'change_columns' => array( - $this->table_prefix . 'styles' => array( - 'style_id' => array('UINT', NULL, 'auto_increment'), - 'template_id' => array('UINT', 0), - 'theme_id' => array('UINT', 0), - 'imageset_id' => array('UINT', 0), - ), - $this->table_prefix . 'styles_imageset' => array( - 'imageset_id' => array('UINT', NULL, 'auto_increment'), - ), - $this->table_prefix . 'styles_imageset_data' => array( - 'image_id' => array('UINT', NULL, 'auto_increment'), - 'imageset_id' => array('UINT', 0), - ), - $this->table_prefix . 'styles_theme' => array( - 'theme_id' => array('UINT', NULL, 'auto_increment'), - ), - $this->table_prefix . 'styles_template' => array( - 'template_id' => array('UINT', NULL, 'auto_increment'), - ), - $this->table_prefix . 'styles_template_data' => array( - 'template_id' => array('UINT', 0), - ), - $this->table_prefix . 'forums' => array( - 'forum_style' => array('UINT', 0), - ), - $this->table_prefix . 'users' => array( - 'user_style' => array('UINT', 0), - ), - ), - ); - } - - public function revert_schema() - { - return array( - 'drop_columns' => array( - $this->table_prefix . 'profile_fields' => array( - 'field_show_profile', - ), - ), - ); - } - - public function update_data() - { - return array( - array('custom', array(array(&$this, 'update_custom_profile_fields'))), - - array('config.update', array('version', '3.0.4-RC1')), - ); - } - - public function update_custom_profile_fields() - { - // Update the Custom Profile Fields based on previous settings to the new \format - $sql = 'SELECT field_id, field_required, field_show_on_reg, field_hide - FROM ' . PROFILE_FIELDS_TABLE; - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - $sql_ary = array( - 'field_required' => 0, - 'field_show_on_reg' => 0, - 'field_hide' => 0, - 'field_show_profile'=> 0, - ); - - if ($row['field_required']) - { - $sql_ary['field_required'] = $sql_ary['field_show_on_reg'] = $sql_ary['field_show_profile'] = 1; - } - else if ($row['field_show_on_reg']) - { - $sql_ary['field_show_on_reg'] = $sql_ary['field_show_profile'] = 1; - } - else if ($row['field_hide']) - { - // Only administrators and moderators can see this CPF, if the view is enabled, they can see it, otherwise just admins in the acp_users module - $sql_ary['field_hide'] = 1; - } - else - { - // equivelant to "none", which is the "Display in user control panel" option - $sql_ary['field_show_profile'] = 1; - } - - $this->sql_query('UPDATE ' . $this->table_prefix . 'profile_fields SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE field_id = ' . $row['field_id'], $errored, $error_ary); - } - - $this->db->sql_freeresult($result); - } -} diff --git a/install/update/old/phpbb/db/migration/data/v310/softdelete_p1.php b/install/update/old/phpbb/db/migration/data/v310/softdelete_p1.php deleted file mode 100644 index b1e7486..0000000 --- a/install/update/old/phpbb/db/migration/data/v310/softdelete_p1.php +++ /dev/null @@ -1,211 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\db\migration\data\v310; - -class softdelete_p1 extends \phpbb\db\migration\migration -{ - public function effectively_installed() - { - return $this->db_tools->sql_column_exists($this->table_prefix . 'posts', 'post_visibility'); - } - - static public function depends_on() - { - return array('\phpbb\db\migration\data\v310\dev'); - } - - public function update_schema() - { - return array( - 'add_columns' => array( - $this->table_prefix . 'forums' => array( - 'forum_posts_approved' => array('UINT', 0), - 'forum_posts_unapproved' => array('UINT', 0), - 'forum_posts_softdeleted' => array('UINT', 0), - 'forum_topics_approved' => array('UINT', 0), - 'forum_topics_unapproved' => array('UINT', 0), - 'forum_topics_softdeleted' => array('UINT', 0), - ), - $this->table_prefix . 'posts' => array( - 'post_visibility' => array('TINT:3', 0), - 'post_delete_time' => array('TIMESTAMP', 0), - 'post_delete_reason' => array('STEXT_UNI', ''), - 'post_delete_user' => array('UINT', 0), - ), - $this->table_prefix . 'topics' => array( - 'topic_visibility' => array('TINT:3', 0), - 'topic_delete_time' => array('TIMESTAMP', 0), - 'topic_delete_reason' => array('STEXT_UNI', ''), - 'topic_delete_user' => array('UINT', 0), - 'topic_posts_approved' => array('UINT', 0), - 'topic_posts_unapproved' => array('UINT', 0), - 'topic_posts_softdeleted' => array('UINT', 0), - ), - ), - 'add_index' => array( - $this->table_prefix . 'posts' => array( - 'post_visibility' => array('post_visibility'), - ), - $this->table_prefix . 'topics' => array( - 'topic_visibility' => array('topic_visibility'), - 'forum_vis_last' => array('forum_id', 'topic_visibility', 'topic_last_post_id'), - ), - ), - ); - } - - public function revert_schema() - { - return array( - 'drop_columns' => array( - $this->table_prefix . 'forums' => array( - 'forum_posts_approved', - 'forum_posts_unapproved', - 'forum_posts_softdeleted', - 'forum_topics_approved', - 'forum_topics_unapproved', - 'forum_topics_softdeleted', - ), - $this->table_prefix . 'posts' => array( - 'post_visibility', - 'post_delete_time', - 'post_delete_reason', - 'post_delete_user', - ), - $this->table_prefix . 'topics' => array( - 'topic_visibility', - 'topic_delete_time', - 'topic_delete_reason', - 'topic_delete_user', - 'topic_posts_approved', - 'topic_posts_unapproved', - 'topic_posts_softdeleted', - ), - ), - 'drop_keys' => array( - $this->table_prefix . 'posts' => array('post_visibility'), - $this->table_prefix . 'topics' => array('topic_visibility', 'forum_vis_last'), - ), - ); - } - - public function update_data() - { - return array( - array('custom', array(array($this, 'update_post_visibility'))), - array('custom', array(array($this, 'update_topic_visibility'))), - array('custom', array(array($this, 'update_topics_post_counts'))), - array('custom', array(array($this, 'update_forums_topic_and_post_counts'))), - - array('permission.add', array('f_softdelete', false)), - array('permission.add', array('m_softdelete', false)), - ); - } - - public function update_post_visibility() - { - $sql = 'UPDATE ' . $this->table_prefix . 'posts - SET post_visibility = post_approved'; - $this->sql_query($sql); - } - - public function update_topic_visibility() - { - $sql = 'UPDATE ' . $this->table_prefix . 'topics - SET topic_visibility = topic_approved'; - $this->sql_query($sql); - } - - public function update_topics_post_counts() - { - /* - * Using sql_case here to avoid "BIGINT UNSIGNED value is out of range" errors. - * As we update all topics in 2 queries, one broken topic would stop the conversion - * for all topics and the surpressed error will cause the admin to not even notice it. - */ - $sql = 'UPDATE ' . $this->table_prefix . 'topics - SET topic_posts_approved = topic_replies + 1, - topic_posts_unapproved = ' . $this->db->sql_case('topic_replies_real > topic_replies', 'topic_replies_real - topic_replies', '0') . ' - WHERE topic_visibility = ' . ITEM_APPROVED; - $this->sql_query($sql); - - $sql = 'UPDATE ' . $this->table_prefix . 'topics - SET topic_posts_approved = 0, - topic_posts_unapproved = (' . $this->db->sql_case('topic_replies_real > topic_replies', 'topic_replies_real - topic_replies', '0') . ') + 1 - WHERE topic_visibility = ' . ITEM_UNAPPROVED; - $this->sql_query($sql); - } - - public function update_forums_topic_and_post_counts($start) - { - $start = (int) $start; - $limit = 10; - $converted_forums = 0; - - if (!$start) - { - // Preserve the forum_posts value for link forums as it represents redirects. - $sql = 'UPDATE ' . $this->table_prefix . 'forums - SET forum_posts_approved = forum_posts - WHERE forum_type = ' . FORUM_LINK; - $this->db->sql_query($sql); - } - - $sql = 'SELECT forum_id, topic_visibility, COUNT(topic_id) AS sum_topics, SUM(topic_posts_approved) AS sum_posts_approved, SUM(topic_posts_unapproved) AS sum_posts_unapproved - FROM ' . $this->table_prefix . 'topics - GROUP BY forum_id, topic_visibility - ORDER BY forum_id, topic_visibility'; - $result = $this->db->sql_query_limit($sql, $limit, $start); - - $update_forums = array(); - while ($row = $this->db->sql_fetchrow($result)) - { - $converted_forums++; - - $forum_id = (int) $row['forum_id']; - if (!isset($update_forums[$forum_id])) - { - $update_forums[$forum_id] = array( - 'forum_posts_approved' => 0, - 'forum_posts_unapproved' => 0, - 'forum_topics_approved' => 0, - 'forum_topics_unapproved' => 0, - ); - } - - $update_forums[$forum_id]['forum_posts_approved'] += (int) $row['sum_posts_approved']; - $update_forums[$forum_id]['forum_posts_unapproved'] += (int) $row['sum_posts_unapproved']; - - $update_forums[$forum_id][(($row['topic_visibility'] == ITEM_APPROVED) ? 'forum_topics_approved' : 'forum_topics_unapproved')] += (int) $row['sum_topics']; - } - $this->db->sql_freeresult($result); - - foreach ($update_forums as $forum_id => $forum_data) - { - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET ' . $this->db->sql_build_array('UPDATE', $forum_data) . ' - WHERE forum_id = ' . $forum_id; - $this->sql_query($sql); - } - - if ($converted_forums < $limit) - { - // There are no more topics, we are done - return; - } - - // There are still more topics to query, return the next start value - return $start + $limit; - } -} diff --git a/install/update/old/phpbb/db/migration/tool/module.php b/install/update/old/phpbb/db/migration/tool/module.php deleted file mode 100644 index e5133c8..0000000 --- a/install/update/old/phpbb/db/migration/tool/module.php +++ /dev/null @@ -1,556 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\db\migration\tool; - -use phpbb\module\exception\module_exception; - -/** -* Migration module management tool -*/ -class module implements \phpbb\db\migration\tool\tool_interface -{ - /** @var \phpbb\cache\service */ - protected $cache; - - /** @var \phpbb\db\driver\driver_interface */ - protected $db; - - /** @var \phpbb\user */ - protected $user; - - /** @var \phpbb\module\module_manager */ - protected $module_manager; - - /** @var string */ - protected $phpbb_root_path; - - /** @var string */ - protected $php_ext; - - /** @var string */ - protected $modules_table; - - /** @var array */ - protected $module_categories = array(); - - /** - * Constructor - * - * @param \phpbb\db\driver\driver_interface $db - * @param \phpbb\cache\service $cache - * @param \phpbb\user $user - * @param \phpbb\module\module_manager $module_manager - * @param string $phpbb_root_path - * @param string $php_ext - * @param string $modules_table - */ - public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\cache\service $cache, \phpbb\user $user, \phpbb\module\module_manager $module_manager, $phpbb_root_path, $php_ext, $modules_table) - { - $this->db = $db; - $this->cache = $cache; - $this->user = $user; - $this->module_manager = $module_manager; - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - $this->modules_table = $modules_table; - } - - /** - * {@inheritdoc} - */ - public function get_name() - { - return 'module'; - } - - /** - * Module Exists - * - * Check if a module exists - * - * @param string $class The module class(acp|mcp|ucp) - * @param int|string|bool $parent The parent module_id|module_langname (0 for no parent). - * Use false to ignore the parent check and check class wide. - * @param int|string $module The module_id|module_langname you would like to - * check for to see if it exists - * @param bool $lazy Checks lazily if the module exists. Returns true if it exists in at - * least one given parent. - * @return bool true if module exists in *all* given parents, false if not in any given parent; - * true if ignoring parent check and module exists class wide, false if not found at all. - */ - public function exists($class, $parent, $module, $lazy = false) - { - // the main root directory should return true - if (!$module) - { - return true; - } - - $parent_sqls = []; - if ($parent !== false) - { - $parents = $this->get_parent_module_id($parent, $module, false); - if ($parents === false) - { - return false; - } - - foreach ((array) $parents as $parent_id) - { - $parent_sqls[] = 'AND parent_id = ' . (int) $parent_id; - } - } - else - { - $parent_sqls[] = ''; - } - - foreach ($parent_sqls as $parent_sql) - { - $sql = 'SELECT module_id - FROM ' . $this->modules_table . " - WHERE module_class = '" . $this->db->sql_escape($class) . "' - $parent_sql - AND " . ((is_numeric($module)) ? 'module_id = ' . (int) $module : "module_langname = '" . $this->db->sql_escape($module) . "'"); - $result = $this->db->sql_query($sql); - $module_id = $this->db->sql_fetchfield('module_id'); - $this->db->sql_freeresult($result); - - if (!$lazy && !$module_id) - { - return false; - } - if ($lazy && $module_id) - { - return true; - } - } - - // Returns true, if modules exist in all parents and false otherwise - return !$lazy; - } - - /** - * Module Add - * - * Add a new module - * - * @param string $class The module class(acp|mcp|ucp) - * @param int|string $parent The parent module_id|module_langname (0 for no parent) - * @param array $data an array of the data on the new \module. - * This can be setup in two different ways. - * 1. The "manual" way. For inserting a category or one at a time. - * It will be merged with the base array shown a bit below, - * but at the least requires 'module_langname' to be sent, and, - * if you want to create a module (instead of just a category) you must - * send module_basename and module_mode. - * array( - * 'module_enabled' => 1, - * 'module_display' => 1, - * 'module_basename' => '', - * 'module_class' => $class, - * 'parent_id' => (int) $parent, - * 'module_langname' => '', - * 'module_mode' => '', - * 'module_auth' => '', - * ) - * 2. The "automatic" way. For inserting multiple at a time based on the - * specs in the info file for the module(s). For this to work the - * modules must be correctly setup in the info file. - * An example follows (this would insert the settings, log, and flag - * modes from the includes/acp/info/acp_asacp.php file): - * array( - * 'module_basename' => 'asacp', - * 'modes' => array('settings', 'log', 'flag'), - * ) - * Optionally you may not send 'modes' and it will insert all of the - * modules in that info file. - * path, specify that here - * @return null - * @throws \phpbb\db\migration\exception - */ - public function add($class, $parent = 0, $data = array()) - { - global $user, $phpbb_log; - - // allow sending the name as a string in $data to create a category - if (!is_array($data)) - { - $data = array('module_langname' => $data); - } - - $parents = (array) $this->get_parent_module_id($parent, $data); - - if (!isset($data['module_langname'])) - { - // The "automatic" way - $basename = (isset($data['module_basename'])) ? $data['module_basename'] : ''; - $module = $this->get_module_info($class, $basename); - - foreach ($module['modes'] as $mode => $module_info) - { - if (!isset($data['modes']) || in_array($mode, $data['modes'])) - { - $new_module = array( - 'module_basename' => $basename, - 'module_langname' => $module_info['title'], - 'module_mode' => $mode, - 'module_auth' => $module_info['auth'], - 'module_display' => (isset($module_info['display'])) ? $module_info['display'] : true, - 'before' => (isset($module_info['before'])) ? $module_info['before'] : false, - 'after' => (isset($module_info['after'])) ? $module_info['after'] : false, - ); - - // Run the "manual" way with the data we've collected. - foreach ($parents as $parent) - { - $this->add($class, $parent, $new_module); - } - } - } - - return; - } - - foreach ($parents as $parent) - { - $data['parent_id'] = $parent; - - // The "manual" way - if (!$this->exists($class, false, $parent)) - { - throw new \phpbb\db\migration\exception('MODULE_NOT_EXIST', $parent); - } - - if ($this->exists($class, $parent, $data['module_langname'])) - { - throw new \phpbb\db\migration\exception('MODULE_EXISTS', $data['module_langname']); - } - - $module_data = array( - 'module_enabled' => (isset($data['module_enabled'])) ? $data['module_enabled'] : 1, - 'module_display' => (isset($data['module_display'])) ? $data['module_display'] : 1, - 'module_basename' => (isset($data['module_basename'])) ? $data['module_basename'] : '', - 'module_class' => $class, - 'parent_id' => (int) $parent, - 'module_langname' => (isset($data['module_langname'])) ? $data['module_langname'] : '', - 'module_mode' => (isset($data['module_mode'])) ? $data['module_mode'] : '', - 'module_auth' => (isset($data['module_auth'])) ? $data['module_auth'] : '', - ); - - try - { - $this->module_manager->update_module_data($module_data); - - // Success - $module_log_name = ((isset($this->user->lang[$data['module_langname']])) ? $this->user->lang[$data['module_langname']] : $data['module_langname']); - $phpbb_log->add('admin', (isset($user->data['user_id'])) ? $user->data['user_id'] : ANONYMOUS, $user->ip, 'LOG_MODULE_ADD', false, array($module_log_name)); - - // Move the module if requested above/below an existing one - if (isset($data['before']) && $data['before']) - { - $before_mode = $before_langname = ''; - if (is_array($data['before'])) - { - // Restore legacy-legacy behaviour from phpBB 3.0 - list($before_mode, $before_langname) = $data['before']; - } - else - { - // Legacy behaviour from phpBB 3.1+ - $before_langname = $data['before']; - } - - $sql = 'SELECT left_id - FROM ' . $this->modules_table . " - WHERE module_class = '" . $this->db->sql_escape($class) . "' - AND parent_id = " . (int) $parent . " - AND module_langname = '" . $this->db->sql_escape($before_langname) . "'" - . (($before_mode) ? " AND module_mode = '" . $this->db->sql_escape($before_mode) . "'" : ''); - $result = $this->db->sql_query($sql); - $to_left = (int) $this->db->sql_fetchfield('left_id'); - $this->db->sql_freeresult($result); - - $sql = 'UPDATE ' . $this->modules_table . " - SET left_id = left_id + 2, right_id = right_id + 2 - WHERE module_class = '" . $this->db->sql_escape($class) . "' - AND left_id >= $to_left - AND left_id < {$module_data['left_id']}"; - $this->db->sql_query($sql); - - $sql = 'UPDATE ' . $this->modules_table . " - SET left_id = $to_left, right_id = " . ($to_left + 1) . " - WHERE module_class = '" . $this->db->sql_escape($class) . "' - AND module_id = {$module_data['module_id']}"; - $this->db->sql_query($sql); - } - else if (isset($data['after']) && $data['after']) - { - $after_mode = $after_langname = ''; - if (is_array($data['after'])) - { - // Restore legacy-legacy behaviour from phpBB 3.0 - list($after_mode, $after_langname) = $data['after']; - } - else - { - // Legacy behaviour from phpBB 3.1+ - $after_langname = $data['after']; - } - - $sql = 'SELECT right_id - FROM ' . $this->modules_table . " - WHERE module_class = '" . $this->db->sql_escape($class) . "' - AND parent_id = " . (int) $parent . " - AND module_langname = '" . $this->db->sql_escape($after_langname) . "'" - . (($after_mode) ? " AND module_mode = '" . $this->db->sql_escape($after_mode) . "'" : ''); - $result = $this->db->sql_query($sql); - $to_right = (int) $this->db->sql_fetchfield('right_id'); - $this->db->sql_freeresult($result); - - $sql = 'UPDATE ' . $this->modules_table . " - SET left_id = left_id + 2, right_id = right_id + 2 - WHERE module_class = '" . $this->db->sql_escape($class) . "' - AND left_id >= $to_right - AND left_id < {$module_data['left_id']}"; - $this->db->sql_query($sql); - - $sql = 'UPDATE ' . $this->modules_table . ' - SET left_id = ' . ($to_right + 1) . ', right_id = ' . ($to_right + 2) . " - WHERE module_class = '" . $this->db->sql_escape($class) . "' - AND module_id = {$module_data['module_id']}"; - $this->db->sql_query($sql); - } - } - catch (module_exception $e) - { - // Error - throw new \phpbb\db\migration\exception('MODULE_ERROR', $e->getMessage()); - } - } - - // Clear the Modules Cache - $this->module_manager->remove_cache_file($class); - } - - /** - * Module Remove - * - * Remove a module - * - * @param string $class The module class(acp|mcp|ucp) - * @param int|string|bool $parent The parent module_id|module_langname(0 for no parent). - * Use false to ignore the parent check and check class wide. - * @param int|string $module The module id|module_langname - * specify that here - * @return null - * @throws \phpbb\db\migration\exception - */ - public function remove($class, $parent = 0, $module = '') - { - // Imitation of module_add's "automatic" and "manual" method so the uninstaller works from the same set of instructions for umil_auto - if (is_array($module)) - { - if (isset($module['module_langname'])) - { - // Manual Method - return $this->remove($class, $parent, $module['module_langname']); - } - - // Failed. - if (!isset($module['module_basename'])) - { - throw new \phpbb\db\migration\exception('MODULE_NOT_EXIST'); - } - - // Automatic method - $basename = $module['module_basename']; - $module_info = $this->get_module_info($class, $basename); - - foreach ($module_info['modes'] as $mode => $info) - { - if (!isset($module['modes']) || in_array($mode, $module['modes'])) - { - $this->remove($class, $parent, $info['title']); - } - } - } - else - { - if (!$this->exists($class, $parent, $module, true)) - { - return; - } - - $parent_sql = ''; - if ($parent !== false) - { - $parents = (array) $this->get_parent_module_id($parent, $module); - $parent_sql = 'AND ' . $this->db->sql_in_set('parent_id', $parents); - } - - $module_ids = array(); - if (!is_numeric($module)) - { - $sql = 'SELECT module_id - FROM ' . $this->modules_table . " - WHERE module_langname = '" . $this->db->sql_escape($module) . "' - AND module_class = '" . $this->db->sql_escape($class) . "' - $parent_sql"; - $result = $this->db->sql_query($sql); - while ($module_id = $this->db->sql_fetchfield('module_id')) - { - $module_ids[] = (int) $module_id; - } - $this->db->sql_freeresult($result); - } - else - { - $module_ids[] = (int) $module; - } - - foreach ($module_ids as $module_id) - { - $this->module_manager->delete_module($module_id, $class); - } - - $this->module_manager->remove_cache_file($class); - } - } - - /** - * {@inheritdoc} - */ - public function reverse() - { - $arguments = func_get_args(); - $original_call = array_shift($arguments); - - $call = false; - switch ($original_call) - { - case 'add': - $call = 'remove'; - break; - - case 'remove': - $call = 'add'; - break; - - case 'reverse': - // Reversing a reverse is just the call itself - $call = array_shift($arguments); - break; - } - - if ($call) - { - return call_user_func_array(array(&$this, $call), $arguments); - } - } - - /** - * Wrapper for \acp_modules::get_module_infos() - * - * @param string $class Module Class - * @param string $basename Module Basename - * @return array Module Information - * @throws \phpbb\db\migration\exception - */ - protected function get_module_info($class, $basename) - { - $module = $this->module_manager->get_module_infos($class, $basename, true); - - if (empty($module)) - { - throw new \phpbb\db\migration\exception('MODULE_INFO_FILE_NOT_EXIST', $class, $basename); - } - - return array_pop($module); - } - - /** - * Get the list of installed module categories - * key - module_id - * value - module_langname - * - * @return null - */ - protected function get_categories_list() - { - // Select the top level categories - // and 2nd level [sub]categories - $sql = 'SELECT m2.module_id, m2.module_langname - FROM ' . $this->modules_table . ' m1, ' . $this->modules_table . " m2 - WHERE m1.parent_id = 0 - AND (m1.module_id = m2.module_id OR m2.parent_id = m1.module_id) - ORDER BY m1.module_id, m2.module_id ASC"; - - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - $this->module_categories[(int) $row['module_id']] = $row['module_langname']; - } - $this->db->sql_freeresult($result); - } - - /** - * Get parent module id - * - * @param string|int $parent_id The parent module_id|module_langname - * @param int|string|array $data The module_id, module_langname for existance checking or module data array for adding - * @param bool $throw_exception The flag indicating if exception should be thrown on error - * @return mixed The int parent module_id, an array of int parent module_id values or false - * @throws \phpbb\db\migration\exception - */ - public function get_parent_module_id($parent_id, $data = '', $throw_exception = true) - { - // Allow '' to be sent as 0 - $parent_id = $parent_id ?: 0; - - if (!is_numeric($parent_id)) - { - // Refresh the $module_categories array - $this->get_categories_list(); - - // Search for the parent module_langname - $ids = array_keys($this->module_categories, $parent_id); - - switch (count($ids)) - { - // No parent with the given module_langname exist - case 0: - if ($throw_exception) - { - throw new \phpbb\db\migration\exception('MODULE_NOT_EXIST', $parent_id); - } - - return false; - break; - - // Return the module id - case 1: - return (int) $ids[0]; - break; - - default: - // This represents the old behaviour of phpBB 3.0 - return $ids; - break; - } - } - - return $parent_id; - } -} diff --git a/install/update/old/phpbb/db/migrator.php b/install/update/old/phpbb/db/migrator.php deleted file mode 100644 index 2b0c66f..0000000 --- a/install/update/old/phpbb/db/migrator.php +++ /dev/null @@ -1,1037 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\db; - -use phpbb\db\output_handler\migrator_output_handler_interface; -use phpbb\db\output_handler\null_migrator_output_handler; -use Symfony\Component\DependencyInjection\ContainerAwareInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; - -/** -* The migrator is responsible for applying new migrations in the correct order. -*/ -class migrator -{ - /** - * @var ContainerInterface - */ - protected $container; - - /** @var \phpbb\config\config */ - protected $config; - - /** @var \phpbb\db\driver\driver_interface */ - protected $db; - - /** @var \phpbb\db\tools\tools_interface */ - protected $db_tools; - - /** @var \phpbb\db\migration\helper */ - protected $helper; - - /** @var string */ - protected $table_prefix; - - /** @var string */ - protected $phpbb_root_path; - - /** @var string */ - protected $php_ext; - - /** @var string */ - protected $migrations_table; - - /** - * State of all migrations - * - * (SELECT * FROM migrations table) - * - * @var array - */ - protected $migration_state = array(); - - /** - * Array of all migrations available to be run - * - * @var array - */ - protected $migrations = array(); - - /** - * Array of migrations that have been determined to be fulfillable - * - * @var array - */ - protected $fulfillable_migrations = array(); - - /** - * 'name,' 'class,' and 'state' of the last migration run - * - * 'effectively_installed' set and set to true if the migration was effectively_installed - * - * @var array - */ - protected $last_run_migration = false; - - /** - * The output handler. A null handler is configured by default. - * - * @var migrator_output_handler_interface - */ - protected $output_handler; - - /** - * Constructor of the database migrator - */ - public function __construct(ContainerInterface $container, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\db\tools\tools_interface $db_tools, $migrations_table, $phpbb_root_path, $php_ext, $table_prefix, $tools, \phpbb\db\migration\helper $helper) - { - $this->container = $container; - $this->config = $config; - $this->db = $db; - $this->db_tools = $db_tools; - $this->helper = $helper; - - $this->migrations_table = $migrations_table; - - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - - $this->table_prefix = $table_prefix; - - $this->output_handler = new null_migrator_output_handler(); - - foreach ($tools as $tool) - { - $this->tools[$tool->get_name()] = $tool; - } - - $this->tools['dbtools'] = $this->db_tools; - - $this->load_migration_state(); - } - - /** - * Set the output handler. - * - * @param migrator_output_handler_interface $handler The output handler - */ - public function set_output_handler(migrator_output_handler_interface $handler) - { - $this->output_handler = $handler; - } - - /** - * Loads all migrations and their application state from the database. - * - * @return null - */ - public function load_migration_state() - { - $this->migration_state = array(); - - // prevent errors in case the table does not exist yet - $this->db->sql_return_on_error(true); - - $sql = "SELECT * - FROM " . $this->migrations_table; - $result = $this->db->sql_query($sql); - - if (!$this->db->get_sql_error_triggered()) - { - while ($migration = $this->db->sql_fetchrow($result)) - { - $this->migration_state[$migration['migration_name']] = $migration; - - $this->migration_state[$migration['migration_name']]['migration_depends_on'] = unserialize($migration['migration_depends_on']); - $this->migration_state[$migration['migration_name']]['migration_data_state'] = !empty($migration['migration_data_state']) ? unserialize($migration['migration_data_state']) : ''; - } - } - - $this->db->sql_freeresult($result); - - $this->db->sql_return_on_error(false); - } - - /** - * Get an array with information about the last migration run. - * - * The array contains 'name', 'class' and 'state'. 'effectively_installed' is set - * and set to true if the last migration was effectively_installed. - * - * @return array - */ - public function get_last_run_migration() - { - return $this->last_run_migration; - } - - /** - * Sets the list of available migration class names to the given array. - * - * @param array $class_names An array of migration class names - * @return null - */ - public function set_migrations($class_names) - { - foreach ($class_names as $key => $class) - { - if (!self::is_migration($class)) - { - unset($class_names[$key]); - } - } - - $this->migrations = $class_names; - } - - /** - * Get the list of available migration class names - * - * @return array Array of all migrations available to be run - */ - public function get_migrations() - { - return $this->migrations; - } - - /** - * Get the list of available and not installed migration class names - * - * @return array - */ - public function get_installable_migrations() - { - $unfinished_migrations = array(); - - foreach ($this->migrations as $name) - { - if (!isset($this->migration_state[$name]) || - !$this->migration_state[$name]['migration_schema_done'] || - !$this->migration_state[$name]['migration_data_done']) - { - $unfinished_migrations[] = $name; - } - } - - return $unfinished_migrations; - } - - /** - * Runs a single update step from the next migration to be applied. - * - * The update step can either be a schema or a (partial) data update. To - * check if update() needs to be called again use the finished() method. - * - * @return null - */ - public function update() - { - $this->container->get('dispatcher')->disable(); - $this->update_do(); - $this->container->get('dispatcher')->enable(); - } - - /** - * Get a valid migration name from the migration state array in case the - * supplied name is not in the migration state list. - * - * @param string $name Migration name - * @return string Migration name - */ - protected function get_valid_name($name) - { - // Try falling back to a valid migration name with or without leading backslash - if (!isset($this->migration_state[$name])) - { - $prepended_name = ($name[0] == '\\' ? '' : '\\') . $name; - $prefixless_name = $name[0] == '\\' ? substr($name, 1) : $name; - - if (isset($this->migration_state[$prepended_name])) - { - $name = $prepended_name; - } - else if (isset($this->migration_state[$prefixless_name])) - { - $name = $prefixless_name; - } - } - - return $name; - } - - /** - * Effectively runs a single update step from the next migration to be applied. - * - * @return null - */ - protected function update_do() - { - foreach ($this->migrations as $name) - { - $name = $this->get_valid_name($name); - - if (!isset($this->migration_state[$name]) || - !$this->migration_state[$name]['migration_schema_done'] || - !$this->migration_state[$name]['migration_data_done']) - { - if (!$this->try_apply($name)) - { - continue; - } - else - { - return; - } - } - else - { - $this->output_handler->write(array('MIGRATION_EFFECTIVELY_INSTALLED', $name), migrator_output_handler_interface::VERBOSITY_DEBUG); - } - } - } - - /** - * Attempts to apply a step of the given migration or one of its dependencies - * - * @param string $name The class name of the migration - * @return bool Whether any update step was successfully run - * @throws \phpbb\db\migration\exception - */ - protected function try_apply($name) - { - if (!class_exists($name)) - { - $this->output_handler->write(array('MIGRATION_NOT_VALID', $name), migrator_output_handler_interface::VERBOSITY_DEBUG); - return false; - } - - $migration = $this->get_migration($name); - - $state = (isset($this->migration_state[$name])) ? - $this->migration_state[$name] : - array( - 'migration_depends_on' => $migration->depends_on(), - 'migration_schema_done' => false, - 'migration_data_done' => false, - 'migration_data_state' => '', - 'migration_start_time' => 0, - 'migration_end_time' => 0, - ); - - if (!empty($state['migration_depends_on'])) - { - $this->output_handler->write(array('MIGRATION_APPLY_DEPENDENCIES', $name), migrator_output_handler_interface::VERBOSITY_DEBUG); - } - - foreach ($state['migration_depends_on'] as $depend) - { - $depend = $this->get_valid_name($depend); - - // Test all possible namings before throwing exception - if ($this->unfulfillable($depend) !== false) - { - throw new \phpbb\db\migration\exception('MIGRATION_NOT_FULFILLABLE', $name, $depend); - } - - if (!isset($this->migration_state[$depend]) || - !$this->migration_state[$depend]['migration_schema_done'] || - !$this->migration_state[$depend]['migration_data_done']) - { - return $this->try_apply($depend); - } - } - - $this->last_run_migration = array( - 'name' => $name, - 'class' => $migration, - 'state' => $state, - 'task' => '', - ); - - if (!isset($this->migration_state[$name])) - { - if ($state['migration_start_time'] == 0 && $migration->effectively_installed()) - { - $state = array( - 'migration_depends_on' => $migration->depends_on(), - 'migration_schema_done' => true, - 'migration_data_done' => true, - 'migration_data_state' => '', - 'migration_start_time' => 0, - 'migration_end_time' => 0, - ); - - $this->last_run_migration['effectively_installed'] = true; - - $this->output_handler->write(array('MIGRATION_EFFECTIVELY_INSTALLED', $name), migrator_output_handler_interface::VERBOSITY_VERBOSE); - } - else - { - $state['migration_start_time'] = time(); - } - } - - $this->set_migration_state($name, $state); - - if (!$state['migration_schema_done']) - { - $verbosity = empty($state['migration_data_state']) ? - migrator_output_handler_interface::VERBOSITY_VERBOSE : migrator_output_handler_interface::VERBOSITY_DEBUG; - $this->output_handler->write(array('MIGRATION_SCHEMA_RUNNING', $name), $verbosity); - - $this->last_run_migration['task'] = 'process_schema_step'; - - $total_time = (is_array($state['migration_data_state']) && isset($state['migration_data_state']['_total_time'])) ? - $state['migration_data_state']['_total_time'] : 0.0; - $elapsed_time = microtime(true); - - $steps = $this->helper->get_schema_steps($migration->update_schema()); - $result = $this->process_data_step($steps, $state['migration_data_state']); - - $elapsed_time = microtime(true) - $elapsed_time; - $total_time += $elapsed_time; - - if (is_array($result)) - { - $result['_total_time'] = $total_time; - } - - $state['migration_data_state'] = ($result === true) ? '' : $result; - $state['migration_schema_done'] = ($result === true); - - if ($state['migration_schema_done']) - { - $this->output_handler->write(array('MIGRATION_SCHEMA_DONE', $name, $total_time), migrator_output_handler_interface::VERBOSITY_NORMAL); - } - else - { - $this->output_handler->write(array('MIGRATION_SCHEMA_IN_PROGRESS', $name, $elapsed_time), migrator_output_handler_interface::VERBOSITY_VERY_VERBOSE); - } - } - else if (!$state['migration_data_done']) - { - try - { - $verbosity = empty($state['migration_data_state']) ? - migrator_output_handler_interface::VERBOSITY_VERBOSE : migrator_output_handler_interface::VERBOSITY_DEBUG; - $this->output_handler->write(array('MIGRATION_DATA_RUNNING', $name), $verbosity); - - $this->last_run_migration['task'] = 'process_data_step'; - - $total_time = (is_array($state['migration_data_state']) && isset($state['migration_data_state']['_total_time'])) ? - $state['migration_data_state']['_total_time'] : 0.0; - $elapsed_time = microtime(true); - - $result = $this->process_data_step($migration->update_data(), $state['migration_data_state']); - - $elapsed_time = microtime(true) - $elapsed_time; - $total_time += $elapsed_time; - - if (is_array($result)) - { - $result['_total_time'] = $total_time; - } - - $state['migration_data_state'] = ($result === true) ? '' : $result; - $state['migration_data_done'] = ($result === true); - $state['migration_end_time'] = ($result === true) ? time() : 0; - - if ($state['migration_data_done']) - { - $this->output_handler->write(array('MIGRATION_DATA_DONE', $name, $total_time), migrator_output_handler_interface::VERBOSITY_NORMAL); - } - else - { - $this->output_handler->write(array('MIGRATION_DATA_IN_PROGRESS', $name, $elapsed_time), migrator_output_handler_interface::VERBOSITY_VERY_VERBOSE); - } - } - catch (\phpbb\db\migration\exception $e) - { - // Reset data state and revert the schema changes - $state['migration_data_state'] = ''; - $this->set_migration_state($name, $state); - - $this->revert_do($name); - - throw $e; - } - } - - $this->set_migration_state($name, $state); - - return true; - } - - /** - * Runs a single revert step from the last migration installed - * - * YOU MUST ADD/SET ALL MIGRATIONS THAT COULD BE DEPENDENT ON THE MIGRATION TO REVERT TO BEFORE CALLING THIS METHOD! - * The revert step can either be a schema or a (partial) data revert. To - * check if revert() needs to be called again use the migration_state() method. - * - * @param string $migration String migration name to revert (including any that depend on this migration) - */ - public function revert($migration) - { - $this->container->get('dispatcher')->disable(); - $this->revert_do($migration); - $this->container->get('dispatcher')->enable(); - } - - /** - * Effectively runs a single revert step from the last migration installed - * - * @param string $migration String migration name to revert (including any that depend on this migration) - * @return null - */ - protected function revert_do($migration) - { - if (!isset($this->migration_state[$migration])) - { - // Not installed - return; - } - - foreach ($this->migrations as $name) - { - $state = $this->migration_state($name); - - if ($state && in_array($migration, $state['migration_depends_on']) && ($state['migration_schema_done'] || $state['migration_data_done'])) - { - $this->revert_do($name); - return; - } - } - - $this->try_revert($migration); - } - - /** - * Attempts to revert a step of the given migration or one of its dependencies - * - * @param string $name The class name of the migration - * @return bool Whether any update step was successfully run - */ - protected function try_revert($name) - { - if (!class_exists($name)) - { - return false; - } - - $migration = $this->get_migration($name); - - $state = $this->migration_state[$name]; - - $this->last_run_migration = array( - 'name' => $name, - 'class' => $migration, - 'task' => '', - ); - - if ($state['migration_data_done']) - { - $verbosity = empty($state['migration_data_state']) ? - migrator_output_handler_interface::VERBOSITY_VERBOSE : migrator_output_handler_interface::VERBOSITY_DEBUG; - $this->output_handler->write(array('MIGRATION_REVERT_DATA_RUNNING', $name), $verbosity); - - $total_time = (is_array($state['migration_data_state']) && isset($state['migration_data_state']['_total_time'])) ? - $state['migration_data_state']['_total_time'] : 0.0; - $elapsed_time = microtime(true); - - $steps = array_merge($this->helper->reverse_update_data($migration->update_data()), $migration->revert_data()); - $result = $this->process_data_step($steps, $state['migration_data_state']); - - $elapsed_time = microtime(true) - $elapsed_time; - $total_time += $elapsed_time; - - if (is_array($result)) - { - $result['_total_time'] = $total_time; - } - - $state['migration_data_state'] = ($result === true) ? '' : $result; - $state['migration_data_done'] = ($result === true) ? false : true; - - $this->set_migration_state($name, $state); - - if (!$state['migration_data_done']) - { - $this->output_handler->write(array('MIGRATION_REVERT_DATA_DONE', $name, $total_time), migrator_output_handler_interface::VERBOSITY_NORMAL); - } - else - { - $this->output_handler->write(array('MIGRATION_REVERT_DATA_IN_PROGRESS', $name, $elapsed_time), migrator_output_handler_interface::VERBOSITY_VERY_VERBOSE); - } - } - else if ($state['migration_schema_done']) - { - $verbosity = empty($state['migration_data_state']) ? - migrator_output_handler_interface::VERBOSITY_VERBOSE : migrator_output_handler_interface::VERBOSITY_DEBUG; - $this->output_handler->write(array('MIGRATION_REVERT_SCHEMA_RUNNING', $name), $verbosity); - - $total_time = (is_array($state['migration_data_state']) && isset($state['migration_data_state']['_total_time'])) ? - $state['migration_data_state']['_total_time'] : 0.0; - $elapsed_time = microtime(true); - - $steps = $this->helper->get_schema_steps($migration->revert_schema()); - $result = $this->process_data_step($steps, $state['migration_data_state']); - - $elapsed_time = microtime(true) - $elapsed_time; - $total_time += $elapsed_time; - - if (is_array($result)) - { - $result['_total_time'] = $total_time; - } - - $state['migration_data_state'] = ($result === true) ? '' : $result; - $state['migration_schema_done'] = ($result === true) ? false : true; - - if (!$state['migration_schema_done']) - { - $sql = 'DELETE FROM ' . $this->migrations_table . " - WHERE migration_name = '" . $this->db->sql_escape($name) . "'"; - $this->db->sql_query($sql); - - $this->last_run_migration = false; - unset($this->migration_state[$name]); - - $this->output_handler->write(array('MIGRATION_REVERT_SCHEMA_DONE', $name, $total_time), migrator_output_handler_interface::VERBOSITY_NORMAL); - } - else - { - $this->set_migration_state($name, $state); - - $this->output_handler->write(array('MIGRATION_REVERT_SCHEMA_IN_PROGRESS', $name, $elapsed_time), migrator_output_handler_interface::VERBOSITY_VERY_VERBOSE); - } - } - - return true; - } - - /** - * Process the data step of the migration - * - * @param array $steps The steps to run - * @param bool|string $state Current state of the migration - * @param bool $revert true to revert a data step - * @return bool|string migration state. True if completed, serialized array if not finished - * @throws \phpbb\db\migration\exception - */ - protected function process_data_step($steps, $state, $revert = false) - { - if (count($steps) === 0) - { - return true; - } - - $state = is_array($state) ? $state : false; - - // reverse order of steps if reverting - if ($revert === true) - { - $steps = array_reverse($steps); - } - - $step = $last_result = 0; - if ($state) - { - $step = $state['step']; - - // We send the result from last time to the callable function - $last_result = $state['result']; - } - - try - { - // Result will be null or true if everything completed correctly - // Stop after each update step, to let the updater control the script runtime - $result = $this->run_step($steps[$step], $last_result, $revert); - if (($result !== null && $result !== true) || $step + 1 < count($steps)) - { - return array( - 'result' => $result, - // Move on if the last call finished - 'step' => ($result !== null && $result !== true) ? $step : $step + 1, - ); - } - } - catch (\phpbb\db\migration\exception $e) - { - // We should try rolling back here - foreach ($steps as $reverse_step_identifier => $reverse_step) - { - // If we've reached the current step we can break because we reversed everything that was run - if ($reverse_step_identifier == $step) - { - break; - } - - // Reverse the step that was run - $result = $this->run_step($reverse_step, false, !$revert); - } - - throw $e; - } - - return true; - } - - /** - * Run a single step - * - * An exception should be thrown if an error occurs - * - * @param mixed $step Data step from migration - * @param mixed $last_result Result to pass to the callable (only for 'custom' method) - * @param bool $reverse False to install, True to attempt uninstallation by reversing the call - * @return null - */ - protected function run_step($step, $last_result = 0, $reverse = false) - { - $callable_and_parameters = $this->get_callable_from_step($step, $last_result, $reverse); - - if ($callable_and_parameters === false) - { - return; - } - - $callable = $callable_and_parameters[0]; - $parameters = $callable_and_parameters[1]; - - return call_user_func_array($callable, $parameters); - } - - /** - * Get a callable statement from a data step - * - * @param array $step Data step from migration - * @param mixed $last_result Result to pass to the callable (only for 'custom' method) - * @param bool $reverse False to install, True to attempt uninstallation by reversing the call - * @return array Array with parameters for call_user_func_array(), 0 is the callable, 1 is parameters - * @throws \phpbb\db\migration\exception - */ - protected function get_callable_from_step(array $step, $last_result = 0, $reverse = false) - { - $type = $step[0]; - $parameters = $step[1]; - - $parts = explode('.', $type); - - $class = $parts[0]; - $method = false; - - if (isset($parts[1])) - { - $method = $parts[1]; - } - - switch ($class) - { - case 'if': - if (!isset($parameters[0])) - { - throw new \phpbb\db\migration\exception('MIGRATION_INVALID_DATA_MISSING_CONDITION', $step); - } - - if (!isset($parameters[1])) - { - throw new \phpbb\db\migration\exception('MIGRATION_INVALID_DATA_MISSING_STEP', $step); - } - - if ($reverse) - { - // We might get unexpected results when trying - // to revert this, so just avoid it - return false; - } - - $condition = $parameters[0]; - - if (!$condition || (is_array($condition) && !$this->run_step($condition, $last_result, $reverse))) - { - return false; - } - - $step = $parameters[1]; - - return $this->get_callable_from_step($step); - break; - - case 'custom': - if (!is_callable($parameters[0])) - { - throw new \phpbb\db\migration\exception('MIGRATION_INVALID_DATA_CUSTOM_NOT_CALLABLE', $step); - } - - if ($reverse) - { - return false; - } - else - { - return array( - $parameters[0], - array($last_result), - ); - } - break; - - default: - if (!$method) - { - throw new \phpbb\db\migration\exception('MIGRATION_INVALID_DATA_UNKNOWN_TYPE', $step); - } - - if (!isset($this->tools[$class])) - { - throw new \phpbb\db\migration\exception('MIGRATION_INVALID_DATA_UNDEFINED_TOOL', $step); - } - - if (!method_exists(get_class($this->tools[$class]), $method)) - { - throw new \phpbb\db\migration\exception('MIGRATION_INVALID_DATA_UNDEFINED_METHOD', $step); - } - - // Attempt to reverse operations - if ($reverse) - { - array_unshift($parameters, $method); - - return array( - array($this->tools[$class], 'reverse'), - $parameters, - ); - } - - return array( - array($this->tools[$class], $method), - $parameters, - ); - break; - } - } - - /** - * Insert/Update migration row into the database - * - * @param string $name Name of the migration - * @param array $state - * @return null - */ - protected function set_migration_state($name, $state) - { - $migration_row = $state; - $migration_row['migration_depends_on'] = serialize($state['migration_depends_on']); - $migration_row['migration_data_state'] = !empty($state['migration_data_state']) ? serialize($state['migration_data_state']) : ''; - - if (isset($this->migration_state[$name])) - { - $sql = 'UPDATE ' . $this->migrations_table . ' - SET ' . $this->db->sql_build_array('UPDATE', $migration_row) . " - WHERE migration_name = '" . $this->db->sql_escape($name) . "'"; - $this->db->sql_query($sql); - } - else - { - $migration_row['migration_name'] = $name; - $sql = 'INSERT INTO ' . $this->migrations_table . ' - ' . $this->db->sql_build_array('INSERT', $migration_row); - $this->db->sql_query($sql); - } - - $this->migration_state[$name] = $state; - - $this->last_run_migration['state'] = $state; - } - - /** - * Checks if a migration's dependencies can even theoretically be satisfied. - * - * @param string $name The class name of the migration - * @return bool|string False if fulfillable, string of missing migration name if unfulfillable - */ - public function unfulfillable($name) - { - $name = $this->get_valid_name($name); - - if (isset($this->migration_state[$name]) || isset($this->fulfillable_migrations[$name])) - { - return false; - } - - if (!class_exists($name)) - { - return $name; - } - - $migration = $this->get_migration($name); - $depends = $migration->depends_on(); - - foreach ($depends as $depend) - { - $depend = $this->get_valid_name($depend); - $unfulfillable = $this->unfulfillable($depend); - if ($unfulfillable !== false) - { - return $unfulfillable; - } - } - $this->fulfillable_migrations[$name] = true; - - return false; - } - - /** - * Checks whether all available, fulfillable migrations have been applied. - * - * @return bool Whether the migrations have been applied - */ - public function finished() - { - foreach ($this->migrations as $name) - { - if (!isset($this->migration_state[$name])) - { - // skip unfulfillable migrations, but fulfillables mean we - // are not finished yet - if ($this->unfulfillable($name) !== false) - { - continue; - } - - return false; - } - - $migration = $this->migration_state[$name]; - - if (!$migration['migration_schema_done'] || !$migration['migration_data_done']) - { - return false; - } - } - - return true; - } - - /** - * Gets a migration state (whether it is installed and to what extent) - * - * @param string $migration String migration name to check if it is installed - * @return bool|array False if the migration has not at all been installed, array - */ - public function migration_state($migration) - { - if (!isset($this->migration_state[$migration])) - { - return false; - } - - return $this->migration_state[$migration]; - } - - /** - * Helper to get a migration - * - * @param string $name Name of the migration - * @return \phpbb\db\migration\migration - */ - protected function get_migration($name) - { - $migration = new $name($this->config, $this->db, $this->db_tools, $this->phpbb_root_path, $this->php_ext, $this->table_prefix); - - if ($migration instanceof ContainerAwareInterface) - { - $migration->setContainer($this->container); - } - - return $migration; - } - - /** - * This function adds all migrations sent to it to the migrations table - * - * THIS SHOULD NOT GENERALLY BE USED! THIS IS FOR THE PHPBB INSTALLER. - * THIS WILL THROW ERRORS IF MIGRATIONS ALREADY EXIST IN THE TABLE, DO NOT CALL MORE THAN ONCE! - * - * @param array $migrations Array of migrations (names) to add to the migrations table - * @return null - */ - public function populate_migrations($migrations) - { - foreach ($migrations as $name) - { - if ($this->migration_state($name) === false) - { - $state = array( - 'migration_depends_on' => $name::depends_on(), - 'migration_schema_done' => true, - 'migration_data_done' => true, - 'migration_data_state' => '', - 'migration_start_time' => time(), - 'migration_end_time' => time(), - ); - $this->set_migration_state($name, $state); - } - } - } - - /** - * Creates the migrations table if it does not exist. - * @return null - */ - public function create_migrations_table() - { - // Make sure migrations have been installed. - if (!$this->db_tools->sql_table_exists($this->table_prefix . 'migrations')) - { - $this->db_tools->sql_create_table($this->table_prefix . 'migrations', array( - 'COLUMNS' => array( - 'migration_name' => array('VCHAR', ''), - 'migration_depends_on' => array('TEXT', ''), - 'migration_schema_done' => array('BOOL', 0), - 'migration_data_done' => array('BOOL', 0), - 'migration_data_state' => array('TEXT', ''), - 'migration_start_time' => array('TIMESTAMP', 0), - 'migration_end_time' => array('TIMESTAMP', 0), - ), - 'PRIMARY_KEY' => 'migration_name', - )); - } - } - - /** - * Check if a class is a migration. - * - * @param string $migration A migration class name - * @return bool Return true if class is a migration, false otherwise - */ - static public function is_migration($migration) - { - if (class_exists($migration)) - { - // Migration classes should extend the abstract class - // phpbb\db\migration\migration (which implements the - // migration_interface) and be instantiable. - $reflector = new \ReflectionClass($migration); - if ($reflector->implementsInterface('\phpbb\db\migration\migration_interface') && $reflector->isInstantiable()) - { - return true; - } - } - - return false; - } -} diff --git a/install/update/old/phpbb/db/tools/mssql.php b/install/update/old/phpbb/db/tools/mssql.php deleted file mode 100644 index cbedf9a..0000000 --- a/install/update/old/phpbb/db/tools/mssql.php +++ /dev/null @@ -1,880 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\db\tools; - -/** - * Database Tools for handling cross-db actions such as altering columns, etc. - * Currently not supported is returning SQL for creating tables. - */ -class mssql extends tools -{ - /** - * Is the used MS SQL Server a SQL Server 2000? - * @var bool - */ - protected $is_sql_server_2000; - - /** - * Get the column types for mssql based databases - * - * @return array - */ - public static function get_dbms_type_map() - { - return array( - 'mssql' => array( - 'INT:' => '[int]', - 'BINT' => '[float]', - 'ULINT' => '[int]', - 'UINT' => '[int]', - 'UINT:' => '[int]', - 'TINT:' => '[int]', - 'USINT' => '[int]', - 'BOOL' => '[int]', - 'VCHAR' => '[varchar] (255)', - 'VCHAR:' => '[varchar] (%d)', - 'CHAR:' => '[char] (%d)', - 'XSTEXT' => '[varchar] (1000)', - 'STEXT' => '[varchar] (3000)', - 'TEXT' => '[varchar] (8000)', - 'MTEXT' => '[text]', - 'XSTEXT_UNI'=> '[nvarchar] (100)', - 'STEXT_UNI' => '[nvarchar] (255)', - 'TEXT_UNI' => '[nvarchar] (4000)', - 'MTEXT_UNI' => '[ntext]', - 'TIMESTAMP' => '[int]', - 'DECIMAL' => '[float]', - 'DECIMAL:' => '[float]', - 'PDECIMAL' => '[float]', - 'PDECIMAL:' => '[float]', - 'VCHAR_UNI' => '[nvarchar] (255)', - 'VCHAR_UNI:'=> '[nvarchar] (%d)', - 'VCHAR_CI' => '[nvarchar] (255)', - 'VARBINARY' => '[varchar] (255)', - ), - - 'mssqlnative' => array( - 'INT:' => '[int]', - 'BINT' => '[float]', - 'ULINT' => '[int]', - 'UINT' => '[int]', - 'UINT:' => '[int]', - 'TINT:' => '[int]', - 'USINT' => '[int]', - 'BOOL' => '[int]', - 'VCHAR' => '[varchar] (255)', - 'VCHAR:' => '[varchar] (%d)', - 'CHAR:' => '[char] (%d)', - 'XSTEXT' => '[varchar] (1000)', - 'STEXT' => '[varchar] (3000)', - 'TEXT' => '[varchar] (8000)', - 'MTEXT' => '[text]', - 'XSTEXT_UNI'=> '[nvarchar] (100)', - 'STEXT_UNI' => '[nvarchar] (255)', - 'TEXT_UNI' => '[nvarchar] (4000)', - 'MTEXT_UNI' => '[ntext]', - 'TIMESTAMP' => '[int]', - 'DECIMAL' => '[float]', - 'DECIMAL:' => '[float]', - 'PDECIMAL' => '[float]', - 'PDECIMAL:' => '[float]', - 'VCHAR_UNI' => '[nvarchar] (255)', - 'VCHAR_UNI:'=> '[nvarchar] (%d)', - 'VCHAR_CI' => '[nvarchar] (255)', - 'VARBINARY' => '[varchar] (255)', - ), - ); - } - - /** - * Constructor. Set DB Object and set {@link $return_statements return_statements}. - * - * @param \phpbb\db\driver\driver_interface $db Database connection - * @param bool $return_statements True if only statements should be returned and no SQL being executed - */ - public function __construct(\phpbb\db\driver\driver_interface $db, $return_statements = false) - { - parent::__construct($db, $return_statements); - - // Determine mapping database type - switch ($this->db->get_sql_layer()) - { - case 'mssql_odbc': - $this->sql_layer = 'mssql'; - break; - - case 'mssqlnative': - $this->sql_layer = 'mssqlnative'; - break; - } - - $this->dbms_type_map = self::get_dbms_type_map(); - } - - /** - * {@inheritDoc} - */ - function sql_list_tables() - { - $sql = "SELECT name - FROM sysobjects - WHERE type='U'"; - $result = $this->db->sql_query($sql); - - $tables = array(); - while ($row = $this->db->sql_fetchrow($result)) - { - $name = current($row); - $tables[$name] = $name; - } - $this->db->sql_freeresult($result); - - return $tables; - } - - /** - * {@inheritDoc} - */ - function sql_create_table($table_name, $table_data) - { - // holds the DDL for a column - $columns = $statements = array(); - - if ($this->sql_table_exists($table_name)) - { - return $this->_sql_run_sql($statements); - } - - // Begin transaction - $statements[] = 'begin'; - - // Determine if we have created a PRIMARY KEY in the earliest - $primary_key_gen = false; - - // Determine if the table requires a sequence - $create_sequence = false; - - // Begin table sql statement - $table_sql = 'CREATE TABLE [' . $table_name . '] (' . "\n"; - - if (!isset($table_data['PRIMARY_KEY'])) - { - $table_data['COLUMNS']['mssqlindex'] = array('UINT', null, 'auto_increment'); - $table_data['PRIMARY_KEY'] = 'mssqlindex'; - } - - // Iterate through the columns to create a table - foreach ($table_data['COLUMNS'] as $column_name => $column_data) - { - // here lies an array, filled with information compiled on the column's data - $prepared_column = $this->sql_prepare_column_data($table_name, $column_name, $column_data); - - if (isset($prepared_column['auto_increment']) && $prepared_column['auto_increment'] && strlen($column_name) > 26) // "${column_name}_gen" - { - trigger_error("Index name '${column_name}_gen' on table '$table_name' is too long. The maximum auto increment column length is 26 characters.", E_USER_ERROR); - } - - // here we add the definition of the new column to the list of columns - $columns[] = "\t [{$column_name}] " . $prepared_column['column_type_sql_default']; - - // see if we have found a primary key set due to a column definition if we have found it, we can stop looking - if (!$primary_key_gen) - { - $primary_key_gen = isset($prepared_column['primary_key_set']) && $prepared_column['primary_key_set']; - } - - // create sequence DDL based off of the existance of auto incrementing columns - if (!$create_sequence && isset($prepared_column['auto_increment']) && $prepared_column['auto_increment']) - { - $create_sequence = $column_name; - } - } - - // this makes up all the columns in the create table statement - $table_sql .= implode(",\n", $columns); - - // Close the table for two DBMS and add to the statements - $table_sql .= "\n);"; - $statements[] = $table_sql; - - // we have yet to create a primary key for this table, - // this means that we can add the one we really wanted instead - if (!$primary_key_gen) - { - // Write primary key - if (isset($table_data['PRIMARY_KEY'])) - { - if (!is_array($table_data['PRIMARY_KEY'])) - { - $table_data['PRIMARY_KEY'] = array($table_data['PRIMARY_KEY']); - } - - // We need the data here - $old_return_statements = $this->return_statements; - $this->return_statements = true; - - $primary_key_stmts = $this->sql_create_primary_key($table_name, $table_data['PRIMARY_KEY']); - foreach ($primary_key_stmts as $pk_stmt) - { - $statements[] = $pk_stmt; - } - - $this->return_statements = $old_return_statements; - } - } - - // Write Keys - if (isset($table_data['KEYS'])) - { - foreach ($table_data['KEYS'] as $key_name => $key_data) - { - if (!is_array($key_data[1])) - { - $key_data[1] = array($key_data[1]); - } - - $old_return_statements = $this->return_statements; - $this->return_statements = true; - - $key_stmts = ($key_data[0] == 'UNIQUE') ? $this->sql_create_unique_index($table_name, $key_name, $key_data[1]) : $this->sql_create_index($table_name, $key_name, $key_data[1]); - - foreach ($key_stmts as $key_stmt) - { - $statements[] = $key_stmt; - } - - $this->return_statements = $old_return_statements; - } - } - - // Commit Transaction - $statements[] = 'commit'; - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritDoc} - */ - function sql_list_columns($table_name) - { - $columns = array(); - - $sql = "SELECT c.name - FROM syscolumns c - LEFT JOIN sysobjects o ON c.id = o.id - WHERE o.name = '{$table_name}'"; - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - $column = strtolower(current($row)); - $columns[$column] = $column; - } - $this->db->sql_freeresult($result); - - return $columns; - } - - /** - * {@inheritDoc} - */ - function sql_index_exists($table_name, $index_name) - { - $sql = "EXEC sp_statistics '$table_name'"; - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - if ($row['TYPE'] == 3) - { - if (strtolower($row['INDEX_NAME']) == strtolower($index_name)) - { - $this->db->sql_freeresult($result); - return true; - } - } - } - $this->db->sql_freeresult($result); - - return false; - } - - /** - * {@inheritDoc} - */ - function sql_unique_index_exists($table_name, $index_name) - { - $sql = "EXEC sp_statistics '$table_name'"; - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - // Usually NON_UNIQUE is the column we want to check, but we allow for both - if ($row['TYPE'] == 3) - { - if (strtolower($row['INDEX_NAME']) == strtolower($index_name)) - { - $this->db->sql_freeresult($result); - return true; - } - } - } - $this->db->sql_freeresult($result); - - return false; - } - - /** - * {@inheritDoc} - */ - function sql_prepare_column_data($table_name, $column_name, $column_data) - { - if (strlen($column_name) > 30) - { - trigger_error("Column name '$column_name' on table '$table_name' is too long. The maximum is 30 characters.", E_USER_ERROR); - } - - // Get type - list($column_type, ) = $this->get_column_type($column_data[0]); - - // Adjust default value if db-dependent specified - if (is_array($column_data[1])) - { - $column_data[1] = (isset($column_data[1][$this->sql_layer])) ? $column_data[1][$this->sql_layer] : $column_data[1]['default']; - } - - $sql = ''; - - $return_array = array(); - - $sql .= " {$column_type} "; - $sql_default = " {$column_type} "; - - // For adding columns we need the default definition - if (!is_null($column_data[1])) - { - // For hexadecimal values do not use single quotes - if (strpos($column_data[1], '0x') === 0) - { - $return_array['default'] = 'DEFAULT (' . $column_data[1] . ') '; - $sql_default .= $return_array['default']; - } - else - { - $return_array['default'] = 'DEFAULT (' . ((is_numeric($column_data[1])) ? $column_data[1] : "'{$column_data[1]}'") . ') '; - $sql_default .= $return_array['default']; - } - } - - if (isset($column_data[2]) && $column_data[2] == 'auto_increment') - { - // $sql .= 'IDENTITY (1, 1) '; - $sql_default .= 'IDENTITY (1, 1) '; - } - - $return_array['textimage'] = $column_type === '[text]'; - - if (!is_null($column_data[1]) || (isset($column_data[2]) && $column_data[2] == 'auto_increment')) - { - $sql .= 'NOT NULL'; - $sql_default .= 'NOT NULL'; - } - else - { - $sql .= 'NULL'; - $sql_default .= 'NULL'; - } - - $return_array['column_type_sql_default'] = $sql_default; - - $return_array['column_type_sql'] = $sql; - - return $return_array; - } - - /** - * {@inheritDoc} - */ - function sql_column_add($table_name, $column_name, $column_data, $inline = false) - { - $column_data = $this->sql_prepare_column_data($table_name, $column_name, $column_data); - $statements = array(); - - // Does not support AFTER, only through temporary table - $statements[] = 'ALTER TABLE [' . $table_name . '] ADD [' . $column_name . '] ' . $column_data['column_type_sql_default']; - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritDoc} - */ - function sql_column_remove($table_name, $column_name, $inline = false) - { - $statements = array(); - - // We need the data here - $old_return_statements = $this->return_statements; - $this->return_statements = true; - - $indexes = $this->get_existing_indexes($table_name, $column_name); - $indexes = array_merge($indexes, $this->get_existing_indexes($table_name, $column_name, true)); - - // Drop any indexes - $recreate_indexes = array(); - if (!empty($indexes)) - { - foreach ($indexes as $index_name => $index_data) - { - $result = $this->sql_index_drop($table_name, $index_name); - $statements = array_merge($statements, $result); - if (count($index_data) > 1) - { - // Remove this column from the index and recreate it - $recreate_indexes[$index_name] = array_diff($index_data, array($column_name)); - } - } - } - - // Drop primary keys depending on this column - $result = $this->mssql_get_drop_default_primary_key_queries($table_name, $column_name); - $statements = array_merge($statements, $result); - - // Drop default value constraint - $result = $this->mssql_get_drop_default_constraints_queries($table_name, $column_name); - $statements = array_merge($statements, $result); - - // Remove the column - $statements[] = 'ALTER TABLE [' . $table_name . '] DROP COLUMN [' . $column_name . ']'; - - if (!empty($recreate_indexes)) - { - // Recreate indexes after we removed the column - foreach ($recreate_indexes as $index_name => $index_data) - { - $result = $this->sql_create_index($table_name, $index_name, $index_data); - $statements = array_merge($statements, $result); - } - } - - $this->return_statements = $old_return_statements; - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritDoc} - */ - function sql_index_drop($table_name, $index_name) - { - $statements = array(); - - $statements[] = 'DROP INDEX [' . $table_name . '].[' . $index_name . ']'; - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritDoc} - */ - function sql_table_drop($table_name) - { - $statements = array(); - - if (!$this->sql_table_exists($table_name)) - { - return $this->_sql_run_sql($statements); - } - - // the most basic operation, get rid of the table - $statements[] = 'DROP TABLE ' . $table_name; - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritDoc} - */ - function sql_create_primary_key($table_name, $column, $inline = false) - { - $statements = array(); - - $sql = "ALTER TABLE [{$table_name}] WITH NOCHECK ADD "; - $sql .= "CONSTRAINT [PK_{$table_name}] PRIMARY KEY CLUSTERED ("; - $sql .= '[' . implode("],\n\t\t[", $column) . ']'; - $sql .= ')'; - - $statements[] = $sql; - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritDoc} - */ - function sql_create_unique_index($table_name, $index_name, $column) - { - $statements = array(); - - if ($this->mssql_is_sql_server_2000()) - { - $this->check_index_name_length($table_name, $index_name); - } - - $statements[] = 'CREATE UNIQUE INDEX [' . $index_name . '] ON [' . $table_name . ']([' . implode('], [', $column) . '])'; - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritDoc} - */ - function sql_create_index($table_name, $index_name, $column) - { - $statements = array(); - - $this->check_index_name_length($table_name, $index_name); - - // remove index length - $column = preg_replace('#:.*$#', '', $column); - - $statements[] = 'CREATE INDEX [' . $index_name . '] ON [' . $table_name . ']([' . implode('], [', $column) . '])'; - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritdoc} - */ - protected function get_max_index_name_length() - { - if ($this->mssql_is_sql_server_2000()) - { - return parent::get_max_index_name_length(); - } - else - { - return 128; - } - } - - /** - * {@inheritDoc} - */ - function sql_list_index($table_name) - { - $index_array = array(); - $sql = "EXEC sp_statistics '$table_name'"; - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - if ($row['TYPE'] == 3) - { - $index_array[] = strtolower($row['INDEX_NAME']); - } - } - $this->db->sql_freeresult($result); - - return $index_array; - } - - /** - * {@inheritDoc} - */ - function sql_column_change($table_name, $column_name, $column_data, $inline = false) - { - $column_data = $this->sql_prepare_column_data($table_name, $column_name, $column_data); - $statements = array(); - - // We need the data here - $old_return_statements = $this->return_statements; - $this->return_statements = true; - - $indexes = $this->get_existing_indexes($table_name, $column_name); - $unique_indexes = $this->get_existing_indexes($table_name, $column_name, true); - - // Drop any indexes - if (!empty($indexes) || !empty($unique_indexes)) - { - $drop_indexes = array_merge(array_keys($indexes), array_keys($unique_indexes)); - foreach ($drop_indexes as $index_name) - { - $result = $this->sql_index_drop($table_name, $index_name); - $statements = array_merge($statements, $result); - } - } - - // Drop default value constraint - $result = $this->mssql_get_drop_default_constraints_queries($table_name, $column_name); - $statements = array_merge($statements, $result); - - // Change the column - $statements[] = 'ALTER TABLE [' . $table_name . '] ALTER COLUMN [' . $column_name . '] ' . $column_data['column_type_sql']; - - if (!empty($column_data['default']) && !$this->mssql_is_column_identity($table_name, $column_name)) - { - // Add new default value constraint - $statements[] = 'ALTER TABLE [' . $table_name . '] ADD CONSTRAINT [DF_' . $table_name . '_' . $column_name . '_1] ' . $column_data['default'] . ' FOR [' . $column_name . ']'; - } - - if (!empty($indexes)) - { - // Recreate indexes after we changed the column - foreach ($indexes as $index_name => $index_data) - { - $result = $this->sql_create_index($table_name, $index_name, $index_data); - $statements = array_merge($statements, $result); - } - } - - if (!empty($unique_indexes)) - { - // Recreate unique indexes after we changed the column - foreach ($unique_indexes as $index_name => $index_data) - { - $result = $this->sql_create_unique_index($table_name, $index_name, $index_data); - $statements = array_merge($statements, $result); - } - } - - $this->return_statements = $old_return_statements; - - return $this->_sql_run_sql($statements); - } - - /** - * Get queries to drop the default constraints of a column - * - * We need to drop the default constraints of a column, - * before being able to change their type or deleting them. - * - * @param string $table_name - * @param string $column_name - * @return array Array with SQL statements - */ - protected function mssql_get_drop_default_constraints_queries($table_name, $column_name) - { - $statements = array(); - if ($this->mssql_is_sql_server_2000()) - { - // http://msdn.microsoft.com/en-us/library/aa175912%28v=sql.80%29.aspx - // Deprecated in SQL Server 2005 - $sql = "SELECT so.name AS def_name - FROM sysobjects so - JOIN sysconstraints sc ON so.id = sc.constid - WHERE object_name(so.parent_obj) = '{$table_name}' - AND so.xtype = 'D' - AND sc.colid = (SELECT colid FROM syscolumns - WHERE id = object_id('{$table_name}') - AND name = '{$column_name}')"; - } - else - { - $sql = "SELECT dobj.name AS def_name - FROM sys.columns col - LEFT OUTER JOIN sys.objects dobj ON (dobj.object_id = col.default_object_id AND dobj.type = 'D') - WHERE col.object_id = object_id('{$table_name}') - AND col.name = '{$column_name}' - AND dobj.name IS NOT NULL"; - } - - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - $statements[] = 'ALTER TABLE [' . $table_name . '] DROP CONSTRAINT [' . $row['def_name'] . ']'; - } - $this->db->sql_freeresult($result); - - return $statements; - } - - /** - * Get queries to drop the primary keys depending on the specified column - * - * We need to drop primary keys depending on this column before being able - * to delete them. - * - * @param string $table_name - * @param string $column_name - * @return array Array with SQL statements - */ - protected function mssql_get_drop_default_primary_key_queries($table_name, $column_name) - { - $statements = array(); - - $sql = "SELECT ccu.CONSTRAINT_NAME, ccu.COLUMN_NAME - FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc - JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu ON tc.CONSTRAINT_NAME = ccu.Constraint_name - WHERE tc.TABLE_NAME = '{$table_name}' - AND tc.CONSTRAINT_TYPE = 'Primary Key' - AND ccu.COLUMN_NAME = '{$column_name}'"; - - $result = $this->db->sql_query($sql); - - while ($primary_key = $this->db->sql_fetchrow($result)) - { - $statements[] = 'ALTER TABLE [' . $table_name . '] DROP CONSTRAINT [' . $primary_key['CONSTRAINT_NAME'] . ']'; - } - $this->db->sql_freeresult($result); - - return $statements; - } - - /** - * Checks to see if column is an identity column - * - * Identity columns cannot have defaults set for them. - * - * @param string $table_name - * @param string $column_name - * @return bool true if identity, false if not - */ - protected function mssql_is_column_identity($table_name, $column_name) - { - if ($this->mssql_is_sql_server_2000()) - { - // http://msdn.microsoft.com/en-us/library/aa175912%28v=sql.80%29.aspx - // Deprecated in SQL Server 2005 - $sql = "SELECT COLUMNPROPERTY(object_id('{$table_name}'), '{$column_name}', 'IsIdentity') AS is_identity"; - } - else - { - $sql = "SELECT is_identity FROM sys.columns - WHERE object_id = object_id('{$table_name}') - AND name = '{$column_name}'"; - } - - $result = $this->db->sql_query($sql); - $is_identity = $this->db->sql_fetchfield('is_identity'); - $this->db->sql_freeresult($result); - - return (bool) $is_identity; - } - - /** - * Get a list with existing indexes for the column - * - * @param string $table_name - * @param string $column_name - * @param bool $unique Should we get unique indexes or normal ones - * @return array Array with Index name => columns - */ - public function get_existing_indexes($table_name, $column_name, $unique = false) - { - $existing_indexes = array(); - if ($this->mssql_is_sql_server_2000()) - { - // http://msdn.microsoft.com/en-us/library/aa175912%28v=sql.80%29.aspx - // Deprecated in SQL Server 2005 - $sql = "SELECT DISTINCT ix.name AS phpbb_index_name - FROM sysindexes ix - INNER JOIN sysindexkeys ixc - ON ixc.id = ix.id - AND ixc.indid = ix.indid - INNER JOIN syscolumns cols - ON cols.colid = ixc.colid - AND cols.id = ix.id - WHERE ix.id = object_id('{$table_name}') - AND cols.name = '{$column_name}' - AND INDEXPROPERTY(ix.id, ix.name, 'IsUnique') = " . ($unique ? '1' : '0'); - } - else - { - $sql = "SELECT DISTINCT ix.name AS phpbb_index_name - FROM sys.indexes ix - INNER JOIN sys.index_columns ixc - ON ixc.object_id = ix.object_id - AND ixc.index_id = ix.index_id - INNER JOIN sys.columns cols - ON cols.column_id = ixc.column_id - AND cols.object_id = ix.object_id - WHERE ix.object_id = object_id('{$table_name}') - AND cols.name = '{$column_name}' - AND ix.is_primary_key = 0 - AND ix.is_unique = " . ($unique ? '1' : '0'); - } - - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - if (!isset($row['is_unique']) || ($unique && $row['is_unique'] == 'UNIQUE') || (!$unique && $row['is_unique'] == 'NONUNIQUE')) - { - $existing_indexes[$row['phpbb_index_name']] = array(); - } - } - $this->db->sql_freeresult($result); - - if (empty($existing_indexes)) - { - return array(); - } - - if ($this->mssql_is_sql_server_2000()) - { - $sql = "SELECT DISTINCT ix.name AS phpbb_index_name, cols.name AS phpbb_column_name - FROM sysindexes ix - INNER JOIN sysindexkeys ixc - ON ixc.id = ix.id - AND ixc.indid = ix.indid - INNER JOIN syscolumns cols - ON cols.colid = ixc.colid - AND cols.id = ix.id - WHERE ix.id = object_id('{$table_name}') - AND " . $this->db->sql_in_set('ix.name', array_keys($existing_indexes)); - } - else - { - $sql = "SELECT DISTINCT ix.name AS phpbb_index_name, cols.name AS phpbb_column_name - FROM sys.indexes ix - INNER JOIN sys.index_columns ixc - ON ixc.object_id = ix.object_id - AND ixc.index_id = ix.index_id - INNER JOIN sys.columns cols - ON cols.column_id = ixc.column_id - AND cols.object_id = ix.object_id - WHERE ix.object_id = object_id('{$table_name}') - AND " . $this->db->sql_in_set('ix.name', array_keys($existing_indexes)); - } - - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - $existing_indexes[$row['phpbb_index_name']][] = $row['phpbb_column_name']; - } - $this->db->sql_freeresult($result); - - return $existing_indexes; - } - - /** - * Is the used MS SQL Server a SQL Server 2000? - * - * @return bool - */ - protected function mssql_is_sql_server_2000() - { - if ($this->is_sql_server_2000 === null) - { - $sql = "SELECT CAST(SERVERPROPERTY('productversion') AS VARCHAR(25)) AS mssql_version"; - $result = $this->db->sql_query($sql); - $properties = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - $this->is_sql_server_2000 = $properties['mssql_version'][0] == '8'; - } - - return $this->is_sql_server_2000; - } - -} diff --git a/install/update/old/phpbb/db/tools/postgres.php b/install/update/old/phpbb/db/tools/postgres.php deleted file mode 100644 index 077d6e0..0000000 --- a/install/update/old/phpbb/db/tools/postgres.php +++ /dev/null @@ -1,614 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\db\tools; - -/** - * Database Tools for handling cross-db actions such as altering columns, etc. - * Currently not supported is returning SQL for creating tables. - */ -class postgres extends tools -{ - /** - * Get the column types for postgres only - * - * @return array - */ - public static function get_dbms_type_map() - { - return array( - 'postgres' => array( - 'INT:' => 'INT4', - 'BINT' => 'INT8', - 'ULINT' => 'INT4', // unsigned - 'UINT' => 'INT4', // unsigned - 'UINT:' => 'INT4', // unsigned - 'USINT' => 'INT2', // unsigned - 'BOOL' => 'INT2', // unsigned - 'TINT:' => 'INT2', - 'VCHAR' => 'varchar(255)', - 'VCHAR:' => 'varchar(%d)', - 'CHAR:' => 'char(%d)', - 'XSTEXT' => 'varchar(1000)', - 'STEXT' => 'varchar(3000)', - 'TEXT' => 'varchar(8000)', - 'MTEXT' => 'TEXT', - 'XSTEXT_UNI'=> 'varchar(100)', - 'STEXT_UNI' => 'varchar(255)', - 'TEXT_UNI' => 'varchar(4000)', - 'MTEXT_UNI' => 'TEXT', - 'TIMESTAMP' => 'INT4', // unsigned - 'DECIMAL' => 'decimal(5,2)', - 'DECIMAL:' => 'decimal(%d,2)', - 'PDECIMAL' => 'decimal(6,3)', - 'PDECIMAL:' => 'decimal(%d,3)', - 'VCHAR_UNI' => 'varchar(255)', - 'VCHAR_UNI:'=> 'varchar(%d)', - 'VCHAR_CI' => 'varchar_ci', - 'VARBINARY' => 'bytea', - ), - ); - } - - /** - * Constructor. Set DB Object and set {@link $return_statements return_statements}. - * - * @param \phpbb\db\driver\driver_interface $db Database connection - * @param bool $return_statements True if only statements should be returned and no SQL being executed - */ - public function __construct(\phpbb\db\driver\driver_interface $db, $return_statements = false) - { - parent::__construct($db, $return_statements); - - // Determine mapping database type - $this->sql_layer = 'postgres'; - - $this->dbms_type_map = self::get_dbms_type_map(); - } - - /** - * {@inheritDoc} - */ - function sql_list_tables() - { - $sql = 'SELECT relname - FROM pg_stat_user_tables'; - $result = $this->db->sql_query($sql); - - $tables = array(); - while ($row = $this->db->sql_fetchrow($result)) - { - $name = current($row); - $tables[$name] = $name; - } - $this->db->sql_freeresult($result); - - return $tables; - } - - /** - * {@inheritDoc} - */ - function sql_create_table($table_name, $table_data) - { - // holds the DDL for a column - $columns = $statements = array(); - - if ($this->sql_table_exists($table_name)) - { - return $this->_sql_run_sql($statements); - } - - // Begin transaction - $statements[] = 'begin'; - - // Determine if we have created a PRIMARY KEY in the earliest - $primary_key_gen = false; - - // Determine if the table requires a sequence - $create_sequence = false; - - // Begin table sql statement - $table_sql = 'CREATE TABLE ' . $table_name . ' (' . "\n"; - - // Iterate through the columns to create a table - foreach ($table_data['COLUMNS'] as $column_name => $column_data) - { - // here lies an array, filled with information compiled on the column's data - $prepared_column = $this->sql_prepare_column_data($table_name, $column_name, $column_data); - - if (isset($prepared_column['auto_increment']) && $prepared_column['auto_increment'] && strlen($column_name) > 26) // "${column_name}_gen" - { - trigger_error("Index name '${column_name}_gen' on table '$table_name' is too long. The maximum auto increment column length is 26 characters.", E_USER_ERROR); - } - - // here we add the definition of the new column to the list of columns - $columns[] = "\t {$column_name} " . $prepared_column['column_type_sql']; - - // see if we have found a primary key set due to a column definition if we have found it, we can stop looking - if (!$primary_key_gen) - { - $primary_key_gen = isset($prepared_column['primary_key_set']) && $prepared_column['primary_key_set']; - } - - // create sequence DDL based off of the existance of auto incrementing columns - if (!$create_sequence && isset($prepared_column['auto_increment']) && $prepared_column['auto_increment']) - { - $create_sequence = $column_name; - } - } - - // this makes up all the columns in the create table statement - $table_sql .= implode(",\n", $columns); - - // we have yet to create a primary key for this table, - // this means that we can add the one we really wanted instead - if (!$primary_key_gen) - { - // Write primary key - if (isset($table_data['PRIMARY_KEY'])) - { - if (!is_array($table_data['PRIMARY_KEY'])) - { - $table_data['PRIMARY_KEY'] = array($table_data['PRIMARY_KEY']); - } - - $table_sql .= ",\n\t PRIMARY KEY (" . implode(', ', $table_data['PRIMARY_KEY']) . ')'; - } - } - - // do we need to add a sequence for auto incrementing columns? - if ($create_sequence) - { - $statements[] = "CREATE SEQUENCE {$table_name}_seq;"; - } - - // close the table - $table_sql .= "\n);"; - $statements[] = $table_sql; - - // Write Keys - if (isset($table_data['KEYS'])) - { - foreach ($table_data['KEYS'] as $key_name => $key_data) - { - if (!is_array($key_data[1])) - { - $key_data[1] = array($key_data[1]); - } - - $old_return_statements = $this->return_statements; - $this->return_statements = true; - - $key_stmts = ($key_data[0] == 'UNIQUE') ? $this->sql_create_unique_index($table_name, $key_name, $key_data[1]) : $this->sql_create_index($table_name, $key_name, $key_data[1]); - - foreach ($key_stmts as $key_stmt) - { - $statements[] = $key_stmt; - } - - $this->return_statements = $old_return_statements; - } - } - - // Commit Transaction - $statements[] = 'commit'; - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritDoc} - */ - function sql_list_columns($table_name) - { - $columns = array(); - - $sql = "SELECT a.attname - FROM pg_class c, pg_attribute a - WHERE c.relname = '{$table_name}' - AND a.attnum > 0 - AND a.attrelid = c.oid"; - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - $column = strtolower(current($row)); - $columns[$column] = $column; - } - $this->db->sql_freeresult($result); - - return $columns; - } - - /** - * {@inheritDoc} - */ - function sql_index_exists($table_name, $index_name) - { - $sql = "SELECT ic.relname as index_name - FROM pg_class bc, pg_class ic, pg_index i - WHERE (bc.oid = i.indrelid) - AND (ic.oid = i.indexrelid) - AND (bc.relname = '" . $table_name . "') - AND (i.indisunique != 't') - AND (i.indisprimary != 't')"; - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - // This DBMS prefixes index names with the table name - $row['index_name'] = $this->strip_table_name_from_index_name($table_name, $row['index_name']); - - if (strtolower($row['index_name']) == strtolower($index_name)) - { - $this->db->sql_freeresult($result); - return true; - } - } - $this->db->sql_freeresult($result); - - return false; - } - - /** - * {@inheritDoc} - */ - function sql_unique_index_exists($table_name, $index_name) - { - $sql = "SELECT ic.relname as index_name, i.indisunique - FROM pg_class bc, pg_class ic, pg_index i - WHERE (bc.oid = i.indrelid) - AND (ic.oid = i.indexrelid) - AND (bc.relname = '" . $table_name . "') - AND (i.indisprimary != 't')"; - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - if ($row['indisunique'] != 't') - { - continue; - } - - // This DBMS prefixes index names with the table name - $row['index_name'] = $this->strip_table_name_from_index_name($table_name, $row['index_name']); - - if (strtolower($row['index_name']) == strtolower($index_name)) - { - $this->db->sql_freeresult($result); - return true; - } - } - $this->db->sql_freeresult($result); - - return false; - } - - /** - * Function to prepare some column information for better usage - * @access private - */ - function sql_prepare_column_data($table_name, $column_name, $column_data) - { - if (strlen($column_name) > 30) - { - trigger_error("Column name '$column_name' on table '$table_name' is too long. The maximum is 30 characters.", E_USER_ERROR); - } - - // Get type - list($column_type, $orig_column_type) = $this->get_column_type($column_data[0]); - - // Adjust default value if db-dependent specified - if (is_array($column_data[1])) - { - $column_data[1] = (isset($column_data[1][$this->sql_layer])) ? $column_data[1][$this->sql_layer] : $column_data[1]['default']; - } - - $sql = " {$column_type} "; - - $return_array = array( - 'column_type' => $column_type, - 'auto_increment' => false, - ); - - if (isset($column_data[2]) && $column_data[2] == 'auto_increment') - { - $default_val = "nextval('{$table_name}_seq')"; - $return_array['auto_increment'] = true; - } - else if (!is_null($column_data[1])) - { - $default_val = "'" . $column_data[1] . "'"; - $return_array['null'] = 'NOT NULL'; - $sql .= 'NOT NULL '; - } - else - { - // Integers need to have 0 instead of empty string as default - if (strpos($column_type, 'INT') === 0) - { - $default_val = '0'; - } - else - { - $default_val = "'" . $column_data[1] . "'"; - } - $return_array['null'] = 'NULL'; - $sql .= 'NULL '; - } - - $return_array['default'] = $default_val; - - $sql .= "DEFAULT {$default_val}"; - - // Unsigned? Then add a CHECK contraint - if (in_array($orig_column_type, $this->unsigned_types)) - { - $return_array['constraint'] = "CHECK ({$column_name} >= 0)"; - $sql .= " CHECK ({$column_name} >= 0)"; - } - - $return_array['column_type_sql'] = $sql; - - return $return_array; - } - - /** - * {@inheritDoc} - */ - function sql_column_add($table_name, $column_name, $column_data, $inline = false) - { - $column_data = $this->sql_prepare_column_data($table_name, $column_name, $column_data); - $statements = array(); - - // Does not support AFTER, only through temporary table - if (version_compare($this->db->sql_server_info(true), '8.0', '>=')) - { - $statements[] = 'ALTER TABLE ' . $table_name . ' ADD COLUMN "' . $column_name . '" ' . $column_data['column_type_sql']; - } - else - { - // old versions cannot add columns with default and null information - $statements[] = 'ALTER TABLE ' . $table_name . ' ADD COLUMN "' . $column_name . '" ' . $column_data['column_type'] . ' ' . $column_data['constraint']; - - if (isset($column_data['null'])) - { - if ($column_data['null'] == 'NOT NULL') - { - $statements[] = 'ALTER TABLE ' . $table_name . ' ALTER COLUMN ' . $column_name . ' SET NOT NULL'; - } - } - - if (isset($column_data['default'])) - { - $statements[] = 'ALTER TABLE ' . $table_name . ' ALTER COLUMN ' . $column_name . ' SET DEFAULT ' . $column_data['default']; - } - } - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritDoc} - */ - function sql_column_remove($table_name, $column_name, $inline = false) - { - $statements = array(); - - $statements[] = 'ALTER TABLE ' . $table_name . ' DROP COLUMN "' . $column_name . '"'; - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritDoc} - */ - function sql_index_drop($table_name, $index_name) - { - $statements = array(); - - $statements[] = 'DROP INDEX ' . $table_name . '_' . $index_name; - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritDoc} - */ - function sql_table_drop($table_name) - { - $statements = array(); - - if (!$this->sql_table_exists($table_name)) - { - return $this->_sql_run_sql($statements); - } - - // the most basic operation, get rid of the table - $statements[] = 'DROP TABLE ' . $table_name; - - // PGSQL does not "tightly" bind sequences and tables, we must guess... - $sql = "SELECT relname - FROM pg_class - WHERE relkind = 'S' - AND relname = '{$table_name}_seq'"; - $result = $this->db->sql_query($sql); - - // We don't even care about storing the results. We already know the answer if we get rows back. - if ($this->db->sql_fetchrow($result)) - { - $statements[] = "DROP SEQUENCE IF EXISTS {$table_name}_seq;\n"; - } - $this->db->sql_freeresult($result); - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritDoc} - */ - function sql_create_primary_key($table_name, $column, $inline = false) - { - $statements = array(); - - $statements[] = 'ALTER TABLE ' . $table_name . ' ADD PRIMARY KEY (' . implode(', ', $column) . ')'; - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritDoc} - */ - function sql_create_unique_index($table_name, $index_name, $column) - { - $statements = array(); - - $this->check_index_name_length($table_name, $index_name); - - $statements[] = 'CREATE UNIQUE INDEX ' . $table_name . '_' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')'; - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritDoc} - */ - function sql_create_index($table_name, $index_name, $column) - { - $statements = array(); - - $this->check_index_name_length($table_name, $index_name); - - // remove index length - $column = preg_replace('#:.*$#', '', $column); - - $statements[] = 'CREATE INDEX ' . $table_name . '_' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')'; - - return $this->_sql_run_sql($statements); - } - - - /** - * {@inheritDoc} - */ - function sql_list_index($table_name) - { - $index_array = array(); - - $sql = "SELECT ic.relname as index_name - FROM pg_class bc, pg_class ic, pg_index i - WHERE (bc.oid = i.indrelid) - AND (ic.oid = i.indexrelid) - AND (bc.relname = '" . $table_name . "') - AND (i.indisunique != 't') - AND (i.indisprimary != 't')"; - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - $row['index_name'] = $this->strip_table_name_from_index_name($table_name, $row['index_name']); - - $index_array[] = $row['index_name']; - } - $this->db->sql_freeresult($result); - - return array_map('strtolower', $index_array); - } - - /** - * {@inheritDoc} - */ - function sql_column_change($table_name, $column_name, $column_data, $inline = false) - { - $column_data = $this->sql_prepare_column_data($table_name, $column_name, $column_data); - $statements = array(); - - $sql = 'ALTER TABLE ' . $table_name . ' '; - - $sql_array = array(); - $sql_array[] = 'ALTER COLUMN ' . $column_name . ' TYPE ' . $column_data['column_type']; - - if (isset($column_data['null'])) - { - if ($column_data['null'] == 'NOT NULL') - { - $sql_array[] = 'ALTER COLUMN ' . $column_name . ' SET NOT NULL'; - } - else if ($column_data['null'] == 'NULL') - { - $sql_array[] = 'ALTER COLUMN ' . $column_name . ' DROP NOT NULL'; - } - } - - if (isset($column_data['default'])) - { - $sql_array[] = 'ALTER COLUMN ' . $column_name . ' SET DEFAULT ' . $column_data['default']; - } - - // we don't want to double up on constraints if we change different number data types - if (isset($column_data['constraint'])) - { - $constraint_sql = "SELECT consrc as constraint_data - FROM pg_constraint, pg_class bc - WHERE conrelid = bc.oid - AND bc.relname = '{$table_name}' - AND NOT EXISTS ( - SELECT * - FROM pg_constraint as c, pg_inherits as i - WHERE i.inhrelid = pg_constraint.conrelid - AND c.conname = pg_constraint.conname - AND c.consrc = pg_constraint.consrc - AND c.conrelid = i.inhparent - )"; - - $constraint_exists = false; - - $result = $this->db->sql_query($constraint_sql); - while ($row = $this->db->sql_fetchrow($result)) - { - if (trim($row['constraint_data']) == trim($column_data['constraint'])) - { - $constraint_exists = true; - break; - } - } - $this->db->sql_freeresult($result); - - if (!$constraint_exists) - { - $sql_array[] = 'ADD ' . $column_data['constraint']; - } - } - - $sql .= implode(', ', $sql_array); - - $statements[] = $sql; - - return $this->_sql_run_sql($statements); - } - - /** - * Get a list with existing indexes for the column - * - * @param string $table_name - * @param string $column_name - * @param bool $unique Should we get unique indexes or normal ones - * @return array Array with Index name => columns - */ - public function get_existing_indexes($table_name, $column_name, $unique = false) - { - // Not supported - throw new \Exception('DBMS is not supported'); - } -} diff --git a/install/update/old/phpbb/db/tools/tools.php b/install/update/old/phpbb/db/tools/tools.php deleted file mode 100644 index d21d34b..0000000 --- a/install/update/old/phpbb/db/tools/tools.php +++ /dev/null @@ -1,1956 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\db\tools; - -/** -* Database Tools for handling cross-db actions such as altering columns, etc. -* Currently not supported is returning SQL for creating tables. -*/ -class tools implements tools_interface -{ - /** - * Current sql layer - */ - var $sql_layer = ''; - - /** - * @var object DB object - */ - var $db = null; - - /** - * The Column types for every database we support - * @var array - */ - var $dbms_type_map = array(); - - /** - * Get the column types for every database we support - * - * @return array - */ - static public function get_dbms_type_map() - { - return array( - 'mysql_41' => array( - 'INT:' => 'int(%d)', - 'BINT' => 'bigint(20)', - 'ULINT' => 'INT(10) UNSIGNED', - 'UINT' => 'mediumint(8) UNSIGNED', - 'UINT:' => 'int(%d) UNSIGNED', - 'TINT:' => 'tinyint(%d)', - 'USINT' => 'smallint(4) UNSIGNED', - 'BOOL' => 'tinyint(1) UNSIGNED', - 'VCHAR' => 'varchar(255)', - 'VCHAR:' => 'varchar(%d)', - 'CHAR:' => 'char(%d)', - 'XSTEXT' => 'text', - 'XSTEXT_UNI'=> 'varchar(100)', - 'STEXT' => 'text', - 'STEXT_UNI' => 'varchar(255)', - 'TEXT' => 'text', - 'TEXT_UNI' => 'text', - 'MTEXT' => 'mediumtext', - 'MTEXT_UNI' => 'mediumtext', - 'TIMESTAMP' => 'int(11) UNSIGNED', - 'DECIMAL' => 'decimal(5,2)', - 'DECIMAL:' => 'decimal(%d,2)', - 'PDECIMAL' => 'decimal(6,3)', - 'PDECIMAL:' => 'decimal(%d,3)', - 'VCHAR_UNI' => 'varchar(255)', - 'VCHAR_UNI:'=> 'varchar(%d)', - 'VCHAR_CI' => 'varchar(255)', - 'VARBINARY' => 'varbinary(255)', - ), - - 'mysql_40' => array( - 'INT:' => 'int(%d)', - 'BINT' => 'bigint(20)', - 'ULINT' => 'INT(10) UNSIGNED', - 'UINT' => 'mediumint(8) UNSIGNED', - 'UINT:' => 'int(%d) UNSIGNED', - 'TINT:' => 'tinyint(%d)', - 'USINT' => 'smallint(4) UNSIGNED', - 'BOOL' => 'tinyint(1) UNSIGNED', - 'VCHAR' => 'varbinary(255)', - 'VCHAR:' => 'varbinary(%d)', - 'CHAR:' => 'binary(%d)', - 'XSTEXT' => 'blob', - 'XSTEXT_UNI'=> 'blob', - 'STEXT' => 'blob', - 'STEXT_UNI' => 'blob', - 'TEXT' => 'blob', - 'TEXT_UNI' => 'blob', - 'MTEXT' => 'mediumblob', - 'MTEXT_UNI' => 'mediumblob', - 'TIMESTAMP' => 'int(11) UNSIGNED', - 'DECIMAL' => 'decimal(5,2)', - 'DECIMAL:' => 'decimal(%d,2)', - 'PDECIMAL' => 'decimal(6,3)', - 'PDECIMAL:' => 'decimal(%d,3)', - 'VCHAR_UNI' => 'blob', - 'VCHAR_UNI:'=> array('varbinary(%d)', 'limit' => array('mult', 3, 255, 'blob')), - 'VCHAR_CI' => 'blob', - 'VARBINARY' => 'varbinary(255)', - ), - - 'oracle' => array( - 'INT:' => 'number(%d)', - 'BINT' => 'number(20)', - 'ULINT' => 'number(10)', - 'UINT' => 'number(8)', - 'UINT:' => 'number(%d)', - 'TINT:' => 'number(%d)', - 'USINT' => 'number(4)', - 'BOOL' => 'number(1)', - 'VCHAR' => 'varchar2(255)', - 'VCHAR:' => 'varchar2(%d)', - 'CHAR:' => 'char(%d)', - 'XSTEXT' => 'varchar2(1000)', - 'STEXT' => 'varchar2(3000)', - 'TEXT' => 'clob', - 'MTEXT' => 'clob', - 'XSTEXT_UNI'=> 'varchar2(300)', - 'STEXT_UNI' => 'varchar2(765)', - 'TEXT_UNI' => 'clob', - 'MTEXT_UNI' => 'clob', - 'TIMESTAMP' => 'number(11)', - 'DECIMAL' => 'number(5, 2)', - 'DECIMAL:' => 'number(%d, 2)', - 'PDECIMAL' => 'number(6, 3)', - 'PDECIMAL:' => 'number(%d, 3)', - 'VCHAR_UNI' => 'varchar2(765)', - 'VCHAR_UNI:'=> array('varchar2(%d)', 'limit' => array('mult', 3, 765, 'clob')), - 'VCHAR_CI' => 'varchar2(255)', - 'VARBINARY' => 'raw(255)', - ), - - 'sqlite3' => array( - 'INT:' => 'INT(%d)', - 'BINT' => 'BIGINT(20)', - 'ULINT' => 'INTEGER UNSIGNED', - 'UINT' => 'INTEGER UNSIGNED', - 'UINT:' => 'INTEGER UNSIGNED', - 'TINT:' => 'TINYINT(%d)', - 'USINT' => 'INTEGER UNSIGNED', - 'BOOL' => 'INTEGER UNSIGNED', - 'VCHAR' => 'VARCHAR(255)', - 'VCHAR:' => 'VARCHAR(%d)', - 'CHAR:' => 'CHAR(%d)', - 'XSTEXT' => 'TEXT(65535)', - 'STEXT' => 'TEXT(65535)', - 'TEXT' => 'TEXT(65535)', - 'MTEXT' => 'MEDIUMTEXT(16777215)', - 'XSTEXT_UNI'=> 'TEXT(65535)', - 'STEXT_UNI' => 'TEXT(65535)', - 'TEXT_UNI' => 'TEXT(65535)', - 'MTEXT_UNI' => 'MEDIUMTEXT(16777215)', - 'TIMESTAMP' => 'INTEGER UNSIGNED', //'int(11) UNSIGNED', - 'DECIMAL' => 'DECIMAL(5,2)', - 'DECIMAL:' => 'DECIMAL(%d,2)', - 'PDECIMAL' => 'DECIMAL(6,3)', - 'PDECIMAL:' => 'DECIMAL(%d,3)', - 'VCHAR_UNI' => 'VARCHAR(255)', - 'VCHAR_UNI:'=> 'VARCHAR(%d)', - 'VCHAR_CI' => 'VARCHAR(255)', - 'VARBINARY' => 'BLOB', - ), - ); - } - - /** - * A list of types being unsigned for better reference in some db's - * @var array - */ - var $unsigned_types = array('ULINT', 'UINT', 'UINT:', 'USINT', 'BOOL', 'TIMESTAMP'); - - /** - * This is set to true if user only wants to return the 'to-be-executed' SQL statement(s) (as an array). - * This mode has no effect on some methods (inserting of data for example). This is expressed within the methods command. - */ - var $return_statements = false; - - /** - * Constructor. Set DB Object and set {@link $return_statements return_statements}. - * - * @param \phpbb\db\driver\driver_interface $db Database connection - * @param bool $return_statements True if only statements should be returned and no SQL being executed - */ - public function __construct(\phpbb\db\driver\driver_interface $db, $return_statements = false) - { - $this->db = $db; - $this->return_statements = $return_statements; - - $this->dbms_type_map = self::get_dbms_type_map(); - - // Determine mapping database type - switch ($this->db->get_sql_layer()) - { - case 'mysql': - $this->sql_layer = 'mysql_40'; - break; - - case 'mysql4': - if (version_compare($this->db->sql_server_info(true), '4.1.3', '>=')) - { - $this->sql_layer = 'mysql_41'; - } - else - { - $this->sql_layer = 'mysql_40'; - } - break; - - case 'mysqli': - $this->sql_layer = 'mysql_41'; - break; - - default: - $this->sql_layer = $this->db->get_sql_layer(); - break; - } - } - - /** - * Setter for {@link $return_statements return_statements}. - * - * @param bool $return_statements True if SQL should not be executed but returned as strings - * @return null - */ - public function set_return_statements($return_statements) - { - $this->return_statements = $return_statements; - } - - /** - * {@inheritDoc} - */ - function sql_list_tables() - { - switch ($this->db->get_sql_layer()) - { - case 'mysql': - case 'mysql4': - case 'mysqli': - $sql = 'SHOW TABLES'; - break; - - case 'sqlite3': - $sql = 'SELECT name - FROM sqlite_master - WHERE type = "table" - AND name <> "sqlite_sequence"'; - break; - - case 'oracle': - $sql = 'SELECT table_name - FROM USER_TABLES'; - break; - } - - $result = $this->db->sql_query($sql); - - $tables = array(); - while ($row = $this->db->sql_fetchrow($result)) - { - $name = current($row); - $tables[$name] = $name; - } - $this->db->sql_freeresult($result); - - return $tables; - } - - /** - * {@inheritDoc} - */ - function sql_table_exists($table_name) - { - $this->db->sql_return_on_error(true); - $result = $this->db->sql_query_limit('SELECT * FROM ' . $table_name, 1); - $this->db->sql_return_on_error(false); - - if ($result) - { - $this->db->sql_freeresult($result); - return true; - } - - return false; - } - - /** - * {@inheritDoc} - */ - function sql_create_table($table_name, $table_data) - { - // holds the DDL for a column - $columns = $statements = array(); - - if ($this->sql_table_exists($table_name)) - { - return $this->_sql_run_sql($statements); - } - - // Begin transaction - $statements[] = 'begin'; - - // Determine if we have created a PRIMARY KEY in the earliest - $primary_key_gen = false; - - // Determine if the table requires a sequence - $create_sequence = false; - - // Begin table sql statement - $table_sql = 'CREATE TABLE ' . $table_name . ' (' . "\n"; - - // Iterate through the columns to create a table - foreach ($table_data['COLUMNS'] as $column_name => $column_data) - { - // here lies an array, filled with information compiled on the column's data - $prepared_column = $this->sql_prepare_column_data($table_name, $column_name, $column_data); - - if (isset($prepared_column['auto_increment']) && $prepared_column['auto_increment'] && strlen($column_name) > 26) // "${column_name}_gen" - { - trigger_error("Index name '${column_name}_gen' on table '$table_name' is too long. The maximum auto increment column length is 26 characters.", E_USER_ERROR); - } - - // here we add the definition of the new column to the list of columns - $columns[] = "\t {$column_name} " . $prepared_column['column_type_sql']; - - // see if we have found a primary key set due to a column definition if we have found it, we can stop looking - if (!$primary_key_gen) - { - $primary_key_gen = isset($prepared_column['primary_key_set']) && $prepared_column['primary_key_set']; - } - - // create sequence DDL based off of the existance of auto incrementing columns - if (!$create_sequence && isset($prepared_column['auto_increment']) && $prepared_column['auto_increment']) - { - $create_sequence = $column_name; - } - } - - // this makes up all the columns in the create table statement - $table_sql .= implode(",\n", $columns); - - // we have yet to create a primary key for this table, - // this means that we can add the one we really wanted instead - if (!$primary_key_gen) - { - // Write primary key - if (isset($table_data['PRIMARY_KEY'])) - { - if (!is_array($table_data['PRIMARY_KEY'])) - { - $table_data['PRIMARY_KEY'] = array($table_data['PRIMARY_KEY']); - } - - switch ($this->sql_layer) - { - case 'mysql_40': - case 'mysql_41': - case 'sqlite3': - $table_sql .= ",\n\t PRIMARY KEY (" . implode(', ', $table_data['PRIMARY_KEY']) . ')'; - break; - - case 'oracle': - $table_sql .= ",\n\t CONSTRAINT pk_{$table_name} PRIMARY KEY (" . implode(', ', $table_data['PRIMARY_KEY']) . ')'; - break; - } - } - } - - // close the table - switch ($this->sql_layer) - { - case 'mysql_41': - // make sure the table is in UTF-8 mode - $table_sql .= "\n) CHARACTER SET `utf8` COLLATE `utf8_bin`;"; - $statements[] = $table_sql; - break; - - case 'mysql_40': - case 'sqlite3': - $table_sql .= "\n);"; - $statements[] = $table_sql; - break; - - case 'oracle': - $table_sql .= "\n)"; - $statements[] = $table_sql; - - // do we need to add a sequence and a tigger for auto incrementing columns? - if ($create_sequence) - { - // create the actual sequence - $statements[] = "CREATE SEQUENCE {$table_name}_seq"; - - // the trigger is the mechanism by which we increment the counter - $trigger = "CREATE OR REPLACE TRIGGER t_{$table_name}\n"; - $trigger .= "BEFORE INSERT ON {$table_name}\n"; - $trigger .= "FOR EACH ROW WHEN (\n"; - $trigger .= "\tnew.{$create_sequence} IS NULL OR new.{$create_sequence} = 0\n"; - $trigger .= ")\n"; - $trigger .= "BEGIN\n"; - $trigger .= "\tSELECT {$table_name}_seq.nextval\n"; - $trigger .= "\tINTO :new.{$create_sequence}\n"; - $trigger .= "\tFROM dual;\n"; - $trigger .= "END;"; - - $statements[] = $trigger; - } - break; - } - - // Write Keys - if (isset($table_data['KEYS'])) - { - foreach ($table_data['KEYS'] as $key_name => $key_data) - { - if (!is_array($key_data[1])) - { - $key_data[1] = array($key_data[1]); - } - - $old_return_statements = $this->return_statements; - $this->return_statements = true; - - $key_stmts = ($key_data[0] == 'UNIQUE') ? $this->sql_create_unique_index($table_name, $key_name, $key_data[1]) : $this->sql_create_index($table_name, $key_name, $key_data[1]); - - foreach ($key_stmts as $key_stmt) - { - $statements[] = $key_stmt; - } - - $this->return_statements = $old_return_statements; - } - } - - // Commit Transaction - $statements[] = 'commit'; - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritDoc} - */ - function perform_schema_changes($schema_changes) - { - if (empty($schema_changes)) - { - return; - } - - $statements = array(); - $sqlite = false; - - // For SQLite we need to perform the schema changes in a much more different way - if ($this->db->get_sql_layer() == 'sqlite3' && $this->return_statements) - { - $sqlite_data = array(); - $sqlite = true; - } - - // Drop tables? - if (!empty($schema_changes['drop_tables'])) - { - foreach ($schema_changes['drop_tables'] as $table) - { - // only drop table if it exists - if ($this->sql_table_exists($table)) - { - $result = $this->sql_table_drop($table); - if ($this->return_statements) - { - $statements = array_merge($statements, $result); - } - } - } - } - - // Add tables? - if (!empty($schema_changes['add_tables'])) - { - foreach ($schema_changes['add_tables'] as $table => $table_data) - { - $result = $this->sql_create_table($table, $table_data); - if ($this->return_statements) - { - $statements = array_merge($statements, $result); - } - } - } - - // Change columns? - if (!empty($schema_changes['change_columns'])) - { - foreach ($schema_changes['change_columns'] as $table => $columns) - { - foreach ($columns as $column_name => $column_data) - { - // If the column exists we change it, else we add it ;) - if ($column_exists = $this->sql_column_exists($table, $column_name)) - { - $result = $this->sql_column_change($table, $column_name, $column_data, true); - } - else - { - $result = $this->sql_column_add($table, $column_name, $column_data, true); - } - - if ($sqlite) - { - if ($column_exists) - { - $sqlite_data[$table]['change_columns'][] = $result; - } - else - { - $sqlite_data[$table]['add_columns'][] = $result; - } - } - else if ($this->return_statements) - { - $statements = array_merge($statements, $result); - } - } - } - } - - // Add columns? - if (!empty($schema_changes['add_columns'])) - { - foreach ($schema_changes['add_columns'] as $table => $columns) - { - foreach ($columns as $column_name => $column_data) - { - // Only add the column if it does not exist yet - if ($column_exists = $this->sql_column_exists($table, $column_name)) - { - continue; - // This is commented out here because it can take tremendous time on updates -// $result = $this->sql_column_change($table, $column_name, $column_data, true); - } - else - { - $result = $this->sql_column_add($table, $column_name, $column_data, true); - } - - if ($sqlite) - { - if ($column_exists) - { - continue; -// $sqlite_data[$table]['change_columns'][] = $result; - } - else - { - $sqlite_data[$table]['add_columns'][] = $result; - } - } - else if ($this->return_statements) - { - $statements = array_merge($statements, $result); - } - } - } - } - - // Remove keys? - if (!empty($schema_changes['drop_keys'])) - { - foreach ($schema_changes['drop_keys'] as $table => $indexes) - { - foreach ($indexes as $index_name) - { - if (!$this->sql_index_exists($table, $index_name)) - { - continue; - } - - $result = $this->sql_index_drop($table, $index_name); - - if ($this->return_statements) - { - $statements = array_merge($statements, $result); - } - } - } - } - - // Drop columns? - if (!empty($schema_changes['drop_columns'])) - { - foreach ($schema_changes['drop_columns'] as $table => $columns) - { - foreach ($columns as $column) - { - // Only remove the column if it exists... - if ($this->sql_column_exists($table, $column)) - { - $result = $this->sql_column_remove($table, $column, true); - - if ($sqlite) - { - $sqlite_data[$table]['drop_columns'][] = $result; - } - else if ($this->return_statements) - { - $statements = array_merge($statements, $result); - } - } - } - } - } - - // Add primary keys? - if (!empty($schema_changes['add_primary_keys'])) - { - foreach ($schema_changes['add_primary_keys'] as $table => $columns) - { - $result = $this->sql_create_primary_key($table, $columns, true); - - if ($sqlite) - { - $sqlite_data[$table]['primary_key'] = $result; - } - else if ($this->return_statements) - { - $statements = array_merge($statements, $result); - } - } - } - - // Add unique indexes? - if (!empty($schema_changes['add_unique_index'])) - { - foreach ($schema_changes['add_unique_index'] as $table => $index_array) - { - foreach ($index_array as $index_name => $column) - { - if ($this->sql_unique_index_exists($table, $index_name)) - { - continue; - } - - $result = $this->sql_create_unique_index($table, $index_name, $column); - - if ($this->return_statements) - { - $statements = array_merge($statements, $result); - } - } - } - } - - // Add indexes? - if (!empty($schema_changes['add_index'])) - { - foreach ($schema_changes['add_index'] as $table => $index_array) - { - foreach ($index_array as $index_name => $column) - { - if ($this->sql_index_exists($table, $index_name)) - { - continue; - } - - $result = $this->sql_create_index($table, $index_name, $column); - - if ($this->return_statements) - { - $statements = array_merge($statements, $result); - } - } - } - } - - if ($sqlite) - { - foreach ($sqlite_data as $table_name => $sql_schema_changes) - { - // Create temporary table with original data - $statements[] = 'begin'; - - $sql = "SELECT sql - FROM sqlite_master - WHERE type = 'table' - AND name = '{$table_name}' - ORDER BY type DESC, name;"; - $result = $this->db->sql_query($sql); - - if (!$result) - { - continue; - } - - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - // Create a backup table and populate it, destroy the existing one - $statements[] = preg_replace('#CREATE\s+TABLE\s+"?' . $table_name . '"?#i', 'CREATE TEMPORARY TABLE ' . $table_name . '_temp', $row['sql']); - $statements[] = 'INSERT INTO ' . $table_name . '_temp SELECT * FROM ' . $table_name; - $statements[] = 'DROP TABLE ' . $table_name; - - // Get the columns... - preg_match('#\((.*)\)#s', $row['sql'], $matches); - - $plain_table_cols = trim($matches[1]); - $new_table_cols = preg_split('/,(?![\s\w]+\))/m', $plain_table_cols); - $column_list = array(); - - foreach ($new_table_cols as $declaration) - { - $entities = preg_split('#\s+#', trim($declaration)); - if ($entities[0] == 'PRIMARY') - { - continue; - } - $column_list[] = $entities[0]; - } - - // note down the primary key notation because sqlite only supports adding it to the end for the new table - $primary_key = false; - $_new_cols = array(); - - foreach ($new_table_cols as $key => $declaration) - { - $entities = preg_split('#\s+#', trim($declaration)); - if ($entities[0] == 'PRIMARY') - { - $primary_key = $declaration; - continue; - } - $_new_cols[] = $declaration; - } - - $new_table_cols = $_new_cols; - - // First of all... change columns - if (!empty($sql_schema_changes['change_columns'])) - { - foreach ($sql_schema_changes['change_columns'] as $column_sql) - { - foreach ($new_table_cols as $key => $declaration) - { - $entities = preg_split('#\s+#', trim($declaration)); - if (strpos($column_sql, $entities[0] . ' ') === 0) - { - $new_table_cols[$key] = $column_sql; - } - } - } - } - - if (!empty($sql_schema_changes['add_columns'])) - { - foreach ($sql_schema_changes['add_columns'] as $column_sql) - { - $new_table_cols[] = $column_sql; - } - } - - // Now drop them... - if (!empty($sql_schema_changes['drop_columns'])) - { - foreach ($sql_schema_changes['drop_columns'] as $column_name) - { - // Remove from column list... - $new_column_list = array(); - foreach ($column_list as $key => $value) - { - if ($value === $column_name) - { - continue; - } - - $new_column_list[] = $value; - } - - $column_list = $new_column_list; - - // Remove from table... - $_new_cols = array(); - foreach ($new_table_cols as $key => $declaration) - { - $entities = preg_split('#\s+#', trim($declaration)); - if (strpos($column_name . ' ', $entities[0] . ' ') === 0) - { - continue; - } - $_new_cols[] = $declaration; - } - $new_table_cols = $_new_cols; - } - } - - // Primary key... - if (!empty($sql_schema_changes['primary_key'])) - { - $new_table_cols[] = 'PRIMARY KEY (' . implode(', ', $sql_schema_changes['primary_key']) . ')'; - } - // Add a new one or the old primary key - else if ($primary_key !== false) - { - $new_table_cols[] = $primary_key; - } - - $columns = implode(',', $column_list); - - // create a new table and fill it up. destroy the temp one - $statements[] = 'CREATE TABLE ' . $table_name . ' (' . implode(',', $new_table_cols) . ');'; - $statements[] = 'INSERT INTO ' . $table_name . ' (' . $columns . ') SELECT ' . $columns . ' FROM ' . $table_name . '_temp;'; - $statements[] = 'DROP TABLE ' . $table_name . '_temp'; - - $statements[] = 'commit'; - } - } - - if ($this->return_statements) - { - return $statements; - } - } - - /** - * {@inheritDoc} - */ - function sql_list_columns($table_name) - { - $columns = array(); - - switch ($this->sql_layer) - { - case 'mysql_40': - case 'mysql_41': - $sql = "SHOW COLUMNS FROM $table_name"; - break; - - case 'oracle': - $sql = "SELECT column_name - FROM user_tab_columns - WHERE LOWER(table_name) = '" . strtolower($table_name) . "'"; - break; - - case 'sqlite3': - $sql = "SELECT sql - FROM sqlite_master - WHERE type = 'table' - AND name = '{$table_name}'"; - - $result = $this->db->sql_query($sql); - - if (!$result) - { - return false; - } - - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - preg_match('#\((.*)\)#s', $row['sql'], $matches); - - $cols = trim($matches[1]); - $col_array = preg_split('/,(?![\s\w]+\))/m', $cols); - - foreach ($col_array as $declaration) - { - $entities = preg_split('#\s+#', trim($declaration)); - if ($entities[0] == 'PRIMARY') - { - continue; - } - - $column = strtolower($entities[0]); - $columns[$column] = $column; - } - - return $columns; - break; - } - - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - $column = strtolower(current($row)); - $columns[$column] = $column; - } - $this->db->sql_freeresult($result); - - return $columns; - } - - /** - * {@inheritDoc} - */ - function sql_column_exists($table_name, $column_name) - { - $columns = $this->sql_list_columns($table_name); - - return isset($columns[$column_name]); - } - - /** - * {@inheritDoc} - */ - function sql_index_exists($table_name, $index_name) - { - switch ($this->sql_layer) - { - case 'mysql_40': - case 'mysql_41': - $sql = 'SHOW KEYS - FROM ' . $table_name; - $col = 'Key_name'; - break; - - case 'oracle': - $sql = "SELECT index_name - FROM user_indexes - WHERE table_name = '" . strtoupper($table_name) . "' - AND generated = 'N' - AND uniqueness = 'NONUNIQUE'"; - $col = 'index_name'; - break; - - case 'sqlite3': - $sql = "PRAGMA index_list('" . $table_name . "');"; - $col = 'name'; - break; - } - - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - if (($this->sql_layer == 'mysql_40' || $this->sql_layer == 'mysql_41') && !$row['Non_unique']) - { - continue; - } - - switch ($this->sql_layer) - { - // These DBMS prefix index name with the table name - case 'oracle': - case 'sqlite3': - $new_index_name = $this->check_index_name_length($table_name, $table_name . '_' . $index_name, false); - break; - default: - $new_index_name = $this->check_index_name_length($table_name, $index_name, false); - break; - } - - if (strtolower($row[$col]) == strtolower($new_index_name)) - { - $this->db->sql_freeresult($result); - return true; - } - } - $this->db->sql_freeresult($result); - - return false; - } - - /** - * {@inheritDoc} - */ - function sql_unique_index_exists($table_name, $index_name) - { - switch ($this->sql_layer) - { - case 'mysql_40': - case 'mysql_41': - $sql = 'SHOW KEYS - FROM ' . $table_name; - $col = 'Key_name'; - break; - - case 'oracle': - $sql = "SELECT index_name, table_owner - FROM user_indexes - WHERE table_name = '" . strtoupper($table_name) . "' - AND generated = 'N' - AND uniqueness = 'UNIQUE'"; - $col = 'index_name'; - break; - - case 'sqlite3': - $sql = "PRAGMA index_list('" . $table_name . "');"; - $col = 'name'; - break; - } - - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - if (($this->sql_layer == 'mysql_40' || $this->sql_layer == 'mysql_41') && ($row['Non_unique'] || $row[$col] == 'PRIMARY')) - { - continue; - } - - if ($this->sql_layer == 'sqlite3' && !$row['unique']) - { - continue; - } - - // These DBMS prefix index name with the table name - switch ($this->sql_layer) - { - case 'oracle': - // Two cases here... prefixed with U_[table_owner] and not prefixed with table_name - if (strpos($row[$col], 'U_') === 0) - { - $row[$col] = substr($row[$col], strlen('U_' . $row['table_owner']) + 1); - } - else if (strpos($row[$col], strtoupper($table_name)) === 0) - { - $row[$col] = substr($row[$col], strlen($table_name) + 1); - } - break; - - case 'sqlite3': - $row[$col] = substr($row[$col], strlen($table_name) + 1); - break; - } - - if (strtolower($row[$col]) == strtolower($index_name)) - { - $this->db->sql_freeresult($result); - return true; - } - } - $this->db->sql_freeresult($result); - - return false; - } - - /** - * Private method for performing sql statements (either execute them or return them) - * @access private - */ - function _sql_run_sql($statements) - { - if ($this->return_statements) - { - return $statements; - } - - // We could add error handling here... - foreach ($statements as $sql) - { - if ($sql === 'begin') - { - $this->db->sql_transaction('begin'); - } - else if ($sql === 'commit') - { - $this->db->sql_transaction('commit'); - } - else - { - $this->db->sql_query($sql); - } - } - - return true; - } - - /** - * Function to prepare some column information for better usage - * @access private - */ - function sql_prepare_column_data($table_name, $column_name, $column_data) - { - if (strlen($column_name) > 30) - { - trigger_error("Column name '$column_name' on table '$table_name' is too long. The maximum is 30 characters.", E_USER_ERROR); - } - - // Get type - list($column_type) = $this->get_column_type($column_data[0]); - - // Adjust default value if db-dependent specified - if (is_array($column_data[1])) - { - $column_data[1] = (isset($column_data[1][$this->sql_layer])) ? $column_data[1][$this->sql_layer] : $column_data[1]['default']; - } - - $sql = ''; - - $return_array = array(); - - switch ($this->sql_layer) - { - case 'mysql_40': - case 'mysql_41': - $sql .= " {$column_type} "; - - // For hexadecimal values do not use single quotes - if (!is_null($column_data[1]) && substr($column_type, -4) !== 'text' && substr($column_type, -4) !== 'blob') - { - $sql .= (strpos($column_data[1], '0x') === 0) ? "DEFAULT {$column_data[1]} " : "DEFAULT '{$column_data[1]}' "; - } - - if (!is_null($column_data[1]) || (isset($column_data[2]) && $column_data[2] == 'auto_increment')) - { - $sql .= 'NOT NULL'; - } - else - { - $sql .= 'NULL'; - } - - if (isset($column_data[2])) - { - if ($column_data[2] == 'auto_increment') - { - $sql .= ' auto_increment'; - } - else if ($this->sql_layer === 'mysql_41' && $column_data[2] == 'true_sort') - { - $sql .= ' COLLATE utf8_unicode_ci'; - } - } - - if (isset($column_data['after'])) - { - $return_array['after'] = $column_data['after']; - } - - break; - - case 'oracle': - $sql .= " {$column_type} "; - $sql .= (!is_null($column_data[1])) ? "DEFAULT '{$column_data[1]}' " : ''; - - // In Oracle empty strings ('') are treated as NULL. - // Therefore in oracle we allow NULL's for all DEFAULT '' entries - // Oracle does not like setting NOT NULL on a column that is already NOT NULL (this happens only on number fields) - if (!preg_match('/number/i', $column_type)) - { - $sql .= ($column_data[1] === '' || $column_data[1] === null) ? '' : 'NOT NULL'; - } - - $return_array['auto_increment'] = false; - if (isset($column_data[2]) && $column_data[2] == 'auto_increment') - { - $return_array['auto_increment'] = true; - } - - break; - - case 'sqlite3': - $return_array['primary_key_set'] = false; - if (isset($column_data[2]) && $column_data[2] == 'auto_increment') - { - $sql .= ' INTEGER PRIMARY KEY AUTOINCREMENT'; - $return_array['primary_key_set'] = true; - } - else - { - $sql .= ' ' . $column_type; - } - - if (!is_null($column_data[1])) - { - $sql .= ' NOT NULL '; - $sql .= "DEFAULT '{$column_data[1]}'"; - } - - break; - } - - $return_array['column_type_sql'] = $sql; - - return $return_array; - } - - /** - * Get the column's database type from the type map - * - * @param string $column_map_type - * @return array column type for this database - * and map type without length - */ - function get_column_type($column_map_type) - { - $column_type = ''; - if (strpos($column_map_type, ':') !== false) - { - list($orig_column_type, $column_length) = explode(':', $column_map_type); - if (!is_array($this->dbms_type_map[$this->sql_layer][$orig_column_type . ':'])) - { - $column_type = sprintf($this->dbms_type_map[$this->sql_layer][$orig_column_type . ':'], $column_length); - } - else - { - if (isset($this->dbms_type_map[$this->sql_layer][$orig_column_type . ':']['rule'])) - { - switch ($this->dbms_type_map[$this->sql_layer][$orig_column_type . ':']['rule'][0]) - { - case 'div': - $column_length /= $this->dbms_type_map[$this->sql_layer][$orig_column_type . ':']['rule'][1]; - $column_length = ceil($column_length); - $column_type = sprintf($this->dbms_type_map[$this->sql_layer][$orig_column_type . ':'][0], $column_length); - break; - } - } - - if (isset($this->dbms_type_map[$this->sql_layer][$orig_column_type . ':']['limit'])) - { - switch ($this->dbms_type_map[$this->sql_layer][$orig_column_type . ':']['limit'][0]) - { - case 'mult': - $column_length *= $this->dbms_type_map[$this->sql_layer][$orig_column_type . ':']['limit'][1]; - if ($column_length > $this->dbms_type_map[$this->sql_layer][$orig_column_type . ':']['limit'][2]) - { - $column_type = $this->dbms_type_map[$this->sql_layer][$orig_column_type . ':']['limit'][3]; - } - else - { - $column_type = sprintf($this->dbms_type_map[$this->sql_layer][$orig_column_type . ':'][0], $column_length); - } - break; - } - } - } - $orig_column_type .= ':'; - } - else - { - $orig_column_type = $column_map_type; - $column_type = $this->dbms_type_map[$this->sql_layer][$column_map_type]; - } - - return array($column_type, $orig_column_type); - } - - /** - * {@inheritDoc} - */ - function sql_column_add($table_name, $column_name, $column_data, $inline = false) - { - $column_data = $this->sql_prepare_column_data($table_name, $column_name, $column_data); - $statements = array(); - - switch ($this->sql_layer) - { - case 'mysql_40': - case 'mysql_41': - $after = (!empty($column_data['after'])) ? ' AFTER ' . $column_data['after'] : ''; - $statements[] = 'ALTER TABLE `' . $table_name . '` ADD COLUMN `' . $column_name . '` ' . $column_data['column_type_sql'] . $after; - break; - - case 'oracle': - // Does not support AFTER, only through temporary table - $statements[] = 'ALTER TABLE ' . $table_name . ' ADD ' . $column_name . ' ' . $column_data['column_type_sql']; - break; - - case 'sqlite3': - if ($inline && $this->return_statements) - { - return $column_name . ' ' . $column_data['column_type_sql']; - } - - $statements[] = 'ALTER TABLE ' . $table_name . ' ADD ' . $column_name . ' ' . $column_data['column_type_sql']; - break; - } - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritDoc} - */ - function sql_column_remove($table_name, $column_name, $inline = false) - { - $statements = array(); - - switch ($this->sql_layer) - { - case 'mysql_40': - case 'mysql_41': - $statements[] = 'ALTER TABLE `' . $table_name . '` DROP COLUMN `' . $column_name . '`'; - break; - - case 'oracle': - $statements[] = 'ALTER TABLE ' . $table_name . ' DROP COLUMN ' . $column_name; - break; - - case 'sqlite3': - - if ($inline && $this->return_statements) - { - return $column_name; - } - - $recreate_queries = $this->sqlite_get_recreate_table_queries($table_name, $column_name); - if (empty($recreate_queries)) - { - break; - } - - $statements[] = 'begin'; - - $sql_create_table = array_shift($recreate_queries); - - // Create a backup table and populate it, destroy the existing one - $statements[] = preg_replace('#CREATE\s+TABLE\s+"?' . $table_name . '"?#i', 'CREATE TEMPORARY TABLE ' . $table_name . '_temp', $sql_create_table); - $statements[] = 'INSERT INTO ' . $table_name . '_temp SELECT * FROM ' . $table_name; - $statements[] = 'DROP TABLE ' . $table_name; - - preg_match('#\((.*)\)#s', $sql_create_table, $matches); - - $new_table_cols = trim($matches[1]); - $old_table_cols = preg_split('/,(?![\s\w]+\))/m', $new_table_cols); - $column_list = array(); - - foreach ($old_table_cols as $declaration) - { - $entities = preg_split('#\s+#', trim($declaration)); - if ($entities[0] == 'PRIMARY' || $entities[0] === $column_name) - { - continue; - } - $column_list[] = $entities[0]; - } - - $columns = implode(',', $column_list); - - $new_table_cols = trim(preg_replace('/' . $column_name . '\b[^,]+(?:,|$)/m', '', $new_table_cols)); - if (substr($new_table_cols, -1) === ',') - { - // Remove the comma from the last entry again - $new_table_cols = substr($new_table_cols, 0, -1); - } - - // create a new table and fill it up. destroy the temp one - $statements[] = 'CREATE TABLE ' . $table_name . ' (' . $new_table_cols . ');'; - $statements = array_merge($statements, $recreate_queries); - - $statements[] = 'INSERT INTO ' . $table_name . ' (' . $columns . ') SELECT ' . $columns . ' FROM ' . $table_name . '_temp;'; - $statements[] = 'DROP TABLE ' . $table_name . '_temp'; - - $statements[] = 'commit'; - break; - } - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritDoc} - */ - function sql_index_drop($table_name, $index_name) - { - $statements = array(); - - switch ($this->sql_layer) - { - case 'mysql_40': - case 'mysql_41': - $index_name = $this->check_index_name_length($table_name, $index_name, false); - $statements[] = 'DROP INDEX ' . $index_name . ' ON ' . $table_name; - break; - - case 'oracle': - case 'sqlite3': - $index_name = $this->check_index_name_length($table_name, $table_name . '_' . $index_name, false); - $statements[] = 'DROP INDEX ' . $index_name; - break; - } - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritDoc} - */ - function sql_table_drop($table_name) - { - $statements = array(); - - if (!$this->sql_table_exists($table_name)) - { - return $this->_sql_run_sql($statements); - } - - // the most basic operation, get rid of the table - $statements[] = 'DROP TABLE ' . $table_name; - - switch ($this->sql_layer) - { - case 'oracle': - $sql = 'SELECT A.REFERENCED_NAME - FROM USER_DEPENDENCIES A, USER_TRIGGERS B - WHERE A.REFERENCED_TYPE = \'SEQUENCE\' - AND A.NAME = B.TRIGGER_NAME - AND B.TABLE_NAME = \'' . strtoupper($table_name) . "'"; - $result = $this->db->sql_query($sql); - - // any sequences ref'd to this table's triggers? - while ($row = $this->db->sql_fetchrow($result)) - { - $statements[] = "DROP SEQUENCE {$row['referenced_name']}"; - } - $this->db->sql_freeresult($result); - break; - } - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritDoc} - */ - function sql_create_primary_key($table_name, $column, $inline = false) - { - $statements = array(); - - switch ($this->sql_layer) - { - case 'mysql_40': - case 'mysql_41': - $statements[] = 'ALTER TABLE ' . $table_name . ' ADD PRIMARY KEY (' . implode(', ', $column) . ')'; - break; - - case 'oracle': - $statements[] = 'ALTER TABLE ' . $table_name . ' add CONSTRAINT pk_' . $table_name . ' PRIMARY KEY (' . implode(', ', $column) . ')'; - break; - - case 'sqlite3': - - if ($inline && $this->return_statements) - { - return $column; - } - - $recreate_queries = $this->sqlite_get_recreate_table_queries($table_name); - if (empty($recreate_queries)) - { - break; - } - - $statements[] = 'begin'; - - $sql_create_table = array_shift($recreate_queries); - - // Create a backup table and populate it, destroy the existing one - $statements[] = preg_replace('#CREATE\s+TABLE\s+"?' . $table_name . '"?#i', 'CREATE TEMPORARY TABLE ' . $table_name . '_temp', $sql_create_table); - $statements[] = 'INSERT INTO ' . $table_name . '_temp SELECT * FROM ' . $table_name; - $statements[] = 'DROP TABLE ' . $table_name; - - preg_match('#\((.*)\)#s', $sql_create_table, $matches); - - $new_table_cols = trim($matches[1]); - $old_table_cols = preg_split('/,(?![\s\w]+\))/m', $new_table_cols); - $column_list = array(); - - foreach ($old_table_cols as $declaration) - { - $entities = preg_split('#\s+#', trim($declaration)); - if ($entities[0] == 'PRIMARY') - { - continue; - } - $column_list[] = $entities[0]; - } - - $columns = implode(',', $column_list); - - // create a new table and fill it up. destroy the temp one - $statements[] = 'CREATE TABLE ' . $table_name . ' (' . $new_table_cols . ', PRIMARY KEY (' . implode(', ', $column) . '));'; - $statements = array_merge($statements, $recreate_queries); - - $statements[] = 'INSERT INTO ' . $table_name . ' (' . $columns . ') SELECT ' . $columns . ' FROM ' . $table_name . '_temp;'; - $statements[] = 'DROP TABLE ' . $table_name . '_temp'; - - $statements[] = 'commit'; - break; - } - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritDoc} - */ - function sql_create_unique_index($table_name, $index_name, $column) - { - $statements = array(); - - switch ($this->sql_layer) - { - case 'oracle': - case 'sqlite3': - $index_name = $this->check_index_name_length($table_name, $table_name . '_' . $index_name); - $statements[] = 'CREATE UNIQUE INDEX ' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')'; - break; - - case 'mysql_40': - case 'mysql_41': - $index_name = $this->check_index_name_length($table_name, $index_name); - $statements[] = 'ALTER TABLE ' . $table_name . ' ADD UNIQUE INDEX ' . $index_name . '(' . implode(', ', $column) . ')'; - break; - } - - return $this->_sql_run_sql($statements); - } - - /** - * {@inheritDoc} - */ - function sql_create_index($table_name, $index_name, $column) - { - $statements = array(); - - // remove index length unless MySQL4 - if ('mysql_40' != $this->sql_layer) - { - $column = preg_replace('#:.*$#', '', $column); - } - - switch ($this->sql_layer) - { - case 'oracle': - case 'sqlite3': - $index_name = $this->check_index_name_length($table_name, $table_name . '_' . $index_name); - $statements[] = 'CREATE INDEX ' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')'; - break; - - case 'mysql_40': - // add index size to definition as required by MySQL4 - foreach ($column as $i => $col) - { - if (false !== strpos($col, ':')) - { - list($col, $index_size) = explode(':', $col); - $column[$i] = "$col($index_size)"; - } - } - // no break - case 'mysql_41': - $index_name = $this->check_index_name_length($table_name, $index_name); - $statements[] = 'ALTER TABLE ' . $table_name . ' ADD INDEX ' . $index_name . ' (' . implode(', ', $column) . ')'; - break; - } - - return $this->_sql_run_sql($statements); - } - - /** - * Check whether the index name is too long - * - * @param string $table_name - * @param string $index_name - * @param bool $throw_error - * @return string The index name, shortened if too long - */ - protected function check_index_name_length($table_name, $index_name, $throw_error = true) - { - $max_index_name_length = $this->get_max_index_name_length(); - if (strlen($index_name) > $max_index_name_length) - { - // Try removing the table prefix if it's at the beginning - $table_prefix = substr(CONFIG_TABLE, 0, -6); // strlen(config) - if (strpos($index_name, $table_prefix) === 0) - { - $index_name = substr($index_name, strlen($table_prefix)); - return $this->check_index_name_length($table_name, $index_name, $throw_error); - } - - // Try removing the remaining suffix part of table name then - $table_suffix = substr($table_name, strlen($table_prefix)); - if (strpos($index_name, $table_suffix) === 0) - { - // Remove the suffix and underscore separator between table_name and index_name - $index_name = substr($index_name, strlen($table_suffix) + 1); - return $this->check_index_name_length($table_name, $index_name, $throw_error); - } - - if ($throw_error) - { - trigger_error("Index name '$index_name' on table '$table_name' is too long. The maximum is $max_index_name_length characters.", E_USER_ERROR); - } - } - - return $index_name; - } - - /** - * Get maximum index name length. Might vary depending on db type - * - * @return int Maximum index name length - */ - protected function get_max_index_name_length() - { - return 30; - } - - /** - * {@inheritDoc} - */ - function sql_list_index($table_name) - { - $index_array = array(); - - switch ($this->sql_layer) - { - case 'mysql_40': - case 'mysql_41': - $sql = 'SHOW KEYS - FROM ' . $table_name; - $col = 'Key_name'; - break; - - case 'oracle': - $sql = "SELECT index_name - FROM user_indexes - WHERE table_name = '" . strtoupper($table_name) . "' - AND generated = 'N' - AND uniqueness = 'NONUNIQUE'"; - $col = 'index_name'; - break; - - case 'sqlite3': - $sql = "PRAGMA index_info('" . $table_name . "');"; - $col = 'name'; - break; - } - - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - if (($this->sql_layer == 'mysql_40' || $this->sql_layer == 'mysql_41') && !$row['Non_unique']) - { - continue; - } - - switch ($this->sql_layer) - { - case 'oracle': - case 'sqlite3': - $row[$col] = substr($row[$col], strlen($table_name) + 1); - break; - } - - $index_array[] = $row[$col]; - } - $this->db->sql_freeresult($result); - - return array_map('strtolower', $index_array); - } - - /** - * Removes table_name from the index_name if it is at the beginning - * - * @param $table_name - * @param $index_name - * @return string - */ - protected function strip_table_name_from_index_name($table_name, $index_name) - { - return (strpos(strtoupper($index_name), strtoupper($table_name)) === 0) ? substr($index_name, strlen($table_name) + 1) : $index_name; - } - - /** - * {@inheritDoc} - */ - function sql_column_change($table_name, $column_name, $column_data, $inline = false) - { - $original_column_data = $column_data; - $column_data = $this->sql_prepare_column_data($table_name, $column_name, $column_data); - $statements = array(); - - switch ($this->sql_layer) - { - case 'mysql_40': - case 'mysql_41': - $statements[] = 'ALTER TABLE `' . $table_name . '` CHANGE `' . $column_name . '` `' . $column_name . '` ' . $column_data['column_type_sql']; - break; - - case 'oracle': - // We need the data here - $old_return_statements = $this->return_statements; - $this->return_statements = true; - - // Get list of existing indexes - $indexes = $this->get_existing_indexes($table_name, $column_name); - $unique_indexes = $this->get_existing_indexes($table_name, $column_name, true); - - // Drop any indexes - if (!empty($indexes) || !empty($unique_indexes)) - { - $drop_indexes = array_merge(array_keys($indexes), array_keys($unique_indexes)); - foreach ($drop_indexes as $index_name) - { - $result = $this->sql_index_drop($table_name, $this->strip_table_name_from_index_name($table_name, $index_name)); - $statements = array_merge($statements, $result); - } - } - - $temp_column_name = 'temp_' . substr(md5($column_name), 0, 25); - // Add a temporary table with the new type - $result = $this->sql_column_add($table_name, $temp_column_name, $original_column_data); - $statements = array_merge($statements, $result); - - // Copy the data to the new column - $statements[] = 'UPDATE ' . $table_name . ' SET ' . $temp_column_name . ' = ' . $column_name; - - // Drop the original column - $result = $this->sql_column_remove($table_name, $column_name); - $statements = array_merge($statements, $result); - - // Recreate the original column with the new type - $result = $this->sql_column_add($table_name, $column_name, $original_column_data); - $statements = array_merge($statements, $result); - - if (!empty($indexes)) - { - // Recreate indexes after we changed the column - foreach ($indexes as $index_name => $index_data) - { - $result = $this->sql_create_index($table_name, $this->strip_table_name_from_index_name($table_name, $index_name), $index_data); - $statements = array_merge($statements, $result); - } - } - - if (!empty($unique_indexes)) - { - // Recreate unique indexes after we changed the column - foreach ($unique_indexes as $index_name => $index_data) - { - $result = $this->sql_create_unique_index($table_name, $this->strip_table_name_from_index_name($table_name, $index_name), $index_data); - $statements = array_merge($statements, $result); - } - } - - // Copy the data to the original column - $statements[] = 'UPDATE ' . $table_name . ' SET ' . $column_name . ' = ' . $temp_column_name; - - // Drop the temporary column again - $result = $this->sql_column_remove($table_name, $temp_column_name); - $statements = array_merge($statements, $result); - - $this->return_statements = $old_return_statements; - break; - - case 'sqlite3': - - if ($inline && $this->return_statements) - { - return $column_name . ' ' . $column_data['column_type_sql']; - } - - $recreate_queries = $this->sqlite_get_recreate_table_queries($table_name); - if (empty($recreate_queries)) - { - break; - } - - $statements[] = 'begin'; - - $sql_create_table = array_shift($recreate_queries); - - // Create a temp table and populate it, destroy the existing one - $statements[] = preg_replace('#CREATE\s+TABLE\s+"?' . $table_name . '"?#i', 'CREATE TEMPORARY TABLE ' . $table_name . '_temp', $sql_create_table); - $statements[] = 'INSERT INTO ' . $table_name . '_temp SELECT * FROM ' . $table_name; - $statements[] = 'DROP TABLE ' . $table_name; - - preg_match('#\((.*)\)#s', $sql_create_table, $matches); - - $new_table_cols = trim($matches[1]); - $old_table_cols = preg_split('/,(?![\s\w]+\))/m', $new_table_cols); - $column_list = array(); - - foreach ($old_table_cols as $key => $declaration) - { - $declaration = trim($declaration); - - // Check for the beginning of the constraint section and stop - if (preg_match('/[^\(]*\s*PRIMARY KEY\s+\(/', $declaration) || - preg_match('/[^\(]*\s*UNIQUE\s+\(/', $declaration) || - preg_match('/[^\(]*\s*FOREIGN KEY\s+\(/', $declaration) || - preg_match('/[^\(]*\s*CHECK\s+\(/', $declaration)) - { - break; - } - - $entities = preg_split('#\s+#', $declaration); - $column_list[] = $entities[0]; - if ($entities[0] == $column_name) - { - $old_table_cols[$key] = $column_name . ' ' . $column_data['column_type_sql']; - } - } - - $columns = implode(',', $column_list); - - // Create a new table and fill it up. destroy the temp one - $statements[] = 'CREATE TABLE ' . $table_name . ' (' . implode(',', $old_table_cols) . ');'; - $statements = array_merge($statements, $recreate_queries); - - $statements[] = 'INSERT INTO ' . $table_name . ' (' . $columns . ') SELECT ' . $columns . ' FROM ' . $table_name . '_temp;'; - $statements[] = 'DROP TABLE ' . $table_name . '_temp'; - - $statements[] = 'commit'; - - break; - } - - return $this->_sql_run_sql($statements); - } - - /** - * Get a list with existing indexes for the column - * - * @param string $table_name - * @param string $column_name - * @param bool $unique Should we get unique indexes or normal ones - * @return array Array with Index name => columns - */ - public function get_existing_indexes($table_name, $column_name, $unique = false) - { - switch ($this->sql_layer) - { - case 'mysql_40': - case 'mysql_41': - case 'sqlite3': - // Not supported - throw new \Exception('DBMS is not supported'); - break; - } - - $sql = ''; - $existing_indexes = array(); - - switch ($this->sql_layer) - { - case 'oracle': - $sql = "SELECT ix.index_name AS phpbb_index_name, ix.uniqueness AS is_unique - FROM all_ind_columns ixc, all_indexes ix - WHERE ix.index_name = ixc.index_name - AND ixc.table_name = '" . strtoupper($table_name) . "' - AND ixc.column_name = '" . strtoupper($column_name) . "'"; - break; - } - - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - if (!isset($row['is_unique']) || ($unique && $row['is_unique'] == 'UNIQUE') || (!$unique && $row['is_unique'] == 'NONUNIQUE')) - { - $existing_indexes[$row['phpbb_index_name']] = array(); - } - } - $this->db->sql_freeresult($result); - - if (empty($existing_indexes)) - { - return array(); - } - - switch ($this->sql_layer) - { - case 'oracle': - $sql = "SELECT index_name AS phpbb_index_name, column_name AS phpbb_column_name - FROM all_ind_columns - WHERE table_name = '" . strtoupper($table_name) . "' - AND " . $this->db->sql_in_set('index_name', array_keys($existing_indexes)); - break; - } - - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - $existing_indexes[$row['phpbb_index_name']][] = $row['phpbb_column_name']; - } - $this->db->sql_freeresult($result); - - return $existing_indexes; - } - - /** - * Returns the Queries which are required to recreate a table including indexes - * - * @param string $table_name - * @param string $remove_column When we drop a column, we remove the column - * from all indexes. If the index has no other - * column, we drop it completly. - * @return array - */ - protected function sqlite_get_recreate_table_queries($table_name, $remove_column = '') - { - $queries = array(); - - $sql = "SELECT sql - FROM sqlite_master - WHERE type = 'table' - AND name = '{$table_name}'"; - $result = $this->db->sql_query($sql); - $sql_create_table = $this->db->sql_fetchfield('sql'); - $this->db->sql_freeresult($result); - - if (!$sql_create_table) - { - return array(); - } - $queries[] = $sql_create_table; - - $sql = "SELECT sql - FROM sqlite_master - WHERE type = 'index' - AND tbl_name = '{$table_name}'"; - $result = $this->db->sql_query($sql); - while ($sql_create_index = $this->db->sql_fetchfield('sql')) - { - if ($remove_column) - { - $match = array(); - preg_match('#(?:[\w ]+)\((.*)\)#', $sql_create_index, $match); - if (!isset($match[1])) - { - continue; - } - - // Find and remove $remove_column from the index - $columns = explode(', ', $match[1]); - $found_column = array_search($remove_column, $columns); - if ($found_column !== false) - { - unset($columns[$found_column]); - - // If the column list is not empty add the index to the list - if (!empty($columns)) - { - $queries[] = str_replace($match[1], implode(', ', $columns), $sql_create_index); - } - } - else - { - $queries[] = $sql_create_index; - } - } - else - { - $queries[] = $sql_create_index; - } - } - $this->db->sql_freeresult($result); - - return $queries; - } -} diff --git a/install/update/old/phpbb/di/container_builder.php b/install/update/old/phpbb/di/container_builder.php deleted file mode 100644 index 8c1ce8b..0000000 --- a/install/update/old/phpbb/di/container_builder.php +++ /dev/null @@ -1,673 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\di; - -use phpbb\filesystem\filesystem; -use Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper; -use Symfony\Component\Config\ConfigCache; -use Symfony\Component\Config\FileLocator; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Dumper\PhpDumper; -use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; -use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; -use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass; -use Symfony\Component\Filesystem\Exception\IOException; -use Symfony\Component\Finder\Finder; -use Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass; - -class container_builder -{ - /** - * @var string The environment to use. - */ - protected $environment; - - /** - * @var string phpBB Root Path - */ - protected $phpbb_root_path; - - /** - * @var string php file extension - */ - protected $php_ext; - - /** - * The container under construction - * - * @var ContainerBuilder - */ - protected $container; - - /** - * @var \phpbb\db\driver\driver_interface - */ - protected $dbal_connection = null; - - /** - * Indicates whether extensions should be used (default to true). - * - * @var bool - */ - protected $use_extensions = true; - - /** - * Defines a custom path to find the configuration of the container (default to $this->phpbb_root_path . 'config') - * - * @var string - */ - protected $config_path = null; - - /** - * Indicates whether the container should be dumped to the filesystem (default to true). - * - * If DEBUG_CONTAINER is set this option is ignored and a new container is build. - * - * @var bool - */ - protected $use_cache = true; - - /** - * Indicates if the container should be compiled automatically (default to true). - * - * @var bool - */ - protected $compile_container = true; - - /** - * Custom parameters to inject into the container. - * - * Default to: - * array( - * 'core.root_path', $this->phpbb_root_path, - * 'core.php_ext', $this->php_ext, - * ); - * - * @var array - */ - protected $custom_parameters = []; - - /** - * @var \phpbb\config_php_file - */ - protected $config_php_file; - - /** - * @var string - */ - protected $cache_dir; - - /** - * @var array - */ - private $container_extensions; - - /** @var \Exception */ - private $build_exception; - - /** - * Constructor - * - * @param string $phpbb_root_path Path to the phpbb includes directory. - * @param string $php_ext php file extension - */ - public function __construct($phpbb_root_path, $php_ext) - { - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - } - - /** - * Build and return a new Container respecting the current configuration - * - * @return \phpbb_cache_container|ContainerBuilder - */ - public function get_container() - { - try - { - $container_filename = $this->get_container_filename(); - $config_cache = new ConfigCache($container_filename, defined('DEBUG')); - if ($this->use_cache && $config_cache->isFresh()) - { - if ($this->use_extensions) - { - $autoload_cache = new ConfigCache($this->get_autoload_filename(), defined('DEBUG')); - if (!$autoload_cache->isFresh()) - { - // autoload cache should be refreshed - $this->load_extensions(); - } - - require($this->get_autoload_filename()); - } - - require($config_cache->getPath()); - $this->container = new \phpbb_cache_container(); - } - else - { - $this->container_extensions = array(new extension\core($this->get_config_path())); - - if ($this->use_extensions) - { - $this->load_extensions(); - } - - // Inject the config - if ($this->config_php_file) - { - $this->container_extensions[] = new extension\config($this->config_php_file); - } - - $this->container = $this->create_container($this->container_extensions); - - // Easy collections through tags - $this->container->addCompilerPass(new pass\collection_pass()); - - // Event listeners "phpBB style" - $this->container->addCompilerPass(new RegisterListenersPass('dispatcher', 'event.listener_listener', 'event.listener')); - - // Event listeners "Symfony style" - $this->container->addCompilerPass(new RegisterListenersPass('dispatcher')); - - if ($this->use_extensions) - { - $this->register_ext_compiler_pass(); - } - - $filesystem = new filesystem(); - $loader = new YamlFileLoader($this->container, new FileLocator($filesystem->realpath($this->get_config_path()))); - $loader->load($this->container->getParameter('core.environment') . '/config.yml'); - - $this->inject_custom_parameters(); - - if ($this->compile_container) - { - $this->container->compile(); - - if ($this->use_cache) - { - $this->dump_container($config_cache); - } - } - } - - if ($this->compile_container && $this->config_php_file) - { - $this->container->set('config.php', $this->config_php_file); - } - - $this->inject_dbal_driver(); - - return $this->container; - } - catch (\Exception $e) - { - // Don't try to recover if we are in the development environment - if ($this->get_environment() === 'development') - { - throw $e; - } - - if ($this->build_exception === null) - { - $this->build_exception = $e; - - return $this - ->without_extensions() - ->without_cache() - ->with_custom_parameters(array_merge($this->custom_parameters, [ - 'container_exception' => $e, - ])) - ->get_container(); - } - else - { - // Rethrow the original exception if it's still failing - throw $this->build_exception; - } - } - } - - /** - * Enable the extensions. - * - * @param string $environment The environment to use - * @return $this - */ - public function with_environment($environment) - { - $this->environment = $environment; - - return $this; - } - - /** - * Enable the extensions. - * - * @return $this - */ - public function with_extensions() - { - $this->use_extensions = true; - - return $this; - } - - /** - * Disable the extensions. - * - * @return $this - */ - public function without_extensions() - { - $this->use_extensions = false; - - return $this; - } - - /** - * Enable the caching of the container. - * - * If DEBUG_CONTAINER is set this option is ignored and a new container is build. - * - * @return $this - */ - public function with_cache() - { - $this->use_cache = true; - - return $this; - } - - /** - * Disable the caching of the container. - * - * @return $this - */ - public function without_cache() - { - $this->use_cache = false; - - return $this; - } - - /** - * Set the cache directory. - * - * @param string $cache_dir The cache directory. - * @return $this - */ - public function with_cache_dir($cache_dir) - { - $this->cache_dir = $cache_dir; - - return $this; - } - - /** - * Enable the compilation of the container. - * - * @return $this - */ - public function with_compiled_container() - { - $this->compile_container = true; - - return $this; - } - - /** - * Disable the compilation of the container. - * - * @return $this - */ - public function without_compiled_container() - { - $this->compile_container = false; - - return $this; - } - - /** - * Set a custom path to find the configuration of the container. - * - * @param string $config_path - * @return $this - */ - public function with_config_path($config_path) - { - $this->config_path = $config_path; - - return $this; - } - - /** - * Set custom parameters to inject into the container. - * - * @param array $custom_parameters - * @return $this - */ - public function with_custom_parameters($custom_parameters) - { - $this->custom_parameters = $custom_parameters; - - return $this; - } - - /** - * Set custom parameters to inject into the container. - * - * @param \phpbb\config_php_file $config_php_file - * @return $this - */ - public function with_config(\phpbb\config_php_file $config_php_file) - { - $this->config_php_file = $config_php_file; - - return $this; - } - - /** - * Returns the path to the container configuration (default: root_path/config) - * - * @return string - */ - protected function get_config_path() - { - return $this->config_path ?: $this->phpbb_root_path . 'config'; - } - - /** - * Returns the path to the cache directory (default: root_path/cache/environment). - * - * @return string Path to the cache directory. - */ - protected function get_cache_dir() - { - return $this->cache_dir ?: $this->phpbb_root_path . 'cache/' . $this->get_environment() . '/'; - } - - /** - * Load the enabled extensions. - */ - protected function load_extensions() - { - if ($this->config_php_file !== null) - { - // Build an intermediate container to load the ext list from the database - $container_builder = new container_builder($this->phpbb_root_path, $this->php_ext); - $ext_container = $container_builder - ->without_cache() - ->without_extensions() - ->with_config($this->config_php_file) - ->with_config_path($this->get_config_path()) - ->with_environment('production') - ->without_compiled_container() - ->get_container() - ; - - $ext_container->register('cache.driver', '\\phpbb\\cache\\driver\\dummy'); - $ext_container->compile(); - - $extensions = $ext_container->get('ext.manager')->all_enabled(); - - // Load each extension found - $autoloaders = ' $path) - { - $extension_class = '\\' . str_replace('/', '\\', $ext_name) . '\\di\\extension'; - - if (!class_exists($extension_class)) - { - $extension_class = '\\phpbb\\extension\\di\\extension_base'; - } - - $this->container_extensions[] = new $extension_class($ext_name, $path); - - // Load extension autoloader - $filename = $path . 'vendor/autoload.php'; - if (file_exists($filename)) - { - $autoloaders .= "require('{$filename}');\n"; - } - } - - $configCache = new ConfigCache($this->get_autoload_filename(), false); - $configCache->write($autoloaders); - - require($this->get_autoload_filename()); - } - else - { - // To load the extensions we need the database credentials. - // Automatically disable the extensions if we don't have them. - $this->use_extensions = false; - } - } - - /** - * Dump the container to the disk. - * - * @param ConfigCache $cache The config cache - */ - protected function dump_container($cache) - { - try - { - $dumper = new PhpDumper($this->container); - $proxy_dumper = new ProxyDumper(); - $dumper->setProxyDumper($proxy_dumper); - - $cached_container_dump = $dumper->dump(array( - 'class' => 'phpbb_cache_container', - 'base_class' => 'Symfony\\Component\\DependencyInjection\\ContainerBuilder', - )); - - $cache->write($cached_container_dump, $this->container->getResources()); - } - catch (IOException $e) - { - // Don't fail if the cache isn't writeable - } - } - - /** - * Create the ContainerBuilder object - * - * @param array $extensions Array of Container extension objects - * @return ContainerBuilder object - */ - protected function create_container(array $extensions) - { - $container = new ContainerBuilder(new ParameterBag($this->get_core_parameters())); - $container->setProxyInstantiator(new proxy_instantiator($this->get_cache_dir())); - - $extensions_alias = array(); - - foreach ($extensions as $extension) - { - $container->registerExtension($extension); - $extensions_alias[] = $extension->getAlias(); - } - - $container->getCompilerPassConfig()->setMergePass(new MergeExtensionConfigurationPass($extensions_alias)); - - return $container; - } - - /** - * Inject the customs parameters into the container - */ - protected function inject_custom_parameters() - { - foreach ($this->custom_parameters as $key => $value) - { - $this->container->setParameter($key, $value); - } - } - - /** - * Inject the dbal connection driver into container - */ - protected function inject_dbal_driver() - { - if (empty($this->config_php_file)) - { - return; - } - - $config_data = $this->config_php_file->get_all(); - if (!empty($config_data)) - { - if ($this->dbal_connection === null) - { - $dbal_driver_class = $this->config_php_file->convert_30_dbms_to_31($this->config_php_file->get('dbms')); - /** @var \phpbb\db\driver\driver_interface $dbal_connection */ - $this->dbal_connection = new $dbal_driver_class(); - $this->dbal_connection->sql_connect( - $this->config_php_file->get('dbhost'), - $this->config_php_file->get('dbuser'), - $this->config_php_file->get('dbpasswd'), - $this->config_php_file->get('dbname'), - $this->config_php_file->get('dbport'), - false, - defined('PHPBB_DB_NEW_LINK') && PHPBB_DB_NEW_LINK - ); - } - $this->container->set('dbal.conn.driver', $this->dbal_connection); - } - } - - /** - * Returns the core parameters. - * - * @return array An array of core parameters - */ - protected function get_core_parameters() - { - return array_merge( - array( - 'core.root_path' => $this->phpbb_root_path, - 'core.php_ext' => $this->php_ext, - 'core.environment' => $this->get_environment(), - 'core.debug' => defined('DEBUG') ? DEBUG : false, - 'core.cache_dir' => $this->get_cache_dir(), - ), - $this->get_env_parameters() - ); - } - - /** - * Gets the environment parameters. - * - * Only the parameters starting with "PHPBB__" are considered. - * - * @return array An array of parameters - */ - protected function get_env_parameters() - { - $parameters = array(); - foreach ($_SERVER as $key => $value) - { - if (0 === strpos($key, 'PHPBB__')) - { - $parameters[strtolower(str_replace('__', '.', substr($key, 9)))] = $value; - } - } - - return $parameters; - } - - /** - * Get the filename under which the dumped container will be stored. - * - * @return string Path for dumped container - */ - protected function get_container_filename() - { - $container_params = [ - 'phpbb_root_path' => $this->phpbb_root_path, - 'use_extensions' => $this->use_extensions, - 'config_path' => $this->config_path, - ]; - - return $this->get_cache_dir() . 'container_' . md5(implode(',', $container_params)) . '.' . $this->php_ext; - } - - /** - * Get the filename under which the dumped extensions autoloader will be stored. - * - * @return string Path for dumped extensions autoloader - */ - protected function get_autoload_filename() - { - $container_params = [ - 'phpbb_root_path' => $this->phpbb_root_path, - 'use_extensions' => $this->use_extensions, - 'config_path' => $this->config_path, - ]; - - return $this->get_cache_dir() . 'autoload_' . md5(implode(',', $container_params)) . '.' . $this->php_ext; - } - - /** - * Return the name of the current environment. - * - * @return string - */ - protected function get_environment() - { - return $this->environment ?: PHPBB_ENVIRONMENT; - } - - private function register_ext_compiler_pass() - { - $finder = new Finder(); - $finder - ->name('*_pass.php') - ->path('di/pass') - ->files() - ->ignoreDotFiles(true) - ->ignoreUnreadableDirs(true) - ->ignoreVCS(true) - ->followLinks() - ->in($this->phpbb_root_path . 'ext') - ; - - /** @var \SplFileInfo $pass */ - foreach ($finder as $pass) - { - $filename = $pass->getPathname(); - $filename = substr($filename, 0, -strlen('.' . $pass->getExtension())); - $filename = str_replace(DIRECTORY_SEPARATOR, '/', $filename); - $className = preg_replace('#^.*ext/#', '', $filename); - $className = '\\' . str_replace('/', '\\', $className); - - if (class_exists($className) && in_array('Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface', class_implements($className), true)) - { - $this->container->addCompilerPass(new $className()); - } - } - } -} diff --git a/install/update/old/phpbb/di/extension/container_configuration.php b/install/update/old/phpbb/di/extension/container_configuration.php deleted file mode 100644 index 4585d65..0000000 --- a/install/update/old/phpbb/di/extension/container_configuration.php +++ /dev/null @@ -1,52 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\di\extension; - -use Symfony\Component\Config\Definition\Builder\TreeBuilder; -use Symfony\Component\Config\Definition\ConfigurationInterface; - -class container_configuration implements ConfigurationInterface -{ - - /** - * Generates the configuration tree builder. - * - * @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The tree builder - */ - public function getConfigTreeBuilder() - { - $treeBuilder = new TreeBuilder(); - $rootNode = $treeBuilder->root('core'); - $rootNode - ->children() - ->booleanNode('require_dev_dependencies')->defaultValue(false)->end() - ->arrayNode('debug') - ->addDefaultsIfNotSet() - ->children() - ->booleanNode('exceptions')->defaultValue(false)->end() - ->end() - ->end() - ->arrayNode('twig') - ->addDefaultsIfNotSet() - ->children() - ->booleanNode('debug')->defaultValue(null)->end() - ->booleanNode('auto_reload')->defaultValue(null)->end() - ->booleanNode('enable_debug_extension')->defaultValue(false)->end() - ->end() - ->end() - ->end() - ; - return $treeBuilder; - } -} diff --git a/install/update/old/phpbb/di/extension/core.php b/install/update/old/phpbb/di/extension/core.php deleted file mode 100644 index 67150f0..0000000 --- a/install/update/old/phpbb/di/extension/core.php +++ /dev/null @@ -1,124 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\di\extension; - -use Symfony\Component\Config\FileLocator; -use Symfony\Component\Config\Resource\FileResource; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; -use Symfony\Component\HttpKernel\DependencyInjection\Extension; - -/** -* Container core extension -*/ -class core extends Extension -{ - const TWIG_OPTIONS_POSITION = 7; - - /** - * Config path - * @var string - */ - protected $config_path; - - /** - * Constructor - * - * @param string $config_path Config path - */ - public function __construct($config_path) - { - $this->config_path = $config_path; - } - - /** - * Loads a specific configuration. - * - * @param array $configs An array of configuration values - * @param ContainerBuilder $container A ContainerBuilder instance - * - * @throws \InvalidArgumentException When provided tag is not defined in this extension - */ - public function load(array $configs, ContainerBuilder $container) - { - $filesystem = new \phpbb\filesystem\filesystem(); - $loader = new YamlFileLoader($container, new FileLocator($filesystem->realpath($this->config_path))); - $loader->load($container->getParameter('core.environment') . '/container/environment.yml'); - - $config = $this->getConfiguration($configs, $container); - $config = $this->processConfiguration($config, $configs); - - if ($config['require_dev_dependencies']) - { - if (!class_exists('Goutte\Client', true)) - { - trigger_error( - 'Composer development dependencies have not been set up for the ' . $container->getParameter('core.environment') . ' environment yet, run ' . - "'php ../composer.phar install --dev' from the phpBB directory to do so.", - E_USER_ERROR - ); - } - } - - // Set the Twig options if defined in the environment - $definition = $container->getDefinition('template.twig.environment'); - $twig_environment_options = $definition->getArgument(static::TWIG_OPTIONS_POSITION); - if ($config['twig']['debug']) - { - $twig_environment_options['debug'] = true; - } - if ($config['twig']['auto_reload']) - { - $twig_environment_options['auto_reload'] = true; - } - - // Replace the 7th argument, the options passed to the environment - $definition->replaceArgument(static::TWIG_OPTIONS_POSITION, $twig_environment_options); - - if ($config['twig']['enable_debug_extension']) - { - $definition = $container->getDefinition('template.twig.extensions.debug'); - $definition->addTag('twig.extension'); - } - - // Set the debug options - foreach ($config['debug'] as $name => $value) - { - $container->setParameter('debug.' . $name, $value); - } - } - - /** - * {@inheritdoc} - */ - public function getConfiguration(array $config, ContainerBuilder $container) - { - $r = new \ReflectionClass('\phpbb\di\extension\container_configuration'); - $container->addResource(new FileResource($r->getFileName())); - - return new container_configuration(); - } - - /** - * Returns the recommended alias to use in XML. - * - * This alias is also the mandatory prefix to use when using YAML. - * - * @return string The alias - */ - public function getAlias() - { - return 'core'; - } -} diff --git a/install/update/old/phpbb/di/service_collection.php b/install/update/old/phpbb/di/service_collection.php deleted file mode 100644 index 8e9175e..0000000 --- a/install/update/old/phpbb/di/service_collection.php +++ /dev/null @@ -1,106 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\di; - -use Symfony\Component\DependencyInjection\ContainerInterface; - -/** -* Collection of services to be configured at container compile time. -*/ -class service_collection extends \ArrayObject -{ - /** - * @var \Symfony\Component\DependencyInjection\ContainerInterface - */ - protected $container; - - /** - * @var array - */ - protected $service_classes; - - /** - * Constructor - * - * @param ContainerInterface $container Container object - */ - public function __construct(ContainerInterface $container) - { - $this->container = $container; - $this->service_classes = array(); - } - - /** - * {@inheritdoc} - */ - public function getIterator() - { - return new service_collection_iterator($this); - } - - // Because of a PHP issue we have to redefine offsetExists - // (even with a call to the parent): - // https://bugs.php.net/bug.php?id=66834 - // https://bugs.php.net/bug.php?id=67067 - // But it triggers a sniffer issue that we have to skip - // @codingStandardsIgnoreStart - /** - * {@inheritdoc} - */ - public function offsetExists($index) - { - return parent::offsetExists($index); - } - // @codingStandardsIgnoreEnd - - /** - * {@inheritdoc} - */ - public function offsetGet($index) - { - return $this->container->get($index); - } - - /** - * Add a service to the collection - * - * @param string $name The service name - * @return null - */ - public function add($name) - { - $this->offsetSet($name, null); - } - - /** - * Add a service's class to the collection - * - * @param string $service_id - * @param string $class - */ - public function add_service_class($service_id, $class) - { - $this->service_classes[$service_id] = $class; - } - - /** - * Get services' classes - * - * @return array - */ - public function get_service_classes() - { - return $this->service_classes; - } -} diff --git a/install/update/old/phpbb/event/md_exporter.php b/install/update/old/phpbb/event/md_exporter.php deleted file mode 100644 index c3942bd..0000000 --- a/install/update/old/phpbb/event/md_exporter.php +++ /dev/null @@ -1,561 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\event; - -/** -* Crawls through a markdown file and grabs all events -*/ -class md_exporter -{ - /** @var string Path where we look for files*/ - protected $path; - - /** @var string phpBB Root Path */ - protected $root_path; - - /** @var string The minimum version for the events to return */ - protected $min_version; - - /** @var string The maximum version for the events to return */ - protected $max_version; - - /** @var string */ - protected $filter; - - /** @var string */ - protected $current_event; - - /** @var array */ - protected $events; - - /** - * @param string $phpbb_root_path - * @param mixed $extension String 'vendor/ext' to filter, null for phpBB core - * @param string $min_version - * @param string $max_version - */ - public function __construct($phpbb_root_path, $extension = null, $min_version = null, $max_version = null) - { - $this->root_path = $phpbb_root_path; - $this->path = $this->root_path; - if ($extension) - { - $this->path .= 'ext/' . $extension . '/'; - } - - $this->events = array(); - $this->events_by_file = array(); - $this->filter = $this->current_event = ''; - $this->min_version = $min_version; - $this->max_version = $max_version; - } - - /** - * Get the list of all events - * - * @return array Array with events: name => details - */ - public function get_events() - { - return $this->events; - } - - /** - * @param string $md_file Relative from phpBB root - * @return int Number of events found - * @throws \LogicException - */ - public function crawl_phpbb_directory_adm($md_file) - { - $this->crawl_eventsmd($md_file, 'adm'); - - $file_list = $this->get_recursive_file_list($this->path . 'adm/style/'); - foreach ($file_list as $file) - { - $file_name = 'adm/style/' . $file; - $this->validate_events_from_file($file_name, $this->crawl_file_for_events($file_name)); - } - - return count($this->events); - } - - /** - * @param string $md_file Relative from phpBB root - * @return int Number of events found - * @throws \LogicException - */ - public function crawl_phpbb_directory_styles($md_file) - { - $this->crawl_eventsmd($md_file, 'styles'); - - $styles = array('prosilver'); - foreach ($styles as $style) - { - $file_list = $this->get_recursive_file_list( - $this->path . 'styles/' . $style . '/template/' - ); - - foreach ($file_list as $file) - { - $file_name = 'styles/' . $style . '/template/' . $file; - $this->validate_events_from_file($file_name, $this->crawl_file_for_events($file_name)); - } - } - - return count($this->events); - } - - /** - * @param string $md_file Relative from phpBB root - * @param string $filter Should be 'styles' or 'adm' - * @return int Number of events found - * @throws \LogicException - */ - public function crawl_eventsmd($md_file, $filter) - { - if (!file_exists($this->path . $md_file)) - { - throw new \LogicException("The event docs file '{$md_file}' could not be found"); - } - - $file_content = file_get_contents($this->path . $md_file); - $this->filter = $filter; - - $events = explode("\n\n", $file_content); - foreach ($events as $event) - { - // Last row of the file - if (strpos($event, "\n===\n") === false) - { - continue; - } - - list($event_name, $details) = explode("\n===\n", $event, 2); - $this->validate_event_name($event_name); - $sorted_events = [$this->current_event, $event_name]; - natsort($sorted_events); - $this->current_event = $event_name; - - if (isset($this->events[$this->current_event])) - { - throw new \LogicException("The event '{$this->current_event}' is defined multiple times"); - } - - // Use array_values() to get actual first element and check against natural order - if (array_values($sorted_events)[0] === $event_name) - { - throw new \LogicException("The event '{$sorted_events[1]}' should be defined before '{$sorted_events[0]}'"); - } - - if (($this->filter == 'adm' && strpos($this->current_event, 'acp_') !== 0) - || ($this->filter == 'styles' && strpos($this->current_event, 'acp_') === 0)) - { - continue; - } - - list($file_details, $details) = explode("\n* Since: ", $details, 2); - - $changed_versions = array(); - if (strpos($details, "\n* Changed: ") !== false) - { - list($since, $details) = explode("\n* Changed: ", $details, 2); - while (strpos($details, "\n* Changed: ") !== false) - { - list($changed, $details) = explode("\n* Changed: ", $details, 2); - $changed_versions[] = $changed; - } - list($changed, $description) = explode("\n* Purpose: ", $details, 2); - $changed_versions[] = $changed; - } - else - { - list($since, $description) = explode("\n* Purpose: ", $details, 2); - $changed_versions = array(); - } - - $files = $this->validate_file_list($file_details); - $since = $this->validate_since($since); - $changes = array(); - foreach ($changed_versions as $changed) - { - list($changed_version, $changed_description) = $this->validate_changed($changed); - - if (isset($changes[$changed_version])) - { - throw new \LogicException("Duplicate change information found for event '{$this->current_event}'"); - } - - $changes[$changed_version] = $changed_description; - } - $description = trim($description, "\n") . "\n"; - - if (!$this->version_is_filtered($since)) - { - $is_filtered = false; - foreach ($changes as $version => $null) - { - if ($this->version_is_filtered($version)) - { - $is_filtered = true; - break; - } - } - - if (!$is_filtered) - { - continue; - } - } - - $this->events[$event_name] = array( - 'event' => $this->current_event, - 'files' => $files, - 'since' => $since, - 'changed' => $changes, - 'description' => $description, - ); - } - - return count($this->events); - } - - /** - * The version to check - * - * @param string $version - * @return bool - */ - protected function version_is_filtered($version) - { - return (!$this->min_version || phpbb_version_compare($this->min_version, $version, '<=')) - && (!$this->max_version || phpbb_version_compare($this->max_version, $version, '>=')); - } - - /** - * Format the php events as a wiki table - * - * @param string $action - * @return string Number of events found - */ - public function export_events_for_wiki($action = '') - { - if ($this->filter === 'adm') - { - if ($action === 'diff') - { - $wiki_page = '=== ACP Template Events ===' . "\n"; - } - else - { - $wiki_page = '= ACP Template Events =' . "\n"; - } - $wiki_page .= '{| class="zebra sortable" cellspacing="0" cellpadding="5"' . "\n"; - $wiki_page .= '! Identifier !! Placement !! Added in Release !! Explanation' . "\n"; - } - else - { - if ($action === 'diff') - { - $wiki_page = '=== Template Events ===' . "\n"; - } - else - { - $wiki_page = '= Template Events =' . "\n"; - } - $wiki_page .= '{| class="zebra sortable" cellspacing="0" cellpadding="5"' . "\n"; - $wiki_page .= '! Identifier !! Prosilver Placement (If applicable) !! Added in Release !! Explanation' . "\n"; - } - - foreach ($this->events as $event_name => $event) - { - $wiki_page .= "|- id=\"{$event_name}\"\n"; - $wiki_page .= "| [[#{$event_name}|{$event_name}]] || "; - - if ($this->filter === 'adm') - { - $wiki_page .= implode(', ', $event['files']['adm']); - } - else - { - $wiki_page .= implode(', ', $event['files']['prosilver']); - } - - $wiki_page .= " || {$event['since']} || " . str_replace("\n", ' ', $event['description']) . "\n"; - } - $wiki_page .= '|}' . "\n"; - - return $wiki_page; - } - - /** - * Validates a template event name - * - * @param $event_name - * @return null - * @throws \LogicException - */ - public function validate_event_name($event_name) - { - if (!preg_match('#^([a-z][a-z0-9]*(?:_[a-z][a-z0-9]*)+)$#', $event_name)) - { - throw new \LogicException("Invalid event name '{$event_name}'"); - } - } - - /** - * Validate "Since" Information - * - * @param string $since - * @return string - * @throws \LogicException - */ - public function validate_since($since) - { - if (!$this->validate_version($since)) - { - throw new \LogicException("Invalid since information found for event '{$this->current_event}'"); - } - - return $since; - } - - /** - * Validate "Changed" Information - * - * @param string $changed - * @return string - * @throws \LogicException - */ - public function validate_changed($changed) - { - if (strpos($changed, ' ') !== false) - { - list($version, $description) = explode(' ', $changed, 2); - } - else - { - $version = $changed; - $description = ''; - } - - if (!$this->validate_version($version)) - { - throw new \LogicException("Invalid changed information found for event '{$this->current_event}'"); - } - - return array($version, $description); - } - - /** - * Validate "version" Information - * - * @param string $version - * @return bool True if valid, false otherwise - */ - public function validate_version($version) - { - return preg_match('#^\d+\.\d+\.\d+(?:-(?:a|b|RC|pl)\d+)?$#', $version); - } - - /** - * Validate the files list - * - * @param string $file_details - * @return array - * @throws \LogicException - */ - public function validate_file_list($file_details) - { - $files_list = array( - 'prosilver' => array(), - 'adm' => array(), - ); - - // Multi file list - if (strpos($file_details, "* Locations:\n + ") === 0) - { - $file_details = substr($file_details, strlen("* Locations:\n + ")); - $files = explode("\n + ", $file_details); - foreach ($files as $file) - { - if (!file_exists($this->path . $file) || substr($file, -5) !== '.html') - { - throw new \LogicException("Invalid file '{$file}' not found for event '{$this->current_event}'", 1); - } - - if (($this->filter !== 'adm') && strpos($file, 'styles/prosilver/template/') === 0) - { - $files_list['prosilver'][] = substr($file, strlen('styles/prosilver/template/')); - } - else if (($this->filter === 'adm') && strpos($file, 'adm/style/') === 0) - { - $files_list['adm'][] = substr($file, strlen('adm/style/')); - } - else - { - throw new \LogicException("Invalid file '{$file}' not found for event '{$this->current_event}'", 2); - } - - $this->events_by_file[$file][] = $this->current_event; - } - } - else if ($this->filter == 'adm') - { - $file = substr($file_details, strlen('* Location: ')); - if (!file_exists($this->path . $file) || substr($file, -5) !== '.html') - { - throw new \LogicException("Invalid file '{$file}' not found for event '{$this->current_event}'", 1); - } - - $files_list['adm'][] = substr($file, strlen('adm/style/')); - - $this->events_by_file[$file][] = $this->current_event; - } - else - { - throw new \LogicException("Invalid file list found for event '{$this->current_event}'", 2); - } - - return $files_list; - } - - /** - * Get all template events in a template file - * - * @param string $file - * @return array - * @throws \LogicException - */ - public function crawl_file_for_events($file) - { - if (!file_exists($this->path . $file)) - { - throw new \LogicException("File '{$file}' does not exist", 1); - } - - $event_list = array(); - $file_content = file_get_contents($this->path . $file); - - preg_match_all('/(?:{%|)/U', $file_content, $event_list); - - return $event_list[1]; - } - - /** - * Validates whether all events from $file are in the md file and vice-versa - * - * @param string $file - * @param array $events - * @return true - * @throws \LogicException - */ - public function validate_events_from_file($file, array $events) - { - if (empty($this->events_by_file[$file]) && empty($events)) - { - return true; - } - else if (empty($this->events_by_file[$file])) - { - $event_list = implode("', '", $events); - throw new \LogicException("File '{$file}' should not contain events, but contains: " - . "'{$event_list}'", 1); - } - else if (empty($events)) - { - $event_list = implode("', '", $this->events_by_file[$file]); - throw new \LogicException("File '{$file}' contains no events, but should contain: " - . "'{$event_list}'", 1); - } - - $missing_events_from_file = array(); - foreach ($this->events_by_file[$file] as $event) - { - if (!in_array($event, $events)) - { - $missing_events_from_file[] = $event; - } - } - - if (!empty($missing_events_from_file)) - { - $event_list = implode("', '", $missing_events_from_file); - throw new \LogicException("File '{$file}' does not contain events: '{$event_list}'", 2); - } - - $missing_events_from_md = array(); - foreach ($events as $event) - { - if (!in_array($event, $this->events_by_file[$file])) - { - $missing_events_from_md[] = $event; - } - } - - if (!empty($missing_events_from_md)) - { - $event_list = implode("', '", $missing_events_from_md); - throw new \LogicException("File '{$file}' contains additional events: '{$event_list}'", 3); - } - - return true; - } - - /** - * Returns a list of files in $dir - * - * Works recursive with any depth - * - * @param string $dir Directory to go through - * @return array List of files (including directories) - */ - public function get_recursive_file_list($dir) - { - try - { - $iterator = new \RecursiveIteratorIterator( - new \phpbb\recursive_dot_prefix_filter_iterator( - new \RecursiveDirectoryIterator( - $dir, - \FilesystemIterator::SKIP_DOTS - ) - ), - \RecursiveIteratorIterator::SELF_FIRST - ); - } - catch (\Exception $e) - { - return array(); - } - - $files = array(); - foreach ($iterator as $file_info) - { - /** @var \RecursiveDirectoryIterator $file_info */ - if ($file_info->isDir()) - { - continue; - } - - $relative_path = $iterator->getInnerIterator()->getSubPathname(); - - if (substr($relative_path, -5) == '.html') - { - $files[] = str_replace(DIRECTORY_SEPARATOR, '/', $relative_path); - } - } - - return $files; - } -} diff --git a/install/update/old/phpbb/extension/extension_interface.php b/install/update/old/phpbb/extension/extension_interface.php deleted file mode 100644 index 6a6b6ad..0000000 --- a/install/update/old/phpbb/extension/extension_interface.php +++ /dev/null @@ -1,70 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\extension; - -/** -* The interface extension meta classes have to implement to run custom code -* on enable/disable/purge. -*/ -interface extension_interface -{ - /** - * Indicate whether or not the extension can be enabled. - * - * @return bool - */ - public function is_enableable(); - - /** - * enable_step is executed on enabling an extension until it returns false. - * - * Calls to this function can be made in subsequent requests, when the - * function is invoked through a webserver with a too low max_execution_time. - * - * @param mixed $old_state The return value of the previous call - * of this method, or false on the first call - * @return mixed Returns false after last step, otherwise - * temporary state which is passed as an - * argument to the next step - */ - public function enable_step($old_state); - - /** - * Disables the extension. - * - * Calls to this function can be made in subsequent requests, when the - * function is invoked through a webserver with a too low max_execution_time. - * - * @param mixed $old_state The return value of the previous call - * of this method, or false on the first call - * @return mixed Returns false after last step, otherwise - * temporary state which is passed as an - * argument to the next step - */ - public function disable_step($old_state); - - /** - * purge_step is executed on purging an extension until it returns false. - * - * Calls to this function can be made in subsequent requests, when the - * function is invoked through a webserver with a too low max_execution_time. - * - * @param mixed $old_state The return value of the previous call - * of this method, or false on the first call - * @return mixed Returns false after last step, otherwise - * temporary state which is passed as an - * argument to the next step - */ - public function purge_step($old_state); -} diff --git a/install/update/old/phpbb/extension/manager.php b/install/update/old/phpbb/extension/manager.php deleted file mode 100644 index 4b4109b..0000000 --- a/install/update/old/phpbb/extension/manager.php +++ /dev/null @@ -1,633 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\extension; - -use phpbb\exception\runtime_exception; -use phpbb\file_downloader; -use Symfony\Component\DependencyInjection\ContainerInterface; - -/** -* The extension manager provides means to activate/deactivate extensions. -*/ -class manager -{ - /** @var ContainerInterface */ - protected $container; - - protected $db; - protected $config; - protected $cache; - protected $php_ext; - protected $extensions; - protected $extension_table; - protected $phpbb_root_path; - protected $cache_name; - - /** - * Creates a manager and loads information from database - * - * @param ContainerInterface $container A container - * @param \phpbb\db\driver\driver_interface $db A database connection - * @param \phpbb\config\config $config Config object - * @param \phpbb\filesystem\filesystem_interface $filesystem - * @param string $extension_table The name of the table holding extensions - * @param string $phpbb_root_path Path to the phpbb includes directory. - * @param string $php_ext php file extension, defaults to php - * @param \phpbb\cache\service $cache A cache instance or null - * @param string $cache_name The name of the cache variable, defaults to _ext - */ - public function __construct(ContainerInterface $container, \phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\filesystem\filesystem_interface $filesystem, $extension_table, $phpbb_root_path, $php_ext = 'php', \phpbb\cache\service $cache = null, $cache_name = '_ext') - { - $this->cache = $cache; - $this->cache_name = $cache_name; - $this->config = $config; - $this->container = $container; - $this->db = $db; - $this->extension_table = $extension_table; - $this->filesystem = $filesystem; - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - - $this->extensions = ($this->cache) ? $this->cache->get($this->cache_name) : false; - - if ($this->extensions === false) - { - $this->load_extensions(); - } - } - - /** - * Loads all extension information from the database - * - * @return null - */ - public function load_extensions() - { - $this->extensions = array(); - - // Do not try to load any extensions if the extension table - // does not exist or when installing or updating. - // Note: database updater invokes this code, and in 3.0 - // there is no extension table therefore the rest of this function - // fails - if (defined('IN_INSTALL') || version_compare($this->config['version'], '3.1.0-dev', '<')) - { - return; - } - - $sql = 'SELECT * - FROM ' . $this->extension_table; - - $result = $this->db->sql_query($sql); - $extensions = $this->db->sql_fetchrowset($result); - $this->db->sql_freeresult($result); - - foreach ($extensions as $extension) - { - $extension['ext_path'] = $this->get_extension_path($extension['ext_name']); - $this->extensions[$extension['ext_name']] = $extension; - } - - ksort($this->extensions); - - if ($this->cache) - { - $this->cache->put($this->cache_name, $this->extensions); - } - } - - /** - * Generates the path to an extension - * - * @param string $name The name of the extension - * @param bool $phpbb_relative Whether the path should be relative to phpbb root - * @return string Path to an extension - */ - public function get_extension_path($name, $phpbb_relative = false) - { - $name = str_replace('.', '', $name); - - return (($phpbb_relative) ? $this->phpbb_root_path : '') . 'ext/' . $name . '/'; - } - - /** - * Instantiates the extension meta class for the extension with the given name - * - * @param string $name The extension name - * @return \phpbb\extension\extension_interface Instance of the extension meta class or - * \phpbb\extension\base if the class does not exist - */ - public function get_extension($name) - { - $extension_class_name = str_replace('/', '\\', $name) . '\\ext'; - - $migrator = $this->container->get('migrator'); - - if (class_exists($extension_class_name)) - { - return new $extension_class_name($this->container, $this->get_finder(), $migrator, $name, $this->get_extension_path($name, true)); - } - else - { - return new \phpbb\extension\base($this->container, $this->get_finder(), $migrator, $name, $this->get_extension_path($name, true)); - } - } - - /** - * Instantiates the metadata manager for the extension with the given name - * - * @param string $name The extension name - * @return \phpbb\extension\metadata_manager Instance of the metadata manager - */ - public function create_extension_metadata_manager($name) - { - if (!isset($this->extensions[$name]['metadata'])) - { - $metadata = new \phpbb\extension\metadata_manager($name, $this->get_extension_path($name, true)); - $this->extensions[$name]['metadata'] = $metadata; - } - return $this->extensions[$name]['metadata']; - } - - /** - * Runs a step of the extension enabling process. - * - * Allows the exentension to enable in a long running script that works - * in multiple steps across requests. State is kept for the extension - * in the extensions table. - * - * @param string $name The extension's name - * @return bool False if enabling is finished, true otherwise - */ - public function enable_step($name) - { - // ignore extensions that are already enabled - if ($this->is_enabled($name)) - { - return false; - } - - $old_state = (isset($this->extensions[$name]['ext_state'])) ? unserialize($this->extensions[$name]['ext_state']) : false; - - $extension = $this->get_extension($name); - - if (!$extension->is_enableable()) - { - return false; - } - - $state = $extension->enable_step($old_state); - - $active = ($state === false); - - $extension_data = array( - 'ext_name' => $name, - 'ext_active' => $active, - 'ext_state' => serialize($state), - ); - - $this->extensions[$name] = $extension_data; - $this->extensions[$name]['ext_path'] = $this->get_extension_path($extension_data['ext_name']); - ksort($this->extensions); - - $sql = 'SELECT COUNT(ext_name) as row_count - FROM ' . $this->extension_table . " - WHERE ext_name = '" . $this->db->sql_escape($name) . "'"; - $result = $this->db->sql_query($sql); - $count = $this->db->sql_fetchfield('row_count'); - $this->db->sql_freeresult($result); - - if ($count) - { - $sql = 'UPDATE ' . $this->extension_table . ' - SET ' . $this->db->sql_build_array('UPDATE', $extension_data) . " - WHERE ext_name = '" . $this->db->sql_escape($name) . "'"; - $this->db->sql_query($sql); - } - else - { - $sql = 'INSERT INTO ' . $this->extension_table . ' - ' . $this->db->sql_build_array('INSERT', $extension_data); - $this->db->sql_query($sql); - } - - if ($this->cache) - { - $this->cache->purge(); - } - - if ($active) - { - $this->config->increment('assets_version', 1); - } - - return !$active; - } - - /** - * Enables an extension - * - * This method completely enables an extension. But it could be long running - * so never call this in a script that has a max_execution time. - * - * @param string $name The extension's name - * @return null - */ - public function enable($name) - { - // @codingStandardsIgnoreStart - while ($this->enable_step($name)); - // @codingStandardsIgnoreEnd - } - - /** - * Disables an extension - * - * Calls the disable method on the extension's meta class to allow it to - * process the event. - * - * @param string $name The extension's name - * @return bool False if disabling is finished, true otherwise - */ - public function disable_step($name) - { - // ignore extensions that are not enabled - if (!$this->is_enabled($name)) - { - return false; - } - - $old_state = unserialize($this->extensions[$name]['ext_state']); - - $extension = $this->get_extension($name); - $state = $extension->disable_step($old_state); - - // continue until the state is false - if ($state !== false) - { - $extension_data = array( - 'ext_state' => serialize($state), - ); - $this->extensions[$name]['ext_state'] = serialize($state); - - $sql = 'UPDATE ' . $this->extension_table . ' - SET ' . $this->db->sql_build_array('UPDATE', $extension_data) . " - WHERE ext_name = '" . $this->db->sql_escape($name) . "'"; - $this->db->sql_query($sql); - - if ($this->cache) - { - $this->cache->purge(); - } - - return true; - } - - $extension_data = array( - 'ext_active' => false, - 'ext_state' => serialize(false), - ); - $this->extensions[$name]['ext_active'] = false; - $this->extensions[$name]['ext_state'] = serialize(false); - - $sql = 'UPDATE ' . $this->extension_table . ' - SET ' . $this->db->sql_build_array('UPDATE', $extension_data) . " - WHERE ext_name = '" . $this->db->sql_escape($name) . "'"; - $this->db->sql_query($sql); - - if ($this->cache) - { - $this->cache->purge(); - } - - return false; - } - - /** - * Disables an extension - * - * Disables an extension completely at once. This process could run for a - * while so never call this in a script that has a max_execution time. - * - * @param string $name The extension's name - * @return null - */ - public function disable($name) - { - // @codingStandardsIgnoreStart - while ($this->disable_step($name)); - // @codingStandardsIgnoreEnd - } - - /** - * Purge an extension - * - * Disables the extension first if active, and then calls purge on the - * extension's meta class to delete the extension's database content. - * - * @param string $name The extension's name - * @return bool False if purging is finished, true otherwise - */ - public function purge_step($name) - { - // ignore extensions that are not configured - if (!$this->is_configured($name)) - { - return false; - } - - // disable first if necessary - if ($this->extensions[$name]['ext_active']) - { - $this->disable($name); - } - - $old_state = unserialize($this->extensions[$name]['ext_state']); - - $extension = $this->get_extension($name); - $state = $extension->purge_step($old_state); - - // continue until the state is false - if ($state !== false) - { - $extension_data = array( - 'ext_state' => serialize($state), - ); - $this->extensions[$name]['ext_state'] = serialize($state); - - $sql = 'UPDATE ' . $this->extension_table . ' - SET ' . $this->db->sql_build_array('UPDATE', $extension_data) . " - WHERE ext_name = '" . $this->db->sql_escape($name) . "'"; - $this->db->sql_query($sql); - - if ($this->cache) - { - $this->cache->purge(); - } - - return true; - } - - unset($this->extensions[$name]); - - $sql = 'DELETE FROM ' . $this->extension_table . " - WHERE ext_name = '" . $this->db->sql_escape($name) . "'"; - $this->db->sql_query($sql); - - if ($this->cache) - { - $this->cache->purge(); - } - - return false; - } - - /** - * Purge an extension - * - * Purges an extension completely at once. This process could run for a while - * so never call this in a script that has a max_execution time. - * - * @param string $name The extension's name - * @return null - */ - public function purge($name) - { - // @codingStandardsIgnoreStart - while ($this->purge_step($name)); - // @codingStandardsIgnoreEnd - } - - /** - * Retrieves a list of all available extensions on the filesystem - * - * @return array An array with extension names as keys and paths to the - * extension as values - */ - public function all_available() - { - $available = array(); - if (!is_dir($this->phpbb_root_path . 'ext/')) - { - return $available; - } - - $iterator = new \RecursiveIteratorIterator( - new \phpbb\recursive_dot_prefix_filter_iterator( - new \RecursiveDirectoryIterator($this->phpbb_root_path . 'ext/', \FilesystemIterator::NEW_CURRENT_AND_KEY | \FilesystemIterator::FOLLOW_SYMLINKS) - ), - \RecursiveIteratorIterator::SELF_FIRST - ); - $iterator->setMaxDepth(2); - - foreach ($iterator as $file_info) - { - if ($file_info->isFile() && $file_info->getFilename() == 'composer.json') - { - $ext_name = $iterator->getInnerIterator()->getSubPath(); - $ext_name = str_replace(DIRECTORY_SEPARATOR, '/', $ext_name); - if ($this->is_available($ext_name)) - { - $available[$ext_name] = $this->get_extension_path($ext_name, true); - } - } - } - ksort($available); - return $available; - } - - /** - * Retrieves all configured extensions. - * - * All enabled and disabled extensions are considered configured. A purged - * extension that is no longer in the database is not configured. - * - * @param bool $phpbb_relative Whether the path should be relative to phpbb root - * - * @return array An array with extension names as keys and and the - * database stored extension information as values - */ - public function all_configured($phpbb_relative = true) - { - $configured = array(); - foreach ($this->extensions as $name => $data) - { - if ($this->is_configured($name)) - { - unset($data['metadata']); - $data['ext_path'] = ($phpbb_relative ? $this->phpbb_root_path : '') . $data['ext_path']; - $configured[$name] = $data; - } - } - return $configured; - } - - /** - * Retrieves all enabled extensions. - * @param bool $phpbb_relative Whether the path should be relative to phpbb root - * - * @return array An array with extension names as keys and and the - * database stored extension information as values - */ - public function all_enabled($phpbb_relative = true) - { - $enabled = array(); - foreach ($this->extensions as $name => $data) - { - if ($this->is_enabled($name)) - { - $enabled[$name] = ($phpbb_relative ? $this->phpbb_root_path : '') . $data['ext_path']; - } - } - return $enabled; - } - - /** - * Retrieves all disabled extensions. - * - * @param bool $phpbb_relative Whether the path should be relative to phpbb root - * - * @return array An array with extension names as keys and and the - * database stored extension information as values - */ - public function all_disabled($phpbb_relative = true) - { - $disabled = array(); - foreach ($this->extensions as $name => $data) - { - if ($this->is_disabled($name)) - { - $disabled[$name] = ($phpbb_relative ? $this->phpbb_root_path : '') . $data['ext_path']; - } - } - return $disabled; - } - - /** - * Check to see if a given extension is available on the filesystem - * - * @param string $name Extension name to check NOTE: Can be user input - * @return bool Depending on whether or not the extension is available - */ - public function is_available($name) - { - $md_manager = $this->create_extension_metadata_manager($name); - try - { - return $md_manager->get_metadata('all') && $md_manager->validate_enable(); - } - catch (\phpbb\extension\exception $e) - { - return false; - } - } - - /** - * Check to see if a given extension is enabled - * - * @param string $name Extension name to check - * @return bool Depending on whether or not the extension is enabled - */ - public function is_enabled($name) - { - return isset($this->extensions[$name]['ext_active']) && $this->extensions[$name]['ext_active']; - } - - /** - * Check to see if a given extension is disabled - * - * @param string $name Extension name to check - * @return bool Depending on whether or not the extension is disabled - */ - public function is_disabled($name) - { - return isset($this->extensions[$name]['ext_active']) && !$this->extensions[$name]['ext_active']; - } - - /** - * Check to see if a given extension is configured - * - * All enabled and disabled extensions are considered configured. A purged - * extension that is no longer in the database is not configured. - * - * @param string $name Extension name to check - * @return bool Depending on whether or not the extension is configured - */ - public function is_configured($name) - { - return isset($this->extensions[$name]['ext_active']); - } - - /** - * Check the version and return the available updates (for an extension). - * - * @param \phpbb\extension\metadata_manager $md_manager The metadata manager for the version to check. - * @param bool $force_update Ignores cached data. Defaults to false. - * @param bool $force_cache Force the use of the cache. Override $force_update. - * @param string $stability Force the stability (null by default). - * @return array - * @throws runtime_exception - */ - public function version_check(\phpbb\extension\metadata_manager $md_manager, $force_update = false, $force_cache = false, $stability = null) - { - $meta = $md_manager->get_metadata('all'); - - if (!isset($meta['extra']['version-check'])) - { - throw new runtime_exception('NO_VERSIONCHECK'); - } - - $version_check = $meta['extra']['version-check']; - - $version_helper = new \phpbb\version_helper($this->cache, $this->config, new file_downloader()); - $version_helper->set_current_version($meta['version']); - $version_helper->set_file_location($version_check['host'], $version_check['directory'], $version_check['filename'], isset($version_check['ssl']) ? $version_check['ssl'] : false); - $version_helper->force_stability($stability); - - return $version_helper->get_ext_update_on_branch($force_update, $force_cache); - } - - /** - * Check to see if a given extension is purged - * - * An extension is purged if it is available, not enabled and not disabled. - * - * @param string $name Extension name to check - * @return bool Depending on whether or not the extension is purged - */ - public function is_purged($name) - { - return $this->is_available($name) && !$this->is_configured($name); - } - - /** - * Instantiates a \phpbb\finder. - * - * @param bool $use_all_available Should we load all extensions, or just enabled ones - * @return \phpbb\finder An extension finder instance - */ - public function get_finder($use_all_available = false) - { - $finder = new \phpbb\finder($this->filesystem, $this->phpbb_root_path, $this->cache, $this->php_ext, $this->cache_name . '_finder'); - if ($use_all_available) - { - $finder->set_extensions(array_keys($this->all_available())); - } - else - { - $finder->set_extensions(array_keys($this->all_enabled())); - } - return $finder; - } -} diff --git a/install/update/old/phpbb/feed/controller/feed.php b/install/update/old/phpbb/feed/controller/feed.php deleted file mode 100644 index c0d7bc7..0000000 --- a/install/update/old/phpbb/feed/controller/feed.php +++ /dev/null @@ -1,411 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\feed\controller; - -use phpbb\auth\auth; -use phpbb\config\config; -use phpbb\db\driver\driver_interface; -use \phpbb\event\dispatcher_interface; -use phpbb\exception\http_exception; -use phpbb\feed\feed_interface; -use phpbb\feed\exception\feed_unavailable_exception; -use phpbb\feed\exception\unauthorized_exception; -use phpbb\feed\helper as feed_helper; -use phpbb\controller\helper as controller_helper; -use phpbb\symfony_request; -use phpbb\user; -use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Routing\Generator\UrlGeneratorInterface; - -class feed -{ - /** - * @var \Twig_Environment - */ - protected $template; - - /** - * @var symfony_request - */ - protected $request; - - /** - * @var controller_helper - */ - protected $controller_helper; - - /** - * @var config - */ - protected $config; - - /** - * @var driver_interface - */ - protected $db; - - /** - * @var ContainerInterface - */ - protected $container; - - /** - * @var feed_helper - */ - protected $feed_helper; - - /** - * @var user - */ - protected $user; - - /** - * @var auth - */ - protected $auth; - - /** - * @var dispatcher_interface - */ - protected $phpbb_dispatcher; - - /** - * @var string - */ - protected $php_ext; - - /** - * Constructor - * - * @param \Twig_Environment $twig - * @param symfony_request $request - * @param controller_helper $controller_helper - * @param config $config - * @param driver_interface $db - * @param ContainerInterface $container - * @param feed_helper $feed_helper - * @param user $user - * @param auth $auth - * @param dispatcher_interface $phpbb_dispatcher - * @param string $php_ext - */ - public function __construct(\Twig_Environment $twig, symfony_request $request, controller_helper $controller_helper, config $config, driver_interface $db, ContainerInterface $container, feed_helper $feed_helper, user $user, auth $auth, dispatcher_interface $phpbb_dispatcher, $php_ext) - { - $this->request = $request; - $this->controller_helper = $controller_helper; - $this->config = $config; - $this->db = $db; - $this->container = $container; - $this->feed_helper = $feed_helper; - $this->user = $user; - $this->auth = $auth; - $this->php_ext = $php_ext; - $this->template = $twig; - $this->phpbb_dispatcher = $phpbb_dispatcher; - } - - /** - * Controller for /feed/forums route - * - * @return Response - * - * @throws http_exception when the feed is disabled - */ - public function forums() - { - if (!$this->config['feed_overall_forums']) - { - $this->send_unavailable(); - } - - return $this->send_feed($this->container->get('feed.forums')); - } - - /** - * Controller for /feed/news route - * - * @return Response - * - * @throws http_exception when the feed is disabled - */ - public function news() - { - // Get at least one news forum - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE . ' - WHERE ' . $this->db->sql_bit_and('forum_options', FORUM_OPTION_FEED_NEWS, '<> 0'); - $result = $this->db->sql_query_limit($sql, 1, 0, 600); - $s_feed_news = (int) $this->db->sql_fetchfield('forum_id'); - $this->db->sql_freeresult($result); - - if (!$s_feed_news) - { - $this->send_unavailable(); - } - - return $this->send_feed($this->container->get('feed.news')); - } - - /** - * Controller for /feed/topics route - * - * @return Response - * - * @throws http_exception when the feed is disabled - */ - public function topics() - { - if (!$this->config['feed_topics_new']) - { - $this->send_unavailable(); - } - - return $this->send_feed($this->container->get('feed.topics')); - } - - /** - * Controller for /feed/topics_new route - * - * @return Response - * - * @throws http_exception when the feed is disabled - */ - public function topics_new() - { - return $this->topics(); - } - - /** - * Controller for /feed/topics_active route - * - * @return Response - * - * @throws http_exception when the feed is disabled - */ - public function topics_active() - { - if (!$this->config['feed_topics_active']) - { - $this->send_unavailable(); - } - - return $this->send_feed($this->container->get('feed.topics_active')); - } - - /** - * Controller for /feed/forum/{forum_id} route - * - * @param int $forum_id - * - * @return Response - * - * @throws http_exception when the feed is disabled - */ - public function forum($forum_id) - { - if (!$this->config['feed_forum']) - { - $this->send_unavailable(); - } - - return $this->send_feed($this->container->get('feed.forum')->set_forum_id($forum_id)); - } - - /** - * Controller for /feed/topic/{topic_id} route - * - * @param int $topic_id - * - * @return Response - * - * @throws http_exception when the feed is disabled - */ - public function topic($topic_id) - { - if (!$this->config['feed_topic']) - { - $this->send_unavailable(); - } - - return $this->send_feed($this->container->get('feed.topic')->set_topic_id($topic_id)); - } - - /** - * Controller for /feed/{mode] route - * - * @return Response - * - * @throws http_exception when the feed is disabled - */ - public function overall() - { - if (!$this->config['feed_overall']) - { - $this->send_unavailable(); - } - - return $this->send_feed($this->container->get('feed.overall')); - } - - /** - * Display a given feed - * - * @param feed_interface $feed - * - * @return Response - */ - protected function send_feed(feed_interface $feed) - { - try - { - return $this->send_feed_do($feed); - } - catch (feed_unavailable_exception $e) - { - throw new http_exception(Response::HTTP_NOT_FOUND, $e->getMessage(), $e->get_parameters(), $e); - } - catch (unauthorized_exception $e) - { - throw new http_exception(Response::HTTP_FORBIDDEN, $e->getMessage(), $e->get_parameters(), $e); - } - } - - /** - * Really send the feed - * - * @param feed_interface $feed - * - * @return Response - * - * @throw exception\feed_exception - */ - protected function send_feed_do(feed_interface $feed) - { - $feed_updated_time = 0; - $item_vars = array(); - - $board_url = $this->feed_helper->get_board_url(); - - // Open Feed - $feed->open(); - - // Iterate through items - while ($row = $feed->get_item()) - { - /** - * Event to modify the feed row - * - * @event core.feed_modify_feed_row - * @var int forum_id Forum ID - * @var string mode Feeds mode (forums|topics|topics_new|topics_active|news) - * @var array row Array with feed data - * @var int topic_id Topic ID - * - * @since 3.1.10-RC1 - */ - $vars = array('forum_id', 'mode', 'row', 'topic_id'); - extract($this->phpbb_dispatcher->trigger_event('core.feed_modify_feed_row', compact($vars))); - - // BBCode options to correctly disable urls, smilies, bbcode... - if ($feed->get('options') === null) - { - // Allow all combinations - $options = 7; - - if ($feed->get('enable_bbcode') !== null && $feed->get('enable_smilies') !== null && $feed->get('enable_magic_url') !== null) - { - $options = (($row[$feed->get('enable_bbcode')]) ? OPTION_FLAG_BBCODE : 0) + (($row[$feed->get('enable_smilies')]) ? OPTION_FLAG_SMILIES : 0) + (($row[$feed->get('enable_magic_url')]) ? OPTION_FLAG_LINKS : 0); - } - } - else - { - $options = $row[$feed->get('options')]; - } - - $title = (isset($row[$feed->get('title')]) && $row[$feed->get('title')] !== '') ? $row[$feed->get('title')] : ((isset($row[$feed->get('title2')])) ? $row[$feed->get('title2')] : ''); - - $published = ($feed->get('published') !== null) ? (int) $row[$feed->get('published')] : 0; - $updated = ($feed->get('updated') !== null) ? (int) $row[$feed->get('updated')] : 0; - - $display_attachments = ($this->auth->acl_get('u_download') && $this->auth->acl_get('f_download', $row['forum_id']) && isset($row['post_attachment']) && $row['post_attachment']) ? true : false; - - $item_row = array( - 'author' => ($feed->get('creator') !== null) ? $row[$feed->get('creator')] : '', - 'published' => ($published > 0) ? $this->feed_helper->format_date($published) : '', - 'updated' => ($updated > 0) ? $this->feed_helper->format_date($updated) : '', - 'link' => '', - 'title' => censor_text($title), - 'category' => ($this->config['feed_item_statistics'] && !empty($row['forum_id'])) ? $board_url . '/viewforum.' . $this->php_ext . '?f=' . $row['forum_id'] : '', - 'category_name' => ($this->config['feed_item_statistics'] && isset($row['forum_name'])) ? $row['forum_name'] : '', - 'description' => censor_text($this->feed_helper->generate_content($row[$feed->get('text')], $row[$feed->get('bbcode_uid')], $row[$feed->get('bitfield')], $options, $row['forum_id'], ($display_attachments ? $feed->get_attachments($row['post_id']) : array()))), - 'statistics' => '', - ); - - // Adjust items, fill link, etc. - $feed->adjust_item($item_row, $row); - - $item_vars[] = $item_row; - - $feed_updated_time = max($feed_updated_time, $published, $updated); - } - - // If we do not have any items at all, sending the current time is better than sending no time. - if (!$feed_updated_time) - { - $feed_updated_time = time(); - } - - $feed->close(); - - $content = $this->template->render('feed.xml.twig', array( - // Some default assignments - // FEED_IMAGE is not used (atom) - 'FEED_IMAGE' => '', - 'SELF_LINK' => $this->controller_helper->route($this->request->attributes->get('_route'), $this->request->attributes->get('_route_params'), true, '', UrlGeneratorInterface::ABSOLUTE_URL), - 'FEED_LINK' => $board_url . '/index.' . $this->php_ext, - 'FEED_TITLE' => $this->config['sitename'], - 'FEED_SUBTITLE' => $this->config['site_desc'], - 'FEED_UPDATED' => $this->feed_helper->format_date($feed_updated_time), - 'FEED_LANG' => $this->user->lang['USER_LANG'], - 'FEED_AUTHOR' => $this->config['sitename'], - - // Feed entries - 'FEED_ROWS' => $item_vars, - )); - - $response = new Response($content); - $response->headers->set('Content-Type', 'application/atom+xml'); - $response->setCharset('UTF-8'); - $response->setLastModified(new \DateTime('@' . $feed_updated_time)); - - if (!empty($this->user->data['is_bot'])) - { - // Let reverse proxies know we detected a bot. - $response->headers->set('X-PHPBB-IS-BOT', 'yes'); - } - - return $response; - } - - /** - * Throw and exception saying that the feed isn't available - * - * @throw http_exception - */ - protected function send_unavailable() - { - throw new http_exception(404, 'FEATURE_NOT_AVAILABLE'); - } -} diff --git a/install/update/old/phpbb/feed/topics_active.php b/install/update/old/phpbb/feed/topics_active.php deleted file mode 100644 index ea9ee97..0000000 --- a/install/update/old/phpbb/feed/topics_active.php +++ /dev/null @@ -1,147 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\feed; - -/** - * Active Topics feed - * - * This will give you the last {$this->num_items} topics - * with replies made withing the last {$this->sort_days} days - * including the last post. - */ -class topics_active extends topic_base -{ - protected $sort_days = 7; - - /** - * {@inheritdoc} - */ - public function set_keys() - { - parent::set_keys(); - - $this->set('author_id', 'topic_last_poster_id'); - $this->set('creator', 'topic_last_poster_name'); - } - - /** - * {@inheritdoc} - */ - protected function get_sql() - { - $forum_ids_read = $this->get_readable_forums(); - if (empty($forum_ids_read)) - { - return false; - } - - $in_fid_ary = array_intersect($forum_ids_read, $this->get_forum_ids()); - $in_fid_ary = array_diff($in_fid_ary, $this->get_passworded_forums()); - if (empty($in_fid_ary)) - { - return false; - } - - // Search for topics in last X days - $last_post_time_sql = ($this->sort_days) ? ' AND topic_last_post_time > ' . (time() - ($this->sort_days * 24 * 3600)) : ''; - - // We really have to get the post ids first! - $sql = 'SELECT topic_last_post_id, topic_last_post_time - FROM ' . TOPICS_TABLE . ' - WHERE topic_moved_id = 0 - AND ' . $this->content_visibility->get_forums_visibility_sql('topic', $in_fid_ary) . ' - ' . $last_post_time_sql . ' - ORDER BY topic_last_post_time DESC, topic_last_post_id DESC'; - $result = $this->db->sql_query_limit($sql, $this->num_items); - - $post_ids = array(); - while ($row = $this->db->sql_fetchrow($result)) - { - $post_ids[] = (int) $row['topic_last_post_id']; - } - $this->db->sql_freeresult($result); - - if (empty($post_ids)) - { - return false; - } - - parent::fetch_attachments($post_ids); - - $this->sql = array( - 'SELECT' => 'f.forum_id, f.forum_name, - t.topic_id, t.topic_title, t.topic_posts_approved, t.topic_posts_unapproved, t.topic_posts_softdeleted, t.topic_views, - t.topic_last_poster_id, t.topic_last_poster_name, t.topic_last_post_time, - p.post_id, p.post_time, p.post_edit_time, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, p.post_attachment, t.topic_visibility', - 'FROM' => array( - TOPICS_TABLE => 't', - POSTS_TABLE => 'p', - ), - 'LEFT_JOIN' => array( - array( - 'FROM' => array(FORUMS_TABLE => 'f'), - 'ON' => 'p.forum_id = f.forum_id', - ), - ), - 'WHERE' => 'p.topic_id = t.topic_id - AND ' . $this->db->sql_in_set('p.post_id', $post_ids), - 'ORDER_BY' => 'p.post_time DESC, p.post_id DESC', - ); - - return true; - } - - /** - * Returns the ids of the forums not excluded from the active list - * - * @return int[] - */ - private function get_forum_ids() - { - static $forum_ids; - - $cache_name = 'feed_topic_active_forum_ids'; - - if (!isset($forum_ids) && ($forum_ids = $this->cache->get('_' . $cache_name)) === false) - { - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE . ' - WHERE forum_type = ' . FORUM_POST . ' - AND ' . $this->db->sql_bit_and('forum_options', FORUM_OPTION_FEED_EXCLUDE, '= 0') . ' - AND ' . $this->db->sql_bit_and('forum_flags', round(log(FORUM_FLAG_ACTIVE_TOPICS, 2)), '<> 0'); - $result = $this->db->sql_query($sql); - - $forum_ids = array(); - while ($forum_id = (int) $this->db->sql_fetchfield('forum_id')) - { - $forum_ids[$forum_id] = $forum_id; - } - $this->db->sql_freeresult($result); - - $this->cache->put('_' . $cache_name, $forum_ids, 180); - } - - return $forum_ids; - } - - /** - * {@inheritdoc} - */ - public function adjust_item(&$item_row, &$row) - { - parent::adjust_item($item_row, $row); - - $item_row['title'] = (isset($row['forum_name']) && $row['forum_name'] !== '') ? $row['forum_name'] . ' ' . $this->separator . ' ' . $item_row['title'] : $item_row['title']; - } -} diff --git a/install/update/old/phpbb/files/filespec.php b/install/update/old/phpbb/files/filespec.php deleted file mode 100644 index 6847bca..0000000 --- a/install/update/old/phpbb/files/filespec.php +++ /dev/null @@ -1,584 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\files; - -use phpbb\language\language; - -/** - * Responsible for holding all file relevant information, as well as doing file-specific operations. - * The {@link fileupload fileupload class} can be used to upload several files, each of them being this object to operate further on. - */ -class filespec -{ - /** @var string File name */ - protected $filename = ''; - - /** @var string Real name of file */ - protected $realname = ''; - - /** @var string Upload name of file */ - protected $uploadname = ''; - - /** @var string Mimetype of file */ - protected $mimetype = ''; - - /** @var string File extension */ - protected $extension = ''; - - /** @var int File size */ - protected $filesize = 0; - - /** @var int Width of file */ - protected $width = 0; - - /** @var int Height of file */ - protected $height = 0; - - /** @var array Image info including type and size */ - protected $image_info = array(); - - /** @var string Destination file name */ - protected $destination_file = ''; - - /** @var string Destination file path */ - protected $destination_path = ''; - - /** @var bool Whether file was moved */ - protected $file_moved = false; - - /** @var bool Whether file is local */ - protected $local = false; - - /** @var bool Class initialization flag */ - protected $class_initialized = false; - - /** @var array Error array */ - public $error = array(); - - /** @var upload Instance of upload class */ - public $upload; - - /** @var \phpbb\filesystem\filesystem_interface */ - protected $filesystem; - - /** @var \bantu\IniGetWrapper\IniGetWrapper ini_get() wrapper class */ - protected $php_ini; - - /** @var \FastImageSize\FastImageSize */ - protected $imagesize; - - /** @var language Language class */ - protected $language; - - /** @var string phpBB root path */ - protected $phpbb_root_path; - - /** @var \phpbb\plupload\plupload The plupload object */ - protected $plupload; - - /** @var \phpbb\mimetype\guesser phpBB Mimetype guesser */ - protected $mimetype_guesser; - - /** - * File upload class - * - * @param \phpbb\filesystem\filesystem_interface $phpbb_filesystem Filesystem - * @param language $language Language - * @param \bantu\IniGetWrapper\IniGetWrapper $php_ini ini_get() wrapper - * @param \FastImageSize\FastImageSize $imagesize Imagesize class - * @param string $phpbb_root_path phpBB root path - * @param \phpbb\mimetype\guesser $mimetype_guesser Mime type guesser - * @param \phpbb\plupload\plupload $plupload Plupload - */ - public function __construct(\phpbb\filesystem\filesystem_interface $phpbb_filesystem, language $language, \bantu\IniGetWrapper\IniGetWrapper $php_ini, \FastImageSize\FastImageSize $imagesize, $phpbb_root_path, \phpbb\mimetype\guesser $mimetype_guesser = null, \phpbb\plupload\plupload $plupload = null) - { - $this->filesystem = $phpbb_filesystem; - $this->language = $language; - $this->php_ini = $php_ini; - $this->imagesize = $imagesize; - $this->phpbb_root_path = $phpbb_root_path; - $this->plupload = $plupload; - $this->mimetype_guesser = $mimetype_guesser; - } - - /** - * Set upload ary - * - * @param array $upload_ary Upload ary - * - * @return filespec This instance of the filespec class - */ - public function set_upload_ary($upload_ary) - { - if (!isset($upload_ary) || !count($upload_ary)) - { - return $this; - } - - $this->class_initialized = true; - $this->filename = $upload_ary['tmp_name']; - $this->filesize = $upload_ary['size']; - $name = $upload_ary['name']; - $name = trim(utf8_basename($name)); - $this->realname = $this->uploadname = $name; - $this->mimetype = $upload_ary['type']; - - // Opera adds the name to the mime type - $this->mimetype = (strpos($this->mimetype, '; name') !== false) ? str_replace(strstr($this->mimetype, '; name'), '', $this->mimetype) : $this->mimetype; - - if (!$this->mimetype) - { - $this->mimetype = 'application/octet-stream'; - } - - $this->extension = strtolower(self::get_extension($this->realname)); - - // Try to get real filesize from temporary folder (not always working) ;) - $this->filesize = ($this->get_filesize($this->filename)) ?: $this->filesize; - - $this->width = $this->height = 0; - $this->file_moved = false; - - $this->local = (isset($upload_ary['local_mode'])) ? true : false; - - return $this; - } - - /** - * Set the upload namespace - * - * @param upload $namespace Instance of upload class - * - * @return filespec This instance of the filespec class - */ - public function set_upload_namespace($namespace) - { - $this->upload = $namespace; - - return $this; - } - - /** - * Check if class members were not properly initialised yet - * - * @return bool True if there was an init error, false if not - */ - public function init_error() - { - return !$this->class_initialized; - } - - /** - * Set error in error array - * - * @param mixed $error Content for error array - * - * @return \phpbb\files\filespec This instance of the filespec class - */ - public function set_error($error) - { - $this->error[] = $error; - - return $this; - } - - /** - * Cleans destination filename - * - * @param string $mode Either real, unique, or unique_ext. Real creates a - * realname, filtering some characters, lowering every - * character. Unique creates a unique filename. - * @param string $prefix Prefix applied to filename - * @param string $user_id The user_id is only needed for when cleaning a user's avatar - */ - public function clean_filename($mode = 'unique', $prefix = '', $user_id = '') - { - if ($this->init_error()) - { - return; - } - - switch ($mode) - { - case 'real': - // Remove every extension from filename (to not let the mime bug being exposed) - if (strpos($this->realname, '.') !== false) - { - $this->realname = substr($this->realname, 0, strpos($this->realname, '.')); - } - - // Replace any chars which may cause us problems with _ - $bad_chars = array("'", "\\", ' ', '/', ':', '*', '?', '"', '<', '>', '|'); - - $this->realname = rawurlencode(str_replace($bad_chars, '_', strtolower($this->realname))); - $this->realname = preg_replace("/%(\w{2})/", '_', $this->realname); - - $this->realname = $prefix . $this->realname . '.' . $this->extension; - break; - - case 'unique': - $this->realname = $prefix . md5(unique_id()); - break; - - case 'avatar': - $this->extension = strtolower($this->extension); - $this->realname = $prefix . $user_id . '.' . $this->extension; - - break; - - case 'unique_ext': - default: - $this->realname = $prefix . md5(unique_id()) . '.' . $this->extension; - } - } - - /** - * Get property from file object - * - * @param string $property Name of property - * - * @return mixed Content of property - */ - public function get($property) - { - if ($this->init_error() || !isset($this->$property)) - { - return false; - } - - return $this->$property; - } - - /** - * Check if file is an image (mime type) - * - * @return bool true if it is an image, false if not - */ - public function is_image() - { - return (strpos($this->mimetype, 'image/') === 0); - } - - /** - * Check if the file got correctly uploaded - * - * @return bool true if it is a valid upload, false if not - */ - public function is_uploaded() - { - $is_plupload = $this->plupload && $this->plupload->is_active(); - - if (!$this->local && !$is_plupload && !is_uploaded_file($this->filename)) - { - return false; - } - - if (($this->local || $is_plupload) && !file_exists($this->filename)) - { - return false; - } - - return true; - } - - /** - * Remove file - */ - public function remove() - { - if ($this->file_moved) - { - @unlink($this->destination_file); - } - } - - /** - * Get file extension - * - * @param string $filename Filename that needs to be checked - * - * @return string Extension of the supplied filename - */ - static public function get_extension($filename) - { - $filename = utf8_basename($filename); - - if (strpos($filename, '.') === false) - { - return ''; - } - - $filename = explode('.', $filename); - return array_pop($filename); - } - - /** - * Get mime type - * - * @param string $filename Filename that needs to be checked - * @return string Mime type of supplied filename - */ - public function get_mimetype($filename) - { - if ($this->mimetype_guesser !== null) - { - $mimetype = $this->mimetype_guesser->guess($filename, $this->uploadname); - - if ($mimetype !== 'application/octet-stream') - { - $this->mimetype = $mimetype; - } - } - - return $this->mimetype; - } - - /** - * Get file size - * - * @param string $filename File name of file to check - * - * @return int File size - */ - public function get_filesize($filename) - { - return @filesize($filename); - } - - - /** - * Check the first 256 bytes for forbidden content - * - * @param array $disallowed_content Array containg disallowed content - * - * @return bool False if disallowed content found, true if not - */ - public function check_content($disallowed_content) - { - if (empty($disallowed_content)) - { - return true; - } - - $fp = @fopen($this->filename, 'rb'); - - if ($fp !== false) - { - $ie_mime_relevant = fread($fp, 256); - fclose($fp); - foreach ($disallowed_content as $forbidden) - { - if (stripos($ie_mime_relevant, '<' . $forbidden) !== false) - { - return false; - } - } - } - return true; - } - - /** - * Move file to destination folder - * The phpbb_root_path variable will be applied to the destination path - * - * @param string $destination Destination path, for example $config['avatar_path'] - * @param bool $overwrite If set to true, an already existing file will be overwritten - * @param bool $skip_image_check If set to true, the check for the file to be a valid image is skipped - * @param string|bool $chmod Permission mask for chmodding the file after a successful move. - * The mode entered here reflects the mode defined by {@link phpbb_chmod()} - * - * @return bool True if file was moved, false if not - * @access public - */ - public function move_file($destination, $overwrite = false, $skip_image_check = false, $chmod = false) - { - if (count($this->error)) - { - return false; - } - - $chmod = ($chmod === false) ? CHMOD_READ | CHMOD_WRITE : $chmod; - - // We need to trust the admin in specifying valid upload directories and an attacker not being able to overwrite it... - $this->destination_path = $this->phpbb_root_path . $destination; - - // Check if the destination path exist... - if (!file_exists($this->destination_path)) - { - @unlink($this->filename); - return false; - } - - $upload_mode = ($this->php_ini->getBool('open_basedir') || $this->php_ini->getBool('safe_mode')) ? 'move' : 'copy'; - $upload_mode = ($this->local) ? 'local' : $upload_mode; - $this->destination_file = $this->destination_path . '/' . utf8_basename($this->realname); - - // Check if the file already exist, else there is something wrong... - if (file_exists($this->destination_file) && !$overwrite) - { - @unlink($this->filename); - $this->error[] = $this->language->lang($this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR', $this->destination_file); - $this->file_moved = false; - return false; - } - else - { - if (file_exists($this->destination_file)) - { - @unlink($this->destination_file); - } - - switch ($upload_mode) - { - case 'copy': - - if (!@copy($this->filename, $this->destination_file)) - { - if (!@move_uploaded_file($this->filename, $this->destination_file)) - { - $this->error[] = $this->language->lang($this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR', $this->destination_file); - } - } - - break; - - case 'move': - - if (!@move_uploaded_file($this->filename, $this->destination_file)) - { - if (!@copy($this->filename, $this->destination_file)) - { - $this->error[] = $this->language->lang($this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR', $this->destination_file); - } - } - - break; - - case 'local': - - if (!@copy($this->filename, $this->destination_file)) - { - $this->error[] = $this->language->lang($this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR', $this->destination_file); - } - - break; - } - - // Remove temporary filename - @unlink($this->filename); - - if (count($this->error)) - { - return false; - } - - try - { - $this->filesystem->phpbb_chmod($this->destination_file, $chmod); - } - catch (\phpbb\filesystem\exception\filesystem_exception $e) - { - // Do nothing - } - } - - // Try to get real filesize from destination folder - $this->filesize = ($this->get_filesize($this->destination_file)) ?: $this->filesize; - - // Get mimetype of supplied file - $this->mimetype = $this->get_mimetype($this->destination_file); - - if ($this->is_image() && !$skip_image_check) - { - $this->width = $this->height = 0; - - $this->image_info = $this->imagesize->getImageSize($this->destination_file, $this->mimetype); - - if ($this->image_info !== false) - { - $this->width = $this->image_info['width']; - $this->height = $this->image_info['height']; - - // Check image type - $types = upload::image_types(); - - if (!isset($types[$this->image_info['type']]) || !in_array($this->extension, $types[$this->image_info['type']])) - { - if (!isset($types[$this->image_info['type']])) - { - $this->error[] = $this->language->lang('IMAGE_FILETYPE_INVALID', $this->image_info['type'], $this->mimetype); - } - else - { - $this->error[] = $this->language->lang('IMAGE_FILETYPE_MISMATCH', $types[$this->image_info['type']][0], $this->extension); - } - } - - // Make sure the dimensions match a valid image - if (empty($this->width) || empty($this->height)) - { - $this->error[] = $this->language->lang('ATTACHED_IMAGE_NOT_IMAGE'); - } - } - else - { - $this->error[] = $this->language->lang('UNABLE_GET_IMAGE_SIZE'); - } - } - - $this->file_moved = true; - $this->additional_checks(); - unset($this->upload); - - return true; - } - - /** - * Performing additional checks - * - * @return bool False if issue was found, true if not - */ - public function additional_checks() - { - if (!$this->file_moved) - { - return false; - } - - // Filesize is too big or it's 0 if it was larger than the maxsize in the upload form - if ($this->upload->max_filesize && ($this->get('filesize') > $this->upload->max_filesize || $this->filesize == 0)) - { - $max_filesize = get_formatted_filesize($this->upload->max_filesize, false); - - $this->error[] = $this->language->lang($this->upload->error_prefix . 'WRONG_FILESIZE', $max_filesize['value'], $max_filesize['unit']); - - return false; - } - - if (!$this->upload->valid_dimensions($this)) - { - $this->error[] = $this->language->lang($this->upload->error_prefix . 'WRONG_SIZE', - $this->language->lang('PIXELS', (int) $this->upload->min_width), - $this->language->lang('PIXELS', (int) $this->upload->min_height), - $this->language->lang('PIXELS', (int) $this->upload->max_width), - $this->language->lang('PIXELS', (int) $this->upload->max_height), - $this->language->lang('PIXELS', (int) $this->width), - $this->language->lang('PIXELS', (int) $this->height)); - - return false; - } - - return true; - } -} diff --git a/install/update/old/phpbb/filesystem.php b/install/update/old/phpbb/filesystem.php deleted file mode 100644 index af56d78..0000000 --- a/install/update/old/phpbb/filesystem.php +++ /dev/null @@ -1,21 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb; - -/** - * @deprecated 3.2.0-dev (To be removed 3.3.0) use \phpbb\filesystem\filesystem instead - */ -class filesystem extends \phpbb\filesystem\filesystem -{ -} diff --git a/install/update/old/phpbb/filesystem/filesystem.php b/install/update/old/phpbb/filesystem/filesystem.php deleted file mode 100644 index bfafdf5..0000000 --- a/install/update/old/phpbb/filesystem/filesystem.php +++ /dev/null @@ -1,916 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\filesystem; - -use phpbb\filesystem\exception\filesystem_exception; - -/** - * A class with various functions that are related to paths, files and the filesystem - */ -class filesystem implements filesystem_interface -{ - /** - * Store some information about file ownership for phpBB's chmod function - * - * @var array - */ - protected $chmod_info; - - /** - * Stores current working directory - * - * @var string|bool current working directory or false if it cannot be recovered - */ - protected $working_directory; - - /** - * Symfony's Filesystem component - * - * @var \Symfony\Component\Filesystem\Filesystem - */ - protected $symfony_filesystem; - - /** - * Constructor - */ - public function __construct() - { - $this->chmod_info = array(); - $this->symfony_filesystem = new \Symfony\Component\Filesystem\Filesystem(); - $this->working_directory = null; - } - - /** - * {@inheritdoc} - */ - public function chgrp($files, $group, $recursive = false) - { - try - { - $this->symfony_filesystem->chgrp($files, $group, $recursive); - } - catch (\Symfony\Component\Filesystem\Exception\IOException $e) - { - // Try to recover filename - // By the time this is written that is at the end of the message - $error = trim($e->getMessage()); - $file = substr($error, strrpos($error, ' ')); - - throw new filesystem_exception('CANNOT_CHANGE_FILE_GROUP', $file, array(), $e); - } - } - - /** - * {@inheritdoc} - */ - public function chmod($files, $perms = null, $recursive = false, $force_chmod_link = false) - { - if (is_null($perms)) - { - // Default to read permission for compatibility reasons - $perms = self::CHMOD_READ; - } - - // Check if we got a permission flag - if ($perms > self::CHMOD_ALL) - { - $file_perm = $perms; - - // Extract permissions - //$owner = ($file_perm >> 6) & 7; // This will be ignored - $group = ($file_perm >> 3) & 7; - $other = ($file_perm >> 0) & 7; - - // Does any permissions provided? if so we add execute bit for directories - $group = ($group !== 0) ? ($group | self::CHMOD_EXECUTE) : $group; - $other = ($other !== 0) ? ($other | self::CHMOD_EXECUTE) : $other; - - // Compute directory permissions - $dir_perm = (self::CHMOD_ALL << 6) + ($group << 3) + ($other << 3); - } - else - { - // Add execute bit to owner if execute bit is among perms - $owner_perm = (self::CHMOD_READ | self::CHMOD_WRITE) | ($perms & self::CHMOD_EXECUTE); - $file_perm = ($owner_perm << 6) + ($perms << 3) + ($perms << 0); - - // Compute directory permissions - $perm = ($perms !== 0) ? ($perms | self::CHMOD_EXECUTE) : $perms; - $dir_perm = (($owner_perm | self::CHMOD_EXECUTE) << 6) + ($perm << 3) + ($perm << 0); - } - - // Symfony's filesystem component does not support extra execution flags on directories - // so we need to implement it again - foreach ($this->to_iterator($files) as $file) - { - if ($recursive && is_dir($file) && !is_link($file)) - { - $this->chmod(new \FilesystemIterator($file), $perms, true); - } - - // Don't chmod links as mostly those require 0777 and that cannot be changed - if (is_dir($file) || (is_link($file) && $force_chmod_link)) - { - if (true !== @chmod($file, $dir_perm)) - { - throw new filesystem_exception('CANNOT_CHANGE_FILE_PERMISSIONS', $file, array()); - } - } - else if (is_file($file)) - { - if (true !== @chmod($file, $file_perm)) - { - throw new filesystem_exception('CANNOT_CHANGE_FILE_PERMISSIONS', $file, array()); - } - } - } - } - - /** - * {@inheritdoc} - */ - public function chown($files, $user, $recursive = false) - { - try - { - $this->symfony_filesystem->chown($files, $user, $recursive); - } - catch (\Symfony\Component\Filesystem\Exception\IOException $e) - { - // Try to recover filename - // By the time this is written that is at the end of the message - $error = trim($e->getMessage()); - $file = substr($error, strrpos($error, ' ')); - - throw new filesystem_exception('CANNOT_CHANGE_FILE_GROUP', $file, array(), $e); - } - } - - /** - * {@inheritdoc} - */ - public function clean_path($path) - { - $exploded = explode('/', $path); - $filtered = array(); - foreach ($exploded as $part) - { - if ($part === '.' && !empty($filtered)) - { - continue; - } - - if ($part === '..' && !empty($filtered) && $filtered[count($filtered) - 1] !== '.' && $filtered[count($filtered) - 1] !== '..') - { - array_pop($filtered); - } - else - { - $filtered[] = $part; - } - } - $path = implode('/', $filtered); - return $path; - } - - /** - * {@inheritdoc} - */ - public function copy($origin_file, $target_file, $override = false) - { - try - { - $this->symfony_filesystem->copy($origin_file, $target_file, $override); - } - catch (\Symfony\Component\Filesystem\Exception\IOException $e) - { - throw new filesystem_exception('CANNOT_COPY_FILES', '', array(), $e); - } - } - - /** - * {@inheritdoc} - */ - public function dump_file($filename, $content) - { - try - { - $this->symfony_filesystem->dumpFile($filename, $content); - } - catch (\Symfony\Component\Filesystem\Exception\IOException $e) - { - throw new filesystem_exception('CANNOT_DUMP_FILE', $filename, array(), $e); - } - } - - /** - * {@inheritdoc} - */ - public function exists($files) - { - return $this->symfony_filesystem->exists($files); - } - - /** - * {@inheritdoc} - */ - public function is_absolute_path($path) - { - return (isset($path[0]) && $path[0] === '/' || preg_match('#^[a-z]:[/\\\]#i', $path)) ? true : false; - } - - /** - * {@inheritdoc} - */ - public function is_readable($files, $recursive = false) - { - foreach ($this->to_iterator($files) as $file) - { - if ($recursive && is_dir($file) && !is_link($file)) - { - if (!$this->is_readable(new \FilesystemIterator($file), true)) - { - return false; - } - } - - if (!is_readable($file)) - { - return false; - } - } - - return true; - } - - /** - * {@inheritdoc} - */ - public function is_writable($files, $recursive = false) - { - if (defined('PHP_WINDOWS_VERSION_MAJOR') || !function_exists('is_writable')) - { - foreach ($this->to_iterator($files) as $file) - { - if ($recursive && is_dir($file) && !is_link($file)) - { - if (!$this->is_writable(new \FilesystemIterator($file), true)) - { - return false; - } - } - - if (!$this->phpbb_is_writable($file)) - { - return false; - } - } - } - else - { - // use built in is_writable - foreach ($this->to_iterator($files) as $file) - { - if ($recursive && is_dir($file) && !is_link($file)) - { - if (!$this->is_writable(new \FilesystemIterator($file), true)) - { - return false; - } - } - - if (!is_writable($file)) - { - return false; - } - } - } - - return true; - } - - /** - * {@inheritdoc} - */ - public function make_path_relative($end_path, $start_path) - { - return $this->symfony_filesystem->makePathRelative($end_path, $start_path); - } - - /** - * {@inheritdoc} - */ - public function mirror($origin_dir, $target_dir, \Traversable $iterator = null, $options = array()) - { - try - { - $this->symfony_filesystem->mirror($origin_dir, $target_dir, $iterator, $options); - } - catch (\Symfony\Component\Filesystem\Exception\IOException $e) - { - $msg = $e->getMessage(); - $filename = substr($msg, strpos($msg, '"'), strrpos($msg, '"')); - - throw new filesystem_exception('CANNOT_MIRROR_DIRECTORY', $filename, array(), $e); - } - } - - /** - * {@inheritdoc} - */ - public function mkdir($dirs, $mode = 0777) - { - try - { - $this->symfony_filesystem->mkdir($dirs, $mode); - } - catch (\Symfony\Component\Filesystem\Exception\IOException $e) - { - $msg = $e->getMessage(); - $filename = substr($msg, strpos($msg, '"'), strrpos($msg, '"')); - - throw new filesystem_exception('CANNOT_CREATE_DIRECTORY', $filename, array(), $e); - } - } - - /** - * {@inheritdoc} - */ - public function phpbb_chmod($files, $perms = null, $recursive = false, $force_chmod_link = false) - { - if (is_null($perms)) - { - // Default to read permission for compatibility reasons - $perms = self::CHMOD_READ; - } - - if (empty($this->chmod_info)) - { - if (!function_exists('fileowner') || !function_exists('filegroup')) - { - $this->chmod_info['process'] = false; - } - else - { - $common_php_owner = @fileowner(__FILE__); - $common_php_group = @filegroup(__FILE__); - - // And the owner and the groups PHP is running under. - $php_uid = (function_exists('posix_getuid')) ? @posix_getuid() : false; - $php_gids = (function_exists('posix_getgroups')) ? @posix_getgroups() : false; - - // If we are unable to get owner/group, then do not try to set them by guessing - if (!$php_uid || empty($php_gids) || !$common_php_owner || !$common_php_group) - { - $this->chmod_info['process'] = false; - } - else - { - $this->chmod_info = array( - 'process' => true, - 'common_owner' => $common_php_owner, - 'common_group' => $common_php_group, - 'php_uid' => $php_uid, - 'php_gids' => $php_gids, - ); - } - } - } - - if ($this->chmod_info['process']) - { - try - { - foreach ($this->to_iterator($files) as $file) - { - $file_uid = @fileowner($file); - $file_gid = @filegroup($file); - - // Change owner - if ($file_uid !== $this->chmod_info['common_owner']) - { - $this->chown($file, $this->chmod_info['common_owner'], $recursive); - } - - // Change group - if ($file_gid !== $this->chmod_info['common_group']) - { - $this->chgrp($file, $this->chmod_info['common_group'], $recursive); - } - - clearstatcache(); - $file_uid = @fileowner($file); - $file_gid = @filegroup($file); - } - } - catch (filesystem_exception $e) - { - $this->chmod_info['process'] = false; - } - } - - // Still able to process? - if ($this->chmod_info['process']) - { - if ($file_uid === $this->chmod_info['php_uid']) - { - $php = 'owner'; - } - else if (in_array($file_gid, $this->chmod_info['php_gids'])) - { - $php = 'group'; - } - else - { - // Since we are setting the everyone bit anyway, no need to do expensive operations - $this->chmod_info['process'] = false; - } - } - - // We are not able to determine or change something - if (!$this->chmod_info['process']) - { - $php = 'other'; - } - - switch ($php) - { - case 'owner': - try - { - $this->chmod($files, $perms, $recursive, $force_chmod_link); - clearstatcache(); - if ($this->is_readable($files) && $this->is_writable($files)) - { - break; - } - } - catch (filesystem_exception $e) - { - // Do nothing - } - case 'group': - try - { - $this->chmod($files, $perms, $recursive, $force_chmod_link); - clearstatcache(); - if ((!($perms & self::CHMOD_READ) || $this->is_readable($files, $recursive)) && (!($perms & self::CHMOD_WRITE) || $this->is_writable($files, $recursive))) - { - break; - } - } - catch (filesystem_exception $e) - { - // Do nothing - } - case 'other': - default: - $this->chmod($files, $perms, $recursive, $force_chmod_link); - break; - } - } - - /** - * {@inheritdoc} - */ - public function realpath($path) - { - if (!function_exists('realpath')) - { - return $this->phpbb_own_realpath($path); - } - - $realpath = realpath($path); - - // Strangely there are provider not disabling realpath but returning strange values. :o - // We at least try to cope with them. - if ((!$this->is_absolute_path($path) && $realpath === $path) || $realpath === false) - { - return $this->phpbb_own_realpath($path); - } - - // Check for DIRECTORY_SEPARATOR at the end (and remove it!) - if (substr($realpath, -1) === DIRECTORY_SEPARATOR) - { - $realpath = substr($realpath, 0, -1); - } - - return $realpath; - } - - /** - * {@inheritdoc} - */ - public function remove($files) - { - try - { - $this->symfony_filesystem->remove($files); - } - catch (\Symfony\Component\Filesystem\Exception\IOException $e) - { - // Try to recover filename - // By the time this is written that is at the end of the message - $error = trim($e->getMessage()); - $file = substr($error, strrpos($error, ' ')); - - throw new filesystem_exception('CANNOT_DELETE_FILES', $file, array(), $e); - } - } - - /** - * {@inheritdoc} - */ - public function rename($origin, $target, $overwrite = false) - { - try - { - $this->symfony_filesystem->rename($origin, $target, $overwrite); - } - catch (\Symfony\Component\Filesystem\Exception\IOException $e) - { - $msg = $e->getMessage(); - $filename = substr($msg, strpos($msg, '"'), strrpos($msg, '"')); - - throw new filesystem_exception('CANNOT_RENAME_FILE', $filename, array(), $e); - } - } - - /** - * {@inheritdoc} - */ - public function symlink($origin_dir, $target_dir, $copy_on_windows = false) - { - try - { - $this->symfony_filesystem->symlink($origin_dir, $target_dir, $copy_on_windows); - } - catch (\Symfony\Component\Filesystem\Exception\IOException $e) - { - throw new filesystem_exception('CANNOT_CREATE_SYMLINK', $origin_dir, array(), $e); - } - } - - /** - * {@inheritdoc} - */ - public function touch($files, $time = null, $access_time = null) - { - try - { - $this->symfony_filesystem->touch($files, $time, $access_time); - } - catch (\Symfony\Component\Filesystem\Exception\IOException $e) - { - // Try to recover filename - // By the time this is written that is at the end of the message - $error = trim($e->getMessage()); - $file = substr($error, strrpos($error, ' ')); - - throw new filesystem_exception('CANNOT_TOUCH_FILES', $file, array(), $e); - } - } - - /** - * phpBB's implementation of is_writable - * - * @todo Investigate if is_writable is still buggy - * - * @param string $file file/directory to check if writable - * - * @return bool true if the given path is writable - */ - protected function phpbb_is_writable($file) - { - if (file_exists($file)) - { - // Canonicalise path to absolute path - $file = $this->realpath($file); - - if (is_dir($file)) - { - // Test directory by creating a file inside the directory - $result = @tempnam($file, 'i_w'); - - if (is_string($result) && file_exists($result)) - { - unlink($result); - - // Ensure the file is actually in the directory (returned realpathed) - return (strpos($result, $file) === 0) ? true : false; - } - } - else - { - $handle = @fopen($file, 'c'); - - if (is_resource($handle)) - { - fclose($handle); - return true; - } - } - } - else - { - // file does not exist test if we can write to the directory - $dir = dirname($file); - - if (file_exists($dir) && is_dir($dir) && $this->phpbb_is_writable($dir)) - { - return true; - } - } - - return false; - } - - /** - * Try to resolve real path when PHP's realpath failes to do so - * - * @param string $path - * @return bool|string - */ - protected function phpbb_own_realpath($path) - { - // Replace all directory separators with '/' - $path = str_replace(DIRECTORY_SEPARATOR, '/', $path); - - $is_absolute_path = false; - $path_prefix = ''; - - if ($this->is_absolute_path($path)) - { - $is_absolute_path = true; - } - else - { - // Resolve working directory and store it - if (is_null($this->working_directory)) - { - if (function_exists('getcwd')) - { - $this->working_directory = str_replace(DIRECTORY_SEPARATOR, '/', getcwd()); - } - - // - // From this point on we really just guessing - // If chdir were called we screwed - // - else if (function_exists('debug_backtrace')) - { - $call_stack = debug_backtrace(0); - $this->working_directory = str_replace(DIRECTORY_SEPARATOR, '/', dirname($call_stack[count($call_stack) - 1]['file'])); - } - else - { - // - // Assuming that the working directory is phpBB root - // we could use this as a fallback, when phpBB will use controllers - // everywhere this will be a safe assumption - // - //$dir_parts = explode(DIRECTORY_SEPARATOR, __DIR__); - //$namespace_parts = explode('\\', trim(__NAMESPACE__, '\\')); - - //$namespace_part_count = count($namespace_parts); - - // Check if we still loading from root - //if (array_slice($dir_parts, -$namespace_part_count) === $namespace_parts) - //{ - // $this->working_directory = implode('/', array_slice($dir_parts, 0, -$namespace_part_count)); - //} - //else - //{ - // $this->working_directory = false; - //} - - $this->working_directory = false; - } - } - - if ($this->working_directory !== false) - { - $is_absolute_path = true; - $path = $this->working_directory . '/' . $path; - } - } - - if ($is_absolute_path) - { - if (defined('PHP_WINDOWS_VERSION_MAJOR')) - { - $path_prefix = $path[0] . ':'; - $path = substr($path, 2); - } - else - { - $path_prefix = ''; - } - } - - $resolved_path = $this->resolve_path($path, $path_prefix, $is_absolute_path); - if ($resolved_path === false) - { - return false; - } - - if (!@file_exists($resolved_path) || (!@is_dir($resolved_path . '/') && !is_file($resolved_path))) - { - return false; - } - - // Return OS specific directory separators - $resolved = str_replace('/', DIRECTORY_SEPARATOR, $resolved_path); - - // Check for DIRECTORY_SEPARATOR at the end (and remove it!) - if (substr($resolved, -1) === DIRECTORY_SEPARATOR) - { - return substr($resolved, 0, -1); - } - - return $resolved; - } - - /** - * Convert file(s) to \Traversable object - * - * This is the same function as Symfony's toIterator, but that is private - * so we cannot use it. - * - * @param string|array|\Traversable $files filename/list of filenames - * @return \Traversable - */ - protected function to_iterator($files) - { - if (!$files instanceof \Traversable) - { - $files = new \ArrayObject(is_array($files) ? $files : array($files)); - } - - return $files; - } - - /** - * Try to resolve symlinks in path - * - * @param string $path The path to resolve - * @param string $prefix The path prefix (on windows the drive letter) - * @param bool $absolute Whether or not the path is absolute - * @param bool $return_array Whether or not to return path parts - * - * @return string|array|bool returns the resolved path or an array of parts of the path if $return_array is true - * or false if path cannot be resolved - */ - protected function resolve_path($path, $prefix = '', $absolute = false, $return_array = false) - { - if ($return_array) - { - $path = str_replace(DIRECTORY_SEPARATOR, '/', $path); - } - - trim ($path, '/'); - $path_parts = explode('/', $path); - $resolved = array(); - $resolved_path = $prefix; - $file_found = false; - - foreach ($path_parts as $path_part) - { - if ($file_found) - { - return false; - } - - if (empty($path_part) || ($path_part === '.' && ($absolute || !empty($resolved)))) - { - continue; - } - else if ($absolute && $path_part === '..') - { - if (empty($resolved)) - { - // No directories above root - return false; - } - - array_pop($resolved); - $resolved_path = false; - } - else if ($path_part === '..' && !empty($resolved) && !in_array($resolved[count($resolved) - 1], array('.', '..'))) - { - array_pop($resolved); - $resolved_path = false; - } - else - { - if ($resolved_path === false) - { - if (empty($resolved)) - { - $resolved_path = ($absolute) ? $prefix . '/' . $path_part : $path_part; - } - else - { - $tmp_array = $resolved; - if ($absolute) - { - array_unshift($tmp_array, $prefix); - } - - $resolved_path = implode('/', $tmp_array); - } - } - - $current_path = $resolved_path . '/' . $path_part; - - // Resolve symlinks - if (is_link($current_path)) - { - if (!function_exists('readlink')) - { - return false; - } - - $link = readlink($current_path); - - // Is link has an absolute path in it? - if ($this->is_absolute_path($link)) - { - if (defined('PHP_WINDOWS_VERSION_MAJOR')) - { - $prefix = $link[0] . ':'; - $link = substr($link, 2); - } - else - { - $prefix = ''; - } - - $resolved = $this->resolve_path($link, $prefix, true, true); - $absolute = true; - } - else - { - $resolved = $this->resolve_path($resolved_path . '/' . $link, $prefix, $absolute, true); - } - - if (!$resolved) - { - return false; - } - - $resolved_path = false; - } - else if (is_dir($current_path . '/')) - { - $resolved[] = $path_part; - $resolved_path = $current_path; - } - else if (is_file($current_path)) - { - $resolved[] = $path_part; - $resolved_path = $current_path; - $file_found = true; - } - else - { - return false; - } - } - } - - // If at the end of the path there were a .. or . - // we need to build the path again. - // Only doing this when a string is expected in return - if ($resolved_path === false && $return_array === false) - { - if (empty($resolved)) - { - $resolved_path = ($absolute) ? $prefix . '/' : './'; - } - else - { - $tmp_array = $resolved; - if ($absolute) - { - array_unshift($tmp_array, $prefix); - } - - $resolved_path = implode('/', $tmp_array); - } - } - - return ($return_array) ? $resolved : $resolved_path; - } -} diff --git a/install/update/old/phpbb/filesystem/filesystem_interface.php b/install/update/old/phpbb/filesystem/filesystem_interface.php deleted file mode 100644 index 1093be2..0000000 --- a/install/update/old/phpbb/filesystem/filesystem_interface.php +++ /dev/null @@ -1,284 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\filesystem; - -/** - * Interface for phpBB's filesystem service - */ -interface filesystem_interface -{ - /** - * chmod all permissions flag - * - * @var int - */ - const CHMOD_ALL = 7; - - /** - * chmod read permissions flag - * - * @var int - */ - const CHMOD_READ = 4; - - /** - * chmod write permissions flag - * - * @var int - */ - const CHMOD_WRITE = 2; - - /** - * chmod execute permissions flag - * - * @var int - */ - const CHMOD_EXECUTE = 1; - - /** - * Change owner group of files/directories - * - * @param string|array|\Traversable $files The file(s)/directorie(s) to change group - * @param string $group The group that should own the files/directories - * @param bool $recursive If the group should be changed recursively - * @throws \phpbb\filesystem\exception\filesystem_exception the filename which triggered the error can be - * retrieved by filesystem_exception::get_filename() - */ - public function chgrp($files, $group, $recursive = false); - - /** - * Global function for chmodding directories and files for internal use - * - * The function accepts filesystem_interface::CHMOD_ flags in the permission argument - * or the user can specify octal values (or any integer if it makes sense). All directories will have - * an execution bit appended, if the user group (owner, group or other) has any bit specified. - * - * @param string|array|\Traversable $files The file/directory to be chmodded - * @param int $perms Permissions to set - * @param bool $recursive If the permissions should be changed recursively - * @param bool $force_chmod_link Try to apply permissions to symlinks as well - * - * @throws \phpbb\filesystem\exception\filesystem_exception the filename which triggered the error can be - * retrieved by filesystem_exception::get_filename() - */ - public function chmod($files, $perms = null, $recursive = false, $force_chmod_link = false); - - /** - * Change owner group of files/directories - * - * @param string|array|\Traversable $files The file(s)/directorie(s) to change group - * @param string $user The owner user name - * @param bool $recursive Whether change the owner recursively or not - * - * @throws \phpbb\filesystem\exception\filesystem_exception the filename which triggered the error can be - * retrieved by filesystem_exception::get_filename() - */ - public function chown($files, $user, $recursive = false); - - /** - * Eliminates useless . and .. components from specified path. - * - * @param string $path Path to clean - * - * @return string Cleaned path - */ - public function clean_path($path); - - /** - * Copies a file. - * - * This method only copies the file if the origin file is newer than the target file. - * - * By default, if the target already exists, it is not overridden. - * - * @param string $origin_file The original filename - * @param string $target_file The target filename - * @param bool $override Whether to override an existing file or not - * - * @throws \phpbb\filesystem\exception\filesystem_exception When the file cannot be copied - */ - public function copy($origin_file, $target_file, $override = false); - - /** - * Atomically dumps content into a file. - * - * @param string $filename The file to be written to. - * @param string $content The data to write into the file. - * - * @throws \phpbb\filesystem\exception\filesystem_exception When the file cannot be written - */ - public function dump_file($filename, $content); - - /** - * Checks the existence of files or directories. - * - * @param string|array|\Traversable $files files/directories to check - * - * @return bool Returns true if all files/directories exist, false otherwise - */ - public function exists($files); - - /** - * Checks if a path is absolute or not - * - * @param string $path Path to check - * - * @return bool true if the path is absolute, false otherwise - */ - public function is_absolute_path($path); - - /** - * Checks if files/directories are readable - * - * @param string|array|\Traversable $files files/directories to check - * @param bool $recursive Whether or not directories should be checked recursively - * - * @return bool True when the files/directories are readable, otherwise false. - */ - public function is_readable($files, $recursive = false); - - /** - * Test if a file/directory is writable - * - * @param string|array|\Traversable $files files/directories to perform write test on - * @param bool $recursive Whether or not directories should be checked recursively - * - * @return bool True when the files/directories are writable, otherwise false. - */ - public function is_writable($files, $recursive = false); - - /** - * Given an existing path, convert it to a path relative to a given starting path - * - * @param string $end_path Absolute path of target - * @param string $start_path Absolute path where traversal begins - * - * @return string Path of target relative to starting path - */ - public function make_path_relative($end_path, $start_path); - - /** - * Mirrors a directory to another. - * - * @param string $origin_dir The origin directory - * @param string $target_dir The target directory - * @param \Traversable $iterator A Traversable instance - * @param array $options An array of boolean options - * Valid options are: - * - $options['override'] Whether to override an existing file on copy or not (see copy()) - * - $options['copy_on_windows'] Whether to copy files instead of links on Windows (see symlink()) - * - $options['delete'] Whether to delete files that are not in the source directory (defaults to false) - * - * @throws \phpbb\filesystem\exception\filesystem_exception When the file cannot be copied. - * The filename which triggered the error can be - * retrieved by filesystem_exception::get_filename() - */ - public function mirror($origin_dir, $target_dir, \Traversable $iterator = null, $options = array()); - - /** - * Creates a directory recursively. - * - * @param string|array|\Traversable $dirs The directory path - * @param int $mode The directory mode - * - * @throws \phpbb\filesystem\exception\filesystem_exception On any directory creation failure - * The filename which triggered the error can be - * retrieved by filesystem_exception::get_filename() - */ - public function mkdir($dirs, $mode = 0777); - - /** - * Global function for chmodding directories and files for internal use - * - * This function determines owner and group whom the file belongs to and user and group of PHP and then set safest possible file permissions. - * The function determines owner and group from common.php file and sets the same to the provided file. - * The function uses bit fields to build the permissions. - * The function sets the appropiate execute bit on directories. - * - * Supported constants representing bit fields are: - * - * filesystem_interface::CHMOD_ALL - all permissions (7) - * filesystem_interface::CHMOD_READ - read permission (4) - * filesystem_interface::CHMOD_WRITE - write permission (2) - * filesystem_interface::CHMOD_EXECUTE - execute permission (1) - * - * NOTE: The function uses POSIX extension and fileowner()/filegroup() functions. If any of them is disabled, this function tries to build proper permissions, by calling is_readable() and is_writable() functions. - * - * @param string|array|\Traversable $file The file/directory to be chmodded - * @param int $perms Permissions to set - * @param bool $recursive If the permissions should be changed recursively - * @param bool $force_chmod_link Try to apply permissions to symlinks as well - * - * @throws \phpbb\filesystem\exception\filesystem_exception the filename which triggered the error can be - * retrieved by filesystem_exception::get_filename() - */ - public function phpbb_chmod($file, $perms = null, $recursive = false, $force_chmod_link = false); - - /** - * A wrapper for PHP's realpath - * - * Try to resolve realpath when PHP's realpath is not available, or - * known to be buggy. - * - * @param string $path Path to resolve - * - * @return string Resolved path - */ - public function realpath($path); - - /** - * Removes files or directories. - * - * @param string|array|\Traversable $files A filename, an array of files, or a \Traversable instance to remove - * - * @throws \phpbb\filesystem\exception\filesystem_exception When removal fails. - * The filename which triggered the error can be - * retrieved by filesystem_exception::get_filename() - */ - public function remove($files); - - /** - * Renames a file or a directory. - * - * @param string $origin The origin filename or directory - * @param string $target The new filename or directory - * @param bool $overwrite Whether to overwrite the target if it already exists - * - * @throws \phpbb\filesystem\exception\filesystem_exception When target file or directory already exists, - * or origin cannot be renamed. - */ - public function rename($origin, $target, $overwrite = false); - - /** - * Creates a symbolic link or copy a directory. - * - * @param string $origin_dir The origin directory path - * @param string $target_dir The symbolic link name - * @param bool $copy_on_windows Whether to copy files if on Windows - * - * @throws \phpbb\filesystem\exception\filesystem_exception When symlink fails - */ - public function symlink($origin_dir, $target_dir, $copy_on_windows = false); - - /** - * Sets access and modification time of file. - * - * @param string|array|\Traversable $files A filename, an array of files, or a \Traversable instance to create - * @param int $time The touch time as a Unix timestamp - * @param int $access_time The access time as a Unix timestamp - * - * @throws \phpbb\filesystem\exception\filesystem_exception When touch fails - */ - public function touch($files, $time = null, $access_time = null); -} diff --git a/install/update/old/phpbb/finder.php b/install/update/old/phpbb/finder.php deleted file mode 100644 index 1f1d931..0000000 --- a/install/update/old/phpbb/finder.php +++ /dev/null @@ -1,547 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb; - -/** -* The finder provides a simple way to locate files in the core and a set of extensions -*/ -class finder -{ - protected $extensions; - protected $filesystem; - protected $phpbb_root_path; - protected $cache; - protected $php_ext; - - /** - * The cache variable name used to store $this->cached_queries in $this->cache. - * - * Allows the use of multiple differently configured finders with the same cache. - * @var string - */ - protected $cache_name; - - /** - * An associative array, containing all search parameters set in methods. - * @var array - */ - protected $query; - - /** - * A map from md5 hashes of serialized queries to their previously retrieved - * results. - * @var array - */ - protected $cached_queries; - - /** - * Creates a new finder instance with its dependencies - * - * @param \phpbb\filesystem\filesystem_interface $filesystem Filesystem instance - * @param string $phpbb_root_path Path to the phpbb root directory - * @param \phpbb\cache\service $cache A cache instance or null - * @param string $php_ext php file extension - * @param string $cache_name The name of the cache variable, defaults to - * _ext_finder - */ - public function __construct(\phpbb\filesystem\filesystem_interface $filesystem, $phpbb_root_path = '', \phpbb\cache\service $cache = null, $php_ext = 'php', $cache_name = '_ext_finder') - { - $this->filesystem = $filesystem; - $this->phpbb_root_path = $phpbb_root_path; - $this->cache = $cache; - $this->php_ext = $php_ext; - $this->cache_name = $cache_name; - - $this->query = array( - 'core_path' => false, - 'core_suffix' => false, - 'core_prefix' => false, - 'core_directory' => false, - 'extension_suffix' => false, - 'extension_prefix' => false, - 'extension_directory' => false, - ); - $this->extensions = array(); - - $this->cached_queries = ($this->cache) ? $this->cache->get($this->cache_name) : false; - } - - /** - * Set the array of extensions - * - * @param array $extensions A list of extensions that should be searched aswell - * @param bool $replace_list Should the list be emptied before adding the extensions - * @return \phpbb\finder This object for chaining calls - */ - public function set_extensions(array $extensions, $replace_list = true) - { - if ($replace_list) - { - $this->extensions = array(); - } - - foreach ($extensions as $ext_name) - { - $this->extensions[$ext_name] = $this->phpbb_root_path . 'ext/' . $ext_name . '/'; - } - return $this; - } - - /** - * Sets a core path to be searched in addition to extensions - * - * @param string $core_path The path relative to phpbb_root_path - * @return \phpbb\finder This object for chaining calls - */ - public function core_path($core_path) - { - $this->query['core_path'] = $core_path; - return $this; - } - - /** - * Sets the suffix all files found in extensions and core must match. - * - * There is no default file extension, so to find PHP files only, you will - * have to specify .php as a suffix. However when using get_classes, the .php - * file extension is automatically added to suffixes. - * - * @param string $suffix A filename suffix - * @return \phpbb\finder This object for chaining calls - */ - public function suffix($suffix) - { - $this->core_suffix($suffix); - $this->extension_suffix($suffix); - return $this; - } - - /** - * Sets a suffix all files found in extensions must match - * - * There is no default file extension, so to find PHP files only, you will - * have to specify .php as a suffix. However when using get_classes, the .php - * file extension is automatically added to suffixes. - * - * @param string $extension_suffix A filename suffix - * @return \phpbb\finder This object for chaining calls - */ - public function extension_suffix($extension_suffix) - { - $this->query['extension_suffix'] = $extension_suffix; - return $this; - } - - /** - * Sets a suffix all files found in the core path must match - * - * There is no default file extension, so to find PHP files only, you will - * have to specify .php as a suffix. However when using get_classes, the .php - * file extension is automatically added to suffixes. - * - * @param string $core_suffix A filename suffix - * @return \phpbb\finder This object for chaining calls - */ - public function core_suffix($core_suffix) - { - $this->query['core_suffix'] = $core_suffix; - return $this; - } - - /** - * Sets the prefix all files found in extensions and core must match - * - * @param string $prefix A filename prefix - * @return \phpbb\finder This object for chaining calls - */ - public function prefix($prefix) - { - $this->core_prefix($prefix); - $this->extension_prefix($prefix); - return $this; - } - - /** - * Sets a prefix all files found in extensions must match - * - * @param string $extension_prefix A filename prefix - * @return \phpbb\finder This object for chaining calls - */ - public function extension_prefix($extension_prefix) - { - $this->query['extension_prefix'] = $extension_prefix; - return $this; - } - - /** - * Sets a prefix all files found in the core path must match - * - * @param string $core_prefix A filename prefix - * @return \phpbb\finder This object for chaining calls - */ - public function core_prefix($core_prefix) - { - $this->query['core_prefix'] = $core_prefix; - return $this; - } - - /** - * Sets a directory all files found in extensions and core must be contained in - * - * Automatically sets the core_directory if its value does not differ from - * the current directory. - * - * @param string $directory - * @return \phpbb\finder This object for chaining calls - */ - public function directory($directory) - { - $this->core_directory($directory); - $this->extension_directory($directory); - return $this; - } - - /** - * Sets a directory all files found in extensions must be contained in - * - * @param string $extension_directory - * @return \phpbb\finder This object for chaining calls - */ - public function extension_directory($extension_directory) - { - $this->query['extension_directory'] = $this->sanitise_directory($extension_directory); - return $this; - } - - /** - * Sets a directory all files found in the core path must be contained in - * - * @param string $core_directory - * @return \phpbb\finder This object for chaining calls - */ - public function core_directory($core_directory) - { - $this->query['core_directory'] = $this->sanitise_directory($core_directory); - return $this; - } - - /** - * Removes occurances of /./ and makes sure path ends without trailing slash - * - * @param string $directory A directory pattern - * @return string A cleaned up directory pattern - */ - protected function sanitise_directory($directory) - { - $directory = $this->filesystem->clean_path($directory); - $dir_len = strlen($directory); - - if ($dir_len > 1 && $directory[$dir_len - 1] === '/') - { - $directory = substr($directory, 0, -1); - } - - return $directory; - } - - /** - * Finds classes matching the configured options if they follow phpBB naming rules. - * - * The php file extension is automatically added to suffixes. - * - * Note: If a file is matched but contains a class name not following the - * phpBB naming rules an incorrect class name will be returned. - * - * @param bool $cache Whether the result should be cached - * @return array An array of found class names - */ - public function get_classes($cache = true) - { - $this->query['extension_suffix'] .= '.' . $this->php_ext; - $this->query['core_suffix'] .= '.' . $this->php_ext; - - $files = $this->find($cache, false); - - return $this->get_classes_from_files($files); - } - - /** - * Get class names from a list of files - * - * @param array $files Array of files (from find()) - * @return array Array of class names - */ - public function get_classes_from_files($files) - { - $classes = array(); - foreach ($files as $file => $ext_name) - { - $class = substr($file, 0, -strlen('.' . $this->php_ext)); - if ($ext_name === '/' && preg_match('#^includes/#', $file)) - { - $class = preg_replace('#^includes/#', '', $class); - $classes[] = 'phpbb_' . str_replace('/', '_', $class); - } - else - { - $class = preg_replace('#^ext/#', '', $class); - $classes[] = '\\' . str_replace('/', '\\', $class); - } - } - return $classes; - } - - /** - * Finds all directories matching the configured options - * - * @param bool $cache Whether the result should be cached - * @param bool $extension_keys Whether the result should have extension name as array key - * @return array An array of paths to found directories - */ - public function get_directories($cache = true, $extension_keys = false) - { - return $this->find_with_root_path($cache, true, $extension_keys); - } - - /** - * Finds all files matching the configured options. - * - * @param bool $cache Whether the result should be cached - * @return array An array of paths to found files - */ - public function get_files($cache = true) - { - return $this->find_with_root_path($cache, false); - } - - /** - * A wrapper around the general find which prepends a root path to results - * - * @param bool $cache Whether the result should be cached - * @param bool $is_dir Directories will be returned when true, only files - * otherwise - * @param bool $extension_keys If true, result will be associative array - * with extension name as key - * @return array An array of paths to found items - */ - protected function find_with_root_path($cache = true, $is_dir = false, $extension_keys = false) - { - $items = $this->find($cache, $is_dir); - - $result = array(); - foreach ($items as $item => $ext_name) - { - if ($extension_keys) - { - $result[$ext_name] = $this->phpbb_root_path . $item; - } - else - { - $result[] = $this->phpbb_root_path . $item; - } - } - - return $result; - } - - /** - * Finds all file system entries matching the configured options - * - * @param bool $cache Whether the result should be cached - * @param bool $is_dir Directories will be returned when true, only files - * otherwise - * @return array An array of paths to found items - */ - public function find($cache = true, $is_dir = false) - { - $extensions = $this->extensions; - if ($this->query['core_path']) - { - $extensions['/'] = $this->phpbb_root_path . $this->query['core_path']; - } - - $files = array(); - $file_list = $this->find_from_paths($extensions, $cache, $is_dir); - - foreach ($file_list as $file) - { - $files[$file['named_path']] = $file['ext_name']; - } - - return $files; - } - - /** - * Finds all file system entries matching the configured options for one - * specific extension - * - * @param string $extension_name Name of the extension - * @param string $extension_path Relative path to the extension root directory - * @param bool $cache Whether the result should be cached - * @param bool $is_dir Directories will be returned when true, only files - * otherwise - * @return array An array of paths to found items - */ - public function find_from_extension($extension_name, $extension_path, $cache = true, $is_dir = false) - { - $extensions = array( - $extension_name => $extension_path, - ); - - $files = array(); - $file_list = $this->find_from_paths($extensions, $cache, $is_dir); - - foreach ($file_list as $file) - { - $files[$file['named_path']] = $file['ext_name']; - } - - return $files; - } - - /** - * Finds all file system entries matching the configured options from - * an array of paths - * - * @param array $extensions Array of extensions (name => full relative path) - * @param bool $cache Whether the result should be cached - * @param bool $is_dir Directories will be returned when true, only files - * otherwise - * @return array An array of paths to found items - */ - public function find_from_paths($extensions, $cache = true, $is_dir = false) - { - $this->query['is_dir'] = $is_dir; - $query = md5(serialize($this->query) . serialize($extensions)); - - if (!defined('DEBUG') && $cache && isset($this->cached_queries[$query])) - { - return $this->cached_queries[$query]; - } - - $files = array(); - - foreach ($extensions as $name => $path) - { - $ext_name = $name; - - if (!file_exists($path)) - { - continue; - } - - if ($name === '/') - { - $location = $this->query['core_path']; - $name = ''; - $suffix = $this->query['core_suffix']; - $prefix = $this->query['core_prefix']; - $directory = $this->query['core_directory']; - } - else - { - $location = 'ext/'; - $name .= '/'; - $suffix = $this->query['extension_suffix']; - $prefix = $this->query['extension_prefix']; - $directory = $this->query['extension_directory']; - } - - // match only first directory if leading slash is given - if ($directory === '/') - { - $directory_pattern = '^' . preg_quote(DIRECTORY_SEPARATOR, '#'); - } - else if ($directory && $directory[0] === '/') - { - if (!$is_dir) - { - $path .= substr($directory, 1); - } - $directory_pattern = '^' . preg_quote(str_replace('/', DIRECTORY_SEPARATOR, $directory) . DIRECTORY_SEPARATOR, '#'); - } - else - { - $directory_pattern = preg_quote(DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $directory) . DIRECTORY_SEPARATOR, '#'); - } - if ($is_dir) - { - $directory_pattern .= '$'; - } - $directory_pattern = '#' . $directory_pattern . '#'; - - if (is_dir($path)) - { - $iterator = new \RecursiveIteratorIterator( - new \phpbb\recursive_dot_prefix_filter_iterator( - new \RecursiveDirectoryIterator( - $path, - \FilesystemIterator::SKIP_DOTS - ) - ), - \RecursiveIteratorIterator::SELF_FIRST - ); - - foreach ($iterator as $file_info) - { - $filename = $file_info->getFilename(); - - if ($file_info->isDir() == $is_dir) - { - if ($is_dir) - { - $relative_path = $iterator->getInnerIterator()->getSubPath() . DIRECTORY_SEPARATOR . basename($filename) . DIRECTORY_SEPARATOR; - if ($relative_path[0] !== DIRECTORY_SEPARATOR) - { - $relative_path = DIRECTORY_SEPARATOR . $relative_path; - } - } - else - { - $relative_path = $iterator->getInnerIterator()->getSubPathname(); - if ($directory && $directory[0] === '/') - { - $relative_path = str_replace('/', DIRECTORY_SEPARATOR, $directory) . DIRECTORY_SEPARATOR . $relative_path; - } - else - { - $relative_path = DIRECTORY_SEPARATOR . $relative_path; - } - } - - if ((!$suffix || substr($relative_path, -strlen($suffix)) === $suffix) && - (!$prefix || substr($filename, 0, strlen($prefix)) === $prefix) && - (!$directory || preg_match($directory_pattern, $relative_path))) - { - $files[] = array( - 'named_path' => str_replace(DIRECTORY_SEPARATOR, '/', $location . $name . substr($relative_path, 1)), - 'ext_name' => $ext_name, - 'path' => str_replace(array(DIRECTORY_SEPARATOR, $this->phpbb_root_path), array('/', ''), $file_info->getPath()) . '/', - 'filename' => $filename, - ); - } - } - } - } - } - - if ($cache && $this->cache) - { - $this->cached_queries[$query] = $files; - $this->cache->put($this->cache_name, $this->cached_queries); - } - - return $files; - } -} diff --git a/install/update/old/phpbb/group/helper.php b/install/update/old/phpbb/group/helper.php deleted file mode 100644 index 5befddf..0000000 --- a/install/update/old/phpbb/group/helper.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\group; - -class helper -{ - /** @var \phpbb\language\language */ - protected $language; - - /** - * Constructor - * - * @param \phpbb\language\language $language Language object - */ - public function __construct(\phpbb\language\language $language) - { - $this->language = $language; - } - - /** - * @param $group_name string The stored group name - * - * @return string Group name or translated group name if it exists - */ - public function get_name($group_name) - { - return $this->language->is_set('G_' . utf8_strtoupper($group_name)) ? $this->language->lang('G_' . utf8_strtoupper($group_name)) : $group_name; - } -} diff --git a/install/update/old/phpbb/help/controller/bbcode.php b/install/update/old/phpbb/help/controller/bbcode.php deleted file mode 100644 index e16f990..0000000 --- a/install/update/old/phpbb/help/controller/bbcode.php +++ /dev/null @@ -1,85 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\help\controller; - -/** - * BBCode help page - */ -class bbcode extends controller -{ - /** - * @return string The title of the page - */ - public function display() - { - $this->language->add_lang('help/bbcode'); - - $this->manager->add_block( - 'HELP_BBCODE_BLOCK_INTRO', - false, - array( - 'HELP_BBCODE_INTRO_BBCODE_QUESTION' => 'HELP_BBCODE_INTRO_BBCODE_ANSWER', - ) - ); - $this->manager->add_block( - 'HELP_BBCODE_BLOCK_TEXT', - false, - array( - 'HELP_BBCODE_TEXT_BASIC_QUESTION' => 'HELP_BBCODE_TEXT_BASIC_ANSWER', - 'HELP_BBCODE_TEXT_COLOR_QUESTION' => 'HELP_BBCODE_TEXT_COLOR_ANSWER', - 'HELP_BBCODE_TEXT_COMBINE_QUESTION' => 'HELP_BBCODE_TEXT_COMBINE_ANSWER', - ) - ); - $this->manager->add_block( - 'HELP_BBCODE_BLOCK_QUOTES', - false, - array( - 'HELP_BBCODE_QUOTES_TEXT_QUESTION' => 'HELP_BBCODE_QUOTES_TEXT_ANSWER', - 'HELP_BBCODE_QUOTES_CODE_QUESTION' => 'HELP_BBCODE_QUOTES_CODE_ANSWER', - ) - ); - $this->manager->add_block( - 'HELP_BBCODE_BLOCK_LISTS', - false, - array( - 'HELP_BBCODE_LISTS_UNORDERER_QUESTION' => 'HELP_BBCODE_LISTS_UNORDERER_ANSWER', - 'HELP_BBCODE_LISTS_ORDERER_QUESTION' => 'HELP_BBCODE_LISTS_ORDERER_ANSWER', - ) - ); - $this->manager->add_block( - 'HELP_BBCODE_BLOCK_LINKS', - true, - array( - 'HELP_BBCODE_LINKS_BASIC_QUESTION' => 'HELP_BBCODE_LINKS_BASIC_ANSWER', - ) - ); - $this->manager->add_block( - 'HELP_BBCODE_BLOCK_IMAGES', - false, - array( - 'HELP_BBCODE_IMAGES_BASIC_QUESTION' => 'HELP_BBCODE_IMAGES_BASIC_ANSWER', - 'HELP_BBCODE_IMAGES_ATTACHMENT_QUESTION' => 'HELP_BBCODE_IMAGES_ATTACHMENT_ANSWER', - ) - ); - $this->manager->add_block( - 'HELP_BBCODE_BLOCK_OTHERS', - false, - array( - 'HELP_BBCODE_OTHERS_CUSTOM_QUESTION' => 'HELP_BBCODE_OTHERS_CUSTOM_ANSWER', - ) - ); - - return $this->language->lang('BBCODE_GUIDE'); - } -} diff --git a/install/update/old/phpbb/help/controller/faq.php b/install/update/old/phpbb/help/controller/faq.php deleted file mode 100644 index 5e45cfe..0000000 --- a/install/update/old/phpbb/help/controller/faq.php +++ /dev/null @@ -1,165 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\help\controller; - -/** - * FAQ help page - */ -class faq extends controller -{ - /** - * @return string The title of the page - */ - public function display() - { - $this->language->add_lang('help/faq'); - - $this->manager->add_block( - 'HELP_FAQ_BLOCK_LOGIN', - false, - array( - 'HELP_FAQ_LOGIN_REGISTER_QUESTION' => 'HELP_FAQ_LOGIN_REGISTER_ANSWER', - 'HELP_FAQ_LOGIN_COPPA_QUESTION' => 'HELP_FAQ_LOGIN_COPPA_ANSWER', - 'HELP_FAQ_LOGIN_CANNOT_REGISTER_QUESTION' => 'HELP_FAQ_LOGIN_CANNOT_REGISTER_ANSWER', - 'HELP_FAQ_LOGIN_REGISTER_CONFIRM_QUESTION' => 'HELP_FAQ_LOGIN_REGISTER_CONFIRM_ANSWER', - 'HELP_FAQ_LOGIN_CANNOT_LOGIN_QUESTION' => 'HELP_FAQ_LOGIN_CANNOT_LOGIN_ANSWER', - 'HELP_FAQ_LOGIN_CANNOT_LOGIN_ANYMORE_QUESTION' => 'HELP_FAQ_LOGIN_CANNOT_LOGIN_ANYMORE_ANSWER', - 'HELP_FAQ_LOGIN_LOST_PASSWORD_QUESTION' => 'HELP_FAQ_LOGIN_LOST_PASSWORD_ANSWER', - 'HELP_FAQ_LOGIN_AUTO_LOGOUT_QUESTION' => 'HELP_FAQ_LOGIN_AUTO_LOGOUT_ANSWER', - 'HELP_FAQ_LOGIN_DELETE_COOKIES_QUESTION' => 'HELP_FAQ_LOGIN_DELETE_COOKIES_ANSWER', - ) - ); - $this->manager->add_block( - 'HELP_FAQ_BLOCK_USERSETTINGS', - false, - array( - 'HELP_FAQ_USERSETTINGS_CHANGE_SETTINGS_QUESTION' => 'HELP_FAQ_USERSETTINGS_CHANGE_SETTINGS_ANSWER', - 'HELP_FAQ_USERSETTINGS_HIDE_ONLINE_QUESTION' => 'HELP_FAQ_USERSETTINGS_HIDE_ONLINE_ANSWER', - 'HELP_FAQ_USERSETTINGS_TIMEZONE_QUESTION' => 'HELP_FAQ_USERSETTINGS_TIMEZONE_ANSWER', - 'HELP_FAQ_USERSETTINGS_SERVERTIME_QUESTION' => 'HELP_FAQ_USERSETTINGS_SERVERTIME_ANSWER', - 'HELP_FAQ_USERSETTINGS_LANGUAGE_QUESTION' => 'HELP_FAQ_USERSETTINGS_LANGUAGE_ANSWER', - 'HELP_FAQ_USERSETTINGS_AVATAR_QUESTION' => 'HELP_FAQ_USERSETTINGS_AVATAR_ANSWER', - 'HELP_FAQ_USERSETTINGS_AVATAR_DISPLAY_QUESTION' => 'HELP_FAQ_USERSETTINGS_AVATAR_DISPLAY_ANSWER', - 'HELP_FAQ_USERSETTINGS_RANK_QUESTION' => 'HELP_FAQ_USERSETTINGS_RANK_ANSWER', - 'HELP_FAQ_USERSETTINGS_EMAIL_LOGIN_QUESTION' => 'HELP_FAQ_USERSETTINGS_EMAIL_LOGIN_ANSWER', - ) - ); - $this->manager->add_block( - 'HELP_FAQ_BLOCK_POSTING', - false, - array( - 'HELP_FAQ_POSTING_CREATE_QUESTION' => 'HELP_FAQ_POSTING_CREATE_ANSWER', - 'HELP_FAQ_POSTING_EDIT_DELETE_QUESTION' => 'HELP_FAQ_POSTING_EDIT_DELETE_ANSWER', - 'HELP_FAQ_POSTING_SIGNATURE_QUESTION' => 'HELP_FAQ_POSTING_SIGNATURE_ANSWER', - 'HELP_FAQ_POSTING_POLL_CREATE_QUESTION' => 'HELP_FAQ_POSTING_POLL_CREATE_ANSWER', - 'HELP_FAQ_POSTING_POLL_ADD_QUESTION' => 'HELP_FAQ_POSTING_POLL_ADD_ANSWER', - 'HELP_FAQ_POSTING_POLL_EDIT_QUESTION' => 'HELP_FAQ_POSTING_POLL_EDIT_ANSWER', - 'HELP_FAQ_POSTING_FORUM_RESTRICTED_QUESTION' => 'HELP_FAQ_POSTING_FORUM_RESTRICTED_ANSWER', - 'HELP_FAQ_POSTING_NO_ATTACHMENTS_QUESTION' => 'HELP_FAQ_POSTING_NO_ATTACHMENTS_ANSWER', - 'HELP_FAQ_POSTING_WARNING_QUESTION' => 'HELP_FAQ_POSTING_WARNING_ANSWER', - 'HELP_FAQ_POSTING_REPORT_QUESTION' => 'HELP_FAQ_POSTING_REPORT_ANSWER', - 'HELP_FAQ_POSTING_DRAFT_QUESTION' => 'HELP_FAQ_POSTING_DRAFT_ANSWER', - 'HELP_FAQ_POSTING_QUEUE_QUESTION' => 'HELP_FAQ_POSTING_QUEUE_ANSWER', - 'HELP_FAQ_POSTING_BUMP_QUESTION' => 'HELP_FAQ_POSTING_BUMP_ANSWER', - ) - ); - $this->manager->add_block( - 'HELP_FAQ_BLOCK_FORMATTING', - false, - array( - 'HELP_FAQ_FORMATTING_BBOCDE_QUESTION' => 'HELP_FAQ_FORMATTING_BBOCDE_ANSWER', - 'HELP_FAQ_FORMATTING_HTML_QUESTION' => 'HELP_FAQ_FORMATTING_HTML_ANSWER', - 'HELP_FAQ_FORMATTING_SMILIES_QUESTION' => 'HELP_FAQ_FORMATTING_SMILIES_ANSWER', - 'HELP_FAQ_FORMATTING_IMAGES_QUESTION' => 'HELP_FAQ_FORMATTING_IMAGES_ANSWER', - 'HELP_FAQ_FORMATTING_GLOBAL_ANNOUNCE_QUESTION' => 'HELP_FAQ_FORMATTING_GLOBAL_ANNOUNCE_ANSWER', - 'HELP_FAQ_FORMATTING_ANNOUNCEMENT_QUESTION' => 'HELP_FAQ_FORMATTING_ANNOUNCEMENT_ANSWER', - 'HELP_FAQ_FORMATTING_STICKIES_QUESTION' => 'HELP_FAQ_FORMATTING_STICKIES_ANSWER', - 'HELP_FAQ_FORMATTING_LOCKED_QUESTION' => 'HELP_FAQ_FORMATTING_LOCKED_ANSWER', - 'HELP_FAQ_FORMATTING_ICONS_QUESTION' => 'HELP_FAQ_FORMATTING_ICONS_ANSWER', - ) - ); - $this->manager->add_block( - 'HELP_FAQ_BLOCK_GROUPS', - true, - array( - 'HELP_FAQ_GROUPS_ADMINISTRATORS_QUESTION' => 'HELP_FAQ_GROUPS_ADMINISTRATORS_ANSWER', - 'HELP_FAQ_GROUPS_MODERATORS_QUESTION' => 'HELP_FAQ_GROUPS_MODERATORS_ANSWER', - 'HELP_FAQ_GROUPS_USERGROUPS_QUESTION' => 'HELP_FAQ_GROUPS_USERGROUPS_ANSWER', - 'HELP_FAQ_GROUPS_USERGROUPS_JOIN_QUESTION' => 'HELP_FAQ_GROUPS_USERGROUPS_JOIN_ANSWER', - 'HELP_FAQ_GROUPS_USERGROUPS_LEAD_QUESTION' => 'HELP_FAQ_GROUPS_USERGROUPS_LEAD_ANSWER', - 'HELP_FAQ_GROUPS_COLORS_QUESTION' => 'HELP_FAQ_GROUPS_COLORS_ANSWER', - 'HELP_FAQ_GROUPS_DEFAULT_QUESTION' => 'HELP_FAQ_GROUPS_DEFAULT_ANSWER', - 'HELP_FAQ_GROUPS_TEAM_QUESTION' => 'HELP_FAQ_GROUPS_TEAM_ANSWER', - ) - ); - $this->manager->add_block( - 'HELP_FAQ_BLOCK_PMS', - false, - array( - 'HELP_FAQ_PMS_CANNOT_SEND_QUESTION' => 'HELP_FAQ_PMS_CANNOT_SEND_ANSWER', - 'HELP_FAQ_PMS_UNWANTED_QUESTION' => 'HELP_FAQ_PMS_UNWANTED_ANSWER', - 'HELP_FAQ_PMS_SPAM_QUESTION' => 'HELP_FAQ_PMS_SPAM_ANSWER', - ) - ); - $this->manager->add_block( - 'HELP_FAQ_BLOCK_FRIENDS', - false, - array( - 'HELP_FAQ_FRIENDS_BASIC_QUESTION' => 'HELP_FAQ_FRIENDS_BASIC_ANSWER', - 'HELP_FAQ_FRIENDS_MANAGE_QUESTION' => 'HELP_FAQ_FRIENDS_MANAGE_ANSWER', - ) - ); - $this->manager->add_block( - 'HELP_FAQ_BLOCK_SEARCH', - false, - array( - 'HELP_FAQ_SEARCH_FORUM_QUESTION' => 'HELP_FAQ_SEARCH_FORUM_ANSWER', - 'HELP_FAQ_SEARCH_NO_RESULT_QUESTION' => 'HELP_FAQ_SEARCH_NO_RESULT_ANSWER', - 'HELP_FAQ_SEARCH_BLANK_QUESTION' => 'HELP_FAQ_SEARCH_BLANK_ANSWER', - 'HELP_FAQ_SEARCH_MEMBERS_QUESTION' => 'HELP_FAQ_SEARCH_MEMBERS_ANSWER', - 'HELP_FAQ_SEARCH_OWN_QUESTION' => 'HELP_FAQ_SEARCH_OWN_ANSWER', - ) - ); - $this->manager->add_block( - 'HELP_FAQ_BLOCK_BOOKMARKS', - false, - array( - 'HELP_FAQ_BOOKMARKS_DIFFERENCE_QUESTION' => 'HELP_FAQ_BOOKMARKS_DIFFERENCE_ANSWER', - 'HELP_FAQ_BOOKMARKS_TOPIC_QUESTION' => 'HELP_FAQ_BOOKMARKS_TOPIC_ANSWER', - 'HELP_FAQ_BOOKMARKS_FORUM_QUESTION' => 'HELP_FAQ_BOOKMARKS_FORUM_ANSWER', - 'HELP_FAQ_BOOKMARKS_REMOVE_QUESTION' => 'HELP_FAQ_BOOKMARKS_REMOVE_ANSWER', - ) - ); - $this->manager->add_block( - 'HELP_FAQ_BLOCK_ATTACHMENTS', - false, - array( - 'HELP_FAQ_ATTACHMENTS_ALLOWED_QUESTION' => 'HELP_FAQ_ATTACHMENTS_ALLOWED_ANSWER', - 'HELP_FAQ_ATTACHMENTS_OWN_QUESTION' => 'HELP_FAQ_ATTACHMENTS_OWN_ANSWER', - ) - ); - $this->manager->add_block( - 'HELP_FAQ_BLOCK_ISSUES', - false, - array( - 'HELP_FAQ_ISSUES_WHOIS_PHPBB_QUESTION' => 'HELP_FAQ_ISSUES_WHOIS_PHPBB_ANSWER', - 'HELP_FAQ_ISSUES_FEATURE_QUESTION' => 'HELP_FAQ_ISSUES_FEATURE_ANSWER', - 'HELP_FAQ_ISSUES_LEGAL_QUESTION' => 'HELP_FAQ_ISSUES_LEGAL_ANSWER', - 'HELP_FAQ_ISSUES_ADMIN_QUESTION' => 'HELP_FAQ_ISSUES_ADMIN_ANSWER', - ) - ); - - return $this->language->lang('FAQ_EXPLAIN'); - } -} diff --git a/install/update/old/phpbb/install/controller/helper.php b/install/update/old/phpbb/install/controller/helper.php deleted file mode 100644 index ff7e691..0000000 --- a/install/update/old/phpbb/install/controller/helper.php +++ /dev/null @@ -1,413 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\install\controller; - -use phpbb\install\helper\config; -use phpbb\install\helper\navigation\navigation_provider; -use phpbb\language\language; -use phpbb\language\language_file_helper; -use phpbb\path_helper; -use phpbb\request\request; -use phpbb\request\request_interface; -use phpbb\routing\router; -use phpbb\symfony_request; -use phpbb\template\template; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\Cookie; - -/** - * A duplicate of \phpbb\controller\helper - * - * This class is necessary because of controller\helper's legacy function calls - * to page_header() page_footer() functions which has unavailable dependencies. - */ -class helper -{ - /** - * @var config - */ - protected $installer_config; - - /** - * @var \phpbb\language\language - */ - protected $language; - - /** - * @var bool|string - */ - protected $language_cookie; - - /** - * @var \phpbb\language\language_file_helper - */ - protected $lang_helper; - - /** - * @var \phpbb\install\helper\navigation\navigation_provider - */ - protected $navigation_provider; - - /** - * @var \phpbb\template\template - */ - protected $template; - - /** - * @var \phpbb\path_helper - */ - protected $path_helper; - - /** - * @var \phpbb\request\request - */ - protected $phpbb_request; - - /** - * @var \phpbb\symfony_request - */ - protected $request; - - /** - * @var \phpbb\routing\router - */ - protected $router; - - /** - * @var string - */ - protected $phpbb_admin_path; - - /** - * @var string - */ - protected $phpbb_root_path; - - /** - * Constructor - * - * @param config $config - * @param language $language - * @param language_file_helper $lang_helper - * @param navigation_provider $nav - * @param template $template - * @param path_helper $path_helper - * @param request $phpbb_request - * @param symfony_request $request - * @param router $router - * @param string $phpbb_root_path - */ - public function __construct(config $config, language $language, language_file_helper $lang_helper, navigation_provider $nav, template $template, path_helper $path_helper, request $phpbb_request, symfony_request $request, router $router, $phpbb_root_path) - { - $this->installer_config = $config; - $this->language = $language; - $this->language_cookie = false; - $this->lang_helper = $lang_helper; - $this->navigation_provider = $nav; - $this->template = $template; - $this->path_helper = $path_helper; - $this->phpbb_request = $phpbb_request; - $this->request = $request; - $this->router = $router; - $this->phpbb_root_path = $phpbb_root_path; - $this->phpbb_admin_path = $phpbb_root_path . 'adm/'; - } - - /** - * Automate setting up the page and creating the response object. - * - * @param string $template_file The template handle to render - * @param string $page_title The title of the page to output - * @param bool $selected_language True to enable language selector it, false otherwise - * @param int $status_code The status code to be sent to the page header - * - * @return Response object containing rendered page - */ - public function render($template_file, $page_title = '', $selected_language = false, $status_code = 200) - { - $this->page_header($page_title, $selected_language); - - $this->template->set_filenames(array( - 'body' => $template_file, - )); - - $response = new Response($this->template->assign_display('body'), $status_code); - - // Set language cookie - if ($this->language_cookie !== false) - { - $cookie = new Cookie('lang', $this->language_cookie, time() + 3600); - $response->headers->setCookie($cookie); - - $this->language_cookie = false; - } - - return $response; - } - - /** - * Returns path from route name - * - * @param string $route_name - * @param array $parameters - * - * @return string - */ - public function route($route_name, $parameters = array()) - { - $url = $this->router->generate($route_name, $parameters); - - return $url; - } - - /** - * Handles language selector form - */ - public function handle_language_select() - { - $lang = null; - - // Check if language form has been submited - $submit = $this->phpbb_request->variable('change_lang', ''); - if (!empty($submit)) - { - $lang = $this->phpbb_request->variable('language', ''); - } - - // Retrieve language from cookie - $lang_cookie = $this->phpbb_request->variable('lang', '', false, request_interface::COOKIE); - if (empty($lang) && !empty($lang_cookie)) - { - $lang = $lang_cookie; - } - - $lang = (!empty($lang) && strpos($lang, '/') === false) ? $lang : null; - $this->language_cookie = $lang; - - $this->render_language_select($lang); - - if ($lang !== null) - { - $this->language->set_user_language($lang, true); - $this->installer_config->set('user_language', $lang); - } - } - - /** - * Process navigation data to reflect active/completed stages - * - * @param \phpbb\install\helper\iohandler\iohandler_interface|null $iohandler - */ - public function handle_navigation($iohandler = null) - { - $nav_data = $this->installer_config->get_navigation_data(); - - // Set active navigation stage - if (isset($nav_data['active']) && is_array($nav_data['active'])) - { - if ($iohandler !== null) - { - $iohandler->set_active_stage_menu($nav_data['active']); - } - - $this->navigation_provider->set_nav_property($nav_data['active'], array( - 'selected' => true, - 'completed' => false, - )); - } - - // Set finished navigation stages - if (isset($nav_data['finished']) && is_array($nav_data['finished'])) - { - foreach ($nav_data['finished'] as $finished_stage) - { - if ($iohandler !== null) - { - $iohandler->set_finished_stage_menu($finished_stage); - } - - $this->navigation_provider->set_nav_property($finished_stage, array( - 'selected' => false, - 'completed' => true, - )); - } - } - } - - /** - * Set default template variables - * - * @param string $page_title Title of the page - * @param bool $selected_language True to enable language selector it, false otherwise - */ - protected function page_header($page_title, $selected_language = false) - { - // Path to templates - $paths = array($this->phpbb_root_path . 'install/update/new/adm/', $this->phpbb_admin_path); - $paths = array_filter($paths, 'is_dir'); - $path = array_shift($paths); - $path = substr($path, strlen($this->phpbb_root_path)); - - $this->template->assign_vars(array( - 'L_CHANGE' => $this->language->lang('CHANGE'), - 'L_COLON' => $this->language->lang('COLON'), - 'L_INSTALL_PANEL' => $this->language->lang('INSTALL_PANEL'), - 'L_SELECT_LANG' => $this->language->lang('SELECT_LANG'), - 'L_SKIP' => $this->language->lang('SKIP'), - 'PAGE_TITLE' => $this->language->lang($page_title), - 'T_IMAGE_PATH' => $this->path_helper->get_web_root_path() . $path . 'images', - 'T_JQUERY_LINK' => $this->path_helper->get_web_root_path() . $path . '../assets/javascript/jquery.min.js', - 'T_TEMPLATE_PATH' => $this->path_helper->get_web_root_path() . $path . 'style', - 'T_ASSETS_PATH' => $this->path_helper->get_web_root_path() . $path . '../assets', - - 'S_CONTENT_DIRECTION' => $this->language->lang('DIRECTION'), - 'S_CONTENT_FLOW_BEGIN' => ($this->language->lang('DIRECTION') === 'ltr') ? 'left' : 'right', - 'S_CONTENT_FLOW_END' => ($this->language->lang('DIRECTION') === 'ltr') ? 'right' : 'left', - 'S_CONTENT_ENCODING' => 'UTF-8', - 'S_LANG_SELECT' => $selected_language, - - 'S_USER_LANG' => $this->language->lang('USER_LANG'), - )); - - $this->render_navigation(); - } - - /** - * Render navigation - */ - protected function render_navigation() - { - // Get navigation items - $nav_array = $this->navigation_provider->get(); - $nav_array = $this->sort_navigation_level($nav_array); - - $active_main_menu = $this->get_active_main_menu($nav_array); - - // Pass navigation to template - foreach ($nav_array as $key => $entry) - { - $this->template->assign_block_vars('t_block1', array( - 'L_TITLE' => $this->language->lang($entry['label']), - 'S_SELECTED' => ($active_main_menu === $key), - 'U_TITLE' => $this->route($entry['route']), - )); - - if (is_array($entry[0]) && $active_main_menu === $key) - { - $entry[0] = $this->sort_navigation_level($entry[0]); - - foreach ($entry[0] as $name => $sub_entry) - { - if (isset($sub_entry['stage']) && $sub_entry['stage'] === true) - { - $this->template->assign_block_vars('l_block2', array( - 'L_TITLE' => $this->language->lang($sub_entry['label']), - 'S_SELECTED' => (isset($sub_entry['selected']) && $sub_entry['selected'] === true), - 'S_COMPLETE' => (isset($sub_entry['completed']) && $sub_entry['completed'] === true), - 'STAGE_NAME' => $name, - )); - } - else - { - $this->template->assign_block_vars('l_block1', array( - 'L_TITLE' => $this->language->lang($sub_entry['label']), - 'S_SELECTED' => (isset($sub_entry['route']) && $sub_entry['route'] === $this->request->get('_route')), - 'U_TITLE' => $this->route($sub_entry['route']), - )); - } - } - } - } - } - - /** - * Render language select form - * - * @param string $selected_language - */ - protected function render_language_select($selected_language = null) - { - $langs = $this->lang_helper->get_available_languages(); - foreach ($langs as $lang) - { - $this->template->assign_block_vars('language_select_item', array( - 'VALUE' => $lang['iso'], - 'NAME' => $lang['local_name'], - 'SELECTED' => ($lang['iso'] === $selected_language), - )); - } - } - - /** - * Returns the name of the active main menu item - * - * @param array $nav_array - * - * @return string|bool Returns the name of the active main menu element, if the element not found, returns false - */ - protected function get_active_main_menu($nav_array) - { - $active_route = $this->request->get('_route'); - - foreach ($nav_array as $nav_name => $nav_options) - { - $current_menu = $nav_name; - - if (isset($nav_options['route']) && $nav_options['route'] === $active_route) - { - return $nav_name; - } - - if (is_array($nav_options[0])) - { - foreach ($nav_options[0] as $sub_menus) - { - if (isset($sub_menus['route']) && $sub_menus['route'] === $active_route) - { - return $current_menu; - } - } - } - } - - return false; - } - - /** - * Sorts the top level of navigation array - * - * @param array $nav_array Navigation array - * - * @return array - */ - protected function sort_navigation_level($nav_array) - { - $sorted = array(); - foreach ($nav_array as $key => $nav) - { - $order = (isset($nav['order'])) ? $nav['order'] : 0; - $sorted[$order][$key] = $nav; - } - - // Linearization of navigation array - $nav_array = array(); - ksort($sorted); - foreach ($sorted as $nav) - { - $nav_array = array_merge($nav_array, $nav); - } - - return $nav_array; - } -} diff --git a/install/update/old/phpbb/install/helper/container_factory.php b/install/update/old/phpbb/install/helper/container_factory.php deleted file mode 100644 index 9e372fe..0000000 --- a/install/update/old/phpbb/install/helper/container_factory.php +++ /dev/null @@ -1,191 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\install\helper; - -use phpbb\install\exception\cannot_build_container_exception; -use phpbb\language\language; -use phpbb\request\request; - -class container_factory -{ - /** - * @var language - */ - protected $language; - - /** - * @var string - */ - protected $phpbb_root_path; - - /** - * @var string - */ - protected $php_ext; - - /** - * @var \phpbb\request\request - */ - protected $request; - - /** - * @var update_helper - */ - protected $update_helper; - - /** - * The full phpBB container - * - * @var \Symfony\Component\DependencyInjection\ContainerInterface - */ - protected $container; - - /** - * Constructor - * - * @param language $language Language service - * @param request $request Request interface - * @param update_helper $update_helper Update helper - * @param string $phpbb_root_path Path to phpBB's root - * @param string $php_ext Extension of PHP files - */ - public function __construct(language $language, request $request, update_helper $update_helper, $phpbb_root_path, $php_ext) - { - $this->language = $language; - $this->request = $request; - $this->update_helper = $update_helper; - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - $this->container = null; - } - - /** - * Container getter - * - * @param null|string $service_name Name of the service to return - * - * @return \Symfony\Component\DependencyInjection\ContainerInterface|Object phpBB's dependency injection container - * or the service specified in $service_name - * - * @throws \phpbb\install\exception\cannot_build_container_exception When container cannot be built - * @throws \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException If the service is not defined - * @throws \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException When a circular reference is detected - * @throws \Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException When the service is not defined - */ - public function get($service_name = null) - { - // Check if container was built, if not try to build it - if ($this->container === null) - { - $this->build_container(); - } - - return ($service_name === null) ? $this->container : $this->container->get($service_name); - } - - /** - * Returns the specified parameter from the container - * - * @param string $param_name - * - * @return mixed - * - * @throws \phpbb\install\exception\cannot_build_container_exception When container cannot be built - */ - public function get_parameter($param_name) - { - // Check if container was built, if not try to build it - if ($this->container === null) - { - $this->build_container(); - } - - return $this->container->getParameter($param_name); - } - - /** - * Build dependency injection container - * - * @throws \phpbb\install\exception\cannot_build_container_exception When container cannot be built - */ - protected function build_container() - { - // If the container has been already built just return. - // Although this should never happen - if ($this->container instanceof \Symfony\Component\DependencyInjection\ContainerInterface) - { - return; - } - - // Check whether container can be built - // We need config.php for that so let's check if it has been set up yet - if (!filesize($this->phpbb_root_path . 'config.' . $this->php_ext)) - { - throw new cannot_build_container_exception(); - } - - $phpbb_config_php_file = new \phpbb\config_php_file($this->phpbb_root_path, $this->php_ext); - $phpbb_container_builder = new \phpbb\di\container_builder($this->phpbb_root_path, $this->php_ext); - - // For BC with functions that we need during install - global $phpbb_container, $table_prefix; - - $disable_super_globals = $this->request->super_globals_disabled(); - - // This is needed because container_builder::get_env_parameters() uses $_SERVER - if ($disable_super_globals) - { - $this->request->enable_super_globals(); - } - - $other_config_path = $this->phpbb_root_path . 'install/update/new/config'; - $config_path = (is_dir($other_config_path)) ? $other_config_path : $this->phpbb_root_path . 'config'; - - $this->container = $phpbb_container_builder - ->with_environment('production') - ->with_config($phpbb_config_php_file) - ->with_config_path($config_path) - ->without_compiled_container() - ->get_container(); - - // Setting request is required for the compatibility globals as those are generated from - // this container - if (!$this->container->isFrozen()) - { - $this->container->register('request')->setSynthetic(true); - $this->container->register('language')->setSynthetic(true); - } - - $this->container->set('request', $this->request); - $this->container->set('language', $this->language); - - $this->container->compile(); - - $phpbb_container = $this->container; - $table_prefix = $phpbb_config_php_file->get('table_prefix'); - - // Restore super globals to previous state - if ($disable_super_globals) - { - $this->request->disable_super_globals(); - } - - // Get compatibilty globals and constants - $this->update_helper->include_file('includes/compatibility_globals.' . $this->php_ext); - - register_compatibility_globals(); - - $this->update_helper->include_file('includes/constants.' . $this->php_ext); - } -} diff --git a/install/update/old/phpbb/install/helper/database.php b/install/update/old/phpbb/install/helper/database.php deleted file mode 100644 index fa5a10c..0000000 --- a/install/update/old/phpbb/install/helper/database.php +++ /dev/null @@ -1,439 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\install\helper; - -use phpbb\install\exception\invalid_dbms_exception; - -/** - * Database related general functionality for installer - */ -class database -{ - /** - * @var \phpbb\filesystem\filesystem_interface - */ - protected $filesystem; - - /** - * @var string - */ - protected $phpbb_root_path; - - /** - * @var array - */ - protected $supported_dbms = array( - // Note: php 5.5 alpha 2 deprecated mysql. - // Keep mysqli before mysql in this list. - 'mysqli' => array( - 'LABEL' => 'MySQL with MySQLi Extension', - 'SCHEMA' => 'mysql_41', - 'MODULE' => 'mysqli', - 'DELIM' => ';', - 'DRIVER' => 'phpbb\db\driver\mysqli', - 'AVAILABLE' => true, - '2.0.x' => true, - ), - 'mysql' => array( - 'LABEL' => 'MySQL', - 'SCHEMA' => 'mysql', - 'MODULE' => 'mysql', - 'DELIM' => ';', - 'DRIVER' => 'phpbb\db\driver\mysql', - 'AVAILABLE' => true, - '2.0.x' => true, - ), - 'mssql_odbc'=> array( - 'LABEL' => 'MS SQL Server [ ODBC ]', - 'SCHEMA' => 'mssql', - 'MODULE' => 'odbc', - 'DELIM' => ';', - 'DRIVER' => 'phpbb\db\driver\mssql_odbc', - 'AVAILABLE' => true, - '2.0.x' => true, - ), - 'mssqlnative' => array( - 'LABEL' => 'MS SQL Server 2005+ [ Native ]', - 'SCHEMA' => 'mssql', - 'MODULE' => 'sqlsrv', - 'DELIM' => ';', - 'DRIVER' => 'phpbb\db\driver\mssqlnative', - 'AVAILABLE' => true, - '2.0.x' => false, - ), - 'oracle' => array( - 'LABEL' => 'Oracle', - 'SCHEMA' => 'oracle', - 'MODULE' => 'oci8', - 'DELIM' => ';', - 'DRIVER' => 'phpbb\db\driver\oracle', - 'AVAILABLE' => true, - '2.0.x' => false, - ), - 'postgres' => array( - 'LABEL' => 'PostgreSQL 8.3+', - 'SCHEMA' => 'postgres', - 'MODULE' => 'pgsql', - 'DELIM' => ';', - 'DRIVER' => 'phpbb\db\driver\postgres', - 'AVAILABLE' => true, - '2.0.x' => true, - ), - 'sqlite3' => array( - 'LABEL' => 'SQLite3', - 'SCHEMA' => 'sqlite', - 'MODULE' => 'sqlite3', - 'DELIM' => ';', - 'DRIVER' => 'phpbb\db\driver\sqlite3', - 'AVAILABLE' => true, - '2.0.x' => false, - ), - ); - - /** - * Constructor - * - * @param \phpbb\filesystem\filesystem_interface $filesystem Filesystem interface - * @param string $phpbb_root_path Path to phpBB's root - */ - public function __construct(\phpbb\filesystem\filesystem_interface $filesystem, $phpbb_root_path) - { - $this->filesystem = $filesystem; - $this->phpbb_root_path = $phpbb_root_path; - } - - /** - * Returns an array of available DBMS supported by phpBB - * - * If a DBMS is specified it will only return data for that DBMS - * and will load its extension if necessary. - * - * @param mixed $dbms name of the DBMS that's info is required or false for all DBMS info - * @param bool $return_unavailable set it to true if you expect unavailable but supported DBMS - * returned as well - * @param bool $only_20x_options set it to true if you only want to recover 2.0.x options - * - * @return array Array of available and supported DBMS - */ - public function get_available_dbms($dbms = false, $return_unavailable = false, $only_20x_options = false) - { - $available_dbms = $this->supported_dbms; - - if ($dbms) - { - if (isset($this->supported_dbms[$dbms])) - { - $available_dbms = array($dbms => $this->supported_dbms[$dbms]); - } - else - { - return array(); - } - } - - $any_dbms_available = false; - foreach ($available_dbms as $db_name => $db_array) - { - if ($only_20x_options && !$db_array['2.0.x']) - { - if ($return_unavailable) - { - $available_dbms[$db_name]['AVAILABLE'] = false; - } - else - { - unset($available_dbms[$db_name]); - } - - continue; - } - - $dll = $db_array['MODULE']; - if (!@extension_loaded($dll)) - { - if ($return_unavailable) - { - $available_dbms[$db_name]['AVAILABLE'] = false; - } - else - { - unset($available_dbms[$db_name]); - } - - continue; - } - - $any_dbms_available = true; - } - - if ($return_unavailable) - { - $available_dbms['ANY_DB_SUPPORT'] = $any_dbms_available; - } - - return $available_dbms; - } - - /** - * Removes "/* style" as well as "# style" comments from $input. - * - * @param string $sql_query Input string - * - * @return string Input string with comments removed - */ - public function remove_comments($sql_query) - { - // Remove /* */ comments (http://ostermiller.org/findcomment.html) - $sql_query = preg_replace('#/\*(.|[\r\n])*?\*/#', "\n", $sql_query); - - // Remove # style comments - $sql_query = preg_replace('/\n{2,}/', "\n", preg_replace('/^#.*$/m', "\n", $sql_query)); - - return $sql_query; - } - - /** - * split_sql_file() will split an uploaded sql file into single sql statements. - * - * Note: expects trim() to have already been run on $sql. - * - * @param string $sql SQL statements - * @param string $delimiter Delimiter between sql statements - * - * @return array Array of sql statements - */ - public function split_sql_file($sql, $delimiter) - { - $sql = str_replace("\r" , '', $sql); - $data = preg_split('/' . preg_quote($delimiter, '/') . '$/m', $sql); - - $data = array_map('trim', $data); - - // The empty case - $end_data = end($data); - - if (empty($end_data)) - { - unset($data[key($data)]); - } - - return $data; - } - - /** - * Validates table prefix - * - * @param string $dbms The selected dbms - * @param string $table_prefix The table prefix to validate - * - * @return bool|array true if table prefix is valid, array of errors otherwise - * - * @throws \phpbb\install\exception\invalid_dbms_exception When $dbms is not a valid - */ - public function validate_table_prefix($dbms, $table_prefix) - { - $errors = array(); - - if (!preg_match('#^[a-zA-Z][a-zA-Z0-9_]*$#', $table_prefix)) - { - $errors[] = array( - 'title' => 'INST_ERR_DB_INVALID_PREFIX', - ); - } - - // Do dbms specific checks - $dbms_info = $this->get_available_dbms($dbms); - switch ($dbms_info[$dbms]['SCHEMA']) - { - case 'mysql': - case 'mysql_41': - $prefix_length = 36; - break; - case 'mssql': - $prefix_length = 90; - break; - case 'oracle': - $prefix_length = 6; - break; - case 'postgres': - $prefix_length = 36; - break; - case 'sqlite': - $prefix_length = 200; - break; - default: - throw new invalid_dbms_exception(); - break; - } - - // Check the prefix length to ensure that index names are not too long - if (strlen($table_prefix) > $prefix_length) - { - $errors[] = array( - 'title' => array('INST_ERR_PREFIX_TOO_LONG', $prefix_length), - ); - } - - return (empty($errors)) ? true : $errors; - } - - /** - * Check if the user provided database parameters are correct - * - * This function checks the database connection data and also checks for - * any other problems that could cause an error during the installation - * such as if there is any database table names conflicting. - * - * Note: The function assumes that $table_prefix has been already validated - * with validate_table_prefix(). - * - * @param string $dbms Selected database type - * @param string $dbhost Database host address - * @param int $dbport Database port number - * @param string $dbuser Database username - * @param string $dbpass Database password - * @param string $dbname Database name - * @param string $table_prefix Database table prefix - * - * @return array|bool Returns true if test is successful, array of errors otherwise - */ - public function check_database_connection($dbms, $dbhost, $dbport, $dbuser, $dbpass, $dbname, $table_prefix) - { - $dbms_info = $this->get_available_dbms($dbms); - $dbms_info = $dbms_info[$dbms]; - $errors = array(); - - // Instantiate it and set return on error true - /** @var \phpbb\db\driver\driver_interface $db */ - $db = new $dbms_info['DRIVER']; - $db->sql_return_on_error(true); - - // Check that we actually have a database name before going any further - if (!in_array($dbms_info['SCHEMA'], array('sqlite', 'oracle'), true) && $dbname === '') - { - $errors[] = array( - 'title' => 'INST_ERR_DB_NO_NAME', - ); - } - - // Make sure we don't have a daft user who thinks having the SQLite database in the forum directory is a good idea - if ($dbms_info['SCHEMA'] === 'sqlite' - && stripos($this->filesystem->realpath($dbhost), $this->filesystem->realpath($this->phpbb_root_path) === 0)) - { - $errors[] = array( - 'title' =>'INST_ERR_DB_FORUM_PATH', - ); - } - - // Check if SQLite database is writable - if ($dbms_info['SCHEMA'] === 'sqlite' - && (($this->filesystem->exists($dbhost) && !$this->filesystem->is_writable($dbhost)) || !$this->filesystem->is_writable(pathinfo($dbhost, PATHINFO_DIRNAME)))) - { - $errors[] = array( - 'title' =>'INST_ERR_DB_NO_WRITABLE', - ); - } - - // Try to connect to db - if (is_array($db->sql_connect($dbhost, $dbuser, $dbpass, $dbname, $dbport, false, true))) - { - $db_error = $db->sql_error(); - $errors[] = array( - 'title' => 'INST_ERR_DB_CONNECT', - 'description' => ($db_error['message']) ? utf8_convert_message($db_error['message']) : 'INST_ERR_DB_NO_ERROR', - ); - } - else - { - // Check if there is any table name collisions - $temp_prefix = strtolower($table_prefix); - $table_ary = array( - $temp_prefix . 'attachments', - $temp_prefix . 'config', - $temp_prefix . 'sessions', - $temp_prefix . 'topics', - $temp_prefix . 'users', - ); - - $db_tools_factory = new \phpbb\db\tools\factory(); - $db_tools = $db_tools_factory->get($db); - $tables = $db_tools->sql_list_tables(); - $tables = array_map('strtolower', $tables); - $table_intersect = array_intersect($tables, $table_ary); - - if (count($table_intersect)) - { - $errors[] = array( - 'title' => 'INST_ERR_PREFIX', - ); - } - - // Check if database version is supported - switch ($dbms) - { - case 'mysqli': - if (version_compare($db->sql_server_info(true), '4.1.3', '<')) - { - $errors[] = array( - 'title' => 'INST_ERR_DB_NO_MYSQLI', - ); - } - break; - case 'sqlite3': - if (version_compare($db->sql_server_info(true), '3.6.15', '<')) - { - $errors[] = array( - 'title' => 'INST_ERR_DB_NO_SQLITE3', - ); - } - break; - case 'oracle': - $sql = "SELECT * - FROM NLS_DATABASE_PARAMETERS - WHERE PARAMETER = 'NLS_RDBMS_VERSION' - OR PARAMETER = 'NLS_CHARACTERSET'"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $stats[$row['parameter']] = $row['value']; - } - $db->sql_freeresult($result); - - if (version_compare($stats['NLS_RDBMS_VERSION'], '9.2', '<') && $stats['NLS_CHARACTERSET'] !== 'UTF8') - { - $errors[] = array( - 'title' => 'INST_ERR_DB_NO_ORACLE', - ); - } - break; - case 'postgres': - $sql = "SHOW server_encoding;"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row['server_encoding'] !== 'UNICODE' && $row['server_encoding'] !== 'UTF8') - { - $errors[] = array( - 'title' => 'INST_ERR_DB_NO_POSTGRES', - ); - } - break; - } - } - - return (empty($errors)) ? true : $errors; - } -} diff --git a/install/update/old/phpbb/install/helper/iohandler/iohandler_interface.php b/install/update/old/phpbb/install/helper/iohandler/iohandler_interface.php deleted file mode 100644 index 4407489..0000000 --- a/install/update/old/phpbb/install/helper/iohandler/iohandler_interface.php +++ /dev/null @@ -1,222 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\install\helper\iohandler; - -/** - * Input-Output handler interface for the installer - */ -interface iohandler_interface -{ - /** - * Renders or returns response message - * - * @param bool $no_more_output Whether or not there will be more output in this output unit - */ - public function send_response($no_more_output = false); - - /** - * Returns input variable - * - * @param string $name Name of the input variable to obtain - * @param mixed $default A default value that is returned if the variable was not set. - * This function will always return a value of the same type as the default. - * @param bool $multibyte If $default is a string this paramater has to be true if the variable may contain any UTF-8 characters - * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks - * - * @return mixed Value of the input variable - */ - public function get_input($name, $default, $multibyte = false); - - /** - * Returns raw input variable - * - * @param string $name Name of the input variable to obtain - * @param mixed $default A default value that is returned if the variable was not set. - * This function will always return a value of the same type as the default. - * - * @return mixed Value of the raw input variable - */ - public function get_raw_input($name, $default); - - /** - * Returns server variable - * - * This function should work the same as request_interface::server(). - * - * @param string $name Name of the server variable - * @param mixed $default Default value to return when the requested variable does not exist - * - * @return mixed Value of the server variable - */ - public function get_server_variable($name, $default = ''); - - /** - * Wrapper function for request_interface::header() - * - * @param string $name Name of the request header variable - * @param mixed $default Default value to return when the requested variable does not exist - * - * @return mixed - */ - public function get_header_variable($name, $default = ''); - - /** - * Returns true if the connection is encrypted - * - * @return bool - */ - public function is_secure(); - - /** - * Adds an error message to the rendering queue - * - * Note: When an array is passed into the parameters below, it will be - * resolved as printf($param[0], $param[1], ...). - * - * @param string|array $error_title Title of the error message. - * @param string|bool|array $error_description Description of the error (and possibly guidelines to resolve it), - * or false if the error description is not available. - */ - public function add_error_message($error_title, $error_description = false); - - /** - * Adds a warning message to the rendering queue - * - * Note: When an array is passed into the parameters below, it will be - * resolved as printf($param[0], $param[1], ...). - * - * @param string|array $warning_title Title of the warning message - * @param string|bool|array $warning_description Description of the warning (and possibly guidelines to resolve it), - * or false if the warning description is not available - */ - public function add_warning_message($warning_title, $warning_description = false); - - /** - * Adds a log message to the rendering queue - * - * Note: When an array is passed into the parameters below, it will be - * resolved as printf($param[0], $param[1], ...). - * - * @param string|array $log_title Title of the log message - * @param string|bool|array $log_description Description of the log, - * or false if the log description is not available - */ - public function add_log_message($log_title, $log_description = false); - - /** - * Adds a success message to the rendering queue - * - * Note: When an array is passed into the parameters below, it will be - * resolved as printf($param[0], $param[1], ...). - * - * @param string|array $success_title Title of the success message - * @param string|bool|array $success_description Description of the success, - * or false if the success description is not available - * - * @return null - */ - public function add_success_message($success_title, $success_description = false); - - /** - * Adds a requested data group to the rendering queue - * - * @param string $title Language variable with the title of the form - * @param array $form An array describing the required data (options etc) - */ - public function add_user_form_group($title, $form); - - /** - * Returns the rendering information for the form - * - * @param string $title Language variable with the title of the form - * @param array $form An array describing the required data (options etc) - * - * @return string Information to render the form - */ - public function generate_form_render_data($title, $form); - - /** - * Sets the number of tasks belonging to the installer in the current mode. - * - * @param int $task_count Number of tasks - * @param bool $restart Whether or not to restart the progress bar, false by default - */ - public function set_task_count($task_count, $restart = false); - - /** - * Sets the progress information - * - * @param string $task_lang_key Language key for the name of the task - * @param int $task_number Position of the current task in the task queue - */ - public function set_progress($task_lang_key, $task_number); - - /** - * Sends refresh request to the client - */ - public function request_refresh(); - - /** - * Marks stage as active in the navigation bar - * - * @param array $menu_path Array to the navigation elem - */ - public function set_active_stage_menu($menu_path); - - /** - * Marks stage as completed in the navigation bar - * - * @param array $menu_path Array to the navigation elem - */ - public function set_finished_stage_menu($menu_path); - - /** - * Finish the progress bar - * - * @param string $message_lang_key Language key for the message - */ - public function finish_progress($message_lang_key); - - /** - * Adds a download link - * - * @param string $route Route for the link - * @param string $title Language key for the title - * @param string|null|array $msg Language key for the message - */ - public function add_download_link($route, $title, $msg = null); - - /** - * Redirects the user to a new page - * - * @param string $url URL to redirect to - * @param bool $use_ajax Whether or not to use AJAX redirect - */ - public function redirect($url, $use_ajax = false); - - /** - * Renders the status of update files - * - * @param array $status_array Array containing files in groups to render - */ - public function render_update_file_status($status_array); - - /** - * Sends and sets cookies - * - * @param string $cookie_name Name of the cookie to set - * @param string $cookie_value Value of the cookie to set - */ - public function set_cookie($cookie_name, $cookie_value); -} diff --git a/install/update/old/phpbb/install/installer_configuration.php b/install/update/old/phpbb/install/installer_configuration.php deleted file mode 100644 index 8051403..0000000 --- a/install/update/old/phpbb/install/installer_configuration.php +++ /dev/null @@ -1,147 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\install; - -use Symfony\Component\Config\Definition\Builder\TreeBuilder; -use Symfony\Component\Config\Definition\ConfigurationInterface; - -class installer_configuration implements ConfigurationInterface -{ - - /** - * Generates the configuration tree builder. - * - * @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The tree builder - */ - public function getConfigTreeBuilder() - { - $treeBuilder = new TreeBuilder(); - $rootNode = $treeBuilder->root('installer'); - $rootNode - ->children() - ->arrayNode('admin') - ->children() - ->scalarNode('name')->defaultValue('admin')->cannotBeEmpty()->end() - ->scalarNode('password')->defaultValue('adminadmin')->cannotBeEmpty()->end() - ->scalarNode('email')->defaultValue('admin@example.org')->cannotBeEmpty()->end() - ->end() - ->end() - ->arrayNode('board') - ->children() - ->scalarNode('lang') - ->defaultValue('en') - ->cannotBeEmpty() - ->end() - ->scalarNode('name') - ->defaultValue('My Board') - ->cannotBeEmpty() - ->end() - ->scalarNode('description') - ->defaultValue('My amazing new phpBB board') - ->cannotBeEmpty() - ->end() - ->end() - ->end() - ->arrayNode('database') - ->children() - ->scalarNode('dbms') - ->defaultValue('sqlite3') - ->cannotBeEmpty() - ->isRequired() - ->end() - ->scalarNode('dbhost') - ->defaultValue(null) - ->end() - ->scalarNode('dbport') - ->defaultValue(null) - ->end() - ->scalarNode('dbuser') - ->defaultValue(null) - ->end() - ->scalarNode('dbpasswd') - ->defaultValue(null) - ->end() - ->scalarNode('dbname') - ->defaultValue(null) - ->end() - ->scalarNode('table_prefix') - ->defaultValue('phpbb_') - ->cannotBeEmpty() - ->isRequired() - ->end() - ->end() - ->end() - ->arrayNode('email') - ->canBeEnabled() - ->addDefaultsIfNotSet() - ->children() - ->booleanNode('smtp_delivery') - ->defaultValue(false) - ->treatNullLike(false) - ->end() - ->scalarNode('smtp_host') - ->defaultValue(null) - ->end() - ->scalarNode('smtp_port') - ->defaultValue(null) - ->end() - ->scalarNode('smtp_auth') - ->defaultValue(null) - ->end() - ->scalarNode('smtp_user') - ->defaultValue(null) - ->end() - ->scalarNode('smtp_pass') - ->defaultValue(null) - ->end() - ->end() - ->end() - ->arrayNode('server') - ->children() - ->booleanNode('cookie_secure') - ->defaultValue(false) - ->treatNullLike(false) - ->end() - ->scalarNode('server_protocol') - ->defaultValue('http://') - ->cannotBeEmpty() - ->end() - ->booleanNode('force_server_vars') - ->defaultValue(false) - ->treatNullLike(false) - ->end() - ->scalarNode('server_name') - ->defaultValue('localhost') - ->cannotBeEmpty() - ->end() - ->integerNode('server_port') - ->defaultValue(80) - ->min(1) - ->cannotBeEmpty() - ->end() - ->scalarNode('script_path') - ->defaultValue('/') - ->cannotBeEmpty() - ->end() - ->end() - ->end() - ->arrayNode('extensions') - ->prototype('scalar')->end() - ->defaultValue([]) - ->end() - ->end() - ; - return $treeBuilder; - } -} diff --git a/install/update/old/phpbb/install/module/install_database/task/add_config_settings.php b/install/update/old/phpbb/install/module/install_database/task/add_config_settings.php deleted file mode 100644 index ba43960..0000000 --- a/install/update/old/phpbb/install/module/install_database/task/add_config_settings.php +++ /dev/null @@ -1,368 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\install\module\install_database\task; - -use phpbb\install\exception\resource_limit_reached_exception; - -/** - * Create database schema - */ -class add_config_settings extends \phpbb\install\task_base -{ - /** - * @var \phpbb\db\driver\driver_interface - */ - protected $db; - - /** - * @var \phpbb\filesystem\filesystem_interface - */ - protected $filesystem; - - /** - * @var \phpbb\install\helper\config - */ - protected $install_config; - - /** - * @var \phpbb\install\helper\iohandler\iohandler_interface - */ - protected $iohandler; - - /** - * @var \phpbb\language\language - */ - protected $language; - - /** - * @var \phpbb\passwords\manager - */ - protected $password_manager; - - /** - * @var string - */ - protected $phpbb_root_path; - - /** - * @var string - */ - protected $config_table; - - /** - * @var string - */ - protected $user_table; - - /** - * @var string - */ - protected $topics_table; - - /** - * @var string - */ - protected $forums_table; - - /** - * @var string - */ - protected $posts_table; - - /** - * @var string - */ - protected $moderator_cache_table; - - /** - * Constructor - * - * @param \phpbb\filesystem\filesystem_interface $filesystem Filesystem service - * @param \phpbb\install\helper\config $install_config Installer's config helper - * @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler Installer's input-output handler - * @param \phpbb\install\helper\container_factory $container Installer's DI container - * @param \phpbb\language\language $language Language service - * @param string $phpbb_root_path Path to phpBB's root - */ - public function __construct(\phpbb\filesystem\filesystem_interface $filesystem, - \phpbb\install\helper\config $install_config, - \phpbb\install\helper\iohandler\iohandler_interface $iohandler, - \phpbb\install\helper\container_factory $container, - \phpbb\language\language $language, - $phpbb_root_path) - { - $this->db = $container->get('dbal.conn'); - $this->filesystem = $filesystem; - $this->install_config = $install_config; - $this->iohandler = $iohandler; - $this->language = $language; - $this->password_manager = $container->get('passwords.manager'); - $this->phpbb_root_path = $phpbb_root_path; - - // Table names - $this->config_table = $container->get_parameter('tables.config'); - $this->forums_table = $container->get_parameter('tables.forums'); - $this->topics_table = $container->get_parameter('tables.topics'); - $this->user_table = $container->get_parameter('tables.users'); - $this->moderator_cache_table = $container->get_parameter('tables.moderator_cache'); - $this->posts_table = $container->get_parameter('tables.posts'); - - parent::__construct(true); - } - - /** - * {@inheritdoc} - */ - public function run() - { - $this->db->sql_return_on_error(true); - - $server_name = $this->install_config->get('server_name'); - $current_time = time(); - $user_ip = phpbb_ip_normalise($this->iohandler->get_server_variable('REMOTE_ADDR')); - $user_ip = ($user_ip === false) ? '' : $user_ip; - $referer = $this->iohandler->get_server_variable('REFERER'); - - // Calculate cookie domain - $cookie_domain = $server_name; - - if (strpos($cookie_domain, 'www.') === 0) - { - $cookie_domain = substr($cookie_domain, 3); - } - - // Set default config and post data, this applies to all DB's - $sql_ary = array( - 'INSERT INTO ' . $this->config_table . " (config_name, config_value) - VALUES ('board_startdate', '$current_time')", - - 'INSERT INTO ' . $this->config_table . " (config_name, config_value) - VALUES ('default_lang', '" . $this->db->sql_escape($this->install_config->get('default_lang')) . "')", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($this->install_config->get('server_name')) . "' - WHERE config_name = 'server_name'", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($this->install_config->get('server_port')) . "' - WHERE config_name = 'server_port'", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($this->install_config->get('board_email')) . "' - WHERE config_name = 'board_email'", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($this->install_config->get('board_email')) . "' - WHERE config_name = 'board_contact'", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($cookie_domain) . "' - WHERE config_name = 'cookie_domain'", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($this->language->lang('default_dateformat')) . "' - WHERE config_name = 'default_dateformat'", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($this->install_config->get('email_enable')) . "' - WHERE config_name = 'email_enable'", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($this->install_config->get('smtp_delivery')) . "' - WHERE config_name = 'smtp_delivery'", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($this->install_config->get('smtp_host')) . "' - WHERE config_name = 'smtp_host'", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($this->install_config->get('smtp_port')) . "' - WHERE config_name = 'smtp_port'", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($this->install_config->get('smtp_auth')) . "' - WHERE config_name = 'smtp_auth_method'", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($this->install_config->get('smtp_user')) . "' - WHERE config_name = 'smtp_username'", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($this->install_config->get('smtp_pass')) . "' - WHERE config_name = 'smtp_password'", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($this->install_config->get('cookie_secure')) . "' - WHERE config_name = 'cookie_secure'", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($this->install_config->get('force_server_vars')) . "' - WHERE config_name = 'force_server_vars'", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($this->install_config->get('script_path')) . "' - WHERE config_name = 'script_path'", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($this->install_config->get('server_protocol')) . "' - WHERE config_name = 'server_protocol'", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($this->install_config->get('admin_name')) . "' - WHERE config_name = 'newest_username'", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . md5(mt_rand()) . "' - WHERE config_name = 'avatar_salt'", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . md5(mt_rand()) . "' - WHERE config_name = 'plupload_salt'", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($this->install_config->get('board_name')) . "' - WHERE config_name = 'sitename'", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($this->install_config->get('board_description')) . "' - WHERE config_name = 'site_desc'", - - 'UPDATE ' . $this->user_table . " - SET username = '" . $this->db->sql_escape($this->install_config->get('admin_name')) . "', - user_password='" . $this->password_manager->hash($this->install_config->get('admin_passwd')) . "', - user_ip = '" . $this->db->sql_escape($user_ip) . "', - user_lang = '" . $this->db->sql_escape($this->install_config->get('user_language', 'en')) . "', - user_email='" . $this->db->sql_escape($this->install_config->get('board_email')) . "', - user_dateformat='" . $this->db->sql_escape($this->language->lang('default_dateformat')) . "', - user_email_hash = " . $this->db->sql_escape(phpbb_email_hash($this->install_config->get('board_email'))) . ", - username_clean = '" . $this->db->sql_escape(utf8_clean_string($this->install_config->get('admin_name'))) . "' - WHERE username = 'Admin'", - - 'UPDATE ' . $this->moderator_cache_table . " - SET username = '" . $this->db->sql_escape($this->install_config->get('admin_name')) . "' - WHERE username = 'Admin'", - - 'UPDATE ' . $this->forums_table . " - SET forum_last_poster_name = '" . $this->db->sql_escape($this->install_config->get('admin_name')) . "' - WHERE forum_last_poster_name = 'Admin'", - - 'UPDATE ' . $this->topics_table . " - SET topic_first_poster_name = '" . $this->db->sql_escape($this->install_config->get('admin_name')) . "', - topic_last_poster_name = '" . $this->db->sql_escape($this->install_config->get('admin_name')) . "' - WHERE topic_first_poster_name = 'Admin' - OR topic_last_poster_name = 'Admin'", - - 'UPDATE ' . $this->user_table . " - SET user_regdate = $current_time", - - 'UPDATE ' . $this->posts_table . " - SET post_time = $current_time, poster_ip = '" . $this->db->sql_escape($user_ip) . "'", - - 'UPDATE ' . $this->topics_table . " - SET topic_time = $current_time, topic_last_post_time = $current_time", - - 'UPDATE ' . $this->forums_table . " - SET forum_last_post_time = $current_time", - - 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($this->db->sql_server_info(true)) . "' - WHERE config_name = 'dbms_version'", - ); - - if (@extension_loaded('gd')) - { - $sql_ary[] = 'UPDATE ' . $this->config_table . " - SET config_value = 'core.captcha.plugins.gd' - WHERE config_name = 'captcha_plugin'"; - - $sql_ary[] = 'UPDATE ' . $this->config_table . " - SET config_value = '1' - WHERE config_name = 'captcha_gd'"; - } - - $ref = substr($referer, strpos($referer, '://') + 3); - if (!(stripos($ref, $server_name) === 0)) - { - $sql_ary[] = 'UPDATE ' . $this->config_table . " - SET config_value = '0' - WHERE config_name = 'referer_validation'"; - } - - // We set a (semi-)unique cookie name to bypass login issues related to the cookie name. - $cookie_name = 'phpbb3_'; - $rand_str = md5(mt_rand()); - $rand_str = str_replace('0', 'z', base_convert($rand_str, 16, 35)); - $rand_str = substr($rand_str, 0, 5); - $cookie_name .= strtolower($rand_str); - - $sql_ary[] = 'UPDATE ' . $this->config_table . " - SET config_value = '" . $this->db->sql_escape($cookie_name) . "' - WHERE config_name = 'cookie_name'"; - - // Disable avatars if upload directory is not writable - if (!$this->filesystem->is_writable($this->phpbb_root_path . 'images/avatars/upload/')) - { - $sql_ary[] = 'UPDATE ' . $this->config_table . " - SET config_value = '0' - WHERE config_name = 'allow_avatar'"; - - $sql_ary[] = 'UPDATE ' . $this->config_table . " - SET config_value = '0' - WHERE config_name = 'allow_avatar_upload'"; - } - - $i = $this->install_config->get('add_config_settings_index', 0); - $total = count($sql_ary); - $sql_ary = array_slice($sql_ary, $i); - - foreach ($sql_ary as $sql) - { - if (!$this->db->sql_query($sql)) - { - $error = $this->db->sql_error($this->db->get_sql_error_sql()); - $this->iohandler->add_error_message('INST_ERR_DB', $error['message']); - } - - $i++; - - // Stop execution if resource limit is reached - if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0) - { - break; - } - } - - if ($i < $total) - { - $this->install_config->set('add_config_settings_index', $i); - throw new resource_limit_reached_exception(); - } - } - - /** - * {@inheritdoc} - */ - static public function get_step_count() - { - return 1; - } - - /** - * {@inheritdoc} - */ - public function get_task_lang_name() - { - return 'TASK_ADD_CONFIG_SETTINGS'; - } -} diff --git a/install/update/old/phpbb/install/module/install_database/task/create_schema.php b/install/update/old/phpbb/install/module/install_database/task/create_schema.php deleted file mode 100644 index a5635d5..0000000 --- a/install/update/old/phpbb/install/module/install_database/task/create_schema.php +++ /dev/null @@ -1,234 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\install\module\install_database\task; - -use phpbb\install\exception\resource_limit_reached_exception; - -/** - * Create database schema - */ -class create_schema extends \phpbb\install\task_base -{ - /** - * @var \phpbb\install\helper\config - */ - protected $config; - - /** - * @var \phpbb\db\driver\driver_interface - */ - protected $db; - - /** - * @var \phpbb\db\tools\tools_interface - */ - protected $db_tools; - - /** - * @var \phpbb\install\helper\database - */ - protected $database_helper; - - /** - * @var \phpbb\filesystem\filesystem_interface - */ - protected $filesystem; - - /** - * @var \phpbb\install\helper\iohandler\iohandler_interface - */ - protected $iohandler; - - /** - * @var string - */ - protected $phpbb_root_path; - - /** - * @var string - */ - protected $php_ext; - - /** - * Constructor - * - * @param \phpbb\install\helper\config $config Installer's config provider - * @param \phpbb\install\helper\database $db_helper Installer's database helper - * @param \phpbb\filesystem\filesystem_interface $filesystem Filesystem service - * @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler Installer's input-output handler - * @param string $phpbb_root_path Path phpBB's root - * @param string $php_ext Extension of PHP files - */ - public function __construct(\phpbb\install\helper\config $config, - \phpbb\install\helper\database $db_helper, - \phpbb\filesystem\filesystem_interface $filesystem, - \phpbb\install\helper\iohandler\iohandler_interface $iohandler, - $phpbb_root_path, - $php_ext) - { - $dbms = $db_helper->get_available_dbms($config->get('dbms')); - $dbms = $dbms[$config->get('dbms')]['DRIVER']; - $factory = new \phpbb\db\tools\factory(); - - $this->db = new $dbms(); - $this->db->sql_connect( - $config->get('dbhost'), - $config->get('dbuser'), - $config->get('dbpasswd'), - $config->get('dbname'), - $config->get('dbport'), - false, - false - ); - - $this->config = $config; - $this->db_tools = $factory->get($this->db); - $this->database_helper = $db_helper; - $this->filesystem = $filesystem; - $this->iohandler = $iohandler; - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - - parent::__construct(true); - } - - /** - * {@inheritdoc} - */ - public function run() - { - // As this task may take a large amount of time to complete refreshing the page might be necessary for some - // server configurations with limited resources - if (!$this->config->get('pre_schema_forced_refresh')) - { - if ($this->config->get_time_remaining() < 5) - { - $this->config->set('pre_schema_forced_refresh', true); - throw new resource_limit_reached_exception(); - } - } - - $this->db->sql_return_on_error(true); - - $dbms = $this->config->get('dbms'); - $dbms_info = $this->database_helper->get_available_dbms($dbms); - $schema_name = $dbms_info[$dbms]['SCHEMA']; - $delimiter = $dbms_info[$dbms]['DELIM']; - $table_prefix = $this->config->get('table_prefix'); - - if ($dbms === 'mysql') - { - if (version_compare($this->db->sql_server_info(true), '4.1.3', '>=')) - { - $schema_name .= '_41'; - } - else - { - $schema_name .= '_40'; - } - } - - $db_schema_path = $this->phpbb_root_path . 'install/schemas/' . $schema_name . '_schema.sql'; - - // Load database vendor specific code if there is any - if ($this->filesystem->exists($db_schema_path)) - { - $sql_query = @file_get_contents($db_schema_path); - $sql_query = preg_replace('#phpbb_#i', $table_prefix, $sql_query); - $sql_query = $this->database_helper->remove_comments($sql_query); - $sql_query = $this->database_helper->split_sql_file($sql_query, $delimiter); - - foreach ($sql_query as $sql) - { - if (!$this->db->sql_query($sql)) - { - $error = $this->db->sql_error($this->db->get_sql_error_sql()); - $this->iohandler->add_error_message('INST_ERR_DB', $error['message']); - } - } - - unset($sql_query); - } - - $change_prefix = false; - - // Generate database schema - if ($this->filesystem->exists($this->phpbb_root_path . 'install/schemas/schema.json')) - { - $db_table_schema = @file_get_contents($this->phpbb_root_path . 'install/schemas/schema.json'); - $db_table_schema = json_decode($db_table_schema, true); - $change_prefix = true; - } - else - { - global $table_prefix; - - $table_prefix = $this->config->get('table_prefix'); - - if (!defined('CONFIG_TABLE')) - { - // We need to include the constants file for the table constants - // when we generate the schema from the migration files. - include ($this->phpbb_root_path . 'includes/constants.' . $this->php_ext); - } - - $finder = new \phpbb\finder($this->filesystem, $this->phpbb_root_path, null, $this->php_ext); - $migrator_classes = $finder->core_path('phpbb/db/migration/data/')->get_classes(); - $factory = new \phpbb\db\tools\factory(); - $db_tools = $factory->get($this->db, true); - $schema_generator = new \phpbb\db\migration\schema_generator( - $migrator_classes, - new \phpbb\config\config(array()), - $this->db, - $db_tools, - $this->phpbb_root_path, - $this->php_ext, - $table_prefix - ); - $db_table_schema = $schema_generator->get_schema(); - } - - if (!defined('CONFIG_TABLE')) - { - // CONFIG_TABLE is required by sql_create_index() to check the - // length of index names. However table_prefix is not defined - // here yet, so we need to create the constant ourselves. - define('CONFIG_TABLE', $table_prefix . 'config'); - } - - foreach ($db_table_schema as $table_name => $table_data) - { - $this->db_tools->sql_create_table( - ( ($change_prefix) ? ($table_prefix . substr($table_name, 6)) : $table_name ), - $table_data - ); - } - } - - /** - * {@inheritdoc} - */ - static public function get_step_count() - { - return 1; - } - - /** - * {@inheritdoc} - */ - public function get_task_lang_name() - { - return 'TASK_CREATE_DATABASE_SCHEMA'; - } -} diff --git a/install/update/old/phpbb/install/module/install_database/task/set_up_database.php b/install/update/old/phpbb/install/module/install_database/task/set_up_database.php deleted file mode 100644 index 49c8ea2..0000000 --- a/install/update/old/phpbb/install/module/install_database/task/set_up_database.php +++ /dev/null @@ -1,164 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\install\module\install_database\task; - -/** - * Set up database for table generation - */ -class set_up_database extends \phpbb\install\task_base -{ - /** - * @var \phpbb\install\helper\config - */ - protected $config; - - /** - * @var \phpbb\db\driver\driver_interface - */ - protected $db; - - /** - * @var \phpbb\install\helper\database - */ - protected $database_helper; - - /** - * @var \phpbb\filesystem\filesystem_interface - */ - protected $filesystem; - - /** - * @var \phpbb\install\helper\iohandler\iohandler_interface - */ - protected $iohandler; - - /** - * @var string - */ - protected $schema_file_path; - - /** - * @var string - */ - protected $phpbb_root_path; - - /** - * Constructor - * - * @param \phpbb\install\helper\config $config - * @param \phpbb\install\helper\database $db_helper - * @param \phpbb\filesystem\filesystem_interface $filesystem - * @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler - * @param string $phpbb_root_path - */ - public function __construct(\phpbb\install\helper\config $config, - \phpbb\install\helper\database $db_helper, - \phpbb\filesystem\filesystem_interface $filesystem, - \phpbb\install\helper\iohandler\iohandler_interface $iohandler, - $phpbb_root_path) - { - $dbms = $db_helper->get_available_dbms($config->get('dbms')); - $dbms = $dbms[$config->get('dbms')]['DRIVER']; - - $this->db = new $dbms(); - $this->db->sql_connect( - $config->get('dbhost'), - $config->get('dbuser'), - $config->get('dbpasswd'), - $config->get('dbname'), - $config->get('dbport'), - false, - false - ); - - $this->config = $config; - $this->database_helper = $db_helper; - $this->filesystem = $filesystem; - $this->iohandler = $iohandler; - $this->phpbb_root_path = $phpbb_root_path; - - parent::__construct(false); - } - - /** - * {@inheritdoc} - */ - public function check_requirements() - { - $dbms = $this->config->get('dbms'); - $dbms_info = $this->database_helper->get_available_dbms($dbms); - $schema_name = $dbms_info[$dbms]['SCHEMA']; - - if ($dbms === 'mysql') - { - if (version_compare($this->db->sql_server_info(true), '4.1.3', '>=')) - { - $schema_name .= '_41'; - } - else - { - $schema_name .= '_40'; - } - } - - $this->schema_file_path = $this->phpbb_root_path . 'install/schemas/' . $schema_name . '_schema.sql'; - - return $this->filesystem->exists($this->schema_file_path); - } - - /** - * {@inheritdoc} - */ - public function run() - { - $this->db->sql_return_on_error(true); - - $dbms = $this->config->get('dbms'); - $dbms_info = $this->database_helper->get_available_dbms($dbms); - $delimiter = $dbms_info[$dbms]['DELIM']; - $table_prefix = $this->config->get('table_prefix'); - - $sql_query = @file_get_contents($this->schema_file_path); - $sql_query = preg_replace('#phpbb_#i', $table_prefix, $sql_query); - $sql_query = $this->database_helper->remove_comments($sql_query); - $sql_query = $this->database_helper->split_sql_file($sql_query, $delimiter); - - foreach ($sql_query as $sql) - { - if (!$this->db->sql_query($sql)) - { - $error = $this->db->sql_error($this->db->get_sql_error_sql()); - $this->iohandler->add_error_message('INST_ERR_DB', $error['message']); - } - } - - unset($sql_query); - } - - /** - * {@inheritdoc} - */ - static public function get_step_count() - { - return 1; - } - - /** - * {@inheritdoc} - */ - public function get_task_lang_name() - { - return 'TASK_SETUP_DATABASE'; - } -} diff --git a/install/update/old/phpbb/install/module/install_filesystem/task/create_config_file.php b/install/update/old/phpbb/install/module/install_filesystem/task/create_config_file.php deleted file mode 100644 index 5bc425b..0000000 --- a/install/update/old/phpbb/install/module/install_filesystem/task/create_config_file.php +++ /dev/null @@ -1,244 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\install\module\install_filesystem\task; - -use phpbb\install\exception\user_interaction_required_exception; - -/** - * Dumps config file - */ -class create_config_file extends \phpbb\install\task_base -{ - /** - * @var \phpbb\filesystem\filesystem_interface - */ - protected $filesystem; - - /** - * @var \phpbb\install\helper\database - */ - protected $db_helper; - - /** - * @var \phpbb\install\helper\config - */ - protected $install_config; - - /** - * @var \phpbb\install\helper\iohandler\iohandler_interface - */ - protected $iohandler; - - /** - * @var string - */ - protected $phpbb_root_path; - - /** - * @var string - */ - protected $php_ext; - - /** - * @var array - */ - protected $options; - - /** - * Constructor - * - * @param \phpbb\filesystem\filesystem_interface $filesystem - * @param \phpbb\install\helper\config $install_config - * @param \phpbb\install\helper\database $db_helper - * @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler - * @param string $phpbb_root_path - * @param string $php_ext - * @param array $options - */ - public function __construct(\phpbb\filesystem\filesystem_interface $filesystem, - \phpbb\install\helper\config $install_config, - \phpbb\install\helper\database $db_helper, - \phpbb\install\helper\iohandler\iohandler_interface $iohandler, - $phpbb_root_path, - $php_ext, - $options = array()) - { - $this->install_config = $install_config; - $this->db_helper = $db_helper; - $this->filesystem = $filesystem; - $this->iohandler = $iohandler; - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - $this->options = array_merge(array( - 'debug' => false, - 'debug_container' => false, - 'environment' => null, - ), $options); - - parent::__construct(true); - } - - /** - * {@inheritdoc} - */ - public function run() - { - $config_written = true; - - // Create config.php - $path_to_config = $this->phpbb_root_path . 'config.' . $this->php_ext; - - $fp = @fopen($path_to_config, 'w'); - if (!$fp) - { - $config_written = false; - } - - $config_content = $this->get_config_data($this->options['debug'], $this->options['debug_container'], $this->options['environment']); - - if (!@fwrite($fp, $config_content)) - { - $config_written = false; - } - - @fclose($fp); - - // chmod config.php to be only readable - if ($config_written) - { - try - { - $this->filesystem->phpbb_chmod($path_to_config, \phpbb\filesystem\filesystem_interface::CHMOD_READ); - } - catch (\phpbb\filesystem\exception\filesystem_exception $e) - { - // Do nothing, the user will get a notice later - } - } - else - { - $this->iohandler->add_error_message('UNABLE_TO_WRITE_CONFIG_FILE'); - throw new user_interaction_required_exception(); - } - - // Create a lock file to indicate that there is an install in progress - $fp = @fopen($this->phpbb_root_path . 'cache/install_lock', 'wb'); - if ($fp === false) - { - // We were unable to create the lock file - abort - $this->iohandler->add_error_message('UNABLE_TO_WRITE_LOCK'); - throw new user_interaction_required_exception(); - } - @fclose($fp); - - try - { - $this->filesystem->phpbb_chmod($this->phpbb_root_path . 'cache/install_lock', 0777); - } - catch (\phpbb\filesystem\exception\filesystem_exception $e) - { - // Do nothing, the user will get a notice later - } - } - - /** - * Returns the content which should be dumped to config.php - * - * @param bool $debug If the debug constants should be enabled by default or not - * @param bool $debug_container If the container should be compiled on - * every page load or not - * @param string $environment The environment to use - * - * @return string content to be written to the config file - */ - protected function get_config_data($debug = false, $debug_container = false, $environment = null) - { - $config_content = "install_config->get('dbms'); - $db_driver = $this->db_helper->get_available_dbms($dbms); - $db_driver = $db_driver[$dbms]['DRIVER']; - - $config_data_array = array( - 'dbms' => $db_driver, - 'dbhost' => $this->install_config->get('dbhost'), - 'dbport' => $this->install_config->get('dbport'), - 'dbname' => $this->install_config->get('dbname'), - 'dbuser' => $this->install_config->get('dbuser'), - 'dbpasswd' => $this->install_config->get('dbpasswd'), - 'table_prefix' => $this->install_config->get('table_prefix'), - - 'phpbb_adm_relative_path' => 'adm/', - - 'acm_type' => 'phpbb\cache\driver\file', - ); - - foreach ($config_data_array as $key => $value) - { - $config_content .= "\${$key} = '" . str_replace("'", "\\'", str_replace('\\', '\\\\', $value)) . "';\n"; - } - - $config_content .= "\n@define('PHPBB_INSTALLED', true);\n"; - $config_content .= "// @define('PHPBB_DISPLAY_LOAD_TIME', true);\n"; - - if ($environment) - { - $config_content .= "@define('PHPBB_ENVIRONMENT', 'test');\n"; - } - else if ($debug) - { - $config_content .= "@define('PHPBB_ENVIRONMENT', 'development');\n"; - } - else - { - $config_content .= "@define('PHPBB_ENVIRONMENT', 'production');\n"; - } - - if ($debug_container) - { - $config_content .= "@define('DEBUG_CONTAINER', true);\n"; - } - else - { - $config_content .= "// @define('DEBUG_CONTAINER', true);\n"; - } - - if ($environment === 'test') - { - $config_content .= "@define('DEBUG_TEST', true);\n"; - - // Mandatory for the functional tests, will be removed by PHPBB3-12623 - $config_content .= "@define('DEBUG', true);\n"; - } - - return $config_content; - } - - /** - * {@inheritdoc} - */ - static public function get_step_count() - { - return 1; - } - - /** - * {@inheritdoc} - */ - public function get_task_lang_name() - { - return 'TASK_CREATE_CONFIG_FILE'; - } -} diff --git a/install/update/old/phpbb/install/module/requirements/task/check_server_environment.php b/install/update/old/phpbb/install/module/requirements/task/check_server_environment.php deleted file mode 100644 index 29f9777..0000000 --- a/install/update/old/phpbb/install/module/requirements/task/check_server_environment.php +++ /dev/null @@ -1,209 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\install\module\requirements\task; - -/** - * Installer task that checks if the server meats phpBB requirements - */ -class check_server_environment extends \phpbb\install\task_base -{ - /** - * @var \phpbb\install\helper\database - */ - protected $database_helper; - - /** - * @var \phpbb\install\helper\iohandler\iohandler_interface - */ - protected $response_helper; - - /** - * @var bool - */ - protected $tests_passed; - - /** - * Constructor - * - * @param \phpbb\install\helper\database $database_helper - * @param \phpbb\install\helper\iohandler\iohandler_interface $response - */ - public function __construct(\phpbb\install\helper\database $database_helper, - \phpbb\install\helper\iohandler\iohandler_interface $response) - { - $this->database_helper = $database_helper; - $this->response_helper = $response; - $this->tests_passed = true; - - parent::__construct(true); - } - - /** - * {@inheritdoc} - */ - public function run() - { - // - // Check requirements - // The error messages should be set in the check_ functions - // - - // Check PHP version - $this->check_php_version(); - - // Check for getimagesize() - $this->check_image_size(); - - // Check for PCRE support - $this->check_pcre(); - - // Check for JSON support - $this->check_json(); - - // XML extension support check - $this->check_xml(); - - // Check for dbms support - $this->check_available_dbms(); - - return $this->tests_passed; - } - - /** - * Sets $this->tests_passed - * - * @param bool $is_passed - */ - protected function set_test_passed($is_passed) - { - // If one test failed, tests_passed should be false - $this->tests_passed = (!$this->tests_passed) ? false : $is_passed; - } - - /** - * Check if the requirements for PHP version is met - */ - protected function check_php_version() - { - $php_version = PHP_VERSION; - - if (version_compare($php_version, '5.4') < 0) - { - $this->response_helper->add_error_message('PHP_VERSION_REQD', 'PHP_VERSION_REQD_EXPLAIN'); - - $this->set_test_passed(false); - return; - } - - $this->set_test_passed(true); - } - - /** - * Checks if the installed PHP has getimagesize() available - */ - protected function check_image_size() - { - if (!@function_exists('getimagesize')) - { - $this->response_helper->add_error_message('PHP_GETIMAGESIZE_SUPPORT', 'PHP_GETIMAGESIZE_SUPPORT_EXPLAIN'); - - $this->set_test_passed(false); - return; - } - - $this->set_test_passed(true); - } - - /** - * Checks if the installed PHP supports PCRE - */ - protected function check_pcre() - { - if (@preg_match('//u', '')) - { - $this->set_test_passed(true); - return; - } - - $this->response_helper->add_error_message('PCRE_UTF_SUPPORT', 'PCRE_UTF_SUPPORT_EXPLAIN'); - - $this->set_test_passed(false); - } - - /** - * Checks whether PHP's JSON extension is available or not - */ - protected function check_json() - { - if (@extension_loaded('json')) - { - $this->set_test_passed(true); - return; - } - - $this->response_helper->add_error_message('PHP_JSON_SUPPORT', 'PHP_JSON_SUPPORT_EXPLAIN'); - - $this->set_test_passed(false); - } - - /** - * Checks whether or not the XML PHP extension is available (Required by the text formatter) - */ - protected function check_xml() - { - if (class_exists('DOMDocument')) - { - $this->set_test_passed(true); - return; - } - - $this->response_helper->add_error_message('PHP_XML_SUPPORT', 'PHP_XML_SUPPORT_EXPLAIN'); - - $this->set_test_passed(false); - } - - /** - * Check if any supported DBMS is available - */ - protected function check_available_dbms() - { - $available_dbms = $this->database_helper->get_available_dbms(false, true); - - if ($available_dbms['ANY_DB_SUPPORT']) - { - $this->set_test_passed(true); - return; - } - - $this->response_helper->add_error_message('PHP_SUPPORTED_DB', 'PHP_SUPPORTED_DB_EXPLAIN'); - - $this->set_test_passed(false); - } - - /** - * {@inheritdoc} - */ - static public function get_step_count() - { - return 0; - } - - /** - * {@inheritdoc} - */ - public function get_task_lang_name() - { - return ''; - } -} diff --git a/install/update/old/phpbb/install/module_base.php b/install/update/old/phpbb/install/module_base.php deleted file mode 100644 index 93c10bd..0000000 --- a/install/update/old/phpbb/install/module_base.php +++ /dev/null @@ -1,213 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\install; - -use phpbb\di\ordered_service_collection; -use phpbb\install\exception\resource_limit_reached_exception; -use phpbb\install\helper\config; -use phpbb\install\helper\iohandler\iohandler_interface; - -/** - * Base class for installer module - */ -abstract class module_base implements module_interface -{ - /** - * @var config - */ - protected $install_config; - - /** - * @var iohandler_interface - */ - protected $iohandler; - - /** - * @var bool - */ - protected $is_essential; - - /** - * Array of tasks for installer module - * - * @var ordered_service_collection - */ - protected $task_collection; - - /** - * @var array - */ - protected $task_step_count; - - /** - * @var bool - */ - protected $allow_progress_bar; - - /** - * Installer module constructor - * - * @param ordered_service_collection $tasks array of installer tasks for installer module - * @param bool $essential flag indicating whether the module is essential or not - * @param bool $allow_progress_bar flag indicating whether or not to send progress information from within the module - */ - public function __construct(ordered_service_collection $tasks, $essential = true, $allow_progress_bar = true) - { - $this->task_collection = $tasks; - $this->is_essential = $essential; - $this->allow_progress_bar = $allow_progress_bar; - } - - /** - * Dependency getter - * - * @param config $config - * @param iohandler_interface $iohandler - */ - public function setup(config $config, iohandler_interface $iohandler) - { - $this->install_config = $config; - $this->iohandler = $iohandler; - } - - /** - * {@inheritdoc} - */ - public function is_essential() - { - return $this->is_essential; - } - - /** - * {@inheritdoc} - * - * Overwrite this method if your task is non-essential! - */ - public function check_requirements() - { - return true; - } - - /** - * {@inheritdoc} - */ - public function run() - { - // Recover install progress - $task_index = $this->recover_progress(); - $iterator = $this->task_collection->getIterator(); - - if ($task_index < $iterator->count()) - { - $iterator->seek($task_index); - } - else - { - $this->install_config->set_finished_task(0); - return; - } - - while ($iterator->valid()) - { - $task = $iterator->current(); - $name = $iterator->key(); - - // Check if we can run the task - if (!$task->is_essential() && !$task->check_requirements()) - { - $this->iohandler->add_log_message(array( - 'SKIP_TASK', - $name, - )); - - $this->install_config->increment_current_task_progress($this->task_step_count[$name]); - } - else - { - // Send progress information - if ($this->allow_progress_bar) - { - $this->iohandler->set_progress( - $task->get_task_lang_name(), - $this->install_config->get_current_task_progress() - ); - - $this->iohandler->send_response(); - } - - $task->run(); - - if ($this->allow_progress_bar) - { - // Only increment progress by one, as if a task has more than one steps - // then that should be incremented in the task itself - $this->install_config->increment_current_task_progress(); - } - } - - $task_index++; - $this->install_config->set_finished_task($task_index); - $iterator->next(); - - // Send progress information - if ($this->allow_progress_bar) - { - $this->iohandler->set_progress( - $task->get_task_lang_name(), - $this->install_config->get_current_task_progress() - ); - } - - $this->iohandler->send_response(); - - // Stop execution if resource limit is reached - if ($iterator->valid() && ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0)) - { - throw new resource_limit_reached_exception(); - } - } - - // Module finished, so clear task progress - $this->install_config->set_finished_task(0); - } - - /** - * Returns the next task's name - * - * @return string Index of the array element of the next task - */ - protected function recover_progress() - { - $progress_array = $this->install_config->get_progress_data(); - return $progress_array['last_task_index']; - } - - /** - * {@inheritdoc} - */ - public function get_step_count() - { - $task_step_count = 0; - $task_class_names = $this->task_collection->get_service_classes(); - - foreach ($task_class_names as $name => $task_class) - { - $step_count = $task_class::get_step_count(); - $task_step_count += $step_count; - $this->task_step_count[$name] = $step_count; - } - - return $task_step_count; - } -} diff --git a/install/update/old/phpbb/language/language_file_loader.php b/install/update/old/phpbb/language/language_file_loader.php deleted file mode 100644 index b6816af..0000000 --- a/install/update/old/phpbb/language/language_file_loader.php +++ /dev/null @@ -1,206 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\language; - -use \phpbb\language\exception\language_file_not_found; - -/** - * Language file loader - */ -class language_file_loader -{ - /** - * @var string Path to phpBB's root - */ - protected $phpbb_root_path; - - /** - * @var string Extension of PHP files - */ - protected $php_ext; - - /** - * @var \phpbb\extension\manager Extension manager - */ - protected $extension_manager; - - /** - * Constructor - * - * @param string $phpbb_root_path Path to phpBB's root - * @param string $php_ext Extension of PHP files - */ - public function __construct($phpbb_root_path, $php_ext) - { - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - - $this->extension_manager = null; - } - - /** - * Extension manager setter - * - * @param \phpbb\extension\manager $extension_manager Extension manager - */ - public function set_extension_manager(\phpbb\extension\manager $extension_manager) - { - $this->extension_manager = $extension_manager; - } - - /** - * Loads language array for the given component - * - * @param string $component Name of the language component - * @param string|array $locale ISO code of the language to load, or array of ISO codes if you want to - * specify additional language fallback steps - * @param array $lang Array reference containing language strings - */ - public function load($component, $locale, &$lang) - { - $locale = (array) $locale; - - // Determine path to language directory - $path = $this->phpbb_root_path . 'language/'; - - $this->load_file($path, $component, $locale, $lang); - } - - /** - * Loads language array for the given extension component - * - * @param string $extension Name of the extension - * @param string $component Name of the language component - * @param string|array $locale ISO code of the language to load, or array of ISO codes if you want to - * specify additional language fallback steps - * @param array $lang Array reference containing language strings - */ - public function load_extension($extension, $component, $locale, &$lang) - { - // Check if extension manager was loaded - if ($this->extension_manager === null) - { - // If not, let's return - return; - } - - $locale = (array) $locale; - - // Determine path to language directory - $path = $this->extension_manager->get_extension_path($extension, true) . 'language/'; - - $this->load_file($path, $component, $locale, $lang); - } - - /** - * Prepares language file loading - * - * @param string $path Path to search for file in - * @param string $component Name of the language component - * @param array $locale Array containing language fallback options - * @param array $lang Array reference of language strings - */ - protected function load_file($path, $component, $locale, &$lang) - { - // This is BC stuff and not the best idea as it makes language fallback - // implementation quite hard like below. - if (strpos($this->phpbb_root_path . $component, $path) === 0) - { - // Filter out the path - $path_diff = str_replace($path, '', dirname($this->phpbb_root_path . $component)); - $language_file = basename($component, '.' . $this->php_ext); - $component = ''; - - // This step is needed to resolve language/en/subdir style $component - // $path already points to the language base directory so we need to eliminate - // the first directory from the path (that should be the language directory) - $path_diff_parts = explode('/', $path_diff); - - if (count($path_diff_parts) > 1) - { - array_shift($path_diff_parts); - $component = implode('/', $path_diff_parts) . '/'; - } - - $component .= $language_file; - } - - // Determine filename - $filename = $component . '.' . $this->php_ext; - - // Determine path to file - $file_path = $this->get_language_file_path($path, $filename, $locale); - - // Load language array - $this->load_language_file($file_path, $lang); - } - - /** - * This function implements language fallback logic - * - * @param string $path Path to language directory - * @param string $filename Filename to load language strings from - * - * @return string Relative path to language file - * - * @throws language_file_not_found When the path to the file cannot be resolved - */ - protected function get_language_file_path($path, $filename, $locales) - { - $language_file_path = $filename; - - // Language fallback logic - foreach ($locales as $locale) - { - $language_file_path = $path . $locale . '/' . $filename; - - // If we are in install, try to use the updated version, when available - if (defined('IN_INSTALL')) - { - $install_language_path = str_replace('language/', 'install/update/new/language/', $language_file_path); - if (file_exists($install_language_path)) - { - return $install_language_path; - } - } - - if (file_exists($language_file_path)) - { - return $language_file_path; - } - } - - // The language file is not exist - throw new language_file_not_found('Language file ' . $language_file_path . ' couldn\'t be opened.'); - } - - /** - * Loads language file - * - * @param string $path Path to language file to load - * @param array $lang Reference of the array of language strings - */ - protected function load_language_file($path, &$lang) - { - // Do not suppress error if in DEBUG mode - if (defined('DEBUG')) - { - include $path; - } - else - { - @include $path; - } - } -} diff --git a/install/update/old/phpbb/lock/db.php b/install/update/old/phpbb/lock/db.php deleted file mode 100644 index 85ba9a7..0000000 --- a/install/update/old/phpbb/lock/db.php +++ /dev/null @@ -1,146 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\lock; - -/** -* Database locking class -*/ -class db -{ - /** - * Name of the config variable this lock uses - * @var string - */ - private $config_name; - - /** - * Unique identifier for this lock. - * - * @var string - */ - private $unique_id; - - /** - * Stores the state of this lock - * @var bool - */ - private $locked; - - /** - * The phpBB configuration - * @var \phpbb\config\config - */ - private $config; - - /** - * A database connection - * @var \phpbb\db\driver\driver_interface - */ - private $db; - - /** - * Creates a named released instance of the lock. - * - * You have to call acquire() to actually create the lock. - * - * @param string $config_name A config variable to be used for locking - * @param \phpbb\config\config $config The phpBB configuration - * @param \phpbb\db\driver\driver_interface $db A database connection - */ - public function __construct($config_name, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db) - { - $this->config_name = $config_name; - $this->config = $config; - $this->db = $db; - } - - /** - * Tries to acquire the lock by updating - * the configuration variable in the database. - * - * As a lock may only be held by one process at a time, lock - * acquisition may fail if another process is holding the lock - * or if another process obtained the lock but never released it. - * Locks are forcibly released after a timeout of 1 hour. - * - * @return bool true if lock was acquired - * false otherwise - */ - public function acquire() - { - if ($this->locked) - { - return false; - } - - if (!isset($this->config[$this->config_name])) - { - $this->config->set($this->config_name, '0', false); - } - $lock_value = $this->config[$this->config_name]; - - // make sure lock cannot be acquired by multiple processes - if ($lock_value) - { - // if the other process is running more than an hour already we have to assume it - // aborted without cleaning the lock - $time = explode(' ', $lock_value); - $time = $time[0]; - - if ($time + 3600 >= time()) - { - return false; - } - } - - $this->unique_id = time() . ' ' . unique_id(); - - // try to update the config value, if it was already modified by another - // process we failed to acquire the lock. - $this->locked = $this->config->set_atomic($this->config_name, $lock_value, $this->unique_id, false); - - return $this->locked; - } - - /** - * Does this process own the lock? - * - * @return bool true if lock is owned - * false otherwise - */ - public function owns_lock() - { - return (bool) $this->locked; - } - - /** - * Releases the lock. - * - * The lock must have been previously obtained, that is, acquire() call - * was issued and returned true. - * - * Note: Attempting to release a lock that is already released, - * that is, calling release() multiple times, is harmless. - * - * @return null - */ - public function release() - { - if ($this->locked) - { - $this->config->set_atomic($this->config_name, $this->unique_id, '0', false); - $this->locked = false; - } - } -} diff --git a/install/update/old/phpbb/lock/flock.php b/install/update/old/phpbb/lock/flock.php deleted file mode 100644 index df88e14..0000000 --- a/install/update/old/phpbb/lock/flock.php +++ /dev/null @@ -1,141 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\lock; - -/** -* File locking class -*/ -class flock -{ - /** - * Path to the file to which access is controlled - * - * @var string - */ - private $path; - - /** - * File pointer for the lock file - * @var string - */ - private $lock_fp; - - /** - * Constructor. - * - * You have to call acquire() to actually acquire the lock. - * - * @param string $path Path to the file to which access is controlled - */ - public function __construct($path) - { - $this->path = $path; - $this->lock_fp = null; - } - - /** - * Tries to acquire the lock. - * - * If the lock is already held by another process, this call will block - * until the other process releases the lock. If a lock is acquired and - * is not released before script finishes but the process continues to - * live (apache/fastcgi) then subsequent processes trying to acquire - * the same lock will be blocked forever. - * - * If the lock is already held by the same process via another instance - * of this class, this call will block forever. - * - * If flock function is disabled in php or fails to work, lock - * acquisition will fail and false will be returned. - * - * @return bool true if lock was acquired - * false otherwise - */ - public function acquire() - { - if ($this->lock_fp) - { - return false; - } - - // For systems that can't have two processes opening - // one file for writing simultaneously - if (file_exists($this->path . '.lock')) - { - $mode = 'rb'; - } - else - { - $mode = 'wb'; - } - - $this->lock_fp = @fopen($this->path . '.lock', $mode); - - if ($mode == 'wb') - { - if (!$this->lock_fp) - { - // Two processes may attempt to create lock file at the same time. - // Have the losing process try opening the lock file again for reading - // on the assumption that the winning process created it - $mode = 'rb'; - $this->lock_fp = @fopen($this->path . '.lock', $mode); - } - else - { - // Only need to set mode when the lock file is written - @chmod($this->path . '.lock', 0666); - } - } - - if ($this->lock_fp) - { - @flock($this->lock_fp, LOCK_EX); - } - - return (bool) $this->lock_fp; - } - - /** - * Does this process own the lock? - * - * @return bool true if lock is owned - * false otherwise - */ - public function owns_lock() - { - return (bool) $this->lock_fp; - } - - /** - * Releases the lock. - * - * The lock must have been previously obtained, that is, acquire() call - * was issued and returned true. - * - * Note: Attempting to release a lock that is already released, - * that is, calling release() multiple times, is harmless. - * - * @return null - */ - public function release() - { - if ($this->lock_fp) - { - @flock($this->lock_fp, LOCK_UN); - fclose($this->lock_fp); - $this->lock_fp = null; - } - } -} diff --git a/install/update/old/phpbb/message/form.php b/install/update/old/phpbb/message/form.php deleted file mode 100644 index 63bada9..0000000 --- a/install/update/old/phpbb/message/form.php +++ /dev/null @@ -1,175 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\message; - -/** -* Abstract class form -*/ -abstract class form -{ - /** @var \phpbb\auth\auth */ - protected $auth; - /** @var \phpbb\config\config */ - protected $config; - /** @var \phpbb\db\driver\driver_interface */ - protected $db; - /** @var \phpbb\message\message */ - protected $message; - /** @var \phpbb\user */ - protected $user; - - /** @var string */ - protected $phpbb_root_path; - /** @var string */ - protected $phpEx; - - /** @var array */ - protected $errors = array(); - /** @var bool */ - protected $cc_sender; - /** @var string */ - protected $body; - - /** - * Construct - * - * @param \phpbb\auth\auth $auth - * @param \phpbb\config\config $config - * @param \phpbb\db\driver\driver_interface $db - * @param \phpbb\user $user - * @param string $phpbb_root_path - * @param string $phpEx - */ - public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\user $user, $phpbb_root_path, $phpEx) - { - $this->phpbb_root_path = $phpbb_root_path; - $this->phpEx = $phpEx; - $this->user = $user; - $this->auth = $auth; - $this->config = $config; - $this->db = $db; - - $this->message = new message($config['server_name']); - $this->message->set_sender_from_user($this->user); - } - - /** - * Returns the title for the email form page - * - * @return string - */ - public function get_page_title() - { - return $this->user->lang['SEND_EMAIL']; - } - - /** - * Returns the file name of the form template - * - * @return string - */ - public function get_template_file() - { - return 'memberlist_email.html'; - } - - /** - * Checks whether the user is allowed to use the form - * - * @return false|string Error string if not allowed, false otherwise - */ - public function check_allow() - { - if (!$this->config['email_enable']) - { - return 'EMAIL_DISABLED'; - } - - if (time() - $this->user->data['user_emailtime'] < $this->config['flood_interval']) - { - return 'FLOOD_EMAIL_LIMIT'; - } - - return false; - } - - /** - * Get the return link after the message has been sent - * - * @return string - */ - public function get_return_message() - { - return sprintf($this->user->lang['RETURN_INDEX'], '', ''); - } - - /** - * Bind the values of the request to the form - * - * @param \phpbb\request\request_interface $request - * @return null - */ - public function bind(\phpbb\request\request_interface $request) - { - $this->cc_sender = $request->is_set_post('cc_sender'); - $this->body = $request->variable('message', '', true); - } - - /** - * Submit form, generate the email and send it - * - * @param \messenger $messenger - * @return null - */ - public function submit(\messenger $messenger) - { - if (!check_form_key('memberlist_email')) - { - $this->errors[] = 'FORM_INVALID'; - } - - if (!count($this->errors)) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_emailtime = ' . time() . ' - WHERE user_id = ' . $this->user->data['user_id']; - $this->db->sql_query($sql); - - if ($this->cc_sender && $this->user->data['is_registered']) - { - $this->message->cc_sender(); - } - - $this->message->send($messenger, phpbb_get_board_contact($this->config, $this->phpEx)); - - meta_refresh(3, append_sid($this->phpbb_root_path . 'index.' . $this->phpEx)); - trigger_error($this->user->lang['EMAIL_SENT'] . '

' . $this->get_return_message()); - } - } - - /** - * Render the template of the form - * - * @param \phpbb\template\template $template - * @return null - */ - public function render(\phpbb\template\template $template) - { - add_form_key('memberlist_email'); - - $template->assign_vars(array( - 'ERROR_MESSAGE' => (count($this->errors)) ? implode('
', $this->errors) : '', - )); - } -} diff --git a/install/update/old/phpbb/mimetype/guesser.php b/install/update/old/phpbb/mimetype/guesser.php deleted file mode 100644 index 8baa770..0000000 --- a/install/update/old/phpbb/mimetype/guesser.php +++ /dev/null @@ -1,156 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\mimetype; - -class guesser -{ - /** - * @const Default priority for mimetype guessers - */ - const PRIORITY_DEFAULT = 0; - - /** - * @var array guessers - */ - protected $guessers; - - /** - * Construct a mimetype guesser object - * - * @param array $mimetype_guessers Mimetype guesser service collection - */ - public function __construct($mimetype_guessers) - { - $this->register_guessers($mimetype_guessers); - } - - /** - * Register MimeTypeGuessers and sort them by priority - * - * @param array $mimetype_guessers Mimetype guesser service collection - * - * @throws \LogicException If incorrect or not mimetype guessers have - * been supplied to class - */ - protected function register_guessers($mimetype_guessers) - { - foreach ($mimetype_guessers as $guesser) - { - $is_supported = (method_exists($guesser, 'is_supported')) ? 'is_supported' : ''; - $is_supported = (method_exists($guesser, 'isSupported')) ? 'isSupported' : $is_supported; - - if (empty($is_supported)) - { - throw new \LogicException('Incorrect mimetype guesser supplied.'); - } - - if ($guesser->$is_supported()) - { - $this->guessers[] = $guesser; - } - } - - if (empty($this->guessers)) - { - throw new \LogicException('No mimetype guesser supplied.'); - } - - // Sort guessers by priority - usort($this->guessers, array($this, 'sort_priority')); - } - - /** - * Sort the priority of supplied guessers - * This is a compare function for usort. A guesser with higher priority - * should be used first and vice versa. usort() orders the array values - * from low to high depending on what the comparison function returns - * to it. Return value should be smaller than 0 if value a is smaller - * than value b. This has been reversed in the comparision function in - * order to sort the guessers from high to low. - * Method has been set to public in order to allow proper testing. - * - * @param object $guesser_a Mimetype guesser a - * @param object $guesser_b Mimetype guesser b - * - * @return int If both guessers have the same priority 0, bigger - * than 0 if first guesser has lower priority, and lower - * than 0 if first guesser has higher priority - */ - public function sort_priority($guesser_a, $guesser_b) - { - $priority_a = (int) (method_exists($guesser_a, 'get_priority')) ? $guesser_a->get_priority() : self::PRIORITY_DEFAULT; - $priority_b = (int) (method_exists($guesser_b, 'get_priority')) ? $guesser_b->get_priority() : self::PRIORITY_DEFAULT; - - return $priority_b - $priority_a; - } - - /** - * Guess mimetype of supplied file - * - * @param string $file Path to file - * @param string $file_name The real file name - * - * @return string Guess for mimetype of file - */ - public function guess($file, $file_name = '') - { - if (!is_file($file)) - { - return false; - } - - if (!is_readable($file)) - { - return false; - } - - $mimetype = 'application/octet-stream'; - - foreach ($this->guessers as $guesser) - { - $mimetype_guess = $guesser->guess($file, $file_name); - - $mimetype = $this->choose_mime_type($mimetype, $mimetype_guess); - } - // Return any mimetype if we got a result or the fallback value - return $mimetype; - } - - /** - * Choose the best mime type based on the current mime type and the guess - * If a guesser returns nulls or application/octet-stream, we will keep - * the current guess. Guesses with a slash inside them will be favored over - * already existing ones. However, any guess that will pass the first check - * will always overwrite the default application/octet-stream. - * - * @param string $mime_type The current mime type - * @param string $guess The current mime type guess - * - * @return string The best mime type based on current mime type and guess - */ - public function choose_mime_type($mime_type, $guess) - { - if ($guess === null || $guess == 'application/octet-stream') - { - return $mime_type; - } - - if ($mime_type == 'application/octet-stream' || strpos($guess, '/') !== false) - { - $mime_type = $guess; - } - - return $mime_type; - } -} diff --git a/install/update/old/phpbb/notification/type/approve_post.php b/install/update/old/phpbb/notification/type/approve_post.php deleted file mode 100644 index e4b111e..0000000 --- a/install/update/old/phpbb/notification/type/approve_post.php +++ /dev/null @@ -1,149 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\notification\type; - -/** -* Post approved notifications class -* This class handles notifications for posts when they are approved (to their authors) -*/ - -class approve_post extends \phpbb\notification\type\post -{ - /** - * Get notification type name - * - * @return string - */ - public function get_type() - { - return 'notification.type.approve_post'; - } - - /** - * Language key used to output the text - * - * @var string - */ - protected $language_key = 'NOTIFICATION_POST_APPROVED'; - - /** - * Inherit notification read status from post. - * - * @var bool - */ - protected $inherit_read_status = false; - - /** - * Notification option data (for outputting to the user) - * - * @var bool|array False if the service should use it's default data - * Array of data (including keys 'id', 'lang', and 'group') - */ - static public $notification_option = array( - 'id' => 'moderation_queue', - 'lang' => 'NOTIFICATION_TYPE_MODERATION_QUEUE', - 'group' => 'NOTIFICATION_GROUP_POSTING', - ); - - /** - * Is available - */ - public function is_available() - { - return !$this->auth->acl_get('m_approve'); - } - - /** - * Find the users who want to receive notifications - * - * @param array $post Data from submit_post - * @param array $options Options for finding users for notification - * - * @return array - */ - public function find_users_for_notification($post, $options = array()) - { - $options = array_merge(array( - 'ignore_users' => array(), - ), $options); - - $users = array(); - $users[$post['poster_id']] = $this->notification_manager->get_default_methods(); - - return $this->get_authorised_recipients(array_keys($users), $post['forum_id'], array_merge($options, array( - 'item_type' => static::$notification_option['id'], - ))); - } - - /** - * Pre create insert array function - * This allows you to perform certain actions, like run a query - * and load data, before create_insert_array() is run. The data - * returned from this function will be sent to create_insert_array(). - * - * @param array $post Post data from submit_post - * @param array $notify_users Notify users list - * Formated from find_users_for_notification() - * @return array Whatever you want to send to create_insert_array(). - */ - public function pre_create_insert_array($post, $notify_users) - { - // In the parent class, this is used to check if the post is already - // read by a user and marks the notification read if it was marked read. - // Returning an empty array in effect, forces it to be marked as unread - // (and also saves a query) - return array(); - } - - /** - * {@inheritdoc} - */ - public function create_insert_array($post, $pre_create_data = array()) - { - $this->set_data('post_subject', $post['post_subject']); - - parent::create_insert_array($post, $pre_create_data); - - $this->notification_time = time(); - } - - /** - * {@inheritdoc} - */ - public function get_insert_array() - { - $data = parent::get_insert_array(); - $data['notification_time'] = $this->notification_time; - - return $data; - } - - /** - * Get email template - * - * @return string|bool - */ - public function get_email_template() - { - return 'post_approved'; - } - - /** - * {inheritDoc} - */ - public function get_redirect_url() - { - return $this->get_url(); - } -} diff --git a/install/update/old/phpbb/notification/type/approve_topic.php b/install/update/old/phpbb/notification/type/approve_topic.php deleted file mode 100644 index f8a3fde..0000000 --- a/install/update/old/phpbb/notification/type/approve_topic.php +++ /dev/null @@ -1,140 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\notification\type; - -/** -* Topic approved notifications class -* This class handles notifications for topics when they are approved (for authors) -*/ - -class approve_topic extends \phpbb\notification\type\topic -{ - /** - * Get notification type name - * - * @return string - */ - public function get_type() - { - return 'notification.type.approve_topic'; - } - - /** - * Language key used to output the text - * - * @var string - */ - protected $language_key = 'NOTIFICATION_TOPIC_APPROVED'; - - /** - * Inherit notification read status from topic. - * - * @var bool - */ - protected $inherit_read_status = false; - - /** - * Notification option data (for outputting to the user) - * - * @var bool|array False if the service should use it's default data - * Array of data (including keys 'id', 'lang', and 'group') - */ - static public $notification_option = array( - 'id' => 'moderation_queue', - 'lang' => 'NOTIFICATION_TYPE_MODERATION_QUEUE', - 'group' => 'NOTIFICATION_GROUP_POSTING', - ); - - /** - * Is available - */ - public function is_available() - { - return !$this->auth->acl_get('m_approve'); - } - - /** - * Find the users who want to receive notifications - * - * @param array $post Data from submit_post - * @param array $options Options for finding users for notification - * - * @return array - */ - public function find_users_for_notification($post, $options = array()) - { - $options = array_merge(array( - 'ignore_users' => array(), - ), $options); - - $users = array(); - $users[$post['poster_id']] = $this->notification_manager->get_default_methods(); - - return $this->get_authorised_recipients(array_keys($users), $post['forum_id'], array_merge($options, array( - 'item_type' => static::$notification_option['id'], - ))); - } - - /** - * Pre create insert array function - * This allows you to perform certain actions, like run a query - * and load data, before create_insert_array() is run. The data - * returned from this function will be sent to create_insert_array(). - * - * @param array $post Post data from submit_post - * @param array $notify_users Notify users list - * Formated from find_users_for_notification() - * @return array Whatever you want to send to create_insert_array(). - */ - public function pre_create_insert_array($post, $notify_users) - { - // In the parent class, this is used to check if the post is already - // read by a user and marks the notification read if it was marked read. - // Returning an empty array in effect, forces it to be marked as unread - // (and also saves a query) - return array(); - } - - /** - * {@inheritdoc} - */ - public function create_insert_array($post, $pre_create_data = array()) - { - - parent::create_insert_array($post, $pre_create_data); - - $this->notification_time = time(); - } - - /** - * {@inheritdoc} - */ - public function get_insert_array() - { - $data = parent::get_insert_array(); - $data['notification_time'] = $this->notification_time; - - return $data; - } - - /** - * Get email template - * - * @return string|bool - */ - public function get_email_template() - { - return 'topic_approved'; - } -} diff --git a/install/update/old/phpbb/notification/type/base.php b/install/update/old/phpbb/notification/type/base.php deleted file mode 100644 index 77ed7f2..0000000 --- a/install/update/old/phpbb/notification/type/base.php +++ /dev/null @@ -1,577 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\notification\type; - -/** -* Base notifications class -*/ -abstract class base implements \phpbb\notification\type\type_interface -{ - /** @var \phpbb\notification\manager */ - protected $notification_manager; - - /** @var \phpbb\db\driver\driver_interface */ - protected $db; - - /** @var \phpbb\language\language */ - protected $language; - - /** @var \phpbb\user */ - protected $user; - - /** @var \phpbb\auth\auth */ - protected $auth; - - /** @var string */ - protected $phpbb_root_path; - - /** @var string */ - protected $php_ext; - - /** @var string */ - protected $user_notifications_table; - - /** - * Notification option data (for outputting to the user) - * - * @var bool|array False if the service should use its default data - * Array of data (including keys 'id', 'lang', and 'group') - */ - static public $notification_option = false; - - /** - * The notification_type_id, set upon creation of the class - * This is the notification_type_id from the notification_types table - * - * @var int - */ - protected $notification_type_id; - - /** - * Identification data - * notification_type_id - ID of the item type (auto generated, from notification types table) - * item_id - ID of the item (e.g. post_id, msg_id) - * item_parent_id - Parent item id (ex: for topic => forum_id, for post => topic_id, etc) - * user_id - * notification_read - * notification_time - * notification_data (special serialized field that each notification type can use to store stuff) - * - * @var array $data Notification row from the database - * This must be private, all interaction should use __get(), __set(), get_data(), set_data() - */ - private $data = array(); - - /** - * Notification Type Base Constructor - * - * @param \phpbb\db\driver\driver_interface $db - * @param \phpbb\language\language $language - * @param \phpbb\user $user - * @param \phpbb\auth\auth $auth - * @param string $phpbb_root_path - * @param string $php_ext - * @param string $user_notifications_table - */ - public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\language\language $language, \phpbb\user $user, \phpbb\auth\auth $auth, $phpbb_root_path, $php_ext, $user_notifications_table) - { - $this->db = $db; - $this->language = $language; - $this->user = $user; - $this->auth = $auth; - - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - - $this->user_notifications_table = $user_notifications_table; - } - - /** - * Set notification manager (required) - * - * @param \phpbb\notification\manager $notification_manager - */ - public function set_notification_manager(\phpbb\notification\manager $notification_manager) - { - $this->notification_manager = $notification_manager; - - $this->notification_type_id = $this->notification_manager->get_notification_type_id($this->get_type()); - } - - /** - * Set initial data from the database - * - * @param array $data Row directly from the database - */ - public function set_initial_data($data = array()) - { - // The row from the database (unless this is a new notification we're going to add) - $this->data = $data; - $this->data['notification_data'] = (isset($this->data['notification_data'])) ? unserialize($this->data['notification_data']) : array(); - } - - /** - * Magic method to get data from this notification - * - * @param mixed $name - * @return mixed - */ - public function __get($name) - { - return (!isset($this->data[$name])) ? null : $this->data[$name]; - } - - - /** - * Magic method to set data on this notification - * - * @param mixed $name - * @param mixed $value - * - * @return null - */ - public function __set($name, $value) - { - $this->data[$name] = $value; - } - - - /** - * Magic method to get a string of this notification - * - * Primarily for testing - * - * @return mixed - */ - public function __toString() - { - return (!empty($this->data)) ? var_export($this->data, true) : $this->get_type(); - } - - /** - * Get special data (only important for the classes that extend this) - * - * @param string $name Name of the variable to get - * @return mixed - */ - protected function get_data($name) - { - return ($name === false) ? $this->data['notification_data'] : ((isset($this->data['notification_data'][$name])) ? $this->data['notification_data'][$name] : null); - } - - /** - * Set special data (only important for the classes that extend this) - * - * @param string $name Name of the variable to set - * @param mixed $value Value to set to the variable - * @return mixed - */ - protected function set_data($name, $value) - { - $this->data['notification_data'][$name] = $value; - } - - /** - * {@inheritdoc} - */ - public function create_insert_array($type_data, $pre_create_data = array()) - { - // Defaults - $this->data = array_merge(array( - 'item_id' => static::get_item_id($type_data), - 'notification_type_id' => $this->notification_type_id, - 'item_parent_id' => static::get_item_parent_id($type_data), - - 'notification_time' => time(), - 'notification_read' => false, - - 'notification_data' => array(), - ), $this->data); - } - - /** - * {@inheritdoc} - */ - public function get_insert_array() - { - $data = $this->data; - - $data['notification_data'] = serialize($data['notification_data']); - - return $data; - } - - /** - * Function for preparing the data for update in an SQL query - * (The service handles insertion) - * - * @param array $type_data Data unique to this notification type - * @return array Array of data ready to be updated in the database - */ - public function create_update_array($type_data) - { - $this->create_insert_array($type_data); - $data = $this->get_insert_array(); - - // Unset data unique to each row - unset( - $data['notification_time'], // Also unsetting time, since it always tries to change the time to current (if you actually need to change the time, over-ride this function) - $data['notification_id'], - $data['notification_read'], - $data['user_id'] - ); - - return $data; - } - - /** - * Mark this item read - * - * @param bool $return True to return a string containing the SQL code to update this item, False to execute it (Default: False) - * @return string|null If $return is False, nothing will be returned, else the sql code to update this item - */ - public function mark_read($return = false) - { - return $this->mark(false, $return); - } - - /** - * Mark this item unread - * - * @param bool $return True to return a string containing the SQL code to update this item, False to execute it (Default: False) - * @return string|null If $return is False, nothing will be returned, else the sql code to update this item - */ - public function mark_unread($return = false) - { - return $this->mark(true, $return); - } - - /** - * {inheritDoc} - */ - public function get_redirect_url() - { - return $this->get_url(); - } - - /** - * Prepare to output the notification to the template - * - * @return array Template variables - */ - public function prepare_for_display() - { - $mark_hash = generate_link_hash('mark_notification_read'); - - if ($this->get_url()) - { - $u_mark_read = append_sid($this->phpbb_root_path . 'index.' . $this->php_ext, 'mark_notification=' . $this->notification_id . '&hash=' . $mark_hash); - } - else - { - $redirect = (($this->user->page['page_dir']) ? $this->user->page['page_dir'] . '/' : '') . $this->user->page['page_name'] . (($this->user->page['query_string']) ? '?' . $this->user->page['query_string'] : ''); - - $u_mark_read = append_sid($this->phpbb_root_path . 'index.' . $this->php_ext, 'mark_notification=' . $this->notification_id . '&hash=' . $mark_hash . '&redirect=' . urlencode($redirect)); - } - - return array( - 'NOTIFICATION_ID' => $this->notification_id, - 'STYLING' => $this->get_style_class(), - 'AVATAR' => $this->get_avatar(), - 'FORMATTED_TITLE' => $this->get_title(), - 'REFERENCE' => $this->get_reference(), - 'FORUM' => $this->get_forum(), - 'REASON' => $this->get_reason(), - 'URL' => $this->get_url(), - 'TIME' => $this->user->format_date($this->notification_time), - 'UNREAD' => !$this->notification_read, - 'U_MARK_READ' => (!$this->notification_read) ? $u_mark_read : '', - ); - } - - /** - * -------------- Fall back functions ------------------- - */ - - /** - * URL to unsubscribe to this notification (fall back) - * - * @param string|bool $method Method name to unsubscribe from (email|jabber|etc), False to unsubscribe from all notifications for this item - * @return false - */ - public function get_unsubscribe_url($method = false) - { - return false; - } - - /** - * Get the CSS style class of the notification (fall back) - * - * @return string - */ - public function get_style_class() - { - return ''; - } - - /** - * Get the user's avatar (fall back) - * - * @return string - */ - public function get_avatar() - { - return ''; - } - - /** - * Get the reference of the notifcation (fall back) - * - * @return string - */ - public function get_reference() - { - return ''; - } - - /** - * Get the forum of the notification reference (fall back) - * - * @return string - */ - public function get_forum() - { - return ''; - } - - /** - * Get the reason for the notifcation (fall back) - * - * @return string - */ - public function get_reason() - { - return ''; - } - - /** - * Get the special items to load (fall back) - * - * @return array - */ - public function get_load_special() - { - return array(); - } - - /** - * Load the special items (fall back) - * - * @param array $data - * @param array $notifications - */ - public function load_special($data, $notifications) - { - return; - } - - /** - * Is available (fall back) - * - * @return bool - */ - public function is_available() - { - return true; - } - - /** - * Pre create insert array function (fall back) - * - * @param array $type_data - * @param array $notify_users - * @return array - */ - public function pre_create_insert_array($type_data, $notify_users) - { - return array(); - } - - /** - * -------------- Helper functions ------------------- - */ - - /** - * Find the users who want to receive notifications (helper) - * - * @param array|bool $user_ids User IDs to check if they want to receive notifications - * (Bool False to check all users besides anonymous and bots (USER_IGNORE)) - * @param array $options - * @return array - */ - protected function check_user_notification_options($user_ids = false, $options = array()) - { - $options = array_merge(array( - 'ignore_users' => array(), - 'item_type' => $this->get_type(), - 'item_id' => 0, // Global by default - ), $options); - - if ($user_ids === false) - { - $user_ids = array(); - - $sql = 'SELECT user_id - FROM ' . USERS_TABLE . ' - WHERE user_id <> ' . ANONYMOUS . ' - AND user_type <> ' . USER_IGNORE; - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - $user_ids[] = $row['user_id']; - } - $this->db->sql_freeresult($result); - } - - if (empty($user_ids)) - { - return array(); - } - - $rowset = $output = array(); - - $sql = 'SELECT user_id, method, notify - FROM ' . $this->user_notifications_table . ' - WHERE ' . $this->db->sql_in_set('user_id', $user_ids) . " - AND item_type = '" . $this->db->sql_escape($options['item_type']) . "' - AND item_id = " . (int) $options['item_id']; - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - if (isset($options['ignore_users'][$row['user_id']]) && in_array($row['method'], $options['ignore_users'][$row['user_id']])) - { - continue; - } - - if (!isset($rowset[$row['user_id']])) - { - $rowset[$row['user_id']] = array(); - } - $rowset[$row['user_id']][$row['method']] = $row['notify']; - - if (!isset($output[$row['user_id']])) - { - $output[$row['user_id']] = array(); - } - if ($row['notify']) - { - $output[$row['user_id']][] = $row['method']; - } - } - - $this->db->sql_freeresult($result); - - $default_methods = $this->notification_manager->get_default_methods(); - - foreach ($user_ids as $user_id) - { - if (isset($options['ignore_users'][$user_id])) - { - continue; - } - if (!array_key_exists($user_id, $rowset)) - { - // No rows at all for this user, use the default methods - $output[$user_id] = $default_methods; - } - else - { - foreach ($default_methods as $default_method) - { - if (!array_key_exists($default_method, $rowset[$user_id])) - { - // No user preference for this type recorded, but it should be enabled by default. - $output[$user_id][] = $default_method; - } - } - } - } - - return $output; - } - - /** - * Mark this item read/unread helper - * - * @param bool $unread Unread (True/False) (Default: False) - * @param bool $return True to return a string containing the SQL code to update this item, False to execute it (Default: False) - * @return string|null If $return is False, nothing will be returned, else the sql code to update this item - */ - protected function mark($unread = true, $return = false) - { - $this->notification_read = (bool) !$unread; - - if ($return) - { - $where = array( - 'notification_type_id = ' . (int) $this->notification_type_id, - 'item_id = ' . (int) $this->item_id, - 'user_id = ' . (int) $this->user_id, - ); - - $where = implode(' AND ', $where); - return $where; - } - else - { - $this->notification_manager->mark_notifications($this->get_type(), (int) $this->item_id, (int) $this->user_id, false, $this->notification_read); - } - - return null; - } - - /** - * Get a list of users that are authorised to receive notifications - * - * @param array $users Array of users that have subscribed to a notification - * @param int $forum_id Forum ID of the forum - * @param array $options Array of notification options - * @param bool $sort Whether the users array should be sorted. Default: false - * @return array Array of users that are authorised recipients - */ - protected function get_authorised_recipients($users, $forum_id, $options, $sort = false) - { - if (empty($users)) - { - return array(); - } - - $users = array_unique($users); - - if ($sort) - { - sort($users); - } - - $auth_read = $this->auth->acl_get_list($users, 'f_read', $forum_id); - - if (empty($auth_read)) - { - return array(); - } - - return $this->check_user_notification_options($auth_read[$forum_id]['f_read'], $options); - } -} diff --git a/install/update/old/phpbb/notification/type/post.php b/install/update/old/phpbb/notification/type/post.php deleted file mode 100644 index 254f4c0..0000000 --- a/install/update/old/phpbb/notification/type/post.php +++ /dev/null @@ -1,467 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\notification\type; - -/** -* Post notifications class -* This class handles notifications for replies to a topic -*/ - -class post extends \phpbb\notification\type\base -{ - /** - * Get notification type name - * - * @return string - */ - public function get_type() - { - return 'notification.type.post'; - } - - /** - * Language key used to output the text - * - * @var string - */ - protected $language_key = 'NOTIFICATION_POST'; - - /** - * Inherit notification read status from post. - * - * @var bool - */ - protected $inherit_read_status = true; - - /** - * Notification option data (for outputting to the user) - * - * @var bool|array False if the service should use it's default data - * Array of data (including keys 'id', 'lang', and 'group') - */ - static public $notification_option = array( - 'lang' => 'NOTIFICATION_TYPE_POST', - 'group' => 'NOTIFICATION_GROUP_POSTING', - ); - - /** @var \phpbb\user_loader */ - protected $user_loader; - - /** @var \phpbb\config\config */ - protected $config; - - public function set_config(\phpbb\config\config $config) - { - $this->config = $config; - } - - public function set_user_loader(\phpbb\user_loader $user_loader) - { - $this->user_loader = $user_loader; - } - - /** - * Is available - */ - public function is_available() - { - return $this->config['allow_topic_notify']; - } - - /** - * Get the id of the item - * - * @param array $post The data from the post - * @return int The post id - */ - static public function get_item_id($post) - { - return (int) $post['post_id']; - } - - /** - * Get the id of the parent - * - * @param array $post The data from the post - * @return int The topic id - */ - static public function get_item_parent_id($post) - { - return (int) $post['topic_id']; - } - - /** - * Find the users who want to receive notifications - * - * @param array $post Data from submit_post - * @param array $options Options for finding users for notification - * - * @return array - */ - public function find_users_for_notification($post, $options = array()) - { - $options = array_merge(array( - 'ignore_users' => array(), - ), $options); - - $users = array(); - - $sql = 'SELECT user_id - FROM ' . TOPICS_WATCH_TABLE . ' - WHERE topic_id = ' . (int) $post['topic_id'] . ' - AND notify_status = ' . NOTIFY_YES . ' - AND user_id <> ' . (int) $post['poster_id']; - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - $users[] = (int) $row['user_id']; - } - $this->db->sql_freeresult($result); - - $sql = 'SELECT user_id - FROM ' . FORUMS_WATCH_TABLE . ' - WHERE forum_id = ' . (int) $post['forum_id'] . ' - AND notify_status = ' . NOTIFY_YES . ' - AND user_id <> ' . (int) $post['poster_id']; - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - $users[] = (int) $row['user_id']; - } - $this->db->sql_freeresult($result); - - $notify_users = $this->get_authorised_recipients($users, $post['forum_id'], $options, true); - - if (empty($notify_users)) - { - return array(); - } - - // Try to find the users who already have been notified about replies and have not read the topic since and just update their notifications - $notified_users = $this->notification_manager->get_notified_users($this->get_type(), array( - 'item_parent_id' => static::get_item_parent_id($post), - 'read' => 0, - )); - - foreach ($notified_users as $user => $notification_data) - { - unset($notify_users[$user]); - - /** @var post $notification */ - $notification = $this->notification_manager->get_item_type_class($this->get_type(), $notification_data); - $update_responders = $notification->add_responders($post); - if (!empty($update_responders)) - { - $this->notification_manager->update_notification($notification, $update_responders, array( - 'item_parent_id' => self::get_item_parent_id($post), - 'read' => 0, - 'user_id' => $user, - )); - } - } - - return $notify_users; - } - - /** - * Get the user's avatar - */ - public function get_avatar() - { - return $this->user_loader->get_avatar($this->get_data('poster_id'), false, true); - } - - /** - * Get the HTML formatted title of this notification - * - * @return string - */ - public function get_title() - { - $responders = $this->get_data('responders'); - $usernames = array(); - - if (!is_array($responders)) - { - $responders = array(); - } - - $responders = array_merge(array(array( - 'poster_id' => $this->get_data('poster_id'), - 'username' => $this->get_data('post_username'), - )), $responders); - - $responders_cnt = count($responders); - $responders = $this->trim_user_ary($responders); - $trimmed_responders_cnt = $responders_cnt - count($responders); - - foreach ($responders as $responder) - { - if ($responder['username']) - { - $usernames[] = $responder['username']; - } - else - { - $usernames[] = $this->user_loader->get_username($responder['poster_id'], 'no_profile'); - } - } - - if ($trimmed_responders_cnt > 20) - { - $usernames[] = $this->language->lang('NOTIFICATION_MANY_OTHERS'); - } - else if ($trimmed_responders_cnt) - { - $usernames[] = $this->language->lang('NOTIFICATION_X_OTHERS', $trimmed_responders_cnt); - } - - return $this->language->lang( - $this->language_key, - phpbb_generate_string_list($usernames, $this->user), - $responders_cnt - ); - } - - /** - * Get the HTML formatted reference of the notification - * - * @return string - */ - public function get_reference() - { - return $this->language->lang( - 'NOTIFICATION_REFERENCE', - censor_text($this->get_data('topic_title')) - ); - } - - /** - * Get email template - * - * @return string|bool - */ - public function get_email_template() - { - return 'topic_notify'; - } - - /** - * Get email template variables - * - * @return array - */ - public function get_email_template_variables() - { - if ($this->get_data('post_username')) - { - $username = $this->get_data('post_username'); - } - else - { - $username = $this->user_loader->get_username($this->get_data('poster_id'), 'username'); - } - - return array( - 'AUTHOR_NAME' => htmlspecialchars_decode($username), - 'POST_SUBJECT' => htmlspecialchars_decode(censor_text($this->get_data('post_subject'))), - 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($this->get_data('topic_title'))), - - 'U_VIEW_POST' => generate_board_url() . "/viewtopic.{$this->php_ext}?p={$this->item_id}#p{$this->item_id}", - 'U_NEWEST_POST' => generate_board_url() . "/viewtopic.{$this->php_ext}?f={$this->get_data('forum_id')}&t={$this->item_parent_id}&e=1&view=unread#unread", - 'U_TOPIC' => generate_board_url() . "/viewtopic.{$this->php_ext}?f={$this->get_data('forum_id')}&t={$this->item_parent_id}", - 'U_VIEW_TOPIC' => generate_board_url() . "/viewtopic.{$this->php_ext}?f={$this->get_data('forum_id')}&t={$this->item_parent_id}", - 'U_FORUM' => generate_board_url() . "/viewforum.{$this->php_ext}?f={$this->get_data('forum_id')}", - 'U_STOP_WATCHING_TOPIC' => generate_board_url() . "/viewtopic.{$this->php_ext}?uid={$this->user_id}&f={$this->get_data('forum_id')}&t={$this->item_parent_id}&unwatch=topic", - ); - } - - /** - * Get the url to this item - * - * @return string URL - */ - public function get_url() - { - return append_sid($this->phpbb_root_path . 'viewtopic.' . $this->php_ext, "p={$this->item_id}#p{$this->item_id}"); - } - - /** - * {inheritDoc} - */ - public function get_redirect_url() - { - return append_sid($this->phpbb_root_path . 'viewtopic.' . $this->php_ext, "t={$this->item_parent_id}&view=unread#unread"); - } - - /** - * Users needed to query before this notification can be displayed - * - * @return array Array of user_ids - */ - public function users_to_query() - { - $responders = $this->get_data('responders'); - $users = array( - $this->get_data('poster_id'), - ); - - if (is_array($responders)) - { - foreach ($responders as $responder) - { - $users[] = $responder['poster_id']; - } - } - - return $this->trim_user_ary($users); - } - - /** - * Trim the user array passed down to 3 users if the array contains - * more than 4 users. - * - * @param array $users Array of users - * @return array Trimmed array of user_ids - */ - public function trim_user_ary($users) - { - if (count($users) > 4) - { - array_splice($users, 3); - } - return $users; - } - - /** - * Pre create insert array function - * This allows you to perform certain actions, like run a query - * and load data, before create_insert_array() is run. The data - * returned from this function will be sent to create_insert_array(). - * - * @param array $post Post data from submit_post - * @param array $notify_users Notify users list - * Formated from find_users_for_notification() - * @return array Whatever you want to send to create_insert_array(). - */ - public function pre_create_insert_array($post, $notify_users) - { - if (!count($notify_users) || !$this->inherit_read_status) - { - return array(); - } - - $tracking_data = array(); - $sql = 'SELECT user_id, mark_time FROM ' . TOPICS_TRACK_TABLE . ' - WHERE topic_id = ' . (int) $post['topic_id'] . ' - AND ' . $this->db->sql_in_set('user_id', array_keys($notify_users)); - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - $tracking_data[$row['user_id']] = $row['mark_time']; - } - $this->db->sql_freeresult($result); - - return $tracking_data; - } - - /** - * {@inheritdoc} - */ - public function create_insert_array($post, $pre_create_data = array()) - { - $this->set_data('poster_id', $post['poster_id']); - - $this->set_data('topic_title', $post['topic_title']); - - $this->set_data('post_subject', $post['post_subject']); - - $this->set_data('post_username', (($post['poster_id'] == ANONYMOUS) ? $post['post_username'] : '')); - - $this->set_data('forum_id', $post['forum_id']); - - $this->set_data('forum_name', $post['forum_name']); - - $this->notification_time = $post['post_time']; - - // Topics can be "read" before they are public (while awaiting approval). - // Make sure that if the user has read the topic, it's marked as read in the notification - if ($this->inherit_read_status && isset($pre_create_data[$this->user_id]) && $pre_create_data[$this->user_id] >= $this->notification_time) - { - $this->notification_read = true; - } - - parent::create_insert_array($post, $pre_create_data); - } - - /** - * Add responders to the notification - * - * @param mixed $post - * @return array Array of responder data - */ - public function add_responders($post) - { - // Do not add them as a responder if they were the original poster that created the notification - if ($this->get_data('poster_id') == $post['poster_id']) - { - return array(); - } - - $responders = $this->get_data('responders'); - - $responders = ($responders === null) ? array() : $responders; - - // Do not add more than 25 responders, - // we trim the username list to "a, b, c and x others" anyway - // so there is no use to add all of them anyway. - if (count($responders) > 25) - { - return array(); - } - - foreach ($responders as $responder) - { - // Do not add them as a responder multiple times - if ($responder['poster_id'] == $post['poster_id']) - { - return array(); - } - } - - $responders[] = array( - 'poster_id' => $post['poster_id'], - 'username' => (($post['poster_id'] == ANONYMOUS) ? $post['post_username'] : ''), - ); - - $this->set_data('responders', $responders); - - $serialized_data = serialize($this->get_data(false)); - - // If the data is longer then 4000 characters, it would cause a SQL error. - // We don't add the username to the list if this is the case. - if (utf8_strlen($serialized_data) >= 4000) - { - return array(); - } - - $data_array = array_merge(array( - 'post_time' => $post['post_time'], - 'post_id' => $post['post_id'], - 'topic_id' => $post['topic_id'] - ), $this->get_data(false)); - - return $data_array; - } -} diff --git a/install/update/old/phpbb/notification/type/topic.php b/install/update/old/phpbb/notification/type/topic.php deleted file mode 100644 index 5c42afa..0000000 --- a/install/update/old/phpbb/notification/type/topic.php +++ /dev/null @@ -1,307 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\notification\type; - -/** -* Topic notifications class -* This class handles notifications for new topics -*/ - -class topic extends \phpbb\notification\type\base -{ - /** - * Get notification type name - * - * @return string - */ - public function get_type() - { - return 'notification.type.topic'; - } - - /** - * Language key used to output the text - * - * @var string - */ - protected $language_key = 'NOTIFICATION_TOPIC'; - - /** - * Inherit notification read status from topic. - * - * @var bool - */ - protected $inherit_read_status = true; - - /** - * Notification option data (for outputting to the user) - * - * @var bool|array False if the service should use it's default data - * Array of data (including keys 'id', 'lang', and 'group') - */ - static public $notification_option = array( - 'lang' => 'NOTIFICATION_TYPE_TOPIC', - 'group' => 'NOTIFICATION_GROUP_POSTING', - ); - - /** @var \phpbb\user_loader */ - protected $user_loader; - - /** @var \phpbb\config\config */ - protected $config; - - public function set_config(\phpbb\config\config $config) - { - $this->config = $config; - } - - public function set_user_loader(\phpbb\user_loader $user_loader) - { - $this->user_loader = $user_loader; - } - - /** - * Is available - */ - public function is_available() - { - return $this->config['allow_forum_notify']; - } - - /** - * Get the id of the item - * - * @param array $post The data from the post - * @return int The topic id - */ - static public function get_item_id($post) - { - return (int) $post['topic_id']; - } - - /** - * Get the id of the parent - * - * @param array $post The data from the post - * @return int The forum id - */ - static public function get_item_parent_id($post) - { - return (int) $post['forum_id']; - } - - /** - * Find the users who want to receive notifications - * - * @param array $topic Data from the topic - * @param array $options Options for finding users for notification - * - * @return array - */ - public function find_users_for_notification($topic, $options = array()) - { - $options = array_merge(array( - 'ignore_users' => array(), - ), $options); - - $users = array(); - - $sql = 'SELECT user_id - FROM ' . FORUMS_WATCH_TABLE . ' - WHERE forum_id = ' . (int) $topic['forum_id'] . ' - AND notify_status = ' . NOTIFY_YES . ' - AND user_id <> ' . (int) $topic['poster_id']; - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - $users[] = (int) $row['user_id']; - } - $this->db->sql_freeresult($result); - - return $this->get_authorised_recipients($users, $topic['forum_id'], $options); - } - - /** - * Get the user's avatar - */ - public function get_avatar() - { - return $this->user_loader->get_avatar($this->get_data('poster_id'), false, true); - } - - /** - * Get the HTML formatted title of this notification - * - * @return string - */ - public function get_title() - { - if ($this->get_data('post_username')) - { - $username = $this->get_data('post_username'); - } - else - { - $username = $this->user_loader->get_username($this->get_data('poster_id'), 'no_profile'); - } - - return $this->language->lang( - $this->language_key, - $username - ); - } - - /** - * Get the HTML formatted reference of the notification - * - * @return string - */ - public function get_reference() - { - return $this->language->lang( - 'NOTIFICATION_REFERENCE', - censor_text($this->get_data('topic_title')) - ); - } - - /** - * Get the forum of the notification reference - * - * @return string - */ - public function get_forum() - { - return $this->language->lang( - 'NOTIFICATION_FORUM', - $this->get_data('forum_name') - ); - } - - /** - * Get email template - * - * @return string|bool - */ - public function get_email_template() - { - return 'newtopic_notify'; - } - - /** - * Get email template variables - * - * @return array - */ - public function get_email_template_variables() - { - $board_url = generate_board_url(); - - if ($this->get_data('post_username')) - { - $username = $this->get_data('post_username'); - } - else - { - $username = $this->user_loader->get_username($this->get_data('poster_id'), 'username'); - } - - return array( - 'AUTHOR_NAME' => htmlspecialchars_decode($username), - 'FORUM_NAME' => htmlspecialchars_decode($this->get_data('forum_name')), - 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($this->get_data('topic_title'))), - - 'U_TOPIC' => "{$board_url}/viewtopic.{$this->php_ext}?f={$this->item_parent_id}&t={$this->item_id}", - 'U_VIEW_TOPIC' => "{$board_url}/viewtopic.{$this->php_ext}?f={$this->item_parent_id}&t={$this->item_id}", - 'U_FORUM' => "{$board_url}/viewforum.{$this->php_ext}?f={$this->item_parent_id}", - 'U_STOP_WATCHING_FORUM' => "{$board_url}/viewforum.{$this->php_ext}?uid={$this->user_id}&f={$this->item_parent_id}&unwatch=forum", - ); - } - - /** - * Get the url to this item - * - * @return string URL - */ - public function get_url() - { - return append_sid($this->phpbb_root_path . 'viewtopic.' . $this->php_ext, "f={$this->item_parent_id}&t={$this->item_id}"); - } - - /** - * Users needed to query before this notification can be displayed - * - * @return array Array of user_ids - */ - public function users_to_query() - { - return array($this->get_data('poster_id')); - } - - /** - * Pre create insert array function - * This allows you to perform certain actions, like run a query - * and load data, before create_insert_array() is run. The data - * returned from this function will be sent to create_insert_array(). - * - * @param array $post Post data from submit_post - * @param array $notify_users Notify users list - * Formated from find_users_for_notification() - * @return array Whatever you want to send to create_insert_array(). - */ - public function pre_create_insert_array($post, $notify_users) - { - if (!count($notify_users) || !$this->inherit_read_status) - { - return array(); - } - - $tracking_data = array(); - $sql = 'SELECT user_id, mark_time FROM ' . TOPICS_TRACK_TABLE . ' - WHERE topic_id = ' . (int) $post['topic_id'] . ' - AND ' . $this->db->sql_in_set('user_id', array_keys($notify_users)); - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - $tracking_data[$row['user_id']] = $row['mark_time']; - } - $this->db->sql_freeresult($result); - - return $tracking_data; - } - - /** - * {@inheritdoc} - */ - public function create_insert_array($post, $pre_create_data = array()) - { - $this->set_data('poster_id', $post['poster_id']); - - $this->set_data('topic_title', $post['topic_title']); - - $this->set_data('post_username', (($post['poster_id'] == ANONYMOUS) ? $post['post_username'] : '')); - - $this->set_data('forum_name', $post['forum_name']); - - $this->notification_time = $post['post_time']; - - // Topics can be "read" before they are public (while awaiting approval). - // Make sure that if the user has read the topic, it's marked as read in the notification - if ($this->inherit_read_status && isset($pre_create_data[$this->user_id]) && $pre_create_data[$this->user_id] >= $this->notification_time) - { - $this->notification_read = true; - } - - parent::create_insert_array($post, $pre_create_data); - } -} diff --git a/install/update/old/phpbb/notification/type/type_interface.php b/install/update/old/phpbb/notification/type/type_interface.php deleted file mode 100644 index f9f832b..0000000 --- a/install/update/old/phpbb/notification/type/type_interface.php +++ /dev/null @@ -1,218 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\notification\type; - -/** -* Base notifications interface -*/ -interface type_interface -{ - /** - * Get notification type name - * - * @return string - */ - public function get_type(); - - /** - * Set initial data from the database - * - * @param array $data Row directly from the database - */ - public function set_initial_data($data); - - /** - * Get the id of the item - * - * @param array $type_data The type specific data - */ - static public function get_item_id($type_data); - - /** - * Get the id of the parent - * - * @param array $type_data The type specific data - */ - static public function get_item_parent_id($type_data); - - /** - * Is this type available to the current user (defines whether or not it will be shown in the UCP Edit notification options) - * - * @return bool True/False whether or not this is available to the user - */ - public function is_available(); - - /** - * Find the users who want to receive notifications - * - * @param array $type_data The type specific data - * @param array $options Options for finding users for notification - * ignore_users => array of users and user types that should not receive notifications from this type because they've already been notified - * e.g.: array(2 => array(''), 3 => array('', 'email'), ...) - * - * @return array - */ - public function find_users_for_notification($type_data, $options); - - /** - * Users needed to query before this notification can be displayed - * - * @return array Array of user_ids - */ - public function users_to_query(); - - /** - * Get the special items to load - * - * @return array Data will be combined sent to load_special() so you can run a single query and get data required for this notification type - */ - public function get_load_special(); - - /** - * Load the special items - * - * @param array $data Data from get_load_special() - * @param array $notifications Array of notifications (key is notification_id, value is the notification objects) - */ - public function load_special($data, $notifications); - - /** - * Get the CSS style class of the notification - * - * @return string - */ - public function get_style_class(); - - /** - * Get the HTML formatted title of this notification - * - * @return string - */ - public function get_title(); - - /** - * Get the HTML formatted reference of the notification - * - * @return string - */ - public function get_reference(); - - /** - * Get the forum of the notification reference - * - * @return string - */ - public function get_forum(); - - /** - * Get the url to this item - * - * @return string URL - */ - public function get_url(); - - /** - * Get the url to redirect after the item has been marked as read - * - * @return string URL - */ - public function get_redirect_url(); - - /** - * URL to unsubscribe to this notification - * - * @param string|bool $method Method name to unsubscribe from (email|jabber|etc), False to unsubscribe from all notifications for this item - */ - public function get_unsubscribe_url($method); - - /** - * Get the user's avatar (the user who caused the notification typically) - * - * @return string - */ - public function get_avatar(); - - /** - * Prepare to output the notification to the template - */ - public function prepare_for_display(); - - /** - * Get email template - * - * @return string|bool - */ - public function get_email_template(); - - /** - * Get email template variables - * - * @return array - */ - public function get_email_template_variables(); - - /** - * Pre create insert array function - * This allows you to perform certain actions, like run a query - * and load data, before create_insert_array() is run. The data - * returned from this function will be sent to create_insert_array(). - * - * @param array $type_data The type specific data - * @param array $notify_users Notify users list - * Formated from find_users_for_notification() - * @return array Whatever you want to send to create_insert_array(). - */ - public function pre_create_insert_array($type_data, $notify_users); - - /** - * Function for preparing the data for insertion in an SQL query - * - * @param array $type_data The type specific data - * @param array $pre_create_data Data from pre_create_insert_array() - */ - public function create_insert_array($type_data, $pre_create_data); - - /** - * Function for getting the data for insertion in an SQL query - * - * @return array Array of data ready to be inserted into the database - */ - public function get_insert_array(); - - /** - * Function for preparing the data for update in an SQL query - * (The service handles insertion) - * - * @param array $type_data Data unique to this notification type - * - * @return array Array of data ready to be updated in the database - */ - public function create_update_array($type_data); - - /** - * Mark this item read - * - * @param bool $return True to return a string containing the SQL code to update this item, False to execute it (Default: False) - * @return string - */ - public function mark_read($return = false); - - /** - * Mark this item unread - * - * @param bool $return True to return a string containing the SQL code to update this item, False to execute it (Default: False) - * @return string - */ - public function mark_unread($return = false); -} diff --git a/install/update/old/phpbb/passwords/manager.php b/install/update/old/phpbb/passwords/manager.php deleted file mode 100644 index fad76a9..0000000 --- a/install/update/old/phpbb/passwords/manager.php +++ /dev/null @@ -1,407 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\passwords; - -class manager -{ - /** - * Default hashing method - */ - protected $type = false; - - /** - * Hashing algorithm type map - * Will be used to map hash prefix to type - */ - protected $type_map = false; - - /** - * Service collection of hashing algorithms - * Needs to be public for passwords helper - */ - public $algorithms = false; - - /** - * Password convert flag. Signals that password should be converted - */ - public $convert_flag = false; - - /** - * Passwords helper - * @var \phpbb\passwords\helper - */ - protected $helper; - - /** - * phpBB configuration - * @var \phpbb\config\config - */ - protected $config; - - /** - * @var bool Whether or not initialized() has been called - */ - private $initialized = false; - - /** - * @var array Hashing driver service collection - */ - private $hashing_algorithms; - - /** - * @var array List of default driver types - */ - private $defaults; - - /** - * Construct a passwords object - * - * @param \phpbb\config\config $config phpBB configuration - * @param array $hashing_algorithms Hashing driver service collection - * @param \phpbb\passwords\helper $helper Passwords helper object - * @param array $defaults List of default driver types - */ - public function __construct(\phpbb\config\config $config, $hashing_algorithms, helper $helper, $defaults) - { - $this->config = $config; - $this->helper = $helper; - $this->hashing_algorithms = $hashing_algorithms; - $this->defaults = $defaults; - } - - /** - * Initialize the internal state - */ - protected function initialize() - { - if (!$this->initialized) - { - $this->initialized = true; - $this->fill_type_map($this->hashing_algorithms); - $this->register_default_type($this->defaults); - } - } - - /** - * Register default type - * Will register the first supported type from the list of default types - * - * @param array $defaults List of default types in order from first to - * use to last to use - */ - protected function register_default_type($defaults) - { - foreach ($defaults as $type) - { - if ($this->algorithms[$type]->is_supported()) - { - $this->type = $this->algorithms[$type]->get_prefix(); - break; - } - } - } - - /** - * Fill algorithm type map - * - * @param \phpbb\di\service_collection $hashing_algorithms - */ - protected function fill_type_map($hashing_algorithms) - { - foreach ($hashing_algorithms as $algorithm) - { - if (!isset($this->type_map[$algorithm->get_prefix()])) - { - $this->type_map[$algorithm->get_prefix()] = $algorithm; - } - } - $this->algorithms = $hashing_algorithms; - } - - /** - * Get the algorithm specified by a specific prefix - * - * @param string $prefix Password hash prefix - * - * @return object|bool The hash type object or false if prefix is not - * supported - */ - protected function get_algorithm($prefix) - { - if (isset($this->type_map[$prefix])) - { - return $this->type_map[$prefix]; - } - else - { - return false; - } - } - - /** - * Detect the hash type of the supplied hash - * - * @param string $hash Password hash that should be checked - * - * @return object|bool The hash type object or false if the specified - * type is not supported - */ - public function detect_algorithm($hash) - { - /* - * preg_match() will also show hashing algos like $2a\H$, which - * is a combination of bcrypt and phpass. Legacy algorithms - * like md5 will not be matched by this and need to be treated - * differently. - */ - if (!preg_match('#^\$([a-zA-Z0-9\\\]*?)\$#', $hash, $match)) - { - return false; - } - - $this->initialize(); - - // Be on the lookout for multiple hashing algorithms - // 2 is correct: H\2a > 2, H\P > 2 - if (strlen($match[1]) > 2 && strpos($match[1], '\\') !== false) - { - $hash_types = explode('\\', $match[1]); - $return_ary = array(); - foreach ($hash_types as $type) - { - // we do not support the same hashing - // algorithm more than once - if (isset($return_ary[$type])) - { - return false; - } - - $return_ary[$type] = $this->get_algorithm('$' . $type . '$'); - - if (empty($return_ary[$type])) - { - return false; - } - } - return $return_ary; - } - - // get_algorithm() will automatically return false if prefix - // is not supported - return $this->get_algorithm($match[0]); - } - - /** - * Hash supplied password - * - * @param string $password Password that should be hashed - * @param string $type Hash type. Will default to standard hash type if - * none is supplied - * @return string|bool Password hash of supplied password or false if - * if something went wrong during hashing - */ - public function hash($password, $type = '') - { - if (strlen($password) > 4096) - { - // If the password is too huge, we will simply reject it - // and not let the server try to hash it. - return false; - } - - $this->initialize(); - - // Try to retrieve algorithm by service name if type doesn't - // start with dollar sign - if (!is_array($type) && strpos($type, '$') !== 0 && isset($this->algorithms[$type])) - { - $type = $this->algorithms[$type]->get_prefix(); - } - - $type = ($type === '') ? $this->type : $type; - - if (is_array($type)) - { - return $this->combined_hash_password($password, $type); - } - - if (isset($this->type_map[$type])) - { - $hashing_algorithm = $this->type_map[$type]; - } - else - { - return false; - } - - return $hashing_algorithm->hash($password); - } - - /** - * Check supplied password against hash and set convert_flag if password - * needs to be converted to different format (preferrably newer one) - * - * @param string $password Password that should be checked - * @param string $hash Stored hash - * @param array $user_row User's row in users table - * @return string|bool True if password is correct, false if not - */ - public function check($password, $hash, $user_row = array()) - { - if (strlen($password) > 4096) - { - // If the password is too huge, we will simply reject it - // and not let the server try to hash it. - return false; - } - - // Empty hashes can't be checked - if (empty($hash)) - { - return false; - } - - $this->initialize(); - - // First find out what kind of hash we're dealing with - $stored_hash_type = $this->detect_algorithm($hash); - if ($stored_hash_type == false) - { - // Still check MD5 hashes as that is what the installer - // will default to for the admin user - return $this->get_algorithm('$H$')->check($password, $hash); - } - - // Multiple hash passes needed - if (is_array($stored_hash_type)) - { - $correct = $this->check_combined_hash($password, $stored_hash_type, $hash); - $this->convert_flag = ($correct === true) ? true : false; - return $correct; - } - - if ($stored_hash_type->get_prefix() !== $this->type) - { - $this->convert_flag = true; - } - else - { - if ($stored_hash_type instanceof driver\rehashable_driver_interface) - { - $this->convert_flag = $stored_hash_type->needs_rehash($hash); - } - else - { - $this->convert_flag = false; - } - } - - // Check all legacy hash types if prefix is $CP$ - if ($stored_hash_type->get_prefix() === '$CP$') - { - // Remove $CP$ prefix for proper checking - $hash = substr($hash, 4); - - foreach ($this->type_map as $algorithm) - { - if ($algorithm->is_legacy() && $algorithm->check($password, $hash, $user_row) === true) - { - return true; - } - } - } - - return $stored_hash_type->check($password, $hash); - } - - /** - * Create combined hash from already hashed password - * - * @param string $password_hash Complete current password hash - * @param string $type Type of the hashing algorithm the password hash - * should be combined with - * @return string|bool Combined password hash if combined hashing was - * successful, else false - */ - public function combined_hash_password($password_hash, $type) - { - $this->initialize(); - - $data = array( - 'prefix' => '$', - 'settings' => '$', - ); - $hash_settings = $this->helper->get_combined_hash_settings($password_hash); - $hash = $hash_settings[0]; - - // Put settings of current hash into data array - $stored_hash_type = $this->detect_algorithm($password_hash); - $this->helper->combine_hash_output($data, 'prefix', $stored_hash_type->get_prefix()); - $this->helper->combine_hash_output($data, 'settings', $stored_hash_type->get_settings_only($password_hash)); - - // Hash current hash with the defined types - foreach ($type as $cur_type) - { - if (isset($this->algorithms[$cur_type])) - { - $new_hash_type = $this->algorithms[$cur_type]; - } - else - { - $new_hash_type = $this->get_algorithm($cur_type); - } - - if (!$new_hash_type) - { - return false; - } - - $new_hash = $new_hash_type->hash(str_replace($stored_hash_type->get_settings_only($password_hash), '', $hash)); - $this->helper->combine_hash_output($data, 'prefix', $new_hash_type->get_prefix()); - $this->helper->combine_hash_output($data, 'settings', substr(str_replace('$', '\\', $new_hash_type->get_settings_only($new_hash, true)), 0)); - $hash = str_replace($new_hash_type->get_settings_only($new_hash), '', $this->helper->obtain_hash_only($new_hash)); - } - return $this->helper->combine_hash_output($data, 'hash', $hash); - } - - /** - * Check combined password hash against the supplied password - * - * @param string $password Password entered by user - * @param array $stored_hash_type An array containing the hash types - * as described by stored password hash - * @param string $hash Stored password hash - * - * @return bool True if password is correct, false if not - */ - public function check_combined_hash($password, $stored_hash_type, $hash) - { - $i = 0; - $data = array( - 'prefix' => '$', - 'settings' => '$', - ); - $hash_settings = $this->helper->get_combined_hash_settings($hash); - foreach ($stored_hash_type as $key => $hash_type) - { - $rebuilt_hash = $this->helper->rebuild_hash($hash_type->get_prefix(), $hash_settings[$i]); - $this->helper->combine_hash_output($data, 'prefix', $key); - $this->helper->combine_hash_output($data, 'settings', $hash_settings[$i]); - $cur_hash = $hash_type->hash($password, $rebuilt_hash); - $password = str_replace($rebuilt_hash, '', $cur_hash); - $i++; - } - return ($hash === $this->helper->combine_hash_output($data, 'hash', $password)); - } -} diff --git a/install/update/old/phpbb/permissions.php b/install/update/old/phpbb/permissions.php deleted file mode 100644 index 7697884..0000000 --- a/install/update/old/phpbb/permissions.php +++ /dev/null @@ -1,364 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb; - -class permissions -{ - /** - * Event dispatcher object - * @var \phpbb\event\dispatcher_interface - */ - protected $dispatcher; - - /** - * User object - * @var \phpbb\user - */ - protected $user; - - /** - * Constructor - * - * @param \phpbb\event\dispatcher_interface $phpbb_dispatcher Event dispatcher - * @param \phpbb\user $user User Object - */ - public function __construct(\phpbb\event\dispatcher_interface $phpbb_dispatcher, \phpbb\user $user) - { - $this->dispatcher = $phpbb_dispatcher; - $this->user = $user; - - $categories = $this->categories; - $types = $this->types; - $permissions = $this->permissions; - - /** - * Allows to specify additional permission categories, types and permissions - * - * @event core.permissions - * @var array types Array with permission types (a_, u_, m_, etc.) - * @var array categories Array with permission categories (pm, post, settings, misc, etc.) - * @var array permissions Array with permissions. Each Permission has the following layout: - * '' => array( - * 'lang' => 'Language Key with a Short description', // Optional, if not set, - * // the permissions identifier '' is used with - * // all uppercase. - * 'cat' => 'Identifier of the category, the permission should be displayed in', - * ), - * Example: - * 'u_viewprofile' => array( - * 'lang' => 'ACL_U_VIEWPROFILE', - * 'cat' => 'profile', - * ), - * @since 3.1.0-a1 - */ - $vars = array('types', 'categories', 'permissions'); - extract($phpbb_dispatcher->trigger_event('core.permissions', compact($vars))); - - $this->categories = $categories; - $this->types = $types; - $this->permissions = $permissions; - } - - /** - * Returns an array with all the permission categories (pm, post, settings, misc, etc.) - * - * @return array Layout: cat-identifier => Language key - */ - public function get_categories() - { - return $this->categories; - } - - /** - * Returns the language string of a permission category - * - * @param string $category Identifier of the category - * @return string Language string - */ - public function get_category_lang($category) - { - return $this->user->lang($this->categories[$category]); - } - - /** - * Returns an array with all the permission types (a_, u_, m_, etc.) - * - * @return array Layout: type-identifier => Language key - */ - public function get_types() - { - return $this->types; - } - - /** - * Returns the language string of a permission type - * - * @param string $type Identifier of the type - * @param mixed $scope Scope of the type (should be 'global', 'local' or false) - * @return string Language string - */ - public function get_type_lang($type, $scope = false) - { - if ($scope && isset($this->types[$scope][$type])) - { - $lang_key = $this->types[$scope][$type]; - } - else if (isset($this->types[$type])) - { - $lang_key = $this->types[$type]; - } - else - { - $lang_key = 'ACL_TYPE_' . strtoupper(($scope) ? $scope . '_' . $type : $type); - } - - return $this->user->lang($lang_key); - } - - /** - * Returns an array with all the permissions. - * Each Permission has the following layout: - * '' => array( - * 'lang' => 'Language Key with a Short description', // Optional, if not set, - * // the permissions identifier '' is used with - * // all uppercase. - * 'cat' => 'Identifier of the category, the permission should be displayed in', - * ), - * Example: - * 'u_viewprofile' => array( - * 'lang' => 'ACL_U_VIEWPROFILE', - * 'cat' => 'profile', - * ), - * - * @return array - */ - public function get_permissions() - { - return $this->permissions; - } - - /** - * Returns the category of a permission - * - * @param string $permission Identifier of the permission - * @return string Returns the category identifier of the permission - */ - public function get_permission_category($permission) - { - return (isset($this->permissions[$permission]['cat'])) ? $this->permissions[$permission]['cat'] : 'misc'; - } - - /** - * Checks if a category has been defined - * - * @param string $category Identifier of the category - * @return bool True if the category is defined, false otherwise - */ - public function category_defined($category) - { - return isset($this->categories[$category]); - } - - /** - * Checks if a permission has been defined - * - * @param string $permission Identifier of the permission - * @return bool True if the permission is defined, false otherwise - */ - public function permission_defined($permission) - { - return isset($this->permissions[$permission]); - } - - /** - * Returns the language string of a permission - * - * @param string $permission Identifier of the permission - * @return string Language string - */ - public function get_permission_lang($permission) - { - return (isset($this->permissions[$permission]['lang'])) ? $this->user->lang($this->permissions[$permission]['lang']) : $this->user->lang('ACL_' . strtoupper($permission)); - } - - protected $types = array( - 'u_' => 'ACL_TYPE_U_', - 'a_' => 'ACL_TYPE_A_', - 'm_' => 'ACL_TYPE_M_', - 'f_' => 'ACL_TYPE_F_', - 'global' => array( - 'm_' => 'ACL_TYPE_GLOBAL_M_', - ), - ); - - protected $categories = array( - 'actions' => 'ACL_CAT_ACTIONS', - 'content' => 'ACL_CAT_CONTENT', - 'forums' => 'ACL_CAT_FORUMS', - 'misc' => 'ACL_CAT_MISC', - 'permissions' => 'ACL_CAT_PERMISSIONS', - 'pm' => 'ACL_CAT_PM', - 'polls' => 'ACL_CAT_POLLS', - 'post' => 'ACL_CAT_POST', - 'post_actions' => 'ACL_CAT_POST_ACTIONS', - 'posting' => 'ACL_CAT_POSTING', - 'profile' => 'ACL_CAT_PROFILE', - 'settings' => 'ACL_CAT_SETTINGS', - 'topic_actions' => 'ACL_CAT_TOPIC_ACTIONS', - 'user_group' => 'ACL_CAT_USER_GROUP', - ); - - protected $permissions = array( - // User Permissions - 'u_viewprofile' => array('lang' => 'ACL_U_VIEWPROFILE', 'cat' => 'profile'), - 'u_chgname' => array('lang' => 'ACL_U_CHGNAME', 'cat' => 'profile'), - 'u_chgpasswd' => array('lang' => 'ACL_U_CHGPASSWD', 'cat' => 'profile'), - 'u_chgemail' => array('lang' => 'ACL_U_CHGEMAIL', 'cat' => 'profile'), - 'u_chgavatar' => array('lang' => 'ACL_U_CHGAVATAR', 'cat' => 'profile'), - 'u_chggrp' => array('lang' => 'ACL_U_CHGGRP', 'cat' => 'profile'), - 'u_chgprofileinfo' => array('lang' => 'ACL_U_CHGPROFILEINFO', 'cat' => 'profile'), - - 'u_attach' => array('lang' => 'ACL_U_ATTACH', 'cat' => 'post'), - 'u_download' => array('lang' => 'ACL_U_DOWNLOAD', 'cat' => 'post'), - 'u_savedrafts' => array('lang' => 'ACL_U_SAVEDRAFTS', 'cat' => 'post'), - 'u_chgcensors' => array('lang' => 'ACL_U_CHGCENSORS', 'cat' => 'post'), - 'u_sig' => array('lang' => 'ACL_U_SIG', 'cat' => 'post'), - - 'u_sendpm' => array('lang' => 'ACL_U_SENDPM', 'cat' => 'pm'), - 'u_masspm' => array('lang' => 'ACL_U_MASSPM', 'cat' => 'pm'), - 'u_masspm_group'=> array('lang' => 'ACL_U_MASSPM_GROUP', 'cat' => 'pm'), - 'u_readpm' => array('lang' => 'ACL_U_READPM', 'cat' => 'pm'), - 'u_pm_edit' => array('lang' => 'ACL_U_PM_EDIT', 'cat' => 'pm'), - 'u_pm_delete' => array('lang' => 'ACL_U_PM_DELETE', 'cat' => 'pm'), - 'u_pm_forward' => array('lang' => 'ACL_U_PM_FORWARD', 'cat' => 'pm'), - 'u_pm_emailpm' => array('lang' => 'ACL_U_PM_EMAILPM', 'cat' => 'pm'), - 'u_pm_printpm' => array('lang' => 'ACL_U_PM_PRINTPM', 'cat' => 'pm'), - 'u_pm_attach' => array('lang' => 'ACL_U_PM_ATTACH', 'cat' => 'pm'), - 'u_pm_download' => array('lang' => 'ACL_U_PM_DOWNLOAD', 'cat' => 'pm'), - 'u_pm_bbcode' => array('lang' => 'ACL_U_PM_BBCODE', 'cat' => 'pm'), - 'u_pm_smilies' => array('lang' => 'ACL_U_PM_SMILIES', 'cat' => 'pm'), - 'u_pm_img' => array('lang' => 'ACL_U_PM_IMG', 'cat' => 'pm'), - 'u_pm_flash' => array('lang' => 'ACL_U_PM_FLASH', 'cat' => 'pm'), - - 'u_sendemail' => array('lang' => 'ACL_U_SENDEMAIL', 'cat' => 'misc'), - 'u_sendim' => array('lang' => 'ACL_U_SENDIM', 'cat' => 'misc'), - 'u_ignoreflood' => array('lang' => 'ACL_U_IGNOREFLOOD', 'cat' => 'misc'), - 'u_hideonline' => array('lang' => 'ACL_U_HIDEONLINE', 'cat' => 'misc'), - 'u_viewonline' => array('lang' => 'ACL_U_VIEWONLINE', 'cat' => 'misc'), - 'u_search' => array('lang' => 'ACL_U_SEARCH', 'cat' => 'misc'), - - // Forum Permissions - 'f_list' => array('lang' => 'ACL_F_LIST', 'cat' => 'actions'), - 'f_list_topics' => array('lang' => 'ACL_F_LIST_TOPICS', 'cat' => 'actions'), - 'f_read' => array('lang' => 'ACL_F_READ', 'cat' => 'actions'), - 'f_search' => array('lang' => 'ACL_F_SEARCH', 'cat' => 'actions'), - 'f_subscribe' => array('lang' => 'ACL_F_SUBSCRIBE', 'cat' => 'actions'), - 'f_print' => array('lang' => 'ACL_F_PRINT', 'cat' => 'actions'), - 'f_email' => array('lang' => 'ACL_F_EMAIL', 'cat' => 'actions'), - 'f_bump' => array('lang' => 'ACL_F_BUMP', 'cat' => 'actions'), - 'f_user_lock' => array('lang' => 'ACL_F_USER_LOCK', 'cat' => 'actions'), - 'f_download' => array('lang' => 'ACL_F_DOWNLOAD', 'cat' => 'actions'), - 'f_report' => array('lang' => 'ACL_F_REPORT', 'cat' => 'actions'), - - 'f_post' => array('lang' => 'ACL_F_POST', 'cat' => 'post'), - 'f_sticky' => array('lang' => 'ACL_F_STICKY', 'cat' => 'post'), - 'f_announce' => array('lang' => 'ACL_F_ANNOUNCE', 'cat' => 'post'), - 'f_announce_global' => array('lang' => 'ACL_F_ANNOUNCE_GLOBAL', 'cat' => 'post'), - 'f_reply' => array('lang' => 'ACL_F_REPLY', 'cat' => 'post'), - 'f_edit' => array('lang' => 'ACL_F_EDIT', 'cat' => 'post'), - 'f_delete' => array('lang' => 'ACL_F_DELETE', 'cat' => 'post'), - 'f_softdelete' => array('lang' => 'ACL_F_SOFTDELETE', 'cat' => 'post'), - 'f_ignoreflood' => array('lang' => 'ACL_F_IGNOREFLOOD', 'cat' => 'post'), - 'f_postcount' => array('lang' => 'ACL_F_POSTCOUNT', 'cat' => 'post'), - 'f_noapprove' => array('lang' => 'ACL_F_NOAPPROVE', 'cat' => 'post'), - - 'f_attach' => array('lang' => 'ACL_F_ATTACH', 'cat' => 'content'), - 'f_icons' => array('lang' => 'ACL_F_ICONS', 'cat' => 'content'), - 'f_bbcode' => array('lang' => 'ACL_F_BBCODE', 'cat' => 'content'), - 'f_flash' => array('lang' => 'ACL_F_FLASH', 'cat' => 'content'), - 'f_img' => array('lang' => 'ACL_F_IMG', 'cat' => 'content'), - 'f_sigs' => array('lang' => 'ACL_F_SIGS', 'cat' => 'content'), - 'f_smilies' => array('lang' => 'ACL_F_SMILIES', 'cat' => 'content'), - - 'f_poll' => array('lang' => 'ACL_F_POLL', 'cat' => 'polls'), - 'f_vote' => array('lang' => 'ACL_F_VOTE', 'cat' => 'polls'), - 'f_votechg' => array('lang' => 'ACL_F_VOTECHG', 'cat' => 'polls'), - - // Moderator Permissions - 'm_edit' => array('lang' => 'ACL_M_EDIT', 'cat' => 'post_actions'), - 'm_delete' => array('lang' => 'ACL_M_DELETE', 'cat' => 'post_actions'), - 'm_approve' => array('lang' => 'ACL_M_APPROVE', 'cat' => 'post_actions'), - 'm_report' => array('lang' => 'ACL_M_REPORT', 'cat' => 'post_actions'), - 'm_chgposter' => array('lang' => 'ACL_M_CHGPOSTER', 'cat' => 'post_actions'), - 'm_info' => array('lang' => 'ACL_M_INFO', 'cat' => 'post_actions'), - 'm_softdelete' => array('lang' => 'ACL_M_SOFTDELETE', 'cat' => 'post_actions'), - - 'm_move' => array('lang' => 'ACL_M_MOVE', 'cat' => 'topic_actions'), - 'm_lock' => array('lang' => 'ACL_M_LOCK', 'cat' => 'topic_actions'), - 'm_split' => array('lang' => 'ACL_M_SPLIT', 'cat' => 'topic_actions'), - 'm_merge' => array('lang' => 'ACL_M_MERGE', 'cat' => 'topic_actions'), - - 'm_warn' => array('lang' => 'ACL_M_WARN', 'cat' => 'misc'), - 'm_pm_report' => array('lang' => 'ACL_M_PM_REPORT', 'cat' => 'misc'), - 'm_ban' => array('lang' => 'ACL_M_BAN', 'cat' => 'misc'), - - // Admin Permissions - 'a_board' => array('lang' => 'ACL_A_BOARD', 'cat' => 'settings'), - 'a_server' => array('lang' => 'ACL_A_SERVER', 'cat' => 'settings'), - 'a_jabber' => array('lang' => 'ACL_A_JABBER', 'cat' => 'settings'), - 'a_phpinfo' => array('lang' => 'ACL_A_PHPINFO', 'cat' => 'settings'), - - 'a_forum' => array('lang' => 'ACL_A_FORUM', 'cat' => 'forums'), - 'a_forumadd' => array('lang' => 'ACL_A_FORUMADD', 'cat' => 'forums'), - 'a_forumdel' => array('lang' => 'ACL_A_FORUMDEL', 'cat' => 'forums'), - 'a_prune' => array('lang' => 'ACL_A_PRUNE', 'cat' => 'forums'), - - 'a_icons' => array('lang' => 'ACL_A_ICONS', 'cat' => 'posting'), - 'a_words' => array('lang' => 'ACL_A_WORDS', 'cat' => 'posting'), - 'a_bbcode' => array('lang' => 'ACL_A_BBCODE', 'cat' => 'posting'), - 'a_attach' => array('lang' => 'ACL_A_ATTACH', 'cat' => 'posting'), - - 'a_user' => array('lang' => 'ACL_A_USER', 'cat' => 'user_group'), - 'a_userdel' => array('lang' => 'ACL_A_USERDEL', 'cat' => 'user_group'), - 'a_group' => array('lang' => 'ACL_A_GROUP', 'cat' => 'user_group'), - 'a_groupadd' => array('lang' => 'ACL_A_GROUPADD', 'cat' => 'user_group'), - 'a_groupdel' => array('lang' => 'ACL_A_GROUPDEL', 'cat' => 'user_group'), - 'a_ranks' => array('lang' => 'ACL_A_RANKS', 'cat' => 'user_group'), - 'a_profile' => array('lang' => 'ACL_A_PROFILE', 'cat' => 'user_group'), - 'a_names' => array('lang' => 'ACL_A_NAMES', 'cat' => 'user_group'), - 'a_ban' => array('lang' => 'ACL_A_BAN', 'cat' => 'user_group'), - - 'a_viewauth' => array('lang' => 'ACL_A_VIEWAUTH', 'cat' => 'permissions'), - 'a_authgroups' => array('lang' => 'ACL_A_AUTHGROUPS', 'cat' => 'permissions'), - 'a_authusers' => array('lang' => 'ACL_A_AUTHUSERS', 'cat' => 'permissions'), - 'a_fauth' => array('lang' => 'ACL_A_FAUTH', 'cat' => 'permissions'), - 'a_mauth' => array('lang' => 'ACL_A_MAUTH', 'cat' => 'permissions'), - 'a_aauth' => array('lang' => 'ACL_A_AAUTH', 'cat' => 'permissions'), - 'a_uauth' => array('lang' => 'ACL_A_UAUTH', 'cat' => 'permissions'), - 'a_roles' => array('lang' => 'ACL_A_ROLES', 'cat' => 'permissions'), - 'a_switchperm' => array('lang' => 'ACL_A_SWITCHPERM', 'cat' => 'permissions'), - - 'a_styles' => array('lang' => 'ACL_A_STYLES', 'cat' => 'misc'), - 'a_extensions' => array('lang' => 'ACL_A_EXTENSIONS', 'cat' => 'misc'), - 'a_viewlogs' => array('lang' => 'ACL_A_VIEWLOGS', 'cat' => 'misc'), - 'a_clearlogs' => array('lang' => 'ACL_A_CLEARLOGS', 'cat' => 'misc'), - 'a_modules' => array('lang' => 'ACL_A_MODULES', 'cat' => 'misc'), - 'a_language' => array('lang' => 'ACL_A_LANGUAGE', 'cat' => 'misc'), - 'a_email' => array('lang' => 'ACL_A_EMAIL', 'cat' => 'misc'), - 'a_bots' => array('lang' => 'ACL_A_BOTS', 'cat' => 'misc'), - 'a_reasons' => array('lang' => 'ACL_A_REASONS', 'cat' => 'misc'), - 'a_backup' => array('lang' => 'ACL_A_BACKUP', 'cat' => 'misc'), - 'a_search' => array('lang' => 'ACL_A_SEARCH', 'cat' => 'misc'), - ); -} diff --git a/install/update/old/phpbb/plupload/plupload.php b/install/update/old/phpbb/plupload/plupload.php deleted file mode 100644 index eb698fb..0000000 --- a/install/update/old/phpbb/plupload/plupload.php +++ /dev/null @@ -1,402 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\plupload; - -/** -* This class handles all server-side plupload functions -*/ -class plupload -{ - /** - * @var string - */ - protected $phpbb_root_path; - - /** - * @var \phpbb\config\config - */ - protected $config; - - /** - * @var \phpbb\request\request_interface - */ - protected $request; - - /** - * @var \phpbb\user - */ - protected $user; - - /** - * @var \bantu\IniGetWrapper\IniGetWrapper - */ - protected $php_ini; - - /** - * @var \phpbb\mimetype\guesser - */ - protected $mimetype_guesser; - - /** - * Final destination for uploaded files, i.e. the "files" directory. - * @var string - */ - protected $upload_directory; - - /** - * Temporary upload directory for plupload uploads. - * @var string - */ - protected $temporary_directory; - - /** - * Constructor. - * - * @param string $phpbb_root_path - * @param \phpbb\config\config $config - * @param \phpbb\request\request_interface $request - * @param \phpbb\user $user - * @param \bantu\IniGetWrapper\IniGetWrapper $php_ini - * @param \phpbb\mimetype\guesser $mimetype_guesser - */ - public function __construct($phpbb_root_path, \phpbb\config\config $config, \phpbb\request\request_interface $request, \phpbb\user $user, \bantu\IniGetWrapper\IniGetWrapper $php_ini, \phpbb\mimetype\guesser $mimetype_guesser) - { - $this->phpbb_root_path = $phpbb_root_path; - $this->config = $config; - $this->request = $request; - $this->user = $user; - $this->php_ini = $php_ini; - $this->mimetype_guesser = $mimetype_guesser; - - $this->set_default_directories(); - } - - /** - * Plupload allows for chunking so we must check for that and assemble - * the whole file first before performing any checks on it. - * - * @param string $form_name The name of the file element in the upload form - * - * @return array|null null if there are no chunks to piece together - * otherwise array containing the path to the - * pieced-together file and its size - */ - public function handle_upload($form_name) - { - $chunks_expected = $this->request->variable('chunks', 0); - - // If chunking is disabled or we are not using plupload, just return - // and handle the file as usual - if ($chunks_expected < 2) - { - return; - } - - $file_name = $this->request->variable('name', ''); - $chunk = $this->request->variable('chunk', 0); - - $this->user->add_lang('plupload'); - $this->prepare_temporary_directory(); - - $file_path = $this->temporary_filepath($file_name); - $this->integrate_uploaded_file($form_name, $chunk, $file_path); - - // If we are done with all the chunks, strip the .part suffix and then - // handle the resulting file as normal, otherwise die and await the - // next chunk. - if ($chunk == $chunks_expected - 1) - { - rename("{$file_path}.part", $file_path); - - // Reset upload directories to defaults once completed - $this->set_default_directories(); - - // Need to modify some of the $_FILES values to reflect the new file - return array( - 'tmp_name' => $file_path, - 'name' => $this->request->variable('real_filename', '', true), - 'size' => filesize($file_path), - 'type' => $this->mimetype_guesser->guess($file_path, $file_name), - ); - } - else - { - $json_response = new \phpbb\json_response(); - $json_response->send(array( - 'jsonrpc' => '2.0', - 'id' => 'id', - 'result' => null, - )); - } - } - - /** - * Fill in the plupload configuration options in the template - * - * @param \phpbb\cache\service $cache - * @param \phpbb\template\template $template - * @param string $s_action The URL to submit the POST data to - * @param int $forum_id The ID of the forum - * @param int $max_files Maximum number of files allowed. 0 for unlimited. - * - * @return null - */ - public function configure(\phpbb\cache\service $cache, \phpbb\template\template $template, $s_action, $forum_id, $max_files) - { - $filters = $this->generate_filter_string($cache, $forum_id); - $chunk_size = $this->get_chunk_size(); - $resize = $this->generate_resize_string(); - - $template->assign_vars(array( - 'S_RESIZE' => $resize, - 'S_PLUPLOAD' => true, - 'FILTERS' => $filters, - 'CHUNK_SIZE' => $chunk_size, - 'S_PLUPLOAD_URL' => htmlspecialchars_decode($s_action), - 'MAX_ATTACHMENTS' => $max_files, - 'ATTACH_ORDER' => ($this->config['display_order']) ? 'asc' : 'desc', - 'L_TOO_MANY_ATTACHMENTS' => $this->user->lang('TOO_MANY_ATTACHMENTS', $max_files), - )); - - $this->user->add_lang('plupload'); - } - - /** - * Checks whether the page request was sent by plupload or not - * - * @return bool - */ - public function is_active() - { - return $this->request->header('X-PHPBB-USING-PLUPLOAD', false); - } - - /** - * Returns whether the current HTTP request is a multipart request. - * - * @return bool - */ - public function is_multipart() - { - $content_type = $this->request->server('CONTENT_TYPE'); - - return strpos($content_type, 'multipart') === 0; - } - - /** - * Sends an error message back to the client via JSON response - * - * @param int $code The error code - * @param string $msg The translation string of the message to be sent - * - * @return null - */ - public function emit_error($code, $msg) - { - $json_response = new \phpbb\json_response(); - $json_response->send(array( - 'jsonrpc' => '2.0', - 'id' => 'id', - 'error' => array( - 'code' => $code, - 'message' => $this->user->lang($msg), - ), - )); - } - - /** - * Looks at the list of allowed extensions and generates a string - * appropriate for use in configuring plupload with - * - * @param \phpbb\cache\service $cache - * @param string $forum_id The ID of the forum - * - * @return string - */ - public function generate_filter_string(\phpbb\cache\service $cache, $forum_id) - { - $attach_extensions = $cache->obtain_attach_extensions($forum_id); - unset($attach_extensions['_allowed_']); - $groups = array(); - - // Re-arrange the extension array to $groups[$group_name][] - foreach ($attach_extensions as $extension => $extension_info) - { - if (!isset($groups[$extension_info['group_name']])) - { - $groups[$extension_info['group_name']] = array(); - } - - $groups[$extension_info['group_name']][] = $extension; - } - - $filters = array(); - foreach ($groups as $group => $extensions) - { - $filters[] = sprintf( - "{title: '%s', extensions: '%s'}", - addslashes(ucfirst(strtolower($group))), - addslashes(implode(',', $extensions)) - ); - } - - return implode(',', $filters); - } - - /** - * Generates a string that is used to tell plupload to automatically resize - * files before uploading them. - * - * @return string - */ - public function generate_resize_string() - { - $resize = ''; - if ($this->config['img_max_height'] > 0 && $this->config['img_max_width'] > 0) - { - $resize = sprintf( - 'resize: {width: %d, height: %d, quality: 85},', - (int) $this->config['img_max_width'], - (int) $this->config['img_max_height'] - ); - } - - return $resize; - } - - /** - * Checks various php.ini values and the maximum file size to determine - * the maximum size chunks a file can be split up into for upload - * - * @return int - */ - public function get_chunk_size() - { - $max = min( - $this->php_ini->getBytes('upload_max_filesize'), - $this->php_ini->getBytes('post_max_size'), - max(1, $this->php_ini->getBytes('memory_limit')), - $this->config['max_filesize'] - ); - - // Use half of the maximum possible to leave plenty of room for other - // POST data. - return floor($max / 2); - } - - protected function temporary_filepath($file_name) - { - // Must preserve the extension for plupload to work. - return sprintf( - '%s/%s_%s%s', - $this->temporary_directory, - $this->config['plupload_salt'], - md5($file_name), - \phpbb\files\filespec::get_extension($file_name) - ); - } - - /** - * Checks whether the chunk we are about to deal with was actually uploaded - * by PHP and actually exists, if not, it generates an error - * - * @param string $form_name The name of the file in the form data - * - * @return null - */ - protected function integrate_uploaded_file($form_name, $chunk, $file_path) - { - $is_multipart = $this->is_multipart(); - $upload = $this->request->file($form_name); - if ($is_multipart && (!isset($upload['tmp_name']) || !is_uploaded_file($upload['tmp_name']))) - { - $this->emit_error(103, 'PLUPLOAD_ERR_MOVE_UPLOADED'); - } - - $tmp_file = $this->temporary_filepath($upload['tmp_name']); - - if (!phpbb_is_writable($this->temporary_directory) || !move_uploaded_file($upload['tmp_name'], $tmp_file)) - { - $this->emit_error(103, 'PLUPLOAD_ERR_MOVE_UPLOADED'); - } - - $out = fopen("{$file_path}.part", $chunk == 0 ? 'wb' : 'ab'); - if (!$out) - { - $this->emit_error(102, 'PLUPLOAD_ERR_OUTPUT'); - } - - $in = fopen(($is_multipart) ? $tmp_file : 'php://input', 'rb'); - if (!$in) - { - $this->emit_error(101, 'PLUPLOAD_ERR_INPUT'); - } - - while ($buf = fread($in, 4096)) - { - fwrite($out, $buf); - } - - fclose($in); - fclose($out); - - if ($is_multipart) - { - unlink($tmp_file); - } - } - - /** - * Creates the temporary directory if it does not already exist. - * - * @return null - */ - protected function prepare_temporary_directory() - { - if (!file_exists($this->temporary_directory)) - { - mkdir($this->temporary_directory); - - copy( - $this->upload_directory . '/index.htm', - $this->temporary_directory . '/index.htm' - ); - } - } - - /** - * Sets the default directories for uploads - * - * @return null - */ - protected function set_default_directories() - { - $this->upload_directory = $this->phpbb_root_path . $this->config['upload_path']; - $this->temporary_directory = $this->upload_directory . '/plupload'; - } - - /** - * Sets the upload directories to the specified paths - * - * @param string $upload_directory Upload directory - * @param string $temporary_directory Temporary directory - * - * @return null - */ - public function set_upload_directories($upload_directory, $temporary_directory) - { - $this->upload_directory = $upload_directory; - $this->temporary_directory = $temporary_directory; - } -} diff --git a/install/update/old/phpbb/report/report_handler.php b/install/update/old/phpbb/report/report_handler.php deleted file mode 100644 index 854318c..0000000 --- a/install/update/old/phpbb/report/report_handler.php +++ /dev/null @@ -1,104 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\report; - -abstract class report_handler implements report_handler_interface -{ - /** - * @var \phpbb\db\driver\driver_interface - */ - protected $db; - - /** - * @var \phpbb\event\dispatcher_interface - */ - protected $dispatcher; - - /** - * @var \phpbb\config\config - */ - protected $config; - - /** - * @var \phpbb\auth\auth - */ - protected $auth; - - /** - * @var \phpbb\user - */ - protected $user; - - /** - * @var \phpbb\notification\manager - */ - protected $notifications; - - /** - * @var array - */ - protected $report_data; - - /** - * Construtor - * - * @param \phpbb\db\driver\driver_interface $db - * @param \phpbb\event\dispatcher_interface $dispatcher - * @param \phpbb\config\db $config - * @param \phpbb\auth\auth $auth - * @param \phpbb\user $user - * @param \phpbb\notification\manager $notification - */ - public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\event\dispatcher_interface $dispatcher, \phpbb\config\config $config, \phpbb\auth\auth $auth, \phpbb\user $user, \phpbb\notification\manager $notification) - { - $this->db = $db; - $this->dispatcher = $dispatcher; - $this->config = $config; - $this->auth = $auth; - $this->user = $user; - $this->notifications = $notification; - $this->report_data = array(); - } - - /** - * Creates a report entity in the database - * - * @param array $report_data - * @return int the ID of the created entity - */ - protected function create_report(array $report_data) - { - $sql_ary = array( - 'reason_id' => (int) $report_data['reason_id'], - 'post_id' => $report_data['post_id'], - 'pm_id' => $report_data['pm_id'], - 'user_id' => (int) $this->user->data['user_id'], - 'user_notify' => (int) $report_data['user_notify'], - 'report_closed' => 0, - 'report_time' => (int) time(), - 'report_text' => (string) $report_data['report_text'], - 'reported_post_text' => $report_data['reported_post_text'], - 'reported_post_uid' => $report_data['reported_post_uid'], - 'reported_post_bitfield' => $report_data['reported_post_bitfield'], - 'reported_post_enable_bbcode' => $report_data['reported_post_enable_bbcode'], - 'reported_post_enable_smilies' => $report_data['reported_post_enable_smilies'], - 'reported_post_enable_magic_url' => $report_data['reported_post_enable_magic_url'], - ); - - $sql = 'INSERT INTO ' . REPORTS_TABLE . ' ' . $this->db->sql_build_array('INSERT', $sql_ary); - $this->db->sql_query($sql); - - return $this->db->sql_nextid(); - } -} diff --git a/install/update/old/phpbb/request/request.php b/install/update/old/phpbb/request/request.php deleted file mode 100644 index a0267d1..0000000 --- a/install/update/old/phpbb/request/request.php +++ /dev/null @@ -1,454 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\request; - -/** -* All application input is accessed through this class. -* -* It provides a method to disable access to input data through super globals. -* This should force MOD authors to read about data validation. -*/ -class request implements \phpbb\request\request_interface -{ - /** - * @var array The names of super global variables that this class should protect if super globals are disabled. - */ - protected $super_globals = array( - \phpbb\request\request_interface::POST => '_POST', - \phpbb\request\request_interface::GET => '_GET', - \phpbb\request\request_interface::REQUEST => '_REQUEST', - \phpbb\request\request_interface::COOKIE => '_COOKIE', - \phpbb\request\request_interface::SERVER => '_SERVER', - \phpbb\request\request_interface::FILES => '_FILES', - ); - - /** - * @var array Stores original contents of $_REQUEST array. - */ - protected $original_request = null; - - /** - * @var - */ - protected $super_globals_disabled = false; - - /** - * @var array An associative array that has the value of super global constants as keys and holds their data as values. - */ - protected $input; - - /** - * @var \phpbb\request\type_cast_helper_interface An instance of a type cast helper providing convenience methods for type conversions. - */ - protected $type_cast_helper; - - /** - * Initialises the request class, that means it stores all input data in {@link $input input} - * and then calls {@link \phpbb\request\deactivated_super_global \phpbb\request\deactivated_super_global} - */ - public function __construct(\phpbb\request\type_cast_helper_interface $type_cast_helper = null, $disable_super_globals = true) - { - if ($type_cast_helper) - { - $this->type_cast_helper = $type_cast_helper; - } - else - { - $this->type_cast_helper = new \phpbb\request\type_cast_helper(); - } - - foreach ($this->super_globals as $const => $super_global) - { - $this->input[$const] = isset($GLOBALS[$super_global]) ? $GLOBALS[$super_global] : array(); - } - - // simulate request_order = GP - $this->original_request = $this->input[\phpbb\request\request_interface::REQUEST]; - $this->input[\phpbb\request\request_interface::REQUEST] = $this->input[\phpbb\request\request_interface::POST] + $this->input[\phpbb\request\request_interface::GET]; - - if ($disable_super_globals) - { - $this->disable_super_globals(); - } - } - - /** - * Getter for $super_globals_disabled - * - * @return bool Whether super globals are disabled or not. - */ - public function super_globals_disabled() - { - return $this->super_globals_disabled; - } - - /** - * Disables access of super globals specified in $super_globals. - * This is achieved by overwriting the super globals with instances of {@link \phpbb\request\deactivated_super_global \phpbb\request\deactivated_super_global} - */ - public function disable_super_globals() - { - if (!$this->super_globals_disabled) - { - foreach ($this->super_globals as $const => $super_global) - { - unset($GLOBALS[$super_global]); - $GLOBALS[$super_global] = new \phpbb\request\deactivated_super_global($this, $super_global, $const); - } - - $this->super_globals_disabled = true; - } - } - - /** - * Enables access of super globals specified in $super_globals if they were disabled by {@link disable_super_globals disable_super_globals}. - * This is achieved by making the super globals point to the data stored within this class in {@link $input input}. - */ - public function enable_super_globals() - { - if ($this->super_globals_disabled) - { - foreach ($this->super_globals as $const => $super_global) - { - $GLOBALS[$super_global] = $this->input[$const]; - } - - $GLOBALS['_REQUEST'] = $this->original_request; - - $this->super_globals_disabled = false; - } - } - - /** - * This function allows overwriting or setting a value in one of the super global arrays. - * - * Changes which are performed on the super globals directly will not have any effect on the results of - * other methods this class provides. Using this function should be avoided if possible! It will - * consume twice the the amount of memory of the value - * - * @param string $var_name The name of the variable that shall be overwritten - * @param mixed $value The value which the variable shall contain. - * If this is null the variable will be unset. - * @param \phpbb\request\request_interface::POST|GET|REQUEST|COOKIE $super_global - * Specifies which super global shall be changed - */ - public function overwrite($var_name, $value, $super_global = \phpbb\request\request_interface::REQUEST) - { - if (!isset($this->super_globals[$super_global])) - { - return; - } - - // setting to null means unsetting - if ($value === null) - { - unset($this->input[$super_global][$var_name]); - if (!$this->super_globals_disabled()) - { - unset($GLOBALS[$this->super_globals[$super_global]][$var_name]); - } - } - else - { - $this->input[$super_global][$var_name] = $value; - if (!$this->super_globals_disabled()) - { - $GLOBALS[$this->super_globals[$super_global]][$var_name] = $value; - } - } - } - - /** - * Central type safe input handling function. - * All variables in GET or POST requests should be retrieved through this function to maximise security. - * - * @param string|array $var_name The form variable's name from which data shall be retrieved. - * If the value is an array this may be an array of indizes which will give - * direct access to a value at any depth. E.g. if the value of "var" is array(1 => "a") - * then specifying array("var", 1) as the name will return "a". - * @param mixed $default A default value that is returned if the variable was not set. - * This function will always return a value of the same type as the default. - * @param bool $multibyte If $default is a string this paramater has to be true if the variable may contain any UTF-8 characters - * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks - * @param \phpbb\request\request_interface::POST|GET|REQUEST|COOKIE $super_global - * Specifies which super global should be used - * - * @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the - * the same as that of $default. If the variable is not set $default is returned. - */ - public function variable($var_name, $default, $multibyte = false, $super_global = \phpbb\request\request_interface::REQUEST) - { - return $this->_variable($var_name, $default, $multibyte, $super_global, true); - } - - /** - * Get a variable, but without trimming strings. - * Same functionality as variable(), except does not run trim() on strings. - * This method should be used when handling passwords. - * - * @param string|array $var_name The form variable's name from which data shall be retrieved. - * If the value is an array this may be an array of indizes which will give - * direct access to a value at any depth. E.g. if the value of "var" is array(1 => "a") - * then specifying array("var", 1) as the name will return "a". - * @param mixed $default A default value that is returned if the variable was not set. - * This function will always return a value of the same type as the default. - * @param bool $multibyte If $default is a string this paramater has to be true if the variable may contain any UTF-8 characters - * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks - * @param \phpbb\request\request_interface::POST|GET|REQUEST|COOKIE $super_global - * Specifies which super global should be used - * - * @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the - * the same as that of $default. If the variable is not set $default is returned. - */ - public function untrimmed_variable($var_name, $default, $multibyte = false, $super_global = \phpbb\request\request_interface::REQUEST) - { - return $this->_variable($var_name, $default, $multibyte, $super_global, false); - } - - /** - * {@inheritdoc} - */ - public function raw_variable($var_name, $default, $super_global = \phpbb\request\request_interface::REQUEST) - { - $path = false; - - // deep direct access to multi dimensional arrays - if (is_array($var_name)) - { - $path = $var_name; - // make sure at least the variable name is specified - if (empty($path)) - { - return (is_array($default)) ? array() : $default; - } - // the variable name is the first element on the path - $var_name = array_shift($path); - } - - if (!isset($this->input[$super_global][$var_name])) - { - return (is_array($default)) ? array() : $default; - } - $var = $this->input[$super_global][$var_name]; - - if ($path) - { - // walk through the array structure and find the element we are looking for - foreach ($path as $key) - { - if (is_array($var) && isset($var[$key])) - { - $var = $var[$key]; - } - else - { - return (is_array($default)) ? array() : $default; - } - } - } - - return $var; - } - - /** - * Shortcut method to retrieve SERVER variables. - * - * Also fall back to getenv(), some CGI setups may need it (probably not, but - * whatever). - * - * @param string|array $var_name See \phpbb\request\request_interface::variable - * @param mixed $Default See \phpbb\request\request_interface::variable - * - * @return mixed The server variable value. - */ - public function server($var_name, $default = '') - { - $multibyte = true; - - if ($this->is_set($var_name, \phpbb\request\request_interface::SERVER)) - { - return $this->variable($var_name, $default, $multibyte, \phpbb\request\request_interface::SERVER); - } - else - { - $var = getenv($var_name); - $this->type_cast_helper->recursive_set_var($var, $default, $multibyte); - return $var; - } - } - - /** - * Shortcut method to retrieve the value of client HTTP headers. - * - * @param string|array $header_name The name of the header to retrieve. - * @param mixed $default See \phpbb\request\request_interface::variable - * - * @return mixed The header value. - */ - public function header($header_name, $default = '') - { - $var_name = 'HTTP_' . str_replace('-', '_', strtoupper($header_name)); - return $this->server($var_name, $default); - } - - /** - * Shortcut method to retrieve $_FILES variables - * - * @param string $form_name The name of the file input form element - * - * @return array The uploaded file's information or an empty array if the - * variable does not exist in _FILES. - */ - public function file($form_name) - { - return $this->variable($form_name, array('name' => 'none'), true, \phpbb\request\request_interface::FILES); - } - - /** - * Checks whether a certain variable was sent via POST. - * To make sure that a request was sent using POST you should call this function - * on at least one variable. - * - * @param string $name The name of the form variable which should have a - * _p suffix to indicate the check in the code that creates the form too. - * - * @return bool True if the variable was set in a POST request, false otherwise. - */ - public function is_set_post($name) - { - return $this->is_set($name, \phpbb\request\request_interface::POST); - } - - /** - * Checks whether a certain variable is set in one of the super global - * arrays. - * - * @param string $var Name of the variable - * @param \phpbb\request\request_interface::POST|GET|REQUEST|COOKIE $super_global - * Specifies the super global which shall be checked - * - * @return bool True if the variable was sent as input - */ - public function is_set($var, $super_global = \phpbb\request\request_interface::REQUEST) - { - return isset($this->input[$super_global][$var]); - } - - /** - * Checks whether the current request is an AJAX request (XMLHttpRequest) - * - * @return bool True if the current request is an ajax request - */ - public function is_ajax() - { - return $this->header('X-Requested-With') == 'XMLHttpRequest'; - } - - /** - * Checks if the current request is happening over HTTPS. - * - * @return bool True if the request is secure. - */ - public function is_secure() - { - $https = $this->server('HTTPS'); - $https = $this->server('HTTP_X_FORWARDED_PROTO') === 'https' ? 'on' : $https; - return !empty($https) && $https !== 'off'; - } - - /** - * Returns all variable names for a given super global - * - * @param \phpbb\request\request_interface::POST|GET|REQUEST|COOKIE $super_global - * The super global from which names shall be taken - * - * @return array All variable names that are set for the super global. - * Pay attention when using these, they are unsanitised! - */ - public function variable_names($super_global = \phpbb\request\request_interface::REQUEST) - { - if (!isset($this->input[$super_global])) - { - return array(); - } - - return array_keys($this->input[$super_global]); - } - - /** - * Helper function used by variable() and untrimmed_variable(). - * - * @param string|array $var_name The form variable's name from which data shall be retrieved. - * If the value is an array this may be an array of indizes which will give - * direct access to a value at any depth. E.g. if the value of "var" is array(1 => "a") - * then specifying array("var", 1) as the name will return "a". - * @param mixed $default A default value that is returned if the variable was not set. - * This function will always return a value of the same type as the default. - * @param bool $multibyte If $default is a string this paramater has to be true if the variable may contain any UTF-8 characters - * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks - * @param \phpbb\request\request_interface::POST|GET|REQUEST|COOKIE $super_global - * Specifies which super global should be used - * @param bool $trim Indicates whether trim() should be applied to string values. - * - * @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the - * the same as that of $default. If the variable is not set $default is returned. - */ - protected function _variable($var_name, $default, $multibyte = false, $super_global = \phpbb\request\request_interface::REQUEST, $trim = true) - { - $var = $this->raw_variable($var_name, $default, $super_global); - - // Return prematurely if raw variable is empty array or the same as - // the default. Using strict comparison to ensure that one can't - // prevent proper type checking on any input variable - if ($var === array() || $var === $default) - { - return $var; - } - - $this->type_cast_helper->recursive_set_var($var, $default, $multibyte, $trim); - - return $var; - } - - /** - * {@inheritdoc} - */ - public function get_super_global($super_global = \phpbb\request\request_interface::REQUEST) - { - return $this->input[$super_global]; - } - - /** - * {@inheritdoc} - */ - public function escape($var, $multibyte) - { - if (is_array($var)) - { - $result = array(); - foreach ($var as $key => $value) - { - $this->type_cast_helper->set_var($key, $key, gettype($key), $multibyte); - $result[$key] = $this->escape($value, $multibyte); - } - $var = $result; - } - else - { - $this->type_cast_helper->set_var($var, $var, 'string', $multibyte); - } - - return $var; - } -} diff --git a/install/update/old/phpbb/request/request_interface.php b/install/update/old/phpbb/request/request_interface.php deleted file mode 100644 index 3bfa8bb..0000000 --- a/install/update/old/phpbb/request/request_interface.php +++ /dev/null @@ -1,177 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\request; - -/** -* An interface through which all application input can be accessed. -*/ -interface request_interface -{ - /**#@+ - * Constant identifying the super global with the same name. - */ - const POST = 0; - const GET = 1; - const REQUEST = 2; - const COOKIE = 3; - const SERVER = 4; - const FILES = 5; - /**#@-*/ - - /** - * This function allows overwriting or setting a value in one of the super global arrays. - * - * Changes which are performed on the super globals directly will not have any effect on the results of - * other methods this class provides. Using this function should be avoided if possible! It will - * consume twice the the amount of memory of the value - * - * @param string $var_name The name of the variable that shall be overwritten - * @param mixed $value The value which the variable shall contain. - * If this is null the variable will be unset. - * @param \phpbb\request\request_interface::POST|GET|REQUEST|COOKIE $super_global - * Specifies which super global shall be changed - */ - public function overwrite($var_name, $value, $super_global = \phpbb\request\request_interface::REQUEST); - - /** - * Central type safe input handling function. - * All variables in GET or POST requests should be retrieved through this function to maximise security. - * - * @param string|array $var_name The form variable's name from which data shall be retrieved. - * If the value is an array this may be an array of indizes which will give - * direct access to a value at any depth. E.g. if the value of "var" is array(1 => "a") - * then specifying array("var", 1) as the name will return "a". - * @param mixed $default A default value that is returned if the variable was not set. - * This function will always return a value of the same type as the default. - * @param bool $multibyte If $default is a string this paramater has to be true if the variable may contain any UTF-8 characters - * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks - * @param \phpbb\request\request_interface::POST|GET|REQUEST|COOKIE $super_global - * Specifies which super global should be used - * - * @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the - * the same as that of $default. If the variable is not set $default is returned. - */ - public function variable($var_name, $default, $multibyte = false, $super_global = \phpbb\request\request_interface::REQUEST); - - /** - * Get a variable without trimming strings and without escaping. - * This method MUST NOT be used with queries. - * Same functionality as variable(), except does not run trim() on strings - * and does not escape input. - * This method should only be used when the raw input is needed without - * any escaping, i.e. for database password during the installation. - * - * @param string|array $var_name The form variable's name from which data shall be retrieved. - * If the value is an array this may be an array of indizes which will give - * direct access to a value at any depth. E.g. if the value of "var" is array(1 => "a") - * then specifying array("var", 1) as the name will return "a". - * @param mixed $default A default value that is returned if the variable was not set. - * This function will always return a value of the same type as the default. - * @param \phpbb\request\request_interface::POST|GET|REQUEST|COOKIE $super_global - * Specifies which super global should be used - * - * @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the - * the same as that of $default. If the variable is not set $default is returned. - */ - public function raw_variable($var_name, $default, $super_global = \phpbb\request\request_interface::REQUEST); - - /** - * Shortcut method to retrieve SERVER variables. - * - * @param string|array $var_name See \phpbb\request\request_interface::variable - * @param mixed $default See \phpbb\request\request_interface::variable - * - * @return mixed The server variable value. - */ - public function server($var_name, $default = ''); - - /** - * Shortcut method to retrieve the value of client HTTP headers. - * - * @param string|array $header_name The name of the header to retrieve. - * @param mixed $default See \phpbb\request\request_interface::variable - * - * @return mixed The header value. - */ - public function header($var_name, $default = ''); - - /** - * Checks whether a certain variable was sent via POST. - * To make sure that a request was sent using POST you should call this function - * on at least one variable. - * - * @param string $name The name of the form variable which should have a - * _p suffix to indicate the check in the code that creates the form too. - * - * @return bool True if the variable was set in a POST request, false otherwise. - */ - public function is_set_post($name); - - /** - * Checks whether a certain variable is set in one of the super global - * arrays. - * - * @param string $var Name of the variable - * @param \phpbb\request\request_interface::POST|GET|REQUEST|COOKIE $super_global - * Specifies the super global which shall be checked - * - * @return bool True if the variable was sent as input - */ - public function is_set($var, $super_global = \phpbb\request\request_interface::REQUEST); - - /** - * Checks whether the current request is an AJAX request (XMLHttpRequest) - * - * @return bool True if the current request is an ajax request - */ - public function is_ajax(); - - /** - * Checks if the current request is happening over HTTPS. - * - * @return bool True if the request is secure. - */ - public function is_secure(); - - /** - * Returns all variable names for a given super global - * - * @param \phpbb\request\request_interface::POST|GET|REQUEST|COOKIE $super_global - * The super global from which names shall be taken - * - * @return array All variable names that are set for the super global. - * Pay attention when using these, they are unsanitised! - */ - public function variable_names($super_global = \phpbb\request\request_interface::REQUEST); - - /** - * Returns the original array of the requested super global - * - * @param \phpbb\request\request_interface::POST|GET|REQUEST|COOKIE $super_global - * The super global which will be returned - * - * @return array The original array of the requested super global. - */ - public function get_super_global($super_global = \phpbb\request\request_interface::REQUEST); - - /** - * Escape a string variable. - * - * @param mixed $value The contents to fill with - * @param bool $multibyte Indicates whether string values may contain UTF-8 characters. - * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks. - * @return string|array - */ - public function escape($value, $multibyte); -} diff --git a/install/update/old/phpbb/request/type_cast_helper.php b/install/update/old/phpbb/request/type_cast_helper.php deleted file mode 100644 index 9124949..0000000 --- a/install/update/old/phpbb/request/type_cast_helper.php +++ /dev/null @@ -1,124 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\request; - -/** -* A helper class that provides convenience methods for type casting. -*/ -class type_cast_helper implements \phpbb\request\type_cast_helper_interface -{ - /** - * Set variable $result to a particular type. - * - * @param mixed &$result The variable to fill - * @param mixed $var The contents to fill with - * @param mixed $type The variable type. Will be used with {@link settype()} - * @param bool $multibyte Indicates whether string values may contain UTF-8 characters. - * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks. - * @param bool $trim Indicates whether trim() should be applied to string values. - * Default is true. - */ - public function set_var(&$result, $var, $type, $multibyte = false, $trim = true) - { - settype($var, $type); - $result = $var; - - if ($type == 'string') - { - $result = str_replace(array("\r\n", "\r", "\0"), array("\n", "\n", ''), $result); - - if ($trim) - { - $result = trim($result); - } - - $result = htmlspecialchars($result, ENT_COMPAT, 'UTF-8'); - - if ($multibyte) - { - $result = utf8_normalize_nfc($result); - } - - if (!empty($result)) - { - // Make sure multibyte characters are wellformed - if ($multibyte) - { - if (!preg_match('/^./u', $result)) - { - $result = ''; - } - } - else - { - // no multibyte, allow only ASCII (0-127) - $result = preg_replace('/[\x80-\xFF]/', '?', $result); - } - } - } - } - - /** - * Recursively sets a variable to a given type using {@link set_var set_var} - * - * @param string $var The value which shall be sanitised (passed by reference). - * @param mixed $default Specifies the type $var shall have. - * If it is an array and $var is not one, then an empty array is returned. - * Otherwise var is cast to the same type, and if $default is an array all - * keys and values are cast recursively using this function too. - * @param bool $multibyte Indicates whether string keys and values may contain UTF-8 characters. - * Default is false, causing all bytes outside the ASCII range (0-127) to - * be replaced with question marks. - * @param bool $trim Indicates whether trim() should be applied to string values. - * Default is true. - */ - public function recursive_set_var(&$var, $default, $multibyte, $trim = true) - { - if (is_array($var) !== is_array($default)) - { - $var = (is_array($default)) ? array() : $default; - return; - } - - if (!is_array($default)) - { - $type = gettype($default); - $this->set_var($var, $var, $type, $multibyte, $trim); - } - else - { - // make sure there is at least one key/value pair to use get the - // types from - if (empty($default)) - { - $var = array(); - return; - } - - list($default_key, $default_value) = each($default); - $key_type = gettype($default_key); - - $_var = $var; - $var = array(); - - foreach ($_var as $k => $v) - { - $this->set_var($k, $k, $key_type, $multibyte); - - $this->recursive_set_var($v, $default_value, $multibyte, $trim); - $var[$k] = $v; - } - } - } -} diff --git a/install/update/old/phpbb/search/fulltext_mysql.php b/install/update/old/phpbb/search/fulltext_mysql.php deleted file mode 100644 index 137ed74..0000000 --- a/install/update/old/phpbb/search/fulltext_mysql.php +++ /dev/null @@ -1,1227 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\search; - -/** -* Fulltext search for MySQL -*/ -class fulltext_mysql extends \phpbb\search\base -{ - /** - * Associative array holding index stats - * @var array - */ - protected $stats = array(); - - /** - * Holds the words entered by user, obtained by splitting the entered query on whitespace - * @var array - */ - protected $split_words = array(); - - /** - * Config object - * @var \phpbb\config\config - */ - protected $config; - - /** - * Database connection - * @var \phpbb\db\driver\driver_interface - */ - protected $db; - - /** - * phpBB event dispatcher object - * @var \phpbb\event\dispatcher_interface - */ - protected $phpbb_dispatcher; - - /** - * User object - * @var \phpbb\user - */ - protected $user; - - /** - * Associative array stores the min and max word length to be searched - * @var array - */ - protected $word_length = array(); - - /** - * Contains tidied search query. - * Operators are prefixed in search query and common words excluded - * @var string - */ - protected $search_query; - - /** - * Contains common words. - * Common words are words with length less/more than min/max length - * @var array - */ - protected $common_words = array(); - - /** - * Constructor - * Creates a new \phpbb\search\fulltext_mysql, which is used as a search backend - * - * @param string|bool $error Any error that occurs is passed on through this reference variable otherwise false - * @param string $phpbb_root_path Relative path to phpBB root - * @param string $phpEx PHP file extension - * @param \phpbb\auth\auth $auth Auth object - * @param \phpbb\config\config $config Config object - * @param \phpbb\db\driver\driver_interface Database object - * @param \phpbb\user $user User object - * @param \phpbb\event\dispatcher_interface $phpbb_dispatcher Event dispatcher object - */ - public function __construct(&$error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher) - { - $this->config = $config; - $this->db = $db; - $this->phpbb_dispatcher = $phpbb_dispatcher; - $this->user = $user; - - $this->word_length = array('min' => $this->config['fulltext_mysql_min_word_len'], 'max' => $this->config['fulltext_mysql_max_word_len']); - - /** - * Load the UTF tools - */ - if (!function_exists('utf8_strlen')) - { - include($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); - } - - $error = false; - } - - /** - * Returns the name of this search backend to be displayed to administrators - * - * @return string Name - */ - public function get_name() - { - return 'MySQL Fulltext'; - } - - /** - * Returns the search_query - * - * @return string search query - */ - public function get_search_query() - { - return $this->search_query; - } - - /** - * Returns the common_words array - * - * @return array common words that are ignored by search backend - */ - public function get_common_words() - { - return $this->common_words; - } - - /** - * Returns the word_length array - * - * @return array min and max word length for searching - */ - public function get_word_length() - { - return $this->word_length; - } - - /** - * Checks for correct MySQL version and stores min/max word length in the config - * - * @return string|bool Language key of the error/incompatiblity occurred - */ - public function init() - { - if ($this->db->get_sql_layer() != 'mysql4' && $this->db->get_sql_layer() != 'mysqli') - { - return $this->user->lang['FULLTEXT_MYSQL_INCOMPATIBLE_DATABASE']; - } - - $result = $this->db->sql_query('SHOW TABLE STATUS LIKE \'' . POSTS_TABLE . '\''); - $info = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - $engine = ''; - if (isset($info['Engine'])) - { - $engine = $info['Engine']; - } - else if (isset($info['Type'])) - { - $engine = $info['Type']; - } - - $fulltext_supported = - $engine === 'MyISAM' || - // FULLTEXT is supported on InnoDB since MySQL 5.6.4 according to - // http://dev.mysql.com/doc/refman/5.6/en/innodb-storage-engine.html - // We also require https://bugs.mysql.com/bug.php?id=67004 to be - // fixed for proper overall operation. Hence we require 5.6.8. - $engine === 'InnoDB' && - phpbb_version_compare($this->db->sql_server_info(true), '5.6.8', '>='); - - if (!$fulltext_supported) - { - return $this->user->lang['FULLTEXT_MYSQL_NOT_SUPPORTED']; - } - - $sql = 'SHOW VARIABLES - LIKE \'ft\_%\''; - $result = $this->db->sql_query($sql); - - $mysql_info = array(); - while ($row = $this->db->sql_fetchrow($result)) - { - $mysql_info[$row['Variable_name']] = $row['Value']; - } - $this->db->sql_freeresult($result); - - $this->config->set('fulltext_mysql_max_word_len', $mysql_info['ft_max_word_len']); - $this->config->set('fulltext_mysql_min_word_len', $mysql_info['ft_min_word_len']); - - return false; - } - - /** - * Splits keywords entered by a user into an array of words stored in $this->split_words - * Stores the tidied search query in $this->search_query - * - * @param string &$keywords Contains the keyword as entered by the user - * @param string $terms is either 'all' or 'any' - * @return bool false if no valid keywords were found and otherwise true - */ - public function split_keywords(&$keywords, $terms) - { - if ($terms == 'all') - { - $match = array('#\sand\s#iu', '#\sor\s#iu', '#\snot\s#iu', '#(^|\s)\+#', '#(^|\s)-#', '#(^|\s)\|#'); - $replace = array(' +', ' |', ' -', ' +', ' -', ' |'); - - $keywords = preg_replace($match, $replace, $keywords); - } - - // Filter out as above - $split_keywords = preg_replace("#[\n\r\t]+#", ' ', trim(htmlspecialchars_decode($keywords))); - - // Split words - $split_keywords = preg_replace('#([^\p{L}\p{N}\'*"()])#u', '$1$1', str_replace('\'\'', '\' \'', trim($split_keywords))); - $matches = array(); - preg_match_all('#(?:[^\p{L}\p{N}*"()]|^)([+\-|]?(?:[\p{L}\p{N}*"()]+\'?)*[\p{L}\p{N}*"()])(?:[^\p{L}\p{N}*"()]|$)#u', $split_keywords, $matches); - $this->split_words = $matches[1]; - - // We limit the number of allowed keywords to minimize load on the database - if ($this->config['max_num_search_keywords'] && count($this->split_words) > $this->config['max_num_search_keywords']) - { - trigger_error($this->user->lang('MAX_NUM_SEARCH_KEYWORDS_REFINE', (int) $this->config['max_num_search_keywords'], count($this->split_words))); - } - - // to allow phrase search, we need to concatenate quoted words - $tmp_split_words = array(); - $phrase = ''; - foreach ($this->split_words as $word) - { - if ($phrase) - { - $phrase .= ' ' . $word; - if (strpos($word, '"') !== false && substr_count($word, '"') % 2 == 1) - { - $tmp_split_words[] = $phrase; - $phrase = ''; - } - } - else if (strpos($word, '"') !== false && substr_count($word, '"') % 2 == 1) - { - $phrase = $word; - } - else - { - $tmp_split_words[] = $word; - } - } - if ($phrase) - { - $tmp_split_words[] = $phrase; - } - - $this->split_words = $tmp_split_words; - - unset($tmp_split_words); - unset($phrase); - - foreach ($this->split_words as $i => $word) - { - // Check for not allowed search queries for InnoDB. - // We assume similar restrictions for MyISAM, which is usually even - // slower but not as restrictive as InnoDB. - // InnoDB full-text search does not support the use of a leading - // plus sign with wildcard ('+*'), a plus and minus sign - // combination ('+-'), or leading a plus and minus sign combination. - // InnoDB full-text search only supports leading plus or minus signs. - // For example, InnoDB supports '+apple' but does not support 'apple+'. - // Specifying a trailing plus or minus sign causes InnoDB to report - // a syntax error. InnoDB full-text search does not support the use - // of multiple operators on a single search word, as in this example: - // '++apple'. Use of multiple operators on a single search word - // returns a syntax error to standard out. - // Also, ensure that the wildcard character is only used at the - // end of the line as it's intended by MySQL. - if (preg_match('#^(\+[+-]|\+\*|.+[+-]$|.+\*(?!$))#', $word)) - { - unset($this->split_words[$i]); - continue; - } - - $clean_word = preg_replace('#^[+\-|"]#', '', $word); - - // check word length - $clean_len = utf8_strlen(str_replace('*', '', $clean_word)); - if (($clean_len < $this->config['fulltext_mysql_min_word_len']) || ($clean_len > $this->config['fulltext_mysql_max_word_len'])) - { - $this->common_words[] = $word; - unset($this->split_words[$i]); - } - } - - if ($terms == 'any') - { - $this->search_query = ''; - foreach ($this->split_words as $word) - { - if ((strpos($word, '+') === 0) || (strpos($word, '-') === 0) || (strpos($word, '|') === 0)) - { - $word = substr($word, 1); - } - $this->search_query .= $word . ' '; - } - } - else - { - $this->search_query = ''; - foreach ($this->split_words as $word) - { - if ((strpos($word, '+') === 0) || (strpos($word, '-') === 0)) - { - $this->search_query .= $word . ' '; - } - else if (strpos($word, '|') === 0) - { - $this->search_query .= substr($word, 1) . ' '; - } - else - { - $this->search_query .= '+' . $word . ' '; - } - } - } - - $this->search_query = utf8_htmlspecialchars($this->search_query); - - if ($this->search_query) - { - $this->split_words = array_values($this->split_words); - sort($this->split_words); - return true; - } - return false; - } - - /** - * Turns text into an array of words - * @param string $text contains post text/subject - */ - public function split_message($text) - { - // Split words - $text = preg_replace('#([^\p{L}\p{N}\'*])#u', '$1$1', str_replace('\'\'', '\' \'', trim($text))); - $matches = array(); - preg_match_all('#(?:[^\p{L}\p{N}*]|^)([+\-|]?(?:[\p{L}\p{N}*]+\'?)*[\p{L}\p{N}*])(?:[^\p{L}\p{N}*]|$)#u', $text, $matches); - $text = $matches[1]; - - // remove too short or too long words - $text = array_values($text); - for ($i = 0, $n = count($text); $i < $n; $i++) - { - $text[$i] = trim($text[$i]); - if (utf8_strlen($text[$i]) < $this->config['fulltext_mysql_min_word_len'] || utf8_strlen($text[$i]) > $this->config['fulltext_mysql_max_word_len']) - { - unset($text[$i]); - } - } - - return array_values($text); - } - - /** - * Performs a search on keywords depending on display specific params. You have to run split_keywords() first - * - * @param string $type contains either posts or topics depending on what should be searched for - * @param string $fields contains either titleonly (topic titles should be searched), msgonly (only message bodies should be searched), firstpost (only subject and body of the first post should be searched) or all (all post bodies and subjects should be searched) - * @param string $terms is either 'all' (use query as entered, words without prefix should default to "have to be in field") or 'any' (ignore search query parts and just return all posts that contain any of the specified words) - * @param array $sort_by_sql contains SQL code for the ORDER BY part of a query - * @param string $sort_key is the key of $sort_by_sql for the selected sorting - * @param string $sort_dir is either a or d representing ASC and DESC - * @param string $sort_days specifies the maximum amount of days a post may be old - * @param array $ex_fid_ary specifies an array of forum ids which should not be searched - * @param string $post_visibility specifies which types of posts the user can view in which forums - * @param int $topic_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched - * @param array $author_ary an array of author ids if the author should be ignored during the search the array is empty - * @param string $author_name specifies the author match, when ANONYMOUS is also a search-match - * @param array &$id_ary passed by reference, to be filled with ids for the page specified by $start and $per_page, should be ordered - * @param int $start indicates the first index of the page - * @param int $per_page number of ids each page is supposed to contain - * @return boolean|int total number of results - */ - public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page) - { - // No keywords? No posts - if (!$this->search_query) - { - return false; - } - - // generate a search_key from all the options to identify the results - $search_key_array = array( - implode(', ', $this->split_words), - $type, - $fields, - $terms, - $sort_days, - $sort_key, - $topic_id, - implode(',', $ex_fid_ary), - $post_visibility, - implode(',', $author_ary) - ); - - /** - * Allow changing the search_key for cached results - * - * @event core.search_mysql_by_keyword_modify_search_key - * @var array search_key_array Array with search parameters to generate the search_key - * @var string type Searching type ('posts', 'topics') - * @var string fields Searching fields ('titleonly', 'msgonly', 'firstpost', 'all') - * @var string terms Searching terms ('all', 'any') - * @var int sort_days Time, in days, of the oldest possible post to list - * @var string sort_key The sort type used from the possible sort types - * @var int topic_id Limit the search to this topic_id only - * @var array ex_fid_ary Which forums not to search on - * @var string post_visibility Post visibility data - * @var array author_ary Array of user_id containing the users to filter the results to - * @since 3.1.7-RC1 - */ - $vars = array( - 'search_key_array', - 'type', - 'fields', - 'terms', - 'sort_days', - 'sort_key', - 'topic_id', - 'ex_fid_ary', - 'post_visibility', - 'author_ary', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_mysql_by_keyword_modify_search_key', compact($vars))); - - $search_key = md5(implode('#', $search_key_array)); - - if ($start < 0) - { - $start = 0; - } - - // try reading the results from cache - $result_count = 0; - if ($this->obtain_ids($search_key, $result_count, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE) - { - return $result_count; - } - - $id_ary = array(); - - $join_topic = ($type == 'posts') ? false : true; - - // Build sql strings for sorting - $sql_sort = $sort_by_sql[$sort_key] . (($sort_dir == 'a') ? ' ASC' : ' DESC'); - $sql_sort_table = $sql_sort_join = ''; - - switch ($sql_sort[0]) - { - case 'u': - $sql_sort_table = USERS_TABLE . ' u, '; - $sql_sort_join = ($type == 'posts') ? ' AND u.user_id = p.poster_id ' : ' AND u.user_id = t.topic_poster '; - break; - - case 't': - $join_topic = true; - break; - - case 'f': - $sql_sort_table = FORUMS_TABLE . ' f, '; - $sql_sort_join = ' AND f.forum_id = p.forum_id '; - break; - } - - // Build some display specific sql strings - switch ($fields) - { - case 'titleonly': - $sql_match = 'p.post_subject'; - $sql_match_where = ' AND p.post_id = t.topic_first_post_id'; - $join_topic = true; - break; - - case 'msgonly': - $sql_match = 'p.post_text'; - $sql_match_where = ''; - break; - - case 'firstpost': - $sql_match = 'p.post_subject, p.post_text'; - $sql_match_where = ' AND p.post_id = t.topic_first_post_id'; - $join_topic = true; - break; - - default: - $sql_match = 'p.post_subject, p.post_text'; - $sql_match_where = ''; - break; - } - - $search_query = $this->search_query; - - /** - * Allow changing the query used to search for posts using fulltext_mysql - * - * @event core.search_mysql_keywords_main_query_before - * @var string search_query The parsed keywords used for this search - * @var int result_count The previous result count for the format of the query. - * Set to 0 to force a re-count - * @var bool join_topic Weather or not TOPICS_TABLE should be CROSS JOIN'ED - * @var array author_ary Array of user_id containing the users to filter the results to - * @var string author_name An extra username to search on (!empty(author_ary) must be true, to be relevant) - * @var array ex_fid_ary Which forums not to search on - * @var int topic_id Limit the search to this topic_id only - * @var string sql_sort_table Extra tables to include in the SQL query. - * Used in conjunction with sql_sort_join - * @var string sql_sort_join SQL conditions to join all the tables used together. - * Used in conjunction with sql_sort_table - * @var int sort_days Time, in days, of the oldest possible post to list - * @var string sql_match Which columns to do the search on. - * @var string sql_match_where Extra conditions to use to properly filter the matching process - * @var string sort_by_sql The possible predefined sort types - * @var string sort_key The sort type used from the possible sort types - * @var string sort_dir "a" for ASC or "d" dor DESC for the sort order used - * @var string sql_sort The result SQL when processing sort_by_sql + sort_key + sort_dir - * @var int start How many posts to skip in the search results (used for pagination) - * @since 3.1.5-RC1 - */ - $vars = array( - 'search_query', - 'result_count', - 'join_topic', - 'author_ary', - 'author_name', - 'ex_fid_ary', - 'topic_id', - 'sql_sort_table', - 'sql_sort_join', - 'sort_days', - 'sql_match', - 'sql_match_where', - 'sort_by_sql', - 'sort_key', - 'sort_dir', - 'sql_sort', - 'start', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_mysql_keywords_main_query_before', compact($vars))); - - $sql_select = (!$result_count) ? 'SQL_CALC_FOUND_ROWS ' : ''; - $sql_select = ($type == 'posts') ? $sql_select . 'p.post_id' : 'DISTINCT ' . $sql_select . 't.topic_id'; - $sql_from = ($join_topic) ? TOPICS_TABLE . ' t, ' : ''; - $field = ($type == 'posts') ? 'post_id' : 'topic_id'; - if (count($author_ary) && $author_name) - { - // first one matches post of registered users, second one guests and deleted users - $sql_author = ' AND (' . $this->db->sql_in_set('p.poster_id', array_diff($author_ary, array(ANONYMOUS)), false, true) . ' OR p.post_username ' . $author_name . ')'; - } - else if (count($author_ary)) - { - $sql_author = ' AND ' . $this->db->sql_in_set('p.poster_id', $author_ary); - } - else - { - $sql_author = ''; - } - - $sql_where_options = $sql_sort_join; - $sql_where_options .= ($topic_id) ? ' AND p.topic_id = ' . $topic_id : ''; - $sql_where_options .= ($join_topic) ? ' AND t.topic_id = p.topic_id' : ''; - $sql_where_options .= (count($ex_fid_ary)) ? ' AND ' . $this->db->sql_in_set('p.forum_id', $ex_fid_ary, true) : ''; - $sql_where_options .= ' AND ' . $post_visibility; - $sql_where_options .= $sql_author; - $sql_where_options .= ($sort_days) ? ' AND p.post_time >= ' . (time() - ($sort_days * 86400)) : ''; - $sql_where_options .= $sql_match_where; - - $sql = "SELECT $sql_select - FROM $sql_from$sql_sort_table" . POSTS_TABLE . " p - WHERE MATCH ($sql_match) AGAINST ('" . $this->db->sql_escape(htmlspecialchars_decode($this->search_query)) . "' IN BOOLEAN MODE) - $sql_where_options - ORDER BY $sql_sort"; - $this->db->sql_return_on_error(true); - $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); - - while ($row = $this->db->sql_fetchrow($result)) - { - $id_ary[] = (int) $row[$field]; - } - $this->db->sql_freeresult($result); - - $id_ary = array_unique($id_ary); - - // if the total result count is not cached yet, retrieve it from the db - if (!$result_count && count($id_ary)) - { - $sql_found_rows = 'SELECT FOUND_ROWS() as result_count'; - $result = $this->db->sql_query($sql_found_rows); - $result_count = (int) $this->db->sql_fetchfield('result_count'); - $this->db->sql_freeresult($result); - - if (!$result_count) - { - return false; - } - } - - if ($start >= $result_count) - { - $start = floor(($result_count - 1) / $per_page) * $per_page; - - $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); - - while ($row = $this->db->sql_fetchrow($result)) - { - $id_ary[] = (int) $row[$field]; - } - $this->db->sql_freeresult($result); - - $id_ary = array_unique($id_ary); - } - - // store the ids, from start on then delete anything that isn't on the current page because we only need ids for one page - $this->save_ids($search_key, implode(' ', $this->split_words), $author_ary, $result_count, $id_ary, $start, $sort_dir); - $id_ary = array_slice($id_ary, 0, (int) $per_page); - - return $result_count; - } - - /** - * Performs a search on an author's posts without caring about message contents. Depends on display specific params - * - * @param string $type contains either posts or topics depending on what should be searched for - * @param boolean $firstpost_only if true, only topic starting posts will be considered - * @param array $sort_by_sql contains SQL code for the ORDER BY part of a query - * @param string $sort_key is the key of $sort_by_sql for the selected sorting - * @param string $sort_dir is either a or d representing ASC and DESC - * @param string $sort_days specifies the maximum amount of days a post may be old - * @param array $ex_fid_ary specifies an array of forum ids which should not be searched - * @param string $post_visibility specifies which types of posts the user can view in which forums - * @param int $topic_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched - * @param array $author_ary an array of author ids - * @param string $author_name specifies the author match, when ANONYMOUS is also a search-match - * @param array &$id_ary passed by reference, to be filled with ids for the page specified by $start and $per_page, should be ordered - * @param int $start indicates the first index of the page - * @param int $per_page number of ids each page is supposed to contain - * @return boolean|int total number of results - */ - public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page) - { - // No author? No posts - if (!count($author_ary)) - { - return 0; - } - - // generate a search_key from all the options to identify the results - $search_key_array = array( - '', - $type, - ($firstpost_only) ? 'firstpost' : '', - '', - '', - $sort_days, - $sort_key, - $topic_id, - implode(',', $ex_fid_ary), - $post_visibility, - implode(',', $author_ary), - $author_name, - ); - - /** - * Allow changing the search_key for cached results - * - * @event core.search_mysql_by_author_modify_search_key - * @var array search_key_array Array with search parameters to generate the search_key - * @var string type Searching type ('posts', 'topics') - * @var boolean firstpost_only Flag indicating if only topic starting posts are considered - * @var int sort_days Time, in days, of the oldest possible post to list - * @var string sort_key The sort type used from the possible sort types - * @var int topic_id Limit the search to this topic_id only - * @var array ex_fid_ary Which forums not to search on - * @var string post_visibility Post visibility data - * @var array author_ary Array of user_id containing the users to filter the results to - * @var string author_name The username to search on - * @since 3.1.7-RC1 - */ - $vars = array( - 'search_key_array', - 'type', - 'firstpost_only', - 'sort_days', - 'sort_key', - 'topic_id', - 'ex_fid_ary', - 'post_visibility', - 'author_ary', - 'author_name', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_mysql_by_author_modify_search_key', compact($vars))); - - $search_key = md5(implode('#', $search_key_array)); - - if ($start < 0) - { - $start = 0; - } - - // try reading the results from cache - $result_count = 0; - if ($this->obtain_ids($search_key, $result_count, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE) - { - return $result_count; - } - - $id_ary = array(); - - // Create some display specific sql strings - if ($author_name) - { - // first one matches post of registered users, second one guests and deleted users - $sql_author = '(' . $this->db->sql_in_set('p.poster_id', array_diff($author_ary, array(ANONYMOUS)), false, true) . ' OR p.post_username ' . $author_name . ')'; - } - else - { - $sql_author = $this->db->sql_in_set('p.poster_id', $author_ary); - } - $sql_fora = (count($ex_fid_ary)) ? ' AND ' . $this->db->sql_in_set('p.forum_id', $ex_fid_ary, true) : ''; - $sql_topic_id = ($topic_id) ? ' AND p.topic_id = ' . (int) $topic_id : ''; - $sql_time = ($sort_days) ? ' AND p.post_time >= ' . (time() - ($sort_days * 86400)) : ''; - $sql_firstpost = ($firstpost_only) ? ' AND p.post_id = t.topic_first_post_id' : ''; - - // Build sql strings for sorting - $sql_sort = $sort_by_sql[$sort_key] . (($sort_dir == 'a') ? ' ASC' : ' DESC'); - $sql_sort_table = $sql_sort_join = ''; - switch ($sql_sort[0]) - { - case 'u': - $sql_sort_table = USERS_TABLE . ' u, '; - $sql_sort_join = ($type == 'posts') ? ' AND u.user_id = p.poster_id ' : ' AND u.user_id = t.topic_poster '; - break; - - case 't': - $sql_sort_table = ($type == 'posts' && !$firstpost_only) ? TOPICS_TABLE . ' t, ' : ''; - $sql_sort_join = ($type == 'posts' && !$firstpost_only) ? ' AND t.topic_id = p.topic_id ' : ''; - break; - - case 'f': - $sql_sort_table = FORUMS_TABLE . ' f, '; - $sql_sort_join = ' AND f.forum_id = p.forum_id '; - break; - } - - $m_approve_fid_sql = ' AND ' . $post_visibility; - - /** - * Allow changing the query used to search for posts by author in fulltext_mysql - * - * @event core.search_mysql_author_query_before - * @var int result_count The previous result count for the format of the query. - * Set to 0 to force a re-count - * @var string sql_sort_table CROSS JOIN'ed table to allow doing the sort chosen - * @var string sql_sort_join Condition to define how to join the CROSS JOIN'ed table specifyed in sql_sort_table - * @var string type Either "posts" or "topics" specifying the type of search being made - * @var array author_ary Array of user_id containing the users to filter the results to - * @var string author_name An extra username to search on - * @var string sql_author SQL WHERE condition for the post author ids - * @var int topic_id Limit the search to this topic_id only - * @var string sql_topic_id SQL of topic_id - * @var string sort_by_sql The possible predefined sort types - * @var string sort_key The sort type used from the possible sort types - * @var string sort_dir "a" for ASC or "d" dor DESC for the sort order used - * @var string sql_sort The result SQL when processing sort_by_sql + sort_key + sort_dir - * @var string sort_days Time, in days, that the oldest post showing can have - * @var string sql_time The SQL to search on the time specifyed by sort_days - * @var bool firstpost_only Wether or not to search only on the first post of the topics - * @var string sql_firstpost The SQL with the conditions to join the tables when using firstpost_only - * @var array ex_fid_ary Forum ids that must not be searched on - * @var array sql_fora SQL query for ex_fid_ary - * @var string m_approve_fid_sql WHERE clause condition on post_visibility restrictions - * @var int start How many posts to skip in the search results (used for pagination) - * @since 3.1.5-RC1 - */ - $vars = array( - 'result_count', - 'sql_sort_table', - 'sql_sort_join', - 'type', - 'author_ary', - 'author_name', - 'sql_author', - 'topic_id', - 'sql_topic_id', - 'sort_by_sql', - 'sort_key', - 'sort_dir', - 'sql_sort', - 'sort_days', - 'sql_time', - 'firstpost_only', - 'sql_firstpost', - 'ex_fid_ary', - 'sql_fora', - 'm_approve_fid_sql', - 'start', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_mysql_author_query_before', compact($vars))); - - // If the cache was completely empty count the results - $calc_results = ($result_count) ? '' : 'SQL_CALC_FOUND_ROWS '; - - // Build the query for really selecting the post_ids - if ($type == 'posts') - { - $sql = "SELECT {$calc_results}p.post_id - FROM " . $sql_sort_table . POSTS_TABLE . ' p' . (($firstpost_only) ? ', ' . TOPICS_TABLE . ' t ' : ' ') . " - WHERE $sql_author - $sql_topic_id - $sql_firstpost - $m_approve_fid_sql - $sql_fora - $sql_sort_join - $sql_time - ORDER BY $sql_sort"; - $field = 'post_id'; - } - else - { - $sql = "SELECT {$calc_results}t.topic_id - FROM " . $sql_sort_table . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p - WHERE $sql_author - $sql_topic_id - $sql_firstpost - $m_approve_fid_sql - $sql_fora - AND t.topic_id = p.topic_id - $sql_sort_join - $sql_time - GROUP BY t.topic_id - ORDER BY $sql_sort"; - $field = 'topic_id'; - } - - // Only read one block of posts from the db and then cache it - $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); - - while ($row = $this->db->sql_fetchrow($result)) - { - $id_ary[] = (int) $row[$field]; - } - $this->db->sql_freeresult($result); - - // retrieve the total result count if needed - if (!$result_count) - { - $sql_found_rows = 'SELECT FOUND_ROWS() as result_count'; - $result = $this->db->sql_query($sql_found_rows); - $result_count = (int) $this->db->sql_fetchfield('result_count'); - $this->db->sql_freeresult($result); - - if (!$result_count) - { - return false; - } - } - - if ($start >= $result_count) - { - $start = floor(($result_count - 1) / $per_page) * $per_page; - - $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); - while ($row = $this->db->sql_fetchrow($result)) - { - $id_ary[] = (int) $row[$field]; - } - $this->db->sql_freeresult($result); - - $id_ary = array_unique($id_ary); - } - - if (count($id_ary)) - { - $this->save_ids($search_key, '', $author_ary, $result_count, $id_ary, $start, $sort_dir); - $id_ary = array_slice($id_ary, 0, $per_page); - - return $result_count; - } - return false; - } - - /** - * Destroys cached search results, that contained one of the new words in a post so the results won't be outdated - * - * @param string $mode contains the post mode: edit, post, reply, quote ... - * @param int $post_id contains the post id of the post to index - * @param string $message contains the post text of the post - * @param string $subject contains the subject of the post to index - * @param int $poster_id contains the user id of the poster - * @param int $forum_id contains the forum id of parent forum of the post - */ - public function index($mode, $post_id, &$message, &$subject, $poster_id, $forum_id) - { - // Split old and new post/subject to obtain array of words - $split_text = $this->split_message($message); - $split_title = ($subject) ? $this->split_message($subject) : array(); - - $words = array_unique(array_merge($split_text, $split_title)); - - /** - * Event to modify method arguments and words before the MySQL search index is updated - * - * @event core.search_mysql_index_before - * @var string mode Contains the post mode: edit, post, reply, quote - * @var int post_id The id of the post which is modified/created - * @var string message New or updated post content - * @var string subject New or updated post subject - * @var int poster_id Post author's user id - * @var int forum_id The id of the forum in which the post is located - * @var array words List of words added to the index - * @var array split_text Array of words from the message - * @var array split_title Array of words from the title - * @since 3.2.3-RC1 - */ - $vars = array( - 'mode', - 'post_id', - 'message', - 'subject', - 'poster_id', - 'forum_id', - 'words', - 'split_text', - 'split_title', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_mysql_index_before', compact($vars))); - - unset($split_text); - unset($split_title); - - // destroy cached search results containing any of the words removed or added - $this->destroy_cache($words, array($poster_id)); - - unset($words); - } - - /** - * Destroy cached results, that might be outdated after deleting a post - */ - public function index_remove($post_ids, $author_ids, $forum_ids) - { - $this->destroy_cache(array(), array_unique($author_ids)); - } - - /** - * Destroy old cache entries - */ - public function tidy() - { - // destroy too old cached search results - $this->destroy_cache(array()); - - $this->config->set('search_last_gc', time(), false); - } - - /** - * Create fulltext index - * - * @return string|bool error string is returned incase of errors otherwise false - */ - public function create_index($acp_module, $u_action) - { - // Make sure we can actually use MySQL with fulltext indexes - if ($error = $this->init()) - { - return $error; - } - - if (empty($this->stats)) - { - $this->get_stats(); - } - - $alter_list = array(); - - if (!isset($this->stats['post_subject'])) - { - $alter_entry = array(); - if ($this->db->get_sql_layer() == 'mysqli' || version_compare($this->db->sql_server_info(true), '4.1.3', '>=')) - { - $alter_entry[] = 'MODIFY post_subject varchar(255) COLLATE utf8_unicode_ci DEFAULT \'\' NOT NULL'; - } - else - { - $alter_entry[] = 'MODIFY post_subject text NOT NULL'; - } - $alter_entry[] = 'ADD FULLTEXT (post_subject)'; - $alter_list[] = $alter_entry; - } - - if (!isset($this->stats['post_content'])) - { - $alter_entry = array(); - if ($this->db->get_sql_layer() == 'mysqli' || version_compare($this->db->sql_server_info(true), '4.1.3', '>=')) - { - $alter_entry[] = 'MODIFY post_text mediumtext COLLATE utf8_unicode_ci NOT NULL'; - } - else - { - $alter_entry[] = 'MODIFY post_text mediumtext NOT NULL'; - } - - $alter_entry[] = 'ADD FULLTEXT post_content (post_text, post_subject)'; - $alter_list[] = $alter_entry; - } - - $sql_queries = []; - - foreach ($alter_list as $alter) - { - $sql_queries[] = 'ALTER TABLE ' . POSTS_TABLE . ' ' . implode(', ', $alter); - } - - if (!isset($this->stats['post_text'])) - { - $sql_queries[] = 'ALTER TABLE ' . POSTS_TABLE . ' ADD FULLTEXT post_text (post_text)'; - } - - $stats = $this->stats; - - /** - * Event to modify SQL queries before the MySQL search index is created - * - * @event core.search_mysql_create_index_before - * @var array sql_queries Array with queries for creating the search index - * @var array stats Array with statistics of the current index (read only) - * @since 3.2.3-RC1 - */ - $vars = array( - 'sql_queries', - 'stats', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_mysql_create_index_before', compact($vars))); - - foreach ($sql_queries as $sql_query) - { - $this->db->sql_query($sql_query); - } - - $this->db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE); - - return false; - } - - /** - * Drop fulltext index - * - * @return string|bool error string is returned incase of errors otherwise false - */ - public function delete_index($acp_module, $u_action) - { - // Make sure we can actually use MySQL with fulltext indexes - if ($error = $this->init()) - { - return $error; - } - - if (empty($this->stats)) - { - $this->get_stats(); - } - - $alter = array(); - - if (isset($this->stats['post_subject'])) - { - $alter[] = 'DROP INDEX post_subject'; - } - - if (isset($this->stats['post_content'])) - { - $alter[] = 'DROP INDEX post_content'; - } - - if (isset($this->stats['post_text'])) - { - $alter[] = 'DROP INDEX post_text'; - } - - $sql_queries = []; - - if (count($alter)) - { - $sql_queries[] = 'ALTER TABLE ' . POSTS_TABLE . ' ' . implode(', ', $alter); - } - - $stats = $this->stats; - - /** - * Event to modify SQL queries before the MySQL search index is deleted - * - * @event core.search_mysql_delete_index_before - * @var array sql_queries Array with queries for deleting the search index - * @var array stats Array with statistics of the current index (read only) - * @since 3.2.3-RC1 - */ - $vars = array( - 'sql_queries', - 'stats', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_mysql_delete_index_before', compact($vars))); - - foreach ($sql_queries as $sql_query) - { - $this->db->sql_query($sql_query); - } - - $this->db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE); - - return false; - } - - /** - * Returns true if both FULLTEXT indexes exist - */ - public function index_created() - { - if (empty($this->stats)) - { - $this->get_stats(); - } - - return isset($this->stats['post_subject']) && isset($this->stats['post_content']) && isset($this->stats['post_text']); - } - - /** - * Returns an associative array containing information about the indexes - */ - public function index_stats() - { - if (empty($this->stats)) - { - $this->get_stats(); - } - - return array( - $this->user->lang['FULLTEXT_MYSQL_TOTAL_POSTS'] => ($this->index_created()) ? $this->stats['total_posts'] : 0, - ); - } - - /** - * Computes the stats and store them in the $this->stats associative array - */ - protected function get_stats() - { - if (strpos($this->db->get_sql_layer(), 'mysql') === false) - { - $this->stats = array(); - return; - } - - $sql = 'SHOW INDEX - FROM ' . POSTS_TABLE; - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - // deal with older MySQL versions which didn't use Index_type - $index_type = (isset($row['Index_type'])) ? $row['Index_type'] : $row['Comment']; - - if ($index_type == 'FULLTEXT') - { - if ($row['Key_name'] == 'post_subject') - { - $this->stats['post_subject'] = $row; - } - else if ($row['Key_name'] == 'post_text') - { - $this->stats['post_text'] = $row; - } - else if ($row['Key_name'] == 'post_content') - { - $this->stats['post_content'] = $row; - } - } - } - $this->db->sql_freeresult($result); - - $this->stats['total_posts'] = empty($this->stats) ? 0 : $this->db->get_estimated_row_count(POSTS_TABLE); - } - - /** - * Display a note, that UTF-8 support is not available with certain versions of PHP - * - * @return associative array containing template and config variables - */ - public function acp() - { - $tpl = ' -
-

' . $this->user->lang['FULLTEXT_MYSQL_MIN_SEARCH_CHARS_EXPLAIN'] . '
-
' . $this->config['fulltext_mysql_min_word_len'] . '
-
-
-

' . $this->user->lang['FULLTEXT_MYSQL_MAX_SEARCH_CHARS_EXPLAIN'] . '
-
' . $this->config['fulltext_mysql_max_word_len'] . '
-
- '; - - // These are fields required in the config table - return array( - 'tpl' => $tpl, - 'config' => array() - ); - } -} diff --git a/install/update/old/phpbb/search/fulltext_native.php b/install/update/old/phpbb/search/fulltext_native.php deleted file mode 100644 index c83de75..0000000 --- a/install/update/old/phpbb/search/fulltext_native.php +++ /dev/null @@ -1,2062 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\search; - -/** -* phpBB's own db driven fulltext search, version 2 -*/ -class fulltext_native extends \phpbb\search\base -{ - const UTF8_HANGUL_FIRST = "\xEA\xB0\x80"; - const UTF8_HANGUL_LAST = "\xED\x9E\xA3"; - const UTF8_CJK_FIRST = "\xE4\xB8\x80"; - const UTF8_CJK_LAST = "\xE9\xBE\xBB"; - const UTF8_CJK_B_FIRST = "\xF0\xA0\x80\x80"; - const UTF8_CJK_B_LAST = "\xF0\xAA\x9B\x96"; - - /** - * Associative array holding index stats - * @var array - */ - protected $stats = array(); - - /** - * Associative array stores the min and max word length to be searched - * @var array - */ - protected $word_length = array(); - - /** - * Contains tidied search query. - * Operators are prefixed in search query and common words excluded - * @var string - */ - protected $search_query; - - /** - * Contains common words. - * Common words are words with length less/more than min/max length - * @var array - */ - protected $common_words = array(); - - /** - * Post ids of posts containing words that are to be included - * @var array - */ - protected $must_contain_ids = array(); - - /** - * Post ids of posts containing words that should not be included - * @var array - */ - protected $must_not_contain_ids = array(); - - /** - * Post ids of posts containing at least one word that needs to be excluded - * @var array - */ - protected $must_exclude_one_ids = array(); - - /** - * Relative path to board root - * @var string - */ - protected $phpbb_root_path; - - /** - * PHP Extension - * @var string - */ - protected $php_ext; - - /** - * Config object - * @var \phpbb\config\config - */ - protected $config; - - /** - * Database connection - * @var \phpbb\db\driver\driver_interface - */ - protected $db; - - /** - * phpBB event dispatcher object - * @var \phpbb\event\dispatcher_interface - */ - protected $phpbb_dispatcher; - - /** - * User object - * @var \phpbb\user - */ - protected $user; - - /** - * Initialises the fulltext_native search backend with min/max word length - * - * @param boolean|string &$error is passed by reference and should either be set to false on success or an error message on failure - * @param \phpbb\event\dispatcher_interface $phpbb_dispatcher Event dispatcher object - */ - public function __construct(&$error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher) - { - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $phpEx; - $this->config = $config; - $this->db = $db; - $this->phpbb_dispatcher = $phpbb_dispatcher; - $this->user = $user; - - $this->word_length = array('min' => (int) $this->config['fulltext_native_min_chars'], 'max' => (int) $this->config['fulltext_native_max_chars']); - - /** - * Load the UTF tools - */ - if (!function_exists('utf8_decode_ncr')) - { - include($this->phpbb_root_path . 'includes/utf/utf_tools.' . $this->php_ext); - } - - $error = false; - } - - /** - * Returns the name of this search backend to be displayed to administrators - * - * @return string Name - */ - public function get_name() - { - return 'phpBB Native Fulltext'; - } - - /** - * Returns the search_query - * - * @return string search query - */ - public function get_search_query() - { - return $this->search_query; - } - - /** - * Returns the common_words array - * - * @return array common words that are ignored by search backend - */ - public function get_common_words() - { - return $this->common_words; - } - - /** - * Returns the word_length array - * - * @return array min and max word length for searching - */ - public function get_word_length() - { - return $this->word_length; - } - - /** - * This function fills $this->search_query with the cleaned user search query - * - * If $terms is 'any' then the words will be extracted from the search query - * and combined with | inside brackets. They will afterwards be treated like - * an standard search query. - * - * Then it analyses the query and fills the internal arrays $must_not_contain_ids, - * $must_contain_ids and $must_exclude_one_ids which are later used by keyword_search() - * - * @param string $keywords contains the search query string as entered by the user - * @param string $terms is either 'all' (use search query as entered, default words to 'must be contained in post') - * or 'any' (find all posts containing at least one of the given words) - * @return boolean false if no valid keywords were found and otherwise true - */ - public function split_keywords($keywords, $terms) - { - $tokens = '+-|()* '; - - $keywords = trim($this->cleanup($keywords, $tokens)); - - // allow word|word|word without brackets - if ((strpos($keywords, ' ') === false) && (strpos($keywords, '|') !== false) && (strpos($keywords, '(') === false)) - { - $keywords = '(' . $keywords . ')'; - } - - $open_bracket = $space = false; - for ($i = 0, $n = strlen($keywords); $i < $n; $i++) - { - if ($open_bracket !== false) - { - switch ($keywords[$i]) - { - case ')': - if ($open_bracket + 1 == $i) - { - $keywords[$i - 1] = '|'; - $keywords[$i] = '|'; - } - $open_bracket = false; - break; - case '(': - $keywords[$i] = '|'; - break; - case '+': - case '-': - case ' ': - $keywords[$i] = '|'; - break; - case '*': - // $i can never be 0 here since $open_bracket is initialised to false - if (strpos($tokens, $keywords[$i - 1]) !== false && ($i + 1 === $n || strpos($tokens, $keywords[$i + 1]) !== false)) - { - $keywords[$i] = '|'; - } - break; - } - } - else - { - switch ($keywords[$i]) - { - case ')': - $keywords[$i] = ' '; - break; - case '(': - $open_bracket = $i; - $space = false; - break; - case '|': - $keywords[$i] = ' '; - break; - case '-': - case '+': - $space = $keywords[$i]; - break; - case ' ': - if ($space !== false) - { - $keywords[$i] = $space; - } - break; - default: - $space = false; - } - } - } - - if ($open_bracket !== false) - { - $keywords .= ')'; - } - - $match = array( - '# +#', - '#\|\|+#', - '#(\+|\-)(?:\+|\-)+#', - '#\(\|#', - '#\|\)#', - ); - $replace = array( - ' ', - '|', - '$1', - '(', - ')', - ); - - $keywords = preg_replace($match, $replace, $keywords); - $num_keywords = count(explode(' ', $keywords)); - - // We limit the number of allowed keywords to minimize load on the database - if ($this->config['max_num_search_keywords'] && $num_keywords > $this->config['max_num_search_keywords']) - { - trigger_error($this->user->lang('MAX_NUM_SEARCH_KEYWORDS_REFINE', (int) $this->config['max_num_search_keywords'], $num_keywords)); - } - - // $keywords input format: each word separated by a space, words in a bracket are not separated - - // the user wants to search for any word, convert the search query - if ($terms == 'any') - { - $words = array(); - - preg_match_all('#([^\\s+\\-|()]+)(?:$|[\\s+\\-|()])#u', $keywords, $words); - if (count($words[1])) - { - $keywords = '(' . implode('|', $words[1]) . ')'; - } - } - - // Remove non trailing wildcards from each word to prevent a full table scan (it's now using the database index) - $match = '#\*(?!$|\s)#'; - $replace = '$1'; - $keywords = preg_replace($match, $replace, $keywords); - - // Only allow one wildcard in the search query to limit the database load - $match = '#\*#'; - $replace = '$1'; - $count_wildcards = substr_count($keywords, '*'); - - // Reverse the string to remove all wildcards except the first one - $keywords = strrev(preg_replace($match, $replace, strrev($keywords), $count_wildcards - 1)); - unset($count_wildcards); - - // set the search_query which is shown to the user - $this->search_query = $keywords; - - $exact_words = array(); - preg_match_all('#([^\\s+\\-|()]+)(?:$|[\\s+\\-|()])#u', $keywords, $exact_words); - $exact_words = $exact_words[1]; - - $common_ids = $words = array(); - - if (count($exact_words)) - { - $sql = 'SELECT word_id, word_text, word_common - FROM ' . SEARCH_WORDLIST_TABLE . ' - WHERE ' . $this->db->sql_in_set('word_text', $exact_words) . ' - ORDER BY word_count ASC'; - $result = $this->db->sql_query($sql); - - // store an array of words and ids, remove common words - while ($row = $this->db->sql_fetchrow($result)) - { - if ($row['word_common']) - { - $this->common_words[] = $row['word_text']; - $common_ids[$row['word_text']] = (int) $row['word_id']; - continue; - } - - $words[$row['word_text']] = (int) $row['word_id']; - } - $this->db->sql_freeresult($result); - } - - // Handle +, - without preceeding whitespace character - $match = array('#(\S)\+#', '#(\S)-#'); - $replace = array('$1 +', '$1 +'); - - $keywords = preg_replace($match, $replace, $keywords); - - // now analyse the search query, first split it using the spaces - $query = explode(' ', $keywords); - - $this->must_contain_ids = array(); - $this->must_not_contain_ids = array(); - $this->must_exclude_one_ids = array(); - - foreach ($query as $word) - { - if (empty($word)) - { - continue; - } - - // words which should not be included - if ($word[0] == '-') - { - $word = substr($word, 1); - - // a group of which at least one may not be in the resulting posts - if ($word[0] == '(') - { - $word = array_unique(explode('|', substr($word, 1, -1))); - $mode = 'must_exclude_one'; - } - // one word which should not be in the resulting posts - else - { - $mode = 'must_not_contain'; - } - $ignore_no_id = true; - } - // words which have to be included - else - { - // no prefix is the same as a +prefix - if ($word[0] == '+') - { - $word = substr($word, 1); - } - - // a group of words of which at least one word should be in every resulting post - if ($word[0] == '(') - { - $word = array_unique(explode('|', substr($word, 1, -1))); - } - $ignore_no_id = false; - $mode = 'must_contain'; - } - - if (empty($word)) - { - continue; - } - - // if this is an array of words then retrieve an id for each - if (is_array($word)) - { - $non_common_words = array(); - $id_words = array(); - foreach ($word as $i => $word_part) - { - if (strpos($word_part, '*') !== false) - { - $len = utf8_strlen(str_replace('*', '', $word_part)); - if ($len >= $this->word_length['min'] && $len <= $this->word_length['max']) - { - $id_words[] = '\'' . $this->db->sql_escape(str_replace('*', '%', $word_part)) . '\''; - $non_common_words[] = $word_part; - } - else - { - $this->common_words[] = $word_part; - } - } - else if (isset($words[$word_part])) - { - $id_words[] = $words[$word_part]; - $non_common_words[] = $word_part; - } - else - { - $len = utf8_strlen($word_part); - if ($len < $this->word_length['min'] || $len > $this->word_length['max']) - { - $this->common_words[] = $word_part; - } - } - } - if (count($id_words)) - { - sort($id_words); - if (count($id_words) > 1) - { - $this->{$mode . '_ids'}[] = $id_words; - } - else - { - $mode = ($mode == 'must_exclude_one') ? 'must_not_contain' : $mode; - $this->{$mode . '_ids'}[] = $id_words[0]; - } - } - // throw an error if we shall not ignore unexistant words - else if (!$ignore_no_id && count($non_common_words)) - { - trigger_error(sprintf($this->user->lang['WORDS_IN_NO_POST'], implode($this->user->lang['COMMA_SEPARATOR'], $non_common_words))); - } - unset($non_common_words); - } - // else we only need one id - else if (($wildcard = strpos($word, '*') !== false) || isset($words[$word])) - { - if ($wildcard) - { - $len = utf8_strlen(str_replace('*', '', $word)); - if ($len >= $this->word_length['min'] && $len <= $this->word_length['max']) - { - $this->{$mode . '_ids'}[] = '\'' . $this->db->sql_escape(str_replace('*', '%', $word)) . '\''; - } - else - { - $this->common_words[] = $word; - } - } - else - { - $this->{$mode . '_ids'}[] = $words[$word]; - } - } - else - { - if (!isset($common_ids[$word])) - { - $len = utf8_strlen($word); - if ($len < $this->word_length['min'] || $len > $this->word_length['max']) - { - $this->common_words[] = $word; - } - } - } - } - - // Return true if all words are not common words - if (count($exact_words) - count($this->common_words) > 0) - { - return true; - } - return false; - } - - /** - * Performs a search on keywords depending on display specific params. You have to run split_keywords() first - * - * @param string $type contains either posts or topics depending on what should be searched for - * @param string $fields contains either titleonly (topic titles should be searched), msgonly (only message bodies should be searched), firstpost (only subject and body of the first post should be searched) or all (all post bodies and subjects should be searched) - * @param string $terms is either 'all' (use query as entered, words without prefix should default to "have to be in field") or 'any' (ignore search query parts and just return all posts that contain any of the specified words) - * @param array $sort_by_sql contains SQL code for the ORDER BY part of a query - * @param string $sort_key is the key of $sort_by_sql for the selected sorting - * @param string $sort_dir is either a or d representing ASC and DESC - * @param string $sort_days specifies the maximum amount of days a post may be old - * @param array $ex_fid_ary specifies an array of forum ids which should not be searched - * @param string $post_visibility specifies which types of posts the user can view in which forums - * @param int $topic_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched - * @param array $author_ary an array of author ids if the author should be ignored during the search the array is empty - * @param string $author_name specifies the author match, when ANONYMOUS is also a search-match - * @param array &$id_ary passed by reference, to be filled with ids for the page specified by $start and $per_page, should be ordered - * @param int $start indicates the first index of the page - * @param int $per_page number of ids each page is supposed to contain - * @return boolean|int total number of results - */ - public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page) - { - // No keywords? No posts. - if (empty($this->search_query)) - { - return false; - } - - // we can't search for negatives only - if (empty($this->must_contain_ids)) - { - return false; - } - - $must_contain_ids = $this->must_contain_ids; - $must_not_contain_ids = $this->must_not_contain_ids; - $must_exclude_one_ids = $this->must_exclude_one_ids; - - sort($must_contain_ids); - sort($must_not_contain_ids); - sort($must_exclude_one_ids); - - // generate a search_key from all the options to identify the results - $search_key_array = array( - serialize($must_contain_ids), - serialize($must_not_contain_ids), - serialize($must_exclude_one_ids), - $type, - $fields, - $terms, - $sort_days, - $sort_key, - $topic_id, - implode(',', $ex_fid_ary), - $post_visibility, - implode(',', $author_ary), - $author_name, - ); - - /** - * Allow changing the search_key for cached results - * - * @event core.search_native_by_keyword_modify_search_key - * @var array search_key_array Array with search parameters to generate the search_key - * @var array must_contain_ids Array with post ids of posts containing words that are to be included - * @var array must_not_contain_ids Array with post ids of posts containing words that should not be included - * @var array must_exclude_one_ids Array with post ids of posts containing at least one word that needs to be excluded - * @var string type Searching type ('posts', 'topics') - * @var string fields Searching fields ('titleonly', 'msgonly', 'firstpost', 'all') - * @var string terms Searching terms ('all', 'any') - * @var int sort_days Time, in days, of the oldest possible post to list - * @var string sort_key The sort type used from the possible sort types - * @var int topic_id Limit the search to this topic_id only - * @var array ex_fid_ary Which forums not to search on - * @var string post_visibility Post visibility data - * @var array author_ary Array of user_id containing the users to filter the results to - * @since 3.1.7-RC1 - */ - $vars = array( - 'search_key_array', - 'must_contain_ids', - 'must_not_contain_ids', - 'must_exclude_one_ids', - 'type', - 'fields', - 'terms', - 'sort_days', - 'sort_key', - 'topic_id', - 'ex_fid_ary', - 'post_visibility', - 'author_ary', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_native_by_keyword_modify_search_key', compact($vars))); - - $search_key = md5(implode('#', $search_key_array)); - - // try reading the results from cache - $total_results = 0; - if ($this->obtain_ids($search_key, $total_results, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE) - { - return $total_results; - } - - $id_ary = array(); - - $sql_where = array(); - $m_num = 0; - $w_num = 0; - - $sql_array = array( - 'SELECT' => ($type == 'posts') ? 'p.post_id' : 'p.topic_id', - 'FROM' => array( - SEARCH_WORDMATCH_TABLE => array(), - SEARCH_WORDLIST_TABLE => array(), - ), - 'LEFT_JOIN' => array(array( - 'FROM' => array(POSTS_TABLE => 'p'), - 'ON' => 'm0.post_id = p.post_id', - )), - ); - - $title_match = ''; - $left_join_topics = false; - $group_by = true; - // Build some display specific sql strings - switch ($fields) - { - case 'titleonly': - $title_match = 'title_match = 1'; - $group_by = false; - // no break - case 'firstpost': - $left_join_topics = true; - $sql_where[] = 'p.post_id = t.topic_first_post_id'; - break; - - case 'msgonly': - $title_match = 'title_match = 0'; - $group_by = false; - break; - } - - if ($type == 'topics') - { - $left_join_topics = true; - $group_by = true; - } - - /** - * @todo Add a query optimizer (handle stuff like "+(4|3) +4") - */ - - foreach ($this->must_contain_ids as $subquery) - { - if (is_array($subquery)) - { - $group_by = true; - - $word_id_sql = array(); - $word_ids = array(); - foreach ($subquery as $id) - { - if (is_string($id)) - { - $sql_array['LEFT_JOIN'][] = array( - 'FROM' => array(SEARCH_WORDLIST_TABLE => 'w' . $w_num), - 'ON' => "w$w_num.word_text LIKE $id" - ); - $word_ids[] = "w$w_num.word_id"; - - $w_num++; - } - else - { - $word_ids[] = $id; - } - } - - $sql_where[] = $this->db->sql_in_set("m$m_num.word_id", $word_ids); - - unset($word_id_sql); - unset($word_ids); - } - else if (is_string($subquery)) - { - $sql_array['FROM'][SEARCH_WORDLIST_TABLE][] = 'w' . $w_num; - - $sql_where[] = "w$w_num.word_text LIKE $subquery"; - $sql_where[] = "m$m_num.word_id = w$w_num.word_id"; - - $group_by = true; - $w_num++; - } - else - { - $sql_where[] = "m$m_num.word_id = $subquery"; - } - - $sql_array['FROM'][SEARCH_WORDMATCH_TABLE][] = 'm' . $m_num; - - if ($title_match) - { - $sql_where[] = "m$m_num.$title_match"; - } - - if ($m_num != 0) - { - $sql_where[] = "m$m_num.post_id = m0.post_id"; - } - $m_num++; - } - - foreach ($this->must_not_contain_ids as $key => $subquery) - { - if (is_string($subquery)) - { - $sql_array['LEFT_JOIN'][] = array( - 'FROM' => array(SEARCH_WORDLIST_TABLE => 'w' . $w_num), - 'ON' => "w$w_num.word_text LIKE $subquery" - ); - - $this->must_not_contain_ids[$key] = "w$w_num.word_id"; - - $group_by = true; - $w_num++; - } - } - - if (count($this->must_not_contain_ids)) - { - $sql_array['LEFT_JOIN'][] = array( - 'FROM' => array(SEARCH_WORDMATCH_TABLE => 'm' . $m_num), - 'ON' => $this->db->sql_in_set("m$m_num.word_id", $this->must_not_contain_ids) . (($title_match) ? " AND m$m_num.$title_match" : '') . " AND m$m_num.post_id = m0.post_id" - ); - - $sql_where[] = "m$m_num.word_id IS NULL"; - $m_num++; - } - - foreach ($this->must_exclude_one_ids as $ids) - { - $is_null_joins = array(); - foreach ($ids as $id) - { - if (is_string($id)) - { - $sql_array['LEFT_JOIN'][] = array( - 'FROM' => array(SEARCH_WORDLIST_TABLE => 'w' . $w_num), - 'ON' => "w$w_num.word_text LIKE $id" - ); - $id = "w$w_num.word_id"; - - $group_by = true; - $w_num++; - } - - $sql_array['LEFT_JOIN'][] = array( - 'FROM' => array(SEARCH_WORDMATCH_TABLE => 'm' . $m_num), - 'ON' => "m$m_num.word_id = $id AND m$m_num.post_id = m0.post_id" . (($title_match) ? " AND m$m_num.$title_match" : '') - ); - $is_null_joins[] = "m$m_num.word_id IS NULL"; - - $m_num++; - } - $sql_where[] = '(' . implode(' OR ', $is_null_joins) . ')'; - } - - $sql_where[] = $post_visibility; - - $search_query = $this->search_query; - $must_exclude_one_ids = $this->must_exclude_one_ids; - $must_not_contain_ids = $this->must_not_contain_ids; - $must_contain_ids = $this->must_contain_ids; - - /** - * Allow changing the query used for counting for posts using fulltext_native - * - * @event core.search_native_keywords_count_query_before - * @var string search_query The parsed keywords used for this search - * @var array must_not_contain_ids Ids that cannot be taken into account for the results - * @var array must_exclude_one_ids Ids that cannot be on the results - * @var array must_contain_ids Ids that must be on the results - * @var int total_results The previous result count for the format of the query - * Set to 0 to force a re-count - * @var array sql_array The data on how to search in the DB at this point - * @var bool left_join_topics Whether or not TOPICS_TABLE should be CROSS JOIN'ED - * @var array author_ary Array of user_id containing the users to filter the results to - * @var string author_name An extra username to search on (!empty(author_ary) must be true, to be relevant) - * @var array ex_fid_ary Which forums not to search on - * @var int topic_id Limit the search to this topic_id only - * @var string sql_sort_table Extra tables to include in the SQL query. - * Used in conjunction with sql_sort_join - * @var string sql_sort_join SQL conditions to join all the tables used together. - * Used in conjunction with sql_sort_table - * @var int sort_days Time, in days, of the oldest possible post to list - * @var string sql_where An array of the current WHERE clause conditions - * @var string sql_match Which columns to do the search on - * @var string sql_match_where Extra conditions to use to properly filter the matching process - * @var bool group_by Whether or not the SQL query requires a GROUP BY for the elements in the SELECT clause - * @var string sort_by_sql The possible predefined sort types - * @var string sort_key The sort type used from the possible sort types - * @var string sort_dir "a" for ASC or "d" dor DESC for the sort order used - * @var string sql_sort The result SQL when processing sort_by_sql + sort_key + sort_dir - * @var int start How many posts to skip in the search results (used for pagination) - * @since 3.1.5-RC1 - */ - $vars = array( - 'search_query', - 'must_not_contain_ids', - 'must_exclude_one_ids', - 'must_contain_ids', - 'total_results', - 'sql_array', - 'left_join_topics', - 'author_ary', - 'author_name', - 'ex_fid_ary', - 'topic_id', - 'sql_sort_table', - 'sql_sort_join', - 'sort_days', - 'sql_where', - 'sql_match', - 'sql_match_where', - 'group_by', - 'sort_by_sql', - 'sort_key', - 'sort_dir', - 'sql_sort', - 'start', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_native_keywords_count_query_before', compact($vars))); - - if ($topic_id) - { - $sql_where[] = 'p.topic_id = ' . $topic_id; - } - - if (count($author_ary)) - { - if ($author_name) - { - // first one matches post of registered users, second one guests and deleted users - $sql_author = '(' . $this->db->sql_in_set('p.poster_id', array_diff($author_ary, array(ANONYMOUS)), false, true) . ' OR p.post_username ' . $author_name . ')'; - } - else - { - $sql_author = $this->db->sql_in_set('p.poster_id', $author_ary); - } - $sql_where[] = $sql_author; - } - - if (count($ex_fid_ary)) - { - $sql_where[] = $this->db->sql_in_set('p.forum_id', $ex_fid_ary, true); - } - - if ($sort_days) - { - $sql_where[] = 'p.post_time >= ' . (time() - ($sort_days * 86400)); - } - - $sql_array['WHERE'] = implode(' AND ', $sql_where); - - $is_mysql = false; - // if the total result count is not cached yet, retrieve it from the db - if (!$total_results) - { - $sql = ''; - $sql_array_count = $sql_array; - - if ($left_join_topics) - { - $sql_array_count['LEFT_JOIN'][] = array( - 'FROM' => array(TOPICS_TABLE => 't'), - 'ON' => 'p.topic_id = t.topic_id' - ); - } - - switch ($this->db->get_sql_layer()) - { - case 'mysql4': - case 'mysqli': - - // 3.x does not support SQL_CALC_FOUND_ROWS - // $sql_array['SELECT'] = 'SQL_CALC_FOUND_ROWS ' . $sql_array['SELECT']; - $is_mysql = true; - - break; - - case 'sqlite3': - $sql_array_count['SELECT'] = ($type == 'posts') ? 'DISTINCT p.post_id' : 'DISTINCT p.topic_id'; - $sql = 'SELECT COUNT(' . (($type == 'posts') ? 'post_id' : 'topic_id') . ') as total_results - FROM (' . $this->db->sql_build_query('SELECT', $sql_array_count) . ')'; - - // no break - - default: - $sql_array_count['SELECT'] = ($type == 'posts') ? 'COUNT(DISTINCT p.post_id) AS total_results' : 'COUNT(DISTINCT p.topic_id) AS total_results'; - $sql = (!$sql) ? $this->db->sql_build_query('SELECT', $sql_array_count) : $sql; - - $result = $this->db->sql_query($sql); - $total_results = (int) $this->db->sql_fetchfield('total_results'); - $this->db->sql_freeresult($result); - - if (!$total_results) - { - return false; - } - break; - } - - unset($sql_array_count, $sql); - } - - // Build sql strings for sorting - $sql_sort = $sort_by_sql[$sort_key] . (($sort_dir == 'a') ? ' ASC' : ' DESC'); - - switch ($sql_sort[0]) - { - case 'u': - $sql_array['FROM'][USERS_TABLE] = 'u'; - $sql_where[] = 'u.user_id = p.poster_id '; - break; - - case 't': - $left_join_topics = true; - break; - - case 'f': - $sql_array['FROM'][FORUMS_TABLE] = 'f'; - $sql_where[] = 'f.forum_id = p.forum_id'; - break; - } - - if ($left_join_topics) - { - $sql_array['LEFT_JOIN'][] = array( - 'FROM' => array(TOPICS_TABLE => 't'), - 'ON' => 'p.topic_id = t.topic_id' - ); - } - - // if using mysql and the total result count is not calculated yet, get it from the db - if (!$total_results && $is_mysql) - { - // Also count rows for the query as if there was not LIMIT. Add SQL_CALC_FOUND_ROWS to SQL - $sql_array['SELECT'] = 'SQL_CALC_FOUND_ROWS ' . $sql_array['SELECT']; - } - - $sql_array['WHERE'] = implode(' AND ', $sql_where); - $sql_array['GROUP_BY'] = ($group_by) ? (($type == 'posts') ? 'p.post_id' : 'p.topic_id') . ', ' . $sort_by_sql[$sort_key] : ''; - $sql_array['ORDER_BY'] = $sql_sort; - - unset($sql_where, $sql_sort, $group_by); - - $sql = $this->db->sql_build_query('SELECT', $sql_array); - $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); - - while ($row = $this->db->sql_fetchrow($result)) - { - $id_ary[] = (int) $row[(($type == 'posts') ? 'post_id' : 'topic_id')]; - } - $this->db->sql_freeresult($result); - - if (!$total_results && $is_mysql) - { - // Get the number of results as calculated by MySQL - $sql_count = 'SELECT FOUND_ROWS() as total_results'; - $result = $this->db->sql_query($sql_count); - $total_results = (int) $this->db->sql_fetchfield('total_results'); - $this->db->sql_freeresult($result); - - if (!$total_results) - { - return false; - } - } - - if ($start >= $total_results) - { - $start = floor(($total_results - 1) / $per_page) * $per_page; - - $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); - - while ($row = $this->db->sql_fetchrow($result)) - { - $id_ary[] = (int) $row[(($type == 'posts') ? 'post_id' : 'topic_id')]; - } - $this->db->sql_freeresult($result); - - } - - // store the ids, from start on then delete anything that isn't on the current page because we only need ids for one page - $this->save_ids($search_key, $this->search_query, $author_ary, $total_results, $id_ary, $start, $sort_dir); - $id_ary = array_slice($id_ary, 0, (int) $per_page); - - return $total_results; - } - - /** - * Performs a search on an author's posts without caring about message contents. Depends on display specific params - * - * @param string $type contains either posts or topics depending on what should be searched for - * @param boolean $firstpost_only if true, only topic starting posts will be considered - * @param array $sort_by_sql contains SQL code for the ORDER BY part of a query - * @param string $sort_key is the key of $sort_by_sql for the selected sorting - * @param string $sort_dir is either a or d representing ASC and DESC - * @param string $sort_days specifies the maximum amount of days a post may be old - * @param array $ex_fid_ary specifies an array of forum ids which should not be searched - * @param string $post_visibility specifies which types of posts the user can view in which forums - * @param int $topic_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched - * @param array $author_ary an array of author ids - * @param string $author_name specifies the author match, when ANONYMOUS is also a search-match - * @param array &$id_ary passed by reference, to be filled with ids for the page specified by $start and $per_page, should be ordered - * @param int $start indicates the first index of the page - * @param int $per_page number of ids each page is supposed to contain - * @return boolean|int total number of results - */ - public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page) - { - // No author? No posts - if (!count($author_ary)) - { - return 0; - } - - // generate a search_key from all the options to identify the results - $search_key_array = array( - '', - $type, - ($firstpost_only) ? 'firstpost' : '', - '', - '', - $sort_days, - $sort_key, - $topic_id, - implode(',', $ex_fid_ary), - $post_visibility, - implode(',', $author_ary), - $author_name, - ); - - /** - * Allow changing the search_key for cached results - * - * @event core.search_native_by_author_modify_search_key - * @var array search_key_array Array with search parameters to generate the search_key - * @var string type Searching type ('posts', 'topics') - * @var boolean firstpost_only Flag indicating if only topic starting posts are considered - * @var int sort_days Time, in days, of the oldest possible post to list - * @var string sort_key The sort type used from the possible sort types - * @var int topic_id Limit the search to this topic_id only - * @var array ex_fid_ary Which forums not to search on - * @var string post_visibility Post visibility data - * @var array author_ary Array of user_id containing the users to filter the results to - * @var string author_name The username to search on - * @since 3.1.7-RC1 - */ - $vars = array( - 'search_key_array', - 'type', - 'firstpost_only', - 'sort_days', - 'sort_key', - 'topic_id', - 'ex_fid_ary', - 'post_visibility', - 'author_ary', - 'author_name', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_native_by_author_modify_search_key', compact($vars))); - - $search_key = md5(implode('#', $search_key_array)); - - // try reading the results from cache - $total_results = 0; - if ($this->obtain_ids($search_key, $total_results, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE) - { - return $total_results; - } - - $id_ary = array(); - - // Create some display specific sql strings - if ($author_name) - { - // first one matches post of registered users, second one guests and deleted users - $sql_author = '(' . $this->db->sql_in_set('p.poster_id', array_diff($author_ary, array(ANONYMOUS)), false, true) . ' OR p.post_username ' . $author_name . ')'; - } - else - { - $sql_author = $this->db->sql_in_set('p.poster_id', $author_ary); - } - $sql_fora = (count($ex_fid_ary)) ? ' AND ' . $this->db->sql_in_set('p.forum_id', $ex_fid_ary, true) : ''; - $sql_time = ($sort_days) ? ' AND p.post_time >= ' . (time() - ($sort_days * 86400)) : ''; - $sql_topic_id = ($topic_id) ? ' AND p.topic_id = ' . (int) $topic_id : ''; - $sql_firstpost = ($firstpost_only) ? ' AND p.post_id = t.topic_first_post_id' : ''; - $post_visibility = ($post_visibility) ? ' AND ' . $post_visibility : ''; - - // Build sql strings for sorting - $sql_sort = $sort_by_sql[$sort_key] . (($sort_dir == 'a') ? ' ASC' : ' DESC'); - $sql_sort_table = $sql_sort_join = ''; - switch ($sql_sort[0]) - { - case 'u': - $sql_sort_table = USERS_TABLE . ' u, '; - $sql_sort_join = ' AND u.user_id = p.poster_id '; - break; - - case 't': - $sql_sort_table = ($type == 'posts' && !$firstpost_only) ? TOPICS_TABLE . ' t, ' : ''; - $sql_sort_join = ($type == 'posts' && !$firstpost_only) ? ' AND t.topic_id = p.topic_id ' : ''; - break; - - case 'f': - $sql_sort_table = FORUMS_TABLE . ' f, '; - $sql_sort_join = ' AND f.forum_id = p.forum_id '; - break; - } - - $select = ($type == 'posts') ? 'p.post_id' : 't.topic_id'; - $is_mysql = false; - - /** - * Allow changing the query used to search for posts by author in fulltext_native - * - * @event core.search_native_author_count_query_before - * @var int total_results The previous result count for the format of the query. - * Set to 0 to force a re-count - * @var string type The type of search being made - * @var string select SQL SELECT clause for what to get - * @var string sql_sort_table CROSS JOIN'ed table to allow doing the sort chosen - * @var string sql_sort_join Condition to define how to join the CROSS JOIN'ed table specifyed in sql_sort_table - * @var array sql_author SQL WHERE condition for the post author ids - * @var int topic_id Limit the search to this topic_id only - * @var string sort_by_sql The possible predefined sort types - * @var string sort_key The sort type used from the possible sort types - * @var string sort_dir "a" for ASC or "d" dor DESC for the sort order used - * @var string sql_sort The result SQL when processing sort_by_sql + sort_key + sort_dir - * @var string sort_days Time, in days, that the oldest post showing can have - * @var string sql_time The SQL to search on the time specifyed by sort_days - * @var bool firstpost_only Wether or not to search only on the first post of the topics - * @var string sql_firstpost The SQL used in the WHERE claused to filter by firstpost. - * @var array ex_fid_ary Forum ids that must not be searched on - * @var array sql_fora SQL query for ex_fid_ary - * @var int start How many posts to skip in the search results (used for pagination) - * @since 3.1.5-RC1 - */ - $vars = array( - 'total_results', - 'type', - 'select', - 'sql_sort_table', - 'sql_sort_join', - 'sql_author', - 'topic_id', - 'sort_by_sql', - 'sort_key', - 'sort_dir', - 'sql_sort', - 'sort_days', - 'sql_time', - 'firstpost_only', - 'sql_firstpost', - 'ex_fid_ary', - 'sql_fora', - 'start', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_native_author_count_query_before', compact($vars))); - - // If the cache was completely empty count the results - if (!$total_results) - { - switch ($this->db->get_sql_layer()) - { - case 'mysql4': - case 'mysqli': -// $select = 'SQL_CALC_FOUND_ROWS ' . $select; - $is_mysql = true; - break; - - default: - if ($type == 'posts') - { - $sql = 'SELECT COUNT(p.post_id) as total_results - FROM ' . POSTS_TABLE . ' p' . (($firstpost_only) ? ', ' . TOPICS_TABLE . ' t ' : ' ') . " - WHERE $sql_author - $sql_topic_id - $sql_firstpost - $post_visibility - $sql_fora - $sql_time"; - } - else - { - if ($this->db->get_sql_layer() == 'sqlite3') - { - $sql = 'SELECT COUNT(topic_id) as total_results - FROM (SELECT DISTINCT t.topic_id'; - } - else - { - $sql = 'SELECT COUNT(DISTINCT t.topic_id) as total_results'; - } - - $sql .= ' FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p - WHERE $sql_author - $sql_topic_id - $sql_firstpost - $post_visibility - $sql_fora - AND t.topic_id = p.topic_id - $sql_time" . ($this->db->get_sql_layer() == 'sqlite3' ? ')' : ''); - } - $result = $this->db->sql_query($sql); - - $total_results = (int) $this->db->sql_fetchfield('total_results'); - $this->db->sql_freeresult($result); - - if (!$total_results) - { - return false; - } - break; - } - } - - // Build the query for really selecting the post_ids - if ($type == 'posts') - { - $sql = "SELECT $select - FROM " . $sql_sort_table . POSTS_TABLE . ' p' . (($firstpost_only) ? ', ' . TOPICS_TABLE . ' t' : '') . " - WHERE $sql_author - $sql_topic_id - $sql_firstpost - $post_visibility - $sql_fora - $sql_sort_join - $sql_time - ORDER BY $sql_sort"; - $field = 'post_id'; - } - else - { - $sql = "SELECT $select - FROM " . $sql_sort_table . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p - WHERE $sql_author - $sql_topic_id - $sql_firstpost - $post_visibility - $sql_fora - AND t.topic_id = p.topic_id - $sql_sort_join - $sql_time - GROUP BY t.topic_id, " . $sort_by_sql[$sort_key] . ' - ORDER BY ' . $sql_sort; - $field = 'topic_id'; - } - - // Only read one block of posts from the db and then cache it - $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); - - while ($row = $this->db->sql_fetchrow($result)) - { - $id_ary[] = (int) $row[$field]; - } - $this->db->sql_freeresult($result); - - if (!$total_results && $is_mysql) - { - // Count rows for the executed queries. Replace $select within $sql with SQL_CALC_FOUND_ROWS, and run it. - $sql_calc = str_replace('SELECT ' . $select, 'SELECT SQL_CALC_FOUND_ROWS ' . $select, $sql); - - $result = $this->db->sql_query($sql_calc); - $this->db->sql_freeresult($result); - - $sql_count = 'SELECT FOUND_ROWS() as total_results'; - $result = $this->db->sql_query($sql_count); - $total_results = (int) $this->db->sql_fetchfield('total_results'); - $this->db->sql_freeresult($result); - - if (!$total_results) - { - return false; - } - } - - if ($start >= $total_results) - { - $start = floor(($total_results - 1) / $per_page) * $per_page; - - $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); - - while ($row = $this->db->sql_fetchrow($result)) - { - $id_ary[] = (int) $row[$field]; - } - $this->db->sql_freeresult($result); - } - - if (count($id_ary)) - { - $this->save_ids($search_key, '', $author_ary, $total_results, $id_ary, $start, $sort_dir); - $id_ary = array_slice($id_ary, 0, $per_page); - - return $total_results; - } - return false; - } - - /** - * Split a text into words of a given length - * - * The text is converted to UTF-8, cleaned up, and split. Then, words that - * conform to the defined length range are returned in an array. - * - * NOTE: duplicates are NOT removed from the return array - * - * @param string $text Text to split, encoded in UTF-8 - * @return array Array of UTF-8 words - */ - public function split_message($text) - { - $match = $words = array(); - - /** - * Taken from the original code - */ - // Do not index code - $match[] = '#\[code(?:=.*?)?(\:?[0-9a-z]{5,})\].*?\[\/code(\:?[0-9a-z]{5,})\]#is'; - // BBcode - $match[] = '#\[\/?[a-z0-9\*\+\-]+(?:=.*?)?(?::[a-z])?(\:?[0-9a-z]{5,})\]#'; - - $min = $this->word_length['min']; - - $isset_min = $min - 1; - - /** - * Clean up the string, remove HTML tags, remove BBCodes - */ - $word = strtok($this->cleanup(preg_replace($match, ' ', strip_tags($text)), -1), ' '); - - while (strlen($word)) - { - if (strlen($word) > 255 || strlen($word) <= $isset_min) - { - /** - * Words longer than 255 bytes are ignored. This will have to be - * changed whenever we change the length of search_wordlist.word_text - * - * Words shorter than $isset_min bytes are ignored, too - */ - $word = strtok(' '); - continue; - } - - $len = utf8_strlen($word); - - /** - * Test whether the word is too short to be indexed. - * - * Note that this limit does NOT apply to CJK and Hangul - */ - if ($len < $min) - { - /** - * Note: this could be optimized. If the codepoint is lower than Hangul's range - * we know that it will also be lower than CJK ranges - */ - if ((strncmp($word, self::UTF8_HANGUL_FIRST, 3) < 0 || strncmp($word, self::UTF8_HANGUL_LAST, 3) > 0) - && (strncmp($word, self::UTF8_CJK_FIRST, 3) < 0 || strncmp($word, self::UTF8_CJK_LAST, 3) > 0) - && (strncmp($word, self::UTF8_CJK_B_FIRST, 4) < 0 || strncmp($word, self::UTF8_CJK_B_LAST, 4) > 0)) - { - $word = strtok(' '); - continue; - } - } - - $words[] = $word; - $word = strtok(' '); - } - - return $words; - } - - /** - * Updates wordlist and wordmatch tables when a message is posted or changed - * - * @param string $mode Contains the post mode: edit, post, reply, quote - * @param int $post_id The id of the post which is modified/created - * @param string &$message New or updated post content - * @param string &$subject New or updated post subject - * @param int $poster_id Post author's user id - * @param int $forum_id The id of the forum in which the post is located - */ - public function index($mode, $post_id, &$message, &$subject, $poster_id, $forum_id) - { - if (!$this->config['fulltext_native_load_upd']) - { - /** - * The search indexer is disabled, return - */ - return; - } - - // Split old and new post/subject to obtain array of 'words' - $split_text = $this->split_message($message); - $split_title = $this->split_message($subject); - - $cur_words = array('post' => array(), 'title' => array()); - - $words = array(); - if ($mode == 'edit') - { - $words['add']['post'] = array(); - $words['add']['title'] = array(); - $words['del']['post'] = array(); - $words['del']['title'] = array(); - - $sql = 'SELECT w.word_id, w.word_text, m.title_match - FROM ' . SEARCH_WORDLIST_TABLE . ' w, ' . SEARCH_WORDMATCH_TABLE . " m - WHERE m.post_id = $post_id - AND w.word_id = m.word_id"; - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - $which = ($row['title_match']) ? 'title' : 'post'; - $cur_words[$which][$row['word_text']] = $row['word_id']; - } - $this->db->sql_freeresult($result); - - $words['add']['post'] = array_diff($split_text, array_keys($cur_words['post'])); - $words['add']['title'] = array_diff($split_title, array_keys($cur_words['title'])); - $words['del']['post'] = array_diff(array_keys($cur_words['post']), $split_text); - $words['del']['title'] = array_diff(array_keys($cur_words['title']), $split_title); - } - else - { - $words['add']['post'] = $split_text; - $words['add']['title'] = $split_title; - $words['del']['post'] = array(); - $words['del']['title'] = array(); - } - - /** - * Event to modify method arguments and words before the native search index is updated - * - * @event core.search_native_index_before - * @var string mode Contains the post mode: edit, post, reply, quote - * @var int post_id The id of the post which is modified/created - * @var string message New or updated post content - * @var string subject New or updated post subject - * @var int poster_id Post author's user id - * @var int forum_id The id of the forum in which the post is located - * @var array words Grouped lists of words added to or remove from the index - * @var array split_text Array of words from the message - * @var array split_title Array of words from the title - * @var array cur_words Array of words currently in the index for comparing to new words - * when mode is edit. Empty for other modes. - * @since 3.2.3-RC1 - */ - $vars = array( - 'mode', - 'post_id', - 'message', - 'subject', - 'poster_id', - 'forum_id', - 'words', - 'split_text', - 'split_title', - 'cur_words', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_native_index_before', compact($vars))); - - unset($split_text); - unset($split_title); - - // Get unique words from the above arrays - $unique_add_words = array_unique(array_merge($words['add']['post'], $words['add']['title'])); - - // We now have unique arrays of all words to be added and removed and - // individual arrays of added and removed words for text and title. What - // we need to do now is add the new words (if they don't already exist) - // and then add (or remove) matches between the words and this post - if (count($unique_add_words)) - { - $sql = 'SELECT word_id, word_text - FROM ' . SEARCH_WORDLIST_TABLE . ' - WHERE ' . $this->db->sql_in_set('word_text', $unique_add_words); - $result = $this->db->sql_query($sql); - - $word_ids = array(); - while ($row = $this->db->sql_fetchrow($result)) - { - $word_ids[$row['word_text']] = $row['word_id']; - } - $this->db->sql_freeresult($result); - $new_words = array_diff($unique_add_words, array_keys($word_ids)); - - $this->db->sql_transaction('begin'); - if (count($new_words)) - { - $sql_ary = array(); - - foreach ($new_words as $word) - { - $sql_ary[] = array('word_text' => (string) $word, 'word_count' => 0); - } - $this->db->sql_return_on_error(true); - $this->db->sql_multi_insert(SEARCH_WORDLIST_TABLE, $sql_ary); - $this->db->sql_return_on_error(false); - } - unset($new_words, $sql_ary); - } - else - { - $this->db->sql_transaction('begin'); - } - - // now update the search match table, remove links to removed words and add links to new words - foreach ($words['del'] as $word_in => $word_ary) - { - $title_match = ($word_in == 'title') ? 1 : 0; - - if (count($word_ary)) - { - $sql_in = array(); - foreach ($word_ary as $word) - { - $sql_in[] = $cur_words[$word_in][$word]; - } - - $sql = 'DELETE FROM ' . SEARCH_WORDMATCH_TABLE . ' - WHERE ' . $this->db->sql_in_set('word_id', $sql_in) . ' - AND post_id = ' . intval($post_id) . " - AND title_match = $title_match"; - $this->db->sql_query($sql); - - $sql = 'UPDATE ' . SEARCH_WORDLIST_TABLE . ' - SET word_count = word_count - 1 - WHERE ' . $this->db->sql_in_set('word_id', $sql_in) . ' - AND word_count > 0'; - $this->db->sql_query($sql); - - unset($sql_in); - } - } - - $this->db->sql_return_on_error(true); - foreach ($words['add'] as $word_in => $word_ary) - { - $title_match = ($word_in == 'title') ? 1 : 0; - - if (count($word_ary)) - { - $sql = 'INSERT INTO ' . SEARCH_WORDMATCH_TABLE . ' (post_id, word_id, title_match) - SELECT ' . (int) $post_id . ', word_id, ' . (int) $title_match . ' - FROM ' . SEARCH_WORDLIST_TABLE . ' - WHERE ' . $this->db->sql_in_set('word_text', $word_ary); - $this->db->sql_query($sql); - - $sql = 'UPDATE ' . SEARCH_WORDLIST_TABLE . ' - SET word_count = word_count + 1 - WHERE ' . $this->db->sql_in_set('word_text', $word_ary); - $this->db->sql_query($sql); - } - } - $this->db->sql_return_on_error(false); - - $this->db->sql_transaction('commit'); - - // destroy cached search results containing any of the words removed or added - $this->destroy_cache(array_unique(array_merge($words['add']['post'], $words['add']['title'], $words['del']['post'], $words['del']['title'])), array($poster_id)); - - unset($unique_add_words); - unset($words); - unset($cur_words); - } - - /** - * Removes entries from the wordmatch table for the specified post_ids - */ - public function index_remove($post_ids, $author_ids, $forum_ids) - { - if (count($post_ids)) - { - $sql = 'SELECT w.word_id, w.word_text, m.title_match - FROM ' . SEARCH_WORDMATCH_TABLE . ' m, ' . SEARCH_WORDLIST_TABLE . ' w - WHERE ' . $this->db->sql_in_set('m.post_id', $post_ids) . ' - AND w.word_id = m.word_id'; - $result = $this->db->sql_query($sql); - - $message_word_ids = $title_word_ids = $word_texts = array(); - while ($row = $this->db->sql_fetchrow($result)) - { - if ($row['title_match']) - { - $title_word_ids[] = $row['word_id']; - } - else - { - $message_word_ids[] = $row['word_id']; - } - $word_texts[] = $row['word_text']; - } - $this->db->sql_freeresult($result); - - if (count($title_word_ids)) - { - $sql = 'UPDATE ' . SEARCH_WORDLIST_TABLE . ' - SET word_count = word_count - 1 - WHERE ' . $this->db->sql_in_set('word_id', $title_word_ids) . ' - AND word_count > 0'; - $this->db->sql_query($sql); - } - - if (count($message_word_ids)) - { - $sql = 'UPDATE ' . SEARCH_WORDLIST_TABLE . ' - SET word_count = word_count - 1 - WHERE ' . $this->db->sql_in_set('word_id', $message_word_ids) . ' - AND word_count > 0'; - $this->db->sql_query($sql); - } - - unset($title_word_ids); - unset($message_word_ids); - - $sql = 'DELETE FROM ' . SEARCH_WORDMATCH_TABLE . ' - WHERE ' . $this->db->sql_in_set('post_id', $post_ids); - $this->db->sql_query($sql); - } - - $this->destroy_cache(array_unique($word_texts), array_unique($author_ids)); - } - - /** - * Tidy up indexes: Tag 'common words' and remove - * words no longer referenced in the match table - */ - public function tidy() - { - // Is the fulltext indexer disabled? If yes then we need not - // carry on ... it's okay ... I know when I'm not wanted boo hoo - if (!$this->config['fulltext_native_load_upd']) - { - $this->config->set('search_last_gc', time(), false); - return; - } - - $destroy_cache_words = array(); - - // Remove common words - if ($this->config['num_posts'] >= 100 && $this->config['fulltext_native_common_thres']) - { - $common_threshold = ((double) $this->config['fulltext_native_common_thres']) / 100.0; - // First, get the IDs of common words - $sql = 'SELECT word_id, word_text - FROM ' . SEARCH_WORDLIST_TABLE . ' - WHERE word_count > ' . floor($this->config['num_posts'] * $common_threshold) . ' - OR word_common = 1'; - $result = $this->db->sql_query($sql); - - $sql_in = array(); - while ($row = $this->db->sql_fetchrow($result)) - { - $sql_in[] = $row['word_id']; - $destroy_cache_words[] = $row['word_text']; - } - $this->db->sql_freeresult($result); - - if (count($sql_in)) - { - // Flag the words - $sql = 'UPDATE ' . SEARCH_WORDLIST_TABLE . ' - SET word_common = 1 - WHERE ' . $this->db->sql_in_set('word_id', $sql_in); - $this->db->sql_query($sql); - - // by setting search_last_gc to the new time here we make sure that if a user reloads because the - // following query takes too long, he won't run into it again - $this->config->set('search_last_gc', time(), false); - - // Delete the matches - $sql = 'DELETE FROM ' . SEARCH_WORDMATCH_TABLE . ' - WHERE ' . $this->db->sql_in_set('word_id', $sql_in); - $this->db->sql_query($sql); - } - unset($sql_in); - } - - if (count($destroy_cache_words)) - { - // destroy cached search results containing any of the words that are now common or were removed - $this->destroy_cache(array_unique($destroy_cache_words)); - } - - $this->config->set('search_last_gc', time(), false); - } - - /** - * Deletes all words from the index - */ - public function delete_index($acp_module, $u_action) - { - $sql_queries = []; - - switch ($this->db->get_sql_layer()) - { - case 'sqlite3': - $sql_queries[] = 'DELETE FROM ' . SEARCH_WORDLIST_TABLE; - $sql_queries[] = 'DELETE FROM ' . SEARCH_WORDMATCH_TABLE; - $sql_queries[] = 'DELETE FROM ' . SEARCH_RESULTS_TABLE; - break; - - default: - $sql_queries[] = 'TRUNCATE TABLE ' . SEARCH_WORDLIST_TABLE; - $sql_queries[] = 'TRUNCATE TABLE ' . SEARCH_WORDMATCH_TABLE; - $sql_queries[] = 'TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE; - break; - } - - $stats = $this->stats; - - /** - * Event to modify SQL queries before the native search index is deleted - * - * @event core.search_native_delete_index_before - * @var array sql_queries Array with queries for deleting the search index - * @var array stats Array with statistics of the current index (read only) - * @since 3.2.3-RC1 - */ - $vars = array( - 'sql_queries', - 'stats', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_native_delete_index_before', compact($vars))); - - foreach ($sql_queries as $sql_query) - { - $this->db->sql_query($sql_query); - } - } - - /** - * Returns true if both FULLTEXT indexes exist - */ - public function index_created() - { - if (!count($this->stats)) - { - $this->get_stats(); - } - - return ($this->stats['total_words'] && $this->stats['total_matches']) ? true : false; - } - - /** - * Returns an associative array containing information about the indexes - */ - public function index_stats() - { - if (!count($this->stats)) - { - $this->get_stats(); - } - - return array( - $this->user->lang['TOTAL_WORDS'] => $this->stats['total_words'], - $this->user->lang['TOTAL_MATCHES'] => $this->stats['total_matches']); - } - - protected function get_stats() - { - $this->stats['total_words'] = $this->db->get_estimated_row_count(SEARCH_WORDLIST_TABLE); - $this->stats['total_matches'] = $this->db->get_estimated_row_count(SEARCH_WORDMATCH_TABLE); - } - - /** - * Clean up a text to remove non-alphanumeric characters - * - * This method receives a UTF-8 string, normalizes and validates it, replaces all - * non-alphanumeric characters with strings then returns the result. - * - * Any number of "allowed chars" can be passed as a UTF-8 string in NFC. - * - * @param string $text Text to split, in UTF-8 (not normalized or sanitized) - * @param string $allowed_chars String of special chars to allow - * @param string $encoding Text encoding - * @return string Cleaned up text, only alphanumeric chars are left - */ - protected function cleanup($text, $allowed_chars = null, $encoding = 'utf-8') - { - static $conv = array(), $conv_loaded = array(); - $allow = array(); - - // Convert the text to UTF-8 - $encoding = strtolower($encoding); - if ($encoding != 'utf-8') - { - $text = utf8_recode($text, $encoding); - } - - $utf_len_mask = array( - "\xC0" => 2, - "\xD0" => 2, - "\xE0" => 3, - "\xF0" => 4 - ); - - /** - * Replace HTML entities and NCRs - */ - $text = htmlspecialchars_decode(utf8_decode_ncr($text), ENT_QUOTES); - - /** - * Normalize to NFC - */ - $text = \Normalizer::normalize($text); - - /** - * The first thing we do is: - * - * - convert ASCII-7 letters to lowercase - * - remove the ASCII-7 non-alpha characters - * - remove the bytes that should not appear in a valid UTF-8 string: 0xC0, - * 0xC1 and 0xF5-0xFF - * - * @todo in theory, the third one is already taken care of during normalization and those chars should have been replaced by Unicode replacement chars - */ - $sb_match = "ISTCPAMELRDOJBNHFGVWUQKYXZ\r\n\t!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~\x00\x01\x02\x03\x04\x05\x06\x07\x08\x0B\x0C\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\xC0\xC1\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF"; - $sb_replace = 'istcpamelrdojbnhfgvwuqkyxz '; - - /** - * This is the list of legal ASCII chars, it is automatically extended - * with ASCII chars from $allowed_chars - */ - $legal_ascii = ' eaisntroludcpmghbfvq10xy2j9kw354867z'; - - /** - * Prepare an array containing the extra chars to allow - */ - if (isset($allowed_chars[0])) - { - $pos = 0; - $len = strlen($allowed_chars); - do - { - $c = $allowed_chars[$pos]; - - if ($c < "\x80") - { - /** - * ASCII char - */ - $sb_pos = strpos($sb_match, $c); - if (is_int($sb_pos)) - { - /** - * Remove the char from $sb_match and its corresponding - * replacement in $sb_replace - */ - $sb_match = substr($sb_match, 0, $sb_pos) . substr($sb_match, $sb_pos + 1); - $sb_replace = substr($sb_replace, 0, $sb_pos) . substr($sb_replace, $sb_pos + 1); - $legal_ascii .= $c; - } - - ++$pos; - } - else - { - /** - * UTF-8 char - */ - $utf_len = $utf_len_mask[$c & "\xF0"]; - $allow[substr($allowed_chars, $pos, $utf_len)] = 1; - $pos += $utf_len; - } - } - while ($pos < $len); - } - - $text = strtr($text, $sb_match, $sb_replace); - $ret = ''; - - $pos = 0; - $len = strlen($text); - - do - { - /** - * Do all consecutive ASCII chars at once - */ - if ($spn = strspn($text, $legal_ascii, $pos)) - { - $ret .= substr($text, $pos, $spn); - $pos += $spn; - } - - if ($pos >= $len) - { - return $ret; - } - - /** - * Capture the UTF char - */ - $utf_len = $utf_len_mask[$text[$pos] & "\xF0"]; - $utf_char = substr($text, $pos, $utf_len); - $pos += $utf_len; - - if (($utf_char >= self::UTF8_HANGUL_FIRST && $utf_char <= self::UTF8_HANGUL_LAST) - || ($utf_char >= self::UTF8_CJK_FIRST && $utf_char <= self::UTF8_CJK_LAST) - || ($utf_char >= self::UTF8_CJK_B_FIRST && $utf_char <= self::UTF8_CJK_B_LAST)) - { - /** - * All characters within these ranges are valid - * - * We separate them with a space in order to index each character - * individually - */ - $ret .= ' ' . $utf_char . ' '; - continue; - } - - if (isset($allow[$utf_char])) - { - /** - * The char is explicitly allowed - */ - $ret .= $utf_char; - continue; - } - - if (isset($conv[$utf_char])) - { - /** - * The char is mapped to something, maybe to itself actually - */ - $ret .= $conv[$utf_char]; - continue; - } - - /** - * The char isn't mapped, but did we load its conversion table? - * - * The search indexer table is split into blocks. The block number of - * each char is equal to its codepoint right-shifted for 11 bits. It - * means that out of the 11, 16 or 21 meaningful bits of a 2-, 3- or - * 4- byte sequence we only keep the leftmost 0, 5 or 10 bits. Thus, - * all UTF chars encoded in 2 bytes are in the same first block. - */ - if (isset($utf_char[2])) - { - if (isset($utf_char[3])) - { - /** - * 1111 0nnn 10nn nnnn 10nx xxxx 10xx xxxx - * 0000 0111 0011 1111 0010 0000 - */ - $idx = ((ord($utf_char[0]) & 0x07) << 7) | ((ord($utf_char[1]) & 0x3F) << 1) | ((ord($utf_char[2]) & 0x20) >> 5); - } - else - { - /** - * 1110 nnnn 10nx xxxx 10xx xxxx - * 0000 0111 0010 0000 - */ - $idx = ((ord($utf_char[0]) & 0x07) << 1) | ((ord($utf_char[1]) & 0x20) >> 5); - } - } - else - { - /** - * 110x xxxx 10xx xxxx - * 0000 0000 0000 0000 - */ - $idx = 0; - } - - /** - * Check if the required conv table has been loaded already - */ - if (!isset($conv_loaded[$idx])) - { - $conv_loaded[$idx] = 1; - $file = $this->phpbb_root_path . 'includes/utf/data/search_indexer_' . $idx . '.' . $this->php_ext; - - if (file_exists($file)) - { - $conv += include($file); - } - } - - if (isset($conv[$utf_char])) - { - $ret .= $conv[$utf_char]; - } - else - { - /** - * We add an entry to the conversion table so that we - * don't have to convert to codepoint and perform the checks - * that are above this block - */ - $conv[$utf_char] = ' '; - $ret .= ' '; - } - } - while (1); - - return $ret; - } - - /** - * Returns a list of options for the ACP to display - */ - public function acp() - { - /** - * if we need any options, copied from fulltext_native for now, will have to be adjusted or removed - */ - - $tpl = ' -
-

' . $this->user->lang['YES_SEARCH_UPDATE_EXPLAIN'] . '
-
-
-
-

' . $this->user->lang['MIN_SEARCH_CHARS_EXPLAIN'] . '
-
-
-
-

' . $this->user->lang['MAX_SEARCH_CHARS_EXPLAIN'] . '
-
-
-
-

' . $this->user->lang['COMMON_WORD_THRESHOLD_EXPLAIN'] . '
-
%
-
- '; - - // These are fields required in the config table - return array( - 'tpl' => $tpl, - 'config' => array('fulltext_native_load_upd' => 'bool', 'fulltext_native_min_chars' => 'integer:0:255', 'fulltext_native_max_chars' => 'integer:0:255', 'fulltext_native_common_thres' => 'double:0:100') - ); - } -} diff --git a/install/update/old/phpbb/search/fulltext_postgres.php b/install/update/old/phpbb/search/fulltext_postgres.php deleted file mode 100644 index 2f387e7..0000000 --- a/install/update/old/phpbb/search/fulltext_postgres.php +++ /dev/null @@ -1,1178 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\search; - -/** -* Fulltext search for PostgreSQL -*/ -class fulltext_postgres extends \phpbb\search\base -{ - /** - * Associative array holding index stats - * @var array - */ - protected $stats = array(); - - /** - * Holds the words entered by user, obtained by splitting the entered query on whitespace - * @var array - */ - protected $split_words = array(); - - /** - * Stores the tsearch query - * @var string - */ - protected $tsearch_query; - - /** - * True if phrase search is supported. - * PostgreSQL fulltext currently doesn't support it - * @var boolean - */ - protected $phrase_search = false; - - /** - * Config object - * @var \phpbb\config\config - */ - protected $config; - - /** - * Database connection - * @var \phpbb\db\driver\driver_interface - */ - protected $db; - - /** - * phpBB event dispatcher object - * @var \phpbb\event\dispatcher_interface - */ - protected $phpbb_dispatcher; - - /** - * User object - * @var \phpbb\user - */ - protected $user; - - /** - * Contains tidied search query. - * Operators are prefixed in search query and common words excluded - * @var string - */ - protected $search_query; - - /** - * Contains common words. - * Common words are words with length less/more than min/max length - * @var array - */ - protected $common_words = array(); - - /** - * Associative array stores the min and max word length to be searched - * @var array - */ - protected $word_length = array(); - - /** - * Constructor - * Creates a new \phpbb\search\fulltext_postgres, which is used as a search backend - * - * @param string|bool $error Any error that occurs is passed on through this reference variable otherwise false - * @param string $phpbb_root_path Relative path to phpBB root - * @param string $phpEx PHP file extension - * @param \phpbb\auth\auth $auth Auth object - * @param \phpbb\config\config $config Config object - * @param \phpbb\db\driver\driver_interface Database object - * @param \phpbb\user $user User object - * @param \phpbb\event\dispatcher_interface $phpbb_dispatcher Event dispatcher object - */ - public function __construct(&$error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher) - { - $this->config = $config; - $this->db = $db; - $this->phpbb_dispatcher = $phpbb_dispatcher; - $this->user = $user; - - $this->word_length = array('min' => $this->config['fulltext_postgres_min_word_len'], 'max' => $this->config['fulltext_postgres_max_word_len']); - - /** - * Load the UTF tools - */ - if (!function_exists('utf8_strlen')) - { - include($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); - } - - $error = false; - } - - /** - * Returns the name of this search backend to be displayed to administrators - * - * @return string Name - */ - public function get_name() - { - return 'PostgreSQL Fulltext'; - } - - /** - * Returns the search_query - * - * @return string search query - */ - public function get_search_query() - { - return $this->search_query; - } - - /** - * Returns the common_words array - * - * @return array common words that are ignored by search backend - */ - public function get_common_words() - { - return $this->common_words; - } - - /** - * Returns the word_length array - * - * @return array min and max word length for searching - */ - public function get_word_length() - { - return $this->word_length; - } - - /** - * Returns if phrase search is supported or not - * - * @return bool - */ - public function supports_phrase_search() - { - return $this->phrase_search; - } - - /** - * Checks for correct PostgreSQL version and stores min/max word length in the config - * - * @return string|bool Language key of the error/incompatiblity occurred - */ - public function init() - { - if ($this->db->get_sql_layer() != 'postgres') - { - return $this->user->lang['FULLTEXT_POSTGRES_INCOMPATIBLE_DATABASE']; - } - - return false; - } - - /** - * Splits keywords entered by a user into an array of words stored in $this->split_words - * Stores the tidied search query in $this->search_query - * - * @param string &$keywords Contains the keyword as entered by the user - * @param string $terms is either 'all' or 'any' - * @return bool false if no valid keywords were found and otherwise true - */ - public function split_keywords(&$keywords, $terms) - { - if ($terms == 'all') - { - $match = array('#\sand\s#iu', '#\sor\s#iu', '#\snot\s#iu', '#(^|\s)\+#', '#(^|\s)-#', '#(^|\s)\|#'); - $replace = array(' +', ' |', ' -', ' +', ' -', ' |'); - - $keywords = preg_replace($match, $replace, $keywords); - } - - // Filter out as above - $split_keywords = preg_replace("#[\"\n\r\t]+#", ' ', trim(htmlspecialchars_decode($keywords))); - - // Split words - $split_keywords = preg_replace('#([^\p{L}\p{N}\'*"()])#u', '$1$1', str_replace('\'\'', '\' \'', trim($split_keywords))); - $matches = array(); - preg_match_all('#(?:[^\p{L}\p{N}*"()]|^)([+\-|]?(?:[\p{L}\p{N}*"()]+\'?)*[\p{L}\p{N}*"()])(?:[^\p{L}\p{N}*"()]|$)#u', $split_keywords, $matches); - $this->split_words = $matches[1]; - - foreach ($this->split_words as $i => $word) - { - $clean_word = preg_replace('#^[+\-|"]#', '', $word); - - // check word length - $clean_len = utf8_strlen(str_replace('*', '', $clean_word)); - if (($clean_len < $this->config['fulltext_postgres_min_word_len']) || ($clean_len > $this->config['fulltext_postgres_max_word_len'])) - { - $this->common_words[] = $word; - unset($this->split_words[$i]); - } - } - - if ($terms == 'any') - { - $this->search_query = ''; - $this->tsearch_query = ''; - foreach ($this->split_words as $word) - { - if ((strpos($word, '+') === 0) || (strpos($word, '-') === 0) || (strpos($word, '|') === 0)) - { - $word = substr($word, 1); - } - $this->search_query .= $word . ' '; - $this->tsearch_query .= '|' . $word . ' '; - } - } - else - { - $this->search_query = ''; - $this->tsearch_query = ''; - foreach ($this->split_words as $word) - { - if (strpos($word, '+') === 0) - { - $this->search_query .= $word . ' '; - $this->tsearch_query .= '&' . substr($word, 1) . ' '; - } - else if (strpos($word, '-') === 0) - { - $this->search_query .= $word . ' '; - $this->tsearch_query .= '&!' . substr($word, 1) . ' '; - } - else if (strpos($word, '|') === 0) - { - $this->search_query .= $word . ' '; - $this->tsearch_query .= '|' . substr($word, 1) . ' '; - } - else - { - $this->search_query .= '+' . $word . ' '; - $this->tsearch_query .= '&' . $word . ' '; - } - } - } - - $this->tsearch_query = substr($this->tsearch_query, 1); - $this->search_query = utf8_htmlspecialchars($this->search_query); - - if ($this->search_query) - { - $this->split_words = array_values($this->split_words); - sort($this->split_words); - return true; - } - return false; - } - - /** - * Turns text into an array of words - * @param string $text contains post text/subject - */ - public function split_message($text) - { - // Split words - $text = preg_replace('#([^\p{L}\p{N}\'*])#u', '$1$1', str_replace('\'\'', '\' \'', trim($text))); - $matches = array(); - preg_match_all('#(?:[^\p{L}\p{N}*]|^)([+\-|]?(?:[\p{L}\p{N}*]+\'?)*[\p{L}\p{N}*])(?:[^\p{L}\p{N}*]|$)#u', $text, $matches); - $text = $matches[1]; - - // remove too short or too long words - $text = array_values($text); - for ($i = 0, $n = count($text); $i < $n; $i++) - { - $text[$i] = trim($text[$i]); - if (utf8_strlen($text[$i]) < $this->config['fulltext_postgres_min_word_len'] || utf8_strlen($text[$i]) > $this->config['fulltext_postgres_max_word_len']) - { - unset($text[$i]); - } - } - - return array_values($text); - } - - /** - * Performs a search on keywords depending on display specific params. You have to run split_keywords() first - * - * @param string $type contains either posts or topics depending on what should be searched for - * @param string $fields contains either titleonly (topic titles should be searched), msgonly (only message bodies should be searched), firstpost (only subject and body of the first post should be searched) or all (all post bodies and subjects should be searched) - * @param string $terms is either 'all' (use query as entered, words without prefix should default to "have to be in field") or 'any' (ignore search query parts and just return all posts that contain any of the specified words) - * @param array $sort_by_sql contains SQL code for the ORDER BY part of a query - * @param string $sort_key is the key of $sort_by_sql for the selected sorting - * @param string $sort_dir is either a or d representing ASC and DESC - * @param string $sort_days specifies the maximum amount of days a post may be old - * @param array $ex_fid_ary specifies an array of forum ids which should not be searched - * @param string $post_visibility specifies which types of posts the user can view in which forums - * @param int $topic_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched - * @param array $author_ary an array of author ids if the author should be ignored during the search the array is empty - * @param string $author_name specifies the author match, when ANONYMOUS is also a search-match - * @param array &$id_ary passed by reference, to be filled with ids for the page specified by $start and $per_page, should be ordered - * @param int $start indicates the first index of the page - * @param int $per_page number of ids each page is supposed to contain - * @return boolean|int total number of results - */ - public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page) - { - // No keywords? No posts - if (!$this->search_query) - { - return false; - } - - // When search query contains queries like -foo - if (strpos($this->search_query, '+') === false) - { - return false; - } - - // generate a search_key from all the options to identify the results - $search_key_array = array( - implode(', ', $this->split_words), - $type, - $fields, - $terms, - $sort_days, - $sort_key, - $topic_id, - implode(',', $ex_fid_ary), - $post_visibility, - implode(',', $author_ary) - ); - - /** - * Allow changing the search_key for cached results - * - * @event core.search_postgres_by_keyword_modify_search_key - * @var array search_key_array Array with search parameters to generate the search_key - * @var string type Searching type ('posts', 'topics') - * @var string fields Searching fields ('titleonly', 'msgonly', 'firstpost', 'all') - * @var string terms Searching terms ('all', 'any') - * @var int sort_days Time, in days, of the oldest possible post to list - * @var string sort_key The sort type used from the possible sort types - * @var int topic_id Limit the search to this topic_id only - * @var array ex_fid_ary Which forums not to search on - * @var string post_visibility Post visibility data - * @var array author_ary Array of user_id containing the users to filter the results to - * @since 3.1.7-RC1 - */ - $vars = array( - 'search_key_array', - 'type', - 'fields', - 'terms', - 'sort_days', - 'sort_key', - 'topic_id', - 'ex_fid_ary', - 'post_visibility', - 'author_ary', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_postgres_by_keyword_modify_search_key', compact($vars))); - - $search_key = md5(implode('#', $search_key_array)); - - if ($start < 0) - { - $start = 0; - } - - // try reading the results from cache - $result_count = 0; - if ($this->obtain_ids($search_key, $result_count, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE) - { - return $result_count; - } - - $id_ary = array(); - - $join_topic = ($type == 'posts') ? false : true; - - // Build sql strings for sorting - $sql_sort = $sort_by_sql[$sort_key] . (($sort_dir == 'a') ? ' ASC' : ' DESC'); - $sql_sort_table = $sql_sort_join = ''; - - switch ($sql_sort[0]) - { - case 'u': - $sql_sort_table = USERS_TABLE . ' u, '; - $sql_sort_join = ($type == 'posts') ? ' AND u.user_id = p.poster_id ' : ' AND u.user_id = t.topic_poster '; - break; - - case 't': - $join_topic = true; - break; - - case 'f': - $sql_sort_table = FORUMS_TABLE . ' f, '; - $sql_sort_join = ' AND f.forum_id = p.forum_id '; - break; - } - - // Build some display specific sql strings - switch ($fields) - { - case 'titleonly': - $sql_match = 'p.post_subject'; - $sql_match_where = ' AND p.post_id = t.topic_first_post_id'; - $join_topic = true; - break; - - case 'msgonly': - $sql_match = 'p.post_text'; - $sql_match_where = ''; - break; - - case 'firstpost': - $sql_match = 'p.post_subject, p.post_text'; - $sql_match_where = ' AND p.post_id = t.topic_first_post_id'; - $join_topic = true; - break; - - default: - $sql_match = 'p.post_subject, p.post_text'; - $sql_match_where = ''; - break; - } - - $tsearch_query = $this->tsearch_query; - - /** - * Allow changing the query used to search for posts using fulltext_postgres - * - * @event core.search_postgres_keywords_main_query_before - * @var string tsearch_query The parsed keywords used for this search - * @var int result_count The previous result count for the format of the query. - * Set to 0 to force a re-count - * @var bool join_topic Weather or not TOPICS_TABLE should be CROSS JOIN'ED - * @var array author_ary Array of user_id containing the users to filter the results to - * @var string author_name An extra username to search on (!empty(author_ary) must be true, to be relevant) - * @var array ex_fid_ary Which forums not to search on - * @var int topic_id Limit the search to this topic_id only - * @var string sql_sort_table Extra tables to include in the SQL query. - * Used in conjunction with sql_sort_join - * @var string sql_sort_join SQL conditions to join all the tables used together. - * Used in conjunction with sql_sort_table - * @var int sort_days Time, in days, of the oldest possible post to list - * @var string sql_match Which columns to do the search on. - * @var string sql_match_where Extra conditions to use to properly filter the matching process - * @var string sort_by_sql The possible predefined sort types - * @var string sort_key The sort type used from the possible sort types - * @var string sort_dir "a" for ASC or "d" dor DESC for the sort order used - * @var string sql_sort The result SQL when processing sort_by_sql + sort_key + sort_dir - * @var int start How many posts to skip in the search results (used for pagination) - * @since 3.1.5-RC1 - */ - $vars = array( - 'tsearch_query', - 'result_count', - 'join_topic', - 'author_ary', - 'author_name', - 'ex_fid_ary', - 'topic_id', - 'sql_sort_table', - 'sql_sort_join', - 'sort_days', - 'sql_match', - 'sql_match_where', - 'sort_by_sql', - 'sort_key', - 'sort_dir', - 'sql_sort', - 'start', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_postgres_keywords_main_query_before', compact($vars))); - - $sql_select = ($type == 'posts') ? 'p.post_id' : 'DISTINCT t.topic_id, ' . $sort_by_sql[$sort_key]; - $sql_from = ($join_topic) ? TOPICS_TABLE . ' t, ' : ''; - $field = ($type == 'posts') ? 'post_id' : 'topic_id'; - - if (count($author_ary) && $author_name) - { - // first one matches post of registered users, second one guests and deleted users - $sql_author = '(' . $this->db->sql_in_set('p.poster_id', array_diff($author_ary, array(ANONYMOUS)), false, true) . ' OR p.post_username ' . $author_name . ')'; - } - else if (count($author_ary)) - { - $sql_author = ' AND ' . $this->db->sql_in_set('p.poster_id', $author_ary); - } - else - { - $sql_author = ''; - } - - $sql_where_options = $sql_sort_join; - $sql_where_options .= ($topic_id) ? ' AND p.topic_id = ' . $topic_id : ''; - $sql_where_options .= ($join_topic) ? ' AND t.topic_id = p.topic_id' : ''; - $sql_where_options .= (count($ex_fid_ary)) ? ' AND ' . $this->db->sql_in_set('p.forum_id', $ex_fid_ary, true) : ''; - $sql_where_options .= ' AND ' . $post_visibility; - $sql_where_options .= $sql_author; - $sql_where_options .= ($sort_days) ? ' AND p.post_time >= ' . (time() - ($sort_days * 86400)) : ''; - $sql_where_options .= $sql_match_where; - - $sql_match = str_replace(',', " || ' ' ||", $sql_match); - $tmp_sql_match = "to_tsvector ('" . $this->db->sql_escape($this->config['fulltext_postgres_ts_name']) . "', " . $sql_match . ") @@ to_tsquery ('" . $this->db->sql_escape($this->config['fulltext_postgres_ts_name']) . "', '" . $this->db->sql_escape($this->tsearch_query) . "')"; - - $this->db->sql_transaction('begin'); - - $sql_from = "FROM $sql_from$sql_sort_table" . POSTS_TABLE . " p"; - $sql_where = "WHERE (" . $tmp_sql_match . ") - $sql_where_options"; - $sql = "SELECT $sql_select - $sql_from - $sql_where - ORDER BY $sql_sort"; - $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); - - while ($row = $this->db->sql_fetchrow($result)) - { - $id_ary[] = $row[$field]; - } - $this->db->sql_freeresult($result); - - $id_ary = array_unique($id_ary); - - // if the total result count is not cached yet, retrieve it from the db - if (!$result_count) - { - $sql_count = "SELECT COUNT(*) as result_count - $sql_from - $sql_where"; - $result = $this->db->sql_query($sql_count); - $result_count = (int) $this->db->sql_fetchfield('result_count'); - $this->db->sql_freeresult($result); - - if (!$result_count) - { - return false; - } - } - - $this->db->sql_transaction('commit'); - - if ($start >= $result_count) - { - $start = floor(($result_count - 1) / $per_page) * $per_page; - - $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); - - while ($row = $this->db->sql_fetchrow($result)) - { - $id_ary[] = $row[$field]; - } - $this->db->sql_freeresult($result); - - $id_ary = array_unique($id_ary); - } - - // store the ids, from start on then delete anything that isn't on the current page because we only need ids for one page - $this->save_ids($search_key, implode(' ', $this->split_words), $author_ary, $result_count, $id_ary, $start, $sort_dir); - $id_ary = array_slice($id_ary, 0, (int) $per_page); - - return $result_count; - } - - /** - * Performs a search on an author's posts without caring about message contents. Depends on display specific params - * - * @param string $type contains either posts or topics depending on what should be searched for - * @param boolean $firstpost_only if true, only topic starting posts will be considered - * @param array $sort_by_sql contains SQL code for the ORDER BY part of a query - * @param string $sort_key is the key of $sort_by_sql for the selected sorting - * @param string $sort_dir is either a or d representing ASC and DESC - * @param string $sort_days specifies the maximum amount of days a post may be old - * @param array $ex_fid_ary specifies an array of forum ids which should not be searched - * @param string $post_visibility specifies which types of posts the user can view in which forums - * @param int $topic_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched - * @param array $author_ary an array of author ids - * @param string $author_name specifies the author match, when ANONYMOUS is also a search-match - * @param array &$id_ary passed by reference, to be filled with ids for the page specified by $start and $per_page, should be ordered - * @param int $start indicates the first index of the page - * @param int $per_page number of ids each page is supposed to contain - * @return boolean|int total number of results - */ - public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page) - { - // No author? No posts - if (!count($author_ary)) - { - return 0; - } - - // generate a search_key from all the options to identify the results - $search_key_array = array( - '', - $type, - ($firstpost_only) ? 'firstpost' : '', - '', - '', - $sort_days, - $sort_key, - $topic_id, - implode(',', $ex_fid_ary), - $post_visibility, - implode(',', $author_ary), - $author_name, - ); - - /** - * Allow changing the search_key for cached results - * - * @event core.search_postgres_by_author_modify_search_key - * @var array search_key_array Array with search parameters to generate the search_key - * @var string type Searching type ('posts', 'topics') - * @var boolean firstpost_only Flag indicating if only topic starting posts are considered - * @var int sort_days Time, in days, of the oldest possible post to list - * @var string sort_key The sort type used from the possible sort types - * @var int topic_id Limit the search to this topic_id only - * @var array ex_fid_ary Which forums not to search on - * @var string post_visibility Post visibility data - * @var array author_ary Array of user_id containing the users to filter the results to - * @var string author_name The username to search on - * @since 3.1.7-RC1 - */ - $vars = array( - 'search_key_array', - 'type', - 'firstpost_only', - 'sort_days', - 'sort_key', - 'topic_id', - 'ex_fid_ary', - 'post_visibility', - 'author_ary', - 'author_name', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_postgres_by_author_modify_search_key', compact($vars))); - - $search_key = md5(implode('#', $search_key_array)); - - if ($start < 0) - { - $start = 0; - } - - // try reading the results from cache - $result_count = 0; - if ($this->obtain_ids($search_key, $result_count, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE) - { - return $result_count; - } - - $id_ary = array(); - - // Create some display specific sql strings - if ($author_name) - { - // first one matches post of registered users, second one guests and deleted users - $sql_author = '(' . $this->db->sql_in_set('p.poster_id', array_diff($author_ary, array(ANONYMOUS)), false, true) . ' OR p.post_username ' . $author_name . ')'; - } - else - { - $sql_author = $this->db->sql_in_set('p.poster_id', $author_ary); - } - $sql_fora = (count($ex_fid_ary)) ? ' AND ' . $this->db->sql_in_set('p.forum_id', $ex_fid_ary, true) : ''; - $sql_topic_id = ($topic_id) ? ' AND p.topic_id = ' . (int) $topic_id : ''; - $sql_time = ($sort_days) ? ' AND p.post_time >= ' . (time() - ($sort_days * 86400)) : ''; - $sql_firstpost = ($firstpost_only) ? ' AND p.post_id = t.topic_first_post_id' : ''; - - // Build sql strings for sorting - $sql_sort = $sort_by_sql[$sort_key] . (($sort_dir == 'a') ? ' ASC' : ' DESC'); - $sql_sort_table = $sql_sort_join = ''; - switch ($sql_sort[0]) - { - case 'u': - $sql_sort_table = USERS_TABLE . ' u, '; - $sql_sort_join = ($type == 'posts') ? ' AND u.user_id = p.poster_id ' : ' AND u.user_id = t.topic_poster '; - break; - - case 't': - $sql_sort_table = ($type == 'posts' && !$firstpost_only) ? TOPICS_TABLE . ' t, ' : ''; - $sql_sort_join = ($type == 'posts' && !$firstpost_only) ? ' AND t.topic_id = p.topic_id ' : ''; - break; - - case 'f': - $sql_sort_table = FORUMS_TABLE . ' f, '; - $sql_sort_join = ' AND f.forum_id = p.forum_id '; - break; - } - - $m_approve_fid_sql = ' AND ' . $post_visibility; - - /** - * Allow changing the query used to search for posts by author in fulltext_postgres - * - * @event core.search_postgres_author_count_query_before - * @var int result_count The previous result count for the format of the query. - * Set to 0 to force a re-count - * @var string sql_sort_table CROSS JOIN'ed table to allow doing the sort chosen - * @var string sql_sort_join Condition to define how to join the CROSS JOIN'ed table specifyed in sql_sort_table - * @var array author_ary Array of user_id containing the users to filter the results to - * @var string author_name An extra username to search on - * @var string sql_author SQL WHERE condition for the post author ids - * @var int topic_id Limit the search to this topic_id only - * @var string sql_topic_id SQL of topic_id - * @var string sort_by_sql The possible predefined sort types - * @var string sort_key The sort type used from the possible sort types - * @var string sort_dir "a" for ASC or "d" dor DESC for the sort order used - * @var string sql_sort The result SQL when processing sort_by_sql + sort_key + sort_dir - * @var string sort_days Time, in days, that the oldest post showing can have - * @var string sql_time The SQL to search on the time specifyed by sort_days - * @var bool firstpost_only Wether or not to search only on the first post of the topics - * @var array ex_fid_ary Forum ids that must not be searched on - * @var array sql_fora SQL query for ex_fid_ary - * @var string m_approve_fid_sql WHERE clause condition on post_visibility restrictions - * @var int start How many posts to skip in the search results (used for pagination) - * @since 3.1.5-RC1 - */ - $vars = array( - 'result_count', - 'sql_sort_table', - 'sql_sort_join', - 'author_ary', - 'author_name', - 'sql_author', - 'topic_id', - 'sql_topic_id', - 'sort_by_sql', - 'sort_key', - 'sort_dir', - 'sql_sort', - 'sort_days', - 'sql_time', - 'firstpost_only', - 'ex_fid_ary', - 'sql_fora', - 'm_approve_fid_sql', - 'start', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_postgres_author_count_query_before', compact($vars))); - - // Build the query for really selecting the post_ids - if ($type == 'posts') - { - $sql = "SELECT p.post_id - FROM " . $sql_sort_table . POSTS_TABLE . ' p' . (($firstpost_only) ? ', ' . TOPICS_TABLE . ' t ' : ' ') . " - WHERE $sql_author - $sql_topic_id - $sql_firstpost - $m_approve_fid_sql - $sql_fora - $sql_sort_join - $sql_time - ORDER BY $sql_sort"; - $field = 'post_id'; - } - else - { - $sql = "SELECT t.topic_id - FROM " . $sql_sort_table . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p - WHERE $sql_author - $sql_topic_id - $sql_firstpost - $m_approve_fid_sql - $sql_fora - AND t.topic_id = p.topic_id - $sql_sort_join - $sql_time - GROUP BY t.topic_id, $sort_by_sql[$sort_key] - ORDER BY $sql_sort"; - $field = 'topic_id'; - } - - $this->db->sql_transaction('begin'); - - // Only read one block of posts from the db and then cache it - $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); - - while ($row = $this->db->sql_fetchrow($result)) - { - $id_ary[] = $row[$field]; - } - $this->db->sql_freeresult($result); - - // retrieve the total result count if needed - if (!$result_count) - { - if ($type == 'posts') - { - $sql_count = "SELECT COUNT(*) as result_count - FROM " . $sql_sort_table . POSTS_TABLE . ' p' . (($firstpost_only) ? ', ' . TOPICS_TABLE . ' t ' : ' ') . " - WHERE $sql_author - $sql_topic_id - $sql_firstpost - $m_approve_fid_sql - $sql_fora - $sql_sort_join - $sql_time"; - } - else - { - $sql_count = "SELECT COUNT(*) as result_count - FROM " . $sql_sort_table . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p - WHERE $sql_author - $sql_topic_id - $sql_firstpost - $m_approve_fid_sql - $sql_fora - AND t.topic_id = p.topic_id - $sql_sort_join - $sql_time - GROUP BY t.topic_id, $sort_by_sql[$sort_key]"; - } - - $this->db->sql_query($sql_count); - $result_count = (int) $this->db->sql_fetchfield('result_count'); - - if (!$result_count) - { - return false; - } - } - - $this->db->sql_transaction('commit'); - - if ($start >= $result_count) - { - $start = floor(($result_count - 1) / $per_page) * $per_page; - - $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); - while ($row = $this->db->sql_fetchrow($result)) - { - $id_ary[] = (int) $row[$field]; - } - $this->db->sql_freeresult($result); - - $id_ary = array_unique($id_ary); - } - - if (count($id_ary)) - { - $this->save_ids($search_key, '', $author_ary, $result_count, $id_ary, $start, $sort_dir); - $id_ary = array_slice($id_ary, 0, $per_page); - - return $result_count; - } - return false; - } - - /** - * Destroys cached search results, that contained one of the new words in a post so the results won't be outdated - * - * @param string $mode contains the post mode: edit, post, reply, quote ... - * @param int $post_id contains the post id of the post to index - * @param string $message contains the post text of the post - * @param string $subject contains the subject of the post to index - * @param int $poster_id contains the user id of the poster - * @param int $forum_id contains the forum id of parent forum of the post - */ - public function index($mode, $post_id, &$message, &$subject, $poster_id, $forum_id) - { - // Split old and new post/subject to obtain array of words - $split_text = $this->split_message($message); - $split_title = ($subject) ? $this->split_message($subject) : array(); - - $words = array_unique(array_merge($split_text, $split_title)); - - /** - * Event to modify method arguments and words before the PostgreSQL search index is updated - * - * @event core.search_postgres_index_before - * @var string mode Contains the post mode: edit, post, reply, quote - * @var int post_id The id of the post which is modified/created - * @var string message New or updated post content - * @var string subject New or updated post subject - * @var int poster_id Post author's user id - * @var int forum_id The id of the forum in which the post is located - * @var array words Array of words added to the index - * @var array split_text Array of words from the message - * @var array split_title Array of words from the title - * @since 3.2.3-RC1 - */ - $vars = array( - 'mode', - 'post_id', - 'message', - 'subject', - 'poster_id', - 'forum_id', - 'words', - 'split_text', - 'split_title', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_postgres_index_before', compact($vars))); - - unset($split_text); - unset($split_title); - - // destroy cached search results containing any of the words removed or added - $this->destroy_cache($words, array($poster_id)); - - unset($words); - } - - /** - * Destroy cached results, that might be outdated after deleting a post - */ - public function index_remove($post_ids, $author_ids, $forum_ids) - { - $this->destroy_cache(array(), $author_ids); - } - - /** - * Destroy old cache entries - */ - public function tidy() - { - // destroy too old cached search results - $this->destroy_cache(array()); - - $this->config->set('search_last_gc', time(), false); - } - - /** - * Create fulltext index - * - * @return string|bool error string is returned incase of errors otherwise false - */ - public function create_index($acp_module, $u_action) - { - // Make sure we can actually use PostgreSQL with fulltext indexes - if ($error = $this->init()) - { - return $error; - } - - if (empty($this->stats)) - { - $this->get_stats(); - } - - $sql_queries = []; - - if (!isset($this->stats['post_subject'])) - { - $sql_queries[] = "CREATE INDEX " . POSTS_TABLE . "_" . $this->config['fulltext_postgres_ts_name'] . "_post_subject ON " . POSTS_TABLE . " USING gin (to_tsvector ('" . $this->db->sql_escape($this->config['fulltext_postgres_ts_name']) . "', post_subject))"; - } - - if (!isset($this->stats['post_content'])) - { - $sql_queries[] = "CREATE INDEX " . POSTS_TABLE . "_" . $this->config['fulltext_postgres_ts_name'] . "_post_content ON " . POSTS_TABLE . " USING gin (to_tsvector ('" . $this->db->sql_escape($this->config['fulltext_postgres_ts_name']) . "', post_text || ' ' || post_subject))"; - } - - $stats = $this->stats; - - /** - * Event to modify SQL queries before the Postgres search index is created - * - * @event core.search_postgres_create_index_before - * @var array sql_queries Array with queries for creating the search index - * @var array stats Array with statistics of the current index (read only) - * @since 3.2.3-RC1 - */ - $vars = array( - 'sql_queries', - 'stats', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_postgres_create_index_before', compact($vars))); - - foreach ($sql_queries as $sql_query) - { - $this->db->sql_query($sql_query); - } - - $this->db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE); - - return false; - } - - /** - * Drop fulltext index - * - * @return string|bool error string is returned incase of errors otherwise false - */ - public function delete_index($acp_module, $u_action) - { - // Make sure we can actually use PostgreSQL with fulltext indexes - if ($error = $this->init()) - { - return $error; - } - - if (empty($this->stats)) - { - $this->get_stats(); - } - - $sql_queries = []; - - if (isset($this->stats['post_subject'])) - { - $sql_queries[] = 'DROP INDEX ' . $this->stats['post_subject']['relname']; - } - - if (isset($this->stats['post_content'])) - { - $sql_queries[] = 'DROP INDEX ' . $this->stats['post_content']['relname']; - } - - $stats = $this->stats; - - /** - * Event to modify SQL queries before the Postgres search index is created - * - * @event core.search_postgres_delete_index_before - * @var array sql_queries Array with queries for deleting the search index - * @var array stats Array with statistics of the current index (read only) - * @since 3.2.3-RC1 - */ - $vars = array( - 'sql_queries', - 'stats', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_postgres_delete_index_before', compact($vars))); - - foreach ($sql_queries as $sql_query) - { - $this->db->sql_query($sql_query); - } - - $this->db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE); - - return false; - } - - /** - * Returns true if both FULLTEXT indexes exist - */ - public function index_created() - { - if (empty($this->stats)) - { - $this->get_stats(); - } - - return (isset($this->stats['post_subject']) && isset($this->stats['post_content'])) ? true : false; - } - - /** - * Returns an associative array containing information about the indexes - */ - public function index_stats() - { - if (empty($this->stats)) - { - $this->get_stats(); - } - - return array( - $this->user->lang['FULLTEXT_POSTGRES_TOTAL_POSTS'] => ($this->index_created()) ? $this->stats['total_posts'] : 0, - ); - } - - /** - * Computes the stats and store them in the $this->stats associative array - */ - protected function get_stats() - { - if ($this->db->get_sql_layer() != 'postgres') - { - $this->stats = array(); - return; - } - - $sql = "SELECT c2.relname, pg_catalog.pg_get_indexdef(i.indexrelid, 0, true) AS indexdef - FROM pg_catalog.pg_class c1, pg_catalog.pg_index i, pg_catalog.pg_class c2 - WHERE c1.relname = '" . POSTS_TABLE . "' - AND pg_catalog.pg_table_is_visible(c1.oid) - AND c1.oid = i.indrelid - AND i.indexrelid = c2.oid"; - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - // deal with older PostgreSQL versions which didn't use Index_type - if (strpos($row['indexdef'], 'to_tsvector') !== false) - { - if ($row['relname'] == POSTS_TABLE . '_' . $this->config['fulltext_postgres_ts_name'] . '_post_subject' || $row['relname'] == POSTS_TABLE . '_post_subject') - { - $this->stats['post_subject'] = $row; - } - else if ($row['relname'] == POSTS_TABLE . '_' . $this->config['fulltext_postgres_ts_name'] . '_post_content' || $row['relname'] == POSTS_TABLE . '_post_content') - { - $this->stats['post_content'] = $row; - } - } - } - $this->db->sql_freeresult($result); - - $this->stats['total_posts'] = $this->config['num_posts']; - } - - /** - * Display various options that can be configured for the backend from the acp - * - * @return associative array containing template and config variables - */ - public function acp() - { - $tpl = ' -
-

' . $this->user->lang['FULLTEXT_POSTGRES_VERSION_CHECK_EXPLAIN'] . '
-
' . (($this->db->get_sql_layer() == 'postgres') ? $this->user->lang['YES'] : $this->user->lang['NO']) . '
-
-
-

' . $this->user->lang['FULLTEXT_POSTGRES_TS_NAME_EXPLAIN'] . '
-
-
-
-

' . $this->user->lang['FULLTEXT_POSTGRES_MIN_WORD_LEN_EXPLAIN'] . '
-
-
-
-

' . $this->user->lang['FULLTEXT_POSTGRES_MAX_WORD_LEN_EXPLAIN'] . '
-
-
- '; - - // These are fields required in the config table - return array( - 'tpl' => $tpl, - 'config' => array('fulltext_postgres_ts_name' => 'string', 'fulltext_postgres_min_word_len' => 'integer:0:255', 'fulltext_postgres_max_word_len' => 'integer:0:255') - ); - } -} diff --git a/install/update/old/phpbb/search/fulltext_sphinx.php b/install/update/old/phpbb/search/fulltext_sphinx.php deleted file mode 100644 index 2c2eb84..0000000 --- a/install/update/old/phpbb/search/fulltext_sphinx.php +++ /dev/null @@ -1,992 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\search; - -define('SPHINX_MAX_MATCHES', 20000); -define('SPHINX_CONNECT_RETRIES', 3); -define('SPHINX_CONNECT_WAIT_TIME', 300); - -/** -* Fulltext search based on the sphinx search deamon -*/ -class fulltext_sphinx -{ - /** - * Associative array holding index stats - * @var array - */ - protected $stats = array(); - - /** - * Holds the words entered by user, obtained by splitting the entered query on whitespace - * @var array - */ - protected $split_words = array(); - - /** - * Holds unique sphinx id - * @var string - */ - protected $id; - - /** - * Stores the names of both main and delta sphinx indexes - * separated by a semicolon - * @var string - */ - protected $indexes; - - /** - * Sphinx searchd client object - * @var SphinxClient - */ - protected $sphinx; - - /** - * Relative path to board root - * @var string - */ - protected $phpbb_root_path; - - /** - * PHP Extension - * @var string - */ - protected $php_ext; - - /** - * Auth object - * @var \phpbb\auth\auth - */ - protected $auth; - - /** - * Config object - * @var \phpbb\config\config - */ - protected $config; - - /** - * Database connection - * @var \phpbb\db\driver\driver_interface - */ - protected $db; - - /** - * Database Tools object - * @var \phpbb\db\tools\tools_interface - */ - protected $db_tools; - - /** - * Stores the database type if supported by sphinx - * @var string - */ - protected $dbtype; - - /** - * phpBB event dispatcher object - * @var \phpbb\event\dispatcher_interface - */ - protected $phpbb_dispatcher; - - /** - * User object - * @var \phpbb\user - */ - protected $user; - - /** - * Stores the generated content of the sphinx config file - * @var string - */ - protected $config_file_data = ''; - - /** - * Contains tidied search query. - * Operators are prefixed in search query and common words excluded - * @var string - */ - protected $search_query; - - /** - * Constructor - * Creates a new \phpbb\search\fulltext_postgres, which is used as a search backend - * - * @param string|bool $error Any error that occurs is passed on through this reference variable otherwise false - * @param string $phpbb_root_path Relative path to phpBB root - * @param string $phpEx PHP file extension - * @param \phpbb\auth\auth $auth Auth object - * @param \phpbb\config\config $config Config object - * @param \phpbb\db\driver\driver_interface Database object - * @param \phpbb\user $user User object - * @param \phpbb\event\dispatcher_interface $phpbb_dispatcher Event dispatcher object - */ - public function __construct(&$error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher) - { - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $phpEx; - $this->config = $config; - $this->phpbb_dispatcher = $phpbb_dispatcher; - $this->user = $user; - $this->db = $db; - $this->auth = $auth; - - // Initialize \phpbb\db\tools\tools object - global $phpbb_container; // TODO inject into object - $this->db_tools = $phpbb_container->get('dbal.tools'); - - if (!$this->config['fulltext_sphinx_id']) - { - $this->config->set('fulltext_sphinx_id', unique_id()); - } - $this->id = $this->config['fulltext_sphinx_id']; - $this->indexes = 'index_phpbb_' . $this->id . '_delta;index_phpbb_' . $this->id . '_main'; - - if (!class_exists('SphinxClient')) - { - require($this->phpbb_root_path . 'includes/sphinxapi.' . $this->php_ext); - } - - // Initialize sphinx client - $this->sphinx = new \SphinxClient(); - - $this->sphinx->SetServer(($this->config['fulltext_sphinx_host'] ? $this->config['fulltext_sphinx_host'] : 'localhost'), ($this->config['fulltext_sphinx_port'] ? (int) $this->config['fulltext_sphinx_port'] : 9312)); - - $error = false; - } - - /** - * Returns the name of this search backend to be displayed to administrators - * - * @return string Name - */ - public function get_name() - { - return 'Sphinx Fulltext'; - } - - /** - * Returns the search_query - * - * @return string search query - */ - public function get_search_query() - { - return $this->search_query; - } - - /** - * Returns false as there is no word_len array - * - * @return false - */ - public function get_word_length() - { - return false; - } - - /** - * Returns an empty array as there are no common_words - * - * @return array common words that are ignored by search backend - */ - public function get_common_words() - { - return array(); - } - - /** - * Checks permissions and paths, if everything is correct it generates the config file - * - * @return string|bool Language key of the error/incompatiblity encountered, or false if successful - */ - public function init() - { - if ($this->db->get_sql_layer() != 'mysql' && $this->db->get_sql_layer() != 'mysql4' && $this->db->get_sql_layer() != 'mysqli' && $this->db->get_sql_layer() != 'postgres') - { - return $this->user->lang['FULLTEXT_SPHINX_WRONG_DATABASE']; - } - - // Move delta to main index each hour - $this->config->set('search_gc', 3600); - - return false; - } - - /** - * Generates content of sphinx.conf - * - * @return bool True if sphinx.conf content is correctly generated, false otherwise - */ - protected function config_generate() - { - // Check if Database is supported by Sphinx - if ($this->db->get_sql_layer() =='mysql' || $this->db->get_sql_layer() == 'mysql4' || $this->db->get_sql_layer() == 'mysqli') - { - $this->dbtype = 'mysql'; - } - else if ($this->db->get_sql_layer() == 'postgres') - { - $this->dbtype = 'pgsql'; - } - else - { - $this->config_file_data = $this->user->lang('FULLTEXT_SPHINX_WRONG_DATABASE'); - return false; - } - - // Check if directory paths have been filled - if (!$this->config['fulltext_sphinx_data_path']) - { - $this->config_file_data = $this->user->lang('FULLTEXT_SPHINX_NO_CONFIG_DATA'); - return false; - } - - include($this->phpbb_root_path . 'config.' . $this->php_ext); - - /* Now that we're sure everything was entered correctly, - generate a config for the index. We use a config value - fulltext_sphinx_id for this, as it should be unique. */ - $config_object = new \phpbb\search\sphinx\config($this->config_file_data); - $config_data = array( - 'source source_phpbb_' . $this->id . '_main' => array( - array('type', $this->dbtype . ' # mysql or pgsql'), - // This config value sql_host needs to be changed incase sphinx and sql are on different servers - array('sql_host', $dbhost . ' # SQL server host sphinx connects to'), - array('sql_user', '[dbuser]'), - array('sql_pass', '[dbpassword]'), - array('sql_db', $dbname), - array('sql_port', $dbport . ' # optional, default is 3306 for mysql and 5432 for pgsql'), - array('sql_query_pre', 'SET NAMES \'utf8\''), - array('sql_query_pre', 'UPDATE ' . SPHINX_TABLE . ' SET max_doc_id = (SELECT MAX(post_id) FROM ' . POSTS_TABLE . ') WHERE counter_id = 1'), - array('sql_query_range', 'SELECT MIN(post_id), MAX(post_id) FROM ' . POSTS_TABLE . ''), - array('sql_range_step', '5000'), - array('sql_query', 'SELECT - p.post_id AS id, - p.forum_id, - p.topic_id, - p.poster_id, - p.post_visibility, - CASE WHEN p.post_id = t.topic_first_post_id THEN 1 ELSE 0 END as topic_first_post, - p.post_time, - p.post_subject, - p.post_subject as title, - p.post_text as data, - t.topic_last_post_time, - 0 as deleted - FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t - WHERE - p.topic_id = t.topic_id - AND p.post_id >= $start AND p.post_id <= $end'), - array('sql_query_post', ''), - array('sql_query_post_index', 'UPDATE ' . SPHINX_TABLE . ' SET max_doc_id = $maxid WHERE counter_id = 1'), - array('sql_attr_uint', 'forum_id'), - array('sql_attr_uint', 'topic_id'), - array('sql_attr_uint', 'poster_id'), - array('sql_attr_uint', 'post_visibility'), - array('sql_attr_bool', 'topic_first_post'), - array('sql_attr_bool', 'deleted'), - array('sql_attr_timestamp', 'post_time'), - array('sql_attr_timestamp', 'topic_last_post_time'), - array('sql_attr_string', 'post_subject'), - ), - 'source source_phpbb_' . $this->id . '_delta : source_phpbb_' . $this->id . '_main' => array( - array('sql_query_pre', 'SET NAMES \'utf8\''), - array('sql_query_range', ''), - array('sql_range_step', ''), - array('sql_query', 'SELECT - p.post_id AS id, - p.forum_id, - p.topic_id, - p.poster_id, - p.post_visibility, - CASE WHEN p.post_id = t.topic_first_post_id THEN 1 ELSE 0 END as topic_first_post, - p.post_time, - p.post_subject, - p.post_subject as title, - p.post_text as data, - t.topic_last_post_time, - 0 as deleted - FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t - WHERE - p.topic_id = t.topic_id - AND p.post_id >= ( SELECT max_doc_id FROM ' . SPHINX_TABLE . ' WHERE counter_id=1 )'), - array('sql_query_post_index', ''), - ), - 'index index_phpbb_' . $this->id . '_main' => array( - array('path', $this->config['fulltext_sphinx_data_path'] . 'index_phpbb_' . $this->id . '_main'), - array('source', 'source_phpbb_' . $this->id . '_main'), - array('docinfo', 'extern'), - array('morphology', 'none'), - array('stopwords', ''), - array('min_word_len', '2'), - array('charset_table', 'U+FF10..U+FF19->0..9, 0..9, U+FF41..U+FF5A->a..z, U+FF21..U+FF3A->a..z, A..Z->a..z, a..z, U+0149, U+017F, U+0138, U+00DF, U+00FF, U+00C0..U+00D6->U+00E0..U+00F6, U+00E0..U+00F6, U+00D8..U+00DE->U+00F8..U+00FE, U+00F8..U+00FE, U+0100->U+0101, U+0101, U+0102->U+0103, U+0103, U+0104->U+0105, U+0105, U+0106->U+0107, U+0107, U+0108->U+0109, U+0109, U+010A->U+010B, U+010B, U+010C->U+010D, U+010D, U+010E->U+010F, U+010F, U+0110->U+0111, U+0111, U+0112->U+0113, U+0113, U+0114->U+0115, U+0115, U+0116->U+0117, U+0117, U+0118->U+0119, U+0119, U+011A->U+011B, U+011B, U+011C->U+011D, U+011D, U+011E->U+011F, U+011F, U+0130->U+0131, U+0131, U+0132->U+0133, U+0133, U+0134->U+0135, U+0135, U+0136->U+0137, U+0137, U+0139->U+013A, U+013A, U+013B->U+013C, U+013C, U+013D->U+013E, U+013E, U+013F->U+0140, U+0140, U+0141->U+0142, U+0142, U+0143->U+0144, U+0144, U+0145->U+0146, U+0146, U+0147->U+0148, U+0148, U+014A->U+014B, U+014B, U+014C->U+014D, U+014D, U+014E->U+014F, U+014F, U+0150->U+0151, U+0151, U+0152->U+0153, U+0153, U+0154->U+0155, U+0155, U+0156->U+0157, U+0157, U+0158->U+0159, U+0159, U+015A->U+015B, U+015B, U+015C->U+015D, U+015D, U+015E->U+015F, U+015F, U+0160->U+0161, U+0161, U+0162->U+0163, U+0163, U+0164->U+0165, U+0165, U+0166->U+0167, U+0167, U+0168->U+0169, U+0169, U+016A->U+016B, U+016B, U+016C->U+016D, U+016D, U+016E->U+016F, U+016F, U+0170->U+0171, U+0171, U+0172->U+0173, U+0173, U+0174->U+0175, U+0175, U+0176->U+0177, U+0177, U+0178->U+00FF, U+00FF, U+0179->U+017A, U+017A, U+017B->U+017C, U+017C, U+017D->U+017E, U+017E, U+0410..U+042F->U+0430..U+044F, U+0430..U+044F, U+4E00..U+9FFF'), - array('min_prefix_len', '0'), - array('min_infix_len', '0'), - ), - 'index index_phpbb_' . $this->id . '_delta : index_phpbb_' . $this->id . '_main' => array( - array('path', $this->config['fulltext_sphinx_data_path'] . 'index_phpbb_' . $this->id . '_delta'), - array('source', 'source_phpbb_' . $this->id . '_delta'), - ), - 'indexer' => array( - array('mem_limit', $this->config['fulltext_sphinx_indexer_mem_limit'] . 'M'), - ), - 'searchd' => array( - array('listen' , ($this->config['fulltext_sphinx_host'] ? $this->config['fulltext_sphinx_host'] : 'localhost') . ':' . ($this->config['fulltext_sphinx_port'] ? $this->config['fulltext_sphinx_port'] : '9312')), - array('log', $this->config['fulltext_sphinx_data_path'] . 'log/searchd.log'), - array('query_log', $this->config['fulltext_sphinx_data_path'] . 'log/sphinx-query.log'), - array('read_timeout', '5'), - array('max_children', '30'), - array('pid_file', $this->config['fulltext_sphinx_data_path'] . 'searchd.pid'), - array('binlog_path', $this->config['fulltext_sphinx_data_path']), - ), - ); - - $non_unique = array('sql_query_pre' => true, 'sql_attr_uint' => true, 'sql_attr_timestamp' => true, 'sql_attr_str2ordinal' => true, 'sql_attr_bool' => true); - $delete = array('sql_group_column' => true, 'sql_date_column' => true, 'sql_str2ordinal_column' => true); - - /** - * Allow adding/changing the Sphinx configuration data - * - * @event core.search_sphinx_modify_config_data - * @var array config_data Array with the Sphinx configuration data - * @var array non_unique Array with the Sphinx non-unique variables to delete - * @var array delete Array with the Sphinx variables to delete - * @since 3.1.7-RC1 - */ - $vars = array( - 'config_data', - 'non_unique', - 'delete', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_sphinx_modify_config_data', compact($vars))); - - foreach ($config_data as $section_name => $section_data) - { - $section = $config_object->get_section_by_name($section_name); - if (!$section) - { - $section = $config_object->add_section($section_name); - } - - foreach ($delete as $key => $void) - { - $section->delete_variables_by_name($key); - } - - foreach ($non_unique as $key => $void) - { - $section->delete_variables_by_name($key); - } - - foreach ($section_data as $entry) - { - $key = $entry[0]; - $value = $entry[1]; - - if (!isset($non_unique[$key])) - { - $variable = $section->get_variable_by_name($key); - if (!$variable) - { - $section->create_variable($key, $value); - } - else - { - $variable->set_value($value); - } - } - else - { - $section->create_variable($key, $value); - } - } - } - $this->config_file_data = $config_object->get_data(); - - return true; - } - - /** - * Splits keywords entered by a user into an array of words stored in $this->split_words - * Stores the tidied search query in $this->search_query - * - * @param string $keywords Contains the keyword as entered by the user - * @param string $terms is either 'all' or 'any' - * @return false if no valid keywords were found and otherwise true - */ - public function split_keywords(&$keywords, $terms) - { - if ($terms == 'all') - { - $match = array('#\sand\s#i', '#\sor\s#i', '#\snot\s#i', '#\+#', '#-#', '#\|#', '#@#'); - $replace = array(' & ', ' | ', ' - ', ' +', ' -', ' |', ''); - - $keywords = preg_replace($match, $replace, $keywords); - $this->sphinx->SetMatchMode(SPH_MATCH_EXTENDED); - } - else - { - $this->sphinx->SetMatchMode(SPH_MATCH_ANY); - } - - // Keep quotes and new lines - $keywords = str_replace(array('"', "\n"), array('"', ' '), trim($keywords)); - - if (strlen($keywords) > 0) - { - $this->search_query = str_replace('"', '"', $keywords); - return true; - } - - return false; - } - - /** - * Performs a search on keywords depending on display specific params. You have to run split_keywords() first - * - * @param string $type contains either posts or topics depending on what should be searched for - * @param string $fields contains either titleonly (topic titles should be searched), msgonly (only message bodies should be searched), firstpost (only subject and body of the first post should be searched) or all (all post bodies and subjects should be searched) - * @param string $terms is either 'all' (use query as entered, words without prefix should default to "have to be in field") or 'any' (ignore search query parts and just return all posts that contain any of the specified words) - * @param array $sort_by_sql contains SQL code for the ORDER BY part of a query - * @param string $sort_key is the key of $sort_by_sql for the selected sorting - * @param string $sort_dir is either a or d representing ASC and DESC - * @param string $sort_days specifies the maximum amount of days a post may be old - * @param array $ex_fid_ary specifies an array of forum ids which should not be searched - * @param string $post_visibility specifies which types of posts the user can view in which forums - * @param int $topic_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched - * @param array $author_ary an array of author ids if the author should be ignored during the search the array is empty - * @param string $author_name specifies the author match, when ANONYMOUS is also a search-match - * @param array &$id_ary passed by reference, to be filled with ids for the page specified by $start and $per_page, should be ordered - * @param int $start indicates the first index of the page - * @param int $per_page number of ids each page is supposed to contain - * @return boolean|int total number of results - */ - public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page) - { - global $user, $phpbb_log; - - // No keywords? No posts. - if (!strlen($this->search_query) && !count($author_ary)) - { - return false; - } - - $id_ary = array(); - - // Sorting - - if ($type == 'topics') - { - switch ($sort_key) - { - case 'a': - $this->sphinx->SetGroupBy('topic_id', SPH_GROUPBY_ATTR, 'poster_id ' . (($sort_dir == 'a') ? 'ASC' : 'DESC')); - break; - - case 'f': - $this->sphinx->SetGroupBy('topic_id', SPH_GROUPBY_ATTR, 'forum_id ' . (($sort_dir == 'a') ? 'ASC' : 'DESC')); - break; - - case 'i': - - case 's': - $this->sphinx->SetGroupBy('topic_id', SPH_GROUPBY_ATTR, 'post_subject ' . (($sort_dir == 'a') ? 'ASC' : 'DESC')); - break; - - case 't': - - default: - $this->sphinx->SetGroupBy('topic_id', SPH_GROUPBY_ATTR, 'topic_last_post_time ' . (($sort_dir == 'a') ? 'ASC' : 'DESC')); - break; - } - } - else - { - switch ($sort_key) - { - case 'a': - $this->sphinx->SetSortMode(($sort_dir == 'a') ? SPH_SORT_ATTR_ASC : SPH_SORT_ATTR_DESC, 'poster_id'); - break; - - case 'f': - $this->sphinx->SetSortMode(($sort_dir == 'a') ? SPH_SORT_ATTR_ASC : SPH_SORT_ATTR_DESC, 'forum_id'); - break; - - case 'i': - - case 's': - $this->sphinx->SetSortMode(($sort_dir == 'a') ? SPH_SORT_ATTR_ASC : SPH_SORT_ATTR_DESC, 'post_subject'); - break; - - case 't': - - default: - $this->sphinx->SetSortMode(($sort_dir == 'a') ? SPH_SORT_ATTR_ASC : SPH_SORT_ATTR_DESC, 'post_time'); - break; - } - } - - // Most narrow filters first - if ($topic_id) - { - $this->sphinx->SetFilter('topic_id', array($topic_id)); - } - - /** - * Allow modifying the Sphinx search options - * - * @event core.search_sphinx_keywords_modify_options - * @var string type Searching type ('posts', 'topics') - * @var string fields Searching fields ('titleonly', 'msgonly', 'firstpost', 'all') - * @var string terms Searching terms ('all', 'any') - * @var int sort_days Time, in days, of the oldest possible post to list - * @var string sort_key The sort type used from the possible sort types - * @var int topic_id Limit the search to this topic_id only - * @var array ex_fid_ary Which forums not to search on - * @var string post_visibility Post visibility data - * @var array author_ary Array of user_id containing the users to filter the results to - * @var string author_name The username to search on - * @var object sphinx The Sphinx searchd client object - * @since 3.1.7-RC1 - */ - $sphinx = $this->sphinx; - $vars = array( - 'type', - 'fields', - 'terms', - 'sort_days', - 'sort_key', - 'topic_id', - 'ex_fid_ary', - 'post_visibility', - 'author_ary', - 'author_name', - 'sphinx', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_sphinx_keywords_modify_options', compact($vars))); - $this->sphinx = $sphinx; - unset($sphinx); - - $search_query_prefix = ''; - - switch ($fields) - { - case 'titleonly': - // Only search the title - if ($terms == 'all') - { - $search_query_prefix = '@title '; - } - // Weight for the title - $this->sphinx->SetFieldWeights(array("title" => 5, "data" => 1)); - // 1 is first_post, 0 is not first post - $this->sphinx->SetFilter('topic_first_post', array(1)); - break; - - case 'msgonly': - // Only search the body - if ($terms == 'all') - { - $search_query_prefix = '@data '; - } - // Weight for the body - $this->sphinx->SetFieldWeights(array("title" => 1, "data" => 5)); - break; - - case 'firstpost': - // More relative weight for the title, also search the body - $this->sphinx->SetFieldWeights(array("title" => 5, "data" => 1)); - // 1 is first_post, 0 is not first post - $this->sphinx->SetFilter('topic_first_post', array(1)); - break; - - default: - // More relative weight for the title, also search the body - $this->sphinx->SetFieldWeights(array("title" => 5, "data" => 1)); - break; - } - - if (count($author_ary)) - { - $this->sphinx->SetFilter('poster_id', $author_ary); - } - - // As this is not simply possible at the moment, we limit the result to approved posts. - // This will make it impossible for moderators to search unapproved and softdeleted posts, - // but at least it will also cause the same for normal users. - $this->sphinx->SetFilter('post_visibility', array(ITEM_APPROVED)); - - if (count($ex_fid_ary)) - { - // All forums that a user is allowed to access - $fid_ary = array_unique(array_intersect(array_keys($this->auth->acl_getf('f_read', true)), array_keys($this->auth->acl_getf('f_search', true)))); - // All forums that the user wants to and can search in - $search_forums = array_diff($fid_ary, $ex_fid_ary); - - if (count($search_forums)) - { - $this->sphinx->SetFilter('forum_id', $search_forums); - } - } - - $this->sphinx->SetFilter('deleted', array(0)); - - $this->sphinx->SetLimits((int) $start, (int) $per_page, SPHINX_MAX_MATCHES); - $result = $this->sphinx->Query($search_query_prefix . $this->sphinx->EscapeString(str_replace('"', '"', $this->search_query)), $this->indexes); - - // Could be connection to localhost:9312 failed (errno=111, - // msg=Connection refused) during rotate, retry if so - $retries = SPHINX_CONNECT_RETRIES; - while (!$result && (strpos($this->sphinx->GetLastError(), "errno=111,") !== false) && $retries--) - { - usleep(SPHINX_CONNECT_WAIT_TIME); - $result = $this->sphinx->Query($search_query_prefix . $this->sphinx->EscapeString(str_replace('"', '"', $this->search_query)), $this->indexes); - } - - if ($this->sphinx->GetLastError()) - { - $phpbb_log->add('critical', $user->data['user_id'], $user->ip, 'LOG_SPHINX_ERROR', false, array($this->sphinx->GetLastError())); - if ($this->auth->acl_get('a_')) - { - trigger_error($this->user->lang('SPHINX_SEARCH_FAILED', $this->sphinx->GetLastError())); - } - else - { - trigger_error($this->user->lang('SPHINX_SEARCH_FAILED_LOG')); - } - } - - $result_count = $result['total_found']; - - if ($result_count && $start >= $result_count) - { - $start = floor(($result_count - 1) / $per_page) * $per_page; - - $this->sphinx->SetLimits((int) $start, (int) $per_page, SPHINX_MAX_MATCHES); - $result = $this->sphinx->Query($search_query_prefix . $this->sphinx->EscapeString(str_replace('"', '"', $this->search_query)), $this->indexes); - - // Could be connection to localhost:9312 failed (errno=111, - // msg=Connection refused) during rotate, retry if so - $retries = SPHINX_CONNECT_RETRIES; - while (!$result && (strpos($this->sphinx->GetLastError(), "errno=111,") !== false) && $retries--) - { - usleep(SPHINX_CONNECT_WAIT_TIME); - $result = $this->sphinx->Query($search_query_prefix . $this->sphinx->EscapeString(str_replace('"', '"', $this->search_query)), $this->indexes); - } - } - - $id_ary = array(); - if (isset($result['matches'])) - { - if ($type == 'posts') - { - $id_ary = array_keys($result['matches']); - } - else - { - foreach ($result['matches'] as $key => $value) - { - $id_ary[] = $value['attrs']['topic_id']; - } - } - } - else - { - return false; - } - - $id_ary = array_slice($id_ary, 0, (int) $per_page); - - return $result_count; - } - - /** - * Performs a search on an author's posts without caring about message contents. Depends on display specific params - * - * @param string $type contains either posts or topics depending on what should be searched for - * @param boolean $firstpost_only if true, only topic starting posts will be considered - * @param array $sort_by_sql contains SQL code for the ORDER BY part of a query - * @param string $sort_key is the key of $sort_by_sql for the selected sorting - * @param string $sort_dir is either a or d representing ASC and DESC - * @param string $sort_days specifies the maximum amount of days a post may be old - * @param array $ex_fid_ary specifies an array of forum ids which should not be searched - * @param string $post_visibility specifies which types of posts the user can view in which forums - * @param int $topic_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched - * @param array $author_ary an array of author ids - * @param string $author_name specifies the author match, when ANONYMOUS is also a search-match - * @param array &$id_ary passed by reference, to be filled with ids for the page specified by $start and $per_page, should be ordered - * @param int $start indicates the first index of the page - * @param int $per_page number of ids each page is supposed to contain - * @return boolean|int total number of results - */ - public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page) - { - $this->search_query = ''; - - $this->sphinx->SetMatchMode(SPH_MATCH_FULLSCAN); - $fields = ($firstpost_only) ? 'firstpost' : 'all'; - $terms = 'all'; - return $this->keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, $id_ary, $start, $per_page); - } - - /** - * Updates wordlist and wordmatch tables when a message is posted or changed - * - * @param string $mode Contains the post mode: edit, post, reply, quote - * @param int $post_id The id of the post which is modified/created - * @param string &$message New or updated post content - * @param string &$subject New or updated post subject - * @param int $poster_id Post author's user id - * @param int $forum_id The id of the forum in which the post is located - */ - public function index($mode, $post_id, &$message, &$subject, $poster_id, $forum_id) - { - /** - * Event to modify method arguments before the Sphinx search index is updated - * - * @event core.search_sphinx_index_before - * @var string mode Contains the post mode: edit, post, reply, quote - * @var int post_id The id of the post which is modified/created - * @var string message New or updated post content - * @var string subject New or updated post subject - * @var int poster_id Post author's user id - * @var int forum_id The id of the forum in which the post is located - * @since 3.2.3-RC1 - */ - $vars = array( - 'mode', - 'post_id', - 'message', - 'subject', - 'poster_id', - 'forum_id', - ); - extract($this->phpbb_dispatcher->trigger_event('core.search_sphinx_index_before', compact($vars))); - - if ($mode == 'edit') - { - $this->sphinx->UpdateAttributes($this->indexes, array('forum_id', 'poster_id'), array((int) $post_id => array((int) $forum_id, (int) $poster_id))); - } - else if ($mode != 'post' && $post_id) - { - // Update topic_last_post_time for full topic - $sql_array = array( - 'SELECT' => 'p1.post_id', - 'FROM' => array( - POSTS_TABLE => 'p1', - ), - 'LEFT_JOIN' => array(array( - 'FROM' => array( - POSTS_TABLE => 'p2' - ), - 'ON' => 'p1.topic_id = p2.topic_id', - )), - 'WHERE' => 'p2.post_id = ' . ((int) $post_id), - ); - - $sql = $this->db->sql_build_query('SELECT', $sql_array); - $result = $this->db->sql_query($sql); - - $post_updates = array(); - $post_time = time(); - while ($row = $this->db->sql_fetchrow($result)) - { - $post_updates[(int) $row['post_id']] = array($post_time); - } - $this->db->sql_freeresult($result); - - if (count($post_updates)) - { - $this->sphinx->UpdateAttributes($this->indexes, array('topic_last_post_time'), $post_updates); - } - } - } - - /** - * Delete a post from the index after it was deleted - */ - public function index_remove($post_ids, $author_ids, $forum_ids) - { - $values = array(); - foreach ($post_ids as $post_id) - { - $values[$post_id] = array(1); - } - - $this->sphinx->UpdateAttributes($this->indexes, array('deleted'), $values); - } - - /** - * Nothing needs to be destroyed - */ - public function tidy($create = false) - { - $this->config->set('search_last_gc', time(), false); - } - - /** - * Create sphinx table - * - * @return string|bool error string is returned incase of errors otherwise false - */ - public function create_index($acp_module, $u_action) - { - if (!$this->index_created()) - { - $table_data = array( - 'COLUMNS' => array( - 'counter_id' => array('UINT', 0), - 'max_doc_id' => array('UINT', 0), - ), - 'PRIMARY_KEY' => 'counter_id', - ); - $this->db_tools->sql_create_table(SPHINX_TABLE, $table_data); - - $sql = 'TRUNCATE TABLE ' . SPHINX_TABLE; - $this->db->sql_query($sql); - - $data = array( - 'counter_id' => '1', - 'max_doc_id' => '0', - ); - $sql = 'INSERT INTO ' . SPHINX_TABLE . ' ' . $this->db->sql_build_array('INSERT', $data); - $this->db->sql_query($sql); - } - - return false; - } - - /** - * Drop sphinx table - * - * @return string|bool error string is returned incase of errors otherwise false - */ - public function delete_index($acp_module, $u_action) - { - if (!$this->index_created()) - { - return false; - } - - $this->db_tools->sql_table_drop(SPHINX_TABLE); - - return false; - } - - /** - * Returns true if the sphinx table was created - * - * @return bool true if sphinx table was created - */ - public function index_created($allow_new_files = true) - { - $created = false; - - if ($this->db_tools->sql_table_exists(SPHINX_TABLE)) - { - $created = true; - } - - return $created; - } - - /** - * Returns an associative array containing information about the indexes - * - * @return string|bool Language string of error false otherwise - */ - public function index_stats() - { - if (empty($this->stats)) - { - $this->get_stats(); - } - - return array( - $this->user->lang['FULLTEXT_SPHINX_MAIN_POSTS'] => ($this->index_created()) ? $this->stats['main_posts'] : 0, - $this->user->lang['FULLTEXT_SPHINX_DELTA_POSTS'] => ($this->index_created()) ? $this->stats['total_posts'] - $this->stats['main_posts'] : 0, - $this->user->lang['FULLTEXT_MYSQL_TOTAL_POSTS'] => ($this->index_created()) ? $this->stats['total_posts'] : 0, - ); - } - - /** - * Collects stats that can be displayed on the index maintenance page - */ - protected function get_stats() - { - if ($this->index_created()) - { - $sql = 'SELECT COUNT(post_id) as total_posts - FROM ' . POSTS_TABLE; - $result = $this->db->sql_query($sql); - $this->stats['total_posts'] = (int) $this->db->sql_fetchfield('total_posts'); - $this->db->sql_freeresult($result); - - $sql = 'SELECT COUNT(p.post_id) as main_posts - FROM ' . POSTS_TABLE . ' p, ' . SPHINX_TABLE . ' m - WHERE p.post_id <= m.max_doc_id - AND m.counter_id = 1'; - $result = $this->db->sql_query($sql); - $this->stats['main_posts'] = (int) $this->db->sql_fetchfield('main_posts'); - $this->db->sql_freeresult($result); - } - } - - /** - * Returns a list of options for the ACP to display - * - * @return associative array containing template and config variables - */ - public function acp() - { - $config_vars = array( - 'fulltext_sphinx_data_path' => 'string', - 'fulltext_sphinx_host' => 'string', - 'fulltext_sphinx_port' => 'string', - 'fulltext_sphinx_indexer_mem_limit' => 'int', - ); - - $tpl = ' - ' . $this->user->lang['FULLTEXT_SPHINX_CONFIGURE']. ' -
-

' . $this->user->lang['FULLTEXT_SPHINX_DATA_PATH_EXPLAIN'] . '
-
-
-
-

' . $this->user->lang['FULLTEXT_SPHINX_HOST_EXPLAIN'] . '
-
-
-
-

' . $this->user->lang['FULLTEXT_SPHINX_PORT_EXPLAIN'] . '
-
-
-
-

' . $this->user->lang['FULLTEXT_SPHINX_INDEXER_MEM_LIMIT_EXPLAIN'] . '
-
' . $this->user->lang['MIB'] . '
-
-
-

' . $this->user->lang['FULLTEXT_SPHINX_CONFIG_FILE_EXPLAIN'] . '
-
' . (($this->config_generate()) ? '' : $this->config_file_data) . '
-
- '; - - // These are fields required in the config table - return array( - 'tpl' => $tpl, - 'config' => $config_vars - ); - } -} diff --git a/install/update/old/phpbb/session.php b/install/update/old/phpbb/session.php deleted file mode 100644 index 31f32af..0000000 --- a/install/update/old/phpbb/session.php +++ /dev/null @@ -1,1650 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb; - -/** -* Session class -*/ -class session -{ - var $cookie_data = array(); - var $page = array(); - var $data = array(); - var $browser = ''; - var $forwarded_for = ''; - var $host = ''; - var $session_id = ''; - var $ip = ''; - var $load = 0; - var $time_now = 0; - var $update_session_page = true; - - /** - * Extract current session page - * - * @param string $root_path current root path (phpbb_root_path) - * @return array - */ - static function extract_current_page($root_path) - { - global $request, $symfony_request, $phpbb_filesystem; - - $page_array = array(); - - // First of all, get the request uri... - $script_name = $request->escape($symfony_request->getScriptName(), true); - $args = $request->escape(explode('&', $symfony_request->getQueryString()), true); - - // If we are unable to get the script name we use REQUEST_URI as a failover and note it within the page array for easier support... - if (!$script_name) - { - $script_name = htmlspecialchars_decode($request->server('REQUEST_URI')); - $script_name = (($pos = strpos($script_name, '?')) !== false) ? substr($script_name, 0, $pos) : $script_name; - $page_array['failover'] = 1; - } - - // Replace backslashes and doubled slashes (could happen on some proxy setups) - $script_name = str_replace(array('\\', '//'), '/', $script_name); - - // Now, remove the sid and let us get a clean query string... - $use_args = array(); - - // Since some browser do not encode correctly we need to do this with some "special" characters... - // " -> %22, ' => %27, < -> %3C, > -> %3E - $find = array('"', "'", '<', '>', '"', '<', '>'); - $replace = array('%22', '%27', '%3C', '%3E', '%22', '%3C', '%3E'); - - foreach ($args as $key => $argument) - { - if (strpos($argument, 'sid=') === 0) - { - continue; - } - - $use_args[] = str_replace($find, $replace, $argument); - } - unset($args); - - // The following examples given are for an request uri of {path to the phpbb directory}/adm/index.php?i=10&b=2 - - // The current query string - $query_string = trim(implode('&', $use_args)); - - // basenamed page name (for example: index.php) - $page_name = (substr($script_name, -1, 1) == '/') ? '' : basename($script_name); - $page_name = urlencode(htmlspecialchars($page_name)); - - $symfony_request_path = $phpbb_filesystem->clean_path($symfony_request->getPathInfo()); - if ($symfony_request_path !== '/') - { - $page_name .= str_replace('%2F', '/', urlencode($symfony_request_path)); - } - - if (substr($root_path, 0, 2) === './' && strpos($root_path, '..') === false) - { - $root_dirs = explode('/', str_replace('\\', '/', rtrim($root_path, '/'))); - $page_dirs = explode('/', str_replace('\\', '/', '.')); - } - else - { - // current directory within the phpBB root (for example: adm) - $root_dirs = explode('/', str_replace('\\', '/', $phpbb_filesystem->realpath($root_path))); - $page_dirs = explode('/', str_replace('\\', '/', $phpbb_filesystem->realpath('./'))); - } - - $intersection = array_intersect_assoc($root_dirs, $page_dirs); - - $root_dirs = array_diff_assoc($root_dirs, $intersection); - $page_dirs = array_diff_assoc($page_dirs, $intersection); - - $page_dir = str_repeat('../', count($root_dirs)) . implode('/', $page_dirs); - - if ($page_dir && substr($page_dir, -1, 1) == '/') - { - $page_dir = substr($page_dir, 0, -1); - } - - // Current page from phpBB root (for example: adm/index.php?i=10&b=2) - $page = (($page_dir) ? $page_dir . '/' : '') . $page_name; - if ($query_string) - { - $page .= '?' . $query_string; - } - - // The script path from the webroot to the current directory (for example: /phpBB3/adm/) : always prefixed with / and ends in / - $script_path = $symfony_request->getBasePath(); - - // The script path from the webroot to the phpBB root (for example: /phpBB3/) - $script_dirs = explode('/', $script_path); - array_splice($script_dirs, -count($page_dirs)); - $root_script_path = implode('/', $script_dirs) . (count($root_dirs) ? '/' . implode('/', $root_dirs) : ''); - - // We are on the base level (phpBB root == webroot), lets adjust the variables a bit... - if (!$root_script_path) - { - $root_script_path = ($page_dir) ? str_replace($page_dir, '', $script_path) : $script_path; - } - - $script_path .= (substr($script_path, -1, 1) == '/') ? '' : '/'; - $root_script_path .= (substr($root_script_path, -1, 1) == '/') ? '' : '/'; - - $forum_id = $request->variable('f', 0); - // maximum forum id value is maximum value of mediumint unsigned column - $forum_id = ($forum_id > 0 && $forum_id < 16777215) ? $forum_id : 0; - - $page_array += array( - 'page_name' => $page_name, - 'page_dir' => $page_dir, - - 'query_string' => $query_string, - 'script_path' => str_replace(' ', '%20', htmlspecialchars($script_path)), - 'root_script_path' => str_replace(' ', '%20', htmlspecialchars($root_script_path)), - - 'page' => $page, - 'forum' => $forum_id, - ); - - return $page_array; - } - - /** - * Get valid hostname/port. HTTP_HOST is used, SERVER_NAME if HTTP_HOST not present. - */ - function extract_current_hostname() - { - global $config, $request; - - // Get hostname - $host = htmlspecialchars_decode($request->header('Host', $request->server('SERVER_NAME'))); - - // Should be a string and lowered - $host = (string) strtolower($host); - - // If host is equal the cookie domain or the server name (if config is set), then we assume it is valid - if ((isset($config['cookie_domain']) && $host === $config['cookie_domain']) || (isset($config['server_name']) && $host === $config['server_name'])) - { - return $host; - } - - // Is the host actually a IP? If so, we use the IP... (IPv4) - if (long2ip(ip2long($host)) === $host) - { - return $host; - } - - // Now return the hostname (this also removes any port definition). The http:// is prepended to construct a valid URL, hosts never have a scheme assigned - $host = @parse_url('http://' . $host); - $host = (!empty($host['host'])) ? $host['host'] : ''; - - // Remove any portions not removed by parse_url (#) - $host = str_replace('#', '', $host); - - // If, by any means, the host is now empty, we will use a "best approach" way to guess one - if (empty($host)) - { - if (!empty($config['server_name'])) - { - $host = $config['server_name']; - } - else if (!empty($config['cookie_domain'])) - { - $host = (strpos($config['cookie_domain'], '.') === 0) ? substr($config['cookie_domain'], 1) : $config['cookie_domain']; - } - else - { - // Set to OS hostname or localhost - $host = (function_exists('php_uname')) ? php_uname('n') : 'localhost'; - } - } - - // It may be still no valid host, but for sure only a hostname (we may further expand on the cookie domain... if set) - return $host; - } - - /** - * Start session management - * - * This is where all session activity begins. We gather various pieces of - * information from the client and server. We test to see if a session already - * exists. If it does, fine and dandy. If it doesn't we'll go on to create a - * new one ... pretty logical heh? We also examine the system load (if we're - * running on a system which makes such information readily available) and - * halt if it's above an admin definable limit. - * - * @param bool $update_session_page if true the session page gets updated. - * This can be set to circumvent certain scripts to update the users last visited page. - */ - function session_begin($update_session_page = true) - { - global $phpEx, $SID, $_SID, $_EXTRA_URL, $db, $config, $phpbb_root_path; - global $request, $phpbb_container, $user, $phpbb_log, $phpbb_dispatcher; - - // Give us some basic information - $this->time_now = time(); - $this->cookie_data = array('u' => 0, 'k' => ''); - $this->update_session_page = $update_session_page; - $this->browser = $request->header('User-Agent'); - $this->referer = $request->header('Referer'); - $this->forwarded_for = $request->header('X-Forwarded-For'); - - $this->host = $this->extract_current_hostname(); - $this->page = $this->extract_current_page($phpbb_root_path); - - // if the forwarded for header shall be checked we have to validate its contents - if ($config['forwarded_for_check']) - { - $this->forwarded_for = preg_replace('# {2,}#', ' ', str_replace(',', ' ', $this->forwarded_for)); - - // split the list of IPs - $ips = explode(' ', $this->forwarded_for); - foreach ($ips as $ip) - { - // check IPv4 first, the IPv6 is hopefully only going to be used very seldomly - if (!empty($ip) && !preg_match(get_preg_expression('ipv4'), $ip) && !preg_match(get_preg_expression('ipv6'), $ip)) - { - // contains invalid data, don't use the forwarded for header - $this->forwarded_for = ''; - break; - } - } - } - else - { - $this->forwarded_for = ''; - } - - if ($request->is_set($config['cookie_name'] . '_sid', \phpbb\request\request_interface::COOKIE) || $request->is_set($config['cookie_name'] . '_u', \phpbb\request\request_interface::COOKIE)) - { - $this->cookie_data['u'] = $request->variable($config['cookie_name'] . '_u', 0, false, \phpbb\request\request_interface::COOKIE); - $this->cookie_data['k'] = $request->variable($config['cookie_name'] . '_k', '', false, \phpbb\request\request_interface::COOKIE); - $this->session_id = $request->variable($config['cookie_name'] . '_sid', '', false, \phpbb\request\request_interface::COOKIE); - - $SID = (defined('NEED_SID')) ? '?sid=' . $this->session_id : '?sid='; - $_SID = (defined('NEED_SID')) ? $this->session_id : ''; - - if (empty($this->session_id)) - { - $this->session_id = $_SID = $request->variable('sid', ''); - $SID = '?sid=' . $this->session_id; - $this->cookie_data = array('u' => 0, 'k' => ''); - } - } - else - { - $this->session_id = $_SID = $request->variable('sid', ''); - $SID = '?sid=' . $this->session_id; - } - - $_EXTRA_URL = array(); - - // Why no forwarded_for et al? Well, too easily spoofed. With the results of my recent requests - // it's pretty clear that in the majority of cases you'll at least be left with a proxy/cache ip. - $ip = htmlspecialchars_decode($request->server('REMOTE_ADDR')); - $ip = preg_replace('# {2,}#', ' ', str_replace(',', ' ', $ip)); - - /** - * Event to alter user IP address - * - * @event core.session_ip_after - * @var string ip REMOTE_ADDR - * @since 3.1.10-RC1 - */ - $vars = array('ip'); - extract($phpbb_dispatcher->trigger_event('core.session_ip_after', compact($vars))); - - // split the list of IPs - $ips = explode(' ', trim($ip)); - - // Default IP if REMOTE_ADDR is invalid - $this->ip = '127.0.0.1'; - - foreach ($ips as $ip) - { - if (function_exists('phpbb_ip_normalise')) - { - // Normalise IP address - $ip = phpbb_ip_normalise($ip); - - if (empty($ip)) - { - // IP address is invalid. - break; - } - - // IP address is valid. - $this->ip = $ip; - - // Skip legacy code. - continue; - } - - if (preg_match(get_preg_expression('ipv4'), $ip)) - { - $this->ip = $ip; - } - else if (preg_match(get_preg_expression('ipv6'), $ip)) - { - // Quick check for IPv4-mapped address in IPv6 - if (stripos($ip, '::ffff:') === 0) - { - $ipv4 = substr($ip, 7); - - if (preg_match(get_preg_expression('ipv4'), $ipv4)) - { - $ip = $ipv4; - } - } - - $this->ip = $ip; - } - else - { - // We want to use the last valid address in the chain - // Leave foreach loop when address is invalid - break; - } - } - - $this->load = false; - - // Load limit check (if applicable) - if ($config['limit_load'] || $config['limit_search_load']) - { - if ((function_exists('sys_getloadavg') && $load = sys_getloadavg()) || ($load = explode(' ', @file_get_contents('/proc/loadavg')))) - { - $this->load = array_slice($load, 0, 1); - $this->load = floatval($this->load[0]); - } - else - { - $config->set('limit_load', '0'); - $config->set('limit_search_load', '0'); - } - } - - // if no session id is set, redirect to index.php - $session_id = $request->variable('sid', ''); - if (defined('NEED_SID') && (empty($session_id) || $this->session_id !== $session_id)) - { - send_status_line(401, 'Unauthorized'); - redirect(append_sid("{$phpbb_root_path}index.$phpEx")); - } - - // if session id is set - if (!empty($this->session_id)) - { - $sql = 'SELECT u.*, s.* - FROM ' . SESSIONS_TABLE . ' s, ' . USERS_TABLE . " u - WHERE s.session_id = '" . $db->sql_escape($this->session_id) . "' - AND u.user_id = s.session_user_id"; - $result = $db->sql_query($sql); - $this->data = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - // Did the session exist in the DB? - if (isset($this->data['user_id'])) - { - // Validate IP length according to admin ... enforces an IP - // check on bots if admin requires this -// $quadcheck = ($config['ip_check_bot'] && $this->data['user_type'] & USER_BOT) ? 4 : $config['ip_check']; - - if (strpos($this->ip, ':') !== false && strpos($this->data['session_ip'], ':') !== false) - { - $s_ip = short_ipv6($this->data['session_ip'], $config['ip_check']); - $u_ip = short_ipv6($this->ip, $config['ip_check']); - } - else - { - $s_ip = implode('.', array_slice(explode('.', $this->data['session_ip']), 0, $config['ip_check'])); - $u_ip = implode('.', array_slice(explode('.', $this->ip), 0, $config['ip_check'])); - } - - $s_browser = ($config['browser_check']) ? trim(strtolower(substr($this->data['session_browser'], 0, 149))) : ''; - $u_browser = ($config['browser_check']) ? trim(strtolower(substr($this->browser, 0, 149))) : ''; - - $s_forwarded_for = ($config['forwarded_for_check']) ? substr($this->data['session_forwarded_for'], 0, 254) : ''; - $u_forwarded_for = ($config['forwarded_for_check']) ? substr($this->forwarded_for, 0, 254) : ''; - - // referer checks - // The @ before $config['referer_validation'] suppresses notices present while running the updater - $check_referer_path = (@$config['referer_validation'] == REFERER_VALIDATE_PATH); - $referer_valid = true; - - // we assume HEAD and TRACE to be foul play and thus only whitelist GET - if (@$config['referer_validation'] && strtolower($request->server('REQUEST_METHOD')) !== 'get') - { - $referer_valid = $this->validate_referer($check_referer_path); - } - - if ($u_ip === $s_ip && $s_browser === $u_browser && $s_forwarded_for === $u_forwarded_for && $referer_valid) - { - $session_expired = false; - - // Check whether the session is still valid if we have one - /* @var $provider_collection \phpbb\auth\provider_collection */ - $provider_collection = $phpbb_container->get('auth.provider_collection'); - $provider = $provider_collection->get_provider(); - - if (!($provider instanceof \phpbb\auth\provider\provider_interface)) - { - throw new \RuntimeException($provider . ' must implement \phpbb\auth\provider\provider_interface'); - } - - $ret = $provider->validate_session($this->data); - if ($ret !== null && !$ret) - { - $session_expired = true; - } - - if (!$session_expired) - { - // Check the session length timeframe if autologin is not enabled. - // Else check the autologin length... and also removing those having autologin enabled but no longer allowed board-wide. - if (!$this->data['session_autologin']) - { - if ($this->data['session_time'] < $this->time_now - ($config['session_length'] + 60)) - { - $session_expired = true; - } - } - else if (!$config['allow_autologin'] || ($config['max_autologin_time'] && $this->data['session_time'] < $this->time_now - (86400 * (int) $config['max_autologin_time']) + 60)) - { - $session_expired = true; - } - } - - if (!$session_expired) - { - $this->data['is_registered'] = ($this->data['user_id'] != ANONYMOUS && ($this->data['user_type'] == USER_NORMAL || $this->data['user_type'] == USER_FOUNDER)) ? true : false; - $this->data['is_bot'] = (!$this->data['is_registered'] && $this->data['user_id'] != ANONYMOUS) ? true : false; - $this->data['user_lang'] = basename($this->data['user_lang']); - - // Is user banned? Are they excluded? Won't return on ban, exists within method - $this->check_ban_for_current_session($config); - - return true; - } - } - else - { - // Added logging temporarly to help debug bugs... - if (defined('DEBUG') && $this->data['user_id'] != ANONYMOUS) - { - if ($referer_valid) - { - $phpbb_log->add('critical', $user->data['user_id'], $user->ip, 'LOG_IP_BROWSER_FORWARDED_CHECK', false, array( - $u_ip, - $s_ip, - $u_browser, - $s_browser, - htmlspecialchars($u_forwarded_for), - htmlspecialchars($s_forwarded_for) - )); - } - else - { - $phpbb_log->add('critical', $user->data['user_id'], $user->ip, 'LOG_REFERER_INVALID', false, array($this->referer)); - } - } - } - } - } - - // If we reach here then no (valid) session exists. So we'll create a new one - return $this->session_create(); - } - - /** - * Create a new session - * - * If upon trying to start a session we discover there is nothing existing we - * jump here. Additionally this method is called directly during login to regenerate - * the session for the specific user. In this method we carry out a number of tasks; - * garbage collection, (search)bot checking, banned user comparison. Basically - * though this method will result in a new session for a specific user. - */ - function session_create($user_id = false, $set_admin = false, $persist_login = false, $viewonline = true) - { - global $SID, $_SID, $db, $config, $cache, $phpbb_container, $phpbb_dispatcher; - - $this->data = array(); - - /* Garbage collection ... remove old sessions updating user information - // if necessary. It means (potentially) 11 queries but only infrequently - if ($this->time_now > $config['session_last_gc'] + $config['session_gc']) - { - $this->session_gc(); - }*/ - - // Do we allow autologin on this board? No? Then override anything - // that may be requested here - if (!$config['allow_autologin']) - { - $this->cookie_data['k'] = $persist_login = false; - } - - /** - * Here we do a bot check, oh er saucy! No, not that kind of bot - * check. We loop through the list of bots defined by the admin and - * see if we have any useragent and/or IP matches. If we do, this is a - * bot, act accordingly - */ - $bot = false; - $active_bots = $cache->obtain_bots(); - - foreach ($active_bots as $row) - { - if ($row['bot_agent'] && preg_match('#' . str_replace('\*', '.*?', preg_quote($row['bot_agent'], '#')) . '#i', $this->browser)) - { - $bot = $row['user_id']; - } - - // If ip is supplied, we will make sure the ip is matching too... - if ($row['bot_ip'] && ($bot || !$row['bot_agent'])) - { - // Set bot to false, then we only have to set it to true if it is matching - $bot = false; - - foreach (explode(',', $row['bot_ip']) as $bot_ip) - { - $bot_ip = trim($bot_ip); - - if (!$bot_ip) - { - continue; - } - - if (strpos($this->ip, $bot_ip) === 0) - { - $bot = (int) $row['user_id']; - break; - } - } - } - - if ($bot) - { - break; - } - } - - /* @var $provider_collection \phpbb\auth\provider_collection */ - $provider_collection = $phpbb_container->get('auth.provider_collection'); - $provider = $provider_collection->get_provider(); - $this->data = $provider->autologin(); - - if ($user_id !== false && isset($this->data['user_id']) && $this->data['user_id'] != $user_id) - { - $this->data = array(); - } - - if (isset($this->data['user_id'])) - { - $this->cookie_data['k'] = ''; - $this->cookie_data['u'] = $this->data['user_id']; - } - - // If we're presented with an autologin key we'll join against it. - // Else if we've been passed a user_id we'll grab data based on that - if (isset($this->cookie_data['k']) && $this->cookie_data['k'] && $this->cookie_data['u'] && empty($this->data)) - { - $sql = 'SELECT u.* - FROM ' . USERS_TABLE . ' u, ' . SESSIONS_KEYS_TABLE . ' k - WHERE u.user_id = ' . (int) $this->cookie_data['u'] . ' - AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ") - AND k.user_id = u.user_id - AND k.key_id = '" . $db->sql_escape(md5($this->cookie_data['k'])) . "'"; - $result = $db->sql_query($sql); - $user_data = $db->sql_fetchrow($result); - - if ($user_id === false || (isset($user_data['user_id']) && $user_id == $user_data['user_id'])) - { - $this->data = $user_data; - $bot = false; - } - - $db->sql_freeresult($result); - } - - if ($user_id !== false && empty($this->data)) - { - $this->cookie_data['k'] = ''; - $this->cookie_data['u'] = $user_id; - - $sql = 'SELECT * - FROM ' . USERS_TABLE . ' - WHERE user_id = ' . (int) $this->cookie_data['u'] . ' - AND user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')'; - $result = $db->sql_query($sql); - $this->data = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - $bot = false; - } - - // Bot user, if they have a SID in the Request URI we need to get rid of it - // otherwise they'll index this page with the SID, duplicate content oh my! - if ($bot && isset($_GET['sid'])) - { - send_status_line(301, 'Moved Permanently'); - redirect(build_url(array('sid'))); - } - - // If no data was returned one or more of the following occurred: - // Key didn't match one in the DB - // User does not exist - // User is inactive - // User is bot - if (!is_array($this->data) || !count($this->data)) - { - $this->cookie_data['k'] = ''; - $this->cookie_data['u'] = ($bot) ? $bot : ANONYMOUS; - - if (!$bot) - { - $sql = 'SELECT * - FROM ' . USERS_TABLE . ' - WHERE user_id = ' . (int) $this->cookie_data['u']; - } - else - { - // We give bots always the same session if it is not yet expired. - $sql = 'SELECT u.*, s.* - FROM ' . USERS_TABLE . ' u - LEFT JOIN ' . SESSIONS_TABLE . ' s ON (s.session_user_id = u.user_id) - WHERE u.user_id = ' . (int) $bot; - } - - $result = $db->sql_query($sql); - $this->data = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - } - - if ($this->data['user_id'] != ANONYMOUS && !$bot) - { - $this->data['session_last_visit'] = (isset($this->data['session_time']) && $this->data['session_time']) ? $this->data['session_time'] : (($this->data['user_lastvisit']) ? $this->data['user_lastvisit'] : time()); - } - else - { - $this->data['session_last_visit'] = $this->time_now; - } - - // Force user id to be integer... - $this->data['user_id'] = (int) $this->data['user_id']; - - // At this stage we should have a filled data array, defined cookie u and k data. - // data array should contain recent session info if we're a real user and a recent - // session exists in which case session_id will also be set - - // Is user banned? Are they excluded? Won't return on ban, exists within method - $this->check_ban_for_current_session($config); - - $this->data['is_registered'] = (!$bot && $this->data['user_id'] != ANONYMOUS && ($this->data['user_type'] == USER_NORMAL || $this->data['user_type'] == USER_FOUNDER)) ? true : false; - $this->data['is_bot'] = ($bot) ? true : false; - - // If our friend is a bot, we re-assign a previously assigned session - if ($this->data['is_bot'] && $bot == $this->data['user_id'] && $this->data['session_id']) - { - // Only assign the current session if the ip, browser and forwarded_for match... - if (strpos($this->ip, ':') !== false && strpos($this->data['session_ip'], ':') !== false) - { - $s_ip = short_ipv6($this->data['session_ip'], $config['ip_check']); - $u_ip = short_ipv6($this->ip, $config['ip_check']); - } - else - { - $s_ip = implode('.', array_slice(explode('.', $this->data['session_ip']), 0, $config['ip_check'])); - $u_ip = implode('.', array_slice(explode('.', $this->ip), 0, $config['ip_check'])); - } - - $s_browser = ($config['browser_check']) ? trim(strtolower(substr($this->data['session_browser'], 0, 149))) : ''; - $u_browser = ($config['browser_check']) ? trim(strtolower(substr($this->browser, 0, 149))) : ''; - - $s_forwarded_for = ($config['forwarded_for_check']) ? substr($this->data['session_forwarded_for'], 0, 254) : ''; - $u_forwarded_for = ($config['forwarded_for_check']) ? substr($this->forwarded_for, 0, 254) : ''; - - if ($u_ip === $s_ip && $s_browser === $u_browser && $s_forwarded_for === $u_forwarded_for) - { - $this->session_id = $this->data['session_id']; - - // Only update session DB a minute or so after last update or if page changes - if ($this->time_now - $this->data['session_time'] > 60 || ($this->update_session_page && $this->data['session_page'] != $this->page['page'])) - { - // Update the last visit time - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_lastvisit = ' . (int) $this->data['session_time'] . ' - WHERE user_id = ' . (int) $this->data['user_id']; - $db->sql_query($sql); - } - - $SID = '?sid='; - $_SID = ''; - return true; - } - else - { - // If the ip and browser does not match make sure we only have one bot assigned to one session - $db->sql_query('DELETE FROM ' . SESSIONS_TABLE . ' WHERE session_user_id = ' . $this->data['user_id']); - } - } - - $session_autologin = (($this->cookie_data['k'] || $persist_login) && $this->data['is_registered']) ? true : false; - $set_admin = ($set_admin && $this->data['is_registered']) ? true : false; - - // Create or update the session - $sql_ary = array( - 'session_user_id' => (int) $this->data['user_id'], - 'session_start' => (int) $this->time_now, - 'session_last_visit' => (int) $this->data['session_last_visit'], - 'session_time' => (int) $this->time_now, - 'session_browser' => (string) trim(substr($this->browser, 0, 149)), - 'session_forwarded_for' => (string) $this->forwarded_for, - 'session_ip' => (string) $this->ip, - 'session_autologin' => ($session_autologin) ? 1 : 0, - 'session_admin' => ($set_admin) ? 1 : 0, - 'session_viewonline' => ($viewonline) ? 1 : 0, - ); - - if ($this->update_session_page) - { - $sql_ary['session_page'] = (string) substr($this->page['page'], 0, 199); - $sql_ary['session_forum_id'] = $this->page['forum']; - } - - $db->sql_return_on_error(true); - - $sql = 'DELETE - FROM ' . SESSIONS_TABLE . ' - WHERE session_id = \'' . $db->sql_escape($this->session_id) . '\' - AND session_user_id = ' . ANONYMOUS; - - if (!defined('IN_ERROR_HANDLER') && (!$this->session_id || !$db->sql_query($sql) || !$db->sql_affectedrows())) - { - // Limit new sessions in 1 minute period (if required) - if (empty($this->data['session_time']) && $config['active_sessions']) - { -// $db->sql_return_on_error(false); - - $sql = 'SELECT COUNT(session_id) AS sessions - FROM ' . SESSIONS_TABLE . ' - WHERE session_time >= ' . ($this->time_now - 60); - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ((int) $row['sessions'] > (int) $config['active_sessions']) - { - send_status_line(503, 'Service Unavailable'); - trigger_error('BOARD_UNAVAILABLE'); - } - } - } - - // Since we re-create the session id here, the inserted row must be unique. Therefore, we display potential errors. - // Commented out because it will not allow forums to update correctly -// $db->sql_return_on_error(false); - - // Something quite important: session_page always holds the *last* page visited, except for the *first* visit. - // We are not able to simply have an empty session_page btw, therefore we need to tell phpBB how to detect this special case. - // If the session id is empty, we have a completely new one and will set an "identifier" here. This identifier is able to be checked later. - if (empty($this->data['session_id'])) - { - // This is a temporary variable, only set for the very first visit - $this->data['session_created'] = true; - } - - $this->session_id = $this->data['session_id'] = md5(unique_id()); - - $sql_ary['session_id'] = (string) $this->session_id; - $sql_ary['session_page'] = (string) substr($this->page['page'], 0, 199); - $sql_ary['session_forum_id'] = $this->page['forum']; - - $sql = 'INSERT INTO ' . SESSIONS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); - $db->sql_query($sql); - - $db->sql_return_on_error(false); - - // Regenerate autologin/persistent login key - if ($session_autologin) - { - $this->set_login_key(); - } - - // refresh data - $SID = '?sid=' . $this->session_id; - $_SID = $this->session_id; - $this->data = array_merge($this->data, $sql_ary); - - if (!$bot) - { - $cookie_expire = $this->time_now + (($config['max_autologin_time']) ? 86400 * (int) $config['max_autologin_time'] : 31536000); - - $this->set_cookie('u', $this->cookie_data['u'], $cookie_expire); - $this->set_cookie('k', $this->cookie_data['k'], $cookie_expire); - $this->set_cookie('sid', $this->session_id, $cookie_expire); - - unset($cookie_expire); - - $sql = 'SELECT COUNT(session_id) AS sessions - FROM ' . SESSIONS_TABLE . ' - WHERE session_user_id = ' . (int) $this->data['user_id'] . ' - AND session_time >= ' . (int) ($this->time_now - (max((int) $config['session_length'], (int) $config['form_token_lifetime']))); - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ((int) $row['sessions'] <= 1 || empty($this->data['user_form_salt'])) - { - $this->data['user_form_salt'] = unique_id(); - // Update the form key - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_form_salt = \'' . $db->sql_escape($this->data['user_form_salt']) . '\' - WHERE user_id = ' . (int) $this->data['user_id']; - $db->sql_query($sql); - } - } - else - { - $this->data['session_time'] = $this->data['session_last_visit'] = $this->time_now; - - // Update the last visit time - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_lastvisit = ' . (int) $this->data['session_time'] . ' - WHERE user_id = ' . (int) $this->data['user_id']; - $db->sql_query($sql); - - $SID = '?sid='; - $_SID = ''; - } - - $session_data = $sql_ary; - /** - * Event to send new session data to extension - * Read-only event - * - * @event core.session_create_after - * @var array session_data Associative array of session keys to be updated - * @since 3.1.6-RC1 - */ - $vars = array('session_data'); - extract($phpbb_dispatcher->trigger_event('core.session_create_after', compact($vars))); - unset($session_data); - - return true; - } - - /** - * Kills a session - * - * This method does what it says on the tin. It will delete a pre-existing session. - * It resets cookie information (destroying any autologin key within that cookie data) - * and update the users information from the relevant session data. It will then - * grab guest user information. - */ - function session_kill($new_session = true) - { - global $SID, $_SID, $db, $phpbb_container, $phpbb_dispatcher; - - $sql = 'DELETE FROM ' . SESSIONS_TABLE . " - WHERE session_id = '" . $db->sql_escape($this->session_id) . "' - AND session_user_id = " . (int) $this->data['user_id']; - $db->sql_query($sql); - - $user_id = (int) $this->data['user_id']; - $session_id = $this->session_id; - /** - * Event to send session kill information to extension - * Read-only event - * - * @event core.session_kill_after - * @var int user_id user_id of the session user. - * @var string session_id current user's session_id - * @var bool new_session should we create new session for user - * @since 3.1.6-RC1 - */ - $vars = array('user_id', 'session_id', 'new_session'); - extract($phpbb_dispatcher->trigger_event('core.session_kill_after', compact($vars))); - unset($user_id); - unset($session_id); - - // Allow connecting logout with external auth method logout - /* @var $provider_collection \phpbb\auth\provider_collection */ - $provider_collection = $phpbb_container->get('auth.provider_collection'); - $provider = $provider_collection->get_provider(); - $provider->logout($this->data, $new_session); - - if ($this->data['user_id'] != ANONYMOUS) - { - // Delete existing session, update last visit info first! - if (!isset($this->data['session_time'])) - { - $this->data['session_time'] = time(); - } - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_lastvisit = ' . (int) $this->data['session_time'] . ' - WHERE user_id = ' . (int) $this->data['user_id']; - $db->sql_query($sql); - - if ($this->cookie_data['k']) - { - $sql = 'DELETE FROM ' . SESSIONS_KEYS_TABLE . ' - WHERE user_id = ' . (int) $this->data['user_id'] . " - AND key_id = '" . $db->sql_escape(md5($this->cookie_data['k'])) . "'"; - $db->sql_query($sql); - } - - // Reset the data array - $this->data = array(); - - $sql = 'SELECT * - FROM ' . USERS_TABLE . ' - WHERE user_id = ' . ANONYMOUS; - $result = $db->sql_query($sql); - $this->data = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - } - - $cookie_expire = $this->time_now - 31536000; - $this->set_cookie('u', '', $cookie_expire); - $this->set_cookie('k', '', $cookie_expire); - $this->set_cookie('sid', '', $cookie_expire); - unset($cookie_expire); - - $SID = '?sid='; - $this->session_id = $_SID = ''; - - // To make sure a valid session is created we create one for the anonymous user - if ($new_session) - { - $this->session_create(ANONYMOUS); - } - - return true; - } - - /** - * Session garbage collection - * - * This looks a lot more complex than it really is. Effectively we are - * deleting any sessions older than an admin definable limit. Due to the - * way in which we maintain session data we have to ensure we update user - * data before those sessions are destroyed. In addition this method - * removes autologin key information that is older than an admin defined - * limit. - */ - function session_gc() - { - global $db, $config, $phpbb_container, $phpbb_dispatcher; - - $batch_size = 10; - - if (!$this->time_now) - { - $this->time_now = time(); - } - - // Firstly, delete guest sessions - $sql = 'DELETE FROM ' . SESSIONS_TABLE . ' - WHERE session_user_id = ' . ANONYMOUS . ' - AND session_time < ' . (int) ($this->time_now - $config['session_length']); - $db->sql_query($sql); - - // Get expired sessions, only most recent for each user - $sql = 'SELECT session_user_id, session_page, MAX(session_time) AS recent_time - FROM ' . SESSIONS_TABLE . ' - WHERE session_time < ' . ($this->time_now - $config['session_length']) . ' - GROUP BY session_user_id, session_page'; - $result = $db->sql_query_limit($sql, $batch_size); - - $del_user_id = array(); - $del_sessions = 0; - - while ($row = $db->sql_fetchrow($result)) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_lastvisit = ' . (int) $row['recent_time'] . ", user_lastpage = '" . $db->sql_escape($row['session_page']) . "' - WHERE user_id = " . (int) $row['session_user_id']; - $db->sql_query($sql); - - $del_user_id[] = (int) $row['session_user_id']; - $del_sessions++; - } - $db->sql_freeresult($result); - - if (count($del_user_id)) - { - // Delete expired sessions - $sql = 'DELETE FROM ' . SESSIONS_TABLE . ' - WHERE ' . $db->sql_in_set('session_user_id', $del_user_id) . ' - AND session_time < ' . ($this->time_now - $config['session_length']); - $db->sql_query($sql); - } - - if ($del_sessions < $batch_size) - { - // Less than 10 users, update gc timer ... else we want gc - // called again to delete other sessions - $config->set('session_last_gc', $this->time_now, false); - - if ($config['max_autologin_time']) - { - $sql = 'DELETE FROM ' . SESSIONS_KEYS_TABLE . ' - WHERE last_login < ' . (time() - (86400 * (int) $config['max_autologin_time'])); - $db->sql_query($sql); - } - - // only called from CRON; should be a safe workaround until the infrastructure gets going - /* @var $captcha_factory \phpbb\captcha\factory */ - $captcha_factory = $phpbb_container->get('captcha.factory'); - $captcha_factory->garbage_collect($config['captcha_plugin']); - - $sql = 'DELETE FROM ' . LOGIN_ATTEMPT_TABLE . ' - WHERE attempt_time < ' . (time() - (int) $config['ip_login_limit_time']); - $db->sql_query($sql); - } - - /** - * Event to trigger extension on session_gc - * - * @event core.session_gc_after - * @since 3.1.6-RC1 - */ - $phpbb_dispatcher->dispatch('core.session_gc_after'); - - return; - } - - /** - * Sets a cookie - * - * Sets a cookie of the given name with the specified data for the given length of time. If no time is specified, a session cookie will be set. - * - * @param string $name Name of the cookie, will be automatically prefixed with the phpBB cookie name. track becomes [cookie_name]_track then. - * @param string $cookiedata The data to hold within the cookie - * @param int $cookietime The expiration time as UNIX timestamp. If 0 is provided, a session cookie is set. - * @param bool $httponly Use HttpOnly. Defaults to true. Use false to make cookie accessible by client-side scripts. - */ - function set_cookie($name, $cookiedata, $cookietime, $httponly = true) - { - global $config; - - // If headers are already set, we just return - if (headers_sent()) - { - return; - } - - $name_data = rawurlencode($config['cookie_name'] . '_' . $name) . '=' . rawurlencode($cookiedata); - $expire = gmdate('D, d-M-Y H:i:s \\G\\M\\T', $cookietime); - $domain = (!$config['cookie_domain'] || $config['cookie_domain'] == '127.0.0.1' || strpos($config['cookie_domain'], '.') === false) ? '' : '; domain=' . $config['cookie_domain']; - - header('Set-Cookie: ' . $name_data . (($cookietime) ? '; expires=' . $expire : '') . '; path=' . $config['cookie_path'] . $domain . ((!$config['cookie_secure']) ? '' : '; secure') . ';' . (($httponly) ? ' HttpOnly' : ''), false); - } - - /** - * Check for banned user - * - * Checks whether the supplied user is banned by id, ip or email. If no parameters - * are passed to the method pre-existing session data is used. - * - * @param int|false $user_id The user id - * @param mixed $user_ips Can contain a string with one IP or an array of multiple IPs - * @param string|false $user_email The user email - * @param bool $return If $return is false this routine does not return on finding a banned user, - * it outputs a relevant message and stops execution. - */ - function check_ban($user_id = false, $user_ips = false, $user_email = false, $return = false) - { - global $config, $db, $phpbb_dispatcher; - - if (defined('IN_CHECK_BAN') || defined('SKIP_CHECK_BAN')) - { - return; - } - - $banned = false; - $cache_ttl = 3600; - $where_sql = array(); - - $sql = 'SELECT ban_ip, ban_userid, ban_email, ban_exclude, ban_give_reason, ban_end - FROM ' . BANLIST_TABLE . ' - WHERE '; - - // Determine which entries to check, only return those - if ($user_email === false) - { - $where_sql[] = "ban_email = ''"; - } - - if ($user_ips === false) - { - $where_sql[] = "(ban_ip = '' OR ban_exclude = 1)"; - } - - if ($user_id === false) - { - $where_sql[] = '(ban_userid = 0 OR ban_exclude = 1)'; - } - else - { - $cache_ttl = ($user_id == ANONYMOUS) ? 3600 : 0; - $_sql = '(ban_userid = ' . $user_id; - - if ($user_email !== false) - { - $_sql .= " OR ban_email <> ''"; - } - - if ($user_ips !== false) - { - $_sql .= " OR ban_ip <> ''"; - } - - $_sql .= ')'; - - $where_sql[] = $_sql; - } - - $sql .= (count($where_sql)) ? implode(' AND ', $where_sql) : ''; - $result = $db->sql_query($sql, $cache_ttl); - - $ban_triggered_by = 'user'; - while ($row = $db->sql_fetchrow($result)) - { - if ($row['ban_end'] && $row['ban_end'] < time()) - { - continue; - } - - $ip_banned = false; - if (!empty($row['ban_ip'])) - { - if (!is_array($user_ips)) - { - $ip_banned = preg_match('#^' . str_replace('\*', '.*?', preg_quote($row['ban_ip'], '#')) . '$#i', $user_ips); - } - else - { - foreach ($user_ips as $user_ip) - { - if (preg_match('#^' . str_replace('\*', '.*?', preg_quote($row['ban_ip'], '#')) . '$#i', $user_ip)) - { - $ip_banned = true; - break; - } - } - } - } - - if ((!empty($row['ban_userid']) && intval($row['ban_userid']) == $user_id) || - $ip_banned || - (!empty($row['ban_email']) && preg_match('#^' . str_replace('\*', '.*?', preg_quote($row['ban_email'], '#')) . '$#i', $user_email))) - { - if (!empty($row['ban_exclude'])) - { - $banned = false; - break; - } - else - { - $banned = true; - $ban_row = $row; - - if (!empty($row['ban_userid']) && intval($row['ban_userid']) == $user_id) - { - $ban_triggered_by = 'user'; - } - else if ($ip_banned) - { - $ban_triggered_by = 'ip'; - } - else - { - $ban_triggered_by = 'email'; - } - - // Don't break. Check if there is an exclude rule for this user - } - } - } - $db->sql_freeresult($result); - - /** - * Event to set custom ban type - * - * @event core.session_set_custom_ban - * @var bool return If $return is false this routine does not return on finding a banned user, it outputs a relevant message and stops execution - * @var bool banned Check if user already banned - * @var array|false ban_row Ban data - * @var string ban_triggered_by Method that caused ban, can be your custom method - * @since 3.1.3-RC1 - */ - $ban_row = isset($ban_row) ? $ban_row : false; - $vars = array('return', 'banned', 'ban_row', 'ban_triggered_by'); - extract($phpbb_dispatcher->trigger_event('core.session_set_custom_ban', compact($vars))); - - if ($banned && !$return) - { - global $phpbb_root_path, $phpEx; - - // If the session is empty we need to create a valid one... - if (empty($this->session_id)) - { - // This seems to be no longer needed? - #14971 -// $this->session_create(ANONYMOUS); - } - - // Initiate environment ... since it won't be set at this stage - $this->setup(); - - // Logout the user, banned users are unable to use the normal 'logout' link - if ($this->data['user_id'] != ANONYMOUS) - { - $this->session_kill(); - } - - // We show a login box here to allow founders accessing the board if banned by IP - if (defined('IN_LOGIN') && $this->data['user_id'] == ANONYMOUS) - { - $this->setup('ucp'); - $this->data['is_registered'] = $this->data['is_bot'] = false; - - // Set as a precaution to allow login_box() handling this case correctly as well as this function not being executed again. - define('IN_CHECK_BAN', 1); - - login_box("index.$phpEx"); - - // The false here is needed, else the user is able to circumvent the ban. - $this->session_kill(false); - } - - // Ok, we catch the case of an empty session id for the anonymous user... - // This can happen if the user is logging in, banned by username and the login_box() being called "again". - if (empty($this->session_id) && defined('IN_CHECK_BAN')) - { - $this->session_create(ANONYMOUS); - } - - // Determine which message to output - $till_date = ($ban_row['ban_end']) ? $this->format_date($ban_row['ban_end']) : ''; - $message = ($ban_row['ban_end']) ? 'BOARD_BAN_TIME' : 'BOARD_BAN_PERM'; - - $contact_link = phpbb_get_board_contact_link($config, $phpbb_root_path, $phpEx); - $message = sprintf($this->lang[$message], $till_date, '', ''); - $message .= ($ban_row['ban_give_reason']) ? '

' . sprintf($this->lang['BOARD_BAN_REASON'], $ban_row['ban_give_reason']) : ''; - $message .= '

' . $this->lang['BAN_TRIGGERED_BY_' . strtoupper($ban_triggered_by)] . ''; - - // A very special case... we are within the cron script which is not supposed to print out the ban message... show blank page - if (defined('IN_CRON')) - { - garbage_collection(); - exit_handler(); - exit; - } - - // To circumvent session_begin returning a valid value and the check_ban() not called on second page view, we kill the session again - $this->session_kill(false); - - trigger_error($message); - } - - if (!empty($ban_row)) - { - $ban_row['ban_triggered_by'] = $ban_triggered_by; - } - - return ($banned && $ban_row) ? $ban_row : $banned; - } - - /** - * Check the current session for bans - * - * @return true if session user is banned. - */ - protected function check_ban_for_current_session($config) - { - if (!defined('SKIP_CHECK_BAN') && $this->data['user_type'] != USER_FOUNDER) - { - if (!$config['forwarded_for_check']) - { - $this->check_ban($this->data['user_id'], $this->ip); - } - else - { - $ips = explode(' ', $this->forwarded_for); - $ips[] = $this->ip; - $this->check_ban($this->data['user_id'], $ips); - } - } - } - - /** - * Check if ip is blacklisted - * This should be called only where absolutely necessary - * - * Only IPv4 (rbldns does not support AAAA records/IPv6 lookups) - * - * @author satmd (from the php manual) - * @param string $mode register/post - spamcop for example is ommitted for posting - * @param string|false $ip the IPv4 address to check - * - * @return false if ip is not blacklisted, else an array([checked server], [lookup]) - */ - function check_dnsbl($mode, $ip = false) - { - if ($ip === false) - { - $ip = $this->ip; - } - - // Neither Spamhaus nor Spamcop supports IPv6 addresses. - if (strpos($ip, ':') !== false) - { - return false; - } - - $dnsbl_check = array( - 'sbl.spamhaus.org' => 'http://www.spamhaus.org/query/bl?ip=', - ); - - if ($mode == 'register') - { - $dnsbl_check['bl.spamcop.net'] = 'http://spamcop.net/bl.shtml?'; - } - - if ($ip) - { - $quads = explode('.', $ip); - $reverse_ip = $quads[3] . '.' . $quads[2] . '.' . $quads[1] . '.' . $quads[0]; - - // Need to be listed on all servers... - $listed = true; - $info = array(); - - foreach ($dnsbl_check as $dnsbl => $lookup) - { - if (phpbb_checkdnsrr($reverse_ip . '.' . $dnsbl . '.', 'A') === true) - { - $info = array($dnsbl, $lookup . $ip); - } - else - { - $listed = false; - } - } - - if ($listed) - { - return $info; - } - } - - return false; - } - - /** - * Check if URI is blacklisted - * This should be called only where absolutly necessary, for example on the submitted website field - * This function is not in use at the moment and is only included for testing purposes, it may not work at all! - * This means it is untested at the moment and therefore commented out - * - * @param string $uri URI to check - * @return true if uri is on blacklist, else false. Only blacklist is checked (~zero FP), no grey lists - function check_uribl($uri) - { - // Normally parse_url() is not intended to parse uris - // We need to get the top-level domain name anyway... change. - $uri = parse_url($uri); - - if ($uri === false || empty($uri['host'])) - { - return false; - } - - $uri = trim($uri['host']); - - if ($uri) - { - // One problem here... the return parameter for the "windows" method is different from what - // we expect... this may render this check useless... - if (phpbb_checkdnsrr($uri . '.multi.uribl.com.', 'A') === true) - { - return true; - } - } - - return false; - } - */ - - /** - * Set/Update a persistent login key - * - * This method creates or updates a persistent session key. When a user makes - * use of persistent (formerly auto-) logins a key is generated and stored in the - * DB. When they revisit with the same key it's automatically updated in both the - * DB and cookie. Multiple keys may exist for each user representing different - * browsers or locations. As with _any_ non-secure-socket no passphrase login this - * remains vulnerable to exploit. - */ - function set_login_key($user_id = false, $key = false, $user_ip = false) - { - global $db; - - $user_id = ($user_id === false) ? $this->data['user_id'] : $user_id; - $user_ip = ($user_ip === false) ? $this->ip : $user_ip; - $key = ($key === false) ? (($this->cookie_data['k']) ? $this->cookie_data['k'] : false) : $key; - - $key_id = unique_id(hexdec(substr($this->session_id, 0, 8))); - - $sql_ary = array( - 'key_id' => (string) md5($key_id), - 'last_ip' => (string) $user_ip, - 'last_login' => (int) time() - ); - - if (!$key) - { - $sql_ary += array( - 'user_id' => (int) $user_id - ); - } - - if ($key) - { - $sql = 'UPDATE ' . SESSIONS_KEYS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE user_id = ' . (int) $user_id . " - AND key_id = '" . $db->sql_escape(md5($key)) . "'"; - } - else - { - $sql = 'INSERT INTO ' . SESSIONS_KEYS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); - } - $db->sql_query($sql); - - $this->cookie_data['k'] = $key_id; - - return false; - } - - /** - * Reset all login keys for the specified user - * - * This method removes all current login keys for a specified (or the current) - * user. It will be called on password change to render old keys unusable - */ - function reset_login_keys($user_id = false) - { - global $db; - - $user_id = ($user_id === false) ? (int) $this->data['user_id'] : (int) $user_id; - - $sql = 'DELETE FROM ' . SESSIONS_KEYS_TABLE . ' - WHERE user_id = ' . (int) $user_id; - $db->sql_query($sql); - - // If the user is logged in, update last visit info first before deleting sessions - $sql = 'SELECT session_time, session_page - FROM ' . SESSIONS_TABLE . ' - WHERE session_user_id = ' . (int) $user_id . ' - ORDER BY session_time DESC'; - $result = $db->sql_query_limit($sql, 1); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_lastvisit = ' . (int) $row['session_time'] . ", user_lastpage = '" . $db->sql_escape($row['session_page']) . "' - WHERE user_id = " . (int) $user_id; - $db->sql_query($sql); - } - - // Let's also clear any current sessions for the specified user_id - // If it's the current user then we'll leave this session intact - $sql_where = 'session_user_id = ' . (int) $user_id; - $sql_where .= ($user_id === (int) $this->data['user_id']) ? " AND session_id <> '" . $db->sql_escape($this->session_id) . "'" : ''; - - $sql = 'DELETE FROM ' . SESSIONS_TABLE . " - WHERE $sql_where"; - $db->sql_query($sql); - - // We're changing the password of the current user and they have a key - // Lets regenerate it to be safe - if ($user_id === (int) $this->data['user_id'] && $this->cookie_data['k']) - { - $this->set_login_key($user_id); - } - } - - - /** - * Check if the request originated from the same page. - * @param bool $check_script_path If true, the path will be checked as well - */ - function validate_referer($check_script_path = false) - { - global $config, $request; - - // no referer - nothing to validate, user's fault for turning it off (we only check on POST; so meta can't be the reason) - if (empty($this->referer) || empty($this->host)) - { - return true; - } - - $host = htmlspecialchars($this->host); - $ref = substr($this->referer, strpos($this->referer, '://') + 3); - - if (!(stripos($ref, $host) === 0) && (!$config['force_server_vars'] || !(stripos($ref, $config['server_name']) === 0))) - { - return false; - } - else if ($check_script_path && rtrim($this->page['root_script_path'], '/') !== '') - { - $ref = substr($ref, strlen($host)); - $server_port = $request->server('SERVER_PORT', 0); - - if ($server_port !== 80 && $server_port !== 443 && stripos($ref, ":$server_port") === 0) - { - $ref = substr($ref, strlen(":$server_port")); - } - - if (!(stripos(rtrim($ref, '/'), rtrim($this->page['root_script_path'], '/')) === 0)) - { - return false; - } - } - - return true; - } - - - function unset_admin() - { - global $db; - $sql = 'UPDATE ' . SESSIONS_TABLE . ' - SET session_admin = 0 - WHERE session_id = \'' . $db->sql_escape($this->session_id) . '\''; - $db->sql_query($sql); - } - - /** - * Update the session data - * - * @param array $session_data associative array of session keys to be updated - * @param string $session_id optional session_id, defaults to current user's session_id - */ - public function update_session($session_data, $session_id = null) - { - global $db, $phpbb_dispatcher; - - $session_id = ($session_id) ? $session_id : $this->session_id; - - $sql = 'UPDATE ' . SESSIONS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $session_data) . " - WHERE session_id = '" . $db->sql_escape($session_id) . "'"; - $db->sql_query($sql); - - /** - * Event to send update session information to extension - * Read-only event - * - * @event core.update_session_after - * @var array session_data Associative array of session keys to be updated - * @var string session_id current user's session_id - * @since 3.1.6-RC1 - */ - $vars = array('session_data', 'session_id'); - extract($phpbb_dispatcher->trigger_event('core.update_session_after', compact($vars))); - } - - public function update_session_infos() - { - global $config, $db, $request; - - // No need to update if it's a new session. Informations are already inserted by session_create() - if (isset($this->data['session_created']) && $this->data['session_created']) - { - return; - } - - // Do not update the session page for ajax requests, so the view online still works as intended - $page_changed = $this->update_session_page && $this->data['session_page'] != $this->page['page'] && !$request->is_ajax(); - - // Only update session DB a minute or so after last update or if page changes - if ($this->time_now - (isset($this->data['session_time']) ? $this->data['session_time'] : 0) > 60 || $page_changed) - { - $sql_ary = array('session_time' => $this->time_now); - - if ($page_changed) - { - $sql_ary['session_page'] = substr($this->page['page'], 0, 199); - $sql_ary['session_forum_id'] = $this->page['forum']; - } - - $db->sql_return_on_error(true); - - $this->update_session($sql_ary); - - $db->sql_return_on_error(false); - - $this->data = array_merge($this->data, $sql_ary); - - if ($this->data['user_id'] != ANONYMOUS && isset($config['new_member_post_limit']) && $this->data['user_new'] && $config['new_member_post_limit'] <= $this->data['user_posts']) - { - $this->leave_newly_registered(); - } - } - } -} diff --git a/install/update/old/phpbb/template/asset.php b/install/update/old/phpbb/template/asset.php deleted file mode 100644 index cb00f16..0000000 --- a/install/update/old/phpbb/template/asset.php +++ /dev/null @@ -1,210 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\template; - -class asset -{ - protected $components = array(); - - /** @var \phpbb\path_helper **/ - protected $path_helper; - - /** @var \phpbb\filesystem\filesystem */ - protected $filesystem; - - /** - * Constructor - * - * @param string $url URL - * @param \phpbb\path_helper $path_helper Path helper object - * @param \phpbb\filesystem\filesystem $filesystem - */ - public function __construct($url, \phpbb\path_helper $path_helper, \phpbb\filesystem\filesystem $filesystem) - { - $this->path_helper = $path_helper; - $this->filesystem = $filesystem; - - $this->set_url($url); - } - - /** - * Set URL - * - * @param string $url URL - */ - public function set_url($url) - { - if (version_compare(PHP_VERSION, '5.4.7') < 0 && substr($url, 0, 2) === '//') - { - // Workaround for PHP 5.4.6 and older bug #62844 - add fake scheme and then remove it - $this->components = parse_url('http:' . $url); - $this->components['scheme'] = ''; - return; - } - $this->components = parse_url($url); - } - - /** - * Convert URL components into string - * - * @param array $components URL components - * @return string URL - */ - protected function join_url($components) - { - $path = ''; - if (isset($components['scheme'])) - { - $path = $components['scheme'] === '' ? '//' : $components['scheme'] . '://'; - } - - if (isset($components['user']) || isset($components['pass'])) - { - if ($path === '' && !isset($components['port'])) - { - $path = '//'; - } - $path .= $components['user']; - if (isset($components['pass'])) - { - $path .= ':' . $components['pass']; - } - $path .= '@'; - } - - if (isset($components['host'])) - { - if ($path === '' && !isset($components['port'])) - { - $path = '//'; - } - $path .= $components['host']; - if (isset($components['port'])) - { - $path .= ':' . $components['port']; - } - } - - if (isset($components['path'])) - { - $path .= $components['path']; - } - - if (isset($components['query'])) - { - $path .= '?' . $components['query']; - } - - if (isset($components['fragment'])) - { - $path .= '#' . $components['fragment']; - } - - return $path; - } - - /** - * Get URL - * - * @return string URL - */ - public function get_url() - { - return $this->path_helper->update_web_root_path($this->join_url($this->components)); - } - - /** - * Checks if URL is local and relative - * - * @return boolean True if URL is local and relative - */ - public function is_relative() - { - if (empty($this->components) || !isset($this->components['path'])) - { - // Invalid URL - return false; - } - return !isset($this->components['scheme']) && !isset($this->components['host']) && substr($this->components['path'], 0, 1) !== '/'; - } - - /** - * Get path component of current URL - * - * @return string Path - */ - public function get_path() - { - return isset($this->components['path']) ? $this->components['path'] : ''; - } - - /** - * Set path component - * - * @param string $path Path component - * @param boolean $urlencode If true, parts of path should be encoded with rawurlencode() - */ - public function set_path($path, $urlencode = false) - { - // Since 1.7.0 Twig returns the real path of the file. We need it to be relative. - $real_root_path = $this->filesystem->realpath($this->path_helper->get_phpbb_root_path()) . DIRECTORY_SEPARATOR; - - // If the asset is under the phpBB root path we need to remove its path and then prepend $phpbb_root_path - if ($real_root_path && substr($path . DIRECTORY_SEPARATOR, 0, strlen($real_root_path)) === $real_root_path) - { - $path = $this->path_helper->get_phpbb_root_path() . str_replace('\\', '/', substr($path, strlen($real_root_path))); - } - else - { - // Else we make the path relative to the current working directory - $real_root_path = $this->filesystem->realpath('.') . DIRECTORY_SEPARATOR; - if ($real_root_path && substr($path . DIRECTORY_SEPARATOR, 0, strlen($real_root_path)) === $real_root_path) - { - $path = str_replace('\\', '/', substr($path, strlen($real_root_path))); - } - } - - if ($urlencode) - { - $paths = explode('/', $path); - foreach ($paths as &$dir) - { - $dir = rawurlencode($dir); - } - $path = implode('/', $paths); - } - - $this->components['path'] = $path; - } - - /** - * Add assets_version parameter to URL. - * Parameter will not be added if assets_version already exists in URL - * - * @param string $version Version - */ - public function add_assets_version($version) - { - if (!isset($this->components['query'])) - { - $this->components['query'] = 'assets_version=' . $version; - return; - } - $query = $this->components['query']; - if (!preg_match('/(^|[&;])assets_version=/', $query)) - { - $this->components['query'] = $query . '&assets_version=' . $version; - } - } -} diff --git a/install/update/old/phpbb/template/context.php b/install/update/old/phpbb/template/context.php deleted file mode 100644 index 202e29c..0000000 --- a/install/update/old/phpbb/template/context.php +++ /dev/null @@ -1,631 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\template; - -/** -* Stores variables assigned to template. -*/ -class context -{ - /** - * variable that holds all the data we'll be substituting into - * the compiled templates. Takes form: - * --> $this->tpldata[block][iteration#][child][iteration#][child2][iteration#][variablename] == value - * if it's a root-level variable, it'll be like this: - * --> $this->tpldata[.][0][varname] == value - * - * @var array - */ - private $tpldata = array('.' => array(0 => array())); - - /** - * @var array Reference to template->tpldata['.'][0] - */ - private $rootref; - - /** - * @var bool - */ - private $num_rows_is_set; - - public function __construct() - { - $this->clear(); - } - - /** - * Clears template data set. - */ - public function clear() - { - $this->tpldata = array('.' => array(0 => array())); - $this->rootref = &$this->tpldata['.'][0]; - $this->num_rows_is_set = false; - } - - /** - * Assign a single scalar value to a single key. - * - * Value can be a string, an integer or a boolean. - * - * @param string $varname Variable name - * @param string $varval Value to assign to variable - * @return true - */ - public function assign_var($varname, $varval) - { - $this->rootref[$varname] = $varval; - - return true; - } - - /** - * Append text to the string value stored in a key. - * - * Text is appended using the string concatenation operator (.). - * - * @param string $varname Variable name - * @param string $varval Value to append to variable - * @return true - */ - public function append_var($varname, $varval) - { - $this->rootref[$varname] = (isset($this->rootref[$varname]) ? $this->rootref[$varname] : '') . $varval; - - return true; - } - - /** - * Retreive a single scalar value from a single key. - * - * @param string $varname Variable name - * @return mixed Variable value, or null if not set - */ - public function retrieve_var($varname) - { - return isset($this->rootref[$varname]) ? $this->rootref[$varname] : null; - } - - /** - * Returns a reference to template data array. - * - * This function is public so that template renderer may invoke it. - * Users should alter template variables via functions in \phpbb\template\template. - * - * Note: modifying returned array will affect data stored in the context. - * - * @return array template data - */ - public function &get_data_ref() - { - // returning a reference directly is not - // something php is capable of doing - $ref = &$this->tpldata; - - if (!$this->num_rows_is_set) - { - /* - * We do not set S_NUM_ROWS while adding a row, to reduce the complexity - * If we would set it on adding, each subsequent adding would cause - * n modifications, resulting in a O(n!) complexity, rather then O(n) - */ - foreach ($ref as $loop_name => &$loop_data) - { - if ($loop_name === '.') - { - continue; - } - - $this->set_num_rows($loop_data); - } - $this->num_rows_is_set = true; - } - - return $ref; - } - - /** - * Set S_NUM_ROWS for each row in this template block - * - * @param array $loop_data - */ - protected function set_num_rows(&$loop_data) - { - $s_num_rows = count($loop_data); - foreach ($loop_data as &$mod_block) - { - foreach ($mod_block as $sub_block_name => &$sub_block) - { - // If the key name is lowercase and the data is an array, - // it could be a template loop. So we set the S_NUM_ROWS there - // aswell. - if ($sub_block_name === strtolower($sub_block_name) && is_array($sub_block)) - { - $this->set_num_rows($sub_block); - } - } - - // Check whether we are inside a block before setting the variable - if (isset($mod_block['S_BLOCK_NAME'])) - { - $mod_block['S_NUM_ROWS'] = $s_num_rows; - } - } - } - - /** - * Returns a reference to template root scope. - * - * This function is public so that template renderer may invoke it. - * Users should not need to invoke this function. - * - * Note: modifying returned array will affect data stored in the context. - * - * @return array template data - */ - public function &get_root_ref() - { - // rootref is already a reference - return $this->rootref; - } - - /** - * Assign key variable pairs from an array to a specified block - * - * @param string $blockname Name of block to assign $vararray to - * @param array $vararray A hash of variable name => value pairs - * @return true - */ - public function assign_block_vars($blockname, array $vararray) - { - $this->num_rows_is_set = false; - - // For nested block, $blockcount > 0, for top-level block, $blockcount == 0 - $blocks = explode('.', $blockname); - $blockcount = count($blocks) - 1; - - $block = &$this->tpldata; - for ($i = 0; $i < $blockcount; $i++) - { - $pos = strpos($blocks[$i], '['); - $name = ($pos !== false) ? substr($blocks[$i], 0, $pos) : $blocks[$i]; - $block = &$block[$name]; - $block_count = empty($block) ? 0 : count($block) - 1; - $index = (!$pos || strpos($blocks[$i], '[]') === $pos) ? $block_count : (min((int) substr($blocks[$i], $pos + 1, -1), $block_count)); - $block = &$block[$index]; - } - - // $block = &$block[$blocks[$i]]; // Do not traverse the last block as it might be empty - $name = $blocks[$i]; - - // Assign S_ROW_COUNT and S_ROW_NUM - $s_row_count = isset($block[$name]) ? count($block[$name]) : 0; - $vararray['S_ROW_COUNT'] = $vararray['S_ROW_NUM'] = $s_row_count; - - // Assign S_FIRST_ROW - if (!$s_row_count) - { - $vararray['S_FIRST_ROW'] = true; - } - - // Assign S_BLOCK_NAME - $vararray['S_BLOCK_NAME'] = $name; - - // Now the tricky part, we always assign S_LAST_ROW and remove the entry before - // This is much more clever than going through the complete template data on display (phew) - $vararray['S_LAST_ROW'] = true; - if ($s_row_count > 0) - { - unset($block[$name][($s_row_count - 1)]['S_LAST_ROW']); - } - - // Now we add the block that we're actually assigning to. - // We're adding a new iteration to this block with the given - // variable assignments. - $block[$name][] = $vararray; - - return true; - } - - /** - * Assign key variable pairs from an array to a whole specified block loop - * - * @param string $blockname Name of block to assign $block_vars_array to - * @param array $block_vars_array An array of hashes of variable name => value pairs - * @return true - */ - public function assign_block_vars_array($blockname, array $block_vars_array) - { - foreach ($block_vars_array as $vararray) - { - $this->assign_block_vars($blockname, $vararray); - } - - return true; - } - - /** - * Retrieve key variable pairs from the specified block - * - * @param string $blockname Name of block to retrieve $vararray from - * @param array $vararray An array of variable names, empty array retrieves all vars - * @return array of hashes with variable name as key and retrieved value or null as value - */ - public function retrieve_block_vars($blockname, array $vararray) - { - // For nested block, $blockcount > 0, for top-level block, $blockcount == 0 - $blocks = explode('.', $blockname); - $blockcount = count($blocks) - 1; - - $block = $this->tpldata; - for ($i = 0; $i <= $blockcount; $i++) - { - if (($pos = strpos($blocks[$i], '[')) !== false) - { - $name = substr($blocks[$i], 0, $pos); - - if (empty($block[$name])) - { - return array(); - } - - if (strpos($blocks[$i], '[]') === $pos) - { - $index = count($block[$name]) - 1; - } - else - { - $index = min((int) substr($blocks[$i], $pos + 1, -1), count($block[$name]) - 1); - } - } - else - { - $name = $blocks[$i]; - if (empty($block[$name])) - { - return array(); - } - - $index = count($block[$name]) - 1; - } - $block = $block[$name]; - $block = $block[$index]; - } - - $result = array(); - if ($vararray === array()) - { - // The calculated vars that depend on the block position are excluded from the complete block returned results - $excluded_vars = array('S_FIRST_ROW', 'S_LAST_ROW', 'S_BLOCK_NAME', 'S_NUM_ROWS', 'S_ROW_COUNT', 'S_ROW_NUM'); - - foreach ($block as $varname => $varvalue) - { - if ($varname === strtoupper($varname) && !is_array($varvalue) && !in_array($varname, $excluded_vars)) - { - $result[$varname] = $varvalue; - } - } - } - else - { - foreach ($vararray as $varname) - { - $result[$varname] = isset($block[$varname]) ? $block[$varname] : null; - } - } - return $result; - } - - /** - * Find the index for a specified key in the innermost specified block - * - * @param string $blockname the blockname, for example 'loop' - * @param mixed $key Key to search for - * - * array: KEY => VALUE [the key/value pair to search for within the loop to determine the correct position] - * - * int: Position [the position to search for] - * - * If key is false the position is set to 0 - * If key is true the position is set to the last entry - * - * @return mixed false if not found, index position otherwise; be sure to test with === - */ - public function find_key_index($blockname, $key) - { - // For nested block, $blockcount > 0, for top-level block, $blockcount == 0 - $blocks = explode('.', $blockname); - $blockcount = count($blocks) - 1; - - $block = $this->tpldata; - for ($i = 0; $i < $blockcount; $i++) - { - $pos = strpos($blocks[$i], '['); - $name = ($pos !== false) ? substr($blocks[$i], 0, $pos) : $blocks[$i]; - - if (!isset($block[$name])) - { - return false; - } - - $index = (!$pos || strpos($blocks[$i], '[]') === $pos) ? (count($block[$name]) - 1) : (min((int) substr($blocks[$i], $pos + 1, -1), count($block[$name]) - 1)); - - if (!isset($block[$name][$index])) - { - return false; - } - $block = $block[$name][$index]; - } - - if (!isset($block[$blocks[$i]])) - { - return false; - } - $block = $block[$blocks[$i]]; // Traverse the last block - - // Change key to zero (change first position) if false and to last position if true - if (is_bool($key)) - { - return (!$key) ? 0 : count($block) - 1; - } - - // Get correct position if array given - if (is_array($key)) - { - // Search array to get correct position - list($search_key, $search_value) = @each($key); - foreach ($block as $i => $val_ary) - { - if ($val_ary[$search_key] === $search_value) - { - return $i; - } - } - } - - return (is_int($key) && ((0 <= $key) && ($key < count($block)))) ? $key : false; - } - - /** - * Change already assigned key variable pair (one-dimensional - single loop entry) - * - * An example of how to use this function: - * {@example alter_block_array.php} - * - * @param string $blockname the blockname, for example 'loop' - * @param array $vararray the var array to insert/add or merge - * @param mixed $key Key to search for - * - * array: KEY => VALUE [the key/value pair to search for within the loop to determine the correct position] - * - * int: Position [the position to change or insert at directly given] - * - * If key is false the position is set to 0 - * If key is true the position is set to the last entry - * - * @param string $mode Mode to execute (valid modes are 'insert', 'change' and 'delete') - * - * If insert, the vararray is inserted at the given position (position counting from zero). - * If change, the current block gets merged with the vararray (resulting in new key/value pairs be added and existing keys be replaced by the new \value). - * If delete, the vararray is ignored, and the block at the given position (counting from zero) is removed. - * - * Since counting begins by zero, inserting at the last position will result in this array: array(vararray, last positioned array) - * and inserting at position 1 will result in this array: array(first positioned array, vararray, following vars) - * - * @return bool false on error, true on success - */ - public function alter_block_array($blockname, array $vararray, $key = false, $mode = 'insert') - { - $this->num_rows_is_set = false; - - // For nested block, $blockcount > 0, for top-level block, $blockcount == 0 - $blocks = explode('.', $blockname); - $blockcount = count($blocks) - 1; - - $block = &$this->tpldata; - for ($i = 0; $i < $blockcount; $i++) - { - if (($pos = strpos($blocks[$i], '[')) !== false) - { - $name = substr($blocks[$i], 0, $pos); - - if (strpos($blocks[$i], '[]') === $pos) - { - $index = count($block[$name]) - 1; - } - else - { - $index = min((int) substr($blocks[$i], $pos + 1, -1), count($block[$name]) - 1); - } - } - else - { - $name = $blocks[$i]; - $index = count($block[$name]) - 1; - } - $block = &$block[$name]; - $block = &$block[$index]; - } - $name = $blocks[$i]; - - // If last block does not exist and we are inserting, and not searching for key, we create it empty; otherwise, nothing to do - if (!isset($block[$name])) - { - if ($mode != 'insert' || is_array($key)) - { - return false; - } - $block[$name] = array(); - } - - $block = &$block[$name]; // Now we can traverse the last block - - // Change key to zero (change first position) if false and to last position if true - if ($key === false || $key === true) - { - $key = ($key === false) ? 0 : count($block); - } - - // Get correct position if array given - if (is_array($key)) - { - // Search array to get correct position - list($search_key, $search_value) = @each($key); - - $key = null; - foreach ($block as $i => $val_ary) - { - if ($val_ary[$search_key] === $search_value) - { - $key = $i; - break; - } - } - - // key/value pair not found - if ($key === null) - { - return false; - } - } - - // Insert Block - if ($mode == 'insert') - { - // Make sure we are not exceeding the last iteration - if ($key >= count($block)) - { - $key = count($block); - unset($block[($key - 1)]['S_LAST_ROW']); - $vararray['S_LAST_ROW'] = true; - } - if ($key <= 0) - { - $key = 0; - unset($block[0]['S_FIRST_ROW']); - $vararray['S_FIRST_ROW'] = true; - } - - // Assign S_BLOCK_NAME - $vararray['S_BLOCK_NAME'] = $name; - - // Re-position template blocks - for ($i = count($block); $i > $key; $i--) - { - $block[$i] = $block[$i-1]; - - $block[$i]['S_ROW_COUNT'] = $block[$i]['S_ROW_NUM'] = $i; - } - - // Insert vararray at given position - $block[$key] = $vararray; - $block[$key]['S_ROW_COUNT'] = $block[$key]['S_ROW_NUM'] = $key; - - return true; - } - - // Which block to change? - if ($mode == 'change') - { - // If key is out of bounds, do not change anything - if ($key > count($block) || $key < 0) - { - return false; - } - - if ($key == count($block)) - { - $key--; - } - - $block[$key] = array_merge($block[$key], $vararray); - - return true; - } - - // Delete Block - if ($mode == 'delete') - { - // If we are exceeding last iteration, do not delete anything - if ($key > count($block) || $key < 0) - { - return false; - } - - // If we are positioned at the end, we remove the last element - if ($key == count($block)) - { - $key--; - } - - // We are deleting the last element in the block, so remove the block - if (count($block) === 1) - { - $block = null; // unset($block); does not work on references - return true; - } - - // Re-position template blocks - for ($i = $key; $i < count($block)-1; $i++) - { - $block[$i] = $block[$i+1]; - $block[$i]['S_ROW_COUNT'] = $block[$i]['S_ROW_NUM'] = $i; - } - - // Remove the last element - unset($block[$i]); - - // Set first and last elements again, in case they were removed - $block[0]['S_FIRST_ROW'] = true; - $block[count($block)-1]['S_LAST_ROW'] = true; - - return true; - } - - return false; - } - - /** - * Reset/empty complete block - * - * @param string $blockname Name of block to destroy - * @return true - */ - public function destroy_block_vars($blockname) - { - $this->num_rows_is_set = false; - if (strpos($blockname, '.') !== false) - { - // Nested block. - $blocks = explode('.', $blockname); - $blockcount = count($blocks) - 1; - - $str = &$this->tpldata; - for ($i = 0; $i < $blockcount; $i++) - { - $str = &$str[$blocks[$i]]; - $str = &$str[count($str) - 1]; - } - - unset($str[$blocks[$blockcount]]); - } - else - { - // Top-level block. - unset($this->tpldata[$blockname]); - } - - return true; - } -} diff --git a/install/update/old/phpbb/template/template.php b/install/update/old/phpbb/template/template.php deleted file mode 100644 index df83d5b..0000000 --- a/install/update/old/phpbb/template/template.php +++ /dev/null @@ -1,224 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\template; - -interface template -{ - - /** - * Clear the cache - * - * @return \phpbb\template\template - */ - public function clear_cache(); - - /** - * Sets the template filenames for handles. - * - * @param array $filename_array Should be a hash of handle => filename pairs. - * @return \phpbb\template\template $this - */ - public function set_filenames(array $filename_array); - - /** - * Get the style tree of the style preferred by the current user - * - * @return array Style tree, most specific first - */ - public function get_user_style(); - - /** - * Set style location based on (current) user's chosen style. - * - * @param array $style_directories The directories to add style paths for - * E.g. array('ext/foo/bar/styles', 'styles') - * Default: array('styles') (phpBB's style directory) - * @return \phpbb\template\template $this - */ - public function set_style($style_directories = array('styles')); - - /** - * Set custom style location (able to use directory outside of phpBB). - * - * Note: Templates are still compiled to phpBB's cache directory. - * - * @param string|array $names Array of names or string of name of template(s) in inheritance tree order, used by extensions. - * @param string|array or string $paths Array of style paths, relative to current root directory - * @return \phpbb\template\template $this - */ - public function set_custom_style($names, $paths); - - /** - * Clears all variables and blocks assigned to this template. - * - * @return \phpbb\template\template $this - */ - public function destroy(); - - /** - * Reset/empty complete block - * - * @param string $blockname Name of block to destroy - * @return \phpbb\template\template $this - */ - public function destroy_block_vars($blockname); - - /** - * Display a template for provided handle. - * - * The template will be loaded and compiled, if necessary, first. - * - * This function calls hooks. - * - * @param string $handle Handle to display - * @return \phpbb\template\template $this - */ - public function display($handle); - - /** - * Display the handle and assign the output to a template variable - * or return the compiled result. - * - * @param string $handle Handle to operate on - * @param string $template_var Template variable to assign compiled handle to - * @param bool $return_content If true return compiled handle, otherwise assign to $template_var - * @return \phpbb\template\template|string if $return_content is true return string of the compiled handle, otherwise return $this - */ - public function assign_display($handle, $template_var = '', $return_content = true); - - /** - * Assign key variable pairs from an array - * - * @param array $vararray A hash of variable name => value pairs - * @return \phpbb\template\template $this - */ - public function assign_vars(array $vararray); - - /** - * Assign a single scalar value to a single key. - * - * Value can be a string, an integer or a boolean. - * - * @param string $varname Variable name - * @param string $varval Value to assign to variable - * @return \phpbb\template\template $this - */ - public function assign_var($varname, $varval); - - /** - * Append text to the string value stored in a key. - * - * Text is appended using the string concatenation operator (.). - * - * @param string $varname Variable name - * @param string $varval Value to append to variable - * @return \phpbb\template\template $this - */ - public function append_var($varname, $varval); - - /** - * Retrieve multiple template values - * - * @param array $vararray An array with variable names - * @return array A hash of variable name => value pairs (value is null if not set) - */ - public function retrieve_vars(array $vararray); - - /** - * Retreive a single scalar value from a single key. - * - * @param string $varname Variable name - * @return mixed Variable value, or null if not set - */ - public function retrieve_var($varname); - - /** - * Assign key variable pairs from an array to a specified block - * @param string $blockname Name of block to assign $vararray to - * @param array $vararray A hash of variable name => value pairs - * @return \phpbb\template\template $this - */ - public function assign_block_vars($blockname, array $vararray); - - /** - * Assign key variable pairs from an array to a whole specified block loop - * @param string $blockname Name of block to assign $block_vars_array to - * @param array $block_vars_array An array of hashes of variable name => value pairs - * @return \phpbb\template\template $this - */ - public function assign_block_vars_array($blockname, array $block_vars_array); - - /** - * Retrieve variable values from an specified block - * @param string $blockname Name of block to retrieve $vararray from - * @param array $vararray An array with variable names, empty array gets all vars - * @return array A hash of variable name => value pairs (value is null if not set) - */ - public function retrieve_block_vars($blockname, array $vararray); - - /** - * Change already assigned key variable pair (one-dimensional - single loop entry) - * - * An example of how to use this function: - * {@example alter_block_array.php} - * - * @param string $blockname the blockname, for example 'loop' - * @param array $vararray the var array to insert/add or merge - * @param mixed $key Key to search for - * - * array: KEY => VALUE [the key/value pair to search for within the loop to determine the correct position] - * - * int: Position [the position to change or insert at directly given] - * - * If key is false the position is set to 0 - * If key is true the position is set to the last entry - * - * @param string $mode Mode to execute (valid modes are 'insert', 'change' and 'delete') - * - * If insert, the vararray is inserted at the given position (position counting from zero). - * If change, the current block gets merged with the vararray (resulting in new \key/value pairs be added and existing keys be replaced by the new \value). - * If delete, the vararray is ignored, and the block at the given position (counting from zero) is removed. - * - * Since counting begins by zero, inserting at the last position will result in this array: array(vararray, last positioned array) - * and inserting at position 1 will result in this array: array(first positioned array, vararray, following vars) - * - * @return bool false on error, true on success - */ - public function alter_block_array($blockname, array $vararray, $key = false, $mode = 'insert'); - - /** - * Find the index for a specified key in the innermost specified block - * - * @param string $blockname the blockname, for example 'loop' - * @param mixed $key Key to search for - * - * array: KEY => VALUE [the key/value pair to search for within the loop to determine the correct position] - * - * int: Position [the position to search for] - * - * If key is false the position is set to 0 - * If key is true the position is set to the last entry - * - * @return mixed false if not found, index position otherwise; be sure to test with === - */ - public function find_key_index($blockname, $key); - - /** - * Get path to template for handle (required for BBCode parser) - * - * @param string $handle Handle to retrieve the source file - * @return string - */ - public function get_source_file_for_handle($handle); -} diff --git a/install/update/old/phpbb/template/twig/extension.php b/install/update/old/phpbb/template/twig/extension.php deleted file mode 100644 index f6f8e03..0000000 --- a/install/update/old/phpbb/template/twig/extension.php +++ /dev/null @@ -1,185 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\template\twig; - -class extension extends \Twig_Extension -{ - /** @var \phpbb\template\context */ - protected $context; - - /** @var \phpbb\language\language */ - protected $language; - - /** - * Constructor - * - * @param \phpbb\template\context $context - * @param \phpbb\language\language $language - * @return \phpbb\template\twig\extension - */ - public function __construct(\phpbb\template\context $context, $language) - { - $this->context = $context; - $this->language = $language; - } - - /** - * Get the name of this extension - * - * @return string - */ - public function getName() - { - return 'phpbb'; - } - - /** - * Returns the token parser instance to add to the existing list. - * - * @return array An array of Twig_TokenParser instances - */ - public function getTokenParsers() - { - return array( - new \phpbb\template\twig\tokenparser\defineparser, - new \phpbb\template\twig\tokenparser\includeparser, - new \phpbb\template\twig\tokenparser\includejs, - new \phpbb\template\twig\tokenparser\includecss, - new \phpbb\template\twig\tokenparser\event, - new \phpbb\template\twig\tokenparser\includephp, - new \phpbb\template\twig\tokenparser\php, - ); - } - - /** - * Returns a list of filters to add to the existing list. - * - * @return array An array of filters - */ - public function getFilters() - { - return array( - new \Twig_SimpleFilter('subset', array($this, 'loop_subset'), array('needs_environment' => true)), - // @deprecated 3.2.0 Uses twig's JS escape method instead of addslashes - new \Twig_SimpleFilter('addslashes', 'addslashes'), - ); - } - - /** - * Returns a list of global functions to add to the existing list. - * - * @return array An array of global functions - */ - public function getFunctions() - { - return array( - new \Twig_SimpleFunction('lang', array($this, 'lang')), - ); - } - - /** - * Returns a list of operators to add to the existing list. - * - * @return array An array of operators - */ - public function getOperators() - { - return array( - array( - '!' => array('precedence' => 50, 'class' => 'Twig_Node_Expression_Unary_Not'), - ), - array( - // precedence settings are copied from similar operators in Twig core extension - '||' => array('precedence' => 10, 'class' => 'Twig_Node_Expression_Binary_Or', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT), - '&&' => array('precedence' => 15, 'class' => 'Twig_Node_Expression_Binary_And', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT), - - 'eq' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Equal', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT), - - 'ne' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_NotEqual', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT), - 'neq' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_NotEqual', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT), - '<>' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_NotEqual', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT), - - '===' => array('precedence' => 20, 'class' => '\phpbb\template\twig\node\expression\binary\equalequal', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT), - '!==' => array('precedence' => 20, 'class' => '\phpbb\template\twig\node\expression\binary\notequalequal', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT), - - 'gt' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Greater', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT), - 'gte' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_GreaterEqual', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT), - 'ge' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_GreaterEqual', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT), - 'lt' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Less', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT), - 'lte' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_LessEqual', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT), - 'le' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_LessEqual', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT), - - 'mod' => array('precedence' => 60, 'class' => 'Twig_Node_Expression_Binary_Mod', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT), - ), - ); - } - - /** - * Grabs a subset of a loop - * - * @param \Twig_Environment $env A Twig_Environment instance - * @param mixed $item A variable - * @param integer $start Start of the subset - * @param integer $end End of the subset - * @param Boolean $preserveKeys Whether to preserve key or not (when the input is an array) - * - * @return mixed The sliced variable - */ - function loop_subset(\Twig_Environment $env, $item, $start, $end = null, $preserveKeys = false) - { - // We do almost the same thing as Twig's slice (array_slice), except when $end is positive - if ($end >= 1) - { - // When end is > 1, subset will end on the last item in an array with the specified $end - // This is different from slice in that it is the number we end on rather than the number - // of items to grab (length) - - // Start must always be the actual starting number for this calculation (not negative) - $start = ($start < 0) ? count($item) + $start : $start; - $end = $end - $start; - } - - // We always include the last element (this was the past design) - $end = ($end == -1 || $end === null) ? null : $end + 1; - - return twig_slice($env, $item, $start, $end, $preserveKeys); - } - - /** - * Get output for a language variable (L_FOO, LA_FOO) - * - * This function checks to see if the language var was outputted to $context - * (e.g. in the ACP, L_TITLE) - * If not, we return the result of $user->lang() - * - * @return string - */ - function lang() - { - $args = func_get_args(); - $key = $args[0]; - - $context_vars = $this->context->get_root_ref(); - - if (is_string($key) && isset($context_vars['L_' . $key])) - { - return $context_vars['L_' . $key]; - } - - // LA_ is transformed into lang(\'$1\')|escape('js'), so we should not - // need to check for it - - return call_user_func_array(array($this->language, 'lang'), $args); - } -} diff --git a/install/update/old/phpbb/template/twig/lexer.php b/install/update/old/phpbb/template/twig/lexer.php deleted file mode 100644 index d0bcfa6..0000000 --- a/install/update/old/phpbb/template/twig/lexer.php +++ /dev/null @@ -1,368 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\template\twig; - -class lexer extends \Twig_Lexer -{ - public function set_environment(\Twig_Environment $env) - { - $this->env = $env; - } - - public function tokenize($code, $filename = null) - { - // Handle \Twig_Source format input - if ($code instanceof \Twig_Source) - { - $source = $code; - $code = $source->getCode(); - $filename = $source->getName(); - } - - // Our phpBB tags - // Commented out tokens are handled separately from the main replace - $phpbb_tags = array( - /*'BEGIN', - 'BEGINELSE', - 'END', - 'IF', - 'ELSE', - 'ELSEIF', - 'ENDIF', - 'DEFINE', - 'UNDEFINE',*/ - 'ENDDEFINE', - 'INCLUDE', - 'INCLUDEPHP', - 'INCLUDEJS', - 'INCLUDECSS', - 'PHP', - 'ENDPHP', - 'EVENT', - ); - - // Twig tag masks - $twig_tags = array( - 'autoescape', - 'endautoescape', - 'if', - 'elseif', - 'else', - 'endif', - 'block', - 'endblock', - 'use', - 'extends', - 'embed', - 'filter', - 'endfilter', - 'flush', - 'for', - 'endfor', - 'macro', - 'endmacro', - 'import', - 'from', - 'sandbox', - 'endsandbox', - 'set', - 'endset', - 'spaceless', - 'endspaceless', - 'verbatim', - 'endverbatim', - ); - - // Fix tokens that may have inline variables (e.g. with Twig style, {% TOKEN %} - // This also strips outer parenthesis, becomes - $code = preg_replace('##', '{% $1 $2 %}', $code); - - // Replace all of our twig masks with Twig code (e.g. with {% block $1 %}) - $code = $this->replace_twig_tag_masks($code, $twig_tags); - - // Replace all of our language variables, {L_VARNAME}, with Twig style, {{ lang('NAME') }} - // Appends any filters after lang() - $code = preg_replace('#{L_([a-zA-Z0-9_\.]+)(\|[^}]+?)?}#', '{{ lang(\'$1\')$2 }}', $code); - - // Replace all of our escaped language variables, {LA_VARNAME}, with Twig style, {{ lang('NAME')|escape('js') }} - // Appends any filters after lang(), but before escape('js') - $code = preg_replace('#{LA_([a-zA-Z0-9_\.]+)(\|[^}]+?)?}#', '{{ lang(\'$1\')$2|escape(\'js\') }}', $code); - - // Replace all of our variables, {VARNAME}, with Twig style, {{ VARNAME }} - // Appends any filters - $code = preg_replace('#{([a-zA-Z0-9_\.]+)(\|[^}]+?)?}#', '{{ $1$2 }}', $code); - - // Tokenize \Twig_Source instance - return parent::tokenize(new \Twig_Source($code, $filename)); - } - - /** - * Strip surrounding quotes - * - * First step to fix tokens that may have inline variables - * E.g. #', '', $code); - } - - /** - * Fix tokens that may have inline variables - * - * Second step to fix tokens that may have inline variables - * E.g. "; - }; - - return preg_replace_callback('##', $callback, $code); - } - - /** - * Add surrounding quotes - * - * Last step to fix tokens that may have inline variables - * E.g. #', '', $code); - } - - /** - * Fix begin tokens (convert our BEGIN to Twig for) - * - * Not meant to be used outside of this context, public because the anonymous function calls this - * - * @param string $code - * @param array $parent_nodes (used in recursion) - * @return string - */ - public function fix_begin_tokens($code, $parent_nodes = array()) - { - // PHP 5.3 cannot use $this in an anonymous function, so use this as a work-around - $parent_class = $this; - $callback = function ($matches) use ($parent_class, $parent_nodes) - { - $hard_parents = explode('.', $matches[1]); - array_pop($hard_parents); // ends with . - if ($hard_parents) - { - $parent_nodes = array_merge($hard_parents, $parent_nodes); - } - - $name = $matches[2]; - $subset = trim(substr($matches[3], 1, -1)); // Remove parenthesis - $body = $matches[4]; - - // Replace - $body = str_replace('', '{% else %}', $body); - - // Is the designer wanting to call another loop in a loop? - // - // - // - // - // 'loop2' is actually on the same nesting level as 'loop' you assign - // variables to it with template->assign_block_vars('loop2', array(...)) - if (strpos($name, '!') === 0) - { - // Count the number if ! occurrences - $count = substr_count($name, '!'); - for ($i = 0; $i < $count; $i++) - { - array_pop($parent_nodes); - $name = substr($name, 1); - } - } - - // Remove all parent nodes, e.g. foo, bar from foo.bar.foobar.VAR - foreach ($parent_nodes as $node) - { - $body = preg_replace('#([^a-zA-Z0-9_])' . $node . '\.([a-zA-Z0-9_]+)\.#', '$1$2.', $body); - } - - // Add current node to list of parent nodes for child nodes - $parent_nodes[] = $name; - - // Recursive...fix any child nodes - $body = $parent_class->fix_begin_tokens($body, $parent_nodes); - - // Need the parent variable name - array_pop($parent_nodes); - $parent = (!empty($parent_nodes)) ? end($parent_nodes) . '.' : ''; - - if ($subset !== '') - { - $subset = '|subset(' . $subset . ')'; - } - - $parent = ($parent) ?: 'loops.'; - // Turn into a Twig for loop - return "{% for {$name} in {$parent}{$name}{$subset} %}{$body}{% endfor %}"; - }; - - return preg_replace_callback('#(.+?)#s', $callback, $code); - } - - /** - * Fix IF statements - * - * @param string $code - * @return string - */ - protected function fix_if_tokens($code) - { - // Replace ELSE IF with ELSEIF - $code = preg_replace('##', '', $code); - - // Replace our "div by" with Twig's divisibleby (Twig does not like test names with spaces) - $code = preg_replace('# div by ([0-9]+)#', ' divisibleby($1)', $code); - - $callback = function($matches) - { - $inner = $matches[2]; - // Replace $TEST with definition.TEST - $inner = preg_replace('#(\s\(*!?)\$([a-zA-Z_0-9]+)#', '$1definition.$2', $inner); - - // Replace .foo with loops.foo|length - $inner = preg_replace('#(\s\(*!?)\.([a-zA-Z_0-9]+)([^a-zA-Z_0-9\.])#', '$1loops.$2|length$3', $inner); - - // Replace .foo.bar with foo.bar|length - $inner = preg_replace('#(\s\(*!?)\.([a-zA-Z_0-9\.]+)([^a-zA-Z_0-9\.])#', '$1$2|length$3', $inner); - - return ""; - }; - - return preg_replace_callback('##', $callback, $code); - } - - /** - * Fix DEFINE statements and {$VARNAME} variables - * - * @param string $code - * @return string - */ - protected function fix_define_tokens($code) - { - /** - * Changing $VARNAME to definition.varname because set is only local - * context (e.g. DEFINE $TEST will only make $TEST available in current - * template and any child templates, but not any parent templates). - * - * DEFINE handles setting it properly to definition in its node, but the - * variables reading FROM it need to be altered to definition.VARNAME - * - * Setting up definition as a class in the array passed to Twig - * ($context) makes set definition.TEST available in the global context - */ - - // Replace #', '{% DEFINE $1 %}', $code); - - // Changing UNDEFINE NAME to DEFINE NAME = null to save from creating an extra token parser/node - $code = preg_replace('##', '{% DEFINE $1= null %}', $code); - - // Replace all of our variables, {$VARNAME}, with Twig style, {{ definition.VARNAME }} - $code = preg_replace('#{\$([a-zA-Z0-9_\.]+)}#', '{{ definition.$1 }}', $code); - - // Replace all of our variables, ~ $VARNAME ~, with Twig style, ~ definition.VARNAME ~ - $code = preg_replace('#~ \$([a-zA-Z0-9_\.]+) ~#', '~ definition.$1 ~', $code); - - return $code; - } - - /** - * Replace Twig tag masks with Twig tag calls - * - * E.g. with {% block foo %} - * - * @param string $code - * @param array $twig_tags All tags we want to create a mask for - * @return string - */ - protected function replace_twig_tag_masks($code, $twig_tags) - { - $callback = function ($matches) - { - $matches[1] = strtolower($matches[1]); - - return "{% {$matches[1]}{$matches[2]}%}"; - }; - - foreach ($twig_tags as &$tag) - { - $tag = strtoupper($tag); - } - - // twig_tags is an array of the twig tags, which are all lowercase, but we use all uppercase tags - $code = preg_replace_callback('##',$callback, $code); - - return $code; - } -} diff --git a/install/update/old/phpbb/template/twig/loader.php b/install/update/old/phpbb/template/twig/loader.php deleted file mode 100644 index c13e3ee..0000000 --- a/install/update/old/phpbb/template/twig/loader.php +++ /dev/null @@ -1,176 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\template\twig; - -/** -* Twig Template loader -*/ -class loader extends \Twig_Loader_Filesystem -{ - protected $safe_directories = array(); - - /** - * @var \phpbb\filesystem\filesystem_interface - */ - protected $filesystem; - - /** - * Constructor - * - * @param \phpbb\filesystem\filesystem_interface $filesystem - * @param string|array $paths - */ - public function __construct(\phpbb\filesystem\filesystem_interface $filesystem, $paths = array()) - { - $this->filesystem = $filesystem; - - parent::__construct($paths, $this->filesystem->realpath(dirname(__FILE__))); - } - - /** - * Set safe directories - * - * @param array $directories Array of directories that are safe (empty to clear) - * @return \Twig_Loader_Filesystem - */ - public function setSafeDirectories($directories = array()) - { - $this->safe_directories = array(); - - if (!empty($directories)) - { - foreach ($directories as $directory) - { - $this->addSafeDirectory($directory); - } - } - - return $this; - } - - /** - * Add safe directory - * - * @param string $directory Directory that should be added - * @return \Twig_Loader_Filesystem - */ - public function addSafeDirectory($directory) - { - $directory = $this->filesystem->realpath($directory); - - if ($directory !== false) - { - $this->safe_directories[] = $directory; - } - - return $this; - } - - /** - * Get current safe directories - * - * @return array - */ - public function getSafeDirectories() - { - return $this->safe_directories; - } - - /** - * Override for parent::validateName() - * - * This is done because we added support for safe directories, and when Twig - * findTemplate() is called, validateName() is called first, which would - * always throw an exception if the file is outside of the configured - * template directories. - */ - protected function validateName($name) - { - return; - } - - /** - * Adds a realpath call to fix a BC break in Twig 1.26 (https://github.com/twigphp/Twig/issues/2145) - * - * {@inheritdoc} - */ - public function addPath($path, $namespace = self::MAIN_NAMESPACE) - { - return parent::addPath($this->filesystem->realpath($path), $namespace); - } - - /** - * Find the template - * - * Override for Twig_Loader_Filesystem::findTemplate to add support - * for loading from safe directories. - */ - protected function findTemplate($name) - { - $name = (string) $name; - - // normalize name - $name = preg_replace('#/{2,}#', '/', strtr($name, '\\', '/')); - - // If this is in the cache we can skip the entire process below - // as it should have already been validated - if (isset($this->cache[$name])) - { - return $this->cache[$name]; - } - - // First, find the template name. The override above of validateName - // causes the validateName process to be skipped for this call - $file = parent::findTemplate($name); - - try - { - // Try validating the name (which may throw an exception) - parent::validateName($name); - } - catch (\Twig_Error_Loader $e) - { - if (strpos($e->getRawMessage(), 'Looks like you try to load a template outside configured directories') === 0) - { - // Ok, so outside of the configured template directories, we - // can now check if we're within a "safe" directory - - // Find the real path of the directory the file is in - $directory = $this->filesystem->realpath(dirname($file)); - - if ($directory === false) - { - // Some sort of error finding the actual path, must throw the exception - throw $e; - } - - foreach ($this->safe_directories as $safe_directory) - { - if (strpos($directory, $safe_directory) === 0) - { - // The directory being loaded is below a directory - // that is "safe". We're good to load it! - return $file; - } - } - } - - // Not within any safe directories - throw $e; - } - - // No exception from validateName, safe to load. - return $file; - } -} diff --git a/install/update/old/phpbb/template/twig/node/definenode.php b/install/update/old/phpbb/template/twig/node/definenode.php deleted file mode 100644 index ddbd151..0000000 --- a/install/update/old/phpbb/template/twig/node/definenode.php +++ /dev/null @@ -1,57 +0,0 @@ - -* @copyright Portions (c) 2009 Fabien Potencier, Armin Ronacher -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\template\twig\node; - -class definenode extends \Twig_Node -{ - public function __construct($capture, \Twig_NodeInterface $name, \Twig_NodeInterface $value, $lineno, $tag = null) - { - parent::__construct(array('name' => $name, 'value' => $value), array('capture' => $capture, 'safe' => false), $lineno, $tag); - } - - /** - * Compiles the node to PHP. - * - * @param \Twig_Compiler A Twig_Compiler instance - */ - public function compile(\Twig_Compiler $compiler) - { - $compiler->addDebugInfo($this); - - if ($this->getAttribute('capture')) - { - $compiler - ->write("ob_start();\n") - ->subcompile($this->getNode('value')) - ; - - $compiler->write("\$value = ('' === \$value = ob_get_clean()) ? '' : new \Twig_Markup(\$value, \$this->env->getCharset());\n"); - } - else - { - $compiler - ->write("\$value = ") - ->subcompile($this->getNode('value')) - ->raw(";\n") - ; - } - - $compiler - ->write("\$context['definition']->set('") - ->raw($this->getNode('name')->getAttribute('name')) - ->raw("', \$value);\n") - ; - } -} diff --git a/install/update/old/phpbb/template/twig/node/includeasset.php b/install/update/old/phpbb/template/twig/node/includeasset.php deleted file mode 100644 index 12034b7..0000000 --- a/install/update/old/phpbb/template/twig/node/includeasset.php +++ /dev/null @@ -1,71 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\template\twig\node; - -abstract class includeasset extends \Twig_Node -{ - /** @var \Twig_Environment */ - protected $environment; - - public function __construct(\Twig_Node_Expression $expr, \phpbb\template\twig\environment $environment, $lineno, $tag = null) - { - $this->environment = $environment; - - parent::__construct(array('expr' => $expr), array(), $lineno, $tag); - } - /** - * Compiles the node to PHP. - * - * @param \Twig_Compiler A Twig_Compiler instance - */ - public function compile(\Twig_Compiler $compiler) - { - $compiler->addDebugInfo($this); - - $config = $this->environment->get_phpbb_config(); - - $compiler - ->write("\$asset_file = ") - ->subcompile($this->getNode('expr')) - ->raw(";\n") - ->write("\$asset = new \phpbb\\template\\asset(\$asset_file, \$this->getEnvironment()->get_path_helper(), \$this->getEnvironment()->get_filesystem());\n") - ->write("if (substr(\$asset_file, 0, 2) !== './' && \$asset->is_relative()) {\n") - ->indent() - ->write("\$asset_path = \$asset->get_path();") - ->write("\$local_file = \$this->getEnvironment()->get_phpbb_root_path() . \$asset_path;\n") - ->write("if (!file_exists(\$local_file)) {\n") - ->indent() - ->write("\$local_file = \$this->getEnvironment()->findTemplate(\$asset_path);\n") - ->write("\$asset->set_path(\$local_file, true);\n") - ->outdent() - ->write("}\n") - ->outdent() - ->write("}\n") - ->write("\n") - ->write("if (\$asset->is_relative()) {\n") - ->indent() - ->write("\$asset->add_assets_version('{$config['assets_version']}');\n") - ->outdent() - ->write("}\n") - ->write("\$this->getEnvironment()->get_assets_bag()->add_{$this->get_setters_name()}(\$asset);") - ; - } - - /** - * Get the name of the assets bag setter - * - * @return string (e.g. 'script') - */ - abstract public function get_setters_name(); -} diff --git a/install/update/old/phpbb/template/twig/node/includephp.php b/install/update/old/phpbb/template/twig/node/includephp.php deleted file mode 100644 index 76182c2..0000000 --- a/install/update/old/phpbb/template/twig/node/includephp.php +++ /dev/null @@ -1,91 +0,0 @@ - -* Sections (c) 2009 Fabien Potencier, Armin Ronacher -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\template\twig\node; - -class includephp extends \Twig_Node -{ - /** @var \Twig_Environment */ - protected $environment; - - public function __construct(\Twig_Node_Expression $expr, \phpbb\template\twig\environment $environment, $lineno, $ignoreMissing = false, $tag = null) - { - $this->environment = $environment; - - parent::__construct(array('expr' => $expr), array('ignore_missing' => (Boolean) $ignoreMissing), $lineno, $tag); - } - - /** - * Compiles the node to PHP. - * - * @param \Twig_Compiler A Twig_Compiler instance - */ - public function compile(\Twig_Compiler $compiler) - { - $compiler->addDebugInfo($this); - - $config = $this->environment->get_phpbb_config(); - - if (!$config['tpl_allow_php']) - { - $compiler - ->write("// INCLUDEPHP Disabled\n") - ; - - return; - } - - if ($this->getAttribute('ignore_missing')) - { - $compiler - ->write("try {\n") - ->indent() - ; - } - - $compiler - ->write("\$location = ") - ->subcompile($this->getNode('expr')) - ->raw(";\n") - ->write("if (phpbb_is_absolute(\$location)) {\n") - ->indent() - // Absolute path specified - ->write("require(\$location);\n") - ->outdent() - ->write("} else if (file_exists(\$this->getEnvironment()->get_phpbb_root_path() . \$location)) {\n") - ->indent() - // PHP file relative to phpbb_root_path - ->write("require(\$this->getEnvironment()->get_phpbb_root_path() . \$location);\n") - ->outdent() - ->write("} else {\n") - ->indent() - // Local path (behaves like INCLUDE) - ->write("require(\$this->getEnvironment()->getLoader()->getCacheKey(\$location));\n") - ->outdent() - ->write("}\n") - ; - - if ($this->getAttribute('ignore_missing')) - { - $compiler - ->outdent() - ->write("} catch (\Twig_Error_Loader \$e) {\n") - ->indent() - ->write("// ignore missing template\n") - ->outdent() - ->write("}\n\n") - ; - } - } -} diff --git a/install/update/old/phpbb/template/twig/tokenparser/defineparser.php b/install/update/old/phpbb/template/twig/tokenparser/defineparser.php deleted file mode 100644 index b755836..0000000 --- a/install/update/old/phpbb/template/twig/tokenparser/defineparser.php +++ /dev/null @@ -1,76 +0,0 @@ - -* @copyright Portions (c) 2009 Fabien Potencier, Armin Ronacher -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\template\twig\tokenparser; - -class defineparser extends \Twig_TokenParser -{ - /** - * Parses a token and returns a node. - * - * @param \Twig_Token $token A Twig_Token instance - * - * @return \Twig_NodeInterface A Twig_NodeInterface instance - * @throws \Twig_Error_Syntax - * @throws \phpbb\template\twig\node\definenode - */ - public function parse(\Twig_Token $token) - { - $lineno = $token->getLine(); - $stream = $this->parser->getStream(); - $name = $this->parser->getExpressionParser()->parseExpression(); - - $capture = false; - if ($stream->test(\Twig_Token::OPERATOR_TYPE, '=')) - { - $stream->next(); - $value = $this->parser->getExpressionParser()->parseExpression(); - - if ($value instanceof \Twig_Node_Expression_Name) - { - // This would happen if someone improperly formed their DEFINE syntax - // e.g. - throw new \Twig_Error_Syntax('Invalid DEFINE', $token->getLine(), $this->parser->getFilename()); - } - - $stream->expect(\Twig_Token::BLOCK_END_TYPE); - } - else - { - $capture = true; - - $stream->expect(\Twig_Token::BLOCK_END_TYPE); - - $value = $this->parser->subparse(array($this, 'decideBlockEnd'), true); - $stream->expect(\Twig_Token::BLOCK_END_TYPE); - } - - return new \phpbb\template\twig\node\definenode($capture, $name, $value, $lineno, $this->getTag()); - } - - public function decideBlockEnd(\Twig_Token $token) - { - return $token->test('ENDDEFINE'); - } - - /** - * Gets the tag name associated with this token parser. - * - * @return string The tag name - */ - public function getTag() - { - return 'DEFINE'; - } -} diff --git a/install/update/old/phpbb/template/twig/tokenparser/event.php b/install/update/old/phpbb/template/twig/tokenparser/event.php deleted file mode 100644 index f73ef4a..0000000 --- a/install/update/old/phpbb/template/twig/tokenparser/event.php +++ /dev/null @@ -1,44 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\template\twig\tokenparser; - -class event extends \Twig_TokenParser -{ - /** - * Parses a token and returns a node. - * - * @param \Twig_Token $token A Twig_Token instance - * - * @return \Twig_NodeInterface A Twig_NodeInterface instance - */ - public function parse(\Twig_Token $token) - { - $expr = $this->parser->getExpressionParser()->parseExpression(); - - $stream = $this->parser->getStream(); - $stream->expect(\Twig_Token::BLOCK_END_TYPE); - - return new \phpbb\template\twig\node\event($expr, $this->parser->getEnvironment(), $token->getLine(), $this->getTag()); - } - - /** - * Gets the tag name associated with this token parser. - * - * @return string The tag name - */ - public function getTag() - { - return 'EVENT'; - } -} diff --git a/install/update/old/phpbb/template/twig/tokenparser/includecss.php b/install/update/old/phpbb/template/twig/tokenparser/includecss.php deleted file mode 100644 index 1f30811..0000000 --- a/install/update/old/phpbb/template/twig/tokenparser/includecss.php +++ /dev/null @@ -1,44 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\template\twig\tokenparser; - -class includecss extends \Twig_TokenParser -{ - /** - * Parses a token and returns a node. - * - * @param \Twig_Token $token A Twig_Token instance - * - * @return \Twig_NodeInterface A Twig_NodeInterface instance - */ - public function parse(\Twig_Token $token) - { - $expr = $this->parser->getExpressionParser()->parseExpression(); - - $stream = $this->parser->getStream(); - $stream->expect(\Twig_Token::BLOCK_END_TYPE); - - return new \phpbb\template\twig\node\includecss($expr, $this->parser->getEnvironment(), $token->getLine(), $this->getTag()); - } - - /** - * Gets the tag name associated with this token parser. - * - * @return string The tag name - */ - public function getTag() - { - return 'INCLUDECSS'; - } -} diff --git a/install/update/old/phpbb/template/twig/tokenparser/includejs.php b/install/update/old/phpbb/template/twig/tokenparser/includejs.php deleted file mode 100644 index 4b67d2c..0000000 --- a/install/update/old/phpbb/template/twig/tokenparser/includejs.php +++ /dev/null @@ -1,44 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\template\twig\tokenparser; - -class includejs extends \Twig_TokenParser -{ - /** - * Parses a token and returns a node. - * - * @param \Twig_Token $token A Twig_Token instance - * - * @return \Twig_NodeInterface A Twig_NodeInterface instance - */ - public function parse(\Twig_Token $token) - { - $expr = $this->parser->getExpressionParser()->parseExpression(); - - $stream = $this->parser->getStream(); - $stream->expect(\Twig_Token::BLOCK_END_TYPE); - - return new \phpbb\template\twig\node\includejs($expr, $this->parser->getEnvironment(), $token->getLine(), $this->getTag()); - } - - /** - * Gets the tag name associated with this token parser. - * - * @return string The tag name - */ - public function getTag() - { - return 'INCLUDEJS'; - } -} diff --git a/install/update/old/phpbb/template/twig/tokenparser/includeparser.php b/install/update/old/phpbb/template/twig/tokenparser/includeparser.php deleted file mode 100644 index aa7236a..0000000 --- a/install/update/old/phpbb/template/twig/tokenparser/includeparser.php +++ /dev/null @@ -1,44 +0,0 @@ - -* @copyright Portions (c) 2009 Fabien Potencier, Armin Ronacher -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\template\twig\tokenparser; - -class includeparser extends \Twig_TokenParser_Include -{ - /** - * Parses a token and returns a node. - * - * @param \Twig_Token $token A Twig_Token instance - * - * @return \Twig_NodeInterface A Twig_NodeInterface instance - */ - public function parse(\Twig_Token $token) - { - $expr = $this->parser->getExpressionParser()->parseExpression(); - - list($variables, $only, $ignoreMissing) = $this->parseArguments(); - - return new \phpbb\template\twig\node\includenode($expr, $variables, $only, $ignoreMissing, $token->getLine(), $this->getTag()); - } - - /** - * Gets the tag name associated with this token parser. - * - * @return string The tag name - */ - public function getTag() - { - return 'INCLUDE'; - } -} diff --git a/install/update/old/phpbb/template/twig/tokenparser/includephp.php b/install/update/old/phpbb/template/twig/tokenparser/includephp.php deleted file mode 100644 index 3992636..0000000 --- a/install/update/old/phpbb/template/twig/tokenparser/includephp.php +++ /dev/null @@ -1,55 +0,0 @@ - -* @copyright Portions (c) 2009 Fabien Potencier, Armin Ronacher -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\template\twig\tokenparser; - -class includephp extends \Twig_TokenParser -{ - /** - * Parses a token and returns a node. - * - * @param \Twig_Token $token A Twig_Token instance - * - * @return \Twig_NodeInterface A Twig_NodeInterface instance - */ - public function parse(\Twig_Token $token) - { - $expr = $this->parser->getExpressionParser()->parseExpression(); - - $stream = $this->parser->getStream(); - - $ignoreMissing = false; - if ($stream->test(\Twig_Token::NAME_TYPE, 'ignore')) - { - $stream->next(); - $stream->expect(\Twig_Token::NAME_TYPE, 'missing'); - - $ignoreMissing = true; - } - - $stream->expect(\Twig_Token::BLOCK_END_TYPE); - - return new \phpbb\template\twig\node\includephp($expr, $this->parser->getEnvironment(), $token->getLine(), $ignoreMissing, $this->getTag()); - } - - /** - * Gets the tag name associated with this token parser. - * - * @return string The tag name - */ - public function getTag() - { - return 'INCLUDEPHP'; - } -} diff --git a/install/update/old/phpbb/template/twig/tokenparser/php.php b/install/update/old/phpbb/template/twig/tokenparser/php.php deleted file mode 100644 index f11ce35..0000000 --- a/install/update/old/phpbb/template/twig/tokenparser/php.php +++ /dev/null @@ -1,52 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\template\twig\tokenparser; - -class php extends \Twig_TokenParser -{ - /** - * Parses a token and returns a node. - * - * @param \Twig_Token $token A Twig_Token instance - * - * @return \Twig_NodeInterface A Twig_NodeInterface instance - */ - public function parse(\Twig_Token $token) - { - $stream = $this->parser->getStream(); - - $stream->expect(\Twig_Token::BLOCK_END_TYPE); - - $body = $this->parser->subparse(array($this, 'decideEnd'), true); - - $stream->expect(\Twig_Token::BLOCK_END_TYPE); - - return new \phpbb\template\twig\node\php($body, $this->parser->getEnvironment(), $token->getLine(), $this->getTag()); - } - - public function decideEnd(\Twig_Token $token) - { - return $token->test('ENDPHP'); - } - - /** - * Gets the tag name associated with this token parser. - * - * @return string The tag name - */ - public function getTag() - { - return 'PHP'; - } -} diff --git a/install/update/old/phpbb/textformatter/s9e/bbcode_merger.php b/install/update/old/phpbb/textformatter/s9e/bbcode_merger.php deleted file mode 100644 index a05ca3c..0000000 --- a/install/update/old/phpbb/textformatter/s9e/bbcode_merger.php +++ /dev/null @@ -1,183 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\textformatter\s9e; - -use phpbb\textformatter\s9e\factory; -use s9e\TextFormatter\Configurator\Helpers\TemplateHelper; -use s9e\TextFormatter\Configurator\Items\UnsafeTemplate; - -class bbcode_merger -{ - /** - * @var \s9e\TextFormatter\Configurator $configurator Configurator instance used to inspect BBCodes - */ - protected $configurator; - - /** - * @param \phpbb\textformatter\s9e\factory $factory - */ - public function __construct(factory $factory) - { - $this->configurator = $factory->get_configurator(); - } - - /** - * Merge two BBCode definitions - * - * All of the arrays contain a "usage" element and a "template" element - * - * @throws InvalidArgumentException if a definition cannot be interpreted - * @throws RuntimeException if something unexpected occurs - * - * @param array $without BBCode definition without an attribute - * @param array $with BBCode definition with an attribute - * @return array Merged definition - */ - public function merge_bbcodes(array $without, array $with) - { - $without = $this->create_bbcode($without); - $with = $this->create_bbcode($with); - - // Select the appropriate strategy for merging this BBCode - if ($this->is_content_bbcode($without, $with)) - { - $merged = $this->merge_content_bbcode($without, $with); - } - else - { - $merged = $this->merge_optional_bbcode($without, $with); - } - - $merged['template'] = $this->normalize_template($merged['template']); - - return $merged; - } - - /** - * Create a custom BBCode for inspection - * - * @param array $definition Original BBCode definition - * @return array Updated definition containing a BBCode object and a Tag - */ - protected function create_bbcode(array $definition) - { - $bbcode = $this->configurator->BBCodes->addCustom( - $definition['usage'], - new UnsafeTemplate($definition['template']) - ); - - $definition['bbcode'] = $bbcode; - $definition['tag'] = $this->configurator->tags[$bbcode->tagName]; - - return $definition; - } - - /** - * Indent given template for readability - * - * @param string $template - * @return string - */ - protected function indent_template($template) - { - $dom = TemplateHelper::loadTemplate($template); - $dom->formatOutput = true; - $template = TemplateHelper::saveTemplate($dom); - - // Remove the first level of indentation if the template starts with whitespace - if (preg_match('(^\\n +)', $template, $m)) - { - $template = str_replace($m[0], "\n", $template); - } - - return trim($template); - } - - /** - * Test whether the two definitions form a "content"-style BBCode - * - * Such BBCodes include the [URL] BBCode, which uses its text content as - * attribute if none is provided - * - * @param array $without BBCode definition without an attribute - * @param array $with BBCode definition with an attribute - * @return array Merged definition - */ - protected function is_content_bbcode(array $without, array $with) - { - // Test whether we find the same non-TEXT token between "]" and "[" in the usage - // as between ">" and "<" in the template - return (preg_match('(\\]\\s*(\\{(?!TEXT)[^}]+\\})\\s*\\[)', $without['usage'], $m) - && preg_match('(>[^<]*?' . preg_quote($m[1]) . '[^>]*?<)s', $without['template'])); - } - - /** - * Merge the two BBCode definitions of a "content"-style BBCode - * - * @param array $without BBCode definition without an attribute - * @param array $with BBCode definition with an attribute - * @return array Merged definition - */ - protected function merge_content_bbcode(array $without, array $with) - { - // Convert [X={X}] into [X={X;useContent}] - $usage = preg_replace('(\\})', ';useContent}', $with['usage'], 1); - - // Use the template from the definition that uses an attribute - $template = $with['tag']->template; - - return ['usage' => $usage, 'template' => $template]; - } - - /** - * Merge the two BBCode definitions of a BBCode with an optional argument - * - * Such BBCodes include the [QUOTE] BBCode, which takes an optional argument - * but otherwise does not behave differently - * - * @param array $without BBCode definition without an attribute - * @param array $with BBCode definition with an attribute - * @return array Merged definition - */ - protected function merge_optional_bbcode(array $without, array $with) - { - // Convert [X={X}] into [X={X?}] - $usage = preg_replace('(\\})', '?}', $with['usage'], 1); - - // Build a template for both versions - $template = '' . $with['tag']->template . '' . $without['tag']->template . ''; - - return ['usage' => $usage, 'template' => $template]; - } - - /** - * Normalize a template - * - * @param string $template - * @return string - */ - protected function normalize_template($template) - { - // Normalize the template to simplify it - $template = $this->configurator->templateNormalizer->normalizeTemplate($template); - - // Convert xsl:value-of elements back to {L_} tokens where applicable - $template = preg_replace('()', '{$1}', $template); - - // Beautify the template - $template = $this->indent_template($template); - - return $template; - } -} diff --git a/install/update/old/phpbb/textformatter/s9e/factory.php b/install/update/old/phpbb/textformatter/s9e/factory.php deleted file mode 100644 index 6191b9a..0000000 --- a/install/update/old/phpbb/textformatter/s9e/factory.php +++ /dev/null @@ -1,676 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\textformatter\s9e; - -use s9e\TextFormatter\Configurator; -use s9e\TextFormatter\Configurator\Items\AttributeFilters\RegexpFilter; -use s9e\TextFormatter\Configurator\Items\UnsafeTemplate; - -/** -* Creates s9e\TextFormatter objects -*/ -class factory implements \phpbb\textformatter\cache_interface -{ - /** - * @var \phpbb\textformatter\s9e\link_helper - */ - protected $link_helper; - - /** - * @var \phpbb\cache\driver\driver_interface - */ - protected $cache; - - /** - * @var string Path to the cache dir - */ - protected $cache_dir; - - /** - * @var string Cache key used for the parser - */ - protected $cache_key_parser; - - /** - * @var string Cache key used for the renderer - */ - protected $cache_key_renderer; - - /** - * @var \phpbb\config\config - */ - protected $config; - - /** - * @var array Custom tokens used in bbcode.html and their corresponding token from the definition - */ - protected $custom_tokens = array( - 'email' => array('{DESCRIPTION}' => '{TEXT}'), - 'flash' => array('{WIDTH}' => '{NUMBER1}', '{HEIGHT}' => '{NUMBER2}'), - 'img' => array('{URL}' => '{IMAGEURL}'), - 'list' => array('{LIST_TYPE}' => '{HASHMAP}'), - 'quote' => array('{USERNAME}' => '{TEXT1}'), - 'size' => array('{SIZE}' => '{FONTSIZE}'), - 'url' => array('{DESCRIPTION}' => '{TEXT}'), - ); - - /** - * @var \phpbb\textformatter\data_access - */ - protected $data_access; - - /** - * @var array Default BBCode definitions - */ - protected $default_definitions = array( - 'attachment' => '[ATTACHMENT index={NUMBER} filename={TEXT;useContent}]', - 'b' => '[B]{TEXT}[/B]', - 'code' => '[CODE lang={IDENTIFIER;optional}]{TEXT}[/CODE]', - 'color' => '[COLOR={COLOR}]{TEXT}[/COLOR]', - 'email' => '[EMAIL={EMAIL;useContent} subject={TEXT1;optional;postFilter=rawurlencode} body={TEXT2;optional;postFilter=rawurlencode}]{TEXT}[/EMAIL]', - 'flash' => '[FLASH={NUMBER1},{NUMBER2} width={NUMBER1;postFilter=#flashwidth} height={NUMBER2;postFilter=#flashheight} url={URL;useContent} /]', - 'i' => '[I]{TEXT}[/I]', - 'img' => '[IMG src={IMAGEURL;useContent}]', - 'list' => '[LIST type={HASHMAP=1:decimal,a:lower-alpha,A:upper-alpha,i:lower-roman,I:upper-roman;optional;postFilter=#simpletext} #createChild=LI]{TEXT}[/LIST]', - 'li' => '[* $tagName=LI]{TEXT}[/*]', - 'quote' => - "[QUOTE - author={TEXT1;optional} - post_id={UINT;optional} - post_url={URL;optional;postFilter=#false} - profile_url={URL;optional;postFilter=#false} - time={UINT;optional} - url={URL;optional} - user_id={UINT;optional} - author={PARSE=/^\\[url=(?'url'.*?)](?'author'.*)\\[\\/url]$/i} - author={PARSE=/^\\[url](?'author'(?'url'.*?))\\[\\/url]$/i} - author={PARSE=/(?'url'https?:\\/\\/[^[\\]]+)/i} - ]{TEXT2}[/QUOTE]", - 'size' => '[SIZE={FONTSIZE}]{TEXT}[/SIZE]', - 'u' => '[U]{TEXT}[/U]', - 'url' => '[URL={URL;useContent} $forceLookahead=true]{TEXT}[/URL]', - ); - - /** - * @var array Default templates, taken from bbcode::bbcode_tpl() - */ - protected $default_templates = array( - 'b' => '', - 'i' => '', - 'u' => '', - 'img' => '{L_IMAGE}', - 'size' => '', - 'color' => '', - 'email' => ' - - mailto: - - - ? - subject= - &body= - - - - ', - ); - - /** - * @var \phpbb\event\dispatcher_interface - */ - protected $dispatcher; - - /** - * @var \phpbb\log\log_interface - */ - protected $log; - - /** - * Constructor - * - * @param \phpbb\textformatter\data_access $data_access - * @param \phpbb\cache\driver\driver_interface $cache - * @param \phpbb\event\dispatcher_interface $dispatcher - * @param \phpbb\config\config $config - * @param \phpbb\textformatter\s9e\link_helper $link_helper - * @param \phpbb\log\log_interface $log - * @param string $cache_dir Path to the cache dir - * @param string $cache_key_parser Cache key used for the parser - * @param string $cache_key_renderer Cache key used for the renderer - */ - public function __construct(\phpbb\textformatter\data_access $data_access, \phpbb\cache\driver\driver_interface $cache, \phpbb\event\dispatcher_interface $dispatcher, \phpbb\config\config $config, \phpbb\textformatter\s9e\link_helper $link_helper, \phpbb\log\log_interface $log, $cache_dir, $cache_key_parser, $cache_key_renderer) - { - $this->link_helper = $link_helper; - $this->cache = $cache; - $this->cache_dir = $cache_dir; - $this->cache_key_parser = $cache_key_parser; - $this->cache_key_renderer = $cache_key_renderer; - $this->config = $config; - $this->data_access = $data_access; - $this->dispatcher = $dispatcher; - $this->log = $log; - } - - /** - * {@inheritdoc} - */ - public function invalidate() - { - $this->regenerate(); - } - - /** - * {@inheritdoc} - * - * Will remove old renderers from the cache dir but won't touch the current renderer - */ - public function tidy() - { - // Get the name of current renderer - $renderer_data = $this->cache->get($this->cache_key_renderer); - $renderer_file = ($renderer_data) ? $renderer_data['class'] . '.php' : null; - - foreach (glob($this->cache_dir . 's9e_*') as $filename) - { - // Only remove the file if it's not the current renderer - if (!$renderer_file || substr($filename, -strlen($renderer_file)) !== $renderer_file) - { - unlink($filename); - } - } - } - - /** - * Generate and return a new configured instance of s9e\TextFormatter\Configurator - * - * @return Configurator - */ - public function get_configurator() - { - // Create a new Configurator - $configurator = new Configurator; - - /** - * Modify the s9e\TextFormatter configurator before the default settings are set - * - * @event core.text_formatter_s9e_configure_before - * @var \s9e\TextFormatter\Configurator configurator Configurator instance - * @since 3.2.0-a1 - */ - $vars = array('configurator'); - extract($this->dispatcher->trigger_event('core.text_formatter_s9e_configure_before', compact($vars))); - - // Reset the list of allowed schemes - foreach ($configurator->urlConfig->getAllowedSchemes() as $scheme) - { - $configurator->urlConfig->disallowScheme($scheme); - } - foreach (explode(',', $this->config['allowed_schemes_links']) as $scheme) - { - $configurator->urlConfig->allowScheme(trim($scheme)); - } - - // Convert newlines to br elements by default - $configurator->rootRules->enableAutoLineBreaks(); - - // Don't automatically ignore text in places where text is not allowed - $configurator->rulesGenerator->remove('IgnoreTextIfDisallowed'); - - // Don't remove comments and instead convert them to xsl:comment elements - $configurator->templateNormalizer->remove('RemoveComments'); - $configurator->templateNormalizer->add('TransposeComments'); - - // Set the rendering engine and configure it to save to the cache dir - $configurator->rendering->engine = 'PHP'; - $configurator->rendering->engine->cacheDir = $this->cache_dir; - $configurator->rendering->engine->defaultClassPrefix = 's9e_renderer_'; - $configurator->rendering->engine->enableQuickRenderer = true; - - // Create custom filters for BBCode tokens that are supported in phpBB but not in - // s9e\TextFormatter - $filter = new RegexpFilter('#^' . get_preg_expression('relative_url') . '$#Du'); - $configurator->attributeFilters->add('#local_url', $filter); - $configurator->attributeFilters->add('#relative_url', $filter); - - // INTTEXT regexp from acp_bbcodes - $filter = new RegexpFilter('!^([\p{L}\p{N}\-+,_. ]+)$!Du'); - $configurator->attributeFilters->add('#inttext', $filter); - - // Create custom filters for Flash restrictions, which use the same values as the image - // restrictions but have their own error message - $configurator->attributeFilters - ->add('#flashheight', __NAMESPACE__ . '\\parser::filter_flash_height') - ->addParameterByName('max_img_height') - ->addParameterByName('logger'); - - $configurator->attributeFilters - ->add('#flashwidth', __NAMESPACE__ . '\\parser::filter_flash_width') - ->addParameterByName('max_img_width') - ->addParameterByName('logger'); - - // Create a custom filter for phpBB's per-mode font size limits - $configurator->attributeFilters - ->add('#fontsize', __NAMESPACE__ . '\\parser::filter_font_size') - ->addParameterByName('max_font_size') - ->addParameterByName('logger') - ->markAsSafeInCSS(); - - // Create a custom filter for image URLs - $configurator->attributeFilters - ->add('#imageurl', __NAMESPACE__ . '\\parser::filter_img_url') - ->addParameterByName('urlConfig') - ->addParameterByName('logger') - ->addParameterByName('max_img_height') - ->addParameterByName('max_img_width') - ->markAsSafeAsURL() - ->setJS('UrlFilter.filter'); - - // Add default BBCodes - foreach ($this->get_default_bbcodes($configurator) as $bbcode) - { - $this->add_bbcode($configurator, $bbcode['usage'], $bbcode['template']); - } - if (isset($configurator->tags['QUOTE'])) - { - // Remove the nesting limit and let other services remove quotes at parsing time - $configurator->tags['QUOTE']->nestingLimit = PHP_INT_MAX; - } - - // Modify the template to disable images/flash depending on user's settings - foreach (array('FLASH', 'IMG') as $name) - { - $tag = $configurator->tags[$name]; - $tag->template = '' . $tag->template . ''; - } - - // Load custom BBCodes - foreach ($this->data_access->get_bbcodes() as $row) - { - // Insert the board's URL before {LOCAL_URL} tokens - $tpl = preg_replace_callback( - '#\\{LOCAL_URL\\d*\\}#', - function ($m) - { - return generate_board_url() . '/' . $m[0]; - }, - $row['bbcode_tpl'] - ); - $this->add_bbcode($configurator, $row['bbcode_match'], $tpl); - } - - // Load smilies - foreach ($this->data_access->get_smilies() as $row) - { - $configurator->Emoticons->set( - $row['code'], - '{.}' - ); - } - - if (isset($configurator->Emoticons)) - { - // Force emoticons to be rendered as text if $S_VIEWSMILIES is not set - $configurator->Emoticons->notIfCondition = 'not($S_VIEWSMILIES)'; - - // Only parse emoticons at the beginning of the text or if they're preceded by any - // one of: a new line, a space, a dot, or a right square bracket - $configurator->Emoticons->notAfter = '[^\\n .\\]]'; - - // Ignore emoticons that are immediately followed by a "word" character - $configurator->Emoticons->notBefore = '\\w'; - } - - // Load the censored words - $censor = $this->data_access->get_censored_words(); - if (!empty($censor)) - { - // Use a namespaced tag to avoid collisions - $configurator->plugins->load('Censor', array('tagName' => 'censor:tag')); - foreach ($censor as $row) - { - $configurator->Censor->add($row['word'], $row['replacement']); - } - } - - // Load the magic links plugins. We do that after BBCodes so that they use the same tags - $this->configure_autolink($configurator); - - // Register some vars with a default value. Those should be set at runtime by whatever calls - // the parser - $configurator->registeredVars['max_font_size'] = 0; - $configurator->registeredVars['max_img_height'] = 0; - $configurator->registeredVars['max_img_width'] = 0; - - // Load the Emoji plugin and modify its tag's template to obey viewsmilies - $tag = $configurator->Emoji->getTag(); - $tag->template = ' - - {.} - - - {.} - - '; - $tag->template = '' . str_replace('class="emoji"', 'class="emoji smilies"', $tag->template) . ''; - - /** - * Modify the s9e\TextFormatter configurator after the default settings are set - * - * @event core.text_formatter_s9e_configure_after - * @var \s9e\TextFormatter\Configurator configurator Configurator instance - * @since 3.2.0-a1 - */ - $vars = array('configurator'); - extract($this->dispatcher->trigger_event('core.text_formatter_s9e_configure_after', compact($vars))); - - return $configurator; - } - - /** - * Regenerate and cache a new parser and renderer - * - * @return array Associative array with at least two elements: "parser" and "renderer" - */ - public function regenerate() - { - $configurator = $this->get_configurator(); - - // Get the censor helper and remove the Censor plugin if applicable - if (isset($configurator->Censor)) - { - $censor = $configurator->Censor->getHelper(); - unset($configurator->Censor); - unset($configurator->tags['censor:tag']); - } - - $objects = $configurator->finalize(); - - /** - * Access the objects returned by finalize() before they are saved to cache - * - * @event core.text_formatter_s9e_configure_finalize - * @var array objects Array containing a "parser" object, a "renderer" object and optionally a "js" string - * @since 3.2.2-RC1 - */ - $vars = array('objects'); - extract($this->dispatcher->trigger_event('core.text_formatter_s9e_configure_finalize', compact($vars))); - - $parser = $objects['parser']; - $renderer = $objects['renderer']; - - // Cache the parser as-is - $this->cache->put($this->cache_key_parser, $parser); - - // We need to cache the name of the renderer's generated class - $renderer_data = array('class' => get_class($renderer)); - if (isset($censor)) - { - $renderer_data['censor'] = $censor; - } - $this->cache->put($this->cache_key_renderer, $renderer_data); - - return array('parser' => $parser, 'renderer' => $renderer); - } - - /** - * Add a BBCode to given configurator - * - * @param Configurator $configurator - * @param string $usage - * @param string $template - * @return void - */ - protected function add_bbcode(Configurator $configurator, $usage, $template) - { - try - { - $configurator->BBCodes->addCustom($usage, new UnsafeTemplate($template)); - } - catch (\Exception $e) - { - $this->log->add('critical', null, null, 'LOG_BBCODE_CONFIGURATION_ERROR', false, [$usage, $e->getMessage()]); - } - } - - /** - * Configure the Autolink / Autoemail plugins used to linkify text - * - * @param \s9e\TextFormatter\Configurator $configurator - * @return void - */ - protected function configure_autolink(Configurator $configurator) - { - $configurator->plugins->load('Autoemail'); - $configurator->plugins->load('Autolink', array('matchWww' => true)); - - // Add a tag filter that creates a tag that stores and replace the - // content of a link created by the Autolink plugin - $configurator->Autolink->getTag()->filterChain - ->add(array($this->link_helper, 'generate_link_text_tag')) - ->resetParameters() - ->addParameterByName('tag') - ->addParameterByName('parser'); - - // Create a tag that will be used to display the truncated text by - // replacing the original content with the content of the @text attribute - $tag = $configurator->tags->add('LINK_TEXT'); - $tag->attributes->add('text'); - $tag->template = ''; - - $tag->filterChain - ->add(array($this->link_helper, 'truncate_local_url')) - ->resetParameters() - ->addParameterByName('tag') - ->addParameterByValue(generate_board_url() . '/'); - $tag->filterChain - ->add(array($this->link_helper, 'truncate_text')) - ->resetParameters() - ->addParameterByName('tag'); - $tag->filterChain - ->add(array($this->link_helper, 'cleanup_tag')) - ->resetParameters() - ->addParameterByName('tag') - ->addParameterByName('parser'); - } - - /** - * Escape a literal to be used in an HTML attribute in an XSL template - * - * Escapes "HTML special chars" for obvious reasons and curly braces to avoid them - * being interpreted as an attribute value template - * - * @param string $value Original string - * @return string Escaped string - */ - protected function escape_html_attribute($value) - { - return htmlspecialchars(strtr($value, ['{' => '{{', '}' => '}}']), ENT_COMPAT | ENT_XML1, 'UTF-8'); - } - - /** - * Return the default BBCodes configuration - * - * @return array 2D array. Each element has a 'usage' key, a 'template' key, and an optional 'options' key - */ - protected function get_default_bbcodes($configurator) - { - // For each BBCode, build an associative array matching style_ids to their template - $templates = array(); - foreach ($this->data_access->get_styles_templates() as $style_id => $data) - { - foreach ($this->extract_templates($data['template']) as $bbcode_name => $template) - { - $templates[$bbcode_name][$style_id] = $template; - } - - // Add default templates wherever missing, or for BBCodes that were not specified in - // this template's bitfield. For instance, prosilver has a custom template for b but its - // bitfield does not enable it so the default template is used instead - foreach ($this->default_templates as $bbcode_name => $template) - { - if (!isset($templates[$bbcode_name][$style_id]) || !in_array($bbcode_name, $data['bbcodes'], true)) - { - $templates[$bbcode_name][$style_id] = $template; - } - } - } - - // Replace custom tokens and normalize templates - foreach ($templates as $bbcode_name => $style_templates) - { - foreach ($style_templates as $i => $template) - { - if (isset($this->custom_tokens[$bbcode_name])) - { - $template = strtr($template, $this->custom_tokens[$bbcode_name]); - } - - $templates[$bbcode_name][$i] = $configurator->templateNormalizer->normalizeTemplate($template); - } - } - - $bbcodes = array(); - foreach ($this->default_definitions as $bbcode_name => $usage) - { - $bbcodes[$bbcode_name] = array( - 'usage' => $usage, - 'template' => $this->merge_templates($templates[$bbcode_name]), - ); - } - - return $bbcodes; - } - - /** - * Extract and recompose individual BBCode templates from a style's template file - * - * @param string $template Style template (bbcode.html) - * @return array Associative array matching BBCode names to their template - */ - protected function extract_templates($template) - { - // Capture the template fragments - // Allow either phpBB template or the Twig syntax - preg_match_all('#(.*?)#s', $template, $matches, PREG_SET_ORDER) ?: - preg_match_all('#{% for (.*?) in .*? %}(.*?){% endfor %}#s', $template, $matches, PREG_SET_ORDER); - - $fragments = array(); - foreach ($matches as $match) - { - // Normalize the whitespace - $fragment = preg_replace('#>\\n\\t*<#', '><', trim($match[2])); - - $fragments[$match[1]] = $fragment; - } - - // Automatically recompose templates split between *_open and *_close - foreach ($fragments as $fragment_name => $fragment) - { - if (preg_match('#^(\\w+)_close$#', $fragment_name, $match)) - { - $bbcode_name = $match[1]; - - if (isset($fragments[$bbcode_name . '_open'])) - { - $templates[$bbcode_name] = $fragments[$bbcode_name . '_open'] . '' . $fragment; - } - } - } - - // Manually recompose and overwrite irregular templates - $templates['list'] = - ' - - ' . $fragments['ulist_open_default'] . '' . $fragments['ulist_close'] . ' - - - ' . $fragments['olist_open'] . '' . $fragments['olist_close'] . ' - - - ' . $fragments['ulist_open'] . '' . $fragments['ulist_close'] . ' - - '; - - $templates['li'] = $fragments['listitem'] . '' . $fragments['listitem_close']; - - // Replace the regular quote template with the extended quote template if available - if (isset($fragments['quote_extended'])) - { - $templates['quote'] = $fragments['quote_extended']; - } - - // The [attachment] BBCode uses the inline_attachment template to output a comment that - // is post-processed by parse_attachments() - $templates['attachment'] = $fragments['inline_attachment_open'] . ' ia ia ' . $fragments['inline_attachment_close']; - - // Add fragments as templates - foreach ($fragments as $fragment_name => $fragment) - { - if (preg_match('#^\\w+$#', $fragment_name)) - { - $templates[$fragment_name] = $fragment; - } - } - - // Keep only templates that are named after an existing BBCode - $templates = array_intersect_key($templates, $this->default_definitions); - - return $templates; - } - - /** - * Merge the templates from any number of styles into one BBCode template - * - * When multiple templates are available for the same BBCode (because of multiple styles) we - * merge them into a single template that uses an xsl:choose construct that determines which - * style to use at rendering time. - * - * @param array $style_templates Associative array matching style_ids to their template - * @return string - */ - protected function merge_templates(array $style_templates) - { - // Return the template as-is if there's only one style or all styles share the same template - if (count(array_unique($style_templates)) === 1) - { - return end($style_templates); - } - - // Group identical templates together - $grouped_templates = array(); - foreach ($style_templates as $style_id => $style_template) - { - $grouped_templates[$style_template][] = '$STYLE_ID=' . $style_id; - } - - // Sort templates by frequency descending - $templates_cnt = array_map('sizeof', $grouped_templates); - array_multisort($grouped_templates, $templates_cnt); - - // Remove the most frequent template from the list; It becomes the default - reset($grouped_templates); - $default_template = key($grouped_templates); - unset($grouped_templates[$default_template]); - - // Build an xsl:choose switch - $template = ''; - foreach ($grouped_templates as $style_template => $exprs) - { - $template .= '' . $style_template . ''; - } - $template .= '' . $default_template . ''; - - return $template; - } -} diff --git a/install/update/old/phpbb/textformatter/s9e/link_helper.php b/install/update/old/phpbb/textformatter/s9e/link_helper.php deleted file mode 100644 index 483794a..0000000 --- a/install/update/old/phpbb/textformatter/s9e/link_helper.php +++ /dev/null @@ -1,115 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\textformatter\s9e; - -class link_helper -{ - /** - * Clean up and invalidate a LINK_TEXT tag if applicable - * - * Will invalidate the tag if its replacement text is the same as the original - * text and would have no visible effect - * - * @param \s9e\TextFormatter\Parser\Tag $tag LINK_TEXT tag - * @param \s9e\TextFormatter\Parser $parser Parser - * @return void - */ - public function cleanup_tag(\s9e\TextFormatter\Parser\Tag $tag, \s9e\TextFormatter\Parser $parser) - { - // Invalidate if the content of the tag matches the text attribute - $text = substr($parser->getText(), $tag->getPos(), $tag->getLen()); - if ($text === $tag->getAttribute('text')) - { - $tag->invalidate(); - } - } - - /** - * Create a LINK_TEXT tag inside of a link - * - * Meant to only apply to linkified URLs and [url] BBCodes without a parameter - * - * @param \s9e\TextFormatter\Parser\Tag $tag URL tag (start tag) - * @param \s9e\TextFormatter\Parser $parser Parser - * @return void - */ - public function generate_link_text_tag(\s9e\TextFormatter\Parser\Tag $tag, \s9e\TextFormatter\Parser $parser) - { - // Only create a LINK_TEXT tag if the start tag is paired with an end - // tag, which is the case with tags from the Autolink plugins and with - // the [url] BBCode when its content is used for the URL - if (!$tag->getEndTag() || !$this->should_shorten($tag, $parser->getText())) - { - return; - } - - // Capture the text between the start tag and its end tag - $start = $tag->getPos() + $tag->getLen(); - $end = $tag->getEndTag()->getPos(); - $length = $end - $start; - $text = substr($parser->getText(), $start, $length); - - // Create a tag that consumes the link's text and make it depends on this tag - $link_text_tag = $parser->addSelfClosingTag('LINK_TEXT', $start, $length); - $link_text_tag->setAttribute('text', $text); - $tag->cascadeInvalidationTo($link_text_tag); - } - - /** - * Test whether we should shorten this tag's text - * - * Will test whether the tag either does not use any markup or uses a single - * [url] BBCode - * - * @param \s9e\TextFormatter\Parser\Tag $tag URL tag - * @param string $text Original text - * @return bool - */ - protected function should_shorten(\s9e\TextFormatter\Parser\Tag $tag, $text) - { - return ($tag->getLen() === 0 || strtolower(substr($text, $tag->getPos(), $tag->getLen())) === '[url]'); - } - - /** - * Remove the board's root URL from a the start of a string - * - * @param \s9e\TextFormatter\Parser\Tag $tag LINK_TEXT tag - * @param string $board_url Forum's root URL (with trailing slash) - * @return void - */ - public function truncate_local_url(\s9e\TextFormatter\Parser\Tag $tag, $board_url) - { - $text = $tag->getAttribute('text'); - if (stripos($text, $board_url) === 0 && strlen($text) > strlen($board_url)) - { - $tag->setAttribute('text', substr($text, strlen($board_url))); - } - } - - /** - * Truncate the replacement text set in a LINK_TEXT tag - * - * @param \s9e\TextFormatter\Parser\Tag $tag LINK_TEXT tag - * @return void - */ - public function truncate_text(\s9e\TextFormatter\Parser\Tag $tag) - { - $text = $tag->getAttribute('text'); - if (utf8_strlen($text) > 55) - { - $text = utf8_substr($text, 0, 39) . ' ... ' . utf8_substr($text, -10); - $tag->setAttribute('text', $text); - } - } -} diff --git a/install/update/old/phpbb/textformatter/s9e/parser.php b/install/update/old/phpbb/textformatter/s9e/parser.php deleted file mode 100644 index 3698dca..0000000 --- a/install/update/old/phpbb/textformatter/s9e/parser.php +++ /dev/null @@ -1,399 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\textformatter\s9e; - -use s9e\TextFormatter\Parser\AttributeFilters\UrlFilter; -use s9e\TextFormatter\Parser\Logger; - -/** -* s9e\TextFormatter\Parser adapter -*/ -class parser implements \phpbb\textformatter\parser_interface -{ - /** - * @var \phpbb\event\dispatcher_interface - */ - protected $dispatcher; - - /** - * @var \s9e\TextFormatter\Parser - */ - protected $parser; - - /** - * Constructor - * - * @param \phpbb\cache\driver_interface $cache - * @param string $key Cache key - * @param factory $factory - * @param \phpbb\event\dispatcher_interface $dispatcher - */ - public function __construct(\phpbb\cache\driver\driver_interface $cache, $key, factory $factory, \phpbb\event\dispatcher_interface $dispatcher) - { - $parser = $cache->get($key); - if (!$parser) - { - $objects = $factory->regenerate(); - $parser = $objects['parser']; - } - - $this->dispatcher = $dispatcher; - $this->parser = $parser; - - $parser = $this; - - /** - * Configure the parser service - * - * Can be used to: - * - toggle features or BBCodes - * - register variables or custom parsers in the s9e\TextFormatter parser - * - configure the s9e\TextFormatter parser's runtime settings - * - * @event core.text_formatter_s9e_parser_setup - * @var \phpbb\textformatter\s9e\parser parser This parser service - * @since 3.2.0-a1 - */ - $vars = array('parser'); - extract($dispatcher->trigger_event('core.text_formatter_s9e_parser_setup', compact($vars))); - } - - /** - * {@inheritdoc} - */ - public function parse($text) - { - $parser = $this; - - /** - * Modify a text before it is parsed - * - * @event core.text_formatter_s9e_parse_before - * @var \phpbb\textformatter\s9e\parser parser This parser service - * @var string text The original text - * @since 3.2.0-a1 - */ - $vars = array('parser', 'text'); - extract($this->dispatcher->trigger_event('core.text_formatter_s9e_parse_before', compact($vars))); - - $xml = $this->parser->parse($text); - - /** - * Modify a parsed text in its XML form - * - * @event core.text_formatter_s9e_parse_after - * @var \phpbb\textformatter\s9e\parser parser This parser service - * @var string xml The parsed text, in XML - * @since 3.2.0-a1 - */ - $vars = array('parser', 'xml'); - extract($this->dispatcher->trigger_event('core.text_formatter_s9e_parse_after', compact($vars))); - - return $xml; - } - - /** - * {@inheritdoc} - */ - public function disable_bbcode($name) - { - $this->parser->disableTag(strtoupper($name)); - } - - /** - * {@inheritdoc} - */ - public function disable_bbcodes() - { - $this->parser->disablePlugin('BBCodes'); - } - - /** - * {@inheritdoc} - */ - public function disable_censor() - { - $this->parser->disablePlugin('Censor'); - } - - /** - * {@inheritdoc} - */ - public function disable_magic_url() - { - $this->parser->disablePlugin('Autoemail'); - $this->parser->disablePlugin('Autolink'); - } - - /** - * {@inheritdoc} - */ - public function disable_smilies() - { - $this->parser->disablePlugin('Emoticons'); - $this->parser->disablePlugin('Emoji'); - } - - /** - * {@inheritdoc} - */ - public function enable_bbcode($name) - { - $this->parser->enableTag(strtoupper($name)); - } - - /** - * {@inheritdoc} - */ - public function enable_bbcodes() - { - $this->parser->enablePlugin('BBCodes'); - } - - /** - * {@inheritdoc} - */ - public function enable_censor() - { - $this->parser->enablePlugin('Censor'); - } - - /** - * {@inheritdoc} - */ - public function enable_magic_url() - { - $this->parser->enablePlugin('Autoemail'); - $this->parser->enablePlugin('Autolink'); - } - - /** - * {@inheritdoc} - */ - public function enable_smilies() - { - $this->parser->enablePlugin('Emoticons'); - $this->parser->enablePlugin('Emoji'); - } - - /** - * {@inheritdoc} - * - * This will convert the log entries found in s9e\TextFormatter's logger into phpBB error - * messages - */ - public function get_errors() - { - $errors = array(); - foreach ($this->parser->getLogger()->getLogs() as $entry) - { - list(, $msg, $context) = $entry; - - if ($msg === 'Tag limit exceeded') - { - if ($context['tagName'] === 'E') - { - $errors[] = array('TOO_MANY_SMILIES', $context['tagLimit']); - } - else if ($context['tagName'] === 'URL') - { - $errors[] = array('TOO_MANY_URLS', $context['tagLimit']); - } - } - else if ($msg === 'MAX_FONT_SIZE_EXCEEDED') - { - $errors[] = array($msg, $context['max_size']); - } - else if (preg_match('/^MAX_(?:FLASH|IMG)_(HEIGHT|WIDTH)_EXCEEDED$/D', $msg, $m)) - { - $errors[] = array($msg, $context['max_' . strtolower($m[1])]); - } - else if ($msg === 'Tag is disabled') - { - $name = strtolower($context['tag']->getName()); - $errors[] = array('UNAUTHORISED_BBCODE', '[' . $name . ']'); - } - else if ($msg === 'UNABLE_GET_IMAGE_SIZE') - { - $errors[] = array($msg); - } - } - - // Deduplicate error messages. array_unique() only works on strings so we have to serialize - if (!empty($errors)) - { - $errors = array_map('unserialize', array_unique(array_map('serialize', $errors))); - } - - return $errors; - } - - /** - * Return the instance of s9e\TextFormatter\Parser used by this object - * - * @return \s9e\TextFormatter\Parser - */ - public function get_parser() - { - return $this->parser; - } - - /** - * {@inheritdoc} - */ - public function set_var($name, $value) - { - if ($name === 'max_smilies') - { - $this->parser->setTagLimit('E', $value ?: PHP_INT_MAX); - } - else if ($name === 'max_urls') - { - $this->parser->setTagLimit('URL', $value ?: PHP_INT_MAX); - } - else - { - $this->parser->registeredVars[$name] = $value; - } - } - - /** - * {@inheritdoc} - */ - public function set_vars(array $vars) - { - foreach ($vars as $name => $value) - { - $this->set_var($name, $value); - } - } - - /** - * Filter a flash object's height - * - * @see bbcode_firstpass::bbcode_flash() - * - * @param string $height - * @param integer $max_height - * @param Logger $logger - * @return mixed Original value if valid, FALSE otherwise - */ - static public function filter_flash_height($height, $max_height, Logger $logger) - { - if ($max_height && $height > $max_height) - { - $logger->err('MAX_FLASH_HEIGHT_EXCEEDED', array('max_height' => $max_height)); - - return false; - } - - return $height; - } - - /** - * Filter a flash object's width - * - * @see bbcode_firstpass::bbcode_flash() - * - * @param string $width - * @param integer $max_width - * @param Logger $logger - * @return mixed Original value if valid, FALSE otherwise - */ - static public function filter_flash_width($width, $max_width, Logger $logger) - { - if ($max_width && $width > $max_width) - { - $logger->err('MAX_FLASH_WIDTH_EXCEEDED', array('max_width' => $max_width)); - - return false; - } - - return $width; - } - - /** - * Filter the value used in a [size] BBCode - * - * @see bbcode_firstpass::bbcode_size() - * - * @param string $size Original size - * @param integer $max_size Maximum allowed size - * @param Logger $logger - * @return mixed Original value if valid, FALSE otherwise - */ - static public function filter_font_size($size, $max_size, Logger $logger) - { - if ($max_size && $size > $max_size) - { - $logger->err('MAX_FONT_SIZE_EXCEEDED', array('max_size' => $max_size)); - - return false; - } - - if ($size < 1) - { - return false; - } - - return $size; - } - - /** - * Filter an image's URL to enforce restrictions on its dimensions - * - * @see bbcode_firstpass::bbcode_img() - * - * @param string $url Original URL - * @param array $url_config Config used by the URL filter - * @param Logger $logger - * @param integer $max_height Maximum height allowed - * @param integer $max_width Maximum width allowed - * @return string|bool Original value if valid, FALSE otherwise - */ - static public function filter_img_url($url, array $url_config, Logger $logger, $max_height, $max_width) - { - // Validate the URL - $url = UrlFilter::filter($url, $url_config, $logger); - if ($url === false) - { - return false; - } - - if ($max_height || $max_width) - { - $imagesize = new \FastImageSize\FastImageSize(); - $size_info = $imagesize->getImageSize($url); - if ($size_info === false) - { - $logger->err('UNABLE_GET_IMAGE_SIZE'); - return false; - } - - if ($max_height && $max_height < $size_info['height']) - { - $logger->err('MAX_IMG_HEIGHT_EXCEEDED', array('max_height' => $max_height)); - return false; - } - - if ($max_width && $max_width < $size_info['width']) - { - $logger->err('MAX_IMG_WIDTH_EXCEEDED', array('max_width' => $max_width)); - return false; - } - } - - return $url; - } -} diff --git a/install/update/old/phpbb/textformatter/s9e/quote_helper.php b/install/update/old/phpbb/textformatter/s9e/quote_helper.php deleted file mode 100644 index 86c33c7..0000000 --- a/install/update/old/phpbb/textformatter/s9e/quote_helper.php +++ /dev/null @@ -1,81 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\textformatter\s9e; - -class quote_helper -{ - /** - * @var string Base URL for a post link, uses {POST_ID} as placeholder - */ - protected $post_url; - - /** - * @var string Base URL for a profile link, uses {USER_ID} as placeholder - */ - protected $profile_url; - - /** - * @var \phpbb\user - */ - protected $user; - - /** - * Constructor - * - * @param \phpbb\user $user - * @param string $root_path - * @param string $php_ext - */ - public function __construct(\phpbb\user $user, $root_path, $php_ext) - { - $this->post_url = append_sid($root_path . 'viewtopic.' . $php_ext, 'p={POST_ID}#p{POST_ID}', false); - $this->profile_url = append_sid($root_path . 'memberlist.' . $php_ext, 'mode=viewprofile&u={USER_ID}', false); - $this->user = $user; - } - - /** - * Inject dynamic metadata into QUOTE tags in given XML - * - * @param string $xml Original XML - * @return string Modified XML - */ - public function inject_metadata($xml) - { - $post_url = $this->post_url; - $profile_url = $this->profile_url; - $user = $this->user; - - return \s9e\TextFormatter\Utils::replaceAttributes( - $xml, - 'QUOTE', - function ($attributes) use ($post_url, $profile_url, $user) - { - if (isset($attributes['post_id'])) - { - $attributes['post_url'] = str_replace('{POST_ID}', $attributes['post_id'], $post_url); - } - if (isset($attributes['time'])) - { - $attributes['date'] = $user->format_date($attributes['time']); - } - if (isset($attributes['user_id'])) - { - $attributes['profile_url'] = str_replace('{USER_ID}', $attributes['user_id'], $profile_url); - } - - return $attributes; - } - ); - } -} diff --git a/install/update/old/phpbb/user.php b/install/update/old/phpbb/user.php deleted file mode 100644 index 7363290..0000000 --- a/install/update/old/phpbb/user.php +++ /dev/null @@ -1,814 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb; - -/** -* Base user class -* -* This is the overarching class which contains (through session extend) -* all methods utilised for user functionality during a session. -*/ -class user extends \phpbb\session -{ - /** - * @var \phpbb\language\language - */ - protected $language; - - var $style = array(); - var $date_format; - - /** - * DateTimeZone object holding the timezone of the user - */ - public $timezone; - - /** - * @var string Class name of datetime object - */ - protected $datetime; - - var $lang_name = false; - var $lang_id = false; - var $lang_path; - var $img_lang; - var $img_array = array(); - - /** @var bool */ - protected $is_setup_flag; - - // Able to add new options (up to id 31) - var $keyoptions = array('viewimg' => 0, 'viewflash' => 1, 'viewsmilies' => 2, 'viewsigs' => 3, 'viewavatars' => 4, 'viewcensors' => 5, 'attachsig' => 6, 'bbcode' => 8, 'smilies' => 9, 'sig_bbcode' => 15, 'sig_smilies' => 16, 'sig_links' => 17); - - /** - * Constructor to set the lang path - * - * @param \phpbb\language\language $lang phpBB's Language loader - * @param string $datetime_class Class name of datetime class - */ - function __construct(\phpbb\language\language $lang, $datetime_class) - { - global $phpbb_root_path; - - $this->lang_path = $phpbb_root_path . 'language/'; - $this->language = $lang; - $this->datetime = $datetime_class; - - $this->is_setup_flag = false; - } - - /** - * Returns whether user::setup was called - * - * @return bool - */ - public function is_setup() - { - return $this->is_setup_flag; - } - - /** - * Magic getter for BC compatibility - * - * Implement array access for user::lang. - * - * @param string $param_name Name of the BC component the user want to access - * - * @return array The appropriate array - * - * @deprecated 3.2.0-dev (To be removed: 4.0.0) - */ - public function __get($param_name) - { - if ($param_name === 'lang') - { - return $this->language->get_lang_array(); - } - else if ($param_name === 'help') - { - $help_array = $this->language->get_lang_array(); - return $help_array['__help']; - } - - return array(); - } - - /** - * Setup basic user-specific items (style, language, ...) - */ - function setup($lang_set = false, $style_id = false) - { - global $db, $request, $template, $config, $auth, $phpEx, $phpbb_root_path, $cache; - global $phpbb_dispatcher; - - $this->language->set_default_language($config['default_lang']); - - if ($this->data['user_id'] != ANONYMOUS) - { - $user_lang_name = (file_exists($this->lang_path . $this->data['user_lang'] . "/common.$phpEx")) ? $this->data['user_lang'] : basename($config['default_lang']); - $user_date_format = $this->data['user_dateformat']; - $user_timezone = $this->data['user_timezone']; - } - else - { - $lang_override = $request->variable('language', ''); - if ($lang_override) - { - $this->set_cookie('lang', $lang_override, 0, false); - } - else - { - $lang_override = $request->variable($config['cookie_name'] . '_lang', '', true, \phpbb\request\request_interface::COOKIE); - } - - if ($lang_override) - { - $use_lang = basename($lang_override); - $user_lang_name = (file_exists($this->lang_path . $use_lang . "/common.$phpEx")) ? $use_lang : basename($config['default_lang']); - $this->data['user_lang'] = $user_lang_name; - } - else - { - $user_lang_name = basename($config['default_lang']); - } - - $user_date_format = $config['default_dateformat']; - $user_timezone = $config['board_timezone']; - - /** - * If a guest user is surfing, we try to guess his/her language first by obtaining the browser language - * If re-enabled we need to make sure only those languages installed are checked - * Commented out so we do not loose the code. - - if ($request->header('Accept-Language')) - { - $accept_lang_ary = explode(',', $request->header('Accept-Language')); - - foreach ($accept_lang_ary as $accept_lang) - { - // Set correct format ... guess full xx_YY form - $accept_lang = substr($accept_lang, 0, 2) . '_' . strtoupper(substr($accept_lang, 3, 2)); - $accept_lang = basename($accept_lang); - - if (file_exists($this->lang_path . $accept_lang . "/common.$phpEx")) - { - $user_lang_name = $config['default_lang'] = $accept_lang; - break; - } - else - { - // No match on xx_YY so try xx - $accept_lang = substr($accept_lang, 0, 2); - $accept_lang = basename($accept_lang); - - if (file_exists($this->lang_path . $accept_lang . "/common.$phpEx")) - { - $user_lang_name = $config['default_lang'] = $accept_lang; - break; - } - } - } - } - */ - } - - $user_data = $this->data; - $lang_set_ext = array(); - - /** - * Event to load language files and modify user data on every page - * - * Note: To load language file with this event, see description - * of lang_set_ext variable. - * - * @event core.user_setup - * @var array user_data Array with user's data row - * @var string user_lang_name Basename of the user's langauge - * @var string user_date_format User's date/time format - * @var string user_timezone User's timezone, should be one of - * http://www.php.net/manual/en/timezones.php - * @var mixed lang_set String or array of language files - * @var array lang_set_ext Array containing entries of format - * array( - * 'ext_name' => (string) [extension name], - * 'lang_set' => (string|array) [language files], - * ) - * For performance reasons, only load translations - * that are absolutely needed globally using this - * event. Use local events otherwise. - * @var mixed style_id Style we are going to display - * @since 3.1.0-a1 - */ - $vars = array( - 'user_data', - 'user_lang_name', - 'user_date_format', - 'user_timezone', - 'lang_set', - 'lang_set_ext', - 'style_id', - ); - extract($phpbb_dispatcher->trigger_event('core.user_setup', compact($vars))); - - $this->data = $user_data; - $this->lang_name = $user_lang_name; - $this->date_format = $user_date_format; - - $this->language->set_user_language($user_lang_name); - - try - { - $this->timezone = new \DateTimeZone($user_timezone); - } - catch (\Exception $e) - { - // If the timezone the user has selected is invalid, we fall back to UTC. - $this->timezone = new \DateTimeZone('UTC'); - } - - $this->add_lang($lang_set); - unset($lang_set); - - foreach ($lang_set_ext as $ext_lang_pair) - { - $this->add_lang_ext($ext_lang_pair['ext_name'], $ext_lang_pair['lang_set']); - } - unset($lang_set_ext); - - $style_request = $request->variable('style', 0); - if ($style_request && (!$config['override_user_style'] || $auth->acl_get('a_styles')) && !defined('ADMIN_START')) - { - global $SID, $_EXTRA_URL; - - $style_id = $style_request; - $SID .= '&style=' . $style_id; - $_EXTRA_URL = array('style=' . $style_id); - } - else - { - // Set up style - $style_id = ($style_id) ? $style_id : ((!$config['override_user_style']) ? $this->data['user_style'] : $config['default_style']); - } - - $sql = 'SELECT * - FROM ' . STYLES_TABLE . " s - WHERE s.style_id = $style_id"; - $result = $db->sql_query($sql, 3600); - $this->style = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - // Fallback to user's standard style - if (!$this->style && $style_id != $this->data['user_style']) - { - $style_id = $this->data['user_style']; - - $sql = 'SELECT * - FROM ' . STYLES_TABLE . " s - WHERE s.style_id = $style_id"; - $result = $db->sql_query($sql, 3600); - $this->style = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - } - - if (!$this->style) - { - trigger_error('NO_STYLE_DATA', E_USER_ERROR); - } - - // Now parse the cfg file and cache it - $parsed_items = $cache->obtain_cfg_items($this->style); - - $check_for = array( - 'pagination_sep' => (string) ', ' - ); - - foreach ($check_for as $key => $default_value) - { - $this->style[$key] = (isset($parsed_items[$key])) ? $parsed_items[$key] : $default_value; - settype($this->style[$key], gettype($default_value)); - - if (is_string($default_value)) - { - $this->style[$key] = htmlspecialchars($this->style[$key]); - } - } - - $template->set_style(); - - $this->img_lang = $this->lang_name; - - // Call phpbb_user_session_handler() in case external application want to "bend" some variables or replace classes... - // After calling it we continue script execution... - phpbb_user_session_handler(); - - /** - * Execute code at the end of user setup - * - * @event core.user_setup_after - * @since 3.1.6-RC1 - */ - $phpbb_dispatcher->dispatch('core.user_setup_after'); - - // If this function got called from the error handler we are finished here. - if (defined('IN_ERROR_HANDLER')) - { - return; - } - - // Disable board if the install/ directory is still present - // For the brave development army we do not care about this, else we need to comment out this everytime we develop locally - if (!defined('DEBUG') && !defined('ADMIN_START') && !defined('IN_INSTALL') && !defined('IN_LOGIN') && file_exists($phpbb_root_path . 'install') && !is_file($phpbb_root_path . 'install')) - { - // Adjust the message slightly according to the permissions - if ($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) - { - $message = 'REMOVE_INSTALL'; - } - else - { - $message = (!empty($config['board_disable_msg'])) ? $config['board_disable_msg'] : 'BOARD_DISABLE'; - } - trigger_error($message); - } - - // Is board disabled and user not an admin or moderator? - if ($config['board_disable'] && !defined('IN_INSTALL') && !defined('IN_LOGIN') && !defined('SKIP_CHECK_DISABLED') && !$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_')) - { - if ($this->data['is_bot']) - { - send_status_line(503, 'Service Unavailable'); - } - - $message = (!empty($config['board_disable_msg'])) ? $config['board_disable_msg'] : 'BOARD_DISABLE'; - trigger_error($message); - } - - // Is load exceeded? - if ($config['limit_load'] && $this->load !== false) - { - if ($this->load > floatval($config['limit_load']) && !defined('IN_LOGIN') && !defined('IN_ADMIN')) - { - // Set board disabled to true to let the admins/mods get the proper notification - $config['board_disable'] = '1'; - - if (!$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_')) - { - if ($this->data['is_bot']) - { - send_status_line(503, 'Service Unavailable'); - } - trigger_error('BOARD_UNAVAILABLE'); - } - } - } - - if (isset($this->data['session_viewonline'])) - { - // Make sure the user is able to hide his session - if (!$this->data['session_viewonline']) - { - // Reset online status if not allowed to hide the session... - if (!$auth->acl_get('u_hideonline')) - { - $sql = 'UPDATE ' . SESSIONS_TABLE . ' - SET session_viewonline = 1 - WHERE session_user_id = ' . $this->data['user_id']; - $db->sql_query($sql); - $this->data['session_viewonline'] = 1; - } - } - else if (!$this->data['user_allow_viewonline']) - { - // the user wants to hide and is allowed to -> cloaking device on. - if ($auth->acl_get('u_hideonline')) - { - $sql = 'UPDATE ' . SESSIONS_TABLE . ' - SET session_viewonline = 0 - WHERE session_user_id = ' . $this->data['user_id']; - $db->sql_query($sql); - $this->data['session_viewonline'] = 0; - } - } - } - - // Does the user need to change their password? If so, redirect to the - // ucp profile reg_details page ... of course do not redirect if we're already in the ucp - if (!defined('IN_ADMIN') && !defined('ADMIN_START') && $config['chg_passforce'] && !empty($this->data['is_registered']) && $auth->acl_get('u_chgpasswd') && $this->data['user_passchg'] < time() - ($config['chg_passforce'] * 86400)) - { - if (strpos($this->page['query_string'], 'mode=reg_details') === false && $this->page['page_name'] != "ucp.$phpEx") - { - redirect(append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=profile&mode=reg_details')); - } - } - - $this->is_setup_flag = true; - - return; - } - - /** - * More advanced language substitution - * Function to mimic sprintf() with the possibility of using phpBB's language system to substitute nullar/singular/plural forms. - * Params are the language key and the parameters to be substituted. - * This function/functionality is inspired by SHS` and Ashe. - * - * Example call: $user->lang('NUM_POSTS_IN_QUEUE', 1); - * - * If the first parameter is an array, the elements are used as keys and subkeys to get the language entry: - * Example: $user->lang(array('datetime', 'AGO'), 1) uses $user->lang['datetime']['AGO'] as language entry. - * - * @deprecated 3.2.0-dev (To be removed 4.0.0) - */ - function lang() - { - $args = func_get_args(); - return call_user_func_array(array($this->language, 'lang'), $args); - } - - /** - * Determine which plural form we should use. - * For some languages this is not as simple as for English. - * - * @param $number int|float The number we want to get the plural case for. Float numbers are floored. - * @param $force_rule mixed False to use the plural rule of the language package - * or an integer to force a certain plural rule - * @return int|bool The plural-case we need to use for the number plural-rule combination, false if $force_rule - * was invalid. - * - * @deprecated: 3.2.0-dev (To be removed: 3.3.0) - */ - function get_plural_form($number, $force_rule = false) - { - return $this->language->get_plural_form($number, $force_rule); - } - - /** - * Add Language Items - use_db and use_help are assigned where needed (only use them to force inclusion) - * - * @param mixed $lang_set specifies the language entries to include - * @param bool $use_db internal variable for recursion, do not use @deprecated 3.2.0-dev (To be removed: 3.3.0) - * @param bool $use_help internal variable for recursion, do not use @deprecated 3.2.0-dev (To be removed: 3.3.0) - * @param string $ext_name The extension to load language from, or empty for core files - * - * Examples: - * - * $lang_set = array('posting', 'help' => 'faq'); - * $lang_set = array('posting', 'viewtopic', 'help' => array('bbcode', 'faq')) - * $lang_set = array(array('posting', 'viewtopic'), 'help' => array('bbcode', 'faq')) - * $lang_set = 'posting' - * $lang_set = array('help' => 'faq', 'db' => array('help:faq', 'posting')) - * - * - * Note: $use_db and $use_help should be removed. The old function was kept for BC purposes, - * so the BC logic is handled here. - * - * @deprecated: 3.2.0-dev (To be removed: 3.3.0) - */ - function add_lang($lang_set, $use_db = false, $use_help = false, $ext_name = '') - { - if (is_array($lang_set)) - { - foreach ($lang_set as $key => $lang_file) - { - // Please do not delete this line. - // We have to force the type here, else [array] language inclusion will not work - $key = (string) $key; - - if ($key == 'db') - { - // This is never used - $this->add_lang($lang_file, true, $use_help, $ext_name); - } - else if ($key == 'help') - { - $this->add_lang($lang_file, $use_db, true, $ext_name); - } - else if (!is_array($lang_file)) - { - $this->set_lang($lang_file, $use_help, $ext_name); - } - else - { - $this->add_lang($lang_file, $use_db, $use_help, $ext_name); - } - } - unset($lang_set); - } - else if ($lang_set) - { - $this->set_lang($lang_set, $use_help, $ext_name); - } - } - - /** - * BC function for loading language files - * - * @deprecated 3.2.0-dev (To be removed: 3.3.0) - */ - private function set_lang($lang_set, $use_help, $ext_name) - { - if (empty($ext_name)) - { - $ext_name = null; - } - - if ($use_help && strpos($lang_set, '/') !== false) - { - $component = dirname($lang_set) . '/help_' . basename($lang_set); - - if ($component[0] === '/') - { - $component = substr($component, 1); - } - } - else - { - $component = (($use_help) ? 'help_' : '') . $lang_set; - } - - $this->language->add_lang($component, $ext_name); - } - - /** - * Add Language Items from an extension - use_db and use_help are assigned where needed (only use them to force inclusion) - * - * @param string $ext_name The extension to load language from, or empty for core files - * @param mixed $lang_set specifies the language entries to include - * @param bool $use_db internal variable for recursion, do not use - * @param bool $use_help internal variable for recursion, do not use - * - * Note: $use_db and $use_help should be removed. Kept for BC purposes. - * - * @deprecated: 3.2.0-dev (To be removed: 3.3.0) - */ - function add_lang_ext($ext_name, $lang_set, $use_db = false, $use_help = false) - { - if ($ext_name === '/') - { - $ext_name = ''; - } - - $this->add_lang($lang_set, $use_db, $use_help, $ext_name); - } - - /** - * Format user date - * - * @param int $gmepoch unix timestamp - * @param string $format date format in date() notation. | used to indicate relative dates, for example |d m Y|, h:i is translated to Today, h:i. - * @param bool $forcedate force non-relative date format. - * - * @return mixed translated date - */ - function format_date($gmepoch, $format = false, $forcedate = false) - { - global $phpbb_dispatcher; - static $utc; - - if (!isset($utc)) - { - $utc = new \DateTimeZone('UTC'); - } - - $format_date_override = false; - $function_arguments = func_get_args(); - /** - * Execute code and/or override format_date() - * - * To override the format_date() function generated value - * set $format_date_override to new return value - * - * @event core.user_format_date_override - * @var DateTimeZone utc Is DateTimeZone in UTC - * @var array function_arguments is array comprising a function's argument list - * @var string format_date_override Shall we return custom format (string) or not (false) - * @since 3.2.1-RC1 - */ - $vars = array('utc', 'function_arguments', 'format_date_override'); - extract($phpbb_dispatcher->trigger_event('core.user_format_date_override', compact($vars))); - - if (!$format_date_override) - { - $time = new $this->datetime($this, '@' . (int) $gmepoch, $utc); - $time->setTimezone($this->timezone); - - return $time->format($format, $forcedate); - } - else - { - return $format_date_override; - } - } - - /** - * Create a \phpbb\datetime object in the context of the current user - * - * @since 3.1 - * @param string $time String in a format accepted by strtotime(). - * @param DateTimeZone $timezone Time zone of the time. - * @return \phpbb\datetime Date time object linked to the current users locale - */ - public function create_datetime($time = 'now', \DateTimeZone $timezone = null) - { - $timezone = $timezone ?: $this->timezone; - return new $this->datetime($this, $time, $timezone); - } - - /** - * Get the UNIX timestamp for a datetime in the users timezone, so we can store it in the database. - * - * @param string $format Format of the entered date/time - * @param string $time Date/time with the timezone applied - * @param DateTimeZone $timezone Timezone of the date/time, falls back to timezone of current user - * @return int Returns the unix timestamp - */ - public function get_timestamp_from_format($format, $time, \DateTimeZone $timezone = null) - { - $timezone = $timezone ?: $this->timezone; - $date = \DateTime::createFromFormat($format, $time, $timezone); - return ($date !== false) ? $date->format('U') : false; - } - - /** - * Get language id currently used by the user - */ - function get_iso_lang_id() - { - global $config, $db; - - if (!empty($this->lang_id)) - { - return $this->lang_id; - } - - if (!$this->lang_name) - { - $this->lang_name = $config['default_lang']; - } - - $sql = 'SELECT lang_id - FROM ' . LANG_TABLE . " - WHERE lang_iso = '" . $db->sql_escape($this->lang_name) . "'"; - $result = $db->sql_query($sql); - $this->lang_id = (int) $db->sql_fetchfield('lang_id'); - $db->sql_freeresult($result); - - return $this->lang_id; - } - - /** - * Get users profile fields - */ - function get_profile_fields($user_id) - { - global $db; - - if (isset($this->profile_fields)) - { - return; - } - - $sql = 'SELECT * - FROM ' . PROFILE_FIELDS_DATA_TABLE . " - WHERE user_id = $user_id"; - $result = $db->sql_query_limit($sql, 1); - $this->profile_fields = (!($row = $db->sql_fetchrow($result))) ? array() : $row; - $db->sql_freeresult($result); - } - - /** - * Specify/Get image - */ - function img($img, $alt = '') - { - $title = ''; - - if ($alt) - { - $alt = $this->language->lang($alt); - $title = ' title="' . $alt . '"'; - } - return '' . $alt . ''; - } - - /** - * Get option bit field from user options. - * - * @param int $key option key, as defined in $keyoptions property. - * @param int $data bit field value to use, or false to use $this->data['user_options'] - * @return bool true if the option is set in the bit field, false otherwise - */ - function optionget($key, $data = false) - { - $var = ($data !== false) ? $data : $this->data['user_options']; - return phpbb_optionget($this->keyoptions[$key], $var); - } - - /** - * Set option bit field for user options. - * - * @param int $key Option key, as defined in $keyoptions property. - * @param bool $value True to set the option, false to clear the option. - * @param int $data Current bit field value, or false to use $this->data['user_options'] - * @return int|bool If $data is false, the bit field is modified and - * written back to $this->data['user_options'], and - * return value is true if the bit field changed and - * false otherwise. If $data is not false, the new - * bitfield value is returned. - */ - function optionset($key, $value, $data = false) - { - $var = ($data !== false) ? $data : $this->data['user_options']; - - $new_var = phpbb_optionset($this->keyoptions[$key], $value, $var); - - if ($data === false) - { - if ($new_var != $var) - { - $this->data['user_options'] = $new_var; - return true; - } - else - { - return false; - } - } - else - { - return $new_var; - } - } - - /** - * Funtion to make the user leave the NEWLY_REGISTERED system group. - * @access public - */ - function leave_newly_registered() - { - if (empty($this->data['user_new'])) - { - return false; - } - - if (!function_exists('remove_newly_registered')) - { - global $phpbb_root_path, $phpEx; - - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - } - if ($group = remove_newly_registered($this->data['user_id'], $this->data)) - { - $this->data['group_id'] = $group; - - } - $this->data['user_permissions'] = ''; - $this->data['user_new'] = 0; - - return true; - } - - /** - * Returns all password protected forum ids the user is currently NOT authenticated for. - * - * @return array Array of forum ids - * @access public - */ - function get_passworded_forums() - { - global $db; - - $sql = 'SELECT f.forum_id, fa.user_id - FROM ' . FORUMS_TABLE . ' f - LEFT JOIN ' . FORUMS_ACCESS_TABLE . " fa - ON (fa.forum_id = f.forum_id - AND fa.session_id = '" . $db->sql_escape($this->session_id) . "') - WHERE f.forum_password <> ''"; - $result = $db->sql_query($sql); - - $forum_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $forum_id = (int) $row['forum_id']; - - if ($row['user_id'] != $this->data['user_id']) - { - $forum_ids[$forum_id] = $forum_id; - } - } - $db->sql_freeresult($result); - - return $forum_ids; - } -} diff --git a/install/update/old/phpbb/user_loader.php b/install/update/old/phpbb/user_loader.php deleted file mode 100644 index 9297450..0000000 --- a/install/update/old/phpbb/user_loader.php +++ /dev/null @@ -1,238 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb; - -/** -* User loader class -* -* This handles loading users from the database and -* storing in them in a temporary cache so we do not -* have to query the same user multiple times in -* different services. -*/ -class user_loader -{ - /** @var \phpbb\db\driver\driver_interface */ - protected $db = null; - - /** @var string */ - protected $phpbb_root_path = null; - - /** @var string */ - protected $php_ext = null; - - /** @var string */ - protected $users_table = null; - - /** - * Users loaded from the DB - * - * @var array Array of user data that we've loaded from the DB - */ - protected $users = array(); - - /** - * User loader constructor - * - * @param \phpbb\db\driver\driver_interface $db A database connection - * @param string $phpbb_root_path Path to the phpbb includes directory. - * @param string $php_ext php file extension - * @param string $users_table The name of the database table (phpbb_users) - */ - public function __construct(\phpbb\db\driver\driver_interface $db, $phpbb_root_path, $php_ext, $users_table) - { - $this->db = $db; - - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - - $this->users_table = $users_table; - } - - /** - * Load user helper - * - * @param array $user_ids - * @param array $ignore_types user types to ignore - */ - public function load_users(array $user_ids, array $ignore_types = array()) - { - $user_ids[] = ANONYMOUS; - - // Make user_ids unique and convert to integer. - $user_ids = array_map('intval', array_unique($user_ids)); - - // Do not load users we already have in $this->users - $user_ids = array_diff($user_ids, array_keys($this->users)); - - if (count($user_ids)) - { - $sql = 'SELECT * - FROM ' . $this->users_table . ' - WHERE ' . $this->db->sql_in_set('user_id', $user_ids) . ' - AND ' . $this->db->sql_in_set('user_type', $ignore_types, true, true); - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - $this->users[$row['user_id']] = $row; - } - $this->db->sql_freeresult($result); - } - } - - /** - * Load a user by username - * - * Stores the full data in the user cache so they do not need to be loaded again - * Returns the user id so you may use get_user() from the returned value - * - * @param string $username Raw username to load (will be cleaned) - * @return int User ID for the username - */ - public function load_user_by_username($username) - { - $sql = 'SELECT * - FROM ' . $this->users_table . " - WHERE username_clean = '" . $this->db->sql_escape(utf8_clean_string($username)) . "'"; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if ($row) - { - $this->users[$row['user_id']] = $row; - - return $row['user_id']; - } - - return ANONYMOUS; - } - - /** - * Get a user row from our users cache - * - * @param int $user_id User ID of the user you want to retreive - * @param bool $query Should we query the database if this user has not yet been loaded? - * Typically this should be left as false and you should make sure - * you load users ahead of time with load_users() - * @return array|bool Row from the database of the user or Anonymous if the user wasn't loaded/does not exist - * or bool False if the anonymous user was not loaded - */ - public function get_user($user_id, $query = false) - { - if (isset($this->users[$user_id])) - { - return $this->users[$user_id]; - } - // Query them if we must (if ANONYMOUS is sent as the user_id and we have not loaded Anonymous yet, we must load Anonymous as a last resort) - else if ($query || $user_id == ANONYMOUS) - { - $this->load_users(array($user_id)); - - return $this->get_user($user_id); - } - - return $this->get_user(ANONYMOUS); - } - - /** - * Get username - * - * @param int $user_id User ID of the user you want to retreive the username for - * @param string $mode The mode to load (same as get_username_string). One of the following: - * profile (for getting an url to the profile) - * username (for obtaining the username) - * colour (for obtaining the user colour) - * full (for obtaining a html string representing a coloured link to the users profile) - * no_profile (the same as full but forcing no profile link) - * @param string $guest_username Optional parameter to specify the guest username. It will be used in favor of the GUEST language variable then. - * @param string $custom_profile_url Optional parameter to specify a profile url. The user id get appended to this url as &u={user_id} - * @param bool $query Should we query the database if this user has not yet been loaded? - * Typically this should be left as false and you should make sure - * you load users ahead of time with load_users() - * @return string - */ - public function get_username($user_id, $mode, $guest_username = false, $custom_profile_url = false, $query = false) - { - if (!($user = $this->get_user($user_id, $query))) - { - return ''; - } - - return get_username_string($mode, $user['user_id'], $user['username'], $user['user_colour'], $guest_username, $custom_profile_url); - } - - /** - * Get avatar - * - * @param int $user_id User ID of the user you want to retrieve the avatar for - * @param bool $query Should we query the database if this user has not yet been loaded? - * Typically this should be left as false and you should make sure - * you load users ahead of time with load_users() - * @param bool @lazy If true, will be lazy loaded (requires JS) - * @return string - */ - public function get_avatar($user_id, $query = false, $lazy = false) - { - if (!($user = $this->get_user($user_id, $query))) - { - return ''; - } - - $row = array( - 'avatar' => $user['user_avatar'], - 'avatar_type' => $user['user_avatar_type'], - 'avatar_width' => $user['user_avatar_width'], - 'avatar_height' => $user['user_avatar_height'], - ); - - return phpbb_get_avatar($row, 'USER_AVATAR', false, $lazy); - } - - /** - * Get rank - * - * @param int $user_id User ID of the user you want to retreive the rank for - * @param bool $query Should we query the database if this user has not yet been loaded? - * Typically this should be left as false and you should make sure - * you load users ahead of time with load_users() - * @return array Array with keys 'rank_title', 'rank_img', and 'rank_img_src' - */ - public function get_rank($user_id, $query = false) - { - if (!($user = $this->get_user($user_id, $query))) - { - return ''; - } - - if (!function_exists('phpbb_get_user_rank')) - { - include($this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext); - } - - $rank = array( - 'rank_title', - 'rank_img', - 'rank_img_src', - ); - - $user_rank_data = phpbb_get_user_rank($user, (($user['user_id'] == ANONYMOUS) ? false : $user['user_posts'])); - $rank['rank_title'] = $user_rank_data['title']; - $rank['rank_img'] = $user_rank_data['img']; - $rank['rank_img_src'] = $user_rank_data['img_src']; - - return $rank; - } -} diff --git a/install/update/old/posting.php b/install/update/old/posting.php deleted file mode 100644 index 75085a5..0000000 --- a/install/update/old/posting.php +++ /dev/null @@ -1,1990 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -define('IN_PHPBB', true); -$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); -include($phpbb_root_path . 'common.' . $phpEx); -include($phpbb_root_path . 'includes/functions_posting.' . $phpEx); -include($phpbb_root_path . 'includes/functions_display.' . $phpEx); -include($phpbb_root_path . 'includes/message_parser.' . $phpEx); - - -// Start session management -$user->session_begin(); -$auth->acl($user->data); - - -// Grab only parameters needed here -$post_id = $request->variable('p', 0); -$topic_id = $request->variable('t', 0); -$forum_id = $request->variable('f', 0); -$draft_id = $request->variable('d', 0); - -$preview = (isset($_POST['preview'])) ? true : false; -$save = (isset($_POST['save'])) ? true : false; -$load = (isset($_POST['load'])) ? true : false; -$confirm = $request->is_set_post('confirm'); -$cancel = (isset($_POST['cancel']) && !isset($_POST['save'])) ? true : false; - -$refresh = (isset($_POST['add_file']) || isset($_POST['delete_file']) || isset($_POST['cancel_unglobalise']) || $save || $load || $preview); -$submit = $request->is_set_post('post') && !$refresh && !$preview; -$mode = $request->variable('mode', ''); - -// If the user is not allowed to delete the post, we try to soft delete it, so we overwrite the mode here. -if ($mode == 'delete' && (($confirm && !$request->is_set_post('delete_permanent')) || !$auth->acl_gets('f_delete', 'm_delete', $forum_id))) -{ - $mode = 'soft_delete'; -} - -$error = $post_data = array(); -$current_time = time(); - -/** -* This event allows you to alter the above parameters, such as submit and mode -* -* Note: $refresh must be true to retain previously submitted form data. -* -* Note: The template class will not work properly until $user->setup() is -* called, and it has not been called yet. Extensions requiring template -* assignments should use an event that comes later in this file. -* -* @event core.modify_posting_parameters -* @var int post_id ID of the post -* @var int topic_id ID of the topic -* @var int forum_id ID of the forum -* @var int draft_id ID of the draft -* @var bool submit Whether or not the form has been submitted -* @var bool preview Whether or not the post is being previewed -* @var bool save Whether or not a draft is being saved -* @var bool load Whether or not a draft is being loaded -* @var bool cancel Whether or not to cancel the form (returns to -* viewtopic or viewforum depending on if the user -* is posting a new topic or editing a post) -* @var bool refresh Whether or not to retain previously submitted data -* @var string mode What action to take if the form has been submitted -* post|reply|quote|edit|delete|bump|smilies|popup -* @var array error Any error strings; a non-empty array aborts -* form submission. -* NOTE: Should be actual language strings, NOT -* language keys. -* @since 3.1.0-a1 -* @changed 3.1.2-RC1 Removed 'delete' var as it does not exist -* @changed 3.2.4-RC1 Remove unused 'lastclick' var -*/ -$vars = array( - 'post_id', - 'topic_id', - 'forum_id', - 'draft_id', - 'submit', - 'preview', - 'save', - 'load', - 'cancel', - 'refresh', - 'mode', - 'error', -); -extract($phpbb_dispatcher->trigger_event('core.modify_posting_parameters', compact($vars))); - -// Was cancel pressed? If so then redirect to the appropriate page -if ($cancel) -{ - $f = ($forum_id) ? 'f=' . $forum_id . '&' : ''; - $redirect = ($post_id) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", $f . 'p=' . $post_id) . '#p' . $post_id : (($topic_id) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", $f . 't=' . $topic_id) : (($forum_id) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id) : append_sid("{$phpbb_root_path}index.$phpEx"))); - redirect($redirect); -} - -if (in_array($mode, array('post', 'reply', 'quote', 'edit', 'delete')) && !$forum_id) -{ - trigger_error('NO_FORUM'); -} - -/* @var $phpbb_content_visibility \phpbb\content_visibility */ -$phpbb_content_visibility = $phpbb_container->get('content.visibility'); - -// We need to know some basic information in all cases before we do anything. -switch ($mode) -{ - case 'post': - $sql = 'SELECT * - FROM ' . FORUMS_TABLE . " - WHERE forum_id = $forum_id"; - break; - - case 'bump': - case 'reply': - if (!$topic_id) - { - trigger_error('NO_TOPIC'); - } - - // Force forum id - $sql = 'SELECT forum_id - FROM ' . TOPICS_TABLE . ' - WHERE topic_id = ' . $topic_id; - $result = $db->sql_query($sql); - $f_id = (int) $db->sql_fetchfield('forum_id'); - $db->sql_freeresult($result); - - $forum_id = (!$f_id) ? $forum_id : $f_id; - - $sql = 'SELECT f.*, t.* - FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f - WHERE t.topic_id = $topic_id - AND f.forum_id = t.forum_id - AND " . $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.'); - break; - - case 'quote': - case 'edit': - case 'delete': - case 'soft_delete': - if (!$post_id) - { - $user->setup('posting'); - trigger_error('NO_POST'); - } - - // Force forum id - $sql = 'SELECT forum_id - FROM ' . POSTS_TABLE . ' - WHERE post_id = ' . $post_id; - $result = $db->sql_query($sql); - $f_id = (int) $db->sql_fetchfield('forum_id'); - $db->sql_freeresult($result); - - $forum_id = (!$f_id) ? $forum_id : $f_id; - - $sql = 'SELECT f.*, t.*, p.*, u.username, u.username_clean, u.user_sig, u.user_sig_bbcode_uid, u.user_sig_bbcode_bitfield - FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . ' f, ' . USERS_TABLE . " u - WHERE p.post_id = $post_id - AND t.topic_id = p.topic_id - AND u.user_id = p.poster_id - AND f.forum_id = t.forum_id - AND " . $phpbb_content_visibility->get_visibility_sql('post', $forum_id, 'p.'); - break; - - case 'smilies': - $sql = ''; - generate_smilies('window', $forum_id); - break; - - case 'popup': - if ($forum_id) - { - $sql = 'SELECT forum_style - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . $forum_id; - } - else - { - phpbb_upload_popup(); - return; - } - break; - - default: - $sql = ''; - break; -} - -if (!$sql) -{ - $user->setup('posting'); - trigger_error('NO_POST_MODE'); -} - -$result = $db->sql_query($sql); -$post_data = $db->sql_fetchrow($result); -$db->sql_freeresult($result); - -if (!$post_data) -{ - if (!($mode == 'post' || $mode == 'bump' || $mode == 'reply')) - { - $user->setup('posting'); - } - trigger_error(($mode == 'post' || $mode == 'bump' || $mode == 'reply') ? 'NO_TOPIC' : 'NO_POST'); -} - -// Not able to reply to unapproved posts/topics -// TODO: add more descriptive language key -if ($auth->acl_get('m_approve', $forum_id) && ((($mode == 'reply' || $mode == 'bump') && $post_data['topic_visibility'] != ITEM_APPROVED) || ($mode == 'quote' && $post_data['post_visibility'] != ITEM_APPROVED))) -{ - trigger_error(($mode == 'reply' || $mode == 'bump') ? 'TOPIC_UNAPPROVED' : 'POST_UNAPPROVED'); -} - -if ($mode == 'popup') -{ - phpbb_upload_popup($post_data['forum_style']); - return; -} - -$user->setup(array('posting', 'mcp', 'viewtopic'), $post_data['forum_style']); - -if ($config['enable_post_confirm'] && !$user->data['is_registered']) -{ - $captcha = $phpbb_container->get('captcha.factory')->get_instance($config['captcha_plugin']); - $captcha->init(CONFIRM_POST); -} - -// Use post_row values in favor of submitted ones... -$forum_id = (!empty($post_data['forum_id'])) ? (int) $post_data['forum_id'] : (int) $forum_id; -$topic_id = (!empty($post_data['topic_id'])) ? (int) $post_data['topic_id'] : (int) $topic_id; -$post_id = (!empty($post_data['post_id'])) ? (int) $post_data['post_id'] : (int) $post_id; - -// Need to login to passworded forum first? -if ($post_data['forum_password']) -{ - login_forum_box(array( - 'forum_id' => $forum_id, - 'forum_name' => $post_data['forum_name'], - 'forum_password' => $post_data['forum_password']) - ); -} - -// Check permissions -if ($user->data['is_bot']) -{ - redirect(append_sid("{$phpbb_root_path}index.$phpEx")); -} - -// Is the user able to read within this forum? -if (!$auth->acl_get('f_read', $forum_id)) -{ - if ($user->data['user_id'] != ANONYMOUS) - { - trigger_error('USER_CANNOT_READ'); - } - $message = $user->lang['LOGIN_EXPLAIN_POST']; - - if ($request->is_ajax()) - { - $json = new phpbb\json_response(); - $json->send(array( - 'title' => $user->lang['INFORMATION'], - 'message' => $message, - )); - } - - login_box('', $message); -} - -// Permission to do the action asked? -$is_authed = false; - -switch ($mode) -{ - case 'post': - if ($auth->acl_get('f_post', $forum_id)) - { - $is_authed = true; - } - break; - - case 'bump': - if ($auth->acl_get('f_bump', $forum_id)) - { - $is_authed = true; - } - break; - - case 'quote': - - $post_data['post_edit_locked'] = 0; - - // no break; - - case 'reply': - if ($auth->acl_get('f_reply', $forum_id)) - { - $is_authed = true; - } - break; - - case 'edit': - if ($user->data['is_registered'] && $auth->acl_gets('f_edit', 'm_edit', $forum_id)) - { - $is_authed = true; - } - break; - - case 'delete': - if ($user->data['is_registered'] && ($auth->acl_get('m_delete', $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)))) - { - $is_authed = true; - } - - // no break; - - case 'soft_delete': - if (!$is_authed && $user->data['is_registered'] && $phpbb_content_visibility->can_soft_delete($forum_id, $post_data['poster_id'], $post_data['post_edit_locked'])) - { - // Fall back to soft_delete if we have no permissions to delete posts but to soft delete them - $is_authed = true; - $mode = 'soft_delete'; - } - break; -} -/** -* This event allows you to do extra auth checks and verify if the user -* has the required permissions -* -* Extensions should only change the error and is_authed variables. -* -* @event core.modify_posting_auth -* @var int post_id ID of the post -* @var int topic_id ID of the topic -* @var int forum_id ID of the forum -* @var int draft_id ID of the draft -* @var bool submit Whether or not the form has been submitted -* @var bool preview Whether or not the post is being previewed -* @var bool save Whether or not a draft is being saved -* @var bool load Whether or not a draft is being loaded -* @var bool refresh Whether or not to retain previously submitted data -* @var string mode What action to take if the form has been submitted -* post|reply|quote|edit|delete|bump|smilies|popup -* @var array error Any error strings; a non-empty array aborts -* form submission. -* NOTE: Should be actual language strings, NOT -* language keys. -* @var bool is_authed Does the user have the required permissions? -* @var array post_data All post data from database -* @since 3.1.3-RC1 -* @changed 3.1.10-RC1 Added post_data -* @changed 3.2.4-RC1 Remove unused 'lastclick' var -*/ -$vars = array( - 'post_id', - 'topic_id', - 'forum_id', - 'draft_id', - 'submit', - 'preview', - 'save', - 'load', - 'refresh', - 'mode', - 'error', - 'is_authed', - 'post_data', -); -extract($phpbb_dispatcher->trigger_event('core.modify_posting_auth', compact($vars))); - -if (!$is_authed || !empty($error)) -{ - $check_auth = ($mode == 'quote') ? 'reply' : (($mode == 'soft_delete') ? 'delete' : $mode); - - if ($user->data['is_registered']) - { - trigger_error(empty($error) ? 'USER_CANNOT_' . strtoupper($check_auth) : implode('
', $error)); - } - $message = $user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)]; - - if ($request->is_ajax()) - { - $json = new phpbb\json_response(); - $json->send(array( - 'title' => $user->lang['INFORMATION'], - 'message' => $message, - )); - } - - login_box('', $message); -} - -// Is the user able to post within this forum? -if ($post_data['forum_type'] != FORUM_POST && in_array($mode, array('post', 'bump', 'quote', 'reply'))) -{ - trigger_error('USER_CANNOT_FORUM_POST'); -} - -// Forum/Topic locked? -if (($post_data['forum_status'] == ITEM_LOCKED || (isset($post_data['topic_status']) && $post_data['topic_status'] == ITEM_LOCKED)) && !$auth->acl_get('m_edit', $forum_id)) -{ - trigger_error(($post_data['forum_status'] == ITEM_LOCKED) ? 'FORUM_LOCKED' : 'TOPIC_LOCKED'); -} - -// Can we edit this post ... if we're a moderator with rights then always yes -// else it depends on editing times, lock status and if we're the correct user -if ($mode == 'edit' && !$auth->acl_get('m_edit', $forum_id)) -{ - $force_edit_allowed = false; - - $s_cannot_edit = $user->data['user_id'] != $post_data['poster_id']; - $s_cannot_edit_time = $config['edit_time'] && $post_data['post_time'] <= time() - ($config['edit_time'] * 60); - $s_cannot_edit_locked = $post_data['post_edit_locked']; - - /** - * This event allows you to modify the conditions for the "cannot edit post" checks - * - * @event core.posting_modify_cannot_edit_conditions - * @var array post_data Array with post data - * @var bool force_edit_allowed Allow the user to edit the post (all permissions and conditions are ignored) - * @var bool s_cannot_edit User can not edit the post because it's not his - * @var bool s_cannot_edit_locked User can not edit the post because it's locked - * @var bool s_cannot_edit_time User can not edit the post because edit_time has passed - * @since 3.1.0-b4 - */ - $vars = array( - 'post_data', - 'force_edit_allowed', - 's_cannot_edit', - 's_cannot_edit_locked', - 's_cannot_edit_time', - ); - extract($phpbb_dispatcher->trigger_event('core.posting_modify_cannot_edit_conditions', compact($vars))); - - if (!$force_edit_allowed) - { - if ($s_cannot_edit) - { - trigger_error('USER_CANNOT_EDIT'); - } - else if ($s_cannot_edit_time) - { - trigger_error('CANNOT_EDIT_TIME'); - } - else if ($s_cannot_edit_locked) - { - trigger_error('CANNOT_EDIT_POST_LOCKED'); - } - } -} - -// Handle delete mode... -if ($mode == 'delete' || $mode == 'soft_delete') -{ - if ($mode == 'soft_delete' && $post_data['post_visibility'] == ITEM_DELETED) - { - $user->setup('posting'); - trigger_error('NO_POST'); - } - - $delete_reason = $request->variable('delete_reason', '', true); - phpbb_handle_post_delete($forum_id, $topic_id, $post_id, $post_data, ($mode == 'soft_delete' && !$request->is_set_post('delete_permanent')), $delete_reason); - return; -} - -// Handle bump mode... -if ($mode == 'bump') -{ - if ($bump_time = bump_topic_allowed($forum_id, $post_data['topic_bumped'], $post_data['topic_last_post_time'], $post_data['topic_poster'], $post_data['topic_last_poster_id']) - && check_link_hash($request->variable('hash', ''), "topic_{$post_data['topic_id']}")) - { - $meta_url = phpbb_bump_topic($forum_id, $topic_id, $post_data, $current_time); - meta_refresh(3, $meta_url); - $message = $user->lang['TOPIC_BUMPED']; - - if (!$request->is_ajax()) - { - $message .= '

' . $user->lang('VIEW_MESSAGE', '', ''); - $message .= '

' . $user->lang('RETURN_FORUM', '', ''); - } - - trigger_error($message); - } - - trigger_error('BUMP_ERROR'); -} - -// Subject length limiting to 60 characters if first post... -if ($mode == 'post' || ($mode == 'edit' && $post_data['topic_first_post_id'] == $post_data['post_id'])) -{ - $template->assign_var('S_NEW_MESSAGE', true); -} - -// Determine some vars -if (isset($post_data['poster_id']) && $post_data['poster_id'] == ANONYMOUS) -{ - $post_data['quote_username'] = (!empty($post_data['post_username'])) ? $post_data['post_username'] : $user->lang['GUEST']; -} -else -{ - $post_data['quote_username'] = isset($post_data['username']) ? $post_data['username'] : ''; -} - -$post_data['post_edit_locked'] = (isset($post_data['post_edit_locked'])) ? (int) $post_data['post_edit_locked'] : 0; -$post_data['post_subject_md5'] = (isset($post_data['post_subject']) && $mode == 'edit') ? md5($post_data['post_subject']) : ''; -$post_data['post_subject'] = (in_array($mode, array('quote', 'edit'))) ? $post_data['post_subject'] : ((isset($post_data['topic_title'])) ? $post_data['topic_title'] : ''); -$post_data['topic_time_limit'] = (isset($post_data['topic_time_limit'])) ? (($post_data['topic_time_limit']) ? (int) $post_data['topic_time_limit'] / 86400 : (int) $post_data['topic_time_limit']) : 0; -$post_data['poll_length'] = (!empty($post_data['poll_length'])) ? (int) $post_data['poll_length'] / 86400 : 0; -$post_data['poll_start'] = (!empty($post_data['poll_start'])) ? (int) $post_data['poll_start'] : 0; -$post_data['icon_id'] = (!isset($post_data['icon_id']) || in_array($mode, array('quote', 'reply'))) ? 0 : (int) $post_data['icon_id']; -$post_data['poll_options'] = array(); - -// Get Poll Data -if ($post_data['poll_start']) -{ - $sql = 'SELECT poll_option_text - FROM ' . POLL_OPTIONS_TABLE . " - WHERE topic_id = $topic_id - ORDER BY poll_option_id"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $post_data['poll_options'][] = trim($row['poll_option_text']); - } - $db->sql_freeresult($result); -} - -/** -* This event allows you to modify the post data before parsing -* -* @event core.posting_modify_post_data -* @var int forum_id ID of the forum -* @var string mode What action to take if the form has been submitted -* post|reply|quote|edit|delete|bump|smilies|popup -* @var array post_data Array with post data -* @var int post_id ID of the post -* @var int topic_id ID of the topic -* @since 3.2.2-RC1 -*/ -$vars = array( - 'forum_id', - 'mode', - 'post_data', - 'post_id', - 'topic_id', -); -extract($phpbb_dispatcher->trigger_event('core.posting_modify_post_data', compact($vars))); - -if ($mode == 'edit') -{ - $original_poll_data = array( - 'poll_title' => $post_data['poll_title'], - 'poll_length' => $post_data['poll_length'], - 'poll_max_options' => $post_data['poll_max_options'], - 'poll_option_text' => implode("\n", $post_data['poll_options']), - 'poll_start' => $post_data['poll_start'], - 'poll_last_vote' => $post_data['poll_last_vote'], - 'poll_vote_change' => $post_data['poll_vote_change'], - ); -} - -$orig_poll_options_size = count($post_data['poll_options']); - -$message_parser = new parse_message(); -/* @var $plupload \phpbb\plupload\plupload */ -$plupload = $phpbb_container->get('plupload'); - -/* @var $mimetype_guesser \phpbb\mimetype\guesser */ -$mimetype_guesser = $phpbb_container->get('mimetype.guesser'); -$message_parser->set_plupload($plupload); - -if (isset($post_data['post_text'])) -{ - $message_parser->message = &$post_data['post_text']; - unset($post_data['post_text']); -} - -// Set some default variables -$uninit = array('post_attachment' => 0, 'poster_id' => $user->data['user_id'], 'enable_magic_url' => 0, 'topic_status' => 0, 'topic_type' => POST_NORMAL, 'post_subject' => '', 'topic_title' => '', 'post_time' => 0, 'post_edit_reason' => '', 'notify_set' => 0); - -/** -* This event allows you to modify the default variables for post_data, and unset them in post_data if needed -* -* @event core.posting_modify_default_variables -* @var array post_data Array with post data -* @var array uninit Array with default vars to put into post_data, if they aren't there -* @since 3.2.5-RC1 -*/ -$vars = array( - 'post_data', - 'uninit', -); -extract($phpbb_dispatcher->trigger_event('core.posting_modify_default_variables', compact($vars))); - -foreach ($uninit as $var_name => $default_value) -{ - if (!isset($post_data[$var_name])) - { - $post_data[$var_name] = $default_value; - } -} -unset($uninit); - -// Always check if the submitted attachment data is valid and belongs to the user. -// Further down (especially in submit_post()) we do not check this again. -$message_parser->get_submitted_attachment_data($post_data['poster_id']); - -if ($post_data['post_attachment'] && !$submit && !$refresh && !$preview && $mode == 'edit') -{ - // Do not change to SELECT * - $sql = 'SELECT attach_id, is_orphan, attach_comment, real_filename, filesize - FROM ' . ATTACHMENTS_TABLE . " - WHERE post_msg_id = $post_id - AND in_message = 0 - AND is_orphan = 0 - ORDER BY attach_id DESC"; - $result = $db->sql_query($sql); - $message_parser->attachment_data = array_merge($message_parser->attachment_data, $db->sql_fetchrowset($result)); - $db->sql_freeresult($result); -} - -if ($post_data['poster_id'] == ANONYMOUS) -{ - $post_data['username'] = ($mode == 'quote' || $mode == 'edit') ? trim($post_data['post_username']) : ''; -} -else -{ - $post_data['username'] = ($mode == 'quote' || $mode == 'edit') ? trim($post_data['username']) : ''; -} - -$post_data['enable_urls'] = $post_data['enable_magic_url']; - -if ($mode != 'edit') -{ - $post_data['enable_sig'] = ($config['allow_sig'] && $user->optionget('attachsig')) ? true: false; - $post_data['enable_smilies'] = ($config['allow_smilies'] && $user->optionget('smilies')) ? true : false; - $post_data['enable_bbcode'] = ($config['allow_bbcode'] && $user->optionget('bbcode')) ? true : false; - $post_data['enable_urls'] = true; -} - -if ($mode == 'post') -{ - $post_data['topic_status'] = ($request->is_set_post('lock_topic') && $auth->acl_gets('m_lock', 'f_user_lock', $forum_id)) ? ITEM_LOCKED : ITEM_UNLOCKED; -} - -$post_data['enable_magic_url'] = $post_data['drafts'] = false; - -// User own some drafts? -if ($user->data['is_registered'] && $auth->acl_get('u_savedrafts') && ($mode == 'reply' || $mode == 'post' || $mode == 'quote')) -{ - $sql = 'SELECT draft_id - FROM ' . DRAFTS_TABLE . ' - WHERE user_id = ' . $user->data['user_id'] . - (($forum_id) ? ' AND forum_id = ' . (int) $forum_id : '') . - (($topic_id) ? ' AND topic_id = ' . (int) $topic_id : '') . - (($draft_id) ? " AND draft_id <> $draft_id" : ''); - $result = $db->sql_query_limit($sql, 1); - - if ($db->sql_fetchrow($result)) - { - $post_data['drafts'] = true; - } - $db->sql_freeresult($result); -} - -$check_value = (($post_data['enable_bbcode']+1) << 8) + (($post_data['enable_smilies']+1) << 4) + (($post_data['enable_urls']+1) << 2) + (($post_data['enable_sig']+1) << 1); - -// Check if user is watching this topic -if ($mode != 'post' && $config['allow_topic_notify'] && $user->data['is_registered']) -{ - $sql = 'SELECT topic_id - FROM ' . TOPICS_WATCH_TABLE . ' - WHERE topic_id = ' . $topic_id . ' - AND user_id = ' . $user->data['user_id']; - $result = $db->sql_query($sql); - $post_data['notify_set'] = (int) $db->sql_fetchfield('topic_id'); - $db->sql_freeresult($result); -} - -// Do we want to edit our post ? -if ($mode == 'edit' && $post_data['bbcode_uid']) -{ - $message_parser->bbcode_uid = $post_data['bbcode_uid']; -} - -// HTML, BBCode, Smilies, Images and Flash status -$bbcode_status = ($config['allow_bbcode'] && $auth->acl_get('f_bbcode', $forum_id)) ? true : false; -$smilies_status = ($config['allow_smilies'] && $auth->acl_get('f_smilies', $forum_id)) ? true : false; -$img_status = ($bbcode_status && $auth->acl_get('f_img', $forum_id)) ? true : false; -$url_status = ($config['allow_post_links']) ? true : false; -$flash_status = ($bbcode_status && $auth->acl_get('f_flash', $forum_id) && $config['allow_post_flash']) ? true : false; -$quote_status = true; - -// Save Draft -if ($save && $user->data['is_registered'] && $auth->acl_get('u_savedrafts') && ($mode == 'reply' || $mode == 'post' || $mode == 'quote')) -{ - $subject = $request->variable('subject', '', true); - $subject = (!$subject && $mode != 'post') ? $post_data['topic_title'] : $subject; - $message = $request->variable('message', '', true); - - if ($subject && $message) - { - if (confirm_box(true)) - { - $message_parser->message = $message; - $message_parser->parse($post_data['enable_bbcode'], ($config['allow_post_links']) ? $post_data['enable_urls'] : false, $post_data['enable_smilies'], $img_status, $flash_status, $quote_status, $config['allow_post_links']); - - $sql = 'INSERT INTO ' . DRAFTS_TABLE . ' ' . $db->sql_build_array('INSERT', array( - 'user_id' => (int) $user->data['user_id'], - 'topic_id' => (int) $topic_id, - 'forum_id' => (int) $forum_id, - 'save_time' => (int) $current_time, - 'draft_subject' => (string) $subject, - 'draft_message' => (string) $message_parser->message) - ); - $db->sql_query($sql); - - $meta_info = ($mode == 'post') ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id) : append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id"); - - meta_refresh(3, $meta_info); - - $message = $user->lang['DRAFT_SAVED'] . '

'; - $message .= ($mode != 'post') ? sprintf($user->lang['RETURN_TOPIC'], '', '') . '

' : ''; - $message .= sprintf($user->lang['RETURN_FORUM'], '', ''); - - trigger_error($message); - } - else - { - $s_hidden_fields = build_hidden_fields(array( - 'mode' => $mode, - 'save' => true, - 'f' => $forum_id, - 't' => $topic_id, - 'subject' => $subject, - 'message' => $message, - 'attachment_data' => $message_parser->attachment_data, - ) - ); - - $hidden_fields = array( - 'icon_id' => 0, - - 'disable_bbcode' => false, - 'disable_smilies' => false, - 'disable_magic_url' => false, - 'attach_sig' => true, - 'lock_topic' => false, - - 'topic_type' => POST_NORMAL, - 'topic_time_limit' => 0, - - 'poll_title' => '', - 'poll_option_text' => '', - 'poll_max_options' => 1, - 'poll_length' => 0, - 'poll_vote_change' => false, - ); - - foreach ($hidden_fields as $name => $default) - { - if (!isset($_POST[$name])) - { - // Don't include it, if its not available - unset($hidden_fields[$name]); - continue; - } - - if (is_bool($default)) - { - // Use the string representation - $hidden_fields[$name] = $request->variable($name, ''); - } - else - { - $hidden_fields[$name] = $request->variable($name, $default); - } - } - - $s_hidden_fields .= build_hidden_fields($hidden_fields); - - confirm_box(false, 'SAVE_DRAFT', $s_hidden_fields); - } - } - else - { - if (utf8_clean_string($subject) === '') - { - $error[] = $user->lang['EMPTY_SUBJECT']; - } - - if (utf8_clean_string($message) === '') - { - $error[] = $user->lang['TOO_FEW_CHARS']; - } - } - unset($subject, $message); -} - -// Load requested Draft -if ($draft_id && ($mode == 'reply' || $mode == 'quote' || $mode == 'post') && $user->data['is_registered'] && $auth->acl_get('u_savedrafts')) -{ - $sql = 'SELECT draft_subject, draft_message - FROM ' . DRAFTS_TABLE . " - WHERE draft_id = $draft_id - AND user_id = " . $user->data['user_id']; - $result = $db->sql_query_limit($sql, 1); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - $post_data['post_subject'] = $row['draft_subject']; - $message_parser->message = $row['draft_message']; - - $template->assign_var('S_DRAFT_LOADED', true); - } - else - { - $draft_id = 0; - } -} - -// Load draft overview -if ($load && ($mode == 'reply' || $mode == 'quote' || $mode == 'post') && $post_data['drafts']) -{ - load_drafts($topic_id, $forum_id); -} - -/** @var \phpbb\textformatter\utils_interface $bbcode_utils */ -$bbcode_utils = $phpbb_container->get('text_formatter.utils'); - -if ($submit || $preview || $refresh) -{ - $post_data['topic_cur_post_id'] = $request->variable('topic_cur_post_id', 0); - $post_data['post_subject'] = $request->variable('subject', '', true); - $message_parser->message = $request->variable('message', '', true); - - $post_data['username'] = $request->variable('username', $post_data['username'], true); - $post_data['post_edit_reason'] = ($request->variable('edit_reason', false, false, \phpbb\request\request_interface::POST) && $mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? $request->variable('edit_reason', '', true) : ''; - - $post_data['orig_topic_type'] = $post_data['topic_type']; - $post_data['topic_type'] = $request->variable('topic_type', (($mode != 'post') ? (int) $post_data['topic_type'] : POST_NORMAL)); - $post_data['topic_time_limit'] = $request->variable('topic_time_limit', (($mode != 'post') ? (int) $post_data['topic_time_limit'] : 0)); - - if ($post_data['enable_icons'] && $auth->acl_get('f_icons', $forum_id)) - { - $post_data['icon_id'] = $request->variable('icon', (int) $post_data['icon_id']); - } - - $post_data['enable_bbcode'] = (!$bbcode_status || isset($_POST['disable_bbcode'])) ? false : true; - $post_data['enable_smilies'] = (!$smilies_status || isset($_POST['disable_smilies'])) ? false : true; - $post_data['enable_urls'] = (isset($_POST['disable_magic_url'])) ? 0 : 1; - $post_data['enable_sig'] = (!$config['allow_sig'] || !$auth->acl_get('f_sigs', $forum_id) || !$auth->acl_get('u_sig')) ? false : ((isset($_POST['attach_sig']) && $user->data['is_registered']) ? true : false); - - if ($config['allow_topic_notify'] && $user->data['is_registered']) - { - $notify = (isset($_POST['notify'])) ? true : false; - } - else - { - $notify = false; - } - - $topic_lock = (isset($_POST['lock_topic'])) ? true : false; - $post_lock = (isset($_POST['lock_post'])) ? true : false; - $poll_delete = (isset($_POST['poll_delete'])) ? true : false; - - if ($submit) - { - $status_switch = (($post_data['enable_bbcode']+1) << 8) + (($post_data['enable_smilies']+1) << 4) + (($post_data['enable_urls']+1) << 2) + (($post_data['enable_sig']+1) << 1); - $status_switch = ($status_switch != $check_value); - } - else - { - $status_switch = 1; - } - - // Delete Poll - if ($poll_delete && $mode == 'edit' && count($post_data['poll_options']) && - ((!$post_data['poll_last_vote'] && $post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) || $auth->acl_get('m_delete', $forum_id))) - { - if ($submit && check_form_key('posting')) - { - $sql = 'DELETE FROM ' . POLL_OPTIONS_TABLE . " - WHERE topic_id = $topic_id"; - $db->sql_query($sql); - - $sql = 'DELETE FROM ' . POLL_VOTES_TABLE . " - WHERE topic_id = $topic_id"; - $db->sql_query($sql); - - $topic_sql = array( - 'poll_title' => '', - 'poll_start' => 0, - 'poll_length' => 0, - 'poll_last_vote' => 0, - 'poll_max_options' => 0, - 'poll_vote_change' => 0 - ); - - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $topic_sql) . " - WHERE topic_id = $topic_id"; - $db->sql_query($sql); - } - - $post_data['poll_title'] = $post_data['poll_option_text'] = ''; - $post_data['poll_vote_change'] = $post_data['poll_max_options'] = $post_data['poll_length'] = 0; - } - else - { - $post_data['poll_title'] = $request->variable('poll_title', '', true); - $post_data['poll_length'] = $request->variable('poll_length', 0); - $post_data['poll_option_text'] = $request->variable('poll_option_text', '', true); - $post_data['poll_max_options'] = $request->variable('poll_max_options', 1); - $post_data['poll_vote_change'] = ($auth->acl_get('f_votechg', $forum_id) && $auth->acl_get('f_vote', $forum_id) && isset($_POST['poll_vote_change'])) ? 1 : 0; - } - - // If replying/quoting and last post id has changed - // give user option to continue submit or return to post - // notify and show user the post made between his request and the final submit - if (($mode == 'reply' || $mode == 'quote') && $post_data['topic_cur_post_id'] && $post_data['topic_cur_post_id'] != $post_data['topic_last_post_id']) - { - // Only do so if it is allowed forum-wide - if ($post_data['forum_flags'] & FORUM_FLAG_POST_REVIEW) - { - if (topic_review($topic_id, $forum_id, 'post_review', $post_data['topic_cur_post_id'])) - { - $template->assign_var('S_POST_REVIEW', true); - } - - $submit = false; - $refresh = true; - } - } - - // Parse Attachments - before checksum is calculated - $message_parser->parse_attachments('fileupload', $mode, $forum_id, $submit, $preview, $refresh); - - /** - * This event allows you to modify message text before parsing - * - * @event core.posting_modify_message_text - * @var array post_data Array with post data - * @var string mode What action to take if the form is submitted - * post|reply|quote|edit|delete|bump|smilies|popup - * @var int post_id ID of the post - * @var int topic_id ID of the topic - * @var int forum_id ID of the forum - * @var bool submit Whether or not the form has been submitted - * @var bool preview Whether or not the post is being previewed - * @var bool save Whether or not a draft is being saved - * @var bool load Whether or not a draft is being loaded - * @var bool cancel Whether or not to cancel the form (returns to - * viewtopic or viewforum depending on if the user - * is posting a new topic or editing a post) - * @var bool refresh Whether or not to retain previously submitted data - * @var object message_parser The message parser object - * @var array error Array of errors - * @since 3.1.2-RC1 - * @changed 3.1.11-RC1 Added error - */ - $vars = array( - 'post_data', - 'mode', - 'post_id', - 'topic_id', - 'forum_id', - 'submit', - 'preview', - 'save', - 'load', - 'cancel', - 'refresh', - 'message_parser', - 'error', - ); - extract($phpbb_dispatcher->trigger_event('core.posting_modify_message_text', compact($vars))); - - // Grab md5 'checksum' of new message - $message_md5 = md5($message_parser->message); - - // If editing and checksum has changed we know the post was edited while we're editing - // Notify and show user the changed post - if ($mode == 'edit' && $post_data['forum_flags'] & FORUM_FLAG_POST_REVIEW) - { - $edit_post_message_checksum = $request->variable('edit_post_message_checksum', ''); - $edit_post_subject_checksum = $request->variable('edit_post_subject_checksum', ''); - - // $post_data['post_checksum'] is the checksum of the post submitted in the meantime - // $message_md5 is the checksum of the post we're about to submit - // $edit_post_message_checksum is the checksum of the post we're editing - // ... - - // We make sure nobody else made exactly the same change - // we're about to submit by also checking $message_md5 != $post_data['post_checksum'] - if ($edit_post_message_checksum !== '' && - $edit_post_message_checksum != $post_data['post_checksum'] && - $message_md5 != $post_data['post_checksum'] - || - $edit_post_subject_checksum !== '' && - $edit_post_subject_checksum != $post_data['post_subject_md5'] && - md5($post_data['post_subject']) != $post_data['post_subject_md5']) - { - if (topic_review($topic_id, $forum_id, 'post_review_edit', $post_id)) - { - $template->assign_vars(array( - 'S_POST_REVIEW' => true, - - 'L_POST_REVIEW' => $user->lang['POST_REVIEW_EDIT'], - 'L_POST_REVIEW_EXPLAIN' => $user->lang['POST_REVIEW_EDIT_EXPLAIN'], - )); - } - - $submit = false; - $refresh = true; - } - } - - // Check checksum ... don't re-parse message if the same - $update_message = ($mode != 'edit' || $message_md5 != $post_data['post_checksum'] || $status_switch || strlen($post_data['bbcode_uid']) < BBCODE_UID_LEN) ? true : false; - - // Also check if subject got updated... - $update_subject = $mode != 'edit' || ($post_data['post_subject_md5'] && $post_data['post_subject_md5'] != md5($post_data['post_subject'])); - - // Parse message - if ($update_message) - { - if (count($message_parser->warn_msg)) - { - $error[] = implode('
', $message_parser->warn_msg); - $message_parser->warn_msg = array(); - } - - if (!$preview || !empty($message_parser->message)) - { - $message_parser->parse($post_data['enable_bbcode'], ($config['allow_post_links']) ? $post_data['enable_urls'] : false, $post_data['enable_smilies'], $img_status, $flash_status, $quote_status, $config['allow_post_links']); - } - - // On a refresh we do not care about message parsing errors - if (count($message_parser->warn_msg) && $refresh && !$preview) - { - $message_parser->warn_msg = array(); - } - } - else - { - $message_parser->bbcode_bitfield = $post_data['bbcode_bitfield']; - } - - $ignore_flood = $auth->acl_get('u_ignoreflood') ? true : $auth->acl_get('f_ignoreflood', $forum_id); - if ($mode != 'edit' && !$preview && !$refresh && $config['flood_interval'] && !$ignore_flood) - { - // Flood check - $last_post_time = 0; - - if ($user->data['is_registered']) - { - $last_post_time = $user->data['user_lastpost_time']; - } - else - { - $sql = 'SELECT post_time AS last_post_time - FROM ' . POSTS_TABLE . " - WHERE poster_ip = '" . $user->ip . "' - AND post_time > " . ($current_time - $config['flood_interval']); - $result = $db->sql_query_limit($sql, 1); - if ($row = $db->sql_fetchrow($result)) - { - $last_post_time = $row['last_post_time']; - } - $db->sql_freeresult($result); - } - - if ($last_post_time && ($current_time - $last_post_time) < intval($config['flood_interval'])) - { - $error[] = $user->lang['FLOOD_ERROR']; - } - } - - // Validate username - if (($post_data['username'] && !$user->data['is_registered']) || ($mode == 'edit' && $post_data['poster_id'] == ANONYMOUS && $post_data['username'] && $post_data['post_username'] && $post_data['post_username'] != $post_data['username'])) - { - if (!function_exists('validate_username')) - { - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - } - - $user->add_lang('ucp'); - - if (($result = validate_username($post_data['username'], (!empty($post_data['post_username'])) ? $post_data['post_username'] : '')) !== false) - { - $error[] = $user->lang[$result . '_USERNAME']; - } - - if (($result = validate_string($post_data['username'], false, $config['min_name_chars'], $config['max_name_chars'])) !== false) - { - $min_max_amount = ($result == 'TOO_SHORT') ? $config['min_name_chars'] : $config['max_name_chars']; - $error[] = $user->lang('FIELD_' . $result, $min_max_amount, $user->lang['USERNAME']); - } - } - - if ($config['enable_post_confirm'] && !$user->data['is_registered'] && in_array($mode, array('quote', 'post', 'reply'))) - { - $captcha_data = array( - 'message' => $request->variable('message', '', true), - 'subject' => $request->variable('subject', '', true), - 'username' => $request->variable('username', '', true), - ); - $vc_response = $captcha->validate($captcha_data); - if ($vc_response) - { - $error[] = $vc_response; - } - } - - // check form - if (($submit || $preview) && !check_form_key('posting')) - { - $error[] = $user->lang['FORM_INVALID']; - } - - if ($submit && $mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED && !isset($_POST['soft_delete']) && $auth->acl_get('m_approve', $forum_id)) - { - $is_first_post = ($post_id == $post_data['topic_first_post_id'] || !$post_data['topic_posts_approved']); - $is_last_post = ($post_id == $post_data['topic_last_post_id'] || !$post_data['topic_posts_approved']); - $updated_post_data = $phpbb_content_visibility->set_post_visibility(ITEM_APPROVED, $post_id, $post_data['topic_id'], $post_data['forum_id'], $user->data['user_id'], time(), '', $is_first_post, $is_last_post); - - if (!empty($updated_post_data)) - { - // Update the post_data, so we don't need to refetch it. - $post_data = array_merge($post_data, $updated_post_data); - } - } - - // Parse subject - if (!$preview && !$refresh && utf8_clean_string($post_data['post_subject']) === '' && ($mode == 'post' || ($mode == 'edit' && $post_data['topic_first_post_id'] == $post_id))) - { - $error[] = $user->lang['EMPTY_SUBJECT']; - } - - // Check for out-of-bounds characters that are currently - // not supported by utf8_bin in MySQL - if (preg_match_all('/[\x{10000}-\x{10FFFF}]/u', $post_data['post_subject'], $matches)) - { - $character_list = implode('
', $matches[0]); - $error[] = $user->lang('UNSUPPORTED_CHARACTERS_SUBJECT', $character_list); - } - - $post_data['poll_last_vote'] = (isset($post_data['poll_last_vote'])) ? $post_data['poll_last_vote'] : 0; - - if ($post_data['poll_option_text'] && - ($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id']/* && (!$post_data['poll_last_vote'] || $auth->acl_get('m_edit', $forum_id))*/)) - && $auth->acl_get('f_poll', $forum_id)) - { - $poll = array( - 'poll_title' => $post_data['poll_title'], - 'poll_length' => $post_data['poll_length'], - 'poll_max_options' => $post_data['poll_max_options'], - 'poll_option_text' => $post_data['poll_option_text'], - 'poll_start' => $post_data['poll_start'], - 'poll_last_vote' => $post_data['poll_last_vote'], - 'poll_vote_change' => $post_data['poll_vote_change'], - 'enable_bbcode' => $post_data['enable_bbcode'], - 'enable_urls' => $post_data['enable_urls'], - 'enable_smilies' => $post_data['enable_smilies'], - 'img_status' => $img_status - ); - - $message_parser->parse_poll($poll); - - $post_data['poll_options'] = (isset($poll['poll_options'])) ? $poll['poll_options'] : array(); - $post_data['poll_title'] = (isset($poll['poll_title'])) ? $poll['poll_title'] : ''; - - /* We reset votes, therefore also allow removing options - if ($post_data['poll_last_vote'] && ($poll['poll_options_size'] < $orig_poll_options_size)) - { - $message_parser->warn_msg[] = $user->lang['NO_DELETE_POLL_OPTIONS']; - }*/ - } - else if ($mode == 'edit' && $post_id == $post_data['topic_first_post_id'] && $auth->acl_get('f_poll', $forum_id)) - { - // The user removed all poll options, this is equal to deleting the poll. - $poll = array( - 'poll_title' => '', - 'poll_length' => 0, - 'poll_max_options' => 0, - 'poll_option_text' => '', - 'poll_start' => 0, - 'poll_last_vote' => 0, - 'poll_vote_change' => 0, - 'poll_options' => array(), - ); - - $post_data['poll_options'] = array(); - $post_data['poll_title'] = ''; - $post_data['poll_start'] = $post_data['poll_length'] = $post_data['poll_max_options'] = $post_data['poll_last_vote'] = $post_data['poll_vote_change'] = 0; - } - else if (!$auth->acl_get('f_poll', $forum_id) && ($mode == 'edit') && ($post_id == $post_data['topic_first_post_id']) && !$bbcode_utils->is_empty($original_poll_data['poll_title'])) - { - // We have a poll but the editing user is not permitted to create/edit it. - // So we just keep the original poll-data. - // Decode the poll title and options text fisrt. - $original_poll_data['poll_title'] = $bbcode_utils->unparse($original_poll_data['poll_title']); - $original_poll_data['poll_option_text'] = $bbcode_utils->unparse($original_poll_data['poll_option_text']); - $original_poll_data['poll_options'] = explode("\n", $original_poll_data['poll_option_text']); - - $poll = array_merge($original_poll_data, array( - 'enable_bbcode' => $post_data['enable_bbcode'], - 'enable_urls' => $post_data['enable_urls'], - 'enable_smilies' => $post_data['enable_smilies'], - 'img_status' => $img_status, - )); - - $message_parser->parse_poll($poll); - - $post_data['poll_options'] = (isset($poll['poll_options'])) ? $poll['poll_options'] : array(); - $post_data['poll_title'] = (isset($poll['poll_title'])) ? $poll['poll_title'] : ''; - } - else - { - $poll = array(); - } - - // Check topic type - if ($post_data['topic_type'] != POST_NORMAL && ($mode == 'post' || ($mode == 'edit' && $post_data['topic_first_post_id'] == $post_id))) - { - switch ($post_data['topic_type']) - { - case POST_GLOBAL: - $auth_option = 'f_announce_global'; - break; - - case POST_ANNOUNCE: - $auth_option = 'f_announce'; - break; - - case POST_STICKY: - $auth_option = 'f_sticky'; - break; - - default: - $auth_option = ''; - break; - } - - if ($auth_option != '' && !$auth->acl_get($auth_option, $forum_id)) - { - // There is a special case where a user edits his post whereby the topic type got changed by an admin/mod. - // Another case would be a mod not having sticky permissions for example but edit permissions. - if ($mode == 'edit') - { - // To prevent non-authed users messing around with the topic type we reset it to the original one. - $post_data['topic_type'] = $post_data['orig_topic_type']; - } - else - { - $error[] = $user->lang['CANNOT_POST_' . str_replace('F_', '', strtoupper($auth_option))]; - } - } - } - - if (count($message_parser->warn_msg)) - { - $error[] = implode('
', $message_parser->warn_msg); - } - - // DNSBL check - if ($config['check_dnsbl'] && !$refresh) - { - if (($dnsbl = $user->check_dnsbl('post')) !== false) - { - $error[] = sprintf($user->lang['IP_BLACKLISTED'], $user->ip, $dnsbl[1]); - } - } - - /** - * This event allows you to define errors before the post action is performed - * - * @event core.posting_modify_submission_errors - * @var array post_data Array with post data - * @var array poll Array with poll data from post (must be used instead of the post_data equivalent) - * @var string mode What action to take if the form is submitted - * post|reply|quote|edit|delete|bump|smilies|popup - * @var int post_id ID of the post - * @var int topic_id ID of the topic - * @var int forum_id ID of the forum - * @var bool submit Whether or not the form has been submitted - * @var array error Any error strings; a non-empty array aborts form submission. - * NOTE: Should be actual language strings, NOT language keys. - * @since 3.1.0-RC5 - * @changed 3.1.5-RC1 Added poll array to the event - * @changed 3.2.0-a1 Removed undefined page_title - */ - $vars = array( - 'post_data', - 'poll', - 'mode', - 'post_id', - 'topic_id', - 'forum_id', - 'submit', - 'error', - ); - extract($phpbb_dispatcher->trigger_event('core.posting_modify_submission_errors', compact($vars))); - - // Store message, sync counters - if (!count($error) && $submit) - { - if ($submit) - { - // Lock/Unlock Topic - $change_topic_status = $post_data['topic_status']; - $perm_lock_unlock = ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && !empty($post_data['topic_poster']) && $user->data['user_id'] == $post_data['topic_poster'] && $post_data['topic_status'] == ITEM_UNLOCKED)) ? true : false; - - if ($post_data['topic_status'] == ITEM_LOCKED && !$topic_lock && $perm_lock_unlock) - { - $change_topic_status = ITEM_UNLOCKED; - } - else if ($post_data['topic_status'] == ITEM_UNLOCKED && $topic_lock && $perm_lock_unlock) - { - $change_topic_status = ITEM_LOCKED; - } - - if ($change_topic_status != $post_data['topic_status']) - { - $sql = 'UPDATE ' . TOPICS_TABLE . " - SET topic_status = $change_topic_status - WHERE topic_id = $topic_id - AND topic_moved_id = 0"; - $db->sql_query($sql); - - $user_lock = ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $post_data['topic_poster']) ? 'USER_' : ''; - - $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_' . $user_lock . (($change_topic_status == ITEM_LOCKED) ? 'LOCK' : 'UNLOCK'), false, array( - 'forum_id' => $forum_id, - 'topic_id' => $topic_id, - $post_data['topic_title'] - )); - } - - // Lock/Unlock Post Edit - if ($mode == 'edit' && $post_data['post_edit_locked'] == ITEM_LOCKED && !$post_lock && $auth->acl_get('m_edit', $forum_id)) - { - $post_data['post_edit_locked'] = ITEM_UNLOCKED; - } - else if ($mode == 'edit' && $post_data['post_edit_locked'] == ITEM_UNLOCKED && $post_lock && $auth->acl_get('m_edit', $forum_id)) - { - $post_data['post_edit_locked'] = ITEM_LOCKED; - } - - $data = array( - 'topic_title' => (empty($post_data['topic_title'])) ? $post_data['post_subject'] : $post_data['topic_title'], - 'topic_first_post_id' => (isset($post_data['topic_first_post_id'])) ? (int) $post_data['topic_first_post_id'] : 0, - 'topic_last_post_id' => (isset($post_data['topic_last_post_id'])) ? (int) $post_data['topic_last_post_id'] : 0, - 'topic_time_limit' => (int) $post_data['topic_time_limit'], - 'topic_attachment' => (isset($post_data['topic_attachment'])) ? (int) $post_data['topic_attachment'] : 0, - 'post_id' => (int) $post_id, - 'topic_id' => (int) $topic_id, - 'forum_id' => (int) $forum_id, - 'icon_id' => (int) $post_data['icon_id'], - 'poster_id' => (int) $post_data['poster_id'], - 'enable_sig' => (bool) $post_data['enable_sig'], - 'enable_bbcode' => (bool) $post_data['enable_bbcode'], - 'enable_smilies' => (bool) $post_data['enable_smilies'], - 'enable_urls' => (bool) $post_data['enable_urls'], - 'enable_indexing' => (bool) $post_data['enable_indexing'], - 'message_md5' => (string) $message_md5, - 'post_checksum' => (isset($post_data['post_checksum'])) ? (string) $post_data['post_checksum'] : '', - 'post_edit_reason' => $post_data['post_edit_reason'], - 'post_edit_user' => ($mode == 'edit') ? $user->data['user_id'] : ((isset($post_data['post_edit_user'])) ? (int) $post_data['post_edit_user'] : 0), - 'forum_parents' => $post_data['forum_parents'], - 'forum_name' => $post_data['forum_name'], - 'notify' => $notify, - 'notify_set' => $post_data['notify_set'], - 'poster_ip' => (isset($post_data['poster_ip'])) ? $post_data['poster_ip'] : $user->ip, - 'post_edit_locked' => (int) $post_data['post_edit_locked'], - 'bbcode_bitfield' => $message_parser->bbcode_bitfield, - 'bbcode_uid' => $message_parser->bbcode_uid, - 'message' => $message_parser->message, - 'attachment_data' => $message_parser->attachment_data, - 'filename_data' => $message_parser->filename_data, - 'topic_status' => $post_data['topic_status'], - - 'topic_visibility' => (isset($post_data['topic_visibility'])) ? $post_data['topic_visibility'] : false, - 'post_visibility' => (isset($post_data['post_visibility'])) ? $post_data['post_visibility'] : false, - ); - - if ($mode == 'edit') - { - $data['topic_posts_approved'] = $post_data['topic_posts_approved']; - $data['topic_posts_unapproved'] = $post_data['topic_posts_unapproved']; - $data['topic_posts_softdeleted'] = $post_data['topic_posts_softdeleted']; - } - - // Only return the username when it is either a guest posting or we are editing a post and - // the username was supplied; otherwise post_data might hold the data of the post that is - // being quoted (which could result in the username being returned being that of the quoted - // post's poster, not the poster of the current post). See: PHPBB3-11769 for more information. - $post_author_name = ((!$user->data['is_registered'] || $mode == 'edit') && $post_data['username'] !== '') ? $post_data['username'] : ''; - - /** - * This event allows you to define errors before the post action is performed - * - * @event core.posting_modify_submit_post_before - * @var array post_data Array with post data - * @var array poll Array with poll data - * @var array data Array with post data going to be stored in the database - * @var string mode What action to take if the form is submitted - * post|reply|quote|edit|delete - * @var int post_id ID of the post - * @var int topic_id ID of the topic - * @var int forum_id ID of the forum - * @var string post_author_name Author name for guest posts - * @var bool update_message Boolean if the post message was changed - * @var bool update_subject Boolean if the post subject was changed - * NOTE: Should be actual language strings, NOT language keys. - * @since 3.1.0-RC5 - * @changed 3.1.6-RC1 remove submit and error from event Submit and Error are checked previously prior to running event - * @change 3.2.0-a1 Removed undefined page_title - */ - $vars = array( - 'post_data', - 'poll', - 'data', - 'mode', - 'post_id', - 'topic_id', - 'forum_id', - 'post_author_name', - 'update_message', - 'update_subject', - ); - extract($phpbb_dispatcher->trigger_event('core.posting_modify_submit_post_before', compact($vars))); - - // The last parameter tells submit_post if search indexer has to be run - $redirect_url = submit_post($mode, $post_data['post_subject'], $post_author_name, $post_data['topic_type'], $poll, $data, $update_message, ($update_message || $update_subject) ? true : false); - - /** - * This event allows you to define errors after the post action is performed - * - * @event core.posting_modify_submit_post_after - * @var array post_data Array with post data - * @var array poll Array with poll data - * @var array data Array with post data going to be stored in the database - * @var string mode What action to take if the form is submitted - * post|reply|quote|edit|delete - * @var int post_id ID of the post - * @var int topic_id ID of the topic - * @var int forum_id ID of the forum - * @var string post_author_name Author name for guest posts - * @var bool update_message Boolean if the post message was changed - * @var bool update_subject Boolean if the post subject was changed - * @var string redirect_url URL the user is going to be redirected to - * NOTE: Should be actual language strings, NOT language keys. - * @since 3.1.0-RC5 - * @changed 3.1.6-RC1 remove submit and error from event Submit and Error are checked previously prior to running event - * @change 3.2.0-a1 Removed undefined page_title - */ - $vars = array( - 'post_data', - 'poll', - 'data', - 'mode', - 'post_id', - 'topic_id', - 'forum_id', - 'post_author_name', - 'update_message', - 'update_subject', - 'redirect_url', - ); - extract($phpbb_dispatcher->trigger_event('core.posting_modify_submit_post_after', compact($vars))); - - if ($config['enable_post_confirm'] && !$user->data['is_registered'] && (isset($captcha) && $captcha->is_solved() === true) && ($mode == 'post' || $mode == 'reply' || $mode == 'quote')) - { - $captcha->reset(); - } - - // Handle delete mode... - if ($request->is_set_post('delete') || $request->is_set_post('delete_permanent')) - { - $delete_reason = $request->variable('delete_reason', '', true); - phpbb_handle_post_delete($forum_id, $topic_id, $post_id, $post_data, !$request->is_set_post('delete_permanent'), $delete_reason); - return; - } - - // Check the permissions for post approval. - // Moderators must go through post approval like ordinary users. - if ((!$auth->acl_get('f_noapprove', $data['forum_id']) && empty($data['force_approved_state'])) || (isset($data['force_approved_state']) && !$data['force_approved_state'])) - { - meta_refresh(10, $redirect_url); - $message = ($mode == 'edit') ? $user->lang['POST_EDITED_MOD'] : $user->lang['POST_STORED_MOD']; - $message .= (($user->data['user_id'] == ANONYMOUS) ? '' : ' '. $user->lang['POST_APPROVAL_NOTIFY']); - $message .= '

' . sprintf($user->lang['RETURN_FORUM'], '', ''); - trigger_error($message); - } - - redirect($redirect_url); - } - } -} - -// Preview -if (!count($error) && $preview) -{ - $post_data['post_time'] = ($mode == 'edit') ? $post_data['post_time'] : $current_time; - - $preview_message = $message_parser->format_display($post_data['enable_bbcode'], $post_data['enable_urls'], $post_data['enable_smilies'], false); - - $preview_signature = ($mode == 'edit') ? $post_data['user_sig'] : $user->data['user_sig']; - $preview_signature_uid = ($mode == 'edit') ? $post_data['user_sig_bbcode_uid'] : $user->data['user_sig_bbcode_uid']; - $preview_signature_bitfield = ($mode == 'edit') ? $post_data['user_sig_bbcode_bitfield'] : $user->data['user_sig_bbcode_bitfield']; - - // Signature - if ($post_data['enable_sig'] && $config['allow_sig'] && $preview_signature && $auth->acl_get('f_sigs', $forum_id)) - { - $flags = ($config['allow_sig_bbcode']) ? OPTION_FLAG_BBCODE : 0; - $flags |= ($config['allow_sig_links']) ? OPTION_FLAG_LINKS : 0; - $flags |= ($config['allow_sig_smilies']) ? OPTION_FLAG_SMILIES : 0; - - $preview_signature = generate_text_for_display($preview_signature, $preview_signature_uid, $preview_signature_bitfield, $flags, false); - } - else - { - $preview_signature = ''; - } - - $preview_subject = censor_text($post_data['post_subject']); - - // Poll Preview - if (!$poll_delete && ($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id']/* && (!$post_data['poll_last_vote'] || $auth->acl_get('m_edit', $forum_id))*/)) - && $auth->acl_get('f_poll', $forum_id)) - { - $parse_poll = new parse_message($post_data['poll_title']); - $parse_poll->bbcode_uid = $message_parser->bbcode_uid; - $parse_poll->bbcode_bitfield = $message_parser->bbcode_bitfield; - - $parse_poll->format_display($post_data['enable_bbcode'], $post_data['enable_urls'], $post_data['enable_smilies']); - - if ($post_data['poll_length']) - { - $poll_end = ($post_data['poll_length'] * 86400) + (($post_data['poll_start']) ? $post_data['poll_start'] : time()); - } - - $template->assign_vars(array( - 'S_HAS_POLL_OPTIONS' => (count($post_data['poll_options'])), - 'S_IS_MULTI_CHOICE' => ($post_data['poll_max_options'] > 1) ? true : false, - - 'POLL_QUESTION' => $parse_poll->message, - - 'L_POLL_LENGTH' => ($post_data['poll_length']) ? sprintf($user->lang['POLL_RUN_TILL'], $user->format_date($poll_end)) : '', - 'L_MAX_VOTES' => $user->lang('MAX_OPTIONS_SELECT', (int) $post_data['poll_max_options']), - )); - - $preview_poll_options = array(); - foreach ($post_data['poll_options'] as $poll_option) - { - $parse_poll->message = $poll_option; - $parse_poll->format_display($post_data['enable_bbcode'], $post_data['enable_urls'], $post_data['enable_smilies']); - $preview_poll_options[] = $parse_poll->message; - } - unset($parse_poll); - - foreach ($preview_poll_options as $key => $option) - { - $template->assign_block_vars('poll_option', array( - 'POLL_OPTION_CAPTION' => $option, - 'POLL_OPTION_ID' => $key + 1) - ); - } - unset($preview_poll_options); - } - - // Attachment Preview - if (count($message_parser->attachment_data)) - { - $template->assign_var('S_HAS_ATTACHMENTS', true); - - $update_count = array(); - $attachment_data = $message_parser->attachment_data; - - parse_attachments($forum_id, $preview_message, $attachment_data, $update_count, true); - - foreach ($attachment_data as $i => $attachment) - { - $template->assign_block_vars('attachment', array( - 'DISPLAY_ATTACHMENT' => $attachment) - ); - } - unset($attachment_data); - } - - if (!count($error)) - { - $template->assign_vars(array( - 'PREVIEW_SUBJECT' => $preview_subject, - 'PREVIEW_MESSAGE' => $preview_message, - 'PREVIEW_SIGNATURE' => $preview_signature, - - 'S_DISPLAY_PREVIEW' => !empty($preview_message), - )); - } -} - -// Remove quotes that would become nested too deep before decoding the text -$generate_quote = ($mode == 'quote' && !$submit && !$preview && !$refresh); -if ($generate_quote && $config['max_quote_depth'] > 0) -{ - $tmp_bbcode_uid = $message_parser->bbcode_uid; - $message_parser->bbcode_uid = $post_data['bbcode_uid']; - $message_parser->remove_nested_quotes($config['max_quote_depth'] - 1); - $message_parser->bbcode_uid = $tmp_bbcode_uid; -} - -// Decode text for message display -$post_data['bbcode_uid'] = ($mode == 'quote' && !$preview && !$refresh && !count($error)) ? $post_data['bbcode_uid'] : $message_parser->bbcode_uid; -$message_parser->decode_message($post_data['bbcode_uid']); - -if ($generate_quote) -{ - // Remove attachment bbcode tags from the quoted message to avoid mixing with the new post attachments if any - $message_parser->message = preg_replace('#\[attachment=([0-9]+)\](.*?)\[\/attachment\]#uis', '\\2', $message_parser->message); - - $quote_attributes = array( - 'author' => $post_data['quote_username'], - 'post_id' => $post_data['post_id'], - 'time' => $post_data['post_time'], - 'user_id' => $post_data['poster_id'], - ); - - /** - * This event allows you to modify the quote attributes of the post being quoted - * - * @event core.posting_modify_quote_attributes - * @var array quote_attributes Array with quote attributes - * @var array post_data Array with post data - * @since 3.2.6-RC1 - */ - $vars = array( - 'quote_attributes', - 'post_data', - ); - extract($phpbb_dispatcher->trigger_event('core.posting_modify_quote_attributes', compact($vars))); - - /** @var \phpbb\language\language $language */ - $language = $phpbb_container->get('language'); - phpbb_format_quote($language, $message_parser, $bbcode_utils, $bbcode_status, $quote_attributes); -} - -if (($mode == 'reply' || $mode == 'quote') && !$submit && !$preview && !$refresh) -{ - $post_data['post_subject'] = ((strpos($post_data['post_subject'], 'Re: ') !== 0) ? 'Re: ' : '') . censor_text($post_data['post_subject']); -} - -$attachment_data = $message_parser->attachment_data; -$filename_data = $message_parser->filename_data; -$post_data['post_text'] = $message_parser->message; - -if (count($post_data['poll_options']) || (isset($post_data['poll_title']) && !$bbcode_utils->is_empty($post_data['poll_title']))) -{ - $message_parser->message = $post_data['poll_title']; - $message_parser->bbcode_uid = $post_data['bbcode_uid']; - - $message_parser->decode_message(); - $post_data['poll_title'] = $message_parser->message; - - $message_parser->message = implode("\n", $post_data['poll_options']); - $message_parser->decode_message(); - $post_data['poll_options'] = explode("\n", $message_parser->message); -} - -// MAIN POSTING PAGE BEGINS HERE - -// Forum moderators? -$moderators = array(); -if ($config['load_moderators']) -{ - get_moderators($moderators, $forum_id); -} - -// Generate smiley listing -generate_smilies('inline', $forum_id); - -// Generate inline attachment select box -posting_gen_inline_attachments($attachment_data); - -// Do show topic type selection only in first post. -$topic_type_toggle = false; - -if ($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id'])) -{ - $topic_type_toggle = posting_gen_topic_types($forum_id, $post_data['topic_type']); -} - -$s_topic_icons = false; -if ($post_data['enable_icons'] && $auth->acl_get('f_icons', $forum_id)) -{ - $s_topic_icons = posting_gen_topic_icons($mode, $post_data['icon_id']); -} - -$bbcode_checked = (isset($post_data['enable_bbcode'])) ? !$post_data['enable_bbcode'] : (($config['allow_bbcode']) ? !$user->optionget('bbcode') : 1); -$smilies_checked = (isset($post_data['enable_smilies'])) ? !$post_data['enable_smilies'] : (($config['allow_smilies']) ? !$user->optionget('smilies') : 1); -$urls_checked = (isset($post_data['enable_urls'])) ? !$post_data['enable_urls'] : 0; -$sig_checked = $post_data['enable_sig']; -$lock_topic_checked = (isset($topic_lock) && $topic_lock) ? $topic_lock : (($post_data['topic_status'] == ITEM_LOCKED) ? 1 : 0); -$lock_post_checked = (isset($post_lock)) ? $post_lock : $post_data['post_edit_locked']; - -// If the user is replying or posting and not already watching this topic but set to always being notified we need to overwrite this setting -$notify_set = ($mode != 'edit' && $config['allow_topic_notify'] && $user->data['is_registered'] && !$post_data['notify_set']) ? $user->data['user_notify'] : $post_data['notify_set']; -$notify_checked = (isset($notify)) ? $notify : (($mode == 'post') ? $user->data['user_notify'] : $notify_set); - -// Page title & action URL -$s_action = append_sid("{$phpbb_root_path}posting.$phpEx", "mode=$mode&f=$forum_id"); -$s_action .= ($topic_id) ? "&t=$topic_id" : ''; -$s_action .= ($post_id) ? "&p=$post_id" : ''; - -switch ($mode) -{ - case 'post': - $page_title = $user->lang['POST_TOPIC']; - break; - - case 'quote': - case 'reply': - $page_title = $user->lang['POST_REPLY']; - break; - - case 'delete': - case 'edit': - $page_title = $user->lang['EDIT_POST']; - break; -} - -// Build Navigation Links -generate_forum_nav($post_data); - -// Build Forum Rules -generate_forum_rules($post_data); - -// Posting uses is_solved for legacy reasons. Plugins have to use is_solved to force themselves to be displayed. -if ($config['enable_post_confirm'] && !$user->data['is_registered'] && (isset($captcha) && $captcha->is_solved() === false) && ($mode == 'post' || $mode == 'reply' || $mode == 'quote')) -{ - - $template->assign_vars(array( - 'S_CONFIRM_CODE' => true, - 'CAPTCHA_TEMPLATE' => $captcha->get_template(), - )); -} - -$s_hidden_fields = ($mode == 'reply' || $mode == 'quote') ? '' : ''; -$s_hidden_fields .= ($draft_id || isset($_REQUEST['draft_loaded'])) ? '' : ''; - -if ($mode == 'edit') -{ - $s_hidden_fields .= build_hidden_fields(array( - 'edit_post_message_checksum' => $post_data['post_checksum'], - 'edit_post_subject_checksum' => $post_data['post_subject_md5'], - )); -} - -// Add the confirm id/code pair to the hidden fields, else an error is displayed on next submit/preview -if (isset($captcha) && $captcha->is_solved() !== false) -{ - $s_hidden_fields .= build_hidden_fields($captcha->get_hidden_fields()); -} - -$form_enctype = (@ini_get('file_uploads') == '0' || strtolower(@ini_get('file_uploads')) == 'off' || !$config['allow_attachments'] || !$auth->acl_get('u_attach') || !$auth->acl_get('f_attach', $forum_id)) ? '' : ' enctype="multipart/form-data"'; -add_form_key('posting'); - -/** @var \phpbb\controller\helper $controller_helper */ -$controller_helper = $phpbb_container->get('controller.helper'); - -// Build array of variables for main posting page -$page_data = array( - 'L_POST_A' => $page_title, - 'L_ICON' => ($mode == 'reply' || $mode == 'quote' || ($mode == 'edit' && $post_id != $post_data['topic_first_post_id'])) ? $user->lang['POST_ICON'] : $user->lang['TOPIC_ICON'], - 'L_MESSAGE_BODY_EXPLAIN' => $user->lang('MESSAGE_BODY_EXPLAIN', (int) $config['max_post_chars']), - 'L_DELETE_POST_PERMANENTLY' => $user->lang('DELETE_POST_PERMANENTLY', 1), - - 'FORUM_NAME' => $post_data['forum_name'], - 'FORUM_DESC' => ($post_data['forum_desc']) ? generate_text_for_display($post_data['forum_desc'], $post_data['forum_desc_uid'], $post_data['forum_desc_bitfield'], $post_data['forum_desc_options']) : '', - 'TOPIC_TITLE' => censor_text($post_data['topic_title']), - 'MODERATORS' => (count($moderators)) ? implode($user->lang['COMMA_SEPARATOR'], $moderators[$forum_id]) : '', - 'USERNAME' => ((!$preview && $mode != 'quote') || $preview) ? $post_data['username'] : '', - 'SUBJECT' => $post_data['post_subject'], - 'MESSAGE' => $post_data['post_text'], - 'BBCODE_STATUS' => $user->lang(($bbcode_status ? 'BBCODE_IS_ON' : 'BBCODE_IS_OFF'), '', ''), - 'IMG_STATUS' => ($img_status) ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'], - 'FLASH_STATUS' => ($flash_status) ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'], - 'SMILIES_STATUS' => ($smilies_status) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'], - 'URL_STATUS' => ($bbcode_status && $url_status) ? $user->lang['URL_IS_ON'] : $user->lang['URL_IS_OFF'], - 'MAX_FONT_SIZE' => (int) $config['max_post_font_size'], - 'MINI_POST_IMG' => $user->img('icon_post_target', $user->lang['POST']), - 'POST_DATE' => ($post_data['post_time']) ? $user->format_date($post_data['post_time']) : '', - 'ERROR' => (count($error)) ? implode('
', $error) : '', - 'TOPIC_TIME_LIMIT' => (int) $post_data['topic_time_limit'], - 'EDIT_REASON' => $request->variable('edit_reason', '', true), - 'SHOW_PANEL' => $request->variable('show_panel', ''), - 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id"), - 'U_VIEW_TOPIC' => ($mode != 'post') ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id") : '', - 'U_PROGRESS_BAR' => append_sid("{$phpbb_root_path}posting.$phpEx", "f=$forum_id&mode=popup"), - 'UA_PROGRESS_BAR' => addslashes(append_sid("{$phpbb_root_path}posting.$phpEx", "f=$forum_id&mode=popup")), - - 'S_PRIVMSGS' => false, - 'S_CLOSE_PROGRESS_WINDOW' => (isset($_POST['add_file'])) ? true : false, - 'S_EDIT_POST' => ($mode == 'edit') ? true : false, - 'S_EDIT_REASON' => ($mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? true : false, - 'S_DISPLAY_USERNAME' => (!$user->data['is_registered'] || ($mode == 'edit' && $post_data['poster_id'] == ANONYMOUS)) ? true : false, - 'S_SHOW_TOPIC_ICONS' => $s_topic_icons, - 'S_DELETE_ALLOWED' => ($mode == 'edit' && (($post_id == $post_data['topic_last_post_id'] && $post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id) && !$post_data['post_edit_locked'] && ($post_data['post_time'] > time() - ($config['delete_time'] * 60) || !$config['delete_time'])) || $auth->acl_get('m_delete', $forum_id))) ? true : false, - 'S_BBCODE_ALLOWED' => ($bbcode_status) ? 1 : 0, - 'S_BBCODE_CHECKED' => ($bbcode_checked) ? ' checked="checked"' : '', - 'S_SMILIES_ALLOWED' => $smilies_status, - 'S_SMILIES_CHECKED' => ($smilies_checked) ? ' checked="checked"' : '', - 'S_SIG_ALLOWED' => ($auth->acl_get('f_sigs', $forum_id) && $config['allow_sig'] && $user->data['is_registered']) ? true : false, - 'S_SIGNATURE_CHECKED' => ($sig_checked) ? ' checked="checked"' : '', - 'S_NOTIFY_ALLOWED' => (!$user->data['is_registered'] || ($mode == 'edit' && $user->data['user_id'] != $post_data['poster_id']) || !$config['allow_topic_notify'] || !$config['email_enable']) ? false : true, - 'S_NOTIFY_CHECKED' => ($notify_checked) ? ' checked="checked"' : '', - 'S_LOCK_TOPIC_ALLOWED' => (($mode == 'edit' || $mode == 'reply' || $mode == 'quote' || $mode == 'post') && ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && !empty($post_data['topic_poster']) && $user->data['user_id'] == $post_data['topic_poster'] && $post_data['topic_status'] == ITEM_UNLOCKED))) ? true : false, - 'S_LOCK_TOPIC_CHECKED' => ($lock_topic_checked) ? ' checked="checked"' : '', - 'S_LOCK_POST_ALLOWED' => ($mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? true : false, - 'S_LOCK_POST_CHECKED' => ($lock_post_checked) ? ' checked="checked"' : '', - 'S_SOFTDELETE_CHECKED' => ($mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED) ? ' checked="checked"' : '', - 'S_SOFTDELETE_ALLOWED' => ($mode == 'edit' && $phpbb_content_visibility->can_soft_delete($forum_id, $post_data['poster_id'], $lock_post_checked)) ? true : false, - 'S_RESTORE_ALLOWED' => $auth->acl_get('m_approve', $forum_id), - 'S_IS_DELETED' => ($mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED) ? true : false, - 'S_LINKS_ALLOWED' => $url_status, - 'S_MAGIC_URL_CHECKED' => ($urls_checked) ? ' checked="checked"' : '', - 'S_TYPE_TOGGLE' => $topic_type_toggle, - 'S_SAVE_ALLOWED' => ($auth->acl_get('u_savedrafts') && $user->data['is_registered'] && $mode != 'edit') ? true : false, - 'S_HAS_DRAFTS' => ($auth->acl_get('u_savedrafts') && $user->data['is_registered'] && $post_data['drafts']) ? true : false, - 'S_FORM_ENCTYPE' => $form_enctype, - - 'S_BBCODE_IMG' => $img_status, - 'S_BBCODE_URL' => $url_status, - 'S_BBCODE_FLASH' => $flash_status, - 'S_BBCODE_QUOTE' => $quote_status, - - 'S_POST_ACTION' => $s_action, - 'S_HIDDEN_FIELDS' => $s_hidden_fields, - 'S_ATTACH_DATA' => json_encode($message_parser->attachment_data), - 'S_IN_POSTING' => true, -); - -// Build custom bbcodes array -display_custom_bbcodes(); - -// Poll entry -if (($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id']/* && (!$post_data['poll_last_vote'] || $auth->acl_get('m_edit', $forum_id))*/)) - && $auth->acl_get('f_poll', $forum_id)) -{ - $page_data = array_merge($page_data, array( - 'S_SHOW_POLL_BOX' => true, - 'S_POLL_VOTE_CHANGE' => ($auth->acl_get('f_votechg', $forum_id) && $auth->acl_get('f_vote', $forum_id)), - 'S_POLL_DELETE' => ($mode == 'edit' && count($post_data['poll_options']) && ((!$post_data['poll_last_vote'] && $post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) || $auth->acl_get('m_delete', $forum_id))), - 'S_POLL_DELETE_CHECKED' => (!empty($poll_delete)) ? true : false, - - 'L_POLL_OPTIONS_EXPLAIN' => $user->lang('POLL_OPTIONS_' . (($mode == 'edit') ? 'EDIT_' : '') . 'EXPLAIN', (int) $config['max_poll_options']), - - 'VOTE_CHANGE_CHECKED' => (!empty($post_data['poll_vote_change'])) ? ' checked="checked"' : '', - 'POLL_TITLE' => (isset($post_data['poll_title'])) ? $post_data['poll_title'] : '', - 'POLL_OPTIONS' => (!empty($post_data['poll_options'])) ? implode("\n", $post_data['poll_options']) : '', - 'POLL_MAX_OPTIONS' => (isset($post_data['poll_max_options'])) ? (int) $post_data['poll_max_options'] : 1, - 'POLL_LENGTH' => $post_data['poll_length'], - ) - ); -} - -/** -* This event allows you to modify template variables for the posting screen -* -* @event core.posting_modify_template_vars -* @var array post_data Array with post data -* @var array moderators Array with forum moderators -* @var string mode What action to take if the form is submitted -* post|reply|quote|edit|delete|bump|smilies|popup -* @var string page_title Title of the mode page -* @var bool s_topic_icons Whether or not to show the topic icons -* @var string form_enctype If attachments are allowed for this form -* "multipart/form-data" or empty string -* @var string s_action The URL to submit the POST data to -* @var string s_hidden_fields Concatenated hidden input tags of posting form -* @var int post_id ID of the post -* @var int topic_id ID of the topic -* @var int forum_id ID of the forum -* @var int draft_id ID of the draft -* @var bool submit Whether or not the form has been submitted -* @var bool preview Whether or not the post is being previewed -* @var bool save Whether or not a draft is being saved -* @var bool load Whether or not a draft is being loaded -* @var bool cancel Whether or not to cancel the form (returns to -* viewtopic or viewforum depending on if the user -* is posting a new topic or editing a post) -* @var array error Any error strings; a non-empty array aborts -* form submission. -* NOTE: Should be actual language strings, NOT -* language keys. -* @var bool refresh Whether or not to retain previously submitted data -* @var array page_data Posting page data that should be passed to the -* posting page via $template->assign_vars() -* @var object message_parser The message parser object -* @since 3.1.0-a1 -* @changed 3.1.0-b3 Added vars post_data, moderators, mode, page_title, -* s_topic_icons, form_enctype, s_action, s_hidden_fields, -* post_id, topic_id, forum_id, submit, preview, save, load, -* delete, cancel, refresh, error, page_data, message_parser -* @changed 3.1.2-RC1 Removed 'delete' var as it does not exist -* @changed 3.1.5-RC1 Added poll variables to the page_data array -* @changed 3.1.6-RC1 Added 'draft_id' var -*/ -$vars = array( - 'post_data', - 'moderators', - 'mode', - 'page_title', - 's_topic_icons', - 'form_enctype', - 's_action', - 's_hidden_fields', - 'post_id', - 'topic_id', - 'forum_id', - 'draft_id', - 'submit', - 'preview', - 'save', - 'load', - 'cancel', - 'refresh', - 'error', - 'page_data', - 'message_parser', -); -extract($phpbb_dispatcher->trigger_event('core.posting_modify_template_vars', compact($vars))); - -// Start assigning vars for main posting page ... -$template->assign_vars($page_data); - -// Show attachment box for adding attachments if true -$allowed = ($auth->acl_get('f_attach', $forum_id) && $auth->acl_get('u_attach') && $config['allow_attachments'] && $form_enctype); - -if ($allowed) -{ - $max_files = ($auth->acl_get('a_') || $auth->acl_get('m_', $forum_id)) ? 0 : (int) $config['max_attachments']; - $plupload->configure($cache, $template, $s_action, $forum_id, $max_files); -} - -// Attachment entry -posting_gen_attachment_entry($attachment_data, $filename_data, $allowed); - -// Output page ... -page_header($page_title); - -$template->set_filenames(array( - 'body' => 'posting_body.html') -); - -make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx")); - -// Topic review -if ($mode == 'reply' || $mode == 'quote') -{ - if (topic_review($topic_id, $forum_id)) - { - $template->assign_var('S_DISPLAY_REVIEW', true); - } -} - -page_footer(); diff --git a/install/update/old/report.php b/install/update/old/report.php deleted file mode 100644 index bb26b97..0000000 --- a/install/update/old/report.php +++ /dev/null @@ -1,41 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -use Symfony\Component\HttpFoundation\RedirectResponse; - -/** -* @ignore -*/ -define('IN_PHPBB', true); -$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); -include($phpbb_root_path . 'common.' . $phpEx); - -// Start session management -$user->session_begin(); -$auth->acl($user->data); - -$post_id = $request->variable('p', 0); -$pm_id = $request->variable('pm', 0); - -$redirect_route_name = ($pm_id === 0) ? 'phpbb_report_post_controller' : 'phpbb_report_pm_controller'; - -/** @var \phpbb\controller\helper $controller_helper */ -$controller_helper = $phpbb_container->get('controller.helper'); -$response = new RedirectResponse( - $controller_helper->route($redirect_route_name, array( - 'id' => ($pm_id === 0) ? $post_id : $pm_id, - )), - 301 -); -$response->send(); diff --git a/install/update/old/search.php b/install/update/old/search.php deleted file mode 100644 index 97a8f32..0000000 --- a/install/update/old/search.php +++ /dev/null @@ -1,1552 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -define('IN_PHPBB', true); -$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); -include($phpbb_root_path . 'common.' . $phpEx); - -// Start session management -$user->session_begin(); -$auth->acl($user->data); -$user->setup('search'); - -// Define initial vars -$mode = $request->variable('mode', ''); -$search_id = $request->variable('search_id', ''); -$start = max($request->variable('start', 0), 0); -$post_id = $request->variable('p', 0); -$topic_id = $request->variable('t', 0); -$view = $request->variable('view', ''); - -$submit = $request->variable('submit', false); -$keywords = $request->variable('keywords', '', true); -$add_keywords = $request->variable('add_keywords', '', true); -$author = $request->variable('author', '', true); -$author_id = $request->variable('author_id', 0); -$show_results = ($topic_id) ? 'posts' : $request->variable('sr', 'posts'); -$show_results = ($show_results == 'posts') ? 'posts' : 'topics'; -$search_terms = $request->variable('terms', 'all'); -$search_fields = $request->variable('sf', 'all'); -$search_child = $request->variable('sc', true); - -$sort_days = $request->variable('st', 0); -$sort_key = $request->variable('sk', 't'); -$sort_dir = $request->variable('sd', 'd'); - -$return_chars = $request->variable('ch', ($topic_id) ? -1 : 300); -$search_forum = $request->variable('fid', array(0)); - -// We put login boxes for the case if search_id is newposts, egosearch or unreadposts -// because a guest should be able to log in even if guests search is not permitted - -switch ($search_id) -{ - // Egosearch is an author search - case 'egosearch': - $author_id = $user->data['user_id']; - if ($user->data['user_id'] == ANONYMOUS) - { - login_box('', $user->lang['LOGIN_EXPLAIN_EGOSEARCH']); - } - break; - - // Search for unread posts needs to be allowed and user to be logged in if topics tracking for guests is disabled - case 'unreadposts': - if (!$config['load_unreads_search']) - { - $template->assign_var('S_NO_SEARCH', true); - trigger_error('NO_SEARCH_UNREADS'); - } - else if (!$config['load_anon_lastread'] && !$user->data['is_registered']) - { - login_box('', $user->lang['LOGIN_EXPLAIN_UNREADSEARCH']); - } - break; - - // The "new posts" search uses user_lastvisit which is user based, so it should require user to log in. - case 'newposts': - if ($user->data['user_id'] == ANONYMOUS) - { - login_box('', $user->lang['LOGIN_EXPLAIN_NEWPOSTS']); - } - break; - - default: - // There's nothing to do here for now ;) - break; -} - -// Is user able to search? Has search been disabled? -if (!$auth->acl_get('u_search') || !$auth->acl_getf_global('f_search') || !$config['load_search']) -{ - $template->assign_var('S_NO_SEARCH', true); - trigger_error('NO_SEARCH'); -} - -// Check search load limit -if ($user->load && $config['limit_search_load'] && ($user->load > doubleval($config['limit_search_load']))) -{ - $template->assign_var('S_NO_SEARCH', true); - trigger_error('NO_SEARCH_LOAD'); -} - -// It is applicable if the configuration setting is non-zero, and the user cannot -// ignore the flood setting, and the search is a keyword search. -$interval = ($user->data['user_id'] == ANONYMOUS) ? $config['search_anonymous_interval'] : $config['search_interval']; -if ($interval && !in_array($search_id, array('unreadposts', 'unanswered', 'active_topics', 'egosearch')) && !$auth->acl_get('u_ignoreflood')) -{ - if ($user->data['user_last_search'] > time() - $interval) - { - $template->assign_var('S_NO_SEARCH', true); - trigger_error($user->lang('NO_SEARCH_TIME', (int) ($user->data['user_last_search'] + $interval - time()))); - } -} - -// Define some vars -$limit_days = array(0 => $user->lang['ALL_RESULTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); -$sort_by_text = array('a' => $user->lang['SORT_AUTHOR'], 't' => $user->lang['SORT_TIME'], 'f' => $user->lang['SORT_FORUM'], 'i' => $user->lang['SORT_TOPIC_TITLE'], 's' => $user->lang['SORT_POST_SUBJECT']); - -$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; -gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); - -/* @var $phpbb_content_visibility \phpbb\content_visibility */ -$phpbb_content_visibility = $phpbb_container->get('content.visibility'); - -/* @var $pagination \phpbb\pagination */ -$pagination = $phpbb_container->get('pagination'); - -/** -* This event allows you to alter the above parameters, such as keywords and submit -* -* @event core.search_modify_submit_parameters -* @var string keywords The search keywords -* @var string author Specifies the author match, when ANONYMOUS is also a search-match -* @var int author_id ID of the author to search by -* @var string search_id Predefined search type name -* @var bool submit Whether or not the form has been submitted -* @since 3.1.10-RC1 -*/ -$vars = array( - 'keywords', - 'author', - 'author_id', - 'search_id', - 'submit', -); -extract($phpbb_dispatcher->trigger_event('core.search_modify_submit_parameters', compact($vars))); - -if ($keywords || $author || $author_id || $search_id || $submit) -{ - // clear arrays - $id_ary = array(); - - // If we are looking for authors get their ids - $author_id_ary = array(); - $sql_author_match = ''; - if ($author_id) - { - $author_id_ary[] = $author_id; - } - else if ($author) - { - if ((strpos($author, '*') !== false) && (utf8_strlen(str_replace(array('*', '%'), '', $author)) < $config['min_search_author_chars'])) - { - trigger_error($user->lang('TOO_FEW_AUTHOR_CHARS', (int) $config['min_search_author_chars'])); - } - - $sql_where = (strpos($author, '*') !== false) ? ' username_clean ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), utf8_clean_string($author))) : " username_clean = '" . $db->sql_escape(utf8_clean_string($author)) . "'"; - - $sql = 'SELECT user_id - FROM ' . USERS_TABLE . " - WHERE $sql_where - AND user_type <> " . USER_IGNORE; - $result = $db->sql_query_limit($sql, 100); - - while ($row = $db->sql_fetchrow($result)) - { - $author_id_ary[] = (int) $row['user_id']; - } - $db->sql_freeresult($result); - - $sql_where = (strpos($author, '*') !== false) ? ' post_username ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), utf8_clean_string($author))) : " post_username = '" . $db->sql_escape(utf8_clean_string($author)) . "'"; - - $sql = 'SELECT 1 as guest_post - FROM ' . POSTS_TABLE . " - WHERE $sql_where - AND poster_id = " . ANONYMOUS; - $result = $db->sql_query_limit($sql, 1); - $found_guest_post = $db->sql_fetchfield('guest_post'); - $db->sql_freeresult($result); - - if ($found_guest_post) - { - $author_id_ary[] = ANONYMOUS; - $sql_author_match = (strpos($author, '*') !== false) ? ' ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), utf8_clean_string($author))) : " = '" . $db->sql_escape(utf8_clean_string($author)) . "'"; - } - - if (!count($author_id_ary)) - { - trigger_error('NO_SEARCH_RESULTS'); - } - } - - // if we search in an existing search result just add the additional keywords. But we need to use "all search terms"-mode - // so we can keep the old keywords in their old mode, but add the new ones as required words - if ($add_keywords) - { - if ($search_terms == 'all') - { - $keywords .= ' ' . $add_keywords; - } - else - { - $search_terms = 'all'; - $keywords = implode(' |', explode(' ', preg_replace('#\s+#u', ' ', $keywords))) . ' ' .$add_keywords; - } - } - - // Which forums should not be searched? Author searches are also carried out in unindexed forums - if (empty($keywords) && count($author_id_ary)) - { - $ex_fid_ary = array_keys($auth->acl_getf('!f_read', true)); - } - else - { - $ex_fid_ary = array_unique(array_merge(array_keys($auth->acl_getf('!f_read', true)), array_keys($auth->acl_getf('!f_search', true)))); - } - - $not_in_fid = (count($ex_fid_ary)) ? 'WHERE ' . $db->sql_in_set('f.forum_id', $ex_fid_ary, true) . " OR (f.forum_password <> '' AND fa.user_id <> " . (int) $user->data['user_id'] . ')' : ""; - - $sql = 'SELECT f.forum_id, f.forum_name, f.parent_id, f.forum_type, f.right_id, f.forum_password, f.forum_flags, fa.user_id - FROM ' . FORUMS_TABLE . ' f - LEFT JOIN ' . FORUMS_ACCESS_TABLE . " fa ON (fa.forum_id = f.forum_id - AND fa.session_id = '" . $db->sql_escape($user->session_id) . "') - $not_in_fid - ORDER BY f.left_id"; - $result = $db->sql_query($sql); - - $right_id = 0; - $reset_search_forum = true; - while ($row = $db->sql_fetchrow($result)) - { - if ($row['forum_password'] && $row['user_id'] != $user->data['user_id']) - { - $ex_fid_ary[] = (int) $row['forum_id']; - continue; - } - - // Exclude forums from active topics - if (!($row['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS) && ($search_id == 'active_topics')) - { - $ex_fid_ary[] = (int) $row['forum_id']; - continue; - } - - if (count($search_forum)) - { - if ($search_child) - { - if (in_array($row['forum_id'], $search_forum) && $row['right_id'] > $right_id) - { - $right_id = (int) $row['right_id']; - } - else if ($row['right_id'] < $right_id) - { - continue; - } - } - - if (!in_array($row['forum_id'], $search_forum)) - { - $ex_fid_ary[] = (int) $row['forum_id']; - $reset_search_forum = false; - } - } - } - $db->sql_freeresult($result); - - // find out in which forums the user is allowed to view posts - $m_approve_posts_fid_sql = $phpbb_content_visibility->get_global_visibility_sql('post', $ex_fid_ary, 'p.'); - $m_approve_topics_fid_sql = $phpbb_content_visibility->get_global_visibility_sql('topic', $ex_fid_ary, 't.'); - - if ($reset_search_forum) - { - $search_forum = array(); - } - - // Select which method we'll use to obtain the post_id or topic_id information - $search_type = $config['search_type']; - - if (!class_exists($search_type)) - { - trigger_error('NO_SUCH_SEARCH_MODULE'); - } - // We do some additional checks in the module to ensure it can actually be utilised - $error = false; - $search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher); - - if ($error) - { - trigger_error($error); - } - - // let the search module split up the keywords - if ($keywords) - { - $correct_query = $search->split_keywords($keywords, $search_terms); - $common_words = $search->get_common_words(); - if (!$correct_query || (!$search->get_search_query() && !count($author_id_ary) && !$search_id)) - { - $ignored = (count($common_words)) ? sprintf($user->lang['IGNORED_TERMS_EXPLAIN'], implode(' ', $common_words)) . '
' : ''; - $word_length = $search->get_word_length(); - if ($word_length) - { - trigger_error($ignored . $user->lang('NO_KEYWORDS', $user->lang('CHARACTERS', (int) $word_length['min']), $user->lang('CHARACTERS', (int) $word_length['max']))); - } - else - { - trigger_error($ignored); - } - } - } - - if (!$keywords && count($author_id_ary)) - { - // if it is an author search we want to show topics by default - $show_results = ($topic_id) ? 'posts' : $request->variable('sr', ($search_id == 'egosearch') ? 'topics' : 'posts'); - $show_results = ($show_results == 'posts') ? 'posts' : 'topics'; - } - - // define some variables needed for retrieving post_id/topic_id information - $sort_by_sql = array('a' => 'u.username_clean', 't' => (($show_results == 'posts') ? 'p.post_time' : 't.topic_last_post_time'), 'f' => 'f.forum_id', 'i' => 't.topic_title', 's' => (($show_results == 'posts') ? 'p.post_subject' : 't.topic_title')); - - /** - * Event to modify the SQL parameters before pre-made searches - * - * @event core.search_modify_param_before - * @var string keywords String of the specified keywords - * @var array sort_by_sql Array of SQL sorting instructions - * @var array ex_fid_ary Array of excluded forum ids - * @var array author_id_ary Array of exclusive author ids - * @var string search_id The id of the search request - * @var array id_ary Array of post or topic ids for search result - * @var string show_results 'posts' or 'topics' type of ids - * @since 3.1.3-RC1 - * @changed 3.1.10-RC1 Added id_ary, show_results - */ - $vars = array( - 'keywords', - 'sort_by_sql', - 'ex_fid_ary', - 'author_id_ary', - 'search_id', - 'id_ary', - 'show_results', - ); - extract($phpbb_dispatcher->trigger_event('core.search_modify_param_before', compact($vars))); - - // pre-made searches - $sql = $field = $l_search_title = ''; - if ($search_id) - { - switch ($search_id) - { - // Oh holy Bob, bring us some activity... - case 'active_topics': - $l_search_title = $user->lang['SEARCH_ACTIVE_TOPICS']; - $show_results = 'topics'; - $sort_key = 't'; - $sort_dir = 'd'; - $sort_days = $request->variable('st', 7); - $sort_by_sql['t'] = 't.topic_last_post_time'; - - gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); - $s_sort_key = $s_sort_dir = ''; - - $last_post_time_sql = ($sort_days) ? ' AND t.topic_last_post_time > ' . (time() - ($sort_days * 24 * 3600)) : ''; - - $sql = 'SELECT t.topic_last_post_time, t.topic_id - FROM ' . TOPICS_TABLE . " t - WHERE t.topic_moved_id = 0 - $last_post_time_sql - AND " . $m_approve_topics_fid_sql . ' - ' . ((count($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '') . ' - ORDER BY t.topic_last_post_time DESC'; - $field = 'topic_id'; - break; - - case 'unanswered': - $l_search_title = $user->lang['SEARCH_UNANSWERED']; - $show_results = $request->variable('sr', 'topics'); - $show_results = ($show_results == 'posts') ? 'posts' : 'topics'; - $sort_by_sql['t'] = ($show_results == 'posts') ? 'p.post_time' : 't.topic_last_post_time'; - $sort_by_sql['s'] = ($show_results == 'posts') ? 'p.post_subject' : 't.topic_title'; - $sql_sort = 'ORDER BY ' . $sort_by_sql[$sort_key] . (($sort_dir == 'a') ? ' ASC' : ' DESC'); - - $sort_join = ($sort_key == 'f') ? FORUMS_TABLE . ' f, ' : ''; - $sql_sort = ($sort_key == 'f') ? ' AND f.forum_id = p.forum_id ' . $sql_sort : $sql_sort; - - if ($sort_days) - { - $last_post_time = 'AND p.post_time > ' . (time() - ($sort_days * 24 * 3600)); - } - else - { - $last_post_time = ''; - } - - if ($sort_key == 'a') - { - $sort_join = USERS_TABLE . ' u, '; - $sql_sort = ' AND u.user_id = p.poster_id ' . $sql_sort; - } - if ($show_results == 'posts') - { - $sql = "SELECT p.post_id - FROM $sort_join" . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t - WHERE t.topic_posts_approved = 1 - AND p.topic_id = t.topic_id - $last_post_time - AND $m_approve_posts_fid_sql - " . ((count($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . " - $sql_sort"; - $field = 'post_id'; - } - else - { - $sql = 'SELECT DISTINCT ' . $sort_by_sql[$sort_key] . ", p.topic_id - FROM $sort_join" . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t - WHERE t.topic_posts_approved = 1 - AND t.topic_moved_id = 0 - AND p.topic_id = t.topic_id - $last_post_time - AND $m_approve_topics_fid_sql - " . ((count($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . " - $sql_sort"; - $field = 'topic_id'; - } - break; - - case 'unreadposts': - $l_search_title = $user->lang['SEARCH_UNREAD']; - // force sorting - $show_results = 'topics'; - $sort_key = 't'; - $sort_by_sql['t'] = 't.topic_last_post_time'; - $sql_sort = 'ORDER BY ' . $sort_by_sql[$sort_key] . (($sort_dir == 'a') ? ' ASC' : ' DESC'); - - $sql_where = 'AND t.topic_moved_id = 0 - AND ' . $m_approve_topics_fid_sql . ' - ' . ((count($ex_fid_ary)) ? 'AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : ''); - - gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); - $s_sort_key = $s_sort_dir = $u_sort_param = $s_limit_days = ''; - - $template->assign_var('U_MARK_ALL_READ', ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}index.$phpEx", 'hash=' . generate_link_hash('global') . '&mark=forums&mark_time=' . time()) : ''); - break; - - case 'newposts': - $l_search_title = $user->lang['SEARCH_NEW']; - // force sorting - $show_results = ($request->variable('sr', 'topics') == 'posts') ? 'posts' : 'topics'; - $sort_key = 't'; - $sort_dir = 'd'; - $sort_by_sql['t'] = ($show_results == 'posts') ? 'p.post_time' : 't.topic_last_post_time'; - $sql_sort = 'ORDER BY ' . $sort_by_sql[$sort_key] . (($sort_dir == 'a') ? ' ASC' : ' DESC'); - - gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); - $s_sort_key = $s_sort_dir = $u_sort_param = $s_limit_days = ''; - - if ($show_results == 'posts') - { - $sql = 'SELECT p.post_id - FROM ' . POSTS_TABLE . ' p - WHERE p.post_time > ' . $user->data['user_lastvisit'] . ' - AND ' . $m_approve_posts_fid_sql . ' - ' . ((count($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . " - $sql_sort"; - $field = 'post_id'; - } - else - { - $sql = 'SELECT t.topic_id - FROM ' . TOPICS_TABLE . ' t - WHERE t.topic_last_post_time > ' . $user->data['user_lastvisit'] . ' - AND t.topic_moved_id = 0 - AND ' . $m_approve_topics_fid_sql . ' - ' . ((count($ex_fid_ary)) ? 'AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '') . " - $sql_sort"; -/* - [Fix] queued replies missing from "view new posts" (Bug #42705 - Patch by Paul) - - Creates temporary table, query is far from optimized - - $sql = 'SELECT t.topic_id - FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p - WHERE p.post_time > ' . $user->data['user_lastvisit'] . ' - AND t.topic_id = p.topic_id - AND t.topic_moved_id = 0 - AND ' . $m_approve_topics_fid_sql . " - GROUP BY t.topic_id - $sql_sort"; -*/ - $field = 'topic_id'; - } - break; - - case 'egosearch': - $l_search_title = $user->lang['SEARCH_SELF']; - break; - } - } - - /** - * Event to modify data after pre-made searches - * - * @event core.search_modify_param_after - * @var string l_search_title The title of the search page - * @var string search_id Predefined search type name - * @var string show_results Display topics or posts - * @var string sql SQL query corresponding to the pre-made search id - * @since 3.1.7-RC1 - */ - $vars = array( - 'l_search_title', - 'search_id', - 'show_results', - 'sql', - ); - extract($phpbb_dispatcher->trigger_event('core.search_modify_param_after', compact($vars))); - - // show_results should not change after this - $per_page = ($show_results == 'posts') ? $config['posts_per_page'] : $config['topics_per_page']; - $total_match_count = 0; - - // Set limit for the $total_match_count to reduce server load - $total_matches_limit = 1000; - $found_more_search_matches = false; - - if ($search_id) - { - if ($sql) - { - // Only return up to $total_matches_limit+1 ids (the last one will be removed later) - $result = $db->sql_query_limit($sql, $total_matches_limit + 1); - - while ($row = $db->sql_fetchrow($result)) - { - $id_ary[] = (int) $row[$field]; - } - $db->sql_freeresult($result); - } - else if ($search_id == 'unreadposts') - { - // Only return up to $total_matches_limit+1 ids (the last one will be removed later) - $id_ary = array_keys(get_unread_topics($user->data['user_id'], $sql_where, $sql_sort, $total_matches_limit + 1)); - } - else - { - $search_id = ''; - } - - $total_match_count = count($id_ary); - if ($total_match_count) - { - // Limit the number to $total_matches_limit for pre-made searches - if ($total_match_count > $total_matches_limit) - { - $found_more_search_matches = true; - $total_match_count = $total_matches_limit; - } - - // Make sure $start is set to the last page if it exceeds the amount - $start = $pagination->validate_start($start, $per_page, $total_match_count); - - $id_ary = array_slice($id_ary, $start, $per_page); - } - else - { - // Set $start to 0 if no matches were found - $start = 0; - } - } - - // make sure that some arrays are always in the same order - sort($ex_fid_ary); - sort($author_id_ary); - - if ($search->get_search_query()) - { - $total_match_count = $search->keyword_search($show_results, $search_fields, $search_terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_posts_fid_sql, $topic_id, $author_id_ary, $sql_author_match, $id_ary, $start, $per_page); - } - else if (count($author_id_ary)) - { - $firstpost_only = ($search_fields === 'firstpost' || $search_fields == 'titleonly') ? true : false; - $total_match_count = $search->author_search($show_results, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_posts_fid_sql, $topic_id, $author_id_ary, $sql_author_match, $id_ary, $start, $per_page); - } - - /** - * Event to search otherwise than by keywords or author - * - * @event core.search_backend_search_after - * @var string show_results 'posts' or 'topics' type of ids - * @var string search_fields The data fields to search in - * @var string search_terms Is either 'all' (use query as entered, words without prefix should default to "have to be in field") or 'any' (ignore search query parts and just return all posts that contain any of the specified words) - * @var array sort_by_sql Array of SQL sorting instructions - * @var string sort_key The sort key - * @var string sort_dir The sort direction - * @var int sort_days Limit the age of results - * @var array ex_fid_ary Array of excluded forum ids - * @var string m_approve_posts_fid_sql Specifies which types of posts the user can view in which forums - * @var int topic_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched - * @var array author_id_ary Array of exclusive author ids - * @var string sql_author_match Specifies the author match, when ANONYMOUS is also a search-match - * @var array id_ary Array of post or topic ids for search result - * @var int start The starting id of the results - * @var int per_page Number of ids each page is supposed to contain - * @var int total_match_count The total number of search matches - * @since 3.1.10-RC1 - */ - $vars = array( - 'show_results', - 'search_fields', - 'search_terms', - 'sort_by_sql', - 'sort_key', - 'sort_dir', - 'sort_days', - 'ex_fid_ary', - 'm_approve_posts_fid_sql', - 'topic_id', - 'author_id_ary', - 'sql_author_match', - 'id_ary', - 'start', - 'per_page', - 'total_match_count', - ); - extract($phpbb_dispatcher->trigger_event('core.search_backend_search_after', compact($vars))); - - $sql_where = ''; - - if (count($id_ary)) - { - $sql_where .= $db->sql_in_set(($show_results == 'posts') ? 'p.post_id' : 't.topic_id', $id_ary); - $sql_where .= (count($ex_fid_ary)) ? ' AND (' . $db->sql_in_set('f.forum_id', $ex_fid_ary, true) . ' OR f.forum_id IS NULL)' : ''; - $sql_where .= ' AND ' . (($show_results == 'posts') ? $m_approve_posts_fid_sql : $m_approve_topics_fid_sql); - } - - if ($show_results == 'posts') - { - include($phpbb_root_path . 'includes/functions_posting.' . $phpEx); - } - else - { - include($phpbb_root_path . 'includes/functions_display.' . $phpEx); - } - - $user->add_lang('viewtopic'); - - // Grab icons - $icons = $cache->obtain_icons(); - - // define some vars for urls - // A single wildcard will make the search results look ugly - $hilit = phpbb_clean_search_string(str_replace(array('+', '-', '|', '(', ')', '"'), ' ', $keywords)); - $hilit = str_replace(' ', '|', $hilit); - - $u_hilit = urlencode(htmlspecialchars_decode(str_replace('|', ' ', $hilit))); - $u_show_results = '&sr=' . $show_results; - $u_search_forum = implode('&fid%5B%5D=', $search_forum); - - $u_search = append_sid("{$phpbb_root_path}search.$phpEx", $u_sort_param . $u_show_results); - $u_search .= ($search_id) ? '&search_id=' . $search_id : ''; - $u_search .= ($u_hilit) ? '&keywords=' . urlencode(htmlspecialchars_decode($keywords)) : ''; - $u_search .= ($search_terms != 'all') ? '&terms=' . $search_terms : ''; - $u_search .= ($topic_id) ? '&t=' . $topic_id : ''; - $u_search .= ($author) ? '&author=' . urlencode(htmlspecialchars_decode($author)) : ''; - $u_search .= ($author_id) ? '&author_id=' . $author_id : ''; - $u_search .= ($u_search_forum) ? '&fid%5B%5D=' . $u_search_forum : ''; - $u_search .= (!$search_child) ? '&sc=0' : ''; - $u_search .= ($search_fields != 'all') ? '&sf=' . $search_fields : ''; - $u_search .= ($return_chars != 300) ? '&ch=' . $return_chars : ''; - - /** - * Event to add or modify search URL parameters - * - * @event core.search_modify_url_parameters - * @var string u_search Search URL parameters string - * @var string search_id Predefined search type name - * @var string show_results String indicating the show results mode - * @var string sql_where The SQL WHERE string used by search to get topic data - * @var int total_match_count The total number of search matches - * @var array ex_fid_ary Array of excluded forum ids - * @since 3.1.7-RC1 - * @changed 3.1.10-RC1 Added show_results, sql_where, total_match_count - * @changed 3.1.11-RC1 Added ex_fid_ary - */ - $vars = array( - 'u_search', - 'search_id', - 'show_results', - 'sql_where', - 'total_match_count', - 'ex_fid_ary', - ); - extract($phpbb_dispatcher->trigger_event('core.search_modify_url_parameters', compact($vars))); - - if ($sql_where) - { - if ($show_results == 'posts') - { - // @todo Joining this query to the one below? - $sql = 'SELECT zebra_id, friend, foe - FROM ' . ZEBRA_TABLE . ' - WHERE user_id = ' . $user->data['user_id']; - $result = $db->sql_query($sql); - - $zebra = array(); - while ($row = $db->sql_fetchrow($result)) - { - $zebra[($row['friend']) ? 'friend' : 'foe'][] = $row['zebra_id']; - } - $db->sql_freeresult($result); - - $sql_array = array( - 'SELECT' => 'p.*, f.forum_id, f.forum_name, t.*, u.username, u.username_clean, u.user_sig, u.user_sig_bbcode_uid, u.user_colour', - 'FROM' => array( - POSTS_TABLE => 'p', - ), - 'LEFT_JOIN' => array( - array( - 'FROM' => array(TOPICS_TABLE => 't'), - 'ON' => 'p.topic_id = t.topic_id', - ), - array( - 'FROM' => array(FORUMS_TABLE => 'f'), - 'ON' => 'p.forum_id = f.forum_id', - ), - array( - 'FROM' => array(USERS_TABLE => 'u'), - 'ON' => 'p.poster_id = u.user_id', - ), - ), - 'WHERE' => $sql_where, - 'ORDER_BY' => $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'), - ); - - /** - * Event to modify the SQL query before the posts data is retrieved - * - * @event core.search_get_posts_data - * @var array sql_array The SQL array - * @var array zebra Array of zebra data for the current user - * @var int total_match_count The total number of search matches - * @var string keywords String of the specified keywords - * @var array sort_by_sql Array of SQL sorting instructions - * @var string s_sort_dir The sort direction - * @var string s_sort_key The sort key - * @var string s_limit_days Limit the age of results - * @var array ex_fid_ary Array of excluded forum ids - * @var array author_id_ary Array of exclusive author ids - * @var string search_fields The data fields to search in - * @var int search_id The id of the search request - * @var int start The starting id of the results - * @since 3.1.0-b3 - */ - $vars = array( - 'sql_array', - 'zebra', - 'total_match_count', - 'keywords', - 'sort_by_sql', - 's_sort_dir', - 's_sort_key', - 's_limit_days', - 'ex_fid_ary', - 'author_id_ary', - 'search_fields', - 'search_id', - 'start', - ); - extract($phpbb_dispatcher->trigger_event('core.search_get_posts_data', compact($vars))); - - $sql = $db->sql_build_query('SELECT', $sql_array); - } - else - { - $sql_from = TOPICS_TABLE . ' t - LEFT JOIN ' . FORUMS_TABLE . ' f ON (f.forum_id = t.forum_id) - ' . (($sort_key == 'a') ? ' LEFT JOIN ' . USERS_TABLE . ' u ON (u.user_id = t.topic_poster) ' : ''); - $sql_select = 't.*, f.forum_id, f.forum_name'; - - if ($user->data['is_registered']) - { - if ($config['load_db_track'] && $author_id !== $user->data['user_id']) - { - $sql_from .= ' LEFT JOIN ' . TOPICS_POSTED_TABLE . ' tp ON (tp.user_id = ' . $user->data['user_id'] . ' - AND t.topic_id = tp.topic_id)'; - $sql_select .= ', tp.topic_posted'; - } - - if ($config['load_db_lastread']) - { - $sql_from .= ' LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (tt.user_id = ' . $user->data['user_id'] . ' - AND t.topic_id = tt.topic_id) - LEFT JOIN ' . FORUMS_TRACK_TABLE . ' ft ON (ft.user_id = ' . $user->data['user_id'] . ' - AND ft.forum_id = f.forum_id)'; - $sql_select .= ', tt.mark_time, ft.mark_time as f_mark_time'; - } - } - - if ($config['load_anon_lastread'] || ($user->data['is_registered'] && !$config['load_db_lastread'])) - { - $tracking_topics = $request->variable($config['cookie_name'] . '_track', '', true, \phpbb\request\request_interface::COOKIE); - $tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array(); - } - - $sql_order_by = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'); - - /** - * Event to modify the SQL query before the topic data is retrieved - * - * @event core.search_get_topic_data - * @var string sql_select The SQL SELECT string used by search to get topic data - * @var string sql_from The SQL FROM string used by search to get topic data - * @var string sql_where The SQL WHERE string used by search to get topic data - * @var int total_match_count The total number of search matches - * @var array sort_by_sql Array of SQL sorting instructions - * @var string sort_dir The sorting direction - * @var string sort_key The sorting key - * @var string sql_order_by The SQL ORDER BY string used by search to get topic data - * @since 3.1.0-a1 - * @changed 3.1.0-RC5 Added total_match_count - * @changed 3.1.7-RC1 Added sort_by_sql, sort_dir, sort_key, sql_order_by - */ - $vars = array( - 'sql_select', - 'sql_from', - 'sql_where', - 'total_match_count', - 'sort_by_sql', - 'sort_dir', - 'sort_key', - 'sql_order_by', - ); - extract($phpbb_dispatcher->trigger_event('core.search_get_topic_data', compact($vars))); - - $sql = "SELECT $sql_select - FROM $sql_from - WHERE $sql_where - ORDER BY $sql_order_by"; - } - $result = $db->sql_query($sql); - $result_topic_id = 0; - - $rowset = $attachments = $topic_tracking_info = array(); - - if ($show_results == 'topics') - { - $forums = $rowset = $shadow_topic_list = array(); - while ($row = $db->sql_fetchrow($result)) - { - $row['forum_id'] = (int) $row['forum_id']; - $row['topic_id'] = (int) $row['topic_id']; - - if ($row['topic_status'] == ITEM_MOVED) - { - $shadow_topic_list[$row['topic_moved_id']] = $row['topic_id']; - } - - $rowset[$row['topic_id']] = $row; - - if (!isset($forums[$row['forum_id']]) && $user->data['is_registered'] && $config['load_db_lastread']) - { - $forums[$row['forum_id']]['mark_time'] = $row['f_mark_time']; - } - $forums[$row['forum_id']]['topic_list'][] = $row['topic_id']; - $forums[$row['forum_id']]['rowset'][$row['topic_id']] = &$rowset[$row['topic_id']]; - } - $db->sql_freeresult($result); - - // If we have some shadow topics, update the rowset to reflect their topic information - if (count($shadow_topic_list)) - { - $sql = 'SELECT * - FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', array_keys($shadow_topic_list)); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $orig_topic_id = $shadow_topic_list[$row['topic_id']]; - - // We want to retain some values - $row = array_merge($row, array( - 'topic_moved_id' => $rowset[$orig_topic_id]['topic_moved_id'], - 'topic_status' => $rowset[$orig_topic_id]['topic_status'], - 'forum_name' => $rowset[$orig_topic_id]['forum_name']) - ); - - $rowset[$orig_topic_id] = $row; - } - $db->sql_freeresult($result); - } - unset($shadow_topic_list); - - foreach ($forums as $forum_id => $forum) - { - if ($user->data['is_registered'] && $config['load_db_lastread']) - { - $topic_tracking_info[$forum_id] = get_topic_tracking($forum_id, $forum['topic_list'], $forum['rowset'], array($forum_id => $forum['mark_time'])); - } - else if ($config['load_anon_lastread'] || $user->data['is_registered']) - { - $topic_tracking_info[$forum_id] = get_complete_topic_tracking($forum_id, $forum['topic_list']); - - if (!$user->data['is_registered']) - { - $user->data['user_lastmark'] = (isset($tracking_topics['l'])) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0; - } - } - } - unset($forums); - } - else - { - $text_only_message = ''; - $attach_list = array(); - - while ($row = $db->sql_fetchrow($result)) - { - /** - * Modify the row of a post result before the post_text is trimmed - * - * @event core.search_modify_post_row - * @var string hilit String to highlight - * @var array row Array with the post data - * @var string u_hilit Highlight string to be injected into URL - * @var string view Search results view mode - * @var array zebra Array with zebra data for the current user - * @since 3.2.2-RC1 - */ - $vars = array( - 'hilit', - 'row', - 'u_hilit', - 'view', - 'zebra', - ); - extract($phpbb_dispatcher->trigger_event('core.search_modify_post_row', compact($vars))); - - // We pre-process some variables here for later usage - $row['post_text'] = censor_text($row['post_text']); - - $text_only_message = $row['post_text']; - // make list items visible as such - if ($row['bbcode_uid']) - { - $text_only_message = str_replace('[*:' . $row['bbcode_uid'] . ']', '⋅ ', $text_only_message); - // no BBCode in text only message - strip_bbcode($text_only_message, $row['bbcode_uid']); - } - - if ($return_chars == -1 || utf8_strlen($text_only_message) < ($return_chars + 3)) - { - $row['display_text_only'] = false; - - // Does this post have an attachment? If so, add it to the list - if ($row['post_attachment'] && $config['allow_attachments']) - { - $attach_list[$row['forum_id']][] = $row['post_id']; - } - } - else - { - $row['post_text'] = $text_only_message; - $row['display_text_only'] = true; - } - - $rowset[] = $row; - } - $db->sql_freeresult($result); - - unset($text_only_message); - - // Pull attachment data - if (count($attach_list)) - { - $use_attach_list = $attach_list; - $attach_list = array(); - - foreach ($use_attach_list as $forum_id => $_list) - { - if ($auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id)) - { - $attach_list = array_merge($attach_list, $_list); - } - } - } - - if (count($attach_list)) - { - $sql = 'SELECT * - FROM ' . ATTACHMENTS_TABLE . ' - WHERE ' . $db->sql_in_set('post_msg_id', $attach_list) . ' - AND in_message = 0 - ORDER BY filetime DESC, post_msg_id ASC'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $attachments[$row['post_msg_id']][] = $row; - } - $db->sql_freeresult($result); - } - } - - if ($hilit) - { - // Remove bad highlights - $hilit_array = array_filter(explode('|', $hilit), 'strlen'); - foreach ($hilit_array as $key => $value) - { - $hilit_array[$key] = phpbb_clean_search_string($value); - $hilit_array[$key] = str_replace('\*', '\w*?', preg_quote($hilit_array[$key], '#')); - $hilit_array[$key] = preg_replace('#(^|\s)\\\\w\*\?(\s|$)#', '$1\w+?$2', $hilit_array[$key]); - } - $hilit = implode('|', $hilit_array); - } - - /** - * Modify the rowset data - * - * @event core.search_modify_rowset - * @var array attachments Array with posts attachments data - * @var string hilit String to highlight - * @var array rowset Array with the search results data - * @var string show_results String indicating the show results mode - * @var array topic_tracking_info Array with the topics tracking data - * @var string u_hilit Highlight string to be injected into URL - * @var string view Search results view mode - * @var array zebra Array with zebra data for the current user - * @since 3.1.0-b4 - * @changed 3.1.0-b5 Added var show_results - */ - $vars = array( - 'attachments', - 'hilit', - 'rowset', - 'show_results', - 'topic_tracking_info', - 'u_hilit', - 'view', - 'zebra', - ); - extract($phpbb_dispatcher->trigger_event('core.search_modify_rowset', compact($vars))); - - foreach ($rowset as $row) - { - $forum_id = $row['forum_id']; - $result_topic_id = $row['topic_id']; - $topic_title = censor_text($row['topic_title']); - $replies = $phpbb_content_visibility->get_count('topic_posts', $row, $forum_id) - 1; - - $view_topic_url_params = "f=$forum_id&t=$result_topic_id" . (($u_hilit) ? "&hilit=$u_hilit" : ''); - $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params); - - if ($show_results == 'topics') - { - if ($config['load_db_track'] && $author_id === $user->data['user_id']) - { - $row['topic_posted'] = 1; - } - - $folder_img = $folder_alt = $topic_type = ''; - topic_status($row, $replies, (isset($topic_tracking_info[$forum_id][$row['topic_id']]) && $row['topic_last_post_time'] > $topic_tracking_info[$forum_id][$row['topic_id']]) ? true : false, $folder_img, $folder_alt, $topic_type); - - $unread_topic = (isset($topic_tracking_info[$forum_id][$row['topic_id']]) && $row['topic_last_post_time'] > $topic_tracking_info[$forum_id][$row['topic_id']]) ? true : false; - - $topic_unapproved = (($row['topic_visibility'] == ITEM_UNAPPROVED || $row['topic_visibility'] == ITEM_REAPPROVE) && $auth->acl_get('m_approve', $forum_id)) ? true : false; - $posts_unapproved = ($row['topic_visibility'] == ITEM_APPROVED && $row['topic_posts_unapproved'] && $auth->acl_get('m_approve', $forum_id)) ? true : false; - $topic_deleted = $row['topic_visibility'] == ITEM_DELETED; - $u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . "&t=$result_topic_id", true, $user->session_id) : ''; - $u_mcp_queue = (!$u_mcp_queue && $topic_deleted) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue&mode=deleted_topics&t=$result_topic_id", true, $user->session_id) : $u_mcp_queue; - - $row['topic_title'] = preg_replace('#(?!<.*)(?]*(?:)#isu', '$1', $row['topic_title']); - - $tpl_ary = array( - 'TOPIC_AUTHOR' => get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), - 'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), - 'TOPIC_AUTHOR_FULL' => get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), - 'FIRST_POST_TIME' => $user->format_date($row['topic_time']), - 'LAST_POST_SUBJECT' => $row['topic_last_post_subject'], - 'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']), - 'LAST_VIEW_TIME' => $user->format_date($row['topic_last_view_time']), - 'LAST_POST_AUTHOR' => get_username_string('username', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), - 'LAST_POST_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), - 'LAST_POST_AUTHOR_FULL' => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), - - 'TOPIC_TYPE' => $topic_type, - - 'TOPIC_IMG_STYLE' => $folder_img, - 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt), - 'TOPIC_FOLDER_IMG_ALT' => $user->lang[$folder_alt], - - 'TOPIC_ICON_IMG' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['img'] : '', - 'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['width'] : '', - 'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['height'] : '', - 'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id) && $row['topic_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', - 'UNAPPROVED_IMG' => ($topic_unapproved || $posts_unapproved) ? $user->img('icon_topic_unapproved', ($topic_unapproved) ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '', - - 'S_TOPIC_TYPE' => $row['topic_type'], - 'S_USER_POSTED' => (!empty($row['topic_posted'])) ? true : false, - 'S_UNREAD_TOPIC' => $unread_topic, - - 'S_TOPIC_REPORTED' => (!empty($row['topic_reported']) && $auth->acl_get('m_report', $forum_id)) ? true : false, - 'S_TOPIC_UNAPPROVED' => $topic_unapproved, - 'S_POSTS_UNAPPROVED' => $posts_unapproved, - 'S_TOPIC_DELETED' => $topic_deleted, - 'S_HAS_POLL' => ($row['poll_start']) ? true : false, - - 'U_LAST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params . '&p=' . $row['topic_last_post_id']) . '#p' . $row['topic_last_post_id'], - 'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), - 'U_TOPIC_AUTHOR' => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), - 'U_NEWEST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params . '&view=unread') . '#unread', - 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=reports&t=' . $result_topic_id, true, $user->session_id), - 'U_MCP_QUEUE' => $u_mcp_queue, - ); - } - else - { - if ((isset($zebra['foe']) && in_array($row['poster_id'], $zebra['foe'])) && (!$view || $view != 'show' || $post_id != $row['post_id'])) - { - $template->assign_block_vars('searchresults', array( - 'S_IGNORE_POST' => true, - - 'L_IGNORE_POST' => sprintf($user->lang['POST_BY_FOE'], $row['username'], "', '')) - ); - - continue; - } - - // Replace naughty words such as farty pants - $row['post_subject'] = censor_text($row['post_subject']); - - if ($row['display_text_only']) - { - // now find context for the searched words - $row['post_text'] = get_context($row['post_text'], array_filter(explode('|', $hilit), 'strlen'), $return_chars); - $row['post_text'] = bbcode_nl2br($row['post_text']); - } - else - { - $parse_flags = ($row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES; - $row['post_text'] = generate_text_for_display($row['post_text'], $row['bbcode_uid'], $row['bbcode_bitfield'], $parse_flags, false); - - if (!empty($attachments[$row['post_id']])) - { - parse_attachments($forum_id, $row['post_text'], $attachments[$row['post_id']], $update_count); - - // we only display inline attachments - unset($attachments[$row['post_id']]); - } - } - - if ($hilit) - { - // post highlighting - $row['post_text'] = preg_replace('#(?!<.*)(?]*(?:)#isu', '$1', $row['post_text']); - $row['post_subject'] = preg_replace('#(?!<.*)(?]*(?:)#isu', '$1', $row['post_subject']); - } - - $tpl_ary = array( - 'POST_AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), - 'POST_AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), - 'POST_AUTHOR' => get_username_string('username', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), - 'U_POST_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), - - 'POST_SUBJECT' => $row['post_subject'], - 'POST_DATE' => (!empty($row['post_time'])) ? $user->format_date($row['post_time']) : '', - 'MESSAGE' => $row['post_text'] - ); - } - - $tpl_ary = array_merge($tpl_ary, array( - 'FORUM_ID' => $forum_id, - 'TOPIC_ID' => $result_topic_id, - 'POST_ID' => ($show_results == 'posts') ? $row['post_id'] : false, - - 'FORUM_TITLE' => $row['forum_name'], - 'TOPIC_TITLE' => $topic_title, - 'TOPIC_REPLIES' => $replies, - 'TOPIC_VIEWS' => $row['topic_views'], - - 'U_VIEW_TOPIC' => $view_topic_url, - 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id), - 'U_VIEW_POST' => (!empty($row['post_id'])) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=" . $row['topic_id'] . '&p=' . $row['post_id'] . (($u_hilit) ? '&hilit=' . $u_hilit : '')) . '#p' . $row['post_id'] : '', - )); - - /** - * Modify the topic data before it is assigned to the template - * - * @event core.search_modify_tpl_ary - * @var array row Array with topic data - * @var array tpl_ary Template block array with topic data - * @var string show_results Display topics or posts - * @var string topic_title Cleaned topic title - * @var int replies The number of topic replies - * @var string view_topic_url The URL to the topic - * @var string folder_img The folder image of the topic - * @var string folder_alt The alt attribute of the topic folder img - * @var int topic_type The topic type - * @var bool unread_topic Whether the topic has unread posts - * @var bool topic_unapproved Whether the topic is unapproved - * @var int posts_unapproved The number of unapproved posts - * @var bool topic_deleted Whether the topic has been deleted - * @var string u_mcp_queue The URL to the corresponding MCP queue page - * @var array zebra The zebra data of the current user - * @var array attachments All the attachments of the search results - * @since 3.1.0-a1 - * @changed 3.1.0-b3 Added vars show_results, topic_title, replies, - * view_topic_url, folder_img, folder_alt, topic_type, unread_topic, - * topic_unapproved, posts_unapproved, topic_deleted, u_mcp_queue, - * zebra, attachments - */ - $vars = array( - 'row', - 'tpl_ary', - 'show_results', - 'topic_title', - 'replies', - 'view_topic_url', - 'folder_img', - 'folder_alt', - 'topic_type', - 'unread_topic', - 'topic_unapproved', - 'posts_unapproved', - 'topic_deleted', - 'u_mcp_queue', - 'zebra', - 'attachments', - ); - extract($phpbb_dispatcher->trigger_event('core.search_modify_tpl_ary', compact($vars))); - - $template->assign_block_vars('searchresults', $tpl_ary); - - if ($show_results == 'topics') - { - $pagination->generate_template_pagination($view_topic_url, 'searchresults.pagination', 'start', $replies + 1, $config['posts_per_page'], 1, true, true); - } - } - - if ($topic_id && ($topic_id == $result_topic_id)) - { - $template->assign_vars(array( - 'SEARCH_TOPIC' => $topic_title, - 'L_RETURN_TO_TOPIC' => $user->lang('RETURN_TO', $topic_title), - 'U_SEARCH_TOPIC' => $view_topic_url - )); - } - } - unset($rowset); - - // Output header - if ($found_more_search_matches) - { - $l_search_matches = $user->lang('FOUND_MORE_SEARCH_MATCHES', (int) $total_match_count); - } - else - { - $l_search_matches = $user->lang('FOUND_SEARCH_MATCHES', (int) $total_match_count); - } - - // Check if search backend supports phrase search or not - $phrase_search_disabled = ''; - if (strpos(html_entity_decode($keywords), '"') !== false && method_exists($search, 'supports_phrase_search')) - { - $phrase_search_disabled = $search->supports_phrase_search() ? false : true; - } - - $pagination->generate_template_pagination($u_search, 'pagination', 'start', $total_match_count, $per_page, $start); - - $template->assign_vars(array( - 'SEARCH_TITLE' => $l_search_title, - 'SEARCH_MATCHES' => $l_search_matches, - 'SEARCH_WORDS' => $keywords, - 'SEARCHED_QUERY' => $search->get_search_query(), - 'IGNORED_WORDS' => (!empty($common_words)) ? implode(' ', $common_words) : '', - - 'PHRASE_SEARCH_DISABLED' => $phrase_search_disabled, - - 'TOTAL_MATCHES' => $total_match_count, - 'SEARCH_IN_RESULTS' => ($search_id) ? false : true, - - 'S_SELECT_SORT_DIR' => $s_sort_dir, - 'S_SELECT_SORT_KEY' => $s_sort_key, - 'S_SELECT_SORT_DAYS' => $s_limit_days, - 'S_SEARCH_ACTION' => $u_search, - 'S_SHOW_TOPICS' => ($show_results == 'posts') ? false : true, - - 'GOTO_PAGE_IMG' => $user->img('icon_post_target', 'GOTO_PAGE'), - 'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'), - 'REPORTED_IMG' => $user->img('icon_topic_reported', 'TOPIC_REPORTED'), - 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'TOPIC_UNAPPROVED'), - 'DELETED_IMG' => $user->img('icon_topic_deleted', 'TOPIC_DELETED'), - 'POLL_IMG' => $user->img('icon_topic_poll', 'TOPIC_POLL'), - 'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'), - - 'U_SEARCH_WORDS' => $u_search, - )); - - /** - * Modify the title and/or load data for the search results page - * - * @event core.search_results_modify_search_title - * @var int author_id ID of the author to search by - * @var string l_search_title The title of the search page - * @var string search_id Predefined search type name - * @var string show_results Search results output mode - topics or posts - * @var int start The starting id of the results - * @var int total_match_count The count of search results - * @var string keywords The search keywords - * @since 3.1.0-RC4 - * @changed 3.1.6-RC1 Added total_match_count and keywords - */ - $vars = array( - 'author_id', - 'l_search_title', - 'search_id', - 'show_results', - 'start', - 'total_match_count', - 'keywords', - ); - extract($phpbb_dispatcher->trigger_event('core.search_results_modify_search_title', compact($vars))); - - page_header(($l_search_title) ? $l_search_title : $user->lang['SEARCH']); - - $template->set_filenames(array( - 'body' => 'search_results.html') - ); - make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx")); - - page_footer(); -} - -// Search forum -$rowset = array(); -$s_forums = ''; -$sql = 'SELECT f.forum_id, f.forum_name, f.parent_id, f.forum_type, f.left_id, f.right_id, f.forum_password, f.enable_indexing, fa.user_id - FROM ' . FORUMS_TABLE . ' f - LEFT JOIN ' . FORUMS_ACCESS_TABLE . " fa ON (fa.forum_id = f.forum_id - AND fa.session_id = '" . $db->sql_escape($user->session_id) . "') - ORDER BY f.left_id ASC"; -$result = $db->sql_query($sql); - -while ($row = $db->sql_fetchrow($result)) -{ - $rowset[(int) $row['forum_id']] = $row; -} -$db->sql_freeresult($result); - -$right = $cat_right = $padding_inc = 0; -$padding = $forum_list = $holding = ''; -$pad_store = array('0' => ''); - -/** -* Modify the forum select list for advanced search page -* -* @event core.search_modify_forum_select_list -* @var array rowset Array with the forums list data -* @since 3.1.10-RC1 -*/ -$vars = array('rowset'); -extract($phpbb_dispatcher->trigger_event('core.search_modify_forum_select_list', compact($vars))); - -foreach ($rowset as $row) -{ - if ($row['forum_type'] == FORUM_CAT && ($row['left_id'] + 1 == $row['right_id'])) - { - // Non-postable forum with no subforums, don't display - continue; - } - - if ($row['forum_type'] == FORUM_POST && ($row['left_id'] + 1 == $row['right_id']) && !$row['enable_indexing']) - { - // Postable forum with no subforums and indexing disabled, don't display - continue; - } - - if ($row['forum_type'] == FORUM_LINK || ($row['forum_password'] && !$row['user_id'])) - { - // if this forum is a link or password protected (user has not entered the password yet) then skip to the next branch - continue; - } - - if ($row['left_id'] < $right) - { - $padding .= '   '; - $pad_store[$row['parent_id']] = $padding; - } - else if ($row['left_id'] > $right + 1) - { - if (isset($pad_store[$row['parent_id']])) - { - $padding = $pad_store[$row['parent_id']]; - } - else - { - continue; - } - } - - $right = $row['right_id']; - - if ($auth->acl_gets('!f_search', '!f_list', $row['forum_id'])) - { - // if the user does not have permissions to search or see this forum skip only this forum/category - continue; - } - - $selected = (in_array($row['forum_id'], $search_forum)) ? ' selected="selected"' : ''; - - if ($row['left_id'] > $cat_right) - { - // make sure we don't forget anything - $s_forums .= $holding; - $holding = ''; - } - - if ($row['right_id'] - $row['left_id'] > 1) - { - $cat_right = max($cat_right, $row['right_id']); - - $holding .= ''; - } - else - { - $s_forums .= $holding . ''; - $holding = ''; - } -} - -if ($holding) -{ - $s_forums .= $holding; -} - -unset($pad_store); -unset($rowset); - -if (!$s_forums) -{ - trigger_error('NO_SEARCH'); -} - -// Number of chars returned -$s_characters = ''; -$s_characters .= ''; -$s_characters .= ''; -$s_characters .= ''; - -for ($i = 100; $i <= 1000; $i += 100) -{ - $selected = ($i == 300) ? ' selected="selected"' : ''; - $s_characters .= ''; -} - -$s_hidden_fields = array('t' => $topic_id); - -if ($_SID) -{ - $s_hidden_fields['sid'] = $_SID; -} - -if (!empty($_EXTRA_URL)) -{ - foreach ($_EXTRA_URL as $url_param) - { - $url_param = explode('=', $url_param, 2); - $s_hidden_fields[$url_param[0]] = $url_param[1]; - } -} - -$template->assign_vars(array( - 'S_SEARCH_ACTION' => append_sid("{$phpbb_root_path}search.$phpEx", false, true, 0), // We force no ?sid= appending by using 0 - 'S_HIDDEN_FIELDS' => build_hidden_fields($s_hidden_fields), - 'S_CHARACTER_OPTIONS' => $s_characters, - 'S_FORUM_OPTIONS' => $s_forums, - 'S_SELECT_SORT_DIR' => $s_sort_dir, - 'S_SELECT_SORT_KEY' => $s_sort_key, - 'S_SELECT_SORT_DAYS' => $s_limit_days, - 'S_IN_SEARCH' => true, -)); - -// only show recent searches to search administrators -if ($auth->acl_get('a_search')) -{ - // Handle large objects differently for Oracle and MSSQL - switch ($db->get_sql_layer()) - { - case 'oracle': - $sql = 'SELECT search_time, search_keywords - FROM ' . SEARCH_RESULTS_TABLE . ' - WHERE dbms_lob.getlength(search_keywords) > 0 - ORDER BY search_time DESC'; - break; - - case 'mssql_odbc': - case 'mssqlnative': - $sql = 'SELECT search_time, search_keywords - FROM ' . SEARCH_RESULTS_TABLE . ' - WHERE DATALENGTH(search_keywords) > 0 - ORDER BY search_time DESC'; - break; - - default: - $sql = 'SELECT search_time, search_keywords - FROM ' . SEARCH_RESULTS_TABLE . ' - WHERE search_keywords <> \'\' - ORDER BY search_time DESC'; - break; - } - $result = $db->sql_query_limit($sql, 5); - - while ($row = $db->sql_fetchrow($result)) - { - $keywords = $row['search_keywords']; - - $template->assign_block_vars('recentsearch', array( - 'KEYWORDS' => $keywords, - 'TIME' => $user->format_date($row['search_time']), - - 'U_KEYWORDS' => append_sid("{$phpbb_root_path}search.$phpEx", 'keywords=' . urlencode(htmlspecialchars_decode($keywords))) - )); - } - $db->sql_freeresult($result); -} - -// Output the basic page -page_header($user->lang['SEARCH']); - -$template->set_filenames(array( - 'body' => 'search_body.html') -); -make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx")); - -page_footer(); diff --git a/install/update/old/styles/prosilver/style.cfg b/install/update/old/styles/prosilver/style.cfg deleted file mode 100644 index 4485b17..0000000 --- a/install/update/old/styles/prosilver/style.cfg +++ /dev/null @@ -1,32 +0,0 @@ -# -# phpBB Style Configuration File -# -# This file is part of the phpBB Forum Software package. -# -# @copyright (c) phpBB Limited -# @license GNU General Public License, version 2 (GPL-2.0) -# -# For full copyright and license information, please see -# the docs/CREDITS.txt file. -# -# At the left is the name, please do not change this -# At the right the value is entered -# -# Values get trimmed, if you want to add a space in front or at the end of -# the value, then enclose the value with single or double quotes. -# Single and double quotes do not need to be escaped. -# -# - -# General Information about this style -name = prosilver -copyright = © phpBB Limited, 2007 -style_version = 3.2.7 -phpbb_version = 3.2.7 - -# Defining a different template bitfield -# template_bitfield = //g= - -# Parent style -# Set value to empty or to this style's name if this style does not have a parent style -parent = prosilver diff --git a/install/update/old/styles/prosilver/template/attachment.html b/install/update/old/styles/prosilver/template/attachment.html deleted file mode 100644 index 0978d91..0000000 --- a/install/update/old/styles/prosilver/template/attachment.html +++ /dev/null @@ -1,48 +0,0 @@ - - - - -

[{_file.DENIED_MESSAGE}]

- - - - -
-
{_file.DOWNLOAD_NAME}
-
{_file.COMMENT}
-
- - - -
-
{_file.DOWNLOAD_NAME}
-
{_file.COMMENT}
-
{_file.DOWNLOAD_NAME} ({_file.FILESIZE} {_file.SIZE_LANG}) {_file.L_DOWNLOAD_COUNT}
-
- - - -
-
{_file.UPLOAD_ICON} {_file.DOWNLOAD_NAME}
-
{_file.COMMENT}
-
({_file.FILESIZE} {_file.SIZE_LANG}) {_file.L_DOWNLOAD_COUNT}
-
- - - - - - - - - - - - -

{_file.DOWNLOAD_NAME} [ {_file.FILESIZE} {_file.SIZE_LANG} | {_file.L_DOWNLOAD_COUNT} ]

- - - - - - diff --git a/install/update/old/styles/prosilver/template/bbcode.html b/install/update/old/styles/prosilver/template/bbcode.html deleted file mode 100644 index 940c0ac..0000000 --- a/install/update/old/styles/prosilver/template/bbcode.html +++ /dev/null @@ -1,75 +0,0 @@ -
    -
      -
    - -
      -
    - -
  • -
  • - -
    {USERNAME} {L_WROTE}{L_COLON} -
    -
    - -
    - - uncited - -
    - - - - - - - - - - - - - - - - - - - - - -
    -
    -
    -
    - -
    -
    - - -

    {L_CODE}{L_COLON} {L_SELECT_ALL_CODE}

    
    -
    - -
    -
    - - - - - - - - - - -{TEXT} - -{TEXT} - -{L_IMAGE} - -{DESCRIPTION} - -{DESCRIPTION} - - diff --git a/install/update/old/styles/prosilver/template/captcha_recaptcha.html b/install/update/old/styles/prosilver/template/captcha_recaptcha.html deleted file mode 100644 index a123f54..0000000 --- a/install/update/old/styles/prosilver/template/captcha_recaptcha.html +++ /dev/null @@ -1,30 +0,0 @@ - -
    -
    - -

    {L_CONFIRMATION}

    -

    {L_CONFIRM_EXPLAIN}

    - -
    - - - -
    -

    {L_RECAPTCHA_EXPLAIN}
    -
    - - -
    -
    -
    - -{L_RECAPTCHA_NOT_AVAILABLE} - - - -
    -
    -
    - diff --git a/install/update/old/styles/prosilver/template/forum_fn.js b/install/update/old/styles/prosilver/template/forum_fn.js deleted file mode 100644 index 3f28f8a..0000000 --- a/install/update/old/styles/prosilver/template/forum_fn.js +++ /dev/null @@ -1,937 +0,0 @@ -/* global phpbb */ - -/** -* phpBB3 forum functions -*/ - -/** -* Find a member -*/ -function find_username(url) { - 'use strict'; - - popup(url, 760, 570, '_usersearch'); - return false; -} - -/** -* Window popup -*/ -function popup(url, width, height, name) { - 'use strict'; - - if (!name) { - name = '_popup'; - } - - window.open(url.replace(/&/g, '&'), name, 'height=' + height + ',resizable=yes,scrollbars=yes, width=' + width); - return false; -} - -/** -* Jump to page -*/ -function pageJump(item) { - 'use strict'; - - var page = parseInt(item.val(), 10), - perPage = item.attr('data-per-page'), - baseUrl = item.attr('data-base-url'), - startName = item.attr('data-start-name'); - - if (page !== null && !isNaN(page) && page === Math.floor(page) && page > 0) { - if (baseUrl.indexOf('?') === -1) { - document.location.href = baseUrl + '?' + startName + '=' + ((page - 1) * perPage); - } else { - document.location.href = baseUrl.replace(/&/g, '&') + '&' + startName + '=' + ((page - 1) * perPage); - } - } -} - -/** -* Mark/unmark checklist -* id = ID of parent container, name = name prefix, state = state [true/false] -*/ -function marklist(id, name, state) { - 'use strict'; - - jQuery('#' + id + ' input[type=checkbox][name]').each(function() { - var $this = jQuery(this); - if ($this.attr('name').substr(0, name.length) === name && !$this.prop('disabled')) { - $this.prop('checked', state); - } - }); -} - -/** -* Resize viewable area for attached image or topic review panel (possibly others to come) -* e = element -*/ -function viewableArea(e, itself) { - 'use strict'; - - if (!e) { - return; - } - - if (!itself) { - e = e.parentNode; - } - - if (!e.vaHeight) { - // Store viewable area height before changing style to auto - e.vaHeight = e.offsetHeight; - e.vaMaxHeight = e.style.maxHeight; - e.style.height = 'auto'; - e.style.maxHeight = 'none'; - e.style.overflow = 'visible'; - } else { - // Restore viewable area height to the default - e.style.height = e.vaHeight + 'px'; - e.style.overflow = 'auto'; - e.style.maxHeight = e.vaMaxHeight; - e.vaHeight = false; - } -} - -/** -* Alternate display of subPanels -*/ -jQuery(function($) { - 'use strict'; - - $('.sub-panels').each(function() { - - var $childNodes = $('a[data-subpanel]', this), - panels = $childNodes.map(function () { - return this.getAttribute('data-subpanel'); - }), - showPanel = this.getAttribute('data-show-panel'); - - if (panels.length) { - activateSubPanel(showPanel, panels); - $childNodes.click(function () { - activateSubPanel(this.getAttribute('data-subpanel'), panels); - return false; - }); - } - }); -}); - -/** -* Activate specific subPanel -*/ -function activateSubPanel(p, panels) { - 'use strict'; - - var i, showPanel; - - if (typeof p === 'string') { - showPanel = p; - } - $('input[name="show_panel"]').val(showPanel); - - if (typeof panels === 'undefined') { - panels = jQuery('.sub-panels a[data-subpanel]').map(function() { - return this.getAttribute('data-subpanel'); - }); - } - - for (i = 0; i < panels.length; i++) { - jQuery('#' + panels[i]).css('display', panels[i] === showPanel ? 'block' : 'none'); - jQuery('#' + panels[i] + '-tab').toggleClass('activetab', panels[i] === showPanel); - } -} - -function selectCode(a) { - 'use strict'; - - // Get ID of code block - var e = a.parentNode.parentNode.getElementsByTagName('CODE')[0]; - var s, r; - - // Not IE and IE9+ - if (window.getSelection) { - s = window.getSelection(); - // Safari and Chrome - if (s.setBaseAndExtent) { - var l = (e.innerText.length > 1) ? e.innerText.length - 1 : 1; - try { - s.setBaseAndExtent(e, 0, e, l); - } catch (error) { - r = document.createRange(); - r.selectNodeContents(e); - s.removeAllRanges(); - s.addRange(r); - } - } - // Firefox and Opera - else { - // workaround for bug # 42885 - if (window.opera && e.innerHTML.substring(e.innerHTML.length - 4) === '
    ') { - e.innerHTML = e.innerHTML + ' '; - } - - r = document.createRange(); - r.selectNodeContents(e); - s.removeAllRanges(); - s.addRange(r); - } - } - // Some older browsers - else if (document.getSelection) { - s = document.getSelection(); - r = document.createRange(); - r.selectNodeContents(e); - s.removeAllRanges(); - s.addRange(r); - } - // IE - else if (document.selection) { - r = document.body.createTextRange(); - r.moveToElementText(e); - r.select(); - } -} - -var inAutocomplete = false; -var lastKeyEntered = ''; - -/** -* Check event key -*/ -function phpbbCheckKey(event) { - 'use strict'; - - // Keycode is array down or up? - if (event.keyCode && (event.keyCode === 40 || event.keyCode === 38)) { - inAutocomplete = true; - } - - // Make sure we are not within an "autocompletion" field - if (inAutocomplete) { - // If return pressed and key changed we reset the autocompletion - if (!lastKeyEntered || lastKeyEntered === event.which) { - inAutocomplete = false; - return true; - } - } - - // Keycode is not return, then return. ;) - if (event.which !== 13) { - lastKeyEntered = event.which; - return true; - } - - return false; -} - -/** -* Apply onkeypress event for forcing default submit button on ENTER key press -*/ -jQuery(function($) { - 'use strict'; - - $('form input[type=text], form input[type=password]').on('keypress', function (e) { - var defaultButton = $(this).parents('form').find('input[type=submit].default-submit-action'); - - if (!defaultButton || defaultButton.length <= 0) { - return true; - } - - if (phpbbCheckKey(e)) { - return true; - } - - if ((e.which && e.which === 13) || (e.keyCode && e.keyCode === 13)) { - defaultButton.click(); - return false; - } - - return true; - }); -}); - -/** -* Functions for user search popup -*/ -function insertUser(formId, value) { - 'use strict'; - - var $form = jQuery(formId), - formName = $form.attr('data-form-name'), - fieldName = $form.attr('data-field-name'), - item = opener.document.forms[formName][fieldName]; - - if (item.value.length && item.type === 'textarea') { - value = item.value + '\n' + value; - } - - item.value = value; -} - -function insert_marked_users(formId, users) { - 'use strict'; - - $(users).filter(':checked').each(function() { - insertUser(formId, this.value); - }); - - window.close(); -} - -function insert_single_user(formId, user) { - 'use strict'; - - insertUser(formId, user); - window.close(); -} - -/** -* Parse document block -*/ -function parseDocument($container) { - 'use strict'; - - var test = document.createElement('div'), - oldBrowser = (typeof test.style.borderRadius === 'undefined'), - $body = $('body'); - - /** - * Reset avatar dimensions when changing URL or EMAIL - */ - $container.find('input[data-reset-on-edit]').on('keyup', function() { - $(this.getAttribute('data-reset-on-edit')).val(''); - }); - - /** - * Pagination - */ - $container.find('.pagination .page-jump-form :button').click(function() { - var $input = $(this).siblings('input.inputbox'); - pageJump($input); - }); - - $container.find('.pagination .page-jump-form input.inputbox').on('keypress', function(event) { - if (event.which === 13 || event.keyCode === 13) { - event.preventDefault(); - pageJump($(this)); - } - }); - - $container.find('.pagination .dropdown-trigger').click(function() { - var $dropdownContainer = $(this).parent(); - // Wait a little bit to make sure the dropdown has activated - setTimeout(function() { - if ($dropdownContainer.hasClass('dropdown-visible')) { - $dropdownContainer.find('input.inputbox').focus(); - } - }, 100); - }); - - /** - * Adjust HTML code for IE8 and older versions - */ - // if (oldBrowser) { - // // Fix .linklist.bulletin lists - // $container - // .find('ul.linklist.bulletin > li') - // .filter(':first-child, .rightside:last-child') - // .addClass('no-bulletin'); - // } - - /** - * Resize navigation (breadcrumbs) block to keep all links on same line - */ - $container.find('.navlinks').each(function() { - var $this = $(this), - $left = $this.children().not('.rightside'), - $right = $this.children('.rightside'); - - if ($left.length !== 1 || !$right.length) { - return; - } - - function resize() { - var width = 0, - diff = $left.outerWidth(true) - $left.width(), - minWidth = Math.max($this.width() / 3, 240), - maxWidth; - - $right.each(function() { - var $this = $(this); - if ($this.is(':visible')) { - width += $this.outerWidth(true); - } - }); - - maxWidth = $this.width() - width - diff; - $left.css('max-width', Math.floor(Math.max(maxWidth, minWidth)) + 'px'); - } - - resize(); - $(window).resize(resize); - }); - - /** - * Makes breadcrumbs responsive - */ - $container.find('.breadcrumbs:not([data-skip-responsive])').each(function() { - var $this = $(this), - $links = $this.find('.crumb'), - length = $links.length, - classes = ['wrapped-max', 'wrapped-wide', 'wrapped-medium', 'wrapped-small', 'wrapped-tiny'], - classesLength = classes.length, - maxHeight = 0, - lastWidth = false, - wrapped = false; - - // Set tooltips - $this.find('a').each(function() { - var $link = $(this); - $link.attr('title', $link.text()); - }); - - // Function that checks breadcrumbs - function check() { - var height = $this.height(), - width; - - // Test max-width set in code for .navlinks above - width = parseInt($this.css('max-width'), 10); - if (!width) { - width = $body.width(); - } - - maxHeight = parseInt($this.css('line-height'), 10); - $links.each(function() { - if ($(this).height() > 0) { - maxHeight = Math.max(maxHeight, $(this).outerHeight(true)); - } - }); - - if (height <= maxHeight) { - if (!wrapped || lastWidth === false || lastWidth >= width) { - return; - } - } - lastWidth = width; - - if (wrapped) { - $this.removeClass('wrapped').find('.crumb.wrapped').removeClass('wrapped ' + classes.join(' ')); - if ($this.height() <= maxHeight) { - return; - } - } - - wrapped = true; - $this.addClass('wrapped'); - if ($this.height() <= maxHeight) { - return; - } - - for (var i = 0; i < classesLength; i++) { - for (var j = length - 1; j >= 0; j--) { - $links.eq(j).addClass('wrapped ' + classes[i]); - if ($this.height() <= maxHeight) { - return; - } - } - } - } - - // Run function and set event - check(); - $(window).resize(check); - }); - - /** - * Responsive link lists - */ - var selector = '.linklist:not(.navlinks, [data-skip-responsive]),' + - '.postbody .post-buttons:not([data-skip-responsive])'; - $container.find(selector).each(function() { - var $this = $(this), - filterSkip = '.breadcrumbs, [data-skip-responsive]', - filterLast = '.edit-icon, .quote-icon, [data-last-responsive]', - $linksAll = $this.children(), - $linksNotSkip = $linksAll.not(filterSkip), // All items that can potentially be hidden - $linksFirst = $linksNotSkip.not(filterLast), // The items that will be hidden first - $linksLast = $linksNotSkip.filter(filterLast), // The items that will be hidden last - persistent = $this.attr('id') === 'nav-main', // Does this list already have a menu (such as quick-links)? - html = '', - slack = 3; // Vertical slack space (in pixels). Determines how sensitive the script is in determining whether a line-break has occured. - - // Add a hidden drop-down menu to each links list (except those that already have one) - if (!persistent) { - if ($linksNotSkip.is('.rightside')) { - $linksNotSkip.filter('.rightside:first').before(html); - $this.children('.responsive-menu').addClass('rightside'); - } else { - $this.append(html); - } - } - - // Set some object references and initial states - var $menu = $this.children('.responsive-menu'), - $menuContents = $menu.find('.dropdown-contents'), - persistentContent = $menuContents.find('li:not(.separator)').length, - lastWidth = false, - compact = false, - responsive1 = false, - responsive2 = false, - copied1 = false, - copied2 = false, - maxHeight = 0; - - // Find the tallest element in the list (we assume that all elements are roughly the same height) - $linksAll.each(function() { - if (!$(this).height()) { - return; - } - maxHeight = Math.max(maxHeight, $(this).outerHeight(true)); - }); - if (maxHeight < 1) { - return; // Shouldn't be possible, but just in case, abort - } else { - maxHeight = maxHeight + slack; - } - - function check() { - var width = $body.width(); - // We can't make it any smaller than this, so just skip - if (responsive2 && compact && (width <= lastWidth)) { - return; - } - lastWidth = width; - - // Reset responsive and compact layout - if (responsive1 || responsive2) { - $linksNotSkip.removeClass('hidden'); - $menuContents.children('.clone').addClass('hidden'); - responsive1 = responsive2 = false; - } - if (compact) { - $this.removeClass('compact'); - compact = false; - } - - // Unhide the quick-links menu if it has "persistent" content - if (persistent && persistentContent) { - $menu.removeClass('hidden'); - } else { - $menu.addClass('hidden'); - } - - // Nothing to resize if block's height is not bigger than tallest element's height - if ($this.height() <= maxHeight) { - return; - } - - // STEP 1: Compact - if (!compact) { - $this.addClass('compact'); - compact = true; - } - if ($this.height() <= maxHeight) { - return; - } - - // STEP 2: First responsive set - compact - if (compact) { - $this.removeClass('compact'); - compact = false; - } - // Copy the list items to the dropdown - if (!copied1) { - var $clones1 = $linksFirst.clone(); - $menuContents.prepend($clones1.addClass('clone clone-first').removeClass('leftside rightside')); - - if ($this.hasClass('post-buttons')) { - $('.button', $menuContents).removeClass('button'); - $('.sr-only', $menuContents).removeClass('sr-only'); - $('.js-responsive-menu-link').addClass('button').addClass('button-icon-only'); - $('.js-responsive-menu-link .icon').removeClass('fa-bars').addClass('fa-ellipsis-h'); - } - copied1 = true; - } - if (!responsive1) { - $linksFirst.addClass('hidden'); - responsive1 = true; - $menuContents.children('.clone-first').removeClass('hidden'); - $menu.removeClass('hidden'); - } - if ($this.height() <= maxHeight) { - return; - } - - // STEP 3: First responsive set + compact - if (!compact) { - $this.addClass('compact'); - compact = true; - } - if ($this.height() <= maxHeight) { - return; - } - - // STEP 4: Last responsive set - compact - if (!$linksLast.length) { - return; // No other links to hide, can't do more - } - if (compact) { - $this.removeClass('compact'); - compact = false; - } - // Copy the list items to the dropdown - if (!copied2) { - var $clones2 = $linksLast.clone(); - $menuContents.prepend($clones2.addClass('clone clone-last').removeClass('leftside rightside')); - copied2 = true; - } - if (!responsive2) { - $linksLast.addClass('hidden'); - responsive2 = true; - $menuContents.children('.clone-last').removeClass('hidden'); - } - if ($this.height() <= maxHeight) { - return; - } - - // STEP 5: Last responsive set + compact - if (!compact) { - $this.addClass('compact'); - compact = true; - } - } - - if (!persistent) { - phpbb.registerDropdown($menu.find('a.js-responsive-menu-link'), $menu.find('.dropdown'), false); - } - - // If there are any images in the links list, run the check again after they have loaded - $linksAll.find('img').each(function() { - $(this).on('load', function() { - check(); - }); - }); - - check(); - $(window).resize(check); - }); - - /** - * Do not run functions below for old browsers - */ - if (oldBrowser) { - return; - } - - /** - * Adjust topiclist lists with check boxes - */ - $container.find('ul.topiclist dd.mark').siblings('dt').children('.list-inner').addClass('with-mark'); - - /** - * Appends contents of all extra columns to first column in - * .topiclist lists for mobile devices. Copies contents as is. - * - * To add that functionality to .topiclist list simply add - * responsive-show-all to list of classes - */ - $container.find('.topiclist.responsive-show-all > li > dl').each(function() { - var $this = $(this), - $block = $this.find('dt .responsive-show:last-child'), - first = true; - - // Create block that is visible only on mobile devices - if (!$block.length) { - $this.find('dt > .list-inner').append('
- -
-
- - - - -
-
- -
    - - - - - -
  • - -
    -
    - -
    - - - - - - {forumrow.FORUM_IMAGE} - - - {forumrow.FORUM_NAME} -
    {forumrow.FORUM_DESC} - -
    {forumrow.L_MODERATOR_STR}{L_COLON} {forumrow.MODERATORS} - - - -
    {forumrow.L_SUBFORUM_STR}{L_COLON} - - - {forumrow.subforum.SUBFORUM_NAME}{L_COMMA_SEPARATOR} - - - - - - - -
    -
    - -
    {L_REDIRECTS}{L_COLON} {forumrow.CLICKS}
    - -
    {forumrow.TOPICS} {L_TOPICS}
    -
    {forumrow.POSTS} {L_POSTS}
    -
    - - - - {L_TOPICS_UNAPPROVED} - - - - {L_POSTS_UNAPPROVED_FORUM} - - - - {L_LAST_POST} - - - {forumrow.LAST_POST_SUBJECT_TRUNCATED}
    - - {L_POST_BY_AUTHOR} {forumrow.LAST_POSTER_FULL} - - - {L_VIEW_LATEST_POST} - - -
    {forumrow.LAST_POST_TIME} - - {% if forumrow.U_UNAPPROVED_TOPICS %} - {{ lang('TOPIC_UNAPPROVED_FORUM', forumrow.TOPICS) }} - {% else %} - {{ lang('NO_POSTS') }} - {% endif %} - -
    -
    - -
     
    - -
    - -
  • - - - - -
- -
-
- - - - -
-
- {L_NO_FORUMS} -
-
- diff --git a/install/update/old/styles/prosilver/template/mcp_forum.html b/install/update/old/styles/prosilver/template/mcp_forum.html deleted file mode 100644 index f6c518e..0000000 --- a/install/update/old/styles/prosilver/template/mcp_forum.html +++ /dev/null @@ -1,153 +0,0 @@ - - - - - -

{L_FORUM}{L_COLON} {FORUM_NAME}

- -
- -
-
- -
- -
- - -
    -
  • -
    -
    {L_TOPICS}
    -
    {L_REPLIES}
    -
    {L_LAST_POST}
    -
    {L_MARK}
    -
    -
  • -
- - -
    -
  • {L_NO_TOPICS}

  • -
- - -
- - - -
- -
-
- - -
- - - - - - {S_FORM_TOKEN} -
- -
- - diff --git a/install/update/old/styles/prosilver/template/mcp_move.html b/install/update/old/styles/prosilver/template/mcp_move.html deleted file mode 100644 index 45a9ae8..0000000 --- a/install/update/old/styles/prosilver/template/mcp_move.html +++ /dev/null @@ -1,71 +0,0 @@ - - -

{MESSAGE_TITLE}

-

{MESSAGE_TEXT}

- -

{ADDITIONAL_MSG}

- - - - - - - - - - - -
-   - -
- - - - - - - -
- -
-
- -
-

{MESSAGE_TITLE}

-

{ADDITIONAL_MSG}

- -
-
-
-
-
-
-
-
-
 
-
{MESSAGE_TEXT}
-
-
- -
- {S_HIDDEN_FIELDS}  - - {S_FORM_TOKEN} -
- -
- -
-
-
- - - diff --git a/install/update/old/styles/prosilver/template/mcp_topic.html b/install/update/old/styles/prosilver/template/mcp_topic.html deleted file mode 100644 index b56ed18..0000000 --- a/install/update/old/styles/prosilver/template/mcp_topic.html +++ /dev/null @@ -1,202 +0,0 @@ - - - - -
- -
-
- -
-
-

{L_POSTS_PER_PAGE_EXPLAIN}
-
-
-
-
-
{S_SELECT_SORT_DAYS}  
-
-
- - -
-

{L_SPLIT_TOPIC_EXPLAIN}

- - -
-
-
-
-
- - - -
-
-
-
- -
-
-
-
-
- - - -
-

{L_MERGE_TOPIC_EXPLAIN}

-
-
-
- - {L_SELECT_TOPIC} -
-
{TO_TOPIC_INFO}
-
-
- - -
-
- -
-
- -

- {L_EXPAND_VIEW} - {L_TOPIC_REVIEW}{L_COLON} {TOPIC_TITLE} -

- -
- - -
-
- -
- - - -

{postrow.POST_SUBJECT}

- - - -

- - {postrow.MINI_POST} - {L_POSTED} {postrow.POST_DATE} {L_POST_BY_AUTHOR} {postrow.POST_AUTHOR_FULL} [ {L_POST_DETAILS} ] -

- - - -

- {L_POST_UNAPPROVED} -

- - - -

- {L_POST_DELETED} -

- - - -

- {L_POST_REPORTED} -

- - -
{postrow.MESSAGE}
- - - - -
-
{L_ATTACHMENTS}
- -
{postrow.attachment.DISPLAY_ATTACHMENT}
- -
- - - - -
- -
-
- -
- -
- -
- -
- -
-
- -
-   - - -{S_HIDDEN_FIELDS} -{S_FORM_TOKEN} -
- -
- - diff --git a/install/update/old/styles/prosilver/template/memberlist_body.html b/install/update/old/styles/prosilver/template/memberlist_body.html deleted file mode 100644 index 5f03ad9..0000000 --- a/install/update/old/styles/prosilver/template/memberlist_body.html +++ /dev/null @@ -1,179 +0,0 @@ - - - -
- - - - - - - - -{% EVENT memberlist_body_page_header_after %} - - - {% EVENT memberlist_body_group_name_before %} -

style="color:#{GROUP_COLOR};">{GROUP_NAME}

- {% EVENT memberlist_body_group_name_after %} - -

{L_MANAGE_GROUP}

- -

{GROUP_DESC} {GROUP_TYPE}

- - {% EVENT memberlist_body_group_desc_after %} - -

- {AVATAR_IMG} - {% EVENT memberlist_body_group_rank_before %} - {RANK_IMG} - {GROUP_RANK} - {% EVENT memberlist_body_group_rank_after %} -

- - {% EVENT memberlist_body_page_title_before %} -

{PAGE_TITLE}{L_COLON} {SEARCH_WORDS}

- -
- - - -
- - - -
-
- - - - - - - - - - {% EVENT memberlist_body_memberlist_after %} - - - - - - - - - - - - - - -
{L_RANK}{L_GROUP_LEADER}{L_USERNAME}{L_POSTS}{L_COMMA_SEPARATOR} {custom_fields.PROFILE_FIELD_NAME}{L_JOINED}{L_LAST_ACTIVE}
 
- -
-
- -
-
- - - - - - - - - - - {% EVENT memberlist_body_leaders_set_after %} - - - - - - - {% EVENT memberlist_body_show_group_after %} - - - - - - - - - - - - - - - {% EVENT memberlist_body_memberrow_after %} - - - - - - - -
{L_RANK}{L_GROUP_MEMBERS}{L_USERNAME}{L_POSTS}{% for field in custom_fields %}{% if not loop.first %}{L_COMMA_SEPARATOR} {% endif %}{{ field.PROFILE_FIELD_NAME }}{% endfor %}{L_JOINED}{L_LAST_ACTIVE}{L_GROUP_MEMBERS}{L_POSTS}{L_COMMA_SEPARATOR} {custom_fields.PROFILE_FIELD_NAME}{L_JOINED}{L_LAST_ACTIVE}
{memberrow.RANK_IMG}{memberrow.RANK_TITLE} {memberrow.USERNAME_FULL} ({L_INACTIVE})
{L_SELECT} ]
{memberrow.POSTS}{memberrow.POSTS}
{memberrow.custom_fields.PROFILE_FIELD_VALUE}
 
{memberrow.JOINED}{memberrow.LAST_ACTIVE} 
{L_NO_MEMBERS}
- -
-
- - -
- - -
- - - -
-
- - - -
- - - -
- - -
- -
- -
- -{% EVENT memberlist_body_page_footer_before %} - - - - - - - diff --git a/install/update/old/styles/prosilver/template/memberlist_search.html b/install/update/old/styles/prosilver/template/memberlist_search.html deleted file mode 100644 index b1c7a81..0000000 --- a/install/update/old/styles/prosilver/template/memberlist_search.html +++ /dev/null @@ -1,87 +0,0 @@ -

{L_FIND_USERNAME}

- -
-
-
- -

{L_FIND_USERNAME_EXPLAIN}

- - -
-
-
-
- - -
-
- -
-
-
-
- - -
-
-
-
- -
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
- -
-
-
-
- -
-
-
-
- - -
- -
- -
- -
-   - - {S_FORM_TOKEN} -
- -
-
- -
diff --git a/install/update/old/styles/prosilver/template/navbar_header.html b/install/update/old/styles/prosilver/template/navbar_header.html deleted file mode 100644 index dc29285..0000000 --- a/install/update/old/styles/prosilver/template/navbar_header.html +++ /dev/null @@ -1,210 +0,0 @@ - diff --git a/install/update/old/styles/prosilver/template/overall_footer.html b/install/update/old/styles/prosilver/template/overall_footer.html deleted file mode 100644 index bdff1a0..0000000 --- a/install/update/old/styles/prosilver/template/overall_footer.html +++ /dev/null @@ -1,120 +0,0 @@ - -
- - - - - -
- -
- - {RUN_CRON_TASK} -
- - - - - - - - - - - - - - - - - - -{$SCRIPTS} - - - - - diff --git a/install/update/old/styles/prosilver/template/overall_header.html b/install/update/old/styles/prosilver/template/overall_header.html deleted file mode 100644 index 09824d0..0000000 --- a/install/update/old/styles/prosilver/template/overall_header.html +++ /dev/null @@ -1,131 +0,0 @@ - - - - - - -{META} -<!-- IF UNREAD_NOTIFICATIONS_COUNT -->({UNREAD_NOTIFICATIONS_COUNT}) <!-- ENDIF --><!-- IF not S_VIEWTOPIC and not S_VIEWFORUM -->{SITENAME} - <!-- ENDIF --><!-- IF S_IN_MCP -->{L_MCP} - <!-- ELSEIF S_IN_UCP -->{L_UCP} - <!-- ENDIF -->{PAGE_TITLE}<!-- IF S_VIEWTOPIC or S_VIEWFORUM --> - {SITENAME}<!-- ENDIF --> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -{$STYLESHEETS} - - - - - - - - -
- - - - - - -
- -
-
- {L_INFORMATION}{L_COLON} {L_BOARD_DISABLED} -
-
- - - diff --git a/install/update/old/styles/prosilver/template/plupload.html b/install/update/old/styles/prosilver/template/plupload.html deleted file mode 100644 index 1eb8437..0000000 --- a/install/update/old/styles/prosilver/template/plupload.html +++ /dev/null @@ -1,67 +0,0 @@ - - - diff --git a/install/update/old/styles/prosilver/template/posting_attach_body.html b/install/update/old/styles/prosilver/template/posting_attach_body.html deleted file mode 100644 index b46e9c9..0000000 --- a/install/update/old/styles/prosilver/template/posting_attach_body.html +++ /dev/null @@ -1,93 +0,0 @@ -
-
- -

{L_ADD_ATTACHMENT_EXPLAIN}

- -
-
-
-
- - -
-
-
-
-
-
-
- -
- -
- - {% EVENT posting_attach_body_file_list_before %} -
-
- - - - - - - - - - - - - - - - - {% EVENT posting_attach_body_attach_row_before %} - - {% EVENT posting_attach_body_attach_row_prepend %} - - - - - - - {% EVENT posting_attach_body_attach_row_append %} - - {% EVENT posting_attach_body_attach_row_after %} - -
{L_PLUPLOAD_FILENAME}{L_FILE_COMMENT}{L_PLUPLOAD_SIZE}{L_PLUPLOAD_STATUS}
- - -   - - - - - - - - - - - - -
- {attach_row.FILENAME} - {% EVENT posting_attach_body_attach_row_controls_prepend %} - -   - - - {% EVENT posting_attach_body_attach_row_controls_append %} - - - - {attach_row.S_HIDDEN} - - {attach_row.FILESIZE} - - -
-
-
- {% EVENT posting_attach_body_file_list_after %} -
-
diff --git a/install/update/old/styles/prosilver/template/posting_buttons.html b/install/update/old/styles/prosilver/template/posting_buttons.html deleted file mode 100644 index 122afdf..0000000 --- a/install/update/old/styles/prosilver/template/posting_buttons.html +++ /dev/null @@ -1,126 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - diff --git a/install/update/old/styles/prosilver/template/posting_layout.html b/install/update/old/styles/prosilver/template/posting_layout.html deleted file mode 100644 index bca9195..0000000 --- a/install/update/old/styles/prosilver/template/posting_layout.html +++ /dev/null @@ -1,86 +0,0 @@ - - - -

{TOPIC_TITLE}

- -

{FORUM_NAME}

- - - -
-
- - - {L_FORUM_RULES} - - {L_FORUM_RULES}
- {FORUM_RULES} - - -
-
- - -
- - -
-
- -

{L_INFORMATION}

-

{L_DRAFT_LOADED}

- -
-
- - - - - - - -
-
-
-

{L_SELECT_DESTINATION_FORUM}

-

{L_UNGLOBALISE_EXPLAIN}

-
-
-
-
- -
-
 
-
-
-
- -
-
- - - - -
-
- -

{L_POST_A}

- - - - - {S_FORM_TOKEN} -
-
- - - - - - - - - -
- - diff --git a/install/update/old/styles/prosilver/template/posting_poll_body.html b/install/update/old/styles/prosilver/template/posting_poll_body.html deleted file mode 100644 index ee7100a..0000000 --- a/install/update/old/styles/prosilver/template/posting_poll_body.html +++ /dev/null @@ -1,53 +0,0 @@ -
-
- - -

{L_ADD_POLL_EXPLAIN}

- - -
- -
-
-
-
- - - -
-
-
-
-
-

{L_POLL_OPTIONS_EXPLAIN}
-
-
- -
- -
-
-
-
{L_POLL_MAX_OPTIONS_EXPLAIN}
-
-
-
-
-
{L_POLL_FOR_EXPLAIN}
-
- - -
- -
-
-
-
- - - - -
- -
-
diff --git a/install/update/old/styles/prosilver/template/posting_review.html b/install/update/old/styles/prosilver/template/posting_review.html deleted file mode 100644 index 1304046..0000000 --- a/install/update/old/styles/prosilver/template/posting_review.html +++ /dev/null @@ -1,44 +0,0 @@ -

{L_POST_REVIEW}

- -

{L_POST_REVIEW_EXPLAIN}

- - - -
-
- {post_review_row.L_IGNORE_POST} - -
-
- - -
-

{post_review_row.POST_SUBJECT}

-

- - {post_review_row.MINI_POST} - - - {post_review_row.MINI_POST} - - - {L_POST_BY_AUTHOR} {post_review_row.POST_AUTHOR_FULL} » {post_review_row.POST_DATE} -

-
{post_review_row.MESSAGE}
- - -
-
{L_ATTACHMENTS}
- -
{post_review_row.attachment.DISPLAY_ATTACHMENT}
- -
- - -
- -
-
- - -
diff --git a/install/update/old/styles/prosilver/template/posting_topic_review.html b/install/update/old/styles/prosilver/template/posting_topic_review.html deleted file mode 100644 index 93c4484..0000000 --- a/install/update/old/styles/prosilver/template/posting_topic_review.html +++ /dev/null @@ -1,89 +0,0 @@ - -

- {L_EXPAND_VIEW} - {L_TOPIC_REVIEW}{L_COLON} {TOPIC_TITLE} -

- -
- - - - -
-
- {topic_review_row.L_IGNORE_POST} - -
-
- {topic_review_row.L_DELETE_POST} - -
-
- - -
-

{topic_review_row.POST_SUBJECT}

- - - - - - -

- - {topic_review_row.MINI_POST} - - - {topic_review_row.MINI_POST} - - - {L_POST_BY_AUTHOR} {topic_review_row.POST_AUTHOR_FULL} » {topic_review_row.POST_DATE} -

- - -
{topic_review_row.MESSAGE}
- - - - -
-
{L_ATTACHMENTS}
- -
{topic_review_row.attachment.DISPLAY_ATTACHMENT}
- -
- - - - - -
-
-
- -
- -
- -

- - {L_BACK_TO_TOP} - -

diff --git a/install/update/old/styles/prosilver/template/search_results.html b/install/update/old/styles/prosilver/template/search_results.html deleted file mode 100644 index d4dc6aa..0000000 --- a/install/update/old/styles/prosilver/template/search_results.html +++ /dev/null @@ -1,242 +0,0 @@ - - - - -

{SEARCH_TITLE}{SEARCH_MATCHES}{L_COLON} {SEARCH_WORDS}

-

{L_SEARCHED_QUERY}{L_COLON} {SEARCHED_QUERY}

-

{L_IGNORED_TERMS}{L_COLON} {IGNORED_WORDS}

-

{L_PHRASE_SEARCH_DISABLED}

- - - - - - - - - - -
- - - - - - - - -
- - - - - -
- -
-
    -
  • -
    -
    {L_TOPICS}
    -
    {L_REPLIES}
    -
    {L_VIEWS}
    -
    {L_LAST_POST}
    -
    -
  • -
- - -
-
- -
-
- {L_NO_SEARCH_RESULTS} -
-
- - - - - - -
-
- - -
- {searchresults.L_IGNORE_POST} -
- -
- -
{L_POST_BY_AUTHOR} {searchresults.POST_AUTHOR_FULL}
-
{searchresults.POST_DATE}
-
{L_FORUM}{L_COLON} {searchresults.FORUM_TITLE}
-
{L_TOPIC}{L_COLON} {searchresults.TOPIC_TITLE}
- -
{L_REPLIES}{L_COLON} {searchresults.TOPIC_REPLIES}
-
{L_VIEWS}{L_COLON} {searchresults.TOPIC_VIEWS}
- -
- -
-

{searchresults.POST_SUBJECT}

-
{searchresults.MESSAGE}
- -
- - - - - - -
-
- - -
-
- {L_NO_SEARCH_RESULTS} -
-
- - - -
- -
- -
- - - -
- - - - diff --git a/install/update/old/styles/prosilver/template/simple_footer.html b/install/update/old/styles/prosilver/template/simple_footer.html deleted file mode 100644 index 1ef44d1..0000000 --- a/install/update/old/styles/prosilver/template/simple_footer.html +++ /dev/null @@ -1,40 +0,0 @@ -
- - - -
-
 
-
-
- -
- - - -

-
-
- - - -
-
-
- - - - - - - - - -{$SCRIPTS} - -{% EVENT simple_footer_body_after %} - - - diff --git a/install/update/old/styles/prosilver/template/ucp_agreement.html b/install/update/old/styles/prosilver/template/ucp_agreement.html deleted file mode 100644 index ace6525..0000000 --- a/install/update/old/styles/prosilver/template/ucp_agreement.html +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - -
-

- - {S_HIDDEN_FIELDS} -

-
- -
- - - -
- -
-
-
-

{SITENAME} - {L_REGISTRATION}

- -

{L_COPPA_BIRTHDAY}{L_TERMS_OF_USE}

- -
-
-
- -
-
-
- - {L_COPPA_NO}  {L_COPPA_YES} - -   - - - {S_HIDDEN_FIELDS} - {S_FORM_TOKEN} -
-
-
-
- - - -
-
-
-

{SITENAME} - {AGREEMENT_TITLE}

-

{AGREEMENT_TEXT}

-
-

{L_BACK}

-
-
-
- - - - diff --git a/install/update/old/styles/prosilver/template/ucp_attachments.html b/install/update/old/styles/prosilver/template/ucp_attachments.html deleted file mode 100644 index 696f621..0000000 --- a/install/update/old/styles/prosilver/template/ucp_attachments.html +++ /dev/null @@ -1,83 +0,0 @@ - - -
- -

{L_TITLE}

- -
-
- -

{L_ATTACHMENTS_EXPLAIN}

- - -
- -
- - - - -
- - {S_FORM_TOKEN} - - -
- - -

{L_UCP_NO_ATTACHMENTS}

- - -
-
- - -
- - - {S_FORM_TOKEN} -
- -
- - diff --git a/install/update/old/styles/prosilver/template/ucp_avatar_options_upload.html b/install/update/old/styles/prosilver/template/ucp_avatar_options_upload.html deleted file mode 100644 index 63a734e..0000000 --- a/install/update/old/styles/prosilver/template/ucp_avatar_options_upload.html +++ /dev/null @@ -1,11 +0,0 @@ -
-
-
-
- - -
-

{L_UPLOAD_AVATAR_URL_EXPLAIN}
-
-
- diff --git a/install/update/old/styles/prosilver/template/ucp_groups_manage.html b/install/update/old/styles/prosilver/template/ucp_groups_manage.html deleted file mode 100644 index f2b4f00..0000000 --- a/install/update/old/styles/prosilver/template/ucp_groups_manage.html +++ /dev/null @@ -1,247 +0,0 @@ - - - style="color:#{GROUP_COLOR};">{L_USERGROUPS} :: {GROUP_NAME} - -
- -
-
- - -
-

{ERROR_MSG}

-
- - -

{L_GROUPS_EXPLAIN}

- - -

{L_GROUP_DETAILS}

- -
-
-
-
style="color: #{GROUP_COLOUR};">{GROUP_NAME} -
-
-
-
-
-
  
-
- -
-

{L_GROUP_TYPE_EXPLAIN}
-
- - - - -
-
- - - -
- -
-
- -
-
-

{L_GROUP_SETTINGS_SAVE}

- -
-
-

{L_GROUP_COLOR_EXPLAIN}
-
- -     - [ {L_COLOUR_SWATCH} ] - -
-
-
-
-
-
-
- -
-
- - - -
- {S_HIDDEN_FIELDS} -   - - {S_FORM_TOKEN} -
- - - - - - - - - - - - - - - - - - - - - - - - - -
{L_GROUP_LEAD}{L_GROUP_DEFAULT}{L_POSTS}{L_JOINED}{L_MARK}
{leader.USERNAME_FULL}{L_YES}{L_NO}{leader.USER_POSTS}{leader.JOINED} 
- - - - - - - - - - - - - - - - - - -
{L_GROUP_PENDING}{L_GROUP_DEFAULT}{L_POSTS}{L_JOINED}{L_MARK}
- - - - - - - - - - - - - - - - - - - - - - -
{L_GROUP_APPROVED}{L_GROUP_DEFAULT}{L_POSTS}{L_JOINED}{L_MARK}
{member.USERNAME_FULL}{L_YES}{L_NO}{member.USER_POSTS}{member.JOINED}
- - - - - - - - - - - -
{L_MEMBERS}
{L_GROUPS_NO_MEMBERS}
- - -
- -
- - -
-
- -
- - - -
- -
-
- -

{L_ADD_USERS}

- -

{L_ADD_USERS_UCP_EXPLAIN}

- -
-
-

{L_USER_GROUP_DEFAULT_EXPLAIN}
-
- - -
-
-
-

{L_USERNAMES_EXPLAIN}
-
-
{L_FIND_USERNAME}
-
-
- -
-
- -
- - {S_FORM_TOKEN} -
- - - - -
    -
  • -
    -
    {L_GROUP_LEADER}
    -
    {L_OPTIONS}
    -
    -
  • -
- - -

{L_NO_LEADERS}

- - -
-
- - - - - diff --git a/install/update/old/styles/prosilver/template/ucp_pm_history.html b/install/update/old/styles/prosilver/template/ucp_pm_history.html deleted file mode 100644 index 6362a0b..0000000 --- a/install/update/old/styles/prosilver/template/ucp_pm_history.html +++ /dev/null @@ -1,57 +0,0 @@ - -

- {L_EXPAND_VIEW} - {L_MESSAGE_HISTORY}{L_COLON} -

- - -
- - -
-
- -
-

class="current">{history_row.SUBJECT}

- - - - - - - - -

- {history_row.MINI_POST} {L_SENT_AT}{L_COLON} {history_row.SENT_DATE} -
- {L_MESSAGE_BY_AUTHOR} {history_row.MESSAGE_AUTHOR_FULL} -

-
{history_row.MESSAGE}{L_MESSAGE_REMOVED_FROM_OUTBOX}
- -
- -
-
- -
- - -
-

- - {L_BACK_TO_TOP} - -

- diff --git a/install/update/old/styles/prosilver/template/ucp_pm_viewmessage_print.html b/install/update/old/styles/prosilver/template/ucp_pm_viewmessage_print.html deleted file mode 100644 index 7a88492..0000000 --- a/install/update/old/styles/prosilver/template/ucp_pm_viewmessage_print.html +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - -{META} -{SITENAME} • {PAGE_TITLE} - - - - - - -
- - - - -
-
{PAGE_NUMBER}
-
-

{SUBJECT}

-
{L_SENT_AT} {SENT_DATE}
-
{L_PM_FROM} {MESSAGE_AUTHOR}
- -
{L_TO} {to_recipient.NAME} 
- - -
{L_BCC} {bcc_recipient.NAME} 
- -
-
{MESSAGE}
-
-
-
- - -
- - - diff --git a/install/update/old/styles/prosilver/template/ucp_profile_profile_info.html b/install/update/old/styles/prosilver/template/ucp_profile_profile_info.html deleted file mode 100644 index 69eda8c..0000000 --- a/install/update/old/styles/prosilver/template/ucp_profile_profile_info.html +++ /dev/null @@ -1,51 +0,0 @@ - - -
- -

{L_TITLE} [ {L_VIEW_PROFILE} ]

- -
-
-

{L_PROFILE_INFO_NOTICE}

- -
-

{ERROR}

- - -
-

{L_BIRTHDAY_EXPLAIN}
-
- - - -
-
- - -
-
-
-
- - -
-
for="{profile_fields.FIELD_ID}">{profile_fields.LANG_NAME}{L_COLON} * -
{profile_fields.LANG_EXPLAIN}
-
{profile_fields.ERROR}
-
{profile_fields.FIELD}
-
- - -
- -
-
- -
- {S_HIDDEN_FIELDS}  - - {S_FORM_TOKEN} -
-
- - diff --git a/install/update/old/styles/prosilver/template/ucp_register.html b/install/update/old/styles/prosilver/template/ucp_register.html deleted file mode 100644 index bf39990..0000000 --- a/install/update/old/styles/prosilver/template/ucp_register.html +++ /dev/null @@ -1,106 +0,0 @@ - - - - -
- -
-
- -

{SITENAME} - {L_REGISTRATION}

- -
-
{ERROR}
- -
{L_REG_COND}
- - -
-

{L_USERNAME_EXPLAIN}
-
-
-
-
-
-
-
-

{L_PASSWORD_EXPLAIN}
-
-
-
-
-
-
- - -
- - -
-
-
-
- - - - - -
{L_ITEMS_REQUIRED}
- - -
-
for="{profile_fields.FIELD_ID}">{profile_fields.LANG_NAME}{L_COLON} * -
{profile_fields.LANG_EXPLAIN} -
{profile_fields.ERROR}
-
{profile_fields.FIELD}
-
- - - - -
-
-
- - - - - - -
-
- -

{L_COPPA_COMPLIANCE}

- -

{L_COPPA_EXPLAIN}

-
-
- - - - -
-
- -
- {S_HIDDEN_FIELDS} -   - - {S_FORM_TOKEN} -
- -
-
-
- - diff --git a/install/update/old/styles/prosilver/template/viewforum_body.html b/install/update/old/styles/prosilver/template/viewforum_body.html deleted file mode 100644 index d7099f3..0000000 --- a/install/update/old/styles/prosilver/template/viewforum_body.html +++ /dev/null @@ -1,313 +0,0 @@ - - -

{FORUM_NAME}

- - -
- -
{FORUM_DESC}
-

{L_MODERATOR}{L_MODERATORS}{L_COLON} {MODERATORS}

-
- - - -
-
- - - {L_FORUM_RULES} - - {L_FORUM_RULES}
- {FORUM_RULES} - - -
-
- - - - - - - - - - -
- - - - - - - {L_BUTTON_FORUM_LOCKED} - - {L_BUTTON_NEW_TOPIC} - - - - - - - - - - - -
- - - - -
-
- {L_NO_READ_ACCESS} -
-
- - - -
- -
-
- -
-

{L_LOGIN_LOGOUT}  •  {L_REGISTER}

- -
-
-
-
-
-
-
-
-
-
-
-
-
 
-
-
- {S_LOGIN_REDIRECT} - {S_FORM_TOKEN_LOGIN} -
-
- -
-
- -
- - - - - - - - - - - -
-
- - - -
-
-
    -
  • -
    - id="active_topics">
    {L_ACTIVE_TOPICS}{L_ANNOUNCEMENTS}{L_TOPICS}
    -
    {L_REPLIES}
    -
    {L_VIEWS}
    -
    {L_LAST_POST}
    -
    -
  • -
- -
-
- - - - -
-
- {L_NO_TOPICS} -
-
- -
-
- {L_NO_FORUMS_IN_CATEGORY} -
-
- - - - -
- - - - - - {L_BUTTON_FORUM_LOCKED} - - {L_BUTTON_NEW_TOPIC} - - - - - - - -
- -
- - - -
- - - - - -
-

{L_WHO_IS_ONLINE}

-

{LOGGED_IN_USER_LIST}

-
- - - -
-

{L_FORUM_PERMISSIONS}

-

{rules.RULE}

-
- - - diff --git a/install/update/old/styles/prosilver/template/viewtopic_body.html b/install/update/old/styles/prosilver/template/viewtopic_body.html deleted file mode 100644 index 8d7e26f..0000000 --- a/install/update/old/styles/prosilver/template/viewtopic_body.html +++ /dev/null @@ -1,452 +0,0 @@ - - - -

{TOPIC_TITLE}

- - -
{FORUM_DESC}
- - -

- {L_MODERATOR}{L_MODERATORS}{L_COLON} {MODERATORS} -

- - - -
-
- - - {L_FORUM_RULES} - - {L_FORUM_RULES}
- {FORUM_RULES} - - -
-
- - -
- - - - - - {L_BUTTON_TOPIC_LOCKED} - - {L_BUTTON_POST_REPLY} - - - - - - - - - - - - - - - - -
- - - - -
- -
-
- -
-

{POLL_QUESTION}

-

{L_POLL_LENGTH}
{L_MAX_VOTES}

- -
- - -
title="{L_POLL_VOTED_OPTION}" data-alt-text="{L_POLL_VOTED_OPTION}" data-poll-option-id="{poll_option.POLL_OPTION_ID}"> -
{poll_option.POLL_OPTION_CAPTION}
-
checked="checked" /> checked="checked" />
-
{poll_option.POLL_OPTION_RESULT}
-
{L_NO_VOTES}{poll_option.POLL_OPTION_PERCENT}
-
- - - -
-
 
-
{L_TOTAL_VOTES}{L_COLON} {TOTAL_VOTES}
-
- - -
-
 
-
-
- - - -
-
 
-
{L_VIEW_RESULTS}
-
- -
- -
- -
- {S_FORM_TOKEN} - {S_HIDDEN_FIELDS} -
- -
-
- - - - - - - - data-url="{postrow.U_MINI_POST}"> - -
-
- -
style="display: none;"> -
-
- - - {postrow.POSTER_AVATAR}{postrow.POSTER_AVATAR} - - -
- - {postrow.POST_AUTHOR_FULL}{postrow.POST_AUTHOR_FULL} - -
- - -
{postrow.RANK_TITLE}
{postrow.RANK_IMG}
- - -
{L_POSTS}{L_COLON} {postrow.POSTER_POSTS}
-
{L_JOINED}{L_COLON} {postrow.POSTER_JOINED}
-
{L_WARNINGS}{L_COLON} {postrow.POSTER_WARNINGS}
- - - -
{postrow.PROFILE_FIELD1_NAME}{L_COLON} {postrow.PROFILE_FIELD1_VALUE}
- - - - - -
{postrow.custom_fields.PROFILE_FIELD_NAME}{L_COLON} {postrow.custom_fields.PROFILE_FIELD_VALUE}
- - - - - - -
- {L_CONTACT}{L_COLON} - -
- - - -
- -
- - -
- {postrow.L_POST_DELETED_MESSAGE}
- {postrow.L_POST_DISPLAY} -
- -
- {postrow.L_IGNORE_POST}
- {postrow.L_POST_DISPLAY} -
- - -
style="display: none;"> - - -

class="first">{postrow.POST_ICON_IMG_ALT} {postrow.POST_SUBJECT}

- - - - - - - - - - - -

- - {postrow.MINI_POST} - - - {postrow.MINI_POST} - - - {L_POST_BY_AUTHOR} {postrow.POST_AUTHOR_FULL} » {postrow.POST_DATE} -

- - - -
-

- - {L_POST_UNAPPROVED_ACTION} - - - - {S_FORM_TOKEN} -

-
- -
-

- {L_POST_DELETED_ACTION} - - - - - - {S_FORM_TOKEN} -

-
- - - -

- {L_POST_REPORTED} -

- - -
{postrow.MESSAGE}
- - - - -
-
- {L_ATTACHMENTS} -
- -
{postrow.attachment.DISPLAY_ATTACHMENT}
- -
- - - -
{L_DOWNLOAD_NOTICE}
- -
- {postrow.DELETED_MESSAGE} -
{L_REASON}{L_COLON} {postrow.DELETE_REASON} -
- -
- {postrow.EDITED_MESSAGE} -
{L_REASON}{L_COLON} {postrow.EDIT_REASON} -
- - -


{postrow.BUMPED_MESSAGE}
- -
{postrow.SIGNATURE}
- - -
- -
- - - - - -
-
- -
- - - - - - - - -
- - - - - - {L_BUTTON_TOPIC_LOCKED} - - {L_BUTTON_POST_REPLY} - - - - - - - - -
- -
- - - - - - - - - - - -
- - - - - -
-

{L_WHO_IS_ONLINE}

-

{LOGGED_IN_USER_LIST}

-
- - - diff --git a/install/update/old/styles/prosilver/template/viewtopic_print.html b/install/update/old/styles/prosilver/template/viewtopic_print.html deleted file mode 100644 index b504949..0000000 --- a/install/update/old/styles/prosilver/template/viewtopic_print.html +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - -{META} -{SITENAME} • {PAGE_TITLE} - - - - - - -
- - - - -
-
{PAGE_NUMBER}
- -
-

{postrow.POST_SUBJECT}

-
{L_POSTED}{L_COLON} {postrow.POST_DATE}
-
{L_POST_BY_AUTHOR} {postrow.POST_AUTHOR}
-
{postrow.MESSAGE}
-
-
- -
- - -
- - - diff --git a/install/update/old/styles/prosilver/theme/colours.css b/install/update/old/styles/prosilver/theme/colours.css deleted file mode 100644 index ffaa710..0000000 --- a/install/update/old/styles/prosilver/theme/colours.css +++ /dev/null @@ -1,1163 +0,0 @@ -/* --------------------------------------------------------------- -Colours and backgrounds for common.css --------------------------------------------------------------- */ - -html, body { - color: #536482; - background-color: #F5F7FA; -} - -h1 { - color: #FFFFFF; -} - -h2 { - color: #28313F; -} - -h3 { - border-bottom-color: #CCCCCC; - color: #115098; -} - -hr { - border-color: #FFFFFF; - border-top-color: #CCCCCC; -} - -/* --------------------------------------------------------------- -Colours and backgrounds for links.css --------------------------------------------------------------- */ - -a { color: #105289; } -a:hover { color: #D31141; } - -/* Links on gradient backgrounds */ -.forumbg .header a, .forabg .header a, th a { - color: #FFFFFF; -} - -.forumbg .header a:hover, .forabg .header a:hover, th a:hover { - color: #A8D8FF; -} - -/* Notification mark read link */ -.dropdown-extended a.mark_read { - background-color: #FFFFFF; -} - -/* Post body links */ -.postlink { - border-bottom-color: #368AD2; - color: #368AD2; -} - -.postlink:visited { - border-bottom-color: #5D8FBD; - color: #5D8FBD; -} - -.postlink:hover { - background-color: #D0E4F6; - color: #0D4473; -} - -.signature a, .signature a:hover { - background-color: transparent; -} - -/* Back to top of page */ -.top i { - color: #999999; -} - -/* Arrow links */ -.arrow-left:hover, .arrow-right:hover { - color: #368AD2; -} - -/* Round cornered boxes and backgrounds ----------------------------------------- */ -.wrap { - background-color: #FFF; - border-color: #E6E9ED; -} - -.headerbar { - color: #FFFFFF; -} - -.headerbar, .forumbg { - background-color: #12A3EB; - background-image: -webkit-linear-gradient(top, #6ACEFF 0%, #0076B1 2px, #12A3EB 92px, #12A3EB 100%); - background-image: linear-gradient(to bottom, #6ACEFF 0%,#0076B1 2px,#12A3EB 92px,#12A3EB 100%); - background-repeat: repeat-x; -} - -.forabg { - background-color: #0076B1; - background-image: -webkit-linear-gradient(top, #6ACEFF 0%, #12A3EB 2px, #0076B1 92px, #0076B1 100%); - background-image: linear-gradient(to bottom, #6ACEFF 0%,#12A3EB 2px,#0076B1 92px,#0076B1 100%); - background-repeat: repeat-x; -} - -.navbar { - background-color: #CADCEB; -} - -.panel { - background-color: #ECF1F3; - color: #28313F; -} - -.post:target .content { - color: #000000; -} - -.post:target h3 a { - color: #000000; -} - -.bg1 { - background-color: #ECF3F7; -} - -table.zebra-list tr:nth-child(odd) td, ul.zebra-list li:nth-child(odd) { - background-color: #ECF3F7; -} - -.bg2 { - background-color: #E1EBF2; -} - -table.zebra-list tr:nth-child(even) td, ul.zebra-list li:nth-child(even) { - background-color: #E1EBF2; -} - -.bg3 { - background-color: #CADCEB; -} - -.ucprowbg { - background-color: #DCDEE2; -} - -.fieldsbg { - background-color: #E7E8EA; -} - -.site_logo { - background-image: url("./images/site_logo.gif"); -} - -/* Horizontal lists -----------------------------------------*/ - -ul.navlinks { - border-top-color: #FFFFFF; -} - -/* Table styles -----------------------------------------*/ -table.table1 thead th { - color: #FFFFFF; -} - -table.table1 tbody tr { - border-color: #BFC1CF; -} - -table.table1 tbody tr:hover, table.table1 tbody tr.hover { - background-color: #CFE1F6; - color: #000; -} - -table.table1 td { - color: #536482; -} - -table.table1 tbody td { - border-top-color: #FAFAFA; -} - -table.table1 tbody th { - border-bottom-color: #000000; - color: #333333; - background-color: #FFFFFF; -} - -table.info tbody th { - color: #000000; -} - -/* Misc layout styles ----------------------------------------- */ -dl.details dt { - color: #000000; -} - -dl.details dd { - color: #536482; -} - -.sep { - color: #1198D9; -} - -/* Icon styles ----------------------------------------- */ -.icon.icon-blue, a:hover .icon.icon-blue { - color: #196db5; -} - -.icon.icon-green, a:hover .icon.icon-green{ - color: #1b9A1B; -} - -.icon.icon-red, a:hover .icon.icon-red{ - color: #BC2A4D; -} - -.icon.icon-orange, a:hover .icon.icon-orange{ - color: #FF6600; -} - -.icon.icon-bluegray, a:hover .icon.icon-bluegray{ - color: #536482; -} - -.icon.icon-gray, a:hover .icon.icon-gray{ - color: #777777; -} - -.icon.icon-lightgray, a:hover .icon.icon-lightgray{ - color: #999999; -} - -.icon.icon-black, a:hover .icon.icon-black{ - color: #333333; -} - -.alert_close .icon:before { - background-color: #FFFFFF; -} - -/* Jumpbox */ -.jumpbox .dropdown li { - border-top-color: #CCCCCC; -} - -.jumpbox-cat-link { - background-color: #0076b1; - border-top-color: #0076B1; - color: #FFFFFF; -} - -.jumpbox-cat-link:hover { - background-color: #12A3EB; - border-top-color: #12A3EB; - color: #FFFFFF; -} - -.jumpbox-forum-link { - background-color: #E1EBF2; -} - -.jumpbox-forum-link:hover { - background-color: #F6F4D0; -} - -.jumpbox .dropdown .pointer-inner { - border-color: #E1EBF2 transparent; -} - -.jumpbox-sub-link { - background-color: #E1EBF2; -} - -.jumpbox-sub-link:hover { - background-color: #F1F8FF; -} - -/* Miscellaneous styles ----------------------------------------- */ - -.copyright { - color: #555555; -} - -.error { - color: #BC2A4D; -} - -.reported { - background-color: #F7ECEF; -} - -li.reported:hover { - background-color: #ECD5D8 !important; -} -.sticky, .announce { - /* you can add a background for stickies and announcements*/ -} - -div.rules { - background-color: #ECD5D8; - color: #BC2A4D; -} - -p.post-notice { - background-color: #ECD5D8; - background-image: none; -} - -/* --------------------------------------------------------------- -Colours and backgrounds for content.css --------------------------------------------------------------- */ - -ul.forums { - background-color: #EEF5F9; /* Old browsers */ /* FF3.6+ */ - background-image: -webkit-linear-gradient(top, #D2E0EB 0%, #EEF5F9 100%); - background-image: linear-gradient(to bottom, #D2E0EB 0%,#EEF5F9 100%); /* W3C */ - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#D2E0EB', endColorstr='#EEF5F9',GradientType=0 ); /* IE6-9 */ -} - -ul.topiclist li { - color: #4C5D77; -} - -ul.topiclist dd { - border-left-color: #FFFFFF; -} - -.rtl ul.topiclist dd { - border-right-color: #FFFFFF; - border-left-color: transparent; -} - -li.row { - border-top-color: #FFFFFF; - border-bottom-color: #00608F; -} - -li.row strong { - color: #000000; -} - -li.row:hover { - background-color: #F6F4D0; -} - -li.row:hover dd { - border-left-color: #CCCCCC; -} - -.rtl li.row:hover dd { - border-right-color: #CCCCCC; - border-left-color: transparent; -} - -li.header dt, li.header dd { - color: #FFFFFF; -} - -/* Post body styles -----------------------------------------*/ -.postbody { - color: #333333; -} - -/* Content container styles -----------------------------------------*/ -.content { - color: #333333; -} - -.content h2, .panel h2 { - color: #115098; - border-bottom-color: #CCCCCC; -} - -dl.faq dt { - color: #333333; -} - -.posthilit { - background-color: #F3BFCC; - color: #BC2A4D; -} - -.announce, .unreadpost { - /* Highlight the announcements & unread posts box */ -} - -/* Post signature */ -.signature { - border-top-color: #CCCCCC; -} - -/* Post noticies */ -.notice { - border-top-color: #CCCCCC; -} - -/* BB Code styles -----------------------------------------*/ -/* Quote block */ -blockquote { - background-color: #EBEADD; - border-color:#DBDBCE; -} - -blockquote blockquote { - /* Nested quotes */ - background-color:#EFEED9; -} - -blockquote blockquote blockquote { - /* Nested quotes */ - background-color: #EBEADD; -} - -/* Code block */ -.codebox { - background-color: #FFFFFF; - border-color: #C9D2D8; -} - -.codebox p { - border-bottom-color: #CCCCCC; -} - -.codebox code { - color: #2E8B57; -} - -/* Attachments -----------------------------------------*/ -.attachbox { - background-color: #FFFFFF; - border-color: #C9D2D8; -} - -.pm-message .attachbox { - background-color: #F2F3F3; -} - -.attachbox dd { - border-top-color: #C9D2D8; -} - -.attachbox p { - color: #666666; -} - -.attachbox p.stats { - color: #666666; -} - -.attach-image img { - border-color: #999999; -} - -/* Inline image thumbnails */ - -dl.file dd { - color: #666666; -} - -dl.thumbnail img { - border-color: #666666; - background-color: #FFFFFF; -} - -dl.thumbnail dd { - color: #666666; -} - -dl.thumbnail dt a:hover { - background-color: #EEEEEE; -} - -dl.thumbnail dt a:hover img { - border-color: #368AD2; -} - -/* Post poll styles -----------------------------------------*/ - -fieldset.polls dl { - border-top-color: #DCDEE2; - color: #666666; -} - -fieldset.polls dl.voted { - color: #000000; -} - -fieldset.polls dd div { - color: #FFFFFF; -} - -.rtl .pollbar1, .rtl .pollbar2, .rtl .pollbar3, .rtl .pollbar4, .rtl .pollbar5 { - border-right-color: transparent; -} - -.pollbar1 { - background-color: #AA2346; - border-bottom-color: #74162C; - border-right-color: #74162C; -} - -.rtl .pollbar1 { - border-left-color: #74162C; -} - -.pollbar2 { - background-color: #BE1E4A; - border-bottom-color: #8C1C38; - border-right-color: #8C1C38; -} - -.rtl .pollbar2 { - border-left-color: #8C1C38; -} - -.pollbar3 { - background-color: #D11A4E; - border-bottom-color: #AA2346; - border-right-color: #AA2346; -} - -.rtl .pollbar3 { - border-left-color: #AA2346; -} - -.pollbar4 { - background-color: #E41653; - border-bottom-color: #BE1E4A; - border-right-color: #BE1E4A; -} - -.rtl .pollbar4 { - border-left-color: #BE1E4A; -} - -.pollbar5 { - background-color: #F81157; - border-bottom-color: #D11A4E; - border-right-color: #D11A4E; -} - -.rtl .pollbar5 { - border-left-color: #D11A4E; -} - -/* Poster profile block -----------------------------------------*/ -.postprofile { - color: #666666; - border-color: #FFFFFF; -} - -.pm .postprofile { - border-color: #DDDDDD; -} - -.postprofile strong { - color: #000000; -} - -.online { - background-image: url("./en/icon_user_online.gif"); -} - -dd.profile-warnings { - color: #BC2A4D; -} - -/* --------------------------------------------------------------- -Colours and backgrounds for buttons.css --------------------------------------------------------------- */ -.button { - border-color: #C7C3BF; - background-color: #E9E9E9; /* Old browsers */ /* FF3.6+ */ - background-image: -webkit-linear-gradient(top, #FFFFFF 0%, #E9E9E9 100%); - background-image: linear-gradient(to bottom, #FFFFFF 0%,#E9E9E9 100%); /* W3C */ - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#FFFFFF', endColorstr='#E9E9E9',GradientType=0 ); /* IE6-9 */ - box-shadow: 0 0 0 1px #FFFFFF inset; - -webkit-box-shadow: 0 0 0 1px #FFFFFF inset; - color: #D31141; -} - -.button:hover, -.button:focus { - border-color: #0A8ED0; - background-color: #FFFFFF; /* Old browsers */ /* FF3.6+ */ - background-image: -webkit-linear-gradient(top, #E9E9E9 0%, #FFFFFF 100%); - background-image: linear-gradient(to bottom, #E9E9E9 0%,#FFFFFF 100%); /* W3C */ - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#E9E9E9', endColorstr='#FFFFFF',GradientType=0 ); /* IE6-9 */ - text-shadow: 1px 1px 0 #FFFFFF, -1px -1px 0 #FFFFFF, -1px -1px 0 rgba(188, 42, 77, 0.2); -} - - -.button .icon, -.button-secondary { - color: #8f8f8f; -} - -.button-secondary:focus, -.button-secondary:hover, -.button:focus .icon, -.button:hover .icon { - color: #0A8ED0; -} - -.button-search:hover, -.button-search-end:hover { - border-color: #C7C3BF; -} - -.caret { border-color: #DADADA; } -.caret { border-color: #C7C3BF; } - -.contact-icons a { border-color: #DCDCDC; } -.contact-icons a:hover { background-color: #F2F6F9; } - -/* Pagination ----------------------------------------- */ - -.pagination li a { - background: #ECEDEE; - filter: none; - border-color: #B4BAC0; - box-shadow: none; - -webkit-box-shadow: none; - color: #5C758C; -} - -.pagination li.ellipsis span { - background: transparent; - color: #000000; -} - -.pagination li.active span { - background: #4692BF; - border-color: #4692BF; - color: #FFFFFF; -} - -.pagination li a:hover, .pagination li a:hover .icon, .pagination .dropdown-visible a.dropdown-trigger, .nojs .pagination .dropdown-container:hover a.dropdown-trigger { - background: #368AD2; - border-color: #368AD2; - filter: none; - color: #FFFFFF; - text-shadow: none; -} - -/* Search box ---------------------------------------------- */ - -.search-box .inputbox, -.search-box .inputbox:hover, -.search-box .inputbox:focus { - border-color: #C7C3BF; -} - -.search-header { - box-shadow: 0 0 10px #0075B0; -} - -/* Icon images ----------------------------------------- */ - -.contact-icon { background-image: url("./images/icons_contact.png"); } - -/* Profile & navigation icons */ -.pm-icon { background-position: 0 0; } -.email-icon { background-position: -21px 0; } -.jabber-icon { background-position: -80px 0; } -.phpbb_icq-icon { background-position: -61px 0 ; } -.phpbb_wlm-icon { background-position: -182px 0; } -.phpbb_aol-icon { background-position: -244px 0; } -.phpbb_website-icon { background-position: -40px 0; } -.phpbb_youtube-icon { background-position: -98px 0; } -.phpbb_facebook-icon { background-position: -119px 0; } -.phpbb_googleplus-icon { background-position: -140px 0; } -.phpbb_skype-icon { background-position: -161px 0; } -.phpbb_twitter-icon { background-position: -203px 0; } -.phpbb_yahoo-icon { background-position: -224px 0; } - -/* Forum icons & Topic icons */ -.global_read { background-image: url("./images/announce_read.gif"); } -.global_read_mine { background-image: url("./images/announce_read_mine.gif"); } -.global_read_locked { background-image: url("./images/announce_read_locked.gif"); } -.global_read_locked_mine { background-image: url("./images/announce_read_locked_mine.gif"); } -.global_unread { background-image: url("./images/announce_unread.gif"); } -.global_unread_mine { background-image: url("./images/announce_unread_mine.gif"); } -.global_unread_locked { background-image: url("./images/announce_unread_locked.gif"); } -.global_unread_locked_mine { background-image: url("./images/announce_unread_locked_mine.gif"); } - -.announce_read { background-image: url("./images/announce_read.gif"); } -.announce_read_mine { background-image: url("./images/announce_read_mine.gif"); } -.announce_read_locked { background-image: url("./images/announce_read_locked.gif"); } -.announce_read_locked_mine { background-image: url("./images/announce_read_locked_mine.gif"); } -.announce_unread { background-image: url("./images/announce_unread.gif"); } -.announce_unread_mine { background-image: url("./images/announce_unread_mine.gif"); } -.announce_unread_locked { background-image: url("./images/announce_unread_locked.gif"); } -.announce_unread_locked_mine { background-image: url("./images/announce_unread_locked_mine.gif"); } - -.forum_link { background-image: url("./images/forum_link.gif"); } -.forum_read { background-image: url("./images/forum_read.gif"); } -.forum_read_locked { background-image: url("./images/forum_read_locked.gif"); } -.forum_read_subforum { background-image: url("./images/forum_read_subforum.gif"); } -.forum_unread { background-image: url("./images/forum_unread.gif"); } -.forum_unread_locked { background-image: url("./images/forum_unread_locked.gif"); } -.forum_unread_subforum { background-image: url("./images/forum_unread_subforum.gif"); } - -.sticky_read { background-image: url("./images/sticky_read.gif"); } -.sticky_read_mine { background-image: url("./images/sticky_read_mine.gif"); } -.sticky_read_locked { background-image: url("./images/sticky_read_locked.gif"); } -.sticky_read_locked_mine { background-image: url("./images/sticky_read_locked_mine.gif"); } -.sticky_unread { background-image: url("./images/sticky_unread.gif"); } -.sticky_unread_mine { background-image: url("./images/sticky_unread_mine.gif"); } -.sticky_unread_locked { background-image: url("./images/sticky_unread_locked.gif"); } -.sticky_unread_locked_mine { background-image: url("./images/sticky_unread_locked_mine.gif"); } - -.topic_moved { background-image: url("./images/topic_moved.gif"); } -.pm_read, -.topic_read { background-image: url("./images/topic_read.gif"); } -.topic_read_mine { background-image: url("./images/topic_read_mine.gif"); } -.topic_read_hot { background-image: url("./images/topic_read_hot.gif"); } -.topic_read_hot_mine { background-image: url("./images/topic_read_hot_mine.gif"); } -.topic_read_locked { background-image: url("./images/topic_read_locked.gif"); } -.topic_read_locked_mine { background-image: url("./images/topic_read_locked_mine.gif"); } -.pm_unread, -.topic_unread { background-image: url("./images/topic_unread.gif"); } -.topic_unread_mine { background-image: url("./images/topic_unread_mine.gif"); } -.topic_unread_hot { background-image: url("./images/topic_unread_hot.gif"); } -.topic_unread_hot_mine { background-image: url("./images/topic_unread_hot_mine.gif"); } -.topic_unread_locked { background-image: url("./images/topic_unread_locked.gif"); } -.topic_unread_locked_mine { background-image: url("./images/topic_unread_locked_mine.gif"); } - - -/* --------------------------------------------------------------- -Colours and backgrounds for cp.css --------------------------------------------------------------- */ - -/* Main CP box -----------------------------------------*/ - -.panel-container h3, .panel-container hr, .cp-menu hr { - border-color: #A4B3BF; -} - -.panel-container .panel li.row { - border-bottom-color: #B5C1CB; - border-top-color: #F9F9F9; -} - -ul.cplist { - border-top-color: #B5C1CB; -} - -.panel-container .panel li.header dd, .panel-container .panel li.header dt { - color: #000000; -} - -.panel-container table.table1 thead th { - color: #333333; - border-bottom-color: #333333; -} - -.cp-main .pm-message { - border-color: #DBDEE2; - background-color: #FFFFFF; -} - -/* CP tabbed menu -----------------------------------------*/ -.tabs .tab > a { - background: #BACCD9; - color: #536482; -} - -.tabs .tab > a:hover { - background: #DDEDFB; - color: #D31141; -} - -.tabs .activetab > a, -.tabs .activetab > a:hover { - background-color: #CADCEB; /* Old browsers */ /* FF3.6+ */ - background-image: -webkit-linear-gradient(top, #E2F2FF 0%, #CADCEB 100%); - background-image: linear-gradient(to bottom, #E2F2FF 0%,#CADCEB 100%); /* W3C */ - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#E2F2FF', endColorstr='#CADCEB',GradientType=0 ); /* IE6-9 */ - border-color: #CADCEB; - box-shadow: 0 1px 1px #F2F9FF inset; - color: #333333; -} - -.tabs .activetab > a:hover { - color: #000000; -} - -/* Mini tabbed menu used in MCP -----------------------------------------*/ -.minitabs .tab > a { - background-color: #E1EBF2; -} - -.minitabs .activetab > a, -.minitabs .activetab > a:hover { - background-color: #F9F9F9; - color: #333333; -} - -/* Responsive tabs -----------------------------------------*/ -.responsive-tab .responsive-tab-link:before { - border-color: #536482; -} - -.responsive-tab .responsive-tab-link:hover:before { - border-color: #D31141; -} - -/* UCP navigation menu -----------------------------------------*/ - -/* Link styles for the sub-section links */ -.navigation a { - color: #333; - background: #CADCEB; /* Old browsers */ /* FF3.6+ */ - background: -webkit-linear-gradient(left, #B4C4D1 50%, #CADCEB 100%); - background: linear-gradient(to right, #B4C4D1 50%,#CADCEB 100%); /* W3C */ - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#B4C4D1', endColorstr='#CADCEB',GradientType=1 ); /* IE6-9 */ -} - -.rtl .navigation a { - background: #B4C4D1; /* Old browsers */ /* FF3.6+ */ - background: -webkit-linear-gradient(left, #CADCEB 50%, #B4C4D1 100%); - background: linear-gradient(to right, #CADCEB 50%,#B4C4D1 100%); /* W3C */ - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#CADCEB', endColorstr='#B4C4D1',GradientType=1 ); /* IE6-9 */ -} - -.navigation a:hover { - background: #AABAC6; - color: #BC2A4D; - filter: progid:DXImageTransform.Microsoft.gradient(enabled = false); -} - -.navigation .active-subsection a { - background: #F9F9F9; - color: #D31141; - filter: progid:DXImageTransform.Microsoft.gradient(enabled = false); -} - -.navigation .active-subsection a:hover { - color: #D31141; -} - -@media only screen and (max-width: 900px), only screen and (max-device-width: 900px) -{ - #navigation a, .rtl #navigation a { - background: #B2C2CF; - } -} - -/* Preferences pane layout -----------------------------------------*/ -.panel-container h2 { - color: #333333; -} - -.panel-container .panel { - background-color: #F9F9F9; -} - -.cp-main .pm { - background-color: #FFFFFF; -} - -/* Friends list */ -.cp-mini { - background-color: #EEF5F9; -} - -dl.mini dt { - color: #425067; -} - -/* PM Styles -----------------------------------------*/ -/* PM Message history */ -.current { - color: #000000 !important; -} - -/* PM marking colours */ -.pmlist li.pm_message_reported_colour, .pm_message_reported_colour { - border-left-color: #BC2A4D; - border-right-color: #BC2A4D; -} - -.pmlist li.pm_marked_colour, .pm_marked_colour { - border-color: #FF6600; -} - -.pmlist li.pm_replied_colour, .pm_replied_colour { - border-color: #A9B8C2; -} - -.pmlist li.pm_friend_colour, .pm_friend_colour { - border-color: #5D8FBD; -} - -.pmlist li.pm_foe_colour, .pm_foe_colour { - border-color: #000000; -} - -/* Avatar gallery */ -.gallery label { - background: #FFFFFF; - border-color: #CCC; -} - -.gallery label:hover { - background-color: #EEE; -} - -/* --------------------------------------------------------------- -Colours and backgrounds for forms.css --------------------------------------------------------------- */ - -/* General form styles -----------------------------------------*/ -select { - border-color: #666666; - background-color: #FAFAFA; - color: #000; -} - -label { - color: #425067; -} - -option.disabled-option { - color: graytext; -} - -/* Definition list layout for forms ----------------------------------------- */ -dd label { - color: #333; -} - -fieldset.fields1 { - background-color: transparent; -} - -/* Hover effects */ -fieldset dl:hover dt label { - color: #000000; -} - -fieldset.fields2 dl:hover dt label { - color: inherit; -} - -/* Quick-login on index page */ -fieldset.quick-login input.inputbox { - background-color: #F2F3F3; -} - -/* Posting page styles -----------------------------------------*/ - -.message-box textarea { - color: #333333; -} - -.message-box textarea.drag-n-drop { - outline-color: rgba(102, 102, 102, 0.5); -} - -.message-box textarea.drag-n-drop-highlight { - outline-color: rgba(17, 163, 234, 0.5); -} - -/* Input field styles ----------------------------------------- */ -.inputbox { - background-color: #FFFFFF; - border-color: #B4BAC0; - color: #333333; -} - -.inputbox:-moz-placeholder { - color: #333333; -} - -.inputbox::-webkit-input-placeholder { - color: #333333; -} - -.inputbox:hover { - border-color: #11A3EA; -} - -.inputbox:focus { - border-color: #11A3EA; -} - -.inputbox:focus:-moz-placeholder { - color: transparent; -} - -.inputbox:focus::-webkit-input-placeholder { - color: transparent; -} - - -/* Form button styles ----------------------------------------- */ - -a.button1, input.button1, input.button3, a.button2, input.button2 { - color: #000; - background-color: #EFEFEF; /* Old browsers */ /* FF3.6+ */ - background-image: -webkit-linear-gradient(top, #D2D2D2 0%, #EFEFEF 100%); - background-image: linear-gradient(to bottom, #D2D2D2 0%,#EFEFEF 100%); /* W3C */ - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#D2D2D2', endColorstr='#EFEFEF',GradientType=0 ); /* IE6-9 */ -} - -a.button1, input.button1 { - border-color: #666666; -} - -input.button3 { - background-image: none; -} - -/* Alternative button */ -a.button2, input.button2, input.button3 { - border-color: #666666; -} - -/* button in the style of the form buttons */ -a.button1, a.button2 { - color: #000000; -} - -/* Hover states */ -a.button1:hover, input.button1:hover, a.button2:hover, input.button2:hover, input.button3:hover { - border-color: #D31141; - color: #D31141; - background-color: #D2D2D2; /* Old browsers */ /* FF3.6+ */ - background-image: -webkit-linear-gradient(top, #EFEFEF 0%, #D2D2D2 100%); - background-image: linear-gradient(to bottom, #EFEFEF 0%,#D2D2D2 100%); /* W3C */ - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#EFEFEF', endColorstr='#D2D2D2',GradientType=0 ); /* IE6-9 */ -} - -/* Focus states */ -input.button1:focus, input.button2:focus, input.button3:focus { - border-color: #11A3EA; - color: #0F4987; -} - -input.disabled { - color: #666666; -} - -/* jQuery popups ----------------------------------------- */ -.phpbb_alert { - background-color: #FFFFFF; - border-color: #999999; -} -.darken { - background-color: #000000; -} - -.loading_indicator { - background-color: #000000; - background-image: url("./images/loading.gif"); -} - -.dropdown-extended ul li { - border-top-color: #B9B9B9; -} - -.dropdown-extended ul li:hover { - background-color: #CFE1F6; - color: #000000; -} - -.dropdown-extended .header, .dropdown-extended .footer { - border-color: #B9B9B9; - color: #000000; -} - -.dropdown-extended .footer { - border-top-style: solid; - border-top-width: 1px; -} - -.dropdown-extended .header { - background-color: #F1F8FF; /* Old browsers */ /* FF3.6+ */ - background-image: -webkit-linear-gradient(top, #F1F8FF 0%, #CADCEB 100%); - background-image: linear-gradient(to bottom, #F1F8FF 0%,#CADCEB 100%); /* W3C */ - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#F1F8FF', endColorstr='#CADCEB',GradientType=0 ); /* IE6-9 */ -} - -.dropdown .pointer { - border-color: #B9B9B9 transparent; -} - -.dropdown .pointer-inner { - border-color: #FFF transparent; -} - -.dropdown-extended .pointer-inner { - border-color: #F1F8FF transparent; -} - -.dropdown .dropdown-contents { - background: #fff; - border-color: #B9B9B9; - box-shadow: 1px 3px 5px rgba(0, 0, 0, 0.2); -} - -.dropdown-up .dropdown-contents { - box-shadow: 1px 0 5px rgba(0, 0, 0, 0.2); -} - -.dropdown li, .dropdown li li { - border-color: #DCDCDC; -} - -.dropdown li.separator { - border-color: #DCDCDC; -} - -/* Notifications ----------------------------------------- */ - -.notification_list p.notification-time { - color: #4C5D77; -} - -li.notification-reported strong, li.notification-disapproved strong { - color: #D31141; -} - -.badge { - background-color: #D31141; - color: #ffffff; -} diff --git a/install/update/old/styles/prosilver/theme/common.css b/install/update/old/styles/prosilver/theme/common.css deleted file mode 100644 index a0dc5e0..0000000 --- a/install/update/old/styles/prosilver/theme/common.css +++ /dev/null @@ -1,1287 +0,0 @@ -/* General Markup Styles ----------------------------------------- */ -html { - font-size: 100%; - /* Always show a scrollbar for short pages - stops the jump when the scrollbar appears. non-IE browsers */ - height: 101%; -} - -body { - font-family: Verdana, Helvetica, Arial, sans-serif; - font-size: 10px; - line-height: normal; - margin: 0; - padding: 12px 0; - word-wrap: break-word; - -webkit-print-color-adjust: exact; -} - -h1 { - /* Forum name */ - font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; - margin-right: 200px; - margin-top: 15px; - font-weight: bold; - font-size: 2em; -} - -h2 { - /* Forum header titles */ - font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; - font-weight: normal; - font-size: 2em; - margin: 0.8em 0 0.2em 0; -} - -h2.solo { - margin-bottom: 1em; -} - -h3 { - /* Sub-headers (also used as post headers, but defined later) */ - font-family: Arial, Helvetica, sans-serif; - font-weight: bold; - text-transform: uppercase; - border-bottom: 1px solid transparent; - margin-bottom: 3px; - padding-bottom: 2px; - font-size: 1.05em; - margin-top: 20px; -} - -h4 { - /* Forum and topic list titles */ - font-family: "Trebuchet MS", Verdana, Helvetica, Arial, Sans-serif; - font-size: 1.3em; -} - -p { - line-height: 1.3em; - font-size: 1.1em; - margin-bottom: 1.5em; -} - -img { - border-width: 0; -} - -hr { - border: 0 solid transparent; - border-top-width: 1px; - height: 1px; - margin: 5px 0; - display: block; - clear: both; -} - -hr.dashed { - border-top-style: dashed; - margin: 10px 0; -} - -hr.divider { - display: none; -} - -p.right { - text-align: right; -} - -p.jumpbox-return { - margin-top: 10px; - margin-bottom: 0; - float: left; -} - -b, strong { - font-weight: bold; -} - -.text-strong { - font-weight: bold; -} - -i, em { - font-style: italic; -} - -.text-italics { - font-style: italic; -} - -u { - text-decoration: underline; -} - -ul { - list-style-type: disc; -} - -ol { - list-style-type: decimal; -} - -li { - display: list-item; -} - -ul ul, ol ul { - list-style-type: circle; -} - -ol ol ul, ol ul ul, ul ol ul, ul ul ul { - list-style-type: square; -} - -a:hover { text-decoration: underline; } - -/* Main blocks ----------------------------------------- */ -.wrap { - border: 1px solid transparent; - border-radius: 8px; - margin: 0 auto; - max-width: 1152px; - min-width: 625px; - padding: 15px; -} - -@media only screen and (max-width: 1220px), only screen and (max-device-width: 1220px) { - .wrap { - margin: 0 12px; - } -} - -.page-body { - margin: 4px 0; - clear: both; -} - -.page-footer { - clear: both; -} - -.page-footer h3 { - margin-top: 20px; -} - -.logo { - float: left; - width: auto; - padding: 10px 13px 0 10px; -} - -.logo:hover { - text-decoration: none; -} - -.site_logo { - display: inline-block; - width: 149px; - height: 52px; -} - -/* Site description and logo */ -.site-description { - float: left; - width: 65%; -} - -.site-description h1 { - margin-right: 0; -} - -/* Round cornered boxes and backgrounds ----------------------------------------- */ -.headerbar { - margin-bottom: 4px; - padding: 5px; - border-radius: 7px; -} - -.navbar { - padding: 3px 10px; - border-radius: 7px; -} - -.forabg { - margin-bottom: 4px; - padding: 5px; - clear: both; - border-radius: 7px; -} - -.forumbg { - margin-bottom: 4px; - padding: 5px; - clear: both; - border-radius: 7px; -} - -.panel { - margin-bottom: 4px; - padding: 5px 10px; - border-radius: 7px; -} - -.post { - padding: 5px 10px; - margin-bottom: 4px; - background-repeat: no-repeat; - background-position: 100% 0; - border-radius: 7px; - position: relative; -} - -.rowbg { - margin: 5px 5px 2px 5px; -} - -/* Horizontal lists -----------------------------------------*/ -.navbar ul.linklist { - padding: 2px 0; - list-style-type: none; -} - -ul.linklist { - display: block; - margin: 0; -} - -.cp-main .panel { - padding: 5px 10px; -} - -ul.linklist > li { - float: left; - font-size: 1.1em; - line-height: 2.2em; - list-style-type: none; - margin-right: 7px; - padding-top: 1px; - width: auto; -} - -ul.linklist > li.rightside, p.rightside, a.rightside { - float: right; - margin-right: 0; - margin-left: 7px; - text-align: right; -} - -ul.navlinks { - border-top: 1px solid transparent; -} - -ul.leftside { - float: left; - margin-left: 0; - margin-right: 5px; - text-align: left; -} - -ul.rightside { - float: right; - margin-left: 5px; - margin-right: -5px; - text-align: right; -} - -ul.linklist li.responsive-menu { - position: relative; - margin: 0 5px 0 0; -} - -.hasjs ul.linklist.leftside, .hasjs ul.linklist.rightside { - max-width: 48%; -} - -.hasjs ul.linklist.fullwidth { - max-width: none; -} - -li.responsive-menu.dropdown-right .dropdown { - left: -9px; -} - -li.responsive-menu.dropdown-left .dropdown { - right: -6px; -} - -ul.linklist .dropdown { - top: 22px; -} - -ul.linklist .dropdown-up .dropdown { - bottom: 18px; - top: auto; -} - -/* Bulletin icons for list items -----------------------------------------*/ -ul.linklist.bulletin > li:before { - display: inline-block; - content: "\2022"; - font-size: inherit; - line-height: inherit; - padding-right: 4px; -} - -ul.linklist.bulletin > li:first-child:before, -ul.linklist.bulletin > li.rightside:last-child:before { - content: none; -} - -ul.linklist.bulletin > li.no-bulletin:before { - content: none; -} - -.responsive-menu:before { - display: none !important; -} - -/* Profile in overall_header.html */ -.header-profile { - display: inline-block; - vertical-align: top; -} - -a.header-avatar, -a.header-avatar:hover { - text-decoration: none; -} - -a.header-avatar img { - margin-bottom: 2px; - max-height: 20px; - vertical-align: middle; - width: auto; -} - -a.header-avatar span:after { - content: '\f0dd'; - display: inline-block; - font: normal normal normal 14px/1 FontAwesome; - padding-left: 6px; - padding-top: 2px; - vertical-align: top; -} - -/* Dropdown menu -----------------------------------------*/ -.dropdown-container { - position: relative; -} - -.dropdown-container-right { - float: right; -} - -.dropdown-container-left { - float: left; -} - -.nojs .dropdown-container:hover .dropdown { - display: block !important; -} - -.dropdown { - display: none; - position: absolute; - left: 0; - top: 1.2em; - z-index: 2; - border: 1px solid transparent; - border-radius: 5px; - padding: 9px 0 0; - margin-right: -500px; -} - -.dropdown.live-search { - top: auto; -} - -.dropdown-container.topic-tools { - float: left; -} - -.dropdown-up .dropdown { - top: auto; - bottom: 1.2em; - padding: 0 0 9px; -} - -.dropdown-left .dropdown, .nojs .rightside .dropdown { - left: auto; - right: 0; - margin-left: -500px; - margin-right: 0; -} - -.dropdown-button-control .dropdown { - top: 24px; -} - -.dropdown-button-control.dropdown-up .dropdown { - top: auto; - bottom: 24px; -} - -.dropdown .pointer, .dropdown .pointer-inner { - position: absolute; - width: 0; - height: 0; - border-top-width: 0; - border-bottom: 10px solid transparent; - border-left: 10px dashed transparent; - border-right: 10px dashed transparent; - -webkit-transform: rotate(360deg); /* better anti-aliasing in webkit */ - display: block; -} - -.dropdown-up .pointer, .dropdown-up .pointer-inner { - border-bottom-width: 0; - border-top: 10px solid transparent; -} - -.dropdown .pointer { - right: auto; - left: 10px; - top: -1px; - z-index: 3; -} - -.dropdown-up .pointer { - bottom: -1px; - top: auto; -} - -.dropdown-left .dropdown .pointer, .nojs .rightside .dropdown .pointer { - left: auto; - right: 10px; -} - -.dropdown .pointer-inner { - top: auto; - bottom: -11px; - left: -10px; -} - -.dropdown-up .pointer-inner { - bottom: auto; - top: -11px; -} - -.dropdown .dropdown-contents { - z-index: 2; - overflow: hidden; - overflow-y: auto; - border: 1px solid transparent; - border-radius: 5px; - padding: 5px; - position: relative; - max-height: 300px; -} - -.dropdown-contents a { - display: block; - padding: 5px; -} - -.jumpbox { - margin: 5px 0; -} - -.jumpbox .dropdown li { - border-top: 1px solid transparent; -} - -.jumpbox .dropdown-select { - margin: 0; -} - -.jumpbox .dropdown-contents { - padding: 0; - text-decoration: none; -} - -.jumpbox .dropdown-contents li { - padding: 0; -} - -.jumpbox .dropdown-contents a { - margin-right: 20px; - padding: 5px 10px; - text-decoration: none; - width: 100%; -} - -.jumpbox .spacer { - display: inline-block; - width: 0px; -} - -.jumpbox .spacer + .spacer { - width: 20px; -} - -.dropdown-contents a { - display: block; - padding: 5px; -} - -.jumpbox .dropdown-select { - margin: 0; -} - -.jumpbox .dropdown-contents a { - text-decoration: none; -} - -.dropdown li { - display: list-item; - border-top: 1px dotted transparent; - float: none !important; - line-height: normal !important; - font-size: 1em !important; - list-style: none; - margin: 0; - white-space: nowrap; - text-align: left; -} - -.dropdown-contents > li { - padding-right: 15px; -} - -.dropdown-nonscroll > li { - padding-right: 0; -} - -.dropdown li:first-child, .dropdown li.separator + li, .dropdown li li { - border-top: 0; -} - -.dropdown li li:first-child { - margin-top: 4px; -} - -.dropdown li li:last-child { - padding-bottom: 0; -} - -.dropdown li li { - border-top: 1px dotted transparent; - padding-left: 18px; -} - -.wrap .dropdown li, .dropdown.wrap li, .dropdown-extended li { - white-space: normal; -} - -.dropdown li.separator { - border-top: 1px solid transparent; - padding: 0; -} - -.dropdown li.separator:first-child, .dropdown li.separator:last-child { - display: none !important; -} - -/* Responsive breadcrumbs -----------------------------------------*/ -.breadcrumbs .crumb { - float: left; - font-weight: bold; - word-wrap: normal; -} - -.breadcrumbs .crumb:before { - content: '\2039'; - font-weight: bold; - padding: 0 0.5em; -} - -.breadcrumbs .crumb:first-child:before { - content: none; -} - -.breadcrumbs .crumb a { - white-space: nowrap; - text-overflow: ellipsis; - vertical-align: bottom; - overflow: hidden; -} - -.breadcrumbs.wrapped .crumb a { letter-spacing: -.3px; } -.breadcrumbs.wrapped .crumb.wrapped-medium a { letter-spacing: -.4px; } -.breadcrumbs.wrapped .crumb.wrapped-tiny a { letter-spacing: -.5px; } - -.breadcrumbs .crumb.wrapped-max a { max-width: 120px; } -.breadcrumbs .crumb.wrapped-wide a { max-width: 100px; } -.breadcrumbs .crumb.wrapped-medium a { max-width: 80px; } -.breadcrumbs .crumb.wrapped-small a { max-width: 60px; } -.breadcrumbs .crumb.wrapped-tiny a { max-width: 40px; } - -/* Table styles -----------------------------------------*/ -table.table1 { - width: 100%; -} - -.ucp-main table.table1 { - padding: 2px; -} - -table.table1 thead th { - font-weight: normal; - text-transform: uppercase; - line-height: 1.3em; - font-size: 1em; - padding: 0 0 4px 3px; -} - -table.table1 thead th span { - padding-left: 7px; -} - -table.table1 tbody tr { - border: 1px solid transparent; -} - -table.table1 td { - font-size: 1.1em; -} - -table.table1 tbody td { - padding: 5px; - border-top: 1px solid transparent; -} - -table.table1 tbody th { - padding: 5px; - border-bottom: 1px solid transparent; - text-align: left; -} - -/* Specific column styles */ -table.table1 .name { text-align: left; } -table.table1 .center { text-align: center; } -table.table1 .reportby { width: 15%; } -table.table1 .posts { text-align: center; width: 7%; } -table.table1 .joined { text-align: left; width: 15%; } -table.table1 .active { text-align: left; width: 15%; } -table.table1 .mark { text-align: center; width: 7%; } -table.table1 .info { text-align: left; width: 30%; } -table.table1 .info div { width: 100%; white-space: normal; overflow: hidden; } -table.table1 .autocol { line-height: 2em; white-space: nowrap; } -table.table1 thead .autocol { padding-left: 1em; } - -table.table1 span.rank-img { - float: right; - width: auto; -} - -table.info td { - padding: 3px; -} - -table.info tbody th { - padding: 3px; - text-align: right; - vertical-align: top; - font-weight: normal; -} - -.forumbg table.table1 { - margin: 0; -} - -.forumbg-table > .inner { - margin: 0 -1px; -} - -.color_palette_placeholder table { - border-collapse: separate; - border-spacing: 1px; -} - -/* Misc layout styles ----------------------------------------- */ -/* column[1-2] styles are containers for two column layouts */ -.column1 { - float: left; - clear: left; - width: 49%; -} - -.column2 { - float: right; - clear: right; - width: 49%; -} - -/* General classes for placing floating blocks */ -.left-box { - float: left; - width: auto; - text-align: left; - max-width: 100%; -} - -.left-box.profile-details { - width: 80%; -} - -.right-box { - float: right; - width: auto; - text-align: right; - max-width: 100%; -} - -dl.details { - /*font-family: "Lucida Grande", Verdana, Helvetica, Arial, sans-serif;*/ - font-size: 1.1em; -} - -dl.details dt { - float: left; - clear: left; - width: 30%; - text-align: right; - display: block; -} - -dl.details dd { - margin-left: 0; - padding-left: 5px; - margin-bottom: 5px; - float: left; - width: 65%; - overflow: hidden; - text-overflow: ellipsis; -} - -.clearfix, fieldset dl, ul.topiclist dl, dl.polls { - overflow: hidden; -} - -fieldset.fields1 ul.recipients { - list-style-type: none; - line-height: 1.8; - max-height: 150px; - overflow-y: auto; -} - -fieldset.fields1 dd.recipients { - clear: left; - margin-left: 1em; -} - -fieldset.fields1 ul.recipients input.button2{ - font-size: 0.8em; - margin-right: 0; - padding: 0; -} - -fieldset.fields1 dl.pmlist > dt { - width: auto !important; -} - -fieldset.fields1 dl.pmlist dd.recipients { - margin-left: 0 !important; -} - -/* Action-bars (container for post/reply buttons, pagination, etc.) ----------------------------------------- */ -.action-bar { - font-size: 11px; - margin: 4px 0; -} - -.forabg + .action-bar { - margin-top: 2em; -} - -.action-bar .button { - margin-right: 5px; - float: left; -} - -.action-bar .button-search { - margin-right: 0; -} - -/* Pagination ----------------------------------------- */ -.pagination { - float: right; - text-align: right; - width: auto; -} - -.action-bar.bar-bottom .pagination { - margin-top: 0; -} - -.action-bar .pagination .button { - margin-right: 0; - float: none; -} - -.pagination > ul { - display: inline-block; - list-style: none !important; - margin-left: 5px; -} - -.pagination > ul > li { - display: inline-block !important; - padding: 0; - font-size: 100%; - line-height: normal; - vertical-align: middle; -} - -.pagination li a, .pagination li span { - border-radius: 2px; - padding: 2px 5px; -} - -.pagination li.active span { - display: inline-block; - font-size: 13px; - font-weight: normal; - font-family: "Open Sans", "Droid Sans", Verdana, Arial, Helvetica; - line-height: 1.4; - text-align: center; - white-space: nowrap; - vertical-align: middle; - border: 1px solid transparent; -} - -.pagination li.ellipsis span { - border: none; - padding: 0; -} - -.pagination li.page-jump { - margin-right: 5px; -} - -.pagination li.page-jump a { - padding: 0 8px; -} - -.pagination li.page-jump a i { - font-size: 21px; -} - -.pagination .arrow a { - padding: 2px 0; -} - -/* Pagination in viewforum for multipage topics */ -.row .pagination { - display: block; - margin-top: 3px; - margin-bottom: 3px; -} - -.row .pagination > ul { - margin: 0; -} - -.row .pagination li a, .row .pagination li span { - border-radius: 2px; - padding: 1px 3px; - font-size: 9px; -} - -/* jQuery popups ----------------------------------------- */ -.phpbb_alert { - border: 1px solid transparent; - display: none; - left: 0; - padding: 0 25px 20px 25px; - position: fixed; - right: 0; - top: 150px; - z-index: 50; - width: 620px; - margin: 0 auto; -} - -@media only screen and (max-height: 500px), only screen and (max-device-width: 500px) -{ - .phpbb_alert { - top: 25px; - } -} - -.phpbb_alert .alert_close { - float: right; - margin-right: -36px; - margin-top: -8px; -} - -.phpbb_alert p { - margin: 8px 0; - padding-bottom: 8px; -} - -.phpbb_alert label { - display: block; - margin: 8px 0; - padding-bottom: 8px; -} - -.phpbb_alert div.alert_text > p, -.phpbb_alert div.alert_text > label, -.phpbb_alert div.alert_text > select, -.phpbb_alert div.alert_text > textarea, -.phpbb_alert div.alert_text > input { - font-size: 1.1em; -} - -.darkenwrapper { - display: none; - position: relative; - z-index: 44; -} - -.darken { - position: fixed; - left: 0; - top: 0; - width: 100%; - height: 100%; - opacity: 0.5; - z-index: 45; -} - -.loading_indicator { - background: center center no-repeat; - border-radius: 5px; - display: none; - opacity: 0.8; - margin-top: -50px; - margin-left: -50px; - height: 50px; - width: 50px; - position: fixed; - left: 50%; - top: 50%; - z-index: 51; -} - -/* Miscellaneous styles ----------------------------------------- */ -.copyright { - font-size: 10px; - text-align: center; - padding: 10px; -} - -.footer-row { - font-size: 10px; - line-height: 1.8; - margin: 0; -} - -.small { - font-size: 0.9em !important; -} - -.titlespace { - margin-bottom: 15px; -} - -.headerspace { - margin-top: 20px; -} - -.error { - font-weight: bold; - font-size: 1em; -} - -div.rules { - margin: 10px 0; - font-size: 1.1em; - padding: 5px 10px; - border-radius: 7px; -} - -div.rules ul, div.rules ol { - margin-left: 20px; -} - -p.post-notice { - position: relative; - padding: 5px; - min-height: 14px; - margin-bottom: 1em; -} - -form > p.post-notice strong { - line-height: 20px; -} - -.stat-block { - clear: both; -} - -.top-anchor { - display: block; - position: absolute; - top: -20px; -} - -.clear { - display: block; - clear: both; - font-size: 1px; - line-height: 1px; - background: transparent; -} - -/* Inner box-model clearing */ -.inner:after, -ul.linklist:after, -.action-bar:after, -.notification_text:after, -.tabs-container:after, -.tabs > ul:after, -.minitabs > ul:after, -.postprofile .avatar-container:after { - clear: both; - content: ''; - display: block; -} - -.emoji { - min-height: 18px; - min-width: 18px; - height: 1em; - width: 1em; -} - -.smilies { - vertical-align: text-bottom; -} - -.icon-notification { - position: relative; -} - -.member-search { - float: left; - margin: 0; - padding: 6px 10px; -} - -.member-search strong { - font-size: 0.95em; -} - -.dropdown-extended { - display: none; - z-index: 1; -} - -.dropdown-extended ul { - max-height: 350px; - overflow-y: auto; - overflow-x: hidden; - clear: both; -} - -.dropdown-extended ul li { - padding: 0; - margin: 0 !important; - float: none; - border-top: 1px solid; - list-style-type: none; - font-size: 0.95em; - clear: both; - position: relative; -} - -.dropdown-extended ul li:first-child { - border-top: none; -} - -.dropdown-extended ul li.no_notifications { - padding: 10px; -} - -.dropdown-extended .dropdown-contents { - max-height: none; - padding: 0; - position: absolute; - width: 340px; -} - -.nojs .dropdown-extended .dropdown-contents { - position: relative; -} - -.dropdown-extended .header { - padding: 0 10px; - font-family: Arial, "Helvetica Neue", Helvetica, Arial, sans-serif; - font-weight: bold; - text-align: left; - text-shadow: 1px 1px 1px white; - text-transform: uppercase; - line-height: 3em; - border-bottom: 1px solid; - border-radius: 5px 5px 0 0; -} - -.dropdown-extended .header .header_settings { - float: right; - font-weight: normal; - text-transform: none; -} - -.dropdown-extended .header .header_settings a { - display: inline-block; - padding: 0 5px; -} - -.dropdown-extended .header:after { - content: ''; - display: table; - clear: both; -} - -.dropdown-extended .footer { - text-align: center; - font-size: 1.1em; -} - -.dropdown-extended ul li a, .dropdown-extended ul li.no-url { - padding: 8px; -} - -.dropdown-extended .footer > a { - padding: 5px 0; -} - -.dropdown-extended ul li a, .notification_list dt > a, .dropdown-extended .footer > a { - display: block; - text-decoration: none; -} - -.notification_list ul li img { - float: left; - max-height: 50px; - max-width: 50px; - width: auto !important; - height: auto !important; - margin-right: 5px; -} - -.notification_list ul li p { - margin-bottom: 4px; - font-size: 1em; -} - -.notification_list p.notification-reference, -.notification_list p.notification-location, -.notification_list li a p.notification-reason { - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} - -.notification_list p.notification-time { - font-size: 0.9em; - margin: 0; - text-align: right; -} - -.notification_list div.notifications { - margin-left: 50px; - padding: 5px; -} - -.notification_list div.notifications a { - display: block; -} - -.notification_list p.notifications_title { - font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; - font-size: 1.2em !important; -} - -.notification_list p.notifications_title strong { - font-weight: bold; -} - -.notification_list p.notifications_time { - font-size: 0.9em !important; -} - -.notification_text { - margin-left: 58px; -} - -.badge { - border-radius: 10px; - opacity: 0.8; - text-align: center; - white-space: nowrap; - font-size: 10px; - line-height: 1; - float: right; - display: inline-block; - margin-left: 3px; - vertical-align: baseline; - position: relative; - top: 3px; - padding: 4px 6px; -} - -.badge.hidden { - display: none; -} - -/* Navbar specific list items -----------------------------------------*/ - -.linklist .quick-links { - margin: 0 7px 0 0; -} - -.linklist.compact .rightside > a > span { - display: none; -} - -.dropdown-page-jump .dropdown { - top: 20px; -} - -.dropdown-page-jump.dropdown-up .dropdown { - bottom: 20px; -} - -.dropdown-page-jump input.tiny { - width: 50px; -} - -.dropdown .clone.hidden { - display: none; -} - -.dropdown .clone.hidden + li.separator { - display: none; -} - -.dropdown .clone.hidden + li { - border-top: none; -} diff --git a/install/update/old/styles/prosilver/theme/forms.css b/install/update/old/styles/prosilver/theme/forms.css deleted file mode 100644 index 5646a7d..0000000 --- a/install/update/old/styles/prosilver/theme/forms.css +++ /dev/null @@ -1,429 +0,0 @@ -/* Form Styles ----------------------------------------- */ - -/* General form styles -----------------------------------------*/ -fieldset { - border-width: 0; - font-family: Verdana, Helvetica, Arial, sans-serif; - font-size: 1.1em; -} - -input { - font-weight: normal; - vertical-align: middle; - padding: 0 3px; - font-size: 1em; - font-family: Verdana, Helvetica, Arial, sans-serif; -} - -select { - font-family: Verdana, Helvetica, Arial, sans-serif; - font-weight: normal; - cursor: pointer; - vertical-align: middle; - border: 1px solid transparent; - padding: 1px; - font-size: 1em; -} - -select:focus { - outline-style: none; -} - -option { - padding-right: 1em; -} - -select optgroup option { - padding-right: 1em; - font-family: Verdana, Helvetica, Arial, sans-serif; -} - -textarea { - font-family: "Lucida Grande", Verdana, Helvetica, Arial, sans-serif; - width: 60%; - padding: 2px; - font-size: 1em; - line-height: 1.4em; -} - -label { - cursor: default; - padding-right: 5px; -} - -label input { - vertical-align: middle; -} - -label img { - vertical-align: middle; -} - -/* Definition list layout for forms ----------------------------------------- */ -fieldset dl { - padding: 4px 0; -} - -fieldset dt { - float: left; - width: 40%; - text-align: left; - display: block; -} - -fieldset dd { - margin-left: 41%; - vertical-align: top; - margin-bottom: 3px; -} - -/* Specific layout 1 */ -fieldset.fields1 dt { - width: 15em; - border-right-width: 0; -} - -fieldset.fields1 dd { - margin-left: 15em; - border-left-width: 0; -} - -fieldset.fields1 div { - margin-bottom: 3px; -} - -/* Set it back to 0px for the reCaptcha divs: PHPBB3-9587 */ -fieldset.fields1 .live-search div { - margin-bottom: 0; -} - -/* Specific layout 2 */ -fieldset.fields2 dt { - width: 15em; - border-right-width: 0; -} - -fieldset.fields2 dd { - margin-left: 16em; - border-left-width: 0; -} - -/* Form elements */ -dt label { - font-weight: bold; - text-align: left; -} - -dd label { - white-space: nowrap; -} - -dd input, dd textarea { - margin-right: 3px; -} - -dd select { - width: auto; -} - -dd select[multiple] { - width: 100%; -} - -dd textarea { - width: 85%; -} - -/* Hover effects */ -.timezone { - width: 95%; -} - -/* Browser-specific tweaks */ -button::-moz-focus-inner { - padding: 0; - border: 0 -} - -/* Quick-login on index page */ -fieldset.quick-login { - margin-top: 5px; -} - -fieldset.quick-login input { - width: auto; -} - -fieldset.quick-login input.inputbox { - width: 15%; - vertical-align: middle; - margin-right: 5px; -} - -fieldset.quick-login label { - white-space: nowrap; - padding-right: 2px; -} - -/* Display options on viewtopic/viewforum pages */ -fieldset.display-options { - text-align: center; - margin: 3px 0 5px 0; -} - -fieldset.display-options label { - white-space: nowrap; - padding-right: 2px; -} - -fieldset.display-options a { - margin-top: 3px; -} - -.dropdown fieldset.display-options { - font-size: 1em; - margin: 0; - padding: 0; -} - -.dropdown fieldset.display-options label { - display: block; - margin: 4px; - padding: 0; - text-align: right; - white-space: nowrap; -} - -.dropdown fieldset.display-options select { - min-width: 120px; -} - -/* Display actions for ucp and mcp pages */ -fieldset.display-actions { - text-align: right; - line-height: 2em; - white-space: nowrap; - padding-right: 1em; -} - -fieldset.display-actions label { - white-space: nowrap; - padding-right: 2px; -} - -fieldset.sort-options { - line-height: 2em; -} - -/* MCP forum selection*/ -fieldset.forum-selection { - margin: 5px 0 3px 0; - float: right; -} - -fieldset.forum-selection2 { - margin: 13px 0 3px 0; - float: right; -} - -/* Submit button fieldset */ -fieldset.submit-buttons { - text-align: center; - vertical-align: middle; - margin: 5px 0; -} - -fieldset.submit-buttons input { - vertical-align: middle; -} - -/* Posting page styles -----------------------------------------*/ - -/* Buttons used in the editor */ -.format-buttons { - margin: 15px 0 2px 0; -} - -.format-buttons input, .format-buttons select { - vertical-align: middle; -} - -/* Main message box */ -.message-box { - width: 80%; -} - -.message-box textarea { - font-family: "Trebuchet MS", Verdana, Helvetica, Arial, sans-serif; - width: 450px; - height: 270px; - min-width: 100%; - max-width: 100%; - font-size: 1.2em; - resize: vertical; - outline: 3px dashed transparent; - outline-offset: -4px; - -webkit-transition: all .5s ease, height 1ms linear; - -moz-transition: all .5s ease, height 1ms linear; - -ms-transition: all .5s ease, height 1ms linear; - -o-transition: all .5s ease, height 1ms linear; - transition: all .5s ease, height 1ms linear; -} - -/* Emoticons panel */ -.smiley-box { - width: 18%; - float: right; -} - -.smiley-box img { - margin: 3px; -} - -/* Input field styles ----------------------------------------- */ -.inputbox { - border: 1px solid transparent; - padding: 2px; -} - -.inputbox:hover, .inputbox:focus { - border: 1px solid transparent; - outline-style: none; -} - -input.inputbox { width: 85%; } -input.medium { width: 50%; } -input.narrow { width: 25%; } -input.tiny { width: 150px; } - -textarea.inputbox { - width: 85%; -} - -.autowidth { - width: auto !important; -} - -input[type="number"] { - -moz-padding-end: 0; -} - -input[type="search"] { - -webkit-appearance: textfield; - -webkit-box-sizing: content-box; -} - -input[type="search"]::-webkit-search-decoration, input[type="search"]::-webkit-search-results-button, input[type="search"]::-webkit-search-results-decoration { - display: none; -} - -input[type="search"]::-webkit-search-cancel-button { - cursor: pointer; -} - -/* Form button styles ----------------------------------------- */ -input.button1, input.button2 { - font-size: 1em; -} - -a.button1, input.button1, input.button3, a.button2, input.button2 { - width: auto !important; - padding-top: 1px; - padding-bottom: 1px; - font-family: "Lucida Grande", Verdana, Helvetica, Arial, sans-serif; - background: transparent none repeat-x top left; - line-height: 1.5; -} - -a.button1, input.button1 { - font-weight: bold; - border: 1px solid transparent; -} - -input.button3 { - padding: 0; - margin: 0; - line-height: 5px; - height: 12px; - background-image: none; - font-variant: small-caps; -} - -input[type="button"], input[type="submit"], input[type="reset"], input[type="checkbox"], input[type="radio"] { - cursor: pointer; -} - -/* Alternative button */ -a.button2, input.button2, input.button3 { - border: 1px solid transparent; -} - -/* button in the style of the form buttons */ -a.button1, a.button2 { - text-decoration: none; - padding: 0 3px; - vertical-align: text-bottom; -} - -/* Hover states */ -a.button1:hover, input.button1:hover, a.button2:hover, input.button2:hover, input.button3:hover { - border: 1px solid transparent; -} - -input.disabled { - font-weight: normal; -} - -/* Focus states */ -input.button1:focus, input.button2:focus, input.button3:focus { - outline-style: none; -} - -/* Topic and forum Search */ -.search-box { - float: left; -} - -.search-box .inputbox { - background-image: none; - border-right-width: 0; - border-radius: 4px 0 0 4px; - float: left; - height: 24px; - padding: 3px; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; -} - -/* Search box (header) ---------------------------------------------- */ -.search-header { - border-radius: 4px; - display: block; - float: right; - margin-right: 5px; - margin-top: 30px; -} - -.search-header .inputbox { border: 0; } - -.navbar .linklist > li.responsive-search { display: none; } - -input.search { - background-image: none; - background-repeat: no-repeat; - background-position: left 1px; - padding-left: 17px; -} - -.full { width: 95%; } -.medium { width: 50%;} -.narrow { width: 25%;} -.tiny { width: 10%;} diff --git a/install/update/old/styles/prosilver/theme/icons.css b/install/update/old/styles/prosilver/theme/icons.css deleted file mode 100644 index 6643f12..0000000 --- a/install/update/old/styles/prosilver/theme/icons.css +++ /dev/null @@ -1,96 +0,0 @@ -/* -------------------------------------------------------------- - $Icons --------------------------------------------------------------- */ - -/* Global module setup ---------------------------------*/ - -/* Renamed version of .fa class for agnostic useage of icon fonts. - * Just change the name of the font after the 14/1 to the name of - * the font you wish to use. - */ -.icon, .button .icon, blockquote cite:before, .uncited:before { - display: inline-block; - font-weight: normal; - font-style: normal; - font-variant: normal; - font-family: FontAwesome; - font-size: 14px; - line-height: 1; - text-rendering: auto; /* optimizelegibility throws things off #1094 */ - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -.icon:before { padding-right: 2px; } - -.button .icon:before { - padding-right: 0; -} - -/* Icon size classes - Default size is 14px, use these for small variations */ - -.icon.icon-xl { - font-size: 20px; -} - -.icon.icon-lg { - font-size: 16px; -} - -.icon.icon-md { - font-size: 10px; -} - -.icon.icon-sm { - font-size: 8px; -} - -/* icon modifiers */ -.icon-tiny { - width: 12px; - transform: scale(0.65, 0.75); - vertical-align: text-bottom; - font-size: 16px; -} - -.arrow-left .icon { - float: left; -} - -.arrow-left:hover .icon { - margin-left: -5px; - margin-right: 5px; -} - -.arrow-right .icon { - float: right; -} - -.arrow-right:hover .icon { - margin-left: 5px; - margin-right: -5px; -} - -.post-buttons .dropdown-contents .icon { - float: right; - margin-left: 5px; -} - -.alert_close .icon:before { - padding: 0; - border-radius: 50%; - width: 11px; - display: block; - line-height: .9; - height: 12px; -} - -blockquote cite:before, .uncited:before { - content: '\f10d'; /* Font Awesome quote-left */ -} - -.rtl blockquote cite:before, .rtl .uncited:before { - content: '\f10e'; /* Font Awesome quote-right */ -} - diff --git a/install/update/old/styles/prosilver/theme/plupload.css b/install/update/old/styles/prosilver/theme/plupload.css deleted file mode 100644 index f466803..0000000 --- a/install/update/old/styles/prosilver/theme/plupload.css +++ /dev/null @@ -1,86 +0,0 @@ -.attach-panel-multi { - display: none; - margin-bottom: 1em; -} - -.file-list td { - vertical-align: middle; -} - -.attach-name { - width: 50%; -} - -.attach-comment { - width: 30%; -} - -.attach-comment .inputbox { - resize: vertical; - width: 100%; -} - -.attach-filesize { - width: 15%; -} - -.attach-status { - width: 5%; -} - -.attach-filesize, .attach-status { - text-align: center; -} - -.attach-controls { - display: inline-block; - float: right; -} - -.nojs .file-inline-bbcode { - display: none; -} - -.file-total-progress { - height: 2px; - display: block; - position: relative; - margin: 4px -10px -6px -10px; -} - -.file-progress { - background-color: #CCCCCC; - display:inline-block; - height: 8px; - width: 50px; -} - -.file-progress-bar, .file-total-progress-bar { - background-color: green; - display: block; - height: 100%; - width: 0; -} - -.file-status.file-working { - background: url('./images/plupload/throbber.gif'); -} - -.file-status.file-uploaded { - background: url('./images/plupload/done.gif'); -} - -.file-status.file-error { - background: url('./images/plupload/error.gif'); -} - -.file-status { - display: inline-block; - height: 16px; - width: 16px; -} - -.file-name { - max-width: 65%; - vertical-align: bottom; -} diff --git a/install/update/old/styles/prosilver/theme/print.css b/install/update/old/styles/prosilver/theme/print.css deleted file mode 100644 index 9445279..0000000 --- a/install/update/old/styles/prosilver/theme/print.css +++ /dev/null @@ -1,150 +0,0 @@ -/* Print Style Sheet ----------------------------------------- */ - - -/* Lots still TODO here! */ - -/* General markup styles */ -* { - padding: 0; - margin: 0; -} - -body { - font: 11pt Verdana, Arial, Helvetica, sans-serif; - color:#000000; -} - -a:link { color: #000000; text-decoration: none; } -a:visited { color: #000000; text-decoration: none; } -a:active { color: #000000; text-decoration: none; } - -img, .noprint, .navbar, .box1, .divider, .signature { display: none; } -/* Display smilies (Bug #47265) */ -.content img { - display: inline; -} - -/* Container for the main body */ -.wrap { - margin: 0 2em; -} - -p { font-size: 85%; } -.copyright { font-size: 75%; } -.page-number { float:right; width: auto; text-align: right; font-size: 75%; } - -h1, h2, h3, h1 a, h2 a, h3 a { - font-family: "Trebuchet MS",georgia,Verdana,Sans-serif; - color: #000000; - background: none; - text-decoration: none; - font-weight: bold; -} - -h1 { font-size: 20pt; } -h2 { font-size: 16pt; margin-top: 1em; } -h3 { font-size: 14pt; margin-top: 1em; } - -.content { - font-size: 11pt; - line-height: 14pt; - margin-bottom: 1em; - font-family: "Lucida Grande", "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif; - overflow: hidden; -} - -/* CSS2 Print tip from: http://www.alistapart.com/articles/goingtoprint/ */ -.postbody a:link, .postbody a:visited, .postbody a:hover, .postbody a:active { - text-decoration: underline; - padding: 0.1em 0.2em; - margin: -0.1em -0.2em; - color: #666; - background: none; - font-size: 100%; -} - -html>body .postbody a:link:after, html>body .postbody a:visited:after { - content: " (" attr(href) ") "; - font-size: 90%; - text-decoration: none; -} - -hr { - height: 1px; - background-color: #999999; - border-width: 0; -} - -.author { - font-family: Verdana, Arial, Helvetica, sans-serif; - font-size: 75%; - margin-bottom: 0.6em; -} - -.date { - font-family: Verdana, Arial, Helvetica, sans-serif; - float: right; - position: relative; - text-align: right; - font-size: 75%; -} - -/* Dont want to print url for names or titles in content area */ -.postbody .author a:link, .postbody .author a:visited, -html>body .postbody .author a:link:after, -html>body .postbody .author a:visited:after, -.postquote .quote-by a:link, .postquote .quote-by a:visited, -html>body .postquote .quote-by a:link:after, -html>body .postquote .quote-by a:visited:after, -html>body .postbody h1 a:link:after, html>body .postbody h2 a:link:after { - text-decoration: none; - content: ""; -} - -/* Poster profile */ -.postprofile { display: none; } -.grip-show { display:none; } - -/* Quote */ -.postquote, blockquote { - font-size: 85%; - margin: 1em 18% 1em 4%; - padding: 0.5em; - position: relative; - line-height: 1.5em; - border: 1px #999999 solid; -} - -.postquote img { display: none; } -.postquote span { display: block; } -.postquote span .postquote { font-size: 100%; } -.quote-by, blockquote cite { - color: black; - display : block; - font-weight: bold; -} - -/* List */ -ol, ul { - margin-left: 15pt -} - -/* Misc page elements */ -div.spacer { clear: both; } - -code { display: block; } - -/* Accessibility tweaks: Mozilla.org */ -.skip_link { display: none; } - -.codebox p { display: none; } - -/* stylelint-disable declaration-property-unit-whitelist */ -.emoji { - min-height: 18px; - min-width: 18px; - height: 1em; - width: 1em; -} -/* stylelint-enable declaration-property-unit-whitelist */ diff --git a/install/update/old/styles/prosilver/theme/stylesheet.css b/install/update/old/styles/prosilver/theme/stylesheet.css deleted file mode 100644 index 45eb5b6..0000000 --- a/install/update/old/styles/prosilver/theme/stylesheet.css +++ /dev/null @@ -1,21 +0,0 @@ -/* phpBB3 Style Sheet - -------------------------------------------------------------- - Style name: prosilver (the default phpBB 3.2.x style) - Based on style: - Original author: Tom Beddard ( http://www.subblue.com/ ) - Modified by: phpBB Limited ( https://www.phpbb.com/ ) - -------------------------------------------------------------- -*/ - -@import url("normalize.css?v=3.2"); -@import url("base.css?v=3.2"); -@import url("utilities.css?v=3.2"); -@import url("common.css?v=3.2"); -@import url("links.css?v=3.2"); -@import url("content.css?v=3.2"); -@import url("buttons.css?v=3.2"); -@import url("cp.css?v=3.2"); -@import url("forms.css?v=3.2"); -@import url("icons.css?v=3.2"); -@import url("colours.css?v=3.2"); -@import url("responsive.css?v=3.2"); diff --git a/install/update/old/ucp.php b/install/update/old/ucp.php deleted file mode 100644 index 96a3efe..0000000 --- a/install/update/old/ucp.php +++ /dev/null @@ -1,406 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -define('IN_PHPBB', true); -$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); -require($phpbb_root_path . 'common.' . $phpEx); -require($phpbb_root_path . 'includes/functions_user.' . $phpEx); -require($phpbb_root_path . 'includes/functions_module.' . $phpEx); - -// Basic parameter data -$id = $request->variable('i', ''); -$mode = $request->variable('mode', ''); - -if (in_array($mode, array('login', 'login_link', 'logout', 'confirm', 'sendpassword', 'activate'))) -{ - define('IN_LOGIN', true); -} - -if ($mode === 'delete_cookies') -{ - define('SKIP_CHECK_BAN', true); - define('SKIP_CHECK_DISABLED', true); -} - -// Start session management -$user->session_begin(); -$auth->acl($user->data); -$user->setup('ucp'); - -// Setting a variable to let the style designer know where he is... -$template->assign_var('S_IN_UCP', true); - -$module = new p_master(); -$default = false; - -// Basic "global" modes -switch ($mode) -{ - case 'activate': - $module->load('ucp', 'activate'); - $module->display($user->lang['UCP_ACTIVATE']); - - redirect(append_sid("{$phpbb_root_path}index.$phpEx")); - break; - - case 'resend_act': - $module->load('ucp', 'resend'); - $module->display($user->lang['UCP_RESEND']); - break; - - case 'sendpassword': - $module->load('ucp', 'remind'); - $module->display($user->lang['UCP_REMIND']); - break; - - case 'register': - if ($user->data['is_registered'] || isset($_REQUEST['not_agreed'])) - { - redirect(append_sid("{$phpbb_root_path}index.$phpEx")); - } - - $module->load('ucp', 'register'); - $module->display($user->lang['REGISTER']); - break; - - case 'confirm': - $module->load('ucp', 'confirm'); - break; - - case 'login': - if ($user->data['is_registered']) - { - redirect(append_sid("{$phpbb_root_path}index.$phpEx")); - } - - login_box($request->variable('redirect', "index.$phpEx")); - break; - - case 'login_link': - if ($user->data['is_registered']) - { - redirect(append_sid("{$phpbb_root_path}index.$phpEx")); - } - - $module->load('ucp', 'login_link'); - $module->display($user->lang['UCP_LOGIN_LINK']); - break; - - case 'logout': - if ($user->data['user_id'] != ANONYMOUS && $request->is_set('sid') && $request->variable('sid', '') === $user->session_id) - { - $user->session_kill(); - } - else if ($user->data['user_id'] != ANONYMOUS) - { - meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx")); - - $message = $user->lang['LOGOUT_FAILED'] . '

' . sprintf($user->lang['RETURN_INDEX'], '
', ' '); - trigger_error($message); - } - - redirect(append_sid("{$phpbb_root_path}index.$phpEx")); - break; - - case 'terms': - case 'privacy': - - $message = ($mode == 'terms') ? 'TERMS_OF_USE_CONTENT' : 'PRIVACY_POLICY'; - $title = ($mode == 'terms') ? 'TERMS_USE' : 'PRIVACY'; - - if (empty($user->lang[$message])) - { - if ($user->data['is_registered']) - { - redirect(append_sid("{$phpbb_root_path}index.$phpEx")); - } - - login_box(); - } - - $template->set_filenames(array( - 'body' => 'ucp_agreement.html') - ); - - // Disable online list - page_header($user->lang[$title]); - - $template->assign_vars(array( - 'S_AGREEMENT' => true, - 'AGREEMENT_TITLE' => $user->lang[$title], - 'AGREEMENT_TEXT' => sprintf($user->lang[$message], $config['sitename'], generate_board_url()), - 'U_BACK' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'), - 'L_BACK' => $user->lang['BACK_TO_PREV'], - )); - - page_footer(); - - break; - - case 'delete_cookies': - - // Delete Cookies with dynamic names (do NOT delete poll cookies) - if (confirm_box(true)) - { - $set_time = time() - 31536000; - - foreach ($request->variable_names(\phpbb\request\request_interface::COOKIE) as $cookie_name) - { - $cookie_data = $request->variable($cookie_name, '', true, \phpbb\request\request_interface::COOKIE); - - // Only delete board cookies, no other ones... - if (strpos($cookie_name, $config['cookie_name'] . '_') !== 0) - { - continue; - } - - $cookie_name = str_replace($config['cookie_name'] . '_', '', $cookie_name); - - /** - * Event to save custom cookies from deletion - * - * @event core.ucp_delete_cookies - * @var string cookie_name Cookie name to checking - * @var bool retain_cookie Do we retain our cookie or not, true if retain - * @since 3.1.3-RC1 - */ - $retain_cookie = false; - $vars = array('cookie_name', 'retain_cookie'); - extract($phpbb_dispatcher->trigger_event('core.ucp_delete_cookies', compact($vars))); - if ($retain_cookie) - { - continue; - } - - // Polls are stored as {cookie_name}_poll_{topic_id}, cookie_name_ got removed, therefore checking for poll_ - if (strpos($cookie_name, 'poll_') !== 0) - { - $user->set_cookie($cookie_name, '', $set_time); - } - } - - $user->set_cookie('track', '', $set_time); - $user->set_cookie('u', '', $set_time); - $user->set_cookie('k', '', $set_time); - $user->set_cookie('sid', '', $set_time); - - // We destroy the session here, the user will be logged out nevertheless - $user->session_kill(); - $user->session_begin(); - - meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx")); - - $message = $user->lang['COOKIES_DELETED'] . '

' . sprintf($user->lang['RETURN_INDEX'], '', ''); - trigger_error($message); - } - else - { - confirm_box(false, 'DELETE_COOKIES', ''); - } - - redirect(append_sid("{$phpbb_root_path}index.$phpEx")); - - break; - - case 'switch_perm': - - $user_id = $request->variable('u', 0); - - $sql = 'SELECT * - FROM ' . USERS_TABLE . ' - WHERE user_id = ' . (int) $user_id; - $result = $db->sql_query($sql); - $user_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$auth->acl_get('a_switchperm') || !$user_row || $user_id == $user->data['user_id'] || !check_link_hash($request->variable('hash', ''), 'switchperm')) - { - redirect(append_sid("{$phpbb_root_path}index.$phpEx")); - } - - include($phpbb_root_path . 'includes/acp/auth.' . $phpEx); - - $auth_admin = new auth_admin(); - if (!$auth_admin->ghost_permissions($user_id, $user->data['user_id'])) - { - redirect(append_sid("{$phpbb_root_path}index.$phpEx")); - } - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ACL_TRANSFER_PERMISSIONS', false, array($user_row['username'])); - - $message = sprintf($user->lang['PERMISSIONS_TRANSFERRED'], $user_row['username']) . '

' . sprintf($user->lang['RETURN_INDEX'], '', ''); - - /** - * Event to run code after permissions are switched - * - * @event core.ucp_switch_permissions - * @var int user_id User ID to switch permission to - * @var array user_row User data - * @var string message Success message - * @since 3.1.11-RC1 - */ - $vars = array('user_id', 'user_row', 'message'); - extract($phpbb_dispatcher->trigger_event('core.ucp_switch_permissions', compact($vars))); - - trigger_error($message); - - break; - - case 'restore_perm': - - if (!$user->data['user_perm_from'] || !$auth->acl_get('a_switchperm')) - { - redirect(append_sid("{$phpbb_root_path}index.$phpEx")); - } - - $auth->acl_cache($user->data); - - $sql = 'SELECT username - FROM ' . USERS_TABLE . ' - WHERE user_id = ' . $user->data['user_perm_from']; - $result = $db->sql_query($sql); - $username = $db->sql_fetchfield('username'); - $db->sql_freeresult($result); - - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ACL_RESTORE_PERMISSIONS', false, array($username)); - - $message = $user->lang['PERMISSIONS_RESTORED'] . '

' . sprintf($user->lang['RETURN_INDEX'], '', ''); - - /** - * Event to run code after permissions are restored - * - * @event core.ucp_restore_permissions - * @var string username User name - * @var string message Success message - * @since 3.1.11-RC1 - */ - $vars = array('username', 'message'); - extract($phpbb_dispatcher->trigger_event('core.ucp_restore_permissions', compact($vars))); - - trigger_error($message); - - break; - - default: - $default = true; - break; -} - -// We use this approach because it does not impose large code changes -if (!$default) -{ - return true; -} - -// Only registered users can go beyond this point -if (!$user->data['is_registered']) -{ - if ($user->data['is_bot']) - { - redirect(append_sid("{$phpbb_root_path}index.$phpEx")); - } - - if ($id == 'pm' && $mode == 'view' && isset($_GET['p'])) - { - $redirect_url = append_sid("{$phpbb_root_path}ucp.$phpEx?i=pm&p=" . $request->variable('p', 0)); - login_box($redirect_url, $user->lang['LOGIN_EXPLAIN_UCP']); - } - - login_box('', $user->lang['LOGIN_EXPLAIN_UCP']); -} - -// Instantiate module system and generate list of available modules -$module->list_modules('ucp'); - -// Check if the zebra module is set -if ($module->is_active('zebra', 'friends')) -{ - // Output listing of friends online - $update_time = $config['load_online_time'] * 60; - - $sql_ary = array( - 'SELECT' => 'u.user_id, u.username, u.username_clean, u.user_colour, MAX(s.session_time) as online_time, MIN(s.session_viewonline) AS viewonline', - - 'FROM' => array( - USERS_TABLE => 'u', - ZEBRA_TABLE => 'z', - ), - - 'LEFT_JOIN' => array( - array( - 'FROM' => array(SESSIONS_TABLE => 's'), - 'ON' => 's.session_user_id = z.zebra_id', - ), - ), - - 'WHERE' => 'z.user_id = ' . $user->data['user_id'] . ' - AND z.friend = 1 - AND u.user_id = z.zebra_id', - - 'GROUP_BY' => 'z.zebra_id, u.user_id, u.username_clean, u.user_colour, u.username', - - 'ORDER_BY' => 'u.username_clean ASC', - ); - - $sql = $db->sql_build_query('SELECT_DISTINCT', $sql_ary); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $which = (time() - $update_time < $row['online_time'] && ($row['viewonline'] || $auth->acl_get('u_viewonline'))) ? 'online' : 'offline'; - - $template->assign_block_vars("friends_{$which}", array( - 'USER_ID' => $row['user_id'], - - 'U_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']), - 'USER_COLOUR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), - 'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), - 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'])) - ); - } - $db->sql_freeresult($result); -} - -// Do not display subscribed topics/forums if not allowed -if (!$config['allow_topic_notify'] && !$config['allow_forum_notify']) -{ - $module->set_display('main', 'subscribed', false); -} - -/** -* Use this event to enable and disable additional UCP modules -* -* @event core.ucp_display_module_before -* @var p_master module Object holding all modules and their status -* @var mixed id Active module category (can be the int or string) -* @var string mode Active module -* @since 3.1.0-a1 -*/ -$vars = array('module', 'id', 'mode'); -extract($phpbb_dispatcher->trigger_event('core.ucp_display_module_before', compact($vars))); - -// Select the active module -$module->set_active($id, $mode); - -// Load and execute the relevant module -$module->load_active(); - -// Assign data to the template engine for the list of modules -$module->assign_tpl_vars(append_sid("{$phpbb_root_path}ucp.$phpEx")); - -// Generate the page, do not display/query online list -$module->display($module->get_page_title()); diff --git a/install/update/old/viewforum.php b/install/update/old/viewforum.php deleted file mode 100644 index 5525a0d..0000000 --- a/install/update/old/viewforum.php +++ /dev/null @@ -1,1059 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -define('IN_PHPBB', true); -$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); -include($phpbb_root_path . 'common.' . $phpEx); -include($phpbb_root_path . 'includes/functions_display.' . $phpEx); - -// Start session -$user->session_begin(); -$auth->acl($user->data); - -// Start initial var setup -$forum_id = $request->variable('f', 0); -$mark_read = $request->variable('mark', ''); -$start = $request->variable('start', 0); - -$default_sort_days = (!empty($user->data['user_topic_show_days'])) ? $user->data['user_topic_show_days'] : 0; -$default_sort_key = (!empty($user->data['user_topic_sortby_type'])) ? $user->data['user_topic_sortby_type'] : 't'; -$default_sort_dir = (!empty($user->data['user_topic_sortby_dir'])) ? $user->data['user_topic_sortby_dir'] : 'd'; - -$sort_days = $request->variable('st', $default_sort_days); -$sort_key = $request->variable('sk', $default_sort_key); -$sort_dir = $request->variable('sd', $default_sort_dir); - -/* @var $pagination \phpbb\pagination */ -$pagination = $phpbb_container->get('pagination'); - -// Check if the user has actually sent a forum ID with his/her request -// If not give them a nice error page. -if (!$forum_id) -{ - trigger_error('NO_FORUM'); -} - -$sql_from = FORUMS_TABLE . ' f'; -$lastread_select = ''; - -// Grab appropriate forum data -if ($config['load_db_lastread'] && $user->data['is_registered']) -{ - $sql_from .= ' LEFT JOIN ' . FORUMS_TRACK_TABLE . ' ft ON (ft.user_id = ' . $user->data['user_id'] . ' - AND ft.forum_id = f.forum_id)'; - $lastread_select .= ', ft.mark_time'; -} - -if ($user->data['is_registered']) -{ - $sql_from .= ' LEFT JOIN ' . FORUMS_WATCH_TABLE . ' fw ON (fw.forum_id = f.forum_id AND fw.user_id = ' . $user->data['user_id'] . ')'; - $lastread_select .= ', fw.notify_status'; -} - -$sql = "SELECT f.* $lastread_select - FROM $sql_from - WHERE f.forum_id = $forum_id"; -$result = $db->sql_query($sql); -$forum_data = $db->sql_fetchrow($result); -$db->sql_freeresult($result); - -if (!$forum_data) -{ - trigger_error('NO_FORUM'); -} - - -// Configure style, language, etc. -$user->setup('viewforum', $forum_data['forum_style']); - -// Redirect to login upon emailed notification links -if (isset($_GET['e']) && !$user->data['is_registered']) -{ - login_box('', $user->lang['LOGIN_NOTIFY_FORUM']); -} - -// Permissions check -if (!$auth->acl_gets('f_list', 'f_list_topics', 'f_read', $forum_id) || ($forum_data['forum_type'] == FORUM_LINK && $forum_data['forum_link'] && !$auth->acl_get('f_read', $forum_id))) -{ - if ($user->data['user_id'] != ANONYMOUS) - { - send_status_line(403, 'Forbidden'); - trigger_error('SORRY_AUTH_READ'); - } - - login_box('', $user->lang['LOGIN_VIEWFORUM']); -} - -// Forum is passworded ... check whether access has been granted to this -// user this session, if not show login box -if ($forum_data['forum_password']) -{ - login_forum_box($forum_data); -} - -// Is this forum a link? ... User got here either because the -// number of clicks is being tracked or they guessed the id -if ($forum_data['forum_type'] == FORUM_LINK && $forum_data['forum_link']) -{ - // Does it have click tracking enabled? - if ($forum_data['forum_flags'] & FORUM_FLAG_LINK_TRACK) - { - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET forum_posts_approved = forum_posts_approved + 1 - WHERE forum_id = ' . $forum_id; - $db->sql_query($sql); - } - - // We redirect to the url. The third parameter indicates that external redirects are allowed. - redirect($forum_data['forum_link'], false, true); - return; -} - -// Build navigation links -generate_forum_nav($forum_data); - -// Forum Rules -if ($auth->acl_get('f_read', $forum_id)) -{ - generate_forum_rules($forum_data); -} - -// Do we have subforums? -$active_forum_ary = $moderators = array(); - -if ($forum_data['left_id'] != $forum_data['right_id'] - 1) -{ - list($active_forum_ary, $moderators) = display_forums($forum_data, $config['load_moderators'], $config['load_moderators']); -} -else -{ - $template->assign_var('S_HAS_SUBFORUM', false); - if ($config['load_moderators']) - { - get_moderators($moderators, $forum_id); - } -} - -// Is a forum specific topic count required? -if ($forum_data['forum_topics_per_page']) -{ - $config['topics_per_page'] = $forum_data['forum_topics_per_page']; -} - -/* @var $phpbb_content_visibility \phpbb\content_visibility */ -$phpbb_content_visibility = $phpbb_container->get('content.visibility'); - -// Dump out the page header and load viewforum template -$topics_count = $phpbb_content_visibility->get_count('forum_topics', $forum_data, $forum_id); -$start = $pagination->validate_start($start, $config['topics_per_page'], $topics_count); - -$page_title = $forum_data['forum_name'] . ($start ? ' - ' . $user->lang('PAGE_TITLE_NUMBER', $pagination->get_on_page($config['topics_per_page'], $start)) : ''); - -/** -* You can use this event to modify the page title of the viewforum page -* -* @event core.viewforum_modify_page_title -* @var string page_title Title of the viewforum page -* @var array forum_data Array with forum data -* @var int forum_id The forum ID -* @var int start Start offset used to calculate the page -* @since 3.2.2-RC1 -*/ -$vars = array('page_title', 'forum_data', 'forum_id', 'start'); -extract($phpbb_dispatcher->trigger_event('core.viewforum_modify_page_title', compact($vars))); - -page_header($page_title, true, $forum_id); - -$template->set_filenames(array( - 'body' => 'viewforum_body.html') -); - -make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"), $forum_id); - -$template->assign_vars(array( - 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . (($start == 0) ? '' : "&start=$start")), -)); - -// Not postable forum or showing active topics? -if (!($forum_data['forum_type'] == FORUM_POST || (($forum_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS) && $forum_data['forum_type'] == FORUM_CAT))) -{ - page_footer(); -} - -// Ok, if someone has only list-access, we only display the forum list. -// We also make this circumstance available to the template in case we want to display a notice. ;) -if (!$auth->acl_gets('f_read', 'f_list_topics', $forum_id)) -{ - // Add form token for login box - add_form_key('login', '_LOGIN'); - - $template->assign_vars(array( - 'S_NO_READ_ACCESS' => true, - )); - - page_footer(); -} - -// Handle marking posts -if ($mark_read == 'topics') -{ - $token = $request->variable('hash', ''); - if (check_link_hash($token, 'global')) - { - markread('topics', array($forum_id), false, $request->variable('mark_time', 0)); - } - $redirect_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id); - meta_refresh(3, $redirect_url); - - if ($request->is_ajax()) - { - // Tell the ajax script what language vars and URL need to be replaced - $data = array( - 'NO_UNREAD_POSTS' => $user->lang['NO_UNREAD_POSTS'], - 'UNREAD_POSTS' => $user->lang['UNREAD_POSTS'], - 'U_MARK_TOPICS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'hash=' . generate_link_hash('global') . "&f=$forum_id&mark=topics&mark_time=" . time()) : '', - 'MESSAGE_TITLE' => $user->lang['INFORMATION'], - 'MESSAGE_TEXT' => $user->lang['TOPICS_MARKED'] - ); - $json_response = new \phpbb\json_response(); - $json_response->send($data); - } - - trigger_error($user->lang['TOPICS_MARKED'] . '

' . sprintf($user->lang['RETURN_FORUM'], '', '')); -} - -// Do the forum Prune thang - cron type job ... -if (!$config['use_system_cron']) -{ - /* @var $cron \phpbb\cron\manager */ - $cron = $phpbb_container->get('cron.manager'); - - $task = $cron->find_task('cron.task.core.prune_forum'); - $task->set_forum_data($forum_data); - - if ($task->is_ready()) - { - $url = $task->get_url(); - $template->assign_var('RUN_CRON_TASK', 'cron'); - } - else - { - // See if we should prune the shadow topics instead - $task = $cron->find_task('cron.task.core.prune_shadow_topics'); - $task->set_forum_data($forum_data); - - if ($task->is_ready()) - { - $url = $task->get_url(); - $template->assign_var('RUN_CRON_TASK', 'cron'); - } - } -} - -// Forum rules and subscription info -$s_watching_forum = array( - 'link' => '', - 'link_toggle' => '', - 'title' => '', - 'title_toggle' => '', - 'is_watching' => false, -); - -if ($config['allow_forum_notify'] && $forum_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_subscribe', $forum_id) || $user->data['user_id'] == ANONYMOUS)) -{ - $notify_status = (isset($forum_data['notify_status'])) ? $forum_data['notify_status'] : NULL; - watch_topic_forum('forum', $s_watching_forum, $user->data['user_id'], $forum_id, 0, $notify_status, $start, $forum_data['forum_name']); -} - -$s_forum_rules = ''; -gen_forum_auth_level('forum', $forum_id, $forum_data['forum_status']); - -// Topic ordering options -$limit_days = array(0 => $user->lang['ALL_TOPICS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); - -$sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 'r' => $user->lang['REPLIES'], 's' => $user->lang['SUBJECT'], 'v' => $user->lang['VIEWS']); -$sort_by_sql = array('a' => 't.topic_first_poster_name', 't' => array('t.topic_last_post_time', 't.topic_last_post_id'), 'r' => (($auth->acl_get('m_approve', $forum_id)) ? 't.topic_posts_approved + t.topic_posts_unapproved + t.topic_posts_softdeleted' : 't.topic_posts_approved'), 's' => 'LOWER(t.topic_title)', 'v' => 't.topic_views'); - -/** - * Modify the topic ordering if needed - * - * @event core.viewforum_modify_topic_ordering - * @var array sort_by_text Topic ordering options - * @var array sort_by_sql Topic orderings options SQL equivalent - * @since 3.2.5-RC1 - */ -$vars = array( - 'sort_by_text', - 'sort_by_sql', -); -extract($phpbb_dispatcher->trigger_event('core.viewforum_modify_topic_ordering', compact($vars))); - -$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; -gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param, $default_sort_days, $default_sort_key, $default_sort_dir); - -// Limit topics to certain time frame, obtain correct topic count -if ($sort_days) -{ - $min_post_time = time() - ($sort_days * 86400); - - $sql_array = array( - 'SELECT' => 'COUNT(t.topic_id) AS num_topics', - 'FROM' => array( - TOPICS_TABLE => 't', - ), - 'WHERE' => 't.forum_id = ' . $forum_id . ' - AND (t.topic_last_post_time >= ' . $min_post_time . ' - OR t.topic_type = ' . POST_ANNOUNCE . ' - OR t.topic_type = ' . POST_GLOBAL . ') - AND ' . $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.'), - ); - - /** - * Modify the sort data SQL query for getting additional fields if needed - * - * @event core.viewforum_modify_sort_data_sql - * @var int forum_id The forum_id whose topics are being listed - * @var int start Variable containing start for pagination - * @var int sort_days The oldest topic displayable in elapsed days - * @var string sort_key The sorting by. It is one of the first character of (in low case): - * Author, Post time, Replies, Subject, Views - * @var string sort_dir Either "a" for ascending or "d" for descending - * @var array sql_array The SQL array to get the data of all topics - * @since 3.1.9-RC1 - */ - $vars = array( - 'forum_id', - 'start', - 'sort_days', - 'sort_key', - 'sort_dir', - 'sql_array', - ); - extract($phpbb_dispatcher->trigger_event('core.viewforum_modify_sort_data_sql', compact($vars))); - - $result = $db->sql_query($db->sql_build_query('SELECT', $sql_array)); - $topics_count = (int) $db->sql_fetchfield('num_topics'); - $db->sql_freeresult($result); - - if (isset($_POST['sort'])) - { - $start = 0; - } - $sql_limit_time = "AND t.topic_last_post_time >= $min_post_time"; - - // Make sure we have information about day selection ready - $template->assign_var('S_SORT_DAYS', true); -} -else -{ - $sql_limit_time = ''; -} - -// Basic pagewide vars -$post_alt = ($forum_data['forum_status'] == ITEM_LOCKED) ? $user->lang['FORUM_LOCKED'] : $user->lang['POST_NEW_TOPIC']; - -// Display active topics? -$s_display_active = ($forum_data['forum_type'] == FORUM_CAT && ($forum_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS)) ? true : false; - -$s_search_hidden_fields = array('fid' => array($forum_id)); -if ($_SID) -{ - $s_search_hidden_fields['sid'] = $_SID; -} - -if (!empty($_EXTRA_URL)) -{ - foreach ($_EXTRA_URL as $url_param) - { - $url_param = explode('=', $url_param, 2); - $s_search_hidden_fields[$url_param[0]] = $url_param[1]; - } -} - -$template->assign_vars(array( - 'MODERATORS' => (!empty($moderators[$forum_id])) ? implode($user->lang['COMMA_SEPARATOR'], $moderators[$forum_id]) : '', - - 'POST_IMG' => ($forum_data['forum_status'] == ITEM_LOCKED) ? $user->img('button_topic_locked', $post_alt) : $user->img('button_topic_new', $post_alt), - 'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'), - 'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'), - 'FOLDER_IMG' => $user->img('topic_read', 'NO_UNREAD_POSTS'), - 'FOLDER_UNREAD_IMG' => $user->img('topic_unread', 'UNREAD_POSTS'), - 'FOLDER_HOT_IMG' => $user->img('topic_read_hot', 'NO_UNREAD_POSTS_HOT'), - 'FOLDER_HOT_UNREAD_IMG' => $user->img('topic_unread_hot', 'UNREAD_POSTS_HOT'), - 'FOLDER_LOCKED_IMG' => $user->img('topic_read_locked', 'NO_UNREAD_POSTS_LOCKED'), - 'FOLDER_LOCKED_UNREAD_IMG' => $user->img('topic_unread_locked', 'UNREAD_POSTS_LOCKED'), - 'FOLDER_STICKY_IMG' => $user->img('sticky_read', 'POST_STICKY'), - 'FOLDER_STICKY_UNREAD_IMG' => $user->img('sticky_unread', 'POST_STICKY'), - 'FOLDER_ANNOUNCE_IMG' => $user->img('announce_read', 'POST_ANNOUNCEMENT'), - 'FOLDER_ANNOUNCE_UNREAD_IMG'=> $user->img('announce_unread', 'POST_ANNOUNCEMENT'), - 'FOLDER_MOVED_IMG' => $user->img('topic_moved', 'TOPIC_MOVED'), - 'REPORTED_IMG' => $user->img('icon_topic_reported', 'TOPIC_REPORTED'), - 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'TOPIC_UNAPPROVED'), - 'DELETED_IMG' => $user->img('icon_topic_deleted', 'TOPIC_DELETED'), - 'POLL_IMG' => $user->img('icon_topic_poll', 'TOPIC_POLL'), - 'GOTO_PAGE_IMG' => $user->img('icon_post_target', 'GOTO_PAGE'), - - 'L_NO_TOPICS' => ($forum_data['forum_status'] == ITEM_LOCKED) ? $user->lang['POST_FORUM_LOCKED'] : $user->lang['NO_TOPICS'], - - 'S_DISPLAY_POST_INFO' => ($forum_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS)) ? true : false, - - 'S_IS_POSTABLE' => ($forum_data['forum_type'] == FORUM_POST) ? true : false, - 'S_USER_CAN_POST' => ($auth->acl_get('f_post', $forum_id)) ? true : false, - 'S_DISPLAY_ACTIVE' => $s_display_active, - 'S_SELECT_SORT_DIR' => $s_sort_dir, - 'S_SELECT_SORT_KEY' => $s_sort_key, - 'S_SELECT_SORT_DAYS' => $s_limit_days, - 'S_TOPIC_ICONS' => ($s_display_active && count($active_forum_ary)) ? max($active_forum_ary['enable_icons']) : (($forum_data['enable_icons']) ? true : false), - 'U_WATCH_FORUM_LINK' => $s_watching_forum['link'], - 'U_WATCH_FORUM_TOGGLE' => $s_watching_forum['link_toggle'], - 'S_WATCH_FORUM_TITLE' => $s_watching_forum['title'], - 'S_WATCH_FORUM_TOGGLE' => $s_watching_forum['title_toggle'], - 'S_WATCHING_FORUM' => $s_watching_forum['is_watching'], - 'S_FORUM_ACTION' => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . (($start == 0) ? '' : "&start=$start")), - 'S_DISPLAY_SEARCHBOX' => ($auth->acl_get('u_search') && $auth->acl_get('f_search', $forum_id) && $config['load_search']) ? true : false, - 'S_SEARCHBOX_ACTION' => append_sid("{$phpbb_root_path}search.$phpEx"), - 'S_SEARCH_LOCAL_HIDDEN_FIELDS' => build_hidden_fields($s_search_hidden_fields), - 'S_SINGLE_MODERATOR' => (!empty($moderators[$forum_id]) && count($moderators[$forum_id]) > 1) ? false : true, - 'S_IS_LOCKED' => ($forum_data['forum_status'] == ITEM_LOCKED) ? true : false, - 'S_VIEWFORUM' => true, - - 'U_MCP' => ($auth->acl_get('m_', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "f=$forum_id&i=main&mode=forum_view", true, $user->session_id) : '', - 'U_POST_NEW_TOPIC' => ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS) ? append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=post&f=' . $forum_id) : '', - 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . ((strlen($u_sort_param)) ? "&$u_sort_param" : '') . (($start == 0) ? '' : "&start=$start")), - 'U_CANONICAL' => generate_board_url() . '/' . append_sid("viewforum.$phpEx", "f=$forum_id" . (($start) ? "&start=$start" : ''), true, ''), - 'U_MARK_TOPICS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'hash=' . generate_link_hash('global') . "&f=$forum_id&mark=topics&mark_time=" . time()) : '', -)); - -// Grab icons -$icons = $cache->obtain_icons(); - -// Grab all topic data -$rowset = $announcement_list = $topic_list = $global_announce_forums = array(); - -$sql_array = array( - 'SELECT' => 't.*', - 'FROM' => array( - TOPICS_TABLE => 't' - ), - 'LEFT_JOIN' => array(), -); - -/** -* Event to modify the SQL query before the topic data is retrieved -* -* It may also be used to override the above assigned template vars -* -* @event core.viewforum_get_topic_data -* @var array forum_data Array with forum data -* @var array sql_array The SQL array to get the data of all topics -* @var int forum_id The forum_id whose topics are being listed -* @var int topics_count The total number of topics for display -* @var int sort_days The oldest topic displayable in elapsed days -* @var string sort_key The sorting by. It is one of the first character of (in low case): -* Author, Post time, Replies, Subject, Views -* @var string sort_dir Either "a" for ascending or "d" for descending -* @since 3.1.0-a1 -* @changed 3.1.0-RC4 Added forum_data var -* @changed 3.1.4-RC1 Added forum_id, topics_count, sort_days, sort_key and sort_dir vars -* @changed 3.1.9-RC1 Fix types of properties -*/ -$vars = array( - 'forum_data', - 'sql_array', - 'forum_id', - 'topics_count', - 'sort_days', - 'sort_key', - 'sort_dir', -); -extract($phpbb_dispatcher->trigger_event('core.viewforum_get_topic_data', compact($vars))); - -$sql_approved = ' AND ' . $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.'); - -if ($user->data['is_registered']) -{ - if ($config['load_db_track']) - { - $sql_array['LEFT_JOIN'][] = array('FROM' => array(TOPICS_POSTED_TABLE => 'tp'), 'ON' => 'tp.topic_id = t.topic_id AND tp.user_id = ' . $user->data['user_id']); - $sql_array['SELECT'] .= ', tp.topic_posted'; - } - - if ($config['load_db_lastread']) - { - $sql_array['LEFT_JOIN'][] = array('FROM' => array(TOPICS_TRACK_TABLE => 'tt'), 'ON' => 'tt.topic_id = t.topic_id AND tt.user_id = ' . $user->data['user_id']); - $sql_array['SELECT'] .= ', tt.mark_time'; - - if ($s_display_active && count($active_forum_ary)) - { - $sql_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TRACK_TABLE => 'ft'), 'ON' => 'ft.forum_id = t.forum_id AND ft.user_id = ' . $user->data['user_id']); - $sql_array['SELECT'] .= ', ft.mark_time AS forum_mark_time'; - } - } -} - -if ($forum_data['forum_type'] == FORUM_POST) -{ - // Get global announcement forums - $g_forum_ary = $auth->acl_getf('f_read', true); - $g_forum_ary = array_unique(array_keys($g_forum_ary)); - - $sql_anounce_array['LEFT_JOIN'] = $sql_array['LEFT_JOIN']; - $sql_anounce_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 'f.forum_id = t.forum_id'); - $sql_anounce_array['SELECT'] = $sql_array['SELECT'] . ', f.forum_name'; - - // Obtain announcements ... removed sort ordering, sort by time in all cases - $sql_ary = array( - 'SELECT' => $sql_anounce_array['SELECT'], - 'FROM' => $sql_array['FROM'], - 'LEFT_JOIN' => $sql_anounce_array['LEFT_JOIN'], - - 'WHERE' => '(t.forum_id = ' . $forum_id . ' - AND t.topic_type = ' . POST_ANNOUNCE . ') OR - (' . $db->sql_in_set('t.forum_id', $g_forum_ary, false, true) . ' - AND t.topic_type = ' . POST_GLOBAL . ')', - - 'ORDER_BY' => 't.topic_time DESC', - ); - - /** - * Event to modify the SQL query before the announcement topic ids data is retrieved - * - * @event core.viewforum_get_announcement_topic_ids_data - * @var array forum_data Data about the forum - * @var array g_forum_ary Global announcement forums array - * @var array sql_anounce_array SQL announcement array - * @var array sql_ary SQL query array to get the announcement topic ids data - * @var int forum_id The forum ID - * - * @since 3.1.10-RC1 - */ - $vars = array( - 'forum_data', - 'g_forum_ary', - 'sql_anounce_array', - 'sql_ary', - 'forum_id', - ); - extract($phpbb_dispatcher->trigger_event('core.viewforum_get_announcement_topic_ids_data', compact($vars))); - - $sql = $db->sql_build_query('SELECT', $sql_ary); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if (!$phpbb_content_visibility->is_visible('topic', $row['forum_id'], $row)) - { - // Do not display announcements that are waiting for approval or soft deleted. - continue; - } - - $rowset[$row['topic_id']] = $row; - $announcement_list[] = $row['topic_id']; - - if ($forum_id != $row['forum_id']) - { - $topics_count++; - $global_announce_forums[] = $row['forum_id']; - } - } - $db->sql_freeresult($result); -} - -$forum_tracking_info = array(); - -if ($user->data['is_registered'] && $config['load_db_lastread']) -{ - $forum_tracking_info[$forum_id] = $forum_data['mark_time']; - - if (!empty($global_announce_forums)) - { - $sql = 'SELECT forum_id, mark_time - FROM ' . FORUMS_TRACK_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $global_announce_forums) . ' - AND user_id = ' . $user->data['user_id']; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $forum_tracking_info[$row['forum_id']] = $row['mark_time']; - } - $db->sql_freeresult($result); - } -} - -// If the user is trying to reach late pages, start searching from the end -$store_reverse = false; -$sql_limit = $config['topics_per_page']; -if ($start > $topics_count / 2) -{ - $store_reverse = true; - - // Select the sort order - $direction = (($sort_dir == 'd') ? 'ASC' : 'DESC'); - - $sql_limit = $pagination->reverse_limit($start, $sql_limit, $topics_count - count($announcement_list)); - $sql_start = $pagination->reverse_start($start, $sql_limit, $topics_count - count($announcement_list)); -} -else -{ - // Select the sort order - $direction = (($sort_dir == 'd') ? 'DESC' : 'ASC'); - $sql_start = $start; -} - -/** - * Modify the topics sort ordering if needed - * - * @event core.viewforum_modify_sort_direction - * @var string direction Topics sort order - * @since 3.2.5-RC1 - */ -$vars = array( - 'direction', -); -extract($phpbb_dispatcher->trigger_event('core.viewforum_modify_sort_direction', compact($vars))); - -if (is_array($sort_by_sql[$sort_key])) -{ - $sql_sort_order = implode(' ' . $direction . ', ', $sort_by_sql[$sort_key]) . ' ' . $direction; -} -else -{ - $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . $direction; -} - -if ($forum_data['forum_type'] == FORUM_POST || !count($active_forum_ary)) -{ - $sql_where = 't.forum_id = ' . $forum_id; -} -else if (empty($active_forum_ary['exclude_forum_id'])) -{ - $sql_where = $db->sql_in_set('t.forum_id', $active_forum_ary['forum_id']); -} -else -{ - $get_forum_ids = array_diff($active_forum_ary['forum_id'], $active_forum_ary['exclude_forum_id']); - $sql_where = (count($get_forum_ids)) ? $db->sql_in_set('t.forum_id', $get_forum_ids) : 't.forum_id = ' . $forum_id; -} - -// Grab just the sorted topic ids -$sql_ary = array( - 'SELECT' => 't.topic_id', - 'FROM' => array( - TOPICS_TABLE => 't', - ), - 'WHERE' => "$sql_where - AND t.topic_type IN (" . POST_NORMAL . ', ' . POST_STICKY . ") - $sql_approved - $sql_limit_time", - 'ORDER_BY' => 't.topic_type ' . ((!$store_reverse) ? 'DESC' : 'ASC') . ', ' . $sql_sort_order, -); - -/** -* Event to modify the SQL query before the topic ids data is retrieved -* -* @event core.viewforum_get_topic_ids_data -* @var array forum_data Data about the forum -* @var array sql_ary SQL query array to get the topic ids data -* @var string sql_approved Topic visibility SQL string -* @var int sql_limit Number of records to select -* @var string sql_limit_time SQL string to limit topic_last_post_time data -* @var array sql_sort_order SQL sorting string -* @var int sql_start Offset point to start selection from -* @var string sql_where SQL WHERE clause string -* @var bool store_reverse Flag indicating if we select from the late pages -* -* @since 3.1.0-RC4 -* -* @changed 3.1.3 Added forum_data -*/ -$vars = array( - 'forum_data', - 'sql_ary', - 'sql_approved', - 'sql_limit', - 'sql_limit_time', - 'sql_sort_order', - 'sql_start', - 'sql_where', - 'store_reverse', -); -extract($phpbb_dispatcher->trigger_event('core.viewforum_get_topic_ids_data', compact($vars))); - -$sql = $db->sql_build_query('SELECT', $sql_ary); -$result = $db->sql_query_limit($sql, $sql_limit, $sql_start); - -while ($row = $db->sql_fetchrow($result)) -{ - $topic_list[] = (int) $row['topic_id']; -} -$db->sql_freeresult($result); - -// For storing shadow topics -$shadow_topic_list = array(); - -if (count($topic_list)) -{ - // SQL array for obtaining topics/stickies - $sql_array = array( - 'SELECT' => $sql_array['SELECT'], - 'FROM' => $sql_array['FROM'], - 'LEFT_JOIN' => $sql_array['LEFT_JOIN'], - - 'WHERE' => $db->sql_in_set('t.topic_id', $topic_list), - ); - - // If store_reverse, then first obtain topics, then stickies, else the other way around... - // Funnily enough you typically save one query if going from the last page to the middle (store_reverse) because - // the number of stickies are not known - $sql = $db->sql_build_query('SELECT', $sql_array); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if ($row['topic_status'] == ITEM_MOVED) - { - $shadow_topic_list[$row['topic_moved_id']] = $row['topic_id']; - } - - $rowset[$row['topic_id']] = $row; - } - $db->sql_freeresult($result); -} - -// If we have some shadow topics, update the rowset to reflect their topic information -if (count($shadow_topic_list)) -{ - // SQL array for obtaining shadow topics - $sql_array = array( - 'SELECT' => 't.*', - 'FROM' => array( - TOPICS_TABLE => 't' - ), - 'WHERE' => $db->sql_in_set('t.topic_id', array_keys($shadow_topic_list)), - ); - - /** - * Event to modify the SQL query before the shadowtopic data is retrieved - * - * @event core.viewforum_get_shadowtopic_data - * @var array sql_array SQL array to get the data of any shadowtopics - * @since 3.1.0-a1 - */ - $vars = array('sql_array'); - extract($phpbb_dispatcher->trigger_event('core.viewforum_get_shadowtopic_data', compact($vars))); - - $sql = $db->sql_build_query('SELECT', $sql_array); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $orig_topic_id = $shadow_topic_list[$row['topic_id']]; - - // If the shadow topic is already listed within the rowset (happens for active topics for example), then do not include it... - if (isset($rowset[$row['topic_id']])) - { - // We need to remove any trace regarding this topic. :) - unset($rowset[$orig_topic_id]); - unset($topic_list[array_search($orig_topic_id, $topic_list)]); - $topics_count--; - - continue; - } - - // Do not include those topics the user has no permission to access - if (!$auth->acl_gets('f_read', 'f_list_topics', $row['forum_id'])) - { - // We need to remove any trace regarding this topic. :) - unset($rowset[$orig_topic_id]); - unset($topic_list[array_search($orig_topic_id, $topic_list)]); - $topics_count--; - - continue; - } - - // We want to retain some values - $row = array_merge($row, array( - 'topic_moved_id' => $rowset[$orig_topic_id]['topic_moved_id'], - 'topic_status' => $rowset[$orig_topic_id]['topic_status'], - 'topic_type' => $rowset[$orig_topic_id]['topic_type'], - 'topic_title' => $rowset[$orig_topic_id]['topic_title'], - )); - - // Shadow topics are never reported - $row['topic_reported'] = 0; - - $rowset[$orig_topic_id] = $row; - } - $db->sql_freeresult($result); -} -unset($shadow_topic_list); - -// Ok, adjust topics count for active topics list -if ($s_display_active) -{ - $topics_count = 1; -} - -// We need to remove the global announcements from the forums total topic count, -// otherwise the number is different from the one on the forum list -$total_topic_count = $topics_count - count($announcement_list); - -$base_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . ((strlen($u_sort_param)) ? "&$u_sort_param" : '')); -$pagination->generate_template_pagination($base_url, 'pagination', 'start', $total_topic_count, $config['topics_per_page'], $start); - -$template->assign_vars(array( - 'TOTAL_TOPICS' => ($s_display_active) ? false : $user->lang('VIEW_FORUM_TOPICS', (int) $total_topic_count), -)); - -$topic_list = ($store_reverse) ? array_merge($announcement_list, array_reverse($topic_list)) : array_merge($announcement_list, $topic_list); -$topic_tracking_info = $tracking_topics = array(); - -/** -* Modify topics data before we display the viewforum page -* -* @event core.viewforum_modify_topics_data -* @var array topic_list Array with current viewforum page topic ids -* @var array rowset Array with topics data (in topic_id => topic_data format) -* @var int total_topic_count Forum's total topic count -* @var int forum_id Forum identifier -* @since 3.1.0-b3 -* @changed 3.1.11-RC1 Added forum_id -*/ -$vars = array('topic_list', 'rowset', 'total_topic_count', 'forum_id'); -extract($phpbb_dispatcher->trigger_event('core.viewforum_modify_topics_data', compact($vars))); - -// Okay, lets dump out the page ... -if (count($topic_list)) -{ - $mark_forum_read = true; - $mark_time_forum = 0; - - // Generate topic forum list... - $topic_forum_list = array(); - foreach ($rowset as $t_id => $row) - { - if (isset($forum_tracking_info[$row['forum_id']])) - { - $row['forum_mark_time'] = $forum_tracking_info[$row['forum_id']]; - } - - $topic_forum_list[$row['forum_id']]['forum_mark_time'] = ($config['load_db_lastread'] && $user->data['is_registered'] && isset($row['forum_mark_time'])) ? $row['forum_mark_time'] : 0; - $topic_forum_list[$row['forum_id']]['topics'][] = (int) $t_id; - } - - if ($config['load_db_lastread'] && $user->data['is_registered']) - { - foreach ($topic_forum_list as $f_id => $topic_row) - { - $topic_tracking_info += get_topic_tracking($f_id, $topic_row['topics'], $rowset, array($f_id => $topic_row['forum_mark_time'])); - } - } - else if ($config['load_anon_lastread'] || $user->data['is_registered']) - { - foreach ($topic_forum_list as $f_id => $topic_row) - { - $topic_tracking_info += get_complete_topic_tracking($f_id, $topic_row['topics']); - } - } - - unset($topic_forum_list); - - if (!$s_display_active) - { - if ($config['load_db_lastread'] && $user->data['is_registered']) - { - $mark_time_forum = (!empty($forum_data['mark_time'])) ? $forum_data['mark_time'] : $user->data['user_lastmark']; - } - else if ($config['load_anon_lastread'] || $user->data['is_registered']) - { - if (!$user->data['is_registered']) - { - $user->data['user_lastmark'] = (isset($tracking_topics['l'])) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0; - } - $mark_time_forum = (isset($tracking_topics['f'][$forum_id])) ? (int) (base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate']) : $user->data['user_lastmark']; - } - } - - $s_type_switch = 0; - foreach ($topic_list as $topic_id) - { - $row = &$rowset[$topic_id]; - - $topic_forum_id = ($row['forum_id']) ? (int) $row['forum_id'] : $forum_id; - - // This will allow the style designer to output a different header - // or even separate the list of announcements from sticky and normal topics - $s_type_switch_test = ($row['topic_type'] == POST_ANNOUNCE || $row['topic_type'] == POST_GLOBAL) ? 1 : 0; - - // Replies - $replies = $phpbb_content_visibility->get_count('topic_posts', $row, $topic_forum_id) - 1; - - if ($row['topic_status'] == ITEM_MOVED) - { - $topic_id = $row['topic_moved_id']; - $unread_topic = false; - } - else - { - $unread_topic = (isset($topic_tracking_info[$topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false; - } - - // Get folder img, topic status/type related information - $folder_img = $folder_alt = $topic_type = ''; - topic_status($row, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type); - - // Generate all the URIs ... - $view_topic_url_params = 'f=' . $row['forum_id'] . '&t=' . $topic_id; - $view_topic_url = $auth->acl_get('f_read', $forum_id) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params) : false; - - $topic_unapproved = (($row['topic_visibility'] == ITEM_UNAPPROVED || $row['topic_visibility'] == ITEM_REAPPROVE) && $auth->acl_get('m_approve', $row['forum_id'])); - $posts_unapproved = ($row['topic_visibility'] == ITEM_APPROVED && $row['topic_posts_unapproved'] && $auth->acl_get('m_approve', $row['forum_id'])); - $topic_deleted = $row['topic_visibility'] == ITEM_DELETED; - - $u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . "&t=$topic_id", true, $user->session_id) : ''; - $u_mcp_queue = (!$u_mcp_queue && $topic_deleted) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=deleted_topics&t=' . $topic_id, true, $user->session_id) : $u_mcp_queue; - - // Send vars to template - $topic_row = array( - 'FORUM_ID' => $row['forum_id'], - 'TOPIC_ID' => $topic_id, - 'TOPIC_AUTHOR' => get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), - 'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), - 'TOPIC_AUTHOR_FULL' => get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), - 'FIRST_POST_TIME' => $user->format_date($row['topic_time']), - 'LAST_POST_SUBJECT' => censor_text($row['topic_last_post_subject']), - 'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']), - 'LAST_VIEW_TIME' => $user->format_date($row['topic_last_view_time']), - 'LAST_POST_AUTHOR' => get_username_string('username', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), - 'LAST_POST_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), - 'LAST_POST_AUTHOR_FULL' => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), - - 'REPLIES' => $replies, - 'VIEWS' => $row['topic_views'], - 'TOPIC_TITLE' => censor_text($row['topic_title']), - 'TOPIC_TYPE' => $topic_type, - 'FORUM_NAME' => (isset($row['forum_name'])) ? $row['forum_name'] : $forum_data['forum_name'], - - 'TOPIC_IMG_STYLE' => $folder_img, - 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt), - 'TOPIC_FOLDER_IMG_ALT' => $user->lang[$folder_alt], - - 'TOPIC_ICON_IMG' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['img'] : '', - 'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['width'] : '', - 'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['height'] : '', - 'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['topic_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', - 'UNAPPROVED_IMG' => ($topic_unapproved || $posts_unapproved) ? $user->img('icon_topic_unapproved', ($topic_unapproved) ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '', - - 'S_TOPIC_TYPE' => $row['topic_type'], - 'S_USER_POSTED' => (isset($row['topic_posted']) && $row['topic_posted']) ? true : false, - 'S_UNREAD_TOPIC' => $unread_topic, - 'S_TOPIC_REPORTED' => (!empty($row['topic_reported']) && $auth->acl_get('m_report', $row['forum_id'])) ? true : false, - 'S_TOPIC_UNAPPROVED' => $topic_unapproved, - 'S_POSTS_UNAPPROVED' => $posts_unapproved, - 'S_TOPIC_DELETED' => $topic_deleted, - 'S_HAS_POLL' => ($row['poll_start']) ? true : false, - 'S_POST_ANNOUNCE' => ($row['topic_type'] == POST_ANNOUNCE) ? true : false, - 'S_POST_GLOBAL' => ($row['topic_type'] == POST_GLOBAL) ? true : false, - 'S_POST_STICKY' => ($row['topic_type'] == POST_STICKY) ? true : false, - 'S_TOPIC_LOCKED' => ($row['topic_status'] == ITEM_LOCKED) ? true : false, - 'S_TOPIC_MOVED' => ($row['topic_status'] == ITEM_MOVED) ? true : false, - - 'U_NEWEST_POST' => $auth->acl_get('f_read', $forum_id) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params . '&view=unread') . '#unread' : false, - 'U_LAST_POST' => $auth->acl_get('f_read', $forum_id) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params . '&p=' . $row['topic_last_post_id']) . '#p' . $row['topic_last_post_id'] : false, - 'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), - 'U_TOPIC_AUTHOR' => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), - 'U_VIEW_TOPIC' => $view_topic_url, - 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']), - 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=reports&f=' . $row['forum_id'] . '&t=' . $topic_id, true, $user->session_id), - 'U_MCP_QUEUE' => $u_mcp_queue, - - 'S_TOPIC_TYPE_SWITCH' => ($s_type_switch == $s_type_switch_test) ? -1 : $s_type_switch_test, - ); - - /** - * Modify the topic data before it is assigned to the template - * - * @event core.viewforum_modify_topicrow - * @var array row Array with topic data - * @var array topic_row Template array with topic data - * @var bool s_type_switch Flag indicating if the topic type is [global] announcement - * @var bool s_type_switch_test Flag indicating if the test topic type is [global] announcement - * @since 3.1.0-a1 - * - * @changed 3.1.10-RC1 Added s_type_switch, s_type_switch_test - */ - $vars = array('row', 'topic_row', 's_type_switch', 's_type_switch_test'); - extract($phpbb_dispatcher->trigger_event('core.viewforum_modify_topicrow', compact($vars))); - - $template->assign_block_vars('topicrow', $topic_row); - - $pagination->generate_template_pagination($view_topic_url, 'topicrow.pagination', 'start', $replies + 1, $config['posts_per_page'], 1, true, true); - - $s_type_switch = ($row['topic_type'] == POST_ANNOUNCE || $row['topic_type'] == POST_GLOBAL) ? 1 : 0; - - /** - * Event after the topic data has been assigned to the template - * - * @event core.viewforum_topic_row_after - * @var array row Array with the topic data - * @var array rowset Array with topics data (in topic_id => topic_data format) - * @var bool s_type_switch Flag indicating if the topic type is [global] announcement - * @var int topic_id The topic ID - * @var array topic_list Array with current viewforum page topic ids - * @var array topic_row Template array with topic data - * @since 3.1.3-RC1 - */ - $vars = array( - 'row', - 'rowset', - 's_type_switch', - 'topic_id', - 'topic_list', - 'topic_row', - ); - extract($phpbb_dispatcher->trigger_event('core.viewforum_topic_row_after', compact($vars))); - - if ($unread_topic) - { - $mark_forum_read = false; - } - - unset($rowset[$topic_id]); - } -} - -/** -* This event is to perform additional actions on viewforum page -* -* @event core.viewforum_generate_page_after -* @var array forum_data Array with the forum data -* @since 3.2.2-RC1 -*/ -$vars = array('forum_data'); -extract($phpbb_dispatcher->trigger_event('core.viewforum_generate_page_after', compact($vars))); - -// This is rather a fudge but it's the best I can think of without requiring information -// on all topics (as we do in 2.0.x). It looks for unread or new topics, if it doesn't find -// any it updates the forum last read cookie. This requires that the user visit the forum -// after reading a topic -if ($forum_data['forum_type'] == FORUM_POST && count($topic_list) && $mark_forum_read) -{ - update_forum_tracking_info($forum_id, $forum_data['forum_last_post_time'], false, $mark_time_forum); -} - -page_footer(); diff --git a/install/update/old/viewonline.php b/install/update/old/viewonline.php deleted file mode 100644 index d5ddb0b..0000000 --- a/install/update/old/viewonline.php +++ /dev/null @@ -1,517 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -define('IN_PHPBB', true); -$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); -include($phpbb_root_path . 'common.' . $phpEx); - -// Start session management -$user->session_begin(); -$auth->acl($user->data); -$user->setup('memberlist'); - -// Get and set some variables -$mode = $request->variable('mode', ''); -$session_id = $request->variable('s', ''); -$start = $request->variable('start', 0); -$sort_key = $request->variable('sk', 'b'); -$sort_dir = $request->variable('sd', 'd'); -$show_guests = ($config['load_online_guests']) ? $request->variable('sg', 0) : 0; - -// Can this user view profiles/memberlist? -if (!$auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel')) -{ - if ($user->data['user_id'] != ANONYMOUS) - { - send_status_line(403, 'Forbidden'); - trigger_error('NO_VIEW_USERS'); - } - - login_box('', $user->lang['LOGIN_EXPLAIN_VIEWONLINE']); -} - -/* @var $pagination \phpbb\pagination */ -$pagination = $phpbb_container->get('pagination'); - -/* @var $viewonline_helper \phpbb\viewonline_helper */ -$viewonline_helper = $phpbb_container->get('viewonline_helper'); - -$sort_key_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_JOINED'], 'c' => $user->lang['SORT_LOCATION']); -$sort_key_sql = array('a' => 'u.username_clean', 'b' => 's.session_time', 'c' => 's.session_page'); - -// Sorting and order -if (!isset($sort_key_text[$sort_key])) -{ - $sort_key = 'b'; -} - -$order_by = $sort_key_sql[$sort_key] . ' ' . (($sort_dir == 'a') ? 'ASC' : 'DESC'); - -// Whois requested -if ($mode == 'whois' && $auth->acl_get('a_') && $session_id) -{ - if (!function_exists('user_get_id_name')) - { - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - } - - $sql = 'SELECT u.user_id, u.username, u.user_type, s.session_ip - FROM ' . USERS_TABLE . ' u, ' . SESSIONS_TABLE . " s - WHERE s.session_id = '" . $db->sql_escape($session_id) . "' - AND u.user_id = s.session_user_id"; - $result = $db->sql_query($sql); - - if ($row = $db->sql_fetchrow($result)) - { - $template->assign_var('WHOIS', user_ipwhois($row['session_ip'])); - } - $db->sql_freeresult($result); - - // Output the page - page_header($user->lang['WHO_IS_ONLINE']); - - $template->set_filenames(array( - 'body' => 'viewonline_whois.html') - ); - make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx")); - - page_footer(); -} - -$user->update_session_infos(); - -// Forum info -$sql_ary = array( - 'SELECT' => 'f.forum_id, f.forum_name, f.parent_id, f.forum_type, f.left_id, f.right_id', - 'FROM' => array( - FORUMS_TABLE => 'f', - ), - 'ORDER_BY' => 'f.left_id ASC', -); - -/** -* Modify the forum data SQL query for getting additional fields if needed -* -* @event core.viewonline_modify_forum_data_sql -* @var array sql_ary The SQL array -* @since 3.1.5-RC1 -*/ -$vars = array('sql_ary'); -extract($phpbb_dispatcher->trigger_event('core.viewonline_modify_forum_data_sql', compact($vars))); - -$result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary), 600); -unset($sql_ary); - -$forum_data = array(); -while ($row = $db->sql_fetchrow($result)) -{ - $forum_data[$row['forum_id']] = $row; -} -$db->sql_freeresult($result); - -$guest_counter = 0; - -// Get number of online guests (if we do not display them) -if (!$show_guests) -{ - switch ($db->get_sql_layer()) - { - case 'sqlite3': - $sql = 'SELECT COUNT(session_ip) as num_guests - FROM ( - SELECT DISTINCT session_ip - FROM ' . SESSIONS_TABLE . ' - WHERE session_user_id = ' . ANONYMOUS . ' - AND session_time >= ' . (time() - ($config['load_online_time'] * 60)) . - ')'; - break; - - default: - $sql = 'SELECT COUNT(DISTINCT session_ip) as num_guests - FROM ' . SESSIONS_TABLE . ' - WHERE session_user_id = ' . ANONYMOUS . ' - AND session_time >= ' . (time() - ($config['load_online_time'] * 60)); - break; - } - $result = $db->sql_query($sql); - $guest_counter = (int) $db->sql_fetchfield('num_guests'); - $db->sql_freeresult($result); -} - -// Get user list -$sql_ary = array( - 'SELECT' => 'u.user_id, u.username, u.username_clean, u.user_type, u.user_colour, s.session_id, s.session_time, s.session_page, s.session_ip, s.session_browser, s.session_viewonline, s.session_forum_id', - 'FROM' => array( - USERS_TABLE => 'u', - SESSIONS_TABLE => 's', - ), - 'WHERE' => 'u.user_id = s.session_user_id - AND s.session_time >= ' . (time() - ($config['load_online_time'] * 60)) . - ((!$show_guests) ? ' AND s.session_user_id <> ' . ANONYMOUS : ''), - 'ORDER_BY' => $order_by, -); - -/** -* Modify the SQL query for getting the user data to display viewonline list -* -* @event core.viewonline_modify_sql -* @var array sql_ary The SQL array -* @var bool show_guests Do we display guests in the list -* @var int guest_counter Number of guests displayed -* @var array forum_data Array with forum data -* @since 3.1.0-a1 -* @changed 3.1.0-a2 Added vars guest_counter and forum_data -*/ -$vars = array('sql_ary', 'show_guests', 'guest_counter', 'forum_data'); -extract($phpbb_dispatcher->trigger_event('core.viewonline_modify_sql', compact($vars))); - -$result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary)); - -$prev_id = $prev_ip = $user_list = array(); -$logged_visible_online = $logged_hidden_online = $counter = 0; - -/** @var \phpbb\controller\helper $controller_helper */ -$controller_helper = $phpbb_container->get('controller.helper'); - -/** @var \phpbb\group\helper $group_helper */ -$group_helper = $phpbb_container->get('group_helper'); - -while ($row = $db->sql_fetchrow($result)) -{ - if ($row['user_id'] != ANONYMOUS && !isset($prev_id[$row['user_id']])) - { - $view_online = $s_user_hidden = false; - $user_colour = ($row['user_colour']) ? ' style="color:#' . $row['user_colour'] . '" class="username-coloured"' : ''; - - $username_full = ($row['user_type'] != USER_IGNORE) ? get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']) : '' . $row['username'] . ''; - - if (!$row['session_viewonline']) - { - $view_online = ($auth->acl_get('u_viewonline') || $row['user_id'] === $user->data['user_id']) ? true : false; - $logged_hidden_online++; - - $username_full = '' . $username_full . ''; - $s_user_hidden = true; - } - else - { - $view_online = true; - $logged_visible_online++; - } - - $prev_id[$row['user_id']] = 1; - - if ($view_online) - { - $counter++; - } - - if (!$view_online || $counter > $start + $config['topics_per_page'] || $counter <= $start) - { - continue; - } - } - else if ($show_guests && $row['user_id'] == ANONYMOUS && !isset($prev_ip[$row['session_ip']])) - { - $prev_ip[$row['session_ip']] = 1; - $guest_counter++; - $counter++; - - if ($counter > $start + $config['topics_per_page'] || $counter <= $start) - { - continue; - } - - $s_user_hidden = false; - $username_full = get_username_string('full', $row['user_id'], $user->lang['GUEST']); - } - else - { - continue; - } - - $on_page = $viewonline_helper->get_user_page($row['session_page']); - - switch ($on_page[1]) - { - case 'index': - $location = $user->lang['INDEX']; - $location_url = append_sid("{$phpbb_root_path}index.$phpEx"); - break; - - case $phpbb_adm_relative_path . 'index': - $location = $user->lang['ACP']; - $location_url = append_sid("{$phpbb_root_path}index.$phpEx"); - break; - - case 'posting': - case 'viewforum': - case 'viewtopic': - $forum_id = $row['session_forum_id']; - - if ($forum_id && $auth->acl_get('f_list', $forum_id)) - { - $location = ''; - $location_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id); - - if ($forum_data[$forum_id]['forum_type'] == FORUM_LINK) - { - $location = sprintf($user->lang['READING_LINK'], $forum_data[$forum_id]['forum_name']); - break; - } - - switch ($on_page[1]) - { - case 'posting': - preg_match('#mode=([a-z]+)#', $row['session_page'], $on_page); - $posting_mode = (!empty($on_page[1])) ? $on_page[1] : ''; - - switch ($posting_mode) - { - case 'reply': - case 'quote': - $location = sprintf($user->lang['REPLYING_MESSAGE'], $forum_data[$forum_id]['forum_name']); - break; - - default: - $location = sprintf($user->lang['POSTING_MESSAGE'], $forum_data[$forum_id]['forum_name']); - break; - } - break; - - case 'viewtopic': - $location = sprintf($user->lang['READING_TOPIC'], $forum_data[$forum_id]['forum_name']); - break; - - case 'viewforum': - $location = sprintf($user->lang['READING_FORUM'], $forum_data[$forum_id]['forum_name']); - break; - } - } - else - { - $location = $user->lang['INDEX']; - $location_url = append_sid("{$phpbb_root_path}index.$phpEx"); - } - break; - - case 'search': - $location = $user->lang['SEARCHING_FORUMS']; - $location_url = append_sid("{$phpbb_root_path}search.$phpEx"); - break; - - case 'viewonline': - $location = $user->lang['VIEWING_ONLINE']; - $location_url = append_sid("{$phpbb_root_path}viewonline.$phpEx"); - break; - - case 'memberlist': - $location_url = append_sid("{$phpbb_root_path}memberlist.$phpEx"); - - if (strpos($row['session_page'], 'mode=viewprofile') !== false) - { - $location = $user->lang['VIEWING_MEMBER_PROFILE']; - } - else if (strpos($row['session_page'], 'mode=contactadmin') !== false) - { - $location = $user->lang['VIEWING_CONTACT_ADMIN']; - $location_url = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contactadmin'); - } - else - { - $location = $user->lang['VIEWING_MEMBERS']; - } - break; - - case 'mcp': - $location = $user->lang['VIEWING_MCP']; - $location_url = append_sid("{$phpbb_root_path}index.$phpEx"); - break; - - case 'ucp': - $location = $user->lang['VIEWING_UCP']; - - // Grab some common modules - $url_params = array( - 'mode=register' => 'VIEWING_REGISTER', - 'i=pm&mode=compose' => 'POSTING_PRIVATE_MESSAGE', - 'i=pm&' => 'VIEWING_PRIVATE_MESSAGES', - 'i=profile&' => 'CHANGING_PROFILE', - 'i=prefs&' => 'CHANGING_PREFERENCES', - ); - - foreach ($url_params as $param => $lang) - { - if (strpos($row['session_page'], $param) !== false) - { - $location = $user->lang[$lang]; - break; - } - } - - $location_url = append_sid("{$phpbb_root_path}index.$phpEx"); - break; - - case 'download/file': - $location = $user->lang['DOWNLOADING_FILE']; - $location_url = append_sid("{$phpbb_root_path}index.$phpEx"); - break; - - case 'report': - $location = $user->lang['REPORTING_POST']; - $location_url = append_sid("{$phpbb_root_path}index.$phpEx"); - break; - - default: - $location = $user->lang['INDEX']; - $location_url = append_sid("{$phpbb_root_path}index.$phpEx"); - - if ($row['session_page'] === 'app.' . $phpEx . '/help/faq' || - $row['session_page'] === 'app.' . $phpEx . '/help/bbcode') - { - $location = $user->lang['VIEWING_FAQ']; - $location_url = $controller_helper->route('phpbb_help_faq_controller'); - } - break; - } - - /** - * Overwrite the location's name and URL, which are displayed in the list - * - * @event core.viewonline_overwrite_location - * @var array on_page File name and query string - * @var array row Array with the users sql row - * @var string location Page name to displayed in the list - * @var string location_url Page url to displayed in the list - * @var array forum_data Array with forum data - * @since 3.1.0-a1 - * @changed 3.1.0-a2 Added var forum_data - */ - $vars = array('on_page', 'row', 'location', 'location_url', 'forum_data'); - extract($phpbb_dispatcher->trigger_event('core.viewonline_overwrite_location', compact($vars))); - - $template_row = array( - 'USERNAME' => $row['username'], - 'USERNAME_COLOUR' => $row['user_colour'], - 'USERNAME_FULL' => $username_full, - 'LASTUPDATE' => $user->format_date($row['session_time']), - 'FORUM_LOCATION' => $location, - 'USER_IP' => ($auth->acl_get('a_')) ? (($mode == 'lookup' && $session_id == $row['session_id']) ? gethostbyaddr($row['session_ip']) : $row['session_ip']) : '', - 'USER_BROWSER' => ($auth->acl_get('a_user')) ? $row['session_browser'] : '', - - 'U_USER_PROFILE' => ($row['user_type'] != USER_IGNORE) ? get_username_string('profile', $row['user_id'], '') : '', - 'U_USER_IP' => append_sid("{$phpbb_root_path}viewonline.$phpEx", 'mode=lookup' . (($mode != 'lookup' || $row['session_id'] != $session_id) ? '&s=' . $row['session_id'] : '') . "&sg=$show_guests&start=$start&sk=$sort_key&sd=$sort_dir"), - 'U_WHOIS' => append_sid("{$phpbb_root_path}viewonline.$phpEx", 'mode=whois&s=' . $row['session_id']), - 'U_FORUM_LOCATION' => $location_url, - - 'S_USER_HIDDEN' => $s_user_hidden, - 'S_GUEST' => ($row['user_id'] == ANONYMOUS) ? true : false, - 'S_USER_TYPE' => $row['user_type'], - ); - - /** - * Modify viewonline template data before it is displayed in the list - * - * @event core.viewonline_modify_user_row - * @var array on_page File name and query string - * @var array row Array with the users sql row - * @var array forum_data Array with forum data - * @var array template_row Array with template variables for the user row - * @since 3.1.0-RC4 - */ - $vars = array('on_page', 'row', 'forum_data', 'template_row'); - extract($phpbb_dispatcher->trigger_event('core.viewonline_modify_user_row', compact($vars))); - - $template->assign_block_vars('user_row', $template_row); -} -$db->sql_freeresult($result); -unset($prev_id, $prev_ip); - -$order_legend = ($config['legend_sort_groupname']) ? 'group_name' : 'group_legend'; -// Grab group details for legend display -if ($auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) -{ - $sql = 'SELECT group_id, group_name, group_colour, group_type, group_legend - FROM ' . GROUPS_TABLE . ' - WHERE group_legend > 0 - ORDER BY ' . $order_legend . ' ASC'; -} -else -{ - $sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type, g.group_legend - FROM ' . GROUPS_TABLE . ' g - LEFT JOIN ' . USER_GROUP_TABLE . ' ug - ON ( - g.group_id = ug.group_id - AND ug.user_id = ' . $user->data['user_id'] . ' - AND ug.user_pending = 0 - ) - WHERE g.group_legend > 0 - AND (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $user->data['user_id'] . ') - ORDER BY g.' . $order_legend . ' ASC'; -} -$result = $db->sql_query($sql); - -$legend = ''; -while ($row = $db->sql_fetchrow($result)) -{ - if ($row['group_name'] == 'BOTS') - { - $legend .= (($legend != '') ? ', ' : '') . '' . $user->lang['G_BOTS'] . ''; - } - else - { - $legend .= (($legend != '') ? ', ' : '') . '' . $group_helper->get_name($row['group_name']) . ''; - } -} -$db->sql_freeresult($result); - -// Refreshing the page every 60 seconds... -meta_refresh(60, append_sid("{$phpbb_root_path}viewonline.$phpEx", "sg=$show_guests&sk=$sort_key&sd=$sort_dir&start=$start")); - -$start = $pagination->validate_start($start, $config['topics_per_page'], $counter); -$base_url = append_sid("{$phpbb_root_path}viewonline.$phpEx", "sg=$show_guests&sk=$sort_key&sd=$sort_dir"); -$pagination->generate_template_pagination($base_url, 'pagination', 'start', $counter, $config['topics_per_page'], $start); - -// Send data to template -$template->assign_vars(array( - 'TOTAL_REGISTERED_USERS_ONLINE' => $user->lang('REG_USERS_ONLINE', (int) $logged_visible_online, $user->lang('HIDDEN_USERS_ONLINE', (int) $logged_hidden_online)), - 'TOTAL_GUEST_USERS_ONLINE' => $user->lang('GUEST_USERS_ONLINE', (int) $guest_counter), - 'LEGEND' => $legend, - - 'U_SORT_USERNAME' => append_sid("{$phpbb_root_path}viewonline.$phpEx", 'sk=a&sd=' . (($sort_key == 'a' && $sort_dir == 'a') ? 'd' : 'a') . '&sg=' . ((int) $show_guests)), - 'U_SORT_UPDATED' => append_sid("{$phpbb_root_path}viewonline.$phpEx", 'sk=b&sd=' . (($sort_key == 'b' && $sort_dir == 'a') ? 'd' : 'a') . '&sg=' . ((int) $show_guests)), - 'U_SORT_LOCATION' => append_sid("{$phpbb_root_path}viewonline.$phpEx", 'sk=c&sd=' . (($sort_key == 'c' && $sort_dir == 'a') ? 'd' : 'a') . '&sg=' . ((int) $show_guests)), - - 'U_SWITCH_GUEST_DISPLAY' => append_sid("{$phpbb_root_path}viewonline.$phpEx", 'sg=' . ((int) !$show_guests)), - 'L_SWITCH_GUEST_DISPLAY' => ($show_guests) ? $user->lang['HIDE_GUESTS'] : $user->lang['DISPLAY_GUESTS'], - 'S_SWITCH_GUEST_DISPLAY' => ($config['load_online_guests']) ? true : false, - 'S_VIEWONLINE' => true, -)); - -// We do not need to load the who is online box here. ;) -$config['load_online'] = false; - -// Output the page -page_header($user->lang['WHO_IS_ONLINE']); - -$template->set_filenames(array( - 'body' => 'viewonline_body.html') -); -make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx")); - -page_footer(); diff --git a/install/update/old/viewtopic.php b/install/update/old/viewtopic.php deleted file mode 100644 index eb2d52c..0000000 --- a/install/update/old/viewtopic.php +++ /dev/null @@ -1,2380 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -define('IN_PHPBB', true); -$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); -include($phpbb_root_path . 'common.' . $phpEx); -include($phpbb_root_path . 'includes/functions_display.' . $phpEx); -include($phpbb_root_path . 'includes/bbcode.' . $phpEx); -include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - -// Start session management -$user->session_begin(); -$auth->acl($user->data); - -// Initial var setup -$forum_id = $request->variable('f', 0); -$topic_id = $request->variable('t', 0); -$post_id = $request->variable('p', 0); -$voted_id = $request->variable('vote_id', array('' => 0)); - -$voted_id = (count($voted_id) > 1) ? array_unique($voted_id) : $voted_id; - - -$start = $request->variable('start', 0); -$view = $request->variable('view', ''); - -$default_sort_days = (!empty($user->data['user_post_show_days'])) ? $user->data['user_post_show_days'] : 0; -$default_sort_key = (!empty($user->data['user_post_sortby_type'])) ? $user->data['user_post_sortby_type'] : 't'; -$default_sort_dir = (!empty($user->data['user_post_sortby_dir'])) ? $user->data['user_post_sortby_dir'] : 'a'; - -$sort_days = $request->variable('st', $default_sort_days); -$sort_key = $request->variable('sk', $default_sort_key); -$sort_dir = $request->variable('sd', $default_sort_dir); - -$update = $request->variable('update', false); - -/* @var $pagination \phpbb\pagination */ -$pagination = $phpbb_container->get('pagination'); - -$s_can_vote = false; -/** -* @todo normalize? -*/ -$hilit_words = $request->variable('hilit', '', true); - -// Do we have a topic or post id? -if (!$topic_id && !$post_id) -{ - trigger_error('NO_TOPIC'); -} - -/* @var $phpbb_content_visibility \phpbb\content_visibility */ -$phpbb_content_visibility = $phpbb_container->get('content.visibility'); - -// Find topic id if user requested a newer or older topic -if ($view && !$post_id) -{ - if (!$forum_id) - { - $sql = 'SELECT forum_id - FROM ' . TOPICS_TABLE . " - WHERE topic_id = $topic_id"; - $result = $db->sql_query($sql); - $forum_id = (int) $db->sql_fetchfield('forum_id'); - $db->sql_freeresult($result); - - if (!$forum_id) - { - trigger_error('NO_TOPIC'); - } - } - - if ($view == 'unread') - { - // Get topic tracking info - $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id); - $topic_last_read = (isset($topic_tracking_info[$topic_id])) ? $topic_tracking_info[$topic_id] : 0; - - $sql = 'SELECT post_id, topic_id, forum_id - FROM ' . POSTS_TABLE . " - WHERE topic_id = $topic_id - AND " . $phpbb_content_visibility->get_visibility_sql('post', $forum_id) . " - AND post_time > $topic_last_read - AND forum_id = $forum_id - ORDER BY post_time ASC, post_id ASC"; - $result = $db->sql_query_limit($sql, 1); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - $sql = 'SELECT topic_last_post_id as post_id, topic_id, forum_id - FROM ' . TOPICS_TABLE . ' - WHERE topic_id = ' . $topic_id; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - } - - if (!$row) - { - // Setup user environment so we can process lang string - $user->setup('viewtopic'); - - trigger_error('NO_TOPIC'); - } - - $post_id = $row['post_id']; - $topic_id = $row['topic_id']; - } - else if ($view == 'next' || $view == 'previous') - { - $sql_condition = ($view == 'next') ? '>' : '<'; - $sql_ordering = ($view == 'next') ? 'ASC' : 'DESC'; - - $sql = 'SELECT forum_id, topic_last_post_time - FROM ' . TOPICS_TABLE . ' - WHERE topic_id = ' . $topic_id; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - $user->setup('viewtopic'); - // OK, the topic doesn't exist. This error message is not helpful, but technically correct. - trigger_error(($view == 'next') ? 'NO_NEWER_TOPICS' : 'NO_OLDER_TOPICS'); - } - else - { - $sql = 'SELECT topic_id, forum_id - FROM ' . TOPICS_TABLE . ' - WHERE forum_id = ' . $row['forum_id'] . " - AND topic_moved_id = 0 - AND topic_last_post_time $sql_condition {$row['topic_last_post_time']} - AND " . $phpbb_content_visibility->get_visibility_sql('topic', $row['forum_id']) . " - ORDER BY topic_last_post_time $sql_ordering, topic_last_post_id $sql_ordering"; - $result = $db->sql_query_limit($sql, 1); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - $sql = 'SELECT forum_style - FROM ' . FORUMS_TABLE . " - WHERE forum_id = $forum_id"; - $result = $db->sql_query($sql); - $forum_style = (int) $db->sql_fetchfield('forum_style'); - $db->sql_freeresult($result); - - $user->setup('viewtopic', $forum_style); - trigger_error(($view == 'next') ? 'NO_NEWER_TOPICS' : 'NO_OLDER_TOPICS'); - } - else - { - $topic_id = $row['topic_id']; - $forum_id = $row['forum_id']; - } - } - } - - if (isset($row) && $row['forum_id']) - { - $forum_id = $row['forum_id']; - } -} - -// This rather complex gaggle of code handles querying for topics but -// also allows for direct linking to a post (and the calculation of which -// page the post is on and the correct display of viewtopic) -$sql_array = array( - 'SELECT' => 't.*, f.*', - - 'FROM' => array(FORUMS_TABLE => 'f'), -); - -// The FROM-Order is quite important here, else t.* columns can not be correctly bound. -if ($post_id) -{ - $sql_array['SELECT'] .= ', p.post_visibility, p.post_time, p.post_id'; - $sql_array['FROM'][POSTS_TABLE] = 'p'; -} - -// Topics table need to be the last in the chain -$sql_array['FROM'][TOPICS_TABLE] = 't'; - -if ($user->data['is_registered']) -{ - $sql_array['SELECT'] .= ', tw.notify_status'; - $sql_array['LEFT_JOIN'] = array(); - - $sql_array['LEFT_JOIN'][] = array( - 'FROM' => array(TOPICS_WATCH_TABLE => 'tw'), - 'ON' => 'tw.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = tw.topic_id' - ); - - if ($config['allow_bookmarks']) - { - $sql_array['SELECT'] .= ', bm.topic_id as bookmarked'; - $sql_array['LEFT_JOIN'][] = array( - 'FROM' => array(BOOKMARKS_TABLE => 'bm'), - 'ON' => 'bm.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = bm.topic_id' - ); - } - - if ($config['load_db_lastread']) - { - $sql_array['SELECT'] .= ', tt.mark_time, ft.mark_time as forum_mark_time'; - - $sql_array['LEFT_JOIN'][] = array( - 'FROM' => array(TOPICS_TRACK_TABLE => 'tt'), - 'ON' => 'tt.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = tt.topic_id' - ); - - $sql_array['LEFT_JOIN'][] = array( - 'FROM' => array(FORUMS_TRACK_TABLE => 'ft'), - 'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND t.forum_id = ft.forum_id' - ); - } -} - -if (!$post_id) -{ - $sql_array['WHERE'] = "t.topic_id = $topic_id"; -} -else -{ - $sql_array['WHERE'] = "p.post_id = $post_id AND t.topic_id = p.topic_id"; -} - -$sql_array['WHERE'] .= ' AND f.forum_id = t.forum_id'; - -$sql = $db->sql_build_query('SELECT', $sql_array); -$result = $db->sql_query($sql); -$topic_data = $db->sql_fetchrow($result); -$db->sql_freeresult($result); - -// link to unapproved post or incorrect link -if (!$topic_data) -{ - // If post_id was submitted, we try at least to display the topic as a last resort... - if ($post_id && $topic_id) - { - redirect(append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t=$topic_id" . (($forum_id) ? "&f=$forum_id" : ''))); - } - - trigger_error('NO_TOPIC'); -} - -$forum_id = (int) $topic_data['forum_id']; - -/** - * Modify the forum ID to handle the correct display of viewtopic if needed - * - * @event core.viewtopic_modify_forum_id - * @var string forum_id forum ID - * @var array topic_data array of topic's data - * @since 3.2.5-RC1 - */ -$vars = array( - 'forum_id', - 'topic_data', -); -extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_forum_id', compact($vars))); - -// If the request is missing the f parameter, the forum id in the user session data is 0 at the moment. -// Let's fix that now so that the user can't hide from the forum's Who Is Online list. -$user->page['forum'] = $forum_id; - -// Now we know the forum_id and can check the permissions -if (!$phpbb_content_visibility->is_visible('topic', $forum_id, $topic_data)) -{ - trigger_error('NO_TOPIC'); -} - -// This is for determining where we are (page) -if ($post_id) -{ - // are we where we are supposed to be? - if (($topic_data['post_visibility'] == ITEM_UNAPPROVED || $topic_data['post_visibility'] == ITEM_REAPPROVE) && !$auth->acl_get('m_approve', $topic_data['forum_id'])) - { - // If post_id was submitted, we try at least to display the topic as a last resort... - if ($topic_id) - { - redirect(append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t=$topic_id" . (($forum_id) ? "&f=$forum_id" : ''))); - } - - trigger_error('NO_TOPIC'); - } - if ($post_id == $topic_data['topic_first_post_id'] || $post_id == $topic_data['topic_last_post_id']) - { - $check_sort = ($post_id == $topic_data['topic_first_post_id']) ? 'd' : 'a'; - - if ($sort_dir == $check_sort) - { - $topic_data['prev_posts'] = $phpbb_content_visibility->get_count('topic_posts', $topic_data, $forum_id) - 1; - } - else - { - $topic_data['prev_posts'] = 0; - } - } - else - { - $sql = 'SELECT COUNT(p.post_id) AS prev_posts - FROM ' . POSTS_TABLE . " p - WHERE p.topic_id = {$topic_data['topic_id']} - AND " . $phpbb_content_visibility->get_visibility_sql('post', $forum_id, 'p.'); - - if ($sort_dir == 'd') - { - $sql .= " AND (p.post_time > {$topic_data['post_time']} OR (p.post_time = {$topic_data['post_time']} AND p.post_id >= {$topic_data['post_id']}))"; - } - else - { - $sql .= " AND (p.post_time < {$topic_data['post_time']} OR (p.post_time = {$topic_data['post_time']} AND p.post_id <= {$topic_data['post_id']}))"; - } - - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $topic_data['prev_posts'] = $row['prev_posts'] - 1; - } -} - -$topic_id = (int) $topic_data['topic_id']; -$topic_replies = $phpbb_content_visibility->get_count('topic_posts', $topic_data, $forum_id) - 1; - -// Check sticky/announcement/global time limit -if (($topic_data['topic_type'] != POST_NORMAL) && $topic_data['topic_time_limit'] && ($topic_data['topic_time'] + $topic_data['topic_time_limit']) < time()) -{ - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_type = ' . POST_NORMAL . ', topic_time_limit = 0 - WHERE topic_id = ' . $topic_id; - $db->sql_query($sql); - - $topic_data['topic_type'] = POST_NORMAL; - $topic_data['topic_time_limit'] = 0; -} - -// Setup look and feel -$user->setup('viewtopic', $topic_data['forum_style']); - -if ($view == 'print' && !$auth->acl_get('f_print', $forum_id)) -{ - send_status_line(403, 'Forbidden'); - trigger_error('NO_AUTH_PRINT_TOPIC'); -} - -$overrides_f_read_check = false; -$overrides_forum_password_check = false; -$topic_tracking_info = isset($topic_tracking_info) ? $topic_tracking_info : null; - -/** -* Event to apply extra permissions and to override original phpBB's f_read permission and forum password check -* on viewtopic access -* -* @event core.viewtopic_before_f_read_check -* @var int forum_id The forum id from where the topic belongs -* @var int topic_id The id of the topic the user tries to access -* @var int post_id The id of the post the user tries to start viewing at. -* It may be 0 for none given. -* @var array topic_data All the information from the topic and forum tables for this topic -* It includes posts information if post_id is not 0 -* @var bool overrides_f_read_check Set true to remove f_read check afterwards -* @var bool overrides_forum_password_check Set true to remove forum_password check afterwards -* @var array topic_tracking_info Information upon calling get_topic_tracking() -* Set it to NULL to allow auto-filling later. -* Set it to an array to override original data. -* @since 3.1.3-RC1 -*/ -$vars = array( - 'forum_id', - 'topic_id', - 'post_id', - 'topic_data', - 'overrides_f_read_check', - 'overrides_forum_password_check', - 'topic_tracking_info', -); -extract($phpbb_dispatcher->trigger_event('core.viewtopic_before_f_read_check', compact($vars))); - -// Start auth check -if (!$overrides_f_read_check && !$auth->acl_get('f_read', $forum_id)) -{ - if ($user->data['user_id'] != ANONYMOUS) - { - send_status_line(403, 'Forbidden'); - trigger_error('SORRY_AUTH_READ'); - } - - login_box('', $user->lang['LOGIN_VIEWFORUM']); -} - -// Forum is passworded ... check whether access has been granted to this -// user this session, if not show login box -if (!$overrides_forum_password_check && $topic_data['forum_password']) -{ - login_forum_box($topic_data); -} - -// Redirect to login upon emailed notification links if user is not logged in. -if (isset($_GET['e']) && $user->data['user_id'] == ANONYMOUS) -{ - login_box(build_url('e') . '#unread', $user->lang['LOGIN_NOTIFY_TOPIC']); -} - -// What is start equal to? -if ($post_id) -{ - $start = floor(($topic_data['prev_posts']) / $config['posts_per_page']) * $config['posts_per_page']; -} - -// Get topic tracking info -if (!isset($topic_tracking_info)) -{ - $topic_tracking_info = array(); - - // Get topic tracking info - if ($config['load_db_lastread'] && $user->data['is_registered']) - { - $tmp_topic_data = array($topic_id => $topic_data); - $topic_tracking_info = get_topic_tracking($forum_id, $topic_id, $tmp_topic_data, array($forum_id => $topic_data['forum_mark_time'])); - unset($tmp_topic_data); - } - else if ($config['load_anon_lastread'] || $user->data['is_registered']) - { - $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id); - } -} - -// Post ordering options -$limit_days = array(0 => $user->lang['ALL_POSTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); - -$sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']); -$sort_by_sql = array('a' => array('u.username_clean', 'p.post_id'), 't' => array('p.post_time', 'p.post_id'), 's' => array('p.post_subject', 'p.post_id')); -$join_user_sql = array('a' => true, 't' => false, 's' => false); - -$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; - -gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param, $default_sort_days, $default_sort_key, $default_sort_dir); - -// Obtain correct post count and ordering SQL if user has -// requested anything different -if ($sort_days) -{ - $min_post_time = time() - ($sort_days * 86400); - - $sql = 'SELECT COUNT(post_id) AS num_posts - FROM ' . POSTS_TABLE . " - WHERE topic_id = $topic_id - AND post_time >= $min_post_time - AND " . $phpbb_content_visibility->get_visibility_sql('post', $forum_id); - $result = $db->sql_query($sql); - $total_posts = (int) $db->sql_fetchfield('num_posts'); - $db->sql_freeresult($result); - - $limit_posts_time = "AND p.post_time >= $min_post_time "; - - if (isset($_POST['sort'])) - { - $start = 0; - } -} -else -{ - $total_posts = $topic_replies + 1; - $limit_posts_time = ''; -} - -// Was a highlight request part of the URI? -$highlight_match = $highlight = ''; -if ($hilit_words) -{ - $highlight_match = phpbb_clean_search_string($hilit_words); - $highlight = urlencode($highlight_match); - $highlight_match = str_replace('\*', '\w+?', preg_quote($highlight_match, '#')); - $highlight_match = preg_replace('#(?<=^|\s)\\\\w\*\?(?=\s|$)#', '\w+?', $highlight_match); - $highlight_match = str_replace(' ', '|', $highlight_match); -} - -// Make sure $start is set to the last page if it exceeds the amount -$start = $pagination->validate_start($start, $config['posts_per_page'], $total_posts); - -// General Viewtopic URL for return links -$viewtopic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start") . ((strlen($u_sort_param)) ? "&$u_sort_param" : '') . (($highlight_match) ? "&hilit=$highlight" : '')); - -// Are we watching this topic? -$s_watching_topic = array( - 'link' => '', - 'link_toggle' => '', - 'title' => '', - 'title_toggle' => '', - 'is_watching' => false, -); - -if ($config['allow_topic_notify']) -{ - $notify_status = (isset($topic_data['notify_status'])) ? $topic_data['notify_status'] : null; - watch_topic_forum('topic', $s_watching_topic, $user->data['user_id'], $forum_id, $topic_id, $notify_status, $start, $topic_data['topic_title']); - - // Reset forum notification if forum notify is set - if ($config['allow_forum_notify'] && $auth->acl_get('f_subscribe', $forum_id)) - { - $s_watching_forum = $s_watching_topic; - watch_topic_forum('forum', $s_watching_forum, $user->data['user_id'], $forum_id, 0); - } -} - -/** -* Event to modify highlight. -* -* @event core.viewtopic_highlight_modify -* @var string highlight String to be highlighted -* @var string highlight_match Highlight string to be used in preg_replace -* @var array topic_data Topic data -* @var int start Pagination start -* @var int total_posts Number of posts -* @var string viewtopic_url Current viewtopic URL -* @since 3.1.11-RC1 -*/ -$vars = array( - 'highlight', - 'highlight_match', - 'topic_data', - 'start', - 'total_posts', - 'viewtopic_url', -); -extract($phpbb_dispatcher->trigger_event('core.viewtopic_highlight_modify', compact($vars))); - -// Bookmarks -if ($config['allow_bookmarks'] && $user->data['is_registered'] && $request->variable('bookmark', 0)) -{ - if (check_link_hash($request->variable('hash', ''), "topic_$topic_id")) - { - if (!$topic_data['bookmarked']) - { - $sql = 'INSERT INTO ' . BOOKMARKS_TABLE . ' ' . $db->sql_build_array('INSERT', array( - 'user_id' => $user->data['user_id'], - 'topic_id' => $topic_id, - )); - $db->sql_query($sql); - } - else - { - $sql = 'DELETE FROM ' . BOOKMARKS_TABLE . " - WHERE user_id = {$user->data['user_id']} - AND topic_id = $topic_id"; - $db->sql_query($sql); - } - $message = (($topic_data['bookmarked']) ? $user->lang['BOOKMARK_REMOVED'] : $user->lang['BOOKMARK_ADDED']); - - if (!$request->is_ajax()) - { - $message .= '

' . $user->lang('RETURN_TOPIC', '', ''); - } - } - else - { - $message = $user->lang['BOOKMARK_ERR']; - - if (!$request->is_ajax()) - { - $message .= '

' . $user->lang('RETURN_TOPIC', '', ''); - } - } - meta_refresh(3, $viewtopic_url); - - trigger_error($message); -} - -// Grab ranks -$ranks = $cache->obtain_ranks(); - -// Grab icons -$icons = $cache->obtain_icons(); - -// Grab extensions -$extensions = array(); -if ($topic_data['topic_attachment']) -{ - $extensions = $cache->obtain_attach_extensions($forum_id); -} - -// Forum rules listing -$s_forum_rules = ''; -gen_forum_auth_level('topic', $forum_id, $topic_data['forum_status']); - -// Quick mod tools -$allow_change_type = ($auth->acl_get('m_', $forum_id) || ($user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'])) ? true : false; - -$s_quickmod_action = append_sid( - "{$phpbb_root_path}mcp.$phpEx", - array( - 'f' => $forum_id, - 't' => $topic_id, - 'start' => $start, - 'quickmod' => 1, - 'redirect' => urlencode(str_replace('&', '&', $viewtopic_url)), - ), - true, - $user->session_id -); - -$quickmod_array = array( -// 'key' => array('LANG_KEY', $userHasPermissions), - - 'lock' => array('LOCK_TOPIC', ($topic_data['topic_status'] == ITEM_UNLOCKED) && ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster']))), - 'unlock' => array('UNLOCK_TOPIC', ($topic_data['topic_status'] != ITEM_UNLOCKED) && ($auth->acl_get('m_lock', $forum_id))), - 'delete_topic' => array('DELETE_TOPIC', ($auth->acl_get('m_delete', $forum_id) || (($topic_data['topic_visibility'] != ITEM_DELETED) && $auth->acl_get('m_softdelete', $forum_id)))), - 'restore_topic' => array('RESTORE_TOPIC', (($topic_data['topic_visibility'] == ITEM_DELETED) && $auth->acl_get('m_approve', $forum_id))), - 'move' => array('MOVE_TOPIC', $auth->acl_get('m_move', $forum_id) && $topic_data['topic_status'] != ITEM_MOVED), - 'split' => array('SPLIT_TOPIC', $auth->acl_get('m_split', $forum_id)), - 'merge' => array('MERGE_POSTS', $auth->acl_get('m_merge', $forum_id)), - 'merge_topic' => array('MERGE_TOPIC', $auth->acl_get('m_merge', $forum_id)), - 'fork' => array('FORK_TOPIC', $auth->acl_get('m_move', $forum_id)), - 'make_normal' => array('MAKE_NORMAL', ($allow_change_type && $auth->acl_gets('f_sticky', 'f_announce', 'f_announce_global', $forum_id) && $topic_data['topic_type'] != POST_NORMAL)), - 'make_sticky' => array('MAKE_STICKY', ($allow_change_type && $auth->acl_get('f_sticky', $forum_id) && $topic_data['topic_type'] != POST_STICKY)), - 'make_announce' => array('MAKE_ANNOUNCE', ($allow_change_type && $auth->acl_get('f_announce', $forum_id) && $topic_data['topic_type'] != POST_ANNOUNCE)), - 'make_global' => array('MAKE_GLOBAL', ($allow_change_type && $auth->acl_get('f_announce_global', $forum_id) && $topic_data['topic_type'] != POST_GLOBAL)), - 'topic_logs' => array('VIEW_TOPIC_LOGS', $auth->acl_get('m_', $forum_id)), -); - -/** -* Event to modify data in the quickmod_array before it gets sent to the -* phpbb_add_quickmod_option function. -* -* @event core.viewtopic_add_quickmod_option_before -* @var int forum_id Forum ID -* @var int post_id Post ID -* @var array quickmod_array Array with quick moderation options data -* @var array topic_data Array with topic data -* @var int topic_id Topic ID -* @var array topic_tracking_info Array with topic tracking data -* @var string viewtopic_url URL to the topic page -* @var bool allow_change_type Topic change permissions check -* @since 3.1.9-RC1 -*/ -$vars = array( - 'forum_id', - 'post_id', - 'quickmod_array', - 'topic_data', - 'topic_id', - 'topic_tracking_info', - 'viewtopic_url', - 'allow_change_type', -); -extract($phpbb_dispatcher->trigger_event('core.viewtopic_add_quickmod_option_before', compact($vars))); - -foreach ($quickmod_array as $option => $qm_ary) -{ - if (!empty($qm_ary[1])) - { - phpbb_add_quickmod_option($s_quickmod_action, $option, $qm_ary[0]); - } -} - -// Navigation links -generate_forum_nav($topic_data); - -// Forum Rules -generate_forum_rules($topic_data); - -// Moderators -$forum_moderators = array(); -if ($config['load_moderators']) -{ - get_moderators($forum_moderators, $forum_id); -} - -// This is only used for print view so ... -$server_path = (!$view) ? $phpbb_root_path : generate_board_url() . '/'; - -// Replace naughty words in title -$topic_data['topic_title'] = censor_text($topic_data['topic_title']); - -$s_search_hidden_fields = array( - 't' => $topic_id, - 'sf' => 'msgonly', -); -if ($_SID) -{ - $s_search_hidden_fields['sid'] = $_SID; -} - -if (!empty($_EXTRA_URL)) -{ - foreach ($_EXTRA_URL as $url_param) - { - $url_param = explode('=', $url_param, 2); - $s_search_hidden_fields[$url_param[0]] = $url_param[1]; - } -} - -// If we've got a hightlight set pass it on to pagination. -$base_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id" . ((strlen($u_sort_param)) ? "&$u_sort_param" : '') . (($highlight_match) ? "&hilit=$highlight" : '')); - -/** -* Event to modify data before template variables are being assigned -* -* @event core.viewtopic_assign_template_vars_before -* @var string base_url URL to be passed to generate pagination -* @var int forum_id Forum ID -* @var int post_id Post ID -* @var array quickmod_array Array with quick moderation options data -* @var int start Pagination information -* @var array topic_data Array with topic data -* @var int topic_id Topic ID -* @var array topic_tracking_info Array with topic tracking data -* @var int total_posts Topic total posts count -* @var string viewtopic_url URL to the topic page -* @since 3.1.0-RC4 -* @changed 3.1.2-RC1 Added viewtopic_url -*/ -$vars = array( - 'base_url', - 'forum_id', - 'post_id', - 'quickmod_array', - 'start', - 'topic_data', - 'topic_id', - 'topic_tracking_info', - 'total_posts', - 'viewtopic_url', -); -extract($phpbb_dispatcher->trigger_event('core.viewtopic_assign_template_vars_before', compact($vars))); - -$pagination->generate_template_pagination($base_url, 'pagination', 'start', $total_posts, $config['posts_per_page'], $start); - -// Send vars to template -$template->assign_vars(array( - 'FORUM_ID' => $forum_id, - 'FORUM_NAME' => $topic_data['forum_name'], - 'FORUM_DESC' => generate_text_for_display($topic_data['forum_desc'], $topic_data['forum_desc_uid'], $topic_data['forum_desc_bitfield'], $topic_data['forum_desc_options']), - 'TOPIC_ID' => $topic_id, - 'TOPIC_TITLE' => $topic_data['topic_title'], - 'TOPIC_POSTER' => $topic_data['topic_poster'], - - 'TOPIC_AUTHOR_FULL' => get_username_string('full', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']), - 'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']), - 'TOPIC_AUTHOR' => get_username_string('username', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']), - - 'TOTAL_POSTS' => $user->lang('VIEW_TOPIC_POSTS', (int) $total_posts), - 'U_MCP' => ($auth->acl_get('m_', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&mode=topic_view&f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start") . ((strlen($u_sort_param)) ? "&$u_sort_param" : ''), true, $user->session_id) : '', - 'MODERATORS' => (isset($forum_moderators[$forum_id]) && count($forum_moderators[$forum_id])) ? implode($user->lang['COMMA_SEPARATOR'], $forum_moderators[$forum_id]) : '', - - 'POST_IMG' => ($topic_data['forum_status'] == ITEM_LOCKED) ? $user->img('button_topic_locked', 'FORUM_LOCKED') : $user->img('button_topic_new', 'POST_NEW_TOPIC'), - 'QUOTE_IMG' => $user->img('icon_post_quote', 'REPLY_WITH_QUOTE'), - 'REPLY_IMG' => ($topic_data['forum_status'] == ITEM_LOCKED || $topic_data['topic_status'] == ITEM_LOCKED) ? $user->img('button_topic_locked', 'TOPIC_LOCKED') : $user->img('button_topic_reply', 'REPLY_TO_TOPIC'), - 'EDIT_IMG' => $user->img('icon_post_edit', 'EDIT_POST'), - 'DELETE_IMG' => $user->img('icon_post_delete', 'DELETE_POST'), - 'DELETED_IMG' => $user->img('icon_topic_deleted', 'POST_DELETED_RESTORE'), - 'INFO_IMG' => $user->img('icon_post_info', 'VIEW_INFO'), - 'PROFILE_IMG' => $user->img('icon_user_profile', 'READ_PROFILE'), - 'SEARCH_IMG' => $user->img('icon_user_search', 'SEARCH_USER_POSTS'), - 'PM_IMG' => $user->img('icon_contact_pm', 'SEND_PRIVATE_MESSAGE'), - 'EMAIL_IMG' => $user->img('icon_contact_email', 'SEND_EMAIL'), - 'JABBER_IMG' => $user->img('icon_contact_jabber', 'JABBER') , - 'REPORT_IMG' => $user->img('icon_post_report', 'REPORT_POST'), - 'REPORTED_IMG' => $user->img('icon_topic_reported', 'POST_REPORTED'), - 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'POST_UNAPPROVED'), - 'WARN_IMG' => $user->img('icon_user_warn', 'WARN_USER'), - - 'S_IS_LOCKED' => ($topic_data['topic_status'] == ITEM_UNLOCKED && $topic_data['forum_status'] == ITEM_UNLOCKED) ? false : true, - 'S_SELECT_SORT_DIR' => $s_sort_dir, - 'S_SELECT_SORT_KEY' => $s_sort_key, - 'S_SELECT_SORT_DAYS' => $s_limit_days, - 'S_SINGLE_MODERATOR' => (!empty($forum_moderators[$forum_id]) && count($forum_moderators[$forum_id]) > 1) ? false : true, - 'S_TOPIC_ACTION' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start")), - 'S_MOD_ACTION' => $s_quickmod_action, - - 'L_RETURN_TO_FORUM' => $user->lang('RETURN_TO', $topic_data['forum_name']), - 'S_VIEWTOPIC' => true, - 'S_UNREAD_VIEW' => $view == 'unread', - 'S_DISPLAY_SEARCHBOX' => ($auth->acl_get('u_search') && $auth->acl_get('f_search', $forum_id) && $config['load_search']) ? true : false, - 'S_SEARCHBOX_ACTION' => append_sid("{$phpbb_root_path}search.$phpEx"), - 'S_SEARCH_LOCAL_HIDDEN_FIELDS' => build_hidden_fields($s_search_hidden_fields), - - 'S_DISPLAY_POST_INFO' => ($topic_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS)) ? true : false, - 'S_DISPLAY_REPLY_INFO' => ($topic_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_reply', $forum_id) || $user->data['user_id'] == ANONYMOUS)) ? true : false, - 'S_ENABLE_FEEDS_TOPIC' => ($config['feed_topic'] && !phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $topic_data['forum_options'])) ? true : false, - - 'U_TOPIC' => "{$server_path}viewtopic.$phpEx?f=$forum_id&t=$topic_id", - 'U_FORUM' => $server_path, - 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start") . (strlen($u_sort_param) ? "&$u_sort_param" : '')), - 'U_CANONICAL' => generate_board_url() . '/' . append_sid("viewtopic.$phpEx", "t=$topic_id" . (($start) ? "&start=$start" : ''), true, ''), - 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id), - 'U_VIEW_OLDER_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&view=previous"), - 'U_VIEW_NEWER_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&view=next"), - 'U_PRINT_TOPIC' => ($auth->acl_get('f_print', $forum_id)) ? $viewtopic_url . '&view=print' : '', - 'U_EMAIL_TOPIC' => ($auth->acl_get('f_email', $forum_id) && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=email&t=$topic_id") : '', - - 'U_WATCH_TOPIC' => $s_watching_topic['link'], - 'U_WATCH_TOPIC_TOGGLE' => $s_watching_topic['link_toggle'], - 'S_WATCH_TOPIC_TITLE' => $s_watching_topic['title'], - 'S_WATCH_TOPIC_TOGGLE' => $s_watching_topic['title_toggle'], - 'S_WATCHING_TOPIC' => $s_watching_topic['is_watching'], - - 'U_BOOKMARK_TOPIC' => ($user->data['is_registered'] && $config['allow_bookmarks']) ? $viewtopic_url . '&bookmark=1&hash=' . generate_link_hash("topic_$topic_id") : '', - 'S_BOOKMARK_TOPIC' => ($user->data['is_registered'] && $config['allow_bookmarks'] && $topic_data['bookmarked']) ? $user->lang['BOOKMARK_TOPIC_REMOVE'] : $user->lang['BOOKMARK_TOPIC'], - 'S_BOOKMARK_TOGGLE' => (!$user->data['is_registered'] || !$config['allow_bookmarks'] || !$topic_data['bookmarked']) ? $user->lang['BOOKMARK_TOPIC_REMOVE'] : $user->lang['BOOKMARK_TOPIC'], - 'S_BOOKMARKED_TOPIC' => ($user->data['is_registered'] && $config['allow_bookmarks'] && $topic_data['bookmarked']) ? true : false, - - 'U_POST_NEW_TOPIC' => ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=post&f=$forum_id") : '', - 'U_POST_REPLY_TOPIC' => ($auth->acl_get('f_reply', $forum_id) || $user->data['user_id'] == ANONYMOUS) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=reply&f=$forum_id&t=$topic_id") : '', - 'U_BUMP_TOPIC' => (bump_topic_allowed($forum_id, $topic_data['topic_bumped'], $topic_data['topic_last_post_time'], $topic_data['topic_poster'], $topic_data['topic_last_poster_id'])) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=bump&f=$forum_id&t=$topic_id&hash=" . generate_link_hash("topic_$topic_id")) : '') -); - -// Does this topic contain a poll? -if (!empty($topic_data['poll_start'])) -{ - $sql = 'SELECT o.*, p.bbcode_bitfield, p.bbcode_uid - FROM ' . POLL_OPTIONS_TABLE . ' o, ' . POSTS_TABLE . " p - WHERE o.topic_id = $topic_id - AND p.post_id = {$topic_data['topic_first_post_id']} - AND p.topic_id = o.topic_id - ORDER BY o.poll_option_id"; - $result = $db->sql_query($sql); - - $poll_info = $vote_counts = array(); - while ($row = $db->sql_fetchrow($result)) - { - $poll_info[] = $row; - $option_id = (int) $row['poll_option_id']; - $vote_counts[$option_id] = (int) $row['poll_option_total']; - } - $db->sql_freeresult($result); - - $cur_voted_id = array(); - if ($user->data['is_registered']) - { - $sql = 'SELECT poll_option_id - FROM ' . POLL_VOTES_TABLE . ' - WHERE topic_id = ' . $topic_id . ' - AND vote_user_id = ' . $user->data['user_id']; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $cur_voted_id[] = $row['poll_option_id']; - } - $db->sql_freeresult($result); - } - else - { - // Cookie based guest tracking ... I don't like this but hum ho - // it's oft requested. This relies on "nice" users who don't feel - // the need to delete cookies to mess with results. - if ($request->is_set($config['cookie_name'] . '_poll_' . $topic_id, \phpbb\request\request_interface::COOKIE)) - { - $cur_voted_id = explode(',', $request->variable($config['cookie_name'] . '_poll_' . $topic_id, '', true, \phpbb\request\request_interface::COOKIE)); - $cur_voted_id = array_map('intval', $cur_voted_id); - } - } - - // Can not vote at all if no vote permission - $s_can_vote = ($auth->acl_get('f_vote', $forum_id) && - (($topic_data['poll_length'] != 0 && $topic_data['poll_start'] + $topic_data['poll_length'] > time()) || $topic_data['poll_length'] == 0) && - $topic_data['topic_status'] != ITEM_LOCKED && - $topic_data['forum_status'] != ITEM_LOCKED && - (!count($cur_voted_id) || - ($auth->acl_get('f_votechg', $forum_id) && $topic_data['poll_vote_change']))) ? true : false; - $s_display_results = (!$s_can_vote || ($s_can_vote && count($cur_voted_id)) || $view == 'viewpoll') ? true : false; - - /** - * Event to manipulate the poll data - * - * @event core.viewtopic_modify_poll_data - * @var array cur_voted_id Array with options' IDs current user has voted for - * @var int forum_id The topic's forum id - * @var array poll_info Array with the poll information - * @var bool s_can_vote Flag indicating if a user can vote - * @var bool s_display_results Flag indicating if results or poll options should be displayed - * @var int topic_id The id of the topic the user tries to access - * @var array topic_data All the information from the topic and forum tables for this topic - * @var string viewtopic_url URL to the topic page - * @var array vote_counts Array with the vote counts for every poll option - * @var array voted_id Array with updated options' IDs current user is voting for - * @since 3.1.5-RC1 - */ - $vars = array( - 'cur_voted_id', - 'forum_id', - 'poll_info', - 's_can_vote', - 's_display_results', - 'topic_id', - 'topic_data', - 'viewtopic_url', - 'vote_counts', - 'voted_id', - ); - extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_poll_data', compact($vars))); - - if ($update && $s_can_vote) - { - - if (!count($voted_id) || count($voted_id) > $topic_data['poll_max_options'] || in_array(VOTE_CONVERTED, $cur_voted_id) || !check_form_key('posting')) - { - $redirect_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start")); - - meta_refresh(5, $redirect_url); - if (!count($voted_id)) - { - $message = 'NO_VOTE_OPTION'; - } - else if (count($voted_id) > $topic_data['poll_max_options']) - { - $message = 'TOO_MANY_VOTE_OPTIONS'; - } - else if (in_array(VOTE_CONVERTED, $cur_voted_id)) - { - $message = 'VOTE_CONVERTED'; - } - else - { - $message = 'FORM_INVALID'; - } - - $message = $user->lang[$message] . '

' . sprintf($user->lang['RETURN_TOPIC'], '', ''); - trigger_error($message); - } - - foreach ($voted_id as $option) - { - if (in_array($option, $cur_voted_id)) - { - continue; - } - - $sql = 'UPDATE ' . POLL_OPTIONS_TABLE . ' - SET poll_option_total = poll_option_total + 1 - WHERE poll_option_id = ' . (int) $option . ' - AND topic_id = ' . (int) $topic_id; - $db->sql_query($sql); - - $vote_counts[$option]++; - - if ($user->data['is_registered']) - { - $sql_ary = array( - 'topic_id' => (int) $topic_id, - 'poll_option_id' => (int) $option, - 'vote_user_id' => (int) $user->data['user_id'], - 'vote_user_ip' => (string) $user->ip, - ); - - $sql = 'INSERT INTO ' . POLL_VOTES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); - $db->sql_query($sql); - } - } - - foreach ($cur_voted_id as $option) - { - if (!in_array($option, $voted_id)) - { - $sql = 'UPDATE ' . POLL_OPTIONS_TABLE . ' - SET poll_option_total = poll_option_total - 1 - WHERE poll_option_id = ' . (int) $option . ' - AND topic_id = ' . (int) $topic_id; - $db->sql_query($sql); - - $vote_counts[$option]--; - - if ($user->data['is_registered']) - { - $sql = 'DELETE FROM ' . POLL_VOTES_TABLE . ' - WHERE topic_id = ' . (int) $topic_id . ' - AND poll_option_id = ' . (int) $option . ' - AND vote_user_id = ' . (int) $user->data['user_id']; - $db->sql_query($sql); - } - } - } - - if ($user->data['user_id'] == ANONYMOUS && !$user->data['is_bot']) - { - $user->set_cookie('poll_' . $topic_id, implode(',', $voted_id), time() + 31536000); - } - - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET poll_last_vote = ' . time() . " - WHERE topic_id = $topic_id"; - //, topic_last_post_time = ' . time() . " -- for bumping topics with new votes, ignore for now - $db->sql_query($sql); - - $redirect_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start")); - $message = $user->lang['VOTE_SUBMITTED'] . '

' . sprintf($user->lang['RETURN_TOPIC'], '', ''); - - if ($request->is_ajax()) - { - // Filter out invalid options - $valid_user_votes = array_intersect(array_keys($vote_counts), $voted_id); - - $data = array( - 'NO_VOTES' => $user->lang['NO_VOTES'], - 'success' => true, - 'user_votes' => array_flip($valid_user_votes), - 'vote_counts' => $vote_counts, - 'total_votes' => array_sum($vote_counts), - 'can_vote' => !count($valid_user_votes) || ($auth->acl_get('f_votechg', $forum_id) && $topic_data['poll_vote_change']), - ); - - /** - * Event to manipulate the poll data sent by AJAX response - * - * @event core.viewtopic_modify_poll_ajax_data - * @var array data JSON response data - * @var array valid_user_votes Valid user votes - * @var array vote_counts Vote counts - * @var int forum_id Forum ID - * @var array topic_data Topic data - * @var array poll_info Array with the poll information - * @since 3.2.4-RC1 - */ - $vars = array( - 'data', - 'valid_user_votes', - 'vote_counts', - 'forum_id', - 'topic_data', - 'poll_info', - ); - extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_poll_ajax_data', compact($vars))); - - $json_response = new \phpbb\json_response(); - $json_response->send($data); - } - - meta_refresh(5, $redirect_url); - trigger_error($message); - } - - $poll_total = 0; - $poll_most = 0; - foreach ($poll_info as $poll_option) - { - $poll_total += $poll_option['poll_option_total']; - $poll_most = ($poll_option['poll_option_total'] >= $poll_most) ? $poll_option['poll_option_total'] : $poll_most; - } - - $parse_flags = ($poll_info[0]['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES; - - for ($i = 0, $size = count($poll_info); $i < $size; $i++) - { - $poll_info[$i]['poll_option_text'] = generate_text_for_display($poll_info[$i]['poll_option_text'], $poll_info[$i]['bbcode_uid'], $poll_option['bbcode_bitfield'], $parse_flags, true); - } - - $topic_data['poll_title'] = generate_text_for_display($topic_data['poll_title'], $poll_info[0]['bbcode_uid'], $poll_info[0]['bbcode_bitfield'], $parse_flags, true); - - $poll_template_data = $poll_options_template_data = array(); - foreach ($poll_info as $poll_option) - { - $option_pct = ($poll_total > 0) ? $poll_option['poll_option_total'] / $poll_total : 0; - $option_pct_txt = sprintf("%.1d%%", round($option_pct * 100)); - $option_pct_rel = ($poll_most > 0) ? $poll_option['poll_option_total'] / $poll_most : 0; - $option_pct_rel_txt = sprintf("%.1d%%", round($option_pct_rel * 100)); - $option_most_votes = ($poll_option['poll_option_total'] > 0 && $poll_option['poll_option_total'] == $poll_most) ? true : false; - - $poll_options_template_data[] = array( - 'POLL_OPTION_ID' => $poll_option['poll_option_id'], - 'POLL_OPTION_CAPTION' => $poll_option['poll_option_text'], - 'POLL_OPTION_RESULT' => $poll_option['poll_option_total'], - 'POLL_OPTION_PERCENT' => $option_pct_txt, - 'POLL_OPTION_PERCENT_REL' => $option_pct_rel_txt, - 'POLL_OPTION_PCT' => round($option_pct * 100), - 'POLL_OPTION_WIDTH' => round($option_pct * 250), - 'POLL_OPTION_VOTED' => (in_array($poll_option['poll_option_id'], $cur_voted_id)) ? true : false, - 'POLL_OPTION_MOST_VOTES' => $option_most_votes, - ); - } - - $poll_end = $topic_data['poll_length'] + $topic_data['poll_start']; - - $poll_template_data = array( - 'POLL_QUESTION' => $topic_data['poll_title'], - 'TOTAL_VOTES' => $poll_total, - 'POLL_LEFT_CAP_IMG' => $user->img('poll_left'), - 'POLL_RIGHT_CAP_IMG'=> $user->img('poll_right'), - - 'L_MAX_VOTES' => $user->lang('MAX_OPTIONS_SELECT', (int) $topic_data['poll_max_options']), - 'L_POLL_LENGTH' => ($topic_data['poll_length']) ? sprintf($user->lang[($poll_end > time()) ? 'POLL_RUN_TILL' : 'POLL_ENDED_AT'], $user->format_date($poll_end)) : '', - - 'S_HAS_POLL' => true, - 'S_CAN_VOTE' => $s_can_vote, - 'S_DISPLAY_RESULTS' => $s_display_results, - 'S_IS_MULTI_CHOICE' => ($topic_data['poll_max_options'] > 1) ? true : false, - 'S_POLL_ACTION' => $viewtopic_url, - - 'U_VIEW_RESULTS' => $viewtopic_url . '&view=viewpoll', - ); - - /** - * Event to add/modify poll template data - * - * @event core.viewtopic_modify_poll_template_data - * @var array cur_voted_id Array with options' IDs current user has voted for - * @var int poll_end The poll end time - * @var array poll_info Array with the poll information - * @var array poll_options_template_data Array with the poll options template data - * @var array poll_template_data Array with the common poll template data - * @var int poll_total Total poll votes count - * @var int poll_most Mostly voted option votes count - * @var array topic_data All the information from the topic and forum tables for this topic - * @var string viewtopic_url URL to the topic page - * @var array vote_counts Array with the vote counts for every poll option - * @var array voted_id Array with updated options' IDs current user is voting for - * @since 3.1.5-RC1 - */ - $vars = array( - 'cur_voted_id', - 'poll_end', - 'poll_info', - 'poll_options_template_data', - 'poll_template_data', - 'poll_total', - 'poll_most', - 'topic_data', - 'viewtopic_url', - 'vote_counts', - 'voted_id', - ); - extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_poll_template_data', compact($vars))); - - $template->assign_block_vars_array('poll_option', $poll_options_template_data); - - $template->assign_vars($poll_template_data); - - unset($poll_end, $poll_info, $poll_options_template_data, $poll_template_data, $voted_id); -} - -// If the user is trying to reach the second half of the topic, fetch it starting from the end -$store_reverse = false; -$sql_limit = $config['posts_per_page']; -$sql_sort_order = $direction = ''; - -if ($start > $total_posts / 2) -{ - $store_reverse = true; - - // Select the sort order - $direction = (($sort_dir == 'd') ? 'ASC' : 'DESC'); - - $sql_limit = $pagination->reverse_limit($start, $sql_limit, $total_posts); - $sql_start = $pagination->reverse_start($start, $sql_limit, $total_posts); -} -else -{ - // Select the sort order - $direction = (($sort_dir == 'd') ? 'DESC' : 'ASC'); - $sql_start = $start; -} - -if (is_array($sort_by_sql[$sort_key])) -{ - $sql_sort_order = implode(' ' . $direction . ', ', $sort_by_sql[$sort_key]) . ' ' . $direction; -} -else -{ - $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . $direction; -} - -// Container for user details, only process once -$post_list = $user_cache = $id_cache = $attachments = $attach_list = $rowset = $update_count = $post_edit_list = $post_delete_list = array(); -$has_unapproved_attachments = $has_approved_attachments = $display_notice = false; -$i = $i_total = 0; - -// Go ahead and pull all data for this topic -$sql = 'SELECT p.post_id - FROM ' . POSTS_TABLE . ' p' . (($join_user_sql[$sort_key]) ? ', ' . USERS_TABLE . ' u': '') . " - WHERE p.topic_id = $topic_id - AND " . $phpbb_content_visibility->get_visibility_sql('post', $forum_id, 'p.') . " - " . (($join_user_sql[$sort_key]) ? 'AND u.user_id = p.poster_id': '') . " - $limit_posts_time - ORDER BY $sql_sort_order"; - -/** -* Event to modify the SQL query that gets post_list -* -* @event core.viewtopic_modify_post_list_sql -* @var string sql The SQL query to generate the post_list -* @var int sql_limit The number of posts the query fetches -* @var int sql_start The index the query starts to fetch from -* @var string sort_key Key the posts are sorted by -* @var string sort_days Display posts of previous x days -* @var int forum_id Forum ID -* @since 3.2.4-RC1 -*/ -$vars = array( - 'sql', - 'sql_limit', - 'sql_start', - 'sort_key', - 'sort_days', - 'forum_id', -); -extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_post_list_sql', compact($vars))); - -$result = $db->sql_query_limit($sql, $sql_limit, $sql_start); - -$i = ($store_reverse) ? $sql_limit - 1 : 0; -while ($row = $db->sql_fetchrow($result)) -{ - $post_list[$i] = (int) $row['post_id']; - ($store_reverse) ? $i-- : $i++; -} -$db->sql_freeresult($result); - -if (!count($post_list)) -{ - if ($sort_days) - { - trigger_error('NO_POSTS_TIME_FRAME'); - } - else - { - trigger_error('NO_TOPIC'); - } -} - -// Holding maximum post time for marking topic read -// We need to grab it because we do reverse ordering sometimes -$max_post_time = 0; - -$sql_ary = array( - 'SELECT' => 'u.*, z.friend, z.foe, p.*', - - 'FROM' => array( - USERS_TABLE => 'u', - POSTS_TABLE => 'p', - ), - - 'LEFT_JOIN' => array( - array( - 'FROM' => array(ZEBRA_TABLE => 'z'), - 'ON' => 'z.user_id = ' . $user->data['user_id'] . ' AND z.zebra_id = p.poster_id', - ), - ), - - 'WHERE' => $db->sql_in_set('p.post_id', $post_list) . ' - AND u.user_id = p.poster_id', -); - -/** -* Event to modify the SQL query before the post and poster data is retrieved -* -* @event core.viewtopic_get_post_data -* @var int forum_id Forum ID -* @var int topic_id Topic ID -* @var array topic_data Array with topic data -* @var array post_list Array with post_ids we are going to retrieve -* @var int sort_days Display posts of previous x days -* @var string sort_key Key the posts are sorted by -* @var string sort_dir Direction the posts are sorted by -* @var int start Pagination information -* @var array sql_ary The SQL array to get the data of posts and posters -* @since 3.1.0-a1 -* @changed 3.1.0-a2 Added vars forum_id, topic_id, topic_data, post_list, sort_days, sort_key, sort_dir, start -*/ -$vars = array( - 'forum_id', - 'topic_id', - 'topic_data', - 'post_list', - 'sort_days', - 'sort_key', - 'sort_dir', - 'start', - 'sql_ary', -); -extract($phpbb_dispatcher->trigger_event('core.viewtopic_get_post_data', compact($vars))); - -$sql = $db->sql_build_query('SELECT', $sql_ary); -$result = $db->sql_query($sql); - -$now = $user->create_datetime(); -$now = phpbb_gmgetdate($now->getTimestamp() + $now->getOffset()); - -// Posts are stored in the $rowset array while $attach_list, $user_cache -// and the global bbcode_bitfield are built -while ($row = $db->sql_fetchrow($result)) -{ - // Set max_post_time - if ($row['post_time'] > $max_post_time) - { - $max_post_time = $row['post_time']; - } - - $poster_id = (int) $row['poster_id']; - - // Does post have an attachment? If so, add it to the list - if ($row['post_attachment'] && $config['allow_attachments']) - { - $attach_list[] = (int) $row['post_id']; - - if ($row['post_visibility'] == ITEM_UNAPPROVED || $row['post_visibility'] == ITEM_REAPPROVE) - { - $has_unapproved_attachments = true; - } - else if ($row['post_visibility'] == ITEM_APPROVED) - { - $has_approved_attachments = true; - } - } - - $rowset_data = array( - 'hide_post' => (($row['foe'] || $row['post_visibility'] == ITEM_DELETED) && ($view != 'show' || $post_id != $row['post_id'])) ? true : false, - - 'post_id' => $row['post_id'], - 'post_time' => $row['post_time'], - 'user_id' => $row['user_id'], - 'username' => $row['username'], - 'user_colour' => $row['user_colour'], - 'topic_id' => $row['topic_id'], - 'forum_id' => $row['forum_id'], - 'post_subject' => $row['post_subject'], - 'post_edit_count' => $row['post_edit_count'], - 'post_edit_time' => $row['post_edit_time'], - 'post_edit_reason' => $row['post_edit_reason'], - 'post_edit_user' => $row['post_edit_user'], - 'post_edit_locked' => $row['post_edit_locked'], - 'post_delete_time' => $row['post_delete_time'], - 'post_delete_reason'=> $row['post_delete_reason'], - 'post_delete_user' => $row['post_delete_user'], - - // Make sure the icon actually exists - 'icon_id' => (isset($icons[$row['icon_id']]['img'], $icons[$row['icon_id']]['height'], $icons[$row['icon_id']]['width'])) ? $row['icon_id'] : 0, - 'post_attachment' => $row['post_attachment'], - 'post_visibility' => $row['post_visibility'], - 'post_reported' => $row['post_reported'], - 'post_username' => $row['post_username'], - 'post_text' => $row['post_text'], - 'bbcode_uid' => $row['bbcode_uid'], - 'bbcode_bitfield' => $row['bbcode_bitfield'], - 'enable_smilies' => $row['enable_smilies'], - 'enable_sig' => $row['enable_sig'], - 'friend' => $row['friend'], - 'foe' => $row['foe'], - ); - - /** - * Modify the post rowset containing data to be displayed with posts - * - * @event core.viewtopic_post_rowset_data - * @var array rowset_data Array with the rowset data for this post - * @var array row Array with original user and post data - * @since 3.1.0-a1 - */ - $vars = array('rowset_data', 'row'); - extract($phpbb_dispatcher->trigger_event('core.viewtopic_post_rowset_data', compact($vars))); - - $rowset[$row['post_id']] = $rowset_data; - - // Cache various user specific data ... so we don't have to recompute - // this each time the same user appears on this page - if (!isset($user_cache[$poster_id])) - { - if ($poster_id == ANONYMOUS) - { - $user_cache_data = array( - 'user_type' => USER_IGNORE, - 'joined' => '', - 'posts' => '', - - 'sig' => '', - 'sig_bbcode_uid' => '', - 'sig_bbcode_bitfield' => '', - - 'online' => false, - 'avatar' => ($user->optionget('viewavatars')) ? phpbb_get_user_avatar($row) : '', - 'rank_title' => '', - 'rank_image' => '', - 'rank_image_src' => '', - 'pm' => '', - 'email' => '', - 'jabber' => '', - 'search' => '', - 'age' => '', - - 'username' => $row['username'], - 'user_colour' => $row['user_colour'], - 'contact_user' => '', - - 'warnings' => 0, - 'allow_pm' => 0, - ); - - /** - * Modify the guest user's data displayed with the posts - * - * @event core.viewtopic_cache_guest_data - * @var array user_cache_data Array with the user's data - * @var int poster_id Poster's user id - * @var array row Array with original user and post data - * @since 3.1.0-a1 - */ - $vars = array('user_cache_data', 'poster_id', 'row'); - extract($phpbb_dispatcher->trigger_event('core.viewtopic_cache_guest_data', compact($vars))); - - $user_cache[$poster_id] = $user_cache_data; - - $user_rank_data = phpbb_get_user_rank($row, false); - $user_cache[$poster_id]['rank_title'] = $user_rank_data['title']; - $user_cache[$poster_id]['rank_image'] = $user_rank_data['img']; - $user_cache[$poster_id]['rank_image_src'] = $user_rank_data['img_src']; - } - else - { - $user_sig = ''; - - // We add the signature to every posters entry because enable_sig is post dependent - if ($row['user_sig'] && $config['allow_sig'] && $user->optionget('viewsigs')) - { - $user_sig = $row['user_sig']; - } - - $id_cache[] = $poster_id; - - $user_cache_data = array( - 'user_type' => $row['user_type'], - 'user_inactive_reason' => $row['user_inactive_reason'], - - 'joined' => $user->format_date($row['user_regdate']), - 'posts' => $row['user_posts'], - 'warnings' => (isset($row['user_warnings'])) ? $row['user_warnings'] : 0, - - 'sig' => $user_sig, - 'sig_bbcode_uid' => (!empty($row['user_sig_bbcode_uid'])) ? $row['user_sig_bbcode_uid'] : '', - 'sig_bbcode_bitfield' => (!empty($row['user_sig_bbcode_bitfield'])) ? $row['user_sig_bbcode_bitfield'] : '', - - 'viewonline' => $row['user_allow_viewonline'], - 'allow_pm' => $row['user_allow_pm'], - - 'avatar' => ($user->optionget('viewavatars')) ? phpbb_get_user_avatar($row) : '', - 'age' => '', - - 'rank_title' => '', - 'rank_image' => '', - 'rank_image_src' => '', - - 'username' => $row['username'], - 'user_colour' => $row['user_colour'], - 'contact_user' => $user->lang('CONTACT_USER', get_username_string('username', $poster_id, $row['username'], $row['user_colour'], $row['username'])), - - 'online' => false, - 'jabber' => ($config['jab_enable'] && $row['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&action=jabber&u=$poster_id") : '', - 'search' => ($config['load_search'] && $auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id=$poster_id&sr=posts") : '', - - 'author_full' => get_username_string('full', $poster_id, $row['username'], $row['user_colour']), - 'author_colour' => get_username_string('colour', $poster_id, $row['username'], $row['user_colour']), - 'author_username' => get_username_string('username', $poster_id, $row['username'], $row['user_colour']), - 'author_profile' => get_username_string('profile', $poster_id, $row['username'], $row['user_colour']), - ); - - /** - * Modify the users' data displayed with their posts - * - * @event core.viewtopic_cache_user_data - * @var array user_cache_data Array with the user's data - * @var int poster_id Poster's user id - * @var array row Array with original user and post data - * @since 3.1.0-a1 - */ - $vars = array('user_cache_data', 'poster_id', 'row'); - extract($phpbb_dispatcher->trigger_event('core.viewtopic_cache_user_data', compact($vars))); - - $user_cache[$poster_id] = $user_cache_data; - - $user_rank_data = phpbb_get_user_rank($row, $row['user_posts']); - $user_cache[$poster_id]['rank_title'] = $user_rank_data['title']; - $user_cache[$poster_id]['rank_image'] = $user_rank_data['img']; - $user_cache[$poster_id]['rank_image_src'] = $user_rank_data['img_src']; - - if ((!empty($row['user_allow_viewemail']) && $auth->acl_get('u_sendemail')) || $auth->acl_get('a_email')) - { - $user_cache[$poster_id]['email'] = ($config['board_email_form'] && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=email&u=$poster_id") : (($config['board_hide_emails'] && !$auth->acl_get('a_email')) ? '' : 'mailto:' . $row['user_email']); - } - else - { - $user_cache[$poster_id]['email'] = ''; - } - - if ($config['allow_birthdays'] && !empty($row['user_birthday'])) - { - list($bday_day, $bday_month, $bday_year) = array_map('intval', explode('-', $row['user_birthday'])); - - if ($bday_year) - { - $diff = $now['mon'] - $bday_month; - if ($diff == 0) - { - $diff = ($now['mday'] - $bday_day < 0) ? 1 : 0; - } - else - { - $diff = ($diff < 0) ? 1 : 0; - } - - $user_cache[$poster_id]['age'] = (int) ($now['year'] - $bday_year - $diff); - } - } - } - } -} -$db->sql_freeresult($result); - -// Load custom profile fields -if ($config['load_cpf_viewtopic']) -{ - /* @var $cp \phpbb\profilefields\manager */ - $cp = $phpbb_container->get('profilefields.manager'); - - // Grab all profile fields from users in id cache for later use - similar to the poster cache - $profile_fields_tmp = $cp->grab_profile_fields_data($id_cache); - - // filter out fields not to be displayed on viewtopic. Yes, it's a hack, but this shouldn't break any MODs. - $profile_fields_cache = array(); - foreach ($profile_fields_tmp as $profile_user_id => $profile_fields) - { - $profile_fields_cache[$profile_user_id] = array(); - foreach ($profile_fields as $used_ident => $profile_field) - { - if ($profile_field['data']['field_show_on_vt']) - { - $profile_fields_cache[$profile_user_id][$used_ident] = $profile_field; - } - } - } - unset($profile_fields_tmp); -} - -// Generate online information for user -if ($config['load_onlinetrack'] && count($id_cache)) -{ - $sql = 'SELECT session_user_id, MAX(session_time) as online_time, MIN(session_viewonline) AS viewonline - FROM ' . SESSIONS_TABLE . ' - WHERE ' . $db->sql_in_set('session_user_id', $id_cache) . ' - GROUP BY session_user_id'; - $result = $db->sql_query($sql); - - $update_time = $config['load_online_time'] * 60; - while ($row = $db->sql_fetchrow($result)) - { - $user_cache[$row['session_user_id']]['online'] = (time() - $update_time < $row['online_time'] && (($row['viewonline']) || $auth->acl_get('u_viewonline'))) ? true : false; - } - $db->sql_freeresult($result); -} -unset($id_cache); - -// Pull attachment data -if (count($attach_list)) -{ - if ($auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id)) - { - $sql = 'SELECT * - FROM ' . ATTACHMENTS_TABLE . ' - WHERE ' . $db->sql_in_set('post_msg_id', $attach_list) . ' - AND in_message = 0 - ORDER BY attach_id DESC, post_msg_id ASC'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $attachments[$row['post_msg_id']][] = $row; - } - $db->sql_freeresult($result); - - // No attachments exist, but post table thinks they do so go ahead and reset post_attach flags - if (!count($attachments)) - { - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET post_attachment = 0 - WHERE ' . $db->sql_in_set('post_id', $attach_list); - $db->sql_query($sql); - - // We need to update the topic indicator too if the complete topic is now without an attachment - if (count($rowset) != $total_posts) - { - // Not all posts are displayed so we query the db to find if there's any attachment for this topic - $sql = 'SELECT a.post_msg_id as post_id - FROM ' . ATTACHMENTS_TABLE . ' a, ' . POSTS_TABLE . " p - WHERE p.topic_id = $topic_id - AND p.post_visibility = " . ITEM_APPROVED . ' - AND p.topic_id = a.topic_id'; - $result = $db->sql_query_limit($sql, 1); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - $sql = 'UPDATE ' . TOPICS_TABLE . " - SET topic_attachment = 0 - WHERE topic_id = $topic_id"; - $db->sql_query($sql); - } - } - else - { - $sql = 'UPDATE ' . TOPICS_TABLE . " - SET topic_attachment = 0 - WHERE topic_id = $topic_id"; - $db->sql_query($sql); - } - } - else if ($has_approved_attachments && !$topic_data['topic_attachment']) - { - // Topic has approved attachments but its flag is wrong - $sql = 'UPDATE ' . TOPICS_TABLE . " - SET topic_attachment = 1 - WHERE topic_id = $topic_id"; - $db->sql_query($sql); - - $topic_data['topic_attachment'] = 1; - } - else if ($has_unapproved_attachments && !$topic_data['topic_attachment']) - { - // Topic has only unapproved attachments but we have the right to see and download them - $topic_data['topic_attachment'] = 1; - } - } - else - { - $display_notice = true; - } -} - -if ($config['enable_accurate_pm_button']) -{ - // Get the list of users who can receive private messages - $can_receive_pm_list = $auth->acl_get_list(array_keys($user_cache), 'u_readpm'); - $can_receive_pm_list = (empty($can_receive_pm_list) || !isset($can_receive_pm_list[0]['u_readpm'])) ? array() : $can_receive_pm_list[0]['u_readpm']; - - // Get the list of permanently banned users - $permanently_banned_users = phpbb_get_banned_user_ids(array_keys($user_cache), false); -} -else -{ - $can_receive_pm_list = array_keys($user_cache); - $permanently_banned_users = []; -} - -$i_total = count($rowset) - 1; -$prev_post_id = ''; - -$template->assign_vars(array( - 'S_HAS_ATTACHMENTS' => $topic_data['topic_attachment'], - 'S_NUM_POSTS' => count($post_list)) -); - -/** -* Event to modify the post, poster and attachment data before assigning the posts -* -* @event core.viewtopic_modify_post_data -* @var int forum_id Forum ID -* @var int topic_id Topic ID -* @var array topic_data Array with topic data -* @var array post_list Array with post_ids we are going to display -* @var array rowset Array with post_id => post data -* @var array user_cache Array with prepared user data -* @var int start Pagination information -* @var int sort_days Display posts of previous x days -* @var string sort_key Key the posts are sorted by -* @var string sort_dir Direction the posts are sorted by -* @var bool display_notice Shall we display a notice instead of attachments -* @var bool has_approved_attachments Does the topic have approved attachments -* @var array attachments List of attachments post_id => array of attachments -* @var array permanently_banned_users List of permanently banned users -* @var array can_receive_pm_list Array with posters that can receive pms -* @since 3.1.0-RC3 -*/ -$vars = array( - 'forum_id', - 'topic_id', - 'topic_data', - 'post_list', - 'rowset', - 'user_cache', - 'sort_days', - 'sort_key', - 'sort_dir', - 'start', - 'permanently_banned_users', - 'can_receive_pm_list', - 'display_notice', - 'has_approved_attachments', - 'attachments', -); -extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_post_data', compact($vars))); - -// Output the posts -$first_unread = $post_unread = false; -for ($i = 0, $end = count($post_list); $i < $end; ++$i) -{ - // A non-existing rowset only happens if there was no user present for the entered poster_id - // This could be a broken posts table. - if (!isset($rowset[$post_list[$i]])) - { - continue; - } - - $row = $rowset[$post_list[$i]]; - $poster_id = $row['user_id']; - - // End signature parsing, only if needed - if ($user_cache[$poster_id]['sig'] && $row['enable_sig'] && empty($user_cache[$poster_id]['sig_parsed'])) - { - $parse_flags = ($user_cache[$poster_id]['sig_bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES; - $user_cache[$poster_id]['sig'] = generate_text_for_display($user_cache[$poster_id]['sig'], $user_cache[$poster_id]['sig_bbcode_uid'], $user_cache[$poster_id]['sig_bbcode_bitfield'], $parse_flags, true); - $user_cache[$poster_id]['sig_parsed'] = true; - } - - // Parse the message and subject - $parse_flags = ($row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES; - $message = generate_text_for_display($row['post_text'], $row['bbcode_uid'], $row['bbcode_bitfield'], $parse_flags, true); - - if (!empty($attachments[$row['post_id']])) - { - parse_attachments($forum_id, $message, $attachments[$row['post_id']], $update_count); - } - - // Replace naughty words such as farty pants - $row['post_subject'] = censor_text($row['post_subject']); - - // Highlight active words (primarily for search) - if ($highlight_match) - { - $message = preg_replace('#(?!<.*)(?]*(?:)#is', '\1', $message); - $row['post_subject'] = preg_replace('#(?!<.*)(?]*(?:)#is', '\1', $row['post_subject']); - } - - // Editing information - if (($row['post_edit_count'] && $config['display_last_edited']) || $row['post_edit_reason']) - { - // Get usernames for all following posts if not already stored - if (!count($post_edit_list) && ($row['post_edit_reason'] || ($row['post_edit_user'] && !isset($user_cache[$row['post_edit_user']])))) - { - // Remove all post_ids already parsed (we do not have to check them) - $post_storage_list = (!$store_reverse) ? array_slice($post_list, $i) : array_slice(array_reverse($post_list), $i); - - $sql = 'SELECT DISTINCT u.user_id, u.username, u.user_colour - FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u - WHERE ' . $db->sql_in_set('p.post_id', $post_storage_list) . ' - AND p.post_edit_count <> 0 - AND p.post_edit_user <> 0 - AND p.post_edit_user = u.user_id'; - $result2 = $db->sql_query($sql); - while ($user_edit_row = $db->sql_fetchrow($result2)) - { - $post_edit_list[$user_edit_row['user_id']] = $user_edit_row; - } - $db->sql_freeresult($result2); - - unset($post_storage_list); - } - - if ($row['post_edit_reason']) - { - // User having edited the post also being the post author? - if (!$row['post_edit_user'] || $row['post_edit_user'] == $poster_id) - { - $display_username = get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']); - } - else - { - $display_username = get_username_string('full', $row['post_edit_user'], $post_edit_list[$row['post_edit_user']]['username'], $post_edit_list[$row['post_edit_user']]['user_colour']); - } - - $l_edited_by = $user->lang('EDITED_TIMES_TOTAL', (int) $row['post_edit_count'], $display_username, $user->format_date($row['post_edit_time'], false, true)); - } - else - { - if ($row['post_edit_user'] && !isset($user_cache[$row['post_edit_user']])) - { - $user_cache[$row['post_edit_user']] = $post_edit_list[$row['post_edit_user']]; - } - - // User having edited the post also being the post author? - if (!$row['post_edit_user'] || $row['post_edit_user'] == $poster_id) - { - $display_username = get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']); - } - else - { - $display_username = get_username_string('full', $row['post_edit_user'], $user_cache[$row['post_edit_user']]['username'], $user_cache[$row['post_edit_user']]['user_colour']); - } - - $l_edited_by = $user->lang('EDITED_TIMES_TOTAL', (int) $row['post_edit_count'], $display_username, $user->format_date($row['post_edit_time'], false, true)); - } - } - else - { - $l_edited_by = ''; - } - - // Deleting information - if ($row['post_visibility'] == ITEM_DELETED && $row['post_delete_user']) - { - // Get usernames for all following posts if not already stored - if (!count($post_delete_list) && ($row['post_delete_reason'] || ($row['post_delete_user'] && !isset($user_cache[$row['post_delete_user']])))) - { - // Remove all post_ids already parsed (we do not have to check them) - $post_storage_list = (!$store_reverse) ? array_slice($post_list, $i) : array_slice(array_reverse($post_list), $i); - - $sql = 'SELECT DISTINCT u.user_id, u.username, u.user_colour - FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u - WHERE ' . $db->sql_in_set('p.post_id', $post_storage_list) . ' - AND p.post_delete_user <> 0 - AND p.post_delete_user = u.user_id'; - $result2 = $db->sql_query($sql); - while ($user_delete_row = $db->sql_fetchrow($result2)) - { - $post_delete_list[$user_delete_row['user_id']] = $user_delete_row; - } - $db->sql_freeresult($result2); - - unset($post_storage_list); - } - - if ($row['post_delete_user'] && !isset($user_cache[$row['post_delete_user']])) - { - $user_cache[$row['post_delete_user']] = $post_delete_list[$row['post_delete_user']]; - } - - $display_postername = get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']); - - // User having deleted the post also being the post author? - if (!$row['post_delete_user'] || $row['post_delete_user'] == $poster_id) - { - $display_username = $display_postername; - } - else - { - $display_username = get_username_string('full', $row['post_delete_user'], $user_cache[$row['post_delete_user']]['username'], $user_cache[$row['post_delete_user']]['user_colour']); - } - - if ($row['post_delete_reason']) - { - $l_deleted_message = $user->lang('POST_DELETED_BY_REASON', $display_postername, $display_username, $user->format_date($row['post_delete_time'], false, true), $row['post_delete_reason']); - } - else - { - $l_deleted_message = $user->lang('POST_DELETED_BY', $display_postername, $display_username, $user->format_date($row['post_delete_time'], false, true)); - } - $l_deleted_by = $user->lang('DELETED_INFORMATION', $display_username, $user->format_date($row['post_delete_time'], false, true)); - } - else - { - $l_deleted_by = $l_deleted_message = ''; - } - - // Bump information - if ($topic_data['topic_bumped'] && $row['post_id'] == $topic_data['topic_last_post_id'] && isset($user_cache[$topic_data['topic_bumper']]) ) - { - // It is safe to grab the username from the user cache array, we are at the last - // post and only the topic poster and last poster are allowed to bump. - // Admins and mods are bound to the above rules too... - $l_bumped_by = sprintf($user->lang['BUMPED_BY'], $user_cache[$topic_data['topic_bumper']]['username'], $user->format_date($topic_data['topic_last_post_time'], false, true)); - } - else - { - $l_bumped_by = ''; - } - - $cp_row = array(); - - // - if ($config['load_cpf_viewtopic']) - { - $cp_row = (isset($profile_fields_cache[$poster_id])) ? $cp->generate_profile_fields_template_data($profile_fields_cache[$poster_id]) : array(); - } - - $post_unread = (isset($topic_tracking_info[$topic_id]) && $row['post_time'] > $topic_tracking_info[$topic_id]) ? true : false; - - $s_first_unread = false; - if (!$first_unread && $post_unread) - { - $s_first_unread = $first_unread = true; - } - - $force_edit_allowed = $force_delete_allowed = $force_softdelete_allowed = false; - - $s_cannot_edit = !$auth->acl_get('f_edit', $forum_id) || $user->data['user_id'] != $poster_id; - $s_cannot_edit_time = $config['edit_time'] && $row['post_time'] <= time() - ($config['edit_time'] * 60); - $s_cannot_edit_locked = $topic_data['topic_status'] == ITEM_LOCKED || $row['post_edit_locked']; - - $s_cannot_delete = $user->data['user_id'] != $poster_id || ( - !$auth->acl_get('f_delete', $forum_id) && - (!$auth->acl_get('f_softdelete', $forum_id) || $row['post_visibility'] == ITEM_DELETED) - ); - $s_cannot_delete_lastpost = $topic_data['topic_last_post_id'] != $row['post_id']; - $s_cannot_delete_time = $config['delete_time'] && $row['post_time'] <= time() - ($config['delete_time'] * 60); - // we do not want to allow removal of the last post if a moderator locked it! - $s_cannot_delete_locked = $topic_data['topic_status'] == ITEM_LOCKED || $row['post_edit_locked']; - - /** - * This event allows you to modify the conditions for the "can edit post" and "can delete post" checks - * - * @event core.viewtopic_modify_post_action_conditions - * @var array row Array with post data - * @var array topic_data Array with topic data - * @var bool force_edit_allowed Allow the user to edit the post (all permissions and conditions are ignored) - * @var bool s_cannot_edit User can not edit the post because it's not his - * @var bool s_cannot_edit_locked User can not edit the post because it's locked - * @var bool s_cannot_edit_time User can not edit the post because edit_time has passed - * @var bool force_delete_allowed Allow the user to delete the post (all permissions and conditions are ignored) - * @var bool s_cannot_delete User can not delete the post because it's not his - * @var bool s_cannot_delete_lastpost User can not delete the post because it's not the last post of the topic - * @var bool s_cannot_delete_locked User can not delete the post because it's locked - * @var bool s_cannot_delete_time User can not delete the post because edit_time has passed - * @var bool force_softdelete_allowed Allow the user to ыoftdelete the post (all permissions and conditions are ignored) - * @since 3.1.0-b4 - * @changed 3.1.11-RC1 Added force_softdelete_allowed var - */ - $vars = array( - 'row', - 'topic_data', - 'force_edit_allowed', - 's_cannot_edit', - 's_cannot_edit_locked', - 's_cannot_edit_time', - 'force_delete_allowed', - 's_cannot_delete', - 's_cannot_delete_lastpost', - 's_cannot_delete_locked', - 's_cannot_delete_time', - 'force_softdelete_allowed', - ); - extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_post_action_conditions', compact($vars))); - - $edit_allowed = $force_edit_allowed || ($user->data['is_registered'] && ($auth->acl_get('m_edit', $forum_id) || ( - !$s_cannot_edit && - !$s_cannot_edit_time && - !$s_cannot_edit_locked - ))); - - $quote_allowed = $auth->acl_get('m_edit', $forum_id) || ($topic_data['topic_status'] != ITEM_LOCKED && - ($user->data['user_id'] == ANONYMOUS || $auth->acl_get('f_reply', $forum_id)) - ); - - // Only display the quote button if the post is quotable. Posts not approved are not quotable. - $quote_allowed = ($quote_allowed && $row['post_visibility'] == ITEM_APPROVED) ? true : false; - - $delete_allowed = $force_delete_allowed || ($user->data['is_registered'] && ( - ($auth->acl_get('m_delete', $forum_id) || ($auth->acl_get('m_softdelete', $forum_id) && $row['post_visibility'] != ITEM_DELETED)) || - (!$s_cannot_delete && !$s_cannot_delete_lastpost && !$s_cannot_delete_time && !$s_cannot_delete_locked) - )); - - $softdelete_allowed = $force_softdelete_allowed || (($auth->acl_get('m_softdelete', $forum_id) || - ($auth->acl_get('f_softdelete', $forum_id) && $user->data['user_id'] == $poster_id)) && ($row['post_visibility'] != ITEM_DELETED)); - - $permanent_delete_allowed = $force_delete_allowed || ($auth->acl_get('m_delete', $forum_id) || - ($auth->acl_get('f_delete', $forum_id) && $user->data['user_id'] == $poster_id)); - - // Can this user receive a Private Message? - $can_receive_pm = ( - // They must be a "normal" user - $user_cache[$poster_id]['user_type'] != USER_IGNORE && - - // They must not be deactivated by the administrator - ($user_cache[$poster_id]['user_type'] != USER_INACTIVE || $user_cache[$poster_id]['user_inactive_reason'] != INACTIVE_MANUAL) && - - // They must be able to read PMs - in_array($poster_id, $can_receive_pm_list) && - - // They must not be permanently banned - !in_array($poster_id, $permanently_banned_users) && - - // They must allow users to contact via PM - (($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) || $user_cache[$poster_id]['allow_pm']) - ); - - $u_pm = ''; - - if ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && $can_receive_pm) - { - $u_pm = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&action=quotepost&p=' . $row['post_id']); - } - - // - $post_row = array( - 'POST_AUTHOR_FULL' => ($poster_id != ANONYMOUS) ? $user_cache[$poster_id]['author_full'] : get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), - 'POST_AUTHOR_COLOUR' => ($poster_id != ANONYMOUS) ? $user_cache[$poster_id]['author_colour'] : get_username_string('colour', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), - 'POST_AUTHOR' => ($poster_id != ANONYMOUS) ? $user_cache[$poster_id]['author_username'] : get_username_string('username', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), - 'U_POST_AUTHOR' => ($poster_id != ANONYMOUS) ? $user_cache[$poster_id]['author_profile'] : get_username_string('profile', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), - - 'RANK_TITLE' => $user_cache[$poster_id]['rank_title'], - 'RANK_IMG' => $user_cache[$poster_id]['rank_image'], - 'RANK_IMG_SRC' => $user_cache[$poster_id]['rank_image_src'], - 'POSTER_JOINED' => $user_cache[$poster_id]['joined'], - 'POSTER_POSTS' => $user_cache[$poster_id]['posts'], - 'POSTER_AVATAR' => $user_cache[$poster_id]['avatar'], - 'POSTER_WARNINGS' => $auth->acl_get('m_warn') ? $user_cache[$poster_id]['warnings'] : '', - 'POSTER_AGE' => $user_cache[$poster_id]['age'], - 'CONTACT_USER' => $user_cache[$poster_id]['contact_user'], - - 'POST_DATE' => $user->format_date($row['post_time'], false, ($view == 'print') ? true : false), - 'POST_SUBJECT' => $row['post_subject'], - 'MESSAGE' => $message, - 'SIGNATURE' => ($row['enable_sig']) ? $user_cache[$poster_id]['sig'] : '', - 'EDITED_MESSAGE' => $l_edited_by, - 'EDIT_REASON' => $row['post_edit_reason'], - 'DELETED_MESSAGE' => $l_deleted_by, - 'DELETE_REASON' => $row['post_delete_reason'], - 'BUMPED_MESSAGE' => $l_bumped_by, - - 'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'), - 'POST_ICON_IMG' => ($topic_data['enable_icons'] && !empty($row['icon_id'])) ? $icons[$row['icon_id']]['img'] : '', - 'POST_ICON_IMG_WIDTH' => ($topic_data['enable_icons'] && !empty($row['icon_id'])) ? $icons[$row['icon_id']]['width'] : '', - 'POST_ICON_IMG_HEIGHT' => ($topic_data['enable_icons'] && !empty($row['icon_id'])) ? $icons[$row['icon_id']]['height'] : '', - 'POST_ICON_IMG_ALT' => ($topic_data['enable_icons'] && !empty($row['icon_id'])) ? $icons[$row['icon_id']]['alt'] : '', - 'ONLINE_IMG' => ($poster_id == ANONYMOUS || !$config['load_onlinetrack']) ? '' : (($user_cache[$poster_id]['online']) ? $user->img('icon_user_online', 'ONLINE') : $user->img('icon_user_offline', 'OFFLINE')), - 'S_ONLINE' => ($poster_id == ANONYMOUS || !$config['load_onlinetrack']) ? false : (($user_cache[$poster_id]['online']) ? true : false), - - 'U_EDIT' => ($edit_allowed) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=edit&f=$forum_id&p={$row['post_id']}") : '', - 'U_QUOTE' => ($quote_allowed) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=quote&f=$forum_id&p={$row['post_id']}") : '', - 'U_INFO' => ($auth->acl_get('m_info', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&mode=post_details&f=$forum_id&p=" . $row['post_id'], true, $user->session_id) : '', - 'U_DELETE' => ($delete_allowed) ? append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=' . (($softdelete_allowed) ? 'soft_delete' : 'delete') . "&f=$forum_id&p={$row['post_id']}") : '', - - 'U_SEARCH' => $user_cache[$poster_id]['search'], - 'U_PM' => $u_pm, - 'U_EMAIL' => $user_cache[$poster_id]['email'], - 'U_JABBER' => $user_cache[$poster_id]['jabber'], - - 'U_APPROVE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue&p={$row['post_id']}&f=$forum_id&redirect=" . urlencode(str_replace('&', '&', $viewtopic_url . '&p=' . $row['post_id'] . '#p' . $row['post_id']))), - 'U_REPORT' => ($auth->acl_get('f_report', $forum_id)) ? $phpbb_container->get('controller.helper')->route('phpbb_report_post_controller', array('id' => $row['post_id'])) : '', - 'U_MCP_REPORT' => ($auth->acl_get('m_report', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=report_details&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '', - 'U_MCP_APPROVE' => ($auth->acl_get('m_approve', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=approve_details&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '', - 'U_MCP_RESTORE' => ($auth->acl_get('m_approve', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=' . (($topic_data['topic_visibility'] != ITEM_DELETED) ? 'deleted_posts' : 'deleted_topics') . '&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '', - 'U_MINI_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $row['post_id']) . '#p' . $row['post_id'], - 'U_NEXT_POST_ID' => ($i < $i_total && isset($rowset[$post_list[$i + 1]])) ? $rowset[$post_list[$i + 1]]['post_id'] : '', - 'U_PREV_POST_ID' => $prev_post_id, - 'U_NOTES' => ($auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $poster_id, true, $user->session_id) : '', - 'U_WARN' => ($auth->acl_get('m_warn') && $poster_id != $user->data['user_id'] && $poster_id != ANONYMOUS) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_post&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '', - - 'POST_ID' => $row['post_id'], - 'POST_NUMBER' => $i + $start + 1, - 'POSTER_ID' => $poster_id, - 'MINI_POST' => ($post_unread) ? $user->lang['UNREAD_POST'] : $user->lang['POST'], - - - 'S_HAS_ATTACHMENTS' => (!empty($attachments[$row['post_id']])) ? true : false, - 'S_MULTIPLE_ATTACHMENTS' => !empty($attachments[$row['post_id']]) && count($attachments[$row['post_id']]) > 1, - 'S_POST_UNAPPROVED' => ($row['post_visibility'] == ITEM_UNAPPROVED || $row['post_visibility'] == ITEM_REAPPROVE) ? true : false, - 'S_POST_DELETED' => ($row['post_visibility'] == ITEM_DELETED) ? true : false, - 'L_POST_DELETED_MESSAGE' => $l_deleted_message, - 'S_POST_REPORTED' => ($row['post_reported'] && $auth->acl_get('m_report', $forum_id)) ? true : false, - 'S_DISPLAY_NOTICE' => $display_notice && $row['post_attachment'], - 'S_FRIEND' => ($row['friend']) ? true : false, - 'S_UNREAD_POST' => $post_unread, - 'S_FIRST_UNREAD' => $s_first_unread, - 'S_CUSTOM_FIELDS' => (isset($cp_row['row']) && count($cp_row['row'])) ? true : false, - 'S_TOPIC_POSTER' => ($topic_data['topic_poster'] == $poster_id) ? true : false, - 'S_FIRST_POST' => ($topic_data['topic_first_post_id'] == $row['post_id']) ? true : false, - - 'S_IGNORE_POST' => ($row['foe']) ? true : false, - 'L_IGNORE_POST' => ($row['foe']) ? sprintf($user->lang['POST_BY_FOE'], get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username'])) : '', - 'S_POST_HIDDEN' => $row['hide_post'], - 'L_POST_DISPLAY' => ($row['hide_post']) ? $user->lang('POST_DISPLAY', '', '') : '', - 'S_DELETE_PERMANENT' => $permanent_delete_allowed, - ); - - $user_poster_data = $user_cache[$poster_id]; - - $current_row_number = $i; - - /** - * Modify the posts template block - * - * @event core.viewtopic_modify_post_row - * @var int start Start item of this page - * @var int current_row_number Number of the post on this page - * @var int end Number of posts on this page - * @var int total_posts Total posts count - * @var int poster_id Post author id - * @var array row Array with original post and user data - * @var array cp_row Custom profile field data of the poster - * @var array attachments List of attachments - * @var array user_poster_data Poster's data from user cache - * @var array post_row Template block array of the post - * @var array topic_data Array with topic data - * @var array user_cache Array with cached user data - * @var array post_edit_list Array with post edited list - * @since 3.1.0-a1 - * @changed 3.1.0-a3 Added vars start, current_row_number, end, attachments - * @changed 3.1.0-b3 Added topic_data array, total_posts - * @changed 3.1.0-RC3 Added poster_id - * @changed 3.2.2-RC1 Added user_cache and post_edit_list - */ - $vars = array( - 'start', - 'current_row_number', - 'end', - 'total_posts', - 'poster_id', - 'row', - 'cp_row', - 'attachments', - 'user_poster_data', - 'post_row', - 'topic_data', - 'user_cache', - 'post_edit_list', - ); - extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_post_row', compact($vars))); - - $i = $current_row_number; - - if (isset($cp_row['row']) && count($cp_row['row'])) - { - $post_row = array_merge($post_row, $cp_row['row']); - } - - // Dump vars into template - $template->assign_block_vars('postrow', $post_row); - - $contact_fields = array( - array( - 'ID' => 'pm', - 'NAME' => $user->lang['SEND_PRIVATE_MESSAGE'], - 'U_CONTACT' => $post_row['U_PM'], - ), - array( - 'ID' => 'email', - 'NAME' => $user->lang['SEND_EMAIL'], - 'U_CONTACT' => $user_cache[$poster_id]['email'], - ), - array( - 'ID' => 'jabber', - 'NAME' => $user->lang['JABBER'], - 'U_CONTACT' => $user_cache[$poster_id]['jabber'], - ), - ); - - foreach ($contact_fields as $field) - { - if ($field['U_CONTACT']) - { - $template->assign_block_vars('postrow.contact', $field); - } - } - - if (!empty($cp_row['blockrow'])) - { - foreach ($cp_row['blockrow'] as $field_data) - { - $template->assign_block_vars('postrow.custom_fields', $field_data); - - if ($field_data['S_PROFILE_CONTACT']) - { - $template->assign_block_vars('postrow.contact', array( - 'ID' => $field_data['PROFILE_FIELD_IDENT'], - 'NAME' => $field_data['PROFILE_FIELD_NAME'], - 'U_CONTACT' => $field_data['PROFILE_FIELD_CONTACT'], - )); - } - } - } - - // Display not already displayed Attachments for this post, we already parsed them. ;) - if (!empty($attachments[$row['post_id']])) - { - foreach ($attachments[$row['post_id']] as $attachment) - { - $template->assign_block_vars('postrow.attachment', array( - 'DISPLAY_ATTACHMENT' => $attachment) - ); - } - } - - $current_row_number = $i; - - /** - * Event after the post data has been assigned to the template - * - * @event core.viewtopic_post_row_after - * @var int start Start item of this page - * @var int current_row_number Number of the post on this page - * @var int end Number of posts on this page - * @var int total_posts Total posts count - * @var array row Array with original post and user data - * @var array cp_row Custom profile field data of the poster - * @var array attachments List of attachments - * @var array user_poster_data Poster's data from user cache - * @var array post_row Template block array of the post - * @var array topic_data Array with topic data - * @since 3.1.0-a3 - * @changed 3.1.0-b3 Added topic_data array, total_posts - */ - $vars = array( - 'start', - 'current_row_number', - 'end', - 'total_posts', - 'row', - 'cp_row', - 'attachments', - 'user_poster_data', - 'post_row', - 'topic_data', - ); - extract($phpbb_dispatcher->trigger_event('core.viewtopic_post_row_after', compact($vars))); - - $i = $current_row_number; - - $prev_post_id = $row['post_id']; - - unset($rowset[$post_list[$i]]); - unset($attachments[$row['post_id']]); -} -unset($rowset, $user_cache); - -// Update topic view and if necessary attachment view counters ... but only for humans and if this is the first 'page view' -if (isset($user->data['session_page']) && !$user->data['is_bot'] && (strpos($user->data['session_page'], '&t=' . $topic_id) === false || isset($user->data['session_created']))) -{ - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_views = topic_views + 1, topic_last_view_time = ' . time() . " - WHERE topic_id = $topic_id"; - $db->sql_query($sql); - - // Update the attachment download counts - if (count($update_count)) - { - $sql = 'UPDATE ' . ATTACHMENTS_TABLE . ' - SET download_count = download_count + 1 - WHERE ' . $db->sql_in_set('attach_id', array_unique($update_count)); - $db->sql_query($sql); - } -} - -// Only mark topic if it's currently unread. Also make sure we do not set topic tracking back if earlier pages are viewed. -if (isset($topic_tracking_info[$topic_id]) && $topic_data['topic_last_post_time'] > $topic_tracking_info[$topic_id] && $max_post_time > $topic_tracking_info[$topic_id]) -{ - markread('topic', $forum_id, $topic_id, $max_post_time); - - // Update forum info - $all_marked_read = update_forum_tracking_info($forum_id, $topic_data['forum_last_post_time'], (isset($topic_data['forum_mark_time'])) ? $topic_data['forum_mark_time'] : false, false); -} -else -{ - $all_marked_read = true; -} - -// If there are absolutely no more unread posts in this forum -// and unread posts shown, we can safely show the #unread link -if ($all_marked_read) -{ - if ($post_unread) - { - $template->assign_vars(array( - 'U_VIEW_UNREAD_POST' => '#unread', - )); - } - else if (isset($topic_tracking_info[$topic_id]) && $topic_data['topic_last_post_time'] > $topic_tracking_info[$topic_id]) - { - $template->assign_vars(array( - 'U_VIEW_UNREAD_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&view=unread") . '#unread', - )); - } -} -else if (!$all_marked_read) -{ - $last_page = ((floor($start / $config['posts_per_page']) + 1) == max(ceil($total_posts / $config['posts_per_page']), 1)) ? true : false; - - // What can happen is that we are at the last displayed page. If so, we also display the #unread link based in $post_unread - if ($last_page && $post_unread) - { - $template->assign_vars(array( - 'U_VIEW_UNREAD_POST' => '#unread', - )); - } - else if (!$last_page) - { - $template->assign_vars(array( - 'U_VIEW_UNREAD_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&view=unread") . '#unread', - )); - } -} - -// let's set up quick_reply -$s_quick_reply = false; -if ($user->data['is_registered'] && $config['allow_quick_reply'] && ($topic_data['forum_flags'] & FORUM_FLAG_QUICK_REPLY) && $auth->acl_get('f_reply', $forum_id)) -{ - // Quick reply enabled forum - $s_quick_reply = (($topic_data['forum_status'] == ITEM_UNLOCKED && $topic_data['topic_status'] == ITEM_UNLOCKED) || $auth->acl_get('m_edit', $forum_id)) ? true : false; -} - -if ($s_can_vote || $s_quick_reply) -{ - add_form_key('posting'); - - if ($s_quick_reply) - { - $s_attach_sig = $config['allow_sig'] && $user->optionget('attachsig') && $auth->acl_get('f_sigs', $forum_id) && $auth->acl_get('u_sig'); - $s_smilies = $config['allow_smilies'] && $user->optionget('smilies') && $auth->acl_get('f_smilies', $forum_id); - $s_bbcode = $config['allow_bbcode'] && $user->optionget('bbcode') && $auth->acl_get('f_bbcode', $forum_id); - $s_notify = $config['allow_topic_notify'] && ($user->data['user_notify'] || $s_watching_topic['is_watching']); - - $qr_hidden_fields = array( - 'topic_cur_post_id' => (int) $topic_data['topic_last_post_id'], - 'topic_id' => (int) $topic_data['topic_id'], - 'forum_id' => (int) $forum_id, - ); - - // Originally we use checkboxes and check with isset(), so we only provide them if they would be checked - (!$s_bbcode) ? $qr_hidden_fields['disable_bbcode'] = 1 : true; - (!$s_smilies) ? $qr_hidden_fields['disable_smilies'] = 1 : true; - (!$config['allow_post_links']) ? $qr_hidden_fields['disable_magic_url'] = 1 : true; - ($s_attach_sig) ? $qr_hidden_fields['attach_sig'] = 1 : true; - ($s_notify) ? $qr_hidden_fields['notify'] = 1 : true; - ($topic_data['topic_status'] == ITEM_LOCKED) ? $qr_hidden_fields['lock_topic'] = 1 : true; - - $template->assign_vars(array( - 'S_QUICK_REPLY' => true, - 'U_QR_ACTION' => append_sid("{$phpbb_root_path}posting.$phpEx", "mode=reply&f=$forum_id&t=$topic_id"), - 'QR_HIDDEN_FIELDS' => build_hidden_fields($qr_hidden_fields), - 'SUBJECT' => 'Re: ' . censor_text($topic_data['topic_title']), - )); - } -} -// now I have the urge to wash my hands :( - - -// We overwrite $_REQUEST['f'] if there is no forum specified -// to be able to display the correct online list. -// One downside is that the user currently viewing this topic/post is not taken into account. -if (!$request->variable('f', 0)) -{ - $request->overwrite('f', $forum_id); -} - -// We need to do the same with the topic_id. See #53025. -if (!$request->variable('t', 0) && !empty($topic_id)) -{ - $request->overwrite('t', $topic_id); -} - -$page_title = $topic_data['topic_title'] . ($start ? ' - ' . sprintf($user->lang['PAGE_TITLE_NUMBER'], $pagination->get_on_page($config['posts_per_page'], $start)) : ''); - -/** -* You can use this event to modify the page title of the viewtopic page -* -* @event core.viewtopic_modify_page_title -* @var string page_title Title of the viewtopic page -* @var array topic_data Array with topic data -* @var int forum_id Forum ID of the topic -* @var int start Start offset used to calculate the page -* @var array post_list Array with post_ids we are going to display -* @since 3.1.0-a1 -* @changed 3.1.0-RC4 Added post_list var -*/ -$vars = array('page_title', 'topic_data', 'forum_id', 'start', 'post_list'); -extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_page_title', compact($vars))); - -// Output the page -page_header($page_title, true, $forum_id); - -$template->set_filenames(array( - 'body' => ($view == 'print') ? 'viewtopic_print.html' : 'viewtopic_body.html') -); -make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"), $forum_id); - -page_footer(); diff --git a/language/fr/email/user_activate_passwd.txt b/language/fr/email/user_activate_passwd.txt deleted file mode 100644 index 739d00d..0000000 --- a/language/fr/email/user_activate_passwd.txt +++ /dev/null @@ -1,17 +0,0 @@ -Subject: Activation d’un nouveau mot de passe - -Bonjour {USERNAME}, - -Vous recevez cette notification car vous (ou quelqu’un se faisant passer pour vous) avez demandé qu’un nouveau mot de passe vous soit envoyé pour votre compte sur « {SITENAME} ». Si vous n’avez pas demandé cette modification, veuillez alors l’ignorer. Si vous continuez à recevoir cette notification, veuillez contacter un administrateur du forum. - -Pour utiliser le nouveau mot de passe, vous avez besoin de l’activer. Pour cela, veuillez cliquer sur le lien ci-dessous : - -{U_ACTIVATE} - -Si cela a fonctionné, vous pourrez vous connecter en utilisant le mot de passe suivant : - -Mot de passe : {PASSWORD} - -Vous pouvez modifier ce mot de passe dans le panneau de contrôle de l’utilisateur. Si vous éprouvez une quelconque difficulté durant ces étapes, veuillez contacter un administrateur du forum. - -{EMAIL_SIG} diff --git a/styles/Milk_v2/theme/blank.css.css b/styles/Milk_v2/theme/blank.css.css deleted file mode 100644 index 34f1449..0000000 --- a/styles/Milk_v2/theme/blank.css.css +++ /dev/null @@ -1,3 +0,0 @@ -/* This file is intentionally left blank. -It's used by the light/dark toggle -If deleted, you'll get a console log error (but things will still work) */ diff --git a/styles/Milk_v2/theme/images/icon_download.gif b/styles/Milk_v2/theme/images/icon_download.gif deleted file mode 100644 index 70cd61c..0000000 Binary files a/styles/Milk_v2/theme/images/icon_download.gif and /dev/null differ diff --git a/styles/Milk_v2/theme/images/icon_offline.gif b/styles/Milk_v2/theme/images/icon_offline.gif deleted file mode 100644 index 5dc4212..0000000 Binary files a/styles/Milk_v2/theme/images/icon_offline.gif and /dev/null differ diff --git a/styles/Milk_v2/theme/images/icon_online.gif b/styles/Milk_v2/theme/images/icon_online.gif deleted file mode 100644 index d0d202d..0000000 Binary files a/styles/Milk_v2/theme/images/icon_online.gif and /dev/null differ diff --git a/styles/Milk_v2/theme/images/icon_rate_bad.gif b/styles/Milk_v2/theme/images/icon_rate_bad.gif deleted file mode 100644 index 7901889..0000000 Binary files a/styles/Milk_v2/theme/images/icon_rate_bad.gif and /dev/null differ diff --git a/styles/Milk_v2/theme/images/icon_rate_good.gif b/styles/Milk_v2/theme/images/icon_rate_good.gif deleted file mode 100644 index 6d23034..0000000 Binary files a/styles/Milk_v2/theme/images/icon_rate_good.gif and /dev/null differ diff --git a/styles/Milk_v2/theme/images/quote.gif b/styles/Milk_v2/theme/images/quote.gif deleted file mode 100644 index d199227..0000000 Binary files a/styles/Milk_v2/theme/images/quote.gif and /dev/null differ diff --git a/styles/Milk_v2/theme/images/quote_rtl.gif b/styles/Milk_v2/theme/images/quote_rtl.gif deleted file mode 100644 index ac719cf..0000000 Binary files a/styles/Milk_v2/theme/images/quote_rtl.gif and /dev/null differ diff --git a/styles/Milk_v2/theme/images/sticky_read_locked.gif b/styles/Milk_v2/theme/images/sticky_read_locked.gif deleted file mode 100644 index 79f581b..0000000 Binary files a/styles/Milk_v2/theme/images/sticky_read_locked.gif and /dev/null differ diff --git a/styles/Milk_v2/theme/images/sticky_read_locked_mine.gif b/styles/Milk_v2/theme/images/sticky_read_locked_mine.gif deleted file mode 100644 index ad05608..0000000 Binary files a/styles/Milk_v2/theme/images/sticky_read_locked_mine.gif and /dev/null differ diff --git a/styles/Milk_v2/theme/images/sticky_read_mine.gif b/styles/Milk_v2/theme/images/sticky_read_mine.gif deleted file mode 100644 index 8f5f28f..0000000 Binary files a/styles/Milk_v2/theme/images/sticky_read_mine.gif and /dev/null differ diff --git a/styles/Milk_v2/theme/images/sticky_unread.gif b/styles/Milk_v2/theme/images/sticky_unread.gif deleted file mode 100644 index d62b3c0..0000000 Binary files a/styles/Milk_v2/theme/images/sticky_unread.gif and /dev/null differ diff --git a/styles/Milk_v2/theme/stylesheet.css b/styles/Milk_v2/theme/stylesheet.css deleted file mode 100644 index 0d19a04..0000000 --- a/styles/Milk_v2/theme/stylesheet.css +++ /dev/null @@ -1,40 +0,0 @@ -/* phpBB3 Style Sheet - -------------------------------------------------------------- - phpBB style name: Milk v2 - Based on style: Merlin Framework (http://www.planetstyles.net) - -------------------------------------------------------------- -*/ - -/* Core */ -@import url("merlin.css?v=3.3"); -@import url("normalize.css?v=3.3"); -@import url("base.css?v=3.3"); -@import url("utilities.css?v=3.3"); -@import url("common.css?v=3.3"); -@import url("links.css?v=3.3"); -@import url("content.css?v=3.3"); -@import url("buttons.css?v=3.3"); -@import url("cp.css?v=3.3"); -@import url("forms.css?v=3.3"); - -/* Icons */ -@import url("icons.css?v=3.3"); -@import url("icons_forums_topics.css?v=3.3"); - -/* Custom Additions */ -@import url("animate.css?v=3.3"); -@import url("tooltipster.bundle.min.css?v=3.3"); -@import url("tooltipster-sideTip-borderless.min.css?v=3.3"); - -/* Responsive */ -@import url("responsive/responsive.css?v=3.3"); -@import url("responsive/xs-phones.css?v=3.3"); -@import url("responsive/small-smaller-tablets.css?v=3.3"); -@import url("responsive/medium-ipad.css?v=3.3"); -@import url("responsive/large-desktops.css?v=3.3"); -@import url("responsive/squishy.css?v=3.3"); - -/* Facelift */ -@import url("colours.css?v=3.3"); -@import url("fonts.css?v=3.3"); -@import url("milk.css?v=3.3"); diff --git a/styles/Milk_v2/theme/stylesheet_jour.css b/styles/Milk_v2/theme/stylesheet_jour.css index 96f21db..0d19a04 100644 --- a/styles/Milk_v2/theme/stylesheet_jour.css +++ b/styles/Milk_v2/theme/stylesheet_jour.css @@ -6,35 +6,35 @@ */ /* Core */ -@import url("merlin.css"); -@import url("normalize.css"); -@import url("base.css"); -@import url("utilities.css"); -@import url("common.css"); -@import url("links.css"); -@import url("content.css"); -@import url("buttons.css"); -@import url("cp.css"); -@import url("forms.css"); +@import url("merlin.css?v=3.3"); +@import url("normalize.css?v=3.3"); +@import url("base.css?v=3.3"); +@import url("utilities.css?v=3.3"); +@import url("common.css?v=3.3"); +@import url("links.css?v=3.3"); +@import url("content.css?v=3.3"); +@import url("buttons.css?v=3.3"); +@import url("cp.css?v=3.3"); +@import url("forms.css?v=3.3"); /* Icons */ -@import url("icons.css"); -@import url("icons_forums_topics.css"); +@import url("icons.css?v=3.3"); +@import url("icons_forums_topics.css?v=3.3"); /* Custom Additions */ -@import url("animate.css"); -@import url("tooltipster.bundle.min.css"); -@import url("tooltipster-sideTip-borderless.min.css"); +@import url("animate.css?v=3.3"); +@import url("tooltipster.bundle.min.css?v=3.3"); +@import url("tooltipster-sideTip-borderless.min.css?v=3.3"); /* Responsive */ -@import url("responsive/responsive.css"); -@import url("responsive/xs-phones.css"); -@import url("responsive/small-smaller-tablets.css"); -@import url("responsive/medium-ipad.css"); -@import url("responsive/large-desktops.css"); -@import url("responsive/squishy.css"); +@import url("responsive/responsive.css?v=3.3"); +@import url("responsive/xs-phones.css?v=3.3"); +@import url("responsive/small-smaller-tablets.css?v=3.3"); +@import url("responsive/medium-ipad.css?v=3.3"); +@import url("responsive/large-desktops.css?v=3.3"); +@import url("responsive/squishy.css?v=3.3"); /* Facelift */ -@import url("colours.css"); -@import url("fonts.css"); -@import url("milk.css"); \ No newline at end of file +@import url("colours.css?v=3.3"); +@import url("fonts.css?v=3.3"); +@import url("milk.css?v=3.3"); diff --git a/styles/Milk_v2/theme/stylesheet_nuit.css b/styles/Milk_v2/theme/stylesheet_nuit.css index 96f21db..0d19a04 100644 --- a/styles/Milk_v2/theme/stylesheet_nuit.css +++ b/styles/Milk_v2/theme/stylesheet_nuit.css @@ -6,35 +6,35 @@ */ /* Core */ -@import url("merlin.css"); -@import url("normalize.css"); -@import url("base.css"); -@import url("utilities.css"); -@import url("common.css"); -@import url("links.css"); -@import url("content.css"); -@import url("buttons.css"); -@import url("cp.css"); -@import url("forms.css"); +@import url("merlin.css?v=3.3"); +@import url("normalize.css?v=3.3"); +@import url("base.css?v=3.3"); +@import url("utilities.css?v=3.3"); +@import url("common.css?v=3.3"); +@import url("links.css?v=3.3"); +@import url("content.css?v=3.3"); +@import url("buttons.css?v=3.3"); +@import url("cp.css?v=3.3"); +@import url("forms.css?v=3.3"); /* Icons */ -@import url("icons.css"); -@import url("icons_forums_topics.css"); +@import url("icons.css?v=3.3"); +@import url("icons_forums_topics.css?v=3.3"); /* Custom Additions */ -@import url("animate.css"); -@import url("tooltipster.bundle.min.css"); -@import url("tooltipster-sideTip-borderless.min.css"); +@import url("animate.css?v=3.3"); +@import url("tooltipster.bundle.min.css?v=3.3"); +@import url("tooltipster-sideTip-borderless.min.css?v=3.3"); /* Responsive */ -@import url("responsive/responsive.css"); -@import url("responsive/xs-phones.css"); -@import url("responsive/small-smaller-tablets.css"); -@import url("responsive/medium-ipad.css"); -@import url("responsive/large-desktops.css"); -@import url("responsive/squishy.css"); +@import url("responsive/responsive.css?v=3.3"); +@import url("responsive/xs-phones.css?v=3.3"); +@import url("responsive/small-smaller-tablets.css?v=3.3"); +@import url("responsive/medium-ipad.css?v=3.3"); +@import url("responsive/large-desktops.css?v=3.3"); +@import url("responsive/squishy.css?v=3.3"); /* Facelift */ -@import url("colours.css"); -@import url("fonts.css"); -@import url("milk.css"); \ No newline at end of file +@import url("colours.css?v=3.3"); +@import url("fonts.css?v=3.3"); +@import url("milk.css?v=3.3"); diff --git a/styles/prosilver/theme/stylesheet.css b/styles/prosilver/theme/stylesheet.css deleted file mode 100644 index c402d56..0000000 --- a/styles/prosilver/theme/stylesheet.css +++ /dev/null @@ -1,21 +0,0 @@ -/* phpBB3 Style Sheet - -------------------------------------------------------------- - Style name: prosilver (the default phpBB 3.3.x style) - Based on style: - Original author: Tom Beddard ( http://www.subblue.com/ ) - Modified by: phpBB Limited ( https://www.phpbb.com/ ) - -------------------------------------------------------------- -*/ - -@import url("normalize.css?v=3.3"); -@import url("base.css?v=3.3"); -@import url("utilities.css?v=3.3"); -@import url("common.css?v=3.3"); -@import url("links.css?v=3.3"); -@import url("content.css?v=3.3"); -@import url("buttons.css?v=3.3"); -@import url("cp.css?v=3.3"); -@import url("forms.css?v=3.3"); -@import url("icons.css?v=3.3"); -@import url("colours.css?v=3.3"); -@import url("responsive.css?v=3.3"); diff --git a/styles/prosilver/theme/stylesheet_jour.css b/styles/prosilver/theme/stylesheet_jour.css index 45eb5b6..c402d56 100644 --- a/styles/prosilver/theme/stylesheet_jour.css +++ b/styles/prosilver/theme/stylesheet_jour.css @@ -1,21 +1,21 @@ /* phpBB3 Style Sheet -------------------------------------------------------------- - Style name: prosilver (the default phpBB 3.2.x style) + Style name: prosilver (the default phpBB 3.3.x style) Based on style: Original author: Tom Beddard ( http://www.subblue.com/ ) Modified by: phpBB Limited ( https://www.phpbb.com/ ) -------------------------------------------------------------- */ -@import url("normalize.css?v=3.2"); -@import url("base.css?v=3.2"); -@import url("utilities.css?v=3.2"); -@import url("common.css?v=3.2"); -@import url("links.css?v=3.2"); -@import url("content.css?v=3.2"); -@import url("buttons.css?v=3.2"); -@import url("cp.css?v=3.2"); -@import url("forms.css?v=3.2"); -@import url("icons.css?v=3.2"); -@import url("colours.css?v=3.2"); -@import url("responsive.css?v=3.2"); +@import url("normalize.css?v=3.3"); +@import url("base.css?v=3.3"); +@import url("utilities.css?v=3.3"); +@import url("common.css?v=3.3"); +@import url("links.css?v=3.3"); +@import url("content.css?v=3.3"); +@import url("buttons.css?v=3.3"); +@import url("cp.css?v=3.3"); +@import url("forms.css?v=3.3"); +@import url("icons.css?v=3.3"); +@import url("colours.css?v=3.3"); +@import url("responsive.css?v=3.3"); diff --git a/styles/prosilver/theme/stylesheet_nuit.css b/styles/prosilver/theme/stylesheet_nuit.css index 45eb5b6..c402d56 100644 --- a/styles/prosilver/theme/stylesheet_nuit.css +++ b/styles/prosilver/theme/stylesheet_nuit.css @@ -1,21 +1,21 @@ /* phpBB3 Style Sheet -------------------------------------------------------------- - Style name: prosilver (the default phpBB 3.2.x style) + Style name: prosilver (the default phpBB 3.3.x style) Based on style: Original author: Tom Beddard ( http://www.subblue.com/ ) Modified by: phpBB Limited ( https://www.phpbb.com/ ) -------------------------------------------------------------- */ -@import url("normalize.css?v=3.2"); -@import url("base.css?v=3.2"); -@import url("utilities.css?v=3.2"); -@import url("common.css?v=3.2"); -@import url("links.css?v=3.2"); -@import url("content.css?v=3.2"); -@import url("buttons.css?v=3.2"); -@import url("cp.css?v=3.2"); -@import url("forms.css?v=3.2"); -@import url("icons.css?v=3.2"); -@import url("colours.css?v=3.2"); -@import url("responsive.css?v=3.2"); +@import url("normalize.css?v=3.3"); +@import url("base.css?v=3.3"); +@import url("utilities.css?v=3.3"); +@import url("common.css?v=3.3"); +@import url("links.css?v=3.3"); +@import url("content.css?v=3.3"); +@import url("buttons.css?v=3.3"); +@import url("cp.css?v=3.3"); +@import url("forms.css?v=3.3"); +@import url("icons.css?v=3.3"); +@import url("colours.css?v=3.3"); +@import url("responsive.css?v=3.3"); diff --git a/vendor/guzzlehttp/guzzle/src/BatchResults.php b/vendor/guzzlehttp/guzzle/src/BatchResults.php deleted file mode 100644 index e5af433..0000000 --- a/vendor/guzzlehttp/guzzle/src/BatchResults.php +++ /dev/null @@ -1,148 +0,0 @@ -hash = $hash; - } - - /** - * Get the keys that are available on the batch result. - * - * @return array - */ - public function getKeys() - { - return iterator_to_array($this->hash); - } - - /** - * Gets a result from the container for the given object. When getting - * results for a batch of requests, provide the request object. - * - * @param object $forObject Object to retrieve the result for. - * - * @return mixed|null - */ - public function getResult($forObject) - { - return isset($this->hash[$forObject]) ? $this->hash[$forObject] : null; - } - - /** - * Get an array of successful results. - * - * @return array - */ - public function getSuccessful() - { - $results = []; - foreach ($this->hash as $key) { - if (!($this->hash[$key] instanceof \Exception)) { - $results[] = $this->hash[$key]; - } - } - - return $results; - } - - /** - * Get an array of failed results. - * - * @return array - */ - public function getFailures() - { - $results = []; - foreach ($this->hash as $key) { - if ($this->hash[$key] instanceof \Exception) { - $results[] = $this->hash[$key]; - } - } - - return $results; - } - - /** - * Allows iteration over all batch result values. - * - * @return \ArrayIterator - */ - public function getIterator() - { - $results = []; - foreach ($this->hash as $key) { - $results[] = $this->hash[$key]; - } - - return new \ArrayIterator($results); - } - - /** - * Counts the number of elements in the batch result. - * - * @return int - */ - public function count() - { - return count($this->hash); - } - - /** - * Checks if the batch contains a specific numerical array index. - * - * @param int $key Index to access - * - * @return bool - */ - public function offsetExists($key) - { - return $key < count($this->hash); - } - - /** - * Allows access of the batch using a numerical array index. - * - * @param int $key Index to access. - * - * @return mixed|null - */ - public function offsetGet($key) - { - $i = -1; - foreach ($this->hash as $obj) { - if ($key === ++$i) { - return $this->hash[$obj]; - } - } - - return null; - } - - public function offsetUnset($key) - { - throw new \RuntimeException('Not implemented'); - } - - public function offsetSet($key, $value) - { - throw new \RuntimeException('Not implemented'); - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Collection.php b/vendor/guzzlehttp/guzzle/src/Collection.php deleted file mode 100644 index 4aabd20..0000000 --- a/vendor/guzzlehttp/guzzle/src/Collection.php +++ /dev/null @@ -1,236 +0,0 @@ -data = $data; - } - - /** - * Create a new collection from an array, validate the keys, and add default - * values where missing - * - * @param array $config Configuration values to apply. - * @param array $defaults Default parameters - * @param array $required Required parameter names - * - * @return self - * @throws \InvalidArgumentException if a parameter is missing - */ - public static function fromConfig( - array $config = [], - array $defaults = [], - array $required = [] - ) { - $data = $config + $defaults; - - if ($missing = array_diff($required, array_keys($data))) { - throw new \InvalidArgumentException( - 'Config is missing the following keys: ' . - implode(', ', $missing)); - } - - return new self($data); - } - - /** - * Removes all key value pairs - */ - public function clear() - { - $this->data = []; - } - - /** - * Get a specific key value. - * - * @param string $key Key to retrieve. - * - * @return mixed|null Value of the key or NULL - */ - public function get($key) - { - return isset($this->data[$key]) ? $this->data[$key] : null; - } - - /** - * Set a key value pair - * - * @param string $key Key to set - * @param mixed $value Value to set - */ - public function set($key, $value) - { - $this->data[$key] = $value; - } - - /** - * Add a value to a key. If a key of the same name has already been added, - * the key value will be converted into an array and the new value will be - * pushed to the end of the array. - * - * @param string $key Key to add - * @param mixed $value Value to add to the key - */ - public function add($key, $value) - { - if (!array_key_exists($key, $this->data)) { - $this->data[$key] = $value; - } elseif (is_array($this->data[$key])) { - $this->data[$key][] = $value; - } else { - $this->data[$key] = array($this->data[$key], $value); - } - } - - /** - * Remove a specific key value pair - * - * @param string $key A key to remove - */ - public function remove($key) - { - unset($this->data[$key]); - } - - /** - * Get all keys in the collection - * - * @return array - */ - public function getKeys() - { - return array_keys($this->data); - } - - /** - * Returns whether or not the specified key is present. - * - * @param string $key The key for which to check the existence. - * - * @return bool - */ - public function hasKey($key) - { - return array_key_exists($key, $this->data); - } - - /** - * Checks if any keys contains a certain value - * - * @param string $value Value to search for - * - * @return mixed Returns the key if the value was found FALSE if the value - * was not found. - */ - public function hasValue($value) - { - return array_search($value, $this->data, true); - } - - /** - * Replace the data of the object with the value of an array - * - * @param array $data Associative array of data - */ - public function replace(array $data) - { - $this->data = $data; - } - - /** - * Add and merge in a Collection or array of key value pair data. - * - * @param Collection|array $data Associative array of key value pair data - */ - public function merge($data) - { - foreach ($data as $key => $value) { - $this->add($key, $value); - } - } - - /** - * Overwrite key value pairs in this collection with all of the data from - * an array or collection. - * - * @param array|\Traversable $data Values to override over this config - */ - public function overwriteWith($data) - { - if (is_array($data)) { - $this->data = $data + $this->data; - } elseif ($data instanceof Collection) { - $this->data = $data->toArray() + $this->data; - } else { - foreach ($data as $key => $value) { - $this->data[$key] = $value; - } - } - } - - /** - * Returns a Collection containing all the elements of the collection after - * applying the callback function to each one. - * - * The callable should accept three arguments: - * - (string) $key - * - (string) $value - * - (array) $context - * - * The callable must return a the altered or unaltered value. - * - * @param callable $closure Map function to apply - * @param array $context Context to pass to the callable - * - * @return Collection - */ - public function map(callable $closure, array $context = []) - { - $collection = new static(); - foreach ($this as $key => $value) { - $collection[$key] = $closure($key, $value, $context); - } - - return $collection; - } - - /** - * Iterates over each key value pair in the collection passing them to the - * callable. If the callable returns true, the current value from input is - * returned into the result Collection. - * - * The callable must accept two arguments: - * - (string) $key - * - (string) $value - * - * @param callable $closure Evaluation function - * - * @return Collection - */ - public function filter(callable $closure) - { - $collection = new static(); - foreach ($this->data as $key => $value) { - if ($closure($key, $value)) { - $collection[$key] = $value; - } - } - - return $collection; - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Event/AbstractEvent.php b/vendor/guzzlehttp/guzzle/src/Event/AbstractEvent.php deleted file mode 100644 index 0d2f4db..0000000 --- a/vendor/guzzlehttp/guzzle/src/Event/AbstractEvent.php +++ /dev/null @@ -1,20 +0,0 @@ -propagationStopped; - } - - public function stopPropagation() - { - $this->propagationStopped = true; - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Event/AbstractRequestEvent.php b/vendor/guzzlehttp/guzzle/src/Event/AbstractRequestEvent.php deleted file mode 100644 index 8a6ee47..0000000 --- a/vendor/guzzlehttp/guzzle/src/Event/AbstractRequestEvent.php +++ /dev/null @@ -1,61 +0,0 @@ -transaction = $transaction; - } - - /** - * Get the HTTP client associated with the event. - * - * @return ClientInterface - */ - public function getClient() - { - return $this->transaction->client; - } - - /** - * Get the request object - * - * @return RequestInterface - */ - public function getRequest() - { - return $this->transaction->request; - } - - /** - * Get the number of transaction retries. - * - * @return int - */ - public function getRetryCount() - { - return $this->transaction->retries; - } - - /** - * @return Transaction - */ - public function getTransaction() - { - return $this->transaction; - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Event/AbstractRetryableEvent.php b/vendor/guzzlehttp/guzzle/src/Event/AbstractRetryableEvent.php deleted file mode 100644 index bbbdfaf..0000000 --- a/vendor/guzzlehttp/guzzle/src/Event/AbstractRetryableEvent.php +++ /dev/null @@ -1,40 +0,0 @@ -transaction->state = 'retry'; - - if ($afterDelay) { - $this->transaction->request->getConfig()->set('delay', $afterDelay); - } - - $this->stopPropagation(); - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Event/AbstractTransferEvent.php b/vendor/guzzlehttp/guzzle/src/Event/AbstractTransferEvent.php deleted file mode 100644 index 3b106df..0000000 --- a/vendor/guzzlehttp/guzzle/src/Event/AbstractTransferEvent.php +++ /dev/null @@ -1,63 +0,0 @@ -transaction->transferInfo; - } - - return isset($this->transaction->transferInfo[$name]) - ? $this->transaction->transferInfo[$name] - : null; - } - - /** - * Returns true/false if a response is available. - * - * @return bool - */ - public function hasResponse() - { - return !($this->transaction->response instanceof FutureInterface); - } - - /** - * Get the response. - * - * @return ResponseInterface|null - */ - public function getResponse() - { - return $this->hasResponse() ? $this->transaction->response : null; - } - - /** - * Intercept the request and associate a response - * - * @param ResponseInterface $response Response to set - */ - public function intercept(ResponseInterface $response) - { - $this->transaction->response = $response; - $this->transaction->exception = null; - $this->stopPropagation(); - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Event/BeforeEvent.php b/vendor/guzzlehttp/guzzle/src/Event/BeforeEvent.php deleted file mode 100644 index f313c37..0000000 --- a/vendor/guzzlehttp/guzzle/src/Event/BeforeEvent.php +++ /dev/null @@ -1,26 +0,0 @@ -transaction->response = $response; - $this->transaction->exception = null; - $this->stopPropagation(); - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Event/CompleteEvent.php b/vendor/guzzlehttp/guzzle/src/Event/CompleteEvent.php deleted file mode 100644 index 56cc557..0000000 --- a/vendor/guzzlehttp/guzzle/src/Event/CompleteEvent.php +++ /dev/null @@ -1,14 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - * - * @link https://github.com/symfony/symfony/tree/master/src/Symfony/Component/EventDispatcher - */ -class Emitter implements EmitterInterface -{ - /** @var array */ - private $listeners = []; - - /** @var array */ - private $sorted = []; - - public function on($eventName, callable $listener, $priority = 0) - { - if ($priority === 'first') { - $priority = isset($this->listeners[$eventName]) - ? max(array_keys($this->listeners[$eventName])) + 1 - : 1; - } elseif ($priority === 'last') { - $priority = isset($this->listeners[$eventName]) - ? min(array_keys($this->listeners[$eventName])) - 1 - : -1; - } - - $this->listeners[$eventName][$priority][] = $listener; - unset($this->sorted[$eventName]); - } - - public function once($eventName, callable $listener, $priority = 0) - { - $onceListener = function ( - EventInterface $event - ) use (&$onceListener, $eventName, $listener, $priority) { - $this->removeListener($eventName, $onceListener); - $listener($event, $eventName); - }; - - $this->on($eventName, $onceListener, $priority); - } - - public function removeListener($eventName, callable $listener) - { - if (empty($this->listeners[$eventName])) { - return; - } - - foreach ($this->listeners[$eventName] as $priority => $listeners) { - if (false !== ($key = array_search($listener, $listeners, true))) { - unset( - $this->listeners[$eventName][$priority][$key], - $this->sorted[$eventName] - ); - } - } - } - - public function listeners($eventName = null) - { - // Return all events in a sorted priority order - if ($eventName === null) { - foreach (array_keys($this->listeners) as $eventName) { - if (empty($this->sorted[$eventName])) { - $this->listeners($eventName); - } - } - return $this->sorted; - } - - // Return the listeners for a specific event, sorted in priority order - if (empty($this->sorted[$eventName])) { - $this->sorted[$eventName] = []; - if (isset($this->listeners[$eventName])) { - krsort($this->listeners[$eventName], SORT_NUMERIC); - foreach ($this->listeners[$eventName] as $listeners) { - foreach ($listeners as $listener) { - $this->sorted[$eventName][] = $listener; - } - } - } - } - - return $this->sorted[$eventName]; - } - - public function hasListeners($eventName) - { - return !empty($this->listeners[$eventName]); - } - - public function emit($eventName, EventInterface $event) - { - if (isset($this->listeners[$eventName])) { - foreach ($this->listeners($eventName) as $listener) { - $listener($event, $eventName); - if ($event->isPropagationStopped()) { - break; - } - } - } - - return $event; - } - - public function attach(SubscriberInterface $subscriber) - { - foreach ($subscriber->getEvents() as $eventName => $listeners) { - if (is_array($listeners[0])) { - foreach ($listeners as $listener) { - $this->on( - $eventName, - [$subscriber, $listener[0]], - isset($listener[1]) ? $listener[1] : 0 - ); - } - } else { - $this->on( - $eventName, - [$subscriber, $listeners[0]], - isset($listeners[1]) ? $listeners[1] : 0 - ); - } - } - } - - public function detach(SubscriberInterface $subscriber) - { - foreach ($subscriber->getEvents() as $eventName => $listener) { - $this->removeListener($eventName, [$subscriber, $listener[0]]); - } - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Event/EmitterInterface.php b/vendor/guzzlehttp/guzzle/src/Event/EmitterInterface.php deleted file mode 100644 index 9783efd..0000000 --- a/vendor/guzzlehttp/guzzle/src/Event/EmitterInterface.php +++ /dev/null @@ -1,96 +0,0 @@ -transaction->exception; - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Event/ErrorEvent.php b/vendor/guzzlehttp/guzzle/src/Event/ErrorEvent.php deleted file mode 100644 index 7432134..0000000 --- a/vendor/guzzlehttp/guzzle/src/Event/ErrorEvent.php +++ /dev/null @@ -1,27 +0,0 @@ -transaction->exception; - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Event/EventInterface.php b/vendor/guzzlehttp/guzzle/src/Event/EventInterface.php deleted file mode 100644 index 97247e8..0000000 --- a/vendor/guzzlehttp/guzzle/src/Event/EventInterface.php +++ /dev/null @@ -1,23 +0,0 @@ -emitter) { - $this->emitter = new Emitter(); - } - - return $this->emitter; - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Event/ListenerAttacherTrait.php b/vendor/guzzlehttp/guzzle/src/Event/ListenerAttacherTrait.php deleted file mode 100644 index 407dc92..0000000 --- a/vendor/guzzlehttp/guzzle/src/Event/ListenerAttacherTrait.php +++ /dev/null @@ -1,88 +0,0 @@ -getEmitter(); - foreach ($listeners as $el) { - if ($el['once']) { - $emitter->once($el['name'], $el['fn'], $el['priority']); - } else { - $emitter->on($el['name'], $el['fn'], $el['priority']); - } - } - } - - /** - * Extracts the allowed events from the provided array, and ignores anything - * else in the array. The event listener must be specified as a callable or - * as an array of event listener data ("name", "fn", "priority", "once"). - * - * @param array $source Array containing callables or hashes of data to be - * prepared as event listeners. - * @param array $events Names of events to look for in the provided $source - * array. Other keys are ignored. - * @return array - */ - private function prepareListeners(array $source, array $events) - { - $listeners = []; - foreach ($events as $name) { - if (isset($source[$name])) { - $this->buildListener($name, $source[$name], $listeners); - } - } - - return $listeners; - } - - /** - * Creates a complete event listener definition from the provided array of - * listener data. Also works recursively if more than one listeners are - * contained in the provided array. - * - * @param string $name Name of the event the listener is for. - * @param array|callable $data Event listener data to prepare. - * @param array $listeners Array of listeners, passed by reference. - * - * @throws \InvalidArgumentException if the event data is malformed. - */ - private function buildListener($name, $data, &$listeners) - { - static $defaults = ['priority' => 0, 'once' => false]; - - // If a callable is provided, normalize it to the array format. - if (is_callable($data)) { - $data = ['fn' => $data]; - } - - // Prepare the listener and add it to the array, recursively. - if (isset($data['fn'])) { - $data['name'] = $name; - $listeners[] = $data + $defaults; - } elseif (is_array($data)) { - foreach ($data as $listenerData) { - $this->buildListener($name, $listenerData, $listeners); - } - } else { - throw new \InvalidArgumentException('Each event listener must be a ' - . 'callable or an associative array containing a "fn" key.'); - } - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Event/ProgressEvent.php b/vendor/guzzlehttp/guzzle/src/Event/ProgressEvent.php deleted file mode 100644 index 3fd0de4..0000000 --- a/vendor/guzzlehttp/guzzle/src/Event/ProgressEvent.php +++ /dev/null @@ -1,51 +0,0 @@ -downloadSize = $downloadSize; - $this->downloaded = $downloaded; - $this->uploadSize = $uploadSize; - $this->uploaded = $uploaded; - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Event/RequestEvents.php b/vendor/guzzlehttp/guzzle/src/Event/RequestEvents.php deleted file mode 100644 index f51d420..0000000 --- a/vendor/guzzlehttp/guzzle/src/Event/RequestEvents.php +++ /dev/null @@ -1,56 +0,0 @@ - ['methodName']] - * - ['eventName' => ['methodName', $priority]] - * - ['eventName' => [['methodName'], ['otherMethod']] - * - ['eventName' => [['methodName'], ['otherMethod', $priority]] - * - ['eventName' => [['methodName', $priority], ['otherMethod', $priority]] - * - * @return array - */ - public function getEvents(); -} diff --git a/vendor/guzzlehttp/guzzle/src/Exception/CouldNotRewindStreamException.php b/vendor/guzzlehttp/guzzle/src/Exception/CouldNotRewindStreamException.php deleted file mode 100644 index fbe2dcd..0000000 --- a/vendor/guzzlehttp/guzzle/src/Exception/CouldNotRewindStreamException.php +++ /dev/null @@ -1,4 +0,0 @@ -response = $response; - } - /** - * Get the associated response - * - * @return ResponseInterface|null - */ - public function getResponse() - { - return $this->response; - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Exception/StateException.php b/vendor/guzzlehttp/guzzle/src/Exception/StateException.php deleted file mode 100644 index a7652a3..0000000 --- a/vendor/guzzlehttp/guzzle/src/Exception/StateException.php +++ /dev/null @@ -1,4 +0,0 @@ -error = $error; - } - - /** - * Get the associated error - * - * @return \LibXMLError|null - */ - public function getError() - { - return $this->error; - } -} diff --git a/vendor/guzzlehttp/guzzle/src/HasDataTrait.php b/vendor/guzzlehttp/guzzle/src/HasDataTrait.php deleted file mode 100644 index 020dfc9..0000000 --- a/vendor/guzzlehttp/guzzle/src/HasDataTrait.php +++ /dev/null @@ -1,75 +0,0 @@ -data); - } - - public function offsetGet($offset) - { - return isset($this->data[$offset]) ? $this->data[$offset] : null; - } - - public function offsetSet($offset, $value) - { - $this->data[$offset] = $value; - } - - public function offsetExists($offset) - { - return isset($this->data[$offset]); - } - - public function offsetUnset($offset) - { - unset($this->data[$offset]); - } - - public function toArray() - { - return $this->data; - } - - public function count() - { - return count($this->data); - } - - /** - * Get a value from the collection using a path syntax to retrieve nested - * data. - * - * @param string $path Path to traverse and retrieve a value from - * - * @return mixed|null - */ - public function getPath($path) - { - return Utils::getPath($this->data, $path); - } - - /** - * Set a value into a nested array key. Keys will be created as needed to - * set the value. - * - * @param string $path Path to set - * @param mixed $value Value to set at the key - * - * @throws \RuntimeException when trying to setPath using a nested path - * that travels through a scalar value - */ - public function setPath($path, $value) - { - Utils::setPath($this->data, $path, $value); - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Message/AbstractMessage.php b/vendor/guzzlehttp/guzzle/src/Message/AbstractMessage.php deleted file mode 100644 index f118e0f..0000000 --- a/vendor/guzzlehttp/guzzle/src/Message/AbstractMessage.php +++ /dev/null @@ -1,253 +0,0 @@ -getBody(); - } - - public function getProtocolVersion() - { - return $this->protocolVersion; - } - - public function getBody() - { - return $this->body; - } - - public function setBody(StreamInterface $body = null) - { - if ($body === null) { - // Setting a null body will remove the body of the request - $this->removeHeader('Content-Length'); - $this->removeHeader('Transfer-Encoding'); - } - - $this->body = $body; - } - - public function addHeader($header, $value) - { - if (is_array($value)) { - $current = array_merge($this->getHeaderAsArray($header), $value); - } else { - $current = $this->getHeaderAsArray($header); - $current[] = (string) $value; - } - - $this->setHeader($header, $current); - } - - public function addHeaders(array $headers) - { - foreach ($headers as $name => $header) { - $this->addHeader($name, $header); - } - } - - public function getHeader($header) - { - $name = strtolower($header); - return isset($this->headers[$name]) - ? implode(', ', $this->headers[$name]) - : ''; - } - - public function getHeaderAsArray($header) - { - $name = strtolower($header); - return isset($this->headers[$name]) ? $this->headers[$name] : []; - } - - public function getHeaders() - { - $headers = []; - foreach ($this->headers as $name => $values) { - $headers[$this->headerNames[$name]] = $values; - } - - return $headers; - } - - public function setHeader($header, $value) - { - $header = trim($header); - $name = strtolower($header); - $this->headerNames[$name] = $header; - - if (is_array($value)) { - foreach ($value as &$v) { - $v = trim($v); - } - $this->headers[$name] = $value; - } else { - $this->headers[$name] = [trim($value)]; - } - } - - public function setHeaders(array $headers) - { - $this->headers = $this->headerNames = []; - foreach ($headers as $key => $value) { - $this->addHeader($key, $value); - } - } - - public function hasHeader($header) - { - return isset($this->headers[strtolower($header)]); - } - - public function removeHeader($header) - { - $name = strtolower($header); - unset($this->headers[$name], $this->headerNames[$name]); - } - - /** - * Parse an array of header values containing ";" separated data into an - * array of associative arrays representing the header key value pair - * data of the header. When a parameter does not contain a value, but just - * contains a key, this function will inject a key with a '' string value. - * - * @param MessageInterface $message That contains the header - * @param string $header Header to retrieve from the message - * - * @return array Returns the parsed header values. - */ - public static function parseHeader(MessageInterface $message, $header) - { - static $trimmed = "\"' \n\t\r"; - $params = $matches = []; - - foreach (self::normalizeHeader($message, $header) as $val) { - $part = []; - foreach (preg_split('/;(?=([^"]*"[^"]*")*[^"]*$)/', $val) as $kvp) { - if (preg_match_all('/<[^>]+>|[^=]+/', $kvp, $matches)) { - $m = $matches[0]; - if (isset($m[1])) { - $part[trim($m[0], $trimmed)] = trim($m[1], $trimmed); - } else { - $part[] = trim($m[0], $trimmed); - } - } - } - if ($part) { - $params[] = $part; - } - } - - return $params; - } - - /** - * Converts an array of header values that may contain comma separated - * headers into an array of headers with no comma separated values. - * - * @param MessageInterface $message That contains the header - * @param string $header Header to retrieve from the message - * - * @return array Returns the normalized header field values. - */ - public static function normalizeHeader(MessageInterface $message, $header) - { - $h = $message->getHeaderAsArray($header); - for ($i = 0, $total = count($h); $i < $total; $i++) { - if (strpos($h[$i], ',') === false) { - continue; - } - foreach (preg_split('/,(?=([^"]*"[^"]*")*[^"]*$)/', $h[$i]) as $v) { - $h[] = trim($v); - } - unset($h[$i]); - } - - return $h; - } - - /** - * Gets the start-line and headers of a message as a string - * - * @param MessageInterface $message - * - * @return string - */ - public static function getStartLineAndHeaders(MessageInterface $message) - { - return static::getStartLine($message) - . self::getHeadersAsString($message); - } - - /** - * Gets the headers of a message as a string - * - * @param MessageInterface $message - * - * @return string - */ - public static function getHeadersAsString(MessageInterface $message) - { - $result = ''; - foreach ($message->getHeaders() as $name => $values) { - $result .= "\r\n{$name}: " . implode(', ', $values); - } - - return $result; - } - - /** - * Gets the start line of a message - * - * @param MessageInterface $message - * - * @return string - * @throws \InvalidArgumentException - */ - public static function getStartLine(MessageInterface $message) - { - if ($message instanceof RequestInterface) { - return trim($message->getMethod() . ' ' - . $message->getResource()) - . ' HTTP/' . $message->getProtocolVersion(); - } elseif ($message instanceof ResponseInterface) { - return 'HTTP/' . $message->getProtocolVersion() . ' ' - . $message->getStatusCode() . ' ' - . $message->getReasonPhrase(); - } else { - throw new \InvalidArgumentException('Unknown message type'); - } - } - - /** - * Accepts and modifies the options provided to the message in the - * constructor. - * - * Can be overridden in subclasses as necessary. - * - * @param array $options Options array passed by reference. - */ - protected function handleOptions(array &$options) - { - if (isset($options['protocol_version'])) { - $this->protocolVersion = $options['protocol_version']; - } - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Message/AppliesHeadersInterface.php b/vendor/guzzlehttp/guzzle/src/Message/AppliesHeadersInterface.php deleted file mode 100644 index ca42f20..0000000 --- a/vendor/guzzlehttp/guzzle/src/Message/AppliesHeadersInterface.php +++ /dev/null @@ -1,24 +0,0 @@ -then($onFulfilled, $onRejected, $onProgress), - [$future, 'wait'], - [$future, 'cancel'] - ); - } - - public function getStatusCode() - { - return $this->_value->getStatusCode(); - } - - public function setStatusCode($code) - { - $this->_value->setStatusCode($code); - } - - public function getReasonPhrase() - { - return $this->_value->getReasonPhrase(); - } - - public function setReasonPhrase($phrase) - { - $this->_value->setReasonPhrase($phrase); - } - - public function getEffectiveUrl() - { - return $this->_value->getEffectiveUrl(); - } - - public function setEffectiveUrl($url) - { - $this->_value->setEffectiveUrl($url); - } - - public function json(array $config = []) - { - return $this->_value->json($config); - } - - public function xml(array $config = []) - { - return $this->_value->xml($config); - } - - public function __toString() - { - try { - return $this->_value->__toString(); - } catch (\Exception $e) { - trigger_error($e->getMessage(), E_USER_WARNING); - return ''; - } - } - - public function getProtocolVersion() - { - return $this->_value->getProtocolVersion(); - } - - public function setBody(StreamInterface $body = null) - { - $this->_value->setBody($body); - } - - public function getBody() - { - return $this->_value->getBody(); - } - - public function getHeaders() - { - return $this->_value->getHeaders(); - } - - public function getHeader($header) - { - return $this->_value->getHeader($header); - } - - public function getHeaderAsArray($header) - { - return $this->_value->getHeaderAsArray($header); - } - - public function hasHeader($header) - { - return $this->_value->hasHeader($header); - } - - public function removeHeader($header) - { - $this->_value->removeHeader($header); - } - - public function addHeader($header, $value) - { - $this->_value->addHeader($header, $value); - } - - public function addHeaders(array $headers) - { - $this->_value->addHeaders($headers); - } - - public function setHeader($header, $value) - { - $this->_value->setHeader($header, $value); - } - - public function setHeaders(array $headers) - { - $this->_value->setHeaders($headers); - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Message/MessageFactory.php b/vendor/guzzlehttp/guzzle/src/Message/MessageFactory.php deleted file mode 100644 index b366d6d..0000000 --- a/vendor/guzzlehttp/guzzle/src/Message/MessageFactory.php +++ /dev/null @@ -1,364 +0,0 @@ - 1, 'timeout' => 1, 'verify' => 1, 'ssl_key' => 1, - 'cert' => 1, 'proxy' => 1, 'debug' => 1, 'save_to' => 1, 'stream' => 1, - 'expect' => 1, 'future' => 1 - ]; - - /** @var array Default allow_redirects request option settings */ - private static $defaultRedirect = [ - 'max' => 5, - 'strict' => false, - 'referer' => false, - 'protocols' => ['http', 'https'] - ]; - - /** - * @param array $customOptions Associative array of custom request option - * names mapping to functions used to apply - * the option. The function accepts the request - * and the option value to apply. - */ - public function __construct(array $customOptions = []) - { - $this->errorPlugin = new HttpError(); - $this->redirectPlugin = new Redirect(); - $this->customOptions = $customOptions; - } - - public function createResponse( - $statusCode, - array $headers = [], - $body = null, - array $options = [] - ) { - if (null !== $body) { - $body = Stream::factory($body); - } - - return new Response($statusCode, $headers, $body, $options); - } - - public function createRequest($method, $url, array $options = []) - { - // Handle the request protocol version option that needs to be - // specified in the request constructor. - if (isset($options['version'])) { - $options['config']['protocol_version'] = $options['version']; - unset($options['version']); - } - - $request = new Request($method, $url, [], null, - isset($options['config']) ? $options['config'] : []); - - unset($options['config']); - - // Use a POST body by default - if (strtoupper($method) == 'POST' - && !isset($options['body']) - && !isset($options['json']) - ) { - $options['body'] = []; - } - - if ($options) { - $this->applyOptions($request, $options); - } - - return $request; - } - - /** - * Create a request or response object from an HTTP message string - * - * @param string $message Message to parse - * - * @return RequestInterface|ResponseInterface - * @throws \InvalidArgumentException if unable to parse a message - */ - public function fromMessage($message) - { - static $parser; - if (!$parser) { - $parser = new MessageParser(); - } - - // Parse a response - if (strtoupper(substr($message, 0, 4)) == 'HTTP') { - $data = $parser->parseResponse($message); - return $this->createResponse( - $data['code'], - $data['headers'], - $data['body'] === '' ? null : $data['body'], - $data - ); - } - - // Parse a request - if (!($data = ($parser->parseRequest($message)))) { - throw new \InvalidArgumentException('Unable to parse request'); - } - - return $this->createRequest( - $data['method'], - Url::buildUrl($data['request_url']), - [ - 'headers' => $data['headers'], - 'body' => $data['body'] === '' ? null : $data['body'], - 'config' => [ - 'protocol_version' => $data['protocol_version'] - ] - ] - ); - } - - /** - * Apply POST fields and files to a request to attempt to give an accurate - * representation. - * - * @param RequestInterface $request Request to update - * @param array $body Body to apply - */ - protected function addPostData(RequestInterface $request, array $body) - { - static $fields = ['string' => true, 'array' => true, 'NULL' => true, - 'boolean' => true, 'double' => true, 'integer' => true]; - - $post = new PostBody(); - foreach ($body as $key => $value) { - if (isset($fields[gettype($value)])) { - $post->setField($key, $value); - } elseif ($value instanceof PostFileInterface) { - $post->addFile($value); - } else { - $post->addFile(new PostFile($key, $value)); - } - } - - if ($request->getHeader('Content-Type') == 'multipart/form-data') { - $post->forceMultipartUpload(true); - } - - $request->setBody($post); - } - - protected function applyOptions( - RequestInterface $request, - array $options = [] - ) { - $config = $request->getConfig(); - $emitter = $request->getEmitter(); - - foreach ($options as $key => $value) { - - if (isset(self::$configMap[$key])) { - $config[$key] = $value; - continue; - } - - switch ($key) { - - case 'allow_redirects': - - if ($value === false) { - continue 2; - } - - if ($value === true) { - $value = self::$defaultRedirect; - } elseif (!is_array($value)) { - throw new Iae('allow_redirects must be true, false, or array'); - } else { - // Merge the default settings with the provided settings - $value += self::$defaultRedirect; - } - - $config['redirect'] = $value; - $emitter->attach($this->redirectPlugin); - break; - - case 'decode_content': - - if ($value === false) { - continue 2; - } - - $config['decode_content'] = true; - if ($value !== true) { - $request->setHeader('Accept-Encoding', $value); - } - break; - - case 'headers': - - if (!is_array($value)) { - throw new Iae('header value must be an array'); - } - foreach ($value as $k => $v) { - $request->setHeader($k, $v); - } - break; - - case 'exceptions': - - if ($value === true) { - $emitter->attach($this->errorPlugin); - } - break; - - case 'body': - - if (is_array($value)) { - $this->addPostData($request, $value); - } elseif ($value !== null) { - $request->setBody(Stream::factory($value)); - } - break; - - case 'auth': - - if (!$value) { - continue 2; - } - - if (is_array($value)) { - $type = isset($value[2]) ? strtolower($value[2]) : 'basic'; - } else { - $type = strtolower($value); - } - - $config['auth'] = $value; - - if ($type == 'basic') { - $request->setHeader( - 'Authorization', - 'Basic ' . base64_encode("$value[0]:$value[1]") - ); - } elseif ($type == 'digest') { - // @todo: Do not rely on curl - $config->setPath('curl/' . CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); - $config->setPath('curl/' . CURLOPT_USERPWD, "$value[0]:$value[1]"); - } - break; - - case 'query': - - if ($value instanceof Query) { - $original = $request->getQuery(); - // Do not overwrite existing query string variables by - // overwriting the object with the query string data passed - // in the URL - $value->overwriteWith($original->toArray()); - $request->setQuery($value); - } elseif (is_array($value)) { - // Do not overwrite existing query string variables - $query = $request->getQuery(); - foreach ($value as $k => $v) { - if (!isset($query[$k])) { - $query[$k] = $v; - } - } - } else { - throw new Iae('query must be an array or Query object'); - } - break; - - case 'cookies': - - if ($value === true) { - static $cookie = null; - if (!$cookie) { - $cookie = new Cookie(); - } - $emitter->attach($cookie); - } elseif (is_array($value)) { - $emitter->attach( - new Cookie(CookieJar::fromArray($value, $request->getHost())) - ); - } elseif ($value instanceof CookieJarInterface) { - $emitter->attach(new Cookie($value)); - } elseif ($value !== false) { - throw new Iae('cookies must be an array, true, or CookieJarInterface'); - } - break; - - case 'events': - - if (!is_array($value)) { - throw new Iae('events must be an array'); - } - - $this->attachListeners($request, - $this->prepareListeners( - $value, - ['before', 'complete', 'error', 'progress', 'end'] - ) - ); - break; - - case 'subscribers': - - if (!is_array($value)) { - throw new Iae('subscribers must be an array'); - } - - foreach ($value as $subscribers) { - $emitter->attach($subscribers); - } - break; - - case 'json': - - $request->setBody(Stream::factory(json_encode($value))); - if (!$request->hasHeader('Content-Type')) { - $request->setHeader('Content-Type', 'application/json'); - } - break; - - default: - - // Check for custom handler functions. - if (isset($this->customOptions[$key])) { - $fn = $this->customOptions[$key]; - $fn($request, $value); - continue 2; - } - - throw new Iae("No method can handle the {$key} config key"); - } - } - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Message/MessageFactoryInterface.php b/vendor/guzzlehttp/guzzle/src/Message/MessageFactoryInterface.php deleted file mode 100644 index 86ae9c7..0000000 --- a/vendor/guzzlehttp/guzzle/src/Message/MessageFactoryInterface.php +++ /dev/null @@ -1,71 +0,0 @@ -getHeaders() as $name => $values) { - * echo $name . ": " . implode(", ", $values); - * } - * - * @return array Returns an associative array of the message's headers. - */ - public function getHeaders(); - - /** - * Retrieve a header by the given case-insensitive name. - * - * @param string $header Case-insensitive header name. - * - * @return string - */ - public function getHeader($header); - - /** - * Retrieves a header by the given case-insensitive name as an array of strings. - * - * @param string $header Case-insensitive header name. - * - * @return string[] - */ - public function getHeaderAsArray($header); - - /** - * Checks if a header exists by the given case-insensitive name. - * - * @param string $header Case-insensitive header name. - * - * @return bool Returns true if any header names match the given header - * name using a case-insensitive string comparison. Returns false if - * no matching header name is found in the message. - */ - public function hasHeader($header); - - /** - * Remove a specific header by case-insensitive name. - * - * @param string $header Case-insensitive header name. - */ - public function removeHeader($header); - - /** - * Appends a header value to any existing values associated with the - * given header name. - * - * @param string $header Header name to add - * @param string $value Value of the header - */ - public function addHeader($header, $value); - - /** - * Merges in an associative array of headers. - * - * Each array key MUST be a string representing the case-insensitive name - * of a header. Each value MUST be either a string or an array of strings. - * For each value, the value is appended to any existing header of the same - * name, or, if a header does not already exist by the given name, then the - * header is added. - * - * @param array $headers Associative array of headers to add to the message - */ - public function addHeaders(array $headers); - - /** - * Sets a header, replacing any existing values of any headers with the - * same case-insensitive name. - * - * The header values MUST be a string or an array of strings. - * - * @param string $header Header name - * @param string|array $value Header value(s) - */ - public function setHeader($header, $value); - - /** - * Sets headers, replacing any headers that have already been set on the - * message. - * - * The array keys MUST be a string. The array values must be either a - * string or an array of strings. - * - * @param array $headers Headers to set. - */ - public function setHeaders(array $headers); -} diff --git a/vendor/guzzlehttp/guzzle/src/Message/MessageParser.php b/vendor/guzzlehttp/guzzle/src/Message/MessageParser.php deleted file mode 100644 index c3cc195..0000000 --- a/vendor/guzzlehttp/guzzle/src/Message/MessageParser.php +++ /dev/null @@ -1,171 +0,0 @@ -parseMessage($message))) { - return false; - } - - // Parse the protocol and protocol version - if (isset($parts['start_line'][2])) { - $startParts = explode('/', $parts['start_line'][2]); - $protocol = strtoupper($startParts[0]); - $version = isset($startParts[1]) ? $startParts[1] : '1.1'; - } else { - $protocol = 'HTTP'; - $version = '1.1'; - } - - $parsed = [ - 'method' => strtoupper($parts['start_line'][0]), - 'protocol' => $protocol, - 'protocol_version' => $version, - 'headers' => $parts['headers'], - 'body' => $parts['body'] - ]; - - $parsed['request_url'] = $this->getUrlPartsFromMessage( - (isset($parts['start_line'][1]) ? $parts['start_line'][1] : ''), $parsed); - - return $parsed; - } - - /** - * Parse an HTTP response message into an associative array of parts. - * - * @param string $message HTTP response to parse - * - * @return array|bool Returns false if the message is invalid - */ - public function parseResponse($message) - { - if (!($parts = $this->parseMessage($message))) { - return false; - } - - list($protocol, $version) = explode('/', trim($parts['start_line'][0])); - - return [ - 'protocol' => $protocol, - 'protocol_version' => $version, - 'code' => $parts['start_line'][1], - 'reason_phrase' => isset($parts['start_line'][2]) ? $parts['start_line'][2] : '', - 'headers' => $parts['headers'], - 'body' => $parts['body'] - ]; - } - - /** - * Parse a message into parts - * - * @param string $message Message to parse - * - * @return array|bool - */ - private function parseMessage($message) - { - if (!$message) { - return false; - } - - $startLine = null; - $headers = []; - $body = ''; - - // Iterate over each line in the message, accounting for line endings - $lines = preg_split('/(\\r?\\n)/', $message, -1, PREG_SPLIT_DELIM_CAPTURE); - for ($i = 0, $totalLines = count($lines); $i < $totalLines; $i += 2) { - - $line = $lines[$i]; - - // If two line breaks were encountered, then this is the end of body - if (empty($line)) { - if ($i < $totalLines - 1) { - $body = implode('', array_slice($lines, $i + 2)); - } - break; - } - - // Parse message headers - if (!$startLine) { - $startLine = explode(' ', $line, 3); - } elseif (strpos($line, ':')) { - $parts = explode(':', $line, 2); - $key = trim($parts[0]); - $value = isset($parts[1]) ? trim($parts[1]) : ''; - if (!isset($headers[$key])) { - $headers[$key] = $value; - } elseif (!is_array($headers[$key])) { - $headers[$key] = [$headers[$key], $value]; - } else { - $headers[$key][] = $value; - } - } - } - - return [ - 'start_line' => $startLine, - 'headers' => $headers, - 'body' => $body - ]; - } - - /** - * Create URL parts from HTTP message parts - * - * @param string $requestUrl Associated URL - * @param array $parts HTTP message parts - * - * @return array - */ - private function getUrlPartsFromMessage($requestUrl, array $parts) - { - // Parse the URL information from the message - $urlParts = ['path' => $requestUrl, 'scheme' => 'http']; - - // Check for the Host header - if (isset($parts['headers']['Host'])) { - $urlParts['host'] = $parts['headers']['Host']; - } elseif (isset($parts['headers']['host'])) { - $urlParts['host'] = $parts['headers']['host']; - } else { - $urlParts['host'] = null; - } - - if (false === strpos($urlParts['host'], ':')) { - $urlParts['port'] = ''; - } else { - $hostParts = explode(':', $urlParts['host']); - $urlParts['host'] = trim($hostParts[0]); - $urlParts['port'] = (int) trim($hostParts[1]); - if ($urlParts['port'] == 443) { - $urlParts['scheme'] = 'https'; - } - } - - // Check if a query is present - $path = $urlParts['path']; - $qpos = strpos($path, '?'); - if ($qpos) { - $urlParts['query'] = substr($path, $qpos + 1); - $urlParts['path'] = substr($path, 0, $qpos); - } else { - $urlParts['query'] = ''; - } - - return $urlParts; - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Message/Request.php b/vendor/guzzlehttp/guzzle/src/Message/Request.php deleted file mode 100644 index 38714af..0000000 --- a/vendor/guzzlehttp/guzzle/src/Message/Request.php +++ /dev/null @@ -1,195 +0,0 @@ -setUrl($url); - $this->method = strtoupper($method); - $this->handleOptions($options); - $this->transferOptions = new Collection($options); - $this->addPrepareEvent(); - - if ($body !== null) { - $this->setBody($body); - } - - if ($headers) { - foreach ($headers as $key => $value) { - $this->addHeader($key, $value); - } - } - } - - public function __clone() - { - if ($this->emitter) { - $this->emitter = clone $this->emitter; - } - $this->transferOptions = clone $this->transferOptions; - $this->url = clone $this->url; - } - - public function setUrl($url) - { - $this->url = $url instanceof Url ? $url : Url::fromString($url); - $this->updateHostHeaderFromUrl(); - } - - public function getUrl() - { - return (string) $this->url; - } - - public function setQuery($query) - { - $this->url->setQuery($query); - } - - public function getQuery() - { - return $this->url->getQuery(); - } - - public function setMethod($method) - { - $this->method = strtoupper($method); - } - - public function getMethod() - { - return $this->method; - } - - public function getScheme() - { - return $this->url->getScheme(); - } - - public function setScheme($scheme) - { - $this->url->setScheme($scheme); - } - - public function getPort() - { - return $this->url->getPort(); - } - - public function setPort($port) - { - $this->url->setPort($port); - $this->updateHostHeaderFromUrl(); - } - - public function getHost() - { - return $this->url->getHost(); - } - - public function setHost($host) - { - $this->url->setHost($host); - $this->updateHostHeaderFromUrl(); - } - - public function getPath() - { - return '/' . ltrim($this->url->getPath(), '/'); - } - - public function setPath($path) - { - $this->url->setPath($path); - } - - public function getResource() - { - $resource = $this->getPath(); - if ($query = (string) $this->url->getQuery()) { - $resource .= '?' . $query; - } - - return $resource; - } - - public function getConfig() - { - return $this->transferOptions; - } - - protected function handleOptions(array &$options) - { - parent::handleOptions($options); - // Use a custom emitter if one is specified, and remove it from - // options that are exposed through getConfig() - if (isset($options['emitter'])) { - $this->emitter = $options['emitter']; - unset($options['emitter']); - } - } - - /** - * Adds a subscriber that ensures a request's body is prepared before - * sending. - */ - private function addPrepareEvent() - { - static $subscriber; - if (!$subscriber) { - $subscriber = new Prepare(); - } - - $this->getEmitter()->attach($subscriber); - } - - private function updateHostHeaderFromUrl() - { - $port = $this->url->getPort(); - $scheme = $this->url->getScheme(); - if ($host = $this->url->getHost()) { - if (($port == 80 && $scheme == 'http') || - ($port == 443 && $scheme == 'https') - ) { - $this->setHeader('Host', $host); - } else { - $this->setHeader('Host', "{$host}:{$port}"); - } - } - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Message/RequestInterface.php b/vendor/guzzlehttp/guzzle/src/Message/RequestInterface.php deleted file mode 100644 index f6a69d1..0000000 --- a/vendor/guzzlehttp/guzzle/src/Message/RequestInterface.php +++ /dev/null @@ -1,136 +0,0 @@ - 'Continue', - 101 => 'Switching Protocols', - 102 => 'Processing', - 200 => 'OK', - 201 => 'Created', - 202 => 'Accepted', - 203 => 'Non-Authoritative Information', - 204 => 'No Content', - 205 => 'Reset Content', - 206 => 'Partial Content', - 207 => 'Multi-Status', - 208 => 'Already Reported', - 226 => 'IM Used', - 300 => 'Multiple Choices', - 301 => 'Moved Permanently', - 302 => 'Found', - 303 => 'See Other', - 304 => 'Not Modified', - 305 => 'Use Proxy', - 307 => 'Temporary Redirect', - 308 => 'Permanent Redirect', - 400 => 'Bad Request', - 401 => 'Unauthorized', - 402 => 'Payment Required', - 403 => 'Forbidden', - 404 => 'Not Found', - 405 => 'Method Not Allowed', - 406 => 'Not Acceptable', - 407 => 'Proxy Authentication Required', - 408 => 'Request Timeout', - 409 => 'Conflict', - 410 => 'Gone', - 411 => 'Length Required', - 412 => 'Precondition Failed', - 413 => 'Request Entity Too Large', - 414 => 'Request-URI Too Long', - 415 => 'Unsupported Media Type', - 416 => 'Requested Range Not Satisfiable', - 417 => 'Expectation Failed', - 422 => 'Unprocessable Entity', - 423 => 'Locked', - 424 => 'Failed Dependency', - 425 => 'Reserved for WebDAV advanced collections expired proposal', - 426 => 'Upgrade required', - 428 => 'Precondition Required', - 429 => 'Too Many Requests', - 431 => 'Request Header Fields Too Large', - 500 => 'Internal Server Error', - 501 => 'Not Implemented', - 502 => 'Bad Gateway', - 503 => 'Service Unavailable', - 504 => 'Gateway Timeout', - 505 => 'HTTP Version Not Supported', - 506 => 'Variant Also Negotiates (Experimental)', - 507 => 'Insufficient Storage', - 508 => 'Loop Detected', - 510 => 'Not Extended', - 511 => 'Network Authentication Required', - ]; - - /** @var string The reason phrase of the response (human readable code) */ - private $reasonPhrase; - - /** @var string The status code of the response */ - private $statusCode; - - /** @var string The effective URL that returned this response */ - private $effectiveUrl; - - /** - * @param int|string $statusCode The response status code (e.g. 200) - * @param array $headers The response headers - * @param StreamInterface $body The body of the response - * @param array $options Response message options - * - reason_phrase: Set a custom reason phrase - * - protocol_version: Set a custom protocol version - */ - public function __construct( - $statusCode, - array $headers = [], - StreamInterface $body = null, - array $options = [] - ) { - $this->statusCode = (int) $statusCode; - $this->handleOptions($options); - - // Assume a reason phrase if one was not applied as an option - if (!$this->reasonPhrase && - isset(self::$statusTexts[$this->statusCode]) - ) { - $this->reasonPhrase = self::$statusTexts[$this->statusCode]; - } - - if ($headers) { - $this->setHeaders($headers); - } - - if ($body) { - $this->setBody($body); - } - } - - public function getStatusCode() - { - return $this->statusCode; - } - - public function setStatusCode($code) - { - return $this->statusCode = (int) $code; - } - - public function getReasonPhrase() - { - return $this->reasonPhrase; - } - - public function setReasonPhrase($phrase) - { - return $this->reasonPhrase = $phrase; - } - - public function json(array $config = []) - { - try { - return Utils::jsonDecode( - (string) $this->getBody(), - isset($config['object']) ? !$config['object'] : true, - 512, - isset($config['big_int_strings']) ? JSON_BIGINT_AS_STRING : 0 - ); - } catch (\InvalidArgumentException $e) { - throw new ParseException( - $e->getMessage(), - $this - ); - } - } - - public function xml(array $config = []) - { - $disableEntities = libxml_disable_entity_loader(true); - $internalErrors = libxml_use_internal_errors(true); - - try { - // Allow XML to be retrieved even if there is no response body - $xml = new \SimpleXMLElement( - (string) $this->getBody() ?: '', - isset($config['libxml_options']) ? $config['libxml_options'] : LIBXML_NONET, - false, - isset($config['ns']) ? $config['ns'] : '', - isset($config['ns_is_prefix']) ? $config['ns_is_prefix'] : false - ); - libxml_disable_entity_loader($disableEntities); - libxml_use_internal_errors($internalErrors); - } catch (\Exception $e) { - libxml_disable_entity_loader($disableEntities); - libxml_use_internal_errors($internalErrors); - throw new XmlParseException( - 'Unable to parse response body into XML: ' . $e->getMessage(), - $this, - $e, - (libxml_get_last_error()) ?: null - ); - } - - return $xml; - } - - public function getEffectiveUrl() - { - return $this->effectiveUrl; - } - - public function setEffectiveUrl($url) - { - $this->effectiveUrl = $url; - } - - /** - * Accepts and modifies the options provided to the response in the - * constructor. - * - * @param array $options Options array passed by reference. - */ - protected function handleOptions(array &$options = []) - { - parent::handleOptions($options); - if (isset($options['reason_phrase'])) { - $this->reasonPhrase = $options['reason_phrase']; - } - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Message/ResponseInterface.php b/vendor/guzzlehttp/guzzle/src/Message/ResponseInterface.php deleted file mode 100644 index c0ae9be..0000000 --- a/vendor/guzzlehttp/guzzle/src/Message/ResponseInterface.php +++ /dev/null @@ -1,111 +0,0 @@ - 'text/vnd.in3d.3dml', - '3g2' => 'video/3gpp2', - '3gp' => 'video/3gpp', - '7z' => 'application/x-7z-compressed', - 'aab' => 'application/x-authorware-bin', - 'aac' => 'audio/x-aac', - 'aam' => 'application/x-authorware-map', - 'aas' => 'application/x-authorware-seg', - 'abw' => 'application/x-abiword', - 'ac' => 'application/pkix-attr-cert', - 'acc' => 'application/vnd.americandynamics.acc', - 'ace' => 'application/x-ace-compressed', - 'acu' => 'application/vnd.acucobol', - 'acutc' => 'application/vnd.acucorp', - 'adp' => 'audio/adpcm', - 'aep' => 'application/vnd.audiograph', - 'afm' => 'application/x-font-type1', - 'afp' => 'application/vnd.ibm.modcap', - 'ahead' => 'application/vnd.ahead.space', - 'ai' => 'application/postscript', - 'aif' => 'audio/x-aiff', - 'aifc' => 'audio/x-aiff', - 'aiff' => 'audio/x-aiff', - 'air' => 'application/vnd.adobe.air-application-installer-package+zip', - 'ait' => 'application/vnd.dvb.ait', - 'ami' => 'application/vnd.amiga.ami', - 'apk' => 'application/vnd.android.package-archive', - 'application' => 'application/x-ms-application', - 'apr' => 'application/vnd.lotus-approach', - 'asa' => 'text/plain', - 'asax' => 'application/octet-stream', - 'asc' => 'application/pgp-signature', - 'ascx' => 'text/plain', - 'asf' => 'video/x-ms-asf', - 'ashx' => 'text/plain', - 'asm' => 'text/x-asm', - 'asmx' => 'text/plain', - 'aso' => 'application/vnd.accpac.simply.aso', - 'asp' => 'text/plain', - 'aspx' => 'text/plain', - 'asx' => 'video/x-ms-asf', - 'atc' => 'application/vnd.acucorp', - 'atom' => 'application/atom+xml', - 'atomcat' => 'application/atomcat+xml', - 'atomsvc' => 'application/atomsvc+xml', - 'atx' => 'application/vnd.antix.game-component', - 'au' => 'audio/basic', - 'avi' => 'video/x-msvideo', - 'aw' => 'application/applixware', - 'axd' => 'text/plain', - 'azf' => 'application/vnd.airzip.filesecure.azf', - 'azs' => 'application/vnd.airzip.filesecure.azs', - 'azw' => 'application/vnd.amazon.ebook', - 'bat' => 'application/x-msdownload', - 'bcpio' => 'application/x-bcpio', - 'bdf' => 'application/x-font-bdf', - 'bdm' => 'application/vnd.syncml.dm+wbxml', - 'bed' => 'application/vnd.realvnc.bed', - 'bh2' => 'application/vnd.fujitsu.oasysprs', - 'bin' => 'application/octet-stream', - 'bmi' => 'application/vnd.bmi', - 'bmp' => 'image/bmp', - 'book' => 'application/vnd.framemaker', - 'box' => 'application/vnd.previewsystems.box', - 'boz' => 'application/x-bzip2', - 'bpk' => 'application/octet-stream', - 'btif' => 'image/prs.btif', - 'bz' => 'application/x-bzip', - 'bz2' => 'application/x-bzip2', - 'c' => 'text/x-c', - 'c11amc' => 'application/vnd.cluetrust.cartomobile-config', - 'c11amz' => 'application/vnd.cluetrust.cartomobile-config-pkg', - 'c4d' => 'application/vnd.clonk.c4group', - 'c4f' => 'application/vnd.clonk.c4group', - 'c4g' => 'application/vnd.clonk.c4group', - 'c4p' => 'application/vnd.clonk.c4group', - 'c4u' => 'application/vnd.clonk.c4group', - 'cab' => 'application/vnd.ms-cab-compressed', - 'car' => 'application/vnd.curl.car', - 'cat' => 'application/vnd.ms-pki.seccat', - 'cc' => 'text/x-c', - 'cct' => 'application/x-director', - 'ccxml' => 'application/ccxml+xml', - 'cdbcmsg' => 'application/vnd.contact.cmsg', - 'cdf' => 'application/x-netcdf', - 'cdkey' => 'application/vnd.mediastation.cdkey', - 'cdmia' => 'application/cdmi-capability', - 'cdmic' => 'application/cdmi-container', - 'cdmid' => 'application/cdmi-domain', - 'cdmio' => 'application/cdmi-object', - 'cdmiq' => 'application/cdmi-queue', - 'cdx' => 'chemical/x-cdx', - 'cdxml' => 'application/vnd.chemdraw+xml', - 'cdy' => 'application/vnd.cinderella', - 'cer' => 'application/pkix-cert', - 'cfc' => 'application/x-coldfusion', - 'cfm' => 'application/x-coldfusion', - 'cgm' => 'image/cgm', - 'chat' => 'application/x-chat', - 'chm' => 'application/vnd.ms-htmlhelp', - 'chrt' => 'application/vnd.kde.kchart', - 'cif' => 'chemical/x-cif', - 'cii' => 'application/vnd.anser-web-certificate-issue-initiation', - 'cil' => 'application/vnd.ms-artgalry', - 'cla' => 'application/vnd.claymore', - 'class' => 'application/java-vm', - 'clkk' => 'application/vnd.crick.clicker.keyboard', - 'clkp' => 'application/vnd.crick.clicker.palette', - 'clkt' => 'application/vnd.crick.clicker.template', - 'clkw' => 'application/vnd.crick.clicker.wordbank', - 'clkx' => 'application/vnd.crick.clicker', - 'clp' => 'application/x-msclip', - 'cmc' => 'application/vnd.cosmocaller', - 'cmdf' => 'chemical/x-cmdf', - 'cml' => 'chemical/x-cml', - 'cmp' => 'application/vnd.yellowriver-custom-menu', - 'cmx' => 'image/x-cmx', - 'cod' => 'application/vnd.rim.cod', - 'com' => 'application/x-msdownload', - 'conf' => 'text/plain', - 'cpio' => 'application/x-cpio', - 'cpp' => 'text/x-c', - 'cpt' => 'application/mac-compactpro', - 'crd' => 'application/x-mscardfile', - 'crl' => 'application/pkix-crl', - 'crt' => 'application/x-x509-ca-cert', - 'cryptonote' => 'application/vnd.rig.cryptonote', - 'cs' => 'text/plain', - 'csh' => 'application/x-csh', - 'csml' => 'chemical/x-csml', - 'csp' => 'application/vnd.commonspace', - 'css' => 'text/css', - 'cst' => 'application/x-director', - 'csv' => 'text/csv', - 'cu' => 'application/cu-seeme', - 'curl' => 'text/vnd.curl', - 'cww' => 'application/prs.cww', - 'cxt' => 'application/x-director', - 'cxx' => 'text/x-c', - 'dae' => 'model/vnd.collada+xml', - 'daf' => 'application/vnd.mobius.daf', - 'dataless' => 'application/vnd.fdsn.seed', - 'davmount' => 'application/davmount+xml', - 'dcr' => 'application/x-director', - 'dcurl' => 'text/vnd.curl.dcurl', - 'dd2' => 'application/vnd.oma.dd2+xml', - 'ddd' => 'application/vnd.fujixerox.ddd', - 'deb' => 'application/x-debian-package', - 'def' => 'text/plain', - 'deploy' => 'application/octet-stream', - 'der' => 'application/x-x509-ca-cert', - 'dfac' => 'application/vnd.dreamfactory', - 'dic' => 'text/x-c', - 'dir' => 'application/x-director', - 'dis' => 'application/vnd.mobius.dis', - 'dist' => 'application/octet-stream', - 'distz' => 'application/octet-stream', - 'djv' => 'image/vnd.djvu', - 'djvu' => 'image/vnd.djvu', - 'dll' => 'application/x-msdownload', - 'dmg' => 'application/octet-stream', - 'dms' => 'application/octet-stream', - 'dna' => 'application/vnd.dna', - 'doc' => 'application/msword', - 'docm' => 'application/vnd.ms-word.document.macroenabled.12', - 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', - 'dot' => 'application/msword', - 'dotm' => 'application/vnd.ms-word.template.macroenabled.12', - 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', - 'dp' => 'application/vnd.osgi.dp', - 'dpg' => 'application/vnd.dpgraph', - 'dra' => 'audio/vnd.dra', - 'dsc' => 'text/prs.lines.tag', - 'dssc' => 'application/dssc+der', - 'dtb' => 'application/x-dtbook+xml', - 'dtd' => 'application/xml-dtd', - 'dts' => 'audio/vnd.dts', - 'dtshd' => 'audio/vnd.dts.hd', - 'dump' => 'application/octet-stream', - 'dvi' => 'application/x-dvi', - 'dwf' => 'model/vnd.dwf', - 'dwg' => 'image/vnd.dwg', - 'dxf' => 'image/vnd.dxf', - 'dxp' => 'application/vnd.spotfire.dxp', - 'dxr' => 'application/x-director', - 'ecelp4800' => 'audio/vnd.nuera.ecelp4800', - 'ecelp7470' => 'audio/vnd.nuera.ecelp7470', - 'ecelp9600' => 'audio/vnd.nuera.ecelp9600', - 'ecma' => 'application/ecmascript', - 'edm' => 'application/vnd.novadigm.edm', - 'edx' => 'application/vnd.novadigm.edx', - 'efif' => 'application/vnd.picsel', - 'ei6' => 'application/vnd.pg.osasli', - 'elc' => 'application/octet-stream', - 'eml' => 'message/rfc822', - 'emma' => 'application/emma+xml', - 'eol' => 'audio/vnd.digital-winds', - 'eot' => 'application/vnd.ms-fontobject', - 'eps' => 'application/postscript', - 'epub' => 'application/epub+zip', - 'es3' => 'application/vnd.eszigno3+xml', - 'esf' => 'application/vnd.epson.esf', - 'et3' => 'application/vnd.eszigno3+xml', - 'etx' => 'text/x-setext', - 'exe' => 'application/x-msdownload', - 'exi' => 'application/exi', - 'ext' => 'application/vnd.novadigm.ext', - 'ez' => 'application/andrew-inset', - 'ez2' => 'application/vnd.ezpix-album', - 'ez3' => 'application/vnd.ezpix-package', - 'f' => 'text/x-fortran', - 'f4v' => 'video/x-f4v', - 'f77' => 'text/x-fortran', - 'f90' => 'text/x-fortran', - 'fbs' => 'image/vnd.fastbidsheet', - 'fcs' => 'application/vnd.isac.fcs', - 'fdf' => 'application/vnd.fdf', - 'fe_launch' => 'application/vnd.denovo.fcselayout-link', - 'fg5' => 'application/vnd.fujitsu.oasysgp', - 'fgd' => 'application/x-director', - 'fh' => 'image/x-freehand', - 'fh4' => 'image/x-freehand', - 'fh5' => 'image/x-freehand', - 'fh7' => 'image/x-freehand', - 'fhc' => 'image/x-freehand', - 'fig' => 'application/x-xfig', - 'fli' => 'video/x-fli', - 'flo' => 'application/vnd.micrografx.flo', - 'flv' => 'video/x-flv', - 'flw' => 'application/vnd.kde.kivio', - 'flx' => 'text/vnd.fmi.flexstor', - 'fly' => 'text/vnd.fly', - 'fm' => 'application/vnd.framemaker', - 'fnc' => 'application/vnd.frogans.fnc', - 'for' => 'text/x-fortran', - 'fpx' => 'image/vnd.fpx', - 'frame' => 'application/vnd.framemaker', - 'fsc' => 'application/vnd.fsc.weblaunch', - 'fst' => 'image/vnd.fst', - 'ftc' => 'application/vnd.fluxtime.clip', - 'fti' => 'application/vnd.anser-web-funds-transfer-initiation', - 'fvt' => 'video/vnd.fvt', - 'fxp' => 'application/vnd.adobe.fxp', - 'fxpl' => 'application/vnd.adobe.fxp', - 'fzs' => 'application/vnd.fuzzysheet', - 'g2w' => 'application/vnd.geoplan', - 'g3' => 'image/g3fax', - 'g3w' => 'application/vnd.geospace', - 'gac' => 'application/vnd.groove-account', - 'gdl' => 'model/vnd.gdl', - 'geo' => 'application/vnd.dynageo', - 'gex' => 'application/vnd.geometry-explorer', - 'ggb' => 'application/vnd.geogebra.file', - 'ggt' => 'application/vnd.geogebra.tool', - 'ghf' => 'application/vnd.groove-help', - 'gif' => 'image/gif', - 'gim' => 'application/vnd.groove-identity-message', - 'gmx' => 'application/vnd.gmx', - 'gnumeric' => 'application/x-gnumeric', - 'gph' => 'application/vnd.flographit', - 'gqf' => 'application/vnd.grafeq', - 'gqs' => 'application/vnd.grafeq', - 'gram' => 'application/srgs', - 'gre' => 'application/vnd.geometry-explorer', - 'grv' => 'application/vnd.groove-injector', - 'grxml' => 'application/srgs+xml', - 'gsf' => 'application/x-font-ghostscript', - 'gtar' => 'application/x-gtar', - 'gtm' => 'application/vnd.groove-tool-message', - 'gtw' => 'model/vnd.gtw', - 'gv' => 'text/vnd.graphviz', - 'gxt' => 'application/vnd.geonext', - 'h' => 'text/x-c', - 'h261' => 'video/h261', - 'h263' => 'video/h263', - 'h264' => 'video/h264', - 'hal' => 'application/vnd.hal+xml', - 'hbci' => 'application/vnd.hbci', - 'hdf' => 'application/x-hdf', - 'hh' => 'text/x-c', - 'hlp' => 'application/winhlp', - 'hpgl' => 'application/vnd.hp-hpgl', - 'hpid' => 'application/vnd.hp-hpid', - 'hps' => 'application/vnd.hp-hps', - 'hqx' => 'application/mac-binhex40', - 'hta' => 'application/octet-stream', - 'htc' => 'text/html', - 'htke' => 'application/vnd.kenameaapp', - 'htm' => 'text/html', - 'html' => 'text/html', - 'hvd' => 'application/vnd.yamaha.hv-dic', - 'hvp' => 'application/vnd.yamaha.hv-voice', - 'hvs' => 'application/vnd.yamaha.hv-script', - 'i2g' => 'application/vnd.intergeo', - 'icc' => 'application/vnd.iccprofile', - 'ice' => 'x-conference/x-cooltalk', - 'icm' => 'application/vnd.iccprofile', - 'ico' => 'image/x-icon', - 'ics' => 'text/calendar', - 'ief' => 'image/ief', - 'ifb' => 'text/calendar', - 'ifm' => 'application/vnd.shana.informed.formdata', - 'iges' => 'model/iges', - 'igl' => 'application/vnd.igloader', - 'igm' => 'application/vnd.insors.igm', - 'igs' => 'model/iges', - 'igx' => 'application/vnd.micrografx.igx', - 'iif' => 'application/vnd.shana.informed.interchange', - 'imp' => 'application/vnd.accpac.simply.imp', - 'ims' => 'application/vnd.ms-ims', - 'in' => 'text/plain', - 'ini' => 'text/plain', - 'ipfix' => 'application/ipfix', - 'ipk' => 'application/vnd.shana.informed.package', - 'irm' => 'application/vnd.ibm.rights-management', - 'irp' => 'application/vnd.irepository.package+xml', - 'iso' => 'application/octet-stream', - 'itp' => 'application/vnd.shana.informed.formtemplate', - 'ivp' => 'application/vnd.immervision-ivp', - 'ivu' => 'application/vnd.immervision-ivu', - 'jad' => 'text/vnd.sun.j2me.app-descriptor', - 'jam' => 'application/vnd.jam', - 'jar' => 'application/java-archive', - 'java' => 'text/x-java-source', - 'jisp' => 'application/vnd.jisp', - 'jlt' => 'application/vnd.hp-jlyt', - 'jnlp' => 'application/x-java-jnlp-file', - 'joda' => 'application/vnd.joost.joda-archive', - 'jpe' => 'image/jpeg', - 'jpeg' => 'image/jpeg', - 'jpg' => 'image/jpeg', - 'jpgm' => 'video/jpm', - 'jpgv' => 'video/jpeg', - 'jpm' => 'video/jpm', - 'js' => 'text/javascript', - 'json' => 'application/json', - 'kar' => 'audio/midi', - 'karbon' => 'application/vnd.kde.karbon', - 'kfo' => 'application/vnd.kde.kformula', - 'kia' => 'application/vnd.kidspiration', - 'kml' => 'application/vnd.google-earth.kml+xml', - 'kmz' => 'application/vnd.google-earth.kmz', - 'kne' => 'application/vnd.kinar', - 'knp' => 'application/vnd.kinar', - 'kon' => 'application/vnd.kde.kontour', - 'kpr' => 'application/vnd.kde.kpresenter', - 'kpt' => 'application/vnd.kde.kpresenter', - 'ksp' => 'application/vnd.kde.kspread', - 'ktr' => 'application/vnd.kahootz', - 'ktx' => 'image/ktx', - 'ktz' => 'application/vnd.kahootz', - 'kwd' => 'application/vnd.kde.kword', - 'kwt' => 'application/vnd.kde.kword', - 'lasxml' => 'application/vnd.las.las+xml', - 'latex' => 'application/x-latex', - 'lbd' => 'application/vnd.llamagraphics.life-balance.desktop', - 'lbe' => 'application/vnd.llamagraphics.life-balance.exchange+xml', - 'les' => 'application/vnd.hhe.lesson-player', - 'lha' => 'application/octet-stream', - 'link66' => 'application/vnd.route66.link66+xml', - 'list' => 'text/plain', - 'list3820' => 'application/vnd.ibm.modcap', - 'listafp' => 'application/vnd.ibm.modcap', - 'log' => 'text/plain', - 'lostxml' => 'application/lost+xml', - 'lrf' => 'application/octet-stream', - 'lrm' => 'application/vnd.ms-lrm', - 'ltf' => 'application/vnd.frogans.ltf', - 'lvp' => 'audio/vnd.lucent.voice', - 'lwp' => 'application/vnd.lotus-wordpro', - 'lzh' => 'application/octet-stream', - 'm13' => 'application/x-msmediaview', - 'm14' => 'application/x-msmediaview', - 'm1v' => 'video/mpeg', - 'm21' => 'application/mp21', - 'm2a' => 'audio/mpeg', - 'm2v' => 'video/mpeg', - 'm3a' => 'audio/mpeg', - 'm3u' => 'audio/x-mpegurl', - 'm3u8' => 'application/vnd.apple.mpegurl', - 'm4a' => 'audio/mp4', - 'm4u' => 'video/vnd.mpegurl', - 'm4v' => 'video/mp4', - 'ma' => 'application/mathematica', - 'mads' => 'application/mads+xml', - 'mag' => 'application/vnd.ecowin.chart', - 'maker' => 'application/vnd.framemaker', - 'man' => 'text/troff', - 'mathml' => 'application/mathml+xml', - 'mb' => 'application/mathematica', - 'mbk' => 'application/vnd.mobius.mbk', - 'mbox' => 'application/mbox', - 'mc1' => 'application/vnd.medcalcdata', - 'mcd' => 'application/vnd.mcd', - 'mcurl' => 'text/vnd.curl.mcurl', - 'mdb' => 'application/x-msaccess', - 'mdi' => 'image/vnd.ms-modi', - 'me' => 'text/troff', - 'mesh' => 'model/mesh', - 'meta4' => 'application/metalink4+xml', - 'mets' => 'application/mets+xml', - 'mfm' => 'application/vnd.mfmp', - 'mgp' => 'application/vnd.osgeo.mapguide.package', - 'mgz' => 'application/vnd.proteus.magazine', - 'mid' => 'audio/midi', - 'midi' => 'audio/midi', - 'mif' => 'application/vnd.mif', - 'mime' => 'message/rfc822', - 'mj2' => 'video/mj2', - 'mjp2' => 'video/mj2', - 'mlp' => 'application/vnd.dolby.mlp', - 'mmd' => 'application/vnd.chipnuts.karaoke-mmd', - 'mmf' => 'application/vnd.smaf', - 'mmr' => 'image/vnd.fujixerox.edmics-mmr', - 'mny' => 'application/x-msmoney', - 'mobi' => 'application/x-mobipocket-ebook', - 'mods' => 'application/mods+xml', - 'mov' => 'video/quicktime', - 'movie' => 'video/x-sgi-movie', - 'mp2' => 'audio/mpeg', - 'mp21' => 'application/mp21', - 'mp2a' => 'audio/mpeg', - 'mp3' => 'audio/mpeg', - 'mp4' => 'video/mp4', - 'mp4a' => 'audio/mp4', - 'mp4s' => 'application/mp4', - 'mp4v' => 'video/mp4', - 'mpc' => 'application/vnd.mophun.certificate', - 'mpe' => 'video/mpeg', - 'mpeg' => 'video/mpeg', - 'mpg' => 'video/mpeg', - 'mpg4' => 'video/mp4', - 'mpga' => 'audio/mpeg', - 'mpkg' => 'application/vnd.apple.installer+xml', - 'mpm' => 'application/vnd.blueice.multipass', - 'mpn' => 'application/vnd.mophun.application', - 'mpp' => 'application/vnd.ms-project', - 'mpt' => 'application/vnd.ms-project', - 'mpy' => 'application/vnd.ibm.minipay', - 'mqy' => 'application/vnd.mobius.mqy', - 'mrc' => 'application/marc', - 'mrcx' => 'application/marcxml+xml', - 'ms' => 'text/troff', - 'mscml' => 'application/mediaservercontrol+xml', - 'mseed' => 'application/vnd.fdsn.mseed', - 'mseq' => 'application/vnd.mseq', - 'msf' => 'application/vnd.epson.msf', - 'msh' => 'model/mesh', - 'msi' => 'application/x-msdownload', - 'msl' => 'application/vnd.mobius.msl', - 'msty' => 'application/vnd.muvee.style', - 'mts' => 'model/vnd.mts', - 'mus' => 'application/vnd.musician', - 'musicxml' => 'application/vnd.recordare.musicxml+xml', - 'mvb' => 'application/x-msmediaview', - 'mwf' => 'application/vnd.mfer', - 'mxf' => 'application/mxf', - 'mxl' => 'application/vnd.recordare.musicxml', - 'mxml' => 'application/xv+xml', - 'mxs' => 'application/vnd.triscape.mxs', - 'mxu' => 'video/vnd.mpegurl', - 'n-gage' => 'application/vnd.nokia.n-gage.symbian.install', - 'n3' => 'text/n3', - 'nb' => 'application/mathematica', - 'nbp' => 'application/vnd.wolfram.player', - 'nc' => 'application/x-netcdf', - 'ncx' => 'application/x-dtbncx+xml', - 'ngdat' => 'application/vnd.nokia.n-gage.data', - 'nlu' => 'application/vnd.neurolanguage.nlu', - 'nml' => 'application/vnd.enliven', - 'nnd' => 'application/vnd.noblenet-directory', - 'nns' => 'application/vnd.noblenet-sealer', - 'nnw' => 'application/vnd.noblenet-web', - 'npx' => 'image/vnd.net-fpx', - 'nsf' => 'application/vnd.lotus-notes', - 'oa2' => 'application/vnd.fujitsu.oasys2', - 'oa3' => 'application/vnd.fujitsu.oasys3', - 'oas' => 'application/vnd.fujitsu.oasys', - 'obd' => 'application/x-msbinder', - 'oda' => 'application/oda', - 'odb' => 'application/vnd.oasis.opendocument.database', - 'odc' => 'application/vnd.oasis.opendocument.chart', - 'odf' => 'application/vnd.oasis.opendocument.formula', - 'odft' => 'application/vnd.oasis.opendocument.formula-template', - 'odg' => 'application/vnd.oasis.opendocument.graphics', - 'odi' => 'application/vnd.oasis.opendocument.image', - 'odm' => 'application/vnd.oasis.opendocument.text-master', - 'odp' => 'application/vnd.oasis.opendocument.presentation', - 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', - 'odt' => 'application/vnd.oasis.opendocument.text', - 'oga' => 'audio/ogg', - 'ogg' => 'audio/ogg', - 'ogv' => 'video/ogg', - 'ogx' => 'application/ogg', - 'onepkg' => 'application/onenote', - 'onetmp' => 'application/onenote', - 'onetoc' => 'application/onenote', - 'onetoc2' => 'application/onenote', - 'opf' => 'application/oebps-package+xml', - 'oprc' => 'application/vnd.palm', - 'org' => 'application/vnd.lotus-organizer', - 'osf' => 'application/vnd.yamaha.openscoreformat', - 'osfpvg' => 'application/vnd.yamaha.openscoreformat.osfpvg+xml', - 'otc' => 'application/vnd.oasis.opendocument.chart-template', - 'otf' => 'application/x-font-otf', - 'otg' => 'application/vnd.oasis.opendocument.graphics-template', - 'oth' => 'application/vnd.oasis.opendocument.text-web', - 'oti' => 'application/vnd.oasis.opendocument.image-template', - 'otp' => 'application/vnd.oasis.opendocument.presentation-template', - 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template', - 'ott' => 'application/vnd.oasis.opendocument.text-template', - 'oxt' => 'application/vnd.openofficeorg.extension', - 'p' => 'text/x-pascal', - 'p10' => 'application/pkcs10', - 'p12' => 'application/x-pkcs12', - 'p7b' => 'application/x-pkcs7-certificates', - 'p7c' => 'application/pkcs7-mime', - 'p7m' => 'application/pkcs7-mime', - 'p7r' => 'application/x-pkcs7-certreqresp', - 'p7s' => 'application/pkcs7-signature', - 'p8' => 'application/pkcs8', - 'pas' => 'text/x-pascal', - 'paw' => 'application/vnd.pawaafile', - 'pbd' => 'application/vnd.powerbuilder6', - 'pbm' => 'image/x-portable-bitmap', - 'pcf' => 'application/x-font-pcf', - 'pcl' => 'application/vnd.hp-pcl', - 'pclxl' => 'application/vnd.hp-pclxl', - 'pct' => 'image/x-pict', - 'pcurl' => 'application/vnd.curl.pcurl', - 'pcx' => 'image/x-pcx', - 'pdb' => 'application/vnd.palm', - 'pdf' => 'application/pdf', - 'pfa' => 'application/x-font-type1', - 'pfb' => 'application/x-font-type1', - 'pfm' => 'application/x-font-type1', - 'pfr' => 'application/font-tdpfr', - 'pfx' => 'application/x-pkcs12', - 'pgm' => 'image/x-portable-graymap', - 'pgn' => 'application/x-chess-pgn', - 'pgp' => 'application/pgp-encrypted', - 'php' => 'text/x-php', - 'phps' => 'application/x-httpd-phps', - 'pic' => 'image/x-pict', - 'pkg' => 'application/octet-stream', - 'pki' => 'application/pkixcmp', - 'pkipath' => 'application/pkix-pkipath', - 'plb' => 'application/vnd.3gpp.pic-bw-large', - 'plc' => 'application/vnd.mobius.plc', - 'plf' => 'application/vnd.pocketlearn', - 'pls' => 'application/pls+xml', - 'pml' => 'application/vnd.ctc-posml', - 'png' => 'image/png', - 'pnm' => 'image/x-portable-anymap', - 'portpkg' => 'application/vnd.macports.portpkg', - 'pot' => 'application/vnd.ms-powerpoint', - 'potm' => 'application/vnd.ms-powerpoint.template.macroenabled.12', - 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template', - 'ppam' => 'application/vnd.ms-powerpoint.addin.macroenabled.12', - 'ppd' => 'application/vnd.cups-ppd', - 'ppm' => 'image/x-portable-pixmap', - 'pps' => 'application/vnd.ms-powerpoint', - 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroenabled.12', - 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', - 'ppt' => 'application/vnd.ms-powerpoint', - 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroenabled.12', - 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', - 'pqa' => 'application/vnd.palm', - 'prc' => 'application/x-mobipocket-ebook', - 'pre' => 'application/vnd.lotus-freelance', - 'prf' => 'application/pics-rules', - 'ps' => 'application/postscript', - 'psb' => 'application/vnd.3gpp.pic-bw-small', - 'psd' => 'image/vnd.adobe.photoshop', - 'psf' => 'application/x-font-linux-psf', - 'pskcxml' => 'application/pskc+xml', - 'ptid' => 'application/vnd.pvi.ptid1', - 'pub' => 'application/x-mspublisher', - 'pvb' => 'application/vnd.3gpp.pic-bw-var', - 'pwn' => 'application/vnd.3m.post-it-notes', - 'pya' => 'audio/vnd.ms-playready.media.pya', - 'pyv' => 'video/vnd.ms-playready.media.pyv', - 'qam' => 'application/vnd.epson.quickanime', - 'qbo' => 'application/vnd.intu.qbo', - 'qfx' => 'application/vnd.intu.qfx', - 'qps' => 'application/vnd.publishare-delta-tree', - 'qt' => 'video/quicktime', - 'qwd' => 'application/vnd.quark.quarkxpress', - 'qwt' => 'application/vnd.quark.quarkxpress', - 'qxb' => 'application/vnd.quark.quarkxpress', - 'qxd' => 'application/vnd.quark.quarkxpress', - 'qxl' => 'application/vnd.quark.quarkxpress', - 'qxt' => 'application/vnd.quark.quarkxpress', - 'ra' => 'audio/x-pn-realaudio', - 'ram' => 'audio/x-pn-realaudio', - 'rar' => 'application/x-rar-compressed', - 'ras' => 'image/x-cmu-raster', - 'rb' => 'text/plain', - 'rcprofile' => 'application/vnd.ipunplugged.rcprofile', - 'rdf' => 'application/rdf+xml', - 'rdz' => 'application/vnd.data-vision.rdz', - 'rep' => 'application/vnd.businessobjects', - 'res' => 'application/x-dtbresource+xml', - 'resx' => 'text/xml', - 'rgb' => 'image/x-rgb', - 'rif' => 'application/reginfo+xml', - 'rip' => 'audio/vnd.rip', - 'rl' => 'application/resource-lists+xml', - 'rlc' => 'image/vnd.fujixerox.edmics-rlc', - 'rld' => 'application/resource-lists-diff+xml', - 'rm' => 'application/vnd.rn-realmedia', - 'rmi' => 'audio/midi', - 'rmp' => 'audio/x-pn-realaudio-plugin', - 'rms' => 'application/vnd.jcp.javame.midlet-rms', - 'rnc' => 'application/relax-ng-compact-syntax', - 'roff' => 'text/troff', - 'rp9' => 'application/vnd.cloanto.rp9', - 'rpss' => 'application/vnd.nokia.radio-presets', - 'rpst' => 'application/vnd.nokia.radio-preset', - 'rq' => 'application/sparql-query', - 'rs' => 'application/rls-services+xml', - 'rsd' => 'application/rsd+xml', - 'rss' => 'application/rss+xml', - 'rtf' => 'application/rtf', - 'rtx' => 'text/richtext', - 's' => 'text/x-asm', - 'saf' => 'application/vnd.yamaha.smaf-audio', - 'sbml' => 'application/sbml+xml', - 'sc' => 'application/vnd.ibm.secure-container', - 'scd' => 'application/x-msschedule', - 'scm' => 'application/vnd.lotus-screencam', - 'scq' => 'application/scvp-cv-request', - 'scs' => 'application/scvp-cv-response', - 'scurl' => 'text/vnd.curl.scurl', - 'sda' => 'application/vnd.stardivision.draw', - 'sdc' => 'application/vnd.stardivision.calc', - 'sdd' => 'application/vnd.stardivision.impress', - 'sdkd' => 'application/vnd.solent.sdkm+xml', - 'sdkm' => 'application/vnd.solent.sdkm+xml', - 'sdp' => 'application/sdp', - 'sdw' => 'application/vnd.stardivision.writer', - 'see' => 'application/vnd.seemail', - 'seed' => 'application/vnd.fdsn.seed', - 'sema' => 'application/vnd.sema', - 'semd' => 'application/vnd.semd', - 'semf' => 'application/vnd.semf', - 'ser' => 'application/java-serialized-object', - 'setpay' => 'application/set-payment-initiation', - 'setreg' => 'application/set-registration-initiation', - 'sfd-hdstx' => 'application/vnd.hydrostatix.sof-data', - 'sfs' => 'application/vnd.spotfire.sfs', - 'sgl' => 'application/vnd.stardivision.writer-global', - 'sgm' => 'text/sgml', - 'sgml' => 'text/sgml', - 'sh' => 'application/x-sh', - 'shar' => 'application/x-shar', - 'shf' => 'application/shf+xml', - 'sig' => 'application/pgp-signature', - 'silo' => 'model/mesh', - 'sis' => 'application/vnd.symbian.install', - 'sisx' => 'application/vnd.symbian.install', - 'sit' => 'application/x-stuffit', - 'sitx' => 'application/x-stuffitx', - 'skd' => 'application/vnd.koan', - 'skm' => 'application/vnd.koan', - 'skp' => 'application/vnd.koan', - 'skt' => 'application/vnd.koan', - 'sldm' => 'application/vnd.ms-powerpoint.slide.macroenabled.12', - 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide', - 'slt' => 'application/vnd.epson.salt', - 'sm' => 'application/vnd.stepmania.stepchart', - 'smf' => 'application/vnd.stardivision.math', - 'smi' => 'application/smil+xml', - 'smil' => 'application/smil+xml', - 'snd' => 'audio/basic', - 'snf' => 'application/x-font-snf', - 'so' => 'application/octet-stream', - 'spc' => 'application/x-pkcs7-certificates', - 'spf' => 'application/vnd.yamaha.smaf-phrase', - 'spl' => 'application/x-futuresplash', - 'spot' => 'text/vnd.in3d.spot', - 'spp' => 'application/scvp-vp-response', - 'spq' => 'application/scvp-vp-request', - 'spx' => 'audio/ogg', - 'src' => 'application/x-wais-source', - 'sru' => 'application/sru+xml', - 'srx' => 'application/sparql-results+xml', - 'sse' => 'application/vnd.kodak-descriptor', - 'ssf' => 'application/vnd.epson.ssf', - 'ssml' => 'application/ssml+xml', - 'st' => 'application/vnd.sailingtracker.track', - 'stc' => 'application/vnd.sun.xml.calc.template', - 'std' => 'application/vnd.sun.xml.draw.template', - 'stf' => 'application/vnd.wt.stf', - 'sti' => 'application/vnd.sun.xml.impress.template', - 'stk' => 'application/hyperstudio', - 'stl' => 'application/vnd.ms-pki.stl', - 'str' => 'application/vnd.pg.format', - 'stw' => 'application/vnd.sun.xml.writer.template', - 'sub' => 'image/vnd.dvb.subtitle', - 'sus' => 'application/vnd.sus-calendar', - 'susp' => 'application/vnd.sus-calendar', - 'sv4cpio' => 'application/x-sv4cpio', - 'sv4crc' => 'application/x-sv4crc', - 'svc' => 'application/vnd.dvb.service', - 'svd' => 'application/vnd.svd', - 'svg' => 'image/svg+xml', - 'svgz' => 'image/svg+xml', - 'swa' => 'application/x-director', - 'swf' => 'application/x-shockwave-flash', - 'swi' => 'application/vnd.aristanetworks.swi', - 'sxc' => 'application/vnd.sun.xml.calc', - 'sxd' => 'application/vnd.sun.xml.draw', - 'sxg' => 'application/vnd.sun.xml.writer.global', - 'sxi' => 'application/vnd.sun.xml.impress', - 'sxm' => 'application/vnd.sun.xml.math', - 'sxw' => 'application/vnd.sun.xml.writer', - 't' => 'text/troff', - 'tao' => 'application/vnd.tao.intent-module-archive', - 'tar' => 'application/x-tar', - 'tcap' => 'application/vnd.3gpp2.tcap', - 'tcl' => 'application/x-tcl', - 'teacher' => 'application/vnd.smart.teacher', - 'tei' => 'application/tei+xml', - 'teicorpus' => 'application/tei+xml', - 'tex' => 'application/x-tex', - 'texi' => 'application/x-texinfo', - 'texinfo' => 'application/x-texinfo', - 'text' => 'text/plain', - 'tfi' => 'application/thraud+xml', - 'tfm' => 'application/x-tex-tfm', - 'thmx' => 'application/vnd.ms-officetheme', - 'tif' => 'image/tiff', - 'tiff' => 'image/tiff', - 'tmo' => 'application/vnd.tmobile-livetv', - 'torrent' => 'application/x-bittorrent', - 'tpl' => 'application/vnd.groove-tool-template', - 'tpt' => 'application/vnd.trid.tpt', - 'tr' => 'text/troff', - 'tra' => 'application/vnd.trueapp', - 'trm' => 'application/x-msterminal', - 'tsd' => 'application/timestamped-data', - 'tsv' => 'text/tab-separated-values', - 'ttc' => 'application/x-font-ttf', - 'ttf' => 'application/x-font-ttf', - 'ttl' => 'text/turtle', - 'twd' => 'application/vnd.simtech-mindmapper', - 'twds' => 'application/vnd.simtech-mindmapper', - 'txd' => 'application/vnd.genomatix.tuxedo', - 'txf' => 'application/vnd.mobius.txf', - 'txt' => 'text/plain', - 'u32' => 'application/x-authorware-bin', - 'udeb' => 'application/x-debian-package', - 'ufd' => 'application/vnd.ufdl', - 'ufdl' => 'application/vnd.ufdl', - 'umj' => 'application/vnd.umajin', - 'unityweb' => 'application/vnd.unity', - 'uoml' => 'application/vnd.uoml+xml', - 'uri' => 'text/uri-list', - 'uris' => 'text/uri-list', - 'urls' => 'text/uri-list', - 'ustar' => 'application/x-ustar', - 'utz' => 'application/vnd.uiq.theme', - 'uu' => 'text/x-uuencode', - 'uva' => 'audio/vnd.dece.audio', - 'uvd' => 'application/vnd.dece.data', - 'uvf' => 'application/vnd.dece.data', - 'uvg' => 'image/vnd.dece.graphic', - 'uvh' => 'video/vnd.dece.hd', - 'uvi' => 'image/vnd.dece.graphic', - 'uvm' => 'video/vnd.dece.mobile', - 'uvp' => 'video/vnd.dece.pd', - 'uvs' => 'video/vnd.dece.sd', - 'uvt' => 'application/vnd.dece.ttml+xml', - 'uvu' => 'video/vnd.uvvu.mp4', - 'uvv' => 'video/vnd.dece.video', - 'uvva' => 'audio/vnd.dece.audio', - 'uvvd' => 'application/vnd.dece.data', - 'uvvf' => 'application/vnd.dece.data', - 'uvvg' => 'image/vnd.dece.graphic', - 'uvvh' => 'video/vnd.dece.hd', - 'uvvi' => 'image/vnd.dece.graphic', - 'uvvm' => 'video/vnd.dece.mobile', - 'uvvp' => 'video/vnd.dece.pd', - 'uvvs' => 'video/vnd.dece.sd', - 'uvvt' => 'application/vnd.dece.ttml+xml', - 'uvvu' => 'video/vnd.uvvu.mp4', - 'uvvv' => 'video/vnd.dece.video', - 'uvvx' => 'application/vnd.dece.unspecified', - 'uvx' => 'application/vnd.dece.unspecified', - 'vcd' => 'application/x-cdlink', - 'vcf' => 'text/x-vcard', - 'vcg' => 'application/vnd.groove-vcard', - 'vcs' => 'text/x-vcalendar', - 'vcx' => 'application/vnd.vcx', - 'vis' => 'application/vnd.visionary', - 'viv' => 'video/vnd.vivo', - 'vor' => 'application/vnd.stardivision.writer', - 'vox' => 'application/x-authorware-bin', - 'vrml' => 'model/vrml', - 'vsd' => 'application/vnd.visio', - 'vsf' => 'application/vnd.vsf', - 'vss' => 'application/vnd.visio', - 'vst' => 'application/vnd.visio', - 'vsw' => 'application/vnd.visio', - 'vtu' => 'model/vnd.vtu', - 'vxml' => 'application/voicexml+xml', - 'w3d' => 'application/x-director', - 'wad' => 'application/x-doom', - 'wav' => 'audio/x-wav', - 'wax' => 'audio/x-ms-wax', - 'wbmp' => 'image/vnd.wap.wbmp', - 'wbs' => 'application/vnd.criticaltools.wbs+xml', - 'wbxml' => 'application/vnd.wap.wbxml', - 'wcm' => 'application/vnd.ms-works', - 'wdb' => 'application/vnd.ms-works', - 'weba' => 'audio/webm', - 'webm' => 'video/webm', - 'webp' => 'image/webp', - 'wg' => 'application/vnd.pmi.widget', - 'wgt' => 'application/widget', - 'wks' => 'application/vnd.ms-works', - 'wm' => 'video/x-ms-wm', - 'wma' => 'audio/x-ms-wma', - 'wmd' => 'application/x-ms-wmd', - 'wmf' => 'application/x-msmetafile', - 'wml' => 'text/vnd.wap.wml', - 'wmlc' => 'application/vnd.wap.wmlc', - 'wmls' => 'text/vnd.wap.wmlscript', - 'wmlsc' => 'application/vnd.wap.wmlscriptc', - 'wmv' => 'video/x-ms-wmv', - 'wmx' => 'video/x-ms-wmx', - 'wmz' => 'application/x-ms-wmz', - 'woff' => 'application/x-font-woff', - 'wpd' => 'application/vnd.wordperfect', - 'wpl' => 'application/vnd.ms-wpl', - 'wps' => 'application/vnd.ms-works', - 'wqd' => 'application/vnd.wqd', - 'wri' => 'application/x-mswrite', - 'wrl' => 'model/vrml', - 'wsdl' => 'application/wsdl+xml', - 'wspolicy' => 'application/wspolicy+xml', - 'wtb' => 'application/vnd.webturbo', - 'wvx' => 'video/x-ms-wvx', - 'x32' => 'application/x-authorware-bin', - 'x3d' => 'application/vnd.hzn-3d-crossword', - 'xap' => 'application/x-silverlight-app', - 'xar' => 'application/vnd.xara', - 'xbap' => 'application/x-ms-xbap', - 'xbd' => 'application/vnd.fujixerox.docuworks.binder', - 'xbm' => 'image/x-xbitmap', - 'xdf' => 'application/xcap-diff+xml', - 'xdm' => 'application/vnd.syncml.dm+xml', - 'xdp' => 'application/vnd.adobe.xdp+xml', - 'xdssc' => 'application/dssc+xml', - 'xdw' => 'application/vnd.fujixerox.docuworks', - 'xenc' => 'application/xenc+xml', - 'xer' => 'application/patch-ops-error+xml', - 'xfdf' => 'application/vnd.adobe.xfdf', - 'xfdl' => 'application/vnd.xfdl', - 'xht' => 'application/xhtml+xml', - 'xhtml' => 'application/xhtml+xml', - 'xhvml' => 'application/xv+xml', - 'xif' => 'image/vnd.xiff', - 'xla' => 'application/vnd.ms-excel', - 'xlam' => 'application/vnd.ms-excel.addin.macroenabled.12', - 'xlc' => 'application/vnd.ms-excel', - 'xlm' => 'application/vnd.ms-excel', - 'xls' => 'application/vnd.ms-excel', - 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroenabled.12', - 'xlsm' => 'application/vnd.ms-excel.sheet.macroenabled.12', - 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', - 'xlt' => 'application/vnd.ms-excel', - 'xltm' => 'application/vnd.ms-excel.template.macroenabled.12', - 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', - 'xlw' => 'application/vnd.ms-excel', - 'xml' => 'application/xml', - 'xo' => 'application/vnd.olpc-sugar', - 'xop' => 'application/xop+xml', - 'xpi' => 'application/x-xpinstall', - 'xpm' => 'image/x-xpixmap', - 'xpr' => 'application/vnd.is-xpr', - 'xps' => 'application/vnd.ms-xpsdocument', - 'xpw' => 'application/vnd.intercon.formnet', - 'xpx' => 'application/vnd.intercon.formnet', - 'xsl' => 'application/xml', - 'xslt' => 'application/xslt+xml', - 'xsm' => 'application/vnd.syncml+xml', - 'xspf' => 'application/xspf+xml', - 'xul' => 'application/vnd.mozilla.xul+xml', - 'xvm' => 'application/xv+xml', - 'xvml' => 'application/xv+xml', - 'xwd' => 'image/x-xwindowdump', - 'xyz' => 'chemical/x-xyz', - 'yaml' => 'text/yaml', - 'yang' => 'application/yang', - 'yin' => 'application/yin+xml', - 'yml' => 'text/yaml', - 'zaz' => 'application/vnd.zzazz.deck+xml', - 'zip' => 'application/zip', - 'zir' => 'application/vnd.zul', - 'zirz' => 'application/vnd.zul', - 'zmm' => 'application/vnd.handheld-entertainment+xml' - ); - - /** - * Get a singleton instance of the class - * - * @return self - * @codeCoverageIgnore - */ - public static function getInstance() - { - if (!self::$instance) { - self::$instance = new self(); - } - - return self::$instance; - } - - /** - * Get a mimetype value from a file extension - * - * @param string $extension File extension - * - * @return string|null - * - */ - public function fromExtension($extension) - { - $extension = strtolower($extension); - - return isset($this->mimetypes[$extension]) - ? $this->mimetypes[$extension] - : null; - } - - /** - * Get a mimetype from a filename - * - * @param string $filename Filename to generate a mimetype from - * - * @return string|null - */ - public function fromFilename($filename) - { - return $this->fromExtension(pathinfo($filename, PATHINFO_EXTENSION)); - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Post/MultipartBody.php b/vendor/guzzlehttp/guzzle/src/Post/MultipartBody.php deleted file mode 100644 index 1149e62..0000000 --- a/vendor/guzzlehttp/guzzle/src/Post/MultipartBody.php +++ /dev/null @@ -1,109 +0,0 @@ -boundary = $boundary ?: uniqid(); - $this->stream = $this->createStream($fields, $files); - } - - /** - * Get the boundary - * - * @return string - */ - public function getBoundary() - { - return $this->boundary; - } - - public function isWritable() - { - return false; - } - - /** - * Get the string needed to transfer a POST field - */ - private function getFieldString($name, $value) - { - return sprintf( - "--%s\r\nContent-Disposition: form-data; name=\"%s\"\r\n\r\n%s\r\n", - $this->boundary, - $name, - $value - ); - } - - /** - * Get the headers needed before transferring the content of a POST file - */ - private function getFileHeaders(PostFileInterface $file) - { - $headers = ''; - foreach ($file->getHeaders() as $key => $value) { - $headers .= "{$key}: {$value}\r\n"; - } - - return "--{$this->boundary}\r\n" . trim($headers) . "\r\n\r\n"; - } - - /** - * Create the aggregate stream that will be used to upload the POST data - */ - protected function createStream(array $fields, array $files) - { - $stream = new AppendStream(); - - foreach ($fields as $name => $fieldValues) { - foreach ((array) $fieldValues as $value) { - $stream->addStream( - Stream::factory($this->getFieldString($name, $value)) - ); - } - } - - foreach ($files as $file) { - - if (!$file instanceof PostFileInterface) { - throw new \InvalidArgumentException('All POST fields must ' - . 'implement PostFieldInterface'); - } - - $stream->addStream( - Stream::factory($this->getFileHeaders($file)) - ); - $stream->addStream($file->getContent()); - $stream->addStream(Stream::factory("\r\n")); - } - - // Add the trailing boundary with CRLF - $stream->addStream(Stream::factory("--{$this->boundary}--\r\n")); - - return $stream; - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Post/PostBody.php b/vendor/guzzlehttp/guzzle/src/Post/PostBody.php deleted file mode 100644 index ed14d1f..0000000 --- a/vendor/guzzlehttp/guzzle/src/Post/PostBody.php +++ /dev/null @@ -1,287 +0,0 @@ -files || $this->forceMultipart) { - $request->setHeader( - 'Content-Type', - 'multipart/form-data; boundary=' . $this->getBody()->getBoundary() - ); - } elseif ($this->fields && !$request->hasHeader('Content-Type')) { - $request->setHeader( - 'Content-Type', - 'application/x-www-form-urlencoded' - ); - } - - if ($size = $this->getSize()) { - $request->setHeader('Content-Length', $size); - } - } - - public function forceMultipartUpload($force) - { - $this->forceMultipart = $force; - } - - public function setAggregator(callable $aggregator) - { - $this->aggregator = $aggregator; - } - - public function setField($name, $value) - { - $this->fields[$name] = $value; - $this->mutate(); - } - - public function replaceFields(array $fields) - { - $this->fields = $fields; - $this->mutate(); - } - - public function getField($name) - { - return isset($this->fields[$name]) ? $this->fields[$name] : null; - } - - public function removeField($name) - { - unset($this->fields[$name]); - $this->mutate(); - } - - public function getFields($asString = false) - { - if (!$asString) { - return $this->fields; - } - - $query = new Query($this->fields); - $query->setEncodingType(Query::RFC1738); - $query->setAggregator($this->getAggregator()); - - return (string) $query; - } - - public function hasField($name) - { - return isset($this->fields[$name]); - } - - public function getFile($name) - { - foreach ($this->files as $file) { - if ($file->getName() == $name) { - return $file; - } - } - - return null; - } - - public function getFiles() - { - return $this->files; - } - - public function addFile(PostFileInterface $file) - { - $this->files[] = $file; - $this->mutate(); - } - - public function clearFiles() - { - $this->files = []; - $this->mutate(); - } - - /** - * Returns the numbers of fields + files - * - * @return int - */ - public function count() - { - return count($this->files) + count($this->fields); - } - - public function __toString() - { - return (string) $this->getBody(); - } - - public function getContents($maxLength = -1) - { - return $this->getBody()->getContents(); - } - - public function close() - { - $this->detach(); - } - - public function detach() - { - $this->detached = true; - $this->fields = $this->files = []; - - if ($this->body) { - $this->body->close(); - $this->body = null; - } - } - - public function attach($stream) - { - throw new CannotAttachException(); - } - - public function eof() - { - return $this->getBody()->eof(); - } - - public function tell() - { - return $this->body ? $this->body->tell() : 0; - } - - public function isSeekable() - { - return true; - } - - public function isReadable() - { - return true; - } - - public function isWritable() - { - return false; - } - - public function getSize() - { - return $this->getBody()->getSize(); - } - - public function seek($offset, $whence = SEEK_SET) - { - return $this->getBody()->seek($offset, $whence); - } - - public function read($length) - { - return $this->getBody()->read($length); - } - - public function write($string) - { - return false; - } - - public function getMetadata($key = null) - { - return $key ? null : []; - } - - /** - * Return a stream object that is built from the POST fields and files. - * - * If one has already been created, the previously created stream will be - * returned. - */ - private function getBody() - { - if ($this->body) { - return $this->body; - } elseif ($this->files || $this->forceMultipart) { - return $this->body = $this->createMultipart(); - } elseif ($this->fields) { - return $this->body = $this->createUrlEncoded(); - } else { - return $this->body = Stream::factory(); - } - } - - /** - * Get the aggregator used to join multi-valued field parameters - * - * @return callable - */ - final protected function getAggregator() - { - if (!$this->aggregator) { - $this->aggregator = Query::phpAggregator(); - } - - return $this->aggregator; - } - - /** - * Creates a multipart/form-data body stream - * - * @return MultipartBody - */ - private function createMultipart() - { - // Flatten the nested query string values using the correct aggregator - return new MultipartBody( - call_user_func($this->getAggregator(), $this->fields), - $this->files - ); - } - - /** - * Creates an application/x-www-form-urlencoded stream body - * - * @return StreamInterface - */ - private function createUrlEncoded() - { - return Stream::factory($this->getFields(true)); - } - - /** - * Get rid of any cached data - */ - private function mutate() - { - $this->body = null; - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Post/PostBodyInterface.php b/vendor/guzzlehttp/guzzle/src/Post/PostBodyInterface.php deleted file mode 100644 index c2ec9a6..0000000 --- a/vendor/guzzlehttp/guzzle/src/Post/PostBodyInterface.php +++ /dev/null @@ -1,109 +0,0 @@ -headers = $headers; - $this->name = $name; - $this->prepareContent($content); - $this->prepareFilename($filename); - $this->prepareDefaultHeaders(); - } - - public function getName() - { - return $this->name; - } - - public function getFilename() - { - return $this->filename; - } - - public function getContent() - { - return $this->content; - } - - public function getHeaders() - { - return $this->headers; - } - - /** - * Prepares the contents of a POST file. - * - * @param mixed $content Content of the POST file - */ - private function prepareContent($content) - { - $this->content = $content; - - if (!($this->content instanceof StreamInterface)) { - $this->content = Stream::factory($this->content); - } elseif ($this->content instanceof MultipartBody) { - if (!$this->hasHeader('Content-Disposition')) { - $disposition = 'form-data; name="' . $this->name .'"'; - $this->headers['Content-Disposition'] = $disposition; - } - - if (!$this->hasHeader('Content-Type')) { - $this->headers['Content-Type'] = sprintf( - "multipart/form-data; boundary=%s", - $this->content->getBoundary() - ); - } - } - } - - /** - * Applies a file name to the POST file based on various checks. - * - * @param string|null $filename Filename to apply (or null to guess) - */ - private function prepareFilename($filename) - { - $this->filename = $filename; - - if (!$this->filename) { - $this->filename = $this->content->getMetadata('uri'); - } - - if (!$this->filename || substr($this->filename, 0, 6) === 'php://') { - $this->filename = $this->name; - } - } - - /** - * Applies default Content-Disposition and Content-Type headers if needed. - */ - private function prepareDefaultHeaders() - { - // Set a default content-disposition header if one was no provided - if (!$this->hasHeader('Content-Disposition')) { - $this->headers['Content-Disposition'] = sprintf( - 'form-data; name="%s"; filename="%s"', - $this->name, - basename($this->filename) - ); - } - - // Set a default Content-Type if one was not supplied - if (!$this->hasHeader('Content-Type')) { - $this->headers['Content-Type'] = Mimetypes::getInstance() - ->fromFilename($this->filename) ?: 'text/plain'; - } - } - - /** - * Check if a specific header exists on the POST file by name. - * - * @param string $name Case-insensitive header to check - * - * @return bool - */ - private function hasHeader($name) - { - return isset(array_change_key_case($this->headers)[strtolower($name)]); - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Post/PostFileInterface.php b/vendor/guzzlehttp/guzzle/src/Post/PostFileInterface.php deleted file mode 100644 index 2e816c0..0000000 --- a/vendor/guzzlehttp/guzzle/src/Post/PostFileInterface.php +++ /dev/null @@ -1,41 +0,0 @@ -setEncodingType($urlEncoding); - } - - $qp->parseInto($q, $query, $urlEncoding); - - return $q; - } - - /** - * Convert the query string parameters to a query string string - * - * @return string - */ - public function __toString() - { - if (!$this->data) { - return ''; - } - - // The default aggregator is statically cached - static $defaultAggregator; - - if (!$this->aggregator) { - if (!$defaultAggregator) { - $defaultAggregator = self::phpAggregator(); - } - $this->aggregator = $defaultAggregator; - } - - $result = ''; - $aggregator = $this->aggregator; - $encoder = $this->encoding; - - foreach ($aggregator($this->data) as $key => $values) { - foreach ($values as $value) { - if ($result) { - $result .= '&'; - } - $result .= $encoder($key); - if ($value !== null) { - $result .= '=' . $encoder($value); - } - } - } - - return $result; - } - - /** - * Controls how multi-valued query string parameters are aggregated into a - * string. - * - * $query->setAggregator($query::duplicateAggregator()); - * - * @param callable $aggregator Callable used to convert a deeply nested - * array of query string variables into a flattened array of key value - * pairs. The callable accepts an array of query data and returns a - * flattened array of key value pairs where each value is an array of - * strings. - */ - public function setAggregator(callable $aggregator) - { - $this->aggregator = $aggregator; - } - - /** - * Specify how values are URL encoded - * - * @param string|bool $type One of 'RFC1738', 'RFC3986', or false to disable encoding - * - * @throws \InvalidArgumentException - */ - public function setEncodingType($type) - { - switch ($type) { - case self::RFC3986: - $this->encoding = 'rawurlencode'; - break; - case self::RFC1738: - $this->encoding = 'urlencode'; - break; - case false: - $this->encoding = function ($v) { return $v; }; - break; - default: - throw new \InvalidArgumentException('Invalid URL encoding type'); - } - } - - /** - * Query string aggregator that does not aggregate nested query string - * values and allows duplicates in the resulting array. - * - * Example: http://test.com?q=1&q=2 - * - * @return callable - */ - public static function duplicateAggregator() - { - return function (array $data) { - return self::walkQuery($data, '', function ($key, $prefix) { - return is_int($key) ? $prefix : "{$prefix}[{$key}]"; - }); - }; - } - - /** - * Aggregates nested query string variables using the same technique as - * ``http_build_query()``. - * - * @param bool $numericIndices Pass false to not include numeric indices - * when multi-values query string parameters are present. - * - * @return callable - */ - public static function phpAggregator($numericIndices = true) - { - return function (array $data) use ($numericIndices) { - return self::walkQuery( - $data, - '', - function ($key, $prefix) use ($numericIndices) { - return !$numericIndices && is_int($key) - ? "{$prefix}[]" - : "{$prefix}[{$key}]"; - } - ); - }; - } - - /** - * Easily create query aggregation functions by providing a key prefix - * function to this query string array walker. - * - * @param array $query Query string to walk - * @param string $keyPrefix Key prefix (start with '') - * @param callable $prefixer Function used to create a key prefix - * - * @return array - */ - public static function walkQuery(array $query, $keyPrefix, callable $prefixer) - { - $result = []; - foreach ($query as $key => $value) { - if ($keyPrefix) { - $key = $prefixer($key, $keyPrefix); - } - if (is_array($value)) { - $result += self::walkQuery($value, $key, $prefixer); - } elseif (isset($result[$key])) { - $result[$key][] = $value; - } else { - $result[$key] = array($value); - } - } - - return $result; - } -} diff --git a/vendor/guzzlehttp/guzzle/src/QueryParser.php b/vendor/guzzlehttp/guzzle/src/QueryParser.php deleted file mode 100644 index 90727cc..0000000 --- a/vendor/guzzlehttp/guzzle/src/QueryParser.php +++ /dev/null @@ -1,163 +0,0 @@ -duplicates = false; - $this->numericIndices = true; - $decoder = self::getDecoder($urlEncoding); - - foreach (explode('&', $str) as $kvp) { - - $parts = explode('=', $kvp, 2); - $key = $decoder($parts[0]); - $value = isset($parts[1]) ? $decoder($parts[1]) : null; - - // Special handling needs to be taken for PHP nested array syntax - if (strpos($key, '[') !== false) { - $this->parsePhpValue($key, $value, $result); - continue; - } - - if (!isset($result[$key])) { - $result[$key] = $value; - } else { - $this->duplicates = true; - if (!is_array($result[$key])) { - $result[$key] = [$result[$key]]; - } - $result[$key][] = $value; - } - } - - $query->replace($result); - - if (!$this->numericIndices) { - $query->setAggregator(Query::phpAggregator(false)); - } elseif ($this->duplicates) { - $query->setAggregator(Query::duplicateAggregator()); - } - } - - /** - * Returns a callable that is used to URL decode query keys and values. - * - * @param string|bool $type One of true, false, RFC3986, and RFC1738 - * - * @return callable|string - */ - private static function getDecoder($type) - { - if ($type === true) { - return function ($value) { - return rawurldecode(str_replace('+', ' ', $value)); - }; - } elseif ($type == Query::RFC3986) { - return 'rawurldecode'; - } elseif ($type == Query::RFC1738) { - return 'urldecode'; - } else { - return function ($str) { return $str; }; - } - } - - /** - * Parses a PHP style key value pair. - * - * @param string $key Key to parse (e.g., "foo[a][b]") - * @param string|null $value Value to set - * @param array $result Result to modify by reference - */ - private function parsePhpValue($key, $value, array &$result) - { - $node =& $result; - $keyBuffer = ''; - - for ($i = 0, $t = strlen($key); $i < $t; $i++) { - switch ($key[$i]) { - case '[': - if ($keyBuffer) { - $this->prepareNode($node, $keyBuffer); - $node =& $node[$keyBuffer]; - $keyBuffer = ''; - } - break; - case ']': - $k = $this->cleanKey($node, $keyBuffer); - $this->prepareNode($node, $k); - $node =& $node[$k]; - $keyBuffer = ''; - break; - default: - $keyBuffer .= $key[$i]; - break; - } - } - - if (isset($node)) { - $this->duplicates = true; - $node[] = $value; - } else { - $node = $value; - } - } - - /** - * Prepares a value in the array at the given key. - * - * If the key already exists, the key value is converted into an array. - * - * @param array $node Result node to modify - * @param string $key Key to add or modify in the node - */ - private function prepareNode(&$node, $key) - { - if (!isset($node[$key])) { - $node[$key] = null; - } elseif (!is_array($node[$key])) { - $node[$key] = [$node[$key]]; - } - } - - /** - * Returns the appropriate key based on the node and key. - */ - private function cleanKey($node, $key) - { - if ($key === '') { - $key = $node ? (string) count($node) : 0; - // Found a [] key, so track this to ensure that we disable numeric - // indexing of keys in the resolved query aggregator. - $this->numericIndices = false; - } - - return $key; - } -} diff --git a/vendor/guzzlehttp/guzzle/src/RequestFsm.php b/vendor/guzzlehttp/guzzle/src/RequestFsm.php deleted file mode 100644 index b37c190..0000000 --- a/vendor/guzzlehttp/guzzle/src/RequestFsm.php +++ /dev/null @@ -1,153 +0,0 @@ -mf = $messageFactory; - $this->maxTransitions = $maxTransitions; - $this->handler = $handler; - } - - /** - * Runs the state machine until a terminal state is entered or the - * optionally supplied $finalState is entered. - * - * @param Transaction $trans Transaction being transitioned. - * - * @throws \Exception if a terminal state throws an exception. - */ - public function __invoke(Transaction $trans) - { - $trans->_transitionCount = 0; - - if (!$trans->state) { - $trans->state = 'before'; - } - - transition: - - if (++$trans->_transitionCount > $this->maxTransitions) { - throw new StateException("Too many state transitions were " - . "encountered ({$trans->_transitionCount}). This likely " - . "means that a combination of event listeners are in an " - . "infinite loop."); - } - - switch ($trans->state) { - case 'before': goto before; - case 'complete': goto complete; - case 'error': goto error; - case 'retry': goto retry; - case 'send': goto send; - case 'end': goto end; - default: throw new StateException("Invalid state: {$trans->state}"); - } - - before: { - try { - $trans->request->getEmitter()->emit('before', new BeforeEvent($trans)); - $trans->state = 'send'; - if ((bool) $trans->response) { - $trans->state = 'complete'; - } - } catch (\Exception $e) { - $trans->state = 'error'; - $trans->exception = $e; - } - goto transition; - } - - complete: { - try { - if ($trans->response instanceof FutureInterface) { - // Futures will have their own end events emitted when - // dereferenced. - return; - } - $trans->state = 'end'; - $trans->response->setEffectiveUrl($trans->request->getUrl()); - $trans->request->getEmitter()->emit('complete', new CompleteEvent($trans)); - } catch (\Exception $e) { - $trans->state = 'error'; - $trans->exception = $e; - } - goto transition; - } - - error: { - try { - // Convert non-request exception to a wrapped exception - $trans->exception = RequestException::wrapException( - $trans->request, $trans->exception - ); - $trans->state = 'end'; - $trans->request->getEmitter()->emit('error', new ErrorEvent($trans)); - // An intercepted request (not retried) transitions to complete - if (!$trans->exception && $trans->state !== 'retry') { - $trans->state = 'complete'; - } - } catch (\Exception $e) { - $trans->state = 'end'; - $trans->exception = $e; - } - goto transition; - } - - retry: { - $trans->retries++; - $trans->response = null; - $trans->exception = null; - $trans->state = 'before'; - goto transition; - } - - send: { - $fn = $this->handler; - $trans->response = FutureResponse::proxy( - $fn(RingBridge::prepareRingRequest($trans)), - function ($value) use ($trans) { - RingBridge::completeRingResponse($trans, $value, $this->mf, $this); - $this($trans); - return $trans->response; - } - ); - return; - } - - end: { - $trans->request->getEmitter()->emit('end', new EndEvent($trans)); - // Throw exceptions in the terminal event if the exception - // was not handled by an "end" event listener. - if ($trans->exception) { - if (!($trans->exception instanceof RequestException)) { - $trans->exception = RequestException::wrapException( - $trans->request, $trans->exception - ); - } - throw $trans->exception; - } - } - } -} diff --git a/vendor/guzzlehttp/guzzle/src/RingBridge.php b/vendor/guzzlehttp/guzzle/src/RingBridge.php deleted file mode 100644 index bc6841d..0000000 --- a/vendor/guzzlehttp/guzzle/src/RingBridge.php +++ /dev/null @@ -1,165 +0,0 @@ -getConfig()->toArray(); - $url = $request->getUrl(); - // No need to calculate the query string twice (in URL and query). - $qs = ($pos = strpos($url, '?')) ? substr($url, $pos + 1) : null; - - return [ - 'scheme' => $request->getScheme(), - 'http_method' => $request->getMethod(), - 'url' => $url, - 'uri' => $request->getPath(), - 'headers' => $request->getHeaders(), - 'body' => $request->getBody(), - 'version' => $request->getProtocolVersion(), - 'client' => $options, - 'query_string' => $qs, - 'future' => isset($options['future']) ? $options['future'] : false - ]; - } - - /** - * Creates a Ring request from a request object AND prepares the callbacks. - * - * @param Transaction $trans Transaction to update. - * - * @return array Converted Guzzle Ring request. - */ - public static function prepareRingRequest(Transaction $trans) - { - // Clear out the transaction state when initiating. - $trans->exception = null; - $request = self::createRingRequest($trans->request); - - // Emit progress events if any progress listeners are registered. - if ($trans->request->getEmitter()->hasListeners('progress')) { - $emitter = $trans->request->getEmitter(); - $request['client']['progress'] = function ($a, $b, $c, $d) use ($trans, $emitter) { - $emitter->emit('progress', new ProgressEvent($trans, $a, $b, $c, $d)); - }; - } - - return $request; - } - - /** - * Handles the process of processing a response received from a ring - * handler. The created response is added to the transaction, and the - * transaction stat is set appropriately. - * - * @param Transaction $trans Owns request and response. - * @param array $response Ring response array - * @param MessageFactoryInterface $messageFactory Creates response objects. - */ - public static function completeRingResponse( - Transaction $trans, - array $response, - MessageFactoryInterface $messageFactory - ) { - $trans->state = 'complete'; - $trans->transferInfo = isset($response['transfer_stats']) - ? $response['transfer_stats'] : []; - - if (!empty($response['status'])) { - $options = []; - if (isset($response['version'])) { - $options['protocol_version'] = $response['version']; - } - if (isset($response['reason'])) { - $options['reason_phrase'] = $response['reason']; - } - $trans->response = $messageFactory->createResponse( - $response['status'], - isset($response['headers']) ? $response['headers'] : [], - isset($response['body']) ? $response['body'] : null, - $options - ); - if (isset($response['effective_url'])) { - $trans->response->setEffectiveUrl($response['effective_url']); - } - } elseif (empty($response['error'])) { - // When nothing was returned, then we need to add an error. - $response['error'] = self::getNoRingResponseException($trans->request); - } - - if (isset($response['error'])) { - $trans->state = 'error'; - $trans->exception = $response['error']; - } - } - - /** - * Creates a Guzzle request object using a ring request array. - * - * @param array $request Ring request - * - * @return Request - * @throws \InvalidArgumentException for incomplete requests. - */ - public static function fromRingRequest(array $request) - { - $options = []; - if (isset($request['version'])) { - $options['protocol_version'] = $request['version']; - } - - if (!isset($request['http_method'])) { - throw new \InvalidArgumentException('No http_method'); - } - - return new Request( - $request['http_method'], - Core::url($request), - isset($request['headers']) ? $request['headers'] : [], - isset($request['body']) ? Stream::factory($request['body']) : null, - $options - ); - } - - /** - * Get an exception that can be used when a RingPHP handler does not - * populate a response. - * - * @param RequestInterface $request - * - * @return RequestException - */ - public static function getNoRingResponseException(RequestInterface $request) - { - $message = <<cookieJar = $cookieJar ?: new CookieJar(); - } - - public function getEvents() - { - // Fire the cookie plugin complete event before redirecting - return [ - 'before' => ['onBefore'], - 'complete' => ['onComplete', RequestEvents::REDIRECT_RESPONSE + 10] - ]; - } - - /** - * Get the cookie cookieJar - * - * @return CookieJarInterface - */ - public function getCookieJar() - { - return $this->cookieJar; - } - - public function onBefore(BeforeEvent $event) - { - $this->cookieJar->addCookieHeader($event->getRequest()); - } - - public function onComplete(CompleteEvent $event) - { - $this->cookieJar->extractCookies( - $event->getRequest(), - $event->getResponse() - ); - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Subscriber/History.php b/vendor/guzzlehttp/guzzle/src/Subscriber/History.php deleted file mode 100644 index 5cf0611..0000000 --- a/vendor/guzzlehttp/guzzle/src/Subscriber/History.php +++ /dev/null @@ -1,172 +0,0 @@ -limit = $limit; - } - - public function getEvents() - { - return [ - 'complete' => ['onComplete', RequestEvents::EARLY], - 'error' => ['onError', RequestEvents::EARLY], - ]; - } - - /** - * Convert to a string that contains all request and response headers - * - * @return string - */ - public function __toString() - { - $lines = array(); - foreach ($this->transactions as $entry) { - $response = isset($entry['response']) ? $entry['response'] : ''; - $lines[] = '> ' . trim($entry['sent_request']) - . "\n\n< " . trim($response) . "\n"; - } - - return implode("\n", $lines); - } - - public function onComplete(CompleteEvent $event) - { - $this->add($event->getRequest(), $event->getResponse()); - } - - public function onError(ErrorEvent $event) - { - // Only track when no response is present, meaning this didn't ever - // emit a complete event - if (!$event->getResponse()) { - $this->add($event->getRequest()); - } - } - - /** - * Returns an Iterator that yields associative array values where each - * associative array contains the following key value pairs: - * - * - request: Representing the actual request that was received. - * - sent_request: A clone of the request that will not be mutated. - * - response: The response that was received (if available). - * - * @return \Iterator - */ - public function getIterator() - { - return new \ArrayIterator($this->transactions); - } - - /** - * Get all of the requests sent through the plugin. - * - * Requests can be modified after they are logged by the history - * subscriber. By default this method will return the actual request - * instances that were received. Pass true to this method if you wish to - * get copies of the requests that represent the request state when it was - * initially logged by the history subscriber. - * - * @param bool $asSent Set to true to get clones of the requests that have - * not been mutated since the request was received by - * the history subscriber. - * - * @return RequestInterface[] - */ - public function getRequests($asSent = false) - { - return array_map(function ($t) use ($asSent) { - return $asSent ? $t['sent_request'] : $t['request']; - }, $this->transactions); - } - - /** - * Get the number of requests in the history - * - * @return int - */ - public function count() - { - return count($this->transactions); - } - - /** - * Get the last request sent. - * - * Requests can be modified after they are logged by the history - * subscriber. By default this method will return the actual request - * instance that was received. Pass true to this method if you wish to get - * a copy of the request that represents the request state when it was - * initially logged by the history subscriber. - * - * @param bool $asSent Set to true to get a clone of the last request that - * has not been mutated since the request was received - * by the history subscriber. - * - * @return RequestInterface - */ - public function getLastRequest($asSent = false) - { - return $asSent - ? end($this->transactions)['sent_request'] - : end($this->transactions)['request']; - } - - /** - * Get the last response in the history - * - * @return ResponseInterface|null - */ - public function getLastResponse() - { - return end($this->transactions)['response']; - } - - /** - * Clears the history - */ - public function clear() - { - $this->transactions = array(); - } - - /** - * Add a request to the history - * - * @param RequestInterface $request Request to add - * @param ResponseInterface $response Response of the request - */ - private function add( - RequestInterface $request, - ResponseInterface $response = null - ) { - $this->transactions[] = [ - 'request' => $request, - 'sent_request' => clone $request, - 'response' => $response - ]; - if (count($this->transactions) > $this->limit) { - array_shift($this->transactions); - } - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Subscriber/HttpError.php b/vendor/guzzlehttp/guzzle/src/Subscriber/HttpError.php deleted file mode 100644 index ed9de5b..0000000 --- a/vendor/guzzlehttp/guzzle/src/Subscriber/HttpError.php +++ /dev/null @@ -1,36 +0,0 @@ - ['onComplete', RequestEvents::VERIFY_RESPONSE]]; - } - - /** - * Throw a RequestException on an HTTP protocol error - * - * @param CompleteEvent $event Emitted event - * @throws RequestException - */ - public function onComplete(CompleteEvent $event) - { - $code = (string) $event->getResponse()->getStatusCode(); - // Throw an exception for an unsuccessful response - if ($code[0] >= 4) { - throw RequestException::create( - $event->getRequest(), - $event->getResponse() - ); - } - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Subscriber/Mock.php b/vendor/guzzlehttp/guzzle/src/Subscriber/Mock.php deleted file mode 100644 index 2af4d37..0000000 --- a/vendor/guzzlehttp/guzzle/src/Subscriber/Mock.php +++ /dev/null @@ -1,147 +0,0 @@ -factory = new MessageFactory(); - $this->readBodies = $readBodies; - $this->addMultiple($items); - } - - public function getEvents() - { - // Fire the event last, after signing - return ['before' => ['onBefore', RequestEvents::SIGN_REQUEST - 10]]; - } - - /** - * @throws \OutOfBoundsException|\Exception - */ - public function onBefore(BeforeEvent $event) - { - if (!$item = array_shift($this->queue)) { - throw new \OutOfBoundsException('Mock queue is empty'); - } elseif ($item instanceof RequestException) { - throw $item; - } - - // Emulate reading a response body - $request = $event->getRequest(); - if ($this->readBodies && $request->getBody()) { - while (!$request->getBody()->eof()) { - $request->getBody()->read(8096); - } - } - - $saveTo = $event->getRequest()->getConfig()->get('save_to'); - - if (null !== $saveTo) { - $body = $item->getBody(); - - if (is_resource($saveTo)) { - fwrite($saveTo, $body); - } elseif (is_string($saveTo)) { - file_put_contents($saveTo, $body); - } elseif ($saveTo instanceof StreamInterface) { - $saveTo->write($body); - } - } - - $event->intercept($item); - } - - public function count() - { - return count($this->queue); - } - - /** - * Add a response to the end of the queue - * - * @param string|ResponseInterface $response Response or path to response file - * - * @return self - * @throws \InvalidArgumentException if a string or Response is not passed - */ - public function addResponse($response) - { - if (is_string($response)) { - $response = file_exists($response) - ? $this->factory->fromMessage(file_get_contents($response)) - : $this->factory->fromMessage($response); - } elseif (!($response instanceof ResponseInterface)) { - throw new \InvalidArgumentException('Response must a message ' - . 'string, response object, or path to a file'); - } - - $this->queue[] = $response; - - return $this; - } - - /** - * Add an exception to the end of the queue - * - * @param RequestException $e Exception to throw when the request is executed - * - * @return self - */ - public function addException(RequestException $e) - { - $this->queue[] = $e; - - return $this; - } - - /** - * Add multiple items to the queue - * - * @param array $items Items to add - */ - public function addMultiple(array $items) - { - foreach ($items as $item) { - if ($item instanceof RequestException) { - $this->addException($item); - } else { - $this->addResponse($item); - } - } - } - - /** - * Clear the queue - */ - public function clearQueue() - { - $this->queue = []; - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Subscriber/Prepare.php b/vendor/guzzlehttp/guzzle/src/Subscriber/Prepare.php deleted file mode 100644 index b5ed4e2..0000000 --- a/vendor/guzzlehttp/guzzle/src/Subscriber/Prepare.php +++ /dev/null @@ -1,130 +0,0 @@ - ['onBefore', RequestEvents::PREPARE_REQUEST]]; - } - - public function onBefore(BeforeEvent $event) - { - $request = $event->getRequest(); - - // Set the appropriate Content-Type for a request if one is not set and - // there are form fields - if (!($body = $request->getBody())) { - return; - } - - $this->addContentLength($request, $body); - - if ($body instanceof AppliesHeadersInterface) { - // Synchronize the body with the request headers - $body->applyRequestHeaders($request); - } elseif (!$request->hasHeader('Content-Type')) { - $this->addContentType($request, $body); - } - - $this->addExpectHeader($request, $body); - } - - private function addContentType( - RequestInterface $request, - StreamInterface $body - ) { - if (!($uri = $body->getMetadata('uri'))) { - return; - } - - // Guess the content-type based on the stream's "uri" metadata value. - // The file extension is used to determine the appropriate mime-type. - if ($contentType = Mimetypes::getInstance()->fromFilename($uri)) { - $request->setHeader('Content-Type', $contentType); - } - } - - private function addContentLength( - RequestInterface $request, - StreamInterface $body - ) { - // Set the Content-Length header if it can be determined, and never - // send a Transfer-Encoding: chunked and Content-Length header in - // the same request. - if ($request->hasHeader('Content-Length')) { - // Remove transfer-encoding if content-length is set. - $request->removeHeader('Transfer-Encoding'); - return; - } - - if ($request->hasHeader('Transfer-Encoding')) { - return; - } - - if (null !== ($size = $body->getSize())) { - $request->setHeader('Content-Length', $size); - $request->removeHeader('Transfer-Encoding'); - } elseif ('1.1' == $request->getProtocolVersion()) { - // Use chunked Transfer-Encoding if there is no determinable - // content-length header and we're using HTTP/1.1. - $request->setHeader('Transfer-Encoding', 'chunked'); - $request->removeHeader('Content-Length'); - } - } - - private function addExpectHeader( - RequestInterface $request, - StreamInterface $body - ) { - // Determine if the Expect header should be used - if ($request->hasHeader('Expect')) { - return; - } - - $expect = $request->getConfig()['expect']; - - // Return if disabled or if you're not using HTTP/1.1 - if ($expect === false || $request->getProtocolVersion() !== '1.1') { - return; - } - - // The expect header is unconditionally enabled - if ($expect === true) { - $request->setHeader('Expect', '100-Continue'); - return; - } - - // By default, send the expect header when the payload is > 1mb - if ($expect === null) { - $expect = 1048576; - } - - // Always add if the body cannot be rewound, the size cannot be - // determined, or the size is greater than the cutoff threshold - $size = $body->getSize(); - if ($size === null || $size >= (int) $expect || !$body->isSeekable()) { - $request->setHeader('Expect', '100-Continue'); - } - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Subscriber/Redirect.php b/vendor/guzzlehttp/guzzle/src/Subscriber/Redirect.php deleted file mode 100644 index ff99226..0000000 --- a/vendor/guzzlehttp/guzzle/src/Subscriber/Redirect.php +++ /dev/null @@ -1,176 +0,0 @@ - ['onComplete', RequestEvents::REDIRECT_RESPONSE]]; - } - - /** - * Rewind the entity body of the request if needed - * - * @param RequestInterface $redirectRequest - * @throws CouldNotRewindStreamException - */ - public static function rewindEntityBody(RequestInterface $redirectRequest) - { - // Rewind the entity body of the request if needed - if ($body = $redirectRequest->getBody()) { - // Only rewind the body if some of it has been read already, and - // throw an exception if the rewind fails - if ($body->tell() && !$body->seek(0)) { - throw new CouldNotRewindStreamException( - 'Unable to rewind the non-seekable request body after redirecting', - $redirectRequest - ); - } - } - } - - /** - * Called when a request receives a redirect response - * - * @param CompleteEvent $event Event emitted - * @throws TooManyRedirectsException - */ - public function onComplete(CompleteEvent $event) - { - $response = $event->getResponse(); - - if (substr($response->getStatusCode(), 0, 1) != '3' - || !$response->hasHeader('Location') - ) { - return; - } - - $request = $event->getRequest(); - $config = $request->getConfig(); - - // Increment the redirect and initialize the redirect state. - if ($redirectCount = $config['redirect_count']) { - $config['redirect_count'] = ++$redirectCount; - } else { - $config['redirect_scheme'] = $request->getScheme(); - $config['redirect_count'] = $redirectCount = 1; - } - - $max = $config->getPath('redirect/max') ?: 5; - - if ($redirectCount > $max) { - throw new TooManyRedirectsException( - "Will not follow more than {$redirectCount} redirects", - $request - ); - } - - $this->modifyRedirectRequest($request, $response); - $event->retry(); - } - - private function modifyRedirectRequest( - RequestInterface $request, - ResponseInterface $response - ) { - $config = $request->getConfig(); - $protocols = $config->getPath('redirect/protocols') ?: ['http', 'https']; - - // Use a GET request if this is an entity enclosing request and we are - // not forcing RFC compliance, but rather emulating what all browsers - // would do. - $statusCode = $response->getStatusCode(); - if ($statusCode == 303 || - ($statusCode <= 302 && $request->getBody() && !$config->getPath('redirect/strict')) - ) { - $request->setMethod('GET'); - $request->setBody(null); - } - - $previousUrl = $request->getUrl(); - $this->setRedirectUrl($request, $response, $protocols); - $this->rewindEntityBody($request); - - // Add the Referer header if it is told to do so and only - // add the header if we are not redirecting from https to http. - if ($config->getPath('redirect/referer') - && ($request->getScheme() == 'https' || $request->getScheme() == $config['redirect_scheme']) - ) { - $url = Url::fromString($previousUrl); - $url->setUsername(null); - $url->setPassword(null); - $request->setHeader('Referer', (string) $url); - } else { - $request->removeHeader('Referer'); - } - } - - /** - * Set the appropriate URL on the request based on the location header - * - * @param RequestInterface $request - * @param ResponseInterface $response - * @param array $protocols - */ - private function setRedirectUrl( - RequestInterface $request, - ResponseInterface $response, - array $protocols - ) { - $location = $response->getHeader('Location'); - $location = Url::fromString($location); - - // Combine location with the original URL if it is not absolute. - if (!$location->isAbsolute()) { - $originalUrl = Url::fromString($request->getUrl()); - // Remove query string parameters and just take what is present on - // the redirect Location header - $originalUrl->getQuery()->clear(); - $location = $originalUrl->combine($location); - } - - // Ensure that the redirect URL is allowed based on the protocols. - if (!in_array($location->getScheme(), $protocols)) { - throw new BadResponseException( - sprintf( - 'Redirect URL, %s, does not use one of the allowed redirect protocols: %s', - $location, - implode(', ', $protocols) - ), - $request, - $response - ); - } - - $request->setUrl($location); - } -} diff --git a/vendor/guzzlehttp/guzzle/src/ToArrayInterface.php b/vendor/guzzlehttp/guzzle/src/ToArrayInterface.php deleted file mode 100644 index d57c022..0000000 --- a/vendor/guzzlehttp/guzzle/src/ToArrayInterface.php +++ /dev/null @@ -1,15 +0,0 @@ -client = $client; - $this->request = $request; - $this->_future = $future; - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Url.php b/vendor/guzzlehttp/guzzle/src/Url.php deleted file mode 100644 index 637f60c..0000000 --- a/vendor/guzzlehttp/guzzle/src/Url.php +++ /dev/null @@ -1,595 +0,0 @@ - 80, 'https' => 443, 'ftp' => 21]; - private static $pathPattern = '/[^a-zA-Z0-9\-\._~!\$&\'\(\)\*\+,;=%:@\/]+|%(?![A-Fa-f0-9]{2})/'; - private static $queryPattern = '/[^a-zA-Z0-9\-\._~!\$\'\(\)\*\+,;%:@\/\?=&]+|%(?![A-Fa-f0-9]{2})/'; - /** @var Query|string Query part of the URL */ - private $query; - - /** - * Factory method to create a new URL from a URL string - * - * @param string $url Full URL used to create a Url object - * - * @return Url - * @throws \InvalidArgumentException - */ - public static function fromString($url) - { - static $defaults = ['scheme' => null, 'host' => null, - 'path' => null, 'port' => null, 'query' => null, - 'user' => null, 'pass' => null, 'fragment' => null]; - - if (false === ($parts = parse_url($url))) { - throw new \InvalidArgumentException('Unable to parse malformed ' - . 'url: ' . $url); - } - - $parts += $defaults; - - // Convert the query string into a Query object - if ($parts['query'] || 0 !== strlen($parts['query'])) { - $parts['query'] = Query::fromString($parts['query']); - } - - return new static($parts['scheme'], $parts['host'], $parts['user'], - $parts['pass'], $parts['port'], $parts['path'], $parts['query'], - $parts['fragment']); - } - - /** - * Build a URL from parse_url parts. The generated URL will be a relative - * URL if a scheme or host are not provided. - * - * @param array $parts Array of parse_url parts - * - * @return string - */ - public static function buildUrl(array $parts) - { - $url = $scheme = ''; - - if (!empty($parts['scheme'])) { - $scheme = $parts['scheme']; - $url .= $scheme . ':'; - } - - if (!empty($parts['host'])) { - $url .= '//'; - if (isset($parts['user'])) { - $url .= $parts['user']; - if (isset($parts['pass'])) { - $url .= ':' . $parts['pass']; - } - $url .= '@'; - } - - $url .= $parts['host']; - - // Only include the port if it is not the default port of the scheme - if (isset($parts['port']) && - (!isset(self::$defaultPorts[$scheme]) || - $parts['port'] != self::$defaultPorts[$scheme]) - ) { - $url .= ':' . $parts['port']; - } - } - - // Add the path component if present - if (isset($parts['path']) && strlen($parts['path'])) { - // Always ensure that the path begins with '/' if set and something - // is before the path - if (!empty($parts['host']) && $parts['path'][0] != '/') { - $url .= '/'; - } - $url .= $parts['path']; - } - - // Add the query string if present - if (isset($parts['query'])) { - $queryStr = (string) $parts['query']; - if ($queryStr || $queryStr === '0') { - $url .= '?' . $queryStr; - } - } - - // Ensure that # is only added to the url if fragment contains anything. - if (isset($parts['fragment'])) { - $url .= '#' . $parts['fragment']; - } - - return $url; - } - - /** - * Create a new URL from URL parts - * - * @param string $scheme Scheme of the URL - * @param string $host Host of the URL - * @param string $username Username of the URL - * @param string $password Password of the URL - * @param int $port Port of the URL - * @param string $path Path of the URL - * @param Query|array|string $query Query string of the URL - * @param string $fragment Fragment of the URL - */ - public function __construct( - $scheme, - $host, - $username = null, - $password = null, - $port = null, - $path = null, - $query = null, - $fragment = null - ) { - $this->scheme = strtolower($scheme); - $this->host = $host; - $this->port = $port; - $this->username = $username; - $this->password = $password; - $this->fragment = $fragment; - - if ($query) { - $this->setQuery($query); - } - - $this->setPath($path); - } - - /** - * Clone the URL - */ - public function __clone() - { - if ($this->query instanceof Query) { - $this->query = clone $this->query; - } - } - - /** - * Returns the URL as a URL string - * - * @return string - */ - public function __toString() - { - return static::buildUrl($this->getParts()); - } - - /** - * Get the parts of the URL as an array - * - * @return array - */ - public function getParts() - { - return array( - 'scheme' => $this->scheme, - 'user' => $this->username, - 'pass' => $this->password, - 'host' => $this->host, - 'port' => $this->port, - 'path' => $this->path, - 'query' => $this->query, - 'fragment' => $this->fragment, - ); - } - - /** - * Set the host of the request. - * - * @param string $host Host to set (e.g. www.yahoo.com, yahoo.com) - * - * @return Url - */ - public function setHost($host) - { - if (strpos($host, ':') === false) { - $this->host = $host; - } else { - list($host, $port) = explode(':', $host); - $this->host = $host; - $this->setPort($port); - } - } - - /** - * Get the host part of the URL - * - * @return string - */ - public function getHost() - { - return $this->host; - } - - /** - * Set the scheme part of the URL (http, https, ftp, etc.) - * - * @param string $scheme Scheme to set - */ - public function setScheme($scheme) - { - // Remove the default port if one is specified - if ($this->port - && isset(self::$defaultPorts[$this->scheme]) - && self::$defaultPorts[$this->scheme] == $this->port - ) { - $this->port = null; - } - - $this->scheme = strtolower($scheme); - } - - /** - * Get the scheme part of the URL - * - * @return string - */ - public function getScheme() - { - return $this->scheme; - } - - /** - * Set the port part of the URL - * - * @param int $port Port to set - */ - public function setPort($port) - { - $this->port = $port; - } - - /** - * Get the port part of the URl. - * - * If no port was set, this method will return the default port for the - * scheme of the URI. - * - * @return int|null - */ - public function getPort() - { - if ($this->port) { - return $this->port; - } elseif (isset(self::$defaultPorts[$this->scheme])) { - return self::$defaultPorts[$this->scheme]; - } - - return null; - } - - /** - * Set the path part of the URL. - * - * The provided URL is URL encoded as necessary. - * - * @param string $path Path string to set - */ - public function setPath($path) - { - $this->path = self::encodePath($path); - } - - /** - * Removes dot segments from a URL - * @link http://tools.ietf.org/html/rfc3986#section-5.2.4 - */ - public function removeDotSegments() - { - static $noopPaths = ['' => true, '/' => true, '*' => true]; - static $ignoreSegments = ['.' => true, '..' => true]; - - if (isset($noopPaths[$this->path])) { - return; - } - - $results = []; - $segments = $this->getPathSegments(); - foreach ($segments as $segment) { - if ($segment == '..') { - array_pop($results); - } elseif (!isset($ignoreSegments[$segment])) { - $results[] = $segment; - } - } - - $newPath = implode('/', $results); - - // Add the leading slash if necessary - if (substr($this->path, 0, 1) === '/' && - substr($newPath, 0, 1) !== '/' - ) { - $newPath = '/' . $newPath; - } - - // Add the trailing slash if necessary - if ($newPath != '/' && isset($ignoreSegments[end($segments)])) { - $newPath .= '/'; - } - - $this->path = $newPath; - } - - /** - * Add a relative path to the currently set path. - * - * @param string $relativePath Relative path to add - */ - public function addPath($relativePath) - { - if ($relativePath != '/' && - is_string($relativePath) && - strlen($relativePath) > 0 - ) { - // Add a leading slash if needed - if ($relativePath[0] !== '/' && - substr($this->path, -1, 1) !== '/' - ) { - $relativePath = '/' . $relativePath; - } - - $this->setPath($this->path . $relativePath); - } - } - - /** - * Get the path part of the URL - * - * @return string - */ - public function getPath() - { - return $this->path; - } - - /** - * Get the path segments of the URL as an array - * - * @return array - */ - public function getPathSegments() - { - return explode('/', $this->path); - } - - /** - * Set the password part of the URL - * - * @param string $password Password to set - */ - public function setPassword($password) - { - $this->password = $password; - } - - /** - * Get the password part of the URL - * - * @return null|string - */ - public function getPassword() - { - return $this->password; - } - - /** - * Set the username part of the URL - * - * @param string $username Username to set - */ - public function setUsername($username) - { - $this->username = $username; - } - - /** - * Get the username part of the URl - * - * @return null|string - */ - public function getUsername() - { - return $this->username; - } - - /** - * Get the query part of the URL as a Query object - * - * @return Query - */ - public function getQuery() - { - // Convert the query string to a query object if not already done. - if (!$this->query instanceof Query) { - $this->query = $this->query === null - ? new Query() - : Query::fromString($this->query); - } - - return $this->query; - } - - /** - * Set the query part of the URL. - * - * You may provide a query string as a string and pass $rawString as true - * to provide a query string that is not parsed until a call to getQuery() - * is made. Setting a raw query string will still encode invalid characters - * in a query string. - * - * @param Query|string|array $query Query string value to set. Can - * be a string that will be parsed into a Query object, an array - * of key value pairs, or a Query object. - * @param bool $rawString Set to true when providing a raw query string. - * - * @throws \InvalidArgumentException - */ - public function setQuery($query, $rawString = false) - { - if ($query instanceof Query) { - $this->query = $query; - } elseif (is_string($query)) { - if (!$rawString) { - $this->query = Query::fromString($query); - } else { - // Ensure the query does not have illegal characters. - $this->query = preg_replace_callback( - self::$queryPattern, - [__CLASS__, 'encodeMatch'], - $query - ); - } - - } elseif (is_array($query)) { - $this->query = new Query($query); - } else { - throw new \InvalidArgumentException('Query must be a Query, ' - . 'array, or string. Got ' . Core::describeType($query)); - } - } - - /** - * Get the fragment part of the URL - * - * @return null|string - */ - public function getFragment() - { - return $this->fragment; - } - - /** - * Set the fragment part of the URL - * - * @param string $fragment Fragment to set - */ - public function setFragment($fragment) - { - $this->fragment = $fragment; - } - - /** - * Check if this is an absolute URL - * - * @return bool - */ - public function isAbsolute() - { - return $this->scheme && $this->host; - } - - /** - * Combine the URL with another URL and return a new URL instance. - * - * Follows the rules specific in RFC 3986 section 5.4. - * - * @param string $url Relative URL to combine with - * - * @return Url - * @throws \InvalidArgumentException - * @link http://tools.ietf.org/html/rfc3986#section-5.4 - */ - public function combine($url) - { - $url = static::fromString($url); - - // Use the more absolute URL as the base URL - if (!$this->isAbsolute() && $url->isAbsolute()) { - $url = $url->combine($this); - } - - $parts = $url->getParts(); - - // Passing a URL with a scheme overrides everything - if ($parts['scheme']) { - return clone $url; - } - - // Setting a host overrides the entire rest of the URL - if ($parts['host']) { - return new static( - $this->scheme, - $parts['host'], - $parts['user'], - $parts['pass'], - $parts['port'], - $parts['path'], - $parts['query'] instanceof Query - ? clone $parts['query'] - : $parts['query'], - $parts['fragment'] - ); - } - - if (!$parts['path'] && $parts['path'] !== '0') { - // The relative URL has no path, so check if it is just a query - $path = $this->path ?: ''; - $query = $parts['query'] ?: $this->query; - } else { - $query = $parts['query']; - if ($parts['path'][0] == '/' || !$this->path) { - // Overwrite the existing path if the rel path starts with "/" - $path = $parts['path']; - } else { - // If the relative URL does not have a path or the base URL - // path does not end in a "/" then overwrite the existing path - // up to the last "/" - $path = substr($this->path, 0, strrpos($this->path, '/') + 1) . $parts['path']; - } - } - - $result = new self( - $this->scheme, - $this->host, - $this->username, - $this->password, - $this->port, - $path, - $query instanceof Query ? clone $query : $query, - $parts['fragment'] - ); - - if ($path) { - $result->removeDotSegments(); - } - - return $result; - } - - /** - * Encodes the path part of a URL without double-encoding percent-encoded - * key value pairs. - * - * @param string $path Path to encode - * - * @return string - */ - public static function encodePath($path) - { - static $cb = [__CLASS__, 'encodeMatch']; - return preg_replace_callback(self::$pathPattern, $cb, $path); - } - - private static function encodeMatch(array $match) - { - return rawurlencode($match[0]); - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Utils.php b/vendor/guzzlehttp/guzzle/src/Utils.php deleted file mode 100644 index 1754719..0000000 --- a/vendor/guzzlehttp/guzzle/src/Utils.php +++ /dev/null @@ -1,215 +0,0 @@ -expand($template, $variables); - } - - /** - * Wrapper for JSON decode that implements error detection with helpful - * error messages. - * - * @param string $json JSON data to parse - * @param bool $assoc When true, returned objects will be converted - * into associative arrays. - * @param int $depth User specified recursion depth. - * @param int $options Bitmask of JSON decode options. - * - * @return mixed - * @throws \InvalidArgumentException if the JSON cannot be parsed. - * @link http://www.php.net/manual/en/function.json-decode.php - */ - public static function jsonDecode($json, $assoc = false, $depth = 512, $options = 0) - { - if ($json === '' || $json === null) { - return null; - } - - static $jsonErrors = [ - JSON_ERROR_DEPTH => 'JSON_ERROR_DEPTH - Maximum stack depth exceeded', - JSON_ERROR_STATE_MISMATCH => 'JSON_ERROR_STATE_MISMATCH - Underflow or the modes mismatch', - JSON_ERROR_CTRL_CHAR => 'JSON_ERROR_CTRL_CHAR - Unexpected control character found', - JSON_ERROR_SYNTAX => 'JSON_ERROR_SYNTAX - Syntax error, malformed JSON', - JSON_ERROR_UTF8 => 'JSON_ERROR_UTF8 - Malformed UTF-8 characters, possibly incorrectly encoded' - ]; - - $data = \json_decode($json, $assoc, $depth, $options); - - if (JSON_ERROR_NONE !== json_last_error()) { - $last = json_last_error(); - throw new \InvalidArgumentException( - 'Unable to parse JSON data: ' - . (isset($jsonErrors[$last]) - ? $jsonErrors[$last] - : 'Unknown error') - ); - } - - return $data; - } - - /** - * Get the default User-Agent string to use with Guzzle - * - * @return string - */ - public static function getDefaultUserAgent() - { - static $defaultAgent = ''; - if (!$defaultAgent) { - $defaultAgent = 'Guzzle/' . ClientInterface::VERSION; - if (extension_loaded('curl')) { - $defaultAgent .= ' curl/' . curl_version()['version']; - } - $defaultAgent .= ' PHP/' . PHP_VERSION; - } - - return $defaultAgent; - } - - /** - * Create a default handler to use based on the environment - * - * @throws \RuntimeException if no viable Handler is available. - */ - public static function getDefaultHandler() - { - $default = $future = null; - - if (extension_loaded('curl')) { - $config = [ - 'select_timeout' => getenv('GUZZLE_CURL_SELECT_TIMEOUT') ?: 1 - ]; - if ($maxHandles = getenv('GUZZLE_CURL_MAX_HANDLES')) { - $config['max_handles'] = $maxHandles; - } - if (function_exists('curl_reset')) { - $default = new CurlHandler(); - $future = new CurlMultiHandler($config); - } else { - $default = new CurlMultiHandler($config); - } - } - - if (ini_get('allow_url_fopen')) { - $default = !$default - ? new StreamHandler() - : Middleware::wrapStreaming($default, new StreamHandler()); - } elseif (!$default) { - throw new \RuntimeException('Guzzle requires cURL, the ' - . 'allow_url_fopen ini setting, or a custom HTTP handler.'); - } - - return $future ? Middleware::wrapFuture($default, $future) : $default; - } -} diff --git a/vendor/guzzlehttp/ringphp/.editorconfig b/vendor/guzzlehttp/ringphp/.editorconfig deleted file mode 100644 index 70dabca..0000000 --- a/vendor/guzzlehttp/ringphp/.editorconfig +++ /dev/null @@ -1,12 +0,0 @@ -root = true - -[*] -charset = utf-8 -end_of_line = lf -indent_size = 4 -indent_style = space -insert_final_newline = true -trim_trailing_whitespace = true - -[{Makefile,*.mk}] -indent_style = tab diff --git a/vendor/guzzlehttp/ringphp/LICENSE b/vendor/guzzlehttp/ringphp/LICENSE deleted file mode 100644 index 71d3b78..0000000 --- a/vendor/guzzlehttp/ringphp/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2014 Michael Dowling, https://github.com/mtdowling - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/vendor/guzzlehttp/ringphp/composer.json b/vendor/guzzlehttp/ringphp/composer.json deleted file mode 100644 index 8df60ec..0000000 --- a/vendor/guzzlehttp/ringphp/composer.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "name": "guzzlehttp/ringphp", - "description": "Provides a simple API and specification that abstracts away the details of HTTP into a single PHP function.", - "license": "MIT", - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "require": { - "php": ">=5.4.0", - "guzzlehttp/streams": "~3.0", - "react/promise": "~2.0" - }, - "require-dev": { - "ext-curl": "*", - "phpunit/phpunit": "~4.0" - }, - "suggest": { - "ext-curl": "Guzzle will use specific adapters if cURL is present" - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\Ring\\": "src/" - } - }, - "autoload-dev": { - "psr-4": { - "GuzzleHttp\\Tests\\Ring\\": "tests/" - } - }, - "scripts": { - "test": "make test", - "test-ci": "make coverage" - }, - "extra": { - "branch-alias": { - "dev-master": "1.1-dev" - } - } -} diff --git a/vendor/guzzlehttp/ringphp/src/Client/ClientUtils.php b/vendor/guzzlehttp/ringphp/src/Client/ClientUtils.php deleted file mode 100644 index 27d5fe7..0000000 --- a/vendor/guzzlehttp/ringphp/src/Client/ClientUtils.php +++ /dev/null @@ -1,74 +0,0 @@ -getDefaultOptions($request, $headers); - $this->applyMethod($request, $options); - - if (isset($request['client'])) { - $this->applyHandlerOptions($request, $options); - } - - $this->applyHeaders($request, $options); - unset($options['_headers']); - - // Add handler options from the request's configuration options - if (isset($request['client']['curl'])) { - $options = $this->applyCustomCurlOptions( - $request['client']['curl'], - $options - ); - } - - if (!$handle) { - $handle = curl_init(); - } - - $body = $this->getOutputBody($request, $options); - curl_setopt_array($handle, $options); - - return [$handle, &$headers, $body]; - } - - /** - * Creates a response hash from a cURL result. - * - * @param callable $handler Handler that was used. - * @param array $request Request that sent. - * @param array $response Response hash to update. - * @param array $headers Headers received during transfer. - * @param resource $body Body fopen response. - * - * @return array - */ - public static function createResponse( - callable $handler, - array $request, - array $response, - array $headers, - $body - ) { - if (isset($response['transfer_stats']['url'])) { - $response['effective_url'] = $response['transfer_stats']['url']; - } - - if (!empty($headers)) { - $startLine = explode(' ', array_shift($headers), 3); - $headerList = Core::headersFromLines($headers); - $response['headers'] = $headerList; - $response['version'] = isset($startLine[0]) ? substr($startLine[0], 5) : null; - $response['status'] = isset($startLine[1]) ? (int) $startLine[1] : null; - $response['reason'] = isset($startLine[2]) ? $startLine[2] : null; - $response['body'] = $body; - Core::rewindBody($response); - } - - return !empty($response['curl']['errno']) || !isset($response['status']) - ? self::createErrorResponse($handler, $request, $response) - : $response; - } - - private static function createErrorResponse( - callable $handler, - array $request, - array $response - ) { - static $connectionErrors = [ - CURLE_OPERATION_TIMEOUTED => true, - CURLE_COULDNT_RESOLVE_HOST => true, - CURLE_COULDNT_CONNECT => true, - CURLE_SSL_CONNECT_ERROR => true, - CURLE_GOT_NOTHING => true, - ]; - - // Retry when nothing is present or when curl failed to rewind. - if (!isset($response['err_message']) - && (empty($response['curl']['errno']) - || $response['curl']['errno'] == 65) - ) { - return self::retryFailedRewind($handler, $request, $response); - } - - $message = isset($response['err_message']) - ? $response['err_message'] - : sprintf('cURL error %s: %s', - $response['curl']['errno'], - isset($response['curl']['error']) - ? $response['curl']['error'] - : 'See http://curl.haxx.se/libcurl/c/libcurl-errors.html'); - - $error = isset($response['curl']['errno']) - && isset($connectionErrors[$response['curl']['errno']]) - ? new ConnectException($message) - : new RingException($message); - - return $response + [ - 'status' => null, - 'reason' => null, - 'body' => null, - 'headers' => [], - 'error' => $error, - ]; - } - - private function getOutputBody(array $request, array &$options) - { - // Determine where the body of the response (if any) will be streamed. - if (isset($options[CURLOPT_WRITEFUNCTION])) { - return $request['client']['save_to']; - } - - if (isset($options[CURLOPT_FILE])) { - return $options[CURLOPT_FILE]; - } - - if ($request['http_method'] != 'HEAD') { - // Create a default body if one was not provided - return $options[CURLOPT_FILE] = fopen('php://temp', 'w+'); - } - - return null; - } - - private function getDefaultOptions(array $request, array &$headers) - { - $url = Core::url($request); - $startingResponse = false; - - $options = [ - '_headers' => $request['headers'], - CURLOPT_CUSTOMREQUEST => $request['http_method'], - CURLOPT_URL => $url, - CURLOPT_RETURNTRANSFER => false, - CURLOPT_HEADER => false, - CURLOPT_CONNECTTIMEOUT => 150, - CURLOPT_HEADERFUNCTION => function ($ch, $h) use (&$headers, &$startingResponse) { - $value = trim($h); - if ($value === '') { - $startingResponse = true; - } elseif ($startingResponse) { - $startingResponse = false; - $headers = [$value]; - } else { - $headers[] = $value; - } - return strlen($h); - }, - ]; - - if (isset($request['version'])) { - if ($request['version'] == 2.0) { - $options[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_2_0; - } else if ($request['version'] == 1.1) { - $options[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_1; - } else { - $options[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_0; - } - } - - if (defined('CURLOPT_PROTOCOLS')) { - $options[CURLOPT_PROTOCOLS] = CURLPROTO_HTTP | CURLPROTO_HTTPS; - } - - return $options; - } - - private function applyMethod(array $request, array &$options) - { - if (isset($request['body'])) { - $this->applyBody($request, $options); - return; - } - - switch ($request['http_method']) { - case 'PUT': - case 'POST': - // See http://tools.ietf.org/html/rfc7230#section-3.3.2 - if (!Core::hasHeader($request, 'Content-Length')) { - $options[CURLOPT_HTTPHEADER][] = 'Content-Length: 0'; - } - break; - case 'HEAD': - $options[CURLOPT_NOBODY] = true; - unset( - $options[CURLOPT_WRITEFUNCTION], - $options[CURLOPT_READFUNCTION], - $options[CURLOPT_FILE], - $options[CURLOPT_INFILE] - ); - } - } - - private function applyBody(array $request, array &$options) - { - $contentLength = Core::firstHeader($request, 'Content-Length'); - $size = $contentLength !== null ? (int) $contentLength : null; - - // Send the body as a string if the size is less than 1MB OR if the - // [client][curl][body_as_string] request value is set. - if (($size !== null && $size < 1000000) || - isset($request['client']['curl']['body_as_string']) || - is_string($request['body']) - ) { - $options[CURLOPT_POSTFIELDS] = Core::body($request); - // Don't duplicate the Content-Length header - $this->removeHeader('Content-Length', $options); - $this->removeHeader('Transfer-Encoding', $options); - } else { - $options[CURLOPT_UPLOAD] = true; - if ($size !== null) { - // Let cURL handle setting the Content-Length header - $options[CURLOPT_INFILESIZE] = $size; - $this->removeHeader('Content-Length', $options); - } - $this->addStreamingBody($request, $options); - } - - // If the Expect header is not present, prevent curl from adding it - if (!Core::hasHeader($request, 'Expect')) { - $options[CURLOPT_HTTPHEADER][] = 'Expect:'; - } - - // cURL sometimes adds a content-type by default. Prevent this. - if (!Core::hasHeader($request, 'Content-Type')) { - $options[CURLOPT_HTTPHEADER][] = 'Content-Type:'; - } - } - - private function addStreamingBody(array $request, array &$options) - { - $body = $request['body']; - - if ($body instanceof StreamInterface) { - $options[CURLOPT_READFUNCTION] = function ($ch, $fd, $length) use ($body) { - return (string) $body->read($length); - }; - if (!isset($options[CURLOPT_INFILESIZE])) { - if ($size = $body->getSize()) { - $options[CURLOPT_INFILESIZE] = $size; - } - } - } elseif (is_resource($body)) { - $options[CURLOPT_INFILE] = $body; - } elseif ($body instanceof \Iterator) { - $buf = ''; - $options[CURLOPT_READFUNCTION] = function ($ch, $fd, $length) use ($body, &$buf) { - if ($body->valid()) { - $buf .= $body->current(); - $body->next(); - } - $result = (string) substr($buf, 0, $length); - $buf = substr($buf, $length); - return $result; - }; - } else { - throw new \InvalidArgumentException('Invalid request body provided'); - } - } - - private function applyHeaders(array $request, array &$options) - { - foreach ($options['_headers'] as $name => $values) { - foreach ($values as $value) { - $options[CURLOPT_HTTPHEADER][] = "$name: $value"; - } - } - - // Remove the Accept header if one was not set - if (!Core::hasHeader($request, 'Accept')) { - $options[CURLOPT_HTTPHEADER][] = 'Accept:'; - } - } - - /** - * Takes an array of curl options specified in the 'curl' option of a - * request's configuration array and maps them to CURLOPT_* options. - * - * This method is only called when a request has a 'curl' config setting. - * - * @param array $config Configuration array of custom curl option - * @param array $options Array of existing curl options - * - * @return array Returns a new array of curl options - */ - private function applyCustomCurlOptions(array $config, array $options) - { - $curlOptions = []; - foreach ($config as $key => $value) { - if (is_int($key)) { - $curlOptions[$key] = $value; - } - } - - return $curlOptions + $options; - } - - /** - * Remove a header from the options array. - * - * @param string $name Case-insensitive header to remove - * @param array $options Array of options to modify - */ - private function removeHeader($name, array &$options) - { - foreach (array_keys($options['_headers']) as $key) { - if (!strcasecmp($key, $name)) { - unset($options['_headers'][$key]); - return; - } - } - } - - /** - * Applies an array of request client options to a the options array. - * - * This method uses a large switch rather than double-dispatch to save on - * high overhead of calling functions in PHP. - */ - private function applyHandlerOptions(array $request, array &$options) - { - foreach ($request['client'] as $key => $value) { - switch ($key) { - // Violating PSR-4 to provide more room. - case 'verify': - - if ($value === false) { - unset($options[CURLOPT_CAINFO]); - $options[CURLOPT_SSL_VERIFYHOST] = 0; - $options[CURLOPT_SSL_VERIFYPEER] = false; - continue 2; - } - - $options[CURLOPT_SSL_VERIFYHOST] = 2; - $options[CURLOPT_SSL_VERIFYPEER] = true; - - if (is_string($value)) { - $options[CURLOPT_CAINFO] = $value; - if (!file_exists($value)) { - throw new \InvalidArgumentException( - "SSL CA bundle not found: $value" - ); - } - } - break; - - case 'decode_content': - - if ($value === false) { - continue 2; - } - - $accept = Core::firstHeader($request, 'Accept-Encoding'); - if ($accept) { - $options[CURLOPT_ENCODING] = $accept; - } else { - $options[CURLOPT_ENCODING] = ''; - // Don't let curl send the header over the wire - $options[CURLOPT_HTTPHEADER][] = 'Accept-Encoding:'; - } - break; - - case 'save_to': - - if (is_string($value)) { - if (!is_dir(dirname($value))) { - throw new \RuntimeException(sprintf( - 'Directory %s does not exist for save_to value of %s', - dirname($value), - $value - )); - } - $value = new LazyOpenStream($value, 'w+'); - } - - if ($value instanceof StreamInterface) { - $options[CURLOPT_WRITEFUNCTION] = - function ($ch, $write) use ($value) { - return $value->write($write); - }; - } elseif (is_resource($value)) { - $options[CURLOPT_FILE] = $value; - } else { - throw new \InvalidArgumentException('save_to must be a ' - . 'GuzzleHttp\Stream\StreamInterface or resource'); - } - break; - - case 'timeout': - - if (defined('CURLOPT_TIMEOUT_MS')) { - $options[CURLOPT_TIMEOUT_MS] = $value * 1000; - } else { - $options[CURLOPT_TIMEOUT] = $value; - } - break; - - case 'connect_timeout': - - if (defined('CURLOPT_CONNECTTIMEOUT_MS')) { - $options[CURLOPT_CONNECTTIMEOUT_MS] = $value * 1000; - } else { - $options[CURLOPT_CONNECTTIMEOUT] = $value; - } - break; - - case 'proxy': - - if (!is_array($value)) { - $options[CURLOPT_PROXY] = $value; - } elseif (isset($request['scheme'])) { - $scheme = $request['scheme']; - if (isset($value[$scheme])) { - $options[CURLOPT_PROXY] = $value[$scheme]; - } - } - break; - - case 'cert': - - if (is_array($value)) { - $options[CURLOPT_SSLCERTPASSWD] = $value[1]; - $value = $value[0]; - } - - if (!file_exists($value)) { - throw new \InvalidArgumentException( - "SSL certificate not found: {$value}" - ); - } - - $options[CURLOPT_SSLCERT] = $value; - break; - - case 'ssl_key': - - if (is_array($value)) { - $options[CURLOPT_SSLKEYPASSWD] = $value[1]; - $value = $value[0]; - } - - if (!file_exists($value)) { - throw new \InvalidArgumentException( - "SSL private key not found: {$value}" - ); - } - - $options[CURLOPT_SSLKEY] = $value; - break; - - case 'progress': - - if (!is_callable($value)) { - throw new \InvalidArgumentException( - 'progress client option must be callable' - ); - } - - $options[CURLOPT_NOPROGRESS] = false; - $options[CURLOPT_PROGRESSFUNCTION] = - function () use ($value) { - $args = func_get_args(); - // PHP 5.5 pushed the handle onto the start of the args - if (is_resource($args[0])) { - array_shift($args); - } - call_user_func_array($value, $args); - }; - break; - - case 'debug': - - if ($value) { - $options[CURLOPT_STDERR] = Core::getDebugResource($value); - $options[CURLOPT_VERBOSE] = true; - } - break; - } - } - } - - /** - * This function ensures that a response was set on a transaction. If one - * was not set, then the request is retried if possible. This error - * typically means you are sending a payload, curl encountered a - * "Connection died, retrying a fresh connect" error, tried to rewind the - * stream, and then encountered a "necessary data rewind wasn't possible" - * error, causing the request to be sent through curl_multi_info_read() - * without an error status. - */ - private static function retryFailedRewind( - callable $handler, - array $request, - array $response - ) { - // If there is no body, then there is some other kind of issue. This - // is weird and should probably never happen. - if (!isset($request['body'])) { - $response['err_message'] = 'No response was received for a request ' - . 'with no body. This could mean that you are saturating your ' - . 'network.'; - return self::createErrorResponse($handler, $request, $response); - } - - if (!Core::rewindBody($request)) { - $response['err_message'] = 'The connection unexpectedly failed ' - . 'without providing an error. The request would have been ' - . 'retried, but attempting to rewind the request body failed.'; - return self::createErrorResponse($handler, $request, $response); - } - - // Retry no more than 3 times before giving up. - if (!isset($request['curl']['retries'])) { - $request['curl']['retries'] = 1; - } elseif ($request['curl']['retries'] == 2) { - $response['err_message'] = 'The cURL request was retried 3 times ' - . 'and did no succeed. cURL was unable to rewind the body of ' - . 'the request and subsequent retries resulted in the same ' - . 'error. Turn on the debug option to see what went wrong. ' - . 'See https://bugs.php.net/bug.php?id=47204 for more information.'; - return self::createErrorResponse($handler, $request, $response); - } else { - $request['curl']['retries']++; - } - - return $handler($request); - } -} diff --git a/vendor/guzzlehttp/ringphp/src/Client/CurlHandler.php b/vendor/guzzlehttp/ringphp/src/Client/CurlHandler.php deleted file mode 100644 index e00aa4e..0000000 --- a/vendor/guzzlehttp/ringphp/src/Client/CurlHandler.php +++ /dev/null @@ -1,135 +0,0 @@ -handles = $this->ownedHandles = []; - $this->factory = isset($options['handle_factory']) - ? $options['handle_factory'] - : new CurlFactory(); - $this->maxHandles = isset($options['max_handles']) - ? $options['max_handles'] - : 5; - } - - public function __destruct() - { - foreach ($this->handles as $handle) { - if (is_resource($handle)) { - curl_close($handle); - } - } - } - - /** - * @param array $request - * - * @return CompletedFutureArray - */ - public function __invoke(array $request) - { - return new CompletedFutureArray( - $this->_invokeAsArray($request) - ); - } - - /** - * @internal - * - * @param array $request - * - * @return array - */ - public function _invokeAsArray(array $request) - { - $factory = $this->factory; - - // Ensure headers are by reference. They're updated elsewhere. - $result = $factory($request, $this->checkoutEasyHandle()); - $h = $result[0]; - $hd =& $result[1]; - $bd = $result[2]; - Core::doSleep($request); - curl_exec($h); - $response = ['transfer_stats' => curl_getinfo($h)]; - $response['curl']['error'] = curl_error($h); - $response['curl']['errno'] = curl_errno($h); - $response['transfer_stats'] = array_merge($response['transfer_stats'], $response['curl']); - $this->releaseEasyHandle($h); - - return CurlFactory::createResponse([$this, '_invokeAsArray'], $request, $response, $hd, $bd); - } - - private function checkoutEasyHandle() - { - // Find an unused handle in the cache - if (false !== ($key = array_search(false, $this->ownedHandles, true))) { - $this->ownedHandles[$key] = true; - return $this->handles[$key]; - } - - // Add a new handle - $handle = curl_init(); - $id = (int) $handle; - $this->handles[$id] = $handle; - $this->ownedHandles[$id] = true; - - return $handle; - } - - private function releaseEasyHandle($handle) - { - $id = (int) $handle; - if (count($this->ownedHandles) > $this->maxHandles) { - curl_close($this->handles[$id]); - unset($this->handles[$id], $this->ownedHandles[$id]); - } else { - // curl_reset doesn't clear these out for some reason - static $unsetValues = [ - CURLOPT_HEADERFUNCTION => null, - CURLOPT_WRITEFUNCTION => null, - CURLOPT_READFUNCTION => null, - CURLOPT_PROGRESSFUNCTION => null, - ]; - curl_setopt_array($handle, $unsetValues); - curl_reset($handle); - $this->ownedHandles[$id] = false; - } - } -} diff --git a/vendor/guzzlehttp/ringphp/src/Client/CurlMultiHandler.php b/vendor/guzzlehttp/ringphp/src/Client/CurlMultiHandler.php deleted file mode 100644 index f84cf19..0000000 --- a/vendor/guzzlehttp/ringphp/src/Client/CurlMultiHandler.php +++ /dev/null @@ -1,248 +0,0 @@ -_mh = $options['mh']; - } - $this->factory = isset($options['handle_factory']) - ? $options['handle_factory'] : new CurlFactory(); - $this->selectTimeout = isset($options['select_timeout']) - ? $options['select_timeout'] : 1; - $this->maxHandles = isset($options['max_handles']) - ? $options['max_handles'] : 100; - } - - public function __get($name) - { - if ($name === '_mh') { - return $this->_mh = curl_multi_init(); - } - - throw new \BadMethodCallException(); - } - - public function __destruct() - { - // Finish any open connections before terminating the script. - if ($this->handles) { - $this->execute(); - } - - if (isset($this->_mh)) { - curl_multi_close($this->_mh); - unset($this->_mh); - } - } - - public function __invoke(array $request) - { - $factory = $this->factory; - $result = $factory($request); - $entry = [ - 'request' => $request, - 'response' => [], - 'handle' => $result[0], - 'headers' => &$result[1], - 'body' => $result[2], - 'deferred' => new Deferred(), - ]; - - $id = (int) $result[0]; - - $future = new FutureArray( - $entry['deferred']->promise(), - [$this, 'execute'], - function () use ($id) { - return $this->cancel($id); - } - ); - - $this->addRequest($entry); - - // Transfer outstanding requests if there are too many open handles. - if (count($this->handles) >= $this->maxHandles) { - $this->execute(); - } - - return $future; - } - - /** - * Runs until all outstanding connections have completed. - */ - public function execute() - { - do { - - if ($this->active && - curl_multi_select($this->_mh, $this->selectTimeout) === -1 - ) { - // Perform a usleep if a select returns -1. - // See: https://bugs.php.net/bug.php?id=61141 - usleep(250); - } - - // Add any delayed futures if needed. - if ($this->delays) { - $this->addDelays(); - } - - do { - $mrc = curl_multi_exec($this->_mh, $this->active); - } while ($mrc === CURLM_CALL_MULTI_PERFORM); - - $this->processMessages(); - - // If there are delays but no transfers, then sleep for a bit. - if (!$this->active && $this->delays) { - usleep(500); - } - - } while ($this->active || $this->handles); - } - - private function addRequest(array &$entry) - { - $id = (int) $entry['handle']; - $this->handles[$id] = $entry; - - // If the request is a delay, then add the reques to the curl multi - // pool only after the specified delay. - if (isset($entry['request']['client']['delay'])) { - $this->delays[$id] = microtime(true) + ($entry['request']['client']['delay'] / 1000); - } elseif (empty($entry['request']['future'])) { - curl_multi_add_handle($this->_mh, $entry['handle']); - } else { - curl_multi_add_handle($this->_mh, $entry['handle']); - // "lazy" futures are only sent once the pool has many requests. - if ($entry['request']['future'] !== 'lazy') { - do { - $mrc = curl_multi_exec($this->_mh, $this->active); - } while ($mrc === CURLM_CALL_MULTI_PERFORM); - $this->processMessages(); - } - } - } - - private function removeProcessed($id) - { - if (isset($this->handles[$id])) { - curl_multi_remove_handle( - $this->_mh, - $this->handles[$id]['handle'] - ); - curl_close($this->handles[$id]['handle']); - unset($this->handles[$id], $this->delays[$id]); - } - } - - /** - * Cancels a handle from sending and removes references to it. - * - * @param int $id Handle ID to cancel and remove. - * - * @return bool True on success, false on failure. - */ - private function cancel($id) - { - // Cannot cancel if it has been processed. - if (!isset($this->handles[$id])) { - return false; - } - - $handle = $this->handles[$id]['handle']; - unset($this->delays[$id], $this->handles[$id]); - curl_multi_remove_handle($this->_mh, $handle); - curl_close($handle); - - return true; - } - - private function addDelays() - { - $currentTime = microtime(true); - - foreach ($this->delays as $id => $delay) { - if ($currentTime >= $delay) { - unset($this->delays[$id]); - curl_multi_add_handle( - $this->_mh, - $this->handles[$id]['handle'] - ); - } - } - } - - private function processMessages() - { - while ($done = curl_multi_info_read($this->_mh)) { - $id = (int) $done['handle']; - - if (!isset($this->handles[$id])) { - // Probably was cancelled. - continue; - } - - $entry = $this->handles[$id]; - $entry['response']['transfer_stats'] = curl_getinfo($done['handle']); - - if ($done['result'] !== CURLM_OK) { - $entry['response']['curl']['errno'] = $done['result']; - $entry['response']['curl']['error'] = curl_error($done['handle']); - } - - $result = CurlFactory::createResponse( - $this, - $entry['request'], - $entry['response'], - $entry['headers'], - $entry['body'] - ); - - $this->removeProcessed($id); - $entry['deferred']->resolve($result); - } - } -} diff --git a/vendor/guzzlehttp/ringphp/src/Client/Middleware.php b/vendor/guzzlehttp/ringphp/src/Client/Middleware.php deleted file mode 100644 index 6fa7318..0000000 --- a/vendor/guzzlehttp/ringphp/src/Client/Middleware.php +++ /dev/null @@ -1,58 +0,0 @@ -result = $result; - } - - public function __invoke(array $request) - { - Core::doSleep($request); - $response = is_callable($this->result) - ? call_user_func($this->result, $request) - : $this->result; - - if (is_array($response)) { - $response = new CompletedFutureArray($response + [ - 'status' => null, - 'body' => null, - 'headers' => [], - 'reason' => null, - 'effective_url' => null, - ]); - } elseif (!$response instanceof FutureArrayInterface) { - throw new \InvalidArgumentException( - 'Response must be an array or FutureArrayInterface. Found ' - . Core::describeType($request) - ); - } - - return $response; - } -} diff --git a/vendor/guzzlehttp/ringphp/src/Client/StreamHandler.php b/vendor/guzzlehttp/ringphp/src/Client/StreamHandler.php deleted file mode 100644 index 4bacec1..0000000 --- a/vendor/guzzlehttp/ringphp/src/Client/StreamHandler.php +++ /dev/null @@ -1,414 +0,0 @@ -options = $options; - } - - public function __invoke(array $request) - { - $url = Core::url($request); - Core::doSleep($request); - - try { - // Does not support the expect header. - $request = Core::removeHeader($request, 'Expect'); - $stream = $this->createStream($url, $request); - return $this->createResponse($request, $url, $stream); - } catch (RingException $e) { - return $this->createErrorResponse($url, $e); - } - } - - private function createResponse(array $request, $url, $stream) - { - $hdrs = $this->lastHeaders; - $this->lastHeaders = null; - $parts = explode(' ', array_shift($hdrs), 3); - $response = [ - 'version' => substr($parts[0], 5), - 'status' => $parts[1], - 'reason' => isset($parts[2]) ? $parts[2] : null, - 'headers' => Core::headersFromLines($hdrs), - 'effective_url' => $url, - ]; - - $stream = $this->checkDecode($request, $response, $stream); - - // If not streaming, then drain the response into a stream. - if (empty($request['client']['stream'])) { - $dest = isset($request['client']['save_to']) - ? $request['client']['save_to'] - : fopen('php://temp', 'r+'); - $stream = $this->drain($stream, $dest); - } - - $response['body'] = $stream; - - return new CompletedFutureArray($response); - } - - private function checkDecode(array $request, array $response, $stream) - { - // Automatically decode responses when instructed. - if (!empty($request['client']['decode_content'])) { - switch (Core::firstHeader($response, 'Content-Encoding', true)) { - case 'gzip': - case 'deflate': - $stream = new InflateStream(Stream::factory($stream)); - break; - } - } - - return $stream; - } - - /** - * Drains the stream into the "save_to" client option. - * - * @param resource $stream - * @param string|resource|StreamInterface $dest - * - * @return Stream - * @throws \RuntimeException when the save_to option is invalid. - */ - private function drain($stream, $dest) - { - if (is_resource($stream)) { - if (!is_resource($dest)) { - $stream = Stream::factory($stream); - } else { - stream_copy_to_stream($stream, $dest); - fclose($stream); - rewind($dest); - return $dest; - } - } - - // Stream the response into the destination stream - $dest = is_string($dest) - ? new Stream(Utils::open($dest, 'r+')) - : Stream::factory($dest); - - Utils::copyToStream($stream, $dest); - $dest->seek(0); - $stream->close(); - - return $dest; - } - - /** - * Creates an error response for the given stream. - * - * @param string $url - * @param RingException $e - * - * @return array - */ - private function createErrorResponse($url, RingException $e) - { - // Determine if the error was a networking error. - $message = $e->getMessage(); - - // This list can probably get more comprehensive. - if (strpos($message, 'getaddrinfo') // DNS lookup failed - || strpos($message, 'Connection refused') - ) { - $e = new ConnectException($e->getMessage(), 0, $e); - } - - return new CompletedFutureArray([ - 'status' => null, - 'body' => null, - 'headers' => [], - 'effective_url' => $url, - 'error' => $e - ]); - } - - /** - * Create a resource and check to ensure it was created successfully - * - * @param callable $callback Callable that returns stream resource - * - * @return resource - * @throws \RuntimeException on error - */ - private function createResource(callable $callback) - { - $errors = null; - set_error_handler(function ($_, $msg, $file, $line) use (&$errors) { - $errors[] = [ - 'message' => $msg, - 'file' => $file, - 'line' => $line - ]; - return true; - }); - - $resource = $callback(); - restore_error_handler(); - - if (!$resource) { - $message = 'Error creating resource: '; - foreach ($errors as $err) { - foreach ($err as $key => $value) { - $message .= "[$key] $value" . PHP_EOL; - } - } - throw new RingException(trim($message)); - } - - return $resource; - } - - private function createStream($url, array $request) - { - static $methods; - if (!$methods) { - $methods = array_flip(get_class_methods(__CLASS__)); - } - - // HTTP/1.1 streams using the PHP stream wrapper require a - // Connection: close header - if ((!isset($request['version']) || $request['version'] == '1.1') - && !Core::hasHeader($request, 'Connection') - ) { - $request['headers']['Connection'] = ['close']; - } - - // Ensure SSL is verified by default - if (!isset($request['client']['verify'])) { - $request['client']['verify'] = true; - } - - $params = []; - $options = $this->getDefaultOptions($request); - - if (isset($request['client'])) { - foreach ($request['client'] as $key => $value) { - $method = "add_{$key}"; - if (isset($methods[$method])) { - $this->{$method}($request, $options, $value, $params); - } - } - } - - return $this->createStreamResource( - $url, - $request, - $options, - $this->createContext($request, $options, $params) - ); - } - - private function getDefaultOptions(array $request) - { - $headers = ""; - foreach ($request['headers'] as $name => $value) { - foreach ((array) $value as $val) { - $headers .= "$name: $val\r\n"; - } - } - - $context = [ - 'http' => [ - 'method' => $request['http_method'], - 'header' => $headers, - 'protocol_version' => isset($request['version']) ? $request['version'] : 1.1, - 'ignore_errors' => true, - 'follow_location' => 0, - ], - ]; - - $body = Core::body($request); - if (isset($body)) { - $context['http']['content'] = $body; - // Prevent the HTTP handler from adding a Content-Type header. - if (!Core::hasHeader($request, 'Content-Type')) { - $context['http']['header'] .= "Content-Type:\r\n"; - } - } - - $context['http']['header'] = rtrim($context['http']['header']); - - return $context; - } - - private function add_proxy(array $request, &$options, $value, &$params) - { - if (!is_array($value)) { - $options['http']['proxy'] = $value; - } else { - $scheme = isset($request['scheme']) ? $request['scheme'] : 'http'; - if (isset($value[$scheme])) { - $options['http']['proxy'] = $value[$scheme]; - } - } - } - - private function add_timeout(array $request, &$options, $value, &$params) - { - $options['http']['timeout'] = $value; - } - - private function add_verify(array $request, &$options, $value, &$params) - { - if ($value === true) { - // PHP 5.6 or greater will find the system cert by default. When - // < 5.6, use the Guzzle bundled cacert. - if (PHP_VERSION_ID < 50600) { - $options['ssl']['cafile'] = ClientUtils::getDefaultCaBundle(); - } - } elseif (is_string($value)) { - $options['ssl']['cafile'] = $value; - if (!file_exists($value)) { - throw new RingException("SSL CA bundle not found: $value"); - } - } elseif ($value === false) { - $options['ssl']['verify_peer'] = false; - $options['ssl']['allow_self_signed'] = true; - return; - } else { - throw new RingException('Invalid verify request option'); - } - - $options['ssl']['verify_peer'] = true; - $options['ssl']['allow_self_signed'] = false; - } - - private function add_cert(array $request, &$options, $value, &$params) - { - if (is_array($value)) { - $options['ssl']['passphrase'] = $value[1]; - $value = $value[0]; - } - - if (!file_exists($value)) { - throw new RingException("SSL certificate not found: {$value}"); - } - - $options['ssl']['local_cert'] = $value; - } - - private function add_progress(array $request, &$options, $value, &$params) - { - $fn = function ($code, $_1, $_2, $_3, $transferred, $total) use ($value) { - if ($code == STREAM_NOTIFY_PROGRESS) { - $value($total, $transferred, null, null); - } - }; - - // Wrap the existing function if needed. - $params['notification'] = isset($params['notification']) - ? Core::callArray([$params['notification'], $fn]) - : $fn; - } - - private function add_debug(array $request, &$options, $value, &$params) - { - if ($value === false) { - return; - } - - static $map = [ - STREAM_NOTIFY_CONNECT => 'CONNECT', - STREAM_NOTIFY_AUTH_REQUIRED => 'AUTH_REQUIRED', - STREAM_NOTIFY_AUTH_RESULT => 'AUTH_RESULT', - STREAM_NOTIFY_MIME_TYPE_IS => 'MIME_TYPE_IS', - STREAM_NOTIFY_FILE_SIZE_IS => 'FILE_SIZE_IS', - STREAM_NOTIFY_REDIRECTED => 'REDIRECTED', - STREAM_NOTIFY_PROGRESS => 'PROGRESS', - STREAM_NOTIFY_FAILURE => 'FAILURE', - STREAM_NOTIFY_COMPLETED => 'COMPLETED', - STREAM_NOTIFY_RESOLVE => 'RESOLVE', - ]; - - static $args = ['severity', 'message', 'message_code', - 'bytes_transferred', 'bytes_max']; - - $value = Core::getDebugResource($value); - $ident = $request['http_method'] . ' ' . Core::url($request); - $fn = function () use ($ident, $value, $map, $args) { - $passed = func_get_args(); - $code = array_shift($passed); - fprintf($value, '<%s> [%s] ', $ident, $map[$code]); - foreach (array_filter($passed) as $i => $v) { - fwrite($value, $args[$i] . ': "' . $v . '" '); - } - fwrite($value, "\n"); - }; - - // Wrap the existing function if needed. - $params['notification'] = isset($params['notification']) - ? Core::callArray([$params['notification'], $fn]) - : $fn; - } - - private function applyCustomOptions(array $request, array &$options) - { - if (!isset($request['client']['stream_context'])) { - return; - } - - if (!is_array($request['client']['stream_context'])) { - throw new RingException('stream_context must be an array'); - } - - $options = array_replace_recursive( - $options, - $request['client']['stream_context'] - ); - } - - private function createContext(array $request, array $options, array $params) - { - $this->applyCustomOptions($request, $options); - return $this->createResource( - function () use ($request, $options, $params) { - return stream_context_create($options, $params); - }, - $request, - $options - ); - } - - private function createStreamResource( - $url, - array $request, - array $options, - $context - ) { - return $this->createResource( - function () use ($url, $context) { - if (false === strpos($url, 'http')) { - trigger_error("URL is invalid: {$url}", E_USER_WARNING); - return null; - } - $resource = fopen($url, 'r', null, $context); - $this->lastHeaders = $http_response_header; - return $resource; - }, - $request, - $options - ); - } -} diff --git a/vendor/guzzlehttp/ringphp/src/Core.php b/vendor/guzzlehttp/ringphp/src/Core.php deleted file mode 100644 index dd7d1a0..0000000 --- a/vendor/guzzlehttp/ringphp/src/Core.php +++ /dev/null @@ -1,364 +0,0 @@ - $value) { - if (!strcasecmp($name, $header)) { - $result = array_merge($result, $value); - } - } - } - - return $result; - } - - /** - * Gets a header value from a message as a string or null - * - * This method searches through the "headers" key of a message for a header - * using a case-insensitive search. The lines of the header are imploded - * using commas into a single string return value. - * - * @param array $message Request or response hash. - * @param string $header Header to retrieve - * - * @return string|null Returns the header string if found, or null if not. - */ - public static function header($message, $header) - { - $match = self::headerLines($message, $header); - return $match ? implode(', ', $match) : null; - } - - /** - * Returns the first header value from a message as a string or null. If - * a header line contains multiple values separated by a comma, then this - * function will return the first value in the list. - * - * @param array $message Request or response hash. - * @param string $header Header to retrieve - * - * @return string|null Returns the value as a string if found. - */ - public static function firstHeader($message, $header) - { - if (!empty($message['headers'])) { - foreach ($message['headers'] as $name => $value) { - if (!strcasecmp($name, $header)) { - // Return the match itself if it is a single value. - $pos = strpos($value[0], ','); - return $pos ? substr($value[0], 0, $pos) : $value[0]; - } - } - } - - return null; - } - - /** - * Returns true if a message has the provided case-insensitive header. - * - * @param array $message Request or response hash. - * @param string $header Header to check - * - * @return bool - */ - public static function hasHeader($message, $header) - { - if (!empty($message['headers'])) { - foreach ($message['headers'] as $name => $value) { - if (!strcasecmp($name, $header)) { - return true; - } - } - } - - return false; - } - - /** - * Parses an array of header lines into an associative array of headers. - * - * @param array $lines Header lines array of strings in the following - * format: "Name: Value" - * @return array - */ - public static function headersFromLines($lines) - { - $headers = []; - - foreach ($lines as $line) { - $parts = explode(':', $line, 2); - $headers[trim($parts[0])][] = isset($parts[1]) - ? trim($parts[1]) - : null; - } - - return $headers; - } - - /** - * Removes a header from a message using a case-insensitive comparison. - * - * @param array $message Message that contains 'headers' - * @param string $header Header to remove - * - * @return array - */ - public static function removeHeader(array $message, $header) - { - if (isset($message['headers'])) { - foreach (array_keys($message['headers']) as $key) { - if (!strcasecmp($header, $key)) { - unset($message['headers'][$key]); - } - } - } - - return $message; - } - - /** - * Replaces any existing case insensitive headers with the given value. - * - * @param array $message Message that contains 'headers' - * @param string $header Header to set. - * @param array $value Value to set. - * - * @return array - */ - public static function setHeader(array $message, $header, array $value) - { - $message = self::removeHeader($message, $header); - $message['headers'][$header] = $value; - - return $message; - } - - /** - * Creates a URL string from a request. - * - * If the "url" key is present on the request, it is returned, otherwise - * the url is built up based on the scheme, host, uri, and query_string - * request values. - * - * @param array $request Request to get the URL from - * - * @return string Returns the request URL as a string. - * @throws \InvalidArgumentException if no Host header is present. - */ - public static function url(array $request) - { - if (isset($request['url'])) { - return $request['url']; - } - - $uri = (isset($request['scheme']) - ? $request['scheme'] : 'http') . '://'; - - if ($host = self::header($request, 'host')) { - $uri .= $host; - } else { - throw new \InvalidArgumentException('No Host header was provided'); - } - - if (isset($request['uri'])) { - $uri .= $request['uri']; - } - - if (isset($request['query_string'])) { - $uri .= '?' . $request['query_string']; - } - - return $uri; - } - - /** - * Reads the body of a message into a string. - * - * @param array|FutureArrayInterface $message Array containing a "body" key - * - * @return null|string Returns the body as a string or null if not set. - * @throws \InvalidArgumentException if a request body is invalid. - */ - public static function body($message) - { - if (!isset($message['body'])) { - return null; - } - - if ($message['body'] instanceof StreamInterface) { - return (string) $message['body']; - } - - switch (gettype($message['body'])) { - case 'string': - return $message['body']; - case 'resource': - return stream_get_contents($message['body']); - case 'object': - if ($message['body'] instanceof \Iterator) { - return implode('', iterator_to_array($message['body'])); - } elseif (method_exists($message['body'], '__toString')) { - return (string) $message['body']; - } - default: - throw new \InvalidArgumentException('Invalid request body: ' - . self::describeType($message['body'])); - } - } - - /** - * Rewind the body of the provided message if possible. - * - * @param array $message Message that contains a 'body' field. - * - * @return bool Returns true on success, false on failure - */ - public static function rewindBody($message) - { - if ($message['body'] instanceof StreamInterface) { - return $message['body']->seek(0); - } - - if ($message['body'] instanceof \Generator) { - return false; - } - - if ($message['body'] instanceof \Iterator) { - $message['body']->rewind(); - return true; - } - - if (is_resource($message['body'])) { - return rewind($message['body']); - } - - return is_string($message['body']) - || (is_object($message['body']) - && method_exists($message['body'], '__toString')); - } - - /** - * Debug function used to describe the provided value type and class. - * - * @param mixed $input - * - * @return string Returns a string containing the type of the variable and - * if a class is provided, the class name. - */ - public static function describeType($input) - { - switch (gettype($input)) { - case 'object': - return 'object(' . get_class($input) . ')'; - case 'array': - return 'array(' . count($input) . ')'; - default: - ob_start(); - var_dump($input); - // normalize float vs double - return str_replace('double(', 'float(', rtrim(ob_get_clean())); - } - } - - /** - * Sleep for the specified amount of time specified in the request's - * ['client']['delay'] option if present. - * - * This function should only be used when a non-blocking sleep is not - * possible. - * - * @param array $request Request to sleep - */ - public static function doSleep(array $request) - { - if (isset($request['client']['delay'])) { - usleep($request['client']['delay'] * 1000); - } - } - - /** - * Returns a proxied future that modifies the dereferenced value of another - * future using a promise. - * - * @param FutureArrayInterface $future Future to wrap with a new future - * @param callable $onFulfilled Invoked when the future fulfilled - * @param callable $onRejected Invoked when the future rejected - * @param callable $onProgress Invoked when the future progresses - * - * @return FutureArray - */ - public static function proxy( - FutureArrayInterface $future, - callable $onFulfilled = null, - callable $onRejected = null, - callable $onProgress = null - ) { - return new FutureArray( - $future->then($onFulfilled, $onRejected, $onProgress), - [$future, 'wait'], - [$future, 'cancel'] - ); - } - - /** - * Returns a debug stream based on the provided variable. - * - * @param mixed $value Optional value - * - * @return resource - */ - public static function getDebugResource($value = null) - { - if (is_resource($value)) { - return $value; - } elseif (defined('STDOUT')) { - return STDOUT; - } else { - return fopen('php://output', 'w'); - } - } -} diff --git a/vendor/guzzlehttp/ringphp/src/Exception/CancelledException.php b/vendor/guzzlehttp/ringphp/src/Exception/CancelledException.php deleted file mode 100644 index 95b353a..0000000 --- a/vendor/guzzlehttp/ringphp/src/Exception/CancelledException.php +++ /dev/null @@ -1,7 +0,0 @@ -wrappedPromise = $promise; - $this->waitfn = $wait; - $this->cancelfn = $cancel; - } - - public function wait() - { - if (!$this->isRealized) { - $this->addShadow(); - if (!$this->isRealized && $this->waitfn) { - $this->invokeWait(); - } - if (!$this->isRealized) { - $this->error = new RingException('Waiting did not resolve future'); - } - } - - if ($this->error) { - throw $this->error; - } - - return $this->result; - } - - public function promise() - { - return $this->wrappedPromise; - } - - public function then( - callable $onFulfilled = null, - callable $onRejected = null, - callable $onProgress = null - ) { - return $this->wrappedPromise->then($onFulfilled, $onRejected, $onProgress); - } - - public function cancel() - { - if (!$this->isRealized) { - $cancelfn = $this->cancelfn; - $this->waitfn = $this->cancelfn = null; - $this->isRealized = true; - $this->error = new CancelledFutureAccessException(); - if ($cancelfn) { - $cancelfn($this); - } - } - } - - private function addShadow() - { - // Get the result and error when the promise is resolved. Note that - // calling this function might trigger the resolution immediately. - $this->wrappedPromise->then( - function ($value) { - $this->isRealized = true; - $this->result = $value; - $this->waitfn = $this->cancelfn = null; - }, - function ($error) { - $this->isRealized = true; - $this->error = $error; - $this->waitfn = $this->cancelfn = null; - } - ); - } - - private function invokeWait() - { - try { - $wait = $this->waitfn; - $this->waitfn = null; - $wait(); - } catch (\Exception $e) { - // Defer can throw to reject. - $this->error = $e; - $this->isRealized = true; - } - } -} diff --git a/vendor/guzzlehttp/ringphp/src/Future/CompletedFutureArray.php b/vendor/guzzlehttp/ringphp/src/Future/CompletedFutureArray.php deleted file mode 100644 index 0a90c93..0000000 --- a/vendor/guzzlehttp/ringphp/src/Future/CompletedFutureArray.php +++ /dev/null @@ -1,43 +0,0 @@ -result[$offset]); - } - - public function offsetGet($offset) - { - return $this->result[$offset]; - } - - public function offsetSet($offset, $value) - { - $this->result[$offset] = $value; - } - - public function offsetUnset($offset) - { - unset($this->result[$offset]); - } - - public function count() - { - return count($this->result); - } - - public function getIterator() - { - return new \ArrayIterator($this->result); - } -} diff --git a/vendor/guzzlehttp/ringphp/src/Future/CompletedFutureValue.php b/vendor/guzzlehttp/ringphp/src/Future/CompletedFutureValue.php deleted file mode 100644 index 0d25af7..0000000 --- a/vendor/guzzlehttp/ringphp/src/Future/CompletedFutureValue.php +++ /dev/null @@ -1,57 +0,0 @@ -result = $result; - $this->error = $e; - } - - public function wait() - { - if ($this->error) { - throw $this->error; - } - - return $this->result; - } - - public function cancel() {} - - public function promise() - { - if (!$this->cachedPromise) { - $this->cachedPromise = $this->error - ? new RejectedPromise($this->error) - : new FulfilledPromise($this->result); - } - - return $this->cachedPromise; - } - - public function then( - callable $onFulfilled = null, - callable $onRejected = null, - callable $onProgress = null - ) { - return $this->promise()->then($onFulfilled, $onRejected, $onProgress); - } -} diff --git a/vendor/guzzlehttp/ringphp/src/Future/FutureArray.php b/vendor/guzzlehttp/ringphp/src/Future/FutureArray.php deleted file mode 100644 index 3d64c96..0000000 --- a/vendor/guzzlehttp/ringphp/src/Future/FutureArray.php +++ /dev/null @@ -1,40 +0,0 @@ -_value[$offset]); - } - - public function offsetGet($offset) - { - return $this->_value[$offset]; - } - - public function offsetSet($offset, $value) - { - $this->_value[$offset] = $value; - } - - public function offsetUnset($offset) - { - unset($this->_value[$offset]); - } - - public function count() - { - return count($this->_value); - } - - public function getIterator() - { - return new \ArrayIterator($this->_value); - } -} diff --git a/vendor/guzzlehttp/ringphp/src/Future/FutureArrayInterface.php b/vendor/guzzlehttp/ringphp/src/Future/FutureArrayInterface.php deleted file mode 100644 index 58f5f73..0000000 --- a/vendor/guzzlehttp/ringphp/src/Future/FutureArrayInterface.php +++ /dev/null @@ -1,11 +0,0 @@ -_value = $this->wait(); - } -} diff --git a/vendor/guzzlehttp/streams/LICENSE b/vendor/guzzlehttp/streams/LICENSE deleted file mode 100644 index 71d3b78..0000000 --- a/vendor/guzzlehttp/streams/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2014 Michael Dowling, https://github.com/mtdowling - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/vendor/guzzlehttp/streams/composer.json b/vendor/guzzlehttp/streams/composer.json deleted file mode 100644 index 6d70343..0000000 --- a/vendor/guzzlehttp/streams/composer.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "name": "guzzlehttp/streams", - "description": "Provides a simple abstraction over streams of data", - "homepage": "http://guzzlephp.org/", - "keywords": ["stream", "guzzle"], - "license": "MIT", - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "require": { - "php": ">=5.4.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "autoload": { - "psr-4": { "GuzzleHttp\\Stream\\": "src/" } - }, - "extra": { - "branch-alias": { - "dev-master": "3.0-dev" - } - } -} diff --git a/vendor/guzzlehttp/streams/src/AppendStream.php b/vendor/guzzlehttp/streams/src/AppendStream.php deleted file mode 100644 index 94bda71..0000000 --- a/vendor/guzzlehttp/streams/src/AppendStream.php +++ /dev/null @@ -1,220 +0,0 @@ -addStream($stream); - } - } - - public function __toString() - { - try { - $this->seek(0); - return $this->getContents(); - } catch (\Exception $e) { - return ''; - } - } - - /** - * Add a stream to the AppendStream - * - * @param StreamInterface $stream Stream to append. Must be readable. - * - * @throws \InvalidArgumentException if the stream is not readable - */ - public function addStream(StreamInterface $stream) - { - if (!$stream->isReadable()) { - throw new \InvalidArgumentException('Each stream must be readable'); - } - - // The stream is only seekable if all streams are seekable - if (!$stream->isSeekable()) { - $this->seekable = false; - } - - $this->streams[] = $stream; - } - - public function getContents() - { - return Utils::copyToString($this); - } - - /** - * Closes each attached stream. - * - * {@inheritdoc} - */ - public function close() - { - $this->pos = $this->current = 0; - - foreach ($this->streams as $stream) { - $stream->close(); - } - - $this->streams = []; - } - - /** - * Detaches each attached stream - * - * {@inheritdoc} - */ - public function detach() - { - $this->close(); - $this->detached = true; - } - - public function attach($stream) - { - throw new CannotAttachException(); - } - - public function tell() - { - return $this->pos; - } - - /** - * Tries to calculate the size by adding the size of each stream. - * - * If any of the streams do not return a valid number, then the size of the - * append stream cannot be determined and null is returned. - * - * {@inheritdoc} - */ - public function getSize() - { - $size = 0; - - foreach ($this->streams as $stream) { - $s = $stream->getSize(); - if ($s === null) { - return null; - } - $size += $s; - } - - return $size; - } - - public function eof() - { - return !$this->streams || - ($this->current >= count($this->streams) - 1 && - $this->streams[$this->current]->eof()); - } - - /** - * Attempts to seek to the given position. Only supports SEEK_SET. - * - * {@inheritdoc} - */ - public function seek($offset, $whence = SEEK_SET) - { - if (!$this->seekable || $whence !== SEEK_SET) { - return false; - } - - $success = true; - $this->pos = $this->current = 0; - - // Rewind each stream - foreach ($this->streams as $stream) { - if (!$stream->seek(0)) { - $success = false; - } - } - - if (!$success) { - return false; - } - - // Seek to the actual position by reading from each stream - while ($this->pos < $offset && !$this->eof()) { - $this->read(min(8096, $offset - $this->pos)); - } - - return $this->pos == $offset; - } - - /** - * Reads from all of the appended streams until the length is met or EOF. - * - * {@inheritdoc} - */ - public function read($length) - { - $buffer = ''; - $total = count($this->streams) - 1; - $remaining = $length; - - while ($remaining > 0) { - // Progress to the next stream if needed. - if ($this->streams[$this->current]->eof()) { - if ($this->current == $total) { - break; - } - $this->current++; - } - $buffer .= $this->streams[$this->current]->read($remaining); - $remaining = $length - strlen($buffer); - } - - $this->pos += strlen($buffer); - - return $buffer; - } - - public function isReadable() - { - return true; - } - - public function isWritable() - { - return false; - } - - public function isSeekable() - { - return $this->seekable; - } - - public function write($string) - { - return false; - } - - public function getMetadata($key = null) - { - return $key ? null : []; - } -} diff --git a/vendor/guzzlehttp/streams/src/AsyncReadStream.php b/vendor/guzzlehttp/streams/src/AsyncReadStream.php deleted file mode 100644 index 25ad960..0000000 --- a/vendor/guzzlehttp/streams/src/AsyncReadStream.php +++ /dev/null @@ -1,207 +0,0 @@ -isReadable() || !$buffer->isWritable()) { - throw new \InvalidArgumentException( - 'Buffer must be readable and writable' - ); - } - - if (isset($config['size'])) { - $this->size = $config['size']; - } - - static $callables = ['pump', 'drain']; - foreach ($callables as $check) { - if (isset($config[$check])) { - if (!is_callable($config[$check])) { - throw new \InvalidArgumentException( - $check . ' must be callable' - ); - } - $this->{$check} = $config[$check]; - } - } - - $this->hwm = $buffer->getMetadata('hwm'); - - // Cannot drain when there's no high water mark. - if ($this->hwm === null) { - $this->drain = null; - } - - $this->stream = $buffer; - } - - /** - * Factory method used to create new async stream and an underlying buffer - * if no buffer is provided. - * - * This function accepts the same options as AsyncReadStream::__construct, - * but added the following key value pairs: - * - * - buffer: (StreamInterface) Buffer used to buffer data. If none is - * provided, a default buffer is created. - * - hwm: (int) High water mark to use if a buffer is created on your - * behalf. - * - max_buffer: (int) If provided, wraps the utilized buffer in a - * DroppingStream decorator to ensure that buffer does not exceed a given - * length. When exceeded, the stream will begin dropping data. Set the - * max_buffer to 0, to use a NullStream which does not store data. - * - write: (callable) A function that is invoked when data is written - * to the underlying buffer. The function accepts the buffer as the first - * argument, and the data being written as the second. The function MUST - * return the number of bytes that were written or false to let writers - * know to slow down. - * - drain: (callable) See constructor documentation. - * - pump: (callable) See constructor documentation. - * - * @param array $options Associative array of options. - * - * @return array Returns an array containing the buffer used to buffer - * data, followed by the ready to use AsyncReadStream object. - */ - public static function create(array $options = []) - { - $maxBuffer = isset($options['max_buffer']) - ? $options['max_buffer'] - : null; - - if ($maxBuffer === 0) { - $buffer = new NullStream(); - } elseif (isset($options['buffer'])) { - $buffer = $options['buffer']; - } else { - $hwm = isset($options['hwm']) ? $options['hwm'] : 16384; - $buffer = new BufferStream($hwm); - } - - if ($maxBuffer > 0) { - $buffer = new DroppingStream($buffer, $options['max_buffer']); - } - - // Call the on_write callback if an on_write function was provided. - if (isset($options['write'])) { - $onWrite = $options['write']; - $buffer = FnStream::decorate($buffer, [ - 'write' => function ($string) use ($buffer, $onWrite) { - $result = $buffer->write($string); - $onWrite($buffer, $string); - return $result; - } - ]); - } - - return [$buffer, new self($buffer, $options)]; - } - - public function getSize() - { - return $this->size; - } - - public function isWritable() - { - return false; - } - - public function write($string) - { - return false; - } - - public function read($length) - { - if (!$this->needsDrain && $this->drain) { - $this->needsDrain = $this->stream->getSize() >= $this->hwm; - } - - $result = $this->stream->read($length); - - // If we need to drain, then drain when the buffer is empty. - if ($this->needsDrain && $this->stream->getSize() === 0) { - $this->needsDrain = false; - $drainFn = $this->drain; - $drainFn($this->stream); - } - - $resultLen = strlen($result); - - // If a pump was provided, the buffer is still open, and not enough - // data was given, then block until the data is provided. - if ($this->pump && $resultLen < $length) { - $pumpFn = $this->pump; - $result .= $pumpFn($length - $resultLen); - } - - return $result; - } -} diff --git a/vendor/guzzlehttp/streams/src/BufferStream.php b/vendor/guzzlehttp/streams/src/BufferStream.php deleted file mode 100644 index 0fffbd6..0000000 --- a/vendor/guzzlehttp/streams/src/BufferStream.php +++ /dev/null @@ -1,138 +0,0 @@ -hwm = $hwm; - } - - public function __toString() - { - return $this->getContents(); - } - - public function getContents() - { - $buffer = $this->buffer; - $this->buffer = ''; - - return $buffer; - } - - public function close() - { - $this->buffer = ''; - } - - public function detach() - { - $this->close(); - } - - public function attach($stream) - { - throw new CannotAttachException(); - } - - public function getSize() - { - return strlen($this->buffer); - } - - public function isReadable() - { - return true; - } - - public function isWritable() - { - return true; - } - - public function isSeekable() - { - return false; - } - - public function seek($offset, $whence = SEEK_SET) - { - return false; - } - - public function eof() - { - return strlen($this->buffer) === 0; - } - - public function tell() - { - return false; - } - - /** - * Reads data from the buffer. - */ - public function read($length) - { - $currentLength = strlen($this->buffer); - - if ($length >= $currentLength) { - // No need to slice the buffer because we don't have enough data. - $result = $this->buffer; - $this->buffer = ''; - } else { - // Slice up the result to provide a subset of the buffer. - $result = substr($this->buffer, 0, $length); - $this->buffer = substr($this->buffer, $length); - } - - return $result; - } - - /** - * Writes data to the buffer. - */ - public function write($string) - { - $this->buffer .= $string; - - if (strlen($this->buffer) >= $this->hwm) { - return false; - } - - return strlen($string); - } - - public function getMetadata($key = null) - { - if ($key == 'hwm') { - return $this->hwm; - } - - return $key ? null : []; - } -} diff --git a/vendor/guzzlehttp/streams/src/CachingStream.php b/vendor/guzzlehttp/streams/src/CachingStream.php deleted file mode 100644 index 60bb905..0000000 --- a/vendor/guzzlehttp/streams/src/CachingStream.php +++ /dev/null @@ -1,122 +0,0 @@ -remoteStream = $stream; - $this->stream = $target ?: new Stream(fopen('php://temp', 'r+')); - } - - public function getSize() - { - return max($this->stream->getSize(), $this->remoteStream->getSize()); - } - - /** - * {@inheritdoc} - * @throws SeekException When seeking with SEEK_END or when seeking - * past the total size of the buffer stream - */ - public function seek($offset, $whence = SEEK_SET) - { - if ($whence == SEEK_SET) { - $byte = $offset; - } elseif ($whence == SEEK_CUR) { - $byte = $offset + $this->tell(); - } else { - return false; - } - - // You cannot skip ahead past where you've read from the remote stream - if ($byte > $this->stream->getSize()) { - throw new SeekException( - $this, - $byte, - sprintf('Cannot seek to byte %d when the buffered stream only' - . ' contains %d bytes', $byte, $this->stream->getSize()) - ); - } - - return $this->stream->seek($byte); - } - - public function read($length) - { - // Perform a regular read on any previously read data from the buffer - $data = $this->stream->read($length); - $remaining = $length - strlen($data); - - // More data was requested so read from the remote stream - if ($remaining) { - // If data was written to the buffer in a position that would have - // been filled from the remote stream, then we must skip bytes on - // the remote stream to emulate overwriting bytes from that - // position. This mimics the behavior of other PHP stream wrappers. - $remoteData = $this->remoteStream->read( - $remaining + $this->skipReadBytes - ); - - if ($this->skipReadBytes) { - $len = strlen($remoteData); - $remoteData = substr($remoteData, $this->skipReadBytes); - $this->skipReadBytes = max(0, $this->skipReadBytes - $len); - } - - $data .= $remoteData; - $this->stream->write($remoteData); - } - - return $data; - } - - public function write($string) - { - // When appending to the end of the currently read stream, you'll want - // to skip bytes from being read from the remote stream to emulate - // other stream wrappers. Basically replacing bytes of data of a fixed - // length. - $overflow = (strlen($string) + $this->tell()) - $this->remoteStream->tell(); - if ($overflow > 0) { - $this->skipReadBytes += $overflow; - } - - return $this->stream->write($string); - } - - public function eof() - { - return $this->stream->eof() && $this->remoteStream->eof(); - } - - /** - * Close both the remote stream and buffer stream - */ - public function close() - { - $this->remoteStream->close() && $this->stream->close(); - } -} diff --git a/vendor/guzzlehttp/streams/src/DroppingStream.php b/vendor/guzzlehttp/streams/src/DroppingStream.php deleted file mode 100644 index 56ee80c..0000000 --- a/vendor/guzzlehttp/streams/src/DroppingStream.php +++ /dev/null @@ -1,42 +0,0 @@ -stream = $stream; - $this->maxLength = $maxLength; - } - - public function write($string) - { - $diff = $this->maxLength - $this->stream->getSize(); - - // Begin returning false when the underlying stream is too large. - if ($diff <= 0) { - return false; - } - - // Write the stream or a subset of the stream if needed. - if (strlen($string) < $diff) { - return $this->stream->write($string); - } - - $this->stream->write(substr($string, 0, $diff)); - - return false; - } -} diff --git a/vendor/guzzlehttp/streams/src/Exception/CannotAttachException.php b/vendor/guzzlehttp/streams/src/Exception/CannotAttachException.php deleted file mode 100644 index e631b9f..0000000 --- a/vendor/guzzlehttp/streams/src/Exception/CannotAttachException.php +++ /dev/null @@ -1,4 +0,0 @@ -stream = $stream; - $msg = $msg ?: 'Could not seek the stream to position ' . $pos; - parent::__construct($msg); - } - - /** - * @return StreamInterface - */ - public function getStream() - { - return $this->stream; - } -} diff --git a/vendor/guzzlehttp/streams/src/FnStream.php b/vendor/guzzlehttp/streams/src/FnStream.php deleted file mode 100644 index 6b5872d..0000000 --- a/vendor/guzzlehttp/streams/src/FnStream.php +++ /dev/null @@ -1,147 +0,0 @@ -methods = $methods; - - // Create the functions on the class - foreach ($methods as $name => $fn) { - $this->{'_fn_' . $name} = $fn; - } - } - - /** - * Lazily determine which methods are not implemented. - * @throws \BadMethodCallException - */ - public function __get($name) - { - throw new \BadMethodCallException(str_replace('_fn_', '', $name) - . '() is not implemented in the FnStream'); - } - - /** - * The close method is called on the underlying stream only if possible. - */ - public function __destruct() - { - if (isset($this->_fn_close)) { - call_user_func($this->_fn_close); - } - } - - /** - * Adds custom functionality to an underlying stream by intercepting - * specific method calls. - * - * @param StreamInterface $stream Stream to decorate - * @param array $methods Hash of method name to a closure - * - * @return FnStream - */ - public static function decorate(StreamInterface $stream, array $methods) - { - // If any of the required methods were not provided, then simply - // proxy to the decorated stream. - foreach (array_diff(self::$slots, array_keys($methods)) as $diff) { - $methods[$diff] = [$stream, $diff]; - } - - return new self($methods); - } - - public function __toString() - { - return call_user_func($this->_fn___toString); - } - - public function close() - { - return call_user_func($this->_fn_close); - } - - public function detach() - { - return call_user_func($this->_fn_detach); - } - - public function attach($stream) - { - return call_user_func($this->_fn_attach, $stream); - } - - public function getSize() - { - return call_user_func($this->_fn_getSize); - } - - public function tell() - { - return call_user_func($this->_fn_tell); - } - - public function eof() - { - return call_user_func($this->_fn_eof); - } - - public function isSeekable() - { - return call_user_func($this->_fn_isSeekable); - } - - public function seek($offset, $whence = SEEK_SET) - { - return call_user_func($this->_fn_seek, $offset, $whence); - } - - public function isWritable() - { - return call_user_func($this->_fn_isWritable); - } - - public function write($string) - { - return call_user_func($this->_fn_write, $string); - } - - public function isReadable() - { - return call_user_func($this->_fn_isReadable); - } - - public function read($length) - { - return call_user_func($this->_fn_read, $length); - } - - public function getContents() - { - return call_user_func($this->_fn_getContents); - } - - public function getMetadata($key = null) - { - return call_user_func($this->_fn_getMetadata, $key); - } -} diff --git a/vendor/guzzlehttp/streams/src/GuzzleStreamWrapper.php b/vendor/guzzlehttp/streams/src/GuzzleStreamWrapper.php deleted file mode 100644 index 4d049a6..0000000 --- a/vendor/guzzlehttp/streams/src/GuzzleStreamWrapper.php +++ /dev/null @@ -1,117 +0,0 @@ -isReadable()) { - $mode = $stream->isWritable() ? 'r+' : 'r'; - } elseif ($stream->isWritable()) { - $mode = 'w'; - } else { - throw new \InvalidArgumentException('The stream must be readable, ' - . 'writable, or both.'); - } - - return fopen('guzzle://stream', $mode, null, stream_context_create([ - 'guzzle' => ['stream' => $stream] - ])); - } - - /** - * Registers the stream wrapper if needed - */ - public static function register() - { - if (!in_array('guzzle', stream_get_wrappers())) { - stream_wrapper_register('guzzle', __CLASS__); - } - } - - public function stream_open($path, $mode, $options, &$opened_path) - { - $options = stream_context_get_options($this->context); - - if (!isset($options['guzzle']['stream'])) { - return false; - } - - $this->mode = $mode; - $this->stream = $options['guzzle']['stream']; - - return true; - } - - public function stream_read($count) - { - return $this->stream->read($count); - } - - public function stream_write($data) - { - return (int) $this->stream->write($data); - } - - public function stream_tell() - { - return $this->stream->tell(); - } - - public function stream_eof() - { - return $this->stream->eof(); - } - - public function stream_seek($offset, $whence) - { - return $this->stream->seek($offset, $whence); - } - - public function stream_stat() - { - static $modeMap = [ - 'r' => 33060, - 'r+' => 33206, - 'w' => 33188 - ]; - - return [ - 'dev' => 0, - 'ino' => 0, - 'mode' => $modeMap[$this->mode], - 'nlink' => 0, - 'uid' => 0, - 'gid' => 0, - 'rdev' => 0, - 'size' => $this->stream->getSize() ?: 0, - 'atime' => 0, - 'mtime' => 0, - 'ctime' => 0, - 'blksize' => 0, - 'blocks' => 0 - ]; - } -} diff --git a/vendor/guzzlehttp/streams/src/InflateStream.php b/vendor/guzzlehttp/streams/src/InflateStream.php deleted file mode 100644 index 978af21..0000000 --- a/vendor/guzzlehttp/streams/src/InflateStream.php +++ /dev/null @@ -1,27 +0,0 @@ -stream = new Stream($resource); - } -} diff --git a/vendor/guzzlehttp/streams/src/LazyOpenStream.php b/vendor/guzzlehttp/streams/src/LazyOpenStream.php deleted file mode 100644 index 6242ee7..0000000 --- a/vendor/guzzlehttp/streams/src/LazyOpenStream.php +++ /dev/null @@ -1,37 +0,0 @@ -filename = $filename; - $this->mode = $mode; - } - - /** - * Creates the underlying stream lazily when required. - * - * @return StreamInterface - */ - protected function createStream() - { - return Stream::factory(Utils::open($this->filename, $this->mode)); - } -} diff --git a/vendor/guzzlehttp/streams/src/LimitStream.php b/vendor/guzzlehttp/streams/src/LimitStream.php deleted file mode 100644 index e9fad98..0000000 --- a/vendor/guzzlehttp/streams/src/LimitStream.php +++ /dev/null @@ -1,161 +0,0 @@ -stream = $stream; - $this->setLimit($limit); - $this->setOffset($offset); - } - - public function eof() - { - // Always return true if the underlying stream is EOF - if ($this->stream->eof()) { - return true; - } - - // No limit and the underlying stream is not at EOF - if ($this->limit == -1) { - return false; - } - - $tell = $this->stream->tell(); - if ($tell === false) { - return false; - } - - return $tell >= $this->offset + $this->limit; - } - - /** - * Returns the size of the limited subset of data - * {@inheritdoc} - */ - public function getSize() - { - if (null === ($length = $this->stream->getSize())) { - return null; - } elseif ($this->limit == -1) { - return $length - $this->offset; - } else { - return min($this->limit, $length - $this->offset); - } - } - - /** - * Allow for a bounded seek on the read limited stream - * {@inheritdoc} - */ - public function seek($offset, $whence = SEEK_SET) - { - if ($whence !== SEEK_SET || $offset < 0) { - return false; - } - - $offset += $this->offset; - - if ($this->limit !== -1) { - if ($offset > $this->offset + $this->limit) { - $offset = $this->offset + $this->limit; - } - } - - return $this->stream->seek($offset); - } - - /** - * Give a relative tell() - * {@inheritdoc} - */ - public function tell() - { - return $this->stream->tell() - $this->offset; - } - - /** - * Set the offset to start limiting from - * - * @param int $offset Offset to seek to and begin byte limiting from - * - * @return self - * @throws SeekException - */ - public function setOffset($offset) - { - $current = $this->stream->tell(); - - if ($current !== $offset) { - // If the stream cannot seek to the offset position, then read to it - if (!$this->stream->seek($offset)) { - if ($current > $offset) { - throw new SeekException($this, $offset); - } else { - $this->stream->read($offset - $current); - } - } - } - - $this->offset = $offset; - - return $this; - } - - /** - * Set the limit of bytes that the decorator allows to be read from the - * stream. - * - * @param int $limit Number of bytes to allow to be read from the stream. - * Use -1 for no limit. - * @return self - */ - public function setLimit($limit) - { - $this->limit = $limit; - - return $this; - } - - public function read($length) - { - if ($this->limit == -1) { - return $this->stream->read($length); - } - - // Check if the current position is less than the total allowed - // bytes + original offset - $remaining = ($this->offset + $this->limit) - $this->stream->tell(); - if ($remaining > 0) { - // Only return the amount of requested data, ensuring that the byte - // limit is not exceeded - return $this->stream->read(min($remaining, $length)); - } else { - return false; - } - } -} diff --git a/vendor/guzzlehttp/streams/src/MetadataStreamInterface.php b/vendor/guzzlehttp/streams/src/MetadataStreamInterface.php deleted file mode 100644 index c1433ad..0000000 --- a/vendor/guzzlehttp/streams/src/MetadataStreamInterface.php +++ /dev/null @@ -1,11 +0,0 @@ -stream->attach($stream); - } -} diff --git a/vendor/guzzlehttp/streams/src/NullStream.php b/vendor/guzzlehttp/streams/src/NullStream.php deleted file mode 100644 index 41ee776..0000000 --- a/vendor/guzzlehttp/streams/src/NullStream.php +++ /dev/null @@ -1,78 +0,0 @@ -source = $source; - $this->size = isset($options['size']) ? $options['size'] : null; - $this->metadata = isset($options['metadata']) ? $options['metadata'] : []; - $this->buffer = new BufferStream(); - } - - public function __toString() - { - return Utils::copyToString($this); - } - - public function close() - { - $this->detach(); - } - - public function detach() - { - $this->tellPos = false; - $this->source = null; - } - - public function attach($stream) - { - throw new CannotAttachException(); - } - - public function getSize() - { - return $this->size; - } - - public function tell() - { - return $this->tellPos; - } - - public function eof() - { - return !$this->source; - } - - public function isSeekable() - { - return false; - } - - public function seek($offset, $whence = SEEK_SET) - { - return false; - } - - public function isWritable() - { - return false; - } - - public function write($string) - { - return false; - } - - public function isReadable() - { - return true; - } - - public function read($length) - { - $data = $this->buffer->read($length); - $readLen = strlen($data); - $this->tellPos += $readLen; - $remaining = $length - $readLen; - - if ($remaining) { - $this->pump($remaining); - $data .= $this->buffer->read($remaining); - $this->tellPos += strlen($data) - $readLen; - } - - return $data; - } - - public function getContents() - { - $result = ''; - while (!$this->eof()) { - $result .= $this->read(1000000); - } - - return $result; - } - - public function getMetadata($key = null) - { - if (!$key) { - return $this->metadata; - } - - return isset($this->metadata[$key]) ? $this->metadata[$key] : null; - } - - private function pump($length) - { - if ($this->source) { - do { - $data = call_user_func($this->source, $length); - if ($data === false || $data === null) { - $this->source = null; - return; - } - $this->buffer->write($data); - $length -= strlen($data); - } while ($length > 0); - } - } -} diff --git a/vendor/guzzlehttp/streams/src/Stream.php b/vendor/guzzlehttp/streams/src/Stream.php deleted file mode 100644 index 7adbc5e..0000000 --- a/vendor/guzzlehttp/streams/src/Stream.php +++ /dev/null @@ -1,261 +0,0 @@ - [ - 'r' => true, 'w+' => true, 'r+' => true, 'x+' => true, 'c+' => true, - 'rb' => true, 'w+b' => true, 'r+b' => true, 'x+b' => true, - 'c+b' => true, 'rt' => true, 'w+t' => true, 'r+t' => true, - 'x+t' => true, 'c+t' => true, 'a+' => true - ], - 'write' => [ - 'w' => true, 'w+' => true, 'rw' => true, 'r+' => true, 'x+' => true, - 'c+' => true, 'wb' => true, 'w+b' => true, 'r+b' => true, - 'x+b' => true, 'c+b' => true, 'w+t' => true, 'r+t' => true, - 'x+t' => true, 'c+t' => true, 'a' => true, 'a+' => true - ] - ]; - - /** - * Create a new stream based on the input type. - * - * This factory accepts the same associative array of options as described - * in the constructor. - * - * @param resource|string|StreamInterface $resource Entity body data - * @param array $options Additional options - * - * @return Stream - * @throws \InvalidArgumentException if the $resource arg is not valid. - */ - public static function factory($resource = '', array $options = []) - { - $type = gettype($resource); - - if ($type == 'string') { - $stream = fopen('php://temp', 'r+'); - if ($resource !== '') { - fwrite($stream, $resource); - fseek($stream, 0); - } - return new self($stream, $options); - } - - if ($type == 'resource') { - return new self($resource, $options); - } - - if ($resource instanceof StreamInterface) { - return $resource; - } - - if ($type == 'object' && method_exists($resource, '__toString')) { - return self::factory((string) $resource, $options); - } - - if (is_callable($resource)) { - return new PumpStream($resource, $options); - } - - if ($resource instanceof \Iterator) { - return new PumpStream(function () use ($resource) { - if (!$resource->valid()) { - return false; - } - $result = $resource->current(); - $resource->next(); - return $result; - }, $options); - } - - throw new \InvalidArgumentException('Invalid resource type: ' . $type); - } - - /** - * This constructor accepts an associative array of options. - * - * - size: (int) If a read stream would otherwise have an indeterminate - * size, but the size is known due to foreknownledge, then you can - * provide that size, in bytes. - * - metadata: (array) Any additional metadata to return when the metadata - * of the stream is accessed. - * - * @param resource $stream Stream resource to wrap. - * @param array $options Associative array of options. - * - * @throws \InvalidArgumentException if the stream is not a stream resource - */ - public function __construct($stream, $options = []) - { - if (!is_resource($stream)) { - throw new \InvalidArgumentException('Stream must be a resource'); - } - - if (isset($options['size'])) { - $this->size = $options['size']; - } - - $this->customMetadata = isset($options['metadata']) - ? $options['metadata'] - : []; - - $this->attach($stream); - } - - /** - * Closes the stream when the destructed - */ - public function __destruct() - { - $this->close(); - } - - public function __toString() - { - if (!$this->stream) { - return ''; - } - - $this->seek(0); - - return (string) stream_get_contents($this->stream); - } - - public function getContents() - { - return $this->stream ? stream_get_contents($this->stream) : ''; - } - - public function close() - { - if (is_resource($this->stream)) { - fclose($this->stream); - } - - $this->detach(); - } - - public function detach() - { - $result = $this->stream; - $this->stream = $this->size = $this->uri = null; - $this->readable = $this->writable = $this->seekable = false; - - return $result; - } - - public function attach($stream) - { - $this->stream = $stream; - $meta = stream_get_meta_data($this->stream); - $this->seekable = $meta['seekable']; - $this->readable = isset(self::$readWriteHash['read'][$meta['mode']]); - $this->writable = isset(self::$readWriteHash['write'][$meta['mode']]); - $this->uri = $this->getMetadata('uri'); - } - - public function getSize() - { - if ($this->size !== null) { - return $this->size; - } - - if (!$this->stream) { - return null; - } - - // Clear the stat cache if the stream has a URI - if ($this->uri) { - clearstatcache(true, $this->uri); - } - - $stats = fstat($this->stream); - if (isset($stats['size'])) { - $this->size = $stats['size']; - return $this->size; - } - - return null; - } - - public function isReadable() - { - return $this->readable; - } - - public function isWritable() - { - return $this->writable; - } - - public function isSeekable() - { - return $this->seekable; - } - - public function eof() - { - return !$this->stream || feof($this->stream); - } - - public function tell() - { - return $this->stream ? ftell($this->stream) : false; - } - - public function setSize($size) - { - $this->size = $size; - - return $this; - } - - public function seek($offset, $whence = SEEK_SET) - { - return $this->seekable - ? fseek($this->stream, $offset, $whence) === 0 - : false; - } - - public function read($length) - { - return $this->readable ? fread($this->stream, $length) : false; - } - - public function write($string) - { - // We can't know the size after writing anything - $this->size = null; - - return $this->writable ? fwrite($this->stream, $string) : false; - } - - public function getMetadata($key = null) - { - if (!$this->stream) { - return $key ? null : []; - } elseif (!$key) { - return $this->customMetadata + stream_get_meta_data($this->stream); - } elseif (isset($this->customMetadata[$key])) { - return $this->customMetadata[$key]; - } - - $meta = stream_get_meta_data($this->stream); - - return isset($meta[$key]) ? $meta[$key] : null; - } -} diff --git a/vendor/guzzlehttp/streams/src/StreamDecoratorTrait.php b/vendor/guzzlehttp/streams/src/StreamDecoratorTrait.php deleted file mode 100644 index 39c19c5..0000000 --- a/vendor/guzzlehttp/streams/src/StreamDecoratorTrait.php +++ /dev/null @@ -1,143 +0,0 @@ -stream = $stream; - } - - /** - * Magic method used to create a new stream if streams are not added in - * the constructor of a decorator (e.g., LazyOpenStream). - */ - public function __get($name) - { - if ($name == 'stream') { - $this->stream = $this->createStream(); - return $this->stream; - } - - throw new \UnexpectedValueException("$name not found on class"); - } - - public function __toString() - { - try { - $this->seek(0); - return $this->getContents(); - } catch (\Exception $e) { - // Really, PHP? https://bugs.php.net/bug.php?id=53648 - trigger_error('StreamDecorator::__toString exception: ' - . (string) $e, E_USER_ERROR); - return ''; - } - } - - public function getContents() - { - return Utils::copyToString($this); - } - - /** - * Allow decorators to implement custom methods - * - * @param string $method Missing method name - * @param array $args Method arguments - * - * @return mixed - */ - public function __call($method, array $args) - { - $result = call_user_func_array(array($this->stream, $method), $args); - - // Always return the wrapped object if the result is a return $this - return $result === $this->stream ? $this : $result; - } - - public function close() - { - $this->stream->close(); - } - - public function getMetadata($key = null) - { - return $this->stream->getMetadata($key); - } - - public function detach() - { - return $this->stream->detach(); - } - - public function attach($stream) - { - throw new CannotAttachException(); - } - - public function getSize() - { - return $this->stream->getSize(); - } - - public function eof() - { - return $this->stream->eof(); - } - - public function tell() - { - return $this->stream->tell(); - } - - public function isReadable() - { - return $this->stream->isReadable(); - } - - public function isWritable() - { - return $this->stream->isWritable(); - } - - public function isSeekable() - { - return $this->stream->isSeekable(); - } - - public function seek($offset, $whence = SEEK_SET) - { - return $this->stream->seek($offset, $whence); - } - - public function read($length) - { - return $this->stream->read($length); - } - - public function write($string) - { - return $this->stream->write($string); - } - - /** - * Implement in subclasses to dynamically create streams when requested. - * - * @return StreamInterface - * @throws \BadMethodCallException - */ - protected function createStream() - { - throw new \BadMethodCallException('createStream() not implemented in ' - . get_class($this)); - } -} diff --git a/vendor/guzzlehttp/streams/src/StreamInterface.php b/vendor/guzzlehttp/streams/src/StreamInterface.php deleted file mode 100644 index fd19c6f..0000000 --- a/vendor/guzzlehttp/streams/src/StreamInterface.php +++ /dev/null @@ -1,159 +0,0 @@ -eof()) { - $buf = $stream->read(1048576); - if ($buf === false) { - break; - } - $buffer .= $buf; - } - return $buffer; - } - - $len = 0; - while (!$stream->eof() && $len < $maxLen) { - $buf = $stream->read($maxLen - $len); - if ($buf === false) { - break; - } - $buffer .= $buf; - $len = strlen($buffer); - } - - return $buffer; - } - - /** - * Copy the contents of a stream into another stream until the given number - * of bytes have been read. - * - * @param StreamInterface $source Stream to read from - * @param StreamInterface $dest Stream to write to - * @param int $maxLen Maximum number of bytes to read. Pass -1 - * to read the entire stream. - */ - public static function copyToStream( - StreamInterface $source, - StreamInterface $dest, - $maxLen = -1 - ) { - if ($maxLen === -1) { - while (!$source->eof()) { - if (!$dest->write($source->read(1048576))) { - break; - } - } - return; - } - - $bytes = 0; - while (!$source->eof()) { - $buf = $source->read($maxLen - $bytes); - if (!($len = strlen($buf))) { - break; - } - $bytes += $len; - $dest->write($buf); - if ($bytes == $maxLen) { - break; - } - } - } - - /** - * Calculate a hash of a Stream - * - * @param StreamInterface $stream Stream to calculate the hash for - * @param string $algo Hash algorithm (e.g. md5, crc32, etc) - * @param bool $rawOutput Whether or not to use raw output - * - * @return string Returns the hash of the stream - * @throws SeekException - */ - public static function hash( - StreamInterface $stream, - $algo, - $rawOutput = false - ) { - $pos = $stream->tell(); - - if ($pos > 0 && !$stream->seek(0)) { - throw new SeekException($stream); - } - - $ctx = hash_init($algo); - while (!$stream->eof()) { - hash_update($ctx, $stream->read(1048576)); - } - - $out = hash_final($ctx, (bool) $rawOutput); - $stream->seek($pos); - - return $out; - } - - /** - * Read a line from the stream up to the maximum allowed buffer length - * - * @param StreamInterface $stream Stream to read from - * @param int $maxLength Maximum buffer length - * - * @return string|bool - */ - public static function readline(StreamInterface $stream, $maxLength = null) - { - $buffer = ''; - $size = 0; - - while (!$stream->eof()) { - if (false === ($byte = $stream->read(1))) { - return $buffer; - } - $buffer .= $byte; - // Break when a new line is found or the max length - 1 is reached - if ($byte == PHP_EOL || ++$size == $maxLength - 1) { - break; - } - } - - return $buffer; - } - - /** - * Alias of GuzzleHttp\Stream\Stream::factory. - * - * @param mixed $resource Resource to create - * @param array $options Associative array of stream options defined in - * {@see \GuzzleHttp\Stream\Stream::__construct} - * - * @return StreamInterface - * - * @see GuzzleHttp\Stream\Stream::factory - * @see GuzzleHttp\Stream\Stream::__construct - */ - public static function create($resource, array $options = []) - { - return Stream::factory($resource, $options); - } -} diff --git a/vendor/ircmaxell/password-compat/LICENSE.md b/vendor/ircmaxell/password-compat/LICENSE.md deleted file mode 100644 index 1efc565..0000000 --- a/vendor/ircmaxell/password-compat/LICENSE.md +++ /dev/null @@ -1,7 +0,0 @@ -Copyright (c) 2012 Anthony Ferrara - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/vendor/ircmaxell/password-compat/composer.json b/vendor/ircmaxell/password-compat/composer.json deleted file mode 100644 index 822fd1f..0000000 --- a/vendor/ircmaxell/password-compat/composer.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "ircmaxell/password-compat", - "description": "A compatibility library for the proposed simplified password hashing algorithm: https://wiki.php.net/rfc/password_hash", - "keywords": ["password", "hashing"], - "homepage": "https://github.com/ircmaxell/password_compat", - "license": "MIT", - "authors": [ - { - "name": "Anthony Ferrara", - "email": "ircmaxell@php.net", - "homepage": "http://blog.ircmaxell.com" - } - ], - "require-dev": { - "phpunit/phpunit": "4.*" - }, - "autoload": { - "files": ["lib/password.php"] - } -} diff --git a/vendor/ircmaxell/password-compat/lib/password.php b/vendor/ircmaxell/password-compat/lib/password.php deleted file mode 100644 index cc6896c..0000000 --- a/vendor/ircmaxell/password-compat/lib/password.php +++ /dev/null @@ -1,314 +0,0 @@ - - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @copyright 2012 The Authors - */ - -namespace { - - if (!defined('PASSWORD_BCRYPT')) { - /** - * PHPUnit Process isolation caches constants, but not function declarations. - * So we need to check if the constants are defined separately from - * the functions to enable supporting process isolation in userland - * code. - */ - define('PASSWORD_BCRYPT', 1); - define('PASSWORD_DEFAULT', PASSWORD_BCRYPT); - define('PASSWORD_BCRYPT_DEFAULT_COST', 10); - } - - if (!function_exists('password_hash')) { - - /** - * Hash the password using the specified algorithm - * - * @param string $password The password to hash - * @param int $algo The algorithm to use (Defined by PASSWORD_* constants) - * @param array $options The options for the algorithm to use - * - * @return string|false The hashed password, or false on error. - */ - function password_hash($password, $algo, array $options = array()) { - if (!function_exists('crypt')) { - trigger_error("Crypt must be loaded for password_hash to function", E_USER_WARNING); - return null; - } - if (is_null($password) || is_int($password)) { - $password = (string) $password; - } - if (!is_string($password)) { - trigger_error("password_hash(): Password must be a string", E_USER_WARNING); - return null; - } - if (!is_int($algo)) { - trigger_error("password_hash() expects parameter 2 to be long, " . gettype($algo) . " given", E_USER_WARNING); - return null; - } - $resultLength = 0; - switch ($algo) { - case PASSWORD_BCRYPT: - $cost = PASSWORD_BCRYPT_DEFAULT_COST; - if (isset($options['cost'])) { - $cost = $options['cost']; - if ($cost < 4 || $cost > 31) { - trigger_error(sprintf("password_hash(): Invalid bcrypt cost parameter specified: %d", $cost), E_USER_WARNING); - return null; - } - } - // The length of salt to generate - $raw_salt_len = 16; - // The length required in the final serialization - $required_salt_len = 22; - $hash_format = sprintf("$2y$%02d$", $cost); - // The expected length of the final crypt() output - $resultLength = 60; - break; - default: - trigger_error(sprintf("password_hash(): Unknown password hashing algorithm: %s", $algo), E_USER_WARNING); - return null; - } - $salt_requires_encoding = false; - if (isset($options['salt'])) { - switch (gettype($options['salt'])) { - case 'NULL': - case 'boolean': - case 'integer': - case 'double': - case 'string': - $salt = (string) $options['salt']; - break; - case 'object': - if (method_exists($options['salt'], '__tostring')) { - $salt = (string) $options['salt']; - break; - } - case 'array': - case 'resource': - default: - trigger_error('password_hash(): Non-string salt parameter supplied', E_USER_WARNING); - return null; - } - if (PasswordCompat\binary\_strlen($salt) < $required_salt_len) { - trigger_error(sprintf("password_hash(): Provided salt is too short: %d expecting %d", PasswordCompat\binary\_strlen($salt), $required_salt_len), E_USER_WARNING); - return null; - } elseif (0 == preg_match('#^[a-zA-Z0-9./]+$#D', $salt)) { - $salt_requires_encoding = true; - } - } else { - $buffer = ''; - $buffer_valid = false; - if (function_exists('mcrypt_create_iv') && !defined('PHALANGER')) { - $buffer = mcrypt_create_iv($raw_salt_len, MCRYPT_DEV_URANDOM); - if ($buffer) { - $buffer_valid = true; - } - } - if (!$buffer_valid && function_exists('openssl_random_pseudo_bytes')) { - $buffer = openssl_random_pseudo_bytes($raw_salt_len); - if ($buffer) { - $buffer_valid = true; - } - } - if (!$buffer_valid && @is_readable('/dev/urandom')) { - $f = fopen('/dev/urandom', 'r'); - $read = PasswordCompat\binary\_strlen($buffer); - while ($read < $raw_salt_len) { - $buffer .= fread($f, $raw_salt_len - $read); - $read = PasswordCompat\binary\_strlen($buffer); - } - fclose($f); - if ($read >= $raw_salt_len) { - $buffer_valid = true; - } - } - if (!$buffer_valid || PasswordCompat\binary\_strlen($buffer) < $raw_salt_len) { - $bl = PasswordCompat\binary\_strlen($buffer); - for ($i = 0; $i < $raw_salt_len; $i++) { - if ($i < $bl) { - $buffer[$i] = $buffer[$i] ^ chr(mt_rand(0, 255)); - } else { - $buffer .= chr(mt_rand(0, 255)); - } - } - } - $salt = $buffer; - $salt_requires_encoding = true; - } - if ($salt_requires_encoding) { - // encode string with the Base64 variant used by crypt - $base64_digits = - 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; - $bcrypt64_digits = - './ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; - - $base64_string = base64_encode($salt); - $salt = strtr(rtrim($base64_string, '='), $base64_digits, $bcrypt64_digits); - } - $salt = PasswordCompat\binary\_substr($salt, 0, $required_salt_len); - - $hash = $hash_format . $salt; - - $ret = crypt($password, $hash); - - if (!is_string($ret) || PasswordCompat\binary\_strlen($ret) != $resultLength) { - return false; - } - - return $ret; - } - - /** - * Get information about the password hash. Returns an array of the information - * that was used to generate the password hash. - * - * array( - * 'algo' => 1, - * 'algoName' => 'bcrypt', - * 'options' => array( - * 'cost' => PASSWORD_BCRYPT_DEFAULT_COST, - * ), - * ) - * - * @param string $hash The password hash to extract info from - * - * @return array The array of information about the hash. - */ - function password_get_info($hash) { - $return = array( - 'algo' => 0, - 'algoName' => 'unknown', - 'options' => array(), - ); - if (PasswordCompat\binary\_substr($hash, 0, 4) == '$2y$' && PasswordCompat\binary\_strlen($hash) == 60) { - $return['algo'] = PASSWORD_BCRYPT; - $return['algoName'] = 'bcrypt'; - list($cost) = sscanf($hash, "$2y$%d$"); - $return['options']['cost'] = $cost; - } - return $return; - } - - /** - * Determine if the password hash needs to be rehashed according to the options provided - * - * If the answer is true, after validating the password using password_verify, rehash it. - * - * @param string $hash The hash to test - * @param int $algo The algorithm used for new password hashes - * @param array $options The options array passed to password_hash - * - * @return boolean True if the password needs to be rehashed. - */ - function password_needs_rehash($hash, $algo, array $options = array()) { - $info = password_get_info($hash); - if ($info['algo'] != $algo) { - return true; - } - switch ($algo) { - case PASSWORD_BCRYPT: - $cost = isset($options['cost']) ? $options['cost'] : PASSWORD_BCRYPT_DEFAULT_COST; - if ($cost != $info['options']['cost']) { - return true; - } - break; - } - return false; - } - - /** - * Verify a password against a hash using a timing attack resistant approach - * - * @param string $password The password to verify - * @param string $hash The hash to verify against - * - * @return boolean If the password matches the hash - */ - function password_verify($password, $hash) { - if (!function_exists('crypt')) { - trigger_error("Crypt must be loaded for password_verify to function", E_USER_WARNING); - return false; - } - $ret = crypt($password, $hash); - if (!is_string($ret) || PasswordCompat\binary\_strlen($ret) != PasswordCompat\binary\_strlen($hash) || PasswordCompat\binary\_strlen($ret) <= 13) { - return false; - } - - $status = 0; - for ($i = 0; $i < PasswordCompat\binary\_strlen($ret); $i++) { - $status |= (ord($ret[$i]) ^ ord($hash[$i])); - } - - return $status === 0; - } - } - -} - -namespace PasswordCompat\binary { - - if (!function_exists('PasswordCompat\\binary\\_strlen')) { - - /** - * Count the number of bytes in a string - * - * We cannot simply use strlen() for this, because it might be overwritten by the mbstring extension. - * In this case, strlen() will count the number of *characters* based on the internal encoding. A - * sequence of bytes might be regarded as a single multibyte character. - * - * @param string $binary_string The input string - * - * @internal - * @return int The number of bytes - */ - function _strlen($binary_string) { - if (function_exists('mb_strlen')) { - return mb_strlen($binary_string, '8bit'); - } - return strlen($binary_string); - } - - /** - * Get a substring based on byte limits - * - * @see _strlen() - * - * @param string $binary_string The input string - * @param int $start - * @param int $length - * - * @internal - * @return string The substring - */ - function _substr($binary_string, $start, $length) { - if (function_exists('mb_substr')) { - return mb_substr($binary_string, $start, $length, '8bit'); - } - return substr($binary_string, $start, $length); - } - - /** - * Check if current PHP version is compatible with the library - * - * @return boolean the check result - */ - function check() { - static $pass = NULL; - - if (is_null($pass)) { - if (function_exists('crypt')) { - $hash = '$2y$04$usesomesillystringfore7hnbRJHxXVLeakoG8K30oukPsA.ztMG'; - $test = crypt("password", $hash); - $pass = $test == $hash; - } else { - $pass = false; - } - } - return $pass; - } - - } -} \ No newline at end of file diff --git a/vendor/ircmaxell/password-compat/version-test.php b/vendor/ircmaxell/password-compat/version-test.php deleted file mode 100644 index 96f60ca..0000000 --- a/vendor/ircmaxell/password-compat/version-test.php +++ /dev/null @@ -1,6 +0,0 @@ - composer-installer.php - hhvm composer-installer.php - hhvm -v ResourceLimit.SocketDefaultTimeout=30 -v Http.SlowQueryThreshold=30000 composer.phar update --prefer-source - hhvm -v ResourceLimit.SocketDefaultTimeout=30 -v Http.SlowQueryThreshold=30000 composer.phar install --dev --prefer-source -else - composer self-update - composer update --prefer-source - composer install --dev --prefer-source -fi diff --git a/vendor/ocramius/proxy-manager/.travis.yml b/vendor/ocramius/proxy-manager/.travis.yml deleted file mode 100644 index 5f42dac..0000000 --- a/vendor/ocramius/proxy-manager/.travis.yml +++ /dev/null @@ -1,28 +0,0 @@ -language: php - -php: - - 5.3.3 - - 5.3 - - 5.4 - - 5.5 - - 5.6 - - hhvm - - hhvm-nightly - -before_script: - - sh .travis.install.sh - -script: - - ./vendor/bin/phpunit --disallow-test-output --report-useless-tests --coverage-clover ./clover.xml --group=Coverage - - ./vendor/bin/phpunit --disallow-test-output --report-useless-tests --strict --exclude-group=Performance,Coverage - - php -n ./vendor/bin/phpunit --group=Performance - - ./vendor/bin/phpcs --standard=PSR2 ./src/ ./tests/ - -matrix: - allow_failures: - - php: hhvm - - php: hhvm-nightly - -after_script: - - wget https://scrutinizer-ci.com/ocular.phar - - php ocular.phar code-coverage:upload --format=php-clover ./clover.xml diff --git a/vendor/ocramius/proxy-manager/CONTRIBUTING.md b/vendor/ocramius/proxy-manager/CONTRIBUTING.md deleted file mode 100644 index d07d8dc..0000000 --- a/vendor/ocramius/proxy-manager/CONTRIBUTING.md +++ /dev/null @@ -1,35 +0,0 @@ -# Contributing - - * Coding standard for the project is [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md) - * The project will follow strict [object calisthenics](http://www.slideshare.net/guilhermeblanco/object-calisthenics-applied-to-php) - * Any contribution must provide tests for additional introduced conditions - * Any un-confirmed issue needs a failing test case before being accepted - * Pull requests must be sent from a new hotfix/feature branch, not from `master`. - -## Installation - -To install the project and run the tests, you need to clone it first: - -```sh -$ git clone git://github.com/Ocramius/ProxyManager.git -``` - -You will then need to run a composer installation: - -```sh -$ cd ProxyManager -$ curl -s https://getcomposer.org/installer | php -$ php composer.phar update -``` - -## Testing - -The PHPUnit version to be used is the one installed as a dev- dependency via composer: - -```sh -$ ./vendor/bin/phpunit -``` - -Accepted coverage for new contributions is 80%. Any contribution not satisfying this requirement -won't be merged. - diff --git a/vendor/ocramius/proxy-manager/examples/access-interceptor-scope-localizer.php b/vendor/ocramius/proxy-manager/examples/access-interceptor-scope-localizer.php deleted file mode 100644 index eb1da5b..0000000 --- a/vendor/ocramius/proxy-manager/examples/access-interceptor-scope-localizer.php +++ /dev/null @@ -1,38 +0,0 @@ -counter += 1; - - return $this; - } -} - -$factory = new AccessInterceptorScopeLocalizerFactory(); -$foo = new FluentCounter(); - -/* @var $proxy FluentCounter */ -$proxy = $factory->createProxy( - $foo, - array('fluentMethod' => function ($proxy) { echo "pre-fluentMethod #{$proxy->counter}!\n"; }), - array('fluentMethod' => function ($proxy) { echo "post-fluentMethod #{$proxy->counter}!\n"; }) -); - -$proxy->fluentMethod()->fluentMethod()->fluentMethod()->fluentMethod(); - -echo 'The proxy counter is now at ' . $proxy->counter . "\n"; -echo 'The real instance counter is now at ' . $foo->counter . "\n"; diff --git a/vendor/ocramius/proxy-manager/examples/ghost-object.php b/vendor/ocramius/proxy-manager/examples/ghost-object.php deleted file mode 100644 index b4ec216..0000000 --- a/vendor/ocramius/proxy-manager/examples/ghost-object.php +++ /dev/null @@ -1,46 +0,0 @@ -foo = (string) $foo; - } - - public function getFoo() - { - return $this->foo; - } -} - -$startTime = microtime(true); -$factory = new LazyLoadingGhostFactory(); - -for ($i = 0; $i < 1000; $i += 1) { - $proxy = $factory->createProxy( - 'Foo', - function ($proxy, $method, $parameters, & $initializer) { - $initializer = null; - $proxy->setFoo('Hello World!'); - - return true; - } - ); -} - -var_dump('time after 1000 instantiations: ' . (microtime(true) - $startTime)); - -echo $proxy->getFoo() . "\n"; - -var_dump('time after single call to doFoo: ' . (microtime(true) - $startTime)); diff --git a/vendor/ocramius/proxy-manager/examples/remote-proxy.php b/vendor/ocramius/proxy-manager/examples/remote-proxy.php deleted file mode 100644 index 97025fc..0000000 --- a/vendor/ocramius/proxy-manager/examples/remote-proxy.php +++ /dev/null @@ -1,36 +0,0 @@ -createProxy('Foo'); - -try { - var_dump($proxy->bar()); // bar remote ! -} catch (\Zend\Http\Client\Adapter\Exception\RuntimeException $error) { - echo "To run this example, please following before:\n\n\$ php -S localhost:9876 -t \"" . __DIR__ . "\"\n"; - - exit(2); -} diff --git a/vendor/ocramius/proxy-manager/examples/remote-proxy/remote-proxy-server.php b/vendor/ocramius/proxy-manager/examples/remote-proxy/remote-proxy-server.php deleted file mode 100644 index 81a742f..0000000 --- a/vendor/ocramius/proxy-manager/examples/remote-proxy/remote-proxy-server.php +++ /dev/null @@ -1,20 +0,0 @@ -setClass(new Foo(), 'Foo'); -$server->setReturnResponse(false); - -$server->handle(); diff --git a/vendor/ocramius/proxy-manager/examples/smart-reference.php b/vendor/ocramius/proxy-manager/examples/smart-reference.php deleted file mode 100644 index 8c00a3a..0000000 --- a/vendor/ocramius/proxy-manager/examples/smart-reference.php +++ /dev/null @@ -1,23 +0,0 @@ -createProxy( - new Foo(), - array('doFoo' => function () { echo "pre-foo!\n"; }), - array('doFoo' => function () { echo "post-foo!\n"; }) -); - -$proxy->doFoo(); diff --git a/vendor/ocramius/proxy-manager/examples/virtual-proxy.php b/vendor/ocramius/proxy-manager/examples/virtual-proxy.php deleted file mode 100644 index 7ee6b2e..0000000 --- a/vendor/ocramius/proxy-manager/examples/virtual-proxy.php +++ /dev/null @@ -1,39 +0,0 @@ -createProxy( - 'Foo', - function (& $wrappedObject, $proxy, $method, $parameters, & $initializer) { - $initializer = null; - $wrappedObject = new Foo(); - - return true; - } - ); -} - -var_dump('time after 1000 instantiations: ' . (microtime(true) - $startTime)); - -$proxy->doFoo(); - -var_dump('time after single call to doFoo: ' . (microtime(true) - $startTime)); diff --git a/vendor/ocramius/proxy-manager/html-docs/access-interceptor-scope-localizer-proxy.html b/vendor/ocramius/proxy-manager/html-docs/access-interceptor-scope-localizer-proxy.html deleted file mode 100644 index dac8c93..0000000 --- a/vendor/ocramius/proxy-manager/html-docs/access-interceptor-scope-localizer-proxy.html +++ /dev/null @@ -1,197 +0,0 @@ - - - - ProxyManager - Tuning the ProxyManager for production - - - - - - - - - - - - - - -
-
- -
-
-
- - - - -
-
-
-
-
-
- - -
-
-

Access Interceptor Scope Localizer Proxy

- -

An access interceptor scope localizer is a smart reference proxy that allows you to dynamically define logic to be executed before or after any of the proxied object's methods' logic.

- -

It works exactly like the access interceptor value holder, with some minor differences in behavior.

- -

The working concept of an access interceptor scope localizer is to localize scope of a proxied object:

- -
-        
-class Example
-{
-    protected $foo;
-    protected $bar;
-    protected $baz;
-
-    public function doFoo()
-    {
-        // ...
-    }
-}
-
-class ExampleProxy extends Example
-{
-    public function __construct(Example $example)
-    {
-        $this->foo = & $example->foo;
-        $this->bar = & $example->bar;
-        $this->baz = & $example->baz;
-    }
-
-    public function doFoo()
-    {
-        return parent::doFoo();
-    }
-}
-        
-    
- -

This allows to create a mirror copy of the real instance, where any change in the proxy or in the real instance is reflected in both objects.

- -

The main advantage of this approach is that the proxy is now safe against fluent interfaces, which would break an access interceptor value holder instead.

-
-

Differences with access interceptor value holder:

- -
    -
  • It does NOT implement the ProxyManager\Proxy\ValueHolderInterface, since the proxy itself does not keep a reference to the original object being proxied
  • -
  • In all interceptor methods (see access interceptor value holder), the $instance passed in is the proxy itself. There is no way to gather a reference to the original object right now, and that's mainly to protect from misuse.
  • -
-
- -

Known limitations

- -
    -
  • It is NOT possible to intercept access to public properties
  • -
  • It is NOT possible to proxy interfaces, since this proxy relies on parent::method() calls. Interfaces obviously don't provide a parent method implementation.
  • -
  • calling unset on a property of an access interceptor scope localizer (or the real instance) will cause the two objects to be un-synchronized, with possible unexpected behaviour.
  • -
  • serializing or un-serializing an access interceptor scope localizer (or the real instance) will not cause the real instance (or the proxy) to be serialized or un-serialized
  • -
  • if a proxied object contains private properties, then an exception will be thrown if you use PHP < 5.4.0.
  • -
-
-

Example

- -

Here's an example of how you can create and use an access interceptor scope localizer :

- -
-        
-<?php
-
-use ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory as Factory;
-
-require_once __DIR__ . '/vendor/autoload.php';
-
-class Foo
-{
-    public function doFoo()
-    {
-        echo "Foo!\n";
-    }
-}
-
-$factory = new Factory();
-
-$proxy = $factory->createProxy(
-    new Foo(),
-    array('doFoo' => function () { echo "PreFoo!\n"; }),
-    array('doFoo' => function () { echo "PostFoo!\n"; })
-);
-
-$proxy->doFoo();
-        
-    
- -

This send something like following to your output:

- -
-        
-PreFoo!
-Foo!
-PostFoo!
-        
-    
- -

This is pretty much the same logic that you can find in access interceptor value holder.

- -
- - -
- - diff --git a/vendor/ocramius/proxy-manager/html-docs/access-interceptor-value-holder-proxy.html b/vendor/ocramius/proxy-manager/html-docs/access-interceptor-value-holder-proxy.html deleted file mode 100644 index b98e95a..0000000 --- a/vendor/ocramius/proxy-manager/html-docs/access-interceptor-value-holder-proxy.html +++ /dev/null @@ -1,208 +0,0 @@ - - - - ProxyManager - Tuning the ProxyManager for production - - - - - - - - - - - - - - -
-
- -
-
-
- - - - -
-
-
-
-
-
- - -
-
-

Access Interceptor Value Holder Proxy

- -

An access interceptor value holder is a smart reference proxy that allows you to dynamically define logic to be executed before or after any of the wrapped object's methods logic.

- -

It wraps around a real instance of the object to be proxied, and can be useful for things like:

- -
    -
  • caching execution of slow and heavy methods
  • -
  • log method calls
  • -
  • debugging
  • -
  • event triggering
  • -
  • handling of orthogonal logic, and AOP in general
  • -
-
-

Example

- -

Here's an example of how you can create and use an access interceptor value holder:

- -
-        
-<?php
-
-use ProxyManager\Factory\AccessInterceptorValueHolderFactory as Factory;
-
-require_once __DIR__ . '/vendor/autoload.php';
-
-class Foo
-{
-    public function doFoo()
-    {
-        echo "Foo!\n";
-    }
-}
-
-$factory = new Factory();
-
-$proxy = $factory->createProxy(
-    new Foo(),
-    array('doFoo' => function () { echo "PreFoo!\n"; }),
-    array('doFoo' => function () { echo "PostFoo!\n"; })
-);
-
-$proxy->doFoo();
-        
-    
- -

This send something like following to your output:

- -
-        
-PreFoo!
-Foo!
-PostFoo!
-        
-    
- -
-

Implementing pre- and post- access interceptors

- -

A proxy produced by the ProxyManager\Factory\AccessInterceptorValueHolderFactory implements both the ProxyManager\Proxy\ValueHolderInterface and the ProxyManager\Proxy\AccessInterceptorInterface.

- - -

Therefore, you can set an access interceptor callback by calling:

- -
-        
-$proxy->setMethodPrefixInterceptor('methodName', function () { echo 'pre'; });
-$proxy->setMethodSuffixInterceptor('methodName', function () { echo 'post'; });
-        
-    
- -

You can also listen to public properties access by attaching interceptors to __get, __set, __isset and __unset.

- -

A prefix interceptor (executed before method logic) should have following signature:

- -
-        
-/**
- * @var object $proxy       the proxy that intercepted the method call
- * @var object $instance    the wrapped instance within the proxy
- * @var string $method      name of the called method
- * @var array  $params      sorted array of parameters passed to the intercepted
- *                          method, indexed by parameter name
- * @var bool   $returnEarly flag to tell the interceptor proxy to return early, returning
- *                          the interceptor's return value instead of executing the method logic
- *
- * @return mixed
- */
-$prefixInterceptor = function ($proxy, $instance, $method, $params, & $returnEarly) {};
-        
-    
- - A suffix interceptor (executed after method logic) should have following signature: - -
-        
-/**
- * @var object $proxy       the proxy that intercepted the method call
- * @var object $instance    the wrapped instance within the proxy
- * @var string $method      name of the called method
- * @var array  $params      sorted array of parameters passed to the intercepted
- *                          method, indexed by parameter name
- * @var mixed  $returnValue the return value of the intercepted method
- * @var bool   $returnEarly flag to tell the proxy to return early, returning the interceptor's
- *                          return value instead of the value produced by the method
- *
- * @return mixed
- */
-$suffixInterceptor = function ($proxy, $instance, $method, $params, $returnValue, & $returnEarly) {};
-        
-    
- -
-

Tuning performance for production

- -

See Tuning ProxyManager for Production.

-
- - -
- - diff --git a/vendor/ocramius/proxy-manager/html-docs/contributing.html b/vendor/ocramius/proxy-manager/html-docs/contributing.html deleted file mode 100644 index aa34320..0000000 --- a/vendor/ocramius/proxy-manager/html-docs/contributing.html +++ /dev/null @@ -1,139 +0,0 @@ - - - - ProxyManager - Contributing - - - - - - - - - - - - - - -
-
- -
-
-
- - - - -
-
-
-
-
-
- - -
-
-

Contributing

- -
    -
  • Coding standard for the project is PSR-2
  • -
  • The project will follow strict object calisthenics
  • -
  • Any contribution must provide tests for additional introduced conditions
  • -
  • Any un-confirmed issue needs a failing test case before being accepted
  • -
  • Pull requests must be sent from a new hotfix/feature branch, not from master.
  • -
- - -
- -

Installation

- -

To install the project and run the tests, you need to clone it first:

- -
-        
-$ git clone git://github.com/Ocramius/ProxyManager.git
-            
-    
- -

You will then need to run a composer installation:

- -
-        
-$ cd ProxyManager
-$ curl -s https://getcomposer.org/installer | php
-$ php composer.phar update
-        
-    
- -
- -

Testing

- -

The PHPUnit version to be used is the one installed as a dev- dependency via composer:

- -
-        
-$ ./vendor/bin/phpunit
-        
-    
- -

Accepted coverage for new contributions is 80%. Any contribution not satisfying this requirement won't be merged.

- -
- - -
- - diff --git a/vendor/ocramius/proxy-manager/html-docs/copyright.html b/vendor/ocramius/proxy-manager/html-docs/copyright.html deleted file mode 100644 index 94f3fc7..0000000 --- a/vendor/ocramius/proxy-manager/html-docs/copyright.html +++ /dev/null @@ -1,100 +0,0 @@ - - - - ProxyManager - - - - - - - - - - - - -
-
- -
-
-
- - - - -
-
-
-
-
-
- - -
-
-

License

-

Copyright (c) 2013 Marco Pivetta

- -

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

- -

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

- -

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

-
- -
- - -
- - diff --git a/vendor/ocramius/proxy-manager/html-docs/credits.html b/vendor/ocramius/proxy-manager/html-docs/credits.html deleted file mode 100644 index 33f78d2..0000000 --- a/vendor/ocramius/proxy-manager/html-docs/credits.html +++ /dev/null @@ -1,113 +0,0 @@ - - - - ProxyManager - Credits - - - - - - - - - - - - -
-
- -
-
-
- - - - -
-
-
-
-
- - -
- - diff --git a/vendor/ocramius/proxy-manager/html-docs/css/styles.css b/vendor/ocramius/proxy-manager/html-docs/css/styles.css deleted file mode 100644 index ca49812..0000000 --- a/vendor/ocramius/proxy-manager/html-docs/css/styles.css +++ /dev/null @@ -1,203 +0,0 @@ -html { font-family: sans-serif; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; } -body { margin: 0; } -article, aside, details, figcaption, figure, footer, header, hgroup, main, nav, section, summary { display: block; } -audio, canvas, progress, video { display: inline-block; vertical-align: baseline; } -audio:not([controls]) { display: none; height: 0; } -[hidden], template { display: none; } -a { background: transparent; } -a:active, a:hover { outline: 0; } -abbr[title] { border-bottom: 1px dotted; } -b, strong { font-weight: bold; } -dfn { font-style: italic; } -h1 { font-size: 2em; margin: 0.67em 0; } -mark { background: #ff0; color: #000; } -small { font-size: 80%; } -sub, sup { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline; } -sup { top: -0.5em; } -sub { bottom: -0.25em; } -img { border: 0; } -svg:not(:root) { overflow: hidden; } -figure { margin: 1em 40px; } -hr { -moz-box-sizing: content-box; box-sizing: content-box; height: 0; } -pre { overflow: auto; } -code, kbd, pre, samp { font-family: monospace, monospace; font-size: 1em; } -button, input, optgroup, select, textarea { color: inherit; font: inherit; margin: 0; } -button { overflow: visible; } -button, select { text-transform: none; } -button, html input[type="button"], input[type="reset"], input[type="submit"] { -webkit-appearance: button; cursor: pointer; } -button[disabled], html input[disabled] { cursor: default; } -button::-moz-focus-inner, input::-moz-focus-inner { border: 0; padding: 0; } -input { line-height: normal; } -input[type="checkbox"], input[type="radio"] { box-sizing: border-box; padding: 0; } -input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { height: auto; } -input[type="search"] { -webkit-appearance: textfield; -moz-box-sizing: content-box; -webkit-box-sizing: content-box; box-sizing: content-box; } -input[type="search"]::-webkit-search-cancel-button, input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; } -fieldset { border: 1px solid #c0c0c0; margin: 0 2px; padding: 0.35em 0.625em 0.75em; } -legend { border: 0; padding: 0; } -textarea { overflow: auto; } -optgroup { font-weight: bold; } -table { border-collapse: collapse; border-spacing: 0; } -td, th { padding: 0; } -h1, h2, h3, h4, h5, h6, p, ul, ol, li { margin: 0; padding: 0; line-height: normal; } -a { color: #31811D; text-decoration: none; } -a:hover { color: #2F611C; text-decoration: none; } -strong { font-weight: 600; } -h3 { margin-bottom: 1em; color: #17324f; font-weight: 400; font-size: 3em; } -h4 { margin-bottom: 1em; font-weight: 400; font-size: 1.375em; } -p { margin-bottom: 1.5em; font-size: 1.125em; } -hr { margin: 2.5em 0; padding: 0; width: 100%; height: 3px; border: 0; background: #e6eaef; } -pre code { padding: 20px; border: 1px solid #EBEBEB; background: #F5F5F5; color: #08468a; font-weight: 200; font-size: .875em; } -code { background: transparent; color: #08468a; font-size: .875em; } -form { margin: 0; } -label { display: block; color: #18324f; font-weight: 400; font-size: 1.5em; margin-bottom: 2em; } -legend { position: static; margin: 0; padding: 0; font-weight: normal; } -legend span { position: absolute; top: 0; right: 0; left: 0; display: block; padding: 7px 0; border-bottom: 1px solid #e0dede; color: #ed4a21; font-size: 18px; line-height: 1em; } - -/* Menu Sidebar*/ -.button-block { padding-top: 15px; } -.button-block .btn-1 { margin-right: 6px; } -.btn, .spy-nav a { position: relative; display: inline-block; margin: 0; padding: 0 20px; height: 57px; border: 0; vertical-align: top; text-align: center; text-transform: uppercase; font-weight: 400; font-size: 1.125em; transitionP: all .2s; line-height: 57px; } -.btn.btn-action, .spy-nav a.btn-action { background: #ee2d4d; color: #fff; } -.btn.btn-action:hover, .spy-nav a.btn-action:hover { background: #bf0f2d; } -.btn.btn-default, .spy-nav a { background: #31811D; color: #fff; } -.btn.btn-default:hover, .spy-nav a:hover { background: #2F611C; color: #fff; } -.btn.btn-text, .spy-nav a.btn-text { color: #18324f; font-weight: 600; } -.btn.btn-full, .spy-nav a { display: block; } -@media only screen and (max-width: 480px) { - .site-header{ position: fixed !important; top: 0; z-index: 999999} - .page-title-wrapper{ margin-top: 70px;} - .main-wrapper iframe{ width: 42% !important; float: left; margin-left: 8%;} - .content iframe{width: 100%; height: 100%;} -} - -.btn-top { position: relative; display: inline-block; float: right; margin: 20px 0 0; padding: 0 30px 0 50px; height: 57px; border: 2px solid ##31811D; color: #31811D; vertical-align: top; text-align: center; text-transform: uppercase; font-weight: 600; font-size: 1.125em; line-height: 53px; transition: all .2s; } -.btn-top:before { background-position: 0 -140px; width: 52px; height: 52px; position: absolute; top: 0; left: 0; content: ''; } -@media only screen and (min-resolution: 2dppx), (-webkit-min-device-pixel-ratio: 2) { .btn-top:before { background-position: 0 -140px; background-size: 152px auto; width: 52px; height: 52px; } } -.btn-top:hover { border-color: #2F611C; color: #2F611C; } -@media only screen and (max-width: 768px) { .btn-top { float: none; margin-top: 0; margin-bottom: 30px; white-space: nowrap; } } -@media only screen and (max-width: 480px) { .btn-top { font-size: 0.9em; line-height: 46px; height: 48px; padding-right: 22px; padding-left: 47px; } } - -.btn-download { float: right; padding-left: 50px; } -.btn-download:before { background-position: -18px -116px; width: 16px; height: 16px; position: absolute; top: 50%; left: 20px; margin-top: -7px; content: ''; } -@media only screen and (min-resolution: 2dppx), (-webkit-min-device-pixel-ratio: 2) { .btn-download:before { background-position: -18px -116px; background-size: 152px auto; width: 16px; height: 16px; } } - -.btn-done { float: right; padding-left: 50px; } -.btn-done:before { background-position: 0 -116px; width: 18px; height: 14px; position: absolute; top: 50%; margin-top: -7px; left: 20px; content: ''; } -@media only screen and (min-resolution: 2dppx), (-webkit-min-device-pixel-ratio: 2) { .btn-done:before { background-position: 0 -116px; background-size: 152px auto; width: 18px; height: 13.5px; margin-top: -6.75px; } } - -.btn-cancel { float: right; } - -*, *:before, *:after { -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; } - -html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; min-width: 280px; } -@media only screen and (min-width: 64.063em) and (max-width: 90em) { html { min-width: 960px; } } - -body { font-size: 16px; font-family: 'Source Sans Pro', sans-serif; min-width: 290px; } -@media only screen and (max-width: 480px) { body.page-home { background-image: none; } } - -img { max-width: 100%; height: auto !important; } - -input { -webkit-appearance: none; -webkit-border-radius: 0; border-radius: 0; } - -main { overflow: hidden; } - -.clearfix:after { content: ""; display: table; clear: both; } - -.container { width: 60em; margin-left: auto; margin-right: auto; } -.container:after { content: " "; display: block; clear: both; } -@media only screen and (max-width: 1024px) { .container { margin-left: 15px; margin-right: 15px; width: auto; } } - -.content ul { padding-left: 19px; list-style-type: square; margin-top: 15px; } - -/* Menu top */ -.main-nav { float: right; } -.fixed-wrapper .main-nav { display: none; } -.active .main-nav { display: block; } -.main-nav > ul { list-style: none; } -.main-nav > ul > li { float: left; } -.main-nav > ul > li > a { display: block; padding: 22px 30px; color: #fff; text-decoration: none; text-transform: uppercase; font-weight: 600; font-size: 1.375em; line-height: 29px; transition: all .2s; } -.main-nav > ul > li > a:hover { color: #bfe5f1; background-color: #2F611C; } -.main-nav > ul > li > a.active { background-color: #2F611C; color: #fff; } -.main-nav > ul > li > a.opened { background-color: #18324f; } -@media only screen and (max-width: 600px) { .main-nav { font-size: 0.86em; } - .main-nav > ul > li > a { padding-left: 18px; padding-right: 18px; } } -@media only screen and (max-width: 480px) { .main-nav > ul > li > a { font-size: 0.95em; padding: 22px 6px; } } - -.site-header { position: relative; width: 100%; background: #31811D; } -.site-header h1 { float: left; margin: 15px 0; } -.site-header h1 a { display: block; } -.site-header h1 img { display: block; max-height: 42px; } -@media only screen and (max-width: 480px) { .site-header h1 img { max-height: 42px; } } - -.page-title-wrapper { position: relative; padding: 26px 0 55px; text-align: center; } -.page-title-wrapper .page-title { margin-top: 44px; color: #17324f; font-weight: 400; font-size: 3.75em; } -.page-title-wrapper .linguistics { padding: 0 2em 13px; border-bottom: 1px solid #D4DBE3; color: #18324f; text-transform: uppercase; font-weight: 400; font-size: 1.25em; } -@media only screen and (max-width: 768px) { .page-title-wrapper { font-size: 0.8em; } } -@media only screen and (max-width: 480px) { .page-title-wrapper { font-size: 0.65em; } } - -.site-footer { margin-top: 20px; padding-top: 50px; padding-bottom: 50px; background: #18324f; color: #7c8ea3; text-align: center; } -.site-footer .container { position: relative; } -.site-footer + .bcms-clearfix:after { content: ""; } -.about + .site-footer .main { padding-top: 150px; } -.footer-logos ul li{ list-style: none; display: inline-block;} -.footer-logos ul li a{ padding-left: 10px; padding-right: 10px} -.site-footer a{ color: white !important;} -.site-footer p { text-align: left; display: block; margin-bottom: 1.5em; font-size: 1.125em; } -@media only screen and (max-width: 1024px) { .site-footer p { margin-left: 0; } } -@media only screen and (max-width: 768px) { .site-footer p { text-align: center; margin-left: auto; } } -@media only screen and (max-width: 600px) { .site-footer { font-size: 0.9em; } } - -.main-logo { display: block; float: left; margin: 30px 0; } -.fixed-wrapper .main-logo { display: none; } -.main-logo img { display: block; } -.main-logo figure { position: relative; margin: 0; max-width: 56px; } -.main-logo figcaption { position: absolute; width: 160px; top: 20px; left: 68px; } -.active .main-logo { display: block; margin: 0; } -.active .main-logo figure { max-width: 42px; } -.active .main-logo figcaption { width: 120px; top: 15px; left: 55px; } -@media only screen and (max-width: 480px) { .main-logo figcaption { display: none; } } - -.container { width: 60em; margin-left: auto; margin-right: auto; } -.container:after { content: " "; display: block; clear: both; } -@media only screen and (max-width: 1024px) { .container { margin-left: 15px; margin-right: 15px; width: auto; } } - -.component-demo { position: relative; padding: 1px 0 0; background: #e6eaef; } -.component-demo:before { background-image: url("../img/enf.png"); } -@media only screen and (max-width: 480px) { .component-demo { padding: 40px 0 0; } } - -.component-info .container { position: relative; } -.component-info .sidebar { width: 220px; float: left; margin-top: 75px; } -.component-info .sidebar .component-meta { margin-top: 10px; font-size: 1.125em; } -.component-info .sidebar .component-meta span { white-space: nowrap; margin-bottom: 10px; padding-left: 25px; color: #18324f; } -.component-info .sidebar.sticky { position: fixed; margin-top: 38px; } -.component-info .content { width: 64.58333333%; float: right; margin-top: 60px; margin-bottom: 75px; } -.component-info .content h3 { margin-bottom: .75em; font-size: 2.75em; } -.component-info .content p { margin-bottom: 1.75em; line-height: 1.45; } -@media only screen and (max-width: 480px) { .component-info .content .section-title { font-size: 2.1em; } } -@media only screen and (max-width: 768px) { .component-info .sidebar { float: none; margin-left: auto; margin-right: auto; } - .component-info .sidebar .component-meta { margin-top: 30px; text-align: center; } - .component-info .sidebar.sticky { position: relative; margin-top: 75px; } - .component-info .content { float: none; width: 100%; } } -@media only screen and (max-width: 480px) { .component-info .content { margin-bottom: 0; } } - -.spy-nav { margin-bottom: 10px; } -.spy-nav ul { list-style: none; } -.spy-nav a { padding-top: 9px; padding-bottom: 10px; height: auto; border-bottom: 1px solid #4B8B20; text-align: left; text-transform: none; font-size: 1.375em; line-height: normal; } -.spy-nav .active a { border-bottom-color: #fff; background: #fff; color: #17324f; } -@media only screen and (max-width: 768px) { /*.spy-nav { display: none; } */} - -.main-wrapper { margin: 44px auto 44px; max-width: 600px; } -.main-wrapper label { display: block; margin-bottom: .75em; color: #3f4e5e; font-size: 1.25em; } -.main-wrapper .text-field { padding: 0 15px; width: 100%; height: 40px; border: 1px solid #CBD3DD; font-size: 1.125em; } -.main-wrapper ::-webkit-input-placeholder { color: #CBD3DD; font-style: italic; font-size: 18px; } -.main-wrapper :-moz-placeholder { color: #CBD3DD; font-style: italic; font-size: 18px; } -.main-wrapper ::-moz-placeholder { color: #CBD3DD; font-style: italic; font-size: 18px; } -.main-wrapper :-ms-input-placeholder { color: #CBD3DD; font-style: italic; font-size: 18px; } - -.page-icon-wrapper:before, .page-icon-wrapper .logo-asp:before, .page-icon-wrapper .logo-hibernate:before, .page-icon-wrapper .logo-angularjs:before, .page-icon-wrapper .logo-requirejs:before, .page-icon-wrapper .logo-reward:before, .component-demo:before {background-repeat: no-repeat; background-size: 100%; width: 92px; height: 108px; position: absolute; left: 50%; margin-left: -46px; top: 0; bottom: auto; margin-top: -28px; content: ''; } - -.container { width: 60em; margin-left: auto; margin-right: auto; } -.container:after { content: " "; display: block; clear: both; } -@media only screen and (max-width: 1024px) { .container { margin-left: 15px; margin-right: 15px; width: auto; } } - -.bcms-clearfix:after {content: ""; visibility: hidden; display: block; height: 0; clear: both; } diff --git a/vendor/ocramius/proxy-manager/html-docs/download.html b/vendor/ocramius/proxy-manager/html-docs/download.html deleted file mode 100644 index 4862ef3..0000000 --- a/vendor/ocramius/proxy-manager/html-docs/download.html +++ /dev/null @@ -1,97 +0,0 @@ - - - - ProxyManager - - - - - - - - - - - - - - -
-
- -
-
-
- - - - -
-
-
-
-
-
- - -
-
-

Installation

-

The suggested installation method is via composer.

-
php composer.phar require ocramius/proxy-manager:1.0.*
-
- -
- - -
- - diff --git a/vendor/ocramius/proxy-manager/html-docs/favicon.ico b/vendor/ocramius/proxy-manager/html-docs/favicon.ico deleted file mode 100644 index 797ca03..0000000 Binary files a/vendor/ocramius/proxy-manager/html-docs/favicon.ico and /dev/null differ diff --git a/vendor/ocramius/proxy-manager/html-docs/ghost-object.html b/vendor/ocramius/proxy-manager/html-docs/ghost-object.html deleted file mode 100644 index ce7b2fc..0000000 --- a/vendor/ocramius/proxy-manager/html-docs/ghost-object.html +++ /dev/null @@ -1,314 +0,0 @@ - - - - ProxyManager - Ghost object - - - - - - - - - - - - - - -
-
- -
-
-
- - - - -
-
-
-
-
-
- - -
-
-

Lazy Loading Ghost Object Proxies

- -

A lazy loading ghost object proxy is a ghost proxy that looks exactly like the real instance of the proxied subject, but which has all properties nulled before initialization.

-
- -

Lazy loading with the Ghost Object

- -

In pseudo-code, in userland, lazy loading in a ghost object looks like following:

- -
-        
-class MyObjectProxy
-{
-    private $initialized = false;
-    private $name;
-    private $surname;
-
-    public function doFoo()
-    {
-        $this->init();
-
-        // Perform doFoo routine using loaded variables
-    }
-
-    private function init()
-    {
-        if (! $this->initialized) {
-            $data          = some_logic_that_loads_data();
-
-            $this->name    = $data['name'];
-            $this->surname = $data['surname'];
-
-            $this->initialized = true;
-        }
-    }
-}
-        
-    
- -

Ghost objects work similarly to virtual proxies, but since they don't wrap around a "real" instance of the proxied subject, they are better suited for representing dataset rows.

- -
- -

When do I use a ghost object?

- -

You usually need a ghost object in cases where following applies

- -
    -
  • you are building a small data-mapper and want to lazily load data across associations in your object graph
  • -
  • you want to initialize objects representing rows in a large dataset
  • -
  • you want to compare instances of lazily initialized objects without the risk of comparing a proxy with a real subject
  • -
  • you are aware of the internal state of the object and are confident in working with its internals via reflection or direct property access
  • -
- -
- -

Usage examples

- -

ProxyManager provides a factory that creates lazy loading ghost objects. To use it, follow these steps:

- -

First of all, define your object's logic without taking care of lazy loading:

- -
-        
-namespace MyApp;
-
-class Customer
-{
-    private $name;
-    private $surname;
-
-    // just write your business logic or generally logic
-    // don't worry about how complex this object will be!
-    // don't code lazy-loading oriented optimizations in here!
-    public function getName() { return $this->name; }
-    public function setName($name) { $this->name = (string) $name; }
-    public function getSurname() { return $this->surname; }
-    public function setSurname($surname) { $this->surname = (string) $surname; }
-}
-        
-    
- -

Then use the proxy manager to create a ghost object of it. You will be responsible of setting its state during lazy loading:

- -
-        
-namespace MyApp;
-
-use ProxyManager\Factory\LazyLoadingGhostFactory;
-use ProxyManager\Proxy\LazyLoadingInterface;
-
-require_once __DIR__ . '/vendor/autoload.php';
-
-$factory     = new LazyLoadingGhostFactory();
-$initializer = function (LazyLoadingInterface $proxy, $method, array $parameters, & $initializer) {
-    $initializer   = null; // disable initialization
-
-    // load data and modify the object here
-    $proxy->setName('Agent');
-    $proxy->setSurname('Smith');
-
-    return true; // confirm that initialization occurred correctly
-};
-
-$instance = $factory->createProxy('MyApp\Customer', $initializer);
-        
-    
- -

You can now simply use your object as before:

- -
-        
-// this will just work as before
-echo $proxy->getName() . ' ' . $proxy->getSurname(); // Agent Smith
-        
-    
-
- -

Lazy Initialization

- -

As you can see, we use a closure to handle lazy initialization of the proxy instance at runtime. The initializer closure signature for ghost objects should be as following:

- -
-        
-/**
- * @var object  $proxy         the instance the ghost object proxy that is being initialized
- * @var string  $method        the name of the method that triggered lazy initialization
- * @var array   $parameters    an ordered list of parameters passed to the method that
- *                             triggered initialization, indexed by parameter name
- * @var Closure $initializer   a reference to the property that is the initializer for the
- *                             proxy. Set it to null to disable further initialization
- *
- * @return bool true on success
- */
-$initializer = function ($proxy, $method, $parameters, & $initializer) {};
-        
-    
- -

The initializer closure should usually be coded like following:

- -
-        
-$initializer = function ($proxy, $method, $parameters, & $initializer) {
-    $initializer = null; // disable initializer for this proxy instance
-
-    // modify the object with loaded data
-    $proxy->setFoo(/* ... */);
-    $proxy->setBar(/* ... */);
-
-    return true; // report success
-};
-        
-    
- -

The ProxyManager\Factory\LazyLoadingGhostFactory produces proxies that implement both the ProxyManager\Proxy\GhostObjectInterface and the ProxyManager\Proxy\LazyLoadingInterface.

- -

At any point in time, you can set a new initializer for the proxy:

- -
-        
-$proxy->setProxyInitializer($initializer);
-        
-    
- -

In your initializer, you MUST turn off any further initialization:

- -
-        
-$proxy->setProxyInitializer(null);
-        
-    
- -

or

- -
-        
-$initializer = null; // if you use the initializer passed by reference to the closure
-        
-    
-
- -

Triggering Initialization

- -

A lazy loading ghost object is initialized whenever you access any property or method of it. Any of the following interactions would trigger lazy initialization:

- -
-        
-// calling a method
-$proxy->someMethod();
-
-// reading a property
-echo $proxy->someProperty;
-
-// writing a property
-$proxy->someProperty = 'foo';
-
-// checking for existence of a property
-isset($proxy->someProperty);
-
-// removing a property
-unset($proxy->someProperty);
-
-// cloning the entire proxy
-clone $proxy;
-
-// serializing the proxy
-$unserialized = unserialize(serialize($proxy));
-        
-    
- -

Remember to call $proxy->setProxyInitializer(null); to disable initialization of your proxy, or it will happen more than once.

- -
- -

Proxying interfaces

- -

You can also generate proxies from an interface FQCN. By proxying an interface, you will only be able to access the methods defined by the interface itself, even if the wrappedObject implements more methods. This will anyway save some memory since the proxy won't contain any properties.

- -

Tuning performance for production

- -

See Tuning ProxyManager for Production.

- -
- - -
- - diff --git a/vendor/ocramius/proxy-manager/html-docs/img/block.png b/vendor/ocramius/proxy-manager/html-docs/img/block.png deleted file mode 100644 index fb8f17a..0000000 Binary files a/vendor/ocramius/proxy-manager/html-docs/img/block.png and /dev/null differ diff --git a/vendor/ocramius/proxy-manager/html-docs/img/enf.png b/vendor/ocramius/proxy-manager/html-docs/img/enf.png deleted file mode 100644 index 7e15bdd..0000000 Binary files a/vendor/ocramius/proxy-manager/html-docs/img/enf.png and /dev/null differ diff --git a/vendor/ocramius/proxy-manager/html-docs/index.html b/vendor/ocramius/proxy-manager/html-docs/index.html deleted file mode 100644 index 9c0ef23..0000000 --- a/vendor/ocramius/proxy-manager/html-docs/index.html +++ /dev/null @@ -1,295 +0,0 @@ - - - - ProxyManager - - - - - - - - - - - - - - -
-
-
- -

Proxy Manager

-
-
- -
-
-
- - - - -
-
-
-
-
-
- - - -
-

Proxy Manager

-

This library aims at providing abstraction for generating various kinds of proxy classes.

-

If you want to learn more about proxy pattern watch this video:

- - -
-
-

Installation

-

The suggested installation method is via composer.

-
php composer.phar require ocramius/proxy-manager:1.0.*
-
- -

Lazy Loading Value Holders (Virtual Proxy)

- -

ProxyManager can generate - lazy loading value holders, - which are virtual proxies capable of saving performance and memory for objects that - require a lot of dependencies or CPU cycles to be loaded: - particularly useful when you may not always need the object, - but are constructing it anyways.

- -
-        
-$factory = new \ProxyManager\Factory\LazyLoadingValueHolderFactory();
-
-$proxy = $factory->createProxy(
-    'MyApp\HeavyComplexObject',
-    function (& $wrappedObject, $proxy, $method, $parameters, & $initializer) {
-        $wrappedObject = new HeavyComplexObject(); // instantiation logic here
-        $initializer   = null; // turning off further lazy initialization
-
-        return true;
-    }
-);
-
-$proxy->doFoo();
-        
-    
- -

See the complete documentation about lazy loading value holders.

-
- -

Access Interceptor Value Holder

- -

An access interceptor value holder is a smart reference that allows you to execute - logic before and after a particular method is executed or a particular property is - accessed, and it allows to manipulate parameters and return values depending on - your needs.

- -
-        
-$factory = new \ProxyManager\Factory\AccessInterceptorValueHolderFactory();
-
-$proxy = $factory->createProxy(
-    new \My\Db\Connection(),
-    array('query' => function () { echo "Query being executed!\n"; }),
-    array('query' => function () { echo "Query completed!\n"; })
-);
-
-$proxy->query(); // produces "Query being executed!\nQuery completed!\n"
-        
-    
- -

See the complete documentation about access interceptor value holders.

-
- -

Access Interceptor Scope Localizer

- -

An access interceptor scope localizer works exactly like an access interceptor - value holder, but it is safe to use to proxy fluent interfaces.

- -

See the complete documentation about access interceptor scope localizer.

-
- - -

Null Objects

- -

A Null Object proxy implements the null object pattern.

- -

This kind of proxy allows you to have fallback logic in case loading of the wrapped value failed.

-
-        
-$factory = new \ProxyManager\Factory\NullObjectFactory();
-
-$proxy = $factory->createProxy('My\EntityObject');
-
-$proxy->getName(); // empty return
-        
-    
- -

A Null Object Proxy can be created from an object, a class name or an interface name:

-
-        
-$factory = new \ProxyManager\Factory\NullObjectFactory();
-
-$proxy = $factory->createProxy('My\EntityObjectInterface');
-$proxy->getName(); // empty return
-
-$proxy = $factory->createProxy($entity); // created from object
-$proxy->getName(); // empty return
-        
-    
- -

See the complete documentation about null object proxy.

- -
- -

Ghost Objects

- -

Similar to value holder, a ghost object is usually created to handle lazy loading.

- -

The difference between a value holder and a ghost object is that the ghost - object does not contain a real instance of the required object, but handles - lazy loading by initializing its own inherited properties.

- -

ProxyManager can generate - lazy loading ghost objects, - which are proxies used to save performance and memory for large datasets and - graphs representing relational data. Ghost objects are particularly useful - when building data-mappers.

- -

Additionally, the overhead introduced by ghost objects is very low when - compared to the memory and performance overhead caused by virtual proxies.

- -
-        
-$factory = new \ProxyManager\Factory\LazyLoadingGhostFactory();
-
-$proxy = $factory->createProxy(
-    'MyApp\HeavyComplexObject',
-    function ($proxy, $method, $parameters, & $initializer) {
-        $initializer   = null; // turning off further lazy initialization
-
-        // modify the proxy instance
-        $proxy->setFoo('foo');
-        $proxy->setBar('bar');
-
-        return true;
-    }
-);
-
-$proxy->doFoo();
-        
-    
- -

See the complete documentation about lazy loading ghost objects.

- -
- -

Remote Object

- -

A remote object proxy is an object that is located on a different system, - but is used as if it was available locally. There's various possible - remote proxy implementations, which could be based on xmlrpc/jsonrpc/soap/dnode/etc.

- -

This example uses the XML-RPC client of Zend Framework 2:

- -
-        
-interface FooServiceInterface
-{
-    public function foo();
-}
-
-$factory = new \ProxyManager\Factory\RemoteObjectFactory(
-    new \ProxyManager\Factory\RemoteObject\Adapter\XmlRpc(
-        new \Zend\XmlRpc\Client('https://example.com/rpc-endpoint')
-    )
-);
-
-// proxy is your remote implementation
-$proxy = $factory->createProxy('FooServiceInterface');
-
-var_dump($proxy->foo());
-        
-    
- -

See the complete documentation about remote objects.

-
- - -

Contributing

-

Please read the CONTRIBUTING contents if you wish to help out!

- -
- -

Credits

- -

The idea was originated by a talk about Proxies in PHP OOP that I gave at the @phpugffm in January 2013.

- - -
- -
-
-
- - -
- - -
- - diff --git a/vendor/ocramius/proxy-manager/html-docs/null-object.html b/vendor/ocramius/proxy-manager/html-docs/null-object.html deleted file mode 100644 index 5c2476b..0000000 --- a/vendor/ocramius/proxy-manager/html-docs/null-object.html +++ /dev/null @@ -1,185 +0,0 @@ - - - - ProxyManager - Null object - - - - - - - - - - - - - - -
-
- -
-
-
- - - - -
-
-
-
-
-
- - -
-
-

Null Object Proxy

-

A Null Object proxy is a null object pattern implementation. The proxy factory creates a new object with defined neutral behavior based on an other object, class name or interface.

-
- -

What is null object proxy ?

- -

In your application, when you can't return the object related to the request, the consumer of the model must check for the return value and handle the failing condition gracefully, thus generating an explosion of conditionals throughout your code. Fortunately, this seemingly-tangled situation can be sorted out simply by creating a polymorphic implementation of the domain object, which would implement the same interface as the one of the object in question, only that its methods wouldn’t do anything, therefore offloading client code from doing repetitive checks for ugly null values when the operation is executed.

- -
- -

Usage examples

- -
-        
-class UserMapper
-{   
-    private $adapter;
-
-    public function __construct(DatabaseAdapterInterface $adapter) {
-        $this->adapter = $adapter;
-    }
-
-    public function fetchById($id) {
-        $this->adapter->select("users", array("id" => $id));
-        if (!$row = $this->adapter->fetch()) {
-            return null;
-        }
-        return $this->createUser($row);
-    }
-
-    private function createUser(array $row) {
-        $user = new Entity\User($row["name"], $row["email"]);
-        $user->setId($row["id"]);
-        return $user;
-    }
-}
-        
-    
- -

If you want to remove conditionals from client code, you need to have a version of the entity conforming to the corresponding interface. With the Null Object Proxy, you can build this object :

- -
-        
-$factory = new \ProxyManager\Factory\NullObjectFactory();
-
-$nullUser = $factory->createProxy('Entity\User');
-
-var_dump($nullUser->getName()); // empty return
-        
-    
- -

You can now return a valid entity :

- -
-        
-class UserMapper
-{   
-    private $adapter;
-
-    public function __construct(DatabaseAdapterInterface $adapter) {
-        $this->adapter = $adapter;
-    }
-
-    public function fetchById($id) {
-        $this->adapter->select("users", array("id" => $id));
-        return $this->createUser($this->adapter->fetch());
-    }
-
-    private function createUser($row) {
-        if (!$row) {
-            $factory = new \ProxyManager\Factory\NullObjectFactory();
-
-            return $factory->createProxy('Entity\User');
-        }
-        $user = new Entity\User($row["name"], $row["email"]);
-        $user->setId($row["id"]);
-        return $user; 
-    }
-}
-        
-    
- - -
- -

Proxying interfaces

- -

You can also generate proxies from an interface FQCN. By proxying an interface, you will only be able to access the methods defined by the interface itself, and like with the object, the methods are empty.

- -

Tuning performance for production

- -

See Tuning ProxyManager for Production.

- -
- - -
- - diff --git a/vendor/ocramius/proxy-manager/html-docs/production.html b/vendor/ocramius/proxy-manager/html-docs/production.html deleted file mode 100644 index 39c086b..0000000 --- a/vendor/ocramius/proxy-manager/html-docs/production.html +++ /dev/null @@ -1,114 +0,0 @@ - - - - ProxyManager - Tuning the ProxyManager for production - - - - - - - - - - - - - - -
-
- -
-
-
- - - - -
-
-
-
-
-
- - -
-
-

Tuning the ProxyManager for production

- -

By default, all proxy factories generate the required proxy classes at runtime.

- -

Proxy generation causes I/O operations and uses a lot of reflection, so be sure to have generated all of your proxies before deploying your code on a live system, or you may experience poor performance.

- -

You can configure ProxyManager so that it will try autoloading the proxies first. Generating them "bulk" is not yet implemented:

- -
-        
-$config = new \ProxyManager\Configuration();
-$config->setProxiesTargetDir(__DIR__ . '/my/generated/classes/cache/dir');
-
-// then register the autoloader
-spl_autoload_register($config->getProxyAutoloader());
-        
-    
- -

Generating a classmap with all your proxy classes in it will also work perfectly.

- -

Please note that all the currently implemented ProxyManager\Factory\* classes accept a ProxyManager\Configuration object as optional constructor parameter. This allows for fine-tuning of ProxyManager according to your needs.

- -
- - -
- - diff --git a/vendor/ocramius/proxy-manager/html-docs/remote-object.html b/vendor/ocramius/proxy-manager/html-docs/remote-object.html deleted file mode 100644 index 3fc627d..0000000 --- a/vendor/ocramius/proxy-manager/html-docs/remote-object.html +++ /dev/null @@ -1,203 +0,0 @@ - - - - ProxyManager - Remote object - - - - - - - - - - - - - - -
-
- -
-
-
- - - - -
-
-
-
-
-
- - -
-
-

Remote Object Proxy

- -

The remote object implementation is a mechanism that enables an local object to control an other object on an other server. Each call method on the local object will do a network call to get information or execute operations on the remote object.

-
- -

What is remote object proxy ?

- -

A remote object is based on an interface. The remote interface defines the API that a consumer can call. This interface must be implemented both by the client and the RPC server.

-
- -

Adapters

- -

ZendFramework's RPC components (XmlRpc, JsonRpc & Soap) can be used easily with the remote object. You will need to require the one you need via composer, though:

- -
-        
-$ php composer.phar require zendframework/zend-xmlrpc:2.*
-$ php composer.phar require zendframework/zend-json:2.*
-$ php composer.phar require zendframework/zend-soap:2.*
-        
-    
- -

ProxyManager comes with 3 adapters:

- -
    -
  • ProxyManager\Factory\RemoteObject\Adapter\XmlRpc
  • -
  • ProxyManager\Factory\RemoteObject\Adapter\JsonRpc
  • -
  • ProxyManager\Factory\RemoteObject\Adapter\Soap
  • -
- -
- -

Usage examples

- -

RPC server side code (xmlrpc.php in your local webroot):

- -
-        
-interface FooServiceInterface
-{
-    public function foo();
-}
-
-class Foo implements FooServiceInterface
-{
-    /**
-     * Foo function
-     * @return string
-     */
-    public function foo()
-    {
-        return 'bar remote';
-    }
-}
-
-$server = new Zend\XmlRpc\Server();
-$server->setClass('Foo', 'FooServiceInterface');  // my FooServiceInterface implementation
-$server->handle();
-        
-    
- -

Client side code (proxy) :

- -
-        
-interface FooServiceInterface
-{
-    public function foo();
-}
-
-$factory = new \ProxyManager\Factory\RemoteObjectFactory(
-    new \ProxyManager\Factory\RemoteObject\Adapter\XmlRpc(
-        new \Zend\XmlRpc\Client('https://localhost/xmlrpc.php')
-    )
-);
-
-$proxy = $factory->createProxy('FooServiceInterface');
-
-var_dump($proxy->foo()); // "bar remote"
-        
-    
-
- -

Implementing custom adapters

- -

Your adapters must implement ProxyManager\Factory\RemoteObject\AdapterInterface :

- -
-        
-interface AdapterInterface
-{
-    /**
-     * Call remote object
-     *
-     * @param string $wrappedClass
-     * @param string $method
-     * @param array $params
-     *
-     * @return mixed
-     */
-    public function call($wrappedClass, $method, array $params = array());
-}
-        
-    
- -

It is very easy to create your own implementation (for RESTful web services, for example). Simply pass your own adapter instance to your factory at construction time

- -

Tuning performance for production

- -

See Tuning ProxyManager for Production.

- -
- - -
- - diff --git a/vendor/ocramius/proxy-manager/html-docs/virtual-proxy.html b/vendor/ocramius/proxy-manager/html-docs/virtual-proxy.html deleted file mode 100644 index 5dbb038..0000000 --- a/vendor/ocramius/proxy-manager/html-docs/virtual-proxy.html +++ /dev/null @@ -1,305 +0,0 @@ - - - - ProxyManager - Virtual Proxy - - - - - - - - - - - - - - -
-
- -
-
-
- - - - -
-
-
-
-
-
- - -
-
-

Lazy Loading Value Holder Proxy

-

A lazy loading value holder proxy is a virtual proxy that wraps and lazily initializes a "real" instance of the proxied class.

-
- -

What is lazy loading?

- -

In pseudo-code, in userland, lazy loading looks like following:

- -
-        
-class MyObjectProxy
-{
-    private $wrapped;
-
-    public function doFoo()
-    {
-        $this->init();
-
-        return $this->wrapped->doFoo();
-    }
-
-    private function init()
-    {
-        if (null === $this->wrapped) {
-            $this->wrapped = new MyObject();
-        }
-    }
-}
-    
-
- -

This code is problematic, and adds a lot of complexity that makes your unit tests' code even worse.

- -

Also, this kind of usage often ends up in coupling your code with a particular Dependency Injection Container or a framework that fetches dependencies for you. That way, further complexity is introduced, and some problems related with service location raise, as I've explained in this article.

- -

Lazy loading value holders abstract this logic for you, hiding your complex, slow, performance-impacting objects behind tiny wrappers that have their same API, and that get initialized at first usage.

- -
- -

When do I use a lazy value holder?

- -

You usually need a lazy value holder in cases where following applies

- -
    -
  • your object takes a lot of time and memory to be initialized (with all dependencies)
  • -
  • your object is not always used, and the instantiation overhead can be avoided
  • -
- -
- -

Usage examples

- -

ProxyManager provides a factory that eases instantiation of lazy loading value holders. To use it, follow these steps:

- -

First of all, define your object's logic without taking care of lazy loading:

- -
-    
-namespace MyApp;
-
-class HeavyComplexObject
-{
-    public function __construct()
-    {
-        // just write your business logic
-        // don't worry about how heavy initialization of this will be!
-    }
-
-    public function doFoo() {
-        echo "OK!"
-    }
-}
-    
-
- -

Then use the proxy manager to create a lazy version of the object (as a proxy):

- -
-    
-namespace MyApp;
-
-use ProxyManager\Factory\LazyLoadingValueHolderFactory;
-use ProxyManager\Proxy\LazyLoadingInterface;
-
-require_once __DIR__ . '/vendor/autoload.php';
-
-$factory     = new LazyLoadingValueHolderFactory();
-$initializer = function (& $wrappedObject, LazyLoadingInterface $proxy, $method, array $parameters, & $initializer) {
-    $initializer   = null; // disable initialization
-    $wrappedObject = new HeavyComplexObject(); // fill your object with values here
-
-    return true; // confirm that initialization occurred correctly
-};
-
-$instance = $factory->createProxy('MyApp\HeavyComplexObject', $initializer);
-    
-
- -

You can now simply use your object as before:

- -
-    
-// this will just work as before
-$proxy->doFoo(); // OK!
-    
-
-
- - -

Lazy Initialization

- -

As you can see, we use a closure to handle lazy initialization of the proxy instance at runtime. The initializer closure signature should be as following:

- -
-    
-/**
- * @var object  $wrappedObject the instance (passed by reference) of the wrapped object,
- *                             set it to your real object
- * @var object  $proxy         the instance proxy that is being initialized
- * @var string  $method        the name of the method that triggered lazy initialization
- * @var string  $parameters    an ordered list of parameters passed to the method that
- *                             triggered initialization, indexed by parameter name
- * @var Closure $initializer   a reference to the property that is the initializer for the
- *                             proxy. Set it to null to disable further initialization
- *
- * @return bool true on success
- */
-$initializer = function (& $wrappedObject, $proxy, $method, $parameters, & $initializer) {};
-    
-
- -

The initializer closure should usually be coded like following:

- -
-    
-$initializer = function (& $wrappedObject, $proxy, $method, $parameters, & $initializer) {
-    $newlyCreatedObject = new Foo(); // instantiation logic
-    $newlyCreatedObject->setBar('baz') // instantiation logic
-    $newlyCreatedObject->setBat('bam') // instantiation logic
-
-    $wrappedObject = $newlyCreatedObject; // set wrapped object in the proxy
-    $initializer   = null; // disable initializer
-
-    return true; // report success
-};
-    
-
- -

The ProxyManager\Factory\LazyLoadingValueHolderFactory produces proxies that implement both the ProxyManager\Proxy\ValueHolderInterface and the ProxyManager\Proxy\LazyLoadingInterface.

- -

At any point in time, you can set a new initializer for the proxy:

- -
$proxy->setProxyInitializer($initializer);
- -

In your initializer, you currently MUST turn off any further initialization:

- -
$proxy->setProxyInitializer(null);
- -

or

- -
$initializer = null; // if you use the initializer by reference
-
- -

Triggering Initialization

- -

A lazy loading proxy is initialized whenever you access any property or method of it. Any of the following interactions would trigger lazy initialization:

- -
-    
-// calling a method
-$proxy->someMethod();
-
-// reading a property
-echo $proxy->someProperty;
-
-// writing a property
-$proxy->someProperty = 'foo';
-
-// checking for existence of a property
-isset($proxy->someProperty);
-
-// removing a property
-unset($proxy->someProperty);
-
-// cloning the entire proxy
-clone $proxy;
-
-// serializing the proxy
-$unserialized = serialize(unserialize($proxy));
-    
-
- -

Remember to call $proxy->setProxyInitializer(null); to disable initialization of your proxy, or it will happen more than once.

- - - - - - - - -
- -

Proxying interfaces

- -

You can also generate proxies from an interface FQCN. By proxying an interface, you will only be able to access the methods defined by the interface itself, even if the wrappedObject implements more methods. This will anyway save some memory since the proxy won't contain useless inherited properties.

- -

Tuning performance for production

- -

See Tuning ProxyManager for Production.

- - - -
- - -
- - diff --git a/vendor/ocramius/proxy-manager/index.html b/vendor/ocramius/proxy-manager/index.html deleted file mode 100644 index da417f7..0000000 --- a/vendor/ocramius/proxy-manager/index.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/vendor/ocramius/proxy-manager/phpdox.xml.dist b/vendor/ocramius/proxy-manager/phpdox.xml.dist deleted file mode 100644 index 6cbf78b..0000000 --- a/vendor/ocramius/proxy-manager/phpdox.xml.dist +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - diff --git a/vendor/ocramius/proxy-manager/phpmd.xml.dist b/vendor/ocramius/proxy-manager/phpmd.xml.dist deleted file mode 100644 index ae91e86..0000000 --- a/vendor/ocramius/proxy-manager/phpmd.xml.dist +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - diff --git a/vendor/ocramius/proxy-manager/phpunit.xml.dist b/vendor/ocramius/proxy-manager/phpunit.xml.dist deleted file mode 100644 index b595427..0000000 --- a/vendor/ocramius/proxy-manager/phpunit.xml.dist +++ /dev/null @@ -1,25 +0,0 @@ - - - - ./tests/ProxyManagerTest - - - ./tests/language-feature-scripts - - - - ./src - - - diff --git a/vendor/ocramius/proxy-manager/proxy-manager.png b/vendor/ocramius/proxy-manager/proxy-manager.png deleted file mode 100644 index 0ab1c6e..0000000 Binary files a/vendor/ocramius/proxy-manager/proxy-manager.png and /dev/null differ diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/AbstractLazyFactory.php b/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/AbstractLazyFactory.php deleted file mode 100644 index 690bfa1..0000000 --- a/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/AbstractLazyFactory.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @license MIT - */ -abstract class AbstractLazyFactory extends AbstractBaseFactory -{ - /** - * Creates a new lazy proxy instance of the given class with - * the given initializer - * - * @param string $className name of the class to be proxied - * @param \Closure $initializer initializer to be passed to the proxy - * - * @return \ProxyManager\Proxy\LazyLoadingInterface - */ - public function createProxy($className, Closure $initializer) - { - $proxyClassName = $this->generateProxy($className); - - return new $proxyClassName($initializer); - } -} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/Generator/ParameterGenerator.php b/vendor/ocramius/proxy-manager/src/ProxyManager/Generator/ParameterGenerator.php deleted file mode 100644 index 7960d42..0000000 --- a/vendor/ocramius/proxy-manager/src/ProxyManager/Generator/ParameterGenerator.php +++ /dev/null @@ -1,149 +0,0 @@ - - * @license MIT - */ -class ParameterGenerator extends ZendParameterGenerator -{ - /** - * @override - uses `static` to instantiate the parameter - * - * {@inheritDoc} - */ - public static function fromReflection(ParameterReflection $reflectionParameter) - { - /* @var $param self */ - $param = new static(); - - $param->setName($reflectionParameter->getName()); - $param->setPosition($reflectionParameter->getPosition()); - - $type = self::extractParameterType($reflectionParameter); - - if (null !== $type) { - $param->setType($type); - } - - self::setOptionalParameter($param, $reflectionParameter); - - $param->setPassedByReference($reflectionParameter->isPassedByReference()); - - return $param; - } - - /** - * Retrieves the type of a reflection parameter (null if none is found) - * - * @param ParameterReflection $reflectionParameter - * - * @return string|null - */ - private static function extractParameterType(ParameterReflection $reflectionParameter) - { - if ($reflectionParameter->isArray()) { - return 'array'; - } - - if (method_exists($reflectionParameter, 'isCallable') && $reflectionParameter->isCallable()) { - return 'callable'; - } - - if ($typeClass = $reflectionParameter->getClass()) { - return $typeClass->getName(); - } - - return null; - } - - /** - * @return string - */ - public function generate() - { - return $this->getGeneratedType() - . (true === $this->passedByReference ? '&' : '') - . '$' . $this->name - . $this->generateDefaultValue(); - } - - /** - * @return string - */ - private function generateDefaultValue() - { - if (null === $this->defaultValue) { - return ''; - } - - $defaultValue = $this->defaultValue instanceof ValueGenerator - ? $this->defaultValue - : new ValueGenerator($this->defaultValue); - - $defaultValue->setOutputMode(ValueGenerator::OUTPUT_SINGLE_LINE); - - return ' = ' . $defaultValue; - } - - /** - * Retrieves the generated parameter type - * - * @return string - */ - private function getGeneratedType() - { - if (! $this->type || in_array($this->type, static::$simple)) { - return ''; - } - - if ('array' === $this->type || 'callable' === $this->type) { - return $this->type . ' '; - } - - return '\\' . trim($this->type, '\\') . ' '; - } - - /** - * Set the default value for a parameter (if it is optional) - * - * @param ZendParameterGenerator $parameterGenerator - * @param ParameterReflection $reflectionParameter - */ - private static function setOptionalParameter( - ZendParameterGenerator $parameterGenerator, - ParameterReflection $reflectionParameter - ) { - if ($reflectionParameter->isOptional()) { - try { - $parameterGenerator->setDefaultValue($reflectionParameter->getDefaultValue()); - } catch (ReflectionException $e) { - $parameterGenerator->setDefaultValue(null); - } - } - } -} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/Constructor.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/Constructor.php deleted file mode 100644 index 3770a16..0000000 --- a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/Constructor.php +++ /dev/null @@ -1,92 +0,0 @@ - - * @license MIT - */ -class Constructor extends MethodGenerator -{ - /** - * Constructor - */ - public function __construct( - ReflectionClass $originalClass, - PropertyGenerator $prefixInterceptors, - PropertyGenerator $suffixInterceptors - ) { - parent::__construct('__construct'); - - $localizedObject = new ParameterGenerator('localizedObject'); - $prefix = new ParameterGenerator('prefixInterceptors'); - $suffix = new ParameterGenerator('suffixInterceptors'); - - $localizedObject->setType($originalClass->getName()); - $prefix->setDefaultValue(array()); - $suffix->setDefaultValue(array()); - $prefix->setType('array'); - $suffix->setType('array'); - - $this->setParameter($localizedObject); - $this->setParameter($prefix); - $this->setParameter($suffix); - - $localizedProperties = array(); - - foreach ($originalClass->getProperties() as $originalProperty) { - if ((! method_exists('Closure', 'bind')) && $originalProperty->isPrivate()) { - // @codeCoverageIgnoreStart - throw UnsupportedProxiedClassException::unsupportedLocalizedReflectionProperty($originalProperty); - // @codeCoverageIgnoreEnd - } - - $propertyName = $originalProperty->getName(); - - if ($originalProperty->isPrivate()) { - $localizedProperties[] = "\\Closure::bind(function () use (\$localizedObject) {\n " - . '$this->' . $propertyName . ' = & $localizedObject->' . $propertyName . ";\n" - . '}, $this, ' . var_export($originalProperty->getDeclaringClass()->getName(), true) - . ')->__invoke();'; - } else { - $localizedProperties[] = '$this->' . $propertyName . ' = & $localizedObject->' . $propertyName . ";"; - } - } - - $this->setDocblock( - "@override constructor to setup interceptors\n\n" - . "@param \\" . $originalClass->getName() . " \$localizedObject\n" - . "@param \\Closure[] \$prefixInterceptors method interceptors to be used before method logic\n" - . "@param \\Closure[] \$suffixInterceptors method interceptors to be used before method logic" - ); - $this->setBody( - (empty($localizedProperties) ? '' : implode("\n\n", $localizedProperties) . "\n\n") - . '$this->' . $prefixInterceptors->getName() . " = \$prefixInterceptors;\n" - . '$this->' . $suffixInterceptors->getName() . " = \$suffixInterceptors;" - ); - } -} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/Constructor.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/Constructor.php deleted file mode 100644 index 925ee6b..0000000 --- a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/Constructor.php +++ /dev/null @@ -1,79 +0,0 @@ - - * @license MIT - */ -class Constructor extends MethodGenerator -{ - /** - * Constructor - */ - public function __construct( - ReflectionClass $originalClass, - PropertyGenerator $valueHolder, - PropertyGenerator $prefixInterceptors, - PropertyGenerator $suffixInterceptors - ) { - parent::__construct('__construct'); - - $prefix = new ParameterGenerator('prefixInterceptors'); - $suffix = new ParameterGenerator('suffixInterceptors'); - - $prefix->setDefaultValue(array()); - $suffix->setDefaultValue(array()); - $prefix->setType('array'); - $suffix->setType('array'); - - $this->setParameter(new ParameterGenerator('wrappedObject')); - $this->setParameter($prefix); - $this->setParameter($suffix); - - /* @var $publicProperties \ReflectionProperty[] */ - $publicProperties = $originalClass->getProperties(ReflectionProperty::IS_PUBLIC); - $unsetProperties = array(); - - foreach ($publicProperties as $publicProperty) { - $unsetProperties[] = '$this->' . $publicProperty->getName(); - } - - $this->setDocblock( - "@override constructor to setup interceptors\n\n" - . "@param \\" . $originalClass->getName() . " \$wrappedObject\n" - . "@param \\Closure[] \$prefixInterceptors method interceptors to be used before method logic\n" - . "@param \\Closure[] \$suffixInterceptors method interceptors to be used before method logic" - ); - $this->setBody( - ($unsetProperties ? 'unset(' . implode(', ', $unsetProperties) . ");\n\n" : '') - . '$this->' . $valueHolder->getName() . " = \$wrappedObject;\n" - . '$this->' . $prefixInterceptors->getName() . " = \$prefixInterceptors;\n" - . '$this->' . $suffixInterceptors->getName() . " = \$suffixInterceptors;" - ); - } -} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoading/MethodGenerator/Constructor.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoading/MethodGenerator/Constructor.php deleted file mode 100644 index 224370b..0000000 --- a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoading/MethodGenerator/Constructor.php +++ /dev/null @@ -1,58 +0,0 @@ - - * @license MIT - */ -class Constructor extends MethodGenerator -{ - /** - * Constructor - */ - public function __construct(ReflectionClass $originalClass, PropertyGenerator $initializerProperty) - { - parent::__construct('__construct'); - - $this->setParameter(new ParameterGenerator('initializer')); - - /* @var $publicProperties \ReflectionProperty[] */ - $publicProperties = $originalClass->getProperties(ReflectionProperty::IS_PUBLIC); - $unsetProperties = array(); - - foreach ($publicProperties as $publicProperty) { - $unsetProperties[] = '$this->' . $publicProperty->getName(); - } - - $this->setDocblock("@override constructor for lazy initialization\n\n@param \\Closure|null \$initializer"); - $this->setBody( - ($unsetProperties ? 'unset(' . implode(', ', $unsetProperties) . ");\n\n" : '') - . '$this->' . $initializerProperty->getName() . ' = $initializer;' - ); - } -} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/MethodGenerator/LazyLoadingMethodInterceptor.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/MethodGenerator/LazyLoadingMethodInterceptor.php deleted file mode 100644 index d511a48..0000000 --- a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/LazyLoadingGhost/MethodGenerator/LazyLoadingMethodInterceptor.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @license MIT - */ -class LazyLoadingMethodInterceptor extends MethodGenerator -{ - /** - * @param \Zend\Code\Reflection\MethodReflection $originalMethod - * @param \Zend\Code\Generator\PropertyGenerator $initializerProperty - * @param \Zend\Code\Generator\MethodGenerator $callInitializer - * - * @return LazyLoadingMethodInterceptor|static - */ - public static function generateMethod( - MethodReflection $originalMethod, - PropertyGenerator $initializerProperty, - ZendMethodGenerator $callInitializer - ) { - /* @var $method self */ - $method = static::fromReflection($originalMethod); - $parameters = $originalMethod->getParameters(); - $methodName = $originalMethod->getName(); - $initializerParams = array(); - $forwardedParams = array(); - - foreach ($parameters as $parameter) { - $parameterName = $parameter->getName(); - $initializerParams[] = var_export($parameterName, true) . ' => $' . $parameterName; - $forwardedParams[] = '$' . $parameterName; - } - - $method->setBody( - '$this->' . $initializerProperty->getName() - . ' && $this->' . $callInitializer->getName() - . '(' . var_export($methodName, true) - . ', array(' . implode(', ', $initializerParams) . "));\n\n" - . 'return parent::' - . $methodName . '(' . implode(', ', $forwardedParams) . ');' - ); - $method->setDocblock('{@inheritDoc}'); - - return $method; - } -} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/NullObject/MethodGenerator/Constructor.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/NullObject/MethodGenerator/Constructor.php deleted file mode 100644 index 7f4c4ce..0000000 --- a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/NullObject/MethodGenerator/Constructor.php +++ /dev/null @@ -1,55 +0,0 @@ - - * @license MIT - */ -class Constructor extends MethodGenerator -{ - /** - * Constructor - * - * @param ReflectionClass $originalClass Reflection of the class to proxy - */ - public function __construct(ReflectionClass $originalClass) - { - parent::__construct('__construct'); - - /* @var $publicProperties \ReflectionProperty[] */ - $publicProperties = $originalClass->getProperties(ReflectionProperty::IS_PUBLIC); - $nullableProperties = array(); - - foreach ($publicProperties as $publicProperty) { - $nullableProperties[] = '$this->' . $publicProperty->getName() . ' = null;'; - } - - $this->setDocblock("@override constructor for null object initialization"); - if ($nullableProperties) { - $this->setBody(implode("\n", $nullableProperties)); - } - } -} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/PropertyGenerator/PublicPropertiesDefaults.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/PropertyGenerator/PublicPropertiesDefaults.php deleted file mode 100644 index 55822f3..0000000 --- a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/PropertyGenerator/PublicPropertiesDefaults.php +++ /dev/null @@ -1,58 +0,0 @@ - - * @license MIT - */ -class PublicPropertiesDefaults extends PropertyGenerator -{ - /** - * @var bool[] - */ - private $publicProperties = array(); - - /** - * @param \ReflectionClass $originalClass - */ - public function __construct(ReflectionClass $originalClass) - { - parent::__construct(UniqueIdentifierGenerator::getIdentifier('publicPropertiesDefaults')); - - $defaults = $originalClass->getDefaultProperties(); - - foreach ($originalClass->getProperties(ReflectionProperty::IS_PUBLIC) as $publicProperty) { - $name = $publicProperty->getName(); - $this->publicProperties[$name] = $defaults[$name]; - } - - $this->setDefaultValue($this->publicProperties); - $this->setVisibility(self::VISIBILITY_PRIVATE); - $this->setStatic(true); - $this->setDocblock('@var mixed[] map of default property values of the parent class'); - } -} diff --git a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/RemoteObject/MethodGenerator/Constructor.php b/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/RemoteObject/MethodGenerator/Constructor.php deleted file mode 100644 index d1fcb89..0000000 --- a/vendor/ocramius/proxy-manager/src/ProxyManager/ProxyGenerator/RemoteObject/MethodGenerator/Constructor.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @license MIT - */ -class Constructor extends MethodGenerator -{ - /** - * Constructor - * - * @param ReflectionClass $originalClass Reflection of the class to proxy - * @param PropertyGenerator $adapter Adapter property - */ - public function __construct(ReflectionClass $originalClass, PropertyGenerator $adapter) - { - parent::__construct('__construct'); - - $adapterName = $adapter->getName(); - - $this->setParameter(new ParameterGenerator($adapterName, 'ProxyManager\Factory\RemoteObject\AdapterInterface')); - - $this->setDocblock( - '@override constructor for remote object control\n\n' - . '@param \\ProxyManager\\Factory\\RemoteObject\\AdapterInterface \$adapter' - ); - - $body = '$this->' . $adapterName . ' = $' . $adapterName . ';'; - - foreach ($originalClass->getProperties() as $property) { - if ($property->isPublic() && ! $property->isStatic()) { - $body .= "\nunset(\$this->" . $property->getName() . ');'; - } - } - - $this->setBody($body); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Autoloader/AutoloaderTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Autoloader/AutoloaderTest.php deleted file mode 100644 index aba8cf0..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Autoloader/AutoloaderTest.php +++ /dev/null @@ -1,133 +0,0 @@ - - * @license MIT - * - * @covers \ProxyManager\Autoloader\Autoloader - * @group Coverage - */ -class AutoloaderTest extends PHPUnit_Framework_TestCase -{ - /** - * @var \ProxyManager\Autoloader\Autoloader - */ - protected $autoloader; - - /** - * @var \ProxyManager\FileLocator\FileLocatorInterface|\PHPUnit_Framework_MockObject_MockObject - */ - protected $fileLocator; - - /** - * @var \ProxyManager\Inflector\ClassNameInflectorInterface|\PHPUnit_Framework_MockObject_MockObject - */ - protected $classNameInflector; - - /** - * @covers \ProxyManager\Autoloader\Autoloader::__construct - */ - public function setUp() - { - $this->fileLocator = $this->getMock('ProxyManager\\FileLocator\\FileLocatorInterface'); - $this->classNameInflector = $this->getMock('ProxyManager\\Inflector\\ClassNameInflectorInterface'); - $this->autoloader = new Autoloader($this->fileLocator, $this->classNameInflector); - } - - /** - * @covers \ProxyManager\Autoloader\Autoloader::__invoke - */ - public function testWillNotAutoloadUserClasses() - { - $className = 'Foo\\' . UniqueIdentifierGenerator::getIdentifier('Bar'); - $this - ->classNameInflector - ->expects($this->once()) - ->method('isProxyClassName') - ->with($className) - ->will($this->returnValue(false)); - - $this->assertFalse($this->autoloader->__invoke($className)); - } - - /** - * @covers \ProxyManager\Autoloader\Autoloader::__invoke - */ - public function testWillNotAutoloadNonExistingClass() - { - $className = 'Foo\\' . UniqueIdentifierGenerator::getIdentifier('Bar'); - $this - ->classNameInflector - ->expects($this->once()) - ->method('isProxyClassName') - ->with($className) - ->will($this->returnValue(true)); - $this - ->fileLocator - ->expects($this->once()) - ->method('getProxyFileName') - ->will($this->returnValue(__DIR__ . '/non-existing')); - - $this->assertFalse($this->autoloader->__invoke($className)); - } - - /** - * @covers \ProxyManager\Autoloader\Autoloader::__invoke - */ - public function testWillNotAutoloadExistingClass() - { - $this->assertFalse($this->autoloader->__invoke(__CLASS__)); - } - - /** - * @covers \ProxyManager\Autoloader\Autoloader::__invoke - */ - public function testWillAutoloadExistingFile() - { - $namespace = 'Foo'; - $className = UniqueIdentifierGenerator::getIdentifier('Bar'); - $fqcn = $namespace . '\\' . $className; - $fileName = sys_get_temp_dir() . '/foo_' . uniqid() . '.php'; - - file_put_contents($fileName, 'classNameInflector - ->expects($this->once()) - ->method('isProxyClassName') - ->with($fqcn) - ->will($this->returnValue(true)); - $this - ->fileLocator - ->expects($this->once()) - ->method('getProxyFileName') - ->will($this->returnValue($fileName)); - - $this->assertTrue($this->autoloader->__invoke($fqcn)); - $this->assertTrue(class_exists($fqcn, false)); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ConfigurationTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ConfigurationTest.php deleted file mode 100644 index 17ea451..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ConfigurationTest.php +++ /dev/null @@ -1,183 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class ConfigurationTest extends PHPUnit_Framework_TestCase -{ - /** - * @var \ProxyManager\Configuration - */ - protected $configuration; - - /** - * {@inheritDoc} - */ - public function setUp() - { - $this->configuration = new Configuration(); - } - - /** - * @covers \ProxyManager\Configuration::getProxiesNamespace - * @covers \ProxyManager\Configuration::setProxiesNamespace - */ - public function testGetSetProxiesNamespace() - { - $this->assertSame( - 'ProxyManagerGeneratedProxy', - $this->configuration->getProxiesNamespace(), - 'Default setting check for BC' - ); - - $this->configuration->setProxiesNamespace('foo'); - $this->assertSame('foo', $this->configuration->getProxiesNamespace()); - } - - /** - * @covers \ProxyManager\Configuration::getClassNameInflector - * @covers \ProxyManager\Configuration::setClassNameInflector - */ - public function testSetGetClassNameInflector() - { - $this->assertInstanceOf( - 'ProxyManager\\Inflector\\ClassNameInflectorInterface', - $this->configuration->getClassNameInflector() - ); - - /* @var $inflector \ProxyManager\Inflector\ClassNameInflectorInterface */ - $inflector = $this->getMock('ProxyManager\\Inflector\\ClassNameInflectorInterface'); - - $this->configuration->setClassNameInflector($inflector); - $this->assertSame($inflector, $this->configuration->getClassNameInflector()); - } - - /** - * @covers \ProxyManager\Configuration::getGeneratorStrategy - * @covers \ProxyManager\Configuration::setGeneratorStrategy - */ - public function testSetGetGeneratorStrategy() - { - - $this->assertInstanceOf( - 'ProxyManager\\GeneratorStrategy\\GeneratorStrategyInterface', - $this->configuration->getGeneratorStrategy() - ); - - /* @var $strategy \ProxyManager\GeneratorStrategy\GeneratorStrategyInterface */ - $strategy = $this->getMock('ProxyManager\\GeneratorStrategy\\GeneratorStrategyInterface'); - - $this->configuration->setGeneratorStrategy($strategy); - $this->assertSame($strategy, $this->configuration->getGeneratorStrategy()); - } - - /** - * @covers \ProxyManager\Configuration::getProxiesTargetDir - * @covers \ProxyManager\Configuration::setProxiesTargetDir - */ - public function testSetGetProxiesTargetDir() - { - $this->assertTrue(is_dir($this->configuration->getProxiesTargetDir())); - - $this->configuration->setProxiesTargetDir(__DIR__); - $this->assertSame(__DIR__, $this->configuration->getProxiesTargetDir()); - } - - /** - * @covers \ProxyManager\Configuration::getProxyAutoloader - * @covers \ProxyManager\Configuration::setProxyAutoloader - */ - public function testSetGetProxyAutoloader() - { - $this->assertInstanceOf( - 'ProxyManager\\Autoloader\\AutoloaderInterface', - $this->configuration->getProxyAutoloader() - ); - - /* @var $autoloader \ProxyManager\Autoloader\AutoloaderInterface */ - $autoloader = $this->getMock('ProxyManager\\Autoloader\\AutoloaderInterface'); - - $this->configuration->setProxyAutoloader($autoloader); - $this->assertSame($autoloader, $this->configuration->getProxyAutoloader()); - } - - /** - * @covers \ProxyManager\Configuration::getSignatureGenerator - * @covers \ProxyManager\Configuration::setSignatureGenerator - */ - public function testSetGetSignatureGenerator() - { - $this->assertInstanceOf( - 'ProxyManager\\Signature\\SignatureGeneratorInterface', - $this->configuration->getSignatureGenerator() - ); - - /* @var $signatureGenerator \ProxyManager\Signature\SignatureGeneratorInterface */ - $signatureGenerator = $this->getMock('ProxyManager\\Signature\\SignatureGeneratorInterface'); - - $this->configuration->setSignatureGenerator($signatureGenerator); - $this->assertSame($signatureGenerator, $this->configuration->getSignatureGenerator()); - } - - /** - * @covers \ProxyManager\Configuration::getSignatureChecker - * @covers \ProxyManager\Configuration::setSignatureChecker - */ - public function testSetGetSignatureChecker() - { - $this->assertInstanceOf( - 'ProxyManager\\Signature\\SignatureCheckerInterface', - $this->configuration->getSignatureChecker() - ); - - /* @var $signatureChecker \ProxyManager\Signature\SignatureCheckerInterface */ - $signatureChecker = $this->getMock('ProxyManager\\Signature\\SignatureCheckerInterface'); - - $this->configuration->setSignatureChecker($signatureChecker); - $this->assertSame($signatureChecker, $this->configuration->getSignatureChecker()); - } - - /** - * @covers \ProxyManager\Configuration::getClassSignatureGenerator - * @covers \ProxyManager\Configuration::setClassSignatureGenerator - */ - public function testSetGetClassSignatureGenerator() - { - $this->assertInstanceOf( - 'ProxyManager\\Signature\\ClassSignatureGeneratorInterface', - $this->configuration->getClassSignatureGenerator() - ); - - /* @var $classSignatureGenerator \ProxyManager\Signature\ClassSignatureGeneratorInterface */ - $classSignatureGenerator = $this->getMock('ProxyManager\\Signature\\ClassSignatureGeneratorInterface'); - - $this->configuration->setClassSignatureGenerator($classSignatureGenerator); - $this->assertSame($classSignatureGenerator, $this->configuration->getClassSignatureGenerator()); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Exception/DisabledMethodExceptionTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Exception/DisabledMethodExceptionTest.php deleted file mode 100644 index 5dc574e..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Exception/DisabledMethodExceptionTest.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @license MIT - * - * @covers \ProxyManager\Exception\DisabledMethodException - * @group Coverage - */ -class DisabledMethodExceptionTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\Exception\DisabledMethodException::disabledMethod - */ - public function testProxyDirectoryNotFound() - { - $exception = DisabledMethodException::disabledMethod('foo::bar'); - - $this->assertSame('Method "foo::bar" is forcefully disabled', $exception->getMessage()); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Exception/FileNotWritableExceptionTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Exception/FileNotWritableExceptionTest.php deleted file mode 100644 index 915b8f1..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Exception/FileNotWritableExceptionTest.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @license MIT - * - * @covers \ProxyManager\Exception\FileNotWritableException - * @group Coverage - */ -class FileNotWritableExceptionTest extends PHPUnit_Framework_TestCase -{ - public function testFromInvalidMoveOperation() - { - $exception = FileNotWritableException::fromInvalidMoveOperation('/tmp/a', '/tmp/b'); - - $this->assertInstanceOf('ProxyManager\\Exception\\FileNotWritableException', $exception); - $this->assertSame( - 'Could not move file "/tmp/a" to location "/tmp/b": either the source file is not readable,' - . ' or the destination is not writable', - $exception->getMessage() - ); - } - - public function testFromNotWritableLocationWithNonFilePath() - { - $exception = FileNotWritableException::fromNonWritableLocation(__DIR__); - - $this->assertInstanceOf('ProxyManager\\Exception\\FileNotWritableException', $exception); - $this->assertSame( - 'Could not write to path "' . __DIR__ . '": exists and is not a file', - $exception->getMessage() - ); - } - - public function testFromNotWritableLocationWithNonWritablePath() - { - $path = sys_get_temp_dir() . '/' . uniqid('FileNotWritableExceptionTestNonWritable', true); - - mkdir($path, 0555); - - $exception = FileNotWritableException::fromNonWritableLocation($path . '/foo'); - - $this->assertInstanceOf('ProxyManager\\Exception\\FileNotWritableException', $exception); - $this->assertSame( - 'Could not write to path "' . $path . '/foo": is not writable', - $exception->getMessage() - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Exception/InvalidProxiedClassExceptionTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Exception/InvalidProxiedClassExceptionTest.php deleted file mode 100644 index 0656dad..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Exception/InvalidProxiedClassExceptionTest.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @license MIT - * - * @covers \ProxyManager\Exception\InvalidProxiedClassException - * @group Coverage - */ -class InvalidProxiedClassExceptionTest extends PHPUnit_Framework_TestCase -{ - public function testInterfaceNotSupported() - { - $this->assertSame( - 'Provided interface "ProxyManagerTestAsset\BaseInterface" cannot be proxied', - InvalidProxiedClassException::interfaceNotSupported( - new ReflectionClass('ProxyManagerTestAsset\BaseInterface') - )->getMessage() - ); - } - - public function testFinalClassNotSupported() - { - $this->assertSame( - 'Provided class "ProxyManagerTestAsset\FinalClass" is final and cannot be proxied', - InvalidProxiedClassException::finalClassNotSupported( - new ReflectionClass('ProxyManagerTestAsset\FinalClass') - )->getMessage() - ); - } - - public function testAbstractProtectedMethodsNotSupported() - { - $this->assertSame( - 'Provided class "ProxyManagerTestAsset\ClassWithAbstractProtectedMethod" has following protected abstract' - . ' methods, and therefore cannot be proxied:' . "\n" - . 'ProxyManagerTestAsset\ClassWithAbstractProtectedMethod::protectedAbstractMethod', - InvalidProxiedClassException::abstractProtectedMethodsNotSupported( - new ReflectionClass('ProxyManagerTestAsset\ClassWithAbstractProtectedMethod') - )->getMessage() - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Exception/InvalidProxyDirectoryExceptionTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Exception/InvalidProxyDirectoryExceptionTest.php deleted file mode 100644 index 71edab1..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Exception/InvalidProxyDirectoryExceptionTest.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @license MIT - * - * @covers \ProxyManager\Exception\InvalidProxyDirectoryException - * @group Coverage - */ -class InvalidProxyDirectoryExceptionTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\Exception\InvalidProxyDirectoryException::proxyDirectoryNotFound - */ - public function testProxyDirectoryNotFound() - { - $exception = InvalidProxyDirectoryException::proxyDirectoryNotFound('foo/bar'); - - $this->assertSame('Provided directory "foo/bar" does not exist', $exception->getMessage()); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Exception/UnsupportedProxiedClassExceptionTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Exception/UnsupportedProxiedClassExceptionTest.php deleted file mode 100644 index 68977c8..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Exception/UnsupportedProxiedClassExceptionTest.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @license MIT - * - * @covers \ProxyManager\Exception\UnsupportedProxiedClassException - * @group Coverage - */ -class UnsupportedProxiedClassExceptionTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\Exception\UnsupportedProxiedClassException::unsupportedLocalizedReflectionProperty - */ - public function testUnsupportedLocalizedReflectionProperty() - { - $this->assertSame( - 'Provided reflection property "property0" of class "ProxyManagerTestAsset\ClassWithPrivateProperties" ' - . 'is private and cannot be localized in PHP 5.3', - UnsupportedProxiedClassException::unsupportedLocalizedReflectionProperty( - new ReflectionProperty('ProxyManagerTestAsset\ClassWithPrivateProperties', 'property0') - )->getMessage() - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/AbstractBaseFactoryTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/AbstractBaseFactoryTest.php deleted file mode 100644 index 2c1b759..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/AbstractBaseFactoryTest.php +++ /dev/null @@ -1,158 +0,0 @@ - - * @license MIT - * - * @covers \ProxyManager\Factory\AbstractBaseFactory - * @group Coverage - */ -class AbstractBaseFactoryTest extends PHPUnit_Framework_TestCase -{ - /** - * @var \ProxyManager\Factory\AbstractBaseFactory - */ - private $factory; - - /** - * @var \ProxyManager\ProxyGenerator\ProxyGeneratorInterface|\PHPUnit_Framework_MockObject_MockObject - */ - private $generator; - - /** - * @var \ProxyManager\Inflector\ClassNameInflectorInterface|\PHPUnit_Framework_MockObject_MockObject - */ - private $classNameInflector; - - /** - * @var \ProxyManager\GeneratorStrategy\GeneratorStrategyInterface|\PHPUnit_Framework_MockObject_MockObject - */ - private $generatorStrategy; - - /** - * @var \ProxyManager\Autoloader\AutoloaderInterface|\PHPUnit_Framework_MockObject_MockObject - */ - private $proxyAutoloader; - - /** - * @var \ProxyManager\Signature\SignatureCheckerInterface|\PHPUnit_Framework_MockObject_MockObject - */ - private $signatureChecker; - - /** - * @var \ProxyManager\Signature\ClassSignatureGeneratorInterface|\PHPUnit_Framework_MockObject_MockObject - */ - private $classSignatureGenerator; - - /** - * {@inheritDoc} - */ - public function setUp() - { - $configuration = $this->getMock('ProxyManager\\Configuration'); - $this->generator = $this->getMock('ProxyManager\\ProxyGenerator\\ProxyGeneratorInterface'); - $this->classNameInflector = $this->getMock('ProxyManager\\Inflector\\ClassNameInflectorInterface'); - $this->generatorStrategy = $this->getMock('ProxyManager\\GeneratorStrategy\\GeneratorStrategyInterface'); - $this->proxyAutoloader = $this->getMock('ProxyManager\\Autoloader\\AutoloaderInterface'); - $this->signatureChecker = $this->getMock('ProxyManager\\Signature\\SignatureCheckerInterface'); - $this->classSignatureGenerator = $this->getMock('ProxyManager\\Signature\\ClassSignatureGeneratorInterface'); - - $configuration - ->expects($this->any()) - ->method('getClassNameInflector') - ->will($this->returnValue($this->classNameInflector)); - - $configuration - ->expects($this->any()) - ->method('getGeneratorStrategy') - ->will($this->returnValue($this->generatorStrategy)); - - $configuration - ->expects($this->any()) - ->method('getProxyAutoloader') - ->will($this->returnValue($this->proxyAutoloader)); - - $configuration - ->expects($this->any()) - ->method('getSignatureChecker') - ->will($this->returnValue($this->signatureChecker)); - - $configuration - ->expects($this->any()) - ->method('getClassSignatureGenerator') - ->will($this->returnValue($this->classSignatureGenerator)); - - $this - ->classNameInflector - ->expects($this->any()) - ->method('getUserClassName') - ->will($this->returnValue('stdClass')); - - $this->factory = $this->getMockForAbstractClass( - 'ProxyManager\\Factory\\AbstractBaseFactory', - array($configuration) - ); - - $this->factory->expects($this->any())->method('getGenerator')->will($this->returnValue($this->generator)); - } - - public function testGeneratesClass() - { - $generateProxy = new ReflectionMethod($this->factory, 'generateProxy'); - - $generateProxy->setAccessible(true); - $generatedClass = UniqueIdentifierGenerator::getIdentifier('fooBar'); - - $this - ->classNameInflector - ->expects($this->any()) - ->method('getProxyClassName') - ->with('stdClass') - ->will($this->returnValue($generatedClass)); - - $this - ->generatorStrategy - ->expects($this->once()) - ->method('generate') - ->with($this->isInstanceOf('Zend\\Code\\Generator\\ClassGenerator')); - $this - ->proxyAutoloader - ->expects($this->once()) - ->method('__invoke') - ->with($generatedClass) - ->will($this->returnCallback(function ($className) { - eval('class ' . $className . ' {}'); - })); - - $this->signatureChecker->expects($this->atLeastOnce())->method('checkSignature'); - $this->classSignatureGenerator->expects($this->once())->method('addSignature')->will($this->returnArgument(0)); - - $this->assertSame($generatedClass, $generateProxy->invoke($this->factory, 'stdClass')); - $this->assertTrue(class_exists($generatedClass, false)); - $this->assertSame($generatedClass, $generateProxy->invoke($this->factory, 'stdClass')); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/AccessInterceptorScopeLocalizerFactoryTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/AccessInterceptorScopeLocalizerFactoryTest.php deleted file mode 100644 index ce10d0c..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/AccessInterceptorScopeLocalizerFactoryTest.php +++ /dev/null @@ -1,199 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class AccessInterceptorScopeLocalizerFactoryTest extends PHPUnit_Framework_TestCase -{ - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $inflector; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $signatureChecker; - - /** - * @var \ProxyManager\Signature\ClassSignatureGeneratorInterface|\PHPUnit_Framework_MockObject_MockObject - */ - private $classSignatureGenerator; - - /** - * @var \ProxyManager\Configuration|\PHPUnit_Framework_MockObject_MockObject - */ - protected $config; - - /** - * {@inheritDoc} - */ - public function setUp() - { - $this->config = $this->getMock('ProxyManager\\Configuration'); - $this->inflector = $this->getMock('ProxyManager\\Inflector\\ClassNameInflectorInterface'); - $this->signatureChecker = $this->getMock('ProxyManager\\Signature\\SignatureCheckerInterface'); - $this->classSignatureGenerator = $this->getMock('ProxyManager\\Signature\\ClassSignatureGeneratorInterface'); - - $this - ->config - ->expects($this->any()) - ->method('getClassNameInflector') - ->will($this->returnValue($this->inflector)); - - $this - ->config - ->expects($this->any()) - ->method('getSignatureChecker') - ->will($this->returnValue($this->signatureChecker)); - - $this - ->config - ->expects($this->any()) - ->method('getClassSignatureGenerator') - ->will($this->returnValue($this->classSignatureGenerator)); - } - - /** - * {@inheritDoc} - * - * @covers \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory::__construct - */ - public function testWithOptionalFactory() - { - $factory = new AccessInterceptorValueHolderFactory(); - $this->assertAttributeNotEmpty('configuration', $factory); - $this->assertAttributeInstanceOf('ProxyManager\Configuration', 'configuration', $factory); - } - - /** - * {@inheritDoc} - * - * @covers \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory::__construct - * @covers \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory::createProxy - * @covers \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory::getGenerator - */ - public function testWillSkipAutoGeneration() - { - $instance = new stdClass(); - - $this - ->inflector - ->expects($this->once()) - ->method('getProxyClassName') - ->with('stdClass') - ->will($this->returnValue('ProxyManagerTestAsset\\AccessInterceptorValueHolderMock')); - - $factory = new AccessInterceptorScopeLocalizerFactory($this->config); - /* @var $proxy \ProxyManagerTestAsset\AccessInterceptorValueHolderMock */ - $proxy = $factory->createProxy($instance, array('foo'), array('bar')); - - $this->assertInstanceOf('ProxyManagerTestAsset\\AccessInterceptorValueHolderMock', $proxy); - $this->assertSame($instance, $proxy->instance); - $this->assertSame(array('foo'), $proxy->prefixInterceptors); - $this->assertSame(array('bar'), $proxy->suffixInterceptors); - } - - /** - * {@inheritDoc} - * - * @covers \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory::__construct - * @covers \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory::createProxy - * @covers \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory::getGenerator - * - * NOTE: serious mocking going on in here (a class is generated on-the-fly) - careful - */ - public function testWillTryAutoGeneration() - { - $instance = new stdClass(); - $proxyClassName = UniqueIdentifierGenerator::getIdentifier('bar'); - $generator = $this->getMock('ProxyManager\GeneratorStrategy\\GeneratorStrategyInterface'); - $autoloader = $this->getMock('ProxyManager\\Autoloader\\AutoloaderInterface'); - - $this->config->expects($this->any())->method('getGeneratorStrategy')->will($this->returnValue($generator)); - $this->config->expects($this->any())->method('getProxyAutoloader')->will($this->returnValue($autoloader)); - - $generator - ->expects($this->once()) - ->method('generate') - ->with( - $this->callback( - function (ClassGenerator $targetClass) use ($proxyClassName) { - return $targetClass->getName() === $proxyClassName; - } - ) - ); - - // simulate autoloading - $autoloader - ->expects($this->once()) - ->method('__invoke') - ->with($proxyClassName) - ->will( - $this->returnCallback( - function () use ($proxyClassName) { - eval( - 'class ' . $proxyClassName - . ' extends \\ProxyManagerTestAsset\\AccessInterceptorValueHolderMock {}' - ); - } - ) - ); - - $this - ->inflector - ->expects($this->once()) - ->method('getProxyClassName') - ->with('stdClass') - ->will($this->returnValue($proxyClassName)); - - $this - ->inflector - ->expects($this->once()) - ->method('getUserClassName') - ->with('stdClass') - ->will($this->returnValue('ProxyManagerTestAsset\\LazyLoadingMock')); - - $this->signatureChecker->expects($this->atLeastOnce())->method('checkSignature'); - $this->classSignatureGenerator->expects($this->once())->method('addSignature')->will($this->returnArgument(0)); - - $factory = new AccessInterceptorScopeLocalizerFactory($this->config); - /* @var $proxy \ProxyManagerTestAsset\AccessInterceptorValueHolderMock */ - $proxy = $factory->createProxy($instance, array('foo'), array('bar')); - - $this->assertInstanceOf($proxyClassName, $proxy); - $this->assertSame($instance, $proxy->instance); - $this->assertSame(array('foo'), $proxy->prefixInterceptors); - $this->assertSame(array('bar'), $proxy->suffixInterceptors); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/AccessInterceptorValueHolderFactoryTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/AccessInterceptorValueHolderFactoryTest.php deleted file mode 100644 index a9a881c..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/AccessInterceptorValueHolderFactoryTest.php +++ /dev/null @@ -1,198 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class AccessInterceptorValueHolderFactoryTest extends PHPUnit_Framework_TestCase -{ - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $inflector; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $signatureChecker; - - /** - * @var \ProxyManager\Signature\ClassSignatureGeneratorInterface|\PHPUnit_Framework_MockObject_MockObject - */ - private $classSignatureGenerator; - - /** - * @var \ProxyManager\Configuration|\PHPUnit_Framework_MockObject_MockObject - */ - protected $config; - - /** - * {@inheritDoc} - */ - public function setUp() - { - $this->config = $this->getMock('ProxyManager\\Configuration'); - $this->inflector = $this->getMock('ProxyManager\\Inflector\\ClassNameInflectorInterface'); - $this->signatureChecker = $this->getMock('ProxyManager\\Signature\\SignatureCheckerInterface'); - $this->classSignatureGenerator = $this->getMock('ProxyManager\\Signature\\ClassSignatureGeneratorInterface'); - - $this - ->config - ->expects($this->any()) - ->method('getClassNameInflector') - ->will($this->returnValue($this->inflector)); - - $this - ->config - ->expects($this->any()) - ->method('getSignatureChecker') - ->will($this->returnValue($this->signatureChecker)); - - $this - ->config - ->expects($this->any()) - ->method('getClassSignatureGenerator') - ->will($this->returnValue($this->classSignatureGenerator)); - } - - /** - * {@inheritDoc} - * - * @covers \ProxyManager\Factory\AccessInterceptorValueHolderFactory::__construct - */ - public function testWithOptionalFactory() - { - $factory = new AccessInterceptorValueHolderFactory(); - $this->assertAttributeNotEmpty('configuration', $factory); - $this->assertAttributeInstanceOf('ProxyManager\Configuration', 'configuration', $factory); - } - - /** - * {@inheritDoc} - * - * @covers \ProxyManager\Factory\AccessInterceptorValueHolderFactory::__construct - * @covers \ProxyManager\Factory\AccessInterceptorValueHolderFactory::createProxy - * @covers \ProxyManager\Factory\AccessInterceptorValueHolderFactory::getGenerator - */ - public function testWillSkipAutoGeneration() - { - $instance = new stdClass(); - - $this - ->inflector - ->expects($this->once()) - ->method('getProxyClassName') - ->with('stdClass') - ->will($this->returnValue('ProxyManagerTestAsset\\AccessInterceptorValueHolderMock')); - - $factory = new AccessInterceptorValueHolderFactory($this->config); - /* @var $proxy \ProxyManagerTestAsset\AccessInterceptorValueHolderMock */ - $proxy = $factory->createProxy($instance, array('foo'), array('bar')); - - $this->assertInstanceOf('ProxyManagerTestAsset\\AccessInterceptorValueHolderMock', $proxy); - $this->assertSame($instance, $proxy->instance); - $this->assertSame(array('foo'), $proxy->prefixInterceptors); - $this->assertSame(array('bar'), $proxy->suffixInterceptors); - } - - /** - * {@inheritDoc} - * - * @covers \ProxyManager\Factory\AccessInterceptorValueHolderFactory::__construct - * @covers \ProxyManager\Factory\AccessInterceptorValueHolderFactory::createProxy - * @covers \ProxyManager\Factory\AccessInterceptorValueHolderFactory::getGenerator - * - * NOTE: serious mocking going on in here (a class is generated on-the-fly) - careful - */ - public function testWillTryAutoGeneration() - { - $instance = new stdClass(); - $proxyClassName = UniqueIdentifierGenerator::getIdentifier('bar'); - $generator = $this->getMock('ProxyManager\GeneratorStrategy\\GeneratorStrategyInterface'); - $autoloader = $this->getMock('ProxyManager\\Autoloader\\AutoloaderInterface'); - - $this->config->expects($this->any())->method('getGeneratorStrategy')->will($this->returnValue($generator)); - $this->config->expects($this->any())->method('getProxyAutoloader')->will($this->returnValue($autoloader)); - - $generator - ->expects($this->once()) - ->method('generate') - ->with( - $this->callback( - function (ClassGenerator $targetClass) use ($proxyClassName) { - return $targetClass->getName() === $proxyClassName; - } - ) - ); - - // simulate autoloading - $autoloader - ->expects($this->once()) - ->method('__invoke') - ->with($proxyClassName) - ->will( - $this->returnCallback( - function () use ($proxyClassName) { - eval( - 'class ' . $proxyClassName - . ' extends \\ProxyManagerTestAsset\\AccessInterceptorValueHolderMock {}' - ); - } - ) - ); - - $this - ->inflector - ->expects($this->once()) - ->method('getProxyClassName') - ->with('stdClass') - ->will($this->returnValue($proxyClassName)); - - $this - ->inflector - ->expects($this->once()) - ->method('getUserClassName') - ->with('stdClass') - ->will($this->returnValue('ProxyManagerTestAsset\\LazyLoadingMock')); - - $this->signatureChecker->expects($this->atLeastOnce())->method('checkSignature'); - $this->classSignatureGenerator->expects($this->once())->method('addSignature')->will($this->returnArgument(0)); - - $factory = new AccessInterceptorValueHolderFactory($this->config); - /* @var $proxy \ProxyManagerTestAsset\AccessInterceptorValueHolderMock */ - $proxy = $factory->createProxy($instance, array('foo'), array('bar')); - - $this->assertInstanceOf($proxyClassName, $proxy); - $this->assertSame($instance, $proxy->instance); - $this->assertSame(array('foo'), $proxy->prefixInterceptors); - $this->assertSame(array('bar'), $proxy->suffixInterceptors); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/LazyLoadingGhostFactoryTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/LazyLoadingGhostFactoryTest.php deleted file mode 100644 index 2089f58..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/LazyLoadingGhostFactoryTest.php +++ /dev/null @@ -1,193 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class LazyLoadingGhostFactoryTest extends PHPUnit_Framework_TestCase -{ - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $inflector; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $signatureChecker; - - /** - * @var \ProxyManager\Signature\ClassSignatureGeneratorInterface|\PHPUnit_Framework_MockObject_MockObject - */ - private $classSignatureGenerator; - - /** - * @var \ProxyManager\Configuration|\PHPUnit_Framework_MockObject_MockObject - */ - protected $config; - - /** - * {@inheritDoc} - */ - public function setUp() - { - $this->config = $this->getMock('ProxyManager\\Configuration'); - $this->inflector = $this->getMock('ProxyManager\\Inflector\\ClassNameInflectorInterface'); - $this->signatureChecker = $this->getMock('ProxyManager\\Signature\\SignatureCheckerInterface'); - $this->classSignatureGenerator = $this->getMock('ProxyManager\\Signature\\ClassSignatureGeneratorInterface'); - - $this - ->config - ->expects($this->any()) - ->method('getClassNameInflector') - ->will($this->returnValue($this->inflector)); - - $this - ->config - ->expects($this->any()) - ->method('getSignatureChecker') - ->will($this->returnValue($this->signatureChecker)); - - $this - ->config - ->expects($this->any()) - ->method('getClassSignatureGenerator') - ->will($this->returnValue($this->classSignatureGenerator)); - } - - /** - * {@inheritDoc} - * - * @covers \ProxyManager\Factory\LazyLoadingGhostFactory::__construct - */ - public function testWithOptionalFactory() - { - $factory = new LazyLoadingGhostFactory(); - $this->assertAttributeNotEmpty('configuration', $factory); - $this->assertAttributeInstanceOf('ProxyManager\Configuration', 'configuration', $factory); - } - - /** - * {@inheritDoc} - * - * @covers \ProxyManager\Factory\LazyLoadingGhostFactory::__construct - * @covers \ProxyManager\Factory\LazyLoadingGhostFactory::createProxy - */ - public function testWillSkipAutoGeneration() - { - $className = UniqueIdentifierGenerator::getIdentifier('foo'); - - $this - ->inflector - ->expects($this->once()) - ->method('getProxyClassName') - ->with($className) - ->will($this->returnValue('ProxyManagerTestAsset\\LazyLoadingMock')); - - $factory = new LazyLoadingGhostFactory($this->config); - $initializer = function () { - }; - /* @var $proxy \ProxyManagerTestAsset\LazyLoadingMock */ - $proxy = $factory->createProxy($className, $initializer); - - $this->assertInstanceOf('ProxyManagerTestAsset\\LazyLoadingMock', $proxy); - $this->assertSame($initializer, $proxy->initializer); - } - - /** - * {@inheritDoc} - * - * @covers \ProxyManager\Factory\LazyLoadingGhostFactory::__construct - * @covers \ProxyManager\Factory\LazyLoadingGhostFactory::createProxy - * @covers \ProxyManager\Factory\LazyLoadingGhostFactory::getGenerator - * - * NOTE: serious mocking going on in here (a class is generated on-the-fly) - careful - */ - public function testWillTryAutoGeneration() - { - $className = UniqueIdentifierGenerator::getIdentifier('foo'); - $proxyClassName = UniqueIdentifierGenerator::getIdentifier('bar'); - $generator = $this->getMock('ProxyManager\\GeneratorStrategy\\GeneratorStrategyInterface'); - $autoloader = $this->getMock('ProxyManager\\Autoloader\\AutoloaderInterface'); - - $this->config->expects($this->any())->method('getGeneratorStrategy')->will($this->returnValue($generator)); - $this->config->expects($this->any())->method('getProxyAutoloader')->will($this->returnValue($autoloader)); - - $generator - ->expects($this->once()) - ->method('generate') - ->with( - $this->callback( - function (ClassGenerator $targetClass) use ($proxyClassName) { - return $targetClass->getName() === $proxyClassName; - } - ) - ); - - // simulate autoloading - $autoloader - ->expects($this->once()) - ->method('__invoke') - ->with($proxyClassName) - ->will( - $this->returnCallback( - function () use ($proxyClassName) { - eval('class ' . $proxyClassName . ' extends \\ProxyManagerTestAsset\\LazyLoadingMock {}'); - } - ) - ); - - $this - ->inflector - ->expects($this->once()) - ->method('getProxyClassName') - ->with($className) - ->will($this->returnValue($proxyClassName)); - - $this - ->inflector - ->expects($this->once()) - ->method('getUserClassName') - ->with($className) - ->will($this->returnValue('ProxyManagerTestAsset\\LazyLoadingMock')); - - $this->signatureChecker->expects($this->atLeastOnce())->method('checkSignature'); - $this->classSignatureGenerator->expects($this->once())->method('addSignature')->will($this->returnArgument(0)); - - $factory = new LazyLoadingGhostFactory($this->config); - $initializer = function () { - }; - /* @var $proxy \ProxyManagerTestAsset\LazyLoadingMock */ - $proxy = $factory->createProxy($className, $initializer); - - $this->assertInstanceOf($proxyClassName, $proxy); - $this->assertSame($initializer, $proxy->initializer); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/LazyLoadingValueHolderFactoryTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/LazyLoadingValueHolderFactoryTest.php deleted file mode 100644 index 31c0f3b..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/LazyLoadingValueHolderFactoryTest.php +++ /dev/null @@ -1,193 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class LazyLoadingValueHolderFactoryTest extends PHPUnit_Framework_TestCase -{ - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $inflector; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $signatureChecker; - - /** - * @var \ProxyManager\Signature\ClassSignatureGeneratorInterface|\PHPUnit_Framework_MockObject_MockObject - */ - private $classSignatureGenerator; - - /** - * @var \ProxyManager\Configuration|\PHPUnit_Framework_MockObject_MockObject - */ - protected $config; - - /** - * {@inheritDoc} - */ - public function setUp() - { - $this->config = $this->getMock('ProxyManager\\Configuration'); - $this->inflector = $this->getMock('ProxyManager\\Inflector\\ClassNameInflectorInterface'); - $this->signatureChecker = $this->getMock('ProxyManager\\Signature\\SignatureCheckerInterface'); - $this->classSignatureGenerator = $this->getMock('ProxyManager\\Signature\\ClassSignatureGeneratorInterface'); - - $this - ->config - ->expects($this->any()) - ->method('getClassNameInflector') - ->will($this->returnValue($this->inflector)); - - $this - ->config - ->expects($this->any()) - ->method('getSignatureChecker') - ->will($this->returnValue($this->signatureChecker)); - - $this - ->config - ->expects($this->any()) - ->method('getClassSignatureGenerator') - ->will($this->returnValue($this->classSignatureGenerator)); - } - - /** - * {@inheritDoc} - * - * @covers \ProxyManager\Factory\LazyLoadingValueHolderFactory::__construct - */ - public function testWithOptionalFactory() - { - $factory = new LazyLoadingValueHolderFactory(); - $this->assertAttributeNotEmpty('configuration', $factory); - $this->assertAttributeInstanceOf('ProxyManager\Configuration', 'configuration', $factory); - } - - /** - * {@inheritDoc} - * - * @covers \ProxyManager\Factory\LazyLoadingValueHolderFactory::__construct - * @covers \ProxyManager\Factory\LazyLoadingValueHolderFactory::createProxy - */ - public function testWillSkipAutoGeneration() - { - $className = UniqueIdentifierGenerator::getIdentifier('foo'); - - $this - ->inflector - ->expects($this->once()) - ->method('getProxyClassName') - ->with($className) - ->will($this->returnValue('ProxyManagerTestAsset\\LazyLoadingMock')); - - $factory = new LazyLoadingValueHolderFactory($this->config); - $initializer = function () { - }; - /* @var $proxy \ProxyManagerTestAsset\LazyLoadingMock */ - $proxy = $factory->createProxy($className, $initializer); - - $this->assertInstanceOf('ProxyManagerTestAsset\\LazyLoadingMock', $proxy); - $this->assertSame($initializer, $proxy->initializer); - } - - /** - * {@inheritDoc} - * - * @covers \ProxyManager\Factory\LazyLoadingValueHolderFactory::__construct - * @covers \ProxyManager\Factory\LazyLoadingValueHolderFactory::createProxy - * @covers \ProxyManager\Factory\LazyLoadingValueHolderFactory::getGenerator - * - * NOTE: serious mocking going on in here (a class is generated on-the-fly) - careful - */ - public function testWillTryAutoGeneration() - { - $className = UniqueIdentifierGenerator::getIdentifier('foo'); - $proxyClassName = UniqueIdentifierGenerator::getIdentifier('bar'); - $generator = $this->getMock('ProxyManager\\GeneratorStrategy\\GeneratorStrategyInterface'); - $autoloader = $this->getMock('ProxyManager\\Autoloader\\AutoloaderInterface'); - - $this->config->expects($this->any())->method('getGeneratorStrategy')->will($this->returnValue($generator)); - $this->config->expects($this->any())->method('getProxyAutoloader')->will($this->returnValue($autoloader)); - - $generator - ->expects($this->once()) - ->method('generate') - ->with( - $this->callback( - function (ClassGenerator $targetClass) use ($proxyClassName) { - return $targetClass->getName() === $proxyClassName; - } - ) - ); - - // simulate autoloading - $autoloader - ->expects($this->once()) - ->method('__invoke') - ->with($proxyClassName) - ->will( - $this->returnCallback( - function () use ($proxyClassName) { - eval('class ' . $proxyClassName . ' extends \\ProxyManagerTestAsset\\LazyLoadingMock {}'); - } - ) - ); - - $this - ->inflector - ->expects($this->once()) - ->method('getProxyClassName') - ->with($className) - ->will($this->returnValue($proxyClassName)); - - $this - ->inflector - ->expects($this->once()) - ->method('getUserClassName') - ->with($className) - ->will($this->returnValue('ProxyManagerTestAsset\\LazyLoadingMock')); - - $this->signatureChecker->expects($this->atLeastOnce())->method('checkSignature'); - $this->classSignatureGenerator->expects($this->once())->method('addSignature')->will($this->returnArgument(0)); - - $factory = new LazyLoadingValueHolderFactory($this->config); - $initializer = function () { - }; - /* @var $proxy \ProxyManagerTestAsset\LazyLoadingMock */ - $proxy = $factory->createProxy($className, $initializer); - - $this->assertInstanceOf($proxyClassName, $proxy); - $this->assertSame($initializer, $proxy->initializer); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/NullObjectFactoryTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/NullObjectFactoryTest.php deleted file mode 100644 index ef3f2a7..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/NullObjectFactoryTest.php +++ /dev/null @@ -1,180 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class NullObjectFactoryTest extends PHPUnit_Framework_TestCase -{ - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $inflector; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $signatureChecker; - - /** - * @var \ProxyManager\Signature\ClassSignatureGeneratorInterface|\PHPUnit_Framework_MockObject_MockObject - */ - private $classSignatureGenerator; - - /** - * @var \ProxyManager\Configuration|\PHPUnit_Framework_MockObject_MockObject - */ - protected $config; - - /** - * {@inheritDoc} - */ - public function setUp() - { - $this->config = $this->getMock('ProxyManager\\Configuration'); - $this->inflector = $this->getMock('ProxyManager\\Inflector\\ClassNameInflectorInterface'); - $this->signatureChecker = $this->getMock('ProxyManager\\Signature\\SignatureCheckerInterface'); - $this->classSignatureGenerator = $this->getMock('ProxyManager\\Signature\\ClassSignatureGeneratorInterface'); - - $this - ->config - ->expects($this->any()) - ->method('getClassNameInflector') - ->will($this->returnValue($this->inflector)); - - $this - ->config - ->expects($this->any()) - ->method('getSignatureChecker') - ->will($this->returnValue($this->signatureChecker)); - - $this - ->config - ->expects($this->any()) - ->method('getClassSignatureGenerator') - ->will($this->returnValue($this->classSignatureGenerator)); - } - - /** - * {@inheritDoc} - * - * @covers \ProxyManager\Factory\NullObjectFactory::__construct - * @covers \ProxyManager\Factory\NullObjectFactory::createProxy - * @covers \ProxyManager\Factory\NullObjectFactory::getGenerator - */ - public function testWillSkipAutoGeneration() - { - $instance = new stdClass(); - - $this - ->inflector - ->expects($this->once()) - ->method('getProxyClassName') - ->with('stdClass') - ->will($this->returnValue('ProxyManagerTestAsset\\NullObjectMock')); - - $factory = new NullObjectFactory($this->config); - /* @var $proxy \ProxyManagerTestAsset\NullObjectMock */ - $proxy = $factory->createProxy($instance); - - $this->assertInstanceOf('ProxyManagerTestAsset\\NullObjectMock', $proxy); - } - - /** - * {@inheritDoc} - * - * @covers \ProxyManager\Factory\NullObjectFactory::__construct - * @covers \ProxyManager\Factory\NullObjectFactory::createProxy - * @covers \ProxyManager\Factory\NullObjectFactory::getGenerator - * - * NOTE: serious mocking going on in here (a class is generated on-the-fly) - careful - */ - public function testWillTryAutoGeneration() - { - $instance = new stdClass(); - $proxyClassName = UniqueIdentifierGenerator::getIdentifier('bar'); - $generator = $this->getMock('ProxyManager\GeneratorStrategy\\GeneratorStrategyInterface'); - $autoloader = $this->getMock('ProxyManager\\Autoloader\\AutoloaderInterface'); - - $this->config->expects($this->any())->method('getGeneratorStrategy')->will($this->returnValue($generator)); - $this->config->expects($this->any())->method('getProxyAutoloader')->will($this->returnValue($autoloader)); - - $generator - ->expects($this->once()) - ->method('generate') - ->with( - $this->callback( - function (ClassGenerator $targetClass) use ($proxyClassName) { - return $targetClass->getName() === $proxyClassName; - } - ) - ); - - // simulate autoloading - $autoloader - ->expects($this->once()) - ->method('__invoke') - ->with($proxyClassName) - ->will( - $this->returnCallback( - function () use ($proxyClassName) { - eval( - 'class ' . $proxyClassName - . ' extends \\ProxyManagerTestAsset\\NullObjectMock {}' - ); - } - ) - ); - - $this - ->inflector - ->expects($this->once()) - ->method('getProxyClassName') - ->with('stdClass') - ->will($this->returnValue($proxyClassName)); - - $this - ->inflector - ->expects($this->once()) - ->method('getUserClassName') - ->with('stdClass') - ->will($this->returnValue('ProxyManagerTestAsset\\NullObjectMock')); - - $this->signatureChecker->expects($this->atLeastOnce())->method('checkSignature'); - $this->classSignatureGenerator->expects($this->once())->method('addSignature')->will($this->returnArgument(0)); - - $factory = new NullObjectFactory($this->config); - /* @var $proxy \ProxyManagerTestAsset\NullObjectMock */ - $proxy = $factory->createProxy($instance); - - $this->assertInstanceOf($proxyClassName, $proxy); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/RemoteObject/Adapter/BaseAdapterTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/RemoteObject/Adapter/BaseAdapterTest.php deleted file mode 100644 index df70ce8..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/RemoteObject/Adapter/BaseAdapterTest.php +++ /dev/null @@ -1,101 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class BaseAdapterTest extends PHPUnit_Framework_TestCase -{ - /** - * {@inheritDoc} - * - * @covers \ProxyManager\Factory\RemoteObject\Adapter\BaseAdapter::__construct - * @covers \ProxyManager\Factory\RemoteObject\Adapter\BaseAdapter::call - * @covers \ProxyManager\Factory\RemoteObject\Adapter\Soap::getServiceName - */ - public function testBaseAdapter() - { - $client = $this - ->getMockBuilder('Zend\Server\Client') - ->setMethods(array('call')) - ->getMock(); - - $adapter = $this->getMockForAbstractClass( - 'ProxyManager\\Factory\\RemoteObject\\Adapter\\BaseAdapter', - array($client) - ); - - $client - ->expects($this->once()) - ->method('call') - ->with('foobarbaz', array('tab' => 'taz')) - ->will($this->returnValue('baz')); - - $adapter - ->expects($this->once()) - ->method('getServiceName') - ->with('foo', 'bar') - ->will($this->returnValue('foobarbaz')); - - $this->assertSame('baz', $adapter->call('foo', 'bar', array('tab' => 'taz'))); - } - - /** - * {@inheritDoc} - * - * @covers \ProxyManager\Factory\RemoteObject\Adapter\BaseAdapter::__construct - * @covers \ProxyManager\Factory\RemoteObject\Adapter\BaseAdapter::call - * @covers \ProxyManager\Factory\RemoteObject\Adapter\Soap::getServiceName - */ - public function testBaseAdapterWithServiceMap() - { - $client = $this - ->getMockBuilder('Zend\Server\Client') - ->setMethods(array('call')) - ->getMock(); - - $adapter = $this->getMockForAbstractClass( - 'ProxyManager\\Factory\\RemoteObject\\Adapter\\BaseAdapter', - array($client, array('foobarbaz' => 'mapped')) - ); - - $client - ->expects($this->once()) - ->method('call') - ->with('mapped', array('tab' => 'taz')) - ->will($this->returnValue('baz')); - - $adapter - ->expects($this->once()) - ->method('getServiceName') - ->with('foo', 'bar') - ->will($this->returnValue('foobarbaz')); - - $this->assertSame('baz', $adapter->call('foo', 'bar', array('tab' => 'taz'))); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/RemoteObject/Adapter/JsonRpcTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/RemoteObject/Adapter/JsonRpcTest.php deleted file mode 100644 index 66e80d7..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/RemoteObject/Adapter/JsonRpcTest.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class JsonRpcTest extends PHPUnit_Framework_TestCase -{ - /** - * {@inheritDoc} - * - * @covers \ProxyManager\Factory\RemoteObject\Adapter\JsonRpc::__construct - * @covers \ProxyManager\Factory\RemoteObject\Adapter\JsonRpc::getServiceName - */ - public function testCanBuildAdapterWithJsonRpcClient() - { - $client = $this - ->getMockBuilder('Zend\Server\Client') - ->setMethods(array('call')) - ->getMock(); - - $adapter = new JsonRpc($client); - - $client - ->expects($this->once()) - ->method('call') - ->with('foo.bar', array('tab' => 'taz')) - ->will($this->returnValue('baz')); - - $this->assertSame('baz', $adapter->call('foo', 'bar', array('tab' => 'taz'))); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/RemoteObject/Adapter/SoapTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/RemoteObject/Adapter/SoapTest.php deleted file mode 100644 index fe93e00..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/RemoteObject/Adapter/SoapTest.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class SoapTest extends PHPUnit_Framework_TestCase -{ - /** - * {@inheritDoc} - * - * @covers \ProxyManager\Factory\RemoteObject\Adapter\Soap::__construct - * @covers \ProxyManager\Factory\RemoteObject\Adapter\Soap::getServiceName - */ - public function testCanBuildAdapterWithSoapRpcClient() - { - $client = $this - ->getMockBuilder('Zend\Server\Client') - ->setMethods(array('call')) - ->getMock(); - - $adapter = new Soap($client); - - $client - ->expects($this->once()) - ->method('call') - ->with('bar', array('tab' => 'taz')) - ->will($this->returnValue('baz')); - - $this->assertSame('baz', $adapter->call('foo', 'bar', array('tab' => 'taz'))); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/RemoteObject/Adapter/XmlRpcTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/RemoteObject/Adapter/XmlRpcTest.php deleted file mode 100644 index d795e40..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/RemoteObject/Adapter/XmlRpcTest.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class XmlRpcTest extends PHPUnit_Framework_TestCase -{ - /** - * {@inheritDoc} - * - * @covers \ProxyManager\Factory\RemoteObject\Adapter\XmlRpc::__construct - * @covers \ProxyManager\Factory\RemoteObject\Adapter\XmlRpc::getServiceName - */ - public function testCanBuildAdapterWithXmlRpcClient() - { - $client = $this - ->getMockBuilder('Zend\Server\Client') - ->setMethods(array('call')) - ->getMock(); - - $adapter = new XmlRpc($client); - - $client - ->expects($this->once()) - ->method('call') - ->with('foo.bar', array('tab' => 'taz')) - ->will($this->returnValue('baz')); - - $this->assertSame('baz', $adapter->call('foo', 'bar', array('tab' => 'taz'))); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/RemoteObjectFactoryTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/RemoteObjectFactoryTest.php deleted file mode 100644 index a7385e0..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Factory/RemoteObjectFactoryTest.php +++ /dev/null @@ -1,178 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class RemoteObjectFactoryTest extends PHPUnit_Framework_TestCase -{ - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $inflector; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $signatureChecker; - - /** - * @var \ProxyManager\Signature\ClassSignatureGeneratorInterface|\PHPUnit_Framework_MockObject_MockObject - */ - private $classSignatureGenerator; - - /** - * @var \ProxyManager\Configuration|\PHPUnit_Framework_MockObject_MockObject - */ - protected $config; - - /** - * {@inheritDoc} - */ - public function setUp() - { - $this->config = $this->getMock('ProxyManager\\Configuration'); - $this->inflector = $this->getMock('ProxyManager\\Inflector\\ClassNameInflectorInterface'); - $this->signatureChecker = $this->getMock('ProxyManager\\Signature\\SignatureCheckerInterface'); - $this->classSignatureGenerator = $this->getMock('ProxyManager\\Signature\\ClassSignatureGeneratorInterface'); - - $this - ->config - ->expects($this->any()) - ->method('getClassNameInflector') - ->will($this->returnValue($this->inflector)); - - $this - ->config - ->expects($this->any()) - ->method('getSignatureChecker') - ->will($this->returnValue($this->signatureChecker)); - - $this - ->config - ->expects($this->any()) - ->method('getClassSignatureGenerator') - ->will($this->returnValue($this->classSignatureGenerator)); - } - - /** - * {@inheritDoc} - * - * @covers \ProxyManager\Factory\RemoteObjectFactory::__construct - * @covers \ProxyManager\Factory\RemoteObjectFactory::createProxy - * @covers \ProxyManager\Factory\RemoteObjectFactory::getGenerator - */ - public function testWillSkipAutoGeneration() - { - $this - ->inflector - ->expects($this->once()) - ->method('getProxyClassName') - ->with('ProxyManagerTestAsset\\BaseInterface') - ->will($this->returnValue('StdClass')); - - $adapter = $this->getMock('ProxyManager\Factory\RemoteObject\AdapterInterface'); - $factory = new RemoteObjectFactory($adapter, $this->config); - /* @var $proxy \stdClass */ - $proxy = $factory->createProxy('ProxyManagerTestAsset\\BaseInterface', $adapter); - - $this->assertInstanceOf('stdClass', $proxy); - } - - /** - * {@inheritDoc} - * - * @covers \ProxyManager\Factory\RemoteObjectFactory::__construct - * @covers \ProxyManager\Factory\RemoteObjectFactory::createProxy - * @covers \ProxyManager\Factory\RemoteObjectFactory::getGenerator - * - * NOTE: serious mocking going on in here (a class is generated on-the-fly) - careful - */ - public function testWillTryAutoGeneration() - { - $proxyClassName = UniqueIdentifierGenerator::getIdentifier('bar'); - $generator = $this->getMock('ProxyManager\GeneratorStrategy\\GeneratorStrategyInterface'); - $autoloader = $this->getMock('ProxyManager\\Autoloader\\AutoloaderInterface'); - - $this->config->expects($this->any())->method('getGeneratorStrategy')->will($this->returnValue($generator)); - $this->config->expects($this->any())->method('getProxyAutoloader')->will($this->returnValue($autoloader)); - - $generator - ->expects($this->once()) - ->method('generate') - ->with( - $this->callback( - function (ClassGenerator $targetClass) use ($proxyClassName) { - return $targetClass->getName() === $proxyClassName; - } - ) - ); - - // simulate autoloading - $autoloader - ->expects($this->once()) - ->method('__invoke') - ->with($proxyClassName) - ->will( - $this->returnCallback( - function () use ($proxyClassName) { - eval( - 'class ' . $proxyClassName - . ' extends stdClass {}' - ); - } - ) - ); - - $this - ->inflector - ->expects($this->once()) - ->method('getProxyClassName') - ->with('ProxyManagerTestAsset\\BaseInterface') - ->will($this->returnValue($proxyClassName)); - - $this - ->inflector - ->expects($this->once()) - ->method('getUserClassName') - ->with('ProxyManagerTestAsset\\BaseInterface') - ->will($this->returnValue('stdClass')); - - $this->signatureChecker->expects($this->atLeastOnce())->method('checkSignature'); - $this->classSignatureGenerator->expects($this->once())->method('addSignature')->will($this->returnArgument(0)); - - $adapter = $this->getMock('ProxyManager\Factory\RemoteObject\AdapterInterface'); - $factory = new RemoteObjectFactory($adapter, $this->config); - /* @var $proxy \stdClass */ - $proxy = $factory->createProxy('ProxyManagerTestAsset\\BaseInterface', $adapter); - - $this->assertInstanceOf($proxyClassName, $proxy); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/FileLocator/FileLocatorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/FileLocator/FileLocatorTest.php deleted file mode 100644 index 92991a0..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/FileLocator/FileLocatorTest.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class FileLocatorTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\FileLocator\FileLocator::__construct - * @covers \ProxyManager\FileLocator\FileLocator::getProxyFileName - */ - public function testGetProxyFileName() - { - $locator = new FileLocator(__DIR__); - - $this->assertSame(__DIR__ . DIRECTORY_SEPARATOR . 'FooBarBaz.php', $locator->getProxyFileName('Foo\\Bar\\Baz')); - $this->assertSame(__DIR__ . DIRECTORY_SEPARATOR . 'Foo_Bar_Baz.php', $locator->getProxyFileName('Foo_Bar_Baz')); - } - - /** - * @covers \ProxyManager\FileLocator\FileLocator::__construct - */ - public function testRejectsNonExistingDirectory() - { - $this->setExpectedException('ProxyManager\\Exception\\InvalidProxyDirectoryException'); - new FileLocator(__DIR__ . '/non-existing'); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/AccessInterceptorScopeLocalizerFunctionalTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/AccessInterceptorScopeLocalizerFunctionalTest.php deleted file mode 100644 index 2e8984d..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/AccessInterceptorScopeLocalizerFunctionalTest.php +++ /dev/null @@ -1,388 +0,0 @@ - - * @license MIT - * - * @group Functional - * @coversNothing - */ -class AccessInterceptorScopeLocalizerFunctionalTest extends PHPUnit_Framework_TestCase -{ - /** - * {@inheritDoc} - */ - public static function setUpBeforeClass() - { - if (! method_exists('Closure', 'bind')) { - throw new PHPUnit_Framework_SkippedTestError( - 'PHP 5.3 doesn\'t support scope localization of private properties' - ); - } - } - - /** - * @dataProvider getProxyMethods - */ - public function testMethodCalls($className, $instance, $method, $params, $expectedValue) - { - $proxyName = $this->generateProxy($className); - - /* @var $proxy \ProxyManager\Proxy\AccessInterceptorInterface */ - $proxy = new $proxyName($instance); - - $this->assertProxySynchronized($instance, $proxy); - $this->assertSame($expectedValue, call_user_func_array(array($proxy, $method), $params)); - - $listener = $this->getMock('stdClass', array('__invoke')); - $listener - ->expects($this->once()) - ->method('__invoke') - ->with($proxy, $proxy, $method, $params, false); - - $proxy->setMethodPrefixInterceptor( - $method, - function ($proxy, $instance, $method, $params, & $returnEarly) use ($listener) { - $listener->__invoke($proxy, $instance, $method, $params, $returnEarly); - } - ); - - $this->assertSame($expectedValue, call_user_func_array(array($proxy, $method), $params)); - - $random = uniqid(); - - $proxy->setMethodPrefixInterceptor( - $method, - function ($proxy, $instance, $method, $params, & $returnEarly) use ($random) { - $returnEarly = true; - - return $random; - } - ); - - $this->assertSame($random, call_user_func_array(array($proxy, $method), $params)); - $this->assertProxySynchronized($instance, $proxy); - } - - /** - * @dataProvider getProxyMethods - */ - public function testMethodCallsWithSuffixListener($className, $instance, $method, $params, $expectedValue) - { - $proxyName = $this->generateProxy($className); - - /* @var $proxy \ProxyManager\Proxy\AccessInterceptorInterface */ - $proxy = new $proxyName($instance); - $listener = $this->getMock('stdClass', array('__invoke')); - $listener - ->expects($this->once()) - ->method('__invoke') - ->with($proxy, $proxy, $method, $params, $expectedValue, false); - - $proxy->setMethodSuffixInterceptor( - $method, - function ($proxy, $instance, $method, $params, $returnValue, & $returnEarly) use ($listener) { - $listener->__invoke($proxy, $instance, $method, $params, $returnValue, $returnEarly); - } - ); - - $this->assertSame($expectedValue, call_user_func_array(array($proxy, $method), $params)); - - $random = uniqid(); - - $proxy->setMethodSuffixInterceptor( - $method, - function ($proxy, $instance, $method, $params, $returnValue, & $returnEarly) use ($random) { - $returnEarly = true; - - return $random; - } - ); - - $this->assertSame($random, call_user_func_array(array($proxy, $method), $params)); - $this->assertProxySynchronized($instance, $proxy); - } - - /** - * @dataProvider getProxyMethods - */ - public function testMethodCallsAfterUnSerialization($className, $instance, $method, $params, $expectedValue) - { - $proxyName = $this->generateProxy($className); - /* @var $proxy \ProxyManager\Proxy\AccessInterceptorInterface */ - $proxy = unserialize(serialize(new $proxyName($instance))); - - $this->assertSame($expectedValue, call_user_func_array(array($proxy, $method), $params)); - $this->assertProxySynchronized($instance, $proxy); - } - - /** - * @dataProvider getProxyMethods - */ - public function testMethodCallsAfterCloning($className, $instance, $method, $params, $expectedValue) - { - $proxyName = $this->generateProxy($className); - - /* @var $proxy \ProxyManager\Proxy\AccessInterceptorInterface */ - $proxy = new $proxyName($instance); - $cloned = clone $proxy; - - $this->assertProxySynchronized($instance, $proxy); - $this->assertSame($expectedValue, call_user_func_array(array($cloned, $method), $params)); - $this->assertProxySynchronized($instance, $proxy); - } - - /** - * @dataProvider getPropertyAccessProxies - */ - public function testPropertyReadAccess($instance, $proxy, $publicProperty, $propertyValue) - { - /* @var $proxy \ProxyManager\Proxy\AccessInterceptorInterface */ - $this->assertSame($propertyValue, $proxy->$publicProperty); - $this->assertProxySynchronized($instance, $proxy); - } - - /** - * @dataProvider getPropertyAccessProxies - */ - public function testPropertyWriteAccess($instance, $proxy, $publicProperty) - { - /* @var $proxy \ProxyManager\Proxy\AccessInterceptorInterface */ - $newValue = uniqid(); - $proxy->$publicProperty = $newValue; - - $this->assertSame($newValue, $proxy->$publicProperty); - $this->assertProxySynchronized($instance, $proxy); - } - - /** - * @dataProvider getPropertyAccessProxies - */ - public function testPropertyExistence($instance, $proxy, $publicProperty) - { - /* @var $proxy \ProxyManager\Proxy\AccessInterceptorInterface */ - $this->assertSame(isset($instance->$publicProperty), isset($proxy->$publicProperty)); - $this->assertProxySynchronized($instance, $proxy); - - $instance->$publicProperty = null; - $this->assertFalse(isset($proxy->$publicProperty)); - $this->assertProxySynchronized($instance, $proxy); - } - - /** - * @dataProvider getPropertyAccessProxies - */ - public function testPropertyUnset($instance, $proxy, $publicProperty) - { - $this->markTestSkipped('It is currently not possible to synchronize properties un-setting'); - /* @var $proxy \ProxyManager\Proxy\AccessInterceptorInterface */ - unset($proxy->$publicProperty); - - $this->assertFalse(isset($instance->$publicProperty)); - $this->assertFalse(isset($proxy->$publicProperty)); - $this->assertProxySynchronized($instance, $proxy); - } - - /** - * Verifies that accessing a public property containing an array behaves like in a normal context - */ - public function testCanWriteToArrayKeysInPublicProperty() - { - $instance = new ClassWithPublicArrayProperty(); - $className = get_class($instance); - $proxyName = $this->generateProxy($className); - /* @var $proxy ClassWithPublicArrayProperty */ - $proxy = new $proxyName($instance); - - $proxy->arrayProperty['foo'] = 'bar'; - - $this->assertSame('bar', $proxy->arrayProperty['foo']); - - $proxy->arrayProperty = array('tab' => 'taz'); - - $this->assertSame(array('tab' => 'taz'), $proxy->arrayProperty); - $this->assertProxySynchronized($instance, $proxy); - } - - /** - * Verifies that public properties retrieved via `__get` don't get modified in the object state - */ - public function testWillNotModifyRetrievedPublicProperties() - { - $instance = new ClassWithPublicProperties(); - $className = get_class($instance); - $proxyName = $this->generateProxy($className); - /* @var $proxy ClassWithPublicProperties */ - $proxy = new $proxyName($instance); - $variable = $proxy->property0; - - $this->assertSame('property0', $variable); - - $variable = 'foo'; - - $this->assertSame('property0', $proxy->property0); - $this->assertProxySynchronized($instance, $proxy); - } - - /** - * Verifies that public properties references retrieved via `__get` modify in the object state - */ - public function testWillModifyByRefRetrievedPublicProperties() - { - $instance = new ClassWithPublicProperties(); - $className = get_class($instance); - $proxyName = $this->generateProxy($className); - /* @var $proxy ClassWithPublicProperties */ - $proxy = new $proxyName($instance); - $variable = & $proxy->property0; - - $this->assertSame('property0', $variable); - - $variable = 'foo'; - - $this->assertSame('foo', $proxy->property0); - $this->assertProxySynchronized($instance, $proxy); - } - - /** - * Generates a proxy for the given class name, and retrieves its class name - * - * @param string $parentClassName - * - * @return string - * - * @throws UnsupportedProxiedClassException - */ - private function generateProxy($parentClassName) - { - $generatedClassName = __NAMESPACE__ . '\\' . UniqueIdentifierGenerator::getIdentifier('Foo'); - $generator = new AccessInterceptorScopeLocalizerGenerator(); - $generatedClass = new ClassGenerator($generatedClassName); - $strategy = new EvaluatingGeneratorStrategy(); - - $generator->generate(new ReflectionClass($parentClassName), $generatedClass); - $strategy->generate($generatedClass); - - return $generatedClassName; - } - - /** - * Generates a list of object | invoked method | parameters | expected result - * - * @return array - */ - public function getProxyMethods() - { - $selfHintParam = new ClassWithSelfHint(); - - $data = array( - array( - 'ProxyManagerTestAsset\\BaseClass', - new BaseClass(), - 'publicMethod', - array(), - 'publicMethodDefault' - ), - array( - 'ProxyManagerTestAsset\\BaseClass', - new BaseClass(), - 'publicTypeHintedMethod', - array('param' => new \stdClass()), - 'publicTypeHintedMethodDefault' - ), - array( - 'ProxyManagerTestAsset\\BaseClass', - new BaseClass(), - 'publicByReferenceMethod', - array(), - 'publicByReferenceMethodDefault' - ), - ); - - if (PHP_VERSION_ID >= 50401) { - // PHP < 5.4.1 misbehaves, throwing strict standards, see https://bugs.php.net/bug.php?id=60573 - $data[] = array( - 'ProxyManagerTestAsset\\ClassWithSelfHint', - new ClassWithSelfHint(), - 'selfHintMethod', - array('parameter' => $selfHintParam), - $selfHintParam - ); - } - - return $data; - } - - /** - * Generates proxies and instances with a public property to feed to the property accessor methods - * - * @return array - */ - public function getPropertyAccessProxies() - { - $instance1 = new BaseClass(); - $proxyName1 = $this->generateProxy(get_class($instance1)); - - return array( - array( - $instance1, - new $proxyName1($instance1), - 'publicProperty', - 'publicPropertyDefault', - ), - ); - } - - /** - * @param object $instance - * @param AccessInterceptorInterface $proxy - */ - private function assertProxySynchronized($instance, AccessInterceptorInterface $proxy) - { - $reflectionClass = new ReflectionClass($instance); - - foreach ($reflectionClass->getProperties() as $property) { - $property->setAccessible(true); - - $this->assertSame( - $property->getValue($instance), - $property->getValue($proxy), - 'Property "' . $property->getName() . '" is synchronized between instance and proxy' - ); - } - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/AccessInterceptorValueHolderFunctionalTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/AccessInterceptorValueHolderFunctionalTest.php deleted file mode 100644 index 7740e2e..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/AccessInterceptorValueHolderFunctionalTest.php +++ /dev/null @@ -1,360 +0,0 @@ - - * @license MIT - * - * @group Functional - * @coversNothing - */ -class AccessInterceptorValueHolderFunctionalTest extends PHPUnit_Framework_TestCase -{ - /** - * @dataProvider getProxyMethods - */ - public function testMethodCalls($className, $instance, $method, $params, $expectedValue) - { - $proxyName = $this->generateProxy($className); - - /* @var $proxy \ProxyManager\Proxy\AccessInterceptorInterface|\ProxyManager\Proxy\ValueHolderInterface */ - $proxy = new $proxyName($instance); - - $this->assertSame($instance, $proxy->getWrappedValueHolderValue()); - $this->assertSame($expectedValue, call_user_func_array(array($proxy, $method), $params)); - - $listener = $this->getMock('stdClass', array('__invoke')); - $listener - ->expects($this->once()) - ->method('__invoke') - ->with($proxy, $instance, $method, $params, false); - - $proxy->setMethodPrefixInterceptor( - $method, - function ($proxy, $instance, $method, $params, & $returnEarly) use ($listener) { - $listener->__invoke($proxy, $instance, $method, $params, $returnEarly); - } - ); - - $this->assertSame($expectedValue, call_user_func_array(array($proxy, $method), $params)); - - $random = uniqid(); - - $proxy->setMethodPrefixInterceptor( - $method, - function ($proxy, $instance, $method, $params, & $returnEarly) use ($random) { - $returnEarly = true; - - return $random; - } - ); - - $this->assertSame($random, call_user_func_array(array($proxy, $method), $params)); - } - - /** - * @dataProvider getProxyMethods - */ - public function testMethodCallsWithSuffixListener($className, $instance, $method, $params, $expectedValue) - { - $proxyName = $this->generateProxy($className); - - /* @var $proxy \ProxyManager\Proxy\AccessInterceptorInterface|\ProxyManager\Proxy\ValueHolderInterface */ - $proxy = new $proxyName($instance); - $listener = $this->getMock('stdClass', array('__invoke')); - $listener - ->expects($this->once()) - ->method('__invoke') - ->with($proxy, $instance, $method, $params, $expectedValue, false); - - $proxy->setMethodSuffixInterceptor( - $method, - function ($proxy, $instance, $method, $params, $returnValue, & $returnEarly) use ($listener) { - $listener->__invoke($proxy, $instance, $method, $params, $returnValue, $returnEarly); - } - ); - - $this->assertSame($expectedValue, call_user_func_array(array($proxy, $method), $params)); - - $random = uniqid(); - - $proxy->setMethodSuffixInterceptor( - $method, - function ($proxy, $instance, $method, $params, $returnValue, & $returnEarly) use ($random) { - $returnEarly = true; - - return $random; - } - ); - - $this->assertSame($random, call_user_func_array(array($proxy, $method), $params)); - } - - /** - * @dataProvider getProxyMethods - */ - public function testMethodCallsAfterUnSerialization($className, $instance, $method, $params, $expectedValue) - { - $proxyName = $this->generateProxy($className); - /* @var $proxy \ProxyManager\Proxy\AccessInterceptorInterface|\ProxyManager\Proxy\ValueHolderInterface */ - $proxy = unserialize(serialize(new $proxyName($instance))); - - $this->assertSame($expectedValue, call_user_func_array(array($proxy, $method), $params)); - $this->assertEquals($instance, $proxy->getWrappedValueHolderValue()); - } - - /** - * @dataProvider getProxyMethods - */ - public function testMethodCallsAfterCloning($className, $instance, $method, $params, $expectedValue) - { - $proxyName = $this->generateProxy($className); - - /* @var $proxy \ProxyManager\Proxy\AccessInterceptorInterface|\ProxyManager\Proxy\ValueHolderInterface */ - $proxy = new $proxyName($instance); - $cloned = clone $proxy; - - $this->assertNotSame($proxy->getWrappedValueHolderValue(), $cloned->getWrappedValueHolderValue()); - $this->assertSame($expectedValue, call_user_func_array(array($cloned, $method), $params)); - $this->assertEquals($instance, $cloned->getWrappedValueHolderValue()); - } - - /** - * @dataProvider getPropertyAccessProxies - */ - public function testPropertyReadAccess($instance, $proxy, $publicProperty, $propertyValue) - { - /* @var $proxy \ProxyManager\Proxy\AccessInterceptorInterface|\ProxyManager\Proxy\ValueHolderInterface */ - $this->assertSame($propertyValue, $proxy->$publicProperty); - $this->assertEquals($instance, $proxy->getWrappedValueHolderValue()); - } - - /** - * @dataProvider getPropertyAccessProxies - */ - public function testPropertyWriteAccess($instance, $proxy, $publicProperty) - { - /* @var $proxy \ProxyManager\Proxy\AccessInterceptorInterface|\ProxyManager\Proxy\ValueHolderInterface */ - $newValue = uniqid(); - $proxy->$publicProperty = $newValue; - - $this->assertSame($newValue, $proxy->$publicProperty); - $this->assertSame($newValue, $proxy->getWrappedValueHolderValue()->$publicProperty); - } - - /** - * @dataProvider getPropertyAccessProxies - */ - public function testPropertyExistence($instance, $proxy, $publicProperty) - { - /* @var $proxy \ProxyManager\Proxy\AccessInterceptorInterface|\ProxyManager\Proxy\ValueHolderInterface */ - $this->assertSame(isset($instance->$publicProperty), isset($proxy->$publicProperty)); - $this->assertEquals($instance, $proxy->getWrappedValueHolderValue()); - - $proxy->getWrappedValueHolderValue()->$publicProperty = null; - $this->assertFalse(isset($proxy->$publicProperty)); - } - - /** - * @dataProvider getPropertyAccessProxies - */ - public function testPropertyUnset($instance, $proxy, $publicProperty) - { - /* @var $proxy \ProxyManager\Proxy\AccessInterceptorInterface|\ProxyManager\Proxy\ValueHolderInterface */ - $instance = $proxy->getWrappedValueHolderValue() ? $proxy->getWrappedValueHolderValue() : $instance; - unset($proxy->$publicProperty); - - $this->assertFalse(isset($instance->$publicProperty)); - $this->assertFalse(isset($proxy->$publicProperty)); - } - - /** - * Verifies that accessing a public property containing an array behaves like in a normal context - */ - public function testCanWriteToArrayKeysInPublicProperty() - { - $instance = new ClassWithPublicArrayProperty(); - $className = get_class($instance); - $proxyName = $this->generateProxy($className); - /* @var $proxy ClassWithPublicArrayProperty */ - $proxy = new $proxyName($instance); - - $proxy->arrayProperty['foo'] = 'bar'; - - $this->assertSame('bar', $proxy->arrayProperty['foo']); - - $proxy->arrayProperty = array('tab' => 'taz'); - - $this->assertSame(array('tab' => 'taz'), $proxy->arrayProperty); - } - - /** - * Verifies that public properties retrieved via `__get` don't get modified in the object state - */ - public function testWillNotModifyRetrievedPublicProperties() - { - $instance = new ClassWithPublicProperties(); - $className = get_class($instance); - $proxyName = $this->generateProxy($className); - /* @var $proxy ClassWithPublicProperties */ - $proxy = new $proxyName($instance); - $variable = $proxy->property0; - - $this->assertSame('property0', $variable); - - $variable = 'foo'; - - $this->assertSame('property0', $proxy->property0); - } - - /** - * Verifies that public properties references retrieved via `__get` modify in the object state - */ - public function testWillModifyByRefRetrievedPublicProperties() - { - $instance = new ClassWithPublicProperties(); - $className = get_class($instance); - $proxyName = $this->generateProxy($className); - /* @var $proxy ClassWithPublicProperties */ - $proxy = new $proxyName($instance); - $variable = & $proxy->property0; - - $this->assertSame('property0', $variable); - - $variable = 'foo'; - - $this->assertSame('foo', $proxy->property0); - } - - /** - * Generates a proxy for the given class name, and retrieves its class name - * - * @param string $parentClassName - * - * @return string - */ - private function generateProxy($parentClassName) - { - $generatedClassName = __NAMESPACE__ . '\\' . UniqueIdentifierGenerator::getIdentifier('Foo'); - $generator = new AccessInterceptorValueHolderGenerator(); - $generatedClass = new ClassGenerator($generatedClassName); - $strategy = new EvaluatingGeneratorStrategy(); - - $generator->generate(new ReflectionClass($parentClassName), $generatedClass); - $strategy->generate($generatedClass); - - return $generatedClassName; - } - - /** - * Generates a list of object | invoked method | parameters | expected result - * - * @return array - */ - public function getProxyMethods() - { - $selfHintParam = new ClassWithSelfHint(); - - $data = array( - array( - 'ProxyManagerTestAsset\\BaseClass', - new BaseClass(), - 'publicMethod', - array(), - 'publicMethodDefault' - ), - array( - 'ProxyManagerTestAsset\\BaseClass', - new BaseClass(), - 'publicTypeHintedMethod', - array('param' => new \stdClass()), - 'publicTypeHintedMethodDefault' - ), - array( - 'ProxyManagerTestAsset\\BaseClass', - new BaseClass(), - 'publicByReferenceMethod', - array(), - 'publicByReferenceMethodDefault' - ), - array( - 'ProxyManagerTestAsset\\BaseInterface', - new BaseClass(), - 'publicMethod', - array(), - 'publicMethodDefault' - ), - ); - - if (PHP_VERSION_ID >= 50401) { - // PHP < 5.4.1 misbehaves, throwing strict standards, see https://bugs.php.net/bug.php?id=60573 - $data[] = array( - 'ProxyManagerTestAsset\\ClassWithSelfHint', - new ClassWithSelfHint(), - 'selfHintMethod', - array('parameter' => $selfHintParam), - $selfHintParam - ); - } - - return $data; - } - - /** - * Generates proxies and instances with a public property to feed to the property accessor methods - * - * @return array - */ - public function getPropertyAccessProxies() - { - $instance1 = new BaseClass(); - $proxyName1 = $this->generateProxy(get_class($instance1)); - $instance2 = new BaseClass(); - $proxyName2 = $this->generateProxy(get_class($instance2)); - - return array( - array( - $instance1, - new $proxyName1($instance1), - 'publicProperty', - 'publicPropertyDefault', - ), - array( - $instance2, - unserialize(serialize(new $proxyName2($instance2))), - 'publicProperty', - 'publicPropertyDefault', - ), - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/BaseLazyLoadingPerformanceTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/BaseLazyLoadingPerformanceTest.php deleted file mode 100644 index d00fa41..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/BaseLazyLoadingPerformanceTest.php +++ /dev/null @@ -1,196 +0,0 @@ - - * @license MIT - * - * @group Performance - * @coversNothing - */ -abstract class BaseLazyLoadingPerformanceTest extends BasePerformanceTest -{ - /** - * @param string $className - * @param object[] $instances - * @param \ProxyManager\Proxy\LazyLoadingInterface[] $proxies - * @param string $methodName - * @param array $parameters - */ - protected function profileMethodAccess($className, array $instances, array $proxies, $methodName, array $parameters) - { - $iterations = count($instances); - - $this->startCapturing(); - - foreach ($instances as $instance) { - call_user_func_array(array($instance, $methodName), $parameters); - } - - $baseProfile = $this->endCapturing( - $iterations . ' calls to ' . $className . '#' . $methodName . ': %fms / %fKb' - ); - $this->startCapturing(); - - foreach ($proxies as $proxy) { - call_user_func_array(array($proxy, $methodName), $parameters); - } - - $proxyProfile = $this->endCapturing( - $iterations . ' calls to proxied ' . $className . '#' . $methodName . ': %fms / %fKb' - ); - $this->compareProfile($baseProfile, $proxyProfile); - } - - /** - * @param string $className - * @param object[] $instances - * @param \ProxyManager\Proxy\LazyLoadingInterface[] $proxies - * @param string $property - */ - protected function profilePropertyWrites($className, array $instances, array $proxies, $property) - { - $iterations = count($instances); - - $this->startCapturing(); - - foreach ($instances as $instance) { - $instance->$property = 'foo'; - } - - $baseProfile = $this->endCapturing( - $iterations . ' writes of ' . $className . '::' . $property . ': %fms / %fKb' - ); - $this->startCapturing(); - - foreach ($proxies as $proxy) { - $proxy->$property = 'foo'; - } - - $proxyProfile = $this->endCapturing( - $iterations . ' writes of proxied ' . $className . '::' . $property . ': %fms / %fKb' - ); - $this->compareProfile($baseProfile, $proxyProfile); - } - - /** - * @param string $className - * @param object[] $instances - * @param \ProxyManager\Proxy\LazyLoadingInterface[] $proxies - * @param string $property - */ - protected function profilePropertyReads($className, array $instances, array $proxies, $property) - { - $iterations = count($instances); - - $this->startCapturing(); - - foreach ($instances as $instance) { - $instance->$property; - } - - $baseProfile = $this->endCapturing( - $iterations . ' reads of ' . $className . '::' . $property . ': %fms / %fKb' - ); - $this->startCapturing(); - - foreach ($proxies as $proxy) { - $proxy->$property; - } - - $proxyProfile = $this->endCapturing( - $iterations . ' reads of proxied ' . $className . '::' . $property . ': %fms / %fKb' - ); - $this->compareProfile($baseProfile, $proxyProfile); - } - - /** - * @param string $className - * @param object[] $instances - * @param \ProxyManager\Proxy\LazyLoadingInterface[] $proxies - * @param string $property - */ - protected function profilePropertyIsset($className, array $instances, array $proxies, $property) - { - $iterations = count($instances); - - $this->startCapturing(); - - foreach ($instances as $instance) { - isset($instance->$property); - } - - $baseProfile = $this->endCapturing( - $iterations . ' isset of ' . $className . '::' . $property . ': %fms / %fKb' - ); - $this->startCapturing(); - - foreach ($proxies as $proxy) { - isset($proxy->$property); - } - - $proxyProfile = $this->endCapturing( - $iterations . ' isset of proxied ' . $className . '::' . $property . ': %fms / %fKb' - ); - $this->compareProfile($baseProfile, $proxyProfile); - } - - /** - * @param string $className - * @param object[] $instances - * @param \ProxyManager\Proxy\LazyLoadingInterface[] $proxies - * @param string $property - */ - protected function profilePropertyUnset($className, array $instances, array $proxies, $property) - { - $iterations = count($instances); - - $this->startCapturing(); - - foreach ($instances as $instance) { - unset($instance->$property); - } - - $baseProfile = $this->endCapturing( - $iterations . ' unset of ' . $className . '::' . $property . ': %fms / %fKb' - ); - $this->startCapturing(); - - foreach ($proxies as $proxy) { - unset($proxy->$property); - } - - $proxyProfile = $this->endCapturing( - $iterations . ' unset of proxied ' . $className . '::' . $property . ': %fms / %fKb' - ); - $this->compareProfile($baseProfile, $proxyProfile); - } - - /** - * Generates a proxy for the given class name, and retrieves its class name - * - * @param string $parentClassName - * - * @return string - */ - abstract protected function generateProxy($parentClassName); -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/BasePerformanceTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/BasePerformanceTest.php deleted file mode 100644 index b9dc803..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/BasePerformanceTest.php +++ /dev/null @@ -1,101 +0,0 @@ - - * @license MIT - * - * @group Performance - * @coversNothing - */ -abstract class BasePerformanceTest extends PHPUnit_Framework_TestCase -{ - /** - * @var float time when last capture was started - */ - private $startTime = 0; - - /** - * @var int bytes when last capture was started - */ - private $startMemory = 0; - - /** - * {@inheritDoc} - */ - public static function setUpBeforeClass() - { - $header = "Performance test - " . get_called_class() . ":"; - - echo "\n\n" . str_repeat('=', strlen($header)) . "\n" . $header . "\n\n"; - } - - /** - * Start profiler snapshot - */ - protected function startCapturing() - { - $this->startMemory = memory_get_usage(); - $this->startTime = microtime(true); - } - - /** - * Echo current profiler output - * - * @param string $messageTemplate - * - * @return array - */ - protected function endCapturing($messageTemplate) - { - $time = microtime(true) - $this->startTime; - $memory = memory_get_usage() - $this->startMemory; - - if (gc_enable()) { - gc_collect_cycles(); - } - - echo sprintf($messageTemplate, $time, $memory / 1024) . "\n"; - - return array( - 'time' => $time, - 'memory' => $memory - ); - } - - /** - * Display comparison between two profiles - * - * @param array $baseProfile - * @param array $proxyProfile - */ - protected function compareProfile(array $baseProfile, array $proxyProfile) - { - $baseMemory = max(1, $baseProfile['memory']); - $timeOverhead = (($proxyProfile['time'] / $baseProfile['time']) - 1) * 100; - $memoryOverhead = (($proxyProfile['memory'] / $baseMemory) - 1) * 100; - - echo sprintf('Comparison time / memory: %.2f%% / %.2f%%', $timeOverhead, $memoryOverhead) . "\n\n"; - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/FatalPreventionFunctionalTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/FatalPreventionFunctionalTest.php deleted file mode 100644 index 290d52b..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/FatalPreventionFunctionalTest.php +++ /dev/null @@ -1,171 +0,0 @@ - - * @license MIT - * - * @group Functional - * @coversNothing - */ -class FatalPreventionFunctionalTest extends PHPUnit_Framework_TestCase -{ - private $template = <<<'PHP' -generate(new ReflectionClass($className), $generatedClass); - $classSignatureGenerator->addSignature($generatedClass, array('eval tests')); - $generatorStrategy->generate($generatedClass); -} catch (ProxyManager\Exception\ExceptionInterface $e) { -} catch (ReflectionException $e) { -} - -echo 'SUCCESS: ' . %s; -PHP; - - /** - * Verifies that code generation and evaluation will not cause fatals with any given class - * - * @param string $generatorClass an instantiable class (no arguments) implementing - * the {@see \ProxyManager\ProxyGenerator\ProxyGeneratorInterface} - * @param string $className a valid (existing/autoloadable) class name - * - * @dataProvider getTestedClasses - */ - public function testCodeGeneration($generatorClass, $className) - { - if (defined('HHVM_VERSION')) { - $this->markTestSkipped('HHVM is just too slow for this kind of test right now.'); - } - - if (PHP_VERSION_ID < 50401) { - $this->markTestSkipped('Can\'t run this test suite on php < 5.4.1'); - } - - $runner = PHPUnit_Util_PHP::factory(); - - $code = sprintf( - $this->template, - var_export(realpath(__DIR__ . '/../../../vendor/autoload.php'), true), - var_export($className, true), - $generatorClass, - var_export($className, true) - ); - - $result = $runner->runJob($code, array('-n')); - - if (('SUCCESS: ' . $className) !== $result['stdout']) { - $this->fail(sprintf( - "Crashed with class '%s' and generator '%s'.\n\nStdout:\n%s\nStderr:\n%s\nGenerated code:\n%s'", - $generatorClass, - $className, - $result['stdout'], - $result['stderr'], - $code - )); - } - - $this->assertSame('SUCCESS: ' . $className, $result['stdout']); - } - - /** - * @return string[][] - */ - public function getTestedClasses() - { - $that = $this; - - return call_user_func_array( - 'array_merge', - array_map( - function ($generator) use ($that) { - return array_map( - function ($class) use ($generator) { - return array($generator, $class); - }, - $that->getProxyTestedClasses() - ); - }, - array( - 'ProxyManager\\ProxyGenerator\\AccessInterceptorScopeLocalizerGenerator', - 'ProxyManager\\ProxyGenerator\\AccessInterceptorValueHolderGenerator', - 'ProxyManager\\ProxyGenerator\\LazyLoadingGhostGenerator', - 'ProxyManager\\ProxyGenerator\\LazyLoadingValueHolderGenerator', - 'ProxyManager\\ProxyGenerator\\NullObjectGenerator', - 'ProxyManager\\ProxyGenerator\\RemoteObjectGenerator', - ) - ) - ); - } - - /** - * @private (public only for PHP 5.3 compatibility) - * - * @return string[] - */ - public function getProxyTestedClasses() - { - $skippedPaths = array( - realpath(__DIR__ . '/../../src'), - realpath(__DIR__ . '/../../vendor'), - realpath(__DIR__ . '/../../tests/ProxyManagerTest'), - ); - - return array_filter( - get_declared_classes(), - function ($className) use ($skippedPaths) { - $reflectionClass = new ReflectionClass($className); - $fileName = $reflectionClass->getFileName(); - - if (! $fileName) { - return false; - } - - $realPath = realpath($fileName); - - foreach ($skippedPaths as $skippedPath) { - if (0 === strpos($realPath, $skippedPath)) { - // skip classes defined within ProxyManager, vendor or the test suite - return false; - } - } - - return true; - } - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/LazyLoadingGhostFunctionalTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/LazyLoadingGhostFunctionalTest.php deleted file mode 100644 index a6690f1..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/LazyLoadingGhostFunctionalTest.php +++ /dev/null @@ -1,441 +0,0 @@ - - * @license MIT - * - * @group Functional - * @coversNothing - */ -class LazyLoadingGhostFunctionalTest extends PHPUnit_Framework_TestCase -{ - /** - * @dataProvider getProxyMethods - */ - public function testMethodCalls($className, $instance, $method, $params, $expectedValue) - { - $proxyName = $this->generateProxy($className); - - /* @var $proxy \ProxyManager\Proxy\GhostObjectInterface|BaseClass */ - $proxy = new $proxyName($this->createInitializer($className, $instance)); - - $this->assertFalse($proxy->isProxyInitialized()); - $this->assertSame($expectedValue, call_user_func_array(array($proxy, $method), $params)); - $this->assertTrue($proxy->isProxyInitialized()); - } - - /** - * @dataProvider getProxyMethods - */ - public function testMethodCallsAfterUnSerialization($className, $instance, $method, $params, $expectedValue) - { - $proxyName = $this->generateProxy($className); - - /* @var $proxy \ProxyManager\Proxy\GhostObjectInterface|BaseClass */ - $proxy = unserialize(serialize(new $proxyName($this->createInitializer($className, $instance)))); - - $this->assertTrue($proxy->isProxyInitialized()); - $this->assertSame($expectedValue, call_user_func_array(array($proxy, $method), $params)); - } - - /** - * @dataProvider getProxyMethods - */ - public function testMethodCallsAfterCloning($className, $instance, $method, $params, $expectedValue) - { - $proxyName = $this->generateProxy($className); - - /* @var $proxy \ProxyManager\Proxy\GhostObjectInterface|BaseClass */ - $proxy = new $proxyName($this->createInitializer($className, $instance)); - $cloned = clone $proxy; - - $this->assertTrue($cloned->isProxyInitialized()); - $this->assertSame($expectedValue, call_user_func_array(array($cloned, $method), $params)); - } - - /** - * @dataProvider getPropertyAccessProxies - */ - public function testPropertyReadAccess($instance, $proxy, $publicProperty, $propertyValue) - { - /* @var $proxy \ProxyManager\Proxy\GhostObjectInterface */ - $this->assertSame($propertyValue, $proxy->$publicProperty); - $this->assertTrue($proxy->isProxyInitialized()); - } - - /** - * @dataProvider getPropertyAccessProxies - */ - public function testPropertyWriteAccess($instance, $proxy, $publicProperty) - { - /* @var $proxy \ProxyManager\Proxy\GhostObjectInterface */ - $newValue = uniqid(); - $proxy->$publicProperty = $newValue; - - $this->assertTrue($proxy->isProxyInitialized()); - $this->assertSame($newValue, $proxy->$publicProperty); - } - - /** - * @dataProvider getPropertyAccessProxies - */ - public function testPropertyExistence($instance, $proxy, $publicProperty) - { - /* @var $proxy \ProxyManager\Proxy\GhostObjectInterface */ - $this->assertSame(isset($instance->$publicProperty), isset($proxy->$publicProperty)); - $this->assertTrue($proxy->isProxyInitialized()); - } - - /** - * @dataProvider getPropertyAccessProxies - */ - public function testPropertyAbsence($instance, $proxy, $publicProperty) - { - /* @var $proxy \ProxyManager\Proxy\GhostObjectInterface */ - $proxy->$publicProperty = null; - $this->assertFalse(isset($proxy->$publicProperty)); - $this->assertTrue($proxy->isProxyInitialized()); - } - - /** - * @dataProvider getPropertyAccessProxies - */ - public function testPropertyUnset($instance, $proxy, $publicProperty) - { - /* @var $proxy \ProxyManager\Proxy\GhostObjectInterface */ - - unset($proxy->$publicProperty); - - $this->assertTrue($proxy->isProxyInitialized()); - $this->assertTrue(isset($instance->$publicProperty)); - $this->assertFalse(isset($proxy->$publicProperty)); - } - - /** - * Verifies that accessing a public property containing an array behaves like in a normal context - */ - public function testCanWriteToArrayKeysInPublicProperty() - { - $instance = new ClassWithPublicArrayProperty(); - $className = get_class($instance); - $initializer = $this->createInitializer($className, $instance); - $proxyName = $this->generateProxy($className); - /* @var $proxy ClassWithPublicArrayProperty */ - $proxy = new $proxyName($initializer); - - $proxy->arrayProperty['foo'] = 'bar'; - - $this->assertSame('bar', $proxy->arrayProperty['foo']); - - $proxy->arrayProperty = array('tab' => 'taz'); - - $this->assertSame(array('tab' => 'taz'), $proxy->arrayProperty); - } - - /** - * Verifies that public properties retrieved via `__get` don't get modified in the object itself - */ - public function testWillNotModifyRetrievedPublicProperties() - { - $instance = new ClassWithPublicProperties(); - $className = get_class($instance); - $initializer = $this->createInitializer($className, $instance); - $proxyName = $this->generateProxy($className); - /* @var $proxy ClassWithPublicProperties */ - $proxy = new $proxyName($initializer); - $variable = $proxy->property0; - - $this->assertSame('property0', $variable); - - $variable = 'foo'; - - $this->assertSame('property0', $proxy->property0); - } - - /** - * Verifies that public properties references retrieved via `__get` modify in the object state - */ - public function testWillModifyByRefRetrievedPublicProperties() - { - $instance = new ClassWithPublicProperties(); - $className = get_class($instance); - $initializer = $this->createInitializer($className, $instance); - $proxyName = $this->generateProxy($className); - /* @var $proxy ClassWithPublicProperties */ - $proxy = new $proxyName($initializer); - $variable = & $proxy->property0; - - $this->assertSame('property0', $variable); - - $variable = 'foo'; - - $this->assertSame('foo', $proxy->property0); - } - - public function testKeepsInitializerWhenNotOverwitten() - { - $instance = new BaseClass(); - $proxyName = $this->generateProxy(get_class($instance)); - $initializer = function () { - }; - /* @var $proxy \ProxyManager\Proxy\GhostObjectInterface */ - $proxy = new $proxyName($initializer); - - $proxy->initializeProxy(); - - $this->assertSame($initializer, $proxy->getProxyInitializer()); - } - - /** - * Verifies that public properties are not being initialized multiple times - */ - public function testKeepsInitializedPublicProperties() - { - $instance = new BaseClass(); - $proxyName = $this->generateProxy(get_class($instance)); - $initializer = function (BaseClass $proxy, $method, $parameters, & $initializer) { - $initializer = null; - $proxy->publicProperty = 'newValue'; - }; - /* @var $proxy \ProxyManager\Proxy\GhostObjectInterface|BaseClass */ - $proxy = new $proxyName($initializer); - - $proxy->initializeProxy(); - $this->assertSame('newValue', $proxy->publicProperty); - - $proxy->publicProperty = 'otherValue'; - - $proxy->initializeProxy(); - - $this->assertSame('otherValue', $proxy->publicProperty); - } - - /** - * Verifies that properties' default values are preserved - */ - public function testPublicPropertyDefaultWillBePreserved() - { - $instance = new ClassWithPublicProperties(); - $proxyName = $this->generateProxy(get_class($instance)); - /* @var $proxy ClassWithPublicProperties */ - $proxy = new $proxyName(function () { - }); - - $this->assertSame('property0', $proxy->property0); - } - - /** - * Verifies that protected properties' default values are preserved - */ - public function testProtectedPropertyDefaultWillBePreserved() - { - $instance = new ClassWithProtectedProperties(); - $proxyName = $this->generateProxy(get_class($instance)); - /* @var $proxy ClassWithProtectedProperties */ - $proxy = new $proxyName(function () { - }); - - // Check protected property via reflection - $reflectionProperty = new ReflectionProperty($instance, 'property0'); - $reflectionProperty->setAccessible(true); - - $this->assertSame('property0', $reflectionProperty->getValue($proxy)); - } - - /** - * Verifies that private properties' default values are preserved - */ - public function testPrivatePropertyDefaultWillBePreserved() - { - $instance = new ClassWithPrivateProperties(); - $proxyName = $this->generateProxy(get_class($instance)); - /* @var $proxy ClassWithPrivateProperties */ - $proxy = new $proxyName(function () { - }); - - // Check protected property via reflection - $reflectionProperty = new ReflectionProperty($instance, 'property0'); - $reflectionProperty->setAccessible(true); - - $this->assertSame('property0', $reflectionProperty->getValue($proxy)); - } - - /** - * Generates a proxy for the given class name, and retrieves its class name - * - * @param string $parentClassName - * - * @return string - */ - private function generateProxy($parentClassName) - { - $generatedClassName = __NAMESPACE__ . '\\' . UniqueIdentifierGenerator::getIdentifier('Foo'); - $generator = new LazyLoadingGhostGenerator(); - $generatedClass = new ClassGenerator($generatedClassName); - $strategy = new EvaluatingGeneratorStrategy(); - - $generator->generate(new ReflectionClass($parentClassName), $generatedClass); - $strategy->generate($generatedClass); - - return $generatedClassName; - } - - /** - * @param string $className - * @param object $realInstance - * @param Mock $initializerMatcher - * - * @return \Closure - */ - private function createInitializer($className, $realInstance, Mock $initializerMatcher = null) - { - if (null === $initializerMatcher) { - $initializerMatcher = $this->getMock('stdClass', array('__invoke')); - - $initializerMatcher - ->expects($this->once()) - ->method('__invoke') - ->with( - $this->logicalAnd( - $this->isInstanceOf('ProxyManager\\Proxy\\GhostObjectInterface'), - $this->isInstanceOf($className) - ) - ); - } - - $initializerMatcher = $initializerMatcher ?: $this->getMock('stdClass', array('__invoke')); - - return function ( - GhostObjectInterface $proxy, - $method, - $params, - & $initializer - ) use ( - $initializerMatcher, - $realInstance - ) { - $initializer = null; - $reflectionClass = new ReflectionClass($realInstance); - - foreach ($reflectionClass->getProperties() as $property) { - $property->setAccessible(true); - $property->setValue($proxy, $property->getValue($realInstance)); - } - - $initializerMatcher->__invoke($proxy, $method, $params); - }; - } - - /** - * Generates a list of object | invoked method | parameters | expected result - * - * @return array - */ - public function getProxyMethods() - { - $selfHintParam = new ClassWithSelfHint(); - - $data = array( - array( - 'ProxyManagerTestAsset\\BaseClass', - new BaseClass(), - 'publicMethod', - array(), - 'publicMethodDefault' - ), - array( - 'ProxyManagerTestAsset\\BaseClass', - new BaseClass(), - 'publicTypeHintedMethod', - array(new \stdClass()), - 'publicTypeHintedMethodDefault' - ), - array( - 'ProxyManagerTestAsset\\BaseClass', - new BaseClass(), - 'publicByReferenceMethod', - array(), - 'publicByReferenceMethodDefault' - ), - ); - - if (PHP_VERSION_ID >= 50401) { - // PHP < 5.4.1 misbehaves, throwing strict standards, see https://bugs.php.net/bug.php?id=60573 - $data[] = array( - 'ProxyManagerTestAsset\\ClassWithSelfHint', - new ClassWithSelfHint(), - 'selfHintMethod', - array('parameter' => $selfHintParam), - $selfHintParam - ); - } - - return $data; - } - - /** - * Generates proxies and instances with a public property to feed to the property accessor methods - * - * @return array - */ - public function getPropertyAccessProxies() - { - $instance1 = new BaseClass(); - $proxyName1 = $this->generateProxy(get_class($instance1)); - $instance2 = new BaseClass(); - $proxyName2 = $this->generateProxy(get_class($instance2)); - - return array( - array( - $instance1, - new $proxyName1($this->createInitializer('ProxyManagerTestAsset\\BaseClass', $instance1)), - 'publicProperty', - 'publicPropertyDefault', - ), - array( - $instance2, - unserialize( - serialize(new $proxyName2($this->createInitializer('ProxyManagerTestAsset\\BaseClass', $instance2))) - ), - 'publicProperty', - 'publicPropertyDefault', - ), - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/LazyLoadingGhostPerformanceTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/LazyLoadingGhostPerformanceTest.php deleted file mode 100644 index 21b9f49..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/LazyLoadingGhostPerformanceTest.php +++ /dev/null @@ -1,160 +0,0 @@ - - * @license MIT - * - * @group Performance - * @coversNothing - */ -class LazyLoadingGhostPerformanceTest extends BaseLazyLoadingPerformanceTest -{ - /** - * @outputBuffering - * @dataProvider getTestedClasses - * - * @param string $className - * @param array $methods - * @param array $properties - * @param \ReflectionProperty[] $reflectionProperties - * - * @return void - */ - public function testProxyInstantiationPerformance( - $className, - array $methods, - array $properties, - array $reflectionProperties - ) { - $proxyName = $this->generateProxy($className); - $iterations = 20000; - $instances = array(); - /* @var $proxies \ProxyManager\Proxy\GhostObjectInterface[] */ - $proxies = array(); - $realInstance = new $className(); - $initializer = function ( - GhostObjectInterface $proxy, - $method, - $params, - & $initializer - ) use ( - $reflectionProperties, - $realInstance - ) { - $initializer = null; - - foreach ($reflectionProperties as $reflectionProperty) { - $reflectionProperty->setValue($proxy, $reflectionProperty->getValue($realInstance)); - } - - return true; - }; - - $this->startCapturing(); - - for ($i = 0; $i < $iterations; $i += 1) { - $instances[] = new $className(); - } - - $baseProfile = $this->endCapturing( - 'Instantiation for ' . $iterations . ' objects of type ' . $className . ': %fms / %fKb' - ); - $this->startCapturing(); - - for ($i = 0; $i < $iterations; $i += 1) { - $proxies[] = new $proxyName($initializer); - } - - $proxyProfile = $this->endCapturing( - 'Instantiation for ' . $iterations . ' proxies of type ' . $className . ': %fms / %fKb' - ); - $this->compareProfile($baseProfile, $proxyProfile); - $this->startCapturing(); - - foreach ($proxies as $proxy) { - $proxy->initializeProxy(); - } - - $this->endCapturing('Initialization of ' . $iterations . ' proxies of type ' . $className . ': %fms / %fKb'); - - foreach ($methods as $methodName => $parameters) { - $this->profileMethodAccess($className, $instances, $proxies, $methodName, $parameters); - } - - foreach ($properties as $property) { - $this->profilePropertyWrites($className, $instances, $proxies, $property); - $this->profilePropertyReads($className, $instances, $proxies, $property); - $this->profilePropertyIsset($className, $instances, $proxies, $property); - $this->profilePropertyUnset($className, $instances, $proxies, $property); - } - } - - /** - * @return array - */ - public function getTestedClasses() - { - $testedClasses = array( - array('stdClass', array(), array()), - array('ProxyManagerTestAsset\\BaseClass', array('publicMethod' => array()), array('publicProperty')), - ); - - foreach ($testedClasses as $key => $testedClass) { - $reflectionProperties = array(); - $reflectionClass = new ReflectionClass($testedClass[0]); - - foreach ($reflectionClass->getProperties() as $property) { - $property->setAccessible(true); - - $reflectionProperties[$property->getName()] = $property; - } - - $testedClasses[$key][] = $reflectionProperties; - } - - return $testedClasses; - } - - /** - * {@inheritDoc} - */ - protected function generateProxy($parentClassName) - { - $generatedClassName = __NAMESPACE__ . '\\' . UniqueIdentifierGenerator::getIdentifier('Foo'); - $generator = new LazyLoadingGhostGenerator(); - $generatedClass = new ClassGenerator($generatedClassName); - $strategy = new EvaluatingGeneratorStrategy(); - - $generator->generate(new ReflectionClass($parentClassName), $generatedClass); - $strategy->generate($generatedClass); - - return $generatedClassName; - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/LazyLoadingValueHolderFunctionalTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/LazyLoadingValueHolderFunctionalTest.php deleted file mode 100644 index a638760..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/LazyLoadingValueHolderFunctionalTest.php +++ /dev/null @@ -1,386 +0,0 @@ - - * @license MIT - * - * @group Functional - * @coversNothing - */ -class LazyLoadingValueHolderFunctionalTest extends PHPUnit_Framework_TestCase -{ - /** - * @dataProvider getProxyMethods - */ - public function testMethodCalls($className, $instance, $method, $params, $expectedValue) - { - $proxyName = $this->generateProxy($className); - - /* @var $proxy \ProxyManager\Proxy\VirtualProxyInterface|BaseClass */ - $proxy = new $proxyName($this->createInitializer($className, $instance)); - - $this->assertFalse($proxy->isProxyInitialized()); - $this->assertSame($expectedValue, call_user_func_array(array($proxy, $method), $params)); - $this->assertTrue($proxy->isProxyInitialized()); - $this->assertSame($instance, $proxy->getWrappedValueHolderValue()); - } - - /** - * @dataProvider getProxyMethods - */ - public function testMethodCallsAfterUnSerialization($className, $instance, $method, $params, $expectedValue) - { - $proxyName = $this->generateProxy($className); - - /* @var $proxy \ProxyManager\Proxy\VirtualProxyInterface|BaseClass */ - $proxy = unserialize(serialize(new $proxyName($this->createInitializer($className, $instance)))); - - $this->assertTrue($proxy->isProxyInitialized()); - $this->assertSame($expectedValue, call_user_func_array(array($proxy, $method), $params)); - $this->assertEquals($instance, $proxy->getWrappedValueHolderValue()); - } - - /** - * @dataProvider getProxyMethods - */ - public function testMethodCallsAfterCloning($className, $instance, $method, $params, $expectedValue) - { - $proxyName = $this->generateProxy($className); - - /* @var $proxy \ProxyManager\Proxy\VirtualProxyInterface|BaseClass */ - $proxy = new $proxyName($this->createInitializer($className, $instance)); - $cloned = clone $proxy; - - $this->assertTrue($cloned->isProxyInitialized()); - $this->assertNotSame($proxy->getWrappedValueHolderValue(), $cloned->getWrappedValueHolderValue()); - $this->assertSame($expectedValue, call_user_func_array(array($cloned, $method), $params)); - $this->assertEquals($instance, $cloned->getWrappedValueHolderValue()); - } - - /** - * @dataProvider getPropertyAccessProxies - */ - public function testPropertyReadAccess($instance, $proxy, $publicProperty, $propertyValue) - { - /* @var $proxy \ProxyManager\Proxy\VirtualProxyInterface|BaseClass */ - $this->assertSame($propertyValue, $proxy->$publicProperty); - $this->assertTrue($proxy->isProxyInitialized()); - $this->assertEquals($instance, $proxy->getWrappedValueHolderValue()); - } - - /** - * @dataProvider getPropertyAccessProxies - */ - public function testPropertyWriteAccess($instance, $proxy, $publicProperty) - { - /* @var $proxy \ProxyManager\Proxy\VirtualProxyInterface|BaseClass */ - $newValue = uniqid(); - $proxy->$publicProperty = $newValue; - - $this->assertTrue($proxy->isProxyInitialized()); - $this->assertSame($newValue, $proxy->$publicProperty); - $this->assertSame($newValue, $proxy->getWrappedValueHolderValue()->$publicProperty); - } - - /** - * @dataProvider getPropertyAccessProxies - */ - public function testPropertyExistence($instance, $proxy, $publicProperty) - { - /* @var $proxy \ProxyManager\Proxy\VirtualProxyInterface|BaseClass */ - $this->assertSame(isset($instance->$publicProperty), isset($proxy->$publicProperty)); - $this->assertTrue($proxy->isProxyInitialized()); - $this->assertEquals($instance, $proxy->getWrappedValueHolderValue()); - } - - /** - * @dataProvider getPropertyAccessProxies - */ - public function testPropertyAbsence($instance, $proxy, $publicProperty) - { - /* @var $proxy \ProxyManager\Proxy\VirtualProxyInterface|BaseClass */ - $instance = $proxy->getWrappedValueHolderValue() ? $proxy->getWrappedValueHolderValue() : $instance; - $instance->$publicProperty = null; - $this->assertFalse(isset($proxy->$publicProperty)); - $this->assertTrue($proxy->isProxyInitialized()); - } - - /** - * @dataProvider getPropertyAccessProxies - */ - public function testPropertyUnset($instance, $proxy, $publicProperty) - { - /* @var $proxy \ProxyManager\Proxy\VirtualProxyInterface|BaseClass */ - $instance = $proxy->getWrappedValueHolderValue() ? $proxy->getWrappedValueHolderValue() : $instance; - unset($proxy->$publicProperty); - - $this->assertTrue($proxy->isProxyInitialized()); - - $this->assertFalse(isset($instance->$publicProperty)); - $this->assertFalse(isset($proxy->$publicProperty)); - } - - /** - * Verifies that accessing a public property containing an array behaves like in a normal context - */ - public function testCanWriteToArrayKeysInPublicProperty() - { - $instance = new ClassWithPublicArrayProperty(); - $className = get_class($instance); - $initializer = $this->createInitializer($className, $instance); - $proxyName = $this->generateProxy($className); - /* @var $proxy ClassWithPublicArrayProperty */ - $proxy = new $proxyName($initializer); - - $proxy->arrayProperty['foo'] = 'bar'; - - $this->assertSame('bar', $proxy->arrayProperty['foo']); - - $proxy->arrayProperty = array('tab' => 'taz'); - - $this->assertSame(array('tab' => 'taz'), $proxy->arrayProperty); - } - - /** - * Verifies that public properties retrieved via `__get` don't get modified in the object itself - */ - public function testWillNotModifyRetrievedPublicProperties() - { - $instance = new ClassWithPublicProperties(); - $className = get_class($instance); - $initializer = $this->createInitializer($className, $instance); - $proxyName = $this->generateProxy($className); - /* @var $proxy ClassWithPublicProperties */ - $proxy = new $proxyName($initializer); - $variable = $proxy->property0; - - $this->assertSame('property0', $variable); - - $variable = 'foo'; - - $this->assertSame('property0', $proxy->property0); - } - - /** - * Verifies that public properties references retrieved via `__get` modify in the object state - */ - public function testWillModifyByRefRetrievedPublicProperties() - { - $instance = new ClassWithPublicProperties(); - $className = get_class($instance); - $initializer = $this->createInitializer($className, $instance); - $proxyName = $this->generateProxy($className); - /* @var $proxy ClassWithPublicProperties */ - $proxy = new $proxyName($initializer); - $variable = & $proxy->property0; - - $this->assertSame('property0', $variable); - - $variable = 'foo'; - - $this->assertSame('foo', $proxy->property0); - } - - /** - * @group 16 - * - * Verifies that initialization of a value holder proxy may happen multiple times - */ - public function testWillAllowMultipleProxyInitialization() - { - $proxyClass = $this->generateProxy('ProxyManagerTestAsset\\BaseClass'); - $counter = 0; - $initializer = function (& $wrappedInstance) use (& $counter) { - $wrappedInstance = new BaseClass(); - - $wrappedInstance->publicProperty = (string) ($counter += 1); - }; - - /* @var $proxy BaseClass */ - $proxy = new $proxyClass($initializer); - - $this->assertSame('1', $proxy->publicProperty); - $this->assertSame('2', $proxy->publicProperty); - $this->assertSame('3', $proxy->publicProperty); - } - - /** - * Generates a proxy for the given class name, and retrieves its class name - * - * @param string $parentClassName - * - * @return string - */ - private function generateProxy($parentClassName) - { - $generatedClassName = __NAMESPACE__ . '\\' . UniqueIdentifierGenerator::getIdentifier('Foo'); - $generator = new LazyLoadingValueHolderGenerator(); - $generatedClass = new ClassGenerator($generatedClassName); - $strategy = new EvaluatingGeneratorStrategy(); - - $generator->generate(new ReflectionClass($parentClassName), $generatedClass); - $strategy->generate($generatedClass); - - return $generatedClassName; - } - - /** - * @param string $className - * @param object $realInstance - * @param Mock $initializerMatcher - * - * @return \Closure - */ - private function createInitializer($className, $realInstance, Mock $initializerMatcher = null) - { - if (null === $initializerMatcher) { - $initializerMatcher = $this->getMock('stdClass', array('__invoke')); - - $initializerMatcher - ->expects($this->once()) - ->method('__invoke') - ->with( - $this->logicalAnd( - $this->isInstanceOf('ProxyManager\\Proxy\\VirtualProxyInterface'), - $this->isInstanceOf($className) - ), - $realInstance - ); - } - - $initializerMatcher = $initializerMatcher ?: $this->getMock('stdClass', array('__invoke')); - - return function ( - & $wrappedObject, - VirtualProxyInterface $proxy, - $method, - $params, - & $initializer - ) use ( - $initializerMatcher, - $realInstance - ) { - $initializer = null; - $wrappedObject = $realInstance; - - $initializerMatcher->__invoke($proxy, $wrappedObject, $method, $params); - }; - } - - /** - * Generates a list of object | invoked method | parameters | expected result - * - * @return array - */ - public function getProxyMethods() - { - $selfHintParam = new ClassWithSelfHint(); - - $data = array( - array( - 'ProxyManagerTestAsset\\BaseClass', - new BaseClass(), - 'publicMethod', - array(), - 'publicMethodDefault' - ), - array( - 'ProxyManagerTestAsset\\BaseClass', - new BaseClass(), - 'publicTypeHintedMethod', - array(new \stdClass()), - 'publicTypeHintedMethodDefault' - ), - array( - 'ProxyManagerTestAsset\\BaseClass', - new BaseClass(), - 'publicByReferenceMethod', - array(), - 'publicByReferenceMethodDefault' - ), - array( - 'ProxyManagerTestAsset\\BaseInterface', - new BaseClass(), - 'publicMethod', - array(), - 'publicMethodDefault' - ), - ); - - if (PHP_VERSION_ID >= 50401) { - // PHP < 5.4.1 misbehaves, throwing strict standards, see https://bugs.php.net/bug.php?id=60573 - $data[] = array( - 'ProxyManagerTestAsset\\ClassWithSelfHint', - new ClassWithSelfHint(), - 'selfHintMethod', - array('parameter' => $selfHintParam), - $selfHintParam - ); - } - - return $data; - } - - /** - * Generates proxies and instances with a public property to feed to the property accessor methods - * - * @return array - */ - public function getPropertyAccessProxies() - { - $instance1 = new BaseClass(); - $proxyName1 = $this->generateProxy(get_class($instance1)); - $instance2 = new BaseClass(); - $proxyName2 = $this->generateProxy(get_class($instance2)); - - return array( - array( - $instance1, - new $proxyName1($this->createInitializer('ProxyManagerTestAsset\\BaseClass', $instance1)), - 'publicProperty', - 'publicPropertyDefault', - ), - array( - $instance2, - unserialize( - serialize(new $proxyName2($this->createInitializer('ProxyManagerTestAsset\\BaseClass', $instance2))) - ), - 'publicProperty', - 'publicPropertyDefault', - ), - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/LazyLoadingValueHolderPerformanceTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/LazyLoadingValueHolderPerformanceTest.php deleted file mode 100644 index 1279526..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/LazyLoadingValueHolderPerformanceTest.php +++ /dev/null @@ -1,134 +0,0 @@ - - * @license MIT - * - * @group Performance - * @coversNothing - */ -class LazyLoadingValueHolderPerformanceTest extends BaseLazyLoadingPerformanceTest -{ - /** - * @outputBuffering - * @dataProvider getTestedClasses - * - * @param string $className - * @param array $methods - * @param array $properties - * - * @return void - */ - public function testProxyInstantiationPerformance($className, array $methods, array $properties) - { - $proxyName = $this->generateProxy($className); - $iterations = 20000; - $instances = array(); - /* @var $proxies \ProxyManager\Proxy\VirtualProxyInterface[] */ - $proxies = array(); - $initializer = function ( - & $valueHolder, - VirtualProxyInterface $proxy, - $method, - $params, - & $initializer - ) use ($className) { - $initializer = null; - $valueHolder = new $className(); - - return true; - }; - - $this->startCapturing(); - - for ($i = 0; $i < $iterations; $i += 1) { - $instances[] = new $className(); - } - - $baseProfile = $this->endCapturing( - 'Instantiation for ' . $iterations . ' objects of type ' . $className . ': %fms / %fKb' - ); - $this->startCapturing(); - - for ($i = 0; $i < $iterations; $i += 1) { - $proxies[] = new $proxyName($initializer); - } - - $proxyProfile = $this->endCapturing( - 'Instantiation for ' . $iterations . ' proxies of type ' . $className . ': %fms / %fKb' - ); - $this->compareProfile($baseProfile, $proxyProfile); - $this->startCapturing(); - - foreach ($proxies as $proxy) { - $proxy->initializeProxy(); - } - - $this->endCapturing('Initialization of ' . $iterations . ' proxies of type ' . $className . ': %fms / %fKb'); - - foreach ($methods as $methodName => $parameters) { - $this->profileMethodAccess($className, $instances, $proxies, $methodName, $parameters); - } - - foreach ($properties as $property) { - $this->profilePropertyWrites($className, $instances, $proxies, $property); - $this->profilePropertyReads($className, $instances, $proxies, $property); - $this->profilePropertyIsset($className, $instances, $proxies, $property); - $this->profilePropertyUnset($className, $instances, $proxies, $property); - } - } - - /** - * @return array - */ - public function getTestedClasses() - { - return array( - array('stdClass', array(), array()), - array('ProxyManagerTestAsset\\BaseClass', array('publicMethod' => array()), array('publicProperty')), - ); - } - - /** - * {@inheritDoc} - */ - protected function generateProxy($parentClassName) - { - $generatedClassName = __NAMESPACE__ . '\\' . UniqueIdentifierGenerator::getIdentifier('Foo'); - $generator = new LazyLoadingValueHolderGenerator(); - $generatedClass = new ClassGenerator($generatedClassName); - $strategy = new EvaluatingGeneratorStrategy(); - - $generator->generate(new ReflectionClass($parentClassName), $generatedClass); - $strategy->generate($generatedClass); - - return $generatedClassName; - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/MultipleProxyGenerationTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/MultipleProxyGenerationTest.php deleted file mode 100644 index 00be47d..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/MultipleProxyGenerationTest.php +++ /dev/null @@ -1,123 +0,0 @@ - - * @license MIT - * - * @link https://github.com/Ocramius/ProxyManager/issues/10 - * - * @group Functional - * @group issue-10 - * @coversNothing - */ -class MultipleProxyGenerationTest extends PHPUnit_Framework_TestCase -{ - /** - * Verifies that proxies generated from different factories will retain their specific implementation - * and won't conflict - * - * @dataProvider getTestedClasses - */ - public function testCanGenerateMultipleDifferentProxiesForSameClass($className) - { - $skipScopeLocalizerTests = false; - $ghostProxyFactory = new LazyLoadingGhostFactory(); - $virtualProxyFactory = new LazyLoadingValueHolderFactory(); - $accessInterceptorFactory = new AccessInterceptorValueHolderFactory(); - $accessInterceptorScopeLocalizerFactory = new AccessInterceptorScopeLocalizerFactory(); - $initializer = function () { - }; - - $reflectionClass = new ReflectionClass($className); - - if ((! method_exists('Closure', 'bind')) && $reflectionClass->getProperties(ReflectionProperty::IS_PRIVATE)) { - $skipScopeLocalizerTests = true; - } - - $generated = array( - $ghostProxyFactory->createProxy($className, $initializer), - $virtualProxyFactory->createProxy($className, $initializer), - $accessInterceptorFactory->createProxy(new $className()), - ); - - if (! $skipScopeLocalizerTests) { - $generated[] = $accessInterceptorScopeLocalizerFactory->createProxy(new $className()); - } - - foreach ($generated as $key => $proxy) { - $this->assertInstanceOf($className, $proxy); - - foreach ($generated as $comparedKey => $comparedProxy) { - if ($comparedKey === $key) { - continue; - } - - $this->assertNotSame(get_class($comparedProxy), get_class($proxy)); - } - } - - $this->assertInstanceOf('ProxyManager\Proxy\GhostObjectInterface', $generated[0]); - $this->assertInstanceOf('ProxyManager\Proxy\VirtualProxyInterface', $generated[1]); - $this->assertInstanceOf('ProxyManager\Proxy\AccessInterceptorInterface', $generated[2]); - $this->assertInstanceOf('ProxyManager\Proxy\ValueHolderInterface', $generated[2]); - - if (! $skipScopeLocalizerTests) { - $this->assertInstanceOf('ProxyManager\Proxy\AccessInterceptorInterface', $generated[3]); - } - } - - /** - * @return string[][] - */ - public function getTestedClasses() - { - $data = array( - array('ProxyManagerTestAsset\\BaseClass'), - array('ProxyManagerTestAsset\\ClassWithMagicMethods'), - array('ProxyManagerTestAsset\\ClassWithFinalMethods'), - array('ProxyManagerTestAsset\\ClassWithFinalMagicMethods'), - array('ProxyManagerTestAsset\\ClassWithByRefMagicMethods'), - array('ProxyManagerTestAsset\\ClassWithMixedProperties'), - array('ProxyManagerTestAsset\\ClassWithPrivateProperties'), - array('ProxyManagerTestAsset\\ClassWithProtectedProperties'), - array('ProxyManagerTestAsset\\ClassWithPublicProperties'), - array('ProxyManagerTestAsset\\EmptyClass'), - array('ProxyManagerTestAsset\\HydratedObject'), - ); - - if (PHP_VERSION_ID >= 50401) { - // PHP < 5.4.1 misbehaves, throwing strict standards, see https://bugs.php.net/bug.php?id=60573 - $data[] = array('ProxyManagerTestAsset\\ClassWithSelfHint'); - } - - return $data; - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/NullObjectFunctionalTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/NullObjectFunctionalTest.php deleted file mode 100644 index adfeae5..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/NullObjectFunctionalTest.php +++ /dev/null @@ -1,223 +0,0 @@ - - * @license MIT - * - * @group Functional - * @coversNothing - */ -class NullObjectFunctionalTest extends PHPUnit_Framework_TestCase -{ - /** - * @dataProvider getProxyMethods - */ - public function testMethodCalls($className, $instance, $method, $params, $expectedValue) - { - $proxyName = $this->generateProxy($className); - - /* @var $proxy \ProxyManager\Proxy\NullObjectInterface */ - $proxy = new $proxyName(); - - $this->assertSame(null, call_user_func_array(array($proxy, $method), $params)); - } - - /** - * @dataProvider getProxyMethods - */ - public function testMethodCallsAfterUnSerialization($className, $instance, $method, $params, $expectedValue) - { - $proxyName = $this->generateProxy($className); - /* @var $proxy \ProxyManager\Proxy\NullObjectInterface */ - $proxy = unserialize(serialize(new $proxyName())); - - $this->assertSame(null, call_user_func_array(array($proxy, $method), $params)); - } - - /** - * @dataProvider getProxyMethods - */ - public function testMethodCallsAfterCloning($className, $instance, $method, $params, $expectedValue) - { - $proxyName = $this->generateProxy($className); - - /* @var $proxy \ProxyManager\Proxy\NullObjectInterface */ - $proxy = new $proxyName(); - $cloned = clone $proxy; - - $this->assertSame(null, call_user_func_array(array($cloned, $method), $params)); - } - - /** - * @dataProvider getPropertyAccessProxies - */ - public function testPropertyReadAccess($instance, $proxy, $publicProperty, $propertyValue) - { - /* @var $proxy \ProxyManager\Proxy\NullObjectInterface */ - $this->assertSame(null, $proxy->$publicProperty); - } - - /** - * @dataProvider getPropertyAccessProxies - */ - public function testPropertyWriteAccess($instance, $proxy, $publicProperty) - { - /* @var $proxy \ProxyManager\Proxy\NullObjectInterface */ - $newValue = uniqid(); - $proxy->$publicProperty = $newValue; - - $this->assertSame($newValue, $proxy->$publicProperty); - } - - /** - * @dataProvider getPropertyAccessProxies - */ - public function testPropertyExistence($instance, $proxy, $publicProperty) - { - /* @var $proxy \ProxyManager\Proxy\NullObjectInterface */ - $this->assertSame(null, $proxy->$publicProperty); - } - - /** - * @dataProvider getPropertyAccessProxies - */ - public function testPropertyUnset($instance, $proxy, $publicProperty) - { - /* @var $proxy \ProxyManager\Proxy\NullObjectInterface */ - unset($proxy->$publicProperty); - - $this->assertTrue(isset($instance->$publicProperty)); - $this->assertFalse(isset($proxy->$publicProperty)); - } - - /** - * Generates a proxy for the given class name, and retrieves its class name - * - * @param string $parentClassName - * - * @return string - */ - private function generateProxy($parentClassName) - { - $generatedClassName = __NAMESPACE__ . '\\' . UniqueIdentifierGenerator::getIdentifier('Foo'); - $generator = new NullObjectGenerator(); - $generatedClass = new ClassGenerator($generatedClassName); - $strategy = new EvaluatingGeneratorStrategy(); - - $generator->generate(new ReflectionClass($parentClassName), $generatedClass); - $strategy->generate($generatedClass); - - return $generatedClassName; - } - - /** - * Generates a list of object | invoked method | parameters | expected result - * - * @return array - */ - public function getProxyMethods() - { - $selfHintParam = new ClassWithSelfHint(); - - $data = array( - array( - 'ProxyManagerTestAsset\\BaseClass', - new BaseClass(), - 'publicMethod', - array(), - 'publicMethodDefault' - ), - array( - 'ProxyManagerTestAsset\\BaseClass', - new BaseClass(), - 'publicTypeHintedMethod', - array('param' => new \stdClass()), - 'publicTypeHintedMethodDefault' - ), - array( - 'ProxyManagerTestAsset\\BaseClass', - new BaseClass(), - 'publicByReferenceMethod', - array(), - 'publicByReferenceMethodDefault' - ), - array( - 'ProxyManagerTestAsset\\BaseInterface', - new BaseClass(), - 'publicMethod', - array(), - 'publicMethodDefault' - ), - ); - - if (PHP_VERSION_ID >= 50401) { - // PHP < 5.4.1 misbehaves, throwing strict standards, see https://bugs.php.net/bug.php?id=60573 - $data[] = array( - 'ProxyManagerTestAsset\\ClassWithSelfHint', - new ClassWithSelfHint(), - 'selfHintMethod', - array('parameter' => $selfHintParam), - $selfHintParam - ); - } - - return $data; - } - - /** - * Generates proxies and instances with a public property to feed to the property accessor methods - * - * @return array - */ - public function getPropertyAccessProxies() - { - $instance1 = new BaseClass(); - $proxyName1 = $this->generateProxy(get_class($instance1)); - $instance2 = new BaseClass(); - $proxyName2 = $this->generateProxy(get_class($instance2)); - - return array( - array( - $instance1, - new $proxyName1($instance1), - 'publicProperty', - 'publicPropertyDefault', - ), - array( - $instance2, - unserialize(serialize(new $proxyName2($instance2))), - 'publicProperty', - 'publicPropertyDefault', - ), - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/RemoteObjectFunctionalTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/RemoteObjectFunctionalTest.php deleted file mode 100644 index b5d9c95..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Functional/RemoteObjectFunctionalTest.php +++ /dev/null @@ -1,231 +0,0 @@ - - * @license MIT - * - * @group Functional - * @coversNothing - */ -class RemoteObjectFunctionalTest extends PHPUnit_Framework_TestCase -{ - /** - * @param mixed $expectedValue - * @param string $method - * @param array $params - * - * @return XmlRpcAdapter - */ - protected function getXmlRpcAdapter($expectedValue, $method, array $params) - { - $client = $this - ->getMockBuilder('Zend\Server\Client') - ->setMethods(array('call')) - ->getMock(); - - $client - ->expects($this->any()) - ->method('call') - ->with($this->stringEndsWith($method), $params) - ->will($this->returnValue($expectedValue)); - - $adapter = new XmlRpcAdapter( - $client, - array( - 'ProxyManagerTestAsset\RemoteProxy\Foo.foo' - => 'ProxyManagerTestAsset\RemoteProxy\FooServiceInterface.foo' - ) - ); - - return $adapter; - } - - /** - * @param mixed $expectedValue - * @param string $method - * @param array $params - * - * @return JsonRpcAdapter - */ - protected function getJsonRpcAdapter($expectedValue, $method, array $params) - { - $client = $this - ->getMockBuilder('Zend\Server\Client') - ->setMethods(array('call')) - ->getMock(); - - $client - ->expects($this->any()) - ->method('call') - ->with($this->stringEndsWith($method), $params) - ->will($this->returnValue($expectedValue)); - - $adapter = new JsonRpcAdapter( - $client, - array( - 'ProxyManagerTestAsset\RemoteProxy\Foo.foo' - => 'ProxyManagerTestAsset\RemoteProxy\FooServiceInterface.foo' - ) - ); - - return $adapter; - } - - /** - * @dataProvider getProxyMethods - */ - public function testXmlRpcMethodCalls($instanceOrClassname, $method, $params, $expectedValue) - { - $proxyName = $this->generateProxy($instanceOrClassname); - - /* @var $proxy \ProxyManager\Proxy\RemoteObjectInterface */ - $proxy = new $proxyName($this->getXmlRpcAdapter($expectedValue, $method, $params)); - - $this->assertSame($expectedValue, call_user_func_array(array($proxy, $method), $params)); - } - - /** - * @dataProvider getProxyMethods - */ - public function testJsonRpcMethodCalls($instanceOrClassname, $method, $params, $expectedValue) - { - $proxyName = $this->generateProxy($instanceOrClassname); - - /* @var $proxy \ProxyManager\Proxy\RemoteObjectInterface */ - $proxy = new $proxyName($this->getJsonRpcAdapter($expectedValue, $method, $params)); - - $this->assertSame($expectedValue, call_user_func_array(array($proxy, $method), $params)); - } - - /** - * @dataProvider getPropertyAccessProxies - */ - public function testJsonRpcPropertyReadAccess($instanceOrClassname, $publicProperty, $propertyValue) - { - $proxyName = $this->generateProxy($instanceOrClassname); - - /* @var $proxy \ProxyManager\Proxy\RemoteObjectInterface */ - $proxy = new $proxyName( - $this->getJsonRpcAdapter($propertyValue, '__get', array($publicProperty)) - ); - - /* @var $proxy \ProxyManager\Proxy\NullObjectInterface */ - $this->assertSame($propertyValue, $proxy->$publicProperty); - } - - /** - * Generates a proxy for the given class name, and retrieves its class name - * - * @param string $parentClassName - * - * @return string - */ - private function generateProxy($parentClassName) - { - $generatedClassName = __NAMESPACE__ . '\\' . UniqueIdentifierGenerator::getIdentifier('Foo'); - $generator = new RemoteObjectGenerator(); - $generatedClass = new ClassGenerator($generatedClassName); - $strategy = new EvaluatingGeneratorStrategy(); - - $generator->generate(new ReflectionClass($parentClassName), $generatedClass); - $strategy->generate($generatedClass); - - return $generatedClassName; - } - - /** - * Generates a list of object | invoked method | parameters | expected result - * - * @return array - */ - public function getProxyMethods() - { - $selfHintParam = new ClassWithSelfHint(); - - $data = array( - array( - 'ProxyManagerTestAsset\RemoteProxy\FooServiceInterface', - 'foo', - array(), - 'bar remote' - ), - array( - 'ProxyManagerTestAsset\RemoteProxy\Foo', - 'foo', - array(), - 'bar remote' - ), - array( - new Foo(), - 'foo', - array(), - 'bar remote' - ), - array( - 'ProxyManagerTestAsset\RemoteProxy\BazServiceInterface', - 'baz', - array('baz'), - 'baz remote' - ), - ); - - if (PHP_VERSION_ID >= 50401) { - // PHP < 5.4.1 misbehaves, throwing strict standards, see https://bugs.php.net/bug.php?id=60573 - $data[] = array( - new ClassWithSelfHint(), - 'selfHintMethod', - array($selfHintParam), - $selfHintParam - ); - } - - return $data; - } - - /** - * Generates proxies and instances with a public property to feed to the property accessor methods - * - * @return array - */ - public function getPropertyAccessProxies() - { - return array( - array( - 'ProxyManagerTestAsset\RemoteProxy\FooServiceInterface', - 'publicProperty', - 'publicProperty remote', - ), - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Generator/ClassGeneratorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Generator/ClassGeneratorTest.php deleted file mode 100644 index c00f849..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Generator/ClassGeneratorTest.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class ClassGeneratorTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\Generator\ClassGenerator::setExtendedClass - */ - public function testExtendedClassesAreFQCNs() - { - $desiredFqcn = '\\stdClass'; - $classNameInputs = array('stdClass', '\\stdClass\\'); - - foreach ($classNameInputs as $className) { - $classGenerator = new ClassGenerator(); - $classGenerator->setExtendedClass($className); - - $this->assertEquals($desiredFqcn, $classGenerator->getExtendedClass()); - } - } - - /** - * @covers \ProxyManager\Generator\ClassGenerator::setImplementedInterfaces - */ - public function testImplementedInterfacesAreFQCNs() - { - $desiredFqcns = array('\\Countable'); - $interfaceNameInputs = array(array('Countable'), array('\\Countable\\')); - - foreach ($interfaceNameInputs as $interfaceNames) { - $classGenerator = new ClassGenerator(); - $classGenerator->setImplementedInterfaces($interfaceNames); - - $this->assertEquals($desiredFqcns, $classGenerator->getImplementedInterfaces()); - } - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Generator/MagicMethodGeneratorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Generator/MagicMethodGeneratorTest.php deleted file mode 100644 index c5ae31a..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Generator/MagicMethodGeneratorTest.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class MagicMethodGeneratorTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\Generator\MagicMethodGenerator::__construct - */ - public function testGeneratesCorrectByRefReturnValue() - { - $reflection = new ReflectionClass('ProxyManagerTestAsset\\ClassWithByRefMagicMethods'); - $magicMethod = new MagicMethodGenerator($reflection, '__get', array('name')); - - $this->assertTrue($magicMethod->returnsReference()); - } - - /** - * @covers \ProxyManager\Generator\MagicMethodGenerator::__construct - */ - public function testGeneratesCorrectByValReturnValue() - { - $reflection = new ReflectionClass('ProxyManagerTestAsset\\ClassWithMagicMethods'); - $magicMethod = new MagicMethodGenerator($reflection, '__get', array('name')); - - $this->assertFalse($magicMethod->returnsReference()); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Generator/MethodGeneratorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Generator/MethodGeneratorTest.php deleted file mode 100644 index 4c2306a..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Generator/MethodGeneratorTest.php +++ /dev/null @@ -1,97 +0,0 @@ - - * @license MIT - * - * @covers \ProxyManager\Generator\MethodGenerator - * @group Coverage - */ -class MethodGeneratorTest extends PHPUnit_Framework_TestCase -{ - public function testGenerateSimpleMethod() - { - $methodGenerator = new MethodGenerator(); - - $methodGenerator->setReturnsReference(true); - $methodGenerator->setName('methodName'); - $methodGenerator->setVisibility('protected'); - $methodGenerator->setBody('/* body */'); - $methodGenerator->setDocBlock('docBlock'); - $methodGenerator->setParameter(new ParameterGenerator('foo')); - - $this->assertSame(true, $methodGenerator->returnsReference()); - $this->assertStringMatchesFormat( - '%a/**%adocBlock%a*/%aprotected function & methodName($foo)%a{%a/* body */%a}', - $methodGenerator->generate() - ); - } - - /** - * Verify that building from reflection works - */ - public function testGenerateFromReflection() - { - $method = MethodGenerator::fromReflection(new MethodReflection(__CLASS__, __FUNCTION__)); - - $this->assertSame(__FUNCTION__, $method->getName()); - $this->assertSame(MethodGenerator::VISIBILITY_PUBLIC, $method->getVisibility()); - $this->assertFalse($method->isStatic()); - $this->assertSame('Verify that building from reflection works', $method->getDocBlock()->getShortDescription()); - - $method = MethodGenerator::fromReflection( - new MethodReflection('ProxyManagerTestAsset\\BaseClass', 'protectedMethod') - ); - - $this->assertSame(MethodGenerator::VISIBILITY_PROTECTED, $method->getVisibility()); - - $method = MethodGenerator::fromReflection( - new MethodReflection('ProxyManagerTestAsset\\BaseClass', 'privateMethod') - ); - - $this->assertSame(MethodGenerator::VISIBILITY_PRIVATE, $method->getVisibility()); - } - - public function testGeneratedParametersFromReflection() - { - $method = MethodGenerator::fromReflection(new MethodReflection( - 'ProxyManagerTestAsset\\BaseClass', - 'publicTypeHintedMethod' - )); - - $this->assertSame('publicTypeHintedMethod', $method->getName()); - - $parameters = $method->getParameters(); - - $this->assertCount(1, $parameters); - - $param = $parameters['param']; - - $this->assertSame('stdClass', $param->getType()); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Generator/ParameterGeneratorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Generator/ParameterGeneratorTest.php deleted file mode 100644 index a67f225..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Generator/ParameterGeneratorTest.php +++ /dev/null @@ -1,146 +0,0 @@ - - * @license MIT - * - * @covers \ProxyManager\Generator\ParameterGenerator - * @group Coverage - */ -class ParameterGeneratorTest extends PHPUnit_Framework_TestCase -{ - public function testGeneratesProperTypeHint() - { - $generator = new ParameterGenerator('foo'); - - $generator->setType('array'); - $this->assertSame('array $foo', $generator->generate()); - - $generator->setType('stdClass'); - $this->assertSame('\\stdClass $foo', $generator->generate()); - - $generator->setType('\\fooClass'); - $this->assertSame('\\fooClass $foo', $generator->generate()); - } - - public function testGeneratesMethodWithCallableType() - { - if (PHP_VERSION_ID < 50400) { - $this->markTestSkipped('`callable` is only supported in PHP >=5.4.0'); - } - - $generator = new ParameterGenerator(); - - $generator->setType('callable'); - $generator->setName('foo'); - - $this->assertSame('callable $foo', $generator->generate()); - } - - public function testVisitMethodWithCallable() - { - if (PHP_VERSION_ID < 50400) { - $this->markTestSkipped('`callable` is only supported in PHP >=5.4.0'); - } - - $parameter = new ParameterReflection( - array('ProxyManagerTestAsset\\CallableTypeHintClass', 'callableTypeHintMethod'), - 'parameter' - ); - - $generator = ParameterGenerator::fromReflection($parameter); - - $this->assertSame('callable', $generator->getType()); - } - - public function testReadsParameterDefaults() - { - $parameter = ParameterGenerator::fromReflection(new ParameterReflection( - array( - 'ProxyManagerTestAsset\\ClassWithMethodWithDefaultParameters', - 'publicMethodWithDefaults' - ), - 'parameter' - )); - - /* @var $defaultValue \Zend\Code\Generator\ValueGenerator */ - $defaultValue = $parameter->getDefaultValue(); - - $this->assertInstanceOf('Zend\\Code\\Generator\\ValueGenerator', $defaultValue); - $this->assertSame(array('foo'), $defaultValue->getValue()); - - $this->assertStringMatchesFormat('array%a$parameter%a=%aarray(\'foo\')', $parameter->generate()); - } - - public function testReadsParameterTypeHint() - { - $parameter = ParameterGenerator::fromReflection(new ParameterReflection( - array('ProxyManagerTestAsset\\BaseClass', 'publicTypeHintedMethod'), - 'param' - )); - - $this->assertSame('stdClass', $parameter->getType()); - } - - public function testGeneratesParameterPassedByReference() - { - $parameter = new ParameterGenerator('foo'); - - $parameter->setPassedByReference(true); - - $this->assertStringMatchesFormat('&%A$foo', $parameter->generate()); - } - - public function testGeneratesDefaultParameterForInternalPhpClasses() - { - $parameter = ParameterGenerator::fromReflection(new ParameterReflection( - array( - 'Phar', - 'compress' - ), - 1 - )); - - $this->assertSame('null', strtolower((string) $parameter->getDefaultValue())); - } - - public function testGeneratedParametersAreProperlyEscaped() - { - $parameter = new ParameterGenerator(); - - $parameter->setName('foo'); - $parameter->setDefaultValue('\'bar\\baz'); - - $this->assertThat( - $parameter->generate(), - $this->logicalOr( - $this->equalTo('$foo = \'\\\'bar\\baz\''), - $this->equalTo('$foo = \'\\\'bar\\\\baz\'') - ) - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Generator/Util/ClassGeneratorUtilsTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Generator/Util/ClassGeneratorUtilsTest.php deleted file mode 100644 index cf52546..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Generator/Util/ClassGeneratorUtilsTest.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @license MIT - * - * @covers ProxyManager\Generator\Util\ClassGeneratorUtils - */ -class ClassGeneratorUtilsTest extends PHPUnit_Framework_TestCase -{ - public function testCantAddAFinalMethod() - { - $classGenerator = $this->getMock('Zend\\Code\\Generator\\ClassGenerator'); - $methodGenerator = $this->getMock('Zend\\Code\\Generator\\MethodGenerator'); - - $methodGenerator - ->expects($this->once()) - ->method('getName') - ->willReturn('foo'); - - $classGenerator - ->expects($this->never()) - ->method('addMethodFromGenerator'); - - $reflection = new ReflectionClass('ProxyManagerTestAsset\\ClassWithFinalMethods'); - - ClassGeneratorUtils::addMethodIfNotFinal($reflection, $classGenerator, $methodGenerator); - } - - public function testCanAddANotFinalMethod() - { - $classGenerator = $this->getMock('Zend\\Code\\Generator\\ClassGenerator'); - $methodGenerator = $this->getMock('Zend\\Code\\Generator\\MethodGenerator'); - - $methodGenerator - ->expects($this->once()) - ->method('getName') - ->willReturn('publicMethod'); - - $classGenerator - ->expects($this->once()) - ->method('addMethodFromGenerator'); - - $reflection = new ReflectionClass('ProxyManagerTestAsset\\BaseClass'); - - ClassGeneratorUtils::addMethodIfNotFinal($reflection, $classGenerator, $methodGenerator); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Generator/Util/UniqueIdentifierGeneratorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Generator/Util/UniqueIdentifierGeneratorTest.php deleted file mode 100644 index 5f4e8ec..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Generator/Util/UniqueIdentifierGeneratorTest.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class UniqueIdentifierGeneratorTest extends PHPUnit_Framework_TestCase -{ - /** - * @dataProvider getBaseIdentifierNames - * - * @covers \ProxyManager\Generator\Util\UniqueIdentifierGenerator::getIdentifier - */ - public function testGeneratesUniqueIdentifiers($name) - { - $this->assertNotSame( - UniqueIdentifierGenerator::getIdentifier($name), - UniqueIdentifierGenerator::getIdentifier($name) - ); - } - - /** - * @dataProvider getBaseIdentifierNames - * - * @covers \ProxyManager\Generator\Util\UniqueIdentifierGenerator::getIdentifier - */ - public function testGeneratesValidIdentifiers($name) - { - $this->assertRegExp( - '/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]+$/', - UniqueIdentifierGenerator::getIdentifier($name) - ); - } - - /** - * Data provider generating identifier names to be checked - * - * @return string[][] - */ - public function getBaseIdentifierNames() - { - return array( - array(''), - array('1'), - array('foo'), - array('Foo'), - array('bar'), - array('Bar'), - array('foo_bar'), - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/GeneratorStrategy/BaseGeneratorStrategyTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/GeneratorStrategy/BaseGeneratorStrategyTest.php deleted file mode 100644 index d2366a2..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/GeneratorStrategy/BaseGeneratorStrategyTest.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class BaseGeneratorStrategyTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\GeneratorStrategy\BaseGeneratorStrategy::generate - */ - public function testGenerate() - { - $strategy = new BaseGeneratorStrategy(); - $className = UniqueIdentifierGenerator::getIdentifier('Foo'); - $classGenerator = new ClassGenerator($className); - $generated = $strategy->generate($classGenerator); - - $this->assertGreaterThan(0, strpos($generated, $className)); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/GeneratorStrategy/EvaluatingGeneratorStrategyTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/GeneratorStrategy/EvaluatingGeneratorStrategyTest.php deleted file mode 100644 index 90d22ce..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/GeneratorStrategy/EvaluatingGeneratorStrategyTest.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class EvaluatingGeneratorStrategyTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\GeneratorStrategy\EvaluatingGeneratorStrategy::generate - * @covers \ProxyManager\GeneratorStrategy\EvaluatingGeneratorStrategy::__construct - */ - public function testGenerate() - { - $strategy = new EvaluatingGeneratorStrategy(); - $className = UniqueIdentifierGenerator::getIdentifier('Foo'); - $classGenerator = new ClassGenerator($className); - $generated = $strategy->generate($classGenerator); - - $this->assertGreaterThan(0, strpos($generated, $className)); - $this->assertTrue(class_exists($className, false)); - } - - /** - * @covers \ProxyManager\GeneratorStrategy\EvaluatingGeneratorStrategy::generate - * @covers \ProxyManager\GeneratorStrategy\EvaluatingGeneratorStrategy::__construct - */ - public function testGenerateWithDisabledEval() - { - if (! ini_get('suhosin.executor.disable_eval')) { - $this->markTestSkipped('Ini setting "suhosin.executor.disable_eval" is needed to run this test'); - } - - $strategy = new EvaluatingGeneratorStrategy(); - $className = 'Foo' . uniqid(); - $classGenerator = new ClassGenerator($className); - $generated = $strategy->generate($classGenerator); - - $this->assertGreaterThan(0, strpos($generated, $className)); - $this->assertTrue(class_exists($className, false)); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/GeneratorStrategy/FileWriterGeneratorStrategyTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/GeneratorStrategy/FileWriterGeneratorStrategyTest.php deleted file mode 100644 index 03eef8a..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/GeneratorStrategy/FileWriterGeneratorStrategyTest.php +++ /dev/null @@ -1,148 +0,0 @@ - - * @license MIT - * - * @group Coverage - * - * Note: this test generates temporary files that are not deleted - */ -class FileWriterGeneratorStrategyTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\GeneratorStrategy\FileWriterGeneratorStrategy::__construct - * @covers \ProxyManager\GeneratorStrategy\FileWriterGeneratorStrategy::generate - */ - public function testGenerate() - { - /* @var $locator \ProxyManager\FileLocator\FileLocatorInterface|\PHPUnit_Framework_MockObject_MockObject */ - $locator = $this->getMock('ProxyManager\\FileLocator\\FileLocatorInterface'); - $generator = new FileWriterGeneratorStrategy($locator); - $tmpFile = sys_get_temp_dir() . '/' . uniqid('FileWriterGeneratorStrategyTest', true) . '.php'; - $namespace = 'Foo'; - $className = UniqueIdentifierGenerator::getIdentifier('Bar'); - $fqcn = $namespace . '\\' . $className; - - $locator - ->expects($this->any()) - ->method('getProxyFileName') - ->with($fqcn) - ->will($this->returnValue($tmpFile)); - - $body = $generator->generate(new ClassGenerator($fqcn)); - - $this->assertGreaterThan(0, strpos($body, $className)); - $this->assertFalse(class_exists($fqcn, false)); - $this->assertTrue(file_exists($tmpFile)); - - require $tmpFile; - - $this->assertTrue(class_exists($fqcn, false)); - } - - public function testGenerateWillFailIfTmpFileCannotBeWrittenToDisk() - { - $tmpDirPath = sys_get_temp_dir() . '/' . uniqid('nonWritable', true); - - mkdir($tmpDirPath, 0555, true); - - /* @var $locator \ProxyManager\FileLocator\FileLocatorInterface|\PHPUnit_Framework_MockObject_MockObject */ - $locator = $this->getMock('ProxyManager\\FileLocator\\FileLocatorInterface'); - $generator = new FileWriterGeneratorStrategy($locator); - $tmpFile = $tmpDirPath . '/' . uniqid('FileWriterGeneratorStrategyFailedFileWriteTest', true) . '.php'; - $namespace = 'Foo'; - $className = UniqueIdentifierGenerator::getIdentifier('Bar'); - $fqcn = $namespace . '\\' . $className; - - $locator - ->expects($this->any()) - ->method('getProxyFileName') - ->with($fqcn) - ->will($this->returnValue($tmpFile)); - - $this->setExpectedException('ProxyManager\\Exception\\FileNotWritableException'); - $generator->generate(new ClassGenerator($fqcn)); - } - - public function testGenerateWillFailIfTmpFileCannotBeMovedToFinalDestination() - { - /* @var $locator \ProxyManager\FileLocator\FileLocatorInterface|\PHPUnit_Framework_MockObject_MockObject */ - $locator = $this->getMock('ProxyManager\\FileLocator\\FileLocatorInterface'); - $generator = new FileWriterGeneratorStrategy($locator); - $tmpFile = sys_get_temp_dir() . '/' . uniqid('FileWriterGeneratorStrategyFailedFileMoveTest', true) . '.php'; - $namespace = 'Foo'; - $className = UniqueIdentifierGenerator::getIdentifier('Bar'); - $fqcn = $namespace . '\\' . $className; - - $locator - ->expects($this->any()) - ->method('getProxyFileName') - ->with($fqcn) - ->will($this->returnValue($tmpFile)); - - mkdir($tmpFile); - - $this->setExpectedException('ProxyManager\\Exception\\FileNotWritableException'); - $generator->generate(new ClassGenerator($fqcn)); - } - - public function testWhenFailingAllTemporaryFilesAreRemoved() - { - $tmpDirPath = sys_get_temp_dir() . '/' . uniqid('noTempFilesLeftBehind', true); - - mkdir($tmpDirPath); - - /* @var $locator \ProxyManager\FileLocator\FileLocatorInterface|\PHPUnit_Framework_MockObject_MockObject */ - $locator = $this->getMock('ProxyManager\\FileLocator\\FileLocatorInterface'); - $generator = new FileWriterGeneratorStrategy($locator); - $tmpFile = $tmpDirPath . '/' . uniqid('FileWriterGeneratorStrategyFailedFileMoveTest', true) . '.php'; - $namespace = 'Foo'; - $className = UniqueIdentifierGenerator::getIdentifier('Bar'); - $fqcn = $namespace . '\\' . $className; - - $locator - ->expects($this->any()) - ->method('getProxyFileName') - ->with($fqcn) - ->will($this->returnValue($tmpFile)); - - mkdir($tmpFile); - - try { - $generator->generate(new ClassGenerator($fqcn)); - - $this->fail('An exception was supposed to be thrown'); - } catch (FileNotWritableException $exception) { - rmdir($tmpFile); - - $this->assertEquals(array('.', '..'), scandir($tmpDirPath)); - } - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Inflector/ClassNameInflectorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Inflector/ClassNameInflectorTest.php deleted file mode 100644 index b95d7f2..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Inflector/ClassNameInflectorTest.php +++ /dev/null @@ -1,161 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class ClassNameInflectorTest extends PHPUnit_Framework_TestCase -{ - /** - * @dataProvider getClassNames - * - * @covers \ProxyManager\Inflector\ClassNameInflector::__construct - * @covers \ProxyManager\Inflector\ClassNameInflector::getUserClassName - * @covers \ProxyManager\Inflector\ClassNameInflector::getProxyClassName - * @covers \ProxyManager\Inflector\ClassNameInflector::isProxyClassName - */ - public function testInflector($realClassName, $proxyClassName) - { - $inflector = new ClassNameInflector('ProxyNS'); - - $this->assertFalse($inflector->isProxyClassName($realClassName)); - $this->assertTrue($inflector->isProxyClassName($proxyClassName)); - $this->assertStringMatchesFormat($realClassName, $inflector->getUserClassName($realClassName)); - $this->assertStringMatchesFormat($proxyClassName, $inflector->getProxyClassName($proxyClassName)); - $this->assertStringMatchesFormat($proxyClassName, $inflector->getProxyClassName($realClassName)); - $this->assertStringMatchesFormat($realClassName, $inflector->getUserClassName($proxyClassName)); - } - - /** - * @covers \ProxyManager\Inflector\ClassNameInflector::getProxyClassName - */ - public function testGeneratesSameClassNameWithSameParameters() - { - $inflector = new ClassNameInflector('ProxyNS'); - - $this->assertSame($inflector->getProxyClassName('Foo\\Bar'), $inflector->getProxyClassName('Foo\\Bar')); - $this->assertSame( - $inflector->getProxyClassName('Foo\\Bar', array('baz' => 'tab')), - $inflector->getProxyClassName('Foo\\Bar', array('baz' => 'tab')) - ); - $this->assertSame( - $inflector->getProxyClassName('Foo\\Bar', array('tab' => 'baz')), - $inflector->getProxyClassName('Foo\\Bar', array('tab' => 'baz')) - ); - } - - /** - * @covers \ProxyManager\Inflector\ClassNameInflector::getProxyClassName - */ - public function testGeneratesDifferentClassNameWithDifferentParameters() - { - $inflector = new ClassNameInflector('ProxyNS'); - - $this->assertNotSame( - $inflector->getProxyClassName('Foo\\Bar'), - $inflector->getProxyClassName('Foo\\Bar', array('foo' => 'bar')) - ); - $this->assertNotSame( - $inflector->getProxyClassName('Foo\\Bar', array('baz' => 'tab')), - $inflector->getProxyClassName('Foo\\Bar', array('tab' => 'baz')) - ); - $this->assertNotSame( - $inflector->getProxyClassName('Foo\\Bar', array('foo' => 'bar', 'tab' => 'baz')), - $inflector->getProxyClassName('Foo\\Bar', array('foo' => 'bar')) - ); - $this->assertNotSame( - $inflector->getProxyClassName('Foo\\Bar', array('foo' => 'bar', 'tab' => 'baz')), - $inflector->getProxyClassName('Foo\\Bar', array('tab' => 'baz', 'foo' => 'bar')) - ); - } - - /** - * @covers \ProxyManager\Inflector\ClassNameInflector::getProxyClassName - */ - public function testGeneratesCorrectClassNameWhenGivenLeadingBackslash() - { - $inflector = new ClassNameInflector('ProxyNS'); - - $this->assertSame( - $inflector->getProxyClassName('\\Foo\\Bar', array('tab' => 'baz')), - $inflector->getProxyClassName('Foo\\Bar', array('tab' => 'baz')) - ); - } - - /** - * @covers \ProxyManager\Inflector\ClassNameInflector::getProxyClassName - * - * @dataProvider getClassAndParametersCombinations - * - * @param string $className - * @param array $parameters - */ - public function testClassNameIsValidClassIdentifier($className, array $parameters) - { - $inflector = new ClassNameInflector('ProxyNS'); - - $this->assertRegExp( - '/([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]+)(\\\\[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]+)*/', - $inflector->getProxyClassName($className, $parameters), - 'Class name string is a valid class identifier' - ); - } - - /** - * Data provider. - * - * @return array[] - */ - public function getClassNames() - { - return array( - array('Foo', 'ProxyNS\\' . ClassNameInflectorInterface::PROXY_MARKER . '\\Foo\\%s'), - array('Foo\\Bar', 'ProxyNS\\' . ClassNameInflectorInterface::PROXY_MARKER . '\\Foo\\Bar\\%s'), - ); - } - - /** - * Data provider. - * - * @return array[] - */ - public function getClassAndParametersCombinations() - { - return array( - array('Foo', array()), - array('Foo\\Bar', array()), - array('Foo', array(null)), - array('Foo\\Bar', array(null)), - array('Foo', array('foo' => 'bar')), - array('Foo\\Bar', array('foo' => 'bar')), - array('Foo', array("\0" => "very \0 bad")), - array('Foo\\Bar', array("\0" => "very \0 bad")), - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Inflector/Util/ParameterEncoderTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Inflector/Util/ParameterEncoderTest.php deleted file mode 100644 index 1acd28e..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Inflector/Util/ParameterEncoderTest.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class ParameterEncoderTest extends PHPUnit_Framework_TestCase -{ - /** - * @dataProvider getParameters - * - * @covers \ProxyManager\Inflector\Util\ParameterEncoder::encodeParameters - */ - public function testGeneratesValidClassName(array $parameters) - { - $encoder = new ParameterEncoder(); - - $this->assertRegExp( - '/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]+/', - $encoder->encodeParameters($parameters), - 'Encoded string is a valid class identifier' - ); - } - - /** - * @return array - */ - public function getParameters() - { - return array( - array(array()), - array(array('foo' => 'bar')), - array(array('bar' => 'baz')), - array(array(null)), - array(array(null, null)), - array(array('bar' => null)), - array(array('bar' => 12345)), - array(array('foo' => 'bar', 'bar' => 'baz')), - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Inflector/Util/ParameterHasherTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Inflector/Util/ParameterHasherTest.php deleted file mode 100644 index 22bf68d..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Inflector/Util/ParameterHasherTest.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class ParameterHasherTest extends PHPUnit_Framework_TestCase -{ - /** - * @dataProvider getParameters - * - * @covers \ProxyManager\Inflector\Util\ParameterHasher::hashParameters - */ - public function testGeneratesValidClassName(array $parameters, $expectedHash) - { - $encoder = new ParameterHasher(); - - $this->assertSame($expectedHash, $encoder->hashParameters($parameters)); - } - - /** - * @return array - */ - public function getParameters() - { - return array( - array(array(), '40cd750bba9870f18aada2478b24840a'), - array(array('foo' => 'bar'), '49a3696adf0fbfacc12383a2d7400d51'), - array(array('bar' => 'baz'), '6ed41c8a63c1571554ecaeb998198757'), - array(array(null), '38017a839aaeb8ff1a658fce9af6edd3'), - array(array(null, null), '12051f9a58288e5328ad748881cc4e00'), - array(array('bar' => null), '0dbb112e1c4e6e4126232de2daa2d660'), - array(array('bar' => 12345), 'eb6291ea4973741bf9b6571f49b4ffd2'), - array(array('foo' => 'bar', 'bar' => 'baz'), '4447ff857f244d24c31bd84d7a855eda'), - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AbstractProxyGeneratorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AbstractProxyGeneratorTest.php deleted file mode 100644 index 307aafc..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AbstractProxyGeneratorTest.php +++ /dev/null @@ -1,95 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -abstract class AbstractProxyGeneratorTest extends PHPUnit_Framework_TestCase -{ - /** - * @dataProvider getTestedImplementations - * - * Verifies that generated code is valid and implements expected interfaces - */ - public function testGeneratesValidCode($className) - { - $generator = $this->getProxyGenerator(); - $generatedClassName = UniqueIdentifierGenerator::getIdentifier('AbstractProxyGeneratorTest'); - $generatedClass = new ClassGenerator($generatedClassName); - $originalClass = new ReflectionClass($className); - $generatorStrategy = new EvaluatingGeneratorStrategy(); - - $generator->generate($originalClass, $generatedClass); - $generatorStrategy->generate($generatedClass); - - $generatedReflection = new ReflectionClass($generatedClassName); - - if ($originalClass->isInterface()) { - $this->assertTrue($generatedReflection->implementsInterface($className)); - } else { - $this->assertSame($originalClass->getName(), $generatedReflection->getParentClass()->getName()); - } - - $this->assertSame($generatedClassName, $generatedReflection->getName()); - - foreach ($this->getExpectedImplementedInterfaces() as $interface) { - $this->assertTrue($generatedReflection->implementsInterface($interface)); - } - } - - /** - * Retrieve a new generator instance - * - * @return \ProxyManager\ProxyGenerator\ProxyGeneratorInterface - */ - abstract protected function getProxyGenerator(); - - /** - * Retrieve interfaces that should be implemented by the generated code - * - * @return string[] - */ - abstract protected function getExpectedImplementedInterfaces(); - - /** - * @return array - */ - public function getTestedImplementations() - { - return array( - array('ProxyManagerTestAsset\\BaseClass'), - array('ProxyManagerTestAsset\\ClassWithMagicMethods'), - array('ProxyManagerTestAsset\\ClassWithByRefMagicMethods'), - array('ProxyManagerTestAsset\\ClassWithMixedProperties'), - array('ProxyManagerTestAsset\\BaseInterface'), - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptor/MethodGenerator/MagicWakeupTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptor/MethodGenerator/MagicWakeupTest.php deleted file mode 100644 index a5c5bec..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptor/MethodGenerator/MagicWakeupTest.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class MagicWakeupTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\AccessInterceptor\MethodGenerator\MagicWakeup::__construct - */ - public function testBodyStructure() - { - $reflection = new ReflectionClass( - 'ProxyManagerTestAsset\\ProxyGenerator\\LazyLoading\\MethodGenerator\\ClassWithTwoPublicProperties' - ); - - $magicWakeup = new MagicWakeup($reflection); - - $this->assertSame('__wakeup', $magicWakeup->getName()); - $this->assertCount(0, $magicWakeup->getParameters()); - $this->assertSame("unset(\$this->bar, \$this->baz);", $magicWakeup->getBody()); - } - - /** - * @covers \ProxyManager\ProxyGenerator\AccessInterceptor\MethodGenerator\MagicWakeup::__construct - */ - public function testBodyStructureWithoutPublicProperties() - { - $magicWakeup = new MagicWakeup(new ReflectionClass('ProxyManagerTestAsset\\EmptyClass')); - - $this->assertSame('__wakeup', $magicWakeup->getName()); - $this->assertCount(0, $magicWakeup->getParameters()); - $this->assertEmpty($magicWakeup->getBody()); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptor/MethodGenerator/SetMethodPrefixInterceptorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptor/MethodGenerator/SetMethodPrefixInterceptorTest.php deleted file mode 100644 index e35c993..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptor/MethodGenerator/SetMethodPrefixInterceptorTest.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class SetMethodPrefixInterceptorTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\AccessInterceptor\MethodGenerator\SetMethodPrefixInterceptor::__construct - */ - public function testBodyStructure() - { - $suffix = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - - $suffix->expects($this->once())->method('getName')->will($this->returnValue('foo')); - - $setter = new SetMethodPrefixInterceptor($suffix); - - $this->assertSame('setMethodPrefixInterceptor', $setter->getName()); - $this->assertCount(2, $setter->getParameters()); - $this->assertSame('$this->foo[$methodName] = $prefixInterceptor;', $setter->getBody()); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptor/MethodGenerator/SetMethodSuffixInterceptorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptor/MethodGenerator/SetMethodSuffixInterceptorTest.php deleted file mode 100644 index db65647..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptor/MethodGenerator/SetMethodSuffixInterceptorTest.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class SetMethodSuffixInterceptorTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\AccessInterceptor\MethodGenerator\SetMethodSuffixInterceptor::__construct - */ - public function testBodyStructure() - { - $suffix = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - - $suffix->expects($this->once())->method('getName')->will($this->returnValue('foo')); - - $setter = new SetMethodSuffixInterceptor($suffix); - - $this->assertSame('setMethodSuffixInterceptor', $setter->getName()); - $this->assertCount(2, $setter->getParameters()); - $this->assertSame('$this->foo[$methodName] = $suffixInterceptor;', $setter->getBody()); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptor/PropertyGenerator/MethodPrefixInterceptorsTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptor/PropertyGenerator/MethodPrefixInterceptorsTest.php deleted file mode 100644 index 9b6de3d..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptor/PropertyGenerator/MethodPrefixInterceptorsTest.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @license MIT - * - * @covers \ProxyManager\ProxyGenerator\AccessInterceptor\PropertyGenerator\MethodPrefixInterceptors - * @group Coverage - */ -class MethodPrefixInterceptorsTest extends AbstractUniquePropertyNameTest -{ - /** - * {@inheritDoc} - */ - protected function createProperty() - { - return new MethodPrefixInterceptors(); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptor/PropertyGenerator/MethodSuffixInterceptorsTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptor/PropertyGenerator/MethodSuffixInterceptorsTest.php deleted file mode 100644 index 7515bad..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptor/PropertyGenerator/MethodSuffixInterceptorsTest.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @license MIT - * - * @covers \ProxyManager\ProxyGenerator\AccessInterceptor\PropertyGenerator\MethodSuffixInterceptors - * @group Coverage - */ -class MethodSuffixInterceptorsTest extends AbstractUniquePropertyNameTest -{ - /** - * {@inheritDoc} - */ - protected function createProperty() - { - return new MethodSuffixInterceptors(); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/ConstructorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/ConstructorTest.php deleted file mode 100644 index a1b5c12..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/ConstructorTest.php +++ /dev/null @@ -1,207 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class ConstructorTest extends PHPUnit_Framework_TestCase -{ - private $prefixInterceptors; - private $suffixInterceptors; - public function setUp() - { - $this->prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $this->suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - - $this->prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); - $this->suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); - } - - /** - * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\Constructor::__construct - */ - public function testSignature() - { - $constructor = new Constructor( - new ReflectionClass('ProxyManagerTestAsset\\ClassWithProtectedProperties'), - $this->prefixInterceptors, - $this->suffixInterceptors - ); - $this->assertSame('__construct', $constructor->getName()); - - $parameters = $constructor->getParameters(); - - $this->assertCount(3, $parameters); - - $this->assertSame( - 'ProxyManagerTestAsset\\ClassWithProtectedProperties', - $parameters['localizedObject']->getType() - ); - $this->assertSame('array', $parameters['prefixInterceptors']->getType()); - $this->assertSame('array', $parameters['suffixInterceptors']->getType()); - } - - /** - * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\Constructor::__construct - */ - public function testBodyStructure() - { - $constructor = new Constructor( - new ReflectionClass('ProxyManagerTestAsset\\ClassWithPublicProperties'), - $this->prefixInterceptors, - $this->suffixInterceptors - ); - - $this->assertSame( - '$this->property0 = & $localizedObject->property0; - -$this->property1 = & $localizedObject->property1; - -$this->property2 = & $localizedObject->property2; - -$this->property3 = & $localizedObject->property3; - -$this->property4 = & $localizedObject->property4; - -$this->property5 = & $localizedObject->property5; - -$this->property6 = & $localizedObject->property6; - -$this->property7 = & $localizedObject->property7; - -$this->property8 = & $localizedObject->property8; - -$this->property9 = & $localizedObject->property9; - -$this->pre = $prefixInterceptors; -$this->post = $suffixInterceptors;', - $constructor->getBody() - ); - } - - /** - * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\Constructor::__construct - */ - public function testBodyStructureWithProtectedProperties() - { - $constructor = new Constructor( - new ReflectionClass('ProxyManagerTestAsset\\ClassWithProtectedProperties'), - $this->prefixInterceptors, - $this->suffixInterceptors - ); - - $this->assertSame( - '$this->property0 = & $localizedObject->property0; - -$this->property1 = & $localizedObject->property1; - -$this->property2 = & $localizedObject->property2; - -$this->property3 = & $localizedObject->property3; - -$this->property4 = & $localizedObject->property4; - -$this->property5 = & $localizedObject->property5; - -$this->property6 = & $localizedObject->property6; - -$this->property7 = & $localizedObject->property7; - -$this->property8 = & $localizedObject->property8; - -$this->property9 = & $localizedObject->property9; - -$this->pre = $prefixInterceptors; -$this->post = $suffixInterceptors;', - $constructor->getBody() - ); - } - - /** - * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\Constructor::__construct - */ - public function testBodyStructureWithPrivateProperties() - { - if (! method_exists('Closure', 'bind')) { - $this->setExpectedException('ProxyManager\Exception\UnsupportedProxiedClassException'); - } - - $constructor = new Constructor( - new ReflectionClass('ProxyManagerTestAsset\\ClassWithPrivateProperties'), - $this->prefixInterceptors, - $this->suffixInterceptors - ); - - $this->assertSame( - '\Closure::bind(function () use ($localizedObject) { - $this->property0 = & $localizedObject->property0; -}, $this, \'ProxyManagerTestAsset\\\\ClassWithPrivateProperties\')->__invoke(); - -\Closure::bind(function () use ($localizedObject) { - $this->property1 = & $localizedObject->property1; -}, $this, \'ProxyManagerTestAsset\\\\ClassWithPrivateProperties\')->__invoke(); - -\Closure::bind(function () use ($localizedObject) { - $this->property2 = & $localizedObject->property2; -}, $this, \'ProxyManagerTestAsset\\\\ClassWithPrivateProperties\')->__invoke(); - -\Closure::bind(function () use ($localizedObject) { - $this->property3 = & $localizedObject->property3; -}, $this, \'ProxyManagerTestAsset\\\\ClassWithPrivateProperties\')->__invoke(); - -\Closure::bind(function () use ($localizedObject) { - $this->property4 = & $localizedObject->property4; -}, $this, \'ProxyManagerTestAsset\\\\ClassWithPrivateProperties\')->__invoke(); - -\Closure::bind(function () use ($localizedObject) { - $this->property5 = & $localizedObject->property5; -}, $this, \'ProxyManagerTestAsset\\\\ClassWithPrivateProperties\')->__invoke(); - -\Closure::bind(function () use ($localizedObject) { - $this->property6 = & $localizedObject->property6; -}, $this, \'ProxyManagerTestAsset\\\\ClassWithPrivateProperties\')->__invoke(); - -\Closure::bind(function () use ($localizedObject) { - $this->property7 = & $localizedObject->property7; -}, $this, \'ProxyManagerTestAsset\\\\ClassWithPrivateProperties\')->__invoke(); - -\Closure::bind(function () use ($localizedObject) { - $this->property8 = & $localizedObject->property8; -}, $this, \'ProxyManagerTestAsset\\\\ClassWithPrivateProperties\')->__invoke(); - -\Closure::bind(function () use ($localizedObject) { - $this->property9 = & $localizedObject->property9; -}, $this, \'ProxyManagerTestAsset\\\\ClassWithPrivateProperties\')->__invoke(); - -$this->pre = $prefixInterceptors; -$this->post = $suffixInterceptors;', - $constructor->getBody() - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/InterceptedMethodTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/InterceptedMethodTest.php deleted file mode 100644 index 207359f..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/InterceptedMethodTest.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @license MIT - * - * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\InterceptedMethod - * @group Coverage - */ -class InterceptedMethodTest extends PHPUnit_Framework_TestCase -{ - public function testBodyStructure() - { - $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - - $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); - $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); - - $method = InterceptedMethod::generateMethod( - new MethodReflection('ProxyManagerTestAsset\\BaseClass', 'publicByReferenceParameterMethod'), - $prefixInterceptors, - $suffixInterceptors - ); - - $this->assertInstanceOf('ProxyManager\\Generator\\MethodGenerator', $method); - - $this->assertSame('publicByReferenceParameterMethod', $method->getName()); - $this->assertCount(2, $method->getParameters()); - $this->assertGreaterThan( - 0, - strpos( - $method->getBody(), - '$returnValue = parent::publicByReferenceParameterMethod($param, $byRefParam);' - ) - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicCloneTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicCloneTest.php deleted file mode 100644 index df4f49e..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicCloneTest.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class MagicCloneTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicClone::__construct - */ - public function testBodyStructure() - { - $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); - $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - - $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); - $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); - - $magicClone = new MagicClone($reflection, $prefixInterceptors, $suffixInterceptors); - - $this->assertSame('__clone', $magicClone->getName()); - $this->assertCount(0, $magicClone->getParameters()); - $this->assertStringMatchesFormat("%a\n\n\$returnValue = null;\n\n%a", $magicClone->getBody()); - } - - /** - * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicClone::__construct - */ - public function testBodyStructureWithInheritedMethod() - { - $reflection = new ReflectionClass('ProxyManagerTestAsset\\ClassWithMagicMethods'); - $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - - $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); - $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); - - $magicClone = new MagicClone($reflection, $prefixInterceptors, $suffixInterceptors); - - $this->assertSame('__clone', $magicClone->getName()); - $this->assertCount(0, $magicClone->getParameters()); - $this->assertStringMatchesFormat("%a\n\n\$returnValue = parent::__clone();\n\n%a", $magicClone->getBody()); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicGetTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicGetTest.php deleted file mode 100644 index ed67bb0..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicGetTest.php +++ /dev/null @@ -1,80 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class MagicGetTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicGet::__construct - */ - public function testBodyStructure() - { - $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); - $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - - $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); - $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); - - $magicGet = new MagicGet( - $reflection, - $prefixInterceptors, - $suffixInterceptors - ); - - $this->assertSame('__get', $magicGet->getName()); - $this->assertCount(1, $magicGet->getParameters()); - $this->assertStringMatchesFormat('%a$returnValue = & $accessor();%a', $magicGet->getBody()); - } - - /** - * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicGet::__construct - */ - public function testBodyStructureWithInheritedMethod() - { - $reflection = new ReflectionClass('ProxyManagerTestAsset\\ClassWithMagicMethods'); - $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - - $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); - $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); - - $magicGet = new MagicGet( - $reflection, - $prefixInterceptors, - $suffixInterceptors - ); - - $this->assertSame('__get', $magicGet->getName()); - $this->assertCount(1, $magicGet->getParameters()); - $this->assertStringMatchesFormat('%a$returnValue = & parent::__get($name);%a', $magicGet->getBody()); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicIssetTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicIssetTest.php deleted file mode 100644 index 0dabe4c..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicIssetTest.php +++ /dev/null @@ -1,80 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class MagicIssetTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicIsset::__construct - */ - public function testBodyStructure() - { - $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); - $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - - $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); - $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); - - $magicGet = new MagicIsset( - $reflection, - $prefixInterceptors, - $suffixInterceptors - ); - - $this->assertSame('__isset', $magicGet->getName()); - $this->assertCount(1, $magicGet->getParameters()); - $this->assertStringMatchesFormat('%a$returnValue = $accessor();%a', $magicGet->getBody()); - } - - /** - * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicIsset::__construct - */ - public function testBodyStructureWithInheritedMethod() - { - $reflection = new ReflectionClass('ProxyManagerTestAsset\\ClassWithMagicMethods'); - $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - - $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); - $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); - - $magicGet = new MagicIsset( - $reflection, - $prefixInterceptors, - $suffixInterceptors - ); - - $this->assertSame('__isset', $magicGet->getName()); - $this->assertCount(1, $magicGet->getParameters()); - $this->assertStringMatchesFormat('%a$returnValue = & parent::__isset($name);%a', $magicGet->getBody()); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicSetTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicSetTest.php deleted file mode 100644 index 25d3070..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicSetTest.php +++ /dev/null @@ -1,80 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class MagicSetTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicSet::__construct - */ - public function testBodyStructure() - { - $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); - $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - - $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); - $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); - - $magicGet = new MagicSet( - $reflection, - $prefixInterceptors, - $suffixInterceptors - ); - - $this->assertSame('__set', $magicGet->getName()); - $this->assertCount(2, $magicGet->getParameters()); - $this->assertStringMatchesFormat('%a$returnValue = & $accessor();%a', $magicGet->getBody()); - } - - /** - * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicSet::__construct - */ - public function testBodyStructureWithInheritedMethod() - { - $reflection = new ReflectionClass('ProxyManagerTestAsset\\ClassWithMagicMethods'); - $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - - $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); - $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); - - $magicGet = new MagicSet( - $reflection, - $prefixInterceptors, - $suffixInterceptors - ); - - $this->assertSame('__set', $magicGet->getName()); - $this->assertCount(2, $magicGet->getParameters()); - $this->assertStringMatchesFormat('%a$returnValue = & parent::__set($name, $value);%a', $magicGet->getBody()); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicSleepTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicSleepTest.php deleted file mode 100644 index 98e401b..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicSleepTest.php +++ /dev/null @@ -1,80 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class MagicSleepTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicSleep::__construct - */ - public function testBodyStructure() - { - $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); - $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - - $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); - $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); - - $magicGet = new MagicSleep( - $reflection, - $prefixInterceptors, - $suffixInterceptors - ); - - $this->assertSame('__sleep', $magicGet->getName()); - $this->assertEmpty($magicGet->getParameters()); - $this->assertStringMatchesFormat('%a$returnValue = array_keys((array) $this);%a', $magicGet->getBody()); - } - - /** - * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicSleep::__construct - */ - public function testBodyStructureWithInheritedMethod() - { - $reflection = new ReflectionClass('ProxyManagerTestAsset\\ClassWithMagicMethods'); - $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - - $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); - $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); - - $magicGet = new MagicSleep( - $reflection, - $prefixInterceptors, - $suffixInterceptors - ); - - $this->assertSame('__sleep', $magicGet->getName()); - $this->assertEmpty($magicGet->getParameters()); - $this->assertStringMatchesFormat('%a$returnValue = & parent::__sleep();%a', $magicGet->getBody()); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicUnsetTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicUnsetTest.php deleted file mode 100644 index 822fda5..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/MagicUnsetTest.php +++ /dev/null @@ -1,80 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class MagicUnsetTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicUnset::__construct - */ - public function testBodyStructure() - { - $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); - $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - - $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); - $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); - - $magicGet = new MagicUnset( - $reflection, - $prefixInterceptors, - $suffixInterceptors - ); - - $this->assertSame('__unset', $magicGet->getName()); - $this->assertCount(1, $magicGet->getParameters()); - $this->assertStringMatchesFormat('%a$returnValue = $accessor();%a', $magicGet->getBody()); - } - - /** - * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\MagicUnset::__construct - */ - public function testBodyStructureWithInheritedMethod() - { - $reflection = new ReflectionClass('ProxyManagerTestAsset\\ClassWithMagicMethods'); - $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - - $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); - $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); - - $magicGet = new MagicUnset( - $reflection, - $prefixInterceptors, - $suffixInterceptors - ); - - $this->assertSame('__unset', $magicGet->getName()); - $this->assertCount(1, $magicGet->getParameters()); - $this->assertStringMatchesFormat('%a$returnValue = & parent::__unset($name);%a', $magicGet->getBody()); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/Util/InterceptorGeneratorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/Util/InterceptorGeneratorTest.php deleted file mode 100644 index 7e54c70..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizer/MethodGenerator/Util/InterceptorGeneratorTest.php +++ /dev/null @@ -1,81 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class InterceptorGeneratorTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\Util\InterceptorGenerator - */ - public function testInterceptorGenerator() - { - $method = $this->getMock('ProxyManager\\Generator\\MethodGenerator'); - $bar = $this->getMock('ProxyManager\\Generator\\ParameterGenerator'); - $baz = $this->getMock('ProxyManager\\Generator\\ParameterGenerator'); - $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - - $bar->expects($this->any())->method('getName')->will($this->returnValue('bar')); - $baz->expects($this->any())->method('getName')->will($this->returnValue('baz')); - $method->expects($this->any())->method('getName')->will($this->returnValue('fooMethod')); - $method->expects($this->any())->method('getParameters')->will($this->returnValue(array($bar, $baz))); - $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); - $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); - - $body = InterceptorGenerator::createInterceptedMethodBody( - '$returnValue = "foo";', - $method, - $prefixInterceptors, - $suffixInterceptors - ); - - $this->assertSame( - 'if (isset($this->pre[\'fooMethod\'])) {' . "\n" - . ' $returnEarly = false;' . "\n" - . ' $prefixReturnValue = $this->pre[\'fooMethod\']->__invoke($this, $this, \'fooMethod\', ' - . 'array(\'bar\' => $bar, \'baz\' => $baz), $returnEarly);' . "\n\n" - . ' if ($returnEarly) {' . "\n" - . ' return $prefixReturnValue;' . "\n" - . ' }' . "\n" - . '}' . "\n\n" - . '$returnValue = "foo";' . "\n\n" - . 'if (isset($this->post[\'fooMethod\'])) {' . "\n" - . ' $returnEarly = false;' . "\n" - . ' $suffixReturnValue = $this->post[\'fooMethod\']->__invoke($this, $this, \'fooMethod\', ' - . 'array(\'bar\' => $bar, \'baz\' => $baz), $returnValue, $returnEarly);' . "\n\n" - . ' if ($returnEarly) {' . "\n" - . ' return $suffixReturnValue;' . "\n" - . ' }' . "\n" - . '}' . "\n\n" - . 'return $returnValue;', - $body - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizerTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizerTest.php deleted file mode 100644 index bd6af22..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorScopeLocalizerTest.php +++ /dev/null @@ -1,76 +0,0 @@ - - * @license MIT - * - * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizerGenerator - * @group Coverage - */ -class AccessInterceptorScopeLocalizerTest extends AbstractProxyGeneratorTest -{ - /** - * @dataProvider getTestedImplementations - * - * {@inheritDoc} - */ - public function testGeneratesValidCode($className) - { - $reflectionClass = new ReflectionClass($className); - - if ($reflectionClass->isInterface()) { - // @todo interfaces *may* be proxied by deferring property localization to the constructor (no hardcoding) - $this->setExpectedException('ProxyManager\Exception\InvalidProxiedClassException'); - - return parent::testGeneratesValidCode($className); - } - - if ((! method_exists('Closure', 'bind')) - && $reflectionClass->getProperties(ReflectionProperty::IS_PRIVATE) - ) { - $this->setExpectedException('ProxyManager\Exception\UnsupportedProxiedClassException'); - } - - return parent::testGeneratesValidCode($className); - } - - /** - * {@inheritDoc} - */ - protected function getProxyGenerator() - { - return new AccessInterceptorScopeLocalizerGenerator(); - } - - /** - * {@inheritDoc} - */ - protected function getExpectedImplementedInterfaces() - { - return array('ProxyManager\\Proxy\\AccessInterceptorInterface'); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/LazyLoading/MethodGenerator/ConstructorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/LazyLoading/MethodGenerator/ConstructorTest.php deleted file mode 100644 index e4209c1..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/LazyLoading/MethodGenerator/ConstructorTest.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class ConstructorTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\LazyLoading\MethodGenerator\Constructor::__construct - */ - public function testBodyStructure() - { - $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $reflection = new ReflectionClass( - 'ProxyManagerTestAsset\\ProxyGenerator\\LazyLoading\\MethodGenerator\\ClassWithTwoPublicProperties' - ); - - $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); - - $constructor = new Constructor($reflection, $initializer); - - $this->assertSame('__construct', $constructor->getName()); - $this->assertCount(1, $constructor->getParameters()); - $this->assertSame("unset(\$this->bar, \$this->baz);\n\n\$this->foo = \$initializer;", $constructor->getBody()); - } - - /** - * @covers \ProxyManager\ProxyGenerator\LazyLoading\MethodGenerator\Constructor::__construct - */ - public function testBodyStructureWithoutPublicProperties() - { - $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - - $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); - - $constructor = new Constructor(new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'), $initializer); - - $this->assertSame('__construct', $constructor->getName()); - $this->assertCount(1, $constructor->getParameters()); - $this->assertSame("\$this->foo = \$initializer;", $constructor->getBody()); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/ConstructorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/ConstructorTest.php deleted file mode 100644 index 97f7175..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/ConstructorTest.php +++ /dev/null @@ -1,86 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class ConstructorTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\Constructor::__construct - */ - public function testBodyStructure() - { - $valueHolder = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $reflection = new ReflectionClass( - 'ProxyManagerTestAsset\\ProxyGenerator\\LazyLoading\\MethodGenerator\\ClassWithTwoPublicProperties' - ); - - $valueHolder->expects($this->any())->method('getName')->will($this->returnValue('foo')); - $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); - $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); - - $constructor = new Constructor($reflection, $valueHolder, $prefixInterceptors, $suffixInterceptors); - - $this->assertSame('__construct', $constructor->getName()); - $this->assertCount(3, $constructor->getParameters()); - $this->assertSame( - "unset(\$this->bar, \$this->baz);\n\n\$this->foo = \$wrappedObject;\n\$this->pre = \$prefixInterceptors;" - . "\n\$this->post = \$suffixInterceptors;", - $constructor->getBody() - ); - } - - /** - * @covers \ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\Constructor::__construct - */ - public function testBodyStructureWithoutPublicProperties() - { - $valueHolder = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); - - $valueHolder->expects($this->any())->method('getName')->will($this->returnValue('foo')); - $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); - $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); - - $constructor = new Constructor($reflection, $valueHolder, $prefixInterceptors, $suffixInterceptors); - - $this->assertSame('__construct', $constructor->getName()); - $this->assertCount(3, $constructor->getParameters()); - $this->assertSame( - "\$this->foo = \$wrappedObject;\n\$this->pre = \$prefixInterceptors;" - . "\n\$this->post = \$suffixInterceptors;", - $constructor->getBody() - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/InterceptedMethodTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/InterceptedMethodTest.php deleted file mode 100644 index 41b5bfb..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/InterceptedMethodTest.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @license MIT - * - * @covers \ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\InterceptedMethod::generateMethod - * @group Coverage - */ -class InterceptedMethodTest extends PHPUnit_Framework_TestCase -{ - public function testBodyStructure() - { - $valueHolder = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - - $valueHolder->expects($this->any())->method('getName')->will($this->returnValue('foo')); - $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); - $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); - - $method = InterceptedMethod::generateMethod( - new MethodReflection('ProxyManagerTestAsset\\BaseClass', 'publicByReferenceParameterMethod'), - $valueHolder, - $prefixInterceptors, - $suffixInterceptors - ); - - $this->assertInstanceOf('ProxyManager\\Generator\\MethodGenerator', $method); - - $this->assertSame('publicByReferenceParameterMethod', $method->getName()); - $this->assertCount(2, $method->getParameters()); - $this->assertGreaterThan( - 0, - strpos( - $method->getBody(), - '$returnValue = $this->foo->publicByReferenceParameterMethod($param, $byRefParam);' - ) - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicCloneTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicCloneTest.php deleted file mode 100644 index 72a7763..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicCloneTest.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class MagicCloneTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\MagicClone::__construct - */ - public function testBodyStructure() - { - $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); - $valueHolder = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - - $valueHolder->expects($this->any())->method('getName')->will($this->returnValue('bar')); - $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); - $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); - - $magicClone = new MagicClone($reflection, $valueHolder, $prefixInterceptors, $suffixInterceptors); - - $this->assertSame('__clone', $magicClone->getName()); - $this->assertCount(0, $magicClone->getParameters()); - $this->assertSame( - '$this->bar = clone $this->bar;' . "\n\n" - . 'foreach ($this->pre as $key => $value) {' . "\n" - . ' $this->pre[$key] = clone $value;' . "\n" - . '}' . "\n\n" - . 'foreach ($this->post as $key => $value) {' . "\n" - . ' $this->post[$key] = clone $value;' . "\n" - . '}', - $magicClone->getBody() - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicGetTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicGetTest.php deleted file mode 100644 index 0ca38de..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicGetTest.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class MagicGetTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\MagicGet::__construct - */ - public function testBodyStructure() - { - $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); - $valueHolder = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $publicProperties = $this - ->getMockBuilder('ProxyManager\\ProxyGenerator\\PropertyGenerator\\PublicPropertiesMap') - ->disableOriginalConstructor() - ->getMock(); - - $valueHolder->expects($this->any())->method('getName')->will($this->returnValue('bar')); - $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); - $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); - $publicProperties->expects($this->any())->method('isEmpty')->will($this->returnValue(false)); - - $magicGet = new MagicGet( - $reflection, - $valueHolder, - $prefixInterceptors, - $suffixInterceptors, - $publicProperties - ); - - $this->assertSame('__get', $magicGet->getName()); - $this->assertCount(1, $magicGet->getParameters()); - $this->assertStringMatchesFormat('%A$returnValue = & $this->bar->$name;%A', $magicGet->getBody()); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicIssetTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicIssetTest.php deleted file mode 100644 index 5f34baf..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicIssetTest.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class MagicIssetTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\MagicIsset::__construct - */ - public function testBodyStructure() - { - $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); - $valueHolder = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $publicProperties = $this - ->getMockBuilder('ProxyManager\\ProxyGenerator\\PropertyGenerator\\PublicPropertiesMap') - ->disableOriginalConstructor() - ->getMock(); - - $valueHolder->expects($this->any())->method('getName')->will($this->returnValue('bar')); - $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); - $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); - $publicProperties->expects($this->any())->method('isEmpty')->will($this->returnValue(false)); - - $magicIsset = new MagicIsset( - $reflection, - $valueHolder, - $prefixInterceptors, - $suffixInterceptors, - $publicProperties - ); - - $this->assertSame('__isset', $magicIsset->getName()); - $this->assertCount(1, $magicIsset->getParameters()); - $this->assertGreaterThan(0, strpos($magicIsset->getBody(), '$returnValue = isset($this->bar->$name);')); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicSetTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicSetTest.php deleted file mode 100644 index 93da0b9..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicSetTest.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class MagicSetTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\MagicSet::__construct - */ - public function testBodyStructure() - { - $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); - $valueHolder = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $publicProperties = $this - ->getMockBuilder('ProxyManager\\ProxyGenerator\\PropertyGenerator\\PublicPropertiesMap') - ->disableOriginalConstructor() - ->getMock(); - - $valueHolder->expects($this->any())->method('getName')->will($this->returnValue('bar')); - $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); - $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); - $publicProperties->expects($this->any())->method('isEmpty')->will($this->returnValue(false)); - - $magicSet = new MagicSet( - $reflection, - $valueHolder, - $prefixInterceptors, - $suffixInterceptors, - $publicProperties - ); - - $this->assertSame('__set', $magicSet->getName()); - $this->assertCount(2, $magicSet->getParameters()); - $this->assertGreaterThan(0, strpos($magicSet->getBody(), '$returnValue = ($this->bar->$name = $value);')); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicUnsetTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicUnsetTest.php deleted file mode 100644 index 0433ff6..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/MagicUnsetTest.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class MagicUnsetTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\MagicUnset::__construct - */ - public function testBodyStructure() - { - $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); - $valueHolder = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $publicProperties = $this - ->getMockBuilder('ProxyManager\\ProxyGenerator\\PropertyGenerator\\PublicPropertiesMap') - ->disableOriginalConstructor() - ->getMock(); - - $valueHolder->expects($this->any())->method('getName')->will($this->returnValue('bar')); - $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); - $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); - $publicProperties->expects($this->any())->method('isEmpty')->will($this->returnValue(false)); - - $magicUnset = new MagicUnset( - $reflection, - $valueHolder, - $prefixInterceptors, - $suffixInterceptors, - $publicProperties - ); - - $this->assertSame('__unset', $magicUnset->getName()); - $this->assertCount(1, $magicUnset->getParameters()); - $this->assertGreaterThan( - 0, - strpos($magicUnset->getBody(), 'unset($this->bar->$name);') - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/Util/InterceptorGeneratorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/Util/InterceptorGeneratorTest.php deleted file mode 100644 index bb5c461..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolder/MethodGenerator/Util/InterceptorGeneratorTest.php +++ /dev/null @@ -1,84 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class InterceptorGeneratorTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\Util\InterceptorGenerator - */ - public function testInterceptorGenerator() - { - $method = $this->getMock('ProxyManager\\Generator\\MethodGenerator'); - $bar = $this->getMock('ProxyManager\\Generator\\ParameterGenerator'); - $baz = $this->getMock('ProxyManager\\Generator\\ParameterGenerator'); - $valueHolder = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - - $bar->expects($this->any())->method('getName')->will($this->returnValue('bar')); - $baz->expects($this->any())->method('getName')->will($this->returnValue('baz')); - $method->expects($this->any())->method('getName')->will($this->returnValue('fooMethod')); - $method->expects($this->any())->method('getParameters')->will($this->returnValue(array($bar, $baz))); - $valueHolder->expects($this->any())->method('getName')->will($this->returnValue('foo')); - $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre')); - $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post')); - - $body = InterceptorGenerator::createInterceptedMethodBody( - '$returnValue = "foo";', - $method, - $valueHolder, - $prefixInterceptors, - $suffixInterceptors - ); - - $this->assertSame( - 'if (isset($this->pre[\'fooMethod\'])) {' . "\n" - . ' $returnEarly = false;' . "\n" - . ' $prefixReturnValue = $this->pre[\'fooMethod\']->__invoke($this, $this->foo, \'fooMethod\', ' - . 'array(\'bar\' => $bar, \'baz\' => $baz), $returnEarly);' . "\n\n" - . ' if ($returnEarly) {' . "\n" - . ' return $prefixReturnValue;' . "\n" - . ' }' . "\n" - . '}' . "\n\n" - . '$returnValue = "foo";' . "\n\n" - . 'if (isset($this->post[\'fooMethod\'])) {' . "\n" - . ' $returnEarly = false;' . "\n" - . ' $suffixReturnValue = $this->post[\'fooMethod\']->__invoke($this, $this->foo, \'fooMethod\', ' - . 'array(\'bar\' => $bar, \'baz\' => $baz), $returnValue, $returnEarly);' . "\n\n" - . ' if ($returnEarly) {' . "\n" - . ' return $suffixReturnValue;' . "\n" - . ' }' . "\n" - . '}' . "\n\n" - . 'return $returnValue;', - $body - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolderTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolderTest.php deleted file mode 100644 index 1b7d806..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/AccessInterceptorValueHolderTest.php +++ /dev/null @@ -1,52 +0,0 @@ - - * @license MIT - * - * @covers \ProxyManager\ProxyGenerator\AccessInterceptorValueHolderGenerator - * @group Coverage - */ -class AccessInterceptorValueHolderTest extends AbstractProxyGeneratorTest -{ - /** - * {@inheritDoc} - */ - protected function getProxyGenerator() - { - return new AccessInterceptorValueHolderGenerator(); - } - - /** - * {@inheritDoc} - */ - protected function getExpectedImplementedInterfaces() - { - return array( - 'ProxyManager\\Proxy\\AccessInterceptorInterface', - 'ProxyManager\\Proxy\\ValueHolderInterface', - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/Assertion/CanProxyAssertionTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/Assertion/CanProxyAssertionTest.php deleted file mode 100644 index 1c9003f..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/Assertion/CanProxyAssertionTest.php +++ /dev/null @@ -1,113 +0,0 @@ - - * @license MIT - * - * @covers \ProxyManager\ProxyGenerator\Assertion\CanProxyAssertion - * @group Coverage - */ -class CanProxyAssertionTest extends PHPUnit_Framework_TestCase -{ - public function testDeniesFinalClasses() - { - $this->setExpectedException('ProxyManager\Exception\InvalidProxiedClassException'); - - CanProxyAssertion::assertClassCanBeProxied(new ReflectionClass('ProxyManagerTestAsset\\FinalClass')); - } - - public function testDeniesClassesWithAbstractProtectedMethods() - { - $this->setExpectedException('ProxyManager\Exception\InvalidProxiedClassException'); - - CanProxyAssertion::assertClassCanBeProxied(new ReflectionClass( - 'ProxyManagerTestAsset\\ClassWithAbstractProtectedMethod' - )); - } - - public function testAllowsInterfaceByDefault() - { - CanProxyAssertion::assertClassCanBeProxied(new ReflectionClass( - 'ProxyManagerTestAsset\\BaseInterface' - )); - - $this->assertTrue(true); // not nice, but assertions are just fail-checks, no real code executed - } - - public function testDeniesInterfaceIfSpecified() - { - $this->setExpectedException('ProxyManager\Exception\InvalidProxiedClassException'); - - CanProxyAssertion::assertClassCanBeProxied(new ReflectionClass('ProxyManagerTestAsset\\BaseInterface'), false); - } - - /** - * @param string $className - * - * @dataProvider validClasses - */ - public function testAllowedClass($className) - { - CanProxyAssertion::assertClassCanBeProxied(new ReflectionClass($className)); - - $this->assertTrue(true); // not nice, but assertions are just fail-checks, no real code executed - } - - public function testDisallowsConstructor() - { - $this->setExpectedException('BadMethodCallException'); - - new CanProxyAssertion(); - } - - /** - * @return string[][] - */ - public function validClasses() - { - return array( - array('ProxyManagerTestAsset\AccessInterceptorValueHolderMock'), - array('ProxyManagerTestAsset\BaseClass'), - array('ProxyManagerTestAsset\BaseInterface'), - array('ProxyManagerTestAsset\CallableTypeHintClass'), - array('ProxyManagerTestAsset\ClassWithByRefMagicMethods'), - array('ProxyManagerTestAsset\ClassWithFinalMagicMethods'), - array('ProxyManagerTestAsset\ClassWithFinalMethods'), - array('ProxyManagerTestAsset\ClassWithMethodWithDefaultParameters'), - array('ProxyManagerTestAsset\ClassWithMixedProperties'), - array('ProxyManagerTestAsset\ClassWithPrivateProperties'), - array('ProxyManagerTestAsset\ClassWithProtectedProperties'), - array('ProxyManagerTestAsset\ClassWithPublicProperties'), - array('ProxyManagerTestAsset\ClassWithPublicArrayProperty'), - array('ProxyManagerTestAsset\ClassWithSelfHint'), - array('ProxyManagerTestAsset\EmptyClass'), - array('ProxyManagerTestAsset\HydratedObject'), - array('ProxyManagerTestAsset\LazyLoadingMock'), - array('ProxyManagerTestAsset\NullObjectMock'), - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/CallInitializerTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/CallInitializerTest.php deleted file mode 100644 index 3fbd81d..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/CallInitializerTest.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class CallInitializerTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\CallInitializer::__construct - */ - public function testBodyStructure() - { - $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $propertiesDefaults = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $initializationTracker = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - - $initializer->expects($this->any())->method('getName')->will($this->returnValue('init')); - $propertiesDefaults->expects($this->any())->method('getName')->will($this->returnValue('props')); - $initializationTracker->expects($this->any())->method('getName')->will($this->returnValue('track')); - - $callInitializer = new CallInitializer($initializer, $propertiesDefaults, $initializationTracker); - - $this->assertStringMatchesFormat( - '%Aif ($this->track || ! $this->init) {%areturn;%a}%a' - . '$this->track = true;%a' - . 'foreach (self::$props as $key => $default) {%a' - . '$this->$key = $default;%a' - . '$this->init->__invoke(%a);%a' - . '$this->track = false;', - $callInitializer->getBody() - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/GetProxyInitializerTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/GetProxyInitializerTest.php deleted file mode 100644 index 32936b9..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/GetProxyInitializerTest.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class GetProxyInitializerTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\GetProxyInitializer::__construct - */ - public function testBodyStructure() - { - $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - - $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); - - $getter = new GetProxyInitializer($initializer); - - $this->assertSame('getProxyInitializer', $getter->getName()); - $this->assertCount(0, $getter->getParameters()); - $this->assertSame('return $this->foo;', $getter->getBody()); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/InitializeProxyTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/InitializeProxyTest.php deleted file mode 100644 index 27e1e2d..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/InitializeProxyTest.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class InitializeProxyTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\InitializeProxy::__construct - */ - public function testBodyStructure() - { - $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $initCall = $this->getMock('Zend\\Code\\Generator\\MethodGenerator'); - - $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); - $initCall->expects($this->any())->method('getName')->will($this->returnValue('bar')); - - $initializeProxy = new InitializeProxy($initializer, $initCall); - - $this->assertSame('initializeProxy', $initializeProxy->getName()); - $this->assertCount(0, $initializeProxy->getParameters()); - $this->assertSame( - 'return $this->foo && $this->bar(\'initializeProxy\', array());', - $initializeProxy->getBody() - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/IsProxyInitializedTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/IsProxyInitializedTest.php deleted file mode 100644 index f82dae9..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/IsProxyInitializedTest.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class IsProxyInitializedTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\IsProxyInitialized::__construct - */ - public function testBodyStructure() - { - $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - - $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); - - $isProxyInitialized = new IsProxyInitialized($initializer); - - $this->assertSame('isProxyInitialized', $isProxyInitialized->getName()); - $this->assertCount(0, $isProxyInitialized->getParameters()); - $this->assertSame('return ! $this->foo;', $isProxyInitialized->getBody()); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/LazyLoadingMethodInterceptorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/LazyLoadingMethodInterceptorTest.php deleted file mode 100644 index db5e3af..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/LazyLoadingMethodInterceptorTest.php +++ /dev/null @@ -1,81 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class LazyLoadingMethodInterceptorTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\LazyLoadingMethodInterceptor - */ - public function testBodyStructure() - { - $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $initCall = $this->getMock('Zend\\Code\\Generator\\MethodGenerator'); - - $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); - $initCall->expects($this->any())->method('getName')->will($this->returnValue('bar')); - - $reflection = new MethodReflection('ProxyManagerTestAsset\\BaseClass', 'publicByReferenceParameterMethod'); - $method = LazyLoadingMethodInterceptor::generateMethod($reflection, $initializer, $initCall); - - $this->assertSame('publicByReferenceParameterMethod', $method->getName()); - $this->assertCount(2, $method->getParameters()); - $this->assertSame( - "\$this->foo && \$this->bar('publicByReferenceParameterMethod', " - . "array('param' => \$param, 'byRefParam' => \$byRefParam));\n\n" - . "return parent::publicByReferenceParameterMethod(\$param, \$byRefParam);", - $method->getBody() - ); - } - - /** - * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\LazyLoadingMethodInterceptor - */ - public function testBodyStructureWithoutParameters() - { - $reflectionMethod = new MethodReflection(__CLASS__, 'testBodyStructureWithoutParameters'); - $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $initCall = $this->getMock('Zend\\Code\\Generator\\MethodGenerator'); - - $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); - $initCall->expects($this->any())->method('getName')->will($this->returnValue('bar')); - - $method = LazyLoadingMethodInterceptor::generateMethod($reflectionMethod, $initializer, $initCall); - - $this->assertSame('testBodyStructureWithoutParameters', $method->getName()); - $this->assertCount(0, $method->getParameters()); - $this->assertSame( - "\$this->foo && \$this->bar('testBodyStructureWithoutParameters', array());\n\n" - . "return parent::testBodyStructureWithoutParameters();", - $method->getBody() - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicCloneTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicCloneTest.php deleted file mode 100644 index 4cb2271..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicCloneTest.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class MagicCloneTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicClone::__construct - */ - public function testBodyStructure() - { - $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); - $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $initCall = $this->getMock('Zend\\Code\\Generator\\MethodGenerator'); - - $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); - $initCall->expects($this->any())->method('getName')->will($this->returnValue('bar')); - - $magicClone = new MagicClone($reflection, $initializer, $initCall); - - $this->assertSame('__clone', $magicClone->getName()); - $this->assertCount(0, $magicClone->getParameters()); - $this->assertSame( - "\$this->foo && \$this->bar('__clone', array());", - $magicClone->getBody() - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicGetTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicGetTest.php deleted file mode 100644 index 6f2a7c0..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicGetTest.php +++ /dev/null @@ -1,124 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class MagicGetTest extends PHPUnit_Framework_TestCase -{ - /** - * @var \Zend\Code\Generator\PropertyGenerator|\PHPUnit_Framework_MockObject_MockObject - */ - protected $initializer; - - /** - * @var \Zend\Code\Generator\MethodGenerator|\PHPUnit_Framework_MockObject_MockObject - */ - protected $initMethod; - - /** - * @var \ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesMap|\PHPUnit_Framework_MockObject_MockObject - */ - protected $publicProperties; - - /** - * {@inheritDoc} - */ - protected function setUp() - { - $this->initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $this->initMethod = $this->getMock('Zend\\Code\\Generator\\MethodGenerator'); - $this->publicProperties = $this - ->getMockBuilder('ProxyManager\\ProxyGenerator\\PropertyGenerator\\PublicPropertiesMap') - ->disableOriginalConstructor() - ->getMock(); - - $this->initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); - $this->initMethod->expects($this->any())->method('getName')->will($this->returnValue('baz')); - $this->publicProperties->expects($this->any())->method('isEmpty')->will($this->returnValue(false)); - $this->publicProperties->expects($this->any())->method('getName')->will($this->returnValue('bar')); - } - - /** - * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicGet::__construct - */ - public function testBodyStructure() - { - $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); - $magicGet = new MagicGet($reflection, $this->initializer, $this->initMethod, $this->publicProperties); - - $this->assertSame('__get', $magicGet->getName()); - $this->assertCount(1, $magicGet->getParameters()); - $this->assertStringMatchesFormat( - "\$this->foo && \$this->baz('__get', array('name' => \$name));\n\n" - . "if (isset(self::\$bar[\$name])) {\n return \$this->\$name;\n}\n\n" - . "%a", - $magicGet->getBody() - ); - } - - /** - * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicGet::__construct - */ - public function testBodyStructureWithPublicProperties() - { - $reflection = new ReflectionClass( - 'ProxyManagerTestAsset\\ProxyGenerator\\LazyLoading\\MethodGenerator\\ClassWithTwoPublicProperties' - ); - - $magicGet = new MagicGet($reflection, $this->initializer, $this->initMethod, $this->publicProperties); - - $this->assertSame('__get', $magicGet->getName()); - $this->assertCount(1, $magicGet->getParameters()); - $this->assertStringMatchesFormat( - "\$this->foo && \$this->baz('__get', array('name' => \$name));\n\n" - . "if (isset(self::\$bar[\$name])) {\n return \$this->\$name;\n}\n\n" - . "%a", - $magicGet->getBody() - ); - } - - /** - * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicGet::__construct - */ - public function testBodyStructureWithOverriddenMagicGet() - { - $reflection = new ReflectionClass('ProxyManagerTestAsset\\ClassWithMagicMethods'); - $magicGet = new MagicGet($reflection, $this->initializer, $this->initMethod, $this->publicProperties); - - $this->assertSame('__get', $magicGet->getName()); - $this->assertCount(1, $magicGet->getParameters()); - $this->assertSame( - "\$this->foo && \$this->baz('__get', array('name' => \$name));\n\n" - . "if (isset(self::\$bar[\$name])) {\n return \$this->\$name;\n}\n\n" - . "return parent::__get(\$name);", - $magicGet->getBody() - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicIssetTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicIssetTest.php deleted file mode 100644 index fa9bb4b..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicIssetTest.php +++ /dev/null @@ -1,123 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class MagicIssetTest extends PHPUnit_Framework_TestCase -{ - /** - * @var \Zend\Code\Generator\PropertyGenerator|\PHPUnit_Framework_MockObject_MockObject - */ - protected $initializer; - - /** - * @var \Zend\Code\Generator\MethodGenerator|\PHPUnit_Framework_MockObject_MockObject - */ - protected $initMethod; - - /** - * @var \ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesMap|\PHPUnit_Framework_MockObject_MockObject - */ - protected $publicProperties; - - /** - * {@inheritDoc} - */ - protected function setUp() - { - $this->initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $this->initMethod = $this->getMock('Zend\\Code\\Generator\\MethodGenerator'); - $this->publicProperties = $this - ->getMockBuilder('ProxyManager\\ProxyGenerator\\PropertyGenerator\\PublicPropertiesMap') - ->disableOriginalConstructor() - ->getMock(); - - $this->initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); - $this->initMethod->expects($this->any())->method('getName')->will($this->returnValue('baz')); - $this->publicProperties->expects($this->any())->method('isEmpty')->will($this->returnValue(false)); - $this->publicProperties->expects($this->any())->method('getName')->will($this->returnValue('bar')); - } - - /** - * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicIsset::__construct - */ - public function testBodyStructure() - { - $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); - $magicIsset = new MagicIsset($reflection, $this->initializer, $this->initMethod, $this->publicProperties); - - $this->assertSame('__isset', $magicIsset->getName()); - $this->assertCount(1, $magicIsset->getParameters()); - $this->assertStringMatchesFormat( - "\$this->foo && \$this->baz('__isset', array('name' => \$name));\n\n" - . "if (isset(self::\$bar[\$name])) {\n return isset(\$this->\$name);\n}\n\n" - . "%areturn %s;", - $magicIsset->getBody() - ); - } - - /** - * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicIsset::__construct - */ - public function testBodyStructureWithPublicProperties() - { - $reflection = new ReflectionClass( - 'ProxyManagerTestAsset\\ProxyGenerator\\LazyLoading\\MethodGenerator\\ClassWithTwoPublicProperties' - ); - $magicIsset = new MagicIsset($reflection, $this->initializer, $this->initMethod, $this->publicProperties); - - $this->assertSame('__isset', $magicIsset->getName()); - $this->assertCount(1, $magicIsset->getParameters()); - $this->assertStringMatchesFormat( - "\$this->foo && \$this->baz('__isset', array('name' => \$name));\n\n" - . "if (isset(self::\$bar[\$name])) {\n return isset(\$this->\$name);\n}\n\n" - . "%areturn %s;", - $magicIsset->getBody() - ); - } - - /** - * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicIsset::__construct - */ - public function testBodyStructureWithOverriddenMagicGet() - { - $reflection = new ReflectionClass('ProxyManagerTestAsset\\ClassWithMagicMethods'); - $magicIsset = new MagicIsset($reflection, $this->initializer, $this->initMethod, $this->publicProperties); - - $this->assertSame('__isset', $magicIsset->getName()); - $this->assertCount(1, $magicIsset->getParameters()); - $this->assertSame( - "\$this->foo && \$this->baz('__isset', array('name' => \$name));\n\n" - . "if (isset(self::\$bar[\$name])) {\n return isset(\$this->\$name);\n}\n\n" - . "return parent::__isset(\$name);", - $magicIsset->getBody() - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicSetTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicSetTest.php deleted file mode 100644 index 00b7ad9..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicSetTest.php +++ /dev/null @@ -1,124 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class MagicSetTest extends PHPUnit_Framework_TestCase -{ - /** - * @var \Zend\Code\Generator\PropertyGenerator|\PHPUnit_Framework_MockObject_MockObject - */ - protected $initializer; - - /** - * @var \Zend\Code\Generator\MethodGenerator|\PHPUnit_Framework_MockObject_MockObject - */ - protected $initMethod; - - /** - * @var \ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesMap|\PHPUnit_Framework_MockObject_MockObject - */ - protected $publicProperties; - - /** - * {@inheritDoc} - */ - protected function setUp() - { - $this->initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $this->initMethod = $this->getMock('Zend\\Code\\Generator\\MethodGenerator'); - $this->publicProperties = $this - ->getMockBuilder('ProxyManager\\ProxyGenerator\\PropertyGenerator\\PublicPropertiesMap') - ->disableOriginalConstructor() - ->getMock(); - - $this->initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); - $this->initMethod->expects($this->any())->method('getName')->will($this->returnValue('baz')); - $this->publicProperties->expects($this->any())->method('isEmpty')->will($this->returnValue(false)); - $this->publicProperties->expects($this->any())->method('getName')->will($this->returnValue('bar')); - } - - /** - * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicSet::__construct - */ - public function testBodyStructure() - { - $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); - $magicSet = new MagicSet($reflection, $this->initializer, $this->initMethod, $this->publicProperties); - - $this->assertSame('__set', $magicSet->getName()); - $this->assertCount(2, $magicSet->getParameters()); - $this->assertStringMatchesFormat( - "\$this->foo && \$this->baz('__set', array('name' => \$name, 'value' => \$value));\n\n" - . "if (isset(self::\$bar[\$name])) {\n return (\$this->\$name = \$value);\n}\n\n" - . "%areturn %s;", - $magicSet->getBody() - ); - } - - /** - * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicSet::__construct - */ - public function testBodyStructureWithPublicProperties() - { - $reflection = new ReflectionClass( - 'ProxyManagerTestAsset\\ProxyGenerator\\LazyLoading\\MethodGenerator\\ClassWithTwoPublicProperties' - ); - - $magicSet = new MagicSet($reflection, $this->initializer, $this->initMethod, $this->publicProperties); - - $this->assertSame('__set', $magicSet->getName()); - $this->assertCount(2, $magicSet->getParameters()); - $this->assertStringMatchesFormat( - "\$this->foo && \$this->baz('__set', array('name' => \$name, 'value' => \$value));\n\n" - . "if (isset(self::\$bar[\$name])) {\n return (\$this->\$name = \$value);\n}\n\n" - . "%areturn %s;", - $magicSet->getBody() - ); - } - - /** - * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicSet::__construct - */ - public function testBodyStructureWithOverriddenMagicGet() - { - $reflection = new ReflectionClass('ProxyManagerTestAsset\\ClassWithMagicMethods'); - $magicSet = new MagicSet($reflection, $this->initializer, $this->initMethod, $this->publicProperties); - - $this->assertSame('__set', $magicSet->getName()); - $this->assertCount(2, $magicSet->getParameters()); - $this->assertSame( - "\$this->foo && \$this->baz('__set', array('name' => \$name, 'value' => \$value));\n\n" - . "if (isset(self::\$bar[\$name])) {\n return (\$this->\$name = \$value);\n}\n\n" - . "return parent::__set(\$name, \$value);", - $magicSet->getBody() - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicSleepTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicSleepTest.php deleted file mode 100644 index 7329e61..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicSleepTest.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class MagicSleepTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicSleep::__construct - */ - public function testBodyStructure() - { - $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); - $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $initMethod = $this->getMock('Zend\\Code\\Generator\\MethodGenerator'); - - $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); - $initMethod->expects($this->any())->method('getName')->will($this->returnValue('bar')); - - $magicSleep = new MagicSleep($reflection, $initializer, $initMethod); - - $this->assertSame('__sleep', $magicSleep->getName()); - $this->assertCount(0, $magicSleep->getParameters()); - $this->assertSame( - "\$this->foo && \$this->bar('__sleep', array());" - . "\n\nreturn array_keys((array) \$this);", - $magicSleep->getBody() - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicUnsetTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicUnsetTest.php deleted file mode 100644 index 5e3ba4e..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/MagicUnsetTest.php +++ /dev/null @@ -1,124 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class MagicUnsetTest extends PHPUnit_Framework_TestCase -{ - /** - * @var \Zend\Code\Generator\PropertyGenerator|\PHPUnit_Framework_MockObject_MockObject - */ - protected $initializer; - - /** - * @var \Zend\Code\Generator\MethodGenerator|\PHPUnit_Framework_MockObject_MockObject - */ - protected $initMethod; - - /** - * @var \ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesMap|\PHPUnit_Framework_MockObject_MockObject - */ - protected $publicProperties; - - /** - * {@inheritDoc} - */ - protected function setUp() - { - $this->initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $this->initMethod = $this->getMock('Zend\\Code\\Generator\\MethodGenerator'); - $this->publicProperties = $this - ->getMockBuilder('ProxyManager\\ProxyGenerator\\PropertyGenerator\\PublicPropertiesMap') - ->disableOriginalConstructor() - ->getMock(); - - $this->initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); - $this->initMethod->expects($this->any())->method('getName')->will($this->returnValue('baz')); - $this->publicProperties->expects($this->any())->method('isEmpty')->will($this->returnValue(false)); - $this->publicProperties->expects($this->any())->method('getName')->will($this->returnValue('bar')); - } - - /** - * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicUnset::__construct - */ - public function testBodyStructure() - { - $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); - $magicIsset = new MagicUnset($reflection, $this->initializer, $this->initMethod, $this->publicProperties); - - $this->assertSame('__unset', $magicIsset->getName()); - $this->assertCount(1, $magicIsset->getParameters()); - $this->assertStringMatchesFormat( - "\$this->foo && \$this->baz('__unset', array('name' => \$name));\n\n" - . "if (isset(self::\$bar[\$name])) {\n unset(\$this->\$name);\n\n return;\n}" - . "%areturn %s;", - $magicIsset->getBody() - ); - } - - /** - * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicUnset::__construct - */ - public function testBodyStructureWithPublicProperties() - { - $reflection = new ReflectionClass( - 'ProxyManagerTestAsset\\ProxyGenerator\\LazyLoading\\MethodGenerator\\ClassWithTwoPublicProperties' - ); - - $magicIsset = new MagicUnset($reflection, $this->initializer, $this->initMethod, $this->publicProperties); - - $this->assertSame('__unset', $magicIsset->getName()); - $this->assertCount(1, $magicIsset->getParameters()); - $this->assertStringMatchesFormat( - "\$this->foo && \$this->baz('__unset', array('name' => \$name));\n\n" - . "if (isset(self::\$bar[\$name])) {\n unset(\$this->\$name);\n\n return;\n}" - . "%areturn %s;", - $magicIsset->getBody() - ); - } - - /** - * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicUnset::__construct - */ - public function testBodyStructureWithOverriddenMagicGet() - { - $reflection = new ReflectionClass('ProxyManagerTestAsset\\ClassWithMagicMethods'); - $magicIsset = new MagicUnset($reflection, $this->initializer, $this->initMethod, $this->publicProperties); - - $this->assertSame('__unset', $magicIsset->getName()); - $this->assertCount(1, $magicIsset->getParameters()); - $this->assertSame( - "\$this->foo && \$this->baz('__unset', array('name' => \$name));\n\n" - . "if (isset(self::\$bar[\$name])) {\n unset(\$this->\$name);\n\n return;\n}\n\n" - . "return parent::__unset(\$name);", - $magicIsset->getBody() - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/SetProxyInitializerTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/SetProxyInitializerTest.php deleted file mode 100644 index 71fcdbf..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/SetProxyInitializerTest.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class SetProxyInitializerTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\SetProxyInitializer::__construct - */ - public function testBodyStructure() - { - $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - - $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); - - $setter = new SetProxyInitializer($initializer); - $parameters = $setter->getParameters(); - - $this->assertSame('setProxyInitializer', $setter->getName()); - $this->assertCount(1, $parameters); - - /* @var $initializer \ProxyManager\Generator\ParameterGenerator */ - $initializer = array_shift($parameters); - - $this->assertInstanceOf('ProxyManager\\Generator\\ParameterGenerator', $initializer); - $this->assertSame('initializer', $initializer->getName()); - $this->assertSame('$this->foo = $initializer;', $setter->getBody()); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/PropertyGenerator/InitializationTrackerTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/PropertyGenerator/InitializationTrackerTest.php deleted file mode 100644 index 62caf49..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/PropertyGenerator/InitializationTrackerTest.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @license MIT - * - * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\PropertyGenerator\InitializationTracker - * @group Coverage - */ -class InitializationTrackerTest extends AbstractUniquePropertyNameTest -{ - /** - * {@inheritDoc} - */ - protected function createProperty() - { - return new InitializationTracker(); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/PropertyGenerator/InitializerPropertyTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/PropertyGenerator/InitializerPropertyTest.php deleted file mode 100644 index c5f1ea1..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/PropertyGenerator/InitializerPropertyTest.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @license MIT - * - * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\PropertyGenerator\InitializerProperty - * @group Coverage - */ -class InitializerPropertyTest extends AbstractUniquePropertyNameTest -{ - /** - * {@inheritDoc} - */ - protected function createProperty() - { - return new InitializerProperty(); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhostGeneratorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhostGeneratorTest.php deleted file mode 100644 index 8eb5443..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhostGeneratorTest.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @license MIT - * - * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhostGenerator - * @group Coverage - */ -class LazyLoadingGhostGeneratorTest extends AbstractProxyGeneratorTest -{ - /** - * {@inheritDoc} - */ - protected function getProxyGenerator() - { - return new LazyLoadingGhostGenerator(); - } - - /** - * {@inheritDoc} - */ - protected function getExpectedImplementedInterfaces() - { - return array('ProxyManager\\Proxy\\GhostObjectInterface'); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/GetProxyInitializerTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/GetProxyInitializerTest.php deleted file mode 100644 index 31fd029..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/GetProxyInitializerTest.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class GetProxyInitializerTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\GetProxyInitializer::__construct - */ - public function testBodyStructure() - { - $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - - $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); - - $getter = new GetProxyInitializer($initializer); - - $this->assertSame('getProxyInitializer', $getter->getName()); - $this->assertCount(0, $getter->getParameters()); - $this->assertSame('return $this->foo;', $getter->getBody()); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/InitializeProxyTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/InitializeProxyTest.php deleted file mode 100644 index dfbcb4c..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/InitializeProxyTest.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class InitializeProxyTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\InitializeProxy::__construct - */ - public function testBodyStructure() - { - $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $valueHolder = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - - $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); - $valueHolder->expects($this->any())->method('getName')->will($this->returnValue('bar')); - - $initializeProxy = new InitializeProxy($initializer, $valueHolder); - - $this->assertSame('initializeProxy', $initializeProxy->getName()); - $this->assertCount(0, $initializeProxy->getParameters()); - $this->assertSame( - 'return $this->foo && $this->foo->__invoke($this->bar, $this, \'initializeProxy\', array(), $this->foo);', - $initializeProxy->getBody() - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/IsProxyInitializedTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/IsProxyInitializedTest.php deleted file mode 100644 index 2b65f28..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/IsProxyInitializedTest.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class IsProxyInitializedTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\IsProxyInitialized::__construct - */ - public function testBodyStructure() - { - $valueHolder = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - - $valueHolder->expects($this->any())->method('getName')->will($this->returnValue('bar')); - - $isProxyInitialized = new IsProxyInitialized($valueHolder); - - $this->assertSame('isProxyInitialized', $isProxyInitialized->getName()); - $this->assertCount(0, $isProxyInitialized->getParameters()); - $this->assertSame('return null !== $this->bar;', $isProxyInitialized->getBody()); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/LazyLoadingMethodInterceptorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/LazyLoadingMethodInterceptorTest.php deleted file mode 100644 index f6f5d0c..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/LazyLoadingMethodInterceptorTest.php +++ /dev/null @@ -1,84 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class LazyLoadingMethodInterceptorTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\LazyLoadingMethodInterceptor - */ - public function testBodyStructure() - { - $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $valueHolder = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - - $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); - $valueHolder->expects($this->any())->method('getName')->will($this->returnValue('bar')); - - $reflection = new MethodReflection('ProxyManagerTestAsset\\BaseClass', 'publicByReferenceParameterMethod'); - $method = LazyLoadingMethodInterceptor::generateMethod($reflection, $initializer, $valueHolder); - - $this->assertSame('publicByReferenceParameterMethod', $method->getName()); - $this->assertCount(2, $method->getParameters()); - $this->assertSame( - "\$this->foo && \$this->foo->__invoke(\$this->bar, \$this, 'publicByReferenceParameterMethod', " - . "array('param' => \$param, 'byRefParam' => \$byRefParam), \$this->foo);\n\n" - . "return \$this->bar->publicByReferenceParameterMethod(\$param, \$byRefParam);", - $method->getBody() - ); - } - - /** - * @covers \ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\LazyLoadingMethodInterceptor - */ - public function testBodyStructureWithoutParameters() - { - $reflectionMethod = new MethodReflection(__CLASS__, 'testBodyStructureWithoutParameters'); - $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $valueHolder = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - - $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); - $valueHolder->expects($this->any())->method('getName')->will($this->returnValue('bar')); - - $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); - - $method = LazyLoadingMethodInterceptor::generateMethod($reflectionMethod, $initializer, $valueHolder); - - $this->assertSame('testBodyStructureWithoutParameters', $method->getName()); - $this->assertCount(0, $method->getParameters()); - $this->assertSame( - "\$this->foo && \$this->foo->__invoke(\$this->bar, \$this, " - . "'testBodyStructureWithoutParameters', array(), \$this->foo);\n\n" - . "return \$this->bar->testBodyStructureWithoutParameters();", - $method->getBody() - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicCloneTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicCloneTest.php deleted file mode 100644 index dea429c..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicCloneTest.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class MagicCloneTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\MagicClone::__construct - */ - public function testBodyStructure() - { - $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); - $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $valueHolder = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - - $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); - $valueHolder->expects($this->any())->method('getName')->will($this->returnValue('bar')); - - $magicClone = new MagicClone($reflection, $initializer, $valueHolder); - - $this->assertSame('__clone', $magicClone->getName()); - $this->assertCount(0, $magicClone->getParameters()); - $this->assertSame( - "\$this->foo && \$this->foo->__invoke(\$this->bar, \$this, " - . "'__clone', array(), \$this->foo);\n\n\$this->bar = clone \$this->bar;", - $magicClone->getBody() - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicGetTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicGetTest.php deleted file mode 100644 index bc3a61c..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicGetTest.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class MagicGetTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\MagicGet::__construct - */ - public function testBodyStructure() - { - $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); - $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $valueHolder = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $publicProperties = $this - ->getMockBuilder('ProxyManager\\ProxyGenerator\\PropertyGenerator\\PublicPropertiesMap') - ->disableOriginalConstructor() - ->getMock(); - - $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); - $valueHolder->expects($this->any())->method('getName')->will($this->returnValue('bar')); - $publicProperties->expects($this->any())->method('isEmpty')->will($this->returnValue(false)); - $publicProperties->expects($this->any())->method('getName')->will($this->returnValue('bar')); - - $magicGet = new MagicGet($reflection, $initializer, $valueHolder, $publicProperties); - - $this->assertSame('__get', $magicGet->getName()); - $this->assertCount(1, $magicGet->getParameters()); - $this->assertStringMatchesFormat( - "\$this->foo && \$this->foo->__invoke(\$this->bar, \$this, '__get', array('name' => \$name)" - . ", \$this->foo);\n\n" - . "if (isset(self::\$bar[\$name])) {\n return \$this->bar->\$name;\n}" - . "%areturn %s;", - $magicGet->getBody() - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicIssetTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicIssetTest.php deleted file mode 100644 index 751840d..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicIssetTest.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class MagicIssetTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\MagicIsset::__construct - */ - public function testBodyStructure() - { - $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); - $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $valueHolder = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $publicProperties = $this - ->getMockBuilder('ProxyManager\\ProxyGenerator\\PropertyGenerator\\PublicPropertiesMap') - ->disableOriginalConstructor() - ->getMock(); - - $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); - $valueHolder->expects($this->any())->method('getName')->will($this->returnValue('bar')); - $publicProperties->expects($this->any())->method('isEmpty')->will($this->returnValue(false)); - $publicProperties->expects($this->any())->method('getName')->will($this->returnValue('bar')); - - $magicIsset = new MagicIsset($reflection, $initializer, $valueHolder, $publicProperties); - - $this->assertSame('__isset', $magicIsset->getName()); - $this->assertCount(1, $magicIsset->getParameters()); - $this->assertStringMatchesFormat( - "\$this->foo && \$this->foo->__invoke(\$this->bar, \$this, '__isset', array('name' => \$name)" - . ", \$this->foo);\n\n" - . "if (isset(self::\$bar[\$name])) {\n return isset(\$this->bar->\$name);\n}" - . "%areturn %s;", - $magicIsset->getBody() - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicSetTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicSetTest.php deleted file mode 100644 index dba5b49..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicSetTest.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class MagicSetTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\MagicSet::__construct - */ - public function testBodyStructure() - { - $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); - $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $valueHolder = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $publicProperties = $this - ->getMockBuilder('ProxyManager\\ProxyGenerator\\PropertyGenerator\\PublicPropertiesMap') - ->disableOriginalConstructor() - ->getMock(); - - $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); - $valueHolder->expects($this->any())->method('getName')->will($this->returnValue('bar')); - $publicProperties->expects($this->any())->method('isEmpty')->will($this->returnValue(false)); - $publicProperties->expects($this->any())->method('getName')->will($this->returnValue('bar')); - - $magicSet = new MagicSet($reflection, $initializer, $valueHolder, $publicProperties); - - $this->assertSame('__set', $magicSet->getName()); - $this->assertCount(2, $magicSet->getParameters()); - $this->assertStringMatchesFormat( - "\$this->foo && \$this->foo->__invoke(\$this->bar, \$this, " - . "'__set', array('name' => \$name, 'value' => \$value), \$this->foo);\n\n" - . "if (isset(self::\$bar[\$name])) {\n return (\$this->bar->\$name = \$value);\n}" - . "%areturn %s;", - $magicSet->getBody() - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicSleepTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicSleepTest.php deleted file mode 100644 index 978eeb7..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicSleepTest.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class MagicSleepTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\MagicSleep::__construct - */ - public function testBodyStructure() - { - $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); - $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $valueHolder = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - - $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); - $valueHolder->expects($this->any())->method('getName')->will($this->returnValue('bar')); - - $magicSleep = new MagicSleep($reflection, $initializer, $valueHolder); - - $this->assertSame('__sleep', $magicSleep->getName()); - $this->assertCount(0, $magicSleep->getParameters()); - $this->assertSame( - "\$this->foo && \$this->foo->__invoke(\$this->bar, \$this, '__sleep', array(), \$this->foo);" - . "\n\nreturn array('bar');", - $magicSleep->getBody() - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicUnsetTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicUnsetTest.php deleted file mode 100644 index e94ee3b..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/MagicUnsetTest.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class MagicUnsetTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\MagicUnset::__construct - */ - public function testBodyStructure() - { - $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); - $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $valueHolder = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $publicProperties = $this - ->getMockBuilder('ProxyManager\\ProxyGenerator\\PropertyGenerator\\PublicPropertiesMap') - ->disableOriginalConstructor() - ->getMock(); - - $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); - $valueHolder->expects($this->any())->method('getName')->will($this->returnValue('bar')); - $publicProperties->expects($this->any())->method('isEmpty')->will($this->returnValue(false)); - $publicProperties->expects($this->any())->method('getName')->will($this->returnValue('bar')); - - $magicIsset = new MagicUnset($reflection, $initializer, $valueHolder, $publicProperties); - - $this->assertSame('__unset', $magicIsset->getName()); - $this->assertCount(1, $magicIsset->getParameters()); - $this->assertStringMatchesFormat( - "\$this->foo && \$this->foo->__invoke(\$this->bar, \$this, '__unset', array('name' => \$name)" - . ", \$this->foo);\n\n" - . "if (isset(self::\$bar[\$name])) {\n unset(\$this->bar->\$name);\n\n return;\n}" - . "%areturn %s;", - $magicIsset->getBody() - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/SetProxyInitializerTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/SetProxyInitializerTest.php deleted file mode 100644 index d70bf2c..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/MethodGenerator/SetProxyInitializerTest.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class SetProxyInitializerTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\SetProxyInitializer::__construct - */ - public function testBodyStructure() - { - $initializer = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - - $initializer->expects($this->any())->method('getName')->will($this->returnValue('foo')); - - $setter = new SetProxyInitializer($initializer); - $parameters = $setter->getParameters(); - - $this->assertSame('setProxyInitializer', $setter->getName()); - $this->assertCount(1, $parameters); - - /* @var $initializer \ProxyManager\Generator\ParameterGenerator */ - $initializer = array_shift($parameters); - - $this->assertInstanceOf('ProxyManager\\Generator\\ParameterGenerator', $initializer); - $this->assertSame('initializer', $initializer->getName()); - $this->assertSame('$this->foo = $initializer;', $setter->getBody()); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/PropertyGenerator/InitializerPropertyTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/PropertyGenerator/InitializerPropertyTest.php deleted file mode 100644 index c292e20..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/PropertyGenerator/InitializerPropertyTest.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @license MIT - * - * @covers \ProxyManager\ProxyGenerator\LazyLoadingValueHolder\PropertyGenerator\InitializerProperty - * @group Coverage - */ -class InitializerPropertyTest extends AbstractUniquePropertyNameTest -{ - /** - * {@inheritDoc} - */ - protected function createProperty() - { - return new InitializerProperty(); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/PropertyGenerator/ValueHolderPropertyTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/PropertyGenerator/ValueHolderPropertyTest.php deleted file mode 100644 index 63a16a7..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolder/PropertyGenerator/ValueHolderPropertyTest.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @license MIT - * - * @covers \ProxyManager\ProxyGenerator\LazyLoadingValueHolder\PropertyGenerator\ValueHolderProperty - * @group Coverage - */ -class ValueHolderPropertyTest extends AbstractUniquePropertyNameTest -{ - /** - * {@inheritDoc} - */ - protected function createProperty() - { - return new ValueHolderProperty(); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolderGeneratorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolderGeneratorTest.php deleted file mode 100644 index 683e2c9..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/LazyLoadingValueHolderGeneratorTest.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @license MIT - * - * @covers \ProxyManager\ProxyGenerator\LazyLoadingValueHolderGenerator - * @group Coverage - */ -class LazyLoadingValueHolderGeneratorTest extends AbstractProxyGeneratorTest -{ - /** - * {@inheritDoc} - */ - protected function getProxyGenerator() - { - return new LazyLoadingValueHolderGenerator(); - } - - /** - * {@inheritDoc} - */ - protected function getExpectedImplementedInterfaces() - { - return array('ProxyManager\\Proxy\\VirtualProxyInterface'); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/NullObject/MethodGenerator/ConstructorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/NullObject/MethodGenerator/ConstructorTest.php deleted file mode 100644 index 7fad56d..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/NullObject/MethodGenerator/ConstructorTest.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class ConstructorTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\NullObject\MethodGenerator\Constructor::__construct - */ - public function testBodyStructure() - { - $reflection = new ReflectionClass('ProxyManagerTestAsset\\ClassWithMixedProperties'); - $constructor = new Constructor($reflection); - - $this->assertSame('__construct', $constructor->getName()); - $this->assertCount(0, $constructor->getParameters()); - $this->assertSame( - "\$this->publicProperty0 = null;\n\$this->publicProperty1 = null;\n\$this->publicProperty2 = null;", - $constructor->getBody() - ); - } - - /** - * @covers \ProxyManager\ProxyGenerator\NullObject\MethodGenerator\Constructor::__construct - */ - public function testBodyStructureWithoutPublicProperties() - { - $reflection = new ReflectionClass('ProxyManagerTestAsset\\ClassWithPrivateProperties'); - $constructor = new Constructor($reflection); - - $this->assertSame('__construct', $constructor->getName()); - $this->assertCount(0, $constructor->getParameters()); - $body = $constructor->getBody(); - $this->assertTrue(empty($body)); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/NullObject/MethodGenerator/NullObjectMethodInterceptorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/NullObject/MethodGenerator/NullObjectMethodInterceptorTest.php deleted file mode 100644 index 31202a1..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/NullObject/MethodGenerator/NullObjectMethodInterceptorTest.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class NullObjectMethodInterceptorTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\NullObject\MethodGenerator\NullObjectMethodInterceptor - */ - public function testBodyStructure() - { - $reflection = new MethodReflection('ProxyManagerTestAsset\\BaseClass', 'publicByReferenceParameterMethod'); - $method = NullObjectMethodInterceptor::generateMethod($reflection); - - $this->assertSame('publicByReferenceParameterMethod', $method->getName()); - $this->assertCount(2, $method->getParameters()); - $this->assertSame("", $method->getBody()); - } - - /** - * @covers \ProxyManager\ProxyGenerator\NullObject\MethodGenerator\NullObjectMethodInterceptor - */ - public function testBodyStructureWithoutParameters() - { - $reflectionMethod = new MethodReflection(__CLASS__, 'testBodyStructureWithoutParameters'); - - $method = NullObjectMethodInterceptor::generateMethod($reflectionMethod); - - $this->assertSame('testBodyStructureWithoutParameters', $method->getName()); - $this->assertCount(0, $method->getParameters()); - $this->assertSame("", $method->getBody()); - } - - /** - * @covers \ProxyManager\ProxyGenerator\NullObject\MethodGenerator\NullObjectMethodInterceptor - */ - public function testBodyStructureWithoutByRefReturn() - { - $reflectionMethod = new MethodReflection('ProxyManagerTestAsset\BaseClass', 'publicByReferenceMethod'); - - $method = NullObjectMethodInterceptor::generateMethod($reflectionMethod); - - $this->assertSame('publicByReferenceMethod', $method->getName()); - $this->assertCount(0, $method->getParameters()); - $this->assertStringMatchesFormat("\$ref%s = null;\nreturn \$ref%s;", $method->getBody()); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/NullObjectGeneratorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/NullObjectGeneratorTest.php deleted file mode 100644 index 11a6cbd..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/NullObjectGeneratorTest.php +++ /dev/null @@ -1,113 +0,0 @@ - - * @license MIT - * - * @covers \ProxyManager\ProxyGenerator\NullObjectGenerator - * @group Coverage - */ -class NullObjectGeneratorTest extends PHPUnit_Framework_TestCase -{ - /** - * @dataProvider getTestedImplementations - * - * Verifies that generated code is valid and implements expected interfaces - */ - public function testGeneratesValidCode($className) - { - $generator = $this->getProxyGenerator(); - $generatedClassName = UniqueIdentifierGenerator::getIdentifier('AbstractProxyGeneratorTest'); - $generatedClass = new ClassGenerator($generatedClassName); - $originalClass = new ReflectionClass($className); - $generatorStrategy = new EvaluatingGeneratorStrategy(); - - $generator->generate($originalClass, $generatedClass); - $generatorStrategy->generate($generatedClass); - - $generatedReflection = new ReflectionClass($generatedClassName); - - if ($originalClass->isInterface()) { - $this->assertTrue($generatedReflection->implementsInterface($className)); - } - - $this->assertSame($generatedClassName, $generatedReflection->getName()); - - foreach ($this->getExpectedImplementedInterfaces() as $interface) { - $this->assertTrue($generatedReflection->implementsInterface($interface)); - } - - $proxyGenerated = new $generatedClassName(); - - foreach ($generatedReflection->getProperties(ReflectionProperty::IS_PUBLIC) as $property) { - $this->assertNull($proxyGenerated->$property); - } - - /** @var \ReflectionMethod $method */ - foreach ($generatedReflection->getMethods(ReflectionProperty::IS_PUBLIC) as $method) { - if ($method->getNumberOfParameters() == 0) { - $this->assertNull(call_user_func(array($proxyGenerated, $method->getName()))); - } - } - } - - /** - * {@inheritDoc} - */ - protected function getProxyGenerator() - { - return new NullObjectGenerator(); - } - - /** - * {@inheritDoc} - */ - protected function getExpectedImplementedInterfaces() - { - return array( - 'ProxyManager\\Proxy\\NullObjectInterface', - ); - } - - /** - * @return array - */ - public function getTestedImplementations() - { - return array( - array('ProxyManagerTestAsset\\BaseClass'), - array('ProxyManagerTestAsset\\ClassWithMagicMethods'), - array('ProxyManagerTestAsset\\ClassWithByRefMagicMethods'), - array('ProxyManagerTestAsset\\ClassWithMixedProperties'), - array('ProxyManagerTestAsset\\BaseInterface'), - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/PropertyGenerator/AbstractUniquePropertyNameTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/PropertyGenerator/AbstractUniquePropertyNameTest.php deleted file mode 100644 index f3cd8ad..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/PropertyGenerator/AbstractUniquePropertyNameTest.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -abstract class AbstractUniquePropertyNameTest extends PHPUnit_Framework_TestCase -{ - /** - * Verifies that a given property name is unique across two different instantiations of the property - */ - public function testUniqueProperty() - { - $property1 = $this->createProperty(); - $property2 = $this->createProperty(); - - $this->assertSame($property1->getName(), $property1->getName()); - $this->assertNotEquals($property1->getName(), $property2->getName()); - } - - /** - * @return \Zend\Code\Generator\PropertyGenerator - */ - abstract protected function createProperty(); -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/PropertyGenerator/PublicPropertiesDefaultsTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/PropertyGenerator/PublicPropertiesDefaultsTest.php deleted file mode 100644 index c714675..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/PropertyGenerator/PublicPropertiesDefaultsTest.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @license MIT - * - * @covers \ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesDefaults - * @group Coverage - */ -class PublicPropertiesDefaultsTest extends PHPUnit_Framework_TestCase -{ - public function testEmptyClass() - { - $publicProperties = new PublicPropertiesDefaults(new ReflectionClass('ProxyManagerTestAsset\\EmptyClass')); - - $this->assertInternalType('array', $publicProperties->getDefaultValue()->getValue()); - $this->assertEmpty($publicProperties->getDefaultValue()->getValue()); - $this->assertTrue($publicProperties->isStatic()); - $this->assertSame(PublicPropertiesDefaults::VISIBILITY_PRIVATE, $publicProperties->getVisibility()); - } - - public function testClassWithPublicProperties() - { - $publicProperties = new PublicPropertiesDefaults( - new ReflectionClass('ProxyManagerTestAsset\\ClassWithPublicProperties') - ); - - $this->assertInternalType('array', $publicProperties->getDefaultValue()->getValue()); - $this->assertCount(10, $publicProperties->getDefaultValue()->getValue()); - $this->assertTrue($publicProperties->isStatic()); - $this->assertSame(PublicPropertiesDefaults::VISIBILITY_PRIVATE, $publicProperties->getVisibility()); - } - - public function testBaseClass() - { - $publicProperties = new PublicPropertiesDefaults( - new ReflectionClass('ProxyManagerTestAsset\\BaseClass') - ); - - $this->assertInternalType('array', $publicProperties->getDefaultValue()->getValue()); - $this->assertSame( - array('publicProperty' => 'publicPropertyDefault'), - $publicProperties->getDefaultValue()->getValue() - ); - $this->assertTrue($publicProperties->isStatic()); - $this->assertSame(PublicPropertiesDefaults::VISIBILITY_PRIVATE, $publicProperties->getVisibility()); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/PropertyGenerator/PublicPropertiesMapTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/PropertyGenerator/PublicPropertiesMapTest.php deleted file mode 100644 index a916762..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/PropertyGenerator/PublicPropertiesMapTest.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @license MIT - * - * @covers \ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesMap - * @group Coverage - */ -class PublicPropertiesMapTest extends PHPUnit_Framework_TestCase -{ - public function testEmptyClass() - { - $publicProperties = new PublicPropertiesMap(new ReflectionClass('ProxyManagerTestAsset\\EmptyClass')); - - $this->assertInternalType('array', $publicProperties->getDefaultValue()->getValue()); - $this->assertEmpty($publicProperties->getDefaultValue()->getValue()); - $this->assertTrue($publicProperties->isStatic()); - $this->assertSame('private', $publicProperties->getVisibility()); - $this->assertTrue($publicProperties->isEmpty()); - } - - public function testClassWithPublicProperties() - { - $publicProperties = new PublicPropertiesMap( - new ReflectionClass('ProxyManagerTestAsset\\ClassWithPublicProperties') - ); - - $this->assertInternalType('array', $publicProperties->getDefaultValue()->getValue()); - $this->assertCount(10, $publicProperties->getDefaultValue()->getValue()); - $this->assertTrue($publicProperties->isStatic()); - $this->assertSame('private', $publicProperties->getVisibility()); - $this->assertFalse($publicProperties->isEmpty()); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/ConstructorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/ConstructorTest.php deleted file mode 100644 index f1c9da0..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/ConstructorTest.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class ConstructorTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\Constructor::__construct - */ - public function testBodyStructure() - { - $adapter = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $adapter->expects($this->any())->method('getName')->will($this->returnValue('adapter')); - - $reflection = new ReflectionClass('ProxyManagerTestAsset\\ClassWithMixedProperties'); - $constructor = new Constructor($reflection, $adapter); - - $this->assertSame('__construct', $constructor->getName()); - $this->assertCount(1, $constructor->getParameters()); - $this->assertSame( - "\$this->adapter = \$adapter;\nunset(\$this->publicProperty0);" - . "\nunset(\$this->publicProperty1);\nunset(\$this->publicProperty2);", - $constructor->getBody() - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/MagicGetTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/MagicGetTest.php deleted file mode 100644 index 096a891..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/MagicGetTest.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class MagicGetTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\MagicGet::__construct - */ - public function testBodyStructure() - { - $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); - $adapter = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $adapter->expects($this->any())->method('getName')->will($this->returnValue('foo')); - - $magicGet = new MagicGet($reflection, $adapter); - - $this->assertSame('__get', $magicGet->getName()); - $this->assertCount(1, $magicGet->getParameters()); - $this->assertStringMatchesFormat( - '$return = $this->foo->call(\'ProxyManagerTestAsset\\\EmptyClass\', \'__get\', array($name));' - . "\n\nreturn \$return;", - $magicGet->getBody() - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/MagicIssetTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/MagicIssetTest.php deleted file mode 100644 index 23ba337..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/MagicIssetTest.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class MagicIssetTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\MagicIsset::__construct - */ - public function testBodyStructure() - { - $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); - $adapter = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $adapter->expects($this->any())->method('getName')->will($this->returnValue('foo')); - - $magicGet = new MagicIsset($reflection, $adapter); - - $this->assertSame('__isset', $magicGet->getName()); - $this->assertCount(1, $magicGet->getParameters()); - $this->assertStringMatchesFormat( - '$return = $this->foo->call(\'ProxyManagerTestAsset\\\EmptyClass\', \'__isset\', array($name));' - . "\n\nreturn \$return;", - $magicGet->getBody() - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/MagicSetTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/MagicSetTest.php deleted file mode 100644 index 6034b99..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/MagicSetTest.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class MagicSetTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\MagicSet::__construct - */ - public function testBodyStructure() - { - $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); - $adapter = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $adapter->expects($this->any())->method('getName')->will($this->returnValue('foo')); - - $magicGet = new MagicSet($reflection, $adapter); - - $this->assertSame('__set', $magicGet->getName()); - $this->assertCount(2, $magicGet->getParameters()); - $this->assertStringMatchesFormat( - '$return = $this->foo->call(\'ProxyManagerTestAsset\\\EmptyClass\', \'__set\', array($name, $value));' - . "\n\nreturn \$return;", - $magicGet->getBody() - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/MagicUnsetTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/MagicUnsetTest.php deleted file mode 100644 index a3f186f..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/MagicUnsetTest.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class MagicUnsetTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\MagicUnset::__construct - */ - public function testBodyStructure() - { - $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); - $adapter = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $adapter->expects($this->any())->method('getName')->will($this->returnValue('foo')); - - $magicGet = new MagicUnset($reflection, $adapter); - - $this->assertSame('__unset', $magicGet->getName()); - $this->assertCount(1, $magicGet->getParameters()); - $this->assertStringMatchesFormat( - '$return = $this->foo->call(\'ProxyManagerTestAsset\\\EmptyClass\', \'__unset\', array($name));' - . "\n\nreturn \$return;", - $magicGet->getBody() - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/RemoteObjectMethodTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/RemoteObjectMethodTest.php deleted file mode 100644 index 1c41a4f..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/MethodGenerator/RemoteObjectMethodTest.php +++ /dev/null @@ -1,116 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class RemoteObjectMethodTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\RemoteObjectMethod - */ - public function testBodyStructureWithParameters() - { - $adapter = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $adapter->expects($this->any())->method('getName')->will($this->returnValue('adapter')); - - $reflectionMethod = new MethodReflection( - 'ProxyManagerTestAsset\\BaseClass', - 'publicByReferenceParameterMethod' - ); - - $method = RemoteObjectMethod::generateMethod( - $reflectionMethod, - $adapter, - new ReflectionClass('Zend\\Code\\Generator\\PropertyGenerator') - ); - - $this->assertSame('publicByReferenceParameterMethod', $method->getName()); - $this->assertCount(2, $method->getParameters()); - $this->assertSame( - '$return = $this->adapter->call(\'Zend\\\Code\\\Generator\\\PropertyGenerator\', ' - . '\'publicByReferenceParameterMethod\', array($param, $byRefParam));' - . "\n\nreturn \$return;", - $method->getBody() - ); - } - - /** - * @covers \ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\RemoteObjectMethod - */ - public function testBodyStructureWithArrayParameter() - { - $adapter = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $adapter->expects($this->any())->method('getName')->will($this->returnValue('adapter')); - - $reflectionMethod = new MethodReflection('ProxyManagerTestAsset\\BaseClass', 'publicArrayHintedMethod'); - - $method = RemoteObjectMethod::generateMethod( - $reflectionMethod, - $adapter, - new ReflectionClass('Zend\\Code\\Generator\\PropertyGenerator') - ); - - $this->assertSame('publicArrayHintedMethod', $method->getName()); - $this->assertCount(1, $method->getParameters()); - $this->assertSame( - '$return = $this->adapter->call(\'Zend\\\Code\\\Generator\\\PropertyGenerator\', ' - . '\'publicArrayHintedMethod\', array($param));' - . "\n\nreturn \$return;", - $method->getBody() - ); - } - - /** - * @covers \ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\RemoteObjectMethod - */ - public function testBodyStructureWithoutParameters() - { - $adapter = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - $adapter->expects($this->any())->method('getName')->will($this->returnValue('adapter')); - - $reflectionMethod = new MethodReflection(__CLASS__, 'testBodyStructureWithoutParameters'); - - $method = RemoteObjectMethod::generateMethod( - $reflectionMethod, - $adapter, - new ReflectionClass('Zend\\Code\\Generator\\PropertyGenerator') - ); - - $this->assertSame('testBodyStructureWithoutParameters', $method->getName()); - $this->assertCount(0, $method->getParameters()); - $this->assertSame( - '$return = $this->adapter->call(\'Zend\\\Code\\\Generator\\\PropertyGenerator\', ' - . '\'testBodyStructureWithoutParameters\', array());' - . "\n\nreturn \$return;", - $method->getBody() - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/PropertyGenerator/AdapterPropertyTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/PropertyGenerator/AdapterPropertyTest.php deleted file mode 100644 index d7e9cc9..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObject/PropertyGenerator/AdapterPropertyTest.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @license MIT - * - * @covers \ProxyManager\ProxyGenerator\RemoteObject\PropertyGenerator\AdapterProperty - * @group Coverage - */ -class AdapterPropertyTest extends AbstractUniquePropertyNameTest -{ - /** - * {@inheritDoc} - */ - protected function createProperty() - { - return new AdapterProperty(); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObjectGeneratorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObjectGeneratorTest.php deleted file mode 100644 index 961c226..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/RemoteObjectGeneratorTest.php +++ /dev/null @@ -1,103 +0,0 @@ - - * @license MIT - * - * @covers \ProxyManager\ProxyGenerator\RemoteObjectGenerator - * @group Coverage - */ -class RemoteObjectGeneratorTest extends PHPUnit_Framework_TestCase -{ - /** - * @dataProvider getTestedImplementations - * - * Verifies that generated code is valid and implements expected interfaces - */ - public function testGeneratesValidCode($className) - { - $generator = $this->getProxyGenerator(); - $generatedClassName = UniqueIdentifierGenerator::getIdentifier('AbstractProxyGeneratorTest'); - $generatedClass = new ClassGenerator($generatedClassName); - $originalClass = new ReflectionClass($className); - $generatorStrategy = new EvaluatingGeneratorStrategy(); - - $generator->generate($originalClass, $generatedClass); - $generatorStrategy->generate($generatedClass); - - $generatedReflection = new ReflectionClass($generatedClassName); - - if ($originalClass->isInterface()) { - $this->assertTrue($generatedReflection->implementsInterface($className)); - } else { - $this->assertEmpty( - array_diff($originalClass->getInterfaceNames(), $generatedReflection->getInterfaceNames()) - ); - } - - $this->assertSame($generatedClassName, $generatedReflection->getName()); - - foreach ($this->getExpectedImplementedInterfaces() as $interface) { - $this->assertTrue($generatedReflection->implementsInterface($interface)); - } - } - - /** - * {@inheritDoc} - */ - protected function getProxyGenerator() - { - return new RemoteObjectGenerator(); - } - - /** - * {@inheritDoc} - */ - protected function getExpectedImplementedInterfaces() - { - return array( - 'ProxyManager\\Proxy\\RemoteObjectInterface', - ); - } - - /** - * @return array - */ - public function getTestedImplementations() - { - return array( - array('ProxyManagerTestAsset\\BaseClass'), - array('ProxyManagerTestAsset\\ClassWithMagicMethods'), - array('ProxyManagerTestAsset\\ClassWithByRefMagicMethods'), - array('ProxyManagerTestAsset\\ClassWithMixedProperties'), - array('ProxyManagerTestAsset\\BaseInterface'), - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/Util/ProxiedMethodsFilterTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/Util/ProxiedMethodsFilterTest.php deleted file mode 100644 index 89bbb6a..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/Util/ProxiedMethodsFilterTest.php +++ /dev/null @@ -1,114 +0,0 @@ - - * @license MIT - * - * @covers \ProxyManager\ProxyGenerator\Util\ProxiedMethodsFilter - * @group Coverage - */ -class ProxiedMethodsFilterTest extends PHPUnit_Framework_TestCase -{ - /** - * @dataProvider expectedMethods - */ - public function testFiltering(ReflectionClass $reflectionClass, $excludes, array $expectedMethods) - { - if (is_array($excludes)) { - $filtered = ProxiedMethodsFilter::getProxiedMethods($reflectionClass, $excludes); - } else { - $filtered = ProxiedMethodsFilter::getProxiedMethods($reflectionClass); - } - - foreach ($filtered as $method) { - $this->assertInstanceOf('ReflectionMethod', $method); - } - - $keys = array_map( - function (ReflectionMethod $method) { - return $method->getName(); - }, - $filtered - ); - - sort($keys); - sort($expectedMethods); - - $this->assertSame($keys, $expectedMethods); - } - - /** - * @return array[][] - */ - public function expectedMethods() - { - return array( - array( - new ReflectionClass('ProxyManagerTestAsset\\BaseClass'), - null, - array( - 'publicArrayHintedMethod', - 'publicByReferenceMethod', - 'publicByReferenceParameterMethod', - 'publicMethod', - 'publicTypeHintedMethod', - ), - ), - array( - new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'), - null, - array(), - ), - array( - new ReflectionClass('ProxyManagerTestAsset\\LazyLoadingMock'), - null, - array(), - ), - array( - new ReflectionClass('ProxyManagerTestAsset\\LazyLoadingMock'), - array(), - array(), - ), - array( - new ReflectionClass('ProxyManagerTestAsset\\HydratedObject'), - array('doFoo'), - array('__get'), - ), - array( - new ReflectionClass('ProxyManagerTestAsset\\HydratedObject'), - array('Dofoo'), - array('__get'), - ), - array( - new ReflectionClass('ProxyManagerTestAsset\\HydratedObject'), - array(), - array('doFoo', '__get'), - ), - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/Util/PublicScopeSimulatorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/Util/PublicScopeSimulatorTest.php deleted file mode 100644 index e5271ff..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/Util/PublicScopeSimulatorTest.php +++ /dev/null @@ -1,133 +0,0 @@ - - * @license MIT - * - * @covers \ProxyManager\ProxyGenerator\Util\PublicScopeSimulator - * @group Coverage - */ -class PublicScopeSimulatorTest extends PHPUnit_Framework_TestCase -{ - public function testSimpleGet() - { - $code = PublicScopeSimulator::getPublicAccessSimulationCode( - PublicScopeSimulator::OPERATION_GET, - 'foo', - null, - null, - 'bar' - ); - - $this->assertStringMatchesFormat('%a{%areturn $%s->$foo;%a}%a$bar = %s;', $code); - } - - public function testSimpleSet() - { - $code = PublicScopeSimulator::getPublicAccessSimulationCode( - PublicScopeSimulator::OPERATION_SET, - 'foo', - 'baz', - null, - 'bar' - ); - - $this->assertStringMatchesFormat('%a{%areturn $%s->$foo = $baz;%a}%a$bar = %s;', $code); - } - - public function testSimpleIsset() - { - $code = PublicScopeSimulator::getPublicAccessSimulationCode( - PublicScopeSimulator::OPERATION_ISSET, - 'foo', - null, - null, - 'bar' - ); - - $this->assertStringMatchesFormat('%a{%areturn isset($%s->$foo);%a}%a$bar = %s;', $code); - } - - public function testSimpleUnset() - { - $code = PublicScopeSimulator::getPublicAccessSimulationCode( - PublicScopeSimulator::OPERATION_UNSET, - 'foo', - null, - null, - 'bar' - ); - - $this->assertStringMatchesFormat('%a{%aunset($%s->$foo);%a}%a$bar = %s;', $code); - } - - public function testSetRequiresValueParameterName() - { - $this->setExpectedException('InvalidArgumentException'); - - PublicScopeSimulator::getPublicAccessSimulationCode( - PublicScopeSimulator::OPERATION_SET, - 'foo', - null, - null, - 'bar' - ); - } - - public function testDelegatesToValueHolderWhenAvailable() - { - $code = PublicScopeSimulator::getPublicAccessSimulationCode( - PublicScopeSimulator::OPERATION_SET, - 'foo', - 'baz', - new PropertyGenerator('valueHolder'), - 'bar' - ); - - $this->assertStringMatchesFormat( - '%A$targetObject = $this->valueHolder;%a{%areturn $%s->$foo = $baz;%a}%a$bar = %s;', - $code - ); - } - - public function testSetRequiresValidOperation() - { - $this->setExpectedException('InvalidArgumentException'); - - PublicScopeSimulator::getPublicAccessSimulationCode('invalid', 'foo'); - } - - public function testWillReturnDirectlyWithNoReturnParam() - { - $code = PublicScopeSimulator::getPublicAccessSimulationCode( - PublicScopeSimulator::OPERATION_GET, - 'foo' - ); - - $this->assertStringMatchesFormat('%a{%areturn $%s->$foo;%a}%areturn %s;', $code); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/ValueHolder/MethodGenerator/GetWrappedValueHolderValueTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/ValueHolder/MethodGenerator/GetWrappedValueHolderValueTest.php deleted file mode 100644 index b7acb31..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/ValueHolder/MethodGenerator/GetWrappedValueHolderValueTest.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class GetWrappedValueHolderValueTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\ValueHolder\MethodGenerator\GetWrappedValueHolderValue::__construct - */ - public function testBodyStructure() - { - $valueHolder = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - - $valueHolder->expects($this->any())->method('getName')->will($this->returnValue('foo')); - - $getter = new GetWrappedValueHolderValue($valueHolder); - - $this->assertSame('getWrappedValueHolderValue', $getter->getName()); - $this->assertCount(0, $getter->getParameters()); - $this->assertSame('return $this->foo;', $getter->getBody()); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/ValueHolder/MethodGenerator/MagicSleepTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/ValueHolder/MethodGenerator/MagicSleepTest.php deleted file mode 100644 index f2b1596..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/ValueHolder/MethodGenerator/MagicSleepTest.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @license MIT - * - * @group Coverage - */ -class MagicSleepTest extends PHPUnit_Framework_TestCase -{ - /** - * @covers \ProxyManager\ProxyGenerator\ValueHolder\MethodGenerator\MagicSleep::__construct - */ - public function testBodyStructure() - { - $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'); - $valueHolder = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator'); - - $valueHolder->expects($this->any())->method('getName')->will($this->returnValue('bar')); - - $magicSleep = new MagicSleep($reflection, $valueHolder); - - $this->assertSame('__sleep', $magicSleep->getName()); - $this->assertCount(0, $magicSleep->getParameters()); - $this->assertSame( - "return array('bar');", - $magicSleep->getBody() - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Signature/ClassSignatureGeneratorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Signature/ClassSignatureGeneratorTest.php deleted file mode 100644 index 95ffbdd..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Signature/ClassSignatureGeneratorTest.php +++ /dev/null @@ -1,87 +0,0 @@ - - * @license MIT - * - * @covers \ProxyManager\Signature\ClassSignatureGenerator - * @group Coverage - */ -class ClassSignatureGeneratorTest extends PHPUnit_Framework_TestCase -{ - /** - * @var \ProxyManager\Signature\SignatureGeneratorInterface|\PHPUnit_Framework_MockObject_MockObject - */ - private $signatureGenerator; - - /** - * @var ClassSignatureGenerator - */ - private $classSignatureGenerator; - - /** - * {@inheritDoc} - */ - protected function setUp() - { - $this->signatureGenerator = $this->getMock('ProxyManager\\Signature\\SignatureGeneratorInterface'); - $this->classSignatureGenerator = new ClassSignatureGenerator($this->signatureGenerator); - } - - public function testAddSignature() - { - /* @var $classGenerator \PHPUnit_Framework_MockObject_MockObject|\Zend\Code\Generator\ClassGenerator */ - $classGenerator = $this->getMock('Zend\\Code\\Generator\\ClassGenerator'); - - $classGenerator - ->expects($this->once()) - ->method('addPropertyFromGenerator') - ->with($this->callback(function (PropertyGenerator $property) { - return $property->getName() === 'signaturePropertyName' - && $property->isStatic() - && $property->getVisibility() === 'private' - && $property->getDefaultValue()->getValue() === 'valid-signature'; - })); - - $this - ->signatureGenerator - ->expects($this->any()) - ->method('generateSignature') - ->with(array('foo' => 'bar')) - ->will($this->returnValue('valid-signature')); - - $this - ->signatureGenerator - ->expects($this->any()) - ->method('generateSignatureKey') - ->with(array('foo' => 'bar')) - ->will($this->returnValue('PropertyName')); - - - $this->classSignatureGenerator->addSignature($classGenerator, array('foo' => 'bar')); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Signature/Exception/InvalidSignatureExceptionTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Signature/Exception/InvalidSignatureExceptionTest.php deleted file mode 100644 index d587fc0..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Signature/Exception/InvalidSignatureExceptionTest.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @license MIT - * - * @covers \ProxyManager\Signature\Exception\InvalidSignatureException - * @group Coverage - */ -class InvalidSignatureExceptionTest extends PHPUnit_Framework_TestCase -{ - public function testFromInvalidSignature() - { - $exception = InvalidSignatureException::fromInvalidSignature( - new ReflectionClass(__CLASS__), - array('foo' => 'bar', 'baz' => 'tab'), - 'blah', - 'expected-signature' - ); - - $this->assertInstanceOf( - 'ProxyManager\Signature\Exception\InvalidSignatureException', - $exception - ); - - $this->assertSame( - 'Found signature "blah" for class "' - . __CLASS__ - . '" does not correspond to expected signature "expected-signature" for 2 parameters', - $exception->getMessage() - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Signature/Exception/MissingSignatureExceptionTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Signature/Exception/MissingSignatureExceptionTest.php deleted file mode 100644 index 2d8a0d8..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Signature/Exception/MissingSignatureExceptionTest.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @license MIT - * - * @covers \ProxyManager\Signature\Exception\MissingSignatureException - * @group Coverage - */ -class MissingSignatureExceptionTest extends PHPUnit_Framework_TestCase -{ - public function testFromMissingSignature() - { - $exception = MissingSignatureException::fromMissingSignature( - new ReflectionClass(__CLASS__), - array('foo' => 'bar', 'baz' => 'tab'), - 'expected-signature' - ); - - $this->assertInstanceOf( - 'ProxyManager\Signature\Exception\MissingSignatureException', - $exception - ); - - $this->assertSame( - 'No signature found for class "' - . __CLASS__ - . '", expected signature "expected-signature" for 2 parameters', - $exception->getMessage() - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Signature/SignatureCheckerTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Signature/SignatureCheckerTest.php deleted file mode 100644 index 0fa13f9..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Signature/SignatureCheckerTest.php +++ /dev/null @@ -1,117 +0,0 @@ - - * @license MIT - * - * @covers \ProxyManager\Signature\SignatureChecker - * @group Coverage - */ -class SignatureCheckerTest extends PHPUnit_Framework_TestCase -{ - /** - * @var string - */ - protected $signatureExample = 'valid-signature'; - - /** - * @var SignatureChecker - */ - private $signatureChecker; - - /** - * @var \ProxyManager\Signature\SignatureGeneratorInterface|\PHPUnit_Framework_MockObject_MockObject - */ - private $signatureGenerator; - - /** - * {@inheritDoc} - */ - protected function setUp() - { - $this->signatureGenerator = $this->getMock('ProxyManager\Signature\SignatureGeneratorInterface'); - $this->signatureChecker = new SignatureChecker($this->signatureGenerator); - } - - public function testCheckSignatureWithValidKey() - { - $this - ->signatureGenerator - ->expects($this->atLeastOnce()) - ->method('generateSignatureKey') - ->with(array('foo' => 'bar')) - ->will($this->returnValue('Example')); - $this - ->signatureGenerator - ->expects($this->atLeastOnce()) - ->method('generateSignature') - ->with(array('foo' => 'bar')) - ->will($this->returnValue('valid-signature')); - - $this->signatureChecker->checkSignature(new ReflectionClass($this), array('foo' => 'bar')); - } - - public function testCheckSignatureWithInvalidKey() - { - $this - ->signatureGenerator - ->expects($this->any()) - ->method('generateSignatureKey') - ->with(array('foo' => 'bar')) - ->will($this->returnValue('InvalidKey')); - $this - ->signatureGenerator - ->expects($this->any()) - ->method('generateSignature') - ->with(array('foo' => 'bar')) - ->will($this->returnValue('valid-signature')); - - $this->setExpectedException('ProxyManager\Signature\Exception\MissingSignatureException'); - - $this->signatureChecker->checkSignature(new ReflectionClass($this), array('foo' => 'bar')); - } - - public function testCheckSignatureWithInvalidValue() - { - $this - ->signatureGenerator - ->expects($this->any()) - ->method('generateSignatureKey') - ->with(array('foo' => 'bar')) - ->will($this->returnValue('Example')); - $this - ->signatureGenerator - ->expects($this->any()) - ->method('generateSignature') - ->with(array('foo' => 'bar')) - ->will($this->returnValue('invalid-signature')); - - $this->setExpectedException('ProxyManager\Signature\Exception\InvalidSignatureException'); - - $this->signatureChecker->checkSignature(new ReflectionClass($this), array('foo' => 'bar')); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Signature/SignatureGeneratorTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Signature/SignatureGeneratorTest.php deleted file mode 100644 index 5ad93d6..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/Signature/SignatureGeneratorTest.php +++ /dev/null @@ -1,116 +0,0 @@ - - * @license MIT - * - * @covers \ProxyManager\Signature\SignatureGenerator - * @group Coverage - */ -class SignatureGeneratorTest extends PHPUnit_Framework_TestCase -{ - /** - * @var SignatureGenerator - */ - private $signatureGenerator; - - /** - * {@inheritDoc} - */ - protected function setUp() - { - $this->signatureGenerator = new SignatureGenerator; - } - - /** - * @param array $parameters - * @param string $expected - * - * @dataProvider signatures - */ - public function testGenerateSignature(array $parameters, $expected) - { - $this->assertSame($expected, $this->signatureGenerator->generateSignature($parameters)); - } - - /** - * @param array $parameters - * @param string $expected - * - * @dataProvider signatureKeys - */ - public function testGenerateSignatureKey(array $parameters, $expected) - { - $this->assertSame($expected, $this->signatureGenerator->generateSignatureKey($parameters)); - } - - /** - * Data provider. - * - * @return array[] - */ - public function signatures() - { - return array( - array( - array(), - 'YTowOnt9' - ), - array( - array('foo' => 'bar'), - 'YToxOntzOjM6ImZvbyI7czozOiJiYXIiO30=' - ), - array( - array('foo' => 'bar', 'baz' => 'tab'), - 'YToyOntzOjM6ImZvbyI7czozOiJiYXIiO3M6MzoiYmF6IjtzOjM6InRhYiI7fQ==' - ), - array( - array('bar'), - 'YToxOntpOjA7czozOiJiYXIiO30=' - ), - array( - array('bar', 'baz'), - 'YToyOntpOjA7czozOiJiYXIiO2k6MTtzOjM6ImJheiI7fQ==' - ), - ); - } - - /** - * Data provider. - * - * @return array[] - */ - public function signatureKeys() - { - return array( - array(array(), '40cd750bba9870f18aada2478b24840a'), - array(array('foo' => 'bar'), '49a3696adf0fbfacc12383a2d7400d51'), - array(array('foo' => 'bar', 'baz' => 'tab'), '3f3cabbf33bae82b0711205c913a8fa0'), - array(array('bar'), '6fc5f617053f53f56b4734453ec86daa'), - array(array('bar', 'baz'), 'b9f31192ffbb4aa958cd1c5f88540c1e'), - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/VersionTest.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/VersionTest.php deleted file mode 100644 index 84f1261..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/VersionTest.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @license MIT - * - * @covers \ProxyManager\Version - * @group Coverage - */ -class VersionTest extends PHPUnit_Framework_TestCase -{ - public function testVersionNumberIsSemverCompliant() - { - $this->assertRegExp( - '/\d+\.\d+\.\d+(-(ALPHA|BETA|RC(\d+)?|DEV))?/i', - Version::VERSION - ); - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/AccessInterceptorValueHolderMock.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/AccessInterceptorValueHolderMock.php deleted file mode 100644 index 8324d97..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/AccessInterceptorValueHolderMock.php +++ /dev/null @@ -1,55 +0,0 @@ - - * @license MIT - */ -class AccessInterceptorValueHolderMock -{ - /** - * @var mixed - */ - public $instance; - - /** - * @var mixed - */ - public $prefixInterceptors; - - /** - * @var mixed - */ - public $suffixInterceptors; - - /** - * @param mixed $instance - * @param mixed $prefixInterceptors - * @param mixed $suffixInterceptors - */ - public function __construct($instance, $prefixInterceptors, $suffixInterceptors) - { - $this->instance = $instance; - $this->prefixInterceptors = $prefixInterceptors; - $this->suffixInterceptors = $suffixInterceptors; - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/BaseClass.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/BaseClass.php deleted file mode 100644 index 4d58a11..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/BaseClass.php +++ /dev/null @@ -1,108 +0,0 @@ - - * @license MIT - */ -class BaseClass implements BaseInterface -{ - /** - * @var string - */ - public $publicProperty = 'publicPropertyDefault'; - - /** - * @var string - */ - protected $protectedProperty = 'protectedPropertyDefault'; - - /** - * @var string - */ - private $privateProperty = 'privatePropertyDefault'; - - /** - * @return string - */ - public function publicMethod() - { - return 'publicMethodDefault'; - } - - /** - * @return string - */ - protected function protectedMethod() - { - return 'protectedMethodDefault'; - } - - /** - * @return string - */ - private function privateMethod() - { - return 'privateMethodDefault'; - } - - /** - * @param \stdClass $param - * - * @return string - */ - public function publicTypeHintedMethod(\stdClass $param) - { - return 'publicTypeHintedMethodDefault'; - } - - /** - * @param array $param - * - * @return string - */ - public function publicArrayHintedMethod(array $param) - { - return 'publicArrayHintedMethodDefault'; - } - - /** - * @return string - */ - public function & publicByReferenceMethod() - { - $returnValue = 'publicByReferenceMethodDefault'; - - return $returnValue; - } - - /** - * @param mixed $param - * @param mixed $byRefParam - * - * @return string - */ - public function publicByReferenceParameterMethod($param, & $byRefParam) - { - return 'publicByReferenceParameterMethodDefault'; - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/BaseInterface.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/BaseInterface.php deleted file mode 100644 index 27aeda5..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/BaseInterface.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @license MIT - */ -interface BaseInterface -{ - /** - * @return string - */ - public function publicMethod(); -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/CallableTypeHintClass.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/CallableTypeHintClass.php deleted file mode 100644 index 4a65595..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/CallableTypeHintClass.php +++ /dev/null @@ -1,39 +0,0 @@ - - * @license MIT - */ -class CallableTypeHintClass -{ - /** - * @param callable $parameter - * - * @return callable - */ - public function callableTypeHintMethod(callable $parameter) - { - return $parameter; - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithAbstractProtectedMethod.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithAbstractProtectedMethod.php deleted file mode 100644 index 1ba3a5c..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithAbstractProtectedMethod.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @license MIT - */ -abstract class ClassWithAbstractProtectedMethod -{ - /** - * @return void - */ - abstract protected function protectedAbstractMethod(); -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithByRefMagicMethods.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithByRefMagicMethods.php deleted file mode 100644 index 6f0ab5d..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithByRefMagicMethods.php +++ /dev/null @@ -1,74 +0,0 @@ - - * @license MIT - */ -class ClassWithByRefMagicMethods -{ - /** - * {@inheritDoc} - */ - public function & __set($name, $value) - { - return array($name => $value); - } - - /** - * {@inheritDoc} - */ - public function & __get($name) - { - return $name; - } - - /** - * {@inheritDoc} - */ - public function & __isset($name) - { - return (bool) $name; - } - - /** - * {@inheritDoc} - */ - public function & __unset($name) - { - return (bool) $name; - } - - /** - * {@inheritDoc} - */ - public function & __sleep() - { - } - - /** - * {@inheritDoc} - */ - public function & __wakeup() - { - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithFinalMagicMethods.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithFinalMagicMethods.php deleted file mode 100644 index d42204b..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithFinalMagicMethods.php +++ /dev/null @@ -1,88 +0,0 @@ - - * @license MIT - */ -class ClassWithFinalMagicMethods -{ - /** - * {@inheritDoc} - */ - final public function __construct() - { - } - - /** - * {@inheritDoc} - */ - final public function __set($name, $value) - { - return array($name => $value); - } - - /** - * {@inheritDoc} - */ - final public function __get($name) - { - return $name; - } - - /** - * {@inheritDoc} - */ - final public function __isset($name) - { - return (bool) $name; - } - - /** - * {@inheritDoc} - */ - final public function __unset($name) - { - return (bool) $name; - } - - /** - * {@inheritDoc} - */ - final public function __sleep() - { - } - - /** - * {@inheritDoc} - */ - final public function __wakeup() - { - } - - /** - * {@inheritDoc} - */ - final public function __clone() - { - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithFinalMethods.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithFinalMethods.php deleted file mode 100644 index a7c0154..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithFinalMethods.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @license MIT - */ -class ClassWithFinalMethods extends PHPUnit_Framework_TestCase -{ - final public function foo() - { - } - - final private function bar() - { - } - - final protected function baz() - { - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithMagicMethods.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithMagicMethods.php deleted file mode 100644 index 2bd26e5..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithMagicMethods.php +++ /dev/null @@ -1,81 +0,0 @@ - - * @license MIT - */ -class ClassWithMagicMethods -{ - /** - * {@inheritDoc} - */ - public function __set($name, $value) - { - return array($name => $value); - } - - /** - * {@inheritDoc} - */ - public function __get($name) - { - return $name; - } - - /** - * {@inheritDoc} - */ - public function __isset($name) - { - return (bool) $name; - } - - /** - * {@inheritDoc} - */ - public function __unset($name) - { - return (bool) $name; - } - - /** - * {@inheritDoc} - */ - public function __sleep() - { - } - - /** - * {@inheritDoc} - */ - public function __wakeup() - { - } - - /** - * {@inheritDoc} - */ - public function __clone() - { - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithMethodWithDefaultParameters.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithMethodWithDefaultParameters.php deleted file mode 100644 index fa6134a..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithMethodWithDefaultParameters.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @license MIT - */ -class ClassWithMethodWithDefaultParameters -{ - /** - * @param array $parameter - * - * @return string - */ - public function publicMethodWithDefaults(array $parameter = array('foo')) - { - return 'defaultValue'; - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithMixedProperties.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithMixedProperties.php deleted file mode 100644 index 3ebf27c..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithMixedProperties.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @license MIT - */ -class ClassWithMixedProperties -{ - public $publicProperty0 = 'publicProperty0'; - - public $publicProperty1 = 'publicProperty1'; - - public $publicProperty2 = 'publicProperty2'; - - protected $protectedProperty0 = 'protectedProperty0'; - - protected $protectedProperty1 = 'protectedProperty1'; - - protected $protectedProperty2 = 'protectedProperty2'; - - private $privateProperty0 = 'privateProperty0'; - - private $privateProperty1 = 'privateProperty1'; - - private $privateProperty2 = 'privateProperty2'; -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithPrivateProperties.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithPrivateProperties.php deleted file mode 100644 index 96a7a93..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithPrivateProperties.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @license MIT - */ -class ClassWithPrivateProperties -{ - private $property0 = 'property0'; - - private $property1 = 'property1'; - - private $property2 = 'property2'; - - private $property3 = 'property3'; - - private $property4 = 'property4'; - - private $property5 = 'property5'; - - private $property6 = 'property6'; - - private $property7 = 'property7'; - - private $property8 = 'property8'; - - private $property9 = 'property9'; -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithProtectedProperties.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithProtectedProperties.php deleted file mode 100644 index ad600d1..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithProtectedProperties.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @license MIT - */ -class ClassWithProtectedProperties -{ - protected $property0 = 'property0'; - - protected $property1 = 'property1'; - - protected $property2 = 'property2'; - - protected $property3 = 'property3'; - - protected $property4 = 'property4'; - - protected $property5 = 'property5'; - - protected $property6 = 'property6'; - - protected $property7 = 'property7'; - - protected $property8 = 'property8'; - - protected $property9 = 'property9'; -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithPublicArrayProperty.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithPublicArrayProperty.php deleted file mode 100644 index af68ceb..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithPublicArrayProperty.php +++ /dev/null @@ -1,31 +0,0 @@ - - * @license MIT - */ -class ClassWithPublicArrayProperty -{ - public $arrayProperty = array(); -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithPublicProperties.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithPublicProperties.php deleted file mode 100644 index d36ea8c..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithPublicProperties.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @license MIT - */ -class ClassWithPublicProperties -{ - public $property0 = 'property0'; - - public $property1 = 'property1'; - - public $property2 = 'property2'; - - public $property3 = 'property3'; - - public $property4 = 'property4'; - - public $property5 = 'property5'; - - public $property6 = 'property6'; - - public $property7 = 'property7'; - - public $property8 = 'property8'; - - public $property9 = 'property9'; -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithSelfHint.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithSelfHint.php deleted file mode 100644 index 37d342c..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ClassWithSelfHint.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @license MIT - */ -class ClassWithSelfHint -{ - /** - * @param self $parameter - * - * @return self - */ - public function selfHintMethod(self $parameter) - { - return $parameter; - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/EmptyClass.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/EmptyClass.php deleted file mode 100644 index e74a0f7..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/EmptyClass.php +++ /dev/null @@ -1,29 +0,0 @@ - - * @license MIT - */ -class EmptyClass -{ -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/FinalClass.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/FinalClass.php deleted file mode 100644 index 4b818d6..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/FinalClass.php +++ /dev/null @@ -1,29 +0,0 @@ - - * @license MIT - */ -final class FinalClass -{ -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/HydratedObject.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/HydratedObject.php deleted file mode 100644 index 198bf6c..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/HydratedObject.php +++ /dev/null @@ -1,60 +0,0 @@ - - * @license MIT - */ -class HydratedObject -{ - /** - * @var mixed - */ - public $foo = 1; - - /** - * @var mixed - */ - protected $bar = 2; - - /** - * @var mixed - */ - private $baz = 3; - - /** - * Method to be disabled - */ - public function doFoo() - { - } - - /** - * @param string $name - * - * @return mixed - */ - public function __get($name) - { - return $this->$name; - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/LazyLoadingMock.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/LazyLoadingMock.php deleted file mode 100644 index b199f8f..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/LazyLoadingMock.php +++ /dev/null @@ -1,41 +0,0 @@ - - * @license MIT - */ -class LazyLoadingMock -{ - /** - * @var mixed - */ - public $initializer; - - /** - * @param mixed $initializer - */ - public function __construct($initializer) - { - $this->initializer = $initializer; - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/NullObjectMock.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/NullObjectMock.php deleted file mode 100644 index b747f3b..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/NullObjectMock.php +++ /dev/null @@ -1,29 +0,0 @@ - - * @license MIT - */ -class NullObjectMock -{ -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ProxyGenerator/LazyLoading/MethodGenerator/ClassWithTwoPublicProperties.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ProxyGenerator/LazyLoading/MethodGenerator/ClassWithTwoPublicProperties.php deleted file mode 100644 index bb34b58..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/ProxyGenerator/LazyLoading/MethodGenerator/ClassWithTwoPublicProperties.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @license MIT - */ -class ClassWithTwoPublicProperties -{ - /** - * @var mixed - */ - public $bar; - - /** - * @var mixed - */ - public $baz; -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/RemoteProxy/BazServiceInterface.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/RemoteProxy/BazServiceInterface.php deleted file mode 100644 index 08df058..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/RemoteProxy/BazServiceInterface.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @license MIT - */ -interface BazServiceInterface -{ - /** - * @param string $param - * - * @return string - */ - public function baz($param); -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/RemoteProxy/Foo.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/RemoteProxy/Foo.php deleted file mode 100644 index 9304f70..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/RemoteProxy/Foo.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @license MIT - */ -class Foo implements FooServiceInterface, BazServiceInterface -{ - /** - * @return string - */ - public function foo() - { - return 'bar remote'; - } - - /** - * @param string $param - * - * @return string - */ - public function baz($param) - { - return $param . ' remote'; - } - - /** - * @param string $name - * - * @return string - */ - public function __get($name) - { - return $name . ' remote'; - } -} diff --git a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/RemoteProxy/FooServiceInterface.php b/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/RemoteProxy/FooServiceInterface.php deleted file mode 100644 index af0b764..0000000 --- a/vendor/ocramius/proxy-manager/tests/ProxyManagerTestAsset/RemoteProxy/FooServiceInterface.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @license MIT - */ -interface FooServiceInterface -{ - /** - * @return string - */ - public function foo(); -} diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/README.md b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/README.md deleted file mode 100644 index f641e6d..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/README.md +++ /dev/null @@ -1,9 +0,0 @@ -## Integration tests for PHP language features of proxies - -Since proxies are quire complex code, this directory is dedicated -to integration tests that are supposed to cause fatal errors or -failures in general that are hard to handle in traditional -PHPUnit test cases. - -You may find a guide on how to write `.phpt` tests on the -[PHP QA website](http://qa.php.net/write-test.php). \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-private-property-isset.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-private-property-isset.phpt deleted file mode 100644 index b820fa1..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-private-property-isset.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -Verifies that generated access interceptors disallow private property direct isset check ---FILE-- -createProxy(new Kitchen()); - -var_dump(isset($proxy->sweets)); -?> ---EXPECT-- -bool(false) \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-private-property-read.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-private-property-read.phpt deleted file mode 100644 index 0dff2c7..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-private-property-read.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -Verifies that generated access interceptors disallow private property direct read ---FILE-- -createProxy(new Kitchen()); - -$proxy->sweets; -?> ---EXPECTF-- -%SFatal error: Cannot access private property %s::$sweets in %s on line %d \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-private-property-unset.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-private-property-unset.phpt deleted file mode 100644 index e6e6eeb..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-private-property-unset.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -Verifies that generated access interceptors disallow private property direct unset ---FILE-- -createProxy(new Kitchen()); - -unset($proxy->sweets); -?> ---EXPECTF-- -%SFatal error: Cannot %s property %s on line %d \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-private-property-write.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-private-property-write.phpt deleted file mode 100644 index e87d520..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-private-property-write.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -Verifies that generated access interceptors disallow private property direct write ---FILE-- -createProxy(new Kitchen()); - -$proxy->sweets = 'stolen'; -?> ---EXPECTF-- -%SFatal error: Cannot access %s property%S in %s on line %d \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-protected-property-isset.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-protected-property-isset.phpt deleted file mode 100644 index e277887..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-protected-property-isset.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -Verifies that generated access interceptors disallow protected property direct isset check ---FILE-- -createProxy(new Kitchen()); - -var_dump(isset($proxy->sweets)); -?> ---EXPECT-- -bool(false) \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-protected-property-read.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-protected-property-read.phpt deleted file mode 100644 index ed579f5..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-protected-property-read.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -Verifies that generated access interceptors disallow protected property direct read ---FILE-- -createProxy(new Kitchen()); - -$proxy->sweets; -?> ---EXPECTF-- -%SFatal error: Cannot access protected property %s::$sweets in %s on line %d \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-protected-property-unset.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-protected-property-unset.phpt deleted file mode 100644 index d8fcd49..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-protected-property-unset.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -Verifies that generated access interceptors disallow protected property direct unset ---FILE-- -createProxy(new Kitchen()); - -unset($proxy->sweets); -?> ---EXPECTF-- -%SFatal error: Cannot %s property%sin %s on line %d \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-protected-property-write.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-protected-property-write.phpt deleted file mode 100644 index f288b0b..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-denies-protected-property-write.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -Verifies that generated access interceptors disallow protected property direct write ---FILE-- -createProxy(new Kitchen()); - -$proxy->sweets = 'stolen'; -?> ---EXPECTF-- -%SFatal error: Cannot %s property%sin %s on line %d \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-private-property-isset.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-private-property-isset.phpt deleted file mode 100644 index d9eef67..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-private-property-isset.phpt +++ /dev/null @@ -1,26 +0,0 @@ ---TEST-- -Verifies that generated access interceptors disallow private property direct isset check ---SKIPIF-- - ---FILE-- -createProxy(new Kitchen()); - -var_dump(isset($proxy->sweets)); -?> ---EXPECT-- -bool(false) diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-private-property-read.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-private-property-read.phpt deleted file mode 100644 index 18a6c95..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-private-property-read.phpt +++ /dev/null @@ -1,26 +0,0 @@ ---TEST-- -Verifies that generated access interceptors disallow private property direct read ---SKIPIF-- - ---FILE-- -createProxy(new Kitchen()); - -$proxy->sweets; -?> ---EXPECTF-- -%SFatal error: Cannot access private property %s::$sweets in %s on line %d diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-private-property-unset.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-private-property-unset.phpt deleted file mode 100644 index 92a64e2..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-private-property-unset.phpt +++ /dev/null @@ -1,26 +0,0 @@ ---TEST-- -Verifies that generated access interceptors disallow private property direct unset ---SKIPIF-- - ---FILE-- -createProxy(new Kitchen()); - -unset($proxy->sweets); -?> ---EXPECTF-- -%SFatal error: Cannot %s property%sin %s on line %d diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-private-property-write.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-private-property-write.phpt deleted file mode 100644 index a0b3cc1..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-private-property-write.phpt +++ /dev/null @@ -1,26 +0,0 @@ ---TEST-- -Verifies that generated access interceptors disallow private property direct write ---SKIPIF-- - ---FILE-- -createProxy(new Kitchen()); - -$proxy->sweets = 'stolen'; -?> ---EXPECTF-- -%SFatal error: Cannot %s property%sin %s on line %d diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-protected-property-isset.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-protected-property-isset.phpt deleted file mode 100644 index f5de693..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-protected-property-isset.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -Verifies that generated access interceptors disallow protected property direct isset check ---FILE-- -createProxy(new Kitchen()); - -var_dump(isset($proxy->sweets)); -?> ---EXPECT-- -bool(false) diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-protected-property-read.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-protected-property-read.phpt deleted file mode 100644 index c97b091..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-protected-property-read.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -Verifies that generated access interceptors disallow protected property direct read ---FILE-- -createProxy(new Kitchen()); - -$proxy->sweets; -?> ---EXPECTF-- -%SFatal error: Cannot access protected property %s::$sweets in %s on line %d diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-protected-property-unset.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-protected-property-unset.phpt deleted file mode 100644 index 91cc4f9..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-protected-property-unset.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -Verifies that generated access interceptors disallow protected property direct unset ---FILE-- -createProxy(new Kitchen()); - -unset($proxy->sweets); -?> ---EXPECTF-- -%SFatal error: Cannot %s property%sin %s on line %d diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-protected-property-write.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-protected-property-write.phpt deleted file mode 100644 index 97da739..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-scope-localizer-denies-protected-property-write.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -Verifies that generated access interceptors disallow protected property direct write ---FILE-- -createProxy(new Kitchen()); - -$proxy->sweets = 'stolen'; -?> ---EXPECTF-- -%SFatal error: Cannot %s property%sin %s on line %d diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-with-cache.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-with-cache.phpt deleted file mode 100644 index 0a180b2..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/access-interceptor-with-cache.phpt +++ /dev/null @@ -1,34 +0,0 @@ ---TEST-- -Verifies that access interceptor proxy file is generated ---FILE-- -setProxiesTargetDir(__DIR__ . '/cache'); -$fileLocator = new \ProxyManager\FileLocator\FileLocator($configuration->getProxiesTargetDir()); -$configuration->setGeneratorStrategy( - new \ProxyManager\GeneratorStrategy\FileWriterGeneratorStrategy($fileLocator) -); - -$factory = new \ProxyManager\Factory\AccessInterceptorValueHolderFactory($configuration); - -$proxy = $factory->createProxy(new Kitchen()); - -$filename = $fileLocator->getProxyFileName(get_class($proxy)); -var_dump(file_exists($filename)); - -$proxy = $factory->createProxy(new Kitchen()); - -var_dump(file_exists($filename)); -@unlink($filename); - -?> ---EXPECT-- -bool(true) -bool(true) \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/cache/README.md b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/cache/README.md deleted file mode 100644 index dcb0d38..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/cache/README.md +++ /dev/null @@ -1,3 +0,0 @@ -## Integration tests for PHP language features of proxies - -This folder is used for the caches \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/init.php b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/init.php deleted file mode 100644 index ce6cffc..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/init.php +++ /dev/null @@ -1,10 +0,0 @@ -setGeneratorStrategy(new EvaluatingGeneratorStrategy()); diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-allows-inexisting-magic-property-read.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-allows-inexisting-magic-property-read.phpt deleted file mode 100644 index 2f318c7..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-allows-inexisting-magic-property-read.phpt +++ /dev/null @@ -1,25 +0,0 @@ ---TEST-- -Verifies that generated lazy loading ghost objects disallow reading non-existing properties via direct read ---FILE-- -createProxy('Kitchen', function () {}); - -echo $proxy->nonExisting; -?> ---EXPECTF-- -nonExisting \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-allows-inexisting-property-write.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-allows-inexisting-property-write.phpt deleted file mode 100644 index e815d0f..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-allows-inexisting-property-write.phpt +++ /dev/null @@ -1,21 +0,0 @@ ---TEST-- -Verifies that generated lazy loading ghost objects disallow reading non-existing properties via direct read ---FILE-- -createProxy('Kitchen', function () {}); - -$proxy->nonExisting = 'I do not exist'; -echo $proxy->nonExisting; -?> ---EXPECTF-- -I do not exist \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-inexisting-property-read.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-inexisting-property-read.phpt deleted file mode 100644 index 0b0267b..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-inexisting-property-read.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -Verifies that generated lazy loading ghost objects disallow reading non-existing properties via direct read ---FILE-- -createProxy('Kitchen', function () {}); - -$proxy->nonExisting; -?> ---EXPECTF-- -%SNotice: Undefined property: Kitchen::$nonExisting in %s on line %d \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-private-property-isset.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-private-property-isset.phpt deleted file mode 100644 index 05f741c..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-private-property-isset.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -Verifies that generated lazy loading ghost objects disallow private property direct isset check ---FILE-- -createProxy('Kitchen', function () {}); - -var_dump(isset($proxy->sweets)); -?> ---EXPECT-- -bool(false) \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-private-property-read.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-private-property-read.phpt deleted file mode 100644 index cdb0d09..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-private-property-read.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -Verifies that generated lazy loading ghost objects disallow private property direct read ---FILE-- -createProxy('Kitchen', function () {}); - -$proxy->sweets; -?> ---EXPECTF-- -%SFatal error: Cannot access private property %s::$sweets in %s on line %d \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-private-property-unset.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-private-property-unset.phpt deleted file mode 100644 index 18580aa..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-private-property-unset.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -Verifies that generated lazy loading ghost objects disallow private property direct unset ---FILE-- -createProxy('Kitchen', function () {}); - -unset($proxy->sweets); -?> ---EXPECTF-- -%SFatal error: Cannot %s property %s on line %d \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-private-property-write.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-private-property-write.phpt deleted file mode 100644 index a081d71..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-private-property-write.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -Verifies that generated lazy loading ghost objects disallow private property direct write ---FILE-- -createProxy('Kitchen', function () {}); - -$proxy->sweets = 'stolen'; -?> ---EXPECTF-- -%SFatal error: Cannot access %s property%S in %s on line %d \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-protected-property-isset.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-protected-property-isset.phpt deleted file mode 100644 index 8fa8485..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-protected-property-isset.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -Verifies that generated lazy loading ghost objects disallow protected property direct isset check ---FILE-- -createProxy('Kitchen', function () {}); - -var_dump(isset($proxy->sweets)); -?> ---EXPECT-- -bool(false) \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-protected-property-read.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-protected-property-read.phpt deleted file mode 100644 index e71bb30..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-protected-property-read.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -Verifies that generated lazy loading ghost objects disallow protected property direct read ---FILE-- -createProxy('Kitchen', function () {}); - -$proxy->sweets; -?> ---EXPECTF-- -%SFatal error: Cannot access protected property %s::$sweets in %s on line %d \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-protected-property-unset.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-protected-property-unset.phpt deleted file mode 100644 index 6e742a1..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-protected-property-unset.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -Verifies that generated lazy loading ghost objects disallow protected property direct unset ---FILE-- -createProxy('Kitchen', function () {}); - -unset($proxy->sweets); -?> ---EXPECTF-- -%SFatal error: Cannot %s property%sin %s on line %d \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-protected-property-write.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-protected-property-write.phpt deleted file mode 100644 index 580f5a5..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-denies-protected-property-write.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -Verifies that generated lazy loading ghost objects disallow protected property direct write ---FILE-- -createProxy('Kitchen', function () {}); - -$proxy->sweets = 'stolen'; -?> ---EXPECTF-- -%SFatal error: Cannot %s property%sin %s on line %d \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-with-cache.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-with-cache.phpt deleted file mode 100644 index 7a60948..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-ghost-with-cache.phpt +++ /dev/null @@ -1,34 +0,0 @@ ---TEST-- -Verifies that lazy loading ghost proxy file is generated ---FILE-- -setProxiesTargetDir(__DIR__ . '/cache'); -$fileLocator = new \ProxyManager\FileLocator\FileLocator($configuration->getProxiesTargetDir()); -$configuration->setGeneratorStrategy( - new \ProxyManager\GeneratorStrategy\FileWriterGeneratorStrategy($fileLocator) -); - -$factory = new \ProxyManager\Factory\LazyLoadingGhostFactory($configuration); - -$proxy = $factory->createProxy('Kitchen', function () {}); - -$filename = $fileLocator->getProxyFileName(get_class($proxy)); -var_dump(file_exists($filename)); - -$proxy = $factory->createProxy('Kitchen', function () {}); - -var_dump(file_exists($filename)); -@unlink($filename); - -?> ---EXPECT-- -bool(true) -bool(true) \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-private-property-isset.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-private-property-isset.phpt deleted file mode 100644 index 14e7989..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-private-property-isset.phpt +++ /dev/null @@ -1,23 +0,0 @@ ---TEST-- -Verifies that generated lazy loading value holders disallow private property direct isset check ---FILE-- -createProxy('Kitchen', function (& $wrapped, $proxy, $method, array $parameters, & $initializer) { - $initializer = null; - $wrapped = new Kitchen(); -}); - -var_dump(isset($proxy->sweets)); -?> ---EXPECT-- -bool(false) \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-private-property-read.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-private-property-read.phpt deleted file mode 100644 index 7631ec9..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-private-property-read.phpt +++ /dev/null @@ -1,23 +0,0 @@ ---TEST-- -Verifies that generated lazy loading value holders disallow private property direct read ---FILE-- -createProxy('Kitchen', function (& $wrapped, $proxy, $method, array $parameters, & $initializer) { - $initializer = null; - $wrapped = new Kitchen(); -}); - -$proxy->sweets; -?> ---EXPECTF-- -%SFatal error: Cannot access private property %s::$sweets in %s on line %d \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-private-property-unset.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-private-property-unset.phpt deleted file mode 100644 index 1454f78..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-private-property-unset.phpt +++ /dev/null @@ -1,23 +0,0 @@ ---TEST-- -Verifies that generated lazy loading value holders disallow private property direct unset ---FILE-- -createProxy('Kitchen', function (& $wrapped, $proxy, $method, array $parameters, & $initializer) { - $initializer = null; - $wrapped = new Kitchen(); -}); - -unset($proxy->sweets); -?> ---EXPECTF-- -%SFatal error: Cannot %s property %s on line %d \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-private-property-write.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-private-property-write.phpt deleted file mode 100644 index 6b90e2f..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-private-property-write.phpt +++ /dev/null @@ -1,23 +0,0 @@ ---TEST-- -Verifies that generated lazy loading value holders disallow private property direct write ---FILE-- -createProxy('Kitchen', function (& $wrapped, $proxy, $method, array $parameters, & $initializer) { - $initializer = null; - $wrapped = new Kitchen(); -}); - -$proxy->sweets = 'stolen'; -?> ---EXPECTF-- -%SFatal error: Cannot access %s property %s on line %d \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-protected-property-isset.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-protected-property-isset.phpt deleted file mode 100644 index d33c0ba..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-protected-property-isset.phpt +++ /dev/null @@ -1,23 +0,0 @@ ---TEST-- -Verifies that generated lazy loading value holders disallow protected property direct isset check ---FILE-- -createProxy('Kitchen', function (& $wrapped, $proxy, $method, array $parameters, & $initializer) { - $initializer = null; - $wrapped = new Kitchen(); -}); - -var_dump(isset($proxy->sweets)); -?> ---EXPECT-- -bool(false) \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-protected-property-read.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-protected-property-read.phpt deleted file mode 100644 index 6f2df1d..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-protected-property-read.phpt +++ /dev/null @@ -1,23 +0,0 @@ ---TEST-- -Verifies that generated lazy loading value holders disallow protected property direct read ---FILE-- -createProxy('Kitchen', function (& $wrapped, $proxy, $method, array $parameters, & $initializer) { - $initializer = null; - $wrapped = new Kitchen(); -}); - -$proxy->sweets; -?> ---EXPECTF-- -%SFatal error: Cannot access protected property %s::$sweets in %s on line %d \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-protected-property-unset.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-protected-property-unset.phpt deleted file mode 100644 index 238a50f..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-protected-property-unset.phpt +++ /dev/null @@ -1,23 +0,0 @@ ---TEST-- -Verifies that generated lazy loading value holders disallow protected property direct unset ---FILE-- -createProxy('Kitchen', function (& $wrapped, $proxy, $method, array $parameters, & $initializer) { - $initializer = null; - $wrapped = new Kitchen(); -}); - -unset($proxy->sweets); -?> ---EXPECTF-- -%SFatal error: Cannot %s property%sin %s on line %d \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-protected-property-write.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-protected-property-write.phpt deleted file mode 100644 index f8c2cac..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-denies-protected-property-write.phpt +++ /dev/null @@ -1,23 +0,0 @@ ---TEST-- -Verifies that generated lazy loading value holders disallow protected property direct write ---FILE-- -createProxy('Kitchen', function (& $wrapped, $proxy, $method, array $parameters, & $initializer) { - $initializer = null; - $wrapped = new Kitchen(); -}); - -$proxy->sweets = 'stolen'; -?> ---EXPECTF-- -%SFatal error: Cannot %s property%sin %s on line %d \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-internal-php-classes.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-internal-php-classes.phpt deleted file mode 100644 index 2a5a777..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-internal-php-classes.phpt +++ /dev/null @@ -1,31 +0,0 @@ ---TEST-- -Verifies that lazy loading value holder factory can generate proxy for PHP core classes. ---FILE-- -createProxy('Phar', function (& $wrapped, $proxy, $method, array $parameters, & $initializer) { - $initializer = null; - $wrapped = new PharMock(); - }) - ->compress('Lazy Loaded!'); - -?> ---EXPECT-- -Lazy Loaded! \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-with-cache.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-with-cache.phpt deleted file mode 100644 index 06afe47..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/lazy-loading-value-holder-with-cache.phpt +++ /dev/null @@ -1,40 +0,0 @@ ---TEST-- -Verifies that lazy loading value holder proxy file is generated ---FILE-- -setProxiesTargetDir(__DIR__ . '/cache'); -$fileLocator = new \ProxyManager\FileLocator\FileLocator($configuration->getProxiesTargetDir()); -$configuration->setGeneratorStrategy( - new \ProxyManager\GeneratorStrategy\FileWriterGeneratorStrategy($fileLocator) -); - -$factory = new \ProxyManager\Factory\LazyLoadingValueHolderFactory($configuration); - -$proxy = $factory->createProxy('Kitchen', function (& $wrapped, $proxy, $method, array $parameters, & $initializer) { - $initializer = null; - $wrapped = new Kitchen(); -}); - -$filename = $fileLocator->getProxyFileName(get_class($proxy)); -var_dump(file_exists($filename)); - -$proxy = $factory->createProxy('Kitchen', function (& $wrapped, $proxy, $method, array $parameters, & $initializer) { - $initializer = null; - $wrapped = new Kitchen(); -}); - -var_dump(file_exists($filename)); -@unlink($filename); - -?> ---EXPECT-- -bool(true) -bool(true) \ No newline at end of file diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/null-object-public-function-empty.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/null-object-public-function-empty.phpt deleted file mode 100644 index 2453ea5..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/null-object-public-function-empty.phpt +++ /dev/null @@ -1,23 +0,0 @@ ---TEST-- -Verifies that generated null object disallow public function ---FILE-- -createProxy('Kitchen'); - -var_dump($proxy->foo()); -?> ---EXPECT-- -NULL diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/null-object-public-property-empty.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/null-object-public-property-empty.phpt deleted file mode 100644 index 9da1a41..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/null-object-public-property-empty.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -Verifies that generated null object disallow public function ---FILE-- -createProxy('Kitchen'); - -var_dump($proxy->foo); -?> ---EXPECT-- -NULL diff --git a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/remote-object-json-adapter-denies-unknow-method.phpt b/vendor/ocramius/proxy-manager/tests/language-feature-scripts/remote-object-json-adapter-denies-unknow-method.phpt deleted file mode 100644 index 1910a34..0000000 --- a/vendor/ocramius/proxy-manager/tests/language-feature-scripts/remote-object-json-adapter-denies-unknow-method.phpt +++ /dev/null @@ -1,43 +0,0 @@ ---TEST-- -Verifies that generated remote object can call public property ---FILE-- -createProxy('ProxyManagerTestAsset\RemoteProxy\FooServiceInterface'); - -var_dump($proxy->foo()); -var_dump($proxy->unknown()); -?> ---EXPECTF-- -string(3) "baz" - -%SFatal error: Call to undefined method %s::unknown%S in %s on line %d diff --git a/vendor/paragonie/random_compat/RATIONALE.md b/vendor/paragonie/random_compat/RATIONALE.md deleted file mode 100644 index a6e7307..0000000 --- a/vendor/paragonie/random_compat/RATIONALE.md +++ /dev/null @@ -1,42 +0,0 @@ -## Rationale (Design Decisions) - -### Reasoning Behind the Order of Preferred Random Data Sources - -The order is: - - 1. `libsodium if available` - 2. `fread() /dev/urandom if available` - 3. `mcrypt_create_iv($bytes, MCRYPT_DEV_URANDOM)` - 4. `COM('CAPICOM.Utilities.1')->GetRandom()` - 5. `openssl_random_pseudo_bytes()` - -If libsodium is available, we get random data from it. This is the preferred -method on all OSes, but libsodium is not very widely installed, so other -fallbacks are available. - -Next, we read `/dev/urandom` (if it exists). This is the preferred file to read -for random data for cryptographic purposes for BSD and Linux. This step -is skipped on Windows, because someone could create a `C:\dev\urandom` -file and PHP would helpfully (but insecurely) return bytes from it. - -Despite [strongly urging people not to use mcrypt in their projects](https://paragonie.com/blog/2015/05/if-you-re-typing-word-mcrypt-into-your-code-you-re-doing-it-wrong) -(because libmcrypt is abandonware and the API puts too much responsibility on the -implementor) we prioritize `mcrypt_create_iv()` with `MCRYPT_DEV_URANDOM` above -the remaining implementations. - -The reason is simple: `mcrypt_create_iv()` is part of PHP's `ext/mcrypt` code, -and is not part `libmcrypt`. It actually does the right thing: - - * On Unix-based operating systems, it reads from `/dev/urandom` which - (unlike `/dev/random`) is the sane and correct thing to do. - * On Windows, it reads from `CryptGenRandom`, which is an exclusively Windows - way to get random bytes. - -If we're on Windows and don't have access to `mcrypt`, we use `CAPICOM.Utilities.1`. - -Finally, we use `openssl_random_pseudo_bytes()` **as a last resort**, due to -[PHP bug #70014](https://bugs.php.net/bug.php?id=70014). Internally, this -function calls `RAND_pseudo_bytes()`, which has been [deprecated](https://github.com/paragonie/random_compat/issues/5) -by the OpenSSL team. Furthermore, [it might silently return weak random data](https://github.com/paragonie/random_compat/issues/6#issuecomment-119564973) -if it is called before OpenSSL's **userspace** CSPRNG is seeded. Also, -[you want the OS CSPRNG, not a userspace CSPRNG](http://sockpuppet.org/blog/2014/02/25/safely-generate-random-numbers/). diff --git a/vendor/paragonie/random_compat/lib/byte_safe_strings.php b/vendor/paragonie/random_compat/lib/byte_safe_strings.php deleted file mode 100644 index 6de294f..0000000 --- a/vendor/paragonie/random_compat/lib/byte_safe_strings.php +++ /dev/null @@ -1,181 +0,0 @@ - RandomCompat_strlen($binary_string)) { - return ''; - } - - return (string) mb_substr($binary_string, $start, $length, '8bit'); - } - - } else { - - /** - * substr() implementation that isn't brittle to mbstring.func_overload - * - * This version just uses the default substr() - * - * @param string $binary_string - * @param int $start - * @param int $length (optional) - * - * @throws TypeError - * - * @return string - */ - function RandomCompat_substr($binary_string, $start, $length = null) - { - if (!is_string($binary_string)) { - throw new TypeError( - 'RandomCompat_substr(): First argument should be a string' - ); - } - - if (!is_int($start)) { - throw new TypeError( - 'RandomCompat_substr(): Second argument should be an integer' - ); - } - - if ($length !== null) { - if (!is_int($length)) { - throw new TypeError( - 'RandomCompat_substr(): Third argument should be an integer, or omitted' - ); - } - - return (string) substr($binary_string, $start, $length); - } - - return (string) substr($binary_string, $start); - } - } -} diff --git a/vendor/paragonie/random_compat/lib/cast_to_int.php b/vendor/paragonie/random_compat/lib/cast_to_int.php deleted file mode 100644 index dc4048c..0000000 --- a/vendor/paragonie/random_compat/lib/cast_to_int.php +++ /dev/null @@ -1,74 +0,0 @@ - operators might accidentally let a float - * through. - * - * @param int|float $number The number we want to convert to an int - * @param boolean $fail_open Set to true to not throw an exception - * - * @return float|int - * - * @throws TypeError - */ - function RandomCompat_intval($number, $fail_open = false) - { - if (is_int($number) || is_float($number)) { - $number += 0; - } elseif (is_numeric($number)) { - $number += 0; - } - - if ( - is_float($number) - && - $number > ~PHP_INT_MAX - && - $number < PHP_INT_MAX - ) { - $number = (int) $number; - } - - if (is_int($number)) { - return (int) $number; - } elseif (!$fail_open) { - throw new TypeError( - 'Expected an integer.' - ); - } - return $number; - } -} diff --git a/vendor/paragonie/random_compat/lib/error_polyfill.php b/vendor/paragonie/random_compat/lib/error_polyfill.php deleted file mode 100644 index 17ece7b..0000000 --- a/vendor/paragonie/random_compat/lib/error_polyfill.php +++ /dev/null @@ -1,49 +0,0 @@ -GetRandom($bytes, 0)); - if (RandomCompat_strlen($buf) >= $bytes) { - /** - * Return our random entropy buffer here: - */ - return RandomCompat_substr($buf, 0, $bytes); - } - ++$execCount; - } while ($execCount < $bytes); - - /** - * If we reach here, PHP has failed us. - */ - throw new Exception( - 'Could not gather sufficient random data' - ); - } -} diff --git a/vendor/paragonie/random_compat/lib/random_bytes_dev_urandom.php b/vendor/paragonie/random_compat/lib/random_bytes_dev_urandom.php deleted file mode 100644 index 8bf7034..0000000 --- a/vendor/paragonie/random_compat/lib/random_bytes_dev_urandom.php +++ /dev/null @@ -1,150 +0,0 @@ - 0); - - /** - * Is our result valid? - */ - if ($buf !== false) { - if (RandomCompat_strlen($buf) === $bytes) { - /** - * Return our random entropy buffer here: - */ - return $buf; - } - } - } - - /** - * If we reach here, PHP has failed us. - */ - throw new Exception( - 'Error reading from source device' - ); - } -} diff --git a/vendor/paragonie/random_compat/lib/random_bytes_libsodium.php b/vendor/paragonie/random_compat/lib/random_bytes_libsodium.php deleted file mode 100644 index 7d32b21..0000000 --- a/vendor/paragonie/random_compat/lib/random_bytes_libsodium.php +++ /dev/null @@ -1,88 +0,0 @@ - 2147483647) { - $buf = ''; - for ($i = 0; $i < $bytes; $i += 1073741824) { - $n = ($bytes - $i) > 1073741824 - ? 1073741824 - : $bytes - $i; - $buf .= \Sodium\randombytes_buf($n); - } - } else { - $buf = \Sodium\randombytes_buf($bytes); - } - - if ($buf !== false) { - if (RandomCompat_strlen($buf) === $bytes) { - return $buf; - } - } - - /** - * If we reach here, PHP has failed us. - */ - throw new Exception( - 'Could not gather sufficient random data' - ); - } -} diff --git a/vendor/paragonie/random_compat/lib/random_bytes_libsodium_legacy.php b/vendor/paragonie/random_compat/lib/random_bytes_libsodium_legacy.php deleted file mode 100644 index ba93c40..0000000 --- a/vendor/paragonie/random_compat/lib/random_bytes_libsodium_legacy.php +++ /dev/null @@ -1,92 +0,0 @@ - 2147483647) { - for ($i = 0; $i < $bytes; $i += 1073741824) { - $n = ($bytes - $i) > 1073741824 - ? 1073741824 - : $bytes - $i; - $buf .= Sodium::randombytes_buf($n); - } - } else { - $buf .= Sodium::randombytes_buf($bytes); - } - - if (is_string($buf)) { - if (RandomCompat_strlen($buf) === $bytes) { - return $buf; - } - } - - /** - * If we reach here, PHP has failed us. - */ - throw new Exception( - 'Could not gather sufficient random data' - ); - } -} diff --git a/vendor/paragonie/random_compat/lib/random_bytes_mcrypt.php b/vendor/paragonie/random_compat/lib/random_bytes_mcrypt.php deleted file mode 100644 index 3bce91a..0000000 --- a/vendor/paragonie/random_compat/lib/random_bytes_mcrypt.php +++ /dev/null @@ -1,77 +0,0 @@ - operators might accidentally let a float - * through. - */ - - try { - $min = RandomCompat_intval($min); - } catch (TypeError $ex) { - throw new TypeError( - 'random_int(): $min must be an integer' - ); - } - - try { - $max = RandomCompat_intval($max); - } catch (TypeError $ex) { - throw new TypeError( - 'random_int(): $max must be an integer' - ); - } - - /** - * Now that we've verified our weak typing system has given us an integer, - * let's validate the logic then we can move forward with generating random - * integers along a given range. - */ - if ($min > $max) { - throw new Error( - 'Minimum value must be less than or equal to the maximum value' - ); - } - - if ($max === $min) { - return $min; - } - - /** - * Initialize variables to 0 - * - * We want to store: - * $bytes => the number of random bytes we need - * $mask => an integer bitmask (for use with the &) operator - * so we can minimize the number of discards - */ - $attempts = $bits = $bytes = $mask = $valueShift = 0; - - /** - * At this point, $range is a positive number greater than 0. It might - * overflow, however, if $max - $min > PHP_INT_MAX. PHP will cast it to - * a float and we will lose some precision. - */ - $range = $max - $min; - - /** - * Test for integer overflow: - */ - if (!is_int($range)) { - - /** - * Still safely calculate wider ranges. - * Provided by @CodesInChaos, @oittaa - * - * @ref https://gist.github.com/CodesInChaos/03f9ea0b58e8b2b8d435 - * - * We use ~0 as a mask in this case because it generates all 1s - * - * @ref https://eval.in/400356 (32-bit) - * @ref http://3v4l.org/XX9r5 (64-bit) - */ - $bytes = PHP_INT_SIZE; - $mask = ~0; - - } else { - - /** - * $bits is effectively ceil(log($range, 2)) without dealing with - * type juggling - */ - while ($range > 0) { - if ($bits % 8 === 0) { - ++$bytes; - } - ++$bits; - $range >>= 1; - $mask = $mask << 1 | 1; - } - $valueShift = $min; - } - - $val = 0; - /** - * Now that we have our parameters set up, let's begin generating - * random integers until one falls between $min and $max - */ - do { - /** - * The rejection probability is at most 0.5, so this corresponds - * to a failure probability of 2^-128 for a working RNG - */ - if ($attempts > 128) { - throw new Exception( - 'random_int: RNG is broken - too many rejections' - ); - } - - /** - * Let's grab the necessary number of random bytes - */ - $randomByteString = random_bytes($bytes); - - /** - * Let's turn $randomByteString into an integer - * - * This uses bitwise operators (<< and |) to build an integer - * out of the values extracted from ord() - * - * Example: [9F] | [6D] | [32] | [0C] => - * 159 + 27904 + 3276800 + 201326592 => - * 204631455 - */ - $val &= 0; - for ($i = 0; $i < $bytes; ++$i) { - $val |= ord($randomByteString[$i]) << ($i * 8); - } - - /** - * Apply mask - */ - $val &= $mask; - $val += $valueShift; - - ++$attempts; - /** - * If $val overflows to a floating point number, - * ... or is larger than $max, - * ... or smaller than $min, - * then try again. - */ - } while (!is_int($val) || $val > $max || $val < $min); - - return (int)$val; - } -} diff --git a/vendor/react/promise/LICENSE b/vendor/react/promise/LICENSE deleted file mode 100644 index 5919d20..0000000 --- a/vendor/react/promise/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -Copyright (c) 2012-2016 Jan Sorgalla - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/react/promise/composer.json b/vendor/react/promise/composer.json deleted file mode 100644 index 2fc4809..0000000 --- a/vendor/react/promise/composer.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "name": "react/promise", - "description": "A lightweight implementation of CommonJS Promises/A for PHP", - "license": "MIT", - "authors": [ - {"name": "Jan Sorgalla", "email": "jsorgalla@gmail.com"} - ], - "require": { - "php": ">=5.4.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.8" - }, - "autoload": { - "psr-4": { - "React\\Promise\\": "src/" - }, - "files": ["src/functions_include.php"] - }, - "autoload-dev": { - "psr-4": { - "React\\Promise\\": "tests/fixtures" - } - }, - "keywords": [ - "promise", - "promises" - ] -} diff --git a/vendor/react/promise/src/CancellablePromiseInterface.php b/vendor/react/promise/src/CancellablePromiseInterface.php deleted file mode 100644 index 896db2d..0000000 --- a/vendor/react/promise/src/CancellablePromiseInterface.php +++ /dev/null @@ -1,11 +0,0 @@ -started) { - return; - } - - $this->started = true; - $this->drain(); - } - - public function enqueue($cancellable) - { - if (!\method_exists($cancellable, 'then') || !\method_exists($cancellable, 'cancel')) { - return; - } - - $length = \array_push($this->queue, $cancellable); - - if ($this->started && 1 === $length) { - $this->drain(); - } - } - - private function drain() - { - for ($i = key($this->queue); isset($this->queue[$i]); $i++) { - $cancellable = $this->queue[$i]; - - $exception = null; - - try { - $cancellable->cancel(); - } catch (\Throwable $exception) { - } catch (\Exception $exception) { - } - - unset($this->queue[$i]); - - if ($exception) { - throw $exception; - } - } - - $this->queue = []; - } -} diff --git a/vendor/react/promise/src/Deferred.php b/vendor/react/promise/src/Deferred.php deleted file mode 100644 index 3ca034b..0000000 --- a/vendor/react/promise/src/Deferred.php +++ /dev/null @@ -1,65 +0,0 @@ -canceller = $canceller; - } - - public function promise() - { - if (null === $this->promise) { - $this->promise = new Promise(function ($resolve, $reject, $notify) { - $this->resolveCallback = $resolve; - $this->rejectCallback = $reject; - $this->notifyCallback = $notify; - }, $this->canceller); - $this->canceller = null; - } - - return $this->promise; - } - - public function resolve($value = null) - { - $this->promise(); - - \call_user_func($this->resolveCallback, $value); - } - - public function reject($reason = null) - { - $this->promise(); - - \call_user_func($this->rejectCallback, $reason); - } - - /** - * @deprecated 2.6.0 Progress support is deprecated and should not be used anymore. - * @param mixed $update - */ - public function notify($update = null) - { - $this->promise(); - - \call_user_func($this->notifyCallback, $update); - } - - /** - * @deprecated 2.2.0 - * @see Deferred::notify() - */ - public function progress($update = null) - { - $this->notify($update); - } -} diff --git a/vendor/react/promise/src/Exception/LengthException.php b/vendor/react/promise/src/Exception/LengthException.php deleted file mode 100644 index 775c48d..0000000 --- a/vendor/react/promise/src/Exception/LengthException.php +++ /dev/null @@ -1,7 +0,0 @@ -value = $value; - } - - public function then(callable $onFulfilled = null, callable $onRejected = null, callable $onProgress = null) - { - if (null === $onFulfilled) { - return $this; - } - - try { - return resolve($onFulfilled($this->value)); - } catch (\Throwable $exception) { - return new RejectedPromise($exception); - } catch (\Exception $exception) { - return new RejectedPromise($exception); - } - } - - public function done(callable $onFulfilled = null, callable $onRejected = null, callable $onProgress = null) - { - if (null === $onFulfilled) { - return; - } - - $result = $onFulfilled($this->value); - - if ($result instanceof ExtendedPromiseInterface) { - $result->done(); - } - } - - public function otherwise(callable $onRejected) - { - return $this; - } - - public function always(callable $onFulfilledOrRejected) - { - return $this->then(function ($value) use ($onFulfilledOrRejected) { - return resolve($onFulfilledOrRejected())->then(function () use ($value) { - return $value; - }); - }); - } - - public function progress(callable $onProgress) - { - return $this; - } - - public function cancel() - { - } -} diff --git a/vendor/react/promise/src/LazyPromise.php b/vendor/react/promise/src/LazyPromise.php deleted file mode 100644 index 7546524..0000000 --- a/vendor/react/promise/src/LazyPromise.php +++ /dev/null @@ -1,63 +0,0 @@ -factory = $factory; - } - - public function then(callable $onFulfilled = null, callable $onRejected = null, callable $onProgress = null) - { - return $this->promise()->then($onFulfilled, $onRejected, $onProgress); - } - - public function done(callable $onFulfilled = null, callable $onRejected = null, callable $onProgress = null) - { - return $this->promise()->done($onFulfilled, $onRejected, $onProgress); - } - - public function otherwise(callable $onRejected) - { - return $this->promise()->otherwise($onRejected); - } - - public function always(callable $onFulfilledOrRejected) - { - return $this->promise()->always($onFulfilledOrRejected); - } - - public function progress(callable $onProgress) - { - return $this->promise()->progress($onProgress); - } - - public function cancel() - { - return $this->promise()->cancel(); - } - - /** - * @internal - * @see Promise::settle() - */ - public function promise() - { - if (null === $this->promise) { - try { - $this->promise = resolve(\call_user_func($this->factory)); - } catch (\Throwable $exception) { - $this->promise = new RejectedPromise($exception); - } catch (\Exception $exception) { - $this->promise = new RejectedPromise($exception); - } - } - - return $this->promise; - } -} diff --git a/vendor/react/promise/src/Promise.php b/vendor/react/promise/src/Promise.php deleted file mode 100644 index 33759e6..0000000 --- a/vendor/react/promise/src/Promise.php +++ /dev/null @@ -1,256 +0,0 @@ -canceller = $canceller; - - // Explicitly overwrite arguments with null values before invoking - // resolver function. This ensure that these arguments do not show up - // in the stack trace in PHP 7+ only. - $cb = $resolver; - $resolver = $canceller = null; - $this->call($cb); - } - - public function then(callable $onFulfilled = null, callable $onRejected = null, callable $onProgress = null) - { - if (null !== $this->result) { - return $this->result->then($onFulfilled, $onRejected, $onProgress); - } - - if (null === $this->canceller) { - return new static($this->resolver($onFulfilled, $onRejected, $onProgress)); - } - - // This promise has a canceller, so we create a new child promise which - // has a canceller that invokes the parent canceller if all other - // followers are also cancelled. We keep a reference to this promise - // instance for the static canceller function and clear this to avoid - // keeping a cyclic reference between parent and follower. - $parent = $this; - ++$parent->requiredCancelRequests; - - return new static( - $this->resolver($onFulfilled, $onRejected, $onProgress), - static function () use (&$parent) { - if (++$parent->cancelRequests >= $parent->requiredCancelRequests) { - $parent->cancel(); - } - - $parent = null; - } - ); - } - - public function done(callable $onFulfilled = null, callable $onRejected = null, callable $onProgress = null) - { - if (null !== $this->result) { - return $this->result->done($onFulfilled, $onRejected, $onProgress); - } - - $this->handlers[] = static function (ExtendedPromiseInterface $promise) use ($onFulfilled, $onRejected) { - $promise - ->done($onFulfilled, $onRejected); - }; - - if ($onProgress) { - $this->progressHandlers[] = $onProgress; - } - } - - public function otherwise(callable $onRejected) - { - return $this->then(null, static function ($reason) use ($onRejected) { - if (!_checkTypehint($onRejected, $reason)) { - return new RejectedPromise($reason); - } - - return $onRejected($reason); - }); - } - - public function always(callable $onFulfilledOrRejected) - { - return $this->then(static function ($value) use ($onFulfilledOrRejected) { - return resolve($onFulfilledOrRejected())->then(function () use ($value) { - return $value; - }); - }, static function ($reason) use ($onFulfilledOrRejected) { - return resolve($onFulfilledOrRejected())->then(function () use ($reason) { - return new RejectedPromise($reason); - }); - }); - } - - public function progress(callable $onProgress) - { - return $this->then(null, null, $onProgress); - } - - public function cancel() - { - if (null === $this->canceller || null !== $this->result) { - return; - } - - $canceller = $this->canceller; - $this->canceller = null; - - $this->call($canceller); - } - - private function resolver(callable $onFulfilled = null, callable $onRejected = null, callable $onProgress = null) - { - return function ($resolve, $reject, $notify) use ($onFulfilled, $onRejected, $onProgress) { - if ($onProgress) { - $progressHandler = static function ($update) use ($notify, $onProgress) { - try { - $notify($onProgress($update)); - } catch (\Throwable $e) { - $notify($e); - } catch (\Exception $e) { - $notify($e); - } - }; - } else { - $progressHandler = $notify; - } - - $this->handlers[] = static function (ExtendedPromiseInterface $promise) use ($onFulfilled, $onRejected, $resolve, $reject, $progressHandler) { - $promise - ->then($onFulfilled, $onRejected) - ->done($resolve, $reject, $progressHandler); - }; - - $this->progressHandlers[] = $progressHandler; - }; - } - - private function reject($reason = null) - { - if (null !== $this->result) { - return; - } - - $this->settle(reject($reason)); - } - - private function settle(ExtendedPromiseInterface $promise) - { - $promise = $this->unwrap($promise); - - if ($promise === $this) { - $promise = new RejectedPromise( - new \LogicException('Cannot resolve a promise with itself.') - ); - } - - $handlers = $this->handlers; - - $this->progressHandlers = $this->handlers = []; - $this->result = $promise; - $this->canceller = null; - - foreach ($handlers as $handler) { - $handler($promise); - } - } - - private function unwrap($promise) - { - $promise = $this->extract($promise); - - while ($promise instanceof self && null !== $promise->result) { - $promise = $this->extract($promise->result); - } - - return $promise; - } - - private function extract($promise) - { - if ($promise instanceof LazyPromise) { - $promise = $promise->promise(); - } - - return $promise; - } - - private function call(callable $cb) - { - // Explicitly overwrite argument with null value. This ensure that this - // argument does not show up in the stack trace in PHP 7+ only. - $callback = $cb; - $cb = null; - - // Use reflection to inspect number of arguments expected by this callback. - // We did some careful benchmarking here: Using reflection to avoid unneeded - // function arguments is actually faster than blindly passing them. - // Also, this helps avoiding unnecessary function arguments in the call stack - // if the callback creates an Exception (creating garbage cycles). - if (\is_array($callback)) { - $ref = new \ReflectionMethod($callback[0], $callback[1]); - } elseif (\is_object($callback) && !$callback instanceof \Closure) { - $ref = new \ReflectionMethod($callback, '__invoke'); - } else { - $ref = new \ReflectionFunction($callback); - } - $args = $ref->getNumberOfParameters(); - - try { - if ($args === 0) { - $callback(); - } else { - // Keep references to this promise instance for the static resolve/reject functions. - // By using static callbacks that are not bound to this instance - // and passing the target promise instance by reference, we can - // still execute its resolving logic and still clear this - // reference when settling the promise. This helps avoiding - // garbage cycles if any callback creates an Exception. - // These assumptions are covered by the test suite, so if you ever feel like - // refactoring this, go ahead, any alternative suggestions are welcome! - $target =& $this; - $progressHandlers =& $this->progressHandlers; - - $callback( - static function ($value = null) use (&$target) { - if ($target !== null) { - $target->settle(resolve($value)); - $target = null; - } - }, - static function ($reason = null) use (&$target) { - if ($target !== null) { - $target->reject($reason); - $target = null; - } - }, - static function ($update = null) use (&$progressHandlers) { - foreach ($progressHandlers as $handler) { - $handler($update); - } - } - ); - } - } catch (\Throwable $e) { - $target = null; - $this->reject($e); - } catch (\Exception $e) { - $target = null; - $this->reject($e); - } - } -} diff --git a/vendor/react/promise/src/PromiseInterface.php b/vendor/react/promise/src/PromiseInterface.php deleted file mode 100644 index fcd763d..0000000 --- a/vendor/react/promise/src/PromiseInterface.php +++ /dev/null @@ -1,14 +0,0 @@ -reason = $reason; - } - - public function then(callable $onFulfilled = null, callable $onRejected = null, callable $onProgress = null) - { - if (null === $onRejected) { - return $this; - } - - try { - return resolve($onRejected($this->reason)); - } catch (\Throwable $exception) { - return new RejectedPromise($exception); - } catch (\Exception $exception) { - return new RejectedPromise($exception); - } - } - - public function done(callable $onFulfilled = null, callable $onRejected = null, callable $onProgress = null) - { - if (null === $onRejected) { - throw UnhandledRejectionException::resolve($this->reason); - } - - $result = $onRejected($this->reason); - - if ($result instanceof self) { - throw UnhandledRejectionException::resolve($result->reason); - } - - if ($result instanceof ExtendedPromiseInterface) { - $result->done(); - } - } - - public function otherwise(callable $onRejected) - { - if (!_checkTypehint($onRejected, $this->reason)) { - return $this; - } - - return $this->then(null, $onRejected); - } - - public function always(callable $onFulfilledOrRejected) - { - return $this->then(null, function ($reason) use ($onFulfilledOrRejected) { - return resolve($onFulfilledOrRejected())->then(function () use ($reason) { - return new RejectedPromise($reason); - }); - }); - } - - public function progress(callable $onProgress) - { - return $this; - } - - public function cancel() - { - } -} diff --git a/vendor/react/promise/src/UnhandledRejectionException.php b/vendor/react/promise/src/UnhandledRejectionException.php deleted file mode 100644 index e7fe2f7..0000000 --- a/vendor/react/promise/src/UnhandledRejectionException.php +++ /dev/null @@ -1,31 +0,0 @@ -reason = $reason; - - $message = \sprintf('Unhandled Rejection: %s', \json_encode($reason)); - - parent::__construct($message, 0); - } - - public function getReason() - { - return $this->reason; - } -} diff --git a/vendor/react/promise/src/functions.php b/vendor/react/promise/src/functions.php deleted file mode 100644 index c549e4e..0000000 --- a/vendor/react/promise/src/functions.php +++ /dev/null @@ -1,246 +0,0 @@ -then($resolve, $reject, $notify); - }, $canceller); - } - - return new FulfilledPromise($promiseOrValue); -} - -function reject($promiseOrValue = null) -{ - if ($promiseOrValue instanceof PromiseInterface) { - return resolve($promiseOrValue)->then(function ($value) { - return new RejectedPromise($value); - }); - } - - return new RejectedPromise($promiseOrValue); -} - -function all($promisesOrValues) -{ - return map($promisesOrValues, function ($val) { - return $val; - }); -} - -function race($promisesOrValues) -{ - $cancellationQueue = new CancellationQueue(); - $cancellationQueue->enqueue($promisesOrValues); - - return new Promise(function ($resolve, $reject, $notify) use ($promisesOrValues, $cancellationQueue) { - resolve($promisesOrValues) - ->done(function ($array) use ($cancellationQueue, $resolve, $reject, $notify) { - if (!is_array($array) || !$array) { - $resolve(); - return; - } - - foreach ($array as $promiseOrValue) { - $cancellationQueue->enqueue($promiseOrValue); - - resolve($promiseOrValue) - ->done($resolve, $reject, $notify); - } - }, $reject, $notify); - }, $cancellationQueue); -} - -function any($promisesOrValues) -{ - return some($promisesOrValues, 1) - ->then(function ($val) { - return \array_shift($val); - }); -} - -function some($promisesOrValues, $howMany) -{ - $cancellationQueue = new CancellationQueue(); - $cancellationQueue->enqueue($promisesOrValues); - - return new Promise(function ($resolve, $reject, $notify) use ($promisesOrValues, $howMany, $cancellationQueue) { - resolve($promisesOrValues) - ->done(function ($array) use ($howMany, $cancellationQueue, $resolve, $reject, $notify) { - if (!\is_array($array) || $howMany < 1) { - $resolve([]); - return; - } - - $len = \count($array); - - if ($len < $howMany) { - throw new Exception\LengthException( - \sprintf( - 'Input array must contain at least %d item%s but contains only %s item%s.', - $howMany, - 1 === $howMany ? '' : 's', - $len, - 1 === $len ? '' : 's' - ) - ); - } - - $toResolve = $howMany; - $toReject = ($len - $toResolve) + 1; - $values = []; - $reasons = []; - - foreach ($array as $i => $promiseOrValue) { - $fulfiller = function ($val) use ($i, &$values, &$toResolve, $toReject, $resolve) { - if ($toResolve < 1 || $toReject < 1) { - return; - } - - $values[$i] = $val; - - if (0 === --$toResolve) { - $resolve($values); - } - }; - - $rejecter = function ($reason) use ($i, &$reasons, &$toReject, $toResolve, $reject) { - if ($toResolve < 1 || $toReject < 1) { - return; - } - - $reasons[$i] = $reason; - - if (0 === --$toReject) { - $reject($reasons); - } - }; - - $cancellationQueue->enqueue($promiseOrValue); - - resolve($promiseOrValue) - ->done($fulfiller, $rejecter, $notify); - } - }, $reject, $notify); - }, $cancellationQueue); -} - -function map($promisesOrValues, callable $mapFunc) -{ - $cancellationQueue = new CancellationQueue(); - $cancellationQueue->enqueue($promisesOrValues); - - return new Promise(function ($resolve, $reject, $notify) use ($promisesOrValues, $mapFunc, $cancellationQueue) { - resolve($promisesOrValues) - ->done(function ($array) use ($mapFunc, $cancellationQueue, $resolve, $reject, $notify) { - if (!\is_array($array) || !$array) { - $resolve([]); - return; - } - - $toResolve = \count($array); - $values = []; - - foreach ($array as $i => $promiseOrValue) { - $cancellationQueue->enqueue($promiseOrValue); - $values[$i] = null; - - resolve($promiseOrValue) - ->then($mapFunc) - ->done( - function ($mapped) use ($i, &$values, &$toResolve, $resolve) { - $values[$i] = $mapped; - - if (0 === --$toResolve) { - $resolve($values); - } - }, - $reject, - $notify - ); - } - }, $reject, $notify); - }, $cancellationQueue); -} - -function reduce($promisesOrValues, callable $reduceFunc, $initialValue = null) -{ - $cancellationQueue = new CancellationQueue(); - $cancellationQueue->enqueue($promisesOrValues); - - return new Promise(function ($resolve, $reject, $notify) use ($promisesOrValues, $reduceFunc, $initialValue, $cancellationQueue) { - resolve($promisesOrValues) - ->done(function ($array) use ($reduceFunc, $initialValue, $cancellationQueue, $resolve, $reject, $notify) { - if (!\is_array($array)) { - $array = []; - } - - $total = \count($array); - $i = 0; - - // Wrap the supplied $reduceFunc with one that handles promises and then - // delegates to the supplied. - $wrappedReduceFunc = function ($current, $val) use ($reduceFunc, $cancellationQueue, $total, &$i) { - $cancellationQueue->enqueue($val); - - return $current - ->then(function ($c) use ($reduceFunc, $total, &$i, $val) { - return resolve($val) - ->then(function ($value) use ($reduceFunc, $total, &$i, $c) { - return $reduceFunc($c, $value, $i++, $total); - }); - }); - }; - - $cancellationQueue->enqueue($initialValue); - - \array_reduce($array, $wrappedReduceFunc, resolve($initialValue)) - ->done($resolve, $reject, $notify); - }, $reject, $notify); - }, $cancellationQueue); -} - -// Internal functions -function _checkTypehint(callable $callback, $object) -{ - if (!\is_object($object)) { - return true; - } - - if (\is_array($callback)) { - $callbackReflection = new \ReflectionMethod($callback[0], $callback[1]); - } elseif (\is_object($callback) && !$callback instanceof \Closure) { - $callbackReflection = new \ReflectionMethod($callback, '__invoke'); - } else { - $callbackReflection = new \ReflectionFunction($callback); - } - - $parameters = $callbackReflection->getParameters(); - - if (!isset($parameters[0])) { - return true; - } - - $expectedException = $parameters[0]; - - if (!$expectedException->getClass()) { - return true; - } - - return $expectedException->getClass()->isInstance($object); -} diff --git a/vendor/react/promise/src/functions_include.php b/vendor/react/promise/src/functions_include.php deleted file mode 100644 index bd0c54f..0000000 --- a/vendor/react/promise/src/functions_include.php +++ /dev/null @@ -1,5 +0,0 @@ -normalizer = new TemplateNormalizer; - $this->normalizer->clear(); - $this->normalizer->append('MergeConsecutiveCopyOf'); - $this->normalizer->append('MergeIdenticalConditionalBranches'); - $this->normalizer->append('OptimizeNestedConditionals'); - $this->normalizer->append('RemoveLivePreviewAttributes'); - } - public function optimizeTemplate($template) - { - return $this->normalizer->normalizeTemplate($template); - } -} \ No newline at end of file diff --git a/vendor/symfony/config/Definition/ReferenceDumper.php b/vendor/symfony/config/Definition/ReferenceDumper.php deleted file mode 100644 index 047b258..0000000 --- a/vendor/symfony/config/Definition/ReferenceDumper.php +++ /dev/null @@ -1,24 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Config\Definition; - -@trigger_error('The '.__NAMESPACE__.'\ReferenceDumper class is deprecated since Symfony 2.4 and will be removed in 3.0. Use the Symfony\Component\Config\Definition\Dumper\YamlReferenceDumper class instead.', E_USER_DEPRECATED); - -use Symfony\Component\Config\Definition\Dumper\YamlReferenceDumper; - -/** - * @deprecated since version 2.4, to be removed in 3.0. - * Use {@link \Symfony\Component\Config\Definition\Dumper\YamlReferenceDumper} instead. - */ -class ReferenceDumper extends YamlReferenceDumper -{ -} diff --git a/vendor/symfony/config/Resource/BCResourceInterfaceChecker.php b/vendor/symfony/config/Resource/BCResourceInterfaceChecker.php deleted file mode 100644 index 64c9309..0000000 --- a/vendor/symfony/config/Resource/BCResourceInterfaceChecker.php +++ /dev/null @@ -1,36 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Config\Resource; - -/** - * Resource checker for the ResourceInterface. Exists for BC. - * - * @author Matthias Pigulla - * - * @deprecated since 2.8, to be removed in 3.0. - */ -class BCResourceInterfaceChecker extends SelfCheckingResourceChecker -{ - public function supports(ResourceInterface $metadata) - { - /* As all resources must be instanceof ResourceInterface, - we support them all. */ - return true; - } - - public function isFresh(ResourceInterface $resource, $timestamp) - { - @trigger_error(sprintf('The class "%s" is performing resource checking through ResourceInterface::isFresh(), which is deprecated since Symfony 2.8 and will be removed in 3.0', \get_class($resource)), E_USER_DEPRECATED); - - return parent::isFresh($resource, $timestamp); // For now, $metadata features the isFresh() method, so off we go (quack quack) - } -} diff --git a/vendor/symfony/console/Helper/DialogHelper.php b/vendor/symfony/console/Helper/DialogHelper.php deleted file mode 100644 index 87a5a0c..0000000 --- a/vendor/symfony/console/Helper/DialogHelper.php +++ /dev/null @@ -1,502 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Console\Helper; - -use Symfony\Component\Console\Exception\InvalidArgumentException; -use Symfony\Component\Console\Exception\RuntimeException; -use Symfony\Component\Console\Formatter\OutputFormatterStyle; -use Symfony\Component\Console\Output\ConsoleOutputInterface; -use Symfony\Component\Console\Output\OutputInterface; - -/** - * The Dialog class provides helpers to interact with the user. - * - * @author Fabien Potencier - * - * @deprecated since version 2.5, to be removed in 3.0. - * Use {@link \Symfony\Component\Console\Helper\QuestionHelper} instead. - */ -class DialogHelper extends InputAwareHelper -{ - private $inputStream; - private static $shell; - private static $stty; - - public function __construct($triggerDeprecationError = true) - { - if ($triggerDeprecationError) { - @trigger_error('"Symfony\Component\Console\Helper\DialogHelper" is deprecated since Symfony 2.5 and will be removed in 3.0. Use "Symfony\Component\Console\Helper\QuestionHelper" instead.', E_USER_DEPRECATED); - } - } - - /** - * Asks the user to select a value. - * - * @param OutputInterface $output An Output instance - * @param string|array $question The question to ask - * @param array $choices List of choices to pick from - * @param bool|string $default The default answer if the user enters nothing - * @param bool|int $attempts Max number of times to ask before giving up (false by default, which means infinite) - * @param string $errorMessage Message which will be shown if invalid value from choice list would be picked - * @param bool $multiselect Select more than one value separated by comma - * - * @return int|string|array The selected value or values (the key of the choices array) - * - * @throws InvalidArgumentException - */ - public function select(OutputInterface $output, $question, $choices, $default = null, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false) - { - if ($output instanceof ConsoleOutputInterface) { - $output = $output->getErrorOutput(); - } - - $width = max(array_map('strlen', array_keys($choices))); - - $messages = (array) $question; - foreach ($choices as $key => $value) { - $messages[] = sprintf(" [%-{$width}s] %s", $key, $value); - } - - $output->writeln($messages); - - $result = $this->askAndValidate($output, '> ', function ($picked) use ($choices, $errorMessage, $multiselect) { - // Collapse all spaces. - $selectedChoices = str_replace(' ', '', $picked); - - if ($multiselect) { - // Check for a separated comma values - if (!preg_match('/^[a-zA-Z0-9_-]+(?:,[a-zA-Z0-9_-]+)*$/', $selectedChoices, $matches)) { - throw new InvalidArgumentException(sprintf($errorMessage, $picked)); - } - $selectedChoices = explode(',', $selectedChoices); - } else { - $selectedChoices = array($picked); - } - - $multiselectChoices = array(); - - foreach ($selectedChoices as $value) { - if (empty($choices[$value])) { - throw new InvalidArgumentException(sprintf($errorMessage, $value)); - } - $multiselectChoices[] = $value; - } - - if ($multiselect) { - return $multiselectChoices; - } - - return $picked; - }, $attempts, $default); - - return $result; - } - - /** - * Asks a question to the user. - * - * @param OutputInterface $output An Output instance - * @param string|array $question The question to ask - * @param string $default The default answer if none is given by the user - * @param array $autocomplete List of values to autocomplete - * - * @return string The user answer - * - * @throws RuntimeException If there is no data to read in the input stream - */ - public function ask(OutputInterface $output, $question, $default = null, array $autocomplete = null) - { - if ($this->input && !$this->input->isInteractive()) { - return $default; - } - - if ($output instanceof ConsoleOutputInterface) { - $output = $output->getErrorOutput(); - } - - $output->write($question); - - $inputStream = $this->inputStream ?: STDIN; - - if (null === $autocomplete || !$this->hasSttyAvailable()) { - $ret = fgets($inputStream, 4096); - if (false === $ret) { - throw new RuntimeException('Aborted'); - } - $ret = trim($ret); - } else { - $ret = ''; - - $i = 0; - $ofs = -1; - $matches = $autocomplete; - $numMatches = \count($matches); - - $sttyMode = shell_exec('stty -g'); - - // Disable icanon (so we can fread each keypress) and echo (we'll do echoing here instead) - shell_exec('stty -icanon -echo'); - - // Add highlighted text style - $output->getFormatter()->setStyle('hl', new OutputFormatterStyle('black', 'white')); - - // Read a keypress - while (!feof($inputStream)) { - $c = fread($inputStream, 1); - - // Backspace Character - if ("\177" === $c) { - if (0 === $numMatches && 0 !== $i) { - --$i; - // Move cursor backwards - $output->write("\033[1D"); - } - - if (0 === $i) { - $ofs = -1; - $matches = $autocomplete; - $numMatches = \count($matches); - } else { - $numMatches = 0; - } - - // Pop the last character off the end of our string - $ret = substr($ret, 0, $i); - } elseif ("\033" === $c) { - // Did we read an escape sequence? - $c .= fread($inputStream, 2); - - // A = Up Arrow. B = Down Arrow - if (isset($c[2]) && ('A' === $c[2] || 'B' === $c[2])) { - if ('A' === $c[2] && -1 === $ofs) { - $ofs = 0; - } - - if (0 === $numMatches) { - continue; - } - - $ofs += ('A' === $c[2]) ? -1 : 1; - $ofs = ($numMatches + $ofs) % $numMatches; - } - } elseif (\ord($c) < 32) { - if ("\t" === $c || "\n" === $c) { - if ($numMatches > 0 && -1 !== $ofs) { - $ret = $matches[$ofs]; - // Echo out remaining chars for current match - $output->write(substr($ret, $i)); - $i = \strlen($ret); - } - - if ("\n" === $c) { - $output->write($c); - break; - } - - $numMatches = 0; - } - - continue; - } else { - $output->write($c); - $ret .= $c; - ++$i; - - $numMatches = 0; - $ofs = 0; - - foreach ($autocomplete as $value) { - // If typed characters match the beginning chunk of value (e.g. [AcmeDe]moBundle) - if (0 === strpos($value, $ret) && $i !== \strlen($value)) { - $matches[$numMatches++] = $value; - } - } - } - - // Erase characters from cursor to end of line - $output->write("\033[K"); - - if ($numMatches > 0 && -1 !== $ofs) { - // Save cursor position - $output->write("\0337"); - // Write highlighted text - $output->write(''.substr($matches[$ofs], $i).''); - // Restore cursor position - $output->write("\0338"); - } - } - - // Reset stty so it behaves normally again - shell_exec(sprintf('stty %s', $sttyMode)); - } - - return \strlen($ret) > 0 ? $ret : $default; - } - - /** - * Asks a confirmation to the user. - * - * The question will be asked until the user answers by nothing, yes, or no. - * - * @param OutputInterface $output An Output instance - * @param string|array $question The question to ask - * @param bool $default The default answer if the user enters nothing - * - * @return bool true if the user has confirmed, false otherwise - */ - public function askConfirmation(OutputInterface $output, $question, $default = true) - { - $answer = 'z'; - while ($answer && !\in_array(strtolower($answer[0]), array('y', 'n'))) { - $answer = $this->ask($output, $question); - } - - if (false === $default) { - return $answer && 'y' == strtolower($answer[0]); - } - - return !$answer || 'y' == strtolower($answer[0]); - } - - /** - * Asks a question to the user, the response is hidden. - * - * @param OutputInterface $output An Output instance - * @param string|array $question The question - * @param bool $fallback In case the response can not be hidden, whether to fallback on non-hidden question or not - * - * @return string The answer - * - * @throws RuntimeException In case the fallback is deactivated and the response can not be hidden - */ - public function askHiddenResponse(OutputInterface $output, $question, $fallback = true) - { - if ($output instanceof ConsoleOutputInterface) { - $output = $output->getErrorOutput(); - } - - if ('\\' === \DIRECTORY_SEPARATOR) { - $exe = __DIR__.'/../Resources/bin/hiddeninput.exe'; - - // handle code running from a phar - if ('phar:' === substr(__FILE__, 0, 5)) { - $tmpExe = sys_get_temp_dir().'/hiddeninput.exe'; - copy($exe, $tmpExe); - $exe = $tmpExe; - } - - $output->write($question); - $value = rtrim(shell_exec($exe)); - $output->writeln(''); - - if (isset($tmpExe)) { - unlink($tmpExe); - } - - return $value; - } - - if ($this->hasSttyAvailable()) { - $output->write($question); - - $sttyMode = shell_exec('stty -g'); - - shell_exec('stty -echo'); - $value = fgets($this->inputStream ?: STDIN, 4096); - shell_exec(sprintf('stty %s', $sttyMode)); - - if (false === $value) { - throw new RuntimeException('Aborted'); - } - - $value = trim($value); - $output->writeln(''); - - return $value; - } - - if (false !== $shell = $this->getShell()) { - $output->write($question); - $readCmd = 'csh' === $shell ? 'set mypassword = $<' : 'read -r mypassword'; - $command = sprintf("/usr/bin/env %s -c 'stty -echo; %s; stty echo; echo \$mypassword'", $shell, $readCmd); - $value = rtrim(shell_exec($command)); - $output->writeln(''); - - return $value; - } - - if ($fallback) { - return $this->ask($output, $question); - } - - throw new RuntimeException('Unable to hide the response'); - } - - /** - * Asks for a value and validates the response. - * - * The validator receives the data to validate. It must return the - * validated data when the data is valid and throw an exception - * otherwise. - * - * @param OutputInterface $output An Output instance - * @param string|array $question The question to ask - * @param callable $validator A PHP callback - * @param int|false $attempts Max number of times to ask before giving up (false by default, which means infinite) - * @param string $default The default answer if none is given by the user - * @param array $autocomplete List of values to autocomplete - * - * @return mixed - * - * @throws \Exception When any of the validators return an error - */ - public function askAndValidate(OutputInterface $output, $question, $validator, $attempts = false, $default = null, array $autocomplete = null) - { - $that = $this; - - $interviewer = function () use ($output, $question, $default, $autocomplete, $that) { - return $that->ask($output, $question, $default, $autocomplete); - }; - - return $this->validateAttempts($interviewer, $output, $validator, $attempts); - } - - /** - * Asks for a value, hide and validates the response. - * - * The validator receives the data to validate. It must return the - * validated data when the data is valid and throw an exception - * otherwise. - * - * @param OutputInterface $output An Output instance - * @param string|array $question The question to ask - * @param callable $validator A PHP callback - * @param int|false $attempts Max number of times to ask before giving up (false by default, which means infinite) - * @param bool $fallback In case the response can not be hidden, whether to fallback on non-hidden question or not - * - * @return string The response - * - * @throws \Exception When any of the validators return an error - * @throws RuntimeException In case the fallback is deactivated and the response can not be hidden - */ - public function askHiddenResponseAndValidate(OutputInterface $output, $question, $validator, $attempts = false, $fallback = true) - { - $that = $this; - - $interviewer = function () use ($output, $question, $fallback, $that) { - return $that->askHiddenResponse($output, $question, $fallback); - }; - - return $this->validateAttempts($interviewer, $output, $validator, $attempts); - } - - /** - * Sets the input stream to read from when interacting with the user. - * - * This is mainly useful for testing purpose. - * - * @param resource $stream The input stream - */ - public function setInputStream($stream) - { - $this->inputStream = $stream; - } - - /** - * Returns the helper's input stream. - * - * @return resource|null The input stream or null if the default STDIN is used - */ - public function getInputStream() - { - return $this->inputStream; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'dialog'; - } - - /** - * Return a valid Unix shell. - * - * @return string|bool The valid shell name, false in case no valid shell is found - */ - private function getShell() - { - if (null !== self::$shell) { - return self::$shell; - } - - self::$shell = false; - - if (file_exists('/usr/bin/env')) { - // handle other OSs with bash/zsh/ksh/csh if available to hide the answer - $test = "/usr/bin/env %s -c 'echo OK' 2> /dev/null"; - foreach (array('bash', 'zsh', 'ksh', 'csh') as $sh) { - if ('OK' === rtrim(shell_exec(sprintf($test, $sh)))) { - self::$shell = $sh; - break; - } - } - } - - return self::$shell; - } - - private function hasSttyAvailable() - { - if (null !== self::$stty) { - return self::$stty; - } - - exec('stty 2>&1', $output, $exitcode); - - return self::$stty = 0 === $exitcode; - } - - /** - * Validate an attempt. - * - * @param callable $interviewer A callable that will ask for a question and return the result - * @param OutputInterface $output An Output instance - * @param callable $validator A PHP callback - * @param int|false $attempts Max number of times to ask before giving up; false will ask infinitely - * - * @return string The validated response - * - * @throws \Exception In case the max number of attempts has been reached and no valid response has been given - */ - private function validateAttempts($interviewer, OutputInterface $output, $validator, $attempts) - { - if ($output instanceof ConsoleOutputInterface) { - $output = $output->getErrorOutput(); - } - - $e = null; - while (false === $attempts || $attempts--) { - if (null !== $e) { - $output->writeln($this->getHelperSet()->get('formatter')->formatBlock($e->getMessage(), 'error')); - } - - try { - return \call_user_func($validator, $interviewer()); - } catch (\Exception $e) { - } - } - - throw $e; - } -} diff --git a/vendor/symfony/console/Helper/ProgressHelper.php b/vendor/symfony/console/Helper/ProgressHelper.php deleted file mode 100644 index 4596f17..0000000 --- a/vendor/symfony/console/Helper/ProgressHelper.php +++ /dev/null @@ -1,469 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Console\Helper; - -use Symfony\Component\Console\Exception\LogicException; -use Symfony\Component\Console\Output\ConsoleOutputInterface; -use Symfony\Component\Console\Output\NullOutput; -use Symfony\Component\Console\Output\OutputInterface; - -/** - * The Progress class provides helpers to display progress output. - * - * @author Chris Jones - * @author Fabien Potencier - * - * @deprecated since version 2.5, to be removed in 3.0 - * Use {@link ProgressBar} instead. - */ -class ProgressHelper extends Helper -{ - const FORMAT_QUIET = ' %percent%%'; - const FORMAT_NORMAL = ' %current%/%max% [%bar%] %percent%%'; - const FORMAT_VERBOSE = ' %current%/%max% [%bar%] %percent%% Elapsed: %elapsed%'; - const FORMAT_QUIET_NOMAX = ' %current%'; - const FORMAT_NORMAL_NOMAX = ' %current% [%bar%]'; - const FORMAT_VERBOSE_NOMAX = ' %current% [%bar%] Elapsed: %elapsed%'; - - // options - private $barWidth = 28; - private $barChar = '='; - private $emptyBarChar = '-'; - private $progressChar = '>'; - private $format = null; - private $redrawFreq = 1; - - private $lastMessagesLength; - private $barCharOriginal; - - /** - * @var OutputInterface - */ - private $output; - - /** - * Current step. - * - * @var int - */ - private $current; - - /** - * Maximum number of steps. - * - * @var int - */ - private $max; - - /** - * Start time of the progress bar. - * - * @var int - */ - private $startTime; - - /** - * List of formatting variables. - * - * @var array - */ - private $defaultFormatVars = array( - 'current', - 'max', - 'bar', - 'percent', - 'elapsed', - ); - - /** - * Available formatting variables. - * - * @var array - */ - private $formatVars; - - /** - * Stored format part widths (used for padding). - * - * @var array - */ - private $widths = array( - 'current' => 4, - 'max' => 4, - 'percent' => 3, - 'elapsed' => 6, - ); - - /** - * Various time formats. - * - * @var array - */ - private $timeFormats = array( - array(0, '???'), - array(2, '1 sec'), - array(59, 'secs', 1), - array(60, '1 min'), - array(3600, 'mins', 60), - array(5400, '1 hr'), - array(86400, 'hrs', 3600), - array(129600, '1 day'), - array(604800, 'days', 86400), - ); - - public function __construct($triggerDeprecationError = true) - { - if ($triggerDeprecationError) { - @trigger_error('The '.__CLASS__.' class is deprecated since Symfony 2.5 and will be removed in 3.0. Use the Symfony\Component\Console\Helper\ProgressBar class instead.', E_USER_DEPRECATED); - } - } - - /** - * Sets the progress bar width. - * - * @param int $size The progress bar size - */ - public function setBarWidth($size) - { - $this->barWidth = (int) $size; - } - - /** - * Sets the bar character. - * - * @param string $char A character - */ - public function setBarCharacter($char) - { - $this->barChar = $char; - } - - /** - * Sets the empty bar character. - * - * @param string $char A character - */ - public function setEmptyBarCharacter($char) - { - $this->emptyBarChar = $char; - } - - /** - * Sets the progress bar character. - * - * @param string $char A character - */ - public function setProgressCharacter($char) - { - $this->progressChar = $char; - } - - /** - * Sets the progress bar format. - * - * @param string $format The format - */ - public function setFormat($format) - { - $this->format = $format; - } - - /** - * Sets the redraw frequency. - * - * @param int $freq The frequency in steps - */ - public function setRedrawFrequency($freq) - { - $this->redrawFreq = (int) $freq; - } - - /** - * Starts the progress output. - * - * @param OutputInterface $output An Output instance - * @param int|null $max Maximum steps - */ - public function start(OutputInterface $output, $max = null) - { - if ($output instanceof ConsoleOutputInterface) { - $output = $output->getErrorOutput(); - } - - $this->startTime = time(); - $this->current = 0; - $this->max = (int) $max; - - // Disabling output when it does not support ANSI codes as it would result in a broken display anyway. - $this->output = $output->isDecorated() ? $output : new NullOutput(); - $this->lastMessagesLength = 0; - $this->barCharOriginal = ''; - - if (null === $this->format) { - switch ($output->getVerbosity()) { - case OutputInterface::VERBOSITY_QUIET: - $this->format = self::FORMAT_QUIET_NOMAX; - if ($this->max > 0) { - $this->format = self::FORMAT_QUIET; - } - break; - case OutputInterface::VERBOSITY_VERBOSE: - case OutputInterface::VERBOSITY_VERY_VERBOSE: - case OutputInterface::VERBOSITY_DEBUG: - $this->format = self::FORMAT_VERBOSE_NOMAX; - if ($this->max > 0) { - $this->format = self::FORMAT_VERBOSE; - } - break; - default: - $this->format = self::FORMAT_NORMAL_NOMAX; - if ($this->max > 0) { - $this->format = self::FORMAT_NORMAL; - } - break; - } - } - - $this->initialize(); - } - - /** - * Advances the progress output X steps. - * - * @param int $step Number of steps to advance - * @param bool $redraw Whether to redraw or not - * - * @throws LogicException - */ - public function advance($step = 1, $redraw = false) - { - $this->setCurrent($this->current + $step, $redraw); - } - - /** - * Sets the current progress. - * - * @param int $current The current progress - * @param bool $redraw Whether to redraw or not - * - * @throws LogicException - */ - public function setCurrent($current, $redraw = false) - { - if (null === $this->startTime) { - throw new LogicException('You must start the progress bar before calling setCurrent().'); - } - - $current = (int) $current; - - if ($current < $this->current) { - throw new LogicException('You can\'t regress the progress bar'); - } - - if (0 === $this->current) { - $redraw = true; - } - - $prevPeriod = (int) ($this->current / $this->redrawFreq); - - $this->current = $current; - - $currPeriod = (int) ($this->current / $this->redrawFreq); - if ($redraw || $prevPeriod !== $currPeriod || $this->max === $this->current) { - $this->display(); - } - } - - /** - * Outputs the current progress string. - * - * @param bool $finish Forces the end result - * - * @throws LogicException - */ - public function display($finish = false) - { - if (null === $this->startTime) { - throw new LogicException('You must start the progress bar before calling display().'); - } - - $message = $this->format; - foreach ($this->generate($finish) as $name => $value) { - $message = str_replace("%{$name}%", $value, $message); - } - $this->overwrite($this->output, $message); - } - - /** - * Removes the progress bar from the current line. - * - * This is useful if you wish to write some output - * while a progress bar is running. - * Call display() to show the progress bar again. - */ - public function clear() - { - $this->overwrite($this->output, ''); - } - - /** - * Finishes the progress output. - */ - public function finish() - { - if (null === $this->startTime) { - throw new LogicException('You must start the progress bar before calling finish().'); - } - - if (null !== $this->startTime) { - if (!$this->max) { - $this->barChar = $this->barCharOriginal; - $this->display(true); - } - $this->startTime = null; - $this->output->writeln(''); - $this->output = null; - } - } - - /** - * Initializes the progress helper. - */ - private function initialize() - { - $this->formatVars = array(); - foreach ($this->defaultFormatVars as $var) { - if (false !== strpos($this->format, "%{$var}%")) { - $this->formatVars[$var] = true; - } - } - - if ($this->max > 0) { - $this->widths['max'] = $this->strlen($this->max); - $this->widths['current'] = $this->widths['max']; - } else { - $this->barCharOriginal = $this->barChar; - $this->barChar = $this->emptyBarChar; - } - } - - /** - * Generates the array map of format variables to values. - * - * @param bool $finish Forces the end result - * - * @return array Array of format vars and values - */ - private function generate($finish = false) - { - $vars = array(); - $percent = 0; - if ($this->max > 0) { - $percent = (float) $this->current / $this->max; - } - - if (isset($this->formatVars['bar'])) { - if ($this->max > 0) { - $completeBars = floor($percent * $this->barWidth); - } else { - if (!$finish) { - $completeBars = floor($this->current % $this->barWidth); - } else { - $completeBars = $this->barWidth; - } - } - - $emptyBars = $this->barWidth - $completeBars - $this->strlen($this->progressChar); - $bar = str_repeat($this->barChar, $completeBars); - if ($completeBars < $this->barWidth) { - $bar .= $this->progressChar; - $bar .= str_repeat($this->emptyBarChar, $emptyBars); - } - - $vars['bar'] = $bar; - } - - if (isset($this->formatVars['elapsed'])) { - $elapsed = time() - $this->startTime; - $vars['elapsed'] = str_pad($this->humaneTime($elapsed), $this->widths['elapsed'], ' ', STR_PAD_LEFT); - } - - if (isset($this->formatVars['current'])) { - $vars['current'] = str_pad($this->current, $this->widths['current'], ' ', STR_PAD_LEFT); - } - - if (isset($this->formatVars['max'])) { - $vars['max'] = $this->max; - } - - if (isset($this->formatVars['percent'])) { - $vars['percent'] = str_pad(floor($percent * 100), $this->widths['percent'], ' ', STR_PAD_LEFT); - } - - return $vars; - } - - /** - * Converts seconds into human-readable format. - * - * @param int $secs Number of seconds - * - * @return string Time in readable format - */ - private function humaneTime($secs) - { - $text = ''; - foreach ($this->timeFormats as $format) { - if ($secs < $format[0]) { - if (2 == \count($format)) { - $text = $format[1]; - break; - } else { - $text = ceil($secs / $format[2]).' '.$format[1]; - break; - } - } - } - - return $text; - } - - /** - * Overwrites a previous message to the output. - * - * @param OutputInterface $output An Output instance - * @param string $message The message - */ - private function overwrite(OutputInterface $output, $message) - { - $length = $this->strlen($message); - - // append whitespace to match the last line's length - if (null !== $this->lastMessagesLength && $this->lastMessagesLength > $length) { - $message = str_pad($message, $this->lastMessagesLength, "\x20", STR_PAD_RIGHT); - } - - // carriage return - $output->write("\x0D"); - $output->write($message); - - $this->lastMessagesLength = $this->strlen($message); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'progress'; - } -} diff --git a/vendor/symfony/console/Helper/TableHelper.php b/vendor/symfony/console/Helper/TableHelper.php deleted file mode 100644 index 3d2095a..0000000 --- a/vendor/symfony/console/Helper/TableHelper.php +++ /dev/null @@ -1,264 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Console\Helper; - -use Symfony\Component\Console\Exception\InvalidArgumentException; -use Symfony\Component\Console\Output\NullOutput; -use Symfony\Component\Console\Output\OutputInterface; - -/** - * Provides helpers to display table output. - * - * @author Саша Стаменковић - * @author Fabien Potencier - * - * @deprecated since version 2.5, to be removed in 3.0 - * Use {@link Table} instead. - */ -class TableHelper extends Helper -{ - const LAYOUT_DEFAULT = 0; - const LAYOUT_BORDERLESS = 1; - const LAYOUT_COMPACT = 2; - - private $table; - - public function __construct($triggerDeprecationError = true) - { - if ($triggerDeprecationError) { - @trigger_error('The '.__CLASS__.' class is deprecated since Symfony 2.5 and will be removed in 3.0. Use the Symfony\Component\Console\Helper\Table class instead.', E_USER_DEPRECATED); - } - - $this->table = new Table(new NullOutput()); - } - - /** - * Sets table layout type. - * - * @param int $layout self::LAYOUT_* - * - * @return $this - * - * @throws InvalidArgumentException when the table layout is not known - */ - public function setLayout($layout) - { - switch ($layout) { - case self::LAYOUT_BORDERLESS: - $this->table->setStyle('borderless'); - break; - - case self::LAYOUT_COMPACT: - $this->table->setStyle('compact'); - break; - - case self::LAYOUT_DEFAULT: - $this->table->setStyle('default'); - break; - - default: - throw new InvalidArgumentException(sprintf('Invalid table layout "%s".', $layout)); - } - - return $this; - } - - public function setHeaders(array $headers) - { - $this->table->setHeaders($headers); - - return $this; - } - - public function setRows(array $rows) - { - $this->table->setRows($rows); - - return $this; - } - - public function addRows(array $rows) - { - $this->table->addRows($rows); - - return $this; - } - - public function addRow(array $row) - { - $this->table->addRow($row); - - return $this; - } - - public function setRow($column, array $row) - { - $this->table->setRow($column, $row); - - return $this; - } - - /** - * Sets padding character, used for cell padding. - * - * @param string $paddingChar - * - * @return $this - */ - public function setPaddingChar($paddingChar) - { - $this->table->getStyle()->setPaddingChar($paddingChar); - - return $this; - } - - /** - * Sets horizontal border character. - * - * @param string $horizontalBorderChar - * - * @return $this - */ - public function setHorizontalBorderChar($horizontalBorderChar) - { - $this->table->getStyle()->setHorizontalBorderChar($horizontalBorderChar); - - return $this; - } - - /** - * Sets vertical border character. - * - * @param string $verticalBorderChar - * - * @return $this - */ - public function setVerticalBorderChar($verticalBorderChar) - { - $this->table->getStyle()->setVerticalBorderChar($verticalBorderChar); - - return $this; - } - - /** - * Sets crossing character. - * - * @param string $crossingChar - * - * @return $this - */ - public function setCrossingChar($crossingChar) - { - $this->table->getStyle()->setCrossingChar($crossingChar); - - return $this; - } - - /** - * Sets header cell format. - * - * @param string $cellHeaderFormat - * - * @return $this - */ - public function setCellHeaderFormat($cellHeaderFormat) - { - $this->table->getStyle()->setCellHeaderFormat($cellHeaderFormat); - - return $this; - } - - /** - * Sets row cell format. - * - * @param string $cellRowFormat - * - * @return $this - */ - public function setCellRowFormat($cellRowFormat) - { - $this->table->getStyle()->setCellHeaderFormat($cellRowFormat); - - return $this; - } - - /** - * Sets row cell content format. - * - * @param string $cellRowContentFormat - * - * @return $this - */ - public function setCellRowContentFormat($cellRowContentFormat) - { - $this->table->getStyle()->setCellRowContentFormat($cellRowContentFormat); - - return $this; - } - - /** - * Sets table border format. - * - * @param string $borderFormat - * - * @return $this - */ - public function setBorderFormat($borderFormat) - { - $this->table->getStyle()->setBorderFormat($borderFormat); - - return $this; - } - - /** - * Sets cell padding type. - * - * @param int $padType STR_PAD_* - * - * @return $this - */ - public function setPadType($padType) - { - $this->table->getStyle()->setPadType($padType); - - return $this; - } - - /** - * Renders table to output. - * - * Example: - * +---------------+-----------------------+------------------+ - * | ISBN | Title | Author | - * +---------------+-----------------------+------------------+ - * | 99921-58-10-7 | Divine Comedy | Dante Alighieri | - * | 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens | - * | 960-425-059-0 | The Lord of the Rings | J. R. R. Tolkien | - * +---------------+-----------------------+------------------+ - */ - public function render(OutputInterface $output) - { - $p = new \ReflectionProperty($this->table, 'output'); - $p->setAccessible(true); - $p->setValue($this->table, $output); - - $this->table->render(); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'table'; - } -} diff --git a/vendor/symfony/console/Shell.php b/vendor/symfony/console/Shell.php deleted file mode 100644 index 5d23e20..0000000 --- a/vendor/symfony/console/Shell.php +++ /dev/null @@ -1,229 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Console; - -use Symfony\Component\Console\Exception\RuntimeException; -use Symfony\Component\Console\Input\StringInput; -use Symfony\Component\Console\Output\ConsoleOutput; -use Symfony\Component\Process\PhpExecutableFinder; -use Symfony\Component\Process\ProcessBuilder; - -/** - * A Shell wraps an Application to add shell capabilities to it. - * - * Support for history and completion only works with a PHP compiled - * with readline support (either --with-readline or --with-libedit) - * - * @deprecated since version 2.8, to be removed in 3.0. - * - * @author Fabien Potencier - * @author Martin Hasoň - */ -class Shell -{ - private $application; - private $history; - private $output; - private $hasReadline; - private $processIsolation = false; - - /** - * If there is no readline support for the current PHP executable - * a \RuntimeException exception is thrown. - */ - public function __construct(Application $application) - { - @trigger_error('The '.__CLASS__.' class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED); - - $this->hasReadline = \function_exists('readline'); - $this->application = $application; - $this->history = getenv('HOME').'/.history_'.$application->getName(); - $this->output = new ConsoleOutput(); - } - - /** - * Runs the shell. - */ - public function run() - { - $this->application->setAutoExit(false); - $this->application->setCatchExceptions(true); - - if ($this->hasReadline) { - readline_read_history($this->history); - readline_completion_function(array($this, 'autocompleter')); - } - - $this->output->writeln($this->getHeader()); - $php = null; - if ($this->processIsolation) { - $finder = new PhpExecutableFinder(); - $php = $finder->find(); - $this->output->writeln(<<<'EOF' -Running with process isolation, you should consider this: - * each command is executed as separate process, - * commands don't support interactivity, all params must be passed explicitly, - * commands output is not colorized. - -EOF - ); - } - - while (true) { - $command = $this->readline(); - - if (false === $command) { - $this->output->writeln("\n"); - - break; - } - - if ($this->hasReadline) { - readline_add_history($command); - readline_write_history($this->history); - } - - if ($this->processIsolation) { - $pb = new ProcessBuilder(); - - $process = $pb - ->add($php) - ->add($_SERVER['argv'][0]) - ->add($command) - ->inheritEnvironmentVariables(true) - ->getProcess() - ; - - $output = $this->output; - $process->run(function ($type, $data) use ($output) { - $output->writeln($data); - }); - - $ret = $process->getExitCode(); - } else { - $ret = $this->application->run(new StringInput($command), $this->output); - } - - if (0 !== $ret) { - $this->output->writeln(sprintf('The command terminated with an error status (%s)', $ret)); - } - } - } - - /** - * Returns the shell header. - * - * @return string The header string - */ - protected function getHeader() - { - return <<{$this->application->getName()} shell ({$this->application->getVersion()}). - -At the prompt, type help for some help, -or list to get a list of available commands. - -To exit the shell, type ^D. - -EOF; - } - - /** - * Renders a prompt. - * - * @return string The prompt - */ - protected function getPrompt() - { - // using the formatter here is required when using readline - return $this->output->getFormatter()->format($this->application->getName().' > '); - } - - protected function getOutput() - { - return $this->output; - } - - protected function getApplication() - { - return $this->application; - } - - /** - * Tries to return autocompletion for the current entered text. - * - * @param string $text The last segment of the entered text - * - * @return bool|array A list of guessed strings or true - */ - private function autocompleter($text) - { - $info = readline_info(); - $text = substr($info['line_buffer'], 0, $info['end']); - - if ($info['point'] !== $info['end']) { - return true; - } - - // task name? - if (false === strpos($text, ' ') || !$text) { - return array_keys($this->application->all()); - } - - // options and arguments? - try { - $command = $this->application->find(substr($text, 0, strpos($text, ' '))); - } catch (\Exception $e) { - return true; - } - - $list = array('--help'); - foreach ($command->getDefinition()->getOptions() as $option) { - $list[] = '--'.$option->getName(); - } - - return $list; - } - - /** - * Reads a single line from standard input. - * - * @return string The single line from standard input - */ - private function readline() - { - if ($this->hasReadline) { - $line = readline($this->getPrompt()); - } else { - $this->output->write($this->getPrompt()); - $line = fgets(STDIN, 1024); - $line = (false === $line || '' === $line) ? false : rtrim($line); - } - - return $line; - } - - public function getProcessIsolation() - { - return $this->processIsolation; - } - - public function setProcessIsolation($processIsolation) - { - $this->processIsolation = (bool) $processIsolation; - - if ($this->processIsolation && !class_exists('Symfony\\Component\\Process\\Process')) { - throw new RuntimeException('Unable to isolate processes as the Symfony Process Component is not installed.'); - } - } -} diff --git a/vendor/symfony/debug/Exception/DummyException.php b/vendor/symfony/debug/Exception/DummyException.php deleted file mode 100644 index 1b9082b..0000000 --- a/vendor/symfony/debug/Exception/DummyException.php +++ /dev/null @@ -1,23 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug\Exception; - -@trigger_error('The '.__NAMESPACE__.'\DummyException class is deprecated since Symfony 2.5 and will be removed in 3.0.', E_USER_DEPRECATED); - -/** - * @author Fabien Potencier - * - * @deprecated since version 2.5, to be removed in 3.0. - */ -class DummyException extends \ErrorException -{ -} diff --git a/vendor/symfony/dependency-injection/ContainerAware.php b/vendor/symfony/dependency-injection/ContainerAware.php deleted file mode 100644 index f3f2a50..0000000 --- a/vendor/symfony/dependency-injection/ContainerAware.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\DependencyInjection; - -/** - * A simple implementation of ContainerAwareInterface. - * - * @author Fabien Potencier - * - * @deprecated since version 2.8, to be removed in 3.0. Use the ContainerAwareTrait instead. - */ -abstract class ContainerAware implements ContainerAwareInterface -{ - /** - * @var ContainerInterface - */ - protected $container; - - /** - * {@inheritdoc} - */ - public function setContainer(ContainerInterface $container = null) - { - $this->container = $container; - } -} diff --git a/vendor/symfony/dependency-injection/Exception/InactiveScopeException.php b/vendor/symfony/dependency-injection/Exception/InactiveScopeException.php deleted file mode 100644 index 6b3dd3e..0000000 --- a/vendor/symfony/dependency-injection/Exception/InactiveScopeException.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\DependencyInjection\Exception; - -/** - * This exception is thrown when you try to create a service of an inactive scope. - * - * @author Johannes M. Schmitt - */ -class InactiveScopeException extends RuntimeException -{ - private $serviceId; - private $scope; - - public function __construct($serviceId, $scope, \Exception $previous = null) - { - parent::__construct(sprintf('You cannot create a service ("%s") of an inactive scope ("%s").', $serviceId, $scope), 0, $previous); - - $this->serviceId = $serviceId; - $this->scope = $scope; - } - - public function getServiceId() - { - return $this->serviceId; - } - - public function getScope() - { - return $this->scope; - } -} diff --git a/vendor/symfony/dependency-injection/Exception/ScopeCrossingInjectionException.php b/vendor/symfony/dependency-injection/Exception/ScopeCrossingInjectionException.php deleted file mode 100644 index 661fbab..0000000 --- a/vendor/symfony/dependency-injection/Exception/ScopeCrossingInjectionException.php +++ /dev/null @@ -1,65 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\DependencyInjection\Exception; - -/** - * This exception is thrown when the a scope crossing injection is detected. - * - * @author Johannes M. Schmitt - */ -class ScopeCrossingInjectionException extends RuntimeException -{ - private $sourceServiceId; - private $sourceScope; - private $destServiceId; - private $destScope; - - public function __construct($sourceServiceId, $sourceScope, $destServiceId, $destScope, \Exception $previous = null) - { - parent::__construct(sprintf( - 'Scope Crossing Injection detected: The definition "%s" references the service "%s" which belongs to another scope hierarchy. ' - .'This service might not be available consistently. Generally, it is safer to either move the definition "%s" to scope "%s", or ' - .'declare "%s" as a child scope of "%s". If you can be sure that the other scope is always active, you can set the reference to strict=false to get rid of this error.', - $sourceServiceId, - $destServiceId, - $sourceServiceId, - $destScope, - $sourceScope, - $destScope - ), 0, $previous); - - $this->sourceServiceId = $sourceServiceId; - $this->sourceScope = $sourceScope; - $this->destServiceId = $destServiceId; - $this->destScope = $destScope; - } - - public function getSourceServiceId() - { - return $this->sourceServiceId; - } - - public function getSourceScope() - { - return $this->sourceScope; - } - - public function getDestServiceId() - { - return $this->destServiceId; - } - - public function getDestScope() - { - return $this->destScope; - } -} diff --git a/vendor/symfony/dependency-injection/Exception/ScopeWideningInjectionException.php b/vendor/symfony/dependency-injection/Exception/ScopeWideningInjectionException.php deleted file mode 100644 index 86a6684..0000000 --- a/vendor/symfony/dependency-injection/Exception/ScopeWideningInjectionException.php +++ /dev/null @@ -1,64 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\DependencyInjection\Exception; - -/** - * Thrown when a scope widening injection is detected. - * - * @author Johannes M. Schmitt - */ -class ScopeWideningInjectionException extends RuntimeException -{ - private $sourceServiceId; - private $sourceScope; - private $destServiceId; - private $destScope; - - public function __construct($sourceServiceId, $sourceScope, $destServiceId, $destScope, \Exception $previous = null) - { - parent::__construct(sprintf( - 'Scope Widening Injection detected: The definition "%s" references the service "%s" which belongs to a narrower scope. ' - .'Generally, it is safer to either move "%s" to scope "%s" or alternatively rely on the provider pattern by injecting the container itself, and requesting the service "%s" each time it is needed. ' - .'In rare, special cases however that might not be necessary, then you can set the reference to strict=false to get rid of this error.', - $sourceServiceId, - $destServiceId, - $sourceServiceId, - $destScope, - $destServiceId - ), 0, $previous); - - $this->sourceServiceId = $sourceServiceId; - $this->sourceScope = $sourceScope; - $this->destServiceId = $destServiceId; - $this->destScope = $destScope; - } - - public function getSourceServiceId() - { - return $this->sourceServiceId; - } - - public function getSourceScope() - { - return $this->sourceScope; - } - - public function getDestServiceId() - { - return $this->destServiceId; - } - - public function getDestScope() - { - return $this->destScope; - } -} diff --git a/vendor/symfony/dependency-injection/IntrospectableContainerInterface.php b/vendor/symfony/dependency-injection/IntrospectableContainerInterface.php deleted file mode 100644 index 4aa0059..0000000 --- a/vendor/symfony/dependency-injection/IntrospectableContainerInterface.php +++ /dev/null @@ -1,32 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\DependencyInjection; - -/** - * IntrospectableContainerInterface defines additional introspection functionality - * for containers, allowing logic to be implemented based on a Container's state. - * - * @author Evan Villemez - * - * @deprecated since version 2.8, to be merged with ContainerInterface in 3.0. - */ -interface IntrospectableContainerInterface extends ContainerInterface -{ - /** - * Check for whether or not a service has been initialized. - * - * @param string $id - * - * @return bool true if the service has been initialized, false otherwise - */ - public function initialized($id); -} diff --git a/vendor/symfony/dependency-injection/Scope.php b/vendor/symfony/dependency-injection/Scope.php deleted file mode 100644 index b0b8ed6..0000000 --- a/vendor/symfony/dependency-injection/Scope.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\DependencyInjection; - -/** - * Scope class. - * - * @author Johannes M. Schmitt - * - * @deprecated since version 2.8, to be removed in 3.0. - */ -class Scope implements ScopeInterface -{ - private $name; - private $parentName; - - public function __construct($name, $parentName = ContainerInterface::SCOPE_CONTAINER) - { - $this->name = $name; - $this->parentName = $parentName; - } - - public function getName() - { - return $this->name; - } - - public function getParentName() - { - return $this->parentName; - } -} diff --git a/vendor/symfony/dependency-injection/ScopeInterface.php b/vendor/symfony/dependency-injection/ScopeInterface.php deleted file mode 100644 index 11b1097..0000000 --- a/vendor/symfony/dependency-injection/ScopeInterface.php +++ /dev/null @@ -1,26 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\DependencyInjection; - -/** - * Scope Interface. - * - * @author Johannes M. Schmitt - * - * @deprecated since version 2.8, to be removed in 3.0. - */ -interface ScopeInterface -{ - public function getName(); - - public function getParentName(); -} diff --git a/vendor/symfony/dependency-injection/SimpleXMLElement.php b/vendor/symfony/dependency-injection/SimpleXMLElement.php deleted file mode 100644 index bb985ac..0000000 --- a/vendor/symfony/dependency-injection/SimpleXMLElement.php +++ /dev/null @@ -1,116 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\DependencyInjection; - -@trigger_error('The '.__NAMESPACE__.'\SimpleXMLElement class is deprecated since Symfony 2.5 and will be removed in 3.0.', E_USER_DEPRECATED); - -use Symfony\Component\Config\Util\XmlUtils; -use Symfony\Component\ExpressionLanguage\Expression; - -/** - * SimpleXMLElement class. - * - * @author Fabien Potencier - * - * @deprecated since version 2.5, to be removed in 3.0. - */ -class SimpleXMLElement extends \SimpleXMLElement -{ - /** - * Converts an attribute as a PHP type. - * - * @param string $name - * - * @return mixed - */ - public function getAttributeAsPhp($name) - { - return self::phpize($this[$name]); - } - - /** - * Returns arguments as valid PHP types. - * - * @param string $name - * @param bool $lowercase - * - * @return mixed - */ - public function getArgumentsAsPhp($name, $lowercase = true) - { - $arguments = array(); - foreach ($this->$name as $arg) { - if (isset($arg['name'])) { - $arg['key'] = (string) $arg['name']; - } - $key = isset($arg['key']) ? (string) $arg['key'] : (!$arguments ? 0 : max(array_keys($arguments)) + 1); - - // parameter keys are case insensitive - if ('parameter' == $name && $lowercase) { - $key = strtolower($key); - } - - // this is used by DefinitionDecorator to overwrite a specific - // argument of the parent definition - if (isset($arg['index'])) { - $key = 'index_'.$arg['index']; - } - - switch ($arg['type']) { - case 'service': - $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE; - if (isset($arg['on-invalid']) && 'ignore' == $arg['on-invalid']) { - $invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE; - } elseif (isset($arg['on-invalid']) && 'null' == $arg['on-invalid']) { - $invalidBehavior = ContainerInterface::NULL_ON_INVALID_REFERENCE; - } - - if (isset($arg['strict'])) { - $strict = self::phpize($arg['strict']); - } else { - $strict = true; - } - - $arguments[$key] = new Reference((string) $arg['id'], $invalidBehavior, $strict); - break; - case 'expression': - $arguments[$key] = new Expression((string) $arg); - break; - case 'collection': - $arguments[$key] = $arg->getArgumentsAsPhp($name, false); - break; - case 'string': - $arguments[$key] = (string) $arg; - break; - case 'constant': - $arguments[$key] = \constant((string) $arg); - break; - default: - $arguments[$key] = self::phpize($arg); - } - } - - return $arguments; - } - - /** - * Converts an xml value to a PHP type. - * - * @param mixed $value - * - * @return mixed - */ - public static function phpize($value) - { - return XmlUtils::phpize($value); - } -} diff --git a/vendor/symfony/finder/Adapter/AbstractAdapter.php b/vendor/symfony/finder/Adapter/AbstractAdapter.php deleted file mode 100644 index 1a1647c..0000000 --- a/vendor/symfony/finder/Adapter/AbstractAdapter.php +++ /dev/null @@ -1,240 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Finder\Adapter; - -@trigger_error('The '.__NAMESPACE__.'\AbstractAdapter class is deprecated since Symfony 2.8 and will be removed in 3.0. Use directly the Finder class instead.', E_USER_DEPRECATED); - -/** - * Interface for finder engine implementations. - * - * @author Jean-François Simon - * - * @deprecated since 2.8, to be removed in 3.0. Use Finder instead. - */ -abstract class AbstractAdapter implements AdapterInterface -{ - protected $followLinks = false; - protected $mode = 0; - protected $minDepth = 0; - protected $maxDepth = PHP_INT_MAX; - protected $exclude = array(); - protected $names = array(); - protected $notNames = array(); - protected $contains = array(); - protected $notContains = array(); - protected $sizes = array(); - protected $dates = array(); - protected $filters = array(); - protected $sort = false; - protected $paths = array(); - protected $notPaths = array(); - protected $ignoreUnreadableDirs = false; - - private static $areSupported = array(); - - /** - * {@inheritdoc} - */ - public function isSupported() - { - $name = $this->getName(); - - if (!array_key_exists($name, self::$areSupported)) { - self::$areSupported[$name] = $this->canBeUsed(); - } - - return self::$areSupported[$name]; - } - - /** - * {@inheritdoc} - */ - public function setFollowLinks($followLinks) - { - $this->followLinks = $followLinks; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setMode($mode) - { - $this->mode = $mode; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setDepths(array $depths) - { - $this->minDepth = 0; - $this->maxDepth = PHP_INT_MAX; - - foreach ($depths as $comparator) { - switch ($comparator->getOperator()) { - case '>': - $this->minDepth = $comparator->getTarget() + 1; - break; - case '>=': - $this->minDepth = $comparator->getTarget(); - break; - case '<': - $this->maxDepth = $comparator->getTarget() - 1; - break; - case '<=': - $this->maxDepth = $comparator->getTarget(); - break; - default: - $this->minDepth = $this->maxDepth = $comparator->getTarget(); - } - } - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setExclude(array $exclude) - { - $this->exclude = $exclude; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setNames(array $names) - { - $this->names = $names; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setNotNames(array $notNames) - { - $this->notNames = $notNames; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setContains(array $contains) - { - $this->contains = $contains; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setNotContains(array $notContains) - { - $this->notContains = $notContains; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setSizes(array $sizes) - { - $this->sizes = $sizes; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setDates(array $dates) - { - $this->dates = $dates; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setFilters(array $filters) - { - $this->filters = $filters; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setSort($sort) - { - $this->sort = $sort; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setPath(array $paths) - { - $this->paths = $paths; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setNotPath(array $notPaths) - { - $this->notPaths = $notPaths; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function ignoreUnreadableDirs($ignore = true) - { - $this->ignoreUnreadableDirs = (bool) $ignore; - - return $this; - } - - /** - * Returns whether the adapter is supported in the current environment. - * - * This method should be implemented in all adapters. Do not implement - * isSupported in the adapters as the generic implementation provides a cache - * layer. - * - * @see isSupported() - * - * @return bool Whether the adapter is supported - */ - abstract protected function canBeUsed(); -} diff --git a/vendor/symfony/finder/Adapter/AbstractFindAdapter.php b/vendor/symfony/finder/Adapter/AbstractFindAdapter.php deleted file mode 100644 index ef45869..0000000 --- a/vendor/symfony/finder/Adapter/AbstractFindAdapter.php +++ /dev/null @@ -1,325 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Finder\Adapter; - -@trigger_error('The '.__NAMESPACE__.'\AbstractFindAdapter class is deprecated since Symfony 2.8 and will be removed in 3.0. Use directly the Finder class instead.', E_USER_DEPRECATED); - -use Symfony\Component\Finder\Comparator\DateComparator; -use Symfony\Component\Finder\Comparator\NumberComparator; -use Symfony\Component\Finder\Exception\AccessDeniedException; -use Symfony\Component\Finder\Expression\Expression; -use Symfony\Component\Finder\Iterator; -use Symfony\Component\Finder\Shell\Command; -use Symfony\Component\Finder\Shell\Shell; - -/** - * Shell engine implementation using GNU find command. - * - * @author Jean-François Simon - * - * @deprecated since 2.8, to be removed in 3.0. Use Finder instead. - */ -abstract class AbstractFindAdapter extends AbstractAdapter -{ - protected $shell; - - public function __construct() - { - $this->shell = new Shell(); - } - - /** - * {@inheritdoc} - */ - public function searchInDirectory($dir) - { - // having "/../" in path make find fail - $dir = realpath($dir); - - // searching directories containing or not containing strings leads to no result - if (Iterator\FileTypeFilterIterator::ONLY_DIRECTORIES === $this->mode && ($this->contains || $this->notContains)) { - return new Iterator\FilePathsIterator(array(), $dir); - } - - $command = Command::create(); - $find = $this->buildFindCommand($command, $dir); - - if ($this->followLinks) { - $find->add('-follow'); - } - - $find->add('-mindepth')->add($this->minDepth + 1); - - if (PHP_INT_MAX !== $this->maxDepth) { - $find->add('-maxdepth')->add($this->maxDepth + 1); - } - - if (Iterator\FileTypeFilterIterator::ONLY_DIRECTORIES === $this->mode) { - $find->add('-type d'); - } elseif (Iterator\FileTypeFilterIterator::ONLY_FILES === $this->mode) { - $find->add('-type f'); - } - - $this->buildNamesFiltering($find, $this->names); - $this->buildNamesFiltering($find, $this->notNames, true); - $this->buildPathsFiltering($find, $dir, $this->paths); - $this->buildPathsFiltering($find, $dir, $this->notPaths, true); - $this->buildSizesFiltering($find, $this->sizes); - $this->buildDatesFiltering($find, $this->dates); - - $useGrep = $this->shell->testCommand('grep') && $this->shell->testCommand('xargs'); - $useSort = \is_int($this->sort) && $this->shell->testCommand('sort') && $this->shell->testCommand('cut'); - - if ($useGrep && ($this->contains || $this->notContains)) { - $grep = $command->ins('grep'); - $this->buildContentFiltering($grep, $this->contains); - $this->buildContentFiltering($grep, $this->notContains, true); - } - - if ($useSort) { - $this->buildSorting($command, $this->sort); - } - - $command->setErrorHandler( - $this->ignoreUnreadableDirs - // If directory is unreadable and finder is set to ignore it, `stderr` is ignored. - ? function ($stderr) { } - : function ($stderr) { throw new AccessDeniedException($stderr); } - ); - - $paths = $this->shell->testCommand('uniq') ? $command->add('| uniq')->execute() : array_unique($command->execute()); - $iterator = new Iterator\FilePathsIterator($paths, $dir); - - if ($this->exclude) { - $iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $this->exclude); - } - - if (!$useGrep && ($this->contains || $this->notContains)) { - $iterator = new Iterator\FilecontentFilterIterator($iterator, $this->contains, $this->notContains); - } - - if ($this->filters) { - $iterator = new Iterator\CustomFilterIterator($iterator, $this->filters); - } - - if (!$useSort && $this->sort) { - $iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort); - $iterator = $iteratorAggregate->getIterator(); - } - - return $iterator; - } - - /** - * {@inheritdoc} - */ - protected function canBeUsed() - { - return $this->shell->testCommand('find'); - } - - /** - * @param Command $command - * @param string $dir - * - * @return Command - */ - protected function buildFindCommand(Command $command, $dir) - { - return $command - ->ins('find') - ->add('find ') - ->arg($dir) - ->add('-noleaf'); // the -noleaf option is required for filesystems that don't follow the '.' and '..' conventions - } - - /** - * @param Command $command - * @param string[] $names - * @param bool $not - */ - private function buildNamesFiltering(Command $command, array $names, $not = false) - { - if (0 === \count($names)) { - return; - } - - $command->add($not ? '-not' : null)->cmd('('); - - foreach ($names as $i => $name) { - $expr = Expression::create($name); - - // Find does not support expandable globs ("*.{a,b}" syntax). - if ($expr->isGlob() && $expr->getGlob()->isExpandable()) { - $expr = Expression::create($expr->getGlob()->toRegex(false)); - } - - // Fixes 'not search' and 'full path matching' regex problems. - // - Jokers '.' are replaced by [^/]. - // - We add '[^/]*' before and after regex (if no ^|$ flags are present). - if ($expr->isRegex()) { - $regex = $expr->getRegex(); - $regex->prepend($regex->hasStartFlag() ? '/' : '/[^/]*') - ->setStartFlag(false) - ->setStartJoker(true) - ->replaceJokers('[^/]'); - if (!$regex->hasEndFlag() || $regex->hasEndJoker()) { - $regex->setEndJoker(false)->append('[^/]*'); - } - } - - $command - ->add($i > 0 ? '-or' : null) - ->add($expr->isRegex() - ? ($expr->isCaseSensitive() ? '-regex' : '-iregex') - : ($expr->isCaseSensitive() ? '-name' : '-iname') - ) - ->arg($expr->renderPattern()); - } - - $command->cmd(')'); - } - - /** - * @param Command $command - * @param string $dir - * @param string[] $paths - * @param bool $not - */ - private function buildPathsFiltering(Command $command, $dir, array $paths, $not = false) - { - if (0 === \count($paths)) { - return; - } - - $command->add($not ? '-not' : null)->cmd('('); - - foreach ($paths as $i => $path) { - $expr = Expression::create($path); - - // Find does not support expandable globs ("*.{a,b}" syntax). - if ($expr->isGlob() && $expr->getGlob()->isExpandable()) { - $expr = Expression::create($expr->getGlob()->toRegex(false)); - } - - // Fixes 'not search' regex problems. - if ($expr->isRegex()) { - $regex = $expr->getRegex(); - $regex->prepend($regex->hasStartFlag() ? preg_quote($dir).\DIRECTORY_SEPARATOR : '.*')->setEndJoker(!$regex->hasEndFlag()); - } else { - $expr->prepend('*')->append('*'); - } - - $command - ->add($i > 0 ? '-or' : null) - ->add($expr->isRegex() - ? ($expr->isCaseSensitive() ? '-regex' : '-iregex') - : ($expr->isCaseSensitive() ? '-path' : '-ipath') - ) - ->arg($expr->renderPattern()); - } - - $command->cmd(')'); - } - - /** - * @param Command $command - * @param NumberComparator[] $sizes - */ - private function buildSizesFiltering(Command $command, array $sizes) - { - foreach ($sizes as $i => $size) { - $command->add($i > 0 ? '-and' : null); - - switch ($size->getOperator()) { - case '<=': - $command->add('-size -'.($size->getTarget() + 1).'c'); - break; - case '>=': - $command->add('-size +'.($size->getTarget() - 1).'c'); - break; - case '>': - $command->add('-size +'.$size->getTarget().'c'); - break; - case '!=': - $command->add('-size -'.$size->getTarget().'c'); - $command->add('-size +'.$size->getTarget().'c'); - break; - case '<': - default: - $command->add('-size -'.$size->getTarget().'c'); - } - } - } - - /** - * @param Command $command - * @param DateComparator[] $dates - */ - private function buildDatesFiltering(Command $command, array $dates) - { - foreach ($dates as $i => $date) { - $command->add($i > 0 ? '-and' : null); - - $mins = (int) round((time() - $date->getTarget()) / 60); - - if (0 > $mins) { - // mtime is in the future - $command->add(' -mmin -0'); - // we will have no result so we don't need to continue - return; - } - - switch ($date->getOperator()) { - case '<=': - $command->add('-mmin +'.($mins - 1)); - break; - case '>=': - $command->add('-mmin -'.($mins + 1)); - break; - case '>': - $command->add('-mmin -'.$mins); - break; - case '!=': - $command->add('-mmin +'.$mins.' -or -mmin -'.$mins); - break; - case '<': - default: - $command->add('-mmin +'.$mins); - } - } - } - - /** - * @param Command $command - * @param string $sort - * - * @throws \InvalidArgumentException - */ - private function buildSorting(Command $command, $sort) - { - $this->buildFormatSorting($command, $sort); - } - - /** - * @param Command $command - * @param string $sort - */ - abstract protected function buildFormatSorting(Command $command, $sort); - - /** - * @param Command $command - * @param array $contains - * @param bool $not - */ - abstract protected function buildContentFiltering(Command $command, array $contains, $not = false); -} diff --git a/vendor/symfony/finder/Adapter/AdapterInterface.php b/vendor/symfony/finder/Adapter/AdapterInterface.php deleted file mode 100644 index 8d8fb07..0000000 --- a/vendor/symfony/finder/Adapter/AdapterInterface.php +++ /dev/null @@ -1,124 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Finder\Adapter; - -/** - * @author Jean-François Simon - * - * @deprecated since 2.8, to be removed in 3.0. - */ -interface AdapterInterface -{ - /** - * @param bool $followLinks - * - * @return $this - */ - public function setFollowLinks($followLinks); - - /** - * @param int $mode - * - * @return $this - */ - public function setMode($mode); - - /** - * @return $this - */ - public function setExclude(array $exclude); - - /** - * @return $this - */ - public function setDepths(array $depths); - - /** - * @return $this - */ - public function setNames(array $names); - - /** - * @return $this - */ - public function setNotNames(array $notNames); - - /** - * @return $this - */ - public function setContains(array $contains); - - /** - * @return $this - */ - public function setNotContains(array $notContains); - - /** - * @return $this - */ - public function setSizes(array $sizes); - - /** - * @return $this - */ - public function setDates(array $dates); - - /** - * @return $this - */ - public function setFilters(array $filters); - - /** - * @param \Closure|int $sort - * - * @return $this - */ - public function setSort($sort); - - /** - * @return $this - */ - public function setPath(array $paths); - - /** - * @return $this - */ - public function setNotPath(array $notPaths); - - /** - * @param bool $ignore - * - * @return $this - */ - public function ignoreUnreadableDirs($ignore = true); - - /** - * @param string $dir - * - * @return \Iterator Result iterator - */ - public function searchInDirectory($dir); - - /** - * Tests adapter support for current platform. - * - * @return bool - */ - public function isSupported(); - - /** - * Returns adapter name. - * - * @return string - */ - public function getName(); -} diff --git a/vendor/symfony/finder/Adapter/BsdFindAdapter.php b/vendor/symfony/finder/Adapter/BsdFindAdapter.php deleted file mode 100644 index f6e4303..0000000 --- a/vendor/symfony/finder/Adapter/BsdFindAdapter.php +++ /dev/null @@ -1,107 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Finder\Adapter; - -@trigger_error('The '.__NAMESPACE__.'\BsdFindAdapter class is deprecated since Symfony 2.8 and will be removed in 3.0. Use directly the Finder class instead.', E_USER_DEPRECATED); - -use Symfony\Component\Finder\Expression\Expression; -use Symfony\Component\Finder\Iterator\SortableIterator; -use Symfony\Component\Finder\Shell\Command; -use Symfony\Component\Finder\Shell\Shell; - -/** - * Shell engine implementation using BSD find command. - * - * @author Jean-François Simon - * - * @deprecated since 2.8, to be removed in 3.0. Use Finder instead. - */ -class BsdFindAdapter extends AbstractFindAdapter -{ - /** - * {@inheritdoc} - */ - public function getName() - { - return 'bsd_find'; - } - - /** - * {@inheritdoc} - */ - protected function canBeUsed() - { - return \in_array($this->shell->getType(), array(Shell::TYPE_BSD, Shell::TYPE_DARWIN)) && parent::canBeUsed(); - } - - /** - * {@inheritdoc} - */ - protected function buildFormatSorting(Command $command, $sort) - { - switch ($sort) { - case SortableIterator::SORT_BY_NAME: - $command->ins('sort')->add('| sort'); - - return; - case SortableIterator::SORT_BY_TYPE: - $format = '%HT'; - break; - case SortableIterator::SORT_BY_ACCESSED_TIME: - $format = '%a'; - break; - case SortableIterator::SORT_BY_CHANGED_TIME: - $format = '%c'; - break; - case SortableIterator::SORT_BY_MODIFIED_TIME: - $format = '%m'; - break; - default: - throw new \InvalidArgumentException(sprintf('Unknown sort options: %s.', $sort)); - } - - $command - ->add('-print0 | xargs -0 stat -f') - ->arg($format.'%t%N') - ->add('| sort | cut -f 2'); - } - - /** - * {@inheritdoc} - */ - protected function buildFindCommand(Command $command, $dir) - { - parent::buildFindCommand($command, $dir)->addAtIndex('-E', 1); - - return $command; - } - - /** - * {@inheritdoc} - */ - protected function buildContentFiltering(Command $command, array $contains, $not = false) - { - foreach ($contains as $contain) { - $expr = Expression::create($contain); - - // todo: avoid forking process for each $pattern by using multiple -e options - $command - ->add('| grep -v \'^$\'') - ->add('| xargs -I{} grep -I') - ->add($expr->isCaseSensitive() ? null : '-i') - ->add($not ? '-L' : '-l') - ->add('-Ee')->arg($expr->renderPattern()) - ->add('{}') - ; - } - } -} diff --git a/vendor/symfony/finder/Adapter/GnuFindAdapter.php b/vendor/symfony/finder/Adapter/GnuFindAdapter.php deleted file mode 100644 index 140c566..0000000 --- a/vendor/symfony/finder/Adapter/GnuFindAdapter.php +++ /dev/null @@ -1,108 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Finder\Adapter; - -@trigger_error('The '.__NAMESPACE__.'\GnuFindAdapter class is deprecated since Symfony 2.8 and will be removed in 3.0. Use directly the Finder class instead.', E_USER_DEPRECATED); - -use Symfony\Component\Finder\Expression\Expression; -use Symfony\Component\Finder\Iterator\SortableIterator; -use Symfony\Component\Finder\Shell\Command; -use Symfony\Component\Finder\Shell\Shell; - -/** - * Shell engine implementation using GNU find command. - * - * @author Jean-François Simon - * - * @deprecated since 2.8, to be removed in 3.0. Use Finder instead. - */ -class GnuFindAdapter extends AbstractFindAdapter -{ - /** - * {@inheritdoc} - */ - public function getName() - { - return 'gnu_find'; - } - - /** - * {@inheritdoc} - */ - protected function buildFormatSorting(Command $command, $sort) - { - switch ($sort) { - case SortableIterator::SORT_BY_NAME: - $command->ins('sort')->add('| sort'); - - return; - case SortableIterator::SORT_BY_TYPE: - $format = '%y'; - break; - case SortableIterator::SORT_BY_ACCESSED_TIME: - $format = '%A@'; - break; - case SortableIterator::SORT_BY_CHANGED_TIME: - $format = '%C@'; - break; - case SortableIterator::SORT_BY_MODIFIED_TIME: - $format = '%T@'; - break; - default: - throw new \InvalidArgumentException(sprintf('Unknown sort options: %s.', $sort)); - } - - $command - ->get('find') - ->add('-printf') - ->arg($format.' %h/%f\\n') - ->add('| sort | cut') - ->arg('-d ') - ->arg('-f2-') - ; - } - - /** - * {@inheritdoc} - */ - protected function canBeUsed() - { - return Shell::TYPE_UNIX === $this->shell->getType() && parent::canBeUsed(); - } - - /** - * {@inheritdoc} - */ - protected function buildFindCommand(Command $command, $dir) - { - return parent::buildFindCommand($command, $dir)->add('-regextype posix-extended'); - } - - /** - * {@inheritdoc} - */ - protected function buildContentFiltering(Command $command, array $contains, $not = false) - { - foreach ($contains as $contain) { - $expr = Expression::create($contain); - - // todo: avoid forking process for each $pattern by using multiple -e options - $command - ->add('| xargs -I{} -r grep -I') - ->add($expr->isCaseSensitive() ? null : '-i') - ->add($not ? '-L' : '-l') - ->add('-Ee')->arg($expr->renderPattern()) - ->add('{}') - ; - } - } -} diff --git a/vendor/symfony/finder/Adapter/PhpAdapter.php b/vendor/symfony/finder/Adapter/PhpAdapter.php deleted file mode 100644 index c2fb66c..0000000 --- a/vendor/symfony/finder/Adapter/PhpAdapter.php +++ /dev/null @@ -1,101 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Finder\Adapter; - -@trigger_error('The '.__NAMESPACE__.'\PhpAdapter class is deprecated since Symfony 2.8 and will be removed in 3.0. Use directly the Finder class instead.', E_USER_DEPRECATED); - -use Symfony\Component\Finder\Iterator; - -/** - * PHP finder engine implementation. - * - * @author Jean-François Simon - * - * @deprecated since 2.8, to be removed in 3.0. Use Finder instead. - */ -class PhpAdapter extends AbstractAdapter -{ - /** - * {@inheritdoc} - */ - public function searchInDirectory($dir) - { - $flags = \RecursiveDirectoryIterator::SKIP_DOTS; - - if ($this->followLinks) { - $flags |= \RecursiveDirectoryIterator::FOLLOW_SYMLINKS; - } - - $iterator = new Iterator\RecursiveDirectoryIterator($dir, $flags, $this->ignoreUnreadableDirs); - - if ($this->exclude) { - $iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $this->exclude); - } - - $iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST); - - if ($this->minDepth > 0 || $this->maxDepth < PHP_INT_MAX) { - $iterator = new Iterator\DepthRangeFilterIterator($iterator, $this->minDepth, $this->maxDepth); - } - - if ($this->mode) { - $iterator = new Iterator\FileTypeFilterIterator($iterator, $this->mode); - } - - if ($this->names || $this->notNames) { - $iterator = new Iterator\FilenameFilterIterator($iterator, $this->names, $this->notNames); - } - - if ($this->contains || $this->notContains) { - $iterator = new Iterator\FilecontentFilterIterator($iterator, $this->contains, $this->notContains); - } - - if ($this->sizes) { - $iterator = new Iterator\SizeRangeFilterIterator($iterator, $this->sizes); - } - - if ($this->dates) { - $iterator = new Iterator\DateRangeFilterIterator($iterator, $this->dates); - } - - if ($this->filters) { - $iterator = new Iterator\CustomFilterIterator($iterator, $this->filters); - } - - if ($this->paths || $this->notPaths) { - $iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $this->notPaths); - } - - if ($this->sort) { - $iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort); - $iterator = $iteratorAggregate->getIterator(); - } - - return $iterator; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'php'; - } - - /** - * {@inheritdoc} - */ - protected function canBeUsed() - { - return true; - } -} diff --git a/vendor/symfony/finder/Exception/AdapterFailureException.php b/vendor/symfony/finder/Exception/AdapterFailureException.php deleted file mode 100644 index 594940a..0000000 --- a/vendor/symfony/finder/Exception/AdapterFailureException.php +++ /dev/null @@ -1,47 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Finder\Exception; - -@trigger_error('The '.__NAMESPACE__.'\AdapterFailureException class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED); - -use Symfony\Component\Finder\Adapter\AdapterInterface; - -/** - * Base exception for all adapter failures. - * - * @author Jean-François Simon - * - * @deprecated since 2.8, to be removed in 3.0. - */ -class AdapterFailureException extends \RuntimeException implements ExceptionInterface -{ - private $adapter; - - /** - * @param AdapterInterface $adapter - * @param string|null $message - * @param \Exception|null $previous - */ - public function __construct(AdapterInterface $adapter, $message = null, \Exception $previous = null) - { - $this->adapter = $adapter; - parent::__construct($message ?: 'Search failed with "'.$adapter->getName().'" adapter.', $previous); - } - - /** - * {@inheritdoc} - */ - public function getAdapter() - { - return $this->adapter; - } -} diff --git a/vendor/symfony/finder/Exception/OperationNotPermitedException.php b/vendor/symfony/finder/Exception/OperationNotPermitedException.php deleted file mode 100644 index 4c66858..0000000 --- a/vendor/symfony/finder/Exception/OperationNotPermitedException.php +++ /dev/null @@ -1,23 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Finder\Exception; - -@trigger_error('The '.__NAMESPACE__.'\OperationNotPermitedException class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED); - -/** - * @author Jean-François Simon - * - * @deprecated since 2.8, to be removed in 3.0. - */ -class OperationNotPermitedException extends AdapterFailureException -{ -} diff --git a/vendor/symfony/finder/Exception/ShellCommandFailureException.php b/vendor/symfony/finder/Exception/ShellCommandFailureException.php deleted file mode 100644 index db85e68..0000000 --- a/vendor/symfony/finder/Exception/ShellCommandFailureException.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Finder\Exception; - -@trigger_error('The '.__NAMESPACE__.'\ShellCommandFailureException class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED); - -use Symfony\Component\Finder\Adapter\AdapterInterface; -use Symfony\Component\Finder\Shell\Command; - -/** - * @author Jean-François Simon - * - * @deprecated since 2.8, to be removed in 3.0. - */ -class ShellCommandFailureException extends AdapterFailureException -{ - private $command; - - public function __construct(AdapterInterface $adapter, Command $command, \Exception $previous = null) - { - $this->command = $command; - parent::__construct($adapter, 'Shell command failed: "'.$command->join().'".', $previous); - } - - /** - * @return Command - */ - public function getCommand() - { - return $this->command; - } -} diff --git a/vendor/symfony/finder/Expression/Expression.php b/vendor/symfony/finder/Expression/Expression.php deleted file mode 100644 index e83c771..0000000 --- a/vendor/symfony/finder/Expression/Expression.php +++ /dev/null @@ -1,148 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Finder\Expression; - -@trigger_error('The '.__NAMESPACE__.'\Expression class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED); - -/** - * @author Jean-François Simon - */ -class Expression implements ValueInterface -{ - const TYPE_REGEX = 1; - const TYPE_GLOB = 2; - - /** - * @var ValueInterface - */ - private $value; - - /** - * @param string $expr - * - * @return self - */ - public static function create($expr) - { - return new self($expr); - } - - /** - * @param string $expr - */ - public function __construct($expr) - { - try { - $this->value = Regex::create($expr); - } catch (\InvalidArgumentException $e) { - $this->value = new Glob($expr); - } - } - - /** - * @return string - */ - public function __toString() - { - return $this->render(); - } - - /** - * {@inheritdoc} - */ - public function render() - { - return $this->value->render(); - } - - /** - * {@inheritdoc} - */ - public function renderPattern() - { - return $this->value->renderPattern(); - } - - /** - * @return bool - */ - public function isCaseSensitive() - { - return $this->value->isCaseSensitive(); - } - - /** - * @return int - */ - public function getType() - { - return $this->value->getType(); - } - - /** - * {@inheritdoc} - */ - public function prepend($expr) - { - $this->value->prepend($expr); - - return $this; - } - - /** - * {@inheritdoc} - */ - public function append($expr) - { - $this->value->append($expr); - - return $this; - } - - /** - * @return bool - */ - public function isRegex() - { - return self::TYPE_REGEX === $this->value->getType(); - } - - /** - * @return bool - */ - public function isGlob() - { - return self::TYPE_GLOB === $this->value->getType(); - } - - /** - * @return Glob - * - * @throws \LogicException - */ - public function getGlob() - { - if (self::TYPE_GLOB !== $this->value->getType()) { - throw new \LogicException('Regex can\'t be transformed to glob.'); - } - - return $this->value; - } - - /** - * @return Regex - */ - public function getRegex() - { - return self::TYPE_REGEX === $this->value->getType() ? $this->value : $this->value->toRegex(); - } -} diff --git a/vendor/symfony/finder/Expression/Glob.php b/vendor/symfony/finder/Expression/Glob.php deleted file mode 100644 index e80578e..0000000 --- a/vendor/symfony/finder/Expression/Glob.php +++ /dev/null @@ -1,108 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Finder\Expression; - -@trigger_error('The '.__NAMESPACE__.'\Glob class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED); - -use Symfony\Component\Finder\Glob as FinderGlob; - -/** - * @author Jean-François Simon - */ -class Glob implements ValueInterface -{ - private $pattern; - - /** - * @param string $pattern - */ - public function __construct($pattern) - { - $this->pattern = $pattern; - } - - /** - * {@inheritdoc} - */ - public function render() - { - return $this->pattern; - } - - /** - * {@inheritdoc} - */ - public function renderPattern() - { - return $this->pattern; - } - - /** - * {@inheritdoc} - */ - public function getType() - { - return Expression::TYPE_GLOB; - } - - /** - * {@inheritdoc} - */ - public function isCaseSensitive() - { - return true; - } - - /** - * {@inheritdoc} - */ - public function prepend($expr) - { - $this->pattern = $expr.$this->pattern; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function append($expr) - { - $this->pattern .= $expr; - - return $this; - } - - /** - * Tests if glob is expandable ("*.{a,b}" syntax). - * - * @return bool - */ - public function isExpandable() - { - return false !== strpos($this->pattern, '{') - && false !== strpos($this->pattern, '}'); - } - - /** - * @param bool $strictLeadingDot - * @param bool $strictWildcardSlash - * - * @return Regex - */ - public function toRegex($strictLeadingDot = true, $strictWildcardSlash = true) - { - $regex = FinderGlob::toRegex($this->pattern, $strictLeadingDot, $strictWildcardSlash, ''); - - return new Regex($regex); - } -} diff --git a/vendor/symfony/finder/Expression/Regex.php b/vendor/symfony/finder/Expression/Regex.php deleted file mode 100644 index 2f1ab3d..0000000 --- a/vendor/symfony/finder/Expression/Regex.php +++ /dev/null @@ -1,321 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Finder\Expression; - -@trigger_error('The '.__NAMESPACE__.'\Regex class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED); - -/** - * @author Jean-François Simon - */ -class Regex implements ValueInterface -{ - const START_FLAG = '^'; - const END_FLAG = '$'; - const BOUNDARY = '~'; - const JOKER = '.*'; - const ESCAPING = '\\'; - - /** - * @var string - */ - private $pattern; - - /** - * @var string - */ - private $options; - - /** - * @var bool - */ - private $startFlag; - - /** - * @var bool - */ - private $endFlag; - - /** - * @var bool - */ - private $startJoker; - - /** - * @var bool - */ - private $endJoker; - - /** - * @param string $expr - * - * @return self - * - * @throws \InvalidArgumentException - */ - public static function create($expr) - { - if (preg_match('/^(.{3,}?)([imsxuADU]*)$/', $expr, $m)) { - $start = substr($m[1], 0, 1); - $end = substr($m[1], -1); - - if ( - ($start === $end && !preg_match('/[*?[:alnum:] \\\\]/', $start)) - || ('{' === $start && '}' === $end) - || ('(' === $start && ')' === $end) - ) { - return new self(substr($m[1], 1, -1), $m[2], $end); - } - } - - throw new \InvalidArgumentException('Given expression is not a regex.'); - } - - /** - * @param string $pattern - * @param string $options - * @param string $delimiter - */ - public function __construct($pattern, $options = '', $delimiter = null) - { - if (null !== $delimiter) { - // removes delimiter escaping - $pattern = str_replace('\\'.$delimiter, $delimiter, $pattern); - } - - $this->parsePattern($pattern); - $this->options = $options; - } - - /** - * @return string - */ - public function __toString() - { - return $this->render(); - } - - /** - * {@inheritdoc} - */ - public function render() - { - return self::BOUNDARY - .$this->renderPattern() - .self::BOUNDARY - .$this->options; - } - - /** - * {@inheritdoc} - */ - public function renderPattern() - { - return ($this->startFlag ? self::START_FLAG : '') - .($this->startJoker ? self::JOKER : '') - .str_replace(self::BOUNDARY, '\\'.self::BOUNDARY, $this->pattern) - .($this->endJoker ? self::JOKER : '') - .($this->endFlag ? self::END_FLAG : ''); - } - - /** - * {@inheritdoc} - */ - public function isCaseSensitive() - { - return !$this->hasOption('i'); - } - - /** - * {@inheritdoc} - */ - public function getType() - { - return Expression::TYPE_REGEX; - } - - /** - * {@inheritdoc} - */ - public function prepend($expr) - { - $this->pattern = $expr.$this->pattern; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function append($expr) - { - $this->pattern .= $expr; - - return $this; - } - - /** - * @param string $option - * - * @return bool - */ - public function hasOption($option) - { - return false !== strpos($this->options, $option); - } - - /** - * @param string $option - * - * @return $this - */ - public function addOption($option) - { - if (!$this->hasOption($option)) { - $this->options .= $option; - } - - return $this; - } - - /** - * @param string $option - * - * @return $this - */ - public function removeOption($option) - { - $this->options = str_replace($option, '', $this->options); - - return $this; - } - - /** - * @param bool $startFlag - * - * @return $this - */ - public function setStartFlag($startFlag) - { - $this->startFlag = $startFlag; - - return $this; - } - - /** - * @return bool - */ - public function hasStartFlag() - { - return $this->startFlag; - } - - /** - * @param bool $endFlag - * - * @return $this - */ - public function setEndFlag($endFlag) - { - $this->endFlag = (bool) $endFlag; - - return $this; - } - - /** - * @return bool - */ - public function hasEndFlag() - { - return $this->endFlag; - } - - /** - * @param bool $startJoker - * - * @return $this - */ - public function setStartJoker($startJoker) - { - $this->startJoker = $startJoker; - - return $this; - } - - /** - * @return bool - */ - public function hasStartJoker() - { - return $this->startJoker; - } - - /** - * @param bool $endJoker - * - * @return $this - */ - public function setEndJoker($endJoker) - { - $this->endJoker = (bool) $endJoker; - - return $this; - } - - /** - * @return bool - */ - public function hasEndJoker() - { - return $this->endJoker; - } - - /** - * @return $this - */ - public function replaceJokers($replacement) - { - $replace = function ($subject) use ($replacement) { - $subject = $subject[0]; - $replace = 0 === substr_count($subject, '\\') % 2; - - return $replace ? str_replace('.', $replacement, $subject) : $subject; - }; - - $this->pattern = preg_replace_callback('~[\\\\]*\\.~', $replace, $this->pattern); - - return $this; - } - - /** - * @param string $pattern - */ - private function parsePattern($pattern) - { - if ($this->startFlag = self::START_FLAG === substr($pattern, 0, 1)) { - $pattern = substr($pattern, 1); - } - - if ($this->startJoker = self::JOKER === substr($pattern, 0, 2)) { - $pattern = substr($pattern, 2); - } - - if ($this->endFlag = (self::END_FLAG === substr($pattern, -1) && self::ESCAPING !== substr($pattern, -2, -1))) { - $pattern = substr($pattern, 0, -1); - } - - if ($this->endJoker = (self::JOKER === substr($pattern, -2) && self::ESCAPING !== substr($pattern, -3, -2))) { - $pattern = substr($pattern, 0, -2); - } - - $this->pattern = $pattern; - } -} diff --git a/vendor/symfony/finder/Expression/ValueInterface.php b/vendor/symfony/finder/Expression/ValueInterface.php deleted file mode 100644 index 08ede14..0000000 --- a/vendor/symfony/finder/Expression/ValueInterface.php +++ /dev/null @@ -1,62 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Finder\Expression; - -@trigger_error('The '.__NAMESPACE__.'\ValueInterface interface is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED); - -/** - * @author Jean-François Simon - */ -interface ValueInterface -{ - /** - * Renders string representation of expression. - * - * @return string - */ - public function render(); - - /** - * Renders string representation of pattern. - * - * @return string - */ - public function renderPattern(); - - /** - * Returns value case sensitivity. - * - * @return bool - */ - public function isCaseSensitive(); - - /** - * Returns expression type. - * - * @return int - */ - public function getType(); - - /** - * @param string $expr - * - * @return $this - */ - public function prepend($expr); - - /** - * @param string $expr - * - * @return $this - */ - public function append($expr); -} diff --git a/vendor/symfony/finder/Iterator/FilePathsIterator.php b/vendor/symfony/finder/Iterator/FilePathsIterator.php deleted file mode 100644 index 9c4e5c4..0000000 --- a/vendor/symfony/finder/Iterator/FilePathsIterator.php +++ /dev/null @@ -1,135 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Finder\Iterator; - -@trigger_error('The '.__NAMESPACE__.'\FilePathsIterator class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED); - -use Symfony\Component\Finder\SplFileInfo; - -/** - * Iterate over shell command result. - * - * @author Jean-François Simon - * - * @deprecated since 2.8, to be removed in 3.0. - */ -class FilePathsIterator extends \ArrayIterator -{ - /** - * @var string - */ - private $baseDir; - - /** - * @var int - */ - private $baseDirLength; - - /** - * @var string - */ - private $subPath; - - /** - * @var string - */ - private $subPathname; - - /** - * @var SplFileInfo - */ - private $current; - - /** - * @param array $paths List of paths returned by shell command - * @param string $baseDir Base dir for relative path building - */ - public function __construct(array $paths, $baseDir) - { - $this->baseDir = $baseDir; - $this->baseDirLength = \strlen($baseDir); - - parent::__construct($paths); - } - - /** - * @param string $name - * @param array $arguments - * - * @return mixed - */ - public function __call($name, array $arguments) - { - return \call_user_func_array(array($this->current(), $name), $arguments); - } - - /** - * Return an instance of SplFileInfo with support for relative paths. - * - * @return SplFileInfo File information - */ - public function current() - { - return $this->current; - } - - /** - * @return string - */ - public function key() - { - return $this->current->getPathname(); - } - - public function next() - { - parent::next(); - $this->buildProperties(); - } - - public function rewind() - { - parent::rewind(); - $this->buildProperties(); - } - - /** - * @return string - */ - public function getSubPath() - { - return $this->subPath; - } - - /** - * @return string - */ - public function getSubPathname() - { - return $this->subPathname; - } - - private function buildProperties() - { - $absolutePath = parent::current(); - - if ($this->baseDir === substr($absolutePath, 0, $this->baseDirLength)) { - $this->subPathname = ltrim(substr($absolutePath, $this->baseDirLength), '/\\'); - $dir = \dirname($this->subPathname); - $this->subPath = '.' === $dir ? '' : $dir; - } else { - $this->subPath = $this->subPathname = ''; - } - - $this->current = new SplFileInfo(parent::current(), $this->subPath, $this->subPathname); - } -} diff --git a/vendor/symfony/finder/Shell/Command.php b/vendor/symfony/finder/Shell/Command.php deleted file mode 100644 index 8219078..0000000 --- a/vendor/symfony/finder/Shell/Command.php +++ /dev/null @@ -1,278 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Finder\Shell; - -@trigger_error('The '.__NAMESPACE__.'\Command class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED); - -/** - * @author Jean-François Simon - * - * @deprecated since 2.8, to be removed in 3.0. - */ -class Command -{ - private $parent; - private $bits = array(); - private $labels = array(); - - /** - * @var \Closure|null - */ - private $errorHandler; - - public function __construct(Command $parent = null) - { - $this->parent = $parent; - } - - /** - * Returns command as string. - * - * @return string - */ - public function __toString() - { - return $this->join(); - } - - /** - * Creates a new Command instance. - * - * @return self - */ - public static function create(Command $parent = null) - { - return new self($parent); - } - - /** - * Escapes special chars from input. - * - * @param string $input A string to escape - * - * @return string The escaped string - */ - public static function escape($input) - { - return escapeshellcmd($input); - } - - /** - * Quotes input. - * - * @param string $input An argument string - * - * @return string The quoted string - */ - public static function quote($input) - { - return escapeshellarg($input); - } - - /** - * Appends a string or a Command instance. - * - * @param string|Command $bit - * - * @return $this - */ - public function add($bit) - { - $this->bits[] = $bit; - - return $this; - } - - /** - * Prepends a string or a command instance. - * - * @param string|Command $bit - * - * @return $this - */ - public function top($bit) - { - array_unshift($this->bits, $bit); - - foreach ($this->labels as $label => $index) { - ++$this->labels[$label]; - } - - return $this; - } - - /** - * Appends an argument, will be quoted. - * - * @param string $arg - * - * @return $this - */ - public function arg($arg) - { - $this->bits[] = self::quote($arg); - - return $this; - } - - /** - * Appends escaped special command chars. - * - * @param string $esc - * - * @return $this - */ - public function cmd($esc) - { - $this->bits[] = self::escape($esc); - - return $this; - } - - /** - * Inserts a labeled command to feed later. - * - * @param string $label The unique label - * - * @return self|string - * - * @throws \RuntimeException If label already exists - */ - public function ins($label) - { - if (isset($this->labels[$label])) { - throw new \RuntimeException(sprintf('Label "%s" already exists.', $label)); - } - - $this->bits[] = self::create($this); - $this->labels[$label] = \count($this->bits) - 1; - - return $this->bits[$this->labels[$label]]; - } - - /** - * Retrieves a previously labeled command. - * - * @param string $label - * - * @return self|string - * - * @throws \RuntimeException - */ - public function get($label) - { - if (!isset($this->labels[$label])) { - throw new \RuntimeException(sprintf('Label "%s" does not exist.', $label)); - } - - return $this->bits[$this->labels[$label]]; - } - - /** - * Returns parent command (if any). - * - * @return self - * - * @throws \RuntimeException If command has no parent - */ - public function end() - { - if (null === $this->parent) { - throw new \RuntimeException('Calling end on root command doesn\'t make sense.'); - } - - return $this->parent; - } - - /** - * Counts bits stored in command. - * - * @return int The bits count - */ - public function length() - { - return \count($this->bits); - } - - /** - * @return $this - */ - public function setErrorHandler(\Closure $errorHandler) - { - $this->errorHandler = $errorHandler; - - return $this; - } - - /** - * @return \Closure|null - */ - public function getErrorHandler() - { - return $this->errorHandler; - } - - /** - * Executes current command. - * - * @return array The command result - * - * @throws \RuntimeException - */ - public function execute() - { - if (null === $errorHandler = $this->errorHandler) { - exec($this->join(), $output); - } else { - $process = proc_open($this->join(), array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w')), $pipes); - $output = preg_split('~(\r\n|\r|\n)~', stream_get_contents($pipes[1]), -1, PREG_SPLIT_NO_EMPTY); - - if ($error = stream_get_contents($pipes[2])) { - $errorHandler($error); - } - - proc_close($process); - } - - return $output ?: array(); - } - - /** - * Joins bits. - * - * @return string - */ - public function join() - { - return implode(' ', array_filter( - array_map(function ($bit) { - return $bit instanceof Command ? $bit->join() : ($bit ?: null); - }, $this->bits), - function ($bit) { return null !== $bit; } - )); - } - - /** - * Insert a string or a Command instance before the bit at given position $index (index starts from 0). - * - * @param string|Command $bit - * @param int $index - * - * @return $this - */ - public function addAtIndex($bit, $index) - { - array_splice($this->bits, $index, 0, $bit instanceof self ? array($bit) : $bit); - - return $this; - } -} diff --git a/vendor/symfony/finder/Shell/Shell.php b/vendor/symfony/finder/Shell/Shell.php deleted file mode 100644 index fa6ca4b..0000000 --- a/vendor/symfony/finder/Shell/Shell.php +++ /dev/null @@ -1,101 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Finder\Shell; - -@trigger_error('The '.__NAMESPACE__.'\Shell class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED); - -/** - * @author Jean-François Simon - * - * @deprecated since 2.8, to be removed in 3.0. - */ -class Shell -{ - const TYPE_UNIX = 1; - const TYPE_DARWIN = 2; - const TYPE_CYGWIN = 3; - const TYPE_WINDOWS = 4; - const TYPE_BSD = 5; - - /** - * @var string|null - */ - private $type; - - /** - * Returns guessed OS type. - * - * @return int - */ - public function getType() - { - if (null === $this->type) { - $this->type = $this->guessType(); - } - - return $this->type; - } - - /** - * Tests if a command is available. - * - * @param string $command - * - * @return bool - */ - public function testCommand($command) - { - if (!\function_exists('exec')) { - return false; - } - - // todo: find a better way (command could not be available) - $testCommand = 'which '; - if (self::TYPE_WINDOWS === $this->type) { - $testCommand = 'where '; - } - - $command = escapeshellcmd($command); - - exec($testCommand.$command, $output, $code); - - return 0 === $code && \count($output) > 0; - } - - /** - * Guesses OS type. - * - * @return int - */ - private function guessType() - { - $os = strtolower(PHP_OS); - - if (false !== strpos($os, 'cygwin')) { - return self::TYPE_CYGWIN; - } - - if (false !== strpos($os, 'darwin')) { - return self::TYPE_DARWIN; - } - - if (false !== strpos($os, 'bsd')) { - return self::TYPE_BSD; - } - - if (0 === strpos($os, 'win')) { - return self::TYPE_WINDOWS; - } - - return self::TYPE_UNIX; - } -} diff --git a/vendor/symfony/http-foundation/Session/Storage/Handler/LegacyPdoSessionHandler.php b/vendor/symfony/http-foundation/Session/Storage/Handler/LegacyPdoSessionHandler.php deleted file mode 100644 index ea11d60..0000000 --- a/vendor/symfony/http-foundation/Session/Storage/Handler/LegacyPdoSessionHandler.php +++ /dev/null @@ -1,268 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; - -@trigger_error('The '.__NAMESPACE__.'\LegacyPdoSessionHandler class is deprecated since Symfony 2.6 and will be removed in 3.0. Use the Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler class instead.', E_USER_DEPRECATED); - -/** - * Session handler using a PDO connection to read and write data. - * - * Session data is a binary string that can contain non-printable characters like the null byte. - * For this reason this handler base64 encodes the data to be able to save it in a character column. - * - * This version of the PdoSessionHandler does NOT implement locking. So concurrent requests to the - * same session can result in data loss due to race conditions. - * - * @author Fabien Potencier - * @author Michael Williams - * @author Tobias Schultze - * - * @deprecated since version 2.6, to be removed in 3.0. Use - * {@link PdoSessionHandler} instead. - */ -class LegacyPdoSessionHandler implements \SessionHandlerInterface -{ - private $pdo; - - /** - * @var string Table name - */ - private $table; - - /** - * @var string Column for session id - */ - private $idCol; - - /** - * @var string Column for session data - */ - private $dataCol; - - /** - * @var string Column for timestamp - */ - private $timeCol; - - /** - * Constructor. - * - * List of available options: - * * db_table: The name of the table [required] - * * db_id_col: The column where to store the session id [default: sess_id] - * * db_data_col: The column where to store the session data [default: sess_data] - * * db_time_col: The column where to store the timestamp [default: sess_time] - * - * @param \PDO $pdo A \PDO instance - * @param array $dbOptions An associative array of DB options - * - * @throws \InvalidArgumentException When "db_table" option is not provided - */ - public function __construct(\PDO $pdo, array $dbOptions = array()) - { - if (!array_key_exists('db_table', $dbOptions)) { - throw new \InvalidArgumentException('You must provide the "db_table" option for a PdoSessionStorage.'); - } - if (\PDO::ERRMODE_EXCEPTION !== $pdo->getAttribute(\PDO::ATTR_ERRMODE)) { - throw new \InvalidArgumentException(sprintf('"%s" requires PDO error mode attribute be set to throw Exceptions (i.e. $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION))', __CLASS__)); - } - - $this->pdo = $pdo; - $dbOptions = array_merge(array( - 'db_id_col' => 'sess_id', - 'db_data_col' => 'sess_data', - 'db_time_col' => 'sess_time', - ), $dbOptions); - - $this->table = $dbOptions['db_table']; - $this->idCol = $dbOptions['db_id_col']; - $this->dataCol = $dbOptions['db_data_col']; - $this->timeCol = $dbOptions['db_time_col']; - } - - /** - * {@inheritdoc} - */ - public function open($savePath, $sessionName) - { - return true; - } - - /** - * {@inheritdoc} - */ - public function close() - { - return true; - } - - /** - * {@inheritdoc} - */ - public function destroy($sessionId) - { - // delete the record associated with this id - $sql = "DELETE FROM $this->table WHERE $this->idCol = :id"; - - try { - $stmt = $this->pdo->prepare($sql); - $stmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); - $stmt->execute(); - } catch (\PDOException $e) { - throw new \RuntimeException(sprintf('PDOException was thrown when trying to delete a session: %s', $e->getMessage()), 0, $e); - } - - return true; - } - - /** - * {@inheritdoc} - */ - public function gc($maxlifetime) - { - // delete the session records that have expired - $sql = "DELETE FROM $this->table WHERE $this->timeCol < :time"; - - try { - $stmt = $this->pdo->prepare($sql); - $stmt->bindValue(':time', time() - $maxlifetime, \PDO::PARAM_INT); - $stmt->execute(); - } catch (\PDOException $e) { - throw new \RuntimeException(sprintf('PDOException was thrown when trying to delete expired sessions: %s', $e->getMessage()), 0, $e); - } - - return true; - } - - /** - * {@inheritdoc} - */ - public function read($sessionId) - { - $sql = "SELECT $this->dataCol FROM $this->table WHERE $this->idCol = :id"; - - try { - $stmt = $this->pdo->prepare($sql); - $stmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); - $stmt->execute(); - - // We use fetchAll instead of fetchColumn to make sure the DB cursor gets closed - $sessionRows = $stmt->fetchAll(\PDO::FETCH_NUM); - - if ($sessionRows) { - return base64_decode($sessionRows[0][0]); - } - - return ''; - } catch (\PDOException $e) { - throw new \RuntimeException(sprintf('PDOException was thrown when trying to read the session data: %s', $e->getMessage()), 0, $e); - } - } - - /** - * {@inheritdoc} - */ - public function write($sessionId, $data) - { - $encoded = base64_encode($data); - - try { - // We use a single MERGE SQL query when supported by the database. - $mergeSql = $this->getMergeSql(); - - if (null !== $mergeSql) { - $mergeStmt = $this->pdo->prepare($mergeSql); - $mergeStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); - $mergeStmt->bindParam(':data', $encoded, \PDO::PARAM_STR); - $mergeStmt->bindValue(':time', time(), \PDO::PARAM_INT); - $mergeStmt->execute(); - - return true; - } - - $updateStmt = $this->pdo->prepare( - "UPDATE $this->table SET $this->dataCol = :data, $this->timeCol = :time WHERE $this->idCol = :id" - ); - $updateStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); - $updateStmt->bindParam(':data', $encoded, \PDO::PARAM_STR); - $updateStmt->bindValue(':time', time(), \PDO::PARAM_INT); - $updateStmt->execute(); - - // When MERGE is not supported, like in Postgres, we have to use this approach that can result in - // duplicate key errors when the same session is written simultaneously. We can just catch such an - // error and re-execute the update. This is similar to a serializable transaction with retry logic - // on serialization failures but without the overhead and without possible false positives due to - // longer gap locking. - if (!$updateStmt->rowCount()) { - try { - $insertStmt = $this->pdo->prepare( - "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time)" - ); - $insertStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); - $insertStmt->bindParam(':data', $encoded, \PDO::PARAM_STR); - $insertStmt->bindValue(':time', time(), \PDO::PARAM_INT); - $insertStmt->execute(); - } catch (\PDOException $e) { - // Handle integrity violation SQLSTATE 23000 (or a subclass like 23505 in Postgres) for duplicate keys - if (0 === strpos($e->getCode(), '23')) { - $updateStmt->execute(); - } else { - throw $e; - } - } - } - } catch (\PDOException $e) { - throw new \RuntimeException(sprintf('PDOException was thrown when trying to write the session data: %s', $e->getMessage()), 0, $e); - } - - return true; - } - - /** - * Returns a merge/upsert (i.e. insert or update) SQL query when supported by the database. - * - * @return string|null The SQL string or null when not supported - */ - private function getMergeSql() - { - $driver = $this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME); - - switch ($driver) { - case 'mysql': - return "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) ". - "ON DUPLICATE KEY UPDATE $this->dataCol = VALUES($this->dataCol), $this->timeCol = VALUES($this->timeCol)"; - case 'oci': - // DUAL is Oracle specific dummy table - return "MERGE INTO $this->table USING DUAL ON ($this->idCol = :id) ". - "WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) ". - "WHEN MATCHED THEN UPDATE SET $this->dataCol = :data, $this->timeCol = :time"; - case 'sqlsrv' === $driver && version_compare($this->pdo->getAttribute(\PDO::ATTR_SERVER_VERSION), '10', '>='): - // MERGE is only available since SQL Server 2008 and must be terminated by semicolon - // It also requires HOLDLOCK according to http://weblogs.sqlteam.com/dang/archive/2009/01/31/UPSERT-Race-Condition-With-MERGE.aspx - return "MERGE INTO $this->table WITH (HOLDLOCK) USING (SELECT 1 AS dummy) AS src ON ($this->idCol = :id) ". - "WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) ". - "WHEN MATCHED THEN UPDATE SET $this->dataCol = :data, $this->timeCol = :time;"; - case 'sqlite': - return "INSERT OR REPLACE INTO $this->table ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time)"; - } - } - - /** - * Return a PDO instance. - * - * @return \PDO - */ - protected function getConnection() - { - return $this->pdo; - } -} diff --git a/vendor/symfony/http-kernel/Debug/ErrorHandler.php b/vendor/symfony/http-kernel/Debug/ErrorHandler.php deleted file mode 100644 index a9c0178..0000000 --- a/vendor/symfony/http-kernel/Debug/ErrorHandler.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Debug; - -@trigger_error('The '.__NAMESPACE__.'\ErrorHandler class is deprecated since Symfony 2.3 and will be removed in 3.0. Use the Symfony\Component\Debug\ErrorHandler class instead.', E_USER_DEPRECATED); - -use Symfony\Component\Debug\ErrorHandler as DebugErrorHandler; - -/** - * ErrorHandler. - * - * @author Fabien Potencier - * - * @deprecated since version 2.3, to be removed in 3.0. Use the same class from the Debug component instead. - */ -class ErrorHandler extends DebugErrorHandler -{ -} diff --git a/vendor/symfony/http-kernel/Debug/ExceptionHandler.php b/vendor/symfony/http-kernel/Debug/ExceptionHandler.php deleted file mode 100644 index 7a8955d..0000000 --- a/vendor/symfony/http-kernel/Debug/ExceptionHandler.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Debug; - -@trigger_error('The '.__NAMESPACE__.'\ExceptionHandler class is deprecated since Symfony 2.3 and will be removed in 3.0. Use the Symfony\Component\Debug\ExceptionHandler class instead.', E_USER_DEPRECATED); - -use Symfony\Component\Debug\ExceptionHandler as DebugExceptionHandler; - -/** - * ExceptionHandler converts an exception to a Response object. - * - * @author Fabien Potencier - * - * @deprecated since version 2.3, to be removed in 3.0. Use the same class from the Debug component instead. - */ -class ExceptionHandler extends DebugExceptionHandler -{ -} diff --git a/vendor/symfony/http-kernel/DependencyInjection/ContainerAwareHttpKernel.php b/vendor/symfony/http-kernel/DependencyInjection/ContainerAwareHttpKernel.php deleted file mode 100644 index b1db5f3..0000000 --- a/vendor/symfony/http-kernel/DependencyInjection/ContainerAwareHttpKernel.php +++ /dev/null @@ -1,85 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DependencyInjection; - -use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\DependencyInjection\Scope; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface; -use Symfony\Component\HttpKernel\HttpKernel; -use Symfony\Component\HttpKernel\HttpKernelInterface; - -/** - * Adds a managed request scope. - * - * @author Fabien Potencier - * @author Johannes M. Schmitt - * - * @deprecated since version 2.7, to be removed in 3.0. - */ -class ContainerAwareHttpKernel extends HttpKernel -{ - protected $container; - - /** - * @param EventDispatcherInterface $dispatcher An EventDispatcherInterface instance - * @param ContainerInterface $container A ContainerInterface instance - * @param ControllerResolverInterface $controllerResolver A ControllerResolverInterface instance - * @param RequestStack $requestStack A stack for master/sub requests - * @param bool $triggerDeprecation Whether or not to trigger the deprecation warning for the ContainerAwareHttpKernel - */ - public function __construct(EventDispatcherInterface $dispatcher, ContainerInterface $container, ControllerResolverInterface $controllerResolver, RequestStack $requestStack = null, $triggerDeprecation = true) - { - parent::__construct($dispatcher, $controllerResolver, $requestStack); - - if ($triggerDeprecation) { - @trigger_error('The '.__CLASS__.' class is deprecated since Symfony 2.7 and will be removed in 3.0. Use the Symfony\Component\HttpKernel\HttpKernel class instead.', E_USER_DEPRECATED); - } - - $this->container = $container; - - // the request scope might have been created before (see FrameworkBundle) - if (!$container->hasScope('request')) { - $container->addScope(new Scope('request')); - } - } - - /** - * {@inheritdoc} - */ - public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true) - { - $this->container->enterScope('request'); - $this->container->set('request', $request, 'request'); - - try { - $response = parent::handle($request, $type, $catch); - } catch (\Exception $e) { - $this->container->set('request', null, 'request'); - $this->container->leaveScope('request'); - - throw $e; - } catch (\Throwable $e) { - $this->container->set('request', null, 'request'); - $this->container->leaveScope('request'); - - throw $e; - } - - $this->container->set('request', null, 'request'); - $this->container->leaveScope('request'); - - return $response; - } -} diff --git a/vendor/symfony/http-kernel/DependencyInjection/RegisterListenersPass.php b/vendor/symfony/http-kernel/DependencyInjection/RegisterListenersPass.php deleted file mode 100644 index 06a2e40..0000000 --- a/vendor/symfony/http-kernel/DependencyInjection/RegisterListenersPass.php +++ /dev/null @@ -1,25 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DependencyInjection; - -@trigger_error('The '.__NAMESPACE__.'\RegisterListenersPass is deprecated since Symfony 2.5 and will be removed in 3.0. Use the Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass class instead.', E_USER_DEPRECATED); - -use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass as BaseRegisterListenersPass; - -/** - * Compiler pass to register tagged services for an event dispatcher. - * - * @deprecated since version 2.5, to be removed in 3.0. Use the Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass class instead. - */ -class RegisterListenersPass extends BaseRegisterListenersPass -{ -} diff --git a/vendor/symfony/http-kernel/EventListener/ErrorsLoggerListener.php b/vendor/symfony/http-kernel/EventListener/ErrorsLoggerListener.php deleted file mode 100644 index 10f2d6c..0000000 --- a/vendor/symfony/http-kernel/EventListener/ErrorsLoggerListener.php +++ /dev/null @@ -1,52 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\EventListener; - -@trigger_error('The '.__NAMESPACE__.'\ErrorsLoggerListener class is deprecated since Symfony 2.6 and will be removed in 3.0. Use the Symfony\Component\HttpKernel\EventListener\DebugHandlersListener class instead.', E_USER_DEPRECATED); - -use Psr\Log\LoggerInterface; -use Symfony\Component\Debug\ErrorHandler; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\HttpKernel\KernelEvents; - -/** - * Injects the logger into the ErrorHandler, so that it can log various errors. - * - * @author Colin Frei - * @author Konstantin Myakshin - * - * @deprecated since version 2.6, to be removed in 3.0. Use the DebugHandlersListener class instead. - */ -class ErrorsLoggerListener implements EventSubscriberInterface -{ - private $channel; - private $logger; - - public function __construct($channel, LoggerInterface $logger = null) - { - $this->channel = $channel; - $this->logger = $logger; - } - - public function injectLogger() - { - if (null !== $this->logger) { - ErrorHandler::setLogger($this->logger, $this->channel); - $this->logger = null; - } - } - - public static function getSubscribedEvents() - { - return array(KernelEvents::REQUEST => array('injectLogger', 2048)); - } -} diff --git a/vendor/symfony/http-kernel/EventListener/EsiListener.php b/vendor/symfony/http-kernel/EventListener/EsiListener.php deleted file mode 100644 index 3deaf65..0000000 --- a/vendor/symfony/http-kernel/EventListener/EsiListener.php +++ /dev/null @@ -1,25 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\EventListener; - -@trigger_error('The '.__NAMESPACE__.'\EsiListener class is deprecated since Symfony 2.6 and will be removed in 3.0. Use the Symfony\Component\HttpKernel\EventListener\SurrogateListener class instead.', E_USER_DEPRECATED); - -/** - * EsiListener adds a Surrogate-Control HTTP header when the Response needs to be parsed for ESI. - * - * @author Fabien Potencier - * - * @deprecated since version 2.6, to be removed in 3.0. Use SurrogateListener instead - */ -class EsiListener extends SurrogateListener -{ -} diff --git a/vendor/symfony/http-kernel/Exception/FatalErrorException.php b/vendor/symfony/http-kernel/Exception/FatalErrorException.php deleted file mode 100644 index 0360ac0..0000000 --- a/vendor/symfony/http-kernel/Exception/FatalErrorException.php +++ /dev/null @@ -1,23 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Exception; - -@trigger_error('The '.__NAMESPACE__.'\FatalErrorException class is deprecated since Symfony 2.3 and will be removed in 3.0. Use the Symfony\Component\Debug\Exception\FatalErrorException class instead.', E_USER_DEPRECATED); - -/* - * Fatal Error Exception. - * - * @author Konstanton Myakshin - * - * @deprecated since version 2.3, to be removed in 3.0. Use the same class from the Debug component instead. - */ -class_exists('Symfony\Component\Debug\Exception\FatalErrorException'); diff --git a/vendor/symfony/http-kernel/Exception/FlattenException.php b/vendor/symfony/http-kernel/Exception/FlattenException.php deleted file mode 100644 index 9ef7abb..0000000 --- a/vendor/symfony/http-kernel/Exception/FlattenException.php +++ /dev/null @@ -1,25 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Exception; - -@trigger_error('The '.__NAMESPACE__.'\FlattenException class is deprecated since Symfony 2.3 and will be removed in 3.0. Use the Symfony\Component\Debug\Exception\FlattenException class instead.', E_USER_DEPRECATED); - -/* - * FlattenException wraps a PHP Exception to be able to serialize it. - * - * Basically, this class removes all objects from the trace. - * - * @author Fabien Potencier - * - * @deprecated since version 2.3, to be removed in 3.0. Use the same class from the Debug component instead. - */ -class_exists('Symfony\Component\Debug\Exception\FlattenException'); diff --git a/vendor/symfony/http-kernel/HttpCache/EsiResponseCacheStrategy.php b/vendor/symfony/http-kernel/HttpCache/EsiResponseCacheStrategy.php deleted file mode 100644 index 41096bb..0000000 --- a/vendor/symfony/http-kernel/HttpCache/EsiResponseCacheStrategy.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * This code is partially based on the Rack-Cache library by Ryan Tomayko, - * which is released under the MIT license. - * (based on commit 02d2b48d75bcb63cf1c0c7149c077ad256542801) - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\HttpCache; - -@trigger_error('The '.__NAMESPACE__.'\EsiResponseCacheStrategy class is deprecated since Symfony 2.6 and will be removed in 3.0. Use the Symfony\Component\HttpKernel\HttpCache\ResponseCacheStrategy class instead.', E_USER_DEPRECATED); - -/** - * EsiResponseCacheStrategy knows how to compute the Response cache HTTP header - * based on the different ESI response cache headers. - * - * This implementation changes the master response TTL to the smallest TTL received - * or force validation if one of the ESI has validation cache strategy. - * - * @author Fabien Potencier - * - * @deprecated since version 2.6, to be removed in 3.0. Use ResponseCacheStrategy instead - */ -class EsiResponseCacheStrategy extends ResponseCacheStrategy implements EsiResponseCacheStrategyInterface -{ -} diff --git a/vendor/symfony/http-kernel/HttpCache/EsiResponseCacheStrategyInterface.php b/vendor/symfony/http-kernel/HttpCache/EsiResponseCacheStrategyInterface.php deleted file mode 100644 index 5388e99..0000000 --- a/vendor/symfony/http-kernel/HttpCache/EsiResponseCacheStrategyInterface.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * This code is partially based on the Rack-Cache library by Ryan Tomayko, - * which is released under the MIT license. - * (based on commit 02d2b48d75bcb63cf1c0c7149c077ad256542801) - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\HttpCache; - -/** - * ResponseCacheStrategyInterface implementations know how to compute the - * Response cache HTTP header based on the different response cache headers. - * - * @author Fabien Potencier - * - * @deprecated since version 2.6, to be removed in 3.0. Use ResponseCacheStrategyInterface instead. - */ -interface EsiResponseCacheStrategyInterface extends ResponseCacheStrategyInterface -{ -} diff --git a/vendor/symfony/http-kernel/Log/LoggerInterface.php b/vendor/symfony/http-kernel/Log/LoggerInterface.php deleted file mode 100644 index cad38e5..0000000 --- a/vendor/symfony/http-kernel/Log/LoggerInterface.php +++ /dev/null @@ -1,44 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Log; - -use Psr\Log\LoggerInterface as PsrLogger; - -/** - * LoggerInterface. - * - * @author Fabien Potencier - * - * @deprecated since version 2.2, to be removed in 3.0. Type-hint \Psr\Log\LoggerInterface instead. - */ -interface LoggerInterface extends PsrLogger -{ - /** - * @deprecated since version 2.2, to be removed in 3.0. Use emergency() which is PSR-3 compatible. - */ - public function emerg($message, array $context = array()); - - /** - * @deprecated since version 2.2, to be removed in 3.0. Use critical() which is PSR-3 compatible. - */ - public function crit($message, array $context = array()); - - /** - * @deprecated since version 2.2, to be removed in 3.0. Use error() which is PSR-3 compatible. - */ - public function err($message, array $context = array()); - - /** - * @deprecated since version 2.2, to be removed in 3.0. Use warning() which is PSR-3 compatible. - */ - public function warn($message, array $context = array()); -} diff --git a/vendor/symfony/http-kernel/Log/NullLogger.php b/vendor/symfony/http-kernel/Log/NullLogger.php deleted file mode 100644 index 18b938d..0000000 --- a/vendor/symfony/http-kernel/Log/NullLogger.php +++ /dev/null @@ -1,44 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Log; - -@trigger_error('The '.__NAMESPACE__.'\NullLogger class is deprecated since Symfony 2.2 and will be removed in 3.0. Use the Psr\Log\NullLogger class instead from the psr/log Composer package.', E_USER_DEPRECATED); - -use Psr\Log\NullLogger as PsrNullLogger; - -/** - * NullLogger. - * - * @author Fabien Potencier - */ -class NullLogger extends PsrNullLogger implements LoggerInterface -{ - public function emerg($message, array $context = array()) - { - @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.2 and will be removed in 3.0. You should use the new emergency() method instead, which is PSR-3 compatible.', E_USER_DEPRECATED); - } - - public function crit($message, array $context = array()) - { - @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.2 and will be removed in 3.0. You should use the new critical() method instead, which is PSR-3 compatible.', E_USER_DEPRECATED); - } - - public function err($message, array $context = array()) - { - @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.2 and will be removed in 3.0. You should use the new error() method instead, which is PSR-3 compatible.', E_USER_DEPRECATED); - } - - public function warn($message, array $context = array()) - { - @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.2 and will be removed in 3.0. You should use the new warning() method instead, which is PSR-3 compatible.', E_USER_DEPRECATED); - } -} diff --git a/vendor/symfony/http-kernel/Profiler/BaseMemcacheProfilerStorage.php b/vendor/symfony/http-kernel/Profiler/BaseMemcacheProfilerStorage.php deleted file mode 100644 index d990e98..0000000 --- a/vendor/symfony/http-kernel/Profiler/BaseMemcacheProfilerStorage.php +++ /dev/null @@ -1,313 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Profiler; - -@trigger_error('The '.__NAMESPACE__.'\BaseMemcacheProfilerStorage class is deprecated since Symfony 2.8 and will be removed in 3.0. Use FileProfilerStorage instead.', E_USER_DEPRECATED); - -/** - * Base Memcache storage for profiling information in a Memcache. - * - * @author Andrej Hudec - * - * @deprecated Deprecated since Symfony 2.8, to be removed in Symfony 3.0. - * Use {@link FileProfilerStorage} instead. - */ -abstract class BaseMemcacheProfilerStorage implements ProfilerStorageInterface -{ - const TOKEN_PREFIX = 'sf_profiler_'; - - protected $dsn; - protected $lifetime; - - /** - * @param string $dsn A data source name - * @param string $username - * @param string $password - * @param int $lifetime The lifetime to use for the purge - */ - public function __construct($dsn, $username = '', $password = '', $lifetime = 86400) - { - $this->dsn = $dsn; - $this->lifetime = (int) $lifetime; - } - - /** - * {@inheritdoc} - */ - public function find($ip, $url, $limit, $method, $start = null, $end = null) - { - $indexName = $this->getIndexName(); - - $indexContent = $this->getValue($indexName); - if (!$indexContent) { - return array(); - } - - $profileList = explode("\n", $indexContent); - $result = array(); - - foreach ($profileList as $item) { - if (0 === $limit) { - break; - } - - if ('' == $item) { - continue; - } - - $values = explode("\t", $item, 7); - list($itemToken, $itemIp, $itemMethod, $itemUrl, $itemTime, $itemParent) = $values; - $statusCode = isset($values[6]) ? $values[6] : null; - - $itemTime = (int) $itemTime; - - if ($ip && false === strpos($itemIp, $ip) || $url && false === strpos($itemUrl, $url) || $method && false === strpos($itemMethod, $method)) { - continue; - } - - if (!empty($start) && $itemTime < $start) { - continue; - } - - if (!empty($end) && $itemTime > $end) { - continue; - } - - $result[$itemToken] = array( - 'token' => $itemToken, - 'ip' => $itemIp, - 'method' => $itemMethod, - 'url' => $itemUrl, - 'time' => $itemTime, - 'parent' => $itemParent, - 'status_code' => $statusCode, - ); - --$limit; - } - - usort($result, function ($a, $b) { - if ($a['time'] === $b['time']) { - return 0; - } - - return $a['time'] > $b['time'] ? -1 : 1; - }); - - return $result; - } - - /** - * {@inheritdoc} - */ - public function purge() - { - // delete only items from index - $indexName = $this->getIndexName(); - - $indexContent = $this->getValue($indexName); - - if (!$indexContent) { - return false; - } - - $profileList = explode("\n", $indexContent); - - foreach ($profileList as $item) { - if ('' == $item) { - continue; - } - - if (false !== $pos = strpos($item, "\t")) { - $this->delete($this->getItemName(substr($item, 0, $pos))); - } - } - - return $this->delete($indexName); - } - - /** - * {@inheritdoc} - */ - public function read($token) - { - if (empty($token)) { - return false; - } - - $profile = $this->getValue($this->getItemName($token)); - - if (false !== $profile) { - $profile = $this->createProfileFromData($token, $profile); - } - - return $profile; - } - - /** - * {@inheritdoc} - */ - public function write(Profile $profile) - { - $data = array( - 'token' => $profile->getToken(), - 'parent' => $profile->getParentToken(), - 'children' => array_map(function ($p) { return $p->getToken(); }, $profile->getChildren()), - 'data' => $profile->getCollectors(), - 'ip' => $profile->getIp(), - 'method' => $profile->getMethod(), - 'url' => $profile->getUrl(), - 'time' => $profile->getTime(), - ); - - $profileIndexed = false !== $this->getValue($this->getItemName($profile->getToken())); - - if ($this->setValue($this->getItemName($profile->getToken()), $data, $this->lifetime)) { - if (!$profileIndexed) { - // Add to index - $indexName = $this->getIndexName(); - - $indexRow = implode("\t", array( - $profile->getToken(), - $profile->getIp(), - $profile->getMethod(), - $profile->getUrl(), - $profile->getTime(), - $profile->getParentToken(), - $profile->getStatusCode(), - ))."\n"; - - return $this->appendValue($indexName, $indexRow, $this->lifetime); - } - - return true; - } - - return false; - } - - /** - * Retrieve item from the memcache server. - * - * @param string $key - * - * @return mixed - */ - abstract protected function getValue($key); - - /** - * Store an item on the memcache server under the specified key. - * - * @param string $key - * @param mixed $value - * @param int $expiration - * - * @return bool - */ - abstract protected function setValue($key, $value, $expiration = 0); - - /** - * Delete item from the memcache server. - * - * @param string $key - * - * @return bool - */ - abstract protected function delete($key); - - /** - * Append data to an existing item on the memcache server. - * - * @param string $key - * @param string $value - * @param int $expiration - * - * @return bool - */ - abstract protected function appendValue($key, $value, $expiration = 0); - - private function createProfileFromData($token, $data, $parent = null) - { - $profile = new Profile($token); - $profile->setIp($data['ip']); - $profile->setMethod($data['method']); - $profile->setUrl($data['url']); - $profile->setTime($data['time']); - $profile->setCollectors($data['data']); - - if (!$parent && $data['parent']) { - $parent = $this->read($data['parent']); - } - - if ($parent) { - $profile->setParent($parent); - } - - foreach ($data['children'] as $token) { - if (!$token) { - continue; - } - - if (!$childProfileData = $this->getValue($this->getItemName($token))) { - continue; - } - - $profile->addChild($this->createProfileFromData($token, $childProfileData, $profile)); - } - - return $profile; - } - - /** - * Get item name. - * - * @param string $token - * - * @return string - */ - private function getItemName($token) - { - $name = self::TOKEN_PREFIX.$token; - - if ($this->isItemNameValid($name)) { - return $name; - } - - return false; - } - - /** - * Get name of index. - * - * @return string - */ - private function getIndexName() - { - $name = self::TOKEN_PREFIX.'index'; - - if ($this->isItemNameValid($name)) { - return $name; - } - - return false; - } - - private function isItemNameValid($name) - { - $length = \strlen($name); - - if ($length > 250) { - throw new \RuntimeException(sprintf('The memcache item key "%s" is too long (%s bytes). Allowed maximum size is 250 bytes.', $name, $length)); - } - - return true; - } -} diff --git a/vendor/symfony/http-kernel/Profiler/MemcacheProfilerStorage.php b/vendor/symfony/http-kernel/Profiler/MemcacheProfilerStorage.php deleted file mode 100644 index 6578ebf..0000000 --- a/vendor/symfony/http-kernel/Profiler/MemcacheProfilerStorage.php +++ /dev/null @@ -1,112 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Profiler; - -@trigger_error('The '.__NAMESPACE__.'\MemcacheProfilerStorage class is deprecated since Symfony 2.8 and will be removed in 3.0. Use FileProfilerStorage instead.', E_USER_DEPRECATED); - -/** - * Memcache Profiler Storage. - * - * @author Andrej Hudec - * - * @deprecated Deprecated since Symfony 2.8, to be removed in Symfony 3.0. - * Use {@link FileProfilerStorage} instead. - */ -class MemcacheProfilerStorage extends BaseMemcacheProfilerStorage -{ - /** - * @var \Memcache - */ - private $memcache; - - /** - * Internal convenience method that returns the instance of the Memcache. - * - * @return \Memcache - * - * @throws \RuntimeException - */ - protected function getMemcache() - { - if (null === $this->memcache) { - if (!preg_match('#^memcache://(?(?=\[.*\])\[(.*)\]|(.*)):(.*)$#', $this->dsn, $matches)) { - throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use Memcache with an invalid dsn "%s". The expected format is "memcache://[host]:port".', $this->dsn)); - } - - $host = $matches[1] ?: $matches[2]; - $port = $matches[3]; - - $memcache = new \Memcache(); - $memcache->addServer($host, $port); - - $this->memcache = $memcache; - } - - return $this->memcache; - } - - /** - * Set instance of the Memcache. - * - * @param \Memcache $memcache - */ - public function setMemcache($memcache) - { - $this->memcache = $memcache; - } - - /** - * {@inheritdoc} - */ - protected function getValue($key) - { - return $this->getMemcache()->get($key); - } - - /** - * {@inheritdoc} - */ - protected function setValue($key, $value, $expiration = 0) - { - return $this->getMemcache()->set($key, $value, false, time() + $expiration); - } - - /** - * {@inheritdoc} - */ - protected function delete($key) - { - return $this->getMemcache()->delete($key); - } - - /** - * {@inheritdoc} - */ - protected function appendValue($key, $value, $expiration = 0) - { - $memcache = $this->getMemcache(); - - if (method_exists($memcache, 'append')) { - // Memcache v3.0 - if (!$result = $memcache->append($key, $value, false, $expiration)) { - return $memcache->set($key, $value, false, $expiration); - } - - return $result; - } - - // simulate append in Memcache <3.0 - $content = $memcache->get($key); - - return $memcache->set($key, $content.$value, false, $expiration); - } -} diff --git a/vendor/symfony/http-kernel/Profiler/MemcachedProfilerStorage.php b/vendor/symfony/http-kernel/Profiler/MemcachedProfilerStorage.php deleted file mode 100644 index edf6ff1..0000000 --- a/vendor/symfony/http-kernel/Profiler/MemcachedProfilerStorage.php +++ /dev/null @@ -1,108 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Profiler; - -@trigger_error('The '.__NAMESPACE__.'\MemcachedProfilerStorage class is deprecated since Symfony 2.8 and will be removed in 3.0. Use FileProfilerStorage instead.', E_USER_DEPRECATED); - -/** - * Memcached Profiler Storage. - * - * @author Andrej Hudec - * - * @deprecated Deprecated since Symfony 2.8, to be removed in Symfony 3.0. - * Use {@link FileProfilerStorage} instead. - */ -class MemcachedProfilerStorage extends BaseMemcacheProfilerStorage -{ - /** - * @var \Memcached - */ - private $memcached; - - /** - * Internal convenience method that returns the instance of the Memcached. - * - * @return \Memcached - * - * @throws \RuntimeException - */ - protected function getMemcached() - { - if (null === $this->memcached) { - if (!preg_match('#^memcached://(?(?=\[.*\])\[(.*)\]|(.*)):(.*)$#', $this->dsn, $matches)) { - throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use Memcached with an invalid dsn "%s". The expected format is "memcached://[host]:port".', $this->dsn)); - } - - $host = $matches[1] ?: $matches[2]; - $port = $matches[3]; - - $memcached = new \Memcached(); - - // disable compression to allow appending - $memcached->setOption(\Memcached::OPT_COMPRESSION, false); - - $memcached->addServer($host, $port); - - $this->memcached = $memcached; - } - - return $this->memcached; - } - - /** - * Set instance of the Memcached. - * - * @param \Memcached $memcached - */ - public function setMemcached($memcached) - { - $this->memcached = $memcached; - } - - /** - * {@inheritdoc} - */ - protected function getValue($key) - { - return $this->getMemcached()->get($key); - } - - /** - * {@inheritdoc} - */ - protected function setValue($key, $value, $expiration = 0) - { - return $this->getMemcached()->set($key, $value, time() + $expiration); - } - - /** - * {@inheritdoc} - */ - protected function delete($key) - { - return $this->getMemcached()->delete($key); - } - - /** - * {@inheritdoc} - */ - protected function appendValue($key, $value, $expiration = 0) - { - $memcached = $this->getMemcached(); - - if (!$result = $memcached->append($key, $value)) { - return $memcached->set($key, $value, $expiration); - } - - return $result; - } -} diff --git a/vendor/symfony/http-kernel/Profiler/MongoDbProfilerStorage.php b/vendor/symfony/http-kernel/Profiler/MongoDbProfilerStorage.php deleted file mode 100644 index 19970f9..0000000 --- a/vendor/symfony/http-kernel/Profiler/MongoDbProfilerStorage.php +++ /dev/null @@ -1,257 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Profiler; - -@trigger_error('The '.__NAMESPACE__.'\MongoDbProfilerStorage class is deprecated since Symfony 2.8 and will be removed in 3.0. Use FileProfilerStorage instead.', E_USER_DEPRECATED); - -/** - * @deprecated Deprecated since Symfony 2.8, to be removed in Symfony 3.0. - * Use {@link FileProfilerStorage} instead. - */ -class MongoDbProfilerStorage implements ProfilerStorageInterface -{ - protected $dsn; - protected $lifetime; - private $mongo; - - /** - * @param string $dsn A data source name - * @param string $username Not used - * @param string $password Not used - * @param int $lifetime The lifetime to use for the purge - */ - public function __construct($dsn, $username = '', $password = '', $lifetime = 86400) - { - $this->dsn = $dsn; - $this->lifetime = (int) $lifetime; - } - - /** - * {@inheritdoc} - */ - public function find($ip, $url, $limit, $method, $start = null, $end = null) - { - $cursor = $this->getMongo()->find($this->buildQuery($ip, $url, $method, $start, $end), array('_id', 'parent', 'ip', 'method', 'url', 'time', 'status_code'))->sort(array('time' => -1))->limit($limit); - - $tokens = array(); - foreach ($cursor as $profile) { - $tokens[] = $this->getData($profile); - } - - return $tokens; - } - - /** - * {@inheritdoc} - */ - public function purge() - { - $this->getMongo()->remove(array()); - } - - /** - * {@inheritdoc} - */ - public function read($token) - { - $profile = $this->getMongo()->findOne(array('_id' => $token, 'data' => array('$exists' => true))); - - if (null !== $profile) { - $profile = $this->createProfileFromData($this->getData($profile)); - } - - return $profile; - } - - /** - * {@inheritdoc} - */ - public function write(Profile $profile) - { - $this->cleanup(); - - $record = array( - '_id' => $profile->getToken(), - 'parent' => $profile->getParentToken(), - 'data' => base64_encode(serialize($profile->getCollectors())), - 'ip' => $profile->getIp(), - 'method' => $profile->getMethod(), - 'url' => $profile->getUrl(), - 'time' => $profile->getTime(), - 'status_code' => $profile->getStatusCode(), - ); - - $result = $this->getMongo()->update(array('_id' => $profile->getToken()), array_filter($record, function ($v) { return !empty($v); }), array('upsert' => true)); - - return (bool) (isset($result['ok']) ? $result['ok'] : $result); - } - - /** - * Internal convenience method that returns the instance of the MongoDB Collection. - * - * @return \MongoCollection - * - * @throws \RuntimeException - */ - protected function getMongo() - { - if (null !== $this->mongo) { - return $this->mongo; - } - - if (!$parsedDsn = $this->parseDsn($this->dsn)) { - throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use MongoDB with an invalid dsn "%s". The expected format is "mongodb://[user:pass@]host/database/collection"', $this->dsn)); - } - - list($server, $database, $collection) = $parsedDsn; - $mongoClass = version_compare(phpversion('mongo'), '1.3.0', '<') ? '\Mongo' : '\MongoClient'; - $mongo = new $mongoClass($server); - - return $this->mongo = $mongo->selectCollection($database, $collection); - } - - /** - * @return Profile - */ - protected function createProfileFromData(array $data) - { - $profile = $this->getProfile($data); - - if ($data['parent']) { - $parent = $this->getMongo()->findOne(array('_id' => $data['parent'], 'data' => array('$exists' => true))); - if ($parent) { - $profile->setParent($this->getProfile($this->getData($parent))); - } - } - - $profile->setChildren($this->readChildren($data['token'])); - - return $profile; - } - - /** - * @param string $token - * - * @return Profile[] An array of Profile instances - */ - protected function readChildren($token) - { - $profiles = array(); - - $cursor = $this->getMongo()->find(array('parent' => $token, 'data' => array('$exists' => true))); - foreach ($cursor as $d) { - $profiles[] = $this->getProfile($this->getData($d)); - } - - return $profiles; - } - - protected function cleanup() - { - $this->getMongo()->remove(array('time' => array('$lt' => time() - $this->lifetime))); - } - - /** - * @param string $ip - * @param string $url - * @param string $method - * @param int $start - * @param int $end - * - * @return array - */ - private function buildQuery($ip, $url, $method, $start, $end) - { - $query = array(); - - if (!empty($ip)) { - $query['ip'] = $ip; - } - - if (!empty($url)) { - $query['url'] = $url; - } - - if (!empty($method)) { - $query['method'] = $method; - } - - if (!empty($start) || !empty($end)) { - $query['time'] = array(); - } - - if (!empty($start)) { - $query['time']['$gte'] = $start; - } - - if (!empty($end)) { - $query['time']['$lte'] = $end; - } - - return $query; - } - - /** - * @return array - */ - private function getData(array $data) - { - return array( - 'token' => $data['_id'], - 'parent' => isset($data['parent']) ? $data['parent'] : null, - 'ip' => isset($data['ip']) ? $data['ip'] : null, - 'method' => isset($data['method']) ? $data['method'] : null, - 'url' => isset($data['url']) ? $data['url'] : null, - 'time' => isset($data['time']) ? $data['time'] : null, - 'data' => isset($data['data']) ? $data['data'] : null, - 'status_code' => isset($data['status_code']) ? $data['status_code'] : null, - ); - } - - /** - * @return Profile - */ - private function getProfile(array $data) - { - $profile = new Profile($data['token']); - $profile->setIp($data['ip']); - $profile->setMethod($data['method']); - $profile->setUrl($data['url']); - $profile->setTime($data['time']); - $profile->setCollectors(unserialize(base64_decode($data['data']))); - - return $profile; - } - - /** - * @param string $dsn - * - * @return array|null Array($server, $database, $collection) - */ - private function parseDsn($dsn) - { - if (!preg_match('#^(mongodb://.*)/(.*)/(.*)$#', $dsn, $matches)) { - return; - } - - $server = $matches[1]; - $database = $matches[2]; - $collection = $matches[3]; - preg_match('#^mongodb://(([^:]+):?(.*)(?=@))?@?([^/]*)(.*)$#', $server, $matchesServer); - - if ('' == $matchesServer[5] && '' != $matches[2]) { - $server .= '/'.$matches[2]; - } - - return array($server, $database, $collection); - } -} diff --git a/vendor/symfony/http-kernel/Profiler/MysqlProfilerStorage.php b/vendor/symfony/http-kernel/Profiler/MysqlProfilerStorage.php deleted file mode 100644 index 086aa87..0000000 --- a/vendor/symfony/http-kernel/Profiler/MysqlProfilerStorage.php +++ /dev/null @@ -1,84 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Profiler; - -@trigger_error('The '.__NAMESPACE__.'\MysqlProfilerStorage class is deprecated since Symfony 2.8 and will be removed in 3.0. Use FileProfilerStorage instead.', E_USER_DEPRECATED); - -/** - * A ProfilerStorage for Mysql. - * - * @author Jan Schumann - * - * @deprecated Deprecated since Symfony 2.8, to be removed in Symfony 3.0. - * Use {@link FileProfilerStorage} instead. - */ -class MysqlProfilerStorage extends PdoProfilerStorage -{ - /** - * {@inheritdoc} - */ - protected function initDb() - { - if (null === $this->db) { - if (0 !== strpos($this->dsn, 'mysql')) { - throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use Mysql with an invalid dsn "%s". The expected format is "mysql:dbname=database_name;host=host_name".', $this->dsn)); - } - - if (!class_exists('PDO') || !\in_array('mysql', \PDO::getAvailableDrivers(), true)) { - throw new \RuntimeException('You need to enable PDO_Mysql extension for the profiler to run properly.'); - } - - $db = new \PDO($this->dsn, $this->username, $this->password); - $db->exec('CREATE TABLE IF NOT EXISTS sf_profiler_data (token VARCHAR(255) PRIMARY KEY, data LONGTEXT, ip VARCHAR(64), method VARCHAR(6), url VARCHAR(255), time INTEGER UNSIGNED, parent VARCHAR(255), created_at INTEGER UNSIGNED, status_code SMALLINT UNSIGNED, KEY (created_at), KEY (ip), KEY (method), KEY (url), KEY (parent))'); - - $this->db = $db; - } - - return $this->db; - } - - /** - * {@inheritdoc} - */ - protected function buildCriteria($ip, $url, $start, $end, $limit, $method) - { - $criteria = array(); - $args = array(); - - if ($ip = preg_replace('/[^\d\.]/', '', $ip)) { - $criteria[] = 'ip LIKE :ip'; - $args[':ip'] = '%'.$ip.'%'; - } - - if ($url) { - $criteria[] = 'url LIKE :url'; - $args[':url'] = '%'.addcslashes($url, '%_\\').'%'; - } - - if ($method) { - $criteria[] = 'method = :method'; - $args[':method'] = $method; - } - - if (!empty($start)) { - $criteria[] = 'time >= :start'; - $args[':start'] = $start; - } - - if (!empty($end)) { - $criteria[] = 'time <= :end'; - $args[':end'] = $end; - } - - return array($criteria, $args); - } -} diff --git a/vendor/symfony/http-kernel/Profiler/PdoProfilerStorage.php b/vendor/symfony/http-kernel/Profiler/PdoProfilerStorage.php deleted file mode 100644 index e5f8bc7..0000000 --- a/vendor/symfony/http-kernel/Profiler/PdoProfilerStorage.php +++ /dev/null @@ -1,265 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Profiler; - -@trigger_error('The '.__NAMESPACE__.'\PdoProfilerStorage class is deprecated since Symfony 2.8 and will be removed in 3.0. Use FileProfilerStorage instead.', E_USER_DEPRECATED); - -/** - * Base PDO storage for profiling information in a PDO database. - * - * @author Fabien Potencier - * @author Jan Schumann - * - * @deprecated Deprecated since Symfony 2.8, to be removed in Symfony 3.0. - * Use {@link FileProfilerStorage} instead. - */ -abstract class PdoProfilerStorage implements ProfilerStorageInterface -{ - protected $dsn; - protected $username; - protected $password; - protected $lifetime; - protected $db; - - /** - * @param string $dsn A data source name - * @param string $username The username for the database - * @param string $password The password for the database - * @param int $lifetime The lifetime to use for the purge - */ - public function __construct($dsn, $username = '', $password = '', $lifetime = 86400) - { - $this->dsn = $dsn; - $this->username = $username; - $this->password = $password; - $this->lifetime = (int) $lifetime; - } - - /** - * {@inheritdoc} - */ - public function find($ip, $url, $limit, $method, $start = null, $end = null) - { - if (null === $start) { - $start = 0; - } - - if (null === $end) { - $end = time(); - } - - list($criteria, $args) = $this->buildCriteria($ip, $url, $start, $end, $limit, $method); - - $criteria = $criteria ? 'WHERE '.implode(' AND ', $criteria) : ''; - - $db = $this->initDb(); - $tokens = $this->fetch($db, 'SELECT token, ip, method, url, time, parent, status_code FROM sf_profiler_data '.$criteria.' ORDER BY time DESC LIMIT '.((int) $limit), $args); - $this->close($db); - - return $tokens; - } - - /** - * {@inheritdoc} - */ - public function read($token) - { - $db = $this->initDb(); - $args = array(':token' => $token); - $data = $this->fetch($db, 'SELECT data, parent, ip, method, url, time FROM sf_profiler_data WHERE token = :token LIMIT 1', $args); - $this->close($db); - if (isset($data[0]['data'])) { - return $this->createProfileFromData($token, $data[0]); - } - } - - /** - * {@inheritdoc} - */ - public function write(Profile $profile) - { - $db = $this->initDb(); - $args = array( - ':token' => $profile->getToken(), - ':parent' => $profile->getParentToken(), - ':data' => base64_encode(serialize($profile->getCollectors())), - ':ip' => $profile->getIp(), - ':method' => $profile->getMethod(), - ':url' => $profile->getUrl(), - ':time' => $profile->getTime(), - ':created_at' => time(), - ':status_code' => $profile->getStatusCode(), - ); - - try { - if ($this->has($profile->getToken())) { - $this->exec($db, 'UPDATE sf_profiler_data SET parent = :parent, data = :data, ip = :ip, method = :method, url = :url, time = :time, created_at = :created_at, status_code = :status_code WHERE token = :token', $args); - } else { - $this->exec($db, 'INSERT INTO sf_profiler_data (token, parent, data, ip, method, url, time, created_at, status_code) VALUES (:token, :parent, :data, :ip, :method, :url, :time, :created_at, :status_code)', $args); - } - $this->cleanup(); - $status = true; - } catch (\Exception $e) { - $status = false; - } - - $this->close($db); - - return $status; - } - - /** - * {@inheritdoc} - */ - public function purge() - { - $db = $this->initDb(); - $this->exec($db, 'DELETE FROM sf_profiler_data'); - $this->close($db); - } - - /** - * Build SQL criteria to fetch records by ip and url. - * - * @param string $ip The IP - * @param string $url The URL - * @param string $start The start period to search from - * @param string $end The end period to search to - * @param string $limit The maximum number of tokens to return - * @param string $method The request method - * - * @return array An array with (criteria, args) - */ - abstract protected function buildCriteria($ip, $url, $start, $end, $limit, $method); - - /** - * Initializes the database. - * - * @throws \RuntimeException When the requested database driver is not installed - */ - abstract protected function initDb(); - - protected function cleanup() - { - $db = $this->initDb(); - $this->exec($db, 'DELETE FROM sf_profiler_data WHERE created_at < :time', array(':time' => time() - $this->lifetime)); - $this->close($db); - } - - protected function exec($db, $query, array $args = array()) - { - $stmt = $this->prepareStatement($db, $query); - - foreach ($args as $arg => $val) { - $stmt->bindValue($arg, $val, \is_int($val) ? \PDO::PARAM_INT : \PDO::PARAM_STR); - } - $success = $stmt->execute(); - if (!$success) { - throw new \RuntimeException(sprintf('Error executing query "%s"', $query)); - } - } - - protected function prepareStatement($db, $query) - { - try { - $stmt = $db->prepare($query); - } catch (\Exception $e) { - $stmt = false; - } - - if (false === $stmt) { - throw new \RuntimeException('The database cannot successfully prepare the statement'); - } - - return $stmt; - } - - protected function fetch($db, $query, array $args = array()) - { - $stmt = $this->prepareStatement($db, $query); - - foreach ($args as $arg => $val) { - $stmt->bindValue($arg, $val, \is_int($val) ? \PDO::PARAM_INT : \PDO::PARAM_STR); - } - $stmt->execute(); - - return $stmt->fetchAll(\PDO::FETCH_ASSOC); - } - - protected function close($db) - { - } - - protected function createProfileFromData($token, $data, $parent = null) - { - $profile = new Profile($token); - $profile->setIp($data['ip']); - $profile->setMethod($data['method']); - $profile->setUrl($data['url']); - $profile->setTime($data['time']); - $profile->setCollectors(unserialize(base64_decode($data['data']))); - - if (!$parent && !empty($data['parent'])) { - $parent = $this->read($data['parent']); - } - - if ($parent) { - $profile->setParent($parent); - } - - $profile->setChildren($this->readChildren($token, $profile)); - - return $profile; - } - - /** - * Reads the child profiles for the given token. - * - * @param string $token The parent token - * @param string $parent The parent instance - * - * @return Profile[] An array of Profile instance - */ - protected function readChildren($token, $parent) - { - $db = $this->initDb(); - $data = $this->fetch($db, 'SELECT token, data, ip, method, url, time FROM sf_profiler_data WHERE parent = :token', array(':token' => $token)); - $this->close($db); - - if (!$data) { - return array(); - } - - $profiles = array(); - foreach ($data as $d) { - $profiles[] = $this->createProfileFromData($d['token'], $d, $parent); - } - - return $profiles; - } - - /** - * Returns whether data for the given token already exists in storage. - * - * @param string $token The profile token - * - * @return string - */ - protected function has($token) - { - $db = $this->initDb(); - $tokenExists = $this->fetch($db, 'SELECT 1 FROM sf_profiler_data WHERE token = :token LIMIT 1', array(':token' => $token)); - $this->close($db); - - return !empty($tokenExists); - } -} diff --git a/vendor/symfony/http-kernel/Profiler/RedisProfilerStorage.php b/vendor/symfony/http-kernel/Profiler/RedisProfilerStorage.php deleted file mode 100644 index 6d3d967..0000000 --- a/vendor/symfony/http-kernel/Profiler/RedisProfilerStorage.php +++ /dev/null @@ -1,395 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Profiler; - -@trigger_error('The '.__NAMESPACE__.'\RedisProfilerStorage class is deprecated since Symfony 2.8 and will be removed in 3.0. Use FileProfilerStorage instead.', E_USER_DEPRECATED); - -/** - * RedisProfilerStorage stores profiling information in Redis. - * - * @author Andrej Hudec - * @author Stephane PY - * - * @deprecated Deprecated since Symfony 2.8, to be removed in Symfony 3.0. - * Use {@link FileProfilerStorage} instead. - */ -class RedisProfilerStorage implements ProfilerStorageInterface -{ - const TOKEN_PREFIX = 'sf_profiler_'; - - const REDIS_OPT_SERIALIZER = 1; - const REDIS_OPT_PREFIX = 2; - const REDIS_SERIALIZER_NONE = 0; - const REDIS_SERIALIZER_PHP = 1; - - protected $dsn; - protected $lifetime; - - /** - * @var \Redis - */ - private $redis; - - /** - * @param string $dsn A data source name - * @param string $username Not used - * @param string $password Not used - * @param int $lifetime The lifetime to use for the purge - */ - public function __construct($dsn, $username = '', $password = '', $lifetime = 86400) - { - $this->dsn = $dsn; - $this->lifetime = (int) $lifetime; - } - - /** - * {@inheritdoc} - */ - public function find($ip, $url, $limit, $method, $start = null, $end = null) - { - $indexName = $this->getIndexName(); - - if (!$indexContent = $this->getValue($indexName, self::REDIS_SERIALIZER_NONE)) { - return array(); - } - - $profileList = array_reverse(explode("\n", $indexContent)); - $result = array(); - - foreach ($profileList as $item) { - if (0 === $limit) { - break; - } - - if ('' == $item) { - continue; - } - - $values = explode("\t", $item, 7); - list($itemToken, $itemIp, $itemMethod, $itemUrl, $itemTime, $itemParent) = $values; - $statusCode = isset($values[6]) ? $values[6] : null; - - $itemTime = (int) $itemTime; - - if ($ip && false === strpos($itemIp, $ip) || $url && false === strpos($itemUrl, $url) || $method && false === strpos($itemMethod, $method)) { - continue; - } - - if (!empty($start) && $itemTime < $start) { - continue; - } - - if (!empty($end) && $itemTime > $end) { - continue; - } - - $result[] = array( - 'token' => $itemToken, - 'ip' => $itemIp, - 'method' => $itemMethod, - 'url' => $itemUrl, - 'time' => $itemTime, - 'parent' => $itemParent, - 'status_code' => $statusCode, - ); - --$limit; - } - - return $result; - } - - /** - * {@inheritdoc} - */ - public function purge() - { - // delete only items from index - $indexName = $this->getIndexName(); - - $indexContent = $this->getValue($indexName, self::REDIS_SERIALIZER_NONE); - - if (!$indexContent) { - return false; - } - - $profileList = explode("\n", $indexContent); - - $result = array(); - - foreach ($profileList as $item) { - if ('' == $item) { - continue; - } - - if (false !== $pos = strpos($item, "\t")) { - $result[] = $this->getItemName(substr($item, 0, $pos)); - } - } - - $result[] = $indexName; - - return $this->delete($result); - } - - /** - * {@inheritdoc} - */ - public function read($token) - { - if (empty($token)) { - return false; - } - - $profile = $this->getValue($this->getItemName($token), self::REDIS_SERIALIZER_PHP); - - if (false !== $profile) { - $profile = $this->createProfileFromData($token, $profile); - } - - return $profile; - } - - /** - * {@inheritdoc} - */ - public function write(Profile $profile) - { - $data = array( - 'token' => $profile->getToken(), - 'parent' => $profile->getParentToken(), - 'children' => array_map(function ($p) { return $p->getToken(); }, $profile->getChildren()), - 'data' => $profile->getCollectors(), - 'ip' => $profile->getIp(), - 'method' => $profile->getMethod(), - 'url' => $profile->getUrl(), - 'time' => $profile->getTime(), - ); - - $profileIndexed = false !== $this->getValue($this->getItemName($profile->getToken())); - - if ($this->setValue($this->getItemName($profile->getToken()), $data, $this->lifetime, self::REDIS_SERIALIZER_PHP)) { - if (!$profileIndexed) { - // Add to index - $indexName = $this->getIndexName(); - - $indexRow = implode("\t", array( - $profile->getToken(), - $profile->getIp(), - $profile->getMethod(), - $profile->getUrl(), - $profile->getTime(), - $profile->getParentToken(), - $profile->getStatusCode(), - ))."\n"; - - return $this->appendValue($indexName, $indexRow, $this->lifetime); - } - - return true; - } - - return false; - } - - /** - * Internal convenience method that returns the instance of Redis. - * - * @return \Redis - * - * @throws \RuntimeException - */ - protected function getRedis() - { - if (null === $this->redis) { - $data = parse_url($this->dsn); - - if (false === $data || !isset($data['scheme']) || 'redis' !== $data['scheme'] || !isset($data['host']) || !isset($data['port'])) { - throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use Redis with an invalid dsn "%s". The minimal expected format is "redis://[host]:port".', $this->dsn)); - } - - if (!\extension_loaded('redis')) { - throw new \RuntimeException('RedisProfilerStorage requires that the redis extension is loaded.'); - } - - $redis = new \Redis(); - $redis->connect($data['host'], $data['port']); - - if (isset($data['path'])) { - $redis->select(substr($data['path'], 1)); - } - - if (isset($data['pass'])) { - $redis->auth($data['pass']); - } - - $redis->setOption(self::REDIS_OPT_PREFIX, self::TOKEN_PREFIX); - - $this->redis = $redis; - } - - return $this->redis; - } - - /** - * Set instance of the Redis. - * - * @param \Redis $redis - */ - public function setRedis($redis) - { - $this->redis = $redis; - } - - private function createProfileFromData($token, $data, $parent = null) - { - $profile = new Profile($token); - $profile->setIp($data['ip']); - $profile->setMethod($data['method']); - $profile->setUrl($data['url']); - $profile->setTime($data['time']); - $profile->setCollectors($data['data']); - - if (!$parent && $data['parent']) { - $parent = $this->read($data['parent']); - } - - if ($parent) { - $profile->setParent($parent); - } - - foreach ($data['children'] as $token) { - if (!$token) { - continue; - } - - if (!$childProfileData = $this->getValue($this->getItemName($token), self::REDIS_SERIALIZER_PHP)) { - continue; - } - - $profile->addChild($this->createProfileFromData($token, $childProfileData, $profile)); - } - - return $profile; - } - - /** - * Gets the item name. - * - * @param string $token - * - * @return string - */ - private function getItemName($token) - { - $name = $token; - - if ($this->isItemNameValid($name)) { - return $name; - } - - return false; - } - - /** - * Gets the name of the index. - * - * @return string - */ - private function getIndexName() - { - $name = 'index'; - - if ($this->isItemNameValid($name)) { - return $name; - } - - return false; - } - - private function isItemNameValid($name) - { - $length = \strlen($name); - - if ($length > 2147483648) { - throw new \RuntimeException(sprintf('The Redis item key "%s" is too long (%s bytes). Allowed maximum size is 2^31 bytes.', $name, $length)); - } - - return true; - } - - /** - * Retrieves an item from the Redis server. - * - * @param string $key - * @param int $serializer - * - * @return mixed - */ - private function getValue($key, $serializer = self::REDIS_SERIALIZER_NONE) - { - $redis = $this->getRedis(); - $redis->setOption(self::REDIS_OPT_SERIALIZER, $serializer); - - return $redis->get($key); - } - - /** - * Stores an item on the Redis server under the specified key. - * - * @param string $key - * @param mixed $value - * @param int $expiration - * @param int $serializer - * - * @return bool - */ - private function setValue($key, $value, $expiration = 0, $serializer = self::REDIS_SERIALIZER_NONE) - { - $redis = $this->getRedis(); - $redis->setOption(self::REDIS_OPT_SERIALIZER, $serializer); - - return $redis->setex($key, $expiration, $value); - } - - /** - * Appends data to an existing item on the Redis server. - * - * @param string $key - * @param string $value - * @param int $expiration - * - * @return bool - */ - private function appendValue($key, $value, $expiration = 0) - { - $redis = $this->getRedis(); - $redis->setOption(self::REDIS_OPT_SERIALIZER, self::REDIS_SERIALIZER_NONE); - - if ($redis->exists($key)) { - $redis->append($key, $value); - - return $redis->setTimeout($key, $expiration); - } - - return $redis->setex($key, $expiration, $value); - } - - /** - * Removes the specified keys. - * - * @return bool - */ - private function delete(array $keys) - { - return (bool) $this->getRedis()->delete($keys); - } -} diff --git a/vendor/symfony/http-kernel/Profiler/SqliteProfilerStorage.php b/vendor/symfony/http-kernel/Profiler/SqliteProfilerStorage.php deleted file mode 100644 index 549c27e..0000000 --- a/vendor/symfony/http-kernel/Profiler/SqliteProfilerStorage.php +++ /dev/null @@ -1,144 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Profiler; - -@trigger_error('The '.__NAMESPACE__.'\SqliteProfilerStorage class is deprecated since Symfony 2.8 and will be removed in 3.0. Use FileProfilerStorage instead.', E_USER_DEPRECATED); - -/** - * SqliteProfilerStorage stores profiling information in a SQLite database. - * - * @author Fabien Potencier - * - * @deprecated Deprecated since Symfony 2.8, to be removed in Symfony 3.0. - * Use {@link FileProfilerStorage} instead. - */ -class SqliteProfilerStorage extends PdoProfilerStorage -{ - /** - * @throws \RuntimeException When neither of SQLite3 or PDO_SQLite extension is enabled - */ - protected function initDb() - { - if (null === $this->db || $this->db instanceof \SQLite3) { - if (0 !== strpos($this->dsn, 'sqlite')) { - throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use Sqlite with an invalid dsn "%s". The expected format is "sqlite:/path/to/the/db/file".', $this->dsn)); - } - if (class_exists('SQLite3')) { - $db = new \SQLite3(substr($this->dsn, 7, \strlen($this->dsn)), \SQLITE3_OPEN_READWRITE | \SQLITE3_OPEN_CREATE); - if (method_exists($db, 'busyTimeout')) { - // busyTimeout only exists for PHP >= 5.3.3 - $db->busyTimeout(1000); - } - } elseif (class_exists('PDO') && \in_array('sqlite', \PDO::getAvailableDrivers(), true)) { - $db = new \PDO($this->dsn); - } else { - throw new \RuntimeException('You need to enable either the SQLite3 or PDO_SQLite extension for the profiler to run properly.'); - } - - $db->exec('PRAGMA temp_store=MEMORY; PRAGMA journal_mode=MEMORY;'); - $db->exec('CREATE TABLE IF NOT EXISTS sf_profiler_data (token STRING, data STRING, ip STRING, method STRING, url STRING, time INTEGER, parent STRING, created_at INTEGER, status_code INTEGER)'); - $db->exec('CREATE INDEX IF NOT EXISTS data_created_at ON sf_profiler_data (created_at)'); - $db->exec('CREATE INDEX IF NOT EXISTS data_ip ON sf_profiler_data (ip)'); - $db->exec('CREATE INDEX IF NOT EXISTS data_method ON sf_profiler_data (method)'); - $db->exec('CREATE INDEX IF NOT EXISTS data_url ON sf_profiler_data (url)'); - $db->exec('CREATE INDEX IF NOT EXISTS data_parent ON sf_profiler_data (parent)'); - $db->exec('CREATE UNIQUE INDEX IF NOT EXISTS data_token ON sf_profiler_data (token)'); - - $this->db = $db; - } - - return $this->db; - } - - protected function exec($db, $query, array $args = array()) - { - if ($db instanceof \SQLite3) { - $stmt = $this->prepareStatement($db, $query); - foreach ($args as $arg => $val) { - $stmt->bindValue($arg, $val, \is_int($val) ? \SQLITE3_INTEGER : \SQLITE3_TEXT); - } - - $res = $stmt->execute(); - if (false === $res) { - throw new \RuntimeException(sprintf('Error executing SQLite query "%s"', $query)); - } - $res->finalize(); - } else { - parent::exec($db, $query, $args); - } - } - - protected function fetch($db, $query, array $args = array()) - { - $return = array(); - - if ($db instanceof \SQLite3) { - $stmt = $this->prepareStatement($db, $query); - foreach ($args as $arg => $val) { - $stmt->bindValue($arg, $val, \is_int($val) ? \SQLITE3_INTEGER : \SQLITE3_TEXT); - } - $res = $stmt->execute(); - while ($row = $res->fetchArray(\SQLITE3_ASSOC)) { - $return[] = $row; - } - $res->finalize(); - $stmt->close(); - } else { - $return = parent::fetch($db, $query, $args); - } - - return $return; - } - - /** - * {@inheritdoc} - */ - protected function buildCriteria($ip, $url, $start, $end, $limit, $method) - { - $criteria = array(); - $args = array(); - - if ($ip = preg_replace('/[^\d\.]/', '', $ip)) { - $criteria[] = 'ip LIKE :ip'; - $args[':ip'] = '%'.$ip.'%'; - } - - if ($url) { - $criteria[] = 'url LIKE :url ESCAPE "\"'; - $args[':url'] = '%'.addcslashes($url, '%_\\').'%'; - } - - if ($method) { - $criteria[] = 'method = :method'; - $args[':method'] = $method; - } - - if (!empty($start)) { - $criteria[] = 'time >= :start'; - $args[':start'] = $start; - } - - if (!empty($end)) { - $criteria[] = 'time <= :end'; - $args[':end'] = $end; - } - - return array($criteria, $args); - } - - protected function close($db) - { - if ($db instanceof \SQLite3) { - $db->close(); - } - } -} diff --git a/vendor/symfony/polyfill-php54/LICENSE b/vendor/symfony/polyfill-php54/LICENSE deleted file mode 100644 index 4cd8bdd..0000000 --- a/vendor/symfony/polyfill-php54/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2015-2019 Fabien Potencier - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/vendor/symfony/polyfill-php54/Php54.php b/vendor/symfony/polyfill-php54/Php54.php deleted file mode 100644 index 5fe232c..0000000 --- a/vendor/symfony/polyfill-php54/Php54.php +++ /dev/null @@ -1,36 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Polyfill\Php54; - -/** - * @author Nicolas Grekas - * - * @internal - */ -final class Php54 -{ - public static function hex2bin($data) - { - $len = \strlen($data); - - if (null === $len) { - return; - } - if ($len % 2) { - trigger_error('hex2bin(): Hexadecimal input string must have an even length', E_USER_WARNING); - - return false; - } - - return pack('H*', $data); - } -} diff --git a/vendor/symfony/polyfill-php54/README.md b/vendor/symfony/polyfill-php54/README.md deleted file mode 100644 index d5dd463..0000000 --- a/vendor/symfony/polyfill-php54/README.md +++ /dev/null @@ -1,17 +0,0 @@ -Symfony Polyfill / Php54 -======================== - -This component provides functions unavailable in releases prior to PHP 5.4: - -- [`trait_exists`](http://php.net/trait_exists) -- [`class_uses`](http://php.net/class_uses) -- [`hex2bin`](http://php.net/hex2bin) -- [`session_register_shutdown`](http://php.net/session_register_shutdown) - -More information can be found in the -[main Polyfill README](https://github.com/symfony/polyfill/blob/master/README.md). - -License -======= - -This library is released under the [MIT license](LICENSE). diff --git a/vendor/symfony/polyfill-php54/Resources/stubs/CallbackFilterIterator.php b/vendor/symfony/polyfill-php54/Resources/stubs/CallbackFilterIterator.php deleted file mode 100644 index b69db3d..0000000 --- a/vendor/symfony/polyfill-php54/Resources/stubs/CallbackFilterIterator.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -class CallbackFilterIterator extends FilterIterator -{ - private $iterator; - private $callback; - - public function __construct(Iterator $iterator, $callback) - { - $this->iterator = $iterator; - $this->callback = $callback; - parent::__construct($iterator); - } - - public function accept() - { - return call_user_func($this->callback, $this->current(), $this->key(), $this->iterator); - } -} diff --git a/vendor/symfony/polyfill-php54/Resources/stubs/RecursiveCallbackFilterIterator.php b/vendor/symfony/polyfill-php54/Resources/stubs/RecursiveCallbackFilterIterator.php deleted file mode 100644 index 63afd38..0000000 --- a/vendor/symfony/polyfill-php54/Resources/stubs/RecursiveCallbackFilterIterator.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -class RecursiveCallbackFilterIterator extends CallbackFilterIterator implements RecursiveIterator -{ - private $iterator; - private $callback; - - public function __construct(RecursiveIterator $iterator, $callback) - { - $this->iterator = $iterator; - $this->callback = $callback; - parent::__construct($iterator, $callback); - } - - public function hasChildren() - { - return $this->iterator->hasChildren(); - } - - public function getChildren() - { - return new static($this->iterator->getChildren(), $this->callback); - } -} diff --git a/vendor/symfony/polyfill-php54/Resources/stubs/SessionHandlerInterface.php b/vendor/symfony/polyfill-php54/Resources/stubs/SessionHandlerInterface.php deleted file mode 100644 index 9baa7bc..0000000 --- a/vendor/symfony/polyfill-php54/Resources/stubs/SessionHandlerInterface.php +++ /dev/null @@ -1,102 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -/** - * SessionHandlerInterface for PHP < 5.4. - * - * The order in which these methods are invoked by PHP are: - * 1. open [session_start] - * 2. read - * 3. gc [optional depending on probability settings: gc_probability / gc_divisor] - * 4. destroy [optional when session_regenerate_id(true) is used] - * 5. write [session_write_close] or destroy [session_destroy] - * 6. close - * - * Extensive documentation can be found at php.net, see links: - * - * @see http://php.net/sessionhandlerinterface - * @see http://php.net/session.customhandler - * @see http://php.net/session-set-save-handler - * - * @author Drak - * @author Tobias Schultze - */ -interface SessionHandlerInterface -{ - /** - * Re-initializes existing session, or creates a new one. - * - * @see http://php.net/sessionhandlerinterface.open - * - * @param string $savePath Save path - * @param string $sessionName Session name, see http://php.net/function.session-name.php - * - * @return bool true on success, false on failure - */ - public function open($savePath, $sessionName); - - /** - * Closes the current session. - * - * @see http://php.net/sessionhandlerinterface.close - * - * @return bool true on success, false on failure - */ - public function close(); - - /** - * Reads the session data. - * - * @see http://php.net/sessionhandlerinterface.read - * - * @param string $sessionId Session ID, see http://php.net/function.session-id - * - * @return string Same session data as passed in write() or empty string when non-existent or on failure - */ - public function read($sessionId); - - /** - * Writes the session data to the storage. - * - * Care, the session ID passed to write() can be different from the one previously - * received in read() when the session ID changed due to session_regenerate_id(). - * - * @see http://php.net/sessionhandlerinterface.write - * - * @param string $sessionId Session ID , see http://php.net/function.session-id - * @param string $data Serialized session data to save - * - * @return bool true on success, false on failure - */ - public function write($sessionId, $data); - - /** - * Destroys a session. - * - * @see http://php.net/sessionhandlerinterface.destroy - * - * @param string $sessionId Session ID, see http://php.net/function.session-id - * - * @return bool true on success, false on failure - */ - public function destroy($sessionId); - - /** - * Cleans up expired sessions (garbage collection). - * - * @see http://php.net/sessionhandlerinterface.gc - * - * @param string|int $maxlifetime Sessions that have not updated for the last maxlifetime seconds will be removed - * - * @return bool true on success, false on failure - */ - public function gc($maxlifetime); -} diff --git a/vendor/symfony/polyfill-php54/bootstrap.php b/vendor/symfony/polyfill-php54/bootstrap.php deleted file mode 100644 index d72c199..0000000 --- a/vendor/symfony/polyfill-php54/bootstrap.php +++ /dev/null @@ -1,34 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -use Symfony\Polyfill\Php54 as p; - -if (PHP_VERSION_ID < 50400) { - if (!function_exists('trait_exists')) { - function trait_exists($class, $autoload = true) { return $autoload && \class_exists($class, $autoload) && false; } - } - if (!function_exists('class_uses')) { - function class_uses($class, $autoload = true) - { - if (\is_object($class) || \class_exists($class, $autoload) || \interface_exists($class, false)) { - return array(); - } - - return false; - } - } - if (!function_exists('hex2bin')) { - function hex2bin($data) { return p\Php54::hex2bin($data); } - } - if (!function_exists('session_register_shutdown')) { - function session_register_shutdown() { register_shutdown_function('session_write_close'); } - } -} diff --git a/vendor/symfony/polyfill-php54/composer.json b/vendor/symfony/polyfill-php54/composer.json deleted file mode 100644 index fd2ec53..0000000 --- a/vendor/symfony/polyfill-php54/composer.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "name": "symfony/polyfill-php54", - "type": "library", - "description": "Symfony polyfill backporting some PHP 5.4+ features to lower PHP versions", - "keywords": ["polyfill", "shim", "compatibility", "portable"], - "homepage": "https://symfony.com", - "license": "MIT", - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "require": { - "php": ">=5.3.3" - }, - "autoload": { - "psr-4": { "Symfony\\Polyfill\\Php54\\": "" }, - "files": [ "bootstrap.php" ], - "classmap": [ "Resources/stubs" ] - }, - "minimum-stability": "dev", - "extra": { - "branch-alias": { - "dev-master": "1.11-dev" - } - } -} diff --git a/vendor/symfony/polyfill-php55/LICENSE b/vendor/symfony/polyfill-php55/LICENSE deleted file mode 100644 index 4cd8bdd..0000000 --- a/vendor/symfony/polyfill-php55/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2015-2019 Fabien Potencier - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/vendor/symfony/polyfill-php55/Php55.php b/vendor/symfony/polyfill-php55/Php55.php deleted file mode 100644 index f5cb483..0000000 --- a/vendor/symfony/polyfill-php55/Php55.php +++ /dev/null @@ -1,89 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Polyfill\Php55; - -/** - * @internal - */ -final class Php55 -{ - public static function boolval($val) - { - return (bool) $val; - } - - public static function json_last_error_msg() - { - switch (json_last_error()) { - case JSON_ERROR_NONE: return 'No error'; - case JSON_ERROR_DEPTH: return 'Maximum stack depth exceeded'; - case JSON_ERROR_STATE_MISMATCH: return 'State mismatch (invalid or malformed JSON)'; - case JSON_ERROR_CTRL_CHAR: return 'Control character error, possibly incorrectly encoded'; - case JSON_ERROR_SYNTAX: return 'Syntax error'; - case JSON_ERROR_UTF8: return 'Malformed UTF-8 characters, possibly incorrectly encoded'; - default: return 'Unknown error'; - } - } - - /** - * @author Sebastiaan Stok - * @author Scott - */ - public static function hash_pbkdf2($algorithm, $password, $salt, $iterations, $length = 0, $rawOutput = false) - { - // Pre-hash for optimization if password length > hash length - $hashLength = \strlen(hash($algorithm, '', true)); - switch ($algorithm) { - case 'sha224': - case 'sha256': - $blockSize = 64; - break; - case 'sha384': - case 'sha512': - $blockSize = 128; - break; - default: - $blockSize = $hashLength; - break; - } - if ($length < 1) { - $length = $hashLength; - if (!$rawOutput) { - $length <<= 1; - } - } - - // Number of blocks needed to create the derived key - $blocks = ceil($length / $hashLength); - $digest = ''; - if (\strlen($password) > $blockSize) { - $password = hash($algorithm, $password, true); - } - - for ($i = 1; $i <= $blocks; ++$i) { - $ib = $block = hash_hmac($algorithm, $salt.pack('N', $i), $password, true); - - // Iterations - for ($j = 1; $j < $iterations; ++$j) { - $ib ^= ($block = hash_hmac($algorithm, $block, $password, true)); - } - - $digest .= $ib; - } - - if (!$rawOutput) { - $digest = bin2hex($digest); - } - - return substr($digest, 0, $length); - } -} diff --git a/vendor/symfony/polyfill-php55/Php55ArrayColumn.php b/vendor/symfony/polyfill-php55/Php55ArrayColumn.php deleted file mode 100644 index bb9b36a..0000000 --- a/vendor/symfony/polyfill-php55/Php55ArrayColumn.php +++ /dev/null @@ -1,64 +0,0 @@ - - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -namespace Symfony\Polyfill\Php55; - -/** - * @internal - */ -final class Php55ArrayColumn -{ - public static function array_column(array $input, $columnKey, $indexKey = null) - { - $output = array(); - - foreach ($input as $row) { - $key = $value = null; - $keySet = $valueSet = false; - - if (null !== $indexKey && array_key_exists($indexKey, $row)) { - $keySet = true; - $key = (string) $row[$indexKey]; - } - - if (null === $columnKey) { - $valueSet = true; - $value = $row; - } elseif (\is_array($row) && \array_key_exists($columnKey, $row)) { - $valueSet = true; - $value = $row[$columnKey]; - } - - if ($valueSet) { - if ($keySet) { - $output[$key] = $value; - } else { - $output[] = $value; - } - } - } - - return $output; - } -} diff --git a/vendor/symfony/polyfill-php55/README.md b/vendor/symfony/polyfill-php55/README.md deleted file mode 100644 index 3e432e4..0000000 --- a/vendor/symfony/polyfill-php55/README.md +++ /dev/null @@ -1,18 +0,0 @@ -Symfony Polyfill / Php55 -======================== - -This component provides functions unavailable in releases prior to PHP 5.5: - -- [`boolval`](http://php.net/boolval) -- [`json_last_error_msg`](http://php.net/json_last_error_msg) -- [`array_column`](http://php.net/array_column) -- [`hash_pbkdf2`](http://php.net/hash_pbkdf2) -- `password_*` functions (from [ircmaxell/password_compat](https://github.com/ircmaxell/password_compat)) - -More information can be found in the -[main Polyfill README](https://github.com/symfony/polyfill/blob/master/README.md). - -License -======= - -This library is released under the [MIT license](LICENSE). diff --git a/vendor/symfony/polyfill-php55/bootstrap.php b/vendor/symfony/polyfill-php55/bootstrap.php deleted file mode 100644 index 5e634fe..0000000 --- a/vendor/symfony/polyfill-php55/bootstrap.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -use Symfony\Polyfill\Php55 as p; - -if (PHP_VERSION_ID < 50500) { - if (!function_exists('boolval')) { - function boolval($val) { return p\Php55::boolval($val); } - } - if (!function_exists('json_last_error_msg')) { - function json_last_error_msg() { return p\Php55::json_last_error_msg(); } - } - if (!function_exists('array_column')) { - function array_column($array, $columnKey, $indexKey = null) { return p\Php55ArrayColumn::array_column($array, $columnKey, $indexKey); } - } - if (!function_exists('hash_pbkdf2')) { - function hash_pbkdf2($algorithm, $password, $salt, $iterations, $length = 0, $rawOutput = false) { return p\Php55::hash_pbkdf2($algorithm, $password, $salt, $iterations, $length, $rawOutput); } - } -} diff --git a/vendor/symfony/polyfill-php55/composer.json b/vendor/symfony/polyfill-php55/composer.json deleted file mode 100644 index c2dfd80..0000000 --- a/vendor/symfony/polyfill-php55/composer.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "name": "symfony/polyfill-php55", - "type": "library", - "description": "Symfony polyfill backporting some PHP 5.5+ features to lower PHP versions", - "keywords": ["polyfill", "shim", "compatibility", "portable"], - "homepage": "https://symfony.com", - "license": "MIT", - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "require": { - "php": ">=5.3.3", - "ircmaxell/password-compat": "~1.0" - }, - "autoload": { - "psr-4": { "Symfony\\Polyfill\\Php55\\": "" }, - "files": [ "bootstrap.php" ] - }, - "minimum-stability": "dev", - "extra": { - "branch-alias": { - "dev-master": "1.11-dev" - } - } -} diff --git a/vendor/symfony/routing/Matcher/ApacheUrlMatcher.php b/vendor/symfony/routing/Matcher/ApacheUrlMatcher.php deleted file mode 100644 index 1f17cee..0000000 --- a/vendor/symfony/routing/Matcher/ApacheUrlMatcher.php +++ /dev/null @@ -1,124 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Matcher; - -@trigger_error('The '.__NAMESPACE__.'\ApacheUrlMatcher class is deprecated since Symfony 2.5 and will be removed in 3.0. It\'s hard to replicate the behaviour of the PHP implementation and the performance gains are minimal.', E_USER_DEPRECATED); - -use Symfony\Component\Routing\Exception\MethodNotAllowedException; - -/** - * ApacheUrlMatcher matches URL based on Apache mod_rewrite matching (see ApacheMatcherDumper). - * - * @deprecated since version 2.5, to be removed in 3.0. - * The performance gains are minimal and it's very hard to replicate - * the behavior of PHP implementation. - * - * @author Fabien Potencier - * @author Arnaud Le Blanc - */ -class ApacheUrlMatcher extends UrlMatcher -{ - /** - * Tries to match a URL based on Apache mod_rewrite matching. - * - * Returns false if no route matches the URL. - * - * @param string $pathinfo The pathinfo to be parsed - * - * @return array An array of parameters - * - * @throws MethodNotAllowedException If the current method is not allowed - */ - public function match($pathinfo) - { - $parameters = array(); - $defaults = array(); - $allow = array(); - $route = null; - - foreach ($this->denormalizeValues($_SERVER) as $key => $value) { - $name = $key; - - // skip non-routing variables - // this improves performance when $_SERVER contains many usual - // variables like HTTP_*, DOCUMENT_ROOT, REQUEST_URI, ... - if (false === strpos($name, '_ROUTING_')) { - continue; - } - - while (0 === strpos($name, 'REDIRECT_')) { - $name = substr($name, 9); - } - - // expect _ROUTING__ - // or _ROUTING_ - - if (0 !== strpos($name, '_ROUTING_')) { - continue; - } - if (false !== $pos = strpos($name, '_', 9)) { - $type = substr($name, 9, $pos - 9); - $name = substr($name, $pos + 1); - } else { - $type = substr($name, 9); - } - - if ('param' === $type) { - if ('' !== $value) { - $parameters[$name] = $value; - } - } elseif ('default' === $type) { - $defaults[$name] = $value; - } elseif ('route' === $type) { - $route = $value; - } elseif ('allow' === $type) { - $allow[] = $name; - } - - unset($_SERVER[$key]); - } - - if (null !== $route) { - $parameters['_route'] = $route; - - return $this->mergeDefaults($parameters, $defaults); - } elseif (0 < \count($allow)) { - throw new MethodNotAllowedException($allow); - } else { - return parent::match($pathinfo); - } - } - - /** - * Denormalizes an array of values. - * - * @param string[] $values - * - * @return array - */ - private function denormalizeValues(array $values) - { - $normalizedValues = array(); - foreach ($values as $key => $value) { - if (preg_match('~^(.*)\[(\d+)\]$~', $key, $matches)) { - if (!isset($normalizedValues[$matches[1]])) { - $normalizedValues[$matches[1]] = array(); - } - $normalizedValues[$matches[1]][(int) $matches[2]] = $value; - } else { - $normalizedValues[$key] = $value; - } - } - - return $normalizedValues; - } -} diff --git a/vendor/symfony/routing/Matcher/Dumper/ApacheMatcherDumper.php b/vendor/symfony/routing/Matcher/Dumper/ApacheMatcherDumper.php deleted file mode 100644 index 6027069..0000000 --- a/vendor/symfony/routing/Matcher/Dumper/ApacheMatcherDumper.php +++ /dev/null @@ -1,272 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Matcher\Dumper; - -@trigger_error('The '.__NAMESPACE__.'\ApacheMatcherDumper class is deprecated since Symfony 2.5 and will be removed in 3.0. It\'s hard to replicate the behaviour of the PHP implementation and the performance gains are minimal.', E_USER_DEPRECATED); - -use Symfony\Component\Routing\Route; - -/** - * Dumps a set of Apache mod_rewrite rules. - * - * @deprecated since version 2.5, to be removed in 3.0. - * The performance gains are minimal and it's very hard to replicate - * the behavior of PHP implementation. - * - * @author Fabien Potencier - * @author Kris Wallsmith - */ -class ApacheMatcherDumper extends MatcherDumper -{ - /** - * Dumps a set of Apache mod_rewrite rules. - * - * Available options: - * - * * script_name: The script name (app.php by default) - * * base_uri: The base URI ("" by default) - * - * @return string A string to be used as Apache rewrite rules - * - * @throws \LogicException When the route regex is invalid - */ - public function dump(array $options = array()) - { - $options = array_merge(array( - 'script_name' => 'app.php', - 'base_uri' => '', - ), $options); - - $options['script_name'] = self::escape($options['script_name'], ' ', '\\'); - - $rules = array("# skip \"real\" requests\nRewriteCond %{REQUEST_FILENAME} -f\nRewriteRule .* - [QSA,L]"); - $methodVars = array(); - $hostRegexUnique = 0; - $prevHostRegex = ''; - - foreach ($this->getRoutes()->all() as $name => $route) { - if ($route->getCondition()) { - throw new \LogicException(sprintf('Unable to dump the routes for Apache as route "%s" has a condition.', $name)); - } - - $compiledRoute = $route->compile(); - $hostRegex = $compiledRoute->getHostRegex(); - - if (null !== $hostRegex && $prevHostRegex !== $hostRegex) { - $prevHostRegex = $hostRegex; - ++$hostRegexUnique; - - $rule = array(); - - $regex = $this->regexToApacheRegex($hostRegex); - $regex = self::escape($regex, ' ', '\\'); - - $rule[] = sprintf('RewriteCond %%{HTTP:Host} %s', $regex); - - $variables = array(); - $variables[] = sprintf('E=__ROUTING_host_%s:1', $hostRegexUnique); - - foreach ($compiledRoute->getHostVariables() as $i => $variable) { - $variables[] = sprintf('E=__ROUTING_host_%s_%s:%%%d', $hostRegexUnique, $variable, $i + 1); - } - - $variables = implode(',', $variables); - - $rule[] = sprintf('RewriteRule .? - [%s]', $variables); - - $rules[] = implode("\n", $rule); - } - - $rules[] = $this->dumpRoute($name, $route, $options, $hostRegexUnique); - - $methodVars = array_merge($methodVars, $route->getMethods()); - } - if (0 < \count($methodVars)) { - $rule = array('# 405 Method Not Allowed'); - $methodVars = array_values(array_unique($methodVars)); - if (\in_array('GET', $methodVars) && !\in_array('HEAD', $methodVars)) { - $methodVars[] = 'HEAD'; - } - foreach ($methodVars as $i => $methodVar) { - $rule[] = sprintf('RewriteCond %%{ENV:_ROUTING__allow_%s} =1%s', $methodVar, isset($methodVars[$i + 1]) ? ' [OR]' : ''); - } - $rule[] = sprintf('RewriteRule .* %s [QSA,L]', $options['script_name']); - - $rules[] = implode("\n", $rule); - } - - return implode("\n\n", $rules)."\n"; - } - - /** - * Dumps a single route. - * - * @param string $name Route name - * @param Route $route The route - * @param array $options Options - * @param bool $hostRegexUnique Unique identifier for the host regex - * - * @return string The compiled route - */ - private function dumpRoute($name, $route, array $options, $hostRegexUnique) - { - $compiledRoute = $route->compile(); - - // prepare the apache regex - $regex = $this->regexToApacheRegex($compiledRoute->getRegex()); - $regex = '^'.self::escape(preg_quote($options['base_uri']).substr($regex, 1), ' ', '\\'); - - $methods = $this->getRouteMethods($route); - - $hasTrailingSlash = (!$methods || \in_array('HEAD', $methods)) && '/$' === substr($regex, -2) && '^/$' !== $regex; - - $variables = array('E=_ROUTING_route:'.$name); - foreach ($compiledRoute->getHostVariables() as $variable) { - $variables[] = sprintf('E=_ROUTING_param_%s:%%{ENV:__ROUTING_host_%s_%s}', $variable, $hostRegexUnique, $variable); - } - foreach ($compiledRoute->getPathVariables() as $i => $variable) { - $variables[] = 'E=_ROUTING_param_'.$variable.':%'.($i + 1); - } - foreach ($this->normalizeValues($route->getDefaults()) as $key => $value) { - $variables[] = 'E=_ROUTING_default_'.$key.':'.strtr($value, array( - ':' => '\\:', - '=' => '\\=', - '\\' => '\\\\', - ' ' => '\\ ', - )); - } - $variables = implode(',', $variables); - - $rule = array("# $name"); - - // method mismatch - if (0 < \count($methods)) { - $allow = array(); - foreach ($methods as $method) { - $allow[] = 'E=_ROUTING_allow_'.$method.':1'; - } - - if ($compiledRoute->getHostRegex()) { - $rule[] = sprintf('RewriteCond %%{ENV:__ROUTING_host_%s} =1', $hostRegexUnique); - } - - $rule[] = "RewriteCond %{REQUEST_URI} $regex"; - $rule[] = sprintf('RewriteCond %%{REQUEST_METHOD} !^(%s)$ [NC]', implode('|', $methods)); - $rule[] = sprintf('RewriteRule .* - [S=%d,%s]', $hasTrailingSlash ? 2 : 1, implode(',', $allow)); - } - - // redirect with trailing slash appended - if ($hasTrailingSlash) { - if ($compiledRoute->getHostRegex()) { - $rule[] = sprintf('RewriteCond %%{ENV:__ROUTING_host_%s} =1', $hostRegexUnique); - } - - $rule[] = 'RewriteCond %{REQUEST_URI} '.substr($regex, 0, -2).'$'; - $rule[] = 'RewriteRule .* $0/ [QSA,L,R=301]'; - } - - // the main rule - - if ($compiledRoute->getHostRegex()) { - $rule[] = sprintf('RewriteCond %%{ENV:__ROUTING_host_%s} =1', $hostRegexUnique); - } - - $rule[] = "RewriteCond %{REQUEST_URI} $regex"; - $rule[] = "RewriteRule .* {$options['script_name']} [QSA,L,$variables]"; - - return implode("\n", $rule); - } - - /** - * Returns methods allowed for a route. - * - * @return array The methods - */ - private function getRouteMethods(Route $route) - { - $methods = $route->getMethods(); - - // GET and HEAD are equivalent - if (\in_array('GET', $methods) && !\in_array('HEAD', $methods)) { - $methods[] = 'HEAD'; - } - - return $methods; - } - - /** - * Converts a regex to make it suitable for mod_rewrite. - * - * @param string $regex The regex - * - * @return string The converted regex - */ - private function regexToApacheRegex($regex) - { - $regexPatternEnd = strrpos($regex, $regex[0]); - - return preg_replace('/\?P<.+?>/', '', substr($regex, 1, $regexPatternEnd - 1)); - } - - /** - * Escapes a string. - * - * @param string $string The string to be escaped - * @param string $char The character to be escaped - * @param string $with The character to be used for escaping - * - * @return string The escaped string - */ - private static function escape($string, $char, $with) - { - $escaped = false; - $output = ''; - foreach (str_split($string) as $symbol) { - if ($escaped) { - $output .= $symbol; - $escaped = false; - continue; - } - if ($symbol === $char) { - $output .= $with.$char; - continue; - } - if ($symbol === $with) { - $escaped = true; - } - $output .= $symbol; - } - - return $output; - } - - /** - * Normalizes an array of values. - * - * @return string[] - */ - private function normalizeValues(array $values) - { - $normalizedValues = array(); - foreach ($values as $key => $value) { - if (\is_array($value)) { - foreach ($value as $index => $bit) { - $normalizedValues[sprintf('%s[%s]', $key, $index)] = $bit; - } - } else { - $normalizedValues[$key] = (string) $value; - } - } - - return $normalizedValues; - } -} diff --git a/vendor/symfony/routing/Matcher/Dumper/DumperPrefixCollection.php b/vendor/symfony/routing/Matcher/Dumper/DumperPrefixCollection.php deleted file mode 100644 index f736f75..0000000 --- a/vendor/symfony/routing/Matcher/Dumper/DumperPrefixCollection.php +++ /dev/null @@ -1,105 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Matcher\Dumper; - -/** - * Prefix tree of routes preserving routes order. - * - * @author Arnaud Le Blanc - * - * @internal - */ -class DumperPrefixCollection extends DumperCollection -{ - /** - * @var string - */ - private $prefix = ''; - - /** - * Returns the prefix. - * - * @return string The prefix - */ - public function getPrefix() - { - return $this->prefix; - } - - /** - * Sets the prefix. - * - * @param string $prefix The prefix - */ - public function setPrefix($prefix) - { - $this->prefix = $prefix; - } - - /** - * Adds a route in the tree. - * - * @return self - * - * @throws \LogicException - */ - public function addPrefixRoute(DumperRoute $route) - { - $prefix = $route->getRoute()->compile()->getStaticPrefix(); - - for ($collection = $this; null !== $collection; $collection = $collection->getParent()) { - // Same prefix, add to current leave - if ($collection->prefix === $prefix) { - $collection->add($route); - - return $collection; - } - - // Prefix starts with route's prefix - if ('' === $collection->prefix || 0 === strpos($prefix, $collection->prefix)) { - $child = new self(); - $child->setPrefix(substr($prefix, 0, \strlen($collection->prefix) + 1)); - $collection->add($child); - - return $child->addPrefixRoute($route); - } - } - - // Reached only if the root has a non empty prefix - throw new \LogicException('The collection root must not have a prefix'); - } - - /** - * Merges nodes whose prefix ends with a slash. - * - * Children of a node whose prefix ends with a slash are moved to the parent node - */ - public function mergeSlashNodes() - { - $children = array(); - - foreach ($this as $child) { - if ($child instanceof self) { - $child->mergeSlashNodes(); - if ('/' === substr($child->prefix, -1)) { - $children = array_merge($children, $child->all()); - } else { - $children[] = $child; - } - } else { - $children[] = $child; - } - } - - $this->setAll($children); - } -} diff --git a/vendor/symfony/twig-bridge/Node/FormEnctypeNode.php b/vendor/symfony/twig-bridge/Node/FormEnctypeNode.php deleted file mode 100644 index 14811e6..0000000 --- a/vendor/symfony/twig-bridge/Node/FormEnctypeNode.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bridge\Twig\Node; - -/** - * @author Bernhard Schussek - * - * @deprecated since version 2.3, to be removed in 3.0. Use the helper "form_start()" instead. - */ -class FormEnctypeNode extends SearchAndRenderBlockNode -{ -} diff --git a/vendor/twig/twig/lib/Twig/Autoloader.php b/vendor/twig/twig/lib/Twig/Autoloader.php deleted file mode 100644 index e34e214..0000000 --- a/vendor/twig/twig/lib/Twig/Autoloader.php +++ /dev/null @@ -1,52 +0,0 @@ - - * - * @deprecated since 1.21 and will be removed in 2.0. Use Composer instead. 2.0. - */ -class Twig_Autoloader -{ - /** - * Registers Twig_Autoloader as an SPL autoloader. - * - * @param bool $prepend whether to prepend the autoloader or not - */ - public static function register($prepend = false) - { - @trigger_error('Using Twig_Autoloader is deprecated since version 1.21. Use Composer instead.', E_USER_DEPRECATED); - - spl_autoload_register([__CLASS__, 'autoload'], true, $prepend); - } - - /** - * Handles autoloading of classes. - * - * @param string $class a class name - */ - public static function autoload($class) - { - if (0 !== strpos($class, 'Twig')) { - return; - } - - if (is_file($file = __DIR__.'/../'.str_replace(['_', "\0"], ['/', ''], $class).'.php')) { - require $file; - } elseif (is_file($file = __DIR__.'/../../src/'.str_replace(['Twig\\', '\\', "\0"], ['', '/', ''], $class).'.php')) { - require $file; - } - } -} diff --git a/vendor/twig/twig/lib/Twig/CompilerInterface.php b/vendor/twig/twig/lib/Twig/CompilerInterface.php deleted file mode 100644 index 42872c9..0000000 --- a/vendor/twig/twig/lib/Twig/CompilerInterface.php +++ /dev/null @@ -1,34 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 3.0) - */ -interface Twig_CompilerInterface -{ - /** - * Compiles a node. - * - * @return $this - */ - public function compile(Twig_NodeInterface $node); - - /** - * Gets the current PHP code after compilation. - * - * @return string The PHP code - */ - public function getSource(); -} diff --git a/vendor/twig/twig/lib/Twig/Filter/Function.php b/vendor/twig/twig/lib/Twig/Filter/Function.php deleted file mode 100644 index 011d4cc..0000000 --- a/vendor/twig/twig/lib/Twig/Filter/Function.php +++ /dev/null @@ -1,40 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 2.0) - */ -class Twig_Filter_Function extends Twig_Filter -{ - protected $function; - - public function __construct($function, array $options = []) - { - $options['callable'] = $function; - - parent::__construct($options); - - $this->function = $function; - } - - public function compile() - { - return $this->function; - } -} diff --git a/vendor/twig/twig/lib/Twig/Filter/Method.php b/vendor/twig/twig/lib/Twig/Filter/Method.php deleted file mode 100644 index 5cd0628..0000000 --- a/vendor/twig/twig/lib/Twig/Filter/Method.php +++ /dev/null @@ -1,44 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 2.0) - */ -class Twig_Filter_Method extends Twig_Filter -{ - protected $extension; - protected $method; - - public function __construct(ExtensionInterface $extension, $method, array $options = []) - { - $options['callable'] = [$extension, $method]; - - parent::__construct($options); - - $this->extension = $extension; - $this->method = $method; - } - - public function compile() - { - return sprintf('$this->env->getExtension(\'%s\')->%s', \get_class($this->extension), $this->method); - } -} diff --git a/vendor/twig/twig/lib/Twig/Filter/Node.php b/vendor/twig/twig/lib/Twig/Filter/Node.php deleted file mode 100644 index 8bb2899..0000000 --- a/vendor/twig/twig/lib/Twig/Filter/Node.php +++ /dev/null @@ -1,42 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 2.0) - */ -class Twig_Filter_Node extends Twig_Filter -{ - protected $class; - - public function __construct($class, array $options = []) - { - parent::__construct($options); - - $this->class = $class; - } - - public function getClass() - { - return $this->class; - } - - public function compile() - { - } -} diff --git a/vendor/twig/twig/lib/Twig/FilterCallableInterface.php b/vendor/twig/twig/lib/Twig/FilterCallableInterface.php deleted file mode 100644 index 091ca97..0000000 --- a/vendor/twig/twig/lib/Twig/FilterCallableInterface.php +++ /dev/null @@ -1,24 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 2.0) - */ -interface Twig_FilterCallableInterface -{ - public function getCallable(); -} diff --git a/vendor/twig/twig/lib/Twig/FilterInterface.php b/vendor/twig/twig/lib/Twig/FilterInterface.php deleted file mode 100644 index 9b85f97..0000000 --- a/vendor/twig/twig/lib/Twig/FilterInterface.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 2.0) - */ -interface Twig_FilterInterface -{ - /** - * Compiles a filter. - * - * @return string The PHP code for the filter - */ - public function compile(); - - public function needsEnvironment(); - - public function needsContext(); - - public function getSafe(Node $filterArgs); - - public function getPreservesSafety(); - - public function getPreEscape(); - - public function setArguments($arguments); - - public function getArguments(); -} diff --git a/vendor/twig/twig/lib/Twig/Function/Function.php b/vendor/twig/twig/lib/Twig/Function/Function.php deleted file mode 100644 index 605d8d3..0000000 --- a/vendor/twig/twig/lib/Twig/Function/Function.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 2.0) - */ -class Twig_Function_Function extends Twig_Function -{ - protected $function; - - public function __construct($function, array $options = []) - { - $options['callable'] = $function; - - parent::__construct($options); - - $this->function = $function; - } - - public function compile() - { - return $this->function; - } -} diff --git a/vendor/twig/twig/lib/Twig/Function/Method.php b/vendor/twig/twig/lib/Twig/Function/Method.php deleted file mode 100644 index 9e472c5..0000000 --- a/vendor/twig/twig/lib/Twig/Function/Method.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 2.0) - */ -class Twig_Function_Method extends Twig_Function -{ - protected $extension; - protected $method; - - public function __construct(ExtensionInterface $extension, $method, array $options = []) - { - $options['callable'] = [$extension, $method]; - - parent::__construct($options); - - $this->extension = $extension; - $this->method = $method; - } - - public function compile() - { - return sprintf('$this->env->getExtension(\'%s\')->%s', \get_class($this->extension), $this->method); - } -} diff --git a/vendor/twig/twig/lib/Twig/Function/Node.php b/vendor/twig/twig/lib/Twig/Function/Node.php deleted file mode 100644 index 8148ec3..0000000 --- a/vendor/twig/twig/lib/Twig/Function/Node.php +++ /dev/null @@ -1,42 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 2.0) - */ -class Twig_Function_Node extends Twig_Function -{ - protected $class; - - public function __construct($class, array $options = []) - { - parent::__construct($options); - - $this->class = $class; - } - - public function getClass() - { - return $this->class; - } - - public function compile() - { - } -} diff --git a/vendor/twig/twig/lib/Twig/FunctionCallableInterface.php b/vendor/twig/twig/lib/Twig/FunctionCallableInterface.php deleted file mode 100644 index abc83ea..0000000 --- a/vendor/twig/twig/lib/Twig/FunctionCallableInterface.php +++ /dev/null @@ -1,24 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 2.0) - */ -interface Twig_FunctionCallableInterface -{ - public function getCallable(); -} diff --git a/vendor/twig/twig/lib/Twig/FunctionInterface.php b/vendor/twig/twig/lib/Twig/FunctionInterface.php deleted file mode 100644 index 915d6cc..0000000 --- a/vendor/twig/twig/lib/Twig/FunctionInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 2.0) - */ -interface Twig_FunctionInterface -{ - /** - * Compiles a function. - * - * @return string The PHP code for the function - */ - public function compile(); - - public function needsEnvironment(); - - public function needsContext(); - - public function getSafe(Node $filterArgs); - - public function setArguments($arguments); - - public function getArguments(); -} diff --git a/vendor/twig/twig/lib/Twig/LexerInterface.php b/vendor/twig/twig/lib/Twig/LexerInterface.php deleted file mode 100644 index cc04f68..0000000 --- a/vendor/twig/twig/lib/Twig/LexerInterface.php +++ /dev/null @@ -1,36 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 3.0) - */ -interface Twig_LexerInterface -{ - /** - * Tokenizes a source code. - * - * @param string|Source $code The source code - * @param string $name A unique identifier for the source code - * - * @return TokenStream - * - * @throws SyntaxError When the code is syntactically wrong - */ - public function tokenize($code, $name = null); -} diff --git a/vendor/twig/twig/lib/Twig/Loader/String.php b/vendor/twig/twig/lib/Twig/Loader/String.php deleted file mode 100644 index 348af0c..0000000 --- a/vendor/twig/twig/lib/Twig/Loader/String.php +++ /dev/null @@ -1,63 +0,0 @@ - - */ -class Twig_Loader_String implements LoaderInterface, ExistsLoaderInterface, SourceContextLoaderInterface -{ - public function getSource($name) - { - @trigger_error(sprintf('Calling "getSource" on "%s" is deprecated since 1.27. Use getSourceContext() instead.', \get_class($this)), E_USER_DEPRECATED); - - return $name; - } - - public function getSourceContext($name) - { - return new Source($name, $name); - } - - public function exists($name) - { - return true; - } - - public function getCacheKey($name) - { - return $name; - } - - public function isFresh($name, $time) - { - return true; - } -} diff --git a/vendor/twig/twig/lib/Twig/Node/Expression/ExtensionReference.php b/vendor/twig/twig/lib/Twig/Node/Expression/ExtensionReference.php deleted file mode 100644 index 9b8927a..0000000 --- a/vendor/twig/twig/lib/Twig/Node/Expression/ExtensionReference.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * @deprecated since 1.23 and will be removed in 2.0. - */ -class Twig_Node_Expression_ExtensionReference extends AbstractExpression -{ - public function __construct($name, $lineno, $tag = null) - { - parent::__construct([], ['name' => $name], $lineno, $tag); - } - - public function compile(Compiler $compiler) - { - $compiler->raw(sprintf("\$this->env->getExtension('%s')", $this->getAttribute('name'))); - } -} diff --git a/vendor/twig/twig/lib/Twig/Node/SetTemp.php b/vendor/twig/twig/lib/Twig/Node/SetTemp.php deleted file mode 100644 index 211ab4e..0000000 --- a/vendor/twig/twig/lib/Twig/Node/SetTemp.php +++ /dev/null @@ -1,11 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 3.0) - */ -interface Twig_NodeInterface extends \Countable, \IteratorAggregate -{ - /** - * Compiles the node to PHP. - */ - public function compile(Compiler $compiler); - - /** - * @deprecated since 1.27 (to be removed in 2.0) - */ - public function getLine(); - - public function getNodeTag(); -} diff --git a/vendor/twig/twig/lib/Twig/ParserInterface.php b/vendor/twig/twig/lib/Twig/ParserInterface.php deleted file mode 100644 index 96e9aaa..0000000 --- a/vendor/twig/twig/lib/Twig/ParserInterface.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 3.0) - */ -interface Twig_ParserInterface -{ - /** - * Converts a token stream to a node tree. - * - * @return ModuleNode - * - * @throws SyntaxError When the token stream is syntactically or semantically wrong - */ - public function parse(TokenStream $stream); -} diff --git a/vendor/twig/twig/lib/Twig/TemplateInterface.php b/vendor/twig/twig/lib/Twig/TemplateInterface.php deleted file mode 100644 index 0f767b8..0000000 --- a/vendor/twig/twig/lib/Twig/TemplateInterface.php +++ /dev/null @@ -1,50 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 3.0) - */ -interface Twig_TemplateInterface -{ - const ANY_CALL = 'any'; - const ARRAY_CALL = 'array'; - const METHOD_CALL = 'method'; - - /** - * Renders the template with the given context and returns it as string. - * - * @param array $context An array of parameters to pass to the template - * - * @return string The rendered template - */ - public function render(array $context); - - /** - * Displays the template with the given context. - * - * @param array $context An array of parameters to pass to the template - * @param array $blocks An array of blocks to pass to the template - */ - public function display(array $context, array $blocks = []); - - /** - * Returns the bound environment for this template. - * - * @return Environment - */ - public function getEnvironment(); -} diff --git a/vendor/twig/twig/lib/Twig/Test/Function.php b/vendor/twig/twig/lib/Twig/Test/Function.php deleted file mode 100644 index a789c40..0000000 --- a/vendor/twig/twig/lib/Twig/Test/Function.php +++ /dev/null @@ -1,38 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 2.0) - */ -class Twig_Test_Function extends Twig_Test -{ - protected $function; - - public function __construct($function, array $options = []) - { - $options['callable'] = $function; - - parent::__construct($options); - - $this->function = $function; - } - - public function compile() - { - return $this->function; - } -} diff --git a/vendor/twig/twig/lib/Twig/Test/Method.php b/vendor/twig/twig/lib/Twig/Test/Method.php deleted file mode 100644 index 3559f34..0000000 --- a/vendor/twig/twig/lib/Twig/Test/Method.php +++ /dev/null @@ -1,42 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 2.0) - */ -class Twig_Test_Method extends Twig_Test -{ - protected $extension; - protected $method; - - public function __construct(ExtensionInterface $extension, $method, array $options = []) - { - $options['callable'] = [$extension, $method]; - - parent::__construct($options); - - $this->extension = $extension; - $this->method = $method; - } - - public function compile() - { - return sprintf('$this->env->getExtension(\'%s\')->%s', \get_class($this->extension), $this->method); - } -} diff --git a/vendor/twig/twig/lib/Twig/Test/Node.php b/vendor/twig/twig/lib/Twig/Test/Node.php deleted file mode 100644 index 6b5de15..0000000 --- a/vendor/twig/twig/lib/Twig/Test/Node.php +++ /dev/null @@ -1,40 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 2.0) - */ -class Twig_Test_Node extends Twig_Test -{ - protected $class; - - public function __construct($class, array $options = []) - { - parent::__construct($options); - - $this->class = $class; - } - - public function getClass() - { - return $this->class; - } - - public function compile() - { - } -} diff --git a/vendor/twig/twig/lib/Twig/TestCallableInterface.php b/vendor/twig/twig/lib/Twig/TestCallableInterface.php deleted file mode 100644 index 51ecb9a..0000000 --- a/vendor/twig/twig/lib/Twig/TestCallableInterface.php +++ /dev/null @@ -1,22 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 2.0) - */ -interface Twig_TestCallableInterface -{ - public function getCallable(); -} diff --git a/vendor/twig/twig/lib/Twig/TestInterface.php b/vendor/twig/twig/lib/Twig/TestInterface.php deleted file mode 100644 index 9166407..0000000 --- a/vendor/twig/twig/lib/Twig/TestInterface.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 2.0) - */ -interface Twig_TestInterface -{ - /** - * Compiles a test. - * - * @return string The PHP code for the test - */ - public function compile(); -} diff --git a/vendor/twig/twig/lib/Twig/TokenParserBroker.php b/vendor/twig/twig/lib/Twig/TokenParserBroker.php deleted file mode 100644 index 8cca809..0000000 --- a/vendor/twig/twig/lib/Twig/TokenParserBroker.php +++ /dev/null @@ -1,122 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 2.0) - */ -class Twig_TokenParserBroker implements Twig_TokenParserBrokerInterface -{ - protected $parser; - protected $parsers = []; - protected $brokers = []; - - /** - * @param array|\Traversable $parsers A \Traversable of Twig_TokenParserInterface instances - * @param array|\Traversable $brokers A \Traversable of Twig_TokenParserBrokerInterface instances - * @param bool $triggerDeprecationError - */ - public function __construct($parsers = [], $brokers = [], $triggerDeprecationError = true) - { - if ($triggerDeprecationError) { - @trigger_error('The '.__CLASS__.' class is deprecated since version 1.12 and will be removed in 2.0.', E_USER_DEPRECATED); - } - - foreach ($parsers as $parser) { - if (!$parser instanceof TokenParserInterface) { - throw new \LogicException('$parsers must a an array of Twig_TokenParserInterface.'); - } - $this->parsers[$parser->getTag()] = $parser; - } - foreach ($brokers as $broker) { - if (!$broker instanceof Twig_TokenParserBrokerInterface) { - throw new \LogicException('$brokers must a an array of Twig_TokenParserBrokerInterface.'); - } - $this->brokers[] = $broker; - } - } - - public function addTokenParser(TokenParserInterface $parser) - { - $this->parsers[$parser->getTag()] = $parser; - } - - public function removeTokenParser(TokenParserInterface $parser) - { - $name = $parser->getTag(); - if (isset($this->parsers[$name]) && $parser === $this->parsers[$name]) { - unset($this->parsers[$name]); - } - } - - public function addTokenParserBroker(self $broker) - { - $this->brokers[] = $broker; - } - - public function removeTokenParserBroker(self $broker) - { - if (false !== $pos = array_search($broker, $this->brokers)) { - unset($this->brokers[$pos]); - } - } - - /** - * Gets a suitable TokenParser for a tag. - * - * First looks in parsers, then in brokers. - * - * @param string $tag A tag name - * - * @return TokenParserInterface|null A Twig_TokenParserInterface or null if no suitable TokenParser was found - */ - public function getTokenParser($tag) - { - if (isset($this->parsers[$tag])) { - return $this->parsers[$tag]; - } - $broker = end($this->brokers); - while (false !== $broker) { - $parser = $broker->getTokenParser($tag); - if (null !== $parser) { - return $parser; - } - $broker = prev($this->brokers); - } - } - - public function getParsers() - { - return $this->parsers; - } - - public function getParser() - { - return $this->parser; - } - - public function setParser(Twig_ParserInterface $parser) - { - $this->parser = $parser; - foreach ($this->parsers as $tokenParser) { - $tokenParser->setParser($parser); - } - foreach ($this->brokers as $broker) { - $broker->setParser($parser); - } - } -} diff --git a/vendor/twig/twig/lib/Twig/TokenParserBrokerInterface.php b/vendor/twig/twig/lib/Twig/TokenParserBrokerInterface.php deleted file mode 100644 index f369264..0000000 --- a/vendor/twig/twig/lib/Twig/TokenParserBrokerInterface.php +++ /dev/null @@ -1,46 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 2.0) - */ -interface Twig_TokenParserBrokerInterface -{ - /** - * Gets a TokenParser suitable for a tag. - * - * @param string $tag A tag name - * - * @return TokenParserInterface|null A Twig_TokenParserInterface or null if no suitable TokenParser was found - */ - public function getTokenParser($tag); - - /** - * Calls Twig\TokenParser\TokenParserInterface::setParser on all parsers the implementation knows of. - */ - public function setParser(Twig_ParserInterface $parser); - - /** - * Gets the Twig_ParserInterface. - * - * @return Twig_ParserInterface|null A Twig_ParserInterface instance or null - */ - public function getParser(); -} diff --git a/vendor/twig/twig/src/Node/SetTempNode.php b/vendor/twig/twig/src/Node/SetTempNode.php deleted file mode 100644 index 918fb99..0000000 --- a/vendor/twig/twig/src/Node/SetTempNode.php +++ /dev/null @@ -1,44 +0,0 @@ - $name], $lineno); - } - - public function compile(Compiler $compiler) - { - $name = $this->getAttribute('name'); - $compiler - ->addDebugInfo($this) - ->write('if (isset($context[') - ->string($name) - ->raw('])) { $_') - ->raw($name) - ->raw('_ = $context[') - ->repr($name) - ->raw(']; } else { $_') - ->raw($name) - ->raw("_ = null; }\n") - ; - } -} - -class_alias('Twig\Node\SetTempNode', 'Twig_Node_SetTemp'); diff --git a/vendor/zendframework/zend-eventmanager/src/GlobalEventManager.php b/vendor/zendframework/zend-eventmanager/src/GlobalEventManager.php deleted file mode 100644 index 336b69c..0000000 --- a/vendor/zendframework/zend-eventmanager/src/GlobalEventManager.php +++ /dev/null @@ -1,141 +0,0 @@ -trigger($event, $context, $argv, $callback); - } - - /** - * Trigger listeners until return value of one causes a callback to evaluate - * to true. - * - * @param string $event - * @param string|object $context - * @param array|object $argv - * @param callable $callback - * @return ResponseCollection - * @deprecated Please use trigger() - */ - public static function triggerUntil($event, $context, $argv, $callback) - { - trigger_error( - 'This method is deprecated and will be removed in the future. Please use trigger() instead.', - E_USER_DEPRECATED - ); - return static::trigger($event, $context, $argv, $callback); - } - - /** - * Attach a listener to an event - * - * @param string $event - * @param callable $callback - * @param int $priority - * @return CallbackHandler - */ - public static function attach($event, $callback, $priority = 1) - { - return static::getEventCollection()->attach($event, $callback, $priority); - } - - /** - * Detach a callback from a listener - * - * @param CallbackHandler $listener - * @return bool - */ - public static function detach(CallbackHandler $listener) - { - return static::getEventCollection()->detach($listener); - } - - /** - * Retrieve list of events this object manages - * - * @return array - */ - public static function getEvents() - { - return static::getEventCollection()->getEvents(); - } - - /** - * Retrieve all listeners for a given event - * - * @param string $event - * @return PriorityQueue|array - */ - public static function getListeners($event) - { - return static::getEventCollection()->getListeners($event); - } - - /** - * Clear all listeners for a given event - * - * @param string $event - * @return void - */ - public static function clearListeners($event) - { - static::getEventCollection()->clearListeners($event); - } -} diff --git a/vendor/zendframework/zend-eventmanager/src/ProvidesEvents.php b/vendor/zendframework/zend-eventmanager/src/ProvidesEvents.php deleted file mode 100644 index edb19c1..0000000 --- a/vendor/zendframework/zend-eventmanager/src/ProvidesEvents.php +++ /dev/null @@ -1,23 +0,0 @@ -=5.3.23" - }, - "require-dev": { - "zendframework/zend-config": "~2.5", - "zendframework/zend-eventmanager": "~2.5", - "zendframework/zend-inputfilter": "~2.5", - "zendframework/zend-serializer": "~2.5", - "zendframework/zend-servicemanager": "~2.5", - "zendframework/zend-filter": "~2.5", - "fabpot/php-cs-fixer": "1.7.*", - "phpunit/PHPUnit": "~4.0" - }, - "suggest": { - "zendframework/zend-eventmanager": "To support aggregate hydrator usage", - "zendframework/zend-serializer": "Zend\\Serializer component", - "zendframework/zend-servicemanager": "To support hydrator plugin manager usage", - "zendframework/zend-filter": "To support naming strategy hydrator usage" - }, - "minimum-stability": "dev", - "prefer-stable": true, - "extra": { - "branch-alias": { - "dev-master": "2.5-dev", - "dev-develop": "2.6-dev" - } - }, - "autoload-dev": { - "psr-4": { - "ZendTest\\Stdlib\\": "test/" - } - } -} diff --git a/vendor/zendframework/zend-stdlib/src/AbstractOptions.php b/vendor/zendframework/zend-stdlib/src/AbstractOptions.php deleted file mode 100644 index aaa1dd2..0000000 --- a/vendor/zendframework/zend-stdlib/src/AbstractOptions.php +++ /dev/null @@ -1,176 +0,0 @@ -setFromArray($options); - } - } - - /** - * Set one or more configuration properties - * - * @param array|Traversable|AbstractOptions $options - * @throws Exception\InvalidArgumentException - * @return AbstractOptions Provides fluent interface - */ - public function setFromArray($options) - { - if ($options instanceof self) { - $options = $options->toArray(); - } - - if (!is_array($options) && !$options instanceof Traversable) { - throw new Exception\InvalidArgumentException( - sprintf( - 'Parameter provided to %s must be an %s, %s or %s', - __METHOD__, - 'array', - 'Traversable', - 'Zend\Stdlib\AbstractOptions' - ) - ); - } - - foreach ($options as $key => $value) { - $this->__set($key, $value); - } - - return $this; - } - - /** - * Cast to array - * - * @return array - */ - public function toArray() - { - $array = array(); - $transform = function ($letters) { - $letter = array_shift($letters); - return '_' . strtolower($letter); - }; - foreach ($this as $key => $value) { - if ($key === '__strictMode__') { - continue; - } - $normalizedKey = preg_replace_callback('/([A-Z])/', $transform, $key); - $array[$normalizedKey] = $value; - } - return $array; - } - - /** - * Set a configuration property - * - * @see ParameterObject::__set() - * @param string $key - * @param mixed $value - * @throws Exception\BadMethodCallException - * @return void - */ - public function __set($key, $value) - { - $setter = 'set' . str_replace('_', '', $key); - - if (is_callable(array($this, $setter))) { - $this->{$setter}($value); - - return; - } - - if ($this->__strictMode__) { - throw new Exception\BadMethodCallException(sprintf( - 'The option "%s" does not have a callable "%s" ("%s") setter method which must be defined', - $key, - 'set' . str_replace(' ', '', ucwords(str_replace('_', ' ', $key))), - $setter - )); - } - } - - /** - * Get a configuration property - * - * @see ParameterObject::__get() - * @param string $key - * @throws Exception\BadMethodCallException - * @return mixed - */ - public function __get($key) - { - $getter = 'get' . str_replace('_', '', $key); - - if (is_callable(array($this, $getter))) { - return $this->{$getter}(); - } - - throw new Exception\BadMethodCallException(sprintf( - 'The option "%s" does not have a callable "%s" getter method which must be defined', - $key, - 'get' . str_replace(' ', '', ucwords(str_replace('_', ' ', $key))) - )); - } - - /** - * Test if a configuration property is null - * @see ParameterObject::__isset() - * @param string $key - * @return bool - */ - public function __isset($key) - { - $getter = 'get' . str_replace('_', '', $key); - - return method_exists($this, $getter) && null !== $this->__get($key); - } - - /** - * Set a configuration property to NULL - * - * @see ParameterObject::__unset() - * @param string $key - * @throws Exception\InvalidArgumentException - * @return void - */ - public function __unset($key) - { - try { - $this->__set($key, null); - } catch (Exception\BadMethodCallException $e) { - throw new Exception\InvalidArgumentException( - 'The class property $' . $key . ' cannot be unset as' - . ' NULL is an invalid value for it', - 0, - $e - ); - } - } -} diff --git a/vendor/zendframework/zend-stdlib/src/ArrayObject.php b/vendor/zendframework/zend-stdlib/src/ArrayObject.php deleted file mode 100644 index 44145c8..0000000 --- a/vendor/zendframework/zend-stdlib/src/ArrayObject.php +++ /dev/null @@ -1,432 +0,0 @@ -setFlags($flags); - $this->storage = $input; - $this->setIteratorClass($iteratorClass); - $this->protectedProperties = array_keys(get_object_vars($this)); - } - - /** - * Returns whether the requested key exists - * - * @param mixed $key - * @return bool - */ - public function __isset($key) - { - if ($this->flag == self::ARRAY_AS_PROPS) { - return $this->offsetExists($key); - } - if (in_array($key, $this->protectedProperties)) { - throw new Exception\InvalidArgumentException('$key is a protected property, use a different key'); - } - - return isset($this->$key); - } - - /** - * Sets the value at the specified key to value - * - * @param mixed $key - * @param mixed $value - * @return void - */ - public function __set($key, $value) - { - if ($this->flag == self::ARRAY_AS_PROPS) { - return $this->offsetSet($key, $value); - } - if (in_array($key, $this->protectedProperties)) { - throw new Exception\InvalidArgumentException('$key is a protected property, use a different key'); - } - $this->$key = $value; - } - - /** - * Unsets the value at the specified key - * - * @param mixed $key - * @return void - */ - public function __unset($key) - { - if ($this->flag == self::ARRAY_AS_PROPS) { - return $this->offsetUnset($key); - } - if (in_array($key, $this->protectedProperties)) { - throw new Exception\InvalidArgumentException('$key is a protected property, use a different key'); - } - unset($this->$key); - } - - /** - * Returns the value at the specified key by reference - * - * @param mixed $key - * @return mixed - */ - public function &__get($key) - { - $ret = null; - if ($this->flag == self::ARRAY_AS_PROPS) { - $ret =& $this->offsetGet($key); - - return $ret; - } - if (in_array($key, $this->protectedProperties)) { - throw new Exception\InvalidArgumentException('$key is a protected property, use a different key'); - } - - return $this->$key; - } - - /** - * Appends the value - * - * @param mixed $value - * @return void - */ - public function append($value) - { - $this->storage[] = $value; - } - - /** - * Sort the entries by value - * - * @return void - */ - public function asort() - { - asort($this->storage); - } - - /** - * Get the number of public properties in the ArrayObject - * - * @return int - */ - public function count() - { - return count($this->storage); - } - - /** - * Exchange the array for another one. - * - * @param array|ArrayObject $data - * @return array - */ - public function exchangeArray($data) - { - if (!is_array($data) && !is_object($data)) { - throw new Exception\InvalidArgumentException('Passed variable is not an array or object, using empty array instead'); - } - - if (is_object($data) && ($data instanceof self || $data instanceof \ArrayObject)) { - $data = $data->getArrayCopy(); - } - if (!is_array($data)) { - $data = (array) $data; - } - - $storage = $this->storage; - - $this->storage = $data; - - return $storage; - } - - /** - * Creates a copy of the ArrayObject. - * - * @return array - */ - public function getArrayCopy() - { - return $this->storage; - } - - /** - * Gets the behavior flags. - * - * @return int - */ - public function getFlags() - { - return $this->flag; - } - - /** - * Create a new iterator from an ArrayObject instance - * - * @return \Iterator - */ - public function getIterator() - { - $class = $this->iteratorClass; - - return new $class($this->storage); - } - - /** - * Gets the iterator classname for the ArrayObject. - * - * @return string - */ - public function getIteratorClass() - { - return $this->iteratorClass; - } - - /** - * Sort the entries by key - * - * @return void - */ - public function ksort() - { - ksort($this->storage); - } - - /** - * Sort an array using a case insensitive "natural order" algorithm - * - * @return void - */ - public function natcasesort() - { - natcasesort($this->storage); - } - - /** - * Sort entries using a "natural order" algorithm - * - * @return void - */ - public function natsort() - { - natsort($this->storage); - } - - /** - * Returns whether the requested key exists - * - * @param mixed $key - * @return bool - */ - public function offsetExists($key) - { - return isset($this->storage[$key]); - } - - /** - * Returns the value at the specified key - * - * @param mixed $key - * @return mixed - */ - public function &offsetGet($key) - { - $ret = null; - if (!$this->offsetExists($key)) { - return $ret; - } - $ret =& $this->storage[$key]; - - return $ret; - } - - /** - * Sets the value at the specified key to value - * - * @param mixed $key - * @param mixed $value - * @return void - */ - public function offsetSet($key, $value) - { - $this->storage[$key] = $value; - } - - /** - * Unsets the value at the specified key - * - * @param mixed $key - * @return void - */ - public function offsetUnset($key) - { - if ($this->offsetExists($key)) { - unset($this->storage[$key]); - } - } - - /** - * Serialize an ArrayObject - * - * @return string - */ - public function serialize() - { - return serialize(get_object_vars($this)); - } - - /** - * Sets the behavior flags - * - * @param int $flags - * @return void - */ - public function setFlags($flags) - { - $this->flag = $flags; - } - - /** - * Sets the iterator classname for the ArrayObject - * - * @param string $class - * @return void - */ - public function setIteratorClass($class) - { - if (class_exists($class)) { - $this->iteratorClass = $class; - - return ; - } - - if (strpos($class, '\\') === 0) { - $class = '\\' . $class; - if (class_exists($class)) { - $this->iteratorClass = $class; - - return ; - } - } - - throw new Exception\InvalidArgumentException('The iterator class does not exist'); - } - - /** - * Sort the entries with a user-defined comparison function and maintain key association - * - * @param callable $function - * @return void - */ - public function uasort($function) - { - if (is_callable($function)) { - uasort($this->storage, $function); - } - } - - /** - * Sort the entries by keys using a user-defined comparison function - * - * @param callable $function - * @return void - */ - public function uksort($function) - { - if (is_callable($function)) { - uksort($this->storage, $function); - } - } - - /** - * Unserialize an ArrayObject - * - * @param string $data - * @return void - */ - public function unserialize($data) - { - $ar = unserialize($data); - $this->protectedProperties = array_keys(get_object_vars($this)); - - $this->setFlags($ar['flag']); - $this->exchangeArray($ar['storage']); - $this->setIteratorClass($ar['iteratorClass']); - - foreach ($ar as $k => $v) { - switch ($k) { - case 'flag': - $this->setFlags($v); - break; - case 'storage': - $this->exchangeArray($v); - break; - case 'iteratorClass': - $this->setIteratorClass($v); - break; - case 'protectedProperties': - continue; - default: - $this->__set($k, $v); - } - } - } -} diff --git a/vendor/zendframework/zend-stdlib/src/ArraySerializableInterface.php b/vendor/zendframework/zend-stdlib/src/ArraySerializableInterface.php deleted file mode 100644 index dcf8471..0000000 --- a/vendor/zendframework/zend-stdlib/src/ArraySerializableInterface.php +++ /dev/null @@ -1,28 +0,0 @@ -getArrayCopy(); - return new ArrayIterator(array_reverse($array)); - } -} diff --git a/vendor/zendframework/zend-stdlib/src/ArrayUtils.php b/vendor/zendframework/zend-stdlib/src/ArrayUtils.php deleted file mode 100644 index 3545054..0000000 --- a/vendor/zendframework/zend-stdlib/src/ArrayUtils.php +++ /dev/null @@ -1,335 +0,0 @@ - 0; - } - - /** - * Test whether an array contains one or more integer keys - * - * @param mixed $value - * @param bool $allowEmpty Should an empty array() return true - * @return bool - */ - public static function hasIntegerKeys($value, $allowEmpty = false) - { - if (!is_array($value)) { - return false; - } - - if (!$value) { - return $allowEmpty; - } - - return count(array_filter(array_keys($value), 'is_int')) > 0; - } - - /** - * Test whether an array contains one or more numeric keys. - * - * A numeric key can be one of the following: - * - an integer 1, - * - a string with a number '20' - * - a string with negative number: '-1000' - * - a float: 2.2120, -78.150999 - * - a string with float: '4000.99999', '-10.10' - * - * @param mixed $value - * @param bool $allowEmpty Should an empty array() return true - * @return bool - */ - public static function hasNumericKeys($value, $allowEmpty = false) - { - if (!is_array($value)) { - return false; - } - - if (!$value) { - return $allowEmpty; - } - - return count(array_filter(array_keys($value), 'is_numeric')) > 0; - } - - /** - * Test whether an array is a list - * - * A list is a collection of values assigned to continuous integer keys - * starting at 0 and ending at count() - 1. - * - * For example: - * - * $list = array('a', 'b', 'c', 'd'); - * $list = array( - * 0 => 'foo', - * 1 => 'bar', - * 2 => array('foo' => 'baz'), - * ); - * - * - * @param mixed $value - * @param bool $allowEmpty Is an empty list a valid list? - * @return bool - */ - public static function isList($value, $allowEmpty = false) - { - if (!is_array($value)) { - return false; - } - - if (!$value) { - return $allowEmpty; - } - - return (array_values($value) === $value); - } - - /** - * Test whether an array is a hash table. - * - * An array is a hash table if: - * - * 1. Contains one or more non-integer keys, or - * 2. Integer keys are non-continuous or misaligned (not starting with 0) - * - * For example: - * - * $hash = array( - * 'foo' => 15, - * 'bar' => false, - * ); - * $hash = array( - * 1995 => 'Birth of PHP', - * 2009 => 'PHP 5.3.0', - * 2012 => 'PHP 5.4.0', - * ); - * $hash = array( - * 'formElement, - * 'options' => array( 'debug' => true ), - * ); - * - * - * @param mixed $value - * @param bool $allowEmpty Is an empty array() a valid hash table? - * @return bool - */ - public static function isHashTable($value, $allowEmpty = false) - { - if (!is_array($value)) { - return false; - } - - if (!$value) { - return $allowEmpty; - } - - return (array_values($value) !== $value); - } - - /** - * Checks if a value exists in an array. - * - * Due to "foo" == 0 === TRUE with in_array when strict = false, an option - * has been added to prevent this. When $strict = 0/false, the most secure - * non-strict check is implemented. if $strict = -1, the default in_array - * non-strict behaviour is used. - * - * @param mixed $needle - * @param array $haystack - * @param int|bool $strict - * @return bool - */ - public static function inArray($needle, array $haystack, $strict = false) - { - if (!$strict) { - if (is_int($needle) || is_float($needle)) { - $needle = (string) $needle; - } - if (is_string($needle)) { - foreach ($haystack as &$h) { - if (is_int($h) || is_float($h)) { - $h = (string) $h; - } - } - } - } - return in_array($needle, $haystack, $strict); - } - - /** - * Convert an iterator to an array. - * - * Converts an iterator to an array. The $recursive flag, on by default, - * hints whether or not you want to do so recursively. - * - * @param array|Traversable $iterator The array or Traversable object to convert - * @param bool $recursive Recursively check all nested structures - * @throws Exception\InvalidArgumentException if $iterator is not an array or a Traversable object - * @return array - */ - public static function iteratorToArray($iterator, $recursive = true) - { - if (!is_array($iterator) && !$iterator instanceof Traversable) { - throw new Exception\InvalidArgumentException(__METHOD__ . ' expects an array or Traversable object'); - } - - if (!$recursive) { - if (is_array($iterator)) { - return $iterator; - } - - return iterator_to_array($iterator); - } - - if (method_exists($iterator, 'toArray')) { - return $iterator->toArray(); - } - - $array = array(); - foreach ($iterator as $key => $value) { - if (is_scalar($value)) { - $array[$key] = $value; - continue; - } - - if ($value instanceof Traversable) { - $array[$key] = static::iteratorToArray($value, $recursive); - continue; - } - - if (is_array($value)) { - $array[$key] = static::iteratorToArray($value, $recursive); - continue; - } - - $array[$key] = $value; - } - - return $array; - } - - /** - * Merge two arrays together. - * - * If an integer key exists in both arrays and preserveNumericKeys is false, the value - * from the second array will be appended to the first array. If both values are arrays, they - * are merged together, else the value of the second array overwrites the one of the first array. - * - * @param array $a - * @param array $b - * @param bool $preserveNumericKeys - * @return array - */ - public static function merge(array $a, array $b, $preserveNumericKeys = false) - { - foreach ($b as $key => $value) { - if ($value instanceof MergeReplaceKeyInterface) { - $a[$key] = $value->getData(); - } elseif (isset($a[$key]) || array_key_exists($key, $a)) { - if ($value instanceof MergeRemoveKey) { - unset($a[$key]); - } elseif (!$preserveNumericKeys && is_int($key)) { - $a[] = $value; - } elseif (is_array($value) && is_array($a[$key])) { - $a[$key] = static::merge($a[$key], $value, $preserveNumericKeys); - } else { - $a[$key] = $value; - } - } else { - if (!$value instanceof MergeRemoveKey) { - $a[$key] = $value; - } - } - } - - return $a; - } - - /** - * Compatibility Method for array_filter on <5.6 systems - * - * @param array $data - * @param callable $callback - * @param null|int $flag - * @return array - */ - public static function filter(array $data, $callback, $flag = null) - { - if (! is_callable($callback)) { - throw new Exception\InvalidArgumentException(sprintf( - 'Second parameter of %s must be callable', - __METHOD__ - )); - } - - if (version_compare(PHP_VERSION, '5.6.0') >= 0) { - return array_filter($data, $callback, $flag); - } - - $output = array(); - foreach ($data as $key => $value) { - $params = array($value); - - if ($flag === static::ARRAY_FILTER_USE_BOTH) { - $params[] = $key; - } - - if ($flag === static::ARRAY_FILTER_USE_KEY) { - $params = array($key); - } - - $response = call_user_func_array($callback, $params); - if ($response) { - $output[$key] = $value; - } - } - - return $output; - } -} diff --git a/vendor/zendframework/zend-stdlib/src/ArrayUtils/MergeRemoveKey.php b/vendor/zendframework/zend-stdlib/src/ArrayUtils/MergeRemoveKey.php deleted file mode 100644 index 7c4d097..0000000 --- a/vendor/zendframework/zend-stdlib/src/ArrayUtils/MergeRemoveKey.php +++ /dev/null @@ -1,14 +0,0 @@ -data = $data; - } - - /** - * {@inheritDoc} - */ - public function getData() - { - return $this->data; - } -} diff --git a/vendor/zendframework/zend-stdlib/src/ArrayUtils/MergeReplaceKeyInterface.php b/vendor/zendframework/zend-stdlib/src/ArrayUtils/MergeReplaceKeyInterface.php deleted file mode 100644 index 725cf11..0000000 --- a/vendor/zendframework/zend-stdlib/src/ArrayUtils/MergeReplaceKeyInterface.php +++ /dev/null @@ -1,21 +0,0 @@ -metadata = $metadata; - $this->registerCallback($callback); - } - - /** - * Registers the callback provided in the constructor - * - * @param callable $callback - * @throws Exception\InvalidCallbackException - * @return void - */ - protected function registerCallback($callback) - { - if (!is_callable($callback)) { - throw new Exception\InvalidCallbackException('Invalid callback provided; not callable'); - } - - $this->callback = $callback; - } - - /** - * Retrieve registered callback - * - * @return callable - */ - public function getCallback() - { - return $this->callback; - } - - /** - * Invoke handler - * - * @param array $args Arguments to pass to callback - * @return mixed - */ - public function call(array $args = array()) - { - $callback = $this->getCallback(); - - // Minor performance tweak, if the callback gets called more than once - if (!isset(static::$isPhp54)) { - static::$isPhp54 = version_compare(PHP_VERSION, '5.4.0rc1', '>='); - } - - $argCount = count($args); - - if (static::$isPhp54 && is_string($callback)) { - $result = $this->validateStringCallbackFor54($callback); - - if ($result !== true && $argCount <= 3) { - $callback = $result; - // Minor performance tweak, if the callback gets called more - // than once - $this->callback = $result; - } - } - - // Minor performance tweak; use call_user_func() until > 3 arguments - // reached - switch ($argCount) { - case 0: - if (static::$isPhp54) { - return $callback(); - } - return call_user_func($callback); - case 1: - if (static::$isPhp54) { - return $callback(array_shift($args)); - } - return call_user_func($callback, array_shift($args)); - case 2: - $arg1 = array_shift($args); - $arg2 = array_shift($args); - if (static::$isPhp54) { - return $callback($arg1, $arg2); - } - return call_user_func($callback, $arg1, $arg2); - case 3: - $arg1 = array_shift($args); - $arg2 = array_shift($args); - $arg3 = array_shift($args); - if (static::$isPhp54) { - return $callback($arg1, $arg2, $arg3); - } - return call_user_func($callback, $arg1, $arg2, $arg3); - default: - return call_user_func_array($callback, $args); - } - } - - /** - * Invoke as functor - * - * @return mixed - */ - public function __invoke() - { - return $this->call(func_get_args()); - } - - /** - * Get all callback metadata - * - * @return array - */ - public function getMetadata() - { - return $this->metadata; - } - - /** - * Retrieve a single metadatum - * - * @param string $name - * @return mixed - */ - public function getMetadatum($name) - { - if (array_key_exists($name, $this->metadata)) { - return $this->metadata[$name]; - } - return; - } - - /** - * Validate a static method call - * - * Validates that a static method call in PHP 5.4 will actually work - * - * @param string $callback - * @return true|array - * @throws Exception\InvalidCallbackException if invalid - */ - protected function validateStringCallbackFor54($callback) - { - if (!strstr($callback, '::')) { - return true; - } - - list($class, $method) = explode('::', $callback, 2); - - if (!class_exists($class)) { - throw new Exception\InvalidCallbackException(sprintf( - 'Static method call "%s" refers to a class that does not exist', - $callback - )); - } - - $r = new ReflectionClass($class); - if (!$r->hasMethod($method)) { - throw new Exception\InvalidCallbackException(sprintf( - 'Static method call "%s" refers to a method that does not exist', - $callback - )); - } - $m = $r->getMethod($method); - if (!$m->isStatic()) { - throw new Exception\InvalidCallbackException(sprintf( - 'Static method call "%s" refers to a method that is not static', - $callback - )); - } - - // returning a non boolean value may not be nice for a validate method, - // but that allows the usage of a static string callback without using - // the call_user_func function. - return array($class, $method); - } -} diff --git a/vendor/zendframework/zend-stdlib/src/DateTime.php b/vendor/zendframework/zend-stdlib/src/DateTime.php deleted file mode 100644 index cdab67d..0000000 --- a/vendor/zendframework/zend-stdlib/src/DateTime.php +++ /dev/null @@ -1,47 +0,0 @@ - GLOB_MARK, - self::GLOB_NOSORT => GLOB_NOSORT, - self::GLOB_NOCHECK => GLOB_NOCHECK, - self::GLOB_NOESCAPE => GLOB_NOESCAPE, - self::GLOB_BRACE => GLOB_BRACE, - self::GLOB_ONLYDIR => GLOB_ONLYDIR, - self::GLOB_ERR => GLOB_ERR, - ); - - $globFlags = 0; - - foreach ($flagMap as $internalFlag => $globFlag) { - if ($flags & $internalFlag) { - $globFlags |= $globFlag; - } - } - } else { - $globFlags = 0; - } - - ErrorHandler::start(); - $res = glob($pattern, $globFlags); - $err = ErrorHandler::stop(); - if ($res === false) { - throw new Exception\RuntimeException("glob('{$pattern}', {$globFlags}) failed", 0, $err); - } - return $res; - } - - /** - * Expand braces manually, then use the system glob. - * - * @param string $pattern - * @param int $flags - * @return array - * @throws Exception\RuntimeException - */ - protected static function fallbackGlob($pattern, $flags) - { - if (!$flags & self::GLOB_BRACE) { - return static::systemGlob($pattern, $flags); - } - - $flags &= ~self::GLOB_BRACE; - $length = strlen($pattern); - $paths = array(); - - if ($flags & self::GLOB_NOESCAPE) { - $begin = strpos($pattern, '{'); - } else { - $begin = 0; - - while (true) { - if ($begin === $length) { - $begin = false; - break; - } elseif ($pattern[$begin] === '\\' && ($begin + 1) < $length) { - $begin++; - } elseif ($pattern[$begin] === '{') { - break; - } - - $begin++; - } - } - - if ($begin === false) { - return static::systemGlob($pattern, $flags); - } - - $next = static::nextBraceSub($pattern, $begin + 1, $flags); - - if ($next === null) { - return static::systemGlob($pattern, $flags); - } - - $rest = $next; - - while ($pattern[$rest] !== '}') { - $rest = static::nextBraceSub($pattern, $rest + 1, $flags); - - if ($rest === null) { - return static::systemGlob($pattern, $flags); - } - } - - $p = $begin + 1; - - while (true) { - $subPattern = substr($pattern, 0, $begin) - . substr($pattern, $p, $next - $p) - . substr($pattern, $rest + 1); - - $result = static::fallbackGlob($subPattern, $flags | self::GLOB_BRACE); - - if ($result) { - $paths = array_merge($paths, $result); - } - - if ($pattern[$next] === '}') { - break; - } - - $p = $next + 1; - $next = static::nextBraceSub($pattern, $p, $flags); - } - - return array_unique($paths); - } - - /** - * Find the end of the sub-pattern in a brace expression. - * - * @param string $pattern - * @param int $begin - * @param int $flags - * @return int|null - */ - protected static function nextBraceSub($pattern, $begin, $flags) - { - $length = strlen($pattern); - $depth = 0; - $current = $begin; - - while ($current < $length) { - if (!$flags & self::GLOB_NOESCAPE && $pattern[$current] === '\\') { - if (++$current === $length) { - break; - } - - $current++; - } else { - if (($pattern[$current] === '}' && $depth-- === 0) || ($pattern[$current] === ',' && $depth === 0)) { - break; - } elseif ($pattern[$current++] === '{') { - $depth++; - } - } - } - - return ($current < $length ? $current : null); - } -} diff --git a/vendor/zendframework/zend-stdlib/src/Guard/AllGuardsTrait.php b/vendor/zendframework/zend-stdlib/src/Guard/AllGuardsTrait.php deleted file mode 100644 index 95bc516..0000000 --- a/vendor/zendframework/zend-stdlib/src/Guard/AllGuardsTrait.php +++ /dev/null @@ -1,20 +0,0 @@ -strategies = new ArrayObject(); - $this->filterComposite = new FilterComposite(); - } - - /** - * Gets the strategy with the given name. - * - * @param string $name The name of the strategy to get. - * - * @throws \Zend\Stdlib\Exception\InvalidArgumentException - * @return StrategyInterface - */ - public function getStrategy($name) - { - if (isset($this->strategies[$name])) { - return $this->strategies[$name]; - } - - if (!isset($this->strategies['*'])) { - throw new Exception\InvalidArgumentException(sprintf( - '%s: no strategy by name of "%s", and no wildcard strategy present', - __METHOD__, - $name - )); - } - - return $this->strategies['*']; - } - - /** - * Checks if the strategy with the given name exists. - * - * @param string $name The name of the strategy to check for. - * @return bool - */ - public function hasStrategy($name) - { - return array_key_exists($name, $this->strategies) - || array_key_exists('*', $this->strategies); - } - - /** - * Adds the given strategy under the given name. - * - * @param string $name The name of the strategy to register. - * @param StrategyInterface $strategy The strategy to register. - * @return HydratorInterface - */ - public function addStrategy($name, StrategyInterface $strategy) - { - $this->strategies[$name] = $strategy; - return $this; - } - - /** - * Removes the strategy with the given name. - * - * @param string $name The name of the strategy to remove. - * @return HydratorInterface - */ - public function removeStrategy($name) - { - unset($this->strategies[$name]); - return $this; - } - - /** - * Converts a value for extraction. If no strategy exists the plain value is returned. - * - * @param string $name The name of the strategy to use. - * @param mixed $value The value that should be converted. - * @param mixed $object The object is optionally provided as context. - * @return mixed - */ - public function extractValue($name, $value, $object = null) - { - if ($this->hasStrategy($name)) { - $strategy = $this->getStrategy($name); - $value = $strategy->extract($value, $object); - } - return $value; - } - - /** - * Converts a value for hydration. If no strategy exists the plain value is returned. - * - * @param string $name The name of the strategy to use. - * @param mixed $value The value that should be converted. - * @param array $data The whole data is optionally provided as context. - * @return mixed - */ - public function hydrateValue($name, $value, $data = null) - { - if ($this->hasStrategy($name)) { - $strategy = $this->getStrategy($name); - $value = $strategy->hydrate($value, $data); - } - return $value; - } - - /** - * Convert a name for extraction. If no naming strategy exists, the plain value is returned. - * - * @param string $name The name to convert. - * @param null $object The object is optionally provided as context. - * @return mixed - */ - public function extractName($name, $object = null) - { - if ($this->hasNamingStrategy()) { - $name = $this->getNamingStrategy()->extract($name, $object); - } - return $name; - } - - /** - * Converts a value for hydration. If no naming strategy exists, the plain value is returned. - * - * @param string $name The name to convert. - * @param array $data The whole data is optionally provided as context. - * @return mixed - */ - public function hydrateName($name, $data = null) - { - if ($this->hasNamingStrategy()) { - $name = $this->getNamingStrategy()->hydrate($name, $data); - } - return $name; - } - - /** - * Get the filter instance - * - * @return Filter\FilterComposite - */ - public function getFilter() - { - return $this->filterComposite; - } - - /** - * Add a new filter to take care of what needs to be hydrated. - * To exclude e.g. the method getServiceLocator: - * - * - * $composite->addFilter("servicelocator", - * function ($property) { - * list($class, $method) = explode('::', $property); - * if ($method === 'getServiceLocator') { - * return false; - * } - * return true; - * }, FilterComposite::CONDITION_AND - * ); - * - * - * @param string $name Index in the composite - * @param callable|Filter\FilterInterface $filter - * @param int $condition - * @return Filter\FilterComposite - */ - public function addFilter($name, $filter, $condition = FilterComposite::CONDITION_OR) - { - return $this->filterComposite->addFilter($name, $filter, $condition); - } - - /** - * Check whether a specific filter exists at key $name or not - * - * @param string $name Index in the composite - * @return bool - */ - public function hasFilter($name) - { - return $this->filterComposite->hasFilter($name); - } - - /** - * Remove a filter from the composition. - * To not extract "has" methods, you simply need to unregister it - * - * - * $filterComposite->removeFilter('has'); - * - * - * @param $name - * @return Filter\FilterComposite - */ - public function removeFilter($name) - { - return $this->filterComposite->removeFilter($name); - } - - /** - * Adds the given naming strategy - * - * @param NamingStrategyInterface $strategy The naming to register. - * @return self - */ - public function setNamingStrategy(NamingStrategyInterface $strategy) - { - $this->namingStrategy = $strategy; - - return $this; - } - - /** - * Gets the naming strategy. - * - * @return NamingStrategyInterface - */ - public function getNamingStrategy() - { - return $this->namingStrategy; - } - - /** - * Checks if a naming strategy exists. - * - * @return bool - */ - public function hasNamingStrategy() - { - return isset($this->namingStrategy); - } - - /** - * Removes the naming strategy - * - * @return self - */ - public function removeNamingStrategy() - { - $this->namingStrategy = null; - - return $this; - } -} diff --git a/vendor/zendframework/zend-stdlib/src/Hydrator/Aggregate/AggregateHydrator.php b/vendor/zendframework/zend-stdlib/src/Hydrator/Aggregate/AggregateHydrator.php deleted file mode 100644 index 38a868e..0000000 --- a/vendor/zendframework/zend-stdlib/src/Hydrator/Aggregate/AggregateHydrator.php +++ /dev/null @@ -1,85 +0,0 @@ -getEventManager()->attachAggregate(new HydratorListener($hydrator), $priority); - } - - /** - * {@inheritDoc} - */ - public function extract($object) - { - $event = new ExtractEvent($this, $object); - - $this->getEventManager()->trigger($event); - - return $event->getExtractedData(); - } - - /** - * {@inheritDoc} - */ - public function hydrate(array $data, $object) - { - $event = new HydrateEvent($this, $object, $data); - - $this->getEventManager()->trigger($event); - - return $event->getHydratedObject(); - } - - /** - * {@inheritDoc} - */ - public function setEventManager(EventManagerInterface $eventManager) - { - $eventManager->setIdentifiers(array(__CLASS__, get_class($this))); - - $this->eventManager = $eventManager; - } - - /** - * {@inheritDoc} - */ - public function getEventManager() - { - if (null === $this->eventManager) { - $this->setEventManager(new EventManager()); - } - - return $this->eventManager; - } -} diff --git a/vendor/zendframework/zend-stdlib/src/Hydrator/Aggregate/ExtractEvent.php b/vendor/zendframework/zend-stdlib/src/Hydrator/Aggregate/ExtractEvent.php deleted file mode 100644 index b13bc5c..0000000 --- a/vendor/zendframework/zend-stdlib/src/Hydrator/Aggregate/ExtractEvent.php +++ /dev/null @@ -1,98 +0,0 @@ -target = $target; - $this->extractionObject = $extractionObject; - } - - /** - * Retrieves the object from which data is extracted - * - * @return object - */ - public function getExtractionObject() - { - return $this->extractionObject; - } - - /** - * @param object $extractionObject - * - * @return void - */ - public function setExtractionObject($extractionObject) - { - $this->extractionObject = $extractionObject; - } - - /** - * Retrieves the data that has been extracted - * - * @return array - */ - public function getExtractedData() - { - return $this->extractedData; - } - - /** - * @param array $extractedData - * - * @return void - */ - public function setExtractedData(array $extractedData) - { - $this->extractedData = $extractedData; - } - - /** - * Merge provided data with the extracted data - * - * @param array $additionalData - * - * @return void - */ - public function mergeExtractedData(array $additionalData) - { - $this->extractedData = array_merge($this->extractedData, $additionalData); - } -} diff --git a/vendor/zendframework/zend-stdlib/src/Hydrator/Aggregate/HydrateEvent.php b/vendor/zendframework/zend-stdlib/src/Hydrator/Aggregate/HydrateEvent.php deleted file mode 100644 index a7c91ee..0000000 --- a/vendor/zendframework/zend-stdlib/src/Hydrator/Aggregate/HydrateEvent.php +++ /dev/null @@ -1,84 +0,0 @@ -target = $target; - $this->hydratedObject = $hydratedObject; - $this->hydrationData = $hydrationData; - } - - /** - * Retrieves the object that is being hydrated - * - * @return object - */ - public function getHydratedObject() - { - return $this->hydratedObject; - } - - /** - * @param object $hydratedObject - */ - public function setHydratedObject($hydratedObject) - { - $this->hydratedObject = $hydratedObject; - } - - /** - * Retrieves the data that is being used for hydration - * - * @return array - */ - public function getHydrationData() - { - return $this->hydrationData; - } - - /** - * @param array $hydrationData - */ - public function setHydrationData(array $hydrationData) - { - $this->hydrationData = $hydrationData; - } -} diff --git a/vendor/zendframework/zend-stdlib/src/Hydrator/Aggregate/HydratorListener.php b/vendor/zendframework/zend-stdlib/src/Hydrator/Aggregate/HydratorListener.php deleted file mode 100644 index 1c25ff3..0000000 --- a/vendor/zendframework/zend-stdlib/src/Hydrator/Aggregate/HydratorListener.php +++ /dev/null @@ -1,80 +0,0 @@ -hydrator = $hydrator; - } - - /** - * {@inheritDoc} - */ - public function attach(EventManagerInterface $events, $priority = 1) - { - $this->listeners[] = $events->attach(HydrateEvent::EVENT_HYDRATE, array($this, 'onHydrate'), $priority); - $this->listeners[] = $events->attach(ExtractEvent::EVENT_EXTRACT, array($this, 'onExtract'), $priority); - } - - /** - * Callback to be used when {@see \Zend\Stdlib\Hydrator\Aggregate\HydrateEvent::EVENT_HYDRATE} is triggered - * - * @param \Zend\Stdlib\Hydrator\Aggregate\HydrateEvent $event - * - * @return object - * - * @internal - */ - public function onHydrate(HydrateEvent $event) - { - $object = $this->hydrator->hydrate($event->getHydrationData(), $event->getHydratedObject()); - - $event->setHydratedObject($object); - - return $object; - } - - /** - * Callback to be used when {@see \Zend\Stdlib\Hydrator\Aggregate\ExtractEvent::EVENT_EXTRACT} is triggered - * - * @param \Zend\Stdlib\Hydrator\Aggregate\ExtractEvent $event - * - * @return array - * - * @internal - */ - public function onExtract(ExtractEvent $event) - { - $data = $this->hydrator->extract($event->getExtractionObject()); - - $event->mergeExtractedData($data); - - return $data; - } -} diff --git a/vendor/zendframework/zend-stdlib/src/Hydrator/ArraySerializable.php b/vendor/zendframework/zend-stdlib/src/Hydrator/ArraySerializable.php deleted file mode 100644 index 4f4ab2a..0000000 --- a/vendor/zendframework/zend-stdlib/src/Hydrator/ArraySerializable.php +++ /dev/null @@ -1,83 +0,0 @@ -getArrayCopy(); - $filter = $this->getFilter(); - - foreach ($data as $name => $value) { - if (!$filter->filter($name)) { - unset($data[$name]); - continue; - } - $extractedName = $this->extractName($name, $object); - // replace the original key with extracted, if differ - if ($extractedName !== $name) { - unset($data[$name]); - $name = $extractedName; - } - $data[$name] = $this->extractValue($name, $value, $object); - } - - return $data; - } - - /** - * Hydrate an object - * - * Hydrates an object by passing $data to either its exchangeArray() or - * populate() method. - * - * @param array $data - * @param object $object - * @return object - * @throws Exception\BadMethodCallException for an $object not implementing exchangeArray() or populate() - */ - public function hydrate(array $data, $object) - { - $replacement = array(); - foreach ($data as $key => $value) { - $name = $this->hydrateName($key, $data); - $replacement[$name] = $this->hydrateValue($name, $value, $data); - } - - if (is_callable(array($object, 'exchangeArray'))) { - $object->exchangeArray($replacement); - } elseif (is_callable(array($object, 'populate'))) { - $object->populate($replacement); - } else { - throw new Exception\BadMethodCallException( - sprintf('%s expects the provided object to implement exchangeArray() or populate()', __METHOD__) - ); - } - return $object; - } -} diff --git a/vendor/zendframework/zend-stdlib/src/Hydrator/ClassMethods.php b/vendor/zendframework/zend-stdlib/src/Hydrator/ClassMethods.php deleted file mode 100644 index 4edb1f4..0000000 --- a/vendor/zendframework/zend-stdlib/src/Hydrator/ClassMethods.php +++ /dev/null @@ -1,274 +0,0 @@ -setUnderscoreSeparatedKeys($underscoreSeparatedKeys); - - $this->callableMethodFilter = new OptionalParametersFilter(); - - $this->filterComposite->addFilter('is', new IsFilter()); - $this->filterComposite->addFilter('has', new HasFilter()); - $this->filterComposite->addFilter('get', new GetFilter()); - $this->filterComposite->addFilter('parameter', new OptionalParametersFilter(), FilterComposite::CONDITION_AND); - } - - /** - * @param array|Traversable $options - * @return ClassMethods - * @throws Exception\InvalidArgumentException - */ - public function setOptions($options) - { - if ($options instanceof Traversable) { - $options = ArrayUtils::iteratorToArray($options); - } elseif (!is_array($options)) { - throw new Exception\InvalidArgumentException( - 'The options parameter must be an array or a Traversable' - ); - } - if (isset($options['underscoreSeparatedKeys'])) { - $this->setUnderscoreSeparatedKeys($options['underscoreSeparatedKeys']); - } - - return $this; - } - - /** - * @param bool $underscoreSeparatedKeys - * @return ClassMethods - */ - public function setUnderscoreSeparatedKeys($underscoreSeparatedKeys) - { - $this->underscoreSeparatedKeys = (bool) $underscoreSeparatedKeys; - - if ($this->underscoreSeparatedKeys) { - $this->setNamingStrategy(new UnderscoreNamingStrategy); - } elseif ($this->getNamingStrategy() instanceof UnderscoreNamingStrategy) { - $this->removeNamingStrategy(); - } - - return $this; - } - - /** - * @return bool - */ - public function getUnderscoreSeparatedKeys() - { - return $this->underscoreSeparatedKeys; - } - - /** - * Extract values from an object with class methods - * - * Extracts the getter/setter of the given $object. - * - * @param object $object - * @return array - * @throws Exception\BadMethodCallException for a non-object $object - */ - public function extract($object) - { - if (!is_object($object)) { - throw new Exception\BadMethodCallException(sprintf( - '%s expects the provided $object to be a PHP object)', - __METHOD__ - )); - } - - $objectClass = get_class($object); - - // reset the hydrator's hydrator's cache for this object, as the filter may be per-instance - if ($object instanceof FilterProviderInterface) { - $this->extractionMethodsCache[$objectClass] = null; - } - - // pass 1 - finding out which properties can be extracted, with which methods (populate hydration cache) - if (! isset($this->extractionMethodsCache[$objectClass])) { - $this->extractionMethodsCache[$objectClass] = array(); - $filter = $this->filterComposite; - $methods = get_class_methods($object); - - if ($object instanceof FilterProviderInterface) { - $filter = new FilterComposite( - array($object->getFilter()), - array(new MethodMatchFilter('getFilter')) - ); - } - - foreach ($methods as $method) { - $methodFqn = $objectClass . '::' . $method; - - if (! ($filter->filter($methodFqn) && $this->callableMethodFilter->filter($methodFqn))) { - continue; - } - - $attribute = $method; - - if (strpos($method, 'get') === 0) { - $attribute = substr($method, 3); - if (!property_exists($object, $attribute)) { - $attribute = lcfirst($attribute); - } - } - - $this->extractionMethodsCache[$objectClass][$method] = $attribute; - } - } - - $values = array(); - - // pass 2 - actually extract data - foreach ($this->extractionMethodsCache[$objectClass] as $methodName => $attributeName) { - $realAttributeName = $this->extractName($attributeName, $object); - $values[$realAttributeName] = $this->extractValue($realAttributeName, $object->$methodName(), $object); - } - - return $values; - } - - /** - * Hydrate an object by populating getter/setter methods - * - * Hydrates an object by getter/setter methods of the object. - * - * @param array $data - * @param object $object - * @return object - * @throws Exception\BadMethodCallException for a non-object $object - */ - public function hydrate(array $data, $object) - { - if (!is_object($object)) { - throw new Exception\BadMethodCallException(sprintf( - '%s expects the provided $object to be a PHP object)', - __METHOD__ - )); - } - - $objectClass = get_class($object); - - foreach ($data as $property => $value) { - $propertyFqn = $objectClass . '::$' . $property; - - if (! isset($this->hydrationMethodsCache[$propertyFqn])) { - $setterName = 'set' . ucfirst($this->hydrateName($property, $data)); - - $this->hydrationMethodsCache[$propertyFqn] = is_callable(array($object, $setterName)) - ? $setterName - : false; - } - - if ($this->hydrationMethodsCache[$propertyFqn]) { - $object->{$this->hydrationMethodsCache[$propertyFqn]}($this->hydrateValue($property, $value, $data)); - } - } - - return $object; - } - - /** - * {@inheritDoc} - */ - public function addFilter($name, $filter, $condition = FilterComposite::CONDITION_OR) - { - $this->resetCaches(); - - return parent::addFilter($name, $filter, $condition); - } - - /** - * {@inheritDoc} - */ - public function removeFilter($name) - { - $this->resetCaches(); - - return parent::removeFilter($name); - } - - /** - * {@inheritDoc} - */ - public function setNamingStrategy(NamingStrategyInterface $strategy) - { - $this->resetCaches(); - - return parent::setNamingStrategy($strategy); - } - - /** - * {@inheritDoc} - */ - public function removeNamingStrategy() - { - $this->resetCaches(); - - return parent::removeNamingStrategy(); - } - - /** - * Reset all local hydration/extraction caches - */ - private function resetCaches() - { - $this->hydrationMethodsCache = $this->extractionMethodsCache = array(); - } -} diff --git a/vendor/zendframework/zend-stdlib/src/Hydrator/DelegatingHydrator.php b/vendor/zendframework/zend-stdlib/src/Hydrator/DelegatingHydrator.php deleted file mode 100644 index db234d3..0000000 --- a/vendor/zendframework/zend-stdlib/src/Hydrator/DelegatingHydrator.php +++ /dev/null @@ -1,57 +0,0 @@ -hydrators = $hydrators; - } - - /** - * {@inheritdoc} - */ - public function hydrate(array $data, $object) - { - return $this->getHydrator($object)->hydrate($data, $object); - } - - /** - * {@inheritdoc} - */ - public function extract($object) - { - return $this->getHydrator($object)->extract($object); - } - - /** - * Gets hydrator of an object - * - * @param object $object - * @return HydratorInterface - */ - protected function getHydrator($object) - { - return $this->hydrators->get(get_class($object)); - } -} diff --git a/vendor/zendframework/zend-stdlib/src/Hydrator/DelegatingHydratorFactory.php b/vendor/zendframework/zend-stdlib/src/Hydrator/DelegatingHydratorFactory.php deleted file mode 100644 index c3a0da2..0000000 --- a/vendor/zendframework/zend-stdlib/src/Hydrator/DelegatingHydratorFactory.php +++ /dev/null @@ -1,29 +0,0 @@ -orFilter = new ArrayObject($orFilter); - $this->andFilter = new ArrayObject($andFilter); - } - - /** - * Add a filter to the composite. Has to be indexed with $name in - * order to identify a specific filter. - * - * This example will exclude all methods from the hydration, that starts with 'getService' - * - * $composite->addFilter('exclude', - * function ($method) { - * if (preg_match('/^getService/', $method) { - * return false; - * } - * return true; - * }, FilterComposite::CONDITION_AND - * ); - * - * - * @param string $name - * @param callable|FilterInterface $filter - * @param int $condition Can be either FilterComposite::CONDITION_OR or FilterComposite::CONDITION_AND - * @throws InvalidArgumentException - * @return FilterComposite - */ - public function addFilter($name, $filter, $condition = self::CONDITION_OR) - { - if (!is_callable($filter) && !($filter instanceof FilterInterface)) { - throw new InvalidArgumentException( - 'The value of ' . $name . ' should be either a callable or ' . - 'an instance of Zend\Stdlib\Hydrator\Filter\FilterInterface' - ); - } - - if ($condition === self::CONDITION_OR) { - $this->orFilter[$name] = $filter; - } elseif ($condition === self::CONDITION_AND) { - $this->andFilter[$name] = $filter; - } - - return $this; - } - - /** - * Remove a filter from the composition - * - * @param $name string Identifier for the filter - * @return FilterComposite - */ - public function removeFilter($name) - { - if (isset($this->orFilter[$name])) { - unset($this->orFilter[$name]); - } - - if (isset($this->andFilter[$name])) { - unset($this->andFilter[$name]); - } - - return $this; - } - - /** - * Check if $name has a filter registered - * - * @param $name string Identifier for the filter - * @return bool - */ - public function hasFilter($name) - { - return isset($this->orFilter[$name]) || isset($this->andFilter[$name]); - } - - /** - * Filter the composite based on the AND and OR condition - * Will return true if one from the "or conditions" and all from - * the "and condition" returns true. Otherwise false - * - * @param $property string Parameter will be e.g. Parent\Namespace\Class::method - * @return bool - */ - public function filter($property) - { - $andCount = count($this->andFilter); - $orCount = count($this->orFilter); - // return true if no filters are registered - if ($orCount === 0 && $andCount === 0) { - return true; - } elseif ($orCount === 0 && $andCount !== 0) { - $returnValue = true; - } else { - $returnValue = false; - } - - // Check if 1 from the or filters return true - foreach ($this->orFilter as $filter) { - if (is_callable($filter)) { - if ($filter($property) === true) { - $returnValue = true; - break; - } - continue; - } else { - if ($filter->filter($property) === true) { - $returnValue = true; - break; - } - } - } - - // Check if all of the and condition return true - foreach ($this->andFilter as $filter) { - if (is_callable($filter)) { - if ($filter($property) === false) { - return false; - } - continue; - } else { - if ($filter->filter($property) === false) { - return false; - } - } - } - - return $returnValue; - } -} diff --git a/vendor/zendframework/zend-stdlib/src/Hydrator/Filter/FilterInterface.php b/vendor/zendframework/zend-stdlib/src/Hydrator/Filter/FilterInterface.php deleted file mode 100644 index 16df098..0000000 --- a/vendor/zendframework/zend-stdlib/src/Hydrator/Filter/FilterInterface.php +++ /dev/null @@ -1,21 +0,0 @@ -method = $method; - $this->exclude = $exclude; - } - - public function filter($property) - { - $pos = strpos($property, '::'); - if ($pos !== false) { - $pos += 2; - } else { - $pos = 0; - } - if (substr($property, $pos) === $this->method) { - return !$this->exclude; - } - return $this->exclude; - } -} diff --git a/vendor/zendframework/zend-stdlib/src/Hydrator/Filter/NumberOfParameterFilter.php b/vendor/zendframework/zend-stdlib/src/Hydrator/Filter/NumberOfParameterFilter.php deleted file mode 100644 index 1254b63..0000000 --- a/vendor/zendframework/zend-stdlib/src/Hydrator/Filter/NumberOfParameterFilter.php +++ /dev/null @@ -1,49 +0,0 @@ -numberOfParameters = (int) $numberOfParameters; - } - - /** - * @param string $property the name of the property - * @return bool - * @throws InvalidArgumentException - */ - public function filter($property) - { - try { - $reflectionMethod = new ReflectionMethod($property); - } catch (ReflectionException $exception) { - throw new InvalidArgumentException( - "Method $property doesn't exist" - ); - } - - return $reflectionMethod->getNumberOfParameters() === $this->numberOfParameters; - } -} diff --git a/vendor/zendframework/zend-stdlib/src/Hydrator/Filter/OptionalParametersFilter.php b/vendor/zendframework/zend-stdlib/src/Hydrator/Filter/OptionalParametersFilter.php deleted file mode 100644 index ccd67ca..0000000 --- a/vendor/zendframework/zend-stdlib/src/Hydrator/Filter/OptionalParametersFilter.php +++ /dev/null @@ -1,54 +0,0 @@ -getParameters(), - function (ReflectionParameter $parameter) { - return ! $parameter->isOptional(); - } - ); - - return static::$propertiesCache[$property] = empty($mandatoryParameters); - } -} diff --git a/vendor/zendframework/zend-stdlib/src/Hydrator/FilterEnabledInterface.php b/vendor/zendframework/zend-stdlib/src/Hydrator/FilterEnabledInterface.php deleted file mode 100644 index 380aade..0000000 --- a/vendor/zendframework/zend-stdlib/src/Hydrator/FilterEnabledInterface.php +++ /dev/null @@ -1,63 +0,0 @@ - - * $composite->addFilter( - * "servicelocator", - * function ($property) { - * list($class, $method) = explode('::', $property); - * if ($method === 'getServiceLocator') { - * return false; - * } - * return true; - * }, - * FilterComposite::CONDITION_AND - * ); - * - * - * @param string $name Index in the composite - * @param callable|FilterInterface $filter - * @param int $condition - * @return FilterComposite - */ - public function addFilter($name, $filter, $condition = FilterComposite::CONDITION_OR); - - /** - * Check whether a specific filter exists at key $name or not - * - * @param string $name Index in the composite - * @return bool - */ - public function hasFilter($name); - - /** - * Remove a filter from the composition. - * To not extract "has" methods, you simply need to unregister it - * - * - * $filterComposite->removeFilter('has'); - * - * - * @param $name - * @return FilterComposite - */ - public function removeFilter($name); -} diff --git a/vendor/zendframework/zend-stdlib/src/Hydrator/HydrationInterface.php b/vendor/zendframework/zend-stdlib/src/Hydrator/HydrationInterface.php deleted file mode 100644 index e7deff4..0000000 --- a/vendor/zendframework/zend-stdlib/src/Hydrator/HydrationInterface.php +++ /dev/null @@ -1,22 +0,0 @@ -hydrator = $hydrator; - - return $this; - } - - /** - * Retrieve hydrator - * - * @param void - * @return null|HydratorInterface - * @access public - */ - public function getHydrator() - { - return $this->hydrator; - } -} diff --git a/vendor/zendframework/zend-stdlib/src/Hydrator/HydratorInterface.php b/vendor/zendframework/zend-stdlib/src/Hydrator/HydratorInterface.php deleted file mode 100644 index bc9983d..0000000 --- a/vendor/zendframework/zend-stdlib/src/Hydrator/HydratorInterface.php +++ /dev/null @@ -1,16 +0,0 @@ - 'Zend\Stdlib\Hydrator\DelegatingHydrator', - ); - - /** - * Default set of adapters - * - * @var array - */ - protected $invokableClasses = array( - 'arrayserializable' => 'Zend\Stdlib\Hydrator\ArraySerializable', - 'classmethods' => 'Zend\Stdlib\Hydrator\ClassMethods', - 'objectproperty' => 'Zend\Stdlib\Hydrator\ObjectProperty', - 'reflection' => 'Zend\Stdlib\Hydrator\Reflection' - ); - - /** - * Default factory-based adapters - * - * @var array - */ - protected $factories = array( - 'Zend\Stdlib\Hydrator\DelegatingHydrator' => 'Zend\Stdlib\Hydrator\DelegatingHydratorFactory', - ); - - /** - * {@inheritDoc} - */ - public function validatePlugin($plugin) - { - if ($plugin instanceof HydratorInterface) { - // we're okay - return; - } - - throw new Exception\RuntimeException(sprintf( - 'Plugin of type %s is invalid; must implement Zend\Stdlib\Hydrator\HydratorInterface', - (is_object($plugin) ? get_class($plugin) : gettype($plugin)) - )); - } -} diff --git a/vendor/zendframework/zend-stdlib/src/Hydrator/NamingStrategy/ArrayMapNamingStrategy.php b/vendor/zendframework/zend-stdlib/src/Hydrator/NamingStrategy/ArrayMapNamingStrategy.php deleted file mode 100644 index 962303a..0000000 --- a/vendor/zendframework/zend-stdlib/src/Hydrator/NamingStrategy/ArrayMapNamingStrategy.php +++ /dev/null @@ -1,51 +0,0 @@ -extractionMap = $extractionMap; - $this->hydrationMap = array_flip($extractionMap); - } - - /** - * {@inheritDoc} - */ - public function hydrate($name) - { - return isset($this->hydrationMap[$name]) ? $this->hydrationMap[$name] : $name; - } - - /** - * {@inheritDoc} - */ - public function extract($name) - { - return isset($this->extractionMap[$name]) ? $this->extractionMap[$name] : $name; - } -} diff --git a/vendor/zendframework/zend-stdlib/src/Hydrator/NamingStrategy/CompositeNamingStrategy.php b/vendor/zendframework/zend-stdlib/src/Hydrator/NamingStrategy/CompositeNamingStrategy.php deleted file mode 100644 index 0887e92..0000000 --- a/vendor/zendframework/zend-stdlib/src/Hydrator/NamingStrategy/CompositeNamingStrategy.php +++ /dev/null @@ -1,64 +0,0 @@ -namingStrategies = array_map( - function (NamingStrategyInterface $strategy) { - // this callback is here only to ensure type-safety - return $strategy; - }, - $strategies - ); - - $this->defaultNamingStrategy = $defaultNamingStrategy ?: new IdentityNamingStrategy(); - } - - /** - * {@inheritDoc} - */ - public function extract($name) - { - $strategy = isset($this->namingStrategies[$name]) - ? $this->namingStrategies[$name] - : $this->defaultNamingStrategy; - - return $strategy->extract($name); - } - - /** - * {@inheritDoc} - */ - public function hydrate($name) - { - $strategy = isset($this->namingStrategies[$name]) - ? $this->namingStrategies[$name] - : $this->defaultNamingStrategy; - - return $strategy->hydrate($name); - } -} diff --git a/vendor/zendframework/zend-stdlib/src/Hydrator/NamingStrategy/IdentityNamingStrategy.php b/vendor/zendframework/zend-stdlib/src/Hydrator/NamingStrategy/IdentityNamingStrategy.php deleted file mode 100644 index ee4b328..0000000 --- a/vendor/zendframework/zend-stdlib/src/Hydrator/NamingStrategy/IdentityNamingStrategy.php +++ /dev/null @@ -1,29 +0,0 @@ -mapping = $mapping; - $this->reverse = $reverse ?: $this->flipMapping($mapping); - } - - /** - * Safelly flip mapping array. - * - * @param array $array Array to flip - * @return array Flipped array - * @throws InvalidArgumentException - */ - protected function flipMapping(array $array) - { - array_walk($array, function ($value) { - if (!is_string($value) && !is_int($value)) { - throw new InvalidArgumentException('Mapping array can\'t be flipped because of invalid value'); - } - }); - - return array_flip($array); - } - - /** - * Converts the given name so that it can be extracted by the hydrator. - * - * @param string $name The original name - * @return mixed The hydrated name - */ - public function hydrate($name) - { - if (array_key_exists($name, $this->mapping)) { - return $this->mapping[$name]; - } - - return $name; - } - - /** - * Converts the given name so that it can be hydrated by the hydrator. - * - * @param string $name The original name - * @return mixed The extracted name - */ - public function extract($name) - { - if (array_key_exists($name, $this->reverse)) { - return $this->reverse[$name]; - } - - return $name; - } -} diff --git a/vendor/zendframework/zend-stdlib/src/Hydrator/NamingStrategy/NamingStrategyInterface.php b/vendor/zendframework/zend-stdlib/src/Hydrator/NamingStrategy/NamingStrategyInterface.php deleted file mode 100644 index ff99385..0000000 --- a/vendor/zendframework/zend-stdlib/src/Hydrator/NamingStrategy/NamingStrategyInterface.php +++ /dev/null @@ -1,37 +0,0 @@ -getUnderscoreToStudlyCaseFilter()->filter($name); - } - - /** - * Remove capitalized letters and prepend underscores. - * - * @param string $name - * @return string - */ - public function extract($name) - { - return $this->getCamelCaseToUnderscoreFilter()->filter($name); - } - - /** - * @return FilterChain - */ - protected function getUnderscoreToStudlyCaseFilter() - { - if (static::$underscoreToStudlyCaseFilter instanceof FilterChain) { - return static::$underscoreToStudlyCaseFilter; - } - - $filter = new FilterChain(); - - $filter->attachByName('WordUnderscoreToStudlyCase'); - - return static::$underscoreToStudlyCaseFilter = $filter; - } - - /** - * @return FilterChain - */ - protected function getCamelCaseToUnderscoreFilter() - { - if (static::$camelCaseToUnderscoreFilter instanceof FilterChain) { - return static::$camelCaseToUnderscoreFilter; - } - - $filter = new FilterChain(); - - $filter->attachByName('WordCamelCaseToUnderscore'); - $filter->attachByName('StringToLower'); - - return static::$camelCaseToUnderscoreFilter = $filter; - } -} diff --git a/vendor/zendframework/zend-stdlib/src/Hydrator/NamingStrategyEnabledInterface.php b/vendor/zendframework/zend-stdlib/src/Hydrator/NamingStrategyEnabledInterface.php deleted file mode 100644 index f9c6288..0000000 --- a/vendor/zendframework/zend-stdlib/src/Hydrator/NamingStrategyEnabledInterface.php +++ /dev/null @@ -1,44 +0,0 @@ -getFilter(); - - foreach ($data as $name => $value) { - // Filter keys, removing any we don't want - if (! $filter->filter($name)) { - unset($data[$name]); - continue; - } - - // Replace name if extracted differ - $extracted = $this->extractName($name, $object); - - if ($extracted !== $name) { - unset($data[$name]); - $name = $extracted; - } - - $data[$name] = $this->extractValue($name, $value, $object); - } - - return $data; - } - - /** - * {@inheritDoc} - * - * Hydrate an object by populating public properties - * - * Hydrates an object by setting public properties of the object. - * - * @throws Exception\BadMethodCallException for a non-object $object - */ - public function hydrate(array $data, $object) - { - if (!is_object($object)) { - throw new Exception\BadMethodCallException( - sprintf('%s expects the provided $object to be a PHP object)', __METHOD__) - ); - } - - $properties = & self::$skippedPropertiesCache[get_class($object)]; - - if (! isset($properties)) { - $reflection = new ReflectionClass($object); - $properties = array_fill_keys( - array_map( - function (ReflectionProperty $property) { - return $property->getName(); - }, - $reflection->getProperties( - ReflectionProperty::IS_PRIVATE - + ReflectionProperty::IS_PROTECTED - + ReflectionProperty::IS_STATIC - ) - ), - true - ); - } - - foreach ($data as $name => $value) { - $property = $this->hydrateName($name, $data); - - if (isset($properties[$property])) { - continue; - } - - $object->$property = $this->hydrateValue($property, $value, $data); - } - - return $object; - } -} diff --git a/vendor/zendframework/zend-stdlib/src/Hydrator/Reflection.php b/vendor/zendframework/zend-stdlib/src/Hydrator/Reflection.php deleted file mode 100644 index ea8e2d2..0000000 --- a/vendor/zendframework/zend-stdlib/src/Hydrator/Reflection.php +++ /dev/null @@ -1,95 +0,0 @@ -extractName($property->getName(), $object); - if (!$this->filterComposite->filter($propertyName)) { - continue; - } - - $value = $property->getValue($object); - $result[$propertyName] = $this->extractValue($propertyName, $value, $object); - } - - return $result; - } - - /** - * Hydrate $object with the provided $data. - * - * @param array $data - * @param object $object - * @return object - */ - public function hydrate(array $data, $object) - { - $reflProperties = self::getReflProperties($object); - foreach ($data as $key => $value) { - $name = $this->hydrateName($key, $data); - if (isset($reflProperties[$name])) { - $reflProperties[$name]->setValue($object, $this->hydrateValue($name, $value, $data)); - } - } - return $object; - } - - /** - * Get a reflection properties from in-memory cache and lazy-load if - * class has not been loaded. - * - * @param string|object $input - * @throws Exception\InvalidArgumentException - * @return \ReflectionProperty[] - */ - protected static function getReflProperties($input) - { - if (is_object($input)) { - $input = get_class($input); - } elseif (!is_string($input)) { - throw new Exception\InvalidArgumentException('Input must be a string or an object.'); - } - - if (isset(static::$reflProperties[$input])) { - return static::$reflProperties[$input]; - } - - static::$reflProperties[$input] = array(); - $reflClass = new ReflectionClass($input); - $reflProperties = $reflClass->getProperties(); - - foreach ($reflProperties as $property) { - $property->setAccessible(true); - static::$reflProperties[$input][$property->getName()] = $property; - } - - return static::$reflProperties[$input]; - } -} diff --git a/vendor/zendframework/zend-stdlib/src/Hydrator/Strategy/BooleanStrategy.php b/vendor/zendframework/zend-stdlib/src/Hydrator/Strategy/BooleanStrategy.php deleted file mode 100644 index 3c29231..0000000 --- a/vendor/zendframework/zend-stdlib/src/Hydrator/Strategy/BooleanStrategy.php +++ /dev/null @@ -1,106 +0,0 @@ -trueValue = $trueValue; - $this->falseValue = $falseValue; - } - - /** - * Converts the given value so that it can be extracted by the hydrator. - * - * @param bool $value The original value. - * @throws InvalidArgumentException - * @return int|string Returns the value that should be extracted. - */ - public function extract($value) - { - if (!is_bool($value)) { - throw new InvalidArgumentException(sprintf( - 'Unable to extract. Expected bool. %s was given.', - is_object($value) ? get_class($value) : gettype($value) - )); - } - - return $value === true ? $this->trueValue : $this->falseValue; - } - - /** - * Converts the given value so that it can be hydrated by the hydrator. - * - * @param int|string $value The original value. - * @throws InvalidArgumentException - * @return bool Returns the value that should be hydrated. - */ - public function hydrate($value) - { - if (!is_string($value) && !is_int($value)) { - throw new InvalidArgumentException(sprintf( - 'Unable to hydrate. Expected string or int. %s was given.', - is_object($value) ? get_class($value) : gettype($value) - )); - } - - if ($value === $this->trueValue) { - return true; - } - - if ($value === $this->falseValue) { - return false; - } - - throw new InvalidArgumentException(sprintf( - 'Unexpected value %s can\'t be hydrated. Expect %s or %s as Value.', - $value, - $this->trueValue, - $this->falseValue - )); - } -} diff --git a/vendor/zendframework/zend-stdlib/src/Hydrator/Strategy/ClosureStrategy.php b/vendor/zendframework/zend-stdlib/src/Hydrator/Strategy/ClosureStrategy.php deleted file mode 100644 index bf456a7..0000000 --- a/vendor/zendframework/zend-stdlib/src/Hydrator/Strategy/ClosureStrategy.php +++ /dev/null @@ -1,102 +0,0 @@ -addStrategy('category', new ClosureStrategy( - * function (Category $value) { - * return (int) $value->id; - * }, - * function ($value) { - * return new Category((int) $value); - * } - * )); - * - * @param callable $extractFunc - anonymous function, that extract values - * from object - * @param callable $hydrateFunc - anonymous function, that hydrate values - * into object - */ - public function __construct($extractFunc = null, $hydrateFunc = null) - { - if (isset($extractFunc)) { - if (!is_callable($extractFunc)) { - throw new \Exception('$extractFunc must be callable'); - } - - $this->extractFunc = $extractFunc; - } else { - $this->extractFunc = function ($value) { - return $value; - }; - } - - if (isset($hydrateFunc)) { - if (!is_callable($hydrateFunc)) { - throw new \Exception('$hydrateFunc must be callable'); - } - - $this->hydrateFunc = $hydrateFunc; - } else { - $this->hydrateFunc = function ($value) { - return $value; - }; - } - } - - /** - * Converts the given value so that it can be extracted by the hydrator. - * - * @param mixed $value The original value. - * @param array $object The object is optionally provided as context. - * @return mixed Returns the value that should be extracted. - */ - public function extract($value, $object = null) - { - $func = $this->extractFunc; - - return $func($value, $object); - } - - /** - * Converts the given value so that it can be hydrated by the hydrator. - * - * @param mixed $value The original value. - * @param array $data The whole data is optionally provided as context. - * @return mixed Returns the value that should be hydrated. - */ - public function hydrate($value, $data = null) - { - $func = $this->hydrateFunc; - - return $func($value, $data); - } -} diff --git a/vendor/zendframework/zend-stdlib/src/Hydrator/Strategy/DateTimeFormatterStrategy.php b/vendor/zendframework/zend-stdlib/src/Hydrator/Strategy/DateTimeFormatterStrategy.php deleted file mode 100644 index 62d92c5..0000000 --- a/vendor/zendframework/zend-stdlib/src/Hydrator/Strategy/DateTimeFormatterStrategy.php +++ /dev/null @@ -1,80 +0,0 @@ -format = (string) $format; - $this->timezone = $timezone; - } - - /** - * {@inheritDoc} - * - * Converts to date time string - * - * @param mixed|DateTime $value - * - * @return mixed|string - */ - public function extract($value) - { - if ($value instanceof DateTime) { - return $value->format($this->format); - } - - return $value; - } - - /** - * Converts date time string to DateTime instance for injecting to object - * - * {@inheritDoc} - * - * @param mixed|string $value - * - * @return mixed|DateTime - */ - public function hydrate($value) - { - if ($value === '' || $value === null) { - return; - } - - if ($this->timezone) { - $hydrated = DateTime::createFromFormat($this->format, $value, $this->timezone); - } else { - $hydrated = DateTime::createFromFormat($this->format, $value); - } - - return $hydrated ?: $value; - } -} diff --git a/vendor/zendframework/zend-stdlib/src/Hydrator/Strategy/DefaultStrategy.php b/vendor/zendframework/zend-stdlib/src/Hydrator/Strategy/DefaultStrategy.php deleted file mode 100644 index b2c5c29..0000000 --- a/vendor/zendframework/zend-stdlib/src/Hydrator/Strategy/DefaultStrategy.php +++ /dev/null @@ -1,35 +0,0 @@ -setValueDelimiter($delimiter); - - $this->explodeLimit = ($explodeLimit === null) ? null : (int) $explodeLimit; - } - - /** - * Sets the delimiter string that the values will be split upon - * - * @param string $delimiter - * @return self - */ - private function setValueDelimiter($delimiter) - { - if (!is_string($delimiter)) { - throw new Exception\InvalidArgumentException(sprintf( - '%s expects Delimiter to be string, %s provided instead', - __METHOD__, - is_object($delimiter) ? get_class($delimiter) : gettype($delimiter) - )); - } - - if (empty($delimiter)) { - throw new Exception\InvalidArgumentException('Delimiter cannot be empty.'); - } - - $this->valueDelimiter = $delimiter; - } - - /** - * {@inheritDoc} - * - * Split a string by delimiter - * - * @param string|null $value - * - * @return string[] - * - * @throws Exception\InvalidArgumentException - */ - public function hydrate($value) - { - if (null === $value) { - return array(); - } - - if (!(is_string($value) || is_numeric($value))) { - throw new Exception\InvalidArgumentException(sprintf( - '%s expects argument 1 to be string, %s provided instead', - __METHOD__, - is_object($value) ? get_class($value) : gettype($value) - )); - } - - if ($this->explodeLimit !== null) { - return explode($this->valueDelimiter, $value, $this->explodeLimit); - } - - return explode($this->valueDelimiter, $value); - } - - /** - * {@inheritDoc} - * - * Join array elements with delimiter - * - * @param string[] $value The original value. - * - * @return string|null - */ - public function extract($value) - { - if (!is_array($value)) { - throw new Exception\InvalidArgumentException(sprintf( - '%s expects argument 1 to be array, %s provided instead', - __METHOD__, - is_object($value) ? get_class($value) : gettype($value) - )); - } - - return empty($value) ? null : implode($this->valueDelimiter, $value); - } -} diff --git a/vendor/zendframework/zend-stdlib/src/Hydrator/Strategy/SerializableStrategy.php b/vendor/zendframework/zend-stdlib/src/Hydrator/Strategy/SerializableStrategy.php deleted file mode 100644 index 260efa3..0000000 --- a/vendor/zendframework/zend-stdlib/src/Hydrator/Strategy/SerializableStrategy.php +++ /dev/null @@ -1,123 +0,0 @@ -setSerializer($serializer); - if ($serializerOptions) { - $this->setSerializerOptions($serializerOptions); - } - } - - /** - * Serialize the given value so that it can be extracted by the hydrator. - * - * @param mixed $value The original value. - * @return mixed Returns the value that should be extracted. - */ - public function extract($value) - { - $serializer = $this->getSerializer(); - return $serializer->serialize($value); - } - - /** - * Unserialize the given value so that it can be hydrated by the hydrator. - * - * @param mixed $value The original value. - * @return mixed Returns the value that should be hydrated. - */ - public function hydrate($value) - { - $serializer = $this->getSerializer(); - return $serializer->unserialize($value); - } - - /** - * Set serializer - * - * @param string|SerializerAdapter $serializer - * @return SerializableStrategy - */ - public function setSerializer($serializer) - { - if (!is_string($serializer) && !$serializer instanceof SerializerAdapter) { - throw new InvalidArgumentException(sprintf( - '%s expects either a string serializer name or Zend\Serializer\Adapter\AdapterInterface instance; ' - . 'received "%s"', - __METHOD__, - (is_object($serializer) ? get_class($serializer) : gettype($serializer)) - )); - } - $this->serializer = $serializer; - return $this; - } - - /** - * Get serializer - * - * @return SerializerAdapter - */ - public function getSerializer() - { - if (is_string($this->serializer)) { - $options = $this->getSerializerOptions(); - $this->setSerializer(SerializerFactory::factory($this->serializer, $options)); - } elseif (null === $this->serializer) { - $this->setSerializer(SerializerFactory::getDefaultAdapter()); - } - - return $this->serializer; - } - - /** - * Set configuration options for instantiating a serializer adapter - * - * @param mixed $serializerOptions - * @return SerializableStrategy - */ - public function setSerializerOptions($serializerOptions) - { - $this->serializerOptions = $serializerOptions; - return $this; - } - - /** - * Get configuration options for instantiating a serializer adapter - * - * @return mixed - */ - public function getSerializerOptions() - { - return $this->serializerOptions; - } -} diff --git a/vendor/zendframework/zend-stdlib/src/Hydrator/Strategy/StrategyChain.php b/vendor/zendframework/zend-stdlib/src/Hydrator/Strategy/StrategyChain.php deleted file mode 100644 index a9316bb..0000000 --- a/vendor/zendframework/zend-stdlib/src/Hydrator/Strategy/StrategyChain.php +++ /dev/null @@ -1,73 +0,0 @@ -extractionStrategies = array_map( - function (StrategyInterface $strategy) { - // this callback is here only to ensure type-safety - return $strategy; - }, - $extractionStrategies - ); - - $this->hydrationStrategies = array_reverse($extractionStrategies); - } - - /** - * {@inheritDoc} - */ - public function extract($value) - { - foreach ($this->extractionStrategies as $strategy) { - $value = $strategy->extract($value); - } - - return $value; - } - - /** - * {@inheritDoc} - */ - public function hydrate($value) - { - foreach ($this->hydrationStrategies as $strategy) { - $value = $strategy->hydrate($value); - } - - return $value; - } -} diff --git a/vendor/zendframework/zend-stdlib/src/Hydrator/Strategy/StrategyInterface.php b/vendor/zendframework/zend-stdlib/src/Hydrator/Strategy/StrategyInterface.php deleted file mode 100644 index 562ec4b..0000000 --- a/vendor/zendframework/zend-stdlib/src/Hydrator/Strategy/StrategyInterface.php +++ /dev/null @@ -1,34 +0,0 @@ -metadata[$spec] = $value; - return $this; - } - if (!is_array($spec) && !$spec instanceof Traversable) { - throw new Exception\InvalidArgumentException(sprintf( - 'Expected a string, array, or Traversable argument in first position; received "%s"', - (is_object($spec) ? get_class($spec) : gettype($spec)) - )); - } - foreach ($spec as $key => $value) { - $this->metadata[$key] = $value; - } - return $this; - } - - /** - * Retrieve all metadata or a single metadatum as specified by key - * - * @param null|string|int $key - * @param null|mixed $default - * @throws Exception\InvalidArgumentException - * @return mixed - */ - public function getMetadata($key = null, $default = null) - { - if (null === $key) { - return $this->metadata; - } - - if (!is_scalar($key)) { - throw new Exception\InvalidArgumentException('Non-scalar argument provided for key'); - } - - if (array_key_exists($key, $this->metadata)) { - return $this->metadata[$key]; - } - - return $default; - } - - /** - * Set message content - * - * @param mixed $value - * @return Message - */ - public function setContent($value) - { - $this->content = $value; - return $this; - } - - /** - * Get message content - * - * @return mixed - */ - public function getContent() - { - return $this->content; - } - - /** - * @return string - */ - public function toString() - { - $request = ''; - foreach ($this->getMetadata() as $key => $value) { - $request .= sprintf( - "%s: %s\r\n", - (string) $key, - (string) $value - ); - } - $request .= "\r\n" . $this->getContent(); - return $request; - } -} diff --git a/vendor/zendframework/zend-stdlib/src/MessageInterface.php b/vendor/zendframework/zend-stdlib/src/MessageInterface.php deleted file mode 100644 index 28d8857..0000000 --- a/vendor/zendframework/zend-stdlib/src/MessageInterface.php +++ /dev/null @@ -1,44 +0,0 @@ -exchangeArray($values); - } - - /** - * Populate from query string - * - * @param string $string - * @return void - */ - public function fromString($string) - { - $array = array(); - parse_str($string, $array); - $this->fromArray($array); - } - - /** - * Serialize to native PHP array - * - * @return array - */ - public function toArray() - { - return $this->getArrayCopy(); - } - - /** - * Serialize to query string - * - * @return string - */ - public function toString() - { - return http_build_query($this); - } - - /** - * Retrieve by key - * - * Returns null if the key does not exist. - * - * @param string $name - * @return mixed - */ - public function offsetGet($name) - { - if ($this->offsetExists($name)) { - return parent::offsetGet($name); - } - return; - } - - /** - * @param string $name - * @param mixed $default optional default value - * @return mixed - */ - public function get($name, $default = null) - { - if ($this->offsetExists($name)) { - return parent::offsetGet($name); - } - return $default; - } - - /** - * @param string $name - * @param mixed $value - * @return Parameters - */ - public function set($name, $value) - { - $this[$name] = $value; - return $this; - } -} diff --git a/vendor/zendframework/zend-stdlib/src/ParametersInterface.php b/vendor/zendframework/zend-stdlib/src/ParametersInterface.php deleted file mode 100644 index feeda58..0000000 --- a/vendor/zendframework/zend-stdlib/src/ParametersInterface.php +++ /dev/null @@ -1,86 +0,0 @@ -sorted = false; - $this->count++; - - $this->items[$name] = array( - 'data' => $value, - 'priority' => (int) $priority, - 'serial' => $this->serial++, - ); - } - - /** - * @param string $name - * @param int $priority - * - * @return $this - * - * @throws \Exception - */ - public function setPriority($name, $priority) - { - if (!isset($this->items[$name])) { - throw new \Exception("item $name not found"); - } - - $this->items[$name]['priority'] = (int) $priority; - $this->sorted = false; - - return $this; - } - - /** - * Remove a item. - * - * @param string $name - * @return void - */ - public function remove($name) - { - if (isset($this->items[$name])) { - $this->count--; - } - - unset($this->items[$name]); - } - - /** - * Remove all items. - * - * @return void - */ - public function clear() - { - $this->items = array(); - $this->serial = 0; - $this->count = 0; - $this->sorted = false; - } - - /** - * Get a item. - * - * @param string $name - * @return mixed - */ - public function get($name) - { - if (!isset($this->items[$name])) { - return; - } - - return $this->items[$name]['data']; - } - - /** - * Sort all items. - * - * @return void - */ - protected function sort() - { - if (!$this->sorted) { - uasort($this->items, array($this, 'compare')); - $this->sorted = true; - } - } - - /** - * Compare the priority of two items. - * - * @param array $item1, - * @param array $item2 - * @return int - */ - protected function compare(array $item1, array $item2) - { - return ($item1['priority'] === $item2['priority']) - ? ($item1['serial'] > $item2['serial'] ? -1 : 1) * $this->isLIFO - : ($item1['priority'] > $item2['priority'] ? -1 : 1); - } - - /** - * Get/Set serial order mode - * - * @param bool|null $flag - * - * @return bool - */ - public function isLIFO($flag = null) - { - if ($flag !== null) { - $isLifo = $flag === true ? 1 : -1; - - if ($isLifo !== $this->isLIFO) { - $this->isLIFO = $isLifo; - $this->sorted = false; - } - } - - return 1 === $this->isLIFO; - } - - /** - * {@inheritDoc} - */ - public function rewind() - { - $this->sort(); - reset($this->items); - } - - /** - * {@inheritDoc} - */ - public function current() - { - $this->sorted || $this->sort(); - $node = current($this->items); - - return $node ? $node['data'] : false; - } - - /** - * {@inheritDoc} - */ - public function key() - { - $this->sorted || $this->sort(); - return key($this->items); - } - - /** - * {@inheritDoc} - */ - public function next() - { - $node = next($this->items); - - return $node ? $node['data'] : false; - } - - /** - * {@inheritDoc} - */ - public function valid() - { - return current($this->items) !== false; - } - - /** - * @return self - */ - public function getIterator() - { - return clone $this; - } - - /** - * {@inheritDoc} - */ - public function count() - { - return $this->count; - } - - /** - * Return list as array - * - * @param int $flag - * - * @return array - */ - public function toArray($flag = self::EXTR_DATA) - { - $this->sort(); - - if ($flag == self::EXTR_BOTH) { - return $this->items; - } - - return array_map( - function ($item) use ($flag) { - return ($flag == PriorityList::EXTR_PRIORITY) ? $item['priority'] : $item['data']; - }, - $this->items - ); - } -} diff --git a/vendor/zendframework/zend-stdlib/src/PriorityQueue.php b/vendor/zendframework/zend-stdlib/src/PriorityQueue.php deleted file mode 100644 index 1baf44e..0000000 --- a/vendor/zendframework/zend-stdlib/src/PriorityQueue.php +++ /dev/null @@ -1,301 +0,0 @@ -items[] = array( - 'data' => $data, - 'priority' => $priority, - ); - $this->getQueue()->insert($data, $priority); - return $this; - } - - /** - * Remove an item from the queue - * - * This is different than {@link extract()}; its purpose is to dequeue an - * item. - * - * This operation is potentially expensive, as it requires - * re-initialization and re-population of the inner queue. - * - * Note: this removes the first item matching the provided item found. If - * the same item has been added multiple times, it will not remove other - * instances. - * - * @param mixed $datum - * @return bool False if the item was not found, true otherwise. - */ - public function remove($datum) - { - $found = false; - foreach ($this->items as $key => $item) { - if ($item['data'] === $datum) { - $found = true; - break; - } - } - if ($found) { - unset($this->items[$key]); - $this->queue = null; - - if (!$this->isEmpty()) { - $queue = $this->getQueue(); - foreach ($this->items as $item) { - $queue->insert($item['data'], $item['priority']); - } - } - return true; - } - return false; - } - - /** - * Is the queue empty? - * - * @return bool - */ - public function isEmpty() - { - return (0 === $this->count()); - } - - /** - * How many items are in the queue? - * - * @return int - */ - public function count() - { - return count($this->items); - } - - /** - * Peek at the top node in the queue, based on priority. - * - * @return mixed - */ - public function top() - { - return $this->getIterator()->top(); - } - - /** - * Extract a node from the inner queue and sift up - * - * @return mixed - */ - public function extract() - { - return $this->getQueue()->extract(); - } - - /** - * Retrieve the inner iterator - * - * SplPriorityQueue acts as a heap, which typically implies that as items - * are iterated, they are also removed. This does not work for situations - * where the queue may be iterated multiple times. As such, this class - * aggregates the values, and also injects an SplPriorityQueue. This method - * retrieves the inner queue object, and clones it for purposes of - * iteration. - * - * @return SplPriorityQueue - */ - public function getIterator() - { - $queue = $this->getQueue(); - return clone $queue; - } - - /** - * Serialize the data structure - * - * @return string - */ - public function serialize() - { - return serialize($this->items); - } - - /** - * Unserialize a string into a PriorityQueue object - * - * Serialization format is compatible with {@link Zend\Stdlib\SplPriorityQueue} - * - * @param string $data - * @return void - */ - public function unserialize($data) - { - foreach (unserialize($data) as $item) { - $this->insert($item['data'], $item['priority']); - } - } - - /** - * Serialize to an array - * - * By default, returns only the item data, and in the order registered (not - * sorted). You may provide one of the EXTR_* flags as an argument, allowing - * the ability to return priorities or both data and priority. - * - * @param int $flag - * @return array - */ - public function toArray($flag = self::EXTR_DATA) - { - switch ($flag) { - case self::EXTR_BOTH: - return $this->items; - case self::EXTR_PRIORITY: - return array_map(function ($item) { - return $item['priority']; - }, $this->items); - case self::EXTR_DATA: - default: - return array_map(function ($item) { - return $item['data']; - }, $this->items); - } - } - - /** - * Specify the internal queue class - * - * Please see {@link getIterator()} for details on the necessity of an - * internal queue class. The class provided should extend SplPriorityQueue. - * - * @param string $class - * @return PriorityQueue - */ - public function setInternalQueueClass($class) - { - $this->queueClass = (string) $class; - return $this; - } - - /** - * Does the queue contain the given datum? - * - * @param mixed $datum - * @return bool - */ - public function contains($datum) - { - foreach ($this->items as $item) { - if ($item['data'] === $datum) { - return true; - } - } - return false; - } - - /** - * Does the queue have an item with the given priority? - * - * @param int $priority - * @return bool - */ - public function hasPriority($priority) - { - foreach ($this->items as $item) { - if ($item['priority'] === $priority) { - return true; - } - } - return false; - } - - /** - * Get the inner priority queue instance - * - * @throws Exception\DomainException - * @return SplPriorityQueue - */ - protected function getQueue() - { - if (null === $this->queue) { - $this->queue = new $this->queueClass(); - if (!$this->queue instanceof \SplPriorityQueue) { - throw new Exception\DomainException(sprintf( - 'PriorityQueue expects an internal queue of type SplPriorityQueue; received "%s"', - get_class($this->queue) - )); - } - } - return $this->queue; - } - - /** - * Add support for deep cloning - * - * @return void - */ - public function __clone() - { - if (null !== $this->queue) { - $this->queue = clone $this->queue; - } - } -} diff --git a/vendor/zendframework/zend-stdlib/src/Request.php b/vendor/zendframework/zend-stdlib/src/Request.php deleted file mode 100644 index 7c08403..0000000 --- a/vendor/zendframework/zend-stdlib/src/Request.php +++ /dev/null @@ -1,15 +0,0 @@ -serial--); - } - parent::insert($datum, $priority); - } - - /** - * Serialize to an array - * - * Array will be priority => data pairs - * - * @return array - */ - public function toArray() - { - $array = array(); - foreach (clone $this as $item) { - $array[] = $item; - } - return $array; - } - - /** - * Serialize - * - * @return string - */ - public function serialize() - { - $clone = clone $this; - $clone->setExtractFlags(self::EXTR_BOTH); - - $data = array(); - foreach ($clone as $item) { - $data[] = $item; - } - - return serialize($data); - } - - /** - * Deserialize - * - * @param string $data - * @return void - */ - public function unserialize($data) - { - foreach (unserialize($data) as $item) { - $this->insert($item['data'], $item['priority']); - } - } -} diff --git a/vendor/zendframework/zend-stdlib/src/SplQueue.php b/vendor/zendframework/zend-stdlib/src/SplQueue.php deleted file mode 100644 index 029bc9f..0000000 --- a/vendor/zendframework/zend-stdlib/src/SplQueue.php +++ /dev/null @@ -1,55 +0,0 @@ -toArray()); - } - - /** - * Unserialize - * - * @param string $data - * @return void - */ - public function unserialize($data) - { - foreach (unserialize($data) as $item) { - $this->push($item); - } - } -} diff --git a/vendor/zendframework/zend-stdlib/src/SplStack.php b/vendor/zendframework/zend-stdlib/src/SplStack.php deleted file mode 100644 index fac77a5..0000000 --- a/vendor/zendframework/zend-stdlib/src/SplStack.php +++ /dev/null @@ -1,55 +0,0 @@ -toArray()); - } - - /** - * Unserialize - * - * @param string $data - * @return void - */ - public function unserialize($data) - { - foreach (unserialize($data) as $item) { - $this->unshift($item); - } - } -} diff --git a/vendor/zendframework/zend-stdlib/src/StringUtils.php b/vendor/zendframework/zend-stdlib/src/StringUtils.php deleted file mode 100644 index 9bbb4a4..0000000 --- a/vendor/zendframework/zend-stdlib/src/StringUtils.php +++ /dev/null @@ -1,187 +0,0 @@ -setEncoding($encoding, $convertEncoding); - return $wrapper; - } - } - - throw new Exception\RuntimeException( - 'No wrapper found supporting "' . $encoding . '"' - . (($convertEncoding !== null) ? ' and "' . $convertEncoding . '"' : '') - ); - } - - /** - * Get a list of all known single-byte character encodings - * - * @return string[] - */ - public static function getSingleByteEncodings() - { - return static::$singleByteEncodings; - } - - /** - * Check if a given encoding is a known single-byte character encoding - * - * @param string $encoding - * @return bool - */ - public static function isSingleByteEncoding($encoding) - { - return in_array(strtoupper($encoding), static::$singleByteEncodings); - } - - /** - * Check if a given string is valid UTF-8 encoded - * - * @param string $str - * @return bool - */ - public static function isValidUtf8($str) - { - return is_string($str) && ($str === '' || preg_match('/^./su', $str) == 1); - } - - /** - * Is PCRE compiled with Unicode support? - * - * @return bool - */ - public static function hasPcreUnicodeSupport() - { - if (static::$hasPcreUnicodeSupport === null) { - ErrorHandler::start(); - static::$hasPcreUnicodeSupport = defined('PREG_BAD_UTF8_OFFSET_ERROR') && preg_match('/\pL/u', 'a') == 1; - ErrorHandler::stop(); - } - return static::$hasPcreUnicodeSupport; - } -} diff --git a/vendor/zendframework/zend-stdlib/src/StringWrapper/AbstractStringWrapper.php b/vendor/zendframework/zend-stdlib/src/StringWrapper/AbstractStringWrapper.php deleted file mode 100644 index 3e395cc..0000000 --- a/vendor/zendframework/zend-stdlib/src/StringWrapper/AbstractStringWrapper.php +++ /dev/null @@ -1,269 +0,0 @@ -convertEncoding = $convertEncodingUpper; - } else { - $this->convertEncoding = null; - } - $this->encoding = $encodingUpper; - - return $this; - } - - /** - * Get the defined character encoding to work with - * - * @return string - * @throws Exception\LogicException If no encoding was defined - */ - public function getEncoding() - { - return $this->encoding; - } - - /** - * Get the defined character encoding to convert to - * - * @return string|null - */ - public function getConvertEncoding() - { - return $this->convertEncoding; - } - - /** - * Convert a string from defined character encoding to the defined convert encoding - * - * @param string $str - * @param bool $reverse - * @return string|false - */ - public function convert($str, $reverse = false) - { - $encoding = $this->getEncoding(); - $convertEncoding = $this->getConvertEncoding(); - if ($convertEncoding === null) { - throw new Exception\LogicException( - 'No convert encoding defined' - ); - } - - if ($encoding === $convertEncoding) { - return $str; - } - - $from = $reverse ? $convertEncoding : $encoding; - $to = $reverse ? $encoding : $convertEncoding; - throw new Exception\RuntimeException(sprintf( - 'Converting from "%s" to "%s" isn\'t supported by this string wrapper', - $from, - $to - )); - } - - /** - * Wraps a string to a given number of characters - * - * @param string $string - * @param int $width - * @param string $break - * @param bool $cut - * @return string|false - */ - public function wordWrap($string, $width = 75, $break = "\n", $cut = false) - { - $string = (string) $string; - if ($string === '') { - return ''; - } - - $break = (string) $break; - if ($break === '') { - throw new Exception\InvalidArgumentException('Break string cannot be empty'); - } - - $width = (int) $width; - if ($width === 0 && $cut) { - throw new Exception\InvalidArgumentException('Cannot force cut when width is zero'); - } - - if (StringUtils::isSingleByteEncoding($this->getEncoding())) { - return wordwrap($string, $width, $break, $cut); - } - - $stringWidth = $this->strlen($string); - $breakWidth = $this->strlen($break); - - $result = ''; - $lastStart = $lastSpace = 0; - - for ($current = 0; $current < $stringWidth; $current++) { - $char = $this->substr($string, $current, 1); - - $possibleBreak = $char; - if ($breakWidth !== 1) { - $possibleBreak = $this->substr($string, $current, $breakWidth); - } - - if ($possibleBreak === $break) { - $result .= $this->substr($string, $lastStart, $current - $lastStart + $breakWidth); - $current += $breakWidth - 1; - $lastStart = $lastSpace = $current + 1; - continue; - } - - if ($char === ' ') { - if ($current - $lastStart >= $width) { - $result .= $this->substr($string, $lastStart, $current - $lastStart) . $break; - $lastStart = $current + 1; - } - - $lastSpace = $current; - continue; - } - - if ($current - $lastStart >= $width && $cut && $lastStart >= $lastSpace) { - $result .= $this->substr($string, $lastStart, $current - $lastStart) . $break; - $lastStart = $lastSpace = $current; - continue; - } - - if ($current - $lastStart >= $width && $lastStart < $lastSpace) { - $result .= $this->substr($string, $lastStart, $lastSpace - $lastStart) . $break; - $lastStart = $lastSpace = $lastSpace + 1; - continue; - } - } - - if ($lastStart !== $current) { - $result .= $this->substr($string, $lastStart, $current - $lastStart); - } - - return $result; - } - - /** - * Pad a string to a certain length with another string - * - * @param string $input - * @param int $padLength - * @param string $padString - * @param int $padType - * @return string - */ - public function strPad($input, $padLength, $padString = ' ', $padType = STR_PAD_RIGHT) - { - if (StringUtils::isSingleByteEncoding($this->getEncoding())) { - return str_pad($input, $padLength, $padString, $padType); - } - - $lengthOfPadding = $padLength - $this->strlen($input); - if ($lengthOfPadding <= 0) { - return $input; - } - - $padStringLength = $this->strlen($padString); - if ($padStringLength === 0) { - return $input; - } - - $repeatCount = floor($lengthOfPadding / $padStringLength); - - if ($padType === STR_PAD_BOTH) { - $repeatCountLeft = $repeatCountRight = ($repeatCount - $repeatCount % 2) / 2; - - $lastStringLength = $lengthOfPadding - 2 * $repeatCountLeft * $padStringLength; - $lastStringLeftLength = $lastStringRightLength = floor($lastStringLength / 2); - $lastStringRightLength += $lastStringLength % 2; - - $lastStringLeft = $this->substr($padString, 0, $lastStringLeftLength); - $lastStringRight = $this->substr($padString, 0, $lastStringRightLength); - - return str_repeat($padString, $repeatCountLeft) . $lastStringLeft - . $input - . str_repeat($padString, $repeatCountRight) . $lastStringRight; - } - - $lastString = $this->substr($padString, 0, $lengthOfPadding % $padStringLength); - - if ($padType === STR_PAD_LEFT) { - return str_repeat($padString, $repeatCount) . $lastString . $input; - } - - return $input . str_repeat($padString, $repeatCount) . $lastString; - } -} diff --git a/vendor/zendframework/zend-stdlib/src/StringWrapper/Iconv.php b/vendor/zendframework/zend-stdlib/src/StringWrapper/Iconv.php deleted file mode 100644 index 04930ff..0000000 --- a/vendor/zendframework/zend-stdlib/src/StringWrapper/Iconv.php +++ /dev/null @@ -1,289 +0,0 @@ -getEncoding()); - } - - /** - * Returns the portion of string specified by the start and length parameters - * - * @param string $str - * @param int $offset - * @param int|null $length - * @return string|false - */ - public function substr($str, $offset = 0, $length = null) - { - return iconv_substr($str, $offset, $length, $this->getEncoding()); - } - - /** - * Find the position of the first occurrence of a substring in a string - * - * @param string $haystack - * @param string $needle - * @param int $offset - * @return int|false - */ - public function strpos($haystack, $needle, $offset = 0) - { - return iconv_strpos($haystack, $needle, $offset, $this->getEncoding()); - } - - /** - * Convert a string from defined encoding to the defined convert encoding - * - * @param string $str - * @param bool $reverse - * @return string|false - */ - public function convert($str, $reverse = false) - { - $encoding = $this->getEncoding(); - $convertEncoding = $this->getConvertEncoding(); - if ($convertEncoding === null) { - throw new Exception\LogicException( - 'No convert encoding defined' - ); - } - - if ($encoding === $convertEncoding) { - return $str; - } - - $fromEncoding = $reverse ? $convertEncoding : $encoding; - $toEncoding = $reverse ? $encoding : $convertEncoding; - - // automatically add "//IGNORE" to not stop converting on invalid characters - // invalid characters triggers a notice anyway - return iconv($fromEncoding, $toEncoding . '//IGNORE', $str); - } -} diff --git a/vendor/zendframework/zend-stdlib/src/StringWrapper/Intl.php b/vendor/zendframework/zend-stdlib/src/StringWrapper/Intl.php deleted file mode 100644 index 1b01277..0000000 --- a/vendor/zendframework/zend-stdlib/src/StringWrapper/Intl.php +++ /dev/null @@ -1,88 +0,0 @@ -getEncoding()); - } - - /** - * Returns the portion of string specified by the start and length parameters - * - * @param string $str - * @param int $offset - * @param int|null $length - * @return string|false - */ - public function substr($str, $offset = 0, $length = null) - { - return mb_substr($str, $offset, $length, $this->getEncoding()); - } - - /** - * Find the position of the first occurrence of a substring in a string - * - * @param string $haystack - * @param string $needle - * @param int $offset - * @return int|false - */ - public function strpos($haystack, $needle, $offset = 0) - { - return mb_strpos($haystack, $needle, $offset, $this->getEncoding()); - } - - /** - * Convert a string from defined encoding to the defined convert encoding - * - * @param string $str - * @param bool $reverse - * @return string|false - */ - public function convert($str, $reverse = false) - { - $encoding = $this->getEncoding(); - $convertEncoding = $this->getConvertEncoding(); - - if ($convertEncoding === null) { - throw new Exception\LogicException( - 'No convert encoding defined' - ); - } - - if ($encoding === $convertEncoding) { - return $str; - } - - $fromEncoding = $reverse ? $convertEncoding : $encoding; - $toEncoding = $reverse ? $encoding : $convertEncoding; - return mb_convert_encoding($str, $toEncoding, $fromEncoding); - } -} diff --git a/vendor/zendframework/zend-stdlib/src/StringWrapper/Native.php b/vendor/zendframework/zend-stdlib/src/StringWrapper/Native.php deleted file mode 100644 index 38b3c10..0000000 --- a/vendor/zendframework/zend-stdlib/src/StringWrapper/Native.php +++ /dev/null @@ -1,134 +0,0 @@ -convertEncoding = $encodingUpper; - } - - if ($convertEncoding !== null) { - if ($encodingUpper !== strtoupper($convertEncoding)) { - throw new Exception\InvalidArgumentException( - 'Wrapper doesn\'t support to convert between character encodings' - ); - } - - $this->convertEncoding = $encodingUpper; - } else { - $this->convertEncoding = null; - } - $this->encoding = $encodingUpper; - - return $this; - } - - /** - * Returns the length of the given string - * - * @param string $str - * @return int|false - */ - public function strlen($str) - { - return strlen($str); - } - - /** - * Returns the portion of string specified by the start and length parameters - * - * @param string $str - * @param int $offset - * @param int|null $length - * @return string|false - */ - public function substr($str, $offset = 0, $length = null) - { - return substr($str, $offset, $length); - } - - /** - * Find the position of the first occurrence of a substring in a string - * - * @param string $haystack - * @param string $needle - * @param int $offset - * @return int|false - */ - public function strpos($haystack, $needle, $offset = 0) - { - return strpos($haystack, $needle, $offset); - } -} diff --git a/vendor/zendframework/zend-stdlib/src/StringWrapper/StringWrapperInterface.php b/vendor/zendframework/zend-stdlib/src/StringWrapper/StringWrapperInterface.php deleted file mode 100644 index f25b325..0000000 --- a/vendor/zendframework/zend-stdlib/src/StringWrapper/StringWrapperInterface.php +++ /dev/null @@ -1,111 +0,0 @@ -